net/virtio: fix incorrect cast of void *
[dpdk.git] / 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 #include <stdint.h>
8 #include <stddef.h>
9 #include <stdbool.h>
10
11 #include <rte_compat.h>
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
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
21
22 /* Valid Commands */
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
27
28 #define RTE_POWER_CORE_TYPE_VIRTUAL 0
29 #define RTE_POWER_CORE_TYPE_PHYSICAL 1
30
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
38
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
44
45 /* Generic Power Command Response */
46 #define RTE_POWER_CMD_ACK       1
47 #define RTE_POWER_CMD_NACK      2
48
49 /* CPU Power Query Responses */
50 #define RTE_POWER_FREQ_LIST     3
51 #define RTE_POWER_CAPS_LIST     4
52
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;
57 };
58
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];
63 };
64
65 enum rte_power_workload_level {
66         RTE_POWER_WL_HIGH,
67         RTE_POWER_WL_MEDIUM,
68         RTE_POWER_WL_LOW
69 };
70
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
76 };
77
78 struct rte_power_turbo_status {
79         bool tbEnabled;
80 };
81
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];
87
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];
92         uint8_t num_vcpu;
93         struct rte_power_timer_profile timer_policy;
94         bool core_type;
95         enum rte_power_workload_level workload;
96         enum rte_power_policy policy_to_use;
97         struct rte_power_turbo_status t_boost_status;
98 };
99
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];
105
106         uint32_t freq_list[RTE_POWER_MAX_VCPU_PER_VM];
107         uint8_t num_vcpu;
108 };
109
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];
115
116         uint64_t turbo[RTE_POWER_MAX_VCPU_PER_VM];
117         uint64_t priority[RTE_POWER_MAX_VCPU_PER_VM];
118         uint8_t num_vcpu;
119 };
120
121 /**
122  * Send a message contained in pkt over the Virtio-Serial to the host endpoint.
123  *
124  * @param pkt
125  *  Pointer to a populated struct channel_packet.
126  *
127  * @param lcore_id
128  *  Use channel specific to this lcore_id.
129  *
130  * @return
131  *  - 0 on success.
132  *  - Negative on error.
133  */
134 int rte_power_guest_channel_send_msg(struct rte_power_channel_packet *pkt,
135                         unsigned int lcore_id);
136
137 /**
138  * @warning
139  * @b EXPERIMENTAL: this API may change without prior notice.
140  *
141  * Receive a message contained in pkt over the Virtio-Serial
142  * from the host endpoint.
143  *
144  * @param pkt
145  *  Pointer to channel_packet or
146  *  channel_packet_freq_list struct.
147  *
148  * @param pkt_len
149  *  Size of expected data packet.
150  *
151  * @param lcore_id
152  *  Use channel specific to this lcore_id.
153  *
154  * @return
155  *  - 0 on success.
156  *  - Negative on error.
157  */
158 __rte_experimental
159 int rte_power_guest_channel_receive_msg(void *pkt,
160                 size_t pkt_len,
161                 unsigned int lcore_id);
162
163
164 #ifdef __cplusplus
165 }
166 #endif
167
168 #endif /* RTE_POWER_GUEST_CHANNEL_H_ */