2 * Copyright (c) 2008, 2009 open80211s Ltd.
3 * Author: Luis Carlos Cobo <luisca@cozybit.com>
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.
10 #include <linux/kernel.h>
11 #include <linux/random.h>
12 #include "ieee80211_i.h"
16 #ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
17 #define mpl_dbg(fmt, args...) printk(KERN_DEBUG fmt, ##args)
19 #define mpl_dbg(fmt, args...) do { (void)(0); } while (0)
22 #define PLINK_GET_LLID(p) (p + 2)
23 #define PLINK_GET_PLID(p) (p + 4)
25 #define mod_plink_timer(s, t) (mod_timer(&s->plink_timer, \
26 jiffies + HZ * t / 1000))
28 #define dot11MeshMaxRetries(s) (s->u.mesh.mshcfg.dot11MeshMaxRetries)
29 #define dot11MeshRetryTimeout(s) (s->u.mesh.mshcfg.dot11MeshRetryTimeout)
30 #define dot11MeshConfirmTimeout(s) (s->u.mesh.mshcfg.dot11MeshConfirmTimeout)
31 #define dot11MeshHoldingTimeout(s) (s->u.mesh.mshcfg.dot11MeshHoldingTimeout)
32 #define dot11MeshMaxPeerLinks(s) (s->u.mesh.mshcfg.dot11MeshMaxPeerLinks)
34 /* We only need a valid sta if user configured a minimum rssi_threshold. */
35 #define rssi_threshold_check(sta, sdata) \
36 (sdata->u.mesh.mshcfg.rssi_threshold == 0 ||\
37 (sta && (s8) -ewma_read(&sta->avg_signal) > \
38 sdata->u.mesh.mshcfg.rssi_threshold))
52 static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
53 enum ieee80211_self_protected_actioncode action,
54 u8 *da, __le16 llid, __le16 plid, __le16 reason);
57 void mesh_plink_inc_estab_count(struct ieee80211_sub_if_data *sdata)
59 atomic_inc(&sdata->u.mesh.mshstats.estab_plinks);
60 mesh_accept_plinks_update(sdata);
64 void mesh_plink_dec_estab_count(struct ieee80211_sub_if_data *sdata)
66 atomic_dec(&sdata->u.mesh.mshstats.estab_plinks);
67 mesh_accept_plinks_update(sdata);
71 * mesh_plink_fsm_restart - restart a mesh peer link finite state machine
73 * @sta: mesh peer link to restart
75 * Locking: this function must be called holding sta->lock
77 static inline void mesh_plink_fsm_restart(struct sta_info *sta)
79 sta->plink_state = NL80211_PLINK_LISTEN;
80 sta->llid = sta->plid = sta->reason = 0;
81 sta->plink_retries = 0;
85 * Allocate mesh sta entry and insert into station table
87 static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata,
92 if (sdata->local->num_sta >= MESH_MAX_PLINKS)
95 sta = sta_info_alloc(sdata, hw_addr, GFP_KERNEL);
99 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
100 sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
101 sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
103 set_sta_flag(sta, WLAN_STA_WME);
109 * __mesh_plink_deactivate - deactivate mesh peer link
111 * @sta: mesh peer link to deactivate
113 * All mesh paths with this peer as next hop will be flushed
115 * Locking: the caller must hold sta->lock
117 static bool __mesh_plink_deactivate(struct sta_info *sta)
119 struct ieee80211_sub_if_data *sdata = sta->sdata;
120 bool deactivated = false;
122 if (sta->plink_state == NL80211_PLINK_ESTAB) {
123 mesh_plink_dec_estab_count(sdata);
126 sta->plink_state = NL80211_PLINK_BLOCKED;
127 mesh_path_flush_by_nexthop(sta);
133 * mesh_plink_deactivate - deactivate mesh peer link
135 * @sta: mesh peer link to deactivate
137 * All mesh paths with this peer as next hop will be flushed
139 void mesh_plink_deactivate(struct sta_info *sta)
141 struct ieee80211_sub_if_data *sdata = sta->sdata;
144 spin_lock_bh(&sta->lock);
145 deactivated = __mesh_plink_deactivate(sta);
146 sta->reason = cpu_to_le16(WLAN_REASON_MESH_PEER_CANCELED);
147 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
148 sta->sta.addr, sta->llid, sta->plid,
150 spin_unlock_bh(&sta->lock);
153 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON);
156 static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
157 enum ieee80211_self_protected_actioncode action,
158 u8 *da, __le16 llid, __le16 plid, __le16 reason) {
159 struct ieee80211_local *local = sdata->local;
161 struct ieee80211_mgmt *mgmt;
162 bool include_plid = false;
163 u16 peering_proto = 0;
165 int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.self_prot) +
166 sizeof(mgmt->u.action.u.self_prot);
168 skb = dev_alloc_skb(local->tx_headroom +
170 2 + /* capability info */
172 2 + 8 + /* supported rates */
173 2 + (IEEE80211_MAX_SUPP_RATES - 8) +
174 2 + sdata->u.mesh.mesh_id_len +
175 2 + sizeof(struct ieee80211_meshconf_ie) +
176 2 + sizeof(struct ieee80211_ht_cap) +
177 2 + sizeof(struct ieee80211_ht_operation) +
178 2 + 8 + /* peering IE */
179 sdata->u.mesh.ie_len);
182 skb_reserve(skb, local->tx_headroom);
183 mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
184 memset(mgmt, 0, hdr_len);
185 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
186 IEEE80211_STYPE_ACTION);
187 memcpy(mgmt->da, da, ETH_ALEN);
188 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
189 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN);
190 mgmt->u.action.category = WLAN_CATEGORY_SELF_PROTECTED;
191 mgmt->u.action.u.self_prot.action_code = action;
193 if (action != WLAN_SP_MESH_PEERING_CLOSE) {
194 /* capability info */
195 pos = skb_put(skb, 2);
197 if (action == WLAN_SP_MESH_PEERING_CONFIRM) {
199 pos = skb_put(skb, 2);
200 memcpy(pos + 2, &plid, 2);
202 if (ieee80211_add_srates_ie(&sdata->vif, skb, true) ||
203 ieee80211_add_ext_srates_ie(&sdata->vif, skb, true) ||
204 mesh_add_rsn_ie(skb, sdata) ||
205 mesh_add_meshid_ie(skb, sdata) ||
206 mesh_add_meshconf_ie(skb, sdata))
208 } else { /* WLAN_SP_MESH_PEERING_CLOSE */
209 if (mesh_add_meshid_ie(skb, sdata))
213 /* Add Mesh Peering Management element */
215 case WLAN_SP_MESH_PEERING_OPEN:
217 case WLAN_SP_MESH_PEERING_CONFIRM:
221 case WLAN_SP_MESH_PEERING_CLOSE:
226 ie_len += 2; /* reason code */
232 if (WARN_ON(skb_tailroom(skb) < 2 + ie_len))
235 pos = skb_put(skb, 2 + ie_len);
236 *pos++ = WLAN_EID_PEER_MGMT;
238 memcpy(pos, &peering_proto, 2);
240 memcpy(pos, &llid, 2);
243 memcpy(pos, &plid, 2);
246 if (action == WLAN_SP_MESH_PEERING_CLOSE) {
247 memcpy(pos, &reason, 2);
251 if (action != WLAN_SP_MESH_PEERING_CLOSE) {
252 if (mesh_add_ht_cap_ie(skb, sdata) ||
253 mesh_add_ht_oper_ie(skb, sdata))
257 if (mesh_add_vendor_ies(skb, sdata))
260 ieee80211_tx_skb(sdata, skb);
264 /* mesh_peer_init - initialize new mesh peer and return resulting sta_info
266 * @sdata: local meshif
267 * @addr: peer's address
268 * @elems: IEs from beacon or mesh peering frame
272 static struct sta_info *mesh_peer_init(struct ieee80211_sub_if_data *sdata,
274 struct ieee802_11_elems *elems)
276 struct ieee80211_local *local = sdata->local;
277 enum ieee80211_band band = local->oper_channel->band;
278 struct ieee80211_supported_band *sband;
279 u32 rates, basic_rates = 0;
280 struct sta_info *sta;
283 sband = local->hw.wiphy->bands[band];
284 rates = ieee80211_sta_get_rates(local, elems, band, &basic_rates);
286 sta = sta_info_get(sdata, addr);
288 sta = mesh_plink_alloc(sdata, addr);
294 spin_lock_bh(&sta->lock);
295 sta->last_rx = jiffies;
296 sta->sta.supp_rates[band] = rates;
297 if (elems->ht_cap_elem &&
298 sdata->local->_oper_channel_type != NL80211_CHAN_NO_HT)
299 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
303 memset(&sta->sta.ht_cap, 0, sizeof(sta->sta.ht_cap));
305 if (elems->ht_operation)
306 if (!(elems->ht_operation->ht_param &
307 IEEE80211_HT_PARAM_CHAN_WIDTH_ANY))
308 sta->sta.ht_cap.cap &=
309 ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
311 rate_control_rate_init(sta);
312 spin_unlock_bh(&sta->lock);
314 if (insert && sta_info_insert(sta))
320 void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata,
322 struct ieee802_11_elems *elems)
324 struct sta_info *sta;
326 /* Userspace handles peer allocation when security is enabled */
327 if (sdata->u.mesh.security & IEEE80211_MESH_SEC_AUTHED) {
328 cfg80211_notify_new_peer_candidate(sdata->dev, hw_addr,
336 sta = mesh_peer_init(sdata, hw_addr, elems);
340 if (mesh_peer_accepts_plinks(elems) &&
341 sta->plink_state == NL80211_PLINK_LISTEN &&
342 sdata->u.mesh.accepting_plinks &&
343 sdata->u.mesh.mshcfg.auto_open_plinks &&
344 rssi_threshold_check(sta, sdata))
345 mesh_plink_open(sta);
351 static void mesh_plink_timer(unsigned long data)
353 struct sta_info *sta;
354 __le16 llid, plid, reason;
355 struct ieee80211_sub_if_data *sdata;
358 * This STA is valid because sta_info_destroy() will
359 * del_timer_sync() this timer after having made sure
360 * it cannot be readded (by deleting the plink.)
362 sta = (struct sta_info *) data;
364 if (sta->sdata->local->quiescing) {
365 sta->plink_timer_was_running = true;
369 spin_lock_bh(&sta->lock);
370 if (sta->ignore_plink_timer) {
371 sta->ignore_plink_timer = false;
372 spin_unlock_bh(&sta->lock);
375 mpl_dbg("Mesh plink timer for %pM fired on state %d\n",
376 sta->sta.addr, sta->plink_state);
382 switch (sta->plink_state) {
383 case NL80211_PLINK_OPN_RCVD:
384 case NL80211_PLINK_OPN_SNT:
386 if (sta->plink_retries < dot11MeshMaxRetries(sdata)) {
388 mpl_dbg("Mesh plink for %pM (retry, timeout): %d %d\n",
389 sta->sta.addr, sta->plink_retries,
391 get_random_bytes(&rand, sizeof(u32));
392 sta->plink_timeout = sta->plink_timeout +
393 rand % sta->plink_timeout;
394 ++sta->plink_retries;
395 mod_plink_timer(sta, sta->plink_timeout);
396 spin_unlock_bh(&sta->lock);
397 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_OPEN,
398 sta->sta.addr, llid, 0, 0);
401 reason = cpu_to_le16(WLAN_REASON_MESH_MAX_RETRIES);
402 /* fall through on else */
403 case NL80211_PLINK_CNF_RCVD:
406 reason = cpu_to_le16(WLAN_REASON_MESH_CONFIRM_TIMEOUT);
407 sta->plink_state = NL80211_PLINK_HOLDING;
408 mod_plink_timer(sta, dot11MeshHoldingTimeout(sdata));
409 spin_unlock_bh(&sta->lock);
410 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
411 sta->sta.addr, llid, plid, reason);
413 case NL80211_PLINK_HOLDING:
415 del_timer(&sta->plink_timer);
416 mesh_plink_fsm_restart(sta);
417 spin_unlock_bh(&sta->lock);
420 spin_unlock_bh(&sta->lock);
426 void mesh_plink_quiesce(struct sta_info *sta)
428 if (del_timer_sync(&sta->plink_timer))
429 sta->plink_timer_was_running = true;
432 void mesh_plink_restart(struct sta_info *sta)
434 if (sta->plink_timer_was_running) {
435 add_timer(&sta->plink_timer);
436 sta->plink_timer_was_running = false;
441 static inline void mesh_plink_timer_set(struct sta_info *sta, int timeout)
443 sta->plink_timer.expires = jiffies + (HZ * timeout / 1000);
444 sta->plink_timer.data = (unsigned long) sta;
445 sta->plink_timer.function = mesh_plink_timer;
446 sta->plink_timeout = timeout;
447 add_timer(&sta->plink_timer);
450 int mesh_plink_open(struct sta_info *sta)
453 struct ieee80211_sub_if_data *sdata = sta->sdata;
455 if (!test_sta_flag(sta, WLAN_STA_AUTH))
458 spin_lock_bh(&sta->lock);
459 get_random_bytes(&llid, 2);
461 if (sta->plink_state != NL80211_PLINK_LISTEN) {
462 spin_unlock_bh(&sta->lock);
465 sta->plink_state = NL80211_PLINK_OPN_SNT;
466 mesh_plink_timer_set(sta, dot11MeshRetryTimeout(sdata));
467 spin_unlock_bh(&sta->lock);
468 mpl_dbg("Mesh plink: starting establishment with %pM\n",
471 return mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_OPEN,
472 sta->sta.addr, llid, 0, 0);
475 void mesh_plink_block(struct sta_info *sta)
477 struct ieee80211_sub_if_data *sdata = sta->sdata;
480 spin_lock_bh(&sta->lock);
481 deactivated = __mesh_plink_deactivate(sta);
482 sta->plink_state = NL80211_PLINK_BLOCKED;
483 spin_unlock_bh(&sta->lock);
486 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON);
490 void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_mgmt *mgmt,
491 size_t len, struct ieee80211_rx_status *rx_status)
493 struct ieee802_11_elems elems;
494 struct sta_info *sta;
495 enum plink_event event;
496 enum ieee80211_self_protected_actioncode ftype;
498 bool deactivated, matches_local = true;
501 __le16 plid, llid, reason;
502 #ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
503 static const char *mplstates[] = {
504 [NL80211_PLINK_LISTEN] = "LISTEN",
505 [NL80211_PLINK_OPN_SNT] = "OPN-SNT",
506 [NL80211_PLINK_OPN_RCVD] = "OPN-RCVD",
507 [NL80211_PLINK_CNF_RCVD] = "CNF_RCVD",
508 [NL80211_PLINK_ESTAB] = "ESTAB",
509 [NL80211_PLINK_HOLDING] = "HOLDING",
510 [NL80211_PLINK_BLOCKED] = "BLOCKED"
514 /* need action_code, aux */
515 if (len < IEEE80211_MIN_ACTION_SIZE + 3)
518 if (is_multicast_ether_addr(mgmt->da)) {
519 mpl_dbg("Mesh plink: ignore frame from multicast address");
523 baseaddr = mgmt->u.action.u.self_prot.variable;
524 baselen = (u8 *) mgmt->u.action.u.self_prot.variable - (u8 *) mgmt;
525 if (mgmt->u.action.u.self_prot.action_code ==
526 WLAN_SP_MESH_PEERING_CONFIRM) {
530 ieee802_11_parse_elems(baseaddr, len - baselen, &elems);
531 if (!elems.peering) {
532 mpl_dbg("Mesh plink: missing necessary peer link ie\n");
536 sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE) {
537 mpl_dbg("Mesh plink: can't establish link with secure peer\n");
541 ftype = mgmt->u.action.u.self_prot.action_code;
542 ie_len = elems.peering_len;
543 if ((ftype == WLAN_SP_MESH_PEERING_OPEN && ie_len != 4) ||
544 (ftype == WLAN_SP_MESH_PEERING_CONFIRM && ie_len != 6) ||
545 (ftype == WLAN_SP_MESH_PEERING_CLOSE && ie_len != 6
547 mpl_dbg("Mesh plink: incorrect plink ie length %d %d\n",
552 if (ftype != WLAN_SP_MESH_PEERING_CLOSE &&
553 (!elems.mesh_id || !elems.mesh_config)) {
554 mpl_dbg("Mesh plink: missing necessary ie\n");
557 /* Note the lines below are correct, the llid in the frame is the plid
558 * from the point of view of this host.
560 memcpy(&plid, PLINK_GET_LLID(elems.peering), 2);
561 if (ftype == WLAN_SP_MESH_PEERING_CONFIRM ||
562 (ftype == WLAN_SP_MESH_PEERING_CLOSE && ie_len == 8))
563 memcpy(&llid, PLINK_GET_PLID(elems.peering), 2);
567 sta = sta_info_get(sdata, mgmt->sa);
568 if (!sta && ftype != WLAN_SP_MESH_PEERING_OPEN) {
569 mpl_dbg("Mesh plink: cls or cnf from unknown peer\n");
574 if (ftype == WLAN_SP_MESH_PEERING_OPEN &&
575 !rssi_threshold_check(sta, sdata)) {
576 mpl_dbg("Mesh plink: %pM does not meet rssi threshold\n",
582 if (sta && !test_sta_flag(sta, WLAN_STA_AUTH)) {
583 mpl_dbg("Mesh plink: Action frame from non-authed peer\n");
588 if (sta && sta->plink_state == NL80211_PLINK_BLOCKED) {
593 /* Now we will figure out the appropriate event... */
594 event = PLINK_UNDEFINED;
595 if (ftype != WLAN_SP_MESH_PEERING_CLOSE &&
596 !mesh_matches_local(sdata, &elems)) {
597 matches_local = false;
599 case WLAN_SP_MESH_PEERING_OPEN:
602 case WLAN_SP_MESH_PEERING_CONFIRM:
610 if (!sta && !matches_local) {
612 reason = cpu_to_le16(WLAN_REASON_MESH_CONFIG);
614 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
615 mgmt->sa, llid, plid, reason);
618 /* ftype == WLAN_SP_MESH_PEERING_OPEN */
619 if (!mesh_plink_free_count(sdata)) {
620 mpl_dbg("Mesh plink error: no more free plinks\n");
625 } else if (matches_local) {
627 case WLAN_SP_MESH_PEERING_OPEN:
628 if (!mesh_plink_free_count(sdata) ||
629 (sta->plid && sta->plid != plid))
634 case WLAN_SP_MESH_PEERING_CONFIRM:
635 if (!mesh_plink_free_count(sdata) ||
636 (sta->llid != llid || sta->plid != plid))
641 case WLAN_SP_MESH_PEERING_CLOSE:
642 if (sta->plink_state == NL80211_PLINK_ESTAB)
643 /* Do not check for llid or plid. This does not
644 * follow the standard but since multiple plinks
645 * per sta are not supported, it is necessary in
646 * order to avoid a livelock when MP A sees an
647 * establish peer link to MP B but MP B does not
648 * see it. This can be caused by a timeout in
649 * B's peer link establishment or B beign
653 else if (sta->plid != plid)
655 else if (ie_len == 7 && sta->llid != llid)
661 mpl_dbg("Mesh plink: unknown frame subtype\n");
667 if (event == OPN_ACPT) {
668 /* allocate sta entry if necessary and update info */
669 sta = mesh_peer_init(sdata, mgmt->sa, &elems);
671 mpl_dbg("Mesh plink: failed to init peer!\n");
677 mpl_dbg("Mesh plink (peer, state, llid, plid, event): %pM %s %d %d %d\n",
678 mgmt->sa, mplstates[sta->plink_state],
679 le16_to_cpu(sta->llid), le16_to_cpu(sta->plid),
682 spin_lock_bh(&sta->lock);
683 switch (sta->plink_state) {
684 /* spin_unlock as soon as state is updated at each case */
685 case NL80211_PLINK_LISTEN:
688 mesh_plink_fsm_restart(sta);
689 spin_unlock_bh(&sta->lock);
692 sta->plink_state = NL80211_PLINK_OPN_RCVD;
694 get_random_bytes(&llid, 2);
696 mesh_plink_timer_set(sta, dot11MeshRetryTimeout(sdata));
697 spin_unlock_bh(&sta->lock);
698 mesh_plink_frame_tx(sdata,
699 WLAN_SP_MESH_PEERING_OPEN,
700 sta->sta.addr, llid, 0, 0);
701 mesh_plink_frame_tx(sdata,
702 WLAN_SP_MESH_PEERING_CONFIRM,
703 sta->sta.addr, llid, plid, 0);
706 spin_unlock_bh(&sta->lock);
711 case NL80211_PLINK_OPN_SNT:
715 reason = cpu_to_le16(WLAN_REASON_MESH_CONFIG);
718 reason = cpu_to_le16(WLAN_REASON_MESH_CLOSE);
719 sta->reason = reason;
720 sta->plink_state = NL80211_PLINK_HOLDING;
721 if (!mod_plink_timer(sta,
722 dot11MeshHoldingTimeout(sdata)))
723 sta->ignore_plink_timer = true;
726 spin_unlock_bh(&sta->lock);
727 mesh_plink_frame_tx(sdata,
728 WLAN_SP_MESH_PEERING_CLOSE,
729 sta->sta.addr, llid, plid, reason);
732 /* retry timer is left untouched */
733 sta->plink_state = NL80211_PLINK_OPN_RCVD;
736 spin_unlock_bh(&sta->lock);
737 mesh_plink_frame_tx(sdata,
738 WLAN_SP_MESH_PEERING_CONFIRM,
739 sta->sta.addr, llid, plid, 0);
742 sta->plink_state = NL80211_PLINK_CNF_RCVD;
743 if (!mod_plink_timer(sta,
744 dot11MeshConfirmTimeout(sdata)))
745 sta->ignore_plink_timer = true;
747 spin_unlock_bh(&sta->lock);
750 spin_unlock_bh(&sta->lock);
755 case NL80211_PLINK_OPN_RCVD:
759 reason = cpu_to_le16(WLAN_REASON_MESH_CONFIG);
762 reason = cpu_to_le16(WLAN_REASON_MESH_CLOSE);
763 sta->reason = reason;
764 sta->plink_state = NL80211_PLINK_HOLDING;
765 if (!mod_plink_timer(sta,
766 dot11MeshHoldingTimeout(sdata)))
767 sta->ignore_plink_timer = true;
770 spin_unlock_bh(&sta->lock);
771 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
772 sta->sta.addr, llid, plid, reason);
776 spin_unlock_bh(&sta->lock);
777 mesh_plink_frame_tx(sdata,
778 WLAN_SP_MESH_PEERING_CONFIRM,
779 sta->sta.addr, llid, plid, 0);
782 del_timer(&sta->plink_timer);
783 sta->plink_state = NL80211_PLINK_ESTAB;
784 spin_unlock_bh(&sta->lock);
785 mesh_plink_inc_estab_count(sdata);
786 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON);
787 mpl_dbg("Mesh plink with %pM ESTABLISHED\n",
791 spin_unlock_bh(&sta->lock);
796 case NL80211_PLINK_CNF_RCVD:
800 reason = cpu_to_le16(WLAN_REASON_MESH_CONFIG);
803 reason = cpu_to_le16(WLAN_REASON_MESH_CLOSE);
804 sta->reason = reason;
805 sta->plink_state = NL80211_PLINK_HOLDING;
806 if (!mod_plink_timer(sta,
807 dot11MeshHoldingTimeout(sdata)))
808 sta->ignore_plink_timer = true;
811 spin_unlock_bh(&sta->lock);
812 mesh_plink_frame_tx(sdata,
813 WLAN_SP_MESH_PEERING_CLOSE,
814 sta->sta.addr, llid, plid, reason);
817 del_timer(&sta->plink_timer);
818 sta->plink_state = NL80211_PLINK_ESTAB;
819 spin_unlock_bh(&sta->lock);
820 mesh_plink_inc_estab_count(sdata);
821 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON);
822 mpl_dbg("Mesh plink with %pM ESTABLISHED\n",
824 mesh_plink_frame_tx(sdata,
825 WLAN_SP_MESH_PEERING_CONFIRM,
826 sta->sta.addr, llid, plid, 0);
829 spin_unlock_bh(&sta->lock);
834 case NL80211_PLINK_ESTAB:
837 reason = cpu_to_le16(WLAN_REASON_MESH_CLOSE);
838 sta->reason = reason;
839 deactivated = __mesh_plink_deactivate(sta);
840 sta->plink_state = NL80211_PLINK_HOLDING;
842 mod_plink_timer(sta, dot11MeshHoldingTimeout(sdata));
843 spin_unlock_bh(&sta->lock);
845 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON);
846 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
847 sta->sta.addr, llid, plid, reason);
851 spin_unlock_bh(&sta->lock);
852 mesh_plink_frame_tx(sdata,
853 WLAN_SP_MESH_PEERING_CONFIRM,
854 sta->sta.addr, llid, plid, 0);
857 spin_unlock_bh(&sta->lock);
861 case NL80211_PLINK_HOLDING:
864 if (del_timer(&sta->plink_timer))
865 sta->ignore_plink_timer = 1;
866 mesh_plink_fsm_restart(sta);
867 spin_unlock_bh(&sta->lock);
874 reason = sta->reason;
875 spin_unlock_bh(&sta->lock);
876 mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE,
877 sta->sta.addr, llid, plid, reason);
880 spin_unlock_bh(&sta->lock);
884 /* should not get here, PLINK_BLOCKED is dealt with at the
885 * beginning of the function
887 spin_unlock_bh(&sta->lock);