OSDN Git Service

iwlwifi: mvm: support new KEK KCK api
authorNathan Errera <nathan.errera@intel.com>
Mon, 28 Sep 2020 09:23:15 +0000 (12:23 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Thu, 1 Oct 2020 18:59:35 +0000 (21:59 +0300)
Add a new version to iwl_wowlan_kek_kck_material_cmd
struct to support akm and send the new cmd if supported.

Signed-off-by: Nathan Errera <nathan.errera@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200928121852.6ec5889d793d.I32ad41a27f046a4047cf852c83936142fca4f20b@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/api/d3.h
drivers/net/wireless/intel/iwlwifi/mvm/d3.c

index 9525843..cc7f899 100644 (file)
@@ -493,7 +493,7 @@ struct iwl_wowlan_tkip_params_cmd {
 #define IWL_KCK_MAX_SIZE       32
 #define IWL_KEK_MAX_SIZE       32
 
-struct iwl_wowlan_kek_kck_material_cmd {
+struct iwl_wowlan_kek_kck_material_cmd_v2 {
        u8      kck[IWL_KCK_MAX_SIZE];
        u8      kek[IWL_KEK_MAX_SIZE];
        __le16  kck_len;
@@ -501,6 +501,18 @@ struct iwl_wowlan_kek_kck_material_cmd {
        __le64  replay_ctr;
 } __packed; /* KEK_KCK_MATERIAL_API_S_VER_2 */
 
+struct iwl_wowlan_kek_kck_material_cmd_v3 {
+       u8      kck[IWL_KCK_MAX_SIZE];
+       u8      kek[IWL_KEK_MAX_SIZE];
+       __le16  kck_len;
+       __le16  kek_len;
+       __le64  replay_ctr;
+       __le32  akm;
+       __le32  gtk_cipher;
+       __le32  igtk_cipher;
+       __le32  bigtk_cipher;
+} __packed; /* KEK_KCK_MATERIAL_API_S_VER_3 */
+
 #define RF_KILL_INDICATOR_FOR_WOWLAN   0x87
 
 enum iwl_wowlan_rekey_status {
index d7e8872..3a1e5ac 100644 (file)
@@ -70,6 +70,7 @@
 #include "iwl-modparams.h"
 #include "fw-api.h"
 #include "mvm.h"
+#include "fw/img.h"
 
 void iwl_mvm_set_rekey_data(struct ieee80211_hw *hw,
                            struct ieee80211_vif *vif,
@@ -739,7 +740,7 @@ static int iwl_mvm_wowlan_config_key_params(struct iwl_mvm *mvm,
                                            struct ieee80211_vif *vif,
                                            u32 cmd_flags)
 {
-       struct iwl_wowlan_kek_kck_material_cmd kek_kck_cmd = {};
+       struct iwl_wowlan_kek_kck_material_cmd_v3 kek_kck_cmd = {};
        struct iwl_wowlan_tkip_params_cmd tkip_cmd = {};
        bool unified = fw_has_capa(&mvm->fw->ucode_capa,
                                   IWL_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG);
@@ -751,6 +752,8 @@ static int iwl_mvm_wowlan_config_key_params(struct iwl_mvm *mvm,
        };
        struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
        int ret;
+       u8 cmd_ver;
+       size_t cmd_size;
 
        key_data.rsc_tsc = kzalloc(sizeof(*key_data.rsc_tsc), GFP_KERNEL);
        if (!key_data.rsc_tsc)
@@ -833,6 +836,16 @@ static int iwl_mvm_wowlan_config_key_params(struct iwl_mvm *mvm,
 
        /* configure rekey data only if offloaded rekey is supported (d3) */
        if (mvmvif->rekey_data.valid) {
+               cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, IWL_ALWAYS_LONG_GROUP,
+                                               WOWLAN_KEK_KCK_MATERIAL);
+               if (WARN_ON(cmd_ver != 2 && cmd_ver != 3 &&
+                           cmd_ver != IWL_FW_CMD_VER_UNKNOWN))
+                       return -EINVAL;
+               if (cmd_ver == 3)
+                       cmd_size = sizeof(struct iwl_wowlan_kek_kck_material_cmd_v3);
+               else
+                       cmd_size = sizeof(struct iwl_wowlan_kek_kck_material_cmd_v2);
+
                memset(&kek_kck_cmd, 0, sizeof(kek_kck_cmd));
                memcpy(kek_kck_cmd.kck, mvmvif->rekey_data.kck,
                       NL80211_KCK_LEN);
@@ -844,7 +857,7 @@ static int iwl_mvm_wowlan_config_key_params(struct iwl_mvm *mvm,
 
                ret = iwl_mvm_send_cmd_pdu(mvm,
                                           WOWLAN_KEK_KCK_MATERIAL, cmd_flags,
-                                          sizeof(kek_kck_cmd),
+                                          cmd_size,
                                           &kek_kck_cmd);
                if (ret)
                        goto out;