netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Wu <flamingice@sourmilk.net>
To: Jiri Benc <jbenc@suse.cz>
Cc: "John W. Linville" <linville@tuxdriver.com>,
	"Jouni Malinen" <jkm@devicescape.com>,
	netdev@vger.kernel.org, jkmaline@cc.hut.fi
Subject: Re: [PATCH wireless-dev] d80211: Don't discriminate against 802.11b drivers
Date: Fri, 12 May 2006 16:35:27 -0400	[thread overview]
Message-ID: <200605121635.27959.flamingice@sourmilk.net> (raw)
In-Reply-To: <20060512124703.563dacd6@griffin.suse.cz>

On Friday 12 May 2006 06:47, you wrote:
> > It seems like hw_modes is more useful for saying
> > what modes shouldn't be used than saying what modes are supported by the
> > hardware and should be used.
>
> This is exactly the purpose of hw_modes. This also means you don't need
> any validation.
>
Hm, so why not add something that will tell you what modes are supported by 
the hardware?

Only problem with this patch is if the hardware adds any modes after 
registration, they will be disabled initially. Hopefully, no drivers will 
actually need to do that.

Signed-off-by: Michael Wu <flamingice@sourmilk.net>

diff --git a/net/d80211/ieee80211.c b/net/d80211/ieee80211.c
index ffb7985..e110237 100644
--- a/net/d80211/ieee80211.c
+++ b/net/d80211/ieee80211.c
@@ -3999,19 +3999,24 @@ void ieee80211_if_setup(struct net_devic
 }
 
 
-static void ieee80211_precalc_rates(struct ieee80211_hw *hw)
+static void ieee80211_precalc_modes(struct ieee80211_hw *hw,
+				    struct ieee80211_local *local)
 {
 	struct ieee80211_hw_modes *mode;
 	struct ieee80211_rate *rate;
 	int m, r;
 
+	local->valid_hw_modes = 0;
 	for (m = 0; m < hw->num_modes; m++) {
 		mode = &hw->modes[m];
+		local->valid_hw_modes |= 1 << mode->mode;
 		for (r = 0; r < mode->num_rates; r++) {
 			rate = &mode->rates[r];
 			rate->rate_inv = CHAN_UTIL_RATE_LCM / rate->rate;
 		}
 	}
+
+	local->hw_modes &= local->valid_hw_modes;
 }
 
 
@@ -4257,7 +4262,7 @@ int ieee80211_update_hw(struct net_devic
 	    !hw->modes->num_channels || !hw->modes->num_rates)
 		return -1;
 
-	ieee80211_precalc_rates(hw);
+	ieee80211_precalc_modes(hw, local);
 	local->conf.phymode = hw->modes[0].mode;
 	local->curr_rates = hw->modes[0].rates;
 	local->num_curr_rates = hw->modes[0].num_rates;
diff --git a/net/d80211/ieee80211_i.h b/net/d80211/ieee80211_i.h
index ee0b399..6f33a75 100644
--- a/net/d80211/ieee80211_i.h
+++ b/net/d80211/ieee80211_i.h
@@ -409,7 +409,6 @@ #define IEEE80211_IRQSAFE_QUEUE_LIMIT 12
 	int scan_oper_antenna_max;
 	u8 scan_ssid[IEEE80211_MAX_SSID_LEN];
 	size_t scan_ssid_len;
-	int scan_skip_11b;
 	struct list_head sta_bss_list;
 	struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
 	spinlock_t sta_bss_lock;
@@ -500,6 +499,8 @@ #endif /* CONFIG_D80211_DEBUG_COUNTERS *
 	int wifi_wme_noack_test;
 	unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
 
+	unsigned int valid_hw_modes; /* bitfield of supported hardware modes;
+				      * (1 << MODE_*) */
 	unsigned int hw_modes; /* bitfield of allowed hardware modes;
 				* (1 << MODE_*) */
 };
diff --git a/net/d80211/ieee80211_ioctl.c b/net/d80211/ieee80211_ioctl.c
index 5d31a8f..89db144 100644
--- a/net/d80211/ieee80211_ioctl.c
+++ b/net/d80211/ieee80211_ioctl.c
@@ -2447,7 +2447,7 @@ static int ieee80211_ioctl_prism2_param(
 		break;
 
 	case PRISM2_PARAM_HW_MODES:
-		local->hw_modes = value;
+		local->hw_modes = value & local->valid_hw_modes;
 		break;
 
 	case PRISM2_PARAM_CREATE_IBSS:
diff --git a/net/d80211/ieee80211_sta.c b/net/d80211/ieee80211_sta.c
index 2720f1d..7955767 100644
--- a/net/d80211/ieee80211_sta.c
+++ b/net/d80211/ieee80211_sta.c
@@ -2468,7 +2468,7 @@ static void ieee80211_sta_scan_timer(uns
 		    (sdata->type == IEEE80211_IF_TYPE_IBSS &&
 		     !(chan->flag & IEEE80211_CHAN_W_IBSS)) ||
 		    (local->hw_modes & (1 << MODE_IEEE80211G) &&
-		     mode->mode == MODE_IEEE80211B && local->scan_skip_11b))
+		     mode->mode == MODE_IEEE80211B))
 			skip = 1;
 
 		if (!skip) {
@@ -2566,7 +2566,6 @@ int ieee80211_sta_req_scan(struct net_de
 		memcpy(local->scan_ssid, ssid, ssid_len);
 	} else
 		local->scan_ssid_len = 0;
-	local->scan_skip_11b = 1; /* FIX: clear this is 11g is not supported */
 	local->scan_state = SCAN_SET_CHANNEL;
 	local->scan_hw_mode_idx = 0;
 	local->scan_channel_idx = 0;

  reply	other threads:[~2006-05-12 20:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-05  2:32 [PATCH wireless-dev] d80211: Don't discriminate against 802.11b drivers Michael Wu
2006-05-11 15:54 ` Jiri Benc
2006-05-10 17:31   ` Michael Wu
2006-05-12 10:47     ` Jiri Benc
2006-05-12 20:35       ` Michael Wu [this message]
2006-05-15 11:37         ` Jiri Benc
2006-05-15 12:04           ` Johannes Berg
2006-05-15 13:35             ` Jiri Benc
2006-05-15 14:01               ` Michael Buesch
2006-05-15 14:12                 ` Jiri Benc
2006-05-15 17:19           ` Michael Wu
2006-05-19 18:06             ` John W. Linville
2006-05-19 19:03               ` Michael Wu
2006-05-19 19:22                 ` John W. Linville
2006-05-11 20:41   ` Michael Buesch

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=200605121635.27959.flamingice@sourmilk.net \
    --to=flamingice@sourmilk.net \
    --cc=jbenc@suse.cz \
    --cc=jkm@devicescape.com \
    --cc=jkmaline@cc.hut.fi \
    --cc=linville@tuxdriver.com \
    --cc=netdev@vger.kernel.org \
    /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).