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
11 #define RTE_POWER_MAX_VFS 10
12 #define RTE_POWER_VM_MAX_NAME_SZ 32
13 #define RTE_POWER_MAX_VCPU_PER_VM 8
14 #define RTE_POWER_HOURS_PER_DAY 24
17 #define RTE_POWER_CPU_POWER 1
18 #define RTE_POWER_CPU_POWER_CONNECT 2
19 #define RTE_POWER_PKT_POLICY 3
20 #define RTE_POWER_PKT_POLICY_REMOVE 4
22 #define RTE_POWER_CORE_TYPE_VIRTUAL 0
23 #define RTE_POWER_CORE_TYPE_PHYSICAL 1
25 /* CPU Power Command Scaling */
26 #define RTE_POWER_SCALE_UP 1
27 #define RTE_POWER_SCALE_DOWN 2
28 #define RTE_POWER_SCALE_MAX 3
29 #define RTE_POWER_SCALE_MIN 4
30 #define RTE_POWER_ENABLE_TURBO 5
31 #define RTE_POWER_DISABLE_TURBO 6
33 /* CPU Power Queries */
34 #define RTE_POWER_QUERY_FREQ_LIST 7
35 #define RTE_POWER_QUERY_FREQ 8
36 #define RTE_POWER_QUERY_CAPS_LIST 9
37 #define RTE_POWER_QUERY_CAPS 10
39 /* Generic Power Command Response */
40 #define RTE_POWER_CMD_ACK 1
41 #define RTE_POWER_CMD_NACK 2
43 /* CPU Power Query Responses */
44 #define RTE_POWER_FREQ_LIST 3
45 #define RTE_POWER_CAPS_LIST 4
47 struct rte_power_traffic_policy {
48 uint32_t min_packet_thresh;
49 uint32_t avg_max_packet_thresh;
50 uint32_t max_max_packet_thresh;
53 struct rte_power_timer_profile {
54 int busy_hours[RTE_POWER_HOURS_PER_DAY];
55 int quiet_hours[RTE_POWER_HOURS_PER_DAY];
56 int hours_to_use_traffic_profile[RTE_POWER_HOURS_PER_DAY];
59 enum rte_power_workload_level {
65 enum rte_power_policy {
66 RTE_POWER_POLICY_TRAFFIC,
67 RTE_POWER_POLICY_TIME,
68 RTE_POWER_POLICY_WORKLOAD,
69 RTE_POWER_POLICY_BRANCH_RATIO
72 struct rte_power_turbo_status {
76 struct rte_power_channel_packet {
77 uint64_t resource_id; /**< core_num, device */
78 uint32_t unit; /**< scale down/up/min/max */
79 uint32_t command; /**< Power, IO, etc */
80 char vm_name[RTE_POWER_VM_MAX_NAME_SZ];
82 uint64_t vfid[RTE_POWER_MAX_VFS];
83 int nb_mac_to_monitor;
84 struct rte_power_traffic_policy traffic_policy;
85 uint8_t vcpu_to_control[RTE_POWER_MAX_VCPU_PER_VM];
87 struct rte_power_timer_profile timer_policy;
89 enum rte_power_workload_level workload;
90 enum rte_power_policy policy_to_use;
91 struct rte_power_turbo_status t_boost_status;
94 struct rte_power_channel_packet_freq_list {
95 uint64_t resource_id; /**< core_num, device */
96 uint32_t unit; /**< scale down/up/min/max */
97 uint32_t command; /**< Power, IO, etc */
98 char vm_name[RTE_POWER_VM_MAX_NAME_SZ];
100 uint32_t freq_list[RTE_POWER_MAX_VCPU_PER_VM];
104 struct rte_power_channel_packet_caps_list {
105 uint64_t resource_id; /**< core_num, device */
106 uint32_t unit; /**< scale down/up/min/max */
107 uint32_t command; /**< Power, IO, etc */
108 char vm_name[RTE_POWER_VM_MAX_NAME_SZ];
110 uint64_t turbo[RTE_POWER_MAX_VCPU_PER_VM];
111 uint64_t priority[RTE_POWER_MAX_VCPU_PER_VM];
119 * @b EXPERIMENTAL: this API may change without prior notice.
121 * Send a message contained in pkt over the Virtio-Serial to the host endpoint.
124 * Pointer to a populated struct channel_packet.
127 * Use channel specific to this lcore_id.
131 * - Negative on error.
134 int rte_power_guest_channel_send_msg(struct rte_power_channel_packet *pkt,
135 unsigned int lcore_id);
141 * @b EXPERIMENTAL: this API may change without prior notice.
143 * Receive a message contained in pkt over the Virtio-Serial
144 * from the host endpoint.
147 * Pointer to channel_packet or
148 * channel_packet_freq_list struct.
151 * Size of expected data packet.
154 * Use channel specific to this lcore_id.
158 * - Negative on error.
161 int rte_power_guest_channel_receive_msg(void *pkt,
163 unsigned int lcore_id);
170 #endif /* RTE_POWER_GUEST_CHANNEL_H_ */