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 BF01A43258; Wed, 1 Nov 2023 05:45:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E35DB42D55; Wed, 1 Nov 2023 05:45:05 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2062.outbound.protection.outlook.com [40.107.243.62]) by mails.dpdk.org (Postfix) with ESMTP id 0851240EDC for ; Wed, 1 Nov 2023 05:45:03 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gKjDNG38ju64ZxBKlWVVo9Uz0AFSI0P6gb/TSPVwc4qmZ4A0hA74WkemJrRv8AVmmubF1e1ESR9P3AYrqr0byrcnezz2O0JpE/pBZ+gDrdpCGHoHfP4gEqigvUurbgjvl50zZQkav8k51Ngw4QebxqingzPnOt8TF3ilyBsiocGgQGnZ8cyXIA7GgFIZjBASEHDUHbyFE5dXMip4PzxgufycKR47ICGQPTAO7iWk10lh1oJUY4VLD8/oWcsToagC4uixqVF/q1xm4wyQB7Gi0Z6909QkspqBW56eyvFiIelXYWHmdp5s7J8XD9GtB3HqAZX3Y9anN3wFM7K9z55jfQ== 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=l3bfT7LkkG6d3knEkNBhe1R1tIFUtIA7AFK996NVtzE=; b=SOw55FXGEGgmMixKy1/O0wBEMAfmQim/rE8VrLVDlKN70dLl6N5Q+Mq7m/KoZvgtJX9bwS1NbH7xiz9d4bnd974PvlLJJN6sqpqPmJ2vKyODHi9wwsgUifFwYAb5tQWgwmTdCgnbL6yVzsxTHDjrNpRdKMqu43Pw717ru1W4pdFYoA1HmIKbMup4V8OIJ/3IIUBM1hJIWYNR+Cl1/n/YatzZnLewj9Aw9tV+w1VdNa44EqAq9dfdHj8r856WnfzgC1pzcwlXBCtNrri5wLvcqE7wXlegaqz0orLqAH3jPxmmR8BC6rHTi6dMf+u2fm7Q1ThK/bn2FW8eN4QVhVPCkQ== 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=l3bfT7LkkG6d3knEkNBhe1R1tIFUtIA7AFK996NVtzE=; b=rX6fN/YdxrrxVdPkmUkpaHejUhylcUWan89PJtwkmqJpbjZhe9eF2FukHebFpKlNXqTcW5FsBj9omVSbNY/gdSh5ECuLd0D/aNYWYlWG8pKOd5SXjDjR7q5X3CcWMm/6IYFPZi17P6V2JQ4VqYjhYiQbebk10kTYuaTklvAIlxcNm2mAs/d0sVrF+PnxyfNDaMOziYe02BhActtdIC+rY4Kb8XW98KbKXHLXhWBRq8IKhDKpvXJnnOU0mpk2RlYvjRAd8oVdAFbhD2helSiQUri76tkM0vNnBDcIFtlk2QBWWDX5NDjBaBeJYP9K9Qqvsz8mEZVwbWF0s149o6tR3g== Received: from DS7PR03CA0168.namprd03.prod.outlook.com (2603:10b6:5:3b2::23) by CYYPR12MB8655.namprd12.prod.outlook.com (2603:10b6:930:c4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.19; Wed, 1 Nov 2023 04:44:59 +0000 Received: from CY4PEPF0000FCBE.namprd03.prod.outlook.com (2603:10b6:5:3b2:cafe::2) by DS7PR03CA0168.outlook.office365.com (2603:10b6:5:3b2::23) 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:58 +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:58 +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:48 -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:46 -0700 From: Rongwei Liu To: , , , , , CC: Alex Vesker , Erez Shitrit Subject: [PATCH v4 05/13] net/mlx5/hws: dynamic re-parse for modify header Date: Wed, 1 Nov 2023 06:44:11 +0200 Message-ID: <20231101044419.732726-6-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_|CYYPR12MB8655:EE_ X-MS-Office365-Filtering-Correlation-Id: 329862a8-4e38-4b64-f6e4-08dbda954d87 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: xdqid81L6Jie79l3k6q5JlKE/+iXY2sRJb30dxMjz9pwZvwf9ldEpXEHtRVWPlHWa90mncTqOU68hWAJRys0pO0imZUHyJ2EmRmVQabFYcOCPTCuv6uJy2rZKfEmgW0gOGPV7nMmtLZ6vaWIfOKuSx32TkDdb/Z8L6Yru/lAoV5+YXm5oe2gtQI0vCNtGlpqFYKe2yo6QWXghRMUfi3kZl90ErAJqcqfg3H97E4PdAveXyaW3jlRXFv27kdoUX8MYPTSlq/bi60sl09nYv0DgzHjcrRXByqF5gwi2APSWh/raZjlBcRqI3d9jny3r8YCb4vUftZVkCNC3KYeD7HM0gvf5iXf5yAXtfu8cpJfwfsbtI/H8+uSrwyY/aR+/U9NoAp2fSDqezOz9bYgnSPYysVW1r9/jbuzVtEI8Ajlu8triRIiKCgrKBDxVvJpUibH3INMsrNnBe7Y5ETXQktFOwWo9xqPjt0Pnv59eCjM7zSznltGOIiFTQ9byN5VZkATL9AO/emydgfzKA0tKa0hOfq5J9G7O9HWvwFLH0BR9aliVzIDEBUwISgm+Trip5ETj+9/D0wO1jgVSts6h/xOt8kbDsUzyZbtPs/1qKAnHkuK2o9bJ7kJKhXCiZAXeLExz9o3KIcD3FsDoJ5v3RWVt2b/nFMkorHKklMsXgZ2a8qCROoV+tNOwBt1O+m30rc91DXb2D4+7n6AnZ5DS7E+CMt9EP9AqZkMjleVvMjdif3kPpOTQLZoZLXqGjrqUpDO 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)(376002)(396003)(346002)(230922051799003)(64100799003)(451199024)(82310400011)(186009)(1800799009)(36840700001)(40470700004)(46966006)(40480700001)(478600001)(40460700003)(7696005)(55016003)(16526019)(6286002)(26005)(110136005)(70586007)(316002)(70206006)(54906003)(82740400003)(356005)(7636003)(426003)(336012)(1076003)(36756003)(2616005)(86362001)(107886003)(5660300002)(83380400001)(4326008)(36860700001)(47076005)(41300700001)(8676002)(2906002)(8936002)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2023 04:44:58.7233 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 329862a8-4e38-4b64-f6e4-08dbda954d87 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: CYYPR12MB8655 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 85987fe2ea..98bb556b7b 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.c +++ b/drivers/net/mlx5/hws/mlx5dr_action.c @@ -547,7 +547,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); @@ -1474,6 +1476,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) { @@ -1620,7 +1624,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 */ @@ -1646,11 +1650,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 4bd3d3b26b..7e5063b57e 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.h +++ b/drivers/net/mlx5/hws/mlx5dr_action.h @@ -127,6 +127,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.27.0