Skip to contentSkip to conversation

ath10k: add ppdu stats support for QCA6174/QCA9377

PATCH In review Yu Wang 4 participants 13 messages Nov 19, 2019 – Apr 14, 2020 1 message not in the archive Qualcomm Atheros ATH10K wireless driver

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Yu Wang

author
#1 lore raw

PATCH v2 1/2 ath10k: add ppdu stats support for QCA6174/QCA9377

When QCA6174/QCA9377 working in station mode, after connected to AP, tx bitrate is always '1.0 MBit/s' in output of command 'iw wlan0 link'.

That's because the parameters to calculate the tx bitrate are not well updated for QCA6174/QCA9377.

To fix this issue:
1. Add processing for HTT_T2H_MSG_TYPE_PPDU_STATS_IND which includes the peer tx stats;
2. Map WMI_TLV_SERVICE_PEER_STATS_INFO to WMI_SERVICE_PEER_STATS to enable the feature.

Tested with QCA6174 PCIe with firmware WLAN.RM.4.4.1.c3-00031. Tested with QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029.

---
 drivers/net/wireless/ath/ath10k/htt.c     |  2 +
 drivers/net/wireless/ath/ath10k/htt.h     | 30 ++++++++++++++
 drivers/net/wireless/ath/ath10k/htt_rx.c  | 65 +++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/wmi-tlv.c |  4 ++
 drivers/net/wireless/ath/ath10k/wmi-tlv.h |  3 ++
 5 files changed, 104 insertions(+)
drivers/net/wireless/ath/ath10k/htt.c +2 -0
index 7b75200..c32ab07 100644
@@ -89,6 +89,8 @@ static const enum htt_t2h_msg_type htt_tlv_t2h_msg_types[] = {
 	[HTT_TLV_T2H_MSG_TYPE_RX_OFLD_PKT_ERR] =
 		HTT_T2H_MSG_TYPE_RX_OFLD_PKT_ERR,
 	[HTT_TLV_T2H_MSG_TYPE_TEST] = HTT_T2H_MSG_TYPE_TEST,
+	[HTT_TLV_T2H_MSG_TYPE_PPDU_STATS_IND] =
+		HTT_T2H_MSG_TYPE_PPDU_STATS_IND,
 };
 
 static const enum htt_t2h_msg_type htt_10_4_t2h_msg_types[] = {
drivers/net/wireless/ath/ath10k/htt.h +30 -0
index 30c0800..e2aae263 100644
@@ -450,6 +450,13 @@ enum htt_tlv_t2h_msg_type {
 	HTT_TLV_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE       = 0x14,
 	HTT_TLV_T2H_MSG_TYPE_CHAN_CHANGE               = 0x15,
 	HTT_TLV_T2H_MSG_TYPE_RX_OFLD_PKT_ERR           = 0x16,
+	HTT_TLV_T2H_MSG_TYPE_RATE_REPORT               = 0x17,
+	HTT_TLV_T2H_MSG_TYPE_FLOW_POOL_MAP             = 0x18,
+	HTT_TLV_T2H_MSG_TYPE_FLOW_POOL_UNMAP           = 0x19,
+	HTT_TLV_T2H_MSG_TYPE_SRING_SETUP_DONE          = 0x1a,
+	HTT_TLV_T2H_MSG_TYPE_MAP_FLOW_INFO             = 0x1b,
+	HTT_TLV_T2H_MSG_TYPE_EXT_STATS_CONF            = 0x1c,
+	HTT_TLV_T2H_MSG_TYPE_PPDU_STATS_IND            = 0x1d,
 	HTT_TLV_T2H_MSG_TYPE_TEST,
 	/* keep this last */
 	HTT_TLV_T2H_NUM_MSGS
@@ -519,6 +526,7 @@ enum htt_t2h_msg_type {
 	HTT_T2H_MSG_TYPE_TX_FETCH_CONFIRM,
 	HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND,
 	HTT_T2H_MSG_TYPE_PEER_STATS,
+	HTT_T2H_MSG_TYPE_PPDU_STATS_IND,
 	/* keep this last */
 	HTT_T2H_NUM_MSGS
 };
@@ -1750,6 +1758,27 @@ struct htt_peer_tx_stats {
 	u8 payload[0];
 } __packed;
 
+struct htt_tx_ppdu_stats_info {
+	__le32 tlv_hdr;
+	__le32 tx_success_bytes;
+	__le32 tx_retry_bytes;
+	__le32 tx_failed_bytes;
+	u8 tx_ratecode;
+	u8 flags;
+	__le16 peer_id;
+	__le16 tx_success_msdus;
+	__le16 tx_retry_msdus;
+	__le16 tx_failed_msdus;
+	__le16 tx_duration;
+} __packed;
+
+struct htt_ppdu_stats {
+	u8 pad[3];
+	__le32 tlv_hdr;
+	__le32 num_ppdu;
+	struct htt_tx_ppdu_stats_info tx_ppdu_stats[0];
+} __packed;
+
 #define ATH10K_10_2_TX_STATS_OFFSET	136
 #define PEER_STATS_FOR_NO_OF_PPDUS	4
 
@@ -1823,6 +1852,7 @@ struct htt_resp {
 		struct htt_tx_mode_switch_ind tx_mode_switch_ind;
 		struct htt_channel_change chan_change;
 		struct htt_peer_tx_stats peer_tx_stats;
+		struct htt_ppdu_stats ppdu_stats;
 	};
 } __packed;
 
drivers/net/wireless/ath/ath10k/htt_rx.c +65 -0

77 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/wmi-tlv.c +4 -0
index 69a1ec5..ae12a58 100644
@@ -1849,6 +1849,10 @@ static struct sk_buff *ath10k_wmi_tlv_op_gen_init(struct ath10k *ar)
 	if (test_bit(WMI_SERVICE_TX_DATA_ACK_RSSI, ar->wmi.svc_map))
 		cfg->host_capab |= __cpu_to_le32(WMI_RSRC_CFG_FLAG_TX_ACK_RSSI);
 
+	if (ath10k_peer_stats_enabled(ar))
+		cfg->host_capab |=
+			__cpu_to_le32(WMI_RSRC_CFG_FLAG_TX_PPDU_STATS);
+
 	ath10k_wmi_tlv_put_host_mem_chunks(ar, chunks);
 
 	ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv init\n");
drivers/net/wireless/ath/ath10k/wmi-tlv.h +3 -0
index 4972dc1..6635d96 100644
@@ -16,6 +16,7 @@
 #define WMI_TLV_VDEV_PARAM_UNSUPPORTED 0
 #define WMI_TLV_MGMT_TX_FRAME_MAX_LEN	64
 
+#define WMI_RSRC_CFG_FLAG_TX_PPDU_STATS		BIT(11)
 #define WMI_RSRC_CFG_FLAG_TX_ACK_RSSI		BIT(18)
 
 enum wmi_tlv_grp_id {
@@ -1600,6 +1601,8 @@ wmi_tlv_svc_map(const __le32 *in, unsigned long *out, size_t len)
 	       WMI_SERVICE_MESH_11S, len);
 	SVCMAP(WMI_TLV_SERVICE_SYNC_DELETE_CMDS,
 	       WMI_SERVICE_SYNC_DELETE_CMDS, len);
+	SVCMAP(WMI_TLV_SERVICE_PEER_STATS_INFO,
+	       WMI_SERVICE_PEER_STATS, len);
 }
 
 static inline void
