2012-12-02 17:09:29

by Antonio Quartulli

[permalink] [raw]
Subject: [PATCH 1/2] cfg80211: allow user to specify short_preamble on ibss join

Short preamble can be used to improve wireless performance
on devices different from lagacy-802.11. This patch
enabled the user to specify such capability on IBSS join.

Signed-off-by: Antonio Quartulli <[email protected]>
---
include/net/cfg80211.h | 1 +
net/wireless/nl80211.c | 4 ++++
2 files changed, 5 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 8e6a6b7..c93955c 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1416,6 +1416,7 @@ struct cfg80211_ibss_params {
bool privacy;
bool control_port;
int mcast_rate[IEEE80211_NUM_BANDS];
+ bool use_short_preamble;
};

/**
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index f45706a..e82c51a 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5459,6 +5459,7 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
struct wiphy *wiphy;
struct cfg80211_cached_keys *connkeys = NULL;
int err;
+ bool sp;

memset(&ibss, 0, sizeof(ibss));

@@ -5554,6 +5555,9 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
ibss.control_port =
nla_get_flag(info->attrs[NL80211_ATTR_CONTROL_PORT]);

+ sp = nla_get_flags(info->attr[NL80211_ATTR_BSS_SHORT_PREAMBLE]);
+ ibss.use_short_preamble = sp;
+
err = cfg80211_join_ibss(rdev, dev, &ibss, connkeys);
if (err)
kfree(connkeys);
--
1.8.0



2012-12-02 17:09:30

by Antonio Quartulli

[permalink] [raw]
Subject: [PATCH 2/2] mac80211: configure short_preamble capability if requested

If the short preamble option is specified by the user on
IBSS join, mac80211 will try to set it in the driver.
Such capability is then advertised by Beacons/ProbeResp
in the capability field.

A station not matching the short_preamble capability of
another set of nodes cannot join the same cell.

Signed-off-by: Antonio Quartulli <[email protected]>
---
net/mac80211/ibss.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 11a6a1b..e5ba99a 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -535,6 +535,11 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
if (!(cbss->capability & WLAN_CAPABILITY_IBSS))
goto put_bss;

+ /* not using the same preamble policy */
+ if ((cbss->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) !=
+ sdata->vif.bss_conf.use_short_preamble)
+ goto put_bss;
+
/* different channel */
if (sdata->u.ibss.fixed_channel &&
sdata->u.ibss.channel != cbss->channel)
@@ -724,6 +729,9 @@ static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata)
else
sdata->drop_unencrypted = 0;

+ if (ifibss->vif.bss_conf.use_short_preamble)
+ capability |= WLAN_CAPABILITY_SHORT_PREAMBLE;
+
__ieee80211_sta_join_ibss(sdata, bssid, sdata->vif.bss_conf.beacon_int,
ifibss->channel, ifibss->basic_rates,
capability, 0, true);
@@ -754,6 +762,8 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata)
capability = WLAN_CAPABILITY_IBSS;
if (ifibss->privacy)
capability |= WLAN_CAPABILITY_PRIVACY;
+ if (ifibss->vif.bss_conf.use_short_preamble)
+ capability |= WLAN_CAPABILITY_SHORT_PREAMBLE;
if (ifibss->fixed_bssid)
bssid = ifibss->bssid;
if (ifibss->fixed_channel)
@@ -762,8 +772,8 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata)
bssid = ifibss->bssid;
cbss = cfg80211_get_bss(local->hw.wiphy, chan, bssid,
ifibss->ssid, ifibss->ssid_len,
- WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_PRIVACY,
- capability);
+ WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_PRIVACY |
+ WLAN_CAPABILITY_SHORT_PREAMBLE, capability);

if (cbss) {
struct ieee80211_bss *bss;
@@ -1102,6 +1112,9 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
memcpy(sdata->u.ibss.ssid, params->ssid, params->ssid_len);
sdata->u.ibss.ssid_len = params->ssid_len;

+ sdata->vif.bss_conf.use_short_preamble = params->use_short_preamble;
+ changed |= BSS_CHANGED_ERP_PREAMBLE;
+
mutex_unlock(&sdata->u.ibss.mtx);

mutex_lock(&sdata->local->mtx);
@@ -1156,11 +1169,14 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata)

if (ifibss->privacy)
capability |= WLAN_CAPABILITY_PRIVACY;
+ if (ifibss->vif.bss_conf.use_short_preamble)
+ capability |= WLAN_CAPABILITY_SHORT_PREAMBLE;

cbss = cfg80211_get_bss(local->hw.wiphy, ifibss->channel,
ifibss->bssid, ifibss->ssid,
ifibss->ssid_len, WLAN_CAPABILITY_IBSS |
- WLAN_CAPABILITY_PRIVACY,
+ WLAN_CAPABILITY_PRIVACY |
+ WLAN_CAPABILITY_SHORT_PREAMBLE,
capability);

if (cbss) {
--
1.8.0