diff options
author | Mohsin Kazmi <sykazmi@cisco.com> | 2021-02-10 11:26:24 +0100 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2021-02-15 20:32:56 +0000 |
commit | 6809538e646bf86c000dc1faba60b0a4157ad898 (patch) | |
tree | 18a228b96226932381f15e44b4972636de1c7fe1 /src/vnet/devices/virtio/node.c | |
parent | 99c6dc6a7a36c0be95da9afb3ad8830b24754d4e (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/devices/virtio/node.c')
-rw-r--r-- | src/vnet/devices/virtio/node.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/vnet/devices/virtio/node.c b/src/vnet/devices/virtio/node.c index be2405bb3b9..98df322ea15 100644 --- a/src/vnet/devices/virtio/node.c +++ b/src/vnet/devices/virtio/node.c @@ -235,6 +235,7 @@ virtio_needs_csum (vlib_buffer_t * b0, virtio_net_hdr_v1_t * hdr, if (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { u16 ethertype = 0, l2hdr_sz = 0; + u32 oflags = 0; if (type == VIRTIO_IF_TYPE_TUN) { @@ -280,11 +281,10 @@ virtio_needs_csum (vlib_buffer_t * b0, virtio_net_hdr_v1_t * hdr, (ip4_header_t *) (vlib_buffer_get_current (b0) + l2hdr_sz); vnet_buffer (b0)->l4_hdr_offset = l2hdr_sz + ip4_header_bytes (ip4); *l4_proto = ip4->protocol; + oflags |= VNET_BUFFER_OFFLOAD_F_IP_CKSUM; b0->flags |= - (VNET_BUFFER_F_IS_IP4 | VNET_BUFFER_F_OFFLOAD_IP_CKSUM); - b0->flags |= - (VNET_BUFFER_F_L2_HDR_OFFSET_VALID - | VNET_BUFFER_F_L3_HDR_OFFSET_VALID | + (VNET_BUFFER_F_IS_IP4 | VNET_BUFFER_F_L2_HDR_OFFSET_VALID | + VNET_BUFFER_F_L3_HDR_OFFSET_VALID | VNET_BUFFER_F_L4_HDR_OFFSET_VALID); } else if (PREDICT_TRUE (ethertype == ETHERNET_TYPE_IP6)) @@ -301,7 +301,7 @@ virtio_needs_csum (vlib_buffer_t * b0, virtio_net_hdr_v1_t * hdr, } if (*l4_proto == IP_PROTOCOL_TCP) { - b0->flags |= VNET_BUFFER_F_OFFLOAD_TCP_CKSUM; + oflags |= VNET_BUFFER_OFFLOAD_F_TCP_CKSUM; tcp_header_t *tcp = (tcp_header_t *) (vlib_buffer_get_current (b0) + vnet_buffer (b0)->l4_hdr_offset); @@ -309,12 +309,14 @@ virtio_needs_csum (vlib_buffer_t * b0, virtio_net_hdr_v1_t * hdr, } else if (*l4_proto == IP_PROTOCOL_UDP) { - b0->flags |= VNET_BUFFER_F_OFFLOAD_UDP_CKSUM; + oflags |= VNET_BUFFER_OFFLOAD_F_UDP_CKSUM; udp_header_t *udp = (udp_header_t *) (vlib_buffer_get_current (b0) + vnet_buffer (b0)->l4_hdr_offset); *l4_hdr_sz = sizeof (*udp); } + if (oflags) + vnet_buffer_offload_flags_set (b0, oflags); } } |