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 + 4)
23 #define PLINK_GET_PLID(p) (p + 6)
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)
47 void mesh_plink_inc_estab_count(struct ieee80211_sub_if_data
*sdata
)
49 atomic_inc(&sdata
->u
.mesh
.mshstats
.estab_plinks
);
50 mesh_accept_plinks_update(sdata
);
54 void mesh_plink_dec_estab_count(struct ieee80211_sub_if_data
*sdata
)
56 atomic_dec(&sdata
->u
.mesh
.mshstats
.estab_plinks
);
57 mesh_accept_plinks_update(sdata
);
61 * mesh_plink_fsm_restart - restart a mesh peer link finite state machine
63 * @sta: mesh peer link to restart
65 * Locking: this function must be called holding sta->lock
67 static inline void mesh_plink_fsm_restart(struct sta_info
*sta
)
69 sta
->plink_state
= NL80211_PLINK_LISTEN
;
70 sta
->llid
= sta
->plid
= sta
->reason
= 0;
71 sta
->plink_retries
= 0;
75 * NOTE: This is just an alias for sta_info_alloc(), see notes
76 * on it in the lifecycle management section!
78 static struct sta_info
*mesh_plink_alloc(struct ieee80211_sub_if_data
*sdata
,
79 u8
*hw_addr
, u32 rates
)
81 struct ieee80211_local
*local
= sdata
->local
;
84 if (local
->num_sta
>= MESH_MAX_PLINKS
)
87 sta
= sta_info_alloc(sdata
, hw_addr
, GFP_KERNEL
);
91 sta
->flags
= WLAN_STA_AUTHORIZED
| WLAN_STA_AUTH
;
92 sta
->sta
.supp_rates
[local
->hw
.conf
.channel
->band
] = rates
;
93 rate_control_rate_init(sta
);
99 * __mesh_plink_deactivate - deactivate mesh peer link
101 * @sta: mesh peer link to deactivate
103 * All mesh paths with this peer as next hop will be flushed
105 * Locking: the caller must hold sta->lock
107 static bool __mesh_plink_deactivate(struct sta_info
*sta
)
109 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
110 bool deactivated
= false;
112 if (sta
->plink_state
== NL80211_PLINK_ESTAB
) {
113 mesh_plink_dec_estab_count(sdata
);
116 sta
->plink_state
= NL80211_PLINK_BLOCKED
;
117 mesh_path_flush_by_nexthop(sta
);
123 * mesh_plink_deactivate - deactivate mesh peer link
125 * @sta: mesh peer link to deactivate
127 * All mesh paths with this peer as next hop will be flushed
129 void mesh_plink_deactivate(struct sta_info
*sta
)
131 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
134 spin_lock_bh(&sta
->lock
);
135 deactivated
= __mesh_plink_deactivate(sta
);
136 spin_unlock_bh(&sta
->lock
);
139 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_BEACON
);
142 static int mesh_plink_frame_tx(struct ieee80211_sub_if_data
*sdata
,
143 enum ieee80211_self_protected_actioncode action
,
144 u8
*da
, __le16 llid
, __le16 plid
, __le16 reason
) {
145 struct ieee80211_local
*local
= sdata
->local
;
146 struct sk_buff
*skb
= dev_alloc_skb(local
->hw
.extra_tx_headroom
+ 400 +
147 sdata
->u
.mesh
.ie_len
);
148 struct ieee80211_mgmt
*mgmt
;
149 bool include_plid
= false;
150 static const u8 meshpeeringproto
[] = { 0x00, 0x0F, 0xAC, 0x2A };
156 skb_reserve(skb
, local
->hw
.extra_tx_headroom
);
157 /* 25 is the size of the common mgmt part (24) plus the size of the
158 * common action part (1)
160 mgmt
= (struct ieee80211_mgmt
*)
161 skb_put(skb
, 25 + sizeof(mgmt
->u
.action
.u
.plink_action
));
162 memset(mgmt
, 0, 25 + sizeof(mgmt
->u
.action
.u
.plink_action
));
163 mgmt
->frame_control
= cpu_to_le16(IEEE80211_FTYPE_MGMT
|
164 IEEE80211_STYPE_ACTION
);
165 memcpy(mgmt
->da
, da
, ETH_ALEN
);
166 memcpy(mgmt
->sa
, sdata
->vif
.addr
, ETH_ALEN
);
167 memcpy(mgmt
->bssid
, sdata
->vif
.addr
, ETH_ALEN
);
168 mgmt
->u
.action
.category
= WLAN_CATEGORY_MESH_ACTION
;
169 mgmt
->u
.action
.u
.plink_action
.action_code
= action
;
171 if (action
== WLAN_SP_MESH_PEERING_CLOSE
)
172 mgmt
->u
.action
.u
.plink_action
.aux
= reason
;
174 mgmt
->u
.action
.u
.plink_action
.aux
= cpu_to_le16(0x0);
175 if (action
== WLAN_SP_MESH_PEERING_CONFIRM
) {
176 pos
= skb_put(skb
, 4);
177 /* two-byte status code followed by two-byte AID */
179 memcpy(pos
+ 2, &plid
, 2);
181 if (mesh_add_srates_ie(skb
, sdata
) ||
182 mesh_add_ext_srates_ie(skb
, sdata
) ||
183 mesh_add_rsn_ie(skb
, sdata
) ||
184 mesh_add_meshid_ie(skb
, sdata
) ||
185 mesh_add_meshconf_ie(skb
, sdata
))
189 /* Add Peer Link Management element */
191 case WLAN_SP_MESH_PEERING_OPEN
:
194 case WLAN_SP_MESH_PEERING_CONFIRM
:
198 case WLAN_SP_MESH_PEERING_CLOSE
:
209 pos
= skb_put(skb
, 2 + ie_len
);
210 *pos
++ = WLAN_EID_PEER_LINK
;
212 memcpy(pos
, meshpeeringproto
, sizeof(meshpeeringproto
));
214 memcpy(pos
, &llid
, 2);
217 memcpy(pos
, &plid
, 2);
219 if (action
== WLAN_SP_MESH_PEERING_CLOSE
) {
221 memcpy(pos
, &reason
, 2);
224 ieee80211_tx_skb(sdata
, skb
);
228 void mesh_neighbour_update(u8
*hw_addr
, u32 rates
,
229 struct ieee80211_sub_if_data
*sdata
,
230 struct ieee802_11_elems
*elems
)
232 struct ieee80211_local
*local
= sdata
->local
;
233 struct sta_info
*sta
;
237 sta
= sta_info_get(sdata
, hw_addr
);
240 /* Userspace handles peer allocation when security is enabled
242 if (sdata
->u
.mesh
.security
& IEEE80211_MESH_SEC_AUTHED
)
243 cfg80211_notify_new_peer_candidate(sdata
->dev
, hw_addr
,
244 elems
->ie_start
, elems
->total_len
,
247 sta
= mesh_plink_alloc(sdata
, hw_addr
, rates
);
250 if (sta_info_insert_rcu(sta
)) {
256 sta
->last_rx
= jiffies
;
257 sta
->sta
.supp_rates
[local
->hw
.conf
.channel
->band
] = rates
;
258 if (mesh_peer_accepts_plinks(elems
) &&
259 sta
->plink_state
== NL80211_PLINK_LISTEN
&&
260 sdata
->u
.mesh
.accepting_plinks
&&
261 sdata
->u
.mesh
.mshcfg
.auto_open_plinks
)
262 mesh_plink_open(sta
);
267 static void mesh_plink_timer(unsigned long data
)
269 struct sta_info
*sta
;
270 __le16 llid
, plid
, reason
;
271 struct ieee80211_sub_if_data
*sdata
;
274 * This STA is valid because sta_info_destroy() will
275 * del_timer_sync() this timer after having made sure
276 * it cannot be readded (by deleting the plink.)
278 sta
= (struct sta_info
*) data
;
280 if (sta
->sdata
->local
->quiescing
) {
281 sta
->plink_timer_was_running
= true;
285 spin_lock_bh(&sta
->lock
);
286 if (sta
->ignore_plink_timer
) {
287 sta
->ignore_plink_timer
= false;
288 spin_unlock_bh(&sta
->lock
);
291 mpl_dbg("Mesh plink timer for %pM fired on state %d\n",
292 sta
->sta
.addr
, sta
->plink_state
);
298 switch (sta
->plink_state
) {
299 case NL80211_PLINK_OPN_RCVD
:
300 case NL80211_PLINK_OPN_SNT
:
302 if (sta
->plink_retries
< dot11MeshMaxRetries(sdata
)) {
304 mpl_dbg("Mesh plink for %pM (retry, timeout): %d %d\n",
305 sta
->sta
.addr
, sta
->plink_retries
,
307 get_random_bytes(&rand
, sizeof(u32
));
308 sta
->plink_timeout
= sta
->plink_timeout
+
309 rand
% sta
->plink_timeout
;
310 ++sta
->plink_retries
;
311 mod_plink_timer(sta
, sta
->plink_timeout
);
312 spin_unlock_bh(&sta
->lock
);
313 mesh_plink_frame_tx(sdata
, WLAN_SP_MESH_PEERING_OPEN
,
314 sta
->sta
.addr
, llid
, 0, 0);
317 reason
= cpu_to_le16(WLAN_REASON_MESH_MAX_RETRIES
);
318 /* fall through on else */
319 case NL80211_PLINK_CNF_RCVD
:
322 reason
= cpu_to_le16(WLAN_REASON_MESH_CONFIRM_TIMEOUT
);
323 sta
->plink_state
= NL80211_PLINK_HOLDING
;
324 mod_plink_timer(sta
, dot11MeshHoldingTimeout(sdata
));
325 spin_unlock_bh(&sta
->lock
);
326 mesh_plink_frame_tx(sdata
, WLAN_SP_MESH_PEERING_CLOSE
,
327 sta
->sta
.addr
, llid
, plid
, reason
);
329 case NL80211_PLINK_HOLDING
:
331 del_timer(&sta
->plink_timer
);
332 mesh_plink_fsm_restart(sta
);
333 spin_unlock_bh(&sta
->lock
);
336 spin_unlock_bh(&sta
->lock
);
342 void mesh_plink_quiesce(struct sta_info
*sta
)
344 if (del_timer_sync(&sta
->plink_timer
))
345 sta
->plink_timer_was_running
= true;
348 void mesh_plink_restart(struct sta_info
*sta
)
350 if (sta
->plink_timer_was_running
) {
351 add_timer(&sta
->plink_timer
);
352 sta
->plink_timer_was_running
= false;
357 static inline void mesh_plink_timer_set(struct sta_info
*sta
, int timeout
)
359 sta
->plink_timer
.expires
= jiffies
+ (HZ
* timeout
/ 1000);
360 sta
->plink_timer
.data
= (unsigned long) sta
;
361 sta
->plink_timer
.function
= mesh_plink_timer
;
362 sta
->plink_timeout
= timeout
;
363 add_timer(&sta
->plink_timer
);
366 int mesh_plink_open(struct sta_info
*sta
)
369 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
371 if (!test_sta_flags(sta
, WLAN_STA_AUTH
))
374 spin_lock_bh(&sta
->lock
);
375 get_random_bytes(&llid
, 2);
377 if (sta
->plink_state
!= NL80211_PLINK_LISTEN
) {
378 spin_unlock_bh(&sta
->lock
);
381 sta
->plink_state
= NL80211_PLINK_OPN_SNT
;
382 mesh_plink_timer_set(sta
, dot11MeshRetryTimeout(sdata
));
383 spin_unlock_bh(&sta
->lock
);
384 mpl_dbg("Mesh plink: starting establishment with %pM\n",
387 return mesh_plink_frame_tx(sdata
, WLAN_SP_MESH_PEERING_OPEN
,
388 sta
->sta
.addr
, llid
, 0, 0);
391 void mesh_plink_block(struct sta_info
*sta
)
393 struct ieee80211_sub_if_data
*sdata
= sta
->sdata
;
396 spin_lock_bh(&sta
->lock
);
397 deactivated
= __mesh_plink_deactivate(sta
);
398 sta
->plink_state
= NL80211_PLINK_BLOCKED
;
399 spin_unlock_bh(&sta
->lock
);
402 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_BEACON
);
406 void mesh_rx_plink_frame(struct ieee80211_sub_if_data
*sdata
, struct ieee80211_mgmt
*mgmt
,
407 size_t len
, struct ieee80211_rx_status
*rx_status
)
409 struct ieee80211_local
*local
= sdata
->local
;
410 struct ieee802_11_elems elems
;
411 struct sta_info
*sta
;
412 enum plink_event event
;
413 enum ieee80211_self_protected_actioncode ftype
;
415 bool deactivated
, matches_local
= true;
418 __le16 plid
, llid
, reason
;
419 #ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
420 static const char *mplstates
[] = {
421 [NL80211_PLINK_LISTEN
] = "LISTEN",
422 [NL80211_PLINK_OPN_SNT
] = "OPN-SNT",
423 [NL80211_PLINK_OPN_RCVD
] = "OPN-RCVD",
424 [NL80211_PLINK_CNF_RCVD
] = "CNF_RCVD",
425 [NL80211_PLINK_ESTAB
] = "ESTAB",
426 [NL80211_PLINK_HOLDING
] = "HOLDING",
427 [NL80211_PLINK_BLOCKED
] = "BLOCKED"
431 /* need action_code, aux */
432 if (len
< IEEE80211_MIN_ACTION_SIZE
+ 3)
435 if (is_multicast_ether_addr(mgmt
->da
)) {
436 mpl_dbg("Mesh plink: ignore frame from multicast address");
440 baseaddr
= mgmt
->u
.action
.u
.plink_action
.variable
;
441 baselen
= (u8
*) mgmt
->u
.action
.u
.plink_action
.variable
- (u8
*) mgmt
;
442 if (mgmt
->u
.action
.u
.plink_action
.action_code
==
443 WLAN_SP_MESH_PEERING_CONFIRM
) {
447 ieee802_11_parse_elems(baseaddr
, len
- baselen
, &elems
);
448 if (!elems
.peer_link
) {
449 mpl_dbg("Mesh plink: missing necessary peer link ie\n");
453 sdata
->u
.mesh
.security
== IEEE80211_MESH_SEC_NONE
) {
454 mpl_dbg("Mesh plink: can't establish link with secure peer\n");
458 ftype
= mgmt
->u
.action
.u
.plink_action
.action_code
;
459 ie_len
= elems
.peer_link_len
;
460 if ((ftype
== WLAN_SP_MESH_PEERING_OPEN
&& ie_len
!= 6) ||
461 (ftype
== WLAN_SP_MESH_PEERING_CONFIRM
&& ie_len
!= 8) ||
462 (ftype
== WLAN_SP_MESH_PEERING_CLOSE
&& ie_len
!= 8
464 mpl_dbg("Mesh plink: incorrect plink ie length %d %d\n",
469 if (ftype
!= WLAN_SP_MESH_PEERING_CLOSE
&&
470 (!elems
.mesh_id
|| !elems
.mesh_config
)) {
471 mpl_dbg("Mesh plink: missing necessary ie\n");
474 /* Note the lines below are correct, the llid in the frame is the plid
475 * from the point of view of this host.
477 memcpy(&plid
, PLINK_GET_LLID(elems
.peer_link
), 2);
478 if (ftype
== WLAN_SP_MESH_PEERING_CONFIRM
||
479 (ftype
== WLAN_SP_MESH_PEERING_CLOSE
&& ie_len
== 10))
480 memcpy(&llid
, PLINK_GET_PLID(elems
.peer_link
), 2);
484 sta
= sta_info_get(sdata
, mgmt
->sa
);
485 if (!sta
&& ftype
!= WLAN_SP_MESH_PEERING_OPEN
) {
486 mpl_dbg("Mesh plink: cls or cnf from unknown peer\n");
491 if (sta
&& !test_sta_flags(sta
, WLAN_STA_AUTH
)) {
492 mpl_dbg("Mesh plink: Action frame from non-authed peer\n");
497 if (sta
&& sta
->plink_state
== NL80211_PLINK_BLOCKED
) {
502 /* Now we will figure out the appropriate event... */
503 event
= PLINK_UNDEFINED
;
504 if (ftype
!= WLAN_SP_MESH_PEERING_CLOSE
&&
505 (!mesh_matches_local(&elems
, sdata
))) {
506 matches_local
= false;
508 case WLAN_SP_MESH_PEERING_OPEN
:
511 case WLAN_SP_MESH_PEERING_CONFIRM
:
519 if (!sta
&& !matches_local
) {
521 reason
= cpu_to_le16(WLAN_REASON_MESH_CONFIG
);
523 mesh_plink_frame_tx(sdata
, WLAN_SP_MESH_PEERING_CLOSE
,
524 mgmt
->sa
, llid
, plid
, reason
);
527 /* ftype == WLAN_SP_MESH_PEERING_OPEN */
532 if (!mesh_plink_free_count(sdata
)) {
533 mpl_dbg("Mesh plink error: no more free plinks\n");
537 rates
= ieee80211_sta_get_rates(local
, &elems
, rx_status
->band
);
538 sta
= mesh_plink_alloc(sdata
, mgmt
->sa
, rates
);
540 mpl_dbg("Mesh plink error: plink table full\n");
543 if (sta_info_insert_rcu(sta
)) {
548 spin_lock_bh(&sta
->lock
);
549 } else if (matches_local
) {
550 spin_lock_bh(&sta
->lock
);
552 case WLAN_SP_MESH_PEERING_OPEN
:
553 if (!mesh_plink_free_count(sdata
) ||
554 (sta
->plid
&& sta
->plid
!= plid
))
559 case WLAN_SP_MESH_PEERING_CONFIRM
:
560 if (!mesh_plink_free_count(sdata
) ||
561 (sta
->llid
!= llid
|| sta
->plid
!= plid
))
566 case WLAN_SP_MESH_PEERING_CLOSE
:
567 if (sta
->plink_state
== NL80211_PLINK_ESTAB
)
568 /* Do not check for llid or plid. This does not
569 * follow the standard but since multiple plinks
570 * per sta are not supported, it is necessary in
571 * order to avoid a livelock when MP A sees an
572 * establish peer link to MP B but MP B does not
573 * see it. This can be caused by a timeout in
574 * B's peer link establishment or B beign
578 else if (sta
->plid
!= plid
)
580 else if (ie_len
== 7 && sta
->llid
!= llid
)
586 mpl_dbg("Mesh plink: unknown frame subtype\n");
587 spin_unlock_bh(&sta
->lock
);
592 spin_lock_bh(&sta
->lock
);
595 mpl_dbg("Mesh plink (peer, state, llid, plid, event): %pM %s %d %d %d\n",
596 mgmt
->sa
, mplstates
[sta
->plink_state
],
597 le16_to_cpu(sta
->llid
), le16_to_cpu(sta
->plid
),
600 switch (sta
->plink_state
) {
601 /* spin_unlock as soon as state is updated at each case */
602 case NL80211_PLINK_LISTEN
:
605 mesh_plink_fsm_restart(sta
);
606 spin_unlock_bh(&sta
->lock
);
609 sta
->plink_state
= NL80211_PLINK_OPN_RCVD
;
611 get_random_bytes(&llid
, 2);
613 mesh_plink_timer_set(sta
, dot11MeshRetryTimeout(sdata
));
614 spin_unlock_bh(&sta
->lock
);
615 mesh_plink_frame_tx(sdata
,
616 WLAN_SP_MESH_PEERING_OPEN
,
617 sta
->sta
.addr
, llid
, 0, 0);
618 mesh_plink_frame_tx(sdata
,
619 WLAN_SP_MESH_PEERING_CONFIRM
,
620 sta
->sta
.addr
, llid
, plid
, 0);
623 spin_unlock_bh(&sta
->lock
);
628 case NL80211_PLINK_OPN_SNT
:
632 reason
= cpu_to_le16(WLAN_REASON_MESH_CONFIG
);
635 reason
= cpu_to_le16(WLAN_REASON_MESH_CLOSE
);
636 sta
->reason
= reason
;
637 sta
->plink_state
= NL80211_PLINK_HOLDING
;
638 if (!mod_plink_timer(sta
,
639 dot11MeshHoldingTimeout(sdata
)))
640 sta
->ignore_plink_timer
= true;
643 spin_unlock_bh(&sta
->lock
);
644 mesh_plink_frame_tx(sdata
,
645 WLAN_SP_MESH_PEERING_CLOSE
,
646 sta
->sta
.addr
, llid
, plid
, reason
);
649 /* retry timer is left untouched */
650 sta
->plink_state
= NL80211_PLINK_OPN_RCVD
;
653 spin_unlock_bh(&sta
->lock
);
654 mesh_plink_frame_tx(sdata
,
655 WLAN_SP_MESH_PEERING_CONFIRM
,
656 sta
->sta
.addr
, llid
, plid
, 0);
659 sta
->plink_state
= NL80211_PLINK_CNF_RCVD
;
660 if (!mod_plink_timer(sta
,
661 dot11MeshConfirmTimeout(sdata
)))
662 sta
->ignore_plink_timer
= true;
664 spin_unlock_bh(&sta
->lock
);
667 spin_unlock_bh(&sta
->lock
);
672 case NL80211_PLINK_OPN_RCVD
:
676 reason
= cpu_to_le16(WLAN_REASON_MESH_CONFIG
);
679 reason
= cpu_to_le16(WLAN_REASON_MESH_CLOSE
);
680 sta
->reason
= reason
;
681 sta
->plink_state
= NL80211_PLINK_HOLDING
;
682 if (!mod_plink_timer(sta
,
683 dot11MeshHoldingTimeout(sdata
)))
684 sta
->ignore_plink_timer
= true;
687 spin_unlock_bh(&sta
->lock
);
688 mesh_plink_frame_tx(sdata
, WLAN_SP_MESH_PEERING_CLOSE
,
689 sta
->sta
.addr
, llid
, plid
, reason
);
693 spin_unlock_bh(&sta
->lock
);
694 mesh_plink_frame_tx(sdata
,
695 WLAN_SP_MESH_PEERING_CONFIRM
,
696 sta
->sta
.addr
, llid
, plid
, 0);
699 del_timer(&sta
->plink_timer
);
700 sta
->plink_state
= NL80211_PLINK_ESTAB
;
701 spin_unlock_bh(&sta
->lock
);
702 mesh_plink_inc_estab_count(sdata
);
703 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_BEACON
);
704 mpl_dbg("Mesh plink with %pM ESTABLISHED\n",
708 spin_unlock_bh(&sta
->lock
);
713 case NL80211_PLINK_CNF_RCVD
:
717 reason
= cpu_to_le16(WLAN_REASON_MESH_CONFIG
);
720 reason
= cpu_to_le16(WLAN_REASON_MESH_CLOSE
);
721 sta
->reason
= reason
;
722 sta
->plink_state
= NL80211_PLINK_HOLDING
;
723 if (!mod_plink_timer(sta
,
724 dot11MeshHoldingTimeout(sdata
)))
725 sta
->ignore_plink_timer
= true;
728 spin_unlock_bh(&sta
->lock
);
729 mesh_plink_frame_tx(sdata
,
730 WLAN_SP_MESH_PEERING_CLOSE
,
731 sta
->sta
.addr
, llid
, plid
, reason
);
734 del_timer(&sta
->plink_timer
);
735 sta
->plink_state
= NL80211_PLINK_ESTAB
;
736 spin_unlock_bh(&sta
->lock
);
737 mesh_plink_inc_estab_count(sdata
);
738 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_BEACON
);
739 mpl_dbg("Mesh plink with %pM ESTABLISHED\n",
741 mesh_plink_frame_tx(sdata
,
742 WLAN_SP_MESH_PEERING_CONFIRM
,
743 sta
->sta
.addr
, llid
, plid
, 0);
746 spin_unlock_bh(&sta
->lock
);
751 case NL80211_PLINK_ESTAB
:
754 reason
= cpu_to_le16(WLAN_REASON_MESH_CLOSE
);
755 sta
->reason
= reason
;
756 deactivated
= __mesh_plink_deactivate(sta
);
757 sta
->plink_state
= NL80211_PLINK_HOLDING
;
759 mod_plink_timer(sta
, dot11MeshHoldingTimeout(sdata
));
760 spin_unlock_bh(&sta
->lock
);
762 ieee80211_bss_info_change_notify(sdata
, BSS_CHANGED_BEACON
);
763 mesh_plink_frame_tx(sdata
, WLAN_SP_MESH_PEERING_CLOSE
,
764 sta
->sta
.addr
, llid
, plid
, reason
);
768 spin_unlock_bh(&sta
->lock
);
769 mesh_plink_frame_tx(sdata
,
770 WLAN_SP_MESH_PEERING_CONFIRM
,
771 sta
->sta
.addr
, llid
, plid
, 0);
774 spin_unlock_bh(&sta
->lock
);
778 case NL80211_PLINK_HOLDING
:
781 if (del_timer(&sta
->plink_timer
))
782 sta
->ignore_plink_timer
= 1;
783 mesh_plink_fsm_restart(sta
);
784 spin_unlock_bh(&sta
->lock
);
791 reason
= sta
->reason
;
792 spin_unlock_bh(&sta
->lock
);
793 mesh_plink_frame_tx(sdata
, WLAN_SP_MESH_PEERING_CLOSE
,
794 sta
->sta
.addr
, llid
, plid
, reason
);
797 spin_unlock_bh(&sta
->lock
);
801 /* should not get here, PLINK_BLOCKED is dealt with at the
802 * beginning of the function
804 spin_unlock_bh(&sta
->lock
);