1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 /* 3 * Copyright (C) 2005-2015, 2018-2025 Intel Corporation 4 * Copyright (C) 2016-2017 Intel Deutschland GmbH 5 */ 6 #ifndef __iwl_nvm_parse_h__ 7 #define __iwl_nvm_parse_h__ 8 9 #include <net/cfg80211.h> 10 #include "iwl-nvm-utils.h" 11 #include "mei/iwl-mei.h" 12 13 /** 14 * enum iwl_nvm_sbands_flags - modification flags for the channel profiles 15 * 16 * @IWL_NVM_SBANDS_FLAGS_LAR: LAR is enabled 17 * @IWL_NVM_SBANDS_FLAGS_NO_WIDE_IN_5GHZ: disallow 40, 80 and 160MHz on 5GHz 18 */ 19 enum iwl_nvm_sbands_flags { 20 IWL_NVM_SBANDS_FLAGS_LAR = BIT(0), 21 IWL_NVM_SBANDS_FLAGS_NO_WIDE_IN_5GHZ = BIT(1), 22 }; 23 24 /** 25 * struct iwl_reg_capa - struct for global regulatory capabilities, Used for 26 * handling the different APIs of reg_capa_flags. 27 * 28 * @allow_40mhz: 11n channel with a width of 40Mhz is allowed 29 * for this regulatory domain. 30 * @allow_80mhz: 11ac channel with a width of 80Mhz is allowed 31 * for this regulatory domain (valid only in 5 and 6 Ghz). 32 * @allow_160mhz: 11ac channel with a width of 160Mhz is allowed 33 * for this regulatory domain (valid only in 5 and 6 Ghz). 34 * @allow_320mhz: 11be channel with a width of 320Mhz is allowed 35 * for this regulatory domain (valid only in 6 Ghz). 36 * @disable_11ax: 11ax is forbidden for this regulatory domain. 37 * @disable_11be: 11be is forbidden for this regulatory domain. 38 */ 39 struct iwl_reg_capa { 40 bool allow_40mhz; 41 bool allow_80mhz; 42 bool allow_160mhz; 43 bool allow_320mhz; 44 bool disable_11ax; 45 bool disable_11be; 46 }; 47 48 /** 49 * enum iwl_nvm_channel_flags - channel flags in NVM 50 * @NVM_CHANNEL_VALID: channel is usable for this SKU/geo 51 * @NVM_CHANNEL_IBSS: usable as an IBSS channel and deprecated 52 * when %IWL_NVM_SBANDS_FLAGS_LAR enabled. 53 * @NVM_CHANNEL_ALLOW_20MHZ_ACTIVITY: active scanning allowed and 54 * AP allowed only in 20 MHz. Valid only 55 * when %IWL_NVM_SBANDS_FLAGS_LAR enabled. 56 * @NVM_CHANNEL_ACTIVE: active scanning allowed and allows IBSS 57 * when %IWL_NVM_SBANDS_FLAGS_LAR enabled. 58 * @NVM_CHANNEL_RADAR: radar detection required 59 * @NVM_CHANNEL_INDOOR_ONLY: only indoor use is allowed 60 * @NVM_CHANNEL_GO_CONCURRENT: GO operation is allowed when connected to BSS 61 * on same channel on 2.4 or same UNII band on 5.2 62 * @NVM_CHANNEL_UNIFORM: uniform spreading required 63 * @NVM_CHANNEL_20MHZ: 20 MHz channel okay 64 * @NVM_CHANNEL_40MHZ: 40 MHz channel okay 65 * @NVM_CHANNEL_80MHZ: 80 MHz channel okay 66 * @NVM_CHANNEL_160MHZ: 160 MHz channel okay 67 * @NVM_CHANNEL_DC_HIGH: DC HIGH required/allowed (?) 68 * @NVM_CHANNEL_VLP: client support connection to UHB VLP AP 69 * @NVM_CHANNEL_AFC: client support connection to UHB AFC AP 70 * @NVM_CHANNEL_VLP_AP_NOT_ALLOWED: UHB VLP AP not allowed, 71 * Valid only when %NVM_CHANNEL_VLP is enabled. 72 */ 73 enum iwl_nvm_channel_flags { 74 NVM_CHANNEL_VALID = BIT(0), 75 NVM_CHANNEL_IBSS = BIT(1), 76 NVM_CHANNEL_ALLOW_20MHZ_ACTIVITY = BIT(2), 77 NVM_CHANNEL_ACTIVE = BIT(3), 78 NVM_CHANNEL_RADAR = BIT(4), 79 NVM_CHANNEL_INDOOR_ONLY = BIT(5), 80 NVM_CHANNEL_GO_CONCURRENT = BIT(6), 81 NVM_CHANNEL_UNIFORM = BIT(7), 82 NVM_CHANNEL_20MHZ = BIT(8), 83 NVM_CHANNEL_40MHZ = BIT(9), 84 NVM_CHANNEL_80MHZ = BIT(10), 85 NVM_CHANNEL_160MHZ = BIT(11), 86 NVM_CHANNEL_DC_HIGH = BIT(12), 87 NVM_CHANNEL_VLP = BIT(13), 88 NVM_CHANNEL_AFC = BIT(14), 89 NVM_CHANNEL_VLP_AP_NOT_ALLOWED = BIT(15), 90 }; 91 92 #if IS_ENABLED(CONFIG_IWLWIFI_KUNIT_TESTS) 93 u32 iwl_nvm_get_regdom_bw_flags(const u16 *nvm_chan, 94 int ch_idx, u16 nvm_flags, 95 struct iwl_reg_capa reg_capa); 96 #endif 97 98 /* 99 * iwl_parse_nvm_data - parse NVM data and return values 100 * 101 * This function parses all NVM values we need and then 102 * returns a (newly allocated) struct containing all the 103 * relevant values for driver use. The struct must be freed 104 * later with iwl_free_nvm_data(). 105 */ 106 struct iwl_nvm_data * 107 iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_rf_cfg *cfg, 108 const struct iwl_fw *fw, 109 const __be16 *nvm_hw, const __le16 *nvm_sw, 110 const __le16 *nvm_calib, const __le16 *regulatory, 111 const __le16 *mac_override, const __le16 *phy_sku, 112 u8 tx_chains, u8 rx_chains); 113 114 /** 115 * iwl_parse_nvm_mcc_info - parse MCC (mobile country code) info coming from FW 116 * 117 * This function parses the regulatory channel data received as a 118 * MCC_UPDATE_CMD command. It returns a newly allocation regulatory domain, 119 * to be fed into the regulatory core. In case the geo_info is set handle 120 * accordingly. An ERR_PTR is returned on error. 121 * If not given to the regulatory core, the user is responsible for freeing 122 * the regdomain returned here with kfree. 123 * 124 * @trans: the transport 125 * @num_of_ch: the number of channels 126 * @channels: channel map 127 * @fw_mcc: firmware country code 128 * @geo_info: geo info value 129 * @cap: capability 130 * @resp_ver: FW response version 131 */ 132 struct ieee80211_regdomain * 133 iwl_parse_nvm_mcc_info(struct iwl_trans *trans, 134 int num_of_ch, __le32 *channels, u16 fw_mcc, 135 u16 geo_info, u32 cap, u8 resp_ver); 136 137 /** 138 * struct iwl_nvm_section - describes an NVM section in memory. 139 * 140 * This struct holds an NVM section read from the NIC using NVM_ACCESS_CMD, 141 * and saved for later use by the driver. Not all NVM sections are saved 142 * this way, only the needed ones. 143 */ 144 struct iwl_nvm_section { 145 u16 length; 146 const u8 *data; 147 }; 148 149 /** 150 * iwl_read_external_nvm - Reads external NVM from a file into nvm_sections 151 */ 152 int iwl_read_external_nvm(struct iwl_trans *trans, 153 const char *nvm_file_name, 154 struct iwl_nvm_section *nvm_sections); 155 void iwl_nvm_fixups(u32 hw_id, unsigned int section, u8 *data, 156 unsigned int len); 157 158 /* 159 * iwl_get_nvm - retrieve NVM data from firmware 160 * 161 * Allocates a new iwl_nvm_data structure, fills it with 162 * NVM data, and returns it to caller. 163 */ 164 struct iwl_nvm_data *iwl_get_nvm(struct iwl_trans *trans, 165 const struct iwl_fw *fw, 166 u8 set_tx_ant, u8 set_rx_ant); 167 168 /* 169 * iwl_parse_mei_nvm_data - parse the mei_nvm_data and get an iwl_nvm_data 170 */ 171 struct iwl_nvm_data * 172 iwl_parse_mei_nvm_data(struct iwl_trans *trans, const struct iwl_rf_cfg *cfg, 173 const struct iwl_mei_nvm *mei_nvm, 174 const struct iwl_fw *fw, u8 set_tx_ant, u8 set_rx_ant); 175 176 /* 177 * iwl_reinit_cab - to be called when the tx_chains or rx_chains are modified 178 */ 179 void iwl_reinit_cab(struct iwl_trans *trans, struct iwl_nvm_data *data, 180 u8 tx_chains, u8 rx_chains, const struct iwl_fw *fw); 181 182 #endif /* __iwl_nvm_parse_h__ */ 183