Skip to content

Commit c4cfdf5

Browse files
Loic Poulaingregkh
Loic Poulain
authored andcommitted
wcn36xx: Correct band/freq reporting on RX
[ Upstream commit 8a27ca3 ] For packets originating from hardware scan, the channel and band is included in the buffer descriptor (bd->rf_band & bd->rx_ch). For 2Ghz band the channel value is directly reported in the 4-bit rx_ch field. For 5Ghz band, the rx_ch field contains a mapping index (given the 4-bit limitation). The reserved0 value field is also used to extend 4-bit mapping to 5-bit mapping to support more than 16 5Ghz channels. This change adds correct reporting of the frequency/band, that is used in scan mechanism. And is required for 5Ghz hardware scan support. Signed-off-by: Loic Poulain <[email protected]> Tested-by: Bryan O'Donoghue <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent a27095c commit c4cfdf5

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

drivers/net/wireless/ath/wcn36xx/txrx.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ struct wcn36xx_rate {
3131
enum rate_info_bw bw;
3232
};
3333

34+
/* Buffer descriptor rx_ch field is limited to 5-bit (4+1), a mapping is used
35+
* for 11A Channels.
36+
*/
37+
static const u8 ab_rx_ch_map[] = { 36, 40, 44, 48, 52, 56, 60, 64, 100, 104,
38+
108, 112, 116, 120, 124, 128, 132, 136, 140,
39+
149, 153, 157, 161, 165, 144 };
40+
3441
static const struct wcn36xx_rate wcn36xx_rate_table[] = {
3542
/* 11b rates */
3643
{ 10, 0, RX_ENC_LEGACY, 0, RATE_INFO_BW_20 },
@@ -291,6 +298,22 @@ int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb)
291298
ieee80211_is_probe_resp(hdr->frame_control))
292299
status.boottime_ns = ktime_get_boottime_ns();
293300

301+
if (bd->scan_learn) {
302+
/* If packet originates from hardware scanning, extract the
303+
* band/channel from bd descriptor.
304+
*/
305+
u8 hwch = (bd->reserved0 << 4) + bd->rx_ch;
306+
307+
if (bd->rf_band != 1 && hwch <= sizeof(ab_rx_ch_map) && hwch >= 1) {
308+
status.band = NL80211_BAND_5GHZ;
309+
status.freq = ieee80211_channel_to_frequency(ab_rx_ch_map[hwch - 1],
310+
status.band);
311+
} else {
312+
status.band = NL80211_BAND_2GHZ;
313+
status.freq = ieee80211_channel_to_frequency(hwch, status.band);
314+
}
315+
}
316+
294317
memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status));
295318

296319
if (ieee80211_is_beacon(hdr->frame_control)) {

drivers/net/wireless/ath/wcn36xx/txrx.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ struct wcn36xx_rx_bd {
110110
/* 0x44 */
111111
u32 exp_seq_num:12;
112112
u32 cur_seq_num:12;
113-
u32 fr_type_subtype:8;
113+
u32 rf_band:2;
114+
u32 fr_type_subtype:6;
114115

115116
/* 0x48 */
116117
u32 msdu_size:16;

0 commit comments

Comments
 (0)