Skip to content

Commit 6f917bb

Browse files
ryderlee1110nbd168
authored andcommitted
wifi: mt76: mt7915: fix band_idx usage
The commit 006b9d4 introduced phy->band_idx to accommodate the band definition change for mt7986 so that the band_idx of main_phy can be 0 or 1. Accordingly, the source of band_idx 1 has switched to "phy != &dev->phy" or "dev->phy.band_idx = 1". We still use ext_phy to represent band 1 somewhere in driver, so fix it. Also, band_idx sounds more reasonable than dbdc_idx, so change it. Fixes: 006b9d4 ("mt76: mt7915: introduce band_idx in mt7915_phy") Signed-off-by: Ryder Lee <[email protected]> Signed-off-by: Felix Fietkau <[email protected]>
1 parent 66b181b commit 6f917bb

File tree

5 files changed

+58
-59
lines changed

5 files changed

+58
-59
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ mt7915_sys_recovery_set(struct file *file, const char __user *user_buf,
5151
{
5252
struct mt7915_phy *phy = file->private_data;
5353
struct mt7915_dev *dev = phy->dev;
54-
bool ext_phy = phy != &dev->phy;
54+
bool band = phy->band_idx;
5555
char buf[16];
5656
int ret = 0;
5757
u16 val;
@@ -83,25 +83,25 @@ mt7915_sys_recovery_set(struct file *file, const char __user *user_buf,
8383
* 8: trigger firmware crash.
8484
*/
8585
case SER_QUERY:
86-
ret = mt7915_mcu_set_ser(dev, 0, 0, ext_phy);
86+
ret = mt7915_mcu_set_ser(dev, 0, 0, band);
8787
break;
8888
case SER_SET_RECOVER_L1:
8989
case SER_SET_RECOVER_L2:
9090
case SER_SET_RECOVER_L3_RX_ABORT:
9191
case SER_SET_RECOVER_L3_TX_ABORT:
9292
case SER_SET_RECOVER_L3_TX_DISABLE:
9393
case SER_SET_RECOVER_L3_BF:
94-
ret = mt7915_mcu_set_ser(dev, SER_ENABLE, BIT(val), ext_phy);
94+
ret = mt7915_mcu_set_ser(dev, SER_ENABLE, BIT(val), band);
9595
if (ret)
9696
return ret;
9797

98-
ret = mt7915_mcu_set_ser(dev, SER_RECOVER, val, ext_phy);
98+
ret = mt7915_mcu_set_ser(dev, SER_RECOVER, val, band);
9999
break;
100100

101101
/* enable full chip reset */
102102
case SER_SET_RECOVER_FULL:
103103
mt76_set(dev, MT_WFDMA0_MCU_HOST_INT_ENA, MT_MCU_CMD_WDT_MASK);
104-
ret = mt7915_mcu_set_ser(dev, 1, 3, ext_phy);
104+
ret = mt7915_mcu_set_ser(dev, 1, 3, band);
105105
if (ret)
106106
return ret;
107107

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,18 +1259,18 @@ void mt7915_mac_set_timing(struct mt7915_phy *phy)
12591259
MT_ARB_SCR_TX_DISABLE | MT_ARB_SCR_RX_DISABLE);
12601260
}
12611261

1262-
void mt7915_mac_enable_nf(struct mt7915_dev *dev, bool ext_phy)
1262+
void mt7915_mac_enable_nf(struct mt7915_dev *dev, bool band)
12631263
{
12641264
u32 reg;
12651265

1266-
reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_RXTD12(ext_phy) :
1267-
MT_WF_PHY_RXTD12_MT7916(ext_phy);
1266+
reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_RXTD12(band) :
1267+
MT_WF_PHY_RXTD12_MT7916(band);
12681268
mt76_set(dev, reg,
12691269
MT_WF_PHY_RXTD12_IRPI_SW_CLR_ONLY |
12701270
MT_WF_PHY_RXTD12_IRPI_SW_CLR);
12711271

1272-
reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_RX_CTRL1(ext_phy) :
1273-
MT_WF_PHY_RX_CTRL1_MT7916(ext_phy);
1272+
reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_RX_CTRL1(band) :
1273+
MT_WF_PHY_RX_CTRL1_MT7916(band);
12741274
mt76_set(dev, reg, FIELD_PREP(MT_WF_PHY_RX_CTRL1_IPI_EN, 0x5));
12751275
}
12761276

@@ -1979,7 +1979,6 @@ void mt7915_mac_update_stats(struct mt7915_phy *phy)
19791979
static void mt7915_mac_severe_check(struct mt7915_phy *phy)
19801980
{
19811981
struct mt7915_dev *dev = phy->dev;
1982-
bool ext_phy = phy != &dev->phy;
19831982
u32 trb;
19841983

19851984
if (!phy->omac_mask)
@@ -1997,7 +1996,7 @@ static void mt7915_mac_severe_check(struct mt7915_phy *phy)
19971996
FIELD_GET(MT_TRB_RXPSR0_RX_WTBL_PTR, phy->trb_ts)) &&
19981997
trb == phy->trb_ts)
19991998
mt7915_mcu_set_ser(dev, SER_RECOVER, SER_SET_RECOVER_L3_RX_ABORT,
2000-
ext_phy);
1999+
phy->band_idx);
20012000

