eal: get relative core index
EAL -c option allows the user to enable any lcore in the system. Often times, the user app wants to know 1st enabled core, 2nd enabled core, etc, rather than phyical core ID (rte_lcore_id().) The new API rte_lcore_index() will return an index from enabled lcores starting from zero. Signed-off-by: Patrick Lu <patrick.lu@intel.com> Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
This commit is contained in:
parent
d888cb8b96
commit
5583037a79
@ -185,19 +185,23 @@ eal_parse_coremask(const char *coremask)
|
||||
return -1;
|
||||
}
|
||||
cfg->lcore_role[idx] = ROLE_RTE;
|
||||
lcore_config[idx].core_index = count;
|
||||
if (count == 0)
|
||||
cfg->master_lcore = idx;
|
||||
count++;
|
||||
} else {
|
||||
cfg->lcore_role[idx] = ROLE_OFF;
|
||||
lcore_config[idx].core_index = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (; i >= 0; i--)
|
||||
if (coremask[i] != '0')
|
||||
return -1;
|
||||
for (; idx < RTE_MAX_LCORE; idx++)
|
||||
for (; idx < RTE_MAX_LCORE; idx++) {
|
||||
cfg->lcore_role[idx] = ROLE_OFF;
|
||||
lcore_config[idx].core_index = -1;
|
||||
}
|
||||
if (count == 0)
|
||||
return -1;
|
||||
/* Update the count of enabled logical cores of the EAL configuration */
|
||||
@ -225,9 +229,11 @@ eal_parse_corelist(const char *corelist)
|
||||
while ((i > 0) && isblank(corelist[i - 1]))
|
||||
i--;
|
||||
|
||||
/* Reset core roles */
|
||||
for (idx = 0; idx < RTE_MAX_LCORE; idx++)
|
||||
/* Reset config */
|
||||
for (idx = 0; idx < RTE_MAX_LCORE; idx++) {
|
||||
cfg->lcore_role[idx] = ROLE_OFF;
|
||||
lcore_config[idx].core_index = -1;
|
||||
}
|
||||
|
||||
/* Get list of cores */
|
||||
min = RTE_MAX_LCORE;
|
||||
@ -250,6 +256,7 @@ eal_parse_corelist(const char *corelist)
|
||||
min = idx;
|
||||
for (idx = min; idx <= max; idx++) {
|
||||
cfg->lcore_role[idx] = ROLE_RTE;
|
||||
lcore_config[idx].core_index = count;
|
||||
if (count == 0)
|
||||
cfg->master_lcore = idx;
|
||||
count++;
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user