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 4B22D43238; Sun, 29 Oct 2023 17:35:37 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 662E441141; Sun, 29 Oct 2023 17:33:41 +0100 (CET) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2067.outbound.protection.outlook.com [40.107.102.67]) by mails.dpdk.org (Postfix) with ESMTP id 68DC640E6E for ; Sun, 29 Oct 2023 17:33:40 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dp9yvO2XtyLQGKWXmpgQ3LYMD7+gFUPrZracFsA5/5pQWvBGjEIonCAmUfC+ETMA6mQ272W/byrHcwSFTAlCxeSLBxN++pjGkYb2V5139Qat8a4Y87erBzZhIquV5bK2nLg65hLGbXE0WLeUrvpTZLBCa3tVsCFt71DmkJDDMxUznMBlvL+2bXgw4autKPZgeenOOypuvchUg0nHf1hcwZwRwaIAL9znovWFBuvf15tCJt40XJB6juNjPqZRfRIiKm1eZ8hAo3GMVRlzoPhw2e9e2AXTT3WPw7EyG17lRDZwliD7rWpBUjfbc1rwadlDMZ+0SoYZbwAdpE9BHSFRVQ== 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=pc/mjrr8zIt5fX/zSTDnKpHzvzHXd9u5tbIVQaxxR0U=; b=W2WD3iaNVDgZcfjp+aq+Ty9wd5ltsNE3WgvaAZy+OVShVGlwqdeYVN7+0x5+zZPFVTBuRokVrpGDfPy+M6yz5irett6GOZao1GUAbZBu2jUks5TcF90pDSgKilQPftWp+FtWHNesyRgMysdOee8XaEQTqecsArX0hXINgJifQ1iPHchbfoQ3xAlOFtO+P8YQlLFioA9dzh4CvqtNjYrrw/CBay4qMUu7za61eFET7LpytLEenpLJxE49AMLpJuBG861uxpUX/2lRHy3R1dqK89t9H38wMGBc5U+TDS5VJSG64wVnpGxZmrTgxfz3jQc6AMy/WNuQRsYlX4dwAApvzw== 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=pc/mjrr8zIt5fX/zSTDnKpHzvzHXd9u5tbIVQaxxR0U=; b=cvPHu14iE/iaC83JELeliu15Z12hceVf/wTKF8tYuv3AdBiM+rrD9eotqi4wQhSGfwwBZqyVGpm3Me47VkMO4hZfEcJsWDns0g19SVky46dM0yvtXuLDQtM50m6g/cEMqQUgs/Mj19buEe8NzLxUMzKyhLqZA0gt8nD8onk9VyAB8EzyQ4MalUZM3S7VJVZS5dSK+QGhlijicUfRngepITvzteHFPJFIkkRAMIDWDHUlycyWGOVg+YnkFXzFj+2RC9buMzw/PedycmykGFoRV5Bd3d7yx5/tVL/vHgClHDQyat6+kPVV4qMLZubJVVcuN9zO3pOiRaAMKBI9YimOfw== Received: from DM6PR07CA0042.namprd07.prod.outlook.com (2603:10b6:5:74::19) by DM4PR12MB5117.namprd12.prod.outlook.com (2603:10b6:5:390::15) 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:37 +0000 Received: from DS2PEPF00003447.namprd04.prod.outlook.com (2603:10b6:5:74:cafe::b5) by DM6PR07CA0042.outlook.office365.com (2603:10b6:5:74::19) 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:37 +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 DS2PEPF00003447.mail.protection.outlook.com (10.167.17.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.18 via Frontend Transport; Sun, 29 Oct 2023 16:33:37 +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:25 -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:21 -0700 From: Gregory Etelson To: CC: , , , "Hamdan Igbaria" , Alex Vesker , Matan Azrad , Viacheslav Ovsiienko , Ori Kam , Suanming Mou Subject: [PATCH 21/30] net/mlx5/hws: support remove header action Date: Sun, 29 Oct 2023 18:31:53 +0200 Message-ID: <20231029163202.216450-21-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: DS2PEPF00003447:EE_|DM4PR12MB5117:EE_ X-MS-Office365-Filtering-Correlation-Id: 79331c70-5c2a-4841-9db6-08dbd89ccd2f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gHCSQ+ctekLm5MBejBScJCxiG/jkyyn97vCcpc87JARerXxL6ClPvVsJpADEmvmACIbPpib3W8Ll74WR1bYcX9d2iga+yWMTXOZs53/ypncOgvhaLG40FU9aCPclQVeWNDC+GcSomiLXX39m94JktLWsejSeOKqFqF5+EKKFJ4LxvS654oYUfXnl3IGjh4DYmI/N7cJCRMxVf5lhFGf+vwjZUS21W/EU63K1WXp84JpIF/BB3ieJ2+e33CFJ5WN2azY/8ugZhzvHYU2d4G1rcLcoXKbdkSTCFE5EqJhAoa1hs4XV8T1PbdMJEJWqNykqP2HLM8On+IHDlZMcGvdvjH50R7A/Qht4PHA3tBYRzvA9FX50t3GfZyjcJr7sm+lYSx5gBJaoN6nKYmJzvae8Z6XzcI/jIEs1Jch3d0dqx4xp80Xlr2rUbU2z/HYAhtbRAD0FQ5UXdr25vfd+dYdK8LqayrAvADkt+xSdVCS+lAqJRKKaWc2cIl1MTlviAysUS/gPjhzS/3N1PaXb37q2634li3+d3Zpb/EACIXLgNjJcK7NiHGeY9ih04bp6x0YgxJoMMQF10dgXdRfn9CRWG5XyvA9tko5vKgqXPoeUEV62ruGmP44tI35c2lZLixmu4Y9ISUnGAK38bNMyCnDvh8B5W8BCLA9kJcxCSc92zmr2F2k1jbwMcmiciDsc5H5YvcYTsvJpBDipaejdB13Pi/OmZjCYzvVOUGY4mCExPsb4D+7zSbhOeFXpiauepghn 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)(376002)(39860400002)(396003)(230922051799003)(186009)(451199024)(1800799009)(64100799003)(82310400011)(36840700001)(40470700004)(46966006)(5660300002)(41300700001)(2906002)(54906003)(70206006)(70586007)(40460700003)(8936002)(8676002)(4326008)(40480700001)(478600001)(316002)(6916009)(83380400001)(356005)(7636003)(107886003)(36860700001)(47076005)(86362001)(36756003)(7696005)(6666004)(55016003)(1076003)(426003)(336012)(26005)(2616005)(82740400003)(16526019)(6286002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2023 16:33:37.0442 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 79331c70-5c2a-4841-9db6-08dbd89ccd2f 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: DS2PEPF00003447.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5117 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: Matan Azrad --- drivers/net/mlx5/hws/mlx5dr.h | 40 ++++++++++++++ drivers/net/mlx5/hws/mlx5dr_action.c | 78 ++++++++++++++++++++++++++++ drivers/net/mlx5/hws/mlx5dr_action.h | 7 +++ drivers/net/mlx5/hws/mlx5dr_debug.c | 1 + 4 files changed, 126 insertions(+) diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h index a6bbb85eed..2e692f76c3 100644 --- a/drivers/net/mlx5/hws/mlx5dr.h +++ b/drivers/net/mlx5/hws/mlx5dr.h @@ -51,6 +51,7 @@ enum mlx5dr_action_type { MLX5DR_ACTION_TYP_CRYPTO_ENCRYPT, MLX5DR_ACTION_TYP_CRYPTO_DECRYPT, MLX5DR_ACTION_TYP_INSERT_HEADER, + MLX5DR_ACTION_TYP_REMOVE_HEADER, MLX5DR_ACTION_TYP_DEST_ROOT, MLX5DR_ACTION_TYP_DEST_ARRAY, MLX5DR_ACTION_TYP_MAX, @@ -189,6 +190,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; @@ -849,6 +873,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 9885555a8f..1a6296a728 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.c +++ b/drivers/net/mlx5/hws/mlx5dr_action.c @@ -9,6 +9,9 @@ #define MLX5DR_ACTION_METER_INIT_COLOR_OFFSET 1 #define MLX5DR_ACTION_ASO_FIRST_HIT_SET_OFFSET 9 +/* 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, PUSH_VLAN, MODIFY, ENCAP, TRAILER, ENCRYPT, * Term @@ -21,6 +24,7 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_ [MLX5DR_TABLE_TYPE_NIC_RX] = { BIT(MLX5DR_ACTION_TYP_TAG), BIT(MLX5DR_ACTION_TYP_REFORMAT_TRAILER), + 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), @@ -69,6 +73,7 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_ }, [MLX5DR_TABLE_TYPE_FDB] = { BIT(MLX5DR_ACTION_TYP_REFORMAT_TRAILER), + 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), @@ -719,6 +724,19 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action, attr->reformat_trailer.op = action->reformat_trailer.op; attr->reformat_trailer.size = action->reformat_trailer.size; 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); @@ -2266,6 +2284,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; @@ -2291,6 +2367,7 @@ static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action) case MLX5DR_ACTION_TYP_CRYPTO_ENCRYPT: case MLX5DR_ACTION_TYP_CRYPTO_DECRYPT: case MLX5DR_ACTION_TYP_REFORMAT_TRAILER: + case MLX5DR_ACTION_TYP_REMOVE_HEADER: mlx5dr_action_destroy_stcs(action); break; case MLX5DR_ACTION_TYP_DEST_ROOT: @@ -2923,6 +3000,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 02358da4cb..4046f658e6 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.h +++ b/drivers/net/mlx5/hws/mlx5dr_action.h @@ -161,6 +161,13 @@ struct mlx5dr_action { uint8_t op; uint8_t size; } reformat_trailer; + struct { + uint8_t type; + uint8_t start_anchor; + uint8_t end_anchor; + uint8_t num_of_words; + bool decap; + } remove_header; struct { struct mlx5dr_devx_obj *devx_obj; } devx_dest; diff --git a/drivers/net/mlx5/hws/mlx5dr_debug.c b/drivers/net/mlx5/hws/mlx5dr_debug.c index 29e207765b..5111f41648 100644 --- a/drivers/net/mlx5/hws/mlx5dr_debug.c +++ b/drivers/net/mlx5/hws/mlx5dr_debug.c @@ -30,6 +30,7 @@ const char *mlx5dr_debug_action_type_str[] = { [MLX5DR_ACTION_TYP_CRYPTO_ENCRYPT] = "CRYPTO_ENCRYPT", [MLX5DR_ACTION_TYP_CRYPTO_DECRYPT] = "CRYPTO_DECRYPT", [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.39.2