diff options
author | Thomas Pedersen <thomas@cozybit.com> | 2012-04-18 22:23:43 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-04-23 15:34:07 -0400 |
commit | f743ff4907fa5bc2b460f48ace831a560806a9fb (patch) | |
tree | 2bf0f42ee4935ff5ee558d5db6a6e529ec1997e3 /net/mac80211 | |
parent | 54ab1ffb6cd94e5c013d61c192e78e30fdf25f8a (diff) |
mac80211: refactor mesh peer rate handling
To avoid passing supp_rates and basic_rates around all the time, just
derive these when needed in mesh_matches_local() and mesh_peer_init().
Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r-- | net/mac80211/mesh.c | 19 | ||||
-rw-r--r-- | net/mac80211/mesh.h | 10 | ||||
-rw-r--r-- | net/mac80211/mesh_plink.c | 25 |
3 files changed, 25 insertions, 29 deletions
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index 133c118526fb..598a96a3a051 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
@@ -64,18 +64,18 @@ static void ieee80211_mesh_housekeeping_timer(unsigned long data) | |||
64 | /** | 64 | /** |
65 | * mesh_matches_local - check if the config of a mesh point matches ours | 65 | * mesh_matches_local - check if the config of a mesh point matches ours |
66 | * | 66 | * |
67 | * @ie: information elements of a management frame from the mesh peer | ||
68 | * @sdata: local mesh subif | 67 | * @sdata: local mesh subif |
69 | * @basic_rates: BSSBasicRateSet of the peer candidate | 68 | * @ie: information elements of a management frame from the mesh peer |
70 | * | 69 | * |
71 | * This function checks if the mesh configuration of a mesh point matches the | 70 | * This function checks if the mesh configuration of a mesh point matches the |
72 | * local mesh configuration, i.e. if both nodes belong to the same mesh network. | 71 | * local mesh configuration, i.e. if both nodes belong to the same mesh network. |
73 | */ | 72 | */ |
74 | bool mesh_matches_local(struct ieee802_11_elems *ie, | 73 | bool mesh_matches_local(struct ieee80211_sub_if_data *sdata, |
75 | struct ieee80211_sub_if_data *sdata, u32 basic_rates) | 74 | struct ieee802_11_elems *ie) |
76 | { | 75 | { |
77 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | 76 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
78 | struct ieee80211_local *local = sdata->local; | 77 | struct ieee80211_local *local = sdata->local; |
78 | u32 basic_rates = 0; | ||
79 | 79 | ||
80 | /* | 80 | /* |
81 | * As support for each feature is added, check for matching | 81 | * As support for each feature is added, check for matching |
@@ -96,6 +96,9 @@ bool mesh_matches_local(struct ieee802_11_elems *ie, | |||
96 | (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth))) | 96 | (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth))) |
97 | goto mismatch; | 97 | goto mismatch; |
98 | 98 | ||
99 | ieee80211_sta_get_rates(local, ie, local->oper_channel->band, | ||
100 | &basic_rates); | ||
101 | |||
99 | if (sdata->vif.bss_conf.basic_rates != basic_rates) | 102 | if (sdata->vif.bss_conf.basic_rates != basic_rates) |
100 | goto mismatch; | 103 | goto mismatch; |
101 | 104 | ||
@@ -630,7 +633,6 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, | |||
630 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | 633 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; |
631 | struct ieee802_11_elems elems; | 634 | struct ieee802_11_elems elems; |
632 | struct ieee80211_channel *channel; | 635 | struct ieee80211_channel *channel; |
633 | u32 supp_rates = 0, basic_rates = 0; | ||
634 | size_t baselen; | 636 | size_t baselen; |
635 | int freq; | 637 | int freq; |
636 | enum ieee80211_band band = rx_status->band; | 638 | enum ieee80211_band band = rx_status->band; |
@@ -661,12 +663,9 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, | |||
661 | if (!channel || channel->flags & IEEE80211_CHAN_DISABLED) | 663 | if (!channel || channel->flags & IEEE80211_CHAN_DISABLED) |
662 | return; | 664 | return; |
663 | 665 | ||
664 | supp_rates = ieee80211_sta_get_rates(local, &elems, | ||
665 | band, &basic_rates); | ||
666 | |||
667 | if (elems.mesh_id && elems.mesh_config && | 666 | if (elems.mesh_id && elems.mesh_config && |
668 | mesh_matches_local(&elems, sdata, basic_rates)) | 667 | mesh_matches_local(sdata, &elems)) |
669 | mesh_neighbour_update(mgmt->sa, supp_rates, sdata, &elems); | 668 | mesh_neighbour_update(sdata, mgmt->sa, &elems); |
670 | 669 | ||
671 | if (ifmsh->sync_ops) | 670 | if (ifmsh->sync_ops) |
672 | ifmsh->sync_ops->rx_bcn_presp(sdata, | 671 | ifmsh->sync_ops->rx_bcn_presp(sdata, |
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h index 4ad738988801..345f0e7d518e 100644 --- a/net/mac80211/mesh.h +++ b/net/mac80211/mesh.h | |||
@@ -222,8 +222,8 @@ int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr, | |||
222 | char *addr6); | 222 | char *addr6); |
223 | int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr, | 223 | int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr, |
224 | struct ieee80211_sub_if_data *sdata); | 224 | struct ieee80211_sub_if_data *sdata); |
225 | bool mesh_matches_local(struct ieee802_11_elems *ie, | 225 | bool mesh_matches_local(struct ieee80211_sub_if_data *sdata, |
226 | struct ieee80211_sub_if_data *sdata, u32 basic_rates); | 226 | struct ieee802_11_elems *ie); |
227 | void mesh_ids_set_default(struct ieee80211_if_mesh *mesh); | 227 | void mesh_ids_set_default(struct ieee80211_if_mesh *mesh); |
228 | void mesh_mgmt_ies_add(struct sk_buff *skb, | 228 | void mesh_mgmt_ies_add(struct sk_buff *skb, |
229 | struct ieee80211_sub_if_data *sdata); | 229 | struct ieee80211_sub_if_data *sdata); |
@@ -276,9 +276,9 @@ int mesh_path_add_gate(struct mesh_path *mpath); | |||
276 | int mesh_path_send_to_gates(struct mesh_path *mpath); | 276 | int mesh_path_send_to_gates(struct mesh_path *mpath); |
277 | int mesh_gate_num(struct ieee80211_sub_if_data *sdata); | 277 | int mesh_gate_num(struct ieee80211_sub_if_data *sdata); |
278 | /* Mesh plinks */ | 278 | /* Mesh plinks */ |
279 | void mesh_neighbour_update(u8 *hw_addr, u32 rates, | 279 | void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata, |
280 | struct ieee80211_sub_if_data *sdata, | 280 | u8 *hw_addr, |
281 | struct ieee802_11_elems *ie); | 281 | struct ieee802_11_elems *ie); |
282 | bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie); | 282 | bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie); |
283 | void mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata); | 283 | void mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata); |
284 | void mesh_plink_broken(struct sta_info *sta); | 284 | void mesh_plink_broken(struct sta_info *sta); |
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index c3a0b0a4f97f..c2af7b3d03cd 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c | |||
@@ -268,20 +268,22 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, | |||
268 | * | 268 | * |
269 | * @sdata: local meshif | 269 | * @sdata: local meshif |
270 | * @addr: peer's address | 270 | * @addr: peer's address |
271 | * @rates: station's supported rates | ||
272 | * @elems: IEs from beacon or mesh peering frame | 271 | * @elems: IEs from beacon or mesh peering frame |
273 | * | 272 | * |
274 | * call under RCU | 273 | * call under RCU |
275 | */ | 274 | */ |
276 | static struct sta_info *mesh_peer_init(struct ieee80211_sub_if_data *sdata, | 275 | static struct sta_info *mesh_peer_init(struct ieee80211_sub_if_data *sdata, |
277 | u8 *addr, u32 rates, | 276 | u8 *addr, |
278 | struct ieee802_11_elems *elems) | 277 | struct ieee802_11_elems *elems) |
279 | { | 278 | { |
280 | struct ieee80211_local *local = sdata->local; | 279 | struct ieee80211_local *local = sdata->local; |
280 | enum ieee80211_band band = local->oper_channel->band; | ||
281 | struct ieee80211_supported_band *sband; | 281 | struct ieee80211_supported_band *sband; |
282 | u32 rates, basic_rates = 0; | ||
282 | struct sta_info *sta; | 283 | struct sta_info *sta; |
283 | 284 | ||
284 | sband = local->hw.wiphy->bands[local->oper_channel->band]; | 285 | sband = local->hw.wiphy->bands[band]; |
286 | rates = ieee80211_sta_get_rates(local, elems, band, &basic_rates); | ||
285 | 287 | ||
286 | sta = sta_info_get(sdata, addr); | 288 | sta = sta_info_get(sdata, addr); |
287 | if (!sta) { | 289 | if (!sta) { |
@@ -292,7 +294,7 @@ static struct sta_info *mesh_peer_init(struct ieee80211_sub_if_data *sdata, | |||
292 | 294 | ||
293 | spin_lock_bh(&sta->lock); | 295 | spin_lock_bh(&sta->lock); |
294 | sta->last_rx = jiffies; | 296 | sta->last_rx = jiffies; |
295 | sta->sta.supp_rates[local->hw.conf.channel->band] = rates; | 297 | sta->sta.supp_rates[band] = rates; |
296 | if (elems->ht_cap_elem) | 298 | if (elems->ht_cap_elem) |
297 | ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband, | 299 | ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband, |
298 | elems->ht_cap_elem, | 300 | elems->ht_cap_elem, |
@@ -306,8 +308,8 @@ static struct sta_info *mesh_peer_init(struct ieee80211_sub_if_data *sdata, | |||
306 | return sta; | 308 | return sta; |
307 | } | 309 | } |
308 | 310 | ||
309 | void mesh_neighbour_update(u8 *hw_addr, u32 rates, | 311 | void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata, |
310 | struct ieee80211_sub_if_data *sdata, | 312 | u8 *hw_addr, |
311 | struct ieee802_11_elems *elems) | 313 | struct ieee802_11_elems *elems) |
312 | { | 314 | { |
313 | struct sta_info *sta; | 315 | struct sta_info *sta; |
@@ -322,7 +324,7 @@ void mesh_neighbour_update(u8 *hw_addr, u32 rates, | |||
322 | } | 324 | } |
323 | 325 | ||
324 | rcu_read_lock(); | 326 | rcu_read_lock(); |
325 | sta = mesh_peer_init(sdata, hw_addr, rates, elems); | 327 | sta = mesh_peer_init(sdata, hw_addr, elems); |
326 | if (!sta) | 328 | if (!sta) |
327 | goto out; | 329 | goto out; |
328 | 330 | ||
@@ -479,7 +481,6 @@ void mesh_plink_block(struct sta_info *sta) | |||
479 | void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_mgmt *mgmt, | 481 | void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_mgmt *mgmt, |
480 | size_t len, struct ieee80211_rx_status *rx_status) | 482 | size_t len, struct ieee80211_rx_status *rx_status) |
481 | { | 483 | { |
482 | struct ieee80211_local *local = sdata->local; | ||
483 | struct ieee802_11_elems elems; | 484 | struct ieee802_11_elems elems; |
484 | struct sta_info *sta; | 485 | struct sta_info *sta; |
485 | enum plink_event event; | 486 | enum plink_event event; |
@@ -488,7 +489,6 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m | |||
488 | bool deactivated, matches_local = true; | 489 | bool deactivated, matches_local = true; |
489 | u8 ie_len; | 490 | u8 ie_len; |
490 | u8 *baseaddr; | 491 | u8 *baseaddr; |
491 | u32 rates, basic_rates = 0; | ||
492 | __le16 plid, llid, reason; | 492 | __le16 plid, llid, reason; |
493 | #ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG | 493 | #ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG |
494 | static const char *mplstates[] = { | 494 | static const char *mplstates[] = { |
@@ -583,11 +583,8 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m | |||
583 | 583 | ||
584 | /* Now we will figure out the appropriate event... */ | 584 | /* Now we will figure out the appropriate event... */ |
585 | event = PLINK_UNDEFINED; | 585 | event = PLINK_UNDEFINED; |
586 | rates = ieee80211_sta_get_rates(local, &elems, | ||
587 | rx_status->band, &basic_rates); | ||
588 | |||
589 | if (ftype != WLAN_SP_MESH_PEERING_CLOSE && | 586 | if (ftype != WLAN_SP_MESH_PEERING_CLOSE && |
590 | (!mesh_matches_local(&elems, sdata, basic_rates))) { | 587 | !mesh_matches_local(sdata, &elems)) { |
591 | matches_local = false; | 588 | matches_local = false; |
592 | switch (ftype) { | 589 | switch (ftype) { |
593 | case WLAN_SP_MESH_PEERING_OPEN: | 590 | case WLAN_SP_MESH_PEERING_OPEN: |
@@ -660,7 +657,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m | |||
660 | 657 | ||
661 | if (event == OPN_ACPT) { | 658 | if (event == OPN_ACPT) { |
662 | /* allocate sta entry if necessary and update info */ | 659 | /* allocate sta entry if necessary and update info */ |
663 | sta = mesh_peer_init(sdata, mgmt->sa, rates, &elems); | 660 | sta = mesh_peer_init(sdata, mgmt->sa, &elems); |
664 | if (!sta) { | 661 | if (!sta) { |
665 | mpl_dbg("Mesh plink: failed to init peer!\n"); | 662 | mpl_dbg("Mesh plink: failed to init peer!\n"); |
666 | rcu_read_unlock(); | 663 | rcu_read_unlock(); |