From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rcdn-iport-6.cisco.com (rcdn-iport-6.cisco.com [173.37.86.77]) by dpdk.org (Postfix) with ESMTP id A5AD13798 for ; Thu, 16 Aug 2018 01:13:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=8887; q=dns/txt; s=iport; t=1534374838; x=1535584438; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=2CYFxn7tRioGAPTyP8JETQrzCtbZJjv7H+RDeY0N9cY=; b=A0glD91dGeqtDHQOESXFfpDV1Qw+5C+cWBn4ESm3sSa18NFyAh3OZPB0 fy7NkXih0dbUUR5f1Xf+0uygqS8gOi6L8QKkKgnijof/fXBzMdftP4xTQ Vhs4vFBrdaip2RqPinXY7p/dvO8WyQPlyjgJiOTvP4mYkB1h0ddHIg0qZ E=; X-IronPort-AV: E=Sophos;i="5.53,245,1531785600"; d="scan'208";a="438740093" Received: from alln-core-10.cisco.com ([173.36.13.132]) by rcdn-iport-6.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Aug 2018 23:13:57 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by alln-core-10.cisco.com (8.15.2/8.15.2) with ESMTP id w7FNDvDn029757; Wed, 15 Aug 2018 23:13:57 GMT Received: by cisco.com (Postfix, from userid 392789) id 6EF233FAB6EF; Wed, 15 Aug 2018 16:13:57 -0700 (PDT) From: John Daley To: stable@dpdk.org Cc: Hyong Youb Kim Date: Wed, 15 Aug 2018 16:13:38 -0700 Message-Id: <20180815231338.1741-3-johndale@cisco.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180815231338.1741-1-johndale@cisco.com> References: <20180815231338.1741-1-johndale@cisco.com> X-Outbound-SMTP-Client: 10.193.184.48, savbu-usnic-a.cisco.com X-Outbound-Node: alln-core-10.cisco.com Subject: [dpdk-stable] [PATCH 18.05] net/enic: add devarg to specify ingress VLAN rewrite mode X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Aug 2018 23:13:59 -0000 From: Hyong Youb Kim [ backported from upstream commit e39c2756e21ad50d5c7e119bb82732ef49af8ef7 ] Add a new devarg "ig-vlan-rewrite" to allow the user to set non-default rewrite mode. The UCS VIC may add/remove/modify the VLAN header of an ingress packet depending on the ingress VLAN rewrite mode. By default, the driver sets the pass-through mode, which tells the NIC "do not touch VLAN header and preserve it as is". This mode is usually sufficient, but can complicate deployments for certain environments. For example, OVS-DPDK in UCS blade environments may want to use "untag default VLAN mode", which removes the VLAN header from an ingress packet if it matches vNIC's default VLAN. Signed-off-by: Hyong Youb Kim Reviewed-by: John Daley Acked-by: Aaron Conole --- While not a "bug fix" we request this patch be applied to 18.05 stable because it can simplify OVS configurations in UCS blade environments and also improve performance by allowing packets to flow through the faster no-VLAN path with "untag" specified in the new devarg. The patch is completely non-invasive since it requires a devarg to enable it. doc/guides/nics/enic.rst | 44 +++++++++++++++++++++++++++++++++++++--- drivers/net/enic/enic.h | 1 + drivers/net/enic/enic_ethdev.c | 46 +++++++++++++++++++++++++++++++++++++++--- drivers/net/enic/enic_main.c | 4 +++- 4 files changed, 88 insertions(+), 7 deletions(-) diff --git a/doc/guides/nics/enic.rst b/doc/guides/nics/enic.rst index d650ba0f7..fabf9c998 100644 --- a/doc/guides/nics/enic.rst +++ b/doc/guides/nics/enic.rst @@ -336,6 +336,35 @@ it, set ``devargs`` parameter ``disable-overlay=1``. For example:: -w 12:00.0,disable-overlay=1 +Ingress VLAN Rewrite +-------------------- + +VIC adapters can tag, untag, or modify the VLAN headers of ingress +packets. The ingress VLAN rewrite mode controls this behavior. By +default, it is set to pass-through, where the NIC does not modify the +VLAN header in any way so that the application can see the original +header. This mode is sufficient for many applications, but may not be +suitable for others. Such applications may change the mode by setting +``devargs`` parameter ``ig-vlan-rewrite`` to one of the following. + +- ``pass``: Pass-through mode. The NIC does not modify the VLAN + header. This is the default mode. + +- ``priority``: Priority-tag default VLAN mode. If the ingress packet + is tagged with the default VLAN, the NIC replaces its VLAN header + with the priority tag (VLAN ID 0). + +- ``trunk``: Default trunk mode. The NIC tags untagged ingress packets + with the default VLAN. Tagged ingress packets are not modified. To + the application, every packet appears as tagged. + +- ``untag``: Untag default VLAN mode. If the ingress packet is tagged + with the default VLAN, the NIC removes or untags its VLAN header so + that the application sees an untagged packet. As a result, the + default VLAN becomes `untagged`. This mode can be useful for + applications such as OVS-DPDK performance benchmarks that utilize + only the default VLAN and want to see only untagged packets. + .. _enic_limitations: Limitations @@ -351,9 +380,10 @@ Limitations In test setups where an Ethernet port of a Cisco adapter in TRUNK mode is connected point-to-point to another adapter port or connected though a router instead of a switch, all ingress packets will be VLAN tagged. Programs such - as l3fwd which do not account for VLAN tags in packets will misbehave. The - solution is to enable VLAN stripping on ingress. The following code fragment is - an example of how to accomplish this: + as l3fwd may not account for VLAN tags in packets and may misbehave. One + solution is to enable VLAN stripping on ingress so the VLAN tag is removed + from the packet and put into the mbuf->vlan_tci field. Here is an example + of how to accomplish this: .. code-block:: console @@ -361,6 +391,14 @@ Limitations vlan_offload |= ETH_VLAN_STRIP_OFFLOAD; rte_eth_dev_set_vlan_offload(port, vlan_offload); +Another alternative is modify the adapter's ingress VLAN rewrite mode so that +packets with the default VLAN tag are stripped by the adapter and presented to +DPDK as untagged packets. In this case mbuf->vlan_tci and the PKT_RX_VLAN and +PKT_RX_VLAN_STRIPPED mbuf flags would not be set. This mode is enabled with the +``devargs`` parameter ``ig-vlan-rewrite=untag``. For example:: + + -w 12:00.0,ig-vlan-rewrite=untag + - Limited flow director support on 1200 series and 1300 series Cisco VIC adapters with old firmware. Please see :ref:`enic-flow-director`. diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h index ea0a688d3..f1895fe70 100644 --- a/drivers/net/enic/enic.h +++ b/drivers/net/enic/enic.h @@ -125,6 +125,7 @@ struct enic { bool disable_overlay; /* devargs disable_overlay=1 */ bool nic_cfg_chk; /* NIC_CFG_CHK available */ bool udp_rss_weak; /* Bodega style UDP RSS */ + uint8_t ig_vlan_rewrite_mode; /* devargs ig-vlan-rewrite */ unsigned int flags; unsigned int priv_flags; diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 6ebad8d96..2cc9a534e 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -41,6 +41,7 @@ static const struct rte_pci_id pci_id_enic_map[] = { }; #define ENIC_DEVARG_DISABLE_OVERLAY "disable-overlay" +#define ENIC_DEVARG_IG_VLAN_REWRITE "ig-vlan-rewrite" RTE_INIT(enicpmd_init_log); static void @@ -834,23 +835,61 @@ static int enic_parse_disable_overlay(__rte_unused const char *key, return 0; } +static int enic_parse_ig_vlan_rewrite(__rte_unused const char *key, + const char *value, + void *opaque) +{ + struct enic *enic; + + enic = (struct enic *)opaque; + if (strcmp(value, "trunk") == 0) { + /* Trunk mode: always tag */ + enic->ig_vlan_rewrite_mode = IG_VLAN_REWRITE_MODE_DEFAULT_TRUNK; + } else if (strcmp(value, "untag") == 0) { + /* Untag default VLAN mode: untag if VLAN = default VLAN */ + enic->ig_vlan_rewrite_mode = + IG_VLAN_REWRITE_MODE_UNTAG_DEFAULT_VLAN; + } else if (strcmp(value, "priority") == 0) { + /* + * Priority-tag default VLAN mode: priority tag (VLAN header + * with ID=0) if VLAN = default + */ + enic->ig_vlan_rewrite_mode = + IG_VLAN_REWRITE_MODE_PRIORITY_TAG_DEFAULT_VLAN; + } else if (strcmp(value, "pass") == 0) { + /* Pass through mode: do not touch tags */ + enic->ig_vlan_rewrite_mode = IG_VLAN_REWRITE_MODE_PASS_THRU; + } else { + dev_err(enic, "Invalid value for " ENIC_DEVARG_IG_VLAN_REWRITE + ": expected=trunk|untag|priority|pass given=%s\n", + value); + return -EINVAL; + } + return 0; +} + static int enic_check_devargs(struct rte_eth_dev *dev) { static const char *const valid_keys[] = { - ENIC_DEVARG_DISABLE_OVERLAY, NULL}; + ENIC_DEVARG_DISABLE_OVERLAY, + ENIC_DEVARG_IG_VLAN_REWRITE, + NULL}; struct enic *enic = pmd_priv(dev); struct rte_kvargs *kvlist; ENICPMD_FUNC_TRACE(); enic->disable_overlay = false; + enic->ig_vlan_rewrite_mode = IG_VLAN_REWRITE_MODE_PASS_THRU; if (!dev->device->devargs) return 0; kvlist = rte_kvargs_parse(dev->device->devargs->args, valid_keys); if (!kvlist) return -EINVAL; if (rte_kvargs_process(kvlist, ENIC_DEVARG_DISABLE_OVERLAY, - enic_parse_disable_overlay, enic) < 0) { + enic_parse_disable_overlay, enic) < 0 || + rte_kvargs_process(kvlist, ENIC_DEVARG_IG_VLAN_REWRITE, + enic_parse_ig_vlan_rewrite, enic) < 0) { rte_kvargs_free(kvlist); return -EINVAL; } @@ -915,4 +954,5 @@ 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"); RTE_PMD_REGISTER_PARAM_STRING(net_enic, - ENIC_DEVARG_DISABLE_OVERLAY "=<0|1> "); + ENIC_DEVARG_DISABLE_OVERLAY "=0|1 " + ENIC_DEVARG_IG_VLAN_REWRITE "=trunk|untag|priority|pass"); diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index 863d2463c..baafb5a53 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -1645,8 +1645,10 @@ int enic_probe(struct enic *enic) } /* Set ingress vlan rewrite mode before vnic initialization */ + dev_debug(enic, "Set ig_vlan_rewrite_mode=%u\n", + enic->ig_vlan_rewrite_mode); err = vnic_dev_set_ig_vlan_rewrite_mode(enic->vdev, - IG_VLAN_REWRITE_MODE_PASS_THRU); + enic->ig_vlan_rewrite_mode); if (err) { dev_err(enic, "Failed to set ingress vlan rewrite mode, aborting.\n"); -- 2.16.2