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 696FE43BDB; Mon, 26 Feb 2024 02:45:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 54C8E42DD2; Mon, 26 Feb 2024 02:45:36 +0100 (CET) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2096.outbound.protection.outlook.com [40.107.101.96]) by mails.dpdk.org (Postfix) with ESMTP id E941B42DA1 for ; Mon, 26 Feb 2024 02:45:30 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KY5ZsNLQ5JYjTe8NVhsUuqm3ZPmPnsTOe49FuIC0GPrTvtTc1X19uUF8ie2qSJrqjlYH5tmT2RiXALFqlEZsXvpYjyHTfCIwJrGWURIZGltKuXWGc8vzsB6KInl/ajR+YX4W6y+gubYC6QACkD0Lx+mdYc8vJSMbiFL8o9jM0cxy4sMqg2ZqgRCnxCauqhK0t/9f9vCipQgg6p1p/82uSdHU4uq3uWDInF83FYeE+hoEIIzbv/ALeHNeqJn8GpN89uiVwD0oNIusTJwFJhkfiXhKo9QVOiDkG1XNDOZcCMH9jfjWT9uhvdE5uW0KYiAG4XoWlRXeZ3DE5+bfnVqI0w== 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=0bQRYnP4/y7GhNsLpVMqdqCh9amolTVZ6NPP4+K0e1E=; b=JRaeSNQkL3czWPZLIcI9n+F9CnKa/w6UKCxO8DyEwnur7VJb1ZZENpVWiRM2sOBSaGqB100KqAym38nOvEDNYoWYMDcie2fcDcAmgHRGhWp8bG3Ypt51/vVYnWYIcEmMBEfw6sSvHi72rkR+LVQ7zTh9h2VnwJhWDSiTKn2xH8MzQFlBwjV0p8O43Vm00+bnGQhhINd0SLNaIGcrdbMZKOTRFSRujtVotjhKpi0RGKxflcv+WfTVdkxeXr9NDYpD1cmxPHQJETRJBt+fHko8luqMGdT2ZKDCYYkPzJNsiqh07/UZ5wpokHfZPIt+b0kV0qE0qvgVHK5/KU6TmHI8dw== 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=0bQRYnP4/y7GhNsLpVMqdqCh9amolTVZ6NPP4+K0e1E=; b=iZTzyNJvJ3VZX3o9gjAP1V3mc7g9RavJ7Urm4IHs0xZ9GQWF/6FspliQddI98HtGX6bypJ45GChGIHyiNcI2jgkRyHInqj92lJr4Ns+9sIQT+SaK8IdX3CghDQ5YrNdtlFpnCIU84N38VZjrwrwD3s55H8qGyzBdlMESpcS3Gt8= 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 PH0PR13MB5794.namprd13.prod.outlook.com (2603:10b6:510:11d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.34; Mon, 26 Feb 2024 01:45:29 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::8e02:f738:570a:f8aa]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::8e02:f738:570a:f8aa%7]) with mapi id 15.20.7316.032; Mon, 26 Feb 2024 01:45:28 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Long Wu , Chaoyong He , Peng Zhang Subject: [PATCH v3 4/4] net/nfp: support RSS flow action Date: Mon, 26 Feb 2024 09:45:00 +0800 Message-Id: <20240226014500.3537561-5-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240226014500.3537561-1-chaoyong.he@corigine.com> References: <20240223024217.3052031-1-chaoyong.he@corigine.com> <20240226014500.3537561-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: PH8PR05CA0005.namprd05.prod.outlook.com (2603:10b6:510:2cc::14) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH0PR13MB5794:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f89c3f5-37fc-4bec-8fd6-08dc366c9c4e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iOoUiEZPFaXT6qeZVVPEBZ2U5XQqo3Nffw3z+7b0i5Gr7TMe/Clb4NPnkc1Sb0Iitga59MkZqKs8ODsFQdWecxX1SpTG9DFr8szAGKbLAAPm1qyGecV2+PaB1QQ2soQR/Zk01bZZII3KqjKFuwPJxen7fKkZi0thPE+YJRat045rSSafQrAscQLq10It0yndkIq4okHRUMjbR7M1xWzCCRYXjU8H3fJMF4jp25ERM6yIWoBR9mP+BpRooweY5CDeAFP2VMrEZKv3TYNakCgIc42yCjYmmH9HTKPFKvVCCaSxDJDxVOF/NUTMUYLdssyylDuCHOoevg2kbBc54qe9Yo3bFrFIfrXGMcwY8BgerO4YMWQsQmPNttZKqE8+4UZDpJWhR4HaRBSsCDr5QeoiA7tBgiD1XJswydkjYrhhjnCbsipsT12pheuWvGFLvqs+M5eHft3ouJRl45X4LAyKgcl5sefCW1Ut2xAYma9sMd2aJ43TszpDrraIQ321YkHtZN7FSJV2Q0FNE4Sz+LBVCeVMCjGRgFjlOkWa0aeHM+igBsFny/r5PxFvNuTE+FYEfVfl/SZE1XUD4QSFoM2gWry2qLCx3oxhogeACbcQh829iYl+Fu7pIf4ZuViDTca93A/U/MhbLTL/UJXae6fO+XKh5yZswyd3/0QDfmj5cqbhKEiDBSj4NPENVB9nUX7+XVCfnAH6iTN4lN0n6JZZhg== 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:(13230031)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?iMkSXBVtBK71Yxzm5N7iNtzSLC7/Zn9QSpdpRO+QqKrj4Yj6apuBtljKtW65?= =?us-ascii?Q?pOcd50KlVH8UaWQME5iUsxaHvMJMKbio/68u1et+oDKzpJKorRLdvwDvOlAo?= =?us-ascii?Q?Bic8aJZdEWKi9KTpPEaz2mfsd6IFE6Upk/YS0T0DDEF8ICjQvDjRZ8fc5Vtj?= =?us-ascii?Q?OPWe+wFJOs7tburcqqfWzjfebevqEdUo7V4mNsVnza4SrP4xptqxxHLCJBoN?= =?us-ascii?Q?qUN4mBbNyb2hA72kxVD/x74tIdfMOwAYQwtI9/92Fu9x5BrCKEuihVP5pDud?= =?us-ascii?Q?bWPjG1xF0h/o/XHAeX01WTe3y62LNldw0/4qtz4g1hK7JUsHEQ9zaUBvRJYA?= =?us-ascii?Q?8xiU38HgT/HqMa26ZLpJ+55ALcppvi2CLKZWheIoTH/pB5xdSSPAS3Czwo+U?= =?us-ascii?Q?0fKMLCc5zsOnX9u+dYSJTYLNeW23Lp6ZJxOg8KDyHDcgT3cFYCJsMxQVB0AP?= =?us-ascii?Q?OqysK8+dVx/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=?us-ascii?Q?YuM7VS9FKp8qu3u/uEKln0N0mTlUCkAwDTa/6YL6UReUHeSKAsINRKN8RsmI?= =?us-ascii?Q?W8Ql5sbKGTuCiuLaCH7J1XCUTg1jzCClYP106jdUXgmgd1ykYQn4XDNGtxEw?= =?us-ascii?Q?3dyOeucR45UKkrMOq6RfiQMi7bbHU05byz4/Ny1v4EMJM6Wzq42JasKLdrfZ?= =?us-ascii?Q?ZhmdH2vdoJYIm0Gr2vxd07ppiPvS18ElWp6F1LxHDVfKSj0hzX3irIOw1+yu?= =?us-ascii?Q?VQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f89c3f5-37fc-4bec-8fd6-08dc366c9c4e X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Feb 2024 01:45:28.9359 (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: Gr5B2AYGOMTninFqRHHBSKeP8/sf4fKryX6u4UNtrhXZ5BWEogK3WeFk+g0mc0W20pUoNtEGfthw/er5ayr28QAuqnzU5pnIYYMlzaL5wiI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5794 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 Add the corresponding logics to support the offload of RSS action. Signed-off-by: Long Wu Reviewed-by: Chaoyong He Reviewed-by: Peng Zhang --- doc/guides/nics/features/nfp.ini | 1 + drivers/net/nfp/flower/nfp_flower_flow.c | 124 ++++++++++++++++++ drivers/net/nfp/flower/nfp_flower_flow.h | 8 ++ .../net/nfp/flower/nfp_flower_representor.c | 6 + .../net/nfp/flower/nfp_flower_representor.h | 1 + 5 files changed, 140 insertions(+) diff --git a/doc/guides/nics/features/nfp.ini b/doc/guides/nics/features/nfp.ini index 3494111f86..b20049b4f5 100644 --- a/doc/guides/nics/features/nfp.ini +++ b/doc/guides/nics/features/nfp.ini @@ -59,6 +59,7 @@ queue = Y raw_decap = Y raw_encap = Y represented_port = Y +rss = Y port_id = Y set_ipv4_dscp = Y set_ipv4_dst = Y diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c index b3a2c1cdaf..086cc8079a 100644 --- a/drivers/net/nfp/flower/nfp_flower_flow.c +++ b/drivers/net/nfp/flower/nfp_flower_flow.c @@ -1143,6 +1143,9 @@ nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[], key_ls->act_size += sizeof(struct nfp_fl_act_mark); PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_MARK detected"); break; + case RTE_FLOW_ACTION_TYPE_RSS: + PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_RSS detected"); + break; default: PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type); return -ENOTSUP; @@ -3509,6 +3512,116 @@ nfp_flow_action_mark(char *act_data, fl_mark->mark = rte_cpu_to_be_32(mark->id); } +static int +nfp_flow_action_rss_add(struct nfp_flower_representor *representor, + const struct rte_flow_action *action, + struct nfp_fl_rss **rss_store) +{ + int ret; + struct nfp_net_hw *pf_hw; + struct rte_eth_rss_conf rss_conf; + struct nfp_fl_rss *rss_store_tmp; + const struct rte_flow_action_rss *rss; + uint8_t rss_key[NFP_NET_CFG_RSS_KEY_SZ]; + + if (nfp_flower_repr_is_vf(representor)) + return 0; + + rss = action->conf; + + if (rss->key_len > NFP_NET_CFG_RSS_KEY_SZ) { + PMD_DRV_LOG(ERR, "Unsupported rss key length."); + return -ENOTSUP; + } + + rss_conf.rss_hf = 0; + rss_conf.rss_key = rss_key; + pf_hw = representor->app_fw_flower->pf_hw; + ret = nfp_net_rss_hash_conf_get(pf_hw->eth_dev, &rss_conf); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Get RSS conf failed."); + return ret; + } + + rss_store_tmp = calloc(1, sizeof(struct nfp_fl_rss)); + if (rss_store_tmp == NULL) { + PMD_DRV_LOG(ERR, "Alloc memory for rss storage failed."); + return -ENOMEM; + } + + if (rss->types != 0) { + rss_conf.rss_hf |= rss->types; + + rss_store_tmp->types = rss->types; + } + + if (rss->key_len != 0 && rss->key != NULL) { + memcpy(rss_conf.rss_key, rss->key, rss->key_len); + rss_conf.rss_key_len = rss->key_len; + + memcpy(rss_store_tmp->key, rss->key, rss->key_len); + rss_store_tmp->key_len = rss->key_len; + } + + ret = nfp_net_rss_hash_update(pf_hw->eth_dev, &rss_conf); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Update RSS conf failed."); + free(rss_store_tmp); + return ret; + } + + *rss_store = rss_store_tmp; + + return 0; +} + +static int +nfp_flow_action_rss_del(struct nfp_flower_representor *representor, + struct rte_flow *nfp_flow) +{ + int ret; + struct nfp_net_hw *pf_hw; + struct nfp_fl_rss *rss_store; + struct rte_eth_rss_conf rss_conf; + uint8_t rss_key[NFP_NET_CFG_RSS_KEY_SZ]; + + if (nfp_flower_repr_is_vf(representor)) + return 0; + + rss_conf.rss_hf = 0; + rss_conf.rss_key = rss_key; + pf_hw = representor->app_fw_flower->pf_hw; + ret = nfp_net_rss_hash_conf_get(pf_hw->eth_dev, &rss_conf); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Get RSS conf failed."); + goto exit; + } + + rss_store = nfp_flow->rss; + + if ((rss_conf.rss_hf & rss_store->types) != 0) + rss_conf.rss_hf &= (~(rss_store->types)); + + /* Need default RSS configuration */ + if (rss_conf.rss_hf == 0) + rss_conf.rss_hf = RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_IPV6; + + if (rss_conf.rss_key_len == rss_store->key_len && + memcmp(rss_conf.rss_key, rss_store->key, rss_store->key_len) == 0) { + rss_conf.rss_key = NULL; + rss_conf.rss_key_len = 0; + } + + ret = nfp_net_rss_hash_update(pf_hw->eth_dev, &rss_conf); + if (ret != 0) + PMD_DRV_LOG(ERR, "Update RSS conf failed."); + +exit: + free(nfp_flow->rss); + + return ret; +} + static uint32_t nfp_flow_count_output(const struct rte_flow_action actions[]) { @@ -3761,6 +3874,13 @@ nfp_flow_compile_action(struct nfp_flower_representor *representor, nfp_flow_action_mark(position, action); position += sizeof(struct nfp_fl_act_mark); break; + case RTE_FLOW_ACTION_TYPE_RSS: + PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_RSS"); + ret = nfp_flow_action_rss_add(representor, action, &nfp_flow->rss); + if (ret != 0) + return ret; + nfp_flow->type = NFP_FLOW_RSS; + break; default: PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type); return -ENOTSUP; @@ -4099,6 +4219,10 @@ nfp_flow_destroy(struct rte_eth_dev *dev, /* Delete the entry in pre tunnel table */ ret = nfp_pre_tun_table_check_del(representor, nfp_flow); break; + case NFP_FLOW_RSS: + /* Clear corresponding RSS configuration */ + ret = nfp_flow_action_rss_del(representor, nfp_flow); + break; default: PMD_DRV_LOG(ERR, "Invalid nfp flow type %d.", nfp_flow->type); ret = -EINVAL; diff --git a/drivers/net/nfp/flower/nfp_flower_flow.h b/drivers/net/nfp/flower/nfp_flower_flow.h index 75f18c6bd5..5d927edde9 100644 --- a/drivers/net/nfp/flower/nfp_flower_flow.h +++ b/drivers/net/nfp/flower/nfp_flower_flow.h @@ -33,6 +33,7 @@ enum nfp_flow_type { NFP_FLOW_COMMON, NFP_FLOW_ENCAP, NFP_FLOW_DECAP, + NFP_FLOW_RSS, }; struct nfp_fl_key_ls { @@ -121,6 +122,12 @@ struct nfp_ipv6_addr_entry { int ref_count; }; +struct nfp_fl_rss { + uint8_t key[NFP_NET_CFG_RSS_KEY_SZ]; + uint32_t key_len; + uint64_t types; +}; + #define NFP_TUN_PRE_TUN_RULE_LIMIT 32 struct nfp_flow_priv { @@ -166,6 +173,7 @@ struct nfp_flow_priv { struct rte_flow { struct nfp_fl_payload payload; struct nfp_fl_tun tun; + struct nfp_fl_rss *rss; size_t length; uint32_t hash_key; uint32_t mtr_id; diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index 7284a1e84d..b2c55879ca 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -860,3 +860,9 @@ nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower) return ret; } + +bool +nfp_flower_repr_is_vf(struct nfp_flower_representor *repr) +{ + return repr->repr_type == NFP_REPR_TYPE_VF; +} diff --git a/drivers/net/nfp/flower/nfp_flower_representor.h b/drivers/net/nfp/flower/nfp_flower_representor.h index 8053617562..7a4e7ecfc1 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.h +++ b/drivers/net/nfp/flower/nfp_flower_representor.h @@ -24,5 +24,6 @@ struct nfp_flower_representor { }; int nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower); +bool nfp_flower_repr_is_vf(struct nfp_flower_representor *repr); #endif /* __NFP_FLOWER_REPRESENTOR_H__ */ -- 2.39.1