AP mode channel setting simplification
Johannes Berg
maintainercover AP mode channel setting simplification
Ath6kl stores the channel, while mac80211 tries to immediately apply it. The latter isn't great for multi-channel.
Change cfg80211 to store the channel, and give it to the driver (mac80211, ath6kl, etc.) only in the start_ap() function.
This simplifies ath6kl a lot, and while it doesn't make a difference to mac80211 today I think it'll make it simpler to implement multi-channel.
johannes
Johannes Berg
maintainerPATCH 1/3 mac80211: move ieee80211_set_channel function
From: Johannes Berg <[email protected]>
Move the set_channel function up so it can be used by other code in this file in the future.
--- net/mac80211/cfg.c | 70 ++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 35 deletions(-)
net/mac80211/cfg.c +35 -35
@@ -674,6 +674,41 @@ static int ieee80211_get_station(structreturn ret; } +static int ieee80211_set_channel (struct wiphy *wiphy, +struct net_device *netdev, +struct ieee80211_channel *chan, +enum nl80211_channel_type channel_type) +{ +struct ieee80211_local *local =wiphy_priv (wiphy); +struct ieee80211_sub_if_data *sdata =NULL ; + +if (netdev) + sdata =IEEE80211_DEV_TO_SUB_IF (netdev); + +switch (ieee80211_get_channel_mode (local,NULL )) { +case CHAN_MODE_HOPPING : +return -EBUSY ; +case CHAN_MODE_FIXED : +if (local->oper_channel != chan) +return -EBUSY ; +if (!sdata && local->_oper_channel_type == channel_type) +return 0 ; +break ; +case CHAN_MODE_UNDEFINED : +break ; + } + +if (!ieee80211_set_channel_type (local, sdata, channel_type)) +return -EBUSY ; + + local->oper_channel = chan; + +/* auto-detects changes */ +ieee80211_hw_config (local,0 ); + +return 0 ; +} +static int ieee80211_set_probe_resp (struct ieee80211_sub_if_data *sdata,const u8 *resp,size_t resp_len) {
@@ -1676,41 +1711,6 @@ static int ieee80211_set_txq_params(strureturn 0 ; } - -static int ieee80211_set_channel (struct wiphy *wiphy, -struct net_device *netdev, -struct ieee80211_channel *chan, -enum nl80211_channel_type channel_type) -{ -struct ieee80211_local *local =wiphy_priv (wiphy); -struct ieee80211_sub_if_data *sdata =NULL ; - -if (netdev) - sdata =IEEE80211_DEV_TO_SUB_IF (netdev); - -switch (ieee80211_get_channel_mode (local,NULL )) { -case CHAN_MODE_HOPPING : -return -EBUSY ; -case CHAN_MODE_FIXED : -if (local->oper_channel != chan) -return -EBUSY ; -if (!sdata && local->_oper_channel_type == channel_type) -return 0 ; -break ; -case CHAN_MODE_UNDEFINED : -break ; - } - -if (!ieee80211_set_channel_type (local, sdata, channel_type)) -return -EBUSY ; - - local->oper_channel = chan; - -/* auto-detects changes */ -ieee80211_hw_config (local,0 ); - -return 0 ; -}#ifdef CONFIG_PM static int ieee80211_suspend(struct wiphy *wiphy,
Johannes Berg
maintainerPATCH 2/3 cfg80211: simplify cfg80211_can_beacon_sec_chan API
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
Change cfg80211_can_beacon_sec_chan() to return true if there is no secondary channel to simplify all the current users of it. They all check the channel type before calling the function because it returns false if there's no secondary channel.
Also actually document the return value.
--- include/net/cfg80211.h | 5 ++++- net/mac80211/ibss.c | 3 +-- net/wireless/chan.c | 22 ++++++---------------- 3 files changed, 11 insertions(+), 19 deletions(-)
include/net/cfg80211.h +4 -1
@@ -3359,11 +3359,14 @@ void cfg80211_report_obss_beacon(struct const u8 *frame, size_t len, int freq, int sig_dbm, gfp_t gfp); -/* +/** * cfg80211_can_beacon_sec_chan - test if ht40 on extension channel can be used * @wiphy: the wiphy * @chan: main channel * @channel_type: HT mode +* +* This function returns true if there is no secondary channel or the secondary +* channel can be used for beaconing (i.e. is not a radar channel etc.) */ bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy, struct ieee80211_channel *chan,
net/mac80211/ibss.c +1 -2
@@ -82,8 +82,7 @@ static void __ieee80211_sta_join_ibss(st local->oper_channel = chan; channel_type = ifibss->channel_type; -if (channel_type >NL80211_CHAN_HT20 && - !cfg80211_can_beacon_sec_chan (local->hw.wiphy, chan, channel_type)) +if (!cfg80211_can_beacon_sec_chan (local->hw.wiphy, chan, channel_type)) channel_type =NL80211_CHAN_HT20 ;if (!ieee80211_set_channel_type (local, sdata, channel_type)) {/* can only fail due to HT40+/- mismatch */
net/wireless/chan.c +6 -16
@@ -60,7 +60,7 @@ bool cfg80211_can_beacon_sec_chan(struct diff =-20 ;break ;default : -return false; +return true; } sec_chan =ieee80211_get_channel (wiphy, chan->center_freq + diff);
@@ -107,21 +107,11 @@ int cfg80211_set_freq(struct cfg80211_re wdev->iftype == NL80211_IFTYPE_AP || wdev->iftype == NL80211_IFTYPE_AP_VLAN || wdev->iftype == NL80211_IFTYPE_MESH_POINT || - wdev->iftype == NL80211_IFTYPE_P2P_GO)) { -switch (channel_type) { -case NL80211_CHAN_HT40PLUS : -case NL80211_CHAN_HT40MINUS : -if (!cfg80211_can_beacon_sec_chan (&rdev->wiphy, chan, - channel_type)) { -printk (KERN_DEBUG -"cfg80211: Secondary channel not " -"allowed to initiate communication\n" ); -return -EINVAL ; - } -break ; -default : -break ; - } + wdev->iftype == NL80211_IFTYPE_P2P_GO) && + !cfg80211_can_beacon_sec_chan(&rdev->wiphy, chan, channel_type)) { +printk (KERN_DEBUG +"cfg80211: Secondary channel not allowed to beacon\n" ); +return -EINVAL ; } result = rdev->ops->set_channel(&rdev->wiphy,
Johannes Berg
maintainerPATCH 3/3 cfg80211: provide channel to start_ap function
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
Instead of setting the channel first and then starting the AP, let cfg80211 store the channel and provide it as one of the AP settings.
This means that now you have to set the channel before you can start an AP interface, but since hostapd/wpa_supplicant always do that we're OK with this change.
Alternatively, it's now possible to give the channel as an attribute to the start-ap nl80211 command, overriding any preset channel.
--- drivers/net/wireless/ath/ath6kl/cfg80211.c | 36 +--------------------- drivers/net/wireless/ath/ath6kl/core.h | 3 - include/linux/nl80211.h | 2 + include/net/cfg80211.h | 12 ++++++- net/mac80211/cfg.c | 5 +++ net/wireless/nl80211.c | 47 ++++++++++++++++++++++++++++- 6 files changed, 67 insertions(+), 38 deletions(-)
include/net/cfg80211.h +11 -1
@@ -404,6 +404,8 @@ struct cfg80211_beacon_data {* * Used to configure an AP interface. * +* @channel: the channel to start the AP on +* @channel_type: the channel type to use * @beacon: beacon data * @beacon_interval: beacon interval * @dtim_period: DTIM period
@@ -417,6 +419,9 @@ struct cfg80211_beacon_data {* @inactivity_timeout: time in seconds to determine station's inactivity. */ struct cfg80211_ap_settings { +struct ieee80211_channel *channel; +enum nl80211_channel_type channel_type; +struct cfg80211_beacon_data beacon;int beacon_interval, dtim_period;
@@ -2263,7 +2268,10 @@ struct cfg80211_cached_keys;* @netdev: (private) Used to reference back to the netdev * @current_bss: (private) Used by the internal configuration code * @channel: (private) Used by the internal configuration code to track -* user-set AP, monitor and WDS channels for wireless extensions +* the user-set AP, monitor and WDS channel +* @preset_chan: (private) Used by the internal configuration code to +* track the channel to be used for AP later +* @preset_chantype: (private) the corresponding channel type * @bssid: (private) Used by the internal configuration code * @ssid: (private) Used by the internal configuration code * @ssid_len: (private) Used by the internal configuration code
@@ -2314,6 +2322,8 @@ struct wireless_dev {struct cfg80211_internal_bss *current_bss;/* associated / joined */ struct ieee80211_channel *channel; +struct ieee80211_channel *preset_chan; +enum nl80211_channel_type preset_chantype;bool ps;int ps_timeout;
net/wireless/nl80211.c +46 -1
71 lines not on this page · raw message
include/linux/nl80211.h +2 -0
@@ -170,6 +170,8 @@* %NL80211_ATTR_CIPHER_GROUP, %NL80211_ATTR_WPA_VERSIONS, * %NL80211_ATTR_AKM_SUITES, %NL80211_ATTR_PRIVACY, * %NL80211_ATTR_AUTH_TYPE and %NL80211_ATTR_INACTIVITY_TIMEOUT. +* The channel to use can be set on the interface or be given using the +* %NL80211_ATTR_WIPHY_FREQ and %NL80211_ATTR_WIPHY_CHANNEL_TYPE attrs. * @NL80211_CMD_NEW_BEACON: old alias for %NL80211_CMD_START_AP * @NL80211_CMD_STOP_AP: Stop AP operation on the given interface * @NL80211_CMD_DEL_BEACON: old alias for %NL80211_CMD_STOP_AP
drivers/net/wireless/ath/ath6kl/cfg80211.c +3 -33
@@ -2521,35 +2521,6 @@ static int ath6kl_set_ies(struct ath6kl_return 0 ; } -static int ath6kl_set_channel (struct wiphy *wiphy,struct net_device *dev, -struct ieee80211_channel *chan, -enum nl80211_channel_type channel_type) -{ -struct ath6kl_vif *vif; - -/* -* 'dev' could be NULL if a channel change is required for the hardware -* device itself, instead of a particular VIF. -* -* FIXME: To be handled properly when monitor mode is supported. -*/ -if (!dev) -return -EBUSY ; - - vif =netdev_priv (dev); - -if (!ath6kl_cfg80211_ready (vif)) -return -EIO ; - -ath6kl_dbg (ATH6KL_DBG_WLAN_CFG ,"%s: center_freq=%u hw_value=%u\n" , - __func__, chan->center_freq, chan->hw_value); - vif->next_chan = chan->center_freq; - vif->next_ch_type = channel_type; - vif->next_ch_band = chan->band; - -return 0 ; -} -static int ath6kl_get_rsn_capab (struct cfg80211_beacon_data *beacon,u8 *rsn_capab) {
@@ -2721,7 +2692,7 @@ static int ath6kl_start_ap(struct wiphy p.ssid_len = vif->ssid_len;memcpy (p.ssid, vif->ssid, vif->ssid_len); p.dot11_auth_mode = vif->dot11_auth_mode; - p.ch =cpu_to_le16 (vif->next_chan); + p.ch =cpu_to_le16 (info->channel->center_freq);/* Enable uAPSD support by default */ res =ath6kl_wmi_ap_set_apsd (ar->wmi, vif->fw_vif_idx, true);
@@ -2745,8 +2716,8 @@ static int ath6kl_start_ap(struct wiphyreturn res; } -if (ath6kl_set_htcap (vif, vif->next_ch_band, - vif->next_ch_type !=NL80211_CHAN_NO_HT )) +if (ath6kl_set_htcap (vif, info->channel->band, + info->channel_type !=NL80211_CHAN_NO_HT ))return -EIO ;/*
@@ -3213,7 +3184,6 @@ static struct cfg80211_ops ath6kl_cfg802 .suspend = __ath6kl_cfg80211_suspend, .resume = __ath6kl_cfg80211_resume, #endif - .set_channel = ath6kl_set_channel, .start_ap = ath6kl_start_ap, .change_beacon = ath6kl_change_beacon, .stop_ap = ath6kl_stop_ap,
drivers/net/wireless/ath/ath6kl/core.h +0 -3
@@ -543,9 +543,6 @@ struct ath6kl_vif {u32 last_cancel_roc_id;u32 send_action_id;bool probe_req_report; -u16 next_chan; -enum nl80211_channel_type next_ch_type; -enum ieee80211_band next_ch_band;u16 assoc_bss_beacon_int;u16 listen_intvl_t;u16 bmiss_time_t;
net/mac80211/cfg.c +5 -0
@@ -823,6 +823,11 @@ static int ieee80211_start_ap(struct wipif (old)return -EALREADY ; + err =ieee80211_set_channel (wiphy, dev, params->channel, + params->channel_type); +if (err) +return err; +/* * Apply control port protocol, this allows us to * not encrypt dynamic WEP control frames.
Re: [PATCH 3/3] cfg80211: provide channel to start_ap function
Quoted 11 lines · Johannes Berg
From: Johannes Berg <[email protected]>
Instead of setting the channel first and then starting the AP, let cfg80211 store the channel and provide it as one of the AP settings.
This means that now you have to set the channel before you can start an AP interface, but since hostapd/wpa_supplicant always do that we're OK with this change.
Quoted 6 lines
Alternatively, it's now possible to give the channel as an attribute to the start-ap nl80211 command, overriding any preset channel.
Cc Kalle Valo <[email protected]>Signed-off-by Johannes Berg <[email protected]>
For the ath6kl part:
Kalle
Quoted 8 lines · Johannes Berg
Ath6kl stores the channel, while mac80211 tries to immediately apply it. The latter isn't great for multi-channel.
Change cfg80211 to store the channel, and give it to the driver (mac80211, ath6kl, etc.) only in the
start_ap()function.
Quoted 5 lines
This simplifies ath6kl a lot, and while it doesn't make a difference to mac80211 today I think it'll make it simpler to implement multi-channel.
johannes
I had some trouble with applying at least 1/3, so I skipped this batch as well.
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.