diff options
author | Joseph Gasparakis <joseph.gasparakis@intel.com> | 2012-12-07 09:14:14 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-12-09 00:20:28 -0500 |
commit | 6a674e9c75b17e7a88ff15b3c2e269eed54f7cfb (patch) | |
tree | cff48ec155b5c7d8a595d66cc7dc0216a91f9ec3 /net | |
parent | 9ecb9aabaf634677c77af467f4e3028b09d7bcda (diff) |
net: Add support for hardware-offloaded encapsulation
This patch adds support in the kernel for offloading in the NIC Tx and Rx
checksumming for encapsulated packets (such as VXLAN and IP GRE).
For Tx encapsulation offload, the driver will need to set the right bits
in netdev->hw_enc_features. The protocol driver will have to set the
skb->encapsulation bit and populate the inner headers, so the NIC driver will
use those inner headers to calculate the csum in hardware.
For Rx encapsulation offload, the driver will need to set again the
skb->encapsulation flag and the skb->ip_csum to CHECKSUM_UNNECESSARY.
In that case the protocol driver should push the decapsulated packet up
to the stack, again with CHECKSUM_UNNECESSARY. In ether case, the protocol
driver should set the skb->encapsulation flag back to zero. Finally the
protocol driver should have NETIF_F_RXCSUM flag set in its features.
Signed-off-by: Joseph Gasparakis <joseph.gasparakis@intel.com>
Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/skbuff.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 880722e22cc5..ccbabf565732 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -682,11 +682,14 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old) | |||
682 | new->transport_header = old->transport_header; | 682 | new->transport_header = old->transport_header; |
683 | new->network_header = old->network_header; | 683 | new->network_header = old->network_header; |
684 | new->mac_header = old->mac_header; | 684 | new->mac_header = old->mac_header; |
685 | new->inner_transport_header = old->inner_transport_header; | ||
686 | new->inner_network_header = old->inner_transport_header; | ||
685 | skb_dst_copy(new, old); | 687 | skb_dst_copy(new, old); |
686 | new->rxhash = old->rxhash; | 688 | new->rxhash = old->rxhash; |
687 | new->ooo_okay = old->ooo_okay; | 689 | new->ooo_okay = old->ooo_okay; |
688 | new->l4_rxhash = old->l4_rxhash; | 690 | new->l4_rxhash = old->l4_rxhash; |
689 | new->no_fcs = old->no_fcs; | 691 | new->no_fcs = old->no_fcs; |
692 | new->encapsulation = old->encapsulation; | ||
690 | #ifdef CONFIG_XFRM | 693 | #ifdef CONFIG_XFRM |
691 | new->sp = secpath_get(old->sp); | 694 | new->sp = secpath_get(old->sp); |
692 | #endif | 695 | #endif |
@@ -892,6 +895,8 @@ static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old) | |||
892 | new->network_header += offset; | 895 | new->network_header += offset; |
893 | if (skb_mac_header_was_set(new)) | 896 | if (skb_mac_header_was_set(new)) |
894 | new->mac_header += offset; | 897 | new->mac_header += offset; |
898 | new->inner_transport_header += offset; | ||
899 | new->inner_network_header += offset; | ||
895 | #endif | 900 | #endif |
896 | skb_shinfo(new)->gso_size = skb_shinfo(old)->gso_size; | 901 | skb_shinfo(new)->gso_size = skb_shinfo(old)->gso_size; |
897 | skb_shinfo(new)->gso_segs = skb_shinfo(old)->gso_segs; | 902 | skb_shinfo(new)->gso_segs = skb_shinfo(old)->gso_segs; |
@@ -1089,6 +1094,8 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, | |||
1089 | skb->network_header += off; | 1094 | skb->network_header += off; |
1090 | if (skb_mac_header_was_set(skb)) | 1095 | if (skb_mac_header_was_set(skb)) |
1091 | skb->mac_header += off; | 1096 | skb->mac_header += off; |
1097 | skb->inner_transport_header += off; | ||
1098 | skb->inner_network_header += off; | ||
1092 | /* Only adjust this if it actually is csum_start rather than csum */ | 1099 | /* Only adjust this if it actually is csum_start rather than csum */ |
1093 | if (skb->ip_summed == CHECKSUM_PARTIAL) | 1100 | if (skb->ip_summed == CHECKSUM_PARTIAL) |
1094 | skb->csum_start += nhead; | 1101 | skb->csum_start += nhead; |
@@ -1188,6 +1195,8 @@ struct sk_buff *skb_copy_expand(const struct sk_buff *skb, | |||
1188 | n->network_header += off; | 1195 | n->network_header += off; |
1189 | if (skb_mac_header_was_set(skb)) | 1196 | if (skb_mac_header_was_set(skb)) |
1190 | n->mac_header += off; | 1197 | n->mac_header += off; |
1198 | n->inner_transport_header += off; | ||
1199 | n->inner_network_header += off; | ||
1191 | #endif | 1200 | #endif |
1192 | 1201 | ||
1193 | return n; | 1202 | return n; |