Signature · 1 line
2.7.4
#2 lore raw
Quoted 13 lines · Yu Wang

When QCA6174/QCA9377 working in station mode, after connected to AP, tx bitrate is always '1.0 MBit/s' in output of command 'iw wlan0 link'.

That's because the parameters to calculate the tx bitrate are not well updated for QCA6174/QCA9377.

To fix this issue:
1. Add processing for HTT_T2H_MSG_TYPE_PPDU_STATS_IND which includes the peer tx stats;
2. Map WMI_TLV_SERVICE_PEER_STATS_INFO to WMI_SERVICE_PEER_STATS to enable the feature.

Quoted 5 lines

Tested with QCA6174 PCIe with firmware WLAN.RM.4.4.1.c3-00031. Tested with QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029.

This has new warnings:

drivers/net/wireless/ath/ath10k/htt_rx.c: In function 'ath10k_htt_process_ppdu_stats':
drivers/net/wireless/ath/ath10k/htt_rx.c:3746:21: warning: variable 'arsta' set but not used [-Wunused-but-set-variable] drivers/net/wireless/ath/ath10k/htt_rx.c:3751:18: warning: incorrect type in assignment (different base types)
drivers/net/wireless/ath/ath10k/htt_rx.c:3751:18: expected unsigned char [usertype] num_ppdu
drivers/net/wireless/ath/ath10k/htt_rx.c:3751:18: got restricted __le32 [usertype] num_ppdu

Signature · 3 lines
https://patchwork.kernel.org/patch/11250999/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#3 lore raw
In reply to Yu Wang
Quoted 13 lines · Yu Wang

When QCA6174/QCA9377 working in station mode, after connected to AP, tx bitrate is always '1.0 MBit/s' in output of command 'iw wlan0 link'.

That's because the parameters to calculate the tx bitrate are not well updated for QCA6174/QCA9377.

To fix this issue:
1. Add processing for HTT_T2H_MSG_TYPE_PPDU_STATS_IND which includes the peer tx stats;
2. Map WMI_TLV_SERVICE_PEER_STATS_INFO to WMI_SERVICE_PEER_STATS to enable the feature.

Quoted 5 lines

Tested with QCA6174 PCIe with firmware WLAN.RM.4.4.1.c3-00031. Tested with QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029.

This has new warnings:

drivers/net/wireless/ath/ath10k/htt_rx.c: In function 'ath10k_htt_process_ppdu_stats':
drivers/net/wireless/ath/ath10k/htt_rx.c:3746:21: warning: variable 'arsta' set but not used [-Wunused-but-set-variable] drivers/net/wireless/ath/ath10k/htt_rx.c:3751:18: warning: incorrect type in assignment (different base types)
drivers/net/wireless/ath/ath10k/htt_rx.c:3751:18: expected unsigned char [usertype] num_ppdu
drivers/net/wireless/ath/ath10k/htt_rx.c:3751:18: got restricted __le32 [usertype] num_ppdu

Signature · 8 lines
https://patchwork.kernel.org/patch/11250999/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
author
#4 lore raw

PATCH v2 1/2 ath10k: add ppdu stats support for QCA6174/QCA9377

In reply to a message not in the archive

When QCA6174/QCA9377 working in station mode, after connected to AP, tx bitrate is always '1.0 MBit/s' in output of command 'iw wlan0 link'.

That's because the parameters to calculate the tx bitrate are not well updated for QCA6174/QCA9377.

To fix this issue:
1. Add processing for HTT_T2H_MSG_TYPE_PPDU_STATS_IND which includes the peer tx stats;
2. Map WMI_TLV_SERVICE_PEER_STATS_INFO to WMI_SERVICE_PEER_STATS to enable the feature.

Tested with QCA6174 PCIe with firmware WLAN.RM.4.4.1.c3-00031. Tested with QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029.

---
 drivers/net/wireless/ath/ath10k/htt.c     |  2 +
 drivers/net/wireless/ath/ath10k/htt.h     | 30 ++++++++++++++
 drivers/net/wireless/ath/ath10k/htt_rx.c  | 65 +++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/wmi-tlv.c |  4 ++
 drivers/net/wireless/ath/ath10k/wmi-tlv.h |  3 ++
 5 files changed, 104 insertions(+)
