Skip to content

Commit 5cf2740

Browse files
author
Kalle Valo
committed
Merge tag 'mt76-for-kvalo-2020-05-28' of https://github.com/nbd168/wireless
mt76 patches for 5.8 * fixes for sparse warnings * DBDC fixes * mt7663 remain-on-channel support * mt7915 spatial reuse support * mt7915 radiotap fix * station wcid allocation fix * mt7663 powersave fix * mt7663 scan fix * mt7611n support * cleanup # gpg: Signature made Thu 28 May 2020 07:02:21 PM EEST using DSA key ID 02A76EF5 # gpg: Good signature from "Felix Fietkau <[email protected]>" # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 75D1 1A7D 91A7 710F 4900 42EF D77D 141D 02A7 6EF5
2 parents 982d728 + d9045b1 commit 5cf2740

File tree

27 files changed

+335
-124
lines changed

27 files changed

+335
-124
lines changed

drivers/net/wireless/mediatek/mt76/debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static int mt76_rx_queues_read(struct seq_file *s, void *data)
5151
struct mt76_dev *dev = dev_get_drvdata(s->private);
5252
int i, queued;
5353

54-
for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++) {
54+
mt76_for_each_q_rx(dev, i) {
5555
struct mt76_queue *q = &dev->q_rx[i];
5656

5757
if (!q->ndesc)

drivers/net/wireless/mediatek/mt76/dma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ mt76_dma_init(struct mt76_dev *dev)
576576

577577
init_dummy_netdev(&dev->napi_dev);
578578

579-
for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++) {
579+
mt76_for_each_q_rx(dev, i) {
580580
netif_napi_add(&dev->napi_dev, &dev->napi[i], mt76_dma_rx_poll,
581581
64);
582582
mt76_dma_rx_fill(dev, &dev->q_rx[i]);
@@ -610,7 +610,7 @@ void mt76_dma_cleanup(struct mt76_dev *dev)
610610
for (i = 0; i < ARRAY_SIZE(dev->q_tx); i++)
611611
mt76_dma_tx_cleanup(dev, i, true);
612612

613-
for (i = 0; i < ARRAY_SIZE(dev->q_rx); i++) {
613+
mt76_for_each_q_rx(dev, i) {
614614
netif_napi_del(&dev->napi[i]);
615615
mt76_dma_rx_cleanup(dev, &dev->q_rx[i]);
616616
}

drivers/net/wireless/mediatek/mt76/mt76.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ enum {
288288
MT76_REMOVED,
289289
MT76_READING_STATS,
290290
MT76_STATE_POWER_OFF,
291-
MT76_STATE_PS,
292291
MT76_STATE_SUSPEND,
292+
MT76_STATE_ROC,
293293
};
294294

295295
struct mt76_hw_cap {
@@ -537,8 +537,8 @@ struct mt76_dev {
537537
wait_queue_head_t tx_wait;
538538
struct sk_buff_head status_list;
539539

540-
unsigned long wcid_mask[MT76_N_WCIDS / BITS_PER_LONG];
541-
unsigned long wcid_phy_mask[MT76_N_WCIDS / BITS_PER_LONG];
540+
u32 wcid_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)];
541+
u32 wcid_phy_mask[DIV_ROUND_UP(MT76_N_WCIDS, 32)];
542542

543543
struct mt76_wcid global_wcid;
544544
struct mt76_wcid __rcu *wcid[MT76_N_WCIDS];
@@ -671,6 +671,10 @@ static inline u16 mt76_rev(struct mt76_dev *dev)
671671
#define mt76_queue_tx_cleanup(dev, ...) (dev)->mt76.queue_ops->tx_cleanup(&((dev)->mt76), __VA_ARGS__)
672672
#define mt76_queue_kick(dev, ...) (dev)->mt76.queue_ops->kick(&((dev)->mt76), __VA_ARGS__)
673673

674+
#define mt76_for_each_q_rx(dev, i) \
675+
for (i = 0; i < ARRAY_SIZE((dev)->q_rx) && \
676+
(dev)->q_rx[i].ndesc; i++)
677+
674678
struct mt76_dev *mt76_alloc_device(struct device *pdev, unsigned int size,
675679
const struct ieee80211_ops *ops,
676680
const struct mt76_driver_ops *drv_ops);

drivers/net/wireless/mediatek/mt76/mt7603/mac.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ mt7603_rx_get_wcid(struct mt7603_dev *dev, u8 idx, bool unicast)
473473
struct mt7603_sta *sta;
474474
struct mt76_wcid *wcid;
475475

476-
if (idx >= ARRAY_SIZE(dev->mt76.wcid))
476+
if (idx >= MT7603_WTBL_SIZE)
477477
return NULL;
478478

479479
wcid = rcu_dereference(dev->mt76.wcid[idx]);
@@ -1238,7 +1238,7 @@ void mt7603_mac_add_txs(struct mt7603_dev *dev, void *data)
12381238
if (pid == MT_PACKET_ID_NO_ACK)
12391239
return;
12401240

1241-
if (wcidx >= ARRAY_SIZE(dev->mt76.wcid))
1241+
if (wcidx >= MT7603_WTBL_SIZE)
12421242
return;
12431243

12441244
rcu_read_lock();
@@ -1438,8 +1438,9 @@ static void mt7603_mac_watchdog_reset(struct mt7603_dev *dev)
14381438
for (i = 0; i < __MT_TXQ_MAX; i++)
14391439
mt76_queue_tx_cleanup(dev, i, true);
14401440

1441-
for (i = 0; i < ARRAY_SIZE(dev->mt76.q_rx); i++)
1441+
mt76_for_each_q_rx(&dev->mt76, i) {
14421442
mt76_queue_rx_reset(dev, i);
1443+
}
14431444

14441445
mt7603_dma_sched_reset(dev);
14451446

drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ mt7615_eeprom_parse_hw_band_cap(struct mt7615_dev *dev)
111111
return;
112112
}
113113

114+
if (is_mt7611(&dev->mt76)) {
115+
/* 5GHz only */
116+
dev->mt76.cap.has_5ghz = true;
117+
return;
118+
}
119+
114120
val = FIELD_GET(MT_EE_NIC_WIFI_CONF_BAND_SEL,
115121
eeprom[MT_EE_WIFI_CONF]);
116122
switch (val) {
@@ -310,6 +316,7 @@ static void mt7615_cal_free_data(struct mt7615_dev *dev)
310316
mt7622_apply_cal_free_data(dev);
311317
break;
312318
case 0x7615:
319+
case 0x7611:
313320
mt7615_apply_cal_free_data(dev);
314321
break;
315322
}

drivers/net/wireless/mediatek/mt76/mt7615/init.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,10 @@ void mt7615_check_offload_capability(struct mt7615_dev *dev)
139139
ieee80211_hw_set(hw, SUPPORTS_PS);
140140
ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS);
141141

142+
wiphy->max_remain_on_channel_duration = 5000;
142143
wiphy->features |= NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR |
143144
NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR |
145+
WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
144146
NL80211_FEATURE_P2P_GO_CTWIN |
145147
NL80211_FEATURE_P2P_GO_OPPPS;
146148
} else {
@@ -149,6 +151,8 @@ void mt7615_check_offload_capability(struct mt7615_dev *dev)
149151
dev->ops->sched_scan_start = NULL;
150152
dev->ops->sched_scan_stop = NULL;
151153
dev->ops->set_rekey_data = NULL;
154+
dev->ops->remain_on_channel = NULL;
155+
dev->ops->cancel_remain_on_channel = NULL;
152156

153157
wiphy->max_sched_scan_plan_interval = 0;
154158
wiphy->max_sched_scan_ie_len = 0;
@@ -368,12 +372,6 @@ int mt7615_register_ext_phy(struct mt7615_dev *dev)
368372
if (phy)
369373
return 0;
370374

371-
INIT_DELAYED_WORK(&phy->mac_work, mt7615_mac_work);
372-
INIT_DELAYED_WORK(&phy->scan_work, mt7615_scan_work);
373-
skb_queue_head_init(&phy->scan_event_list);
374-
375-
INIT_WORK(&phy->ps_work, mt7615_ps_work);
376-
377375
mt7615_cap_dbdc_enable(dev);
378376
mphy = mt76_alloc_phy(&dev->mt76, sizeof(*phy), &mt7615_ops);
379377
if (!mphy)
@@ -386,6 +384,14 @@ int mt7615_register_ext_phy(struct mt7615_dev *dev)
386384
mphy->antenna_mask = BIT(hweight8(phy->chainmask)) - 1;
387385
mt7615_init_wiphy(mphy->hw);
388386

387+
INIT_DELAYED_WORK(&phy->mac_work, mt7615_mac_work);
388+
INIT_DELAYED_WORK(&phy->scan_work, mt7615_scan_work);
389+
skb_queue_head_init(&phy->scan_event_list);
390+
391+
INIT_WORK(&phy->roc_work, mt7615_roc_work);
392+
timer_setup(&phy->roc_timer, mt7615_roc_timer, 0);
393+
init_waitqueue_head(&phy->roc_wait);
394+
389395
mt7615_mac_set_scs(phy, true);
390396

391397
/*
@@ -437,9 +443,11 @@ void mt7615_init_device(struct mt7615_dev *dev)
437443
INIT_LIST_HEAD(&dev->sta_poll_list);
438444
spin_lock_init(&dev->sta_poll_lock);
439445
init_waitqueue_head(&dev->reset_wait);
446+
init_waitqueue_head(&dev->phy.roc_wait);
440447

441448
INIT_WORK(&dev->reset_work, mt7615_mac_reset_work);
442-
INIT_WORK(&dev->phy.ps_work, mt7615_ps_work);
449+
INIT_WORK(&dev->phy.roc_work, mt7615_roc_work);
450+
timer_setup(&dev->phy.roc_timer, mt7615_roc_timer, 0);
443451

444452
mt7615_init_wiphy(hw);
445453
dev->mphy.sband_2g.sband.ht_cap.cap |= IEEE80211_HT_CAP_LDPC_CODING;

drivers/net/wireless/mediatek/mt76/mt7615/mac.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static struct mt76_wcid *mt7615_rx_get_wcid(struct mt7615_dev *dev,
6161
struct mt7615_sta *sta;
6262
struct mt76_wcid *wcid;
6363

64-
if (idx >= ARRAY_SIZE(dev->mt76.wcid))
64+
if (idx >= MT7615_WTBL_SIZE)
6565
return NULL;
6666

6767
wcid = rcu_dereference(dev->mt76.wcid[idx]);
@@ -175,7 +175,8 @@ mt7615_get_status_freq_info(struct mt7615_dev *dev, struct mt76_phy *mphy,
175175
struct mt76_rx_status *status, u8 chfreq)
176176
{
177177
if (!test_bit(MT76_HW_SCANNING, &mphy->state) &&
178-
!test_bit(MT76_HW_SCHED_SCANNING, &mphy->state)) {
178+
!test_bit(MT76_HW_SCHED_SCANNING, &mphy->state) &&
179+
!test_bit(MT76_STATE_ROC, &mphy->state)) {
179180
status->freq = mphy->chandef.chan->center_freq;
180181
status->band = mphy->chandef.chan->band;
181182
return;
@@ -1302,7 +1303,7 @@ static void mt7615_mac_add_txs(struct mt7615_dev *dev, void *data)
13021303
if (pid == MT_PACKET_ID_NO_ACK)
13031304
return;
13041305

1305-
if (wcidx >= ARRAY_SIZE(dev->mt76.wcid))
1306+
if (wcidx >= MT7615_WTBL_SIZE)
13061307
return;
13071308

13081309
rcu_read_lock();
@@ -1819,8 +1820,9 @@ void mt7615_dma_reset(struct mt7615_dev *dev)
18191820
for (i = 0; i < __MT_TXQ_MAX; i++)
18201821
mt76_queue_tx_cleanup(dev, i, true);
18211822

1822-
for (i = 0; i < ARRAY_SIZE(dev->mt76.q_rx); i++)
1823+
mt76_for_each_q_rx(&dev->mt76, i) {
18231824
mt76_queue_rx_reset(dev, i);
1825+
}
18241826

18251827
mt76_set(dev, MT_WPDMA_GLO_CFG,
18261828
MT_WPDMA_GLO_CFG_RX_DMA_EN | MT_WPDMA_GLO_CFG_TX_DMA_EN |
@@ -1849,8 +1851,13 @@ void mt7615_mac_reset_work(struct work_struct *work)
18491851
set_bit(MT76_MCU_RESET, &dev->mphy.state);
18501852
wake_up(&dev->mt76.mcu.wait);
18511853
cancel_delayed_work_sync(&dev->phy.mac_work);
1852-
if (phy2)
1854+
del_timer_sync(&dev->phy.roc_timer);
1855+
cancel_work_sync(&dev->phy.roc_work);
1856+
if (phy2) {
18531857
cancel_delayed_work_sync(&phy2->mac_work);
1858+
del_timer_sync(&phy2->roc_timer);
1859+
cancel_work_sync(&phy2->roc_work);
1860+
}
18541861

18551862
/* lock/unlock all queues to ensure that no tx is pending */
18561863
mt76_txq_schedule_all(&dev->mphy);

drivers/net/wireless/mediatek/mt76/mt7615/main.c

Lines changed: 83 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ static void mt7615_stop(struct ieee80211_hw *hw)
7171
struct mt7615_phy *phy = mt7615_hw_phy(hw);
7272

7373
cancel_delayed_work_sync(&phy->mac_work);
74-
cancel_work_sync(&phy->ps_work);
74+
del_timer_sync(&phy->roc_timer);
75+
cancel_work_sync(&phy->roc_work);
7576

7677
mutex_lock(&dev->mt76.mutex);
7778

@@ -289,12 +290,11 @@ mt7615_queue_key_update(struct mt7615_dev *dev, enum set_key_cmd cmd,
289290
wd->type = MT7615_WTBL_KEY_DESC;
290291
wd->sta = msta;
291292

292-
wd->key.key = kzalloc(key->keylen, GFP_KERNEL);
293+
wd->key.key = kmemdup(key->key, key->keylen, GFP_KERNEL);
293294
if (!wd->key.key) {
294295
kfree(wd);
295296
return -ENOMEM;
296297
}
297-
memcpy(wd->key.key, key->key, key->keylen);
298298
wd->key.cipher = key->cipher;
299299
wd->key.keyidx = key->keyidx;
300300
wd->key.keylen = key->keylen;
@@ -360,20 +360,6 @@ static int mt7615_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
360360
return mt7615_mac_wtbl_set_key(dev, wcid, key, cmd);
361361
}
362362

363-
void mt7615_ps_work(struct work_struct *work)
364-
{
365-
struct mt7615_phy *phy;
366-
367-
phy = (struct mt7615_phy *)container_of(work, struct mt7615_phy,
368-
ps_work);
369-
370-
mutex_lock(&phy->dev->mt76.mutex);
371-
ieee80211_iterate_active_interfaces(phy->mt76->hw,
372-
IEEE80211_IFACE_ITER_RESUME_ALL,
373-
m7615_mcu_set_ps_iter, phy);
374-
mutex_unlock(&phy->dev->mt76.mutex);
375-
}
376-
377363
static int mt7615_config(struct ieee80211_hw *hw, u32 changed)
378364
{
379365
struct mt7615_dev *dev = mt7615_hw_dev(hw);
@@ -399,14 +385,6 @@ static int mt7615_config(struct ieee80211_hw *hw, u32 changed)
399385
mt76_wr(dev, MT_WF_RFCR(band), phy->rxfilter);
400386
}
401387

402-
if (changed & IEEE80211_CONF_CHANGE_PS) {
403-
if (hw->conf.flags & IEEE80211_CONF_PS)
404-
set_bit(MT76_STATE_PS, &phy->mt76->state);
405-
else
406-
clear_bit(MT76_STATE_PS, &phy->mt76->state);
407-
ieee80211_queue_work(hw, &phy->ps_work);
408-
}
409-
410388
mutex_unlock(&dev->mt76.mutex);
411389

412390
return ret;
@@ -509,6 +487,9 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
509487
BSS_CHANGED_BEACON_ENABLED))
510488
mt7615_mcu_add_beacon(dev, hw, vif, info->enable_beacon);
511489

