DPDK patches and discussions
 help / color / mirror / Atom feed
From: Wei Zhao <wei.zhao1@intel.com>
To: dev@dpdk.org
Cc: stable@dpdk.org, qi.z.zhang@intel.com, Wei Zhao <wei.zhao1@intel.com>
Subject: [dpdk-dev] [PATCH v4 2/2] net/ixgbe: add VF promiscuous mode support when PF as host
Date: Fri,  8 Mar 2019 10:46:17 +0800	[thread overview]
Message-ID: <1552013177-70811-3-git-send-email-wei.zhao1@intel.com> (raw)
In-Reply-To: <1552013177-70811-1-git-send-email-wei.zhao1@intel.com>

There is need to PF host promiscuous mode enable. For ixgbe,
in order to support VF vlan promiscuous or unicast promiscuous,
we need to set PF host register PFVML2FLT of bit UPE and VPE.
It also align to ixgbe kernel code version 5.5.3. And also
it need to update to the latest API version in order for
negotiation between pf and vf, then new API message can be
supported.

Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c |  1 +
 drivers/net/ixgbe/ixgbe_ethdev.h |  1 +
 drivers/net/ixgbe/ixgbe_pf.c     | 79 +++++++++++++++++++++++++++++-----------
 3 files changed, 59 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 3bf51ee..97e1021 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1515,6 +1515,7 @@ ixgbevf_negotiate_api(struct ixgbe_hw *hw)
 
 	/* start with highest supported, proceed down */
 	static const enum ixgbe_pfvf_api_rev sup_ver[] = {
+		ixgbe_mbox_api_13,
 		ixgbe_mbox_api_12,
 		ixgbe_mbox_api_11,
 		ixgbe_mbox_api_10,
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 99a5077..3fec613 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -266,6 +266,7 @@ struct ixgbe_vf_info {
 	uint8_t spoofchk_enabled;
 	uint8_t api_version;
 	uint16_t switch_domain_id;
+	uint16_t xcast_mode;
 };
 
 /*
diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c
index be0c076..fafff6b 100644
--- a/drivers/net/ixgbe/ixgbe_pf.c
+++ b/drivers/net/ixgbe/ixgbe_pf.c
@@ -408,23 +408,6 @@ ixgbe_vf_reset_msg(struct rte_eth_dev *dev, uint16_t vf)
 }
 
 static int
-ixgbe_enable_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf)
-{
-	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-	uint32_t vmolr;
-
-	vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(vf));
-
-	RTE_LOG(INFO, PMD, "VF %u: enabling multicast promiscuous\n", vf);
-
-	vmolr |= IXGBE_VMOLR_MPE;
-
-	IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vf), vmolr);
-
-	return 0;
-}
-
-static int
 ixgbe_disable_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf)
 {
 	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -596,6 +579,7 @@ ixgbe_negotiate_vf_api(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
 	case ixgbe_mbox_api_10:
 	case ixgbe_mbox_api_11:
 	case ixgbe_mbox_api_12:
+	case ixgbe_mbox_api_13:
 		vfinfo[vf].api_version = (uint8_t)api_version;
 		return 0;
 	default:
@@ -698,19 +682,70 @@ ixgbe_set_vf_mc_promisc(struct rte_eth_dev *dev, uint32_t vf, uint32_t *msgbuf)
 {
 	struct ixgbe_vf_info *vfinfo =
 		*(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
-	bool enable = !!msgbuf[1];	/* msgbuf contains the flag to enable */
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	int xcast_mode = msgbuf[1];	/* msgbuf contains the flag to enable */
+	u32 vmolr, fctrl, disable, enable;
 
 	switch (vfinfo[vf].api_version) {
 	case ixgbe_mbox_api_12:
+		/* promisc introduced in 1.3 version */
+		if (xcast_mode == IXGBEVF_XCAST_MODE_PROMISC)
+			return -EOPNOTSUPP;
+		break;
+		/* Fall threw */
+	case ixgbe_mbox_api_13:
 		break;
 	default:
 		return -1;
 	}
 
-	if (enable)
-		return ixgbe_enable_vf_mc_promisc(dev, vf);
-	else
-		return ixgbe_disable_vf_mc_promisc(dev, vf);
+	if (vfinfo[vf].xcast_mode == xcast_mode)
+		goto out;
+
+	switch (xcast_mode) {
+	case IXGBEVF_XCAST_MODE_NONE:
+		disable = IXGBE_VMOLR_BAM | IXGBE_VMOLR_ROMPE |
+			  IXGBE_VMOLR_MPE | IXGBE_VMOLR_UPE | IXGBE_VMOLR_VPE;
+		enable = 0;
+		break;
+	case IXGBEVF_XCAST_MODE_MULTI:
+		disable = IXGBE_VMOLR_MPE | IXGBE_VMOLR_UPE | IXGBE_VMOLR_VPE;
+		enable = IXGBE_VMOLR_BAM | IXGBE_VMOLR_ROMPE;
+		break;
+	case IXGBEVF_XCAST_MODE_ALLMULTI:
+		disable = IXGBE_VMOLR_UPE | IXGBE_VMOLR_VPE;
+		enable = IXGBE_VMOLR_BAM | IXGBE_VMOLR_ROMPE | IXGBE_VMOLR_MPE;
+		break;
+	case IXGBEVF_XCAST_MODE_PROMISC:
+		if (hw->mac.type <= ixgbe_mac_82599EB)
+			return -1;
+
+		fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
+		if (!(fctrl & IXGBE_FCTRL_UPE)) {
+			/* VF promisc requires PF in promisc */
+			RTE_LOG(ERR, PMD,
+			       "Enabling VF promisc requires PF in promisc\n");
+			return -1;
+		}
+
+		disable = 0;
+		enable = IXGBE_VMOLR_BAM | IXGBE_VMOLR_ROMPE |
+			 IXGBE_VMOLR_MPE | IXGBE_VMOLR_UPE | IXGBE_VMOLR_VPE;
+		break;
+	default:
+		return -1;
+	}
+
+	vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(vf));
+	vmolr &= ~disable;
+	vmolr |= enable;
+	IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vf), vmolr);
+	vfinfo[vf].xcast_mode = xcast_mode;
+
+out:
+	msgbuf[1] = xcast_mode;
+
+	return 0;
 }
 
 static int
