提交 5d0d9be8 编写于 作者: H Herbert Xu 提交者: David S. Miller

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: NHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 7019298a
...@@ -1375,12 +1375,15 @@ extern int netif_receive_skb(struct sk_buff *skb); ...@@ -1375,12 +1375,15 @@ extern int netif_receive_skb(struct sk_buff *skb);
extern void napi_gro_flush(struct napi_struct *napi); extern void napi_gro_flush(struct napi_struct *napi);
extern int dev_gro_receive(struct napi_struct *napi, extern int dev_gro_receive(struct napi_struct *napi,
struct sk_buff *skb); struct sk_buff *skb);
extern int napi_skb_finish(int ret, struct sk_buff *skb);
extern int napi_gro_receive(struct napi_struct *napi, extern int napi_gro_receive(struct napi_struct *napi,
struct sk_buff *skb); struct sk_buff *skb);
extern void napi_reuse_skb(struct napi_struct *napi, extern void napi_reuse_skb(struct napi_struct *napi,
struct sk_buff *skb); struct sk_buff *skb);
extern struct sk_buff * napi_fraginfo_skb(struct napi_struct *napi, extern struct sk_buff * napi_fraginfo_skb(struct napi_struct *napi,
struct napi_gro_fraginfo *info); struct napi_gro_fraginfo *info);
extern int napi_frags_finish(struct napi_struct *napi,
struct sk_buff *skb, int ret);
extern int napi_gro_frags(struct napi_struct *napi, extern int napi_gro_frags(struct napi_struct *napi,
struct napi_gro_fraginfo *info); struct napi_gro_fraginfo *info);
extern void netif_nit_deliver(struct sk_buff *skb); extern void netif_nit_deliver(struct sk_buff *skb);
......
...@@ -98,22 +98,7 @@ static int vlan_gro_common(struct napi_struct *napi, struct vlan_group *grp, ...@@ -98,22 +98,7 @@ static int vlan_gro_common(struct napi_struct *napi, struct vlan_group *grp,
int vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp, int vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp,
unsigned int vlan_tci, struct sk_buff *skb) unsigned int vlan_tci, struct sk_buff *skb)
{ {
int err = NET_RX_SUCCESS; return napi_skb_finish(vlan_gro_common(napi, grp, vlan_tci, skb), skb);
switch (vlan_gro_common(napi, grp, vlan_tci, skb)) {
case -1:
return netif_receive_skb(skb);
case 2:
err = NET_RX_DROP;
/* fall through */
case 1:
kfree_skb(skb);
break;
}
return err;
} }
EXPORT_SYMBOL(vlan_gro_receive); EXPORT_SYMBOL(vlan_gro_receive);
...@@ -121,27 +106,11 @@ int vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp, ...@@ -121,27 +106,11 @@ int vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp,
unsigned int vlan_tci, struct napi_gro_fraginfo *info) unsigned int vlan_tci, struct napi_gro_fraginfo *info)
{ {
struct sk_buff *skb = napi_fraginfo_skb(napi, info); struct sk_buff *skb = napi_fraginfo_skb(napi, info);
int err = NET_RX_DROP;
if (!skb) if (!skb)
goto out; return NET_RX_DROP;
err = NET_RX_SUCCESS;
switch (vlan_gro_common(napi, grp, vlan_tci, skb)) {
case -1:
return netif_receive_skb(skb);
case 2:
err = NET_RX_DROP;
/* fall through */
case 1:
napi_reuse_skb(napi, skb);
break;
}
out: return napi_frags_finish(napi, skb,
return err; vlan_gro_common(napi, grp, vlan_tci, skb));
} }
EXPORT_SYMBOL(vlan_gro_frags); EXPORT_SYMBOL(vlan_gro_frags);
...@@ -135,6 +135,14 @@ ...@@ -135,6 +135,14 @@
/* This should be increased if a protocol with a bigger head is added. */ /* This should be increased if a protocol with a bigger head is added. */
#define GRO_MAX_HEAD (MAX_HEADER + 128) #define GRO_MAX_HEAD (MAX_HEADER + 128)
enum {
GRO_MERGED,
GRO_MERGED_FREE,
GRO_HELD,
GRO_NORMAL,
GRO_DROP,
};
/* /*
* The list of packet types we will receive (as opposed to discard) * The list of packet types we will receive (as opposed to discard)
* and the routines to invoke. * and the routines to invoke.
...@@ -2369,7 +2377,7 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb) ...@@ -2369,7 +2377,7 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
int count = 0; int count = 0;
int same_flow; int same_flow;
int mac_len; int mac_len;
int free; int ret;
if (!(skb->dev->features & NETIF_F_GRO)) if (!(skb->dev->features & NETIF_F_GRO))
goto normal; goto normal;
...@@ -2412,7 +2420,7 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb) ...@@ -2412,7 +2420,7 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
goto normal; goto normal;
same_flow = NAPI_GRO_CB(skb)->same_flow; same_flow = NAPI_GRO_CB(skb)->same_flow;
free = NAPI_GRO_CB(skb)->free; ret = NAPI_GRO_CB(skb)->free ? GRO_MERGED_FREE : GRO_MERGED;
if (pp) { if (pp) {
struct sk_buff *nskb = *pp; struct sk_buff *nskb = *pp;
...@@ -2435,12 +2443,13 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb) ...@@ -2435,12 +2443,13 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
skb_shinfo(skb)->gso_size = skb->len; skb_shinfo(skb)->gso_size = skb->len;
skb->next = napi->gro_list; skb->next = napi->gro_list;
napi->gro_list = skb; napi->gro_list = skb;
ret = GRO_HELD;
ok: ok:
return free; return ret;
normal: normal:
return -1; return GRO_NORMAL;
} }
EXPORT_SYMBOL(dev_gro_receive); EXPORT_SYMBOL(dev_gro_receive);
...@@ -2456,18 +2465,30 @@ static int __napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb) ...@@ -2456,18 +2465,30 @@ static int __napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
return dev_gro_receive(napi, skb); return dev_gro_receive(napi, skb);
} }
int napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb) int napi_skb_finish(int ret, struct sk_buff *skb)
{ {
switch (__napi_gro_receive(napi, skb)) { int err = NET_RX_SUCCESS;
case -1:
switch (ret) {
case GRO_NORMAL:
return netif_receive_skb(skb); return netif_receive_skb(skb);
case 1: case GRO_DROP:
err = NET_RX_DROP;
/* fall through */
case GRO_MERGED_FREE:
kfree_skb(skb); kfree_skb(skb);
break; break;
} }
return NET_RX_SUCCESS; return err;
}
EXPORT_SYMBOL(napi_skb_finish);
int napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
{
return napi_skb_finish(__napi_gro_receive(napi, skb), skb);
} }
EXPORT_SYMBOL(napi_gro_receive); EXPORT_SYMBOL(napi_gro_receive);
...@@ -2520,29 +2541,36 @@ struct sk_buff *napi_fraginfo_skb(struct napi_struct *napi, ...@@ -2520,29 +2541,36 @@ struct sk_buff *napi_fraginfo_skb(struct napi_struct *napi,
} }
EXPORT_SYMBOL(napi_fraginfo_skb); EXPORT_SYMBOL(napi_fraginfo_skb);
int napi_gro_frags(struct napi_struct *napi, struct napi_gro_fraginfo *info) int napi_frags_finish(struct napi_struct *napi, struct sk_buff *skb, int ret)
{ {
struct sk_buff *skb = napi_fraginfo_skb(napi, info); int err = NET_RX_SUCCESS;
int err = NET_RX_DROP;
if (!skb) switch (ret) {
goto out; case GRO_NORMAL:
err = NET_RX_SUCCESS;
switch (__napi_gro_receive(napi, skb)) {
case -1:
return netif_receive_skb(skb); return netif_receive_skb(skb);
case 0: case GRO_DROP:
goto out; err = NET_RX_DROP;
} /* fall through */
case GRO_MERGED_FREE:
napi_reuse_skb(napi, skb); napi_reuse_skb(napi, skb);
break;
}
out:
return err; return err;
} }
EXPORT_SYMBOL(napi_frags_finish);
int napi_gro_frags(struct napi_struct *napi, struct napi_gro_fraginfo *info)
{
struct sk_buff *skb = napi_fraginfo_skb(napi, info);
if (!skb)
return NET_RX_DROP;
return napi_frags_finish(napi, skb, __napi_gro_receive(napi, skb));
}
EXPORT_SYMBOL(napi_gro_frags); EXPORT_SYMBOL(napi_gro_frags);
static int process_backlog(struct napi_struct *napi, int quota) static int process_backlog(struct napi_struct *napi, int quota)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册