net/enic: add private API to set ingress VLAN rewrite mode
diff mbox series

Message ID 20190305055659.3095-1-hyonkim@cisco.com
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • net/enic: add private API to set ingress VLAN rewrite mode
Related show

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK

Commit Message

Hyong Youb Kim (hyonkim) March 5, 2019, 5:56 a.m. UTC
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

Patch
diff mbox series

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;