Softnet_data的初始化: 每个CPU的softnet_data是在net_dev_init中初始化的,代码如下: 1 "/net/core/dev.c" "static int __init net_dev_init(void)" 2 for_each_possible_cpu(i) { 3 struct softnet_data *queue; 5 queue = &per_cpu(softnet_data, i); 6 skb_queue_head_init(&queue->input_pkt_queue); 7 queue->completion_queue = NULL; 8 INIT_LIST_HEAD(&queue->poll_list); 9 10 queue->backlog.poll = process_backlog; 11 queue->backlog.weight = weight_p; 12 queue->backlog.gro_list = NULL; 13 queue->backlog.gro_count = 0; 14 } 15 16 "include/linux/netdevice.h" 17 struct softnet_data 18 { 19 struct Qdisc *output_queue; 20 struct sk_buff_head input_pkt_queue; 21 struct list_head poll_list; 22 struct sk_buff *completion_queue; 23 24 struct napi_struct backlog; 25 }; 26 27 struct napi_struct { 28 /* The poll_list must only be managed by the entity which 29 * changes the state of the NAPI_STATE_SCHED bit. This means 30 * whoever atomically sets that bit can add this napi_struct 31 * to the per-cpu poll_list, and whoever clears that bit 32 * can remove from the list right before clearing the bit. 33 */ 34 struct list_head poll_list; 35 36 unsigned long state; 37 int weight; 38 int (*poll)(struct napi_struct *, int); 39 #ifdef CONFIG_NETPOLL 40 spinlock_t poll_lock; 41 int poll_owner; 42 #endif 43 44 unsigned int gro_count; 45 46 struct net_device *dev; 47 struct list_head dev_list; 48 struct sk_buff *gro_list; 49 struct sk_buff *skb; 50 };