nl80211: Parse channel type attribute in an IBSS join request
Subsystems (2)
RFC v4 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.
--- 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
Re: [RFC v4 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
Re: [RFC v4 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
Re: [RFC v4 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