From: Serhii Iliushyk <sil-plv@napatech.com>
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 <dvo-plv@napatech.com>
Subject: [PATCH v2 2/2] net/ntnic: fix of Toeplitz key and log with mask
Date: Fri, 22 Nov 2024 23:49:15 +0100 [thread overview]
Message-ID: <20241122224916.432217-3-sil-plv@napatech.com> (raw)
In-Reply-To: <20241122224916.432217-1-sil-plv@napatech.com>
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 <sil-plv@napatech.com>
---
.../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
prev parent reply other threads:[~2024-11-22 22:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-22 22:49 [PATCH v2 0/2] Bugfixes Serhii Iliushyk
2024-11-22 22:49 ` [PATCH v2 1/2] net/ntnic: fix incorrect error message Serhii Iliushyk
2024-11-22 23:08 ` Stephen Hemminger
2024-11-22 22:49 ` Serhii Iliushyk [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241122224916.432217-3-sil-plv@napatech.com \
--to=sil-plv@napatech.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=ckm@napatech.com \
--cc=dev@dpdk.org \
--cc=dvo-plv@napatech.com \
--cc=ferruh.yigit@amd.com \
--cc=mko-plv@napatech.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).