aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-02-08 13:00:39 -0500
committerDavid S. Miller <davem@davemloft.net>2009-02-08 23:22:19 -0500
commita5ad24be728d4352b71a81fba471aa41eb71f83a (patch)
treecdba82286ec2ef470fc4ae9531f6ccb14b0f2970 /net
parentaa4b9f533ed5a22952e038b9fac2447ccc682124 (diff)
gro: Optimise IPv4 packet reception
As this function can be called more than half a million times for 10GbE, it's important to optimise it as much as we can. This patch does some obvious changes to use 2-byte and 4-byte operations instead of byte-oriented ones where possible. Bit ops are also used to replace logical ops to reduce branching. 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/ipv4/af_inet.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index c79087719df0..627be4dc7fb0 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1263,7 +1263,7 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head,
1263 if (!ops || !ops->gro_receive) 1263 if (!ops || !ops->gro_receive)
1264 goto out_unlock; 1264 goto out_unlock;
1265 1265
1266 if (iph->version != 4 || iph->ihl != 5) 1266 if (*(u8 *)iph != 0x45)
1267 goto out_unlock; 1267 goto out_unlock;
1268 1268
1269 if (unlikely(ip_fast_csum((u8 *)iph, iph->ihl))) 1269 if (unlikely(ip_fast_csum((u8 *)iph, iph->ihl)))
@@ -1281,17 +1281,18 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head,
1281 1281
1282 iph2 = ip_hdr(p); 1282 iph2 = ip_hdr(p);
1283 1283
1284 if (iph->protocol != iph2->protocol || 1284 if ((iph->protocol ^ iph2->protocol) |
1285 iph->tos != iph2->tos || 1285 (iph->tos ^ iph2->tos) |
1286 memcmp(&iph->saddr, &iph2->saddr, 8)) { 1286 (iph->saddr ^ iph2->saddr) |
1287 (iph->daddr ^ iph2->daddr)) {
1287 NAPI_GRO_CB(p)->same_flow = 0; 1288 NAPI_GRO_CB(p)->same_flow = 0;
1288 continue; 1289 continue;
1289 } 1290 }
1290 1291
1291 /* All fields must match except length and checksum. */ 1292 /* All fields must match except length and checksum. */
1292 NAPI_GRO_CB(p)->flush |= 1293 NAPI_GRO_CB(p)->flush |=
1293 memcmp(&iph->frag_off, &iph2->frag_off, 4) || 1294 (iph->ttl ^ iph2->ttl) |
1294 (u16)(ntohs(iph2->id) + NAPI_GRO_CB(p)->count) != id; 1295 ((u16)(ntohs(iph2->id) + NAPI_GRO_CB(p)->count) ^ id);
1295 1296
1296 NAPI_GRO_CB(p)->flush |= flush; 1297 NAPI_GRO_CB(p)->flush |= flush;
1297 } 1298 }