Skip to content

Commit

Permalink
wifi: mt76: move aggr_stats array in mt76_phy
Browse files Browse the repository at this point in the history
Move aggregation stats array per-phy instead of share it between multiple
interfaces. This is a preliminary patch to add mt7996 driver support.

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
  • Loading branch information
LorenzoBianconi authored and nbd168 committed Nov 11, 2022
1 parent 75003c6 commit 65c70a3
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 45 deletions.
4 changes: 2 additions & 2 deletions mt76.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,8 @@ struct mt76_phy {
enum mt76_dfs_state dfs_state;
ktime_t survey_time;

u32 aggr_stats[32];

struct mt76_hw_cap cap;
struct mt76_sband sband_2g;
struct mt76_sband sband_5g;
Expand Down Expand Up @@ -781,8 +783,6 @@ struct mt76_dev {

u32 rev;

u32 aggr_stats[32];

struct tasklet_struct pre_tbtt_tasklet;
int beacon_int;
u8 beacon_mask;
Expand Down
2 changes: 1 addition & 1 deletion mt7603/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ mt7603_ampdu_stat_show(struct seq_file *file, void *data)
bound[i], bound[i + 1]);
seq_puts(file, "\nCount: ");
for (i = 0; i < ARRAY_SIZE(bound); i++)
seq_printf(file, "%8d | ", dev->mt76.aggr_stats[i]);
seq_printf(file, "%8d | ", dev->mphy.aggr_stats[i]);
seq_puts(file, "\n");

return 0;
Expand Down
6 changes: 3 additions & 3 deletions mt7603/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void mt7603_mac_reset_counters(struct mt7603_dev *dev)
for (i = 0; i < 2; i++)
mt76_rr(dev, MT_TX_AGG_CNT(i));

memset(dev->mt76.aggr_stats, 0, sizeof(dev->mt76.aggr_stats));
memset(dev->mphy.aggr_stats, 0, sizeof(dev->mphy.aggr_stats));
}

void mt7603_mac_set_timing(struct mt7603_dev *dev)
Expand Down Expand Up @@ -1825,8 +1825,8 @@ void mt7603_mac_work(struct work_struct *work)
for (i = 0, idx = 0; i < 2; i++) {
u32 val = mt76_rr(dev, MT_TX_AGG_CNT(i));

dev->mt76.aggr_stats[idx++] += val & 0xffff;
dev->mt76.aggr_stats[idx++] += val >> 16;
dev->mphy.aggr_stats[idx++] += val & 0xffff;
dev->mphy.aggr_stats[idx++] += val >> 16;
}

