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 4E63843B91; Fri, 23 Feb 2024 03:43:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 956A44113D; Fri, 23 Feb 2024 03:42:54 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2115.outbound.protection.outlook.com [40.107.244.115]) by mails.dpdk.org (Postfix) with ESMTP id 8C44C40EDF for ; Fri, 23 Feb 2024 03:42:46 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S4aYJPgGt6FrNKUSp6eZOa1FdTUqpqXAqdDyFLmOjOgqZHL7L4exVYr6lWD7Y/utruvksSU1buH8xeoTxNedvyLlj1WhNLAjWASYl87OWUbmJM8Zc5UXEAJndoWgSTi0iuOU2scZqx7SH1NtOn2JUXFhj9aGD5kyvafQ3Z4RX4QKZZrR9oBc+aBkL2ZNPG92Sunwgo4w3SezgaTH6YHAwBBjBPm7I1Gqok4Z85efOygC7KdaaqPkrg6vHtZ4hGHVS1CS8VpXIC10I/HofKMJJxmuITg7kNxlOu/XWO1bV8MHjQd+JGIO04zeWXDx1EnN6yAFILBTyAL/HGzqJHlc+w== 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=kynyfO8Jz3442pdrfInFC1oFQO/XUoXwmbbNh8eAV/T9Z3tEyS/ARjDMS83D637uXn5tmzLvA/3EslAuZcDfzLKVvo56xV7Mkp45ju296aCmFfRyN51T78k8MV9BAxncSmrH7khxse3uakBAbnm1tS1GwdC1y15N6O+UsibYnm8TpJMuMVczPfSBKbvN1jnFX4XWuipahPUkaf6UmugNtSUzNMyPKPysrQgtDrQ/6Z1ipjDK2YrARqjWfNupu91uC/Yu6SXVS3AbIFeygc6Wc12okfzXBb9QkCCljSnSnLea8ctm/Og1t/V8f+S8yHXa4QHqKnl2N+Z0d/9rXRIZZA== 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=WktUGfTspTO57I9lKLwShYkHa2vG088UawJGw6hSdI2EVpWtDhmip4Cg2tFT5vBI/yBssWzXzjxkV1knrX4f0IXvY+bW6yR8Wl7nEt1gbxizovkUOS6cm2crmP7fKvZNYQLsXYUg3z8ToCrJLpKrTrZQo160aW6xTQ66Ypc/B9o= 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 SA1PR13MB6645.namprd13.prod.outlook.com (2603:10b6:806:3e6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.24; Fri, 23 Feb 2024 02:42:44 +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.023; Fri, 23 Feb 2024 02:42:44 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Long Wu , Chaoyong He , Peng Zhang Subject: [PATCH v2 4/4] net/nfp: support RSS flow action Date: Fri, 23 Feb 2024 10:42:17 +0800 Message-Id: <20240223024217.3052031-5-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240223024217.3052031-1-chaoyong.he@corigine.com> References: <20240210104214.1248772-1-chaoyong.he@corigine.com> <20240223024217.3052031-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR13CA0040.namprd13.prod.outlook.com (2603:10b6:a03:2c2::15) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|SA1PR13MB6645:EE_ X-MS-Office365-Filtering-Correlation-Id: bf28b7d2-dc83-451a-2b20-08dc34191ca1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hWPdRjvKBYZC1xdV4n31o1BgE2xGar7TmzXXoq0WLC63T1IYjHBgK+08v9xVkqa3rzU4Rm9N2nUOTgzAkwaZT2VGUfEhxf/12rc6Hp5CMv7EKh+1ESXF8kNyhOF62KhMYF1PhOqGfvQ7aSWtTaw49Vt98rSBFuwuIMYdYzi41bdCZVCGqdv3tu2I0GI8YTR/vTSEDkdLZ6GVy9KlMYEGJmU3gS9LT8nTZ6z40wfuO3ofs9gDVCKw3cxlQuhtxk41mvZGTT+k0/+vnTarfMURYaLX3id/gFB9oui3pH058qunaXu9jeatP10rPAu9rEDriuLe7vvAUX1YdPT2piBaZAe+qivd9m/C9mOGOSUHR6yUH1L/zl4kDyzW4k0xfkb+pXZYloLnf0h7S31JlMOnBr2lrzp47bPWoCrPGw5qLpxVHzuxXA38DqPYrUrf26VGvLS3xKTvOUHnERC0bLcPZ30jrqxNBbKaUrzGiiJTM+grYa18Wwcfe80/fm9L7eG8e6aiRzgaDeBtvt4JjIV4eGspDYaLzQUxZK8N7c8iE5kI9a2ZpU6IN+HxBHoqyjV++V29i/PaO3tGaZJI5/hD94AZZozXaSdwn8bQtuPLLh1w2X4TVLdUUmXQPtTKd5Yl 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?TRgRs/j3tTOboMrACqkBsVSLM1kexAI+n8TIHBKj5VJmyKebfryVmWBkzeP/?= =?us-ascii?Q?HURB52iyKWqPqs/Lzg0Pt5Tj6zH/qbv8S97uORId7X7sX7qIJ7Yny8Bc9TcU?= =?us-ascii?Q?/OstqrbVvUNQUH07Sh0n2tqpDBg+cFl3jRjLxHM1eX1xg+GZuRyVTGXimEpY?= =?us-ascii?Q?u1GUboUM0dkDtuen+/rzQrHUk5SM0If3OS5Q6xMr+JXEBJ1dV3urjGMd/9tR?= =?us-ascii?Q?yaS2guCKnXMyFdGR1bKucfjdAXOYNs85E3wXI+8bb+xnC/2Fzx9qa7dzgqr7?= =?us-ascii?Q?XlyQyLwxqdYV14skgOjIpKkvOJN1Vg/ZIiALsnPLgAL6gbwWN2ww7syHNv5Z?= =?us-ascii?Q?QnwNa0Z8DodYp//cVpv5JkgxFF1yv+8frkx9EXnUvArEhEA3Eg9Qf8eaSlq5?= =?us-ascii?Q?F7/EsKgYO6HNMmJCTih8EZ2TTuTH7xH+/4QGnHZkR/eu3Pii0PA1trfP90GH?= =?us-ascii?Q?IG3T48iSpUTVJe4P1vhc+HtVQ1lRye6vs4DHZM9inAw+koHgs74Xr7NvbsPX?= =?us-ascii?Q?xAN/HxErpiZZlW1K39g5NXc3JdPv3k6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3aj429P/JrS/9oQGcLOjTSFu9A100AxEGCVeud1SSJxCUAriut?= =?us-ascii?Q?Y0UyOrQztJnJlEcagL6M4YANLHr1Cu7OsVmFSBhAGM1vi3WeKRVses72d3dd?= =?us-ascii?Q?v5TKZhGyb6/cfY1x8E00vokvJ3zY+anKpVAyDnwcLqnyLcR1GjrA9J59Zfsq?= =?us-ascii?Q?Qg=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: bf28b7d2-dc83-451a-2b20-08dc34191ca1 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2024 02:42:44.1662 (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: w8+ZkZ/I7EuOtFMrc++lt/kaKhdeZIC6sstLb2q0Ryd5j9cA45iX5GrV60O1R+1yjsuuVIHsbkX1jVotMOJXAFYUvrj8n/x56PMBybZws6M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR13MB6645 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