Commit 9da38fd5 authored by Jérôme Pouiller's avatar Jérôme Pouiller Committed by Greg Kroah-Hartman

staging: wfx: keys are kept during whole firmware life

Keys sent to the firmware are never reset. So, it is not necessary to
re-upload them after hif_reset(). Thus, it is no more necessary to keep
a copy of the keys in struct wfx_dev.
Signed-off-by: default avatarJérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-12-Jerome.Pouiller@silabs.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7a44644c
......@@ -21,14 +21,12 @@ static int wfx_alloc_key(struct wfx_dev *wdev)
return -1;
wdev->key_map |= BIT(idx);
wdev->keys[idx].entry_index = idx;
return idx;
}
static void wfx_free_key(struct wfx_dev *wdev, int idx)
{
WARN(!(wdev->key_map & BIT(idx)), "inconsistent key allocation");
memset(&wdev->keys[idx], 0, sizeof(wdev->keys[idx]));
wdev->key_map &= ~BIT(idx);
}
......@@ -160,7 +158,7 @@ static int wfx_add_key(struct wfx_vif *wvif, struct ieee80211_sta *sta,
struct ieee80211_key_conf *key)
{
int ret;
struct hif_req_add_key *k;
struct hif_req_add_key k = { };
struct ieee80211_key_seq seq;
struct wfx_dev *wdev = wvif->wdev;
int idx = wfx_alloc_key(wvif->wdev);
......@@ -170,44 +168,44 @@ static int wfx_add_key(struct wfx_vif *wvif, struct ieee80211_sta *sta,
ieee80211_get_key_rx_seq(key, 0, &seq);
if (idx < 0)
return -EINVAL;
k = &wdev->keys[idx];
k->int_id = wvif->id;
k.int_id = wvif->id;
k.entry_index = idx;
if (key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
key->cipher == WLAN_CIPHER_SUITE_WEP104) {
if (pairwise)
k->type = fill_wep_pair(&k->key.wep_pairwise_key, key,
sta->addr);
k.type = fill_wep_pair(&k.key.wep_pairwise_key, key,
sta->addr);
else
k->type = fill_wep_group(&k->key.wep_group_key, key);
k.type = fill_wep_group(&k.key.wep_group_key, key);
} else if (key->cipher == WLAN_CIPHER_SUITE_TKIP) {
if (pairwise)
k->type = fill_tkip_pair(&k->key.tkip_pairwise_key, key,
sta->addr);
k.type = fill_tkip_pair(&k.key.tkip_pairwise_key, key,
sta->addr);
else
k->type = fill_tkip_group(&k->key.tkip_group_key, key,
&seq, wvif->vif->type);
k.type = fill_tkip_group(&k.key.tkip_group_key, key,
&seq, wvif->vif->type);
} else if (key->cipher == WLAN_CIPHER_SUITE_CCMP) {
if (pairwise)
k->type = fill_ccmp_pair(&k->key.aes_pairwise_key, key,
sta->addr);
k.type = fill_ccmp_pair(&k.key.aes_pairwise_key, key,
sta->addr);
else
k->type = fill_ccmp_group(&k->key.aes_group_key, key,
&seq);
k.type = fill_ccmp_group(&k.key.aes_group_key, key,
&seq);
} else if (key->cipher == WLAN_CIPHER_SUITE_SMS4) {
if (pairwise)
k->type = fill_sms4_pair(&k->key.wapi_pairwise_key, key,
sta->addr);
k.type = fill_sms4_pair(&k.key.wapi_pairwise_key, key,
sta->addr);
else
k->type = fill_sms4_group(&k->key.wapi_group_key, key);
k.type = fill_sms4_group(&k.key.wapi_group_key, key);
} else if (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC) {
k->type = fill_aes_cmac_group(&k->key.igtk_group_key, key,
&seq);
k.type = fill_aes_cmac_group(&k.key.igtk_group_key, key,
&seq);
} else {
dev_warn(wdev->dev, "unsupported key type %d\n", key->cipher);
wfx_free_key(wdev, idx);
return -EOPNOTSUPP;
}
ret = hif_add_key(wdev, k);
ret = hif_add_key(wdev, &k);
if (ret) {
wfx_free_key(wdev, idx);
return -EOPNOTSUPP;
......@@ -241,19 +239,3 @@ int wfx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
return ret;
}
int wfx_upload_keys(struct wfx_vif *wvif)
{
int i;
struct hif_req_add_key *key;
struct wfx_dev *wdev = wvif->wdev;
for (i = 0; i < ARRAY_SIZE(wdev->keys); i++) {
if (wdev->key_map & BIT(i)) {
key = &wdev->keys[i];
if (key->int_id == wvif->id)
hif_add_key(wdev, key);
}
}
return 0;
}
......@@ -16,6 +16,5 @@ struct wfx_vif;
int wfx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
struct ieee80211_vif *vif, struct ieee80211_sta *sta,
struct ieee80211_key_conf *key);
int wfx_upload_keys(struct wfx_vif *wvif);
#endif /* WFX_STA_H */
......@@ -378,9 +378,6 @@ static void wfx_do_join(struct wfx_vif *wvif)
else
wvif->state = WFX_STATE_PRE_STA;
/* Upload keys */
wfx_upload_keys(wvif);
/* Due to beacon filtering it is possible that the
* AP's beacon is not known for the mac80211 stack.
* Disable filtering temporary to make sure the stack
......@@ -457,7 +454,6 @@ int wfx_start_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
{
struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
wfx_upload_keys(wvif);
wvif->state = WFX_STATE_AP;
wfx_upload_ap_templates(wvif);
hif_start(wvif, &vif->bss_conf, wvif->channel);
......
......@@ -56,7 +56,6 @@ struct wfx_dev {
atomic_t packet_id;
u32 key_map;
struct hif_req_add_key keys[MAX_KEY_ENTRIES];
struct hif_rx_stats rx_stats;
struct mutex rx_stats_lock;
......
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