Skip to contentSkip to conversation

wireless: add check of field VHT Extended NSS BW Capable for 160/80+80 MHz setting

PATCH Superseded Wen Gong 2 participants 3 messages May 21, 2021 – May 31, 2021

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Wen Gong

author
#0 lore raw

PATCH v2 1/1 wireless: add check of field VHT Extended NSS BW Capable for 160/80+80 MHz setting

Table 9-251—Supported VHT-MCS and NSS Set subfields, it has subfield VHT Extended NSS BW Capable, its definition is:
Indicates whether the STA is capable of interpreting the Extended NSS BW Support subfield of the VHT Capabilities Information field.

This patch is to add check for the subfield.

---
v2: change code style

 net/wireless/chan.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
net/wireless/chan.c +5 -3
index 285b8076054b..e29562659ae5 100644
@@ -942,7 +942,7 @@ bool cfg80211_chandef_usable(struct wiphy *wiphy,
 	struct ieee80211_sta_vht_cap *vht_cap;
 	struct ieee80211_edmg *edmg_cap;
 	u32 width, control_freq, cap;
-	bool support_80_80 = false;
+	bool ext_nss_cap, support_80_80 = false;
 
 	if (WARN_ON(!cfg80211_chandef_valid(chandef)))
 		return false;
@@ -950,6 +950,7 @@ bool cfg80211_chandef_usable(struct wiphy *wiphy,
 	ht_cap = &wiphy->bands[chandef->chan->band]->ht_cap;
 	vht_cap = &wiphy->bands[chandef->chan->band]->vht_cap;
 	edmg_cap = &wiphy->bands[chandef->chan->band]->edmg_cap;
+	ext_nss_cap = vht_cap->vht_mcs.tx_highest & IEEE80211_VHT_EXT_NSS_BW_CAPABLE;
 
 	if (edmg_cap->channels &&
 	    !cfg80211_edmg_usable(wiphy,
@@ -1015,7 +1016,8 @@ bool cfg80211_chandef_usable(struct wiphy *wiphy,
 			(cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ) ||
 			(cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ &&
 			 cap & IEEE80211_VHT_CAP_EXT_NSS_BW_MASK) ||
-			u32_get_bits(cap, IEEE80211_VHT_CAP_EXT_NSS_BW_MASK) > 1;
+			(ext_nss_cap &&
+			 u32_get_bits(cap, IEEE80211_VHT_CAP_EXT_NSS_BW_MASK) > 1);
 		if (chandef->chan->band != NL80211_BAND_6GHZ && !support_80_80)
 			return false;
 		fallthrough;
@@ -1037,7 +1039,7 @@ bool cfg80211_chandef_usable(struct wiphy *wiphy,
 		cap = vht_cap->cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK;
 		if (cap != IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ &&
 		    cap != IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ &&
-		    !(vht_cap->cap & IEEE80211_VHT_CAP_EXT_NSS_BW_MASK))
+		    !(ext_nss_cap && (vht_cap->cap & IEEE80211_VHT_CAP_EXT_NSS_BW_MASK)))
 			return false;
 		break;
 	default:
Signature · 7 lines
2.31.1


-- 
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#1 lore raw
Thank you for the patch! Perhaps something to improve:

Hi Wen,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mac80211-next/master]
[also build test WARNING on mac80211/master v5.13-rc2 next-20210521] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Wen-Gong/wireless-add-check-of-field-VHT-Extended-NSS-BW-Capable-for-160-80-80-MHz-setting/20210522-224810
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master
config: i386-randconfig-s001-20210522 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-341-g8af24329-dirty
        # https://github.com/0day-ci/linux/commit/ed41c78effa1b66bb3d00e368b92940e5ffadb57
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Wen-Gong/wireless-add-check-of-field-VHT-Extended-NSS-BW-Capable-for-160-80-80-MHz-setting/20210522-224810
        git checkout ed41c78effa1b66bb3d00e368b92940e5ffadb57
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate

sparse warnings: (new ones prefixed by >>)

>> net/wireless/chan.c:953:39: sparse: sparse: restricted __le16 degrades to integer

vim +953 net/wireless/chan.c

936
937 bool cfg80211_chandef_usable(struct wiphy *wiphy,
938 const struct cfg80211_chan_def *chandef,
939 u32 prohibited_flags)
940 {
941 struct ieee80211_sta_ht_cap *ht_cap;
942 struct ieee80211_sta_vht_cap *vht_cap;
943 struct ieee80211_edmg *edmg_cap;
944 u32 width, control_freq, cap;
945 bool ext_nss_cap, support_80_80 = false;
946
947 if (WARN_ON(!cfg80211_chandef_valid(chandef)))
948 return false;
949
950 ht_cap = &wiphy->bands[chandef->chan->band]->ht_cap;
951 vht_cap = &wiphy->bands[chandef->chan->band]->vht_cap;
952 edmg_cap = &wiphy->bands[chandef->chan->band]->edmg_cap;

 > 953		ext_nss_cap = vht_cap->vht_mcs.tx_highest & IEEE80211_VHT_EXT_NSS_BW_CAPABLE;
   954	
   955		if (edmg_cap->channels &&
   956		    !cfg80211_edmg_usable(wiphy,
   957					  chandef->edmg.channels,
   958					  chandef->edmg.bw_config,
   959					  chandef->chan->hw_value,
   960					  edmg_cap))

961 return false;
962
963 control_freq = chandef->chan->center_freq;
964
965 switch (chandef->width) {
966 case NL80211_CHAN_WIDTH_1:
967 width = 1;
968 break;
969 case NL80211_CHAN_WIDTH_2:
970 width = 2;
971 break;
972 case NL80211_CHAN_WIDTH_4:
973 width = 4;
974 break;
975 case NL80211_CHAN_WIDTH_8:
976 width = 8;
977 break;
978 case NL80211_CHAN_WIDTH_16:
979 width = 16;
980 break;
981 case NL80211_CHAN_WIDTH_5:
982 width = 5;
983 break;
984 case NL80211_CHAN_WIDTH_10:
985 prohibited_flags |= IEEE80211_CHAN_NO_10MHZ;
986 width = 10;
987 break;
988 case NL80211_CHAN_WIDTH_20:
989 if (!ht_cap->ht_supported &&
990 chandef->chan->band != NL80211_BAND_6GHZ)
991 return false;
992 fallthrough;
993 case NL80211_CHAN_WIDTH_20_NOHT:
994 prohibited_flags |= IEEE80211_CHAN_NO_20MHZ;
995 width = 20;
996 break;
997 case NL80211_CHAN_WIDTH_40:
998 width = 40;
999 if (chandef->chan->band == NL80211_BAND_6GHZ)
1000 break;
1001 if (!ht_cap->ht_supported)
1002 return false;
1003 if (!(ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) ||
1004 ht_cap->cap & IEEE80211_HT_CAP_40MHZ_INTOLERANT)
1005 return false;
1006 if (chandef->center_freq1 < control_freq &&
1007 chandef->chan->flags & IEEE80211_CHAN_NO_HT40MINUS)
1008 return false;
1009 if (chandef->center_freq1 > control_freq &&
1010 chandef->chan->flags & IEEE80211_CHAN_NO_HT40PLUS)
1011 return false;
1012 break;
1013 case NL80211_CHAN_WIDTH_80P80:
1014 cap = vht_cap->cap;
1015 support_80_80 =
1016 (cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ) ||
1017 (cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ &&
1018 cap & IEEE80211_VHT_CAP_EXT_NSS_BW_MASK) ||
1019 (ext_nss_cap &&
1020 u32_get_bits(cap, IEEE80211_VHT_CAP_EXT_NSS_BW_MASK) > 1);
1021 if (chandef->chan->band != NL80211_BAND_6GHZ && !support_80_80)
1022 return false;
1023 fallthrough;
1024 case NL80211_CHAN_WIDTH_80:
1025 prohibited_flags |= IEEE80211_CHAN_NO_80MHZ;
1026 width = 80;
1027 if (chandef->chan->band == NL80211_BAND_6GHZ)
1028 break;
1029 if (!vht_cap->vht_supported)
1030 return false;
1031 break;
1032 case NL80211_CHAN_WIDTH_160:
1033 prohibited_flags |= IEEE80211_CHAN_NO_160MHZ;
1034 width = 160;
1035 if (chandef->chan->band == NL80211_BAND_6GHZ)
1036 break;
1037 if (!vht_cap->vht_supported)
1038 return false;
1039 cap = vht_cap->cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK;
1040 if (cap != IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ &&
1041 cap != IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ &&
1042 !(ext_nss_cap && (vht_cap->cap & IEEE80211_VHT_CAP_EXT_NSS_BW_MASK)))
1043 return false;
1044 break;
1045 default:
1046 WARN_ON_ONCE(1);
1047 return false;
1048 }
1049
1050 /*
1051 * TODO: What if there are only certain 80/160/80+80 MHz channels
1052 * allowed by the driver, or only certain combinations?
1053 * For 40 MHz the driver can set the NO_HT40 flags, but for
1054 * 80/160 MHz and in particular 80+80 MHz this isn't really
1055 * feasible and we only have NO_80MHZ/NO_160MHZ so far but
1056 * no way to cover 80+80 MHz or more complex restrictions.
1057 * Note that such restrictions also need to be advertised to
1058 * userspace, for example for P2P channel selection.
1059 */
1060
1061 if (width > 20)
1062 prohibited_flags |= IEEE80211_CHAN_NO_OFDM;
1063
1064 /* 5 and 10 MHz are only defined for the OFDM PHY */
1065 if (width < 20)
1066 prohibited_flags |= IEEE80211_CHAN_NO_OFDM;
1067
1068
1069 if (!cfg80211_secondary_chans_ok(wiphy,
1070 ieee80211_chandef_to_khz(chandef),
1071 width, prohibited_flags))
1072 return false;
1073
1074 if (!chandef->center_freq2)
1075 return true;
1076 return cfg80211_secondary_chans_ok(wiphy,
1077 MHZ_TO_KHZ(chandef->center_freq2),
1078 width, prohibited_flags);
1079 }
1080 EXPORT_SYMBOL(cfg80211_chandef_usable);
1081

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

author
#2 lore raw
Quoted 30 lines · kernel test robot

Hi Wen,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mac80211-next/master]
[also build test WARNING on mac80211/master v5.13-rc2 next-20210521] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Wen-Gong/wireless-add-check-of-field-VHT-Extended-NSS-BW-Capable-for-160-80-80-MHz-setting/20210522-224810
base:
https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git
master
config: i386-randconfig-s001-20210522 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:

        # apt-get install sparse
        # sparse version: v0.6.3-341-g8af24329-dirty
        #
https://github.com/0day-ci/linux/commit/ed41c78effa1b66bb3d00e368b92940e5ffadb57
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review
Wen-Gong/wireless-add-check-of-field-VHT-Extended-NSS-BW-Capable-for-160-80-80-MHz-setting/20210522-224810
        git checkout ed41c78effa1b66bb3d00e368b92940e5ffadb57
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 
ARCH=i386
Quoted 8 lines

If you fix the issue, kindly add following tag as appropriate

sparse warnings: (new ones prefixed by >>)

Quoted 2 lines
Quoted 2 lines

net/wireless/chan.c:953:39: sparse: sparse: restricted __le16 degrades to integer

please use new patch: "[PATCH v3] wireless: add check of field VHT Extended NSS BW Capable for 160/80+80 MHz setting"

...