1. NAPI: NAPI的核心在于,在一个繁忙的网络,不需要用中断驱动的方式收包,而是可以使用轮询。
2. Newer NAPI: 不要认为我写错,的确是"Newer NAPI",这是NAPI的一种演化,其核心在于增加了一个新的结构体struct napi_struct,它不是 net_device 的一部分,因此,现在struct napi_struct和 net_device 的关联被弱化了。 一个最主要的好处是如果设备驱动愿意,它可以创建多个napi_struct
structur, 与此同时,硬件能使用诸如亲和性( CPU affinity)等来支持多个接收队列,而多个 NAPI 使得队列的有效性的实施更加方便。
// netdevice.h
/*
* Structure for NAPI scheduling similar to tasklet but with weighting
*/
struct napi_struct {
/* The poll_list must only be managed by the entity which
* changes the state of the NAPI_STATE_SCHED bit. This means
* whoever atomically sets that bit can add this napi_struct
* to the per-cpu poll_list, and whoever clears that bit
* can remove from the list right before clearing the bit.
*/
struct list_head poll_list;
unsigned long state;
int weight;
int (*poll)(struct napi_struct *, int);
#ifdef CONFIG_NETPOLL
spinlock_t poll_lock;
int poll_owner;
#endif
unsigned int gro_count;
struct net_device *dev;
struct list_head dev_list;
struct sk_buff *gro_list;
struct sk_buff *skb;
};
阅读(1402) | 评论(0) | 转发(0) |