Blob Blame History Raw
From f374231a3a0dcfb8c2c6d33b853b17700d899cc0 Mon Sep 17 00:00:00 2001
From: Eugene Syromiatnikov <esyr@redhat.com>
Date: Fri, 6 Sep 2019 01:52:09 +0200
Subject: [PATCH 4/7] Revert "iwlwifi: support new NVM response API"

This reverts commit 2785ce008e3b52b5a8f9a5bef68b8306d3e37b86.
---
 .../net/wireless/intel/iwlwifi/fw/api/nvm-reg.h    | 39 +++---------------
 drivers/net/wireless/intel/iwlwifi/fw/file.h       |  3 --
 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | 46 ++++++----------------
 3 files changed, 19 insertions(+), 69 deletions(-)

Index: src/drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h
===================================================================
--- src.orig/drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h	2019-06-27 14:54:04.121678482 +0200
+++ src/drivers/net/wireless/intel/iwlwifi/fw/api/nvm-reg.h	2019-09-06 01:58:30.665000571 +0200
@@ -8,7 +8,7 @@
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
- * Copyright(C) 2018 - 2019 Intel Corporation
+ * Copyright (C) 2018 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -31,7 +31,7 @@
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
- * Copyright(C) 2018 - 2019 Intel Corporation
+ * Copyright (C) 2018 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -233,8 +233,7 @@
 	__le32 rx_chains;
 } __packed; /* REGULATORY_NVM_GET_INFO_PHY_SKU_SECTION_S_VER_1 */
 
-#define IWL_NUM_CHANNELS_V1	51
-#define IWL_NUM_CHANNELS	110
+#define IWL_NUM_CHANNELS (51)
 
 /**
  * struct iwl_nvm_get_info_regulatory - regulatory information
@@ -242,39 +241,13 @@
  * @channel_profile: regulatory data of this channel
  * @reserved: reserved
  */
