DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hyong Youb Kim <hyonkim@cisco.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: dev@dpdk.org, John Daley <johndale@cisco.com>,
	Hyong Youb Kim <hyonkim@cisco.com>
Subject: [dpdk-dev] [PATCH] net/enic: add private API to set ingress VLAN rewrite mode
Date: Mon,  4 Mar 2019 21:56:59 -0800	[thread overview]
Message-ID: <20190305055659.3095-1-hyonkim@cisco.com> (raw)

The driver currently has a devarg to set the rewrite mode during
init. Some apps want to programatically set it after running
rte_eal_init() and finding that ports are VIC. Add a private function
to support such applications.

Signed-off-by: Hyong Youb Kim <hyonkim@cisco.com>
---
 drivers/net/enic/Makefile                 |  3 +++
 drivers/net/enic/enic.h                   |  1 +
 drivers/net/enic/enic_ethdev.c            |  7 +++++++
 drivers/net/enic/meson.build              |  1 +
 drivers/net/enic/rte_pmd_enic.c           | 33 +++++++++++++++++++++++++++++++
 drivers/net/enic/rte_pmd_enic.h           | 27 +++++++++++++++++++++++++
 drivers/net/enic/rte_pmd_enic_version.map |  6 ++++++
 7 files changed, 78 insertions(+)
 create mode 100644 drivers/net/enic/rte_pmd_enic.c
 create mode 100644 drivers/net/enic/rte_pmd_enic.h

diff --git a/drivers/net/enic/Makefile b/drivers/net/enic/Makefile
index 04bae35e3..60373fa30 100644
--- a/drivers/net/enic/Makefile
+++ b/drivers/net/enic/Makefile
@@ -37,6 +37,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += base/vnic_wq.c
 SRCS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += base/vnic_dev.c
 SRCS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += base/vnic_intr.c
 SRCS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += base/vnic_rq.c
+SRCS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += rte_pmd_enic.c
 
 # The current implementation assumes 64-bit pointers
 CC_AVX2_SUPPORT=0
@@ -66,4 +67,6 @@ ifeq ($(CC_AVX2_SUPPORT), 1)
 	SRCS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += enic_rxtx_vec_avx2.c
 endif
 
+SYMLINK-$(CONFIG_RTE_LIBRTE_ENIC_PMD)-include := rte_pmd_enic.h
+
 include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h
index fa4d5590e..94563fe70 100644
--- a/drivers/net/enic/enic.h
+++ b/drivers/net/enic/enic.h
@@ -279,6 +279,7 @@ enic_ring_incr(uint32_t n_descriptors, uint32_t idx)
 	return idx;
 }
 
