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 3E09145BC0; Tue, 29 Oct 2024 18:19:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 36AFC432CA; Tue, 29 Oct 2024 18:18:18 +0100 (CET) Received: from egress-ip42a.ess.de.barracuda.com (egress-ip42a.ess.de.barracuda.com [18.185.115.201]) by mails.dpdk.org (Postfix) with ESMTP id 4C8C243036 for ; Tue, 29 Oct 2024 18:18:14 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2177.outbound.protection.outlook.com [104.47.17.177]) by mx-outbound12-25.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 29 Oct 2024 17:18:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rk26s3XYpr7M/K0C8XchfWYHOYrzXNk8ED4CBA4FK9IDw3ElVKyb+KPxLM0r0nGWhTvgX7i/BhrLTP/Z1dAiROHiqw4hbMToE5ijvKuFEWwn1y932BP/3XNu2COS2po3b4pbOgSAZNNEwSOnxlgGEAHFK6m/fUin/sZGNojN8lIwSJA636xt9AH8Tg65wgfWNxivu4aA9oIPPBkw/0OVjw9xKQ+aG7EpBb2JiT2gxcJ6Kx4OaA/J2YCk+Gq7o2fVnbA0OjM3SXVTs3lUlOLKvNjcP+rpwbqTwXVDgDoEgZm7zyK1O2zilYK1L70IFqb89DEdRhWVOYyh5xuOFYQnUw== 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=E8hRnl4IKsWDvZQiHYPOthnflwu5amLTRmYXQQAGp7g=; b=WkPjbn/EGs1VnRY8U8l/0/MzmMZ6BkhAv5Xg45KK/70xeRnUBmCe4KQClajtN8enLwtwmThR9uu6DtSVm3nyRHvtLET42werTCRMEPRTN9RMFVifJk0uDWoTEEKQb7RP5kpL5fzi1yfGOdh/vGf72Zx6LV7ip9NQ/3YB/MOlAt7Ua9zFK7tB8rsLkIrG7b6VERh09OskuoD6MkqKD8Ddpd6wTPHWaS36JYv8SIluEgjMoKHHTGk1+08Sq4sXKAG4M3JicjYRV9iFHF/VhUCGcPAVQ5SUDqHMkqnpXx+OJJh1ISDUUvfH6wm3g45IO5NASSc74GhObS2lZLlxBWSIlA== 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=E8hRnl4IKsWDvZQiHYPOthnflwu5amLTRmYXQQAGp7g=; b=mYwAG+uJY/QXLx1nOh4Ri/Hfyc52pxDZW6j8hu3/HBS7hTM/3fZYZRnSlxda6mV1mOSweD2Ad4K6rluqalkwDFpu51BARHPVSP+iySCKY5TFigl1XxhF65uUhoo1+wHxazKi5c4EADks+u3LZUPs2TCLATXwYYeg92Ii8COCDjE= Received: from DUZPR01CA0197.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b6::11) by AM0P190MB0578.EURP190.PROD.OUTLOOK.COM (2603:10a6:208:1a1::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Tue, 29 Oct 2024 16:43:44 +0000 Received: from DU2PEPF00028D06.eurprd03.prod.outlook.com (2603:10a6:10:4b6:cafe::92) by DUZPR01CA0197.outlook.office365.com (2603:10a6:10:4b6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.29 via Frontend Transport; Tue, 29 Oct 2024 16:43:44 +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 DU2PEPF00028D06.mail.protection.outlook.com (10.167.242.166) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Tue, 29 Oct 2024 16:43:43 +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 v4 53/86] net/ntnic: enable RSS feature Date: Tue, 29 Oct 2024 17:41:57 +0100 Message-ID: <20241029164243.1648775-54-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241029164243.1648775-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241029164243.1648775-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D06:EE_|AM0P190MB0578:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: c1d78014-f689-42cd-befe-08dcf838da2c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?RCHXezFMhSIqSIts4FJOym4yEtPvF0hpZ3InZZpUPL9blMMgsQaFelxWlF8n?= =?us-ascii?Q?LRQj/a5QV/9R1MRTz87QFVESQ+fahbizBBm4KhltujXshzI97WlSYsMVXgCn?= =?us-ascii?Q?tXvGPmBAKAZ16KQGFU8ZZK1ghWpy7IYHl5Vi6hTIaRMyJ/j6WgJfHQT3EAJZ?= =?us-ascii?Q?/ibXfIObhtEfTY4WmHaEZkDXc2ti+EAwGl/hR76mj7wjdCdaCPGzZsWaW6Ng?= =?us-ascii?Q?PHCtztgsrxHjGqQdf1qh/9WLU66hKQPBBobcaAcTvz4eV+fiz5nf3qETGtOR?= =?us-ascii?Q?CHW5iAW8zk2tozgv9Kf2k6iELegKppZQUM0JmkrNS/f2Wr+9t6bXSM5rFx1F?= =?us-ascii?Q?6r3xA002+1zZ0jB/J7DGL1Qt6NoSCT6iPAWP9X57EqLPFCxw+Fnp9LIfl2ZA?= =?us-ascii?Q?yGy4JqjYh+Ng+5PaHJ323tU+djURyrZCS1jriR0/z/AUSX5q+bmrRWhy2jsj?= =?us-ascii?Q?v641JadvdeP8qQBb3Somf1u9sNTNRJM8ZmPT913tp+Cg2JJpEOHWaLktF73K?= =?us-ascii?Q?Q9yUSEXHlOt/LsAuGciYScQUr5baO3cCqB3C1eQmDkCJwpIgWbKh1EgR3/2m?= =?us-ascii?Q?SU7exiAT9tLz/UQ230sCwnsltORsENZSB7AWiQqvTVoroEuJq2bPHmpG7hgC?= =?us-ascii?Q?T745S1/XsO4y+L+uk/vObcqYlGoQnzi4MNTn8A8cfPb7QwfyzBsS7xv+eXas?= =?us-ascii?Q?Lfn8yCMGz4S1i170QV2RYxzhlAOLIKEEAX2op0qNeygblXT6gFLy+X609Pnh?= =?us-ascii?Q?lsvmB88B5ibRPDppo8lN/vstz+cJ1pZF1YaHBIH2Z1wR1kgfF9x+sx2ANYqa?= =?us-ascii?Q?cOQfyIIvw4Wp/Zt81lPRMn7FZxYSQmyLaKB4LtYoPxXUmzYMwSUXrF11dMFI?= =?us-ascii?Q?YtSfJTn94EO/6Y7DEXV5zSEYlID3B7gazt8Z+eTCEN9Qm3bWUqVayPhX46PE?= =?us-ascii?Q?b1qD8fK7ZyuER8YJFc9RuFBFNY2Oioz8rsdra3lUhxyOlON5YgM4p8PWRhoR?= =?us-ascii?Q?HfYyQN/0TSQ0jK1mNqFpBdTRwKS0jugWUM/3ho++EhIfJGWSK0Y7h0qluSyq?= =?us-ascii?Q?73Esf47iRkUWcNGT7yRqCkWPQ9NVilYTGoR8HethOu9NLCsuVK0kNJRI+FXX?= =?us-ascii?Q?8hvKbEFbBBbJATw+3eQjBwmUE080vib/54Z9b7hgAQWMptrqvHQNMbjZc4V+?= =?us-ascii?Q?2uWfPErNzndBbTeANaEnnYaihOr1pgi/4tK0iqO9ytzdwn2k31EEcCC+YzfZ?= =?us-ascii?Q?Ku9gw/X2SZwQkbyEZrC82eUxwqXLGLASwPBzOKHIDNYl45jWWmWSDWeNvhVT?= =?us-ascii?Q?th1y7ozbiqzVOM9g41YRKfHSsLovvZkiWJBe28ydC/2EXiiDdiqhsIrCiygb?= =?us-ascii?Q?YjthFrd6jXfYt/DyMHMMrCwsyxw7iCqXtKAuvjxNZ7NYLu6YAg=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)(376014)(36860700013)(82310400026)(1800799024); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: eZkNnzGkYsR3EArLRnl83b8xaMDTSBIFlnM7ycC4+hY81dyOGoGhici1WFYKFcQjEiff5Qq9LyXA5d0XJ9PH3BhDPrVcaoM6rsmvQIeHvLIWmhODUDIsAZC+/eZfu0QR6B945mzf18Xi6wPU4nAQzfOm4xHeegMjhVJvPQ6Q1LaHz7FTOyXDv1MH2e9iMP7QKTf5dd5MpsvP8IJvtihyONocfbj0F2VxxLo2e1oooRW6MX6VHSo+ZYG+7glrIhNLKLkYcpUYg6dJ77P+BVd5UipNncwzxN27FpBetgBp5Y3NQxRqOYDPkXcIThZKPYuF3ufsJaK/73gA0/qaD74b5THiWgaZkcqVJZnV19qkcOnckkG+K3YjlbsHWGzbDGBeAouLp5c2TsK/2RKBm2PyztFpUwh7UQFe/IGZBnFv4seo/xSsoYClxv89XkGUhr2CpJHWW6SdP1qMAwviSB/DAmQY7V1V/Yk3Bez+pOjSmJjlYnblv5vsQ2V7AAmH18Mvc54YD8rxPC7hXClo6vepuOu1TqZxyLJiZ86NHHL6oxl7T+CPvUJ0D+1C0jeIY7lzhh04NRtsUyKTfXgIgTRPAlr7cNAkpceTh2ApknClUkMbD1CcHcLj7Hvt/guPufBHT43nuehFvhhwdtQ1/yLM4/qI65UF0z9g6W+n79ou+wE= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2024 16:43:43.9334 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c1d78014-f689-42cd-befe-08dcf838da2c 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: DU2PEPF00028D06.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0P190MB0578 X-OriginatorOrg: napatech.com X-BESS-ID: 1730222291-303097-12767-31227-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.177 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaGxhZGQGYGUNTQ0sAsNTXNzM zSPNE0KS3NMtHSzMTAMM3U1MjSLCXFWKk2FgCMiPuIQgAAAA== X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260064 [from cloudscan18-215.eu-central-1b.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 --- v4 * Use RTE_MIN instead of the ternary operator. --- 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 | 75 +++++++++++++++++++ drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 73 ++++++++++++++++++ drivers/net/ntnic/ntnic_mod_reg.h | 7 ++ 8 files changed, 210 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 af07819a0c..73e3c05f56 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..91be894e87 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,71 @@ 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 */ + + 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; + int 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 = RTE_MIN(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 +1468,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 93d89d59f3..a435b60fb2 100644 --- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c +++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c @@ -330,6 +330,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