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 6B0DDA0C53 for ; Wed, 3 Nov 2021 09:56:15 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 38A3140E5A; Wed, 3 Nov 2021 09:56:15 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2044.outbound.protection.outlook.com [40.107.223.44]) by mails.dpdk.org (Postfix) with ESMTP id 9552940E5A; Wed, 3 Nov 2021 09:56:13 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bDqrlAKEdbsPQCUhYtE6dXgp/TiqGSyvy67l5Q3ZWI7lk+lelSsmvP238ayXNOTF7+IrngM5mByX5lhuTZvITDOTMcJvY7/uGduXlfwsPU3x6RyAt3xHqXDsc8D8Q0OlsNi2Wt742ZaWJy/0+7w6j+iHaalKlwtLM2LhMmvYXZnJYzlkLP0iZimBLOcc5T4l0J3J3HcoydmRDzo46PNlcbIcpFLnJJSTSUSG7yLIQupliBDta32dYSJ6MKRvzhEfek4q5NLFG0FYfH8uVoDW8afydSYdAfw3Gz7pLrvrQZ/esIBFNwjZj5f+MNjeldw6K0Yi65uP2MBw1aAX02CyAw== 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=xlZz2y9TXCV4EXB2aoZCtv7DEBBnNla+F/ANmrMlpdE=; b=jupjm+iKqKMe1rTW9exHmvbDwCAybRV+6TDMlxABwmhoeFx9lmU2Z5MzH42PL8MruyADJX38oFurlZJVsGCWnZcYoLIFdsocWJrPrY9nBjx7kf+Et9040YxXmH+Pl9Q3b092q8ghWu21UIfJmC3GzkSn9uF4cgI9obDnwGmq1JskLUjnIPT2++TZdGzeBXe87vqC2E6ob2SSiivs1j/N3CDegX16jeHrVNWAOISBvM7kx3QSYphRagut6G1wNd/x6ZEZhSw3LXM9cOM/Qy5wHWtwwb0c5k9UrPvsP+y0ISsJAFfQ5LK4pF/fYkATsGi20XOYMUMoPrB4o8KC21ejmQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine 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=xlZz2y9TXCV4EXB2aoZCtv7DEBBnNla+F/ANmrMlpdE=; b=TY2F0QDv2Fyhj32zqeVPPpUk4TkkXCmb0eO9pYMcP3JpdKO0kowLcdybi9fxDhH6w6pvCYBtUnJR5vIAojedtBTQtfw3MVTcXto8O1m0P6tdfjANcmd8lGV2j9oAE9H9wR7P6EuFE+CMUbeKCYch96UoJBExW7f5v6vPoqDLoTHkZlwG+ObvXofdCnU5KbMXAACRt7JiYDihQvFphIm8IoaxHQMZQw5SXlOSyI51IfamPJo4dVz7uk5D3C1IOMzLvn5f7zDAowYqZt94fX5+CXggz/E4ZBpP8MWrv3VCLadnvS5PpU0qRDvd11w4PT0s6Bsbwk9LIKtBOcGuTBndbA== Received: from DM6PR02CA0097.namprd02.prod.outlook.com (2603:10b6:5:1f4::38) by CH2PR12MB4293.namprd12.prod.outlook.com (2603:10b6:610:7e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.14; Wed, 3 Nov 2021 08:56:12 +0000 Received: from DM6NAM11FT068.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1f4:cafe::ae) by DM6PR02CA0097.outlook.office365.com (2603:10b6:5:1f4::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Wed, 3 Nov 2021 08:56:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT068.mail.protection.outlook.com (10.13.173.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4669.10 via Frontend Transport; Wed, 3 Nov 2021 08:56:11 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 3 Nov 2021 08:56:09 +0000 From: Gregory Etelson To: , CC: , , , "Viacheslav Ovsiienko" Date: Wed, 3 Nov 2021 10:55:56 +0200 Message-ID: <20211103085556.25214-1-getelson@nvidia.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2b170eda-398b-443d-704d-08d99ea7c913 X-MS-TrafficTypeDiagnostic: CH2PR12MB4293: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2043; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7G0V9yoQIiBhtoxUUjE8rJ9ohASluDlGY/aHo47j4rmEXixHSkzP2S7lR9XmY7EROacleEuRXbLBYLfFPwcEtxvAi3v+PMPIw/ARXnO2J25TPv/9M9EqdP6qS+gsEIlWsCGMsniVjXZViqas28JZG1GOCuFxyl+v2me8Y4/U5USuh+oBuMBB5e/akGKd9KL4l81YMeAgtuygG1LXqnYgRMYMG883/kLS4eqflLekszI1ugyc2OKSAd1dnuncqPapt7PPeKjIDtQqiRjfPjbq5cqR7mqWykvKitbPFb8FIHeVI2HG7aGvf4MvjvQuCW3GSkBD0i9jHtLfTD/qx0VCHFYn1lfJJLdmrk1uMeuUQBVlZH9z2VTB9YoEjc23QeQWL9gY7Vb74SsWC66XeUCKUbAVvhF9w0FMB1LIq1f39cpUrqoFQ3bjlNIvEIPh0JVc80e9qnZkTGmnWiOeeAmftXe2ejnKEONdpOW2yaaSYquzPnF3QYbaS1x4c/4oQkpSB/dRQzk080LQCAWLvv15wrwpcaqNgkrDnjhzlvVm3nRixuV+exxkdZvHN8qTWzV1zkEcF2GdyfLjnnOnmnRhWlFyXv4eHWLrujdU+QHEjobbgz4et13AJrLWQB/TQVrbvoWxC8ltpS6eCS94qP6mG+gFC3f94pKK5VuGZUslmYX/2Xs3erUR6ypoa1JOoDS7WhMdyEjgHQ1O5pYj5zTbaA== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(55016002)(26005)(2906002)(107886003)(7696005)(450100002)(6666004)(7049001)(54906003)(4326008)(508600001)(47076005)(36756003)(426003)(5660300002)(2616005)(6286002)(82310400003)(86362001)(16526019)(316002)(186003)(36906005)(336012)(8936002)(110136005)(70586007)(356005)(7636003)(36860700001)(83380400001)(70206006)(8676002)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2021 08:56:11.8497 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2b170eda-398b-443d-704d-08d99ea7c913 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT068.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4293 Subject: [dpdk-stable] [PATCH] net/mlx5: fix tunnel offload validation X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Tunnel offload API allows application to restore packet to its original form if chain of flows missed after DECAP action. MLX5 PMD provides tunnel offload support only if DV API was enabled. The patch verifies DV availability before processing with tunnel offload tasks. Cc: stable@dpdk.org Fixes: 4ec6360de37d ("net/mlx5: implement tunnel offload") Signed-off-by: Gregory Etelson Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow.c | 54 +++++++++++++++------------------ drivers/net/mlx5/mlx5_flow_dv.c | 5 +++ 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 2385a0b550..2ce424dd1b 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -9343,33 +9343,37 @@ int mlx5_alloc_tunnel_hub(struct mlx5_dev_ctx_shared *sh) return err; } -static inline bool +static inline int mlx5_flow_tunnel_validate(struct rte_eth_dev *dev, struct rte_flow_tunnel *tunnel, - const char *err_msg) + struct rte_flow_error *error) { - err_msg = NULL; - if (!is_tunnel_offload_active(dev)) { - err_msg = "tunnel offload was not activated"; - goto out; - } else if (!tunnel) { - err_msg = "no application tunnel"; - goto out; - } + struct mlx5_priv *priv = dev->data->dev_private; + if (!priv->config.dv_flow_en) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, + "flow DV interface is off"); + if (!is_tunnel_offload_active(dev)) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, + "tunnel offload was not activated"); + if (!tunnel) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, + "no application tunnel"); switch (tunnel->type) { default: - err_msg = "unsupported tunnel type"; - goto out; + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, + "unsupported tunnel type"); case RTE_FLOW_ITEM_TYPE_VXLAN: case RTE_FLOW_ITEM_TYPE_GRE: case RTE_FLOW_ITEM_TYPE_NVGRE: case RTE_FLOW_ITEM_TYPE_GENEVE: break; } - -out: - return !err_msg; + return 0; } static int @@ -9379,15 +9383,11 @@ mlx5_flow_tunnel_decap_set(struct rte_eth_dev *dev, uint32_t *num_of_actions, struct rte_flow_error *error) { - int ret; struct mlx5_flow_tunnel *tunnel; - const char *err_msg = NULL; - bool verdict = mlx5_flow_tunnel_validate(dev, app_tunnel, err_msg); + int ret = mlx5_flow_tunnel_validate(dev, app_tunnel, error); - if (!verdict) - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, - err_msg); + if (ret) + return ret; ret = mlx5_get_flow_tunnel(dev, app_tunnel, &tunnel); if (ret < 0) { return rte_flow_error_set(error, ret, @@ -9406,15 +9406,11 @@ mlx5_flow_tunnel_match(struct rte_eth_dev *dev, uint32_t *num_of_items, struct rte_flow_error *error) { - int ret; struct mlx5_flow_tunnel *tunnel; - const char *err_msg = NULL; - bool verdict = mlx5_flow_tunnel_validate(dev, app_tunnel, err_msg); + int ret = mlx5_flow_tunnel_validate(dev, app_tunnel, error); - if (!verdict) - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_HANDLE, NULL, - err_msg); + if (ret) + return ret; ret = mlx5_get_flow_tunnel(dev, app_tunnel, &tunnel); if (ret < 0) { return rte_flow_error_set(error, ret, diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 8962d26c75..21d686f3f0 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -6789,6 +6789,11 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, tunnel = is_tunnel_offload_active(dev) ? mlx5_get_tof(items, actions, &tof_rule_type) : NULL; if (tunnel) { + if (!priv->config.dv_flow_en) + return rte_flow_error_set + (error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "tunnel offload requires DV flow interface"); if (priv->representor) return rte_flow_error_set (error, ENOTSUP, -- 2.33.1