blob: 54ce1af491ebd9651cb6a24891639081a892d7c2 [file] [log] [blame]
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +01001/*
Rui Paulo264d9b72009-11-09 23:46:58 +00002 * Copyright (c) 2008, 2009 open80211s Ltd.
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +01003 * Author: Luis Carlos Cobo <luisca@cozybit.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
Tejun Heo5a0e3ad2010-03-24 17:04:11 +09009#include <linux/gfp.h>
Johannes Berg902acc72008-02-23 15:17:19 +010010#include <linux/kernel.h>
11#include <linux/random.h>
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010012#include "ieee80211_i.h"
Johannes Berg2c8dccc2008-04-08 15:14:40 -040013#include "rate.h"
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010014#include "mesh.h"
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010015
Thomas Pedersen8db09852011-08-12 20:01:00 -070016#define PLINK_GET_LLID(p) (p + 2)
17#define PLINK_GET_PLID(p) (p + 4)
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010018
19#define mod_plink_timer(s, t) (mod_timer(&s->plink_timer, \
20 jiffies + HZ * t / 1000))
21
Johannes Berg472dbc42008-09-11 00:01:49 +020022#define dot11MeshMaxRetries(s) (s->u.mesh.mshcfg.dot11MeshMaxRetries)
23#define dot11MeshRetryTimeout(s) (s->u.mesh.mshcfg.dot11MeshRetryTimeout)
24#define dot11MeshConfirmTimeout(s) (s->u.mesh.mshcfg.dot11MeshConfirmTimeout)
25#define dot11MeshHoldingTimeout(s) (s->u.mesh.mshcfg.dot11MeshHoldingTimeout)
26#define dot11MeshMaxPeerLinks(s) (s->u.mesh.mshcfg.dot11MeshMaxPeerLinks)
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010027
Ashok Nagarajan3d4f9692012-03-06 12:48:30 -080028/* We only need a valid sta if user configured a minimum rssi_threshold. */
29#define rssi_threshold_check(sta, sdata) \
Ashok Nagarajan55335132012-02-28 17:04:08 -080030 (sdata->u.mesh.mshcfg.rssi_threshold == 0 ||\
Ashok Nagarajan3d4f9692012-03-06 12:48:30 -080031 (sta && (s8) -ewma_read(&sta->avg_signal) > \
32 sdata->u.mesh.mshcfg.rssi_threshold))
Ashok Nagarajan55335132012-02-28 17:04:08 -080033
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010034enum plink_event {
35 PLINK_UNDEFINED,
36 OPN_ACPT,
37 OPN_RJCT,
38 OPN_IGNR,
39 CNF_ACPT,
40 CNF_RJCT,
41 CNF_IGNR,
42 CLS_ACPT,
43 CLS_IGNR
44};
45
Thomas Pedersenba4a14e2011-09-20 13:43:32 -070046static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
47 enum ieee80211_self_protected_actioncode action,
48 u8 *da, __le16 llid, __le16 plid, __le16 reason);
49
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010050static inline
51void mesh_plink_inc_estab_count(struct ieee80211_sub_if_data *sdata)
52{
Johannes Berg472dbc42008-09-11 00:01:49 +020053 atomic_inc(&sdata->u.mesh.mshstats.estab_plinks);
Johannes Bergd0709a62008-02-25 16:27:46 +010054 mesh_accept_plinks_update(sdata);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010055}
56
57static inline
58void mesh_plink_dec_estab_count(struct ieee80211_sub_if_data *sdata)
59{
Johannes Berg472dbc42008-09-11 00:01:49 +020060 atomic_dec(&sdata->u.mesh.mshstats.estab_plinks);
Johannes Bergd0709a62008-02-25 16:27:46 +010061 mesh_accept_plinks_update(sdata);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010062}
63
64/**
65 * mesh_plink_fsm_restart - restart a mesh peer link finite state machine
66 *
Rui Paulo23c7a292009-11-09 23:46:42 +000067 * @sta: mesh peer link to restart
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010068 *
Johannes Berg07346f812008-05-03 01:02:02 +020069 * Locking: this function must be called holding sta->lock
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010070 */
71static inline void mesh_plink_fsm_restart(struct sta_info *sta)
72{
Javier Cardona57cf8042011-05-13 10:45:43 -070073 sta->plink_state = NL80211_PLINK_LISTEN;
Luis Carlos Cobo37659ff2008-02-29 12:13:38 -080074 sta->llid = sta->plid = sta->reason = 0;
75 sta->plink_retries = 0;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010076}
77
Johannes Berg93e5deb2008-04-01 15:21:00 +020078/*
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -070079 * Allocate mesh sta entry and insert into station table
Johannes Berg93e5deb2008-04-01 15:21:00 +020080 */
Johannes Berg03e44972008-02-27 09:56:40 +010081static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata,
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -070082 u8 *hw_addr)
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010083{
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010084 struct sta_info *sta;
85
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -070086 if (sdata->local->num_sta >= MESH_MAX_PLINKS)
Johannes Berg73651ee2008-02-25 16:27:47 +010087 return NULL;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010088
Johannes Berg34e89502010-02-03 13:59:58 +010089 sta = sta_info_alloc(sdata, hw_addr, GFP_KERNEL);
Johannes Berg73651ee2008-02-25 16:27:47 +010090 if (!sta)
91 return NULL;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010092
Johannes Berg83d5cc02012-01-12 09:31:10 +010093 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
94 sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
95 sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
Johannes Bergd9a7ddb2011-12-14 12:35:30 +010096
Johannes Bergc2c98fd2011-09-29 16:04:36 +020097 set_sta_flag(sta, WLAN_STA_WME);
Johannes Bergd9a7ddb2011-12-14 12:35:30 +010098
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +010099 return sta;
100}
101
Ben Hutchings2c530402012-07-10 10:55:09 +0000102/**
Ashok Nagarajancbf93222012-05-07 21:00:31 -0700103 * mesh_set_ht_prot_mode - set correct HT protection mode
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700104 *
Ashok Nagarajancbf93222012-05-07 21:00:31 -0700105 * Section 9.23.3.5 of IEEE 80211-2012 describes the protection rules for HT
106 * mesh STA in a MBSS. Three HT protection modes are supported for now, non-HT
107 * mixed mode, 20MHz-protection and no-protection mode. non-HT mixed mode is
108 * selected if any non-HT peers are present in our MBSS. 20MHz-protection mode
109 * is selected if all peers in our 20/40MHz MBSS support HT and atleast one
110 * HT20 peer is present. Otherwise no-protection mode is selected.
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700111 */
112static u32 mesh_set_ht_prot_mode(struct ieee80211_sub_if_data *sdata)
113{
114 struct ieee80211_local *local = sdata->local;
115 struct sta_info *sta;
116 u32 changed = 0;
117 u16 ht_opmode;
118 bool non_ht_sta = false, ht20_sta = false;
119
Johannes Berg466f3102012-07-25 13:51:49 +0200120 if (sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT)
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700121 return 0;
122
123 rcu_read_lock();
124 list_for_each_entry_rcu(sta, &local->sta_list, list) {
Ashok Nagarajancbf93222012-05-07 21:00:31 -0700125 if (sdata != sta->sdata ||
126 sta->plink_state != NL80211_PLINK_ESTAB)
127 continue;
128
129 switch (sta->ch_type) {
130 case NL80211_CHAN_NO_HT:
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200131 mpl_dbg(sdata,
132 "mesh_plink %pM: nonHT sta (%pM) is present\n",
Ashok Nagarajancbf93222012-05-07 21:00:31 -0700133 sdata->vif.addr, sta->sta.addr);
134 non_ht_sta = true;
135 goto out;
136 case NL80211_CHAN_HT20:
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200137 mpl_dbg(sdata,
138 "mesh_plink %pM: HT20 sta (%pM) is present\n",
Ashok Nagarajancbf93222012-05-07 21:00:31 -0700139 sdata->vif.addr, sta->sta.addr);
140 ht20_sta = true;
141 default:
142 break;
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700143 }
144 }
145out:
146 rcu_read_unlock();
147
148 if (non_ht_sta)
149 ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
Johannes Berg466f3102012-07-25 13:51:49 +0200150 else if (ht20_sta &&
151 sdata->vif.bss_conf.channel_type > NL80211_CHAN_HT20)
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700152 ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
153 else
154 ht_opmode = IEEE80211_HT_OP_MODE_PROTECTION_NONE;
155
156 if (sdata->vif.bss_conf.ht_operation_mode != ht_opmode) {
157 sdata->vif.bss_conf.ht_operation_mode = ht_opmode;
Ashok Nagarajan70c33ea2012-04-30 14:20:32 -0700158 sdata->u.mesh.mshcfg.ht_opmode = ht_opmode;
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700159 changed = BSS_CHANGED_HT;
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200160 mpl_dbg(sdata,
161 "mesh_plink %pM: protection mode changed to %d\n",
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700162 sdata->vif.addr, ht_opmode);
163 }
164
165 return changed;
166}
167
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100168/**
John W. Linvillec9370192010-06-21 17:14:07 -0400169 * __mesh_plink_deactivate - deactivate mesh peer link
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100170 *
171 * @sta: mesh peer link to deactivate
172 *
173 * All mesh paths with this peer as next hop will be flushed
174 *
Johannes Berg07346f812008-05-03 01:02:02 +0200175 * Locking: the caller must hold sta->lock
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100176 */
John W. Linvillec9370192010-06-21 17:14:07 -0400177static bool __mesh_plink_deactivate(struct sta_info *sta)
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100178{
Johannes Bergd0709a62008-02-25 16:27:46 +0100179 struct ieee80211_sub_if_data *sdata = sta->sdata;
John W. Linvillec9370192010-06-21 17:14:07 -0400180 bool deactivated = false;
Johannes Bergd0709a62008-02-25 16:27:46 +0100181
Javier Cardona57cf8042011-05-13 10:45:43 -0700182 if (sta->plink_state == NL80211_PLINK_ESTAB) {
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100183 mesh_plink_dec_estab_count(sdata);
John W. Linvillec9370192010-06-21 17:14:07 -0400184 deactivated = true;
185 }
Javier Cardona57cf8042011-05-13 10:45:43 -0700186 sta->plink_state = NL80211_PLINK_BLOCKED;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100187 mesh_path_flush_by_nexthop(sta);
John W. Linvillec9370192010-06-21 17:14:07 -0400188
189 return deactivated;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100190}
191
Johannes Berg902acc72008-02-23 15:17:19 +0100192/**
John W. Linvillec9370192010-06-21 17:14:07 -0400193 * mesh_plink_deactivate - deactivate mesh peer link
Johannes Berg902acc72008-02-23 15:17:19 +0100194 *
195 * @sta: mesh peer link to deactivate
196 *
197 * All mesh paths with this peer as next hop will be flushed
198 */
199void mesh_plink_deactivate(struct sta_info *sta)
200{
John W. Linvillec9370192010-06-21 17:14:07 -0400201 struct ieee80211_sub_if_data *sdata = sta->sdata;
202 bool deactivated;
203
Johannes Berg07346f812008-05-03 01:02:02 +0200204 spin_lock_bh(&sta->lock);
John W. Linvillec9370192010-06-21 17:14:07 -0400205 deactivated = __mesh_plink_deactivate(sta);
Thomas Pedersenba4a14e2011-09-20 13:43:32 -0700206 sta->reason = cpu_to_le16(WLAN_REASON_MESH_PEER_CANCELED);
207 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
208 sta->sta.addr, sta->llid, sta->plid,
209 sta->reason);
Johannes Berg07346f812008-05-03 01:02:02 +0200210 spin_unlock_bh(&sta->lock);
John W. Linvillec9370192010-06-21 17:14:07 -0400211
212 if (deactivated)
213 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON);
Johannes Berg902acc72008-02-23 15:17:19 +0100214}
215
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200216static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700217 enum ieee80211_self_protected_actioncode action,
218 u8 *da, __le16 llid, __le16 plid, __le16 reason) {
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200219 struct ieee80211_local *local = sdata->local;
Thomas Pedersen3b69a9c2011-10-26 14:47:25 -0700220 struct sk_buff *skb;
Thomas Pedersene7570df2012-08-03 12:21:34 -0700221 struct ieee80211_tx_info *info;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100222 struct ieee80211_mgmt *mgmt;
223 bool include_plid = false;
Thomas Pedersen8db09852011-08-12 20:01:00 -0700224 u16 peering_proto = 0;
Thomas Pedersen3b69a9c2011-10-26 14:47:25 -0700225 u8 *pos, ie_len = 4;
226 int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.self_prot) +
227 sizeof(mgmt->u.action.u.self_prot);
Thomas Pedersenf609a432012-08-03 12:21:35 -0700228 int err = -ENOMEM;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100229
Javier Cardona65e8b0c2012-01-17 18:17:46 -0800230 skb = dev_alloc_skb(local->tx_headroom +
Thomas Pedersen3b69a9c2011-10-26 14:47:25 -0700231 hdr_len +
232 2 + /* capability info */
233 2 + /* AID */
234 2 + 8 + /* supported rates */
235 2 + (IEEE80211_MAX_SUPP_RATES - 8) +
236 2 + sdata->u.mesh.mesh_id_len +
237 2 + sizeof(struct ieee80211_meshconf_ie) +
Thomas Pedersen176f3602011-10-26 14:47:27 -0700238 2 + sizeof(struct ieee80211_ht_cap) +
Johannes Berg074d46d2012-03-15 19:45:16 +0100239 2 + sizeof(struct ieee80211_ht_operation) +
Thomas Pedersen3b69a9c2011-10-26 14:47:25 -0700240 2 + 8 + /* peering IE */
241 sdata->u.mesh.ie_len);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100242 if (!skb)
243 return -1;
Thomas Pedersene7570df2012-08-03 12:21:34 -0700244 info = IEEE80211_SKB_CB(skb);
Javier Cardona65e8b0c2012-01-17 18:17:46 -0800245 skb_reserve(skb, local->tx_headroom);
Thomas Pedersen3b69a9c2011-10-26 14:47:25 -0700246 mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
247 memset(mgmt, 0, hdr_len);
Harvey Harrisone7827a72008-07-15 18:44:13 -0700248 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
249 IEEE80211_STYPE_ACTION);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100250 memcpy(mgmt->da, da, ETH_ALEN);
Johannes Berg47846c92009-11-25 17:46:19 +0100251 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
Javier Cardona915b5c52011-05-03 16:57:10 -0700252 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
Thomas Pedersen8db09852011-08-12 20:01:00 -0700253 mgmt->u.action.category = WLAN_CATEGORY_SELF_PROTECTED;
254 mgmt->u.action.u.self_prot.action_code = action;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100255
Thomas Pedersen8db09852011-08-12 20:01:00 -0700256 if (action != WLAN_SP_MESH_PEERING_CLOSE) {
257 /* capability info */
258 pos = skb_put(skb, 2);
259 memset(pos, 0, 2);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700260 if (action == WLAN_SP_MESH_PEERING_CONFIRM) {
Thomas Pedersen8db09852011-08-12 20:01:00 -0700261 /* AID */
262 pos = skb_put(skb, 2);
Rui Paulo77fa76b2009-11-09 23:46:52 +0000263 memcpy(pos + 2, &plid, 2);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100264 }
Johannes Berg6b778632012-07-23 14:53:27 +0200265 if (ieee80211_add_srates_ie(sdata, skb, true,
266 local->oper_channel->band) ||
267 ieee80211_add_ext_srates_ie(sdata, skb, true,
268 local->oper_channel->band) ||
Thomas Pedersen082ebb02011-08-11 19:35:10 -0700269 mesh_add_rsn_ie(skb, sdata) ||
270 mesh_add_meshid_ie(skb, sdata) ||
271 mesh_add_meshconf_ie(skb, sdata))
Thomas Pedersenf609a432012-08-03 12:21:35 -0700272 goto free;
Thomas Pedersen8db09852011-08-12 20:01:00 -0700273 } else { /* WLAN_SP_MESH_PEERING_CLOSE */
Thomas Pedersene7570df2012-08-03 12:21:34 -0700274 info->flags |= IEEE80211_TX_CTL_NO_ACK;
Thomas Pedersen8db09852011-08-12 20:01:00 -0700275 if (mesh_add_meshid_ie(skb, sdata))
Thomas Pedersenf609a432012-08-03 12:21:35 -0700276 goto free;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100277 }
278
Thomas Pedersen8db09852011-08-12 20:01:00 -0700279 /* Add Mesh Peering Management element */
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100280 switch (action) {
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700281 case WLAN_SP_MESH_PEERING_OPEN:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100282 break;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700283 case WLAN_SP_MESH_PEERING_CONFIRM:
Thomas Pedersen8db09852011-08-12 20:01:00 -0700284 ie_len += 2;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100285 include_plid = true;
286 break;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700287 case WLAN_SP_MESH_PEERING_CLOSE:
Thomas Pedersen8db09852011-08-12 20:01:00 -0700288 if (plid) {
289 ie_len += 2;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100290 include_plid = true;
291 }
Thomas Pedersen8db09852011-08-12 20:01:00 -0700292 ie_len += 2; /* reason code */
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100293 break;
Thomas Pedersen8db09852011-08-12 20:01:00 -0700294 default:
Thomas Pedersenf609a432012-08-03 12:21:35 -0700295 err = -EINVAL;
296 goto free;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100297 }
298
Thomas Pedersen8db09852011-08-12 20:01:00 -0700299 if (WARN_ON(skb_tailroom(skb) < 2 + ie_len))
Thomas Pedersenf609a432012-08-03 12:21:35 -0700300 goto free;
Thomas Pedersen8db09852011-08-12 20:01:00 -0700301
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100302 pos = skb_put(skb, 2 + ie_len);
Thomas Pedersen8db09852011-08-12 20:01:00 -0700303 *pos++ = WLAN_EID_PEER_MGMT;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100304 *pos++ = ie_len;
Thomas Pedersen8db09852011-08-12 20:01:00 -0700305 memcpy(pos, &peering_proto, 2);
306 pos += 2;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100307 memcpy(pos, &llid, 2);
Thomas Pedersen8db09852011-08-12 20:01:00 -0700308 pos += 2;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100309 if (include_plid) {
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100310 memcpy(pos, &plid, 2);
Thomas Pedersen8db09852011-08-12 20:01:00 -0700311 pos += 2;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100312 }
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700313 if (action == WLAN_SP_MESH_PEERING_CLOSE) {
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100314 memcpy(pos, &reason, 2);
Thomas Pedersen8db09852011-08-12 20:01:00 -0700315 pos += 2;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100316 }
Thomas Pedersen176f3602011-10-26 14:47:27 -0700317
318 if (action != WLAN_SP_MESH_PEERING_CLOSE) {
319 if (mesh_add_ht_cap_ie(skb, sdata) ||
Johannes Berg074d46d2012-03-15 19:45:16 +0100320 mesh_add_ht_oper_ie(skb, sdata))
Thomas Pedersenf609a432012-08-03 12:21:35 -0700321 goto free;
Thomas Pedersen176f3602011-10-26 14:47:27 -0700322 }
323
Thomas Pedersen8db09852011-08-12 20:01:00 -0700324 if (mesh_add_vendor_ies(skb, sdata))
Thomas Pedersenf609a432012-08-03 12:21:35 -0700325 goto free;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100326
Johannes Berg62ae67b2009-11-18 18:42:05 +0100327 ieee80211_tx_skb(sdata, skb);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100328 return 0;
Thomas Pedersenf609a432012-08-03 12:21:35 -0700329free:
330 kfree_skb(skb);
331 return err;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100332}
333
Ben Hutchings2c530402012-07-10 10:55:09 +0000334/**
335 * mesh_peer_init - initialize new mesh peer and return resulting sta_info
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700336 *
337 * @sdata: local meshif
338 * @addr: peer's address
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700339 * @elems: IEs from beacon or mesh peering frame
340 *
341 * call under RCU
342 */
343static struct sta_info *mesh_peer_init(struct ieee80211_sub_if_data *sdata,
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700344 u8 *addr,
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700345 struct ieee802_11_elems *elems)
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100346{
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200347 struct ieee80211_local *local = sdata->local;
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700348 enum ieee80211_band band = local->oper_channel->band;
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700349 struct ieee80211_supported_band *sband;
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700350 u32 rates, basic_rates = 0;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100351 struct sta_info *sta;
Thomas Pedersene87278e2012-04-26 15:01:06 -0700352 bool insert = false;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100353
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700354 sband = local->hw.wiphy->bands[band];
355 rates = ieee80211_sta_get_rates(local, elems, band, &basic_rates);
Johannes Bergd0709a62008-02-25 16:27:46 +0100356
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700357 sta = sta_info_get(sdata, addr);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100358 if (!sta) {
Thomas Pedersenf5c56812012-05-03 15:06:09 -0700359 /* Userspace handles peer allocation when security is enabled */
360 if (sdata->u.mesh.security & IEEE80211_MESH_SEC_AUTHED) {
361 cfg80211_notify_new_peer_candidate(sdata->dev, addr,
362 elems->ie_start,
363 elems->total_len,
364 GFP_ATOMIC);
365 return NULL;
366 }
367
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700368 sta = mesh_plink_alloc(sdata, addr);
Johannes Berg34e89502010-02-03 13:59:58 +0100369 if (!sta)
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700370 return NULL;
Thomas Pedersene87278e2012-04-26 15:01:06 -0700371 insert = true;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100372 }
373
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700374 spin_lock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100375 sta->last_rx = jiffies;
Chun-Yeow Yeohbae35d92012-07-24 11:52:35 +0800376 if (sta->plink_state == NL80211_PLINK_ESTAB) {
377 spin_unlock_bh(&sta->lock);
378 return sta;
379 }
380
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700381 sta->sta.supp_rates[band] = rates;
Thomas Pedersene76781e2012-04-18 19:24:13 -0700382 if (elems->ht_cap_elem &&
Johannes Berg466f3102012-07-25 13:51:49 +0200383 sdata->vif.bss_conf.channel_type != NL80211_CHAN_NO_HT)
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700384 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
385 elems->ht_cap_elem,
386 &sta->sta.ht_cap);
387 else
388 memset(&sta->sta.ht_cap, 0, sizeof(sta->sta.ht_cap));
389
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700390 if (elems->ht_operation) {
Thomas Pedersenc7d25822012-04-26 15:01:07 -0700391 if (!(elems->ht_operation->ht_param &
392 IEEE80211_HT_PARAM_CHAN_WIDTH_ANY))
393 sta->sta.ht_cap.cap &=
394 ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700395 sta->ch_type =
396 ieee80211_ht_oper_to_channel_type(elems->ht_operation);
397 }
Thomas Pedersenc7d25822012-04-26 15:01:07 -0700398
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700399 rate_control_rate_init(sta);
400 spin_unlock_bh(&sta->lock);
401
Thomas Pedersene87278e2012-04-26 15:01:06 -0700402 if (insert && sta_info_insert(sta))
403 return NULL;
404
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700405 return sta;
406}
407
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700408void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata,
409 u8 *hw_addr,
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700410 struct ieee802_11_elems *elems)
411{
412 struct sta_info *sta;
413
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700414 rcu_read_lock();
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700415 sta = mesh_peer_init(sdata, hw_addr, elems);
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700416 if (!sta)
417 goto out;
418
Javier Cardona1570ca52011-04-07 15:08:35 -0700419 if (mesh_peer_accepts_plinks(elems) &&
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700420 sta->plink_state == NL80211_PLINK_LISTEN &&
421 sdata->u.mesh.accepting_plinks &&
422 sdata->u.mesh.mshcfg.auto_open_plinks &&
423 rssi_threshold_check(sta, sdata))
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100424 mesh_plink_open(sta);
425
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700426out:
Johannes Bergd0709a62008-02-25 16:27:46 +0100427 rcu_read_unlock();
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100428}
429
430static void mesh_plink_timer(unsigned long data)
431{
432 struct sta_info *sta;
433 __le16 llid, plid, reason;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100434 struct ieee80211_sub_if_data *sdata;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100435
Johannes Bergd0709a62008-02-25 16:27:46 +0100436 /*
437 * This STA is valid because sta_info_destroy() will
438 * del_timer_sync() this timer after having made sure
439 * it cannot be readded (by deleting the plink.)
440 */
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100441 sta = (struct sta_info *) data;
442
Johannes Berg5bb644a2009-05-17 11:40:42 +0200443 if (sta->sdata->local->quiescing) {
444 sta->plink_timer_was_running = true;
445 return;
446 }
447
Johannes Berg07346f812008-05-03 01:02:02 +0200448 spin_lock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100449 if (sta->ignore_plink_timer) {
450 sta->ignore_plink_timer = false;
Johannes Berg07346f812008-05-03 01:02:02 +0200451 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100452 return;
453 }
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200454 mpl_dbg(sta->sdata,
455 "Mesh plink timer for %pM fired on state %d\n",
Johannes Berg0c68ae262008-10-27 15:56:10 -0700456 sta->sta.addr, sta->plink_state);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100457 reason = 0;
458 llid = sta->llid;
459 plid = sta->plid;
Johannes Bergd0709a62008-02-25 16:27:46 +0100460 sdata = sta->sdata;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100461
462 switch (sta->plink_state) {
Javier Cardona57cf8042011-05-13 10:45:43 -0700463 case NL80211_PLINK_OPN_RCVD:
464 case NL80211_PLINK_OPN_SNT:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100465 /* retry timer */
466 if (sta->plink_retries < dot11MeshMaxRetries(sdata)) {
467 u32 rand;
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200468 mpl_dbg(sta->sdata,
469 "Mesh plink for %pM (retry, timeout): %d %d\n",
Johannes Berg0c68ae262008-10-27 15:56:10 -0700470 sta->sta.addr, sta->plink_retries,
471 sta->plink_timeout);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100472 get_random_bytes(&rand, sizeof(u32));
473 sta->plink_timeout = sta->plink_timeout +
474 rand % sta->plink_timeout;
475 ++sta->plink_retries;
Johannes Bergd0709a62008-02-25 16:27:46 +0100476 mod_plink_timer(sta, sta->plink_timeout);
Johannes Berg07346f812008-05-03 01:02:02 +0200477 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700478 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_OPEN,
479 sta->sta.addr, llid, 0, 0);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100480 break;
481 }
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700482 reason = cpu_to_le16(WLAN_REASON_MESH_MAX_RETRIES);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100483 /* fall through on else */
Javier Cardona57cf8042011-05-13 10:45:43 -0700484 case NL80211_PLINK_CNF_RCVD:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100485 /* confirm timer */
486 if (!reason)
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700487 reason = cpu_to_le16(WLAN_REASON_MESH_CONFIRM_TIMEOUT);
Javier Cardona57cf8042011-05-13 10:45:43 -0700488 sta->plink_state = NL80211_PLINK_HOLDING;
Johannes Bergd0709a62008-02-25 16:27:46 +0100489 mod_plink_timer(sta, dot11MeshHoldingTimeout(sdata));
Johannes Berg07346f812008-05-03 01:02:02 +0200490 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700491 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
492 sta->sta.addr, llid, plid, reason);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100493 break;
Javier Cardona57cf8042011-05-13 10:45:43 -0700494 case NL80211_PLINK_HOLDING:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100495 /* holding timer */
Johannes Bergd0709a62008-02-25 16:27:46 +0100496 del_timer(&sta->plink_timer);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100497 mesh_plink_fsm_restart(sta);
Johannes Berg07346f812008-05-03 01:02:02 +0200498 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100499 break;
500 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200501 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100502 break;
503 }
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100504}
505
Johannes Berg5bb644a2009-05-17 11:40:42 +0200506#ifdef CONFIG_PM
507void mesh_plink_quiesce(struct sta_info *sta)
508{
509 if (del_timer_sync(&sta->plink_timer))
510 sta->plink_timer_was_running = true;
511}
512
513void mesh_plink_restart(struct sta_info *sta)
514{
515 if (sta->plink_timer_was_running) {
516 add_timer(&sta->plink_timer);
517 sta->plink_timer_was_running = false;
518 }
519}
520#endif
521
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100522static inline void mesh_plink_timer_set(struct sta_info *sta, int timeout)
523{
524 sta->plink_timer.expires = jiffies + (HZ * timeout / 1000);
525 sta->plink_timer.data = (unsigned long) sta;
526 sta->plink_timer.function = mesh_plink_timer;
527 sta->plink_timeout = timeout;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100528 add_timer(&sta->plink_timer);
529}
530
531int mesh_plink_open(struct sta_info *sta)
532{
533 __le16 llid;
Johannes Bergd0709a62008-02-25 16:27:46 +0100534 struct ieee80211_sub_if_data *sdata = sta->sdata;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100535
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200536 if (!test_sta_flag(sta, WLAN_STA_AUTH))
Javier Cardona53e80512011-04-07 15:08:32 -0700537 return -EPERM;
538
Johannes Berg07346f812008-05-03 01:02:02 +0200539 spin_lock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100540 get_random_bytes(&llid, 2);
541 sta->llid = llid;
Javier Cardona57cf8042011-05-13 10:45:43 -0700542 if (sta->plink_state != NL80211_PLINK_LISTEN) {
Johannes Berg07346f812008-05-03 01:02:02 +0200543 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100544 return -EBUSY;
545 }
Javier Cardona57cf8042011-05-13 10:45:43 -0700546 sta->plink_state = NL80211_PLINK_OPN_SNT;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100547 mesh_plink_timer_set(sta, dot11MeshRetryTimeout(sdata));
Johannes Berg07346f812008-05-03 01:02:02 +0200548 spin_unlock_bh(&sta->lock);
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200549 mpl_dbg(sdata,
550 "Mesh plink: starting establishment with %pM\n",
Johannes Berg0c68ae262008-10-27 15:56:10 -0700551 sta->sta.addr);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100552
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700553 return mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_OPEN,
Johannes Berg17741cd2008-09-11 00:02:02 +0200554 sta->sta.addr, llid, 0, 0);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100555}
556
557void mesh_plink_block(struct sta_info *sta)
558{
John W. Linvillec9370192010-06-21 17:14:07 -0400559 struct ieee80211_sub_if_data *sdata = sta->sdata;
560 bool deactivated;
561
Johannes Berg07346f812008-05-03 01:02:02 +0200562 spin_lock_bh(&sta->lock);
John W. Linvillec9370192010-06-21 17:14:07 -0400563 deactivated = __mesh_plink_deactivate(sta);
Javier Cardona57cf8042011-05-13 10:45:43 -0700564 sta->plink_state = NL80211_PLINK_BLOCKED;
Johannes Berg07346f812008-05-03 01:02:02 +0200565 spin_unlock_bh(&sta->lock);
John W. Linvillec9370192010-06-21 17:14:07 -0400566
567 if (deactivated)
568 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100569}
570
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100571
Jasper Bryant-Greenef698d852008-08-03 12:04:37 +1200572void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_mgmt *mgmt,
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100573 size_t len, struct ieee80211_rx_status *rx_status)
574{
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100575 struct ieee802_11_elems elems;
576 struct sta_info *sta;
577 enum plink_event event;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700578 enum ieee80211_self_protected_actioncode ftype;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100579 size_t baselen;
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700580 bool matches_local = true;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100581 u8 ie_len;
582 u8 *baseaddr;
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700583 u32 changed = 0;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100584 __le16 plid, llid, reason;
Rui Paulo1460dd12009-11-09 23:46:48 +0000585 static const char *mplstates[] = {
Javier Cardona57cf8042011-05-13 10:45:43 -0700586 [NL80211_PLINK_LISTEN] = "LISTEN",
587 [NL80211_PLINK_OPN_SNT] = "OPN-SNT",
588 [NL80211_PLINK_OPN_RCVD] = "OPN-RCVD",
589 [NL80211_PLINK_CNF_RCVD] = "CNF_RCVD",
590 [NL80211_PLINK_ESTAB] = "ESTAB",
591 [NL80211_PLINK_HOLDING] = "HOLDING",
592 [NL80211_PLINK_BLOCKED] = "BLOCKED"
Rui Paulo1460dd12009-11-09 23:46:48 +0000593 };
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100594
Johannes Berg9c80d3d2008-09-08 15:41:59 +0200595 /* need action_code, aux */
596 if (len < IEEE80211_MIN_ACTION_SIZE + 3)
597 return;
598
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100599 if (is_multicast_ether_addr(mgmt->da)) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200600 mpl_dbg(sdata,
601 "Mesh plink: ignore frame from multicast address\n");
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100602 return;
603 }
604
Thomas Pedersen8db09852011-08-12 20:01:00 -0700605 baseaddr = mgmt->u.action.u.self_prot.variable;
606 baselen = (u8 *) mgmt->u.action.u.self_prot.variable - (u8 *) mgmt;
607 if (mgmt->u.action.u.self_prot.action_code ==
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700608 WLAN_SP_MESH_PEERING_CONFIRM) {
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100609 baseaddr += 4;
David Woo70bdb6b2009-08-12 11:03:44 -0700610 baselen += 4;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100611 }
612 ieee802_11_parse_elems(baseaddr, len - baselen, &elems);
Thomas Pedersen8db09852011-08-12 20:01:00 -0700613 if (!elems.peering) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200614 mpl_dbg(sdata,
615 "Mesh plink: missing necessary peer link ie\n");
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100616 return;
617 }
Javier Cardonab130e5c2011-05-03 16:57:07 -0700618 if (elems.rsn_len &&
619 sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200620 mpl_dbg(sdata,
621 "Mesh plink: can't establish link with secure peer\n");
Javier Cardona5cff5e02011-04-07 15:08:29 -0700622 return;
623 }
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100624
Thomas Pedersen8db09852011-08-12 20:01:00 -0700625 ftype = mgmt->u.action.u.self_prot.action_code;
626 ie_len = elems.peering_len;
627 if ((ftype == WLAN_SP_MESH_PEERING_OPEN && ie_len != 4) ||
628 (ftype == WLAN_SP_MESH_PEERING_CONFIRM && ie_len != 6) ||
629 (ftype == WLAN_SP_MESH_PEERING_CLOSE && ie_len != 6
630 && ie_len != 8)) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200631 mpl_dbg(sdata,
632 "Mesh plink: incorrect plink ie length %d %d\n",
633 ftype, ie_len);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100634 return;
635 }
636
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700637 if (ftype != WLAN_SP_MESH_PEERING_CLOSE &&
638 (!elems.mesh_id || !elems.mesh_config)) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200639 mpl_dbg(sdata, "Mesh plink: missing necessary ie\n");
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100640 return;
641 }
642 /* Note the lines below are correct, the llid in the frame is the plid
643 * from the point of view of this host.
644 */
Thomas Pedersen8db09852011-08-12 20:01:00 -0700645 memcpy(&plid, PLINK_GET_LLID(elems.peering), 2);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700646 if (ftype == WLAN_SP_MESH_PEERING_CONFIRM ||
Thomas Pedersen8db09852011-08-12 20:01:00 -0700647 (ftype == WLAN_SP_MESH_PEERING_CLOSE && ie_len == 8))
648 memcpy(&llid, PLINK_GET_PLID(elems.peering), 2);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100649
Johannes Bergd0709a62008-02-25 16:27:46 +0100650 rcu_read_lock();
651
Johannes Bergabe60632009-11-25 17:46:18 +0100652 sta = sta_info_get(sdata, mgmt->sa);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700653 if (!sta && ftype != WLAN_SP_MESH_PEERING_OPEN) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200654 mpl_dbg(sdata, "Mesh plink: cls or cnf from unknown peer\n");
Johannes Bergd0709a62008-02-25 16:27:46 +0100655 rcu_read_unlock();
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100656 return;
657 }
658
Ashok Nagarajan55335132012-02-28 17:04:08 -0800659 if (ftype == WLAN_SP_MESH_PEERING_OPEN &&
Ashok Nagarajan3d4f9692012-03-06 12:48:30 -0800660 !rssi_threshold_check(sta, sdata)) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200661 mpl_dbg(sdata, "Mesh plink: %pM does not meet rssi threshold\n",
Ashok Nagarajan3d4f9692012-03-06 12:48:30 -0800662 mgmt->sa);
Ashok Nagarajan55335132012-02-28 17:04:08 -0800663 rcu_read_unlock();
664 return;
665 }
666
Johannes Bergc2c98fd2011-09-29 16:04:36 +0200667 if (sta && !test_sta_flag(sta, WLAN_STA_AUTH)) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200668 mpl_dbg(sdata, "Mesh plink: Action frame from non-authed peer\n");
Javier Cardona53e80512011-04-07 15:08:32 -0700669 rcu_read_unlock();
670 return;
671 }
672
Javier Cardona57cf8042011-05-13 10:45:43 -0700673 if (sta && sta->plink_state == NL80211_PLINK_BLOCKED) {
Johannes Bergd0709a62008-02-25 16:27:46 +0100674 rcu_read_unlock();
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100675 return;
676 }
677
678 /* Now we will figure out the appropriate event... */
679 event = PLINK_UNDEFINED;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700680 if (ftype != WLAN_SP_MESH_PEERING_CLOSE &&
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700681 !mesh_matches_local(sdata, &elems)) {
Christian Lamparterd12c7452010-10-08 22:27:07 +0200682 matches_local = false;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100683 switch (ftype) {
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700684 case WLAN_SP_MESH_PEERING_OPEN:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100685 event = OPN_RJCT;
686 break;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700687 case WLAN_SP_MESH_PEERING_CONFIRM:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100688 event = CNF_RJCT;
689 break;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700690 default:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100691 break;
692 }
Christian Lamparterd12c7452010-10-08 22:27:07 +0200693 }
694
695 if (!sta && !matches_local) {
696 rcu_read_unlock();
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700697 reason = cpu_to_le16(WLAN_REASON_MESH_CONFIG);
Christian Lamparterd12c7452010-10-08 22:27:07 +0200698 llid = 0;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700699 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
700 mgmt->sa, llid, plid, reason);
Christian Lamparterd12c7452010-10-08 22:27:07 +0200701 return;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100702 } else if (!sta) {
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700703 /* ftype == WLAN_SP_MESH_PEERING_OPEN */
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100704 if (!mesh_plink_free_count(sdata)) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200705 mpl_dbg(sdata, "Mesh plink error: no more free plinks\n");
Johannes Berg73651ee2008-02-25 16:27:47 +0100706 rcu_read_unlock();
707 return;
708 }
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100709 event = OPN_ACPT;
Christian Lamparterd12c7452010-10-08 22:27:07 +0200710 } else if (matches_local) {
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100711 switch (ftype) {
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700712 case WLAN_SP_MESH_PEERING_OPEN:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100713 if (!mesh_plink_free_count(sdata) ||
Johannes Bergd0709a62008-02-25 16:27:46 +0100714 (sta->plid && sta->plid != plid))
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100715 event = OPN_IGNR;
716 else
717 event = OPN_ACPT;
718 break;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700719 case WLAN_SP_MESH_PEERING_CONFIRM:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100720 if (!mesh_plink_free_count(sdata) ||
Johannes Bergd0709a62008-02-25 16:27:46 +0100721 (sta->llid != llid || sta->plid != plid))
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100722 event = CNF_IGNR;
723 else
724 event = CNF_ACPT;
725 break;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700726 case WLAN_SP_MESH_PEERING_CLOSE:
Javier Cardona57cf8042011-05-13 10:45:43 -0700727 if (sta->plink_state == NL80211_PLINK_ESTAB)
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100728 /* Do not check for llid or plid. This does not
729 * follow the standard but since multiple plinks
730 * per sta are not supported, it is necessary in
731 * order to avoid a livelock when MP A sees an
732 * establish peer link to MP B but MP B does not
733 * see it. This can be caused by a timeout in
734 * B's peer link establishment or B beign
735 * restarted.
736 */
737 event = CLS_ACPT;
738 else if (sta->plid != plid)
739 event = CLS_IGNR;
740 else if (ie_len == 7 && sta->llid != llid)
741 event = CLS_IGNR;
742 else
743 event = CLS_ACPT;
744 break;
745 default:
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200746 mpl_dbg(sdata, "Mesh plink: unknown frame subtype\n");
Johannes Bergd0709a62008-02-25 16:27:46 +0100747 rcu_read_unlock();
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100748 return;
749 }
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700750 }
751
752 if (event == OPN_ACPT) {
753 /* allocate sta entry if necessary and update info */
Thomas Pedersenf743ff42012-04-18 19:23:43 -0700754 sta = mesh_peer_init(sdata, mgmt->sa, &elems);
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700755 if (!sta) {
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200756 mpl_dbg(sdata, "Mesh plink: failed to init peer!\n");
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700757 rcu_read_unlock();
758 return;
759 }
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100760 }
761
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200762 mpl_dbg(sdata,
763 "Mesh plink (peer, state, llid, plid, event): %pM %s %d %d %d\n",
Rui Paulo1460dd12009-11-09 23:46:48 +0000764 mgmt->sa, mplstates[sta->plink_state],
Johannes Berg0c68ae262008-10-27 15:56:10 -0700765 le16_to_cpu(sta->llid), le16_to_cpu(sta->plid),
766 event);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100767 reason = 0;
Thomas Pedersen54ab1ff2012-04-18 19:23:42 -0700768 spin_lock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100769 switch (sta->plink_state) {
770 /* spin_unlock as soon as state is updated at each case */
Javier Cardona57cf8042011-05-13 10:45:43 -0700771 case NL80211_PLINK_LISTEN:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100772 switch (event) {
773 case CLS_ACPT:
774 mesh_plink_fsm_restart(sta);
Johannes Berg07346f812008-05-03 01:02:02 +0200775 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100776 break;
777 case OPN_ACPT:
Javier Cardona57cf8042011-05-13 10:45:43 -0700778 sta->plink_state = NL80211_PLINK_OPN_RCVD;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100779 sta->plid = plid;
780 get_random_bytes(&llid, 2);
781 sta->llid = llid;
782 mesh_plink_timer_set(sta, dot11MeshRetryTimeout(sdata));
Johannes Berg07346f812008-05-03 01:02:02 +0200783 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700784 mesh_plink_frame_tx(sdata,
785 WLAN_SP_MESH_PEERING_OPEN,
786 sta->sta.addr, llid, 0, 0);
787 mesh_plink_frame_tx(sdata,
788 WLAN_SP_MESH_PEERING_CONFIRM,
789 sta->sta.addr, llid, plid, 0);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100790 break;
791 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200792 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100793 break;
794 }
795 break;
796
Javier Cardona57cf8042011-05-13 10:45:43 -0700797 case NL80211_PLINK_OPN_SNT:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100798 switch (event) {
799 case OPN_RJCT:
800 case CNF_RJCT:
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700801 reason = cpu_to_le16(WLAN_REASON_MESH_CONFIG);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100802 case CLS_ACPT:
803 if (!reason)
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700804 reason = cpu_to_le16(WLAN_REASON_MESH_CLOSE);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100805 sta->reason = reason;
Javier Cardona57cf8042011-05-13 10:45:43 -0700806 sta->plink_state = NL80211_PLINK_HOLDING;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100807 if (!mod_plink_timer(sta,
808 dot11MeshHoldingTimeout(sdata)))
809 sta->ignore_plink_timer = true;
810
811 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200812 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700813 mesh_plink_frame_tx(sdata,
814 WLAN_SP_MESH_PEERING_CLOSE,
815 sta->sta.addr, llid, plid, reason);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100816 break;
817 case OPN_ACPT:
818 /* retry timer is left untouched */
Javier Cardona57cf8042011-05-13 10:45:43 -0700819 sta->plink_state = NL80211_PLINK_OPN_RCVD;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100820 sta->plid = plid;
821 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200822 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700823 mesh_plink_frame_tx(sdata,
824 WLAN_SP_MESH_PEERING_CONFIRM,
825 sta->sta.addr, llid, plid, 0);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100826 break;
827 case CNF_ACPT:
Javier Cardona57cf8042011-05-13 10:45:43 -0700828 sta->plink_state = NL80211_PLINK_CNF_RCVD;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100829 if (!mod_plink_timer(sta,
830 dot11MeshConfirmTimeout(sdata)))
831 sta->ignore_plink_timer = true;
832
Johannes Berg07346f812008-05-03 01:02:02 +0200833 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100834 break;
835 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200836 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100837 break;
838 }
839 break;
840
Javier Cardona57cf8042011-05-13 10:45:43 -0700841 case NL80211_PLINK_OPN_RCVD:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100842 switch (event) {
843 case OPN_RJCT:
844 case CNF_RJCT:
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700845 reason = cpu_to_le16(WLAN_REASON_MESH_CONFIG);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100846 case CLS_ACPT:
847 if (!reason)
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700848 reason = cpu_to_le16(WLAN_REASON_MESH_CLOSE);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100849 sta->reason = reason;
Javier Cardona57cf8042011-05-13 10:45:43 -0700850 sta->plink_state = NL80211_PLINK_HOLDING;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100851 if (!mod_plink_timer(sta,
852 dot11MeshHoldingTimeout(sdata)))
853 sta->ignore_plink_timer = true;
854
855 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200856 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700857 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
858 sta->sta.addr, llid, plid, reason);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100859 break;
860 case OPN_ACPT:
861 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200862 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700863 mesh_plink_frame_tx(sdata,
864 WLAN_SP_MESH_PEERING_CONFIRM,
865 sta->sta.addr, llid, plid, 0);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100866 break;
867 case CNF_ACPT:
Johannes Bergd0709a62008-02-25 16:27:46 +0100868 del_timer(&sta->plink_timer);
Javier Cardona57cf8042011-05-13 10:45:43 -0700869 sta->plink_state = NL80211_PLINK_ESTAB;
Johannes Berg07346f812008-05-03 01:02:02 +0200870 spin_unlock_bh(&sta->lock);
John W. Linvillec9370192010-06-21 17:14:07 -0400871 mesh_plink_inc_estab_count(sdata);
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700872 changed |= mesh_set_ht_prot_mode(sdata);
873 changed |= BSS_CHANGED_BEACON;
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200874 mpl_dbg(sdata, "Mesh plink with %pM ESTABLISHED\n",
Johannes Berg0c68ae262008-10-27 15:56:10 -0700875 sta->sta.addr);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100876 break;
877 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200878 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100879 break;
880 }
881 break;
882
Javier Cardona57cf8042011-05-13 10:45:43 -0700883 case NL80211_PLINK_CNF_RCVD:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100884 switch (event) {
885 case OPN_RJCT:
886 case CNF_RJCT:
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700887 reason = cpu_to_le16(WLAN_REASON_MESH_CONFIG);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100888 case CLS_ACPT:
889 if (!reason)
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700890 reason = cpu_to_le16(WLAN_REASON_MESH_CLOSE);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100891 sta->reason = reason;
Javier Cardona57cf8042011-05-13 10:45:43 -0700892 sta->plink_state = NL80211_PLINK_HOLDING;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100893 if (!mod_plink_timer(sta,
894 dot11MeshHoldingTimeout(sdata)))
895 sta->ignore_plink_timer = true;
896
897 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200898 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700899 mesh_plink_frame_tx(sdata,
900 WLAN_SP_MESH_PEERING_CLOSE,
901 sta->sta.addr, llid, plid, reason);
Johannes Bergff59dc72008-02-25 10:11:50 +0100902 break;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100903 case OPN_ACPT:
Johannes Bergd0709a62008-02-25 16:27:46 +0100904 del_timer(&sta->plink_timer);
Javier Cardona57cf8042011-05-13 10:45:43 -0700905 sta->plink_state = NL80211_PLINK_ESTAB;
Johannes Berg07346f812008-05-03 01:02:02 +0200906 spin_unlock_bh(&sta->lock);
John W. Linvillec9370192010-06-21 17:14:07 -0400907 mesh_plink_inc_estab_count(sdata);
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700908 changed |= mesh_set_ht_prot_mode(sdata);
909 changed |= BSS_CHANGED_BEACON;
Johannes Bergbdcbd8e2012-06-22 11:29:50 +0200910 mpl_dbg(sdata, "Mesh plink with %pM ESTABLISHED\n",
Johannes Berg0c68ae262008-10-27 15:56:10 -0700911 sta->sta.addr);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700912 mesh_plink_frame_tx(sdata,
913 WLAN_SP_MESH_PEERING_CONFIRM,
914 sta->sta.addr, llid, plid, 0);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100915 break;
916 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200917 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100918 break;
919 }
920 break;
921
Javier Cardona57cf8042011-05-13 10:45:43 -0700922 case NL80211_PLINK_ESTAB:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100923 switch (event) {
924 case CLS_ACPT:
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700925 reason = cpu_to_le16(WLAN_REASON_MESH_CLOSE);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100926 sta->reason = reason;
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700927 __mesh_plink_deactivate(sta);
Javier Cardona57cf8042011-05-13 10:45:43 -0700928 sta->plink_state = NL80211_PLINK_HOLDING;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100929 llid = sta->llid;
Johannes Bergd0709a62008-02-25 16:27:46 +0100930 mod_plink_timer(sta, dot11MeshHoldingTimeout(sdata));
Johannes Berg07346f812008-05-03 01:02:02 +0200931 spin_unlock_bh(&sta->lock);
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700932 changed |= mesh_set_ht_prot_mode(sdata);
933 changed |= BSS_CHANGED_BEACON;
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700934 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
935 sta->sta.addr, llid, plid, reason);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100936 break;
937 case OPN_ACPT:
938 llid = sta->llid;
Johannes Berg07346f812008-05-03 01:02:02 +0200939 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700940 mesh_plink_frame_tx(sdata,
941 WLAN_SP_MESH_PEERING_CONFIRM,
942 sta->sta.addr, llid, plid, 0);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100943 break;
944 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200945 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100946 break;
947 }
948 break;
Javier Cardona57cf8042011-05-13 10:45:43 -0700949 case NL80211_PLINK_HOLDING:
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100950 switch (event) {
951 case CLS_ACPT:
Johannes Bergd0709a62008-02-25 16:27:46 +0100952 if (del_timer(&sta->plink_timer))
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100953 sta->ignore_plink_timer = 1;
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100954 mesh_plink_fsm_restart(sta);
Johannes Berg07346f812008-05-03 01:02:02 +0200955 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100956 break;
957 case OPN_ACPT:
958 case CNF_ACPT:
959 case OPN_RJCT:
960 case CNF_RJCT:
961 llid = sta->llid;
962 reason = sta->reason;
Johannes Berg07346f812008-05-03 01:02:02 +0200963 spin_unlock_bh(&sta->lock);
Thomas Pedersen54ef6562011-08-11 19:35:12 -0700964 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
965 sta->sta.addr, llid, plid, reason);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100966 break;
967 default:
Johannes Berg07346f812008-05-03 01:02:02 +0200968 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100969 }
970 break;
971 default:
Luis Carlos Cobob4e08ea2008-02-29 15:46:08 -0800972 /* should not get here, PLINK_BLOCKED is dealt with at the
Daniel Mack3ad2f3f2010-02-03 08:01:28 +0800973 * beginning of the function
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100974 */
Johannes Berg07346f812008-05-03 01:02:02 +0200975 spin_unlock_bh(&sta->lock);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100976 break;
977 }
Johannes Bergd0709a62008-02-25 16:27:46 +0100978
979 rcu_read_unlock();
Ashok Nagarajan57aac7c2012-04-30 14:20:30 -0700980
981 if (changed)
982 ieee80211_bss_info_change_notify(sdata, changed);
Luis Carlos Coboc3896d2c2008-02-23 15:17:13 +0100983}