1 /**
2  * Copyright (c) 2024 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @brief Structures and related enumerations used in Coexistence.
9  */
10 
11 #ifndef __COEX_STRUCT_H__
12 #define __COEX_STRUCT_H__
13 
14 #include <stdint.h>
15 #include <stdbool.h>
16 
17 /* Max size of message buffer (exchanged between host and MAC). This is in "bytes" */
18 #define MAX_MESSAGE_BUF_SIZE 320
19 /* Number of elements in coex_ch_configuration other than configbuf[] */
20 #define NUM_ELEMENTS_EXCL_CONFIGBUF 4
21 /* Each configuration value is of type uint32_t */
22 #define MAX_NUM_CONFIG_VALUES ((MAX_MESSAGE_BUF_SIZE-\
23 	(NUM_ELEMENTS_EXCL_CONFIGBUF*sizeof(uint32_t)))>>2)
24 /* Number of elements in coex_sr_traffic_info other than sr_traffic_info[] */
25 #define NUM_ELEMENTS_EXCL_SRINFOBUF 1
26 /* Each SR Traffic Info is of type uint32_t */
27 #define MAX_SR_TRAFFIC_BUF_SIZE 32
28 
29 enum {
30 	/** Used two different values for AGGREGATION module because offset from base is
31 	 *  beyond supported message buffer size for  WAIT_STATE_1_TIME register
32 	 */
33 	COEX_HARDWARE = 1,
34 	MAC_CTRL,
35 	MAC_CTRL_AGG_WAIT_STATE_1_TIME,
36 	MAC_CTRL_AGG,
37 	MAC_CTRL_DEAGG,
38 	WLAN_CTRL,
39 };
40 
41 /* IDs of different messages posted from Coexistence Driver to Coexistence Manager */
42 enum {
43 	/* To insturct Coexistence Manager to collect and post SR traffic information */
44 	COLLECT_SR_TRAFFIC_INFO = 1,
45 	/* To insturct Coexistence Manager to allocate a priority window to SR */
46 	ALLOCATE_PTI_WINDOW,
47 	/* To do configuration of hardware related to coexistence */
48 	HW_CONFIGURATION,
49 	/* To start allocating periodic priority windows to Wi-Fi and SR */
50 	ALLOCATE_PPW,
51 	/* To start allocating virtual priority windows to Wi-Fi */
52 	ALLOCATE_VPW,
53 	/* To configure CM SW parameters */
54 	SW_CONFIGURATION,
55 	/* To control sheliak side switch */
56 	UPDATE_SWITCH_CONFIG
57 };
58 
59 /* ID(s) of different messages posted from Coexistence Manager to Coexistence Driver */
60 enum {
61 	/* To post SR traffic information */
62 	SR_TRAFFIC_INFO = 1
63 };
64 
65 /**
66  * struct coex_collect_sr_traffic_info - Message from CD to CM  to request SR traffic info.
67  * @message_id: Indicates message ID. This is to be set to COLLECT_SR_TRAFFIC_INFO.
68  * @num_sets_requested: Indicates the number of sets of duration and periodicity to be collected.
69  *
70  * Message from CD to CM  to request SR traffic information.
71  */
72 struct coex_collect_sr_traffic_info {
73 	uint32_t message_id;
74 	uint32_t num_sets_requested;
75 };
76 
77 /**
78  * struct coex_ch_configuration -Message from CD to CM  to configure CH.
79  * @message_id: Indicates message ID. This is to be set to HW_CONFIGURATION.
80  * @num_reg_to_config: Indicates the number of registers to be configured.
81  * @hw_to_config: Indicates the hardware block that is to be configured.
82  * @hw_block_base_addr: Base address of the hardware block to be configured.
83  * @configbuf: Configuration buffer that holds packed offset and configuration value.
84  *
85  * Message from CD to CM  to configure CH
86  */
87 struct coex_ch_configuration {
88 	uint32_t message_id;
89 	uint32_t num_reg_to_config;
90 	uint32_t hw_to_config;
91 	uint32_t hw_block_base_addr;
92 	uint32_t configbuf[MAX_NUM_CONFIG_VALUES];
93 };
94 
95 /**
96  * struct coex_allocate_pti_window - Message to CM to request a priority window.
97  * @message_id: Indicates message ID. This is to be set to ALLOCATE_PTI_WINDOW.
98  * @device_req_window: Indicates device requesting a priority window.
99  * @window_start_or_end: Indicates if request is posted to START or END a priority window.
100  * @imp_of_request: Indicates importance of activity for which the window is requested.
101  * @can_be_deferred: activity of Wi-Fi/SR, for which window is requested can be deferred or not.
102  *
103  * Message to CM to request a priority window
104  */
105 struct coex_allocate_pti_window {
106 	uint32_t message_id;
107 	uint32_t device_req_window;
108 	uint32_t window_start_or_end;
109 	uint32_t imp_of_request;
110 	uint32_t can_be_deferred;
111 };
112 
113 /**
114  * struct coex_allocate_ppw - Message from CD to CM  to allocate Periodic Priority Windows.
115  * @message_id: Indicates message ID. This is to be set to ALLOCATE_PPW.
116  * @start_or_stop: Indiates start or stop allocation of PPWs.
117  * @first_pti_window: Indicates first priority window in the series of PPWs.
118  * @ps_mechanism: Indicates recommended powersave mechanism for Wi-Fi's downlink.
119  * @wifi_window_duration: Indicates duration of Wi-Fi priority window.
120  * @sr_window_duration: Indicates duration of SR priority window.
121  *
122  * Message from CD to CM  to allocate Periodic Priority Windows.
123  */
124 struct coex_allocate_ppw {
125 	uint32_t message_id;
126 	uint32_t start_or_stop;
127 	uint32_t first_pti_window;
128 	uint32_t ps_mechanism;
129 	uint32_t wifi_window_duration;
130 	uint32_t sr_window_duration;
131 };
132 
133 /**
134  * struct coex_allocate_vpw - Message from CD to CM  to allocate Virtual Priority Windows.
135  * @message_id: Indicates message ID. This is to be set to ALLOCATE_VPW.
136  * @start_or_stop: Indicates start or stop allocation of VPWs.
137  * @wifi_window_duration: Indicates duration of Wi-Fi virtual priority window.
138  * @ps_mechanism: Indicates recommended powersave mechanism for Wi-Fi's downlink.
139  *
140  * Message from CD to CM  to allocate Virtual Priority Windows.
141  */
142 struct coex_allocate_vpw {
143 	uint32_t message_id;
144 	uint32_t start_or_stop;
145 	uint32_t wifi_window_duration;
146 	uint32_t ps_mechanism;
147 };
148 
149 /**
150  * struct coex_config_cm_params - Message from CD to CM  to configure CM parameters
151  * @message_id: Indicates message ID. This is to be set to SW_CONFIGURATION.
152  * @first_isr_trigger_period: microseconds . used to trigger the ISR mechanism.
153  * @sr_window_poll_periodicity_vpw: microseconds. This is used to poll through SR window.
154  *  that comes after Wi-Fi window ends and next SR activity starts, in the case of VPWs.
155  * @lead_time_from_end_of_wlan_win: microseconds. Lead time from the end of Wi-Fi window.
156  *  (to inform  AP that Wi-Fi is entering powersave) in the case of PPW and VPW generation.
157  * @sr_window_poll_count_threshold: This is equal to "Wi-Fi contention timeout.
158  *  threshold"/sr_window_poll_periodicity_vpw.
159  *
160  * Message from CD to CM  to configure CM parameters.
161  */
162 struct coex_config_cm_params {
163 	uint32_t message_id;
164 	uint32_t first_isr_trigger_period;
165 	uint32_t sr_window_poll_periodicity_vpw;
166 	uint32_t lead_time_from_end_of_wlan_win;
167 	uint32_t sr_window_poll_count_threshold;
168 };
169 
170 /**
171  * struct coex_sr_traffic_info - Message from CM to CD to post SR traffic information.
172  * @message_id: Indicates message ID. This is to be set to SR_TRAFFIC_INFO.
173  * @sr_traffic_info: Traffic information buffer.
174  *
175  * Message from CM to CD to post SR traffic inforamtion
176  */
177 struct coex_sr_traffic_info {
178 	uint32_t message_id;
179 	uint32_t sr_traffic_info[MAX_SR_TRAFFIC_BUF_SIZE];
180 };
181 
182 #endif /* __COEX_STRUCT_H__ */
183