DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yong Wang <yongwang@vmware.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: "dev@dpdk.org" <dev@dpdk.org>, Stephen Hemminger <shemming@brocade.com>
Subject: Re: [dpdk-dev] [PATCH v3 02/10] vmxnet3: enable VLAN filtering
Date: Fri, 6 Mar 2015 21:54:59 +0000	[thread overview]
Message-ID: <D11F620A.38883%yongwang@vmware.com> (raw)
In-Reply-To: <1425600635-20628-3-git-send-email-stephen@networkplumber.org>

On 3/5/15, 4:10 PM, "Stephen Hemminger" <stephen@networkplumber.org> wrote:

>From: Stephen Hemminger <shemming@brocade.com>
>
>Support the VLAN filter functionality of the VMXNET3 interface.
>
>Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Acked-by: Yong Wang <yongwang@vmware.com>

>---
> lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c | 105
>+++++++++++++++++++++++++++++---
> lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h |   4 +-
> lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c   |  31 +---------
> 3 files changed, 102 insertions(+), 38 deletions(-)
>
>diff --git a/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c
>b/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c
>index 4c882ee..f4c2f12 100644
>--- a/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c
>+++ b/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c
>@@ -87,6 +87,12 @@ static void vmxnet3_dev_stats_get(struct rte_eth_dev
>*dev,
> 				struct rte_eth_stats *stats);
> static void vmxnet3_dev_info_get(struct rte_eth_dev *dev,
> 				struct rte_eth_dev_info *dev_info);
>+static int vmxnet3_dev_vlan_filter_set(struct rte_eth_dev *dev,
>+				       uint16_t vid, int on);
>+static void vmxnet3_dev_vlan_offload_set(struct rte_eth_dev *dev, int
>mask);
>+static void vmxnet3_dev_vlan_offload_set_clear(struct rte_eth_dev *dev,
>+						int mask, int clear);
>+
> #if PROCESS_SYS_EVENTS == 1
> static void vmxnet3_process_events(struct vmxnet3_hw *);
> #endif
>@@ -113,6 +119,8 @@ static struct eth_dev_ops vmxnet3_eth_dev_ops = {
> 	.link_update          = vmxnet3_dev_link_update,
> 	.stats_get            = vmxnet3_dev_stats_get,
> 	.dev_infos_get        = vmxnet3_dev_info_get,
>+	.vlan_filter_set      = vmxnet3_dev_vlan_filter_set,
>+	.vlan_offload_set     = vmxnet3_dev_vlan_offload_set,
> 	.rx_queue_setup       = vmxnet3_dev_rx_queue_setup,
> 	.rx_queue_release     = vmxnet3_dev_rx_queue_release,
> 	.tx_queue_setup       = vmxnet3_dev_tx_queue_setup,
>@@ -398,7 +406,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev)
> 	Vmxnet3_DSDevRead *devRead = &shared->devRead;
> 	uint32_t *mac_ptr;
> 	uint32_t val, i;
>-	int ret;
>+	int ret, mask;
> 
> 	shared->magic = VMXNET3_REV1_MAGIC;
> 	devRead->misc.driverInfo.version = VMXNET3_DRIVER_VERSION_NUM;
>@@ -470,9 +478,6 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev)
> 	if (dev->data->dev_conf.rxmode.hw_ip_checksum)
> 		devRead->misc.uptFeatures |= VMXNET3_F_RXCSUM;
> 
>-	if (dev->data->dev_conf.rxmode.hw_vlan_strip)
>-		devRead->misc.uptFeatures |= VMXNET3_F_RXVLAN;
>-
> 	if (port_conf.rxmode.mq_mode == ETH_MQ_RX_RSS) {
> 		ret = vmxnet3_rss_configure(dev);
> 		if (ret != VMXNET3_SUCCESS)
>@@ -484,11 +489,14 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev)
> 		devRead->rssConfDesc.confPA  = hw->rss_confPA;
> 	}
> 
>-	if (dev->data->dev_conf.rxmode.hw_vlan_filter) {
>-		ret = vmxnet3_vlan_configure(dev);
>-		if (ret != VMXNET3_SUCCESS)
>-			return ret;
>-	}
>+	mask = 0;
>+	if (dev->data->dev_conf.rxmode.hw_vlan_strip)
>+		mask |= ETH_VLAN_STRIP_MASK;
>+
>+	if (dev->data->dev_conf.rxmode.hw_vlan_filter)
>+		mask |= ETH_VLAN_FILTER_MASK;
>+
>+	vmxnet3_dev_vlan_offload_set_clear(dev, mask, 1);
> 
> 	PMD_INIT_LOG(DEBUG,
> 		     "Writing MAC Address : %02x:%02x:%02x:%02x:%02x:%02x",
>@@ -720,8 +728,13 @@ static void
> vmxnet3_dev_promiscuous_enable(struct rte_eth_dev *dev)
> {
> 	struct vmxnet3_hw *hw = dev->data->dev_private;
>+	uint32_t *vf_table = hw->shared->devRead.rxFilterConf.vfTable;
> 
>+	memset(vf_table, 0, VMXNET3_VFT_TABLE_SIZE);
> 	vmxnet3_dev_set_rxmode(hw, VMXNET3_RXM_PROMISC, 1);
>+
>+	VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD,
>+			       VMXNET3_CMD_UPDATE_VLAN_FILTERS);
> }
> 
> /* Promiscuous supported only if Vmxnet3_DriverShared is initialized in
>adapter */
>@@ -729,8 +742,12 @@ static void
> vmxnet3_dev_promiscuous_disable(struct rte_eth_dev *dev)
> {
> 	struct vmxnet3_hw *hw = dev->data->dev_private;
>+	uint32_t *vf_table = hw->shared->devRead.rxFilterConf.vfTable;
> 
>+	memcpy(vf_table, hw->shadow_vfta, VMXNET3_VFT_TABLE_SIZE);
> 	vmxnet3_dev_set_rxmode(hw, VMXNET3_RXM_PROMISC, 0);
>+	VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD,
>+			       VMXNET3_CMD_UPDATE_VLAN_FILTERS);
> }
> 
> /* Allmulticast supported only if Vmxnet3_DriverShared is initialized in
>adapter */
>@@ -751,6 +768,76 @@ vmxnet3_dev_allmulticast_disable(struct rte_eth_dev
>*dev)
> 	vmxnet3_dev_set_rxmode(hw, VMXNET3_RXM_ALL_MULTI, 0);
> }
> 
>+/* Enable/disable filter on vlan */
>+static int
>+vmxnet3_dev_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vid, int
>on)
>+{
>+	struct vmxnet3_hw *hw = dev->data->dev_private;
>+	struct Vmxnet3_RxFilterConf *rxConf = &hw->shared->devRead.rxFilterConf;
>+	uint32_t *vf_table = rxConf->vfTable;
>+
>+	/* save state for restore */
>+	if (on)
>+		VMXNET3_SET_VFTABLE_ENTRY(hw->shadow_vfta, vid);
>+	else
>+		VMXNET3_CLEAR_VFTABLE_ENTRY(hw->shadow_vfta, vid);
>+
>+	/* don't change active filter if in promiscious mode */
>+	if (rxConf->rxMode & VMXNET3_RXM_PROMISC)
>+		return 0;
>+
>+	/* set in hardware */
>+	if (on)
>+		VMXNET3_SET_VFTABLE_ENTRY(vf_table, vid);
>+	else
>+		VMXNET3_CLEAR_VFTABLE_ENTRY(vf_table, vid);
>+
>+	VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD,
>+			       VMXNET3_CMD_UPDATE_VLAN_FILTERS);
>+	return 0;
>+}
>+
>+static void
>+vmxnet3_dev_vlan_offload_set_clear(struct rte_eth_dev *dev,
>+				   int mask, int clear)
>+{
>+	struct vmxnet3_hw *hw = dev->data->dev_private;
>+	Vmxnet3_DSDevRead *devRead = &hw->shared->devRead;
>+	uint32_t *vf_table = devRead->rxFilterConf.vfTable;
>+
>+	if (mask & ETH_VLAN_STRIP_MASK)
>+		devRead->misc.uptFeatures |= UPT1_F_RXVLAN;
>+	else
>+		devRead->misc.uptFeatures &= ~UPT1_F_RXVLAN;
>+
>+	VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD,
>+			       VMXNET3_CMD_UPDATE_FEATURE);
>+
>+	if (mask & ETH_VLAN_FILTER_MASK) {
>+		if (clear) {
>+			memset(hw->shadow_vfta, 0,
>+			       VMXNET3_VFT_TABLE_SIZE);
>+			/* allow untagged pkts */
>+			VMXNET3_SET_VFTABLE_ENTRY(hw->shadow_vfta, 0);
>+		}
>+		memcpy(vf_table, hw->shadow_vfta, VMXNET3_VFT_TABLE_SIZE);
>+	} else {
>+		/* allow any pkts -- no filtering */
>+		if (clear)
>+			memset(hw->shadow_vfta, 0xff, VMXNET3_VFT_TABLE_SIZE);
>+		memset(vf_table, 0xff, VMXNET3_VFT_TABLE_SIZE);
>+	}
>+
>+	VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD,
>+			       VMXNET3_CMD_UPDATE_VLAN_FILTERS);
>+}
>+
>+static void
>+vmxnet3_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask)
>+{
>+	vmxnet3_dev_vlan_offload_set_clear(dev, mask, 0);
>+}
>+
> #if PROCESS_SYS_EVENTS == 1
> static void
> vmxnet3_process_events(struct vmxnet3_hw *hw)
>diff --git a/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h
>b/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h
>index 09993cf..e9d67a7 100644
>--- a/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h
>+++ b/lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h
>@@ -121,8 +121,11 @@ struct vmxnet3_hw {
> 	VMXNET3_RSSConf		 *rss_conf;
> 	uint64_t			 rss_confPA;
> 	vmxnet3_mf_table_t   *mf_table;
>+	uint32_t	      shadow_vfta[VMXNET3_VFT_SIZE];
> };
> 
>+#define VMXNET3_VFT_TABLE_SIZE	   (VMXNET3_VFT_SIZE * sizeof(uint32_t))
>+
> #define VMXNET3_GET_ADDR_LO(reg)   ((uint32_t)(reg))
> #define VMXNET3_GET_ADDR_HI(reg)   ((uint32_t)(((uint64_t)(reg)) >> 32))
> 
>@@ -173,7 +176,6 @@ int  vmxnet3_dev_tx_queue_setup(struct rte_eth_dev
>*dev, uint16_t tx_queue_id,
> int vmxnet3_dev_rxtx_init(struct rte_eth_dev *dev);
> 
> int vmxnet3_rss_configure(struct rte_eth_dev *dev);
>-int vmxnet3_vlan_configure(struct rte_eth_dev *dev);
> 
> uint16_t vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
> 		uint16_t nb_pkts);
>diff --git a/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c
>b/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c
>index 4d8a010..5fe3de5 100644
>--- a/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c
>+++ b/lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c
>@@ -738,9 +738,9 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,
> 		return -EINVAL;
> 	}
> 
>-	if ((tx_conf->txq_flags & ETH_TXQ_FLAGS_NOOFFLOADS) !=
>-	    ETH_TXQ_FLAGS_NOOFFLOADS) {
>-		PMD_INIT_LOG(ERR, "TX not support offload function yet");
>+	if ((tx_conf->txq_flags & ETH_TXQ_FLAGS_NOXSUMS) !=
>+	    ETH_TXQ_FLAGS_NOXSUMS) {
>+		PMD_INIT_LOG(ERR, "TX no support for checksum offload yet");
> 		return -EINVAL;
> 	}
> 
>@@ -1045,28 +1045,3 @@ vmxnet3_rss_configure(struct rte_eth_dev *dev)
> 
> 	return VMXNET3_SUCCESS;
> }
>-
>-/*
>- * Configure VLAN Filter feature
>- */
>-int
>-vmxnet3_vlan_configure(struct rte_eth_dev *dev)
>-{
>-	uint8_t i;
>-	struct vmxnet3_hw *hw = dev->data->dev_private;
>-	uint32_t *vf_table = hw->shared->devRead.rxFilterConf.vfTable;
>-
>-	PMD_INIT_FUNC_TRACE();
>-
>-	/* Verify if this tag is already set */
>-	for (i = 0; i < VMXNET3_VFT_SIZE; i++) {
>-		/* Filter all vlan tags out by default */
>-		vf_table[i] = 0;
>-		/* To-Do: Provide another routine in dev_ops for user config */
>-
>-		PMD_INIT_LOG(DEBUG, "Registering VLAN portid: %"PRIu8" tag %u",
>-					dev->data->port_id, vf_table[i]);
>-	}
>-
>-	return VMXNET3_SUCCESS;
>-}
>-- 
>2.1.4
>


  reply	other threads:[~2015-03-06 21:55 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-06  0:10 [dpdk-dev] [PATCH v3 00/10] vmxnet3: multisegment and bugfixes Stephen Hemminger
2015-03-06  0:10 ` [dpdk-dev] [PATCH v3 01/10] vmxnet3: fix link state handling Stephen Hemminger
2015-03-06 17:21   ` Sanford, Robert
     [not found]   ` <0efb310c0ee54f9192eae95f6ee909e0@BRMWP-EXMB11.corp.brocade.com>
2015-03-08 17:45     ` Stephen Hemminger
2015-03-06  0:10 ` [dpdk-dev] [PATCH v3 02/10] vmxnet3: enable VLAN filtering Stephen Hemminger
2015-03-06 21:54   ` Yong Wang [this message]
2015-03-06  0:10 ` [dpdk-dev] [PATCH v3 03/10] vmxnet3: remove mtu check Stephen Hemminger
2015-03-06  0:10 ` [dpdk-dev] [PATCH v3 04/10] vmxnet3: cleanup txq stats Stephen Hemminger
2015-03-06  0:10 ` [dpdk-dev] [PATCH v3 05/10] vmxnet3: add support for multi-segment transmit Stephen Hemminger
2015-03-06  0:10 ` [dpdk-dev] [PATCH v3 06/10] vmxnet3: support RSS and refactor offload Stephen Hemminger
2015-03-06  0:10 ` [dpdk-dev] [PATCH v3 07/10] vmxnet3: support jumbo frames Stephen Hemminger
2015-03-09 23:28   ` Yong Wang
2015-03-09 23:32     ` Yong Wang
2015-03-10 18:35       ` Stephen Hemminger
2015-03-11  1:03         ` Yong Wang
     [not found]         ` <4ebc1312d5cb42d583fb8a204c353feb@BRMWP-EXMB11.corp.brocade.com>
2015-03-11  6:54           ` Stephen Hemminger
     [not found]   ` <9bc742bd1778468a815da8070b584ee7@BRMWP-EXMB11.corp.brocade.com>
2015-03-10  4:18     ` Stephen Hemminger
2015-03-06  0:10 ` [dpdk-dev] [PATCH v3 08/10] vmxnet3: get rid of DEBUG ifdefs Stephen Hemminger
2015-03-06 21:59   ` Yong Wang
2015-03-06  0:10 ` [dpdk-dev] [PATCH v3 09/10] vmxnet3: add check for jumbo segment Stephen Hemminger
2015-03-06 23:48   ` Yong Wang
2015-03-06  0:10 ` [dpdk-dev] [PATCH v3 10/10] vmxnet3: remove excess inlining Stephen Hemminger
2015-03-06 23:54   ` Yong Wang
2015-03-07  2:00     ` Stephen Hemminger
2015-03-10 13:42 ` [dpdk-dev] [PATCH v3 00/10] vmxnet3: multisegment and bugfixes Thomas Monjalon
2015-06-22 12:22   ` Thomas Monjalon
2015-07-08 23:21     ` Thomas Monjalon

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=D11F620A.38883%yongwang@vmware.com \
    --to=yongwang@vmware.com \
    --cc=dev@dpdk.org \
    --cc=shemming@brocade.com \
    --cc=stephen@networkplumber.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).