490+
if (changed & BSS_CHANGED_PS)
491+
mt7615_mcu_set_vif_ps(dev, vif);
492+
512493
mutex_unlock(&dev->mt76.mutex);
513494
}
514495

@@ -791,6 +772,37 @@ mt7615_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
791772
return 0;
792773
}
793774

775+
static void mt7615_roc_iter(void *priv, u8 *mac,
776+
struct ieee80211_vif *vif)
777+
{
778+
struct mt7615_phy *phy = priv;
779+
780+
mt7615_mcu_set_roc(phy, vif, NULL, 0);
781+
}
782+
783+
void mt7615_roc_work(struct work_struct *work)
784+
{
785+
struct mt7615_phy *phy;
786+
787+
phy = (struct mt7615_phy *)container_of(work, struct mt7615_phy,
788+
roc_work);
789+
790+
if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
791+
return;
792+
793+
ieee80211_iterate_active_interfaces(phy->mt76->hw,
794+
IEEE80211_IFACE_ITER_RESUME_ALL,
795+
mt7615_roc_iter, phy);
796+
ieee80211_remain_on_channel_expired(phy->mt76->hw);
797+
}
798+
799+
void mt7615_roc_timer(struct timer_list *timer)
800+
{
801+
struct mt7615_phy *phy = from_timer(phy, timer, roc_timer);
802+
803+
ieee80211_queue_work(phy->mt76->hw, &phy->roc_work);
804+
}
805+
794806
void mt7615_scan_work(struct work_struct *work)
795807
{
796808
struct mt7615_phy *phy;
@@ -864,6 +876,50 @@ mt7615_stop_sched_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
864876
return mt7615_mcu_sched_scan_enable(mphy->priv, vif, false);
865877
}
866878

