{cfg,mac}80211: move mandatory rates calculation to cfg80211
authorAshok Nagarajan <ashok@cozybit.com>
Sat, 11 May 2013 00:50:51 +0000 (17:50 -0700)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 24 May 2013 21:54:43 +0000 (23:54 +0200)
Move mandatory rates calculation to cfg80211, shared with non mac80211 drivers.

Signed-off-by: Ashok Nagarajan <ashok@cozybit.com>
[extend documentation]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/cfg80211.h
net/mac80211/ibss.c
net/mac80211/ieee80211_i.h
net/mac80211/mesh.c
net/mac80211/util.c
net/wireless/util.c

index 32a2f1b20861c52de2d17446e4588646a127fc83..58f6302da1459c2e88c6f3d675978c9977f36243 100644 (file)
@@ -3005,6 +3005,15 @@ struct ieee80211_rate *
 ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
                            u32 basic_rates, int bitrate);
 
+/**
+ * ieee80211_mandatory_rates - get mandatory rates for a given band
+ * @sband: the band to look for rates in
+ *
+ * This function returns a bitmap of the mandatory rates for the given
+ * band, bits are set according to the rate position in the bitrates array.
+ */
+u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband);
+
 /*
  * Radiotap parsing functions -- for controlled injection support
  *
index 170f9a7fa3190afee4148bb4caf0c817a53b7991..956ba6316da522888228cde8bae5e1fe9f7c38c0 100644 (file)
@@ -341,6 +341,7 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
        struct ieee80211_local *local = sdata->local;
        struct sta_info *sta;
        struct ieee80211_chanctx_conf *chanctx_conf;
+       struct ieee80211_supported_band *sband;
        int band;
 
        /*
@@ -380,8 +381,9 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
        sta->last_rx = jiffies;
 
        /* make sure mandatory rates are always added */
+       sband = local->hw.wiphy->bands[band];
        sta->sta.supp_rates[band] = supp_rates |
-                       ieee80211_mandatory_rates(local, band);
+                       ieee80211_mandatory_rates(sband);
 
        return ieee80211_ibss_finish_sta(sta, auth);
 }
@@ -492,7 +494,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
                                prev_rates = sta->sta.supp_rates[band];
                                /* make sure mandatory rates are always added */
                                sta->sta.supp_rates[band] = supp_rates |
-                                       ieee80211_mandatory_rates(local, band);
+                                       ieee80211_mandatory_rates(sband);
 
                                if (sta->sta.supp_rates[band] != prev_rates) {
                                        ibss_dbg(sdata,
@@ -624,6 +626,7 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
        struct ieee80211_local *local = sdata->local;
        struct sta_info *sta;
        struct ieee80211_chanctx_conf *chanctx_conf;
+       struct ieee80211_supported_band *sband;
        int band;
 
        /*
@@ -658,8 +661,9 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
        sta->last_rx = jiffies;
 
        /* make sure mandatory rates are always added */
+       sband = local->hw.wiphy->bands[band];
        sta->sta.supp_rates[band] = supp_rates |
-                       ieee80211_mandatory_rates(local, band);
+                       ieee80211_mandatory_rates(sband);
 
        spin_lock(&ifibss->incomplete_lock);
        list_add(&sta->list, &ifibss->incomplete_stations);
index 158e6eb188d388e99cb92a7a7cee9429a7bc2108..b7cbd4ebf0e03b6fb3caa62fcd05b1c6f5228bcb 100644 (file)
@@ -1505,9 +1505,6 @@ static inline void ieee802_11_parse_elems(u8 *start, size_t len, bool action,
        ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0);
 }
 
-u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
-                             enum ieee80211_band band);
-
 void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
 void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
 void ieee80211_dynamic_ps_timer(unsigned long data);
index c13db9ad394b1d5dd4a63fe8188d4b66e7a63050..c14bb816c6a3562ca497fbea7620a46d53fb968c 100644 (file)
@@ -741,6 +741,8 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
                      BSS_CHANGED_BASIC_RATES |
                      BSS_CHANGED_BEACON_INT;
        enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
+       struct ieee80211_supported_band *sband =
+                                       sdata->local->hw.wiphy->bands[band];
 
        local->fif_other_bss++;
        /* mesh ifaces must set allmulti to forward mcast traffic */
@@ -758,8 +760,7 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
        sdata->vif.bss_conf.ht_operation_mode =
                                ifmsh->mshcfg.ht_opmode;
        sdata->vif.bss_conf.enable_beacon = true;
-       sdata->vif.bss_conf.basic_rates =
-               ieee80211_mandatory_rates(local, band);
+       sdata->vif.bss_conf.basic_rates = ieee80211_mandatory_rates(sband);
 
        changed |= ieee80211_mps_local_status_update(sdata);
 
index 3f87fa468b1fc18d0ab00079166da5bf053aa738..707953fd83240f13b465467971d3244f01271230 100644 (file)
@@ -1072,32 +1072,6 @@ void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
        ieee80211_set_wmm_default(sdata, true);
 }
 
-u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
-                             enum ieee80211_band band)
-{
-       struct ieee80211_supported_band *sband;
-       struct ieee80211_rate *bitrates;
-       u32 mandatory_rates;
-       enum ieee80211_rate_flags mandatory_flag;
-       int i;
-
-       sband = local->hw.wiphy->bands[band];
-       if (WARN_ON(!sband))
-               return 1;
-
-       if (band == IEEE80211_BAND_2GHZ)
-               mandatory_flag = IEEE80211_RATE_MANDATORY_B;
-       else
-               mandatory_flag = IEEE80211_RATE_MANDATORY_A;
-
-       bitrates = sband->bitrates;
-       mandatory_rates = 0;
-       for (i = 0; i < sband->n_bitrates; i++)
-               if (bitrates[i].flags & mandatory_flag)
-                       mandatory_rates |= BIT(i);
-       return mandatory_rates;
-}
-
 void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
                         u16 transaction, u16 auth_alg, u16 status,
                         const u8 *extra, size_t extra_len, const u8 *da,
index b11052be09bedab1dec4ebaf5fc3c23b9baf3c01..0962f107f57f831d625f59c3e505e70e30d72b96 100644 (file)
@@ -33,6 +33,29 @@ ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
 }
 EXPORT_SYMBOL(ieee80211_get_response_rate);
 
+u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband)
+{
+       struct ieee80211_rate *bitrates;
+       u32 mandatory_rates = 0;
+       enum ieee80211_rate_flags mandatory_flag;
+       int i;
+
+       if (WARN_ON(!sband))
+               return 1;
+
+       if (sband->band == IEEE80211_BAND_2GHZ)
+               mandatory_flag = IEEE80211_RATE_MANDATORY_B;
+       else
+               mandatory_flag = IEEE80211_RATE_MANDATORY_A;
+
+       bitrates = sband->bitrates;
+       for (i = 0; i < sband->n_bitrates; i++)
+               if (bitrates[i].flags & mandatory_flag)
+                       mandatory_rates |= BIT(i);
+       return mandatory_rates;
+}
+EXPORT_SYMBOL(ieee80211_mandatory_rates);
+
 int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band)
 {
        /* see 802.11 17.3.8.3.2 and Annex J