[RFC,6/6] app/testpmd: add command for power management on a port
Checks
Commit Message
A quick-and-dirty testpmd command to enable power management on
a specific port.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
app/test-pmd/cmdline.c | 48 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
@@ -1773,6 +1773,53 @@ cmdline_parse_inst_t cmd_config_speed_specific = {
},
};
+/* *** enable power management for specific port *** */
+struct cmd_port_pmgmt {
+ cmdline_fixed_string_t port;
+ portid_t id;
+ cmdline_fixed_string_t pmgmt;
+ cmdline_fixed_string_t on;
+};
+
+static void
+cmd_port_pmgmt_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_port_pmgmt *res = parsed_result;
+
+ if (port_id_is_invalid(res->id, ENABLED_WARN))
+ return;
+
+ if (!strcmp(res->on, "on"))
+ rte_eth_dev_power_mgmt_enable(res->id);
+ else if (!strcmp(res->on, "off"))
+ rte_eth_dev_power_mgmt_disable(res->id);
+}
+
+
+cmdline_parse_token_string_t cmd_port_pmgmt_port =
+ TOKEN_STRING_INITIALIZER(struct cmd_port_pmgmt, port, "port");
+cmdline_parse_token_num_t cmd_port_pmgmt_id =
+ TOKEN_NUM_INITIALIZER(struct cmd_port_pmgmt, id, UINT16);
+cmdline_parse_token_string_t cmd_port_pmgmt_item1 =
+ TOKEN_STRING_INITIALIZER(struct cmd_port_pmgmt, pmgmt, "power-mgmt");
+cmdline_parse_token_string_t cmd_port_pmgmt_value1 =
+ TOKEN_STRING_INITIALIZER(struct cmd_port_pmgmt, on, "on#off");
+
+cmdline_parse_inst_t cmd_port_pmgmt = {
+ .f = cmd_port_pmgmt_parsed,
+ .data = NULL,
+ .help_str = "port <port_id> power-mgmt on|off",
+ .tokens = {
+ (void *)&cmd_port_pmgmt_port,
+ (void *)&cmd_port_pmgmt_id,
+ (void *)&cmd_port_pmgmt_item1,
+ (void *)&cmd_port_pmgmt_value1,
+ NULL,
+ },
+};
+
/* *** configure loopback for all ports *** */
struct cmd_config_loopback_all {
cmdline_fixed_string_t port;
@@ -19692,6 +19739,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_show_set_raw,
(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
(cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
+ (cmdline_parse_inst_t *)&cmd_port_pmgmt,
NULL,
};