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 483FB43238; Sun, 29 Oct 2023 17:35:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B00C942D9F; Sun, 29 Oct 2023 17:33:39 +0100 (CET) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2040.outbound.protection.outlook.com [40.107.212.40]) by mails.dpdk.org (Postfix) with ESMTP id ABE3742D91 for ; Sun, 29 Oct 2023 17:33:37 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SZzpDJ8hVqeahGAvwMOaaxweqZzp0huB6o63VOL7KsUvEBYy5vD4VWbVC5Ai5yOmPKez0nV2I8U0fyySRFpz8jZkb6T6tX4xGloHKMJC1o2RFIp5XZTnGkw4sBvJWJK/95z9ARUU3NJQEUEkyazaKYhzcTvYYCwOqxfzujqkD5DRdX/S8vGUP8pp0yYU2VJ4sV/4LpKcKmhE711kpeUbdIp9LAwjNuSE4OKcPbsmhwhD/LnkubjIbd7eFQ610+umMiKb2AaKwtGX9nUo7H89NLusLeG7ilyYFmqR61vmxD9DqbeRDFkmFwPmre/lhj8PP7R3P+vXq0HusyYEtrEwRg== 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=m96wFSonQGgcihWRW+fu+ZweFa4C8Bkh1DZhR5PFRMw=; b=bN8ZJBVvugJs2vdmVEkkxUqY5FXihw9+iNSvq4Ys4192WlG8Ss8R5EA2qnmaCuqB0ZC4EBgiLTdgCu6jF+4NS7iDjoSGnSaI74svsyR4eXL+ThNHgDCHWWBxRfFzFew9kfPghwFXWjGa24U1cICWipvJNKvYY/3BcfNfuPcQuwNOmq8oArEfDvey9ps5NRcrB3zPky1LHFMdyZ+x1NOGPFk1JlzAgC6PRlrv1l3EPL2PGGChjFyW/BNiaEIEE8bGEhhkGrIimFGH3m82WuSPC1QHbVZDAN5wqRoc4jI3abLO+SuDxt/4ewdbt285YilZj+/vWHHvLkaXctdMBr8w9g== 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=m96wFSonQGgcihWRW+fu+ZweFa4C8Bkh1DZhR5PFRMw=; b=Y35dbcwKWckQmSH4J1510G4iQLejedqayZCcZuZX6jVpLX68UT11tkRQpC9PdgSz0YthXGzLOMyhuT2k9XTOyLTqoVnPXJRNhGt/ZZiG6ROX3XRkG9BYNu+WMj0uN0nuYYu47EWzWJTs3UF7dqCS2T/sQCTRuozh0/FvwLwR5LzNxbeII/VvhJUAQaz/wk/+S+CKoLYvkyNnfmyeruS17pb5dAHbwDetbo5lXgR0VUVBDF48VGTWmzYtk6OOF/ERhGIelG2JMRvLITZ+KlWEQ+uPIUcswSYgQyF/xVlm5LTeNRF5GkPxr7fbhWLUEKyshRDYZI2o9O1SeOr9cIBpCg== Received: from BYAPR02CA0071.namprd02.prod.outlook.com (2603:10b6:a03:54::48) by PH7PR12MB7164.namprd12.prod.outlook.com (2603:10b6:510:203::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.26; Sun, 29 Oct 2023 16:33:33 +0000 Received: from CO1PEPF000044F4.namprd05.prod.outlook.com (2603:10b6:a03:54:cafe::4f) by BYAPR02CA0071.outlook.office365.com (2603:10b6:a03:54::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.27 via Frontend Transport; Sun, 29 Oct 2023 16:33:33 +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 CO1PEPF000044F4.mail.protection.outlook.com (10.167.241.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.22 via Frontend Transport; Sun, 29 Oct 2023 16:33:33 +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; Sun, 29 Oct 2023 09:33:21 -0700 Received: from nvidia.com (10.126.231.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; Sun, 29 Oct 2023 09:33:18 -0700 From: Gregory Etelson To: CC: , , , "Hamdan Igbaria" , Alex Vesker , Matan Azrad , Viacheslav Ovsiienko , Ori Kam , Suanming Mou Subject: [PATCH 20/30] net/mlx5/hws: support insert header action Date: Sun, 29 Oct 2023 18:31:52 +0200 Message-ID: <20231029163202.216450-20-getelson@nvidia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231029163202.216450-1-getelson@nvidia.com> References: <20231029163202.216450-1-getelson@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F4:EE_|PH7PR12MB7164:EE_ X-MS-Office365-Filtering-Correlation-Id: 6528e1ae-e62e-4e7d-d2af-08dbd89ccb1a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N+VpKYtQJ601yFRM+Yx14sGX7Kai3lko6OLm2CuDwtdh3VCwx9vmArSc1Joq5naidlN4zzxZf3+O8oZwdC9swzUZe/VnCWRX/jFWljxsPlrtn/j6vCTOv0yohuOx/x4C1QVcLwSNm2fuXoAsHOdELV6U//HYAjhqPouaQA59vJHzBvg2Az7nYd3LvL4km/0ABDsmpdTNnrc9hiAkLg3bqUWFZF+zWKPi+lmFOWIKDVshMREV2Yz0Xdi4hke7sa89dZoPEQ7wVzlzOyrY5caiHbbWqfU0EOv5AHlxxA9gK6wtJDssEVz+Au1LQ4Wd+5E3baiaLTHksv5051iwpNLhcWnNJzxnU4OAKLUMaGcY7uUmXOMmZGjtuK7FmNp3DxXEJ3k2nNc/hbPmRRJF5R+pk5ldI/oD5Vhifubl4XsL2hBUABXdjhLF14JGR7eWPELsyTwNUFBNEaiWck1EvZzi8v5GgGGsWU+h0R1wxhHMvLDVYj85eWYEr7ldrTklUBfeWkA5UFO/8oMWRFs8Iuf1e3sjliyJ/0JIWzDp4075mq4/J+wZjJkqGuqAzAbzClqImtn/YGf4D7G8IW/2XWGY5PUSmKIwHKSXcb4pFMCKMz55u8bXAkvIc8goP/gar9Mr+WaD34g05zgsRiWcwJZ4jeenYinkbH5E5gWBC4Hyc4RkQ9NS5IbQ3zfAf5thRYiPQYfeav5gARjKI5xl1NvTV02WDyN3HNgIgY1TuuoTfla4p/ZfYI+uP99B2fyfwAIk 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)(376002)(39860400002)(346002)(136003)(396003)(230922051799003)(82310400011)(64100799003)(186009)(451199024)(1800799009)(46966006)(40470700004)(36840700001)(2616005)(1076003)(16526019)(6286002)(26005)(40480700001)(55016003)(40460700003)(86362001)(36756003)(7636003)(82740400003)(356005)(426003)(336012)(83380400001)(2906002)(30864003)(478600001)(7696005)(107886003)(36860700001)(6666004)(47076005)(4326008)(8676002)(8936002)(54906003)(6916009)(316002)(41300700001)(70206006)(70586007)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2023 16:33:33.5993 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6528e1ae-e62e-4e7d-d2af-08dbd89ccb1a 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: CO1PEPF000044F4.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7164 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 insert header action, this will allow encap at a specific anchor and offset selected by the user. Signed-off-by: Hamdan Igbaria Reviewed-by: Alex Vesker Acked-by: Matan Azrad --- drivers/net/mlx5/hws/mlx5dr.h | 36 ++++++++ drivers/net/mlx5/hws/mlx5dr_action.c | 112 +++++++++++++++++++++---- drivers/net/mlx5/hws/mlx5dr_action.h | 5 +- drivers/net/mlx5/hws/mlx5dr_cmd.c | 4 +- drivers/net/mlx5/hws/mlx5dr_debug.c | 1 + drivers/net/mlx5/hws/mlx5dr_internal.h | 1 + 6 files changed, 141 insertions(+), 18 deletions(-) diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h index e7d89ad7ec..a6bbb85eed 100644 --- a/drivers/net/mlx5/hws/mlx5dr.h +++ b/drivers/net/mlx5/hws/mlx5dr.h @@ -50,6 +50,7 @@ enum mlx5dr_action_type { MLX5DR_ACTION_TYP_ASO_FIRST_HIT, MLX5DR_ACTION_TYP_CRYPTO_ENCRYPT, MLX5DR_ACTION_TYP_CRYPTO_DECRYPT, + MLX5DR_ACTION_TYP_INSERT_HEADER, MLX5DR_ACTION_TYP_DEST_ROOT, MLX5DR_ACTION_TYP_DEST_ARRAY, MLX5DR_ACTION_TYP_MAX, @@ -174,6 +175,20 @@ struct mlx5dr_action_reformat_header { void *data; }; +struct mlx5dr_action_insert_header { + struct mlx5dr_action_reformat_header hdr; + /* PRM start anchor to which header will be inserted */ + uint8_t anchor; + /* Header insertion offset in bytes, from the start + * anchor to the location where new header will be inserted. + */ + uint8_t offset; + /* Indicates this header insertion adds encapsulation header to the packet, + * requiring device to update offloaded fields (for example IPv4 total length). + */ + bool encap; +}; + struct mlx5dr_action_mh_pattern { /* Byte size of modify actions provided by "data" */ size_t sz; @@ -813,6 +828,27 @@ mlx5dr_action_create_crypto(struct mlx5dr_context *ctx, struct mlx5dr_action_crypto_attr *attr, uint32_t flags); +/* Create insert header action. + * + * @param[in] ctx + * The context in which the new action will be created. + * @param[in] num_of_hdrs + * Number of provided headers in "hdrs" array. + * @param[in] hdrs + * Headers array containing header information. + * @param[in] log_bulk_size + * Number of unique values used with this insert header. + * @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_insert_header(struct mlx5dr_context *ctx, + uint8_t num_of_hdrs, + struct mlx5dr_action_insert_header *hdrs, + uint32_t log_bulk_size, + 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 fe9c39b207..9885555a8f 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.c +++ b/drivers/net/mlx5/hws/mlx5dr_action.c @@ -34,6 +34,7 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_ BIT(MLX5DR_ACTION_TYP_PUSH_VLAN), BIT(MLX5DR_ACTION_TYP_PUSH_VLAN), BIT(MLX5DR_ACTION_TYP_MODIFY_HDR), + BIT(MLX5DR_ACTION_TYP_INSERT_HEADER) | BIT(MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L2) | BIT(MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L3), BIT(MLX5DR_ACTION_TYP_TBL) | @@ -55,6 +56,7 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_ BIT(MLX5DR_ACTION_TYP_PUSH_VLAN), BIT(MLX5DR_ACTION_TYP_PUSH_VLAN), BIT(MLX5DR_ACTION_TYP_MODIFY_HDR), + BIT(MLX5DR_ACTION_TYP_INSERT_HEADER) | BIT(MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L2) | BIT(MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L3), BIT(MLX5DR_ACTION_TYP_REFORMAT_TRAILER), @@ -80,6 +82,7 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_ BIT(MLX5DR_ACTION_TYP_PUSH_VLAN), BIT(MLX5DR_ACTION_TYP_PUSH_VLAN), BIT(MLX5DR_ACTION_TYP_MODIFY_HDR), + BIT(MLX5DR_ACTION_TYP_INSERT_HEADER) | BIT(MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L2) | BIT(MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L3), BIT(MLX5DR_ACTION_TYP_REFORMAT_TRAILER), @@ -640,20 +643,15 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action, attr->remove_header.end_anchor = MLX5_HEADER_ANCHOR_INNER_MAC; break; case MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L2: - attr->action_type = MLX5_IFC_STC_ACTION_TYPE_HEADER_INSERT; - attr->action_offset = MLX5DR_ACTION_OFFSET_DW6; - attr->insert_header.encap = 1; - attr->insert_header.insert_anchor = MLX5_HEADER_ANCHOR_PACKET_START; - attr->insert_header.arg_id = action->reformat.arg_obj->id; - attr->insert_header.header_size = action->reformat.header_size; - break; case MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L3: + case MLX5DR_ACTION_TYP_INSERT_HEADER: attr->action_type = MLX5_IFC_STC_ACTION_TYPE_HEADER_INSERT; attr->action_offset = MLX5DR_ACTION_OFFSET_DW6; - attr->insert_header.encap = 1; - attr->insert_header.insert_anchor = MLX5_HEADER_ANCHOR_PACKET_START; + attr->insert_header.encap = action->reformat.encap; + attr->insert_header.insert_anchor = action->reformat.anchor; attr->insert_header.arg_id = action->reformat.arg_obj->id; attr->insert_header.header_size = action->reformat.header_size; + attr->insert_header.insert_offset = action->reformat.offset; break; case MLX5DR_ACTION_TYP_ASO_METER: attr->action_offset = MLX5DR_ACTION_OFFSET_DW6; @@ -1382,7 +1380,7 @@ mlx5dr_action_create_reformat_root(struct mlx5dr_action *action, } static int -mlx5dr_action_handle_l2_to_tunnel_l2(struct mlx5dr_action *action, +mlx5dr_action_handle_insert_with_ptr(struct mlx5dr_action *action, uint8_t num_of_hdrs, struct mlx5dr_action_reformat_header *hdrs, uint32_t log_bulk_sz) @@ -1392,8 +1390,8 @@ mlx5dr_action_handle_l2_to_tunnel_l2(struct mlx5dr_action *action, int ret, i; for (i = 0; i < num_of_hdrs; i++) { - if (hdrs[i].sz % 2 != 0) { - DR_LOG(ERR, "Header data size should be multiply of 2"); + if (hdrs[i].sz % W_SIZE != 0) { + DR_LOG(ERR, "Header data size should be in WORD granularity"); rte_errno = EINVAL; return rte_errno; } @@ -1415,6 +1413,13 @@ mlx5dr_action_handle_l2_to_tunnel_l2(struct mlx5dr_action *action, action[i].reformat.num_of_hdrs = num_of_hdrs; action[i].reformat.max_hdr_sz = max_sz; + if (action[i].type == MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L2 || + action[i].type == MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L3) { + action[i].reformat.anchor = MLX5_HEADER_ANCHOR_PACKET_START; + action[i].reformat.offset = 0; + action[i].reformat.encap = 1; + } + ret = mlx5dr_action_create_stcs(&action[i], NULL); if (ret) { DR_LOG(ERR, "Failed to create stc for reformat"); @@ -1448,7 +1453,7 @@ mlx5dr_action_handle_l2_to_tunnel_l3(struct mlx5dr_action *action, } /* Reuse the insert with pointer for the L2L3 header */ - ret = mlx5dr_action_handle_l2_to_tunnel_l2(action, + ret = mlx5dr_action_handle_insert_with_ptr(action, num_of_hdrs, hdrs, log_bulk_sz); @@ -1592,7 +1597,7 @@ mlx5dr_action_create_reformat_hws(struct mlx5dr_action *action, ret = mlx5dr_action_create_stcs(action, NULL); break; case MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L2: - ret = mlx5dr_action_handle_l2_to_tunnel_l2(action, num_of_hdrs, hdrs, bulk_size); + ret = mlx5dr_action_handle_insert_with_ptr(action, num_of_hdrs, hdrs, bulk_size); break; case MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L3: ret = mlx5dr_action_handle_l2_to_tunnel_l3(action, num_of_hdrs, hdrs, bulk_size); @@ -1622,6 +1627,7 @@ mlx5dr_action_create_reformat(struct mlx5dr_context *ctx, if (!num_of_hdrs) { DR_LOG(ERR, "Reformat num_of_hdrs cannot be zero"); + rte_errno = EINVAL; return NULL; } @@ -1657,7 +1663,6 @@ mlx5dr_action_create_reformat(struct mlx5dr_context *ctx, ret = mlx5dr_action_create_reformat_hws(action, num_of_hdrs, hdrs, log_bulk_size); if (ret) { DR_LOG(ERR, "Failed to create HWS reformat action"); - rte_errno = EINVAL; goto free_action; } @@ -2186,6 +2191,81 @@ mlx5dr_action_create_reformat_trailer(struct mlx5dr_context *ctx, return action; } +struct mlx5dr_action * +mlx5dr_action_create_insert_header(struct mlx5dr_context *ctx, + uint8_t num_of_hdrs, + struct mlx5dr_action_insert_header *hdrs, + uint32_t log_bulk_size, + uint32_t flags) +{ + struct mlx5dr_action_reformat_header *reformat_hdrs; + struct mlx5dr_action *action; + int i, ret; + + if (!num_of_hdrs) { + DR_LOG(ERR, "Reformat num_of_hdrs cannot be zero"); + return NULL; + } + + if (mlx5dr_action_is_root_flags(flags)) { + DR_LOG(ERR, "Dynamic reformat action not supported over root"); + rte_errno = ENOTSUP; + return NULL; + } + + if (!mlx5dr_action_is_hws_flags(flags) || + ((flags & MLX5DR_ACTION_FLAG_SHARED) && (log_bulk_size || num_of_hdrs > 1))) { + DR_LOG(ERR, "Reformat flags don't fit HWS (flags: 0x%x)", flags); + rte_errno = EINVAL; + return NULL; + } + + action = mlx5dr_action_create_generic_bulk(ctx, flags, + MLX5DR_ACTION_TYP_INSERT_HEADER, + num_of_hdrs); + if (!action) + return NULL; + + reformat_hdrs = simple_calloc(num_of_hdrs, sizeof(*reformat_hdrs)); + if (!reformat_hdrs) { + DR_LOG(ERR, "Failed to allocate memory for reformat_hdrs"); + rte_errno = ENOMEM; + goto free_action; + } + + for (i = 0; i < num_of_hdrs; i++) { + if (hdrs[i].offset % W_SIZE != 0) { + DR_LOG(ERR, "Header offset should be in WORD granularity"); + rte_errno = EINVAL; + goto free_reformat_hdrs; + } + + action[i].reformat.anchor = hdrs[i].anchor; + action[i].reformat.encap = hdrs[i].encap; + action[i].reformat.offset = hdrs[i].offset; + reformat_hdrs[i].sz = hdrs[i].hdr.sz; + reformat_hdrs[i].data = hdrs[i].hdr.data; + } + + ret = mlx5dr_action_handle_insert_with_ptr(action, num_of_hdrs, + reformat_hdrs, log_bulk_size); + if (ret) { + DR_LOG(ERR, "Failed to create HWS reformat action"); + rte_errno = EINVAL; + goto free_reformat_hdrs; + } + + simple_free(reformat_hdrs); + + return action; + +free_reformat_hdrs: + simple_free(reformat_hdrs); +free_action: + simple_free(action); + return NULL; +} + static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action) { struct mlx5dr_devx_obj *obj = NULL; @@ -2252,6 +2332,7 @@ static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action) mlx5dr_action_destroy_stcs(&action[i]); mlx5dr_cmd_destroy_obj(action->reformat.arg_obj); break; + case MLX5DR_ACTION_TYP_INSERT_HEADER: case MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L2: for (i = 0; i < action->reformat.num_of_hdrs; i++) mlx5dr_action_destroy_stcs(&action[i]); @@ -2850,6 +2931,7 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at) setter->idx_single = i; break; + case MLX5DR_ACTION_TYP_INSERT_HEADER: case MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L2: /* Double insert header with pointer */ setter = mlx5dr_action_setter_find_first(last_setter, ASF_DOUBLE); diff --git a/drivers/net/mlx5/hws/mlx5dr_action.h b/drivers/net/mlx5/hws/mlx5dr_action.h index b64d6cc9a8..02358da4cb 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.h +++ b/drivers/net/mlx5/hws/mlx5dr_action.h @@ -136,8 +136,11 @@ struct mlx5dr_action { struct { struct mlx5dr_devx_obj *arg_obj; uint32_t header_size; - uint8_t num_of_hdrs; uint16_t max_hdr_sz; + uint8_t num_of_hdrs; + uint8_t anchor; + uint8_t offset; + bool encap; } reformat; struct { struct mlx5dr_devx_obj *devx_obj; diff --git a/drivers/net/mlx5/hws/mlx5dr_cmd.c b/drivers/net/mlx5/hws/mlx5dr_cmd.c index 02547e7178..0ba4774f08 100644 --- a/drivers/net/mlx5/hws/mlx5dr_cmd.c +++ b/drivers/net/mlx5/hws/mlx5dr_cmd.c @@ -492,9 +492,9 @@ mlx5dr_cmd_stc_modify_set_stc_param(struct mlx5dr_cmd_stc_modify_attr *stc_attr, stc_attr->insert_header.insert_anchor); /* HW gets the next 2 sizes in words */ MLX5_SET(stc_ste_param_insert, stc_parm, insert_size, - stc_attr->insert_header.header_size / 2); + stc_attr->insert_header.header_size / W_SIZE); MLX5_SET(stc_ste_param_insert, stc_parm, insert_offset, - stc_attr->insert_header.insert_offset / 2); + stc_attr->insert_header.insert_offset / W_SIZE); MLX5_SET(stc_ste_param_insert, stc_parm, insert_argument, stc_attr->insert_header.arg_id); break; diff --git a/drivers/net/mlx5/hws/mlx5dr_debug.c b/drivers/net/mlx5/hws/mlx5dr_debug.c index 552dba5e63..29e207765b 100644 --- a/drivers/net/mlx5/hws/mlx5dr_debug.c +++ b/drivers/net/mlx5/hws/mlx5dr_debug.c @@ -29,6 +29,7 @@ const char *mlx5dr_debug_action_type_str[] = { [MLX5DR_ACTION_TYP_DEST_ARRAY] = "DEST_ARRAY", [MLX5DR_ACTION_TYP_CRYPTO_ENCRYPT] = "CRYPTO_ENCRYPT", [MLX5DR_ACTION_TYP_CRYPTO_DECRYPT] = "CRYPTO_DECRYPT", + [MLX5DR_ACTION_TYP_INSERT_HEADER] = "INSERT_HEADER", }; static_assert(ARRAY_SIZE(mlx5dr_debug_action_type_str) == MLX5DR_ACTION_TYP_MAX, diff --git a/drivers/net/mlx5/hws/mlx5dr_internal.h b/drivers/net/mlx5/hws/mlx5dr_internal.h index 021d599a56..b9efdc4a9a 100644 --- a/drivers/net/mlx5/hws/mlx5dr_internal.h +++ b/drivers/net/mlx5/hws/mlx5dr_internal.h @@ -40,6 +40,7 @@ #include "mlx5dr_pat_arg.h" #include "mlx5dr_crc32.h" +#define W_SIZE 2 #define DW_SIZE 4 #define BITS_IN_BYTE 8 #define BITS_IN_DW (BITS_IN_BYTE * DW_SIZE) -- 2.39.2