linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Juuso Oikarinen <juuso.oikarinen@nokia.com>
Cc: "linville@tuxdriver.com" <linville@tuxdriver.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: Re: [PATCHv2] mac80211: Fix basic rates for created IBSS networks
Date: Wed, 26 May 2010 16:14:36 +0200	[thread overview]
Message-ID: <1274883276.3658.15.camel@jlt3.sipsolutions.net> (raw)
In-Reply-To: <1274879624.5277.1917.camel@wimaxnb.nmp.nokia.com>

TBD

Needs to be split up (setting bss_conf and the bss_change flag is a
separate bugfix) and tested but this is what I think it should be like.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
 include/net/cfg80211.h     |    2 +
 net/mac80211/ibss.c        |    5 +++-
 net/mac80211/ieee80211_i.h |    2 +
 net/wireless/nl80211.c     |   47 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 55 insertions(+), 1 deletion(-)

--- wireless-testing.orig/include/net/cfg80211.h	2010-05-26 15:43:20.000000000 +0200
+++ wireless-testing/include/net/cfg80211.h	2010-05-26 15:43:54.000000000 +0200
@@ -801,6 +801,7 @@ struct cfg80211_disassoc_request {
  * @beacon_interval: beacon interval to use
  * @privacy: this is a protected network, keys will be configured
  *	after joining
+ * @basic_rates: bitmap of basic rates to use when creating the IBSS
  */
 struct cfg80211_ibss_params {
 	u8 *ssid;
@@ -809,6 +810,7 @@ struct cfg80211_ibss_params {
 	u8 *ie;
 	u8 ssid_len, ie_len;
 	u16 beacon_interval;
+	u32 basic_rates;
 	bool channel_fixed;
 	bool privacy;
 };
--- wireless-testing.orig/net/wireless/nl80211.c	2010-05-26 15:46:01.000000000 +0200
+++ wireless-testing/net/wireless/nl80211.c	2010-05-26 16:08:28.000000000 +0200
@@ -3955,6 +3955,53 @@ static int nl80211_join_ibss(struct sk_b
 		}
 	}
 
+	if (info->attrs[NL80211_ATTR_BSS_BASIC_RATES]) {
+		u8 *rates = nla_data(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);
+		int n_rates = nla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);
+		struct ieee80211_supported_band *sband =
+			wiphy->bands[ibss.channel->band];
+		int i, j;
+
+		if (n_rates == 0) {
+			err = -EINVAL;
+			goto out;
+		}
+
+		for (i = 0; i < n_rates; i++) {
+			int rate = (rates[i] & 0x7f) * 5;
+			bool found = false;
+
+			for (j = 0; j < sband->n_bitrates; j++) {
+				if (sband->bitrates[j].bitrate == rate) {
+					found = true;
+					ibss.basic_rates |= j;
+					break;
+				}
+			}
+			if (!found) {
+				err = -EINVAL;
+				goto out;
+			}
+		}
+	} else {
+		/*
+		 * If no rates were explicitly configured,
+		 * use the mandatory rate set for 11b or
+		 * 11a for maximum compatibility.
+		 */
+		struct ieee80211_supported_band *sband =
+			wiphy->bands[ibss.channel->band];
+		int j;
+		u32 flag = ibss.channel->band == IEEE80211_BAND_5GHZ ?
+				IEEE80211_RATE_MANDATORY_A :
+				IEEE80211_RATE_MANDATORY_B;
+
+		for (j = 0; j < sband->n_bitrates; j++) {
+			if (sband->bitrates[j].flags & flag)
+				ibss.basic_rates |= j;
+		}
+	}
+
 	err = cfg80211_join_ibss(rdev, dev, &ibss, connkeys);
 
 out:
--- wireless-testing.orig/net/mac80211/ibss.c	2010-05-26 16:09:11.000000000 +0200
+++ wireless-testing/net/mac80211/ibss.c	2010-05-26 16:12:32.000000000 +0200
@@ -172,11 +172,13 @@ static void __ieee80211_sta_join_ibss(st
 	rcu_assign_pointer(ifibss->presp, skb);
 
 	sdata->vif.bss_conf.beacon_int = beacon_int;
+	sdata->vif.bss_conf.basic_rates = basic_rates;
 	bss_change = BSS_CHANGED_BEACON_INT;
 	bss_change |= ieee80211_reset_erp_info(sdata);
 	bss_change |= BSS_CHANGED_BSSID;
 	bss_change |= BSS_CHANGED_BEACON;
 	bss_change |= BSS_CHANGED_BEACON_ENABLED;
+	bss_change |= BSS_CHANGED_BASIC_RATES;
 	bss_change |= BSS_CHANGED_IBSS;
 	sdata->vif.bss_conf.ibss_joined = true;
 	ieee80211_bss_info_change_notify(sdata, bss_change);
@@ -529,7 +531,7 @@ static void ieee80211_sta_create_ibss(st
 		sdata->drop_unencrypted = 0;
 
 	__ieee80211_sta_join_ibss(sdata, bssid, sdata->vif.bss_conf.beacon_int,
-				  ifibss->channel, 3, /* first two are basic */
+				  ifibss->channel, ifibss->basic_rates,
 				  capability, 0);
 }
 
@@ -910,6 +912,7 @@ int ieee80211_ibss_join(struct ieee80211
 		sdata->u.ibss.fixed_bssid = false;
 
 	sdata->u.ibss.privacy = params->privacy;
+	sdata->u.ibss.basic_rates = params->basic_rates;
 
 	sdata->vif.bss_conf.beacon_int = params->beacon_interval;
 
--- wireless-testing.orig/net/mac80211/ieee80211_i.h	2010-05-26 16:11:51.000000000 +0200
+++ wireless-testing/net/mac80211/ieee80211_i.h	2010-05-26 16:12:02.000000000 +0200
@@ -393,6 +393,8 @@ struct ieee80211_if_ibss {
 	unsigned long request;
 	unsigned long last_scan_completed;
 
+	u32 basic_rates;
+
 	bool timer_running;
 
 	bool fixed_bssid;



  parent reply	other threads:[~2010-05-26 14:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-26 12:48 [PATCHv2] mac80211: Fix basic rates for created IBSS networks Juuso Oikarinen
2010-05-26 12:53 ` Johannes Berg
2010-05-26 13:13   ` Juuso Oikarinen
2010-05-26 13:27     ` Johannes Berg
2010-05-27  4:50       ` Juuso Oikarinen
2010-05-26 14:14     ` Johannes Berg [this message]
2010-05-27  0:41       ` Bruno Randolf
2010-05-27  8:12         ` Johannes Berg
2010-05-27  0:45       ` [PATCH] mac80211: mark 1, 2, 5.5 and 11Mbps as mandatory rates for 802.11b Bruno Randolf
2010-05-27  6:02         ` [ath5k-devel] " Benoit Papillault
2010-05-27  8:08         ` Johannes Berg
2010-05-27  8:11           ` Johannes Berg
2010-05-27 12:09           ` Benoit Papillault
2010-05-27 12:13             ` Johannes Berg
2010-05-27  5:06       ` [PATCHv2] mac80211: Fix basic rates for created IBSS networks Juuso Oikarinen
2010-05-27  8:11         ` Johannes Berg
2010-05-27  8:28           ` Juuso Oikarinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1274883276.3658.15.camel@jlt3.sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=juuso.oikarinen@nokia.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).