From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3BB52A09E4 for ; Thu, 21 Jan 2021 18:23:02 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 41A5E140DDA; Thu, 21 Jan 2021 18:23:00 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 15BF9140D90; Thu, 21 Jan 2021 18:22:53 +0100 (CET) IronPort-SDR: W+kSQQpz2Q3GPpEBdHY2IEJMZYswzsIjfffX6lFnJ4ExOUqznxKyDwBnSmnNoDHhXFQ+4tYyLW Z4iv0s+c05Bg== X-IronPort-AV: E=McAfee;i="6000,8403,9871"; a="175799676" X-IronPort-AV: E=Sophos;i="5.79,364,1602572400"; d="scan'208";a="175799676" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2021 09:22:53 -0800 IronPort-SDR: LR6kGssMCmcH1DvHp85KZ2NlJtfHZ0Nu8SjyBgKlFE3R6OMeAs9y/Zg/1wYh4D1Cxi761pbH0q 5tp0EYZxWvDw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,364,1602572400"; d="scan'208";a="385386751" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.222.38]) by orsmga008.jf.intel.com with ESMTP; 21 Jan 2021 09:22:51 -0800 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, stable@dpdk.org, Bruce Richardson Date: Thu, 21 Jan 2021 17:21:58 +0000 Message-Id: <20210121172201.22582-4-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210121172201.22582-1-david.hunt@intel.com> References: <20210120135556.33763-2-david.hunt@intel.com> <20210121172201.22582-1-david.hunt@intel.com> Subject: [dpdk-stable] [PATCH v4 3/6] power: rename public structs X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" From: Bruce Richardson rename the public structs to have an rte_power_ prefix and add them to version.map in experimental section. Fixes: 210c383e247b ("power: packet format for vm power management") Fixes: cd0d5547e873 ("power: vm communication channels in guest") Cc: stable@dpdk.org Signed-off-by: Bruce Richardson Signed-off-by: David Hunt --- changes in v4 * Improve sizeof's * add the 2 functions to the version.map file --- examples/vm_power_manager/channel_monitor.c | 33 ++++++------ examples/vm_power_manager/channel_monitor.h | 2 +- examples/vm_power_manager/guest_cli/main.c | 2 +- .../guest_cli/vm_power_cli_guest.c | 38 +++++++------- .../guest_cli/vm_power_cli_guest.h | 4 +- lib/librte_power/guest_channel.c | 7 +-- lib/librte_power/guest_channel.h | 7 +-- lib/librte_power/power_kvm_vm.c | 2 +- lib/librte_power/rte_power_guest_channel.h | 51 +++++++++---------- lib/librte_power/version.map | 4 ++ 10 files changed, 77 insertions(+), 73 deletions(-) diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c index 08306105d..1b6041b6f 100644 --- a/examples/vm_power_manager/channel_monitor.c +++ b/examples/vm_power_manager/channel_monitor.c @@ -108,7 +108,7 @@ str_to_ether_addr(const char *a, struct rte_ether_addr *ether_addr) } static int -set_policy_mac(struct channel_packet *pkt, int idx, char *mac) +set_policy_mac(struct rte_power_channel_packet *pkt, int idx, char *mac) { union PFID pfid; int ret; @@ -165,7 +165,7 @@ get_resource_id_from_vmname(const char *vm_name) } static int -parse_json_to_pkt(json_t *element, struct channel_packet *pkt, +parse_json_to_pkt(json_t *element, struct rte_power_channel_packet *pkt, const char *vm_name) { const char *key; @@ -173,7 +173,7 @@ parse_json_to_pkt(json_t *element, struct channel_packet *pkt, int ret; int resource_id; - memset(pkt, 0, sizeof(struct channel_packet)); + memset(pkt, 0, sizeof(*pkt)); pkt->nb_mac_to_monitor = 0; pkt->t_boost_status.tbEnabled = false; @@ -463,7 +463,7 @@ get_pfid(struct policy *pol) } static int -update_policy(struct channel_packet *pkt) +update_policy(struct rte_power_channel_packet *pkt) { unsigned int updated = 0; @@ -512,7 +512,7 @@ update_policy(struct channel_packet *pkt) } static int -remove_policy(struct channel_packet *pkt __rte_unused) +remove_policy(struct rte_power_channel_packet *pkt __rte_unused) { unsigned int i; @@ -673,7 +673,7 @@ static void apply_policy(struct policy *pol) { - struct channel_packet *pkt = &pol->pkt; + struct rte_power_channel_packet *pkt = &pol->pkt; /*Check policy to use*/ if (pkt->policy_to_use == TRAFFIC) @@ -715,12 +715,12 @@ write_binary_packet(void *buffer, } static int -send_freq(struct channel_packet *pkt, +send_freq(struct rte_power_channel_packet *pkt, struct channel_info *chan_info, bool freq_list) { unsigned int vcore_id = pkt->resource_id; - struct channel_packet_freq_list channel_pkt_freq_list; + struct rte_power_channel_packet_freq_list channel_pkt_freq_list; struct vm_info info; if (get_info_vm(pkt->vm_name, &info) != 0) @@ -751,12 +751,12 @@ send_freq(struct channel_packet *pkt, } static int -send_capabilities(struct channel_packet *pkt, +send_capabilities(struct rte_power_channel_packet *pkt, struct channel_info *chan_info, bool list_requested) { unsigned int vcore_id = pkt->resource_id; - struct channel_packet_caps_list channel_pkt_caps_list; + struct rte_power_channel_packet_caps_list channel_pkt_caps_list; struct vm_info info; struct rte_power_core_capabilities caps; int ret; @@ -805,18 +805,19 @@ send_capabilities(struct channel_packet *pkt, } static int -send_ack_for_received_cmd(struct channel_packet *pkt, +send_ack_for_received_cmd(struct rte_power_channel_packet *pkt, struct channel_info *chan_info, uint32_t command) { pkt->command = command; return write_binary_packet(pkt, - sizeof(struct channel_packet), + sizeof(*pkt), chan_info); } static int -process_request(struct channel_packet *pkt, struct channel_info *chan_info) +process_request(struct rte_power_channel_packet *pkt, + struct channel_info *chan_info) { int ret; @@ -988,7 +989,7 @@ channel_monitor_init(void) static void read_binary_packet(struct channel_info *chan_info) { - struct channel_packet pkt; + struct rte_power_channel_packet pkt; void *buffer = &pkt; int buffer_len = sizeof(pkt); int n_bytes, err = 0; @@ -1019,7 +1020,7 @@ read_binary_packet(struct channel_info *chan_info) static void read_json_packet(struct channel_info *chan_info) { - struct channel_packet pkt; + struct rte_power_channel_packet pkt; int n_bytes, ret; json_t *root; json_error_t error; @@ -1063,7 +1064,7 @@ read_json_packet(struct channel_info *chan_info) /* * Because our data is now in the json * object, we can overwrite the pkt - * with a channel_packet struct, using + * with a rte_power_channel_packet struct, using * parse_json_to_pkt() */ ret = parse_json_to_pkt(root, &pkt, resource_name); diff --git a/examples/vm_power_manager/channel_monitor.h b/examples/vm_power_manager/channel_monitor.h index 4a526ff67..0ca6207ad 100644 --- a/examples/vm_power_manager/channel_monitor.h +++ b/examples/vm_power_manager/channel_monitor.h @@ -18,7 +18,7 @@ struct core_share { }; struct policy { - struct channel_packet pkt; + struct rte_power_channel_packet pkt; uint32_t pfid[MAX_VFS]; uint32_t port[MAX_VFS]; unsigned int enabled; diff --git a/examples/vm_power_manager/guest_cli/main.c b/examples/vm_power_manager/guest_cli/main.c index f63b3c988..fc7a8c30a 100644 --- a/examples/vm_power_manager/guest_cli/main.c +++ b/examples/vm_power_manager/guest_cli/main.c @@ -48,7 +48,7 @@ parse_args(int argc, char **argv) { "policy", required_argument, 0, 'o'}, {NULL, 0, 0, 0} }; - struct channel_packet *policy; + struct rte_power_channel_packet *policy; unsigned short int hours[MAX_HOURS]; unsigned short int cores[MAX_VCPU_PER_VM]; unsigned short int ports[MAX_VCPU_PER_VM]; 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 cf1636e78..125dfeb10 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 @@ -38,9 +38,9 @@ union PFID { uint64_t pfid; }; -static struct channel_packet policy; +static struct rte_power_channel_packet policy; -struct channel_packet * +struct rte_power_channel_packet * get_policy(void) { return &policy; @@ -49,7 +49,7 @@ get_policy(void) int set_policy_mac(int port, int idx) { - struct channel_packet *policy; + struct rte_power_channel_packet *policy; union PFID pfid; int ret; @@ -73,7 +73,7 @@ set_policy_mac(int port, int idx) } int -set_policy_defaults(struct channel_packet *pkt) +set_policy_defaults(struct rte_power_channel_packet *pkt) { int ret; @@ -145,7 +145,7 @@ struct cmd_freq_list_result { }; static int -query_data(struct channel_packet *pkt, unsigned int lcore_id) +query_data(struct rte_power_channel_packet *pkt, unsigned int lcore_id) { int ret; ret = rte_power_guest_channel_send_msg(pkt, lcore_id); @@ -157,13 +157,13 @@ query_data(struct channel_packet *pkt, unsigned int lcore_id) } static int -receive_freq_list(struct channel_packet_freq_list *pkt_freq_list, +receive_freq_list(struct rte_power_channel_packet_freq_list *pkt_freq_list, unsigned int lcore_id) { int ret; ret = rte_power_guest_channel_receive_msg(pkt_freq_list, - sizeof(struct channel_packet_freq_list), + sizeof(*pkt_freq_list), lcore_id); if (ret < 0) { RTE_LOG(ERR, GUEST_CLI, "Error receiving message.\n"); @@ -183,14 +183,14 @@ cmd_query_freq_list_parsed(void *parsed_result, { struct cmd_freq_list_result *res = parsed_result; unsigned int lcore_id; - struct channel_packet_freq_list pkt_freq_list; - struct channel_packet pkt; + struct rte_power_channel_packet_freq_list pkt_freq_list; + struct rte_power_channel_packet pkt; bool query_list = false; int ret; char *ep; - memset(&pkt, 0, sizeof(struct channel_packet)); - memset(&pkt_freq_list, 0, sizeof(struct channel_packet_freq_list)); + memset(&pkt, 0, sizeof(pkt)); + memset(&pkt_freq_list, 0, sizeof(pkt_freq_list)); if (!strcmp(res->cpu_num, "all")) { @@ -267,13 +267,13 @@ struct cmd_query_caps_result { }; static int -receive_capabilities(struct channel_packet_caps_list *pkt_caps_list, +receive_capabilities(struct rte_power_channel_packet_caps_list *pkt_caps_list, unsigned int lcore_id) { int ret; ret = rte_power_guest_channel_receive_msg(pkt_caps_list, - sizeof(struct channel_packet_caps_list), + sizeof(*pkt_caps_list), lcore_id); if (ret < 0) { RTE_LOG(ERR, GUEST_CLI, "Error receiving message.\n"); @@ -293,14 +293,14 @@ cmd_query_caps_list_parsed(void *parsed_result, { struct cmd_query_caps_result *res = parsed_result; unsigned int lcore_id; - struct channel_packet_caps_list pkt_caps_list; - struct channel_packet pkt; + struct rte_power_channel_packet_caps_list pkt_caps_list; + struct rte_power_channel_packet pkt; bool query_list = false; int ret; char *ep; - memset(&pkt, 0, sizeof(struct channel_packet)); - memset(&pkt_caps_list, 0, sizeof(struct channel_packet_caps_list)); + memset(&pkt, 0, sizeof(pkt)); + memset(&pkt_caps_list, 0, sizeof(pkt_caps_list)); if (!strcmp(res->cpu_num, "all")) { @@ -380,7 +380,7 @@ cmdline_parse_inst_t cmd_query_caps_list = { static int check_response_cmd(unsigned int lcore_id, int *result) { - struct channel_packet pkt; + struct rte_power_channel_packet pkt; int ret; ret = rte_power_guest_channel_receive_msg(&pkt, sizeof pkt, lcore_id); @@ -473,7 +473,7 @@ struct cmd_send_policy_result { }; static inline int -send_policy(struct channel_packet *pkt, struct cmdline *cl) +send_policy(struct rte_power_channel_packet *pkt, struct cmdline *cl) { int ret; diff --git a/examples/vm_power_manager/guest_cli/vm_power_cli_guest.h b/examples/vm_power_manager/guest_cli/vm_power_cli_guest.h index 2299d23dc..5d285ca9d 100644 --- a/examples/vm_power_manager/guest_cli/vm_power_cli_guest.h +++ b/examples/vm_power_manager/guest_cli/vm_power_cli_guest.h @@ -11,11 +11,11 @@ extern "C" { #include "rte_power_guest_channel.h" -struct channel_packet *get_policy(void); +struct rte_power_channel_packet *get_policy(void); int set_policy_mac(int port, int idx); -int set_policy_defaults(struct channel_packet *pkt); +int set_policy_defaults(struct rte_power_channel_packet *pkt); void run_cli(__rte_unused void *arg); diff --git a/lib/librte_power/guest_channel.c b/lib/librte_power/guest_channel.c index 4cb5ae1dd..9eb2f6330 100644 --- a/lib/librte_power/guest_channel.c +++ b/lib/librte_power/guest_channel.c @@ -55,7 +55,7 @@ int guest_channel_host_connect(const char *path, unsigned int lcore_id) { int flags, ret; - struct channel_packet pkt; + struct rte_power_channel_packet pkt; char fd_path[PATH_MAX]; int fd = -1; @@ -119,7 +119,8 @@ guest_channel_host_connect(const char *path, unsigned int lcore_id) } int -guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id) +guest_channel_send_msg(struct rte_power_channel_packet *pkt, + unsigned int lcore_id) { int ret, buffer_len = sizeof(*pkt); void *buffer = pkt; @@ -149,7 +150,7 @@ guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id) return 0; } -int rte_power_guest_channel_send_msg(struct channel_packet *pkt, +int rte_power_guest_channel_send_msg(struct rte_power_channel_packet *pkt, unsigned int lcore_id) { return guest_channel_send_msg(pkt, lcore_id); diff --git a/lib/librte_power/guest_channel.h b/lib/librte_power/guest_channel.h index 69020b030..7d3a909d9 100644 --- a/lib/librte_power/guest_channel.h +++ b/lib/librte_power/guest_channel.h @@ -63,7 +63,8 @@ void guest_channel_host_disconnect(unsigned int lcore_id); * - Negative on channel not connected. * - errno on write to channel error. */ -int guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id); +int guest_channel_send_msg(struct rte_power_channel_packet *pkt, + unsigned int lcore_id); @@ -72,8 +73,8 @@ int guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id); * from the host endpoint. * * @param pkt - * Pointer to channel_packet or - * channel_packet_freq_list struct. + * Pointer to rte_power_channel_packet or + * rte_power_channel_packet_freq_list struct. * * @param pkt_len * Size of expected data packet. diff --git a/lib/librte_power/power_kvm_vm.c b/lib/librte_power/power_kvm_vm.c index 649ebe85c..9ae438489 100644 --- a/lib/librte_power/power_kvm_vm.c +++ b/lib/librte_power/power_kvm_vm.c @@ -13,7 +13,7 @@ #define FD_PATH "/dev/virtio-ports/virtio.serial.port.poweragent" -static struct channel_packet pkt[RTE_MAX_LCORE]; +static struct rte_power_channel_packet pkt[RTE_MAX_LCORE]; int power_kvm_vm_check_supported(void) diff --git a/lib/librte_power/rte_power_guest_channel.h b/lib/librte_power/rte_power_guest_channel.h index c500c0cda..c9ab7bae8 100644 --- a/lib/librte_power/rte_power_guest_channel.h +++ b/lib/librte_power/rte_power_guest_channel.h @@ -11,7 +11,10 @@ extern "C" { #include #include -/* --- Incoming messages --- */ +#define MAX_VFS 10 +#define VM_MAX_NAME_SZ 32 +#define MAX_VCPU_PER_VM 8 +#define HOURS 24 /* Valid Commands */ #define CPU_POWER 1 @@ -19,6 +22,9 @@ extern "C" { #define PKT_POLICY 3 #define PKT_POLICY_REMOVE 4 +#define CORE_TYPE_VIRTUAL 0 +#define CORE_TYPE_PHYSICAL 1 + /* CPU Power Command Scaling */ #define CPU_POWER_SCALE_UP 1 #define CPU_POWER_SCALE_DOWN 2 @@ -43,41 +49,32 @@ extern "C" { #define CPU_POWER_FREQ_LIST 3 #define CPU_POWER_CAPS_LIST 4 -#define HOURS 24 - -#define MAX_VFS 10 -#define VM_MAX_NAME_SZ 32 - -#define MAX_VCPU_PER_VM 8 - -struct t_boost_status { - bool tbEnabled; -}; - -struct timer_profile { +struct rte_power_timer_profile { int busy_hours[HOURS]; int quiet_hours[HOURS]; int hours_to_use_traffic_profile[HOURS]; }; -enum workload {HIGH, MEDIUM, LOW}; -enum policy_to_use { +enum rte_power_workload_level {HIGH, MEDIUM, LOW}; + +enum rte_power_policy { TRAFFIC, TIME, WORKLOAD, BRANCH_RATIO }; -struct traffic { +struct rte_power_traffic_policy { uint32_t min_packet_thresh; uint32_t avg_max_packet_thresh; uint32_t max_max_packet_thresh; }; -#define CORE_TYPE_VIRTUAL 0 -#define CORE_TYPE_PHYSICAL 1 +struct rte_power_turbo_status { + bool tbEnabled; +}; -struct channel_packet { +struct rte_power_channel_packet { uint64_t resource_id; /**< core_num, device */ uint32_t unit; /**< scale down/up/min/max */ uint32_t command; /**< Power, IO, etc */ @@ -85,17 +82,17 @@ struct channel_packet { uint64_t vfid[MAX_VFS]; int nb_mac_to_monitor; - struct traffic traffic_policy; + struct rte_power_traffic_policy traffic_policy; uint8_t vcpu_to_control[MAX_VCPU_PER_VM]; uint8_t num_vcpu; - struct timer_profile timer_policy; + struct rte_power_timer_profile timer_policy; bool core_type; - enum workload workload; - enum policy_to_use policy_to_use; - struct t_boost_status t_boost_status; + enum rte_power_workload_level workload; + enum rte_power_policy policy_to_use; + struct rte_power_turbo_status t_boost_status; }; -struct channel_packet_freq_list { +struct rte_power_channel_packet_freq_list { uint64_t resource_id; /**< core_num, device */ uint32_t unit; /**< scale down/up/min/max */ uint32_t command; /**< Power, IO, etc */ @@ -105,7 +102,7 @@ struct channel_packet_freq_list { uint8_t num_vcpu; }; -struct channel_packet_caps_list { +struct rte_power_channel_packet_caps_list { uint64_t resource_id; /**< core_num, device */ uint32_t unit; /**< scale down/up/min/max */ uint32_t command; /**< Power, IO, etc */ @@ -135,7 +132,7 @@ struct channel_packet_caps_list { * - Negative on error. */ __rte_experimental -int rte_power_guest_channel_send_msg(struct channel_packet *pkt, +int rte_power_guest_channel_send_msg(struct rte_power_channel_packet *pkt, unsigned int lcore_id); /** diff --git a/lib/librte_power/version.map b/lib/librte_power/version.map index 69ca9af61..13f0af3b2 100644 --- a/lib/librte_power/version.map +++ b/lib/librte_power/version.map @@ -34,4 +34,8 @@ EXPERIMENTAL { rte_power_guest_channel_receive_msg; rte_power_poll_stat_fetch; rte_power_poll_stat_update; + + # added in 21.02 + rte_power_guest_channel_receive_msg; + rte_power_guest_channel_send_msg; }; -- 2.17.1