mac80211 mlme cleanups
Subsystems (2)
Johannes Berg
maintainercover mac80211 mlme cleanups
Mostly cleanups and moving code into two new files, scan.c and ht.c. mlme.c and main.c each lose a few hundred lines making them more maintainable.
johannes
Johannes Berg
maintainerPATCH 1/8 mac80211: reorder mlme code
This reorders the mlme code a bit so we don't need all the forward function declarations. It also removes the ERP_INFO_USE_PROTECTION define that is unused, but otherwise contains no real changes.
--- net/mac80211/mlme.c | 1224 +++++++++++++++++++++++++--------------------------- 1 file changed, 597 insertions(+), 627 deletions(-)
net/mac80211/mlme.c +597 -627
@@ -26,9 +26,8 @@#include <linux/etherdevice.h> #include <linux/rtnetlink.h> #include <net/iw_handler.h> -#include <asm/types.h> -#include <net/mac80211.h> +#include "ieee80211_i.h" #include "rate.h" #include "led.h"
@@ -58,8 +57,6 @@#define IEEE80211_IBSS_MAX_STA_ENTRIES 128 -#define ERP_INFO_USE_PROTECTION BIT(1) -/* mgmt header + 1 byte category code */ #define IEEE80211_MIN_ACTION_SIZE (24 + 1)
@@ -74,24 +71,199 @@#define IEEE80211_MIN_AMPDU_BUF 0x8#define IEEE80211_MAX_AMPDU_BUF 0x40 -static void ieee80211_send_probe_req (struct ieee80211_sub_if_data *sdata,u8 *dst, -u8 *ssid,size_t ssid_len); +/* BSS handling */ static struct ieee80211_sta_bss *ieee80211_rx_bss_get (struct ieee80211_local *local,u8 *bssid,int freq, -u8 *ssid,u8 ssid_len); +u8 *ssid,u8 ssid_len) +{ +struct ieee80211_sta_bss *bss; + +spin_lock_bh (&local->sta_bss_lock); + bss = local->sta_bss_hash[STA_HASH (bssid)]; +while (bss) { +if (!bss_mesh_cfg (bss) && + !memcmp (bss->bssid, bssid,ETH_ALEN ) && + bss->freq == freq && + bss->ssid_len == ssid_len && + (ssid_len ==0 || !memcmp (bss->ssid, ssid, ssid_len))) { +atomic_inc (&bss->users); +break ; + } + bss = bss->hnext; + } +spin_unlock_bh (&local->sta_bss_lock); +return bss; +} + +/* Caller must hold local->sta_bss_lock */ +static void __ieee80211_rx_bss_hash_add (struct ieee80211_local *local, +struct ieee80211_sta_bss *bss) +{ +u8 hash_idx; + +if (bss_mesh_cfg (bss)) + hash_idx =mesh_id_hash (bss_mesh_id (bss), +bss_mesh_id_len (bss)); +else + hash_idx =STA_HASH (bss->bssid); + + bss->hnext = local->sta_bss_hash[hash_idx]; + local->sta_bss_hash[hash_idx] = bss; +} + +/* Caller must hold local->sta_bss_lock */ +static void __ieee80211_rx_bss_hash_del (struct ieee80211_local *local, +struct ieee80211_sta_bss *bss) +{ +struct ieee80211_sta_bss *b, *prev =NULL ; + b = local->sta_bss_hash[STA_HASH (bss->bssid)]; +while (b) { +if (b == bss) { +if (!prev) + local->sta_bss_hash[STA_HASH (bss->bssid)] = + bss->hnext; +else + prev->hnext = bss->hnext; +break ; + } + prev = b; + b = b->hnext; + } +} + +static struct ieee80211_sta_bss * +ieee80211_rx_bss_add (struct ieee80211_sub_if_data *sdata,u8 *bssid,int freq, +u8 *ssid,u8 ssid_len) +{ +struct ieee80211_local *local = sdata->local; +struct ieee80211_sta_bss *bss; + + bss =kzalloc (sizeof (*bss),GFP_ATOMIC ); +if (!bss) +return NULL ; +atomic_inc (&bss->users); +atomic_inc (&bss->users); +memcpy (bss->bssid, bssid,ETH_ALEN ); + bss->freq = freq; +if (ssid && ssid_len <=IEEE80211_MAX_SSID_LEN ) { +memcpy (bss->ssid, ssid, ssid_len); + bss->ssid_len = ssid_len; + } + +spin_lock_bh (&local->sta_bss_lock); +/* TODO: order by RSSI? */ +list_add_tail (&bss->list, &local->sta_bss_list); +__ieee80211_rx_bss_hash_add (local, bss); +spin_unlock_bh (&local->sta_bss_lock); +return bss; +} + +#ifdef CONFIG_MAC80211_MESH +static struct ieee80211_sta_bss * +ieee80211_rx_mesh_bss_get (struct ieee80211_local *local,u8 *mesh_id,int mesh_id_len, +u8 *mesh_cfg,int freq) +{ +struct ieee80211_sta_bss *bss; + +spin_lock_bh (&local->sta_bss_lock); + bss = local->sta_bss_hash[mesh_id_hash (mesh_id, mesh_id_len)]; +while (bss) { +if (bss_mesh_cfg (bss) && + !memcmp (bss_mesh_cfg (bss), mesh_cfg,MESH_CFG_CMP_LEN ) && + bss->freq == freq && + mesh_id_len == bss->mesh_id_len && + (mesh_id_len ==0 || !memcmp (bss->mesh_id, mesh_id, + mesh_id_len))) { +atomic_inc (&bss->users); +break ; + } + bss = bss->hnext; + } +spin_unlock_bh (&local->sta_bss_lock); +return bss; +} + +static struct ieee80211_sta_bss * +ieee80211_rx_mesh_bss_add (struct ieee80211_local *local,u8 *mesh_id,int mesh_id_len, +u8 *mesh_cfg,int mesh_config_len,int freq) +{ +struct ieee80211_sta_bss *bss; + +if (mesh_config_len !=MESH_CFG_LEN ) +return NULL ; + + bss =kzalloc (sizeof (*bss),GFP_ATOMIC ); +if (!bss) +return NULL ; + + bss->mesh_cfg =kmalloc (MESH_CFG_CMP_LEN ,GFP_ATOMIC ); +if (!bss->mesh_cfg) { +kfree (bss); +return NULL ; + } + +if (mesh_id_len && mesh_id_len <=IEEE80211_MAX_MESH_ID_LEN ) { + bss->mesh_id =kmalloc (mesh_id_len,GFP_ATOMIC ); +if (!bss->mesh_id) { +kfree (bss->mesh_cfg); +kfree (bss); +return NULL ; + } +memcpy (bss->mesh_id, mesh_id, mesh_id_len); + } + +atomic_inc (&bss->users); +atomic_inc (&bss->users); +memcpy (bss->mesh_cfg, mesh_cfg,MESH_CFG_CMP_LEN ); + bss->mesh_id_len = mesh_id_len; + bss->freq = freq; +spin_lock_bh (&local->sta_bss_lock); +/* TODO: order by RSSI? */ +list_add_tail (&bss->list, &local->sta_bss_list); +__ieee80211_rx_bss_hash_add (local, bss); +spin_unlock_bh (&local->sta_bss_lock); +return bss; +} +#endif + +static void ieee80211_rx_bss_free (struct ieee80211_sta_bss *bss) +{ +kfree (bss->ies); +kfree (bss_mesh_id (bss)); +kfree (bss_mesh_cfg (bss)); +kfree (bss); +} +static void ieee80211_rx_bss_put (struct ieee80211_local *local, -struct ieee80211_sta_bss *bss); -static int ieee80211_sta_find_ibss (struct ieee80211_sub_if_data *sdata, -struct ieee80211_if_sta *ifsta); -static int ieee80211_sta_wep_configured (struct ieee80211_sub_if_data *sdata); -static int ieee80211_sta_start_scan (struct ieee80211_sub_if_data *sdata, -u8 *ssid,size_t ssid_len); -static int ieee80211_sta_config_auth (struct ieee80211_sub_if_data *sdata, -struct ieee80211_if_sta *ifsta); -static void sta_rx_agg_session_timer_expired (unsigned long data); +struct ieee80211_sta_bss *bss) +{ +local_bh_disable (); +if (!atomic_dec_and_lock (&bss->users, &local->sta_bss_lock)) { +local_bh_enable (); +return ; + } + +__ieee80211_rx_bss_hash_del (local, bss); +list_del (&bss->list); +spin_unlock_bh (&local->sta_bss_lock); +ieee80211_rx_bss_free (bss); +} +void ieee80211_rx_bss_list_init (struct ieee80211_local *local) +{ +spin_lock_init (&local->sta_bss_lock); +INIT_LIST_HEAD (&local->sta_bss_list); +} + +void ieee80211_rx_bss_list_deinit (struct ieee80211_local *local) +{ +struct ieee80211_sta_bss *bss, *tmp; -static u8 *ieee80211_bss_get_ie (struct ieee80211_sta_bss *bss,u8 ie) +list_for_each_entry_safe (bss, tmp, &local->sta_bss_list, list) +ieee80211_rx_bss_put (local, bss); +} + +static u8 *ieee80211_bss_get_ie (struct ieee80211_sta_bss *bss,u8 ie) {u8 *end, *pos;
@@ -111,13 +283,125 @@ static u8 * ieee80211_bss_get_ie(structreturn NULL ; } - +/* utils */ static int ecw2cw (int ecw) {return (1 << ecw) -1 ; } +/* frame sending functions */ +void ieee80211_sta_tx (struct ieee80211_sub_if_data *sdata,struct sk_buff *skb, +int encrypt) +{ + skb->dev = sdata->local->mdev; +skb_set_mac_header (skb,0 ); +skb_set_network_header (skb,0 ); +skb_set_transport_header (skb,0 ); + skb->iif = sdata->dev->ifindex; + skb->do_not_encrypt = !encrypt; + +dev_queue_xmit (skb); +} + +static void ieee80211_send_auth (struct ieee80211_sub_if_data *sdata, +struct ieee80211_if_sta *ifsta, +int transaction,u8 *extra,size_t extra_len, +int encrypt) +{ +struct ieee80211_local *local = sdata->local; +struct sk_buff *skb; +struct ieee80211_mgmt *mgmt; + + skb =dev_alloc_skb (local->hw.extra_tx_headroom + +sizeof (*mgmt) +6 + extra_len); +if (!skb) { +printk (KERN_DEBUG "%s: failed to allocate buffer for auth " +"frame\n" , sdata->dev->name); +return ; + } +skb_reserve (skb, local->hw.extra_tx_headroom); + + mgmt = (struct ieee80211_mgmt *)skb_put (skb,24 +6 ); +memset (mgmt,0 ,24 +6 ); + mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | +IEEE80211_STYPE_AUTH ); +if (encrypt) + mgmt->frame_control |=cpu_to_le16 (IEEE80211_FCTL_PROTECTED ); +memcpy (mgmt->da, ifsta->bssid,ETH_ALEN ); +memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN ); +memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); + mgmt->u.auth.auth_alg =cpu_to_le16 (ifsta->auth_alg); + mgmt->u.auth.auth_transaction =cpu_to_le16 (transaction); + ifsta->auth_transaction = transaction +1 ; + mgmt->u.auth.status_code =cpu_to_le16 (0 ); +if (extra) +memcpy (skb_put (skb, extra_len), extra, extra_len); + +ieee80211_sta_tx (sdata, skb, encrypt); +} + +static void ieee80211_send_probe_req (struct ieee80211_sub_if_data *sdata,u8 *dst, +u8 *ssid,size_t ssid_len) +{ +struct ieee80211_local *local = sdata->local; +struct ieee80211_supported_band *sband; +struct sk_buff *skb; +struct ieee80211_mgmt *mgmt; +u8 *pos, *supp_rates, *esupp_rates =NULL ; +int i; + + skb =dev_alloc_skb (local->hw.extra_tx_headroom +sizeof (*mgmt) +200 ); +if (!skb) { +printk (KERN_DEBUG "%s: failed to allocate buffer for probe " +"request\n" , sdata->dev->name); +return ; + } +skb_reserve (skb, local->hw.extra_tx_headroom); + + mgmt = (struct ieee80211_mgmt *)skb_put (skb,24 ); +memset (mgmt,0 ,24 ); + mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | +IEEE80211_STYPE_PROBE_REQ ); +memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN ); +if (dst) { +memcpy (mgmt->da, dst,ETH_ALEN ); +memcpy (mgmt->bssid, dst,ETH_ALEN ); + }else { +memset (mgmt->da,0xff ,ETH_ALEN ); +memset (mgmt->bssid,0xff ,ETH_ALEN ); + } + pos =skb_put (skb,2 + ssid_len); + *pos++ =WLAN_EID_SSID ; + *pos++ = ssid_len; +memcpy (pos, ssid, ssid_len); + + supp_rates =skb_put (skb,2 ); + supp_rates[0 ] =WLAN_EID_SUPP_RATES ; + supp_rates[1 ] =0 ; + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; + +for (i =0 ; i < sband->n_bitrates; i++) { +struct ieee80211_rate *rate = &sband->bitrates[i]; +if (esupp_rates) { + pos =skb_put (skb,1 ); + esupp_rates[1 ]++; + }else if (supp_rates[1 ] ==8 ) { + esupp_rates =skb_put (skb,3 ); + esupp_rates[0 ] =WLAN_EID_EXT_SUPP_RATES ; + esupp_rates[1 ] =1 ; + pos = &esupp_rates[2 ]; + }else { + pos =skb_put (skb,1 ); + supp_rates[1 ]++; + } + *pos = rate->bitrate /5 ; + } + +ieee80211_sta_tx (sdata, skb,0 ); +} + +/* MLME */ static void ieee80211_sta_def_wmm_params (struct ieee80211_sub_if_data *sdata,struct ieee80211_sta_bss *bss,int ibss)
@@ -435,58 +719,6 @@ static void ieee80211_set_associated(strieee80211_sta_send_apinfo (sdata, ifsta); } -void ieee80211_sta_tx (struct ieee80211_sub_if_data *sdata,struct sk_buff *skb, -int encrypt) -{ - skb->dev = sdata->local->mdev; -skb_set_mac_header (skb,0 ); -skb_set_network_header (skb,0 ); -skb_set_transport_header (skb,0 ); - - skb->iif = sdata->dev->ifindex; - skb->do_not_encrypt = !encrypt; - -dev_queue_xmit (skb); -} - - -static void ieee80211_send_auth (struct ieee80211_sub_if_data *sdata, -struct ieee80211_if_sta *ifsta, -int transaction,u8 *extra,size_t extra_len, -int encrypt) -{ -struct ieee80211_local *local = sdata->local; -struct sk_buff *skb; -struct ieee80211_mgmt *mgmt; - - skb =dev_alloc_skb (local->hw.extra_tx_headroom + -sizeof (*mgmt) +6 + extra_len); -if (!skb) { -printk (KERN_DEBUG "%s: failed to allocate buffer for auth " -"frame\n" , sdata->dev->name); -return ; - } -skb_reserve (skb, local->hw.extra_tx_headroom); - - mgmt = (struct ieee80211_mgmt *)skb_put (skb,24 +6 ); -memset (mgmt,0 ,24 +6 ); - mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | -IEEE80211_STYPE_AUTH ); -if (encrypt) - mgmt->frame_control |=cpu_to_le16 (IEEE80211_FCTL_PROTECTED ); -memcpy (mgmt->da, ifsta->bssid,ETH_ALEN ); -memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN ); -memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); - mgmt->u.auth.auth_alg =cpu_to_le16 (ifsta->auth_alg); - mgmt->u.auth.auth_transaction =cpu_to_le16 (transaction); - ifsta->auth_transaction = transaction +1 ; - mgmt->u.auth.status_code =cpu_to_le16 (0 ); -if (extra) -memcpy (skb_put (skb, extra_len), extra, extra_len); - -ieee80211_sta_tx (sdata, skb, encrypt); -} -static void ieee80211_direct_probe (struct ieee80211_sub_if_data *sdata,struct ieee80211_if_sta *ifsta) {
@@ -799,6 +1031,13 @@ static void ieee80211_send_deauth(structieee80211_sta_tx (sdata, skb,0 ); } +static int ieee80211_sta_wep_configured (struct ieee80211_sub_if_data *sdata) +{ +if (!sdata || !sdata->default_key || + sdata->default_key->conf.alg !=ALG_WEP ) +return 0 ; +return 1 ; +}static void ieee80211_send_disassoc (struct ieee80211_sub_if_data *sdata,struct ieee80211_if_sta *ifsta,u16 reason)
@@ -918,7 +1157,6 @@ static int ieee80211_privacy_mismatch(streturn 1 ; } -static void ieee80211_associate (struct ieee80211_sub_if_data *sdata,struct ieee80211_if_sta *ifsta) {
@@ -1000,82 +1238,12 @@ static void ieee80211_associated(structrcu_read_unlock (); -if (disassoc) -ieee80211_set_disassoc (sdata, ifsta, true, true, -WLAN_REASON_PREV_AUTH_NOT_VALID ); -else -mod_timer (&ifsta->timer, jiffies + -IEEE80211_MONITORING_INTERVAL ); -} - - -static void ieee80211_send_probe_req (struct ieee80211_sub_if_data *sdata,u8 *dst, -u8 *ssid,size_t ssid_len) -{ -struct ieee80211_local *local = sdata->local; -struct ieee80211_supported_band *sband; -struct sk_buff *skb; -struct ieee80211_mgmt *mgmt; -u8 *pos, *supp_rates, *esupp_rates =NULL ; -int i; - - skb =dev_alloc_skb (local->hw.extra_tx_headroom +sizeof (*mgmt) +200 ); -if (!skb) { -printk (KERN_DEBUG "%s: failed to allocate buffer for probe " -"request\n" , sdata->dev->name); -return ; - } -skb_reserve (skb, local->hw.extra_tx_headroom); - - mgmt = (struct ieee80211_mgmt *)skb_put (skb,24 ); -memset (mgmt,0 ,24 ); - mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | -IEEE80211_STYPE_PROBE_REQ ); -memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN ); -if (dst) { -memcpy (mgmt->da, dst,ETH_ALEN ); -memcpy (mgmt->bssid, dst,ETH_ALEN ); - }else { -memset (mgmt->da,0xff ,ETH_ALEN ); -memset (mgmt->bssid,0xff ,ETH_ALEN ); - } - pos =skb_put (skb,2 + ssid_len); - *pos++ =WLAN_EID_SSID ; - *pos++ = ssid_len; -memcpy (pos, ssid, ssid_len); - - supp_rates =skb_put (skb,2 ); - supp_rates[0 ] =WLAN_EID_SUPP_RATES ; - supp_rates[1 ] =0 ; - sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; - -for (i =0 ; i < sband->n_bitrates; i++) { -struct ieee80211_rate *rate = &sband->bitrates[i]; -if (esupp_rates) { - pos =skb_put (skb,1 ); - esupp_rates[1 ]++; - }else if (supp_rates[1 ] ==8 ) { - esupp_rates =skb_put (skb,3 ); - esupp_rates[0 ] =WLAN_EID_EXT_SUPP_RATES ; - esupp_rates[1 ] =1 ; - pos = &esupp_rates[2 ]; - }else { - pos =skb_put (skb,1 ); - supp_rates[1 ]++; - } - *pos = rate->bitrate /5 ; - } - -ieee80211_sta_tx (sdata, skb,0 ); -} - - -static int ieee80211_sta_wep_configured (struct ieee80211_sub_if_data *sdata) -{ -if (!sdata || !sdata->default_key || - sdata->default_key->conf.alg !=ALG_WEP ) -return 0 ; -return 1 ; +if (disassoc) +ieee80211_set_disassoc (sdata, ifsta, true, true, +WLAN_REASON_PREV_AUTH_NOT_VALID ); +else +mod_timer (&ifsta->timer, jiffies + +IEEE80211_MONITORING_INTERVAL ); }
@@ -1201,6 +1369,30 @@ void ieee80211_send_addba_request(structieee80211_sta_tx (sdata, skb,0 ); } +/* +* After accepting the AddBA Request we activated a timer, +* resetting it after each frame that arrives from the originator. +* if this timer expires ieee80211_sta_stop_rx_ba_session will be executed. +*/ +static void sta_rx_agg_session_timer_expired (unsigned long data) +{ +/* not an elegant detour, but there is no choice as the timer passes +* only one argument, and various sta_info are needed here, so init +* flow in sta_info_create gives the TID as data, while the timer_to_id +* array gives the sta through container_of */ +u8 *ptid = (u8 *)data; +u8 *timer_to_id = ptid - *ptid; + struct sta_info *sta = container_of(timer_to_id, struct sta_info, + timer_to_tid[0 ]); + +#ifdef CONFIG_MAC80211_HT_DEBUG +printk (KERN_DEBUG "rx session timer expired on tid %d\n" , (u16)*ptid); +#endif +ieee80211_sta_stop_rx_ba_session (sta->sdata, sta->addr, + (u16)*ptid,WLAN_BACK_TIMER , +WLAN_REASON_QSTA_TIMEOUT ); +} +static void ieee80211_sta_process_addba_request (struct ieee80211_local *local,struct ieee80211_mgmt *mgmt,size_t len)
@@ -1647,30 +1839,6 @@ timer_expired_exit:rcu_read_unlock (); } -/* -* After accepting the AddBA Request we activated a timer, -* resetting it after each frame that arrives from the originator. -* if this timer expires ieee80211_sta_stop_rx_ba_session will be executed. -*/ -static void sta_rx_agg_session_timer_expired (unsigned long data) -{ -/* not an elegant detour, but there is no choice as the timer passes -* only one argument, and various sta_info are needed here, so init -* flow in sta_info_create gives the TID as data, while the timer_to_id -* array gives the sta through container_of */ -u8 *ptid = (u8 *)data; -u8 *timer_to_id = ptid - *ptid; - struct sta_info *sta = container_of(timer_to_id, struct sta_info, - timer_to_tid[0 ]); - -#ifdef CONFIG_MAC80211_HT_DEBUG -printk (KERN_DEBUG "rx session timer expired on tid %d\n" , (u16)*ptid); -#endif -ieee80211_sta_stop_rx_ba_session (sta->sdata, sta->addr, - (u16)*ptid,WLAN_BACK_TIMER , -WLAN_REASON_QSTA_TIMEOUT ); -} -void ieee80211_sta_tear_down_BA_sessions (struct ieee80211_sub_if_data *sdata,u8 *addr) {struct ieee80211_local *local = sdata->local;
@@ -1992,308 +2160,111 @@ static void ieee80211_rx_mgmt_assoc_resprcu_read_unlock ();return ; } - bss =ieee80211_rx_bss_get (local, ifsta->bssid, - local->hw.conf.channel->center_freq, - ifsta->ssid, ifsta->ssid_len); -if (bss) { - sta->last_signal = bss->signal; - sta->last_qual = bss->qual; - sta->last_noise = bss->noise; -ieee80211_rx_bss_put (local, bss); - } - - err =sta_info_insert (sta); -if (err) { -printk (KERN_DEBUG "%s: failed to insert STA entry for" -" the AP (error %d)\n" , sdata->dev->name, err); -rcu_read_unlock (); -return ; - } -/* update new sta with its last rx activity */ - sta->last_rx = jiffies; - } - -/* -* FIXME: Do we really need to update the sta_info's information here? -* We already know about the AP (we found it in our list) so it -* should already be filled with the right info, no? -* As is stands, all this is racy because typically we assume -* the information that is filled in here (except flags) doesn't -* change while a STA structure is alive. As such, it should move -* to between the sta_info_alloc() and sta_info_insert() above. -*/ - -set_sta_flags (sta,WLAN_STA_AUTH |WLAN_STA_ASSOC |WLAN_STA_ASSOC_AP | -WLAN_STA_AUTHORIZED ); - - rates =0 ; - basic_rates =0 ; - sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; - -for (i =0 ; i < elems.supp_rates_len; i++) { -int rate = (elems.supp_rates[i] &0x7f ) *5 ; - -if (rate >110 ) - have_higher_than_11mbit = true; - -for (j =0 ; j < sband->n_bitrates; j++) { -if (sband->bitrates[j].bitrate == rate) - rates |=BIT (j); -if (elems.supp_rates[i] &0x80 ) - basic_rates |=BIT (j); - } - } - -for (i =0 ; i < elems.ext_supp_rates_len; i++) { -int rate = (elems.ext_supp_rates[i] &0x7f ) *5 ; - -if (rate >110 ) - have_higher_than_11mbit = true; - -for (j =0 ; j < sband->n_bitrates; j++) { -if (sband->bitrates[j].bitrate == rate) - rates |=BIT (j); -if (elems.ext_supp_rates[i] &0x80 ) - basic_rates |=BIT (j); - } - } - - sta->supp_rates[local->hw.conf.channel->band] = rates; - sdata->basic_rates = basic_rates; - -/* cf. IEEE 802.11 9.2.12 */ -if (local->hw.conf.channel->band ==IEEE80211_BAND_2GHZ && - have_higher_than_11mbit) - sdata->flags |=IEEE80211_SDATA_OPERATING_GMODE ; -else - sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE ; - -if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param && - (ifsta->flags &IEEE80211_STA_WMM_ENABLED )) { -struct ieee80211_ht_bss_info bss_info; -ieee80211_ht_cap_ie_to_ht_info ( - (struct ieee80211_ht_cap *) - elems.ht_cap_elem, &sta->ht_info); -ieee80211_ht_addt_info_ie_to_ht_bss_info ( - (struct ieee80211_ht_addt_info *) - elems.ht_info_elem, &bss_info); -ieee80211_handle_ht (local,1 , &sta->ht_info, &bss_info); - } - -rate_control_rate_init (sta, local); - -if (elems.wmm_param) { -set_sta_flags (sta,WLAN_STA_WME ); -rcu_read_unlock (); -ieee80211_sta_wmm_params (local, ifsta, elems.wmm_param, - elems.wmm_param_len); - }else -rcu_read_unlock (); - -/* set AID and assoc capability, -* ieee80211_set_associated() will tell the driver */ - bss_conf->aid = aid; - bss_conf->assoc_capability = capab_info; -ieee80211_set_associated (sdata, ifsta); - -ieee80211_associated (sdata, ifsta); -} - - -/* Caller must hold local->sta_bss_lock */ -static void __ieee80211_rx_bss_hash_add (struct ieee80211_local *local, -struct ieee80211_sta_bss *bss) -{ -u8 hash_idx; - -if (bss_mesh_cfg (bss)) - hash_idx =mesh_id_hash (bss_mesh_id (bss), -bss_mesh_id_len (bss)); -else - hash_idx =STA_HASH (bss->bssid); - - bss->hnext = local->sta_bss_hash[hash_idx]; - local->sta_bss_hash[hash_idx] = bss; -} - - -/* Caller must hold local->sta_bss_lock */ -static void __ieee80211_rx_bss_hash_del (struct ieee80211_local *local, -struct ieee80211_sta_bss *bss) -{ -struct ieee80211_sta_bss *b, *prev =NULL ; - b = local->sta_bss_hash[STA_HASH (bss->bssid)]; -while (b) { -if (b == bss) { -if (!prev) - local->sta_bss_hash[STA_HASH (bss->bssid)] = - bss->hnext; -else - prev->hnext = bss->hnext; -break ; - } - prev = b; - b = b->hnext; - } -} - - -static struct ieee80211_sta_bss * -ieee80211_rx_bss_add (struct ieee80211_sub_if_data *sdata,u8 *bssid,int freq, -u8 *ssid,u8 ssid_len) -{ -struct ieee80211_local *local = sdata->local; -struct ieee80211_sta_bss *bss; - - bss =kzalloc (sizeof (*bss),GFP_ATOMIC ); -if (!bss) -return NULL ; -atomic_inc (&bss->users); -atomic_inc (&bss->users); -memcpy (bss->bssid, bssid,ETH_ALEN ); - bss->freq = freq; -if (ssid && ssid_len <=IEEE80211_MAX_SSID_LEN ) { -memcpy (bss->ssid, ssid, ssid_len); - bss->ssid_len = ssid_len; - } - -spin_lock_bh (&local->sta_bss_lock); -/* TODO: order by RSSI? */ -list_add_tail (&bss->list, &local->sta_bss_list); -__ieee80211_rx_bss_hash_add (local, bss); -spin_unlock_bh (&local->sta_bss_lock); -return bss; -} - -static struct ieee80211_sta_bss * -ieee80211_rx_bss_get (struct ieee80211_local *local,u8 *bssid,int freq, -u8 *ssid,u8 ssid_len) -{ -struct ieee80211_sta_bss *bss; - -spin_lock_bh (&local->sta_bss_lock); - bss = local->sta_bss_hash[STA_HASH (bssid)]; -while (bss) { -if (!bss_mesh_cfg (bss) && - !memcmp (bss->bssid, bssid,ETH_ALEN ) && - bss->freq == freq && - bss->ssid_len == ssid_len && - (ssid_len ==0 || !memcmp (bss->ssid, ssid, ssid_len))) { -atomic_inc (&bss->users); -break ; - } - bss = bss->hnext; - } -spin_unlock_bh (&local->sta_bss_lock); -return bss; -} - -#ifdef CONFIG_MAC80211_MESH -static struct ieee80211_sta_bss * -ieee80211_rx_mesh_bss_get (struct ieee80211_local *local,u8 *mesh_id,int mesh_id_len, -u8 *mesh_cfg,int freq) -{ -struct ieee80211_sta_bss *bss; + bss =ieee80211_rx_bss_get (local, ifsta->bssid, + local->hw.conf.channel->center_freq, + ifsta->ssid, ifsta->ssid_len); +if (bss) { + sta->last_signal = bss->signal; + sta->last_qual = bss->qual; + sta->last_noise = bss->noise; +ieee80211_rx_bss_put (local, bss); + } -spin_lock_bh (&local->sta_bss_lock); - bss = local->sta_bss_hash[mesh_id_hash (mesh_id, mesh_id_len)]; -while (bss) { -if (bss_mesh_cfg (bss) && - !memcmp (bss_mesh_cfg (bss), mesh_cfg,MESH_CFG_CMP_LEN ) && - bss->freq == freq && - mesh_id_len == bss->mesh_id_len && - (mesh_id_len ==0 || !memcmp (bss->mesh_id, mesh_id, - mesh_id_len))) { -atomic_inc (&bss->users); -break ; + err =sta_info_insert (sta); +if (err) { +printk (KERN_DEBUG "%s: failed to insert STA entry for" +" the AP (error %d)\n" , sdata->dev->name, err); +rcu_read_unlock (); +return ; } - bss = bss->hnext; +/* update new sta with its last rx activity */ + sta->last_rx = jiffies; } -spin_unlock_bh (&local->sta_bss_lock); -return bss; -} -static struct ieee80211_sta_bss * -ieee80211_rx_mesh_bss_add (struct ieee80211_local *local,u8 *mesh_id,int mesh_id_len, -u8 *mesh_cfg,int mesh_config_len,int freq) -{ -struct ieee80211_sta_bss *bss; +/* +* FIXME: Do we really need to update the sta_info's information here? +* We already know about the AP (we found it in our list) so it +* should already be filled with the right info, no? +* As is stands, all this is racy because typically we assume +* the information that is filled in here (except flags) doesn't +* change while a STA structure is alive. As such, it should move +* to between the sta_info_alloc() and sta_info_insert() above. +*/ -if (mesh_config_len !=MESH_CFG_LEN ) -return NULL ; +set_sta_flags (sta,WLAN_STA_AUTH |WLAN_STA_ASSOC |WLAN_STA_ASSOC_AP | +WLAN_STA_AUTHORIZED ); - bss =kzalloc (sizeof (*bss),GFP_ATOMIC ); -if (!bss) -return NULL ; + rates =0 ; + basic_rates =0 ; + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; - bss->mesh_cfg =kmalloc (MESH_CFG_CMP_LEN ,GFP_ATOMIC ); -if (!bss->mesh_cfg) { -kfree (bss); -return NULL ; - } +for (i =0 ; i < elems.supp_rates_len; i++) { +int rate = (elems.supp_rates[i] &0x7f ) *5 ; -if (mesh_id_len && mesh_id_len <=IEEE80211_MAX_MESH_ID_LEN ) { - bss->mesh_id =kmalloc (mesh_id_len,GFP_ATOMIC ); -if (!bss->mesh_id) { -kfree (bss->mesh_cfg); -kfree (bss); -return NULL ; +if (rate >110 ) + have_higher_than_11mbit = true; + +for (j =0 ; j < sband->n_bitrates; j++) { +if (sband->bitrates[j].bitrate == rate) + rates |=BIT (j); +if (elems.supp_rates[i] &0x80 ) + basic_rates |=BIT (j); } -memcpy (bss->mesh_id, mesh_id, mesh_id_len); } -atomic_inc (&bss->users); -atomic_inc (&bss->users); -memcpy (bss->mesh_cfg, mesh_cfg,MESH_CFG_CMP_LEN ); - bss->mesh_id_len = mesh_id_len; - bss->freq = freq; -spin_lock_bh (&local->sta_bss_lock); -/* TODO: order by RSSI? */ -list_add_tail (&bss->list, &local->sta_bss_list); -__ieee80211_rx_bss_hash_add (local, bss); -spin_unlock_bh (&local->sta_bss_lock); -return bss; -} -#endif - -static void ieee80211_rx_bss_free (struct ieee80211_sta_bss *bss) -{ -kfree (bss->ies); -kfree (bss_mesh_id (bss)); -kfree (bss_mesh_cfg (bss)); -kfree (bss); -} +for (i =0 ; i < elems.ext_supp_rates_len; i++) { +int rate = (elems.ext_supp_rates[i] &0x7f ) *5 ; +if (rate >110 ) + have_higher_than_11mbit = true; -static void ieee80211_rx_bss_put (struct ieee80211_local *local, -struct ieee80211_sta_bss *bss) -{ -local_bh_disable (); -if (!atomic_dec_and_lock (&bss->users, &local->sta_bss_lock)) { -local_bh_enable (); -return ; +for (j =0 ; j < sband->n_bitrates; j++) { +if (sband->bitrates[j].bitrate == rate) + rates |=BIT (j); +if (elems.ext_supp_rates[i] &0x80 ) + basic_rates |=BIT (j); + } } -__ieee80211_rx_bss_hash_del (local, bss); -list_del (&bss->list); -spin_unlock_bh (&local->sta_bss_lock); -ieee80211_rx_bss_free (bss); -} + sta->supp_rates[local->hw.conf.channel->band] = rates; + sdata->basic_rates = basic_rates; + +/* cf. IEEE 802.11 9.2.12 */ +if (local->hw.conf.channel->band ==IEEE80211_BAND_2GHZ && + have_higher_than_11mbit) + sdata->flags |=IEEE80211_SDATA_OPERATING_GMODE ; +else + sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE ; +if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param && + (ifsta->flags &IEEE80211_STA_WMM_ENABLED )) { +struct ieee80211_ht_bss_info bss_info; +ieee80211_ht_cap_ie_to_ht_info ( + (struct ieee80211_ht_cap *) + elems.ht_cap_elem, &sta->ht_info); +ieee80211_ht_addt_info_ie_to_ht_bss_info ( + (struct ieee80211_ht_addt_info *) + elems.ht_info_elem, &bss_info); +ieee80211_handle_ht (local,1 , &sta->ht_info, &bss_info); + } -void ieee80211_rx_bss_list_init (struct ieee80211_local *local) -{ -spin_lock_init (&local->sta_bss_lock); -INIT_LIST_HEAD (&local->sta_bss_list); -} +rate_control_rate_init (sta, local); +if (elems.wmm_param) { +set_sta_flags (sta,WLAN_STA_WME ); +rcu_read_unlock (); +ieee80211_sta_wmm_params (local, ifsta, elems.wmm_param, + elems.wmm_param_len); + }else +rcu_read_unlock (); -void ieee80211_rx_bss_list_deinit (struct ieee80211_local *local) -{ -struct ieee80211_sta_bss *bss, *tmp; +/* set AID and assoc capability, +* ieee80211_set_associated() will tell the driver */ + bss_conf->aid = aid; + bss_conf->assoc_capability = capab_info; +ieee80211_set_associated (sdata, ifsta); -list_for_each_entry_safe (bss, tmp, &local->sta_bss_list, list) -ieee80211_rx_bss_put (local, bss); +ieee80211_associated (sdata, ifsta); }
@@ -3146,104 +3117,15 @@ void ieee80211_start_mesh(struct ieee802void ieee80211_sta_timer (unsigned long data) { -struct ieee80211_sub_if_data *sdata = - (struct ieee80211_sub_if_data *) data; -struct ieee80211_if_sta *ifsta = &sdata->u.sta; -struct ieee80211_local *local = sdata->local; - -set_bit (IEEE80211_STA_REQ_RUN , &ifsta->request); -queue_work (local->hw.workqueue, &ifsta->work); -} - -void ieee80211_sta_work (struct work_struct *work) -{ -struct ieee80211_sub_if_data *sdata = - container_of(work, struct ieee80211_sub_if_data, u.sta.work); -struct ieee80211_local *local = sdata->local; -struct ieee80211_if_sta *ifsta; -struct sk_buff *skb; - -if (!netif_running (sdata->dev)) -return ; - -if (local->sta_sw_scanning || local->sta_hw_scanning) -return ; - -if (WARN_ON (sdata->vif.type !=IEEE80211_IF_TYPE_STA && - sdata->vif.type !=IEEE80211_IF_TYPE_IBSS && - sdata->vif.type !=IEEE80211_IF_TYPE_MESH_POINT )) -return ; - ifsta = &sdata->u.sta; - -while ((skb =skb_dequeue (&ifsta->skb_queue))) -ieee80211_sta_rx_queued_mgmt (sdata, skb); - -#ifdef CONFIG_MAC80211_MESH -if (ifsta->preq_queue_len && -time_after (jiffies, - ifsta->last_preq +msecs_to_jiffies (ifsta->mshcfg.dot11MeshHWMPpreqMinInterval))) -mesh_path_start_discovery (sdata); -#endif - -if (ifsta->state !=IEEE80211_STA_MLME_DIRECT_PROBE && - ifsta->state !=IEEE80211_STA_MLME_AUTHENTICATE && - ifsta->state !=IEEE80211_STA_MLME_ASSOCIATE && -test_and_clear_bit (IEEE80211_STA_REQ_SCAN , &ifsta->request)) { -if (ifsta->scan_ssid_len) -ieee80211_sta_start_scan (sdata, ifsta->scan_ssid, ifsta->scan_ssid_len); -else -ieee80211_sta_start_scan (sdata,NULL ,0 ); -return ; - } - -if (test_and_clear_bit (IEEE80211_STA_REQ_AUTH , &ifsta->request)) { -if (ieee80211_sta_config_auth (sdata, ifsta)) -return ; -clear_bit (IEEE80211_STA_REQ_RUN , &ifsta->request); - }else if (!test_and_clear_bit (IEEE80211_STA_REQ_RUN , &ifsta->request)) -return ; - -switch (ifsta->state) { -case IEEE80211_STA_MLME_DISABLED : -break ; -case IEEE80211_STA_MLME_DIRECT_PROBE : -ieee80211_direct_probe (sdata, ifsta); -break ; -case IEEE80211_STA_MLME_AUTHENTICATE : -ieee80211_authenticate (sdata, ifsta); -break ; -case IEEE80211_STA_MLME_ASSOCIATE : -ieee80211_associate (sdata, ifsta); -break ; -case IEEE80211_STA_MLME_ASSOCIATED : -ieee80211_associated (sdata, ifsta); -break ; -case IEEE80211_STA_MLME_IBSS_SEARCH : -ieee80211_sta_find_ibss (sdata, ifsta); -break ; -case IEEE80211_STA_MLME_IBSS_JOINED : -ieee80211_sta_merge_ibss (sdata, ifsta); -break ; -#ifdef CONFIG_MAC80211_MESH -case IEEE80211_STA_MLME_MESH_UP : -ieee80211_mesh_housekeeping (sdata, ifsta); -break ; -#endif -default : -WARN_ON (1 ); -break ; - } - -if (ieee80211_privacy_mismatch (sdata, ifsta)) { -printk (KERN_DEBUG "%s: privacy configuration mismatch and " -"mixed-cell disabled - disassociate\n" , sdata->dev->name); +struct ieee80211_sub_if_data *sdata = + (struct ieee80211_sub_if_data *) data; +struct ieee80211_if_sta *ifsta = &sdata->u.sta; +struct ieee80211_local *local = sdata->local; -ieee80211_set_disassoc (sdata, ifsta, false, true, -WLAN_REASON_UNSPECIFIED ); - } +set_bit (IEEE80211_STA_REQ_RUN , &ifsta->request); +queue_work (local->hw.workqueue, &ifsta->work); } -static void ieee80211_sta_reset_auth (struct ieee80211_sub_if_data *sdata,struct ieee80211_if_sta *ifsta) {
@@ -3328,85 +3210,6 @@ static int ieee80211_sta_match_ssid(strureturn 0 ; } -static int ieee80211_sta_config_auth (struct ieee80211_sub_if_data *sdata, -struct ieee80211_if_sta *ifsta) -{ -struct ieee80211_local *local = sdata->local; -struct ieee80211_sta_bss *bss, *selected =NULL ; -int top_rssi =0 , freq; - -spin_lock_bh (&local->sta_bss_lock); - freq = local->oper_channel->center_freq; -list_for_each_entry (bss, &local->sta_bss_list, list) { -if (!(bss->capability &WLAN_CAPABILITY_ESS )) -continue ; - -if ((ifsta->flags & (IEEE80211_STA_AUTO_SSID_SEL | -IEEE80211_STA_AUTO_BSSID_SEL | -IEEE80211_STA_AUTO_CHANNEL_SEL )) && - (!!(bss->capability &WLAN_CAPABILITY_PRIVACY ) ^ - !!sdata->default_key)) -continue ; - -if (!(ifsta->flags &IEEE80211_STA_AUTO_CHANNEL_SEL ) && - bss->freq != freq) -continue ; - -if (!(ifsta->flags &IEEE80211_STA_AUTO_BSSID_SEL ) && -memcmp (bss->bssid, ifsta->bssid,ETH_ALEN )) -continue ; - -if (!(ifsta->flags &IEEE80211_STA_AUTO_SSID_SEL ) && - !ieee80211_sta_match_ssid (ifsta, bss->ssid, bss->ssid_len)) -continue ; - -if (!selected || top_rssi < bss->signal) { - selected = bss; - top_rssi = bss->signal; - } - } -if (selected) -atomic_inc (&selected->users); -spin_unlock_bh (&local->sta_bss_lock); - -if (selected) { -ieee80211_set_freq (sdata, selected->freq); -if (!(ifsta->flags &IEEE80211_STA_SSID_SET )) -ieee80211_sta_set_ssid (sdata, selected->ssid, - selected->ssid_len); -ieee80211_sta_set_bssid (sdata, selected->bssid); -ieee80211_sta_def_wmm_params (sdata, selected,0 ); - -/* Send out direct probe if no probe resp was received or -* the one we have is outdated -*/ -if (!selected->last_probe_resp || -time_after (jiffies, selected->last_probe_resp - +IEEE80211_SCAN_RESULT_EXPIRE )) - ifsta->state =IEEE80211_STA_MLME_DIRECT_PROBE ; -else - ifsta->state =IEEE80211_STA_MLME_AUTHENTICATE ; - -ieee80211_rx_bss_put (local, selected); -ieee80211_sta_reset_auth (sdata, ifsta); -return 0 ; - }else { -if (ifsta->assoc_scan_tries <IEEE80211_ASSOC_SCANS_MAX_TRIES ) { - ifsta->assoc_scan_tries++; -if (ifsta->flags &IEEE80211_STA_AUTO_SSID_SEL ) -ieee80211_sta_start_scan (sdata,NULL ,0 ); -else -ieee80211_sta_start_scan (sdata, ifsta->ssid, - ifsta->ssid_len); - ifsta->state =IEEE80211_STA_MLME_AUTHENTICATE ; -set_bit (IEEE80211_STA_REQ_AUTH , &ifsta->request); - }else - ifsta->state =IEEE80211_STA_MLME_DISABLED ; - } -return -1 ; -} - -static int ieee80211_sta_create_ibss (struct ieee80211_sub_if_data *sdata,struct ieee80211_if_sta *ifsta) {
@@ -4274,6 +4077,85 @@ struct sta_info *ieee80211_ibss_add_sta( } +static int ieee80211_sta_config_auth (struct ieee80211_sub_if_data *sdata, +struct ieee80211_if_sta *ifsta) +{ +struct ieee80211_local *local = sdata->local; +struct ieee80211_sta_bss *bss, *selected =NULL ; +int top_rssi =0 , freq; + +spin_lock_bh (&local->sta_bss_lock); + freq = local->oper_channel->center_freq; +list_for_each_entry (bss, &local->sta_bss_list, list) { +if (!(bss->capability &WLAN_CAPABILITY_ESS )) +continue ; + +if ((ifsta->flags & (IEEE80211_STA_AUTO_SSID_SEL | +IEEE80211_STA_AUTO_BSSID_SEL | +IEEE80211_STA_AUTO_CHANNEL_SEL )) && + (!!(bss->capability &WLAN_CAPABILITY_PRIVACY ) ^ + !!sdata->default_key)) +continue ; + +if (!(ifsta->flags &IEEE80211_STA_AUTO_CHANNEL_SEL ) && + bss->freq != freq) +continue ; + +if (!(ifsta->flags &IEEE80211_STA_AUTO_BSSID_SEL ) && +memcmp (bss->bssid, ifsta->bssid,ETH_ALEN )) +continue ; + +if (!(ifsta->flags &IEEE80211_STA_AUTO_SSID_SEL ) && + !ieee80211_sta_match_ssid (ifsta, bss->ssid, bss->ssid_len)) +continue ; + +if (!selected || top_rssi < bss->signal) { + selected = bss; + top_rssi = bss->signal; + } + } +if (selected) +atomic_inc (&selected->users); +spin_unlock_bh (&local->sta_bss_lock); + +if (selected) { +ieee80211_set_freq (sdata, selected->freq); +if (!(ifsta->flags &IEEE80211_STA_SSID_SET )) +ieee80211_sta_set_ssid (sdata, selected->ssid, + selected->ssid_len); +ieee80211_sta_set_bssid (sdata, selected->bssid); +ieee80211_sta_def_wmm_params (sdata, selected,0 ); + +/* Send out direct probe if no probe resp was received or +* the one we have is outdated +*/ +if (!selected->last_probe_resp || +time_after (jiffies, selected->last_probe_resp + +IEEE80211_SCAN_RESULT_EXPIRE )) + ifsta->state =IEEE80211_STA_MLME_DIRECT_PROBE ; +else + ifsta->state =IEEE80211_STA_MLME_AUTHENTICATE ; + +ieee80211_rx_bss_put (local, selected); +ieee80211_sta_reset_auth (sdata, ifsta); +return 0 ; + }else { +if (ifsta->assoc_scan_tries <IEEE80211_ASSOC_SCANS_MAX_TRIES ) { + ifsta->assoc_scan_tries++; +if (ifsta->flags &IEEE80211_STA_AUTO_SSID_SEL ) +ieee80211_sta_start_scan (sdata,NULL ,0 ); +else +ieee80211_sta_start_scan (sdata, ifsta->ssid, + ifsta->ssid_len); + ifsta->state =IEEE80211_STA_MLME_AUTHENTICATE ; +set_bit (IEEE80211_STA_REQ_AUTH , &ifsta->request); + }else + ifsta->state =IEEE80211_STA_MLME_DISABLED ; + } +return -1 ; +} + +int ieee80211_sta_deauthenticate (struct ieee80211_sub_if_data *sdata,u16 reason) {struct ieee80211_if_sta *ifsta = &sdata->u.sta;
@@ -4327,3 +4209,91 @@ void ieee80211_notify_mac(struct ieee802 } }EXPORT_SYMBOL (ieee80211_notify_mac); + +void ieee80211_sta_work (struct work_struct *work) +{ +struct ieee80211_sub_if_data *sdata = + container_of(work, struct ieee80211_sub_if_data, u.sta.work); +struct ieee80211_local *local = sdata->local; +struct ieee80211_if_sta *ifsta; +struct sk_buff *skb; + +if (!netif_running (sdata->dev)) +return ; + +if (local->sta_sw_scanning || local->sta_hw_scanning) +return ; + +if (WARN_ON (sdata->vif.type !=IEEE80211_IF_TYPE_STA && + sdata->vif.type !=IEEE80211_IF_TYPE_IBSS && + sdata->vif.type !=IEEE80211_IF_TYPE_MESH_POINT )) +return ; + ifsta = &sdata->u.sta; + +while ((skb =skb_dequeue (&ifsta->skb_queue))) +ieee80211_sta_rx_queued_mgmt (sdata, skb); + +#ifdef CONFIG_MAC80211_MESH +if (ifsta->preq_queue_len && +time_after (jiffies, + ifsta->last_preq +msecs_to_jiffies (ifsta->mshcfg.dot11MeshHWMPpreqMinInterval))) +mesh_path_start_discovery (sdata); +#endif + +if (ifsta->state !=IEEE80211_STA_MLME_DIRECT_PROBE && + ifsta->state !=IEEE80211_STA_MLME_AUTHENTICATE && + ifsta->state !=IEEE80211_STA_MLME_ASSOCIATE && +test_and_clear_bit (IEEE80211_STA_REQ_SCAN , &ifsta->request)) { +if (ifsta->scan_ssid_len) +ieee80211_sta_start_scan (sdata, ifsta->scan_ssid, ifsta->scan_ssid_len); +else +ieee80211_sta_start_scan (sdata,NULL ,0 ); +return ; + } + +if (test_and_clear_bit (IEEE80211_STA_REQ_AUTH , &ifsta->request)) { +if (ieee80211_sta_config_auth (sdata, ifsta)) +return ; +clear_bit (IEEE80211_STA_REQ_RUN , &ifsta->request); + }else if (!test_and_clear_bit (IEEE80211_STA_REQ_RUN , &ifsta->request)) +return ; + +switch (ifsta->state) { +case IEEE80211_STA_MLME_DISABLED : +break ; +case IEEE80211_STA_MLME_DIRECT_PROBE : +ieee80211_direct_probe (sdata, ifsta); +break ; +case IEEE80211_STA_MLME_AUTHENTICATE : +ieee80211_authenticate (sdata, ifsta); +break ; +case IEEE80211_STA_MLME_ASSOCIATE : +ieee80211_associate (sdata, ifsta); +break ; +case IEEE80211_STA_MLME_ASSOCIATED : +ieee80211_associated (sdata, ifsta); +break ; +case IEEE80211_STA_MLME_IBSS_SEARCH : +ieee80211_sta_find_ibss (sdata, ifsta); +break ; +case IEEE80211_STA_MLME_IBSS_JOINED : +ieee80211_sta_merge_ibss (sdata, ifsta); +break ; +#ifdef CONFIG_MAC80211_MESH +case IEEE80211_STA_MLME_MESH_UP : +ieee80211_mesh_housekeeping (sdata, ifsta); +break ; +#endif +default : +WARN_ON (1 ); +break ; + } + +if (ieee80211_privacy_mismatch (sdata, ifsta)) { +printk (KERN_DEBUG "%s: privacy configuration mismatch and " +"mixed-cell disabled - disassociate\n" , sdata->dev->name); + +ieee80211_set_disassoc (sdata, ifsta, false, true, +WLAN_REASON_UNSPECIFIED ); + } +}
Johannes Berg
maintainerPATCH 2/8 mac80211: use sdata pointer for scan interface
In reply to Johannes BergSince we now use sdata pointers most of the time, using a netdev pointer here is somewhat artificial, use an sdata pointer instead. Replace a netdev-prefix in a few messages by a wiphy-prefix.
--- net/mac80211/ieee80211_i.h | 2 +- net/mac80211/main.c | 2 +- net/mac80211/mlme.c | 24 +++++++++++------------- 3 files changed, 13 insertions(+), 15 deletions(-)
net/mac80211/ieee80211_i.h +1 -1
@@ -636,7 +636,7 @@ struct ieee80211_local {enum {SCAN_SET_CHANNEL ,SCAN_SEND_PROBE } scan_state;unsigned long last_scan_completed;struct delayed_work scan_work; -struct net_device *scan_dev; +struct ieee80211_sub_if_data *scan_sdata;struct ieee80211_channel *oper_channel, *scan_channel;u8 scan_ssid[IEEE80211_MAX_SSID_LEN ];size_t scan_ssid_len;
net/mac80211/main.c +1 -1
@@ -551,7 +551,7 @@ static int ieee80211_stop(struct net_devsynchronize_rcu ();skb_queue_purge (&sdata->u.sta.skb_queue); -if (local->scan_dev == sdata->dev) { +if (local->scan_sdata == sdata) {if (!local->ops->hw_scan) { local->sta_sw_scanning =0 ;cancel_delayed_work (&local->scan_work);
net/mac80211/mlme.c +11 -13
@@ -3508,19 +3508,18 @@ static void ieee80211_restart_sta_timer(void ieee80211_scan_completed (struct ieee80211_hw *hw) {struct ieee80211_local *local =hw_to_local (hw); -struct net_device *dev = local->scan_dev;struct ieee80211_sub_if_data *sdata;union iwreq_data wrqu; local->last_scan_completed = jiffies;memset (&wrqu,0 ,sizeof (wrqu)); -wireless_send_event (dev,SIOCGIWSCAN , &wrqu,NULL ); +wireless_send_event (local->scan_sdata->dev,SIOCGIWSCAN , &wrqu,NULL );if (local->sta_hw_scanning) { local->sta_hw_scanning =0 ;if (ieee80211_hw_config (local))printk (KERN_DEBUG "%s: failed to restore operational " -"channel after scan\n" , dev->name); +"channel after scan\n" ,wiphy_name (local->hw.wiphy));/* Restart STA timer for HW scan case */ rcu_read_lock ();list_for_each_entry_rcu (sdata, &local->interfaces, list)
@@ -3533,7 +3532,7 @@ void ieee80211_scan_completed(struct iee local->sta_sw_scanning =0 ;if (ieee80211_hw_config (local))printk (KERN_DEBUG "%s: failed to restore operational " -"channel after scan\n" , dev->name); +"channel after scan\n" ,wiphy_name (local->hw.wiphy));netif_tx_lock_bh (local->mdev);
@@ -3563,8 +3562,8 @@ void ieee80211_scan_completed(struct iee }rcu_read_unlock (); -done: - sdata =IEEE80211_DEV_TO_SUB_IF (dev); + done: + sdata = local->scan_sdata;if (sdata->vif.type ==IEEE80211_IF_TYPE_IBSS ) {struct ieee80211_if_sta *ifsta = &sdata->u.sta; if (!(ifsta->flags & IEEE80211_STA_BSSID_SET) ||
@@ -3579,8 +3578,7 @@ void ieee80211_sta_scan_work(struct work {struct ieee80211_local *local = container_of(work, struct ieee80211_local, scan_work.work); -struct net_device *dev = local->scan_dev; -struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev); +struct ieee80211_sub_if_data *sdata = local->scan_sdata;struct ieee80211_supported_band *sband;struct ieee80211_channel *chan;int skip;
@@ -3628,7 +3626,7 @@ void ieee80211_sta_scan_work(struct work local->scan_channel = chan;if (ieee80211_hw_config (local)) {printk (KERN_DEBUG "%s: failed to set freq to " -"%d MHz for scan\n" , dev->name, +"%d MHz for scan\n" ,wiphy_name (local->hw.wiphy), chan->center_freq); skip =1 ; }
@@ -3698,7 +3696,7 @@ static int ieee80211_sta_start_scan(stru*/ if (local->sta_sw_scanning || local->sta_hw_scanning) { -if (local->scan_dev == scan_sdata->dev) +if (local->scan_sdata == scan_sdata)return 0 ;return -EBUSY ; }
@@ -3708,7 +3706,7 @@ static int ieee80211_sta_start_scan(stru ssid, ssid_len);if (!rc) { local->sta_hw_scanning =1 ; - local->scan_dev = scan_sdata->dev; + local->scan_sdata = scan_sdata; }return rc; }
@@ -3735,7 +3733,7 @@ static int ieee80211_sta_start_scan(stru local->scan_state =SCAN_SET_CHANNEL ; local->scan_channel_idx =0 ; local->scan_band =IEEE80211_BAND_2GHZ ; - local->scan_dev = scan_sdata->dev; + local->scan_sdata = scan_sdata;netif_addr_lock_bh (local->mdev); local->filter_flags |=FIF_BCN_PRBRESP_PROMISC ;
@@ -3763,7 +3761,7 @@ int ieee80211_sta_req_scan(struct ieee80return ieee80211_sta_start_scan (sdata, ssid, ssid_len);if (local->sta_sw_scanning || local->sta_hw_scanning) { -if (local->scan_dev == sdata->dev) +if (local->scan_sdata == sdata)return 0 ;return -EBUSY ; }
Johannes Berg
maintainerPATCH 3/8 mac80211: remove useless non-NULL tests from scan results code
In reply to Johannes BergI'm surprised nobody complained about these before. What a waste.
--- net/mac80211/mlme.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-)
net/mac80211/mlme.c +18 -22
@@ -3823,6 +3823,7 @@ ieee80211_sta_scan_result(struct ieee802 char *current_ev, char *end_buf) { struct iw_event iwe; +char *buf;if (time_after (jiffies, bss->last_update +IEEE80211_SCAN_RESULT_EXPIRE ))
@@ -3897,7 +3898,7 @@ ieee80211_sta_scan_result(struct ieee802ieee80211_sta_add_scan_ies (info, bss, ¤t_ev, end_buf); -if (bss && bss->supp_rates_len >0 ) { +if (bss->supp_rates_len >0 ) {/* display all supported rates in readable format */ char *p = current_ev +iwe_stream_lcp_len (info);int i;
@@ -3916,30 +3917,25 @@ ieee80211_sta_scan_result(struct ieee802 current_ev = p; } -if (bss) { -char *buf; - buf =kmalloc (30 ,GFP_ATOMIC ); -if (buf) { -memset (&iwe,0 ,sizeof (iwe)); - iwe.cmd =IWEVCUSTOM ; -sprintf (buf,"tsf=%016llx" , (unsigned long long )(bss->timestamp)); - iwe.u.data.length =strlen (buf); - current_ev =iwe_stream_add_point (info, current_ev, - end_buf, - &iwe, buf); -memset (&iwe,0 ,sizeof (iwe)); - iwe.cmd =IWEVCUSTOM ; -sprintf (buf," Last beacon: %dms ago" , -jiffies_to_msecs (jiffies - bss->last_update)); - iwe.u.data.length =strlen (buf); - current_ev =iwe_stream_add_point (info, current_ev, - end_buf, &iwe, buf); -kfree (buf); - } + buf =kmalloc (30 ,GFP_ATOMIC ); +if (buf) { +memset (&iwe,0 ,sizeof (iwe)); + iwe.cmd =IWEVCUSTOM ; +sprintf (buf,"tsf=%016llx" , (unsigned long long )(bss->timestamp)); + iwe.u.data.length =strlen (buf); + current_ev =iwe_stream_add_point (info, current_ev, end_buf, + &iwe, buf); +memset (&iwe,0 ,sizeof (iwe)); + iwe.cmd =IWEVCUSTOM ; +sprintf (buf," Last beacon: %dms ago" , +jiffies_to_msecs (jiffies - bss->last_update)); + iwe.u.data.length =strlen (buf); + current_ev =iwe_stream_add_point (info, current_ev, + end_buf, &iwe, buf); +kfree (buf); }if (bss_mesh_cfg (bss)) { -char *buf;u8 *cfg =bss_mesh_cfg (bss); buf =kmalloc (50 ,GFP_ATOMIC );if (buf) {
Johannes Berg
maintainerPATCH 4/8 mac80211: start moving scan code from mlme
In reply to Johannes BergHere's a first patch to move some code from mlme.c to a new file called scan.c. The end result will hopefully be a more manageable mlme.c.
--- net/mac80211/Makefile | 1 net/mac80211/ieee80211_i.h | 13 - net/mac80211/mlme.c | 559 +-------------------------------------------- net/mac80211/scan.c | 553 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 582 insertions(+), 544 deletions(-)
net/mac80211/Makefile +1 -0
@@ -7,6 +7,7 @@ mac80211-y := \ sta_info.o \ wep.o \ wpa.o \ + scan.o \ mlme.o \ iface.o \ rate.o \
net/mac80211/ieee80211_i.h +12 -1
@@ -53,6 +53,12 @@ struct ieee80211_local;* increased memory use (about 2 kB of RAM per entry). */ #define IEEE80211_FRAGMENT_MAX 4 +/* +* Time after which we ignore scan results and no longer report/use +* them in any way. +*/ +#define IEEE80211_SCAN_RESULT_EXPIRE (10 * HZ) +struct ieee80211_fragment_entry {unsigned long first_frag_time;unsigned int seq;
@@ -924,8 +930,13 @@ u64 ieee80211_sta_get_rates(struct ieee8 enum ieee80211_band band);void ieee80211_sta_tx (struct ieee80211_sub_if_data *sdata,struct sk_buff *skb,int encrypt); +void ieee80211_send_probe_req (struct ieee80211_sub_if_data *sdata,u8 *dst, +u8 *ssid,size_t ssid_len);void ieee802_11_parse_elems (u8 *start,size_t len, -struct ieee802_11_elems *elems); +struct ieee802_11_elems *elems); +void ieee80211_mlme_notify_scan_completed (struct ieee80211_local *local); +int ieee80211_sta_start_scan (struct ieee80211_sub_if_data *scan_sdata, +u8 *ssid,size_t ssid_len);#ifdef CONFIG_MAC80211_MESH void ieee80211_start_mesh (struct ieee80211_sub_if_data *sdata);
net/mac80211/mlme.c +16 -543
580 lines not on this page · raw message
net/mac80211/scan.c new file +553 -0
553 lines not on this page · raw message
Johannes Berg
maintainerPATCH 5/8 mac80211: refactor and move scan RX code
In reply to Johannes BergThis patch refactors some code and moves the scan RX function to scan.c. More importantly, however, it changes it so that the MLME's beacon/probe_resp functions aren't invoked when scanning so that we can remove a "if (scanning)" conditions from two places.
There's a very slight behavioural change in this patch: now, when scanning, IBSS and mesh aren't updated even on the same channel.
--- net/mac80211/ieee80211_i.h | 9 + net/mac80211/mlme.c | 253 ++++++++++++++++++++------------------------- net/mac80211/scan.c | 68 ++++++++++++ 3 files changed, 194 insertions(+), 136 deletions(-)
net/mac80211/mlme.c +117 -136
@@ -128,10 +128,9 @@ static void __ieee80211_rx_bss_hash_del( }static struct ieee80211_sta_bss * -ieee80211_rx_bss_add (struct ieee80211_sub_if_data *sdata,u8 *bssid,int freq, +ieee80211_rx_bss_add (struct ieee80211_local *local,u8 *bssid,int freq,u8 *ssid,u8 ssid_len) { -struct ieee80211_local *local = sdata->local;struct ieee80211_sta_bss *bss; bss =kzalloc (sizeof (*bss),GFP_ATOMIC );
@@ -230,8 +229,8 @@ static void ieee80211_rx_bss_free(structkfree (bss); } -static void ieee80211_rx_bss_put (struct ieee80211_local *local, -struct ieee80211_sta_bss *bss) +void ieee80211_rx_bss_put (struct ieee80211_local *local, +struct ieee80211_sta_bss *bss) {local_bh_disable ();if (!atomic_dec_and_lock (&bss->users, &local->sta_bss_lock)) {
@@ -2444,74 +2443,16 @@ static u64 ieee80211_sta_get_mandatory_rreturn mandatory_rates; } -static void ieee80211_rx_bss_info (struct ieee80211_sub_if_data *sdata, -struct ieee80211_mgmt *mgmt, -size_t len, -struct ieee80211_rx_status *rx_status, -struct ieee802_11_elems *elems) +struct ieee80211_sta_bss * +ieee80211_bss_info_update (struct ieee80211_local *local, +struct ieee80211_rx_status *rx_status, +struct ieee80211_mgmt *mgmt, +size_t len, +struct ieee802_11_elems *elems, +int freq,bool beacon) { -struct ieee80211_local *local = sdata->local; -int freq, clen;struct ieee80211_sta_bss *bss; -struct sta_info *sta; -struct ieee80211_channel *channel; -u64 beacon_timestamp, rx_timestamp; -u64 supp_rates =0 ; -bool beacon =ieee80211_is_beacon (mgmt->frame_control); -enum ieee80211_band band = rx_status->band; -DECLARE_MAC_BUF (mac); -DECLARE_MAC_BUF (mac2); - -if (elems->ds_params && elems->ds_params_len ==1 ) - freq =ieee80211_channel_to_frequency (elems->ds_params[0 ]); -else - freq = rx_status->freq; - - channel =ieee80211_get_channel (local->hw.wiphy, freq); - -if (!channel || channel->flags &IEEE80211_CHAN_DISABLED ) -return ; - -if (ieee80211_vif_is_mesh (&sdata->vif) && elems->mesh_id && - elems->mesh_config &&mesh_matches_local (elems, sdata)) { - supp_rates =ieee80211_sta_get_rates (local, elems, band); - -mesh_neighbour_update (mgmt->sa, supp_rates, sdata, -mesh_peer_accepts_plinks (elems)); - } - -if (sdata->vif.type ==IEEE80211_IF_TYPE_IBSS && elems->supp_rates && -memcmp (mgmt->bssid, sdata->u.sta.bssid,ETH_ALEN ) ==0 ) { - supp_rates =ieee80211_sta_get_rates (local, elems, band); - -rcu_read_lock (); - - sta =sta_info_get (local, mgmt->sa); -if (sta) { -u64 prev_rates; - - prev_rates = sta->supp_rates[band]; -/* make sure mandatory rates are always added */ - sta->supp_rates[band] = supp_rates | -ieee80211_sta_get_mandatory_rates (local, band); - -#ifdef CONFIG_MAC80211_IBSS_DEBUG -if (sta->supp_rates[band] != prev_rates) -printk (KERN_DEBUG "%s: updated supp_rates set " -"for %s based on beacon info (0x%llx | " -"0x%llx -> 0x%llx)\n" , - sdata->dev->name,print_mac (mac, sta->addr), - (unsigned long long ) prev_rates, - (unsigned long long ) supp_rates, - (unsigned long long ) sta->supp_rates[band]); -#endif - }else { -ieee80211_ibss_add_sta (sdata,NULL , mgmt->bssid, - mgmt->sa, supp_rates); - } - -rcu_read_unlock (); - } +int clen;#ifdef CONFIG_MAC80211_MESH if (elems->mesh_config)
@@ -2529,10 +2470,10 @@ static void ieee80211_rx_bss_info(struct elems->mesh_config_len, freq); else#endif - bss =ieee80211_rx_bss_add (sdata, mgmt->bssid, freq, + bss =ieee80211_rx_bss_add (local, mgmt->bssid, freq, elems->ssid, elems->ssid_len);if (!bss) -return ; +return NULL ; }else {#if 0 /* TODO: order by RSSI? */
@@ -2579,17 +2520,114 @@ static void ieee80211_rx_bss_info(struct bss->supp_rates_len += clen; } - bss->band = band; + bss->band = rx_status->band; - beacon_timestamp =le64_to_cpu (mgmt->u.beacon.timestamp); - - bss->timestamp = beacon_timestamp; + bss->timestamp =le64_to_cpu (mgmt->u.beacon.timestamp); bss->last_update = jiffies; bss->signal = rx_status->signal; bss->noise = rx_status->noise; bss->qual = rx_status->qual; + bss->wmm_used = elems->wmm_param || elems->wmm_info; +if (!beacon) bss->last_probe_resp = jiffies; + +/* +* For probe responses, or if we don't have any information yet, +* use the IEs from the beacon. +*/ +if (!bss->ies || !beacon) { +if (bss->ies ==NULL || bss->ies_len < elems->total_len) { +kfree (bss->ies); + bss->ies =kmalloc (elems->total_len,GFP_ATOMIC ); + } +if (bss->ies) { +memcpy (bss->ies, elems->ie_start, elems->total_len); + bss->ies_len = elems->total_len; + }else + bss->ies_len =0 ; + } + +return bss; +} + +static void ieee80211_rx_bss_info (struct ieee80211_sub_if_data *sdata, +struct ieee80211_mgmt *mgmt, +size_t len, +struct ieee80211_rx_status *rx_status, +struct ieee802_11_elems *elems, +bool beacon) +{ +struct ieee80211_local *local = sdata->local; +int freq; +struct ieee80211_sta_bss *bss; +struct sta_info *sta; +struct ieee80211_channel *channel; +u64 beacon_timestamp, rx_timestamp; +u64 supp_rates =0 ; +enum ieee80211_band band = rx_status->band; +DECLARE_MAC_BUF (mac); +DECLARE_MAC_BUF (mac2); + +if (elems->ds_params && elems->ds_params_len ==1 ) + freq =ieee80211_channel_to_frequency (elems->ds_params[0 ]); +else + freq = rx_status->freq; + + channel =ieee80211_get_channel (local->hw.wiphy, freq); + +if (!channel || channel->flags &IEEE80211_CHAN_DISABLED ) +return ; + +if (ieee80211_vif_is_mesh (&sdata->vif) && elems->mesh_id && + elems->mesh_config &&mesh_matches_local (elems, sdata)) { + supp_rates =ieee80211_sta_get_rates (local, elems, band); + +mesh_neighbour_update (mgmt->sa, supp_rates, sdata, +mesh_peer_accepts_plinks (elems)); + } + +if (sdata->vif.type ==IEEE80211_IF_TYPE_IBSS && elems->supp_rates && +memcmp (mgmt->bssid, sdata->u.sta.bssid,ETH_ALEN ) ==0 ) { + supp_rates =ieee80211_sta_get_rates (local, elems, band); + +rcu_read_lock (); + + sta =sta_info_get (local, mgmt->sa); +if (sta) { +u64 prev_rates; + + prev_rates = sta->supp_rates[band]; +/* make sure mandatory rates are always added */ + sta->supp_rates[band] = supp_rates | +ieee80211_sta_get_mandatory_rates (local, band); + +#ifdef CONFIG_MAC80211_IBSS_DEBUG +if (sta->supp_rates[band] != prev_rates) +printk (KERN_DEBUG "%s: updated supp_rates set " +"for %s based on beacon info (0x%llx | " +"0x%llx -> 0x%llx)\n" , + sdata->dev->name,print_mac (mac, sta->addr), + (unsigned long long ) prev_rates, + (unsigned long long ) supp_rates, + (unsigned long long ) sta->supp_rates[band]); +#endif + }else { +ieee80211_ibss_add_sta (sdata,NULL , mgmt->bssid, + mgmt->sa, supp_rates); + } + +rcu_read_unlock (); + } + + bss =ieee80211_bss_info_update (local, rx_status, mgmt, len, elems, + freq, beacon); +if (!bss) +return ; + +/* was just updated in ieee80211_bss_info_update */ + beacon_timestamp = bss->timestamp; +/* * In STA mode, the remaining parameters should not be overridden * by beacons because they're not necessarily accurate there.
@@ -2600,21 +2638,8 @@ static void ieee80211_rx_bss_info(structreturn ; } -if (bss->ies ==NULL || bss->ies_len < elems->total_len) { -kfree (bss->ies); - bss->ies =kmalloc (elems->total_len,GFP_ATOMIC ); - } -if (bss->ies) { -memcpy (bss->ies, elems->ie_start, elems->total_len); - bss->ies_len = elems->total_len; - }else - bss->ies_len =0 ; - - bss->wmm_used = elems->wmm_param || elems->wmm_info; -/* check if we need to merge IBSS */ if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && beacon && - !local->sta_sw_scanning && !local->sta_hw_scanning && bss->capability & WLAN_CAPABILITY_IBSS && bss->freq == local->oper_channel->center_freq && elems->ssid_len == sdata->u.sta.ssid_len &&
@@ -2691,7 +2716,7 @@ static void ieee80211_rx_mgmt_probe_respieee802_11_parse_elems (mgmt->u.probe_resp.variable, len - baselen, &elems); -ieee80211_rx_bss_info (sdata, mgmt, len, rx_status, &elems); +ieee80211_rx_bss_info (sdata, mgmt, len, rx_status, &elems, false);/* direct probe may be part of the association flow */ if (test_and_clear_bit(IEEE80211_STA_REQ_DIRECT_PROBE,
@@ -2722,7 +2747,7 @@ static void ieee80211_rx_mgmt_beacon(strieee802_11_parse_elems (mgmt->u.beacon.variable, len - baselen, &elems); -ieee80211_rx_bss_info (sdata, mgmt, len, rx_status, &elems); +ieee80211_rx_bss_info (sdata, mgmt, len, rx_status, &elems, true);if (sdata->vif.type !=IEEE80211_IF_TYPE_STA )return ;
@@ -2732,15 +2757,6 @@ static void ieee80211_rx_mgmt_beacon(str memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0)return ; -/* Do not send changes to driver if we are scanning. This removes -* requirement that a driver's bss_info_changed/conf_tx functions -* need to be atomic. -* This is really ugly code, we should rewrite scanning and make -* all this more understandable for humans. -*/ -if (local->sta_sw_scanning || local->sta_hw_scanning) -return ; -ieee80211_sta_wmm_params (local, ifsta, elems.wmm_param, elems.wmm_param_len);
@@ -2983,41 +2999,6 @@ static void ieee80211_sta_rx_queued_mgmt } -ieee80211_rx_result -ieee80211_sta_rx_scan (struct ieee80211_sub_if_data *sdata,struct sk_buff *skb, -struct ieee80211_rx_status *rx_status) -{ -struct ieee80211_mgmt *mgmt; -__le16 fc; - -if (skb->len <2 ) -return RX_DROP_UNUSABLE ; - - mgmt = (struct ieee80211_mgmt *) skb->data; - fc = mgmt->frame_control; - -if (ieee80211_is_ctl (fc)) -return RX_CONTINUE ; - -if (skb->len <24 ) -return RX_DROP_MONITOR ; - -if (ieee80211_is_probe_resp (fc)) { -ieee80211_rx_mgmt_probe_resp (sdata, mgmt, skb->len, rx_status); -dev_kfree_skb (skb); -return RX_QUEUED ; - } - -if (ieee80211_is_beacon (fc)) { -ieee80211_rx_mgmt_beacon (sdata, mgmt, skb->len, rx_status); -dev_kfree_skb (skb); -return RX_QUEUED ; - } - -return RX_CONTINUE ; -} - -static int ieee80211_sta_active_ibss (struct ieee80211_sub_if_data *sdata) {struct ieee80211_local *local = sdata->local;
@@ -3234,7 +3215,7 @@ static int ieee80211_sta_create_ibss(strprintk (KERN_DEBUG "%s: Creating new IBSS network, BSSID %s\n" , sdata->dev->name,print_mac (mac, bssid)); - bss =ieee80211_rx_bss_add (sdata, bssid, + bss =ieee80211_rx_bss_add (local, bssid, local->hw.conf.channel->center_freq, sdata->u.sta.ssid, sdata->u.sta.ssid_len);if (!bss)
net/mac80211/scan.c +68 -0
74 lines not on this page · raw message
net/mac80211/ieee80211_i.h +9 -0
@@ -937,6 +937,15 @@ void ieee802_11_parse_elems(u8 *start, svoid ieee80211_mlme_notify_scan_completed (struct ieee80211_local *local);int ieee80211_sta_start_scan (struct ieee80211_sub_if_data *scan_sdata,u8 *ssid,size_t ssid_len); +struct ieee80211_sta_bss * +ieee80211_bss_info_update (struct ieee80211_local *local, +struct ieee80211_rx_status *rx_status, +struct ieee80211_mgmt *mgmt, +size_t len, +struct ieee802_11_elems *elems, +int freq,bool beacon); +void ieee80211_rx_bss_put (struct ieee80211_local *local, +struct ieee80211_sta_bss *bss);#ifdef CONFIG_MAC80211_MESH void ieee80211_start_mesh (struct ieee80211_sub_if_data *sdata);
Johannes Berg
maintainerPATCH 6/8 mac80211: move BSS handling to scan code
In reply to Johannes BergThis moves all the BSS list handling out of mlme.c to scan.c, no further changes except fixing kzalloc/atomic_inc/atomic_inc to kzalloc/atomic_set(2).
---mlme.c is on a diet!
net/mac80211/ieee80211_i.h | 6 net/mac80211/mlme.c | 310 --------------------------------------------- net/mac80211/scan.c | 305 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 313 insertions(+), 308 deletions(-)
net/mac80211/ieee80211_i.h +6 -0
@@ -944,6 +944,12 @@ ieee80211_bss_info_update(struct ieee802size_t len, struct ieee802_11_elems *elems, int freq, bool beacon); +struct ieee80211_sta_bss * +ieee80211_rx_bss_add (struct ieee80211_local *local,u8 *bssid,int freq, +u8 *ssid,u8 ssid_len); +struct ieee80211_sta_bss * +ieee80211_rx_bss_get (struct ieee80211_local *local,u8 *bssid,int freq, +u8 *ssid,u8 ssid_len);void ieee80211_rx_bss_put (struct ieee80211_local *local,struct ieee80211_sta_bss *bss);
net/mac80211/mlme.c +3 -307
335 lines not on this page · raw message
net/mac80211/scan.c +304 -1
326 lines not on this page · raw message
Johannes Berg
maintainerPATCH 7/8 mac80211: move some HT code out of mlme.c
In reply to Johannes BergSome of the HT code in mlme.c is misplaced:
* constants/definitions belong to the ieee80211.h header
* code being used in other modes as well shouldn't be there
--- include/linux/ieee80211.h | 18 ++ net/mac80211/Makefile | 1 net/mac80211/ht.c | 328 ++++++++++++++++++++++++++++++++++++++++++++++ net/mac80211/mlme.c | 321 --------------------------------------------- 4 files changed, 347 insertions(+), 321 deletions(-)
include/linux/ieee80211.h +18 -0
@@ -643,6 +643,9 @@ struct ieee80211_mgmt { } u; } __attribute__ ((packed)); +/* mgmt header + 1 byte category code */ +#define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u) +/* Control frames */ struct ieee80211_rts {
@@ -737,6 +740,21 @@ struct ieee80211_ht_addt_info {#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010 +/* block-ack parameters */ +#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002 +#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C +#define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFA0 +#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000 +#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800 + +/* +* A-PMDU buffer sizes +* According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2) +*/ +#define IEEE80211_MIN_AMPDU_BUF 0x8 +#define IEEE80211_MAX_AMPDU_BUF 0x40 + +/* Spatial Multiplexing Power Save Modes */ #define WLAN_HT_CAP_SM_PS_STATIC 0#define WLAN_HT_CAP_SM_PS_DYNAMIC 1
net/mac80211/ht.c new file +328 -0
328 lines not on this page · raw message
net/mac80211/mlme.c +0 -321
351 lines not on this page · raw message
net/mac80211/Makefile +1 -0
@@ -8,6 +8,7 @@ mac80211-y := \ wep.o \ wpa.o \ scan.o \ + ht.o \ mlme.o \ iface.o \ rate.o \
Johannes Berg
maintainerPATCH 8/8 mac80211: move some HT code out of main.c
In reply to Johannes BergNow that I've created ht.c, I can move the aggregation code from main.c into it.
--- net/mac80211/ht.c | 377 +++++++++++++++++++++++++++++++++++++++++++++++++++- net/mac80211/main.c | 373 --------------------------------------------------- 2 files changed, 375 insertions(+), 375 deletions(-)
net/mac80211/ht.c +375 -2
@@ -2,8 +2,8 @@* HT handling * * Copyright 2003, Jouni Malinen <[email protected]> -* Copyright 2004, Instant802 Networks, Inc. -* Copyright 2005, Devicescape Software, Inc. +* Copyright 2002-2005, Instant802 Networks, Inc. +* Copyright 2005-2006, Devicescape Software, Inc. * Copyright 2006-2007 Jiri Benc <[email protected]> * Copyright 2007, Michael Wu <[email protected]> * Copyright 2007-2008, Intel Corporation
@@ -18,6 +18,7 @@#include <net/mac80211.h> #include "ieee80211_i.h" #include "sta_info.h" +#include "wme.h" int ieee80211_ht_cap_ie_to_ht_info (struct ieee80211_ht_cap *ht_cap_ie,struct ieee80211_ht_info *ht_info)
@@ -326,3 +327,375 @@ void ieee80211_sta_tear_down_BA_sessions } } +int ieee80211_start_tx_ba_session (struct ieee80211_hw *hw,u8 *ra,u16 tid) +{ +struct ieee80211_local *local =hw_to_local (hw); +struct sta_info *sta; +struct ieee80211_sub_if_data *sdata; +u16 start_seq_num; +u8 *state; +int ret; +DECLARE_MAC_BUF (mac); + +if (tid >=STA_TID_NUM ) +return -EINVAL ; + +#ifdef CONFIG_MAC80211_HT_DEBUG +printk (KERN_DEBUG "Open BA session requested for %s tid %u\n" , +print_mac (mac, ra), tid); +#endif /* CONFIG_MAC80211_HT_DEBUG */ + +rcu_read_lock (); + + sta =sta_info_get (local, ra); +if (!sta) { +#ifdef CONFIG_MAC80211_HT_DEBUG +printk (KERN_DEBUG "Could not find the station\n" ); +#endif + ret = -ENOENT ; + goto exit; + } + +spin_lock_bh (&sta->lock); + +/* we have tried too many times, receiver does not want A-MPDU */ +if (sta->ampdu_mlme.addba_req_num[tid] >HT_AGG_MAX_RETRIES ) { + ret = -EBUSY ; + goto err_unlock_sta; + } + + state = &sta->ampdu_mlme.tid_state_tx[tid]; +/* check if the TID is not in aggregation flow already */ +if (*state !=HT_AGG_STATE_IDLE ) { +#ifdef CONFIG_MAC80211_HT_DEBUG +printk (KERN_DEBUG "BA request denied - session is not " +"idle on tid %u\n" , tid); +#endif /* CONFIG_MAC80211_HT_DEBUG */ + ret = -EAGAIN ; + goto err_unlock_sta; + } + +/* prepare A-MPDU MLME for Tx aggregation */ + sta->ampdu_mlme.tid_tx[tid] = +kmalloc (sizeof (struct tid_ampdu_tx ),GFP_ATOMIC ); +if (!sta->ampdu_mlme.tid_tx[tid]) { +#ifdef CONFIG_MAC80211_HT_DEBUG +if (net_ratelimit ()) +printk (KERN_ERR "allocate tx mlme to tid %d failed\n" , + tid); +#endif + ret = -ENOMEM ; + goto err_unlock_sta; + } +/* Tx timer */ + sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer.function = + sta_addba_resp_timer_expired; + sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer.data = + (unsigned long )&sta->timer_to_tid[tid]; +init_timer (&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer); + +/* create a new queue for this aggregation */ + ret =ieee80211_ht_agg_queue_add (local, sta, tid); + +/* case no queue is available to aggregation +* don't switch to aggregation */ +if (ret) { +#ifdef CONFIG_MAC80211_HT_DEBUG +printk (KERN_DEBUG "BA request denied - queue unavailable for" +" tid %d\n" , tid); +#endif /* CONFIG_MAC80211_HT_DEBUG */ + goto err_unlock_queue; + } + sdata = sta->sdata; + +/* Ok, the Addba frame hasn't been sent yet, but if the driver calls the +* call back right away, it must see that the flow has begun */ + *state |=HT_ADDBA_REQUESTED_MSK ; + +/* This is slightly racy because the queue isn't stopped */ + start_seq_num = sta->tid_seq[tid]; + +if (local->ops->ampdu_action) + ret = local->ops->ampdu_action (hw,IEEE80211_AMPDU_TX_START , + ra, tid, &start_seq_num); + +if (ret) { +/* No need to requeue the packets in the agg queue, since we +* held the tx lock: no packet could be enqueued to the newly +* allocated queue */ +ieee80211_ht_agg_queue_remove (local, sta, tid,0 ); +#ifdef CONFIG_MAC80211_HT_DEBUG +printk (KERN_DEBUG "BA request denied - HW unavailable for" +" tid %d\n" , tid); +#endif /* CONFIG_MAC80211_HT_DEBUG */ + *state =HT_AGG_STATE_IDLE ; + goto err_unlock_queue; + } + +/* Will put all the packets in the new SW queue */ +ieee80211_requeue (local, ieee802_1d_to_ac[tid]); +spin_unlock_bh (&sta->lock); + +/* send an addBA request */ + sta->ampdu_mlme.dialog_token_allocator++; + sta->ampdu_mlme.tid_tx[tid]->dialog_token = + sta->ampdu_mlme.dialog_token_allocator; + sta->ampdu_mlme.tid_tx[tid]->ssn = start_seq_num; + + +ieee80211_send_addba_request (sta->sdata, ra, tid, + sta->ampdu_mlme.tid_tx[tid]->dialog_token, + sta->ampdu_mlme.tid_tx[tid]->ssn, +0x40 ,5000 ); +/* activate the timer for the recipient's addBA response */ + sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer.expires = + jiffies +ADDBA_RESP_INTERVAL ; +add_timer (&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer); +#ifdef CONFIG_MAC80211_HT_DEBUG +printk (KERN_DEBUG "activated addBA response timer on tid %d\n" , tid); +#endif + goto exit; + +err_unlock_queue: +kfree (sta->ampdu_mlme.tid_tx[tid]); + sta->ampdu_mlme.tid_tx[tid] =NULL ; + ret = -EBUSY ; +err_unlock_sta: +spin_unlock_bh (&sta->lock); +exit: +rcu_read_unlock (); +return ret; +} +EXPORT_SYMBOL (ieee80211_start_tx_ba_session); + +int ieee80211_stop_tx_ba_session (struct ieee80211_hw *hw, +u8 *ra,u16 tid, +enum ieee80211_back_parties initiator) +{ +struct ieee80211_local *local =hw_to_local (hw); +struct sta_info *sta; +u8 *state; +int ret =0 ; +DECLARE_MAC_BUF (mac); + +if (tid >=STA_TID_NUM ) +return -EINVAL ; + +rcu_read_lock (); + sta =sta_info_get (local, ra); +if (!sta) { +rcu_read_unlock (); +return -ENOENT ; + } + +/* check if the TID is in aggregation */ + state = &sta->ampdu_mlme.tid_state_tx[tid]; +spin_lock_bh (&sta->lock); + +if (*state !=HT_AGG_STATE_OPERATIONAL ) { + ret = -ENOENT ; + goto stop_BA_exit; + } + +#ifdef CONFIG_MAC80211_HT_DEBUG +printk (KERN_DEBUG "Tx BA session stop requested for %s tid %u\n" , +print_mac (mac, ra), tid); +#endif /* CONFIG_MAC80211_HT_DEBUG */ + +ieee80211_stop_queue (hw, sta->tid_to_tx_q[tid]); + + *state =HT_AGG_STATE_REQ_STOP_BA_MSK | + (initiator <<HT_AGG_STATE_INITIATOR_SHIFT ); + +if (local->ops->ampdu_action) + ret = local->ops->ampdu_action (hw,IEEE80211_AMPDU_TX_STOP , + ra, tid,NULL ); + +/* case HW denied going back to legacy */ +if (ret) { +WARN_ON (ret != -EBUSY ); + *state =HT_AGG_STATE_OPERATIONAL ; +ieee80211_wake_queue (hw, sta->tid_to_tx_q[tid]); + goto stop_BA_exit; + } + +stop_BA_exit: +spin_unlock_bh (&sta->lock); +rcu_read_unlock (); +return ret; +} +EXPORT_SYMBOL (ieee80211_stop_tx_ba_session); + +void ieee80211_start_tx_ba_cb (struct ieee80211_hw *hw,u8 *ra,u16 tid) +{ +struct ieee80211_local *local =hw_to_local (hw); +struct sta_info *sta; +u8 *state; +DECLARE_MAC_BUF (mac); + +if (tid >=STA_TID_NUM ) { +#ifdef CONFIG_MAC80211_HT_DEBUG +printk (KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n" , + tid,STA_TID_NUM ); +#endif +return ; + } + +rcu_read_lock (); + sta =sta_info_get (local, ra); +if (!sta) { +rcu_read_unlock (); +#ifdef CONFIG_MAC80211_HT_DEBUG +printk (KERN_DEBUG "Could not find station: %s\n" , +print_mac (mac, ra)); +#endif +return ; + } + + state = &sta->ampdu_mlme.tid_state_tx[tid]; +spin_lock_bh (&sta->lock); + +if (!(*state &HT_ADDBA_REQUESTED_MSK )) { +#ifdef CONFIG_MAC80211_HT_DEBUG +printk (KERN_DEBUG "addBA was not requested yet, state is %d\n" , + *state); +#endif +spin_unlock_bh (&sta->lock); +rcu_read_unlock (); +return ; + } + +WARN_ON_ONCE (*state &HT_ADDBA_DRV_READY_MSK ); + + *state |=HT_ADDBA_DRV_READY_MSK ; + +if (*state ==HT_AGG_STATE_OPERATIONAL ) { +#ifdef CONFIG_MAC80211_HT_DEBUG +printk (KERN_DEBUG "Aggregation is on for tid %d \n" , tid); +#endif +ieee80211_wake_queue (hw, sta->tid_to_tx_q[tid]); + } +spin_unlock_bh (&sta->lock); +rcu_read_unlock (); +} +EXPORT_SYMBOL (ieee80211_start_tx_ba_cb); + +void ieee80211_stop_tx_ba_cb (struct ieee80211_hw *hw,u8 *ra,u8 tid) +{ +struct ieee80211_local *local =hw_to_local (hw); +struct sta_info *sta; +u8 *state; +int agg_queue; +DECLARE_MAC_BUF (mac); + +if (tid >=STA_TID_NUM ) { +#ifdef CONFIG_MAC80211_HT_DEBUG +printk (KERN_DEBUG "Bad TID value: tid = %d (>= %d)\n" , + tid,STA_TID_NUM ); +#endif +return ; + } + +#ifdef CONFIG_MAC80211_HT_DEBUG +printk (KERN_DEBUG "Stopping Tx BA session for %s tid %d\n" , +print_mac (mac, ra), tid); +#endif /* CONFIG_MAC80211_HT_DEBUG */ + +rcu_read_lock (); + sta =sta_info_get (local, ra); +if (!sta) { +#ifdef CONFIG_MAC80211_HT_DEBUG +printk (KERN_DEBUG "Could not find station: %s\n" , +print_mac (mac, ra)); +#endif +rcu_read_unlock (); +return ; + } + state = &sta->ampdu_mlme.tid_state_tx[tid]; + +/* NOTE: no need to use sta->lock in this state check, as +* ieee80211_stop_tx_ba_session will let only one stop call to +* pass through per sta/tid +*/ +if ((*state &HT_AGG_STATE_REQ_STOP_BA_MSK ) ==0 ) { +#ifdef CONFIG_MAC80211_HT_DEBUG +printk (KERN_DEBUG "unexpected callback to A-MPDU stop\n" ); +#endif +rcu_read_unlock (); +return ; + } + +if (*state &HT_AGG_STATE_INITIATOR_MSK ) +ieee80211_send_delba (sta->sdata, ra, tid, +WLAN_BACK_INITIATOR ,WLAN_REASON_QSTA_NOT_USE ); + + agg_queue = sta->tid_to_tx_q[tid]; + +ieee80211_ht_agg_queue_remove (local, sta, tid,1 ); + +/* We just requeued the all the frames that were in the +* removed queue, and since we might miss a softirq we do +* netif_schedule_queue. ieee80211_wake_queue is not used +* here as this queue is not necessarily stopped +*/ +netif_schedule_queue (netdev_get_tx_queue (local->mdev, agg_queue)); +spin_lock_bh (&sta->lock); + *state =HT_AGG_STATE_IDLE ; + sta->ampdu_mlme.addba_req_num[tid] =0 ; +kfree (sta->ampdu_mlme.tid_tx[tid]); + sta->ampdu_mlme.tid_tx[tid] =NULL ; +spin_unlock_bh (&sta->lock); + +rcu_read_unlock (); +} +EXPORT_SYMBOL (ieee80211_stop_tx_ba_cb); + +void ieee80211_start_tx_ba_cb_irqsafe (struct ieee80211_hw *hw, +const u8 *ra,u16 tid) +{ +struct ieee80211_local *local =hw_to_local (hw); +struct ieee80211_ra_tid *ra_tid; +struct sk_buff *skb =dev_alloc_skb (0 ); + +if (unlikely (!skb)) { +#ifdef CONFIG_MAC80211_HT_DEBUG +if (net_ratelimit ()) +printk (KERN_WARNING "%s: Not enough memory, " +"dropping start BA session" , skb->dev->name); +#endif +return ; + } + ra_tid = (struct ieee80211_ra_tid *) &skb->cb; +memcpy (&ra_tid->ra, ra,ETH_ALEN ); + ra_tid->tid = tid; + + skb->pkt_type =IEEE80211_ADDBA_MSG ; +skb_queue_tail (&local->skb_queue, skb); +tasklet_schedule (&local->tasklet); +} +EXPORT_SYMBOL (ieee80211_start_tx_ba_cb_irqsafe); + +void ieee80211_stop_tx_ba_cb_irqsafe (struct ieee80211_hw *hw, +const u8 *ra,u16 tid) +{ +struct ieee80211_local *local =hw_to_local (hw); +struct ieee80211_ra_tid *ra_tid; +struct sk_buff *skb =dev_alloc_skb (0 ); + +if (unlikely (!skb)) { +#ifdef CONFIG_MAC80211_HT_DEBUG +if (net_ratelimit ()) +printk (KERN_WARNING "%s: Not enough memory, " +"dropping stop BA session" , skb->dev->name); +#endif +return ; + } + ra_tid = (struct ieee80211_ra_tid *) &skb->cb; +memcpy (&ra_tid->ra, ra,ETH_ALEN ); + ra_tid->tid = tid; + + skb->pkt_type =IEEE80211_DELBA_MSG ; +skb_queue_tail (&local->skb_queue, skb); +tasklet_schedule (&local->tasklet); +} +EXPORT_SYMBOL (ieee80211_stop_tx_ba_cb_irqsafe);
net/mac80211/main.c +0 -373
379 lines not on this page · raw message
Johannes Berg
maintainer[PATCH 9/8] mac80211: clarify scan request
In reply to Johannes BergWhen a scan is requested for non-STA interfaces, we simply fire off a scan, but for STA interfaces we shouldn't because they could be in the middle of an association. This clarifies the corresponding code.
--- net/mac80211/scan.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
net/mac80211/scan.c +10 -1
@@ -674,23 +674,32 @@ int ieee80211_sta_start_scan(struct ieeeint ieee80211_sta_req_scan (struct ieee80211_sub_if_data *sdata,u8 *ssid,size_t ssid_len) { -struct ieee80211_if_sta *ifsta = &sdata->u.sta;struct ieee80211_local *local = sdata->local; +struct ieee80211_if_sta *ifsta;if (sdata->vif.type !=IEEE80211_IF_TYPE_STA )return ieee80211_sta_start_scan (sdata, ssid, ssid_len); +/* +* STA has a state machine that might need to defer scanning +* while it's trying to associate/authenticate, therefore we +* queue it up to the state machine in that case. +*/ +if (local->sta_sw_scanning || local->sta_hw_scanning) {if (local->scan_sdata == sdata)return 0 ;return -EBUSY ; } + ifsta = &sdata->u.sta; + ifsta->scan_ssid_len = ssid_len;if (ssid_len)memcpy (ifsta->scan_ssid, ssid, ssid_len);set_bit (IEEE80211_STA_REQ_SCAN , &ifsta->request);queue_work (local->hw.workqueue, &ifsta->work); +return 0 ; }
Johannes Berg
maintainer[PATCH 10/8] mac80211: simplify scan start
In reply to Johannes Bergieee80211_sta_start_scan() can very well take a non-NULL ssid pointer with a zero ssid_len.
--- net/mac80211/mlme.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
net/mac80211/mlme.c +1 -4
@@ -3053,10 +3053,7 @@ void ieee80211_sta_work(struct work_stru ifsta->state != IEEE80211_STA_MLME_AUTHENTICATE && ifsta->state != IEEE80211_STA_MLME_ASSOCIATE && test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifsta->request)) { -if (ifsta->scan_ssid_len) -ieee80211_sta_start_scan (sdata, ifsta->scan_ssid, ifsta->scan_ssid_len); -else -ieee80211_sta_start_scan (sdata,NULL ,0 ); +ieee80211_sta_start_scan (sdata, ifsta->scan_ssid, ifsta->scan_ssid_len);return ; }
Johannes Berg
maintainer[PATCH 11/8] mac80211: remove useless 'ibss' parameter
In reply to Johannes BergEver since we refactored beaconing to not be controlled by a fake queue this parameter to ieee80211_sta_def_wmm_params has been unused.
--- net/mac80211/mlme.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/mac80211/mlme.c +3 -4
@@ -188,8 +188,7 @@ void ieee80211_send_probe_req(struct iee/* MLME */ static void ieee80211_sta_def_wmm_params (struct ieee80211_sub_if_data *sdata, -struct ieee80211_sta_bss *bss, -int ibss) +struct ieee80211_sta_bss *bss) {struct ieee80211_local *local = sdata->local;int i, have_higher_than_11mbit =0 ;
@@ -1850,7 +1849,7 @@ static int ieee80211_sta_join_ibss(struc } ifsta->supp_rates_bits[local->hw.conf.channel->band] = rates; -ieee80211_sta_def_wmm_params (sdata, bss,1 ); +ieee80211_sta_def_wmm_params (sdata, bss); ifsta->state =IEEE80211_STA_MLME_IBSS_JOINED ;mod_timer (&ifsta->timer, jiffies +IEEE80211_IBSS_MERGE_INTERVAL );
@@ -2933,7 +2932,7 @@ static int ieee80211_sta_config_auth(strieee80211_sta_set_ssid (sdata, selected->ssid, selected->ssid_len);ieee80211_sta_set_bssid (sdata, selected->bssid); -ieee80211_sta_def_wmm_params (sdata, selected,0 ); +ieee80211_sta_def_wmm_params (sdata, selected);/* Send out direct probe if no probe resp was received or * the one we have is outdated
Johannes Berg
maintainer[PATCH 12/8] mac80211: reorder frame code in mlme
In reply to Johannes BergThis reorders all frame sending functions to be at the top of the file. When reading the file, I tend to be looking at either the frame code or the state machine, and having them mixed in the file is confusing. When all frame sending is at the top the remainder of the file is more readable, in my opinion.
---
The only actual change is removing a stray "return;" at the end of a function.
net/mac80211/mlme.c | 884 +++++++++++++++++++++++++--------------------------- 1 file changed, 441 insertions(+), 443 deletions(-)
net/mac80211/mlme.c +441 -443
@@ -74,6 +74,27 @@ static u8 *ieee80211_bss_get_ie(struct ireturn NULL ; } +static int ieee80211_compatible_rates (struct ieee80211_sta_bss *bss, +struct ieee80211_supported_band *sband, +u64 *rates) +{ +int i, j, count; + *rates =0 ; + count =0 ; +for (i =0 ; i < bss->supp_rates_len; i++) { +int rate = (bss->supp_rates[i] &0x7F ) *5 ; + +for (j =0 ; j < sband->n_bitrates; j++) +if (sband->bitrates[j].bitrate == rate) { + *rates |=BIT (j); + count++; +break ; + } + } + +return count; +} +/* frame sending functions */ void ieee80211_sta_tx (struct ieee80211_sub_if_data *sdata,struct sk_buff *skb,int encrypt)
@@ -186,6 +207,364 @@ void ieee80211_send_probe_req(struct ieeieee80211_sta_tx (sdata, skb,0 ); } +static void ieee80211_send_assoc (struct ieee80211_sub_if_data *sdata, +struct ieee80211_if_sta *ifsta) +{ +struct ieee80211_local *local = sdata->local; +struct sk_buff *skb; +struct ieee80211_mgmt *mgmt; +u8 *pos, *ies, *ht_add_ie; +int i, len, count, rates_len, supp_rates_len; +u16 capab; +struct ieee80211_sta_bss *bss; +int wmm =0 ; +struct ieee80211_supported_band *sband; +u64 rates =0 ; + + skb =dev_alloc_skb (local->hw.extra_tx_headroom + +sizeof (*mgmt) +200 + ifsta->extra_ie_len + + ifsta->ssid_len); +if (!skb) { +printk (KERN_DEBUG "%s: failed to allocate buffer for assoc " +"frame\n" , sdata->dev->name); +return ; + } +skb_reserve (skb, local->hw.extra_tx_headroom); + + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; + + capab = ifsta->capab; + +if (local->hw.conf.channel->band ==IEEE80211_BAND_2GHZ ) { +if (!(local->hw.flags &IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE )) + capab |=WLAN_CAPABILITY_SHORT_SLOT_TIME ; +if (!(local->hw.flags &IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE )) + capab |=WLAN_CAPABILITY_SHORT_PREAMBLE ; + } + + bss =ieee80211_rx_bss_get (local, ifsta->bssid, + local->hw.conf.channel->center_freq, + ifsta->ssid, ifsta->ssid_len); +if (bss) { +if (bss->capability &WLAN_CAPABILITY_PRIVACY ) + capab |=WLAN_CAPABILITY_PRIVACY ; +if (bss->wmm_used) + wmm =1 ; + +/* get all rates supported by the device and the AP as +* some APs don't like getting a superset of their rates +* in the association request (e.g. D-Link DAP 1353 in +* b-only mode) */ + rates_len =ieee80211_compatible_rates (bss, sband, &rates); + +if ((bss->capability &WLAN_CAPABILITY_SPECTRUM_MGMT ) && + (local->hw.flags &IEEE80211_HW_SPECTRUM_MGMT )) + capab |=WLAN_CAPABILITY_SPECTRUM_MGMT ; + +ieee80211_rx_bss_put (local, bss); + }else { + rates = ~0 ; + rates_len = sband->n_bitrates; + } + + mgmt = (struct ieee80211_mgmt *)skb_put (skb,24 ); +memset (mgmt,0 ,24 ); +memcpy (mgmt->da, ifsta->bssid,ETH_ALEN ); +memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN ); +memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); + +if (ifsta->flags &IEEE80211_STA_PREV_BSSID_SET ) { +skb_put (skb,10 ); + mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | +IEEE80211_STYPE_REASSOC_REQ ); + mgmt->u.reassoc_req.capab_info =cpu_to_le16 (capab); + mgmt->u.reassoc_req.listen_interval = +cpu_to_le16 (local->hw.conf.listen_interval); +memcpy (mgmt->u.reassoc_req.current_ap, ifsta->prev_bssid, +ETH_ALEN ); + }else { +skb_put (skb,4 ); + mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | +IEEE80211_STYPE_ASSOC_REQ ); + mgmt->u.assoc_req.capab_info =cpu_to_le16 (capab); + mgmt->u.reassoc_req.listen_interval = +cpu_to_le16 (local->hw.conf.listen_interval); + } + +/* SSID */ + ies = pos =skb_put (skb,2 + ifsta->ssid_len); + *pos++ =WLAN_EID_SSID ; + *pos++ = ifsta->ssid_len; +memcpy (pos, ifsta->ssid, ifsta->ssid_len); + +/* add all rates which were marked to be used above */ + supp_rates_len = rates_len; +if (supp_rates_len >8 ) + supp_rates_len =8 ; + + len = sband->n_bitrates; + pos =skb_put (skb, supp_rates_len +2 ); + *pos++ =WLAN_EID_SUPP_RATES ; + *pos++ = supp_rates_len; + + count =0 ; +for (i =0 ; i < sband->n_bitrates; i++) { +if (BIT (i) & rates) { +int rate = sband->bitrates[i].bitrate; + *pos++ = (u8) (rate /5 ); +if (++count ==8 ) +break ; + } + } + +if (rates_len > count) { + pos =skb_put (skb, rates_len - count +2 ); + *pos++ =WLAN_EID_EXT_SUPP_RATES ; + *pos++ = rates_len - count; + +for (i++; i < sband->n_bitrates; i++) { +if (BIT (i) & rates) { +int rate = sband->bitrates[i].bitrate; + *pos++ = (u8) (rate /5 ); + } + } + } + +if (capab &WLAN_CAPABILITY_SPECTRUM_MGMT ) { +/* 1. power capabilities */ + pos =skb_put (skb,4 ); + *pos++ =WLAN_EID_PWR_CAPABILITY ; + *pos++ =2 ; + *pos++ =0 ;/* min tx power */ + *pos++ = local->hw.conf.channel->max_power;/* max tx power */ + +/* 2. supported channels */ +/* TODO: get this in reg domain format */ + pos =skb_put (skb,2 * sband->n_channels +2 ); + *pos++ =WLAN_EID_SUPPORTED_CHANNELS ; + *pos++ =2 * sband->n_channels; +for (i =0 ; i < sband->n_channels; i++) { + *pos++ =ieee80211_frequency_to_channel ( + sband->channels[i].center_freq); + *pos++ =1 ;/* one channel in the subband*/ + } + } + +if (ifsta->extra_ie) { + pos =skb_put (skb, ifsta->extra_ie_len); +memcpy (pos, ifsta->extra_ie, ifsta->extra_ie_len); + } + +if (wmm && (ifsta->flags &IEEE80211_STA_WMM_ENABLED )) { + pos =skb_put (skb,9 ); + *pos++ =WLAN_EID_VENDOR_SPECIFIC ; + *pos++ =7 ;/* len */ + *pos++ =0x00 ;/* Microsoft OUI 00:50:F2 */ + *pos++ =0x50 ; + *pos++ =0xf2 ; + *pos++ =2 ;/* WME */ + *pos++ =0 ;/* WME info */ + *pos++ =1 ;/* WME ver */ + *pos++ =0 ; + } + +/* wmm support is a must to HT */ +if (wmm && (ifsta->flags &IEEE80211_STA_WMM_ENABLED ) && + sband->ht_info.ht_supported && + (ht_add_ie =ieee80211_bss_get_ie (bss,WLAN_EID_HT_EXTRA_INFO ))) { +struct ieee80211_ht_addt_info *ht_add_info = + (struct ieee80211_ht_addt_info *)ht_add_ie; +u16 cap = sband->ht_info.cap; +__le16 tmp; +u32 flags = local->hw.conf.channel->flags; + +switch (ht_add_info->ht_param &IEEE80211_HT_IE_CHA_SEC_OFFSET ) { +case IEEE80211_HT_IE_CHA_SEC_ABOVE : +if (flags &IEEE80211_CHAN_NO_FAT_ABOVE ) { + cap &= ~IEEE80211_HT_CAP_SUP_WIDTH ; + cap &= ~IEEE80211_HT_CAP_SGI_40 ; + } +break ; +case IEEE80211_HT_IE_CHA_SEC_BELOW : +if (flags &IEEE80211_CHAN_NO_FAT_BELOW ) { + cap &= ~IEEE80211_HT_CAP_SUP_WIDTH ; + cap &= ~IEEE80211_HT_CAP_SGI_40 ; + } +break ; + } + + tmp =cpu_to_le16 (cap); + 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 )); +memcpy (pos, &tmp,sizeof (u16)); + pos +=sizeof (u16); +/* TODO: needs a define here for << 2 */ + *pos++ = sband->ht_info.ampdu_factor | + (sband->ht_info.ampdu_density <<2 ); +memcpy (pos, sband->ht_info.supp_mcs_set,16 ); + } + +kfree (ifsta->assocreq_ies); + ifsta->assocreq_ies_len = (skb->data + skb->len) - ies; + ifsta->assocreq_ies =kmalloc (ifsta->assocreq_ies_len,GFP_KERNEL ); +if (ifsta->assocreq_ies) +memcpy (ifsta->assocreq_ies, ies, ifsta->assocreq_ies_len); + +ieee80211_sta_tx (sdata, skb,0 ); +} + + +static void ieee80211_send_deauth (struct ieee80211_sub_if_data *sdata, +struct ieee80211_if_sta *ifsta,u16 reason) +{ +struct ieee80211_local *local = sdata->local; +struct sk_buff *skb; +struct ieee80211_mgmt *mgmt; + + skb =dev_alloc_skb (local->hw.extra_tx_headroom +sizeof (*mgmt)); +if (!skb) { +printk (KERN_DEBUG "%s: failed to allocate buffer for deauth " +"frame\n" , sdata->dev->name); +return ; + } +skb_reserve (skb, local->hw.extra_tx_headroom); + + mgmt = (struct ieee80211_mgmt *)skb_put (skb,24 ); +memset (mgmt,0 ,24 ); +memcpy (mgmt->da, ifsta->bssid,ETH_ALEN ); +memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN ); +memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); + mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | +IEEE80211_STYPE_DEAUTH ); +skb_put (skb,2 ); + mgmt->u.deauth.reason_code =cpu_to_le16 (reason); + +ieee80211_sta_tx (sdata, skb,0 ); +} + +static void ieee80211_send_disassoc (struct ieee80211_sub_if_data *sdata, +struct ieee80211_if_sta *ifsta,u16 reason) +{ +struct ieee80211_local *local = sdata->local; +struct sk_buff *skb; +struct ieee80211_mgmt *mgmt; + + skb =dev_alloc_skb (local->hw.extra_tx_headroom +sizeof (*mgmt)); +if (!skb) { +printk (KERN_DEBUG "%s: failed to allocate buffer for disassoc " +"frame\n" , sdata->dev->name); +return ; + } +skb_reserve (skb, local->hw.extra_tx_headroom); + + mgmt = (struct ieee80211_mgmt *)skb_put (skb,24 ); +memset (mgmt,0 ,24 ); +memcpy (mgmt->da, ifsta->bssid,ETH_ALEN ); +memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN ); +memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); + mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | +IEEE80211_STYPE_DISASSOC ); +skb_put (skb,2 ); + mgmt->u.disassoc.reason_code =cpu_to_le16 (reason); + +ieee80211_sta_tx (sdata, skb,0 ); +} + +static void ieee80211_send_addba_resp (struct ieee80211_sub_if_data *sdata,u8 *da,u16 tid, +u8 dialog_token,u16 status,u16 policy, +u16 buf_size,u16 timeout) +{ +struct ieee80211_if_sta *ifsta = &sdata->u.sta; +struct ieee80211_local *local = sdata->local; +struct sk_buff *skb; +struct ieee80211_mgmt *mgmt; +u16 capab; + + skb =dev_alloc_skb (sizeof (*mgmt) + local->hw.extra_tx_headroom); + +if (!skb) { +printk (KERN_DEBUG "%s: failed to allocate buffer " +"for addba resp frame\n" , sdata->dev->name); +return ; + } + +skb_reserve (skb, local->hw.extra_tx_headroom); + mgmt = (struct ieee80211_mgmt *)skb_put (skb,24 ); +memset (mgmt,0 ,24 ); +memcpy (mgmt->da, da,ETH_ALEN ); +memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN ); +if (sdata->vif.type ==IEEE80211_IF_TYPE_AP ) +memcpy (mgmt->bssid, sdata->dev->dev_addr,ETH_ALEN ); +else +memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); + mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | +IEEE80211_STYPE_ACTION ); + +skb_put (skb,1 +sizeof (mgmt->u.action.u.addba_resp)); + mgmt->u.action.category =WLAN_CATEGORY_BACK ; + mgmt->u.action.u.addba_resp.action_code =WLAN_ACTION_ADDBA_RESP ; + mgmt->u.action.u.addba_resp.dialog_token = dialog_token; + + capab = (u16)(policy <<1 );/* bit 1 aggregation policy */ + capab |= (u16)(tid <<2 );/* bit 5:2 TID number */ + capab |= (u16)(buf_size <<6 );/* bit 15:6 max size of aggregation */ + + mgmt->u.action.u.addba_resp.capab =cpu_to_le16 (capab); + mgmt->u.action.u.addba_resp.timeout =cpu_to_le16 (timeout); + mgmt->u.action.u.addba_resp.status =cpu_to_le16 (status); + +ieee80211_sta_tx (sdata, skb,0 ); +} + +static void ieee80211_send_refuse_measurement_request (struct ieee80211_sub_if_data *sdata, +struct ieee80211_msrment_ie *request_ie, +const u8 *da,const u8 *bssid, +u8 dialog_token) +{ +struct ieee80211_local *local = sdata->local; +struct sk_buff *skb; +struct ieee80211_mgmt *msr_report; + + skb =dev_alloc_skb (sizeof (*msr_report) + local->hw.extra_tx_headroom + +sizeof (struct ieee80211_msrment_ie )); + +if (!skb) { +printk (KERN_ERR "%s: failed to allocate buffer for " +"measurement report frame\n" , sdata->dev->name); +return ; + } + +skb_reserve (skb, local->hw.extra_tx_headroom); + msr_report = (struct ieee80211_mgmt *)skb_put (skb,24 ); +memset (msr_report,0 ,24 ); +memcpy (msr_report->da, da,ETH_ALEN ); +memcpy (msr_report->sa, sdata->dev->dev_addr,ETH_ALEN ); +memcpy (msr_report->bssid, bssid,ETH_ALEN ); + msr_report->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | +IEEE80211_STYPE_ACTION ); + +skb_put (skb,1 +sizeof (msr_report->u.action.u.measurement)); + msr_report->u.action.category =WLAN_CATEGORY_SPECTRUM_MGMT ; + msr_report->u.action.u.measurement.action_code = +WLAN_ACTION_SPCT_MSR_RPRT ; + msr_report->u.action.u.measurement.dialog_token = dialog_token; + + msr_report->u.action.u.measurement.element_id =WLAN_EID_MEASURE_REPORT ; + msr_report->u.action.u.measurement.length = +sizeof (struct ieee80211_msrment_ie ); + +memset (&msr_report->u.action.u.measurement.msr_elem,0 , +sizeof (struct ieee80211_msrment_ie )); + msr_report->u.action.u.measurement.msr_elem.token = request_ie->token; + msr_report->u.action.u.measurement.msr_elem.mode |= +IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED ; + msr_report->u.action.u.measurement.msr_elem.type = request_ie->type; + +ieee80211_sta_tx (sdata, skb,0 ); +} +/* MLME */ static void ieee80211_sta_def_wmm_params (struct ieee80211_sub_if_data *sdata,struct ieee80211_sta_bss *bss)
@@ -430,379 +809,85 @@ static void ieee80211_set_associated(str sdata->bss_conf.dtim_period = bss->dtim_period; changed |=ieee80211_handle_bss_capability (sdata, bss); - -ieee80211_rx_bss_put (local, bss); - } - -if (conf->flags &IEEE80211_CONF_SUPPORT_HT_MODE ) { - changed |=BSS_CHANGED_HT ; - sdata->bss_conf.assoc_ht =1 ; - sdata->bss_conf.ht_conf = &conf->ht_conf; - sdata->bss_conf.ht_bss_conf = &conf->ht_bss_conf; - } - - ifsta->flags |=IEEE80211_STA_PREV_BSSID_SET ; -memcpy (ifsta->prev_bssid, sdata->u.sta.bssid,ETH_ALEN ); -ieee80211_sta_send_associnfo (sdata, ifsta); - - ifsta->last_probe = jiffies; -ieee80211_led_assoc (local,1 ); - - sdata->bss_conf.assoc =1 ; -ieee80211_bss_info_change_notify (sdata, changed); - -netif_tx_start_all_queues (sdata->dev); -netif_carrier_on (sdata->dev); - -ieee80211_sta_send_apinfo (sdata, ifsta); -} - -static void ieee80211_direct_probe (struct ieee80211_sub_if_data *sdata, -struct ieee80211_if_sta *ifsta) -{ -DECLARE_MAC_BUF (mac); - - ifsta->direct_probe_tries++; -if (ifsta->direct_probe_tries >IEEE80211_AUTH_MAX_TRIES ) { -printk (KERN_DEBUG "%s: direct probe to AP %s timed out\n" , - sdata->dev->name,print_mac (mac, ifsta->bssid)); - ifsta->state =IEEE80211_STA_MLME_DISABLED ; -return ; - } - -printk (KERN_DEBUG "%s: direct probe to AP %s try %d\n" , - sdata->dev->name,print_mac (mac, ifsta->bssid), - ifsta->direct_probe_tries); - - ifsta->state =IEEE80211_STA_MLME_DIRECT_PROBE ; - -set_bit (IEEE80211_STA_REQ_DIRECT_PROBE , &ifsta->request); - -/* Direct probe is sent to broadcast address as some APs -* will not answer to direct packet in unassociated state. -*/ -ieee80211_send_probe_req (sdata,NULL , - ifsta->ssid, ifsta->ssid_len); - -mod_timer (&ifsta->timer, jiffies +IEEE80211_AUTH_TIMEOUT ); -} - - -static void ieee80211_authenticate (struct ieee80211_sub_if_data *sdata, -struct ieee80211_if_sta *ifsta) -{ -DECLARE_MAC_BUF (mac); - - ifsta->auth_tries++; -if (ifsta->auth_tries >IEEE80211_AUTH_MAX_TRIES ) { -printk (KERN_DEBUG "%s: authentication with AP %s" -" timed out\n" , - sdata->dev->name,print_mac (mac, ifsta->bssid)); - ifsta->state =IEEE80211_STA_MLME_DISABLED ; -return ; - } - - ifsta->state =IEEE80211_STA_MLME_AUTHENTICATE ; -printk (KERN_DEBUG "%s: authenticate with AP %s\n" , - sdata->dev->name,print_mac (mac, ifsta->bssid)); - -ieee80211_send_auth (sdata, ifsta,1 ,NULL ,0 ,0 ); - -mod_timer (&ifsta->timer, jiffies +IEEE80211_AUTH_TIMEOUT ); -} - -static int ieee80211_compatible_rates (struct ieee80211_sta_bss *bss, -struct ieee80211_supported_band *sband, -u64 *rates) -{ -int i, j, count; - *rates =0 ; - count =0 ; -for (i =0 ; i < bss->supp_rates_len; i++) { -int rate = (bss->supp_rates[i] &0x7F ) *5 ; - -for (j =0 ; j < sband->n_bitrates; j++) -if (sband->bitrates[j].bitrate == rate) { - *rates |=BIT (j); - count++; -break ; - } - } - -return count; -} - -static void ieee80211_send_assoc (struct ieee80211_sub_if_data *sdata, -struct ieee80211_if_sta *ifsta) -{ -struct ieee80211_local *local = sdata->local; -struct sk_buff *skb; -struct ieee80211_mgmt *mgmt; -u8 *pos, *ies, *ht_add_ie; -int i, len, count, rates_len, supp_rates_len; -u16 capab; -struct ieee80211_sta_bss *bss; -int wmm =0 ; -struct ieee80211_supported_band *sband; -u64 rates =0 ; - - skb =dev_alloc_skb (local->hw.extra_tx_headroom + -sizeof (*mgmt) +200 + ifsta->extra_ie_len + - ifsta->ssid_len); -if (!skb) { -printk (KERN_DEBUG "%s: failed to allocate buffer for assoc " -"frame\n" , sdata->dev->name); -return ; - } -skb_reserve (skb, local->hw.extra_tx_headroom); - - sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; - - capab = ifsta->capab; - -if (local->hw.conf.channel->band ==IEEE80211_BAND_2GHZ ) { -if (!(local->hw.flags &IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE )) - capab |=WLAN_CAPABILITY_SHORT_SLOT_TIME ; -if (!(local->hw.flags &IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE )) - capab |=WLAN_CAPABILITY_SHORT_PREAMBLE ; - } - - bss =ieee80211_rx_bss_get (local, ifsta->bssid, - local->hw.conf.channel->center_freq, - ifsta->ssid, ifsta->ssid_len); -if (bss) { -if (bss->capability &WLAN_CAPABILITY_PRIVACY ) - capab |=WLAN_CAPABILITY_PRIVACY ; -if (bss->wmm_used) - wmm =1 ; - -/* get all rates supported by the device and the AP as -* some APs don't like getting a superset of their rates -* in the association request (e.g. D-Link DAP 1353 in -* b-only mode) */ - rates_len =ieee80211_compatible_rates (bss, sband, &rates); - -if ((bss->capability &WLAN_CAPABILITY_SPECTRUM_MGMT ) && - (local->hw.flags &IEEE80211_HW_SPECTRUM_MGMT )) - capab |=WLAN_CAPABILITY_SPECTRUM_MGMT ; - -ieee80211_rx_bss_put (local, bss); - }else { - rates = ~0 ; - rates_len = sband->n_bitrates; - } - - mgmt = (struct ieee80211_mgmt *)skb_put (skb,24 ); -memset (mgmt,0 ,24 ); -memcpy (mgmt->da, ifsta->bssid,ETH_ALEN ); -memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN ); -memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); - -if (ifsta->flags &IEEE80211_STA_PREV_BSSID_SET ) { -skb_put (skb,10 ); - mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | -IEEE80211_STYPE_REASSOC_REQ ); - mgmt->u.reassoc_req.capab_info =cpu_to_le16 (capab); - mgmt->u.reassoc_req.listen_interval = -cpu_to_le16 (local->hw.conf.listen_interval); -memcpy (mgmt->u.reassoc_req.current_ap, ifsta->prev_bssid, -ETH_ALEN ); - }else { -skb_put (skb,4 ); - mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | -IEEE80211_STYPE_ASSOC_REQ ); - mgmt->u.assoc_req.capab_info =cpu_to_le16 (capab); - mgmt->u.reassoc_req.listen_interval = -cpu_to_le16 (local->hw.conf.listen_interval); - } - -/* SSID */ - ies = pos =skb_put (skb,2 + ifsta->ssid_len); - *pos++ =WLAN_EID_SSID ; - *pos++ = ifsta->ssid_len; -memcpy (pos, ifsta->ssid, ifsta->ssid_len); - -/* add all rates which were marked to be used above */ - supp_rates_len = rates_len; -if (supp_rates_len >8 ) - supp_rates_len =8 ; - - len = sband->n_bitrates; - pos =skb_put (skb, supp_rates_len +2 ); - *pos++ =WLAN_EID_SUPP_RATES ; - *pos++ = supp_rates_len; - - count =0 ; -for (i =0 ; i < sband->n_bitrates; i++) { -if (BIT (i) & rates) { -int rate = sband->bitrates[i].bitrate; - *pos++ = (u8) (rate /5 ); -if (++count ==8 ) -break ; - } - } - -if (rates_len > count) { - pos =skb_put (skb, rates_len - count +2 ); - *pos++ =WLAN_EID_EXT_SUPP_RATES ; - *pos++ = rates_len - count; - -for (i++; i < sband->n_bitrates; i++) { -if (BIT (i) & rates) { -int rate = sband->bitrates[i].bitrate; - *pos++ = (u8) (rate /5 ); - } - } - } - -if (capab &WLAN_CAPABILITY_SPECTRUM_MGMT ) { -/* 1. power capabilities */ - pos =skb_put (skb,4 ); - *pos++ =WLAN_EID_PWR_CAPABILITY ; - *pos++ =2 ; - *pos++ =0 ;/* min tx power */ - *pos++ = local->hw.conf.channel->max_power;/* max tx power */ - -/* 2. supported channels */ -/* TODO: get this in reg domain format */ - pos =skb_put (skb,2 * sband->n_channels +2 ); - *pos++ =WLAN_EID_SUPPORTED_CHANNELS ; - *pos++ =2 * sband->n_channels; -for (i =0 ; i < sband->n_channels; i++) { - *pos++ =ieee80211_frequency_to_channel ( - sband->channels[i].center_freq); - *pos++ =1 ;/* one channel in the subband*/ - } - } - -if (ifsta->extra_ie) { - pos =skb_put (skb, ifsta->extra_ie_len); -memcpy (pos, ifsta->extra_ie, ifsta->extra_ie_len); + +ieee80211_rx_bss_put (local, bss); } -if (wmm && (ifsta->flags &IEEE80211_STA_WMM_ENABLED )) { - pos =skb_put (skb,9 ); - *pos++ =WLAN_EID_VENDOR_SPECIFIC ; - *pos++ =7 ;/* len */ - *pos++ =0x00 ;/* Microsoft OUI 00:50:F2 */ - *pos++ =0x50 ; - *pos++ =0xf2 ; - *pos++ =2 ;/* WME */ - *pos++ =0 ;/* WME info */ - *pos++ =1 ;/* WME ver */ - *pos++ =0 ; +if (conf->flags &IEEE80211_CONF_SUPPORT_HT_MODE ) { + changed |=BSS_CHANGED_HT ; + sdata->bss_conf.assoc_ht =1 ; + sdata->bss_conf.ht_conf = &conf->ht_conf; + sdata->bss_conf.ht_bss_conf = &conf->ht_bss_conf; } -/* wmm support is a must to HT */ -if (wmm && (ifsta->flags &IEEE80211_STA_WMM_ENABLED ) && - sband->ht_info.ht_supported && - (ht_add_ie =ieee80211_bss_get_ie (bss,WLAN_EID_HT_EXTRA_INFO ))) { -struct ieee80211_ht_addt_info *ht_add_info = - (struct ieee80211_ht_addt_info *)ht_add_ie; -u16 cap = sband->ht_info.cap; -__le16 tmp; -u32 flags = local->hw.conf.channel->flags; + ifsta->flags |=IEEE80211_STA_PREV_BSSID_SET ; +memcpy (ifsta->prev_bssid, sdata->u.sta.bssid,ETH_ALEN ); +ieee80211_sta_send_associnfo (sdata, ifsta); -switch (ht_add_info->ht_param &IEEE80211_HT_IE_CHA_SEC_OFFSET ) { -case IEEE80211_HT_IE_CHA_SEC_ABOVE : -if (flags &IEEE80211_CHAN_NO_FAT_ABOVE ) { - cap &= ~IEEE80211_HT_CAP_SUP_WIDTH ; - cap &= ~IEEE80211_HT_CAP_SGI_40 ; - } -break ; -case IEEE80211_HT_IE_CHA_SEC_BELOW : -if (flags &IEEE80211_CHAN_NO_FAT_BELOW ) { - cap &= ~IEEE80211_HT_CAP_SUP_WIDTH ; - cap &= ~IEEE80211_HT_CAP_SGI_40 ; - } -break ; - } + ifsta->last_probe = jiffies; +ieee80211_led_assoc (local,1 ); - tmp =cpu_to_le16 (cap); - 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 )); -memcpy (pos, &tmp,sizeof (u16)); - pos +=sizeof (u16); -/* TODO: needs a define here for << 2 */ - *pos++ = sband->ht_info.ampdu_factor | - (sband->ht_info.ampdu_density <<2 ); -memcpy (pos, sband->ht_info.supp_mcs_set,16 ); - } + sdata->bss_conf.assoc =1 ; +ieee80211_bss_info_change_notify (sdata, changed); -kfree (ifsta->assocreq_ies); - ifsta->assocreq_ies_len = (skb->data + skb->len) - ies; - ifsta->assocreq_ies =kmalloc (ifsta->assocreq_ies_len,GFP_KERNEL ); -if (ifsta->assocreq_ies) -memcpy (ifsta->assocreq_ies, ies, ifsta->assocreq_ies_len); +netif_tx_start_all_queues (sdata->dev); +netif_carrier_on (sdata->dev); -ieee80211_sta_tx (sdata, skb,0 ); +ieee80211_sta_send_apinfo (sdata, ifsta); } - -static void ieee80211_send_deauth (struct ieee80211_sub_if_data *sdata, -struct ieee80211_if_sta *ifsta,u16 reason) +static void ieee80211_direct_probe (struct ieee80211_sub_if_data *sdata, +struct ieee80211_if_sta *ifsta) { -struct ieee80211_local *local = sdata->local; -struct sk_buff *skb; -struct ieee80211_mgmt *mgmt; +DECLARE_MAC_BUF (mac); - skb =dev_alloc_skb (local->hw.extra_tx_headroom +sizeof (*mgmt)); -if (!skb) { -printk (KERN_DEBUG "%s: failed to allocate buffer for deauth " -"frame\n" , sdata->dev->name); + ifsta->direct_probe_tries++; +if (ifsta->direct_probe_tries >IEEE80211_AUTH_MAX_TRIES ) { +printk (KERN_DEBUG "%s: direct probe to AP %s timed out\n" , + sdata->dev->name,print_mac (mac, ifsta->bssid)); + ifsta->state =IEEE80211_STA_MLME_DISABLED ;return ; } -skb_reserve (skb, local->hw.extra_tx_headroom); - mgmt = (struct ieee80211_mgmt *)skb_put (skb,24 ); -memset (mgmt,0 ,24 ); -memcpy (mgmt->da, ifsta->bssid,ETH_ALEN ); -memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN ); -memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); - mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | -IEEE80211_STYPE_DEAUTH ); -skb_put (skb,2 ); - mgmt->u.deauth.reason_code =cpu_to_le16 (reason); +printk (KERN_DEBUG "%s: direct probe to AP %s try %d\n" , + sdata->dev->name,print_mac (mac, ifsta->bssid), + ifsta->direct_probe_tries); -ieee80211_sta_tx (sdata, skb,0 ); -} + ifsta->state =IEEE80211_STA_MLME_DIRECT_PROBE ; -static int ieee80211_sta_wep_configured (struct ieee80211_sub_if_data *sdata) -{ -if (!sdata || !sdata->default_key || - sdata->default_key->conf.alg !=ALG_WEP ) -return 0 ; -return 1 ; +set_bit (IEEE80211_STA_REQ_DIRECT_PROBE , &ifsta->request); + +/* Direct probe is sent to broadcast address as some APs +* will not answer to direct packet in unassociated state. +*/ +ieee80211_send_probe_req (sdata,NULL , + ifsta->ssid, ifsta->ssid_len); + +mod_timer (&ifsta->timer, jiffies +IEEE80211_AUTH_TIMEOUT ); } -static void ieee80211_send_disassoc (struct ieee80211_sub_if_data *sdata, -struct ieee80211_if_sta *ifsta,u16 reason) + +static void ieee80211_authenticate (struct ieee80211_sub_if_data *sdata, +struct ieee80211_if_sta *ifsta) { -struct ieee80211_local *local = sdata->local; -struct sk_buff *skb; -struct ieee80211_mgmt *mgmt; +DECLARE_MAC_BUF (mac); - skb =dev_alloc_skb (local->hw.extra_tx_headroom +sizeof (*mgmt)); -if (!skb) { -printk (KERN_DEBUG "%s: failed to allocate buffer for disassoc " -"frame\n" , sdata->dev->name); + ifsta->auth_tries++; +if (ifsta->auth_tries >IEEE80211_AUTH_MAX_TRIES ) { +printk (KERN_DEBUG "%s: authentication with AP %s" +" timed out\n" , + sdata->dev->name,print_mac (mac, ifsta->bssid)); + ifsta->state =IEEE80211_STA_MLME_DISABLED ;return ; } -skb_reserve (skb, local->hw.extra_tx_headroom); - mgmt = (struct ieee80211_mgmt *)skb_put (skb,24 ); -memset (mgmt,0 ,24 ); -memcpy (mgmt->da, ifsta->bssid,ETH_ALEN ); -memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN ); -memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); - mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | -IEEE80211_STYPE_DISASSOC ); -skb_put (skb,2 ); - mgmt->u.disassoc.reason_code =cpu_to_le16 (reason); + ifsta->state =IEEE80211_STA_MLME_AUTHENTICATE ; +printk (KERN_DEBUG "%s: authenticate with AP %s\n" , + sdata->dev->name,print_mac (mac, ifsta->bssid)); -ieee80211_sta_tx (sdata, skb,0 ); +ieee80211_send_auth (sdata, ifsta,1 ,NULL ,0 ,0 ); + +mod_timer (&ifsta->timer, jiffies +IEEE80211_AUTH_TIMEOUT ); } static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
@@ -865,6 +950,14 @@ static void ieee80211_set_disassoc(strucsta_info_destroy (sta); } +static int ieee80211_sta_wep_configured (struct ieee80211_sub_if_data *sdata) +{ +if (!sdata || !sdata->default_key || + sdata->default_key->conf.alg !=ALG_WEP ) +return 0 ; +return 1 ; +} +static int ieee80211_privacy_mismatch (struct ieee80211_sub_if_data *sdata,struct ieee80211_if_sta *ifsta) {
@@ -1010,54 +1103,6 @@ static void ieee80211_auth_challenge(str elems.challenge_len + 2, 1); } -static void ieee80211_send_addba_resp (struct ieee80211_sub_if_data *sdata,u8 *da,u16 tid, -u8 dialog_token,u16 status,u16 policy, -u16 buf_size,u16 timeout) -{ -struct ieee80211_if_sta *ifsta = &sdata->u.sta; -struct ieee80211_local *local = sdata->local; -struct sk_buff *skb; -struct ieee80211_mgmt *mgmt; -u16 capab; - - skb =dev_alloc_skb (sizeof (*mgmt) + local->hw.extra_tx_headroom); - -if (!skb) { -printk (KERN_DEBUG "%s: failed to allocate buffer " -"for addba resp frame\n" , sdata->dev->name); -return ; - } - -skb_reserve (skb, local->hw.extra_tx_headroom); - mgmt = (struct ieee80211_mgmt *)skb_put (skb,24 ); -memset (mgmt,0 ,24 ); -memcpy (mgmt->da, da,ETH_ALEN ); -memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN ); -if (sdata->vif.type ==IEEE80211_IF_TYPE_AP ) -memcpy (mgmt->bssid, sdata->dev->dev_addr,ETH_ALEN ); -else -memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); - mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | -IEEE80211_STYPE_ACTION ); - -skb_put (skb,1 +sizeof (mgmt->u.action.u.addba_resp)); - mgmt->u.action.category =WLAN_CATEGORY_BACK ; - mgmt->u.action.u.addba_resp.action_code =WLAN_ACTION_ADDBA_RESP ; - mgmt->u.action.u.addba_resp.dialog_token = dialog_token; - - capab = (u16)(policy <<1 );/* bit 1 aggregation policy */ - capab |= (u16)(tid <<2 );/* bit 5:2 TID number */ - capab |= (u16)(buf_size <<6 );/* bit 15:6 max size of aggregation */ - - mgmt->u.action.u.addba_resp.capab =cpu_to_le16 (capab); - mgmt->u.action.u.addba_resp.timeout =cpu_to_le16 (timeout); - mgmt->u.action.u.addba_resp.status =cpu_to_le16 (status); - -ieee80211_sta_tx (sdata, skb,0 ); - -return ; -} -/* * After accepting the AddBA Request we activated a timer, * resetting it after each frame that arrives from the originator.
@@ -1330,53 +1375,6 @@ static void ieee80211_sta_process_delba(rcu_read_unlock (); } -static void ieee80211_send_refuse_measurement_request (struct ieee80211_sub_if_data *sdata, -struct ieee80211_msrment_ie *request_ie, -const u8 *da,const u8 *bssid, -u8 dialog_token) -{ -struct ieee80211_local *local = sdata->local; -struct sk_buff *skb; -struct ieee80211_mgmt *msr_report; - - skb =dev_alloc_skb (sizeof (*msr_report) + local->hw.extra_tx_headroom + -sizeof (struct ieee80211_msrment_ie )); - -if (!skb) { -printk (KERN_ERR "%s: failed to allocate buffer for " -"measurement report frame\n" , sdata->dev->name); -return ; - } - -skb_reserve (skb, local->hw.extra_tx_headroom); - msr_report = (struct ieee80211_mgmt *)skb_put (skb,24 ); -memset (msr_report,0 ,24 ); -memcpy (msr_report->da, da,ETH_ALEN ); -memcpy (msr_report->sa, sdata->dev->dev_addr,ETH_ALEN ); -memcpy (msr_report->bssid, bssid,ETH_ALEN ); - msr_report->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | -IEEE80211_STYPE_ACTION ); - -skb_put (skb,1 +sizeof (msr_report->u.action.u.measurement)); - msr_report->u.action.category =WLAN_CATEGORY_SPECTRUM_MGMT ; - msr_report->u.action.u.measurement.action_code = -WLAN_ACTION_SPCT_MSR_RPRT ; - msr_report->u.action.u.measurement.dialog_token = dialog_token; - - msr_report->u.action.u.measurement.element_id =WLAN_EID_MEASURE_REPORT ; - msr_report->u.action.u.measurement.length = -sizeof (struct ieee80211_msrment_ie ); - -memset (&msr_report->u.action.u.measurement.msr_elem,0 , -sizeof (struct ieee80211_msrment_ie )); - msr_report->u.action.u.measurement.msr_elem.token = request_ie->token; - msr_report->u.action.u.measurement.msr_elem.mode |= -IEEE80211_SPCT_MSR_RPRT_MODE_REFUSED ; - msr_report->u.action.u.measurement.msr_elem.type = request_ie->type; - -ieee80211_sta_tx (sdata, skb,0 ); -} -static void ieee80211_sta_process_measurement_req (struct ieee80211_sub_if_data *sdata,struct ieee80211_mgmt *mgmt,size_t len)
Johannes Berg
maintainer[PATCH 13/8] mac80211: consolidate deauth/disassoc
In reply to Johannes Bergdeauth and disassoc frames are completely identical so there's little point in having two functions to send them rather than one that gets a parameter. This same a bit of code size.
--- net/mac80211/mlme.c | 47 +++++++++++------------------------------------ 1 file changed, 11 insertions(+), 36 deletions(-)
net/mac80211/mlme.c +11 -36
@@ -416,17 +416,18 @@ static void ieee80211_send_assoc(struct } -static void ieee80211_send_deauth (struct ieee80211_sub_if_data *sdata, -struct ieee80211_if_sta *ifsta,u16 reason) +static void ieee80211_send_deauth_disassoc (struct ieee80211_sub_if_data *sdata, +u16 stype,u16 reason) {struct ieee80211_local *local = sdata->local; +struct ieee80211_if_sta *ifsta = &sdata->u.sta;struct sk_buff *skb;struct ieee80211_mgmt *mgmt; skb =dev_alloc_skb (local->hw.extra_tx_headroom +sizeof (*mgmt));if (!skb) { -printk (KERN_DEBUG "%s: failed to allocate buffer for deauth " -"frame\n" , sdata->dev->name); +printk (KERN_DEBUG "%s: failed to allocate buffer for " +"deauth/disassoc frame\n" , sdata->dev->name);return ; }skb_reserve (skb, local->hw.extra_tx_headroom);
@@ -436,42 +437,14 @@ static void ieee80211_send_deauth(structmemcpy (mgmt->da, ifsta->bssid,ETH_ALEN );memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN );memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); - mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | -IEEE80211_STYPE_DEAUTH ); + mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | stype);skb_put (skb,2 ); +/* u.deauth.reason_code == u.disassoc.reason_code */ mgmt->u.deauth.reason_code =cpu_to_le16 (reason);ieee80211_sta_tx (sdata, skb,0 ); } -static void ieee80211_send_disassoc (struct ieee80211_sub_if_data *sdata, -struct ieee80211_if_sta *ifsta,u16 reason) -{ -struct ieee80211_local *local = sdata->local; -struct sk_buff *skb; -struct ieee80211_mgmt *mgmt; - - skb =dev_alloc_skb (local->hw.extra_tx_headroom +sizeof (*mgmt)); -if (!skb) { -printk (KERN_DEBUG "%s: failed to allocate buffer for disassoc " -"frame\n" , sdata->dev->name); -return ; - } -skb_reserve (skb, local->hw.extra_tx_headroom); - - mgmt = (struct ieee80211_mgmt *)skb_put (skb,24 ); -memset (mgmt,0 ,24 ); -memcpy (mgmt->da, ifsta->bssid,ETH_ALEN ); -memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN ); -memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); - mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | -IEEE80211_STYPE_DISASSOC ); -skb_put (skb,2 ); - mgmt->u.disassoc.reason_code =cpu_to_le16 (reason); - -ieee80211_sta_tx (sdata, skb,0 ); -} -static void ieee80211_send_addba_resp (struct ieee80211_sub_if_data *sdata,u8 *da,u16 tid,u8 dialog_token,u16 status,u16 policy,u16 buf_size,u16 timeout)
@@ -920,9 +893,11 @@ static void ieee80211_set_disassoc(strucif (self_disconnected) {if (deauth) -ieee80211_send_deauth (sdata, ifsta, reason); +ieee80211_send_deauth_disassoc (sdata, +IEEE80211_STYPE_DEAUTH , reason);else -ieee80211_send_disassoc (sdata, ifsta, reason); +ieee80211_send_deauth_disassoc (sdata, +IEEE80211_STYPE_DISASSOC , reason); } ifsta->flags &= ~IEEE80211_STA_ASSOCIATED ;
Re: [PATCH 13/8] mac80211: consolidate deauth/disassoc
Quoted 5 lines · Johannes Berg
deauth and disassoc frames are completely identical so there's little point in having two functions to send them rather than one that gets a parameter. This same a bit of code size.
Signed-off-by Johannes Berg <[email protected]>
Sounds good. Ack
Quoted 95 lines
--- net/mac80211/mlme.c | 47 +++++++++++------------------------------------ 1 file changed, 11 insertions(+), 36 deletions(-)net/mac80211/mlme.c 2008-09-09 09:50:07.000000000 +0200 renamed from net/mac80211/mlme.c 2008-09-09 09:47:27.000000000 +0200 +11
-37@@ -416,17 +416,18 @@ static void ieee80211_send_assoc(struct } -static void ieee80211_send_deauth(struct ieee80211_sub_if_data *sdata, - struct ieee80211_if_sta *ifsta, u16 reason) +static void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, + u16 stype, u16 reason) { struct ieee80211_local *local = sdata->local; + struct ieee80211_if_sta *ifsta = &sdata->u.sta; struct sk_buff *skb; struct ieee80211_mgmt *mgmt; skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt)); if (!skb) { - printk(KERN_DEBUG "%s: failed to allocate buffer for deauth " - "frame\n", sdata->dev->name); + printk(KERN_DEBUG "%s: failed to allocate buffer for " + "deauth/disassoc frame\n", sdata->dev->name); return; } skb_reserve(skb, local->hw.extra_tx_headroom);@@ -436,42 +437,14 @@ static void ieee80211_send_deauth(struct memcpy(mgmt->da, ifsta->bssid, ETH_ALEN); memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); - mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | - IEEE80211_STYPE_DEAUTH); + mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype); skb_put(skb, 2); + /* u.deauth.reason_code == u.disassoc.reason_code */ mgmt->u.deauth.reason_code = cpu_to_le16(reason); ieee80211_sta_tx(sdata, skb, 0); } -static void ieee80211_send_disassoc(struct ieee80211_sub_if_data *sdata, - struct ieee80211_if_sta *ifsta, u16 reason) -{ - struct ieee80211_local *local = sdata->local; - struct sk_buff *skb; - struct ieee80211_mgmt *mgmt; - - skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt)); - if (!skb) { - printk(KERN_DEBUG "%s: failed to allocate buffer for disassoc " - "frame\n", sdata->dev->name); - return; - } - skb_reserve(skb, local->hw.extra_tx_headroom); - - mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); - memset(mgmt, 0, 24); - memcpy(mgmt->da, ifsta->bssid, ETH_ALEN); - memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); - memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); - mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | - IEEE80211_STYPE_DISASSOC); - skb_put(skb, 2); - mgmt->u.disassoc.reason_code = cpu_to_le16(reason); - - ieee80211_sta_tx(sdata, skb, 0); -} - static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *da, u16 tid, u8 dialog_token, u16 status, u16 policy, u16 buf_size, u16 timeout)@@ -920,9 +893,11 @@ static void ieee80211_set_disassoc(struc if (self_disconnected) { if (deauth) - ieee80211_send_deauth(sdata, ifsta, reason); + ieee80211_send_deauth_disassoc(sdata, + IEEE80211_STYPE_DEAUTH, reason); else - ieee80211_send_disassoc(sdata, ifsta, reason); + ieee80211_send_deauth_disassoc(sdata, + IEEE80211_STYPE_DISASSOC, reason); } ifsta->flags &= ~IEEE80211_STA_ASSOCIATED; --To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Johannes Berg
maintainer[PATCH 14/8] mac80211: split ieee80211_sta_def_wmm_params
In reply to Johannes BergCleans up the code a bit and prepares for the next patch that will use the function elsewhere.
--- net/mac80211/mlme.c | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-)
net/mac80211/mlme.c +27 -21
@@ -539,13 +539,38 @@ static void ieee80211_send_refuse_measur }/* MLME */ +static void ieee80211_set_wmm_default (struct ieee80211_sub_if_data *sdata) +{ +struct ieee80211_local *local = sdata->local; +struct ieee80211_tx_queue_params qparam; +int i; + +if (!local->ops->conf_tx) +return ; + +memset (&qparam,0 ,sizeof (qparam)); + + qparam.aifs =2 ; + +if (local->hw.conf.channel->band ==IEEE80211_BAND_2GHZ && + !(sdata->flags &IEEE80211_SDATA_OPERATING_GMODE )) + qparam.cw_min =31 ; +else + qparam.cw_min =15 ; + + qparam.cw_max =1023 ; + qparam.txop =0 ; + +for (i =0 ; i <local_to_hw (local)->queues; i++) + local->ops->conf_tx (local_to_hw (local), i, &qparam); +} +static void ieee80211_sta_def_wmm_params (struct ieee80211_sub_if_data *sdata,struct ieee80211_sta_bss *bss) {struct ieee80211_local *local = sdata->local;int i, have_higher_than_11mbit =0 ; -/* cf. IEEE 802.11 9.2.12 */ for (i =0 ; i < bss->supp_rates_len; i++)if ((bss->supp_rates[i] &0x7f ) *5 >110 )
@@ -557,26 +582,7 @@ static void ieee80211_sta_def_wmm_paramselse sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE ; - -if (local->ops->conf_tx) { -struct ieee80211_tx_queue_params qparam; - -memset (&qparam,0 ,sizeof (qparam)); - - qparam.aifs =2 ; - -if (local->hw.conf.channel->band ==IEEE80211_BAND_2GHZ && - !(sdata->flags &IEEE80211_SDATA_OPERATING_GMODE )) - qparam.cw_min =31 ; -else - qparam.cw_min =15 ; - - qparam.cw_max =1023 ; - qparam.txop =0 ; - -for (i =0 ; i <local_to_hw (local)->queues; i++) - local->ops->conf_tx (local_to_hw (local), i, &qparam); - } +ieee80211_set_wmm_default (sdata); } static void ieee80211_sta_wmm_params(struct ieee80211_local *local,