From: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
To: dev@dpdk.org
Cc: konstantin.v.ananyev@yandex.ru, stable@dpdk.org
Subject: [PATCH v2 1/2] hash: fix reading unaligned bits implementation
Date: Fri, 30 Jun 2023 17:09:26 +0000 [thread overview]
Message-ID: <20230630170927.32829-1-vladimir.medvedkin@intel.com> (raw)
In-Reply-To: <20230628191219.78753-1-vladimir.medvedkin@intel.com>
Fixes: 28ebff11c2dc ("hash: add predictable RSS")
Cc: stable@dpdk.org
Acked-by: Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>
Tested-by: Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>
Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
lib/hash/rte_thash.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c
index 0249883b8d..2228af576b 100644
--- a/lib/hash/rte_thash.c
+++ b/lib/hash/rte_thash.c
@@ -670,7 +670,7 @@ rte_thash_get_gfni_matrices(struct rte_thash_ctx *ctx)
}
static inline uint8_t
-read_unaligned_byte(uint8_t *ptr, unsigned int len, unsigned int offset)
+read_unaligned_byte(uint8_t *ptr, unsigned int offset)
{
uint8_t ret = 0;
@@ -681,13 +681,14 @@ read_unaligned_byte(uint8_t *ptr, unsigned int len, unsigned int offset)
(CHAR_BIT - (offset % CHAR_BIT));
}
- return ret >> (CHAR_BIT - len);
+ return ret;
}
static inline uint32_t
read_unaligned_bits(uint8_t *ptr, int len, int offset)
{
uint32_t ret = 0;
+ int shift;
len = RTE_MAX(len, 0);
len = RTE_MIN(len, (int)(sizeof(uint32_t) * CHAR_BIT));
@@ -695,13 +696,14 @@ read_unaligned_bits(uint8_t *ptr, int len, int offset)
while (len > 0) {
ret <<= CHAR_BIT;
- ret |= read_unaligned_byte(ptr, RTE_MIN(len, CHAR_BIT),
- offset);
+ ret |= read_unaligned_byte(ptr, offset);
offset += CHAR_BIT;
len -= CHAR_BIT;
}
- return ret;
+ shift = (len == 0) ? 0 :
+ (CHAR_BIT - ((len + CHAR_BIT) % CHAR_BIT));
+ return ret >> shift;
}
/* returns mask for len bits with given offset inside byte */
--
2.25.1
next prev parent reply other threads:[~2023-06-30 17:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-28 19:12 [PATCH] test: add additional tests for thash library Vladimir Medvedkin
2023-06-29 12:59 ` David Marchand
2023-06-29 13:17 ` Medvedkin, Vladimir
2023-06-29 13:47 ` David Marchand
2023-06-30 17:09 ` Vladimir Medvedkin [this message]
2023-06-30 17:09 ` [PATCH v2 2/2] " Vladimir Medvedkin
2023-07-06 14:49 ` [PATCH v2 1/2] hash: fix reading unaligned bits implementation Thomas Monjalon
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=20230630170927.32829-1-vladimir.medvedkin@intel.com \
--to=vladimir.medvedkin@intel.com \
--cc=dev@dpdk.org \
--cc=konstantin.v.ananyev@yandex.ru \
--cc=stable@dpdk.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).