@@ -341,11 +341,13 @@ static void ieee80211_add_ht_ie(struct ieee80211_sub_if_data *sdata,
341341
342342static void ieee80211_add_vht_ie (struct ieee80211_sub_if_data * sdata ,
343343 struct sk_buff * skb ,
344- struct ieee80211_supported_band * sband )
344+ struct ieee80211_supported_band * sband ,
345+ struct ieee80211_vht_cap * ap_vht_cap )
345346{
346347 u8 * pos ;
347348 u32 cap ;
348349 struct ieee80211_sta_vht_cap vht_cap ;
350+ int i ;
349351
350352 BUILD_BUG_ON (sizeof (vht_cap ) != sizeof (sband -> vht_cap ));
351353
@@ -364,6 +366,42 @@ static void ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata,
364366 cap &= ~IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ ;
365367 }
366368
369+ /*
370+ * Some APs apparently get confused if our capabilities are better
371+ * than theirs, so restrict what we advertise in the assoc request.
372+ */
373+ if (!(ap_vht_cap -> vht_cap_info &
374+ cpu_to_le32 (IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE )))
375+ cap &= ~IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE ;
376+
377+ if (!(ap_vht_cap -> vht_cap_info &
378+ cpu_to_le32 (IEEE80211_VHT_CAP_TXSTBC )))
379+ cap &= ~(IEEE80211_VHT_CAP_RXSTBC_1 |
380+ IEEE80211_VHT_CAP_RXSTBC_3 |
381+ IEEE80211_VHT_CAP_RXSTBC_4 );
382+
383+ for (i = 0 ; i < 8 ; i ++ ) {
384+ int shift = i * 2 ;
385+ u16 mask = IEEE80211_VHT_MCS_NOT_SUPPORTED << shift ;
386+ u16 ap_mcs , our_mcs ;
387+
388+ ap_mcs = (le16_to_cpu (ap_vht_cap -> supp_mcs .tx_mcs_map ) &
389+ mask ) >> shift ;
390+ our_mcs = (le16_to_cpu (vht_cap .vht_mcs .rx_mcs_map ) &
391+ mask ) >> shift ;
392+
393+ switch (ap_mcs ) {
394+ default :
395+ if (our_mcs <= ap_mcs )
396+ break ;
397+ /* fall through */
398+ case IEEE80211_VHT_MCS_NOT_SUPPORTED :
399+ vht_cap .vht_mcs .rx_mcs_map &= cpu_to_le16 (~mask );
400+ vht_cap .vht_mcs .rx_mcs_map |=
401+ cpu_to_le16 (ap_mcs << shift );
402+ }
403+ }
404+
367405 /* reserve and fill IE */
368406 pos = skb_put (skb , sizeof (struct ieee80211_vht_cap ) + 2 );
369407 ieee80211_ie_build_vht_cap (pos , & vht_cap , cap );
@@ -562,7 +600,8 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
562600 sband , chan , sdata -> smps_mode );
563601
564602 if (!(ifmgd -> flags & IEEE80211_STA_DISABLE_VHT ))
565- ieee80211_add_vht_ie (sdata , skb , sband );
603+ ieee80211_add_vht_ie (sdata , skb , sband ,
604+ & assoc_data -> ap_vht_cap );
566605
567606 /* if present, add any custom non-vendor IEs that go after HT */
568607 if (assoc_data -> ie_len && assoc_data -> ie ) {
@@ -3753,7 +3792,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
37533792 struct ieee80211_bss * bss = (void * )req -> bss -> priv ;
37543793 struct ieee80211_mgd_assoc_data * assoc_data ;
37553794 struct ieee80211_supported_band * sband ;
3756- const u8 * ssidie , * ht_ie ;
3795+ const u8 * ssidie , * ht_ie , * vht_ie ;
37573796 int i , err ;
37583797
37593798 assoc_data = kzalloc (sizeof (* assoc_data ) + req -> ie_len , GFP_KERNEL );
@@ -3872,6 +3911,12 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
38723911 ((struct ieee80211_ht_operation * )(ht_ie + 2 ))-> ht_param ;
38733912 else
38743913 ifmgd -> flags |= IEEE80211_STA_DISABLE_HT ;
3914+ vht_ie = ieee80211_bss_get_ie (req -> bss , WLAN_EID_VHT_CAPABILITY );
3915+ if (vht_ie && vht_ie [1 ] >= sizeof (struct ieee80211_vht_cap ))
3916+ memcpy (& assoc_data -> ap_vht_cap , vht_ie + 2 ,
3917+ sizeof (struct ieee80211_vht_cap ));
3918+ else
3919+ ifmgd -> flags |= IEEE80211_STA_DISABLE_VHT ;
38753920 rcu_read_unlock ();
38763921
38773922 if (bss -> wmm_used && bss -> uapsd_supported &&
0 commit comments