-struct iwl_nvm_get_info_regulatory_v1 {
+struct iwl_nvm_get_info_regulatory {
 	__le32 lar_enabled;
-	__le16 channel_profile[IWL_NUM_CHANNELS_V1];
+	__le16 channel_profile[IWL_NUM_CHANNELS];
 	__le16 reserved;
 } __packed; /* REGULATORY_NVM_GET_INFO_REGULATORY_S_VER_1 */
 
 /**
- * struct iwl_nvm_get_info_regulatory - regulatory information
- * @lar_enabled: is LAR enabled
- * @n_channels: number of valid channels in the array
- * @channel_profile: regulatory data of this channel
- */
-struct iwl_nvm_get_info_regulatory {
-	__le32 lar_enabled;
-	__le32 n_channels;
-	__le32 channel_profile[IWL_NUM_CHANNELS];
-} __packed; /* REGULATORY_NVM_GET_INFO_REGULATORY_S_VER_2 */
-
-/**
- * struct iwl_nvm_get_info_rsp_v3 - response to get NVM data
- * @general: general NVM data
- * @mac_sku: data relating to MAC sku
- * @phy_sku: data relating to PHY sku
- * @regulatory: regulatory data
- */
-struct iwl_nvm_get_info_rsp_v3 {
-	struct iwl_nvm_get_info_general general;
-	struct iwl_nvm_get_info_sku mac_sku;
-	struct iwl_nvm_get_info_phy phy_sku;
-	struct iwl_nvm_get_info_regulatory_v1 regulatory;
-} __packed; /* REGULATORY_NVM_GET_INFO_RSP_API_S_VER_3 */
-
-/**
  * struct iwl_nvm_get_info_rsp - response to get NVM data
  * @general: general NVM data
  * @mac_sku: data relating to MAC sku
@@ -286,7 +259,7 @@
 	struct iwl_nvm_get_info_sku mac_sku;
 	struct iwl_nvm_get_info_phy phy_sku;
 	struct iwl_nvm_get_info_regulatory regulatory;
-} __packed; /* REGULATORY_NVM_GET_INFO_RSP_API_S_VER_4 */
+} __packed; /* REGULATORY_NVM_GET_INFO_RSP_API_S_VER_3 */
 
 /**
  * struct iwl_nvm_access_complete_cmd - NVM_ACCESS commands are completed
Index: src/drivers/net/wireless/intel/iwlwifi/fw/file.h
===================================================================
--- src.orig/drivers/net/wireless/intel/iwlwifi/fw/file.h	2019-09-06 01:47:46.211297764 +0200
+++ src/drivers/net/wireless/intel/iwlwifi/fw/file.h	2019-09-06 01:58:30.666000559 +0200
@@ -275,8 +275,6 @@
  *	version of the beacon notification.
  * @IWL_UCODE_TLV_API_BEACON_FILTER_V4: This ucode supports v4 of
  *	BEACON_FILTER_CONFIG_API_S_VER_4.
- * @IWL_UCODE_TLV_API_REGULATORY_NVM_INFO: This ucode supports v4 of
- *	REGULATORY_NVM_GET_INFO_RSP_API_S.
  * @IWL_UCODE_TLV_API_FTM_NEW_RANGE_REQ: This ucode supports v7 of
  *	LOCATION_RANGE_REQ_CMD_API_S and v6 of LOCATION_RANGE_RESP_NTFY_API_S.
  * @IWL_UCODE_TLV_API_SCAN_OFFLOAD_CHANS: This ucode supports v2 of
@@ -308,7 +306,6 @@
 	IWL_UCODE_TLV_API_REDUCE_TX_POWER	= (__force iwl_ucode_tlv_api_t)45,
 	IWL_UCODE_TLV_API_SHORT_BEACON_NOTIF	= (__force iwl_ucode_tlv_api_t)46,
 	IWL_UCODE_TLV_API_BEACON_FILTER_V4      = (__force iwl_ucode_tlv_api_t)47,
-	IWL_UCODE_TLV_API_REGULATORY_NVM_INFO   = (__force iwl_ucode_tlv_api_t)48,
 	IWL_UCODE_TLV_API_FTM_NEW_RANGE_REQ     = (__force iwl_ucode_tlv_api_t)49,
 	IWL_UCODE_TLV_API_SCAN_OFFLOAD_CHANS    = (__force iwl_ucode_tlv_api_t)50,
 	IWL_UCODE_TLV_API_MBSSID_HE		= (__force iwl_ucode_tlv_api_t)52,
Index: src/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
===================================================================
--- src.orig/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c	2019-09-06 01:57:27.386815264 +0200
+++ src/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c	2019-09-06 01:58:30.666000559 +0200
@@ -226,7 +226,7 @@
 };
 
 static inline void iwl_nvm_print_channel_flags(struct device *dev, u32 level,
-					       int chan, u32 flags)
+					       int chan, u16 flags)
 {
 #define CHECK_AND_PRINT_I(x)	\
 	((flags & NVM_CHANNEL_##x) ? " " #x : "")
@@ -257,7 +257,7 @@
 }
 
 static u32 iwl_get_channel_flags(u8 ch_num, int ch_idx, bool is_5ghz,
-				 u32 nvm_flags, const struct iwl_cfg *cfg)
+				 u16 nvm_flags, const struct iwl_cfg *cfg)
 {
 	u32 flags = IEEE80211_CHAN_NO_HT40;
 
@@ -301,13 +301,13 @@
 
 static int iwl_init_channel_map(struct device *dev, const struct iwl_cfg *cfg,
 				struct iwl_nvm_data *data,
-				const void * const nvm_ch_flags,
-				u32 sbands_flags, bool v4)
+				const __le16 * const nvm_ch_flags,
+				u32 sbands_flags)
 {
 	int ch_idx;
 	int n_channels = 0;
 	struct ieee80211_channel *channel;
-	u32 ch_flags;
+	u16 ch_flags;
 	int num_of_ch, num_2ghz_channels = NUM_2GHZ_CHANNELS;
 	const u16 *nvm_chan;
 
@@ -325,12 +325,7 @@
 	for (ch_idx = 0; ch_idx < num_of_ch; ch_idx++) {
 		bool is_5ghz = (ch_idx >= num_2ghz_channels);
 
-		if (v4)
-			ch_flags =
-				__le32_to_cpup((__le32 *)nvm_ch_flags + ch_idx);
-		else
-			ch_flags =
-				__le16_to_cpup((__le16 *)nvm_ch_flags + ch_idx);
+		ch_flags = __le16_to_cpup(nvm_ch_flags + ch_idx);
 
 		if (is_5ghz && !data->sku_cap_band_52ghz_enable)
 			continue;
@@ -482,15 +477,15 @@
 
 static void iwl_init_sbands(struct device *dev, const struct iwl_cfg *cfg,
 			    struct iwl_nvm_data *data,
-			    const void *nvm_ch_flags, u8 tx_chains,
-			    u8 rx_chains, u32 sbands_flags, bool v4)
+			    const __le16 *nvm_ch_flags, u8 tx_chains,
+			    u8 rx_chains, u32 sbands_flags)
 {
 	int n_channels;
 	int n_used = 0;
 	struct ieee80211_supported_band *sband;
 
 	n_channels = iwl_init_channel_map(dev, cfg, data, nvm_ch_flags,
-					  sbands_flags, v4);
+					  sbands_flags);
 	sband = &data->bands[NL80211_BAND_2GHZ];
 	sband->band = NL80211_BAND_2GHZ;
 	sband->bitrates = &iwl_cfg80211_rates[RATES_24_OFFS];
@@ -823,7 +818,7 @@
 		sbands_flags |= IWL_NVM_SBANDS_FLAGS_NO_WIDE_IN_5GHZ;
 
 	iwl_init_sbands(dev, cfg, data, ch_section, tx_chains, rx_chains,
-			sbands_flags, false);
+			sbands_flags);
 	data->calib_version = 255;
 
 	return data;
@@ -1214,6 +1209,7 @@
 				 const struct iwl_fw *fw)
 {
 	struct iwl_nvm_get_info cmd = {};
+	struct iwl_nvm_get_info_rsp *rsp;
 	struct iwl_nvm_data *nvm;
 	struct iwl_host_cmd hcmd = {
 		.flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
@@ -1228,24 +1224,12 @@
 	bool empty_otp;
 	u32 mac_flags;
 	u32 sbands_flags = 0;
-	/*
-	 * All the values in iwl_nvm_get_info_rsp v4 are the same as
-	 * in v3, except for the channel profile part of the
-	 * regulatory.  So we can just access the new struct, with the
-	 * exception of the latter.
-	 */
-	struct iwl_nvm_get_info_rsp *rsp;
-	struct iwl_nvm_get_info_rsp_v3 *rsp_v3;
-	bool v4 = fw_has_api(&fw->ucode_capa,
-			     IWL_UCODE_TLV_API_REGULATORY_NVM_INFO);
-	size_t rsp_size = v4 ? sizeof(*rsp) : sizeof(*rsp_v3);
-	void *channel_profile;
 
 	ret = iwl_trans_send_cmd(trans, &hcmd);
 	if (ret)
 		return ERR_PTR(ret);
 
-	if (WARN(iwl_rx_packet_payload_len(hcmd.resp_pkt) != rsp_size,
+	if (WARN(iwl_rx_packet_payload_len(hcmd.resp_pkt) != sizeof(*rsp),
 		 "Invalid payload len in NVM response from FW %d",
 		 iwl_rx_packet_payload_len(hcmd.resp_pkt))) {
 		ret = -EINVAL;
@@ -1307,15 +1291,11 @@
 		sbands_flags |= IWL_NVM_SBANDS_FLAGS_LAR;
 	}
 
-	rsp_v3 = (void *)rsp;
-	channel_profile = v4 ? (void *)rsp->regulatory.channel_profile :
-			  (void *)rsp_v3->regulatory.channel_profile;
-
 	iwl_init_sbands(trans->dev, trans->cfg, nvm,
 			channel_profile,
 			nvm->valid_tx_ant & fw->valid_tx_ant,
 			nvm->valid_rx_ant & fw->valid_rx_ant,
-			sbands_flags, v4);
+			sbands_flags);
 
 	iwl_free_resp(&hcmd);
 	return nvm;