aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/vxlan-gbp
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-gbp
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-gbp')
-rw-r--r--src/vnet/vxlan-gbp/encap.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/vnet/vxlan-gbp/encap.c b/src/vnet/vxlan-gbp/encap.c
index 4514fdae7a7..2a4e8a8e312 100644
--- a/src/vnet/vxlan-gbp/encap.c
+++ b/src/vnet/vxlan-gbp/encap.c
@@ -102,14 +102,14 @@ vxlan_gbp_encap_inline (vlib_main_t * vm,
u8 const underlay_hdr_len = is_ip4 ?
sizeof (ip4_vxlan_gbp_header_t) : sizeof (ip6_vxlan_gbp_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 |
@@ -147,7 +147,7 @@ vxlan_gbp_encap_inline (vlib_main_t * vm,
n_left_from -= 2;
u32 or_flags = b[0]->flags | b[1]->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 ((b[0]->flags & VNET_BUFFER_F_GSO) == 0)
@@ -300,9 +300,13 @@ vxlan_gbp_encap_inline (vlib_main_t * vm,
b[0]->flags |= csum_flags;
vnet_buffer (b[0])->l3_hdr_offset = l3_0 - b[0]->data;
vnet_buffer (b[0])->l4_hdr_offset = (u8 *) udp0 - b[0]->data;
+ vnet_buffer_offload_flags_set (b[0],
+ outer_packet_csum_offload_flags);
b[1]->flags |= csum_flags;
vnet_buffer (b[1])->l3_hdr_offset = l3_1 - b[1]->data;
vnet_buffer (b[1])->l4_hdr_offset = (u8 *) udp1 - b[1]->data;
+ vnet_buffer_offload_flags_set (b[1],
+ outer_packet_csum_offload_flags);
}
/* IPv4 UDP checksum only if checksum offload is used */
else if (is_ip4)
@@ -387,7 +391,7 @@ vxlan_gbp_encap_inline (vlib_main_t * vm,
n_left_from -= 1;
n_left_to_next -= 1;
- if (csum_offload && (b[0]->flags & inner_packet_csum_offload_flags))
+ if (csum_offload && (b[0]->flags & VNET_BUFFER_F_OFFLOAD))
{
/* Only calculate the non-GSO packet csum offload */
if ((b[0]->flags & VNET_BUFFER_F_GSO) == 0)
@@ -477,6 +481,8 @@ vxlan_gbp_encap_inline (vlib_main_t * vm,
b[0]->flags |= csum_flags;
vnet_buffer (b[0])->l3_hdr_offset = l3_0 - b[0]->data;
vnet_buffer (b[0])->l4_hdr_offset = (u8 *) udp0 - b[0]->data;
+ vnet_buffer_offload_flags_set (b[0],
+ outer_packet_csum_offload_flags);
}
/* IPv4 UDP checksum only if checksum offload is used */
else if (is_ip4)