DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ciara Power <ciara.power@intel.com>
To: thomas@monjalon.net, ferruh.yigit@intel.com,
	arybchenko@solarflare.com, mtetsuyah@gmail.com,
	bruce.richardson@intel.com
Cc: dev@dpdk.org, Ciara Power <ciara.power@intel.com>
Subject: [dpdk-dev] [PATCH v2 1/2] ethdev: add check for device promiscuous state
Date: Mon, 21 Oct 2019 13:22:37 +0100	[thread overview]
Message-ID: <20191021122238.58852-2-ciara.power@intel.com> (raw)
In-Reply-To: <20191021122238.58852-1-ciara.power@intel.com>

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 <ciara.power@intel.com>
---
 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);
 }
-- 
2.17.1


  reply	other threads:[~2019-10-21 12:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-21 12:22 [dpdk-dev] [PATCH v2 0/2] enable virtual PMD promiscuous and multicast Ciara Power
2019-10-21 12:22 ` Ciara Power [this message]
2019-10-21 18:39   ` [dpdk-dev] [PATCH v2 1/2] ethdev: add check for device promiscuous state Ferruh Yigit
2019-10-22  7:03   ` Andrew Rybchenko
2019-10-22  8:18     ` Ferruh Yigit
2019-10-21 12:22 ` [dpdk-dev] [PATCH v2 2/2] drivers/net: set enabled promiscuous and multicast Ciara Power
2019-10-21 18:40   ` Ferruh Yigit
2019-10-22  7:12   ` Andrew Rybchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191021122238.58852-2-ciara.power@intel.com \
    --to=ciara.power@intel.com \
    --cc=arybchenko@solarflare.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=mtetsuyah@gmail.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).