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 BEDAB45BA3; Tue, 22 Oct 2024 19:31:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 11AB340E41; Tue, 22 Oct 2024 19:30:51 +0200 (CEST) Received: from egress-ip42b.ess.de.barracuda.com (egress-ip42b.ess.de.barracuda.com [18.185.115.246]) by mails.dpdk.org (Postfix) with ESMTP id 80F9F40A80 for ; Tue, 22 Oct 2024 19:30:47 +0200 (CEST) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02lp2041.outbound.protection.outlook.com [104.47.11.41]) by mx-outbound19-119.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 Oct 2024 17:30:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CQQJdBnh9Hcyn06ilY/Wdn/hbxCPNr+BrJawspA5EXNGcJSi4aJBOSeA9mUsyXxwtXVFVjrpSDDGIDlE93KqPdc0RxUCxvweZ63ml0f3v9vLXopdo2sJ/o96Ve/KYUipWmk3qt7vya7mJTaofB1o6PdnpUkS4uqa5ClTGPPWrKe6oZ97AaqIwjTQ8h33oX5NYX9H/ksPSDFru7DnjDj1gnQa9qoGizj2VUv976oEeEGWLNCOJkvLFTn7KYwZ9Sko2znOI7hU9gne74iqT+G5BUjSJdmgr0TnmSio6aPtMbyoe5JZLvNM0Uzg7UjvZzKsVGZ/cD4o3C9Ww4NoACwbaA== 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=/tB7CJEZ+v59rYQLX/sUkC2rymuCDByCVWL2+SYTC6M=; b=TK8ij1VWkDS92yskOIjQLzPpuIul9kbDmqN+vXVgWfgYX4kvVOVuiWheDIyhQzf0+VRmD34p/BsayA0jkxTAhrbLHFtWycmugU5qyIi3tiEBlsiDU6rR/csEt06WpnkU6zytSXjL3pZPa1A9zVWEPOJTaYW9c+KIuOlwCWn97SlPmcWahHfiwwLs8w7MOxz+BVD9tozGcxcqdrvxw9Tvkj3+SfhMH4m0F/rWqtOr7u/3l8bmUprLMOHwKG6gKEXMpUQAH5MZ9wBQzeqqq1yaN3fWXFezJcC4ZEj1RQocS4RzoQtRBLWSnjQnZR9MK8zDUg8iK7ydyc/h6JYvgm1rhA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 178.72.21.4) smtp.rcpttodomain=dpdk.org smtp.mailfrom=napatech.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=napatech.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=napatech.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/tB7CJEZ+v59rYQLX/sUkC2rymuCDByCVWL2+SYTC6M=; b=o5pMpNTQHCSlYxaSsl3CjOImKvWAGXFvju66ffJDiWTMTGY7yTs0b/RCPnC0ikNAK9wDJVVqLn3JXLnuj5alnPk6O5luUHZMnKNzcDO5rqeVQ0R5URJqxvSfMIsQ1JAhvhcFjaXbmDFi21tdiWyhNRgKuROS/7NHb9dY5mXoaYU= Received: from DB9PR06CA0025.eurprd06.prod.outlook.com (2603:10a6:10:1db::30) by AS8P190MB1142.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:2ee::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Tue, 22 Oct 2024 16:57:01 +0000 Received: from DU2PEPF0001E9C2.eurprd03.prod.outlook.com (2603:10a6:10:1db:cafe::e8) by DB9PR06CA0025.outlook.office365.com (2603:10a6:10:1db::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Tue, 22 Oct 2024 16:56:54 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by DU2PEPF0001E9C2.mail.protection.outlook.com (10.167.8.71) with Microsoft SMTP Server id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 16:56:54 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com, stephen@networkplumber.org Subject: [PATCH v2 53/73] net/ntnic: enable RSS feature Date: Tue, 22 Oct 2024 18:55:10 +0200 Message-ID: <20241022165541.3186140-54-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241022165541.3186140-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241022165541.3186140-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF0001E9C2:EE_|AS8P190MB1142:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: d81c90b5-391d-44f3-fa32-08dcf2ba887e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?JB+7nxrGEr2dflHDpp0GAxiowNL86TnRkXJnCSnXhSjFjPdwI6xS4JDK+nE6?= =?us-ascii?Q?I3KrUKckoPeAlKKyv9hb0aUQS2r9WKZ3DK+cDKbU9BVBtQd5m8ukLYepvmXL?= =?us-ascii?Q?3OCohRTMBoH5f2ByyBy28M0FYkbH0tJlPw2YgQE8tIF6Bju2I6I0UzGgegoU?= =?us-ascii?Q?lnK+3ztskbkE+Z/Xld2dcO04UouyOmwsN6qF4ru8AI6fAQsOgzivkqUaFf4u?= =?us-ascii?Q?G7HVoO5x2xbXUBBSsv/Pkgd+JmDZsi9EvJubb85TTlvuN1qkcN70BBcXl2w2?= =?us-ascii?Q?yDRdzHqyTnkiQdbIgL68okXFQMGbDcLJjpXfuqVRYoBxkO7xnwVjSw13a5Nh?= =?us-ascii?Q?7EjFnvExYAdrHadV19QGwXmr/DxSQT+aXfG44aSAewhVSCFnmdDyDF8TZa/T?= =?us-ascii?Q?WmfB8asbxhgjLNmx+qEX5UsXgSHvScekwco9ztcHNUgTriRLFegAkSLgk0OT?= =?us-ascii?Q?nqV+1TBiT9DVxckv2EGs0F7yLlNYak21Ko2WZvxk0MLRIYNaMXSKUVGghMYY?= =?us-ascii?Q?kPtEnDN5wgCAuEN93zqlJrbd1U55yGUOvgICm0zySzkBeDeIftM6eDt0gCBK?= =?us-ascii?Q?0ZYoxkpRpDx85bk7mRKVBXe8QMfFcBylp2CHzPOfS3LQgf4+19A9Xd3u/fQU?= =?us-ascii?Q?usp7vstvdCP1+nbdlqbzkO38A4SoFDtLPdcsbwtwMI069xdCVZyZPGLIBXKQ?= =?us-ascii?Q?Cf9RUjLVcbfqm57n6Dfa+7t/DxAiO09wvASprpAdO1L17JNiPzOKogDWIjkR?= =?us-ascii?Q?8uwRI9xuYMmuRkFPX3Aj8tPbVnZ0Z/hhjSpLkSmZlaoUCpuQwe3RqsepQT7T?= =?us-ascii?Q?djdWYxpDJ1blHzNcSToLpzTabusMtvF1bbDRj0kmB69nkEanm+0n4jeTA6eD?= =?us-ascii?Q?/guhzjVPdD0NxyOhvSeY5etRtLR/jiLCJN1No//J5Bmzkzyb6FnmcdE1ONwX?= =?us-ascii?Q?wV/kqXMa2s3CZ/YDMSBVxdZP2WwMe30rEr8pP/icE7wy2omZIEVlCsjc35FW?= =?us-ascii?Q?/Mz52qL+1ZPfms0FV9lXYotCymbA8kEQ01VgpGrCXzMfRZ5AByYrexyUwspl?= =?us-ascii?Q?11pxRgnM7Yt8WYeHwEjhOuLnYfdtaBh7hzDkzH17bQBtvK29nm87I1Z0D0tV?= =?us-ascii?Q?juhPFQvQBg4A3/KPJRhEppJ0TMZOyqwFkxtojdCN36Q8aE7PEgVJLLLQHsLY?= =?us-ascii?Q?B4JVllQXCqTRaqKUHR8bImtg9VQPB1Fp9T5XfNimqWnsADtaT2dgjefFgq2N?= =?us-ascii?Q?z7lSA+7xZytnAlSaTNjy9VUzTCI/mrqXh+aYxi7l4gvqKJuc42dW4c/k800E?= =?us-ascii?Q?L58dU+EWvZNDqpCtbK7wTMeXZpOUX74fLlqpwUEgDI/Ut4lzfZoYpiColxAO?= =?us-ascii?Q?4jTaaFQ+CU/3HKp+ohcK5vWZCc2rz8iq/EmXL1LvE6CJWeC4XQ=3D=3D?= X-Forefront-Antispam-Report: CIP:178.72.21.4; CTRY:DK; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:localhost.localdomain; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(36860700013)(376014)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: eb/eTdH+ZlqKYQCK6jdu4LyNC20YS4UYJhhGgzSNmfQvA7jTqBy4RcZtNkjh6MA9hKOqXUhHq+qH//3Z3tsgDF2AYrqeAW8qAok10dVTZvha5lqXbnO9cmPHbRvFtlpx6JJKfkOth+IuISm+0hzsePdizjyz+FDvwzhN0p1tymkuMSGxbWDmCVEgA5HPx1OYJFGuYvuiZ+wkdJmoj6M+aN8/ELsY0MoFTMaeZFwn5YPkFG5fMNwwyTJ1Ri+X/KiApuFCqrvdt9d5H1lVD3xwf2r+gX+4Inuj9/x1hT3WQu3SHHD8WkLCujps5DhuqedtEarh1nzcaa0oX+tEoNMDMcpQdQVsWBi+S2N5EELrIZaXbWKdTHbO4Idzox2Ffe2/X1XWdi5c5CKK6SdV+ZG85ExRA0HWe+YSxo4mmwVmYTgdChLhBSQy8N2+EZMRElF4hDKbI8hjIKB1FC6WDmYoxliW/DyqBlGE2/CjE0bChAFWi+3UcdDCDZMBGevOiOQRrUA9Zy/R+iGd7r+ey1n2yoXUw1awkX+5pXv+6UiTs4aM5w3ijYg/sPpctIBngRYGukaHXe2+pBARVNjyBUQJKBswW6VlpjyKQ972i4wRYrQ2WM7orGcbeglueEVUvm5jBspEHsZ5hosUJPJq84YKTMMXFFdRaAcKtIofqZyMITs= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 16:56:54.4817 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d81c90b5-391d-44f3-fa32-08dcf2ba887e X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF0001E9C2.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P190MB1142 X-OriginatorOrg: napatech.com X-BESS-ID: 1729618246-304983-12656-16024-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.11.41 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaGxubmQGYGUNTE2NLCONEwxS AxzSTVwNgk1TApxcwy0TTZJNEsycTSUKk2FgBnh3SCQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259902 [from cloudscan10-242.eu-central-1a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 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 Enable receive side scaling Signed-off-by: Serhii Iliushyk --- doc/guides/nics/features/ntnic.ini | 3 + drivers/net/ntnic/include/create_elements.h | 1 + drivers/net/ntnic/include/flow_api.h | 2 + drivers/net/ntnic/nthw/flow_api/flow_api.c | 6 ++ .../profile_inline/flow_api_profile_inline.c | 43 +++++++++++ drivers/net/ntnic/ntnic_ethdev.c | 77 +++++++++++++++++++ drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 73 ++++++++++++++++++ drivers/net/ntnic/ntnic_mod_reg.h | 7 ++ 8 files changed, 212 insertions(+) diff --git a/doc/guides/nics/features/ntnic.ini b/doc/guides/nics/features/ntnic.ini index 4cb9509742..e5d5abd0ed 100644 --- a/doc/guides/nics/features/ntnic.ini +++ b/doc/guides/nics/features/ntnic.ini @@ -10,6 +10,8 @@ Link status = Y Queue start/stop = Y Unicast MAC filter = Y Multicast MAC filter = Y +RSS hash = Y +RSS key update = Y Linux = Y x86-64 = Y @@ -37,3 +39,4 @@ port_id = Y queue = Y raw_decap = Y raw_encap = Y +rss = Y diff --git a/drivers/net/ntnic/include/create_elements.h b/drivers/net/ntnic/include/create_elements.h index 70e6cad195..eaa578e72a 100644 --- a/drivers/net/ntnic/include/create_elements.h +++ b/drivers/net/ntnic/include/create_elements.h @@ -27,6 +27,7 @@ struct cnv_attr_s { struct cnv_action_s { struct rte_flow_action flow_actions[MAX_ACTIONS]; + struct rte_flow_action_rss flow_rss; struct flow_action_raw_encap encap; struct flow_action_raw_decap decap; struct rte_flow_action_queue queue; diff --git a/drivers/net/ntnic/include/flow_api.h b/drivers/net/ntnic/include/flow_api.h index 2e96fa5bed..4a1525f237 100644 --- a/drivers/net/ntnic/include/flow_api.h +++ b/drivers/net/ntnic/include/flow_api.h @@ -114,6 +114,8 @@ struct flow_nic_dev { struct flow_eth_dev *eth_base; pthread_mutex_t mtx; + /* RSS hashing configuration */ + struct nt_eth_rss_conf rss_conf; /* next NIC linked list */ struct flow_nic_dev *next; }; diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c b/drivers/net/ntnic/nthw/flow_api/flow_api.c index 34f2cad2cd..d61044402d 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -1061,6 +1061,12 @@ static const struct flow_filter_ops ops = { .flow_destroy = flow_destroy, .flow_flush = flow_flush, .flow_dev_dump = flow_dev_dump, + + /* + * Other + */ + .hw_mod_hsh_rcp_flush = hw_mod_hsh_rcp_flush, + .flow_nic_set_hasher_fields = flow_nic_set_hasher_fields, }; void init_flow_filter(void) diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c index 1dfd96eaac..bbf450697c 100644 --- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c +++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c @@ -603,6 +603,49 @@ static int interpret_flow_actions(const struct flow_eth_dev *dev, break; + case RTE_FLOW_ACTION_TYPE_RSS: + NT_LOG(DBG, FILTER, "Dev:%p: RTE_FLOW_ACTION_TYPE_RSS", dev); + + if (action[aidx].conf) { + struct rte_flow_action_rss rss_tmp; + const struct rte_flow_action_rss *rss = + memcpy_mask_if(&rss_tmp, action[aidx].conf, + action_mask ? action_mask[aidx].conf : NULL, + sizeof(struct rte_flow_action_rss)); + + if (rss->key_len > MAX_RSS_KEY_LEN) { + NT_LOG(ERR, FILTER, + "ERROR: RSS hash key length %u exceeds maximum value %u", + rss->key_len, MAX_RSS_KEY_LEN); + flow_nic_set_error(ERR_RSS_TOO_LONG_KEY, error); + return -1; + } + + for (uint32_t i = 0; i < rss->queue_num; ++i) { + int hw_id = rx_queue_idx_to_hw_id(dev, rss->queue[i]); + + fd->dst_id[fd->dst_num_avail].owning_port_id = dev->port; + fd->dst_id[fd->dst_num_avail].id = hw_id; + fd->dst_id[fd->dst_num_avail].type = PORT_VIRT; + fd->dst_id[fd->dst_num_avail].active = 1; + fd->dst_num_avail++; + } + + fd->hsh.func = rss->func; + fd->hsh.types = rss->types; + fd->hsh.key = rss->key; + fd->hsh.key_len = rss->key_len; + + NT_LOG(DBG, FILTER, + "Dev:%p: RSS func: %d, types: 0x%" PRIX64 ", key_len: %d", + dev, rss->func, rss->types, rss->key_len); + + fd->full_offload = 0; + *num_queues += rss->queue_num; + } + + break; + case RTE_FLOW_ACTION_TYPE_MARK: NT_LOG(DBG, FILTER, "Dev:%p: RTE_FLOW_ACTION_TYPE_MARK", dev); diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index bfca8f28b1..1b25621537 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -214,6 +214,14 @@ eth_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *dev_info dev_info->max_rx_pktlen = HW_MAX_PKT_LEN; dev_info->max_mtu = MAX_MTU; + if (p_adapter_info->fpga_info.profile == FPGA_INFO_PROFILE_INLINE) { + dev_info->flow_type_rss_offloads = NT_ETH_RSS_OFFLOAD_MASK; + dev_info->hash_key_size = MAX_RSS_KEY_LEN; + + dev_info->rss_algo_capa = RTE_ETH_HASH_ALGO_CAPA_MASK(DEFAULT) | + RTE_ETH_HASH_ALGO_CAPA_MASK(TOEPLITZ); + } + if (internals->p_drv) { dev_info->max_rx_queues = internals->nb_rx_queues; dev_info->max_tx_queues = internals->nb_tx_queues; @@ -1372,6 +1380,73 @@ promiscuous_enable(struct rte_eth_dev __rte_unused(*dev)) return 0; } +static int eth_dev_rss_hash_update(struct rte_eth_dev *eth_dev, struct rte_eth_rss_conf *rss_conf) +{ + const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops(); + + if (flow_filter_ops == NULL) { + NT_LOG_DBGX(ERR, NTNIC, "flow_filter module uninitialized"); + return -1; + } + + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; + + struct flow_nic_dev *ndev = internals->flw_dev->ndev; + struct nt_eth_rss_conf tmp_rss_conf = { 0 }; + const int hsh_idx = 0; /* hsh index 0 means the default receipt in HSH module */ + int res = 0; + + if (rss_conf->rss_key != NULL) { + if (rss_conf->rss_key_len > MAX_RSS_KEY_LEN) { + NT_LOG(ERR, NTNIC, + "ERROR: - RSS hash key length %u exceeds maximum value %u", + rss_conf->rss_key_len, MAX_RSS_KEY_LEN); + return -1; + } + + rte_memcpy(&tmp_rss_conf.rss_key, rss_conf->rss_key, rss_conf->rss_key_len); + } + + tmp_rss_conf.algorithm = rss_conf->algorithm; + + tmp_rss_conf.rss_hf = rss_conf->rss_hf; + res = flow_filter_ops->flow_nic_set_hasher_fields(ndev, hsh_idx, tmp_rss_conf); + + if (res == 0) { + flow_filter_ops->hw_mod_hsh_rcp_flush(&ndev->be, hsh_idx, 1); + rte_memcpy(&ndev->rss_conf, &tmp_rss_conf, sizeof(struct nt_eth_rss_conf)); + + } else { + NT_LOG(ERR, NTNIC, "ERROR: - RSS hash update failed with error %i", res); + } + + return res; +} + +static int rss_hash_conf_get(struct rte_eth_dev *eth_dev, struct rte_eth_rss_conf *rss_conf) +{ + struct pmd_internals *internals = (struct pmd_internals *)eth_dev->data->dev_private; + struct flow_nic_dev *ndev = internals->flw_dev->ndev; + + rss_conf->algorithm = (enum rte_eth_hash_function)ndev->rss_conf.algorithm; + + rss_conf->rss_hf = ndev->rss_conf.rss_hf; + + /* + * copy full stored key into rss_key and pad it with + * zeros up to rss_key_len / MAX_RSS_KEY_LEN + */ + if (rss_conf->rss_key != NULL) { + int key_len = rss_conf->rss_key_len < MAX_RSS_KEY_LEN ? rss_conf->rss_key_len + : MAX_RSS_KEY_LEN; + memset(rss_conf->rss_key, 0, rss_conf->rss_key_len); + rte_memcpy(rss_conf->rss_key, &ndev->rss_conf.rss_key, key_len); + rss_conf->rss_key_len = key_len; + } + + return 0; +} + static const struct eth_dev_ops nthw_eth_dev_ops = { .dev_configure = eth_dev_configure, .dev_start = eth_dev_start, @@ -1395,6 +1470,8 @@ static const struct eth_dev_ops nthw_eth_dev_ops = { .set_mc_addr_list = eth_set_mc_addr_list, .flow_ops_get = dev_flow_ops_get, .promiscuous_enable = promiscuous_enable, + .rss_hash_update = eth_dev_rss_hash_update, + .rss_hash_conf_get = rss_hash_conf_get, }; /* diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c index 87b26bd315..4962ab8d5a 100644 --- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -317,6 +317,79 @@ int create_action_elements_inline(struct cnv_action_s *action, * Non-compatible actions handled here */ switch (type) { + case RTE_FLOW_ACTION_TYPE_RSS: { + const struct rte_flow_action_rss *rss = + (const struct rte_flow_action_rss *)actions[aidx].conf; + + switch (rss->func) { + case RTE_ETH_HASH_FUNCTION_DEFAULT: + action->flow_rss.func = + (enum rte_eth_hash_function) + RTE_ETH_HASH_FUNCTION_DEFAULT; + break; + + case RTE_ETH_HASH_FUNCTION_TOEPLITZ: + action->flow_rss.func = + (enum rte_eth_hash_function) + RTE_ETH_HASH_FUNCTION_TOEPLITZ; + + if (rte_is_power_of_2(rss->queue_num) == 0) { + NT_LOG(ERR, FILTER, + "RTE ACTION RSS - for Toeplitz the number of queues must be power of two"); + return -1; + } + + break; + + case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: + case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ: + case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT: + case RTE_ETH_HASH_FUNCTION_MAX: + default: + NT_LOG(ERR, FILTER, + "RTE ACTION RSS - unsupported function: %u", + rss->func); + return -1; + } + + uint64_t tmp_rss_types = 0; + + switch (rss->level) { + case 1: + /* clear/override level mask specified at types */ + tmp_rss_types = rss->types & (~RTE_ETH_RSS_LEVEL_MASK); + action->flow_rss.types = + tmp_rss_types | RTE_ETH_RSS_LEVEL_OUTERMOST; + break; + + case 2: + /* clear/override level mask specified at types */ + tmp_rss_types = rss->types & (~RTE_ETH_RSS_LEVEL_MASK); + action->flow_rss.types = + tmp_rss_types | RTE_ETH_RSS_LEVEL_INNERMOST; + break; + + case 0: + /* keep level mask specified at types */ + action->flow_rss.types = rss->types; + break; + + default: + NT_LOG(ERR, FILTER, + "RTE ACTION RSS - unsupported level: %u", + rss->level); + return -1; + } + + action->flow_rss.level = 0; + action->flow_rss.key_len = rss->key_len; + action->flow_rss.queue_num = rss->queue_num; + action->flow_rss.key = rss->key; + action->flow_rss.queue = rss->queue; + action->flow_actions[aidx].conf = &action->flow_rss; + } + break; + case RTE_FLOW_ACTION_TYPE_RAW_DECAP: { const struct rte_flow_action_raw_decap *decap = (const struct rte_flow_action_raw_decap *)actions[aidx] diff --git a/drivers/net/ntnic/ntnic_mod_reg.h b/drivers/net/ntnic/ntnic_mod_reg.h index 12baa13800..e40ed9b949 100644 --- a/drivers/net/ntnic/ntnic_mod_reg.h +++ b/drivers/net/ntnic/ntnic_mod_reg.h @@ -316,6 +316,13 @@ struct flow_filter_ops { int (*flow_flush)(struct flow_eth_dev *dev, uint16_t caller_id, struct rte_flow_error *error); + + /* + * Other + */ + int (*flow_nic_set_hasher_fields)(struct flow_nic_dev *ndev, int hsh_idx, + struct nt_eth_rss_conf rss_conf); + int (*hw_mod_hsh_rcp_flush)(struct flow_api_backend_s *be, int start_idx, int count); }; void register_dev_flow_ops(const struct rte_flow_ops *ops); -- 2.45.0