if (dev->mphy.mac_work_count == 10)
Expand Down
6 changes: 2 additions & 4 deletions mt7615/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ mt7615_ampdu_stat_read_phy(struct mt7615_phy *phy,
{
struct mt7615_dev *dev = file->private;
u32 reg = is_mt7663(&dev->mt76) ? MT_MIB_ARNG(0) : MT_AGG_ASRCR0;
bool ext_phy = phy != &dev->phy;
int bound[7], i, range;

if (!phy)
Expand All @@ -292,17 +291,16 @@ mt7615_ampdu_stat_read_phy(struct mt7615_phy *phy,
for (i = 0; i < 3; i++)
bound[i + 4] = MT_AGG_ASRCR_RANGE(range, i) + 1;

seq_printf(file, "\nPhy %d\n", ext_phy);
seq_printf(file, "\nPhy %d\n", phy != &dev->phy);

seq_printf(file, "Length: %8d | ", bound[0]);
for (i = 0; i < ARRAY_SIZE(bound) - 1; i++)
seq_printf(file, "%3d -%3d | ",
bound[i], bound[i + 1]);
seq_puts(file, "\nCount: ");

range = ext_phy ? ARRAY_SIZE(dev->mt76.aggr_stats) / 2 : 0;
for (i = 0; i < ARRAY_SIZE(bound); i++)
seq_printf(file, "%8d | ", dev->mt76.aggr_stats[i + range]);
seq_printf(file, "%8d | ", phy->mt76->aggr_stats[i]);
seq_puts(file, "\n");

seq_printf(file, "BA miss count: %d\n", phy->mib.ba_miss_cnt);
Expand Down
9 changes: 4 additions & 5 deletions mt7615/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void mt7615_mac_reset_counters(struct mt7615_phy *phy)
mt76_rr(dev, MT_TX_AGG_CNT(1, i));
}

memset(dev->mt76.aggr_stats, 0, sizeof(dev->mt76.aggr_stats));
memset(phy->mt76->aggr_stats, 0, sizeof(phy->mt76->aggr_stats));
phy->mt76->survey_time = ktime_get_boottime();

/* reset airtime counters */
Expand Down Expand Up @@ -2012,7 +2012,7 @@ mt7615_mac_update_mib_stats(struct mt7615_phy *phy)
struct mt7615_dev *dev = phy->dev;
struct mib_stats *mib = &phy->mib;
bool ext_phy = phy != &dev->phy;
int i, aggr;
int i, aggr = 0;
u32 val, val2;

mib->fcs_err_cnt += mt76_get_field(dev, MT_MIB_SDR3(ext_phy),
Expand All @@ -2026,7 +2026,6 @@ mt7615_mac_update_mib_stats(struct mt7615_phy *phy)
mib->aggr_per = 1000 * (val - val2) / val;
}

aggr = ext_phy ? ARRAY_SIZE(dev->mt76.aggr_stats) / 2 : 0;
for (i = 0; i < 4; i++) {
val = mt76_rr(dev, MT_MIB_MB_SDR1(ext_phy, i));
mib->ba_miss_cnt += FIELD_GET(MT_MIB_BA_MISS_COUNT_MASK, val);
Expand All @@ -2039,8 +2038,8 @@ mt7615_mac_update_mib_stats(struct mt7615_phy *phy)
val);

val = mt76_rr(dev, MT_TX_AGG_CNT(ext_phy, i));
dev->mt76.aggr_stats[aggr++] += val & 0xffff;
dev->mt76.aggr_stats[aggr++] += val >> 16;
phy->mt76->aggr_stats[aggr++] += val & 0xffff;
phy->mt76->aggr_stats[aggr++] += val >> 16;
}
}

Expand Down
2 changes: 1 addition & 1 deletion mt76x02_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mt76x02_ampdu_stat_show(struct seq_file *file, void *data)
seq_puts(file, "Count: ");
for (j = 0; j < 8; j++)
seq_printf(file, "%8d | ",
dev->mt76.aggr_stats[i * 8 + j]);
dev->mphy.aggr_stats[i * 8 + j]);
seq_puts(file, "\n");
seq_puts(file, "--------");
for (j = 0; j < 8; j++)
Expand Down
6 changes: 3 additions & 3 deletions mt76x02_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void mt76x02_mac_reset_counters(struct mt76x02_dev *dev)
for (i = 0; i < 16; i++)
mt76_rr(dev, MT_TX_STAT_FIFO);

memset(dev->mt76.aggr_stats, 0, sizeof(dev->mt76.aggr_stats));
memset(dev->mphy.aggr_stats, 0, sizeof(dev->mphy.aggr_stats));
}
EXPORT_SYMBOL_GPL(mt76x02_mac_reset_counters);

Expand Down Expand Up @@ -1191,8 +1191,8 @@ void mt76x02_mac_work(struct work_struct *work)
for (i = 0, idx = 0; i < 16; i++) {
u32 val = mt76_rr(dev, MT_TX_AGG_CNT(i));

dev->mt76.aggr_stats[idx++] += val & 0xffff;
dev->mt76.aggr_stats[idx++] += val >> 16;
dev->mphy.aggr_stats[idx++] += val & 0xffff;
dev->mphy.aggr_stats[idx++] += val >> 16;
}

