power: create guest channel public header file
[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 /* --- Incoming messages --- */
15
16 /* Valid Commands */
17 #define CPU_POWER               1
18 #define CPU_POWER_CONNECT       2
19 #define PKT_POLICY              3
20 #define PKT_POLICY_REMOVE       4
21
22 /* CPU Power Command Scaling */
23 #define CPU_POWER_SCALE_UP      1
24 #define CPU_POWER_SCALE_DOWN    2
25 #define CPU_POWER_SCALE_MAX     3
26 #define CPU_POWER_SCALE_MIN     4
27 #define CPU_POWER_ENABLE_TURBO  5
28 #define CPU_POWER_DISABLE_TURBO 6
29
30 /* CPU Power Queries */
31 #define CPU_POWER_QUERY_FREQ_LIST  7
32 #define CPU_POWER_QUERY_FREQ       8
33 #define CPU_POWER_QUERY_CAPS_LIST  9
34 #define CPU_POWER_QUERY_CAPS       10
35
36 /* --- Outgoing messages --- */
37
38 /* Generic Power Command Response */
39 #define CPU_POWER_CMD_ACK       1
40 #define CPU_POWER_CMD_NACK      2
41
42 /* CPU Power Query Responses */
43 #define CPU_POWER_FREQ_LIST     3
44 #define CPU_POWER_CAPS_LIST     4
45
46 #define HOURS 24
47
48 #define MAX_VFS 10
49 #define VM_MAX_NAME_SZ 32
50
51 #define MAX_VCPU_PER_VM         8
52
53 struct t_boost_status {
54         bool tbEnabled;
55 };
56
57 struct timer_profile {
58         int busy_hours[HOURS];
59         int quiet_hours[HOURS];
60         int hours_to_use_traffic_profile[HOURS];
61 };
62
63 enum workload {HIGH, MEDIUM, LOW};
64 enum policy_to_use {
65         TRAFFIC,
66         TIME,
67         WORKLOAD,
68         BRANCH_RATIO
69 };
70
71 struct traffic {
72         uint32_t min_packet_thresh;
73         uint32_t avg_max_packet_thresh;
74         uint32_t max_max_packet_thresh;
75 };
76
77 #define CORE_TYPE_VIRTUAL 0
78 #define CORE_TYPE_PHYSICAL 1
79
80 struct channel_packet {
81         uint64_t resource_id; /**< core_num, device */
82         uint32_t unit;        /**< scale down/up/min/max */
83         uint32_t command;     /**< Power, IO, etc */
84         char vm_name[VM_MAX_NAME_SZ];
85
86         uint64_t vfid[MAX_VFS];
87         int nb_mac_to_monitor;
88         struct traffic traffic_policy;
89         uint8_t vcpu_to_control[MAX_VCPU_PER_VM];
90         uint8_t num_vcpu;
91         struct timer_profile timer_policy;
92         bool core_type;
93         enum workload workload;
94         enum policy_to_use policy_to_use;
95         struct t_boost_status t_boost_status;
96 };
97
98 struct channel_packet_freq_list {
99         uint64_t resource_id; /**< core_num, device */
100         uint32_t unit;        /**< scale down/up/min/max */
101         uint32_t command;     /**< Power, IO, etc */
102         char vm_name[VM_MAX_NAME_SZ];
103
104         uint32_t freq_list[MAX_VCPU_PER_VM];
105         uint8_t num_vcpu;
106 };
107
108 struct channel_packet_caps_list {
109         uint64_t resource_id; /**< core_num, device */
110         uint32_t unit;        /**< scale down/up/min/max */
111         uint32_t command;     /**< Power, IO, etc */
112         char vm_name[VM_MAX_NAME_SZ];
113
114         uint64_t turbo[MAX_VCPU_PER_VM];
115         uint64_t priority[MAX_VCPU_PER_VM];
116         uint8_t num_vcpu;
117 };
118
119
120 #ifdef __cplusplus
121 }
122 #endif
123
124 #endif /* RTE_POWER_GUEST_CHANNEL_H_ */