| 361 | } |
| 362 | |
| 363 | int |
| 364 | rte_thread_register(void) |
| 365 | { |
| 366 | unsigned int lcore_id; |
| 367 | rte_cpuset_t cpuset; |
| 368 | |
| 369 | /* EAL init flushes all lcores, we can't register before. */ |
| 370 | if (eal_get_internal_configuration()->init_complete != 1) { |
| 371 | RTE_LOG(DEBUG, EAL, "Called %s before EAL init.\n", __func__); |
| 372 | rte_errno = EINVAL; |
| 373 | return -1; |
| 374 | } |
| 375 | if (!rte_mp_disable()) { |
| 376 | RTE_LOG(ERR, EAL, "Multiprocess in use, registering non-EAL threads is not supported.\n"); |
| 377 | rte_errno = EINVAL; |
| 378 | return -1; |
| 379 | } |
| 380 | if (rte_thread_get_affinity_by_id(rte_thread_self(), &cpuset) != 0) |
| 381 | CPU_ZERO(&cpuset); |
| 382 | lcore_id = eal_lcore_non_eal_allocate(); |
| 383 | if (lcore_id >= RTE_MAX_LCORE) |
| 384 | lcore_id = LCORE_ID_ANY; |
| 385 | __rte_thread_init(lcore_id, &cpuset); |
| 386 | if (lcore_id == LCORE_ID_ANY) { |
| 387 | rte_errno = ENOMEM; |
| 388 | return -1; |
| 389 | } |
| 390 | RTE_LOG(DEBUG, EAL, "Registered non-EAL thread as lcore %u.\n", |
| 391 | lcore_id); |
| 392 | return 0; |
| 393 | } |
| 394 | |
| 395 | void |
| 396 | rte_thread_unregister(void) |