879+
static int mt7615_remain_on_channel(struct ieee80211_hw *hw,
880+
struct ieee80211_vif *vif,
881+
struct ieee80211_channel *chan,
882+
int duration,
883+
enum ieee80211_roc_type type)
884+
{
885+
struct mt7615_phy *phy = mt7615_hw_phy(hw);
886+
int err;
887+
888+
if (test_and_set_bit(MT76_STATE_ROC, &phy->mt76->state))
889+
return 0;
890+
891+
err = mt7615_mcu_set_roc(phy, vif, chan, duration);
892+
if (err < 0) {
893+
clear_bit(MT76_STATE_ROC, &phy->mt76->state);
894+
return err;
895+
}
896+
897+
if (!wait_event_timeout(phy->roc_wait, phy->roc_grant, HZ)) {
898+
mt7615_mcu_set_roc(phy, vif, NULL, 0);
899+
clear_bit(MT76_STATE_ROC, &phy->mt76->state);
900+
901+
return -ETIMEDOUT;
902+
}
903+
904+
return 0;
905+
}
906+
907+
static int mt7615_cancel_remain_on_channel(struct ieee80211_hw *hw,
908+
struct ieee80211_vif *vif)
909+
{
910+
struct mt7615_phy *phy = mt7615_hw_phy(hw);
911+
912+
if (!test_and_clear_bit(MT76_STATE_ROC, &phy->mt76->state))
913+
return 0;
914+
915+
del_timer_sync(&phy->roc_timer);
916+
cancel_work_sync(&phy->roc_work);
917+
918+
mt7615_mcu_set_roc(phy, vif, NULL, 0);
919+
920+
return 0;
921+
}
922+
867923
#ifdef CONFIG_PM
868924
static int mt7615_suspend(struct ieee80211_hw *hw,
869925
struct cfg80211_wowlan *wowlan)
@@ -978,6 +1034,8 @@ const struct ieee80211_ops mt7615_ops = {
9781034
.cancel_hw_scan = mt7615_cancel_hw_scan,
9791035
.sched_scan_start = mt7615_start_sched_scan,
9801036
.sched_scan_stop = mt7615_stop_sched_scan,
1037+
.remain_on_channel = mt7615_remain_on_channel,
1038+
.cancel_remain_on_channel = mt7615_cancel_remain_on_channel,
9811039
#ifdef CONFIG_PM
9821040
.suspend = mt7615_suspend,
9831041
.resume = mt7615_resume,

0 commit comments

Comments
 (0)