1 // SPDX-License-Identifier: ISC
2 /* Copyright (C) 2019 MediaTek Inc.
3  *
4  * Author: Roy Luo <royluo@google.com>
5  *         Ryder Lee <ryder.lee@mediatek.com>
6  *         Felix Fietkau <nbd@nbd.name>
7  *         Lorenzo Bianconi <lorenzo@kernel.org>
8  */
9 
10 #include <linux/etherdevice.h>
11 #include <linux/module.h>
12 #include "mt7615.h"
13 #include "mcu.h"
14 
15 static bool mt7615_dev_running(struct mt7615_dev *dev)
16 {
17 	struct mt7615_phy *phy;
18 
19 	if (test_bit(MT76_STATE_RUNNING, &dev->mphy.state))
20 		return true;
21 
22 	phy = mt7615_ext_phy(dev);
23 
24 	return phy && test_bit(MT76_STATE_RUNNING, &phy->mt76->state);
25 }
26 
27 static int mt7615_start(struct ieee80211_hw *hw)
28 {
29 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
30 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
31 	bool running;
32 
33 	if (!mt7615_wait_for_mcu_init(dev))
34 		return -EIO;
35 
36 	mt7615_mutex_acquire(dev);
37 
38 	running = mt7615_dev_running(dev);
39 
40 	if (!running) {
41 		mt7615_mcu_set_pm(dev, 0, 0);
42 		mt76_connac_mcu_set_mac_enable(&dev->mt76, 0, true, false);
43 		mt7615_mac_enable_nf(dev, 0);
44 	}
45 
46 	if (phy != &dev->phy) {
47 		mt7615_mcu_set_pm(dev, 1, 0);
48 		mt76_connac_mcu_set_mac_enable(&dev->mt76, 1, true, false);
49 		mt7615_mac_enable_nf(dev, 1);
50 	}
51 
52 	if (mt7615_firmware_offload(dev))
53 		mt76_connac_mcu_set_channel_domain(phy->mt76);
54 
55 	mt7615_mcu_set_chan_info(phy, MCU_EXT_CMD_SET_RX_PATH);
56 
57 	set_bit(MT76_STATE_RUNNING, &phy->mt76->state);
58 
59 	ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work,
60 				     MT7615_WATCHDOG_TIME);
61 
62 	if (!running)
63 		mt7615_mac_reset_counters(dev);
64 
65 	mt7615_mutex_release(dev);
66 
67 	return 0;
68 }
69 
70 static void mt7615_stop(struct ieee80211_hw *hw)
71 {
72 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
73 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
74 
75 	cancel_delayed_work_sync(&phy->mt76->mac_work);
76 	del_timer_sync(&phy->roc_timer);
77 	cancel_work_sync(&phy->roc_work);
78 
79 	cancel_delayed_work_sync(&dev->pm.ps_work);
80 	cancel_work_sync(&dev->pm.wake_work);
81 
82 	mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
83 
84 	mt7615_mutex_acquire(dev);
85 
86 	mt76_testmode_reset(phy->mt76, true);
87 
88 	clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
89 	cancel_delayed_work_sync(&phy->scan_work);
90 
91 	if (phy != &dev->phy) {
92 		mt7615_mcu_set_pm(dev, 1, 1);
93 		mt76_connac_mcu_set_mac_enable(&dev->mt76, 1, false, false);
94 	}
95 
96 	if (!mt7615_dev_running(dev)) {
97 		mt7615_mcu_set_pm(dev, 0, 1);
98 		mt76_connac_mcu_set_mac_enable(&dev->mt76, 0, false, false);
99 	}
100 
101 	mt7615_mutex_release(dev);
102 }
103 
104 static inline int get_free_idx(u32 mask, u8 start, u8 end)
105 {
106 	return ffs(~mask & GENMASK(end, start));
107 }
108 
109 static int get_omac_idx(enum nl80211_iftype type, u64 mask)
110 {
111 	int i;
112 
113 	switch (type) {
114 	case NL80211_IFTYPE_MESH_POINT:
115 	case NL80211_IFTYPE_ADHOC:
116 	case NL80211_IFTYPE_STATION:
117 		/* prefer hw bssid slot 1-3 */
118 		i = get_free_idx(mask, HW_BSSID_1, HW_BSSID_3);
119 		if (i)
120 			return i - 1;
121 
122 		if (type != NL80211_IFTYPE_STATION)
123 			break;
124 
125 		/* next, try to find a free repeater entry for the sta */
126 		i = get_free_idx(mask >> REPEATER_BSSID_START, 0,
127 				 REPEATER_BSSID_MAX - REPEATER_BSSID_START);
128 		if (i)
129 			return i + 32 - 1;
130 
131 		i = get_free_idx(mask, EXT_BSSID_1, EXT_BSSID_MAX);
132 		if (i)
133 			return i - 1;
134 
135 		if (~mask & BIT(HW_BSSID_0))
136 			return HW_BSSID_0;
137 
138 		break;
139 	case NL80211_IFTYPE_MONITOR:
140 	case NL80211_IFTYPE_AP:
141 		/* ap uses hw bssid 0 and ext bssid */
142 		if (~mask & BIT(HW_BSSID_0))
143 			return HW_BSSID_0;
144 
145 		i = get_free_idx(mask, EXT_BSSID_1, EXT_BSSID_MAX);
146 		if (i)
147 			return i - 1;
148 
149 		break;
150 	default:
151 		WARN_ON(1);
152 		break;
153 	}
154 
155 	return -1;
156 }
157 
158 static int mt7615_add_interface(struct ieee80211_hw *hw,
159 				struct ieee80211_vif *vif)
160 {
161 	struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
162 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
163 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
164 	struct mt76_txq *mtxq;
165 	bool ext_phy = phy != &dev->phy;
166 	int idx, ret = 0;
167 
168 	mt7615_mutex_acquire(dev);
169 
170 	mt76_testmode_reset(phy->mt76, true);
171 
172 	if (vif->type == NL80211_IFTYPE_MONITOR &&
173 	    is_zero_ether_addr(vif->addr))
174 		phy->monitor_vif = vif;
175 
176 	mvif->mt76.idx = ffs(~dev->mt76.vif_mask) - 1;
177 	if (mvif->mt76.idx >= MT7615_MAX_INTERFACES) {
178 		ret = -ENOSPC;
179 		goto out;
180 	}
181 
182 	idx = get_omac_idx(vif->type, dev->omac_mask);
183 	if (idx < 0) {
184 		ret = -ENOSPC;
185 		goto out;
186 	}
187 	mvif->mt76.omac_idx = idx;
188 
189 	mvif->mt76.band_idx = ext_phy;
190 	if (mt7615_ext_phy(dev))
191 		mvif->mt76.wmm_idx = ext_phy * (MT7615_MAX_WMM_SETS / 2) +
192 				mvif->mt76.idx % (MT7615_MAX_WMM_SETS / 2);
193 	else
194 		mvif->mt76.wmm_idx = mvif->mt76.idx % MT7615_MAX_WMM_SETS;
195 
196 	dev->mt76.vif_mask |= BIT(mvif->mt76.idx);
197 	dev->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
198 	phy->omac_mask |= BIT_ULL(mvif->mt76.omac_idx);
199 
200 	mt7615_mcu_set_dbdc(dev);
201 
202 	idx = MT7615_WTBL_RESERVED - mvif->mt76.idx;
203 
204 	INIT_LIST_HEAD(&mvif->sta.poll_list);
205 	mvif->sta.wcid.idx = idx;
206 	mvif->sta.wcid.ext_phy = mvif->mt76.band_idx;
207 	mvif->sta.wcid.hw_key_idx = -1;
208 	mt7615_mac_wtbl_update(dev, idx,
209 			       MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
210 
211 	rcu_assign_pointer(dev->mt76.wcid[idx], &mvif->sta.wcid);
212 	if (vif->txq) {
213 		mtxq = (struct mt76_txq *)vif->txq->drv_priv;
214 		mtxq->wcid = &mvif->sta.wcid;
215 	}
216 
217 	ret = mt7615_mcu_add_dev_info(phy, vif, true);
218 	if (ret)
219 		goto out;
220 
221 	mt7615_mac_set_beacon_filter(phy, vif, true);
222 out:
223 	mt7615_mutex_release(dev);
224 
225 	return ret;
226 }
227 
228 static void mt7615_remove_interface(struct ieee80211_hw *hw,
229 				    struct ieee80211_vif *vif)
230 {
231 	struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
232 	struct mt7615_sta *msta = &mvif->sta;
233 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
234 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
235 	int idx = msta->wcid.idx;
236 
237 	/* TODO: disable beacon for the bss */
238 
239 	mt7615_mutex_acquire(dev);
240 
241 	mt76_testmode_reset(phy->mt76, true);
242 	if (vif == phy->monitor_vif)
243 	    phy->monitor_vif = NULL;
244 
245 	mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->wcid);
246 
247 	mt7615_mac_set_beacon_filter(phy, vif, false);
248 	mt7615_mcu_add_dev_info(phy, vif, false);
249 
250 	rcu_assign_pointer(dev->mt76.wcid[idx], NULL);
251 
252 	dev->mt76.vif_mask &= ~BIT(mvif->mt76.idx);
253 	dev->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx);
254 	phy->omac_mask &= ~BIT_ULL(mvif->mt76.omac_idx);
255 
256 	mt7615_mutex_release(dev);
257 
258 	spin_lock_bh(&dev->sta_poll_lock);
259 	if (!list_empty(&msta->poll_list))
260 		list_del_init(&msta->poll_list);
261 	spin_unlock_bh(&dev->sta_poll_lock);
262 }
263 
264 static void mt7615_init_dfs_state(struct mt7615_phy *phy)
265 {
266 	struct mt76_phy *mphy = phy->mt76;
267 	struct ieee80211_hw *hw = mphy->hw;
268 	struct cfg80211_chan_def *chandef = &hw->conf.chandef;
269 
270 	if (hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
271 		return;
272 
273 	if (!(chandef->chan->flags & IEEE80211_CHAN_RADAR))
274 		return;
275 
276 	if (mphy->chandef.chan->center_freq == chandef->chan->center_freq &&
277 	    mphy->chandef.width == chandef->width)
278 		return;
279 
280 	phy->dfs_state = -1;
281 }
282 
283 int mt7615_set_channel(struct mt7615_phy *phy)
284 {
285 	struct mt7615_dev *dev = phy->dev;
286 	bool ext_phy = phy != &dev->phy;
287 	int ret;
288 
289 	cancel_delayed_work_sync(&phy->mt76->mac_work);
290 
291 	mt7615_mutex_acquire(dev);
292 
293 	set_bit(MT76_RESET, &phy->mt76->state);
294 
295 	mt7615_init_dfs_state(phy);
296 	mt76_set_channel(phy->mt76);
297 
298 	if (is_mt7615(&dev->mt76) && dev->flash_eeprom) {
299 		mt7615_mcu_apply_rx_dcoc(phy);
300 		mt7615_mcu_apply_tx_dpd(phy);
301 	}
302 
303 	ret = mt7615_mcu_set_chan_info(phy, MCU_EXT_CMD_CHANNEL_SWITCH);
304 	if (ret)
305 		goto out;
306 
307 	mt7615_mac_set_timing(phy);
308 	ret = mt7615_dfs_init_radar_detector(phy);
309 	mt7615_mac_cca_stats_reset(phy);
310 	mt7615_mcu_set_sku_en(phy, true);
311 
312 	mt7615_mac_reset_counters(dev);
313 	phy->noise = 0;
314 	phy->chfreq = mt76_rr(dev, MT_CHFREQ(ext_phy));
315 
316 out:
317 	clear_bit(MT76_RESET, &phy->mt76->state);
318 
319 	mt7615_mutex_release(dev);
320 
321 	mt76_txq_schedule_all(phy->mt76);
322 
323 	if (!mt76_testmode_enabled(phy->mt76))
324 		ieee80211_queue_delayed_work(phy->mt76->hw,
325 					     &phy->mt76->mac_work,
326 					     MT7615_WATCHDOG_TIME);
327 
328 	return ret;
329 }
330 
331 static int mt7615_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
332 			  struct ieee80211_vif *vif, struct ieee80211_sta *sta,
333 			  struct ieee80211_key_conf *key)
334 {
335 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
336 	struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
337 	struct mt7615_sta *msta = sta ? (struct mt7615_sta *)sta->drv_priv :
338 				  &mvif->sta;
339 	struct mt76_wcid *wcid = &msta->wcid;
340 	int idx = key->keyidx, err;
341 
342 	/* The hardware does not support per-STA RX GTK, fallback
343 	 * to software mode for these.
344 	 */
345 	if ((vif->type == NL80211_IFTYPE_ADHOC ||
346 	     vif->type == NL80211_IFTYPE_MESH_POINT) &&
347 	    (key->cipher == WLAN_CIPHER_SUITE_TKIP ||
348 	     key->cipher == WLAN_CIPHER_SUITE_CCMP) &&
349 	    !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
350 		return -EOPNOTSUPP;
351 
352 	/* fall back to sw encryption for unsupported ciphers */
353 	switch (key->cipher) {
354 	case WLAN_CIPHER_SUITE_AES_CMAC:
355 		key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIE;
356 		break;
357 	case WLAN_CIPHER_SUITE_TKIP:
358 	case WLAN_CIPHER_SUITE_CCMP:
359 	case WLAN_CIPHER_SUITE_CCMP_256:
360 	case WLAN_CIPHER_SUITE_GCMP:
361 	case WLAN_CIPHER_SUITE_GCMP_256:
362 	case WLAN_CIPHER_SUITE_SMS4:
363 		break;
364 	case WLAN_CIPHER_SUITE_WEP40:
365 	case WLAN_CIPHER_SUITE_WEP104:
366 	default:
367 		return -EOPNOTSUPP;
368 	}
369 
370 	mt7615_mutex_acquire(dev);
371 
372 	if (cmd == SET_KEY) {
373 		key->hw_key_idx = wcid->idx;
374 		wcid->hw_key_idx = idx;
375 	} else if (idx == wcid->hw_key_idx) {
376 		wcid->hw_key_idx = -1;
377 	}
378 	mt76_wcid_key_setup(&dev->mt76, wcid,
379 			    cmd == SET_KEY ? key : NULL);
380 
381 	if (mt76_is_mmio(&dev->mt76))
382 		err = mt7615_mac_wtbl_set_key(dev, wcid, key, cmd);
383 	else
384 		err = __mt7615_mac_wtbl_set_key(dev, wcid, key, cmd);
385 
386 	mt7615_mutex_release(dev);
387 
388 	return err;
389 }
390 
391 static int mt7615_config(struct ieee80211_hw *hw, u32 changed)
392 {
393 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
394 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
395 	bool band = phy != &dev->phy;
396 	int ret = 0;
397 
398 	if (changed & (IEEE80211_CONF_CHANGE_CHANNEL |
399 		       IEEE80211_CONF_CHANGE_POWER)) {
400 #ifdef CONFIG_NL80211_TESTMODE
401 		if (phy->mt76->test.state != MT76_TM_STATE_OFF) {
402 			mt7615_mutex_acquire(dev);
403 			mt76_testmode_reset(phy->mt76, false);
404 			mt7615_mutex_release(dev);
405 		}
406 #endif
407 		ieee80211_stop_queues(hw);
408 		ret = mt7615_set_channel(phy);
409 		ieee80211_wake_queues(hw);
410 	}
411 
412 	mt7615_mutex_acquire(dev);
413 
414 	if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
415 		mt76_testmode_reset(phy->mt76, true);
416 
417 		if (!(hw->conf.flags & IEEE80211_CONF_MONITOR))
418 			phy->rxfilter |= MT_WF_RFCR_DROP_OTHER_UC;
419 		else
420 			phy->rxfilter &= ~MT_WF_RFCR_DROP_OTHER_UC;
421 
422 		mt76_wr(dev, MT_WF_RFCR(band), phy->rxfilter);
423 	}
424 
425 	mt7615_mutex_release(dev);
426 
427 	return ret;
428 }
429 
430 static int
431 mt7615_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue,
432 	       const struct ieee80211_tx_queue_params *params)
433 {
434 	struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
435 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
436 	int err;
437 
438 	mt7615_mutex_acquire(dev);
439 
440 	queue = mt7615_lmac_mapping(dev, queue);
441 	queue += mvif->wmm_idx * MT7615_MAX_WMM_SETS;
442 	err = mt7615_mcu_set_wmm(dev, queue, params);
443 
444 	mt7615_mutex_release(dev);
445 
446 	return err;
447 }
448 
449 static void mt7615_configure_filter(struct ieee80211_hw *hw,
450 				    unsigned int changed_flags,
451 				    unsigned int *total_flags,
452 				    u64 multicast)
453 {
454 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
455 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
456 	bool band = phy != &dev->phy;
457 
458 	u32 ctl_flags = MT_WF_RFCR1_DROP_ACK |
459 			MT_WF_RFCR1_DROP_BF_POLL |
460 			MT_WF_RFCR1_DROP_BA |
461 			MT_WF_RFCR1_DROP_CFEND |
462 			MT_WF_RFCR1_DROP_CFACK;
463 	u32 flags = 0;
464 
465 	mt7615_mutex_acquire(dev);
466 
467 #define MT76_FILTER(_flag, _hw) do { \
468 		flags |= *total_flags & FIF_##_flag;			\
469 		phy->rxfilter &= ~(_hw);				\
470 		if (!mt76_testmode_enabled(phy->mt76))			\
471 			phy->rxfilter |= !(flags & FIF_##_flag) * (_hw);\
472 	} while (0)
473 
474 	phy->rxfilter &= ~(MT_WF_RFCR_DROP_OTHER_BSS |
475 			   MT_WF_RFCR_DROP_FRAME_REPORT |
476 			   MT_WF_RFCR_DROP_PROBEREQ |
477 			   MT_WF_RFCR_DROP_MCAST_FILTERED |
478 			   MT_WF_RFCR_DROP_MCAST |
479 			   MT_WF_RFCR_DROP_BCAST |
480 			   MT_WF_RFCR_DROP_DUPLICATE |
481 			   MT_WF_RFCR_DROP_A2_BSSID |
482 			   MT_WF_RFCR_DROP_UNWANTED_CTL |
483 			   MT_WF_RFCR_DROP_STBC_MULTI);
484 
485 	if (phy->n_beacon_vif || !mt7615_firmware_offload(dev))
486 		phy->rxfilter &= ~MT_WF_RFCR_DROP_OTHER_BEACON;
487 
488 	MT76_FILTER(OTHER_BSS, MT_WF_RFCR_DROP_OTHER_TIM |
489 			       MT_WF_RFCR_DROP_A3_MAC |
490 			       MT_WF_RFCR_DROP_A3_BSSID);
491 
492 	MT76_FILTER(FCSFAIL, MT_WF_RFCR_DROP_FCSFAIL);
493 
494 	MT76_FILTER(CONTROL, MT_WF_RFCR_DROP_CTS |
495 			     MT_WF_RFCR_DROP_RTS |
496 			     MT_WF_RFCR_DROP_CTL_RSV |
497 			     MT_WF_RFCR_DROP_NDPA);
498 
499 	*total_flags = flags;
500 	mt76_wr(dev, MT_WF_RFCR(band), phy->rxfilter);
501 
502 	if (*total_flags & FIF_CONTROL)
503 		mt76_clear(dev, MT_WF_RFCR1(band), ctl_flags);
504 	else
505 		mt76_set(dev, MT_WF_RFCR1(band), ctl_flags);
506 
507 	mt7615_mutex_release(dev);
508 }
509 
510 static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
511 				    struct ieee80211_vif *vif,
512 				    struct ieee80211_bss_conf *info,
513 				    u32 changed)
514 {
515 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
516 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
517 
518 	mt7615_mutex_acquire(dev);
519 
520 	if (changed & BSS_CHANGED_ERP_SLOT) {
521 		int slottime = info->use_short_slot ? 9 : 20;
522 
523 		if (slottime != phy->slottime) {
524 			phy->slottime = slottime;
525 			mt7615_mac_set_timing(phy);
526 		}
527 	}
528 
529 	if (changed & BSS_CHANGED_BEACON_ENABLED) {
530 		mt7615_mcu_add_bss_info(phy, vif, NULL, info->enable_beacon);
531 		mt7615_mcu_sta_add(phy, vif, NULL, info->enable_beacon);
532 
533 		if (vif->p2p && info->enable_beacon)
534 			mt7615_mcu_set_p2p_oppps(hw, vif);
535 	}
536 
537 	if (changed & (BSS_CHANGED_BEACON |
538 		       BSS_CHANGED_BEACON_ENABLED))
539 		mt7615_mcu_add_beacon(dev, hw, vif, info->enable_beacon);
540 
541 	if (changed & BSS_CHANGED_PS)
542 		mt76_connac_mcu_set_vif_ps(&dev->mt76, vif);
543 
544 	if (changed & BSS_CHANGED_ARP_FILTER)
545 		mt7615_mcu_update_arp_filter(hw, vif, info);
546 
547 	mt7615_mutex_release(dev);
548 }
549 
550 static void
551 mt7615_channel_switch_beacon(struct ieee80211_hw *hw,
552 			     struct ieee80211_vif *vif,
553 			     struct cfg80211_chan_def *chandef)
554 {
555 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
556 
557 	mt7615_mutex_acquire(dev);
558 	mt7615_mcu_add_beacon(dev, hw, vif, true);
559 	mt7615_mutex_release(dev);
560 }
561 
562 int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
563 		       struct ieee80211_sta *sta)
564 {
565 	struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
566 	struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv;
567 	struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
568 	struct mt7615_phy *phy;
569 	int idx, err;
570 
571 	idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7615_WTBL_STA - 1);
572 	if (idx < 0)
573 		return -ENOSPC;
574 
575 	INIT_LIST_HEAD(&msta->poll_list);
576 	msta->vif = mvif;
577 	msta->wcid.sta = 1;
578 	msta->wcid.idx = idx;
579 	msta->wcid.ext_phy = mvif->mt76.band_idx;
580 
581 	phy = mvif->mt76.band_idx ? mt7615_ext_phy(dev) : &dev->phy;
582 	err = mt76_connac_pm_wake(phy->mt76, &dev->pm);
583 	if (err)
584 		return err;
585 
586 	if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
587 		mt7615_mcu_add_bss_info(phy, vif, sta, true);
588 	mt7615_mac_wtbl_update(dev, idx,
589 			       MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
590 	mt7615_mcu_sta_add(&dev->phy, vif, sta, true);
591 
592 	mt76_connac_power_save_sched(phy->mt76, &dev->pm);
593 
594 	return 0;
595 }
596 EXPORT_SYMBOL_GPL(mt7615_mac_sta_add);
597 
598 void mt7615_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
599 			   struct ieee80211_sta *sta)
600 {
601 	struct mt7615_dev *dev = container_of(mdev, struct mt7615_dev, mt76);
602 	struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv;
603 	struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
604 	struct mt7615_phy *phy;
605 
606 	mt76_connac_free_pending_tx_skbs(&dev->pm, &msta->wcid);
607 
608 	phy = mvif->mt76.band_idx ? mt7615_ext_phy(dev) : &dev->phy;
609 	mt76_connac_pm_wake(phy->mt76, &dev->pm);
610 
611 	mt7615_mcu_sta_add(&dev->phy, vif, sta, false);
612 	mt7615_mac_wtbl_update(dev, msta->wcid.idx,
613 			       MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
614 	if (vif->type == NL80211_IFTYPE_STATION && !sta->tdls)
615 		mt7615_mcu_add_bss_info(phy, vif, sta, false);
616 
617 	spin_lock_bh(&dev->sta_poll_lock);
618 	if (!list_empty(&msta->poll_list))
619 		list_del_init(&msta->poll_list);
620 	spin_unlock_bh(&dev->sta_poll_lock);
621 
622 	mt76_connac_power_save_sched(phy->mt76, &dev->pm);
623 }
624 EXPORT_SYMBOL_GPL(mt7615_mac_sta_remove);
625 
626 static void mt7615_sta_rate_tbl_update(struct ieee80211_hw *hw,
627 				       struct ieee80211_vif *vif,
628 				       struct ieee80211_sta *sta)
629 {
630 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
631 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
632 	struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv;
633 	struct ieee80211_sta_rates *sta_rates = rcu_dereference(sta->rates);
634 	int i;
635 
636 	spin_lock_bh(&dev->mt76.lock);
637 	for (i = 0; i < ARRAY_SIZE(msta->rates); i++) {
638 		msta->rates[i].idx = sta_rates->rate[i].idx;
639 		msta->rates[i].count = sta_rates->rate[i].count;
640 		msta->rates[i].flags = sta_rates->rate[i].flags;
641 
642 		if (msta->rates[i].idx < 0 || !msta->rates[i].count)
643 			break;
644 	}
645 	msta->n_rates = i;
646 	if (!test_bit(MT76_STATE_PM, &phy->mt76->state))
647 		mt7615_mac_set_rates(phy, msta, NULL, msta->rates);
648 	spin_unlock_bh(&dev->mt76.lock);
649 }
650 
651 static void
652 mt7615_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
653 {
654 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
655 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
656 	struct mt76_phy *mphy = phy->mt76;
657 
658 	if (!test_bit(MT76_STATE_RUNNING, &mphy->state))
659 		return;
660 
661 	if (test_bit(MT76_STATE_PM, &mphy->state)) {
662 		queue_work(dev->mt76.wq, &dev->pm.wake_work);
663 		return;
664 	}
665 
666 	dev->pm.last_activity = jiffies;
667 	mt76_worker_schedule(&dev->mt76.tx_worker);
668 }
669 
670 static void mt7615_tx(struct ieee80211_hw *hw,
671 		      struct ieee80211_tx_control *control,
672 		      struct sk_buff *skb)
673 {
674 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
675 	struct mt76_phy *mphy = hw->priv;
676 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
677 	struct ieee80211_vif *vif = info->control.vif;
678 	struct mt76_wcid *wcid = &dev->mt76.global_wcid;
679 	struct mt7615_sta *msta = NULL;
680 	int qid;
681 
682 	if (control->sta) {
683 		msta = (struct mt7615_sta *)control->sta->drv_priv;
684 		wcid = &msta->wcid;
685 	}
686 
687 	if (vif && !control->sta) {
688 		struct mt7615_vif *mvif;
689 
690 		mvif = (struct mt7615_vif *)vif->drv_priv;
691 		msta = &mvif->sta;
692 		wcid = &msta->wcid;
693 	}
694 
695 	if (!test_bit(MT76_STATE_PM, &mphy->state)) {
696 		dev->pm.last_activity = jiffies;
697 		mt76_tx(mphy, control->sta, wcid, skb);
698 		return;
699 	}
700 
701 	qid = skb_get_queue_mapping(skb);
702 	if (qid >= MT_TXQ_PSD) {
703 		qid = IEEE80211_AC_BE;
704 		skb_set_queue_mapping(skb, qid);
705 	}
706 
707 	mt76_connac_pm_queue_skb(hw, &dev->pm, wcid, skb);
708 }
709 
710 static int mt7615_set_rts_threshold(struct ieee80211_hw *hw, u32 val)
711 {
712 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
713 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
714 	int band = phy != &dev->phy;
715 
716 	mt7615_mutex_acquire(dev);
717 	mt76_connac_mcu_set_rts_thresh(&dev->mt76, val, band);
718 	mt7615_mutex_release(dev);
719 
720 	return 0;
721 }
722 
723 static int
724 mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
725 		    struct ieee80211_ampdu_params *params)
726 {
727 	enum ieee80211_ampdu_mlme_action action = params->action;
728 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
729 	struct ieee80211_sta *sta = params->sta;
730 	struct ieee80211_txq *txq = sta->txq[params->tid];
731 	struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv;
732 	u16 tid = params->tid;
733 	u16 ssn = params->ssn;
734 	struct mt76_txq *mtxq;
735 	int ret = 0;
736 
737 	if (!txq)
738 		return -EINVAL;
739 
740 	mtxq = (struct mt76_txq *)txq->drv_priv;
741 
742 	mt7615_mutex_acquire(dev);
743 
744 	switch (action) {
745 	case IEEE80211_AMPDU_RX_START:
746 		mt76_rx_aggr_start(&dev->mt76, &msta->wcid, tid, ssn,
747 				   params->buf_size);
748 		mt7615_mcu_add_rx_ba(dev, params, true);
749 		break;
750 	case IEEE80211_AMPDU_RX_STOP:
751 		mt76_rx_aggr_stop(&dev->mt76, &msta->wcid, tid);
752 		mt7615_mcu_add_rx_ba(dev, params, false);
753 		break;
754 	case IEEE80211_AMPDU_TX_OPERATIONAL:
755 		mtxq->aggr = true;
756 		mtxq->send_bar = false;
757 		mt7615_mcu_add_tx_ba(dev, params, true);
758 		ssn = mt7615_mac_get_sta_tid_sn(dev, msta->wcid.idx, tid);
759 		ieee80211_send_bar(vif, sta->addr, tid,
760 				   IEEE80211_SN_TO_SEQ(ssn));
761 		break;
762 	case IEEE80211_AMPDU_TX_STOP_FLUSH:
763 	case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
764 		mtxq->aggr = false;
765 		mt7615_mcu_add_tx_ba(dev, params, false);
766 		break;
767 	case IEEE80211_AMPDU_TX_START:
768 		ssn = mt7615_mac_get_sta_tid_sn(dev, msta->wcid.idx, tid);
769 		params->ssn = ssn;
770 		ret = IEEE80211_AMPDU_TX_START_IMMEDIATE;
771 		break;
772 	case IEEE80211_AMPDU_TX_STOP_CONT:
773 		mtxq->aggr = false;
774 		mt7615_mcu_add_tx_ba(dev, params, false);
775 		ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
776 		break;
777 	}
778 	mt7615_mutex_release(dev);
779 
780 	return ret;
781 }
782 
783 static int
784 mt7615_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
785 	       struct ieee80211_sta *sta)
786 {
787     return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NOTEXIST,
788 			  IEEE80211_STA_NONE);
789 }
790 
791 static int
792 mt7615_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
793 		  struct ieee80211_sta *sta)
794 {
795     return mt76_sta_state(hw, vif, sta, IEEE80211_STA_NONE,
796 			  IEEE80211_STA_NOTEXIST);
797 }
798 
799 static int
800 mt7615_get_stats(struct ieee80211_hw *hw,
801 		 struct ieee80211_low_level_stats *stats)
802 {
803 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
804 	struct mib_stats *mib = &phy->mib;
805 
806 	stats->dot11RTSSuccessCount = mib->rts_cnt;
807 	stats->dot11RTSFailureCount = mib->rts_retries_cnt;
808 	stats->dot11FCSErrorCount = mib->fcs_err_cnt;
809 	stats->dot11ACKFailureCount = mib->ack_fail_cnt;
810 
811 	return 0;
812 }
813 
814 static u64
815 mt7615_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
816 {
817 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
818 	union {
819 		u64 t64;
820 		u32 t32[2];
821 	} tsf;
822 
823 	mt7615_mutex_acquire(dev);
824 
825 	mt76_set(dev, MT_LPON_T0CR, MT_LPON_T0CR_MODE); /* TSF read */
826 	tsf.t32[0] = mt76_rr(dev, MT_LPON_UTTR0);
827 	tsf.t32[1] = mt76_rr(dev, MT_LPON_UTTR1);
828 
829 	mt7615_mutex_release(dev);
830 
831 	return tsf.t64;
832 }
833 
834 static void
835 mt7615_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
836 	       u64 timestamp)
837 {
838 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
839 	union {
840 		u64 t64;
841 		u32 t32[2];
842 	} tsf = { .t64 = timestamp, };
843 
844 	mt7615_mutex_acquire(dev);
845 
846 	mt76_wr(dev, MT_LPON_UTTR0, tsf.t32[0]);
847 	mt76_wr(dev, MT_LPON_UTTR1, tsf.t32[1]);
848 	/* TSF software overwrite */
849 	mt76_set(dev, MT_LPON_T0CR, MT_LPON_T0CR_WRITE);
850 
851 	mt7615_mutex_release(dev);
852 }
853 
854 static void
855 mt7615_set_coverage_class(struct ieee80211_hw *hw, s16 coverage_class)
856 {
857 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
858 	struct mt7615_dev *dev = phy->dev;
859 
860 	mt7615_mutex_acquire(dev);
861 	phy->coverage_class = max_t(s16, coverage_class, 0);
862 	mt7615_mac_set_timing(phy);
863 	mt7615_mutex_release(dev);
864 }
865 
866 static int
867 mt7615_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
868 {
869 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
870 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
871 	int max_nss = hweight8(hw->wiphy->available_antennas_tx);
872 	bool ext_phy = phy != &dev->phy;
873 
874 	if (!tx_ant || tx_ant != rx_ant || ffs(tx_ant) > max_nss)
875 		return -EINVAL;
876 
877 	if ((BIT(hweight8(tx_ant)) - 1) != tx_ant)
878 		tx_ant = BIT(ffs(tx_ant) - 1) - 1;
879 
880 	mt7615_mutex_acquire(dev);
881 
882 	phy->mt76->antenna_mask = tx_ant;
883 	if (ext_phy) {
884 		if (dev->chainmask == 0xf)
885 			tx_ant <<= 2;
886 		else
887 			tx_ant <<= 1;
888 	}
889 	phy->mt76->chainmask = tx_ant;
890 
891 	mt76_set_stream_caps(phy->mt76, true);
892 
893 	mt7615_mutex_release(dev);
894 
895 	return 0;
896 }
897 
898 static void mt7615_roc_iter(void *priv, u8 *mac,
899 			    struct ieee80211_vif *vif)
900 {
901 	struct mt7615_phy *phy = priv;
902 
903 	mt7615_mcu_set_roc(phy, vif, NULL, 0);
904 }
905 
906 void mt7615_roc_work(struct work_struct *work)
907 {
908 	struct mt7615_phy *phy;
909 
910 	phy = (struct mt7615_phy *)container_of(work, struct mt7615_phy,
911 						roc_work);
912 
913 	if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
914 		return;
915 
916 	mt7615_mutex_acquire(phy->dev);
917 	ieee80211_iterate_active_interfaces(phy->mt76->hw,
918 					    IEEE80211_IFACE_ITER_RESUME_ALL,
919 					    mt7615_roc_iter, phy);
920 	mt7615_mutex_release(phy->dev);
921 	ieee80211_remain_on_channel_expired(phy->mt76->hw);
922 }
923 
924 void mt7615_roc_timer(struct timer_list *timer)
925 {
926 	struct mt7615_phy *phy = from_timer(phy, timer, roc_timer);
927 
928 	ieee80211_queue_work(phy->mt76->hw, &phy->roc_work);
929 }
930 
931 void mt7615_scan_work(struct work_struct *work)
932 {
933 	struct mt7615_phy *phy;
934 
935 	phy = (struct mt7615_phy *)container_of(work, struct mt7615_phy,
936 						scan_work.work);
937 
938 	while (true) {
939 		struct mt7615_mcu_rxd *rxd;
940 		struct sk_buff *skb;
941 
942 		spin_lock_bh(&phy->dev->mt76.lock);
943 		skb = __skb_dequeue(&phy->scan_event_list);
944 		spin_unlock_bh(&phy->dev->mt76.lock);
945 
946 		if (!skb)
947 			break;
948 
949 		rxd = (struct mt7615_mcu_rxd *)skb->data;
950 		if (rxd->eid == MCU_EVENT_SCHED_SCAN_DONE) {
951 			ieee80211_sched_scan_results(phy->mt76->hw);
952 		} else if (test_and_clear_bit(MT76_HW_SCANNING,
953 					      &phy->mt76->state)) {
954 			struct cfg80211_scan_info info = {
955 				.aborted = false,
956 			};
957 
958 			ieee80211_scan_completed(phy->mt76->hw, &info);
959 		}
960 		dev_kfree_skb(skb);
961 	}
962 }
963 
964 static int
965 mt7615_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
966 	       struct ieee80211_scan_request *req)
967 {
968 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
969 	struct mt76_phy *mphy = hw->priv;
970 	int err;
971 
972 	/* fall-back to sw-scan */
973 	if (!mt7615_firmware_offload(dev))
974 		return 1;
975 
976 	mt7615_mutex_acquire(dev);
977 	err = mt76_connac_mcu_hw_scan(mphy, vif, req);
978 	mt7615_mutex_release(dev);
979 
980 	return err;
981 }
982 
983 static void
984 mt7615_cancel_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
985 {
986 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
987 	struct mt76_phy *mphy = hw->priv;
988 
989 	mt7615_mutex_acquire(dev);
990 	mt76_connac_mcu_cancel_hw_scan(mphy, vif);
991 	mt7615_mutex_release(dev);
992 }
993 
994 static int
995 mt7615_start_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
996 			struct cfg80211_sched_scan_request *req,
997 			struct ieee80211_scan_ies *ies)
998 {
999 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
1000 	struct mt76_phy *mphy = hw->priv;
1001 	int err;
1002 
1003 	if (!mt7615_firmware_offload(dev))
1004 		return -EOPNOTSUPP;
1005 
1006 	mt7615_mutex_acquire(dev);
1007 
1008 	err = mt76_connac_mcu_sched_scan_req(mphy, vif, req);
1009 	if (err < 0)
1010 		goto out;
1011 
1012 	err = mt76_connac_mcu_sched_scan_enable(mphy, vif, true);
1013 out:
1014 	mt7615_mutex_release(dev);
1015 
1016 	return err;
1017 }
1018 
1019 static int
1020 mt7615_stop_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
1021 {
1022 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
1023 	struct mt76_phy *mphy = hw->priv;
1024 	int err;
1025 
1026 	if (!mt7615_firmware_offload(dev))
1027 		return -EOPNOTSUPP;
1028 
1029 	mt7615_mutex_acquire(dev);
1030 	err = mt76_connac_mcu_sched_scan_enable(mphy, vif, false);
1031 	mt7615_mutex_release(dev);
1032 
1033 	return err;
1034 }
1035 
1036 static int mt7615_remain_on_channel(struct ieee80211_hw *hw,
1037 				    struct ieee80211_vif *vif,
1038 				    struct ieee80211_channel *chan,
1039 				    int duration,
1040 				    enum ieee80211_roc_type type)
1041 {
1042 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
1043 	int err;
1044 
1045 	if (test_and_set_bit(MT76_STATE_ROC, &phy->mt76->state))
1046 		return 0;
1047 
1048 	mt7615_mutex_acquire(phy->dev);
1049 
1050 	err = mt7615_mcu_set_roc(phy, vif, chan, duration);
1051 	if (err < 0) {
1052 		clear_bit(MT76_STATE_ROC, &phy->mt76->state);
1053 		goto out;
1054 	}
1055 
1056 	if (!wait_event_timeout(phy->roc_wait, phy->roc_grant, HZ)) {
1057 		mt7615_mcu_set_roc(phy, vif, NULL, 0);
1058 		clear_bit(MT76_STATE_ROC, &phy->mt76->state);
1059 		err = -ETIMEDOUT;
1060 	}
1061 
1062 out:
1063 	mt7615_mutex_release(phy->dev);
1064 
1065 	return err;
1066 }
1067 
1068 static int mt7615_cancel_remain_on_channel(struct ieee80211_hw *hw,
1069 					   struct ieee80211_vif *vif)
1070 {
1071 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
1072 
1073 	if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
1074 		return 0;
1075 
1076 	del_timer_sync(&phy->roc_timer);
1077 	cancel_work_sync(&phy->roc_work);
1078 
1079 	mt7615_mutex_acquire(phy->dev);
1080 	mt7615_mcu_set_roc(phy, vif, NULL, 0);
1081 	mt7615_mutex_release(phy->dev);
1082 
1083 	return 0;
1084 }
1085 
1086 #ifdef CONFIG_PM
1087 static int mt7615_suspend(struct ieee80211_hw *hw,
1088 			  struct cfg80211_wowlan *wowlan)
1089 {
1090 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
1091 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
1092 	int err = 0;
1093 
1094 	cancel_delayed_work_sync(&dev->pm.ps_work);
1095 	mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
1096 
1097 	mt7615_mutex_acquire(dev);
1098 
1099 	clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
1100 	cancel_delayed_work_sync(&phy->scan_work);
1101 	cancel_delayed_work_sync(&phy->mt76->mac_work);
1102 
1103 	set_bit(MT76_STATE_SUSPEND, &phy->mt76->state);
1104 	ieee80211_iterate_active_interfaces(hw,
1105 					    IEEE80211_IFACE_ITER_RESUME_ALL,
1106 					    mt76_connac_mcu_set_suspend_iter,
1107 					    phy->mt76);
1108 
1109 	if (!mt7615_dev_running(dev))
1110 		err = mt76_connac_mcu_set_hif_suspend(&dev->mt76, true);
1111 
1112 	mt7615_mutex_release(dev);
1113 
1114 	return err;
1115 }
1116 
1117 static int mt7615_resume(struct ieee80211_hw *hw)
1118 {
1119 	struct mt7615_phy *phy = mt7615_hw_phy(hw);
1120 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
1121 	bool running;
1122 
1123 	mt7615_mutex_acquire(dev);
1124 
1125 	running = mt7615_dev_running(dev);
1126 	set_bit(MT76_STATE_RUNNING, &phy->mt76->state);
1127 
1128 	if (!running) {
1129 		int err;
1130 
1131 		err = mt76_connac_mcu_set_hif_suspend(&dev->mt76, false);
1132 		if (err < 0) {
1133 			mt7615_mutex_release(dev);
1134 			return err;
1135 		}
1136 	}
1137 
1138 	clear_bit(MT76_STATE_SUSPEND, &phy->mt76->state);
1139 	ieee80211_iterate_active_interfaces(hw,
1140 					    IEEE80211_IFACE_ITER_RESUME_ALL,
1141 					    mt76_connac_mcu_set_suspend_iter,
1142 					    phy->mt76);
1143 
1144 	ieee80211_queue_delayed_work(hw, &phy->mt76->mac_work,
1145 				     MT7615_WATCHDOG_TIME);
1146 
1147 	mt7615_mutex_release(dev);
1148 
1149 	return 0;
1150 }
1151 
1152 static void mt7615_set_wakeup(struct ieee80211_hw *hw, bool enabled)
1153 {
1154 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
1155 	struct mt76_dev *mdev = &dev->mt76;
1156 
1157 	device_set_wakeup_enable(mdev->dev, enabled);
1158 }
1159 
1160 static void mt7615_set_rekey_data(struct ieee80211_hw *hw,
1161 				  struct ieee80211_vif *vif,
1162 				  struct cfg80211_gtk_rekey_data *data)
1163 {
1164 	struct mt7615_dev *dev = mt7615_hw_dev(hw);
1165 
1166 	mt7615_mutex_acquire(dev);
1167 	mt76_connac_mcu_update_gtk_rekey(hw, vif, data);
1168 	mt7615_mutex_release(dev);
1169 }
1170 #endif /* CONFIG_PM */
1171 
1172 const struct ieee80211_ops mt7615_ops = {
1173 	.tx = mt7615_tx,
1174 	.start = mt7615_start,
1175 	.stop = mt7615_stop,
1176 	.add_interface = mt7615_add_interface,
1177 	.remove_interface = mt7615_remove_interface,
1178 	.config = mt7615_config,
1179 	.conf_tx = mt7615_conf_tx,
1180 	.configure_filter = mt7615_configure_filter,
1181 	.bss_info_changed = mt7615_bss_info_changed,
1182 	.sta_add = mt7615_sta_add,
1183 	.sta_remove = mt7615_sta_remove,
1184 	.sta_pre_rcu_remove = mt76_sta_pre_rcu_remove,
1185 	.set_key = mt7615_set_key,
1186 	.ampdu_action = mt7615_ampdu_action,
1187 	.set_rts_threshold = mt7615_set_rts_threshold,
1188 	.wake_tx_queue = mt7615_wake_tx_queue,
1189 	.sta_rate_tbl_update = mt7615_sta_rate_tbl_update,
1190 	.sw_scan_start = mt76_sw_scan,
1191 	.sw_scan_complete = mt76_sw_scan_complete,
1192 	.release_buffered_frames = mt76_release_buffered_frames,
1193 	.get_txpower = mt76_get_txpower,
1194 	.channel_switch_beacon = mt7615_channel_switch_beacon,
1195 	.get_stats = mt7615_get_stats,
1196 	.get_tsf = mt7615_get_tsf,
1197 	.set_tsf = mt7615_set_tsf,
1198 	.get_survey = mt76_get_survey,
1199 	.get_antenna = mt76_get_antenna,
1200 	.set_antenna = mt7615_set_antenna,
1201 	.set_coverage_class = mt7615_set_coverage_class,
1202 	.hw_scan = mt7615_hw_scan,
1203 	.cancel_hw_scan = mt7615_cancel_hw_scan,
1204 	.sched_scan_start = mt7615_start_sched_scan,
1205 	.sched_scan_stop = mt7615_stop_sched_scan,
1206 	.remain_on_channel = mt7615_remain_on_channel,
1207 	.cancel_remain_on_channel = mt7615_cancel_remain_on_channel,
1208 	CFG80211_TESTMODE_CMD(mt76_testmode_cmd)
1209 	CFG80211_TESTMODE_DUMP(mt76_testmode_dump)
1210 #ifdef CONFIG_PM
1211 	.suspend = mt7615_suspend,
1212 	.resume = mt7615_resume,
1213 	.set_wakeup = mt7615_set_wakeup,
1214 	.set_rekey_data = mt7615_set_rekey_data,
1215 #endif /* CONFIG_PM */
1216 };
1217 EXPORT_SYMBOL_GPL(mt7615_ops);
1218 
1219 MODULE_LICENSE("Dual BSD/GPL");
1220