mt76x02_check_mac_err(dev);
Expand Down
5 changes: 2 additions & 3 deletions mt7915/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ mt7915_ampdu_stat_read_phy(struct mt7915_phy *phy,
{
struct mt7915_dev *dev = phy->dev;
bool ext_phy = phy != &dev->phy;
int bound[15], range[4], i, n;
int bound[15], range[4], i;

/* Tx ampdu stat */
for (i = 0; i < ARRAY_SIZE(range); i++)
Expand All @@ -656,9 +656,8 @@ mt7915_ampdu_stat_read_phy(struct mt7915_phy *phy,
bound[i] + 1, bound[i + 1]);

seq_puts(file, "\nCount: ");
n = phy->band_idx ? ARRAY_SIZE(dev->mt76.aggr_stats) / 2 : 0;
for (i = 0; i < ARRAY_SIZE(bound); i++)
seq_printf(file, "%8d | ", dev->mt76.aggr_stats[i + n]);
seq_printf(file, "%8d | ", phy->mt76->aggr_stats[i]);
seq_puts(file, "\n");

seq_printf(file, "BA miss count: %d\n", phy->mib.ba_miss_cnt);
Expand Down
21 changes: 8 additions & 13 deletions mt7915/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1159,12 +1159,8 @@ void mt7915_mac_reset_counters(struct mt7915_phy *phy)
mt76_rr(dev, MT_TX_AGG_CNT2(phy->band_idx, i));
}

i = 0;
phy->mt76->survey_time = ktime_get_boottime();
if (phy->band_idx)
i = ARRAY_SIZE(dev->mt76.aggr_stats) / 2;

memset(&dev->mt76.aggr_stats[i], 0, sizeof(dev->mt76.aggr_stats) / 2);
memset(phy->mt76->aggr_stats, 0, sizeof(phy->mt76->aggr_stats));

/* reset airtime counters */
mt76_set(dev, MT_WF_RMAC_MIB_AIRTIME0(phy->band_idx),
Expand Down Expand Up @@ -1507,7 +1503,7 @@ void mt7915_mac_update_stats(struct mt7915_phy *phy)
{
struct mt7915_dev *dev = phy->dev;
struct mib_stats *mib = &phy->mib;
int i, aggr0, aggr1, cnt;
int i, aggr0 = 0, aggr1, cnt;
u32 val;

cnt = mt76_rr(dev, MT_MIB_SDR3(phy->band_idx));
Expand Down Expand Up @@ -1639,7 +1635,6 @@ void mt7915_mac_update_stats(struct mt7915_phy *phy)
mib->tx_amsdu_cnt += cnt;
}

aggr0 = phy->band_idx ? ARRAY_SIZE(dev->mt76.aggr_stats) / 2 : 0;
if (is_mt7915(&dev->mt76)) {
for (i = 0, aggr1 = aggr0 + 8; i < 4; i++) {
val = mt76_rr(dev, MT_MIB_MB_SDR1(phy->band_idx, (i << 4)));
Expand All @@ -1654,12 +1649,12 @@ void mt7915_mac_update_stats(struct mt7915_phy *phy)
FIELD_GET(MT_MIB_RTS_RETRIES_COUNT_MASK, val);

val = mt76_rr(dev, MT_TX_AGG_CNT(phy->band_idx, i));
dev->mt76.aggr_stats[aggr0++] += val & 0xffff;
dev->mt76.aggr_stats[aggr0++] += val >> 16;
phy->mt76->aggr_stats[aggr0++] += val & 0xffff;
phy->mt76->aggr_stats[aggr0++] += val >> 16;

val = mt76_rr(dev, MT_TX_AGG_CNT2(phy->band_idx, i));
dev->mt76.aggr_stats[aggr1++] += val & 0xffff;
dev->mt76.aggr_stats[aggr1++] += val >> 16;
phy->mt76->aggr_stats[aggr1++] += val & 0xffff;
phy->mt76->aggr_stats[aggr1++] += val >> 16;
}

cnt = mt76_rr(dev, MT_MIB_SDR32(phy->band_idx));
Expand Down Expand Up @@ -1706,8 +1701,8 @@ void mt7915_mac_update_stats(struct mt7915_phy *phy)

for (i = 0; i < 8; i++) {
val = mt76_rr(dev, MT_TX_AGG_CNT(phy->band_idx, i));
dev->mt76.aggr_stats[aggr0++] += FIELD_GET(GENMASK(15, 0), val);
dev->mt76.aggr_stats[aggr0++] += FIELD_GET(GENMASK(31, 16), val);
phy->mt76->aggr_stats[aggr0++] += FIELD_GET(GENMASK(15, 0), val);
phy->mt76->aggr_stats[aggr0++] += FIELD_GET(GENMASK(31, 16), val);
}

cnt = mt76_rr(dev, MT_MIB_SDR32(phy->band_idx));
Expand Down
5 changes: 2 additions & 3 deletions mt7915/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw,
};
struct mib_stats *mib = &phy->mib;
/* See mt7915_ampdu_stat_read_phy, etc */
int i, n, ei = 0;
int i, ei = 0;

mutex_lock(&dev->mt76.mutex);

Expand All @@ -1282,9 +1282,8 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw,
data[ei++] = mib->tx_pkt_ibf_cnt;

/* Tx ampdu stat */
n = phy->band_idx ? ARRAY_SIZE(dev->mt76.aggr_stats) / 2 : 0;
for (i = 0; i < 15 /*ARRAY_SIZE(bound)*/; i++)
data[ei++] = dev->mt76.aggr_stats[i + n];
data[ei++] = phy->mt76->aggr_stats[i];

data[ei++] = phy->mib.ba_miss_cnt;

Expand Down
2 changes: 1 addition & 1 deletion mt7921/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ mt7921_ampdu_stat_read_phy(struct mt7921_phy *phy,

seq_puts(file, "\nCount: ");
for (i = 0; i < ARRAY_SIZE(bound); i++)
seq_printf(file, "%8d | ", dev->mt76.aggr_stats[i]);
seq_printf(file, "%8d | ", phy->mt76->aggr_stats[i]);
seq_puts(file, "\n");

seq_printf(file, "BA miss count: %d\n", phy->mib.ba_miss_cnt);
Expand Down
10 changes: 5 additions & 5 deletions mt7921/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ void mt7921_mac_reset_counters(struct mt7921_phy *phy)
}

dev->mt76.phy.survey_time = ktime_get_boottime();
memset(&dev->mt76.aggr_stats[0], 0, sizeof(dev->mt76.aggr_stats) / 2);
memset(phy->mt76->aggr_stats, 0, sizeof(phy->mt76->aggr_stats));

/* reset airtime counters */
mt76_rr(dev, MT_MIB_SDR9(0));
Expand Down Expand Up @@ -990,10 +990,10 @@ void mt7921_mac_update_mib_stats(struct mt7921_phy *phy)
val = mt76_rr(dev, MT_TX_AGG_CNT(0, i));
val2 = mt76_rr(dev, MT_TX_AGG_CNT2(0, i));

dev->mt76.aggr_stats[aggr0++] += val & 0xffff;
dev->mt76.aggr_stats[aggr0++] += val >> 16;
dev->mt76.aggr_stats[aggr1++] += val2 & 0xffff;
dev->mt76.aggr_stats[aggr1++] += val2 >> 16;
phy->mt76->aggr_stats[aggr0++] += val & 0xffff;
phy->mt76->aggr_stats[aggr0++] += val >> 16;
phy->mt76->aggr_stats[aggr1++] += val2 & 0xffff;
phy->mt76->aggr_stats[aggr1++] += val2 >> 16;
}
}

Expand Down
2 changes: 1 addition & 1 deletion mt7921/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ void mt7921_get_et_stats(struct ieee80211_hw *hw, struct ieee80211_vif *vif,

/* Tx ampdu stat */
for (i = 0; i < 15; i++)
data[ei++] = dev->mt76.aggr_stats[i];
data[ei++] = phy->mt76->aggr_stats[i];

data[ei++] = phy->mib.ba_miss_cnt;

Expand Down

0 comments on commit 65c70a3

Please sign in to comment.