Vhost-vdpa Shadow Virtqueue VLAN support
cover Vhost-vdpa Shadow Virtqueue VLAN support
This series enables shadowed CVQ to intercept VLAN commands through shadowed CVQ, update the virtio NIC device model so qemu send it in a migration, and the restore of that VLAN state in the destination.
It's based on the multiqueue series [1], but it's easy to reorder in case vlan feature is accepted earlier than mq.
Comments are welcome.
[1] https://lists.nongnu.org/archive/html/qemu-devel/2022-09/msg01006.html
Eugenio Pérez (3):
virtio-net: do not reset vlan filtering at set_features
vdpa: load vlan configuration at NIC startup
vdpa: Support VLAN on nic control shadow virtqueue
hw/net/virtio-net.c | 4 +--- net/vhost-vdpa.c | 57 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 5 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/3 virtio-net: do not reset vlan filtering at set_features
This function is called after virtio_load, so all vlan configuration is lost in migration case.
Just allow all the vlan-tagged packets if vlan is not configured, and trust device reset to clear all filtered vlans.
--- hw/net/virtio-net.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/net/virtio-net.c +1 -3
@@ -920,9 +920,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)vhost_net_ack_features (get_vhost_net (nc->peer), features); } -if (virtio_has_feature (features,VIRTIO_NET_F_CTRL_VLAN )) { -memset (n->vlans,0 ,MAX_VLAN >>3 ); - }else { +if (!virtio_has_feature (features,VIRTIO_NET_F_CTRL_VLAN )) {memset (n->vlans,0xff ,MAX_VLAN >>3 ); }
Signature · 1 line
2.31.1
PATCH 2/3 vdpa: load vlan configuration at NIC startup
In reply to Eugenio PérezTo have enabled vlans at device startup may happen in the destination of a live migration, so this configuration must be restored.
At this moment the code is not accessible, since SVQ refuses to start if vlan feature is exposed by the device.
--- net/vhost-vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)
net/vhost-vdpa.c +44 -2
@@ -100,6 +100,8 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_RSC_EXT ) |BIT_ULL (VIRTIO_NET_F_STANDBY ); +#define MAX_VLAN (1 << 12)/* Per 802.1Q definition */ +VHostNetState *vhost_vdpa_get_vhost_net (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);
@@ -423,6 +425,47 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,return *s->status !=VIRTIO_NET_OK ; } +static int vhost_vdpa_net_load_single_vlan (VhostVDPAState *s, +const VirtIONet *n, +uint16_t vid) +{ +ssize_t dev_written =vhost_vdpa_net_load_cmd (s,VIRTIO_NET_CTRL_VLAN , +VIRTIO_NET_CTRL_VLAN_ADD , + &vid,sizeof (vid)); +if (unlikely (dev_written <0 )) { +return dev_written; + } + +if (unlikely (*s->status !=VIRTIO_NET_OK )) { +return -EINVAL ; + } + +return 0 ; +} + +static int vhost_vdpa_net_load_vlan (VhostVDPAState *s, +const VirtIONet *n) +{ +uint64_t features = n->parent_obj.guest_features; + +if (!(features &BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ))) { +return 0 ; + } + +for (int i =0 ; i <MAX_VLAN >>5 ; i++) { +for (int j =0 ; n->vlans[i] && j <=0x1f ; j++) { +if (n->vlans[i] & (1U << j)) { +int r =vhost_vdpa_net_load_single_vlan (s, n, (i <<5 ) + j); +if (unlikely (r !=0 )) { +return r; + } + } + } + } + +return 0 ; +} +static int vhost_vdpa_net_load (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);
@@ -445,8 +488,7 @@ static int vhost_vdpa_net_load(NetClientState *nc)if (unlikely (r)) {return r; } - -return 0 ; +return vhost_vdpa_net_load_vlan (s, n); }static NetClientInfo net_vhost_vdpa_cvq_info = {
Signature · 1 line
2.31.1
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
Quoted 50 lines · Eugenio Pérez
To have enabled vlans at device startup may happen in the destination of a live migration, so this configuration must be restored.
At this moment the code is not accessible, since SVQ refuses to start if vlan feature is exposed by the device.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)net/vhost-vdpa.c +23
-0@@ -100,6 +100,8 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_RSC_EXT ) |BIT_ULL (VIRTIO_NET_F_STANDBY ); +#define MAX_VLAN (1 << 12)/* Per 802.1Q definition */ +VHostNetState *vhost_vdpa_get_vhost_net (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -423,6 +425,47 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,return *s->status !=VIRTIO_NET_OK ; } +static int vhost_vdpa_net_load_single_vlan (VhostVDPAState *s, +const VirtIONet *n, +uint16_t vid) +{ +ssize_t dev_written =vhost_vdpa_net_load_cmd (s,VIRTIO_NET_CTRL_VLAN , +VIRTIO_NET_CTRL_VLAN_ADD , + &vid,sizeof (vid)); +if (unlikely (dev_written <0 )) { +return dev_written; + } + +if (unlikely (*s->status !=VIRTIO_NET_OK )) { +return -EINVAL ; + } + +return 0 ; +} + +static int vhost_vdpa_net_load_vlan (VhostVDPAState *s, +const VirtIONet *n) +{
net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 458
Quoted 10 lines
net/vhost-vdpa.c +10
-0+uint64_t features = n->parent_obj.guest_features; + +if (!(features &BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ))) { +return 0 ; + } + +for (int i =0 ; i <MAX_VLAN >>5 ; i++) { +for (int j =0 ; n->vlans[i] && j <=0x1f ; j++) { +if (n->vlans[i] & (1U << j)) { +int r =vhost_vdpa_net_load_single_vlan (s, n, (i <<5 ) + j);
This seems to cause a lot of latency if the driver has a lot of vlans.
I wonder if it's simply to let all vlan traffic go by disabling CTRL_VLAN feature at vDPA layer.
Thanks
Quoted 26 lines
net/vhost-vdpa.c +11
-3+if (unlikely (r !=0 )) { +return r; + } + } + } + } + +return 0 ; +} +static int vhost_vdpa_net_load (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -445,8 +488,7 @@ static int vhost_vdpa_net_load(NetClientState *nc)if (unlikely (r)) {return r; } - -return 0 ; +return vhost_vdpa_net_load_vlan (s, n); }static NetClientInfo net_vhost_vdpa_cvq_info = { --2.31.1
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
Quoted 65 lines · Jason Wang
Quoted 50 lines · Eugenio Pérez
To have enabled vlans at device startup may happen in the destination of a live migration, so this configuration must be restored.
At this moment the code is not accessible, since SVQ refuses to start if vlan feature is exposed by the device.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)net/vhost-vdpa.c +23
-0@@ -100,6 +100,8 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_RSC_EXT ) |BIT_ULL (VIRTIO_NET_F_STANDBY ); +#define MAX_VLAN (1 << 12)/* Per 802.1Q definition */ +VHostNetState *vhost_vdpa_get_vhost_net (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -423,6 +425,47 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,return *s->status !=VIRTIO_NET_OK ; } +static int vhost_vdpa_net_load_single_vlan (VhostVDPAState *s, +const VirtIONet *n, +uint16_t vid) +{ +ssize_t dev_written =vhost_vdpa_net_load_cmd (s,VIRTIO_NET_CTRL_VLAN , +VIRTIO_NET_CTRL_VLAN_ADD , + &vid,sizeof (vid)); +if (unlikely (dev_written <0 )) { +return dev_written; + } + +if (unlikely (*s->status !=VIRTIO_NET_OK )) { +return -EINVAL ; + } + +return 0 ; +} + +static int vhost_vdpa_net_load_vlan (VhostVDPAState *s, +const VirtIONet *n) +{net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 458
Quoted 10 lines
net/vhost-vdpa.c +10
-0+uint64_t features = n->parent_obj.guest_features; + +if (!(features &BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ))) { +return 0 ; + } + +for (int i =0 ; i <MAX_VLAN >>5 ; i++) { +for (int j =0 ; n->vlans[i] && j <=0x1f ; j++) { +if (n->vlans[i] & (1U << j)) { +int r =vhost_vdpa_net_load_single_vlan (s, n, (i <<5 ) + j);This seems to cause a lot of latency if the driver has a lot of vlans.
Quoted 2 lines
I wonder if it's simply to let all vlan traffic go by disabling
CTRL_VLANfeature at vDPA layer.
Another idea is to extend the spec to allow us to accept a bitmap of the vlan ids via a single command, then we will be fine.
Thanks
Quoted 29 lines
Thanks
Quoted 26 lines
net/vhost-vdpa.c +11
-3+if (unlikely (r !=0 )) { +return r; + } + } + } + } + +return 0 ; +} +static int vhost_vdpa_net_load (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -445,8 +488,7 @@ static int vhost_vdpa_net_load(NetClientState *nc)if (unlikely (r)) {return r; } - -return 0 ; +return vhost_vdpa_net_load_vlan (s, n); }static NetClientInfo net_vhost_vdpa_cvq_info = { --2.31.1
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
Quoted 67 lines · Jason Wang
Quoted 65 lines · Jason Wang
Quoted 50 lines · Eugenio Pérez
To have enabled vlans at device startup may happen in the destination of a live migration, so this configuration must be restored.
At this moment the code is not accessible, since SVQ refuses to start if vlan feature is exposed by the device.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)net/vhost-vdpa.c +23
-0@@ -100,6 +100,8 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_RSC_EXT ) |BIT_ULL (VIRTIO_NET_F_STANDBY ); +#define MAX_VLAN (1 << 12)/* Per 802.1Q definition */ +VHostNetState *vhost_vdpa_get_vhost_net (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -423,6 +425,47 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,return *s->status !=VIRTIO_NET_OK ; } +static int vhost_vdpa_net_load_single_vlan (VhostVDPAState *s, +const VirtIONet *n, +uint16_t vid) +{ +ssize_t dev_written =vhost_vdpa_net_load_cmd (s,VIRTIO_NET_CTRL_VLAN , +VIRTIO_NET_CTRL_VLAN_ADD , + &vid,sizeof (vid)); +if (unlikely (dev_written <0 )) { +return dev_written; + } + +if (unlikely (*s->status !=VIRTIO_NET_OK )) { +return -EINVAL ; + } + +return 0 ; +} + +static int vhost_vdpa_net_load_vlan (VhostVDPAState *s, +const VirtIONet *n) +{net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 458
Quoted 10 lines
net/vhost-vdpa.c +10
-0+uint64_t features = n->parent_obj.guest_features; + +if (!(features &BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ))) { +return 0 ; + } + +for (int i =0 ; i <MAX_VLAN >>5 ; i++) { +for (int j =0 ; n->vlans[i] && j <=0x1f ; j++) { +if (n->vlans[i] & (1U << j)) { +int r =vhost_vdpa_net_load_single_vlan (s, n, (i <<5 ) + j);This seems to cause a lot of latency if the driver has a lot of vlans.
Quoted 3 lines
Quoted 2 lines
I wonder if it's simply to let all vlan traffic go by disabling
CTRL_VLANfeature at vDPA layer.
The guest will not be able to recover that vlan configuration.
Quoted 3 lines
Another idea is to extend the spec to allow us to accept a bitmap of the vlan ids via a single command, then we will be fine.
I'm not sure if adding more ways to configure something is the answer, but I'd be ok to implement it.
Another idea is to allow the sending of many CVQ commands in parallel. It shouldn't be very hard to achieve using exposed buffers as ring buffers, and it will short down the start of the devices with many features.
Thanks!
Quoted 32 lines
Thanks
Quoted 29 lines
Thanks
Quoted 26 lines
net/vhost-vdpa.c +11
-3+if (unlikely (r !=0 )) { +return r; + } + } + } + } + +return 0 ; +} +static int vhost_vdpa_net_load (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -445,8 +488,7 @@ static int vhost_vdpa_net_load(NetClientState *nc)if (unlikely (r)) {return r; } - -return 0 ; +return vhost_vdpa_net_load_vlan (s, n); }static NetClientInfo net_vhost_vdpa_cvq_info = { --2.31.1
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
Quoted 78 lines · Eugenio Perez Martin
Quoted 67 lines · Jason Wang
Quoted 65 lines · Jason Wang
Quoted 50 lines · Eugenio Pérez
To have enabled vlans at device startup may happen in the destination of a live migration, so this configuration must be restored.
At this moment the code is not accessible, since SVQ refuses to start if vlan feature is exposed by the device.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)net/vhost-vdpa.c +23
-0@@ -100,6 +100,8 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_RSC_EXT ) |BIT_ULL (VIRTIO_NET_F_STANDBY ); +#define MAX_VLAN (1 << 12)/* Per 802.1Q definition */ +VHostNetState *vhost_vdpa_get_vhost_net (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -423,6 +425,47 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,return *s->status !=VIRTIO_NET_OK ; } +static int vhost_vdpa_net_load_single_vlan (VhostVDPAState *s, +const VirtIONet *n, +uint16_t vid) +{ +ssize_t dev_written =vhost_vdpa_net_load_cmd (s,VIRTIO_NET_CTRL_VLAN , +VIRTIO_NET_CTRL_VLAN_ADD , + &vid,sizeof (vid)); +if (unlikely (dev_written <0 )) { +return dev_written; + } + +if (unlikely (*s->status !=VIRTIO_NET_OK )) { +return -EINVAL ; + } + +return 0 ; +} + +static int vhost_vdpa_net_load_vlan (VhostVDPAState *s, +const VirtIONet *n) +{net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 458
Quoted 10 lines
net/vhost-vdpa.c +10
-0+uint64_t features = n->parent_obj.guest_features; + +if (!(features &BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ))) { +return 0 ; + } + +for (int i =0 ; i <MAX_VLAN >>5 ; i++) { +for (int j =0 ; n->vlans[i] && j <=0x1f ; j++) { +if (n->vlans[i] & (1U << j)) { +int r =vhost_vdpa_net_load_single_vlan (s, n, (i <<5 ) + j);This seems to cause a lot of latency if the driver has a lot of vlans.
Quoted 3 lines
Quoted 2 lines
I wonder if it's simply to let all vlan traffic go by disabling
CTRL_VLANfeature at vDPA layer.The guest will not be able to recover that vlan configuration.
Quoted 3 lines
Another idea is to extend the spec to allow us to accept a bitmap of the vlan ids via a single command, then we will be fine.
Quoted 7 lines
I'm not sure if adding more ways to configure something is the answer, but I'd be ok to implement it.
Another idea is to allow the sending of many CVQ commands in parallel. It shouldn't be very hard to achieve using exposed buffers as ring buffers, and it will short down the start of the devices with many features.
This would seem like a reasonable second step. A first step would be to measure the overhead to make sure there's actually a need to optimize this.
Quoted 34 lines
Thanks!
Quoted 32 lines
Thanks
Quoted 29 lines
Thanks
Quoted 26 lines
net/vhost-vdpa.c +11
-3+if (unlikely (r !=0 )) { +return r; + } + } + } + } + +return 0 ; +} +static int vhost_vdpa_net_load (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -445,8 +488,7 @@ static int vhost_vdpa_net_load(NetClientState *nc)if (unlikely (r)) {return r; } - -return 0 ; +return vhost_vdpa_net_load_vlan (s, n); }static NetClientInfo net_vhost_vdpa_cvq_info = { --2.31.1
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
Quoted 83 lines · Michael S. Tsirkin
Quoted 81 lines · Eugenio Perez Martin
Quoted 67 lines · Jason Wang
Quoted 65 lines · Jason Wang
Quoted 50 lines · Eugenio Pérez
To have enabled vlans at device startup may happen in the destination of a live migration, so this configuration must be restored.
At this moment the code is not accessible, since SVQ refuses to start if vlan feature is exposed by the device.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)net/vhost-vdpa.c +23
-0@@ -100,6 +100,8 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_RSC_EXT ) |BIT_ULL (VIRTIO_NET_F_STANDBY ); +#define MAX_VLAN (1 << 12)/* Per 802.1Q definition */ +VHostNetState *vhost_vdpa_get_vhost_net (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -423,6 +425,47 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,return *s->status !=VIRTIO_NET_OK ; } +static int vhost_vdpa_net_load_single_vlan (VhostVDPAState *s, +const VirtIONet *n, +uint16_t vid) +{ +ssize_t dev_written =vhost_vdpa_net_load_cmd (s,VIRTIO_NET_CTRL_VLAN , +VIRTIO_NET_CTRL_VLAN_ADD , + &vid,sizeof (vid)); +if (unlikely (dev_written <0 )) { +return dev_written; + } + +if (unlikely (*s->status !=VIRTIO_NET_OK )) { +return -EINVAL ; + } + +return 0 ; +} + +static int vhost_vdpa_net_load_vlan (VhostVDPAState *s, +const VirtIONet *n) +{net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 458
Quoted 10 lines
net/vhost-vdpa.c +10
-0+uint64_t features = n->parent_obj.guest_features; + +if (!(features &BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ))) { +return 0 ; + } + +for (int i =0 ; i <MAX_VLAN >>5 ; i++) { +for (int j =0 ; n->vlans[i] && j <=0x1f ; j++) { +if (n->vlans[i] & (1U << j)) { +int r =vhost_vdpa_net_load_single_vlan (s, n, (i <<5 ) + j);This seems to cause a lot of latency if the driver has a lot of vlans.
Quoted 3 lines
Quoted 2 lines
I wonder if it's simply to let all vlan traffic go by disabling
CTRL_VLANfeature at vDPA layer.The guest will not be able to recover that vlan configuration.
Quoted 3 lines
Another idea is to extend the spec to allow us to accept a bitmap of the vlan ids via a single command, then we will be fine.
I'm not sure if adding more ways to configure something is the answer, but I'd be ok to implement it.
Quoted 8 lines
Quoted 4 lines
Another idea is to allow the sending of many CVQ commands in parallel. It shouldn't be very hard to achieve using exposed buffers as ring buffers, and it will short down the start of the devices with many features.
This would seem like a reasonable second step. A first step would be to measure the overhead to make sure there's actually a need to optimize this.
+1.
Thanks
Quoted 37 lines
Quoted 36 lines
Thanks!
Quoted 32 lines
Thanks
Quoted 29 lines
Thanks
Quoted 26 lines
net/vhost-vdpa.c +11
-3+if (unlikely (r !=0 )) { +return r; + } + } + } + } + +return 0 ; +} +static int vhost_vdpa_net_load (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -445,8 +488,7 @@ static int vhost_vdpa_net_load(NetClientState *nc)if (unlikely (r)) {return r; } - -return 0 ; +return vhost_vdpa_net_load_vlan (s, n); }static NetClientInfo net_vhost_vdpa_cvq_info = { --2.31.1
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
In reply to Michael S. TsirkinQuoted 83 lines · Michael S. Tsirkin
Quoted 81 lines · Eugenio Perez Martin
Quoted 67 lines · Jason Wang
Quoted 65 lines · Jason Wang
Quoted 50 lines · Eugenio Pérez
To have enabled vlans at device startup may happen in the destination of a live migration, so this configuration must be restored.
At this moment the code is not accessible, since SVQ refuses to start if vlan feature is exposed by the device.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)net/vhost-vdpa.c +23
-0@@ -100,6 +100,8 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_RSC_EXT ) |BIT_ULL (VIRTIO_NET_F_STANDBY ); +#define MAX_VLAN (1 << 12)/* Per 802.1Q definition */ +VHostNetState *vhost_vdpa_get_vhost_net (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -423,6 +425,47 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,return *s->status !=VIRTIO_NET_OK ; } +static int vhost_vdpa_net_load_single_vlan (VhostVDPAState *s, +const VirtIONet *n, +uint16_t vid) +{ +ssize_t dev_written =vhost_vdpa_net_load_cmd (s,VIRTIO_NET_CTRL_VLAN , +VIRTIO_NET_CTRL_VLAN_ADD , + &vid,sizeof (vid)); +if (unlikely (dev_written <0 )) { +return dev_written; + } + +if (unlikely (*s->status !=VIRTIO_NET_OK )) { +return -EINVAL ; + } + +return 0 ; +} + +static int vhost_vdpa_net_load_vlan (VhostVDPAState *s, +const VirtIONet *n) +{net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 458
Quoted 10 lines
net/vhost-vdpa.c +10
-0+uint64_t features = n->parent_obj.guest_features; + +if (!(features &BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ))) { +return 0 ; + } + +for (int i =0 ; i <MAX_VLAN >>5 ; i++) { +for (int j =0 ; n->vlans[i] && j <=0x1f ; j++) { +if (n->vlans[i] & (1U << j)) { +int r =vhost_vdpa_net_load_single_vlan (s, n, (i <<5 ) + j);This seems to cause a lot of latency if the driver has a lot of vlans.
Quoted 3 lines
Quoted 2 lines
I wonder if it's simply to let all vlan traffic go by disabling
CTRL_VLANfeature at vDPA layer.The guest will not be able to recover that vlan configuration.
Quoted 3 lines
Another idea is to extend the spec to allow us to accept a bitmap of the vlan ids via a single command, then we will be fine.
I'm not sure if adding more ways to configure something is the answer, but I'd be ok to implement it.
Quoted 9 lines
Quoted 4 lines
Another idea is to allow the sending of many CVQ commands in parallel. It shouldn't be very hard to achieve using exposed buffers as ring buffers, and it will short down the start of the devices with many features.
This would seem like a reasonable second step. A first step would be to measure the overhead to make sure there's actually a need to optimize this.
I totally agree.
The processing time of each command is limited by the device. Taking this to the extreme, we could achieve almost instantaneous configuration for vdpa_sim_net, but a new device could take forever to configure each mac.
So I think it should be considered as an optimization on top too, and apply only if we see the initialization is slow on any devices.
Thanks!
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
In reply to Eugenio Perez MartinQuoted 69 lines · Eugenio Perez Martin
Quoted 67 lines · Jason Wang
Quoted 65 lines · Jason Wang
Quoted 50 lines · Eugenio Pérez
To have enabled vlans at device startup may happen in the destination of a live migration, so this configuration must be restored.
At this moment the code is not accessible, since SVQ refuses to start if vlan feature is exposed by the device.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)net/vhost-vdpa.c +23
-0@@ -100,6 +100,8 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_RSC_EXT ) |BIT_ULL (VIRTIO_NET_F_STANDBY ); +#define MAX_VLAN (1 << 12)/* Per 802.1Q definition */ +VHostNetState *vhost_vdpa_get_vhost_net (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -423,6 +425,47 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,return *s->status !=VIRTIO_NET_OK ; } +static int vhost_vdpa_net_load_single_vlan (VhostVDPAState *s, +const VirtIONet *n, +uint16_t vid) +{ +ssize_t dev_written =vhost_vdpa_net_load_cmd (s,VIRTIO_NET_CTRL_VLAN , +VIRTIO_NET_CTRL_VLAN_ADD , + &vid,sizeof (vid)); +if (unlikely (dev_written <0 )) { +return dev_written; + } + +if (unlikely (*s->status !=VIRTIO_NET_OK )) { +return -EINVAL ; + } + +return 0 ; +} + +static int vhost_vdpa_net_load_vlan (VhostVDPAState *s, +const VirtIONet *n) +{net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 458
Quoted 10 lines
net/vhost-vdpa.c +10
-0+uint64_t features = n->parent_obj.guest_features; + +if (!(features &BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ))) { +return 0 ; + } + +for (int i =0 ; i <MAX_VLAN >>5 ; i++) { +for (int j =0 ; n->vlans[i] && j <=0x1f ; j++) { +if (n->vlans[i] & (1U << j)) { +int r =vhost_vdpa_net_load_single_vlan (s, n, (i <<5 ) + j);This seems to cause a lot of latency if the driver has a lot of vlans.
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
I wonder if it's simply to let all vlan traffic go by disabling
CTRL_VLANfeature at vDPA layer.The guest will not be able to recover that vlan configuration.
Spec said it's best effort and we actually don't do this for vhost-net/user for years and manage to survive.
Quoted 5 lines
Quoted 4 lines
Another idea is to extend the spec to allow us to accept a bitmap of the vlan ids via a single command, then we will be fine.
Quoted 7 lines
I'm not sure if adding more ways to configure something is the answer, but I'd be ok to implement it.
Another idea is to allow the sending of many CVQ commands in parallel. It shouldn't be very hard to achieve using exposed buffers as ring buffers, and it will short down the start of the devices with many features.
In the extreme case, what if guests decide to filter all of the vlans? It means we need MAX_VLAN commands which may exceeds the size of the control virtqueue.
Thanks
Quoted 36 lines
Thanks!
Quoted 32 lines
Thanks
Quoted 29 lines
Thanks
Quoted 26 lines
net/vhost-vdpa.c +11
-3+if (unlikely (r !=0 )) { +return r; + } + } + } + } + +return 0 ; +} +static int vhost_vdpa_net_load (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -445,8 +488,7 @@ static int vhost_vdpa_net_load(NetClientState *nc)if (unlikely (r)) {return r; } - -return 0 ; +return vhost_vdpa_net_load_vlan (s, n); }static NetClientInfo net_vhost_vdpa_cvq_info = { --2.31.1
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
Quoted 71 lines · Jason Wang
Quoted 69 lines · Eugenio Perez Martin
Quoted 67 lines · Jason Wang
Quoted 65 lines · Jason Wang
Quoted 50 lines · Eugenio Pérez
To have enabled vlans at device startup may happen in the destination of a live migration, so this configuration must be restored.
At this moment the code is not accessible, since SVQ refuses to start if vlan feature is exposed by the device.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)net/vhost-vdpa.c +23
-0@@ -100,6 +100,8 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_RSC_EXT ) |BIT_ULL (VIRTIO_NET_F_STANDBY ); +#define MAX_VLAN (1 << 12)/* Per 802.1Q definition */ +VHostNetState *vhost_vdpa_get_vhost_net (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -423,6 +425,47 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,return *s->status !=VIRTIO_NET_OK ; } +static int vhost_vdpa_net_load_single_vlan (VhostVDPAState *s, +const VirtIONet *n, +uint16_t vid) +{ +ssize_t dev_written =vhost_vdpa_net_load_cmd (s,VIRTIO_NET_CTRL_VLAN , +VIRTIO_NET_CTRL_VLAN_ADD , + &vid,sizeof (vid)); +if (unlikely (dev_written <0 )) { +return dev_written; + } + +if (unlikely (*s->status !=VIRTIO_NET_OK )) { +return -EINVAL ; + } + +return 0 ; +} + +static int vhost_vdpa_net_load_vlan (VhostVDPAState *s, +const VirtIONet *n) +{net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 458
Quoted 10 lines
net/vhost-vdpa.c +10
-0+uint64_t features = n->parent_obj.guest_features; + +if (!(features &BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ))) { +return 0 ; + } + +for (int i =0 ; i <MAX_VLAN >>5 ; i++) { +for (int j =0 ; n->vlans[i] && j <=0x1f ; j++) { +if (n->vlans[i] & (1U << j)) { +int r =vhost_vdpa_net_load_single_vlan (s, n, (i <<5 ) + j);This seems to cause a lot of latency if the driver has a lot of vlans.
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
I wonder if it's simply to let all vlan traffic go by disabling
CTRL_VLANfeature at vDPA layer.The guest will not be able to recover that vlan configuration.
Spec said it's best effort and we actually don't do this for vhost-net/user for years and manage to survive.
If that is accepted I'm ok to do it that way.
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Another idea is to extend the spec to allow us to accept a bitmap of the vlan ids via a single command, then we will be fine.
I'm not sure if adding more ways to configure something is the answer, but I'd be ok to implement it.
Quoted 9 lines
Quoted 4 lines
Another idea is to allow the sending of many CVQ commands in parallel. It shouldn't be very hard to achieve using exposed buffers as ring buffers, and it will short down the start of the devices with many features.
In the extreme case, what if guests decide to filter all of the vlans? It means we need
MAX_VLANcommands which may exceeds the size of the control virtqueue.
The buffers should be used in a circular manner: If not every vlan / cmd could be sent, we should wait for previous buffers completion and keep sending.
This would speed up not only vlan initialization but all NIC configuration loading.
Quoted 39 lines
Thanks
Quoted 36 lines
Thanks!
Quoted 32 lines
Thanks
Quoted 29 lines
Thanks
Quoted 26 lines
net/vhost-vdpa.c +11
-3+if (unlikely (r !=0 )) { +return r; + } + } + } + } + +return 0 ; +} +static int vhost_vdpa_net_load (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -445,8 +488,7 @@ static int vhost_vdpa_net_load(NetClientState *nc)if (unlikely (r)) {return r; } - -return 0 ; +return vhost_vdpa_net_load_vlan (s, n); }static NetClientInfo net_vhost_vdpa_cvq_info = { --2.31.1
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
In reply to Jason WangQuoted 65 lines · Jason Wang
Quoted 64 lines · Eugenio Perez Martin
Quoted 63 lines · Jason Wang
Quoted 62 lines · Jason Wang
Quoted 49 lines · Eugenio Pérez
To have enabled vlans at device startup may happen in the destination of a live migration, so this configuration must be restored.
At this moment the code is not accessible, since SVQ refuses to start if vlan feature is exposed by the device.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)net/vhost-vdpa.c +23
-0@@ -100,6 +100,8 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_RSC_EXT ) |BIT_ULL (VIRTIO_NET_F_STANDBY ); +#define MAX_VLAN (1 << 12)/* Per 802.1Q definition */ +VHostNetState *vhost_vdpa_get_vhost_net (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -423,6 +425,47 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,return *s->status !=VIRTIO_NET_OK ; } +static int vhost_vdpa_net_load_single_vlan (VhostVDPAState *s, +const VirtIONet *n, +uint16_t vid) +{ +ssize_t dev_written =vhost_vdpa_net_load_cmd (s,VIRTIO_NET_CTRL_VLAN , +VIRTIO_NET_CTRL_VLAN_ADD , + &vid,sizeof (vid)); +if (unlikely (dev_written <0 )) { +return dev_written; + } + +if (unlikely (*s->status !=VIRTIO_NET_OK )) { +return -EINVAL ; + } + +return 0 ; +} + +static int vhost_vdpa_net_load_vlan (VhostVDPAState *s, +const VirtIONet *n) +{net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 458
Quoted 10 lines
net/vhost-vdpa.c +10
-0+uint64_t features = n->parent_obj.guest_features; + +if (!(features &BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ))) { +return 0 ; + } + +for (int i =0 ; i <MAX_VLAN >>5 ; i++) { +for (int j =0 ; n->vlans[i] && j <=0x1f ; j++) { +if (n->vlans[i] & (1U << j)) { +int r =vhost_vdpa_net_load_single_vlan (s, n, (i <<5 ) + j);This seems to cause a lot of latency if the driver has a lot of vlans.
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
I wonder if it's simply to let all vlan traffic go by disabling
CTRL_VLANfeature at vDPA layer.The guest will not be able to recover that vlan configuration.
Spec said it's best effort and we actually don't do this for vhost-net/user for years and manage to survive.
I thought there's a border line between best effort and do nothing. ;-)
I think that the reason this could survive is really software implementation specific - say if the backend doesn't start with VLAN filtering disabled (meaning allow all VLAN traffic to pass) then it would become a problem. This won't be a problem for almost PF NICs but may be problematic for vDPA e.g. VF backed VDPAs.
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Another idea is to extend the spec to allow us to accept a bitmap of the vlan ids via a single command, then we will be fine.
I'm not sure if adding more ways to configure something is the answer, but I'd be ok to implement it.
Quoted 7 lines
Quoted 4 lines
Another idea is to allow the sending of many CVQ commands in parallel. It shouldn't be very hard to achieve using exposed buffers as ring buffers, and it will short down the start of the devices with many features.
In the extreme case, what if guests decide to filter all of the vlans? It means we need
MAX_VLANcommands which may exceeds the size of the control virtqueue.
Indeed, that's a case where a single flat device state blob would be more efficient for hardware drivers to apply than individual control command messages do.
-Siwei
Quoted 35 lines
Thanks
Quoted 32 lines
Thanks!
Quoted 30 lines
Thanks
Quoted 28 lines
Thanks
Quoted 26 lines
net/vhost-vdpa.c +11
-3+if (unlikely (r !=0 )) { +return r; + } + } + } + } + +return 0 ; +} +static int vhost_vdpa_net_load (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -445,8 +488,7 @@ static int vhost_vdpa_net_load(NetClientState *nc)if (unlikely (r)) {return r; } - -return 0 ; +return vhost_vdpa_net_load_vlan (s, n); }static NetClientInfo net_vhost_vdpa_cvq_info = { --2.31.1
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
Quoted 69 lines · Si-Wei Liu
Quoted 65 lines · Jason Wang
Quoted 64 lines · Eugenio Perez Martin
Quoted 63 lines · Jason Wang
Quoted 62 lines · Jason Wang
Quoted 49 lines · Eugenio Pérez
To have enabled vlans at device startup may happen in the destination of a live migration, so this configuration must be restored.
At this moment the code is not accessible, since SVQ refuses to start if vlan feature is exposed by the device.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)net/vhost-vdpa.c +23
-0@@ -100,6 +100,8 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_RSC_EXT ) |BIT_ULL (VIRTIO_NET_F_STANDBY ); +#define MAX_VLAN (1 << 12)/* Per 802.1Q definition */ +VHostNetState *vhost_vdpa_get_vhost_net (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -423,6 +425,47 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,return *s->status !=VIRTIO_NET_OK ; } +static int vhost_vdpa_net_load_single_vlan (VhostVDPAState *s, +const VirtIONet *n, +uint16_t vid) +{ +ssize_t dev_written =vhost_vdpa_net_load_cmd (s,VIRTIO_NET_CTRL_VLAN , +VIRTIO_NET_CTRL_VLAN_ADD , + &vid,sizeof (vid)); +if (unlikely (dev_written <0 )) { +return dev_written; + } + +if (unlikely (*s->status !=VIRTIO_NET_OK )) { +return -EINVAL ; + } + +return 0 ; +} + +static int vhost_vdpa_net_load_vlan (VhostVDPAState *s, +const VirtIONet *n) +{net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 458
Quoted 10 lines
net/vhost-vdpa.c +10
-0+uint64_t features = n->parent_obj.guest_features; + +if (!(features &BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ))) { +return 0 ; + } + +for (int i =0 ; i <MAX_VLAN >>5 ; i++) { +for (int j =0 ; n->vlans[i] && j <=0x1f ; j++) { +if (n->vlans[i] & (1U << j)) { +int r =vhost_vdpa_net_load_single_vlan (s, n, (i <<5 ) + j);This seems to cause a lot of latency if the driver has a lot of vlans.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
I wonder if it's simply to let all vlan traffic go by disabling
CTRL_VLANfeature at vDPA layer.The guest will not be able to recover that vlan configuration.
Spec said it's best effort and we actually don't do this for vhost-net/user for years and manage to survive.
I thought there's a border line between best effort and do nothing. ;-)
I also think it is worth at least trying to migrate it for sure. For MAC there may be too many entries, but VLAN should be totally manageable (and the information is already there, the bitmap is actually being migrated).
Quoted 5 lines
I think that the reason this could survive is really software implementation specific - say if the backend doesn't start with VLAN filtering disabled (meaning allow all VLAN traffic to pass) then it would become a problem. This won't be a problem for almost PF NICs but may be problematic for vDPA e.g. VF backed VDPAs.
I'd say the driver would expect all vlan filters to be cleared after a reset, isn't it? The spec doesn't explicitly say anything about that as far as I see.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines
Another idea is to extend the spec to allow us to accept a bitmap of the vlan ids via a single command, then we will be fine.
I'm not sure if adding more ways to configure something is the answer, but I'd be ok to implement it.
Another idea is to allow the sending of many CVQ commands in parallel. It shouldn't be very hard to achieve using exposed buffers as ring buffers, and it will short down the start of the devices with many features.
Quoted 7 lines
Quoted 3 lines
In the extreme case, what if guests decide to filter all of the vlans? It means we need
MAX_VLANcommands which may exceeds the size of the control virtqueue.Indeed, that's a case where a single flat device state blob would be more efficient for hardware drivers to apply than individual control command messages do.
If we're going that route, being able to set a bitmap for vlan filtering (Jason's proposal) seems to solve more issues in the same shot, doesn't it?
Thanks!
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
Quoted 72 lines · Eugenio Perez Martin
Quoted 71 lines · Si-Wei Liu
Quoted 68 lines · Jason Wang
Quoted 67 lines · Eugenio Perez Martin
Quoted 63 lines · Jason Wang
Quoted 62 lines · Jason Wang
Quoted 49 lines · Eugenio Pérez
To have enabled vlans at device startup may happen in the destination of a live migration, so this configuration must be restored.
At this moment the code is not accessible, since SVQ refuses to start if vlan feature is exposed by the device.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)net/vhost-vdpa.c +23
-0@@ -100,6 +100,8 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_RSC_EXT ) |BIT_ULL (VIRTIO_NET_F_STANDBY ); +#define MAX_VLAN (1 << 12)/* Per 802.1Q definition */ +VHostNetState *vhost_vdpa_get_vhost_net (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -423,6 +425,47 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,return *s->status !=VIRTIO_NET_OK ; } +static int vhost_vdpa_net_load_single_vlan (VhostVDPAState *s, +const VirtIONet *n, +uint16_t vid) +{ +ssize_t dev_written =vhost_vdpa_net_load_cmd (s,VIRTIO_NET_CTRL_VLAN , +VIRTIO_NET_CTRL_VLAN_ADD , + &vid,sizeof (vid)); +if (unlikely (dev_written <0 )) { +return dev_written; + } + +if (unlikely (*s->status !=VIRTIO_NET_OK )) { +return -EINVAL ; + } + +return 0 ; +} + +static int vhost_vdpa_net_load_vlan (VhostVDPAState *s, +const VirtIONet *n) +{net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 458
Quoted 10 lines
net/vhost-vdpa.c +10
-0+uint64_t features = n->parent_obj.guest_features; + +if (!(features &BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ))) { +return 0 ; + } + +for (int i =0 ; i <MAX_VLAN >>5 ; i++) { +for (int j =0 ; n->vlans[i] && j <=0x1f ; j++) { +if (n->vlans[i] & (1U << j)) { +int r =vhost_vdpa_net_load_single_vlan (s, n, (i <<5 ) + j);This seems to cause a lot of latency if the driver has a lot of vlans.
Quoted 2 lines
Quoted 2 lines
I wonder if it's simply to let all vlan traffic go by disabling
CTRL_VLANfeature at vDPA layer.The guest will not be able to recover that vlan configuration.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Spec said it's best effort and we actually don't do this for vhost-net/user for years and manage to survive.
I thought there's a border line between best effort and do nothing. ;-)
I also think it is worth at least trying to migrate it for sure. For MAC there may be too many entries, but VLAN should be totally manageable (and the information is already there, the bitmap is actually being migrated).
The vlan bitmap is migrated, though you'd still need to add vlan filter one by one through ctrl vq commands, correct? AFAIK you can add one filter for one single vlan ID at a time via VIRTIO_NET_CTRL_VLAN_ADD.
Quoted 8 lines
Quoted 6 lines
I think that the reason this could survive is really software implementation specific - say if the backend doesn't start with VLAN filtering disabled (meaning allow all VLAN traffic to pass) then it would become a problem. This won't be a problem for almost PF NICs but may be problematic for vDPA e.g. VF backed VDPAs.
I'd say the driver would expect all vlan filters to be cleared after a reset, isn't it?
If I understand the intended behavior (from QEMU implementation) correctly, when VIRTIO_NET_F_CTRL_VLAN is negotiated it would start with all VLANs filtered (meaning only untagged traffic can be received and traffic with VLAN tag would get dropped). However, if VIRTIO_NET_F_CTRL_VLAN is not negotiated, all traffic including untagged and tagged can be received.
Quoted 2 lines
The spec doesn't explicitly say anything about that
as far as I see.
Here the spec is totally ruled by the (software artifact of) implementation rather than what a real device is expected to work with VLAN rx filters. Are we sure we'd stick to this flawed device implementation? The guest driver seems to be agnostic with this broken spec behavior so far, and I am afraid it's an overkill to add another feature bit or ctrl command to VLAN filter in clean way.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 11 lines
Quoted 4 lines
Another idea is to extend the spec to allow us to accept a bitmap of the vlan ids via a single command, then we will be fine.
I'm not sure if adding more ways to configure something is the answer, but I'd be ok to implement it.
Another idea is to allow the sending of many CVQ commands in parallel. It shouldn't be very hard to achieve using exposed buffers as ring buffers, and it will short down the start of the devices with many features.
In the extreme case, what if guests decide to filter all of the vlans? It means we need
MAX_VLANcommands which may exceeds the size of the control virtqueue.
Quoted 7 lines
Quoted 4 lines
Indeed, that's a case where a single flat device state blob would be more efficient for hardware drivers to apply than individual control command messages do.
If we're going that route, being able to set a bitmap for vlan filtering (Jason's proposal) seems to solve more issues in the same shot, doesn't it?
If I understand correctly about Jason's proposal, it's a spec extension already to add multiple VLAN IDs in a row. This seems not much different than the device state blob for the resume API idea I just presented in the KVM forum (which also needs to extend the spec in another way)?
struct virtio_mig_cfg_net_ctrl_vlan {
struct virtio_mig_state_header hdr;
le32 vlans[128];
};
What is additional benefit that makes it able to solve more issues?
-Siwei
Quoted 3 lines
Thanks!
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
Quoted 138 lines · Si-Wei Liu
Quoted 72 lines · Eugenio Perez Martin
Quoted 71 lines · Si-Wei Liu
Quoted 68 lines · Jason Wang
Quoted 67 lines · Eugenio Perez Martin
Quoted 63 lines · Jason Wang
Quoted 62 lines · Jason Wang
Quoted 49 lines · Eugenio Pérez
To have enabled vlans at device startup may happen in the destination of a live migration, so this configuration must be restored.
At this moment the code is not accessible, since SVQ refuses to start if vlan feature is exposed by the device.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)net/vhost-vdpa.c +23
-0@@ -100,6 +100,8 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_RSC_EXT ) |BIT_ULL (VIRTIO_NET_F_STANDBY ); +#define MAX_VLAN (1 << 12)/* Per 802.1Q definition */ +VHostNetState *vhost_vdpa_get_vhost_net (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -423,6 +425,47 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,return *s->status !=VIRTIO_NET_OK ; } +static int vhost_vdpa_net_load_single_vlan (VhostVDPAState *s, +const VirtIONet *n, +uint16_t vid) +{ +ssize_t dev_written =vhost_vdpa_net_load_cmd (s,VIRTIO_NET_CTRL_VLAN , +VIRTIO_NET_CTRL_VLAN_ADD , + &vid,sizeof (vid)); +if (unlikely (dev_written <0 )) { +return dev_written; + } + +if (unlikely (*s->status !=VIRTIO_NET_OK )) { +return -EINVAL ; + } + +return 0 ; +} + +static int vhost_vdpa_net_load_vlan (VhostVDPAState *s, +const VirtIONet *n) +{net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 458
Quoted 10 lines
net/vhost-vdpa.c +10
-0+uint64_t features = n->parent_obj.guest_features; + +if (!(features &BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ))) { +return 0 ; + } + +for (int i =0 ; i <MAX_VLAN >>5 ; i++) { +for (int j =0 ; n->vlans[i] && j <=0x1f ; j++) { +if (n->vlans[i] & (1U << j)) { +int r =vhost_vdpa_net_load_single_vlan (s, n, (i <<5 ) + j);This seems to cause a lot of latency if the driver has a lot of vlans.
Quoted 2 lines
Quoted 2 lines
I wonder if it's simply to let all vlan traffic go by disabling
CTRL_VLANfeature at vDPA layer.The guest will not be able to recover that vlan configuration.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Spec said it's best effort and we actually don't do this for vhost-net/user for years and manage to survive.
I thought there's a border line between best effort and do nothing. ;-)
I also think it is worth at least trying to migrate it for sure. For MAC there may be too many entries, but VLAN should be totally manageable (and the information is already there, the bitmap is actually being migrated).
The vlan bitmap is migrated, though you'd still need to add vlan filter one by one through ctrl vq commands, correct? AFAIK you can add one filter for one single vlan ID at a time via
VIRTIO_NET_CTRL_VLAN_ADD.Quoted 8 lines
Quoted 6 lines
I think that the reason this could survive is really software implementation specific - say if the backend doesn't start with VLAN filtering disabled (meaning allow all VLAN traffic to pass) then it would become a problem. This won't be a problem for almost PF NICs but may be problematic for vDPA e.g. VF backed VDPAs.
I'd say the driver would expect all vlan filters to be cleared after a reset, isn't it?
If I understand the intended behavior (from QEMU implementation) correctly, when
VIRTIO_NET_F_CTRL_VLANis negotiated it would start with all VLANs filtered (meaning only untagged traffic can be received and traffic with VLAN tag would get dropped). However, ifVIRTIO_NET_F_CTRL_VLANis not negotiated, all traffic including untagged and tagged can be received.Quoted 2 lines
The spec doesn't explicitly say anything about that
as far as I see.Here the spec is totally ruled by the (software artifact of) implementation rather than what a real device is expected to work with VLAN rx filters. Are we sure we'd stick to this flawed device implementation? The guest driver seems to be agnostic with this broken spec behavior so far, and I am afraid it's an overkill to add another feature bit or ctrl command to VLAN filter in clean way.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 11 lines
Quoted 4 lines
Another idea is to extend the spec to allow us to accept a bitmap of the vlan ids via a single command, then we will be fine.
I'm not sure if adding more ways to configure something is the answer, but I'd be ok to implement it.
Another idea is to allow the sending of many CVQ commands in parallel. It shouldn't be very hard to achieve using exposed buffers as ring buffers, and it will short down the start of the devices with many features.
In the extreme case, what if guests decide to filter all of the vlans? It means we need
MAX_VLANcommands which may exceeds the size of the control virtqueue.Quoted 7 lines
Quoted 4 lines
Indeed, that's a case where a single flat device state blob would be more efficient for hardware drivers to apply than individual control command messages do.
If we're going that route, being able to set a bitmap for vlan filtering (Jason's proposal) seems to solve more issues in the same shot, doesn't it?
If I understand correctly about Jason's proposal, it's a spec extension already to add multiple VLAN IDs in a row. This seems not much different than the device state blob for the resume API idea I just presented in the KVM forum (which also needs to extend the spec in another way)?
Quoted 5 lines
struct virtio_mig_cfg_net_ctrl_vlan {
struct virtio_mig_state_header hdr;
le32 vlans[128];
};Some thoughts, actually, it's a choice of
1) trap and emulate
vs
2) load and save
So far vDPA chooses the way for method 1 (but it doesn't exclude the possibility of method 2). The main "problem" in method 2 is that it may not work or still require trap in the nesting layer.
For example, in the case of ctrl_vlan, if we simply extend the spec with an additional command, trap and emulate still work like a charm.
For load and save, it looks to me it would be better to start the work in the spec (NV is trying to do this). Going with vDPA is also fine if spec turns out to be too hard.
Thanks
Quoted 8 lines
What is additional benefit that makes it able to solve more issues?
-Siwei
Quoted 3 lines
Thanks!
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
In reply to Si-Wei LiuQuoted 103 lines · Si-Wei Liu
Quoted 72 lines · Eugenio Perez Martin
Quoted 71 lines · Si-Wei Liu
Quoted 68 lines · Jason Wang
Quoted 67 lines · Eugenio Perez Martin
Quoted 63 lines · Jason Wang
Quoted 62 lines · Jason Wang
Quoted 49 lines · Eugenio Pérez
To have enabled vlans at device startup may happen in the destination of a live migration, so this configuration must be restored.
At this moment the code is not accessible, since SVQ refuses to start if vlan feature is exposed by the device.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)net/vhost-vdpa.c +23
-0@@ -100,6 +100,8 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_RSC_EXT ) |BIT_ULL (VIRTIO_NET_F_STANDBY ); +#define MAX_VLAN (1 << 12)/* Per 802.1Q definition */ +VHostNetState *vhost_vdpa_get_vhost_net (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -423,6 +425,47 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,return *s->status !=VIRTIO_NET_OK ; } +static int vhost_vdpa_net_load_single_vlan (VhostVDPAState *s, +const VirtIONet *n, +uint16_t vid) +{ +ssize_t dev_written =vhost_vdpa_net_load_cmd (s,VIRTIO_NET_CTRL_VLAN , +VIRTIO_NET_CTRL_VLAN_ADD , + &vid,sizeof (vid)); +if (unlikely (dev_written <0 )) { +return dev_written; + } + +if (unlikely (*s->status !=VIRTIO_NET_OK )) { +return -EINVAL ; + } + +return 0 ; +} + +static int vhost_vdpa_net_load_vlan (VhostVDPAState *s, +const VirtIONet *n) +{net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 458
Quoted 10 lines
net/vhost-vdpa.c +10
-0+uint64_t features = n->parent_obj.guest_features; + +if (!(features &BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ))) { +return 0 ; + } + +for (int i =0 ; i <MAX_VLAN >>5 ; i++) { +for (int j =0 ; n->vlans[i] && j <=0x1f ; j++) { +if (n->vlans[i] & (1U << j)) { +int r =vhost_vdpa_net_load_single_vlan (s, n, (i <<5 ) + j);This seems to cause a lot of latency if the driver has a lot of vlans.
Quoted 2 lines
Quoted 2 lines
I wonder if it's simply to let all vlan traffic go by disabling
CTRL_VLANfeature at vDPA layer.The guest will not be able to recover that vlan configuration.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Spec said it's best effort and we actually don't do this for vhost-net/user for years and manage to survive.
I thought there's a border line between best effort and do nothing. ;-)
I also think it is worth at least trying to migrate it for sure. For MAC there may be too many entries, but VLAN should be totally manageable (and the information is already there, the bitmap is actually being migrated).
The vlan bitmap is migrated, though you'd still need to add vlan filter one by one through ctrl vq commands, correct? AFAIK you can add one filter for one single vlan ID at a time via
VIRTIO_NET_CTRL_VLAN_ADD.Quoted 8 lines
Quoted 6 lines
I think that the reason this could survive is really software implementation specific - say if the backend doesn't start with VLAN filtering disabled (meaning allow all VLAN traffic to pass) then it would become a problem. This won't be a problem for almost PF NICs but may be problematic for vDPA e.g. VF backed VDPAs.
I'd say the driver would expect all vlan filters to be cleared after a reset, isn't it?
If I understand the intended behavior (from QEMU implementation) correctly, when
VIRTIO_NET_F_CTRL_VLANis negotiated it would start with all VLANs filtered (meaning only untagged traffic can be received and traffic with VLAN tag would get dropped). However, ifVIRTIO_NET_F_CTRL_VLANis not negotiated, all traffic including untagged and tagged can be received.
Quoted 9 lines
Quoted 2 lines
The spec doesn't explicitly say anything about that
as far as I see.Here the spec is totally ruled by the (software artifact of) implementation rather than what a real device is expected to work with VLAN rx filters. Are we sure we'd stick to this flawed device implementation? The guest driver seems to be agnostic with this broken spec behavior so far, and I am afraid it's an overkill to add another feature bit or ctrl command to VLAN filter in clean way.
I agree with all of the above. So, double checking, all vlan should be allowed by default at device start? Maybe the spec needs to be more clear in that regard?
Quoted 26 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 11 lines
Quoted 4 lines
Another idea is to extend the spec to allow us to accept a bitmap of the vlan ids via a single command, then we will be fine.
I'm not sure if adding more ways to configure something is the answer, but I'd be ok to implement it.
Another idea is to allow the sending of many CVQ commands in parallel. It shouldn't be very hard to achieve using exposed buffers as ring buffers, and it will short down the start of the devices with many features.
In the extreme case, what if guests decide to filter all of the vlans? It means we need
MAX_VLANcommands which may exceeds the size of the control virtqueue.Quoted 7 lines
Quoted 4 lines
Indeed, that's a case where a single flat device state blob would be more efficient for hardware drivers to apply than individual control command messages do.
If we're going that route, being able to set a bitmap for vlan filtering (Jason's proposal) seems to solve more issues in the same shot, doesn't it?
If I understand correctly about Jason's proposal, it's a spec extension already to add multiple VLAN IDs in a row. This seems not much different than the device state blob for the resume API idea I just presented in the KVM forum (which also needs to extend the spec in another way)?
Quoted 7 lines
struct virtio_mig_cfg_net_ctrl_vlan { struct virtio_mig_state_header hdr; le32 vlans[128]; };What is additional benefit that makes it able to solve more issues?
Maybe I totally misunderstood you.
I don't think the solution to this problem is to create a call from the VMM to restore all the device state (vlan, mac, stats, ...), because that would not allow the guest to configure many vlan filters in one shot and retain all other config.
If your proposal is like Jason's in that regard, I'm totally ok with it, and I don't have a strong opinion about the layout. Maybe I would not name it "mig_state", since it would be used by the guest in other contexts than migration.
In other words, we should handle this outside of the migration scope, because the guest may use it to set many vlan filters in one shot, retaining other configuration. No more, no less.
Thanks!
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
Quoted 110 lines · Eugenio Perez Martin
Quoted 100 lines · Si-Wei Liu
Quoted 71 lines · Eugenio Perez Martin
Quoted 70 lines · Si-Wei Liu
Quoted 68 lines · Jason Wang
Quoted 67 lines · Eugenio Perez Martin
Quoted 63 lines · Jason Wang
Quoted 62 lines · Jason Wang
Quoted 49 lines · Eugenio Pérez
To have enabled vlans at device startup may happen in the destination of a live migration, so this configuration must be restored.
At this moment the code is not accessible, since SVQ refuses to start if vlan feature is exposed by the device.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)net/vhost-vdpa.c +23
-0@@ -100,6 +100,8 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_RSC_EXT ) |BIT_ULL (VIRTIO_NET_F_STANDBY ); +#define MAX_VLAN (1 << 12)/* Per 802.1Q definition */ +VHostNetState *vhost_vdpa_get_vhost_net (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -423,6 +425,47 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,return *s->status !=VIRTIO_NET_OK ; } +static int vhost_vdpa_net_load_single_vlan (VhostVDPAState *s, +const VirtIONet *n, +uint16_t vid) +{ +ssize_t dev_written =vhost_vdpa_net_load_cmd (s,VIRTIO_NET_CTRL_VLAN , +VIRTIO_NET_CTRL_VLAN_ADD , + &vid,sizeof (vid)); +if (unlikely (dev_written <0 )) { +return dev_written; + } + +if (unlikely (*s->status !=VIRTIO_NET_OK )) { +return -EINVAL ; + } + +return 0 ; +} + +static int vhost_vdpa_net_load_vlan (VhostVDPAState *s, +const VirtIONet *n) +{net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 458
Quoted 10 lines
net/vhost-vdpa.c +10
-0+uint64_t features = n->parent_obj.guest_features; + +if (!(features &BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ))) { +return 0 ; + } + +for (int i =0 ; i <MAX_VLAN >>5 ; i++) { +for (int j =0 ; n->vlans[i] && j <=0x1f ; j++) { +if (n->vlans[i] & (1U << j)) { +int r =vhost_vdpa_net_load_single_vlan (s, n, (i <<5 ) + j);This seems to cause a lot of latency if the driver has a lot of vlans.
Quoted 2 lines
Quoted 2 lines
I wonder if it's simply to let all vlan traffic go by disabling
CTRL_VLANfeature at vDPA layer.The guest will not be able to recover that vlan configuration.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Spec said it's best effort and we actually don't do this for vhost-net/user for years and manage to survive.
I thought there's a border line between best effort and do nothing. ;-)
I also think it is worth at least trying to migrate it for sure. For MAC there may be too many entries, but VLAN should be totally manageable (and the information is already there, the bitmap is actually being migrated).
The vlan bitmap is migrated, though you'd still need to add vlan filter one by one through ctrl vq commands, correct? AFAIK you can add one filter for one single vlan ID at a time via
VIRTIO_NET_CTRL_VLAN_ADD.Quoted 7 lines
Quoted 5 lines
I think that the reason this could survive is really software implementation specific - say if the backend doesn't start with VLAN filtering disabled (meaning allow all VLAN traffic to pass) then it would become a problem. This won't be a problem for almost PF NICs but may be problematic for vDPA e.g. VF backed VDPAs.
I'd say the driver would expect all vlan filters to be cleared after a reset, isn't it?
If I understand the intended behavior (from QEMU implementation) correctly, when
VIRTIO_NET_F_CTRL_VLANis negotiated it would start with all VLANs filtered (meaning only untagged traffic can be received and traffic with VLAN tag would get dropped). However, ifVIRTIO_NET_F_CTRL_VLANis not negotiated, all traffic including untagged and tagged can be received.Quoted 9 lines
Quoted 2 lines
The spec doesn't explicitly say anything about that
as far as I see.Here the spec is totally ruled by the (software artifact of) implementation rather than what a real device is expected to work with VLAN rx filters. Are we sure we'd stick to this flawed device implementation? The guest driver seems to be agnostic with this broken spec behavior so far, and I am afraid it's an overkill to add another feature bit or ctrl command to VLAN filter in clean way.
Quoted 2 lines
I agree with all of the above. So, double checking, all vlan should be allowed by default at device start?
That is true only when VIRTIO_NET_F_CTRL_VLAN is not negotiated. If the guest already negotiated VIRTIO_NET_F_CTRL_VLAN before being migrated, device should resume with all VLANs filtered/disallowed.
Quoted 2 lines
Maybe the spec needs to be more
clear in that regard?
Yes, I think this is crucial. Otherwise we can't get consistent behavior, either from software to vDPA, or cross various vDPA vendors.
Quoted 31 lines
Quoted 31 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 11 lines
Quoted 4 lines
Another idea is to extend the spec to allow us to accept a bitmap of the vlan ids via a single command, then we will be fine.
I'm not sure if adding more ways to configure something is the answer, but I'd be ok to implement it.
Another idea is to allow the sending of many CVQ commands in parallel. It shouldn't be very hard to achieve using exposed buffers as ring buffers, and it will short down the start of the devices with many features.
In the extreme case, what if guests decide to filter all of the vlans? It means we need
MAX_VLANcommands which may exceeds the size of the control virtqueue.Quoted 7 lines
Quoted 4 lines
Indeed, that's a case where a single flat device state blob would be more efficient for hardware drivers to apply than individual control command messages do.
If we're going that route, being able to set a bitmap for vlan filtering (Jason's proposal) seems to solve more issues in the same shot, doesn't it?
If I understand correctly about Jason's proposal, it's a spec extension already to add multiple VLAN IDs in a row. This seems not much different than the device state blob for the resume API idea I just presented in the KVM forum (which also needs to extend the spec in another way)?
struct virtio_mig_cfg_net_ctrl_vlan { struct virtio_mig_state_header hdr; le32 vlans[128]; };
Quoted 8 lines
Quoted 2 lines
What is additional benefit that makes it able to solve more issues?
Maybe I totally misunderstood you.
I don't think the solution to this problem is to create a call from the VMM to restore all the device state (vlan, mac, stats, ...), because that would not allow the guest to configure many vlan filters in one shot and retain all other config.
Noted I was simply asking question. I am trying to understand if there exists a use case *out of migration* that the guest would require programming multiple vlan filters in a row rather than do multiple VIRTIO_NET_CTRL_VLAN_ADD calls, adding one vlan filter each. If there's indeed such a use case, then it's a nice addition out of the migration case, I agree.
Thanks,
-Siwei
Quoted 12 lines
If your proposal is like Jason's in that regard, I'm totally ok with it, and I don't have a strong opinion about the layout. Maybe I would not name it "
mig_state", since it would be used by the guest in other contexts than migration.In other words, we should handle this outside of the migration scope, because the guest may use it to set many vlan filters in one shot, retaining other configuration. No more, no less.
Thanks!
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
Quoted 11 lines · Si-Wei Liu
Quoted 11 lines
Quoted 9 lines
Quoted 2 lines
The spec doesn't explicitly say anything about that
as far as I see.Here the spec is totally ruled by the (software artifact of) implementation rather than what a real device is expected to work with VLAN rx filters. Are we sure we'd stick to this flawed device implementation? The guest driver seems to be agnostic with this broken spec behavior so far, and I am afraid it's an overkill to add another feature bit or ctrl command to VLAN filter in clean way.
I agree with all of the above. So, double checking, all vlan should be allowed by default at device start?
Quoted 8 lines
That is true only when
VIRTIO_NET_F_CTRL_VLANis not negotiated. If the guest already negotiatedVIRTIO_NET_F_CTRL_VLANbefore being migrated, device should resume with all VLANs filtered/disallowed.Quoted 2 lines
Maybe the spec needs to be more
clear in that regard?Yes, I think this is crucial. Otherwise we can't get consistent behavior, either from software to vDPA, or cross various vDPA vendors.
OK. Can you open a github issue for the spec? We'll try to address. Also, is it ok if we make it a SHOULD, i.e. best effort filtering?
Signature · 1 line
MST
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
Quoted 16 lines · Michael S. Tsirkin
Quoted 15 lines · Si-Wei Liu
Quoted 11 lines
Quoted 9 lines
Quoted 2 lines
The spec doesn't explicitly say anything about that
as far as I see.Here the spec is totally ruled by the (software artifact of) implementation rather than what a real device is expected to work with VLAN rx filters. Are we sure we'd stick to this flawed device implementation? The guest driver seems to be agnostic with this broken spec behavior so far, and I am afraid it's an overkill to add another feature bit or ctrl command to VLAN filter in clean way.
I agree with all of the above. So, double checking, all vlan should be allowed by default at device start?
That is true only when
VIRTIO_NET_F_CTRL_VLANis not negotiated. If the guest already negotiatedVIRTIO_NET_F_CTRL_VLANbefore being migrated, device should resume with all VLANs filtered/disallowed.
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Maybe the spec needs to be more
clear in that regard?Yes, I think this is crucial. Otherwise we can't get consistent behavior, either from software to vDPA, or cross various vDPA vendors.
OK. Can you open a github issue for the spec? We'll try to address.
Thanks, ticket filed at:
https://github.com/oasis-tcs/virtio-spec/issues/147
Quoted 2 lines
Also, is it ok if we make it a SHOULD, i.e. best effort filtering?
Yes, that's fine.
-Siwei
Re: [PATCH 2/3] vdpa: load vlan configuration at NIC startup
In reply to Si-Wei LiuQuoted 74 lines · Si-Wei Liu
Quoted 65 lines · Jason Wang
Quoted 64 lines · Eugenio Perez Martin
Quoted 63 lines · Jason Wang
Quoted 62 lines · Jason Wang
Quoted 49 lines · Eugenio Pérez
To have enabled vlans at device startup may happen in the destination of a live migration, so this configuration must be restored.
At this moment the code is not accessible, since SVQ refuses to start if vlan feature is exposed by the device.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)net/vhost-vdpa.c +23
-0@@ -100,6 +100,8 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_RSC_EXT ) |BIT_ULL (VIRTIO_NET_F_STANDBY ); +#define MAX_VLAN (1 << 12)/* Per 802.1Q definition */ +VHostNetState *vhost_vdpa_get_vhost_net (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -423,6 +425,47 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,return *s->status !=VIRTIO_NET_OK ; } +static int vhost_vdpa_net_load_single_vlan (VhostVDPAState *s, +const VirtIONet *n, +uint16_t vid) +{ +ssize_t dev_written =vhost_vdpa_net_load_cmd (s,VIRTIO_NET_CTRL_VLAN , +VIRTIO_NET_CTRL_VLAN_ADD , + &vid,sizeof (vid)); +if (unlikely (dev_written <0 )) { +return dev_written; + } + +if (unlikely (*s->status !=VIRTIO_NET_OK )) { +return -EINVAL ; + } + +return 0 ; +} + +static int vhost_vdpa_net_load_vlan (VhostVDPAState *s, +const VirtIONet *n) +{net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 458
Quoted 10 lines
net/vhost-vdpa.c +10
-0+uint64_t features = n->parent_obj.guest_features; + +if (!(features &BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ))) { +return 0 ; + } + +for (int i =0 ; i <MAX_VLAN >>5 ; i++) { +for (int j =0 ; n->vlans[i] && j <=0x1f ; j++) { +if (n->vlans[i] & (1U << j)) { +int r =vhost_vdpa_net_load_single_vlan (s, n, (i <<5 ) + j);This seems to cause a lot of latency if the driver has a lot of vlans.
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
I wonder if it's simply to let all vlan traffic go by disabling
CTRL_VLANfeature at vDPA layer.The guest will not be able to recover that vlan configuration.
Spec said it's best effort and we actually don't do this for vhost-net/user for years and manage to survive.
Quoted 7 lines
I thought there's a border line between best effort and do nothing. ;-)
I think that the reason this could survive is really software implementation specific - say if the backend doesn't start with VLAN filtering disabled (meaning allow all VLAN traffic to pass) then it would become a problem. This won't be a problem for almost PF NICs but may be problematic for vDPA e.g. VF backed VDPAs.
So it looks like an issue of the implementation. If CTRL_VLAN is not negotiated, the device should disable vlan filters.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines
Another idea is to extend the spec to allow us to accept a bitmap of the vlan ids via a single command, then we will be fine.
I'm not sure if adding more ways to configure something is the answer, but I'd be ok to implement it.
Another idea is to allow the sending of many CVQ commands in parallel. It shouldn't be very hard to achieve using exposed buffers as ring buffers, and it will short down the start of the devices with many features.
Quoted 6 lines
Quoted 3 lines
In the extreme case, what if guests decide to filter all of the vlans? It means we need
MAX_VLANcommands which may exceeds the size of the control virtqueue.Indeed, that's a case where a single flat device state blob would be more efficient for hardware drivers to apply than individual control command messages do.
Right, so we can optimize the spec for this.
Thanks
Quoted 38 lines
-Siwei
Quoted 35 lines
Thanks
Quoted 32 lines
Thanks!
Quoted 30 lines
Thanks
Quoted 28 lines
Thanks
Quoted 26 lines
net/vhost-vdpa.c +11
-3+if (unlikely (r !=0 )) { +return r; + } + } + } + } + +return 0 ; +} +static int vhost_vdpa_net_load (NetClientState *nc) {VhostVDPAState *s =DO_UPCAST (VhostVDPAState, nc, nc);@@ -445,8 +488,7 @@ static int vhost_vdpa_net_load(NetClientState *nc)if (unlikely (r)) {return r; } - -return 0 ; +return vhost_vdpa_net_load_vlan (s, n); }static NetClientInfo net_vhost_vdpa_cvq_info = { --2.31.1
PATCH 3/3 vdpa: Support VLAN on nic control shadow virtqueue
In reply to Eugenio PérezUpdate the virtio-net device model with each guest's update of vlan through control virtqueue, and accept creating a SVQ with a device exposing vlan feature bit.
Done in the same commit since a malicious guest could send vlan commands otherwise.
--- net/vhost-vdpa.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
net/vhost-vdpa.c +11 -0
@@ -94,6 +94,7 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_MRG_RXBUF ) |BIT_ULL (VIRTIO_NET_F_STATUS ) |BIT_ULL (VIRTIO_NET_F_CTRL_VQ ) | +BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ) |BIT_ULL (VIRTIO_NET_F_MQ ) |BIT_ULL (VIRTIO_F_ANY_LAYOUT ) | BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) |
@@ -538,6 +539,16 @@ static bool vhost_vdpa_net_cvq_validate_cmd(const void *out_buf, size_t len) __func__, ctrl.cmd); };break ; +case VIRTIO_NET_CTRL_VLAN : +switch (ctrl->cmd) { +case VIRTIO_NET_CTRL_VLAN_ADD : +case VIRTIO_NET_CTRL_VLAN_DEL : +return true; +default : +qemu_log_mask (LOG_GUEST_ERROR ,"%s: invalid vlan cmd %u\n" , + __func__, ctrl->cmd); + }; +break ;default :qemu_log_mask (LOG_GUEST_ERROR ,"%s: invalid control class %u\n" , __func__, ctrl.class);
Signature · 1 line
2.31.1
Re: [PATCH 3/3] vdpa: Support VLAN on nic control shadow virtqueue
Quoted 28 lines · Eugenio Pérez
Update the virtio-net device model with each guest's update of vlan through control virtqueue, and accept creating a SVQ with a device exposing vlan feature bit.
Done in the same commit since a malicious guest could send vlan commands otherwise.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 11 +++++++++++ 1 file changed, 11 insertions(+)net/vhost-vdpa.c +1
-0@@ -94,6 +94,7 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_MRG_RXBUF ) |BIT_ULL (VIRTIO_NET_F_STATUS ) |BIT_ULL (VIRTIO_NET_F_CTRL_VQ ) | +BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ) |BIT_ULL (VIRTIO_NET_F_MQ ) |BIT_ULL (VIRTIO_F_ANY_LAYOUT ) | BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) |@@ -538,6 +539,16 @@ static bool vhost_vdpa_net_cvq_validate_cmd(const void *out_buf, size_t len) __func__, ctrl.cmd); };
net/vhost-vdpa.c static bool vhost_vdpa_net_cvq_validate_cmd(const void *out_buf, size_t len) · line 550
Quoted 10 lines
net/vhost-vdpa.c +9
-0break ; +case VIRTIO_NET_CTRL_VLAN : +switch (ctrl->cmd) { +case VIRTIO_NET_CTRL_VLAN_ADD : +case VIRTIO_NET_CTRL_VLAN_DEL : +return true; +default : +qemu_log_mask (LOG_GUEST_ERROR ,"%s: invalid vlan cmd %u\n" , + __func__, ctrl->cmd); + };
Considering we may add more features here, is it still worthwhile to keep a whitelist like this?
Thanks
Quoted 7 lines
net/vhost-vdpa.c +1
-1+break ;default :qemu_log_mask (LOG_GUEST_ERROR ,"%s: invalid control class %u\n" , __func__, ctrl.class); --2.31.1
Re: [PATCH 3/3] vdpa: Support VLAN on nic control shadow virtqueue
Quoted 25 lines · Jason Wang
Quoted 23 lines · Eugenio Pérez
Update the virtio-net device model with each guest's update of vlan through control virtqueue, and accept creating a SVQ with a device exposing vlan feature bit.
Done in the same commit since a malicious guest could send vlan commands otherwise.
Signed-off-by Eugenio Pérez <[email protected]>--- net/vhost-vdpa.c | 11 +++++++++++ 1 file changed, 11 insertions(+)net/vhost-vdpa.c +1
-0@@ -94,6 +94,7 @@ static const uint64_t vdpa_svq_device_features =BIT_ULL (VIRTIO_NET_F_MRG_RXBUF ) |BIT_ULL (VIRTIO_NET_F_STATUS ) |BIT_ULL (VIRTIO_NET_F_CTRL_VQ ) | +BIT_ULL (VIRTIO_NET_F_CTRL_VLAN ) | BIT_ULL(VIRTIO_NET_F_MQ) |
Quoted 8 lines
net/vhost-vdpa.c static bool vhost_vdpa_net_cvq_validate_cmd(const void *out_buf, size_t len) · line 543
Quoted 8 lines
net/vhost-vdpa.c +2
-0BIT_ULL (VIRTIO_F_ANY_LAYOUT ) | BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) |@@ -538,6 +539,16 @@ static bool vhost_vdpa_net_cvq_validate_cmd(const void *out_buf, size_t len) __func__, ctrl.cmd); };break ; +case VIRTIO_NET_CTRL_VLAN : +switch (ctrl->cmd) {
Rebase mistake by my side: This must be ctrl.cmd.
Quoted 6 lines
net/vhost-vdpa.c static bool vhost_vdpa_net_cvq_validate_cmd(const void *out_buf, size_t len) · line 549
Quoted 6 lines
net/vhost-vdpa.c +6
-0+case VIRTIO_NET_CTRL_VLAN_ADD : +case VIRTIO_NET_CTRL_VLAN_DEL : +return true; +default : +qemu_log_mask (LOG_GUEST_ERROR ,"%s: invalid vlan cmd %u\n" , + __func__, ctrl->cmd);
Same here (s/ctrl->cmd/ctrl.cmd/).
Quoted 5 lines
net/vhost-vdpa.c static bool vhost_vdpa_net_cvq_validate_cmd(const void *out_buf, size_t len) · line 550
Quoted 1 line
net/vhost-vdpa.c +1
-0+ };Considering we may add more features here, is it still worthwhile to keep a whitelist like this?
I guess we can remove it, let me test without it.
Thanks!
Quoted 10 lines
Thanks
Quoted 7 lines
net/vhost-vdpa.c +1
-1+break ;default :qemu_log_mask (LOG_GUEST_ERROR ,"%s: invalid control class %u\n" , __func__, ctrl.class); --2.31.1