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 5A6E1A034F; Tue, 1 Mar 2022 11:27:19 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2B28540DF6; Tue, 1 Mar 2022 11:27:19 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2046.outbound.protection.outlook.com [40.107.243.46]) by mails.dpdk.org (Postfix) with ESMTP id D8EC1407FF; Tue, 1 Mar 2022 11:27:17 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gVQc/anSKywg7ebxC1w4VeCObWNJNTXtk+dvZkSSJWc2DVwdoIhILxO9hW9scD5/NG3PYU/7biRujv1NnEJ720Z94jteDQtXmSf9EHi4PYmfOFvgZd4QeXmhprSUjp0uwemEW9vBgkRJaiR7MIXsPIR8nxZRY2MQHFCT+7jKK546P2nBVpeBPBWTXos0FQPINHFhMs3uB7WOrayIGlPuMklcHRCmbrT6GuTCl+tDo0lQ0Irh5TLLoO24AC4xMLGfuKVRsJtjoLbgjTBNNKgjgQ0fGh7c7SyhXR2zMkIpT8VJVyorP5ZOh/NuOUYxG7dt+inbUO6gfN4hbUu+oMJ9iA== 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=llqxMoY3KwR9vnD02FApaMhcfPv3a50LL6iOF2K9O5c=; b=IkWcb6Ir4ts4LZ3gD3m4m4rP5r6PssQCibTcxxCOttj6yapgsTUsINlbVEqMMdYOcCpeAl/6bJ16pk3f4bVNInj39/4y6kzl4iTIZlya6xu7iwQ9TcXc6BXvieJgswewxlNW3zXUoY66egl6jkVTzVP0hwAKqkwXmMKO2EVGr9NidYcRGrpuBZ4XS62kvxDtwlpF8v4ejb6banOezgT5fVluHBJGWJeLOs3fB2E+9WiEVbueHXOjt6+NkLRP9/JhRR1DckNX1sa0DK4AyDO9FLugEUntFlzrmGtoo0/j/bjkylE0+9sprk3Vm1y4zTG4ADY9AEJpAIBGGXvCB8cdJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=llqxMoY3KwR9vnD02FApaMhcfPv3a50LL6iOF2K9O5c=; b=GupR7RvmimMmU8yo57IFuf0u+RlRebyIKEKFV8pprdJTJOR1VdX9lJ97DBrLFZo2Hv2MfNXmQtIVMFmtQO/bOqkcfQrr5JKgpT4m7Z38BQ7OWJbu6Kg5X/Q+Cay4vfmYv/DHq4RFPqk3SsFiIwh7lErazzoVOxBuE9lXCIqgX9w1Q0M9+xdfPS2lXHCh41mMKLWP85P+cLvglWRjhcVuJFxcZhwFtwcSD6UZXEjwl8dm95SE0GPwM22mZT9MbJXhjBd2iQqARVBWddW6vuhKpjYKIBjm1oKJuDYn7JEAUwkt4Ugzqan+MD5TK4q+C+fyTJdxZDdab7aeYpPyBGHRyw== Received: from DM5PR12CA0008.namprd12.prod.outlook.com (2603:10b6:4:1::18) by BY5PR12MB5526.namprd12.prod.outlook.com (2603:10b6:a03:1d7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.24; Tue, 1 Mar 2022 10:27:15 +0000 Received: from DM6NAM11FT017.eop-nam11.prod.protection.outlook.com (2603:10b6:4:1:cafe::21) by DM5PR12CA0008.outlook.office365.com (2603:10b6:4:1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22 via Frontend Transport; Tue, 1 Mar 2022 10:27:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by DM6NAM11FT017.mail.protection.outlook.com (10.13.172.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5017.22 via Frontend Transport; Tue, 1 Mar 2022 10:27:14 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 1 Mar 2022 10:27:10 +0000 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Tue, 1 Mar 2022 02:27:08 -0800 From: Dariusz Sosnowski To: Matan Azrad , Viacheslav Ovsiienko , Gregory Etelson CC: , Subject: [PATCH] net/mlx5: fix MPLS/GRE Verbs spec ordering Date: Tue, 1 Mar 2022 10:26:17 +0000 Message-ID: <20220301102617.273824-1-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1e41036a-04f3-41f1-2ba4-08d9fb6e0dd5 X-MS-TrafficTypeDiagnostic: BY5PR12MB5526:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Rlz4Qfs/0N/PcCOgXqEB3h7yccuGUJxV6AfnvAdAdZqCEqGZWWi6tcSgEaRLtf5KMAtMXmNr++0QsgUfg01wVpy2PuNsArTAn4Aa2fLCNo72gIjwIU/qho9NMrESlFSUcnWMAqH+7nk+SmU8bOBHA1O3oxCfuAlSIU+/q7uwWD7ZiEX14WpOvzByiFf+jmWdDW0EM0wtF7RptQBwJdabq8H3xXQzinfCkYxx+zbhwY5iESDlDQsLfGJmtcvuV6k78kWZBvrKesyKmYYkFUNjGH08oYiaD+jIkZ3vuJRoFReo10ajM1O5s/hHtfJfTGCYbfPl78y6IgPfvBF5qgjbBozMdk+AOMoNz6Nd7XST3p9LP7DfsCxP0wLh/tTqXoy6FGjf/Y62Bulsc49sftdhPoWt3q+mTCNZ3a4bo0xxRP/lLTqR6LNwYRHfC2xbQ7oaEzUc0hrgpda3KKzAbP/m0SGRvipK/5Kh6aBXrTGzpvdjMR/U8tatBzZAeFQ+iONoytdsdShHTg/o8lTI55/vRbJKd9wCCr2qi9TU4Vvcxm8O/wOD9sw6qkCoEbgYW1PJbkO3nmIJ6DRC6+YFoztIFruz4CuQqmI0Ud14rS9C1zcKTe5DWnD6FGi2WF2eF0Vzvz2YCAXONsVIvO9Rvybb1rgl9H52CuTFQMrkzaIQkTvwhw+vWY3ppswveJtIXfLzsTcj7ws9H4BEubZbkz3N2A== X-Forefront-Antispam-Report: CIP:12.22.5.238; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(16526019)(47076005)(36860700001)(336012)(186003)(26005)(70206006)(6286002)(6666004)(7696005)(2616005)(426003)(508600001)(6636002)(110136005)(54906003)(83380400001)(1076003)(55016003)(5660300002)(8936002)(70586007)(356005)(81166007)(450100002)(4326008)(2906002)(316002)(36756003)(82310400004)(86362001)(8676002)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2022 10:27:14.5590 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1e41036a-04f3-41f1-2ba4-08d9fb6e0dd5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.238]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT017.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB5526 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 When using Verbs flow engine to create flows, GRE Verbs spec was put at the end of specs list. This created problems for flows matching MPLSoGRE packets. In generated specs list MPLS spec was put before GRE spec, but Verbs API requires that MPLS spec must be put in its exact location in protocol stack. This patch fixes this behavior. Space for GRE Verbs spec is reserved at its exact location. MPLS Verbs is inserted at its exact location as well. GRE spec is filled after all flow items are parsed. Fixes: 985b479267aa ("net/mlx5: fix GRE protocol type translation for Verbs") Cc: getelson@nvidia.com Cc: stable@dpdk.org Signed-off-by: Dariusz Sosnowski Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_verbs.c | 48 +++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c index f08aa7a770..ad960b193a 100644 --- a/drivers/net/mlx5/mlx5_flow_verbs.c +++ b/drivers/net/mlx5/mlx5_flow_verbs.c @@ -882,13 +882,48 @@ flow_verbs_item_gre_ip_protocol_update(struct ibv_flow_attr *attr, } } +/** + * Reserve space for GRE spec in spec buffer. + * + * @param[in,out] dev_flow + * Pointer to dev_flow structure. + * + * @return + * Pointer to reserved space in spec buffer. + */ +static uint8_t * +flow_verbs_reserve_gre(struct mlx5_flow *dev_flow) +{ + uint8_t *buffer; + struct mlx5_flow_verbs_workspace *verbs = &dev_flow->verbs; +#ifndef HAVE_IBV_DEVICE_MPLS_SUPPORT + unsigned int size = sizeof(struct ibv_flow_spec_tunnel); + struct ibv_flow_spec_tunnel tunnel = { + .type = IBV_FLOW_SPEC_VXLAN_TUNNEL, + .size = size, + }; +#else + unsigned int size = sizeof(struct ibv_flow_spec_gre); + struct ibv_flow_spec_gre tunnel = { + .type = IBV_FLOW_SPEC_GRE, + .size = size, + }; +#endif + + buffer = verbs->specs + verbs->size; + flow_verbs_spec_add(verbs, &tunnel, size); + return buffer; +} + /** * Convert the @p item into a Verbs specification. This function assumes that - * the input is valid and that there is space to insert the requested item - * into the flow. + * the input is valid and that Verbs specification will be placed in + * the pre-reserved space. * * @param[in, out] dev_flow * Pointer to dev_flow structure. + * @param[in, out] gre_spec + * Pointer to space reserved for GRE spec. * @param[in] item * Item specification. * @param[in] item_flags @@ -896,6 +931,7 @@ flow_verbs_item_gre_ip_protocol_update(struct ibv_flow_attr *attr, */ static void flow_verbs_translate_item_gre(struct mlx5_flow *dev_flow, + uint8_t *gre_spec, const struct rte_flow_item *item __rte_unused, uint64_t item_flags) { @@ -949,7 +985,8 @@ flow_verbs_translate_item_gre(struct mlx5_flow *dev_flow, flow_verbs_item_gre_ip_protocol_update(&verbs->attr, IBV_FLOW_SPEC_IPV6, IPPROTO_GRE); - flow_verbs_spec_add(verbs, &tunnel, size); + MLX5_ASSERT(gre_spec); + memcpy(gre_spec, &tunnel, size); } /** @@ -1679,6 +1716,7 @@ flow_verbs_translate(struct rte_eth_dev *dev, struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_flow_workspace *wks = mlx5_flow_get_thread_workspace(); struct mlx5_flow_rss_desc *rss_desc; + uint8_t *gre_spec = NULL; MLX5_ASSERT(wks); rss_desc = &wks->rss_desc; @@ -1816,6 +1854,7 @@ flow_verbs_translate(struct rte_eth_dev *dev, item_flags |= MLX5_FLOW_LAYER_VXLAN_GPE; break; case RTE_FLOW_ITEM_TYPE_GRE: + gre_spec = flow_verbs_reserve_gre(dev_flow); subpriority = MLX5_TUNNEL_PRIO_GET(rss_desc); item_flags |= MLX5_FLOW_LAYER_GRE; break; @@ -1832,7 +1871,8 @@ flow_verbs_translate(struct rte_eth_dev *dev, } } if (item_flags & MLX5_FLOW_LAYER_GRE) - flow_verbs_translate_item_gre(dev_flow, items, item_flags); + flow_verbs_translate_item_gre(dev_flow, gre_spec, + items, item_flags); dev_flow->handle->layers = item_flags; /* Other members of attr will be ignored. */ dev_flow->verbs.attr.priority = -- 2.25.1