mac80211 updates
Johannes Berg
maintainercover mac80211 updates
The whole set, everything was posted before, but I found a few bugs in some patches, so here's a complete repost.
johannes
Johannes Berg
maintainerPATCH 1/27 zd1211rw: do not ratelimit no-ops
It is rather confusing to see this in the log:
[ 695.606877] __ratelimit: 40 callbacks suppressed [ 700.726878] __ratelimit: 40 callbacks suppressed
without ever seeing any actual message. This is because zd1211rw doesn't compile out the net_ratelimit() call properly if debugging is not enabled.
--- drivers/net/wireless/zd1211rw/zd_def.h | 5 +++++ drivers/net/wireless/zd1211rw/zd_mac.c | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/net/wireless/zd1211rw/zd_def.h +5 -0
@@ -33,8 +33,13 @@ typedef u16 __nocast zd_addr_t;#ifdef DEBUG # define dev_dbg_f(dev, fmt, args...) \ dev_printk_f(KERN_DEBUG, dev, fmt, ## args) +# define dev_dbg_f_limit(dev, fmt, args...) do {\ + if (net_ratelimit()) + dev_printk_f(KERN_DEBUG, dev, fmt, ## args) +} while (0) #else # define dev_dbg_f(dev, fmt, args...) do { (void)(dev); } while (0) +# define dev_dbg_f_limit(dev, fmt, args...) do { (void)(dev); } while (0)#endif /* DEBUG */ #ifdef DEBUG
drivers/net/wireless/zd1211rw/zd_mac.c +3 -4
@@ -793,10 +793,9 @@ static void zd_process_intr(struct work_ struct zd_mac *mac = container_of(work, struct zd_mac, process_intr); int_status =le16_to_cpu (*(__le16 *)(mac->intr_buffer+4 )); -if (int_status &INT_CFG_NEXT_BCN ) { -if (net_ratelimit ()) -dev_dbg_f (zd_mac_dev (mac),"INT_CFG_NEXT_BCN\n" ); - }else +if (int_status &INT_CFG_NEXT_BCN ) +dev_dbg_f_limit (zd_mac_dev (mac),"INT_CFG_NEXT_BCN\n" ); +else dev_dbg_f (zd_mac_dev (mac),"Unsupported interrupt\n" );zd_chip_enable_hwint (&mac->chip);
Johannes Berg
maintainerPATCH 2/27 mac80211: disable IBSS beacon before join
In reply to Johannes BergBefore we have a probe response frame (which is used as the beacon too) there's no need to ask drivers to beacon, they will not get a beacon anyway.
--- net/mac80211/main.c | 2 ++ 1 file changed, 2 insertions(+)
net/mac80211/main.c +2 -0
@@ -210,6 +210,8 @@ int ieee80211_if_config(struct ieee80211 !!rcu_dereference (sdata->u.ap.beacon);break ;case NL80211_IFTYPE_ADHOC : + conf.enable_beacon = !!sdata->u.sta.probe_resp; +break ;case NL80211_IFTYPE_MESH_POINT : conf.enable_beacon = true;break ;
Johannes Berg
maintainerPATCH 3/27 zd1211rw: honour enable_beacon conf
In reply to Johannes BergThis makes zd1211rw honour enable_beacon, as well as fixing a memory leak: the beacon skb is leaked when configuring it to the hardware fails.
--- drivers/net/wireless/zd1211rw/zd_mac.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/net/wireless/zd1211rw/zd_mac.c +13 -3
@@ -768,13 +768,23 @@ static int zd_op_config_interface(structif (!beacon)return -ENOMEM ; r =zd_mac_config_beacon (hw, beacon); +kfree_skb (beacon); +if (r <0 )return r; - r =zd_set_beacon_interval (&mac->chip,BCN_MODE_IBSS | - hw->conf.beacon_int); + } + +if (conf->changed &IEEE80211_IFCC_BEACON_ENABLED ) { +u32 interval; + +if (conf->enable_beacon) + interval =BCN_MODE_IBSS | hw->conf.beacon_int; +else + interval =0 ; + + r =zd_set_beacon_interval (&mac->chip, interval);if (r <0 )return r; -kfree_skb (beacon); } }else associated =is_valid_ether_addr (conf->bssid);
Johannes Berg
maintainerPATCH 4/27 mac80211: properly validate/translate IW_AUTH_MFP values
In reply to Johannes BergMake sure nobody passes in bogus values, and translate the values (although it isn't necessary).
--- net/mac80211/wext.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
net/mac80211/wext.c +15 -3
@@ -982,9 +982,21 @@ static int ieee80211_ioctl_siwauth(strucbreak ; }if (sdata->vif.type ==NL80211_IFTYPE_STATION || - sdata->vif.type ==NL80211_IFTYPE_ADHOC ) - sdata->u.sta.mfp = data->value; -else + sdata->vif.type ==NL80211_IFTYPE_ADHOC ) { +switch (data->value) { +case IW_AUTH_MFP_DISABLED : + sdata->u.sta.mfp =IEEE80211_MFP_DISABLED ; +break ; +case IW_AUTH_MFP_OPTIONAL : + sdata->u.sta.mfp =IEEE80211_MFP_OPTIONAL ; +break ; +case IW_AUTH_MFP_REQUIRED : + sdata->u.sta.mfp =IEEE80211_MFP_REQUIRED ; +break ; +default : + ret = -EINVAL ; + } + }else ret = -EOPNOTSUPP ;break ;default :
Johannes Berg
maintainerPATCH 5/27 mac80211: reject extra IEs for probe request when hw_scan
In reply to Johannes BergWe cannot currently hand off extra IEs to hw_scan, so reject configuring extra IEs for probe request frames when hw_scan is set.
--- net/mac80211/cfg.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
net/mac80211/cfg.c +8 -3
@@ -1176,11 +1176,16 @@ static int ieee80211_set_channel(structreturn ieee80211_hw_config (local,IEEE80211_CONF_CHANGE_CHANNEL ); } -static int set_mgmt_extra_ie_sta (struct ieee80211_if_sta *ifsta,u8 subtype, -u8 *ies,size_t ies_len) +static int set_mgmt_extra_ie_sta (struct ieee80211_sub_if_data *sdata, +u8 subtype,u8 *ies,size_t ies_len) { +struct ieee80211_local *local = sdata->local; +struct ieee80211_if_sta *ifsta = &sdata->u.sta; +switch (subtype) {case IEEE80211_STYPE_PROBE_REQ >>4 : +if (local->ops->hw_scan) +break ;kfree (ifsta->ie_probereq); ifsta->ie_probereq = ies; ifsta->ie_probereq_len = ies_len;
@@ -1244,7 +1249,7 @@ static int ieee80211_set_mgmt_extra_ie(sswitch (sdata->vif.type) {case NL80211_IFTYPE_STATION :case NL80211_IFTYPE_ADHOC : - ret =set_mgmt_extra_ie_sta (&sdata->u.sta, params->subtype, + ret =set_mgmt_extra_ie_sta (sdata, params->subtype, ies, ies_len);break ;default :
Johannes Berg
maintainerPATCH 6/27 mac80211: fix beacon enable more
In reply to Johannes BergHopefully the last required fix ... disable beaconing only on beaconing interfaces, and thus avoid calling ieee80211_if_config for purely virtual interfaces (those driver doesn't know about).
--- net/mac80211/scan.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/mac80211/scan.c +12 -2
@@ -500,7 +500,12 @@ void ieee80211_scan_completed(struct iee }else netif_tx_wake_all_queues (sdata->dev); -ieee80211_if_config (sdata,IEEE80211_IFCC_BEACON_ENABLED ); +/* re-enable beaconing */ +if (sdata->vif.type ==NL80211_IFTYPE_AP || + sdata->vif.type ==NL80211_IFTYPE_ADHOC || + sdata->vif.type ==NL80211_IFTYPE_MESH_POINT ) +ieee80211_if_config (sdata, +IEEE80211_IFCC_BEACON_ENABLED ); }mutex_unlock (&local->iflist_mtx);
@@ -656,7 +661,12 @@ int ieee80211_start_scan(struct ieee8021if (!netif_running (sdata->dev))continue ; -ieee80211_if_config (sdata,IEEE80211_IFCC_BEACON_ENABLED ); +/* disable beaconing */ +if (sdata->vif.type ==NL80211_IFTYPE_AP || + sdata->vif.type ==NL80211_IFTYPE_ADHOC || + sdata->vif.type ==NL80211_IFTYPE_MESH_POINT ) +ieee80211_if_config (sdata, +IEEE80211_IFCC_BEACON_ENABLED );if (sdata->vif.type ==NL80211_IFTYPE_STATION ) {if (sdata->u.sta.flags &IEEE80211_STA_ASSOCIATED ) {
Johannes Berg
maintainerPATCH 7/27 mac80211: remove bssid argument from prepare_for_handlers
In reply to Johannes BergIt's a little confusing to get the BSSID outside the function and pass it in, when it's only needed for this function, so change that.
--- net/mac80211/rx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/mac80211/rx.c +3 -4
@@ -2030,9 +2030,10 @@ static void ieee80211_invoke_rx_handlers/* main receive path */ static int prepare_for_handlers (struct ieee80211_sub_if_data *sdata, -u8 *bssid,struct ieee80211_rx_data *rx, +struct ieee80211_rx_data *rx,struct ieee80211_hdr *hdr) { +u8 *bssid =ieee80211_get_bssid (hdr, rx->skb->len, sdata->vif.type);int multicast =is_multicast_ether_addr (hdr->addr1);switch (sdata->vif.type) {
@@ -2135,7 +2136,6 @@ static void __ieee80211_rx_handle_packetint prepares;struct ieee80211_sub_if_data *prev =NULL ;struct sk_buff *skb_new; -u8 *bssid; hdr = (struct ieee80211_hdr *)skb->data;memset (&rx,0 ,sizeof (rx));
@@ -2174,9 +2174,8 @@ static void __ieee80211_rx_handle_packetif (sdata->vif.type ==NL80211_IFTYPE_MONITOR )continue ; - bssid =ieee80211_get_bssid (hdr, skb->len, sdata->vif.type); rx.flags |=IEEE80211_RX_RA_MATCH ; - prepares =prepare_for_handlers (sdata, bssid, &rx, hdr); + prepares =prepare_for_handlers (sdata, &rx, hdr);if (!prepares)continue ;
Johannes Berg
maintainerPATCH 8/27 mac80211: remove stray aggregation debugfs definition
In reply to Johannes Berg--- net/mac80211/sta_info.h | 1- net/mac80211/sta_info.h | 1 - 1 file changed, 1 deletion(-)
net/mac80211/sta_info.h +0 -1
@@ -65,7 +65,6 @@ enum ieee80211_sta_info_flags {#define HT_AGG_STATE_OPERATIONAL (HT_ADDBA_REQUESTED_MSK | \ HT_ADDBA_DRV_READY_MSK | \ HT_ADDBA_RECEIVED_MSK) -#define HT_AGG_STATE_DEBUGFS_CTL BIT(7)/** * struct tid_ampdu_tx - TID aggregation information (Tx).
Johannes Berg
maintainerPATCH 9/27 mac80211: fix RX aggregation timeouts
In reply to Johannes BergThe values are in TUs (1.024ms), not ms.
--- net/mac80211/ieee80211_i.h | 2 ++ net/mac80211/mesh_hwmp.c | 1 - net/mac80211/rx.c | 16 ++++++---------- net/mac80211/sta_info.h | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-)
net/mac80211/rx.c +6 -10
@@ -1640,11 +1640,9 @@ ieee80211_rx_h_ctrl(struct ieee80211_rx_ start_seq_num =le16_to_cpu (bar->start_seq_num) >>4 ;/* reset session timer */ -if (tid_agg_rx->timeout) { -unsigned long expires = - jiffies + (tid_agg_rx->timeout /1000 ) *HZ ; -mod_timer (&tid_agg_rx->session_timer, expires); - } +if (tid_agg_rx->timeout) +mod_timer (&tid_agg_rx->session_timer, +TU_TO_EXP_TIME (tid_agg_rx->timeout));/* manage reordering buffer according to requested */ /* sequence number */
@@ -2380,11 +2378,9 @@ static u8 ieee80211_rx_reorder_ampdu(str/* new un-ordered ampdu frame - process it */ /* reset session timer */ -if (tid_agg_rx->timeout) { -unsigned long expires = - jiffies + (tid_agg_rx->timeout /1000 ) *HZ ; -mod_timer (&tid_agg_rx->session_timer, expires); - } +if (tid_agg_rx->timeout) +mod_timer (&tid_agg_rx->session_timer, +TU_TO_EXP_TIME (tid_agg_rx->timeout));/* if this mpdu is fragmented - terminate rx aggregation session */ sc =le16_to_cpu (hdr->seq_ctrl);
net/mac80211/sta_info.h +1 -1
@@ -88,7 +88,7 @@ struct tid_ampdu_tx {* @stored_mpdu_num: number of MPDUs in reordering buffer * @ssn: Starting Sequence Number expected to be aggregated. * @buf_size: buffer size for incoming A-MPDUs -* @timeout: reset timer value. +* @timeout: reset timer value (in TUs). * @dialog_token: dialog token for aggregation session */ struct tid_ampdu_rx {
net/mac80211/ieee80211_i.h +2 -0
@@ -57,6 +57,8 @@ struct ieee80211_local;*/ #define IEEE80211_SCAN_RESULT_EXPIRE (10 * HZ) +#define TU_TO_EXP_TIME (x) (jiffies + usecs_to_jiffies((x) * 1024)) +struct ieee80211_fragment_entry {unsigned long first_frag_time;unsigned int seq;
net/mac80211/mesh_hwmp.c +0 -1
@@ -58,7 +58,6 @@ static inline u32 u32_field_get(u8 *preq#define PERR_IE_DST_ADDR (x) (x + 2)#define PERR_IE_DST_DSN (x) u32_field_get(x, 8, 0); -#define TU_TO_EXP_TIME (x) (jiffies + msecs_to_jiffies(x * 1024 / 1000))#define MSEC_TO_TU (x) (x*1000/1024)#define DSN_GT (x, y) ((long) (y) - (long) (x) < 0)#define DSN_LT (x, y) ((long) (x) - (long) (y) < 0)
Johannes Berg
maintainerPATCH 10/27 mac80211: restructure HT code
In reply to Johannes BergCreate two new files, agg-tx.c and agg-rx.c to make it clearer which code is common (ht.c) and which is specific (agg-*.c).
--- net/mac80211/Makefile | 2 net/mac80211/agg-rx.c | 287 ++++++++++++++ net/mac80211/agg-tx.c | 593 ++++++++++++++++++++++++++++++ net/mac80211/ht.c | 867 --------------------------------------------- net/mac80211/ieee80211_i.h | 3 5 files changed, 895 insertions(+), 857 deletions(-)
net/mac80211/ht.c +11 -856
@@ -17,8 +17,6 @@#include <net/wireless.h> #include <net/mac80211.h> #include "ieee80211_i.h" -#include "sta_info.h" -#include "wme.h" void ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_supported_band *sband, struct ieee80211_ht_cap *ht_cap_ie,
@@ -155,105 +153,23 @@ u32 ieee80211_enable_ht(struct ieee80211return changed; } -static void ieee80211_send_addba_request (struct ieee80211_sub_if_data *sdata, -const u8 *da,u16 tid, -u8 dialog_token,u16 start_seq_num, -u16 agg_size,u16 timeout) -{ -struct ieee80211_local *local = sdata->local; -struct ieee80211_if_sta *ifsta = &sdata->u.sta; -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_ERR "%s: failed to allocate buffer " -"for addba request 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 ==NL80211_IFTYPE_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_req)); - - mgmt->u.action.category =WLAN_CATEGORY_BACK ; - mgmt->u.action.u.addba_req.action_code =WLAN_ACTION_ADDBA_REQ ; - - mgmt->u.action.u.addba_req.dialog_token = dialog_token; - capab = (u16)(1 <<1 );/* bit 1 aggregation policy */ - capab |= (u16)(tid <<2 );/* bit 5:2 TID number */ - capab |= (u16)(agg_size <<6 );/* bit 15:6 max size of aggergation */ - - mgmt->u.action.u.addba_req.capab =cpu_to_le16 (capab); - - mgmt->u.action.u.addba_req.timeout =cpu_to_le16 (timeout); - mgmt->u.action.u.addba_req.start_seq_num = -cpu_to_le16 (start_seq_num <<4 ); - -ieee80211_tx_skb (sdata, skb,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) +void ieee80211_sta_tear_down_BA_sessions (struct ieee80211_sub_if_data *sdata,u8 *addr) { -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); +int i; -if (!skb) { -printk (KERN_DEBUG "%s: failed to allocate buffer " -"for addba resp frame\n" , sdata->dev->name); -return ; +for (i =0 ; i <STA_TID_NUM ; i++) { +ieee80211_stop_tx_ba_session (&local->hw, addr, i, +WLAN_BACK_INITIATOR ); +ieee80211_sta_stop_rx_ba_session (sdata, addr, i, +WLAN_BACK_RECIPIENT , +WLAN_REASON_QSTA_LEAVE_QBSS ); } - -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 ==NL80211_IFTYPE_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_tx_skb (sdata, skb,1 ); } -static void ieee80211_send_delba (struct ieee80211_sub_if_data *sdata, -const u8 *da,u16 tid, -u16 initiator,u16 reason_code) +void ieee80211_send_delba (struct ieee80211_sub_if_data *sdata, +const u8 *da,u16 tid, +u16 initiator,u16 reason_code) {struct ieee80211_local *local = sdata->local;struct ieee80211_if_sta *ifsta = &sdata->u.sta;
@@ -294,767 +210,6 @@ static void ieee80211_send_delba(structieee80211_tx_skb (sdata, skb,1 ); } -void ieee80211_send_bar (struct ieee80211_sub_if_data *sdata,u8 *ra,u16 tid,u16 ssn) -{ -struct ieee80211_local *local = sdata->local; -struct sk_buff *skb; -struct ieee80211_bar *bar; -u16 bar_control =0 ; - - skb =dev_alloc_skb (sizeof (*bar) + local->hw.extra_tx_headroom); -if (!skb) { -printk (KERN_ERR "%s: failed to allocate buffer for " -"bar frame\n" , sdata->dev->name); -return ; - } -skb_reserve (skb, local->hw.extra_tx_headroom); - bar = (struct ieee80211_bar *)skb_put (skb,sizeof (*bar)); -memset (bar,0 ,sizeof (*bar)); - bar->frame_control =cpu_to_le16 (IEEE80211_FTYPE_CTL | -IEEE80211_STYPE_BACK_REQ ); -memcpy (bar->ra, ra,ETH_ALEN ); -memcpy (bar->ta, sdata->dev->dev_addr,ETH_ALEN ); - bar_control |= (u16 )IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL ; - bar_control |= (u16 )IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA ; - bar_control |= (u16)(tid <<12 ); - bar->control =cpu_to_le16 (bar_control); - bar->start_seq_num =cpu_to_le16 (ssn); - -ieee80211_tx_skb (sdata, skb,0 ); -} - -void ieee80211_sta_stop_rx_ba_session (struct ieee80211_sub_if_data *sdata,u8 *ra,u16 tid, -u16 initiator,u16 reason) -{ -struct ieee80211_local *local = sdata->local; -struct ieee80211_hw *hw = &local->hw; -struct sta_info *sta; -int ret, i; - -rcu_read_lock (); - - sta =sta_info_get (local, ra); -if (!sta) { -rcu_read_unlock (); -return ; - } - -/* check if TID is in operational state */ -spin_lock_bh (&sta->lock); -if (sta->ampdu_mlme.tid_state_rx[tid] - !=HT_AGG_STATE_OPERATIONAL ) { -spin_unlock_bh (&sta->lock); -rcu_read_unlock (); -return ; - } - sta->ampdu_mlme.tid_state_rx[tid] = -HT_AGG_STATE_REQ_STOP_BA_MSK | - (initiator <<HT_AGG_STATE_INITIATOR_SHIFT ); -spin_unlock_bh (&sta->lock); - -/* stop HW Rx aggregation. ampdu_action existence -* already verified in session init so we add the BUG_ON */ -BUG_ON (!local->ops->ampdu_action); - -#ifdef CONFIG_MAC80211_HT_DEBUG -printk (KERN_DEBUG "Rx BA session stop requested for %pM tid %u\n" , - ra, tid); -#endif /* CONFIG_MAC80211_HT_DEBUG */ - - ret = local->ops->ampdu_action (hw,IEEE80211_AMPDU_RX_STOP , - &sta->sta, tid,NULL ); -if (ret) -printk (KERN_DEBUG "HW problem - can not stop rx " -"aggregation for tid %d\n" , tid); - -/* shutdown timer has not expired */ -if (initiator !=WLAN_BACK_TIMER ) -del_timer_sync (&sta->ampdu_mlme.tid_rx[tid]->session_timer); - -/* check if this is a self generated aggregation halt */ -if (initiator ==WLAN_BACK_RECIPIENT || initiator ==WLAN_BACK_TIMER ) -ieee80211_send_delba (sdata, ra, tid,0 , reason); - -/* free the reordering buffer */ -for (i =0 ; i < sta->ampdu_mlme.tid_rx[tid]->buf_size; i++) { -if (sta->ampdu_mlme.tid_rx[tid]->reorder_buf[i]) { -/* release the reordered frames */ -dev_kfree_skb (sta->ampdu_mlme.tid_rx[tid]->reorder_buf[i]); - sta->ampdu_mlme.tid_rx[tid]->stored_mpdu_num--; - sta->ampdu_mlme.tid_rx[tid]->reorder_buf[i] =NULL ; - } - } -/* free resources */ -kfree (sta->ampdu_mlme.tid_rx[tid]->reorder_buf); -kfree (sta->ampdu_mlme.tid_rx[tid]); - sta->ampdu_mlme.tid_rx[tid] =NULL ; - sta->ampdu_mlme.tid_state_rx[tid] =HT_AGG_STATE_IDLE ; - -rcu_read_unlock (); -} - - -/* -* After sending add Block Ack request we activated a timer until -* add Block Ack response will arrive from the recipient. -* If this timer expires sta_addba_resp_timer_expired will be executed. -*/ -static void sta_addba_resp_timer_expired (unsigned long data) -{ -/* not an elegant detour, but there is no choice as the timer passes -* only one argument, and both sta_info and TID are needed, so init -* flow in sta_info_create gives the TID as data, while the timer_to_id -* array gives the sta through container_of */ -u16 tid = *(u8 *)data; -struct sta_info *temp_sta =container_of ((void *)data, - struct sta_info, timer_to_tid[tid]); - -struct ieee80211_local *local = temp_sta->local; -struct ieee80211_hw *hw = &local->hw; -struct sta_info *sta; -u8 *state; - -rcu_read_lock (); - - sta =sta_info_get (local, temp_sta->sta.addr); -if (!sta) { -rcu_read_unlock (); -return ; - } - - state = &sta->ampdu_mlme.tid_state_tx[tid]; -/* check if the TID waits for addBA response */ -spin_lock_bh (&sta->lock); -if (!(*state &HT_ADDBA_REQUESTED_MSK )) { -spin_unlock_bh (&sta->lock); - *state =HT_AGG_STATE_IDLE ; -#ifdef CONFIG_MAC80211_HT_DEBUG -printk (KERN_DEBUG "timer expired on tid %d but we are not " -"expecting addBA response there" , tid); -#endif - goto timer_expired_exit; - } - -#ifdef CONFIG_MAC80211_HT_DEBUG -printk (KERN_DEBUG "addBA response timer expired on tid %d\n" , tid); -#endif - -/* go through the state check in stop_BA_session */ - *state =HT_AGG_STATE_OPERATIONAL ; -spin_unlock_bh (&sta->lock); -ieee80211_stop_tx_ba_session (hw, temp_sta->sta.addr, tid, -WLAN_BACK_INITIATOR ); - -timer_expired_exit: -rcu_read_unlock (); -} - -void ieee80211_sta_tear_down_BA_sessions (struct ieee80211_sub_if_data *sdata,u8 *addr) -{ -struct ieee80211_local *local = sdata->local; -int i; - -for (i =0 ; i <STA_TID_NUM ; i++) { -ieee80211_stop_tx_ba_session (&local->hw, addr, i, -WLAN_BACK_INITIATOR ); -ieee80211_sta_stop_rx_ba_session (sdata, addr, i, -WLAN_BACK_RECIPIENT , -WLAN_REASON_QSTA_LEAVE_QBSS ); - } -} - -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 =0 ; - -if ((tid >=STA_TID_NUM ) || !(hw->flags &IEEE80211_HW_AMPDU_AGGREGATION )) -return -EINVAL ; - -#ifdef CONFIG_MAC80211_HT_DEBUG -printk (KERN_DEBUG "Open BA session requested for %pM tid %u\n" , - 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); - -if (hw->ampdu_queues) { -/* 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 , - &sta->sta, 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 */ -if (hw->ampdu_queues) -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 */ -if (hw->ampdu_queues) -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 ; - -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 %pM tid %u\n" , - ra, tid); -#endif /* CONFIG_MAC80211_HT_DEBUG */ - -if (hw->ampdu_queues) -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 , - &sta->sta, tid,NULL ); - -/* case HW denied going back to legacy */ -if (ret) { -WARN_ON (ret != -EBUSY ); - *state =HT_AGG_STATE_OPERATIONAL ; -if (hw->ampdu_queues) -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; - -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: %pM\n" , 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 -if (hw->ampdu_queues) -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; - -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 %pM tid %d\n" , - 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: %pM\n" , 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 ); - -if (hw->ampdu_queues) { - 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); - -/* -* 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->sta.addr, - (u16)*ptid,WLAN_BACK_TIMER , -WLAN_REASON_QSTA_TIMEOUT ); -} - -void ieee80211_process_addba_request (struct ieee80211_local *local, -struct sta_info *sta, -struct ieee80211_mgmt *mgmt, -size_t len) -{ -struct ieee80211_hw *hw = &local->hw; -struct ieee80211_conf *conf = &hw->conf; -struct tid_ampdu_rx *tid_agg_rx; -u16 capab, tid, timeout, ba_policy, buf_size, start_seq_num, status; -u8 dialog_token; -int ret = -EOPNOTSUPP ; - -/* extract session parameters from addba request frame */ - dialog_token = mgmt->u.action.u.addba_req.dialog_token; - timeout =le16_to_cpu (mgmt->u.action.u.addba_req.timeout); - start_seq_num = -le16_to_cpu (mgmt->u.action.u.addba_req.start_seq_num) >>4 ; - - capab =le16_to_cpu (mgmt->u.action.u.addba_req.capab); - ba_policy = (capab &IEEE80211_ADDBA_PARAM_POLICY_MASK ) >>1 ; - tid = (capab &IEEE80211_ADDBA_PARAM_TID_MASK ) >>2 ; - buf_size = (capab &IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK ) >>6 ; - - status =WLAN_STATUS_REQUEST_DECLINED ; - -/* sanity check for incoming parameters: -* check if configuration can support the BA policy -* and if buffer size does not exceeds max value */ -/* XXX: check own ht delayed BA capability?? */ -if (((ba_policy !=1 ) - && (!(sta->sta.ht_cap.cap &IEEE80211_HT_CAP_DELAY_BA ))) - || (buf_size >IEEE80211_MAX_AMPDU_BUF )) { - status =WLAN_STATUS_INVALID_QOS_PARAM ; -#ifdef CONFIG_MAC80211_HT_DEBUG -if (net_ratelimit ()) -printk (KERN_DEBUG "AddBA Req with bad params from " -"%pM on tid %u. policy %d, buffer size %d\n" , - mgmt->sa, tid, ba_policy, - buf_size); -#endif /* CONFIG_MAC80211_HT_DEBUG */ - goto end_no_lock; - } -/* determine default buffer size */ -if (buf_size ==0 ) { -struct ieee80211_supported_band *sband; - - sband = local->hw.wiphy->bands[conf->channel->band]; - buf_size =IEEE80211_MIN_AMPDU_BUF ; - buf_size = buf_size << sband->ht_cap.ampdu_factor; - } - - -/* examine state machine */ -spin_lock_bh (&sta->lock); - -if (sta->ampdu_mlme.tid_state_rx[tid] !=HT_AGG_STATE_IDLE ) { -#ifdef CONFIG_MAC80211_HT_DEBUG -if (net_ratelimit ()) -printk (KERN_DEBUG "unexpected AddBA Req from " -"%pM on tid %u\n" , - mgmt->sa, tid); -#endif /* CONFIG_MAC80211_HT_DEBUG */ - goto end; - } - -/* prepare A-MPDU MLME for Rx aggregation */ - sta->ampdu_mlme.tid_rx[tid] = -kmalloc (sizeof (struct tid_ampdu_rx ),GFP_ATOMIC ); -if (!sta->ampdu_mlme.tid_rx[tid]) { -#ifdef CONFIG_MAC80211_HT_DEBUG -if (net_ratelimit ()) -printk (KERN_ERR "allocate rx mlme to tid %d failed\n" , - tid); -#endif - goto end; - } -/* rx timer */ - sta->ampdu_mlme.tid_rx[tid]->session_timer.function = - sta_rx_agg_session_timer_expired; - sta->ampdu_mlme.tid_rx[tid]->session_timer.data = - (unsigned long )&sta->timer_to_tid[tid]; -init_timer (&sta->ampdu_mlme.tid_rx[tid]->session_timer); - - tid_agg_rx = sta->ampdu_mlme.tid_rx[tid]; - -/* prepare reordering buffer */ - tid_agg_rx->reorder_buf = -kcalloc (buf_size,sizeof (struct sk_buff *),GFP_ATOMIC ); -if (!tid_agg_rx->reorder_buf) { -#ifdef CONFIG_MAC80211_HT_DEBUG -if (net_ratelimit ()) -printk (KERN_ERR "can not allocate reordering buffer " -"to tid %d\n" , tid); -#endif -kfree (sta->ampdu_mlme.tid_rx[tid]); - goto end; - } - -if (local->ops->ampdu_action) - ret = local->ops->ampdu_action (hw,IEEE80211_AMPDU_RX_START , - &sta->sta, tid, &start_seq_num); -#ifdef CONFIG_MAC80211_HT_DEBUG -printk (KERN_DEBUG "Rx A-MPDU request on tid %d result %d\n" , tid, ret); -#endif /* CONFIG_MAC80211_HT_DEBUG */ - -if (ret) { -kfree (tid_agg_rx->reorder_buf); -kfree (tid_agg_rx); - sta->ampdu_mlme.tid_rx[tid] =NULL ; - goto end; - } - -/* change state and send addba resp */ - sta->ampdu_mlme.tid_state_rx[tid] =HT_AGG_STATE_OPERATIONAL ; - tid_agg_rx->dialog_token = dialog_token; - tid_agg_rx->ssn = start_seq_num; - tid_agg_rx->head_seq_num = start_seq_num; - tid_agg_rx->buf_size = buf_size; - tid_agg_rx->timeout = timeout; - tid_agg_rx->stored_mpdu_num =0 ; - status =WLAN_STATUS_SUCCESS ; -end: -spin_unlock_bh (&sta->lock); - -end_no_lock: -ieee80211_send_addba_resp (sta->sdata, sta->sta.addr, tid, - dialog_token, status,1 , buf_size, timeout); -} - -void ieee80211_process_addba_resp (struct ieee80211_local *local, -struct sta_info *sta, -struct ieee80211_mgmt *mgmt, -size_t len) -{ -struct ieee80211_hw *hw = &local->hw; -u16 capab; -u16 tid, start_seq_num; -u8 *state; - - capab =le16_to_cpu (mgmt->u.action.u.addba_resp.capab); - tid = (capab &IEEE80211_ADDBA_PARAM_TID_MASK ) >>2 ; - - state = &sta->ampdu_mlme.tid_state_tx[tid]; - -spin_lock_bh (&sta->lock); - -if (!(*state &HT_ADDBA_REQUESTED_MSK )) { -spin_unlock_bh (&sta->lock); -return ; - } - -if (mgmt->u.action.u.addba_resp.dialog_token != - sta->ampdu_mlme.tid_tx[tid]->dialog_token) { -spin_unlock_bh (&sta->lock); -#ifdef CONFIG_MAC80211_HT_DEBUG -printk (KERN_DEBUG "wrong addBA response token, tid %d\n" , tid); -#endif /* CONFIG_MAC80211_HT_DEBUG */ -return ; - } - -del_timer_sync (&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer); -#ifdef CONFIG_MAC80211_HT_DEBUG -printk (KERN_DEBUG "switched off addBA timer for tid %d \n" , tid); -#endif /* CONFIG_MAC80211_HT_DEBUG */ -if (le16_to_cpu (mgmt->u.action.u.addba_resp.status) - ==WLAN_STATUS_SUCCESS ) { - *state |=HT_ADDBA_RECEIVED_MSK ; - sta->ampdu_mlme.addba_req_num[tid] =0 ; - -if (*state ==HT_AGG_STATE_OPERATIONAL && - local->hw.ampdu_queues) -ieee80211_wake_queue (hw, sta->tid_to_tx_q[tid]); - -if (local->ops->ampdu_action) { - (void )local->ops->ampdu_action (hw, -IEEE80211_AMPDU_TX_RESUME , - &sta->sta, tid, &start_seq_num); - } -#ifdef CONFIG_MAC80211_HT_DEBUG -printk (KERN_DEBUG "Resuming TX aggregation for tid %d\n" , tid); -#endif /* CONFIG_MAC80211_HT_DEBUG */ -spin_unlock_bh (&sta->lock); - }else { - sta->ampdu_mlme.addba_req_num[tid]++; -/* this will allow the state check in stop_BA_session */ - *state =HT_AGG_STATE_OPERATIONAL ; -spin_unlock_bh (&sta->lock); -ieee80211_stop_tx_ba_session (hw, sta->sta.addr, tid, -WLAN_BACK_INITIATOR ); - } -} -void ieee80211_process_delba (struct ieee80211_sub_if_data *sdata,struct sta_info *sta,struct ieee80211_mgmt *mgmt,size_t len)
net/mac80211/Makefile +1 -1
@@ -8,7 +8,7 @@ mac80211-y := \ wep.o \ wpa.o \ scan.o \ - ht.o \ + ht.o agg-tx.o agg-rx.o \ mlme.o \ iface.o \ rate.o \
net/mac80211/ieee80211_i.h +3 -0
@@ -984,6 +984,9 @@ u32 ieee80211_enable_ht(struct ieee80211struct ieee80211_ht_info *hti, u16 ap_ht_cap_flags);void ieee80211_send_bar (struct ieee80211_sub_if_data *sdata,u8 *ra,u16 tid,u16 ssn); +void ieee80211_send_delba (struct ieee80211_sub_if_data *sdata, +const u8 *da,u16 tid, +u16 initiator,u16 reason_code);void ieee80211_sta_stop_rx_ba_session (struct ieee80211_sub_if_data *sdata,u8 *da,u16 tid,u16 initiator,u16 reason);
net/mac80211/agg-rx.c new file +287 -0
287 lines not on this page · raw message
net/mac80211/agg-tx.c new file +593 -0
593 lines not on this page · raw message
Johannes Berg
maintainerPATCH 11/27 mac80211: restrict aggregation to supported interface modes
In reply to Johannes BergWe can only support aggregation on AP/STA right now. HT isn't defined for IBSS, WDS or MESH. In the WDS/MESH cases it's not clear what to put into the IBSS field, and we don't handle that in the code at all. Also fix the code to handle VLAN correctly.
---
v2: do not allow IBSS
net/mac80211/agg-rx.c | 3 ++- net/mac80211/agg-tx.c | 16 +++++++++++++++- net/mac80211/ht.c | 3 ++- net/mac80211/rx.c | 11 +++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-)
net/mac80211/agg-tx.c +15 -1
@@ -41,7 +41,8 @@ static void ieee80211_send_addba_requestmemset (mgmt,0 ,24 );memcpy (mgmt->da, da,ETH_ALEN );memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN ); -if (sdata->vif.type ==NL80211_IFTYPE_AP ) +if (sdata->vif.type ==NL80211_IFTYPE_AP || + sdata->vif.type ==NL80211_IFTYPE_AP_VLAN )memcpy (mgmt->bssid, sdata->dev->dev_addr,ETH_ALEN );else memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN );
@@ -180,6 +181,19 @@ int ieee80211_start_tx_ba_session(struct goto exit; } +/* +* The aggregation code is not prepared to handle +* anything but STA/AP due to the BSSID handling. +* IBSS could work in the code but isn't supported +* by drivers or the standard. +*/ +if (sta->sdata->vif.type !=NL80211_IFTYPE_STATION && + sta->sdata->vif.type !=NL80211_IFTYPE_AP_VLAN && + sta->sdata->vif.type !=NL80211_IFTYPE_AP ) { + ret = -EINVAL ; + goto exit; + } +spin_lock_bh (&sta->lock);/* we have tried too many times, receiver does not want A-MPDU */
net/mac80211/rx.c +11 -0
@@ -1735,6 +1735,17 @@ ieee80211_rx_h_action(struct ieee80211_rswitch (mgmt->u.action.category) {case WLAN_CATEGORY_BACK : +/* +* The aggregation code is not prepared to handle +* anything but STA/AP due to the BSSID handling; +* IBSS could work in the code but isn't supported +* by drivers or the standard. +*/ +if (sdata->vif.type !=NL80211_IFTYPE_STATION && + sdata->vif.type !=NL80211_IFTYPE_AP_VLAN && + sdata->vif.type !=NL80211_IFTYPE_AP ) +return RX_DROP_MONITOR ; +switch (mgmt->u.action.u.addba_req.action_code) {case WLAN_ACTION_ADDBA_REQ : if (len < (IEEE80211_MIN_ACTION_SIZE +
net/mac80211/agg-rx.c +2 -1
@@ -134,7 +134,8 @@ static void ieee80211_send_addba_resp(stmemset (mgmt,0 ,24 );memcpy (mgmt->da, da,ETH_ALEN );memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN ); -if (sdata->vif.type ==NL80211_IFTYPE_AP ) +if (sdata->vif.type ==NL80211_IFTYPE_AP || + sdata->vif.type ==NL80211_IFTYPE_AP_VLAN )memcpy (mgmt->bssid, sdata->dev->dev_addr,ETH_ALEN );else memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN );
net/mac80211/ht.c +2 -1
@@ -190,7 +190,8 @@ void ieee80211_send_delba(struct ieee802memset (mgmt,0 ,24 );memcpy (mgmt->da, da,ETH_ALEN );memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN ); -if (sdata->vif.type ==NL80211_IFTYPE_AP ) +if (sdata->vif.type ==NL80211_IFTYPE_AP || + sdata->vif.type ==NL80211_IFTYPE_AP_VLAN )memcpy (mgmt->bssid, sdata->dev->dev_addr,ETH_ALEN );else memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN );
Johannes Berg
maintainerPATCH 12/27 mac80211: hardware should not deny going back to legacy
In reply to Johannes BergDoing so would be an MLME protocol violation when the peer disabled the aggregation session. Quick driver review indicates that there are error codes passed all over the drivers but cannot ever be nonzero except in error conditions that would indicate mac80211 bugs.
No real changes here, since no drivers currently can return -EBUSY.
--- net/mac80211/agg-tx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/mac80211/agg-tx.c +2 -3
@@ -407,9 +407,8 @@ int ieee80211_stop_tx_ba_session(struct ret = local->ops->ampdu_action (hw,IEEE80211_AMPDU_TX_STOP , &sta->sta, tid,NULL ); -/* case HW denied going back to legacy */ -if (ret) { -WARN_ON (ret != -EBUSY ); +/* HW shall not deny going back to legacy */ +if (WARN_ON (ret)) { *state =HT_AGG_STATE_OPERATIONAL ;if (hw->ampdu_queues)ieee80211_wake_queue (hw, sta->tid_to_tx_q[tid]);
Johannes Berg
maintainerPATCH 13/27 mac80211: document TX aggregation (and small cleanup)
In reply to Johannes BergAdd documentation and move ieee80211_start_tx_ba_cb_irqsafe to right after ieee80211_start_tx_ba_cb.
--- net/mac80211/agg-tx.c | 76 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 25 deletions(-)
net/mac80211/agg-tx.c +51 -25
@@ -18,6 +18,31 @@#include "ieee80211_i.h" #include "wme.h" +/** +* DOC: TX aggregation +* +* Aggregation on the TX side requires setting the hardware flag +* %IEEE80211_HW_AMPDU_AGGREGATION as well as, if present, the @ampdu_queues +* hardware parameter to the number of hardware AMPDU queues. If there are no +* hardware queues then the driver will (currently) have to do all frame +* buffering. +* +* When TX aggregation is started by some subsystem (usually the rate control +* algorithm would be appropriate) by calling the +* ieee80211_start_tx_ba_session() function, the driver will be notified via +* its @ampdu_action function, with the %IEEE80211_AMPDU_TX_START action. +* +* In response to that, the driver is later required to call the +* ieee80211_start_tx_ba_cb() (or ieee80211_start_tx_ba_cb_irqsafe()) +* function, which will start the aggregation session. +* +* Similarly, when the aggregation session is stopped by +* ieee80211_stop_tx_ba_session(), the driver's @ampdu_action function will +* be called with the action %IEEE80211_AMPDU_TX_STOP. In this case, the +* call must not fail, and the driver must later call ieee80211_stop_tx_ba_cb() +* (or ieee80211_stop_tx_ba_cb_irqsafe()). +*/ + static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata, const u8 *da, u16 tid, u8 dialog_token, u16 start_seq_num,
@@ -363,6 +388,31 @@ void ieee80211_start_tx_ba_cb(struct iee }EXPORT_SYMBOL (ieee80211_start_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); + int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid,
@@ -492,31 +542,6 @@ void ieee80211_stop_tx_ba_cb(struct ieee }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) {
@@ -542,6 +567,7 @@ void ieee80211_stop_tx_ba_cb_irqsafe(str }EXPORT_SYMBOL (ieee80211_stop_tx_ba_cb_irqsafe); + void ieee80211_process_addba_resp(struct ieee80211_local *local, struct sta_info *sta, struct ieee80211_mgmt *mgmt,
Johannes Berg
maintainerPATCH 14/27 mac80211: fix race in TX aggregation
In reply to Johannes BergWhen disabling TX aggregation because it was rejected or from the timer (it was not accepted), there is a window where we first set the state to operation, unlock, and then undo the whole thing. Avoid that by splitting up the stop function. Also get rid of the pointless sta_info indirection in the timer.
--- net/mac80211/agg-tx.c | 95 +++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 47 deletions(-)
net/mac80211/agg-tx.c +48 -47
@@ -123,6 +123,34 @@ void ieee80211_send_bar(struct ieee80211ieee80211_tx_skb (sdata, skb,0 ); } +static int __ieee80211_stop_tx_ba_session (struct ieee80211_local *local, +struct sta_info *sta,u16 tid, +enum ieee80211_back_parties initiator) +{ +int ret; +u8 *state; + + state = &sta->ampdu_mlme.tid_state_tx[tid]; + +if (local->hw.ampdu_queues) +ieee80211_stop_queue (&local->hw, sta->tid_to_tx_q[tid]); + + *state =HT_AGG_STATE_REQ_STOP_BA_MSK | + (initiator <<HT_AGG_STATE_INITIATOR_SHIFT ); + + ret = local->ops->ampdu_action (&local->hw,IEEE80211_AMPDU_TX_STOP , + &sta->sta, tid,NULL ); + +/* HW shall not deny going back to legacy */ +if (WARN_ON (ret)) { + *state =HT_AGG_STATE_OPERATIONAL ; +if (local->hw.ampdu_queues) +ieee80211_wake_queue (&local->hw, sta->tid_to_tx_q[tid]); + } + +return ret; +} +/* * After sending add Block Ack request we activated a timer until * add Block Ack response will arrive from the recipient.
@@ -135,23 +163,13 @@ static void sta_addba_resp_timer_expired* flow in sta_info_create gives the TID as data, while the timer_to_id * array gives the sta through container_of */ u16 tid = *(u8 *)data; -struct sta_info *temp_sta =container_of ((void *)data, +struct sta_info *sta =container_of ((void *)data, struct sta_info, timer_to_tid[tid]); - -struct ieee80211_local *local = temp_sta->local; -struct ieee80211_hw *hw = &local->hw; -struct sta_info *sta; +struct ieee80211_local *local = sta->local;u8 *state; -rcu_read_lock (); - - sta =sta_info_get (local, temp_sta->sta.addr); -if (!sta) { -rcu_read_unlock (); -return ; - } - state = &sta->ampdu_mlme.tid_state_tx[tid]; +/* check if the TID waits for addBA response */ spin_lock_bh (&sta->lock);if (!(*state &HT_ADDBA_REQUESTED_MSK )) {
@@ -161,21 +179,15 @@ static void sta_addba_resp_timer_expiredprintk (KERN_DEBUG "timer expired on tid %d but we are not " "expecting addBA response there" , tid);#endif - goto timer_expired_exit; +return ; }#ifdef CONFIG_MAC80211_HT_DEBUG printk (KERN_DEBUG "addBA response timer expired on tid %d\n" , tid);#endif -/* go through the state check in stop_BA_session */ - *state =HT_AGG_STATE_OPERATIONAL ; +__ieee80211_stop_tx_ba_session (local, sta, tid,WLAN_BACK_INITIATOR );spin_unlock_bh (&sta->lock); -ieee80211_stop_tx_ba_session (hw, temp_sta->sta.addr, tid, -WLAN_BACK_INITIATOR ); - -timer_expired_exit: -rcu_read_unlock (); }int ieee80211_start_tx_ba_session (struct ieee80211_hw *hw,u8 *ra,u16 tid)
@@ -187,6 +199,9 @@ int ieee80211_start_tx_ba_session(structu8 *state;int ret =0 ; +if (WARN_ON (!local->ops->ampdu_action)) +return -EINVAL ; +if ((tid >=STA_TID_NUM ) || !(hw->flags &IEEE80211_HW_AMPDU_AGGREGATION ))return -EINVAL ;
@@ -280,9 +295,8 @@ int ieee80211_start_tx_ba_session(struct/* 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 , - &sta->sta, tid, &start_seq_num); + ret = local->ops->ampdu_action (hw,IEEE80211_AMPDU_TX_START , + &sta->sta, tid, &start_seq_num);if (ret) {/* No need to requeue the packets in the agg queue, since we
@@ -423,6 +437,9 @@ int ieee80211_stop_tx_ba_session(structu8 *state;int ret =0 ; +if (WARN_ON (!local->ops->ampdu_action)) +return -EINVAL ; +if (tid >=STA_TID_NUM )return -EINVAL ;
@@ -439,7 +456,7 @@ int ieee80211_stop_tx_ba_session(structif (*state !=HT_AGG_STATE_OPERATIONAL ) { ret = -ENOENT ; - goto stop_BA_exit; + goto unlock; }#ifdef CONFIG_MAC80211_HT_DEBUG
@@ -447,27 +464,13 @@ int ieee80211_stop_tx_ba_session(struct ra, tid);#endif /* CONFIG_MAC80211_HT_DEBUG */ -if (hw->ampdu_queues) -ieee80211_stop_queue (hw, sta->tid_to_tx_q[tid]); - - *state =HT_AGG_STATE_REQ_STOP_BA_MSK | - (initiator <<HT_AGG_STATE_INITIATOR_SHIFT ); + ret =__ieee80211_stop_tx_ba_session (local, sta, tid, initiator); -if (local->ops->ampdu_action) - ret = local->ops->ampdu_action (hw,IEEE80211_AMPDU_TX_STOP , - &sta->sta, tid,NULL ); - -/* HW shall not deny going back to legacy */ -if (WARN_ON (ret)) { - *state =HT_AGG_STATE_OPERATIONAL ; -if (hw->ampdu_queues) -ieee80211_wake_queue (hw, sta->tid_to_tx_q[tid]); - goto stop_BA_exit; - } - -stop_BA_exit: + unlock:spin_unlock_bh (&sta->lock); +rcu_read_unlock (); +return ret; }EXPORT_SYMBOL (ieee80211_stop_tx_ba_session);
@@ -623,10 +626,8 @@ void ieee80211_process_addba_resp(structspin_unlock_bh (&sta->lock); }else { sta->ampdu_mlme.addba_req_num[tid]++; -/* this will allow the state check in stop_BA_session */ - *state =HT_AGG_STATE_OPERATIONAL ; +__ieee80211_stop_tx_ba_session (local, sta, tid, +WLAN_BACK_INITIATOR );spin_unlock_bh (&sta->lock); -ieee80211_stop_tx_ba_session (hw, sta->sta.addr, tid, -WLAN_BACK_INITIATOR ); } }
Johannes Berg
maintainerPATCH 15/27 mac80211: fix aggregation timer lockups
In reply to Johannes BergAs far as I can tell, there are possible lockups because both the RX session_timer and TX addba_resp_timer are del_timer_sync'ed under the sta spinlock which both timer functions take. Additionally, the TX agg code seems to leak memory when TX aggregation is not disabled before the sta_info is freed.
Fix this by making the free code a little smarter in the RX agg case, and actually make the sta_info_destroy code free the TX agg info in the TX agg case. We won't notify the peer, but it'll notice something is wrong anyway, and normally this only happens after we've told it in some other way we will no longer talk to it.
--- net/mac80211/agg-rx.c | 11 +++++++++-- net/mac80211/sta_info.c | 37 +++++++++++++++++++++++++++++++++---- net/mac80211/sta_info.h | 1 + 3 files changed, 43 insertions(+), 6 deletions(-)
net/mac80211/agg-rx.c +9 -2
@@ -78,11 +78,18 @@ void ieee80211_sta_stop_rx_ba_session(st sta->ampdu_mlme.tid_rx[tid]->reorder_buf[i] =NULL ; } } + +spin_lock_bh (&sta->lock);/* free resources */ kfree (sta->ampdu_mlme.tid_rx[tid]->reorder_buf); -kfree (sta->ampdu_mlme.tid_rx[tid]); - sta->ampdu_mlme.tid_rx[tid] =NULL ; + +if (!sta->ampdu_mlme.tid_rx[tid]->shutdown) { +kfree (sta->ampdu_mlme.tid_rx[tid]); + sta->ampdu_mlme.tid_rx[tid] =NULL ; + } + sta->ampdu_mlme.tid_state_rx[tid] =HT_AGG_STATE_IDLE ; +spin_unlock_bh (&sta->lock);rcu_read_unlock (); }
net/mac80211/sta_info.c +33 -4
@@ -194,12 +194,41 @@ void sta_info_destroy(struct sta_info *sdev_kfree_skb_any (skb);for (i =0 ; i <STA_TID_NUM ; i++) { +struct tid_ampdu_rx *tid_rx; +struct tid_ampdu_tx *tid_tx; +spin_lock_bh (&sta->lock); -if (sta->ampdu_mlme.tid_rx[i]) -del_timer_sync (&sta->ampdu_mlme.tid_rx[i]->session_timer); -if (sta->ampdu_mlme.tid_tx[i]) -del_timer_sync (&sta->ampdu_mlme.tid_tx[i]->addba_resp_timer); + tid_rx = sta->ampdu_mlme.tid_rx[i]; +/* Make sure timer won't free the tid_rx struct, see below */ +if (tid_rx) + tid_rx->shutdown = true;spin_unlock_bh (&sta->lock); + +/* +* Outside spinlock - shutdown is true now so that the timer +* won't free tid_rx, we have to do that now. Can't let the +* timer do it because we have to sync the timer outside the +* lock that it takes itself. +*/ +if (tid_rx) { +del_timer_sync (&tid_rx->session_timer); +kfree (tid_rx); + } + +/* +* No need to do such complications for TX agg sessions, the +* path leading to freeing the tid_tx struct goes via a call +* from the driver, and thus needs to look up the sta struct +* again, which cannot be found when we get here. Hence, we +* just need to delete the timer and free the aggregation +* info; we won't be telling the peer about it then but that +* doesn't matter if we're not talking to it again anyway. +*/ + tid_tx = sta->ampdu_mlme.tid_tx[i]; +if (tid_tx) { +del_timer_sync (&tid_tx->addba_resp_timer); +kfree (tid_tx); + } }__sta_info_free (local, sta);
net/mac80211/sta_info.h +1 -0
@@ -100,6 +100,7 @@ struct tid_ampdu_rx {u16 buf_size;u16 timeout;u8 dialog_token; +bool shutdown; };/**
Johannes Berg
maintainerPATCH 16/27 mac80211: clean up BA session teardown
In reply to Johannes BergThe sta_info pointer can very well be passed toieee80211_sta_tear_down_BA_sessions, this will
later allow us to pass it through even further.
--- net/mac80211/ht.c | 8 ++++---- net/mac80211/ieee80211_i.h | 2 +- net/mac80211/iface.c | 3 +-- net/mac80211/mlme.c | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-)
net/mac80211/ht.c +4 -4
@@ -153,15 +153,15 @@ u32 ieee80211_enable_ht(struct ieee80211return changed; } -void ieee80211_sta_tear_down_BA_sessions (struct ieee80211_sub_if_data *sdata,u8 *addr) +void ieee80211_sta_tear_down_BA_sessions (struct sta_info *sta) { -struct ieee80211_local *local = sdata->local; +struct ieee80211_local *local = sta->local;int i;for (i =0 ; i <STA_TID_NUM ; i++) { -ieee80211_stop_tx_ba_session (&local->hw, addr, i, +ieee80211_stop_tx_ba_session (&local->hw, sta->sta.addr, i,WLAN_BACK_INITIATOR ); -ieee80211_sta_stop_rx_ba_session (sdata, addr, i, +ieee80211_sta_stop_rx_ba_session (sta->sdata, sta->sta.addr, i,WLAN_BACK_RECIPIENT ,WLAN_REASON_QSTA_LEAVE_QBSS ); }
net/mac80211/ieee80211_i.h +1 -1
@@ -990,7 +990,7 @@ void ieee80211_send_delba(struct ieee802void ieee80211_sta_stop_rx_ba_session (struct ieee80211_sub_if_data *sdata,u8 *da,u16 tid,u16 initiator,u16 reason); -void ieee80211_sta_tear_down_BA_sessions (struct ieee80211_sub_if_data *sdata,u8 *addr); +void ieee80211_sta_tear_down_BA_sessions (struct sta_info *sta);void ieee80211_process_delba (struct ieee80211_sub_if_data *sdata,struct sta_info *sta,struct ieee80211_mgmt *mgmt,size_t len);
net/mac80211/iface.c +1 -2
@@ -362,8 +362,7 @@ static int ieee80211_stop(struct net_devlist_for_each_entry_rcu (sta, &local->sta_list, list) {if (sta->sdata == sdata) -ieee80211_sta_tear_down_BA_sessions (sdata, - sta->sta.addr); +ieee80211_sta_tear_down_BA_sessions (sta); }rcu_read_unlock ();
net/mac80211/mlme.c +1 -1
@@ -924,7 +924,7 @@ static void ieee80211_set_disassoc(strucnetif_tx_stop_all_queues (sdata->dev);netif_carrier_off (sdata->dev); -ieee80211_sta_tear_down_BA_sessions (sdata, sta->sta.addr); +ieee80211_sta_tear_down_BA_sessions (sta);if (self_disconnected) {if (deauth)
Johannes Berg
maintainerPATCH 17/27 mac80211: RX aggregation: clean up stop session
In reply to Johannes BergClean up the locking by splitting it into two functions, this will also enable further cleanups of stopping all sessions.
--- net/mac80211/agg-rx.c | 57 ++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 25 deletions(-)
net/mac80211/agg-rx.c +32 -25
@@ -17,47 +17,32 @@#include <net/mac80211.h> #include "ieee80211_i.h" -void ieee80211_sta_stop_rx_ba_session (struct ieee80211_sub_if_data *sdata,u8 *ra,u16 tid, -u16 initiator,u16 reason) +static void __ieee80211_sta_stop_rx_ba_session (struct sta_info *sta,u16 tid, +u16 initiator,u16 reason) { -struct ieee80211_local *local = sdata->local; +struct ieee80211_local *local = sta->local;struct ieee80211_hw *hw = &local->hw; -struct sta_info *sta; -int ret, i; - -rcu_read_lock (); - - sta =sta_info_get (local, ra); -if (!sta) { -rcu_read_unlock (); -return ; - } +int i;/* check if TID is in operational state */ spin_lock_bh (&sta->lock); -if (sta->ampdu_mlme.tid_state_rx[tid] - !=HT_AGG_STATE_OPERATIONAL ) { +if (sta->ampdu_mlme.tid_state_rx[tid] !=HT_AGG_STATE_OPERATIONAL ) {spin_unlock_bh (&sta->lock); -rcu_read_unlock ();return ; } + sta->ampdu_mlme.tid_state_rx[tid] =HT_AGG_STATE_REQ_STOP_BA_MSK | (initiator <<HT_AGG_STATE_INITIATOR_SHIFT );spin_unlock_bh (&sta->lock); -/* stop HW Rx aggregation. ampdu_action existence -* already verified in session init so we add the BUG_ON */ -BUG_ON (!local->ops->ampdu_action); -#ifdef CONFIG_MAC80211_HT_DEBUG printk (KERN_DEBUG "Rx BA session stop requested for %pM tid %u\n" , - ra, tid); + sta->sta.addr, tid);#endif /* CONFIG_MAC80211_HT_DEBUG */ - ret = local->ops->ampdu_action (hw,IEEE80211_AMPDU_RX_STOP , - &sta->sta, tid,NULL ); -if (ret) +if (local->ops->ampdu_action (hw,IEEE80211_AMPDU_RX_STOP , + &sta->sta, tid,NULL ))printk (KERN_DEBUG "HW problem - can not stop rx " "aggregation for tid %d\n" , tid);
@@ -67,7 +52,8 @@ void ieee80211_sta_stop_rx_ba_session(st/* check if this is a self generated aggregation halt */ if (initiator ==WLAN_BACK_RECIPIENT || initiator ==WLAN_BACK_TIMER ) -ieee80211_send_delba (sdata, ra, tid,0 , reason); +ieee80211_send_delba (sta->sdata, sta->sta.addr, + tid,0 , reason);/* free the reordering buffer */ for (i =0 ; i < sta->ampdu_mlme.tid_rx[tid]->buf_size; i++) {
@@ -90,6 +76,27 @@ void ieee80211_sta_stop_rx_ba_session(st sta->ampdu_mlme.tid_state_rx[tid] =HT_AGG_STATE_IDLE ;spin_unlock_bh (&sta->lock); +} + +void ieee80211_sta_stop_rx_ba_session (struct ieee80211_sub_if_data *sdata,u8 *ra,u16 tid, +u16 initiator,u16 reason) +{ +struct ieee80211_local *local = sdata->local; +struct sta_info *sta; + +/* stop HW Rx aggregation. ampdu_action existence +* already verified in session init so we add the BUG_ON */ +BUG_ON (!local->ops->ampdu_action); + +rcu_read_lock (); + + sta =sta_info_get (local, ra); +if (!sta) { +rcu_read_unlock (); +return ; + } + +__ieee80211_sta_stop_rx_ba_session (sta, tid, initiator, reason);rcu_read_unlock (); }
Johannes Berg
maintainerPATCH 18/27 mac80211: further cleanups to stopping BA sessions
In reply to Johannes BergEssentially consisting of passing the sta_info pointer around, instead of repeatedly doing hash lookups.
--- net/mac80211/agg-rx.c | 6 ++-- net/mac80211/agg-tx.c | 63 +++++++++++++++++++++++---------------------- net/mac80211/ht.c | 9 ++---- net/mac80211/ieee80211_i.h | 5 +++ 4 files changed, 44 insertions(+), 39 deletions(-)
net/mac80211/agg-rx.c +3 -3
@@ -17,8 +17,8 @@#include <net/mac80211.h> #include "ieee80211_i.h" -static void __ieee80211_sta_stop_rx_ba_session (struct sta_info *sta,u16 tid, -u16 initiator,u16 reason) +void __ieee80211_stop_rx_ba_session (struct sta_info *sta,u16 tid, +u16 initiator,u16 reason) {struct ieee80211_local *local = sta->local;struct ieee80211_hw *hw = &local->hw;
@@ -96,7 +96,7 @@ void ieee80211_sta_stop_rx_ba_session(streturn ; } -__ieee80211_sta_stop_rx_ba_session (sta, tid, initiator, reason); +__ieee80211_stop_rx_ba_session (sta, tid, initiator, reason);rcu_read_unlock (); }
net/mac80211/ieee80211_i.h +5 -0
@@ -990,6 +990,8 @@ void ieee80211_send_delba(struct ieee802void ieee80211_sta_stop_rx_ba_session (struct ieee80211_sub_if_data *sdata,u8 *da,u16 tid,u16 initiator,u16 reason); +void __ieee80211_stop_rx_ba_session (struct sta_info *sta,u16 tid, +u16 initiator,u16 reason);void ieee80211_sta_tear_down_BA_sessions (struct sta_info *sta); void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata, struct sta_info *sta,
@@ -1003,6 +1005,9 @@ void ieee80211_process_addba_request(strstruct ieee80211_mgmt *mgmt, size_t len); +int __ieee80211_stop_tx_ba_session (struct sta_info *sta,u16 tid, +enum ieee80211_back_parties initiator); +/* Spectrum management */ void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata, struct ieee80211_mgmt *mgmt,
net/mac80211/agg-tx.c +33 -30
108 lines not on this page · raw message
net/mac80211/ht.c +3 -6
@@ -155,15 +155,12 @@ u32 ieee80211_enable_ht(struct ieee80211void ieee80211_sta_tear_down_BA_sessions (struct sta_info *sta) { -struct ieee80211_local *local = sta->local;int i;for (i =0 ; i <STA_TID_NUM ; i++) { -ieee80211_stop_tx_ba_session (&local->hw, sta->sta.addr, i, -WLAN_BACK_INITIATOR ); -ieee80211_sta_stop_rx_ba_session (sta->sdata, sta->sta.addr, i, -WLAN_BACK_RECIPIENT , -WLAN_REASON_QSTA_LEAVE_QBSS ); +__ieee80211_stop_tx_ba_session (sta, i,WLAN_BACK_INITIATOR ); +__ieee80211_stop_rx_ba_session (sta, i,WLAN_BACK_RECIPIENT , +WLAN_REASON_QSTA_LEAVE_QBSS ); } }
Johannes Berg
maintainerPATCH 19/27 cfg80211/nl80211: scanning (and mac80211 update to use it)
In reply to Johannes BergThis patch adds basic scan capability to cfg80211/nl80211 and changes mac80211 to use it. The BSS list that cfg80211 maintains is made driver-accessible with a private area in each BSS struct, but mac80211 doesn't yet use it. That's another large project.
---
TODO (later):
* use BSS stuff from cfg80211 in mac80211 (this is fairly involved)
* port a fullmac driver and complete the API
drivers/net/wireless/iwlwifi/iwl-agn.c | 12 drivers/net/wireless/iwlwifi/iwl-core.c | 1 drivers/net/wireless/iwlwifi/iwl-scan.c | 2 drivers/net/wireless/iwlwifi/iwl3945-base.c | 17 include/linux/nl80211.h | 65 ++ include/net/cfg80211.h | 131 ++++ include/net/mac80211.h | 6 include/net/wireless.h | 3 net/mac80211/cfg.c | 20 net/mac80211/ieee80211_i.h | 18 net/mac80211/iface.c | 2 net/mac80211/main.c | 32 + net/mac80211/mlme.c | 37 - net/mac80211/scan.c | 356 ++---------- net/mac80211/wext.c | 59 -- net/wireless/Makefile | 2 net/wireless/core.c | 8 net/wireless/core.h | 20 net/wireless/nl80211.c | 323 +++++++++++ net/wireless/nl80211.h | 8 net/wireless/scan.c | 807 ++++++++++++++++++++++++++++ 21 files changed, 1546 insertions(+), 383 deletions(-)
include/linux/nl80211.h +65 -0
@@ -143,6 +143,13 @@* added to all specified management frames generated by * kernel/firmware/driver. * +* @NL80211_CMD_GET_SCAN: get scan results +* @NL80211_CMD_TRIGGER_SCAN: trigger a new scan with the given parameters +* @NL80211_CMD_NEW_SCAN_RESULTS: scan notification (as a reply to +* NL80211_CMD_GET_SCAN and on the "scan" multicast group) +* @NL80211_CMD_SCAN_ABORTED: scan was aborted, for unspecified reasons, +* partial scan results may be available +* * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */
@@ -192,6 +199,11 @@ enum nl80211_commands {NL80211_CMD_GET_REG , +NL80211_CMD_GET_SCAN , +NL80211_CMD_TRIGGER_SCAN , +NL80211_CMD_NEW_SCAN_RESULTS , +NL80211_CMD_SCAN_ABORTED , +/* add new commands above here */ /* used to define NL80211_CMD_MAX below */
@@ -305,6 +317,18 @@ enum nl80211_commands {* @NL80211_ATTR_IE: Information element(s) data (used, e.g., with * %NL80211_CMD_SET_MGMT_EXTRA_IE). * +* @NL80211_ATTR_MAX_NUM_SCAN_SSIDS: number of SSIDs you can scan with +* a single scan request, a wiphy attribute. +* +* @NL80211_ATTR_SCAN_FREQUENCIES: nested attribute with frequencies (in MHz) +* @NL80211_ATTR_SCAN_SSIDS: nested attribute with SSIDs, leave out for passive +* scanning and include a zero-length SSID (wildcard) for wildcard scan +* @NL80211_ATTR_SCAN_GENERATION: the scan generation increases whenever the +* scan result list changes (BSS expired or added) so that applications +* can verify that they got a single, consistent snapshot (when all dump +* messages carried the same generation number) +* @NL80211_ATTR_BSS: scan result BSS +* * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use */
@@ -372,6 +396,13 @@ enum nl80211_attrs {NL80211_ATTR_MGMT_SUBTYPE ,NL80211_ATTR_IE , +NL80211_ATTR_MAX_NUM_SCAN_SSIDS , + +NL80211_ATTR_SCAN_FREQUENCIES , +NL80211_ATTR_SCAN_SSIDS , +NL80211_ATTR_SCAN_GENERATION , +NL80211_ATTR_BSS , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
@@ -841,4 +872,38 @@ enum nl80211_channel_type {NL80211_CHAN_HT40MINUS ,NL80211_CHAN_HT40PLUS }; + +/** +* enum nl80211_bss - netlink attributes for a BSS +* +* @__NL80211_BSS_INVALID: invalid +* @NL80211_BSS_FREQUENCY: frequency in MHz (u32) +* @NL80211_BSS_TSF: TSF of the received probe response/beacon (u64) +* @NL80211_BSS_BEACON_INTERVAL: beacon interval of the (I)BSS (u16) +* @NL80211_BSS_CAPABILITY: capability field (CPU order, u16) +* @NL80211_BSS_INFORMATION_ELEMENTS: binary attribute containing the +* raw information elements from the probe response/beacon (bin) +* @NL80211_BSS_SIGNAL_MBM: signal strength of probe response/beacon +* in mBm (100 * dBm) (s32) +* @NL80211_BSS_SIGNAL_UNSPEC: signal strength of the probe response/beacon +* in unspecified units, scaled to 0..100 (u8) +* @__NL80211_BSS_AFTER_LAST: internal +* @NL80211_BSS_MAX: highest BSS attribute +*/ +enum nl80211_bss { + __NL80211_BSS_INVALID, +NL80211_BSS_BSSID , +NL80211_BSS_FREQUENCY , +NL80211_BSS_TSF , +NL80211_BSS_BEACON_INTERVAL , +NL80211_BSS_CAPABILITY , +NL80211_BSS_INFORMATION_ELEMENTS , +NL80211_BSS_SIGNAL_MBM , +NL80211_BSS_SIGNAL_UNSPEC , + +/* keep last */ + __NL80211_BSS_AFTER_LAST, +NL80211_BSS_MAX = __NL80211_BSS_AFTER_LAST -1 +}; +#endif /* __LINUX_NL80211_H */
include/net/cfg80211.h +131 -0
160 lines not on this page · raw message
net/wireless/nl80211.c +323 -0
371 lines not on this page · raw message
net/wireless/scan.c new file +807 -0
807 lines not on this page · raw message
net/mac80211/ieee80211_i.h +9 -9
@@ -294,8 +294,6 @@ struct ieee80211_if_sta {u8 ssid[IEEE80211_MAX_SSID_LEN ];enum ieee80211_sta_mlme_state state;size_t ssid_len; -u8 scan_ssid[IEEE80211_MAX_SSID_LEN ]; -size_t scan_ssid_len;u16 aid;u16 ap_capab, capab;u8 *extra_ie;/* to be added to the end of AssocReq */
@@ -658,17 +656,18 @@ struct ieee80211_local {/* Scanning and BSS list */ bool sw_scanning, hw_scanning; +struct cfg80211_ssid scan_ssid; +struct cfg80211_scan_request int_scan_req; +struct cfg80211_scan_request *scan_req; +struct ieee80211_channel *scan_channel;int scan_channel_idx; -enum ieee80211_band scan_band;enum {SCAN_SET_CHANNEL ,SCAN_SEND_PROBE } scan_state;unsigned long last_scan_completed;struct delayed_work scan_work;struct ieee80211_sub_if_data *scan_sdata; -struct ieee80211_channel *oper_channel, *scan_channel, *csa_channel;enum nl80211_channel_type oper_channel_type; -u8 scan_ssid[IEEE80211_MAX_SSID_LEN ]; -size_t scan_ssid_len; +struct ieee80211_channel *oper_channel, *csa_channel;struct list_head bss_list;struct ieee80211_bss *bss_hash[STA_HASH_SIZE ];spinlock_t bss_lock;
@@ -926,7 +925,7 @@ void ieee80211_send_probe_req(struct iee/* scan/BSS handling */ int ieee80211_request_scan (struct ieee80211_sub_if_data *sdata, -u8 *ssid,size_t ssid_len); +struct cfg80211_scan_request *req);int ieee80211_scan_results (struct ieee80211_local *local,struct iw_request_info *info,char *buf,size_t len);
@@ -941,14 +940,15 @@ int ieee80211_sta_set_extra_ie(struct ievoid ieee80211_mlme_notify_scan_completed (struct ieee80211_local *local);int ieee80211_start_scan (struct ieee80211_sub_if_data *scan_sdata, -u8 *ssid,size_t ssid_len); +struct cfg80211_scan_request *req);struct ieee80211_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_channel *channel, +bool beacon);struct ieee80211_bss *ieee80211_rx_bss_add (struct ieee80211_local *local,u8 *bssid,int freq,u8 *ssid,u8 ssid_len);
net/mac80211/scan.c +60 -296
466 lines not on this page · raw message
net/mac80211/wext.c +4 -55
78 lines not on this page · raw message
net/mac80211/mlme.c +28 -9
@@ -1713,7 +1713,7 @@ static void ieee80211_rx_bss_info(struct } bss =ieee80211_bss_info_update (local, rx_status, mgmt, len, elems, - freq, beacon); + channel, beacon);if (!bss)return ;
@@ -2117,7 +2117,15 @@ static void ieee80211_sta_merge_ibss(strprintk (KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " "IBSS networks with same SSID (merge)\n" , sdata->dev->name); -ieee80211_request_scan (sdata, ifsta->ssid, ifsta->ssid_len); + +/* XXX maybe racy? */ +if (sdata->local->scan_req) +return ; + +memcpy (sdata->local->int_scan_req.ssids[0 ].ssid, + ifsta->ssid,IEEE80211_MAX_SSID_LEN ); + sdata->local->int_scan_req.ssids[0 ].ssid_len = ifsta->ssid_len; +ieee80211_request_scan (sdata, &sdata->local->int_scan_req); }
@@ -2333,8 +2341,15 @@ dont_join: IEEE80211_SCAN_INTERVAL)) {printk (KERN_DEBUG "%s: Trigger new scan to find an IBSS to " "join\n" , sdata->dev->name); -return ieee80211_request_scan (sdata, ifsta->ssid, - ifsta->ssid_len); + +/* XXX maybe racy? */ +if (local->scan_req) +return -EBUSY ; + +memcpy (local->int_scan_req.ssids[0 ].ssid, + ifsta->ssid,IEEE80211_MAX_SSID_LEN ); + local->int_scan_req.ssids[0 ].ssid_len = ifsta->ssid_len; +return ieee80211_request_scan (sdata, &local->int_scan_req); } else if (ifsta->state != IEEE80211_STA_MLME_IBSS_JOINED) {int interval =IEEE80211_SCAN_INTERVAL ;
@@ -2433,11 +2448,16 @@ static int ieee80211_sta_config_auth(str }else {if (ifsta->assoc_scan_tries <IEEE80211_ASSOC_SCANS_MAX_TRIES ) { ifsta->assoc_scan_tries++; +/* XXX maybe racy? */ +if (local->scan_req) +return -1 ; +memcpy (local->int_scan_req.ssids[0 ].ssid, + ifsta->ssid,IEEE80211_MAX_SSID_LEN );if (ifsta->flags &IEEE80211_STA_AUTO_SSID_SEL ) -ieee80211_start_scan (sdata,NULL ,0 ); + local->int_scan_req.ssids[0 ].ssid_len =0 ;else -ieee80211_start_scan (sdata, ifsta->ssid, - ifsta->ssid_len); + local->int_scan_req.ssids[0 ].ssid_len = ifsta->ssid_len; +ieee80211_start_scan (sdata, &local->int_scan_req); ifsta->state =IEEE80211_STA_MLME_AUTHENTICATE ;set_bit (IEEE80211_STA_REQ_AUTH , &ifsta->request); }else {
@@ -2475,8 +2495,7 @@ static void ieee80211_sta_work(struct wo ifsta->state != IEEE80211_STA_MLME_AUTHENTICATE && ifsta->state != IEEE80211_STA_MLME_ASSOCIATE && test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifsta->request)) { -ieee80211_start_scan (sdata, ifsta->scan_ssid, - ifsta->scan_ssid_len); +ieee80211_start_scan (sdata, local->scan_req);return ; }
net/mac80211/cfg.c +20 -0
@@ -1277,6 +1277,25 @@ static int ieee80211_resume(struct wiphy#define ieee80211_resume NULL#endif +static int ieee80211_scan (struct wiphy *wiphy, +struct net_device *dev, +struct cfg80211_scan_request *req) +{ +struct ieee80211_sub_if_data *sdata; + +if (!netif_running (dev)) +return -ENETDOWN ; + + sdata =IEEE80211_DEV_TO_SUB_IF (dev); + +if (sdata->vif.type !=NL80211_IFTYPE_STATION && + sdata->vif.type !=NL80211_IFTYPE_ADHOC && + sdata->vif.type !=NL80211_IFTYPE_MESH_POINT ) +return -EOPNOTSUPP ; + +return ieee80211_request_scan (sdata, req); +} +struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface,
@@ -1309,4 +1328,5 @@ struct cfg80211_ops mac80211_config_ops .set_mgmt_extra_ie = ieee80211_set_mgmt_extra_ie, .suspend = ieee80211_suspend, .resume = ieee80211_resume, + .scan = ieee80211_scan, };
net/wireless/Makefile +1 -1
@@ -5,7 +5,7 @@ obj-$(CONFIG_LIB80211_CRYPT_WEP) += lib8 obj-$(CONFIG_LIB80211_CRYPT_CCMP) += lib80211_crypt_ccmp.o obj-$(CONFIG_LIB80211_CRYPT_TKIP) += lib80211_crypt_tkip.o -cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o +cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o cfg80211-$(CONFIG_WIRELESS_EXT) += wext-compat.o cfg80211-$(CONFIG_NL80211) += nl80211.o
net/mac80211/main.c +29 -3
@@ -733,6 +733,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(return NULL ; wiphy->privid = mac80211_wiphy_privid; + wiphy->max_scan_ssids =4 ; local =wiphy_priv (wiphy); local->hw.wiphy = wiphy;
@@ -817,25 +818,33 @@ int ieee80211_register_hw(struct ieee802enum ieee80211_band band;struct net_device *mdev;struct ieee80211_master_priv *mpriv; +int channels, i, j;/* * generic code guarantees at least one band, * set this very early because much code assumes * that hw.conf.channel is assigned */ + channels =0 ;for (band =0 ; band <IEEE80211_NUM_BANDS ; band++) {struct ieee80211_supported_band *sband; sband = local->hw.wiphy->bands[band]; -if (sband) { +if (sband && !local->oper_channel) {/* init channel we're on */ local->hw.conf.channel = local->oper_channel = local->scan_channel = &sband->channels[0 ]; -break ; } +if (sband) + channels += sband->n_channels; } + local->int_scan_req.n_channels = channels; + local->int_scan_req.channels =kzalloc (sizeof (void *) * channels,GFP_KERNEL ); +if (!local->int_scan_req.channels) +return -ENOMEM ; +/* if low-level driver supports AP, we also support VLAN */ if (local->hw.wiphy->interface_modes &BIT (NL80211_IFTYPE_AP )) local->hw.wiphy->interface_modes |=BIT (NL80211_IFTYPE_AP_VLAN );
@@ -845,7 +854,7 @@ int ieee80211_register_hw(struct ieee802 result =wiphy_register (local->hw.wiphy);if (result <0 ) -return result; + goto fail_wiphy_register;/* * We use the number of queues for feature tests (QoS, HT) internally
@@ -948,6 +957,20 @@ int ieee80211_register_hw(struct ieee802ieee80211_led_init (local); +/* alloc internal scan request */ + i =0 ; + local->int_scan_req.ssids = &local->scan_ssid; + local->int_scan_req.n_ssids =1 ; +for (band =0 ; band <IEEE80211_NUM_BANDS ; band++) { +if (!hw->wiphy->bands[band]) +continue ; +for (j =0 ; j < hw->wiphy->bands[band]->n_channels; j++) { + local->int_scan_req.channels[i] = + &hw->wiphy->bands[band]->channels[j]; + i++; + } + } +return 0 ; fail_wep:
@@ -966,6 +989,8 @@ fail_workqueue:free_netdev (local->mdev); fail_mdev_alloc:wiphy_unregister (local->hw.wiphy); +fail_wiphy_register: +kfree (local->int_scan_req.channels);return result; }EXPORT_SYMBOL (ieee80211_register_hw);
@@ -1011,6 +1036,7 @@ void ieee80211_unregister_hw(struct ieeeieee80211_wep_free (local);ieee80211_led_exit (local);free_netdev (local->mdev); +kfree (local->int_scan_req.channels); }EXPORT_SYMBOL (ieee80211_unregister_hw);
net/wireless/nl80211.h +8 -0
@@ -7,6 +7,10 @@extern int nl80211_init (void );extern void nl80211_exit (void );extern void nl80211_notify_dev_rename (struct cfg80211_registered_device *rdev); +extern void nl80211_send_scan_done (struct cfg80211_registered_device *rdev, +struct net_device *netdev); +extern void nl80211_send_scan_aborted (struct cfg80211_registered_device *rdev, +struct net_device *netdev);#else static inline int nl80211_init (void ) {
@@ -19,6 +23,10 @@ static inline void nl80211_notify_dev_re struct cfg80211_registered_device *rdev) { } +static inline void +nl80211_send_scan_done (struct cfg80211_registered_device *rdev, +struct net_device *netdev) +{}#endif /* CONFIG_NL80211 */ #endif /* __NET_WIRELESS_NL80211_H */
net/wireless/core.c +8 -0
@@ -240,6 +240,8 @@ struct wiphy *wiphy_new(struct cfg80211_mutex_init (&drv->mtx);mutex_init (&drv->devlist_mtx);INIT_LIST_HEAD (&drv->netdev_list); +spin_lock_init (&drv->bss_lock); +INIT_LIST_HEAD (&drv->bss_list);device_initialize (&drv->wiphy.dev); drv->wiphy.dev.class = &ieee80211_class;
@@ -259,6 +261,9 @@ int wiphy_register(struct wiphy *wiphy)int i;u16 ifmodes = wiphy->interface_modes; +if (WARN_ON (wiphy->max_scan_ssids <1 )) +return -EINVAL ; +/* sanity check ifmodes */ WARN_ON (!ifmodes); ifmodes &= ((1 << __NL80211_IFTYPE_AFTER_LAST) -1 ) & ~1 ;
@@ -367,8 +372,11 @@ EXPORT_SYMBOL(wiphy_unregister);void cfg80211_dev_free (struct cfg80211_registered_device *drv) { +struct cfg80211_internal_bss *scan, *tmp;mutex_destroy (&drv->mtx);mutex_destroy (&drv->devlist_mtx); +list_for_each_entry_safe (scan, tmp, &drv->bss_list, list) +kfree (scan);kfree (drv); }
net/wireless/core.h +20 -0
@@ -8,6 +8,8 @@#include <linux/mutex.h> #include <linux/list.h> #include <linux/netdevice.h> +#include <linux/kref.h> +#include <linux/rbtree.h> #include <net/genetlink.h> #include <net/wireless.h> #include <net/cfg80211.h>
@@ -41,6 +43,13 @@ struct cfg80211_registered_device {struct mutex devlist_mtx;struct list_head netdev_list; +/* BSSes/scanning */ +spinlock_t bss_lock; +struct list_head bss_list; +struct rb_root bss_tree; +u32 bss_generation; +struct cfg80211_scan_request *scan_req;/* protected by RTNL */ +/* must be last because of the way we do wiphy_priv(), * and it should at least be aligned to NETDEV_ALIGN */ struct wiphy wiphy __attribute__((__aligned__(NETDEV_ALIGN)));
@@ -56,6 +65,15 @@ struct cfg80211_registered_device *wiphyextern struct mutex cfg80211_drv_mutex;extern struct list_head cfg80211_drv_list; +struct cfg80211_internal_bss { +struct list_head list; +struct rb_node rbn; +unsigned long ts; +struct kref ref; +/* must be last because of priv member */ +struct cfg80211_bss pub; +}; +/* * This function returns a pointer to the driver * that the genl_info item that is passed refers to.
@@ -94,4 +112,6 @@ extern int cfg80211_dev_rename(struct cfvoid ieee80211_set_bitrate_flags (struct wiphy *wiphy);void wiphy_update_regulatory (struct wiphy *wiphy,enum reg_set_by setby); +void cfg80211_bss_expire (struct cfg80211_registered_device *dev); +#endif /* __NET_WIRELESS_CORE_H */
include/net/wireless.h +3 -0
@@ -213,6 +213,9 @@ struct wiphy {bool custom_regulatory;bool strict_regulatory; +int bss_priv_size; +u8 max_scan_ssids; +/* If multiple wiphys are registered and you're handed e.g. * a regular netdev with assigned ieee80211_ptr, you won't * know whether it points to a wiphy your driver has registered
include/net/mac80211.h +4 -2
@@ -1406,7 +1406,8 @@ struct ieee80211_ops {void (*update_tkip_key)(struct ieee80211_hw *hw,struct ieee80211_key_conf *conf,const u8 *address,u32 iv32,u16 *phase1key); -int (*hw_scan)(struct ieee80211_hw *hw,u8 *ssid,size_t len); +int (*hw_scan)(struct ieee80211_hw *hw, +struct cfg80211_scan_request *req);int (*get_stats)(struct ieee80211_hw *hw,struct ieee80211_low_level_stats *stats); void (*get_tkip_seq)(struct ieee80211_hw *hw, u8 hw_key_idx,
@@ -1844,8 +1845,9 @@ void ieee80211_wake_queues(struct ieee80* mac80211 that the scan finished. * * @hw: the hardware that finished the scan +* @aborted: set to true if scan was aborted */ -void ieee80211_scan_completed (struct ieee80211_hw *hw); +void ieee80211_scan_completed (struct ieee80211_hw *hw,bool aborted);/** * ieee80211_iterate_active_interfaces - iterate active interfaces
drivers/net/wireless/iwlwifi/iwl-agn.c +10 -2
@@ -2678,11 +2678,19 @@ static void iwl_bss_info_changed(struct } -static int iwl_mac_hw_scan (struct ieee80211_hw *hw,u8 *ssid,size_t ssid_len) +static int iwl_mac_hw_scan (struct ieee80211_hw *hw, +struct cfg80211_scan_request *req) {unsigned long flags;struct iwl_priv *priv = hw->priv;int ret; +u8 *ssid =NULL ; +size_t ssid_len =0 ; + +if (req->n_ssids) { + ssid = req->ssids[0 ].ssid; + ssid_len = req->ssids[0 ].ssid_len; + }IWL_DEBUG_MAC80211 (priv,"enter\n" );
@@ -2718,7 +2726,7 @@ static int iwl_mac_hw_scan(struct ieee80if (ssid_len) { priv->one_direct_scan =1 ; - priv->direct_ssid_len =min_t (u8, ssid_len,IW_ESSID_MAX_SIZE ); + priv->direct_ssid_len = ssid_len;memcpy (priv->direct_ssid, ssid, priv->direct_ssid_len); }else { priv->one_direct_scan =0 ;
drivers/net/wireless/iwlwifi/iwl3945-base.c +13 -4
@@ -4442,15 +4442,23 @@ static void iwl3945_bss_info_changed(str } -static int iwl3945_mac_hw_scan (struct ieee80211_hw *hw,u8 *ssid,size_t len) +static int iwl3945_mac_hw_scan (struct ieee80211_hw *hw, +struct cfg80211_scan_request *req) {int rc =0 ;unsigned long flags;struct iwl_priv *priv = hw->priv; +size_t len =0 ; +u8 *ssid =NULL ;DECLARE_SSID_BUF (ssid_buf);IWL_DEBUG_MAC80211 (priv,"enter\n" ); +if (req->n_ssids) { + ssid = req->ssids[0 ].ssid; + len = req->ssids[0 ].ssid_len; + } +mutex_lock (&priv->mutex);spin_lock_irqsave (&priv->lock, flags);
@@ -4478,9 +4486,8 @@ static int iwl3945_mac_hw_scan(struct ie print_ssid(ssid_buf, ssid, len), len); priv->one_direct_scan =1 ; - priv->direct_ssid_len = (u8 ) -min ((u8 ) len, (u8 )IW_ESSID_MAX_SIZE ); -memcpy (priv->direct_ssid, ssid, priv->direct_ssid_len); + priv->direct_ssid_len = len; +memcpy (priv->direct_ssid, ssid, len); }else priv->one_direct_scan =0 ;
@@ -5412,6 +5419,8 @@ static int iwl3945_pci_probe(struct pci_ hw->wiphy->custom_regulatory = true; + hw->wiphy->max_scan_ssids =1 ; +/* 4 EDCA QOS priorities */ hw->queues =4 ;
net/mac80211/iface.c +1 -1
@@ -522,7 +522,7 @@ static int ieee80211_stop(struct net_dev* scan event to userspace -- the scan is incomplete. */ if (local->sw_scanning) -ieee80211_scan_completed (&local->hw); +ieee80211_scan_completed (&local->hw, true); } conf.vif = &sdata->vif;
drivers/net/wireless/iwlwifi/iwl-scan.c +1 -1
@@ -860,7 +860,7 @@ void iwl_bg_scan_completed(struct work_sif (test_bit (STATUS_EXIT_PENDING , &priv->status))return ; -ieee80211_scan_completed (priv->hw); +ieee80211_scan_completed (priv->hw, false);/* Since setting the TXPOWER may have been deferred while * performing the scan, fire one off */
drivers/net/wireless/iwlwifi/iwl-core.c +1 -0
@@ -1271,6 +1271,7 @@ int iwl_setup_mac(struct iwl_priv *priv)BIT (NL80211_IFTYPE_ADHOC ); hw->wiphy->custom_regulatory = true; + hw->wiphy->max_scan_ssids =1 ;/* Default value; 4 EDCA QOS priorities */ hw->queues =4 ;
Johannes Berg
maintainerPATCH 20/27 mac80211: dont add BSS when creating IBSS
In reply to Johannes BergThere's no need to create a BSS struct only to pass it to ieee80211_sta_join_ibss, so refactor this function into __ieee80211_sta_join_ibss which takes all the relevant paramters, and ieee80211_sta_join_ibss which takes a BSS struct (used when joining an IBSS that already has other members).
--- net/mac80211/ieee80211_i.h | 3 - net/mac80211/mlme.c | 107 ++++++++++++++++++++++++--------------------- net/mac80211/scan.c | 8 --- 3 files changed, 60 insertions(+), 58 deletions(-)
net/mac80211/mlme.c +58 -49
@@ -513,14 +513,15 @@ static void ieee80211_send_deauth_disass/* MLME */ static void ieee80211_sta_def_wmm_params (struct ieee80211_sub_if_data *sdata, -struct ieee80211_bss *bss) +const size_t supp_rates_len, +const u8 *supp_rates) {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 ) +for (i =0 ; i < supp_rates_len; i++) +if ((supp_rates[i] &0x7f ) *5 >110 ) have_higher_than_11mbit =1 ; if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ &&
@@ -1516,9 +1517,13 @@ static void ieee80211_rx_mgmt_assoc_resp } -static int ieee80211_sta_join_ibss (struct ieee80211_sub_if_data *sdata, -struct ieee80211_if_sta *ifsta, -struct ieee80211_bss *bss) +static int __ieee80211_sta_join_ibss (struct ieee80211_sub_if_data *sdata, +struct ieee80211_if_sta *ifsta, +const u8 *bssid,const int beacon_int, +const int freq, +const size_t supp_rates_len, +const u8 *supp_rates, +const u16 capability) {struct ieee80211_local *local = sdata->local;int res =0 , rates, i, j;
@@ -1534,7 +1539,7 @@ static int ieee80211_sta_join_ibss(struc }if ((ifsta->flags &IEEE80211_STA_PREV_BSSID_SET ) && -memcmp (ifsta->bssid, bss->bssid,ETH_ALEN ) ==0 ) +memcmp (ifsta->bssid, bssid,ETH_ALEN ) ==0 )return res; skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400 +
@@ -1545,28 +1550,28 @@ static int ieee80211_sta_join_ibss(strucreturn -ENOMEM ; } - sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; -if (!(ifsta->flags &IEEE80211_STA_PREV_BSSID_SET )) {/* Remove possible STA entries from other IBSS networks. */ sta_info_flush_delayed (sdata); } -memcpy (ifsta->bssid, bss->bssid,ETH_ALEN ); +memcpy (ifsta->bssid, bssid,ETH_ALEN ); res =ieee80211_if_config (sdata,IEEE80211_IFCC_BSSID );if (res)return res; - local->hw.conf.beacon_int = bss->beacon_int >=10 ? bss->beacon_int :10 ; + local->hw.conf.beacon_int = beacon_int >=10 ? beacon_int :10 ; - sdata->drop_unencrypted = bss->capability & + sdata->drop_unencrypted = capability &WLAN_CAPABILITY_PRIVACY ?1 :0 ; - res =ieee80211_set_freq (sdata, bss->freq); + res =ieee80211_set_freq (sdata, freq);if (res)return res; + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; +/* Build IBSS probe response */ skb_reserve (skb, local->hw.extra_tx_headroom);
@@ -1575,33 +1580,32 @@ static int ieee80211_sta_join_ibss(strucskb_put (skb,24 +sizeof (mgmt->u.beacon));memset (mgmt,0 ,24 +sizeof (mgmt->u.beacon)); mgmt->frame_control =cpu_to_le16 (IEEE80211_FTYPE_MGMT | -IEEE80211_STYPE_PROBE_RESP ); +IEEE80211_STYPE_PROBE_RESP );memset (mgmt->da,0xff ,ETH_ALEN );memcpy (mgmt->sa, sdata->dev->dev_addr,ETH_ALEN );memcpy (mgmt->bssid, ifsta->bssid,ETH_ALEN ); mgmt->u.beacon.beacon_int =cpu_to_le16 (local->hw.conf.beacon_int); - mgmt->u.beacon.timestamp =cpu_to_le64 (bss->timestamp); - mgmt->u.beacon.capab_info =cpu_to_le16 (bss->capability); + mgmt->u.beacon.capab_info =cpu_to_le16 (capability); pos =skb_put (skb,2 + ifsta->ssid_len); *pos++ =WLAN_EID_SSID ; *pos++ = ifsta->ssid_len;memcpy (pos, ifsta->ssid, ifsta->ssid_len); - rates = bss->supp_rates_len; + rates = supp_rates_len;if (rates >8 ) rates =8 ; pos =skb_put (skb,2 + rates); *pos++ =WLAN_EID_SUPP_RATES ; *pos++ = rates; -memcpy (pos, bss->supp_rates, rates); +memcpy (pos, supp_rates, rates); -if (bss->band ==IEEE80211_BAND_2GHZ ) { +if (sband->band ==IEEE80211_BAND_2GHZ ) { pos =skb_put (skb,2 +1 ); *pos++ =WLAN_EID_DS_PARAMS ; *pos++ =1 ; - *pos++ =ieee80211_frequency_to_channel (bss->freq); + *pos++ =ieee80211_frequency_to_channel (freq); } pos =skb_put (skb,2 +2 );
@@ -1611,12 +1615,12 @@ static int ieee80211_sta_join_ibss(struc *pos++ =0 ; *pos++ =0 ; -if (bss->supp_rates_len >8 ) { - rates = bss->supp_rates_len -8 ; +if (supp_rates_len >8 ) { + rates = supp_rates_len -8 ; pos =skb_put (skb,2 + rates); *pos++ =WLAN_EID_EXT_SUPP_RATES ; *pos++ = rates; -memcpy (pos, &bss->supp_rates[8 ], rates); +memcpy (pos, &supp_rates[8 ], rates); } add_extra_ies(skb, sdata->u.sta.ie_proberesp,
@@ -1629,16 +1633,15 @@ static int ieee80211_sta_join_ibss(struc rates =0 ; - sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; -for (i =0 ; i < bss->supp_rates_len; i++) { -int bitrate = (bss->supp_rates[i] &0x7f ) *5 ; +for (i =0 ; i < supp_rates_len; i++) { +int bitrate = (supp_rates[i] &0x7f ) *5 ;for (j =0 ; j < sband->n_bitrates; j++)if (sband->bitrates[j].bitrate == bitrate) rates |=BIT (j); } ifsta->supp_rates_bits[local->hw.conf.channel->band] = rates; -ieee80211_sta_def_wmm_params (sdata, bss); +ieee80211_sta_def_wmm_params (sdata, supp_rates_len, supp_rates); ifsta->flags |=IEEE80211_STA_PREV_BSSID_SET ; ifsta->state =IEEE80211_STA_MLME_IBSS_JOINED ;
@@ -1647,12 +1650,23 @@ static int ieee80211_sta_join_ibss(strucieee80211_led_assoc (local, true);memset (&wrqu,0 ,sizeof (wrqu)); -memcpy (wrqu.ap_addr.sa_data, bss->bssid,ETH_ALEN ); +memcpy (wrqu.ap_addr.sa_data, bssid,ETH_ALEN );wireless_send_event (sdata->dev,SIOCGIWAP , &wrqu,NULL );return res; } +static int ieee80211_sta_join_ibss (struct ieee80211_sub_if_data *sdata, +struct ieee80211_if_sta *ifsta, +struct ieee80211_bss *bss) +{ +return __ieee80211_sta_join_ibss (sdata, ifsta, + bss->bssid, bss->beacon_int, + bss->freq, + bss->supp_rates_len, bss->supp_rates, + bss->capability); +} + static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, struct ieee80211_mgmt *mgmt, size_t len,
@@ -2206,11 +2220,12 @@ static int ieee80211_sta_create_ibss(str struct ieee80211_if_sta *ifsta) {struct ieee80211_local *local = sdata->local; -struct ieee80211_bss *bss;struct ieee80211_supported_band *sband; -u8 bssid[ETH_ALEN ], *pos; +u8 *pos; +u8 bssid[ETH_ALEN ]; +u8 supp_rates[IEEE80211_MAX_SUPP_RATES ]; +u16 capability;int i; -int ret;if (sdata->u.sta.flags &IEEE80211_STA_BSSID_SET ) {memcpy (bssid, ifsta->bssid,ETH_ALEN );
@@ -2228,36 +2243,29 @@ static int ieee80211_sta_create_ibss(strprintk (KERN_DEBUG "%s: Creating new IBSS network, BSSID %pM\n" , sdata->dev->name, 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) -return -ENOMEM ; - - bss->band = local->hw.conf.channel->band; - sband = local->hw.wiphy->bands[bss->band]; + sband = local->hw.wiphy->bands[local->hw.conf.channel->band];if (local->hw.conf.beacon_int ==0 ) local->hw.conf.beacon_int =100 ; - bss->beacon_int = local->hw.conf.beacon_int; - bss->last_update = jiffies; - bss->capability =WLAN_CAPABILITY_IBSS ; + + capability =WLAN_CAPABILITY_IBSS ;if (sdata->default_key) - bss->capability |=WLAN_CAPABILITY_PRIVACY ; + capability |=WLAN_CAPABILITY_PRIVACY ;else sdata->drop_unencrypted =0 ; - bss->supp_rates_len = sband->n_bitrates; - pos = bss->supp_rates; + pos = supp_rates;for (i =0 ; i < sband->n_bitrates; i++) {int rate = sband->bitrates[i].bitrate; *pos++ = (u8) (rate /5 ); } - ret =ieee80211_sta_join_ibss (sdata, ifsta, bss); -ieee80211_rx_bss_put (local, bss); -return ret; +return __ieee80211_sta_join_ibss (sdata, ifsta, + bssid, local->hw.conf.beacon_int, + local->hw.conf.channel->center_freq, + sband->n_bitrates, supp_rates, + capability); }
@@ -2426,7 +2434,8 @@ 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); +ieee80211_sta_def_wmm_params (sdata, selected->supp_rates_len, + selected->supp_rates);if (sdata->u.sta.mfp ==IEEE80211_MFP_REQUIRED ) sdata->u.sta.flags |=IEEE80211_STA_MFP_ENABLED ;else
net/mac80211/scan.c +2 -6
@@ -14,11 +14,7 @@/* TODO: * figure out how to avoid that the "current BSS" expires -* clean up IBSS code (in MLME), see why it adds a BSS to the list -* use cfg80211's BSS handling (depends on IBSS TODO above) -* order BSS list by RSSI(?) ("quality of AP") -* scan result table filtering (by capability (privacy, IBSS/BSS, WPA/RSN IE, -* SSID) +* use cfg80211's BSS handling */ #include <linux/wireless.h>
@@ -107,7 +103,7 @@ static void __ieee80211_rx_bss_hash_del( } } -struct ieee80211_bss * +static struct ieee80211_bss *ieee80211_rx_bss_add (struct ieee80211_local *local,u8 *bssid,int freq,u8 *ssid,u8 ssid_len) {
net/mac80211/ieee80211_i.h +0 -3
@@ -950,9 +950,6 @@ ieee80211_bss_info_update(struct ieee802struct ieee80211_channel *channel, bool beacon);struct ieee80211_bss * -ieee80211_rx_bss_add (struct ieee80211_local *local,u8 *bssid,int freq, -u8 *ssid,u8 ssid_len); -struct ieee80211_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,
Johannes Berg
maintainerPATCH 21/27 cfg80211: free_priv for BSS info
In reply to Johannes BergWhen cfg80211 users have their own allocated data in the per-BSS private data, they will need to free this when the BSS struct is destroyed. Add a free_priv method and fix one place where the BSS was kfree'd rather than released properly.
--- include/net/cfg80211.h | 2 ++ net/wireless/core.c | 2 +- net/wireless/scan.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-)
include/net/cfg80211.h +2 -0
@@ -567,6 +567,7 @@ enum cfg80211_signal_type {* @len_information_elements: total length of the information elements * @signal: signal strength value * @signal_type: signal type +* @free_priv: function pointer to free private data * @priv: private area for driver use, has at least wiphy->bss_priv_size bytes */ struct cfg80211_bss {
@@ -582,6 +583,7 @@ struct cfg80211_bss {s32 signal;enum cfg80211_signal_type signal_type; +void (*free_priv)(struct cfg80211_bss *bss); u8 priv[0] __attribute__((__aligned__(sizeof(void *)))); };
net/wireless/scan.c +2 -0
@@ -56,6 +56,8 @@ static void bss_release(struct kref *refstruct cfg80211_internal_bss *bss; bss = container_of(ref, struct cfg80211_internal_bss, ref); +if (bss->pub.free_priv) + bss->pub.free_priv (&bss->pub);kfree (bss); }
net/wireless/core.c +1 -1
@@ -376,7 +376,7 @@ void cfg80211_dev_free(struct cfg80211_rmutex_destroy (&drv->mtx);mutex_destroy (&drv->devlist_mtx);list_for_each_entry_safe (scan, tmp, &drv->bss_list, list) -kfree (scan); +cfg80211_put_bss (&scan->pub);kfree (drv); }
Johannes Berg
maintainerPATCH 22/27 cfg80211: allow users to request removing a BSS
In reply to Johannes BergThis patch introduces cfg80211_unlink_bss, a function to allow a driver to remove a BSS from the internal list and make it not show up in scan results any more -- this is to be used when the driver detects that the BSS is no longer available.
--- include/net/cfg80211.h | 11 +++++++++++ net/wireless/scan.c | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+)
include/net/cfg80211.h +11 -0
@@ -791,5 +791,16 @@ struct cfg80211_bss *cfg80211_get_mesh(s const u8 *meshid, size_t meshidlen, const u8 *meshcfg);void cfg80211_put_bss (struct cfg80211_bss *bss); +/** +* cfg80211_unlink_bss - unlink BSS from internal data structures +* @wiphy: the wiphy +* @bss: the bss to remove +* +* This function removes the given BSS from the internal data structures +* thereby making it no longer show up in scan results etc. Use this +* function when you detect a BSS is gone. Normally BSSes will also time +* out, so it is not necessary to use this function at all. +*/ +void cfg80211_unlink_bss (struct wiphy *wiphy,struct cfg80211_bss *bss);#endif /* __NET_CFG80211_H */
net/wireless/scan.c +21 -0
@@ -432,6 +432,27 @@ void cfg80211_put_bss(struct cfg80211_bs }EXPORT_SYMBOL (cfg80211_put_bss); +void cfg80211_unlink_bss (struct wiphy *wiphy,struct cfg80211_bss *pub) +{ +struct cfg80211_registered_device *dev =wiphy_to_dev (wiphy); +struct cfg80211_internal_bss *bss; + +if (WARN_ON (!pub)) +return ; + + bss = container_of(pub, struct cfg80211_internal_bss, pub); + +spin_lock_bh (&dev->bss_lock); + +list_del (&bss->list); +rb_erase (&bss->rbn, &dev->bss_tree); + +spin_unlock_bh (&dev->bss_lock); + +kref_put (&bss->ref, bss_release); +} +EXPORT_SYMBOL (cfg80211_unlink_bss); +#ifdef CONFIG_WIRELESS_EXT int cfg80211_wext_siwscan(struct net_device *dev, struct iw_request_info *info,
Johannes Berg
maintainerPATCH 23/27 cfg80211: add more flexible BSS lookup
In reply to Johannes BergAdd a more flexible BSS lookup function so that mac80211 or other drivers can actually use this for getting the BSS to connect to.
--- include/net/cfg80211.h | 12 +++++++++++- net/wireless/scan.c | 10 ++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-)
include/net/cfg80211.h +11 -1
@@ -785,7 +785,17 @@ cfg80211_inform_bss_frame(struct wiphy *struct cfg80211_bss *cfg80211_get_bss (struct wiphy *wiphy,struct ieee80211_channel *channel,const u8 *bssid, -const u8 *ssid,size_t ssid_len); +const u8 *ssid,size_t ssid_len, +u16 capa_mask,u16 capa_val); +static inline struct cfg80211_bss * +cfg80211_get_ibss (struct wiphy *wiphy, +struct ieee80211_channel *channel, +const u8 *ssid,size_t ssid_len) +{ +return cfg80211_get_bss (wiphy, channel,NULL , ssid, ssid_len, +WLAN_CAPABILITY_IBSS ,WLAN_CAPABILITY_IBSS ); +} + struct cfg80211_bss *cfg80211_get_mesh(struct wiphy *wiphy, struct ieee80211_channel *channel, const u8 *meshid, size_t meshidlen,
net/wireless/scan.c +8 -2
@@ -116,9 +116,12 @@ static bool is_bss(struct cfg80211_bss * {const u8 *ssidie; -if (compare_ether_addr (a->bssid, bssid)) +if (bssid &&compare_ether_addr (a->bssid, bssid))return false; +if (!ssid) +return true; + ssidie =find_ie (WLAN_EID_SSID , a->information_elements, a->len_information_elements);
@@ -199,7 +202,8 @@ static int cmp_bss(struct cfg80211_bss *struct cfg80211_bss *cfg80211_get_bss (struct wiphy *wiphy,struct ieee80211_channel *channel,const u8 *bssid, -const u8 *ssid,size_t ssid_len) +const u8 *ssid,size_t ssid_len, +u16 capa_mask,u16 capa_val) {struct cfg80211_registered_device *dev =wiphy_to_dev (wiphy);struct cfg80211_internal_bss *bss, *res =NULL ;
@@ -207,6 +211,8 @@ struct cfg80211_bss *cfg80211_get_bss(stspin_lock_bh (&dev->bss_lock);list_for_each_entry (bss, &dev->bss_list, list) { +if ((bss->pub.capability & capa_mask) != capa_val) +continue ;if (channel && bss->pub.channel != channel)continue ;if (is_bss (&bss->pub, bssid, ssid, ssid_len)) {
Johannes Berg
maintainerPATCH 24/27 mac80211: use cfg80211s BSS infrastructure
In reply to Johannes BergRemove all the code from mac80211 to keep track of BSSes and use the cfg80211-provided code completely.
--- net/mac80211/ieee80211_i.h | 42 ++----- net/mac80211/main.c | 6 - net/mac80211/mesh.c | 10 - net/mac80211/mesh.h | 1 net/mac80211/mlme.c | 211 ++++++++++++------------------------- net/mac80211/scan.c | 255 +++------------------------------------------ net/mac80211/spectmgmt.c | 7 - 7 files changed, 114 insertions(+), 418 deletions(-)
net/mac80211/ieee80211_i.h +15 -27
@@ -72,43 +72,36 @@ struct ieee80211_fragment_entry {struct ieee80211_bss { -struct list_head list; -struct ieee80211_bss *hnext; -size_t ssid_len; +/* Yes, this is a hack */ +struct cfg80211_bss cbss; -atomic_t users; - -u8 bssid[ETH_ALEN ]; +/* don't want to look up all the time */ +size_t ssid_len;u8 ssid[IEEE80211_MAX_SSID_LEN ]; +u8 dtim_period; -u16 capability;/* host byte order */ -enum ieee80211_band band; -int freq; -int signal, noise, qual; -u8 *ies;/* all information elements from the last Beacon or Probe -* Response frames; note Beacon frame is not allowed to -* override values from Probe Response */ -size_t ies_len; +bool wmm_used; + +unsigned long last_probe_resp; +#ifdef CONFIG_MAC80211_MESH u8 *mesh_id;size_t mesh_id_len;u8 *mesh_cfg;#endif +#define IEEE80211_MAX_SUPP_RATES 32u8 supp_rates[IEEE80211_MAX_SUPP_RATES ];size_t supp_rates_len; -u64 timestamp; -int beacon_int; -unsigned long last_probe_resp; -unsigned long last_update; - -/* during assocation, we save an ERP value from a probe response so +/* +* During assocation, we save an ERP value from a probe response so * that we can feed ERP info to the driver when handling the * association completes. these fields probably won't be up-to-date -* otherwise, you probably don't want to use them. */ -int has_erp_value; +* otherwise, you probably don't want to use them. +*/ +bool has_erp_value;u8 erp_value; };
@@ -668,9 +661,6 @@ struct ieee80211_local {struct ieee80211_sub_if_data *scan_sdata;enum nl80211_channel_type oper_channel_type;struct ieee80211_channel *oper_channel, *csa_channel; -struct list_head bss_list; -struct ieee80211_bss *bss_hash[STA_HASH_SIZE ]; -spinlock_t bss_lock;/* SNMP counters */ /* dot11CountersTable */
@@ -933,8 +923,6 @@ ieee80211_rx_result ieee80211_scan_rx(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, struct ieee80211_rx_status *rx_status); -void ieee80211_rx_bss_list_init (struct ieee80211_local *local); -void ieee80211_rx_bss_list_deinit (struct ieee80211_local *local);int ieee80211_sta_set_extra_ie (struct ieee80211_sub_if_data *sdata,char *ie,size_t len);
net/mac80211/main.c +3 -3
@@ -734,6 +734,9 @@ struct ieee80211_hw *ieee80211_alloc_hw( wiphy->privid = mac80211_wiphy_privid; wiphy->max_scan_ssids =4 ; +/* Yes, putting cfg80211_bss into ieee80211_bss is a hack */ + wiphy->bss_priv_size =sizeof (struct ieee80211_bss ) - +sizeof (struct cfg80211_bss ); local =wiphy_priv (wiphy); local->hw.wiphy = wiphy;
@@ -877,8 +880,6 @@ int ieee80211_register_hw(struct ieee802 mpriv->local = local; local->mdev = mdev; -ieee80211_rx_bss_list_init (local); - local->hw.workqueue =create_singlethread_workqueue (wiphy_name (local->hw.wiphy));if (!local->hw.workqueue) {
@@ -1018,7 +1019,6 @@ void ieee80211_unregister_hw(struct ieeertnl_unlock (); -ieee80211_rx_bss_list_deinit (local);ieee80211_clear_tx_pending (local);sta_info_stop (local);rate_control_deinitialize (local);
net/mac80211/scan.c +19 -236
317 lines not on this page · raw message
net/mac80211/mlme.c +72 -139
329 lines not on this page · raw message
net/mac80211/spectmgmt.c +5 -2
@@ -102,8 +102,9 @@ void ieee80211_chswitch_work(struct work goto exit; sdata->local->oper_channel = sdata->local->csa_channel; +/* XXX: shouldn't really modify cfg80211-owned data! */ if (!ieee80211_hw_config (sdata->local,IEEE80211_CONF_CHANGE_CHANNEL )) - bss->freq = sdata->local->oper_channel->center_freq; + bss->cbss.channel = sdata->local->oper_channel;ieee80211_rx_bss_put (sdata->local, bss); exit:
@@ -158,7 +159,9 @@ void ieee80211_process_chanswitch(struct IEEE80211_QUEUE_STOP_REASON_CSA); ifsta->flags |=IEEE80211_STA_CSA_RECEIVED ;mod_timer (&ifsta->chswitch_timer, - jiffies +msecs_to_jiffies (sw_elem->count * bss->beacon_int)); + jiffies + +msecs_to_jiffies (sw_elem->count * + bss->cbss.beacon_interval)); } }
net/mac80211/mesh.c +0 -10
@@ -275,16 +275,6 @@ u32 mesh_table_hash(u8 *addr, struct iee & tbl->hash_mask; } -u8 mesh_id_hash (u8 *mesh_id,int mesh_id_len) -{ -if (!mesh_id_len) -return 1 ; -else if (mesh_id_len ==1 ) -return (u8 ) mesh_id[0 ]; -else -return (u8) (mesh_id[0 ] +2 * mesh_id[1 ]); -} -struct mesh_table *mesh_table_alloc (int size_order) {int i;
net/mac80211/mesh.h +0 -1
@@ -196,7 +196,6 @@ struct mesh_rmc {/* Public interfaces */ /* Various */ -u8 mesh_id_hash (u8 *mesh_id,int mesh_id_len);int ieee80211_get_mesh_hdrlen (struct ieee80211s_hdr *meshhdr);int ieee80211_new_mesh_header (struct ieee80211s_hdr *meshhdr,struct ieee80211_sub_if_data *sdata);
Johannes Berg
maintainerPATCH 25/27 mac80211: calculate wstats_flags on the fly
In reply to Johannes BergJust to make wext.c more self-contained.
--- net/mac80211/ieee80211_i.h | 1 - net/mac80211/main.c | 8 -------- net/mac80211/wext.c | 21 ++++++++++++++++++--- 3 files changed, 18 insertions(+), 12 deletions(-)
net/mac80211/ieee80211_i.h +0 -1
@@ -592,7 +592,6 @@ struct ieee80211_local {int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss;unsigned int filter_flags;/* FIF_* */ struct iw_statistics wstats; -u8 wstats_flags;bool tim_in_locked_section;/* see ieee80211_beacon_get() */ int tx_headroom;/* required headroom for hardware/radiotap */
net/mac80211/main.c +0 -8
@@ -905,14 +905,6 @@ int ieee80211_register_hw(struct ieee802 local->hw.conf.listen_interval = local->hw.max_listen_interval; - local->wstats_flags |= local->hw.flags & (IEEE80211_HW_SIGNAL_UNSPEC | -IEEE80211_HW_SIGNAL_DBM ) ? -IW_QUAL_QUAL_UPDATED :IW_QUAL_QUAL_INVALID ; - local->wstats_flags |= local->hw.flags &IEEE80211_HW_NOISE_DBM ? -IW_QUAL_NOISE_UPDATED :IW_QUAL_NOISE_INVALID ; -if (local->hw.flags &IEEE80211_HW_SIGNAL_DBM ) - local->wstats_flags |=IW_QUAL_DBM ; - result =sta_info_start (local);if (result <0 ) goto fail_sta_info;
net/mac80211/wext.c +18 -3
@@ -145,6 +145,21 @@ static int ieee80211_ioctl_siwgenie(strureturn -EOPNOTSUPP ; } +static u8 ieee80211_get_wstats_flags (struct ieee80211_local *local) +{ +u8 wstats_flags =0 ; + + wstats_flags |= local->hw.flags & (IEEE80211_HW_SIGNAL_UNSPEC | +IEEE80211_HW_SIGNAL_DBM ) ? +IW_QUAL_QUAL_UPDATED :IW_QUAL_QUAL_INVALID ; + wstats_flags |= local->hw.flags &IEEE80211_HW_NOISE_DBM ? +IW_QUAL_NOISE_UPDATED :IW_QUAL_NOISE_INVALID ; +if (local->hw.flags &IEEE80211_HW_SIGNAL_DBM ) + wstats_flags |=IW_QUAL_DBM ; + +return wstats_flags; +} +static int ieee80211_ioctl_giwrange (struct net_device *dev,struct iw_request_info *info,struct iw_point *data,char *extra)
@@ -187,13 +202,13 @@ static int ieee80211_ioctl_giwrange(stru range->max_qual.noise =0 ; range->max_qual.qual =100 ; - range->max_qual.updated = local->wstats_flags; + range->max_qual.updated =ieee80211_get_wstats_flags (local); range->avg_qual.qual =50 ;/* not always true but better than nothing */ range->avg_qual.level = range->max_qual.level /2 ; range->avg_qual.noise = range->max_qual.noise /2 ; - range->avg_qual.updated = local->wstats_flags; + range->avg_qual.updated =ieee80211_get_wstats_flags (local); range->enc_capa =IW_ENC_CAPA_WPA |IW_ENC_CAPA_WPA2 |IW_ENC_CAPA_CIPHER_TKIP |IW_ENC_CAPA_CIPHER_CCMP ;
@@ -979,7 +994,7 @@ static struct iw_statistics *ieee80211_g wstats->qual.level = sta->last_signal; wstats->qual.qual = sta->last_qual; wstats->qual.noise = sta->last_noise; - wstats->qual.updated = local->wstats_flags; + wstats->qual.updated =ieee80211_get_wstats_flags (local); }rcu_read_unlock ();
Johannes Berg
maintainerPATCH 26/27 mac80211: fix IBSS auth
In reply to Johannes BergThe code beyond this point is supposed to be used for non-IBSS (managed) mode only.
--- net/mac80211/mlme.c | 1 + 1 file changed, 1 insertion(+)
net/mac80211/mlme.c +1 -0
@@ -1175,6 +1175,7 @@ static void ieee80211_rx_mgmt_auth(strucif (auth_alg !=WLAN_AUTH_OPEN || auth_transaction !=1 )return ;ieee80211_send_auth (sdata, ifsta,2 ,NULL ,0 ,0 ); +return ; } if (auth_alg != ifsta->auth_alg ||
Johannes Berg
maintainerPATCH 27/27 mac80211: split managed/ibss code a little more
In reply to Johannes BergIt appears that you can completely mess up mac80211 in IBSS mode by sending it a disassoc or deauth: it'll stop queues and do a lot more but not ever do anything again. Fix this by not handling all those frames in IBSS mode,=20
---
net/mac80211/mlme.c | 254 +++++++++++++++++++++++++++++------------------=
-----
1 file changed, 146 insertions(+), 108 deletions(-)
--- wireless-testing.orig/net/mac80211/mlme.c 2009-02-10 20:59:39.000000000=
+0100
+++ wireless-testing/net/mac80211/mlme.c 2009-02-10 20:59:40.000000000 +010=
0
@@ -778,9 +778,6 @@ static void ieee80211_set_associated(str
bss_info_changed |=3D BSS_CHANGED_ASSOC;
ifsta->flags |=3D IEEE80211_STA_ASSOCIATED;
=20
- if (sdata->vif.type !=3D NL80211_IFTYPE_STATION)
- return;
-
bss =3D ieee80211_rx_bss_get(local, ifsta->bssid,
conf->channel->center_freq, ifsta->ssid, ifsta->ssid_len);
@@ -1139,6 +1136,30 @@ static void ieee80211_auth_challenge(str
elems.challenge_len + 2, 1);
}
=20
+static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdat= a,
+ struct ieee80211_if_sta *ifsta,
+ struct ieee80211_mgmt *mgmt,
+ size_t len)
+{
+ u16 auth_alg, auth_transaction, status_code;
+
+ if (len < 24 + 6)
+ return;
+
+ auth_alg =3D le16_to_cpu(mgmt->u.auth.auth_alg);
+ auth_transaction =3D le16_to_cpu(mgmt->u.auth.auth_transaction);
+ status_code =3D le16_to_cpu(mgmt->u.auth.status_code);
+
+ /*
+ * IEEE 802.11 standard does not require authentication in IBSS
+ * networks and most implementations do not seem to use it.
+ * However, try to reply to authentication attempts if someone
+ * has actually implemented this.
+ */
+ if (auth_alg =3D=3D WLAN_AUTH_OPEN && auth_transaction =3D=3D 1)
+ ieee80211_send_auth(sdata, ifsta, 2, NULL, 0, 0);
+}
+
static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,
struct ieee80211_if_sta *ifsta, struct ieee80211_mgmt *mgmt,
@@ -1146,38 +1167,22 @@ static void ieee80211_rx_mgmt_auth(struc
{
u16 auth_alg, auth_transaction, status_code;
=20
- if (ifsta->state !=3D IEEE80211_STA_MLME_AUTHENTICATE &&
- sdata->vif.type !=3D NL80211_IFTYPE_ADHOC)
+ if (ifsta->state !=3D IEEE80211_STA_MLME_AUTHENTICATE)
return;
=20
if (len < 24 + 6)
return;
=20
- if (sdata->vif.type !=3D NL80211_IFTYPE_ADHOC &&
- memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) !=3D 0)
+ if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) !=3D 0)
return;
=20
- if (sdata->vif.type !=3D NL80211_IFTYPE_ADHOC &&
- memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) !=3D 0)
+ if (memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) !=3D 0)
return;
=20
auth_alg =3D le16_to_cpu(mgmt->u.auth.auth_alg); auth_transaction =3D le16_to_cpu(mgmt->u.auth.auth_transaction); status_code =3D le16_to_cpu(mgmt->u.auth.status_code);
=20
- if (sdata->vif.type =3D=3D NL80211_IFTYPE_ADHOC) {
- /*
- * IEEE 802.11 standard does not require authentication in IBSS
- * networks and most implementations do not seem to use it.
- * However, try to reply to authentication attempts if someone
- * has actually implemented this.
- */
- if (auth_alg !=3D WLAN_AUTH_OPEN || auth_transaction !=3D 1)
- return;
- ieee80211_send_auth(sdata, ifsta, 2, NULL, 0, 0);
- return;
- }
-
if (auth_alg !=3D ifsta->auth_alg ||
auth_transaction !=3D ifsta->auth_transaction)
return;
@@ -1732,74 +1737,85 @@ static void ieee80211_rx_bss_info(struct
/* was just updated in ieee80211_bss_info_update */ beacon_timestamp =3D bss->cbss.tsf;
=20
- /*
- * In STA mode, the remaining parameters should not be overridden
- * by beacons because they're not necessarily accurate there.
- */
- if (sdata->vif.type !=3D NL80211_IFTYPE_ADHOC &&
- bss->last_probe_resp && beacon) {
- ieee80211_rx_bss_put(local, bss);
- return;
- }
+ if (sdata->vif.type !=3D NL80211_IFTYPE_ADHOC)
+ goto put_bss;
=20
/* check if we need to merge IBSS */
- if (sdata->vif.type =3D=3D NL80211_IFTYPE_ADHOC && beacon &&
- (!(sdata->u.sta.flags & IEEE80211_STA_BSSID_SET)) && - bss->cbss.capability & WLAN_CAPABILITY_IBSS && - bss->cbss.channel =3D=3D local->oper_channel && - elems->ssid_len =3D=3D sdata->u.sta.ssid_len &&
+
+ /* merge only on beacons (???) */
+ if (!beacon)
+ goto put_bss;
+
+ /* we use a fixed BSSID */
+ if (sdata->u.sta.flags & IEEE80211_STA_BSSID_SET)
+ goto put_bss;
+
+ /* not an IBSS */
+ if (!(bss->cbss.capability & WLAN_CAPABILITY_IBSS))
+ goto put_bss;
+
+ /* different channel */
+ if (bss->cbss.channel !=3D local->oper_channel)
+ goto put_bss;
+
+ /* different SSID */
+ if (elems->ssid_len !=3D sdata->u.sta.ssid_len ||
memcmp(elems->ssid, sdata->u.sta.ssid,
- sdata->u.sta.ssid_len) =3D=3D 0) {
- if (rx_status->flag & RX_FLAG_TSFT) {
- /* in order for correct IBSS merging we need mactime
- *
- * since mactime is defined as the time the first data
- * symbol of the frame hits the PHY, and the timestamp
- * of the beacon is defined as "the time that the data
- * symbol containing the first bit of the timestamp is
- * transmitted to the PHY plus the transmitting STA=E2=80=99s
- * delays through its local PHY from the MAC-PHY
- * interface to its interface with the WM"
- * (802.11 11.1.2) - equals the time this bit arrives at
- * the receiver - we have to take into account the
- * offset between the two.
- * e.g: at 1 MBit that means mactime is 192 usec earlier
- * (=3D24 bytes * 8 usecs/byte) than the beacon timestamp.
- */
- int rate;
- if (rx_status->flag & RX_FLAG_HT) {
- rate =3D 65; /* TODO: HT rates */
- } else {
- rate =3D local->hw.wiphy->bands[band]->
- bitrates[rx_status->rate_idx].bitrate;
- }
- rx_timestamp =3D rx_status->mactime + (24 * 8 * 10 / rate);
- } else if (local && local->ops && local->ops->get_tsf)
- /* second best option: get current TSF */
- rx_timestamp =3D local->ops->get_tsf(local_to_hw(local));
+ sdata->u.sta.ssid_len))
+ goto put_bss;
+
+ if (rx_status->flag & RX_FLAG_TSFT) {
+ /*
+ * For correct IBSS merging we need mactime; since mactime is
+ * defined as the time the first data symbol of the frame hits
+ * the PHY, and the timestamp of the beacon is defined as "the
+ * time that the data symbol containing the first bit of the
+ * timestamp is transmitted to the PHY plus the transmitting
+ * STA's delays through its local PHY from the MAC-PHY
+ * interface to its interface with the WM" (802.11 11.1.2)
+ * - equals the time this bit arrives at the receiver - we have
+ * to take into account the offset between the two.
+ *
+ * E.g. at 1 MBit that means mactime is 192 usec earlier
+ * (=3D24 bytes * 8 usecs/byte) than the beacon timestamp.
+ */
+ int rate;
+
+ if (rx_status->flag & RX_FLAG_HT)
+ rate =3D 65; /* TODO: HT rates */
else
- /* can't merge without knowing the TSF */
- rx_timestamp =3D -1LLU;
+ rate =3D local->hw.wiphy->bands[band]->
+ bitrates[rx_status->rate_idx].bitrate;
+
+ rx_timestamp =3D rx_status->mactime + (24 * 8 * 10 / rate);
+ } else if (local && local->ops && local->ops->get_tsf)
+ /* second best option: get current TSF */
+ rx_timestamp =3D local->ops->get_tsf(local_to_hw(local));
+ else
+ /* can't merge without knowing the TSF */
+ rx_timestamp =3D -1LLU;
+
#ifdef CONFIG_MAC80211_IBSS_DEBUG
- printk(KERN_DEBUG "RX beacon SA=3D%pM BSSID=3D"
- "%pM TSF=3D0x%llx BCN=3D0x%llx diff=3D%lld @%lu\n",
- mgmt->sa, mgmt->bssid,
- (unsigned long long)rx_timestamp,
- (unsigned long long)beacon_timestamp,
- (unsigned long long)(rx_timestamp - beacon_timestamp),
- jiffies);
-#endif /* CONFIG_MAC80211_IBSS_DEBUG */
- if (beacon_timestamp > rx_timestamp) {
+ printk(KERN_DEBUG "RX beacon SA=3D%pM BSSID=3D"
+ "%pM TSF=3D0x%llx BCN=3D0x%llx diff=3D%lld @%lu\n",
+ mgmt->sa, mgmt->bssid,
+ (unsigned long long)rx_timestamp,
+ (unsigned long long)beacon_timestamp,
+ (unsigned long long)(rx_timestamp - beacon_timestamp),
+ jiffies);+#endif
+
+ if (beacon_timestamp > rx_timestamp) {
#ifdef CONFIG_MAC80211_IBSS_DEBUG
- printk(KERN_DEBUG "%s: beacon TSF higher than "
- "local TSF - IBSS merge with BSSID %pM\n",
- sdata->dev->name, mgmt->bssid);
+ printk(KERN_DEBUG "%s: beacon TSF higher than "
+ "local TSF - IBSS merge with BSSID %pM\n",
+ sdata->dev->name, mgmt->bssid);
#endif
- ieee80211_sta_join_ibss(sdata, &sdata->u.sta, bss);
- ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, supp_rates);
- }
+ ieee80211_sta_join_ibss(sdata, &sdata->u.sta, bss);
+ ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, supp_rates);
}
=20
+ put_bss:
ieee80211_rx_bss_put(local, bss);
}
=20
@@ -1948,8 +1964,7 @@ static void ieee80211_rx_mgmt_probe_req(
struct ieee80211_mgmt *resp;
u8 *pos, *end;
=20
- if (sdata->vif.type !=3D NL80211_IFTYPE_ADHOC ||
- ifsta->state !=3D IEEE80211_STA_MLME_IBSS_JOINED || + if (ifsta->state !=3D IEEE80211_STA_MLME_IBSS_JOINED ||
len < 24 + 2 || !ifsta->probe_resp)
return;
=20
@@ -2053,31 +2068,54 @@ static void ieee80211_sta_rx_queued_mgmt
mgmt =3D (struct ieee80211_mgmt *) skb->data; fc =3D le16_to_cpu(mgmt->frame_control);
=20
- switch (fc & IEEE80211_FCTL_STYPE) {
- case IEEE80211_STYPE_PROBE_REQ:
- ieee80211_rx_mgmt_probe_req(sdata, ifsta, mgmt, skb->len);
- break;
- case IEEE80211_STYPE_PROBE_RESP:
- ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len, rx_status);
- break;
- case IEEE80211_STYPE_BEACON:
- ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, rx_status);
- break;
- case IEEE80211_STYPE_AUTH:
- ieee80211_rx_mgmt_auth(sdata, ifsta, mgmt, skb->len);
- break;
- case IEEE80211_STYPE_ASSOC_RESP:
- ieee80211_rx_mgmt_assoc_resp(sdata, ifsta, mgmt, skb->len, 0);
- break;
- case IEEE80211_STYPE_REASSOC_RESP:
- ieee80211_rx_mgmt_assoc_resp(sdata, ifsta, mgmt, skb->len, 1);
- break;
- case IEEE80211_STYPE_DEAUTH:
- ieee80211_rx_mgmt_deauth(sdata, ifsta, mgmt, skb->len);
- break;
- case IEEE80211_STYPE_DISASSOC:
- ieee80211_rx_mgmt_disassoc(sdata, ifsta, mgmt, skb->len);
- break;
+ if (sdata->vif.type =3D=3D NL80211_IFTYPE_ADHOC) {
+ switch (fc & IEEE80211_FCTL_STYPE) {
+ case IEEE80211_STYPE_PROBE_REQ:
+ ieee80211_rx_mgmt_probe_req(sdata, ifsta, mgmt,
+ skb->len);
+ break;
+ case IEEE80211_STYPE_PROBE_RESP:
+ ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len,
+ rx_status);
+ break;
+ case IEEE80211_STYPE_BEACON:
+ ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len,
+ rx_status);
+ break;
+ case IEEE80211_STYPE_AUTH:
+ ieee80211_rx_mgmt_auth_ibss(sdata, ifsta, mgmt,
+ skb->len);
+ break;
+ }
+ } else { /* NL80211_IFTYPE_STATION */
+ switch (fc & IEEE80211_FCTL_STYPE) {
+ case IEEE80211_STYPE_PROBE_RESP:
+ ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len,
+ rx_status);
+ break;
+ case IEEE80211_STYPE_BEACON:
+ ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len,
+ rx_status);
+ break;
+ case IEEE80211_STYPE_AUTH:
+ ieee80211_rx_mgmt_auth(sdata, ifsta, mgmt, skb->len);
+ break;
+ case IEEE80211_STYPE_ASSOC_RESP:
+ ieee80211_rx_mgmt_assoc_resp(sdata, ifsta, mgmt,
+ skb->len, 0);
+ break;
+ case IEEE80211_STYPE_REASSOC_RESP:
+ ieee80211_rx_mgmt_assoc_resp(sdata, ifsta, mgmt,
+ skb->len, 1);
+ break;
+ case IEEE80211_STYPE_DEAUTH:
+ ieee80211_rx_mgmt_deauth(sdata, ifsta, mgmt, skb->len);
+ break;
+ case IEEE80211_STYPE_DISASSOC:
+ ieee80211_rx_mgmt_disassoc(sdata, ifsta, mgmt,
+ skb->len);
+ break;
+ }
}
=20
kfree_skb(skb);
--=20