X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fcommon%2Finclude%2Frte_lcore.h;h=fe7b5865f7f53c46c10e1e9f7aac52841fc45545;hb=a461943208397029b85273b89d4ac30f7c89c3fa;hp=3802a28b0e677f29d93051fdc513549d4421955c;hpb=3031749c2df04a63cdcef186dcce3781e61436e8;p=dpdk.git diff --git a/lib/librte_eal/common/include/rte_lcore.h b/lib/librte_eal/common/include/rte_lcore.h index 3802a28b0e..fe7b5865f7 100644 --- a/lib/librte_eal/common/include/rte_lcore.h +++ b/lib/librte_eal/common/include/rte_lcore.h @@ -37,8 +37,7 @@ /** * @file * - * API for lcore and Socket Manipulation. Parts of this are execution - * environment specific. + * API for lcore and socket manipulation * */ #include @@ -49,14 +48,45 @@ extern "C" { #endif -#define LCORE_ID_ANY -1 /**< Any lcore. */ +#define LCORE_ID_ANY UINT32_MAX /**< Any lcore. */ -RTE_DECLARE_PER_LCORE(unsigned, _lcore_id); /**< Per core "core id". */ +#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) + */ +struct lcore_config { + unsigned detected; /**< true if lcore was detected */ + pthread_t thread_id; /**< pthread identifier */ + int pipe_master2slave[2]; /**< communication pipe with master */ + int pipe_slave2master[2]; /**< communication pipe with master */ + lcore_function_t * volatile f; /**< function to call */ + void * volatile arg; /**< argument of function */ + volatile int ret; /**< return value of function */ + 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 */ +}; + +/** + * Internal configuration (per-lcore) + */ +extern struct lcore_config lcore_config[RTE_MAX_LCORE]; + +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) @@ -89,7 +119,24 @@ rte_lcore_count(void) return cfg->lcore_count; } -#include +/** + * 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 @@ -97,11 +144,7 @@ rte_lcore_count(void) * @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 @@ -132,7 +175,7 @@ rte_lcore_is_enabled(unsigned lcore_id) struct rte_config *cfg = rte_eal_get_configuration(); if (lcore_id >= RTE_MAX_LCORE) return 0; - return (cfg->lcore_role[lcore_id] != ROLE_OFF); + return cfg->lcore_role[lcore_id] != ROLE_OFF; } /** @@ -183,6 +226,41 @@ rte_get_next_lcore(unsigned i, int skip_master, int wrap) i