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 7521443258; Wed, 1 Nov 2023 05:45:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 42A4E40DCA; Wed, 1 Nov 2023 05:44:58 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2041.outbound.protection.outlook.com [40.107.244.41]) by mails.dpdk.org (Postfix) with ESMTP id 2882D40DCA for ; Wed, 1 Nov 2023 05:44:57 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n7+Pd1UgUnJdUTt69yJXzkvFx3i3OM8qjfUBVab6/BlDO/O66lKJetgIZoDNLW6A4NdSOJEALs9jKpkGPguFbyTRrrMddK+1ea2KHSMKuC7DEqYSBAFWP9mr0PI0qRb1rhgEPskwxMFzkTZFNcOStMEJCO9Q7FfLCzQw/UYhaEfak97Mk3RHV1/eBtq9ZcuGfpcAawQbXlqEBhPs59wvvFGqhcmquznWdJXozQpGrF4V1uAWkiDjZf3Std50yVVKqRt+HSTLQXNI4t/2RC08PmVXFMU6WX5CeA7/Ct/VSQAeNZo19U0JJL1B9mYMu+a12llrSkj/LAF6w+CjKtBcJw== 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=brq4tCnByOnYgXo6CwHngIHZsPoVg450sJo57TAoXJM=; b=EFirg5kz4NUXhlZipg+eJ/Lx94Ad5W822/Z13rL49neVk+Rk+sqWG+9kpWMbQGZtGfqL1saJKVhv66nuKdW2TMlmqClGHMVmK0jAUCLrg4Miju9ErvfGy235a6EtbRqxCsL4x1JiSCgCpCfXHtLnNfUppFEqyq8fh5bH2aJAqIBoKbxrzAVKNIJZaSG7deuVF4d5JngreFDvnJFw6camFy3ehezafDmpPwjdM5CPzMoyq5AhTxXLxsF+U3JgVU9VnapTE+Zb61Ey2q16p2RYfk+PaH45eoQH2UXojdd81Cvp9fychAt0P5hivahvtuNYM5Z7PspYXFjohkER0vD7Sw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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 (0) 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=brq4tCnByOnYgXo6CwHngIHZsPoVg450sJo57TAoXJM=; b=GfiWwYn7eBERPq7kXCzIiVtb2q8iKjL+1YdqvFfa1CWcVjGIkWuvAwUf1LsQIfPG6mbl9MmsrB302Wr95gYANVKQp8YaEbNhQx9dIZGO1VaJQs/UTKHbP9zbrOWjmjuxgJSsmUInB61sp4ocFLnkkqBKoFTa1P8nPiOhoK5nM8bYHZ+nq7ChFu3++8d0pVYh0g5e5ZXEKttpYSzz2d6p8/Sqo5qGQfTKqrobbdqLCyYGMIypG0yewVtuMtFa29fZBFDxr+GaR8U5n9x3IceP9VQCbzD4DeYBlQjAy7bK1LyBESXiuY/VRIqjpNoNzFWVS1HQgfNuzV0Rzzvn7LR4xA== Received: from CY5P221CA0068.NAMP221.PROD.OUTLOOK.COM (2603:10b6:930:4::39) by PH7PR12MB6538.namprd12.prod.outlook.com (2603:10b6:510:1f1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.26; Wed, 1 Nov 2023 04:44:52 +0000 Received: from CY4PEPF0000FCC1.namprd03.prod.outlook.com (2603:10b6:930:4:cafe::30) by CY5P221CA0068.outlook.office365.com (2603:10b6:930:4::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.29 via Frontend Transport; Wed, 1 Nov 2023 04:44:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000FCC1.mail.protection.outlook.com (10.167.242.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.19 via Frontend Transport; Wed, 1 Nov 2023 04:44:52 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 31 Oct 2023 21:44:40 -0700 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.41; Tue, 31 Oct 2023 21:44:37 -0700 From: Rongwei Liu To: , , , , , CC: Hamdan Igbaria , Alex Vesker Subject: [PATCH v4 02/13] net/mlx5/hws: support remove header action Date: Wed, 1 Nov 2023 06:44:08 +0200 Message-ID: <20231101044419.732726-3-rongweil@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231101044419.732726-1-rongweil@nvidia.com> References: <20231031105131.441078-1-rongweil@nvidia.com> <20231101044419.732726-1-rongweil@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC1:EE_|PH7PR12MB6538:EE_ X-MS-Office365-Filtering-Correlation-Id: b8bc5757-2b8e-4b57-b63d-08dbda9549a5 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pPwTJ3cWjEDkwFw7bJ+7Wc4y+OVAyYfhm5TJ77zH9gT6SnfBxrRJNgt3zL0a5TE84GQoaVrGJYBp6Gnq/ZIUPJhWT5mVYS75BsaQuVlALbV+/Up0sTcbKw+8DpDeoVfaNfuCqmit9cWq973fXCme/BtTvYjbWoWSptvfPK4H6NdeBKhZvWVjCo7mLrKTslFzUXialVrpolAXZ5fsP0JEphjIHRZlK6wRguaFe/FSoXnV27X7HvV+1cuwqe9//kH/7c+uWJPwQTvve8B3YaizF8X/nOvWZpiaMdATs9NJ3feBXqLdsRgikI1CUjg1xizYd8zFWnk9rCYT3f4UILWYQ0Ne0pQgShv+4ZspGBWYopE0s61g5qsqcipZQYl7gwIuO5wJ9MOQc6nv94jEJ6ZI8RHDwORoe/QJODlL8BafNLpC+VVkUUZdPVpcXgThtl/YkssMzOb+/VDdDMVpsEX1pX9NoscAWs9CtQ3eX5LGwgcYcAP3ZmEbge0zGUbAfiXfo6KvFZ0jM8wBb0RWU+qKauAL7D0i/8kp8PIDUCo+1fMSTIhWD7JaUyRIm+oWrd1abnH16bMeGo9dJ8KWmYpszqdx34gObmoXFiiQEwJD12H4VcWC1HKyA/x7+QPc1rpdEWcNKv7ny3bYuPX8g5fbNyHFxthc0Kos4Hxh1Oii0Uc+sJv4n/j/3WRl3zzlxSLlm/J30QZpt4fggKf9dntNzU03Lw4bcNR3u9U8Aqtlj60= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(376002)(396003)(346002)(136003)(230922051799003)(1800799009)(186009)(82310400011)(451199024)(64100799003)(46966006)(36840700001)(40470700004)(70206006)(70586007)(54906003)(8676002)(41300700001)(316002)(4326008)(110136005)(8936002)(5660300002)(40460700003)(2616005)(6666004)(107886003)(36860700001)(478600001)(83380400001)(7696005)(36756003)(2906002)(40480700001)(7636003)(26005)(55016003)(356005)(47076005)(1076003)(16526019)(82740400003)(6286002)(426003)(336012)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2023 04:44:52.2073 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b8bc5757-2b8e-4b57-b63d-08dbda9549a5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6538 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: Hamdan Igbaria Support remove header action, this action will allow the user to execute dynamic decaps by choosing to decap by providing a start anchor and number of words to remove, or providing a start anchor and end anchor. Signed-off-by: Hamdan Igbaria Reviewed-by: Alex Vesker Acked-by: Ori Kam --- drivers/net/mlx5/hws/mlx5dr.h | 40 +++++++++++++++ drivers/net/mlx5/hws/mlx5dr_action.c | 77 ++++++++++++++++++++++++++++ drivers/net/mlx5/hws/mlx5dr_action.h | 7 +++ drivers/net/mlx5/hws/mlx5dr_debug.c | 1 + 4 files changed, 125 insertions(+) diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h index f3367297c6..e21dcd72ae 100644 --- a/drivers/net/mlx5/hws/mlx5dr.h +++ b/drivers/net/mlx5/hws/mlx5dr.h @@ -46,6 +46,7 @@ enum mlx5dr_action_type { MLX5DR_ACTION_TYP_ASO_METER, MLX5DR_ACTION_TYP_ASO_CT, MLX5DR_ACTION_TYP_INSERT_HEADER, + MLX5DR_ACTION_TYP_REMOVE_HEADER, MLX5DR_ACTION_TYP_DEST_ROOT, MLX5DR_ACTION_TYP_DEST_ARRAY, MLX5DR_ACTION_TYP_MAX, @@ -184,6 +185,29 @@ struct mlx5dr_action_insert_header { bool encap; }; +enum mlx5dr_action_remove_header_type { + MLX5DR_ACTION_REMOVE_HEADER_TYPE_BY_OFFSET, + MLX5DR_ACTION_REMOVE_HEADER_TYPE_BY_HEADER, +}; + +struct mlx5dr_action_remove_header_attr { + enum mlx5dr_action_remove_header_type type; + union { + struct { + /* PRM start anchor from which header will be removed */ + uint8_t start_anchor; + /* PRM end anchor till which header will be removed */ + uint8_t end_anchor; + bool decap; + } by_anchor; + struct { + /* PRM start anchor from which header will be removed */ + uint8_t start_anchor; + uint8_t size; + } by_offset; + }; +}; + struct mlx5dr_action_mh_pattern { /* Byte size of modify actions provided by "data" */ size_t sz; @@ -727,6 +751,22 @@ mlx5dr_action_create_insert_header(struct mlx5dr_context *ctx, uint32_t log_bulk_size, uint32_t flags); +/* Create remove header action. + * + * @param[in] ctx + * The context in which the new action will be created. + * @param[in] attr + * attributes: specifies the remove header type, PRM start anchor and + * the PRM end anchor or the PRM start anchor and remove size in bytes. + * @param[in] flags + * Action creation flags. (enum mlx5dr_action_flags) + * @return pointer to mlx5dr_action on success NULL otherwise. + */ +struct mlx5dr_action * +mlx5dr_action_create_remove_header(struct mlx5dr_context *ctx, + struct mlx5dr_action_remove_header_attr *attr, + uint32_t flags); + /* Destroy direct rule action. * * @param[in] action diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c index 45e23e2d28..f794d6cd78 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.c +++ b/drivers/net/mlx5/hws/mlx5dr_action.c @@ -7,6 +7,8 @@ #define WIRE_PORT 0xFFFF #define MLX5DR_ACTION_METER_INIT_COLOR_OFFSET 1 +/* Header removal size limited to 128B (64 words) */ +#define MLX5DR_ACTION_REMOVE_HEADER_MAX_SIZE 128 /* This is the maximum allowed action order for each table type: * TX: POP_VLAN, CTR, ASO_METER, AS_CT, PUSH_VLAN, MODIFY, ENCAP, Term @@ -18,6 +20,7 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_MAX] = { [MLX5DR_TABLE_TYPE_NIC_RX] = { BIT(MLX5DR_ACTION_TYP_TAG), + BIT(MLX5DR_ACTION_TYP_REMOVE_HEADER) | BIT(MLX5DR_ACTION_TYP_REFORMAT_TNL_L2_TO_L2) | BIT(MLX5DR_ACTION_TYP_REFORMAT_TNL_L3_TO_L2), BIT(MLX5DR_ACTION_TYP_POP_VLAN), @@ -58,6 +61,7 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_ BIT(MLX5DR_ACTION_TYP_LAST), }, [MLX5DR_TABLE_TYPE_FDB] = { + BIT(MLX5DR_ACTION_TYP_REMOVE_HEADER) | BIT(MLX5DR_ACTION_TYP_REFORMAT_TNL_L2_TO_L2) | BIT(MLX5DR_ACTION_TYP_REFORMAT_TNL_L3_TO_L2), BIT(MLX5DR_ACTION_TYP_POP_VLAN), @@ -603,6 +607,19 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action, attr->insert_header.insert_offset = MLX5DR_ACTION_HDR_LEN_L2_MACS; attr->insert_header.header_size = MLX5DR_ACTION_HDR_LEN_L2_VLAN; break; + case MLX5DR_ACTION_TYP_REMOVE_HEADER: + if (action->remove_header.type == MLX5DR_ACTION_REMOVE_HEADER_TYPE_BY_HEADER) { + attr->action_type = MLX5_IFC_STC_ACTION_TYPE_HEADER_REMOVE; + attr->remove_header.decap = action->remove_header.decap; + attr->remove_header.start_anchor = action->remove_header.start_anchor; + attr->remove_header.end_anchor = action->remove_header.end_anchor; + } else { + attr->action_type = MLX5_IFC_STC_ACTION_TYPE_REMOVE_WORDS; + attr->remove_words.start_anchor = action->remove_header.start_anchor; + attr->remove_words.num_of_words = action->remove_header.num_of_words; + } + attr->action_offset = MLX5DR_ACTION_OFFSET_DW5; + break; default: DR_LOG(ERR, "Invalid action type %d", action->type); assert(false); @@ -2023,6 +2040,64 @@ mlx5dr_action_create_insert_header(struct mlx5dr_context *ctx, return NULL; } +struct mlx5dr_action * +mlx5dr_action_create_remove_header(struct mlx5dr_context *ctx, + struct mlx5dr_action_remove_header_attr *attr, + uint32_t flags) +{ + struct mlx5dr_action *action; + + if (mlx5dr_action_is_root_flags(flags)) { + DR_LOG(ERR, "Remove header action not supported over root"); + rte_errno = ENOTSUP; + return NULL; + } + + action = mlx5dr_action_create_generic(ctx, flags, MLX5DR_ACTION_TYP_REMOVE_HEADER); + if (!action) + return NULL; + + switch (attr->type) { + case MLX5DR_ACTION_REMOVE_HEADER_TYPE_BY_HEADER: + action->remove_header.type = MLX5DR_ACTION_REMOVE_HEADER_TYPE_BY_HEADER; + action->remove_header.start_anchor = attr->by_anchor.start_anchor; + action->remove_header.end_anchor = attr->by_anchor.end_anchor; + action->remove_header.decap = attr->by_anchor.decap; + break; + case MLX5DR_ACTION_REMOVE_HEADER_TYPE_BY_OFFSET: + if (attr->by_offset.size % W_SIZE != 0) { + DR_LOG(ERR, "Invalid size, HW supports header remove in WORD granularity"); + rte_errno = EINVAL; + goto free_action; + } + + if (attr->by_offset.size > MLX5DR_ACTION_REMOVE_HEADER_MAX_SIZE) { + DR_LOG(ERR, "Header removal size limited to %u bytes", + MLX5DR_ACTION_REMOVE_HEADER_MAX_SIZE); + rte_errno = EINVAL; + goto free_action; + } + + action->remove_header.type = MLX5DR_ACTION_REMOVE_HEADER_TYPE_BY_OFFSET; + action->remove_header.start_anchor = attr->by_offset.start_anchor; + action->remove_header.num_of_words = attr->by_offset.size / W_SIZE; + break; + default: + DR_LOG(ERR, "Unsupported remove header type %u", attr->type); + rte_errno = ENOTSUP; + goto free_action; + } + + if (mlx5dr_action_create_stcs(action, NULL)) + goto free_action; + + return action; + +free_action: + simple_free(action); + return NULL; +} + static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action) { struct mlx5dr_devx_obj *obj = NULL; @@ -2043,6 +2118,7 @@ static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action) case MLX5DR_ACTION_TYP_ASO_METER: case MLX5DR_ACTION_TYP_ASO_CT: case MLX5DR_ACTION_TYP_PUSH_VLAN: + case MLX5DR_ACTION_TYP_REMOVE_HEADER: mlx5dr_action_destroy_stcs(action); break; case MLX5DR_ACTION_TYP_DEST_ROOT: @@ -2620,6 +2696,7 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at) setter->idx_double = i; break; + case MLX5DR_ACTION_TYP_REMOVE_HEADER: case MLX5DR_ACTION_TYP_REFORMAT_TNL_L2_TO_L2: /* Single remove header to header */ setter = mlx5dr_action_setter_find_first(last_setter, ASF_SINGLE1 | ASF_MODIFY); diff --git a/drivers/net/mlx5/hws/mlx5dr_action.h b/drivers/net/mlx5/hws/mlx5dr_action.h index 593a7f3817..33a674906e 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.h +++ b/drivers/net/mlx5/hws/mlx5dr_action.h @@ -159,6 +159,13 @@ struct mlx5dr_action { size_t num_dest; struct mlx5dr_cmd_set_fte_dest *dest_list; } dest_array; + struct { + uint8_t type; + uint8_t start_anchor; + uint8_t end_anchor; + uint8_t num_of_words; + bool decap; + } remove_header; }; }; diff --git a/drivers/net/mlx5/hws/mlx5dr_debug.c b/drivers/net/mlx5/hws/mlx5dr_debug.c index a04dfbb97a..6607daaa63 100644 --- a/drivers/net/mlx5/hws/mlx5dr_debug.c +++ b/drivers/net/mlx5/hws/mlx5dr_debug.c @@ -25,6 +25,7 @@ const char *mlx5dr_debug_action_type_str[] = { [MLX5DR_ACTION_TYP_DEST_ROOT] = "DEST_ROOT", [MLX5DR_ACTION_TYP_DEST_ARRAY] = "DEST_ARRAY", [MLX5DR_ACTION_TYP_INSERT_HEADER] = "INSERT_HEADER", + [MLX5DR_ACTION_TYP_REMOVE_HEADER] = "REMOVE_HEADER", }; static_assert(ARRAY_SIZE(mlx5dr_debug_action_type_str) == MLX5DR_ACTION_TYP_MAX, -- 2.27.0