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 47FA445BCC; Thu, 31 Oct 2024 00:15:27 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 38BA74352F; Thu, 31 Oct 2024 00:15:27 +0100 (CET) Received: from egress-ip11b.ess.de.barracuda.com (egress-ip11b.ess.de.barracuda.com [18.185.115.215]) by mails.dpdk.org (Postfix) with ESMTP id B94A04350E for ; Thu, 31 Oct 2024 00:15:26 +0100 (CET) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2109.outbound.protection.outlook.com [104.47.17.109]) by mx-outbound17-81.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Oct 2024 23:15:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RHGfjgUvhvyKUkLsRkknva6+OQXmsGD/1ARuEnX/Nry1OmmfTvWOfPCREsYf60B5OzyjOFM9bviFnEtExQxiyzUFDe4gMjAy8MyeUaH/1eSpie/pwlKVovQ3ACCdGv8zLQwmSdI9LQ/6Z69GHdwSqGGBe5MBW+fim8Xi5ktNYl7fsvAd/zuzELdfG5sr5bd9SGkjsM7HUMjDCxjBfL+T12QzxAnK8flw69dCrCLbwyn//XJZsBOQ8gXSnWeBxA2s9WGyNdOCu9cR8RqFZw4gVt1KC1KEMoRN/GiwpbPNuRXX4tbQjyfjXjtVLHbkRFpvdDlD1+HJv7EkBmBkepTOlA== 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=N3LKBEu4rEOTVNWexWsDg/eVVts2OCd147n0NkwJcvE=; b=ez2MIgUhlC2xANODn9uGyPMJuae0WS8rGnxOX5/NUpSPn/0WZRA0AytUkJOkIi2cbPYCbuJbdFWd97DlqIvgpEsIXk8dD+bBTO9Gl++J3hGFuthTDguII9/Vs6TC01BGEdIu6811/4lKZVKKeXJUoEHJ6977BPEo+6lXayxEgPa6qj9LA43lqjvNgz9F+MhPCd7HN8kYY3zvw7pLCPbc3byURicaEgO5sax6c5s9ayhLGP4XkAWEpoVmgyEYZdmSGapHHFwUSHqdLVR5lfyAHmhWpr3rXnIeXIkK+MJUgIRY1e7cZfPLf/YGnauftFJFi4NRB5J5CgjylNT7CH3cyA== 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=N3LKBEu4rEOTVNWexWsDg/eVVts2OCd147n0NkwJcvE=; b=iT1pDdFgZ8gLHwhd1Kfz21njpsaAIL8M6tz8kFSthJ7AHjhMHIVFuHudSlkuutGxpo8lhIXaUS3NmlSvLnCV8YLcXE2vQlpYjFiYSP+92RAniK9n4hoGe3yo61hoUJeHxlQqUB6zn3M/dDcW6vdDewFM/Fw1UX+ekvaINEvuT88= Received: from DUZPR01CA0006.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c3::13) by GVXP190MB2204.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:1fa::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.24; Wed, 30 Oct 2024 21:40:44 +0000 Received: from DU2PEPF00028D13.eurprd03.prod.outlook.com (2603:10a6:10:3c3:cafe::75) by DUZPR01CA0006.outlook.office365.com (2603:10a6:10:3c3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Wed, 30 Oct 2024 21:40:43 +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 DU2PEPF00028D13.mail.protection.outlook.com (10.167.242.27) with Microsoft SMTP Server id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 21:40: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 v5 53/80] net/ntnic: enable RSS feature Date: Wed, 30 Oct 2024 22:39:00 +0100 Message-ID: <20241030213940.3470062-54-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030213940.3470062-1-sil-plv@napatech.com> References: <20241021210527.2075431-1-sil-plv@napatech.com> <20241030213940.3470062-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D13:EE_|GVXP190MB2204:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: d2110c8f-a3e6-417c-8716-08dcf92b81e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?l79OkZ9i1+seWEmzofNH1tL6FIkXQ9sdwg2J80RiVhtqw3SMVQHdY9sXluWJ?= =?us-ascii?Q?+KihalhefgahXETtFSZl5b/8LSJSIU/Hp8tx3O/Ma/Njp/obruWLkmCk7l09?= =?us-ascii?Q?48B8E+gFty92idlHl0EneNOQyyosTCeJS/boYf77NiQ3lxzzS3P0wLLLUzjg?= =?us-ascii?Q?SlmScJQsZSIJfRGT2EMC5XYf0HX64qEK8zPjM4iPt7jMaA5Am3KdNOEm4E4+?= =?us-ascii?Q?j3WYX2VPn5gIKWXNLSf3dmoCnVL81FUZUHDrH/OOBNBkMuud5KvGGRUdc0g9?= =?us-ascii?Q?58fZ1MpY8XrSRogOB0Viaem41+CTx6Lm2vu2ndsxOSikU2AEXynWCGEMFSWS?= =?us-ascii?Q?snELf5IYKWFQq6SDc1M5mal/XjT3+NIDfvYlEyLP5NP3TKpFjFbZaLvd/dZg?= =?us-ascii?Q?iVzsHfY0SGwjKliPf3SyriHJxhmQy+RHpxbifUmQgu7hI+Ux14arWw6IKy1t?= =?us-ascii?Q?xeudBIdxBvjnXZ0hIaTLJl7L6J+eVmvMGSjxaOHGh66rPeaZRXsH61ho/3C0?= =?us-ascii?Q?9KQx7rD889qspl0QPpI+yG6F4uoIyXApahFkxmlQEC61PZnPdBb5X/7EUjVd?= =?us-ascii?Q?Vcw+0Cu2jAphb7c3VasIQO0MBuceTllbNAa76JcmI6tXAJ7x/COhFc5p1zac?= =?us-ascii?Q?AOPrRaHU+Dss/b33jZV2Itp3KchPVYsS1zxZ4ZbE5VgCD7scl5BS7E0Z3hdP?= =?us-ascii?Q?KQlcDQPAk6Bcittld3lLA1emb4UXmHPz5hbI0nUdZ9g8j6lC4MSgIulh9fpp?= =?us-ascii?Q?uALVHGQMndJOwmY6uyuX5tLToRFU16r4/pGkoysQoypyCdcS2bH7AKmnw3AL?= =?us-ascii?Q?Vp5DxrURwO69KjfM9FIZ1rFq2YtasuDQfgQjUW4COC99VeJeTtO9iFX98emK?= =?us-ascii?Q?+EqTcxUAkX1OvpibiQ26l4vzMjq55NYtgE0gQJPvhg9Kqt1k4wUJ5EDvPD1U?= =?us-ascii?Q?WVPGm6ZFzoin9H0BJK5Z4v692dEzrrzE8OXM/jHccChRDcZEgwX7joXzOa6m?= =?us-ascii?Q?nXH2JqINYVrlZSySf2rdVsZXp/O5vMPDQ65mw64SVUA32PfWe0tLgrQbzMfk?= =?us-ascii?Q?/JtW87cCWn1mokx0Nfurj0xHsTMSjoE7pvX+SDNZ1NIhL3ujsGbvqOd6oO3N?= =?us-ascii?Q?Wun+ze5OoMRM/LjhIMk2VGiSoGbQ294CPwQQPogTHBFUqvd7tkXqWmWKhZPP?= =?us-ascii?Q?j6uLJAGwe99Am0wGnxc4Upr9L3ry9F8WsoVbOURihMR3AjcsWUQt3PBvCY1V?= =?us-ascii?Q?AGK0EDcA8dWZVsxUZmUL8bGI85FVlXQnoNhPmgafF8qJy/IoRHjHqZpzY4Ay?= =?us-ascii?Q?y3r+x25YEyc3xPSKYoJAZexQfh5pA56jlrCn+pnUH7Hk6Wn5Vokd88C1aJLJ?= =?us-ascii?Q?trTQsVgpywbiY7WhqBbfUeHdYV99UMOVbftJNCy5RB1HXDlHFA=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)(1800799024)(82310400026)(36860700013)(376014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: lxkZdyDLApb+Mm7Ib+lUoCDeycoU4n03xQXjCnSWmxPKUGxuIU+sGQwCsEJ0VOtR1ASqo0IFUDTs7kEuKrZRX8aMGnGGM8o3I0zBoio869qlprYnhyDPU41r3jl78WtPTr9h3CJ6H0bJeuU8iz2w1/gaERpzpWnMiLmb6eiw7AxiNs3VCxCNKblXHZz1651YHN/KeQb/K0bmq1Jnc8uq+1OL5Oz3j03WZxaqo3UEr/J6Orkk+WofiVk54/y5f1OEhGQKuqiZ4IybU3UQOFruaLKLd1kWT5djCc2S74tbCXH8jTd4qBn9vrCkpDgCn8ZvYRrW1+gqBIZ5KXhsun4Ej8ZjXb2dBcq2vvAYBtonvN8qp/t0OK4ioXAqJqOsVko/e7LnNhoPp4jT3jnAl4sGLbCRM3Bh8PLy3CAeFKS5sIk7irPNGkACij48bo5W05yWIBtZJdmxSodwGcOJT/L6KZWBxxitSiPGfNDj+V+jqnGDgGAK4WaHzaZGaB2D8OPEOZNTH+DXDRRuyD2hoGVfn8EQ2QPYGz5tsQ8IBYo26W9C83tUaIfoq80Mnn6CXKVFwXrGh9wYn7hivRyS8fRl4aiigKu0xnxT0e6OMTdtNQr7WBgtroI2bPeLntkgh3ZEENw0yYsJ86qNrZvwl/ZS0yn9pu006juN+uzP71Ft4yI= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 21:40:43.5521 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d2110c8f-a3e6-417c-8716-08dcf92b81e8 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: DU2PEPF00028D13.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXP190MB2204 X-OriginatorOrg: napatech.com X-BESS-ID: 1730330123-304433-12634-48467-1 X-BESS-VER: 2019.1_20241018.1852 X-BESS-Apparent-Source-IP: 104.47.17.109 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoZGBpYGQGYGUDQpJTEtydjYNN UsOdnMIMXYOMnCwig5LSXR3MAw0TLRVKk2FgDFa2tpQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260092 [from cloudscan16-249.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_RULE7568M, 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 + doc/guides/nics/ntnic.rst | 7 ++ 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 ++ 9 files changed, 217 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/doc/guides/nics/ntnic.rst b/doc/guides/nics/ntnic.rst index f2cb7a362a..4ed732d9f8 100644 --- a/doc/guides/nics/ntnic.rst +++ b/doc/guides/nics/ntnic.rst @@ -56,6 +56,13 @@ Features - Exact match of 140 million flows and policies. - Tunnel HW offload: Packet type, inner/outer RSS, IP and UDP checksum verification. +- RSS hash +- RSS key update +- RSS based on VLAN or 5-tuple. +- RSS using different combinations of fields: L3 only, L4 only or both, and + source only, destination only or both. +- Several RSS hash keys, one for each flow type. +- Default RSS operation with no hash key specification. Limitations ~~~~~~~~~~~ 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 fc9c68ed1a..4847b2de99 100644 --- a/drivers/net/ntnic/nthw/flow_api/flow_api.c +++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c @@ -1027,6 +1027,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 0232954bec..21d0df56e5 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