drivers/net/wireless/ath/ath10k/htt.c +2 -0
index 7b75200..c32ab07 100644
@@ -89,6 +89,8 @@ static const enum htt_t2h_msg_type htt_tlv_t2h_msg_types[] = {
 	[HTT_TLV_T2H_MSG_TYPE_RX_OFLD_PKT_ERR] =
 		HTT_T2H_MSG_TYPE_RX_OFLD_PKT_ERR,
 	[HTT_TLV_T2H_MSG_TYPE_TEST] = HTT_T2H_MSG_TYPE_TEST,
+	[HTT_TLV_T2H_MSG_TYPE_PPDU_STATS_IND] =
+		HTT_T2H_MSG_TYPE_PPDU_STATS_IND,
 };
 
 static const enum htt_t2h_msg_type htt_10_4_t2h_msg_types[] = {
drivers/net/wireless/ath/ath10k/htt.h +30 -0
index 30c0800..e2aae263 100644
@@ -450,6 +450,13 @@ enum htt_tlv_t2h_msg_type {
 	HTT_TLV_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE       = 0x14,
 	HTT_TLV_T2H_MSG_TYPE_CHAN_CHANGE               = 0x15,
 	HTT_TLV_T2H_MSG_TYPE_RX_OFLD_PKT_ERR           = 0x16,
+	HTT_TLV_T2H_MSG_TYPE_RATE_REPORT               = 0x17,
+	HTT_TLV_T2H_MSG_TYPE_FLOW_POOL_MAP             = 0x18,
+	HTT_TLV_T2H_MSG_TYPE_FLOW_POOL_UNMAP           = 0x19,
+	HTT_TLV_T2H_MSG_TYPE_SRING_SETUP_DONE          = 0x1a,
+	HTT_TLV_T2H_MSG_TYPE_MAP_FLOW_INFO             = 0x1b,
+	HTT_TLV_T2H_MSG_TYPE_EXT_STATS_CONF            = 0x1c,
+	HTT_TLV_T2H_MSG_TYPE_PPDU_STATS_IND            = 0x1d,
 	HTT_TLV_T2H_MSG_TYPE_TEST,
 	/* keep this last */
 	HTT_TLV_T2H_NUM_MSGS
@@ -519,6 +526,7 @@ enum htt_t2h_msg_type {
 	HTT_T2H_MSG_TYPE_TX_FETCH_CONFIRM,
 	HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND,
 	HTT_T2H_MSG_TYPE_PEER_STATS,
+	HTT_T2H_MSG_TYPE_PPDU_STATS_IND,
 	/* keep this last */
 	HTT_T2H_NUM_MSGS
 };
@@ -1750,6 +1758,27 @@ struct htt_peer_tx_stats {
 	u8 payload[0];
 } __packed;
 
+struct htt_tx_ppdu_stats_info {
+	__le32 tlv_hdr;
+	__le32 tx_success_bytes;
+	__le32 tx_retry_bytes;
+	__le32 tx_failed_bytes;
+	u8 tx_ratecode;
+	u8 flags;
+	__le16 peer_id;
+	__le16 tx_success_msdus;
+	__le16 tx_retry_msdus;
+	__le16 tx_failed_msdus;
+	__le16 tx_duration;
+} __packed;
+
+struct htt_ppdu_stats {
+	u8 pad[3];
+	__le32 tlv_hdr;
+	__le32 num_ppdu;
+	struct htt_tx_ppdu_stats_info tx_ppdu_stats[0];
+} __packed;
+
 #define ATH10K_10_2_TX_STATS_OFFSET	136
 #define PEER_STATS_FOR_NO_OF_PPDUS	4
 
@@ -1823,6 +1852,7 @@ struct htt_resp {
 		struct htt_tx_mode_switch_ind tx_mode_switch_ind;
 		struct htt_channel_change chan_change;
 		struct htt_peer_tx_stats peer_tx_stats;
+		struct htt_ppdu_stats ppdu_stats;
 	};
 } __packed;
 
drivers/net/wireless/ath/ath10k/htt_rx.c +65 -0

77 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/wmi-tlv.c +4 -0
index 69a1ec5..ae12a58 100644
@@ -1849,6 +1849,10 @@ static struct sk_buff *ath10k_wmi_tlv_op_gen_init(struct ath10k *ar)
 	if (test_bit(WMI_SERVICE_TX_DATA_ACK_RSSI, ar->wmi.svc_map))
 		cfg->host_capab |= __cpu_to_le32(WMI_RSRC_CFG_FLAG_TX_ACK_RSSI);
 
+	if (ath10k_peer_stats_enabled(ar))
+		cfg->host_capab |=
+			__cpu_to_le32(WMI_RSRC_CFG_FLAG_TX_PPDU_STATS);
+
 	ath10k_wmi_tlv_put_host_mem_chunks(ar, chunks);
 
 	ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv init\n");
drivers/net/wireless/ath/ath10k/wmi-tlv.h +3 -0
index 4972dc1..6635d96 100644
@@ -16,6 +16,7 @@
 #define WMI_TLV_VDEV_PARAM_UNSUPPORTED 0
 #define WMI_TLV_MGMT_TX_FRAME_MAX_LEN	64
 
+#define WMI_RSRC_CFG_FLAG_TX_PPDU_STATS		BIT(11)
 #define WMI_RSRC_CFG_FLAG_TX_ACK_RSSI		BIT(18)
 
 enum wmi_tlv_grp_id {
@@ -1600,6 +1601,8 @@ wmi_tlv_svc_map(const __le32 *in, unsigned long *out, size_t len)
 	       WMI_SERVICE_MESH_11S, len);
 	SVCMAP(WMI_TLV_SERVICE_SYNC_DELETE_CMDS,
 	       WMI_SERVICE_SYNC_DELETE_CMDS, len);
+	SVCMAP(WMI_TLV_SERVICE_PEER_STATS_INFO,
+	       WMI_SERVICE_PEER_STATS, len);
 }
 
 static inline void
Signature · 7 lines
2.7.4


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
author
#5 lore raw

PATCH v2 2/2 ath10k: correct legacy rate in tx stats

In reply to a message not in the archive

When working in station mode, after connected to a legacy AP, 11g only, for example, the tx bitrate is incorrect in output of command 'iw wlan0 link'.

That's because the legacy tx bitrate value reported by firmware is not well handled:
For QCA6174, the value represents rate index, but treated as a real rate;
For QCA9888, the value is real rate, with unit 'Mbps', but treated as '100kbps'.

To fix this issue:
1. Translate the rate index to real rate for QCA6174;
2. Translate the rate from 'Mbps' to 'kbps' for QCA9888.

Tested with:
QCA6174 PCIe with firmware WLAN.RM.4.4.1.c3-00031. QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029. QCA9888 PCIe with firmware 10.4-3.9.0.2-00040.

---
 drivers/net/wireless/ath/ath10k/htt_rx.c | 83 +++++++++++++++++++++++++++++++-
 drivers/net/wireless/ath/ath10k/mac.c    |  2 +-
 drivers/net/wireless/ath/ath10k/mac.h    |  1 +
 3 files changed, 83 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/htt_rx.c +81 -2
index cde2d9b..796c8c0 100644
@@ -3455,7 +3455,7 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar,
 	struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
 	struct ieee80211_chanctx_conf *conf = NULL;
 	u8 rate = 0, sgi;
-	s8 rate_idx = 0;
+	s8 rate_idx = -1;
 	bool skip_auto_rate;
 	struct rate_info txrate;
 
@@ -3497,6 +3497,12 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar,
 		rate_idx = ath10k_get_legacy_rate_idx(ar, rate);
 		if (rate_idx < 0)
 			return;
