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 01AA042493; Thu, 26 Jan 2023 17:19:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7040442D89; Thu, 26 Jan 2023 17:19:34 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by mails.dpdk.org (Postfix) with ESMTP id 4873E42BFE for ; Thu, 26 Jan 2023 17:19:33 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P3Q+1oUqjsRQ1PxDfQbwPnqX5mXED8vgtmOTQgbU4EvNQqaQvsES5GAxmGmpNETP1gUYyPADLCKPWmzeEezbGKGFr10eyyziSFrHyxnCL4yeZCA6k3Kk+8TZ1V1PUXcmpUD/g0XfBwDaU+w8dkeR+EhzGCtmEt79AMb/f5/L8Ob1Qn1j3uYqBI0346sksXv8PsQRAQ42yf5Q+wo0qYg/QUenJmNTfsZ5IyCLzItnjBV4sVL7QaXTeIflg7M9W23TCZzs4z644jMMhxpH9u7BRK7KBgpFgtsV5wWHHon9bamBeEUx8+K6SEOOtKhf8joMvwcVp9QQ5Pd8wcBDJEbxoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Pam9KBk+D2W18XaRbhMHTffKE+s23InSl/V5IsRDkqU=; b=DtT2x3EF4cARXnTKixheF/quW0XYDbWoQRGK/GLfzT1U83ywWIW7/C/X3lP0BaerL1xt7BMXrxp24oM20EQ8/7PHnkYbV/jEXfKaby5deeREigmd1Ykbi0D/lGoVgn0ccy0DlLJlr/SKJTieE+6MnAOdeqnvlwr5cVnwbeEvWyjyfpYBFnbX0J8sZuPBgRmO4caDZHJdlQ06z5H7qQ4b+CQJRxpmluIEvcPOGeGOHHQUik3CF705giJ8mQl/gWzi5xxBh5goJLvoT0aSmZmJkQjVIlb/t15+ZsHMgCGe+rArV8f3wYiToQJRBckeafW+phHq1mKe/77sXUPp/mcMcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=monjalon.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Pam9KBk+D2W18XaRbhMHTffKE+s23InSl/V5IsRDkqU=; b=F9yY3gQetZPIykGX1zn7EVFWDb1Xr7mN98dY5G3yhhFcsPwUkS3F8epOxdcU88h1vTens99i3oMmajO2fboH8j1PnUdnmqzwcjeDcEiWVxOohqf6pDiLYzlzhd0YgWVTcBmZC3UH2be5vjGAf903tVGEawnQsqgqJMouWU8NML0= Received: from BN9PR03CA0242.namprd03.prod.outlook.com (2603:10b6:408:ff::7) by SJ2PR12MB7822.namprd12.prod.outlook.com (2603:10b6:a03:4ca::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21; Thu, 26 Jan 2023 16:19:30 +0000 Received: from BN8NAM11FT096.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ff:cafe::9b) by BN9PR03CA0242.outlook.office365.com (2603:10b6:408:ff::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Thu, 26 Jan 2023 16:19:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT096.mail.protection.outlook.com (10.13.177.195) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6023.16 via Frontend Transport; Thu, 26 Jan 2023 16:19:29 +0000 Received: from telcodpdk.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 26 Jan 2023 10:19:27 -0600 From: Ferruh Yigit To: Thomas Monjalon , Wisam Jaddo , Ori Kam , Aman Singh , Yuying Zhang , Ajit Khaparde , Somnath Kotur , Hemant Agrawal , Sachin Saxena , Matan Azrad , Viacheslav Ovsiienko , Chaoyong He , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Andrew Rybchenko , Olivier Matz CC: David Marchand , Subject: [PATCH v5 4/8] ethdev: use GRE protocol struct for flow matching Date: Thu, 26 Jan 2023 16:19:00 +0000 Message-ID: <20230126161904.864517-5-ferruh.yigit@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230126161904.864517-1-ferruh.yigit@amd.com> References: <20221025214410.715864-1-thomas@monjalon.net> <20230126161904.864517-1-ferruh.yigit@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT096:EE_|SJ2PR12MB7822:EE_ X-MS-Office365-Filtering-Correlation-Id: ba80b4be-c9b9-41cc-cd95-08daffb91a19 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WpW2ZoaCVbCWFGNpiNcE/Ui5on06allTVvxdm7g/eRHb+IhhJFyiqcvJlH4gswjVzGsuhiUw5ZAHOyGqB2JtJy7AicTSqvLiP15SauKl18bMax2DLg3YJrajivnY/BzUpQS7GSVO0N/V04sqjLaZ/e1MhQ6wVR4HL9UANMvAtPV9kU8fFwOM9JNlMnAli2nPIXKC0itTKcwZaupxw/+NX3mCd8xMlMBoL0dxYRVSuRcpdZWm24o8oP1eOZiRpWRx2/T1kosXIqK5qwPSvzsRGesEcwAdHagGTG6qmpl1SDAVBE3qAo/oAi6j/uv5n1U424mWmTebpL+nDv2Qw2EN9sAQElKkqzvPWyMJttknVaEvWKMYcEVoQqjCyvs+uqjGLpVsySLRB1bgy67zGRjO9GKB2ptP4KINq5Q3emRc6YLRbXJXS9qBjNxfIw+kSCtNaePSB3yNtw+em4HKQnSLzEGdMdsYk4wp4XIrEU+jQMCPVVJAE2kQ6tBu6v/ZdFaZE3VVXEiyH2+49aOrvx0yYk4KbtzmaLmL0rNlVe9tgFvSm9o8C6Rjf9Whc8d98j2kOqPazai/9kQq00nmumFCFV1cGeviZi1Ssbii2OkfeihBaNT+iat8/vvbf/5Y0bF7P1A7CWWRdHd0IZx0O0n1F187KYVq67OKubibr9UEaiMG9zyVS/pVTXEuZfUmGPqHibnsKDAWFVJSuECEeLL/HANT4z8XyD8/cyDUMmljC8++roRp0GyEXgbfxH6OXFSp X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230025)(4636009)(346002)(136003)(376002)(396003)(39860400002)(451199018)(46966006)(40470700004)(36840700001)(110136005)(6666004)(478600001)(54906003)(70586007)(7696005)(316002)(82310400005)(36756003)(70206006)(40460700003)(86362001)(336012)(41300700001)(26005)(186003)(16526019)(921005)(2616005)(426003)(47076005)(356005)(7416002)(5660300002)(1076003)(8676002)(4326008)(2906002)(83380400001)(44832011)(81166007)(36860700001)(40480700001)(30864003)(8936002)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2023 16:19:29.7809 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ba80b4be-c9b9-41cc-cd95-08daffb91a19 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT096.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7822 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 From: Thomas Monjalon 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 | 14 +++++------ 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/hws/mlx5dr_definer.c | 8 +++---- drivers/net/mlx5/mlx5_flow.c | 22 ++++++++--------- drivers/net/mlx5/mlx5_flow_dv.c | 30 +++++++++++++----------- drivers/net/mlx5/mlx5_flow_verbs.c | 10 ++++---- drivers/net/nfp/nfp_flow.c | 9 +++---- lib/ethdev/rte_flow.h | 24 +++++++++++++------ lib/net/rte_gre.h | 5 ++++ 13 files changed, 84 insertions(+), 73 deletions(-) diff --git a/app/test-flow-perf/items_gen.c b/app/test-flow-perf/items_gen.c index a58245239ba1..0f19e5e53648 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 b904f8c3d45c..0e115956514c 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -4071,7 +4071,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", @@ -4082,7 +4082,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, - c_rsvd0_ver)), + hdr.c_rsvd0_ver)), }, [ITEM_GRE_C_BIT] = { .name = "c_bit", @@ -4090,7 +4090,7 @@ static const struct token token_list[] = { .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param), .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre, - c_rsvd0_ver, + hdr.c_rsvd0_ver, "\x80\x00\x00\x00")), }, [ITEM_GRE_S_BIT] = { @@ -4098,7 +4098,7 @@ static const struct token token_list[] = { .help = "sequence number bit (S)", .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param), .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre, - c_rsvd0_ver, + hdr.c_rsvd0_ver, "\x10\x00\x00\x00")), }, [ITEM_GRE_K_BIT] = { @@ -4106,7 +4106,7 @@ static const struct token token_list[] = { .help = "key bit (K)", .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param), .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre, - c_rsvd0_ver, + hdr.c_rsvd0_ver, "\x20\x00\x00\x00")), }, [ITEM_FUZZY] = { @@ -7837,7 +7837,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, @@ -7935,7 +7935,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 116722351486..603e1b866be3 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 638051789d19..80bf7209065a 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -68,7 +68,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 80869b79c3fe..c1e231ce8c49 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -1461,16 +1461,16 @@ 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.c_rsvd0_ver); 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_deference_struct(gre_spec, hdr.c_rsvd0_ver), + ulp_deference_struct(gre_mask, hdr.c_rsvd0_ver), ULP_PRSR_ACT_DEFAULT); - size = sizeof(((struct rte_flow_item_gre *)NULL)->protocol); + size = sizeof(((struct rte_flow_item_gre *)NULL)->hdr.proto); 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 eec7e6065097..8a6d44da4875 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/hws/mlx5dr_definer.c b/drivers/net/mlx5/hws/mlx5dr_definer.c index 604384a24253..3a438f2c9d12 100644 --- a/drivers/net/mlx5/hws/mlx5dr_definer.c +++ b/drivers/net/mlx5/hws/mlx5dr_definer.c @@ -156,8 +156,8 @@ struct mlx5dr_definer_conv_data { X(SET, source_qp, v->queue, mlx5_rte_flow_item_sq) \ X(SET, tag, v->data, rte_flow_item_tag) \ X(SET, metadata, v->data, rte_flow_item_meta) \ - X(SET_BE16, gre_c_ver, v->c_rsvd0_ver, rte_flow_item_gre) \ - X(SET_BE16, gre_protocol_type, v->protocol, rte_flow_item_gre) \ + X(SET_BE16, gre_c_ver, v->hdr.c_rsvd0_ver, rte_flow_item_gre) \ + X(SET_BE16, gre_protocol_type, v->hdr.proto, rte_flow_item_gre) \ X(SET, ipv4_protocol_gre, IPPROTO_GRE, rte_flow_item_gre) \ X(SET_BE32, gre_opt_key, v->key.key, rte_flow_item_gre_opt) \ X(SET_BE32, gre_opt_seq, v->sequence.sequence, rte_flow_item_gre_opt) \ @@ -1210,7 +1210,7 @@ mlx5dr_definer_conv_item_gre(struct mlx5dr_definer_conv_data *cd, if (!m) return 0; - if (m->c_rsvd0_ver) { + if (m->hdr.c_rsvd0_ver) { fc = &cd->fc[MLX5DR_DEFINER_FNAME_GRE_C_VER]; fc->item_idx = item_idx; fc->tag_set = &mlx5dr_definer_gre_c_ver_set; @@ -1219,7 +1219,7 @@ mlx5dr_definer_conv_item_gre(struct mlx5dr_definer_conv_data *cd, fc->bit_off = __mlx5_dw_bit_off(header_gre, c_rsvd0_ver); } - if (m->protocol) { + if (m->hdr.proto) { fc = &cd->fc[MLX5DR_DEFINER_FNAME_GRE_PROTOCOL]; fc->item_idx = item_idx; fc->tag_set = &mlx5dr_definer_gre_protocol_type_set; diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index ff08a629e2c6..7b19c5f03f5d 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -329,7 +329,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: @@ -3089,8 +3089,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"); @@ -3165,21 +3164,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, @@ -3230,8 +3226,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) @@ -3259,7 +3257,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 261c60a5c33a..2b9c2ba6a4b5 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -8984,7 +8984,7 @@ static void flow_dv_translate_item_gre(void *key, const struct rte_flow_item *item, uint64_t pattern_flags, uint32_t key_type) { - static const struct rte_flow_item_gre empty_gre = {0,}; + static const struct rte_flow_item_gre empty_gre = {{{0}}}; const struct rte_flow_item_gre *gre_m = item->mask; const struct rte_flow_item_gre *gre_v = item->spec; void *headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers); @@ -9021,8 +9021,8 @@ flow_dv_translate_item_gre(void *key, const struct rte_flow_item *item, gre_v = gre_m; else if (key_type == MLX5_SET_MATCHER_HS_V) gre_m = gre_v; - 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(gre_m->hdr.c_rsvd0_ver); + gre_crks_rsvd0_ver_v.value = rte_be_to_cpu_16(gre_v->hdr.c_rsvd0_ver); MLX5_SET(fte_match_set_misc, misc_v, gre_c_present, gre_crks_rsvd0_ver_v.c_present & gre_crks_rsvd0_ver_m.c_present); @@ -9032,8 +9032,8 @@ flow_dv_translate_item_gre(void *key, const struct rte_flow_item *item, 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); @@ -9072,7 +9072,7 @@ flow_dv_translate_item_gre_option(void *key, const struct rte_flow_item_gre_opt *option_v = item->spec; const struct rte_flow_item_gre *gre_m = gre_item->mask; const struct rte_flow_item_gre *gre_v = gre_item->spec; - static const struct rte_flow_item_gre empty_gre = {0}; + static const struct rte_flow_item_gre empty_gre = {{{0}}}; struct rte_flow_item gre_key_item; uint16_t c_rsvd0_ver_m, c_rsvd0_ver_v; uint16_t protocol_m, protocol_v; @@ -9097,8 +9097,8 @@ flow_dv_translate_item_gre_option(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 = @@ -9108,8 +9108,8 @@ flow_dv_translate_item_gre_option(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 = gre_v->hdr.c_rsvd0_ver; + c_rsvd0_ver_m = gre_m->hdr.c_rsvd0_ver; if (option_m->sequence.sequence) { c_rsvd0_ver_v |= RTE_BE16(0x1000); c_rsvd0_ver_m |= RTE_BE16(0x1000); @@ -9171,12 +9171,14 @@ flow_dv_translate_item_nvgre(void *key, const struct rte_flow_item *item, /* 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 4ef4f3044515..291369d437d4 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -930,7 +930,7 @@ flow_verbs_translate_item_gre(struct mlx5_flow *dev_flow, .size = size, }; #else - static const struct rte_flow_item_gre empty_gre = {0,}; + static const struct rte_flow_item_gre empty_gre = {{{0}}}; const struct rte_flow_item_gre *spec = item->spec; const struct rte_flow_item_gre *mask = item->mask; unsigned int size = sizeof(struct ibv_flow_spec_gre); @@ -946,10 +946,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 = spec->hdr.c_rsvd0_ver; + tunnel.val.protocol = spec->hdr.proto; + tunnel.mask.c_ks_res0_ver = mask->hdr.c_rsvd0_ver; + 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/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c index bd3a8d2a3b2f..0994fdeeb49f 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -1812,8 +1812,9 @@ static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = { [RTE_FLOW_ITEM_TYPE_GRE] = { .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_GRE_KEY), .mask_support = &(const struct rte_flow_item_gre){ - .c_rsvd0_ver = RTE_BE16(0xa000), - .protocol = RTE_BE16(0xffff), + .hdr.c = 1, + .hdr.k = 1, + .hdr.proto = RTE_BE16(0xffff), }, .mask_default = &rte_flow_item_gre_mask, .mask_sz = sizeof(struct rte_flow_item_gre), @@ -3144,7 +3145,7 @@ nfp_flow_action_nvgre_encap_v4(struct nfp_app_fw_flower *app_fw_flower, memset(set_tun, 0, act_set_size); nfp_flow_set_tun_process(set_tun, NFP_FL_TUN_GRE, 0, ipv4->hdr.time_to_live, ipv4->hdr.type_of_service); - set_tun->tun_proto = gre->protocol; + set_tun->tun_proto = gre->hdr.proto; /* Send the tunnel neighbor cmsg to fw */ return nfp_flower_add_tun_neigh_v4_encap(app_fw_flower, nfp_flow_meta, @@ -3181,7 +3182,7 @@ nfp_flow_action_nvgre_encap_v6(struct nfp_app_fw_flower *app_fw_flower, tos = (ipv6->hdr.vtc_flow >> RTE_IPV6_HDR_TC_SHIFT) & 0xff; nfp_flow_set_tun_process(set_tun, NFP_FL_TUN_GRE, 0, ipv6->hdr.hop_limits, tos); - set_tun->tun_proto = gre->protocol; + set_tun->tun_proto = gre->hdr.proto; /* Send the tunnel neighbor cmsg to fw */ return nfp_flower_add_tun_neigh_v6_encap(app_fw_flower, nfp_flow_meta, diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index e2364823d622..3ae89e367c16 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -1070,19 +1070,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 diff --git a/lib/net/rte_gre.h b/lib/net/rte_gre.h index 6c6aef6fcaa0..210b81c99018 100644 --- a/lib/net/rte_gre.h +++ b/lib/net/rte_gre.h @@ -28,6 +28,8 @@ extern "C" { */ __extension__ struct rte_gre_hdr { + union { + struct { #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN uint16_t res2:4; /**< Reserved */ uint16_t s:1; /**< Sequence Number Present bit */ @@ -45,6 +47,9 @@ struct rte_gre_hdr { uint16_t res3:5; /**< Reserved */ uint16_t ver:3; /**< Version Number */ #endif + }; + rte_be16_t c_rsvd0_ver; + }; uint16_t proto; /**< Protocol Type */ } __rte_packed; -- 2.25.1