1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2021 Intel Corporation
4 #ifndef RTE_POWER_GUEST_CHANNEL_H
5 #define RTE_POWER_GUEST_CHANNEL_H
15 #define VM_MAX_NAME_SZ 32
16 #define MAX_VCPU_PER_VM 8
21 #define CPU_POWER_CONNECT 2
23 #define PKT_POLICY_REMOVE 4
25 #define CORE_TYPE_VIRTUAL 0
26 #define CORE_TYPE_PHYSICAL 1
28 /* CPU Power Command Scaling */
29 #define CPU_POWER_SCALE_UP 1
30 #define CPU_POWER_SCALE_DOWN 2
31 #define CPU_POWER_SCALE_MAX 3
32 #define CPU_POWER_SCALE_MIN 4
33 #define CPU_POWER_ENABLE_TURBO 5
34 #define CPU_POWER_DISABLE_TURBO 6
36 /* CPU Power Queries */
37 #define CPU_POWER_QUERY_FREQ_LIST 7
38 #define CPU_POWER_QUERY_FREQ 8
39 #define CPU_POWER_QUERY_CAPS_LIST 9
40 #define CPU_POWER_QUERY_CAPS 10
42 /* --- Outgoing messages --- */
44 /* Generic Power Command Response */
45 #define CPU_POWER_CMD_ACK 1
46 #define CPU_POWER_CMD_NACK 2
48 /* CPU Power Query Responses */
49 #define CPU_POWER_FREQ_LIST 3
50 #define CPU_POWER_CAPS_LIST 4
52 struct rte_power_timer_profile {
53 int busy_hours[HOURS];
54 int quiet_hours[HOURS];
55 int hours_to_use_traffic_profile[HOURS];
58 enum rte_power_workload_level {HIGH, MEDIUM, LOW};
60 enum rte_power_policy {
67 struct rte_power_traffic_policy {
68 uint32_t min_packet_thresh;
69 uint32_t avg_max_packet_thresh;
70 uint32_t max_max_packet_thresh;
73 struct rte_power_turbo_status {
77 struct rte_power_channel_packet {
78 uint64_t resource_id; /**< core_num, device */
79 uint32_t unit; /**< scale down/up/min/max */
80 uint32_t command; /**< Power, IO, etc */
81 char vm_name[VM_MAX_NAME_SZ];
83 uint64_t vfid[MAX_VFS];
84 int nb_mac_to_monitor;
85 struct rte_power_traffic_policy traffic_policy;
86 uint8_t vcpu_to_control[MAX_VCPU_PER_VM];
88 struct rte_power_timer_profile timer_policy;
90 enum rte_power_workload_level workload;
91 enum rte_power_policy policy_to_use;
92 struct rte_power_turbo_status t_boost_status;
95 struct rte_power_channel_packet_freq_list {
96 uint64_t resource_id; /**< core_num, device */
97 uint32_t unit; /**< scale down/up/min/max */
98 uint32_t command; /**< Power, IO, etc */
99 char vm_name[VM_MAX_NAME_SZ];
101 uint32_t freq_list[MAX_VCPU_PER_VM];
105 struct rte_power_channel_packet_caps_list {
106 uint64_t resource_id; /**< core_num, device */
107 uint32_t unit; /**< scale down/up/min/max */
108 uint32_t command; /**< Power, IO, etc */
109 char vm_name[VM_MAX_NAME_SZ];
111 uint64_t turbo[MAX_VCPU_PER_VM];
112 uint64_t priority[MAX_VCPU_PER_VM];
120 * @b EXPERIMENTAL: this API may change without prior notice.
122 * Send a message contained in pkt over the Virtio-Serial to the host endpoint.
125 * Pointer to a populated struct channel_packet.
128 * Use channel specific to this lcore_id.
132 * - Negative on error.
135 int rte_power_guest_channel_send_msg(struct rte_power_channel_packet *pkt,
136 unsigned int lcore_id);
142 * @b EXPERIMENTAL: this API may change without prior notice.
144 * Receive a message contained in pkt over the Virtio-Serial
145 * from the host endpoint.
148 * Pointer to channel_packet or
149 * channel_packet_freq_list struct.
152 * Size of expected data packet.
155 * Use channel specific to this lcore_id.
159 * - Negative on error.
162 int rte_power_guest_channel_receive_msg(void *pkt,
164 unsigned int lcore_id);
171 #endif /* RTE_POWER_GUEST_CHANNEL_H_ */