mesh_plink.c (d0709a65181beb787ef3f58cfe45536a2bb254c8) mesh_plink.c (73651ee6396c499ccb59ebc84c9274db01ed026d)
1/*
2 * Copyright (c) 2008 open80211s Ltd.
3 * 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 */

--- 75 unchanged lines hidden (view full) ---

84 */
85static inline void mesh_plink_fsm_restart(struct sta_info *sta)
86{
87 sta->plink_state = LISTEN;
88 sta->llid = sta->plid = sta->reason = sta->plink_retries = 0;
89}
90
91/**
1/*
2 * Copyright (c) 2008 open80211s Ltd.
3 * 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 */

--- 75 unchanged lines hidden (view full) ---

84 */
85static inline void mesh_plink_fsm_restart(struct sta_info *sta)
86{
87 sta->plink_state = LISTEN;
88 sta->llid = sta->plid = sta->reason = sta->plink_retries = 0;
89}
90
91/**
92 * mesh_plink_add - allocate and add a new mesh peer link
92 * mesh_plink_alloc - allocate a new mesh peer link
93 *
93 *
94 * @sdata: local mesh interface
94 * @hw_addr: hardware address (ETH_ALEN length)
95 * @rates: rates the mesh peer supports
95 * @hw_addr: hardware address (ETH_ALEN length)
96 * @rates: rates the mesh peer supports
96 * @dev: local mesh interface
97 *
98 * The initial state of the new plink is set to LISTEN
99 *
97 *
98 * The initial state of the new plink is set to LISTEN
99 *
100 * Returns: non-NULL on success, ERR_PTR() on error.
100 * Returns: NULL on error.
101 */
101 */
102struct sta_info *mesh_plink_add(u8 *hw_addr, u64 rates,
103 struct ieee80211_sub_if_data *sdata)
102struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata,
103 u8 *hw_addr, u64 rates, gfp_t gfp)
104{
105 struct ieee80211_local *local = sdata->local;
106 struct sta_info *sta;
107
108 if (compare_ether_addr(hw_addr, sdata->dev->dev_addr) == 0)
109 /* never add ourselves as neighbours */
104{
105 struct ieee80211_local *local = sdata->local;
106 struct sta_info *sta;
107
108 if (compare_ether_addr(hw_addr, sdata->dev->dev_addr) == 0)
109 /* never add ourselves as neighbours */
110 return ERR_PTR(-EINVAL);
110 return NULL;
111
112 if (is_multicast_ether_addr(hw_addr))
111
112 if (is_multicast_ether_addr(hw_addr))
113 return ERR_PTR(-EINVAL);
113 return NULL;
114
115 if (local->num_sta >= MESH_MAX_PLINKS)
114
115 if (local->num_sta >= MESH_MAX_PLINKS)
116 return ERR_PTR(-ENOSPC);
116 return NULL;
117
117
118 sta = sta_info_add(sdata, hw_addr);
119 if (IS_ERR(sta))
120 return sta;
118 sta = sta_info_alloc(sdata, hw_addr, gfp);
119 if (!sta)
120 return NULL;
121
122 sta->plink_state = LISTEN;
123 spin_lock_init(&sta->plink_lock);
124 init_timer(&sta->plink_timer);
125 sta->flags |= WLAN_STA_AUTHORIZED;
126 sta->supp_rates[local->hw.conf.channel->band] = rates;
121
122 sta->plink_state = LISTEN;
123 spin_lock_init(&sta->plink_lock);
124 init_timer(&sta->plink_timer);
125 sta->flags |= WLAN_STA_AUTHORIZED;
126 sta->supp_rates[local->hw.conf.channel->band] = rates;
127 rate_control_rate_init(sta, local);
128
127
129 mesh_accept_plinks_update(sdata);
130
131 return sta;
132}
133
134/**
135 * mesh_plink_deactivate - deactivate mesh peer link
136 *
137 * @sta: mesh peer link to deactivate
138 *

--- 108 unchanged lines hidden (view full) ---

247 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
248 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
249 struct sta_info *sta;
250
251 rcu_read_lock();
252
253 sta = sta_info_get(local, hw_addr);
254 if (!sta) {
128 return sta;
129}
130
131/**
132 * mesh_plink_deactivate - deactivate mesh peer link
133 *
134 * @sta: mesh peer link to deactivate
135 *

--- 108 unchanged lines hidden (view full) ---

244 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
245 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
246 struct sta_info *sta;
247
248 rcu_read_lock();
249
250 sta = sta_info_get(local, hw_addr);
251 if (!sta) {
255 sta = mesh_plink_add(hw_addr, rates, sdata);
256 if (IS_ERR(sta)) {
252 sta = mesh_plink_alloc(sdata, hw_addr, rates, GFP_ATOMIC);
253 if (!sta) {
257 rcu_read_unlock();
258 return;
259 }
254 rcu_read_unlock();
255 return;
256 }
257 if (sta_info_insert(sta)) {
258 sta_info_destroy(sta);
259 rcu_read_unlock();
260 return;
261 }
260 }
261
262 sta->last_rx = jiffies;
263 sta->supp_rates[local->hw.conf.channel->band] = rates;
264 if (peer_accepting_plinks && sta->plink_state == LISTEN &&
265 sdata->u.sta.accepting_plinks &&
266 sdata->u.sta.mshcfg.auto_open_plinks)
267 mesh_plink_open(sta);

--- 243 unchanged lines hidden (view full) ---

511 u64 rates;
512 if (!mesh_plink_free_count(sdata)) {
513 mpl_dbg("Mesh plink error: no more free plinks\n");
514 rcu_read_unlock();
515 return;
516 }
517
518 rates = ieee80211_sta_get_rates(local, &elems, rx_status->band);
262 }
263
264 sta->last_rx = jiffies;
265 sta->supp_rates[local->hw.conf.channel->band] = rates;
266 if (peer_accepting_plinks && sta->plink_state == LISTEN &&
267 sdata->u.sta.accepting_plinks &&
268 sdata->u.sta.mshcfg.auto_open_plinks)
269 mesh_plink_open(sta);

--- 243 unchanged lines hidden (view full) ---

513 u64 rates;
514 if (!mesh_plink_free_count(sdata)) {
515 mpl_dbg("Mesh plink error: no more free plinks\n");
516 rcu_read_unlock();
517 return;
518 }
519
520 rates = ieee80211_sta_get_rates(local, &elems, rx_status->band);
519 sta = mesh_plink_add(mgmt->sa, rates, sdata);
520 if (IS_ERR(sta)) {
521 sta = mesh_plink_alloc(sdata, mgmt->sa, rates, GFP_ATOMIC);
522 if (!sta) {
521 mpl_dbg("Mesh plink error: plink table full\n");
522 rcu_read_unlock();
523 return;
524 }
523 mpl_dbg("Mesh plink error: plink table full\n");
524 rcu_read_unlock();
525 return;
526 }
527 if (sta_info_insert(sta)) {
528 sta_info_destroy(sta);
529 rcu_read_unlock();
530 return;
531 }
525 event = OPN_ACPT;
526 spin_lock_bh(&sta->plink_lock);
527 } else {
528 spin_lock_bh(&sta->plink_lock);
529 switch (ftype) {
530 case PLINK_OPEN:
531 if (!mesh_plink_free_count(sdata) ||
532 (sta->plid && sta->plid != plid))

--- 241 unchanged lines hidden ---
532 event = OPN_ACPT;
533 spin_lock_bh(&sta->plink_lock);
534 } else {
535 spin_lock_bh(&sta->plink_lock);
536 switch (ftype) {
537 case PLINK_OPEN:
538 if (!mesh_plink_free_count(sdata) ||
539 (sta->plid && sta->plid != plid))

--- 241 unchanged lines hidden ---