Skip to content

Commit a0facfc

Browse files
csyuancnbd168
authored andcommitted
wifi: mt76: connac: rework connac helpers
Rework connac helpers related to rate and phymode. This is a preliminary patch to add MLO support for mt7996 chipsets. Co-developed-by: Bo Jiao <[email protected]> Signed-off-by: Bo Jiao <[email protected]> Signed-off-by: Shayne Chen <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Felix Fietkau <[email protected]>
1 parent 4b98d4a commit a0facfc

File tree

7 files changed

+22
-24
lines changed

7 files changed

+22
-24
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
427427
struct ieee80211_key_conf *key, int pid,
428428
enum mt76_txq_id qid, u32 changed);
429429
u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
430-
struct ieee80211_vif *vif,
430+
struct ieee80211_bss_conf *conf,
431431
bool beacon, bool mcast);
432432
bool mt76_connac2_mac_fill_txs(struct mt76_dev *dev, struct mt76_wcid *wcid,
433433
__le32 *txs_data);

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,28 +291,28 @@ EXPORT_SYMBOL_GPL(mt76_connac_init_tx_queues);
291291
})
292292

293293
u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
294-
struct ieee80211_vif *vif,
294+
struct ieee80211_bss_conf *conf,
295295
bool beacon, bool mcast)
296296
{
297-
struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv;
297+
struct mt76_vif_link *mvif = mt76_vif_conf_link(mphy->dev, conf->vif, conf);
298298
struct cfg80211_chan_def *chandef = mvif->ctx ?
299299
&mvif->ctx->def : &mphy->chandef;
300300
u8 nss = 0, mode = 0, band = chandef->chan->band;
301301
int rateidx = 0, mcast_rate;
302302
int offset = 0;
303303

304-
if (!vif)
304+
if (!conf)
305305
goto legacy;
306306

307307
if (is_mt7921(mphy->dev)) {
308-
rateidx = ffs(vif->bss_conf.basic_rates) - 1;
308+
rateidx = ffs(conf->basic_rates) - 1;
309309
goto legacy;
310310
}
311311

312312
if (beacon) {
313313
struct cfg80211_bitrate_mask *mask;
314314

315-
mask = &vif->bss_conf.beacon_tx_rate;
315+
mask = &conf->beacon_tx_rate;
316316

317317
__bitrate_mask_check(he_mcs, HE_SU);
318318
__bitrate_mask_check(vht_mcs, VHT);
@@ -324,11 +324,11 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
324324
}
325325
}
326326

327-
mcast_rate = vif->bss_conf.mcast_rate[band];
327+
mcast_rate = conf->mcast_rate[band];
328328
if (mcast && mcast_rate > 0)
329329
rateidx = mcast_rate - 1;
330330
else
331-
rateidx = ffs(vif->bss_conf.basic_rates) - 1;
331+
rateidx = ffs(conf->basic_rates) - 1;
332332

333333
legacy:
334334
if (band != NL80211_BAND_2GHZ)
@@ -581,7 +581,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
581581
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
582582
bool multicast = ieee80211_is_data(hdr->frame_control) &&
583583
is_multicast_ether_addr(hdr->addr1);
584-
u16 rate = mt76_connac2_mac_tx_rate_val(mphy, vif, beacon,
584+
u16 rate = mt76_connac2_mac_tx_rate_val(mphy, &vif->bss_conf, beacon,
585585
multicast);
586586
u32 val = MT_TXD6_FIXED_BW;
587587

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ u8 mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif,
13711371
}
13721372
EXPORT_SYMBOL_GPL(mt76_connac_get_phy_mode);
13731373

1374-
u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif,
1374+
u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_bss_conf *conf,
13751375
enum nl80211_band band)
13761376
{
13771377
const struct ieee80211_sta_eht_cap *eht_cap;
@@ -1382,9 +1382,9 @@ u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif,
13821382
mode |= PHY_MODE_AX_6G;
13831383

13841384
sband = phy->hw->wiphy->bands[band];
1385-
eht_cap = ieee80211_get_eht_iftype_cap(sband, vif->type);
1385+
eht_cap = ieee80211_get_eht_iftype_cap(sband, conf->vif->type);
13861386

1387-
if (!eht_cap || !eht_cap->has_eht || !vif->bss_conf.eht_support)
1387+
if (!eht_cap || !eht_cap->has_eht || !conf->eht_support)
13881388
return mode;
13891389

13901390
switch (band) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2018,7 +2018,7 @@ mt76_connac_get_eht_phy_cap(struct mt76_phy *phy, struct ieee80211_vif *vif);
20182018
u8 mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif,
20192019
enum nl80211_band band,
20202020
struct ieee80211_link_sta *sta);
2021-
u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_vif *vif,
2021+
u8 mt76_connac_get_phy_mode_ext(struct mt76_phy *phy, struct ieee80211_bss_conf *conf,
20222022
enum nl80211_band band);
20232023

