X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fcommon%2Finclude%2Frte_lcore.h;h=49b2c0341391d315b88d58a22c2e97092ef29e81;hb=5583037a795076f74f767d55a00c652f5b8f1382;hp=a0b4356952fae420de1f39065dc55d012eb8be89;hpb=d888cb8b9613c5f72015830d143150ed90207a71;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..49b2c03413 100644 --- a/lib/librte_eal/common/include/rte_lcore.h +++ b/lib/librte_eal/common/include/rte_lcore.h @@ -64,6 +64,7 @@ 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 */ }; /** @@ -109,6 +110,25 @@ 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.