2011-08-20 11:54:09

by Rajkumar Manoharan

[permalink] [raw]
Subject: [RFC] mac80211: Mark mandatory rates as basic

Currently mac80211 announces a supported rate set with
no basic rates. This patch marks the mandatory rates as
basic while constructing supported rate element.

Signed-off-by: Rajkumar Manoharan <[email protected]>
---
include/net/cfg80211.h | 3 +++
net/mac80211/mesh.c | 5 ++++-
net/mac80211/util.c | 6 +++++-
net/mac80211/work.c | 6 +++++-
4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index d86a15d..bb9000a 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -167,6 +167,9 @@ enum ieee80211_rate_flags {
IEEE80211_RATE_ERP_G = 1<<4,
};

+#define IEEE80211_ALL_MANDATORY_RATES \
+ (IEEE80211_RATE_MANDATORY_A | IEEE80211_RATE_MANDATORY_B | \
+ IEEE80211_RATE_MANDATORY_G)
/**
* struct ieee80211_rate - bitrate definition
*
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 29e9980..9b429dd 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -221,7 +221,10 @@ void mesh_mgmt_ies_add(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata)
*pos++ = len;
for (i = 0; i < len; i++) {
rate = sband->bitrates[i].bitrate;
- *pos++ = (u8) (rate / 5);
+ *pos = (u8) (rate / 5);
+ if (sband->bitrates[i].flags & IEEE80211_ALL_MANDATORY_RATES)
+ *pos |= 0x80;
+ pos++;
}

if (sband->n_bitrates > len) {
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index ce916ff..8b32b57 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -758,7 +758,11 @@ int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
for (i = 0; i < sband->n_bitrates; i++) {
if ((BIT(i) & rate_mask) == 0)
continue; /* skip rate */
- rates[num_rates++] = (u8) (sband->bitrates[i].bitrate / 5);
+ rates[num_rates] = (u8) (sband->bitrates[i].bitrate / 5);
+ /* Mark as basic rates */
+ if (sband->bitrates[i].flags & IEEE80211_ALL_MANDATORY_RATES)
+ rates[num_rates] |= 0x80;
+ num_rates++;
}

supp_rates_len = min_t(int, num_rates, 8);
diff --git a/net/mac80211/work.c b/net/mac80211/work.c
index 380b9a7..8647201 100644
--- a/net/mac80211/work.c
+++ b/net/mac80211/work.c
@@ -295,7 +295,11 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
for (i = 0; i < sband->n_bitrates; i++) {
if (BIT(i) & rates) {
int rate = sband->bitrates[i].bitrate;
- *pos++ = (u8) (rate / 5);
+ *pos = (u8) (rate / 5);
+ if (sband->bitrates[i].flags &
+ IEEE80211_ALL_MANDATORY_RATES)
+ *pos |= 0x80;
+ pos++;
if (++count == 8)
break;
}
--
1.7.6



2011-08-20 15:06:24

by Jouni Malinen

[permalink] [raw]
Subject: Re: [RFC] mac80211: Mark mandatory rates as basic

On Sat, Aug 20, 2011 at 05:24:35PM +0530, Rajkumar Manoharan wrote:
> Currently mac80211 announces a supported rate set with
> no basic rates. This patch marks the mandatory rates as
> basic while constructing supported rate element.

Why would you want to do that? I did not check the mesh use case but
neither Probe Request nor (Re)Association Request frames use the 0x80
flag in the rates - the basic rate set comes from the AP, not the non-AP
STA.. For mesh, I think that only Mesh Peering Open and Mesh Peering
Confirm frames indicate basic rate set, so the first patch of the patch
may or may not be correct depending on whether it applies only to those
frames.

--
Jouni Malinen PGP id EFC895FA