Skip to content

Commit a9384b3

Browse files
csyuancnbd168
authored andcommitted
wifi: mt76: mt7996: rework set/get_tsf callabcks to support MLO
This is a preliminary patch in order to enable MLO for MT7996 driver. Co-developed-by: Bo Jiao <Bo.Jiao@mediatek.com> Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com> Co-developed-by: Peter Chiu <chui-hao.chiu@mediatek.com> Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Link: https://patch.msgid.link/20250312-b4-mt7996-mlo-p2-v1-19-015b3d6fd928@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
1 parent a3316d2 commit a9384b3

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2732,7 +2732,7 @@ void mt7996_mac_add_twt_setup(struct ieee80211_hw *hw,
27322732

27332733
flow->sched = true;
27342734
flow->start_tsf = mt7996_mac_twt_sched_list_add(dev, flow);
2735-
curr_tsf = __mt7996_get_tsf(hw, msta->vif);
2735+
curr_tsf = __mt7996_get_tsf(hw, &msta->vif->deflink);
27362736
div_u64_rem(curr_tsf - flow->start_tsf, interval, &rem);
27372737
flow_tsf = curr_tsf + interval - rem;
27382738
twt_agrt->twt = cpu_to_le64(flow_tsf);

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

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,10 +1336,10 @@ mt7996_get_stats(struct ieee80211_hw *hw,
13361336
return 0;
13371337
}
13381338

1339-
u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_vif *mvif)
1339+
u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_vif_link *link)
13401340
{
13411341
struct mt7996_dev *dev = mt7996_hw_dev(hw);
1342-
struct mt7996_phy *phy = mt7996_vif_link_phy(&mvif->deflink);
1342+
struct mt7996_phy *phy = link->phy;
13431343
union {
13441344
u64 t64;
13451345
u32 t32[2];
@@ -1351,8 +1351,8 @@ u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_vif *mvif)
13511351

13521352
lockdep_assert_held(&dev->mt76.mutex);
13531353

1354-
n = mvif->deflink.mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
1355-
: mvif->deflink.mt76.omac_idx;
1354+
n = link->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
1355+
: link->mt76.omac_idx;
13561356
/* TSF software read */
13571357
mt76_rmw(dev, MT_LPON_TCR(phy->mt76->band_idx, n), MT_LPON_TCR_SW_MODE,
13581358
MT_LPON_TCR_SW_READ);
@@ -1370,7 +1370,7 @@ mt7996_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
13701370
u64 ret;
13711371

13721372
mutex_lock(&dev->mt76.mutex);
1373-
ret = __mt7996_get_tsf(hw, mvif);
1373+
ret = __mt7996_get_tsf(hw, &mvif->deflink);
13741374
mutex_unlock(&dev->mt76.mutex);
13751375

13761376
return ret;
@@ -1382,26 +1382,33 @@ mt7996_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
13821382
{
13831383
struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
13841384
struct mt7996_dev *dev = mt7996_hw_dev(hw);
1385-
struct mt7996_phy *phy = mt7996_vif_link_phy(&mvif->deflink);
1385+
struct mt7996_vif_link *link;
1386+
struct mt7996_phy *phy;
13861387
union {
13871388
u64 t64;
13881389
u32 t32[2];
13891390
} tsf = { .t64 = timestamp, };
13901391
u16 n;
13911392

1392-
if (!phy)
1393-
return;
1394-
13951393
mutex_lock(&dev->mt76.mutex);
13961394

1397-
n = mvif->deflink.mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
1398-
: mvif->deflink.mt76.omac_idx;
1395+
link = mt7996_vif_link(dev, vif, mvif->mt76.deflink_id);
1396+
if (!link)
1397+
goto unlock;
1398+
1399+
n = link->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
1400+
: link->mt76.omac_idx;
1401+
phy = link->phy;
1402+
if (!phy)
1403+
goto unlock;
1404+
13991405
mt76_wr(dev, MT_LPON_UTTR0(phy->mt76->band_idx), tsf.t32[0]);
14001406
mt76_wr(dev, MT_LPON_UTTR1(phy->mt76->band_idx), tsf.t32[1]);
14011407
/* TSF software overwrite */
14021408
mt76_rmw(dev, MT_LPON_TCR(phy->mt76->band_idx, n), MT_LPON_TCR_SW_MODE,
14031409
MT_LPON_TCR_SW_WRITE);
14041410

1411+
unlock:
14051412
mutex_unlock(&dev->mt76.mutex);
14061413
}
14071414

@@ -1411,26 +1418,33 @@ mt7996_offset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
14111418
{
14121419
struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
14131420
struct mt7996_dev *dev = mt7996_hw_dev(hw);
1414-
struct mt7996_phy *phy = mt7996_vif_link_phy(&mvif->deflink);
1421+
struct mt7996_vif_link *link;
1422+
struct mt7996_phy *phy;
14151423
union {
14161424
u64 t64;
14171425
u32 t32[2];
14181426
} tsf = { .t64 = timestamp, };
14191427
u16 n;
14201428

1421-
if (!phy)
1422-
return;
1423-
14241429
mutex_lock(&dev->mt76.mutex);
14251430

1426-
n = mvif->deflink.mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
1427-
: mvif->deflink.mt76.omac_idx;
1431+
link = mt7996_vif_link(dev, vif, mvif->mt76.deflink_id);
1432+
if (!link)
1433+
goto unlock;
1434+
1435+
phy = link->phy;
1436+
if (!phy)
1437+
goto unlock;
1438+
1439+
n = link->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
1440+
: link->mt76.omac_idx;
14281441
mt76_wr(dev, MT_LPON_UTTR0(phy->mt76->band_idx), tsf.t32[0]);
14291442
mt76_wr(dev, MT_LPON_UTTR1(phy->mt76->band_idx), tsf.t32[1]);
14301443
/* TSF software adjust*/
14311444
mt76_rmw(dev, MT_LPON_TCR(phy->mt76->band_idx, n), MT_LPON_TCR_SW_MODE,
14321445
MT_LPON_TCR_SW_ADJUST);
14331446

1447+
unlock:
14341448
mutex_unlock(&dev->mt76.mutex);
14351449
}
14361450

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ struct mt7996_dev *mt7996_mmio_probe(struct device *pdev,
535535
void __iomem *mem_base, u32 device_id);
536536
void mt7996_wfsys_reset(struct mt7996_dev *dev);
537537
irqreturn_t mt7996_irq_handler(int irq, void *dev_instance);
538-
u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_vif *mvif);
538+
u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_vif_link *link);
539539
int mt7996_register_device(struct mt7996_dev *dev);
540540
void mt7996_unregister_device(struct mt7996_dev *dev);
541541
int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,

0 commit comments

Comments
 (0)