X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fcommon%2Finclude%2Frte_lcore.h;h=e03264e35fb31a7ed8fc30de05935468a055de22;hb=2a0911ec8bb64b09c9697a63cf3ea96d78e12e59;hp=a0b4356952fae420de1f39065dc55d012eb8be89;hpb=8828a3210c5978bbe3b9b426bc31be8f420bd15a;p=dpdk.git diff --git a/lib/librte_eal/common/include/rte_lcore.h b/lib/librte_eal/common/include/rte_lcore.h index a0b4356952..e03264e35f 100644 --- a/lib/librte_eal/common/include/rte_lcore.h +++ b/lib/librte_eal/common/include/rte_lcore.h @@ -48,7 +48,14 @@ extern "C" { #endif -#define LCORE_ID_ANY -1 /**< Any lcore. */ +#define LCORE_ID_ANY UINT32_MAX /**< Any lcore. */ + +#if defined(__linux__) + typedef cpu_set_t rte_cpuset_t; +#elif defined(__FreeBSD__) +#include + typedef cpuset_t rte_cpuset_t; +#endif /** * Structure storing internal configuration (per-lcore) @@ -64,6 +71,8 @@ struct lcore_config { volatile enum rte_lcore_state_t state; /**< lcore state */ unsigned socket_id; /**< physical socket id for this lcore */ unsigned core_id; /**< core number on socket for this lcore */ + int core_index; /**< relative index, starting from 0 */ + rte_cpuset_t cpuset; /**< cpu set which the lcore affinity to */ }; /** @@ -71,12 +80,13 @@ struct lcore_config { */ extern struct lcore_config lcore_config[RTE_MAX_LCORE]; -RTE_DECLARE_PER_LCORE(unsigned, _lcore_id); /**< Per core "core id". */ +RTE_DECLARE_PER_LCORE(unsigned, _lcore_id); /**< Per thread "lcore id". */ +RTE_DECLARE_PER_LCORE(rte_cpuset_t, _cpuset); /**< Per thread "cpuset". */ /** * Return the ID of the execution unit we are running on. * @return - * Logical core ID + * Logical core ID (in EAL thread) or LCORE_ID_ANY (in non-EAL thread) */ static inline unsigned rte_lcore_id(void) @@ -109,17 +119,32 @@ rte_lcore_count(void) return cfg->lcore_count; } +/** + * Return the index of the lcore starting from zero. + * The order is physical or given by command line (-l option). + * + * @param lcore_id + * The targeted lcore, or -1 for the current one. + * @return + * The relative index, or -1 if not enabled. + */ +static inline int +rte_lcore_index(int lcore_id) +{ + if (lcore_id >= RTE_MAX_LCORE) + return -1; + if (lcore_id < 0) + lcore_id = rte_lcore_id(); + return lcore_config[lcore_id].core_index; +} + /** * Return the ID of the physical socket of the logical core we are * running on. * @return * the ID of current lcoreid's physical socket */ -static inline unsigned -rte_socket_id(void) -{ - return lcore_config[rte_lcore_id()].socket_id; -} +unsigned rte_socket_id(void); /** * Get the ID of the physical socket of the specified lcore @@ -201,6 +226,28 @@ rte_get_next_lcore(unsigned i, int skip_master, int wrap) i