rte_spinlock_unlock(&global_core_freq_info[core_num].power_sl); \
} while (0)
-#define POWER_SCALE_MASK(DIRECTION, core_mask, ret) do { \
- int i; \
- for (i = 0; core_mask; core_mask &= ~(1 << i++)) { \
- if ((core_mask >> i) & 1) { \
- if (!(ci.cd[i].global_enabled_cpus)) \
- continue; \
- rte_spinlock_lock(&global_core_freq_info[i].power_sl); \
- if (rte_power_freq_##DIRECTION(i) != 1) \
- ret = -1; \
- rte_spinlock_unlock(&global_core_freq_info[i].power_sl); \
- } \
- } \
-} while (0)
-
struct freq_info {
rte_spinlock_t power_sl;
uint32_t freqs[RTE_MAX_LCORE_FREQS];
return ret;
}
-int
-power_manager_scale_mask_up(uint64_t core_mask)
-{
- int ret = 0;
-
- POWER_SCALE_MASK(up, core_mask, ret);
- return ret;
-}
-
-int
-power_manager_scale_mask_down(uint64_t core_mask)
-{
- int ret = 0;
-
- POWER_SCALE_MASK(down, core_mask, ret);
- return ret;
-}
-
-int
-power_manager_scale_mask_min(uint64_t core_mask)
-{
- int ret = 0;
-
- POWER_SCALE_MASK(min, core_mask, ret);
- return ret;
-}
-
-int
-power_manager_scale_mask_max(uint64_t core_mask)
-{
- int ret = 0;
-
- POWER_SCALE_MASK(max, core_mask, ret);
- return ret;
-}
-
-int
-power_manager_enable_turbo_mask(uint64_t core_mask)
-{
- int ret = 0;
-
- POWER_SCALE_MASK(enable_turbo, core_mask, ret);
- return ret;
-}
-
-int
-power_manager_disable_turbo_mask(uint64_t core_mask)
-{
- int ret = 0;
-
- POWER_SCALE_MASK(disable_turbo, core_mask, ret);
- return ret;
-}
-
int
power_manager_scale_core_up(unsigned core_num)
{
};
/* *** vCPU to pCPU mapping operations *** */
-struct cmd_set_pcpu_mask_result {
- cmdline_fixed_string_t set_pcpu_mask;
- cmdline_fixed_string_t vm_name;
- uint8_t vcpu;
- char core_mask[POWER_MGR_MAX_CPUS];
-};
-static void
-cmd_set_pcpu_mask_parsed(void *parsed_result, struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_set_pcpu_mask_result *res = parsed_result;
-
- if (set_pcpus_mask(res->vm_name, res->vcpu, res->core_mask) == 0)
- cmdline_printf(cl, "Pinned vCPU(%"PRId8") to pCPU core "
- "\n", res->vcpu);
- else
- cmdline_printf(cl, "Unable to pin vCPU(%"PRId8") to pCPU core "
- "\n", res->vcpu);
-}
-
-cmdline_parse_token_string_t cmd_set_pcpu_mask =
- TOKEN_STRING_INITIALIZER(struct cmd_set_pcpu_mask_result,
- set_pcpu_mask, "set_pcpu_mask");
-cmdline_parse_token_string_t cmd_set_pcpu_mask_vm_name =
- TOKEN_STRING_INITIALIZER(struct cmd_set_pcpu_mask_result,
- vm_name, NULL);
-cmdline_parse_token_num_t set_pcpu_mask_vcpu =
- TOKEN_NUM_INITIALIZER(struct cmd_set_pcpu_mask_result,
- vcpu, UINT8);
-cmdline_parse_token_num_t set_pcpu_mask_core_mask =
- TOKEN_NUM_INITIALIZER(struct cmd_set_pcpu_mask_result,
- core_mask, UINT64);
-
-
-cmdline_parse_inst_t cmd_set_pcpu_mask_set = {
- .f = cmd_set_pcpu_mask_parsed,
- .data = NULL,
- .help_str = "set_pcpu_mask <vm_name> <vcpu> <pcpu>, Set the binding "
- "of Virtual CPU on VM to the Physical CPU mask.",
- .tokens = {
- (void *)&cmd_set_pcpu_mask,
- (void *)&cmd_set_pcpu_mask_vm_name,
- (void *)&set_pcpu_mask_vcpu,
- (void *)&set_pcpu_mask_core_mask,
- NULL,
- },
-};
struct cmd_set_pcpu_result {
cmdline_fixed_string_t set_pcpu;
};
/* *** CPU Frequency operations *** */
-struct cmd_show_cpu_freq_mask_result {
- cmdline_fixed_string_t show_cpu_freq_mask;
- uint64_t core_mask;
-};
-
-static void
-cmd_show_cpu_freq_mask_parsed(void *parsed_result, struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_show_cpu_freq_mask_result *res = parsed_result;
- unsigned i;
- uint64_t mask = res->core_mask;
- uint32_t freq;
-
- for (i = 0; mask; mask &= ~(1ULL << i++)) {
- if ((mask >> i) & 1) {
- freq = power_manager_get_current_frequency(i);
- if (freq > 0)
- cmdline_printf(cl, "Core %u: %"PRId32"\n", i, freq);
- }
- }
-}
-
-cmdline_parse_token_string_t cmd_show_cpu_freq_mask =
- TOKEN_STRING_INITIALIZER(struct cmd_show_cpu_freq_mask_result,
- show_cpu_freq_mask, "show_cpu_freq_mask");
-cmdline_parse_token_num_t cmd_show_cpu_freq_mask_core_mask =
- TOKEN_NUM_INITIALIZER(struct cmd_show_cpu_freq_mask_result,
- core_mask, UINT64);
-
-cmdline_parse_inst_t cmd_show_cpu_freq_mask_set = {
- .f = cmd_show_cpu_freq_mask_parsed,
- .data = NULL,
- .help_str = "show_cpu_freq_mask <mask>, Get the current frequency for each "
- "core specified in the mask",
- .tokens = {
- (void *)&cmd_show_cpu_freq_mask,
- (void *)&cmd_show_cpu_freq_mask_core_mask,
- NULL,
- },
-};
-
-struct cmd_set_cpu_freq_mask_result {
- cmdline_fixed_string_t set_cpu_freq_mask;
- uint64_t core_mask;
- cmdline_fixed_string_t cmd;
-};
-
-static void
-cmd_set_cpu_freq_mask_parsed(void *parsed_result, struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_set_cpu_freq_mask_result *res = parsed_result;
- int ret = -1;
-
- if (!strcmp(res->cmd , "up"))
- ret = power_manager_scale_mask_up(res->core_mask);
- else if (!strcmp(res->cmd , "down"))
- ret = power_manager_scale_mask_down(res->core_mask);
- else if (!strcmp(res->cmd , "min"))
- ret = power_manager_scale_mask_min(res->core_mask);
- else if (!strcmp(res->cmd , "max"))
- ret = power_manager_scale_mask_max(res->core_mask);
- else if (!strcmp(res->cmd, "enable_turbo"))
- ret = power_manager_enable_turbo_mask(res->core_mask);
- else if (!strcmp(res->cmd, "disable_turbo"))
- ret = power_manager_disable_turbo_mask(res->core_mask);
- if (ret < 0) {
- cmdline_printf(cl, "Error scaling core_mask(0x%"PRIx64") '%s' , not "
- "all cores specified have been scaled\n",
- res->core_mask, res->cmd);
- };
-}
-
-cmdline_parse_token_string_t cmd_set_cpu_freq_mask =
- TOKEN_STRING_INITIALIZER(struct cmd_set_cpu_freq_mask_result,
- set_cpu_freq_mask, "set_cpu_freq_mask");
-cmdline_parse_token_num_t cmd_set_cpu_freq_mask_core_mask =
- TOKEN_NUM_INITIALIZER(struct cmd_set_cpu_freq_mask_result,
- core_mask, UINT64);
-cmdline_parse_token_string_t cmd_set_cpu_freq_mask_result =
- TOKEN_STRING_INITIALIZER(struct cmd_set_cpu_freq_mask_result,
- cmd, "up#down#min#max#enable_turbo#disable_turbo");
-
-cmdline_parse_inst_t cmd_set_cpu_freq_mask_set = {
- .f = cmd_set_cpu_freq_mask_parsed,
- .data = NULL,
- .help_str = "set_cpu_freq <core_mask> <up|down|min|max|enable_turbo|disable_turbo>, adjust the current "
- "frequency for the cores specified in <core_mask>",
- .tokens = {
- (void *)&cmd_set_cpu_freq_mask,
- (void *)&cmd_set_cpu_freq_mask_core_mask,
- (void *)&cmd_set_cpu_freq_mask_result,
- NULL,
- },
-};
-
-
-
struct cmd_show_cpu_freq_result {
cmdline_fixed_string_t show_cpu_freq;
uint8_t core_num;
(cmdline_parse_inst_t *)&cmd_channels_op_set,
(cmdline_parse_inst_t *)&cmd_channels_status_op_set,
(cmdline_parse_inst_t *)&cmd_show_vm_set,
- (cmdline_parse_inst_t *)&cmd_show_cpu_freq_mask_set,
- (cmdline_parse_inst_t *)&cmd_set_cpu_freq_mask_set,
(cmdline_parse_inst_t *)&cmd_show_cpu_freq_set,
(cmdline_parse_inst_t *)&cmd_set_cpu_freq_set,
- (cmdline_parse_inst_t *)&cmd_set_pcpu_mask_set,
(cmdline_parse_inst_t *)&cmd_set_pcpu_set,
NULL,
};