diff options
author | Thomas Pedersen <thomas@cozybit.com> | 2013-11-05 14:16:50 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-11-25 14:49:50 -0500 |
commit | 4efec45134d82fa73826cc24d41274beb5097d64 (patch) | |
tree | d09369c18680b0be77ccdbbe70e2b49f17fcf549 /net/mac80211/mesh_plink.c | |
parent | 3cde38e7f3491ea62429556149713b7a875c9ac2 (diff) |
mac80211: consolidate calls to plink_frame_tx
Do all frame transfers in one place at the end of the
big switch statements. sta->plid and sta->reason can
be passed in any case, since they are only used for
the frames that need them. Remove assignments to locals
for values already stored in the sta structure.
Signed-off-by: Thomas Pedersen <thomas@cozybit.com>
Signed-off-by: Bob Copeland <me@bobcopeland.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/mesh_plink.c')
-rw-r--r-- | net/mac80211/mesh_plink.c | 72 |
1 files changed, 29 insertions, 43 deletions
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index a8c75c1c66b5..d45826e347ed 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c | |||
@@ -533,6 +533,7 @@ static void mesh_plink_timer(unsigned long data) | |||
533 | __le16 llid, plid, reason; | 533 | __le16 llid, plid, reason; |
534 | struct ieee80211_sub_if_data *sdata; | 534 | struct ieee80211_sub_if_data *sdata; |
535 | struct mesh_config *mshcfg; | 535 | struct mesh_config *mshcfg; |
536 | enum ieee80211_self_protected_actioncode action = 0; | ||
536 | 537 | ||
537 | /* | 538 | /* |
538 | * This STA is valid because sta_info_destroy() will | 539 | * This STA is valid because sta_info_destroy() will |
@@ -575,8 +576,7 @@ static void mesh_plink_timer(unsigned long data) | |||
575 | ++sta->plink_retries; | 576 | ++sta->plink_retries; |
576 | mod_plink_timer(sta, sta->plink_timeout); | 577 | mod_plink_timer(sta, sta->plink_timeout); |
577 | spin_unlock_bh(&sta->lock); | 578 | spin_unlock_bh(&sta->lock); |
578 | mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_OPEN, | 579 | action = WLAN_SP_MESH_PEERING_OPEN; |
579 | sta->sta.addr, llid, 0, 0); | ||
580 | break; | 580 | break; |
581 | } | 581 | } |
582 | reason = cpu_to_le16(WLAN_REASON_MESH_MAX_RETRIES); | 582 | reason = cpu_to_le16(WLAN_REASON_MESH_MAX_RETRIES); |
@@ -588,8 +588,7 @@ static void mesh_plink_timer(unsigned long data) | |||
588 | sta->plink_state = NL80211_PLINK_HOLDING; | 588 | sta->plink_state = NL80211_PLINK_HOLDING; |
589 | mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout); | 589 | mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout); |
590 | spin_unlock_bh(&sta->lock); | 590 | spin_unlock_bh(&sta->lock); |
591 | mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, | 591 | action = WLAN_SP_MESH_PEERING_CLOSE; |
592 | sta->sta.addr, llid, plid, reason); | ||
593 | break; | 592 | break; |
594 | case NL80211_PLINK_HOLDING: | 593 | case NL80211_PLINK_HOLDING: |
595 | /* holding timer */ | 594 | /* holding timer */ |
@@ -601,6 +600,9 @@ static void mesh_plink_timer(unsigned long data) | |||
601 | spin_unlock_bh(&sta->lock); | 600 | spin_unlock_bh(&sta->lock); |
602 | break; | 601 | break; |
603 | } | 602 | } |
603 | if (action) | ||
604 | mesh_plink_frame_tx(sdata, action, sta->sta.addr, | ||
605 | llid, plid, reason); | ||
604 | } | 606 | } |
605 | 607 | ||
606 | static inline void mesh_plink_timer_set(struct sta_info *sta, int timeout) | 608 | static inline void mesh_plink_timer_set(struct sta_info *sta, int timeout) |
@@ -662,6 +664,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
662 | struct ieee80211_rx_status *rx_status) | 664 | struct ieee80211_rx_status *rx_status) |
663 | { | 665 | { |
664 | struct mesh_config *mshcfg = &sdata->u.mesh.mshcfg; | 666 | struct mesh_config *mshcfg = &sdata->u.mesh.mshcfg; |
667 | enum ieee80211_self_protected_actioncode action = 0; | ||
665 | struct ieee802_11_elems elems; | 668 | struct ieee802_11_elems elems; |
666 | struct sta_info *sta; | 669 | struct sta_info *sta; |
667 | enum plink_event event; | 670 | enum plink_event event; |
@@ -872,12 +875,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
872 | changed |= ieee80211_mps_local_status_update(sdata); | 875 | changed |= ieee80211_mps_local_status_update(sdata); |
873 | 876 | ||
874 | spin_unlock_bh(&sta->lock); | 877 | spin_unlock_bh(&sta->lock); |
875 | mesh_plink_frame_tx(sdata, | 878 | action = WLAN_SP_MESH_PEERING_OPEN; |
876 | WLAN_SP_MESH_PEERING_OPEN, | ||
877 | sta->sta.addr, llid, 0, 0); | ||
878 | mesh_plink_frame_tx(sdata, | ||
879 | WLAN_SP_MESH_PEERING_CONFIRM, | ||
880 | sta->sta.addr, llid, plid, 0); | ||
881 | break; | 879 | break; |
882 | default: | 880 | default: |
883 | spin_unlock_bh(&sta->lock); | 881 | spin_unlock_bh(&sta->lock); |
@@ -899,21 +897,15 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
899 | mshcfg->dot11MeshHoldingTimeout)) | 897 | mshcfg->dot11MeshHoldingTimeout)) |
900 | sta->ignore_plink_timer = true; | 898 | sta->ignore_plink_timer = true; |
901 | 899 | ||
902 | llid = sta->llid; | ||
903 | spin_unlock_bh(&sta->lock); | 900 | spin_unlock_bh(&sta->lock); |
904 | mesh_plink_frame_tx(sdata, | 901 | action = WLAN_SP_MESH_PEERING_CLOSE; |
905 | WLAN_SP_MESH_PEERING_CLOSE, | ||
906 | sta->sta.addr, llid, plid, reason); | ||
907 | break; | 902 | break; |
908 | case OPN_ACPT: | 903 | case OPN_ACPT: |
909 | /* retry timer is left untouched */ | 904 | /* retry timer is left untouched */ |
910 | sta->plink_state = NL80211_PLINK_OPN_RCVD; | 905 | sta->plink_state = NL80211_PLINK_OPN_RCVD; |
911 | sta->plid = plid; | 906 | sta->plid = plid; |
912 | llid = sta->llid; | ||
913 | spin_unlock_bh(&sta->lock); | 907 | spin_unlock_bh(&sta->lock); |
914 | mesh_plink_frame_tx(sdata, | 908 | action = WLAN_SP_MESH_PEERING_CONFIRM; |
915 | WLAN_SP_MESH_PEERING_CONFIRM, | ||
916 | sta->sta.addr, llid, plid, 0); | ||
917 | break; | 909 | break; |
918 | case CNF_ACPT: | 910 | case CNF_ACPT: |
919 | sta->plink_state = NL80211_PLINK_CNF_RCVD; | 911 | sta->plink_state = NL80211_PLINK_CNF_RCVD; |
@@ -943,17 +935,12 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
943 | mshcfg->dot11MeshHoldingTimeout)) | 935 | mshcfg->dot11MeshHoldingTimeout)) |
944 | sta->ignore_plink_timer = true; | 936 | sta->ignore_plink_timer = true; |
945 | 937 | ||
946 | llid = sta->llid; | ||
947 | spin_unlock_bh(&sta->lock); | 938 | spin_unlock_bh(&sta->lock); |
948 | mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, | 939 | action = WLAN_SP_MESH_PEERING_CLOSE; |
949 | sta->sta.addr, llid, plid, reason); | ||
950 | break; | 940 | break; |
951 | case OPN_ACPT: | 941 | case OPN_ACPT: |
952 | llid = sta->llid; | ||
953 | spin_unlock_bh(&sta->lock); | 942 | spin_unlock_bh(&sta->lock); |
954 | mesh_plink_frame_tx(sdata, | 943 | action = WLAN_SP_MESH_PEERING_CONFIRM; |
955 | WLAN_SP_MESH_PEERING_CONFIRM, | ||
956 | sta->sta.addr, llid, plid, 0); | ||
957 | break; | 944 | break; |
958 | case CNF_ACPT: | 945 | case CNF_ACPT: |
959 | del_timer(&sta->plink_timer); | 946 | del_timer(&sta->plink_timer); |
@@ -988,11 +975,8 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
988 | mshcfg->dot11MeshHoldingTimeout)) | 975 | mshcfg->dot11MeshHoldingTimeout)) |
989 | sta->ignore_plink_timer = true; | 976 | sta->ignore_plink_timer = true; |
990 | 977 | ||
991 | llid = sta->llid; | ||
992 | spin_unlock_bh(&sta->lock); | 978 | spin_unlock_bh(&sta->lock); |
993 | mesh_plink_frame_tx(sdata, | 979 | action = WLAN_SP_MESH_PEERING_CLOSE; |
994 | WLAN_SP_MESH_PEERING_CLOSE, | ||
995 | sta->sta.addr, llid, plid, reason); | ||
996 | break; | 980 | break; |
997 | case OPN_ACPT: | 981 | case OPN_ACPT: |
998 | del_timer(&sta->plink_timer); | 982 | del_timer(&sta->plink_timer); |
@@ -1003,9 +987,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
1003 | changed |= mesh_set_short_slot_time(sdata); | 987 | changed |= mesh_set_short_slot_time(sdata); |
1004 | mpl_dbg(sdata, "Mesh plink with %pM ESTABLISHED\n", | 988 | mpl_dbg(sdata, "Mesh plink with %pM ESTABLISHED\n", |
1005 | sta->sta.addr); | 989 | sta->sta.addr); |
1006 | mesh_plink_frame_tx(sdata, | 990 | action = WLAN_SP_MESH_PEERING_CONFIRM; |
1007 | WLAN_SP_MESH_PEERING_CONFIRM, | ||
1008 | sta->sta.addr, llid, plid, 0); | ||
1009 | ieee80211_mps_sta_status_update(sta); | 991 | ieee80211_mps_sta_status_update(sta); |
1010 | changed |= ieee80211_mps_set_sta_local_pm(sta, | 992 | changed |= ieee80211_mps_set_sta_local_pm(sta, |
1011 | mshcfg->power_mode); | 993 | mshcfg->power_mode); |
@@ -1023,20 +1005,15 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
1023 | sta->reason = reason; | 1005 | sta->reason = reason; |
1024 | changed |= __mesh_plink_deactivate(sta); | 1006 | changed |= __mesh_plink_deactivate(sta); |
1025 | sta->plink_state = NL80211_PLINK_HOLDING; | 1007 | sta->plink_state = NL80211_PLINK_HOLDING; |
1026 | llid = sta->llid; | ||
1027 | mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout); | 1008 | mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout); |
1028 | spin_unlock_bh(&sta->lock); | 1009 | spin_unlock_bh(&sta->lock); |
1029 | changed |= mesh_set_ht_prot_mode(sdata); | 1010 | changed |= mesh_set_ht_prot_mode(sdata); |
1030 | changed |= mesh_set_short_slot_time(sdata); | 1011 | changed |= mesh_set_short_slot_time(sdata); |
1031 | mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, | 1012 | action = WLAN_SP_MESH_PEERING_CLOSE; |
1032 | sta->sta.addr, llid, plid, reason); | ||
1033 | break; | 1013 | break; |
1034 | case OPN_ACPT: | 1014 | case OPN_ACPT: |
1035 | llid = sta->llid; | ||
1036 | spin_unlock_bh(&sta->lock); | 1015 | spin_unlock_bh(&sta->lock); |
1037 | mesh_plink_frame_tx(sdata, | 1016 | action = WLAN_SP_MESH_PEERING_CONFIRM; |
1038 | WLAN_SP_MESH_PEERING_CONFIRM, | ||
1039 | sta->sta.addr, llid, plid, 0); | ||
1040 | break; | 1017 | break; |
1041 | default: | 1018 | default: |
1042 | spin_unlock_bh(&sta->lock); | 1019 | spin_unlock_bh(&sta->lock); |
@@ -1055,11 +1032,8 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
1055 | case CNF_ACPT: | 1032 | case CNF_ACPT: |
1056 | case OPN_RJCT: | 1033 | case OPN_RJCT: |
1057 | case CNF_RJCT: | 1034 | case CNF_RJCT: |
1058 | llid = sta->llid; | ||
1059 | reason = sta->reason; | ||
1060 | spin_unlock_bh(&sta->lock); | 1035 | spin_unlock_bh(&sta->lock); |
1061 | mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, | 1036 | action = WLAN_SP_MESH_PEERING_CLOSE; |
1062 | sta->sta.addr, llid, plid, reason); | ||
1063 | break; | 1037 | break; |
1064 | default: | 1038 | default: |
1065 | spin_unlock_bh(&sta->lock); | 1039 | spin_unlock_bh(&sta->lock); |
@@ -1072,6 +1046,18 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, | |||
1072 | spin_unlock_bh(&sta->lock); | 1046 | spin_unlock_bh(&sta->lock); |
1073 | break; | 1047 | break; |
1074 | } | 1048 | } |
1049 | if (action) { | ||
1050 | mesh_plink_frame_tx(sdata, action, sta->sta.addr, | ||
1051 | sta->llid, sta->plid, sta->reason); | ||
1052 | |||
1053 | /* also send confirm in open case */ | ||
1054 | if (action == WLAN_SP_MESH_PEERING_OPEN) { | ||
1055 | mesh_plink_frame_tx(sdata, | ||
1056 | WLAN_SP_MESH_PEERING_CONFIRM, | ||
1057 | sta->sta.addr, sta->llid, | ||
1058 | sta->plid, 0); | ||
1059 | } | ||
1060 | } | ||
1075 | 1061 | ||
1076 | rcu_read_unlock(); | 1062 | rcu_read_unlock(); |
1077 | 1063 | ||