power: clean up includes
[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 #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
15
16 /* Valid Commands */
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
21
22 #define RTE_POWER_CORE_TYPE_VIRTUAL 0
23 #define RTE_POWER_CORE_TYPE_PHYSICAL 1
24
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
32
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
38
39 /* Generic Power Command Response */
40 #define RTE_POWER_CMD_ACK       1
41 #define RTE_POWER_CMD_NACK      2
42
43 /* CPU Power Query Responses */
44 #define RTE_POWER_FREQ_LIST     3
45 #define RTE_POWER_CAPS_LIST     4
46
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;
51 };
52
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];
57 };
58
59 enum rte_power_workload_level {
60         RTE_POWER_WL_HIGH,
61         RTE_POWER_WL_MEDIUM,
62         RTE_POWER_WL_LOW
63 };
64
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
70 };
71
72 struct rte_power_turbo_status {
73         bool tbEnabled;
74 };
75
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];
81
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];
86         uint8_t num_vcpu;
87         struct rte_power_timer_profile timer_policy;
88         bool core_type;
89         enum rte_power_workload_level workload;
90         enum rte_power_policy policy_to_use;
91         struct rte_power_turbo_status t_boost_status;
92 };
93
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];
99
100         uint32_t freq_list[RTE_POWER_MAX_VCPU_PER_VM];
101         uint8_t num_vcpu;
102 };
103
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];
109
110         uint64_t turbo[RTE_POWER_MAX_VCPU_PER_VM];
111         uint64_t priority[RTE_POWER_MAX_VCPU_PER_VM];
112         uint8_t num_vcpu;
113 };
114
115 /**
116  * @internal
117  *
118  * @warning
119  * @b EXPERIMENTAL: this API may change without prior notice.
120  *
121  * Send a message contained in pkt over the Virtio-Serial to the host endpoint.
122  *
123  * @param pkt
124  *  Pointer to a populated struct channel_packet.
125  *
126  * @param lcore_id
127  *  Use channel specific to this lcore_id.
128  *
129  * @return
130  *  - 0 on success.
131  *  - Negative on error.
132  */
133 __rte_experimental
134 int rte_power_guest_channel_send_msg(struct rte_power_channel_packet *pkt,
135                         unsigned int lcore_id);
136
137 /**
138  * @internal
139  *
140  * @warning
141  * @b EXPERIMENTAL: this API may change without prior notice.
142  *
143  * Receive a message contained in pkt over the Virtio-Serial
144  * from the host endpoint.
145  *
146  * @param pkt
147  *  Pointer to channel_packet or
148  *  channel_packet_freq_list struct.
149  *
150  * @param pkt_len
151  *  Size of expected data packet.
152  *
153  * @param lcore_id
154  *  Use channel specific to this lcore_id.
155  *
156  * @return
157  *  - 0 on success.
158  *  - Negative on error.
159  */
160 __rte_experimental
161 int rte_power_guest_channel_receive_msg(void *pkt,
162                 size_t pkt_len,
163                 unsigned int lcore_id);
164
165
166 #ifdef __cplusplus
167 }
168 #endif
169
170 #endif /* RTE_POWER_GUEST_CHANNEL_H_ */