From patchwork Fri May 3 14:08:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 53251 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 77E005B2A; Fri, 3 May 2019 16:09:13 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id AD9635B20 for ; Fri, 3 May 2019 16:09:11 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2019 07:09:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,426,1549958400"; d="scan'208";a="147884564" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.222.236]) by orsmga003.jf.intel.com with ESMTP; 03 May 2019 07:09:09 -0700 From: Bruce Richardson To: david.hunt@intel.com Cc: dev@dpdk.org, Bruce Richardson Date: Fri, 3 May 2019 15:08:58 +0100 Message-Id: <20190503140901.59064-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503140901.59064-1-bruce.richardson@intel.com> References: <20190503140901.59064-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC PATCH 1/4] power: make channel commands header public 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" The channel_commands.h header file is required by applications wanting to use the power management capabilities - as evidenced by the fact that the vm_power_manager example app needs to include it. Therefore we should make the header file public. Signed-off-by: Bruce Richardson --- examples/vm_power_manager/Makefile | 2 +- examples/vm_power_manager/channel_manager.c | 2 +- examples/vm_power_manager/channel_monitor.c | 1 - examples/vm_power_manager/channel_monitor.h | 2 +- examples/vm_power_manager/vm_power_cli.c | 1 - lib/librte_power/Makefile | 4 +++- lib/librte_power/guest_channel.c | 2 +- lib/librte_power/guest_channel.h | 2 -- lib/librte_power/meson.build | 4 +++- lib/librte_power/power_kvm_vm.c | 2 +- .../{channel_commands.h => rte_channel_commands.h} | 0 11 files changed, 11 insertions(+), 11 deletions(-) rename lib/librte_power/{channel_commands.h => rte_channel_commands.h} (100%) diff --git a/examples/vm_power_manager/Makefile b/examples/vm_power_manager/Makefile index 2fdb991d7..d93f900f7 100644 --- a/examples/vm_power_manager/Makefile +++ b/examples/vm_power_manager/Makefile @@ -26,7 +26,7 @@ else SRCS-y += oob_monitor_nop.c endif -CFLAGS += -O3 -I$(RTE_SDK)/lib/librte_power/ +CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) LDLIBS += -lvirt diff --git a/examples/vm_power_manager/channel_manager.c b/examples/vm_power_manager/channel_manager.c index 084681747..755ac0425 100644 --- a/examples/vm_power_manager/channel_manager.c +++ b/examples/vm_power_manager/channel_manager.c @@ -24,11 +24,11 @@ #include #include #include +#include #include #include "channel_manager.h" -#include "channel_commands.h" #include "channel_monitor.h" #include "power_manager.h" diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c index 4a287109b..9ae90c63f 100644 --- a/examples/vm_power_manager/channel_monitor.c +++ b/examples/vm_power_manager/channel_monitor.c @@ -32,7 +32,6 @@ #include #include "channel_monitor.h" -#include "channel_commands.h" #include "channel_manager.h" #include "power_manager.h" #include "oob_monitor.h" diff --git a/examples/vm_power_manager/channel_monitor.h b/examples/vm_power_manager/channel_monitor.h index 7362a80d2..a8bc9a4f1 100644 --- a/examples/vm_power_manager/channel_monitor.h +++ b/examples/vm_power_manager/channel_monitor.h @@ -5,8 +5,8 @@ #ifndef CHANNEL_MONITOR_H_ #define CHANNEL_MONITOR_H_ +#include #include "channel_manager.h" -#include "channel_commands.h" struct core_share { unsigned int pcpu; diff --git a/examples/vm_power_manager/vm_power_cli.c b/examples/vm_power_manager/vm_power_cli.c index 89b000d92..a67387cef 100644 --- a/examples/vm_power_manager/vm_power_cli.c +++ b/examples/vm_power_manager/vm_power_cli.c @@ -21,7 +21,6 @@ #include "channel_manager.h" #include "channel_monitor.h" #include "power_manager.h" -#include "channel_commands.h" struct cmd_quit_result { cmdline_fixed_string_t quit; diff --git a/lib/librte_power/Makefile b/lib/librte_power/Makefile index ab771528f..f192cb334 100644 --- a/lib/librte_power/Makefile +++ b/lib/librte_power/Makefile @@ -21,6 +21,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_POWER) += rte_power_empty_poll.c SRCS-$(CONFIG_RTE_LIBRTE_POWER) += power_pstate_cpufreq.c # install this header file -SYMLINK-$(CONFIG_RTE_LIBRTE_POWER)-include := rte_power.h rte_power_empty_poll.h +SYMLINK-$(CONFIG_RTE_LIBRTE_POWER)-include := rte_power.h +SYMLINK-$(CONFIG_RTE_LIBRTE_POWER)-include += rte_power_empty_poll.h +SYMLINK-$(CONFIG_RTE_LIBRTE_POWER)-include += rte_channel_commands.h include $(RTE_SDK)/mk/rte.lib.mk diff --git a/lib/librte_power/guest_channel.c b/lib/librte_power/guest_channel.c index c17ea46b4..bb35fecec 100644 --- a/lib/librte_power/guest_channel.c +++ b/lib/librte_power/guest_channel.c @@ -13,9 +13,9 @@ #include +#include #include "guest_channel.h" -#include "channel_commands.h" #define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1 diff --git a/lib/librte_power/guest_channel.h b/lib/librte_power/guest_channel.h index 373d39898..6219063d3 100644 --- a/lib/librte_power/guest_channel.h +++ b/lib/librte_power/guest_channel.h @@ -8,8 +8,6 @@ extern "C" { #endif -#include - /** * Connect to the Virtio-Serial VM end-point located in path. It is * thread safe for unique lcore_ids. This function must be only called once from diff --git a/lib/librte_power/meson.build b/lib/librte_power/meson.build index cc6c30075..237f9d59c 100644 --- a/lib/librte_power/meson.build +++ b/lib/librte_power/meson.build @@ -8,5 +8,7 @@ sources = files('rte_power.c', 'power_acpi_cpufreq.c', 'power_kvm_vm.c', 'guest_channel.c', 'rte_power_empty_poll.c', 'power_pstate_cpufreq.c') -headers = files('rte_power.h','rte_power_empty_poll.h') +headers = files('rte_power.h', + 'rte_power_empty_poll.h', + 'rte_channel_commands.h') deps += ['timer'] diff --git a/lib/librte_power/power_kvm_vm.c b/lib/librte_power/power_kvm_vm.c index 277ebbeae..1c60551a4 100644 --- a/lib/librte_power/power_kvm_vm.c +++ b/lib/librte_power/power_kvm_vm.c @@ -5,9 +5,9 @@ #include #include +#include #include "guest_channel.h" -#include "channel_commands.h" #include "power_kvm_vm.h" #include "power_common.h" diff --git a/lib/librte_power/channel_commands.h b/lib/librte_power/rte_channel_commands.h similarity index 100% rename from lib/librte_power/channel_commands.h rename to lib/librte_power/rte_channel_commands.h From patchwork Fri May 3 14:08:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 53252 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1B42A5F0D; Fri, 3 May 2019 16:09:15 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id D39D85B36 for ; Fri, 3 May 2019 16:09:13 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2019 07:09:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,426,1549958400"; d="scan'208";a="147884572" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.222.236]) by orsmga003.jf.intel.com with ESMTP; 03 May 2019 07:09:12 -0700 From: Bruce Richardson To: david.hunt@intel.com Cc: dev@dpdk.org, Bruce Richardson Date: Fri, 3 May 2019 15:08:59 +0100 Message-Id: <20190503140901.59064-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503140901.59064-1-bruce.richardson@intel.com> References: <20190503140901.59064-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC PATCH 2/4] power: add namespace prefix to public header elements 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" Now that the rte_channel_commands.h header file is public, we need to ensure that all structs and defines there start with an rte_ prefix - in many cases, with an rte_power prefix. Signed-off-by: Bruce Richardson --- examples/vm_power_manager/channel_monitor.c | 72 +++++++++---------- examples/vm_power_manager/channel_monitor.h | 8 +-- examples/vm_power_manager/guest_cli/main.c | 2 +- .../guest_cli/vm_power_cli_guest.c | 10 +-- .../guest_cli/vm_power_cli_guest.h | 4 +- examples/vm_power_manager/main.c | 2 +- lib/librte_power/guest_channel.c | 6 +- lib/librte_power/guest_channel.h | 4 +- lib/librte_power/power_kvm_vm.c | 14 ++-- lib/librte_power/rte_channel_commands.h | 66 ++++++++--------- 10 files changed, 94 insertions(+), 94 deletions(-) diff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c index 9ae90c63f..0643e2d6c 100644 --- a/examples/vm_power_manager/channel_monitor.c +++ b/examples/vm_power_manager/channel_monitor.c @@ -104,7 +104,7 @@ str_to_ether_addr(const char *a, struct ether_addr *ether_addr) } static int -set_policy_mac(struct channel_packet *pkt, int idx, char *mac) +set_policy_mac(struct rte_power_channel_pkt *pkt, int idx, char *mac) { union PFID pfid; int ret; @@ -131,20 +131,20 @@ set_policy_mac(struct channel_packet *pkt, int idx, char *mac) static int -parse_json_to_pkt(json_t *element, struct channel_packet *pkt) +parse_json_to_pkt(json_t *element, struct rte_power_channel_pkt *pkt) { const char *key; json_t *value; int ret; - memset(pkt, 0, sizeof(struct channel_packet)); + memset(pkt, 0, sizeof(struct rte_power_channel_pkt)); pkt->nb_mac_to_monitor = 0; pkt->t_boost_status.tbEnabled = false; pkt->workload = LOW; - pkt->policy_to_use = TIME; + pkt->policy_to_use = RTE_POWER_TIME; pkt->command = PKT_POLICY; - pkt->core_type = CORE_TYPE_PHYSICAL; + pkt->core_type = RTE_POWER_CORE_TYPE_PHYSICAL; json_object_foreach(element, key, value) { if (!strcmp(key, "policy")) { @@ -178,13 +178,13 @@ parse_json_to_pkt(json_t *element, struct channel_packet *pkt) char command[32]; strlcpy(command, json_string_value(value), 32); if (!strcmp(command, "TIME")) { - pkt->policy_to_use = TIME; + pkt->policy_to_use = RTE_POWER_TIME; } else if (!strcmp(command, "TRAFFIC")) { - pkt->policy_to_use = TRAFFIC; + pkt->policy_to_use = RTE_POWER_TRAFFIC; } else if (!strcmp(command, "WORKLOAD")) { - pkt->policy_to_use = WORKLOAD; + pkt->policy_to_use = RTE_POWER_WORKLOAD; } else if (!strcmp(command, "BRANCH_RATIO")) { - pkt->policy_to_use = BRANCH_RATIO; + pkt->policy_to_use = RTE_POWER_BRANCH_RATIO; } else { RTE_LOG(ERR, CHANNEL_MONITOR, "Wrong policy_type received in JSON\n"); @@ -254,17 +254,17 @@ parse_json_to_pkt(json_t *element, struct channel_packet *pkt) char unit[32]; strlcpy(unit, json_string_value(value), 32); if (!strcmp(unit, "SCALE_UP")) { - pkt->unit = CPU_POWER_SCALE_UP; + pkt->unit = RTE_POWER_CPU_SCALE_UP; } else if (!strcmp(unit, "SCALE_DOWN")) { - pkt->unit = CPU_POWER_SCALE_DOWN; + pkt->unit = RTE_POWER_CPU_SCALE_DOWN; } else if (!strcmp(unit, "SCALE_MAX")) { - pkt->unit = CPU_POWER_SCALE_MAX; + pkt->unit = RTE_POWER_CPU_SCALE_MAX; } else if (!strcmp(unit, "SCALE_MIN")) { - pkt->unit = CPU_POWER_SCALE_MIN; + pkt->unit = RTE_POWER_CPU_SCALE_MIN; } else if (!strcmp(unit, "ENABLE_TURBO")) { - pkt->unit = CPU_POWER_ENABLE_TURBO; + pkt->unit = RTE_POWER_CPU_ENABLE_TURBO; } else if (!strcmp(unit, "DISABLE_TURBO")) { - pkt->unit = CPU_POWER_DISABLE_TURBO; + pkt->unit = RTE_POWER_CPU_DISABLE_TURBO; } else { RTE_LOG(ERR, CHANNEL_MONITOR, "Invalid command received in JSON\n"); @@ -330,7 +330,7 @@ pcpu_monitor(struct policy *pol, struct core_info *ci, int pcpu, int count) { int ret = 0; - if (pol->pkt.policy_to_use == BRANCH_RATIO) { + if (pol->pkt.policy_to_use == RTE_POWER_BRANCH_RATIO) { ci->cd[pcpu].oob_enabled = 1; ret = add_core_to_monitor(pcpu); if (ret == 0) @@ -370,7 +370,7 @@ get_pcpu_to_control(struct policy *pol) * differenciate between them when adding them to the branch monitor. * Virtual cores need to be converted to physical cores. */ - if (pol->pkt.core_type == CORE_TYPE_VIRTUAL) { + if (pol->pkt.core_type == RTE_POWER_CORE_TYPE_VIRTUAL) { /* * If the cores in the policy are virtual, we need to map them * to physical core. We look up the vm info and use that for @@ -422,7 +422,7 @@ get_pfid(struct policy *pol) } static int -update_policy(struct channel_packet *pkt) +update_policy(struct rte_power_channel_pkt *pkt) { unsigned int updated = 0; @@ -438,7 +438,7 @@ update_policy(struct channel_packet *pkt) policies[i].pkt = *pkt; get_pcpu_to_control(&policies[i]); /* Check Eth dev only for Traffic policy */ - if (policies[i].pkt.policy_to_use == TRAFFIC) { + if (policies[i].pkt.policy_to_use == RTE_POWER_TRAFFIC) { if (get_pfid(&policies[i]) < 0) { updated = 1; break; @@ -455,7 +455,7 @@ update_policy(struct channel_packet *pkt) policies[i].pkt = *pkt; get_pcpu_to_control(&policies[i]); /* Check Eth dev only for Traffic policy */ - if (policies[i].pkt.policy_to_use == TRAFFIC) { + if (policies[i].pkt.policy_to_use == RTE_POWER_TRAFFIC) { if (get_pfid(&policies[i]) < 0) { updated = 1; break; @@ -471,7 +471,7 @@ update_policy(struct channel_packet *pkt) } static int -remove_policy(struct channel_packet *pkt __rte_unused) +remove_policy(struct rte_power_channel_pkt *pkt __rte_unused) { int i; @@ -568,7 +568,7 @@ apply_time_profile(struct policy *pol) /* Format the date and time, down to a single second. */ strftime(time_string, sizeof(time_string), "%Y-%m-%d %H:%M:%S", ptm); - for (x = 0; x < HOURS; x++) { + for (x = 0; x < RTE_HOURS_PER_DAY; x++) { if (ptm->tm_hour == pol->pkt.timer_policy.busy_hours[x]) { for (count = 0; count < pol->pkt.num_vcpu; count++) { @@ -626,19 +626,19 @@ static void apply_policy(struct policy *pol) { - struct channel_packet *pkt = &pol->pkt; + struct rte_power_channel_pkt *pkt = &pol->pkt; /*Check policy to use*/ - if (pkt->policy_to_use == TRAFFIC) + if (pkt->policy_to_use == RTE_POWER_TRAFFIC) apply_traffic_profile(pol); - else if (pkt->policy_to_use == TIME) + else if (pkt->policy_to_use == RTE_POWER_TIME) apply_time_profile(pol); - else if (pkt->policy_to_use == WORKLOAD) + else if (pkt->policy_to_use == RTE_POWER_WORKLOAD) apply_workload_profile(pol); } static int -process_request(struct channel_packet *pkt, struct channel_info *chan_info) +process_request(struct rte_power_channel_pkt *pkt, struct channel_info *chan_info) { int ret; @@ -652,7 +652,7 @@ process_request(struct channel_packet *pkt, struct channel_info *chan_info) if (pkt->command == CPU_POWER) { unsigned int core_num; - if (pkt->core_type == CORE_TYPE_VIRTUAL) + if (pkt->core_type == RTE_POWER_CORE_TYPE_VIRTUAL) core_num = get_pcpu(chan_info, pkt->resource_id); else core_num = pkt->resource_id; @@ -661,22 +661,22 @@ process_request(struct channel_packet *pkt, struct channel_info *chan_info) core_num); switch (pkt->unit) { - case(CPU_POWER_SCALE_MIN): + case(RTE_POWER_CPU_SCALE_MIN): power_manager_scale_core_min(core_num); break; - case(CPU_POWER_SCALE_MAX): + case(RTE_POWER_CPU_SCALE_MAX): power_manager_scale_core_max(core_num); break; - case(CPU_POWER_SCALE_DOWN): + case(RTE_POWER_CPU_SCALE_DOWN): power_manager_scale_core_down(core_num); break; - case(CPU_POWER_SCALE_UP): + case(RTE_POWER_CPU_SCALE_UP): power_manager_scale_core_up(core_num); break; - case(CPU_POWER_ENABLE_TURBO): + case(RTE_POWER_CPU_ENABLE_TURBO): power_manager_enable_turbo_core(core_num); break; - case(CPU_POWER_DISABLE_TURBO): + case(RTE_POWER_CPU_DISABLE_TURBO): power_manager_disable_turbo_core(core_num); break; default: @@ -765,7 +765,7 @@ channel_monitor_init(void) static void read_binary_packet(struct channel_info *chan_info) { - struct channel_packet pkt; + struct rte_power_channel_pkt pkt; void *buffer = &pkt; int buffer_len = sizeof(pkt); int n_bytes, err = 0; @@ -796,7 +796,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_pkt pkt; int n_bytes, ret; json_t *root; json_error_t error; diff --git a/examples/vm_power_manager/channel_monitor.h b/examples/vm_power_manager/channel_monitor.h index a8bc9a4f1..1a8e8c212 100644 --- a/examples/vm_power_manager/channel_monitor.h +++ b/examples/vm_power_manager/channel_monitor.h @@ -18,11 +18,11 @@ struct core_share { }; struct policy { - struct channel_packet pkt; - uint32_t pfid[MAX_VFS]; - uint32_t port[MAX_VFS]; + struct rte_power_channel_pkt pkt; + uint32_t pfid[RTE_POWER_MAX_VFS]; + uint32_t port[RTE_POWER_MAX_VFS]; unsigned int enabled; - struct core_share core_share[MAX_VCPU_PER_VM]; + struct core_share core_share[RTE_POWER_MAX_VCPU_PER_VM]; }; #ifdef __cplusplus diff --git a/examples/vm_power_manager/guest_cli/main.c b/examples/vm_power_manager/guest_cli/main.c index 36365b124..4f748a759 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_pkt *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 2d9e7689a..cb7f5ff02 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_pkt policy; -struct channel_packet * +struct rte_power_channel_pkt * 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_pkt *policy; union PFID pfid; /* Use port MAC address as the vfid */ @@ -67,7 +67,7 @@ set_policy_mac(int port, int idx) } void -set_policy_defaults(struct channel_packet *pkt) +set_policy_defaults(struct rte_power_channel_pkt *pkt) { set_policy_mac(0, 0); pkt->nb_mac_to_monitor = 1; @@ -185,7 +185,7 @@ struct cmd_send_policy_result { }; static inline int -send_policy(struct channel_packet *pkt) +send_policy(struct rte_power_channel_pkt *pkt) { 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 fd77f6a69..d38d90690 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 "channel_commands.h" -struct channel_packet *get_policy(void); +struct rte_power_channel_pkt *get_policy(void); int set_policy_mac(int port, int idx); -void set_policy_defaults(struct channel_packet *pkt); +void set_policy_defaults(struct rte_power_channel_pkt *pkt); void run_cli(__attribute__((unused)) void *arg); diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c index 5fa13fe62..fbe9d6299 100644 --- a/examples/vm_power_manager/main.c +++ b/examples/vm_power_manager/main.c @@ -373,7 +373,7 @@ main(int argc, char **argv) "Cannot init port %"PRIu8 "\n", portid); - for (w = 0; w < MAX_VFS; w++) { + for (w = 0; w < RTE_POWER_MAX_VFS; w++) { eth.addr_bytes[5] = w + 0xf0; ret = -ENOTSUP; diff --git a/lib/librte_power/guest_channel.c b/lib/librte_power/guest_channel.c index bb35fecec..722f7dda4 100644 --- a/lib/librte_power/guest_channel.c +++ b/lib/librte_power/guest_channel.c @@ -25,7 +25,7 @@ int guest_channel_host_connect(const char *path, unsigned int lcore_id) { int flags, ret; - struct channel_packet pkt; + struct rte_power_channel_pkt pkt; char fd_path[PATH_MAX]; int fd = -1; @@ -89,7 +89,7 @@ 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_pkt *pkt, unsigned int lcore_id) { int ret, buffer_len = sizeof(*pkt); void *buffer = pkt; @@ -119,7 +119,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_pkt *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 6219063d3..804743a76 100644 --- a/lib/librte_power/guest_channel.h +++ b/lib/librte_power/guest_channel.h @@ -48,7 +48,7 @@ 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_pkt *pkt, unsigned int lcore_id); /** * Send a message contained in pkt over the Virtio-Serial to the host endpoint. @@ -63,7 +63,7 @@ int guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id); * - 0 on success. * - Negative on error. */ -int rte_power_guest_channel_send_msg(struct channel_packet *pkt, +int rte_power_guest_channel_send_msg(struct rte_power_channel_pkt *pkt, unsigned int lcore_id); #ifdef __cplusplus diff --git a/lib/librte_power/power_kvm_vm.c b/lib/librte_power/power_kvm_vm.c index 1c60551a4..259b68801 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_pkt pkt[RTE_MAX_LCORE]; int @@ -85,25 +85,25 @@ send_msg(unsigned int lcore_id, uint32_t scale_direction) int power_kvm_vm_freq_up(unsigned int lcore_id) { - return send_msg(lcore_id, CPU_POWER_SCALE_UP); + return send_msg(lcore_id, RTE_POWER_CPU_SCALE_UP); } int power_kvm_vm_freq_down(unsigned int lcore_id) { - return send_msg(lcore_id, CPU_POWER_SCALE_DOWN); + return send_msg(lcore_id, RTE_POWER_CPU_SCALE_DOWN); } int power_kvm_vm_freq_max(unsigned int lcore_id) { - return send_msg(lcore_id, CPU_POWER_SCALE_MAX); + return send_msg(lcore_id, RTE_POWER_CPU_SCALE_MAX); } int power_kvm_vm_freq_min(unsigned int lcore_id) { - return send_msg(lcore_id, CPU_POWER_SCALE_MIN); + return send_msg(lcore_id, RTE_POWER_CPU_SCALE_MIN); } int @@ -116,13 +116,13 @@ power_kvm_vm_turbo_status(__attribute__((unused)) unsigned int lcore_id) int power_kvm_vm_enable_turbo(unsigned int lcore_id) { - return send_msg(lcore_id, CPU_POWER_ENABLE_TURBO); + return send_msg(lcore_id, RTE_POWER_CPU_ENABLE_TURBO); } int power_kvm_vm_disable_turbo(unsigned int lcore_id) { - return send_msg(lcore_id, CPU_POWER_DISABLE_TURBO); + return send_msg(lcore_id, RTE_POWER_CPU_DISABLE_TURBO); } struct rte_power_core_capabilities; diff --git a/lib/librte_power/rte_channel_commands.h b/lib/librte_power/rte_channel_commands.h index eca8ff70c..d4681ef19 100644 --- a/lib/librte_power/rte_channel_commands.h +++ b/lib/librte_power/rte_channel_commands.h @@ -19,62 +19,62 @@ extern "C" { #define PKT_POLICY_REMOVE 4 /* CPU Power Command Scaling */ -#define CPU_POWER_SCALE_UP 1 -#define CPU_POWER_SCALE_DOWN 2 -#define CPU_POWER_SCALE_MAX 3 -#define CPU_POWER_SCALE_MIN 4 -#define CPU_POWER_ENABLE_TURBO 5 -#define CPU_POWER_DISABLE_TURBO 6 -#define HOURS 24 +#define RTE_POWER_CPU_SCALE_UP 1 +#define RTE_POWER_CPU_SCALE_DOWN 2 +#define RTE_POWER_CPU_SCALE_MAX 3 +#define RTE_POWER_CPU_SCALE_MIN 4 +#define RTE_POWER_CPU_ENABLE_TURBO 5 +#define RTE_POWER_CPU_DISABLE_TURBO 6 +#define RTE_HOURS_PER_DAY 24 -#define MAX_VFS 10 -#define VM_MAX_NAME_SZ 32 +#define RTE_POWER_MAX_VFS 10 +#define RTE_POWER_VM_MAX_NAME_SZ 32 -#define MAX_VCPU_PER_VM 8 +#define RTE_POWER_MAX_VCPU_PER_VM 8 -struct t_boost_status { +struct rte_power_t_boost_status { bool tbEnabled; }; -struct timer_profile { - int busy_hours[HOURS]; - int quiet_hours[HOURS]; - int hours_to_use_traffic_profile[HOURS]; +struct rte_power_timer_profile { + int busy_hours[RTE_HOURS_PER_DAY]; + int quiet_hours[RTE_HOURS_PER_DAY]; + int hours_to_use_traffic_profile[RTE_HOURS_PER_DAY]; }; -enum workload {HIGH, MEDIUM, LOW}; -enum policy_to_use { - TRAFFIC, - TIME, - WORKLOAD, - BRANCH_RATIO +enum rte_power_workload {HIGH, MEDIUM, LOW}; +enum rte_power_policy_to_use { + RTE_POWER_TRAFFIC, + RTE_POWER_TIME, + RTE_POWER_WORKLOAD, + RTE_POWER_BRANCH_RATIO }; -struct traffic { +struct rte_power_channel_traffic { 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 +#define RTE_POWER_CORE_TYPE_VIRTUAL 0 +#define RTE_POWER_CORE_TYPE_PHYSICAL 1 -struct channel_packet { +struct rte_power_channel_pkt { uint64_t resource_id; /**< core_num, device */ uint32_t unit; /**< scale down/up/min/max */ uint32_t command; /**< Power, IO, etc */ - char vm_name[VM_MAX_NAME_SZ]; + char vm_name[RTE_POWER_VM_MAX_NAME_SZ]; - uint64_t vfid[MAX_VFS]; + uint64_t vfid[RTE_POWER_MAX_VFS]; int nb_mac_to_monitor; - struct traffic traffic_policy; - uint8_t vcpu_to_control[MAX_VCPU_PER_VM]; + struct rte_power_channel_traffic traffic_policy; + uint8_t vcpu_to_control[RTE_POWER_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 workload; + enum rte_power_policy_to_use policy_to_use; + struct rte_power_t_boost_status t_boost_status; }; From patchwork Fri May 3 14:09:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 53253 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 820125F20; Fri, 3 May 2019 16:09:17 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 9748D5F14 for ; Fri, 3 May 2019 16:09:15 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2019 07:09:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,426,1549958400"; d="scan'208";a="147884579" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.222.236]) by orsmga003.jf.intel.com with ESMTP; 03 May 2019 07:09:14 -0700 From: Bruce Richardson To: david.hunt@intel.com Cc: dev@dpdk.org, Bruce Richardson Date: Fri, 3 May 2019 15:09:00 +0100 Message-Id: <20190503140901.59064-4-bruce.richardson@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503140901.59064-1-bruce.richardson@intel.com> References: <20190503140901.59064-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC PATCH 3/4] examples/vm_power_manager: always compile all C files 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" Rather than having an "if" statement in the makefile to select one of two files to build, we can put #ifdefs into the C files themselves so that all files are always built. This is a better approach as the makefile-based approach relies on having the DPDK build system with all it's config settings available. When building using info from a pkg-config file, this build configuration information is not going to be available to the makefile - though it will be available to the preprocessor through rte_config.h header. Signed-off-by: Bruce Richardson --- examples/vm_power_manager/Makefile | 3 --- examples/vm_power_manager/meson.build | 16 ++++++++-------- examples/vm_power_manager/oob_monitor_nop.c | 4 ++++ examples/vm_power_manager/oob_monitor_x86.c | 4 ++++ 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/examples/vm_power_manager/Makefile b/examples/vm_power_manager/Makefile index d93f900f7..6e573916a 100644 --- a/examples/vm_power_manager/Makefile +++ b/examples/vm_power_manager/Makefile @@ -20,11 +20,8 @@ APP = vm_power_mgr # all source are stored in SRCS-y SRCS-y := main.c vm_power_cli.c power_manager.c channel_manager.c SRCS-y += channel_monitor.c parse.c -ifeq ($(CONFIG_RTE_ARCH_X86_64),y) SRCS-y += oob_monitor_x86.c -else SRCS-y += oob_monitor_nop.c -endif CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) diff --git a/examples/vm_power_manager/meson.build b/examples/vm_power_manager/meson.build index f98445bc6..384c778ef 100644 --- a/examples/vm_power_manager/meson.build +++ b/examples/vm_power_manager/meson.build @@ -22,16 +22,16 @@ deps += ['power'] sources = files( - 'channel_manager.c', 'channel_monitor.c', 'main.c', 'parse.c', 'power_manager.c', 'vm_power_cli.c' + 'channel_manager.c', + 'channel_monitor.c', + 'main.c', + 'oob_monitor_nop.c', + 'oob_monitor_x86.c', + 'parse.c', + 'power_manager.c', + 'vm_power_cli.c' ) -# If we're on X86, pull in the x86 code for the branch monitor algo. -if dpdk_conf.has('RTE_ARCH_X86_64') - sources += files('oob_monitor_x86.c') -else - sources += files('oob_monitor_nop.c') -endif - opt_dep = cc.find_library('virt', required : false) build = opt_dep.found() ext_deps += opt_dep diff --git a/examples/vm_power_manager/oob_monitor_nop.c b/examples/vm_power_manager/oob_monitor_nop.c index 7e7b8bc14..90daa7e9b 100644 --- a/examples/vm_power_manager/oob_monitor_nop.c +++ b/examples/vm_power_manager/oob_monitor_nop.c @@ -2,6 +2,8 @@ * Copyright(c) 2010-2014 Intel Corporation */ +#ifndef RTE_ARCH_X86_64 /* X86_64 has separate implementation in another file */ + #include "oob_monitor.h" void branch_monitor_exit(void) @@ -36,3 +38,5 @@ void run_branch_monitor(void) { } + +#endif diff --git a/examples/vm_power_manager/oob_monitor_x86.c b/examples/vm_power_manager/oob_monitor_x86.c index ebd96b205..f41bba6ab 100644 --- a/examples/vm_power_manager/oob_monitor_x86.c +++ b/examples/vm_power_manager/oob_monitor_x86.c @@ -2,6 +2,8 @@ * Copyright(c) 2018 Intel Corporation */ +#ifdef RTE_ARCH_X86_64 /* this file is only for X86_64 */ + #include #include #include @@ -269,3 +271,5 @@ run_branch_monitor(void) } } } + +#endif /* RTE_ARCH_X86_64 */ From patchwork Fri May 3 14:09:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 53254 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 503FE5F28; Fri, 3 May 2019 16:09:19 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 046145F24 for ; Fri, 3 May 2019 16:09:17 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2019 07:09:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,426,1549958400"; d="scan'208";a="147884590" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.222.236]) by orsmga003.jf.intel.com with ESMTP; 03 May 2019 07:09:16 -0700 From: Bruce Richardson To: david.hunt@intel.com Cc: dev@dpdk.org, Bruce Richardson Date: Fri, 3 May 2019 15:09:01 +0100 Message-Id: <20190503140901.59064-5-bruce.richardson@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503140901.59064-1-bruce.richardson@intel.com> References: <20190503140901.59064-1-bruce.richardson@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC PATCH 4/4] examples/vm_power_manager: support build using pkg-config 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" The vm_power_manager example app did not check for a libdpdk pkg-config file and attempt to build using that. Add support for that method of compile to align the app with the other examples. Signed-off-by: Bruce Richardson --- examples/vm_power_manager/Makefile | 80 +++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 18 deletions(-) diff --git a/examples/vm_power_manager/Makefile b/examples/vm_power_manager/Makefile index 6e573916a..d58669b0e 100644 --- a/examples/vm_power_manager/Makefile +++ b/examples/vm_power_manager/Makefile @@ -1,8 +1,69 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2010-2014 Intel Corporation +# binary name +APP = vm_power_mgr + +# all source are stored in SRCS-y +SRCS-y := \ + channel_manager.c \ + channel_monitor.c \ + main.c \ + oob_monitor_nop.c \ + oob_monitor_x86.c \ + parse.c \ + power_manager.c \ + vm_power_cli.c \ + ifneq ($(shell pkg-config --atleast-version=0.9.3 libvirt; echo $$?), 0) $(error vm_power_manager requires libvirt >= 0.9.3) +endif +LDLIBS += -lvirt + +ifeq ($(shell pkg-config --exists jansson; echo $$?), 0) +LDLIBS += $(shell pkg-config --libs jansson) +CFLAGS += -DUSE_JANSSON +endif + + +# Build using pkg-config variables if possible +$(shell pkg-config --exists libdpdk) +ifeq ($(.SHELLSTATUS),0) + +all: shared +.PHONY: shared static +shared: build/$(APP)-shared + ln -sf $(APP)-shared build/$(APP) +static: build/$(APP)-static + ln -sf $(APP)-static build/$(APP) + +PKGCONF=pkg-config +ifneq ($(DPDK_PC_PREFIX),) + PKGCONF += --define-variable=prefix=$(DPDK_PC_PREFIX) +endif + +LDFLAGS += $(LDLIBS) -lrte_pmd_i40e -lrte_pmd_bnxt -lrte_pmd_ixgbe \ + -lrte_bus_pci -lrte_bus_vdev + +PC_FILE := $(shell $(PKGCONF) --path libdpdk) +CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) +LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) +LDFLAGS_STATIC = -Wl,-Bstatic $(shell $(PKGCONF) --static --libs libdpdk) + +build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build + $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) + +build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build + $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) + +build: + @mkdir -p $@ + +.PHONY: clean +clean: + rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared + rmdir --ignore-fail-on-non-empty build + else ifeq ($(RTE_SDK),) @@ -14,26 +75,9 @@ RTE_TARGET ?= $(notdir $(abspath $(dir $(firstword $(wildcard $(RTE_SDK)/*/.conf include $(RTE_SDK)/mk/rte.vars.mk -# binary name -APP = vm_power_mgr - -# all source are stored in SRCS-y -SRCS-y := main.c vm_power_cli.c power_manager.c channel_manager.c -SRCS-y += channel_monitor.c parse.c -SRCS-y += oob_monitor_x86.c -SRCS-y += oob_monitor_nop.c - CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) -LDLIBS += -lvirt - -JANSSON := $(shell pkg-config --exists jansson; echo $$?) -ifeq ($(JANSSON), 0) -LDLIBS += $(shell pkg-config --libs jansson) -CFLAGS += -DUSE_JANSSON -endif - ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y) ifeq ($(CONFIG_RTE_LIBRTE_IXGBE_PMD),y) @@ -58,4 +102,4 @@ endif include $(RTE_SDK)/mk/rte.extapp.mk -endif # libvirt check +endif # pkg-config check