linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: gregory.greenman@intel.com
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org,
	Johannes Berg <johannes.berg@intel.com>,
	Gregory Greenman <gregory.greenman@intel.com>
Subject: [PATCH 05/18] wifi: iwlwifi: mvm: enable TX beacon protection
Date: Mon, 20 Mar 2023 12:33:06 +0200	[thread overview]
Message-ID: <20230320122330.6a90a4f4f469.Ia028dea75f9a8eed40786d876d51f97fb3142688@changeid> (raw)
In-Reply-To: <20230320103319.1309442-1-gregory.greenman@intel.com>

From: Johannes Berg <johannes.berg@intel.com>

Check hardware/firmware support and enable TX beacon protection
as well if supported, programming the key into the firmware as
usual.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/fw/file.h  |  1 +
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 30 ++++++++++++++-----
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/file.h b/drivers/net/wireless/intel/iwlwifi/fw/file.h
index 1c47046e8f69..f2eefca6e260 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/file.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/file.h
@@ -457,6 +457,7 @@ enum iwl_ucode_tlv_capa {
 	IWL_UCODE_TLV_CAPA_DUMP_COMPLETE_SUPPORT	= (__force iwl_ucode_tlv_capa_t)105,
 	IWL_UCODE_TLV_CAPA_SYNCED_TIME			= (__force iwl_ucode_tlv_capa_t)106,
 	IWL_UCODE_TLV_CAPA_TIME_SYNC_BOTH_FTM_TM        = (__force iwl_ucode_tlv_capa_t)108,
+	IWL_UCODE_TLV_CAPA_BIGTK_TX_SUPPORT		= (__force iwl_ucode_tlv_capa_t)109,
 
 #ifdef __CHECKER__
 	/* sparse says it cannot increment the previous enum member */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index 7ee8d24606a2..99a51d519214 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -280,6 +280,8 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
 	bool unified = fw_has_capa(&mvm->fw->ucode_capa,
 				   IWL_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG);
 #endif
+	u32 sec_key_id = WIDE_ID(DATA_PATH_GROUP, SEC_KEY_CMD);
+	u8 sec_key_ver = iwl_fw_lookup_cmd_ver(mvm->fw, sec_key_id, 0);
 
 	/* Tell mac80211 our characteristics */
 	ieee80211_hw_set(hw, SIGNAL_DBM);
@@ -404,8 +406,13 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
 		hw->wiphy->pmsr_capa = &iwl_mvm_pmsr_capa;
 	}
 
-	if (fw_has_capa(&mvm->fw->ucode_capa,
-			IWL_UCODE_TLV_CAPA_BIGTK_SUPPORT))
+	if (sec_key_ver &&
+	    fw_has_capa(&mvm->fw->ucode_capa,
+			IWL_UCODE_TLV_CAPA_BIGTK_TX_SUPPORT))
+		wiphy_ext_feature_set(hw->wiphy,
+				      NL80211_EXT_FEATURE_BEACON_PROTECTION);
+	else if (fw_has_capa(&mvm->fw->ucode_capa,
+			     IWL_UCODE_TLV_CAPA_BIGTK_SUPPORT))
 		wiphy_ext_feature_set(hw->wiphy,
 				      NL80211_EXT_FEATURE_BEACON_PROTECTION_CLIENT);
 
