mirror of https://gitee.com/openkylin/linux.git
iwlwifi: introduce iwl_sta_id_or_broadcast
There are now five places where we need to look up the station ID, but the sta pointer may be NULL due to mac80211 passing that to indicate a certain special state. Replace all these by a new inline function, called iwl_sta_id_or_broadcast(), and add documentation about when to use it. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
This commit is contained in:
parent
fd76f148eb
commit
0af8bcae6f
|
@ -567,10 +567,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
|
||||||
hdr_len = ieee80211_hdrlen(fc);
|
hdr_len = ieee80211_hdrlen(fc);
|
||||||
|
|
||||||
/* Find index into station table for destination station */
|
/* Find index into station table for destination station */
|
||||||
if (!info->control.sta)
|
sta_id = iwl_sta_id_or_broadcast(priv, info->control.sta);
|
||||||
sta_id = priv->hw_params.bcast_sta_id;
|
|
||||||
else
|
|
||||||
sta_id = iwl_sta_id(info->control.sta);
|
|
||||||
if (sta_id == IWL_INVALID_STATION) {
|
if (sta_id == IWL_INVALID_STATION) {
|
||||||
IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
|
IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
|
||||||
hdr->addr1);
|
hdr->addr1);
|
||||||
|
|
|
@ -3081,17 +3081,9 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sta) {
|
sta_id = iwl_sta_id_or_broadcast(priv, sta);
|
||||||
sta_id = iwl_sta_id(sta);
|
if (sta_id == IWL_INVALID_STATION)
|
||||||
|
return -EINVAL;
|
||||||
if (sta_id == IWL_INVALID_STATION) {
|
|
||||||
IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n",
|
|
||||||
sta->addr);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sta_id = priv->hw_params.bcast_sta_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
mutex_lock(&priv->mutex);
|
mutex_lock(&priv->mutex);
|
||||||
iwl_scan_cancel_timeout(priv, 100);
|
iwl_scan_cancel_timeout(priv, 100);
|
||||||
|
|
|
@ -972,24 +972,16 @@ void iwl_update_tkip_key(struct iwl_priv *priv,
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (sta) {
|
|
||||||
sta_id = iwl_sta_id(sta);
|
|
||||||
|
|
||||||
if (sta_id == IWL_INVALID_STATION) {
|
|
||||||
IWL_DEBUG_MAC80211(priv, "leave - %pM not initialised.\n",
|
|
||||||
sta->addr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
sta_id = priv->hw_params.bcast_sta_id;
|
|
||||||
|
|
||||||
|
|
||||||
if (iwl_scan_cancel(priv)) {
|
if (iwl_scan_cancel(priv)) {
|
||||||
/* cancel scan failed, just live w/ bad key and rely
|
/* cancel scan failed, just live w/ bad key and rely
|
||||||
briefly on SW decryption */
|
briefly on SW decryption */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sta_id = iwl_sta_id_or_broadcast(priv, sta);
|
||||||
|
if (sta_id == IWL_INVALID_STATION)
|
||||||
|
return;
|
||||||
|
|
||||||
spin_lock_irqsave(&priv->sta_lock, flags);
|
spin_lock_irqsave(&priv->sta_lock, flags);
|
||||||
|
|
||||||
priv->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32;
|
priv->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32;
|
||||||
|
|
|
@ -107,4 +107,33 @@ static inline int iwl_sta_id(struct ieee80211_sta *sta)
|
||||||
|
|
||||||
return ((struct iwl_station_priv_common *)sta->drv_priv)->sta_id;
|
return ((struct iwl_station_priv_common *)sta->drv_priv)->sta_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* iwl_sta_id_or_broadcast - return sta_id or broadcast sta
|
||||||
|
* @priv: iwl priv
|
||||||
|
* @sta: mac80211 station
|
||||||
|
*
|
||||||
|
* In certain circumstances mac80211 passes a station pointer
|
||||||
|
* that may be %NULL, for example during TX or key setup. In
|
||||||
|
* that case, we need to use the broadcast station, so this
|
||||||
|
* inline wraps that pattern.
|
||||||
|
*/
|
||||||
|
static inline int iwl_sta_id_or_broadcast(struct iwl_priv *priv,
|
||||||
|
struct ieee80211_sta *sta)
|
||||||
|
{
|
||||||
|
int sta_id;
|
||||||
|
|
||||||
|
if (!sta)
|
||||||
|
return priv->hw_params.bcast_sta_id;
|
||||||
|
|
||||||
|
sta_id = iwl_sta_id(sta);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* mac80211 should not be passing a partially
|
||||||
|
* initialised station!
|
||||||
|
*/
|
||||||
|
WARN_ON(sta_id == IWL_INVALID_STATION);
|
||||||
|
|
||||||
|
return sta_id;
|
||||||
|
}
|
||||||
#endif /* __iwl_sta_h__ */
|
#endif /* __iwl_sta_h__ */
|
||||||
|
|
|
@ -509,10 +509,7 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
|
||||||
hdr_len = ieee80211_hdrlen(fc);
|
hdr_len = ieee80211_hdrlen(fc);
|
||||||
|
|
||||||
/* Find index into station table for destination station */
|
/* Find index into station table for destination station */
|
||||||
if (!info->control.sta)
|
sta_id = iwl_sta_id_or_broadcast(priv, info->control.sta);
|
||||||
sta_id = priv->hw_params.bcast_sta_id;
|
|
||||||
else
|
|
||||||
sta_id = iwl_sta_id(info->control.sta);
|
|
||||||
if (sta_id == IWL_INVALID_STATION) {
|
if (sta_id == IWL_INVALID_STATION) {
|
||||||
IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
|
IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
|
||||||
hdr->addr1);
|
hdr->addr1);
|
||||||
|
@ -3336,17 +3333,9 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
|
||||||
static_key = !iwl_is_associated(priv);
|
static_key = !iwl_is_associated(priv);
|
||||||
|
|
||||||
if (!static_key) {
|
if (!static_key) {
|
||||||
if (!sta) {
|
sta_id = iwl_sta_id_or_broadcast(priv, sta);
|
||||||
sta_id = priv->hw_params.bcast_sta_id;
|
if (sta_id == IWL_INVALID_STATION)
|
||||||
} else {
|
return -EINVAL;
|
||||||
sta_id = iwl_sta_id(sta);
|
|
||||||
if (sta_id == IWL_INVALID_STATION) {
|
|
||||||
IWL_DEBUG_MAC80211(priv,
|
|
||||||
"leave - %pM not in station map.\n",
|
|
||||||
sta->addr);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&priv->mutex);
|
mutex_lock(&priv->mutex);
|
||||||
|
|
Loading…
Reference in New Issue