diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2009-05-26 14:50:28 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-05-27 06:26:01 -0400 |
commit | a5b1cf288d4200506ab62fbb86cc81ace948a306 (patch) | |
tree | c95339866f4d67220d111811a92e5c6b79de6ab4 /include/linux/netdevice.h | |
parent | 7489594cb249aeb178287c9a43a9e4f366044259 (diff) |
gro: Avoid unnecessary comparison after skb_gro_header
For the overwhelming majority of cases, skb_gro_header's return
value cannot be NULL. Yet we must check it because of its current
form. This patch splits it up into multiple functions in order
to avoid this.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r-- | include/linux/netdevice.h | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 2e44a049be0f..371ece521e58 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -1132,18 +1132,23 @@ static inline void skb_gro_pull(struct sk_buff *skb, unsigned int len) | |||
1132 | NAPI_GRO_CB(skb)->data_offset += len; | 1132 | NAPI_GRO_CB(skb)->data_offset += len; |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | static inline void *skb_gro_header(struct sk_buff *skb, unsigned int hlen) | 1135 | static inline void *skb_gro_header_fast(struct sk_buff *skb, |
1136 | unsigned int offset) | ||
1136 | { | 1137 | { |
1137 | unsigned int offset = skb_gro_offset(skb); | 1138 | return NAPI_GRO_CB(skb)->frag0 + offset; |
1139 | } | ||
1138 | 1140 | ||
1139 | hlen += offset; | 1141 | static inline int skb_gro_header_hard(struct sk_buff *skb, unsigned int hlen) |
1140 | if (NAPI_GRO_CB(skb)->frag0_len < hlen) { | 1142 | { |
1141 | NAPI_GRO_CB(skb)->frag0 = NULL; | 1143 | return NAPI_GRO_CB(skb)->frag0_len < hlen; |
1142 | NAPI_GRO_CB(skb)->frag0_len = 0; | 1144 | } |
1143 | return pskb_may_pull(skb, hlen) ? skb->data + offset : NULL; | ||
1144 | } | ||
1145 | 1145 | ||
1146 | return NAPI_GRO_CB(skb)->frag0 + offset; | 1146 | static inline void *skb_gro_header_slow(struct sk_buff *skb, unsigned int hlen, |
1147 | unsigned int offset) | ||
1148 | { | ||
1149 | NAPI_GRO_CB(skb)->frag0 = NULL; | ||
1150 | NAPI_GRO_CB(skb)->frag0_len = 0; | ||
1151 | return pskb_may_pull(skb, hlen) ? skb->data + offset : NULL; | ||
1147 | } | 1152 | } |
1148 | 1153 | ||
1149 | static inline void *skb_gro_mac_header(struct sk_buff *skb) | 1154 | static inline void *skb_gro_mac_header(struct sk_buff *skb) |