@@ -3778,7 +3785,8 @@ static int __iwl_mvm_mac_set_key(struct ieee80211_hw *hw,
 
 	switch (cmd) {
 	case SET_KEY:
-		if (keyidx == 6 || keyidx == 7)
+		if (vif->type == NL80211_IFTYPE_STATION &&
+		    (keyidx == 6 || keyidx == 7))
 			rcu_assign_pointer(mvmvif->bcn_prot.keys[keyidx - 6],
 					   key);
 
@@ -3789,10 +3797,14 @@ static int __iwl_mvm_mac_set_key(struct ieee80211_hw *hw,
 			 * on IBSS they're per-station and because we're lazy
 			 * we don't support them for RX, so do the same.
 			 * CMAC/GMAC in AP/IBSS modes must be done in software.
+			 *
+			 * Except, of course, beacon protection - it must be
+			 * offloaded since we just set a beacon template.
 			 */
-			if (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC ||
-			    key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 ||
-			    key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256) {
+			if (keyidx < 6 &&
+			    (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC ||
+			     key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 ||
+			     key->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256)) {
 				ret = -EOPNOTSUPP;
 				break;
 			}
@@ -3873,7 +3885,8 @@ static int __iwl_mvm_mac_set_key(struct ieee80211_hw *hw,
 		if (mvmsta && key->flags & IEEE80211_KEY_FLAG_PAIRWISE)
 			mvmsta->pairwise_cipher = key->cipher;
 
-		IWL_DEBUG_MAC80211(mvm, "set hwcrypto key\n");
+		IWL_DEBUG_MAC80211(mvm, "set hwcrypto key (sta:%pM, id:%d)\n",
+				   sta ? sta->addr : NULL, key->keyidx);
 
 		if (sec_key_ver)
 			ret = iwl_mvm_sec_key_add(mvm, vif, sta, key);
@@ -3897,7 +3910,8 @@ static int __iwl_mvm_mac_set_key(struct ieee80211_hw *hw,
 
 		break;
 	case DISABLE_KEY:
-		if (keyidx == 6 || keyidx == 7)
+		if (vif->type == NL80211_IFTYPE_STATION &&
+		    (keyidx == 6 || keyidx == 7))
 			RCU_INIT_POINTER(mvmvif->bcn_prot.keys[keyidx - 6],
 					 NULL);
 
-- 
2.38.1


  parent reply	other threads:[~2023-03-20 10:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20 10:33 [PATCH 00/18] wifi: iwlwifi: updates intended for v6.4 2023-03-24 gregory.greenman
2023-03-20 10:33 ` [PATCH 01/18] wifi: iwlwifi: mvm: add support for PTP HW clock (PHC) gregory.greenman
2023-03-20 10:33 ` [PATCH 02/18] wifi: iwlwifi: mvm: read synced time from firmware if supported gregory.greenman
2023-03-20 10:33 ` [PATCH 03/18] wifi: iwlwifi: mvm: report hardware timestamps in RX/TX status gregory.greenman
2023-03-31 17:51   ` Nathan Chancellor
2023-04-10 14:12     ` Greenman, Gregory
2023-03-20 10:33 ` [PATCH 04/18] wifi: iwlwifi: mvm: add support for timing measurement gregory.greenman
2023-03-20 10:33 ` gregory.greenman [this message]
2023-03-20 10:33 ` [PATCH 06/18] wifi: iwlwifi: mvm: implement PHC clock adjustments gregory.greenman
2023-03-20 10:33 ` [PATCH 07/18] wifi: iwlwifi: mvm: select ptp cross timestamp from multiple reads gregory.greenman
2023-03-20 10:33 ` [PATCH 08/18] wifi: iwlwifi: mvm: add start_ap() and join_ibss() callbacks for MLD mode gregory.greenman
2023-03-20 10:33 ` [PATCH 09/18] wifi: iwlwifi: mvm: add stop_ap() and leave_ibss() " gregory.greenman
2023-03-20 10:33 ` [PATCH 10/18] wifi: iwlwifi: mvm: Don't send MAC CTXT cmd after deauthorization gregory.greenman
2023-03-20 10:33 ` [PATCH 11/18] wifi: iwlwifi: mvm: refactor iwl_mvm_cfg_he_sta() gregory.greenman
2023-03-20 10:33 ` [PATCH 12/18] wifi: iwlwifi: mvm: refactor iwl_mvm_sta gregory.greenman
2023-03-20 10:33 ` [PATCH 13/18] wifi: iwlwifi: mvm: refactor iwl_mvm_sta_send_to_fw() gregory.greenman
2023-03-20 10:33 ` [PATCH 14/18] wifi: iwlwifi: mvm: remove not needed initializations gregory.greenman
2023-03-20 10:33 ` [PATCH 15/18] wifi: iwlwifi: mvm: refactor iwl_mvm_add_sta(), iwl_mvm_rm_sta() gregory.greenman
2023-03-20 10:33 ` [PATCH 16/18] wifi: iwlwifi: Update configurations for Bnj device gregory.greenman
2023-03-20 10:33 ` [PATCH 17/18] wifi: iwlwifi: mvm: support enabling and disabling HW timestamping gregory.greenman
2023-03-20 10:33 ` [PATCH 18/18] iwlwifi: mvm: Add debugfs to get TAS status gregory.greenman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230320122330.6a90a4f4f469.Ia028dea75f9a8eed40786d876d51f97fb3142688@changeid \
    --to=gregory.greenman@intel.com \
    --cc=johannes.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).