Commit 54ae98ff authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau
Browse files

mt76: move mt76_ethtool_worker_info in mt76 module



Move mt76_ethtool_worker_info in common code in order to be reused in
mt7921 driver.

Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 99043e99
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -1508,3 +1508,31 @@ u16 mt76_calculate_default_rate(struct mt76_phy *phy, int rateidx)
	return rate->hw_value;
}
EXPORT_SYMBOL_GPL(mt76_calculate_default_rate);

void mt76_ethtool_worker(struct mt76_ethtool_worker_info *wi,
			 struct mt76_sta_stats *stats)
{
	int i, ei = wi->initial_stat_idx;
	u64 *data = wi->data;

	wi->sta_count++;

	data[ei++] += stats->tx_mode[MT_PHY_TYPE_CCK];
	data[ei++] += stats->tx_mode[MT_PHY_TYPE_OFDM];
	data[ei++] += stats->tx_mode[MT_PHY_TYPE_HT];
	data[ei++] += stats->tx_mode[MT_PHY_TYPE_HT_GF];
	data[ei++] += stats->tx_mode[MT_PHY_TYPE_VHT];
	data[ei++] += stats->tx_mode[MT_PHY_TYPE_HE_SU];
	data[ei++] += stats->tx_mode[MT_PHY_TYPE_HE_EXT_SU];
	data[ei++] += stats->tx_mode[MT_PHY_TYPE_HE_TB];
	data[ei++] += stats->tx_mode[MT_PHY_TYPE_HE_MU];

	for (i = 0; i < ARRAY_SIZE(stats->tx_bw); i++)
		data[ei++] += stats->tx_bw[i];

	for (i = 0; i < 12; i++)
		data[ei++] += stats->tx_mcs[i];

	wi->worker_stat_count = ei - wi->initial_stat_idx;
}
EXPORT_SYMBOL_GPL(mt76_ethtool_worker);
+10 −0
Original line number Diff line number Diff line
@@ -786,6 +786,14 @@ struct mt76_sta_stats {
	u64 tx_mcs[16];		/* mcs idx */
};

struct mt76_ethtool_worker_info {
	u64 *data;
	int idx;
	int initial_stat_idx;
	int worker_stat_count;
	int sta_count;
};

#define CCK_RATE(_idx, _rate) {					\
	.bitrate = _rate,					\
	.flags = IEEE80211_RATE_SHORT_PREAMBLE,			\
@@ -1241,6 +1249,8 @@ mt76u_bulk_msg(struct mt76_dev *dev, void *data, int len, int *actual_len,
	return usb_bulk_msg(udev, pipe, data, len, actual_len, timeout);
}

void mt76_ethtool_worker(struct mt76_ethtool_worker_info *wi,
			 struct mt76_sta_stats *stats);
int mt76_skb_adjust_pad(struct sk_buff *skb, int pad);
int mt76u_vendor_request(struct mt76_dev *dev, u8 req,
			 u8 req_type, u16 val, u16 offset,
+7 −40
Original line number Diff line number Diff line
@@ -1187,45 +1187,15 @@ int mt7915_get_et_sset_count(struct ieee80211_hw *hw,
	return 0;
}

struct mt7915_ethtool_worker_info {
	u64 *data;
	struct mt7915_vif *mvif;
	int initial_stat_idx;
	int worker_stat_count;
	int sta_count;
};

static void mt7915_ethtool_worker(void *wi_data, struct ieee80211_sta *sta)
{
	struct mt7915_ethtool_worker_info *wi = wi_data;
	struct mt76_ethtool_worker_info *wi = wi_data;
	struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
	struct mt76_sta_stats *mstats = &msta->stats;
	int ei = wi->initial_stat_idx;
	int q;
	u64 *data = wi->data;

	if (msta->vif != wi->mvif)
	if (msta->vif->idx != wi->idx)
		return;

	wi->sta_count++;

	data[ei++] += mstats->tx_mode[MT_PHY_TYPE_CCK];
	data[ei++] += mstats->tx_mode[MT_PHY_TYPE_OFDM];
	data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HT];
	data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HT_GF];
	data[ei++] += mstats->tx_mode[MT_PHY_TYPE_VHT];
	data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HE_SU];
	data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HE_EXT_SU];
	data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HE_TB];
	data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HE_MU];

	for (q = 0; q < ARRAY_SIZE(mstats->tx_bw); q++)
		data[ei++] += mstats->tx_bw[q];

	for (q = 0; q < 12; q++)
		data[ei++] += mstats->tx_mcs[q];

	wi->worker_stat_count = ei - wi->initial_stat_idx;
	mt76_ethtool_worker(wi, &msta->stats);
}

static
@@ -1236,9 +1206,11 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw,
	struct mt7915_dev *dev = mt7915_hw_dev(hw);
	struct mt7915_phy *phy = mt7915_hw_phy(hw);
	struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
	struct mt7915_ethtool_worker_info wi;
	struct mt76_ethtool_worker_info wi = {
		.data = data,
		.idx = mvif->idx,
	};
	struct mib_stats *mib = &phy->mib;

	/* See mt7915_ampdu_stat_read_phy, etc */
	bool ext_phy = phy != &dev->phy;
	int i, n, ei = 0;
@@ -1303,12 +1275,7 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw,
	data[ei++] = mib->rx_ba_cnt;

	/* Add values for all stations owned by this vif */
	wi.data = data;
	wi.mvif = mvif;
	wi.initial_stat_idx = ei;
	wi.worker_stat_count = 0;
	wi.sta_count = 0;

	ieee80211_iterate_stations_atomic(hw, mt7915_ethtool_worker, &wi);

	if (wi.sta_count == 0)