bidirect guest channel
v3 cover bidirect guest channel
From: Marcin Hajkowski <[email protected]>
Extend guest channel API to allow bidirectional communication. Modify power manager host and guest side to communicate in both directions.
v3:
* fix global_fds[lcore_id] comparison to invalid value
* check 0 to verify if read function actually read some data
* define _NACK cmd instead of _NAK
* simplify rte_power_guest_channel_receive_msg func logic
v2:
* send ack only if power operation return positive value
* log diffent error for unexpected incoming command and error during ack/nak cmd sending
Marcin Hajkowski (4):
power: fix invalid socket indicator value
power: extend guest channel api for reading
power: process incoming confirmation cmds
power: send confirmation cmd to vm guest
examples/vm_power_manager/channel_monitor.c | 67 ++++++++++++++-- examples/vm_power_manager/guest_cli/Makefile | 1 + .../guest_cli/vm_power_cli_guest.c | 65 +++++++++++++--- lib/librte_power/channel_commands.h | 5 ++ lib/librte_power/guest_channel.c | 77 +++++++++++++++++-- lib/librte_power/guest_channel.h | 35 +++++++++ lib/librte_power/rte_power_version.map | 1 + 7 files changed, 227 insertions(+), 24 deletions(-)
Signature · 1 line
2.17.2
PATCH v3 1/4 power: fix invalid socket indicator value
From: Marcin Hajkowski <[email protected]>
Currently 0 is being used for not connected slot indication. This is not consistent with linux doc which identifies 0 as valid (connected) slot, thus modification was done to change it.
--- lib/librte_power/guest_channel.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/librte_power/guest_channel.c +6 -6
@@ -19,7 +19,7 @@#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1 -static int global_fds[RTE_MAX_LCORE ]; +static int global_fds[RTE_MAX_LCORE ] = { [0 ...RTE_MAX_LCORE -1 ] =-1 };int guest_channel_host_connect (const char *path,unsigned int lcore_id)
@@ -35,7 +35,7 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id)return -1 ; }/* check if path is already open */ -if (global_fds[lcore_id] !=0 ) { +if (global_fds[lcore_id] !=-1 ) {RTE_LOG (ERR ,GUEST_CHANNEL ,"Channel(%u) is already open with fd %d\n" , lcore_id, global_fds[lcore_id]);return -1 ;
@@ -84,7 +84,7 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id)return 0 ; error:close (fd); - global_fds[lcore_id] =0 ; + global_fds[lcore_id] =-1 ;return -1 ; }
@@ -100,7 +100,7 @@ guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id)return -1 ; } -if (global_fds[lcore_id] ==0 ) { +if (global_fds[lcore_id] <0 ) {RTE_LOG (ERR ,GUEST_CHANNEL ,"Channel is not connected\n" );return -1 ; }
@@ -134,8 +134,8 @@ guest_channel_host_disconnect(unsigned int lcore_id) lcore_id, RTE_MAX_LCORE-1);return ; } -if (global_fds[lcore_id] ==0 ) +if (global_fds[lcore_id] <0 )return ;close (global_fds[lcore_id]); - global_fds[lcore_id] =0 ; + global_fds[lcore_id] =-1 ; }
Signature · 1 line
2.17.2
Re: [PATCH v3 1/4] power: fix invalid socket indicator value
Quoted 56 lines · Hajkowski
From: Marcin Hajkowski <[email protected]>
Currently 0 is being used for not connected slot indication. This is not consistent with linux doc which identifies 0 as valid (connected) slot, thus modification was done to change it.
Fixes cd0d5547 ("power: vm communication channels in guest")Signed-off-by Marcin Hajkowski <[email protected]>--- lib/librte_power/guest_channel.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)lib/librte_power/guest_channel.c +4
-4@@ -19,7 +19,7 @@#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1 -static int global_fds[RTE_MAX_LCORE ]; +static int global_fds[RTE_MAX_LCORE ] = { [0 ...RTE_MAX_LCORE -1 ] =-1 };int guest_channel_host_connect (const char *path,unsigned int lcore_id)@@ -35,7 +35,7 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id)return -1 ; }/* check if path is already open */ -if (global_fds[lcore_id] !=0 ) { +if (global_fds[lcore_id] !=-1 ) {RTE_LOG (ERR ,GUEST_CHANNEL ,"Channel(%u) is already open with fd %d\n" , lcore_id, global_fds[lcore_id]);return -1 ;@@ -84,7 +84,7 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id)return 0 ; error:close (fd); - global_fds[lcore_id] =0 ; + global_fds[lcore_id] =-1 ;return -1 ; }@@ -100,7 +100,7 @@ guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id)return -1 ; } -if (global_fds[lcore_id] ==0 ) { +if (global_fds[lcore_id] <0 ) {RTE_LOG (ERR ,GUEST_CHANNEL ,"Channel is not connected\n" );return -1 ; }
lib/librte_power/guest_channel.c guest_channel_host_disconnect(unsigned int lcore_id) · line 141
Quoted 10 lines
lib/librte_power/guest_channel.c +2
-2@@ -134,8 +134,8 @@ guest_channel_host_disconnect(unsigned int lcore_id) lcore_id, RTE_MAX_LCORE-1);return ; } -if (global_fds[lcore_id] ==0 ) +if (global_fds[lcore_id] <0 )return ;close (global_fds[lcore_id]); - global_fds[lcore_id] =0 ; + global_fds[lcore_id] =-1 ; }
Re: [PATCH v3 1/4] power: fix invalid socket indicator value
In reply to Hajkowskilib/librte_power/guest_channel.c
Quoted 18 lines · Hajkowski
From: Marcin Hajkowski <[email protected]>
Currently 0 is being used for not connected slot indication. This is not consistent with linux doc which identifies 0 as valid (connected) slot, thus modification was done to change it.
Fixes cd0d5547 ("power: vm communication channels in guest")Signed-off-by Marcin Hajkowski <[email protected]>--- lib/librte_power/guest_channel.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)lib/librte_power/guest_channel.c +0
-0
Signature · 2 lines
Thanks, Anatoly
PATCH v3 2/4 power: extend guest channel api for reading
In reply to HajkowskiFrom: Marcin Hajkowski <[email protected]>
Added new experimental API rte_power_guest_channel_receive_msg which gives possibility to receive messages send to guest.
--- lib/librte_power/channel_commands.h | 5 ++ lib/librte_power/guest_channel.c | 65 ++++++++++++++++++++++++++ lib/librte_power/guest_channel.h | 35 ++++++++++++++ lib/librte_power/rte_power_version.map | 1 + 4 files changed, 106 insertions(+)
lib/librte_power/channel_commands.h +5 -0
@@ -28,6 +28,11 @@ extern "C" {#define CPU_POWER_SCALE_MIN 4#define CPU_POWER_ENABLE_TURBO 5#define CPU_POWER_DISABLE_TURBO 6 + +/* Generic Power Command Response */ +#define CPU_POWER_CMD_ACK 1 +#define CPU_POWER_CMD_NACK 2 +#define HOURS 24#define MAX_VFS 10
lib/librte_power/guest_channel.c +65 -0
83 lines not on this page · raw message
lib/librte_power/guest_channel.h +35 -0
@@ -68,6 +68,41 @@ int guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id);int rte_power_guest_channel_send_msg (struct channel_packet *pkt,unsigned int lcore_id); +/** +* Read a message contained in pkt over the Virtio-Serial +* from the host endpoint. +* +* @param pkt +* Pointer to a populated struct channel_packet +* +* @param lcore_id +* lcore_id. +* +* @return +* - 0 on success. +* - Negative on error. +*/ +int power_guest_channel_read_msg (struct channel_packet *pkt, +unsigned int lcore_id); + +/** +* Receive a message contained in pkt over the Virtio-Serial +* from the host endpoint. +* +* @param pkt +* Pointer to a populated struct channel_packet +* +* @param lcore_id +* lcore_id. +* +* @return +* - 0 on success. +* - Negative on error. +*/ +int __rte_experimental +rte_power_guest_channel_receive_msg (struct channel_packet *pkt, +unsigned int lcore_id); + #ifdef __cplusplus }#endif
lib/librte_power/rte_power_version.map +1 -0
@@ -44,4 +44,5 @@ EXPERIMENTAL { rte_power_empty_poll_stat_update; rte_power_poll_stat_fetch; rte_power_poll_stat_update; + rte_power_guest_channel_receive_msg; };
Signature · 1 line
2.17.2
Re: [PATCH v3 2/4] power: extend guest channel api for reading
Quoted 65 lines · Hajkowski
From: Marcin Hajkowski <[email protected]>
Added new experimental API
rte_power_guest_channel_receive_msgwhich gives possibility to receive messages send to guest.Signed-off-by Marcin Hajkowski <[email protected]>--- lib/librte_power/channel_commands.h | 5 ++ lib/librte_power/guest_channel.c | 65 ++++++++++++++++++++++++++ lib/librte_power/guest_channel.h | 35 ++++++++++++++ lib/librte_power/rte_power_version.map | 1 + 4 files changed, 106 insertions(+)lib/librte_power/channel_commands.h +5
-0@@ -28,6 +28,11 @@ extern "C" {#define CPU_POWER_SCALE_MIN 4#define CPU_POWER_ENABLE_TURBO 5#define CPU_POWER_DISABLE_TURBO 6 + +/* Generic Power Command Response */ +#define CPU_POWER_CMD_ACK 1 +#define CPU_POWER_CMD_NACK 2 +#define HOURS 24#define MAX_VFS 10lib/librte_power/guest_channel.c +14
-0@@ -10,6 +10,7 @@#include <fcntl.h> #include <string.h> #include <errno.h> +#include <poll.h> #include <rte_log.h> @@ -19,6 +20,9 @@#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1 +/* Timeout for incoming message in milliseconds. */ +#define TIMEOUT 10 +static int global_fds[RTE_MAX_LCORE ] = { [0 ...RTE_MAX_LCORE -1 ] =-1 };int @@ -125,6 +129,67 @@ int rte_power_guest_channel_send_msg(struct channel_packet *pkt,return guest_channel_send_msg (pkt, lcore_id); } +int power_guest_channel_read_msg (struct channel_packet *pkt, +unsigned int lcore_id) +{ +int ret; + +struct pollfd fds; + fds.fd = global_fds[lcore_id]; + fds.events =POLLIN ; + + ret =poll (&fds,1 ,TIMEOUT );
lib/librte_power/guest_channel.c int rte_power_guest_channel_send_msg(struct channel_packet *pkt, · line 151
Quoted 10 lines
lib/librte_power/guest_channel.c +10
-0+if (ret ==0 ) { +RTE_LOG (DEBUG ,GUEST_CHANNEL ,"Timeout occurs during poll function.\n" ); +return -1 ; + }else if (ret <0 ) { +RTE_LOG (ERR ,GUEST_CHANNEL ,"Error occurred during poll function: %s\n" , +strerror (ret)); +return -1 ; + } + +void *buffer = pkt;
I would prefer it to be declared at the beginning of the function, but at least, declare it just before the while loop.
Quoted 36 lines
lib/librte_power/guest_channel.c +36
-0+ +if (lcore_id >=RTE_MAX_LCORE ) { +RTE_LOG (ERR ,GUEST_CHANNEL ,"Channel(%u) is out of range 0...%d\n" , + lcore_id,RTE_MAX_LCORE -1 ); +return -1 ; + } + +if (global_fds[lcore_id] <0 ) { +RTE_LOG (ERR ,GUEST_CHANNEL ,"Channel is not connected\n" ); +return -1 ; + } + +int buffer_len =sizeof (*pkt); + +while (buffer_len >0 ) { + ret =read (global_fds[lcore_id], + buffer, buffer_len); +if (ret <0 ) { +if (errno ==EINTR ) +continue ; +return -1 ; + } +/* No data has been read, this can indicate not +* consistent buffer_len with actual data size. +*/ +if (ret ==0 ) { +RTE_LOG (ERR ,GUEST_CHANNEL ,"No more data has been read.\n" ); +return -1 ; + } + buffer = (char *)buffer + ret; + buffer_len -= ret; + } + +return 0 ; +} +
Re: [PATCH v3 2/4] power: extend guest channel api for reading
Quoted 81 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Maxime Coquelin
Sent: Friday, March 22, 2019 11:00 AM
To: Hajkowski, MarcinX <[email protected]>; Hunt, David <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v3 2/4] power: extend guest channel api for readingQuoted 69 lines · Hajkowski
From: Marcin Hajkowski <[email protected]>
Added new experimental API
rte_power_guest_channel_receive_msgwhich gives possibility to receive messages send to guest.Signed-off-by Marcin Hajkowski <[email protected]>--- lib/librte_power/channel_commands.h | 5 ++ lib/librte_power/guest_channel.c | 65 ++++++++++++++++++++++++++ lib/librte_power/guest_channel.h | 35 ++++++++++++++ lib/librte_power/rte_power_version.map | 1 + 4 files changed, 106 insertions(+)lib/librte_power/channel_commands.h +5
-0@@ -28,6 +28,11 @@ extern "C" {#define CPU_POWER_SCALE_MIN 4#define CPU_POWER_ENABLE_TURBO 5#define CPU_POWER_DISABLE_TURBO 6 + +/* Generic Power Command Response */ +#define CPU_POWER_CMD_ACK 1 +#define CPU_POWER_CMD_NACK 2 +#define HOURS 24#define MAX_VFS 10lib/librte_power/guest_channel.c +18
-0@@ -10,6 +10,7 @@#include <fcntl.h> #include <string.h> #include <errno.h> +#include <poll.h> #include <rte_log.h> @@ -19,6 +20,9 @@#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1 +/* Timeout for incoming message in milliseconds. */ +#define TIMEOUT 10 +static int global_fds[RTE_MAX_LCORE ] = { [0 ...RTE_MAX_LCORE -1 ] =-1 };int @@ -125,6 +129,67 @@ int rte_power_guest_channel_send_msg(struct channel_packet *pkt,return guest_channel_send_msg (pkt, lcore_id); } +int power_guest_channel_read_msg (struct channel_packet *pkt, +unsigned int lcore_id) +{ +int ret; + +struct pollfd fds; + fds.fd = global_fds[lcore_id]; + fds.events =POLLIN ; + + ret =poll (&fds,1 ,TIMEOUT ); +if (ret ==0 ) { +RTE_LOG (DEBUG ,GUEST_CHANNEL ,"Timeout occurs during poll function.\n" ); +return -1 ; + }else if (ret <0 ) {
Quoted 8 lines
lib/librte_power/guest_channel.c int rte_power_guest_channel_send_msg(struct channel_packet *pkt, · line 151
Quoted 6 lines
lib/librte_power/guest_channel.c +6
-0+RTE_LOG (ERR ,GUEST_CHANNEL ,"Error occurred during poll function: %s\n" , +strerror (ret)); +return -1 ; + } + +void *buffer = pkt;I would prefer it to be declared at the beginning of the function,
+1 here and in other places.
please follow dpdk coding style convention.
Quoted 38 lines
but at least, declare it just before the while loop.
Quoted 36 lines
lib/librte_power/guest_channel.c +36
-0+ +if (lcore_id >=RTE_MAX_LCORE ) { +RTE_LOG (ERR ,GUEST_CHANNEL ,"Channel(%u) is out of range 0...%d\n" , + lcore_id,RTE_MAX_LCORE -1 ); +return -1 ; + } + +if (global_fds[lcore_id] <0 ) { +RTE_LOG (ERR ,GUEST_CHANNEL ,"Channel is not connected\n" ); +return -1 ; + } + +int buffer_len =sizeof (*pkt); + +while (buffer_len >0 ) { + ret =read (global_fds[lcore_id], + buffer, buffer_len); +if (ret <0 ) { +if (errno ==EINTR ) +continue ; +return -1 ; + } +/* No data has been read, this can indicate not +* consistent buffer_len with actual data size. +*/ +if (ret ==0 ) { +RTE_LOG (ERR ,GUEST_CHANNEL ,"No more data has been read.\n" ); +return -1 ; + } + buffer = (char *)buffer + ret; + buffer_len -= ret; + } + +return 0 ; +} +
Re: [PATCH v3 2/4] power: extend guest channel api for reading
In reply to HajkowskiQuoted 52 lines · Hajkowski
From: Marcin Hajkowski <[email protected]>
Added new experimental API
rte_power_guest_channel_receive_msgwhich gives possibility to receive messages send to guest.Signed-off-by Marcin Hajkowski <[email protected]>--- lib/librte_power/channel_commands.h | 5 ++ lib/librte_power/guest_channel.c | 65 ++++++++++++++++++++++++++ lib/librte_power/guest_channel.h | 35 ++++++++++++++ lib/librte_power/rte_power_version.map | 1 + 4 files changed, 106 insertions(+)lib/librte_power/channel_commands.h +5
-0@@ -28,6 +28,11 @@ extern "C" {#define CPU_POWER_SCALE_MIN 4#define CPU_POWER_ENABLE_TURBO 5#define CPU_POWER_DISABLE_TURBO 6 + +/* Generic Power Command Response */ +#define CPU_POWER_CMD_ACK 1 +#define CPU_POWER_CMD_NACK 2 +#define HOURS 24#define MAX_VFS 10lib/librte_power/guest_channel.c +4
-0@@ -10,6 +10,7 @@#include <fcntl.h> #include <string.h> #include <errno.h> +#include <poll.h> #include <rte_log.h> @@ -19,6 +20,9 @@#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1 +/* Timeout for incoming message in milliseconds. */ +#define TIMEOUT 10 +static int global_fds[RTE_MAX_LCORE ] = { [0 ...RTE_MAX_LCORE -1 ] =-1 };int
lib/librte_power/guest_channel.c int rte_power_guest_channel_send_msg(struct channel_packet *pkt, · line 137
Quoted 9 lines
lib/librte_power/guest_channel.c +6
-0@@ -125,6 +129,67 @@ int rte_power_guest_channel_send_msg(struct channel_packet *pkt,return guest_channel_send_msg (pkt, lcore_id); } +int power_guest_channel_read_msg (struct channel_packet *pkt, +unsigned int lcore_id) +{ +int ret; + +struct pollfd fds;
Nitpick, but we generally prefer having a newline after definitions.
lib/librte_power/guest_channel.c int rte_power_guest_channel_send_msg(struct channel_packet *pkt, · line 143
Quoted 6 lines
lib/librte_power/guest_channel.c +6
-0+ fds.fd = global_fds[lcore_id]; + fds.events =POLLIN ; + + ret =poll (&fds,1 ,TIMEOUT ); +if (ret ==0 ) { +RTE_LOG (DEBUG ,GUEST_CHANNEL ,"Timeout occurs during poll function.\n" );
Occurred?
lib/librte_power/guest_channel.c int rte_power_guest_channel_send_msg(struct channel_packet *pkt, · line 151
Quoted 8 lines
lib/librte_power/guest_channel.c +8
-0+return -1 ; + }else if (ret <0 ) { +RTE_LOG (ERR ,GUEST_CHANNEL ,"Error occurred during poll function: %s\n" , +strerror (ret)); +return -1 ; + } + +void *buffer = pkt;
Declarations have to be in the beginning of the function.
lib/librte_power/guest_channel.c int rte_power_guest_channel_send_msg(struct channel_packet *pkt, · line 164
Quoted 13 lines
lib/librte_power/guest_channel.c +13
-0+ +if (lcore_id >=RTE_MAX_LCORE ) { +RTE_LOG (ERR ,GUEST_CHANNEL ,"Channel(%u) is out of range 0...%d\n" , + lcore_id,RTE_MAX_LCORE -1 ); +return -1 ; + } + +if (global_fds[lcore_id] <0 ) { +RTE_LOG (ERR ,GUEST_CHANNEL ,"Channel is not connected\n" ); +return -1 ; + } + +int buffer_len =sizeof (*pkt);
Same, declarations on top.
Quoted 6 lines
lib/librte_power/guest_channel.c +6
-0+ +while (buffer_len >0 ) { + ret =read (global_fds[lcore_id], + buffer, buffer_len); +if (ret <0 ) { +if (errno ==EINTR )
lib/librte_power/guest_channel.c int rte_power_guest_channel_send_msg(struct channel_packet *pkt, · line 180
Quoted 10 lines
lib/librte_power/guest_channel.c +10
-0+continue ; +return -1 ; + } +/* No data has been read, this can indicate not +* consistent buffer_len with actual data size. +*/ +if (ret ==0 ) { +RTE_LOG (ERR ,GUEST_CHANNEL ,"No more data has been read.\n" ); +return -1 ; + }
If i remember correctly, this cannot happen with a blocking fifo read unless the fifo was closed either by us or by the other end. Perhaps the error message should be reworded to reflect that? E.g. something like "Expected more data, but fifo is closed"?
Signature · 2 lines
Thanks, Anatoly
PATCH v3 3/4 power: process incoming confirmation cmds
In reply to HajkowskiFrom: Marcin Hajkowski <[email protected]>
Extend vm_power_guest to check incoming confirmations of messages previously sent to host.
--- examples/vm_power_manager/guest_cli/Makefile | 1 + .../guest_cli/vm_power_cli_guest.c | 65 +++++++++++++++---- 2 files changed, 54 insertions(+), 12 deletions(-)
examples/vm_power_manager/guest_cli/Makefile +1 -0
@@ -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
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +53 -12
102 lines not on this page · raw message
Signature · 1 line
2.17.2
Re: [PATCH v3 3/4] power: process incoming confirmation cmds
Quoted 36 lines · Hajkowski
From: Marcin Hajkowski <[email protected]>
Extend
vm_power_guestto check incoming confirmations of messages previously sent to host.Signed-off-by Marcin Hajkowski <[email protected]>--- examples/vm_power_manager/guest_cli/Makefile | 1 + .../guest_cli/vm_power_cli_guest.c | 65 +++++++++++++++---- 2 files changed, 54 insertions(+), 12 deletions(-)examples/vm_power_manager/guest_cli/Makefile +1
-0@@ -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=12603examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +5
-0@@ -132,6 +132,26 @@ 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;
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c struct cmd_set_cpu_freq_result { · line 149
Quoted 10 lines
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +10
-0+ + ret =rte_power_guest_channel_receive_msg (&pkt, lcore_id); +if (ret <0 ) +return -1 ; + +if (pkt.command !=CPU_POWER_CMD_ACK && + pkt.command !=CPU_POWER_CMD_NACK ) { +RTE_LOG (DEBUG ,POWER ,"Not expected command has been received.\n" ); +return -1 ; + }
Maybe use switch?
E.g.
swithc (pkt.command) {
case ACK:
case NACK:
*result = blah;
break;
default:
log failure;
fail;
}Quoted 31 lines
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +11
-5+ + *result = (pkt.command ==CPU_POWER_CMD_ACK ); +return 0 ; +} +static void cmd_set_cpu_freq_parsed (void *parsed_result,struct cmdline *cl, __attribute__((unused))void *data)@@ -139,20 +159,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 ) {
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c cmd_set_cpu_freq_parsed(void *parsed_result, struct cmdline *cl, · line 185
Quoted 10 lines
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +9
-0cmdline_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 (DEBUG ,POWER ,"No confirmation for sent msg received\n" ); + }else { +cmdline_printf (cl,"Ack for sent msg received with result: %s.\n" , + result ==1 ?"SUCCESS" :"ERROR" );
Here and in other places: others can correct me if i'm wrong, but i'm pretty sure RTE_LOG(..., POWER) is reserved for logs related to power library, and are not supposed to be used in user applications. If logging in an application is required, there are USER log levels.
I can see that the app in question already does that in a few places, so it's kind of consistent with how things are already, but i would question the value of consistency in cases like these. Not sure how to proceed here.
Quoted 47 lines
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +18
-7+ } } cmdline_parse_token_string_t cmd_set_cpu_freq =@@ -185,16 +216,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 (DEBUG ,POWER ,"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 (DEBUG ,POWER ,"No confirmation for sent policy received\n" ); + }else { +cmdline_printf (cl,"Ack for sent policy received with result: %s.\n" , + result ==1 ?"SUCCESS" :"ERROR" ); + } +return 1 ; } static void@@ -206,7 +247,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",
Signature · 2 lines
Thanks, Anatoly
Re: [PATCH v3 3/4] power: process incoming confirmation cmds
In reply to HajkowskiReview
Quoted 8 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Hajkowski
Sent: Thursday, March 21, 2019 10:55 AM(quoted diff) +1
-0+ RTE_LOG(DEBUG, POWER, "No confirmation for sent msgreceived\n");
(quoted diff) +1
-0+ }
As Anatoly mentioned, we should not use POWER log here, instead #define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1 is defined for GUEST_CHANNEL logs, you should use that for the logs in this file.
Thanks,
Reshma
PATCH v3 4/4 power: send confirmation cmd to vm guest
In reply to HajkowskiFrom: Marcin Hajkowski <[email protected]>
Use new guest channel API to send confirmation
message for received power command.
--- examples/vm_power_manager/channel_monitor.c | 67 +++++++++++++++++++-- 1 file changed, 61 insertions(+), 6 deletions(-)
examples/vm_power_manager/channel_monitor.c +61 -6
@@ -627,6 +627,39 @@ apply_policy(struct policy *pol)apply_workload_profile (pol); } +static int +write_binary_packet (struct channel_packet *pkt,struct channel_info *chan_info) +{ +int ret, buffer_len =sizeof (*pkt); +void *buffer = pkt; + +if (chan_info->fd ==0 ) { +RTE_LOG (ERR ,CHANNEL_MONITOR ,"Channel is not connected\n" ); +return -1 ; + } + +while (buffer_len >0 ) { + ret =write (chan_info->fd, buffer, buffer_len); +if (ret ==-1 ) { +if (errno ==EINTR ) +continue ; +return -1 ; + } + buffer = (char *)buffer + ret; + buffer_len -= ret; + } +return 0 ; +} + +static int +send_ack_for_received_cmd (struct channel_packet *pkt, +struct channel_info *chan_info, +uint32_t command) +{ + pkt->command = command; +return write_binary_packet (pkt, chan_info); +} +static int process_request (struct channel_packet *pkt,struct channel_info *chan_info) {
@@ -645,33 +678,55 @@ process_request(struct channel_packet *pkt, struct channel_info *chan_info)else core_num = pkt->resource_id; +bool valid_unit = true; +int scale_res; +switch (pkt->unit) {case (CPU_POWER_SCALE_MIN ): -power_manager_scale_core_min (core_num); + scale_res =power_manager_scale_core_min (core_num);break ;case (CPU_POWER_SCALE_MAX ): -power_manager_scale_core_max (core_num); + scale_res =power_manager_scale_core_max (core_num);break ;case (CPU_POWER_SCALE_DOWN ): -power_manager_scale_core_down (core_num); + scale_res =power_manager_scale_core_down (core_num);break ;case (CPU_POWER_SCALE_UP ): -power_manager_scale_core_up (core_num); + scale_res =power_manager_scale_core_up (core_num);break ;case (CPU_POWER_ENABLE_TURBO ): -power_manager_enable_turbo_core (core_num); + scale_res =power_manager_enable_turbo_core (core_num);break ;case (CPU_POWER_DISABLE_TURBO ): -power_manager_disable_turbo_core (core_num); + scale_res =power_manager_disable_turbo_core (core_num);break ;default : + valid_unit = false;break ; } + +int ret =-1 ; +if (valid_unit) { + ret =send_ack_for_received_cmd (pkt, + chan_info, + scale_res >0 ? +CPU_POWER_CMD_ACK + :CPU_POWER_CMD_NACK ); +if (ret <0 ) +RTE_LOG (DEBUG ,CHANNEL_MONITOR ,"Error during sending ack command.\n" ); + }else +RTE_LOG (DEBUG ,CHANNEL_MONITOR ,"Unexpected unit type.\n" ); + }if (pkt->command ==PKT_POLICY ) {RTE_LOG (INFO ,CHANNEL_MONITOR ,"Processing policy request %s\n" , pkt->vm_name); +int ret =send_ack_for_received_cmd (pkt, + chan_info, +CPU_POWER_CMD_ACK ); +if (ret <0 ) +RTE_LOG (DEBUG ,CHANNEL_MONITOR ,"Error during sending ack command.\n" );update_policy (pkt); policy_is_set =1 ; }
Signature · 1 line
2.17.2
Re: [PATCH v3 4/4] power: send confirmation cmd to vm guest
Quoted 15 lines · Hajkowski
From: Marcin Hajkowski <[email protected]>
Use new guest channel API to send confirmation
message for received power command.Signed-off-by Marcin Hajkowski <[email protected]>--- examples/vm_power_manager/channel_monitor.c | 67 +++++++++++++++++++-- 1 file changed, 61 insertions(+), 6 deletions(-)examples/vm_power_manager/channel_monitor.c +0
-0
examples/vm_power_manager/channel_monitor.c apply_policy(struct policy *pol) · line 636
Quoted 10 lines
examples/vm_power_manager/channel_monitor.c +7
-0@@ -627,6 +627,39 @@ apply_policy(struct policy *pol)apply_workload_profile (pol); } +static int +write_binary_packet (struct channel_packet *pkt,struct channel_info *chan_info) +{ +int ret, buffer_len =sizeof (*pkt); +void *buffer = pkt; + +if (chan_info->fd ==0 ) {
Shouldn't this be -1?
examples/vm_power_manager/channel_monitor.c apply_policy(struct policy *pol) · line 645
Quoted 9 lines
examples/vm_power_manager/channel_monitor.c +9
-0+RTE_LOG (ERR ,CHANNEL_MONITOR ,"Channel is not connected\n" ); +return -1 ; + } + +while (buffer_len >0 ) { + ret =write (chan_info->fd, buffer, buffer_len); +if (ret ==-1 ) { +if (errno ==EINTR ) +continue ;
Perhaps writing out a debug message with strerror(errno) here?
examples/vm_power_manager/channel_monitor.c apply_policy(struct policy *pol) · line 657
Quoted 12 lines
examples/vm_power_manager/channel_monitor.c +12
-0+return -1 ; + } + buffer = (char *)buffer + ret; + buffer_len -= ret; + } +return 0 ; +} + +static int +send_ack_for_received_cmd (struct channel_packet *pkt, +struct channel_info *chan_info, +uint32_t command)
Too much tabs IMO :)
Quoted 42 lines
examples/vm_power_manager/channel_monitor.c +15
-6+{ + pkt->command = command; +return write_binary_packet (pkt, chan_info); +} +static int process_request (struct channel_packet *pkt,struct channel_info *chan_info) {@@ -645,33 +678,55 @@ process_request(struct channel_packet *pkt, struct channel_info *chan_info)else core_num = pkt->resource_id; +bool valid_unit = true; +int scale_res; +switch (pkt->unit) {case (CPU_POWER_SCALE_MIN ): -power_manager_scale_core_min (core_num); + scale_res =power_manager_scale_core_min (core_num);break ;case (CPU_POWER_SCALE_MAX ): -power_manager_scale_core_max (core_num); + scale_res =power_manager_scale_core_max (core_num);break ;case (CPU_POWER_SCALE_DOWN ): -power_manager_scale_core_down (core_num); + scale_res =power_manager_scale_core_down (core_num);break ;case (CPU_POWER_SCALE_UP ): -power_manager_scale_core_up (core_num); + scale_res =power_manager_scale_core_up (core_num);break ;case (CPU_POWER_ENABLE_TURBO ): -power_manager_enable_turbo_core (core_num); + scale_res =power_manager_enable_turbo_core (core_num);break ;case (CPU_POWER_DISABLE_TURBO ): -power_manager_disable_turbo_core (core_num); + scale_res =power_manager_disable_turbo_core (core_num);break ;default : + valid_unit = false;
examples/vm_power_manager/channel_monitor.c process_request(struct channel_packet *pkt, struct channel_info *chan_info) · line 714
Quoted 10 lines
examples/vm_power_manager/channel_monitor.c +8
-0break ; } + +int ret =-1 ; +if (valid_unit) { + ret =send_ack_for_received_cmd (pkt, + chan_info, + scale_res >0 ? +CPU_POWER_CMD_ACK + :CPU_POWER_CMD_NACK );
I think layout like this looks more readable:
ret = send_ack_for_received_cmd(pkt,
chan_info, scale_res > 0 ? CPU_POWER_CMD_ACK : CPU_POWER_CMD_NACK);
Note the two tabs (not three), extra tab for ternary, and colon on the first line rather than the second one.
examples/vm_power_manager/channel_monitor.c process_request(struct channel_packet *pkt, struct channel_info *chan_info) · line 727
Quoted 13 lines
examples/vm_power_manager/channel_monitor.c +8
-0+if (ret <0 ) +RTE_LOG (DEBUG ,CHANNEL_MONITOR ,"Error during sending ack command.\n" ); + }else +RTE_LOG (DEBUG ,CHANNEL_MONITOR ,"Unexpected unit type.\n" ); + }if (pkt->command ==PKT_POLICY ) {RTE_LOG (INFO ,CHANNEL_MONITOR ,"Processing policy request %s\n" , pkt->vm_name); +int ret =send_ack_for_received_cmd (pkt, + chan_info, +CPU_POWER_CMD_ACK );
Again, four tabs seems way too much. Two maybe?
Quoted 6 lines
examples/vm_power_manager/channel_monitor.c +2
-0+if (ret <0 ) +RTE_LOG (DEBUG ,CHANNEL_MONITOR ,"Error during sending ack command.\n" );update_policy (pkt); policy_is_set =1 ; }
Signature · 2 lines
Thanks, Anatoly
21/03/2019 11:55, Hajkowski:
Quoted 12 lines
From: Marcin Hajkowski <[email protected]>
Extend guest channel API to allow bidirectional communication. Modify power manager host and guest side to communicate in both directions.
v3:
* fix global_fds[lcore_id] comparison to invalid value
* check 0 to verify if read function actually read some data
* define_NACKcmd instead of_NAK
* simplifyrte_power_guest_channel_receive_msgfunc logic
Quoted 4 lines
v2:
* send ack only if power operation return positive value
* log diffent error for unexpected incoming command and error during ack/nak cmd sending
Please use --in-reply-to to keep all versions in the same thread, thanks.
v4 cover bidirect guest channel
In reply to HajkowskiFrom: Marcin Hajkowski <[email protected]>
Extend guest channel API to allow bidirectional communication. Modify power manager host and guest side to communicate in both directions.
---
v4:
* [vm_power_manager] treat 0 as valid socket id
* [guest_manager] use user level logs
* correct code formatting
v3:
* fix global_fds[lcore_id] comparison to invalid value
* check 0 to verify if read function actually read some data
* define _NACK cmd instead of _NAK
* simplify rte_power_guest_channel_receive_msg func logic
v2:
* send ack only if power operation return positive value
* log diffent error for unexpected incoming command and error during ack/nak cmd sending
Marcin Hajkowski (4):
power: fix invalid socket indicator value
power: extend guest channel api for reading
power: process incoming confirmation cmds
power: send confirmation cmd to vm guest
examples/vm_power_manager/channel_monitor.c | 68 ++++++++++++++++-- examples/vm_power_manager/guest_cli/Makefile | 1 + .../guest_cli/vm_power_cli_guest.c | 72 +++++++++++++++---- lib/librte_power/channel_commands.h | 5 ++ lib/librte_power/guest_channel.c | 72 +++++++++++++++++-- lib/librte_power/guest_channel.h | 35 +++++++++ lib/librte_power/rte_power_version.map | 1 + 7 files changed, 229 insertions(+), 25 deletions(-)
Signature · 1 line
2.17.2
PATCH v4 1/4 power: fix invalid socket indicator value
From: Marcin Hajkowski <[email protected]>
Currently 0 is being used for not connected slot indication. This is not consistent with linux doc which identifies 0 as valid (connected) slot, thus modification was done to change it.
--- lib/librte_power/guest_channel.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/librte_power/guest_channel.c +6 -6
@@ -19,7 +19,7 @@#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1 -static int global_fds[RTE_MAX_LCORE ]; +static int global_fds[RTE_MAX_LCORE ] = { [0 ...RTE_MAX_LCORE -1 ] =-1 };int guest_channel_host_connect (const char *path,unsigned int lcore_id)
@@ -35,7 +35,7 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id)return -1 ; }/* check if path is already open */ -if (global_fds[lcore_id] !=0 ) { +if (global_fds[lcore_id] !=-1 ) {RTE_LOG (ERR ,GUEST_CHANNEL ,"Channel(%u) is already open with fd %d\n" , lcore_id, global_fds[lcore_id]);return -1 ;
@@ -84,7 +84,7 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id)return 0 ; error:close (fd); - global_fds[lcore_id] =0 ; + global_fds[lcore_id] =-1 ;return -1 ; }
@@ -100,7 +100,7 @@ guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id)return -1 ; } -if (global_fds[lcore_id] ==0 ) { +if (global_fds[lcore_id] <0 ) {RTE_LOG (ERR ,GUEST_CHANNEL ,"Channel is not connected\n" );return -1 ; }
@@ -134,8 +134,8 @@ guest_channel_host_disconnect(unsigned int lcore_id) lcore_id, RTE_MAX_LCORE-1);return ; } -if (global_fds[lcore_id] ==0 ) +if (global_fds[lcore_id] <0 )return ;close (global_fds[lcore_id]); - global_fds[lcore_id] =0 ; + global_fds[lcore_id] =-1 ; }
Signature · 1 line
2.17.2
PATCH v4 2/4 power: extend guest channel api for reading
In reply to HajkowskiFrom: Marcin Hajkowski <[email protected]>
Added new experimental API rte_power_guest_channel_receive_msg which gives possibility to receive messages send to guest.
--- lib/librte_power/channel_commands.h | 5 +++ lib/librte_power/guest_channel.c | 60 ++++++++++++++++++++++++++ lib/librte_power/guest_channel.h | 35 +++++++++++++++ lib/librte_power/rte_power_version.map | 1 + 4 files changed, 101 insertions(+)
lib/librte_power/channel_commands.h +5 -0
@@ -28,6 +28,11 @@ extern "C" {#define CPU_POWER_SCALE_MIN 4#define CPU_POWER_ENABLE_TURBO 5#define CPU_POWER_DISABLE_TURBO 6 + +/* Generic Power Command Response */ +#define CPU_POWER_CMD_ACK 1 +#define CPU_POWER_CMD_NACK 2 +#define HOURS 24#define MAX_VFS 10
lib/librte_power/guest_channel.c +60 -0
78 lines not on this page · raw message
lib/librte_power/guest_channel.h +35 -0
@@ -68,6 +68,41 @@ int guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id);int rte_power_guest_channel_send_msg (struct channel_packet *pkt,unsigned int lcore_id); +/** +* Read a message contained in pkt over the Virtio-Serial +* from the host endpoint. +* +* @param pkt +* Pointer to a populated struct channel_packet +* +* @param lcore_id +* lcore_id. +* +* @return +* - 0 on success. +* - Negative on error. +*/ +int power_guest_channel_read_msg (struct channel_packet *pkt, +unsigned int lcore_id); + +/** +* Receive a message contained in pkt over the Virtio-Serial +* from the host endpoint. +* +* @param pkt +* Pointer to a populated struct channel_packet +* +* @param lcore_id +* lcore_id. +* +* @return +* - 0 on success. +* - Negative on error. +*/ +int __rte_experimental +rte_power_guest_channel_receive_msg (struct channel_packet *pkt, +unsigned int lcore_id); + #ifdef __cplusplus }#endif
lib/librte_power/rte_power_version.map +1 -0
@@ -44,4 +44,5 @@ EXPERIMENTAL { rte_power_empty_poll_stat_update; rte_power_poll_stat_fetch; rte_power_poll_stat_update; + rte_power_guest_channel_receive_msg; };
Signature · 1 line
2.17.2
PATCH v4 3/4 power: process incoming confirmation cmds
In reply to HajkowskiFrom: Marcin Hajkowski <[email protected]>
Extend vm_power_guest to check incoming confirmations of messages previously sent to host.
--- examples/vm_power_manager/guest_cli/Makefile | 1 + .../guest_cli/vm_power_cli_guest.c | 72 +++++++++++++++---- 2 files changed, 60 insertions(+), 13 deletions(-)
examples/vm_power_manager/guest_cli/Makefile +1 -0
@@ -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
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +59 -13
115 lines not on this page · raw message
Signature · 1 line
2.17.2
Re: [PATCH v4 3/4] power: process incoming confirmation cmds
Quoted 6 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Hajkowski(quoted diff) +1
-0+ RTE_LOG(DEBUG, GUEST_CLI, "Not expected command hasbeen received.\n");
Instead of : "Not expected command has been received ". How about, Received invalid response from host, expecting NACK/ACK? But let's hear from others.
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c cmd_set_cpu_freq_parsed(void *parsed_result, struct cmdline *cl, · line 192
Quoted 11 lines
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +4
-0+int result; + ret =check_response_cmd (res->lcore_id, &result); +if (ret <0 ) { + RTE_LOG(DEBUG, GUEST_CLI, "No confirmation for sent msgreceived\n");
(quoted diff) +2
-0+ } else { + cmdline_printf(cl, "Ack for sent msg received with result:%s.\n",
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +2
-0+ result == 1 ? "SUCCESS" : "ERROR"); + } }
In else statement how about just checking for result ACK/NACK and have log saying received ACK /received NACK for msg
Thanks,
Reshma
PATCH v4 4/4 power: send confirmation cmd to vm guest
In reply to HajkowskiFrom: Marcin Hajkowski <[email protected]>
Use new guest channel API to send confirmation
message for received power command.
--- examples/vm_power_manager/channel_monitor.c | 68 +++++++++++++++++++-- 1 file changed, 62 insertions(+), 6 deletions(-)
examples/vm_power_manager/channel_monitor.c +62 -6
@@ -627,6 +627,41 @@ apply_policy(struct policy *pol)apply_workload_profile (pol); } +static int +write_binary_packet (struct channel_packet *pkt,struct channel_info *chan_info) +{ +int ret, buffer_len =sizeof (*pkt); +void *buffer = pkt; + +if (chan_info->fd <0 ) { +RTE_LOG (ERR ,CHANNEL_MONITOR ,"Channel is not connected\n" ); +return -1 ; + } + +while (buffer_len >0 ) { + ret =write (chan_info->fd, buffer, buffer_len); +if (ret ==-1 ) { +if (errno ==EINTR ) +continue ; +RTE_LOG (ERR ,CHANNEL_MONITOR ,"Write function failed due to %s.\n" , +strerror (errno)); +return -1 ; + } + buffer = (char *)buffer + ret; + buffer_len -= ret; + } +return 0 ; +} + +static int +send_ack_for_received_cmd (struct channel_packet *pkt, +struct channel_info *chan_info, +uint32_t command) +{ + pkt->command = command; +return write_binary_packet (pkt, chan_info); +} +static int process_request (struct channel_packet *pkt,struct channel_info *chan_info) {
@@ -650,33 +685,54 @@ process_request(struct channel_packet *pkt, struct channel_info *chan_info)RTE_LOG (DEBUG ,CHANNEL_MONITOR ,"Processing requested cmd for cpu:%d\n" , core_num); +bool valid_unit = true; +int scale_res; +switch (pkt->unit) {case (CPU_POWER_SCALE_MIN ): -power_manager_scale_core_min (core_num); + scale_res =power_manager_scale_core_min (core_num);break ;case (CPU_POWER_SCALE_MAX ): -power_manager_scale_core_max (core_num); + scale_res =power_manager_scale_core_max (core_num);break ;case (CPU_POWER_SCALE_DOWN ): -power_manager_scale_core_down (core_num); + scale_res =power_manager_scale_core_down (core_num);break ;case (CPU_POWER_SCALE_UP ): -power_manager_scale_core_up (core_num); + scale_res =power_manager_scale_core_up (core_num);break ;case (CPU_POWER_ENABLE_TURBO ): -power_manager_enable_turbo_core (core_num); + scale_res =power_manager_enable_turbo_core (core_num);break ;case (CPU_POWER_DISABLE_TURBO ): -power_manager_disable_turbo_core (core_num); + scale_res =power_manager_disable_turbo_core (core_num);break ;default : + valid_unit = false;break ; } + +if (valid_unit) { + ret =send_ack_for_received_cmd (pkt, + chan_info, + scale_res >0 ? +CPU_POWER_CMD_ACK : +CPU_POWER_CMD_NACK ); +if (ret <0 ) +RTE_LOG (DEBUG ,CHANNEL_MONITOR ,"Error during sending ack command.\n" ); + }else +RTE_LOG (DEBUG ,CHANNEL_MONITOR ,"Unexpected unit type.\n" ); + }if (pkt->command ==PKT_POLICY ) {RTE_LOG (INFO ,CHANNEL_MONITOR ,"Processing policy request %s\n" , pkt->vm_name); +int ret =send_ack_for_received_cmd (pkt, + chan_info, +CPU_POWER_CMD_ACK ); +if (ret <0 ) +RTE_LOG (DEBUG ,CHANNEL_MONITOR ,"Error during sending ack command.\n" );update_policy (pkt); policy_is_set =1 ; }
Signature · 1 line
2.17.2