DPDK patches and discussions
 help / color / mirror / Atom feed
From: Robin Zhang <robinx.zhang@intel.com>
To: dev@dpdk.org
Cc: beilei.xing@intel.com, jingjing.wu@intel.com,
	qiming.yang@intel.com, stevex.yang@intel.com,
	Robin Zhang <robinx.zhang@intel.com>
Subject: [dpdk-dev] [PATCH 4/8] net/iavf: optimize promiscuous ops
Date: Sun, 27 Sep 2020 07:26:22 +0000
Message-ID: <20200927072626.28374-5-robinx.zhang@intel.com> (raw)
In-Reply-To: <20200927072626.28374-1-robinx.zhang@intel.com>

This patch is to improve efficiency and eliminate code
redundancy of promiscuous ops.

Signed-off-by: Robin Zhang <robinx.zhang@intel.com>
---
 drivers/net/iavf/iavf_ethdev.c | 49 ++++++----------------------------
 drivers/net/iavf/iavf_vchnl.c  | 13 +++++++--
 2 files changed, 19 insertions(+), 43 deletions(-)

diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 57640c52a..3b3829f75 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -676,17 +676,9 @@ iavf_dev_promiscuous_enable(struct rte_eth_dev *dev)
 	struct iavf_adapter *adapter =
 		IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
-	int ret;
-
-	ret = iavf_config_promisc(adapter, true, vf->promisc_multicast_enabled);
-	if (!ret)
-		vf->promisc_unicast_enabled = true;
-	else if (ret == IAVF_NOT_SUPPORTED)
-		ret = -ENOTSUP;
-	else
-		ret = -EAGAIN;
 
-	return ret;
+	return iavf_config_promisc(adapter,
+				  true, vf->promisc_multicast_enabled);
 }
 
 static int
@@ -695,18 +687,9 @@ iavf_dev_promiscuous_disable(struct rte_eth_dev *dev)
 	struct iavf_adapter *adapter =
 		IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
-	int ret;
-
-	ret = iavf_config_promisc(adapter, false,
-				  vf->promisc_multicast_enabled);
-	if (!ret)
-		vf->promisc_unicast_enabled = false;
-	else if (ret == IAVF_NOT_SUPPORTED)
-		ret = -ENOTSUP;
-	else
-		ret = -EAGAIN;
 
-	return ret;
+	return iavf_config_promisc(adapter,
+				  false, vf->promisc_multicast_enabled);
 }
 
 static int
@@ -715,17 +698,9 @@ iavf_dev_allmulticast_enable(struct rte_eth_dev *dev)
 	struct iavf_adapter *adapter =
 		IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
-	int ret;
-
-	ret = iavf_config_promisc(adapter, vf->promisc_unicast_enabled, true);
-	if (!ret)
-		vf->promisc_multicast_enabled = true;
-	else if (ret == IAVF_NOT_SUPPORTED)
-		ret = -ENOTSUP;
-	else
-		ret = -EAGAIN;
 
-	return ret;
+	return iavf_config_promisc(adapter,
+				  vf->promisc_unicast_enabled, true);
 }
 
 static int
@@ -734,17 +709,9 @@ iavf_dev_allmulticast_disable(struct rte_eth_dev *dev)
 	struct iavf_adapter *adapter =
 		IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
-	int ret;
-
-	ret = iavf_config_promisc(adapter, vf->promisc_unicast_enabled, false);
-	if (!ret)
-		vf->promisc_multicast_enabled = false;
-	else if (ret == IAVF_NOT_SUPPORTED)
-		ret = -ENOTSUP;
-	else
-		ret = -EAGAIN;
 
-	return ret;
+	return iavf_config_promisc(adapter,
+				  vf->promisc_unicast_enabled, false);
 }
 
 static int
diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index 76f8e38d1..7a9f6b920 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -841,10 +841,19 @@ iavf_config_promisc(struct iavf_adapter *adapter,
 
 	err = iavf_execute_vf_cmd(adapter, &args);
 
-	if (err)
+	if (err) {
 		PMD_DRV_LOG(ERR,
 			    "fail to execute command CONFIG_PROMISCUOUS_MODE");
-	return err;
+
+		if (err == IAVF_NOT_SUPPORTED)
+			return -ENOTSUP;
+
+		return -EAGAIN;
+	}
+
+	vf->promisc_unicast_enabled = enable_unicast;
+	vf->promisc_multicast_enabled = enable_multicast;
+	return 0;
 }
 
 int
-- 
2.17.1


  parent reply	other threads:[~2020-09-27  7:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-27  7:26 [dpdk-dev] [PATCH 0/8] feature porting from i40evf to iavf Robin Zhang
2020-09-27  7:26 ` [dpdk-dev] [PATCH 1/8] net/iavf: use link status helper functions Robin Zhang
2020-09-27  7:26 ` [dpdk-dev] [PATCH 2/8] net/iavf: set min and max MTU for VF Robin Zhang
2020-09-27  7:26 ` [dpdk-dev] [PATCH 3/8] net/iavf: re-program promiscuous mode on VF interface Robin Zhang
2020-09-27  7:26 ` Robin Zhang [this message]
2020-09-27  7:26 ` [dpdk-dev] [PATCH 5/8] net/iavf: add workaround promiscuous disable Robin Zhang
2020-09-27  7:26 ` [dpdk-dev] [PATCH 6/8] net/iavf: cleanup Tx buffers Robin Zhang
2020-09-27  7:26 ` [dpdk-dev] [PATCH 7/8] net/iavf: add extended stats Robin Zhang
2020-09-27  7:26 ` [dpdk-dev] [PATCH 8/8] net/iavf: support check DD bit of a RX descriptor Robin Zhang
2020-10-08 15:05   ` Ferruh Yigit
     [not found]     ` <fe7a8f1f1a1f45908c4094ccfc6b547d@intel.com>
2020-10-12  8:32       ` Ferruh Yigit
2020-10-13  5:58         ` Zhang, Qi Z
2020-10-08 12:23 ` [dpdk-dev] [PATCH 0/8] feature porting from i40evf to iavf Zhang, Qi Z

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=20200927072626.28374-5-robinx.zhang@intel.com \
    --to=robinx.zhang@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=qiming.yang@intel.com \
    --cc=stevex.yang@intel.com \
    /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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git