-- 
2.7.5

  parent reply	other threads:[~2019-03-08  3:13 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-16  4:42 [dpdk-dev] [PATCH 0/3] promiscuous mode enable on VF Wei Zhao
2019-01-16  4:42 ` [dpdk-dev] [PATCH 1/3] net/ixgbe: " Wei Zhao
2019-01-16  4:42 ` [dpdk-dev] [PATCH 2/3] net/ixgbe: enable promiscous mode on PF host Wei Zhao
2019-01-16  4:42 ` [dpdk-dev] [PATCH 3/3] net/ixgbe: update API version Wei Zhao
2019-01-16  5:01 ` [dpdk-dev] [PATCH v2 0/3] net/ixgbe: promiscuous mode enable on VF Wei Zhao
2019-01-16  5:01   ` [dpdk-dev] [PATCH v2 1/3] " Wei Zhao
2019-02-13  3:35     ` Zhang, Qi Z
2019-02-13  3:36       ` Zhao1, Wei
2019-01-16  5:01   ` [dpdk-dev] [PATCH v2 2/3] net/ixgbe: enable promiscuous mode on PF host Wei Zhao
2019-02-13  3:41     ` Zhang, Qi Z
2019-02-13  3:42       ` Zhao1, Wei
2019-01-16  5:02   ` [dpdk-dev] [PATCH v2 3/3] net/ixgbe: update API version Wei Zhao
2019-02-13  3:43     ` Zhang, Qi Z
2019-02-14  1:22       ` Zhao1, Wei
2019-02-13  7:18   ` [dpdk-dev] [PATCH v3 0/2] net/ixgbe: promiscuous mode enable on VF Wei Zhao
2019-02-13  7:18     ` [dpdk-dev] [PATCH v3 1/2] " Wei Zhao
2019-03-01  7:53       ` Zhang, Qi Z
2019-03-08  3:18         ` Zhao1, Wei
2019-02-13  7:18     ` [dpdk-dev] [PATCH v3 2/2] net/ixgbe: add VF promiscuous mode support when PF as host Wei Zhao
2019-03-08  2:46     ` [dpdk-dev] [PATCH v4 0/2] net/ixgbe: promiscuous mode enable on VF Wei Zhao
2019-03-08  2:46       ` [dpdk-dev] [PATCH v4 1/2] " Wei Zhao
2019-03-08  2:46       ` Wei Zhao [this message]
2019-03-08  5:45       ` [dpdk-dev] [PATCH v4 0/2] " Zhang, Qi Z
2019-01-16  8:28 ` [dpdk-dev] [PATCH 0/3] " David Marchand
2019-01-17  9:23   ` Zhao1, Wei
2019-01-16 18:59 ` Stephen Hemminger
2019-01-17  9:27   ` Zhao1, Wei

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=1552013177-70811-3-git-send-email-wei.zhao1@intel.com \
    --to=wei.zhao1@intel.com \
    --cc=dev@dpdk.org \
    --cc=qi.z.zhang@intel.com \
    --cc=stable@dpdk.org \
    /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).