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
14 #define RTE_POWER_MAX_VFS 10
15 #define RTE_POWER_VM_MAX_NAME_SZ 32
16 #define RTE_POWER_MAX_VCPU_PER_VM 8
17 #define RTE_POWER_HOURS_PER_DAY 24
20 #define RTE_POWER_CPU_POWER 1
21 #define RTE_POWER_CPU_POWER_CONNECT 2
22 #define RTE_POWER_PKT_POLICY 3
23 #define RTE_POWER_PKT_POLICY_REMOVE 4
25 #define RTE_POWER_CORE_TYPE_VIRTUAL 0
26 #define RTE_POWER_CORE_TYPE_PHYSICAL 1
28 /* CPU Power Command Scaling */
29 #define RTE_POWER_SCALE_UP 1
30 #define RTE_POWER_SCALE_DOWN 2
31 #define RTE_POWER_SCALE_MAX 3
32 #define RTE_POWER_SCALE_MIN 4
33 #define RTE_POWER_ENABLE_TURBO 5
34 #define RTE_POWER_DISABLE_TURBO 6
36 /* CPU Power Queries */
37 #define RTE_POWER_QUERY_FREQ_LIST 7
38 #define RTE_POWER_QUERY_FREQ 8
39 #define RTE_POWER_QUERY_CAPS_LIST 9
40 #define RTE_POWER_QUERY_CAPS 10
42 /* Generic Power Command Response */
43 #define RTE_POWER_CMD_ACK 1
44 #define RTE_POWER_CMD_NACK 2
46 /* CPU Power Query Responses */
47 #define RTE_POWER_FREQ_LIST 3
48 #define RTE_POWER_CAPS_LIST 4
50 struct rte_power_traffic_policy {
51 uint32_t min_packet_thresh;
52 uint32_t avg_max_packet_thresh;
53 uint32_t max_max_packet_thresh;
56 struct rte_power_timer_profile {
57 int busy_hours[RTE_POWER_HOURS_PER_DAY];
58 int quiet_hours[RTE_POWER_HOURS_PER_DAY];
59 int hours_to_use_traffic_profile[RTE_POWER_HOURS_PER_DAY];
62 enum rte_power_workload_level {
68 enum rte_power_policy {
69 RTE_POWER_POLICY_TRAFFIC,
70 RTE_POWER_POLICY_TIME,
71 RTE_POWER_POLICY_WORKLOAD,
72 RTE_POWER_POLICY_BRANCH_RATIO
75 struct rte_power_turbo_status {
79 struct rte_power_channel_packet {
80 uint64_t resource_id; /**< core_num, device */
81 uint32_t unit; /**< scale down/up/min/max */
82 uint32_t command; /**< Power, IO, etc */
83 char vm_name[RTE_POWER_VM_MAX_NAME_SZ];
85 uint64_t vfid[RTE_POWER_MAX_VFS];
86 int nb_mac_to_monitor;
87 struct rte_power_traffic_policy traffic_policy;
88 uint8_t vcpu_to_control[RTE_POWER_MAX_VCPU_PER_VM];
90 struct rte_power_timer_profile timer_policy;
92 enum rte_power_workload_level workload;
93 enum rte_power_policy policy_to_use;
94 struct rte_power_turbo_status t_boost_status;
97 struct rte_power_channel_packet_freq_list {
98 uint64_t resource_id; /**< core_num, device */
99 uint32_t unit; /**< scale down/up/min/max */
100 uint32_t command; /**< Power, IO, etc */
101 char vm_name[RTE_POWER_VM_MAX_NAME_SZ];
103 uint32_t freq_list[RTE_POWER_MAX_VCPU_PER_VM];
107 struct rte_power_channel_packet_caps_list {
108 uint64_t resource_id; /**< core_num, device */
109 uint32_t unit; /**< scale down/up/min/max */
110 uint32_t command; /**< Power, IO, etc */
111 char vm_name[RTE_POWER_VM_MAX_NAME_SZ];
113 uint64_t turbo[RTE_POWER_MAX_VCPU_PER_VM];
114 uint64_t priority[RTE_POWER_MAX_VCPU_PER_VM];
122 * @b EXPERIMENTAL: this API may change without prior notice.
124 * Send a message contained in pkt over the Virtio-Serial to the host endpoint.
127 * Pointer to a populated struct channel_packet.
130 * Use channel specific to this lcore_id.
134 * - Negative on error.
137 int rte_power_guest_channel_send_msg(struct rte_power_channel_packet *pkt,
138 unsigned int lcore_id);
144 * @b EXPERIMENTAL: this API may change without prior notice.
146 * Receive a message contained in pkt over the Virtio-Serial
147 * from the host endpoint.
150 * Pointer to channel_packet or
151 * channel_packet_freq_list struct.
154 * Size of expected data packet.
157 * Use channel specific to this lcore_id.
161 * - Negative on error.
164 int rte_power_guest_channel_receive_msg(void *pkt,
166 unsigned int lcore_id);
173 #endif /* RTE_POWER_GUEST_CHANNEL_H_ */