aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2010-11-22 14:58:24 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-11-24 16:19:35 -0500
commitdd5b4cc71cd09c33e1579cc6d5720656e94e52de (patch)
tree86a27c86480109d9b6bbedddc083095035fbef2d
parent46090979a55a0dc2cdb3d939f94fa47742108194 (diff)
cfg80211/mac80211: improve ad-hoc multicast rate handling
- store the multicast rate as an index instead of the rate value (reduces cpu overhead in a hotpath) - validate the rate values (must match a bitrate in at least one sband) Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--include/net/cfg80211.h4
-rw-r--r--include/net/mac80211.h4
-rw-r--r--net/mac80211/ibss.c3
-rw-r--r--net/mac80211/rate.c25
-rw-r--r--net/wireless/nl80211.c36
5 files changed, 51 insertions, 21 deletions
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 91f099556ac..dd4c43f512e 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -923,7 +923,7 @@ struct cfg80211_disassoc_request {
923 * @privacy: this is a protected network, keys will be configured 923 * @privacy: this is a protected network, keys will be configured
924 * after joining 924 * after joining
925 * @basic_rates: bitmap of basic rates to use when creating the IBSS 925 * @basic_rates: bitmap of basic rates to use when creating the IBSS
926 * @mcast_rate: multicast tx rate (in 100 kbps) 926 * @mcast_rate: per-band multicast rate index + 1 (0: disabled)
927 */ 927 */
928struct cfg80211_ibss_params { 928struct cfg80211_ibss_params {
929 u8 *ssid; 929 u8 *ssid;
@@ -935,7 +935,7 @@ struct cfg80211_ibss_params {
935 u32 basic_rates; 935 u32 basic_rates;
936 bool channel_fixed; 936 bool channel_fixed;
937 bool privacy; 937 bool privacy;
938 int mcast_rate; 938 int mcast_rate[IEEE80211_NUM_BANDS];
939}; 939};
940 940
941/** 941/**
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 5b0fff2178b..08e97e5d03f 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -219,7 +219,7 @@ enum ieee80211_bss_change {
219 * @basic_rates: bitmap of basic rates, each bit stands for an 219 * @basic_rates: bitmap of basic rates, each bit stands for an
220 * index into the rate table configured by the driver in 220 * index into the rate table configured by the driver in
221 * the current band. 221 * the current band.
222 * @mcast_rate: multicast rate for AP and Ad-Hoc (in 100 kbps) 222 * @mcast_rate: per-band multicast rate index + 1 (0: disabled)
223 * @bssid: The BSSID for this BSS 223 * @bssid: The BSSID for this BSS
224 * @enable_beacon: whether beaconing should be enabled or not 224 * @enable_beacon: whether beaconing should be enabled or not
225 * @channel_type: Channel type for this BSS -- the hardware might be 225 * @channel_type: Channel type for this BSS -- the hardware might be
@@ -259,7 +259,7 @@ struct ieee80211_bss_conf {
259 u16 assoc_capability; 259 u16 assoc_capability;
260 u64 timestamp; 260 u64 timestamp;
261 u32 basic_rates; 261 u32 basic_rates;
262 u32 mcast_rate; 262 int mcast_rate[IEEE80211_NUM_BANDS];
263 u16 ht_operation_mode; 263 u16 ht_operation_mode;
264 s32 cqm_rssi_thold; 264 s32 cqm_rssi_thold;
265 u32 cqm_rssi_hyst; 265 u32 cqm_rssi_hyst;
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 6fe6837dc13..410d104b134 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -915,7 +915,8 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
915 915
916 sdata->u.ibss.privacy = params->privacy; 916 sdata->u.ibss.privacy = params->privacy;
917 sdata->u.ibss.basic_rates = params->basic_rates; 917 sdata->u.ibss.basic_rates = params->basic_rates;
918 sdata->vif.bss_conf.mcast_rate = params->mcast_rate; 918 memcpy(sdata->vif.bss_conf.mcast_rate, params->mcast_rate,
919 sizeof(params->mcast_rate));
919 920
920 sdata->vif.bss_conf.beacon_int = params->beacon_interval; 921 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
921 922
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 76de4f8d932..3d5a2cb835c 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -211,20 +211,11 @@ static bool rc_no_data_or_no_ack(struct ieee80211_tx_rate_control *txrc)
211 return (info->flags & IEEE80211_TX_CTL_NO_ACK) || !ieee80211_is_data(fc); 211 return (info->flags & IEEE80211_TX_CTL_NO_ACK) || !ieee80211_is_data(fc);
212} 212}
213 213
214static void rc_send_low_broadcast(s8 *idx, u32 basic_rates, u32 mcast_rate, 214static void rc_send_low_broadcast(s8 *idx, u32 basic_rates,
215 struct ieee80211_supported_band *sband) 215 struct ieee80211_supported_band *sband)
216{ 216{
217 u8 i; 217 u8 i;
218 218
219 if (mcast_rate) {
220 for (i = 0; i < sband->n_bitrates; i++) {
221 if (sband->bitrates[i].bitrate == mcast_rate) {
222 *idx = i;
223 return;
224 }
225 }
226 }
227
228 if (basic_rates == 0) 219 if (basic_rates == 0)
229 return; /* assume basic rates unknown and accept rate */ 220 return; /* assume basic rates unknown and accept rate */
230 if (*idx < 0) 221 if (*idx < 0)
@@ -247,17 +238,25 @@ bool rate_control_send_low(struct ieee80211_sta *sta,
247 struct ieee80211_tx_rate_control *txrc) 238 struct ieee80211_tx_rate_control *txrc)
248{ 239{
249 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb); 240 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
241 struct ieee80211_supported_band *sband = txrc->sband;
242 int mcast_rate;
250 243
251 if (!sta || !priv_sta || rc_no_data_or_no_ack(txrc)) { 244 if (!sta || !priv_sta || rc_no_data_or_no_ack(txrc)) {
252 info->control.rates[0].idx = rate_lowest_index(txrc->sband, sta); 245 info->control.rates[0].idx = rate_lowest_index(txrc->sband, sta);
253 info->control.rates[0].count = 246 info->control.rates[0].count =
254 (info->flags & IEEE80211_TX_CTL_NO_ACK) ? 247 (info->flags & IEEE80211_TX_CTL_NO_ACK) ?
255 1 : txrc->hw->max_rate_tries; 248 1 : txrc->hw->max_rate_tries;
256 if (!sta && txrc->bss) 249 if (!sta && txrc->bss) {
250 mcast_rate = txrc->bss_conf->mcast_rate[sband->band];
251 if (mcast_rate > 0) {
252 info->control.rates[0].idx = mcast_rate - 1;
253 return true;
254 }
255
257 rc_send_low_broadcast(&info->control.rates[0].idx, 256 rc_send_low_broadcast(&info->control.rates[0].idx,
258 txrc->bss_conf->basic_rates, 257 txrc->bss_conf->basic_rates,
259 txrc->bss_conf->mcast_rate, 258 sband);
260 txrc->sband); 259 }
261 return true; 260 return true;
262 } 261 }
263 return false; 262 return false;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index b15eb77195d..8734efa663d 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3600,6 +3600,34 @@ static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info)
3600 local_state_change); 3600 local_state_change);
3601} 3601}
3602 3602
3603static bool
3604nl80211_parse_mcast_rate(struct cfg80211_registered_device *rdev,
3605 int mcast_rate[IEEE80211_NUM_BANDS],
3606 int rateval)
3607{
3608 struct wiphy *wiphy = &rdev->wiphy;
3609 bool found = false;
3610 int band, i;
3611
3612 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
3613 struct ieee80211_supported_band *sband;
3614
3615 sband = wiphy->bands[band];
3616 if (!sband)
3617 continue;
3618
3619 for (i = 0; i < sband->n_bitrates; i++) {
3620 if (sband->bitrates[i].bitrate == rateval) {
3621 mcast_rate[band] = i + 1;
3622 found = true;
3623 break;
3624 }
3625 }
3626 }
3627
3628 return found;
3629}
3630
3603static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) 3631static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
3604{ 3632{
3605 struct cfg80211_registered_device *rdev = info->user_ptr[0]; 3633 struct cfg80211_registered_device *rdev = info->user_ptr[0];
@@ -3683,9 +3711,11 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
3683 return -EINVAL; 3711 return -EINVAL;
3684 } 3712 }
3685 } 3713 }
3686 if (info->attrs[NL80211_ATTR_MCAST_RATE]) 3714
3687 ibss.mcast_rate = 3715 if (info->attrs[NL80211_ATTR_MCAST_RATE] &&
3688 nla_get_u32(info->attrs[NL80211_ATTR_MCAST_RATE]); 3716 !nl80211_parse_mcast_rate(rdev, ibss.mcast_rate,
3717 nla_get_u32(info->attrs[NL80211_ATTR_MCAST_RATE])))
3718 return -EINVAL;
3689 3719
3690 if (ibss.privacy && info->attrs[NL80211_ATTR_KEYS]) { 3720 if (ibss.privacy && info->attrs[NL80211_ATTR_KEYS]) {
3691 connkeys = nl80211_parse_connkeys(rdev, 3721 connkeys = nl80211_parse_connkeys(rdev,