summaryrefslogtreecommitdiffstats
path: root/src/vnet/vxlan
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2021-02-10 11:26:24 +0100
committerDamjan Marion <dmarion@me.com>2021-02-15 20:32:56 +0000
commit6809538e646bf86c000dc1faba60b0a4157ad898 (patch)
tree18a228b96226932381f15e44b4972636de1c7fe1 /src/vnet/vxlan
parent99c6dc6a7a36c0be95da9afb3ad8830b24754d4e (diff)
vlib: refactor checksum offload support
Type: refactor This patch refactors the offload flags in vlib_buffer_t. There are two main reasons behind this refactoring. First, offload flags are insufficient to represent outer and inner headers offloads. Second, room for these flags in first cacheline of vlib_buffer_t is also limited. This patch introduces a generic offload flag in first cacheline. And detailed offload flags in 2nd cacheline of the structure for performance optimization. Change-Id: Icc363a142fb9208ec7113ab5bbfc8230181f6004 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vnet/vxlan')
-rw-r--r--src/vnet/vxlan/encap.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/vnet/vxlan/encap.c b/src/vnet/vxlan/encap.c
index 787758a94f8..476e0f2b3b7 100644
--- a/src/vnet/vxlan/encap.c
+++ b/src/vnet/vxlan/encap.c
@@ -98,14 +98,14 @@ vxlan_encap_inline (vlib_main_t * vm,
u8 const underlay_hdr_len = is_ip4 ?
sizeof (ip4_vxlan_header_t) : sizeof (ip6_vxlan_header_t);
u16 const l3_len = is_ip4 ? sizeof (ip4_header_t) : sizeof (ip6_header_t);
- u32 const csum_flags = is_ip4 ? VNET_BUFFER_F_OFFLOAD_IP_CKSUM |
- VNET_BUFFER_F_IS_IP4 | VNET_BUFFER_F_OFFLOAD_UDP_CKSUM |
- VNET_BUFFER_F_L3_HDR_OFFSET_VALID | VNET_BUFFER_F_L4_HDR_OFFSET_VALID :
- VNET_BUFFER_F_IS_IP6 | VNET_BUFFER_F_OFFLOAD_UDP_CKSUM |
- VNET_BUFFER_F_L3_HDR_OFFSET_VALID | VNET_BUFFER_F_L4_HDR_OFFSET_VALID;
- u32 const inner_packet_csum_offload_flags =
- VNET_BUFFER_F_OFFLOAD_IP_CKSUM | VNET_BUFFER_F_OFFLOAD_UDP_CKSUM |
- VNET_BUFFER_F_OFFLOAD_TCP_CKSUM;
+ u32 const csum_flags =
+ is_ip4 ? VNET_BUFFER_F_IS_IP4 | VNET_BUFFER_F_L3_HDR_OFFSET_VALID |
+ VNET_BUFFER_F_L4_HDR_OFFSET_VALID :
+ VNET_BUFFER_F_IS_IP6 | VNET_BUFFER_F_L3_HDR_OFFSET_VALID |
+ VNET_BUFFER_F_L4_HDR_OFFSET_VALID;
+ u32 const outer_packet_csum_offload_flags =
+ is_ip4 ? VNET_BUFFER_OFFLOAD_F_IP_CKSUM | VNET_BUFFER_OFFLOAD_F_UDP_CKSUM :
+ VNET_BUFFER_OFFLOAD_F_UDP_CKSUM;
u32 const inner_packet_removed_flags =
VNET_BUFFER_F_IS_IP4 | VNET_BUFFER_F_IS_IP6 |
VNET_BUFFER_F_L2_HDR_OFFSET_VALID | VNET_BUFFER_F_L3_HDR_OFFSET_VALID |
@@ -144,7 +144,7 @@ vxlan_encap_inline (vlib_main_t * vm,
b += 2;
u32 or_flags = b0->flags | b1->flags;
- if (csum_offload && (or_flags & inner_packet_csum_offload_flags))
+ if (csum_offload && (or_flags & VNET_BUFFER_F_OFFLOAD))
{
/* Only calculate the non-GSO packet csum offload */
if ((b0->flags & VNET_BUFFER_F_GSO) == 0)
@@ -284,9 +284,13 @@ vxlan_encap_inline (vlib_main_t * vm,
b0->flags |= csum_flags;
vnet_buffer (b0)->l3_hdr_offset = l3_0 - b0->data;
vnet_buffer (b0)->l4_hdr_offset = (u8 *) udp0 - b0->data;
+ vnet_buffer_offload_flags_set (b0,
+ outer_packet_csum_offload_flags);
b1->flags |= csum_flags;
vnet_buffer (b1)->l3_hdr_offset = l3_1 - b1->data;
vnet_buffer (b1)->l4_hdr_offset = (u8 *) udp1 - b1->data;
+ vnet_buffer_offload_flags_set (b1,
+ outer_packet_csum_offload_flags);
}
/* IPv4 UDP checksum only if checksum offload is used */
else if (is_ip4)
@@ -377,7 +381,7 @@ vxlan_encap_inline (vlib_main_t * vm,
vlib_buffer_t *b0 = b[0];
b += 1;
- if (csum_offload && (b0->flags & inner_packet_csum_offload_flags))
+ if (csum_offload && (b0->flags & VNET_BUFFER_F_OFFLOAD))
{
/* Only calculate the non-GSO packet csum offload */
if ((b0->flags & VNET_BUFFER_F_GSO) == 0)
@@ -459,6 +463,8 @@ vxlan_encap_inline (vlib_main_t * vm,
b0->flags |= csum_flags;
vnet_buffer (b0)->l3_hdr_offset = l3_0 - b0->data;
vnet_buffer (b0)->l4_hdr_offset = (u8 *) udp0 - b0->data;
+ vnet_buffer_offload_flags_set (b0,
+ outer_packet_csum_offload_flags);
}
/* IPv4 UDP checksum only if checksum offload is used */
else if (is_ip4)