mac80211: Modify sta_get_rates to give basic rates
authorAshok Nagarajan <ashok@cozybit.com>
Tue, 3 Apr 2012 04:21:21 +0000 (21:21 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 11 Apr 2012 20:23:47 +0000 (16:23 -0400)
Signed-off-by: Ashok Nagarajan <ashok@cozybit.com>
Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/mac80211/ibss.c
net/mac80211/ieee80211_i.h
net/mac80211/mesh.c
net/mac80211/mesh_plink.c
net/mac80211/util.c

index e910449dead09d1e208c0c851be28e207d27f793..49a20798033877939adae23fa85202c12c0716cc 100644 (file)
@@ -408,7 +408,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
 
                if (elems->supp_rates) {
                        supp_rates = ieee80211_sta_get_rates(local, elems,
-                                                            band);
+                                                            band, NULL);
                        if (sta) {
                                u32 prev_rates;
 
@@ -558,7 +558,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
                       sdata->name, mgmt->bssid);
 #endif
                ieee80211_sta_join_ibss(sdata, bss);
-               supp_rates = ieee80211_sta_get_rates(local, elems, band);
+               supp_rates = ieee80211_sta_get_rates(local, elems, band, NULL);
                ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa,
                                       supp_rates, true);
                rcu_read_unlock();
index ea9623cbd969e5fda81a30678241767feccfd877..41f7295cd891b9db227797676e6552676f785b40 100644 (file)
@@ -1480,7 +1480,7 @@ void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
                                  const u8 *supp_rates);
 u32 ieee80211_sta_get_rates(struct ieee80211_local *local,
                            struct ieee802_11_elems *elems,
-                           enum ieee80211_band band);
+                           enum ieee80211_band band, u32 *basic_rates);
 int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
                             enum ieee80211_smps_mode smps_mode);
 void ieee80211_recalc_smps(struct ieee80211_local *local);
index f1d9685d959c761a1e190171cb80e5c7ef4faf07..7b22822d4208a29c550bf5ab02fbf3df6fea8695 100644 (file)
@@ -625,7 +625,7 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
        struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
        struct ieee802_11_elems elems;
        struct ieee80211_channel *channel;
-       u32 supp_rates = 0;
+       u32 supp_rates = 0, basic_rates = 0;
        size_t baselen;
        int freq;
        enum ieee80211_band band = rx_status->band;
@@ -658,7 +658,8 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
 
        if (elems.mesh_id && elems.mesh_config &&
            mesh_matches_local(&elems, sdata)) {
-               supp_rates = ieee80211_sta_get_rates(local, &elems, band);
+               supp_rates = ieee80211_sta_get_rates(local, &elems,
+                                                    band, &basic_rates);
                mesh_neighbour_update(mgmt->sa, supp_rates, sdata, &elems);
        }
 
index 73fa687edc7c2d3eeb5c06b1047cd4f3a41d93ea..91e2043bc9b2787df6aa139aa79a73f8ba65baa6 100644 (file)
@@ -465,6 +465,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
        bool deactivated, matches_local = true;
        u8 ie_len;
        u8 *baseaddr;
+       u32 rates, basic_rates = 0;
        __le16 plid, llid, reason;
 #ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
        static const char *mplstates[] = {
@@ -559,6 +560,9 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
 
        /* Now we will figure out the appropriate event... */
        event = PLINK_UNDEFINED;
+       rates = ieee80211_sta_get_rates(local, &elems,
+                                       rx_status->band, &basic_rates);
+
        if (ftype != WLAN_SP_MESH_PEERING_CLOSE &&
            (!mesh_matches_local(&elems, sdata))) {
                matches_local = false;
@@ -583,7 +587,6 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
                return;
        } else if (!sta) {
                /* ftype == WLAN_SP_MESH_PEERING_OPEN */
-               u32 rates;
 
                rcu_read_unlock();
 
@@ -591,8 +594,6 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
                        mpl_dbg("Mesh plink error: no more free plinks\n");
                        return;
                }
-
-               rates = ieee80211_sta_get_rates(local, &elems, rx_status->band);
                sta = mesh_plink_alloc(sdata, mgmt->sa, rates, &elems);
                if (!sta) {
                        mpl_dbg("Mesh plink error: plink table full\n");
index 468a18ea1f1b32847daa0c204005c35faf01166f..a18b693042b2b5a4ce8f1a07d628b0ac83534cfa 100644 (file)
@@ -1109,7 +1109,7 @@ void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
 
 u32 ieee80211_sta_get_rates(struct ieee80211_local *local,
                            struct ieee802_11_elems *elems,
-                           enum ieee80211_band band)
+                           enum ieee80211_band band, u32 *basic_rates)
 {
        struct ieee80211_supported_band *sband;
        struct ieee80211_rate *bitrates;
@@ -1130,15 +1130,25 @@ u32 ieee80211_sta_get_rates(struct ieee80211_local *local,
                     elems->ext_supp_rates_len; i++) {
                u8 rate = 0;
                int own_rate;
+               bool is_basic;
                if (i < elems->supp_rates_len)
                        rate = elems->supp_rates[i];
                else if (elems->ext_supp_rates)
                        rate = elems->ext_supp_rates
                                [i - elems->supp_rates_len];
                own_rate = 5 * (rate & 0x7f);
-               for (j = 0; j < num_rates; j++)
-                       if (bitrates[j].bitrate == own_rate)
+               is_basic = !!(rate & 0x80);
+
+               if (is_basic && (rate & 0x7f) == BSS_MEMBERSHIP_SELECTOR_HT_PHY)
+                       continue;
+
+               for (j = 0; j < num_rates; j++) {
+                       if (bitrates[j].bitrate == own_rate) {
                                supp_rates |= BIT(j);
+                               if (basic_rates && is_basic)
+                                       *basic_rates |= BIT(j);
+                       }
+               }
        }
        return supp_rates;
 }