Skip to content

Commit 5c2a25a

Browse files
Benjamin Linnbd168
authored andcommitted
wifi: mt76: mt7996: fix incorrect indexing of MIB FW event
Fix wrong calculation of the channel times due to incorrect interpretation from the FW event. Fixes: 98686cd ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi 7 (802.11be) devices") Signed-off-by: Benjamin Lin <[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 7e3aef5 commit 5c2a25a

File tree

1 file changed

+29
-16
lines changed
  • drivers/net/wireless/mediatek/mt76/mt7996

1 file changed

+29
-16
lines changed

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

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3678,6 +3678,13 @@ int mt7996_mcu_get_chip_config(struct mt7996_dev *dev, u32 *cap)
36783678

36793679
int mt7996_mcu_get_chan_mib_info(struct mt7996_phy *phy, bool chan_switch)
36803680
{
3681+
enum {
3682+
IDX_TX_TIME,
3683+
IDX_RX_TIME,
3684+
IDX_OBSS_AIRTIME,
3685+
IDX_NON_WIFI_TIME,
3686+
IDX_NUM
3687+
};
36813688
struct {
36823689
struct {
36833690
u8 band;
@@ -3687,16 +3694,15 @@ int mt7996_mcu_get_chan_mib_info(struct mt7996_phy *phy, bool chan_switch)
36873694
__le16 tag;
36883695
__le16 len;
36893696
__le32 offs;
3690-
} data[4];
3697+
} data[IDX_NUM];
36913698
} __packed req = {
36923699
.hdr.band = phy->mt76->band_idx,
36933700
};
3694-
/* strict order */
36953701
static const u32 offs[] = {
3696-
UNI_MIB_TX_TIME,
3697-
UNI_MIB_RX_TIME,
3698-
UNI_MIB_OBSS_AIRTIME,
3699-
UNI_MIB_NON_WIFI_TIME,
3702+
[IDX_TX_TIME] = UNI_MIB_TX_TIME,
3703+
[IDX_RX_TIME] = UNI_MIB_RX_TIME,
3704+
[IDX_OBSS_AIRTIME] = UNI_MIB_OBSS_AIRTIME,
3705+
[IDX_NON_WIFI_TIME] = UNI_MIB_NON_WIFI_TIME,
37003706
};
37013707
struct mt76_channel_state *state = phy->mt76->chan_state;
37023708
struct mt76_channel_state *state_ts = &phy->state_ts;
@@ -3705,7 +3711,7 @@ int mt7996_mcu_get_chan_mib_info(struct mt7996_phy *phy, bool chan_switch)
37053711
struct sk_buff *skb;
37063712
int i, ret;
37073713

3708-
for (i = 0; i < 4; i++) {
3714+
for (i = 0; i < IDX_NUM; i++) {
37093715
req.data[i].tag = cpu_to_le16(UNI_CMD_MIB_DATA);
37103716
req.data[i].len = cpu_to_le16(sizeof(req.data[i]));
37113717
req.data[i].offs = cpu_to_le32(offs[i]);
@@ -3724,17 +3730,24 @@ int mt7996_mcu_get_chan_mib_info(struct mt7996_phy *phy, bool chan_switch)
37243730
goto out;
37253731

37263732
#define __res_u64(s) le64_to_cpu(res[s].data)
3727-
state->cc_tx += __res_u64(1) - state_ts->cc_tx;
3728-
state->cc_bss_rx += __res_u64(2) - state_ts->cc_bss_rx;
3729-
state->cc_rx += __res_u64(2) + __res_u64(3) - state_ts->cc_rx;
3730-
state->cc_busy += __res_u64(0) + __res_u64(1) + __res_u64(2) + __res_u64(3) -
3733+
state->cc_tx += __res_u64(IDX_TX_TIME) - state_ts->cc_tx;
3734+
state->cc_bss_rx += __res_u64(IDX_RX_TIME) - state_ts->cc_bss_rx;
3735+
state->cc_rx += __res_u64(IDX_RX_TIME) +
3736+
__res_u64(IDX_OBSS_AIRTIME) -
3737+
state_ts->cc_rx;
3738+
state->cc_busy += __res_u64(IDX_TX_TIME) +
3739+
__res_u64(IDX_RX_TIME) +
3740+
__res_u64(IDX_OBSS_AIRTIME) +
3741+
__res_u64(IDX_NON_WIFI_TIME) -
37313742
state_ts->cc_busy;
3732-
37333743
out:
3734-
state_ts->cc_tx = __res_u64(1);
3735-
state_ts->cc_bss_rx = __res_u64(2);
3736-
state_ts->cc_rx = __res_u64(2) + __res_u64(3);
3737-
state_ts->cc_busy = __res_u64(0) + __res_u64(1) + __res_u64(2) + __res_u64(3);
3744+
state_ts->cc_tx = __res_u64(IDX_TX_TIME);
3745+
state_ts->cc_bss_rx = __res_u64(IDX_RX_TIME);
3746+
state_ts->cc_rx = __res_u64(IDX_RX_TIME) + __res_u64(IDX_OBSS_AIRTIME);
3747+
state_ts->cc_busy = __res_u64(IDX_TX_TIME) +
3748+
__res_u64(IDX_RX_TIME) +
3749+
__res_u64(IDX_OBSS_AIRTIME) +
3750+
__res_u64(IDX_NON_WIFI_TIME);
37383751
#undef __res_u64
37393752

37403753
dev_kfree_skb(skb);

0 commit comments

Comments
 (0)