Skip to content

Commit b422c6c

Browse files
ashokrajnagarajanjmberg-intel
authored andcommitted
{cfg,mac}80211: move mandatory rates calculation to cfg80211
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>
1 parent d4a5a48 commit b422c6c

6 files changed

Lines changed: 42 additions & 34 deletions

File tree

‎include/net/cfg80211.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,6 +3005,15 @@ struct ieee80211_rate *
30053005
ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
30063006
u32 basic_rates, int bitrate);
30073007

3008+
/**
3009+
* ieee80211_mandatory_rates - get mandatory rates for a given band
3010+
* @sband: the band to look for rates in
3011+
*
3012+
* This function returns a bitmap of the mandatory rates for the given
3013+
* band, bits are set according to the rate position in the bitrates array.
3014+
*/
3015+
u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband);
3016+
30083017
/*
30093018
* Radiotap parsing functions -- for controlled injection support
30103019
*

‎net/mac80211/ibss.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
341341
struct ieee80211_local *local = sdata->local;
342342
struct sta_info *sta;
343343
struct ieee80211_chanctx_conf *chanctx_conf;
344+
struct ieee80211_supported_band *sband;
344345
int band;
345346

346347
/*
@@ -380,8 +381,9 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
380381
sta->last_rx = jiffies;
381382

382383
/* make sure mandatory rates are always added */
384+
sband = local->hw.wiphy->bands[band];
383385
sta->sta.supp_rates[band] = supp_rates |
384-
ieee80211_mandatory_rates(local, band);
386+
ieee80211_mandatory_rates(sband);
385387

386388
return ieee80211_ibss_finish_sta(sta, auth);
387389
}
@@ -492,7 +494,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
492494
prev_rates = sta->sta.supp_rates[band];
493495
/* make sure mandatory rates are always added */
494496
sta->sta.supp_rates[band] = supp_rates |
495-
ieee80211_mandatory_rates(local, band);
497+
ieee80211_mandatory_rates(sband);
496498

497499
if (sta->sta.supp_rates[band] != prev_rates) {
498500
ibss_dbg(sdata,
@@ -624,6 +626,7 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
624626
struct ieee80211_local *local = sdata->local;
625627
struct sta_info *sta;
626628
struct ieee80211_chanctx_conf *chanctx_conf;
629+
struct ieee80211_supported_band *sband;
627630
int band;
628631

629632
/*
@@ -658,8 +661,9 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
658661
sta->last_rx = jiffies;
659662

660663
/* make sure mandatory rates are always added */
664+
sband = local->hw.wiphy->bands[band];
661665
sta->sta.supp_rates[band] = supp_rates |
662-
ieee80211_mandatory_rates(local, band);
666+
ieee80211_mandatory_rates(sband);
663667

664668
spin_lock(&ifibss->incomplete_lock);
665669
list_add(&sta->list, &ifibss->incomplete_stations);

‎net/mac80211/ieee80211_i.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,9 +1505,6 @@ static inline void ieee802_11_parse_elems(u8 *start, size_t len, bool action,
15051505
ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0);
15061506
}
15071507

1508-
u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
1509-
enum ieee80211_band band);
1510-
15111508
void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
15121509
void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
15131510
void ieee80211_dynamic_ps_timer(unsigned long data);

‎net/mac80211/mesh.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
741741
BSS_CHANGED_BASIC_RATES |
742742
BSS_CHANGED_BEACON_INT;
743743
enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
744+
struct ieee80211_supported_band *sband =
745+
sdata->local->hw.wiphy->bands[band];
744746

745747
local->fif_other_bss++;
746748
/* mesh ifaces must set allmulti to forward mcast traffic */
@@ -758,8 +760,7 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
758760
sdata->vif.bss_conf.ht_operation_mode =
759761
ifmsh->mshcfg.ht_opmode;
760762
sdata->vif.bss_conf.enable_beacon = true;
761-
sdata->vif.bss_conf.basic_rates =
762-
ieee80211_mandatory_rates(local, band);
763+
sdata->vif.bss_conf.basic_rates = ieee80211_mandatory_rates(sband);
763764

764765
changed |= ieee80211_mps_local_status_update(sdata);
765766

‎net/mac80211/util.c‎

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,32 +1072,6 @@ void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
10721072
ieee80211_set_wmm_default(sdata, true);
10731073
}
10741074

1075-
u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
1076-
enum ieee80211_band band)
1077-
{
1078-
struct ieee80211_supported_band *sband;
1079-
struct ieee80211_rate *bitrates;
1080-
u32 mandatory_rates;
1081-
enum ieee80211_rate_flags mandatory_flag;
1082-
int i;
1083-
1084-
sband = local->hw.wiphy->bands[band];
1085-
if (WARN_ON(!sband))
1086-
return 1;
1087-
1088-
if (band == IEEE80211_BAND_2GHZ)
1089-
mandatory_flag = IEEE80211_RATE_MANDATORY_B;
1090-
else
1091-
mandatory_flag = IEEE80211_RATE_MANDATORY_A;
1092-
1093-
bitrates = sband->bitrates;
1094-
mandatory_rates = 0;
1095-
for (i = 0; i < sband->n_bitrates; i++)
1096-
if (bitrates[i].flags & mandatory_flag)
1097-
mandatory_rates |= BIT(i);
1098-
return mandatory_rates;
1099-
}
1100-
11011075
void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
11021076
u16 transaction, u16 auth_alg, u16 status,
11031077
const u8 *extra, size_t extra_len, const u8 *da,

‎net/wireless/util.c‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,29 @@ ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
3333
}
3434
EXPORT_SYMBOL(ieee80211_get_response_rate);
3535

36+
u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband)
37+
{
38+
struct ieee80211_rate *bitrates;
39+
u32 mandatory_rates = 0;
40+
enum ieee80211_rate_flags mandatory_flag;
41+
int i;
42+
43+
if (WARN_ON(!sband))
44+
return 1;
45+
46+
if (sband->band == IEEE80211_BAND_2GHZ)
47+
mandatory_flag = IEEE80211_RATE_MANDATORY_B;
48+
else
49+
mandatory_flag = IEEE80211_RATE_MANDATORY_A;
50+
51+
bitrates = sband->bitrates;
52+
for (i = 0; i < sband->n_bitrates; i++)
53+
if (bitrates[i].flags & mandatory_flag)
54+
mandatory_rates |= BIT(i);
55+
return mandatory_rates;
56+
}
57+
EXPORT_SYMBOL(ieee80211_mandatory_rates);
58+
3659
int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band)
3760
{
3861
/* see 802.11 17.3.8.3.2 and Annex J

0 commit comments

Comments
 (0)