* Init the memzone subsystem */
| 421 | * Init the memzone subsystem |
| 422 | */ |
| 423 | int |
| 424 | rte_eal_memzone_init(void) |
| 425 | { |
| 426 | struct rte_mem_config *mcfg; |
| 427 | int ret = 0; |
| 428 | |
| 429 | /* get pointer to global configuration */ |
| 430 | mcfg = rte_eal_get_configuration()->mem_config; |
| 431 | |
| 432 | rte_rwlock_write_lock(&mcfg->mlock); |
| 433 | |
| 434 | if (rte_eal_process_type() == RTE_PROC_PRIMARY && |
| 435 | rte_fbarray_init(&mcfg->memzones, "memzone", |
| 436 | rte_memzone_max_get(), sizeof(struct rte_memzone))) { |
| 437 | RTE_LOG(ERR, EAL, "Cannot allocate memzone list\n"); |
| 438 | ret = -1; |
| 439 | } else if (rte_eal_process_type() == RTE_PROC_SECONDARY && |
| 440 | rte_fbarray_attach(&mcfg->memzones)) { |
| 441 | RTE_LOG(ERR, EAL, "Cannot attach to memzone list\n"); |
| 442 | ret = -1; |
| 443 | } |
| 444 | |
| 445 | rte_rwlock_write_unlock(&mcfg->mlock); |
| 446 | |
| 447 | return ret; |
| 448 | } |
| 449 | |
| 450 | /* Walk all reserved memory zones */ |
| 451 | void rte_memzone_walk(void (*func)(const struct rte_memzone *, void *), |
no test coverage detected