20242024
int mt76_connac_mcu_add_key(struct mt76_dev *dev, struct ieee80211_vif *vif,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ mt7925_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
805805
u16 rate;
806806
u8 i, idx, ht;
807807

808-
rate = mt76_connac2_mac_tx_rate_val(mphy, vif, beacon, mcast);
808+
rate = mt76_connac2_mac_tx_rate_val(mphy, &vif->bss_conf, beacon, mcast);
809809
ht = FIELD_GET(MT_TX_RATE_MODE, rate) > MT_PHY_TYPE_OFDM;
810810

811811
if (beacon && ht) {

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -541,19 +541,17 @@ static void mt7996_configure_filter(struct ieee80211_hw *hw,
541541
}
542542

543543
static u8
544-
mt7996_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
544+
mt7996_get_rates_table(struct mt7996_phy *phy, struct ieee80211_bss_conf *conf,
545545
bool beacon, bool mcast)
546546
{
547-
struct mt76_vif_link *mvif = (struct mt76_vif_link *)vif->drv_priv;
548-
struct mt76_phy *mphy = hw->priv;
547+
struct mt7996_dev *dev = phy->dev;
548+
struct mt76_vif_link *mvif = mt76_vif_conf_link(&dev->mt76, conf->vif, conf);
549549
u16 rate;
550550
u8 i, idx;
551551

552-
rate = mt76_connac2_mac_tx_rate_val(mphy, vif, beacon, mcast);
552+
rate = mt76_connac2_mac_tx_rate_val(phy->mt76, conf, beacon, mcast);
553553

554554
if (beacon) {
555-
struct mt7996_phy *phy = mphy->priv;
556-
557555
/* odd index for driver, even index for firmware */
558556
idx = MT7996_BEACON_RATES_TBL + 2 * phy->mt76->band_idx;
559557
if (phy->beacon_rate != rate)
@@ -626,11 +624,11 @@ static void mt7996_bss_info_changed(struct ieee80211_hw *hw,
626624

627625
if (changed & BSS_CHANGED_MCAST_RATE)
628626
mvif->mcast_rates_idx =
629-
mt7996_get_rates_table(hw, vif, false, true);
627+
mt7996_get_rates_table(phy, info, false, true);
630628

631629
if (changed & BSS_CHANGED_BASIC_RATES)
632630
mvif->basic_rates_idx =
633-
mt7996_get_rates_table(hw, vif, false, false);
631+
mt7996_get_rates_table(phy, info, false, false);
634632

635633
/* ensure that enable txcmd_mode after bss_info */
636634
if (changed & (BSS_CHANGED_QOS | BSS_CHANGED_BEACON_ENABLED))
@@ -650,7 +648,7 @@ static void mt7996_bss_info_changed(struct ieee80211_hw *hw,
650648
if (changed & (BSS_CHANGED_BEACON |
651649
BSS_CHANGED_BEACON_ENABLED)) {
652650
mvif->beacon_rates_idx =
653-
mt7996_get_rates_table(hw, vif, true, false);
651+
mt7996_get_rates_table(phy, info, true, false);
654652

655653
mt7996_mcu_add_beacon(hw, vif, info);
656654
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ mt7996_mcu_bss_basic_tlv(struct sk_buff *skb,
10391039
bss->dtim_period = vif->bss_conf.dtim_period;
10401040
bss->phymode = mt76_connac_get_phy_mode(phy, vif,
10411041
chandef->chan->band, NULL);
1042-
bss->phymode_ext = mt76_connac_get_phy_mode_ext(phy, vif,
1042+
bss->phymode_ext = mt76_connac_get_phy_mode_ext(phy, &vif->bss_conf,
10431043
chandef->chan->band);
10441044

10451045
return 0;

0 commit comments

Comments
 (0)