summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/virtio
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-01-10 19:38:57 +0000
committerDamjan Marion <dmarion@me.com>2022-01-10 20:51:52 +0000
commitc48ec5d568146389f3c539cea003c242f85e5239 (patch)
tree11a25709bea5db0a93186d56b8f9c8ad1486eba0 /src/vnet/devices/virtio
parent5048bc6ed51592145fcb710cdc06860f25b35e21 (diff)
interface: refactor interface capabilities code, part 2
Type: improvement Signed-off-by: Damjan Marion <damarion@cisco.com> Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com> Change-Id: Ie595e69af8657b0ee18a84ac71c5d433108d9ef8
Diffstat (limited to 'src/vnet/devices/virtio')
-rw-r--r--src/vnet/devices/virtio/pci.c25
-rw-r--r--src/vnet/devices/virtio/vhost_user.c15
2 files changed, 22 insertions, 18 deletions
diff --git a/src/vnet/devices/virtio/pci.c b/src/vnet/devices/virtio/pci.c
index b32f72bc66b..3c070b7160c 100644
--- a/src/vnet/devices/virtio/pci.c
+++ b/src/vnet/devices/virtio/pci.c
@@ -508,7 +508,7 @@ virtio_pci_offloads (vlib_main_t * vm, virtio_if_t * vif, int gso_enabled,
int csum_offload_enabled)
{
vnet_main_t *vnm = vnet_get_main ();
- vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, vif->hw_if_index);
+ vnet_hw_if_caps_change_t cc = {};
if ((vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_CTRL_VQ)) &&
(vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)))
@@ -524,10 +524,10 @@ virtio_pci_offloads (vlib_main_t * vm, virtio_if_t * vif, int gso_enabled,
else
{
vif->gso_enabled = 1;
- vif->csum_offload_enabled = 0;
- hw->caps |= VNET_HW_IF_CAP_TCP_GSO |
- VNET_HW_IF_CAP_TX_TCP_CKSUM |
- VNET_HW_IF_CAP_TX_UDP_CKSUM;
+ vif->csum_offload_enabled = 1;
+ cc.val = cc.mask = VNET_HW_IF_CAP_TCP_GSO |
+ VNET_HW_IF_CAP_TX_TCP_CKSUM |
+ VNET_HW_IF_CAP_TX_UDP_CKSUM;
}
}
else if (csum_offload_enabled
@@ -541,9 +541,10 @@ virtio_pci_offloads (vlib_main_t * vm, virtio_if_t * vif, int gso_enabled,
{
vif->csum_offload_enabled = 1;
vif->gso_enabled = 0;
- hw->caps &= ~VNET_HW_IF_CAP_TCP_GSO;
- hw->caps |=
+ cc.val =
VNET_HW_IF_CAP_TX_TCP_CKSUM | VNET_HW_IF_CAP_TX_UDP_CKSUM;
+ cc.mask = VNET_HW_IF_CAP_TCP_GSO | VNET_HW_IF_CAP_TX_TCP_CKSUM |
+ VNET_HW_IF_CAP_TX_UDP_CKSUM;
}
}
else
@@ -556,12 +557,15 @@ virtio_pci_offloads (vlib_main_t * vm, virtio_if_t * vif, int gso_enabled,
{
vif->csum_offload_enabled = 0;
vif->gso_enabled = 0;
- hw->caps &=
- ~(VNET_HW_IF_CAP_L4_TX_CKSUM | VNET_HW_IF_CAP_TCP_GSO);
+ cc.val = 0;
+ cc.mask = VNET_HW_IF_CAP_L4_TX_CKSUM | VNET_HW_IF_CAP_TCP_GSO;
}
}
}
+ if (cc.mask)
+ vnet_hw_if_change_caps (vnm, vif->hw_if_index, &cc);
+
return 0;
}
@@ -1473,8 +1477,7 @@ virtio_pci_create_if (vlib_main_t * vm, virtio_pci_create_if_args_t * args)
vif->sw_if_index = sw->sw_if_index;
args->sw_if_index = sw->sw_if_index;
- vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, vif->hw_if_index);
- hw->caps |= VNET_HW_IF_CAP_INT_MODE;
+ vnet_hw_if_set_caps (vnm, vif->hw_if_index, VNET_HW_IF_CAP_INT_MODE);
if (args->virtio_flags & VIRTIO_FLAG_BUFFERING)
{
diff --git a/src/vnet/devices/virtio/vhost_user.c b/src/vnet/devices/virtio/vhost_user.c
index 2d8cad8da43..0d24ad5aec8 100644
--- a/src/vnet/devices/virtio/vhost_user.c
+++ b/src/vnet/devices/virtio/vhost_user.c
@@ -553,17 +553,20 @@ vhost_user_socket_read (clib_file_t * uf)
(vui->features & VIRTIO_FEATURE (VIRTIO_F_ANY_LAYOUT)) ? 1 : 0;
ASSERT (vui->virtio_net_hdr_sz < VLIB_BUFFER_PRE_DATA_SIZE);
- vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, vui->hw_if_index);
if (vui->enable_gso &&
((vui->features & FEATURE_VIRTIO_NET_F_HOST_GUEST_TSO_FEATURE_BITS)
== FEATURE_VIRTIO_NET_F_HOST_GUEST_TSO_FEATURE_BITS))
{
- hw->caps |= (VNET_HW_IF_CAP_TCP_GSO | VNET_HW_IF_CAP_TX_TCP_CKSUM |
- VNET_HW_IF_CAP_TX_UDP_CKSUM);
+ vnet_hw_if_set_caps (vnm, vui->hw_if_index,
+ VNET_HW_IF_CAP_TCP_GSO |
+ VNET_HW_IF_CAP_TX_TCP_CKSUM |
+ VNET_HW_IF_CAP_TX_UDP_CKSUM);
}
else
{
- hw->caps &= ~(VNET_HW_IF_CAP_TCP_GSO | VNET_HW_IF_CAP_L4_TX_CKSUM);
+ vnet_hw_if_unset_caps (vnm, vui->hw_if_index,
+ VNET_HW_IF_CAP_TCP_GSO |
+ VNET_HW_IF_CAP_L4_TX_CKSUM);
}
vnet_hw_interface_set_flags (vnm, vui->hw_if_index, 0);
vui->is_ready = 0;
@@ -1596,9 +1599,7 @@ vhost_user_vui_init (vnet_main_t * vnm, vhost_user_intf_t * vui,
vnet_sw_interface_t *sw;
int q;
vhost_user_main_t *vum = &vhost_user_main;
- vnet_hw_interface_t *hw;
- hw = vnet_get_hw_interface (vnm, vui->hw_if_index);
sw = vnet_get_hw_sw_interface (vnm, vui->hw_if_index);
if (server_sock_fd != -1)
{
@@ -1651,7 +1652,7 @@ vhost_user_vui_init (vnet_main_t * vnm, vhost_user_intf_t * vui,
for (q = 0; q < vec_len (vui->vrings); q++)
vhost_user_vring_init (vui, q);
- hw->caps |= VNET_HW_IF_CAP_INT_MODE;
+ vnet_hw_if_set_caps (vnm, vui->hw_if_index, VNET_HW_IF_CAP_INT_MODE);
vnet_hw_interface_set_flags (vnm, vui->hw_if_index, 0);
if (sw_if_index)