Skip to contentSkip to conversation

net/virtio: fix promisc mode enable failure

PATCH Superseded Marvin Liu 3 participants 10 messages Oct 28, 2019 – Nov 6, 2019 Network drivers

lore
Share & tools
lore

Marvin Liu

author
#0 lore raw

PATCH 1/1 net/virtio: fix promisc mode enable failure

As doc mentioned, promisc and multicast are by-default supported in virtio pmd. Mac/vlan filter are supported by best effort. These control messages should return pass.

Fixes f9b9d1a55775 ("net/virtio-user: add multiple queues in device emulation")
---
 .../net/virtio/virtio_user/virtio_user_dev.c    | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/net/virtio/virtio_user/virtio_user_dev.c +13 -4
index 1c575d0cd..d7588e920 100644
@@ -587,7 +587,7 @@ static uint32_t
 virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
 			    uint16_t idx_hdr)
 {
-	struct virtio_net_ctrl_hdr *hdr;
+	struct virtio_pmd_ctrl *ctrl;
 	virtio_net_ctrl_ack status = ~0;
 	uint16_t i, idx_data, idx_status;
 	uint32_t n_descs = 0;
@@ -606,13 +606,22 @@ virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
 	idx_status = i;
 	n_descs++;
 
-	hdr = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
-	if (hdr->class == VIRTIO_NET_CTRL_MQ &&
-	    hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
+	ctrl = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
+	if (ctrl->hdr.class == VIRTIO_NET_CTRL_MQ &&
+	    ctrl->hdr.cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
 		uint16_t queues;
 
 		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_RX) {
+		if (ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_PROMISC ||
+		    ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_ALLMULTI) {
+			if (ctrl->data[0])
+				status = 0;
+		}
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_MAC ||
+		   ctrl->hdr.class == VIRTIO_NET_CTRL_VLAN) {
+		status = 0;
 	}
 
 	/* Update status */
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 1/1 net/virtio: fix multicast and promisc mode enable failure

As doc mentioned, promisc and multicast are by-default supported in virtio pmd. Mac/vlan filter are supported by best effort. These control messages should return pass.

Fixes f9b9d1a55775 ("net/virtio-user: add multiple queues in device emulation")
---
 drivers/net/virtio/virtio_ethdev.c            |  4 ++
 .../net/virtio/virtio_user/virtio_user_dev.c  | 37 ++++++++++++++-----
 2 files changed, 31 insertions(+), 10 deletions(-)
drivers/net/virtio/virtio_ethdev.c +4 -0
index 646de9945..ac412071b 100644
@@ -1697,6 +1697,10 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)
 	else
 		eth_dev->data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC;
 
+	/* multicast and promisc mode are always enabled */
+	eth_dev->data->promiscuous = 1;
+	eth_dev->data->all_multicast = 1;
+
 	/* Setting up rx_header size for the device */
 	if (vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF) ||
 	    vtpci_with_feature(hw, VIRTIO_F_VERSION_1) ||
drivers/net/virtio/virtio_user/virtio_user_dev.c +27 -10
index 1c575d0cd..b614dd0c0 100644
@@ -587,7 +587,7 @@ static uint32_t
 virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
 			    uint16_t idx_hdr)
 {
-	struct virtio_net_ctrl_hdr *hdr;
+	struct virtio_pmd_ctrl *ctrl;
 	virtio_net_ctrl_ack status = ~0;
 	uint16_t i, idx_data, idx_status;
 	uint32_t n_descs = 0;
@@ -606,13 +606,22 @@ virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
 	idx_status = i;
 	n_descs++;
 
-	hdr = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
-	if (hdr->class == VIRTIO_NET_CTRL_MQ &&
-	    hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
+	ctrl = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
+	if (ctrl->hdr.class == VIRTIO_NET_CTRL_MQ &&
+	    ctrl->hdr.cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
 		uint16_t queues;
 
 		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_RX) {
+		if (ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_PROMISC ||
+		    ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_ALLMULTI) {
+			if (ctrl->data[0])
+				status = 0;
+		}
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_MAC ||
+		   ctrl->hdr.class == VIRTIO_NET_CTRL_VLAN) {
+		status = 0;
 	}
 
 	/* Update status */
@@ -635,7 +644,7 @@ virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev *dev,
 				   struct vring_packed *vring,
 				   uint16_t idx_hdr)
 {
-	struct virtio_net_ctrl_hdr *hdr;
+	struct virtio_pmd_ctrl *ctrl;
 	virtio_net_ctrl_ack status = ~0;
 	uint16_t idx_data, idx_status;
 	/* initialize to one, header is first */
@@ -656,14 +665,22 @@ virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev *dev,
 		n_descs++;
 	}
 
-	hdr = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
-	if (hdr->class == VIRTIO_NET_CTRL_MQ &&
-	    hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
+	ctrl = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
+	if (ctrl->hdr.class == VIRTIO_NET_CTRL_MQ &&
+	    ctrl->hdr.cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
 		uint16_t queues;
 
-		queues = *(uint16_t *)(uintptr_t)
-				vring->desc[idx_data].addr;
+		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_RX) {
+		if (ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_PROMISC ||
+		    ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_ALLMULTI) {
+			if (ctrl->data[0])
+				status = 0;
+		}
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_MAC ||
+		   ctrl->hdr.class == VIRTIO_NET_CTRL_VLAN) {
+		status = 0;
 	}
 
 	/* Update status */
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH v3 1/1 net/virtio: fix multicast and promisc mode enable failure

As doc mentioned, promisc and multicast are by-default supported in virtio pmd. Mac/vlan filter are supported by best effort. These control messages should return pass.

Fixes f9b9d1a55775 ("net/virtio-user: add multiple queues in device emulation")
---
 .../net/virtio/virtio_user/virtio_user_dev.c  | 37 ++++++++++++++-----
 drivers/net/virtio/virtio_user_ethdev.c       |  4 ++
 2 files changed, 31 insertions(+), 10 deletions(-)
drivers/net/virtio/virtio_user/virtio_user_dev.c +27 -10
index 1c575d0cd..b614dd0c0 100644
@@ -587,7 +587,7 @@ static uint32_t
 virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
 			    uint16_t idx_hdr)
 {
-	struct virtio_net_ctrl_hdr *hdr;
+	struct virtio_pmd_ctrl *ctrl;
 	virtio_net_ctrl_ack status = ~0;
 	uint16_t i, idx_data, idx_status;
 	uint32_t n_descs = 0;
@@ -606,13 +606,22 @@ virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
 	idx_status = i;
 	n_descs++;
 
-	hdr = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
-	if (hdr->class == VIRTIO_NET_CTRL_MQ &&
-	    hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
+	ctrl = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
+	if (ctrl->hdr.class == VIRTIO_NET_CTRL_MQ &&
+	    ctrl->hdr.cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
 		uint16_t queues;
 
 		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_RX) {
+		if (ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_PROMISC ||
+		    ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_ALLMULTI) {
+			if (ctrl->data[0])
+				status = 0;
+		}
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_MAC ||
+		   ctrl->hdr.class == VIRTIO_NET_CTRL_VLAN) {
+		status = 0;
 	}
 
 	/* Update status */
@@ -635,7 +644,7 @@ virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev *dev,
 				   struct vring_packed *vring,
 				   uint16_t idx_hdr)
 {
-	struct virtio_net_ctrl_hdr *hdr;
+	struct virtio_pmd_ctrl *ctrl;
 	virtio_net_ctrl_ack status = ~0;
 	uint16_t idx_data, idx_status;
 	/* initialize to one, header is first */
@@ -656,14 +665,22 @@ virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev *dev,
 		n_descs++;
 	}
 
-	hdr = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
-	if (hdr->class == VIRTIO_NET_CTRL_MQ &&
-	    hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
+	ctrl = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
+	if (ctrl->hdr.class == VIRTIO_NET_CTRL_MQ &&
+	    ctrl->hdr.cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
 		uint16_t queues;
 
-		queues = *(uint16_t *)(uintptr_t)
-				vring->desc[idx_data].addr;
+		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_RX) {
+		if (ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_PROMISC ||
+		    ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_ALLMULTI) {
+			if (ctrl->data[0])
+				status = 0;
+		}
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_MAC ||
+		   ctrl->hdr.class == VIRTIO_NET_CTRL_VLAN) {
+		status = 0;
 	}
 
 	/* Update status */
drivers/net/virtio/virtio_user_ethdev.c +4 -0
index 3fc172573..18caf5e88 100644
@@ -660,6 +660,10 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev)
 		goto end;
 	}
 
+	/* multicast and promisc mode are always enabled */
+	eth_dev->data->promiscuous = 1;
+	eth_dev->data->all_multicast = 1;
+
 	hw = eth_dev->data->dev_private;
 	if (virtio_user_dev_init(hw->virtio_user_dev, path, queues, cq,
 			 queue_size, mac_addr, &ifname, server_mode,
Signature · 1 line
2.17.1
#3 lore raw

Re: [dpdk-dev] [PATCH v3] net/virtio: fix multicast and promisc mode enable failure

Quoted 18 lines · Marvin Liu

As doc mentioned, promisc and multicast are by-default supported in virtio pmd. Mac/vlan filter are supported by best effort. These control messages should return pass.

Fixes f9b9d1a55775 ("net/virtio-user: add multiple queues in device emulation")
---
 .../net/virtio/virtio_user/virtio_user_dev.c  | 37 ++++++++++++++-----
 drivers/net/virtio/virtio_user_ethdev.c       |  4 ++
 2 files changed, 31 insertions(+), 10 deletions(-)
drivers/net/virtio/virtio_user/virtio_user_dev.c +0 -0
index 1c575d0cd..b614dd0c0 100644

drivers/net/virtio/virtio_user/virtio_user_dev.c static uint32_t · line 590

Quoted 5 lines
drivers/net/virtio/virtio_user/virtio_user_dev.c +1 -1
@@ -587,7 +587,7 @@ static uint32_t
 virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
 			    uint16_t idx_hdr)
 {
-	struct virtio_net_ctrl_hdr *hdr;
+	struct virtio_pmd_ctrl *ctrl;

We shouldn't use virtio_pmd_ctrl here. The virtio_pmd_ctrl is just a private structure defined in virtio PMD (upper layer). And we won't put this structure as is in the buffer pointed by the descriptor.

Quoted 11 lines
drivers/net/virtio/virtio_user/virtio_user_dev.c +1 -3
 	virtio_net_ctrl_ack status = ~0;
 	uint16_t i, idx_data, idx_status;
 	uint32_t n_descs = 0;
@@ -606,13 +606,22 @@ virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
 	idx_status = i;
 	n_descs++;
 
-	hdr = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
-	if (hdr->class == VIRTIO_NET_CTRL_MQ &&
-	    hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
+	ctrl = (void *)(uintptr_t)vring->desc[idx_hdr].addr;

drivers/net/virtio/virtio_user/virtio_user_dev.c virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring, · line 619

Quoted 10 lines
drivers/net/virtio/virtio_user/virtio_user_dev.c +6 -0
+	if (ctrl->hdr.class == VIRTIO_NET_CTRL_MQ &&
+	    ctrl->hdr.cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
 		uint16_t queues;
 
 		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_RX) {
+		if (ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_PROMISC ||
+		    ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_ALLMULTI) {
+			if (ctrl->data[0])

Why do we need this check?

Quoted 63 lines
drivers/net/virtio/virtio_user/virtio_user_dev.c +19 -6
+				status = 0;
+		}
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_MAC ||
+		   ctrl->hdr.class == VIRTIO_NET_CTRL_VLAN) {
+		status = 0;
 	}
 
 	/* Update status */
@@ -635,7 +644,7 @@ virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev *dev,
 				   struct vring_packed *vring,
 				   uint16_t idx_hdr)
 {
-	struct virtio_net_ctrl_hdr *hdr;
+	struct virtio_pmd_ctrl *ctrl;
 	virtio_net_ctrl_ack status = ~0;
 	uint16_t idx_data, idx_status;
 	/* initialize to one, header is first */
@@ -656,14 +665,22 @@ virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev *dev,
 		n_descs++;
 	}
 
-	hdr = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
-	if (hdr->class == VIRTIO_NET_CTRL_MQ &&
-	    hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
+	ctrl = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
+	if (ctrl->hdr.class == VIRTIO_NET_CTRL_MQ &&
+	    ctrl->hdr.cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
 		uint16_t queues;
 
-		queues = *(uint16_t *)(uintptr_t)
-				vring->desc[idx_data].addr;
+		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_RX) {
+		if (ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_PROMISC ||
+		    ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_ALLMULTI) {
+			if (ctrl->data[0])
+				status = 0;
+		}
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_MAC ||
+		   ctrl->hdr.class == VIRTIO_NET_CTRL_VLAN) {
+		status = 0;
 	}
 
 	/* Update status */
drivers/net/virtio/virtio_user_ethdev.c +4 -0
index 3fc172573..18caf5e88 100644
@@ -660,6 +660,10 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev)
 		goto end;
 	}
 
+	/* multicast and promisc mode are always enabled */
+	eth_dev->data->promiscuous = 1;
+	eth_dev->data->all_multicast = 1;
+
 	hw = eth_dev->data->dev_private;
 	if (virtio_user_dev_init(hw->virtio_user_dev, path, queues, cq,
 			 queue_size, mac_addr, &ifname, server_mode,
Signature · 1 line
2.17.1
author
#4 lore raw

Re: [dpdk-dev] [PATCH v3] net/virtio: fix multicast and promisc mode enable failure

Quoted 34 lines

-----Original Message-----
From: Bie, Tiwei
Sent: Tuesday, October 29, 2019 8:28 PM
To: Liu, Yong <[email protected]>
Cc: [email protected]; Wang, Zhihong <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH v3] net/virtio: fix multicast and promisc mode enable failure

Quoted 5 lines · Marvin Liu

As doc mentioned, promisc and multicast are by-default supported in virtio pmd. Mac/vlan filter are supported by best effort. These control messages should return pass.

Fixes f9b9d1a55775 ("net/virtio-user: add multiple queues in device

emulation")

Review

Quoted 9 lines
---
 .../net/virtio/virtio_user/virtio_user_dev.c  | 37 ++++++++++++++-----
 drivers/net/virtio/virtio_user_ethdev.c       |  4 ++
 2 files changed, 31 insertions(+), 10 deletions(-)
(quoted diff) +0 -0

b/drivers/net/virtio/virtio_user/virtio_user_dev.c

drivers/net/virtio/virtio_user/virtio_user_dev.c static uint32_t · line 587

Quoted 5 lines

index 1c575d0cd..b614dd0c0 100644

drivers/net/virtio/virtio_user/virtio_user_dev.c +0 -0
@@ -587,7 +587,7 @@ static uint32_t
 virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring

*vring,

Quoted 9 lines

drivers/net/virtio/virtio_user/virtio_user_dev.c static uint32_t · line 590

Quoted 4 lines
drivers/net/virtio/virtio_user/virtio_user_dev.c +1 -1
 			    uint16_t idx_hdr)
 {
-	struct virtio_net_ctrl_hdr *hdr;
+	struct virtio_pmd_ctrl *ctrl;

We shouldn't use virtio_pmd_ctrl here. The virtio_pmd_ctrl is just a private structure defined in virtio PMD (upper layer). And we won't put this structure as is in the buffer pointed by the descriptor.

Thanks, will change in next version.

Quoted 17 lines

drivers/net/virtio/virtio_user/virtio_user_dev.c virtio_user_handle_ctrl_msg(struct virtio_user_dev

Quoted 5 lines
drivers/net/virtio/virtio_user/virtio_user_dev.c +0 -0
 	virtio_net_ctrl_ack status = ~0;
 	uint16_t i, idx_data, idx_status;
 	uint32_t n_descs = 0;
@@ -606,13 +606,22 @@ virtio_user_handle_ctrl_msg(struct virtio_user_dev

*dev, struct vring *vring,

Quoted 11 lines
drivers/net/virtio/virtio_user/virtio_user_dev.c +3 -3
 	idx_status = i;
 	n_descs++;
 
-	hdr = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
-	if (hdr->class == VIRTIO_NET_CTRL_MQ &&
-	    hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
+	ctrl = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
+	if (ctrl->hdr.class == VIRTIO_NET_CTRL_MQ &&
+	    ctrl->hdr.cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
 		uint16_t queues;
 
Quoted 9 lines

drivers/net/virtio/virtio_user/virtio_user_dev.c virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring, · line 619

Quoted 6 lines
drivers/net/virtio/virtio_user/virtio_user_dev.c +4 -0
 		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_RX) {
+		if (ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_PROMISC ||
+		    ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_ALLMULTI) {
+			if (ctrl->data[0])

Why do we need this check?

Promisc and multicast setting should be checked before return. Ctrl data is not the value should be checked. Will check the content in idx_data in next version.

Quoted 67 lines

drivers/net/virtio/virtio_user/virtio_user_dev.c virtio_user_handle_ctrl_msg_packed(struct

Quoted 10 lines
drivers/net/virtio/virtio_user/virtio_user_dev.c +5 -0
+				status = 0;
+		}
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_MAC ||
+		   ctrl->hdr.class == VIRTIO_NET_CTRL_VLAN) {
+		status = 0;
 	}
 
 	/* Update status */
@@ -635,7 +644,7 @@ virtio_user_handle_ctrl_msg_packed(struct

virtio_user_dev *dev,

drivers/net/virtio/virtio_user/virtio_user_dev.c virtio_user_handle_ctrl_msg_packed(struct

Quoted 9 lines
drivers/net/virtio/virtio_user/virtio_user_dev.c +1 -1
 				   struct vring_packed *vring,
 				   uint16_t idx_hdr)
 {
-	struct virtio_net_ctrl_hdr *hdr;
+	struct virtio_pmd_ctrl *ctrl;
 	virtio_net_ctrl_ack status = ~0;
 	uint16_t idx_data, idx_status;
 	/* initialize to one, header is first */
@@ -656,14 +665,22 @@ virtio_user_handle_ctrl_msg_packed(struct

virtio_user_dev *dev,

Review

Quoted 28 lines
drivers/net/virtio/virtio_user/virtio_user_dev.c +13 -5
 		n_descs++;
 	}
 
-	hdr = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
-	if (hdr->class == VIRTIO_NET_CTRL_MQ &&
-	    hdr->cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
+	ctrl = (void *)(uintptr_t)vring->desc[idx_hdr].addr;
+	if (ctrl->hdr.class == VIRTIO_NET_CTRL_MQ &&
+	    ctrl->hdr.cmd == VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) {
 		uint16_t queues;
 
-		queues = *(uint16_t *)(uintptr_t)
-				vring->desc[idx_data].addr;
+		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_RX) {
+		if (ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_PROMISC ||
+		    ctrl->hdr.cmd == VIRTIO_NET_CTRL_RX_ALLMULTI) {
+			if (ctrl->data[0])
+				status = 0;
+		}
+	} else if (ctrl->hdr.class == VIRTIO_NET_CTRL_MAC ||
+		   ctrl->hdr.class == VIRTIO_NET_CTRL_VLAN) {
+		status = 0;
 	}
 
 	/* Update status */
(quoted diff) +0 -0

b/drivers/net/virtio/virtio_user_ethdev.c

Quoted 17 lines

index 3fc172573..18caf5e88 100644

drivers/net/virtio/virtio_user_ethdev.c +4 -1
@@ -660,6 +660,10 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev)
 		goto end;
 	}
 
+	/* multicast and promisc mode are always enabled */
+	eth_dev->data->promiscuous = 1;
+	eth_dev->data->all_multicast = 1;
+
 	hw = eth_dev->data->dev_private;
 	if (virtio_user_dev_init(hw->virtio_user_dev, path, queues, cq,
 			 queue_size, mac_addr, &ifname, server_mode,
--

2.17.1

author
#5 lore raw

PATCH v4 1/1 net/virtio: fix multicast and promisc mode enable failure

In reply to Marvin Liu

As doc mentioned, promisc and multicast are by-default supported in virtio pmd. Mac/vlan filter are supported by best effort. These control messages should return success.

Fixes f9b9d1a55775 ("net/virtio-user: add multiple queues in device emulation")
---
 .../net/virtio/virtio_user/virtio_user_dev.c  | 24 +++++++++++++++++++
 drivers/net/virtio/virtio_user_ethdev.c       |  4 ++++
 2 files changed, 28 insertions(+)
drivers/net/virtio/virtio_user/virtio_user_dev.c +24 -0
index 1c575d0cd..dc0007b7c 100644
@@ -613,6 +613,18 @@ virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
 
 		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (hdr->class == VIRTIO_NET_CTRL_RX) {
+		if (hdr->cmd == VIRTIO_NET_CTRL_RX_PROMISC ||
+		    hdr->cmd == VIRTIO_NET_CTRL_RX_ALLMULTI) {
+			uint8_t setting;
+			setting = *(uint8_t *)(uintptr_t)
+					vring->desc[idx_data].addr;
+			if (setting)
+				status = 0;
+		}
+	} else if (hdr->class == VIRTIO_NET_CTRL_MAC ||
+		   hdr->class == VIRTIO_NET_CTRL_VLAN) {
+		status = 0;
 	}
 
 	/* Update status */
@@ -664,6 +676,18 @@ virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev *dev,
 		queues = *(uint16_t *)(uintptr_t)
 				vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (hdr->class == VIRTIO_NET_CTRL_RX) {
+		if (hdr->cmd == VIRTIO_NET_CTRL_RX_PROMISC ||
+		    hdr->cmd == VIRTIO_NET_CTRL_RX_ALLMULTI) {
+			uint8_t setting;
+			setting = *(uint8_t *)(uintptr_t)
+					vring->desc[idx_data].addr;
+			if (setting)
+				status = 0;
+		}
+	} else if (hdr->class == VIRTIO_NET_CTRL_MAC ||
+		   hdr->class == VIRTIO_NET_CTRL_VLAN) {
+		status = 0;
 	}
 
 	/* Update status */
drivers/net/virtio/virtio_user_ethdev.c +4 -0
index 3fc172573..18caf5e88 100644
@@ -660,6 +660,10 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev)
 		goto end;
 	}
 
+	/* multicast and promisc mode are always enabled */
+	eth_dev->data->promiscuous = 1;
+	eth_dev->data->all_multicast = 1;
+
 	hw = eth_dev->data->dev_private;
 	if (virtio_user_dev_init(hw->virtio_user_dev, path, queues, cq,
 			 queue_size, mac_addr, &ifname, server_mode,
Signature · 1 line
2.17.1
author
#6 lore raw

PATCH v5 1/1 net/virtio: fix multicast and promisc mode enable failure

As doc mentioned, Rx/Mac/vlan filters are all supported by best effort. These control commands should return pass. Promisc and all multicast modes are always enabled in virio-user, initialize related values in ethernet data.

Fixes f9b9d1a55775 ("net/virtio-user: add multiple queues in device emulation")
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 8 ++++++++
 drivers/net/virtio/virtio_user_ethdev.c          | 4 ++++
 2 files changed, 12 insertions(+)
drivers/net/virtio/virtio_user/virtio_user_dev.c +8 -0
index 1c575d0cd..a4400e772 100644
@@ -613,6 +613,10 @@ virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
 
 		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (hdr->class == VIRTIO_NET_CTRL_RX  ||
+		   hdr->class == VIRTIO_NET_CTRL_MAC ||
+		   hdr->class == VIRTIO_NET_CTRL_VLAN) {
+		status = 0;
 	}
 
 	/* Update status */
@@ -664,6 +668,10 @@ virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev *dev,
 		queues = *(uint16_t *)(uintptr_t)
 				vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (hdr->class == VIRTIO_NET_CTRL_RX  ||
+		   hdr->class == VIRTIO_NET_CTRL_MAC ||
+		   hdr->class == VIRTIO_NET_CTRL_VLAN) {
+		status = 0;
 	}
 
 	/* Update status */
drivers/net/virtio/virtio_user_ethdev.c +4 -0
index 3fc172573..18caf5e88 100644
@@ -660,6 +660,10 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev)
 		goto end;
 	}
 
+	/* multicast and promisc mode are always enabled */
+	eth_dev->data->promiscuous = 1;
+	eth_dev->data->all_multicast = 1;
+
 	hw = eth_dev->data->dev_private;
 	if (virtio_user_dev_init(hw->virtio_user_dev, path, queues, cq,
 			 queue_size, mac_addr, &ifname, server_mode,
Signature · 1 line
2.17.1
author
#7 lore raw

PATCH v6 1/1 net/virtio-user: fix failures when setting filters

As doc mentioned, Rx/Mac/vlan filters are all supported by best effort. These control commands should return success.

Fixes f9b9d1a55775 ("net/virtio-user: add multiple queues in device emulation")
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/virtio/virtio_user/virtio_user_dev.c +8 -0
index 1c575d0cd..a4400e772 100644
@@ -613,6 +613,10 @@ virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
 
 		queues = *(uint16_t *)(uintptr_t)vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (hdr->class == VIRTIO_NET_CTRL_RX  ||
+		   hdr->class == VIRTIO_NET_CTRL_MAC ||
+		   hdr->class == VIRTIO_NET_CTRL_VLAN) {
+		status = 0;
 	}
 
 	/* Update status */
@@ -664,6 +668,10 @@ virtio_user_handle_ctrl_msg_packed(struct virtio_user_dev *dev,
 		queues = *(uint16_t *)(uintptr_t)
 				vring->desc[idx_data].addr;
 		status = virtio_user_handle_mq(dev, queues);
+	} else if (hdr->class == VIRTIO_NET_CTRL_RX  ||
+		   hdr->class == VIRTIO_NET_CTRL_MAC ||
+		   hdr->class == VIRTIO_NET_CTRL_VLAN) {
+		status = 0;
 	}
 
 	/* Update status */
Signature · 1 line
2.17.1
Reviewed-by on v6 1/1
#8 lore raw

Re: [dpdk-dev] [PATCH v6] net/virtio-user: fix failures when setting filters

Quoted 11 lines · Marvin Liu

As doc mentioned, Rx/Mac/vlan filters are all supported by best effort. These control commands should return success.

Fixes f9b9d1a55775 ("net/virtio-user: add multiple queues in device emulation")
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Thanks,
Maxime

#9 lore raw

Re: [dpdk-dev] [PATCH v6] net/virtio-user: fix failures when setting filters

In reply to Marvin Liu
Quoted 10 lines · Marvin Liu

As doc mentioned, Rx/Mac/vlan filters are all supported by best effort. These control commands should return success.

Fixes f9b9d1a55775 ("net/virtio-user: add multiple queues in device emulation")
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Applied to dpdk-next-virtio/master.

Thanks,
Maxime