DPDK  21.02.0
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 
79  bool tbEnabled;
80 };
81 
82 struct rte_power_channel_packet {
83  uint64_t resource_id;
84  uint32_t unit;
85  uint32_t command;
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;
102  uint32_t unit;
103  uint32_t command;
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;
112  uint32_t unit;
113  uint32_t command;
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 
139 __rte_experimental
140 int rte_power_guest_channel_send_msg(struct rte_power_channel_packet *pkt,
141  unsigned int lcore_id);
142 
166 __rte_experimental
167 int rte_power_guest_channel_receive_msg(void *pkt,
168  size_t pkt_len,
169  unsigned int lcore_id);
170 
171 
172 #ifdef __cplusplus
173 }
174 #endif
175 
176 #endif /* RTE_POWER_GUEST_CHANNEL_H_ */
rte_power_freq_change_t rte_power_turbo_status