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 316974589E; Fri, 30 Aug 2024 05:10:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 50DA242E58; Fri, 30 Aug 2024 05:10:53 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2098.outbound.protection.outlook.com [40.107.223.98]) by mails.dpdk.org (Postfix) with ESMTP id 0313C42E4B for ; Fri, 30 Aug 2024 05:10:51 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ewqc6f7ba5tEvn1ZRTf2mE/m2qXE7zpMgeNZPzLAusMK31eVxB7kwPJM2GjlCwJOvcOJduCBkjyZ5ELGQNxGEMODBnUbrbJu+VNnw8MFXqZeOKh3jxdnN6omdVZMpuigFF3q+ljvYTqcJxVlI9CyL0kV8JPVOT+//CXbo0NSSUk0Nv4l1R029Vdu0DxqQ2aEREsU8BT3Pb1615KZVt1UR8x/dP45QQm217zA18ntIRP6mBtHjhxxRgB3sMpt8/Ue5dtvJFRciYUbwzI9jkg5WBilwcREb2hY5gWgNMZJ0VKmJsDOe3v6x2ki4nIU9E4ZKisN7Ux7fh2GoCbPJDtb5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=4X4f6mtxeE8sj2cRg/pS8DpVfg3EMOmyvN3GU0GNryg=; b=DEZyVS1QwS1eV+MO4qycBWmL2RcvmWRf4ak95lGhCgG3o9wFqIWPLszo/5saG3sKLofZR6hEfclDxGYpukbx75cB8nPtxZegtrUnrtvjDdnnBDkgj7YVxqIQ2G+ViUIO6SpjZTKFgGwWKZxzyYpw4VYF5mePU0X0m8+19blwvrywg6ryIIh1+/oGCJHSykQHnTIkMvR3yuFyd5akAESP8Z+5ia93AahnfRYErTqdJA0+pipyM5h3gpIK/SPLebrI7wMWqzaApNILX9tRbV0Fz/SDpnQ7QHOyzdBWYksB58PE5tWjlEPFZoRZ4jnF5rLCCYc6d78fvLIGalznIqCMWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4X4f6mtxeE8sj2cRg/pS8DpVfg3EMOmyvN3GU0GNryg=; b=RUXSHF7CpvC7pORZ0F2w5FaPlpYLN2FuAeoNdhZLX1cOGpYXeBERt/8aqKb7rBo56oNYZbVCDXHwYi9qJWZu2aAjR2gpY4UnCSzpaBfmnKTXPven9qrgG8Q1xP6snThAz4J7TqnxuS3LlvcDOcjjh1KKRNpKaD9O5fBDK3L14Ko= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by PH7PR13MB6244.namprd13.prod.outlook.com (2603:10b6:510:247::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.23; Fri, 30 Aug 2024 03:10:48 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::b900:5f05:766f:833%4]) with mapi id 15.20.7897.021; Fri, 30 Aug 2024 03:10:48 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Long Wu , Chaoyong He Subject: [PATCH 1/2] net/nfp: refactor flow item calculate function arguments Date: Fri, 30 Aug 2024 11:10:24 +0800 Message-Id: <20240830031025.2422579-2-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240830031025.2422579-1-chaoyong.he@corigine.com> References: <20240830031025.2422579-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: CY8P222CA0003.NAMP222.PROD.OUTLOOK.COM (2603:10b6:930:6b::27) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH7PR13MB6244:EE_ X-MS-Office365-Filtering-Correlation-Id: e0ee3d95-631a-4921-cf3c-08dcc8a158a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|366016|1800799024|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?aAg8BpnQECJcv1m6jA29Slo7Wk1dHzw9mS0GucynFVV5bMGfSwQF8YN6K55J?= =?us-ascii?Q?iDpjJ1aXpn1hID/wtKVj3iRmP94BCYyAoSFZlEXc30HqZUP4VKaVgz1lhb9X?= =?us-ascii?Q?L85bpHUBgQCI9iK00tE+FGFR1Yld0csrWvQS+MJKQXtyPhR3xoEsMmHXZoUv?= =?us-ascii?Q?cnrr36t3QOZgCyh2vqdFYwv2DFwFd4XzCOBUwg3Lm+z/E+od/ZPaGAq3I+TK?= =?us-ascii?Q?5KeHWeBC0jRcfa/piHHeVKvGaVMHnT57jeT3lNWGLRaQgEC4zXaHLvovwqhd?= =?us-ascii?Q?zUHSrFvPPsGiGGTp7yEWQBOpR5mIrmo1HADGreloCFZMF+HcH0t8Y7w5w+2a?= =?us-ascii?Q?3LbuF0RpcPpERV60yFi0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rdf+QNmvATpX+n+qHe2UwT2RNM7meThgtFfhpI9RE2wv3TD5zuPqfl50J?= =?us-ascii?Q?pvlDSCOsb2+2CWoTnm+iYzzCcLsyAJQK9uG+Dd9herQWF1zMcl/xCQ65btEb?= =?us-ascii?Q?8zWySZTmEkR+dVYJdbXVUMcI6ednqmCNJPSrN5o23bHnN4lxZg=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(366016)(1800799024)(376014)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?8FK8bF+TLeSGBISHu55Xsv7B+5/JeDVZ9UobZE9Lnx9LQbi0WB30X0+MLgOZ?= =?us-ascii?Q?Kgraoz+kw5cmvUxZqlCJ3MRHJ58LZaEFV15iSluDaFSkW198uRDAqlr2Hi6Q?= =?us-ascii?Q?LQL5SkE7QWt+ALWN3D4moNMqZOozDfT39xI3s9JbCMExE/EW8UUcoUQJl+Fc?= =?us-ascii?Q?R2g1qi93wKjZD5X/CtmBBwmJ966PyGE2dTPXbtUfgOa0at2h/L06AgMsq/ss?= =?us-ascii?Q?x9tgSlCI73XaPGr0nSNXtK5tXRKyTUdJ3i3rEPUSIzbSTaicwCDQBUc0O9nc?= =?us-ascii?Q?SDaGX0d2DzBhin2uZ9LUSrEKvJTvFzSYa4CITGfXx6a5sVn2tJR5fIthMfC8?= =?us-ascii?Q?HB9F9lWJichkYgyLkm3XHORDnX0kmflcv+bvXfGhbt2cd4I4ETPW0a0lQrP0?= =?us-ascii?Q?3rbD6LpVA3S2ZNJPZsts5U77fZN9wndYaMtU1KGD4mA4ThGSkXo7XpSw9rnt?= =?us-ascii?Q?NuTHgimd6OP9jRkwIpfiX7r0AVjIeyvx8OIlhxRv2y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njVhqsWREcSPnA1COzsc79Z08jg+7CYhyLOybyoNRMGkGI5jfF6vQMlXAuH?= =?us-ascii?Q?XqlYT9HWLdLf3M8xvKVGKQm+oeM14WWmTnYCwirSFKOsSw1j45AlZtO/yxTH?= =?us-ascii?Q?Fp984WnYaiNJreO0TCxPeOOYnZZSNSia1/hG414wnQSeSWxrCGeiMeYN8o53?= =?us-ascii?Q?VXf3FzmUe7a81czwYTTSSbI4WGtAIQmg9z1vPT+UhlLob3W0yllFUQEcDTCL?= =?us-ascii?Q?kA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0ee3d95-631a-4921-cf3c-08dcc8a158a6 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 03:10:48.5529 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CRGCoPRhN+pJ8Vl75DECl9bBZJuXC8ihS/pSJ3Mg02S27Jsw3Nc/Z9zhGFckC3R4p0x3xSv0qTQsg98XxTpPDYB8qe1pPxrOapK7sgOa7wE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB6244 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: Long Wu Refactor the flow item calculate function, unify the arguments of item check and calculate function, make the Ethernet item calculate function more readable. Signed-off-by: Long Wu Reviewed-by: Chaoyong He --- drivers/net/nfp/flower/nfp_flower_flow.c | 46 ++++++++++++++---------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c index 0078455658..50b0742b18 100644 --- a/drivers/net/nfp/flower/nfp_flower_flow.c +++ b/drivers/net/nfp/flower/nfp_flower_flow.c @@ -1044,14 +1044,14 @@ static nfp_flow_key_check_item_fn check_item_fns[] = { }; static int -nfp_flow_key_layers_check_items(const struct rte_flow_item items[]) +nfp_flow_key_layers_check_items(const struct rte_flow_item items[], + struct nfp_item_calculate_param *param) { int ret; struct nfp_item_flag flag = {}; const struct rte_flow_item *item; - struct nfp_item_calculate_param param = { - .flag = &flag, - }; + + param->flag = &flag; for (item = items; item->type != RTE_FLOW_ITEM_TYPE_END; ++item) { if (item->type >= RTE_DIM(check_item_fns)) { @@ -1062,8 +1062,8 @@ nfp_flow_key_layers_check_items(const struct rte_flow_item items[]) if (check_item_fns[item->type] == NULL) continue; - param.item = item; - ret = check_item_fns[item->type](¶m); + param->item = item; + ret = check_item_fns[item->type](param); if (ret != 0) { PMD_DRV_LOG(ERR, "Flow item %d check fail", item->type); return ret; @@ -1081,10 +1081,17 @@ nfp_flow_item_calculate_stub(struct nfp_item_calculate_param *param __rte_unused static void nfp_flow_item_calculate_eth(struct nfp_item_calculate_param *param) { - if (param->item->spec != NULL) { - param->key_ls->key_layer |= NFP_FLOWER_LAYER_MAC; - param->key_ls->key_size += sizeof(struct nfp_flower_mac_mpls); - } + struct nfp_fl_key_ls *key_ls; + const struct rte_flow_item_eth *spec; + + spec = param->item->spec; + if (spec == NULL) + return; + + key_ls = param->key_ls; + + key_ls->key_layer |= NFP_FLOWER_LAYER_MAC; + key_ls->key_size += sizeof(struct nfp_flower_mac_mpls); } static void @@ -1238,14 +1245,12 @@ static nfp_flow_key_calculate_item_fn item_fns[] = { static int nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[], - struct nfp_fl_key_ls *key_ls) + struct nfp_item_calculate_param *param) { struct nfp_item_flag flag = {}; const struct rte_flow_item *item; - struct nfp_item_calculate_param param = { - .key_ls = key_ls, - .flag = &flag, - }; + + param->flag = &flag; for (item = items; item->type != RTE_FLOW_ITEM_TYPE_END; ++item) { if (item->type >= RTE_DIM(item_fns) || item_fns[item->type] == NULL) { @@ -1253,8 +1258,8 @@ nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[], return -ERANGE; } - param.item = item; - item_fns[item->type](¶m); + param->item = item; + item_fns[item->type](param); } return 0; @@ -1799,6 +1804,7 @@ nfp_flow_key_layers_calculate(struct rte_eth_dev *dev, struct nfp_fl_key_ls *key_ls) { int ret; + struct nfp_item_calculate_param param = {}; key_ls->key_layer_two = 0; key_ls->key_layer = NFP_FLOWER_LAYER_PORT; @@ -1809,13 +1815,15 @@ nfp_flow_key_layers_calculate(struct rte_eth_dev *dev, key_ls->vlan = 0; key_ls->tun_type = NFP_FL_TUN_NONE; - ret = nfp_flow_key_layers_check_items(items); + param.key_ls = key_ls; + + ret = nfp_flow_key_layers_check_items(items, ¶m); if (ret != 0) { PMD_DRV_LOG(ERR, "flow items check failed"); return ret; } - ret = nfp_flow_key_layers_calculate_items(items, key_ls); + ret = nfp_flow_key_layers_calculate_items(items, ¶m); if (ret != 0) { PMD_DRV_LOG(ERR, "flow items calculate failed"); return ret; -- 2.39.1