···6969#include "iwl-agn-hw.h"70707171/* Highest firmware API version supported */7272-#define IWL7260_UCODE_API_MAX 177272+#define IWL7260_UCODE_API_MAX 1973737474/* Oldest version we won't warn about */7575#define IWL7260_UCODE_API_OK 13
+1-1
drivers/net/wireless/intel/iwlwifi/iwl-8000.c
···6969#include "iwl-agn-hw.h"70707171/* Highest firmware API version supported */7272-#define IWL8000_UCODE_API_MAX 177272+#define IWL8000_UCODE_API_MAX 1973737474/* Oldest version we won't warn about */7575#define IWL8000_UCODE_API_OK 13
+2-6
drivers/net/wireless/intel/iwlwifi/mvm/d3.c
···309309 * to transmit packets to the AP, i.e. the PTK.310310 */311311 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) {312312- key->hw_key_idx = 0;313312 mvm->ptk_ivlen = key->iv_len;314313 mvm->ptk_icvlen = key->icv_len;314314+ ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, 0);315315 } else {316316 /*317317 * firmware only supports TSC/RSC for a single key,···319319 * with new ones -- this relies on mac80211 doing320320 * list_add_tail().321321 */322322- key->hw_key_idx = 1;323322 mvm->gtk_ivlen = key->iv_len;324323 mvm->gtk_icvlen = key->icv_len;324324+ ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, 1);325325 }326326327327- ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, true);328327 data->error = ret != 0;329328out_unlock:330329 mutex_unlock(&mvm->mutex);···770771 * back to the runtime firmware image.771772 */772773 set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);773773-774774- /* We reprogram keys and shouldn't allocate new key indices */775775- memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table));776774777775 mvm->ptk_ivlen = 0;778776 mvm->ptk_icvlen = 0;
+8-3
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
···29412941{29422942 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);29432943 int ret;29442944+ u8 key_offset;2944294529452946 if (iwlwifi_mod_params.sw_crypto) {29462947 IWL_DEBUG_MAC80211(mvm, "leave - hwcrypto disabled\n");···30073006 break;30083007 }3009300830093009+ /* in HW restart reuse the index, otherwise request a new one */30103010+ if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))30113011+ key_offset = key->hw_key_idx;30123012+ else30133013+ key_offset = STA_KEY_IDX_INVALID;30143014+30103015 IWL_DEBUG_MAC80211(mvm, "set hwcrypto key\n");30113011- ret = iwl_mvm_set_sta_key(mvm, vif, sta, key,30123012- test_bit(IWL_MVM_STATUS_IN_HW_RESTART,30133013- &mvm->status));30163016+ ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, key_offset);30143017 if (ret) {30153018 IWL_WARN(mvm, "set key failed\n");30163019 /*
+47-41
drivers/net/wireless/intel/iwlwifi/mvm/sta.c
···12011201 return max_offs;12021202}1203120312041204-static u8 iwl_mvm_get_key_sta_id(struct ieee80211_vif *vif,12041204+static u8 iwl_mvm_get_key_sta_id(struct iwl_mvm *mvm,12051205+ struct ieee80211_vif *vif,12051206 struct ieee80211_sta *sta)12061207{12071208 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);···12191218 * station ID, then use AP's station ID.12201219 */12211220 if (vif->type == NL80211_IFTYPE_STATION &&12221222- mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT)12231223- return mvmvif->ap_sta_id;12211221+ mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) {12221222+ u8 sta_id = mvmvif->ap_sta_id;12231223+12241224+ sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],12251225+ lockdep_is_held(&mvm->mutex));12261226+ /*12271227+ * It is possible that the 'sta' parameter is NULL,12281228+ * for example when a GTK is removed - the sta_id will then12291229+ * be the AP ID, and no station was passed by mac80211.12301230+ */12311231+ if (IS_ERR_OR_NULL(sta))12321232+ return IWL_MVM_STATION_COUNT;12331233+12341234+ return sta_id;12351235+ }1224123612251237 return IWL_MVM_STATION_COUNT;12261238}···12411227static int iwl_mvm_send_sta_key(struct iwl_mvm *mvm,12421228 struct iwl_mvm_sta *mvm_sta,12431229 struct ieee80211_key_conf *keyconf, bool mcast,12441244- u32 tkip_iv32, u16 *tkip_p1k, u32 cmd_flags)12301230+ u32 tkip_iv32, u16 *tkip_p1k, u32 cmd_flags,12311231+ u8 key_offset)12451232{12461233 struct iwl_mvm_add_sta_key_cmd cmd = {};12471234 __le16 key_flags;···12841269 if (mcast)12851270 key_flags |= cpu_to_le16(STA_KEY_MULTICAST);1286127112871287- cmd.key_offset = keyconf->hw_key_idx;12721272+ cmd.key_offset = key_offset;12881273 cmd.key_flags = key_flags;12891274 cmd.sta_id = sta_id;12901275···13751360 struct ieee80211_vif *vif,13761361 struct ieee80211_sta *sta,13771362 struct ieee80211_key_conf *keyconf,13631363+ u8 key_offset,13781364 bool mcast)13791365{13801366 struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta);···13911375 ieee80211_get_key_rx_seq(keyconf, 0, &seq);13921376 ieee80211_get_tkip_rx_p1k(keyconf, addr, seq.tkip.iv32, p1k);13931377 ret = iwl_mvm_send_sta_key(mvm, mvm_sta, keyconf, mcast,13941394- seq.tkip.iv32, p1k, 0);13781378+ seq.tkip.iv32, p1k, 0, key_offset);13951379 break;13961380 case WLAN_CIPHER_SUITE_CCMP:13971381 case WLAN_CIPHER_SUITE_WEP40:13981382 case WLAN_CIPHER_SUITE_WEP104:13991383 ret = iwl_mvm_send_sta_key(mvm, mvm_sta, keyconf, mcast,14001400- 0, NULL, 0);13841384+ 0, NULL, 0, key_offset);14011385 break;14021386 default:14031387 ret = iwl_mvm_send_sta_key(mvm, mvm_sta, keyconf, mcast,14041404- 0, NULL, 0);13881388+ 0, NULL, 0, key_offset);14051389 }1406139014071391 return ret;···14491433 struct ieee80211_vif *vif,14501434 struct ieee80211_sta *sta,14511435 struct ieee80211_key_conf *keyconf,14521452- bool have_key_offset)14361436+ u8 key_offset)14531437{14541438 bool mcast = !(keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE);14551439 u8 sta_id;···14591443 lockdep_assert_held(&mvm->mutex);1460144414611445 /* Get the station id from the mvm local station table */14621462- sta_id = iwl_mvm_get_key_sta_id(vif, sta);14461446+ sta_id = iwl_mvm_get_key_sta_id(mvm, vif, sta);14631447 if (sta_id == IWL_MVM_STATION_COUNT) {14641448 IWL_ERR(mvm, "Failed to find station id\n");14651449 return -EINVAL;···14861470 if (WARN_ON_ONCE(iwl_mvm_sta_from_mac80211(sta)->vif != vif))14871471 return -EINVAL;1488147214891489- if (!have_key_offset) {14901490- /*14911491- * The D3 firmware hardcodes the PTK offset to 0, so we have to14921492- * configure it there. As a result, this workaround exists to14931493- * let the caller set the key offset (hw_key_idx), see d3.c.14941494- */14951495- keyconf->hw_key_idx = iwl_mvm_set_fw_key_idx(mvm);14961496- if (keyconf->hw_key_idx == STA_KEY_IDX_INVALID)14731473+ /* If the key_offset is not pre-assigned, we need to find a14741474+ * new offset to use. In normal cases, the offset is not14751475+ * pre-assigned, but during HW_RESTART we want to reuse the14761476+ * same indices, so we pass them when this function is called.14771477+ *14781478+ * In D3 entry, we need to hardcoded the indices (because the14791479+ * firmware hardcodes the PTK offset to 0). In this case, we14801480+ * need to make sure we don't overwrite the hw_key_idx in the14811481+ * keyconf structure, because otherwise we cannot configure14821482+ * the original ones back when resuming.14831483+ */14841484+ if (key_offset == STA_KEY_IDX_INVALID) {14851485+ key_offset = iwl_mvm_set_fw_key_idx(mvm);14861486+ if (key_offset == STA_KEY_IDX_INVALID)14971487 return -ENOSPC;14881488+ keyconf->hw_key_idx = key_offset;14981489 }1499149015001500- ret = __iwl_mvm_set_sta_key(mvm, vif, sta, keyconf, mcast);14911491+ ret = __iwl_mvm_set_sta_key(mvm, vif, sta, keyconf, key_offset, mcast);15011492 if (ret) {15021493 __clear_bit(keyconf->hw_key_idx, mvm->fw_key_table);15031494 goto end;···15181495 */15191496 if (keyconf->cipher == WLAN_CIPHER_SUITE_WEP40 ||15201497 keyconf->cipher == WLAN_CIPHER_SUITE_WEP104) {15211521- ret = __iwl_mvm_set_sta_key(mvm, vif, sta, keyconf, !mcast);14981498+ ret = __iwl_mvm_set_sta_key(mvm, vif, sta, keyconf,14991499+ key_offset, !mcast);15221500 if (ret) {15231501 __clear_bit(keyconf->hw_key_idx, mvm->fw_key_table);15241502 __iwl_mvm_remove_sta_key(mvm, sta_id, keyconf, mcast);···15451521 lockdep_assert_held(&mvm->mutex);1546152215471523 /* Get the station id from the mvm local station table */15481548- sta_id = iwl_mvm_get_key_sta_id(vif, sta);15241524+ sta_id = iwl_mvm_get_key_sta_id(mvm, vif, sta);1549152515501526 IWL_DEBUG_WEP(mvm, "mvm remove dynamic key: idx=%d sta=%d\n",15511527 keyconf->keyidx, sta_id);···15711547 return 0;15721548 }1573154915741574- /*15751575- * It is possible that the 'sta' parameter is NULL, and thus15761576- * there is a need to retrieve the sta from the local station table,15771577- * for example when a GTK is removed (where the sta_id will then be15781578- * the AP ID, and no station was passed by mac80211.)15791579- */15801580- if (!sta) {15811581- sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],15821582- lockdep_is_held(&mvm->mutex));15831583- if (!sta) {15841584- IWL_ERR(mvm, "Invalid station id\n");15851585- return -EINVAL;15861586- }15871587- }15881588-15891589- if (WARN_ON_ONCE(iwl_mvm_sta_from_mac80211(sta)->vif != vif))15901590- return -EINVAL;15911591-15921550 ret = __iwl_mvm_remove_sta_key(mvm, sta_id, keyconf, mcast);15931551 if (ret)15941552 return ret;···15901584 u16 *phase1key)15911585{15921586 struct iwl_mvm_sta *mvm_sta;15931593- u8 sta_id = iwl_mvm_get_key_sta_id(vif, sta);15871587+ u8 sta_id = iwl_mvm_get_key_sta_id(mvm, vif, sta);15941588 bool mcast = !(keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE);1595158915961590 if (WARN_ON_ONCE(sta_id == IWL_MVM_STATION_COUNT))···1608160216091603 mvm_sta = iwl_mvm_sta_from_mac80211(sta);16101604 iwl_mvm_send_sta_key(mvm, mvm_sta, keyconf, mcast,16111611- iv32, phase1key, CMD_ASYNC);16051605+ iv32, phase1key, CMD_ASYNC, keyconf->hw_key_idx);16121606 rcu_read_unlock();16131607}16141608