From patchwork Mon Dec 21 20:50:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emmanuel Grumbach X-Patchwork-Id: 7898091 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B498C9F32E for ; Mon, 21 Dec 2015 20:52:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D60822026C for ; Mon, 21 Dec 2015 20:52:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CB15F205BB for ; Mon, 21 Dec 2015 20:52:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752039AbbLUUwe (ORCPT ); Mon, 21 Dec 2015 15:52:34 -0500 Received: from mga03.intel.com ([134.134.136.65]:53947 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752027AbbLUUwb (ORCPT ); Mon, 21 Dec 2015 15:52:31 -0500 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 21 Dec 2015 12:52:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,461,1444719600"; d="scan'208";a="621796588" Received: from aidesis-mobl2.ger.corp.intel.com (HELO egrumbacBOX.ger.corp.intel.com) ([10.255.206.60]) by FMSMGA003.fm.intel.com with ESMTP; 21 Dec 2015 12:52:29 -0800 From: Emmanuel Grumbach To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Emmanuel Grumbach Subject: [PATCH 36/45] iwlwifi: mvm: change iwl_mvm_get_key_sta_id() to return the station Date: Mon, 21 Dec 2015 22:50:37 +0200 Message-Id: <1450731046-2796-36-git-send-email-emmanuel.grumbach@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <0BA3FCBA62E2DC44AF3030971E174FB32E949792@hasmsx107.ger.corp.intel.com> References: <0BA3FCBA62E2DC44AF3030971E174FB32E949792@hasmsx107.ger.corp.intel.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Johannes Berg The code in iwl_mvm_update_tkip_key() is now pretty much duplicated with the code in iwl_mvm_get_key_sta_id() doing the station ID lookup again after it was already done. Change iwl_mvm_get_key_sta_id() to iwl_mvm_get_key_sta(), returning the mvm_sta pointer, to allow that duplicate code to be removed. Signed-off-by: Johannes Berg Signed-off-by: Emmanuel Grumbach --- drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 53 ++++++++++++---------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c index bfa4699..2c9675b 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c @@ -1228,17 +1228,14 @@ static int iwl_mvm_set_fw_key_idx(struct iwl_mvm *mvm) return max_offs; } -static u8 iwl_mvm_get_key_sta_id(struct iwl_mvm *mvm, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta) +static struct iwl_mvm_sta *iwl_mvm_get_key_sta(struct iwl_mvm *mvm, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta) { struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); - if (sta) { - struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta); - - return mvm_sta->sta_id; - } + if (sta) + return iwl_mvm_sta_from_mac80211(sta); /* * The device expects GTKs for station interfaces to be @@ -1257,12 +1254,12 @@ static u8 iwl_mvm_get_key_sta_id(struct iwl_mvm *mvm, * be the AP ID, and no station was passed by mac80211. */ if (IS_ERR_OR_NULL(sta)) - return IWL_MVM_STATION_COUNT; + return NULL; - return sta_id; + return iwl_mvm_sta_from_mac80211(sta); } - return IWL_MVM_STATION_COUNT; + return NULL; } static int iwl_mvm_send_sta_key(struct iwl_mvm *mvm, @@ -1479,6 +1476,7 @@ int iwl_mvm_set_sta_key(struct iwl_mvm *mvm, u8 key_offset) { bool mcast = !(keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE); + struct iwl_mvm_sta *mvm_sta; u8 sta_id; int ret; static const u8 __maybe_unused zero_addr[ETH_ALEN] = {0}; @@ -1486,11 +1484,12 @@ int iwl_mvm_set_sta_key(struct iwl_mvm *mvm, lockdep_assert_held(&mvm->mutex); /* Get the station id from the mvm local station table */ - sta_id = iwl_mvm_get_key_sta_id(mvm, vif, sta); - if (sta_id == IWL_MVM_STATION_COUNT) { - IWL_ERR(mvm, "Failed to find station id\n"); + mvm_sta = iwl_mvm_get_key_sta(mvm, vif, sta); + if (!mvm_sta) { + IWL_ERR(mvm, "Failed to find station\n"); return -EINVAL; } + sta_id = mvm_sta->sta_id; if (keyconf->cipher == WLAN_CIPHER_SUITE_AES_CMAC) { ret = iwl_mvm_send_sta_igtk(mvm, keyconf, sta_id, false); @@ -1566,13 +1565,14 @@ int iwl_mvm_remove_sta_key(struct iwl_mvm *mvm, struct ieee80211_key_conf *keyconf) { bool mcast = !(keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE); - u8 sta_id; + struct iwl_mvm_sta *mvm_sta; + u8 sta_id = IWL_MVM_STATION_COUNT; int ret, i; lockdep_assert_held(&mvm->mutex); - /* Get the station id from the mvm local station table */ - sta_id = iwl_mvm_get_key_sta_id(mvm, vif, sta); + /* Get the station from the mvm local station table */ + mvm_sta = iwl_mvm_get_key_sta(mvm, vif, sta); IWL_DEBUG_WEP(mvm, "mvm remove dynamic key: idx=%d sta=%d\n", keyconf->keyidx, sta_id); @@ -1593,11 +1593,13 @@ int iwl_mvm_remove_sta_key(struct iwl_mvm *mvm, } mvm->fw_key_deleted[keyconf->hw_key_idx] = 0; - if (sta_id == IWL_MVM_STATION_COUNT) { + if (!mvm_sta) { IWL_DEBUG_WEP(mvm, "station non-existent, early return.\n"); return 0; } + sta_id = mvm_sta->sta_id; + ret = __iwl_mvm_remove_sta_key(mvm, sta_id, keyconf, mcast); if (ret) return ret; @@ -1617,24 +1619,13 @@ void iwl_mvm_update_tkip_key(struct iwl_mvm *mvm, u16 *phase1key) { struct iwl_mvm_sta *mvm_sta; - u8 sta_id; bool mcast = !(keyconf->flags & IEEE80211_KEY_FLAG_PAIRWISE); rcu_read_lock(); - sta_id = iwl_mvm_get_key_sta_id(mvm, vif, sta); - if (WARN_ON_ONCE(sta_id == IWL_MVM_STATION_COUNT)) + mvm_sta = iwl_mvm_get_key_sta(mvm, vif, sta); + if (WARN_ON_ONCE(!mvm_sta)) goto unlock; - - if (!sta) { - sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); - if (WARN_ON(IS_ERR_OR_NULL(sta))) { - rcu_read_unlock(); - return; - } - } - - mvm_sta = iwl_mvm_sta_from_mac80211(sta); iwl_mvm_send_sta_key(mvm, mvm_sta, keyconf, mcast, iv32, phase1key, CMD_ASYNC, keyconf->hw_key_idx);