diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2009-01-29 09:19:48 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-01-29 19:33:02 -0500 |
commit | 5d0d9be8ef456afc6c3fb5f8aad06ef19b704b05 (patch) | |
tree | 9fc987d5c6850800a83465105af43af4ce9c76a4 /net | |
parent | 7019298a2a5058c4e324494d6c8d0598214c28f4 (diff) |
gro: Move common completion code into helpers
Currently VLAN still has a bit of common code handling the aftermath
of GRO that's shared with the common path. This patch moves them
into shared helpers to reduce code duplication.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/8021q/vlan_core.c | 39 | ||||
-rw-r--r-- | net/core/dev.c | 76 |
2 files changed, 56 insertions, 59 deletions
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c index e9db889d6222..2eb057a74654 100644 --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c | |||
@@ -98,22 +98,7 @@ drop: | |||
98 | int vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp, | 98 | int vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp, |
99 | unsigned int vlan_tci, struct sk_buff *skb) | 99 | unsigned int vlan_tci, struct sk_buff *skb) |
100 | { | 100 | { |
101 | int err = NET_RX_SUCCESS; | 101 | return napi_skb_finish(vlan_gro_common(napi, grp, vlan_tci, skb), skb); |
102 | |||
103 | switch (vlan_gro_common(napi, grp, vlan_tci, skb)) { | ||
104 | case -1: | ||
105 | return netif_receive_skb(skb); | ||
106 | |||
107 | case 2: | ||
108 | err = NET_RX_DROP; | ||
109 | /* fall through */ | ||
110 | |||
111 | case 1: | ||
112 | kfree_skb(skb); | ||
113 | break; | ||
114 | } | ||
115 | |||
116 | return err; | ||
117 | } | 102 | } |
118 | EXPORT_SYMBOL(vlan_gro_receive); | 103 | EXPORT_SYMBOL(vlan_gro_receive); |
119 | 104 | ||
@@ -121,27 +106,11 @@ int vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp, | |||
121 | unsigned int vlan_tci, struct napi_gro_fraginfo *info) | 106 | unsigned int vlan_tci, struct napi_gro_fraginfo *info) |
122 | { | 107 | { |
123 | struct sk_buff *skb = napi_fraginfo_skb(napi, info); | 108 | struct sk_buff *skb = napi_fraginfo_skb(napi, info); |
124 | int err = NET_RX_DROP; | ||
125 | 109 | ||
126 | if (!skb) | 110 | if (!skb) |
127 | goto out; | 111 | return NET_RX_DROP; |
128 | |||
129 | err = NET_RX_SUCCESS; | ||
130 | |||
131 | switch (vlan_gro_common(napi, grp, vlan_tci, skb)) { | ||
132 | case -1: | ||
133 | return netif_receive_skb(skb); | ||
134 | |||
135 | case 2: | ||
136 | err = NET_RX_DROP; | ||
137 | /* fall through */ | ||
138 | |||
139 | case 1: | ||
140 | napi_reuse_skb(napi, skb); | ||
141 | break; | ||
142 | } | ||
143 | 112 | ||
144 | out: | 113 | return napi_frags_finish(napi, skb, |
145 | return err; | 114 | vlan_gro_common(napi, grp, vlan_tci, skb)); |
146 | } | 115 | } |
147 | EXPORT_SYMBOL(vlan_gro_frags); | 116 | EXPORT_SYMBOL(vlan_gro_frags); |
diff --git a/net/core/dev.c b/net/core/dev.c index e61b95c11fc0..cd23ae15a1d5 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -135,6 +135,14 @@ | |||
135 | /* This should be increased if a protocol with a bigger head is added. */ | 135 | /* This should be increased if a protocol with a bigger head is added. */ |
136 | #define GRO_MAX_HEAD (MAX_HEADER + 128) | 136 | #define GRO_MAX_HEAD (MAX_HEADER + 128) |
137 | 137 | ||
138 | enum { | ||
139 | GRO_MERGED, | ||
140 | GRO_MERGED_FREE, | ||
141 | GRO_HELD, | ||
142 | GRO_NORMAL, | ||
143 | GRO_DROP, | ||
144 | }; | ||
145 | |||
138 | /* | 146 | /* |
139 | * The list of packet types we will receive (as opposed to discard) | 147 | * The list of packet types we will receive (as opposed to discard) |
140 | * and the routines to invoke. | 148 | * and the routines to invoke. |
@@ -2369,7 +2377,7 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb) | |||
2369 | int count = 0; | 2377 | int count = 0; |
2370 | int same_flow; | 2378 | int same_flow; |
2371 | int mac_len; | 2379 | int mac_len; |
2372 | int free; | 2380 | int ret; |
2373 | 2381 | ||
2374 | if (!(skb->dev->features & NETIF_F_GRO)) | 2382 | if (!(skb->dev->features & NETIF_F_GRO)) |
2375 | goto normal; | 2383 | goto normal; |
@@ -2412,7 +2420,7 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb) | |||
2412 | goto normal; | 2420 | goto normal; |
2413 | 2421 | ||
2414 | same_flow = NAPI_GRO_CB(skb)->same_flow; | 2422 | same_flow = NAPI_GRO_CB(skb)->same_flow; |
2415 | free = NAPI_GRO_CB(skb)->free; | 2423 | ret = NAPI_GRO_CB(skb)->free ? GRO_MERGED_FREE : GRO_MERGED; |
2416 | 2424 | ||
2417 | if (pp) { | 2425 | if (pp) { |
2418 | struct sk_buff *nskb = *pp; | 2426 | struct sk_buff *nskb = *pp; |
@@ -2435,12 +2443,13 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb) | |||
2435 | skb_shinfo(skb)->gso_size = skb->len; | 2443 | skb_shinfo(skb)->gso_size = skb->len; |
2436 | skb->next = napi->gro_list; | 2444 | skb->next = napi->gro_list; |
2437 | napi->gro_list = skb; | 2445 | napi->gro_list = skb; |
2446 | ret = GRO_HELD; | ||
2438 | 2447 | ||
2439 | ok: | 2448 | ok: |
2440 | return free; | 2449 | return ret; |
2441 | 2450 | ||
2442 | normal: | 2451 | normal: |
2443 | return -1; | 2452 | return GRO_NORMAL; |
2444 | } | 2453 | } |
2445 | EXPORT_SYMBOL(dev_gro_receive); | 2454 | EXPORT_SYMBOL(dev_gro_receive); |
2446 | 2455 | ||
@@ -2456,18 +2465,30 @@ static int __napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb) | |||
2456 | return dev_gro_receive(napi, skb); | 2465 | return dev_gro_receive(napi, skb); |
2457 | } | 2466 | } |
2458 | 2467 | ||
2459 | int napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb) | 2468 | int napi_skb_finish(int ret, struct sk_buff *skb) |
2460 | { | 2469 | { |
2461 | switch (__napi_gro_receive(napi, skb)) { | 2470 | int err = NET_RX_SUCCESS; |
2462 | case -1: | 2471 | |
2472 | switch (ret) { | ||
2473 | case GRO_NORMAL: | ||
2463 | return netif_receive_skb(skb); | 2474 | return netif_receive_skb(skb); |
2464 | 2475 | ||
2465 | case 1: | 2476 | case GRO_DROP: |
2477 | err = NET_RX_DROP; | ||
2478 | /* fall through */ | ||
2479 | |||
2480 | case GRO_MERGED_FREE: | ||
2466 | kfree_skb(skb); | 2481 | kfree_skb(skb); |
2467 | break; | 2482 | break; |
2468 | } | 2483 | } |
2469 | 2484 | ||
2470 | return NET_RX_SUCCESS; | 2485 | return err; |
2486 | } | ||
2487 | EXPORT_SYMBOL(napi_skb_finish); | ||
2488 | |||
2489 | int napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb) | ||
2490 | { | ||
2491 | return napi_skb_finish(__napi_gro_receive(napi, skb), skb); | ||
2471 | } | 2492 | } |
2472 | EXPORT_SYMBOL(napi_gro_receive); | 2493 | EXPORT_SYMBOL(napi_gro_receive); |
2473 | 2494 | ||
@@ -2520,29 +2541,36 @@ out: | |||
2520 | } | 2541 | } |
2521 | EXPORT_SYMBOL(napi_fraginfo_skb); | 2542 | EXPORT_SYMBOL(napi_fraginfo_skb); |
2522 | 2543 | ||
2523 | int napi_gro_frags(struct napi_struct *napi, struct napi_gro_fraginfo *info) | 2544 | int napi_frags_finish(struct napi_struct *napi, struct sk_buff *skb, int ret) |
2524 | { | 2545 | { |
2525 | struct sk_buff *skb = napi_fraginfo_skb(napi, info); | 2546 | int err = NET_RX_SUCCESS; |
2526 | int err = NET_RX_DROP; | ||
2527 | |||
2528 | if (!skb) | ||
2529 | goto out; | ||
2530 | 2547 | ||
2531 | err = NET_RX_SUCCESS; | 2548 | switch (ret) { |
2532 | 2549 | case GRO_NORMAL: | |
2533 | switch (__napi_gro_receive(napi, skb)) { | ||
2534 | case -1: | ||
2535 | return netif_receive_skb(skb); | 2550 | return netif_receive_skb(skb); |
2536 | 2551 | ||
2537 | case 0: | 2552 | case GRO_DROP: |
2538 | goto out; | 2553 | err = NET_RX_DROP; |
2539 | } | 2554 | /* fall through */ |
2540 | 2555 | ||
2541 | napi_reuse_skb(napi, skb); | 2556 | case GRO_MERGED_FREE: |
2557 | napi_reuse_skb(napi, skb); | ||
2558 | break; | ||
2559 | } | ||
2542 | 2560 | ||
2543 | out: | ||
2544 | return err; | 2561 | return err; |
2545 | } | 2562 | } |
2563 | EXPORT_SYMBOL(napi_frags_finish); | ||
2564 | |||
2565 | int napi_gro_frags(struct napi_struct *napi, struct napi_gro_fraginfo *info) | ||
2566 | { | ||
2567 | struct sk_buff *skb = napi_fraginfo_skb(napi, info); | ||
2568 | |||
2569 | if (!skb) | ||
2570 | return NET_RX_DROP; | ||
2571 | |||
2572 | return napi_frags_finish(napi, skb, __napi_gro_receive(napi, skb)); | ||
2573 | } | ||
2546 | EXPORT_SYMBOL(napi_gro_frags); | 2574 | EXPORT_SYMBOL(napi_gro_frags); |
2547 | 2575 | ||
2548 | static int process_backlog(struct napi_struct *napi, int quota) | 2576 | static int process_backlog(struct napi_struct *napi, int quota) |