Skip to content

Commit abbd838

Browse files
author
Kalle Valo
committed
Merge tag 'mt76-for-kvalo-2024-09-06' of https://github.com/nbd168/wireless
mt76 patches for 6.12 - fixes - mt7915 .sta_state support - mt7915 hardware restart improvements
2 parents 0af2b1b + 6bba05d commit abbd838

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+622
-406
lines changed

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

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -929,14 +929,19 @@ void mt76_update_survey(struct mt76_phy *phy)
929929
}
930930
EXPORT_SYMBOL_GPL(mt76_update_survey);
931931

932-
void mt76_set_channel(struct mt76_phy *phy)
932+
int mt76_set_channel(struct mt76_phy *phy, struct cfg80211_chan_def *chandef,
933+
bool offchannel)
933934
{
934935
struct mt76_dev *dev = phy->dev;
935-
struct ieee80211_hw *hw = phy->hw;
936-
struct cfg80211_chan_def *chandef = &hw->conf.chandef;
937-
bool offchannel = hw->conf.flags & IEEE80211_CONF_OFFCHANNEL;
938936
int timeout = HZ / 5;
937+
int ret;
939938

939+
cancel_delayed_work_sync(&phy->mac_work);
940+
941+
mutex_lock(&dev->mutex);
942+
set_bit(MT76_RESET, &phy->state);
943+
944+
mt76_worker_disable(&dev->tx_worker);
940945
wait_event_timeout(dev->tx_wait, !mt76_has_tx_pending(phy), timeout);
941946
mt76_update_survey(phy);
942947

@@ -946,14 +951,34 @@ void mt76_set_channel(struct mt76_phy *phy)
946951

947952
phy->chandef = *chandef;
948953
phy->chan_state = mt76_channel_state(phy, chandef->chan);
954+
phy->offchannel = offchannel;
949955

950956
if (!offchannel)
951957
phy->main_chan = chandef->chan;
952958

953959
if (chandef->chan != phy->main_chan)
954960
memset(phy->chan_state, 0, sizeof(*phy->chan_state));
961+
mt76_worker_enable(&dev->tx_worker);
962+
963+
ret = dev->drv->set_channel(phy);
964+
965+
clear_bit(MT76_RESET, &phy->state);
966+
mt76_worker_schedule(&dev->tx_worker);
967+
968+
mutex_unlock(&dev->mutex);
969+
970+
return ret;
955971
}
956-
EXPORT_SYMBOL_GPL(mt76_set_channel);
972+
973+
int mt76_update_channel(struct mt76_phy *phy)
974+
{
975+
struct ieee80211_hw *hw = phy->hw;
976+
struct cfg80211_chan_def *chandef = &hw->conf.chandef;
977+
bool offchannel = hw->conf.flags & IEEE80211_CONF_OFFCHANNEL;
978+
979+
return mt76_set_channel(phy, chandef, offchannel);
980+
}
981+
EXPORT_SYMBOL_GPL(mt76_update_channel);
957982

