nl80211: Parse channel type attribute in an IBSS join request
Subsystems (2)
PATCH 1/4 nl80211: Parse channel type attribute in an IBSS join request
Check if the requested HT mode can be used.
Extend cfg80211 IBSS struct for HT mode.
---
As there were no replies for my RFC post, i am resending this as PATCH.
include/net/cfg80211.h | 1 + net/wireless/chan.c | 2 +- net/wireless/core.h | 3 +++ net/wireless/nl80211.c | 34 +++++++++++++++++++++++++++++++--- 4 files changed, 36 insertions(+), 4 deletions(-)
include/net/cfg80211.h +1 -0
@@ -1040,6 +1040,7 @@ struct cfg80211_ibss_params {u8 *ssid;u8 *bssid;struct ieee80211_channel *channel; +enum nl80211_channel_type channel_type;u8 *ie;u8 ssid_len, ie_len;u16 beacon_interval;
net/wireless/chan.c +1 -1
@@ -44,7 +44,7 @@ rdev_freq_to_chan(struct cfg80211_registered_device *rdev,return chan; } -static bool can_beacon_sec_chan (struct wiphy *wiphy, +bool can_beacon_sec_chan (struct wiphy *wiphy,struct ieee80211_channel *chan,enum nl80211_channel_type channel_type) {
net/wireless/core.h +3 -0
@@ -441,6 +441,9 @@ cfg80211_can_add_interface(struct cfg80211_registered_device *rdev,struct ieee80211_channel *rdev_freq_to_chan (struct cfg80211_registered_device *rdev,int freq,enum nl80211_channel_type channel_type); +bool can_beacon_sec_chan (struct wiphy *wiphy, +struct ieee80211_channel *chan, +enum nl80211_channel_type channel_type);int cfg80211_set_freq (struct cfg80211_registered_device *rdev,struct wireless_dev *wdev,int freq,enum nl80211_channel_type channel_type);
net/wireless/nl80211.c +31 -3
@@ -4346,12 +4346,40 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) ibss.ie_len =nla_len (info->attrs[NL80211_ATTR_IE ]); } - ibss.channel =ieee80211_get_channel (wiphy, -nla_get_u32 (info->attrs[NL80211_ATTR_WIPHY_FREQ ])); +if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE ]) { +enum nl80211_channel_type channel_type; + + channel_type =nla_get_u32 ( + info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE ]); +if (channel_type !=NL80211_CHAN_NO_HT && + channel_type !=NL80211_CHAN_HT20 && + channel_type !=NL80211_CHAN_HT40PLUS && + channel_type !=NL80211_CHAN_HT40MINUS ) +return -EINVAL ; + ibss.channel_type = channel_type; + }else { + ibss.channel_type =NL80211_CHAN_NO_HT ; + } + + ibss.channel =rdev_freq_to_chan (rdev, +nla_get_u32 (info->attrs[NL80211_ATTR_WIPHY_FREQ ]), + ibss.channel_type);if (!ibss.channel || + ibss.channel->flags &IEEE80211_CHAN_PASSIVE_SCAN || ibss.channel->flags &IEEE80211_CHAN_NO_IBSS || - ibss.channel->flags &IEEE80211_CHAN_DISABLED ) + ibss.channel->flags &IEEE80211_CHAN_RADAR ) +return -EINVAL ; + +/* Both channels should be able to initiate communication */ +if ((ibss.channel_type ==NL80211_CHAN_HT40PLUS || + ibss.channel_type ==NL80211_CHAN_HT40MINUS ) && + !can_beacon_sec_chan (&rdev->wiphy, ibss.channel, + ibss.channel_type)) { +printk (KERN_DEBUG +"cfg80211: Secondary channel not " +"allowed to initiate communication\n" );return -EINVAL ; + } ibss.channel_fixed = !!info->attrs[NL80211_ATTR_FREQ_FIXED ]; ibss.privacy = !!info->attrs[NL80211_ATTR_PRIVACY ];
Signature · 1 line
1.7.3.4
PATCH 2/4 cfg80211: Add cfg80211_get_bss_ht to also match HT configuration
Keep cfg80211_get_bss for compatibility but make use of this new function by matching any HT configuration.
--- include/net/cfg80211.h | 6 ++++++ net/wireless/chan.c | 1 + net/wireless/scan.c | 37 ++++++++++++++++++++++++++++++++++--- 3 files changed, 41 insertions(+), 3 deletions(-)
include/net/cfg80211.h +0 -0
@@ -2581,6 +2581,12 @@ struct cfg80211_bss *cfg80211_get_bss(struct
wiphy *wiphy,
const u8 *bssid, const u8 *ssid, size_t ssid_len, u16 capa_mask, u16 capa_val);
+struct cfg80211_bss *cfg80211_get_bss_ht(struct wiphy *wiphy,
+ struct ieee80211_channel *channel, + const u8 *bssid, + const u8 *ssid, size_t ssid_len, + u16 capa_mask, u16 capa_val,
+ enum nl80211_channel_type channel_type);
static inline struct cfg80211_bss * cfg80211_get_ibss(struct wiphy *wiphy,
struct ieee80211_channel *channel,
net/wireless/chan.c +1 -0
@@ -75,6 +75,7 @@ bool can_beacon_sec_chan(struct wiphy *wiphy,return true; } +EXPORT_SYMBOL (can_beacon_sec_chan); int cfg80211_set_freq(struct cfg80211_registered_device *rdev, struct wireless_dev *wdev, int freq,
net/wireless/scan.c +0 -0
@@ -364,6 +364,19 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy
*wiphy,
const u8 *ssid, size_t ssid_len, u16 capa_mask, u16 capa_val)
{
+ /* call HT version with no HT requirements */
+ return cfg80211_get_bss_ht(wiphy, channel, bssid, ssid, ssid_len,
+ capa_mask, capa_val, NL80211_CHAN_NO_HT);
+}
+EXPORT_SYMBOL(cfg80211_get_bss);
+
+struct cfg80211_bss *cfg80211_get_bss_ht(struct wiphy *wiphy,
+ struct ieee80211_channel *channel, + const u8 *bssid, + const u8 *ssid, size_t ssid_len, + u16 capa_mask, u16 capa_val, + enum nl80211_channel_type require_ht)
+{
struct cfg80211_registered_device *dev = wiphy_to_dev(wiphy); struct cfg80211_internal_bss *bss, *res = NULL;
unsigned long now = jiffies;
@@ -373,8 +386,26 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
list_for_each_entry(bss, &dev->bss_list, list) {
if ((bss->pub.capability & capa_mask) != capa_val)
continue;
- if (channel && bss->pub.channel != channel)
- continue;
+ if (channel) {
+ if (bss->pub.channel != channel)
+ continue;
+ if (require_ht != NL80211_CHAN_NO_HT) {
+ struct ieee80211_ht_info *ht_info;
+ ht_info = (struct ieee80211_ht_info *)
+ ieee80211_bss_get_ie(&bss->pub,
+ WLAN_EID_HT_INFORMATION);
+ if (!ht_info)
+ continue;
+ if (require_ht == NL80211_CHAN_HT40MINUS &&
+ !(ht_info->ht_param &
+ IEEE80211_HT_PARAM_CHA_SEC_BELOW))
+ continue;
+ if (require_ht == NL80211_CHAN_HT40PLUS &&
+ !(ht_info->ht_param &
+ IEEE80211_HT_PARAM_CHA_SEC_ABOVE))
+ continue;
+ }
+ }
/* Don't get expired BSS structs */
if (time_after(now, bss->ts + IEEE80211_SCAN_RESULT_EXPIRE) &&
!atomic_read(&bss->hold))
@@ -391,7 +422,7 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
return NULL;
return &res->pub;
}
-EXPORT_SYMBOL(cfg80211_get_bss); +EXPORT_SYMBOL(cfg80211_get_bss_ht);
struct cfg80211_bss *cfg80211_get_mesh(struct wiphy *wiphy,
struct ieee80211_channel *channel,
Signature · 1 line
1.7.3.4
PATCH 3/4 mac80211: Add HT helper functions
In reply to Alexander Simonthese can also be used from existing code.
--- net/mac80211/ieee80211_i.h | 8 +++ net/mac80211/util.c | 116 +++++++++++++++++++++++++++++++++++++------ net/mac80211/work.c | 29 +----------- 3 files changed, 108 insertions(+), 45 deletions(-)
net/mac80211/ieee80211_i.h +8 -0
@@ -1401,6 +1401,12 @@ void ieee80211_recalc_smps(struct ieee80211_local *local);size_t ieee80211_ie_split (const u8 *ies,size_t ielen,const u8 *ids,int n_ids,size_t offset);size_t ieee80211_ie_split_vendor (const u8 *ies,size_t ielen,size_t offset); +u8 *ieee80211_ie_build_ht_cap (u8 *pos,struct ieee80211_supported_band *sband, +u16 cap); +u8 *ieee80211_ie_build_ht_info (u8 *pos, +struct ieee80211_sta_ht_cap *ht_cap, +struct ieee80211_channel *channel, +enum nl80211_channel_type channel_type);/* internal work items */ void ieee80211_work_init (struct ieee80211_local *local);
@@ -1429,6 +1435,8 @@ ieee80211_get_channel_mode(struct ieee80211_local *local,bool ieee80211_set_channel_type (struct ieee80211_local *local,struct ieee80211_sub_if_data *sdata,enum nl80211_channel_type chantype); +enum nl80211_channel_type ieee80211_ht_info_to_channel_type ( +struct ieee80211_ht_info *ht_info);#ifdef CONFIG_MAC80211_NOINLINE #define debug_noinline noinline
net/mac80211/util.c +99 -17
125 lines not on this page · raw message
net/mac80211/work.c +1 -28
@@ -103,7 +103,6 @@ static void ieee80211_add_ht_ie(struct sk_buff *skb, const u8 *ht_info_ie,u8 *pos;u32 flags = channel->flags;u16 cap = sband->ht_cap.cap; -__le16 tmp;if (!sband->ht_cap.ht_supported)return ;
@@ -154,34 +153,8 @@ static void ieee80211_add_ht_ie(struct sk_buff *skb, const u8 *ht_info_ie, }/* reserve and fill IE */ - pos =skb_put (skb,sizeof (struct ieee80211_ht_cap ) +2 ); - *pos++ =WLAN_EID_HT_CAPABILITY ; - *pos++ =sizeof (struct ieee80211_ht_cap ); -memset (pos,0 ,sizeof (struct ieee80211_ht_cap )); - -/* capability flags */ - tmp =cpu_to_le16 (cap); -memcpy (pos, &tmp,sizeof (u16)); - pos +=sizeof (u16); - -/* AMPDU parameters */ - *pos++ = sband->ht_cap.ampdu_factor | - (sband->ht_cap.ampdu_density << -IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT ); - -/* MCS set */ -memcpy (pos, &sband->ht_cap.mcs,sizeof (sband->ht_cap.mcs)); - pos +=sizeof (sband->ht_cap.mcs); - -/* extended capabilities */ - pos +=sizeof (__le16); - -/* BF capabilities */ - pos +=sizeof (__le32); - -/* antenna selection */ - pos +=sizeof (u8); +ieee80211_ie_build_ht_cap (pos, sband, cap); } static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
Signature · 1 line
1.7.3.4
PATCH 4/4 mac80211: Add HT operation modes for IBSS
In reply to Alexander SimonThis means setting channel into HT mode and adding HT IEs in beacons. Check if regdom allows this first.
If joining another HT network, use its HT mode.
If joining a non-HT network, use HT mode given by iw.
Join as legacy if neither iw nor remote beacon set an HT mode. The same applies when merging with an older BSSID
(as it is basically leaving the current and joining the older BSSID).
If we receive a beacon from another station within our BSSID with a different HT mode than us, we switch to its HT mode. If there are several stations with different HT modes, it may take some time until all will have the same mode. There is no way we can distinguish the "older" station.
Except for fixed channel mode, HT mode is also fixed. Join or merge ONLY if channel AND HT mode matches.
And finally, allow frame aggregation in IBSS mode.
--- net/mac80211/agg-rx.c | 2 + net/mac80211/agg-tx.c | 5 +- net/mac80211/ht.c | 2 + net/mac80211/ibss.c | 166 +++++++++++++++++++++++++++++++++++++++---- net/mac80211/ieee80211_i.h | 2 + net/mac80211/rx.c | 6 +- 6 files changed, 164 insertions(+), 19 deletions(-)
net/mac80211/agg-rx.c +2 -0
@@ -184,6 +184,8 @@ static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *dmemcpy (mgmt->bssid, sdata->vif.addr,ETH_ALEN ); else if (sdata->vif.type == NL80211_IFTYPE_STATION) memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) + memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN); mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ACTION );
net/mac80211/agg-tx.c +4 -1
@@ -83,6 +83,8 @@ static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata,memcpy (mgmt->bssid, sdata->vif.addr,ETH_ALEN ); else if (sdata->vif.type == NL80211_IFTYPE_STATION) memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) + memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN); mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ACTION );
@@ -380,7 +382,8 @@ int ieee80211_start_tx_ba_session(struct ieee80211_sta *pubsta, u16 tid,*/ if (sdata->vif.type !=NL80211_IFTYPE_STATION && sdata->vif.type !=NL80211_IFTYPE_AP_VLAN && - sdata->vif.type !=NL80211_IFTYPE_AP ) + sdata->vif.type !=NL80211_IFTYPE_AP && + sdata->vif.type !=NL80211_IFTYPE_ADHOC )return -EINVAL ;if (test_sta_flags (sta,WLAN_STA_BLOCK_BA )) {
net/mac80211/ht.c +2 -0
@@ -203,6 +203,8 @@ void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,memcpy (mgmt->bssid, sdata->vif.addr,ETH_ALEN ); else if (sdata->vif.type == NL80211_IFTYPE_STATION) memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) + memcpy(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN); mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_ACTION );
net/mac80211/ibss.c +150 -16
263 lines not on this page · raw message
net/mac80211/ieee80211_i.h +2 -0
@@ -464,6 +464,7 @@ struct ieee80211_if_ibss {u8 ssid_len, ie_len;u8 *ie;struct ieee80211_channel *channel; +enum nl80211_channel_type channel_type;unsigned long ibss_join_req;/* probe response/beacon for IBSS */
@@ -1147,6 +1148,7 @@ void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local);void ieee80211_ibss_setup_sdata (struct ieee80211_sub_if_data *sdata);struct sta_info *ieee80211_ibss_add_sta (struct ieee80211_sub_if_data *sdata,u8 *bssid,u8 *addr,u32 supp_rates, +struct ieee80211_ht_cap *ht_cap,gfp_t gfp);int ieee80211_ibss_join (struct ieee80211_sub_if_data *sdata,struct cfg80211_ibss_params *params);
net/mac80211/rx.c +4 -2
@@ -2147,7 +2147,8 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)*/ if (sdata->vif.type !=NL80211_IFTYPE_STATION && sdata->vif.type !=NL80211_IFTYPE_AP_VLAN && - sdata->vif.type !=NL80211_IFTYPE_AP ) + sdata->vif.type !=NL80211_IFTYPE_AP && + sdata->vif.type !=NL80211_IFTYPE_ADHOC )break ;/* verify action_code is present */
@@ -2664,7 +2665,8 @@ static int prepare_for_handlers(struct ieee80211_rx_data *rx,else rate_idx = status->rate_idx; rx->sta =ieee80211_ibss_add_sta (sdata, bssid, - hdr->addr2,BIT (rate_idx),GFP_ATOMIC ); + hdr->addr2,BIT (rate_idx),NULL , +GFP_ATOMIC ); }break ;case NL80211_IFTYPE_MESH_POINT :
Signature · 1 line
1.7.3.4
Johannes Berg
maintainerQuoted 7 lines · Alexander Simon
Check if the requested HT mode can be used.
Extend cfg80211 IBSS struct for HT mode.Signed-off-by Alexander Simon <[email protected]>---
As there were no replies for my RFC post, i am resending this as PATCH.
I was on vacation ;-)
Quoted 8 lines
net/wireless/nl80211.c +5
-1+ ibss.channel =rdev_freq_to_chan (rdev, +nla_get_u32 (info->attrs[NL80211_ATTR_WIPHY_FREQ ]), + ibss.channel_type);if (!ibss.channel || + ibss.channel->flags &IEEE80211_CHAN_PASSIVE_SCAN || ibss.channel->flags &IEEE80211_CHAN_NO_IBSS || - ibss.channel->flags &IEEE80211_CHAN_DISABLED ) + ibss.channel->flags &IEEE80211_CHAN_RADAR )
net/wireless/nl80211.c static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) · line 4380
Quoted 10 lines
net/wireless/nl80211.c +10
-0+return -EINVAL ; + +/* Both channels should be able to initiate communication */ +if ((ibss.channel_type ==NL80211_CHAN_HT40PLUS || + ibss.channel_type ==NL80211_CHAN_HT40MINUS ) && + !can_beacon_sec_chan (&rdev->wiphy, ibss.channel, + ibss.channel_type)) { +printk (KERN_DEBUG +"cfg80211: Secondary channel not " +"allowed to initiate communication\n" );
remove the printk please
johannes
Johannes Berg
maintainerRe: [PATCH 2/4] cfg80211: Add cfg80211_get_bss_ht to also match HT configuration
In reply to Alexander SimonReview
Quoted 6 lines · Alexander Simon
(quoted diff) +6
-0+struct cfg80211_bss *cfg80211_get_bss_ht(struct wiphy *wiphy, + struct ieee80211_channel *channel, + const u8 *bssid, + const u8 *ssid, size_t ssid_len, + u16 capa_mask, u16 capa_val, + enum nl80211_channel_type channel_type);
indentation? Also, you really need kernel-doc for this.
net/wireless/chan.c bool can_beacon_sec_chan(struct wiphy *wiphy, · line 78
Quoted 6 lines
+++
b/net/wireless/chan.cnet/wireless/chan.c +1
-0@@ -75,6 +75,7 @@ bool can_beacon_sec_chan(struct wiphy *wiphy,return true; } +EXPORT_SYMBOL (can_beacon_sec_chan);
You've got to be kidding, if you export it you really need to give it a decent name. Besides, you don't have to export it in this patch.
Quoted 7 lines
net/wireless/chan.c +0
-0int cfg80211_set_freq(struct cfg80211_registered_device *rdev, struct wireless_dev *wdev, int freq,net/wireless/scan.c +0
-0
net/wireless/scan.c struct cfg80211_bss *cfg80211_get_bss(struct wiphy · line 372
Quoted 9 lines
net/wireless/scan.c +5
-0@@ -364,6 +364,19 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, const u8 *ssid, size_t ssid_len, u16 capa_mask, u16 capa_val) { +/* call HT version with no HT requirements */ +return cfg80211_get_bss_ht (wiphy, channel, bssid, ssid, ssid_len, + capa_mask, capa_val,NL80211_CHAN_NO_HT ); +} +EXPORT_SYMBOL (cfg80211_get_bss);
I don't like the semantics of this. Why is NO_HT indicating "don't care about HT"? How then do you really find a NO_HT BSS?
Also, this raises a more fundamental question -- didn't you earlier say you wanted to be able to connect with any IBSS, even non-HT ones, but now it must match?
johannes
Johannes Berg
maintainerRe: [PATCH 3/4] mac80211: Add HT helper functions
In reply to Alexander SimonQuoted 1 line · Alexander Simon
these can also be used from existing code.
So you should say that it's a refactoring. Generally, your commit logs could really be a tad more verbose :-)
I'm not going to really review the code you move here -- hopefully you did only move it?
johannes
Johannes Berg
maintainerRe: [PATCH 3/4] mac80211: Add HT helper functions
In reply to Alexander Simonnet/mac80211/util.c void ieee80211_disable_rssi_reports(struct ieee80211_vif *vif) · line 1584
Quoted 2 lines · Alexander Simon
net/mac80211/util.c +2
-0+enum nl80211_channel_type ieee80211_ht_info_to_channel_type ( +struct ieee80211_ht_info *ht_info)
This isn't used in this patch so you should put it into the other patch.
johannes
Johannes Berg
maintainerRe: [PATCH 4/4] mac80211: Add HT operation modes for IBSS
In reply to Alexander SimonQuoted 6 lines · Alexander Simon
This means setting channel into HT mode and adding HT IEs in beacons. Check if regdom allows this first.
If joining another HT network, use its HT mode.
If joining a non-HT network, use HT mode given by iw. Join as legacy if neither iw nor remote beacon set an HT mode.
Do we really want this? I'm wondering if we shouldn't always do HT IBSS when joining, even if you didn't ask for it? Not really sure though. Thoughts? Are we joining as HT20 if you didn't ask for HT40? And are we joining as HT20 if you asked for HT40- but the network is HT40+?
Quoted 4 lines
If we receive a beacon from another station within our BSSID with a different HT mode than us, we switch to its HT mode. If there are several stations with different HT modes, it may take some time until all will have the same mode. There is no way we can distinguish the "older" station.
Actually, you can ... the highest TSF should win.
Quoted 2 lines
Except for fixed channel mode, HT mode is also fixed. Join or merge ONLY if channel AND HT mode matches.
makes sense.
Quoted 15 lines
+++
b/net/mac80211/ibss.cnet/mac80211/ibss.c +10
-0@@ -35,6 +35,76 @@#define IEEE80211_IBSS_MAX_STA_ENTRIES 128 +static bool ieee80211_can_use_ext_chan (struct ieee80211_sub_if_data *sdata, +struct ieee80211_channel *channel, +enum nl80211_channel_type channel_type) +{ +/* check if we are legally allowed to use HT extension channel */ +if ((channel_type ==NL80211_CHAN_HT40PLUS ) || + (channel_type ==NL80211_CHAN_HT40MINUS )) { +int sec_freq = channel->center_freq + + (channel_type ==NL80211_CHAN_HT40PLUS ?20 :-20 ); + struct ieee80211_channel *sec_chan =
net/mac80211/ibss.c line 57
Quoted 10 lines
net/mac80211/ibss.c +10
-0+ieee80211_get_channel (sdata->wdev.wiphy, sec_freq); +if (!sec_chan || sec_chan->flags & (IEEE80211_CHAN_DISABLED | +IEEE80211_CHAN_PASSIVE_SCAN | +IEEE80211_CHAN_NO_IBSS | +IEEE80211_CHAN_RADAR )) { +return false; + } + } +return true; +}
Isn't that already a function in cfg80211 that you could rename & export?
Quoted 28 lines
net/mac80211/ibss.c +28
-0+static void ieee80211_update_ht_elems (struct ieee80211_sub_if_data *sdata, +struct ieee80211_mgmt *mgmt, +struct ieee80211_ht_info *ht_info) +{ +struct ieee80211_local *local = sdata->local; +struct ieee80211_supported_band *sband = + local->hw.wiphy->bands[local->oper_channel->band]; +enum nl80211_channel_type channel_type = +ieee80211_ht_info_to_channel_type (ht_info); + +if (!ieee80211_can_use_ext_chan (sdata, local->oper_channel, channel_type)) + channel_type =NL80211_CHAN_HT20 ; + +if (channel_type != local->_oper_channel_type) { +struct sk_buff *skb =rcu_dereference_protected ( + sdata->u.ibss.presp, +lockdep_is_held (&ifibss->mtx)); +struct sk_buff *nskb; +u8 *ht_ie; + +/* update HT IE. If not yet existing, create one */ + nskb =skb_copy (skb,GFP_ATOMIC ); + ht_ie = (u8 *)cfg80211_find_ie (WLAN_EID_HT_CAPABILITY , + (const u8 *)(nskb->data +24 + +sizeof (mgmt->u.beacon)), + nskb->len -24 - +sizeof (mgmt->u.beacon)); +if (!ht_ie)
net/mac80211/ibss.c line 96
Quoted 10 lines
net/mac80211/ibss.c +10
-0+ ht_ie =skb_put (nskb,4 + +sizeof (struct ieee80211_ht_cap ) + +sizeof (struct ieee80211_ht_info )); + + ht_ie =ieee80211_ie_build_ht_cap (ht_ie, sband, + sband->ht_cap.cap); + ht_ie =ieee80211_ie_build_ht_info (ht_ie, &sband->ht_cap, + local->oper_channel, channel_type); +rcu_assign_pointer (sdata->u.ibss.presp, nskb); +kfree_skb (skb);
RCU race here.
Quoted 6 lines
net/mac80211/ibss.c +2
-0@@ -104,8 +175,17 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, sdata->drop_unencrypted = capability &WLAN_CAPABILITY_PRIVACY ?1 :0 ; +/* entering a legacy IBSS. Use given HT configuration. */ +if (channel_type ==NL80211_CHAN_NO_HT )
net/mac80211/ibss.c static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, · line 188
Quoted 10 lines
net/mac80211/ibss.c +8
-1+ channel_type = ifibss->channel_type; local->oper_channel = chan; -WARN_ON (!ieee80211_set_channel_type (local, sdata,NL80211_CHAN_NO_HT )); + +/* if phy is on a different extension channel, setting ht40 will fail */ +if (!ieee80211_set_channel_type (local, sdata, channel_type)) { + channel_type =NL80211_CHAN_HT20 ; +WARN_ON (!ieee80211_set_channel_type (local, sdata, + channel_type)); + }
indentation
net/mac80211/ibss.c static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, · line 528
Quoted 6 lines
net/mac80211/ibss.c +1
-1@@ -404,7 +525,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,ieee80211_sta_join_ibss (sdata, bss); supp_rates =ieee80211_sta_get_rates (local, elems, band);ieee80211_ibss_add_sta (sdata, mgmt->bssid, mgmt->sa, - supp_rates,GFP_KERNEL ); + supp_rates, elems->ht_cap_elem,GFP_KERNEL );
indentation
johannes
Re: [PATCH 4/4] mac80211: Add HT operation modes for IBSS
Am Mittwoch, den 10.08.2011, 16:03 +0200 schrieb Johannes Berg:
Quoted 12 lines · Alexander Simon
Quoted 6 lines
This means setting channel into HT mode and adding HT IEs in beacons. Check if regdom allows this first.
If joining another HT network, use its HT mode.
If joining a non-HT network, use HT mode given by iw. Join as legacy if neither iw nor remote beacon set an HT mode.Do we really want this? I'm wondering if we shouldn't always do HT IBSS when joining, even if you didn't ask for it? Not really sure though. Thoughts? Are we joining as HT20 if you didn't ask for HT40? And are we joining as HT20 if you asked for HT40- but the network is HT40+?
In short: The HT parameter shall behave similar to the frequency:
Non-fixed mode: Only used when starting an IBSS or starting HT in an non-IBSS.
Fixed mode: Only join when HT modes match.
This should answer your last questions:
When not fixed, the BSSID configuration always is preferred. Thus, we would join as HT40 even though not requested.
So, when we requsted HT40-, but the IBSS is HT40+, we would work on -.
I wanted to have the opportunity to start HT on an existing IBSS. The problem is that legacy station may "kill" the HT configuration:
If STA A starts in HT IBSS and lets say Windows STA B joins, B would advertise that IBSS as non-HT as it ignores our HT IE. Then, if STA A dies and STA C joins, it will be non-HT.
Quoted 6 lines
Quoted 4 lines
If we receive a beacon from another station within our BSSID with a different HT mode than us, we switch to its HT mode. If there are several stations with different HT modes, it may take some time until all will have the same mode. There is no way we can distinguish the "older" station.
Actually, you can ... the highest TSF should win.
No, pretty sure not. We *are* already joined. That means the TSFs of all stations *within* our BSSID match. TSFs can only tell whitch BSSID is older...
So there is no way to distinguish which station first joined. Or am i wrong? That would be good in that case :)
Quoted 26 lines
Quoted 3 lines
Except for fixed channel mode, HT mode is also fixed. Join or merge ONLY if channel AND HT mode matches.
makes sense.
Quoted 20 lines
+++
b/net/mac80211/ibss.cnet/mac80211/ibss.c +15
-0@@ -35,6 +35,76 @@#define IEEE80211_IBSS_MAX_STA_ENTRIES 128 +static bool ieee80211_can_use_ext_chan (struct ieee80211_sub_if_data *sdata, +struct ieee80211_channel *channel, +enum nl80211_channel_type channel_type) +{ +/* check if we are legally allowed to use HT extension channel */ +if ((channel_type ==NL80211_CHAN_HT40PLUS ) || + (channel_type ==NL80211_CHAN_HT40MINUS )) { +int sec_freq = channel->center_freq + + (channel_type ==NL80211_CHAN_HT40PLUS ?20 :-20 ); +struct ieee80211_channel *sec_chan = +ieee80211_get_channel (sdata->wdev.wiphy, sec_freq); +if (!sec_chan || sec_chan->flags & (IEEE80211_CHAN_DISABLED | +IEEE80211_CHAN_PASSIVE_SCAN | +IEEE80211_CHAN_NO_IBSS | +IEEE80211_CHAN_RADAR )) {
Quoted 8 lines
net/mac80211/ibss.c line 57
Quoted 5 lines
net/mac80211/ibss.c +5
-0+return false; + } + } +return true; +}Isn't that already a function in cfg80211 that you could rename & export?
Hmm... Didn't want to do any changes to the module exports, but I'll use it.
Quoted 72 lines
Quoted 29 lines
net/mac80211/ibss.c +28
-0+static void ieee80211_update_ht_elems (struct ieee80211_sub_if_data *sdata, +struct ieee80211_mgmt *mgmt, +struct ieee80211_ht_info *ht_info) +{ +struct ieee80211_local *local = sdata->local; +struct ieee80211_supported_band *sband = + local->hw.wiphy->bands[local->oper_channel->band]; +enum nl80211_channel_type channel_type = +ieee80211_ht_info_to_channel_type (ht_info); + +if (!ieee80211_can_use_ext_chan (sdata, local->oper_channel, channel_type)) + channel_type =NL80211_CHAN_HT20 ; + +if (channel_type != local->_oper_channel_type) { +struct sk_buff *skb =rcu_dereference_protected ( + sdata->u.ibss.presp, +lockdep_is_held (&ifibss->mtx)); +struct sk_buff *nskb; +u8 *ht_ie; + +/* update HT IE. If not yet existing, create one */ + nskb =skb_copy (skb,GFP_ATOMIC ); + ht_ie = (u8 *)cfg80211_find_ie (WLAN_EID_HT_CAPABILITY , + (const u8 *)(nskb->data +24 + +sizeof (mgmt->u.beacon)), + nskb->len -24 - +sizeof (mgmt->u.beacon)); +if (!ht_ie)net/mac80211/ibss.c line 96
Quoted 10 lines
net/mac80211/ibss.c +10
-0+ ht_ie =skb_put (nskb,4 + +sizeof (struct ieee80211_ht_cap ) + +sizeof (struct ieee80211_ht_info )); + + ht_ie =ieee80211_ie_build_ht_cap (ht_ie, sband, + sband->ht_cap.cap); + ht_ie =ieee80211_ie_build_ht_info (ht_ie, &sband->ht_cap, + local->oper_channel, channel_type); +rcu_assign_pointer (sdata->u.ibss.presp, nskb); +kfree_skb (skb);RCU race here.
Quoted 6 lines
net/mac80211/ibss.c +2
-0@@ -104,8 +175,17 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, sdata->drop_unencrypted = capability &WLAN_CAPABILITY_PRIVACY ?1 :0 ; +/* entering a legacy IBSS. Use given HT configuration. */ +if (channel_type ==NL80211_CHAN_NO_HT )net/mac80211/ibss.c static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, · line 188
Quoted 10 lines
net/mac80211/ibss.c +8
-1+ channel_type = ifibss->channel_type; local->oper_channel = chan; -WARN_ON (!ieee80211_set_channel_type (local, sdata,NL80211_CHAN_NO_HT )); + +/* if phy is on a different extension channel, setting ht40 will fail */ +if (!ieee80211_set_channel_type (local, sdata, channel_type)) { + channel_type =NL80211_CHAN_HT20 ; +WARN_ON (!ieee80211_set_channel_type (local, sdata, + channel_type)); + }indentation
net/mac80211/ibss.c static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, · line 528
Quoted 6 lines
net/mac80211/ibss.c +1
-1@@ -404,7 +525,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,ieee80211_sta_join_ibss (sdata, bss); supp_rates =ieee80211_sta_get_rates (local, elems, band);ieee80211_ibss_add_sta (sdata, mgmt->bssid, mgmt->sa, - supp_rates,GFP_KERNEL ); + supp_rates, elems->ht_cap_elem,GFP_KERNEL );indentation
johannes
Re: [PATCH 2/4] cfg80211: Add cfg80211_get_bss_ht to also match HT configuration
In reply to Johannes BergAm Mittwoch, den 10.08.2011, 15:53 +0200 schrieb Johannes Berg:
Quoted 10 lines · Alexander Simon
Review
Quoted 7 lines
(quoted diff) +6
-0+struct cfg80211_bss *cfg80211_get_bss_ht(struct wiphy *wiphy, + struct ieee80211_channel *channel, + const u8 *bssid, + const u8 *ssid, size_t ssid_len, + u16 capa_mask, u16 capa_val, + enum nl80211_channel_type channel_type);indentation? Also, you really need kernel-doc for this.
Pardon me, but I don't know what you mean... I just browsed Documentation/networking. Could you point me the exact file, please?
Quoted 10 lines
net/wireless/chan.c bool can_beacon_sec_chan(struct wiphy *wiphy, · line 78
Quoted 7 lines
+++
b/net/wireless/chan.cnet/wireless/chan.c +1
-0@@ -75,6 +75,7 @@ bool can_beacon_sec_chan(struct wiphy *wiphy,return true; } +EXPORT_SYMBOL (can_beacon_sec_chan);You've got to be kidding, if you export it you really need to give it a decent name. Besides, you don't have to export it in this patch.
I intended to export this instead of writing ieee80211_can_use_ext_chan first.
Ok, to summarize this: I should use this instead of my own ieee80211_can_use_ext_chan in mac80211 (as in your reply in 4/4), but when I export this I need to rename it. Does cfg80211_can_use_ext_chan sound well?
Quoted 21 lines
Quoted 8 lines
net/wireless/chan.c +0
-0int cfg80211_set_freq(struct cfg80211_registered_device *rdev, struct wireless_dev *wdev, int freq,net/wireless/scan.c +0
-0net/wireless/scan.c struct cfg80211_bss *cfg80211_get_bss(struct wiphy · line 372
Quoted 9 lines
net/wireless/scan.c +5
-0@@ -364,6 +364,19 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, const u8 *ssid, size_t ssid_len, u16 capa_mask, u16 capa_val) { +/* call HT version with no HT requirements */ +return cfg80211_get_bss_ht (wiphy, channel, bssid, ssid, ssid_len, + capa_mask, capa_val,NL80211_CHAN_NO_HT ); +} +EXPORT_SYMBOL (cfg80211_get_bss);I don't like the semantics of this. Why is
NO_HTindicating "don't care about HT"? How then do you really find aNO_HTBSS?
Quoted 3 lines
Also, this raises a more fundamental question -- didn't you earlier say you wanted to be able to connect with any IBSS, even non-HT ones, but now it must match?
This is only used for fixed channel mode. As we would only join a matching HT mode, I have to pass it here.
How about second parameter, "bool match_ht"?
Quoted 3 lines
johannes
Johannes Berg
maintainerRe: [PATCH 2/4] cfg80211: Add cfg80211_get_bss_ht to also match HT configuration
Quoted 11 lines · Alexander Simon
Am Mittwoch, den 10.08.2011, 15:53 +0200 schrieb Johannes Berg:
Quoted 10 lines · Alexander Simon
Review
Quoted 7 lines
(quoted diff) +6
-0+struct cfg80211_bss *cfg80211_get_bss_ht(struct wiphy *wiphy, + struct ieee80211_channel *channel, + const u8 *bssid, + const u8 *ssid, size_t ssid_len, + u16 capa_mask, u16 capa_val, + enum nl80211_channel_type channel_type);indentation? Also, you really need kernel-doc for this.
Quoted 2 lines
Pardon me, but I don't know what you mean... I just browsed
Documentation/networking. Could you point me the exact file, please?
Documentation/kernel-doc-nano-HOWTO.txt maybe?
Quoted 8 lines
Quoted 2 lines
You've got to be kidding, if you export it you really need to give it a decent name. Besides, you don't have to export it in this patch.
I intended to export this instead of writing
ieee80211_can_use_ext_chanfirst.
Ok, to summarize this: I should use this instead of my ownieee80211_can_use_ext_chanin mac80211 (as in your reply in 4/4), but when I export this I need to rename it. Doescfg80211_can_use_ext_chansound well?
Ok but then I guess you forgot to remove the export? Yeah, please rename it and export it for mac80211, that seems fine.
Quoted 9 lines
Quoted 6 lines
I don't like the semantics of this. Why is
NO_HTindicating "don't care about HT"? How then do you really find aNO_HTBSS?Also, this raises a more fundamental question -- didn't you earlier say you wanted to be able to connect with any IBSS, even non-HT ones, but now it must match?
This is only used for fixed channel mode. As we would only join a matching HT mode, I have to pass it here.
How about second parameter, "boolmatch_ht"?
Ahh, ok, that explains it, sorry for the confusion.
johannes
Re: [PATCH 2/4] cfg80211: Add cfg80211_get_bss_ht to also match HT configuration
Am Mittwoch, den 10.08.2011, 18:05 +0200 schrieb Johannes Berg:
Quoted 12 lines · Alexander Simon
Quoted 11 lines
Am Mittwoch, den 10.08.2011, 15:53 +0200 schrieb Johannes Berg:
Quoted 10 lines · Alexander Simon
Review
Quoted 7 lines
(quoted diff) +6
-0+struct cfg80211_bss *cfg80211_get_bss_ht(struct wiphy *wiphy, + struct ieee80211_channel *channel, + const u8 *bssid, + const u8 *ssid, size_t ssid_len, + u16 capa_mask, u16 capa_val, + enum nl80211_channel_type channel_type);indentation? Also, you really need kernel-doc for this.
Quoted 4 lines
Quoted 2 lines
Pardon me, but I don't know what you mean... I just browsed
Documentation/networking. Could you point me the exact file, please?
Documentation/kernel-doc-nano-HOWTO.txtmaybe?
Uh, okay...
I thought as there is no documentation for cfg80211_get_bss, there was no need to document the _ht version...
The problem I'm facing here is that I really *need* to check the HT mode _inside_ the loop. Hence i need a _ht version.
OR I could change cfg80211_get_bss only, causing to add the new parameters in *all* calls of cfg80211_get_bss... Whatever you prefer.
To conclude this:
* I'll write a _ht version that has a check_ht bool
* if (check_ht == 1), match channel_type parameter
* _ht version calls non-ht with check_ht = 0
* documentation for _ht (for non-ht also???)
Indentation will be fixed, of course.
Alex
Johannes Berg
maintainerRe: [PATCH 2/4] cfg80211: Add cfg80211_get_bss_ht to also match HT configuration
Quoted 4 lines · Alexander Simon
The problem I'm facing here is that I really *need* to check the HT mode _inside_ the loop. Hence i need a
_htversion.
OR I could changecfg80211_get_bssonly, causing to add the new parameters in *all* calls ofcfg80211_get_bss... Whatever you prefer.
Well, I would keep the wrapper but make it an inline, not a separate exported function, like cfg80211_get_ibss() (which really is quite pointless, does anything still use it?)
johannes
Johannes Berg
maintainerRe: [PATCH 4/4] mac80211: Add HT operation modes for IBSS
In reply to Alexander SimonQuoted 4 lines · Alexander Simon
In short: The HT parameter shall behave similar to the frequency:
Non-fixed mode: Only used when starting an IBSS or starting HT in an non-IBSS.
Fixed mode: Only join when HT modes match.
Ok, that makes sense. So you need the get_bss_ht() only for fixed mode I guess.
Quoted 4 lines
This should answer your last questions:
When not fixed, the BSSID configuration always is preferred. Thus, we would join as HT40 even though not requested.
So, when we requsted HT40-, but the IBSS is HT40+, we would work on -.
? I think I know what you mean but your example seems .. the wrong way around?
Quoted 1 line
I wanted to have the opportunity to start HT on an existing IBSS.
Well that should always be OK?
Quoted 4 lines
The problem is that legacy station may "kill" the HT configuration:
If STA A starts in HT IBSS and lets say Windows STA B joins, B would advertise that IBSS as non-HT as it ignores our HT IE. Then, if STA A dies and STA C joins, it will be non-HT.
mac80211 is STA C? Would it be a problem to use HT if the IBSS was previously non-HT? The old members will ignore it, but other new HT members may work OK? IOW -- is it not possible to have a mixed HT/non-HT IBSS?
Quoted 5 lines
No, pretty sure not. We *are* already joined. That means the TSFs of all stations *within* our BSSID match. TSFs can only tell whitch BSSID is older...
So there is no way to distinguish which station first joined. Or am i wrong? That would be good in that case :)
Oh, no, you're right of course.
johannes
Re: [PATCH 2/4] cfg80211: Add cfg80211_get_bss_ht to also match HT configuration
In reply to Johannes BergQuoted 5 lines
Well, I would keep the wrapper but make it an inline, not a separate exported function, like
cfg80211_get_ibss()(which really is quite pointless, does anything still use it?)johannes
Yep, i've already done so. Additionally, i also changed the wrapper cfg80211_get_ibss to use cfg80211_get_bss_ht.
Alex
Re: [PATCH 4/4] mac80211: Add HT operation modes for IBSS
In reply to Johannes BergQuoted 2 lines
Ok, that makes sense. So you need the
get_bss_ht()only for fixed mode I guess.
Exactly.
Quoted 8 lines
Quoted 5 lines
This should answer your last questions:
When not fixed, the BSSID configuration always is preferred. Thus, we would join as HT40 even though not requested.
So, when we requsted HT40-, but the IBSS is HT40+, we would work on -.? I think I know what you mean but your example seems .. the wrong way around?
Damn, you're right. We would work on HT+, not -, as the BSS config is preferred.
Quoted 10 lines
Quoted 2 lines
I wanted to have the opportunity to start HT on an existing IBSS.
Well that should always be OK?
Quoted 4 lines
The problem is that legacy station may "kill" the HT configuration:
If STA A starts in HT IBSS and lets say Windows STA B joins, B would advertise that IBSS as non-HT as it ignores our HT IE. Then, if STA A dies and STA C joins, it will be non-HT.
Quoted 4 lines
mac80211 is STA C? Would it be a problem to use HT if the IBSS was previously non-HT? The old members will ignore it, but other new HT members may work OK? IOW -- is it not possible to have a mixed HT/non-HT IBSS?
Basically, as to my knowledge, the only difference is that we add HI IEs. Non- HT stations will ignore these, of course.
A mixed network should be no problem - as long as Greenfield is turned off (and i don't turn in on anywhere).
To proceed with basics: I follow a very simple approach (for non-fixed freq):
Use current BSS HT settings. If none exists, use iw config. If no iw config, no HT.
But there may be a chance that a N-Node joins a mixed IBSS without an iw HT setting.
If it joins from a G-Node's beacon, it won't see or use HT.
That is the reason I inspect later incoming beacons for HT settings and reconfigure our beacon skb, when received one. That also resolves the "windows example" above.
Quoted 8 lines
Quoted 6 lines
No, pretty sure not. We *are* already joined. That means the TSFs of all stations *within* our BSSID match. TSFs can only tell whitch BSSID is older...
So there is no way to distinguish which station first joined. Or am i wrong? That would be good in that case :)Oh, no, you're right of course.
As said above, I take *any* HT configuration from *any* beacon and reconfigure our node (first beacon wins).
For two different HT configs it is normally distributed which config would "win". Identifying the first node would help here...
If there were many stations, with different HT configs, joining at the same time, it would take several beacons until the configurations would tilt into a homogeneous one.
If you have a good idea - I'll be eager to hear :)
Quoted 2 lines
johannes
I hope I could make my thoughts somewhat more understandable...
Alex
Re: [PATCH 4/4] mac80211: Add HT operation modes for IBSS
Quoted 27 lines · Alexander Simon
Quoted 2 lines
Ok, that makes sense. So you need the
get_bss_ht()only for fixed mode I guess.Exactly.
Quoted 8 lines
Quoted 5 lines
This should answer your last questions:
When not fixed, the BSSID configuration always is preferred. Thus, we would join as HT40 even though not requested.
So, when we requsted HT40-, but the IBSS is HT40+, we would work on -.? I think I know what you mean but your example seems .. the wrong way around?
Damn, you're right. We would work on HT+, not -, as the BSS config is preferred.
Quoted 10 lines
Quoted 2 lines
I wanted to have the opportunity to start HT on an existing IBSS.
Well that should always be OK?
Quoted 4 lines
The problem is that legacy station may "kill" the HT configuration:
If STA A starts in HT IBSS and lets say Windows STA B joins, B would advertise that IBSS as non-HT as it ignores our HT IE. Then, if STA A dies and STA C joins, it will be non-HT.Quoted 4 lines
mac80211 is STA C? Would it be a problem to use HT if the IBSS was previously non-HT? The old members will ignore it, but other new HT members may work OK? IOW -- is it not possible to have a mixed HT/non-HT IBSS?
Quoted 8 lines
Basically, as to my knowledge, the only difference is that we add HI IEs. Non- HT stations will ignore these, of course.
A mixed network should be no problem - as long as Greenfield is turned off (and i don't turn in on anywhere).To proceed with basics: I follow a very simple approach (for non-fixed freq):
Use current BSS HT settings. If none exists, use iw config. If no iw config, no HT.
What's the point of disabling HT in that case. Since it's a superset of normal A/B/G mode, we could just leave it enabled (defaulting to HT20) instead of reconfiguring based on beacons at a later point in time.
- Felix
Quoted 7 lines · Alexander Simon
Check if the requested HT mode can be used.
Extend cfg80211 IBSS struct for HT mode.Signed-off-by Alexander Simon <[email protected]>---
As there were no replies for my RFC post, i am resending this as PATCH.
This series got a lot of comments. Are you planning to post a revised series?
John
Signature · 2 lines
John W. Linville Someday the world will need a hero, and you [email protected] might be all we have. Be ready.