Commit 93ae2dd2 authored by Felix Fietkau's avatar Felix Fietkau Committed by John W. Linville

ath9k: assign keycache slots to unencrypted stations

Frame filtering relies on having a valid destination index (keycache slot),
to keep track of the destination. Assigning a keycache slot (configured
to unencrypted, with no key data attached) improves powersave handling in
AP mode with no encryption.
The dummy keycache entry for a station is cleared, when a real key gets
added.
Signed-off-by: default avatarFelix Fietkau <nbd@openwrt.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 5519541d
...@@ -256,6 +256,8 @@ struct ath_node { ...@@ -256,6 +256,8 @@ struct ath_node {
#endif #endif
struct ath_atx_tid tid[WME_NUM_TID]; struct ath_atx_tid tid[WME_NUM_TID];
struct ath_atx_ac ac[WME_NUM_AC]; struct ath_atx_ac ac[WME_NUM_AC];
int ps_key;
u16 maxampdu; u16 maxampdu;
u8 mpdudensity; u8 mpdudensity;
......
...@@ -1732,18 +1732,37 @@ static int ath9k_sta_add(struct ieee80211_hw *hw, ...@@ -1732,18 +1732,37 @@ static int ath9k_sta_add(struct ieee80211_hw *hw,
struct ieee80211_sta *sta) struct ieee80211_sta *sta)
{ {
struct ath_softc *sc = hw->priv; struct ath_softc *sc = hw->priv;
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_node *an = (struct ath_node *) sta->drv_priv;
struct ieee80211_key_conf ps_key = { };
ath_node_attach(sc, sta); ath_node_attach(sc, sta);
an->ps_key = ath_key_config(common, vif, sta, &ps_key);
return 0; return 0;
} }
static void ath9k_del_ps_key(struct ath_softc *sc,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta)
{
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
struct ath_node *an = (struct ath_node *) sta->drv_priv;
struct ieee80211_key_conf ps_key = { .hw_key_idx = an->ps_key };
if (!an->ps_key)
return;
ath_key_delete(common, &ps_key);
}
static int ath9k_sta_remove(struct ieee80211_hw *hw, static int ath9k_sta_remove(struct ieee80211_hw *hw,
struct ieee80211_vif *vif, struct ieee80211_vif *vif,
struct ieee80211_sta *sta) struct ieee80211_sta *sta)
{ {
struct ath_softc *sc = hw->priv; struct ath_softc *sc = hw->priv;
ath9k_del_ps_key(sc, vif, sta);
ath_node_detach(sc, sta); ath_node_detach(sc, sta);
return 0; return 0;
...@@ -1844,6 +1863,9 @@ static int ath9k_set_key(struct ieee80211_hw *hw, ...@@ -1844,6 +1863,9 @@ static int ath9k_set_key(struct ieee80211_hw *hw,
switch (cmd) { switch (cmd) {
case SET_KEY: case SET_KEY:
if (sta)
ath9k_del_ps_key(sc, vif, sta);
ret = ath_key_config(common, vif, sta, key); ret = ath_key_config(common, vif, sta, key);
if (ret >= 0) { if (ret >= 0) {
key->hw_key_idx = ret; key->hw_key_idx = ret;
......
...@@ -1526,7 +1526,7 @@ static void setup_frame_info(struct ieee80211_hw *hw, struct sk_buff *skb, ...@@ -1526,7 +1526,7 @@ static void setup_frame_info(struct ieee80211_hw *hw, struct sk_buff *skb,
struct ieee80211_key_conf *hw_key = tx_info->control.hw_key; struct ieee80211_key_conf *hw_key = tx_info->control.hw_key;
struct ieee80211_hdr *hdr; struct ieee80211_hdr *hdr;
struct ath_frame_info *fi = get_frame_info(skb); struct ath_frame_info *fi = get_frame_info(skb);
struct ath_node *an; struct ath_node *an = NULL;
struct ath_atx_tid *tid; struct ath_atx_tid *tid;
enum ath9k_key_type keytype; enum ath9k_key_type keytype;
u16 seqno = 0; u16 seqno = 0;
...@@ -1534,11 +1534,13 @@ static void setup_frame_info(struct ieee80211_hw *hw, struct sk_buff *skb, ...@@ -1534,11 +1534,13 @@ static void setup_frame_info(struct ieee80211_hw *hw, struct sk_buff *skb,
keytype = ath9k_cmn_get_hw_crypto_keytype(skb); keytype = ath9k_cmn_get_hw_crypto_keytype(skb);
if (sta)
an = (struct ath_node *) sta->drv_priv;
hdr = (struct ieee80211_hdr *)skb->data; hdr = (struct ieee80211_hdr *)skb->data;
if (sta && ieee80211_is_data_qos(hdr->frame_control) && if (an && ieee80211_is_data_qos(hdr->frame_control) &&
conf_is_ht(&hw->conf) && (sc->sc_flags & SC_OP_TXAGGR)) { conf_is_ht(&hw->conf) && (sc->sc_flags & SC_OP_TXAGGR)) {
an = (struct ath_node *) sta->drv_priv;
tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK; tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK;
/* /*
...@@ -1554,6 +1556,8 @@ static void setup_frame_info(struct ieee80211_hw *hw, struct sk_buff *skb, ...@@ -1554,6 +1556,8 @@ static void setup_frame_info(struct ieee80211_hw *hw, struct sk_buff *skb,
memset(fi, 0, sizeof(*fi)); memset(fi, 0, sizeof(*fi));
if (hw_key) if (hw_key)
fi->keyix = hw_key->hw_key_idx; fi->keyix = hw_key->hw_key_idx;
else if (an && ieee80211_is_data(hdr->frame_control) && an->ps_key > 0)
fi->keyix = an->ps_key;
else else
fi->keyix = ATH9K_TXKEYIX_INVALID; fi->keyix = ATH9K_TXKEYIX_INVALID;
fi->keytype = keytype; fi->keytype = keytype;
......
...@@ -483,6 +483,9 @@ int ath_key_config(struct ath_common *common, ...@@ -483,6 +483,9 @@ int ath_key_config(struct ath_common *common,
memset(&hk, 0, sizeof(hk)); memset(&hk, 0, sizeof(hk));
switch (key->cipher) { switch (key->cipher) {
case 0:
hk.kv_type = ATH_CIPHER_CLR;
break;
case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP40:
case WLAN_CIPHER_SUITE_WEP104: case WLAN_CIPHER_SUITE_WEP104:
hk.kv_type = ATH_CIPHER_WEP; hk.kv_type = ATH_CIPHER_WEP;
...@@ -498,7 +501,8 @@ int ath_key_config(struct ath_common *common, ...@@ -498,7 +501,8 @@ int ath_key_config(struct ath_common *common,
} }
hk.kv_len = key->keylen; hk.kv_len = key->keylen;
memcpy(hk.kv_val, key->key, key->keylen); if (key->keylen)
memcpy(hk.kv_val, key->key, key->keylen);
if (!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { if (!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
switch (vif->type) { switch (vif->type) {
......
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