From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rcdn-iport-1.cisco.com (rcdn-iport-1.cisco.com [173.37.86.72]) by dpdk.org (Postfix) with ESMTP id A23381E34 for ; Sat, 2 Mar 2019 11:45:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=5579; q=dns/txt; s=iport; t=1551523522; x=1552733122; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=EgMl45Jrf9f1/NVWn7g1rgUqGvCpxCQNgxZImaDlcJk=; b=eg/sK1CzHzfl+nMAHmuR/ZmACmvLbiUsivQgGf89YJrBK9OUiGdC8OnV jeMPm+ieZ6zE9grXjl/RYwAfVQ7N9NsF4fxczTbYbl6rXlroH6BReCeIi d/CXlnGbT5N8kcSO2G7EEg6SS2g+NA2xueHLJBuGU2Xy2J8BuI3W4KNOQ s=; X-IronPort-AV: E=Sophos;i="5.58,431,1544486400"; d="scan'208";a="527406271" Received: from alln-core-7.cisco.com ([173.36.13.140]) by rcdn-iport-1.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2019 10:45:21 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by alln-core-7.cisco.com (8.15.2/8.15.2) with ESMTP id x22AjLEs029491; Sat, 2 Mar 2019 10:45:21 GMT Received: by cisco.com (Postfix, from userid 508933) id 64B5B20F2001; Sat, 2 Mar 2019 02:45:21 -0800 (PST) From: Hyong Youb Kim To: Ferruh Yigit Cc: dev@dpdk.org, John Daley , Hyong Youb Kim Date: Sat, 2 Mar 2019 02:42:47 -0800 Message-Id: <20190302104251.32565-10-hyonkim@cisco.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20190302104251.32565-1-hyonkim@cisco.com> References: <20190302104251.32565-1-hyonkim@cisco.com> X-Outbound-SMTP-Client: 10.193.184.48, savbu-usnic-a.cisco.com X-Outbound-Node: alln-core-7.cisco.com Subject: [dpdk-dev] [PATCH v2 09/13] net/enic: enable limited support for RAW flow item 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: Sat, 02 Mar 2019 10:45:23 -0000 Some apps like VPP use a raw item to match UDP tunnel headers like VXLAN or GENEVE. The NIC hardware supports such usage via L5 match, which does pattern match on packet data immediately following the outer L4 header. Accept raw items for these limited use cases. Signed-off-by: Hyong Youb Kim --- doc/guides/nics/enic.rst | 3 +- doc/guides/rel_notes/release_19_05.rst | 1 + drivers/net/enic/enic_flow.c | 65 ++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/enic.rst b/doc/guides/nics/enic.rst index 526e58ce9..c1415dc0d 100644 --- a/doc/guides/nics/enic.rst +++ b/doc/guides/nics/enic.rst @@ -255,7 +255,7 @@ Generic Flow API is supported. The baseline support is: - **1300 and later series VICS with advanced filters enabled** - Attributes: ingress - - Items: eth, ipv4, ipv6, udp, tcp, vxlan, inner eth, ipv4, ipv6, udp, tcp + - Items: eth, ipv4, ipv6, udp, tcp, vxlan, raw, inner eth, ipv4, ipv6, udp, tcp - Actions: queue, mark, drop, flag, rss, passthru, and void - Selectors: 'is', 'spec' and 'mask'. 'last' is not supported - In total, up to 64 bytes of mask is allowed across all headers @@ -455,6 +455,7 @@ PKT_RX_VLAN_STRIPPED mbuf flags would not be set. This mode is enabled with the to supporting MARK + RSS and PASSTHRU + MARK to allow the application to mark packets and then receive them normally. These require 1400 series VIC adapters and latest firmware. + - RAW items are limited to matching UDP tunnel headers like VXLAN. - **Statistics** diff --git a/doc/guides/rel_notes/release_19_05.rst b/doc/guides/rel_notes/release_19_05.rst index c8c12c47a..e5f5c0e25 100644 --- a/doc/guides/rel_notes/release_19_05.rst +++ b/doc/guides/rel_notes/release_19_05.rst @@ -79,6 +79,7 @@ New Features * **Updated the enic driver.** + * Added limited support for RAW. * Added limited support for RSS. * Added limited support for PASSTHRU. diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index fda641b6f..ffc6ce1da 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -77,6 +77,7 @@ struct enic_action_cap { static enic_copy_item_fn enic_copy_item_ipv4_v1; static enic_copy_item_fn enic_copy_item_udp_v1; static enic_copy_item_fn enic_copy_item_tcp_v1; +static enic_copy_item_fn enic_copy_item_raw_v2; static enic_copy_item_fn enic_copy_item_eth_v2; static enic_copy_item_fn enic_copy_item_vlan_v2; static enic_copy_item_fn enic_copy_item_ipv4_v2; @@ -123,6 +124,14 @@ static const struct enic_items enic_items_v1[] = { * that layer 3 must be specified. */ static const struct enic_items enic_items_v2[] = { + [RTE_FLOW_ITEM_TYPE_RAW] = { + .copy_item = enic_copy_item_raw_v2, + .valid_start_item = 0, + .prev_items = (const enum rte_flow_item_type[]) { + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_END, + }, + }, [RTE_FLOW_ITEM_TYPE_ETH] = { .copy_item = enic_copy_item_eth_v2, .valid_start_item = 1, @@ -196,6 +205,14 @@ static const struct enic_items enic_items_v2[] = { /** NICs with Advanced filters enabled */ static const struct enic_items enic_items_v3[] = { + [RTE_FLOW_ITEM_TYPE_RAW] = { + .copy_item = enic_copy_item_raw_v2, + .valid_start_item = 0, + .prev_items = (const enum rte_flow_item_type[]) { + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_END, + }, + }, [RTE_FLOW_ITEM_TYPE_ETH] = { .copy_item = enic_copy_item_eth_v2, .valid_start_item = 1, @@ -835,6 +852,54 @@ enic_copy_item_vxlan_v2(struct copy_item_args *arg) return 0; } +/* + * Copy raw item into version 2 NIC filter. Currently, raw pattern match is + * very limited. It is intended for matching UDP tunnel header (e.g. vxlan + * or geneve). + */ +static int +enic_copy_item_raw_v2(struct copy_item_args *arg) +{ + const struct rte_flow_item *item = arg->item; + struct filter_v2 *enic_filter = arg->filter; + uint8_t *inner_ofst = arg->inner_ofst; + const struct rte_flow_item_raw *spec = item->spec; + const struct rte_flow_item_raw *mask = item->mask; + struct filter_generic_1 *gp = &enic_filter->u.generic_1; + + FLOW_TRACE(); + + /* Cannot be used for inner packet */ + if (*inner_ofst) + return EINVAL; + /* Need both spec and mask */ + if (!spec || !mask) + return EINVAL; + /* Only supports relative with offset 0 */ + if (!spec->relative || spec->offset != 0 || spec->search || spec->limit) + return EINVAL; + /* Need non-null pattern that fits within the NIC's filter pattern */ + if (spec->length == 0 || spec->length > FILTER_GENERIC_1_KEY_LEN || + !spec->pattern || !mask->pattern) + return EINVAL; + /* + * Mask fields, including length, are often set to zero. Assume that + * means "same as spec" to avoid breaking existing apps. If length + * is not zero, then it should be >= spec length. + * + * No more pattern follows this, so append to the L4 layer instead of + * L5 to work with both recent and older VICs. + */ + if (mask->length != 0 && mask->length < spec->length) + return EINVAL; + memcpy(gp->layer[FILTER_GENERIC_1_L4].mask + sizeof(struct udp_hdr), + mask->pattern, spec->length); + memcpy(gp->layer[FILTER_GENERIC_1_L4].val + sizeof(struct udp_hdr), + spec->pattern, spec->length); + + return 0; +} + /** * Return 1 if current item is valid on top of the previous one. * -- 2.16.2