Chinaunix首页 | 论坛 | 博客
  • 博客访问: 239945
  • 博文数量: 33
  • 博客积分: 2511
  • 博客等级: 少校
  • 技术积分: 391
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-06 09:24
文章分类
文章存档

2011年(3)

2010年(9)

2009年(3)

2008年(18)

我的朋友

分类: LINUX

2010-08-30 22:29:17

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;
};

阅读(1353) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~