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 1920FA0613 for ; Thu, 26 Sep 2019 15:01:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D90D93977; Thu, 26 Sep 2019 15:01:49 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 920ED37A2 for ; Thu, 26 Sep 2019 15:01:48 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2019 06:01:47 -0700 X-IronPort-AV: E=Sophos;i="5.64,552,1559545200"; d="scan'208";a="194120135" Received: from dhunt5-mobl4.ger.corp.intel.com (HELO [10.237.221.113]) ([10.237.221.113]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/AES256-SHA; 26 Sep 2019 06:01:46 -0700 To: 20190402082121.5472-1-marcinx.hajkowski@intel.com Cc: dev@dpdk.org, Marcin Hajkowski References: <20190405132455.15468-1-marcinx.hajkowski@intel.com> <20190405132455.15468-4-marcinx.hajkowski@intel.com> From: "Hunt, David" Message-ID: <8c4c691c-7ca5-fe13-ba31-0f649b804060@intel.com> Date: Thu, 26 Sep 2019 14:01:44 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190405132455.15468-4-marcinx.hajkowski@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [dpdk-dev] [PATCH v5 3/4] power: process incoming confirmation cmds 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" On 05/04/2019 14:24, Hajkowski wrote: > From: Marcin Hajkowski > > Extend vm_power_guest to check incoming confirmations > of messages previously sent to host. > > Signed-off-by: Marcin Hajkowski > --- > examples/vm_power_manager/guest_cli/Makefile | 1 + > .../guest_cli/vm_power_cli_guest.c | 73 +++++++++++++++---- > 2 files changed, 61 insertions(+), 13 deletions(-) > > diff --git a/examples/vm_power_manager/guest_cli/Makefile b/examples/vm_power_manager/guest_cli/Makefile > index e35a68d0f..67cf08193 100644 > --- a/examples/vm_power_manager/guest_cli/Makefile > +++ b/examples/vm_power_manager/guest_cli/Makefile > @@ -18,6 +18,7 @@ SRCS-y := main.c vm_power_cli_guest.c parse.c > > CFLAGS += -O3 -I$(RTE_SDK)/lib/librte_power/ > CFLAGS += $(WERROR_FLAGS) > +CFLAGS += -DALLOW_EXPERIMENTAL_API > > # workaround for a gcc bug with noreturn attribute > # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603 > diff --git a/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c b/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c > index 2d9e7689a..49ed7b208 100644 > --- a/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c > +++ b/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c > @@ -27,7 +27,7 @@ > #define CHANNEL_PATH "/dev/virtio-ports/virtio.serial.port.poweragent" > > > -#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1 > +#define RTE_LOGTYPE_GUEST_CLI RTE_LOGTYPE_USER1 > > struct cmd_quit_result { > cmdline_fixed_string_t quit; > @@ -132,6 +132,32 @@ struct cmd_set_cpu_freq_result { > cmdline_fixed_string_t cmd; > }; > > +static int > +check_response_cmd(unsigned int lcore_id, int *result) > +{ > + struct channel_packet pkt; > + int ret; > + > + ret = rte_power_guest_channel_receive_msg(&pkt, lcore_id); > + if (ret < 0) > + return -1; > + > + switch (pkt.command) { > + case(CPU_POWER_CMD_ACK): > + *result = 1; > + break; > + case(CPU_POWER_CMD_NACK): > + *result = 0; > + break; > + default: > + RTE_LOG(ERR, GUEST_CLI, > + "Received invalid response from host, expecting ACK/NACK.\n"); > + return -1; > + } > + > + return 0; > +} > + > static void > cmd_set_cpu_freq_parsed(void *parsed_result, struct cmdline *cl, > __attribute__((unused)) void *data) > @@ -139,20 +165,31 @@ cmd_set_cpu_freq_parsed(void *parsed_result, struct cmdline *cl, > int ret = -1; > struct cmd_set_cpu_freq_result *res = parsed_result; > > - if (!strcmp(res->cmd , "up")) > + if (!strcmp(res->cmd, "up")) > ret = rte_power_freq_up(res->lcore_id); > - else if (!strcmp(res->cmd , "down")) > + else if (!strcmp(res->cmd, "down")) > ret = rte_power_freq_down(res->lcore_id); > - else if (!strcmp(res->cmd , "min")) > + else if (!strcmp(res->cmd, "min")) > ret = rte_power_freq_min(res->lcore_id); > - else if (!strcmp(res->cmd , "max")) > + else if (!strcmp(res->cmd, "max")) > ret = rte_power_freq_max(res->lcore_id); > else if (!strcmp(res->cmd, "enable_turbo")) > ret = rte_power_freq_enable_turbo(res->lcore_id); > else if (!strcmp(res->cmd, "disable_turbo")) > ret = rte_power_freq_disable_turbo(res->lcore_id); > - if (ret != 1) > + > + if (ret != 1) { > cmdline_printf(cl, "Error sending message: %s\n", strerror(ret)); > + return; > + } > + int result; > + ret = check_response_cmd(res->lcore_id, &result); > + if (ret < 0) { > + RTE_LOG(ERR, GUEST_CLI, "No confirmation for sent message received\n"); > + } else { > + cmdline_printf(cl, "%s received for message sent to host.\n", > + result == 1 ? "ACK" : "NACK"); > + } > } > > cmdline_parse_token_string_t cmd_set_cpu_freq = > @@ -185,16 +222,26 @@ struct cmd_send_policy_result { > }; > > static inline int > -send_policy(struct channel_packet *pkt) > +send_policy(struct channel_packet *pkt, struct cmdline *cl) > { > int ret; > > ret = rte_power_guest_channel_send_msg(pkt, 1); > - if (ret == 0) > - return 1; > - RTE_LOG(DEBUG, POWER, "Error sending message: %s\n", > - ret > 0 ? strerror(ret) : "channel not connected"); > - return -1; > + if (ret < 0) { > + RTE_LOG(ERR, GUEST_CLI, "Error sending message: %s\n", > + ret > 0 ? strerror(ret) : "channel not connected"); > + return -1; > + } > + > + int result; > + ret = check_response_cmd(1, &result); > + if (ret < 0) { > + RTE_LOG(ERR, GUEST_CLI, "No confirmation for sent policy received\n"); > + } else { > + cmdline_printf(cl, "%s for sent policy received.\n", > + result == 1 ? "ACK" : "NACK"); > + } > + return 1; > } > > static void > @@ -206,7 +253,7 @@ cmd_send_policy_parsed(void *parsed_result, struct cmdline *cl, > > if (!strcmp(res->cmd, "now")) { > printf("Sending Policy down now!\n"); > - ret = send_policy(&policy); > + ret = send_policy(&policy, cl); > } > if (ret != 1) > cmdline_printf(cl, "Error sending message: %s\n", I tested this with the later patches in the set, and the acknowledges successfully get back to the guest from the host in the form of an Ack or Nack for various commands sent from the guest. Tested-by: David Hunt