| 378 | } |
| 379 | |
| 380 | static void * |
| 381 | table_create(struct rte_swx_table_params *params, |
| 382 | struct rte_swx_table_entry_list *entries, |
| 383 | const char *args __rte_unused, |
| 384 | int numa_node) |
| 385 | { |
| 386 | struct table *t = NULL; |
| 387 | size_t meta_sz, data_sz, total_size; |
| 388 | uint32_t entry_data_size; |
| 389 | uint32_t n_entries = count_entries(entries); |
| 390 | |
| 391 | /* Check input arguments. */ |
| 392 | if (!params || !params->key_size) |
| 393 | goto error; |
| 394 | |
| 395 | /* Memory allocation and initialization. */ |
| 396 | entry_data_size = 8 + params->action_data_size; |
| 397 | meta_sz = sizeof(struct table); |
| 398 | data_sz = n_entries * entry_data_size; |
| 399 | total_size = meta_sz + data_sz; |
| 400 | |
| 401 | t = env_malloc(total_size, RTE_CACHE_LINE_SIZE, numa_node); |
| 402 | if (!t) |
| 403 | goto error; |
| 404 | |
| 405 | memset(t, 0, total_size); |
| 406 | t->entry_data_size = entry_data_size; |
| 407 | t->total_size = total_size; |
| 408 | t->data = (uint8_t *)&t[1]; |
| 409 | |
| 410 | t->acl_ctx = acl_table_create(params, entries, n_entries, numa_node); |
| 411 | if (!t->acl_ctx) |
| 412 | goto error; |
| 413 | |
| 414 | entry_data_copy(t->data, entries, n_entries, entry_data_size); |
| 415 | |
| 416 | return t; |
| 417 | |
| 418 | error: |
| 419 | table_free(t); |
| 420 | return NULL; |
| 421 | } |
| 422 | |
| 423 | struct mailbox { |
| 424 |
nothing calls this directly
no test coverage detected