From patchwork Mon Oct 21 12:22:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Power, Ciara" X-Patchwork-Id: 61590 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8F2C44C8B; Mon, 21 Oct 2019 14:25:13 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 2D8E71BF0B for ; Mon, 21 Oct 2019 14:25:12 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Oct 2019 05:25:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,323,1566889200"; d="scan'208";a="397307298" Received: from silpixa00399953.ir.intel.com (HELO silpixa00399953.ger.corp.intel.com) ([10.237.223.218]) by fmsmga005.fm.intel.com with ESMTP; 21 Oct 2019 05:25:09 -0700 From: Ciara Power To: thomas@monjalon.net, ferruh.yigit@intel.com, arybchenko@solarflare.com, mtetsuyah@gmail.com, bruce.richardson@intel.com Cc: dev@dpdk.org, Ciara Power Date: Mon, 21 Oct 2019 13:22:37 +0100 Message-Id: <20191021122238.58852-2-ciara.power@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191021122238.58852-1-ciara.power@intel.com> References: <20191021122238.58852-1-ciara.power@intel.com> Subject: [dpdk-dev] [PATCH v2 1/2] ethdev: add check for device promiscuous state 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" The promiscuous enable and disable functions now check the promiscuous state of the device before checking if the dev_ops function exists for the device. This change is necessary to allow sample applications run on virtual PMDs, as previously -ENOTSUP returned when the promiscuous enable function was called. This caused the sample application to fail unnecessarily. Signed-off-by: Ciara Power Reviewed-by: Ferruh Yigit Reviewed-by: Andrew Rybchenko --- lib/librte_ethdev/rte_ethdev.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index af823607c..67db0d1dd 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1930,12 +1930,13 @@ rte_eth_promiscuous_enable(uint16_t port_id) RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; + if (dev->data->promiscuous == 1) + return 0; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->promiscuous_enable, -ENOTSUP); - if (dev->data->promiscuous == 0) { - diag = (*dev->dev_ops->promiscuous_enable)(dev); - dev->data->promiscuous = (diag == 0) ? 1 : 0; - } + diag = (*dev->dev_ops->promiscuous_enable)(dev); + dev->data->promiscuous = (diag == 0) ? 1 : 0; return eth_err(port_id, diag); } @@ -1949,14 +1950,15 @@ rte_eth_promiscuous_disable(uint16_t port_id) RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; + if (dev->data->promiscuous == 0) + return 0; + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->promiscuous_disable, -ENOTSUP); - if (dev->data->promiscuous == 1) { - dev->data->promiscuous = 0; - diag = (*dev->dev_ops->promiscuous_disable)(dev); - if (diag != 0) - dev->data->promiscuous = 1; - } + dev->data->promiscuous = 0; + diag = (*dev->dev_ops->promiscuous_disable)(dev); + if (diag != 0) + dev->data->promiscuous = 1; return eth_err(port_id, diag); } From patchwork Mon Oct 21 12:22:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Power, Ciara" X-Patchwork-Id: 61591 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 530801BF14; Mon, 21 Oct 2019 14:25:19 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id C8DD71BF13 for ; Mon, 21 Oct 2019 14:25:17 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Oct 2019 05:25:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,323,1566889200"; d="scan'208";a="397307310" Received: from silpixa00399953.ir.intel.com (HELO silpixa00399953.ger.corp.intel.com) ([10.237.223.218]) by fmsmga005.fm.intel.com with ESMTP; 21 Oct 2019 05:25:14 -0700 From: Ciara Power To: thomas@monjalon.net, ferruh.yigit@intel.com, arybchenko@solarflare.com, mtetsuyah@gmail.com, bruce.richardson@intel.com Cc: dev@dpdk.org, Ciara Power Date: Mon, 21 Oct 2019 13:22:38 +0100 Message-Id: <20191021122238.58852-3-ciara.power@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191021122238.58852-1-ciara.power@intel.com> References: <20191021122238.58852-1-ciara.power@intel.com> Subject: [dpdk-dev] [PATCH v2 2/2] drivers/net: set enabled promiscuous and multicast 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" The promiscuous and multicast fields are now initialised as enabled for some virtual PMDs. This allows the devices to be used when running applications that attempt to enable promiscuous or multicast mode. Signed-off-by: Ciara Power Reviewed-by: Ferruh Yigit Acked-by: Andrew Rybchenko --- drivers/net/kni/rte_eth_kni.c | 2 ++ drivers/net/null/rte_eth_null.c | 2 ++ drivers/net/pcap/rte_eth_pcap.c | 2 ++ drivers/net/ring/rte_eth_ring.c | 2 ++ 4 files changed, 8 insertions(+) diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c index 547e08c3d..7cba92e2e 100644 --- a/drivers/net/kni/rte_eth_kni.c +++ b/drivers/net/kni/rte_eth_kni.c @@ -377,6 +377,8 @@ eth_kni_create(struct rte_vdev_device *vdev, data->nb_tx_queues = 1; data->dev_link = pmd_link; data->mac_addrs = &internals->eth_addr; + data->promiscuous = 1; + data->all_multicast = 1; data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index e2ff41a22..35920cd1e 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -514,6 +514,8 @@ eth_dev_null_create(struct rte_vdev_device *dev, data->nb_tx_queues = (uint16_t)nb_tx_queues; data->dev_link = pmd_link; data->mac_addrs = &internals->eth_addr; + data->promiscuous = 1; + data->all_multicast = 1; eth_dev->dev_ops = &ops; diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index 5801915a8..5186d8fe5 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -1129,6 +1129,8 @@ pmd_init_internals(struct rte_vdev_device *vdev, data->nb_tx_queues = (uint16_t)nb_tx_queues; data->dev_link = pmd_link; data->mac_addrs = &(*internals)->eth_addr; + data->promiscuous = 1; + data->all_multicast = 1; /* * NOTE: we'll replace the data element, of originally allocated diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index c6733ee2b..41acbc513 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -318,6 +318,8 @@ do_eth_dev_ring_create(const char *name, data->nb_tx_queues = (uint16_t)nb_tx_queues; data->dev_link = pmd_link; data->mac_addrs = &internals->address; + data->promiscuous = 1; + data->all_multicast = 1; eth_dev->dev_ops = &ops; data->kdrv = RTE_KDRV_NONE;