2012-06-08 02:21:35

by Ashok Nagarajan

[permalink] [raw]
Subject: [PATCH 1/3] mac80211: return correct mandatory rates when operating in 2.4GHz band

Currently, the function ieee80211_mandatory_rates() doesn't get 802.11g
mandatory rates. This patch will make the function to return correct mandatory
rates when operating in 2.4GHz band.

Signed-off-by: Ashok Nagarajan <[email protected]>
---
net/mac80211/ibss.c | 6 +++---
net/mac80211/ieee80211_i.h | 2 +-
net/mac80211/iface.c | 2 +-
net/mac80211/util.c | 8 ++++++--
4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 725cb4b..d3d891d 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -330,7 +330,7 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,

/* make sure mandatory rates are always added */
sta->sta.supp_rates[band] = supp_rates |
- ieee80211_mandatory_rates(local, band);
+ ieee80211_mandatory_rates(sdata, band);

return ieee80211_ibss_finish_sta(sta, auth);
}
@@ -413,7 +413,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
prev_rates = sta->sta.supp_rates[band];
/* make sure mandatory rates are always added */
sta->sta.supp_rates[band] = supp_rates |
- ieee80211_mandatory_rates(local, band);
+ ieee80211_mandatory_rates(sdata, band);

if (sta->sta.supp_rates[band] != prev_rates) {
ibss_vdbg("%s: updated supp_rates set for %pM based on beacon/probe_resp (0x%x -> 0x%x)\n",
@@ -588,7 +588,7 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,

/* make sure mandatory rates are always added */
sta->sta.supp_rates[band] = supp_rates |
- ieee80211_mandatory_rates(local, band);
+ ieee80211_mandatory_rates(sdata, band);

spin_lock(&ifibss->incomplete_lock);
list_add(&sta->list, &ifibss->incomplete_stations);
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index e6cbf5b..7af7c25 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1399,7 +1399,7 @@ void ieee802_11_parse_elems(u8 *start, size_t len,
u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
struct ieee802_11_elems *elems,
u64 filter, u32 crc);
-u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
+u32 ieee80211_mandatory_rates(struct ieee80211_sub_if_data *sdata,
enum ieee80211_band band);

void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 87aeb4f..994e459 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1147,7 +1147,7 @@ int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,

/* reset some values that shouldn't be kept across type changes */
sdata->vif.bss_conf.basic_rates =
- ieee80211_mandatory_rates(sdata->local,
+ ieee80211_mandatory_rates(sdata,
sdata->local->hw.conf.channel->band);
sdata->drop_unencrypted = 0;
if (type == NL80211_IFTYPE_STATION)
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 1df4019..974e022 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -911,9 +911,10 @@ void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata,
ieee80211_set_wmm_default(sdata, true);
}

-u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
+u32 ieee80211_mandatory_rates(struct ieee80211_sub_if_data *sdata,
enum ieee80211_band band)
{
+ struct ieee80211_local *local = sdata->local;
struct ieee80211_supported_band *sband;
struct ieee80211_rate *bitrates;
u32 mandatory_rates;
@@ -924,7 +925,10 @@ u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
if (WARN_ON(!sband))
return 1;

- if (band == IEEE80211_BAND_2GHZ)
+ if (band == IEEE80211_BAND_2GHZ &&
+ sdata->flags & IEEE80211_SDATA_OPERATING_GMODE)
+ mandatory_flag = IEEE80211_RATE_MANDATORY_G;
+ else if (band == IEEE80211_BAND_2GHZ)
mandatory_flag = IEEE80211_RATE_MANDATORY_B;
else
mandatory_flag = IEEE80211_RATE_MANDATORY_A;
--
1.7.5.4



2012-06-08 02:21:35

by Ashok Nagarajan

[permalink] [raw]
Subject: [PATCH 2/3] mac80211: set IEEE80211_SDATA_OPERATING_GMODE in mesh if operating in G band

Signed-off-by: Ashok Nagarajan <[email protected]>
---
net/mac80211/mesh.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 7cf1950..2b814d5 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -581,6 +581,19 @@ void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
{
struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
struct ieee80211_local *local = sdata->local;
+ struct ieee80211_supported_band *sband;
+ struct ieee80211_rate *bitrates;
+ enum ieee80211_band band = local->hw.conf.channel->band;
+ int i;
+
+ sband = local->hw.wiphy->bands[band];
+ bitrates = sband->bitrates;
+ for (i = 0; i < sband->n_bitrates; i++)
+ if (band == IEEE80211_BAND_2GHZ &&
+ bitrates[i].bitrate > 110) {
+ sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE;
+ break;
+ }

local->fif_other_bss++;
/* mesh ifaces must set allmulti to forward mcast traffic */
--
1.7.5.4


2012-06-08 02:21:37

by Ashok Nagarajan

[permalink] [raw]
Subject: [PATCH 3/3] [nl,cfg,mac]80211: Allow user to configure basic rates when joining

Currently mesh uses mandatory rates as default basic rates. This patch
introduces basic rates to be configured at the time of joining mesh.

Signed-off-by: Ashok Nagarajan <[email protected]>
---
include/net/cfg80211.h | 1 +
net/mac80211/cfg.c | 2 ++
net/mac80211/mesh.c | 6 +++---
net/wireless/nl80211.c | 17 +++++++++++++++++
4 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 7319f25..4b65b1f 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -859,6 +859,7 @@ struct mesh_setup {
bool is_authenticated;
bool is_secure;
int mcast_rate[IEEE80211_NUM_BANDS];
+ u32 basic_rates;
};

/**
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 498c94e..6348a6c 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1499,6 +1499,8 @@ static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
/* mcast rate setting in Mesh Node */
memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
sizeof(setup->mcast_rate));
+ if (setup->basic_rates)
+ sdata->vif.bss_conf.basic_rates = setup->basic_rates;

return 0;
}
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 2b814d5..f72c67d 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -612,9 +612,9 @@ void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
sdata->vif.bss_conf.ht_operation_mode =
ifmsh->mshcfg.ht_opmode;
sdata->vif.bss_conf.beacon_int = MESH_DEFAULT_BEACON_INTERVAL;
- sdata->vif.bss_conf.basic_rates =
- ieee80211_mandatory_rates(sdata->local,
- sdata->local->hw.conf.channel->band);
+ if (!sdata->vif.bss_conf.basic_rates)
+ sdata->vif.bss_conf.basic_rates =
+ ieee80211_mandatory_rates(sdata, band);
ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON |
BSS_CHANGED_BEACON_ENABLED |
BSS_CHANGED_HT |
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 7ae54b8..29d3723 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -6063,6 +6063,9 @@ static int nl80211_join_mesh(struct sk_buff *skb, struct genl_info *info)
{
struct cfg80211_registered_device *rdev = info->user_ptr[0];
struct net_device *dev = info->user_ptr[1];
+ struct wireless_dev *wdev = dev->ieee80211_ptr;
+ struct wiphy *wiphy = &rdev->wiphy;
+ struct ieee80211_supported_band *sband;
struct mesh_config cfg;
struct mesh_setup setup;
int err;
@@ -6085,6 +6088,20 @@ static int nl80211_join_mesh(struct sk_buff *skb, struct genl_info *info)
setup.mesh_id = nla_data(info->attrs[NL80211_ATTR_MESH_ID]);
setup.mesh_id_len = nla_len(info->attrs[NL80211_ATTR_MESH_ID]);

+ if (info->attrs[NL80211_ATTR_BSS_BASIC_RATES] &&
+ !WARN_ON(!wdev->preset_chan)) {
+ u8 *rates =
+ nla_data(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);
+ int n_rates =
+ nla_len(info->attrs[NL80211_ATTR_BSS_BASIC_RATES]);
+ sband = wiphy->bands[wdev->preset_chan->band];
+
+ err = ieee80211_get_ratemask(sband, rates, n_rates,
+ &setup.basic_rates);
+ if (err)
+ return err;
+ }
+
if (info->attrs[NL80211_ATTR_MCAST_RATE] &&
!nl80211_parse_mcast_rate(rdev, setup.mcast_rate,
nla_get_u32(info->attrs[NL80211_ATTR_MCAST_RATE])))
--
1.7.5.4


2012-06-12 19:35:11

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 3/3] [nl,cfg,mac]80211: Allow user to configure basic rates when joining

On Tue, 2012-06-12 at 12:33 -0700, Ashok Nagarajan wrote:
> Hello Johannes,
>
> On Sat, Jun 9, 2012 at 1:50 AM, Johannes Berg <[email protected]> wrote:
> > On Thu, 2012-06-07 at 19:21 -0700, Ashok Nagarajan wrote:
> >> Currently mesh uses mandatory rates as default basic rates. This patch
> >> introduces basic rates to be configured at the time of joining mesh.
> >
> >> + if (!sdata->vif.bss_conf.basic_rates)
> >> + sdata->vif.bss_conf.basic_rates =
> >> + ieee80211_mandatory_rates(sdata, band);
> >
> > I think this default should come from cfg80211 instead, there's little
> > point in imposing this calculation on all drivers that want to use mesh.
> >
>
> This default initialization uses the mac80211 utility function which
> will not be accessible from cfg80211.

cfg80211 has the same data though, the function only uses channel flags.

> Could you please explain what is
> the advantage/purpose of imposing this calculation up in cfg80211.

If there are ever non-mac80211 drivers using it they don't have to re-do
the same calculations.

johannes


2012-06-12 19:33:30

by Ashok Nagarajan

[permalink] [raw]
Subject: Re: [PATCH 3/3] [nl,cfg,mac]80211: Allow user to configure basic rates when joining

Hello Johannes,

On Sat, Jun 9, 2012 at 1:50 AM, Johannes Berg <[email protected]> wrote:
> On Thu, 2012-06-07 at 19:21 -0700, Ashok Nagarajan wrote:
>> Currently mesh uses mandatory rates as default basic rates. This patch
>> introduces basic rates to be configured at the time of joining mesh.
>
>> + ? ? if (!sdata->vif.bss_conf.basic_rates)
>> + ? ? ? ? ? ? sdata->vif.bss_conf.basic_rates =
>> + ? ? ? ? ? ? ? ? ? ? ieee80211_mandatory_rates(sdata, band);
>
> I think this default should come from cfg80211 instead, there's little
> point in imposing this calculation on all drivers that want to use mesh.
>

This default initialization uses the mac80211 utility function which
will not be accessible from cfg80211. Could you please explain what is
the advantage/purpose of imposing this calculation up in cfg80211.

Thank you,
Ashok
> johannes
>

2012-06-09 08:50:18

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 3/3] [nl,cfg,mac]80211: Allow user to configure basic rates when joining

On Thu, 2012-06-07 at 19:21 -0700, Ashok Nagarajan wrote:
> Currently mesh uses mandatory rates as default basic rates. This patch
> introduces basic rates to be configured at the time of joining mesh.

> + if (!sdata->vif.bss_conf.basic_rates)
> + sdata->vif.bss_conf.basic_rates =
> + ieee80211_mandatory_rates(sdata, band);

I think this default should come from cfg80211 instead, there's little
point in imposing this calculation on all drivers that want to use mesh.

johannes