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