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

Function table_params_get

dpdk/lib/table/rte_swx_table_learner.c:172–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172static int
173table_params_get(struct table_params *p, struct rte_swx_table_learner_params *params)
174{
175 uint32_t i;
176
177 /* Check input parameters. */
178 if (!params ||
179 !params->key_size ||
180 !params->n_keys_max ||
181 (params->n_keys_max > 1U << 31) ||
182 !params->key_timeout ||
183 !params->n_key_timeouts ||
184 (params->n_key_timeouts > RTE_SWX_TABLE_LEARNER_N_KEY_TIMEOUTS_MAX))
185 return -EINVAL;
186
187 if (params->key_mask0) {
188 for (i = 0; i < params->key_size; i++)
189 if (params->key_mask0[i] != 0xFF)
190 break;
191
192 if (i < params->key_size)
193 return -EINVAL;
194 }
195
196 for (i = 0; i < params->n_key_timeouts; i++)
197 if (!params->key_timeout[i])
198 return -EINVAL;
199
200 /* Key. */
201 p->key_size = params->key_size;
202
203 p->key_size_pow2 = rte_align64pow2(p->key_size);
204
205 p->key_size_log2 = rte_ctz64(p->key_size_pow2);
206
207 p->key_offset = params->key_offset;
208
209 /* Data. */
210 p->action_data_size = params->action_data_size;
211
212 p->data_size_pow2 = rte_align64pow2(sizeof(uint64_t) + p->action_data_size);
213
214 p->data_size_log2 = rte_ctz64(p->data_size_pow2);
215
216 /* Buckets. */
217 p->n_buckets = rte_align32pow2(params->n_keys_max);
218
219 p->bucket_mask = p->n_buckets - 1;
220
221 p->bucket_key_all_size = TABLE_KEYS_PER_BUCKET * p->key_size_pow2;
222
223 p->bucket_size = rte_align64pow2(sizeof(struct table_bucket) +
224 p->bucket_key_all_size +
225 TABLE_KEYS_PER_BUCKET * p->data_size_pow2);
226
227 p->bucket_size_log2 = rte_ctz64(p->bucket_size);
228
229 p->hash_func = params->hash_func ? params->hash_func : rte_hash_crc;

Calls 5

rte_ctz64Function · 0.85
rte_swx_keycmp_func_getFunction · 0.85
timeout_convertFunction · 0.85
rte_align64pow2Function · 0.50
rte_align32pow2Function · 0.50

Tested by

no test coverage detected