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 1FEA543258; Wed, 1 Nov 2023 05:44:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0DD1740A6F; Wed, 1 Nov 2023 05:44:56 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060.outbound.protection.outlook.com [40.107.92.60]) by mails.dpdk.org (Postfix) with ESMTP id 9F1104067A for ; Wed, 1 Nov 2023 05:44:54 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CuLCpG35YMp/HCaUvZHDY3dwhoKFGMztn3IgPCP5Y9BXmBmHLr8jx70LjbsdAxUJ+nkclW+MudEVcKK5SAN9spC0u6bXus1fHYfFRCfUxjqRYuspJ70I3uHybqk5Nzs83wg3pz2frJUICY1Csqd00kpFV5/pqTddP+KrAEwbEiqwYZ/xJ6kfuM8+h+o9NdOxadihEH+UMxNo3b4NDav6uvbVcn+1n/5IieOGmLRi2r+Ke4OPUdDQ2lT4hg9bTDqdxVWAtky5plWjjDciT70VhMPqjktLPMbQStFW9c4tQRCdI4DaXJ9Iytdi5Az1cYd6jHzaHWZ4vLuq0OXzyoaLRA== 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=XlBhjN6zmDOj+l7g8Tb64xOYDPxJPSFuu1GC8E4R07o=; b=g2mZqYMXJnX8IYS9E5h8jX+a8zTwP42zKeOXJbV3RDTW2CZw/LidmigjdrXJJlmD5nJQs+OKDe9N2EXOPV+Rm0yIFlxh29bzCGAnPEvGLp4OUfctAYJV4ekwonjIiDEYSSnGylhNKaiJi3trM18eHSi+rjwjVWLgoZxgBmQhEzg+9Cb2tQXpccidB8h+beRYX0SdTKYsKk/LRY3lPGiPQCP9f3BvBod1U7y3c72xaepZ/iGi62ACo5xdaDAUjh8fnRGjCg0eIhmqVl/WPOnyBPsi9HAow1N9Gh/zwoCDHCxwRMdh7TPNYdn/4o3oCTm0r4sMOGW0FIVS60vt309QsA== 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=XlBhjN6zmDOj+l7g8Tb64xOYDPxJPSFuu1GC8E4R07o=; b=ZoMRb22Atjbqw64j2ZeWmoZtxGznuw2KA8vsG6qq/Qr7L4JrYAekIPT1HNearjPeRAt9U07qCliM/F+dVCfd+Up4kJNRDN51+d1wqbTBBMqr/XrNeysdEywQHcpEZMpDrHl+OzNk/LrZHnt9KQh7WzfeZlNbORbbMDaOrYtCH39sCaDvii/P53mZY7joJUkRpt3GRqUuNdThzUAVFtAisexfzeYcDhrRxGzwWNcCOFIwJSzt4c9oQcAdzIwcK2yQEMkRxN5c8MfFdD1O9efqDqpBGEgRvr6zAA1OxSdsxAbL/bA8Lt/bLj0reszKW9hMmyI6bVuFqazyP0q5K8NYtA== Received: from DS7PR03CA0156.namprd03.prod.outlook.com (2603:10b6:5:3b2::11) by LV8PR12MB9264.namprd12.prod.outlook.com (2603:10b6:408:1e8::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.29; Wed, 1 Nov 2023 04:44:52 +0000 Received: from CY4PEPF0000FCBE.namprd03.prod.outlook.com (2603:10b6:5:3b2:cafe::db) by DS7PR03CA0156.outlook.office365.com (2603:10b6:5:3b2::11) 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:46 +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 CY4PEPF0000FCBE.mail.protection.outlook.com (10.167.242.100) 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:46 +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:37 -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:34 -0700 From: Rongwei Liu To: , , , , , CC: Hamdan Igbaria , Alex Vesker Subject: [PATCH v4 01/13] net/mlx5/hws: support insert header action Date: Wed, 1 Nov 2023 06:44:07 +0200 Message-ID: <20231101044419.732726-2-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: CY4PEPF0000FCBE:EE_|LV8PR12MB9264:EE_ X-MS-Office365-Filtering-Correlation-Id: a82413a5-e3bf-474b-627b-08dbda9545fa 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: VNxjKy2LJi9hvO4ntp09NypxLBzj3+8SUmB5l1Kj/VZwnAgv2OTzISb1r1CdZIEORkw4y+gdJKZOaFyFQME9hnMWeBdYDuS9l3i1LBr+07UJoqpKr6m7tIVbmN/taUU+5ha5PzzSUf5cwgYAZuVE+C24jkuB/XPpnK8z9hcuEdVyW8VbQwXc3OggpZ5rPiJbIZhtCaquxx6m9VSZP0xdvWXXM5ZfJO3AJe+8Pid5rSZih2uf5hV9i4iNI+ofLv1p3jtZE8LZg0CN7QF81iO5UXYnLkpIcu7uRHqEPLW2Je9SBIqjB5ymA4DKV+s9f5UqRDeuUNAQTDtGckLIsFhYI+yF2gN8SbCHWx1rfX2xxEsDZuURKZgOX1YTPGQ0sgiCCylpKgcATqmKOsNXBSflpV5cIupuLaTe2mue/Za7CLSmyAZ5FL6uEocJ98sp140QqA3Tg3Na1WRSlvDGrEqkqspMi3sHbw+fgicEgmTlSa6kLGh9zu/BM7V8pekyVb941guFUCqsvByplg0PToOzpS8qKmUmiYYeNRGOgKM4u/EWe3ZvId8mDYaIQRtZ5wtIzzFonF11/44D/7CW6Y+RQX7U5w0kG+Zmkh3jNZhJf1djQrNSXv5eqcXNSyElm7vY+MhCvbvWcZUrxf7iH4r/eKEBn5sdYazL90ngom+gBTLfYFcq1k57bS7DjgOwnF8FXnAQVJnWZ89cFCNvDD12VpWsKZjT15+VW/RsB1ub+JUI7pr3oqUd+TPaBMiEcWDI 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)(136003)(346002)(39860400002)(376002)(396003)(230922051799003)(1800799009)(82310400011)(186009)(451199024)(64100799003)(36840700001)(46966006)(40470700004)(47076005)(316002)(30864003)(107886003)(86362001)(2616005)(40460700003)(2906002)(336012)(426003)(83380400001)(1076003)(54906003)(26005)(70586007)(110136005)(70206006)(356005)(7636003)(478600001)(36756003)(41300700001)(7696005)(6666004)(8936002)(8676002)(55016003)(6286002)(16526019)(4326008)(82740400003)(40480700001)(36860700001)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2023 04:44:46.0514 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a82413a5-e3bf-474b-627b-08dbda9545fa 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: CY4PEPF0000FCBE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9264 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: Ori Kam --- 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 39d902e762..f3367297c6 100644 --- a/drivers/net/mlx5/hws/mlx5dr.h +++ b/drivers/net/mlx5/hws/mlx5dr.h @@ -45,6 +45,7 @@ enum mlx5dr_action_type { MLX5DR_ACTION_TYP_PUSH_VLAN, MLX5DR_ACTION_TYP_ASO_METER, MLX5DR_ACTION_TYP_ASO_CT, + MLX5DR_ACTION_TYP_INSERT_HEADER, MLX5DR_ACTION_TYP_DEST_ROOT, MLX5DR_ACTION_TYP_DEST_ARRAY, MLX5DR_ACTION_TYP_MAX, @@ -169,6 +170,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; @@ -691,6 +706,27 @@ mlx5dr_action_create_dest_root(struct mlx5dr_context *ctx, uint16_t priority, 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 11a7c58925..45e23e2d28 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.c +++ b/drivers/net/mlx5/hws/mlx5dr_action.c @@ -28,6 +28,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) | @@ -47,6 +48,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) | @@ -66,6 +68,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) | @@ -555,20 +558,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; @@ -1246,7 +1244,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) @@ -1256,8 +1254,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; } @@ -1279,6 +1277,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"); @@ -1312,7 +1317,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); @@ -1456,7 +1461,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); @@ -1486,6 +1491,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; } @@ -1521,7 +1527,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; } @@ -1943,6 +1948,81 @@ mlx5dr_action_create_dest_root(struct mlx5dr_context *ctx, return NULL; } +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; @@ -2004,6 +2084,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]); @@ -2547,6 +2628,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 582a38bebc..593a7f3817 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.h +++ b/drivers/net/mlx5/hws/mlx5dr_action.h @@ -131,8 +131,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 c52cdd0767..f24651041c 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 e7b1f2cc32..a04dfbb97a 100644 --- a/drivers/net/mlx5/hws/mlx5dr_debug.c +++ b/drivers/net/mlx5/hws/mlx5dr_debug.c @@ -24,6 +24,7 @@ const char *mlx5dr_debug_action_type_str[] = { [MLX5DR_ACTION_TYP_ASO_CT] = "ASO_CT", [MLX5DR_ACTION_TYP_DEST_ROOT] = "DEST_ROOT", [MLX5DR_ACTION_TYP_DEST_ARRAY] = "DEST_ARRAY", + [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.27.0