-static void
-setup_hash(int socketid)
-{
- struct rte_hash_parameters ipv4_udp_replay_hash_params = {
- .name = NULL,
- .entries = UDP_Replay_HASH_ENTRIES,
- .key_len = sizeof(union ipv4_5tuple_host),
- .hash_func = ipv4_hash_crc,
- .hash_func_init_val = 0,
- };
-
- struct rte_hash_parameters ipv6_udp_replay_hash_params = {
- .name = NULL,
- .entries = UDP_Replay_HASH_ENTRIES,
- .key_len = sizeof(union ipv6_5tuple_host),
- .hash_func = ipv6_hash_crc,
- .hash_func_init_val = 0,
- };
-
- char s[64];
-
- /* create ipv4 hash */
- snprintf(s, sizeof(s), "ipv4_udp_replay_hash_%d", socketid);
- ipv4_udp_replay_hash_params.name = s;
- ipv4_udp_replay_hash_params.socket_id = socketid;
- ipv4_udp_replay_lookup_struct[socketid] = rte_hash_create(&ipv4_udp_replay_hash_params);
- if (ipv4_udp_replay_lookup_struct[socketid] == NULL)
- rte_exit(EXIT_FAILURE, "Unable to create the udp_replay hash on "
- "socket %d\n", socketid);
-
- /* create ipv6 hash */
- snprintf(s, sizeof(s), "ipv6_udp_replay_hash_%d", socketid);
- ipv6_udp_replay_hash_params.name = s;
- ipv6_udp_replay_hash_params.socket_id = socketid;
- ipv6_udp_replay_lookup_struct[socketid] = rte_hash_create(&ipv6_udp_replay_hash_params);
- if (ipv6_udp_replay_lookup_struct[socketid] == NULL)
- rte_exit(EXIT_FAILURE, "Unable to create the udp_replay hash on "
- "socket %d\n", socketid);
-
- if (hash_entry_number != HASH_ENTRY_NUMBER_DEFAULT) {
- /* For testing hash matching with a large number of flows we
- * generate millions of IP 5-tuples with an incremented dst
- * address to initialize the hash table. */
- if (ipv6 == 0) {
- /* populate the ipv4 hash */
- populate_ipv4_many_flow_into_table(
- ipv4_udp_replay_lookup_struct[socketid], hash_entry_number);
- } else {
- /* populate the ipv6 hash */
- populate_ipv6_many_flow_into_table(
- ipv6_udp_replay_lookup_struct[socketid], hash_entry_number);
- }
- } else {
- /* Use data in ipv4/ipv6 udp_replay lookup table directly to initialize the hash table */
- if (ipv6 == 0) {
- /* populate the ipv4 hash */
- populate_ipv4_few_flow_into_table(ipv4_udp_replay_lookup_struct[socketid]);
- } else {
- /* populate the ipv6 hash */
- populate_ipv6_few_flow_into_table(ipv6_udp_replay_lookup_struct[socketid]);
- }
- }
-}