From 66bed14b22242bf4794b54b09ab342d4e1188f41 Mon Sep 17 00:00:00 2001 From: Veerendranath Jakkam Date: Wed, 16 Sep 2020 13:58:22 +0530 Subject: [PATCH] 6 GHz: Fix opclasses mapping in ieee80211_freq_to_channel_ext() Previously only primary channel number used to calculate 6GHz operating class in ieee80211_freq_to_channel_ext() and it is always giving 131 operating class. Fix this by mapping operating class using chanwidth and sec_channel also. This is needed to avoid OCV failures on the 6 GHz band when the channel width is larger than 20 MHz. Signed-off-by: Veerendranath Jakkam --- src/common/ieee802_11_common.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c index 9c536cc5f..471db43c7 100644 --- a/src/common/ieee802_11_common.c +++ b/src/common/ieee802_11_common.c @@ -1030,15 +1030,28 @@ enum hostapd_hw_mode ieee80211_freq_to_channel_ext(unsigned int freq, } if (freq > 5950 && freq <= 7115) { - int bw; - u8 idx = (freq - 5950) / 5; - - bw = center_idx_to_bw_6ghz(idx); - if (bw < 0) + if ((freq - 5950) % 5) return NUM_HOSTAPD_MODES; - *channel = idx; - *op_class = 131 + bw; + switch (chanwidth) { + case CHANWIDTH_80MHZ: + *op_class = 133; + break; + case CHANWIDTH_160MHZ: + *op_class = 134; + break; + case CHANWIDTH_80P80MHZ: + *op_class = 135; + break; + default: + if (sec_channel) + *op_class = 132; + else + *op_class = 131; + break; + } + + *channel = (freq - 5950) / 5; return HOSTAPD_MODE_IEEE80211A; }