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 0BF7443238; Sun, 29 Oct 2023 17:36:06 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C84F42DDC; Sun, 29 Oct 2023 17:33:47 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2061.outbound.protection.outlook.com [40.107.223.61]) by mails.dpdk.org (Postfix) with ESMTP id 6C7AB40269 for ; Sun, 29 Oct 2023 17:33:44 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZmHSJjPRH58q/4TdRT/0WJnAFeM2CGwrs4SvbNVy8eTCXvrepHzbr7sWvEwwZdCIFfsBAYOxWXYxfLmb1vlcFwhYapdO7xd36ZMcVsasLn+Xp/dTgSoNWj0Fi7A0ylH1IJbNOWQAYS3IJLeybpzq6H0t33xmYstnlnRppKxmMfyPjuWAbPeSDmgxLnFmsRI0PKoW3anO6DMyDZsXL5Nru5JI3/HtGwoIjpA+gmrv8vo6JhWPmYTQvA5Pm+Fitimc7b7ddaEFru+4cWDBY5jVUlcSzqDdFSQQsM3HlCFZ48k8JBdorq6tnLwisNjZiUzeTj2Di1ktJqqMK01Q67rJHQ== 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=szwbucu3kkHDNLdRCr53NR/eWPT7BjyckVMizUJkfYg=; b=a2G10dOtoexslXjepyI793eASHd6kWNuJec/8VwNVai+iX4G0OO855oGycVz5T+7beSt7CODXfWWlExmg0yiZSeTI2yXP5k+Y1x0v9wEomzW3D23YeuAdlYH6IaXvMRXdVvxxXceq8UlhpM7FbRnhTrWLtBOx5UGAgLlGmlMim4oUiO64DQ2Di9aRPFCOMuD0c4H4koyvXhBubVs3PIEIcdYpxJ5HVdpgA5khPXJbhOnSdCq8ivNOKeBg4fUhTI43DyQcOJXaIMU6USgJXaCQcfRz7ldEbite9M6gNqfLnuUBkdm2Vy7RTzskLuDLm4IPEviTsX0IEiSHk6r+8WWUQ== 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=szwbucu3kkHDNLdRCr53NR/eWPT7BjyckVMizUJkfYg=; b=NxJi3B2lbKxVxQ3U6LU1x2cOJxCbe137s65PoVL/sVQftA6pHv/zy02fMbmwaVRlh12mcEsbHFPQop2uAgshRYbnkIgshyYRbuZaE+OT7949hEb9cSP7KUGZT102EXTPXELCtyKUotaOr5ARBvHAMQOr9AePu+Z5jmR6Je4i/xnIcpDBq4FCl0rpX/RSNuOUIfgQXCXpcxv0bfVyqTKmB4fAkB1dz+6cacJ7VyDWER8wdZ41N3sV1Ydc3cl6pYW0x2jHuaMOvMKT4iIzRtxF8S633gUWndQL6S2e4lBhRbYn6ugBvIh5TqjzduTYKi6ik2CF7iGjEE5i2jF6ysqfrg== Received: from CH2PR10CA0007.namprd10.prod.outlook.com (2603:10b6:610:4c::17) by IA1PR12MB8261.namprd12.prod.outlook.com (2603:10b6:208:3f7::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.24; Sun, 29 Oct 2023 16:33:42 +0000 Received: from DS2PEPF00003442.namprd04.prod.outlook.com (2603:10b6:610:4c:cafe::15) by CH2PR10CA0007.outlook.office365.com (2603:10b6:610:4c::17) 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:42 +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 DS2PEPF00003442.mail.protection.outlook.com (10.167.17.69) 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:42 +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:35 -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:32 -0700 From: Gregory Etelson To: CC: , , , "Alex Vesker" , Erez Shitrit , Matan Azrad , Viacheslav Ovsiienko , Ori Kam , Suanming Mou Subject: [PATCH 24/30] net/mlx5/hws: dynamic re-parse for modify header Date: Sun, 29 Oct 2023 18:31:56 +0200 Message-ID: <20231029163202.216450-24-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: DS2PEPF00003442:EE_|IA1PR12MB8261:EE_ X-MS-Office365-Filtering-Correlation-Id: c86918e1-b2ab-42b5-c94d-08dbd89cd057 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3jNvgg+MJRng0/M6EBNlopw6KPREsPwX3p2u0nVLxO7ZhIPVfBIyWZMe88czg/VBocqwwKgpmYtqi+gCQsNDHJSoiUYpD+bQZ+nEFtjj2w9RfHWl8F7XcAAGJ6n0Q49vXpahjUJcFb8X9fakw3PtWXxf9BFaItaOjjzyd9b8lYa+5nqHPb2ltQ1eMc9jkkFrGm/hGPFSlVgsPAvxk7bP7Bgds8QOogNSXAkQhz/LYq4Vnul08mSg92GqdeS2HPsoMCa0miRj2gyc2Brdq9gt8S50n40qyxisABqdt54n/LVMd/G16q/V+3Ka6ar+lJrmZ++qLptjPL2UWjLu6JNXkb/zlD4k27rZRAVmsGs2KCDMASqSL6vadub5NrT8yxv3Edzr99JxW5cTjB6v1zv8r6la/1GBeDOhSI9XtO44U8/Zwyi2kYRVJlhZOZMUfTV4PeomGysckXuMtvolEYBo6RKGc98b6vP0ruRDszO9FdkejjMVk+V00mBf1bWGJqNwRPtKHIdmA5ORBGFrmmVY5sEa/TGem3B27deSXzo4isQiP+uDMfGJ4M8bRoCR5m8hr+23ez/ytr7Edp1n5Ub4DykGOpKDJBnJdO7nwj3kbgGvvkJKB5M6GOS9rPvSadBtzzh0hYKez+Tr3pNW9nCr591tOped1aG/vfyChIphFuxyaLJIHoJfQzAFN7Cb1Z4FMMcG/SO2/a03sVbRjhIbhPWj8Ml2OalADHREzq2I3KuRo9wK4b8gijKDQLbx1IGv 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)(346002)(39850400004)(136003)(396003)(376002)(230922051799003)(82310400011)(1800799009)(186009)(451199024)(64100799003)(46966006)(40470700004)(36840700001)(40460700003)(54906003)(478600001)(7696005)(6666004)(83380400001)(107886003)(2616005)(6916009)(5660300002)(41300700001)(6286002)(26005)(70586007)(16526019)(426003)(2906002)(1076003)(70206006)(316002)(8936002)(4326008)(8676002)(36756003)(86362001)(36860700001)(356005)(82740400003)(47076005)(7636003)(336012)(40480700001)(55016003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2023 16:33:42.3406 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c86918e1-b2ab-42b5-c94d-08dbd89cd057 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: DS2PEPF00003442.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8261 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: Alex Vesker With dynamic re-parse we would always require re-parse but this is not always necessary. Re-parse is only needed when the packet structure is changed. This support will allow dynamically deciding based on the action pattern if re-parse is required or no. Signed-off-by: Alex Vesker Reviewed-by: Erez Shitrit Acked-by: Matan Azrad --- drivers/net/mlx5/hws/mlx5dr_action.c | 15 +++++++--- drivers/net/mlx5/hws/mlx5dr_action.h | 1 + drivers/net/mlx5/hws/mlx5dr_pat_arg.c | 41 +++++++++++++++++++++++++-- drivers/net/mlx5/hws/mlx5dr_pat_arg.h | 2 ++ 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c index bdccfb9cf3..59be8ae2c5 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.c +++ b/drivers/net/mlx5/hws/mlx5dr_action.c @@ -635,7 +635,9 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action, case MLX5DR_ACTION_TYP_REFORMAT_TNL_L3_TO_L2: case MLX5DR_ACTION_TYP_MODIFY_HDR: attr->action_offset = MLX5DR_ACTION_OFFSET_DW6; - attr->reparse_mode = MLX5_IFC_STC_REPARSE_ALWAYS; + if (action->modify_header.require_reparse) + attr->reparse_mode = MLX5_IFC_STC_REPARSE_ALWAYS; + if (action->modify_header.num_of_actions == 1) { attr->modify_action.data = action->modify_header.single_action; attr->action_type = mlx5dr_action_get_mh_stc_type(attr->modify_action.data); @@ -1614,6 +1616,8 @@ mlx5dr_action_handle_tunnel_l3_to_l2(struct mlx5dr_action *action, action[i].modify_header.num_of_actions = num_of_actions; action[i].modify_header.arg_obj = arg_obj; action[i].modify_header.pat_obj = pat_obj; + action[i].modify_header.require_reparse = + mlx5dr_pat_require_reparse((__be64 *)mh_data, num_of_actions); ret = mlx5dr_action_create_stcs(&action[i], NULL); if (ret) { @@ -1760,7 +1764,7 @@ mlx5dr_action_create_modify_header_hws(struct mlx5dr_action *action, { struct mlx5dr_devx_obj *pat_obj, *arg_obj = NULL; struct mlx5dr_context *ctx = action->ctx; - uint16_t max_mh_actions = 0; + uint16_t num_actions, max_mh_actions = 0; int i, ret; /* Calculate maximum number of mh actions for shared arg allocation */ @@ -1786,11 +1790,14 @@ mlx5dr_action_create_modify_header_hws(struct mlx5dr_action *action, goto free_stc_and_pat; } + num_actions = pattern[i].sz / MLX5DR_MODIFY_ACTION_SIZE; action[i].modify_header.num_of_patterns = num_of_patterns; action[i].modify_header.max_num_of_actions = max_mh_actions; - action[i].modify_header.num_of_actions = pattern[i].sz / MLX5DR_MODIFY_ACTION_SIZE; + action[i].modify_header.num_of_actions = num_actions; + action[i].modify_header.require_reparse = + mlx5dr_pat_require_reparse(pattern[i].data, num_actions); - if (action[i].modify_header.num_of_actions == 1) { + if (num_actions == 1) { pat_obj = NULL; /* Optimize single modify action to be used inline */ action[i].modify_header.single_action = pattern[i].data[0]; diff --git a/drivers/net/mlx5/hws/mlx5dr_action.h b/drivers/net/mlx5/hws/mlx5dr_action.h index 328de65a1e..e56f5b59c7 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.h +++ b/drivers/net/mlx5/hws/mlx5dr_action.h @@ -132,6 +132,7 @@ struct mlx5dr_action { uint8_t single_action_type; uint8_t num_of_actions; uint8_t max_num_of_actions; + uint8_t require_reparse; } modify_header; struct { struct mlx5dr_devx_obj *arg_obj; diff --git a/drivers/net/mlx5/hws/mlx5dr_pat_arg.c b/drivers/net/mlx5/hws/mlx5dr_pat_arg.c index 349d77f296..a949844d24 100644 --- a/drivers/net/mlx5/hws/mlx5dr_pat_arg.c +++ b/drivers/net/mlx5/hws/mlx5dr_pat_arg.c @@ -37,6 +37,43 @@ uint32_t mlx5dr_arg_get_arg_size(uint16_t num_of_actions) return BIT(mlx5dr_arg_get_arg_log_size(num_of_actions)); } +bool mlx5dr_pat_require_reparse(__be64 *actions, uint16_t num_of_actions) +{ + uint16_t i, field; + uint8_t action_id; + + for (i = 0; i < num_of_actions; i++) { + action_id = MLX5_GET(set_action_in, &actions[i], action_type); + + switch (action_id) { + case MLX5_MODIFICATION_TYPE_NOP: + field = MLX5_MODI_OUT_NONE; + break; + + case MLX5_MODIFICATION_TYPE_SET: + case MLX5_MODIFICATION_TYPE_ADD: + field = MLX5_GET(set_action_in, &actions[i], field); + break; + + case MLX5_MODIFICATION_TYPE_COPY: + case MLX5_MODIFICATION_TYPE_ADD_FIELD: + field = MLX5_GET(copy_action_in, &actions[i], dst_field); + break; + + default: + /* Insert/Remove/Unknown actions require reparse */ + return true; + } + + /* Below fields can change packet structure require a reparse */ + if (field == MLX5_MODI_OUT_ETHERTYPE || + field == MLX5_MODI_OUT_IPV6_NEXT_HDR) + return true; + } + + return false; +} + /* Cache and cache element handling */ int mlx5dr_pat_init_pattern_cache(struct mlx5dr_pattern_cache **cache) { @@ -228,8 +265,8 @@ mlx5dr_pat_get_pattern(struct mlx5dr_context *ctx, } pat_obj = mlx5dr_cmd_header_modify_pattern_create(ctx->ibv_ctx, - pattern_sz, - (uint8_t *)pattern); + pattern_sz, + (uint8_t *)pattern); if (!pat_obj) { DR_LOG(ERR, "Failed to create pattern FW object"); goto out_unlock; diff --git a/drivers/net/mlx5/hws/mlx5dr_pat_arg.h b/drivers/net/mlx5/hws/mlx5dr_pat_arg.h index 2a38891c4d..bbe313102f 100644 --- a/drivers/net/mlx5/hws/mlx5dr_pat_arg.h +++ b/drivers/net/mlx5/hws/mlx5dr_pat_arg.h @@ -79,6 +79,8 @@ void mlx5dr_pat_put_pattern(struct mlx5dr_context *ctx, bool mlx5dr_arg_is_valid_arg_request_size(struct mlx5dr_context *ctx, uint32_t arg_size); +bool mlx5dr_pat_require_reparse(__be64 *actions, uint16_t num_of_actions); + void mlx5dr_arg_write(struct mlx5dr_send_engine *queue, void *comp_data, uint32_t arg_idx, -- 2.39.2