+bool enic_dev_is_enic(struct rte_eth_dev *dev);
 void enic_fdir_stats_get(struct enic *enic,
 			 struct rte_eth_fdir_stats *stats);
 int enic_fdir_add_fltr(struct enic *enic,
diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c
index 8d14d8ac7..3a6aba3a2 100644
--- a/drivers/net/enic/enic_ethdev.c
+++ b/drivers/net/enic/enic_ethdev.c
@@ -1199,6 +1199,13 @@ static struct rte_pci_driver rte_enic_pmd = {
 	.remove = eth_enic_pci_remove,
 };
 
+bool
+enic_dev_is_enic(struct rte_eth_dev *dev)
+{
+	return strcmp(dev->device->driver->name,
+		      rte_enic_pmd.driver.name) == 0;
+}
+
 RTE_PMD_REGISTER_PCI(net_enic, rte_enic_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_enic, pci_id_enic_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_enic, "* igb_uio | uio_pci_generic | vfio-pci");
diff --git a/drivers/net/enic/meson.build b/drivers/net/enic/meson.build
index c381f1496..c5520c17b 100644
--- a/drivers/net/enic/meson.build
+++ b/drivers/net/enic/meson.build
@@ -13,6 +13,7 @@ sources = files(
 	'enic_main.c',
 	'enic_res.c',
 	'enic_rxtx.c',
+	'rte_pmd_enic.c',
 	)
 deps += ['hash']
 includes += include_directories('base')
diff --git a/drivers/net/enic/rte_pmd_enic.c b/drivers/net/enic/rte_pmd_enic.c
new file mode 100644
index 000000000..7c98edd35
--- /dev/null
+++ b/drivers/net/enic/rte_pmd_enic.c
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2019 Cisco Systems, Inc.  All rights reserved.
+ */
+
+#include <rte_ethdev_driver.h>
+
+#include "enic_compat.h"
+#include "enic.h"
+#include "rte_pmd_enic.h"
+
+int
+rte_pmd_enic_set_ig_vlan_rewrite(uint16_t port, uint8_t mode)
+{
+	struct rte_eth_dev *dev;
+	struct enic *enic;
+	int err;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+	dev = &rte_eth_devices[port];
+	if (!enic_dev_is_enic(dev))
+		return -ENOTSUP;
+	if (mode > RTE_PMD_ENIC_IG_VLAN_REWRITE_MODE_PASS_THRU)
+		return -EINVAL;
+	enic = pmd_priv(dev);
+	dev_debug(enic, "Set ig_vlan_rewrite_mode=%u\n", mode);
+	err = vnic_dev_set_ig_vlan_rewrite_mode(enic->vdev, mode);
+	if (err) {
+		dev_err(enic, "Failed to set ingress vlan rewrite mode\n");
+		return err;
+	}
+	enic->ig_vlan_rewrite_mode = mode;
+	return 0;
+}
diff --git a/drivers/net/enic/rte_pmd_enic.h b/drivers/net/enic/rte_pmd_enic.h
new file mode 100644
index 000000000..d4486929a
--- /dev/null
+++ b/drivers/net/enic/rte_pmd_enic.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2019 Cisco Systems, Inc.  All rights reserved.
+ */
+
+#ifndef _RTE_PMD_ENIC_H_
+#define _RTE_PMD_ENIC_H_
+
+#define RTE_PMD_ENIC_IG_VLAN_REWRITE_MODE_DEFAULT_TRUNK              0
+#define RTE_PMD_ENIC_IG_VLAN_REWRITE_MODE_UNTAG_DEFAULT_VLAN         1
+#define RTE_PMD_ENIC_IG_VLAN_REWRITE_MODE_PRIORITY_TAG_DEFAULT_VLAN  2
+#define RTE_PMD_ENIC_IG_VLAN_REWRITE_MODE_PASS_THRU                  3
+
+/**
+ * Set the ingress VLAN rewrite mode.
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param mode
+ *    Rewrite mode.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ */
+int rte_pmd_enic_set_ig_vlan_rewrite(uint16_t port, uint8_t mode);
+
+#endif /* _RTE_PMD_ENIC_H_ */
diff --git a/drivers/net/enic/rte_pmd_enic_version.map b/drivers/net/enic/rte_pmd_enic_version.map
index ef3539840..0abef048d 100644
--- a/drivers/net/enic/rte_pmd_enic_version.map
+++ b/drivers/net/enic/rte_pmd_enic_version.map
@@ -2,3 +2,9 @@ DPDK_2.0 {
 
 	local: *;
 };
+
+DPDK_19.05 {
+	global:
+
+	rte_pmd_enic_set_ig_vlan_rewrite;
+} DPDK_2.0;
-- 
2.16.2

             reply	other threads:[~2019-03-05  5:57 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-05  5:56 Hyong Youb Kim [this message]
2019-03-05  7:11 ` [dpdk-dev] [PATCH v2] " Hyong Youb Kim
2019-03-13 18:32   ` Ferruh Yigit
2019-03-13 20:36     ` Thomas Monjalon
2019-03-13 20:36       ` Thomas Monjalon
2019-03-13 21:11       ` John Daley (johndale)
2019-03-13 21:11         ` John Daley (johndale)
2019-03-13 21:29         ` Thomas Monjalon
2019-03-13 21:29           ` Thomas Monjalon
2019-03-14  2:58           ` Hyong Youb Kim
2019-03-14  2:58             ` Hyong Youb Kim
2019-03-14 22:04             ` Thomas Monjalon
2019-03-14 22:04               ` Thomas Monjalon
2019-03-19 17:29               ` Ferruh Yigit
2019-03-19 17:29                 ` Ferruh Yigit
2019-03-19 17:36                 ` Thomas Monjalon
2019-03-19 17:36                   ` Thomas Monjalon
2019-03-19 18:00                   ` Ferruh Yigit
2019-03-19 18:00                     ` Ferruh Yigit
2019-03-19 20:30                     ` Thomas Monjalon
2019-03-19 20:30                       ` Thomas Monjalon
2019-03-20 10:45                       ` Ferruh Yigit
2019-03-20 10:45                         ` Ferruh Yigit
2019-03-20 11:46                         ` Thomas Monjalon
2019-03-20 11:46                           ` Thomas Monjalon
2019-03-25 11:49                           ` Ferruh Yigit
2019-03-25 11:49                             ` Ferruh Yigit
2019-03-25 13:26                             ` Gaëtan Rivet
2019-03-25 13:26                               ` Gaëtan Rivet
2019-03-25 13:33                               ` Gaëtan Rivet
2019-03-25 13:33                                 ` Gaëtan Rivet
2019-03-26  6:39                                 ` Hyong Youb Kim
2019-03-26  6:39                                   ` Hyong Youb Kim

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=20190305055659.3095-1-hyonkim@cisco.com \
    --to=hyonkim@cisco.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=johndale@cisco.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
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).