[RFC,v2,4/5] power: keep per-lcore state in lcore variable
Checks
Commit Message
Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
---
lib/power/rte_power_pmd_mgmt.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
@@ -5,6 +5,7 @@
#include <stdlib.h>
#include <rte_lcore.h>
+#include <rte_lcore_var.h>
#include <rte_cycles.h>
#include <rte_cpuflags.h>
#include <rte_malloc.h>
@@ -68,8 +69,8 @@ struct pmd_core_cfg {
/**< Number of queues ready to enter power optimized state */
uint64_t sleep_target;
/**< Prevent a queue from triggering sleep multiple times */
-} __rte_cache_aligned;
-static struct pmd_core_cfg lcore_cfgs[RTE_MAX_LCORE];
+};
+static RTE_LCORE_VAR_HANDLE(struct pmd_core_cfg, lcore_cfgs);
static inline bool
queue_equal(const union queue *l, const union queue *r)
@@ -252,12 +253,11 @@ clb_multiwait(uint16_t port_id __rte_unused, uint16_t qidx __rte_unused,
struct rte_mbuf **pkts __rte_unused, uint16_t nb_rx,
uint16_t max_pkts __rte_unused, void *arg)
{
- const unsigned int lcore = rte_lcore_id();
struct queue_list_entry *queue_conf = arg;
struct pmd_core_cfg *lcore_conf;
const bool empty = nb_rx == 0;
- lcore_conf = &lcore_cfgs[lcore];
+ lcore_conf = RTE_LCORE_VAR_PTR(lcore_cfgs);
/* early exit */
if (likely(!empty))
@@ -317,13 +317,12 @@ clb_pause(uint16_t port_id __rte_unused, uint16_t qidx __rte_unused,
struct rte_mbuf **pkts __rte_unused, uint16_t nb_rx,
uint16_t max_pkts __rte_unused, void *arg)
{
- const unsigned int lcore = rte_lcore_id();
struct queue_list_entry *queue_conf = arg;
struct pmd_core_cfg *lcore_conf;
const bool empty = nb_rx == 0;
uint32_t pause_duration = rte_power_pmd_mgmt_get_pause_duration();
- lcore_conf = &lcore_cfgs[lcore];
+ lcore_conf = RTE_LCORE_VAR_PTR(lcore_cfgs);
if (likely(!empty))
/* early exit */
@@ -358,9 +357,8 @@ clb_scale_freq(uint16_t port_id __rte_unused, uint16_t qidx __rte_unused,
struct rte_mbuf **pkts __rte_unused, uint16_t nb_rx,
uint16_t max_pkts __rte_unused, void *arg)
{
- const unsigned int lcore = rte_lcore_id();
const bool empty = nb_rx == 0;
- struct pmd_core_cfg *lcore_conf = &lcore_cfgs[lcore];
+ struct pmd_core_cfg *lcore_conf = RTE_LCORE_VAR_PTR(lcore_cfgs);
struct queue_list_entry *queue_conf = arg;
if (likely(!empty)) {
@@ -518,7 +516,7 @@ rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id,
goto end;
}
- lcore_cfg = &lcore_cfgs[lcore_id];
+ lcore_cfg = RTE_LCORE_VAR_LCORE_PTR(lcore_id, lcore_cfgs);
/* check if other queues are stopped as well */
ret = cfg_queues_stopped(lcore_cfg);
@@ -619,7 +617,7 @@ rte_power_ethdev_pmgmt_queue_disable(unsigned int lcore_id,
}
/* no need to check queue id as wrong queue id would not be enabled */
- lcore_cfg = &lcore_cfgs[lcore_id];
+ lcore_cfg = RTE_LCORE_VAR_LCORE_PTR(lcore_id, lcore_cfgs);
/* check if other queues are stopped as well */
ret = cfg_queues_stopped(lcore_cfg);
@@ -772,10 +770,13 @@ RTE_INIT(rte_power_ethdev_pmgmt_init) {
size_t i;
int j;
+ RTE_LCORE_VAR_ALLOC(lcore_cfgs);
+
/* initialize all tailqs */
- for (i = 0; i < RTE_DIM(lcore_cfgs); i++) {
- struct pmd_core_cfg *cfg = &lcore_cfgs[i];
- TAILQ_INIT(&cfg->head);
+ for (i = 0; i < RTE_MAX_LCORE; i++) {
+ struct pmd_core_cfg *lcore_cfg =
+ RTE_LCORE_VAR_LCORE_PTR(i, lcore_cfgs);
+ TAILQ_INIT(&lcore_cfg->head);
}
/* initialize config defaults */