summaryrefslogtreecommitdiffstats
path: root/include/linux/netdevice.h
diff options
context:
space:
mode:
authorTom Herbert <therbert@google.com>2014-08-31 18:12:42 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-02 00:36:27 -0400
commitd96535a17dbbafd567961d14c08c0984ddda9c3c (patch)
treeaa07db9a2ef6ea095f7b38ec3be18c92d4f55506 /include/linux/netdevice.h
parent5a21232983aa7acfe7fd26170832a9e0a4a7b4ae (diff)
net: Infrastructure for checksum unnecessary conversions
For normal path, added skb_checksum_try_convert which is called to attempt to convert CHECKSUM_UNNECESSARY to CHECKSUM_COMPLETE. The primary condition to allow this is that ip_summed is CHECKSUM_NONE and csum_valid is true, which will be the state after consuming a CHECKSUM_UNNECESSARY. For GRO path, added skb_gro_checksum_try_convert which is the GRO analogue of skb_checksum_try_convert. The primary condition to allow this is that NAPI_GRO_CB(skb)->csum_cnt == 0 and NAPI_GRO_CB(skb)->csum_valid is set. This implies that we have consumed all available CHECKSUM_UNNECESSARY checksums in the GRO path. Signed-off-by: Tom Herbert <therbert@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r--include/linux/netdevice.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index a0ab6d9d400a..5be20a7bbb0d 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2233,6 +2233,26 @@ static inline void skb_gro_incr_csum_unnecessary(struct sk_buff *skb)
2233#define skb_gro_checksum_simple_validate(skb) \ 2233#define skb_gro_checksum_simple_validate(skb) \
2234 __skb_gro_checksum_validate(skb, 0, false, 0, null_compute_pseudo) 2234 __skb_gro_checksum_validate(skb, 0, false, 0, null_compute_pseudo)
2235 2235
2236static inline bool __skb_gro_checksum_convert_check(struct sk_buff *skb)
2237{
2238 return (NAPI_GRO_CB(skb)->csum_cnt == 0 &&
2239 !NAPI_GRO_CB(skb)->csum_valid);
2240}
2241
2242static inline void __skb_gro_checksum_convert(struct sk_buff *skb,
2243 __sum16 check, __wsum pseudo)
2244{
2245 NAPI_GRO_CB(skb)->csum = ~pseudo;
2246 NAPI_GRO_CB(skb)->csum_valid = 1;
2247}
2248
2249#define skb_gro_checksum_try_convert(skb, proto, check, compute_pseudo) \
2250do { \
2251 if (__skb_gro_checksum_convert_check(skb)) \
2252 __skb_gro_checksum_convert(skb, check, \
2253 compute_pseudo(skb, proto)); \
2254} while (0)
2255
2236static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev, 2256static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
2237 unsigned short type, 2257 unsigned short type,
2238 const void *daddr, const void *saddr, 2258 const void *daddr, const void *saddr,