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

Function init_hash

dpdk/app/test/test_rcu_qsbr.c:1042–1092  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1040}
1041
1042static struct rte_hash *
1043init_hash(int hash_id)
1044{
1045 int i;
1046 struct rte_hash *h = NULL;
1047
1048 sprintf(hash_name[hash_id], "hash%d", hash_id);
1049 struct rte_hash_parameters hash_params = {
1050 .entries = TOTAL_ENTRY,
1051 .key_len = sizeof(uint32_t),
1052 .hash_func_init_val = 0,
1053 .socket_id = rte_socket_id(),
1054 .hash_func = rte_hash_crc,
1055 .extra_flag =
1056 RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF,
1057 .name = hash_name[hash_id],
1058 };
1059
1060 h = rte_hash_create(&hash_params);
1061 if (h == NULL) {
1062 printf("Hash create Failed\n");
1063 return NULL;
1064 }
1065
1066 for (i = 0; i < TOTAL_ENTRY; i++) {
1067 hash_data[hash_id][i] =
1068 rte_zmalloc(NULL, sizeof(uint32_t) * RTE_MAX_LCORE, 0);
1069 if (hash_data[hash_id][i] == NULL) {
1070 printf("No memory\n");
1071 return NULL;
1072 }
1073 }
1074 keys = rte_malloc(NULL, sizeof(uint32_t) * TOTAL_ENTRY, 0);
1075 if (keys == NULL) {
1076 printf("No memory\n");
1077 return NULL;
1078 }
1079
1080 for (i = 0; i < TOTAL_ENTRY; i++)
1081 keys[i] = i;
1082
1083 for (i = 0; i < TOTAL_ENTRY; i++) {
1084 if (rte_hash_add_key_data(h, keys + i,
1085 (void *)((uintptr_t)hash_data[hash_id][i]))
1086 < 0) {
1087 printf("Hash key add Failed #%d\n", i);
1088 return NULL;
1089 }
1090 }
1091 return h;
1092}
1093
1094/*
1095 * Functional test:

Callers 2

test_rcu_qsbr_sw_sv_3qsFunction · 0.70
test_rcu_qsbr_mw_mv_mqsFunction · 0.70

Calls 7

sprintfFunction · 0.85
rte_socket_idFunction · 0.85
rte_hash_createFunction · 0.85
rte_zmallocFunction · 0.85
rte_mallocFunction · 0.85
rte_hash_add_key_dataFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected