summaryrefslogtreecommitdiff
path: root/test/test-pipeline
diff options
context:
space:
mode:
authorJasvinder Singh <jasvinder.singh@intel.com>2018-05-08 15:17:18 +0100
committerCristian Dumitrescu <cristian.dumitrescu@intel.com>2018-05-08 16:19:58 +0200
commit8ea41438832a360aed2b7ba49fb75e310a2ff1dc (patch)
tree481e8e2e8eb9b65725fc722908d75dc1cec047e2 /test/test-pipeline
parent7959831b4d1b52f6525acb63ce0d94eeeb396855 (diff)
downloaddpdk-8ea41438832a360aed2b7ba49fb75e310a2ff1dc.zip
dpdk-8ea41438832a360aed2b7ba49fb75e310a2ff1dc.tar.gz
dpdk-8ea41438832a360aed2b7ba49fb75e310a2ff1dc.tar.xz
table: add dedicated params struct for cuckoo hash
Add dedicated parameter structure for cuckoo hash. The cuckoo hash from librte_hash uses slightly different prototype for the hash function (no key_mask parameter, 32-bit seed and return value) that require either of the following approaches: 1/ Function pointer conversion: gcc 8.1 warning [1], misleading [2] 2/ Union within the parameter structure: pollutes a very generic API parameter structure with some implementation dependent detail (i.e. key mask not available for one of the available implementations) 3/ Using opaque pointer for hash function: same issue from 2/ 4/ Different parameter structure: avoid issue from 2/; hopefully, it won't be long before librte_hash implements the key mask feature, so the generic API structure could be used. [1] http://www.dpdk.org/ml/archives/dev/2018-April/094950.html [2] http://www.dpdk.org/ml/archives/dev/2018-April/096250.html Fixes: 5a80bf0ae613 ("table: add cuckoo hash") Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Diffstat (limited to 'test/test-pipeline')
-rw-r--r--test/test-pipeline/main.h4
-rw-r--r--test/test-pipeline/pipeline_hash.c26
2 files changed, 29 insertions, 1 deletions
diff --git a/test/test-pipeline/main.h b/test/test-pipeline/main.h
index f844e94..59dcfdd 100644
--- a/test/test-pipeline/main.h
+++ b/test/test-pipeline/main.h
@@ -107,6 +107,10 @@ uint64_t test_hash(void *key,
uint32_t key_size,
uint64_t seed);
+uint32_t test_hash_cuckoo(const void *key,
+ uint32_t key_size,
+ uint32_t seed);
+
void app_main_loop_worker(void);
void app_main_loop_worker_pipeline_stub(void);
void app_main_loop_worker_pipeline_hash(void);
diff --git a/test/test-pipeline/pipeline_hash.c b/test/test-pipeline/pipeline_hash.c
index 11e2402..c201472 100644
--- a/test/test-pipeline/pipeline_hash.c
+++ b/test/test-pipeline/pipeline_hash.c
@@ -15,6 +15,7 @@
#include <rte_port_ring.h>
#include <rte_table_hash.h>
#include <rte_hash.h>
+#include <rte_table_hash_cuckoo.h>
#include <rte_pipeline.h>
#include "main.h"
@@ -151,6 +152,17 @@ app_main_loop_worker_pipeline_hash(void) {
.seed = 0,
};
+ struct rte_table_hash_cuckoo_params table_hash_cuckoo_params = {
+ .name = "TABLE",
+ .key_size = key_size,
+ .key_offset = APP_METADATA_OFFSET(32),
+ .key_mask = NULL,
+ .n_keys = 1 << 24,
+ .n_buckets = 1 << 22,
+ .f_hash = test_hash_cuckoo,
+ .seed = 0,
+ };
+
/* Table configuration */
switch (app.pipeline_type) {
case e_APP_PIPELINE_HASH_KEY8_EXT:
@@ -298,7 +310,7 @@ app_main_loop_worker_pipeline_hash(void) {
{
struct rte_pipeline_table_params table_params = {
.ops = &rte_table_hash_cuckoo_ops,
- .arg_create = &table_hash_params,
+ .arg_create = &table_hash_cuckoo_params,
.f_action_hit = NULL,
.f_action_miss = NULL,
.arg_ah = NULL,
@@ -379,6 +391,18 @@ uint64_t test_hash(
return signature;
}
+uint32_t test_hash_cuckoo(
+ const void *key,
+ __attribute__((unused)) uint32_t key_size,
+ __attribute__((unused)) uint32_t seed)
+{
+ const uint32_t *k32 = key;
+ uint32_t ip_dst = rte_be_to_cpu_32(k32[0]);
+ uint32_t signature = (ip_dst >> 2) | ((ip_dst & 0x3) << 30);
+
+ return signature;
+}
+
void
app_main_loop_rx_metadata(void) {
uint32_t i, j;