20022001
phy->trb_ts = trb;
20032002
}

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,31 @@ int mt7915_run(struct ieee80211_hw *hw)
3030
running = mt7915_dev_running(dev);
3131

3232
if (!running) {
33-
ret = mt76_connac_mcu_set_pm(&dev->mt76, 0, 0);
33+
ret = mt76_connac_mcu_set_pm(&dev->mt76, dev->phy.band_idx, 0);
3434
if (ret)
3535
goto out;
3636

37-
ret = mt7915_mcu_set_mac(dev, 0, true, true);
37+
ret = mt7915_mcu_set_mac(dev, dev->phy.band_idx, true, true);
3838
if (ret)
3939
goto out;
4040

41-
mt7915_mac_enable_nf(dev, 0);
41+
mt7915_mac_enable_nf(dev, dev->phy.band_idx);
4242
}
4343

44-
if (phy != &dev->phy || phy->band_idx) {
45-
ret = mt76_connac_mcu_set_pm(&dev->mt76, 1, 0);
44+
if (phy != &dev->phy) {
45+
ret = mt76_connac_mcu_set_pm(&dev->mt76, phy->band_idx, 0);
4646
if (ret)
4747
goto out;
4848

49-
ret = mt7915_mcu_set_mac(dev, 1, true, true);
49+
ret = mt7915_mcu_set_mac(dev, phy->band_idx, true, true);
5050
if (ret)
5151
goto out;
5252

53-
mt7915_mac_enable_nf(dev, 1);
53+
mt7915_mac_enable_nf(dev, phy->band_idx);
5454
}
5555

5656
ret = mt76_connac_mcu_set_rts_thresh(&dev->mt76, 0x92b,
57-
phy != &dev->phy);
57+
phy->band_idx);
5858
if (ret)
5959
goto out;
6060

@@ -107,13 +107,13 @@ static void mt7915_stop(struct ieee80211_hw *hw)
107107
clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
108108

109109
if (phy != &dev->phy) {
110-
mt76_connac_mcu_set_pm(&dev->mt76, 1, 1);
111-
mt7915_mcu_set_mac(dev, 1, false, false);
110+
mt76_connac_mcu_set_pm(&dev->mt76, phy->band_idx, 1);
111+
mt7915_mcu_set_mac(dev, phy->band_idx, false, false);
112112
}
113113

114114
if (!mt7915_dev_running(dev)) {
115-
mt76_connac_mcu_set_pm(&dev->mt76, 0, 1);
116-
mt7915_mcu_set_mac(dev, 0, false, false);
115+
mt76_connac_mcu_set_pm(&dev->mt76, dev->phy.band_idx, 1);
116+
mt7915_mcu_set_mac(dev, dev->phy.band_idx, false, false);
117117
}
118118

