From 71afef2c14c62fa49c3fb8c10cccb0a0f472c61c Mon Sep 17 00:00:00 2001 From: Cristian Dumitrescu Date: Wed, 18 Oct 2017 16:03:50 +0100 Subject: [PATCH] apps: add mask-based hash functions Introduce mask-based hash functions in hash_func.h. Propagate their usage in test/test, test/test-pipeline and examples/ip_pipeline. Remove the non-mask-based hash function prototype from API (which was previously used as build workaround). Signed-off-by: Cristian Dumitrescu --- examples/ip_pipeline/pipeline/hash_func.h | 176 +++++++++++------- .../pipeline/pipeline_flow_classification.c | 10 +- .../pipeline_flow_classification_be.c | 9 +- .../pipeline/pipeline_passthrough_be.c | 14 +- .../pipeline/pipeline_routing_be.c | 2 +- lib/librte_table/rte_table_hash.h | 6 - test/test-pipeline/main.h | 5 +- test/test-pipeline/pipeline_hash.c | 113 ++--------- test/test/test_table.c | 1 + test/test/test_table.h | 3 +- test/test/test_table_combined.c | 14 +- test/test/test_table_tables.c | 12 +- 12 files changed, 155 insertions(+), 210 deletions(-) diff --git a/examples/ip_pipeline/pipeline/hash_func.h b/examples/ip_pipeline/pipeline/hash_func.h index b112369ca2..ecd4e05bfe 100644 --- a/examples/ip_pipeline/pipeline/hash_func.h +++ b/examples/ip_pipeline/pipeline/hash_func.h @@ -34,48 +34,56 @@ #define __INCLUDE_HASH_FUNC_H__ static inline uint64_t -hash_xor_key8(void *key, __rte_unused uint32_t key_size, uint64_t seed) +hash_xor_key8(void *key, void *mask, __rte_unused uint32_t key_size, + uint64_t seed) { uint64_t *k = key; + uint64_t *m = mask; uint64_t xor0; - xor0 = seed ^ k[0]; + xor0 = seed ^ (k[0] & m[0]); return (xor0 >> 32) ^ xor0; } static inline uint64_t -hash_xor_key16(void *key, __rte_unused uint32_t key_size, uint64_t seed) +hash_xor_key16(void *key, void *mask, __rte_unused uint32_t key_size, + uint64_t seed) { uint64_t *k = key; + uint64_t *m = mask; uint64_t xor0; - xor0 = (k[0] ^ seed) ^ k[1]; + xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]); return (xor0 >> 32) ^ xor0; } static inline uint64_t -hash_xor_key24(void *key, __rte_unused uint32_t key_size, uint64_t seed) +hash_xor_key24(void *key, void *mask, __rte_unused uint32_t key_size, + uint64_t seed) { uint64_t *k = key; + uint64_t *m = mask; uint64_t xor0; - xor0 = (k[0] ^ seed) ^ k[1]; + xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]); - xor0 ^= k[2]; + xor0 ^= k[2] & m[2]; return (xor0 >> 32) ^ xor0; } static inline uint64_t -hash_xor_key32(void *key, __rte_unused uint32_t key_size, uint64_t seed) +hash_xor_key32(void *key, void *mask, __rte_unused uint32_t key_size, + uint64_t seed) { uint64_t *k = key; + uint64_t *m = mask; uint64_t xor0, xor1; - xor0 = (k[0] ^ seed) ^ k[1]; - xor1 = k[2] ^ k[3]; + xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]); + xor1 = (k[2] & m[2]) ^ (k[3] & m[3]); xor0 ^= xor1; @@ -83,30 +91,34 @@ hash_xor_key32(void *key, __rte_unused uint32_t key_size, uint64_t seed) } static inline uint64_t -hash_xor_key40(void *key, __rte_unused uint32_t key_size, uint64_t seed) +hash_xor_key40(void *key, void *mask, __rte_unused uint32_t key_size, + uint64_t seed) { uint64_t *k = key; + uint64_t *m = mask; uint64_t xor0, xor1; - xor0 = (k[0] ^ seed) ^ k[1]; - xor1 = k[2] ^ k[3]; + xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]); + xor1 = (k[2] & m[2]) ^ (k[3] & m[3]); xor0 ^= xor1; - xor0 ^= k[4]; + xor0 ^= k[4] & m[4]; return (xor0 >> 32) ^ xor0; } static inline uint64_t -hash_xor_key48(void *key, __rte_unused uint32_t key_size, uint64_t seed) +hash_xor_key48(void *key, void *mask, __rte_unused uint32_t key_size, + uint64_t seed) { uint64_t *k = key; + uint64_t *m = mask; uint64_t xor0, xor1, xor2; - xor0 = (k[0] ^ seed) ^ k[1]; - xor1 = k[2] ^ k[3]; - xor2 = k[4] ^ k[5]; + xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]); + xor1 = (k[2] & m[2]) ^ (k[3] & m[3]); + xor2 = (k[4] & m[4]) ^ (k[5] & m[5]); xor0 ^= xor1; @@ -116,17 +128,19 @@ hash_xor_key48(void *key, __rte_unused uint32_t key_size, uint64_t seed) } static inline uint64_t -hash_xor_key56(void *key, __rte_unused uint32_t key_size, uint64_t seed) +hash_xor_key56(void *key, void *mask, __rte_unused uint32_t key_size, + uint64_t seed) { uint64_t *k = key; + uint64_t *m = mask; uint64_t xor0, xor1, xor2; - xor0 = (k[0] ^ seed) ^ k[1]; - xor1 = k[2] ^ k[3]; - xor2 = k[4] ^ k[5]; + xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]); + xor1 = (k[2] & m[2]) ^ (k[3] & m[3]); + xor2 = (k[4] & m[4]) ^ (k[5] & m[5]); xor0 ^= xor1; - xor2 ^= k[6]; + xor2 ^= k[6] & m[6]; xor0 ^= xor2; @@ -134,15 +148,17 @@ hash_xor_key56(void *key, __rte_unused uint32_t key_size, uint64_t seed) } static inline uint64_t -hash_xor_key64(void *key, __rte_unused uint32_t key_size, uint64_t seed) +hash_xor_key64(void *key, void *mask, __rte_unused uint32_t key_size, + uint64_t seed) { uint64_t *k = key; + uint64_t *m = mask; uint64_t xor0, xor1, xor2, xor3; - xor0 = (k[0] ^ seed) ^ k[1]; - xor1 = k[2] ^ k[3]; - xor2 = k[4] ^ k[5]; - xor3 = k[6] ^ k[7]; + xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]); + xor1 = (k[2] & m[2]) ^ (k[3] & m[3]); + xor2 = (k[4] & m[4]) ^ (k[5] & m[5]); + xor3 = (k[6] & m[6]) ^ (k[7] & m[7]); xor0 ^= xor1; xor2 ^= xor3; @@ -157,26 +173,30 @@ hash_xor_key64(void *key, __rte_unused uint32_t key_size, uint64_t seed) #include static inline uint64_t -hash_crc_key8(void *key, __rte_unused uint32_t key_size, uint64_t seed) +hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size, + uint64_t seed) { uint64_t *k = key; + uint64_t *m = mask; uint64_t crc0; - crc0 = _mm_crc32_u64(seed, k[0]); + crc0 = _mm_crc32_u64(seed, k[0] & m[0]); return crc0; } static inline uint64_t -hash_crc_key16(void *key, __rte_unused uint32_t key_size, uint64_t seed) +hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size, + uint64_t seed) { uint64_t *k = key; + uint64_t *m = mask; uint64_t k0, crc0, crc1; - k0 = k[0]; + k0 = k[0] & m[0]; crc0 = _mm_crc32_u64(k0, seed); - crc1 = _mm_crc32_u64(k0 >> 32, k[1]); + crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]); crc0 ^= crc1; @@ -184,16 +204,18 @@ hash_crc_key16(void *key, __rte_unused uint32_t key_size, uint64_t seed) } static inline uint64_t -hash_crc_key24(void *key, __rte_unused uint32_t key_size, uint64_t seed) +hash_crc_key24(void *key, void *mask, __rte_unused uint32_t key_size, + uint64_t seed) { uint64_t *k = key; + uint64_t *m = mask; uint64_t k0, k2, crc0, crc1; - k0 = k[0]; - k2 = k[2]; + k0 = k[0] & m[0]; + k2 = k[2] & m[2]; crc0 = _mm_crc32_u64(k0, seed); - crc1 = _mm_crc32_u64(k0 >> 32, k[1]); + crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]); crc0 = _mm_crc32_u64(crc0, k2); @@ -203,18 +225,20 @@ hash_crc_key24(void *key, __rte_unused uint32_t key_size, uint64_t seed) } static inline uint64_t -hash_crc_key32(void *key, __rte_unused uint32_t key_size, uint64_t seed) +hash_crc_key32(void *key, void *mask, __rte_unused uint32_t key_size, + uint64_t seed) { uint64_t *k = key; + uint64_t *m = mask; uint64_t k0, k2, crc0, crc1, crc2, crc3; - k0 = k[0]; - k2 = k[2]; + k0 = k[0] & m[0]; + k2 = k[2] & m[2]; crc0 = _mm_crc32_u64(k0, seed); - crc1 = _mm_crc32_u64(k0 >> 32, k[1]); + crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]); - crc2 = _mm_crc32_u64(k2, k[3]); + crc2 = _mm_crc32_u64(k2, k[3] & m[3]); crc3 = k2 >> 32; crc0 = _mm_crc32_u64(crc0, crc1); @@ -226,19 +250,21 @@ hash_crc_key32(void *key, __rte_unused uint32_t key_size, uint64_t seed) } static inline uint64_t -hash_crc_key40(void *key, __rte_unused uint32_t key_size, uint64_t seed) +hash_crc_key40(void *key, void *mask, __rte_unused uint32_t key_size, + uint64_t seed) { uint64_t *k = key; + uint64_t *m = mask; uint64_t k0, k2, crc0, crc1, crc2, crc3; - k0 = k[0]; - k2 = k[2]; + k0 = k[0] & m[0]; + k2 = k[2] & m[2]; crc0 = _mm_crc32_u64(k0, seed); - crc1 = _mm_crc32_u64(k0 >> 32, k[1]); + crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]); - crc2 = _mm_crc32_u64(k2, k[3]); - crc3 = _mm_crc32_u64(k2 >> 32, k[4]); + crc2 = _mm_crc32_u64(k2, k[3] & m[3]); + crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]); crc0 = _mm_crc32_u64(crc0, crc1); crc1 = _mm_crc32_u64(crc2, crc3); @@ -249,20 +275,22 @@ hash_crc_key40(void *key, __rte_unused uint32_t key_size, uint64_t seed) } static inline uint64_t -hash_crc_key48(void *key, __rte_unused uint32_t key_size, uint64_t seed) +hash_crc_key48(void *key, void *mask, __rte_unused uint32_t key_size, + uint64_t seed) { uint64_t *k = key; + uint64_t *m = mask; uint64_t k0, k2, k5, crc0, crc1, crc2, crc3; - k0 = k[0]; - k2 = k[2]; - k5 = k[5]; + k0 = k[0] & m[0]; + k2 = k[2] & m[2]; + k5 = k[5] & m[5]; crc0 = _mm_crc32_u64(k0, seed); - crc1 = _mm_crc32_u64(k0 >> 32, k[1]); + crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]); - crc2 = _mm_crc32_u64(k2, k[3]); - crc3 = _mm_crc32_u64(k2 >> 32, k[4]); + crc2 = _mm_crc32_u64(k2, k[3] & m[3]); + crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]); crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2); crc1 = _mm_crc32_u64(crc3, k5); @@ -273,22 +301,24 @@ hash_crc_key48(void *key, __rte_unused uint32_t key_size, uint64_t seed) } static inline uint64_t -hash_crc_key56(void *key, __rte_unused uint32_t key_size, uint64_t seed) +hash_crc_key56(void *key, void *mask, __rte_unused uint32_t key_size, + uint64_t seed) { uint64_t *k = key; + uint64_t *m = mask; uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5; - k0 = k[0]; - k2 = k[2]; - k5 = k[5]; + k0 = k[0] & m[0]; + k2 = k[2] & m[2]; + k5 = k[5] & m[5]; crc0 = _mm_crc32_u64(k0, seed); - crc1 = _mm_crc32_u64(k0 >> 32, k[1]); + crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]); - crc2 = _mm_crc32_u64(k2, k[3]); - crc3 = _mm_crc32_u64(k2 >> 32, k[4]); + crc2 = _mm_crc32_u64(k2, k[3] & m[3]); + crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]); - crc4 = _mm_crc32_u64(k5, k[6]); + crc4 = _mm_crc32_u64(k5, k[6] & m[6]); crc5 = k5 >> 32; crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2); @@ -300,23 +330,25 @@ hash_crc_key56(void *key, __rte_unused uint32_t key_size, uint64_t seed) } static inline uint64_t -hash_crc_key64(void *key, __rte_unused uint32_t key_size, uint64_t seed) +hash_crc_key64(void *key, void *mask, __rte_unused uint32_t key_size, + uint64_t seed) { uint64_t *k = key; + uint64_t *m = mask; uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5; - k0 = k[0]; - k2 = k[2]; - k5 = k[5]; + k0 = k[0] & m[0]; + k2 = k[2] & m[2]; + k5 = k[5] & m[5]; crc0 = _mm_crc32_u64(k0, seed); - crc1 = _mm_crc32_u64(k0 >> 32, k[1]); + crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]); - crc2 = _mm_crc32_u64(k2, k[3]); - crc3 = _mm_crc32_u64(k2 >> 32, k[4]); + crc2 = _mm_crc32_u64(k2, k[3] & m[3]); + crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]); - crc4 = _mm_crc32_u64(k5, k[6]); - crc5 = _mm_crc32_u64(k5 >> 32, k[7]); + crc4 = _mm_crc32_u64(k5, k[6] & m[6]); + crc5 = _mm_crc32_u64(k5 >> 32, k[7] & m[7]); crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2); crc1 = _mm_crc32_u64(crc3, (crc4 << 32) ^ crc5); diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c index 9ef50cc9ae..70b1938159 100644 --- a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c +++ b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c @@ -88,8 +88,10 @@ app_pipeline_fc_key_convert(struct pipeline_fc_key *key_in, uint32_t *signature) { uint8_t buffer[PIPELINE_FC_FLOW_KEY_MAX_SIZE]; + uint8_t m[PIPELINE_FC_FLOW_KEY_MAX_SIZE]; /* key mask */ void *key_buffer = (key_out) ? key_out : buffer; + memset(m, 0xFF, sizeof(m)); switch (key_in->type) { case FLOW_KEY_QINQ: { @@ -101,7 +103,7 @@ app_pipeline_fc_key_convert(struct pipeline_fc_key *key_in, qinq->cvlan = rte_cpu_to_be_16(key_in->key.qinq.cvlan); if (signature) - *signature = (uint32_t) hash_default_key8(qinq, 8, 0); + *signature = (uint32_t) hash_default_key8(qinq, m, 8, 0); return 0; } @@ -118,7 +120,7 @@ app_pipeline_fc_key_convert(struct pipeline_fc_key *key_in, ipv4->port_dst = rte_cpu_to_be_16(key_in->key.ipv4_5tuple.port_dst); if (signature) - *signature = (uint32_t) hash_default_key16(ipv4, 16, 0); + *signature = (uint32_t) hash_default_key16(ipv4, m, 16, 0); return 0; } @@ -136,7 +138,7 @@ app_pipeline_fc_key_convert(struct pipeline_fc_key *key_in, ipv6->port_dst = rte_cpu_to_be_16(key_in->key.ipv6_5tuple.port_dst); if (signature) - *signature = (uint32_t) hash_default_key64(ipv6, 64, 0); + *signature = (uint32_t) hash_default_key64(ipv6, m, 64, 0); return 0; } @@ -832,12 +834,12 @@ app_pipeline_fc_add_bulk(struct app_params *app, } /* Free resources */ - app_msg_free(app, rsp); for (i = rsp->n_keys; i < n_keys; i++) if (new_flow[i]) rte_free(flow[i]); + app_msg_free(app, rsp); rte_free(flow_rsp); rte_free(flow_req); rte_free(new_flow); diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c index e4a18e44d6..98467774c8 100644 --- a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c +++ b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c @@ -118,7 +118,7 @@ struct flow_table_entry { uint32_t pad; }; -rte_table_hash_op_hash_nomask hash_func[] = { +rte_table_hash_op_hash hash_func[] = { hash_default_key8, hash_default_key16, hash_default_key24, @@ -500,7 +500,7 @@ static void *pipeline_fc_init(struct pipeline_params *params, p_fc->key_mask : NULL, .n_keys = p_fc->n_flows, .n_buckets = p_fc->n_flows / 4, - .f_hash = (rte_table_hash_op_hash)hash_func[(p_fc->key_size / 8) - 1], + .f_hash = hash_func[(p_fc->key_size / 8) - 1], .seed = 0, }; @@ -519,19 +519,18 @@ static void *pipeline_fc_init(struct pipeline_params *params, switch (p_fc->key_size) { case 8: table_params.ops = &rte_table_hash_key8_ext_ops; - table_params.arg_create = &table_hash_params; break; case 16: table_params.ops = &rte_table_hash_key16_ext_ops; - table_params.arg_create = &table_hash_params; break; default: table_params.ops = &rte_table_hash_ext_ops; - table_params.arg_create = &table_hash_params; } + table_params.arg_create = &table_hash_params; + status = rte_pipeline_table_create(p->p, &table_params, &p->table_id[0]); diff --git a/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c b/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c index 6b57f83ac3..93eedbe828 100644 --- a/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c +++ b/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c @@ -52,7 +52,7 @@ struct pipeline_passthrough { struct pipeline p; struct pipeline_passthrough_params params; - rte_table_hash_op_hash_nomask f_hash; + rte_table_hash_op_hash f_hash; uint32_t swap_field0_offset[SWAP_DIM]; uint32_t swap_field1_offset[SWAP_DIM]; uint64_t swap_field_mask[SWAP_DIM]; @@ -102,7 +102,7 @@ pkt_work_dma( /* Read (dma_dst), compute (hash), write (hash) */ if (hash_enabled) { - uint32_t hash = p->f_hash(dma_dst, dma_size, 0); + uint32_t hash = p->f_hash(dma_src, dma_mask, dma_size, 0); *dma_hash = hash; if (lb_hash) { @@ -173,10 +173,10 @@ pkt4_work_dma( /* Read (dma_dst), compute (hash), write (hash) */ if (hash_enabled) { - uint32_t hash0 = p->f_hash(dma_dst0, dma_size, 0); - uint32_t hash1 = p->f_hash(dma_dst1, dma_size, 0); - uint32_t hash2 = p->f_hash(dma_dst2, dma_size, 0); - uint32_t hash3 = p->f_hash(dma_dst3, dma_size, 0); + uint32_t hash0 = p->f_hash(dma_src0, dma_mask, dma_size, 0); + uint32_t hash1 = p->f_hash(dma_src1, dma_mask, dma_size, 0); + uint32_t hash2 = p->f_hash(dma_src2, dma_mask, dma_size, 0); + uint32_t hash3 = p->f_hash(dma_src3, dma_mask, dma_size, 0); *dma_hash0 = hash0; *dma_hash1 = hash1; @@ -677,7 +677,7 @@ pipeline_passthrough_parse_args(struct pipeline_passthrough_params *p, return 0; } -static rte_table_hash_op_hash_nomask +static rte_table_hash_op_hash get_hash_function(struct pipeline_passthrough *p) { switch (p->params.dma_size) { diff --git a/examples/ip_pipeline/pipeline/pipeline_routing_be.c b/examples/ip_pipeline/pipeline/pipeline_routing_be.c index 796cde70ec..7aaf467632 100644 --- a/examples/ip_pipeline/pipeline/pipeline_routing_be.c +++ b/examples/ip_pipeline/pipeline/pipeline_routing_be.c @@ -1356,7 +1356,7 @@ pipeline_routing_init(struct pipeline_params *params, .key_mask = NULL, .n_keys = p_rt->params.n_arp_entries, .n_buckets = p_rt->params.n_arp_entries / 4, - .f_hash = (rte_table_hash_op_hash)hash_default_key8, + .f_hash = hash_default_key8, .seed = 0, }; diff --git a/lib/librte_table/rte_table_hash.h b/lib/librte_table/rte_table_hash.h index eb18c7a441..3c53d6ada5 100644 --- a/lib/librte_table/rte_table_hash.h +++ b/lib/librte_table/rte_table_hash.h @@ -129,12 +129,6 @@ struct rte_table_hash_params { uint64_t seed; }; -/** Hash function */ -typedef uint64_t (*rte_table_hash_op_hash_nomask)( - void *key, - uint32_t key_size, - uint64_t seed); - extern struct rte_table_ops rte_table_hash_ext_ops; extern struct rte_table_ops rte_table_hash_lru_ops; diff --git a/test/test-pipeline/main.h b/test/test-pipeline/main.h index 3685849278..26395a35ee 100644 --- a/test/test-pipeline/main.h +++ b/test/test-pipeline/main.h @@ -131,7 +131,10 @@ enum { void app_main_loop_rx(void); void app_main_loop_rx_metadata(void); -uint64_t test_hash(void *key, uint32_t key_size, uint64_t seed); +uint64_t test_hash(void *key, + void *key_mask, + uint32_t key_size, + uint64_t seed); void app_main_loop_worker(void); void app_main_loop_worker_pipeline_stub(void); diff --git a/test/test-pipeline/pipeline_hash.c b/test/test-pipeline/pipeline_hash.c index 24df81cde0..edc1663c5f 100644 --- a/test/test-pipeline/pipeline_hash.c +++ b/test/test-pipeline/pipeline_hash.c @@ -169,23 +169,23 @@ app_main_loop_worker_pipeline_hash(void) { "ring %d\n", i); } + struct rte_table_hash_params table_hash_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, + .seed = 0, + }; + /* Table configuration */ switch (app.pipeline_type) { case e_APP_PIPELINE_HASH_KEY8_EXT: case e_APP_PIPELINE_HASH_KEY16_EXT: case e_APP_PIPELINE_HASH_KEY32_EXT: { - struct rte_table_hash_params table_hash_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 = (rte_table_hash_op_hash)test_hash, - .seed = 0, - }; - struct rte_pipeline_table_params table_params = { .ops = &rte_table_hash_ext_ops, .arg_create = &table_hash_params, @@ -204,17 +204,6 @@ app_main_loop_worker_pipeline_hash(void) { case e_APP_PIPELINE_HASH_KEY16_LRU: case e_APP_PIPELINE_HASH_KEY32_LRU: { - struct rte_table_hash_params table_hash_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 = (rte_table_hash_op_hash)test_hash, - .seed = 0, - }; - struct rte_pipeline_table_params table_params = { .ops = &rte_table_hash_lru_ops, .arg_create = &table_hash_params, @@ -231,17 +220,6 @@ app_main_loop_worker_pipeline_hash(void) { case e_APP_PIPELINE_HASH_SPEC_KEY8_EXT: { - struct rte_table_hash_params table_hash_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 = (rte_table_hash_op_hash)test_hash, - .seed = 0, - }; - struct rte_pipeline_table_params table_params = { .ops = &rte_table_hash_key8_ext_ops, .arg_create = &table_hash_params, @@ -258,17 +236,6 @@ app_main_loop_worker_pipeline_hash(void) { case e_APP_PIPELINE_HASH_SPEC_KEY8_LRU: { - struct rte_table_hash_params table_hash_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 = (rte_table_hash_op_hash)test_hash, - .seed = 0, - }; - struct rte_pipeline_table_params table_params = { .ops = &rte_table_hash_key8_lru_ops, .arg_create = &table_hash_params, @@ -285,17 +252,6 @@ app_main_loop_worker_pipeline_hash(void) { case e_APP_PIPELINE_HASH_SPEC_KEY16_EXT: { - struct rte_table_hash_params table_hash_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 = (rte_table_hash_op_hash)test_hash, - .seed = 0, - }; - struct rte_pipeline_table_params table_params = { .ops = &rte_table_hash_key16_ext_ops, .arg_create = &table_hash_params, @@ -312,17 +268,6 @@ app_main_loop_worker_pipeline_hash(void) { case e_APP_PIPELINE_HASH_SPEC_KEY16_LRU: { - struct rte_table_hash_params table_hash_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 = (rte_table_hash_op_hash)test_hash, - .seed = 0, - }; - struct rte_pipeline_table_params table_params = { .ops = &rte_table_hash_key16_lru_ops, .arg_create = &table_hash_params, @@ -339,17 +284,6 @@ app_main_loop_worker_pipeline_hash(void) { case e_APP_PIPELINE_HASH_SPEC_KEY32_EXT: { - struct rte_table_hash_params table_hash_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 = (rte_table_hash_op_hash)test_hash, - .seed = 0, - }; - struct rte_pipeline_table_params table_params = { .ops = &rte_table_hash_key32_ext_ops, .arg_create = &table_hash_params, @@ -367,17 +301,6 @@ app_main_loop_worker_pipeline_hash(void) { case e_APP_PIPELINE_HASH_SPEC_KEY32_LRU: { - struct rte_table_hash_params table_hash_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 = (rte_table_hash_op_hash)test_hash, - .seed = 0, - }; - struct rte_pipeline_table_params table_params = { .ops = &rte_table_hash_key32_lru_ops, .arg_create = &table_hash_params, @@ -402,17 +325,6 @@ app_main_loop_worker_pipeline_hash(void) { case e_APP_PIPELINE_HASH_CUCKOO_KEY112: case e_APP_PIPELINE_HASH_CUCKOO_KEY128: { - struct rte_table_hash_params table_hash_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 = (rte_table_hash_op_hash)test_hash, - .seed = 0, - }; - struct rte_pipeline_table_params table_params = { .ops = &rte_table_hash_cuckoo_ops, .arg_create = &table_hash_params, @@ -485,6 +397,7 @@ app_main_loop_worker_pipeline_hash(void) { uint64_t test_hash( void *key, + __attribute__((unused)) void *key_mask, __attribute__((unused)) uint32_t key_size, __attribute__((unused)) uint64_t seed) { @@ -547,7 +460,7 @@ app_main_loop_rx_metadata(void) { } else continue; - *signature = test_hash(key, 0, 0); + *signature = test_hash(key, NULL, 0, 0); } do { diff --git a/test/test/test_table.c b/test/test/test_table.c index 9e9eed886f..db7d4e6648 100644 --- a/test/test/test_table.c +++ b/test/test/test_table.c @@ -72,6 +72,7 @@ static void app_init_rings(void); static void app_init_mbuf_pools(void); uint64_t pipeline_test_hash(void *key, + __attribute__((unused)) void *key_mask, __attribute__((unused)) uint32_t key_size, __attribute__((unused)) uint64_t seed) { diff --git a/test/test/test_table.h b/test/test/test_table.h index 84d1845a3d..8c1df333b1 100644 --- a/test/test/test_table.h +++ b/test/test/test_table.h @@ -94,7 +94,7 @@ APP_METADATA_OFFSET(32)); \ k32 = (uint32_t *) key; \ k32[0] = (value); \ - *signature = pipeline_test_hash(key, 0, 0); \ + *signature = pipeline_test_hash(key, NULL, 0, 0); \ rte_ring_enqueue((ring), m); \ } while (0) @@ -131,6 +131,7 @@ /* Function definitions */ uint64_t pipeline_test_hash( void *key, + __attribute__((unused)) void *key_mask, __attribute__((unused)) uint32_t key_size, __attribute__((unused)) uint64_t seed); diff --git a/test/test/test_table_combined.c b/test/test/test_table_combined.c index 9515dd085b..e863788475 100644 --- a/test/test/test_table_combined.c +++ b/test/test/test_table_combined.c @@ -448,7 +448,7 @@ test_table_hash8lru(void) .key_mask = NULL, .n_keys = 1 << 16, .n_buckets = 1 << 16, - .f_hash = (rte_table_hash_op_hash)pipeline_test_hash, + .f_hash = pipeline_test_hash, .seed = 0, }; @@ -509,7 +509,7 @@ test_table_hash16lru(void) .key_mask = NULL, .n_keys = 1 << 16, .n_buckets = 1 << 16, - .f_hash = (rte_table_hash_op_hash)pipeline_test_hash, + .f_hash = pipeline_test_hash, .seed = 0, }; @@ -570,7 +570,7 @@ test_table_hash32lru(void) .key_mask = NULL, .n_keys = 1 << 16, .n_buckets = 1 << 16, - .f_hash = (rte_table_hash_op_hash)pipeline_test_hash, + .f_hash = pipeline_test_hash, .seed = 0, }; @@ -631,7 +631,7 @@ test_table_hash8ext(void) .key_mask = NULL, .n_keys = 1 << 16, .n_buckets = 1 << 16, - .f_hash = (rte_table_hash_op_hash)pipeline_test_hash, + .f_hash = pipeline_test_hash, .seed = 0, }; @@ -692,7 +692,7 @@ test_table_hash16ext(void) .key_mask = NULL, .n_keys = 1 << 16, .n_buckets = 1 << 16, - .f_hash = (rte_table_hash_op_hash)pipeline_test_hash, + .f_hash = pipeline_test_hash, .seed = 0, }; @@ -753,7 +753,7 @@ test_table_hash32ext(void) .key_mask = NULL, .n_keys = 1 << 16, .n_buckets = 1 << 16, - .f_hash = (rte_table_hash_op_hash)pipeline_test_hash, + .f_hash = pipeline_test_hash, .seed = 0, }; @@ -814,7 +814,7 @@ test_table_hash_cuckoo_combined(void) .key_mask = NULL, .n_keys = 1 << 16, .n_buckets = 1 << 16, - .f_hash = (rte_table_hash_op_hash)pipeline_test_hash, + .f_hash = pipeline_test_hash, .seed = 0, }; diff --git a/test/test/test_table_tables.c b/test/test/test_table_tables.c index 7f04212ed7..a1b0c582c5 100644 --- a/test/test/test_table_tables.c +++ b/test/test/test_table_tables.c @@ -60,7 +60,7 @@ table_test table_tests[] = { memset(key, 0, 32); \ k32 = (uint32_t *) key; \ k32[0] = (value); \ - *signature = pipeline_test_hash(key, 0, 0); \ + *signature = pipeline_test_hash(key, NULL, 0, 0); \ } while (0) unsigned n_table_tests = RTE_DIM(table_tests); @@ -674,7 +674,7 @@ test_table_hash_lru_generic(struct rte_table_ops *ops, uint32_t key_size) .key_mask = NULL, .n_keys = 1 << 10, .n_buckets = 1 << 10, - .f_hash = (rte_table_hash_op_hash)pipeline_test_hash, + .f_hash = pipeline_test_hash, .seed = 0, }; @@ -691,7 +691,7 @@ test_table_hash_lru_generic(struct rte_table_ops *ops, uint32_t key_size) if (table != NULL) return -4; - hash_params.f_hash = (rte_table_hash_op_hash)pipeline_test_hash; + hash_params.f_hash = pipeline_test_hash; table = ops->f_create(&hash_params, 0, 1); if (table == NULL) @@ -777,7 +777,7 @@ test_table_hash_ext_generic(struct rte_table_ops *ops, uint32_t key_size) .key_mask = NULL, .n_keys = 1 << 10, .n_buckets = 1 << 10, - .f_hash = (rte_table_hash_op_hash)pipeline_test_hash, + .f_hash = pipeline_test_hash, .seed = 0, }; @@ -801,7 +801,7 @@ test_table_hash_ext_generic(struct rte_table_ops *ops, uint32_t key_size) if (table != NULL) return -4; - hash_params.f_hash = (rte_table_hash_op_hash)pipeline_test_hash; + hash_params.f_hash = pipeline_test_hash; table = ops->f_create(&hash_params, 0, 1); if (table == NULL) @@ -970,7 +970,7 @@ test_table_hash_cuckoo(void) if (table != NULL) return -4; - cuckoo_params.f_hash = (rte_table_hash_op_hash)pipeline_test_hash; + cuckoo_params.f_hash = pipeline_test_hash; cuckoo_params.name = NULL; table = rte_table_hash_cuckoo_ops.f_create(&cuckoo_params, -- 2.20.1