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 #include <rte_compat.h>
17 #define RTE_POWER_MAX_VFS 10
18 #define RTE_POWER_VM_MAX_NAME_SZ 32
19 #define RTE_POWER_MAX_VCPU_PER_VM 8
20 #define RTE_POWER_HOURS_PER_DAY 24
23 #define RTE_POWER_CPU_POWER 1
24 #define RTE_POWER_CPU_POWER_CONNECT 2
25 #define RTE_POWER_PKT_POLICY 3
26 #define RTE_POWER_PKT_POLICY_REMOVE 4
28 #define RTE_POWER_CORE_TYPE_VIRTUAL 0
29 #define RTE_POWER_CORE_TYPE_PHYSICAL 1
31 /* CPU Power Command Scaling */
32 #define RTE_POWER_SCALE_UP 1
33 #define RTE_POWER_SCALE_DOWN 2
34 #define RTE_POWER_SCALE_MAX 3
35 #define RTE_POWER_SCALE_MIN 4
36 #define RTE_POWER_ENABLE_TURBO 5
37 #define RTE_POWER_DISABLE_TURBO 6
39 /* CPU Power Queries */
40 #define RTE_POWER_QUERY_FREQ_LIST 7
41 #define RTE_POWER_QUERY_FREQ 8
42 #define RTE_POWER_QUERY_CAPS_LIST 9
43 #define RTE_POWER_QUERY_CAPS 10
45 /* Generic Power Command Response */
46 #define RTE_POWER_CMD_ACK 1
47 #define RTE_POWER_CMD_NACK 2
49 /* CPU Power Query Responses */
50 #define RTE_POWER_FREQ_LIST 3
51 #define RTE_POWER_CAPS_LIST 4
53 struct rte_power_traffic_policy {
54 uint32_t min_packet_thresh;
55 uint32_t avg_max_packet_thresh;
56 uint32_t max_max_packet_thresh;
59 struct rte_power_timer_profile {
60 int busy_hours[RTE_POWER_HOURS_PER_DAY];
61 int quiet_hours[RTE_POWER_HOURS_PER_DAY];
62 int hours_to_use_traffic_profile[RTE_POWER_HOURS_PER_DAY];
65 enum rte_power_workload_level {
71 enum rte_power_policy {
72 RTE_POWER_POLICY_TRAFFIC,
73 RTE_POWER_POLICY_TIME,
74 RTE_POWER_POLICY_WORKLOAD,
75 RTE_POWER_POLICY_BRANCH_RATIO
78 struct rte_power_turbo_status {
82 struct rte_power_channel_packet {
83 uint64_t resource_id; /**< core_num, device */
84 uint32_t unit; /**< scale down/up/min/max */
85 uint32_t command; /**< Power, IO, etc */
86 char vm_name[RTE_POWER_VM_MAX_NAME_SZ];
88 uint64_t vfid[RTE_POWER_MAX_VFS];
89 int nb_mac_to_monitor;
90 struct rte_power_traffic_policy traffic_policy;
91 uint8_t vcpu_to_control[RTE_POWER_MAX_VCPU_PER_VM];
93 struct rte_power_timer_profile timer_policy;
95 enum rte_power_workload_level workload;
96 enum rte_power_policy policy_to_use;
97 struct rte_power_turbo_status t_boost_status;
100 struct rte_power_channel_packet_freq_list {
101 uint64_t resource_id; /**< core_num, device */
102 uint32_t unit; /**< scale down/up/min/max */
103 uint32_t command; /**< Power, IO, etc */
104 char vm_name[RTE_POWER_VM_MAX_NAME_SZ];
106 uint32_t freq_list[RTE_POWER_MAX_VCPU_PER_VM];
110 struct rte_power_channel_packet_caps_list {
111 uint64_t resource_id; /**< core_num, device */
112 uint32_t unit; /**< scale down/up/min/max */
113 uint32_t command; /**< Power, IO, etc */
114 char vm_name[RTE_POWER_VM_MAX_NAME_SZ];
116 uint64_t turbo[RTE_POWER_MAX_VCPU_PER_VM];
117 uint64_t priority[RTE_POWER_MAX_VCPU_PER_VM];
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.
134 int rte_power_guest_channel_send_msg(struct rte_power_channel_packet *pkt,
135 unsigned int lcore_id);
139 * @b EXPERIMENTAL: this API may change without prior notice.
141 * Receive a message contained in pkt over the Virtio-Serial
142 * from the host endpoint.
145 * Pointer to channel_packet or
146 * channel_packet_freq_list struct.
149 * Size of expected data packet.
152 * Use channel specific to this lcore_id.
156 * - Negative on error.
159 int rte_power_guest_channel_receive_msg(void *pkt,
161 unsigned int lcore_id);
168 #endif /* RTE_POWER_GUEST_CHANNEL_H_ */