Subject: Re: [PATCH v2 2/2] wcn36xx: Implement tx_rate reporting

From: Kalle Valo <[email-masked]>
Date: Sun, 20 Mar 2022 21:17:40 +0200

Edmond Gagnon <[email-masked]> writes:

> Currently, the driver reports a tx_rate of 6.0 MBit/s no matter the true
> rate:
>
> root@linaro-developer:~# iw wlan0 link
> Connected to 6c:f3:7f:eb:9b:92 (on wlan0)
>         SSID: SQ-DEVICETEST
>         freq: 5200
>         RX: 4141 bytes (32 packets)
>         TX: 2082 bytes (15 packets)
>         signal: -77 dBm
>         rx bitrate: 135.0 MBit/s MCS 6 40MHz short GI
>         tx bitrate: 6.0 MBit/s
>
>         bss flags:      short-slot-time
>         dtim period:    1
>         beacon int:     100
>
> This patch requests HAL_GLOBAL_CLASS_A_STATS_INFO via a hal_get_stats
> firmware message and reports it via ieee80211_tx_rate_update:
>
> root@linaro-developer:~# iw wlan0 link
> Connected to 6c:f3:7f:eb:98:21 (on wlan0)
>         SSID: SQ-DEVICETEST
>         freq: 2412
>         RX: 440785 bytes (573 packets)
>         TX: 60526 bytes (571 packets)
>         signal: -64 dBm
>         rx bitrate: 72.2 MBit/s MCS 7 short GI
>         tx bitrate: 52.0 MBit/s MCS 5
>
>         bss flags:      short-preamble short-slot-time
>         dtim period:    1
>         beacon int:     100
>
> Tested on MSM8939 with WCN3680B running CNSS-PR-2-0-1-2-c1-00083 with
> 5.17, and verified by sniffing frames over the air with Wireshark to
> ensure the MCS indices match.
>
> Signed-off-by: Edmond Gagnon <[email-masked]>
> Reviewed-by: Benjamin Li <[email-masked]>

[...]

> +	// HT?
> +	if (stats->tx_rate_flags & (HAL_TX_RATE_HT20 | HAL_TX_RATE_HT40))
> +		tx_rate->flags |= IEEE80211_TX_RC_MCS;
> +
> +	// VHT?
> +	if (stats->tx_rate_flags & (HAL_TX_RATE_VHT20 | HAL_TX_RATE_VHT40 | HAL_TX_RATE_VHT80))
> +		tx_rate->flags |= IEEE80211_TX_RC_VHT_MCS;
> +
> +	// SGI / LGI?
> +	if (stats->tx_rate_flags & HAL_TX_RATE_SGI)
> +		tx_rate->flags |= IEEE80211_TX_RC_SHORT_GI;
> +
> +	// 40MHz?
> +	if (stats->tx_rate_flags & (HAL_TX_RATE_HT40 | HAL_TX_RATE_VHT40))
> +		tx_rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
> +
> +	// 80MHz?
> +	if (stats->tx_rate_flags & HAL_TX_RATE_VHT80)
> +		tx_rate->flags |= IEEE80211_TX_RC_80_MHZ_WIDTH;

No C++ comments, please. And IMHO the comments are not really providing
any extra value anyway.

https://www.kernel.org/doc/html/latest/process/coding-style.html

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

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