X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fl3fwd-power%2Fmain.c;h=887c6eae3fa71e78de13c00a64e871d04662e45f;hb=68629be3a622ee53cd5b40c8447ae9b083ff3f6c;hp=b8b3be2b8abc00e448a6c42c37e566581cdef0b6;hpb=0f4611cc2642aa19a1fb845c443d10dd83f18ec0;p=dpdk.git diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index b8b3be2b8a..887c6eae3f 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -265,6 +265,10 @@ static struct rte_eth_conf port_conf = { }; static uint32_t max_pkt_len; +static uint32_t max_empty_polls = 512; +static uint32_t pause_duration = 1; +static uint32_t scale_freq_min; +static uint32_t scale_freq_max; static struct rte_mempool * pktmbuf_pool[NB_SOCKETS]; @@ -433,7 +437,7 @@ signal_exit_now(int sigtype) } -/* Freqency scale down timer callback */ +/* Frequency scale down timer callback */ static void power_timer_cb(__rte_unused struct rte_timer *tim, __rte_unused void *arg) @@ -1626,10 +1630,32 @@ print_usage(const char *prgname) " empty polls, full polls, and core busyness to telemetry\n" " --interrupt-only: enable interrupt-only mode\n" " --pmd-mgmt MODE: enable PMD power management mode. " - "Currently supported modes: baseline, monitor, pause, scale\n", + "Currently supported modes: baseline, monitor, pause, scale\n" + " --max-empty-polls MAX_EMPTY_POLLS: number of empty polls to" + " wait before entering sleep state\n" + " --pause-duration DURATION: set the duration, in microseconds," + " of the pause callback\n" + " --scale-freq-min FREQ_MIN: set minimum frequency for scaling mode for" + " all application lcores (FREQ_MIN must be in kHz, in increments of 100MHz)\n" + " --scale-freq-max FREQ_MAX: set maximum frequency for scaling mode for" + " all application lcores (FREQ_MAX must be in kHz, in increments of 100MHz)\n", prgname); } +static int +parse_int(const char *opt) +{ + char *end = NULL; + unsigned long val; + + /* parse integer string */ + val = strtoul(opt, &end, 10); + if ((opt[0] == '\0') || (end == NULL) || (*end != '\0')) + return -1; + + return val; +} + static int parse_max_pkt_len(const char *pktlen) { char *end = NULL; @@ -1803,6 +1829,10 @@ parse_ep_config(const char *q_arg) #define CMD_LINE_OPT_TELEMETRY "telemetry" #define CMD_LINE_OPT_PMD_MGMT "pmd-mgmt" #define CMD_LINE_OPT_MAX_PKT_LEN "max-pkt-len" +#define CMD_LINE_OPT_MAX_EMPTY_POLLS "max-empty-polls" +#define CMD_LINE_OPT_PAUSE_DURATION "pause-duration" +#define CMD_LINE_OPT_SCALE_FREQ_MIN "scale-freq-min" +#define CMD_LINE_OPT_SCALE_FREQ_MAX "scale-freq-max" /* Parse the argument given in the command line of the application */ static int @@ -1825,6 +1855,10 @@ parse_args(int argc, char **argv) {CMD_LINE_OPT_TELEMETRY, 0, 0, 0}, {CMD_LINE_OPT_INTERRUPT_ONLY, 0, 0, 0}, {CMD_LINE_OPT_PMD_MGMT, 1, 0, 0}, + {CMD_LINE_OPT_MAX_EMPTY_POLLS, 1, 0, 0}, + {CMD_LINE_OPT_PAUSE_DURATION, 1, 0, 0}, + {CMD_LINE_OPT_SCALE_FREQ_MIN, 1, 0, 0}, + {CMD_LINE_OPT_SCALE_FREQ_MAX, 1, 0, 0}, {NULL, 0, 0, 0} }; @@ -1975,6 +2009,34 @@ parse_args(int argc, char **argv) parse_ptype = 1; } + if (!strncmp(lgopts[option_index].name, + CMD_LINE_OPT_MAX_EMPTY_POLLS, + sizeof(CMD_LINE_OPT_MAX_EMPTY_POLLS))) { + printf("Maximum empty polls configured\n"); + max_empty_polls = parse_int(optarg); + } + + if (!strncmp(lgopts[option_index].name, + CMD_LINE_OPT_PAUSE_DURATION, + sizeof(CMD_LINE_OPT_PAUSE_DURATION))) { + printf("Pause duration configured\n"); + pause_duration = parse_int(optarg); + } + + if (!strncmp(lgopts[option_index].name, + CMD_LINE_OPT_SCALE_FREQ_MIN, + sizeof(CMD_LINE_OPT_SCALE_FREQ_MIN))) { + printf("Scaling frequency minimum configured\n"); + scale_freq_min = parse_int(optarg); + } + + if (!strncmp(lgopts[option_index].name, + CMD_LINE_OPT_SCALE_FREQ_MAX, + sizeof(CMD_LINE_OPT_SCALE_FREQ_MAX))) { + printf("Scaling frequency maximum configured\n"); + scale_freq_max = parse_int(optarg); + } + break; default: @@ -2358,7 +2420,7 @@ update_telemetry(__rte_unused struct rte_timer *tim, ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, telstats_index, values, RTE_DIM(values)); if (ret < 0) - RTE_LOG(WARNING, POWER, "failed to update metrcis\n"); + RTE_LOG(WARNING, POWER, "failed to update metrics\n"); } static int @@ -2801,6 +2863,28 @@ main(int argc, char **argv) } if (app_mode == APP_MODE_PMD_MGMT && !baseline_enabled) { + /* Set power_pmd_mgmt configs passed by user */ + rte_power_pmd_mgmt_set_emptypoll_max(max_empty_polls); + ret = rte_power_pmd_mgmt_set_pause_duration(pause_duration); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "Error setting pause_duration: err=%d, lcore=%d\n", + ret, lcore_id); + + ret = rte_power_pmd_mgmt_set_scaling_freq_min(lcore_id, + scale_freq_min); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "Error setting scaling freq min: err=%d, lcore=%d\n", + ret, lcore_id); + + ret = rte_power_pmd_mgmt_set_scaling_freq_max(lcore_id, + scale_freq_max); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "Error setting scaling freq max: err=%d, lcore %d\n", + ret, lcore_id); + ret = rte_power_ethdev_pmgmt_queue_enable( lcore_id, portid, queueid, pmgmt_type);