@@ -350,7 +350,6 @@ struct logtype {
static const struct logtype logtype_strings[] = {
{RTE_LOGTYPE_EAL, "lib.eal"},
{RTE_LOGTYPE_PMD, "pmd"},
- {RTE_LOGTYPE_HASH, "lib.hash"},
{RTE_LOGTYPE_METER, "lib.meter"},
{RTE_LOGTYPE_SCHED, "lib.sched"},
{RTE_LOGTYPE_PORT, "lib.port"},
@@ -32,7 +32,7 @@ extern "C" {
/* was RTE_LOGTYPE_MEMPOOL */
/* was RTE_LOGTYPE_TIMER */
#define RTE_LOGTYPE_PMD 5 /**< Log related to poll mode driver. */
-#define RTE_LOGTYPE_HASH 6 /**< Log related to hash table. */
+ /* was RTE_LOGTYPE_HASH */
/* was RTE_LOGTYPE_LPM */
/* was RTE_LOGTYPE_KNI */
/* was RTE_LOGTYPE_ACL */
@@ -26,6 +26,12 @@
#include "rte_hash.h"
#include "rte_cuckoo_hash.h"
+RTE_LOG_REGISTER_SUFFIX(hash_logtype, "hash", INFO);
+
+#define HASH_LOG(level, fmt, args...) \
+ rte_log(RTE_LOG_ ## level, hash_logtype, \
+ "%s(): " fmt "\n", __func__, ##args)
+
/* Mask of all flags supported by this version */
#define RTE_HASH_EXTRA_FLAGS_MASK (RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT | \
RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD | \
@@ -159,7 +165,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
if (params == NULL) {
- RTE_LOG(ERR, HASH, "rte_hash_create has no parameters\n");
+ HASH_LOG(ERR, "null parameters");
return NULL;
}
@@ -168,13 +174,13 @@ rte_hash_create(const struct rte_hash_parameters *params)
(params->entries < RTE_HASH_BUCKET_ENTRIES) ||
(params->key_len == 0)) {
rte_errno = EINVAL;
- RTE_LOG(ERR, HASH, "rte_hash_create has invalid parameters\n");
+ HASH_LOG(ERR, "invalid parameters");
return NULL;
}
if (params->extra_flag & ~RTE_HASH_EXTRA_FLAGS_MASK) {
rte_errno = EINVAL;
- RTE_LOG(ERR, HASH, "rte_hash_create: unsupported extra flags\n");
+ HASH_LOG(ERR, "unsupported extra flags");
return NULL;
}
@@ -182,8 +188,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) &&
(params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)) {
rte_errno = EINVAL;
- RTE_LOG(ERR, HASH, "rte_hash_create: choose rw concurrency or "
- "rw concurrency lock free\n");
+ HASH_LOG(ERR,
+ "choose rw concurrency or rw concurrency lock free");
return NULL;
}
@@ -233,7 +239,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
r = rte_ring_create_elem(ring_name, sizeof(uint32_t),
rte_align32pow2(num_key_slots), params->socket_id, 0);
if (r == NULL) {
- RTE_LOG(ERR, HASH, "memory allocation failed\n");
+ HASH_LOG(ERR, "memory allocation failed");
goto err;
}
@@ -249,8 +255,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
params->socket_id, 0);
if (r_ext == NULL) {
- RTE_LOG(ERR, HASH, "ext buckets memory allocation "
- "failed\n");
+ HASH_LOG(ERR,
+ "ext buckets memory allocation failed");
goto err;
}
}
@@ -275,7 +281,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
te = rte_zmalloc("HASH_TAILQ_ENTRY", sizeof(*te), 0);
if (te == NULL) {
- RTE_LOG(ERR, HASH, "tailq entry allocation failed\n");
+ HASH_LOG(ERR, "tailq entry allocation failed");
goto err_unlock;
}
@@ -283,7 +289,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
RTE_CACHE_LINE_SIZE, params->socket_id);
if (h == NULL) {
- RTE_LOG(ERR, HASH, "memory allocation failed\n");
+ HASH_LOG(ERR, "memory allocation failed");
goto err_unlock;
}
@@ -292,7 +298,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
RTE_CACHE_LINE_SIZE, params->socket_id);
if (buckets == NULL) {
- RTE_LOG(ERR, HASH, "buckets memory allocation failed\n");
+ HASH_LOG(ERR, "buckets memory allocation failed");
goto err_unlock;
}
@@ -302,8 +308,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
num_buckets * sizeof(struct rte_hash_bucket),
RTE_CACHE_LINE_SIZE, params->socket_id);
if (buckets_ext == NULL) {
- RTE_LOG(ERR, HASH, "ext buckets memory allocation "
- "failed\n");
+ HASH_LOG(ERR,
+ "ext buckets memory allocation failed");
goto err_unlock;
}
/* Populate ext bkt ring. We reserve 0 similar to the
@@ -318,8 +324,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
ext_bkt_to_free = rte_zmalloc(NULL, sizeof(uint32_t) *
num_key_slots, 0);
if (ext_bkt_to_free == NULL) {
- RTE_LOG(ERR, HASH, "ext bkt to free memory allocation "
- "failed\n");
+ HASH_LOG(ERR,
+ "ext bkt to free memory allocation failed");
goto err_unlock;
}
}
@@ -334,7 +340,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
RTE_CACHE_LINE_SIZE, params->socket_id);
if (k == NULL) {
- RTE_LOG(ERR, HASH, "memory allocation failed\n");
+ HASH_LOG(ERR, "memory allocation failed");
goto err_unlock;
}
@@ -342,7 +348,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
RTE_CACHE_LINE_SIZE, params->socket_id);
if (tbl_chng_cnt == NULL) {
- RTE_LOG(ERR, HASH, "memory allocation failed\n");
+ HASH_LOG(ERR, "memory allocation failed");
goto err_unlock;
}
@@ -390,7 +396,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
sizeof(struct lcore_cache) * RTE_MAX_LCORE,
RTE_CACHE_LINE_SIZE, params->socket_id);
if (local_free_slots == NULL) {
- RTE_LOG(ERR, HASH, "local free slots memory allocation failed\n");
+ HASH_LOG(ERR, "local free slots memory allocation failed");
goto err_unlock;
}
}
@@ -624,7 +630,7 @@ rte_hash_reset(struct rte_hash *h)
/* Reclaim all the resources */
rte_rcu_qsbr_dq_reclaim(h->dq, ~0, NULL, &pending, NULL);
if (pending != 0)
- RTE_LOG(ERR, HASH, "RCU reclaim all resources failed\n");
+ HASH_LOG(ERR, "RCU reclaim all resources failed");
}
memset(h->buckets, 0, h->num_buckets * sizeof(struct rte_hash_bucket));
@@ -1498,9 +1504,8 @@ __hash_rcu_qsbr_free_resource(void *p, void *e, unsigned int n)
/* Return key indexes to free slot ring */
ret = free_slot(h, rcu_dq_entry.key_idx);
if (ret < 0) {
- RTE_LOG(ERR, HASH,
- "%s: could not enqueue free slots in global ring\n",
- __func__);
+ HASH_LOG(ERR,
+ "could not enqueue free slots in global ring");
}
}
@@ -1527,7 +1532,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg)
hash_rcu_cfg = rte_zmalloc(NULL, sizeof(struct rte_hash_rcu_config), 0);
if (hash_rcu_cfg == NULL) {
- RTE_LOG(ERR, HASH, "memory allocation failed\n");
+ HASH_LOG(ERR, "memory allocation failed");
return 1;
}
@@ -1551,7 +1556,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg)
h->dq = rte_rcu_qsbr_dq_create(¶ms);
if (h->dq == NULL) {
rte_free(hash_rcu_cfg);
- RTE_LOG(ERR, HASH, "HASH defer queue creation failed\n");
+ HASH_LOG(ERR, "HASH defer queue creation failed");
return 1;
}
} else {
@@ -1580,9 +1585,8 @@ remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt,
int ret = free_slot(h, bkt->key_idx[i]);
if (ret < 0) {
- RTE_LOG(ERR, HASH,
- "%s: could not enqueue free slots in global ring\n",
- __func__);
+ HASH_LOG(ERR,
+ "could not enqueue free slots in global ring");
}
}
@@ -1770,7 +1774,7 @@ __rte_hash_del_key_with_hash(const struct rte_hash *h, const void *key,
} else if (h->dq)
/* Push into QSBR FIFO if using RTE_HASH_QSBR_MODE_DQ */
if (rte_rcu_qsbr_dq_enqueue(h->dq, &rcu_dq_entry) != 0)
- RTE_LOG(ERR, HASH, "Failed to push QSBR FIFO\n");
+ HASH_LOG(ERR, "Failed to push QSBR FIFO");
}
__hash_rw_writer_unlock(h);
return ret;
@@ -18,6 +18,12 @@
#include "rte_fbk_hash.h"
+RTE_LOG_REGISTER_SUFFIX(fbk_hash_logtype, "hash.fbk", INFO);
+
+#define HASH_LOG(level, fmt, args...) \
+ rte_log(RTE_LOG_ ## level, fbk_hash_logtype, \
+ "%s(): " fmt "\n", __func__, ##args)
+
TAILQ_HEAD(rte_fbk_hash_list, rte_tailq_entry);
static struct rte_tailq_elem rte_fbk_hash_tailq = {
@@ -114,7 +120,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
te = rte_zmalloc("FBK_HASH_TAILQ_ENTRY", sizeof(*te), 0);
if (te == NULL) {
- RTE_LOG(ERR, HASH, "Failed to allocate tailq entry\n");
+ HASH_LOG(ERR, "Failed to allocate tailq entry");
goto exit;
}
@@ -122,7 +128,7 @@ rte_fbk_hash_create(const struct rte_fbk_hash_params *params)
ht = rte_zmalloc_socket(hash_name, mem_size,
0, params->socket_id);
if (ht == NULL) {
- RTE_LOG(ERR, HASH, "Failed to allocate fbk hash table\n");
+ HASH_LOG(ERR, "Failed to allocate fbk hash table");
rte_free(te);
goto exit;
}
@@ -63,7 +63,7 @@ rte_hash_crc_set_alg(uint8_t alg)
#if defined RTE_ARCH_X86
if (!(alg & CRC32_SSE42_x64))
- RTE_LOG(WARNING, HASH,
+ fprintf(stderr,
"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42\n");
if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_EM64T) || alg == CRC32_SSE42)
crc32_alg = CRC32_SSE42;
@@ -73,14 +73,14 @@ rte_hash_crc_set_alg(uint8_t alg)
#if defined RTE_ARCH_ARM64
if (!(alg & CRC32_ARM64))
- RTE_LOG(WARNING, HASH,
+ fprintf(stderr,
"Unsupported CRC32 algorithm requested using CRC32_ARM64\n");
if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_CRC32))
crc32_alg = CRC32_ARM64;
#endif
if (crc32_alg == CRC32_SW)
- RTE_LOG(WARNING, HASH,
+ fprintf(stderr,
"Unsupported CRC32 algorithm requested using CRC32_SW\n");
}
@@ -13,6 +13,12 @@
#include <rte_log.h>
#include <rte_malloc.h>
+RTE_LOG_REGISTER_SUFFIX(rte_thash_logtype, "thash", INFO);
+
+#define HASH_LOG(level, fmt, args...) \
+ rte_log(RTE_LOG_ ## level, rte_thash_logtype, \
+ "%s(): " fmt "\n", __func__, ##args)
+
#define THASH_NAME_LEN 64
#define TOEPLITZ_HASH_LEN 32
@@ -104,6 +110,28 @@ rte_thash_gfni_supported(void)
return 0;
};
+#ifndef RTE_THASH_GFNI_DEFINED
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx __rte_unused,
+ const uint8_t *key __rte_unused, int len __rte_unused)
+{
+ HASH_LOG(ERR, "is undefined under given arch");
+ return 0;
+}
+
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
+ int len __rte_unused, uint8_t *tuple[] __rte_unused,
+ uint32_t val[], uint32_t num)
+{
+ unsigned int i;
+
+ HASH_LOG(ERR, "is undefined under given arch");
+ for (i = 0; i < num; i++)
+ val[i] = 0;
+}
+#endif
+
void
rte_thash_complete_matrix(uint64_t *matrixes, const uint8_t *rss_key, int size)
{
@@ -240,8 +268,8 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz,
/* allocate tailq entry */
te = rte_zmalloc("THASH_TAILQ_ENTRY", sizeof(*te), 0);
if (te == NULL) {
- RTE_LOG(ERR, HASH,
- "Can not allocate tailq entry for thash context %s\n",
+ HASH_LOG(ERR,
+ "Can not allocate tailq entry for thash context %s",
name);
rte_errno = ENOMEM;
goto exit;
@@ -249,7 +277,8 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz,
ctx = rte_zmalloc(NULL, sizeof(struct rte_thash_ctx) + key_len, 0);
if (ctx == NULL) {
- RTE_LOG(ERR, HASH, "thash ctx %s memory allocation failed\n",
+ HASH_LOG(ERR,
+ "thash ctx %s memory allocation failed",
name);
rte_errno = ENOMEM;
goto free_te;
@@ -272,7 +301,7 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz,
ctx->matrices = rte_zmalloc(NULL, key_len * sizeof(uint64_t),
RTE_CACHE_LINE_SIZE);
if (ctx->matrices == NULL) {
- RTE_LOG(ERR, HASH, "Cannot allocate matrices\n");
+ HASH_LOG(ERR, "Cannot allocate matrices");
rte_errno = ENOMEM;
goto free_ctx;
}
@@ -387,8 +416,8 @@ generate_subkey(struct rte_thash_ctx *ctx, struct thash_lfsr *lfsr,
if (((lfsr->bits_cnt + req_bits) > (1ULL << lfsr->deg) - 1) &&
((ctx->flags & RTE_THASH_IGNORE_PERIOD_OVERFLOW) !=
RTE_THASH_IGNORE_PERIOD_OVERFLOW)) {
- RTE_LOG(ERR, HASH,
- "Can't generate m-sequence due to period overflow\n");
+ HASH_LOG(ERR,
+ "Can't generate m-sequence due to period overflow");
return -ENOSPC;
}
@@ -467,9 +496,9 @@ insert_before(struct rte_thash_ctx *ctx,
return ret;
}
} else if ((next_ent != NULL) && (end > next_ent->offset)) {
- RTE_LOG(ERR, HASH,
- "Can't add helper %s due to conflict with existing"
- " helper %s\n", ent->name, next_ent->name);
+ HASH_LOG(ERR,
+ "Can't add helper %s due to conflict with existing helper %s",
+ ent->name, next_ent->name);
rte_free(ent);
return -ENOSPC;
}
@@ -516,9 +545,9 @@ insert_after(struct rte_thash_ctx *ctx,
int ret;
if ((next_ent != NULL) && (end > next_ent->offset)) {
- RTE_LOG(ERR, HASH,
- "Can't add helper %s due to conflict with existing"
- " helper %s\n", ent->name, next_ent->name);
+ HASH_LOG(ERR,
+ "Can't add helper %s due to conflict with existing helper %s",
+ ent->name, next_ent->name);
rte_free(ent);
return -EEXIST;
}
@@ -38,13 +38,8 @@ extern "C" {
* Calculated Toeplitz hash value.
*/
__rte_experimental
-static inline uint32_t
-rte_thash_gfni(const uint64_t *mtrx __rte_unused,
- const uint8_t *key __rte_unused, int len __rte_unused)
-{
- RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
- return 0;
-}
+uint32_t
+rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len);
/**
* Bulk implementation for Toeplitz hash.
@@ -67,17 +62,10 @@ rte_thash_gfni(const uint64_t *mtrx __rte_unused,
* Number of tuples to hash.
*/
__rte_experimental
-static inline void
-rte_thash_gfni_bulk(const uint64_t *mtrx __rte_unused,
- int len __rte_unused, uint8_t *tuple[] __rte_unused,
- uint32_t val[], uint32_t num)
-{
- unsigned int i;
-
- RTE_LOG(ERR, HASH, "%s is undefined under given arch\n", __func__);
- for (i = 0; i < num; i++)
- val[i] = 0;
-}
+void
+rte_thash_gfni_bulk(const uint64_t *mtrx,
+ int len, uint8_t *tuple[],
+ uint32_t val[], uint32_t num);
#endif /* RTE_THASH_GFNI_DEFINED */
@@ -51,4 +51,8 @@ EXPERIMENTAL {
rte_thash_complete_matrix;
rte_thash_get_gfni_matrices;
rte_thash_gfni_supported;
+
+ # added in 23.07
+ rte_thash_gfni;
+ rte_thash_gfni_bulk;
};