mac80211: Indicate basic rates when adding rate IEs
[cascardo/linux.git] / net / mac80211 / util.c
index 471a831..468a18e 100644 (file)
@@ -1683,13 +1683,15 @@ ieee80211_ht_oper_to_channel_type(struct ieee80211_ht_operation *ht_oper)
        return channel_type;
 }
 
-int ieee80211_add_srates_ie(struct ieee80211_vif *vif, struct sk_buff *skb)
+int ieee80211_add_srates_ie(struct ieee80211_vif *vif,
+                           struct sk_buff *skb, bool need_basic)
 {
        struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_supported_band *sband;
        int rate;
        u8 i, rates, *pos;
+       u32 basic_rates = vif->bss_conf.basic_rates;
 
        sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
        rates = sband->n_bitrates;
@@ -1703,20 +1705,25 @@ int ieee80211_add_srates_ie(struct ieee80211_vif *vif, struct sk_buff *skb)
        *pos++ = WLAN_EID_SUPP_RATES;
        *pos++ = rates;
        for (i = 0; i < rates; i++) {
+               u8 basic = 0;
+               if (need_basic && basic_rates & BIT(i))
+                       basic = 0x80;
                rate = sband->bitrates[i].bitrate;
-               *pos++ = (u8) (rate / 5);
+               *pos++ = basic | (u8) (rate / 5);
        }
 
        return 0;
 }
 
-int ieee80211_add_ext_srates_ie(struct ieee80211_vif *vif, struct sk_buff *skb)
+int ieee80211_add_ext_srates_ie(struct ieee80211_vif *vif,
+                               struct sk_buff *skb, bool need_basic)
 {
        struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_supported_band *sband;
        int rate;
        u8 i, exrates, *pos;
+       u32 basic_rates = vif->bss_conf.basic_rates;
 
        sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
        exrates = sband->n_bitrates;
@@ -1733,8 +1740,11 @@ int ieee80211_add_ext_srates_ie(struct ieee80211_vif *vif, struct sk_buff *skb)
                *pos++ = WLAN_EID_EXT_SUPP_RATES;
                *pos++ = exrates;
                for (i = 8; i < sband->n_bitrates; i++) {
+                       u8 basic = 0;
+                       if (need_basic && basic_rates & BIT(i))
+                               basic = 0x80;
                        rate = sband->bitrates[i].bitrate;
-                       *pos++ = (u8) (rate / 5);
+                       *pos++ = basic | (u8) (rate / 5);
                }
        }
        return 0;