From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5C38EA00B8; Mon, 28 Oct 2019 09:45:01 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D6B901BEF9; Mon, 28 Oct 2019 09:44:59 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id DF1EB1BEF6; Mon, 28 Oct 2019 09:44:57 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Oct 2019 01:44:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,239,1569308400"; d="scan'208";a="193195927" Received: from npg-dpdk-virtual-marvin-dev.sh.intel.com ([10.67.119.142]) by orsmga008.jf.intel.com with ESMTP; 28 Oct 2019 01:44:55 -0700 From: Marvin Liu To: maxime.coquelin@redhat.com, tiwei.bie@intel.com, zhihong.wang@intel.com Cc: dev@dpdk.org, Marvin Liu , stable@dpdk.org Date: Tue, 29 Oct 2019 00:24:25 +0800 Message-Id: <20191028162425.95853-1-yong.liu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028154040.10738-1-yong.liu@intel.com> References: <20191028154040.10738-1-yong.liu@intel.com> Subject: [dpdk-dev] [PATCH v2] net/virtio: fix multicast and promisc mode enable failure X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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") Cc: stable@dpdk.org Signed-off-by: Marvin Liu --- drivers/net/virtio/virtio_ethdev.c | 4 ++ .../net/virtio/virtio_user/virtio_user_dev.c | 37 ++++++++++++++----- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 646de9945..ac412071b 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -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) || diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 1c575d0cd..b614dd0c0 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -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 */ -- 2.17.1