From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rcdn-iport-5.cisco.com (rcdn-iport-5.cisco.com [173.37.86.76]) by dpdk.org (Postfix) with ESMTP id 241992BA7 for ; Tue, 5 Mar 2019 06:57:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=5568; q=dns/txt; s=iport; t=1551765423; x=1552975023; h=from:to:cc:subject:date:message-id; bh=quVQNIAIfJ1pmV5yRG83UUmN+vm85t8LObdCWwxxBO0=; b=FdPlqZv56/pijDCjxOgTzRygYj+qwJhC9gsBeJ+QZIT+efZVvE0kLIoz Wh1Mc8pFuTTStz1qoz6loJ5OltQioeeJjO95YgFpiAD8ujSQxJLnCn3yx 7JaiuLUWT1U8CbhsCWoT5QPZfxaDT5FG5rJuY2xPqHDkmmPAOCYNZJ6jQ I=; X-IronPort-AV: E=Sophos;i="5.58,442,1544486400"; d="scan'208";a="310977442" Received: from alln-core-2.cisco.com ([173.36.13.135]) by rcdn-iport-5.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2019 05:57:01 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by alln-core-2.cisco.com (8.15.2/8.15.2) with ESMTP id x255v10B012196; Tue, 5 Mar 2019 05:57:01 GMT Received: by cisco.com (Postfix, from userid 508933) id 88B9B20F2001; Mon, 4 Mar 2019 21:57:01 -0800 (PST) From: Hyong Youb Kim To: Ferruh Yigit Cc: dev@dpdk.org, John Daley , Hyong Youb Kim Date: Mon, 4 Mar 2019 21:56:59 -0800 Message-Id: <20190305055659.3095-1-hyonkim@cisco.com> X-Mailer: git-send-email 2.16.2 X-Outbound-SMTP-Client: 10.193.184.48, savbu-usnic-a.cisco.com X-Outbound-Node: alln-core-2.cisco.com Subject: [dpdk-dev] [PATCH] net/enic: add private API to set ingress VLAN rewrite mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Mar 2019 05:57:03 -0000 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 --- 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 + +#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