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

Function test_predictable_rss_min_seq

dpdk/app/test/test_thash.c:574–626  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

572}
573
574static int
575test_predictable_rss_min_seq(void)
576{
577 struct rte_thash_ctx *ctx;
578 struct rte_thash_subtuple_helper *h;
579 const int key_len = 40;
580 int reta_sz = 6;
581 uint8_t initial_key[key_len];
582 const uint8_t *new_key;
583 int ret;
584 union rte_thash_tuple tuple;
585 uint32_t orig_hash, adj_hash, adj;
586 unsigned int desired_value = 27 & HASH_MSK(reta_sz);
587 uint16_t port_value = 22;
588
589 memset(initial_key, 0, key_len);
590
591 ctx = rte_thash_init_ctx("test", key_len, reta_sz, initial_key,
592 RTE_THASH_MINIMAL_SEQ);
593 RTE_TEST_ASSERT(ctx != NULL, "can not create thash ctx\n");
594
595 ret = rte_thash_add_helper(ctx, "snat", sizeof(uint16_t) * 8,
596 offsetof(union rte_thash_tuple, v4.sport) * 8);
597 RTE_TEST_ASSERT(ret == 0, "can not add helper, ret %d\n", ret);
598
599 h = rte_thash_get_helper(ctx, "snat");
600 RTE_TEST_ASSERT(h != NULL, "can not find helper\n");
601
602 new_key = rte_thash_get_key(ctx);
603 tuple.v4.src_addr = RTE_IPV4(0, 0, 0, 0);
604 tuple.v4.dst_addr = RTE_IPV4(0, 0, 0, 0);
605 tuple.v4.sport = 0;
606 tuple.v4.sport = rte_cpu_to_be_16(port_value);
607 tuple.v4.dport = 0;
608 tuple.v4.sctp_tag = rte_be_to_cpu_32(tuple.v4.sctp_tag);
609
610 orig_hash = rte_softrss((uint32_t *)&tuple,
611 RTE_THASH_V4_L4_LEN, new_key);
612 adj = rte_thash_get_complement(h, orig_hash, desired_value);
613
614 tuple.v4.sctp_tag = rte_cpu_to_be_32(tuple.v4.sctp_tag);
615 tuple.v4.sport ^= rte_cpu_to_be_16(adj);
616 tuple.v4.sctp_tag = rte_be_to_cpu_32(tuple.v4.sctp_tag);
617
618 adj_hash = rte_softrss((uint32_t *)&tuple,
619 RTE_THASH_V4_L4_LEN, new_key);
620 RTE_TEST_ASSERT((adj_hash & HASH_MSK(reta_sz)) ==
621 desired_value, "bad desired value\n");
622
623 rte_thash_free_ctx(ctx);
624
625 return TEST_SUCCESS;
626}
627
628/*
629 * This test creates 7 subranges in the following order:

Callers

nothing calls this directly

Calls 8

memsetFunction · 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