Skip to contentSkip to conversation

allow vm_power_manager to build using pkg-config

RFC PATCH New Bruce Richardson 1 participant 5 messages May 3, 2019 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover allow vm_power_manager to build using pkg-config

The vm_power_manager builds using meson as part of a DPDK build, but did not support building using make and the libdpdk.pc file. Unfortunately, adding this support was not as easy as for other examples, as the vm_power_manager example was depending on a non-public header file in the power library. Since this header is needed to write real applications, like the example, this patchset makes the header public.

A second, more minor, complication was that the build selected at compile-time which of two C files to include in the app using DPDK build-time variables. Since these vars are not available when building outside the DPDK build-system we need to change this to always compiling both files, and using macros to select the correct set of functions to use. [In this case, merging the files into one was also considered, and would work fine, it just wouldn't scale as well as keeping the files separate if solutions for other architectures were added later].

Bruce Richardson (4):
power: make channel commands header public
power: add namespace prefix to public header elements examples/vm_power_manager: always compile all C files examples/vm_power_manager: support build using pkg-config

 examples/vm_power_manager/Makefile            | 85 ++++++++++++++-----
 examples/vm_power_manager/channel_manager.c   |  2 +-
 examples/vm_power_manager/channel_monitor.c   | 73 ++++++++--------
 examples/vm_power_manager/channel_monitor.h   | 10 +--
 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 +-
 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 +
 examples/vm_power_manager/vm_power_cli.c      |  1 -
 lib/librte_power/Makefile                     |  4 +-
 lib/librte_power/channel_commands.h           | 85 -------------------
 lib/librte_power/guest_channel.c              |  8 +-
 lib/librte_power/guest_channel.h              |  6 +-
 lib/librte_power/meson.build                  |  4 +-
 lib/librte_power/power_kvm_vm.c               | 16 ++--
 lib/librte_power/rte_channel_commands.h       | 85 +++++++++++++++++++
 19 files changed, 235 insertions(+), 186 deletions(-)
 delete mode 100644 lib/librte_power/channel_commands.h
 create mode 100644 lib/librte_power/rte_channel_commands.h
Signature · 1 line
2.20.1
#1 lore raw

RFC PATCH 1/4 power: make channel commands header public

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.

---
 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%)
examples/vm_power_manager/Makefile +1 -1
index 2fdb991d7..d93f900f7 100644
@@ -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
examples/vm_power_manager/channel_manager.c +1 -1
index 084681747..755ac0425 100644
@@ -24,11 +24,11 @@
 #include <rte_log.h>
 #include <rte_atomic.h>
 #include <rte_spinlock.h>
+#include <rte_channel_commands.h>
 
 #include <libvirt/libvirt.h>
 
 #include "channel_manager.h"
-#include "channel_commands.h"
 #include "channel_monitor.h"
 #include "power_manager.h"
 
examples/vm_power_manager/channel_monitor.c +0 -1
index 4a287109b..9ae90c63f 100644
@@ -32,7 +32,6 @@
 
 #include <libvirt/libvirt.h>
 #include "channel_monitor.h"
-#include "channel_commands.h"
 #include "channel_manager.h"
 #include "power_manager.h"
 #include "oob_monitor.h"
examples/vm_power_manager/channel_monitor.h +1 -1
index 7362a80d2..a8bc9a4f1 100644
@@ -5,8 +5,8 @@
 #ifndef CHANNEL_MONITOR_H_
 #define CHANNEL_MONITOR_H_
 
+#include <rte_channel_commands.h>
 #include "channel_manager.h"