+
+		/* from 1Mbps to 100Kbps */
+		rate = rate * 10;
+		if (rate == 50)
+			rate = 55;
+
 		arsta->txrate.legacy = rate;
 	} else if (txrate.flags == WMI_RATE_PREAMBLE_HT) {
 		arsta->txrate.flags = RATE_INFO_FLAGS_MCS;
@@ -3723,6 +3729,74 @@ static void ath10k_htt_rx_sec_ind_handler(struct ath10k *ar,
 	spin_unlock_bh(&ar->data_lock);
 }
 
+static int
+ath10k_htt_update_ratecode(struct ath10k *ar, struct ath10k_sta *arsta,
+			   u8 *ratecode)
+{
+	u8 hw_rate, preamble;
+	u16 bitrate;
+	int i;
+	const struct ieee80211_rate *bitrates;
+	bool cck;
+	struct ieee80211_chanctx_conf *conf = NULL;
+	enum nl80211_band band;
+	struct ieee80211_supported_band *sband;
+
+	if (!ratecode)
+		return -EINVAL;
+
+	/* only for legacy ratecode */
+	preamble = ATH10K_HW_PREAMBLE(*ratecode);
+	if (preamble != WMI_RATE_PREAMBLE_CCK &&
+	    preamble != WMI_RATE_PREAMBLE_OFDM)
+		return 0;
+
+	if (!arsta->arvif || !arsta->arvif->vif)
+		return -EINVAL;
+
+	WARN_ON(!rcu_read_lock_held());
+	conf = rcu_dereference(arsta->arvif->vif->chanctx_conf);
+	if (!conf)
+		return -EINVAL;
+
+	band = conf->def.chan->band;
+	sband = &ar->mac.sbands[band];
+	if (!sband->bitrates)
+		return -EINVAL;
+
+	if (WARN_ON_ONCE(sband->n_bitrates > S8_MAX))
+		return -EINVAL;
+
+	cck = (preamble == WMI_RATE_PREAMBLE_CCK);
+	hw_rate = ATH10K_HW_LEGACY_RATE(*ratecode);
+	for (i = 0; i < sband->n_bitrates; i++) {
+		bitrates = &sband->bitrates[i];
+		if (ath10k_mac_bitrate_is_cck(bitrates->bitrate) != cck)
+			continue;
+
+		if (bitrates->hw_value == hw_rate ||
+		    (bitrates->flags & IEEE80211_RATE_SHORT_PREAMBLE &&
+		     bitrates->hw_value_short == hw_rate)) {
+			bitrate = bitrates->bitrate;
+
+			/* The bitrate will be recovered in
+			 * ath10k_update_per_peer_tx_stats().
+			 */
+			if (bitrate == 55)
+				bitrate = 60;
+
+			bitrate = bitrate / 10;
+
+			/* replace hw_value with bitrate in ratecode */
+			*ratecode = ATH10K_HW_RATECODE(bitrate, 0, preamble);
+			return 0;
+		}
+	}
+
+	ath10k_warn(ar, "Invalid legacy ratecode %hhd ppdu stats", *ratecode);
+	return -EINVAL;
+}
+
 static void
 ath10k_htt_process_ppdu_stats(struct ath10k *ar, struct sk_buff *skb)
 {
@@ -3734,6 +3808,7 @@ ath10k_htt_process_ppdu_stats(struct ath10k *ar, struct sk_buff *skb)
 	struct ath10k_peer *peer;
 	u32 peer_id, i;
 	u8 num_ppdu;
+	u8 ratecode;
 
 	num_ppdu = resp->ppdu_stats.num_ppdu;
 	tx_stats = &resp->ppdu_stats.tx_ppdu_stats[0];
@@ -3753,6 +3828,10 @@ ath10k_htt_process_ppdu_stats(struct ath10k *ar, struct sk_buff *skb)
 	for (i = 0; i < num_ppdu; i++) {
 		tx_stats = &resp->ppdu_stats.tx_ppdu_stats[i];
 		arsta = (struct ath10k_sta *)sta->drv_priv;
+		ratecode = tx_stats->tx_ratecode;
+
+		if (ath10k_htt_update_ratecode(ar, arsta, &ratecode))
+			goto err;
 
 		p_tx_stats->succ_bytes =
 			__le32_to_cpu(tx_stats->tx_success_bytes);
@@ -3760,7 +3839,7 @@ ath10k_htt_process_ppdu_stats(struct ath10k *ar, struct sk_buff *skb)
 			__le32_to_cpu(tx_stats->tx_retry_bytes);
 		p_tx_stats->failed_bytes =
 			__le32_to_cpu(tx_stats->tx_failed_bytes);
-		p_tx_stats->ratecode = tx_stats->tx_ratecode;
+		p_tx_stats->ratecode = ratecode;
 		p_tx_stats->flags = tx_stats->flags;
 		p_tx_stats->succ_pkts =
 			__le16_to_cpu(tx_stats->tx_success_msdus);
drivers/net/wireless/ath/ath10k/mac.c +1 -1
index 83cc877..95a5069 100644
@@ -94,7 +94,7 @@ static struct ieee80211_rate ath10k_rates_rev2[] = {
 
 #define ath10k_wmi_legacy_rates ath10k_rates
 
-static bool ath10k_mac_bitrate_is_cck(int bitrate)
+bool ath10k_mac_bitrate_is_cck(int bitrate)
 {
 	switch (bitrate) {
 	case 10:
drivers/net/wireless/ath/ath10k/mac.h +1 -0
index 98d83a2..cc245b1 100644
@@ -28,6 +28,7 @@ struct rfc1042_hdr {
 	__be16 snap_type;
 } __packed;
 
+bool ath10k_mac_bitrate_is_cck(int bitrate);
 struct ath10k *ath10k_mac_create(size_t priv_size);
 void ath10k_mac_destroy(struct ath10k *ar);
 int ath10k_mac_register(struct ath10k *ar);
Signature · 1 line
2.7.4
#6 lore raw

Re: [PATCH v2 2/2] ath10k: correct legacy rate in tx stats

Quoted 15 lines · Yu Wang

When working in station mode, after connected to a legacy AP, 11g only, for example, the tx bitrate is incorrect in output of command 'iw wlan0 link'.

That's because the legacy tx bitrate value reported by firmware is not well handled:
For QCA6174, the value represents rate index, but treated as a real rate;
For QCA9888, the value is real rate, with unit 'Mbps', but treated as '100kbps'.

To fix this issue:
1. Translate the rate index to real rate for QCA6174;
2. Translate the rate from 'Mbps' to 'kbps' for QCA9888.

Quoted 7 lines

Tested with:
QCA6174 PCIe with firmware WLAN.RM.4.4.1.c3-00031. QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029. QCA9888 PCIe with firmware 10.4-3.9.0.2-00040.

My comments don't seem to go to patchwork, so trying again:

What about QCA988X and WCN3990, how do they behave? Does this patch break those?

Quoted 9 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +9 -0
+	cck = (preamble == WMI_RATE_PREAMBLE_CCK);
+	hw_rate = ATH10K_HW_LEGACY_RATE(*ratecode);
+	for (i = 0; i < sband->n_bitrates; i++) {
+		bitrates = &sband->bitrates[i];
+		if (ath10k_mac_bitrate_is_cck(bitrates->bitrate) != cck)
+			continue;
+
+		if (bitrates->hw_value == hw_rate ||
+		    (bitrates->flags & IEEE80211_RATE_SHORT_PREAMBLE &&

drivers/net/wireless/ath/ath10k/htt_rx.c static void ath10k_htt_rx_sec_ind_handler(struct ath10k *ar, · line 3788

Quoted 10 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +10 -0
+		     bitrates->hw_value_short == hw_rate)) {
+			bitrate = bitrates->bitrate;
+
+			/* The bitrate will be recovered in
+			 * ath10k_update_per_peer_tx_stats().
+			 */
+			if (bitrate == 55)
+				bitrate = 60;
+
+			bitrate = bitrate / 10;

Here you use magic value 60 but in ath10k_update_per_peer_tx_stats() you use magic value 50:

drivers/net/wireless/ath/ath10k/htt_rx.c ath10k_update_per_peer_tx_stats(struct ath10k *ar, · line 3504

Quoted 4 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +4 -0
+		/* from 1Mbps to 100Kbps */
+		rate = rate * 10;
+		if (rate == 50)
+			rate = 55;

Am I missing something or how is this supposed to work?

Signature · 8 lines
https://patchwork.kernel.org/patch/11251001/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
#7 lore raw

RE: [PATCH v2 2/2] ath10k: correct legacy rate in tx stats

Quoted 30 lines

-----Original Message-----
From: ath10k <[email protected]> On Behalf Of Kalle Valo
Sent: Thursday, April 9, 2020 10:22 PM
To: Yu Wang <[email protected]>
Cc: [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v2 2/2] ath10k: correct legacy rate in tx stats

Quoted 19 lines · Yu Wang

When working in station mode, after connected to a legacy AP, 11g only, for example, the tx bitrate is incorrect in output of command 'iw wlan0 link'.

That's because the legacy tx bitrate value reported by firmware is not well handled:
For QCA6174, the value represents rate index, but treated as a real rate; For QCA9888, the value is real rate, with unit 'Mbps', but treated as '100kbps'.

To fix this issue:
1. Translate the rate index to real rate for QCA6174; 2. Translate the rate from 'Mbps' to 'kbps' for QCA9888.

Tested with:
QCA6174 PCIe with firmware WLAN.RM.4.4.1.c3-00031. QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029. QCA9888 PCIe with firmware 10.4-3.9.0.2-00040.

Quoted 7 lines
Quoted 2 lines

My comments don't seem to go to patchwork, so trying again:

What about QCA988X and WCN3990, how do they behave? Does this patch break those?

Since HTT_T2H_MSG_TYPE_PPDU_STATS_IND is a newly added message, suppose it's won't break the other functions. I don’t have environment to verify the patch with QCA988X and WCN3990.
Can anyone help on this?

Quoted 24 lines
Quoted 10 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +9 -0
+cck = (preamble == WMI_RATE_PREAMBLE_CCK);
+hw_rate = ATH10K_HW_LEGACY_RATE(*ratecode);
+for (i = 0; i < sband->n_bitrates; i++) {
+bitrates = &sband->bitrates[i];
+if (ath10k_mac_bitrate_is_cck(bitrates->bitrate) != cck)
+continue;
+
+if (bitrates->hw_value == hw_rate ||
+    (bitrates->flags & IEEE80211_RATE_SHORT_PREAMBLE &&

drivers/net/wireless/ath/ath10k/htt_rx.c static void ath10k_htt_rx_sec_ind_handler(struct ath10k *ar, · line 3788

Quoted 10 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +10 -0
+     bitrates->hw_value_short == hw_rate)) {
+bitrate = bitrates->bitrate;
+
+/* The bitrate will be recovered in
+ * ath10k_update_per_peer_tx_stats().
+ */
+if (bitrate == 55)
+bitrate = 60;
+
+bitrate = bitrate / 10;

Here you use magic value 60 but in ath10k_update_per_peer_tx_stats() you use magic value 50:

Quoted 6 lines

drivers/net/wireless/ath/ath10k/htt_rx.c ath10k_update_per_peer_tx_stats(struct ath10k *ar, · line 3504

Quoted 4 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +4 -0
+/* from 1Mbps to 100Kbps */
+rate = rate * 10;
+if (rate == 50)
+rate = 55;

Am I missing something or how is this supposed to work?

In existing code, ath10k_update_per_peer_tx_stats() will check the bitrate and convert 6_CCK to 5(in the comment: FW sends CCK rate 5.5Mbps as 6), and then 5 will be recovered to 55. That's why we need to convert bitrate 55 to 6 when processing PPDU_STATS.

if (txrate.flags == WMI_RATE_PREAMBLE_CCK || txrate.flags == WMI_RATE_PREAMBLE_OFDM) {
rate = ATH10K_HW_LEGACY_RATE(peer_stats->ratecode); /* This is hacky, FW sends CCK rate 5.5Mbps as 6 */ if (rate == 6 && txrate.flags == WMI_RATE_PREAMBLE_CCK) rate = 5;
rate_idx = ath10k_get_legacy_rate_idx(ar, rate); if (rate_idx < 0)
return;

/* from 1Mbps to 100Kbps */
rate = rate * 10;
if (rate == 50)
rate = 55;

Quoted 11 lines

--
https://patchwork.kernel.org/patch/11251001/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatch
es

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k

#8 lore raw

Re: [PATCH v2 2/2] ath10k: correct legacy rate in tx stats

Quoted 99 lines · Yu Wang
Quoted 30 lines

-----Original Message-----
From: ath10k <[email protected]> On Behalf Of Kalle Valo
Sent: Thursday, April 9, 2020 10:22 PM
To: Yu Wang <[email protected]>
Cc: [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v2 2/2] ath10k: correct legacy rate in tx stats

Quoted 19 lines · Yu Wang

When working in station mode, after connected to a legacy AP, 11g only, for example, the tx bitrate is incorrect in output of command 'iw wlan0 link'.

That's because the legacy tx bitrate value reported by firmware is not well handled:
For QCA6174, the value represents rate index, but treated as a real rate; For QCA9888, the value is real rate, with unit 'Mbps', but treated as '100kbps'.

To fix this issue:
1. Translate the rate index to real rate for QCA6174; 2. Translate the rate from 'Mbps' to 'kbps' for QCA9888.

Tested with:
QCA6174 PCIe with firmware WLAN.RM.4.4.1.c3-00031. QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029. QCA9888 PCIe with firmware 10.4-3.9.0.2-00040.

Quoted 7 lines
Quoted 2 lines

My comments don't seem to go to patchwork, so trying again:

What about QCA988X and WCN3990, how do they behave? Does this patch break those?

Since HTT_T2H_MSG_TYPE_PPDU_STATS_IND is a newly added message, suppose it's won't break the other functions.
I don’t have environment to verify the patch with QCA988X and WCN3990. Can anyone help on this?

Quoted 25 lines
Quoted 10 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +9 -0
+cck = (preamble == WMI_RATE_PREAMBLE_CCK);
+hw_rate = ATH10K_HW_LEGACY_RATE(*ratecode);
+for (i = 0; i < sband->n_bitrates; i++) {
+bitrates = &sband->bitrates[i];
+if (ath10k_mac_bitrate_is_cck(bitrates->bitrate) != cck)
+continue;
+
+if (bitrates->hw_value == hw_rate ||
+    (bitrates->flags & IEEE80211_RATE_SHORT_PREAMBLE &&

drivers/net/wireless/ath/ath10k/htt_rx.c static void ath10k_htt_rx_sec_ind_handler(struct ath10k *ar, · line 3788

Quoted 10 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +10 -0
+     bitrates->hw_value_short == hw_rate)) {
+bitrate = bitrates->bitrate;
+
+/* The bitrate will be recovered in
+ * ath10k_update_per_peer_tx_stats().
+ */
+if (bitrate == 55)
+bitrate = 60;
+
+bitrate = bitrate / 10;

Here you use magic value 60 but in ath10k_update_per_peer_tx_stats() you use
magic value 50:

Quoted 6 lines

drivers/net/wireless/ath/ath10k/htt_rx.c ath10k_update_per_peer_tx_stats(struct ath10k *ar, · line 3504

Quoted 4 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +4 -0
+/* from 1Mbps to 100Kbps */
+rate = rate * 10;
+if (rate == 50)
+rate = 55;

Am I missing something or how is this supposed to work?

In existing code, ath10k_update_per_peer_tx_stats() will check the bitrate and convert 6_CCK to 5(in the comment: FW sends CCK rate 5.5Mbps as 6), and then 5 will be recovered to 55.
That's why we need to convert bitrate 55 to 6 when processing PPDU_STATS.

if (txrate.flags == WMI_RATE_PREAMBLE_CCK || txrate.flags == WMI_RATE_PREAMBLE_OFDM) {
rate = ATH10K_HW_LEGACY_RATE(peer_stats->ratecode); /* This is hacky, FW sends CCK rate 5.5Mbps as 6 */ if (rate == 6 && txrate.flags == WMI_RATE_PREAMBLE_CCK) rate = 5;
rate_idx = ath10k_get_legacy_rate_idx(ar, rate); if (rate_idx < 0)
return;

/* from 1Mbps to 100Kbps */
rate = rate * 10;
if (rate == 50)
rate = 55;

Quoted 7 lines

--
https://patchwork.kernel.org/patch/11251001/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatch
es

Quoted 9 lines
Quoted 4 lines

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k

Hi

I don't understand why are you fixing this in driver when the comment clearly says "FW sends CCK rate 5.5Mbps as 6"
Shouldn't a proper way be to fix this in firmware?

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k

#9 lore raw

Re: [PATCH v2 2/2] ath10k: correct legacy rate in tx stats

In reply to Yu Wang
Quoted 15 lines · Yu Wang

When working in station mode, after connected to a legacy AP, 11g only, for example, the tx bitrate is incorrect in output of command 'iw wlan0 link'.

That's because the legacy tx bitrate value reported by firmware is not well handled:
For QCA6174, the value represents rate index, but treated as a real rate;
For QCA9888, the value is real rate, with unit 'Mbps', but treated as '100kbps'.

To fix this issue:
1. Translate the rate index to real rate for QCA6174;
2. Translate the rate from 'Mbps' to 'kbps' for QCA9888.

Quoted 7 lines

Tested with:
QCA6174 PCIe with firmware WLAN.RM.4.4.1.c3-00031. QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029. QCA9888 PCIe with firmware 10.4-3.9.0.2-00040.

My comments don't seem to go to patchwork, so trying again:

What about QCA988X and WCN3990, how do they behave? Does this patch break those?

Quoted 9 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +9 -0
+	cck = (preamble == WMI_RATE_PREAMBLE_CCK);
+	hw_rate = ATH10K_HW_LEGACY_RATE(*ratecode);
+	for (i = 0; i < sband->n_bitrates; i++) {
+		bitrates = &sband->bitrates[i];
+		if (ath10k_mac_bitrate_is_cck(bitrates->bitrate) != cck)
+			continue;
+
+		if (bitrates->hw_value == hw_rate ||
+		    (bitrates->flags & IEEE80211_RATE_SHORT_PREAMBLE &&

drivers/net/wireless/ath/ath10k/htt_rx.c static void ath10k_htt_rx_sec_ind_handler(struct ath10k *ar, · line 3788

Quoted 10 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +10 -0
+		     bitrates->hw_value_short == hw_rate)) {
+			bitrate = bitrates->bitrate;
+
+			/* The bitrate will be recovered in
+			 * ath10k_update_per_peer_tx_stats().
+			 */
+			if (bitrate == 55)
+				bitrate = 60;
+
+			bitrate = bitrate / 10;

Here you use magic value 60 but in ath10k_update_per_peer_tx_stats() you use magic value 50:

drivers/net/wireless/ath/ath10k/htt_rx.c ath10k_update_per_peer_tx_stats(struct ath10k *ar, · line 3504

Quoted 4 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +4 -0
+		/* from 1Mbps to 100Kbps */
+		rate = rate * 10;
+		if (rate == 50)
+			rate = 55;

Am I missing something or how is this supposed to work?

Signature · 3 lines
https://patchwork.kernel.org/patch/11251001/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
author
#10 lore raw

PATCH v2 2/2 ath10k: correct legacy rate in tx stats

In reply to a message not in the archive

When working in station mode, after connected to a legacy AP, 11g only, for example, the tx bitrate is incorrect in output of command 'iw wlan0 link'.

That's because the legacy tx bitrate value reported by firmware is not well handled:
For QCA6174, the value represents rate index, but treated as a real rate;
For QCA9888, the value is real rate, with unit 'Mbps', but treated as '100kbps'.

To fix this issue:
1. Translate the rate index to real rate for QCA6174;
2. Translate the rate from 'Mbps' to 'kbps' for QCA9888.

Tested with:
QCA6174 PCIe with firmware WLAN.RM.4.4.1.c3-00031. QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029. QCA9888 PCIe with firmware 10.4-3.9.0.2-00040.

---
 drivers/net/wireless/ath/ath10k/htt_rx.c | 83 +++++++++++++++++++++++++++++++-
 drivers/net/wireless/ath/ath10k/mac.c    |  2 +-
 drivers/net/wireless/ath/ath10k/mac.h    |  1 +
 3 files changed, 83 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/htt_rx.c +81 -2
index cde2d9b..796c8c0 100644
@@ -3455,7 +3455,7 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar,
 	struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv;
 	struct ieee80211_chanctx_conf *conf = NULL;
 	u8 rate = 0, sgi;
-	s8 rate_idx = 0;
+	s8 rate_idx = -1;
 	bool skip_auto_rate;
 	struct rate_info txrate;
 
@@ -3497,6 +3497,12 @@ ath10k_update_per_peer_tx_stats(struct ath10k *ar,
 		rate_idx = ath10k_get_legacy_rate_idx(ar, rate);
 		if (rate_idx < 0)
 			return;
+
+		/* from 1Mbps to 100Kbps */
+		rate = rate * 10;
+		if (rate == 50)
+			rate = 55;
+
 		arsta->txrate.legacy = rate;
 	} else if (txrate.flags == WMI_RATE_PREAMBLE_HT) {
 		arsta->txrate.flags = RATE_INFO_FLAGS_MCS;
@@ -3723,6 +3729,74 @@ static void ath10k_htt_rx_sec_ind_handler(struct ath10k *ar,
 	spin_unlock_bh(&ar->data_lock);
 }
 
+static int
+ath10k_htt_update_ratecode(struct ath10k *ar, struct ath10k_sta *arsta,
+			   u8 *ratecode)
+{
+	u8 hw_rate, preamble;
+	u16 bitrate;
+	int i;
+	const struct ieee80211_rate *bitrates;
+	bool cck;
+	struct ieee80211_chanctx_conf *conf = NULL;
+	enum nl80211_band band;
+	struct ieee80211_supported_band *sband;
+
+	if (!ratecode)
+		return -EINVAL;
+
+	/* only for legacy ratecode */
+	preamble = ATH10K_HW_PREAMBLE(*ratecode);
+	if (preamble != WMI_RATE_PREAMBLE_CCK &&
+	    preamble != WMI_RATE_PREAMBLE_OFDM)
+		return 0;
+
+	if (!arsta->arvif || !arsta->arvif->vif)
+		return -EINVAL;
+
+	WARN_ON(!rcu_read_lock_held());
+	conf = rcu_dereference(arsta->arvif->vif->chanctx_conf);
+	if (!conf)
+		return -EINVAL;
+
+	band = conf->def.chan->band;
+	sband = &ar->mac.sbands[band];
+	if (!sband->bitrates)
+		return -EINVAL;
+
+	if (WARN_ON_ONCE(sband->n_bitrates > S8_MAX))
+		return -EINVAL;
+
+	cck = (preamble == WMI_RATE_PREAMBLE_CCK);
+	hw_rate = ATH10K_HW_LEGACY_RATE(*ratecode);
+	for (i = 0; i < sband->n_bitrates; i++) {
+		bitrates = &sband->bitrates[i];
+		if (ath10k_mac_bitrate_is_cck(bitrates->bitrate) != cck)
+			continue;
+
+		if (bitrates->hw_value == hw_rate ||
+		    (bitrates->flags & IEEE80211_RATE_SHORT_PREAMBLE &&
+		     bitrates->hw_value_short == hw_rate)) {
+			bitrate = bitrates->bitrate;
+
+			/* The bitrate will be recovered in
+			 * ath10k_update_per_peer_tx_stats().
+			 */
+			if (bitrate == 55)
+				bitrate = 60;
+
+			bitrate = bitrate / 10;
+
+			/* replace hw_value with bitrate in ratecode */
+			*ratecode = ATH10K_HW_RATECODE(bitrate, 0, preamble);
+			return 0;
+		}
+	}
+
+	ath10k_warn(ar, "Invalid legacy ratecode %hhd ppdu stats", *ratecode);
+	return -EINVAL;
+}
+
 static void
 ath10k_htt_process_ppdu_stats(struct ath10k *ar, struct sk_buff *skb)
 {
@@ -3734,6 +3808,7 @@ ath10k_htt_process_ppdu_stats(struct ath10k *ar, struct sk_buff *skb)
 	struct ath10k_peer *peer;
 	u32 peer_id, i;
 	u8 num_ppdu;
+	u8 ratecode;
 
 	num_ppdu = resp->ppdu_stats.num_ppdu;
 	tx_stats = &resp->ppdu_stats.tx_ppdu_stats[0];
@@ -3753,6 +3828,10 @@ ath10k_htt_process_ppdu_stats(struct ath10k *ar, struct sk_buff *skb)
 	for (i = 0; i < num_ppdu; i++) {
 		tx_stats = &resp->ppdu_stats.tx_ppdu_stats[i];
 		arsta = (struct ath10k_sta *)sta->drv_priv;
+		ratecode = tx_stats->tx_ratecode;
+
+		if (ath10k_htt_update_ratecode(ar, arsta, &ratecode))
+			goto err;
 
 		p_tx_stats->succ_bytes =
 			__le32_to_cpu(tx_stats->tx_success_bytes);
@@ -3760,7 +3839,7 @@ ath10k_htt_process_ppdu_stats(struct ath10k *ar, struct sk_buff *skb)
 			__le32_to_cpu(tx_stats->tx_retry_bytes);
 		p_tx_stats->failed_bytes =
 			__le32_to_cpu(tx_stats->tx_failed_bytes);
-		p_tx_stats->ratecode = tx_stats->tx_ratecode;
+		p_tx_stats->ratecode = ratecode;
 		p_tx_stats->flags = tx_stats->flags;
 		p_tx_stats->succ_pkts =
 			__le16_to_cpu(tx_stats->tx_success_msdus);
drivers/net/wireless/ath/ath10k/mac.c +1 -1
index 83cc877..95a5069 100644
@@ -94,7 +94,7 @@ static struct ieee80211_rate ath10k_rates_rev2[] = {
 
 #define ath10k_wmi_legacy_rates ath10k_rates
 
-static bool ath10k_mac_bitrate_is_cck(int bitrate)
+bool ath10k_mac_bitrate_is_cck(int bitrate)
 {
 	switch (bitrate) {
 	case 10:
drivers/net/wireless/ath/ath10k/mac.h +1 -0
index 98d83a2..cc245b1 100644
@@ -28,6 +28,7 @@ struct rfc1042_hdr {
 	__be16 snap_type;
 } __packed;
 
+bool ath10k_mac_bitrate_is_cck(int bitrate);
 struct ath10k *ath10k_mac_create(size_t priv_size);
 void ath10k_mac_destroy(struct ath10k *ar);
 int ath10k_mac_register(struct ath10k *ar);
Signature · 7 lines
2.7.4


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
#11 lore raw

Re: [PATCH v2 2/2] ath10k: correct legacy rate in tx stats

Quoted 11 lines · Yu Wang

When working in station mode, after connected to a legacy AP, 11g only, for example, the tx bitrate is incorrect in output of command 'iw wlan0 link'.

That's because the legacy tx bitrate value reported by firmware is not well handled:
For QCA6174, the value represents rate index, but treated as a real rate;
For QCA9888, the value is real rate, with unit 'Mbps', but treated as '100kbps'.

Quoted 8 lines

To fix this issue:
1. Translate the rate index to real rate for QCA6174;
2. Translate the rate from 'Mbps' to 'kbps' for QCA9888.

Tested with:
QCA6174 PCIe with firmware WLAN.RM.4.4.1.c3-00031. QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029. QCA9888 PCIe with firmware 10.4-3.9.0.2-00040.

What about QCA988X and WCN3990, how do they behave? Does this patch break those?

Signature · 6 lines
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
#12 lore raw

Re: [PATCH v2 2/2] ath10k: correct legacy rate in tx stats

In reply to Yu Wang
Quoted 21 lines · Yu Wang

When working in station mode, after connected to a legacy AP, 11g only, for example, the tx bitrate is incorrect in output of command 'iw wlan0 link'.

That's because the legacy tx bitrate value reported by firmware is not well handled:
For QCA6174, the value represents rate index, but treated as a real rate;
For QCA9888, the value is real rate, with unit 'Mbps', but treated as '100kbps'.

To fix this issue:
1. Translate the rate index to real rate for QCA6174;
2. Translate the rate from 'Mbps' to 'kbps' for QCA9888.

Tested with:
QCA6174 PCIe with firmware WLAN.RM.4.4.1.c3-00031. QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029. QCA9888 PCIe with firmware 10.4-3.9.0.2-00040.

[...]

Quoted 51 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +47 -0
@@ -3723,6 +3729,74 @@ static void ath10k_htt_rx_sec_ind_handler(struct ath10k *ar,
 	spin_unlock_bh(&ar->data_lock);
 }
 
+static int
+ath10k_htt_update_ratecode(struct ath10k *ar, struct ath10k_sta *arsta,
+			   u8 *ratecode)
+{
+	u8 hw_rate, preamble;
+	u16 bitrate;
+	int i;
+	const struct ieee80211_rate *bitrates;
+	bool cck;
+	struct ieee80211_chanctx_conf *conf = NULL;
+	enum nl80211_band band;
+	struct ieee80211_supported_band *sband;
+
+	if (!ratecode)
+		return -EINVAL;
+
+	/* only for legacy ratecode */
+	preamble = ATH10K_HW_PREAMBLE(*ratecode);
+	if (preamble != WMI_RATE_PREAMBLE_CCK &&
+	    preamble != WMI_RATE_PREAMBLE_OFDM)
+		return 0;
+
+	if (!arsta->arvif || !arsta->arvif->vif)
+		return -EINVAL;
+
+	WARN_ON(!rcu_read_lock_held());
+	conf = rcu_dereference(arsta->arvif->vif->chanctx_conf);
+	if (!conf)
+		return -EINVAL;
+
+	band = conf->def.chan->band;
+	sband = &ar->mac.sbands[band];
+	if (!sband->bitrates)
+		return -EINVAL;
+
+	if (WARN_ON_ONCE(sband->n_bitrates > S8_MAX))
+		return -EINVAL;
+
+	cck = (preamble == WMI_RATE_PREAMBLE_CCK);
+	hw_rate = ATH10K_HW_LEGACY_RATE(*ratecode);
+	for (i = 0; i < sband->n_bitrates; i++) {
+		bitrates = &sband->bitrates[i];
+		if (ath10k_mac_bitrate_is_cck(bitrates->bitrate) != cck)
+			continue;
+
+		if (bitrates->hw_value == hw_rate ||
+		    (bitrates->flags & IEEE80211_RATE_SHORT_PREAMBLE &&

drivers/net/wireless/ath/ath10k/htt_rx.c static void ath10k_htt_rx_sec_ind_handler(struct ath10k *ar, · line 3788

Quoted 10 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +10 -0
+		     bitrates->hw_value_short == hw_rate)) {
+			bitrate = bitrates->bitrate;
+
+			/* The bitrate will be recovered in
+			 * ath10k_update_per_peer_tx_stats().
+			 */
+			if (bitrate == 55)
+				bitrate = 60;
+
+			bitrate = bitrate / 10;

Here you use magic value 60 but in ath10k_update_per_peer_tx_stats() you use magic value 50:

drivers/net/wireless/ath/ath10k/htt_rx.c ath10k_update_per_peer_tx_stats(struct ath10k *ar, · line 3504

Quoted 4 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +4 -0
+		/* from 1Mbps to 100Kbps */
+		rate = rate * 10;
+		if (rate == 50)
+			rate = 55;

Am I missing something or how is this supposed to work?

Signature · 6 lines
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
#13 lore raw

Re: [PATCH v2 2/2] ath10k: correct legacy rate in tx stats

For some reason these comments didn't go to patchwork so resending them again:

Quoted 29 lines · Kalle Valo
Quoted 7 lines · Yu Wang
drivers/net/wireless/ath/ath10k/htt_rx.c +7 -0
+	for (i = 0; i < sband->n_bitrates; i++) {
+		bitrates = &sband->bitrates[i];
+		if (ath10k_mac_bitrate_is_cck(bitrates->bitrate) != cck)
+			continue;
+
+		if (bitrates->hw_value == hw_rate ||
+		    (bitrates->flags & IEEE80211_RATE_SHORT_PREAMBLE &&

drivers/net/wireless/ath/ath10k/htt_rx.c static void ath10k_htt_rx_sec_ind_handler(struct ath10k *ar, · line 3788

Quoted 10 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +10 -0
+		     bitrates->hw_value_short == hw_rate)) {
+			bitrate = bitrates->bitrate;
+
+			/* The bitrate will be recovered in
+			 * ath10k_update_per_peer_tx_stats().
+			 */
+			if (bitrate == 55)
+				bitrate = 60;
+
+			bitrate = bitrate / 10;

Here you use magic value 60 but in ath10k_update_per_peer_tx_stats() you use magic value 50:

drivers/net/wireless/ath/ath10k/htt_rx.c ath10k_update_per_peer_tx_stats(struct ath10k *ar, · line 3504

Quoted 4 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +4 -0
+		/* from 1Mbps to 100Kbps */
+		rate = rate * 10;
+		if (rate == 50)
+			rate = 55;

Am I missing something or how is this supposed to work?

Signature · 1 line
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches