Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright (C) 2017 Intel Corporation. 3 : : * All rights reserved. 4 : : */ 5 : : 6 : : #include "env_internal.h" 7 : : 8 : : #include <rte_config.h> 9 : : #include <rte_lcore.h> 10 : : 11 : : #include "spdk/cpuset.h" 12 : : 13 : : uint32_t 14 : 53157 : spdk_env_get_core_count(void) 15 : : { 16 : 53157 : return rte_lcore_count(); 17 : : } 18 : : 19 : : uint32_t 20 : 476440182 : spdk_env_get_current_core(void) 21 : : { 22 : 476440182 : return rte_lcore_id(); 23 : : } 24 : : 25 : : uint32_t 26 : 0 : spdk_env_get_main_core(void) 27 : : { 28 : 0 : return rte_get_main_lcore(); 29 : : } 30 : : 31 : : uint32_t 32 : 75323 : spdk_env_get_first_core(void) 33 : : { 34 : 75323 : return rte_get_next_lcore(-1, 0, 0); 35 : : } 36 : : 37 : : uint32_t 38 : 2996 : spdk_env_get_last_core(void) 39 : : { 40 : : uint32_t i; 41 : 2996 : uint32_t last_core = UINT32_MAX; 42 : : 43 [ + + ]: 7409 : SPDK_ENV_FOREACH_CORE(i) { 44 : 4413 : last_core = i; 45 : : } 46 : : 47 [ - + ]: 2996 : assert(last_core != UINT32_MAX); 48 : : 49 : 2996 : return last_core; 50 : : } 51 : : 52 : : uint32_t 53 : 190327 : spdk_env_get_next_core(uint32_t prev_core) 54 : : { 55 : : unsigned lcore; 56 : : 57 : 190327 : lcore = rte_get_next_lcore(prev_core, 0, 0); 58 [ + + ]: 190327 : if (lcore == RTE_MAX_LCORE) { 59 : 74479 : return UINT32_MAX; 60 : : } 61 : 115848 : return lcore; 62 : : } 63 : : 64 : : uint32_t 65 : 0 : spdk_env_get_socket_id(uint32_t core) 66 : : { 67 [ # # ]: 0 : if (core >= RTE_MAX_LCORE) { 68 : 0 : return SPDK_ENV_SOCKET_ID_ANY; 69 : : } 70 : : 71 : 0 : return rte_lcore_to_socket_id(core); 72 : : } 73 : : 74 : : void 75 : 5 : spdk_env_get_cpuset(struct spdk_cpuset *cpuset) 76 : : { 77 : : uint32_t i; 78 : : 79 : 5 : spdk_cpuset_zero(cpuset); 80 [ + + ]: 13 : SPDK_ENV_FOREACH_CORE(i) { 81 : 8 : spdk_cpuset_set_cpu(cpuset, i, true); 82 : : } 83 : 5 : } 84 : : 85 : : int 86 : 1254 : spdk_env_thread_launch_pinned(uint32_t core, thread_start_fn fn, void *arg) 87 : : { 88 : : int rc; 89 : : 90 : 1254 : rc = rte_eal_remote_launch(fn, arg, core); 91 : : 92 : 1254 : return rc; 93 : : } 94 : : 95 : : void 96 : 6139 : spdk_env_thread_wait_all(void) 97 : : { 98 : 6139 : rte_eal_mp_wait_lcore(); 99 : 6139 : }