diff options
author | Mohsin Kazmi <sykazmi@cisco.com> | 2021-11-26 17:04:07 +0100 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2021-11-30 21:24:48 +0000 |
commit | 376c2106cec344d65bffd322d261cefaf4f6e67c (patch) | |
tree | f16d9b3cfbdeb1c14611b4177a145bddf623fc97 /src | |
parent | bfcd23968246086b5b884f7df1e78adb1a059724 (diff) |
interface: add support for outer header checksums
Type: improvement
Change-Id: I7c341dc4a99898dd1f865ac2ebd99de9898bb0bd
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/vnet/interface.h | 12 | ||||
-rw-r--r-- | src/vnet/interface_output.c | 1 | ||||
-rw-r--r-- | src/vnet/interface_output.h | 30 |
3 files changed, 43 insertions, 0 deletions
diff --git a/src/vnet/interface.h b/src/vnet/interface.h index 0a30239e982..fe42e5d33a1 100644 --- a/src/vnet/interface.h +++ b/src/vnet/interface.h @@ -561,6 +561,14 @@ typedef enum vnet_hw_interface_capabilities_t_ VNET_HW_INTERFACE_CAP_SUPPORTS_TX_TCP_CKSUM | \ VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_CKSUM) +#define VNET_HW_INTERFACE_CAP_SUPPORTS_TX_OUTER_CKSUM \ + (VNET_HW_INTERFACE_CAP_SUPPORTS_TX_IP4_OUTER_CKSUM | \ + VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_OUTER_CKSUM) + +#define VNET_HW_INTERFACE_CAP_SUPPORTS_TX_CKSUM_MASK \ + (VNET_HW_INTERFACE_CAP_SUPPORTS_TX_CKSUM | \ + VNET_HW_INTERFACE_CAP_SUPPORTS_TX_OUTER_CKSUM) + #define VNET_HW_INTERFACE_CAP_SUPPORTS_L4_RX_CKSUM \ (VNET_HW_INTERFACE_CAP_SUPPORTS_RX_TCP_CKSUM | \ VNET_HW_INTERFACE_CAP_SUPPORTS_RX_UDP_CKSUM) @@ -570,6 +578,10 @@ typedef enum vnet_hw_interface_capabilities_t_ VNET_HW_INTERFACE_CAP_SUPPORTS_RX_TCP_CKSUM | \ VNET_HW_INTERFACE_CAP_SUPPORTS_RX_UDP_CKSUM) +#define VNET_HW_INTERFACE_CAP_SUPPORTS_TNL_GSO_MASK \ + VNET_HW_INTERFACE_CAP_SUPPORTS_VXLAN_TNL_GSO | \ + VNET_HW_INTERFACE_CAP_SUPPORTS_IPIP_TNL_GSO + #define VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT 1 #define VNET_HW_INTERFACE_FLAG_SPEED_SHIFT 3 #define VNET_HW_INTERFACE_FLAG_DUPLEX_MASK \ diff --git a/src/vnet/interface_output.c b/src/vnet/interface_output.c index 5b43f7ef3ff..72ceb95132d 100644 --- a/src/vnet/interface_output.c +++ b/src/vnet/interface_output.c @@ -170,6 +170,7 @@ vnet_interface_output_handle_offload (vlib_main_t *vm, vlib_buffer_t *b) { vnet_calc_checksums_inline (vm, b, b->flags & VNET_BUFFER_F_IS_IP4, b->flags & VNET_BUFFER_F_IS_IP6); + vnet_calc_outer_checksums_inline (vm, b); } static_always_inline uword diff --git a/src/vnet/interface_output.h b/src/vnet/interface_output.h index 15b0a1d3ccc..786b0ff8e21 100644 --- a/src/vnet/interface_output.h +++ b/src/vnet/interface_output.h @@ -114,6 +114,36 @@ vnet_calc_checksums_inline (vlib_main_t * vm, vlib_buffer_t * b, VNET_BUFFER_OFFLOAD_F_TCP_CKSUM)); } +static_always_inline void +vnet_calc_outer_checksums_inline (vlib_main_t *vm, vlib_buffer_t *b) +{ + + if (!(b->flags & VNET_BUFFER_F_OFFLOAD)) + return; + + vnet_buffer_oflags_t oflags = vnet_buffer (b)->oflags; + if (oflags & VNET_BUFFER_OFFLOAD_F_OUTER_IP_CKSUM) + { + ip4_header_t *ip4; + ip4 = (ip4_header_t *) (b->data + vnet_buffer2 (b)->outer_l3_hdr_offset); + ip4->checksum = ip4_header_checksum (ip4); + vnet_buffer_offload_flags_clear (b, + VNET_BUFFER_OFFLOAD_F_OUTER_IP_CKSUM); + } + else if (oflags & VNET_BUFFER_OFFLOAD_F_OUTER_UDP_CKSUM) + { + int bogus; + ip6_header_t *ip6; + udp_header_t *uh; + + ip6 = (ip6_header_t *) (b->data + vnet_buffer2 (b)->outer_l3_hdr_offset); + uh = (udp_header_t *) (b->data + vnet_buffer2 (b)->outer_l4_hdr_offset); + uh->checksum = 0; + uh->checksum = ip6_tcp_udp_icmp_compute_checksum (vm, b, ip6, &bogus); + vnet_buffer_offload_flags_clear (b, + VNET_BUFFER_OFFLOAD_F_OUTER_UDP_CKSUM); + } +} #endif /* |