aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAshok Nagarajan <ashok@cozybit.com>2013-05-10 20:50:51 -0400
committerJohannes Berg <johannes.berg@intel.com>2013-05-24 17:54:43 -0400
commitb422c6cd7e93bb613030f14d7d8a0cc73f115629 (patch)
treed27418a219e0c4809bee0e73c5117da8095ad01a
parentd4a5a48976d12ab340ed34605b5f5049b123d868 (diff)
{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>
-rw-r--r--include/net/cfg80211.h9
-rw-r--r--net/mac80211/ibss.c10
-rw-r--r--net/mac80211/ieee80211_i.h3
-rw-r--r--net/mac80211/mesh.c5
-rw-r--r--net/mac80211/util.c26
-rw-r--r--net/wireless/util.c23
6 files changed, 42 insertions, 34 deletions
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 32a2f1b20861..58f6302da145 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3005,6 +3005,15 @@ struct ieee80211_rate *
3005ieee80211_get_response_rate(struct ieee80211_supported_band *sband, 3005ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
3006 u32 basic_rates, int bitrate); 3006 u32 basic_rates, int bitrate);
3007 3007
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 */
3015u32 ieee80211_mandatory_rates(struct ieee80211_supported_band *sband);
3016
3008/* 3017/*
3009 * Radiotap parsing functions -- for controlled injection support 3018 * Radiotap parsing functions -- for controlled injection support
3010 * 3019 *
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 170f9a7fa319..956ba6316da5 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -341,6 +341,7 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
341 struct ieee80211_local *local = sdata->local; 341 struct ieee80211_local *local = sdata->local;
342 struct sta_info *sta; 342 struct sta_info *sta;
343 struct ieee80211_chanctx_conf *chanctx_conf; 343 struct ieee80211_chanctx_conf *chanctx_conf;
344 struct ieee80211_supported_band *sband;
344 int band; 345 int band;
345 346
346 /* 347 /*
@@ -380,8 +381,9 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
380 sta->last_rx = jiffies; 381 sta->last_rx = jiffies;
381 382
382 /* make sure mandatory rates are always added */ 383 /* make sure mandatory rates are always added */
384 sband = local->hw.wiphy->bands[band];
383 sta->sta.supp_rates[band] = supp_rates | 385 sta->sta.supp_rates[band] = supp_rates |
384 ieee80211_mandatory_rates(local, band); 386 ieee80211_mandatory_rates(sband);
385 387
386 return ieee80211_ibss_finish_sta(sta, auth); 388 return ieee80211_ibss_finish_sta(sta, auth);
387} 389}
@@ -492,7 +494,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
492 prev_rates = sta->sta.supp_rates[band]; 494 prev_rates = sta->sta.supp_rates[band];
493 /* make sure mandatory rates are always added */ 495 /* make sure mandatory rates are always added */
494 sta->sta.supp_rates[band] = supp_rates | 496 sta->sta.supp_rates[band] = supp_rates |
495 ieee80211_mandatory_rates(local, band); 497 ieee80211_mandatory_rates(sband);
496 498
497 if (sta->sta.supp_rates[band] != prev_rates) { 499 if (sta->sta.supp_rates[band] != prev_rates) {
498 ibss_dbg(sdata, 500 ibss_dbg(sdata,
@@ -624,6 +626,7 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
624 struct ieee80211_local *local = sdata->local; 626 struct ieee80211_local *local = sdata->local;
625 struct sta_info *sta; 627 struct sta_info *sta;
626 struct ieee80211_chanctx_conf *chanctx_conf; 628 struct ieee80211_chanctx_conf *chanctx_conf;
629 struct ieee80211_supported_band *sband;
627 int band; 630 int band;
628 631
629 /* 632 /*
@@ -658,8 +661,9 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
658 sta->last_rx = jiffies; 661 sta->last_rx = jiffies;
659 662
660 /* make sure mandatory rates are always added */ 663 /* make sure mandatory rates are always added */
664 sband = local->hw.wiphy->bands[band];
661 sta->sta.supp_rates[band] = supp_rates | 665 sta->sta.supp_rates[band] = supp_rates |
662 ieee80211_mandatory_rates(local, band); 666 ieee80211_mandatory_rates(sband);
663 667
664 spin_lock(&ifibss->incomplete_lock); 668 spin_lock(&ifibss->incomplete_lock);
665 list_add(&sta->list, &ifibss->incomplete_stations); 669 list_add(&sta->list, &ifibss->incomplete_stations);
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 158e6eb188d3..b7cbd4ebf0e0 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1505,9 +1505,6 @@ static inline void ieee802_11_parse_elems(u8 *start, size_t len, bool action,
1505 ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0); 1505 ieee802_11_parse_elems_crc(start, len, action, elems, 0, 0);
1506} 1506}
1507 1507
1508u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
1509 enum ieee80211_band band);
1510
1511void ieee80211_dynamic_ps_enable_work(struct work_struct *work); 1508void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
1512void ieee80211_dynamic_ps_disable_work(struct work_struct *work); 1509void ieee80211_dynamic_ps_disable_work(struct work_struct *work);
1513void ieee80211_dynamic_ps_timer(unsigned long data); 1510void ieee80211_dynamic_ps_timer(unsigned long data);
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index c13db9ad394b..c14bb816c6a3 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -741,6 +741,8 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
741 BSS_CHANGED_BASIC_RATES | 741 BSS_CHANGED_BASIC_RATES |
742 BSS_CHANGED_BEACON_INT; 742 BSS_CHANGED_BEACON_INT;
743 enum ieee80211_band band = ieee80211_get_sdata_band(sdata); 743 enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
744 struct ieee80211_supported_band *sband =
745 sdata->local->hw.wiphy->bands[band];
744 746
745 local->fif_other_bss++; 747 local->fif_other_bss++;
746 /* mesh ifaces must set allmulti to forward mcast traffic */ 748 /* mesh ifaces must set allmulti to forward mcast traffic */
@@ -758,8 +760,7 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
758 sdata->vif.bss_conf.ht_operation_mode = 760 sdata->vif.bss_conf.ht_operation_mode =
759 ifmsh->mshcfg.ht_opmode; 761 ifmsh->mshcfg.ht_opmode;
760 sdata->vif.bss_conf.enable_beacon = true; 762 sdata->vif.bss_conf.enable_beacon = true;
761 sdata->vif.bss_conf.basic_rates = 763 sdata->vif.bss_conf.basic_rates = ieee80211_mandatory_rates(sband);
762 ieee80211_mandatory_rates(local, band);
763 764
764 changed |= ieee80211_mps_local_status_update(sdata); 765 changed |= ieee80211_mps_local_status_update(sdata);
765 766
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 3f87fa468b1f..707953fd8324 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1072,32 +1072,6 @@ void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
1072 ieee80211_set_wmm_default(sdata, true); 1072 ieee80211_set_wmm_default(sdata, true);
1073} 1073}
1074 1074
1075u32 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
1101void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, 1075void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
1102 u16 transaction, u16 auth_alg, u16 status, 1076 u16 transaction, u16 auth_alg, u16 status,
1103 const u8 *extra, size_t extra_len, const u8 *da, 1077 const u8 *extra, size_t extra_len, const u8 *da,
diff --git a/net/wireless/util.c b/net/wireless/util.c
index b11052be09be..0962f107f57f 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -33,6 +33,29 @@ ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
33} 33}
34EXPORT_SYMBOL(ieee80211_get_response_rate); 34EXPORT_SYMBOL(ieee80211_get_response_rate);
35 35
36u32 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}
57EXPORT_SYMBOL(ieee80211_mandatory_rates);
58
36int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band) 59int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band)
37{ 60{
38 /* see 802.11 17.3.8.3.2 and Annex J 61 /* see 802.11 17.3.8.3.2 and Annex J