1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2 /* 3 * Copyright (C) 2012-2014, 2018-2024 Intel Corporation 4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH 5 * Copyright (C) 2016-2017 Intel Deutschland GmbH 6 */ 7 #include <linux/module.h> 8 #include <linux/rtnetlink.h> 9 #include <linux/vmalloc.h> 10 #include <net/mac80211.h> 11 12 #include "fw/notif-wait.h" 13 #include "iwl-trans.h" 14 #include "iwl-op-mode.h" 15 #include "fw/img.h" 16 #include "iwl-debug.h" 17 #include "iwl-drv.h" 18 #include "iwl-modparams.h" 19 #include "mvm.h" 20 #include "iwl-phy-db.h" 21 #include "iwl-eeprom-parse.h" 22 #include "iwl-csr.h" 23 #include "iwl-io.h" 24 #include "iwl-prph.h" 25 #include "rs.h" 26 #include "fw/api/scan.h" 27 #include "fw/api/rfi.h" 28 #include "time-event.h" 29 #include "fw-api.h" 30 #include "fw/acpi.h" 31 #include "fw/uefi.h" 32 #include "time-sync.h" 33 34 #define DRV_DESCRIPTION "The new Intel(R) wireless AGN driver for Linux" 35 MODULE_DESCRIPTION(DRV_DESCRIPTION); 36 MODULE_LICENSE("GPL"); 37 MODULE_IMPORT_NS(IWLWIFI); 38 39 static const struct iwl_op_mode_ops iwl_mvm_ops; 40 static const struct iwl_op_mode_ops iwl_mvm_ops_mq; 41 42 struct iwl_mvm_mod_params iwlmvm_mod_params = { 43 .power_scheme = IWL_POWER_SCHEME_BPS, 44 /* rest of fields are 0 by default */ 45 }; 46 47 module_param_named(init_dbg, iwlmvm_mod_params.init_dbg, bool, 0444); 48 MODULE_PARM_DESC(init_dbg, 49 "set to true to debug an ASSERT in INIT fw (default: false"); 50 module_param_named(power_scheme, iwlmvm_mod_params.power_scheme, int, 0444); 51 MODULE_PARM_DESC(power_scheme, 52 "power management scheme: 1-active, 2-balanced, 3-low power, default: 2"); 53 54 /* 55 * module init and exit functions 56 */ 57 static int __init iwl_mvm_init(void) 58 { 59 int ret; 60 61 ret = iwl_mvm_rate_control_register(); 62 if (ret) { 63 pr_err("Unable to register rate control algorithm: %d\n", ret); 64 return ret; 65 } 66 67 ret = iwl_opmode_register("iwlmvm", &iwl_mvm_ops); 68 if (ret) 69 pr_err("Unable to register MVM op_mode: %d\n", ret); 70 71 return ret; 72 } 73 module_init(iwl_mvm_init); 74 75 static void __exit iwl_mvm_exit(void) 76 { 77 iwl_opmode_deregister("iwlmvm"); 78 iwl_mvm_rate_control_unregister(); 79 } 80 module_exit(iwl_mvm_exit); 81 82 static void iwl_mvm_nic_config(struct iwl_op_mode *op_mode) 83 { 84 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 85 u8 radio_cfg_type, radio_cfg_step, radio_cfg_dash; 86 u32 reg_val; 87 u32 phy_config = iwl_mvm_get_phy_config(mvm); 88 89 radio_cfg_type = (phy_config & FW_PHY_CFG_RADIO_TYPE) >> 90 FW_PHY_CFG_RADIO_TYPE_POS; 91 radio_cfg_step = (phy_config & FW_PHY_CFG_RADIO_STEP) >> 92 FW_PHY_CFG_RADIO_STEP_POS; 93 radio_cfg_dash = (phy_config & FW_PHY_CFG_RADIO_DASH) >> 94 FW_PHY_CFG_RADIO_DASH_POS; 95 96 IWL_DEBUG_INFO(mvm, "Radio type=0x%x-0x%x-0x%x\n", radio_cfg_type, 97 radio_cfg_step, radio_cfg_dash); 98 99 if (mvm->trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) 100 return; 101 102 /* SKU control */ 103 reg_val = CSR_HW_REV_STEP_DASH(mvm->trans->hw_rev); 104 105 /* radio configuration */ 106 reg_val |= radio_cfg_type << CSR_HW_IF_CONFIG_REG_POS_PHY_TYPE; 107 reg_val |= radio_cfg_step << CSR_HW_IF_CONFIG_REG_POS_PHY_STEP; 108 reg_val |= radio_cfg_dash << CSR_HW_IF_CONFIG_REG_POS_PHY_DASH; 109 110 WARN_ON((radio_cfg_type << CSR_HW_IF_CONFIG_REG_POS_PHY_TYPE) & 111 ~CSR_HW_IF_CONFIG_REG_MSK_PHY_TYPE); 112 113 /* 114 * TODO: Bits 7-8 of CSR in 8000 HW family and higher set the ADC 115 * sampling, and shouldn't be set to any non-zero value. 116 * The same is supposed to be true of the other HW, but unsetting 117 * them (such as the 7260) causes automatic tests to fail on seemingly 118 * unrelated errors. Need to further investigate this, but for now 119 * we'll separate cases. 120 */ 121 if (mvm->trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_8000) 122 reg_val |= CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI; 123 124 if (iwl_fw_dbg_is_d3_debug_enabled(&mvm->fwrt)) 125 reg_val |= CSR_HW_IF_CONFIG_REG_D3_DEBUG; 126 127 iwl_trans_set_bits_mask(mvm->trans, CSR_HW_IF_CONFIG_REG, 128 CSR_HW_IF_CONFIG_REG_MSK_MAC_STEP_DASH | 129 CSR_HW_IF_CONFIG_REG_MSK_PHY_TYPE | 130 CSR_HW_IF_CONFIG_REG_MSK_PHY_STEP | 131 CSR_HW_IF_CONFIG_REG_MSK_PHY_DASH | 132 CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | 133 CSR_HW_IF_CONFIG_REG_BIT_MAC_SI | 134 CSR_HW_IF_CONFIG_REG_D3_DEBUG, 135 reg_val); 136 137 /* 138 * W/A : NIC is stuck in a reset state after Early PCIe power off 139 * (PCIe power is lost before PERST# is asserted), causing ME FW 140 * to lose ownership and not being able to obtain it back. 141 */ 142 if (!mvm->trans->cfg->apmg_not_supported) 143 iwl_set_bits_mask_prph(mvm->trans, APMG_PS_CTRL_REG, 144 APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS, 145 ~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS); 146 } 147 148 static void iwl_mvm_rx_monitor_notif(struct iwl_mvm *mvm, 149 struct iwl_rx_cmd_buffer *rxb) 150 { 151 struct iwl_rx_packet *pkt = rxb_addr(rxb); 152 struct iwl_datapath_monitor_notif *notif = (void *)pkt->data; 153 struct ieee80211_supported_band *sband; 154 const struct ieee80211_sta_he_cap *he_cap; 155 struct ieee80211_vif *vif; 156 157 if (notif->type != cpu_to_le32(IWL_DP_MON_NOTIF_TYPE_EXT_CCA)) 158 return; 159 160 vif = iwl_mvm_get_vif_by_macid(mvm, notif->mac_id); 161 if (!vif || vif->type != NL80211_IFTYPE_STATION) 162 return; 163 164 if (!vif->bss_conf.chanreq.oper.chan || 165 vif->bss_conf.chanreq.oper.chan->band != NL80211_BAND_2GHZ || 166 vif->bss_conf.chanreq.oper.width < NL80211_CHAN_WIDTH_40) 167 return; 168 169 if (!vif->cfg.assoc) 170 return; 171 172 /* this shouldn't happen *again*, ignore it */ 173 if (mvm->cca_40mhz_workaround) 174 return; 175 176 /* 177 * We'll decrement this on disconnect - so set to 2 since we'll 178 * still have to disconnect from the current AP first. 179 */ 180 mvm->cca_40mhz_workaround = 2; 181 182 /* 183 * This capability manipulation isn't really ideal, but it's the 184 * easiest choice - otherwise we'd have to do some major changes 185 * in mac80211 to support this, which isn't worth it. This does 186 * mean that userspace may have outdated information, but that's 187 * actually not an issue at all. 188 */ 189 sband = mvm->hw->wiphy->bands[NL80211_BAND_2GHZ]; 190 191 WARN_ON(!sband->ht_cap.ht_supported); 192 WARN_ON(!(sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)); 193 sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; 194 195 he_cap = ieee80211_get_he_iftype_cap_vif(sband, vif); 196 197 if (he_cap) { 198 /* we know that ours is writable */ 199 struct ieee80211_sta_he_cap *he = (void *)(uintptr_t)he_cap; 200 201 WARN_ON(!he->has_he); 202 WARN_ON(!(he->he_cap_elem.phy_cap_info[0] & 203 IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G)); 204 he->he_cap_elem.phy_cap_info[0] &= 205 ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G; 206 } 207 208 ieee80211_disconnect(vif, true); 209 } 210 211 void iwl_mvm_update_link_smps(struct ieee80211_vif *vif, 212 struct ieee80211_bss_conf *link_conf) 213 { 214 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 215 struct iwl_mvm *mvm = mvmvif->mvm; 216 enum ieee80211_smps_mode mode = IEEE80211_SMPS_AUTOMATIC; 217 218 if (!link_conf) 219 return; 220 221 if (mvm->fw_static_smps_request && 222 link_conf->chanreq.oper.width == NL80211_CHAN_WIDTH_160 && 223 link_conf->he_support) 224 mode = IEEE80211_SMPS_STATIC; 225 226 iwl_mvm_update_smps(mvm, vif, IWL_MVM_SMPS_REQ_FW, mode, 227 link_conf->link_id); 228 } 229 230 static void iwl_mvm_intf_dual_chain_req(void *data, u8 *mac, 231 struct ieee80211_vif *vif) 232 { 233 struct ieee80211_bss_conf *link_conf; 234 unsigned int link_id; 235 236 rcu_read_lock(); 237 238 for_each_vif_active_link(vif, link_conf, link_id) 239 iwl_mvm_update_link_smps(vif, link_conf); 240 241 rcu_read_unlock(); 242 } 243 244 static void iwl_mvm_rx_thermal_dual_chain_req(struct iwl_mvm *mvm, 245 struct iwl_rx_cmd_buffer *rxb) 246 { 247 struct iwl_rx_packet *pkt = rxb_addr(rxb); 248 struct iwl_thermal_dual_chain_request *req = (void *)pkt->data; 249 250 /* 251 * We could pass it to the iterator data, but also need to remember 252 * it for new interfaces that are added while in this state. 253 */ 254 mvm->fw_static_smps_request = 255 req->event == cpu_to_le32(THERMAL_DUAL_CHAIN_REQ_DISABLE); 256 ieee80211_iterate_interfaces(mvm->hw, 257 IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER, 258 iwl_mvm_intf_dual_chain_req, NULL); 259 } 260 261 /** 262 * enum iwl_rx_handler_context: context for Rx handler 263 * @RX_HANDLER_SYNC : this means that it will be called in the Rx path 264 * which can't acquire mvm->mutex. 265 * @RX_HANDLER_ASYNC_LOCKED : If the handler needs to hold mvm->mutex 266 * (and only in this case!), it should be set as ASYNC. In that case, 267 * it will be called from a worker with mvm->mutex held. 268 * @RX_HANDLER_ASYNC_UNLOCKED : in case the handler needs to lock the 269 * mutex itself, it will be called from a worker without mvm->mutex held. 270 * @RX_HANDLER_ASYNC_LOCKED_WIPHY: If the handler needs to hold the wiphy lock 271 * and mvm->mutex. Will be handled with the wiphy_work queue infra 272 * instead of regular work queue. 273 */ 274 enum iwl_rx_handler_context { 275 RX_HANDLER_SYNC, 276 RX_HANDLER_ASYNC_LOCKED, 277 RX_HANDLER_ASYNC_UNLOCKED, 278 RX_HANDLER_ASYNC_LOCKED_WIPHY, 279 }; 280 281 /** 282 * struct iwl_rx_handlers: handler for FW notification 283 * @cmd_id: command id 284 * @min_size: minimum size to expect for the notification 285 * @context: see &iwl_rx_handler_context 286 * @fn: the function is called when notification is received 287 */ 288 struct iwl_rx_handlers { 289 u16 cmd_id, min_size; 290 enum iwl_rx_handler_context context; 291 void (*fn)(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 292 }; 293 294 #define RX_HANDLER_NO_SIZE(_cmd_id, _fn, _context) \ 295 { .cmd_id = _cmd_id, .fn = _fn, .context = _context, } 296 #define RX_HANDLER_GRP_NO_SIZE(_grp, _cmd, _fn, _context) \ 297 { .cmd_id = WIDE_ID(_grp, _cmd), .fn = _fn, .context = _context, } 298 #define RX_HANDLER(_cmd_id, _fn, _context, _struct) \ 299 { .cmd_id = _cmd_id, .fn = _fn, \ 300 .context = _context, .min_size = sizeof(_struct), } 301 #define RX_HANDLER_GRP(_grp, _cmd, _fn, _context, _struct) \ 302 { .cmd_id = WIDE_ID(_grp, _cmd), .fn = _fn, \ 303 .context = _context, .min_size = sizeof(_struct), } 304 305 /* 306 * Handlers for fw notifications 307 * Convention: RX_HANDLER(CMD_NAME, iwl_mvm_rx_CMD_NAME 308 * This list should be in order of frequency for performance purposes. 309 * 310 * The handler can be one from three contexts, see &iwl_rx_handler_context 311 */ 312 static const struct iwl_rx_handlers iwl_mvm_rx_handlers[] = { 313 RX_HANDLER(TX_CMD, iwl_mvm_rx_tx_cmd, RX_HANDLER_SYNC, 314 struct iwl_mvm_tx_resp), 315 RX_HANDLER(BA_NOTIF, iwl_mvm_rx_ba_notif, RX_HANDLER_SYNC, 316 struct iwl_mvm_ba_notif), 317 318 RX_HANDLER_GRP(DATA_PATH_GROUP, TLC_MNG_UPDATE_NOTIF, 319 iwl_mvm_tlc_update_notif, RX_HANDLER_SYNC, 320 struct iwl_tlc_update_notif), 321 322 RX_HANDLER(BT_PROFILE_NOTIFICATION, iwl_mvm_rx_bt_coex_notif, 323 RX_HANDLER_ASYNC_LOCKED_WIPHY, 324 struct iwl_bt_coex_profile_notif), 325 RX_HANDLER_NO_SIZE(BEACON_NOTIFICATION, iwl_mvm_rx_beacon_notif, 326 RX_HANDLER_ASYNC_LOCKED), 327 RX_HANDLER_NO_SIZE(STATISTICS_NOTIFICATION, iwl_mvm_rx_statistics, 328 RX_HANDLER_ASYNC_LOCKED), 329 330 RX_HANDLER_GRP(STATISTICS_GROUP, STATISTICS_OPER_NOTIF, 331 iwl_mvm_handle_rx_system_oper_stats, 332 RX_HANDLER_ASYNC_LOCKED_WIPHY, 333 struct iwl_system_statistics_notif_oper), 334 RX_HANDLER_GRP(STATISTICS_GROUP, STATISTICS_OPER_PART1_NOTIF, 335 iwl_mvm_handle_rx_system_oper_part1_stats, 336 RX_HANDLER_ASYNC_LOCKED, 337 struct iwl_system_statistics_part1_notif_oper), 338 RX_HANDLER_GRP(SYSTEM_GROUP, SYSTEM_STATISTICS_END_NOTIF, 339 iwl_mvm_handle_rx_system_end_stats_notif, 340 RX_HANDLER_ASYNC_LOCKED, 341 struct iwl_system_statistics_end_notif), 342 343 RX_HANDLER(BA_WINDOW_STATUS_NOTIFICATION_ID, 344 iwl_mvm_window_status_notif, RX_HANDLER_SYNC, 345 struct iwl_ba_window_status_notif), 346 347 RX_HANDLER(TIME_EVENT_NOTIFICATION, iwl_mvm_rx_time_event_notif, 348 RX_HANDLER_SYNC, struct iwl_time_event_notif), 349 RX_HANDLER_GRP(MAC_CONF_GROUP, SESSION_PROTECTION_NOTIF, 350 iwl_mvm_rx_session_protect_notif, RX_HANDLER_SYNC, 351 struct iwl_mvm_session_prot_notif), 352 RX_HANDLER(MCC_CHUB_UPDATE_CMD, iwl_mvm_rx_chub_update_mcc, 353 RX_HANDLER_ASYNC_LOCKED, struct iwl_mcc_chub_notif), 354 355 RX_HANDLER(EOSP_NOTIFICATION, iwl_mvm_rx_eosp_notif, RX_HANDLER_SYNC, 356 struct iwl_mvm_eosp_notification), 357 358 RX_HANDLER(SCAN_ITERATION_COMPLETE, 359 iwl_mvm_rx_lmac_scan_iter_complete_notif, RX_HANDLER_SYNC, 360 struct iwl_lmac_scan_complete_notif), 361 RX_HANDLER(SCAN_OFFLOAD_COMPLETE, 362 iwl_mvm_rx_lmac_scan_complete_notif, 363 RX_HANDLER_ASYNC_LOCKED, struct iwl_periodic_scan_complete), 364 RX_HANDLER_NO_SIZE(MATCH_FOUND_NOTIFICATION, 365 iwl_mvm_rx_scan_match_found, 366 RX_HANDLER_SYNC), 367 RX_HANDLER(SCAN_COMPLETE_UMAC, iwl_mvm_rx_umac_scan_complete_notif, 368 RX_HANDLER_ASYNC_LOCKED_WIPHY, 369 struct iwl_umac_scan_complete), 370 RX_HANDLER(SCAN_ITERATION_COMPLETE_UMAC, 371 iwl_mvm_rx_umac_scan_iter_complete_notif, RX_HANDLER_SYNC, 372 struct iwl_umac_scan_iter_complete_notif), 373 374 RX_HANDLER(MISSED_BEACONS_NOTIFICATION, iwl_mvm_rx_missed_beacons_notif, 375 RX_HANDLER_ASYNC_LOCKED_WIPHY, 376 struct iwl_missed_beacons_notif), 377 378 RX_HANDLER(REPLY_ERROR, iwl_mvm_rx_fw_error, RX_HANDLER_SYNC, 379 struct iwl_error_resp), 380 RX_HANDLER(PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION, 381 iwl_mvm_power_uapsd_misbehaving_ap_notif, RX_HANDLER_SYNC, 382 struct iwl_uapsd_misbehaving_ap_notif), 383 RX_HANDLER_NO_SIZE(DTS_MEASUREMENT_NOTIFICATION, iwl_mvm_temp_notif, 384 RX_HANDLER_ASYNC_LOCKED), 385 RX_HANDLER_GRP_NO_SIZE(PHY_OPS_GROUP, DTS_MEASUREMENT_NOTIF_WIDE, 386 iwl_mvm_temp_notif, RX_HANDLER_ASYNC_UNLOCKED), 387 RX_HANDLER_GRP(PHY_OPS_GROUP, CT_KILL_NOTIFICATION, 388 iwl_mvm_ct_kill_notif, RX_HANDLER_SYNC, 389 struct ct_kill_notif), 390 391 RX_HANDLER(TDLS_CHANNEL_SWITCH_NOTIFICATION, iwl_mvm_rx_tdls_notif, 392 RX_HANDLER_ASYNC_LOCKED, 393 struct iwl_tdls_channel_switch_notif), 394 RX_HANDLER(MFUART_LOAD_NOTIFICATION, iwl_mvm_rx_mfuart_notif, 395 RX_HANDLER_SYNC, struct iwl_mfuart_load_notif_v1), 396 RX_HANDLER_GRP(LOCATION_GROUP, TOF_RESPONDER_STATS, 397 iwl_mvm_ftm_responder_stats, RX_HANDLER_ASYNC_LOCKED, 398 struct iwl_ftm_responder_stats), 399 400 RX_HANDLER_GRP_NO_SIZE(LOCATION_GROUP, TOF_RANGE_RESPONSE_NOTIF, 401 iwl_mvm_ftm_range_resp, RX_HANDLER_ASYNC_LOCKED), 402 RX_HANDLER_GRP_NO_SIZE(LOCATION_GROUP, TOF_LC_NOTIF, 403 iwl_mvm_ftm_lc_notif, RX_HANDLER_ASYNC_LOCKED), 404 405 RX_HANDLER_GRP(DEBUG_GROUP, MFU_ASSERT_DUMP_NTF, 406 iwl_mvm_mfu_assert_dump_notif, RX_HANDLER_SYNC, 407 struct iwl_mfu_assert_dump_notif), 408 RX_HANDLER_GRP(PROT_OFFLOAD_GROUP, STORED_BEACON_NTF, 409 iwl_mvm_rx_stored_beacon_notif, RX_HANDLER_SYNC, 410 struct iwl_stored_beacon_notif_v2), 411 RX_HANDLER_GRP(DATA_PATH_GROUP, MU_GROUP_MGMT_NOTIF, 412 iwl_mvm_mu_mimo_grp_notif, RX_HANDLER_SYNC, 413 struct iwl_mu_group_mgmt_notif), 414 RX_HANDLER_GRP(DATA_PATH_GROUP, STA_PM_NOTIF, 415 iwl_mvm_sta_pm_notif, RX_HANDLER_SYNC, 416 struct iwl_mvm_pm_state_notification), 417 RX_HANDLER_GRP(MAC_CONF_GROUP, PROBE_RESPONSE_DATA_NOTIF, 418 iwl_mvm_probe_resp_data_notif, 419 RX_HANDLER_ASYNC_LOCKED, 420 struct iwl_probe_resp_data_notif), 421 RX_HANDLER_GRP(MAC_CONF_GROUP, CHANNEL_SWITCH_START_NOTIF, 422 iwl_mvm_channel_switch_start_notif, 423 RX_HANDLER_SYNC, struct iwl_channel_switch_start_notif), 424 RX_HANDLER_GRP(MAC_CONF_GROUP, CHANNEL_SWITCH_ERROR_NOTIF, 425 iwl_mvm_channel_switch_error_notif, 426 RX_HANDLER_ASYNC_UNLOCKED, 427 struct iwl_channel_switch_error_notif), 428 RX_HANDLER_GRP(DATA_PATH_GROUP, MONITOR_NOTIF, 429 iwl_mvm_rx_monitor_notif, RX_HANDLER_ASYNC_LOCKED, 430 struct iwl_datapath_monitor_notif), 431 432 RX_HANDLER_GRP(DATA_PATH_GROUP, THERMAL_DUAL_CHAIN_REQUEST, 433 iwl_mvm_rx_thermal_dual_chain_req, 434 RX_HANDLER_ASYNC_LOCKED, 435 struct iwl_thermal_dual_chain_request), 436 437 RX_HANDLER_GRP(SYSTEM_GROUP, RFI_DEACTIVATE_NOTIF, 438 iwl_rfi_deactivate_notif_handler, RX_HANDLER_ASYNC_UNLOCKED, 439 struct iwl_rfi_deactivate_notif), 440 441 RX_HANDLER_GRP(LEGACY_GROUP, 442 WNM_80211V_TIMING_MEASUREMENT_NOTIFICATION, 443 iwl_mvm_time_sync_msmt_event, RX_HANDLER_SYNC, 444 struct iwl_time_msmt_notify), 445 RX_HANDLER_GRP(LEGACY_GROUP, 446 WNM_80211V_TIMING_MEASUREMENT_CONFIRM_NOTIFICATION, 447 iwl_mvm_time_sync_msmt_confirm_event, RX_HANDLER_SYNC, 448 struct iwl_time_msmt_cfm_notify), 449 RX_HANDLER_GRP(MAC_CONF_GROUP, ROC_NOTIF, 450 iwl_mvm_rx_roc_notif, RX_HANDLER_SYNC, 451 struct iwl_roc_notif), 452 }; 453 #undef RX_HANDLER 454 #undef RX_HANDLER_GRP 455 456 /* Please keep this array *SORTED* by hex value. 457 * Access is done through binary search 458 */ 459 static const struct iwl_hcmd_names iwl_mvm_legacy_names[] = { 460 HCMD_NAME(UCODE_ALIVE_NTFY), 461 HCMD_NAME(REPLY_ERROR), 462 HCMD_NAME(ECHO_CMD), 463 HCMD_NAME(INIT_COMPLETE_NOTIF), 464 HCMD_NAME(PHY_CONTEXT_CMD), 465 HCMD_NAME(DBG_CFG), 466 HCMD_NAME(SCAN_CFG_CMD), 467 HCMD_NAME(SCAN_REQ_UMAC), 468 HCMD_NAME(SCAN_ABORT_UMAC), 469 HCMD_NAME(SCAN_COMPLETE_UMAC), 470 HCMD_NAME(BA_WINDOW_STATUS_NOTIFICATION_ID), 471 HCMD_NAME(ADD_STA_KEY), 472 HCMD_NAME(ADD_STA), 473 HCMD_NAME(REMOVE_STA), 474 HCMD_NAME(TX_CMD), 475 HCMD_NAME(SCD_QUEUE_CFG), 476 HCMD_NAME(TXPATH_FLUSH), 477 HCMD_NAME(MGMT_MCAST_KEY), 478 HCMD_NAME(WEP_KEY), 479 HCMD_NAME(SHARED_MEM_CFG), 480 HCMD_NAME(TDLS_CHANNEL_SWITCH_CMD), 481 HCMD_NAME(MAC_CONTEXT_CMD), 482 HCMD_NAME(TIME_EVENT_CMD), 483 HCMD_NAME(TIME_EVENT_NOTIFICATION), 484 HCMD_NAME(BINDING_CONTEXT_CMD), 485 HCMD_NAME(TIME_QUOTA_CMD), 486 HCMD_NAME(NON_QOS_TX_COUNTER_CMD), 487 HCMD_NAME(LEDS_CMD), 488 HCMD_NAME(LQ_CMD), 489 HCMD_NAME(FW_PAGING_BLOCK_CMD), 490 HCMD_NAME(SCAN_OFFLOAD_REQUEST_CMD), 491 HCMD_NAME(SCAN_OFFLOAD_ABORT_CMD), 492 HCMD_NAME(HOT_SPOT_CMD), 493 HCMD_NAME(SCAN_OFFLOAD_PROFILES_QUERY_CMD), 494 HCMD_NAME(BT_COEX_UPDATE_REDUCED_TXP), 495 HCMD_NAME(BT_COEX_CI), 496 HCMD_NAME(WNM_80211V_TIMING_MEASUREMENT_NOTIFICATION), 497 HCMD_NAME(WNM_80211V_TIMING_MEASUREMENT_CONFIRM_NOTIFICATION), 498 HCMD_NAME(PHY_CONFIGURATION_CMD), 499 HCMD_NAME(CALIB_RES_NOTIF_PHY_DB), 500 HCMD_NAME(PHY_DB_CMD), 501 HCMD_NAME(SCAN_OFFLOAD_COMPLETE), 502 HCMD_NAME(SCAN_OFFLOAD_UPDATE_PROFILES_CMD), 503 HCMD_NAME(POWER_TABLE_CMD), 504 HCMD_NAME(PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION), 505 HCMD_NAME(REPLY_THERMAL_MNG_BACKOFF), 506 HCMD_NAME(NVM_ACCESS_CMD), 507 HCMD_NAME(BEACON_NOTIFICATION), 508 HCMD_NAME(BEACON_TEMPLATE_CMD), 509 HCMD_NAME(TX_ANT_CONFIGURATION_CMD), 510 HCMD_NAME(BT_CONFIG), 511 HCMD_NAME(STATISTICS_CMD), 512 HCMD_NAME(STATISTICS_NOTIFICATION), 513 HCMD_NAME(EOSP_NOTIFICATION), 514 HCMD_NAME(REDUCE_TX_POWER_CMD), 515 HCMD_NAME(MISSED_BEACONS_NOTIFICATION), 516 HCMD_NAME(TDLS_CONFIG_CMD), 517 HCMD_NAME(MAC_PM_POWER_TABLE), 518 HCMD_NAME(TDLS_CHANNEL_SWITCH_NOTIFICATION), 519 HCMD_NAME(MFUART_LOAD_NOTIFICATION), 520 HCMD_NAME(RSS_CONFIG_CMD), 521 HCMD_NAME(SCAN_ITERATION_COMPLETE_UMAC), 522 HCMD_NAME(REPLY_RX_PHY_CMD), 523 HCMD_NAME(REPLY_RX_MPDU_CMD), 524 HCMD_NAME(BAR_FRAME_RELEASE), 525 HCMD_NAME(FRAME_RELEASE), 526 HCMD_NAME(BA_NOTIF), 527 HCMD_NAME(MCC_UPDATE_CMD), 528 HCMD_NAME(MCC_CHUB_UPDATE_CMD), 529 HCMD_NAME(MARKER_CMD), 530 HCMD_NAME(BT_PROFILE_NOTIFICATION), 531 HCMD_NAME(MCAST_FILTER_CMD), 532 HCMD_NAME(REPLY_SF_CFG_CMD), 533 HCMD_NAME(REPLY_BEACON_FILTERING_CMD), 534 HCMD_NAME(D3_CONFIG_CMD), 535 HCMD_NAME(PROT_OFFLOAD_CONFIG_CMD), 536 HCMD_NAME(MATCH_FOUND_NOTIFICATION), 537 HCMD_NAME(DTS_MEASUREMENT_NOTIFICATION), 538 HCMD_NAME(WOWLAN_PATTERNS), 539 HCMD_NAME(WOWLAN_CONFIGURATION), 540 HCMD_NAME(WOWLAN_TSC_RSC_PARAM), 541 HCMD_NAME(WOWLAN_TKIP_PARAM), 542 HCMD_NAME(WOWLAN_KEK_KCK_MATERIAL), 543 HCMD_NAME(WOWLAN_GET_STATUSES), 544 HCMD_NAME(SCAN_ITERATION_COMPLETE), 545 HCMD_NAME(D0I3_END_CMD), 546 HCMD_NAME(LTR_CONFIG), 547 HCMD_NAME(LDBG_CONFIG_CMD), 548 }; 549 550 /* Please keep this array *SORTED* by hex value. 551 * Access is done through binary search 552 */ 553 static const struct iwl_hcmd_names iwl_mvm_system_names[] = { 554 HCMD_NAME(SHARED_MEM_CFG_CMD), 555 HCMD_NAME(INIT_EXTENDED_CFG_CMD), 556 HCMD_NAME(FW_ERROR_RECOVERY_CMD), 557 HCMD_NAME(RFI_CONFIG_CMD), 558 HCMD_NAME(RFI_GET_FREQ_TABLE_CMD), 559 HCMD_NAME(SYSTEM_FEATURES_CONTROL_CMD), 560 HCMD_NAME(SYSTEM_STATISTICS_CMD), 561 HCMD_NAME(SYSTEM_STATISTICS_END_NOTIF), 562 HCMD_NAME(RFI_DEACTIVATE_NOTIF), 563 }; 564 565 /* Please keep this array *SORTED* by hex value. 566 * Access is done through binary search 567 */ 568 static const struct iwl_hcmd_names iwl_mvm_mac_conf_names[] = { 569 HCMD_NAME(CHANNEL_SWITCH_TIME_EVENT_CMD), 570 HCMD_NAME(SESSION_PROTECTION_CMD), 571 HCMD_NAME(MAC_CONFIG_CMD), 572 HCMD_NAME(LINK_CONFIG_CMD), 573 HCMD_NAME(STA_CONFIG_CMD), 574 HCMD_NAME(AUX_STA_CMD), 575 HCMD_NAME(STA_REMOVE_CMD), 576 HCMD_NAME(STA_DISABLE_TX_CMD), 577 HCMD_NAME(ROC_CMD), 578 HCMD_NAME(ROC_NOTIF), 579 HCMD_NAME(SESSION_PROTECTION_NOTIF), 580 HCMD_NAME(CHANNEL_SWITCH_START_NOTIF), 581 }; 582 583 /* Please keep this array *SORTED* by hex value. 584 * Access is done through binary search 585 */ 586 static const struct iwl_hcmd_names iwl_mvm_phy_names[] = { 587 HCMD_NAME(CMD_DTS_MEASUREMENT_TRIGGER_WIDE), 588 HCMD_NAME(CTDP_CONFIG_CMD), 589 HCMD_NAME(TEMP_REPORTING_THRESHOLDS_CMD), 590 HCMD_NAME(PER_CHAIN_LIMIT_OFFSET_CMD), 591 HCMD_NAME(AP_TX_POWER_CONSTRAINTS_CMD), 592 HCMD_NAME(CT_KILL_NOTIFICATION), 593 HCMD_NAME(DTS_MEASUREMENT_NOTIF_WIDE), 594 }; 595 596 /* Please keep this array *SORTED* by hex value. 597 * Access is done through binary search 598 */ 599 static const struct iwl_hcmd_names iwl_mvm_data_path_names[] = { 600 HCMD_NAME(DQA_ENABLE_CMD), 601 HCMD_NAME(UPDATE_MU_GROUPS_CMD), 602 HCMD_NAME(TRIGGER_RX_QUEUES_NOTIF_CMD), 603 HCMD_NAME(STA_HE_CTXT_CMD), 604 HCMD_NAME(RLC_CONFIG_CMD), 605 HCMD_NAME(RFH_QUEUE_CONFIG_CMD), 606 HCMD_NAME(TLC_MNG_CONFIG_CMD), 607 HCMD_NAME(CHEST_COLLECTOR_FILTER_CONFIG_CMD), 608 HCMD_NAME(SCD_QUEUE_CONFIG_CMD), 609 HCMD_NAME(SEC_KEY_CMD), 610 HCMD_NAME(MONITOR_NOTIF), 611 HCMD_NAME(THERMAL_DUAL_CHAIN_REQUEST), 612 HCMD_NAME(STA_PM_NOTIF), 613 HCMD_NAME(MU_GROUP_MGMT_NOTIF), 614 HCMD_NAME(RX_QUEUES_NOTIFICATION), 615 }; 616 617 /* Please keep this array *SORTED* by hex value. 618 * Access is done through binary search 619 */ 620 static const struct iwl_hcmd_names iwl_mvm_statistics_names[] = { 621 HCMD_NAME(STATISTICS_OPER_NOTIF), 622 HCMD_NAME(STATISTICS_OPER_PART1_NOTIF), 623 }; 624 625 /* Please keep this array *SORTED* by hex value. 626 * Access is done through binary search 627 */ 628 static const struct iwl_hcmd_names iwl_mvm_scan_names[] = { 629 HCMD_NAME(OFFLOAD_MATCH_INFO_NOTIF), 630 }; 631 632 /* Please keep this array *SORTED* by hex value. 633 * Access is done through binary search 634 */ 635 static const struct iwl_hcmd_names iwl_mvm_location_names[] = { 636 HCMD_NAME(TOF_RANGE_REQ_CMD), 637 HCMD_NAME(TOF_CONFIG_CMD), 638 HCMD_NAME(TOF_RANGE_ABORT_CMD), 639 HCMD_NAME(TOF_RANGE_REQ_EXT_CMD), 640 HCMD_NAME(TOF_RESPONDER_CONFIG_CMD), 641 HCMD_NAME(TOF_RESPONDER_DYN_CONFIG_CMD), 642 HCMD_NAME(TOF_LC_NOTIF), 643 HCMD_NAME(TOF_RESPONDER_STATS), 644 HCMD_NAME(TOF_MCSI_DEBUG_NOTIF), 645 HCMD_NAME(TOF_RANGE_RESPONSE_NOTIF), 646 }; 647 648 /* Please keep this array *SORTED* by hex value. 649 * Access is done through binary search 650 */ 651 static const struct iwl_hcmd_names iwl_mvm_prot_offload_names[] = { 652 HCMD_NAME(WOWLAN_WAKE_PKT_NOTIFICATION), 653 HCMD_NAME(WOWLAN_INFO_NOTIFICATION), 654 HCMD_NAME(D3_END_NOTIFICATION), 655 HCMD_NAME(STORED_BEACON_NTF), 656 }; 657 658 /* Please keep this array *SORTED* by hex value. 659 * Access is done through binary search 660 */ 661 static const struct iwl_hcmd_names iwl_mvm_regulatory_and_nvm_names[] = { 662 HCMD_NAME(NVM_ACCESS_COMPLETE), 663 HCMD_NAME(NVM_GET_INFO), 664 HCMD_NAME(TAS_CONFIG), 665 }; 666 667 static const struct iwl_hcmd_arr iwl_mvm_groups[] = { 668 [LEGACY_GROUP] = HCMD_ARR(iwl_mvm_legacy_names), 669 [LONG_GROUP] = HCMD_ARR(iwl_mvm_legacy_names), 670 [SYSTEM_GROUP] = HCMD_ARR(iwl_mvm_system_names), 671 [MAC_CONF_GROUP] = HCMD_ARR(iwl_mvm_mac_conf_names), 672 [PHY_OPS_GROUP] = HCMD_ARR(iwl_mvm_phy_names), 673 [DATA_PATH_GROUP] = HCMD_ARR(iwl_mvm_data_path_names), 674 [SCAN_GROUP] = HCMD_ARR(iwl_mvm_scan_names), 675 [LOCATION_GROUP] = HCMD_ARR(iwl_mvm_location_names), 676 [PROT_OFFLOAD_GROUP] = HCMD_ARR(iwl_mvm_prot_offload_names), 677 [REGULATORY_AND_NVM_GROUP] = 678 HCMD_ARR(iwl_mvm_regulatory_and_nvm_names), 679 [STATISTICS_GROUP] = HCMD_ARR(iwl_mvm_statistics_names), 680 }; 681 682 /* this forward declaration can avoid to export the function */ 683 static void iwl_mvm_async_handlers_wk(struct work_struct *wk); 684 static void iwl_mvm_async_handlers_wiphy_wk(struct wiphy *wiphy, 685 struct wiphy_work *work); 686 687 static u32 iwl_mvm_min_backoff(struct iwl_mvm *mvm) 688 { 689 const struct iwl_pwr_tx_backoff *backoff = mvm->cfg->pwr_tx_backoffs; 690 u64 dflt_pwr_limit; 691 692 if (!backoff) 693 return 0; 694 695 iwl_bios_get_pwr_limit(&mvm->fwrt, &dflt_pwr_limit); 696 697 while (backoff->pwr) { 698 if (dflt_pwr_limit >= backoff->pwr) 699 return backoff->backoff; 700 701 backoff++; 702 } 703 704 return 0; 705 } 706 707 static void iwl_mvm_tx_unblock_dwork(struct work_struct *work) 708 { 709 struct iwl_mvm *mvm = 710 container_of(work, struct iwl_mvm, cs_tx_unblock_dwork.work); 711 struct ieee80211_vif *tx_blocked_vif; 712 struct iwl_mvm_vif *mvmvif; 713 714 mutex_lock(&mvm->mutex); 715 716 tx_blocked_vif = 717 rcu_dereference_protected(mvm->csa_tx_blocked_vif, 718 lockdep_is_held(&mvm->mutex)); 719 720 if (!tx_blocked_vif) 721 goto unlock; 722 723 mvmvif = iwl_mvm_vif_from_mac80211(tx_blocked_vif); 724 iwl_mvm_modify_all_sta_disable_tx(mvm, mvmvif, false); 725 RCU_INIT_POINTER(mvm->csa_tx_blocked_vif, NULL); 726 unlock: 727 mutex_unlock(&mvm->mutex); 728 } 729 730 static void iwl_mvm_fwrt_dump_start(void *ctx) 731 { 732 struct iwl_mvm *mvm = ctx; 733 734 mutex_lock(&mvm->mutex); 735 } 736 737 static void iwl_mvm_fwrt_dump_end(void *ctx) 738 { 739 struct iwl_mvm *mvm = ctx; 740 741 mutex_unlock(&mvm->mutex); 742 } 743 744 static bool iwl_mvm_fwrt_fw_running(void *ctx) 745 { 746 return iwl_mvm_firmware_running(ctx); 747 } 748 749 static int iwl_mvm_fwrt_send_hcmd(void *ctx, struct iwl_host_cmd *host_cmd) 750 { 751 struct iwl_mvm *mvm = (struct iwl_mvm *)ctx; 752 int ret; 753 754 mutex_lock(&mvm->mutex); 755 ret = iwl_mvm_send_cmd(mvm, host_cmd); 756 mutex_unlock(&mvm->mutex); 757 758 return ret; 759 } 760 761 static bool iwl_mvm_d3_debug_enable(void *ctx) 762 { 763 return IWL_MVM_D3_DEBUG; 764 } 765 766 static const struct iwl_fw_runtime_ops iwl_mvm_fwrt_ops = { 767 .dump_start = iwl_mvm_fwrt_dump_start, 768 .dump_end = iwl_mvm_fwrt_dump_end, 769 .fw_running = iwl_mvm_fwrt_fw_running, 770 .send_hcmd = iwl_mvm_fwrt_send_hcmd, 771 .d3_debug_enable = iwl_mvm_d3_debug_enable, 772 }; 773 774 static int iwl_mvm_start_get_nvm(struct iwl_mvm *mvm) 775 { 776 struct iwl_trans *trans = mvm->trans; 777 int ret; 778 779 if (trans->csme_own) { 780 if (WARN(!mvm->mei_registered, 781 "csme is owner, but we aren't registered to iwlmei\n")) 782 goto get_nvm_from_fw; 783 784 mvm->mei_nvm_data = iwl_mei_get_nvm(); 785 if (mvm->mei_nvm_data) { 786 /* 787 * mvm->mei_nvm_data is set and because of that, 788 * we'll load the NVM from the FW when we'll get 789 * ownership. 790 */ 791 mvm->nvm_data = 792 iwl_parse_mei_nvm_data(trans, trans->cfg, 793 mvm->mei_nvm_data, 794 mvm->fw, 795 mvm->set_tx_ant, 796 mvm->set_rx_ant); 797 return 0; 798 } 799 800 IWL_ERR(mvm, 801 "Got a NULL NVM from CSME, trying to get it from the device\n"); 802 } 803 804 get_nvm_from_fw: 805 rtnl_lock(); 806 wiphy_lock(mvm->hw->wiphy); 807 mutex_lock(&mvm->mutex); 808 809 ret = iwl_trans_start_hw(mvm->trans); 810 if (ret) { 811 mutex_unlock(&mvm->mutex); 812 wiphy_unlock(mvm->hw->wiphy); 813 rtnl_unlock(); 814 return ret; 815 } 816 817 ret = iwl_run_init_mvm_ucode(mvm); 818 if (ret && ret != -ERFKILL) 819 iwl_fw_dbg_error_collect(&mvm->fwrt, FW_DBG_TRIGGER_DRIVER); 820 if (!ret && iwl_mvm_is_lar_supported(mvm)) { 821 mvm->hw->wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED; 822 ret = iwl_mvm_init_mcc(mvm); 823 } 824 825 if (!iwlmvm_mod_params.init_dbg || !ret) 826 iwl_mvm_stop_device(mvm); 827 828 mutex_unlock(&mvm->mutex); 829 wiphy_unlock(mvm->hw->wiphy); 830 rtnl_unlock(); 831 832 if (ret) 833 IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret); 834 835 /* no longer need this regardless of failure or not */ 836 mvm->pldr_sync = false; 837 838 return ret; 839 } 840 841 static int iwl_mvm_start_post_nvm(struct iwl_mvm *mvm) 842 { 843 struct iwl_mvm_csme_conn_info *csme_conn_info __maybe_unused; 844 int ret; 845 846 iwl_mvm_toggle_tx_ant(mvm, &mvm->mgmt_last_antenna_idx); 847 848 ret = iwl_mvm_mac_setup_register(mvm); 849 if (ret) 850 return ret; 851 852 mvm->hw_registered = true; 853 854 iwl_mvm_dbgfs_register(mvm); 855 856 wiphy_rfkill_set_hw_state_reason(mvm->hw->wiphy, 857 mvm->mei_rfkill_blocked, 858 RFKILL_HARD_BLOCK_NOT_OWNER); 859 860 iwl_mvm_mei_set_sw_rfkill_state(mvm); 861 862 return 0; 863 } 864 865 struct iwl_mvm_frob_txf_data { 866 u8 *buf; 867 size_t buflen; 868 }; 869 870 static void iwl_mvm_frob_txf_key_iter(struct ieee80211_hw *hw, 871 struct ieee80211_vif *vif, 872 struct ieee80211_sta *sta, 873 struct ieee80211_key_conf *key, 874 void *data) 875 { 876 struct iwl_mvm_frob_txf_data *txf = data; 877 u8 keylen, match, matchend; 878 u8 *keydata; 879 size_t i; 880 881 switch (key->cipher) { 882 case WLAN_CIPHER_SUITE_CCMP: 883 keydata = key->key; 884 keylen = key->keylen; 885 break; 886 case WLAN_CIPHER_SUITE_WEP40: 887 case WLAN_CIPHER_SUITE_WEP104: 888 case WLAN_CIPHER_SUITE_TKIP: 889 /* 890 * WEP has short keys which might show up in the payload, 891 * and then you can deduce the key, so in this case just 892 * remove all FIFO data. 893 * For TKIP, we don't know the phase 2 keys here, so same. 894 */ 895 memset(txf->buf, 0xBB, txf->buflen); 896 return; 897 default: 898 return; 899 } 900 901 /* scan for key material and clear it out */ 902 match = 0; 903 for (i = 0; i < txf->buflen; i++) { 904 if (txf->buf[i] != keydata[match]) { 905 match = 0; 906 continue; 907 } 908 match++; 909 if (match == keylen) { 910 memset(txf->buf + i - keylen, 0xAA, keylen); 911 match = 0; 912 } 913 } 914 915 /* we're dealing with a FIFO, so check wrapped around data */ 916 matchend = match; 917 for (i = 0; match && i < keylen - match; i++) { 918 if (txf->buf[i] != keydata[match]) 919 break; 920 match++; 921 if (match == keylen) { 922 memset(txf->buf, 0xAA, i + 1); 923 memset(txf->buf + txf->buflen - matchend, 0xAA, 924 matchend); 925 break; 926 } 927 } 928 } 929 930 static void iwl_mvm_frob_txf(void *ctx, void *buf, size_t buflen) 931 { 932 struct iwl_mvm_frob_txf_data txf = { 933 .buf = buf, 934 .buflen = buflen, 935 }; 936 struct iwl_mvm *mvm = ctx; 937 938 /* embedded key material exists only on old API */ 939 if (iwl_mvm_has_new_tx_api(mvm)) 940 return; 941 942 rcu_read_lock(); 943 ieee80211_iter_keys_rcu(mvm->hw, NULL, iwl_mvm_frob_txf_key_iter, &txf); 944 rcu_read_unlock(); 945 } 946 947 static void iwl_mvm_frob_hcmd(void *ctx, void *hcmd, size_t len) 948 { 949 /* we only use wide headers for commands */ 950 struct iwl_cmd_header_wide *hdr = hcmd; 951 unsigned int frob_start = sizeof(*hdr), frob_end = 0; 952 953 if (len < sizeof(hdr)) 954 return; 955 956 /* all the commands we care about are in LONG_GROUP */ 957 if (hdr->group_id != LONG_GROUP) 958 return; 959 960 switch (hdr->cmd) { 961 case WEP_KEY: 962 case WOWLAN_TKIP_PARAM: 963 case WOWLAN_KEK_KCK_MATERIAL: 964 case ADD_STA_KEY: 965 /* 966 * blank out everything here, easier than dealing 967 * with the various versions of the command 968 */ 969 frob_end = INT_MAX; 970 break; 971 case MGMT_MCAST_KEY: 972 frob_start = offsetof(struct iwl_mvm_mgmt_mcast_key_cmd, igtk); 973 BUILD_BUG_ON(offsetof(struct iwl_mvm_mgmt_mcast_key_cmd, igtk) != 974 offsetof(struct iwl_mvm_mgmt_mcast_key_cmd_v1, igtk)); 975 976 frob_end = offsetofend(struct iwl_mvm_mgmt_mcast_key_cmd, igtk); 977 BUILD_BUG_ON(offsetof(struct iwl_mvm_mgmt_mcast_key_cmd, igtk) < 978 offsetof(struct iwl_mvm_mgmt_mcast_key_cmd_v1, igtk)); 979 break; 980 } 981 982 if (frob_start >= frob_end) 983 return; 984 985 if (frob_end > len) 986 frob_end = len; 987 988 memset((u8 *)hcmd + frob_start, 0xAA, frob_end - frob_start); 989 } 990 991 static void iwl_mvm_frob_mem(void *ctx, u32 mem_addr, void *mem, size_t buflen) 992 { 993 const struct iwl_dump_exclude *excl; 994 struct iwl_mvm *mvm = ctx; 995 int i; 996 997 switch (mvm->fwrt.cur_fw_img) { 998 case IWL_UCODE_INIT: 999 default: 1000 /* not relevant */ 1001 return; 1002 case IWL_UCODE_REGULAR: 1003 case IWL_UCODE_REGULAR_USNIFFER: 1004 excl = mvm->fw->dump_excl; 1005 break; 1006 case IWL_UCODE_WOWLAN: 1007 excl = mvm->fw->dump_excl_wowlan; 1008 break; 1009 } 1010 1011 BUILD_BUG_ON(sizeof(mvm->fw->dump_excl) != 1012 sizeof(mvm->fw->dump_excl_wowlan)); 1013 1014 for (i = 0; i < ARRAY_SIZE(mvm->fw->dump_excl); i++) { 1015 u32 start, end; 1016 1017 if (!excl[i].addr || !excl[i].size) 1018 continue; 1019 1020 start = excl[i].addr; 1021 end = start + excl[i].size; 1022 1023 if (end <= mem_addr || start >= mem_addr + buflen) 1024 continue; 1025 1026 if (start < mem_addr) 1027 start = mem_addr; 1028 1029 if (end > mem_addr + buflen) 1030 end = mem_addr + buflen; 1031 1032 memset((u8 *)mem + start - mem_addr, 0xAA, end - start); 1033 } 1034 } 1035 1036 static const struct iwl_dump_sanitize_ops iwl_mvm_sanitize_ops = { 1037 .frob_txf = iwl_mvm_frob_txf, 1038 .frob_hcmd = iwl_mvm_frob_hcmd, 1039 .frob_mem = iwl_mvm_frob_mem, 1040 }; 1041 1042 static void iwl_mvm_me_conn_status(void *priv, const struct iwl_mei_conn_info *conn_info) 1043 { 1044 struct iwl_mvm *mvm = priv; 1045 struct iwl_mvm_csme_conn_info *prev_conn_info, *curr_conn_info; 1046 1047 /* 1048 * This is protected by the guarantee that this function will not be 1049 * called twice on two different threads 1050 */ 1051 prev_conn_info = rcu_dereference_protected(mvm->csme_conn_info, true); 1052 1053 curr_conn_info = kzalloc(sizeof(*curr_conn_info), GFP_KERNEL); 1054 if (!curr_conn_info) 1055 return; 1056 1057 curr_conn_info->conn_info = *conn_info; 1058 1059 rcu_assign_pointer(mvm->csme_conn_info, curr_conn_info); 1060 1061 if (prev_conn_info) 1062 kfree_rcu(prev_conn_info, rcu_head); 1063 } 1064 1065 static void iwl_mvm_mei_rfkill(void *priv, bool blocked, 1066 bool csme_taking_ownership) 1067 { 1068 struct iwl_mvm *mvm = priv; 1069 1070 if (blocked && !csme_taking_ownership) 1071 return; 1072 1073 mvm->mei_rfkill_blocked = blocked; 1074 if (!mvm->hw_registered) 1075 return; 1076 1077 wiphy_rfkill_set_hw_state_reason(mvm->hw->wiphy, 1078 mvm->mei_rfkill_blocked, 1079 RFKILL_HARD_BLOCK_NOT_OWNER); 1080 } 1081 1082 static void iwl_mvm_mei_roaming_forbidden(void *priv, bool forbidden) 1083 { 1084 struct iwl_mvm *mvm = priv; 1085 1086 if (!mvm->hw_registered || !mvm->csme_vif) 1087 return; 1088 1089 iwl_mvm_send_roaming_forbidden_event(mvm, mvm->csme_vif, forbidden); 1090 } 1091 1092 static void iwl_mvm_sap_connected_wk(struct work_struct *wk) 1093 { 1094 struct iwl_mvm *mvm = 1095 container_of(wk, struct iwl_mvm, sap_connected_wk); 1096 int ret; 1097 1098 ret = iwl_mvm_start_get_nvm(mvm); 1099 if (ret) 1100 goto out_free; 1101 1102 ret = iwl_mvm_start_post_nvm(mvm); 1103 if (ret) 1104 goto out_free; 1105 1106 return; 1107 1108 out_free: 1109 IWL_ERR(mvm, "Couldn't get started...\n"); 1110 iwl_mei_start_unregister(); 1111 iwl_mei_unregister_complete(); 1112 iwl_fw_flush_dumps(&mvm->fwrt); 1113 iwl_mvm_thermal_exit(mvm); 1114 iwl_fw_runtime_free(&mvm->fwrt); 1115 iwl_phy_db_free(mvm->phy_db); 1116 kfree(mvm->scan_cmd); 1117 iwl_trans_op_mode_leave(mvm->trans); 1118 kfree(mvm->nvm_data); 1119 kfree(mvm->mei_nvm_data); 1120 1121 ieee80211_free_hw(mvm->hw); 1122 } 1123 1124 static void iwl_mvm_mei_sap_connected(void *priv) 1125 { 1126 struct iwl_mvm *mvm = priv; 1127 1128 if (!mvm->hw_registered) 1129 schedule_work(&mvm->sap_connected_wk); 1130 } 1131 1132 static void iwl_mvm_mei_nic_stolen(void *priv) 1133 { 1134 struct iwl_mvm *mvm = priv; 1135 1136 rtnl_lock(); 1137 cfg80211_shutdown_all_interfaces(mvm->hw->wiphy); 1138 rtnl_unlock(); 1139 } 1140 1141 static const struct iwl_mei_ops mei_ops = { 1142 .me_conn_status = iwl_mvm_me_conn_status, 1143 .rfkill = iwl_mvm_mei_rfkill, 1144 .roaming_forbidden = iwl_mvm_mei_roaming_forbidden, 1145 .sap_connected = iwl_mvm_mei_sap_connected, 1146 .nic_stolen = iwl_mvm_mei_nic_stolen, 1147 }; 1148 1149 static struct iwl_op_mode * 1150 iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg, 1151 const struct iwl_fw *fw, struct dentry *dbgfs_dir) 1152 { 1153 struct ieee80211_hw *hw; 1154 struct iwl_op_mode *op_mode; 1155 struct iwl_mvm *mvm; 1156 struct iwl_trans_config trans_cfg = {}; 1157 static const u8 no_reclaim_cmds[] = { 1158 TX_CMD, 1159 }; 1160 u32 max_agg; 1161 size_t scan_size; 1162 u32 min_backoff; 1163 struct iwl_mvm_csme_conn_info *csme_conn_info __maybe_unused; 1164 1165 /* 1166 * We use IWL_MVM_STATION_COUNT_MAX to check the validity of the station 1167 * index all over the driver - check that its value corresponds to the 1168 * array size. 1169 */ 1170 BUILD_BUG_ON(ARRAY_SIZE(mvm->fw_id_to_mac_id) != 1171 IWL_MVM_STATION_COUNT_MAX); 1172 1173 /******************************** 1174 * 1. Allocating and configuring HW data 1175 ********************************/ 1176 hw = ieee80211_alloc_hw(sizeof(struct iwl_op_mode) + 1177 sizeof(struct iwl_mvm), 1178 iwl_mvm_has_mld_api(fw) ? &iwl_mvm_mld_hw_ops : 1179 &iwl_mvm_hw_ops); 1180 if (!hw) 1181 return NULL; 1182 1183 if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_BZ) 1184 max_agg = 512; 1185 else 1186 max_agg = IEEE80211_MAX_AMPDU_BUF_HE; 1187 1188 hw->max_rx_aggregation_subframes = max_agg; 1189 1190 if (cfg->max_tx_agg_size) 1191 hw->max_tx_aggregation_subframes = cfg->max_tx_agg_size; 1192 else 1193 hw->max_tx_aggregation_subframes = max_agg; 1194 1195 op_mode = hw->priv; 1196 1197 mvm = IWL_OP_MODE_GET_MVM(op_mode); 1198 mvm->dev = trans->dev; 1199 mvm->trans = trans; 1200 mvm->cfg = cfg; 1201 mvm->fw = fw; 1202 mvm->hw = hw; 1203 1204 iwl_fw_runtime_init(&mvm->fwrt, trans, fw, &iwl_mvm_fwrt_ops, mvm, 1205 &iwl_mvm_sanitize_ops, mvm, dbgfs_dir); 1206 1207 iwl_mvm_get_bios_tables(mvm); 1208 iwl_uefi_get_sgom_table(trans, &mvm->fwrt); 1209 iwl_uefi_get_step_table(trans); 1210 1211 mvm->init_status = 0; 1212 1213 if (iwl_mvm_has_new_rx_api(mvm)) { 1214 op_mode->ops = &iwl_mvm_ops_mq; 1215 trans->rx_mpdu_cmd_hdr_size = 1216 (trans->trans_cfg->device_family >= 1217 IWL_DEVICE_FAMILY_AX210) ? 1218 sizeof(struct iwl_rx_mpdu_desc) : 1219 IWL_RX_DESC_SIZE_V1; 1220 } else { 1221 op_mode->ops = &iwl_mvm_ops; 1222 trans->rx_mpdu_cmd_hdr_size = 1223 sizeof(struct iwl_rx_mpdu_res_start); 1224 1225 if (WARN_ON(trans->num_rx_queues > 1)) 1226 goto out_free; 1227 } 1228 1229 mvm->fw_restart = iwlwifi_mod_params.fw_restart ? -1 : 0; 1230 1231 if (iwl_mvm_has_new_tx_api(mvm)) { 1232 /* 1233 * If we have the new TX/queue allocation API initialize them 1234 * all to invalid numbers. We'll rewrite the ones that we need 1235 * later, but that doesn't happen for all of them all of the 1236 * time (e.g. P2P Device is optional), and if a dynamic queue 1237 * ends up getting number 2 (IWL_MVM_DQA_P2P_DEVICE_QUEUE) then 1238 * iwl_mvm_is_static_queue() erroneously returns true, and we 1239 * might have things getting stuck. 1240 */ 1241 mvm->aux_queue = IWL_MVM_INVALID_QUEUE; 1242 mvm->snif_queue = IWL_MVM_INVALID_QUEUE; 1243 mvm->probe_queue = IWL_MVM_INVALID_QUEUE; 1244 mvm->p2p_dev_queue = IWL_MVM_INVALID_QUEUE; 1245 } else { 1246 mvm->aux_queue = IWL_MVM_DQA_AUX_QUEUE; 1247 mvm->snif_queue = IWL_MVM_DQA_INJECT_MONITOR_QUEUE; 1248 mvm->probe_queue = IWL_MVM_DQA_AP_PROBE_RESP_QUEUE; 1249 mvm->p2p_dev_queue = IWL_MVM_DQA_P2P_DEVICE_QUEUE; 1250 } 1251 1252 mvm->sf_state = SF_UNINIT; 1253 if (iwl_mvm_has_unified_ucode(mvm)) 1254 iwl_fw_set_current_image(&mvm->fwrt, IWL_UCODE_REGULAR); 1255 else 1256 iwl_fw_set_current_image(&mvm->fwrt, IWL_UCODE_INIT); 1257 mvm->drop_bcn_ap_mode = true; 1258 1259 mutex_init(&mvm->mutex); 1260 spin_lock_init(&mvm->async_handlers_lock); 1261 INIT_LIST_HEAD(&mvm->time_event_list); 1262 INIT_LIST_HEAD(&mvm->aux_roc_te_list); 1263 INIT_LIST_HEAD(&mvm->async_handlers_list); 1264 spin_lock_init(&mvm->time_event_lock); 1265 INIT_LIST_HEAD(&mvm->ftm_initiator.loc_list); 1266 INIT_LIST_HEAD(&mvm->ftm_initiator.pasn_list); 1267 INIT_LIST_HEAD(&mvm->resp_pasn_list); 1268 1269 INIT_WORK(&mvm->async_handlers_wk, iwl_mvm_async_handlers_wk); 1270 INIT_WORK(&mvm->roc_done_wk, iwl_mvm_roc_done_wk); 1271 INIT_WORK(&mvm->sap_connected_wk, iwl_mvm_sap_connected_wk); 1272 INIT_DELAYED_WORK(&mvm->tdls_cs.dwork, iwl_mvm_tdls_ch_switch_work); 1273 INIT_DELAYED_WORK(&mvm->scan_timeout_dwork, iwl_mvm_scan_timeout_wk); 1274 INIT_WORK(&mvm->add_stream_wk, iwl_mvm_add_new_dqa_stream_wk); 1275 INIT_LIST_HEAD(&mvm->add_stream_txqs); 1276 spin_lock_init(&mvm->add_stream_lock); 1277 1278 wiphy_work_init(&mvm->async_handlers_wiphy_wk, 1279 iwl_mvm_async_handlers_wiphy_wk); 1280 init_waitqueue_head(&mvm->rx_sync_waitq); 1281 1282 mvm->queue_sync_state = 0; 1283 1284 SET_IEEE80211_DEV(mvm->hw, mvm->trans->dev); 1285 1286 spin_lock_init(&mvm->tcm.lock); 1287 INIT_DELAYED_WORK(&mvm->tcm.work, iwl_mvm_tcm_work); 1288 mvm->tcm.ts = jiffies; 1289 mvm->tcm.ll_ts = jiffies; 1290 mvm->tcm.uapsd_nonagg_ts = jiffies; 1291 1292 INIT_DELAYED_WORK(&mvm->cs_tx_unblock_dwork, iwl_mvm_tx_unblock_dwork); 1293 1294 mvm->cmd_ver.range_resp = 1295 iwl_fw_lookup_notif_ver(mvm->fw, LOCATION_GROUP, 1296 TOF_RANGE_RESPONSE_NOTIF, 5); 1297 /* we only support up to version 9 */ 1298 if (WARN_ON_ONCE(mvm->cmd_ver.range_resp > 9)) 1299 goto out_free; 1300 1301 /* 1302 * Populate the state variables that the transport layer needs 1303 * to know about. 1304 */ 1305 trans_cfg.op_mode = op_mode; 1306 trans_cfg.no_reclaim_cmds = no_reclaim_cmds; 1307 trans_cfg.n_no_reclaim_cmds = ARRAY_SIZE(no_reclaim_cmds); 1308 1309 switch (iwlwifi_mod_params.amsdu_size) { 1310 case IWL_AMSDU_DEF: 1311 trans_cfg.rx_buf_size = IWL_AMSDU_4K; 1312 break; 1313 case IWL_AMSDU_4K: 1314 trans_cfg.rx_buf_size = IWL_AMSDU_4K; 1315 break; 1316 case IWL_AMSDU_8K: 1317 trans_cfg.rx_buf_size = IWL_AMSDU_8K; 1318 break; 1319 case IWL_AMSDU_12K: 1320 trans_cfg.rx_buf_size = IWL_AMSDU_12K; 1321 break; 1322 default: 1323 pr_err("%s: Unsupported amsdu_size: %d\n", KBUILD_MODNAME, 1324 iwlwifi_mod_params.amsdu_size); 1325 trans_cfg.rx_buf_size = IWL_AMSDU_4K; 1326 } 1327 1328 trans->wide_cmd_header = true; 1329 trans_cfg.bc_table_dword = 1330 mvm->trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_AX210; 1331 1332 trans_cfg.command_groups = iwl_mvm_groups; 1333 trans_cfg.command_groups_size = ARRAY_SIZE(iwl_mvm_groups); 1334 1335 trans_cfg.cmd_queue = IWL_MVM_DQA_CMD_QUEUE; 1336 trans_cfg.cmd_fifo = IWL_MVM_TX_FIFO_CMD; 1337 trans_cfg.scd_set_active = true; 1338 1339 trans_cfg.cb_data_offs = offsetof(struct ieee80211_tx_info, 1340 driver_data[2]); 1341 1342 /* Set a short watchdog for the command queue */ 1343 trans_cfg.cmd_q_wdg_timeout = 1344 iwl_mvm_get_wd_timeout(mvm, NULL, false, true); 1345 1346 snprintf(mvm->hw->wiphy->fw_version, 1347 sizeof(mvm->hw->wiphy->fw_version), 1348 "%.31s", fw->fw_version); 1349 1350 trans_cfg.fw_reset_handshake = fw_has_capa(&mvm->fw->ucode_capa, 1351 IWL_UCODE_TLV_CAPA_FW_RESET_HANDSHAKE); 1352 1353 trans_cfg.queue_alloc_cmd_ver = 1354 iwl_fw_lookup_cmd_ver(mvm->fw, 1355 WIDE_ID(DATA_PATH_GROUP, 1356 SCD_QUEUE_CONFIG_CMD), 1357 0); 1358 mvm->sta_remove_requires_queue_remove = 1359 trans_cfg.queue_alloc_cmd_ver > 0; 1360 1361 mvm->mld_api_is_used = iwl_mvm_has_mld_api(mvm->fw); 1362 1363 /* Configure transport layer */ 1364 iwl_trans_configure(mvm->trans, &trans_cfg); 1365 1366 trans->rx_mpdu_cmd = REPLY_RX_MPDU_CMD; 1367 trans->dbg.dest_tlv = mvm->fw->dbg.dest_tlv; 1368 trans->dbg.n_dest_reg = mvm->fw->dbg.n_dest_reg; 1369 memcpy(trans->dbg.conf_tlv, mvm->fw->dbg.conf_tlv, 1370 sizeof(trans->dbg.conf_tlv)); 1371 trans->dbg.trigger_tlv = mvm->fw->dbg.trigger_tlv; 1372 1373 trans->iml = mvm->fw->iml; 1374 trans->iml_len = mvm->fw->iml_len; 1375 1376 /* set up notification wait support */ 1377 iwl_notification_wait_init(&mvm->notif_wait); 1378 1379 /* Init phy db */ 1380 mvm->phy_db = iwl_phy_db_init(trans); 1381 if (!mvm->phy_db) { 1382 IWL_ERR(mvm, "Cannot init phy_db\n"); 1383 goto out_free; 1384 } 1385 1386 IWL_INFO(mvm, "Detected %s, REV=0x%X\n", 1387 mvm->trans->name, mvm->trans->hw_rev); 1388 1389 if (iwlwifi_mod_params.nvm_file) 1390 mvm->nvm_file_name = iwlwifi_mod_params.nvm_file; 1391 else 1392 IWL_DEBUG_EEPROM(mvm->trans->dev, 1393 "working without external nvm file\n"); 1394 1395 scan_size = iwl_mvm_scan_size(mvm); 1396 1397 mvm->scan_cmd = kmalloc(scan_size, GFP_KERNEL); 1398 if (!mvm->scan_cmd) 1399 goto out_free; 1400 mvm->scan_cmd_size = scan_size; 1401 1402 /* invalidate ids to prevent accidental removal of sta_id 0 */ 1403 mvm->aux_sta.sta_id = IWL_MVM_INVALID_STA; 1404 mvm->snif_sta.sta_id = IWL_MVM_INVALID_STA; 1405 1406 /* Set EBS as successful as long as not stated otherwise by the FW. */ 1407 mvm->last_ebs_successful = true; 1408 1409 min_backoff = iwl_mvm_min_backoff(mvm); 1410 iwl_mvm_thermal_initialize(mvm, min_backoff); 1411 1412 if (!iwl_mvm_has_new_rx_stats_api(mvm)) 1413 memset(&mvm->rx_stats_v3, 0, 1414 sizeof(struct mvm_statistics_rx_v3)); 1415 else 1416 memset(&mvm->rx_stats, 0, sizeof(struct mvm_statistics_rx)); 1417 1418 iwl_mvm_ftm_initiator_smooth_config(mvm); 1419 1420 iwl_mvm_init_time_sync(&mvm->time_sync); 1421 1422 mvm->debugfs_dir = dbgfs_dir; 1423 1424 mvm->mei_registered = !iwl_mei_register(mvm, &mei_ops); 1425 1426 iwl_mvm_mei_scan_filter_init(&mvm->mei_scan_filter); 1427 1428 if (iwl_mvm_start_get_nvm(mvm)) { 1429 /* 1430 * Getting NVM failed while CSME is the owner, but we are 1431 * registered to MEI, we'll get the NVM later when it'll be 1432 * possible to get it from CSME. 1433 */ 1434 if (trans->csme_own && mvm->mei_registered) 1435 return op_mode; 1436 1437 goto out_thermal_exit; 1438 } 1439 1440 1441 if (iwl_mvm_start_post_nvm(mvm)) 1442 goto out_thermal_exit; 1443 1444 return op_mode; 1445 1446 out_thermal_exit: 1447 iwl_mvm_thermal_exit(mvm); 1448 if (mvm->mei_registered) { 1449 iwl_mei_start_unregister(); 1450 iwl_mei_unregister_complete(); 1451 } 1452 out_free: 1453 iwl_fw_flush_dumps(&mvm->fwrt); 1454 iwl_fw_runtime_free(&mvm->fwrt); 1455 1456 if (iwlmvm_mod_params.init_dbg) 1457 return op_mode; 1458 iwl_phy_db_free(mvm->phy_db); 1459 kfree(mvm->scan_cmd); 1460 iwl_trans_op_mode_leave(trans); 1461 1462 ieee80211_free_hw(mvm->hw); 1463 return NULL; 1464 } 1465 1466 void iwl_mvm_stop_device(struct iwl_mvm *mvm) 1467 { 1468 lockdep_assert_held(&mvm->mutex); 1469 1470 iwl_fw_cancel_timestamp(&mvm->fwrt); 1471 1472 clear_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status); 1473 1474 iwl_fw_dbg_stop_sync(&mvm->fwrt); 1475 iwl_trans_stop_device(mvm->trans); 1476 iwl_free_fw_paging(&mvm->fwrt); 1477 iwl_fw_dump_conf_clear(&mvm->fwrt); 1478 iwl_mvm_mei_device_state(mvm, false); 1479 } 1480 1481 static void iwl_op_mode_mvm_stop(struct iwl_op_mode *op_mode) 1482 { 1483 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 1484 int i; 1485 1486 if (mvm->mei_registered) { 1487 rtnl_lock(); 1488 iwl_mei_set_netdev(NULL); 1489 rtnl_unlock(); 1490 iwl_mei_start_unregister(); 1491 } 1492 1493 /* 1494 * After we unregister from mei, the worker can't be scheduled 1495 * anymore. 1496 */ 1497 cancel_work_sync(&mvm->sap_connected_wk); 1498 1499 iwl_mvm_leds_exit(mvm); 1500 1501 iwl_mvm_thermal_exit(mvm); 1502 1503 /* 1504 * If we couldn't get ownership on the device and we couldn't 1505 * get the NVM from CSME, we haven't registered to mac80211. 1506 * In that case, we didn't fail op_mode_start, because we are 1507 * waiting for CSME to allow us to get the NVM to register to 1508 * mac80211. If that didn't happen, we haven't registered to 1509 * mac80211, hence the if below. 1510 */ 1511 if (mvm->hw_registered) 1512 ieee80211_unregister_hw(mvm->hw); 1513 1514 kfree(mvm->scan_cmd); 1515 kfree(mvm->mcast_filter_cmd); 1516 mvm->mcast_filter_cmd = NULL; 1517 1518 kfree(mvm->error_recovery_buf); 1519 mvm->error_recovery_buf = NULL; 1520 1521 iwl_mvm_ptp_remove(mvm); 1522 1523 iwl_trans_op_mode_leave(mvm->trans); 1524 1525 iwl_phy_db_free(mvm->phy_db); 1526 mvm->phy_db = NULL; 1527 1528 kfree(mvm->nvm_data); 1529 kfree(mvm->mei_nvm_data); 1530 kfree(rcu_access_pointer(mvm->csme_conn_info)); 1531 kfree(mvm->temp_nvm_data); 1532 for (i = 0; i < NVM_MAX_NUM_SECTIONS; i++) 1533 kfree(mvm->nvm_sections[i].data); 1534 1535 cancel_delayed_work_sync(&mvm->tcm.work); 1536 1537 iwl_fw_runtime_free(&mvm->fwrt); 1538 mutex_destroy(&mvm->mutex); 1539 1540 if (mvm->mei_registered) 1541 iwl_mei_unregister_complete(); 1542 1543 ieee80211_free_hw(mvm->hw); 1544 } 1545 1546 struct iwl_async_handler_entry { 1547 struct list_head list; 1548 struct iwl_rx_cmd_buffer rxb; 1549 enum iwl_rx_handler_context context; 1550 void (*fn)(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb); 1551 }; 1552 1553 void iwl_mvm_async_handlers_purge(struct iwl_mvm *mvm) 1554 { 1555 struct iwl_async_handler_entry *entry, *tmp; 1556 1557 spin_lock_bh(&mvm->async_handlers_lock); 1558 list_for_each_entry_safe(entry, tmp, &mvm->async_handlers_list, list) { 1559 iwl_free_rxb(&entry->rxb); 1560 list_del(&entry->list); 1561 kfree(entry); 1562 } 1563 spin_unlock_bh(&mvm->async_handlers_lock); 1564 } 1565 1566 /* 1567 * This function receives a bitmap of rx async handler contexts 1568 * (&iwl_rx_handler_context) to handle, and runs only them 1569 */ 1570 static void iwl_mvm_async_handlers_by_context(struct iwl_mvm *mvm, 1571 u8 contexts) 1572 { 1573 struct iwl_async_handler_entry *entry, *tmp; 1574 LIST_HEAD(local_list); 1575 1576 /* 1577 * Sync with Rx path with a lock. Remove all the entries of the 1578 * wanted contexts from this list, add them to a local one (lock free), 1579 * and then handle them. 1580 */ 1581 spin_lock_bh(&mvm->async_handlers_lock); 1582 list_for_each_entry_safe(entry, tmp, &mvm->async_handlers_list, list) { 1583 if (!(BIT(entry->context) & contexts)) 1584 continue; 1585 list_del(&entry->list); 1586 list_add_tail(&entry->list, &local_list); 1587 } 1588 spin_unlock_bh(&mvm->async_handlers_lock); 1589 1590 list_for_each_entry_safe(entry, tmp, &local_list, list) { 1591 if (entry->context != RX_HANDLER_ASYNC_UNLOCKED) 1592 mutex_lock(&mvm->mutex); 1593 entry->fn(mvm, &entry->rxb); 1594 iwl_free_rxb(&entry->rxb); 1595 list_del(&entry->list); 1596 if (entry->context != RX_HANDLER_ASYNC_UNLOCKED) 1597 mutex_unlock(&mvm->mutex); 1598 kfree(entry); 1599 } 1600 } 1601 1602 static void iwl_mvm_async_handlers_wiphy_wk(struct wiphy *wiphy, 1603 struct wiphy_work *wk) 1604 { 1605 struct iwl_mvm *mvm = 1606 container_of(wk, struct iwl_mvm, async_handlers_wiphy_wk); 1607 u8 contexts = BIT(RX_HANDLER_ASYNC_LOCKED_WIPHY); 1608 1609 iwl_mvm_async_handlers_by_context(mvm, contexts); 1610 } 1611 1612 static void iwl_mvm_async_handlers_wk(struct work_struct *wk) 1613 { 1614 struct iwl_mvm *mvm = 1615 container_of(wk, struct iwl_mvm, async_handlers_wk); 1616 u8 contexts = BIT(RX_HANDLER_ASYNC_LOCKED) | 1617 BIT(RX_HANDLER_ASYNC_UNLOCKED); 1618 1619 iwl_mvm_async_handlers_by_context(mvm, contexts); 1620 } 1621 1622 static inline void iwl_mvm_rx_check_trigger(struct iwl_mvm *mvm, 1623 struct iwl_rx_packet *pkt) 1624 { 1625 struct iwl_fw_dbg_trigger_tlv *trig; 1626 struct iwl_fw_dbg_trigger_cmd *cmds_trig; 1627 int i; 1628 1629 trig = iwl_fw_dbg_trigger_on(&mvm->fwrt, NULL, 1630 FW_DBG_TRIGGER_FW_NOTIF); 1631 if (!trig) 1632 return; 1633 1634 cmds_trig = (void *)trig->data; 1635 1636 for (i = 0; i < ARRAY_SIZE(cmds_trig->cmds); i++) { 1637 /* don't collect on CMD 0 */ 1638 if (!cmds_trig->cmds[i].cmd_id) 1639 break; 1640 1641 if (cmds_trig->cmds[i].cmd_id != pkt->hdr.cmd || 1642 cmds_trig->cmds[i].group_id != pkt->hdr.group_id) 1643 continue; 1644 1645 iwl_fw_dbg_collect_trig(&mvm->fwrt, trig, 1646 "CMD 0x%02x.%02x received", 1647 pkt->hdr.group_id, pkt->hdr.cmd); 1648 break; 1649 } 1650 } 1651 1652 static void iwl_mvm_rx_common(struct iwl_mvm *mvm, 1653 struct iwl_rx_cmd_buffer *rxb, 1654 struct iwl_rx_packet *pkt) 1655 { 1656 unsigned int pkt_len = iwl_rx_packet_payload_len(pkt); 1657 int i; 1658 union iwl_dbg_tlv_tp_data tp_data = { .fw_pkt = pkt }; 1659 1660 iwl_dbg_tlv_time_point(&mvm->fwrt, 1661 IWL_FW_INI_TIME_POINT_FW_RSP_OR_NOTIF, &tp_data); 1662 iwl_mvm_rx_check_trigger(mvm, pkt); 1663 1664 /* 1665 * Do the notification wait before RX handlers so 1666 * even if the RX handler consumes the RXB we have 1667 * access to it in the notification wait entry. 1668 */ 1669 iwl_notification_wait_notify(&mvm->notif_wait, pkt); 1670 1671 for (i = 0; i < ARRAY_SIZE(iwl_mvm_rx_handlers); i++) { 1672 const struct iwl_rx_handlers *rx_h = &iwl_mvm_rx_handlers[i]; 1673 struct iwl_async_handler_entry *entry; 1674 1675 if (rx_h->cmd_id != WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd)) 1676 continue; 1677 1678 if (IWL_FW_CHECK(mvm, pkt_len < rx_h->min_size, 1679 "unexpected notification 0x%04x size %d, need %d\n", 1680 rx_h->cmd_id, pkt_len, rx_h->min_size)) 1681 return; 1682 1683 if (rx_h->context == RX_HANDLER_SYNC) { 1684 rx_h->fn(mvm, rxb); 1685 return; 1686 } 1687 1688 entry = kzalloc(sizeof(*entry), GFP_ATOMIC); 1689 /* we can't do much... */ 1690 if (!entry) 1691 return; 1692 1693 entry->rxb._page = rxb_steal_page(rxb); 1694 entry->rxb._offset = rxb->_offset; 1695 entry->rxb._rx_page_order = rxb->_rx_page_order; 1696 entry->fn = rx_h->fn; 1697 entry->context = rx_h->context; 1698 spin_lock(&mvm->async_handlers_lock); 1699 list_add_tail(&entry->list, &mvm->async_handlers_list); 1700 spin_unlock(&mvm->async_handlers_lock); 1701 if (rx_h->context == RX_HANDLER_ASYNC_LOCKED_WIPHY) 1702 wiphy_work_queue(mvm->hw->wiphy, 1703 &mvm->async_handlers_wiphy_wk); 1704 else 1705 schedule_work(&mvm->async_handlers_wk); 1706 break; 1707 } 1708 } 1709 1710 static void iwl_mvm_rx(struct iwl_op_mode *op_mode, 1711 struct napi_struct *napi, 1712 struct iwl_rx_cmd_buffer *rxb) 1713 { 1714 struct iwl_rx_packet *pkt = rxb_addr(rxb); 1715 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 1716 u16 cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd); 1717 1718 if (likely(cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))) 1719 iwl_mvm_rx_rx_mpdu(mvm, napi, rxb); 1720 else if (cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_PHY_CMD)) 1721 iwl_mvm_rx_rx_phy_cmd(mvm, rxb); 1722 else 1723 iwl_mvm_rx_common(mvm, rxb, pkt); 1724 } 1725 1726 void iwl_mvm_rx_mq(struct iwl_op_mode *op_mode, 1727 struct napi_struct *napi, 1728 struct iwl_rx_cmd_buffer *rxb) 1729 { 1730 struct iwl_rx_packet *pkt = rxb_addr(rxb); 1731 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 1732 u16 cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd); 1733 1734 if (likely(cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))) 1735 iwl_mvm_rx_mpdu_mq(mvm, napi, rxb, 0); 1736 else if (unlikely(cmd == WIDE_ID(DATA_PATH_GROUP, 1737 RX_QUEUES_NOTIFICATION))) 1738 iwl_mvm_rx_queue_notif(mvm, napi, rxb, 0); 1739 else if (cmd == WIDE_ID(LEGACY_GROUP, FRAME_RELEASE)) 1740 iwl_mvm_rx_frame_release(mvm, napi, rxb, 0); 1741 else if (cmd == WIDE_ID(LEGACY_GROUP, BAR_FRAME_RELEASE)) 1742 iwl_mvm_rx_bar_frame_release(mvm, napi, rxb, 0); 1743 else if (cmd == WIDE_ID(DATA_PATH_GROUP, RX_NO_DATA_NOTIF)) 1744 iwl_mvm_rx_monitor_no_data(mvm, napi, rxb, 0); 1745 else 1746 iwl_mvm_rx_common(mvm, rxb, pkt); 1747 } 1748 1749 static int iwl_mvm_is_static_queue(struct iwl_mvm *mvm, int queue) 1750 { 1751 return queue == mvm->aux_queue || queue == mvm->probe_queue || 1752 queue == mvm->p2p_dev_queue || queue == mvm->snif_queue; 1753 } 1754 1755 static void iwl_mvm_queue_state_change(struct iwl_op_mode *op_mode, 1756 int hw_queue, bool start) 1757 { 1758 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 1759 struct ieee80211_sta *sta; 1760 struct ieee80211_txq *txq; 1761 struct iwl_mvm_txq *mvmtxq; 1762 int i; 1763 unsigned long tid_bitmap; 1764 struct iwl_mvm_sta *mvmsta; 1765 u8 sta_id; 1766 1767 sta_id = iwl_mvm_has_new_tx_api(mvm) ? 1768 mvm->tvqm_info[hw_queue].sta_id : 1769 mvm->queue_info[hw_queue].ra_sta_id; 1770 1771 if (WARN_ON_ONCE(sta_id >= mvm->fw->ucode_capa.num_stations)) 1772 return; 1773 1774 rcu_read_lock(); 1775 1776 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); 1777 if (IS_ERR_OR_NULL(sta)) 1778 goto out; 1779 mvmsta = iwl_mvm_sta_from_mac80211(sta); 1780 1781 if (iwl_mvm_is_static_queue(mvm, hw_queue)) { 1782 if (!start) 1783 ieee80211_stop_queues(mvm->hw); 1784 else if (mvmsta->sta_state != IEEE80211_STA_NOTEXIST) 1785 ieee80211_wake_queues(mvm->hw); 1786 1787 goto out; 1788 } 1789 1790 if (iwl_mvm_has_new_tx_api(mvm)) { 1791 int tid = mvm->tvqm_info[hw_queue].txq_tid; 1792 1793 tid_bitmap = BIT(tid); 1794 } else { 1795 tid_bitmap = mvm->queue_info[hw_queue].tid_bitmap; 1796 } 1797 1798 for_each_set_bit(i, &tid_bitmap, IWL_MAX_TID_COUNT + 1) { 1799 int tid = i; 1800 1801 if (tid == IWL_MAX_TID_COUNT) 1802 tid = IEEE80211_NUM_TIDS; 1803 1804 txq = sta->txq[tid]; 1805 mvmtxq = iwl_mvm_txq_from_mac80211(txq); 1806 if (start) 1807 clear_bit(IWL_MVM_TXQ_STATE_STOP_FULL, &mvmtxq->state); 1808 else 1809 set_bit(IWL_MVM_TXQ_STATE_STOP_FULL, &mvmtxq->state); 1810 1811 if (start && mvmsta->sta_state != IEEE80211_STA_NOTEXIST) { 1812 local_bh_disable(); 1813 iwl_mvm_mac_itxq_xmit(mvm->hw, txq); 1814 local_bh_enable(); 1815 } 1816 } 1817 1818 out: 1819 rcu_read_unlock(); 1820 } 1821 1822 static void iwl_mvm_stop_sw_queue(struct iwl_op_mode *op_mode, int hw_queue) 1823 { 1824 iwl_mvm_queue_state_change(op_mode, hw_queue, false); 1825 } 1826 1827 static void iwl_mvm_wake_sw_queue(struct iwl_op_mode *op_mode, int hw_queue) 1828 { 1829 iwl_mvm_queue_state_change(op_mode, hw_queue, true); 1830 } 1831 1832 static void iwl_mvm_set_rfkill_state(struct iwl_mvm *mvm) 1833 { 1834 wiphy_rfkill_set_hw_state(mvm->hw->wiphy, 1835 iwl_mvm_is_radio_killed(mvm)); 1836 } 1837 1838 void iwl_mvm_set_hw_ctkill_state(struct iwl_mvm *mvm, bool state) 1839 { 1840 if (state) 1841 set_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status); 1842 else 1843 clear_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status); 1844 1845 iwl_mvm_set_rfkill_state(mvm); 1846 } 1847 1848 struct iwl_mvm_csme_conn_info *iwl_mvm_get_csme_conn_info(struct iwl_mvm *mvm) 1849 { 1850 return rcu_dereference_protected(mvm->csme_conn_info, 1851 lockdep_is_held(&mvm->mutex)); 1852 } 1853 1854 static bool iwl_mvm_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state) 1855 { 1856 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 1857 bool rfkill_safe_init_done = READ_ONCE(mvm->rfkill_safe_init_done); 1858 bool unified = iwl_mvm_has_unified_ucode(mvm); 1859 1860 if (state) { 1861 set_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status); 1862 wake_up(&mvm->rx_sync_waitq); 1863 } else { 1864 clear_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status); 1865 } 1866 1867 iwl_mvm_set_rfkill_state(mvm); 1868 1869 /* iwl_run_init_mvm_ucode is waiting for results, abort it. */ 1870 if (rfkill_safe_init_done) 1871 iwl_abort_notification_waits(&mvm->notif_wait); 1872 1873 /* 1874 * Don't ask the transport to stop the firmware. We'll do it 1875 * after cfg80211 takes us down. 1876 */ 1877 if (unified) 1878 return false; 1879 1880 /* 1881 * Stop the device if we run OPERATIONAL firmware or if we are in the 1882 * middle of the calibrations. 1883 */ 1884 return state && rfkill_safe_init_done; 1885 } 1886 1887 static void iwl_mvm_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb) 1888 { 1889 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 1890 struct ieee80211_tx_info *info; 1891 1892 info = IEEE80211_SKB_CB(skb); 1893 iwl_trans_free_tx_cmd(mvm->trans, info->driver_data[1]); 1894 ieee80211_free_txskb(mvm->hw, skb); 1895 } 1896 1897 struct iwl_mvm_reprobe { 1898 struct device *dev; 1899 struct work_struct work; 1900 }; 1901 1902 static void iwl_mvm_reprobe_wk(struct work_struct *wk) 1903 { 1904 struct iwl_mvm_reprobe *reprobe; 1905 1906 reprobe = container_of(wk, struct iwl_mvm_reprobe, work); 1907 if (device_reprobe(reprobe->dev)) 1908 dev_err(reprobe->dev, "reprobe failed!\n"); 1909 put_device(reprobe->dev); 1910 kfree(reprobe); 1911 module_put(THIS_MODULE); 1912 } 1913 1914 void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error) 1915 { 1916 iwl_abort_notification_waits(&mvm->notif_wait); 1917 iwl_dbg_tlv_del_timers(mvm->trans); 1918 1919 /* 1920 * This is a bit racy, but worst case we tell mac80211 about 1921 * a stopped/aborted scan when that was already done which 1922 * is not a problem. It is necessary to abort any os scan 1923 * here because mac80211 requires having the scan cleared 1924 * before restarting. 1925 * We'll reset the scan_status to NONE in restart cleanup in 1926 * the next start() call from mac80211. If restart isn't called 1927 * (no fw restart) scan status will stay busy. 1928 */ 1929 iwl_mvm_report_scan_aborted(mvm); 1930 1931 /* 1932 * If we're restarting already, don't cycle restarts. 1933 * If INIT fw asserted, it will likely fail again. 1934 * If WoWLAN fw asserted, don't restart either, mac80211 1935 * can't recover this since we're already half suspended. 1936 */ 1937 if (!mvm->fw_restart && fw_error) { 1938 iwl_fw_error_collect(&mvm->fwrt, false); 1939 } else if (test_bit(IWL_MVM_STATUS_STARTING, 1940 &mvm->status)) { 1941 IWL_ERR(mvm, "Starting mac, retry will be triggered anyway\n"); 1942 } else if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) { 1943 struct iwl_mvm_reprobe *reprobe; 1944 1945 IWL_ERR(mvm, 1946 "Firmware error during reconfiguration - reprobe!\n"); 1947 1948 /* 1949 * get a module reference to avoid doing this while unloading 1950 * anyway and to avoid scheduling a work with code that's 1951 * being removed. 1952 */ 1953 if (!try_module_get(THIS_MODULE)) { 1954 IWL_ERR(mvm, "Module is being unloaded - abort\n"); 1955 return; 1956 } 1957 1958 reprobe = kzalloc(sizeof(*reprobe), GFP_ATOMIC); 1959 if (!reprobe) { 1960 module_put(THIS_MODULE); 1961 return; 1962 } 1963 reprobe->dev = get_device(mvm->trans->dev); 1964 INIT_WORK(&reprobe->work, iwl_mvm_reprobe_wk); 1965 schedule_work(&reprobe->work); 1966 } else if (test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, 1967 &mvm->status)) { 1968 IWL_ERR(mvm, "HW restart already requested, but not started\n"); 1969 } else if (mvm->fwrt.cur_fw_img == IWL_UCODE_REGULAR && 1970 mvm->hw_registered && 1971 !test_bit(STATUS_TRANS_DEAD, &mvm->trans->status)) { 1972 /* This should be first thing before trying to collect any 1973 * data to avoid endless loops if any HW error happens while 1974 * collecting debug data. 1975 */ 1976 set_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, &mvm->status); 1977 1978 if (mvm->fw->ucode_capa.error_log_size) { 1979 u32 src_size = mvm->fw->ucode_capa.error_log_size; 1980 u32 src_addr = mvm->fw->ucode_capa.error_log_addr; 1981 u8 *recover_buf = kzalloc(src_size, GFP_ATOMIC); 1982 1983 if (recover_buf) { 1984 mvm->error_recovery_buf = recover_buf; 1985 iwl_trans_read_mem_bytes(mvm->trans, 1986 src_addr, 1987 recover_buf, 1988 src_size); 1989 } 1990 } 1991 1992 iwl_fw_error_collect(&mvm->fwrt, false); 1993 1994 if (fw_error && mvm->fw_restart > 0) { 1995 mvm->fw_restart--; 1996 ieee80211_restart_hw(mvm->hw); 1997 } else if (mvm->fwrt.trans->dbg.restart_required) { 1998 IWL_DEBUG_INFO(mvm, "FW restart requested after debug collection\n"); 1999 mvm->fwrt.trans->dbg.restart_required = false; 2000 ieee80211_restart_hw(mvm->hw); 2001 } else if (mvm->trans->trans_cfg->device_family <= IWL_DEVICE_FAMILY_8000) { 2002 ieee80211_restart_hw(mvm->hw); 2003 } 2004 } 2005 } 2006 2007 static void iwl_mvm_nic_error(struct iwl_op_mode *op_mode, bool sync) 2008 { 2009 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 2010 2011 if (!test_bit(STATUS_TRANS_DEAD, &mvm->trans->status) && 2012 !test_and_clear_bit(IWL_MVM_STATUS_SUPPRESS_ERROR_LOG_ONCE, 2013 &mvm->status)) 2014 iwl_mvm_dump_nic_error_log(mvm); 2015 2016 if (sync) { 2017 iwl_fw_error_collect(&mvm->fwrt, true); 2018 /* 2019 * Currently, the only case for sync=true is during 2020 * shutdown, so just stop in this case. If/when that 2021 * changes, we need to be a bit smarter here. 2022 */ 2023 return; 2024 } 2025 2026 /* 2027 * If the firmware crashes while we're already considering it 2028 * to be dead then don't ask for a restart, that cannot do 2029 * anything useful anyway. 2030 */ 2031 if (!test_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status)) 2032 return; 2033 2034 iwl_mvm_nic_restart(mvm, false); 2035 } 2036 2037 static void iwl_mvm_cmd_queue_full(struct iwl_op_mode *op_mode) 2038 { 2039 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 2040 2041 WARN_ON(1); 2042 iwl_mvm_nic_restart(mvm, true); 2043 } 2044 2045 static void iwl_op_mode_mvm_time_point(struct iwl_op_mode *op_mode, 2046 enum iwl_fw_ini_time_point tp_id, 2047 union iwl_dbg_tlv_tp_data *tp_data) 2048 { 2049 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 2050 2051 iwl_dbg_tlv_time_point(&mvm->fwrt, tp_id, tp_data); 2052 } 2053 2054 #define IWL_MVM_COMMON_OPS \ 2055 /* these could be differentiated */ \ 2056 .queue_full = iwl_mvm_stop_sw_queue, \ 2057 .queue_not_full = iwl_mvm_wake_sw_queue, \ 2058 .hw_rf_kill = iwl_mvm_set_hw_rfkill_state, \ 2059 .free_skb = iwl_mvm_free_skb, \ 2060 .nic_error = iwl_mvm_nic_error, \ 2061 .cmd_queue_full = iwl_mvm_cmd_queue_full, \ 2062 .nic_config = iwl_mvm_nic_config, \ 2063 /* as we only register one, these MUST be common! */ \ 2064 .start = iwl_op_mode_mvm_start, \ 2065 .stop = iwl_op_mode_mvm_stop, \ 2066 .time_point = iwl_op_mode_mvm_time_point 2067 2068 static const struct iwl_op_mode_ops iwl_mvm_ops = { 2069 IWL_MVM_COMMON_OPS, 2070 .rx = iwl_mvm_rx, 2071 }; 2072 2073 static void iwl_mvm_rx_mq_rss(struct iwl_op_mode *op_mode, 2074 struct napi_struct *napi, 2075 struct iwl_rx_cmd_buffer *rxb, 2076 unsigned int queue) 2077 { 2078 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 2079 struct iwl_rx_packet *pkt = rxb_addr(rxb); 2080 u16 cmd = WIDE_ID(pkt->hdr.group_id, pkt->hdr.cmd); 2081 2082 if (unlikely(queue >= mvm->trans->num_rx_queues)) 2083 return; 2084 2085 if (unlikely(cmd == WIDE_ID(LEGACY_GROUP, FRAME_RELEASE))) 2086 iwl_mvm_rx_frame_release(mvm, napi, rxb, queue); 2087 else if (unlikely(cmd == WIDE_ID(DATA_PATH_GROUP, 2088 RX_QUEUES_NOTIFICATION))) 2089 iwl_mvm_rx_queue_notif(mvm, napi, rxb, queue); 2090 else if (likely(cmd == WIDE_ID(LEGACY_GROUP, REPLY_RX_MPDU_CMD))) 2091 iwl_mvm_rx_mpdu_mq(mvm, napi, rxb, queue); 2092 } 2093 2094 static const struct iwl_op_mode_ops iwl_mvm_ops_mq = { 2095 IWL_MVM_COMMON_OPS, 2096 .rx = iwl_mvm_rx_mq, 2097 .rx_rss = iwl_mvm_rx_mq_rss, 2098 }; 2099