MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_predictable_rss_multirange

Function test_predictable_rss_multirange

dpdk/app/test/test_thash.c:655–721  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

653};
654
655static int
656test_predictable_rss_multirange(void)
657{
658 struct rte_thash_ctx *ctx;
659 struct rte_thash_subtuple_helper *h[RTE_DIM(rng_arr)];
660 const uint8_t *new_key;
661 const int key_len = 40;
662 int reta_sz = 7;
663 unsigned int i, j, k;
664 int ret;
665 uint32_t desired_value = rte_rand() & HASH_MSK(reta_sz);
666 uint8_t tuples[RTE_DIM(rng_arr)][16] = { {0} };
667 uint32_t *ptr;
668 uint32_t hashes[RTE_DIM(rng_arr)];
669 uint32_t adj_hashes[RTE_DIM(rng_arr)];
670 uint32_t adj;
671
672 ctx = rte_thash_init_ctx("test", key_len, reta_sz, NULL, 0);
673 RTE_TEST_ASSERT(ctx != NULL, "can not create thash ctx\n");
674
675 for (i = 0; i < RTE_DIM(rng_arr); i++) {
676 ret = rte_thash_add_helper(ctx, rng_arr[i].name,
677 rng_arr[i].len, rng_arr[i].offset);
678 RTE_TEST_ASSERT(ret == 0, "can not add helper\n");
679
680 h[i] = rte_thash_get_helper(ctx, rng_arr[i].name);
681 RTE_TEST_ASSERT(h[i] != NULL, "can not find helper\n");
682 }
683 new_key = rte_thash_get_key(ctx);
684
685 /*
686 * calculate hashes, complements, then adjust keys with
687 * complements and recalculate hashes
688 */
689 for (i = 0; i < RTE_DIM(rng_arr); i++) {
690 for (k = 0; k < 100; k++) {
691 /* init with random keys */
692 ptr = (uint32_t *)&tuples[i][0];
693 for (j = 0; j < 4; j++)
694 ptr[j] = rte_rand();
695 /* convert keys from BE to CPU byte order */
696 for (j = 0; j < 4; j++)
697 ptr[j] = rte_be_to_cpu_32(ptr[j]);
698
699 hashes[i] = rte_softrss(ptr, 4, new_key);
700 adj = rte_thash_get_complement(h[i], hashes[i],
701 desired_value);
702 /* convert back to BE to adjust the value */
703 for (j = 0; j < 4; j++)
704 ptr[j] = rte_cpu_to_be_32(ptr[j]);
705
706 tuples[i][rng_arr[i].byte_idx] ^= adj;
707
708 for (j = 0; j < 4; j++)
709 ptr[j] = rte_be_to_cpu_32(ptr[j]);
710
711 adj_hashes[i] = rte_softrss(ptr, 4, new_key);
712 RTE_TEST_ASSERT((adj_hashes[i] & HASH_MSK(reta_sz)) ==

Callers

nothing calls this directly

Calls 8

rte_randFunction · 0.85
rte_thash_init_ctxFunction · 0.85
rte_thash_add_helperFunction · 0.85
rte_thash_get_helperFunction · 0.85
rte_thash_get_keyFunction · 0.85
rte_softrssFunction · 0.85
rte_thash_get_complementFunction · 0.85
rte_thash_free_ctxFunction · 0.85

Tested by

no test coverage detected