power: rename constants
[dpdk.git] / lib / librte_power / rte_power_guest_channel.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2021 Intel Corporation
3  */
4 #ifndef RTE_POWER_GUEST_CHANNEL_H
5 #define RTE_POWER_GUEST_CHANNEL_H
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 #include <stdint.h>
12 #include <stdbool.h>
13
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
18
19 /* Valid Commands */
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
24
25 #define RTE_POWER_CORE_TYPE_VIRTUAL 0
26 #define RTE_POWER_CORE_TYPE_PHYSICAL 1
27
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
35
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
41
42 /* Generic Power Command Response */
43 #define RTE_POWER_CMD_ACK       1
44 #define RTE_POWER_CMD_NACK      2
45
46 /* CPU Power Query Responses */
47 #define RTE_POWER_FREQ_LIST     3
48 #define RTE_POWER_CAPS_LIST     4
49
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;
54 };
55
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];
60 };
61
62 enum rte_power_workload_level {
63         RTE_POWER_WL_HIGH,
64         RTE_POWER_WL_MEDIUM,
65         RTE_POWER_WL_LOW
66 };
67
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
73 };
74
75 struct rte_power_turbo_status {
76         bool tbEnabled;
77 };
78
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];
84
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];
89         uint8_t num_vcpu;
90         struct rte_power_timer_profile timer_policy;
91         bool core_type;
92         enum rte_power_workload_level workload;
93         enum rte_power_policy policy_to_use;
94         struct rte_power_turbo_status t_boost_status;
95 };
96
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];
102
103         uint32_t freq_list[RTE_POWER_MAX_VCPU_PER_VM];
104         uint8_t num_vcpu;
105 };
106
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];
112
113         uint64_t turbo[RTE_POWER_MAX_VCPU_PER_VM];
114         uint64_t priority[RTE_POWER_MAX_VCPU_PER_VM];
115         uint8_t num_vcpu;
116 };
117
118 /**
119  * @internal
120  *
121  * @warning
122  * @b EXPERIMENTAL: this API may change without prior notice.
123  *
124  * Send a message contained in pkt over the Virtio-Serial to the host endpoint.
125  *
126  * @param pkt
127  *  Pointer to a populated struct channel_packet.
128  *
129  * @param lcore_id
130  *  Use channel specific to this lcore_id.
131  *
132  * @return
133  *  - 0 on success.
134  *  - Negative on error.
135  */
136 __rte_experimental
137 int rte_power_guest_channel_send_msg(struct rte_power_channel_packet *pkt,
138                         unsigned int lcore_id);
139
140 /**
141  * @internal
142  *
143  * @warning
144  * @b EXPERIMENTAL: this API may change without prior notice.
145  *
146  * Receive a message contained in pkt over the Virtio-Serial
147  * from the host endpoint.
148  *
149  * @param pkt
150  *  Pointer to channel_packet or
151  *  channel_packet_freq_list struct.
152  *
153  * @param pkt_len
154  *  Size of expected data packet.
155  *
156  * @param lcore_id
157  *  Use channel specific to this lcore_id.
158  *
159  * @return
160  *  - 0 on success.
161  *  - Negative on error.
162  */
163 __rte_experimental
164 int rte_power_guest_channel_receive_msg(void *pkt,
165                 size_t pkt_len,
166                 unsigned int lcore_id);
167
168
169 #ifdef __cplusplus
170 }
171 #endif
172
173 #endif /* RTE_POWER_GUEST_CHANNEL_H_ */