From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B6EF3A0544; Tue, 25 Oct 2022 23:45:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 21AE942C51; Tue, 25 Oct 2022 23:45:00 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by mails.dpdk.org (Postfix) with ESMTP id 0B3DE42C75 for ; Tue, 25 Oct 2022 23:44:58 +0200 (CEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id BD17F5C01AC; Tue, 25 Oct 2022 17:44:57 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 25 Oct 2022 17:44:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1666734297; x=1666820697; bh=IV VtQhy2Cq8xxoRMsKtVjmdHVW//XVe0x0ktVGvwQ1s=; b=avCM6qxRbyYGll9zNU H/o7ICYgwcFuGQNSCw2bq0io/pgHoVqXs0Atn8rzrl1HSPX/tzf+DvbVMoVWsXPk ZgovUAvjYqwyUFewP1LGr2KwMI6+1I66E4IxhXmtxO+x2xW3KC/D7Hmnu12oSUgw VRly55h9rwW8tGaeHRq+JYhCnpzS2l85c0qM/wfhTGL8p1t62des18gBHQuiTSnZ tUq1LNTYIxxkwTSHZY2HDcM96GnDIpAx5wdqxVdBmtBvsLSnn2YmQiNhk7j5omi/ yjVy+rVq2zYp67hqyKLBW//j2qgGbDhHzTbkVVNS6Nvm/KtZpLGroqIokEB/pe2U QetQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1666734297; x=1666820697; bh=IVVtQhy2Cq8xx oRMsKtVjmdHVW//XVe0x0ktVGvwQ1s=; b=JJv3W9vzwgbWulxVzTLtD/pKCrxxQ sWadCkhrpH6rkA79iJEw6TPIv4/Z8Rk4rA3bG8a/EY8SjAyPvCsE1ZMHM/r/BoDp WsUtmeh1pPIma/wDHxBHqStmI3d7USOUW9BMtFFBVnWmIAdMpnuRwMrab2P5Xq1z pgrCQNGnpynm8ZBm2ZhHDnIIOomi1mTa5ZqCAExplfZStJ8r8ZWpTbhQPWJj/Sg0 8qfiOE90vfb+v0CspUW4jnMczQybuFXyQ3C7r53MWpliF+6NKqF5GOL8SnNKBmRm n/NRrRsNmdPal90/lTeJVxBB8vRRUt/sAypbkuZzPTlzuRbLlTf+bJbAA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrtddugddtvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepvdejhfdugeehvddtieejieegteeuudfgjeeukeeiledthfetveek hefhieelhfdtnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrh homhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 25 Oct 2022 17:44:56 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: ferruh.yigit@amd.com, andrew.rybchenko@oktetlabs.ru, Wisam Jaddo , Ori Kam , Aman Singh , Yuying Zhang , Ajit Khaparde , Somnath Kotur , Hemant Agrawal , Sachin Saxena , Matan Azrad , Viacheslav Ovsiienko Subject: [PATCH 4/8] ethdev: use GRE protocol struct for flow matching Date: Tue, 25 Oct 2022 23:44:06 +0200 Message-Id: <20221025214410.715864-5-thomas@monjalon.net> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221025214410.715864-1-thomas@monjalon.net> References: <20221025214410.715864-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org As announced in the deprecation notice, flow item structures should re-use the protocol header definitions from the directory lib/net/. The protocol struct is added in an unnamed union, keeping old field names. The GRE header struct members are used in apps and drivers instead of the redundant fields in the flow items. Signed-off-by: Thomas Monjalon --- app/test-flow-perf/items_gen.c | 4 ++-- app/test-pmd/cmdline_flow.c | 6 +++--- doc/guides/prog_guide/rte_flow.rst | 6 +----- doc/guides/rel_notes/deprecation.rst | 1 - drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 12 +++-------- drivers/net/dpaa2/dpaa2_flow.c | 12 +++++------ drivers/net/mlx5/mlx5_flow.c | 22 +++++++++----------- drivers/net/mlx5/mlx5_flow_dv.c | 26 +++++++++++++----------- drivers/net/mlx5/mlx5_flow_verbs.c | 8 ++++---- lib/ethdev/rte_flow.h | 24 +++++++++++++++------- 10 files changed, 60 insertions(+), 61 deletions(-) diff --git a/app/test-flow-perf/items_gen.c b/app/test-flow-perf/items_gen.c index a58245239b..0f19e5e536 100644 --- a/app/test-flow-perf/items_gen.c +++ b/app/test-flow-perf/items_gen.c @@ -173,10 +173,10 @@ add_gre(struct rte_flow_item *items, __rte_unused struct additional_para para) { static struct rte_flow_item_gre gre_spec = { - .protocol = RTE_BE16(RTE_ETHER_TYPE_TEB), + .hdr.proto = RTE_BE16(RTE_ETHER_TYPE_TEB), }; static struct rte_flow_item_gre gre_mask = { - .protocol = RTE_BE16(0xffff), + .hdr.proto = RTE_BE16(0xffff), }; items[items_counter].type = RTE_FLOW_ITEM_TYPE_GRE; diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index fcbd0a2534..3c2d090a08 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -4037,7 +4037,7 @@ static const struct token token_list[] = { .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre, - protocol)), + hdr.proto)), }, [ITEM_GRE_C_RSVD0_VER] = { .name = "c_rsvd0_ver", @@ -7752,7 +7752,7 @@ parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token, }, }; struct rte_flow_item_gre gre = { - .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST), + .hdr.proto = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST), }; struct rte_flow_item_mpls mpls = { .ttl = 0, @@ -7850,7 +7850,7 @@ parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token, }, }; struct rte_flow_item_gre gre = { - .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST), + .hdr.proto = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST), }; struct rte_flow_item_mpls mpls; uint8_t *header; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 92d3168d39..b6ffb03b01 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -980,8 +980,7 @@ Item: ``GRE`` Matches a GRE header. -- ``c_rsvd0_ver``: checksum, reserved 0 and version. -- ``protocol``: protocol type. +- ``hdr``: header definition (``rte_gre.h``). - Default ``mask`` matches protocol only. Item: ``GRE_KEY`` @@ -1000,9 +999,6 @@ Item: ``GRE_OPTION`` Matches a GRE optional fields (checksum/key/sequence). This should be preceded by item ``GRE``. -- ``checksum``: checksum. -- ``key``: key. -- ``sequence``: sequence. - The items in GRE_OPTION do not change bit flags(c_bit/k_bit/s_bit) in GRE item. The bit flags need be set with GRE item by application. When the items present, the corresponding bits in GRE spec and mask should be set "1" by diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 52c43bb652..8e7af28318 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -70,7 +70,6 @@ Deprecation Notices - ``rte_flow_item_e_tag`` - ``rte_flow_item_geneve`` - ``rte_flow_item_geneve_opt`` - - ``rte_flow_item_gre`` - ``rte_flow_item_gtp`` - ``rte_flow_item_icmp6`` - ``rte_flow_item_icmp6_nd_na`` diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c index 80869b79c3..280ddc0d94 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -1461,16 +1461,10 @@ ulp_rte_gre_hdr_handler(const struct rte_flow_item *item, return BNXT_TF_RC_ERROR; } - size = sizeof(((struct rte_flow_item_gre *)NULL)->c_rsvd0_ver); + size = sizeof(((struct rte_flow_item_gre *)NULL)->hdr.proto); ulp_rte_prsr_fld_mask(params, &idx, size, - ulp_deference_struct(gre_spec, c_rsvd0_ver), - ulp_deference_struct(gre_mask, c_rsvd0_ver), - ULP_PRSR_ACT_DEFAULT); - - size = sizeof(((struct rte_flow_item_gre *)NULL)->protocol); - ulp_rte_prsr_fld_mask(params, &idx, size, - ulp_deference_struct(gre_spec, protocol), - ulp_deference_struct(gre_mask, protocol), + ulp_deference_struct(gre_spec, hdr.proto), + ulp_deference_struct(gre_mask, hdr.proto), ULP_PRSR_ACT_DEFAULT); /* Update the hdr_bitmap with GRE */ diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.c index eec7e60650..8a6d44da48 100644 --- a/drivers/net/dpaa2/dpaa2_flow.c +++ b/drivers/net/dpaa2/dpaa2_flow.c @@ -154,7 +154,7 @@ static const struct rte_flow_item_sctp dpaa2_flow_item_sctp_mask = { }; static const struct rte_flow_item_gre dpaa2_flow_item_gre_mask = { - .protocol = RTE_BE16(0xffff), + .hdr.proto = RTE_BE16(0xffff), }; #endif @@ -2792,7 +2792,7 @@ dpaa2_configure_flow_gre(struct rte_flow *flow, return -1; } - if (!mask->protocol) + if (!mask->hdr.proto) return 0; index = dpaa2_flow_extract_search( @@ -2841,8 +2841,8 @@ dpaa2_configure_flow_gre(struct rte_flow *flow, &flow->qos_rule, NET_PROT_GRE, NH_FLD_GRE_TYPE, - &spec->protocol, - &mask->protocol, + &spec->hdr.proto, + &mask->hdr.proto, sizeof(rte_be16_t)); if (ret) { DPAA2_PMD_ERR( @@ -2855,8 +2855,8 @@ dpaa2_configure_flow_gre(struct rte_flow *flow, &flow->fs_rule, NET_PROT_GRE, NH_FLD_GRE_TYPE, - &spec->protocol, - &mask->protocol, + &spec->hdr.proto, + &mask->hdr.proto, sizeof(rte_be16_t)); if (ret) { DPAA2_PMD_ERR( diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 10f6abeb07..b4a560c18a 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -304,7 +304,7 @@ mlx5_flow_expand_rss_item_complete(const struct rte_flow_item *item) ret = mlx5_ethertype_to_item_type(spec, mask, true); break; case RTE_FLOW_ITEM_TYPE_GRE: - MLX5_XSET_ITEM_MASK_SPEC(gre, protocol); + MLX5_XSET_ITEM_MASK_SPEC(gre, hdr.proto); ret = mlx5_ethertype_to_item_type(spec, mask, true); break; case RTE_FLOW_ITEM_TYPE_VXLAN_GPE: @@ -2987,8 +2987,7 @@ mlx5_flow_validate_item_gre_key(const struct rte_flow_item *item, if (!gre_mask) gre_mask = &rte_flow_item_gre_mask; gre_spec = gre_item->spec; - if (gre_spec && (gre_mask->c_rsvd0_ver & RTE_BE16(0x2000)) && - !(gre_spec->c_rsvd0_ver & RTE_BE16(0x2000))) + if (gre_spec && (gre_mask->hdr.k) && !(gre_spec->hdr.k)) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, "Key bit must be on"); @@ -3063,21 +3062,18 @@ mlx5_flow_validate_item_gre_option(struct rte_eth_dev *dev, if (!gre_mask) gre_mask = &rte_flow_item_gre_mask; if (mask->checksum_rsvd.checksum) - if (gre_spec && (gre_mask->c_rsvd0_ver & RTE_BE16(0x8000)) && - !(gre_spec->c_rsvd0_ver & RTE_BE16(0x8000))) + if (gre_spec && (gre_mask->hdr.c) && !(gre_spec->hdr.c)) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, "Checksum bit must be on"); if (mask->key.key) - if (gre_spec && (gre_mask->c_rsvd0_ver & RTE_BE16(0x2000)) && - !(gre_spec->c_rsvd0_ver & RTE_BE16(0x2000))) + if (gre_spec && (gre_mask->hdr.k) && !(gre_spec->hdr.k)) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, "Key bit must be on"); if (mask->sequence.sequence) - if (gre_spec && (gre_mask->c_rsvd0_ver & RTE_BE16(0x1000)) && - !(gre_spec->c_rsvd0_ver & RTE_BE16(0x1000))) + if (gre_spec && (gre_mask->hdr.s) && !(gre_spec->hdr.s)) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, item, @@ -3128,8 +3124,10 @@ mlx5_flow_validate_item_gre(const struct rte_flow_item *item, const struct rte_flow_item_gre *mask = item->mask; int ret; const struct rte_flow_item_gre nic_mask = { - .c_rsvd0_ver = RTE_BE16(0xB000), - .protocol = RTE_BE16(UINT16_MAX), + .hdr.c = 1, + .hdr.k = 1, + .hdr.s = 1, + .hdr.proto = RTE_BE16(UINT16_MAX), }; if (target_protocol != 0xff && target_protocol != IPPROTO_GRE) @@ -3157,7 +3155,7 @@ mlx5_flow_validate_item_gre(const struct rte_flow_item *item, return ret; #ifndef HAVE_MLX5DV_DR #ifndef HAVE_IBV_DEVICE_MPLS_SUPPORT - if (spec && (spec->protocol & mask->protocol)) + if (spec && (spec->hdr.proto & mask->hdr.proto)) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, item, "without MPLS support the" diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index a06b6e1860..f70018be50 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -9019,8 +9019,8 @@ flow_dv_translate_item_gre(void *matcher, void *key, if (!gre_m) gre_m = &rte_flow_item_gre_mask; } - gre_crks_rsvd0_ver_m.value = rte_be_to_cpu_16(gre_m->c_rsvd0_ver); - gre_crks_rsvd0_ver_v.value = rte_be_to_cpu_16(gre_v->c_rsvd0_ver); + gre_crks_rsvd0_ver_m.value = rte_be_to_cpu_16(*(const uint16_t*)&gre_m->hdr); + gre_crks_rsvd0_ver_v.value = rte_be_to_cpu_16(*(const uint16_t*)&gre_v->hdr); MLX5_SET(fte_match_set_misc, misc_m, gre_c_present, gre_crks_rsvd0_ver_m.c_present); MLX5_SET(fte_match_set_misc, misc_v, gre_c_present, @@ -9036,8 +9036,8 @@ flow_dv_translate_item_gre(void *matcher, void *key, MLX5_SET(fte_match_set_misc, misc_v, gre_s_present, gre_crks_rsvd0_ver_v.s_present & gre_crks_rsvd0_ver_m.s_present); - protocol_m = rte_be_to_cpu_16(gre_m->protocol); - protocol_v = rte_be_to_cpu_16(gre_v->protocol); + protocol_m = rte_be_to_cpu_16(gre_m->hdr.proto); + protocol_v = rte_be_to_cpu_16(gre_v->hdr.proto); if (!protocol_m) { /* Force next protocol to prevent matchers duplication */ protocol_v = mlx5_translate_tunnel_etypes(pattern_flags); @@ -9101,8 +9101,8 @@ flow_dv_translate_item_gre_option(void *matcher, void *key, if (!gre_m) gre_m = &rte_flow_item_gre_mask; } - protocol_v = gre_v->protocol; - protocol_m = gre_m->protocol; + protocol_v = gre_v->hdr.proto; + protocol_m = gre_m->hdr.proto; if (!protocol_m) { /* Force next protocol to prevent matchers duplication */ uint16_t ether_type = @@ -9112,8 +9112,8 @@ flow_dv_translate_item_gre_option(void *matcher, void *key, protocol_m = UINT16_MAX; } } - c_rsvd0_ver_v = gre_v->c_rsvd0_ver; - c_rsvd0_ver_m = gre_m->c_rsvd0_ver; + c_rsvd0_ver_v = *(const uint16_t*)&gre_v->hdr; + c_rsvd0_ver_m = *(const uint16_t*)&gre_m->hdr; if (option_m->sequence.sequence) { c_rsvd0_ver_v |= RTE_BE16(0x1000); c_rsvd0_ver_m |= RTE_BE16(0x1000); @@ -9183,12 +9183,14 @@ flow_dv_translate_item_nvgre(void *matcher, void *key, /* For NVGRE, GRE header fields must be set with defined values. */ const struct rte_flow_item_gre gre_spec = { - .c_rsvd0_ver = RTE_BE16(0x2000), - .protocol = RTE_BE16(RTE_ETHER_TYPE_TEB) + .hdr.k = 1, + .hdr.proto = RTE_BE16(RTE_ETHER_TYPE_TEB) }; const struct rte_flow_item_gre gre_mask = { - .c_rsvd0_ver = RTE_BE16(0xB000), - .protocol = RTE_BE16(UINT16_MAX), + .hdr.c = 1, + .hdr.k = 1, + .hdr.s = 1, + .hdr.proto = RTE_BE16(UINT16_MAX), }; const struct rte_flow_item gre_item = { .spec = &gre_spec, diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c index facab1b313..46f961cbb2 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -959,10 +959,10 @@ flow_verbs_translate_item_gre(struct mlx5_flow *dev_flow, if (!mask) mask = &rte_flow_item_gre_mask; } - tunnel.val.c_ks_res0_ver = spec->c_rsvd0_ver; - tunnel.val.protocol = spec->protocol; - tunnel.mask.c_ks_res0_ver = mask->c_rsvd0_ver; - tunnel.mask.protocol = mask->protocol; + tunnel.val.c_ks_res0_ver = *(const uint16_t*)&spec->hdr; + tunnel.val.protocol = spec->hdr.proto; + tunnel.mask.c_ks_res0_ver = *(const uint16_t*)&mask->hdr; + tunnel.mask.protocol = mask->hdr.proto; /* Remove unwanted bits from values. */ tunnel.val.c_ks_res0_ver &= tunnel.mask.c_ks_res0_ver; tunnel.val.key &= tunnel.mask.key; diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 6045a352ae..fd9be56e31 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -1069,19 +1069,29 @@ static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = { * * Matches a GRE header. */ +RTE_STD_C11 struct rte_flow_item_gre { - /** - * Checksum (1b), reserved 0 (12b), version (3b). - * Refer to RFC 2784. - */ - rte_be16_t c_rsvd0_ver; - rte_be16_t protocol; /**< Protocol type. */ + union { + struct { + /* + * These are old fields kept for compatibility. + * Please prefer hdr field below. + */ + /** + * Checksum (1b), reserved 0 (12b), version (3b). + * Refer to RFC 2784. + */ + rte_be16_t c_rsvd0_ver; + rte_be16_t protocol; /**< Protocol type. */ + }; + struct rte_gre_hdr hdr; /**< GRE header definition. */ + }; }; /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */ #ifndef __cplusplus static const struct rte_flow_item_gre rte_flow_item_gre_mask = { - .protocol = RTE_BE16(0xffff), + .hdr.proto = RTE_BE16(UINT16_MAX), }; #endif -- 2.36.1