aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/virtio
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2020-04-23 17:59:49 +0200
committerNeale Ranns <nranns@cisco.com>2020-05-05 07:44:12 +0000
commit84f91fa9c54f82c54b58ea3bf6e9ba22ff735d3a (patch)
tree63a762ea0e66b1a0074378f25984eb6450ac9ceb /src/vnet/devices/virtio
parent5ec6a4ea4440211e468a813ffe0f3173421c9b29 (diff)
gso: add support for IP-IP
Type: feature Change-Id: I37752af8496e0042a1da91124f3d94216b39ff11 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vnet/devices/virtio')
-rw-r--r--src/vnet/devices/virtio/device.c22
-rw-r--r--src/vnet/devices/virtio/vhost_user_output.c10
2 files changed, 21 insertions, 11 deletions
diff --git a/src/vnet/devices/virtio/device.c b/src/vnet/devices/virtio/device.c
index d110946dede..9a35bb8162f 100644
--- a/src/vnet/devices/virtio/device.c
+++ b/src/vnet/devices/virtio/device.c
@@ -168,13 +168,15 @@ virtio_free_used_device_desc (vlib_main_t * vm, virtio_vring_t * vring,
}
static_always_inline void
-set_checksum_offsets (vlib_buffer_t * b, struct virtio_net_hdr_v1 *hdr)
+set_checksum_offsets (vlib_buffer_t * b, struct virtio_net_hdr_v1 *hdr,
+ int is_l2)
{
if (b->flags & VNET_BUFFER_F_IS_IP4)
{
ip4_header_t *ip4;
generic_header_offset_t gho = { 0 };
- vnet_generic_header_offset_parser (b, &gho);
+ vnet_generic_header_offset_parser (b, &gho, is_l2, 1 /* ip4 */ ,
+ 0 /* ip6 */ );
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
hdr->csum_start = gho.l4_hdr_offset; // 0x22;
if (b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)
@@ -198,7 +200,8 @@ set_checksum_offsets (vlib_buffer_t * b, struct virtio_net_hdr_v1 *hdr)
else if (b->flags & VNET_BUFFER_F_IS_IP6)
{
generic_header_offset_t gho = { 0 };
- vnet_generic_header_offset_parser (b, &gho);
+ vnet_generic_header_offset_parser (b, &gho, is_l2, 0 /* ip4 */ ,
+ 1 /* ip6 */ );
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
hdr->csum_start = gho.l4_hdr_offset; // 0x36;
if (b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)
@@ -213,13 +216,14 @@ set_checksum_offsets (vlib_buffer_t * b, struct virtio_net_hdr_v1 *hdr)
}
static_always_inline void
-set_gso_offsets (vlib_buffer_t * b, struct virtio_net_hdr_v1 *hdr)
+set_gso_offsets (vlib_buffer_t * b, struct virtio_net_hdr_v1 *hdr, int is_l2)
{
if (b->flags & VNET_BUFFER_F_IS_IP4)
{
ip4_header_t *ip4;
generic_header_offset_t gho = { 0 };
- vnet_generic_header_offset_parser (b, &gho);
+ vnet_generic_header_offset_parser (b, &gho, is_l2, 1 /* ip4 */ ,
+ 0 /* ip6 */ );
hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
hdr->gso_size = vnet_buffer2 (b)->gso_size;
hdr->hdr_len = gho.hdr_sz;
@@ -238,7 +242,8 @@ set_gso_offsets (vlib_buffer_t * b, struct virtio_net_hdr_v1 *hdr)
else if (b->flags & VNET_BUFFER_F_IS_IP6)
{
generic_header_offset_t gho = { 0 };
- vnet_generic_header_offset_parser (b, &gho);
+ vnet_generic_header_offset_parser (b, &gho, is_l2, 0 /* ip4 */ ,
+ 1 /* ip6 */ );
hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
hdr->gso_size = vnet_buffer2 (b)->gso_size;
hdr->hdr_len = gho.hdr_sz;
@@ -260,13 +265,14 @@ add_buffer_to_slot (vlib_main_t * vm, virtio_if_t * vif,
d = &vring->desc[next];
vlib_buffer_t *b = vlib_get_buffer (vm, bi);
struct virtio_net_hdr_v1 *hdr = vlib_buffer_get_current (b) - hdr_sz;
+ int is_l2 = (vif->type & (VIRTIO_IF_TYPE_TAP | VIRTIO_IF_TYPE_PCI));
clib_memset (hdr, 0, hdr_sz);
if (b->flags & VNET_BUFFER_F_GSO)
{
if (do_gso)
- set_gso_offsets (b, hdr);
+ set_gso_offsets (b, hdr, is_l2);
else
{
virtio_interface_drop_inline (vm, node_index, &bi, 1,
@@ -278,7 +284,7 @@ add_buffer_to_slot (vlib_main_t * vm, virtio_if_t * vif,
VNET_BUFFER_F_OFFLOAD_UDP_CKSUM))
{
if (csum_offload)
- set_checksum_offsets (b, hdr);
+ set_checksum_offsets (b, hdr, is_l2);
else
{
virtio_interface_drop_inline (vm, node_index, &bi, 1,
diff --git a/src/vnet/devices/virtio/vhost_user_output.c b/src/vnet/devices/virtio/vhost_user_output.c
index 4f5eb3c1d76..d48e43738a9 100644
--- a/src/vnet/devices/virtio/vhost_user_output.c
+++ b/src/vnet/devices/virtio/vhost_user_output.c
@@ -237,7 +237,11 @@ vhost_user_handle_tx_offload (vhost_user_intf_t * vui, vlib_buffer_t * b,
virtio_net_hdr_t * hdr)
{
generic_header_offset_t gho = { 0 };
- vnet_generic_header_offset_parser (b, &gho);
+ int is_ip4 = b->flags & VNET_BUFFER_F_IS_IP4;
+ int is_ip6 = b->flags & VNET_BUFFER_F_IS_IP6;
+
+ ASSERT (!(is_ip4 && is_ip6));
+ vnet_generic_header_offset_parser (b, &gho, 1 /* l2 */ , is_ip4, is_ip6);
if (b->flags & VNET_BUFFER_F_OFFLOAD_IP_CKSUM)
{
ip4_header_t *ip4;
@@ -272,13 +276,13 @@ vhost_user_handle_tx_offload (vhost_user_intf_t * vui, vlib_buffer_t * b,
{
if (b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)
{
- if ((b->flags & VNET_BUFFER_F_IS_IP4) &&
+ if (is_ip4 &&
(vui->features & (1ULL << FEAT_VIRTIO_NET_F_GUEST_TSO4)))
{
hdr->gso_size = vnet_buffer2 (b)->gso_size;
hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
}
- else if ((b->flags & VNET_BUFFER_F_IS_IP6) &&
+ else if (is_ip6 &&
(vui->features & (1ULL << FEAT_VIRTIO_NET_F_GUEST_TSO6)))
{
hdr->gso_size = vnet_buffer2 (b)->gso_size;