From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C76CAA00BE; Wed, 27 May 2020 19:03:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9C4511DB0F; Wed, 27 May 2020 19:02:25 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id AE7731DAAE for ; Wed, 27 May 2020 19:02:17 +0200 (CEST) IronPort-SDR: S4vXEJGBOWUPxv3IfY3lzjAEYLUn9WMKXV+/cDq27v8E4/34h7O9ABgys3dapzq4OEPfKWYrJJ tX/qeOC0lyBQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 May 2020 10:02:13 -0700 IronPort-SDR: 6pmuUF0ABKpTOFgaGQfNCyNOmJtiHLBQ3UnzdubEijy+oCpEImTe7BaieJkgliQFDp2Pg/0z4s YB8yeEltCULA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,442,1583222400"; d="scan'208";a="442596003" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.222.52]) by orsmga005.jf.intel.com with ESMTP; 27 May 2020 10:02:07 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Wenzhuo Lu , Beilei Xing , Bernard Iremonger , david.hunt@intel.com, liang.j.ma@intel.com Date: Wed, 27 May 2020 18:02:06 +0100 Message-Id: <1e4bfc80e83c963145066d48a36b14ddfd7f9e80.1590598121.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [RFC 6/6] app/testpmd: add command for power management on a port X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" A quick-and-dirty testpmd command to enable power management on a specific port. Signed-off-by: Anatoly Burakov --- app/test-pmd/cmdline.c | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 996a498768..e3a5e19485 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -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 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, }; -- 2.17.1