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 A89DE45D7F; Fri, 22 Nov 2024 23:49:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 955BA4341F; Fri, 22 Nov 2024 23:49:31 +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 59DFD402DA for ; Fri, 22 Nov 2024 23:49:29 +0100 (CET) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2169.outbound.protection.outlook.com [104.47.17.169]) by mx-outbound21-54.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 22 Nov 2024 22:49:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YCRypMloz4qpy4OnNt9UyEgXvKnqgDIuUNkCphmeBy2A76GxUkToA7OlpcuTzyZbbiUG8nY8hf3do2Wr+oIc3uPeZ9ARobyJ8+EXnilMqag9R67OfYgiGhwf8ed6jGz4NLGyHMt6rb+BWcGULroNNQlSc0gPb+nyCqNAunL6pVFUILX3eamy/piLU16IxutJRd676SwU4yKb20p0D4IQ1qH6+9sI365PIYoroe/xivbeeN8fCL2wqEI2ZkpWf1W9HQeQzhWixbYvlZYxsIfAK58EVstIk0rh/1DThldJom3pu6EZGHnySBj2DtGyyuwR7Wsnl73ie/g2Gf1lQfnFsQ== 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=31s73bMX0IpWAUApEqE0B/JsGOjyyr4mJbYNgYQhQ7U=; b=wSVTEzhuZVRvxvq3G9xg998SyWNCWA4jKJP0bZ5XU6DwndKo6Es6OZLhVt39MTCMr9uvfk8Nmgyjf9qxe4/njsMVyiczDFaLH0FzagN6rR9UA0JrtHUTQgX3sBmTKvSg38Ee04k3lNo8+JBgy+g5PIvFgIRNTxVpTqgn2cVmaRAJxPazFJBszp2hzxu7vBlKnjQ34yelKUtp+W6AdIAHCdweNjm9B8jHGc18phKVKERFkZjWcAtT32kT2mkxPLtNB+mpsDAfoRIm+3/a6vozxSgb4B0s8jZJHfwa7FgJ3iKYDk9Bdcf/RvevEq3/bO6axS/pj26MuF3o1uPHbufkxw== 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=31s73bMX0IpWAUApEqE0B/JsGOjyyr4mJbYNgYQhQ7U=; b=f9fYJ1DlVV8l0E7LqraPtaJ5Da/ZA9/M2pVRA89SawyQQn6txqxezVFZB9Wc3O4aMd/dQAhF+/Ck3prp2XWR8MUqN6kHuOnY7gI2UyASAtS4e+UlS2dRZBuRXl9JA9ItZ4A/yF+bRjzuMxkmMsz/mRZKAwccVLSSWEvExT0CvGs= Received: from DU6P191CA0072.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:53e::25) by GVXP190MB2146.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:1e4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.18; Fri, 22 Nov 2024 22:49:22 +0000 Received: from DB1PEPF000509FC.eurprd03.prod.outlook.com (2603:10a6:10:53e:cafe::d4) by DU6P191CA0072.outlook.office365.com (2603:10a6:10:53e::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.16 via Frontend Transport; Fri, 22 Nov 2024 22:49:22 +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 DB1PEPF000509FC.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server id 15.20.8182.16 via Frontend Transport; Fri, 22 Nov 2024 22:49:21 +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, Danylo Vodopianov Subject: [PATCH v2 2/2] net/ntnic: fix of Toeplitz key and log with mask Date: Fri, 22 Nov 2024 23:49:15 +0100 Message-ID: <20241122224916.432217-3-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241122224916.432217-1-sil-plv@napatech.com> References: <20241122224916.432217-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF000509FC:EE_|GVXP190MB2146:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: d47fa03e-89c2-4b65-f393-08dd0b47e80a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-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Ye27Vi3KHHmQkr9xCVGDC9D4ibjz7BJ0T0?= =?us-ascii?Q?G8QxUKsgBQDPe8NLq0LoiAOnraxCqswIdBj3oqzNoxK5jyGj6kRHiz9iTQVa?= =?us-ascii?Q?MQqjBPkGidNv01VReJjTlGC6wvIpadRG70W5zMfqThcVbinpMcQ3fbMak8u+?= =?us-ascii?Q?h7jfjA/uT+qqg0GQcSIOEbz9yxbpqxBCxJ8x0/gHX+P7YvzMqS3+NnyaE2gC?= =?us-ascii?Q?Y32Gi+Pi+vHp0CUZHaPL6EY/ENbFkFzk0vNTTPQu+73Ceafw4ScO5ckt4suQ?= =?us-ascii?Q?M/UvGlIYszIYD7QzsR+vboRLuvuX+UV21D2F27tWHWWkRsQQeQw7MYMU6HAu?= =?us-ascii?Q?iPuhMlnVNfVUE5NZJtNgQapRoriannY5RDkBJLsYh0CGTMPvKUJFDD5VzjBy?= =?us-ascii?Q?LUojKtE+0ISWoyZNtgOUDl53ek//BeLKO1gfrnvmp6BlGN4Vc+0PUGNaR3Fz?= =?us-ascii?Q?55cjrpaY59AwTRLa6GBmysLbmFVI+Ig1NQB9lvKqAcdWTFxP/or6tvyCDhFL?= =?us-ascii?Q?bWhlWdkYX55647e0395Seoz3Q9kPMpxuczbd0/a5xPt00yGhmmeFx3gKS+eM?= =?us-ascii?Q?RGxb4htS7dgmzDRpFAY6V9JGEi2MZx2j?= 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)(82310400026)(1800799024)(36860700013); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: A4UPSxdv/uI+Rjmf0bk9E57eedp5452bX83F93JTatNXPZuj9Hg72eU/P0bHyp4VvCyY5oCYAvcDa4KhWfd5suFZS0wIFWyOMvtvGeqQauo5q4M1FD0NUzeEtjaKHCopdrntQbdDKCDY4VlxNPn/20m9eBKJgJ8s4h8eab19cRg+ukC39lSX0pJ6IyVEF9jt6vmYkHCgC1BLmbw5gCwlrYyr/idN925FE+WQxZBfuUapkBS7lY+riHUgg24Bykcm/0exgu5ZnyT1riwxlImvO92gm6N+227UL5T5Uq4t0ePhANkyxH3tJqmMhnMQ2VRuxHS/cG3DtCJyAyYi63KiBvbQ1yRzQcWO5WdMRScEpFcCw9nkeXwz7eA5gI2x8nB1JE1kIOYwmPDCWV6Ub15uACKUqf0B4nj4PbpMxQ6kYQYDqrvEq2AivwFoloza8Vgj4kRL+DWFGNcABBWs5fXyTyqEL187TB5QtCKvj1eNbFZyusSvm88M5N/GDg+KfAdvanj4lJBvotdhna8ms2HCTIgR+dOu3XeXtfaAvTo4jd+e7W7yxz9AIUnWtlKt8fxQF8iH+3yKM3WK9w+hEiY5LUSbmdIHATlJqijLG5u3+nNS/mMWHjqo2gIlK3+bDteGJAieYg87CCSdqSQFF6e/veUgxImNoZF7AOYQKXoAV48= X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2024 22:49:21.7125 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d47fa03e-89c2-4b65-f393-08dd0b47e80a 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: DB1PEPF000509FC.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXP190MB2146 X-BESS-ID: 1732315765-305430-13348-58328-1 X-BESS-VER: 2019.1_20241121.1615 X-BESS-Apparent-Source-IP: 104.47.17.169 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVmaGlgZAVgZQ0Ngg0cLMwtIiyS zNJNXELM0gNdHEOCXZ2NTAPDXRKMlCqTYWAGzai2lBAAAA X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.260611 [from cloudscan9-193.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 Toeplitz secret key word order was reversed during programming into FPGA, which lead to unexpected rss hash values. Fixes: 7fa0bf29e667 ("net/ntnic: add hash module") Signed-off-by: Serhii Iliushyk --- .../profile_inline/flow_api_profile_inline.c | 61 +++++++------------ 1 file changed, 21 insertions(+), 40 deletions(-) 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 a34839e00c..fbe8ee2795 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 @@ -3825,7 +3825,6 @@ struct hsh_words { * is used for hash mask calculation */ uint8_t index; - uint8_t toeplitz_index; /* offset in Bytes of given [Q]W inside Toeplitz RSS key */ enum hw_hsh_e pe; /* offset to header part, e.g. beginning of L4 */ enum hw_hsh_e ofs; /* relative offset in BYTES to 'pe' header offset above */ uint16_t bit_len; /* max length of header part in bits to fit into QW/W */ @@ -3874,7 +3873,6 @@ static int flow_nic_set_hasher_part_inline(struct flow_nic_dev *ndev, int hsh_id /* set HW_HSH_RCP_WORD_MASK based on used QW/W and given 'bit_len' */ int mask_bit_len = bit_len; uint32_t mask = 0x0; - uint32_t mask_be = 0x0; uint32_t toeplitz_mask[9] = { 0x0 }; /* iterate through all words of QW */ uint16_t words_count = words[word].bit_len / 32; @@ -3883,27 +3881,23 @@ static int flow_nic_set_hasher_part_inline(struct flow_nic_dev *ndev, int hsh_id if (mask_bit_len >= 32) { mask_bit_len -= 32; mask = 0xffffffff; - mask_be = mask; } else if (mask_bit_len > 0) { - /* keep bits from left to right, i.e. little to big endian */ - mask_be = 0xffffffff >> (32 - mask_bit_len); - mask = mask_be << (32 - mask_bit_len); + mask = 0xffffffff >> (32 - mask_bit_len) << (32 - mask_bit_len); mask_bit_len = 0; } else { mask = 0x0; - mask_be = 0x0; } /* reorder QW words mask from little to big endian */ res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_WORD_MASK, hsh_idx, words[word].index + words_count - mask_off, mask); - NT_LOG(DBG, FILTER, - "hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_WORD_MASK, %d, %d, 0x%" PRIX32 + NT_LOG_DBGX(DBG, FILTER, + "hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_WORD_MASK, %d, %d, 0x%08" PRIX32 ")", hsh_idx, words[word].index + words_count - mask_off, mask); - toeplitz_mask[words[word].toeplitz_index + mask_off - 1] = mask_be; + toeplitz_mask[words[word].index + mask_off - 1] = mask; } if (toeplitz) { @@ -3911,9 +3905,9 @@ static int flow_nic_set_hasher_part_inline(struct flow_nic_dev *ndev, int hsh_id "Partial Toeplitz RSS key mask: %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 " %08" PRIX32 "", - toeplitz_mask[8], toeplitz_mask[7], toeplitz_mask[6], toeplitz_mask[5], - toeplitz_mask[4], toeplitz_mask[3], toeplitz_mask[2], toeplitz_mask[1], - toeplitz_mask[0]); + toeplitz_mask[0], toeplitz_mask[1], toeplitz_mask[2], toeplitz_mask[3], + toeplitz_mask[4], toeplitz_mask[5], toeplitz_mask[6], toeplitz_mask[7], + toeplitz_mask[8]); NT_LOG(DBG, FILTER, " MSB LSB"); } @@ -4632,11 +4626,11 @@ int flow_nic_set_hasher_fields_inline(struct flow_nic_dev *ndev, int hsh_idx, * word | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | */ struct hsh_words words[HSH_WORDS_SIZE] = { - { 0, 5, HW_HSH_RCP_QW0_PE, HW_HSH_RCP_QW0_OFS, 128, true }, - { 4, 1, HW_HSH_RCP_QW4_PE, HW_HSH_RCP_QW4_OFS, 128, true }, - { 8, 0, HW_HSH_RCP_W8_PE, HW_HSH_RCP_W8_OFS, 32, true }, + { 0, HW_HSH_RCP_QW0_PE, HW_HSH_RCP_QW0_OFS, 128, true }, + { 4, HW_HSH_RCP_QW4_PE, HW_HSH_RCP_QW4_OFS, 128, true }, + { 8, HW_HSH_RCP_W8_PE, HW_HSH_RCP_W8_OFS, 32, true }, { - 9, 255, HW_HSH_RCP_W9_PE, HW_HSH_RCP_W9_OFS, 32, + 9, HW_HSH_RCP_W9_PE, HW_HSH_RCP_W9_OFS, 32, true }, /* not supported for Toeplitz */ }; @@ -4664,34 +4658,21 @@ int flow_nic_set_hasher_fields_inline(struct flow_nic_dev *ndev, int hsh_idx, res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_TOEPLITZ, hsh_idx, 0, 1); uint8_t empty_key = 0; - /* Toeplitz key (always 40B) must be encoded from little to big endian */ - for (uint8_t i = 0; i <= (MAX_RSS_KEY_LEN - 8); i += 8) { - res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_K, hsh_idx, i / 4, - rss_conf.rss_key[i + 4] << 24 | - rss_conf.rss_key[i + 5] << 16 | - rss_conf.rss_key[i + 6] << 8 | - rss_conf.rss_key[i + 7]); - NT_LOG(DBG, FILTER, - "hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_K, %d, %d, 0x%" PRIX32 - ")", - hsh_idx, i / 4, - rss_conf.rss_key[i + 4] << 24 | rss_conf.rss_key[i + 5] << 16 | - rss_conf.rss_key[i + 6] << 8 | rss_conf.rss_key[i + 7]); - res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_K, hsh_idx, i / 4 + 1, - rss_conf.rss_key[i] << 24 | - rss_conf.rss_key[i + 1] << 16 | - rss_conf.rss_key[i + 2] << 8 | - rss_conf.rss_key[i + 3]); - NT_LOG(DBG, FILTER, + /* Toeplitz key (always 40B) words have to be programmed in reverse order */ + for (uint8_t i = 0; i <= (MAX_RSS_KEY_LEN - 4); i += 4) { + res |= hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_K, hsh_idx, 9 - i / 4, + rss_conf.rss_key[i] << 24 | + rss_conf.rss_key[i + 1] << 16 | + rss_conf.rss_key[i + 2] << 8 | + rss_conf.rss_key[i + 3]); + NT_LOG_DBG(DBG, FILTER, "hw_mod_hsh_rcp_set(&ndev->be, HW_HSH_RCP_K, %d, %d, 0x%" PRIX32 ")", - hsh_idx, i / 4 + 1, + hsh_idx, 9 - i / 4, rss_conf.rss_key[i] << 24 | rss_conf.rss_key[i + 1] << 16 | rss_conf.rss_key[i + 2] << 8 | rss_conf.rss_key[i + 3]); empty_key |= rss_conf.rss_key[i] | rss_conf.rss_key[i + 1] | - rss_conf.rss_key[i + 2] | rss_conf.rss_key[i + 3] | - rss_conf.rss_key[i + 4] | rss_conf.rss_key[i + 5] | - rss_conf.rss_key[i + 6] | rss_conf.rss_key[i + 7]; + rss_conf.rss_key[i + 2] | rss_conf.rss_key[i + 3]; } if (empty_key == 0) { -- 2.45.0