aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-02-08 13:00:36 -0500
committerDavid S. Miller <davem@davemloft.net>2009-02-08 23:22:17 -0500
commit4ae5544f9a33e4ae306e337f96951eb3ff2df6d9 (patch)
tree4ca5e02345cb3a680db5ac1016e6e857ccb4a767 /net/core/dev.c
parentd6301d3dd1c287b32132dda15272a50c11e92a14 (diff)
gro: Remember number of held packets instead of counting every time
This patch prepares for the move of the same_flow checks out of dev_gro_receive. As such we need to remember the number of held packets since doing a loop just to count them every time is silly. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 709a9a922258..ae0b66936abe 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2372,6 +2372,7 @@ void napi_gro_flush(struct napi_struct *napi)
2372 napi_gro_complete(skb); 2372 napi_gro_complete(skb);
2373 } 2373 }
2374 2374
2375 napi->gro_count = 0;
2375 napi->gro_list = NULL; 2376 napi->gro_list = NULL;
2376} 2377}
2377EXPORT_SYMBOL(napi_gro_flush); 2378EXPORT_SYMBOL(napi_gro_flush);
@@ -2402,7 +2403,6 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
2402 struct packet_type *ptype; 2403 struct packet_type *ptype;
2403 __be16 type = skb->protocol; 2404 __be16 type = skb->protocol;
2404 struct list_head *head = &ptype_base[ntohs(type) & PTYPE_HASH_MASK]; 2405 struct list_head *head = &ptype_base[ntohs(type) & PTYPE_HASH_MASK];
2405 int count = 0;
2406 int same_flow; 2406 int same_flow;
2407 int mac_len; 2407 int mac_len;
2408 int ret; 2408 int ret;
@@ -2430,8 +2430,6 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
2430 NAPI_GRO_CB(skb)->free = 0; 2430 NAPI_GRO_CB(skb)->free = 0;
2431 2431
2432 for (p = napi->gro_list; p; p = p->next) { 2432 for (p = napi->gro_list; p; p = p->next) {
2433 count++;
2434
2435 if (!NAPI_GRO_CB(p)->same_flow) 2433 if (!NAPI_GRO_CB(p)->same_flow)
2436 continue; 2434 continue;
2437 2435
@@ -2457,15 +2455,16 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
2457 *pp = nskb->next; 2455 *pp = nskb->next;
2458 nskb->next = NULL; 2456 nskb->next = NULL;
2459 napi_gro_complete(nskb); 2457 napi_gro_complete(nskb);
2460 count--; 2458 napi->gro_count--;
2461 } 2459 }
2462 2460
2463 if (same_flow) 2461 if (same_flow)
2464 goto ok; 2462 goto ok;
2465 2463
2466 if (NAPI_GRO_CB(skb)->flush || count >= MAX_GRO_SKBS) 2464 if (NAPI_GRO_CB(skb)->flush || napi->gro_count >= MAX_GRO_SKBS)
2467 goto normal; 2465 goto normal;
2468 2466
2467 napi->gro_count++;
2469 NAPI_GRO_CB(skb)->count = 1; 2468 NAPI_GRO_CB(skb)->count = 1;
2470 skb_shinfo(skb)->gso_size = skb_gro_len(skb); 2469 skb_shinfo(skb)->gso_size = skb_gro_len(skb);
2471 skb->next = napi->gro_list; 2470 skb->next = napi->gro_list;
@@ -2713,6 +2712,7 @@ void netif_napi_add(struct net_device *dev, struct napi_struct *napi,
2713 int (*poll)(struct napi_struct *, int), int weight) 2712 int (*poll)(struct napi_struct *, int), int weight)
2714{ 2713{
2715 INIT_LIST_HEAD(&napi->poll_list); 2714 INIT_LIST_HEAD(&napi->poll_list);
2715 napi->gro_count = 0;
2716 napi->gro_list = NULL; 2716 napi->gro_list = NULL;
2717 napi->skb = NULL; 2717 napi->skb = NULL;
2718 napi->poll = poll; 2718 napi->poll = poll;
@@ -2741,6 +2741,7 @@ void netif_napi_del(struct napi_struct *napi)
2741 } 2741 }
2742 2742
2743 napi->gro_list = NULL; 2743 napi->gro_list = NULL;
2744 napi->gro_count = 0;
2744} 2745}
2745EXPORT_SYMBOL(netif_napi_del); 2746EXPORT_SYMBOL(netif_napi_del);
2746 2747
@@ -5246,6 +5247,7 @@ static int __init net_dev_init(void)
5246 queue->backlog.poll = process_backlog; 5247 queue->backlog.poll = process_backlog;
5247 queue->backlog.weight = weight_p; 5248 queue->backlog.weight = weight_p;
5248 queue->backlog.gro_list = NULL; 5249 queue->backlog.gro_list = NULL;
5250 queue->backlog.gro_count = 0;
5249 } 5251 }
5250 5252
5251 dev_boot_phase = 0; 5253 dev_boot_phase = 0;