aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/mesh_hwmp.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-02-15 08:40:31 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-02-15 09:46:37 -0500
commitbf7cd94dcc71682cd6af4a9028f95307b7db41c5 (patch)
tree66b4573619eaebf52c0a298969a9756eb0059266 /net/mac80211/mesh_hwmp.c
parent93c78c5debeb9c7101ecc73347d4730c26a98c05 (diff)
mac80211: clean up mesh code
There's various code with strange indentation, questionable loop and locking constructs, etc. The bigger change is moving the "sdata" argument to the first argument of all functions, like all other mac80211 functions that have one. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/mesh_hwmp.c')
-rw-r--r--net/mac80211/mesh_hwmp.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 585c1e26cca8..bdb8d3b14587 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -238,9 +238,9 @@ static void prepare_frame_for_deferred_tx(struct ieee80211_sub_if_data *sdata,
238 * also acquires in the TX path. To avoid a deadlock we don't transmit the 238 * also acquires in the TX path. To avoid a deadlock we don't transmit the
239 * frame directly but add it to the pending queue instead. 239 * frame directly but add it to the pending queue instead.
240 */ 240 */
241int mesh_path_error_tx(u8 ttl, const u8 *target, __le32 target_sn, 241int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
242 __le16 target_rcode, const u8 *ra, 242 u8 ttl, const u8 *target, __le32 target_sn,
243 struct ieee80211_sub_if_data *sdata) 243 __le16 target_rcode, const u8 *ra)
244{ 244{
245 struct ieee80211_local *local = sdata->local; 245 struct ieee80211_local *local = sdata->local;
246 struct sk_buff *skb; 246 struct sk_buff *skb;
@@ -430,7 +430,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
430 process = false; 430 process = false;
431 fresh_info = false; 431 fresh_info = false;
432 } else { 432 } else {
433 mpath = mesh_path_lookup(orig_addr, sdata); 433 mpath = mesh_path_lookup(sdata, orig_addr);
434 if (mpath) { 434 if (mpath) {
435 spin_lock_bh(&mpath->state_lock); 435 spin_lock_bh(&mpath->state_lock);
436 if (mpath->flags & MESH_PATH_FIXED) 436 if (mpath->flags & MESH_PATH_FIXED)
@@ -445,8 +445,8 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
445 } 445 }
446 } 446 }
447 } else { 447 } else {
448 mesh_path_add(orig_addr, sdata); 448 mesh_path_add(sdata, orig_addr);
449 mpath = mesh_path_lookup(orig_addr, sdata); 449 mpath = mesh_path_lookup(sdata, orig_addr);
450 if (!mpath) { 450 if (!mpath) {
451 rcu_read_unlock(); 451 rcu_read_unlock();
452 return 0; 452 return 0;
@@ -478,7 +478,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
478 else { 478 else {
479 fresh_info = true; 479 fresh_info = true;
480 480
481 mpath = mesh_path_lookup(ta, sdata); 481 mpath = mesh_path_lookup(sdata, ta);
482 if (mpath) { 482 if (mpath) {
483 spin_lock_bh(&mpath->state_lock); 483 spin_lock_bh(&mpath->state_lock);
484 if ((mpath->flags & MESH_PATH_FIXED) || 484 if ((mpath->flags & MESH_PATH_FIXED) ||
@@ -486,8 +486,8 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
486 (last_hop_metric > mpath->metric))) 486 (last_hop_metric > mpath->metric)))
487 fresh_info = false; 487 fresh_info = false;
488 } else { 488 } else {
489 mesh_path_add(ta, sdata); 489 mesh_path_add(sdata, ta);
490 mpath = mesh_path_lookup(ta, sdata); 490 mpath = mesh_path_lookup(sdata, ta);
491 if (!mpath) { 491 if (!mpath) {
492 rcu_read_unlock(); 492 rcu_read_unlock();
493 return 0; 493 return 0;
@@ -553,7 +553,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
553 } else if (is_broadcast_ether_addr(target_addr) && 553 } else if (is_broadcast_ether_addr(target_addr) &&
554 (target_flags & IEEE80211_PREQ_TO_FLAG)) { 554 (target_flags & IEEE80211_PREQ_TO_FLAG)) {
555 rcu_read_lock(); 555 rcu_read_lock();
556 mpath = mesh_path_lookup(orig_addr, sdata); 556 mpath = mesh_path_lookup(sdata, orig_addr);
557 if (mpath) { 557 if (mpath) {
558 if (flags & IEEE80211_PREQ_PROACTIVE_PREP_FLAG) { 558 if (flags & IEEE80211_PREQ_PROACTIVE_PREP_FLAG) {
559 reply = true; 559 reply = true;
@@ -568,7 +568,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
568 rcu_read_unlock(); 568 rcu_read_unlock();
569 } else { 569 } else {
570 rcu_read_lock(); 570 rcu_read_lock();
571 mpath = mesh_path_lookup(target_addr, sdata); 571 mpath = mesh_path_lookup(sdata, target_addr);
572 if (mpath) { 572 if (mpath) {
573 if ((!(mpath->flags & MESH_PATH_SN_VALID)) || 573 if ((!(mpath->flags & MESH_PATH_SN_VALID)) ||
574 SN_LT(mpath->sn, target_sn)) { 574 SN_LT(mpath->sn, target_sn)) {
@@ -678,7 +678,7 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata,
678 } 678 }
679 679
680 rcu_read_lock(); 680 rcu_read_lock();
681 mpath = mesh_path_lookup(orig_addr, sdata); 681 mpath = mesh_path_lookup(sdata, orig_addr);
682 if (mpath) 682 if (mpath)
683 spin_lock_bh(&mpath->state_lock); 683 spin_lock_bh(&mpath->state_lock);
684 else 684 else
@@ -736,7 +736,7 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata,
736 target_rcode = PERR_IE_TARGET_RCODE(perr_elem); 736 target_rcode = PERR_IE_TARGET_RCODE(perr_elem);
737 737
738 rcu_read_lock(); 738 rcu_read_lock();
739 mpath = mesh_path_lookup(target_addr, sdata); 739 mpath = mesh_path_lookup(sdata, target_addr);
740 if (mpath) { 740 if (mpath) {
741 struct sta_info *sta; 741 struct sta_info *sta;
742 742
@@ -751,9 +751,10 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata,
751 spin_unlock_bh(&mpath->state_lock); 751 spin_unlock_bh(&mpath->state_lock);
752 if (!ifmsh->mshcfg.dot11MeshForwarding) 752 if (!ifmsh->mshcfg.dot11MeshForwarding)
753 goto endperr; 753 goto endperr;
754 mesh_path_error_tx(ttl, target_addr, cpu_to_le32(target_sn), 754 mesh_path_error_tx(sdata, ttl, target_addr,
755 cpu_to_le32(target_sn),
755 cpu_to_le16(target_rcode), 756 cpu_to_le16(target_rcode),
756 broadcast_addr, sdata); 757 broadcast_addr);
757 } else 758 } else
758 spin_unlock_bh(&mpath->state_lock); 759 spin_unlock_bh(&mpath->state_lock);
759 } 760 }
@@ -801,10 +802,10 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,
801 802
802 metric_txsta = airtime_link_metric_get(local, sta); 803 metric_txsta = airtime_link_metric_get(local, sta);
803 804
804 mpath = mesh_path_lookup(orig_addr, sdata); 805 mpath = mesh_path_lookup(sdata, orig_addr);
805 if (!mpath) { 806 if (!mpath) {
806 mesh_path_add(orig_addr, sdata); 807 mesh_path_add(sdata, orig_addr);
807 mpath = mesh_path_lookup(orig_addr, sdata); 808 mpath = mesh_path_lookup(sdata, orig_addr);
808 if (!mpath) { 809 if (!mpath) {
809 rcu_read_unlock(); 810 rcu_read_unlock();
810 sdata->u.mesh.mshstats.dropped_frames_no_route++; 811 sdata->u.mesh.mshstats.dropped_frames_no_route++;
@@ -861,8 +862,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,
861 862
862 863
863void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, 864void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
864 struct ieee80211_mgmt *mgmt, 865 struct ieee80211_mgmt *mgmt, size_t len)
865 size_t len)
866{ 866{
867 struct ieee802_11_elems elems; 867 struct ieee802_11_elems elems;
868 size_t baselen; 868 size_t baselen;
@@ -1006,7 +1006,7 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata)
1006 spin_unlock_bh(&ifmsh->mesh_preq_queue_lock); 1006 spin_unlock_bh(&ifmsh->mesh_preq_queue_lock);
1007 1007
1008 rcu_read_lock(); 1008 rcu_read_lock();
1009 mpath = mesh_path_lookup(preq_node->dst, sdata); 1009 mpath = mesh_path_lookup(sdata, preq_node->dst);
1010 if (!mpath) 1010 if (!mpath)
1011 goto enddiscovery; 1011 goto enddiscovery;
1012 1012
@@ -1076,8 +1076,8 @@ enddiscovery:
1076 * Returns: 0 if the next hop was found and -ENOENT if the frame was queued. 1076 * Returns: 0 if the next hop was found and -ENOENT if the frame was queued.
1077 * skb is freeed here if no mpath could be allocated. 1077 * skb is freeed here if no mpath could be allocated.
1078 */ 1078 */
1079int mesh_nexthop_resolve(struct sk_buff *skb, 1079int mesh_nexthop_resolve(struct ieee80211_sub_if_data *sdata,
1080 struct ieee80211_sub_if_data *sdata) 1080 struct sk_buff *skb)
1081{ 1081{
1082 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1082 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1083 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1083 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -1091,17 +1091,17 @@ int mesh_nexthop_resolve(struct sk_buff *skb,
1091 return 0; 1091 return 0;
1092 1092
1093 rcu_read_lock(); 1093 rcu_read_lock();
1094 err = mesh_nexthop_lookup(skb, sdata); 1094 err = mesh_nexthop_lookup(sdata, skb);
1095 if (!err) 1095 if (!err)
1096 goto endlookup; 1096 goto endlookup;
1097 1097
1098 /* no nexthop found, start resolving */ 1098 /* no nexthop found, start resolving */
1099 mpath = mesh_path_lookup(target_addr, sdata); 1099 mpath = mesh_path_lookup(sdata, target_addr);
1100 if (!mpath) { 1100 if (!mpath) {
1101 mesh_path_add(target_addr, sdata); 1101 mesh_path_add(sdata, target_addr);
1102 mpath = mesh_path_lookup(target_addr, sdata); 1102 mpath = mesh_path_lookup(sdata, target_addr);
1103 if (!mpath) { 1103 if (!mpath) {
1104 mesh_path_discard_frame(skb, sdata); 1104 mesh_path_discard_frame(sdata, skb);
1105 err = -ENOSPC; 1105 err = -ENOSPC;
1106 goto endlookup; 1106 goto endlookup;
1107 } 1107 }
@@ -1118,12 +1118,13 @@ int mesh_nexthop_resolve(struct sk_buff *skb,
1118 skb_queue_tail(&mpath->frame_queue, skb); 1118 skb_queue_tail(&mpath->frame_queue, skb);
1119 err = -ENOENT; 1119 err = -ENOENT;
1120 if (skb_to_free) 1120 if (skb_to_free)
1121 mesh_path_discard_frame(skb_to_free, sdata); 1121 mesh_path_discard_frame(sdata, skb_to_free);
1122 1122
1123endlookup: 1123endlookup:
1124 rcu_read_unlock(); 1124 rcu_read_unlock();
1125 return err; 1125 return err;
1126} 1126}
1127
1127/** 1128/**
1128 * mesh_nexthop_lookup - put the appropriate next hop on a mesh frame. Calling 1129 * mesh_nexthop_lookup - put the appropriate next hop on a mesh frame. Calling
1129 * this function is considered "using" the associated mpath, so preempt a path 1130 * this function is considered "using" the associated mpath, so preempt a path
@@ -1134,8 +1135,8 @@ endlookup:
1134 * 1135 *
1135 * Returns: 0 if the next hop was found. Nonzero otherwise. 1136 * Returns: 0 if the next hop was found. Nonzero otherwise.
1136 */ 1137 */
1137int mesh_nexthop_lookup(struct sk_buff *skb, 1138int mesh_nexthop_lookup(struct ieee80211_sub_if_data *sdata,
1138 struct ieee80211_sub_if_data *sdata) 1139 struct sk_buff *skb)
1139{ 1140{
1140 struct mesh_path *mpath; 1141 struct mesh_path *mpath;
1141 struct sta_info *next_hop; 1142 struct sta_info *next_hop;
@@ -1144,7 +1145,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb,
1144 int err = -ENOENT; 1145 int err = -ENOENT;
1145 1146
1146 rcu_read_lock(); 1147 rcu_read_lock();
1147 mpath = mesh_path_lookup(target_addr, sdata); 1148 mpath = mesh_path_lookup(sdata, target_addr);
1148 1149
1149 if (!mpath || !(mpath->flags & MESH_PATH_ACTIVE)) 1150 if (!mpath || !(mpath->flags & MESH_PATH_ACTIVE))
1150 goto endlookup; 1151 goto endlookup;
@@ -1203,8 +1204,7 @@ void mesh_path_timer(unsigned long data)
1203 } 1204 }
1204} 1205}
1205 1206
1206void 1207void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata)
1207mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata)
1208{ 1208{
1209 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 1209 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
1210 u32 interval = ifmsh->mshcfg.dot11MeshHWMPRannInterval; 1210 u32 interval = ifmsh->mshcfg.dot11MeshHWMPRannInterval;