power: rename public structs
authorBruce Richardson <bruce.richardson@intel.com>
Thu, 21 Jan 2021 17:21:58 +0000 (17:21 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 29 Jan 2021 10:25:40 +0000 (11:25 +0100)
Rename the public structs to have an rte_power_ prefix.

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 <bruce.richardson@intel.com>
Signed-off-by: David Hunt <david.hunt@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
examples/vm_power_manager/channel_monitor.c
examples/vm_power_manager/channel_monitor.h
examples/vm_power_manager/guest_cli/main.c
examples/vm_power_manager/guest_cli/vm_power_cli_guest.c
examples/vm_power_manager/guest_cli/vm_power_cli_guest.h
lib/librte_power/guest_channel.c
lib/librte_power/guest_channel.h
lib/librte_power/power_kvm_vm.c
lib/librte_power/rte_power_guest_channel.h

index 0830610..1b6041b 100644 (file)
@@ -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);
index 4a526ff..0ca6207 100644 (file)
@@ -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;
index f63b3c9..fc7a8c3 100644 (file)
@@ -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];
index cf1636e..125dfeb 100644 (file)
@@ -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;
 
index 2299d23..5d285ca 100644 (file)
@@ -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);
 
index 4cb5ae1..9eb2f63 100644 (file)
@@ -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 @@ error:
 }
 
 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);
index 83186cf..a1db4b0 100644 (file)
@@ -63,15 +63,16 @@ 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);
 
 /**
  * Read a message contained in pkt over the Virtio-Serial
  * 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.
index 649ebe8..9ae4384 100644 (file)
@@ -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)
index c500c0c..c9ab7ba 100644 (file)
@@ -11,7 +11,10 @@ extern "C" {
 #include <stdint.h>
 #include <stdbool.h>
 
-/* --- 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);
 
 /**