958983
int mt76_get_survey(struct ieee80211_hw *hw, int idx,
959984
struct survey_info *survey)
@@ -1484,21 +1509,32 @@ int mt76_sta_state(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
14841509
{
14851510
struct mt76_phy *phy = hw->priv;
14861511
struct mt76_dev *dev = phy->dev;
1512+
enum mt76_sta_event ev;
14871513

14881514
if (old_state == IEEE80211_STA_NOTEXIST &&
14891515
new_state == IEEE80211_STA_NONE)
14901516
return mt76_sta_add(phy, vif, sta);
14911517

1492-
if (old_state == IEEE80211_STA_AUTH &&
1493-
new_state == IEEE80211_STA_ASSOC &&
1494-
dev->drv->sta_assoc)
1495-
dev->drv->sta_assoc(dev, vif, sta);
1496-
14971518
if (old_state == IEEE80211_STA_NONE &&
14981519
new_state == IEEE80211_STA_NOTEXIST)
14991520
mt76_sta_remove(dev, vif, sta);
15001521

1501-
return 0;
1522+
if (!dev->drv->sta_event)
1523+
return 0;
1524+
1525+
if (old_state == IEEE80211_STA_AUTH &&
1526+
new_state == IEEE80211_STA_ASSOC)
1527+
ev = MT76_STA_EVENT_ASSOC;
1528+
else if (old_state == IEEE80211_STA_ASSOC &&
1529+
new_state == IEEE80211_STA_AUTHORIZED)
1530+
ev = MT76_STA_EVENT_AUTHORIZE;
1531+
else if (old_state == IEEE80211_STA_ASSOC &&
1532+
new_state == IEEE80211_STA_AUTH)
1533+
ev = MT76_STA_EVENT_DISASSOC;
1534+
else
1535+
return 0;
1536+
1537+
return dev->drv->sta_event(dev, vif, sta, ev);
15021538
}
15031539
EXPORT_SYMBOL_GPL(mt76_sta_state);
15041540

@@ -1521,6 +1557,7 @@ void mt76_wcid_init(struct mt76_wcid *wcid)
15211557
{
15221558
INIT_LIST_HEAD(&wcid->tx_list);
15231559
skb_queue_head_init(&wcid->tx_pending);
1560+
skb_queue_head_init(&wcid->tx_offchannel);
15241561

15251562
INIT_LIST_HEAD(&wcid->list);
15261563
idr_init(&wcid->pktid);
@@ -1529,7 +1566,7 @@ EXPORT_SYMBOL_GPL(mt76_wcid_init);
15291566

15301567
void mt76_wcid_cleanup(struct mt76_dev *dev, struct mt76_wcid *wcid)
15311568
{
1532-
struct mt76_phy *phy = dev->phys[wcid->phy_idx];
1569+
struct mt76_phy *phy = mt76_dev_phy(dev, wcid->phy_idx);
15331570
struct ieee80211_hw *hw;
15341571
struct sk_buff_head list;
15351572
struct sk_buff *skb;
@@ -1697,14 +1734,15 @@ int mt76_get_rate(struct mt76_dev *dev,
16971734
struct ieee80211_supported_band *sband,
16981735
int idx, bool cck)
16991736
{
1737+
bool is_2g = sband->band == NL80211_BAND_2GHZ;
17001738
int i, offset = 0, len = sband->n_bitrates;
17011739

17021740
if (cck) {
1703-
if (sband != &dev->phy.sband_2g.sband)
1741+
if (!is_2g)
17041742
return 0;
17051743

17061744
idx &= ~BIT(2); /* short preamble */
1707-
} else if (sband == &dev->phy.sband_2g.sband) {
1745+
} else if (is_2g) {
17081746
offset = 4;
17091747
}
17101748

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
7373
int cmd, bool wait_resp,
7474
struct sk_buff **ret_skb)
7575
{
76+
unsigned int retry = 0;
77+
struct sk_buff *orig_skb = NULL;
7678
unsigned long expires;
7779
int ret, seq;
7880

@@ -81,6 +83,14 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
8183

8284
mutex_lock(&dev->mcu.mutex);
8385

86+
if (dev->mcu_ops->mcu_skb_prepare_msg) {
87+
ret = dev->mcu_ops->mcu_skb_prepare_msg(dev, skb, cmd, &seq);
88+
if (ret < 0)
89+
goto out;
90+
}
91+
92+
retry:
93+
orig_skb = skb_get(skb);
8494
ret = dev->mcu_ops->mcu_skb_send_msg(dev, skb, cmd, &seq);
8595
if (ret < 0)
8696
goto out;
@@ -94,14 +104,24 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
94104

95105
do {
96106
skb = mt76_mcu_get_response(dev, expires);
107+
if (!skb && !test_bit(MT76_MCU_RESET, &dev->phy.state) &&
108+
retry++ < dev->mcu_ops->max_retry) {
109+
dev_err(dev->dev, "Retry message %08x (seq %d)\n",
110+
cmd, seq);
111+
skb = orig_skb;
112+
goto retry;
113+
}
114+
97115
ret = dev->mcu_ops->mcu_parse_response(dev, cmd, skb, seq);
98116
if (!ret && ret_skb)
99117
*ret_skb = skb;
100118
else
101119
dev_kfree_skb(skb);
102120
} while (ret == -EAGAIN);
103121

122+
104123
out:
124+
dev_kfree_skb(orig_skb);
105125
mutex_unlock(&dev->mcu.mutex);
106126

107127
return ret;

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ enum mt76_dfs_state {
162162

163163
struct mt76_queue_buf {
164164
dma_addr_t addr;
165-
u16 len;
166-
bool skip_unmap;
165+
u16 len:15,
166+
skip_unmap:1;
167167
};
168168

169169
struct mt76_tx_info {
@@ -230,11 +230,14 @@ struct mt76_queue {
230230
};
231231

232232
struct mt76_mcu_ops {
233+
unsigned int max_retry;
233234
u32 headroom;
234235
u32 tailroom;
235236

236237
int (*mcu_send_msg)(struct mt76_dev *dev, int cmd, const void *data,
237238
int len, bool wait_resp);
239+
int (*mcu_skb_prepare_msg)(struct mt76_dev *dev, struct sk_buff *skb,
240+
int cmd, int *seq);
238241
int (*mcu_skb_send_msg)(struct mt76_dev *dev, struct sk_buff *skb,
239242
int cmd, int *seq);
240243
int (*mcu_parse_response)(struct mt76_dev *dev, int cmd,
@@ -347,6 +350,7 @@ struct mt76_wcid {
347350
u8 hw_key_idx2;
348351

349352
u8 sta:1;
353+
u8 sta_disabled:1;
350354
u8 amsdu:1;
351355
u8 phy_idx:2;
352356
u8 link_id:4;
@@ -361,6 +365,7 @@ struct mt76_wcid {
361365

362366
struct list_head tx_list;
363367
struct sk_buff_head tx_pending;
368+
struct sk_buff_head tx_offchannel;
364369

365370
struct list_head list;
366371
struct idr pktid;
@@ -466,6 +471,12 @@ enum {
466471
MT76_STATE_WED_RESET,
467472
};
468473

474+
enum mt76_sta_event {
475+
MT76_STA_EVENT_ASSOC,
476+
MT76_STA_EVENT_AUTHORIZE,
477+
MT76_STA_EVENT_DISASSOC,
478+
};
479+
469480
struct mt76_hw_cap {
470481
bool has_2ghz;
471482
bool has_5ghz;
@@ -487,6 +498,7 @@ struct mt76_driver_ops {
487498
u8 mcs_rates;
488499

489500
void (*update_survey)(struct mt76_phy *phy);
501+
int (*set_channel)(struct mt76_phy *phy);
490502

491503
int (*tx_prepare_skb)(struct mt76_dev *dev, void *txwi_ptr,
492504
enum mt76_txq_id qid, struct mt76_wcid *wcid,
@@ -511,8 +523,8 @@ struct mt76_driver_ops {
511523
int (*sta_add)(struct mt76_dev *dev, struct ieee80211_vif *vif,
512524
struct ieee80211_sta *sta);
513525

514-
void (*sta_assoc)(struct mt76_dev *dev, struct ieee80211_vif *vif,
515-
struct ieee80211_sta *sta);
526+
int (*sta_event)(struct mt76_dev *dev, struct ieee80211_vif *vif,
527+
struct ieee80211_sta *sta, enum mt76_sta_event ev);
516528

517529
void (*sta_remove)(struct mt76_dev *dev, struct ieee80211_vif *vif,
518530
struct ieee80211_sta *sta);
@@ -768,6 +780,7 @@ struct mt76_phy {
768780

769781
struct cfg80211_chan_def chandef;
770782
struct ieee80211_channel *main_chan;
783+
bool offchannel;
771784

772785
struct mt76_channel_state *chan_state;
773786
enum mt76_dfs_state dfs_state;
@@ -1370,7 +1383,7 @@ void mt76_release_buffered_frames(struct ieee80211_hw *hw,
13701383
enum ieee80211_frame_release_type reason,
13711384
bool more_data);
13721385
bool mt76_has_tx_pending(struct mt76_phy *phy);
1373-
void mt76_set_channel(struct mt76_phy *phy);
1386+
int mt76_update_channel(struct mt76_phy *phy);
13741387
void mt76_update_survey(struct mt76_phy *phy);
13751388
void mt76_update_survey_active_time(struct mt76_phy *phy, ktime_t time);
13761389
int mt76_get_survey(struct ieee80211_hw *hw, int idx,
@@ -1484,6 +1497,8 @@ void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames);
14841497
void mt76_testmode_tx_pending(struct mt76_phy *phy);
14851498
void mt76_queue_tx_complete(struct mt76_dev *dev, struct mt76_queue *q,
14861499
struct mt76_queue_entry *e);
1500+
int mt76_set_channel(struct mt76_phy *phy, struct cfg80211_chan_def *chandef,
1501+
bool offchannel);
14871502

14881503
/* usb */
14891504
static inline bool mt76u_urb_error(struct urb *urb)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void mt7603_pre_tbtt_tasklet(struct tasklet_struct *t)
107107
struct sk_buff *skb;
108108
int i, nframes;
109109

110-
if (mt76_hw(dev)->conf.flags & IEEE80211_CONF_OFFCHANNEL)
110+
if (dev->mphy.offchannel)
111111
return;
112112

113113
data.dev = dev;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ mt7603_rx_loopback_skb(struct mt7603_dev *dev, struct sk_buff *skb)
2929
struct ieee80211_sta *sta;
3030
struct mt7603_sta *msta;
3131
struct mt76_wcid *wcid;
32-
u8 tid = 0, hwq = 0;
32+
u8 qid, tid = 0, hwq = 0;
3333
void *priv;
3434
int idx;
3535
u32 val;
@@ -57,7 +57,7 @@ mt7603_rx_loopback_skb(struct mt7603_dev *dev, struct sk_buff *skb)
5757
if (ieee80211_is_data_qos(hdr->frame_control)) {
5858
tid = *ieee80211_get_qos_ctl(hdr) &
5959
IEEE80211_QOS_CTL_TAG1D_MASK;
60-
u8 qid = tid_to_ac[tid];
60+
qid = tid_to_ac[tid];
6161
hwq = wmm_queue_map[qid];
6262
skb_set_queue_mapping(skb, qid);
6363
} else if (ieee80211_is_data(hdr->frame_control)) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ int mt7603_eeprom_init(struct mt7603_dev *dev)
181181
is_mt7688(dev))
182182
dev->mphy.antenna_mask = 1;
183183

184+
dev->mphy.chainmask = dev->mphy.antenna_mask;
184185
mt76_eeprom_override(&dev->mphy);
185186

186187
return 0;

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ const struct mt76_driver_ops mt7603_drv_ops = {
1515
.rx_poll_complete = mt7603_rx_poll_complete,
1616
.sta_ps = mt7603_sta_ps,
1717
.sta_add = mt7603_sta_add,
18-
.sta_assoc = mt7603_sta_assoc,
18+
.sta_event = mt7603_sta_event,
1919
.sta_remove = mt7603_sta_remove,
2020
.update_survey = mt7603_update_channel,
21+
.set_channel = mt7603_set_channel,
2122
};
2223

2324
static void
@@ -456,11 +457,13 @@ mt7603_init_txpower(struct mt7603_dev *dev,
456457
int target_power = eeprom[MT_EE_TX_POWER_0_START_2G + 2] & ~BIT(7);
457458
u8 *rate_power = &eeprom[MT_EE_TX_POWER_CCK];
458459
bool ext_pa = eeprom[MT_EE_NIC_CONF_0 + 1] & BIT(1);
460+
u8 ext_pa_pwr;
459461
int max_offset, cur_offset;
460462
int i;
461463

462-
if (ext_pa && is_mt7603(dev))
463-
target_power = eeprom[MT_EE_TX_POWER_TSSI_OFF] & ~BIT(7);
464+
ext_pa_pwr = eeprom[MT_EE_TX_POWER_TSSI_OFF];
465+
if (ext_pa && is_mt7603(dev) && ext_pa_pwr != 0 && ext_pa_pwr != 0xff)
466+
target_power = ext_pa_pwr & ~BIT(7);
464467

465468
if (target_power & BIT(6))
466469
target_power = -(target_power & GENMASK(5, 0));

0 commit comments

Comments
 (0)