table: fix hash for 32-bit

When create softnic hash table with 16 keys, it failed on 32-bit
environment, because the pointer field in structure rte_bucket_4_16
is only 32 bits. Add a padding field in 32-bit environment to keep
the structure to a multiple of 64 bytes. Apply this to 8-byte and
32-byte key hash function as well.

Fixes: 8aa327214c ("table: hash")
Cc: stable@dpdk.org

Signed-off-by: Ting Xu <ting.xu@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
This commit is contained in:
Ting Xu 2020-07-22 10:16:28 +08:00 committed by David Marchand
parent c5cf148d89
commit 99541c3028
3 changed files with 50 additions and 0 deletions

View File

@ -33,6 +33,7 @@
#endif
#ifdef RTE_ARCH_64
struct rte_bucket_4_16 {
/* Cache line 0 */
uint64_t signature[4 + 1];
@ -46,6 +47,22 @@ struct rte_bucket_4_16 {
/* Cache line 2 */
uint8_t data[0];
};
#else
struct rte_bucket_4_16 {
/* Cache line 0 */
uint64_t signature[4 + 1];
uint64_t lru_list;
struct rte_bucket_4_16 *next;
uint32_t pad;
uint64_t next_valid;
/* Cache line 1 */
uint64_t key[4][2];
/* Cache line 2 */
uint8_t data[0];
};
#endif
struct rte_table_hash {
struct rte_table_stats stats;

View File

@ -33,6 +33,7 @@
#endif
#ifdef RTE_ARCH_64
struct rte_bucket_4_32 {
/* Cache line 0 */
uint64_t signature[4 + 1];
@ -46,6 +47,22 @@ struct rte_bucket_4_32 {
/* Cache line 3 */
uint8_t data[0];
};
#else
struct rte_bucket_4_32 {
/* Cache line 0 */
uint64_t signature[4 + 1];
uint64_t lru_list;
struct rte_bucket_4_32 *next;
uint32_t pad;
uint64_t next_valid;
/* Cache lines 1 and 2 */
uint64_t key[4][4];
/* Cache line 3 */
uint8_t data[0];
};
#endif
struct rte_table_hash {
struct rte_table_stats stats;

View File

@ -31,6 +31,7 @@
#endif
#ifdef RTE_ARCH_64
struct rte_bucket_4_8 {
/* Cache line 0 */
uint64_t signature;
@ -43,6 +44,21 @@ struct rte_bucket_4_8 {
/* Cache line 1 */
uint8_t data[0];
};
#else
struct rte_bucket_4_8 {
/* Cache line 0 */
uint64_t signature;
uint64_t lru_list;
struct rte_bucket_4_8 *next;
uint32_t pad;
uint64_t next_valid;
uint64_t key[4];
/* Cache line 1 */
uint8_t data[0];
};
#endif
struct rte_table_hash {
struct rte_table_stats stats;