Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp431873pxt; Thu, 5 Aug 2021 03:20:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKJFdeEx+pqXGEbh+zdsF6lOqIux5o3kwKTsHslSnhtjhlnw1W5x77sPzYHO109cWCtOBX X-Received: by 2002:a50:ec0a:: with SMTP id g10mr5544968edr.125.1628158856639; Thu, 05 Aug 2021 03:20:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628158856; cv=none; d=google.com; s=arc-20160816; b=q76wq/zHu7+zBUHWxRU2XKVAZ2IschzBwepnSz0xJd+PivjajXfh0VMhy2Sf3mJwgp Ydi1M0eiYNTPpSerNiixyWVfyKRyEUYyBS5OV6K+MKV67jrC3w1fhCsP/cIYne6GW16n ihqonohAXTPMLX3xucm2EgeACx46StmeXBphWJI4o9EpSXqVD5e/3Mnu0VBxN8cASU2N qaZO5y5GooFrZ2/6+cc2MhyzSGD/IEVVKtiFwTKJpTdyHpQKW7s/fliUAIvWASBoIFem awTBBcft5TjU3Ey9AVIpKhqbaiwqdzJx2sGok7S5e+ZreO++2v5JdcthSepQwSE74srb rX3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from; bh=Cjb4SZh7RM3LO68x1fFQKaGufdIQlIZaWH4mGePHU1Y=; b=UXngV+FK6xmv6dRrgIcAvA/5mYEjcbPC0vfsTdMh8UCvobcLY4z3j0qPWRxnHnDjiG q+r6FMG/saqsxp2InQkUv0Z+SoKxa0uqhEnnsviBqxVpoJo7np3vr+rrYE6cePSpfSLI Pfg13SrU4juQ2iP5i3Td7vLACV0XvMU69001sLHpufC6/rQEkD1ZJ+TY1hImc09jgGGS Ue+I6Gu9SK3ATGRPXP0EGqbDMpRvgb6xpn3Dg2FmNdy5Z43BGjZiBKVpsU68Uk/AbCqG SSR80HelplYljImBiO5VlpSDjL23jLKw4+pJTpNnNBdyU3c4JeThVyMSV6C6qQVuZ7dh Hxtg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w20si5265194eds.417.2021.08.05.03.20.33; Thu, 05 Aug 2021 03:20:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240220AbhHEKT7 (ORCPT + 99 others); Thu, 5 Aug 2021 06:19:59 -0400 Received: from paleale.coelho.fi ([176.9.41.70]:51224 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240199AbhHEKT5 (ORCPT ); Thu, 5 Aug 2021 06:19:57 -0400 Received: from 91-156-6-193.elisa-laajakaista.fi ([91.156.6.193] helo=kveik.lan) by farmhouse.coelho.fi with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1mBaTU-00240Q-8e; Thu, 05 Aug 2021 13:19:42 +0300 From: Luca Coelho To: kvalo@codeaurora.org Cc: luca@coelho.fi, linux-wireless@vger.kernel.org Date: Thu, 5 Aug 2021 13:19:27 +0300 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210805101934.431479-1-luca@coelho.fi> References: <20210805101934.431479-1-luca@coelho.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on farmhouse.coelho.fi X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, TVD_RCVD_IP autolearn=ham autolearn_force=no version=3.4.5-pre1 Subject: [PATCH 05/12] iwlwifi: mvm: d3: make key reprogramming iteration optional Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg Now that only reprogramming is left in the initial key iteration, skip it entirely on unified firmware images instead of skipping only the command sending inside of it. Signed-off-by: Johannes Berg Signed-off-by: Luca Coelho --- drivers/net/wireless/intel/iwlwifi/mvm/d3.c | 102 +++++++++----------- 1 file changed, 48 insertions(+), 54 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c index 61490f17a1fa..ad7308cc4b7f 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c @@ -101,8 +101,8 @@ static const u8 *iwl_mvm_find_max_pn(struct ieee80211_key_conf *key, return ret; } -struct wowlan_key_data { - bool error, configure_keys; +struct wowlan_key_reprogram_data { + bool error; int wep_key_idx; }; @@ -114,7 +114,7 @@ static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw, { struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); - struct wowlan_key_data *data = _data; + struct wowlan_key_reprogram_data *data = _data; int ret; switch (key->cipher) { @@ -152,18 +152,14 @@ static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw, wkc.wep_key.key_offset = data->wep_key_idx; } - if (data->configure_keys) { - mutex_lock(&mvm->mutex); - ret = iwl_mvm_send_cmd_pdu(mvm, WEP_KEY, 0, - sizeof(wkc), &wkc); - data->error = ret != 0; - - mvm->ptk_ivlen = key->iv_len; - mvm->ptk_icvlen = key->icv_len; - mvm->gtk_ivlen = key->iv_len; - mvm->gtk_icvlen = key->icv_len; - mutex_unlock(&mvm->mutex); - } + mutex_lock(&mvm->mutex); + ret = iwl_mvm_send_cmd_pdu(mvm, WEP_KEY, 0, sizeof(wkc), &wkc); + data->error = ret != 0; + + mvm->ptk_ivlen = key->iv_len; + mvm->ptk_icvlen = key->icv_len; + mvm->gtk_ivlen = key->iv_len; + mvm->gtk_icvlen = key->icv_len; /* don't upload key again */ return; @@ -190,30 +186,28 @@ static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw, break; } - if (data->configure_keys) { - mutex_lock(&mvm->mutex); + mutex_lock(&mvm->mutex); + /* + * The D3 firmware hardcodes the key offset 0 as the key it + * uses to transmit packets to the AP, i.e. the PTK. + */ + if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { + mvm->ptk_ivlen = key->iv_len; + mvm->ptk_icvlen = key->icv_len; + ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, 0); + } else { /* - * The D3 firmware hardcodes the key offset 0 as the key it - * uses to transmit packets to the AP, i.e. the PTK. + * firmware only supports TSC/RSC for a single key, + * so if there are multiple keep overwriting them + * with new ones -- this relies on mac80211 doing + * list_add_tail(). */ - if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { - mvm->ptk_ivlen = key->iv_len; - mvm->ptk_icvlen = key->icv_len; - ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, 0); - } else { - /* - * firmware only supports TSC/RSC for a single key, - * so if there are multiple keep overwriting them - * with new ones -- this relies on mac80211 doing - * list_add_tail(). - */ - mvm->gtk_ivlen = key->iv_len; - mvm->gtk_icvlen = key->icv_len; - ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, 1); - } - mutex_unlock(&mvm->mutex); - data->error = ret != 0; + mvm->gtk_ivlen = key->iv_len; + mvm->gtk_icvlen = key->icv_len; + ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, 1); } + mutex_unlock(&mvm->mutex); + data->error = ret != 0; } struct wowlan_key_rsc_tsc_data { @@ -839,30 +833,30 @@ static int iwl_mvm_wowlan_config_key_params(struct iwl_mvm *mvm, { bool unified = fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG); - struct wowlan_key_data key_data = { - .configure_keys = !unified, - }; + struct wowlan_key_reprogram_data key_data = {}; struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); int ret; u8 cmd_ver; size_t cmd_size; - /* - * if we have to configure keys, call ieee80211_iter_keys(), - * as we need non-atomic context in order to take the - * required locks. - */ - /* - * Note that currently we don't use CMD_ASYNC in the iterator. - * In case of key_data.configure_keys, all the configured commands - * are SYNC, and iwl_mvm_wowlan_program_keys() will take care of - * locking/unlocking mvm->mutex. - */ - ieee80211_iter_keys(mvm->hw, vif, iwl_mvm_wowlan_program_keys, - &key_data); + if (!unified) { + /* + * if we have to configure keys, call ieee80211_iter_keys(), + * as we need non-atomic context in order to take the + * required locks. + */ + /* + * Note that currently we don't use CMD_ASYNC in the iterator. + * In case of key_data.configure_keys, all the configured + * commands are SYNC, and iwl_mvm_wowlan_program_keys() will + * take care of locking/unlocking mvm->mutex. + */ + ieee80211_iter_keys(mvm->hw, vif, iwl_mvm_wowlan_program_keys, + &key_data); - if (key_data.error) - return -EIO; + if (key_data.error) + return -EIO; + } ret = iwl_mvm_wowlan_config_rsc_tsc(mvm, vif); if (ret) -- 2.32.0