2022-06-03 19:15:11 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2022-11-01 20:26:26 +00:00
|
|
|
* Copyright (C) 2017 Intel Corporation.
|
2017-03-27 19:59:40 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2018-11-18 00:05:41 +00:00
|
|
|
#include "env_internal.h"
|
2017-03-27 19:59:40 +00:00
|
|
|
|
|
|
|
#include <rte_config.h>
|
|
|
|
#include <rte_lcore.h>
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
spdk_env_get_core_count(void)
|
|
|
|
{
|
|
|
|
return rte_lcore_count();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
spdk_env_get_current_core(void)
|
|
|
|
{
|
|
|
|
return rte_lcore_id();
|
|
|
|
}
|
|
|
|
|
2023-01-30 09:20:17 +00:00
|
|
|
uint32_t
|
|
|
|
spdk_env_get_main_core(void)
|
|
|
|
{
|
|
|
|
return rte_get_main_lcore();
|
|
|
|
}
|
|
|
|
|
2017-03-27 19:59:40 +00:00
|
|
|
uint32_t
|
|
|
|
spdk_env_get_first_core(void)
|
|
|
|
{
|
|
|
|
return rte_get_next_lcore(-1, 0, 0);
|
|
|
|
}
|
|
|
|
|
2017-12-22 00:21:35 +00:00
|
|
|
uint32_t
|
|
|
|
spdk_env_get_last_core(void)
|
|
|
|
{
|
|
|
|
uint32_t i;
|
2018-02-14 18:17:08 +00:00
|
|
|
uint32_t last_core = UINT32_MAX;
|
2017-12-22 00:21:35 +00:00
|
|
|
|
|
|
|
SPDK_ENV_FOREACH_CORE(i) {
|
|
|
|
last_core = i;
|
|
|
|
}
|
|
|
|
|
2018-02-22 03:02:05 +00:00
|
|
|
assert(last_core != UINT32_MAX);
|
|
|
|
|
2017-12-22 00:21:35 +00:00
|
|
|
return last_core;
|
|
|
|
}
|
|
|
|
|
2017-03-27 19:59:40 +00:00
|
|
|
uint32_t
|
|
|
|
spdk_env_get_next_core(uint32_t prev_core)
|
|
|
|
{
|
|
|
|
unsigned lcore;
|
|
|
|
|
|
|
|
lcore = rte_get_next_lcore(prev_core, 0, 0);
|
|
|
|
if (lcore == RTE_MAX_LCORE) {
|
|
|
|
return UINT32_MAX;
|
|
|
|
}
|
|
|
|
return lcore;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
spdk_env_get_socket_id(uint32_t core)
|
|
|
|
{
|
2018-09-08 21:18:05 +00:00
|
|
|
if (core >= RTE_MAX_LCORE) {
|
|
|
|
return SPDK_ENV_SOCKET_ID_ANY;
|
|
|
|
}
|
|
|
|
|
2017-03-27 19:59:40 +00:00
|
|
|
return rte_lcore_to_socket_id(core);
|
|
|
|
}
|
2017-06-02 18:40:23 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
spdk_env_thread_launch_pinned(uint32_t core, thread_start_fn fn, void *arg)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = rte_eal_remote_launch(fn, arg, core);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
spdk_env_thread_wait_all(void)
|
|
|
|
{
|
|
|
|
rte_eal_mp_wait_lcore();
|
|
|
|
}
|