-#include "channel_commands.h"
 
 struct core_share {
 	unsigned int pcpu;
examples/vm_power_manager/vm_power_cli.c +0 -1
index 89b000d92..a67387cef 100644
@@ -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;
lib/librte_power/Makefile +3 -1
index ab771528f..f192cb334 100644
@@ -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
lib/librte_power/guest_channel.c +1 -1
index c17ea46b4..bb35fecec 100644
@@ -13,9 +13,9 @@
 
 
 #include <rte_log.h>
+#include <rte_channel_commands.h>
 
 #include "guest_channel.h"
-#include "channel_commands.h"
 
 #define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1
 
lib/librte_power/guest_channel.h +0 -2
index 373d39898..6219063d3 100644
@@ -8,8 +8,6 @@
 extern "C" {
 #endif
 
-#include <channel_commands.h>
-
 /**
  * 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
lib/librte_power/meson.build +3 -1
index cc6c30075..237f9d59c 100644
@@ -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']
lib/librte_power/power_kvm_vm.c +1 -1
index 277ebbeae..1c60551a4 100644
@@ -5,9 +5,9 @@
 #include <string.h>
 
 #include <rte_log.h>
+#include <rte_channel_commands.h>
 
 #include "guest_channel.h"
-#include "channel_commands.h"
 #include "power_kvm_vm.h"
 #include "power_common.h"
 
lib/librte_power/rte_channel_commands.h renamed from lib/librte_power/channel_commands.h +0 -0
similarity index 100%
rename from lib/librte_power/channel_commands.h
rename to lib/librte_power/rte_channel_commands.h
Signature · 1 line
2.20.1
#2 lore raw

RFC PATCH 2/4 power: add namespace prefix to public header elements

In reply to Bruce Richardson

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.

---
 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(-)
examples/vm_power_manager/channel_monitor.c +36 -36
index 9ae90c63f..0643e2d6c 100644
@@ -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;
examples/vm_power_manager/channel_monitor.h +4 -4
index a8bc9a4f1..1a8e8c212 100644
@@ -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
examples/vm_power_manager/guest_cli/main.c +1 -1
index 36365b124..4f748a759 100644
@@ -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];
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +5 -5
index 2d9e7689a..cb7f5ff02 100644
@@ -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;
 
examples/vm_power_manager/guest_cli/vm_power_cli_guest.h +2 -2
index fd77f6a69..d38d90690 100644
@@ -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);
 
examples/vm_power_manager/main.c +1 -1
index 5fa13fe62..fbe9d6299 100644
@@ -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;
lib/librte_power/guest_channel.c +3 -3
index bb35fecec..722f7dda4 100644
@@ -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);
lib/librte_power/guest_channel.h +2 -2
index 6219063d3..804743a76 100644
@@ -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
lib/librte_power/power_kvm_vm.c +7 -7
index 1c60551a4..259b68801 100644
@@ -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;
lib/librte_power/rte_channel_commands.h +33 -33

95 lines not on this page · raw message

Signature · 1 line
2.20.1
#3 lore raw

RFC PATCH 3/4 examples/vm_power_manager: always compile all C files

In reply to Bruce Richardson

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.

---
 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(-)
examples/vm_power_manager/Makefile +0 -3
index d93f900f7..6e573916a 100644
@@ -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)
examples/vm_power_manager/meson.build +8 -8
index f98445bc6..384c778ef 100644
@@ -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
examples/vm_power_manager/oob_monitor_nop.c +4 -0
index 7e7b8bc14..90daa7e9b 100644
@@ -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
examples/vm_power_manager/oob_monitor_x86.c +4 -0
index ebd96b205..f41bba6ab 100644
@@ -2,6 +2,8 @@
  * Copyright(c) 2018 Intel Corporation
  */
 
+#ifdef RTE_ARCH_X86_64 /* this file is only for X86_64 */
+
 #include <unistd.h>
 #include <fcntl.h>
 #include <rte_log.h>
@@ -269,3 +271,5 @@ run_branch_monitor(void)
 		}
 	}
 }
+
+#endif /* RTE_ARCH_X86_64 */
Signature · 1 line
2.20.1
#4 lore raw

RFC PATCH 4/4 examples/vm_power_manager: support build using pkg-config

In reply to Bruce Richardson

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.

---
 examples/vm_power_manager/Makefile | 80 +++++++++++++++++++++++-------
 1 file changed, 62 insertions(+), 18 deletions(-)
examples/vm_power_manager/Makefile +62 -18
index 6e573916a..d58669b0e 100644
@@ -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
Signature · 1 line
2.20.1