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 DB48A43258; Wed, 1 Nov 2023 05:45:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1E18F4161A; Wed, 1 Nov 2023 05:45:03 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2087.outbound.protection.outlook.com [40.107.94.87]) by mails.dpdk.org (Postfix) with ESMTP id 5386B4161A for ; Wed, 1 Nov 2023 05:45:01 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R6zVSoEzAtg8fIS9/auV0TkCUFxhv9fjP2zA3SLlGR/NMguA+3++98ItKOE6+//hQSwclFyYcHEPbtHwjaYGUeh3TMt9HH8++62UCUrnnXBUKcNHojFKKJQJtSyVmxKVfHUNRTguTNyqJtJESRVvwIl7yWB0gkt3LGKNzvBFAKlYQV1qehQTIE/8o30FU65e8yraisbJO9AEiQgISQ2kgRKzSgcJ30OIoxK5+eCAp8n+nWN+iN/HCKWeUTvxzx9hsHimf+9f2t0SOv0o0srEH61ZVtI+GcZkFvEyCGzo5WWzrfL6mi+kQ87A40Ts4WVB+Rp7bSlSzz5Rn/knYYldSA== 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=8mJS7/RFKOA+jfEP634Us06BBarhYv3+v8K+lQP/bKI=; b=iT1DhEox28JGvWAIlNpDKUBtd+DYtlU4ZHNNFshz/tn1QN4JEVtSEOVx70gnoXyhe9+v3C5r0eWPrih34NZ2BJsK7lrNdn9riR1Tos4MtOmEEAK5/An3L0TRhDFC1r/JXy0dw3VyQyW09PibRDNK99sXOdVkxfD3WgEGjHRPpXO7eWjWtMK3CFM0KzoMvq12I8Ks5ma4YbMmrRJ/CBoCVMtIMWwGDllLC3qsi5IQWb0OZhF6d6ncttgypaDq3DAUc/NYojRXBjCxlg7BSBSzTVxaunSurtw1YSROWpgNJhXte4S2n2xQo2tO+LIzpw0OdEfSxHr95fbFkeySKQA25A== 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=8mJS7/RFKOA+jfEP634Us06BBarhYv3+v8K+lQP/bKI=; b=UjLCbi0SiRbDBst1046gBqdsxkb95JndHoRnnJ2RT19OTe2+3AIgVVYSivTQicUbvTF6yy3/o0g09j98Sa3KbUfMQxLzpN8TJyTk1g7RJJSu6VMrvcA2/mwGb46GO9KPxBy2ZiXy0jMvdcEsKt0Dw7AzAuROwPT/fJxsXfSOfbDK92XkCz3D2uR7bzH5wNOQ9At2ud8Y6iGKaF4yVSyV6MuMjj5kXnx9j2R1VIZiy9zsGMeVC2zp/S3b4nvEpr77ORZNIRRfGljo0ptHZdgaWJ1HuqmPih/ekswhsUGKXPRE55s4CfyBVouoCFNLBvjUl2Ccooaw/7k4gZuzDwhJ2w== Received: from DS7PR03CA0174.namprd03.prod.outlook.com (2603:10b6:5:3b2::29) by DM4PR12MB6565.namprd12.prod.outlook.com (2603:10b6:8:8c::14) 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:57 +0000 Received: from CY4PEPF0000FCBE.namprd03.prod.outlook.com (2603:10b6:5:3b2:cafe::a0) by DS7PR03CA0174.outlook.office365.com (2603:10b6:5:3b2::29) 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:56 +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:56 +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:46 -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:43 -0700 From: Rongwei Liu To: , , , , , CC: Alex Vesker , Erez Shitrit Subject: [PATCH v4 04/13] net/mlx5/hws: support dynamic re-parse Date: Wed, 1 Nov 2023 06:44:10 +0200 Message-ID: <20231101044419.732726-5-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_|DM4PR12MB6565:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e2044cf-7b16-4d71-c9a3-08dbda954c56 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: FgP9BX95iwQhN8njl81kxfU6sMEABrBrlumL/XDn2VStJUU74B9ucytgf3pbDvVINn4t5DAsQELelHRU2/eK92SGUfffhFR3bBVZbba5aO4eLRoV/zmYe+pfwL2FxDtVtr4DEfd0piPubS+Zdb0U6ioRVKtNSYkJRPMVrqz1ED3mmGiwk4ISJeoBNejqWPiVqNAjMCmp/l9+CNb0RICt1bDsbHrbMDb5a+y/qUA8m1MEkfbdFIlTMPuuKqf49ujIjxl8HY8St7lX17SsCY0m0WFhx2LK3pd9b3kD94ey+tLdCwDUweJ3MswjuPA7zGFN/JWRFbNKozRn3tBIiyVtOWriwhPV6jFCutEabgcD0zrSFymqWLCs4hyAalfao8fOpz/9EDooSmTX9sAMCpWP5jRGtP7ztDCKZRqEttFtqwyUysVPJBTCg2jChak4x8A/rK4NypNJM7tcAJGKsPlis/TaXvDqGCOF2mRSXSKg5LIKWfEj6T4cSkAx+bZPwYsxc2WUSk5Y7SvNnsnaM0221KUP9Oy8ot9+WNV9JTj9reql674nJow1qMPgxxHwzT7mtX/1FUcdxazPAEMVK2KEBXYx61nIGztJj0j/ffn30zd7EqseZqXTDTvW++zztmvGrO5lREtgVsBtyiswawWB6GQlQDTvOI/CBhO5odltfHjXp0QW1tyOXXVd/oR43lpKQum3JIgmbt4aCqTK3ZmAm4UTJP3m+j52zFd7RZf+2TP9k/xrASPW5isJDHjNIlYI 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)(396003)(39860400002)(376002)(346002)(136003)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(82310400011)(36840700001)(40470700004)(46966006)(36756003)(478600001)(7696005)(41300700001)(356005)(6286002)(16526019)(110136005)(70206006)(7636003)(70586007)(82740400003)(5660300002)(36860700001)(40480700001)(8936002)(4326008)(6666004)(8676002)(55016003)(86362001)(30864003)(107886003)(40460700003)(2616005)(47076005)(316002)(426003)(336012)(54906003)(26005)(83380400001)(1076003)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2023 04:44:56.7389 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1e2044cf-7b16-4d71-c9a3-08dbda954c56 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: DM4PR12MB6565 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 Each steering entry (STE) has a bit called re-parse used for re-parsing the packet in HW, re-parsing is needed after reformat (e.g. push/pop/encapsulate/...) or when modifying the packet headers requiring structure change (e.g. TCP to UDP). Until now we re-parsed the packet in each STE leading to longer processing per packet. With supported devices we can control re-parse bit to allow better performance. Signed-off-by: Alex Vesker Reviewed-by: Erez Shitrit Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_prm.h | 10 ++++- drivers/net/mlx5/hws/mlx5dr_action.c | 57 +++++++++++++++++---------- drivers/net/mlx5/hws/mlx5dr_action.h | 2 +- drivers/net/mlx5/hws/mlx5dr_cmd.c | 3 +- drivers/net/mlx5/hws/mlx5dr_cmd.h | 2 + drivers/net/mlx5/hws/mlx5dr_context.c | 15 +++++++ drivers/net/mlx5/hws/mlx5dr_context.h | 9 ++++- drivers/net/mlx5/hws/mlx5dr_matcher.c | 2 + 8 files changed, 74 insertions(+), 26 deletions(-) diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index 5259031a04..15dbf1a0cb 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -3445,6 +3445,7 @@ enum mlx5_ifc_rtc_ste_format { enum mlx5_ifc_rtc_reparse_mode { MLX5_IFC_RTC_REPARSE_NEVER = 0x0, MLX5_IFC_RTC_REPARSE_ALWAYS = 0x1, + MLX5_IFC_RTC_REPARSE_BY_STC = 0x2, }; #define MLX5_IFC_RTC_LINEAR_LOOKUP_TBL_LOG_MAX 16 @@ -3512,6 +3513,12 @@ enum mlx5_ifc_stc_action_type { MLX5_IFC_STC_ACTION_TYPE_JUMP_TO_UPLINK = 0x86, }; +enum mlx5_ifc_stc_reparse_mode { + MLX5_IFC_STC_REPARSE_IGNORE = 0x0, + MLX5_IFC_STC_REPARSE_NEVER = 0x1, + MLX5_IFC_STC_REPARSE_ALWAYS = 0x2, +}; + struct mlx5_ifc_stc_ste_param_ste_table_bits { u8 ste_obj_id[0x20]; u8 match_definer_id[0x20]; @@ -3623,7 +3630,8 @@ enum { struct mlx5_ifc_stc_bits { u8 modify_field_select[0x40]; - u8 reserved_at_40[0x48]; + u8 reserved_at_40[0x46]; + u8 reparse_mode[0x2]; u8 table_type[0x8]; u8 ste_action_offset[0x8]; u8 action_type[0x8]; diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c index 1bace23c58..85987fe2ea 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.c +++ b/drivers/net/mlx5/hws/mlx5dr_action.c @@ -107,16 +107,18 @@ static int mlx5dr_action_get_shared_stc_nic(struct mlx5dr_context *ctx, goto unlock_and_out; } switch (stc_type) { - case MLX5DR_CONTEXT_SHARED_STC_DECAP: + case MLX5DR_CONTEXT_SHARED_STC_DECAP_L3: stc_attr.action_type = MLX5_IFC_STC_ACTION_TYPE_HEADER_REMOVE; stc_attr.action_offset = MLX5DR_ACTION_OFFSET_DW5; + stc_attr.reparse_mode = MLX5_IFC_STC_REPARSE_IGNORE; stc_attr.remove_header.decap = 0; stc_attr.remove_header.start_anchor = MLX5_HEADER_ANCHOR_PACKET_START; stc_attr.remove_header.end_anchor = MLX5_HEADER_ANCHOR_IPV6_IPV4; break; - case MLX5DR_CONTEXT_SHARED_STC_POP: + case MLX5DR_CONTEXT_SHARED_STC_DOUBLE_POP: stc_attr.action_type = MLX5_IFC_STC_ACTION_TYPE_REMOVE_WORDS; stc_attr.action_offset = MLX5DR_ACTION_OFFSET_DW5; + stc_attr.reparse_mode = MLX5_IFC_STC_REPARSE_ALWAYS; stc_attr.remove_words.start_anchor = MLX5_HEADER_ANCHOR_FIRST_VLAN_START; stc_attr.remove_words.num_of_words = MLX5DR_ACTION_HDR_LEN_L2_VLAN; break; @@ -424,6 +426,11 @@ int mlx5dr_action_alloc_single_stc(struct mlx5dr_context *ctx, } stc_attr->stc_offset = stc->offset; + + /* Dynamic reparse not supported, overwrite and use default */ + if (!mlx5dr_context_cap_dynamic_reparse(ctx)) + stc_attr->reparse_mode = MLX5_IFC_STC_REPARSE_IGNORE; + devx_obj_0 = mlx5dr_pool_chunk_get_base_devx_obj(stc_pool, stc); /* According to table/action limitation change the stc_attr */ @@ -512,6 +519,8 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action, struct mlx5dr_devx_obj *obj, struct mlx5dr_cmd_stc_modify_attr *attr) { + attr->reparse_mode = MLX5_IFC_STC_REPARSE_IGNORE; + switch (action->type) { case MLX5DR_ACTION_TYP_TAG: attr->action_type = MLX5_IFC_STC_ACTION_TYPE_TAG; @@ -538,6 +547,7 @@ 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.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); @@ -565,6 +575,7 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action, case MLX5DR_ACTION_TYP_REFORMAT_TNL_L2_TO_L2: attr->action_type = MLX5_IFC_STC_ACTION_TYPE_HEADER_REMOVE; attr->action_offset = MLX5DR_ACTION_OFFSET_DW5; + attr->reparse_mode = MLX5_IFC_STC_REPARSE_ALWAYS; attr->remove_header.decap = 1; attr->remove_header.start_anchor = MLX5_HEADER_ANCHOR_PACKET_START; attr->remove_header.end_anchor = MLX5_HEADER_ANCHOR_INNER_MAC; @@ -574,6 +585,7 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action, case MLX5DR_ACTION_TYP_INSERT_HEADER: attr->action_type = MLX5_IFC_STC_ACTION_TYPE_HEADER_INSERT; attr->action_offset = MLX5DR_ACTION_OFFSET_DW6; + attr->reparse_mode = MLX5_IFC_STC_REPARSE_ALWAYS; 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; @@ -603,12 +615,14 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action, case MLX5DR_ACTION_TYP_POP_VLAN: attr->action_type = MLX5_IFC_STC_ACTION_TYPE_REMOVE_WORDS; attr->action_offset = MLX5DR_ACTION_OFFSET_DW5; + attr->reparse_mode = MLX5_IFC_STC_REPARSE_ALWAYS; attr->remove_words.start_anchor = MLX5_HEADER_ANCHOR_FIRST_VLAN_START; attr->remove_words.num_of_words = MLX5DR_ACTION_HDR_LEN_L2_VLAN / 2; break; case MLX5DR_ACTION_TYP_PUSH_VLAN: attr->action_type = MLX5_IFC_STC_ACTION_TYPE_HEADER_INSERT; attr->action_offset = MLX5DR_ACTION_OFFSET_DW6; + attr->reparse_mode = MLX5_IFC_STC_REPARSE_ALWAYS; attr->insert_header.encap = 0; attr->insert_header.is_inline = 1; attr->insert_header.insert_anchor = MLX5_HEADER_ANCHOR_PACKET_START; @@ -627,6 +641,7 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action, attr->remove_words.num_of_words = action->remove_header.num_of_words; } attr->action_offset = MLX5DR_ACTION_OFFSET_DW5; + attr->reparse_mode = MLX5_IFC_STC_REPARSE_ALWAYS; break; default: DR_LOG(ERR, "Invalid action type %d", action->type); @@ -1171,7 +1186,7 @@ mlx5dr_action_create_pop_vlan(struct mlx5dr_context *ctx, uint32_t flags) if (!action) return NULL; - ret = mlx5dr_action_get_shared_stc(action, MLX5DR_CONTEXT_SHARED_STC_POP); + ret = mlx5dr_action_get_shared_stc(action, MLX5DR_CONTEXT_SHARED_STC_DOUBLE_POP); if (ret) { DR_LOG(ERR, "Failed to create remove stc for reformat"); goto free_action; @@ -1186,7 +1201,7 @@ mlx5dr_action_create_pop_vlan(struct mlx5dr_context *ctx, uint32_t flags) return action; free_shared: - mlx5dr_action_put_shared_stc(action, MLX5DR_CONTEXT_SHARED_STC_POP); + mlx5dr_action_put_shared_stc(action, MLX5DR_CONTEXT_SHARED_STC_DOUBLE_POP); free_action: simple_free(action); return NULL; @@ -1342,7 +1357,7 @@ mlx5dr_action_handle_l2_to_tunnel_l3(struct mlx5dr_action *action, int ret; /* The action is remove-l2-header + insert-l3-header */ - ret = mlx5dr_action_get_shared_stc(action, MLX5DR_CONTEXT_SHARED_STC_DECAP); + ret = mlx5dr_action_get_shared_stc(action, MLX5DR_CONTEXT_SHARED_STC_DECAP_L3); if (ret) { DR_LOG(ERR, "Failed to create remove stc for reformat"); return ret; @@ -1359,7 +1374,7 @@ mlx5dr_action_handle_l2_to_tunnel_l3(struct mlx5dr_action *action, return 0; put_shared_stc: - mlx5dr_action_put_shared_stc(action, MLX5DR_CONTEXT_SHARED_STC_DECAP); + mlx5dr_action_put_shared_stc(action, MLX5DR_CONTEXT_SHARED_STC_DECAP_L3); return ret; } @@ -2142,7 +2157,7 @@ static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action) break; case MLX5DR_ACTION_TYP_POP_VLAN: mlx5dr_action_destroy_stcs(action); - mlx5dr_action_put_shared_stc(action, MLX5DR_CONTEXT_SHARED_STC_POP); + mlx5dr_action_put_shared_stc(action, MLX5DR_CONTEXT_SHARED_STC_DOUBLE_POP); break; case MLX5DR_ACTION_TYP_DEST_ARRAY: mlx5dr_action_destroy_stcs(action); @@ -2170,7 +2185,7 @@ static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action) mlx5dr_cmd_destroy_obj(obj); break; case MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L3: - mlx5dr_action_put_shared_stc(action, MLX5DR_CONTEXT_SHARED_STC_DECAP); + mlx5dr_action_put_shared_stc(action, MLX5DR_CONTEXT_SHARED_STC_DECAP_L3); for (i = 0; i < action->reformat.num_of_hdrs; i++) mlx5dr_action_destroy_stcs(&action[i]); mlx5dr_cmd_destroy_obj(action->reformat.arg_obj); @@ -2230,6 +2245,7 @@ int mlx5dr_action_get_default_stc(struct mlx5dr_context *ctx, stc_attr.action_type = MLX5_IFC_STC_ACTION_TYPE_NOP; stc_attr.action_offset = MLX5DR_ACTION_OFFSET_DW0; + stc_attr.reparse_mode = MLX5_IFC_STC_REPARSE_IGNORE; ret = mlx5dr_action_alloc_single_stc(ctx, &stc_attr, tbl_type, &default_stc->nop_ctr); if (ret) { @@ -2594,7 +2610,7 @@ mlx5dr_action_setter_single_double_pop(struct mlx5dr_actions_apply_data *apply, apply->wqe_data[MLX5DR_ACTION_OFFSET_DW5] = 0; apply->wqe_ctrl->stc_ix[MLX5DR_ACTION_STC_IDX_DW5] = htobe32(mlx5dr_action_get_shared_stc_offset(apply->common_res, - MLX5DR_CONTEXT_SHARED_STC_POP)); + MLX5DR_CONTEXT_SHARED_STC_DOUBLE_POP)); } static void @@ -2629,7 +2645,7 @@ mlx5dr_action_setter_common_decap(struct mlx5dr_actions_apply_data *apply, apply->wqe_data[MLX5DR_ACTION_OFFSET_DW5] = 0; apply->wqe_ctrl->stc_ix[MLX5DR_ACTION_STC_IDX_DW5] = htobe32(mlx5dr_action_get_shared_stc_offset(apply->common_res, - MLX5DR_CONTEXT_SHARED_STC_DECAP)); + MLX5DR_CONTEXT_SHARED_STC_DECAP_L3)); } int mlx5dr_action_template_process(struct mlx5dr_action_template *at) @@ -2680,8 +2696,8 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at) pop_setter->set_single = &mlx5dr_action_setter_single_double_pop; break; } - setter = mlx5dr_action_setter_find_first(last_setter, ASF_SINGLE1 | ASF_MODIFY); - setter->flags |= ASF_SINGLE1 | ASF_REPARSE | ASF_REMOVE; + setter = mlx5dr_action_setter_find_first(last_setter, ASF_SINGLE1 | ASF_MODIFY | ASF_INSERT); + setter->flags |= ASF_SINGLE1 | ASF_REMOVE; setter->set_single = &mlx5dr_action_setter_single; setter->idx_single = i; pop_setter = setter; @@ -2690,7 +2706,7 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at) case MLX5DR_ACTION_TYP_PUSH_VLAN: /* Double insert inline */ setter = mlx5dr_action_setter_find_first(last_setter, ASF_DOUBLE | ASF_REMOVE); - setter->flags |= ASF_DOUBLE | ASF_REPARSE | ASF_MODIFY; + setter->flags |= ASF_DOUBLE | ASF_INSERT; setter->set_double = &mlx5dr_action_setter_push_vlan; setter->idx_double = i; break; @@ -2698,7 +2714,7 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at) case MLX5DR_ACTION_TYP_MODIFY_HDR: /* Double modify header list */ setter = mlx5dr_action_setter_find_first(last_setter, ASF_DOUBLE | ASF_REMOVE); - setter->flags |= ASF_DOUBLE | ASF_MODIFY | ASF_REPARSE; + setter->flags |= ASF_DOUBLE | ASF_MODIFY; setter->set_double = &mlx5dr_action_setter_modify_header; setter->idx_double = i; break; @@ -2715,7 +2731,7 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at) 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); - setter->flags |= ASF_SINGLE1 | ASF_REMOVE | ASF_REPARSE; + setter->flags |= ASF_SINGLE1 | ASF_REMOVE; setter->set_single = &mlx5dr_action_setter_single; setter->idx_single = i; break; @@ -2723,8 +2739,8 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at) 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); - setter->flags |= ASF_DOUBLE | ASF_REPARSE; + setter = mlx5dr_action_setter_find_first(last_setter, ASF_DOUBLE | ASF_REMOVE); + setter->flags |= ASF_DOUBLE | ASF_INSERT; setter->set_double = &mlx5dr_action_setter_insert_ptr; setter->idx_double = i; break; @@ -2732,7 +2748,7 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at) case MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L3: /* Single remove + Double insert header with pointer */ setter = mlx5dr_action_setter_find_first(last_setter, ASF_SINGLE1 | ASF_DOUBLE); - setter->flags |= ASF_SINGLE1 | ASF_DOUBLE | ASF_REPARSE | ASF_REMOVE; + setter->flags |= ASF_SINGLE1 | ASF_DOUBLE; setter->set_double = &mlx5dr_action_setter_insert_ptr; setter->idx_double = i; setter->set_single = &mlx5dr_action_setter_common_decap; @@ -2741,9 +2757,8 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at) case MLX5DR_ACTION_TYP_REFORMAT_TNL_L3_TO_L2: /* Double modify header list with remove and push inline */ - setter = mlx5dr_action_setter_find_first(last_setter, - ASF_DOUBLE | ASF_REMOVE); - setter->flags |= ASF_DOUBLE | ASF_MODIFY | ASF_REPARSE; + setter = mlx5dr_action_setter_find_first(last_setter, ASF_DOUBLE | ASF_REMOVE); + setter->flags |= ASF_DOUBLE | ASF_MODIFY | ASF_INSERT; setter->set_double = &mlx5dr_action_setter_tnl_l3_to_l2; setter->idx_double = i; break; diff --git a/drivers/net/mlx5/hws/mlx5dr_action.h b/drivers/net/mlx5/hws/mlx5dr_action.h index 33a674906e..4bd3d3b26b 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.h +++ b/drivers/net/mlx5/hws/mlx5dr_action.h @@ -52,7 +52,7 @@ enum mlx5dr_action_setter_flag { ASF_SINGLE2 = 1 << 1, ASF_SINGLE3 = 1 << 2, ASF_DOUBLE = ASF_SINGLE2 | ASF_SINGLE3, - ASF_REPARSE = 1 << 3, + ASF_INSERT = 1 << 3, ASF_REMOVE = 1 << 4, ASF_MODIFY = 1 << 5, ASF_CTR = 1 << 6, diff --git a/drivers/net/mlx5/hws/mlx5dr_cmd.c b/drivers/net/mlx5/hws/mlx5dr_cmd.c index a07378bc42..876a47147d 100644 --- a/drivers/net/mlx5/hws/mlx5dr_cmd.c +++ b/drivers/net/mlx5/hws/mlx5dr_cmd.c @@ -394,7 +394,7 @@ mlx5dr_cmd_rtc_create(struct ibv_context *ctx, MLX5_SET(rtc, attr, ste_table_base_id, rtc_attr->ste_base); MLX5_SET(rtc, attr, ste_table_offset, rtc_attr->ste_offset); MLX5_SET(rtc, attr, miss_flow_table_id, rtc_attr->miss_ft_id); - MLX5_SET(rtc, attr, reparse_mode, MLX5_IFC_RTC_REPARSE_ALWAYS); + MLX5_SET(rtc, attr, reparse_mode, rtc_attr->reparse_mode); devx_obj->obj = mlx5_glue->devx_obj_create(ctx, in, sizeof(in), out, sizeof(out)); if (!devx_obj->obj) { @@ -570,6 +570,7 @@ mlx5dr_cmd_stc_modify(struct mlx5dr_devx_obj *devx_obj, attr = MLX5_ADDR_OF(create_stc_in, in, stc); MLX5_SET(stc, attr, ste_action_offset, stc_attr->action_offset); MLX5_SET(stc, attr, action_type, stc_attr->action_type); + MLX5_SET(stc, attr, reparse_mode, stc_attr->reparse_mode); MLX5_SET64(stc, attr, modify_field_select, MLX5_IFC_MODIFY_STC_FIELD_SELECT_NEW_STC); diff --git a/drivers/net/mlx5/hws/mlx5dr_cmd.h b/drivers/net/mlx5/hws/mlx5dr_cmd.h index 2b44f0e1f2..18c2b07fc8 100644 --- a/drivers/net/mlx5/hws/mlx5dr_cmd.h +++ b/drivers/net/mlx5/hws/mlx5dr_cmd.h @@ -79,6 +79,7 @@ struct mlx5dr_cmd_rtc_create_attr { uint8_t table_type; uint8_t match_definer_0; uint8_t match_definer_1; + uint8_t reparse_mode; bool is_frst_jumbo; bool is_scnd_range; }; @@ -98,6 +99,7 @@ struct mlx5dr_cmd_stc_create_attr { struct mlx5dr_cmd_stc_modify_attr { uint32_t stc_offset; uint8_t action_offset; + uint8_t reparse_mode; enum mlx5_ifc_stc_action_type action_type; union { uint32_t id; /* TIRN, TAG, FT ID, STE ID */ diff --git a/drivers/net/mlx5/hws/mlx5dr_context.c b/drivers/net/mlx5/hws/mlx5dr_context.c index 08a5ee92a5..15d53c578a 100644 --- a/drivers/net/mlx5/hws/mlx5dr_context.c +++ b/drivers/net/mlx5/hws/mlx5dr_context.c @@ -4,6 +4,21 @@ #include "mlx5dr_internal.h" +bool mlx5dr_context_cap_dynamic_reparse(struct mlx5dr_context *ctx) +{ + return IS_BIT_SET(ctx->caps->rtc_reparse_mode, MLX5_IFC_RTC_REPARSE_BY_STC); +} + +uint8_t mlx5dr_context_get_reparse_mode(struct mlx5dr_context *ctx) +{ + /* Prefer to use dynamic reparse, reparse only specific actions */ + if (mlx5dr_context_cap_dynamic_reparse(ctx)) + return MLX5_IFC_RTC_REPARSE_NEVER; + + /* Otherwise use less efficient static */ + return MLX5_IFC_RTC_REPARSE_ALWAYS; +} + static int mlx5dr_context_pools_init(struct mlx5dr_context *ctx) { struct mlx5dr_pool_attr pool_attr = {0}; diff --git a/drivers/net/mlx5/hws/mlx5dr_context.h b/drivers/net/mlx5/hws/mlx5dr_context.h index 0ba8d0c92e..f476c2308c 100644 --- a/drivers/net/mlx5/hws/mlx5dr_context.h +++ b/drivers/net/mlx5/hws/mlx5dr_context.h @@ -11,8 +11,8 @@ enum mlx5dr_context_flags { }; enum mlx5dr_context_shared_stc_type { - MLX5DR_CONTEXT_SHARED_STC_DECAP = 0, - MLX5DR_CONTEXT_SHARED_STC_POP = 1, + MLX5DR_CONTEXT_SHARED_STC_DECAP_L3 = 0, + MLX5DR_CONTEXT_SHARED_STC_DOUBLE_POP = 1, MLX5DR_CONTEXT_SHARED_STC_MAX = 2, }; @@ -60,4 +60,9 @@ mlx5dr_context_get_local_ibv(struct mlx5dr_context *ctx) return ctx->ibv_ctx; } + +bool mlx5dr_context_cap_dynamic_reparse(struct mlx5dr_context *ctx); + +uint8_t mlx5dr_context_get_reparse_mode(struct mlx5dr_context *ctx); + #endif /* MLX5DR_CONTEXT_H_ */ diff --git a/drivers/net/mlx5/hws/mlx5dr_matcher.c b/drivers/net/mlx5/hws/mlx5dr_matcher.c index ebe42c44c6..35701a4e2c 100644 --- a/drivers/net/mlx5/hws/mlx5dr_matcher.c +++ b/drivers/net/mlx5/hws/mlx5dr_matcher.c @@ -562,6 +562,7 @@ static int mlx5dr_matcher_create_rtc(struct mlx5dr_matcher *matcher, rtc_attr.pd = ctx->pd_num; rtc_attr.ste_base = devx_obj->id; rtc_attr.ste_offset = ste->offset; + rtc_attr.reparse_mode = mlx5dr_context_get_reparse_mode(ctx); rtc_attr.table_type = mlx5dr_table_get_res_fw_ft_type(tbl->type, false); mlx5dr_matcher_set_rtc_attr_sz(matcher, &rtc_attr, rtc_type, false); @@ -764,6 +765,7 @@ static int mlx5dr_matcher_bind_at(struct mlx5dr_matcher *matcher) /* Allocate STC for jumps to STE */ stc_attr.action_offset = MLX5DR_ACTION_OFFSET_HIT; stc_attr.action_type = MLX5_IFC_STC_ACTION_TYPE_JUMP_TO_STE_TABLE; + stc_attr.reparse_mode = MLX5_IFC_STC_REPARSE_NEVER; stc_attr.ste_table.ste = matcher->action_ste.ste; stc_attr.ste_table.ste_pool = matcher->action_ste.pool; stc_attr.ste_table.match_definer_id = ctx->caps->trivial_match_definer; -- 2.27.0