1 // SPDX-License-Identifier: ISC
3 * Copyright (C) 2018 Stanislaw Gruszka <stf_xl@wp.pl>
4 * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
7 #include <linux/module.h>
10 #define CCK_RATE(_idx, _rate) { \
12 .flags = IEEE80211_RATE_SHORT_PREAMBLE, \
13 .hw_value = (MT_PHY_TYPE_CCK << 8) | (_idx), \
14 .hw_value_short = (MT_PHY_TYPE_CCK << 8) | (8 + (_idx)), \
17 #define OFDM_RATE(_idx, _rate) { \
19 .hw_value = (MT_PHY_TYPE_OFDM << 8) | (_idx), \
20 .hw_value_short = (MT_PHY_TYPE_OFDM << 8) | (_idx), \
23 struct ieee80211_rate mt76x02_rates[] = {
37 EXPORT_SYMBOL_GPL(mt76x02_rates);
39 static const struct ieee80211_iface_limit mt76x02_if_limits[] = {
42 .types = BIT(NL80211_IFTYPE_ADHOC)
45 .types = BIT(NL80211_IFTYPE_STATION) |
46 #ifdef CONFIG_MAC80211_MESH
47 BIT(NL80211_IFTYPE_MESH_POINT) |
49 BIT(NL80211_IFTYPE_P2P_CLIENT) |
50 BIT(NL80211_IFTYPE_P2P_GO) |
51 BIT(NL80211_IFTYPE_AP)
55 static const struct ieee80211_iface_limit mt76x02u_if_limits[] = {
58 .types = BIT(NL80211_IFTYPE_ADHOC)
61 .types = BIT(NL80211_IFTYPE_STATION) |
62 #ifdef CONFIG_MAC80211_MESH
63 BIT(NL80211_IFTYPE_MESH_POINT) |
65 BIT(NL80211_IFTYPE_P2P_CLIENT) |
66 BIT(NL80211_IFTYPE_P2P_GO) |
67 BIT(NL80211_IFTYPE_AP)
71 static const struct ieee80211_iface_combination mt76x02_if_comb[] = {
73 .limits = mt76x02_if_limits,
74 .n_limits = ARRAY_SIZE(mt76x02_if_limits),
76 .num_different_channels = 1,
77 .beacon_int_infra_match = true,
78 .radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) |
79 BIT(NL80211_CHAN_WIDTH_20) |
80 BIT(NL80211_CHAN_WIDTH_40) |
81 BIT(NL80211_CHAN_WIDTH_80),
85 static const struct ieee80211_iface_combination mt76x02u_if_comb[] = {
87 .limits = mt76x02u_if_limits,
88 .n_limits = ARRAY_SIZE(mt76x02u_if_limits),
90 .num_different_channels = 1,
91 .beacon_int_infra_match = true,
96 mt76x02_led_set_config(struct mt76_dev *mdev, u8 delay_on,
99 struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev,
103 val = FIELD_PREP(MT_LED_STATUS_DURATION, 0xff) |
104 FIELD_PREP(MT_LED_STATUS_OFF, delay_off) |
105 FIELD_PREP(MT_LED_STATUS_ON, delay_on);
107 mt76_wr(dev, MT_LED_S0(mdev->led_pin), val);
108 mt76_wr(dev, MT_LED_S1(mdev->led_pin), val);
110 val = MT_LED_CTRL_REPLAY(mdev->led_pin) |
111 MT_LED_CTRL_KICK(mdev->led_pin);
113 val |= MT_LED_CTRL_POLARITY(mdev->led_pin);
114 mt76_wr(dev, MT_LED_CTRL, val);
118 mt76x02_led_set_blink(struct led_classdev *led_cdev,
119 unsigned long *delay_on,
120 unsigned long *delay_off)
122 struct mt76_dev *mdev = container_of(led_cdev, struct mt76_dev,
124 u8 delta_on, delta_off;
126 delta_off = max_t(u8, *delay_off / 10, 1);
127 delta_on = max_t(u8, *delay_on / 10, 1);
129 mt76x02_led_set_config(mdev, delta_on, delta_off);
135 mt76x02_led_set_brightness(struct led_classdev *led_cdev,
136 enum led_brightness brightness)
138 struct mt76_dev *mdev = container_of(led_cdev, struct mt76_dev,
142 mt76x02_led_set_config(mdev, 0, 0xff);
144 mt76x02_led_set_config(mdev, 0xff, 0);
147 void mt76x02_init_device(struct mt76x02_dev *dev)
149 struct ieee80211_hw *hw = mt76_hw(dev);
150 struct wiphy *wiphy = hw->wiphy;
152 INIT_DELAYED_WORK(&dev->mphy.mac_work, mt76x02_mac_work);
156 hw->max_report_rates = 7;
157 hw->max_rate_tries = 1;
158 hw->extra_tx_headroom = 2;
160 if (mt76_is_usb(&dev->mt76)) {
161 hw->extra_tx_headroom += sizeof(struct mt76x02_txwi) +
163 wiphy->iface_combinations = mt76x02u_if_comb;
164 wiphy->n_iface_combinations = ARRAY_SIZE(mt76x02u_if_comb);
166 INIT_DELAYED_WORK(&dev->wdt_work, mt76x02_wdt_work);
168 mt76x02_dfs_init_detector(dev);
170 wiphy->reg_notifier = mt76x02_regd_notifier;
171 wiphy->iface_combinations = mt76x02_if_comb;
172 wiphy->n_iface_combinations = ARRAY_SIZE(mt76x02_if_comb);
174 /* init led callbacks */
175 if (IS_ENABLED(CONFIG_MT76_LEDS)) {
176 dev->mt76.led_cdev.brightness_set =
177 mt76x02_led_set_brightness;
178 dev->mt76.led_cdev.blink_set = mt76x02_led_set_blink;
182 wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
184 hw->sta_data_size = sizeof(struct mt76x02_sta);
185 hw->vif_data_size = sizeof(struct mt76x02_vif);
187 ieee80211_hw_set(hw, SUPPORTS_HT_CCK_RATES);
188 ieee80211_hw_set(hw, HOST_BROADCAST_PS_BUFFERING);
189 ieee80211_hw_set(hw, NEEDS_UNIQUE_STA_ADDR);
191 dev->mt76.global_wcid.idx = 255;
192 dev->mt76.global_wcid.hw_key_idx = -1;
195 if (is_mt76x2(dev)) {
196 dev->mphy.sband_2g.sband.ht_cap.cap |=
197 IEEE80211_HT_CAP_LDPC_CODING;
198 dev->mphy.sband_5g.sband.ht_cap.cap |=
199 IEEE80211_HT_CAP_LDPC_CODING;
200 dev->mphy.chainmask = 0x202;
201 dev->mphy.antenna_mask = 3;
203 dev->mphy.chainmask = 0x101;
204 dev->mphy.antenna_mask = 1;
207 EXPORT_SYMBOL_GPL(mt76x02_init_device);
209 void mt76x02_configure_filter(struct ieee80211_hw *hw,
210 unsigned int changed_flags,
211 unsigned int *total_flags, u64 multicast)
213 struct mt76x02_dev *dev = hw->priv;
216 #define MT76_FILTER(_flag, _hw) do { \
217 flags |= *total_flags & FIF_##_flag; \
218 dev->mt76.rxfilter &= ~(_hw); \
219 dev->mt76.rxfilter |= !(flags & FIF_##_flag) * (_hw); \
222 mutex_lock(&dev->mt76.mutex);
224 dev->mt76.rxfilter &= ~MT_RX_FILTR_CFG_OTHER_BSS;
226 MT76_FILTER(FCSFAIL, MT_RX_FILTR_CFG_CRC_ERR);
227 MT76_FILTER(PLCPFAIL, MT_RX_FILTR_CFG_PHY_ERR);
228 MT76_FILTER(CONTROL, MT_RX_FILTR_CFG_ACK |
229 MT_RX_FILTR_CFG_CTS |
230 MT_RX_FILTR_CFG_CFEND |
231 MT_RX_FILTR_CFG_CFACK |
233 MT_RX_FILTR_CFG_CTRL_RSV);
234 MT76_FILTER(PSPOLL, MT_RX_FILTR_CFG_PSPOLL);
236 *total_flags = flags;
237 mt76_wr(dev, MT_RX_FILTR_CFG, dev->mt76.rxfilter);
239 mutex_unlock(&dev->mt76.mutex);
241 EXPORT_SYMBOL_GPL(mt76x02_configure_filter);
243 int mt76x02_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
244 struct ieee80211_sta *sta)
246 struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
247 struct mt76x02_sta *msta = (struct mt76x02_sta *)sta->drv_priv;
248 struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
251 memset(msta, 0, sizeof(*msta));
253 idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT76x02_N_WCIDS);
259 msta->wcid.idx = idx;
260 msta->wcid.hw_key_idx = -1;
261 mt76x02_mac_wcid_setup(dev, idx, mvif->idx, sta->addr);
262 mt76x02_mac_wcid_set_drop(dev, idx, false);
263 ewma_pktlen_init(&msta->pktlen);
265 if (vif->type == NL80211_IFTYPE_AP)
266 set_bit(MT_WCID_FLAG_CHECK_PS, &msta->wcid.flags);
270 EXPORT_SYMBOL_GPL(mt76x02_sta_add);
272 void mt76x02_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
273 struct ieee80211_sta *sta)
275 struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
276 struct mt76_wcid *wcid = (struct mt76_wcid *)sta->drv_priv;
279 mt76x02_mac_wcid_set_drop(dev, idx, true);
280 mt76x02_mac_wcid_setup(dev, idx, 0, NULL);
282 EXPORT_SYMBOL_GPL(mt76x02_sta_remove);
285 mt76x02_vif_init(struct mt76x02_dev *dev, struct ieee80211_vif *vif,
288 struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
289 struct mt76_txq *mtxq;
291 memset(mvif, 0, sizeof(*mvif));
294 mvif->group_wcid.idx = MT_VIF_WCID(idx);
295 mvif->group_wcid.hw_key_idx = -1;
296 mtxq = (struct mt76_txq *)vif->txq->drv_priv;
297 mtxq->wcid = &mvif->group_wcid;
301 mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
303 struct mt76x02_dev *dev = hw->priv;
304 unsigned int idx = 0;
306 /* Allow to change address in HW if we create first interface. */
307 if (!dev->mt76.vif_mask &&
308 (((vif->addr[0] ^ dev->mphy.macaddr[0]) & ~GENMASK(4, 1)) ||
309 memcmp(vif->addr + 1, dev->mphy.macaddr + 1, ETH_ALEN - 1)))
310 mt76x02_mac_setaddr(dev, vif->addr);
312 if (vif->addr[0] & BIT(1))
313 idx = 1 + (((dev->mphy.macaddr[0] ^ vif->addr[0]) >> 2) & 7);
316 * Client mode typically only has one configurable BSSID register,
317 * which is used for bssidx=0. This is linked to the MAC address.
318 * Since mac80211 allows changing interface types, and we cannot
319 * force the use of the primary MAC address for a station mode
320 * interface, we need some other way of configuring a per-interface
322 * The hardware provides an AP-Client feature, where bssidx 0-7 are
323 * used for AP mode and bssidx 8-15 for client mode.
324 * We shift the station interface bss index by 8 to force the
325 * hardware to recognize the BSSID.
326 * The resulting bssidx mismatch for unicast frames is ignored by hw.
328 if (vif->type == NL80211_IFTYPE_STATION)
331 /* vif is already set or idx is 8 for AP/Mesh/... */
332 if (dev->mt76.vif_mask & BIT(idx) ||
333 (vif->type != NL80211_IFTYPE_STATION && idx > 7))
336 dev->mt76.vif_mask |= BIT(idx);
338 mt76x02_vif_init(dev, vif, idx);
341 EXPORT_SYMBOL_GPL(mt76x02_add_interface);
343 void mt76x02_remove_interface(struct ieee80211_hw *hw,
344 struct ieee80211_vif *vif)
346 struct mt76x02_dev *dev = hw->priv;
347 struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
349 dev->mt76.vif_mask &= ~BIT(mvif->idx);
351 EXPORT_SYMBOL_GPL(mt76x02_remove_interface);
353 int mt76x02_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
354 struct ieee80211_ampdu_params *params)
356 enum ieee80211_ampdu_mlme_action action = params->action;
357 struct ieee80211_sta *sta = params->sta;
358 struct mt76x02_dev *dev = hw->priv;
359 struct mt76x02_sta *msta = (struct mt76x02_sta *)sta->drv_priv;
360 struct ieee80211_txq *txq = sta->txq[params->tid];
361 u16 tid = params->tid;
362 u16 ssn = params->ssn;
363 struct mt76_txq *mtxq;
369 mtxq = (struct mt76_txq *)txq->drv_priv;
371 mutex_lock(&dev->mt76.mutex);
373 case IEEE80211_AMPDU_RX_START:
374 mt76_rx_aggr_start(&dev->mt76, &msta->wcid, tid,
375 ssn, params->buf_size);
376 mt76_set(dev, MT_WCID_ADDR(msta->wcid.idx) + 4, BIT(16 + tid));
378 case IEEE80211_AMPDU_RX_STOP:
379 mt76_rx_aggr_stop(&dev->mt76, &msta->wcid, tid);
380 mt76_clear(dev, MT_WCID_ADDR(msta->wcid.idx) + 4,
383 case IEEE80211_AMPDU_TX_OPERATIONAL:
385 mtxq->send_bar = false;
386 ieee80211_send_bar(vif, sta->addr, tid, mtxq->agg_ssn);
388 case IEEE80211_AMPDU_TX_STOP_FLUSH:
389 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
392 case IEEE80211_AMPDU_TX_START:
393 mtxq->agg_ssn = IEEE80211_SN_TO_SEQ(ssn);
394 ret = IEEE80211_AMPDU_TX_START_IMMEDIATE;
396 case IEEE80211_AMPDU_TX_STOP_CONT:
398 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
401 mutex_unlock(&dev->mt76.mutex);
405 EXPORT_SYMBOL_GPL(mt76x02_ampdu_action);
407 int mt76x02_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
408 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
409 struct ieee80211_key_conf *key)
411 struct mt76x02_dev *dev = hw->priv;
412 struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
413 struct mt76x02_sta *msta;
414 struct mt76_wcid *wcid;
415 int idx = key->keyidx;
418 /* fall back to sw encryption for unsupported ciphers */
419 switch (key->cipher) {
420 case WLAN_CIPHER_SUITE_WEP40:
421 case WLAN_CIPHER_SUITE_WEP104:
422 case WLAN_CIPHER_SUITE_TKIP:
423 case WLAN_CIPHER_SUITE_CCMP:
430 * The hardware does not support per-STA RX GTK, fall back
431 * to software mode for these.
433 if ((vif->type == NL80211_IFTYPE_ADHOC ||
434 vif->type == NL80211_IFTYPE_MESH_POINT) &&
435 (key->cipher == WLAN_CIPHER_SUITE_TKIP ||
436 key->cipher == WLAN_CIPHER_SUITE_CCMP) &&
437 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
441 * In USB AP mode, broadcast/multicast frames are setup in beacon
442 * data registers and sent via HW beacons engine, they require to
443 * be already encrypted.
445 if (mt76_is_usb(&dev->mt76) &&
446 vif->type == NL80211_IFTYPE_AP &&
447 !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
450 /* MT76x0 GTK offloading does not work with more than one VIF */
451 if (is_mt76x0(dev) && !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
454 msta = sta ? (struct mt76x02_sta *)sta->drv_priv : NULL;
455 wcid = msta ? &msta->wcid : &mvif->group_wcid;
457 if (cmd == SET_KEY) {
458 key->hw_key_idx = wcid->idx;
459 wcid->hw_key_idx = idx;
460 if (key->flags & IEEE80211_KEY_FLAG_RX_MGMT) {
461 key->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX;
465 if (idx == wcid->hw_key_idx) {
466 wcid->hw_key_idx = -1;
472 mt76_wcid_key_setup(&dev->mt76, wcid, key);
475 if (key || wcid->hw_key_idx == idx) {
476 ret = mt76x02_mac_wcid_set_key(dev, wcid->idx, key);
481 return mt76x02_mac_shared_key_setup(dev, mvif->idx, idx, key);
484 return mt76x02_mac_wcid_set_key(dev, msta->wcid.idx, key);
486 EXPORT_SYMBOL_GPL(mt76x02_set_key);
488 int mt76x02_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
489 u16 queue, const struct ieee80211_tx_queue_params *params)
491 struct mt76x02_dev *dev = hw->priv;
492 u8 cw_min = 5, cw_max = 10, qid;
495 qid = dev->mphy.q_tx[queue]->hw_idx;
498 cw_min = fls(params->cw_min);
500 cw_max = fls(params->cw_max);
502 val = FIELD_PREP(MT_EDCA_CFG_TXOP, params->txop) |
503 FIELD_PREP(MT_EDCA_CFG_AIFSN, params->aifs) |
504 FIELD_PREP(MT_EDCA_CFG_CWMIN, cw_min) |
505 FIELD_PREP(MT_EDCA_CFG_CWMAX, cw_max);
506 mt76_wr(dev, MT_EDCA_CFG_AC(qid), val);
508 val = mt76_rr(dev, MT_WMM_TXOP(qid));
509 val &= ~(MT_WMM_TXOP_MASK << MT_WMM_TXOP_SHIFT(qid));
510 val |= params->txop << MT_WMM_TXOP_SHIFT(qid);
511 mt76_wr(dev, MT_WMM_TXOP(qid), val);
513 val = mt76_rr(dev, MT_WMM_AIFSN);
514 val &= ~(MT_WMM_AIFSN_MASK << MT_WMM_AIFSN_SHIFT(qid));
515 val |= params->aifs << MT_WMM_AIFSN_SHIFT(qid);
516 mt76_wr(dev, MT_WMM_AIFSN, val);
518 val = mt76_rr(dev, MT_WMM_CWMIN);
519 val &= ~(MT_WMM_CWMIN_MASK << MT_WMM_CWMIN_SHIFT(qid));
520 val |= cw_min << MT_WMM_CWMIN_SHIFT(qid);
521 mt76_wr(dev, MT_WMM_CWMIN, val);
523 val = mt76_rr(dev, MT_WMM_CWMAX);
524 val &= ~(MT_WMM_CWMAX_MASK << MT_WMM_CWMAX_SHIFT(qid));
525 val |= cw_max << MT_WMM_CWMAX_SHIFT(qid);
526 mt76_wr(dev, MT_WMM_CWMAX, val);
530 EXPORT_SYMBOL_GPL(mt76x02_conf_tx);
532 void mt76x02_set_tx_ackto(struct mt76x02_dev *dev)
534 u8 ackto, sifs, slottime = dev->slottime;
536 /* As defined by IEEE 802.11-2007 17.3.8.6 */
537 slottime += 3 * dev->coverage_class;
538 mt76_rmw_field(dev, MT_BKOFF_SLOT_CFG,
539 MT_BKOFF_SLOT_CFG_SLOTTIME, slottime);
541 sifs = mt76_get_field(dev, MT_XIFS_TIME_CFG,
542 MT_XIFS_TIME_CFG_OFDM_SIFS);
544 ackto = slottime + sifs;
545 mt76_rmw_field(dev, MT_TX_TIMEOUT_CFG,
546 MT_TX_TIMEOUT_CFG_ACKTO, ackto);
548 EXPORT_SYMBOL_GPL(mt76x02_set_tx_ackto);
550 void mt76x02_set_coverage_class(struct ieee80211_hw *hw,
553 struct mt76x02_dev *dev = hw->priv;
555 mutex_lock(&dev->mt76.mutex);
556 dev->coverage_class = max_t(s16, coverage_class, 0);
557 mt76x02_set_tx_ackto(dev);
558 mutex_unlock(&dev->mt76.mutex);
560 EXPORT_SYMBOL_GPL(mt76x02_set_coverage_class);
562 int mt76x02_set_rts_threshold(struct ieee80211_hw *hw, u32 val)
564 struct mt76x02_dev *dev = hw->priv;
566 if (val != ~0 && val > 0xffff)
569 mutex_lock(&dev->mt76.mutex);
570 mt76x02_mac_set_rts_thresh(dev, val);
571 mutex_unlock(&dev->mt76.mutex);
575 EXPORT_SYMBOL_GPL(mt76x02_set_rts_threshold);
577 void mt76x02_sta_rate_tbl_update(struct ieee80211_hw *hw,
578 struct ieee80211_vif *vif,
579 struct ieee80211_sta *sta)
581 struct mt76x02_dev *dev = hw->priv;
582 struct mt76x02_sta *msta = (struct mt76x02_sta *)sta->drv_priv;
583 struct ieee80211_sta_rates *rates = rcu_dereference(sta->rates);
584 struct ieee80211_tx_rate rate = {};
589 rate.idx = rates->rate[0].idx;
590 rate.flags = rates->rate[0].flags;
591 mt76x02_mac_wcid_set_rate(dev, &msta->wcid, &rate);
593 EXPORT_SYMBOL_GPL(mt76x02_sta_rate_tbl_update);
595 void mt76x02_remove_hdr_pad(struct sk_buff *skb, int len)
602 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
603 memmove(skb->data + len, skb->data, hdrlen);
606 EXPORT_SYMBOL_GPL(mt76x02_remove_hdr_pad);
608 void mt76x02_sw_scan_complete(struct ieee80211_hw *hw,
609 struct ieee80211_vif *vif)
611 struct mt76x02_dev *dev = hw->priv;
613 clear_bit(MT76_SCANNING, &dev->mphy.state);
614 if (dev->cal.gain_init_done) {
615 /* Restore AGC gain and resume calibration after scanning. */
616 dev->cal.low_gain = -1;
617 ieee80211_queue_delayed_work(hw, &dev->cal_work, 0);
620 EXPORT_SYMBOL_GPL(mt76x02_sw_scan_complete);
622 void mt76x02_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta,
625 struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
626 struct mt76x02_sta *msta = (struct mt76x02_sta *)sta->drv_priv;
627 int idx = msta->wcid.idx;
629 mt76_stop_tx_queues(&dev->mphy, sta, true);
630 if (mt76_is_mmio(mdev))
631 mt76x02_mac_wcid_set_drop(dev, idx, ps);
633 EXPORT_SYMBOL_GPL(mt76x02_sta_ps);
635 void mt76x02_bss_info_changed(struct ieee80211_hw *hw,
636 struct ieee80211_vif *vif,
637 struct ieee80211_bss_conf *info,
640 struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
641 struct mt76x02_dev *dev = hw->priv;
643 mutex_lock(&dev->mt76.mutex);
645 if (changed & BSS_CHANGED_BSSID)
646 mt76x02_mac_set_bssid(dev, mvif->idx, info->bssid);
648 if (changed & BSS_CHANGED_HT || changed & BSS_CHANGED_ERP_CTS_PROT)
649 mt76x02_mac_set_tx_protection(dev, info->use_cts_prot,
650 info->ht_operation_mode);
652 if (changed & BSS_CHANGED_BEACON_INT) {
653 mt76_rmw_field(dev, MT_BEACON_TIME_CFG,
654 MT_BEACON_TIME_CFG_INTVAL,
655 info->beacon_int << 4);
656 dev->mt76.beacon_int = info->beacon_int;
659 if (changed & BSS_CHANGED_BEACON_ENABLED)
660 mt76x02_mac_set_beacon_enable(dev, vif, info->enable_beacon);
662 if (changed & BSS_CHANGED_ERP_PREAMBLE)
663 mt76x02_mac_set_short_preamble(dev, info->use_short_preamble);
665 if (changed & BSS_CHANGED_ERP_SLOT) {
666 int slottime = info->use_short_slot ? 9 : 20;
668 dev->slottime = slottime;
669 mt76x02_set_tx_ackto(dev);
672 mutex_unlock(&dev->mt76.mutex);
674 EXPORT_SYMBOL_GPL(mt76x02_bss_info_changed);
676 void mt76x02_config_mac_addr_list(struct mt76x02_dev *dev)
678 struct ieee80211_hw *hw = mt76_hw(dev);
679 struct wiphy *wiphy = hw->wiphy;
682 for (i = 0; i < ARRAY_SIZE(dev->macaddr_list); i++) {
683 u8 *addr = dev->macaddr_list[i].addr;
685 memcpy(addr, dev->mphy.macaddr, ETH_ALEN);
691 addr[0] ^= ((i - 1) << 2);
693 wiphy->addresses = dev->macaddr_list;
694 wiphy->n_addresses = ARRAY_SIZE(dev->macaddr_list);
696 EXPORT_SYMBOL_GPL(mt76x02_config_mac_addr_list);
698 MODULE_LICENSE("Dual BSD/GPL");