Commit 4efec451 authored by Thomas Pedersen's avatar Thomas Pedersen Committed by Johannes Berg

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: default avatarThomas Pedersen <thomas@cozybit.com>
Signed-off-by: default avatarBob Copeland <me@bobcopeland.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 3cde38e7
...@@ -533,6 +533,7 @@ static void mesh_plink_timer(unsigned long data) ...@@ -533,6 +533,7 @@ static void mesh_plink_timer(unsigned long data)
__le16 llid, plid, reason; __le16 llid, plid, reason;
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
struct mesh_config *mshcfg; struct mesh_config *mshcfg;
enum ieee80211_self_protected_actioncode action = 0;
/* /*
* This STA is valid because sta_info_destroy() will * This STA is valid because sta_info_destroy() will
...@@ -575,8 +576,7 @@ static void mesh_plink_timer(unsigned long data) ...@@ -575,8 +576,7 @@ static void mesh_plink_timer(unsigned long data)
++sta->plink_retries; ++sta->plink_retries;
mod_plink_timer(sta, sta->plink_timeout); mod_plink_timer(sta, sta->plink_timeout);
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_OPEN, action = WLAN_SP_MESH_PEERING_OPEN;
sta->sta.addr, llid, 0, 0);
break; break;
} }
reason = cpu_to_le16(WLAN_REASON_MESH_MAX_RETRIES); reason = cpu_to_le16(WLAN_REASON_MESH_MAX_RETRIES);
...@@ -588,8 +588,7 @@ static void mesh_plink_timer(unsigned long data) ...@@ -588,8 +588,7 @@ static void mesh_plink_timer(unsigned long data)
sta->plink_state = NL80211_PLINK_HOLDING; sta->plink_state = NL80211_PLINK_HOLDING;
mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout); mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout);
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, action = WLAN_SP_MESH_PEERING_CLOSE;
sta->sta.addr, llid, plid, reason);
break; break;
case NL80211_PLINK_HOLDING: case NL80211_PLINK_HOLDING:
/* holding timer */ /* holding timer */
...@@ -601,6 +600,9 @@ static void mesh_plink_timer(unsigned long data) ...@@ -601,6 +600,9 @@ static void mesh_plink_timer(unsigned long data)
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
break; break;
} }
if (action)
mesh_plink_frame_tx(sdata, action, sta->sta.addr,
llid, plid, reason);
} }
static inline void mesh_plink_timer_set(struct sta_info *sta, int timeout) 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,6 +664,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
struct ieee80211_rx_status *rx_status) struct ieee80211_rx_status *rx_status)
{ {
struct mesh_config *mshcfg = &sdata->u.mesh.mshcfg; struct mesh_config *mshcfg = &sdata->u.mesh.mshcfg;
enum ieee80211_self_protected_actioncode action = 0;
struct ieee802_11_elems elems; struct ieee802_11_elems elems;
struct sta_info *sta; struct sta_info *sta;
enum plink_event event; enum plink_event event;
...@@ -872,12 +875,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, ...@@ -872,12 +875,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
changed |= ieee80211_mps_local_status_update(sdata); changed |= ieee80211_mps_local_status_update(sdata);
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
mesh_plink_frame_tx(sdata, action = WLAN_SP_MESH_PEERING_OPEN;
WLAN_SP_MESH_PEERING_OPEN,
sta->sta.addr, llid, 0, 0);
mesh_plink_frame_tx(sdata,
WLAN_SP_MESH_PEERING_CONFIRM,
sta->sta.addr, llid, plid, 0);
break; break;
default: default:
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
...@@ -899,21 +897,15 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, ...@@ -899,21 +897,15 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
mshcfg->dot11MeshHoldingTimeout)) mshcfg->dot11MeshHoldingTimeout))
sta->ignore_plink_timer = true; sta->ignore_plink_timer = true;
llid = sta->llid;
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
mesh_plink_frame_tx(sdata, action = WLAN_SP_MESH_PEERING_CLOSE;
WLAN_SP_MESH_PEERING_CLOSE,
sta->sta.addr, llid, plid, reason);
break; break;
case OPN_ACPT: case OPN_ACPT:
/* retry timer is left untouched */ /* retry timer is left untouched */
sta->plink_state = NL80211_PLINK_OPN_RCVD; sta->plink_state = NL80211_PLINK_OPN_RCVD;
sta->plid = plid; sta->plid = plid;
llid = sta->llid;
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
mesh_plink_frame_tx(sdata, action = WLAN_SP_MESH_PEERING_CONFIRM;
WLAN_SP_MESH_PEERING_CONFIRM,
sta->sta.addr, llid, plid, 0);
break; break;
case CNF_ACPT: case CNF_ACPT:
sta->plink_state = NL80211_PLINK_CNF_RCVD; sta->plink_state = NL80211_PLINK_CNF_RCVD;
...@@ -943,17 +935,12 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, ...@@ -943,17 +935,12 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
mshcfg->dot11MeshHoldingTimeout)) mshcfg->dot11MeshHoldingTimeout))
sta->ignore_plink_timer = true; sta->ignore_plink_timer = true;
llid = sta->llid;
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, action = WLAN_SP_MESH_PEERING_CLOSE;
sta->sta.addr, llid, plid, reason);
break; break;
case OPN_ACPT: case OPN_ACPT:
llid = sta->llid;
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
mesh_plink_frame_tx(sdata, action = WLAN_SP_MESH_PEERING_CONFIRM;
WLAN_SP_MESH_PEERING_CONFIRM,
sta->sta.addr, llid, plid, 0);
break; break;
case CNF_ACPT: case CNF_ACPT:
del_timer(&sta->plink_timer); del_timer(&sta->plink_timer);
...@@ -988,11 +975,8 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, ...@@ -988,11 +975,8 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
mshcfg->dot11MeshHoldingTimeout)) mshcfg->dot11MeshHoldingTimeout))
sta->ignore_plink_timer = true; sta->ignore_plink_timer = true;
llid = sta->llid;
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
mesh_plink_frame_tx(sdata, action = WLAN_SP_MESH_PEERING_CLOSE;
WLAN_SP_MESH_PEERING_CLOSE,
sta->sta.addr, llid, plid, reason);
break; break;
case OPN_ACPT: case OPN_ACPT:
del_timer(&sta->plink_timer); del_timer(&sta->plink_timer);
...@@ -1003,9 +987,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, ...@@ -1003,9 +987,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
changed |= mesh_set_short_slot_time(sdata); changed |= mesh_set_short_slot_time(sdata);
mpl_dbg(sdata, "Mesh plink with %pM ESTABLISHED\n", mpl_dbg(sdata, "Mesh plink with %pM ESTABLISHED\n",
sta->sta.addr); sta->sta.addr);
mesh_plink_frame_tx(sdata, action = WLAN_SP_MESH_PEERING_CONFIRM;
WLAN_SP_MESH_PEERING_CONFIRM,
sta->sta.addr, llid, plid, 0);
ieee80211_mps_sta_status_update(sta); ieee80211_mps_sta_status_update(sta);
changed |= ieee80211_mps_set_sta_local_pm(sta, changed |= ieee80211_mps_set_sta_local_pm(sta,
mshcfg->power_mode); mshcfg->power_mode);
...@@ -1023,20 +1005,15 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, ...@@ -1023,20 +1005,15 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
sta->reason = reason; sta->reason = reason;
changed |= __mesh_plink_deactivate(sta); changed |= __mesh_plink_deactivate(sta);
sta->plink_state = NL80211_PLINK_HOLDING; sta->plink_state = NL80211_PLINK_HOLDING;
llid = sta->llid;
mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout); mod_plink_timer(sta, mshcfg->dot11MeshHoldingTimeout);
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
changed |= mesh_set_ht_prot_mode(sdata); changed |= mesh_set_ht_prot_mode(sdata);
changed |= mesh_set_short_slot_time(sdata); changed |= mesh_set_short_slot_time(sdata);
mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, action = WLAN_SP_MESH_PEERING_CLOSE;
sta->sta.addr, llid, plid, reason);
break; break;
case OPN_ACPT: case OPN_ACPT:
llid = sta->llid;
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
mesh_plink_frame_tx(sdata, action = WLAN_SP_MESH_PEERING_CONFIRM;
WLAN_SP_MESH_PEERING_CONFIRM,
sta->sta.addr, llid, plid, 0);
break; break;
default: default:
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
...@@ -1055,11 +1032,8 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, ...@@ -1055,11 +1032,8 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
case CNF_ACPT: case CNF_ACPT:
case OPN_RJCT: case OPN_RJCT:
case CNF_RJCT: case CNF_RJCT:
llid = sta->llid;
reason = sta->reason;
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
mesh_plink_frame_tx(sdata, WLAN_SP_MESH_PEERING_CLOSE, action = WLAN_SP_MESH_PEERING_CLOSE;
sta->sta.addr, llid, plid, reason);
break; break;
default: default:
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
...@@ -1072,6 +1046,18 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, ...@@ -1072,6 +1046,18 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
break; break;
} }
if (action) {
mesh_plink_frame_tx(sdata, action, sta->sta.addr,
sta->llid, sta->plid, sta->reason);
/* also send confirm in open case */
if (action == WLAN_SP_MESH_PEERING_OPEN) {
mesh_plink_frame_tx(sdata,
WLAN_SP_MESH_PEERING_CONFIRM,
sta->sta.addr, sta->llid,
sta->plid, 0);
}
}
rcu_read_unlock(); rcu_read_unlock();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment