xref: /wlan-dirver/qcacld-3.0/core/wma/src/wma_eht.h (revision 2933838e5c361d2ceff0278c7bf3d087c9189fff)
1 /*
2  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #ifndef __WMA_EHT_H
19 #define __WMA_EHT_H
20 
21 #include "wma.h"
22 
23 enum EHT_TXRX_MCS_NSS_IDX {
24 	EHTCAP_TXRX_MCS_NSS_IDX0,
25 	EHTCAP_TXRX_MCS_NSS_IDX1,
26 	EHTCAP_TXRX_MCS_NSS_IDX2,
27 	EHTCAP_TXRX_MCS_NSS_IDXMAX,
28 };
29 
30 #if defined(WLAN_FEATURE_11BE)
31 #define MAX_EHT_DCM_INDEX 2
32 #define MAX_EHT_MCS_IDX 14
33 /* valid only for mcs-15 */
34 #define IS_EHT_ MCS_HAS_DCM_RATE(val)  ((val) == 15)
35 /**
36  * struct index_eht_data_rate_type - eht data rate type
37  * @beacon_rate_index: Beacon rate index
38  * @supported_eht20_rate: eht20 rate
39  * @supported_eht40_rate: eht40 rate
40  * @supported_eht80_rate: eht80 rate
41  * @supported_eht160_rate: eht160 rate
42  */
43 struct index_eht_data_rate_type {
44 	uint8_t beacon_rate_index;
45 	uint16_t supported_eht20_rate[MAX_EHT_DCM_INDEX][3];
46 	uint16_t supported_eht40_rate[MAX_EHT_DCM_INDEX][3];
47 	uint16_t supported_eht80_rate[MAX_EHT_DCM_INDEX][3];
48 	uint16_t supported_eht160_rate[MAX_EHT_DCM_INDEX][3];
49 	uint16_t supported_eht320_rate[MAX_EHT_DCM_INDEX][3];
50 };
51 
52 /*
53  * wma_eht_update_tgt_services() - update tgt cfg to indicate 11be support
54  * @wmi_handle: pointer to WMI handle
55  * @cfg: pointer to WMA target services
56  *
57  * Based on WMI SERVICES information, enable 11be support and set DOT11BE
58  * bit in feature caps bitmap.
59  *
60  * Return: None
61  */
62 void wma_eht_update_tgt_services(struct wmi_unified *wmi_handle,
63 				 struct wma_tgt_services *cfg);
64 /**
65  * wma_update_target_ext_eht_cap() - Update EHT caps with given extended cap
66  * @tgt_hdl: target psoc information
67  * @tgt_cfg: Target config
68  *
69  * This function loop through each hardware mode and for each hardware mode
70  * again it loop through each MAC/PHY and pull the caps 2G and 5G specific
71  * EHT caps and derives the final cap.
72  *
73  * Return: None
74  */
75 void wma_update_target_ext_eht_cap(struct target_psoc_info *tgt_hdl,
76 				   struct wma_tgt_cfg *tgt_cfg);
77 
78 void wma_update_vdev_eht_ops(uint32_t *eht_ops, tDot11fIEeht_op *eht_op);
79 
80 /**
81  * wma_print_eht_cap() - Print EHT capabilities
82  * @eht_cap: pointer to EHT Capability
83  *
84  * Received EHT capabilities are converted into dot11f structure.
85  * This function will print all the EHT capabilities as stored
86  * in the dot11f structure.
87  *
88  * Return: None
89  */
90 void wma_print_eht_cap(tDot11fIEeht_cap *eht_cap);
91 
92 /**
93  * wma_print_eht_phy_cap() - Print EHT PHY Capability
94  * @phy_cap: pointer to PHY Capability
95  *
96  * This function prints EHT PHY Capability received from FW.
97  *
98  * Return: none
99  */
100 void wma_print_eht_phy_cap(uint32_t *phy_cap);
101 
102 /**
103  * wma_print_eht_mac_cap() - Print EHT MAC Capability
104  * @mac_cap: pointer to MAC Capability
105  *
106  * This function prints EHT MAC Capability received from FW.
107  *
108  * Return: none
109  */
110 void wma_print_eht_mac_cap(uint32_t *mac_cap);
111 
112 /**
113  * wma_print_eht_op() - Print EHT Operation
114  * @eht_cap: pointer to EHT Operation
115  *
116  * Print EHT operation stored as dot11f structure
117  *
118  * Return: None
119  */
120 void wma_print_eht_op(tDot11fIEeht_op *eht_ops);
121 
122 /**
123  * wma_populate_peer_eht_cap() - populate peer EHT capabilities in
124  *                               peer assoc cmd
125  * @peer: pointer to peer assoc params
126  * @params: pointer to ADD STA params
127  *
128  * Return: None
129  */
130 void wma_populate_peer_eht_cap(struct peer_assoc_params *peer,
131 			       tpAddStaParams params);
132 
133 /**
134  * wma_vdev_set_eht_bss_params() - set EHT OPs in vdev start
135  * @wma: pointer to wma handle
136  * @vdev_id: VDEV id
137  * @eht_info: pointer to eht info
138  *
139  * Return: None
140  */
141 void wma_vdev_set_eht_bss_params(tp_wma_handle wma, uint8_t vdev_id,
142 				 struct vdev_mlme_eht_ops_info *eht_info);
143 
144 /**
145  * wma_is_peer_eht_capable() - whether peer is eht capable or not
146  * @params: add sta params
147  *
148  * Return: true if eht capable is present
149  */
150 static inline bool wma_is_peer_eht_capable(tpAddStaParams params)
151 {
152 	return params->eht_capable;
153 }
154 
155 /**
156  * wma_get_eht_capabilities() - Get EHT capabilities from WMA
157  * @eht_cap: Pointer to EHT capabilities
158  *
159  * Currently EHT capabilities are not updated in wma_handle. This
160  * is an interface for upper layer to query capabilities from WMA.
161  * When the real use case arise, update wma_handle with EHT capabilities
162  * as required.
163  *
164  * Return: QDF_STATUS
165  */
166 QDF_STATUS wma_get_eht_capabilities(struct eht_capability *eht_cap);
167 
168 /**
169  * wma_set_peer_assoc_params_bw_320() - Set bw_320 based on ch_width
170  * @params: pointer to peer assoc params
171  * @ch_width: enum phy_ch_width
172  *
173  * If ch_width is CH_WIDTH_320MHZ, set params->bw_320 to 1
174  *
175  * Return: None
176  */
177 void wma_set_peer_assoc_params_bw_320(struct peer_assoc_params *params,
178 				      enum phy_ch_width ch_width);
179 
180 /**
181  * wma_set_eht_txbf_cfg() - set EHT Tx beamforming mlme cfg to FW
182  * @mac: Global MAC context
183  * @vdev_id: VDEV id
184  *
185  * Return: None
186  */
187 void wma_set_eht_txbf_cfg(struct mac_context *mac, uint8_t vdev_id);
188 
189 /**
190  * wma_set_eht_txbf_params() - set EHT Tx beamforming params to FW
191  * @vdev_id: VDEV id
192  * @su bfer: SU beamformer capability
193  * @su bfee: SU beamformee capability
194  * @mu bfer: MU beamformer capability
195  *
196  * Return: None
197  */
198 void wma_set_eht_txbf_params(uint8_t vdev_id, bool su_bfer,
199 			     bool su_bfee, bool mu_bfer);
200 
201 /**
202  * wma_get_eht_rate_flags() - Return the EHT rate flags corresponding to the BW
203  * @ch_width: BW for which rate flags is required
204  *
205  * Return: Rate flags corresponding to ch_width
206  */
207 enum tx_rate_info wma_get_eht_rate_flags(enum phy_ch_width ch_width);
208 
209 /**
210  * wma_match_eht_rate() - get eht rate matching with nss
211  * @raw_rate: raw rate from fw
212  * @rate_flags: rate flags
213  * @nss: nss
214  * @dcm: dcm
215  * @guard_interval: guard interval
216  * @mcs_rate_flag: mcs rate flags
217  * @p_index: index for matched rate
218  *
219  *  Return: return match rate if found, else 0
220  */
221 uint16_t wma_match_eht_rate(uint16_t raw_rate,
222 			    enum tx_rate_info rate_flags,
223 			    uint8_t *nss, uint8_t *dcm,
224 			    enum txrate_gi *guard_interval,
225 			    enum tx_rate_info *mcs_rate_flag,
226 			    uint8_t *p_index);
227 
228 /**
229  * wma_set_bss_rate_flags_eht() - set rate flags based on BSS capability
230  * @rate_flags: rate_flags pointer
231  * @add_bss: add_bss params
232  *
233  * Return: QDF_STATUS
234  */
235 QDF_STATUS wma_set_bss_rate_flags_eht(enum tx_rate_info *rate_flags,
236 				      struct bss_params *add_bss);
237 
238 /**
239  * wma_get_bss_eht_capable() - whether bss is eht capable or not
240  * @add_bss: add_bss params
241  *
242  * Return: true if eht capable is present
243  */
244 bool wma_get_bss_eht_capable(struct bss_params *add_bss);
245 
246 static
247 inline bool wma_is_eht_phymode_supported(enum wlan_phymode bss_phymode)
248 {
249 	return IS_WLAN_PHYMODE_EHT(bss_phymode);
250 }
251 
252 /**
253  * wma_set_eht_txbf_vdev_params() - set EHT Tx beamforming params to FW
254  * @mac: mac context
255  * @mode: mode address to access mode value
256  *
257  * Return: success
258  */
259 QDF_STATUS
260 wma_set_eht_txbf_vdev_params(struct mac_context *mac, uint32_t *mode);
261 
262 #else
263 static inline void wma_eht_update_tgt_services(struct wmi_unified *wmi_handle,
264 					       struct wma_tgt_services *cfg)
265 {
266 		cfg->en_11be = false;
267 		return;
268 }
269 
270 static inline
271 void wma_update_target_ext_eht_cap(struct target_psoc_info *tgt_hdl,
272 				   struct wma_tgt_cfg *tgt_cfg)
273 {
274 }
275 
276 static inline
277 void wma_update_vdev_eht_ops(uint32_t *eht_ops, tDot11fIEeht_op *eht_op)
278 {
279 }
280 
281 static inline
282 void wma_print_eht_cap(tDot11fIEeht_cap *eht_cap)
283 {
284 }
285 
286 static inline
287 void wma_print_eht_phy_cap(uint32_t *phy_cap)
288 {
289 }
290 
291 static inline
292 void wma_print_eht_mac_cap(uint32_t *mac_cap)
293 {
294 }
295 
296 static inline
297 void wma_print_eht_op(tDot11fIEeht_op *eht_ops)
298 {
299 }
300 
301 static inline
302 void wma_populate_peer_eht_cap(struct peer_assoc_params *peer,
303 			       tpAddStaParams params)
304 {
305 }
306 
307 static inline bool wma_is_peer_eht_capable(tpAddStaParams params)
308 {
309 	return false;
310 }
311 
312 static inline
313 void wma_set_peer_assoc_params_bw_320(struct peer_assoc_params *params,
314 				      enum phy_ch_width ch_width)
315 {
316 }
317 
318 static inline
319 void wma_set_eht_txbf_cfg(struct mac_context *mac, uint8_t vdev_id)
320 {
321 }
322 
323 static inline
324 void wma_set_eht_txbf_params(uint8_t vdev_id, bool su_bfer,
325 			     bool su_bfee, bool mu_bfer)
326 {
327 }
328 
329 static inline
330 QDF_STATUS wma_set_bss_rate_flags_eht(enum tx_rate_info *rate_flags,
331 				      struct bss_params *add_bss)
332 {
333 	return QDF_STATUS_E_INVAL;
334 }
335 
336 static inline
337 enum tx_rate_info wma_get_eht_rate_flags(enum phy_ch_width ch_width)
338 {
339 	return TX_RATE_EHT20;
340 }
341 
342 static inline
343 uint16_t wma_match_eht_rate(uint16_t raw_rate,
344 			    enum tx_rate_info rate_flags,
345 			    uint8_t *nss, uint8_t *dcm,
346 			    enum txrate_gi *guard_interval,
347 			    enum tx_rate_info *mcs_rate_flag,
348 			    uint8_t *p_index)
349 {
350 		return 0;
351 }
352 
353 static inline
354 bool wma_get_bss_eht_capable(struct bss_params *add_bss)
355 {
356 	return false;
357 }
358 
359 static inline bool wma_is_eht_phymode_supported(enum wlan_phymode bss_phymode)
360 {
361 	return false;
362 }
363 
364 static inline
365 QDF_STATUS wma_set_eht_txbf_vdev_params(struct mac_context *mac, uint32_t *mode)
366 {
367 	return QDF_STATUS_E_NOSUPPORT;
368 }
369 #endif
370 #endif
371