]> git.baikalelectronics.ru Git - kernel.git/commitdiff
staging: wfx: keys are kept during whole firmware life
authorJérôme Pouiller <jerome.pouiller@silabs.com>
Mon, 20 Apr 2020 16:03:06 +0000 (18:03 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Apr 2020 11:26:05 +0000 (13:26 +0200)
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: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-12-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wfx/key.c
drivers/staging/wfx/key.h
drivers/staging/wfx/sta.c
drivers/staging/wfx/wfx.h

index e3853cbf431cf831e52ff5f625595711bd0291b8..ceb57cbdfefd90e1d6de6631a6d705aa2447532f 100644 (file)
@@ -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;
-}
-
index 2c334f9fb2a8c187319d467ecbd7c007f0449537..ff31fc9c565a2ab82c38fb863daf1d08296d783a 100644 (file)
@@ -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 */
index 876952f39fc9bb86490703ad940ce0623354d6a4..56cb6fff4a06a31b88ebd1904d8fae66e249554b 100644 (file)
@@ -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);
index 0fa88de64907c0d218a0b0a9358ca6356c5228e9..354a62394db0508ca49453748ff0d774cfd545c9 100644 (file)
@@ -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;