Vhost-vdpa Shadow Virtqueue _F_CTRL_RX_EXTRA commands support
v3 cover Vhost-vdpa Shadow Virtqueue _F_CTRL_RX_EXTRA commands support
This series enables shadowed CVQ to intercept rx commands related to VIRTIO_NET_F_CTRL_RX_EXTRA feature through shadowed CVQ, update the virtio NIC device model so qemu send it in a migration, and the restore of that rx state in the destination.
To test this patch series, one should modify the n->parent_obj.guest_features value in vhost_vdpa_net_load_rx() using gdb, as the linux virtio-net driver does not currently support the VIRTIO_NET_F_CTRL_RX_EXTRA feature.
Note that this patch should be based on
[1] patch "Vhost-vdpa Shadow Virtqueue _F_CTRL_RX commands support"
[1]. https://lore.kernel.org/all/[email protected]/
TestStep
========
1. test the patch series using vp-vdpa device
- For L0 guest, boot QEMU with virtio-net-pci net device withctrl_vq, ctrl_rx and ctrl_rx_extra feature on, something like:
-device virtio-net-pci,rx_queue_size=256,tx_queue_size=256,
iommu_platform=on,ctrl_vq=on,ctrl_rx=on,ctrl_rx_extra=on...
- For L1 guest, apply the patch series and compile the code,
start QEMU with vdpa device with svq mode and enable the ctrl_vq, ctrl_rx and ctrl_rx_extra feature on, something like:
-netdev type=vhost-vdpa,x-svq=true,...
-device virtio-net-pci,ctrl_vq=on,ctrl_rx=on,ctrl_rx_extra=on...Use gdb to attach the VM and break at the net/vhost-vdpa.c:870.
With this series, gdb can hit the breakpoint. Enable the VIRTIO_NET_F_CTRL_RX_EXTRA feature and enable the non-unicast mode by entering the following gdb commands:
```gdb set n->parent_obj.guest_features |= (1 << 20) set n->nouni = 1 c ```
QEMU should not trigger any errors or warnings.
Without this series, QEMU should fail with "x-svq=true: vdpa svq does not work with features 0x100000".
ChangeLog
=========
v3:
- return early if mismatch the condition suggested by Eugenio in
patch 1 "vdpa: Restore packet receive filtering state relative with _F_CTRL_RX_EXTRA feature"
- remove the on variable suggested by Eugenio in patch 1 "vdpa:
Restore packet receive filtering state relative with _F_CTRL_RX_EXTRA feature"
v2: https://lore.kernel.org/all/[email protected]/
- avoid sending CVQ command in default state suggested by Eugenio
v1: https://lists.nongnu.org/archive/html/qemu-devel/2023-06/msg04956.html
Hawkins Jiawei (2):
vdpa: Restore packet receive filtering state relative with
_F_CTRL_RX_EXTRA feature
vdpa: Allow VIRTIO_NET_F_CTRL_RX_EXTRA in SVQ
net/vhost-vdpa.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+)
Signature · 1 line
2.25.1
PATCH v3 1/2 vdpa: Restore packet receive filtering state relative with _F_CTRL_RX_EXTRA feature
This patch refactors vhost_vdpa_net_load_rx() to restore the packet receive filtering state in relation to VIRTIO_NET_F_CTRL_RX_EXTRA feature at device's startup.
---
v3:
- return early if mismatch the condition suggested by Eugenio
- remove the on variable suggested by Eugenio
v2: https://lore.kernel.org/all/66ec4d7e3a680de645043d0331ab65940154f2b8.1688365324.git.yin31149@gmail.com/
- avoid sending CVQ command in default state suggested by Eugenio
v1: https://lists.nongnu.org/archive/html/qemu-devel/2023-06/msg04957.html
net/vhost-vdpa.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+)
net/vhost-vdpa.c +88 -0
@@ -867,6 +867,94 @@ static int vhost_vdpa_net_load_rx(VhostVDPAState *s, } } +if (!virtio_vdev_has_feature (&n->parent_obj,VIRTIO_NET_F_CTRL_RX_EXTRA )) { +return 0 ; + } + +/* +* According to virtio_net_reset(), device turns all-unicast mode +* off by default. +* +* Therefore, QEMU should only send this CVQ command if the driver +* sets all-unicast mode on, different from the device's defaults. +* +* Note that the device's defaults can mismatch the driver's +* configuration only at live migration. +*/ +if (n->alluni) { + dev_written =vhost_vdpa_net_load_rx_mode (s, +VIRTIO_NET_CTRL_RX_ALLUNI ,1 ); +if (dev_written <0 ) { +return dev_written; + } +if (*s->status !=VIRTIO_NET_OK ) { +return -EIO ; + } + } + +/* +* According to virtio_net_reset(), device turns non-multicast mode +* off by default. +* +* Therefore, QEMU should only send this CVQ command if the driver +* sets non-multicast mode on, different from the device's defaults. +* +* Note that the device's defaults can mismatch the driver's +* configuration only at live migration. +*/ +if (n->nomulti) { + dev_written =vhost_vdpa_net_load_rx_mode (s, +VIRTIO_NET_CTRL_RX_NOMULTI ,1 ); +if (dev_written <0 ) { +return dev_written; + } +if (*s->status !=VIRTIO_NET_OK ) { +return -EIO ; + } + } + +/* +* According to virtio_net_reset(), device turns non-unicast mode +* off by default. +* +* Therefore, QEMU should only send this CVQ command if the driver +* sets non-unicast mode on, different from the device's defaults. +* +* Note that the device's defaults can mismatch the driver's +* configuration only at live migration. +*/ +if (n->nouni) { + dev_written =vhost_vdpa_net_load_rx_mode (s, +VIRTIO_NET_CTRL_RX_NOUNI ,1 ); +if (dev_written <0 ) { +return dev_written; + } +if (*s->status !=VIRTIO_NET_OK ) { +return -EIO ; + } + } + +/* +* According to virtio_net_reset(), device turns non-broadcast mode +* off by default. +* +* Therefore, QEMU should only send this CVQ command if the driver +* sets non-broadcast mode on, different from the device's defaults. +* +* Note that the device's defaults can mismatch the driver's +* configuration only at live migration. +*/ +if (n->nobcast) { + dev_written =vhost_vdpa_net_load_rx_mode (s, +VIRTIO_NET_CTRL_RX_NOBCAST ,1 ); +if (dev_written <0 ) { +return dev_written; + } +if (*s->status !=VIRTIO_NET_OK ) { +return -EIO ; + } + } +return 0 ; }
Signature · 1 line
2.25.1
PATCH v3 2/2 vdpa: Allow VIRTIO_NET_F_CTRL_RX_EXTRA in SVQ
In reply to Hawkins JiaweiEnable SVQ with VIRTIO_NET_F_CTRL_RX_EXTRA feature.
--- net/vhost-vdpa.c | 1 + 1 file changed, 1 insertion(+)
net/vhost-vdpa.c +1 -0
@@ -105,6 +105,7 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_STATUS ) |BIT_ULL (VIRTIO_NET_F_CTRL_VQ ) |BIT_ULL (VIRTIO_NET_F_CTRL_RX ) | +BIT_ULL (VIRTIO_NET_F_CTRL_RX_EXTRA ) |BIT_ULL (VIRTIO_NET_F_MQ ) |BIT_ULL (VIRTIO_F_ANY_LAYOUT ) | BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) |
Signature · 1 line
2.25.1