119119
mutex_unlock(&dev->mt76.mutex);
@@ -440,7 +440,6 @@ static int mt7915_config(struct ieee80211_hw *hw, u32 changed)
440440
{
441441
struct mt7915_dev *dev = mt7915_hw_dev(hw);
442442
struct mt7915_phy *phy = mt7915_hw_phy(hw);
443-
bool band = phy != &dev->phy;
444443
int ret;
445444

446445
if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
@@ -468,6 +467,7 @@ static int mt7915_config(struct ieee80211_hw *hw, u32 changed)
468467

469468
if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
470469
bool enabled = !!(hw->conf.flags & IEEE80211_CONF_MONITOR);
470+
bool band = phy->band_idx;
471471

472472
if (!enabled)
473473
phy->rxfilter |= MT_WF_RFCR_DROP_OTHER_UC;
@@ -506,7 +506,7 @@ static void mt7915_configure_filter(struct ieee80211_hw *hw,
506506
{
507507
struct mt7915_dev *dev = mt7915_hw_dev(hw);
508508
struct mt7915_phy *phy = mt7915_hw_phy(hw);
509-
bool band = phy != &dev->phy;
509+
bool band = phy->band_idx;
510510
u32 ctl_flags = MT_WF_RFCR1_DROP_ACK |
511511
MT_WF_RFCR1_DROP_BF_POLL |
512512
MT_WF_RFCR1_DROP_BA |
@@ -743,7 +743,7 @@ static int mt7915_set_rts_threshold(struct ieee80211_hw *hw, u32 val)
743743
int ret;
744744

745745
mutex_lock(&dev->mt76.mutex);
746-
ret = mt76_connac_mcu_set_rts_thresh(&dev->mt76, val, phy != &dev->phy);
746+
ret = mt76_connac_mcu_set_rts_thresh(&dev->mt76, val, phy->band_idx);
747747
mutex_unlock(&dev->mt76.mutex);
748748

749749
return ret;
@@ -846,7 +846,7 @@ u64 __mt7915_get_tsf(struct ieee80211_hw *hw, struct mt7915_vif *mvif)
846846
{
847847
struct mt7915_dev *dev = mt7915_hw_dev(hw);
848848
struct mt7915_phy *phy = mt7915_hw_phy(hw);
849-
bool band = phy != &dev->phy;
849+
bool band = phy->band_idx;
850850
union {
851851
u64 t64;
852852
u32 t32[2];
@@ -891,7 +891,7 @@ mt7915_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
891891
struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
892892
struct mt7915_dev *dev = mt7915_hw_dev(hw);
893893
struct mt7915_phy *phy = mt7915_hw_phy(hw);
894-
bool band = phy != &dev->phy;
894+
bool band = phy->band_idx;
895895
union {
896896
u64 t64;
897897
u32 t32[2];
@@ -922,7 +922,7 @@ mt7915_offset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
922922
struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
923923
struct mt7915_dev *dev = mt7915_hw_dev(hw);
924924
struct mt7915_phy *phy = mt7915_hw_phy(hw);
925-
bool band = phy != &dev->phy;
925+
bool band = phy->band_idx;
926926
union {
927927
u64 t64;
928928
u32 t32[2];

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ mt7915_mcu_muar_config(struct mt7915_phy *phy, struct ieee80211_vif *vif,
599599
.mode = !!mask || enable,
600600
.entry_count = 1,
601601
.write = 1,
602-
.band = phy != &dev->phy,
602+
.band = phy->band_idx,
603603
.index = idx * 2 + bssid,
604604
};
605605

@@ -1715,7 +1715,7 @@ int mt7915_mcu_add_dev_info(struct mt7915_phy *phy,
17151715
struct {
17161716
struct req_hdr {
17171717
u8 omac_idx;
1718-
u8 dbdc_idx;
1718+
u8 band_idx;
17191719
__le16 tlv_num;
17201720
u8 is_tlv_append;
17211721
u8 rsv[3];
@@ -1724,21 +1724,21 @@ int mt7915_mcu_add_dev_info(struct mt7915_phy *phy,
17241724
__le16 tag;
17251725
__le16 len;
17261726
u8 active;
1727-
u8 dbdc_idx;
1727+
u8 band_idx;
17281728
u8 omac_addr[ETH_ALEN];
17291729
} __packed tlv;
17301730
} data = {
17311731
.hdr = {
17321732
.omac_idx = mvif->mt76.omac_idx,
1733-
.dbdc_idx = mvif->mt76.band_idx,
1733+
.band_idx = mvif->mt76.band_idx,
17341734
.tlv_num = cpu_to_le16(1),
17351735
.is_tlv_append = 1,
17361736
},
17371737
.tlv = {
17381738
.tag = cpu_to_le16(DEV_INFO_ACTIVE),
17391739
.len = cpu_to_le16(sizeof(struct req_tlv)),
17401740
.active = enable,
1741-
.dbdc_idx = mvif->mt76.band_idx,
1741+
.band_idx = mvif->mt76.band_idx,
17421742
},
17431743
};
17441744

@@ -2585,15 +2585,15 @@ mt7915_mcu_background_chain_ctrl(struct mt7915_phy *phy,
25852585
req.monitor_central_chan =
25862586
ieee80211_frequency_to_channel(chandef->center_freq1);
25872587
req.monitor_bw = mt76_connac_chan_bw(chandef);
2588-
req.band_idx = phy != &dev->phy;
2588+
req.band_idx = phy->band_idx;
25892589
req.scan_mode = 1;
25902590
break;
25912591
}
25922592
case CH_SWITCH_BACKGROUND_SCAN_RUNNING:
25932593
req.monitor_chan = chandef->chan->hw_value;
25942594
req.monitor_central_chan =
25952595
ieee80211_frequency_to_channel(chandef->center_freq1);
2596-
req.band_idx = phy != &dev->phy;
2596+
req.band_idx = phy->band_idx;
25972597
req.scan_mode = 2;
25982598
break;
25992599
case CH_SWITCH_BACKGROUND_SCAN_STOP:
@@ -2997,7 +2997,7 @@ int mt7915_mcu_get_chan_mib_info(struct mt7915_phy *phy, bool chan_switch)
29972997
}
29982998

29992999
for (i = 0; i < 5; i++) {
3000-
req[i].band = cpu_to_le32(phy != &dev->phy);
3000+
req[i].band = cpu_to_le32(phy->band_idx);
30013001
req[i].offs = cpu_to_le32(offs[i + start]);
30023002

30033003
if (!is_mt7915(&dev->mt76) && i == 3)
@@ -3042,11 +3042,11 @@ int mt7915_mcu_get_temperature(struct mt7915_phy *phy)
30423042
struct {
30433043
u8 ctrl_id;
30443044
u8 action;
3045-
u8 dbdc_idx;
3045+
u8 band_idx;
30463046
u8 rsv[5];
30473047
} req = {
30483048
.ctrl_id = THERMAL_SENSOR_TEMP_QUERY,
3049-
.dbdc_idx = phy != &dev->phy,
3049+
.band_idx = phy->band_idx,
30503050
};
30513051

30523052
return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_CTRL), &req,
@@ -3195,11 +3195,11 @@ int mt7915_mcu_set_txpower_sku(struct mt7915_phy *phy)
31953195
struct mt7915_sku_val {
31963196
u8 format_id;
31973197
u8 limit_type;
3198-
u8 dbdc_idx;
3198+
u8 band_idx;
31993199
s8 val[MT7915_SKU_RATE_NUM];
32003200
} __packed req = {
32013201
.format_id = TX_POWER_LIMIT_TABLE,
3202-
.dbdc_idx = phy != &dev->phy,
3202+
.band_idx = phy->band_idx,
32033203
};
32043204
struct mt76_power_limits limits_array;
32053205
s8 *la = (s8 *)&limits_array;
@@ -3245,12 +3245,12 @@ int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len)
32453245
struct {
32463246
u8 format_id;
32473247
u8 category;
3248-
u8 band;
3248+
u8 band_idx;
32493249
u8 _rsv;
32503250
} __packed req = {
32513251
.format_id = TX_POWER_LIMIT_INFO,
32523252
.category = RATE_POWER_INFO,
3253-
.band = phy != &dev->phy,
3253+
.band_idx = phy->band_idx,
32543254
};
32553255
s8 txpower_sku[MT7915_SKU_RATE_NUM][2];
32563256
struct sk_buff *skb;
@@ -3299,11 +3299,11 @@ int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable)
32993299
struct mt7915_sku {
33003300
u8 format_id;
33013301
u8 sku_enable;
3302-
u8 dbdc_idx;
3302+
u8 band_idx;
33033303
u8 rsv;
33043304
} __packed req = {
33053305
.format_id = TX_POWER_LIMIT_ENABLE,
3306-
.dbdc_idx = phy != &dev->phy,
3306+
.band_idx = phy->band_idx,
33073307
.sku_enable = enable,
33083308
};
33093309

@@ -3385,7 +3385,7 @@ mt7915_mcu_enable_obss_spr(struct mt7915_phy *phy, u8 action, u8 val)
33853385
struct mt7915_mcu_sr_ctrl req = {
33863386
.action = action,
33873387
.argnum = 1,
3388-
.band_idx = phy != &dev->phy,
3388+
.band_idx = phy->band_idx,
33893389
.val = cpu_to_le32(val),
33903390
};
33913391

@@ -3416,7 +3416,7 @@ mt7915_mcu_set_obss_spr_pd(struct mt7915_phy *phy,
34163416
.ctrl = {
34173417
.action = SPR_SET_PARAM,
34183418
.argnum = 9,
3419-
.band_idx = phy != &dev->phy,
3419+
.band_idx = phy->band_idx,
34203420
},
34213421
};
34223422
int ret;
@@ -3465,7 +3465,7 @@ mt7915_mcu_set_obss_spr_siga(struct mt7915_phy *phy, struct ieee80211_vif *vif,
34653465
.ctrl = {
34663466
.action = SPR_SET_SIGA,
34673467
.argnum = 1,
3468-
.band_idx = phy != &dev->phy,
3468+
.band_idx = phy->band_idx,
34693469
},
34703470
.siga = {
34713471
.omac = omac > HW_BSSID_MAX ? omac - 12 : omac,
@@ -3504,7 +3504,7 @@ mt7915_mcu_set_obss_spr_bitmap(struct mt7915_phy *phy,
35043504
.ctrl = {
35053505
.action = SPR_SET_SRG_BITMAP,
35063506
.argnum = 4,
3507-
.band_idx = phy != &dev->phy,
3507+
.band_idx = phy->band_idx,
35083508
},
35093509
};
35103510
u32 bitmap;

0 commit comments

Comments
 (0)