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 0114143238; Sun, 29 Oct 2023 17:35:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E483242D0B; Sun, 29 Oct 2023 17:33:33 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by mails.dpdk.org (Postfix) with ESMTP id A011C427DC for ; Sun, 29 Oct 2023 17:33:32 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lgRbd0QAIZRfhokzHCw1S8ObmwTsGX16Y2/DhwRyWv9alDz2H0MFuMtlXE5/ACTKBE8BhVtX86z71pZ7YDpD4UtK+HLL3MLnLC+RUQcmW2LGOTJXv/Y22M0bpPm5ef0RZybfTDrS9NYD943XYzF7XrnYySqsivW+IzDr/mNe2pe2qdAwiUwLKScOWJ75dsyvx7Rlql8BdrCENKhijTMxkgxqzTA1eQDNGpAUt+FDGGayrJ0DzNHtyB//ON116L4rqr/qFsNqkreHsdlU1ztN7G7Q51izFRbHsR3fXMsGcHpfAYgWEa3C4NFljczKUgU+CpoNSVILtoNbtGieBzr65w== 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=FRqhbe8dh+zjQnxf98PmYpv7drQFLRz3Y09Ln6HGgLI=; b=C48F9LLU0qUFvarn5utSgBt6XO36Rl9rzjNoNDetj/+3A/2r2OvdPrIrTKnCNWhuIxmzCNYI0YMLwcFJ1ebT79PNkZNLwPC/5zLN/iiKunLxaJuC0wAg3/+2RIobF2++qGV4viAJv0rZ5R+mNcRbXm0MeOoq/y137hIjHO+yshOstBdl6hGOo26VK+oQyYPdpFPl4PS9AflbiNVcRKPNUZ6mDL8ErqWFtZIb4cCZlTfc+I3DmUVr3c5rga7lL2dkgTRM9osWQwxFP8ouHWtogH/tjYG8EvV2tA2NBRcY5ck74A1PmnfXRwRUQgnDayDkG/a5t0g906rYUE5OgTtNAA== 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=FRqhbe8dh+zjQnxf98PmYpv7drQFLRz3Y09Ln6HGgLI=; b=a7K8tHRIergc3n9c1bnMCYboFcsWsp+o8U6RAGBmqYlbO+lbMpEr6QWoDdbq9W6UKeXOI2YvWZIK2urYEclzO4JZAg7aMqJPZgwxEMcsVvVWQeMewhsLAo9wOzDkHUO9TcfcZc3Il8gmGAFtfCz68beE1kX/DDRHIEw1QQ306I92kw1PrJfUAzi4gE7C7JZwFyIC0Y9VAcmx3XPizaOLAqi+s4zjShALHr+c2j6PMDYsO7tgEddrNcvitrzi+g82st2mLTW77xZOh1vFSg4J+QbY0+ILvi+5wgXvgVm+Yd55a7FsikAdyBkO/7ZL5B9A3EMT1qZ4wZ/vC03Lp00tWA== Received: from BYAPR02CA0041.namprd02.prod.outlook.com (2603:10b6:a03:54::18) by DS0PR12MB8043.namprd12.prod.outlook.com (2603:10b6:8:14d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.19; Sun, 29 Oct 2023 16:33:29 +0000 Received: from CO1PEPF000044F4.namprd05.prod.outlook.com (2603:10b6:a03:54:cafe::a1) by BYAPR02CA0041.outlook.office365.com (2603:10b6:a03:54::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.26 via Frontend Transport; Sun, 29 Oct 2023 16:33:28 +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:28 +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:15 -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:11 -0700 From: Gregory Etelson To: CC: , , , "Hamdan Igbaria" , Alex Vesker , Matan Azrad , Viacheslav Ovsiienko , Ori Kam , Suanming Mou Subject: [PATCH 18/30] net/mlx5/hws: support reformat trailer action Date: Sun, 29 Oct 2023 18:31:50 +0200 Message-ID: <20231029163202.216450-18-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_|DS0PR12MB8043:EE_ X-MS-Office365-Filtering-Correlation-Id: 6841ccd3-b238-4d17-92b7-08dbd89cc830 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VYAiG2LqzKXBplEvjiXi4cdW01oYiVvAJigWBpcj3o/tooIhVMd+rH5Kqa8YdnQpCnU+Csae5twHuIhfCjVoalN1Lj4yEu+0HqVimfCtN5QeXz4CfCafaWjNpCHxtWjUmOslvNHeXkUjfH3ROW4DqRv5Q6ZY4Qp4EcAtvQLteUtwfx4nL9Rz6t9Y9feesvlowjGsESSct4SvsD7430+Q0QxqVJBfaVAqsCcxp0CZptdP3TxkhYcfKNVDhXqeU8ai8XAftBM0rtU1aIiK45q8jwRq6A/MIcJVLeACHDRJKxrNOe9/5nHofLqemwbMt/W3xZf/tVZycWcUpeGiirb/+sUwDc/iDsJ9QSXJMzDiIFSzROQL6Y8ga6Nqk5dptUkW9SZXJNlPuIvYkFQ4+umJBzKDttKf+wqRfy2T+6IklK9gGIJ5W9ptdPviKdihFjeenPaLot+FJ0c1qB4mlLnbk4sYAX9cBhmUvFYio9zRvgjnVTfGSjU7UsrGZTJh3sLsAfjGKORSImXBchz65iyeilajIKif+ti/u2cWaRUz+BFWRObBt9kaBIwHyssCiHEPzg/dI9jL8/8ukdKpSK1VlWHsrDxhKhclOj+23AyetmRSDHinHUTb/6J5NneXEiAHQte9mURFkxB9s8sZVliuYX6a7jWYfosVaeYRlQmxP4Aoo9pAU46HEwJr2jbFkBZpTW3TfVjzxszfRPAfZLM2fE7PTHW2Br46Dkt8cj6SiF5e1n3P3oOBBZHlBm8WWLiw 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)(136003)(346002)(396003)(376002)(230922051799003)(186009)(1800799009)(82310400011)(64100799003)(451199024)(36840700001)(40470700004)(46966006)(40460700003)(40480700001)(55016003)(1076003)(478600001)(16526019)(2616005)(70586007)(316002)(6666004)(7696005)(107886003)(70206006)(336012)(47076005)(426003)(36860700001)(86362001)(7636003)(6286002)(26005)(8936002)(41300700001)(8676002)(82740400003)(83380400001)(4326008)(356005)(5660300002)(6916009)(36756003)(54906003)(2906002)(30864003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2023 16:33:28.7243 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6841ccd3-b238-4d17-92b7-08dbd89cc830 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: DS0PR12MB8043 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 reformat trailer action, this action allows to insert/remove specific crypto security protocol trailer on the packet. For now support IPsec crypto protocol trailer. The trailer should be added before encrypting the packet in Tx flow, and it can be removed after decryption in Rx flow. Signed-off-by: Hamdan Igbaria Reviewed-by: Alex Vesker Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_prm.h | 11 +++ drivers/net/mlx5/hws/mlx5dr.h | 32 ++++++++ drivers/net/mlx5/hws/mlx5dr_action.c | 114 ++++++++++++++++++++++++++- drivers/net/mlx5/hws/mlx5dr_action.h | 5 ++ drivers/net/mlx5/hws/mlx5dr_cmd.c | 8 ++ drivers/net/mlx5/hws/mlx5dr_cmd.h | 5 ++ drivers/net/mlx5/hws/mlx5dr_debug.c | 1 + 7 files changed, 172 insertions(+), 4 deletions(-) diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index 31ebec7bcf..793fc1a674 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -3501,6 +3501,7 @@ enum mlx5_ifc_stc_action_type { MLX5_IFC_STC_ACTION_TYPE_CRYPTO_IPSEC_ENCRYPTION = 0x10, MLX5_IFC_STC_ACTION_TYPE_CRYPTO_IPSEC_DECRYPTION = 0x11, MLX5_IFC_STC_ACTION_TYPE_ASO = 0x12, + MLX5_IFC_STC_ACTION_TYPE_TRAILER = 0x13, MLX5_IFC_STC_ACTION_TYPE_COUNTER = 0x14, MLX5_IFC_STC_ACTION_TYPE_ADD_FIELD = 0x1b, MLX5_IFC_STC_ACTION_TYPE_JUMP_TO_STE_TABLE = 0x80, @@ -3557,6 +3558,15 @@ struct mlx5_ifc_stc_ste_param_ipsec_decrypt_bits { u8 ipsec_object_id[0x20]; }; +struct mlx5_ifc_stc_ste_param_trailer_bits { + u8 reserved_at_0[0x8]; + u8 command[0x4]; + u8 reserved_at_c[0x2]; + u8 type[0x2]; + u8 reserved_at_10[0xa]; + u8 length[0x6]; +}; + struct mlx5_ifc_stc_ste_param_header_modify_list_bits { u8 header_modify_pattern_id[0x20]; u8 header_modify_argument_id[0x20]; @@ -3625,6 +3635,7 @@ union mlx5_ifc_stc_param_bits { struct mlx5_ifc_stc_ste_param_vport_bits vport; struct mlx5_ifc_stc_ste_param_ipsec_encrypt_bits ipsec_encrypt; struct mlx5_ifc_stc_ste_param_ipsec_decrypt_bits ipsec_decrypt; + struct mlx5_ifc_stc_ste_param_trailer_bits trailer; u8 reserved_at_0[0x80]; }; diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h index bd352fa26d..e425a8803a 100644 --- a/drivers/net/mlx5/hws/mlx5dr.h +++ b/drivers/net/mlx5/hws/mlx5dr.h @@ -33,6 +33,7 @@ enum mlx5dr_action_type { MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L2, MLX5DR_ACTION_TYP_REFORMAT_TNL_L3_TO_L2, MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L3, + MLX5DR_ACTION_TYP_REFORMAT_TRAILER, MLX5DR_ACTION_TYP_DROP, MLX5DR_ACTION_TYP_TIR, MLX5DR_ACTION_TYP_TBL, @@ -195,6 +196,21 @@ struct mlx5dr_action_crypto_attr { enum mlx5dr_action_crypto_op op; }; +enum mlx5dr_action_trailer_type { + MLX5DR_ACTION_TRAILER_TYPE_IPSEC, +}; + +enum mlx5dr_action_trailer_op { + MLX5DR_ACTION_TRAILER_OP_INSERT, + MLX5DR_ACTION_TRAILER_OP_REMOVE, +}; + +struct mlx5dr_action_trailer_attr { + enum mlx5dr_action_trailer_type type; + enum mlx5dr_action_trailer_op op; + uint8_t size; +}; + /* In actions that take offset, the offset is unique, pointing to a single * resource and the user should not reuse the same index because data changing * is not atomic. @@ -607,6 +623,22 @@ mlx5dr_action_create_reformat(struct mlx5dr_context *ctx, uint32_t log_bulk_size, uint32_t flags); +/* Create reformat trailer action. + * + * @param[in] ctx + * The context in which the new action will be created. + * @param[in] attr + * attributes: specifies if to insert/remove trailer, + * also specifies the trailer type and 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_reformat_trailer(struct mlx5dr_context *ctx, + struct mlx5dr_action_trailer_attr *attr, + uint32_t flags); + /* Create direct rule modify header action. * * @param[in] ctx diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c index 956909a628..f8de3d8d98 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.c +++ b/drivers/net/mlx5/hws/mlx5dr_action.c @@ -9,16 +9,17 @@ #define MLX5DR_ACTION_METER_INIT_COLOR_OFFSET 1 /* This is the maximum allowed action order for each table type: - * TX: POP_VLAN, CTR, ASO, PUSH_VLAN, MODIFY, ENCAP, ENCRYPT, + * TX: POP_VLAN, CTR, ASO, PUSH_VLAN, MODIFY, ENCAP, TRAILER, ENCRYPT, * Term - * RX: TAG, DECAP, POP_VLAN, CTR, DECRYPT, ASO, PUSH_VLAN, + * RX: TAG, TRAILER, DECAP, POP_VLAN, CTR, DECRYPT, ASO, PUSH_VLAN, * MODIFY, ENCAP, Term - * FDB: DECAP, POP_VLAN, CTR, DECRYPT, ASO, PUSH_VLAN, MODIFY, + * FDB: TRAILER, DECAP, POP_VLAN, CTR, DECRYPT, ASO, PUSH_VLAN, MODIFY, * ENCAP, ENCRYPT, Term */ 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_REFORMAT_TRAILER), BIT(MLX5DR_ACTION_TYP_REFORMAT_TNL_L2_TO_L2) | BIT(MLX5DR_ACTION_TYP_REFORMAT_TNL_L3_TO_L2), BIT(MLX5DR_ACTION_TYP_POP_VLAN), @@ -53,6 +54,7 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_ BIT(MLX5DR_ACTION_TYP_MODIFY_HDR), BIT(MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L2) | BIT(MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L3), + BIT(MLX5DR_ACTION_TYP_REFORMAT_TRAILER), BIT(MLX5DR_ACTION_TYP_CRYPTO_ENCRYPT), BIT(MLX5DR_ACTION_TYP_TBL) | BIT(MLX5DR_ACTION_TYP_MISS) | @@ -61,6 +63,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_REFORMAT_TRAILER), BIT(MLX5DR_ACTION_TYP_REFORMAT_TNL_L2_TO_L2) | BIT(MLX5DR_ACTION_TYP_REFORMAT_TNL_L3_TO_L2), BIT(MLX5DR_ACTION_TYP_POP_VLAN), @@ -75,6 +78,7 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_ BIT(MLX5DR_ACTION_TYP_MODIFY_HDR), BIT(MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L2) | BIT(MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L3), + BIT(MLX5DR_ACTION_TYP_REFORMAT_TRAILER), BIT(MLX5DR_ACTION_TYP_CRYPTO_ENCRYPT), BIT(MLX5DR_ACTION_TYP_TBL) | BIT(MLX5DR_ACTION_TYP_MISS) | @@ -296,7 +300,8 @@ bool mlx5dr_action_check_restrictions(struct mlx5dr_matcher *matcher, break; default: restricted_bits = BIT(MLX5DR_ACTION_TYP_CRYPTO_ENCRYPT) | - BIT(MLX5DR_ACTION_TYP_CRYPTO_DECRYPT); + BIT(MLX5DR_ACTION_TYP_CRYPTO_DECRYPT) | + BIT(MLX5DR_ACTION_TYP_REFORMAT_TRAILER); } while (actions[idx] != MLX5DR_ACTION_TYP_LAST) { @@ -377,6 +382,7 @@ mlx5dr_action_fixup_stc_attr(struct mlx5dr_context *ctx, struct mlx5dr_devx_obj *devx_obj; bool use_fixup = false; uint32_t fw_tbl_type; + uint32_t val; fw_tbl_type = mlx5dr_table_get_res_fw_ft_type(table_type, is_mirror); @@ -444,6 +450,20 @@ mlx5dr_action_fixup_stc_attr(struct mlx5dr_context *ctx, } break; + case MLX5_IFC_STC_ACTION_TYPE_TRAILER: + if (table_type != MLX5DR_TABLE_TYPE_FDB) + break; + + val = stc_attr->reformat_trailer.op; + if ((val == MLX5DR_ACTION_TRAILER_OP_INSERT && !is_mirror) || + (val == MLX5DR_ACTION_TRAILER_OP_REMOVE && is_mirror)) { + fixup_stc_attr->action_type = MLX5_IFC_STC_ACTION_TYPE_NOP; + fixup_stc_attr->action_offset = stc_attr->action_offset; + fixup_stc_attr->stc_offset = stc_attr->stc_offset; + use_fixup = true; + } + break; + default: break; } @@ -683,6 +703,13 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action, attr->action_offset = MLX5DR_ACTION_OFFSET_DW5; attr->id = obj->id; break; + case MLX5DR_ACTION_TYP_REFORMAT_TRAILER: + attr->action_type = MLX5_IFC_STC_ACTION_TYPE_TRAILER; + attr->action_offset = MLX5DR_ACTION_OFFSET_DW5; + attr->reformat_trailer.type = action->reformat_trailer.type; + attr->reformat_trailer.op = action->reformat_trailer.op; + attr->reformat_trailer.size = action->reformat_trailer.size; + break; default: DR_LOG(ERR, "Invalid action type %d", action->type); assert(false); @@ -2080,6 +2107,64 @@ mlx5dr_action_create_crypto(struct mlx5dr_context *ctx, return action; } +struct mlx5dr_action * +mlx5dr_action_create_reformat_trailer(struct mlx5dr_context *ctx, + struct mlx5dr_action_trailer_attr *attr, + uint32_t flags) +{ + struct mlx5dr_action *action; + + if (mlx5dr_action_is_root_flags(flags)) { + DR_LOG(ERR, "Action flags must be only non root (HWS)"); + rte_errno = ENOTSUP; + return NULL; + } + + if (attr->type != MLX5DR_ACTION_TRAILER_TYPE_IPSEC) { + DR_LOG(ERR, "Only trailer of IPsec is supported"); + rte_errno = ENOTSUP; + return NULL; + } + + if (attr->op == MLX5DR_ACTION_TRAILER_OP_INSERT) { + if (flags & MLX5DR_ACTION_FLAG_HWS_RX) { + DR_LOG(ERR, "Trailer insertion is not supported in Rx"); + rte_errno = EINVAL; + return NULL; + } + } else if (attr->op == MLX5DR_ACTION_TRAILER_OP_REMOVE) { + if (flags & MLX5DR_ACTION_FLAG_HWS_TX) { + DR_LOG(ERR, "Trailer removal is not supported in Tx"); + rte_errno = EINVAL; + return NULL; + } + } else { + rte_errno = ENOTSUP; + return NULL; + } + + if (attr->size % DW_SIZE) { + DR_LOG(ERR, "Wrong trailer size, size should divide by %u", DW_SIZE); + rte_errno = EINVAL; + return NULL; + } + + action = mlx5dr_action_create_generic(ctx, flags, MLX5DR_ACTION_TYP_REFORMAT_TRAILER); + if (!action) + return NULL; + + action->reformat_trailer.type = attr->type; + action->reformat_trailer.op = attr->op; + action->reformat_trailer.size = attr->size; + + if (mlx5dr_action_create_stcs(action, NULL)) { + simple_free(action); + return NULL; + } + + return action; +} + static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action) { struct mlx5dr_devx_obj *obj = NULL; @@ -2103,6 +2188,7 @@ static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action) case MLX5DR_ACTION_TYP_PUSH_VLAN: case MLX5DR_ACTION_TYP_CRYPTO_ENCRYPT: case MLX5DR_ACTION_TYP_CRYPTO_DECRYPT: + case MLX5DR_ACTION_TYP_REFORMAT_TRAILER: mlx5dr_action_destroy_stcs(action); break; case MLX5DR_ACTION_TYP_DEST_ROOT: @@ -2631,6 +2717,18 @@ mlx5dr_action_setter_crypto_decryption(struct mlx5dr_actions_apply_data *apply, apply->wqe_data[MLX5DR_ACTION_OFFSET_DW7] = 0; } +static void +mlx5dr_action_setter_reformat_trailer(struct mlx5dr_actions_apply_data *apply, + struct mlx5dr_actions_wqe_setter *setter) +{ + mlx5dr_action_apply_stc(apply, MLX5DR_ACTION_STC_IDX_DW5, setter->idx_triple); + apply->wqe_ctrl->stc_ix[MLX5DR_ACTION_STC_IDX_DW6] = 0; + apply->wqe_ctrl->stc_ix[MLX5DR_ACTION_STC_IDX_DW7] = 0; + apply->wqe_data[MLX5DR_ACTION_OFFSET_DW5] = 0; + apply->wqe_data[MLX5DR_ACTION_OFFSET_DW6] = 0; + apply->wqe_data[MLX5DR_ACTION_OFFSET_DW7] = 0; +} + int mlx5dr_action_template_process(struct mlx5dr_action_template *at) { struct mlx5dr_actions_wqe_setter *start_setter = at->setters + 1; @@ -2782,6 +2880,14 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at) setter->idx_triple = i; break; + case MLX5DR_ACTION_TYP_REFORMAT_TRAILER: + /* Single push trailer, consume triple due to HW limitations */ + setter = mlx5dr_action_setter_find_first(last_setter, ASF_TRIPLE); + setter->flags |= ASF_TRIPLE; + setter->set_triple = &mlx5dr_action_setter_reformat_trailer; + setter->idx_triple = i; + break; + default: DR_LOG(ERR, "Unsupported action type: %d", action_type[i]); rte_errno = ENOTSUP; diff --git a/drivers/net/mlx5/hws/mlx5dr_action.h b/drivers/net/mlx5/hws/mlx5dr_action.h index 6bfa0bcc4a..b64d6cc9a8 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.h +++ b/drivers/net/mlx5/hws/mlx5dr_action.h @@ -153,6 +153,11 @@ struct mlx5dr_action { struct { struct mlx5dv_steering_anchor *sa; } root_tbl; + struct { + uint8_t type; + uint8_t op; + uint8_t size; + } reformat_trailer; struct { struct mlx5dr_devx_obj *devx_obj; } devx_dest; diff --git a/drivers/net/mlx5/hws/mlx5dr_cmd.c b/drivers/net/mlx5/hws/mlx5dr_cmd.c index 3b3690699d..02547e7178 100644 --- a/drivers/net/mlx5/hws/mlx5dr_cmd.c +++ b/drivers/net/mlx5/hws/mlx5dr_cmd.c @@ -549,6 +549,14 @@ mlx5dr_cmd_stc_modify_set_stc_param(struct mlx5dr_cmd_stc_modify_attr *stc_attr, MLX5_SET(stc_ste_param_ipsec_decrypt, stc_parm, ipsec_object_id, stc_attr->id); break; + case MLX5_IFC_STC_ACTION_TYPE_TRAILER: + MLX5_SET(stc_ste_param_trailer, stc_parm, command, + stc_attr->reformat_trailer.op); + MLX5_SET(stc_ste_param_trailer, stc_parm, type, + stc_attr->reformat_trailer.type); + MLX5_SET(stc_ste_param_trailer, stc_parm, length, + stc_attr->reformat_trailer.size); + break; default: DR_LOG(ERR, "Not supported type %d", stc_attr->action_type); rte_errno = EINVAL; diff --git a/drivers/net/mlx5/hws/mlx5dr_cmd.h b/drivers/net/mlx5/hws/mlx5dr_cmd.h index 7bbb684dbd..c082157538 100644 --- a/drivers/net/mlx5/hws/mlx5dr_cmd.h +++ b/drivers/net/mlx5/hws/mlx5dr_cmd.h @@ -141,6 +141,11 @@ struct mlx5dr_cmd_stc_modify_attr { uint16_t start_anchor; uint16_t num_of_words; } remove_words; + struct { + uint8_t type; + uint8_t op; + uint8_t size; + } reformat_trailer; uint32_t dest_table_id; uint32_t dest_tir_num; diff --git a/drivers/net/mlx5/hws/mlx5dr_debug.c b/drivers/net/mlx5/hws/mlx5dr_debug.c index 74893f61fb..976a1993e3 100644 --- a/drivers/net/mlx5/hws/mlx5dr_debug.c +++ b/drivers/net/mlx5/hws/mlx5dr_debug.c @@ -10,6 +10,7 @@ const char *mlx5dr_debug_action_type_str[] = { [MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L2] = "L2_TO_TNL_L2", [MLX5DR_ACTION_TYP_REFORMAT_TNL_L3_TO_L2] = "TNL_L3_TO_L2", [MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L3] = "L2_TO_TNL_L3", + [MLX5DR_ACTION_TYP_REFORMAT_TRAILER] = "REFORMAT_TRAILER", [MLX5DR_ACTION_TYP_DROP] = "DROP", [MLX5DR_ACTION_TYP_TIR] = "TIR", [MLX5DR_ACTION_TYP_TBL] = "TBL", -- 2.39.2