1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2 /* Copyright(c) 2019-2020  Realtek Corporation
3  */
4 
5 #include "cam.h"
6 #include "chan.h"
7 #include "coex.h"
8 #include "debug.h"
9 #include "fw.h"
10 #include "mac.h"
11 #include "phy.h"
12 #include "ps.h"
13 #include "reg.h"
14 #include "sar.h"
15 #include "ser.h"
16 #include "util.h"
17 #include "wow.h"
18 
19 static void rtw89_ops_tx(struct ieee80211_hw *hw,
20 			 struct ieee80211_tx_control *control,
21 			 struct sk_buff *skb)
22 {
23 	struct rtw89_dev *rtwdev = hw->priv;
24 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
25 	struct ieee80211_vif *vif = info->control.vif;
26 	struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;
27 	struct ieee80211_sta *sta = control->sta;
28 	u32 flags = IEEE80211_SKB_CB(skb)->flags;
29 	int ret, qsel;
30 
31 	if (rtwvif->offchan && !(flags & IEEE80211_TX_CTL_TX_OFFCHAN) && sta) {
32 		struct rtw89_sta *rtwsta = (struct rtw89_sta *)sta->drv_priv;
33 
34 		rtw89_debug(rtwdev, RTW89_DBG_TXRX, "ops_tx during offchan\n");
35 		skb_queue_tail(&rtwsta->roc_queue, skb);
36 		return;
37 	}
38 
39 	ret = rtw89_core_tx_write(rtwdev, vif, sta, skb, &qsel);
40 	if (ret) {
41 		rtw89_err(rtwdev, "failed to transmit skb: %d\n", ret);
42 		ieee80211_free_txskb(hw, skb);
43 		return;
44 	}
45 	rtw89_core_tx_kick_off(rtwdev, qsel);
46 }
47 
48 static void rtw89_ops_wake_tx_queue(struct ieee80211_hw *hw,
49 				    struct ieee80211_txq *txq)
50 {
51 	struct rtw89_dev *rtwdev = hw->priv;
52 
53 	ieee80211_schedule_txq(hw, txq);
54 	queue_work(rtwdev->txq_wq, &rtwdev->txq_work);
55 }
56 
57 static int rtw89_ops_start(struct ieee80211_hw *hw)
58 {
59 	struct rtw89_dev *rtwdev = hw->priv;
60 	int ret;
61 
62 	mutex_lock(&rtwdev->mutex);
63 	ret = rtw89_core_start(rtwdev);
64 	mutex_unlock(&rtwdev->mutex);
65 
66 	return ret;
67 }
68 
69 static void rtw89_ops_stop(struct ieee80211_hw *hw)
70 {
71 	struct rtw89_dev *rtwdev = hw->priv;
72 
73 	mutex_lock(&rtwdev->mutex);
74 	rtw89_core_stop(rtwdev);
75 	mutex_unlock(&rtwdev->mutex);
76 }
77 
78 static int rtw89_ops_config(struct ieee80211_hw *hw, u32 changed)
79 {
80 	struct rtw89_dev *rtwdev = hw->priv;
81 
82 	/* let previous ips work finish to ensure we don't leave ips twice */
83 	cancel_work_sync(&rtwdev->ips_work);
84 
85 	mutex_lock(&rtwdev->mutex);
86 	rtw89_leave_ps_mode(rtwdev);
87 
88 	if ((changed & IEEE80211_CONF_CHANGE_IDLE) &&
89 	    !(hw->conf.flags & IEEE80211_CONF_IDLE))
90 		rtw89_leave_ips(rtwdev);
91 
92 	if (changed & IEEE80211_CONF_CHANGE_PS) {
93 		if (hw->conf.flags & IEEE80211_CONF_PS) {
94 			rtwdev->lps_enabled = true;
95 		} else {
96 			rtw89_leave_lps(rtwdev);
97 			rtwdev->lps_enabled = false;
98 		}
99 	}
100 
101 	if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
102 		rtw89_config_entity_chandef(rtwdev, RTW89_SUB_ENTITY_0,
103 					    &hw->conf.chandef);
104 		rtw89_set_channel(rtwdev);
105 	}
106 
107 	if ((changed & IEEE80211_CONF_CHANGE_IDLE) &&
108 	    (hw->conf.flags & IEEE80211_CONF_IDLE) &&
109 	    !rtwdev->scanning)
110 		rtw89_enter_ips(rtwdev);
111 
112 	mutex_unlock(&rtwdev->mutex);
113 
114 	return 0;
115 }
116 
117 static int rtw89_ops_add_interface(struct ieee80211_hw *hw,
118 				   struct ieee80211_vif *vif)
119 {
120 	struct rtw89_dev *rtwdev = hw->priv;
121 	struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;
122 	int ret = 0;
123 
124 	rtw89_debug(rtwdev, RTW89_DBG_STATE, "add vif %pM type %d, p2p %d\n",
125 		    vif->addr, vif->type, vif->p2p);
126 
127 	mutex_lock(&rtwdev->mutex);
128 
129 	rtw89_leave_ips_by_hwflags(rtwdev);
130 
131 	if (RTW89_CHK_FW_FEATURE(BEACON_FILTER, &rtwdev->fw))
132 		vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER |
133 				     IEEE80211_VIF_SUPPORTS_CQM_RSSI;
134 
135 	rtwvif->rtwdev = rtwdev;
136 	rtwvif->roc.state = RTW89_ROC_IDLE;
137 	rtwvif->offchan = false;
138 	list_add_tail(&rtwvif->list, &rtwdev->rtwvifs_list);
139 	INIT_WORK(&rtwvif->update_beacon_work, rtw89_core_update_beacon_work);
140 	INIT_DELAYED_WORK(&rtwvif->roc.roc_work, rtw89_roc_work);
141 	rtw89_leave_ps_mode(rtwdev);
142 
143 	rtw89_traffic_stats_init(rtwdev, &rtwvif->stats);
144 	rtw89_vif_type_mapping(vif, false);
145 	rtwvif->port = rtw89_core_acquire_bit_map(rtwdev->hw_port,
146 						  RTW89_PORT_NUM);
147 	if (rtwvif->port == RTW89_PORT_NUM) {
148 		ret = -ENOSPC;
149 		list_del_init(&rtwvif->list);
150 		goto out;
151 	}
152 
153 	rtwvif->bcn_hit_cond = 0;
154 	rtwvif->mac_idx = RTW89_MAC_0;
155 	rtwvif->phy_idx = RTW89_PHY_0;
156 	rtwvif->sub_entity_idx = RTW89_SUB_ENTITY_0;
157 	rtwvif->hit_rule = 0;
158 	ether_addr_copy(rtwvif->mac_addr, vif->addr);
159 	INIT_LIST_HEAD(&rtwvif->general_pkt_list);
160 
161 	ret = rtw89_mac_add_vif(rtwdev, rtwvif);
162 	if (ret) {
163 		rtw89_core_release_bit_map(rtwdev->hw_port, rtwvif->port);
164 		list_del_init(&rtwvif->list);
165 		goto out;
166 	}
167 
168 	rtw89_core_txq_init(rtwdev, vif->txq);
169 
170 	rtw89_btc_ntfy_role_info(rtwdev, rtwvif, NULL, BTC_ROLE_START);
171 out:
172 	mutex_unlock(&rtwdev->mutex);
173 
174 	return ret;
175 }
176 
177 static void rtw89_ops_remove_interface(struct ieee80211_hw *hw,
178 				       struct ieee80211_vif *vif)
179 {
180 	struct rtw89_dev *rtwdev = hw->priv;
181 	struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;
182 
183 	rtw89_debug(rtwdev, RTW89_DBG_STATE, "remove vif %pM type %d p2p %d\n",
184 		    vif->addr, vif->type, vif->p2p);
185 
186 	cancel_work_sync(&rtwvif->update_beacon_work);
187 	cancel_delayed_work_sync(&rtwvif->roc.roc_work);
188 
189 	mutex_lock(&rtwdev->mutex);
190 	rtw89_leave_ps_mode(rtwdev);
191 	rtw89_btc_ntfy_role_info(rtwdev, rtwvif, NULL, BTC_ROLE_STOP);
192 	rtw89_mac_remove_vif(rtwdev, rtwvif);
193 	rtw89_core_release_bit_map(rtwdev->hw_port, rtwvif->port);
194 	list_del_init(&rtwvif->list);
195 	rtw89_enter_ips_by_hwflags(rtwdev);
196 
197 	mutex_unlock(&rtwdev->mutex);
198 }
199 
200 static int rtw89_ops_change_interface(struct ieee80211_hw *hw,
201 				      struct ieee80211_vif *vif,
202 				      enum nl80211_iftype type, bool p2p)
203 {
204 	struct rtw89_dev *rtwdev = hw->priv;
205 	int ret;
206 
207 	set_bit(RTW89_FLAG_CHANGING_INTERFACE, rtwdev->flags);
208 
209 	rtw89_debug(rtwdev, RTW89_DBG_STATE, "change vif %pM (%d)->(%d), p2p (%d)->(%d)\n",
210 		    vif->addr, vif->type, type, vif->p2p, p2p);
211 
212 	rtw89_ops_remove_interface(hw, vif);
213 
214 	vif->type = type;
215 	vif->p2p = p2p;
216 
217 	ret = rtw89_ops_add_interface(hw, vif);
218 	if (ret)
219 		rtw89_warn(rtwdev, "failed to change interface %d\n", ret);
220 
221 	clear_bit(RTW89_FLAG_CHANGING_INTERFACE, rtwdev->flags);
222 
223 	return ret;
224 }
225 
226 static void rtw89_ops_configure_filter(struct ieee80211_hw *hw,
227 				       unsigned int changed_flags,
228 				       unsigned int *new_flags,
229 				       u64 multicast)
230 {
231 	struct rtw89_dev *rtwdev = hw->priv;
232 
233 	mutex_lock(&rtwdev->mutex);
234 	rtw89_leave_ps_mode(rtwdev);
235 
236 	*new_flags &= FIF_ALLMULTI | FIF_OTHER_BSS | FIF_FCSFAIL |
237 		      FIF_BCN_PRBRESP_PROMISC | FIF_PROBE_REQ;
238 
239 	if (changed_flags & FIF_ALLMULTI) {
240 		if (*new_flags & FIF_ALLMULTI)
241 			rtwdev->hal.rx_fltr &= ~B_AX_A_MC;
242 		else
243 			rtwdev->hal.rx_fltr |= B_AX_A_MC;
244 	}
245 	if (changed_flags & FIF_FCSFAIL) {
246 		if (*new_flags & FIF_FCSFAIL)
247 			rtwdev->hal.rx_fltr |= B_AX_A_CRC32_ERR;
248 		else
249 			rtwdev->hal.rx_fltr &= ~B_AX_A_CRC32_ERR;
250 	}
251 	if (changed_flags & FIF_OTHER_BSS) {
252 		if (*new_flags & FIF_OTHER_BSS)
253 			rtwdev->hal.rx_fltr &= ~B_AX_A_A1_MATCH;
254 		else
255 			rtwdev->hal.rx_fltr |= B_AX_A_A1_MATCH;
256 	}
257 	if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
258 		if (*new_flags & FIF_BCN_PRBRESP_PROMISC) {
259 			rtwdev->hal.rx_fltr &= ~B_AX_A_BCN_CHK_EN;
260 			rtwdev->hal.rx_fltr &= ~B_AX_A_BC;
261 			rtwdev->hal.rx_fltr &= ~B_AX_A_A1_MATCH;
262 		} else {
263 			rtwdev->hal.rx_fltr |= B_AX_A_BCN_CHK_EN;
264 			rtwdev->hal.rx_fltr |= B_AX_A_BC;
265 			rtwdev->hal.rx_fltr |= B_AX_A_A1_MATCH;
266 		}
267 	}
268 	if (changed_flags & FIF_PROBE_REQ) {
269 		if (*new_flags & FIF_PROBE_REQ) {
270 			rtwdev->hal.rx_fltr &= ~B_AX_A_BC_CAM_MATCH;
271 			rtwdev->hal.rx_fltr &= ~B_AX_A_UC_CAM_MATCH;
272 		} else {
273 			rtwdev->hal.rx_fltr |= B_AX_A_BC_CAM_MATCH;
274 			rtwdev->hal.rx_fltr |= B_AX_A_UC_CAM_MATCH;
275 		}
276 	}
277 
278 	rtw89_write32_mask(rtwdev,
279 			   rtw89_mac_reg_by_idx(R_AX_RX_FLTR_OPT, RTW89_MAC_0),
280 			   B_AX_RX_FLTR_CFG_MASK,
281 			   rtwdev->hal.rx_fltr);
282 	if (!rtwdev->dbcc_en)
283 		goto out;
284 	rtw89_write32_mask(rtwdev,
285 			   rtw89_mac_reg_by_idx(R_AX_RX_FLTR_OPT, RTW89_MAC_1),
286 			   B_AX_RX_FLTR_CFG_MASK,
287 			   rtwdev->hal.rx_fltr);
288 
289 out:
290 	mutex_unlock(&rtwdev->mutex);
291 }
292 
293 static const u8 ac_to_fw_idx[IEEE80211_NUM_ACS] = {
294 	[IEEE80211_AC_VO] = 3,
295 	[IEEE80211_AC_VI] = 2,
296 	[IEEE80211_AC_BE] = 0,
297 	[IEEE80211_AC_BK] = 1,
298 };
299 
300 static u8 rtw89_aifsn_to_aifs(struct rtw89_dev *rtwdev,
301 			      struct rtw89_vif *rtwvif, u8 aifsn)
302 {
303 	struct ieee80211_vif *vif = rtwvif_to_vif(rtwvif);
304 	const struct rtw89_chan *chan = rtw89_chan_get(rtwdev, RTW89_SUB_ENTITY_0);
305 	u8 slot_time;
306 	u8 sifs;
307 
308 	slot_time = vif->bss_conf.use_short_slot ? 9 : 20;
309 	sifs = chan->band_type == RTW89_BAND_5G ? 16 : 10;
310 
311 	return aifsn * slot_time + sifs;
312 }
313 
314 static void ____rtw89_conf_tx_edca(struct rtw89_dev *rtwdev,
315 				   struct rtw89_vif *rtwvif, u16 ac)
316 {
317 	struct ieee80211_tx_queue_params *params = &rtwvif->tx_params[ac];
318 	u32 val;
319 	u8 ecw_max, ecw_min;
320 	u8 aifs;
321 
322 	/* 2^ecw - 1 = cw; ecw = log2(cw + 1) */
323 	ecw_max = ilog2(params->cw_max + 1);
324 	ecw_min = ilog2(params->cw_min + 1);
325 	aifs = rtw89_aifsn_to_aifs(rtwdev, rtwvif, params->aifs);
326 	val = FIELD_PREP(FW_EDCA_PARAM_TXOPLMT_MSK, params->txop) |
327 	      FIELD_PREP(FW_EDCA_PARAM_CWMAX_MSK, ecw_max) |
328 	      FIELD_PREP(FW_EDCA_PARAM_CWMIN_MSK, ecw_min) |
329 	      FIELD_PREP(FW_EDCA_PARAM_AIFS_MSK, aifs);
330 	rtw89_fw_h2c_set_edca(rtwdev, rtwvif, ac_to_fw_idx[ac], val);
331 }
332 
333 static const u32 ac_to_mu_edca_param[IEEE80211_NUM_ACS] = {
334 	[IEEE80211_AC_VO] = R_AX_MUEDCA_VO_PARAM_0,
335 	[IEEE80211_AC_VI] = R_AX_MUEDCA_VI_PARAM_0,
336 	[IEEE80211_AC_BE] = R_AX_MUEDCA_BE_PARAM_0,
337 	[IEEE80211_AC_BK] = R_AX_MUEDCA_BK_PARAM_0,
338 };
339 
340 static void ____rtw89_conf_tx_mu_edca(struct rtw89_dev *rtwdev,
341 				      struct rtw89_vif *rtwvif, u16 ac)
342 {
343 	struct ieee80211_tx_queue_params *params = &rtwvif->tx_params[ac];
344 	struct ieee80211_he_mu_edca_param_ac_rec *mu_edca;
345 	u8 aifs, aifsn;
346 	u16 timer_32us;
347 	u32 reg;
348 	u32 val;
349 
350 	if (!params->mu_edca)
351 		return;
352 
353 	mu_edca = &params->mu_edca_param_rec;
354 	aifsn = FIELD_GET(GENMASK(3, 0), mu_edca->aifsn);
355 	aifs = aifsn ? rtw89_aifsn_to_aifs(rtwdev, rtwvif, aifsn) : 0;
356 	timer_32us = mu_edca->mu_edca_timer << 8;
357 
358 	val = FIELD_PREP(B_AX_MUEDCA_BE_PARAM_0_TIMER_MASK, timer_32us) |
359 	      FIELD_PREP(B_AX_MUEDCA_BE_PARAM_0_CW_MASK, mu_edca->ecw_min_max) |
360 	      FIELD_PREP(B_AX_MUEDCA_BE_PARAM_0_AIFS_MASK, aifs);
361 	reg = rtw89_mac_reg_by_idx(ac_to_mu_edca_param[ac], rtwvif->mac_idx);
362 	rtw89_write32(rtwdev, reg, val);
363 
364 	rtw89_mac_set_hw_muedca_ctrl(rtwdev, rtwvif, true);
365 }
366 
367 static void __rtw89_conf_tx(struct rtw89_dev *rtwdev,
368 			    struct rtw89_vif *rtwvif, u16 ac)
369 {
370 	____rtw89_conf_tx_edca(rtwdev, rtwvif, ac);
371 	____rtw89_conf_tx_mu_edca(rtwdev, rtwvif, ac);
372 }
373 
374 static void rtw89_conf_tx(struct rtw89_dev *rtwdev,
375 			  struct rtw89_vif *rtwvif)
376 {
377 	u16 ac;
378 
379 	for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
380 		__rtw89_conf_tx(rtwdev, rtwvif, ac);
381 }
382 
383 static void rtw89_station_mode_sta_assoc(struct rtw89_dev *rtwdev,
384 					 struct ieee80211_vif *vif,
385 					 struct ieee80211_bss_conf *conf)
386 {
387 	struct ieee80211_sta *sta;
388 
389 	if (vif->type != NL80211_IFTYPE_STATION)
390 		return;
391 
392 	sta = ieee80211_find_sta(vif, conf->bssid);
393 	if (!sta) {
394 		rtw89_err(rtwdev, "can't find sta to set sta_assoc state\n");
395 		return;
396 	}
397 
398 	rtw89_vif_type_mapping(vif, true);
399 
400 	rtw89_core_sta_assoc(rtwdev, vif, sta);
401 }
402 
403 static void rtw89_ops_bss_info_changed(struct ieee80211_hw *hw,
404 				       struct ieee80211_vif *vif,
405 				       struct ieee80211_bss_conf *conf,
406 				       u64 changed)
407 {
408 	struct rtw89_dev *rtwdev = hw->priv;
409 	struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;
410 
411 	mutex_lock(&rtwdev->mutex);
412 	rtw89_leave_ps_mode(rtwdev);
413 
414 	if (changed & BSS_CHANGED_ASSOC) {
415 		if (vif->cfg.assoc) {
416 			rtw89_station_mode_sta_assoc(rtwdev, vif, conf);
417 			rtw89_phy_set_bss_color(rtwdev, vif);
418 			rtw89_chip_cfg_txpwr_ul_tb_offset(rtwdev, vif);
419 			rtw89_mac_port_update(rtwdev, rtwvif);
420 			rtw89_mac_set_he_obss_narrow_bw_ru(rtwdev, vif);
421 		} else {
422 			/* Abort ongoing scan if cancel_scan isn't issued
423 			 * when disconnected by peer
424 			 */
425 			if (rtwdev->scanning)
426 				rtw89_hw_scan_abort(rtwdev, vif);
427 		}
428 	}
429 
430 	if (changed & BSS_CHANGED_BSSID) {
431 		ether_addr_copy(rtwvif->bssid, conf->bssid);
432 		rtw89_cam_bssid_changed(rtwdev, rtwvif);
433 		rtw89_fw_h2c_cam(rtwdev, rtwvif, NULL, NULL);
434 	}
435 
436 	if (changed & BSS_CHANGED_BEACON)
437 		rtw89_fw_h2c_update_beacon(rtwdev, rtwvif);
438 
439 	if (changed & BSS_CHANGED_ERP_SLOT)
440 		rtw89_conf_tx(rtwdev, rtwvif);
441 
442 	if (changed & BSS_CHANGED_HE_BSS_COLOR)
443 		rtw89_phy_set_bss_color(rtwdev, vif);
444 
445 	if (changed & BSS_CHANGED_MU_GROUPS)
446 		rtw89_mac_bf_set_gid_table(rtwdev, vif, conf);
447 
448 	if (changed & BSS_CHANGED_P2P_PS)
449 		rtw89_process_p2p_ps(rtwdev, vif);
450 
451 	if (changed & BSS_CHANGED_CQM)
452 		rtw89_fw_h2c_set_bcn_fltr_cfg(rtwdev, vif, true);
453 
454 	mutex_unlock(&rtwdev->mutex);
455 }
456 
457 static int rtw89_ops_start_ap(struct ieee80211_hw *hw,
458 			      struct ieee80211_vif *vif,
459 			      struct ieee80211_bss_conf *link_conf)
460 {
461 	struct rtw89_dev *rtwdev = hw->priv;
462 	struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;
463 
464 	mutex_lock(&rtwdev->mutex);
465 	ether_addr_copy(rtwvif->bssid, vif->bss_conf.bssid);
466 	rtw89_cam_bssid_changed(rtwdev, rtwvif);
467 	rtw89_mac_port_update(rtwdev, rtwvif);
468 	rtw89_fw_h2c_assoc_cmac_tbl(rtwdev, vif, NULL);
469 	rtw89_fw_h2c_role_maintain(rtwdev, rtwvif, NULL, RTW89_ROLE_TYPE_CHANGE);
470 	rtw89_fw_h2c_join_info(rtwdev, rtwvif, NULL, true);
471 	rtw89_fw_h2c_cam(rtwdev, rtwvif, NULL, NULL);
472 	rtw89_chip_rfk_channel(rtwdev);
473 	mutex_unlock(&rtwdev->mutex);
474 
475 	return 0;
476 }
477 
478 static
479 void rtw89_ops_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
480 		       struct ieee80211_bss_conf *link_conf)
481 {
482 	struct rtw89_dev *rtwdev = hw->priv;
483 	struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;
484 
485 	mutex_lock(&rtwdev->mutex);
486 	rtw89_mac_stop_ap(rtwdev, rtwvif);
487 	rtw89_fw_h2c_assoc_cmac_tbl(rtwdev, vif, NULL);
488 	rtw89_fw_h2c_join_info(rtwdev, rtwvif, NULL, true);
489 	mutex_unlock(&rtwdev->mutex);
490 }
491 
492 static int rtw89_ops_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
493 			     bool set)
494 {
495 	struct rtw89_dev *rtwdev = hw->priv;
496 	struct rtw89_sta *rtwsta = (struct rtw89_sta *)sta->drv_priv;
497 	struct rtw89_vif *rtwvif = rtwsta->rtwvif;
498 
499 	ieee80211_queue_work(rtwdev->hw, &rtwvif->update_beacon_work);
500 
501 	return 0;
502 }
503 
504 static int rtw89_ops_conf_tx(struct ieee80211_hw *hw,
505 			     struct ieee80211_vif *vif,
506 			     unsigned int link_id, u16 ac,
507 			     const struct ieee80211_tx_queue_params *params)
508 {
509 	struct rtw89_dev *rtwdev = hw->priv;
510 	struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;
511 
512 	mutex_lock(&rtwdev->mutex);
513 	rtw89_leave_ps_mode(rtwdev);
514 	rtwvif->tx_params[ac] = *params;
515 	__rtw89_conf_tx(rtwdev, rtwvif, ac);
516 	mutex_unlock(&rtwdev->mutex);
517 
518 	return 0;
519 }
520 
521 static int __rtw89_ops_sta_state(struct ieee80211_hw *hw,
522 				 struct ieee80211_vif *vif,
523 				 struct ieee80211_sta *sta,
524 				 enum ieee80211_sta_state old_state,
525 				 enum ieee80211_sta_state new_state)
526 {
527 	struct rtw89_dev *rtwdev = hw->priv;
528 
529 	if (old_state == IEEE80211_STA_NOTEXIST &&
530 	    new_state == IEEE80211_STA_NONE)
531 		return rtw89_core_sta_add(rtwdev, vif, sta);
532 
533 	if (old_state == IEEE80211_STA_AUTH &&
534 	    new_state == IEEE80211_STA_ASSOC) {
535 		if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
536 			return 0; /* defer to bss_info_changed to have vif info */
537 		return rtw89_core_sta_assoc(rtwdev, vif, sta);
538 	}
539 
540 	if (old_state == IEEE80211_STA_ASSOC &&
541 	    new_state == IEEE80211_STA_AUTH)
542 		return rtw89_core_sta_disassoc(rtwdev, vif, sta);
543 
544 	if (old_state == IEEE80211_STA_AUTH &&
545 	    new_state == IEEE80211_STA_NONE)
546 		return rtw89_core_sta_disconnect(rtwdev, vif, sta);
547 
548 	if (old_state == IEEE80211_STA_NONE &&
549 	    new_state == IEEE80211_STA_NOTEXIST)
550 		return rtw89_core_sta_remove(rtwdev, vif, sta);
551 
552 	return 0;
553 }
554 
555 static int rtw89_ops_sta_state(struct ieee80211_hw *hw,
556 			       struct ieee80211_vif *vif,
557 			       struct ieee80211_sta *sta,
558 			       enum ieee80211_sta_state old_state,
559 			       enum ieee80211_sta_state new_state)
560 {
561 	struct rtw89_dev *rtwdev = hw->priv;
562 	int ret;
563 
564 	mutex_lock(&rtwdev->mutex);
565 	rtw89_leave_ps_mode(rtwdev);
566 	ret = __rtw89_ops_sta_state(hw, vif, sta, old_state, new_state);
567 	mutex_unlock(&rtwdev->mutex);
568 
569 	return ret;
570 }
571 
572 static int rtw89_ops_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
573 			     struct ieee80211_vif *vif,
574 			     struct ieee80211_sta *sta,
575 			     struct ieee80211_key_conf *key)
576 {
577 	struct rtw89_dev *rtwdev = hw->priv;
578 	int ret = 0;
579 
580 	mutex_lock(&rtwdev->mutex);
581 	rtw89_leave_ps_mode(rtwdev);
582 
583 	switch (cmd) {
584 	case SET_KEY:
585 		rtw89_btc_ntfy_specific_packet(rtwdev, PACKET_EAPOL_END);
586 		ret = rtw89_cam_sec_key_add(rtwdev, vif, sta, key);
587 		if (ret && ret != -EOPNOTSUPP) {
588 			rtw89_err(rtwdev, "failed to add key to sec cam\n");
589 			goto out;
590 		}
591 		break;
592 	case DISABLE_KEY:
593 		rtw89_hci_flush_queues(rtwdev, BIT(rtwdev->hw->queues) - 1,
594 				       false);
595 		rtw89_mac_flush_txq(rtwdev, BIT(rtwdev->hw->queues) - 1, false);
596 		ret = rtw89_cam_sec_key_del(rtwdev, vif, sta, key, true);
597 		if (ret) {
598 			rtw89_err(rtwdev, "failed to remove key from sec cam\n");
599 			goto out;
600 		}
601 		break;
602 	}
603 
604 out:
605 	mutex_unlock(&rtwdev->mutex);
606 
607 	return ret;
608 }
609 
610 static int rtw89_ops_ampdu_action(struct ieee80211_hw *hw,
611 				  struct ieee80211_vif *vif,
612 				  struct ieee80211_ampdu_params *params)
613 {
614 	struct rtw89_dev *rtwdev = hw->priv;
615 	struct ieee80211_sta *sta = params->sta;
616 	struct rtw89_sta *rtwsta = (struct rtw89_sta *)sta->drv_priv;
617 	u16 tid = params->tid;
618 	struct ieee80211_txq *txq = sta->txq[tid];
619 	struct rtw89_txq *rtwtxq = (struct rtw89_txq *)txq->drv_priv;
620 
621 	switch (params->action) {
622 	case IEEE80211_AMPDU_TX_START:
623 		return IEEE80211_AMPDU_TX_START_IMMEDIATE;
624 	case IEEE80211_AMPDU_TX_STOP_CONT:
625 	case IEEE80211_AMPDU_TX_STOP_FLUSH:
626 	case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
627 		mutex_lock(&rtwdev->mutex);
628 		clear_bit(RTW89_TXQ_F_AMPDU, &rtwtxq->flags);
629 		mutex_unlock(&rtwdev->mutex);
630 		ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
631 		break;
632 	case IEEE80211_AMPDU_TX_OPERATIONAL:
633 		mutex_lock(&rtwdev->mutex);
634 		set_bit(RTW89_TXQ_F_AMPDU, &rtwtxq->flags);
635 		rtwsta->ampdu_params[tid].agg_num = params->buf_size;
636 		rtwsta->ampdu_params[tid].amsdu = params->amsdu;
637 		rtw89_leave_ps_mode(rtwdev);
638 		mutex_unlock(&rtwdev->mutex);
639 		break;
640 	case IEEE80211_AMPDU_RX_START:
641 		mutex_lock(&rtwdev->mutex);
642 		rtw89_fw_h2c_ba_cam(rtwdev, rtwsta, true, params);
643 		mutex_unlock(&rtwdev->mutex);
644 		break;
645 	case IEEE80211_AMPDU_RX_STOP:
646 		mutex_lock(&rtwdev->mutex);
647 		rtw89_fw_h2c_ba_cam(rtwdev, rtwsta, false, params);
648 		mutex_unlock(&rtwdev->mutex);
649 		break;
650 	default:
651 		WARN_ON(1);
652 		return -ENOTSUPP;
653 	}
654 
655 	return 0;
656 }
657 
658 static int rtw89_ops_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
659 {
660 	struct rtw89_dev *rtwdev = hw->priv;
661 
662 	mutex_lock(&rtwdev->mutex);
663 	rtw89_leave_ps_mode(rtwdev);
664 	if (test_bit(RTW89_FLAG_POWERON, rtwdev->flags))
665 		rtw89_mac_update_rts_threshold(rtwdev, RTW89_MAC_0);
666 	mutex_unlock(&rtwdev->mutex);
667 
668 	return 0;
669 }
670 
671 static void rtw89_ops_sta_statistics(struct ieee80211_hw *hw,
672 				     struct ieee80211_vif *vif,
673 				     struct ieee80211_sta *sta,
674 				     struct station_info *sinfo)
675 {
676 	struct rtw89_sta *rtwsta = (struct rtw89_sta *)sta->drv_priv;
677 
678 	sinfo->txrate = rtwsta->ra_report.txrate;
679 	sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE);
680 }
681 
682 static
683 void __rtw89_drop_packets(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif)
684 {
685 	struct rtw89_vif *rtwvif;
686 
687 	if (vif) {
688 		rtwvif = (struct rtw89_vif *)vif->drv_priv;
689 		rtw89_mac_pkt_drop_vif(rtwdev, rtwvif);
690 	} else {
691 		rtw89_for_each_rtwvif(rtwdev, rtwvif)
692 			rtw89_mac_pkt_drop_vif(rtwdev, rtwvif);
693 	}
694 }
695 
696 static void rtw89_ops_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
697 			    u32 queues, bool drop)
698 {
699 	struct rtw89_dev *rtwdev = hw->priv;
700 
701 	mutex_lock(&rtwdev->mutex);
702 	rtw89_leave_lps(rtwdev);
703 	rtw89_hci_flush_queues(rtwdev, queues, drop);
704 
705 	if (drop && !RTW89_CHK_FW_FEATURE(NO_PACKET_DROP, &rtwdev->fw))
706 		__rtw89_drop_packets(rtwdev, vif);
707 	else
708 		rtw89_mac_flush_txq(rtwdev, queues, drop);
709 
710 	mutex_unlock(&rtwdev->mutex);
711 }
712 
713 struct rtw89_iter_bitrate_mask_data {
714 	struct rtw89_dev *rtwdev;
715 	struct ieee80211_vif *vif;
716 	const struct cfg80211_bitrate_mask *mask;
717 };
718 
719 static void rtw89_ra_mask_info_update_iter(void *data, struct ieee80211_sta *sta)
720 {
721 	struct rtw89_iter_bitrate_mask_data *br_data = data;
722 	struct rtw89_sta *rtwsta = (struct rtw89_sta *)sta->drv_priv;
723 	struct ieee80211_vif *vif = rtwvif_to_vif(rtwsta->rtwvif);
724 
725 	if (vif != br_data->vif || vif->p2p)
726 		return;
727 
728 	rtwsta->use_cfg_mask = true;
729 	rtwsta->mask = *br_data->mask;
730 	rtw89_phy_ra_updata_sta(br_data->rtwdev, sta, IEEE80211_RC_SUPP_RATES_CHANGED);
731 }
732 
733 static void rtw89_ra_mask_info_update(struct rtw89_dev *rtwdev,
734 				      struct ieee80211_vif *vif,
735 				      const struct cfg80211_bitrate_mask *mask)
736 {
737 	struct rtw89_iter_bitrate_mask_data br_data = { .rtwdev = rtwdev,
738 							.vif = vif,
739 							.mask = mask};
740 
741 	ieee80211_iterate_stations_atomic(rtwdev->hw, rtw89_ra_mask_info_update_iter,
742 					  &br_data);
743 }
744 
745 static int rtw89_ops_set_bitrate_mask(struct ieee80211_hw *hw,
746 				      struct ieee80211_vif *vif,
747 				      const struct cfg80211_bitrate_mask *mask)
748 {
749 	struct rtw89_dev *rtwdev = hw->priv;
750 
751 	mutex_lock(&rtwdev->mutex);
752 	rtw89_phy_rate_pattern_vif(rtwdev, vif, mask);
753 	rtw89_ra_mask_info_update(rtwdev, vif, mask);
754 	mutex_unlock(&rtwdev->mutex);
755 
756 	return 0;
757 }
758 
759 static
760 int rtw89_ops_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
761 {
762 	struct rtw89_dev *rtwdev = hw->priv;
763 	struct rtw89_hal *hal = &rtwdev->hal;
764 
765 	if (rx_ant != hw->wiphy->available_antennas_rx && rx_ant != hal->antenna_rx)
766 		return -EINVAL;
767 
768 	mutex_lock(&rtwdev->mutex);
769 	hal->antenna_tx = tx_ant;
770 	hal->antenna_rx = rx_ant;
771 	hal->tx_path_diversity = false;
772 	mutex_unlock(&rtwdev->mutex);
773 
774 	return 0;
775 }
776 
777 static
778 int rtw89_ops_get_antenna(struct ieee80211_hw *hw,  u32 *tx_ant, u32 *rx_ant)
779 {
780 	struct rtw89_dev *rtwdev = hw->priv;
781 	struct rtw89_hal *hal = &rtwdev->hal;
782 
783 	*tx_ant = hal->antenna_tx;
784 	*rx_ant = hal->antenna_rx;
785 
786 	return 0;
787 }
788 
789 static void rtw89_ops_sw_scan_start(struct ieee80211_hw *hw,
790 				    struct ieee80211_vif *vif,
791 				    const u8 *mac_addr)
792 {
793 	struct rtw89_dev *rtwdev = hw->priv;
794 	struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;
795 
796 	mutex_lock(&rtwdev->mutex);
797 	rtw89_core_scan_start(rtwdev, rtwvif, mac_addr, false);
798 	mutex_unlock(&rtwdev->mutex);
799 }
800 
801 static void rtw89_ops_sw_scan_complete(struct ieee80211_hw *hw,
802 				       struct ieee80211_vif *vif)
803 {
804 	struct rtw89_dev *rtwdev = hw->priv;
805 
806 	mutex_lock(&rtwdev->mutex);
807 	rtw89_core_scan_complete(rtwdev, vif, false);
808 	mutex_unlock(&rtwdev->mutex);
809 }
810 
811 static void rtw89_ops_reconfig_complete(struct ieee80211_hw *hw,
812 					enum ieee80211_reconfig_type reconfig_type)
813 {
814 	struct rtw89_dev *rtwdev = hw->priv;
815 
816 	if (reconfig_type == IEEE80211_RECONFIG_TYPE_RESTART)
817 		rtw89_ser_recfg_done(rtwdev);
818 }
819 
820 static int rtw89_ops_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
821 			     struct ieee80211_scan_request *req)
822 {
823 	struct rtw89_dev *rtwdev = hw->priv;
824 	struct rtw89_vif *rtwvif = vif_to_rtwvif_safe(vif);
825 	int ret = 0;
826 
827 	if (!RTW89_CHK_FW_FEATURE(SCAN_OFFLOAD, &rtwdev->fw))
828 		return 1;
829 
830 	if (rtwdev->scanning || rtwvif->offchan)
831 		return -EBUSY;
832 
833 	mutex_lock(&rtwdev->mutex);
834 	rtw89_hw_scan_start(rtwdev, vif, req);
835 	ret = rtw89_hw_scan_offload(rtwdev, vif, true);
836 	if (ret) {
837 		rtw89_hw_scan_abort(rtwdev, vif);
838 		rtw89_err(rtwdev, "HW scan failed with status: %d\n", ret);
839 	}
840 	mutex_unlock(&rtwdev->mutex);
841 
842 	return ret;
843 }
844 
845 static void rtw89_ops_cancel_hw_scan(struct ieee80211_hw *hw,
846 				     struct ieee80211_vif *vif)
847 {
848 	struct rtw89_dev *rtwdev = hw->priv;
849 
850 	if (!RTW89_CHK_FW_FEATURE(SCAN_OFFLOAD, &rtwdev->fw))
851 		return;
852 
853 	if (!rtwdev->scanning)
854 		return;
855 
856 	mutex_lock(&rtwdev->mutex);
857 	rtw89_hw_scan_abort(rtwdev, vif);
858 	mutex_unlock(&rtwdev->mutex);
859 }
860 
861 static void rtw89_ops_sta_rc_update(struct ieee80211_hw *hw,
862 				    struct ieee80211_vif *vif,
863 				    struct ieee80211_sta *sta, u32 changed)
864 {
865 	struct rtw89_dev *rtwdev = hw->priv;
866 
867 	rtw89_phy_ra_updata_sta(rtwdev, sta, changed);
868 }
869 
870 static int rtw89_ops_add_chanctx(struct ieee80211_hw *hw,
871 				 struct ieee80211_chanctx_conf *ctx)
872 {
873 	struct rtw89_dev *rtwdev = hw->priv;
874 	int ret;
875 
876 	mutex_lock(&rtwdev->mutex);
877 	ret = rtw89_chanctx_ops_add(rtwdev, ctx);
878 	mutex_unlock(&rtwdev->mutex);
879 
880 	return ret;
881 }
882 
883 static void rtw89_ops_remove_chanctx(struct ieee80211_hw *hw,
884 				     struct ieee80211_chanctx_conf *ctx)
885 {
886 	struct rtw89_dev *rtwdev = hw->priv;
887 
888 	mutex_lock(&rtwdev->mutex);
889 	rtw89_chanctx_ops_remove(rtwdev, ctx);
890 	mutex_unlock(&rtwdev->mutex);
891 }
892 
893 static void rtw89_ops_change_chanctx(struct ieee80211_hw *hw,
894 				     struct ieee80211_chanctx_conf *ctx,
895 				     u32 changed)
896 {
897 	struct rtw89_dev *rtwdev = hw->priv;
898 
899 	mutex_lock(&rtwdev->mutex);
900 	rtw89_chanctx_ops_change(rtwdev, ctx, changed);
901 	mutex_unlock(&rtwdev->mutex);
902 }
903 
904 static int rtw89_ops_assign_vif_chanctx(struct ieee80211_hw *hw,
905 					struct ieee80211_vif *vif,
906 					struct ieee80211_bss_conf *link_conf,
907 					struct ieee80211_chanctx_conf *ctx)
908 {
909 	struct rtw89_dev *rtwdev = hw->priv;
910 	struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;
911 	int ret;
912 
913 	mutex_lock(&rtwdev->mutex);
914 	ret = rtw89_chanctx_ops_assign_vif(rtwdev, rtwvif, ctx);
915 	mutex_unlock(&rtwdev->mutex);
916 
917 	return ret;
918 }
919 
920 static void rtw89_ops_unassign_vif_chanctx(struct ieee80211_hw *hw,
921 					   struct ieee80211_vif *vif,
922 					   struct ieee80211_bss_conf *link_conf,
923 					   struct ieee80211_chanctx_conf *ctx)
924 {
925 	struct rtw89_dev *rtwdev = hw->priv;
926 	struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;
927 
928 	mutex_lock(&rtwdev->mutex);
929 	rtw89_chanctx_ops_unassign_vif(rtwdev, rtwvif, ctx);
930 	mutex_unlock(&rtwdev->mutex);
931 }
932 
933 static int rtw89_ops_remain_on_channel(struct ieee80211_hw *hw,
934 				       struct ieee80211_vif *vif,
935 				       struct ieee80211_channel *chan,
936 				       int duration,
937 				       enum ieee80211_roc_type type)
938 {
939 	struct rtw89_dev *rtwdev = hw->priv;
940 	struct rtw89_vif *rtwvif = vif_to_rtwvif_safe(vif);
941 	struct rtw89_roc *roc = &rtwvif->roc;
942 
943 	if (!vif)
944 		return -EINVAL;
945 
946 	mutex_lock(&rtwdev->mutex);
947 
948 	if (roc->state != RTW89_ROC_IDLE) {
949 		mutex_unlock(&rtwdev->mutex);
950 		return -EBUSY;
951 	}
952 
953 	if (rtwdev->scanning)
954 		rtw89_hw_scan_abort(rtwdev, vif);
955 
956 	if (type == IEEE80211_ROC_TYPE_MGMT_TX)
957 		roc->state = RTW89_ROC_MGMT;
958 	else
959 		roc->state = RTW89_ROC_NORMAL;
960 
961 	roc->duration = duration;
962 	roc->chan = *chan;
963 	roc->type = type;
964 
965 	rtw89_roc_start(rtwdev, rtwvif);
966 
967 	mutex_unlock(&rtwdev->mutex);
968 
969 	return 0;
970 }
971 
972 static int rtw89_ops_cancel_remain_on_channel(struct ieee80211_hw *hw,
973 					      struct ieee80211_vif *vif)
974 {
975 	struct rtw89_dev *rtwdev = hw->priv;
976 	struct rtw89_vif *rtwvif = vif_to_rtwvif_safe(vif);
977 
978 	if (!rtwvif)
979 		return -EINVAL;
980 
981 	cancel_delayed_work_sync(&rtwvif->roc.roc_work);
982 
983 	mutex_lock(&rtwdev->mutex);
984 	rtw89_roc_end(rtwdev, rtwvif);
985 	mutex_unlock(&rtwdev->mutex);
986 
987 	return 0;
988 }
989 
990 static void rtw89_set_tid_config_iter(void *data, struct ieee80211_sta *sta)
991 {
992 	struct cfg80211_tid_config *tid_config = data;
993 	struct rtw89_sta *rtwsta = (struct rtw89_sta *)sta->drv_priv;
994 	struct rtw89_dev *rtwdev = rtwsta->rtwvif->rtwdev;
995 
996 	rtw89_core_set_tid_config(rtwdev, sta, tid_config);
997 }
998 
999 static int rtw89_ops_set_tid_config(struct ieee80211_hw *hw,
1000 				    struct ieee80211_vif *vif,
1001 				    struct ieee80211_sta *sta,
1002 				    struct cfg80211_tid_config *tid_config)
1003 {
1004 	struct rtw89_dev *rtwdev = hw->priv;
1005 
1006 	mutex_lock(&rtwdev->mutex);
1007 	if (sta)
1008 		rtw89_core_set_tid_config(rtwdev, sta, tid_config);
1009 	else
1010 		ieee80211_iterate_stations_atomic(rtwdev->hw,
1011 						  rtw89_set_tid_config_iter,
1012 						  tid_config);
1013 	mutex_unlock(&rtwdev->mutex);
1014 
1015 	return 0;
1016 }
1017 
1018 #ifdef CONFIG_PM
1019 static int rtw89_ops_suspend(struct ieee80211_hw *hw,
1020 			     struct cfg80211_wowlan *wowlan)
1021 {
1022 	struct rtw89_dev *rtwdev = hw->priv;
1023 	int ret;
1024 
1025 	set_bit(RTW89_FLAG_FORBIDDEN_TRACK_WROK, rtwdev->flags);
1026 	cancel_delayed_work_sync(&rtwdev->track_work);
1027 
1028 	mutex_lock(&rtwdev->mutex);
1029 	ret = rtw89_wow_suspend(rtwdev, wowlan);
1030 	mutex_unlock(&rtwdev->mutex);
1031 
1032 	if (ret) {
1033 		rtw89_warn(rtwdev, "failed to suspend for wow %d\n", ret);
1034 		clear_bit(RTW89_FLAG_FORBIDDEN_TRACK_WROK, rtwdev->flags);
1035 		return 1;
1036 	}
1037 
1038 	return 0;
1039 }
1040 
1041 static int rtw89_ops_resume(struct ieee80211_hw *hw)
1042 {
1043 	struct rtw89_dev *rtwdev = hw->priv;
1044 	int ret;
1045 
1046 	mutex_lock(&rtwdev->mutex);
1047 	ret = rtw89_wow_resume(rtwdev);
1048 	if (ret)
1049 		rtw89_warn(rtwdev, "failed to resume for wow %d\n", ret);
1050 	mutex_unlock(&rtwdev->mutex);
1051 
1052 	clear_bit(RTW89_FLAG_FORBIDDEN_TRACK_WROK, rtwdev->flags);
1053 	ieee80211_queue_delayed_work(rtwdev->hw, &rtwdev->track_work,
1054 				     RTW89_TRACK_WORK_PERIOD);
1055 
1056 	return ret ? 1 : 0;
1057 }
1058 
1059 static void rtw89_ops_set_wakeup(struct ieee80211_hw *hw, bool enabled)
1060 {
1061 	struct rtw89_dev *rtwdev = hw->priv;
1062 
1063 	device_set_wakeup_enable(rtwdev->dev, enabled);
1064 }
1065 #endif
1066 
1067 const struct ieee80211_ops rtw89_ops = {
1068 	.tx			= rtw89_ops_tx,
1069 	.wake_tx_queue		= rtw89_ops_wake_tx_queue,
1070 	.start			= rtw89_ops_start,
1071 	.stop			= rtw89_ops_stop,
1072 	.config			= rtw89_ops_config,
1073 	.add_interface		= rtw89_ops_add_interface,
1074 	.change_interface       = rtw89_ops_change_interface,
1075 	.remove_interface	= rtw89_ops_remove_interface,
1076 	.configure_filter	= rtw89_ops_configure_filter,
1077 	.bss_info_changed	= rtw89_ops_bss_info_changed,
1078 	.start_ap		= rtw89_ops_start_ap,
1079 	.stop_ap		= rtw89_ops_stop_ap,
1080 	.set_tim		= rtw89_ops_set_tim,
1081 	.conf_tx		= rtw89_ops_conf_tx,
1082 	.sta_state		= rtw89_ops_sta_state,
1083 	.set_key		= rtw89_ops_set_key,
1084 	.ampdu_action		= rtw89_ops_ampdu_action,
1085 	.set_rts_threshold	= rtw89_ops_set_rts_threshold,
1086 	.sta_statistics		= rtw89_ops_sta_statistics,
1087 	.flush			= rtw89_ops_flush,
1088 	.set_bitrate_mask	= rtw89_ops_set_bitrate_mask,
1089 	.set_antenna		= rtw89_ops_set_antenna,
1090 	.get_antenna		= rtw89_ops_get_antenna,
1091 	.sw_scan_start		= rtw89_ops_sw_scan_start,
1092 	.sw_scan_complete	= rtw89_ops_sw_scan_complete,
1093 	.reconfig_complete	= rtw89_ops_reconfig_complete,
1094 	.hw_scan		= rtw89_ops_hw_scan,
1095 	.cancel_hw_scan		= rtw89_ops_cancel_hw_scan,
1096 	.add_chanctx		= rtw89_ops_add_chanctx,
1097 	.remove_chanctx		= rtw89_ops_remove_chanctx,
1098 	.change_chanctx		= rtw89_ops_change_chanctx,
1099 	.assign_vif_chanctx	= rtw89_ops_assign_vif_chanctx,
1100 	.unassign_vif_chanctx	= rtw89_ops_unassign_vif_chanctx,
1101 	.remain_on_channel		= rtw89_ops_remain_on_channel,
1102 	.cancel_remain_on_channel	= rtw89_ops_cancel_remain_on_channel,
1103 	.set_sar_specs		= rtw89_ops_set_sar_specs,
1104 	.sta_rc_update		= rtw89_ops_sta_rc_update,
1105 	.set_tid_config		= rtw89_ops_set_tid_config,
1106 #ifdef CONFIG_PM
1107 	.suspend		= rtw89_ops_suspend,
1108 	.resume			= rtw89_ops_resume,
1109 	.set_wakeup		= rtw89_ops_set_wakeup,
1110 #endif
1111 };
1112 EXPORT_SYMBOL(rtw89_ops);
1113