Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-john' of git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-next

+512 -296
+8 -4
drivers/net/wireless/iwlwifi/Kconfig
··· 2 2 tristate "Intel Wireless WiFi Next Gen AGN - Wireless-N/Advanced-N/Ultimate-N (iwlwifi) " 3 3 depends on PCI && MAC80211 && HAS_IOMEM 4 4 select FW_LOADER 5 - select NEW_LEDS 6 - select LEDS_CLASS 7 - select LEDS_TRIGGERS 8 - select MAC80211_LEDS 9 5 ---help--- 10 6 Select to build the driver supporting the: 11 7 ··· 38 42 inserted in and removed from the running kernel whenever you want), 39 43 say M here and read <file:Documentation/kbuild/modules.txt>. The 40 44 module will be called iwlwifi. 45 + 46 + config IWLWIFI_LEDS 47 + bool 48 + depends on IWLWIFI 49 + depends on LEDS_CLASS 50 + select LEDS_TRIGGERS 51 + select MAC80211_LEDS 52 + default y 41 53 42 54 config IWLDVM 43 55 tristate "Intel Wireless WiFi DVM Firmware support"
+2 -1
drivers/net/wireless/iwlwifi/dvm/Makefile
··· 4 4 iwldvm-objs += lib.o calib.o tt.o sta.o rx.o 5 5 6 6 iwldvm-objs += power.o 7 - iwldvm-objs += scan.o led.o 7 + iwldvm-objs += scan.o 8 8 iwldvm-objs += rxon.o devices.o 9 9 10 + iwldvm-$(CONFIG_IWLWIFI_LEDS) += led.o 10 11 iwldvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o 11 12 12 13 ccflags-y += -D__CHECK_ENDIAN__ -I$(src)/../
+2
drivers/net/wireless/iwlwifi/dvm/dev.h
··· 888 888 889 889 struct iwl_event_log event_log; 890 890 891 + #ifdef CONFIG_IWLWIFI_LEDS 891 892 struct led_classdev led; 892 893 unsigned long blink_on, blink_off; 893 894 bool led_registered; 895 + #endif 894 896 895 897 /* WoWLAN GTK rekey data */ 896 898 u8 kck[NL80211_KCK_LEN], kek[NL80211_KEK_LEN];
+12
drivers/net/wireless/iwlwifi/dvm/led.h
··· 36 36 #define IWL_LED_ACTIVITY (0<<1) 37 37 #define IWL_LED_LINK (1<<1) 38 38 39 + #ifdef CONFIG_IWLWIFI_LEDS 39 40 void iwlagn_led_enable(struct iwl_priv *priv); 40 41 void iwl_leds_init(struct iwl_priv *priv); 41 42 void iwl_leds_exit(struct iwl_priv *priv); 43 + #else 44 + static inline void iwlagn_led_enable(struct iwl_priv *priv) 45 + { 46 + } 47 + static inline void iwl_leds_init(struct iwl_priv *priv) 48 + { 49 + } 50 + static inline void iwl_leds_exit(struct iwl_priv *priv) 51 + { 52 + } 53 + #endif 42 54 43 55 #endif /* __iwl_leds_h__ */
+1 -1
drivers/net/wireless/iwlwifi/iwl-7000.c
··· 98 98 #define NVM_HW_SECTION_NUM_FAMILY_7000 0 99 99 100 100 static const struct iwl_base_params iwl7000_base_params = { 101 - .eeprom_size = OTP_LOW_IMAGE_SIZE, 101 + .eeprom_size = OTP_LOW_IMAGE_SIZE_FAMILY_7000, 102 102 .num_of_queues = IWLAGN_NUM_QUEUES, 103 103 .pll_cfg_val = 0, 104 104 .shadow_ram_support = true,
+1 -1
drivers/net/wireless/iwlwifi/iwl-8000.c
··· 85 85 #define NVM_HW_SECTION_NUM_FAMILY_8000 10 86 86 87 87 static const struct iwl_base_params iwl8000_base_params = { 88 - .eeprom_size = OTP_LOW_IMAGE_SIZE, 88 + .eeprom_size = OTP_LOW_IMAGE_SIZE_FAMILY_8000, 89 89 .num_of_queues = IWLAGN_NUM_QUEUES, 90 90 .pll_cfg_val = 0, 91 91 .shadow_ram_support = true,
+1 -3
drivers/net/wireless/iwlwifi/iwl-agn-hw.h
··· 102 102 103 103 /* EEPROM */ 104 104 #define IWLAGN_EEPROM_IMG_SIZE 2048 105 - /* OTP */ 106 - /* lower blocks contain EEPROM image and calibration data */ 107 - #define OTP_LOW_IMAGE_SIZE (2 * 512 * sizeof(u16)) /* 2 KB */ 105 + 108 106 /* high blocks contain PAPD data */ 109 107 #define OTP_HIGH_IMAGE_SIZE_6x00 (6 * 512 * sizeof(u16)) /* 6 KB */ 110 108 #define OTP_HIGH_IMAGE_SIZE_1000 (0x200 * sizeof(u16)) /* 1024 bytes */
+6
drivers/net/wireless/iwlwifi/iwl-config.h
··· 193 193 #define EEPROM_6000_REG_BAND_24_HT40_CHANNELS 0x80 194 194 #define EEPROM_REGULATORY_BAND_NO_HT40 0 195 195 196 + /* lower blocks contain EEPROM image and calibration data */ 197 + #define OTP_LOW_IMAGE_SIZE (2 * 512 * sizeof(u16)) /* 2 KB */ 198 + #define OTP_LOW_IMAGE_SIZE_FAMILY_7000 (4 * 512 * sizeof(u16)) /* 4 KB */ 199 + #define OTP_LOW_IMAGE_SIZE_FAMILY_8000 (32 * 512 * sizeof(u16)) /* 32 KB */ 200 + 196 201 struct iwl_eeprom_params { 197 202 const u8 regulatory_bands[7]; 198 203 bool enhanced_txpower; ··· 274 269 u8 nvm_hw_section_num; 275 270 bool lp_xtal_workaround; 276 271 const struct iwl_pwr_tx_backoff *pwr_tx_backoffs; 272 + bool no_power_up_nic_in_init; 277 273 }; 278 274 279 275 /*
+2
drivers/net/wireless/iwlwifi/iwl-fw.h
··· 116 116 /** 117 117 * enum iwl_ucode_tlv_api - ucode api 118 118 * @IWL_UCODE_TLV_API_WOWLAN_CONFIG_TID: wowlan config includes tid field. 119 + * @IWL_UCODE_TLV_API_CSA_FLOW: ucode can do unbind-bind flow for CSA. 119 120 */ 120 121 enum iwl_ucode_tlv_api { 121 122 IWL_UCODE_TLV_API_WOWLAN_CONFIG_TID = BIT(0), 123 + IWL_UCODE_TLV_API_CSA_FLOW = BIT(4), 122 124 }; 123 125 124 126 /**
+38 -8
drivers/net/wireless/iwlwifi/iwl-nvm-parse.c
··· 62 62 #include <linux/types.h> 63 63 #include <linux/slab.h> 64 64 #include <linux/export.h> 65 + #include <linux/etherdevice.h> 65 66 #include "iwl-drv.h" 66 67 #include "iwl-modparams.h" 67 68 #include "iwl-nvm-parse.h" ··· 451 450 struct iwl_nvm_data *data, 452 451 const __le16 *nvm_sec) 453 452 { 454 - u8 hw_addr[ETH_ALEN]; 455 - 456 - if (cfg->device_family != IWL_DEVICE_FAMILY_8000) 457 - memcpy(hw_addr, nvm_sec + HW_ADDR, ETH_ALEN); 458 - else 459 - memcpy(hw_addr, nvm_sec + MAC_ADDRESS_OVERRIDE_FAMILY_8000, 460 - ETH_ALEN); 453 + const u8 *hw_addr = (const u8 *)(nvm_sec + HW_ADDR); 461 454 462 455 /* The byte order is little endian 16 bit, meaning 214365 */ 463 456 data->hw_addr[0] = hw_addr[1]; ··· 460 465 data->hw_addr[3] = hw_addr[2]; 461 466 data->hw_addr[4] = hw_addr[5]; 462 467 data->hw_addr[5] = hw_addr[4]; 468 + } 469 + 470 + static void iwl_set_hw_address_family_8000(const struct iwl_cfg *cfg, 471 + struct iwl_nvm_data *data, 472 + const __le16 *mac_override, 473 + const __le16 *nvm_hw) 474 + { 475 + const u8 *hw_addr; 476 + 477 + if (mac_override) { 478 + hw_addr = (const u8 *)(mac_override + 479 + MAC_ADDRESS_OVERRIDE_FAMILY_8000); 480 + 481 + /* The byte order is little endian 16 bit, meaning 214365 */ 482 + data->hw_addr[0] = hw_addr[1]; 483 + data->hw_addr[1] = hw_addr[0]; 484 + data->hw_addr[2] = hw_addr[3]; 485 + data->hw_addr[3] = hw_addr[2]; 486 + data->hw_addr[4] = hw_addr[5]; 487 + data->hw_addr[5] = hw_addr[4]; 488 + 489 + if (is_valid_ether_addr(hw_addr)) 490 + return; 491 + } 492 + 493 + /* take the MAC address from the OTP */ 494 + hw_addr = (const u8 *)(nvm_hw + HW_ADDR0_FAMILY_8000); 495 + data->hw_addr[0] = hw_addr[3]; 496 + data->hw_addr[1] = hw_addr[2]; 497 + data->hw_addr[2] = hw_addr[1]; 498 + data->hw_addr[3] = hw_addr[0]; 499 + 500 + hw_addr = (const u8 *)(nvm_hw + HW_ADDR1_FAMILY_8000); 501 + data->hw_addr[4] = hw_addr[1]; 502 + data->hw_addr[5] = hw_addr[0]; 463 503 } 464 504 465 505 struct iwl_nvm_data * ··· 556 526 rx_chains); 557 527 } else { 558 528 /* MAC address in family 8000 */ 559 - iwl_set_hw_address(cfg, data, mac_override); 529 + iwl_set_hw_address_family_8000(cfg, data, mac_override, nvm_hw); 560 530 561 531 iwl_init_sbands(dev, cfg, data, regulatory, 562 532 sku & NVM_SKU_CAP_11AC_ENABLE, tx_chains,
+19
drivers/net/wireless/iwlwifi/iwl-trans.h
··· 463 463 * @unref: release a reference previously taken with @ref. Note that 464 464 * initially the reference count is 1, making an initial @unref 465 465 * necessary to allow low power states. 466 + * @dump_data: fill a data dump with debug data, maybe containing last 467 + * TX'ed commands and similar. When called with a NULL buffer and 468 + * zero buffer length, provide only the (estimated) required buffer 469 + * length. Return the used buffer length. 470 + * Note that the transport must fill in the proper file headers. 466 471 */ 467 472 struct iwl_trans_ops { 468 473 ··· 516 511 u32 value); 517 512 void (*ref)(struct iwl_trans *trans); 518 513 void (*unref)(struct iwl_trans *trans); 514 + 515 + #ifdef CONFIG_IWLWIFI_DEBUGFS 516 + u32 (*dump_data)(struct iwl_trans *trans, void *buf, u32 buflen); 517 + #endif 519 518 }; 520 519 521 520 /** ··· 672 663 if (trans->ops->unref) 673 664 trans->ops->unref(trans); 674 665 } 666 + 667 + #ifdef CONFIG_IWLWIFI_DEBUGFS 668 + static inline u32 iwl_trans_dump_data(struct iwl_trans *trans, 669 + void *buf, u32 buflen) 670 + { 671 + if (!trans->ops->dump_data) 672 + return 0; 673 + return trans->ops->dump_data(trans, buf, buflen); 674 + } 675 + #endif 675 676 676 677 static inline int iwl_trans_send_cmd(struct iwl_trans *trans, 677 678 struct iwl_host_cmd *cmd)
+2 -1
drivers/net/wireless/iwlwifi/mvm/Makefile
··· 3 3 iwlmvm-y += utils.o rx.o tx.o binding.o quota.o sta.o sf.o 4 4 iwlmvm-y += scan.o time-event.o rs.o 5 5 iwlmvm-y += power.o coex.o 6 - iwlmvm-y += led.o tt.o offloading.o 6 + iwlmvm-y += tt.o offloading.o 7 7 iwlmvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o debugfs-vif.o 8 + iwlmvm-$(CONFIG_IWLWIFI_LEDS) += led.o 8 9 iwlmvm-$(CONFIG_PM_SLEEP) += d3.o 9 10 10 11 ccflags-y += -D__CHECK_ENDIAN__ -I$(src)/../
+3 -3
drivers/net/wireless/iwlwifi/mvm/coex.c
··· 611 611 bt_cmd->flags |= cpu_to_le32(BT_COEX_SYNC2SCO); 612 612 613 613 if (IWL_MVM_BT_COEX_CORUNNING) { 614 - bt_cmd->valid_bit_msk = cpu_to_le32(BT_VALID_CORUN_LUT_20 | 615 - BT_VALID_CORUN_LUT_40); 614 + bt_cmd->valid_bit_msk |= cpu_to_le32(BT_VALID_CORUN_LUT_20 | 615 + BT_VALID_CORUN_LUT_40); 616 616 bt_cmd->flags |= cpu_to_le32(BT_COEX_CORUNNING); 617 617 } 618 618 619 619 if (IWL_MVM_BT_COEX_MPLUT) { 620 620 bt_cmd->flags |= cpu_to_le32(BT_COEX_MPLUT); 621 - bt_cmd->valid_bit_msk = cpu_to_le32(BT_VALID_MULTI_PRIO_LUT); 621 + bt_cmd->valid_bit_msk |= cpu_to_le32(BT_VALID_MULTI_PRIO_LUT); 622 622 } 623 623 624 624 if (mvm->cfg->bt_shared_single_ant)
+1 -1
drivers/net/wireless/iwlwifi/mvm/debugfs.c
··· 67 67 #include "iwl-io.h" 68 68 #include "iwl-prph.h" 69 69 #include "debugfs.h" 70 - #include "fw-error-dump.h" 70 + #include "iwl-fw-error-dump.h" 71 71 72 72 static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm *mvm, char *buf, 73 73 size_t count, loff_t *ppos)
+4 -4
drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
··· 187 187 * this number of packets were received (typically 1) 188 188 * @passive2active: is auto switching from passive to active during scan allowed 189 189 * @rxchain_sel_flags: RXON_RX_CHAIN_* 190 - * @max_out_time: in usecs, max out of serving channel time 190 + * @max_out_time: in TUs, max out of serving channel time 191 191 * @suspend_time: how long to pause scan when returning to service channel: 192 - * bits 0-19: beacon interal in usecs (suspend before executing) 192 + * bits 0-19: beacon interal in TUs (suspend before executing) 193 193 * bits 20-23: reserved 194 194 * bits 24-31: number of beacons (suspend between channels) 195 195 * @rxon_flags: RXON_FLG_* ··· 387 387 * @quiet_plcp_th: quiet channel num of packets threshold 388 388 * @good_CRC_th: passive to active promotion threshold 389 389 * @rx_chain: RXON rx chain. 390 - * @max_out_time: max uSec to be out of assoceated channel 391 - * @suspend_time: pause scan this long when returning to service channel 390 + * @max_out_time: max TUs to be out of assoceated channel 391 + * @suspend_time: pause scan this TUs when returning to service channel 392 392 * @flags: RXON flags 393 393 * @filter_flags: RXONfilter 394 394 * @tx_cmd: tx command for active scan; for 2GHz and for 5GHz.
+26
drivers/net/wireless/iwlwifi/mvm/fw-error-dump.h drivers/net/wireless/iwlwifi/iwl-fw-error-dump.h
··· 72 72 * @IWL_FW_ERROR_DUMP_SRAM: 73 73 * @IWL_FW_ERROR_DUMP_REG: 74 74 * @IWL_FW_ERROR_DUMP_RXF: 75 + * @IWL_FW_ERROR_DUMP_TXCMD: last TX command data, structured as 76 + * &struct iwl_fw_error_dump_txcmd packets 75 77 */ 76 78 enum iwl_fw_error_dump_type { 77 79 IWL_FW_ERROR_DUMP_SRAM = 0, 78 80 IWL_FW_ERROR_DUMP_REG = 1, 79 81 IWL_FW_ERROR_DUMP_RXF = 2, 82 + IWL_FW_ERROR_DUMP_TXCMD = 3, 80 83 81 84 IWL_FW_ERROR_DUMP_MAX, 82 85 }; ··· 107 104 __le32 file_len; 108 105 u8 data[0]; 109 106 } __packed; 107 + 108 + /** 109 + * struct iwl_fw_error_dump_txcmd - TX command data 110 + * @cmdlen: original length of command 111 + * @caplen: captured length of command (may be less) 112 + * @data: captured command data, @caplen bytes 113 + */ 114 + struct iwl_fw_error_dump_txcmd { 115 + __le32 cmdlen; 116 + __le32 caplen; 117 + u8 data[]; 118 + } __packed; 119 + 120 + /** 121 + * iwl_mvm_fw_error_next_data - advance fw error dump data pointer 122 + * @data: previous data block 123 + * Returns: next data block 124 + */ 125 + static inline struct iwl_fw_error_dump_data * 126 + iwl_mvm_fw_error_next_data(struct iwl_fw_error_dump_data *data) 127 + { 128 + return (void *)(data->data + le32_to_cpu(data->len)); 129 + } 110 130 111 131 #endif /* __fw_error_dump_h__ */
+1 -1
drivers/net/wireless/iwlwifi/mvm/fw.c
··· 295 295 /* Read the NVM only at driver load time, no need to do this twice */ 296 296 if (read_nvm) { 297 297 /* Read nvm */ 298 - ret = iwl_nvm_init(mvm); 298 + ret = iwl_nvm_init(mvm, true); 299 299 if (ret) { 300 300 IWL_ERR(mvm, "Failed to read NVM: %d\n", ret); 301 301 goto error;
+12
drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c
··· 1237 1237 u32 rate __maybe_unused = 1238 1238 le32_to_cpu(beacon->beacon_notify_hdr.initial_rate); 1239 1239 1240 + lockdep_assert_held(&mvm->mutex); 1241 + 1240 1242 IWL_DEBUG_RX(mvm, "beacon status %#x retries:%d tsf:0x%16llX rate:%d\n", 1241 1243 status & TX_STATUS_MSK, 1242 1244 beacon->beacon_notify_hdr.failure_frame, 1243 1245 le64_to_cpu(beacon->tsf), 1244 1246 rate); 1247 + 1248 + if (unlikely(mvm->csa_vif && mvm->csa_vif->csa_active)) { 1249 + if (!ieee80211_csa_is_complete(mvm->csa_vif)) { 1250 + iwl_mvm_mac_ctxt_beacon_changed(mvm, mvm->csa_vif); 1251 + } else { 1252 + ieee80211_csa_finish(mvm->csa_vif); 1253 + mvm->csa_vif = NULL; 1254 + } 1255 + } 1256 + 1245 1257 return 0; 1246 1258 } 1247 1259
+87 -4
drivers/net/wireless/iwlwifi/mvm/mac80211.c
··· 320 320 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_GO_UAPSD) 321 321 hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; 322 322 323 + if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_CSA_FLOW) 324 + hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; 325 + 323 326 hw->wiphy->iface_combinations = iwl_mvm_iface_combinations; 324 327 hw->wiphy->n_iface_combinations = 325 328 ARRAY_SIZE(iwl_mvm_iface_combinations); ··· 542 539 return -EACCES; 543 540 544 541 /* return from D0i3 before starting a new Tx aggregation */ 545 - if (action == IEEE80211_AMPDU_TX_START) { 542 + switch (action) { 543 + case IEEE80211_AMPDU_TX_START: 544 + case IEEE80211_AMPDU_TX_STOP_CONT: 545 + case IEEE80211_AMPDU_TX_STOP_FLUSH: 546 + case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: 547 + case IEEE80211_AMPDU_TX_OPERATIONAL: 546 548 iwl_mvm_ref(mvm, IWL_MVM_REF_TX_AGG); 547 549 tx_agg_ref = true; 548 550 549 551 /* 550 - * wait synchronously until D0i3 exit to get the correct 551 - * sequence number for the tid 552 + * for tx start, wait synchronously until D0i3 exit to 553 + * get the correct sequence number for the tid. 554 + * additionally, some other ampdu actions use direct 555 + * target access, which is not handled automatically 556 + * by the trans layer (unlike commands), so wait for 557 + * d0i3 exit in these cases as well. 552 558 */ 553 559 if (!wait_event_timeout(mvm->d0i3_exit_waitq, 554 560 !test_bit(IWL_MVM_STATUS_IN_D0I3, &mvm->status), HZ)) { ··· 565 553 iwl_mvm_unref(mvm, IWL_MVM_REF_TX_AGG); 566 554 return -EIO; 567 555 } 556 + break; 557 + default: 558 + break; 568 559 } 569 560 570 561 mutex_lock(&mvm->mutex); ··· 2201 2186 2202 2187 switch (vif->type) { 2203 2188 case NL80211_IFTYPE_AP: 2189 + /* Unless it's a CSA flow we have nothing to do here */ 2190 + if (vif->csa_active) { 2191 + mvmvif->ap_ibss_active = true; 2192 + break; 2193 + } 2204 2194 case NL80211_IFTYPE_ADHOC: 2205 2195 /* 2206 2196 * The AP binding flow is handled as part of the start_ap flow ··· 2242 2222 goto out_remove_binding; 2243 2223 } 2244 2224 2225 + /* Handle binding during CSA */ 2226 + if (vif->type == NL80211_IFTYPE_AP) { 2227 + iwl_mvm_update_quotas(mvm, vif); 2228 + iwl_mvm_mac_ctxt_changed(mvm, vif); 2229 + } 2230 + 2245 2231 goto out_unlock; 2246 2232 2247 2233 out_remove_binding: ··· 2272 2246 iwl_mvm_remove_time_event(mvm, mvmvif, &mvmvif->time_event_data); 2273 2247 2274 2248 switch (vif->type) { 2275 - case NL80211_IFTYPE_AP: 2276 2249 case NL80211_IFTYPE_ADHOC: 2277 2250 goto out_unlock; 2278 2251 case NL80211_IFTYPE_MONITOR: 2279 2252 mvmvif->monitor_active = false; 2280 2253 iwl_mvm_update_quotas(mvm, NULL); 2281 2254 break; 2255 + case NL80211_IFTYPE_AP: 2256 + /* This part is triggered only during CSA */ 2257 + if (!vif->csa_active || !mvmvif->ap_ibss_active) 2258 + goto out_unlock; 2259 + 2260 + mvmvif->ap_ibss_active = false; 2261 + iwl_mvm_update_quotas(mvm, NULL); 2262 + /*TODO: bt_coex notification here? */ 2282 2263 default: 2283 2264 break; 2284 2265 } ··· 2381 2348 } 2382 2349 #endif 2383 2350 2351 + static void iwl_mvm_channel_switch_beacon(struct ieee80211_hw *hw, 2352 + struct ieee80211_vif *vif, 2353 + struct cfg80211_chan_def *chandef) 2354 + { 2355 + struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); 2356 + 2357 + mutex_lock(&mvm->mutex); 2358 + if (WARN(mvm->csa_vif && mvm->csa_vif->csa_active, 2359 + "Another CSA is already in progress")) 2360 + goto out_unlock; 2361 + 2362 + IWL_DEBUG_MAC80211(mvm, "CSA started to freq %d\n", 2363 + chandef->center_freq1); 2364 + mvm->csa_vif = vif; 2365 + 2366 + out_unlock: 2367 + mutex_unlock(&mvm->mutex); 2368 + } 2369 + 2370 + static void iwl_mvm_mac_flush(struct ieee80211_hw *hw, 2371 + struct ieee80211_vif *vif, u32 queues, bool drop) 2372 + { 2373 + struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); 2374 + struct iwl_mvm_vif *mvmvif; 2375 + struct iwl_mvm_sta *mvmsta; 2376 + 2377 + if (!vif || vif->type != NL80211_IFTYPE_STATION) 2378 + return; 2379 + 2380 + mutex_lock(&mvm->mutex); 2381 + mvmvif = iwl_mvm_vif_from_mac80211(vif); 2382 + mvmsta = iwl_mvm_sta_from_staid_protected(mvm, mvmvif->ap_sta_id); 2383 + 2384 + if (WARN_ON_ONCE(!mvmsta)) 2385 + goto done; 2386 + 2387 + if (drop) { 2388 + if (iwl_mvm_flush_tx_path(mvm, mvmsta->tfd_queue_msk, true)) 2389 + IWL_ERR(mvm, "flush request fail\n"); 2390 + } else { 2391 + iwl_trans_wait_tx_queue_empty(mvm->trans, 2392 + mvmsta->tfd_queue_msk); 2393 + } 2394 + done: 2395 + mutex_unlock(&mvm->mutex); 2396 + } 2397 + 2384 2398 const struct ieee80211_ops iwl_mvm_hw_ops = { 2385 2399 .tx = iwl_mvm_mac_tx, 2386 2400 .ampdu_action = iwl_mvm_mac_ampdu_action, ··· 2451 2371 .sta_rc_update = iwl_mvm_sta_rc_update, 2452 2372 .conf_tx = iwl_mvm_mac_conf_tx, 2453 2373 .mgd_prepare_tx = iwl_mvm_mac_mgd_prepare_tx, 2374 + .flush = iwl_mvm_mac_flush, 2454 2375 .sched_scan_start = iwl_mvm_mac_sched_scan_start, 2455 2376 .sched_scan_stop = iwl_mvm_mac_sched_scan_stop, 2456 2377 .set_key = iwl_mvm_mac_set_key, ··· 2470 2389 .leave_ibss = iwl_mvm_stop_ap_ibss, 2471 2390 2472 2391 .set_tim = iwl_mvm_set_tim, 2392 + 2393 + .channel_switch_beacon = iwl_mvm_channel_switch_beacon, 2473 2394 2474 2395 CFG80211_TESTMODE_CMD(iwl_mvm_mac_testmode_cmd) 2475 2396
+15 -1
drivers/net/wireless/iwlwifi/mvm/mvm.h
··· 589 589 u32 *fw_error_rxf; 590 590 u32 fw_error_rxf_len; 591 591 592 + #ifdef CONFIG_IWLWIFI_LEDS 592 593 struct led_classdev led; 594 + #endif 593 595 594 596 struct ieee80211_vif *p2p_device_vif; 595 597 ··· 644 642 645 643 /* Indicate if device power save is allowed */ 646 644 bool ps_disabled; 645 + 646 + struct ieee80211_vif *csa_vif; 647 647 }; 648 648 649 649 /* Extract MVM priv from op_mode and _hw */ ··· 761 757 struct iwl_device_cmd *cmd); 762 758 763 759 /* NVM */ 764 - int iwl_nvm_init(struct iwl_mvm *mvm); 760 + int iwl_nvm_init(struct iwl_mvm *mvm, bool read_nvm_from_nic); 765 761 int iwl_mvm_load_nvm_to_nic(struct iwl_mvm *mvm); 766 762 767 763 int iwl_mvm_up(struct iwl_mvm *mvm); ··· 900 896 struct iwl_rx_cmd_buffer *rxb, 901 897 struct iwl_device_cmd *cmd); 902 898 899 + #ifdef CONFIG_IWLWIFI_LEDS 903 900 int iwl_mvm_leds_init(struct iwl_mvm *mvm); 904 901 void iwl_mvm_leds_exit(struct iwl_mvm *mvm); 902 + #else 903 + static inline int iwl_mvm_leds_init(struct iwl_mvm *mvm) 904 + { 905 + return 0; 906 + } 907 + static inline void iwl_mvm_leds_exit(struct iwl_mvm *mvm) 908 + { 909 + } 910 + #endif 905 911 906 912 /* D3 (WoWLAN, NetDetect) */ 907 913 int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan);
+20 -10
drivers/net/wireless/iwlwifi/mvm/nvm.c
··· 238 238 return NULL; 239 239 } 240 240 } else { 241 + /* SW and REGULATORY sections are mandatory */ 241 242 if (!mvm->nvm_sections[NVM_SECTION_TYPE_SW].data || 242 - !mvm->nvm_sections[NVM_SECTION_TYPE_MAC_OVERRIDE].data || 243 243 !mvm->nvm_sections[NVM_SECTION_TYPE_REGULATORY].data) { 244 244 IWL_ERR(mvm, 245 245 "Can't parse empty family 8000 NVM sections\n"); 246 + return NULL; 247 + } 248 + /* MAC_OVERRIDE or at least HW section must exist */ 249 + if (!mvm->nvm_sections[mvm->cfg->nvm_hw_section_num].data && 250 + !mvm->nvm_sections[NVM_SECTION_TYPE_MAC_OVERRIDE].data) { 251 + IWL_ERR(mvm, 252 + "Can't parse mac_address, empty sections\n"); 246 253 return NULL; 247 254 } 248 255 } ··· 434 427 return ret; 435 428 } 436 429 437 - int iwl_nvm_init(struct iwl_mvm *mvm) 430 + int iwl_nvm_init(struct iwl_mvm *mvm, bool read_nvm_from_nic) 438 431 { 439 432 int ret, i, section; 440 433 u8 *nvm_buffer, *temp; ··· 444 437 if (WARN_ON_ONCE(mvm->cfg->nvm_hw_section_num >= NVM_MAX_NUM_SECTIONS)) 445 438 return -EINVAL; 446 439 447 - /* load external NVM if configured */ 448 - if (iwlwifi_mod_params.nvm_file) { 449 - /* move to External NVM flow */ 450 - ret = iwl_mvm_read_external_nvm(mvm); 451 - if (ret) 452 - return ret; 453 - } else { 440 + /* load NVM values from nic */ 441 + if (read_nvm_from_nic) { 454 442 /* list of NVM sections we are allowed/need to read */ 455 443 if (mvm->trans->cfg->device_family != IWL_DEVICE_FAMILY_8000) { 456 444 nvm_to_read[0] = mvm->cfg->nvm_hw_section_num; ··· 465 463 /* Read From FW NVM */ 466 464 IWL_DEBUG_EEPROM(mvm->trans->dev, "Read from NVM\n"); 467 465 468 - /* TODO: find correct NVM max size for a section */ 469 466 nvm_buffer = kmalloc(mvm->cfg->base_params->eeprom_size, 470 467 GFP_KERNEL); 471 468 if (!nvm_buffer) ··· 512 511 return ret; 513 512 } 514 513 514 + /* load external NVM if configured */ 515 + if (iwlwifi_mod_params.nvm_file) { 516 + /* move to External NVM flow */ 517 + ret = iwl_mvm_read_external_nvm(mvm); 518 + if (ret) 519 + return ret; 520 + } 521 + 522 + /* parse the relevant nvm sections */ 515 523 mvm->nvm_data = iwl_parse_nvm_sections(mvm); 516 524 if (!mvm->nvm_data) 517 525 return -ENODATA;
+28 -8
drivers/net/wireless/iwlwifi/mvm/ops.c
··· 79 79 #include "iwl-prph.h" 80 80 #include "rs.h" 81 81 #include "fw-api-scan.h" 82 - #include "fw-error-dump.h" 83 82 #include "time-event.h" 83 + #include "iwl-fw-error-dump.h" 84 84 85 85 /* 86 86 * module name, copyright, version, etc. ··· 220 220 RX_HANDLER(BA_NOTIF, iwl_mvm_rx_ba_notif, false), 221 221 222 222 RX_HANDLER(BT_PROFILE_NOTIFICATION, iwl_mvm_rx_bt_coex_notif, true), 223 - RX_HANDLER(BEACON_NOTIFICATION, iwl_mvm_rx_beacon_notif, false), 223 + RX_HANDLER(BEACON_NOTIFICATION, iwl_mvm_rx_beacon_notif, true), 224 224 RX_HANDLER(STATISTICS_NOTIFICATION, iwl_mvm_rx_statistics, true), 225 225 RX_HANDLER(ANTENNA_COUPLING_NOTIFICATION, 226 226 iwl_mvm_rx_ant_coupling_notif, true), ··· 467 467 min_backoff = calc_min_backoff(trans, cfg); 468 468 iwl_mvm_tt_initialize(mvm, min_backoff); 469 469 470 + if (WARN(cfg->no_power_up_nic_in_init && !iwlwifi_mod_params.nvm_file, 471 + "not allowing power-up and not having nvm_file\n")) 472 + goto out_free; 473 + 470 474 /* 471 - * If the NVM exists in an external file, 472 - * there is no need to unnecessarily power up the NIC at driver load 475 + * Even if nvm exists in the nvm_file driver should read agin the nvm 476 + * from the nic because there might be entries that exist in the OTP 477 + * and not in the file. 478 + * for nics with no_power_up_nic_in_init: rely completley on nvm_file 473 479 */ 474 - if (iwlwifi_mod_params.nvm_file) { 475 - err = iwl_nvm_init(mvm); 480 + if (cfg->no_power_up_nic_in_init && iwlwifi_mod_params.nvm_file) { 481 + err = iwl_nvm_init(mvm, false); 476 482 if (err) 477 483 goto out_free; 478 484 } else { ··· 525 519 out_free: 526 520 iwl_phy_db_free(mvm->phy_db); 527 521 kfree(mvm->scan_cmd); 528 - if (!iwlwifi_mod_params.nvm_file) 522 + if (!cfg->no_power_up_nic_in_init || !iwlwifi_mod_params.nvm_file) 529 523 iwl_trans_op_mode_leave(trans); 530 524 ieee80211_free_hw(mvm->hw); 531 525 return NULL; ··· 822 816 struct iwl_fw_error_dump_file *dump_file; 823 817 struct iwl_fw_error_dump_data *dump_data; 824 818 u32 file_len; 819 + u32 trans_len; 825 820 826 821 lockdep_assert_held(&mvm->mutex); 827 822 ··· 833 826 mvm->fw_error_rxf_len + 834 827 sizeof(*dump_file) + 835 828 sizeof(*dump_data) * 2; 829 + 830 + trans_len = iwl_trans_dump_data(mvm->trans, NULL, 0); 831 + if (trans_len) 832 + file_len += trans_len; 836 833 837 834 dump_file = vmalloc(file_len); 838 835 if (!dump_file) ··· 851 840 dump_data->len = cpu_to_le32(mvm->fw_error_rxf_len); 852 841 memcpy(dump_data->data, mvm->fw_error_rxf, mvm->fw_error_rxf_len); 853 842 854 - dump_data = (void *)((u8 *)dump_data->data + mvm->fw_error_rxf_len); 843 + dump_data = iwl_mvm_fw_error_next_data(dump_data); 855 844 dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_SRAM); 856 845 dump_data->len = cpu_to_le32(mvm->fw_error_sram_len); 857 846 ··· 869 858 kfree(mvm->fw_error_sram); 870 859 mvm->fw_error_sram = NULL; 871 860 mvm->fw_error_sram_len = 0; 861 + 862 + if (trans_len) { 863 + void *buf = iwl_mvm_fw_error_next_data(dump_data); 864 + u32 real_trans_len = iwl_trans_dump_data(mvm->trans, buf, 865 + trans_len); 866 + dump_data = (void *)((u8 *)buf + real_trans_len); 867 + dump_file->file_len = 868 + cpu_to_le32(file_len - trans_len + real_trans_len); 869 + } 872 870 } 873 871 #endif 874 872
+3 -6
drivers/net/wireless/iwlwifi/mvm/phy-ctxt.c
··· 202 202 struct cfg80211_chan_def *chandef, 203 203 u8 chains_static, u8 chains_dynamic) 204 204 { 205 - int ret; 206 - 207 205 WARN_ON(!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) && 208 206 ctxt->ref); 209 207 lockdep_assert_held(&mvm->mutex); 210 208 211 209 ctxt->channel = chandef->chan; 212 - ret = iwl_mvm_phy_ctxt_apply(mvm, ctxt, chandef, 213 - chains_static, chains_dynamic, 214 - FW_CTXT_ACTION_ADD, 0); 215 210 216 - return ret; 211 + return iwl_mvm_phy_ctxt_apply(mvm, ctxt, chandef, 212 + chains_static, chains_dynamic, 213 + FW_CTXT_ACTION_ADD, 0); 217 214 } 218 215 219 216 /*
+62 -119
drivers/net/wireless/iwlwifi/mvm/rs.c
··· 211 211 .next_columns = { 212 212 RS_COLUMN_LEGACY_ANT_B, 213 213 RS_COLUMN_SISO_ANT_A, 214 - RS_COLUMN_SISO_ANT_B, 214 + RS_COLUMN_MIMO2, 215 215 RS_COLUMN_INVALID, 216 216 RS_COLUMN_INVALID, 217 217 RS_COLUMN_INVALID, ··· 223 223 .ant = ANT_B, 224 224 .next_columns = { 225 225 RS_COLUMN_LEGACY_ANT_A, 226 - RS_COLUMN_SISO_ANT_A, 227 226 RS_COLUMN_SISO_ANT_B, 227 + RS_COLUMN_MIMO2, 228 228 RS_COLUMN_INVALID, 229 229 RS_COLUMN_INVALID, 230 230 RS_COLUMN_INVALID, ··· 238 238 RS_COLUMN_SISO_ANT_B, 239 239 RS_COLUMN_MIMO2, 240 240 RS_COLUMN_SISO_ANT_A_SGI, 241 - RS_COLUMN_SISO_ANT_B_SGI, 242 241 RS_COLUMN_LEGACY_ANT_A, 243 242 RS_COLUMN_LEGACY_ANT_B, 243 + RS_COLUMN_INVALID, 244 244 RS_COLUMN_INVALID, 245 245 }, 246 246 .checks = { ··· 254 254 RS_COLUMN_SISO_ANT_A, 255 255 RS_COLUMN_MIMO2, 256 256 RS_COLUMN_SISO_ANT_B_SGI, 257 - RS_COLUMN_SISO_ANT_A_SGI, 258 257 RS_COLUMN_LEGACY_ANT_A, 259 258 RS_COLUMN_LEGACY_ANT_B, 259 + RS_COLUMN_INVALID, 260 260 RS_COLUMN_INVALID, 261 261 }, 262 262 .checks = { ··· 271 271 RS_COLUMN_SISO_ANT_B_SGI, 272 272 RS_COLUMN_MIMO2_SGI, 273 273 RS_COLUMN_SISO_ANT_A, 274 - RS_COLUMN_SISO_ANT_B, 275 - RS_COLUMN_MIMO2, 276 274 RS_COLUMN_LEGACY_ANT_A, 277 275 RS_COLUMN_LEGACY_ANT_B, 276 + RS_COLUMN_INVALID, 277 + RS_COLUMN_INVALID, 278 278 }, 279 279 .checks = { 280 280 rs_siso_allow, ··· 289 289 RS_COLUMN_SISO_ANT_A_SGI, 290 290 RS_COLUMN_MIMO2_SGI, 291 291 RS_COLUMN_SISO_ANT_B, 292 - RS_COLUMN_SISO_ANT_A, 293 - RS_COLUMN_MIMO2, 294 292 RS_COLUMN_LEGACY_ANT_A, 295 293 RS_COLUMN_LEGACY_ANT_B, 294 + RS_COLUMN_INVALID, 295 + RS_COLUMN_INVALID, 296 296 }, 297 297 .checks = { 298 298 rs_siso_allow, ··· 304 304 .ant = ANT_AB, 305 305 .next_columns = { 306 306 RS_COLUMN_SISO_ANT_A, 307 - RS_COLUMN_SISO_ANT_B, 308 - RS_COLUMN_SISO_ANT_A_SGI, 309 - RS_COLUMN_SISO_ANT_B_SGI, 310 307 RS_COLUMN_MIMO2_SGI, 311 308 RS_COLUMN_LEGACY_ANT_A, 312 309 RS_COLUMN_LEGACY_ANT_B, 310 + RS_COLUMN_INVALID, 311 + RS_COLUMN_INVALID, 312 + RS_COLUMN_INVALID, 313 313 }, 314 314 .checks = { 315 315 rs_mimo_allow, ··· 321 321 .sgi = true, 322 322 .next_columns = { 323 323 RS_COLUMN_SISO_ANT_A_SGI, 324 - RS_COLUMN_SISO_ANT_B_SGI, 325 - RS_COLUMN_SISO_ANT_A, 326 - RS_COLUMN_SISO_ANT_B, 327 324 RS_COLUMN_MIMO2, 328 325 RS_COLUMN_LEGACY_ANT_A, 329 326 RS_COLUMN_LEGACY_ANT_B, 327 + RS_COLUMN_INVALID, 328 + RS_COLUMN_INVALID, 329 + RS_COLUMN_INVALID, 330 330 }, 331 331 .checks = { 332 332 rs_mimo_allow, ··· 1031 1031 return; 1032 1032 } 1033 1033 1034 - #ifdef CPTCFG_MAC80211_DEBUGFS 1034 + #ifdef CONFIG_MAC80211_DEBUGFS 1035 1035 /* Disable last tx check if we are debugging with fixed rate */ 1036 1036 if (lq_sta->dbg_fixed_rate) { 1037 1037 IWL_DEBUG_RATE(mvm, "Fixed rate. avoid rate scaling\n"); ··· 1335 1335 tbl->expected_tpt = rs_get_expected_tpt_table(lq_sta, column, rate->bw); 1336 1336 } 1337 1337 1338 - /* 1339 - * Find starting rate for new "search" high-throughput mode of modulation. 1340 - * Goal is to find lowest expected rate (under perfect conditions) that is 1341 - * above the current measured throughput of "active" mode, to give new mode 1342 - * a fair chance to prove itself without too many challenges. 1343 - * 1344 - * This gets called when transitioning to more aggressive modulation 1345 - * (i.e. legacy to SISO or MIMO, or SISO to MIMO), as well as less aggressive 1346 - * (i.e. MIMO to SISO). When moving to MIMO, bit rate will typically need 1347 - * to decrease to match "active" throughput. When moving from MIMO to SISO, 1348 - * bit rate will typically need to increase, but not if performance was bad. 1349 - */ 1350 1338 static s32 rs_get_best_rate(struct iwl_mvm *mvm, 1351 1339 struct iwl_lq_sta *lq_sta, 1352 1340 struct iwl_scale_tbl_info *tbl, /* "search" */ 1353 - u16 rate_mask, s8 index) 1341 + unsigned long rate_mask, s8 index) 1354 1342 { 1355 - /* "active" values */ 1356 1343 struct iwl_scale_tbl_info *active_tbl = 1357 1344 &(lq_sta->lq_info[lq_sta->active_tbl]); 1358 - s32 active_sr = active_tbl->win[index].success_ratio; 1359 - s32 active_tpt = active_tbl->expected_tpt[index]; 1360 - /* expected "search" throughput */ 1345 + s32 success_ratio = active_tbl->win[index].success_ratio; 1346 + u16 expected_current_tpt = active_tbl->expected_tpt[index]; 1361 1347 const u16 *tpt_tbl = tbl->expected_tpt; 1362 - 1363 - s32 new_rate, high, low, start_hi; 1364 1348 u16 high_low; 1365 - s8 rate = index; 1349 + u32 target_tpt; 1350 + int rate_idx; 1366 1351 1367 - new_rate = high = low = start_hi = IWL_RATE_INVALID; 1368 - 1369 - while (1) { 1370 - high_low = rs_get_adjacent_rate(mvm, rate, rate_mask, 1371 - tbl->rate.type); 1372 - 1373 - low = high_low & 0xff; 1374 - high = (high_low >> 8) & 0xff; 1375 - 1376 - /* 1377 - * Lower the "search" bit rate, to give new "search" mode 1378 - * approximately the same throughput as "active" if: 1379 - * 1380 - * 1) "Active" mode has been working modestly well (but not 1381 - * great), and expected "search" throughput (under perfect 1382 - * conditions) at candidate rate is above the actual 1383 - * measured "active" throughput (but less than expected 1384 - * "active" throughput under perfect conditions). 1385 - * OR 1386 - * 2) "Active" mode has been working perfectly or very well 1387 - * and expected "search" throughput (under perfect 1388 - * conditions) at candidate rate is above expected 1389 - * "active" throughput (under perfect conditions). 1390 - */ 1391 - if ((((100 * tpt_tbl[rate]) > lq_sta->last_tpt) && 1392 - ((active_sr > RS_SR_FORCE_DECREASE) && 1393 - (active_sr <= IWL_RATE_HIGH_TH) && 1394 - (tpt_tbl[rate] <= active_tpt))) || 1395 - ((active_sr >= IWL_RATE_SCALE_SWITCH) && 1396 - (tpt_tbl[rate] > active_tpt))) { 1397 - /* (2nd or later pass) 1398 - * If we've already tried to raise the rate, and are 1399 - * now trying to lower it, use the higher rate. */ 1400 - if (start_hi != IWL_RATE_INVALID) { 1401 - new_rate = start_hi; 1402 - break; 1403 - } 1404 - 1405 - new_rate = rate; 1406 - 1407 - /* Loop again with lower rate */ 1408 - if (low != IWL_RATE_INVALID) 1409 - rate = low; 1410 - 1411 - /* Lower rate not available, use the original */ 1412 - else 1413 - break; 1414 - 1415 - /* Else try to raise the "search" rate to match "active" */ 1416 - } else { 1417 - /* (2nd or later pass) 1418 - * If we've already tried to lower the rate, and are 1419 - * now trying to raise it, use the lower rate. */ 1420 - if (new_rate != IWL_RATE_INVALID) 1421 - break; 1422 - 1423 - /* Loop again with higher rate */ 1424 - else if (high != IWL_RATE_INVALID) { 1425 - start_hi = high; 1426 - rate = high; 1427 - 1428 - /* Higher rate not available, use the original */ 1429 - } else { 1430 - new_rate = rate; 1431 - break; 1432 - } 1433 - } 1352 + if (success_ratio > RS_SR_NO_DECREASE) { 1353 + target_tpt = 100 * expected_current_tpt; 1354 + IWL_DEBUG_RATE(mvm, 1355 + "SR %d high. Find rate exceeding EXPECTED_CURRENT %d\n", 1356 + success_ratio, target_tpt); 1357 + } else { 1358 + target_tpt = lq_sta->last_tpt; 1359 + IWL_DEBUG_RATE(mvm, 1360 + "SR %d not thag good. Find rate exceeding ACTUAL_TPT %d\n", 1361 + success_ratio, target_tpt); 1434 1362 } 1435 1363 1436 - return new_rate; 1364 + rate_idx = find_first_bit(&rate_mask, BITS_PER_LONG); 1365 + 1366 + while (rate_idx != IWL_RATE_INVALID) { 1367 + if (target_tpt < (100 * tpt_tbl[rate_idx])) 1368 + break; 1369 + 1370 + high_low = rs_get_adjacent_rate(mvm, rate_idx, rate_mask, 1371 + tbl->rate.type); 1372 + 1373 + rate_idx = (high_low >> 8) & 0xff; 1374 + } 1375 + 1376 + IWL_DEBUG_RATE(mvm, "Best rate found %d target_tp %d expected_new %d\n", 1377 + rate_idx, target_tpt, 1378 + rate_idx != IWL_RATE_INVALID ? 1379 + 100 * tpt_tbl[rate_idx] : IWL_INVALID_VALUE); 1380 + 1381 + return rate_idx; 1437 1382 } 1438 1383 1439 1384 static u32 rs_bw_from_sta_bw(struct ieee80211_sta *sta) ··· 1553 1608 1554 1609 tpt = lq_sta->last_tpt / 100; 1555 1610 expected_tpt_tbl = rs_get_expected_tpt_table(lq_sta, next_col, 1556 - tbl->rate.bw); 1611 + rs_bw_from_sta_bw(sta)); 1557 1612 if (WARN_ON_ONCE(!expected_tpt_tbl)) 1558 1613 continue; 1559 1614 ··· 1594 1649 const struct rs_tx_column *curr_column = &rs_tx_columns[tbl->column]; 1595 1650 u32 sz = (sizeof(struct iwl_scale_tbl_info) - 1596 1651 (sizeof(struct iwl_rate_scale_data) * IWL_RATE_COUNT)); 1597 - u16 rate_mask = 0; 1652 + unsigned long rate_mask = 0; 1598 1653 u32 rate_idx = 0; 1599 1654 1600 1655 memcpy(search_tbl, tbl, sz); ··· 1636 1691 !(BIT(rate_idx) & rate_mask)) { 1637 1692 IWL_DEBUG_RATE(mvm, 1638 1693 "can not switch with index %d" 1639 - " rate mask %x\n", 1694 + " rate mask %lx\n", 1640 1695 rate_idx, rate_mask); 1641 1696 1642 1697 goto err; ··· 1750 1805 *stronger = TPC_INVALID; 1751 1806 } 1752 1807 1753 - static bool rs_tpc_allowed(struct iwl_mvm *mvm, struct rs_rate *rate, 1754 - enum ieee80211_band band) 1808 + static bool rs_tpc_allowed(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1809 + struct rs_rate *rate, enum ieee80211_band band) 1755 1810 { 1756 1811 int index = rate->index; 1812 + bool cam = (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_CAM); 1813 + bool sta_ps_disabled = (vif->type == NL80211_IFTYPE_STATION && 1814 + !vif->bss_conf.ps); 1757 1815 1816 + IWL_DEBUG_RATE(mvm, "cam: %d sta_ps_disabled %d\n", 1817 + cam, sta_ps_disabled); 1758 1818 /* 1759 1819 * allow tpc only if power management is enabled, or bt coex 1760 1820 * activity grade allows it and we are on 2.4Ghz. 1761 1821 */ 1762 - if (iwlmvm_mod_params.power_scheme == IWL_POWER_SCHEME_CAM && 1822 + if ((cam || sta_ps_disabled) && 1763 1823 !iwl_mvm_bt_coex_is_tpc_allowed(mvm, band)) 1764 1824 return false; 1765 1825 ··· 1881 1931 band = chanctx_conf->def.chan->band; 1882 1932 rcu_read_unlock(); 1883 1933 1884 - if (!rs_tpc_allowed(mvm, rate, band)) { 1934 + if (!rs_tpc_allowed(mvm, vif, rate, band)) { 1885 1935 IWL_DEBUG_RATE(mvm, 1886 1936 "tpc is not allowed. remove txp restrictions"); 1887 1937 lq_sta->lq.reduced_tpc = TPC_NO_REDUCTION; ··· 2185 2235 break; 2186 2236 case RS_ACTION_STAY: 2187 2237 /* No change */ 2188 - update_lq = rs_tpc_perform(mvm, sta, lq_sta, tbl); 2238 + if (lq_sta->rs_state == RS_STATE_STAY_IN_COLUMN) 2239 + update_lq = rs_tpc_perform(mvm, sta, lq_sta, tbl); 2189 2240 break; 2190 2241 default: 2191 2242 break; ··· 2440 2489 if (i == IWL_RATE_9M_INDEX) 2441 2490 continue; 2442 2491 2443 - /* Disable MCS9 as a workaround */ 2444 - if (i == IWL_RATE_MCS_9_INDEX) 2445 - continue; 2446 - 2447 2492 /* VHT MCS9 isn't valid for 20Mhz for NSS=1,2 */ 2448 2493 if (i == IWL_RATE_MCS_9_INDEX && 2449 2494 sta->bandwidth == IEEE80211_STA_RX_BW_20) ··· 2456 2509 if (highest_mcs >= IWL_RATE_MCS_0_INDEX) { 2457 2510 for (i = IWL_RATE_MCS_0_INDEX; i <= highest_mcs; i++) { 2458 2511 if (i == IWL_RATE_9M_INDEX) 2459 - continue; 2460 - 2461 - /* Disable MCS9 as a workaround */ 2462 - if (i == IWL_RATE_MCS_9_INDEX) 2463 2512 continue; 2464 2513 2465 2514 /* VHT MCS9 isn't valid for 20Mhz for NSS=1,2 */
+12 -41
drivers/net/wireless/iwlwifi/mvm/scan.c
··· 277 277 IEEE80211_IFACE_ITER_NORMAL, 278 278 iwl_mvm_scan_condition_iterator, 279 279 &global_bound); 280 - /* 281 - * Under low latency traffic passive scan is fragmented meaning 282 - * that dwell on a particular channel will be fragmented. Each fragment 283 - * dwell time is 20ms and fragments period is 105ms. Skipping to next 284 - * channel will be delayed by the same period - 105ms. So suspend_time 285 - * parameter describing both fragments and channels skipping periods is 286 - * set to 105ms. This value is chosen so that overall passive scan 287 - * duration will not be too long. Max_out_time in this case is set to 288 - * 70ms, so for active scanning operating channel will be left for 70ms 289 - * while for passive still for 20ms (fragment dwell). 290 - */ 291 - if (global_bound) { 292 - if (!iwl_mvm_low_latency(mvm)) { 293 - params->suspend_time = ieee80211_tu_to_usec(100); 294 - params->max_out_time = ieee80211_tu_to_usec(600); 295 - } else { 296 - params->suspend_time = ieee80211_tu_to_usec(105); 297 - /* P2P doesn't support fragmented passive scan, so 298 - * configure max_out_time to be at least longest dwell 299 - * time for passive scan. 300 - */ 301 - if (vif->type == NL80211_IFTYPE_STATION && !vif->p2p) { 302 - params->max_out_time = ieee80211_tu_to_usec(70); 303 - params->passive_fragmented = true; 304 - } else { 305 - u32 passive_dwell; 306 280 307 - /* 308 - * Use band G so that passive channel dwell time 309 - * will be assigned with maximum value. 310 - */ 311 - band = IEEE80211_BAND_2GHZ; 312 - passive_dwell = iwl_mvm_get_passive_dwell(band); 313 - params->max_out_time = 314 - ieee80211_tu_to_usec(passive_dwell); 315 - } 316 - } 281 + if (!global_bound) 282 + goto not_bound; 283 + 284 + params->suspend_time = 100; 285 + params->max_out_time = 600; 286 + 287 + if (iwl_mvm_low_latency(mvm)) { 288 + params->suspend_time = 250; 289 + params->max_out_time = 250; 317 290 } 318 291 292 + not_bound: 293 + 319 294 for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) { 320 - if (params->passive_fragmented) 321 - params->dwell[band].passive = 20; 322 - else 323 - params->dwell[band].passive = 324 - iwl_mvm_get_passive_dwell(band); 295 + params->dwell[band].passive = iwl_mvm_get_passive_dwell(band); 325 296 params->dwell[band].active = iwl_mvm_get_active_dwell(band, 326 297 n_ssids); 327 298 }
+2
drivers/net/wireless/iwlwifi/mvm/utils.c
··· 519 519 iwl_mvm_dump_umac_error_log(mvm); 520 520 } 521 521 522 + #ifdef CONFIG_IWLWIFI_DEBUGFS 522 523 void iwl_mvm_fw_error_sram_dump(struct iwl_mvm *mvm) 523 524 { 524 525 const struct fw_img *img; ··· 582 581 } 583 582 iwl_trans_release_nic_access(mvm->trans, &flags); 584 583 } 584 + #endif 585 585 586 586 /** 587 587 * iwl_mvm_send_lq_cmd() - Send link quality command
+14 -10
drivers/net/wireless/iwlwifi/pcie/internal.h
··· 117 117 /** 118 118 * iwl_queue_inc_wrap - increment queue index, wrap back to beginning 119 119 * @index -- current index 120 - * @n_bd -- total number of entries in queue (must be power of 2) 121 120 */ 122 - static inline int iwl_queue_inc_wrap(int index, int n_bd) 121 + static inline int iwl_queue_inc_wrap(int index) 123 122 { 124 - return ++index & (n_bd - 1); 123 + return ++index & (TFD_QUEUE_SIZE_MAX - 1); 125 124 } 126 125 127 126 /** 128 127 * iwl_queue_dec_wrap - decrement queue index, wrap back to end 129 128 * @index -- current index 130 - * @n_bd -- total number of entries in queue (must be power of 2) 131 129 */ 132 - static inline int iwl_queue_dec_wrap(int index, int n_bd) 130 + static inline int iwl_queue_dec_wrap(int index) 133 131 { 134 - return --index & (n_bd - 1); 132 + return --index & (TFD_QUEUE_SIZE_MAX - 1); 135 133 } 136 134 137 135 struct iwl_cmd_meta { ··· 143 145 * 144 146 * Contains common data for Rx and Tx queues. 145 147 * 146 - * Note the difference between n_bd and n_window: the hardware 147 - * always assumes 256 descriptors, so n_bd is always 256 (unless 148 + * Note the difference between TFD_QUEUE_SIZE_MAX and n_window: the hardware 149 + * always assumes 256 descriptors, so TFD_QUEUE_SIZE_MAX is always 256 (unless 148 150 * there might be HW changes in the future). For the normal TX 149 151 * queues, n_window, which is the size of the software queue data 150 152 * is also 256; however, for the command queue, n_window is only 151 153 * 32 since we don't need so many commands pending. Since the HW 152 - * still uses 256 BDs for DMA though, n_bd stays 256. As a result, 154 + * still uses 256 BDs for DMA though, TFD_QUEUE_SIZE_MAX stays 256. As a result, 153 155 * the software buffers (in the variables @meta, @txb in struct 154 156 * iwl_txq) only have 32 entries, while the HW buffers (@tfds in 155 157 * the same struct) have 256. ··· 160 162 * data is a window overlayed over the HW queue. 161 163 */ 162 164 struct iwl_queue { 163 - int n_bd; /* number of BDs in this queue */ 164 165 int write_ptr; /* 1-st empty entry (index) host_w*/ 165 166 int read_ptr; /* last used entry (index) host_r*/ 166 167 /* use for monitoring and recovering the stuck queue */ ··· 369 372 void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id, int ssn, 370 373 struct sk_buff_head *skbs); 371 374 void iwl_trans_pcie_tx_reset(struct iwl_trans *trans); 375 + 376 + static inline u16 iwl_pcie_tfd_tb_get_len(struct iwl_tfd *tfd, u8 idx) 377 + { 378 + struct iwl_tfd_tb *tb = &tfd->tbs[idx]; 379 + 380 + return le16_to_cpu(tb->hi_n_len) >> 4; 381 + } 372 382 373 383 /***************************************************** 374 384 * Error handling
+1 -1
drivers/net/wireless/iwlwifi/pcie/rx.c
··· 850 850 trans_pcie->ict_index, read); 851 851 trans_pcie->ict_tbl[trans_pcie->ict_index] = 0; 852 852 trans_pcie->ict_index = 853 - iwl_queue_inc_wrap(trans_pcie->ict_index, ICT_COUNT); 853 + ((trans_pcie->ict_index + 1) & (ICT_COUNT - 1)); 854 854 855 855 read = le32_to_cpu(trans_pcie->ict_tbl[trans_pcie->ict_index]); 856 856 trace_iwlwifi_dev_ict_read(trans->dev, trans_pcie->ict_index,
+62 -2
drivers/net/wireless/iwlwifi/pcie/trans.c
··· 73 73 #include "iwl-csr.h" 74 74 #include "iwl-prph.h" 75 75 #include "iwl-agn-hw.h" 76 + #include "iwl-fw-error-dump.h" 76 77 #include "internal.h" 77 78 78 79 static u32 iwl_trans_pcie_read_shr(struct iwl_trans *trans, u32 reg) ··· 1338 1337 IWL_ERR(trans, 1339 1338 "Q %d is %sactive and mapped to fifo %d ra_tid 0x%04x [%d,%d]\n", 1340 1339 cnt, active ? "" : "in", fifo, tbl_dw, 1341 - iwl_read_prph(trans, 1342 - SCD_QUEUE_RDPTR(cnt)) & (txq->q.n_bd - 1), 1340 + iwl_read_prph(trans, SCD_QUEUE_RDPTR(cnt)) & 1341 + (TFD_QUEUE_SIZE_MAX - 1), 1343 1342 iwl_read_prph(trans, SCD_QUEUE_WRPTR(cnt))); 1344 1343 } 1345 1344 ··· 1670 1669 IWL_ERR(trans, "failed to create the trans debugfs entry\n"); 1671 1670 return -ENOMEM; 1672 1671 } 1672 + 1673 + static u32 iwl_trans_pcie_get_cmdlen(struct iwl_tfd *tfd) 1674 + { 1675 + u32 cmdlen = 0; 1676 + int i; 1677 + 1678 + for (i = 0; i < IWL_NUM_OF_TBS; i++) 1679 + cmdlen += iwl_pcie_tfd_tb_get_len(tfd, i); 1680 + 1681 + return cmdlen; 1682 + } 1683 + 1684 + static u32 iwl_trans_pcie_dump_data(struct iwl_trans *trans, 1685 + void *buf, u32 buflen) 1686 + { 1687 + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1688 + struct iwl_fw_error_dump_data *data; 1689 + struct iwl_txq *cmdq = &trans_pcie->txq[trans_pcie->cmd_queue]; 1690 + struct iwl_fw_error_dump_txcmd *txcmd; 1691 + u32 len; 1692 + int i, ptr; 1693 + 1694 + if (!buf) 1695 + return sizeof(*data) + 1696 + cmdq->q.n_window * (sizeof(*txcmd) + 1697 + TFD_MAX_PAYLOAD_SIZE); 1698 + 1699 + len = 0; 1700 + data = buf; 1701 + data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_TXCMD); 1702 + txcmd = (void *)data->data; 1703 + spin_lock_bh(&cmdq->lock); 1704 + ptr = cmdq->q.write_ptr; 1705 + for (i = 0; i < cmdq->q.n_window; i++) { 1706 + u8 idx = get_cmd_index(&cmdq->q, ptr); 1707 + u32 caplen, cmdlen; 1708 + 1709 + cmdlen = iwl_trans_pcie_get_cmdlen(&cmdq->tfds[ptr]); 1710 + caplen = min_t(u32, TFD_MAX_PAYLOAD_SIZE, cmdlen); 1711 + 1712 + if (cmdlen) { 1713 + len += sizeof(*txcmd) + caplen; 1714 + txcmd->cmdlen = cpu_to_le32(cmdlen); 1715 + txcmd->caplen = cpu_to_le32(caplen); 1716 + memcpy(txcmd->data, cmdq->entries[idx].cmd, caplen); 1717 + txcmd = (void *)((u8 *)txcmd->data + caplen); 1718 + } 1719 + 1720 + ptr = iwl_queue_dec_wrap(ptr); 1721 + } 1722 + spin_unlock_bh(&cmdq->lock); 1723 + 1724 + data->len = cpu_to_le32(len); 1725 + return sizeof(*data) + len; 1726 + } 1673 1727 #else 1674 1728 static int iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans, 1675 1729 struct dentry *dir) ··· 1767 1711 .grab_nic_access = iwl_trans_pcie_grab_nic_access, 1768 1712 .release_nic_access = iwl_trans_pcie_release_nic_access, 1769 1713 .set_bits_mask = iwl_trans_pcie_set_bits_mask, 1714 + 1715 + #ifdef CONFIG_IWLWIFI_DEBUGFS 1716 + .dump_data = iwl_trans_pcie_dump_data, 1717 + #endif 1770 1718 }; 1771 1719 1772 1720 struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
+65 -66
drivers/net/wireless/iwlwifi/pcie/tx.c
··· 70 70 71 71 /* 72 72 * To avoid ambiguity between empty and completely full queues, there 73 - * should always be less than q->n_bd elements in the queue. 74 - * If q->n_window is smaller than q->n_bd, there is no need to reserve 75 - * any queue entries for this purpose. 73 + * should always be less than TFD_QUEUE_SIZE_MAX elements in the queue. 74 + * If q->n_window is smaller than TFD_QUEUE_SIZE_MAX, there is no need 75 + * to reserve any queue entries for this purpose. 76 76 */ 77 - if (q->n_window < q->n_bd) 77 + if (q->n_window < TFD_QUEUE_SIZE_MAX) 78 78 max = q->n_window; 79 79 else 80 - max = q->n_bd - 1; 80 + max = TFD_QUEUE_SIZE_MAX - 1; 81 81 82 82 /* 83 - * q->n_bd is a power of 2, so the following is equivalent to modulo by 84 - * q->n_bd and is well defined for negative dividends. 83 + * TFD_QUEUE_SIZE_MAX is a power of 2, so the following is equivalent to 84 + * modulo by TFD_QUEUE_SIZE_MAX and is well defined. 85 85 */ 86 - used = (q->write_ptr - q->read_ptr) & (q->n_bd - 1); 86 + used = (q->write_ptr - q->read_ptr) & (TFD_QUEUE_SIZE_MAX - 1); 87 87 88 88 if (WARN_ON(used > max)) 89 89 return 0; ··· 94 94 /* 95 95 * iwl_queue_init - Initialize queue's high/low-water and read/write indexes 96 96 */ 97 - static int iwl_queue_init(struct iwl_queue *q, int count, int slots_num, u32 id) 97 + static int iwl_queue_init(struct iwl_queue *q, int slots_num, u32 id) 98 98 { 99 - q->n_bd = count; 100 99 q->n_window = slots_num; 101 100 q->id = id; 102 - 103 - /* count must be power-of-two size, otherwise iwl_queue_inc_wrap 104 - * and iwl_queue_dec_wrap are broken. */ 105 - if (WARN_ON(!is_power_of_2(count))) 106 - return -EINVAL; 107 101 108 102 /* slots_num must be power-of-two size, otherwise 109 103 * get_cmd_index is broken. */ ··· 191 197 IWL_ERR(trans, 192 198 "Q %d is %sactive and mapped to fifo %d ra_tid 0x%04x [%d,%d]\n", 193 199 i, active ? "" : "in", fifo, tbl_dw, 194 - iwl_read_prph(trans, 195 - SCD_QUEUE_RDPTR(i)) & (txq->q.n_bd - 1), 200 + iwl_read_prph(trans, SCD_QUEUE_RDPTR(i)) & 201 + (TFD_QUEUE_SIZE_MAX - 1), 196 202 iwl_read_prph(trans, SCD_QUEUE_WRPTR(i))); 197 203 } 198 204 199 205 for (i = q->read_ptr; i != q->write_ptr; 200 - i = iwl_queue_inc_wrap(i, q->n_bd)) 206 + i = iwl_queue_inc_wrap(i)) 201 207 IWL_ERR(trans, "scratch %d = 0x%08x\n", i, 202 208 le32_to_cpu(txq->scratchbufs[i].scratch)); 203 209 ··· 353 359 return addr; 354 360 } 355 361 356 - static inline u16 iwl_pcie_tfd_tb_get_len(struct iwl_tfd *tfd, u8 idx) 357 - { 358 - struct iwl_tfd_tb *tb = &tfd->tbs[idx]; 359 - 360 - return le16_to_cpu(tb->hi_n_len) >> 4; 361 - } 362 - 363 362 static inline void iwl_pcie_tfd_set_tb(struct iwl_tfd *tfd, u8 idx, 364 363 dma_addr_t addr, u16 len) 365 364 { ··· 412 425 { 413 426 struct iwl_tfd *tfd_tmp = txq->tfds; 414 427 415 - /* rd_ptr is bounded by n_bd and idx is bounded by n_window */ 428 + /* rd_ptr is bounded by TFD_QUEUE_SIZE_MAX and 429 + * idx is bounded by n_window 430 + */ 416 431 int rd_ptr = txq->q.read_ptr; 417 432 int idx = get_cmd_index(&txq->q, rd_ptr); 418 433 419 434 lockdep_assert_held(&txq->lock); 420 435 421 - /* We have only q->n_window txq->entries, but we use q->n_bd tfds */ 436 + /* We have only q->n_window txq->entries, but we use 437 + * TFD_QUEUE_SIZE_MAX tfds 438 + */ 422 439 iwl_pcie_tfd_unmap(trans, &txq->entries[idx].meta, &tfd_tmp[rd_ptr]); 423 440 424 441 /* free SKB */ ··· 443 452 } 444 453 445 454 static int iwl_pcie_txq_build_tfd(struct iwl_trans *trans, struct iwl_txq *txq, 446 - dma_addr_t addr, u16 len, u8 reset) 455 + dma_addr_t addr, u16 len, bool reset) 447 456 { 448 457 struct iwl_queue *q; 449 458 struct iwl_tfd *tfd, *tfd_tmp; ··· 556 565 BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); 557 566 558 567 /* Initialize queue's high/low-water marks, and head/tail indexes */ 559 - ret = iwl_queue_init(&txq->q, TFD_QUEUE_SIZE_MAX, slots_num, 560 - txq_id); 568 + ret = iwl_queue_init(&txq->q, slots_num, txq_id); 561 569 if (ret) 562 570 return ret; 563 571 ··· 581 591 struct iwl_txq *txq = &trans_pcie->txq[txq_id]; 582 592 struct iwl_queue *q = &txq->q; 583 593 584 - if (!q->n_bd) 585 - return; 586 - 587 594 spin_lock_bh(&txq->lock); 588 595 while (q->write_ptr != q->read_ptr) { 589 596 IWL_DEBUG_TX_REPLY(trans, "Q %d Free %d\n", 590 597 txq_id, q->read_ptr); 591 598 iwl_pcie_txq_free_tfd(trans, txq); 592 - q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd); 599 + q->read_ptr = iwl_queue_inc_wrap(q->read_ptr); 593 600 } 594 601 txq->active = false; 595 602 spin_unlock_bh(&txq->lock); ··· 623 636 } 624 637 625 638 /* De-alloc circular buffer of TFDs */ 626 - if (txq->q.n_bd) { 627 - dma_free_coherent(dev, sizeof(struct iwl_tfd) * 628 - txq->q.n_bd, txq->tfds, txq->q.dma_addr); 639 + if (txq->tfds) { 640 + dma_free_coherent(dev, 641 + sizeof(struct iwl_tfd) * TFD_QUEUE_SIZE_MAX, 642 + txq->tfds, txq->q.dma_addr); 629 643 txq->q.dma_addr = 0; 644 + txq->tfds = NULL; 630 645 631 646 dma_free_coherent(dev, 632 647 sizeof(*txq->scratchbufs) * txq->q.n_window, ··· 937 948 { 938 949 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 939 950 struct iwl_txq *txq = &trans_pcie->txq[txq_id]; 940 - /* n_bd is usually 256 => n_bd - 1 = 0xff */ 941 - int tfd_num = ssn & (txq->q.n_bd - 1); 951 + int tfd_num = ssn & (TFD_QUEUE_SIZE_MAX - 1); 942 952 struct iwl_queue *q = &txq->q; 943 953 int last_to_free; 944 954 ··· 961 973 962 974 /*Since we free until index _not_ inclusive, the one before index is 963 975 * the last we will free. This one must be used */ 964 - last_to_free = iwl_queue_dec_wrap(tfd_num, q->n_bd); 976 + last_to_free = iwl_queue_dec_wrap(tfd_num); 965 977 966 978 if (!iwl_queue_used(q, last_to_free)) { 967 979 IWL_ERR(trans, 968 980 "%s: Read index for DMA queue txq id (%d), last_to_free %d is out of range [0-%d] %d %d.\n", 969 - __func__, txq_id, last_to_free, q->n_bd, 981 + __func__, txq_id, last_to_free, TFD_QUEUE_SIZE_MAX, 970 982 q->write_ptr, q->read_ptr); 971 983 goto out; 972 984 } ··· 976 988 977 989 for (; 978 990 q->read_ptr != tfd_num; 979 - q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { 991 + q->read_ptr = iwl_queue_inc_wrap(q->read_ptr)) { 980 992 981 993 if (WARN_ON_ONCE(txq->entries[txq->q.read_ptr].skb == NULL)) 982 994 continue; ··· 1015 1027 1016 1028 lockdep_assert_held(&txq->lock); 1017 1029 1018 - if ((idx >= q->n_bd) || (!iwl_queue_used(q, idx))) { 1030 + if ((idx >= TFD_QUEUE_SIZE_MAX) || (!iwl_queue_used(q, idx))) { 1019 1031 IWL_ERR(trans, 1020 1032 "%s: Read index for DMA queue txq id (%d), index %d is out of range [0-%d] %d %d.\n", 1021 - __func__, txq_id, idx, q->n_bd, 1033 + __func__, txq_id, idx, TFD_QUEUE_SIZE_MAX, 1022 1034 q->write_ptr, q->read_ptr); 1023 1035 return; 1024 1036 } 1025 1037 1026 - for (idx = iwl_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx; 1027 - q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { 1038 + for (idx = iwl_queue_inc_wrap(idx); q->read_ptr != idx; 1039 + q->read_ptr = iwl_queue_inc_wrap(q->read_ptr)) { 1028 1040 1029 1041 if (nfreed++ > 0) { 1030 1042 IWL_ERR(trans, "HCMD skipped: index (%d) %d %d\n", ··· 1315 1327 cmd_pos = offsetof(struct iwl_device_cmd, payload); 1316 1328 copy_size = sizeof(out_cmd->hdr); 1317 1329 for (i = 0; i < IWL_MAX_CMD_TBS_PER_TFD; i++) { 1318 - int copy = 0; 1330 + int copy; 1319 1331 1320 1332 if (!cmd->len[i]) 1321 1333 continue; 1322 1334 1323 - /* need at least IWL_HCMD_SCRATCHBUF_SIZE copied */ 1335 + /* copy everything if not nocopy/dup */ 1336 + if (!(cmd->dataflags[i] & (IWL_HCMD_DFL_NOCOPY | 1337 + IWL_HCMD_DFL_DUP))) { 1338 + copy = cmd->len[i]; 1339 + 1340 + memcpy((u8 *)out_cmd + cmd_pos, cmd->data[i], copy); 1341 + cmd_pos += copy; 1342 + copy_size += copy; 1343 + continue; 1344 + } 1345 + 1346 + /* 1347 + * Otherwise we need at least IWL_HCMD_SCRATCHBUF_SIZE copied 1348 + * in total (for the scratchbuf handling), but copy up to what 1349 + * we can fit into the payload for debug dump purposes. 1350 + */ 1351 + copy = min_t(int, TFD_MAX_PAYLOAD_SIZE - cmd_pos, cmd->len[i]); 1352 + 1353 + memcpy((u8 *)out_cmd + cmd_pos, cmd->data[i], copy); 1354 + cmd_pos += copy; 1355 + 1356 + /* However, treat copy_size the proper way, we need it below */ 1324 1357 if (copy_size < IWL_HCMD_SCRATCHBUF_SIZE) { 1325 1358 copy = IWL_HCMD_SCRATCHBUF_SIZE - copy_size; 1326 1359 1327 1360 if (copy > cmd->len[i]) 1328 1361 copy = cmd->len[i]; 1329 - } 1330 - 1331 - /* copy everything if not nocopy/dup */ 1332 - if (!(cmd->dataflags[i] & (IWL_HCMD_DFL_NOCOPY | 1333 - IWL_HCMD_DFL_DUP))) 1334 - copy = cmd->len[i]; 1335 - 1336 - if (copy) { 1337 - memcpy((u8 *)out_cmd + cmd_pos, cmd->data[i], copy); 1338 - cmd_pos += copy; 1339 1362 copy_size += copy; 1340 1363 } 1341 1364 } ··· 1362 1363 memcpy(&txq->scratchbufs[q->write_ptr], &out_cmd->hdr, scratch_size); 1363 1364 iwl_pcie_txq_build_tfd(trans, txq, 1364 1365 iwl_pcie_get_scratchbuf_dma(txq, q->write_ptr), 1365 - scratch_size, 1); 1366 + scratch_size, true); 1366 1367 1367 1368 /* map first command fragment, if any remains */ 1368 1369 if (copy_size > scratch_size) { ··· 1378 1379 } 1379 1380 1380 1381 iwl_pcie_txq_build_tfd(trans, txq, phys_addr, 1381 - copy_size - scratch_size, 0); 1382 + copy_size - scratch_size, false); 1382 1383 } 1383 1384 1384 1385 /* map the remaining (adjusted) nocopy/dup fragments */ ··· 1401 1402 goto out; 1402 1403 } 1403 1404 1404 - iwl_pcie_txq_build_tfd(trans, txq, phys_addr, cmdlen[i], 0); 1405 + iwl_pcie_txq_build_tfd(trans, txq, phys_addr, cmdlen[i], false); 1405 1406 } 1406 1407 1407 1408 out_meta->flags = cmd->flags; ··· 1444 1445 } 1445 1446 1446 1447 /* Increment and update queue's write index */ 1447 - q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); 1448 + q->write_ptr = iwl_queue_inc_wrap(q->write_ptr); 1448 1449 iwl_pcie_txq_inc_wr_ptr(trans, txq); 1449 1450 1450 1451 spin_unlock_irqrestore(&trans_pcie->reg_lock, flags); ··· 1739 1740 memcpy(&txq->scratchbufs[q->write_ptr], &dev_cmd->hdr, 1740 1741 IWL_HCMD_SCRATCHBUF_SIZE); 1741 1742 iwl_pcie_txq_build_tfd(trans, txq, tb0_phys, 1742 - IWL_HCMD_SCRATCHBUF_SIZE, 1); 1743 + IWL_HCMD_SCRATCHBUF_SIZE, true); 1743 1744 1744 1745 /* there must be data left over for TB1 or this code must be changed */ 1745 1746 BUILD_BUG_ON(sizeof(struct iwl_tx_cmd) < IWL_HCMD_SCRATCHBUF_SIZE); ··· 1749 1750 tb1_phys = dma_map_single(trans->dev, tb1_addr, tb1_len, DMA_TO_DEVICE); 1750 1751 if (unlikely(dma_mapping_error(trans->dev, tb1_phys))) 1751 1752 goto out_err; 1752 - iwl_pcie_txq_build_tfd(trans, txq, tb1_phys, tb1_len, 0); 1753 + iwl_pcie_txq_build_tfd(trans, txq, tb1_phys, tb1_len, false); 1753 1754 1754 1755 /* 1755 1756 * Set up TFD's third entry to point directly to remainder ··· 1765 1766 &txq->tfds[q->write_ptr]); 1766 1767 goto out_err; 1767 1768 } 1768 - iwl_pcie_txq_build_tfd(trans, txq, tb2_phys, tb2_len, 0); 1769 + iwl_pcie_txq_build_tfd(trans, txq, tb2_phys, tb2_len, false); 1769 1770 } 1770 1771 1771 1772 /* Set up entry for this TFD in Tx byte-count array */ ··· 1787 1788 mod_timer(&txq->stuck_timer, jiffies + trans_pcie->wd_timeout); 1788 1789 1789 1790 /* Tell device the write index *just past* this latest filled TFD */ 1790 - q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); 1791 + q->write_ptr = iwl_queue_inc_wrap(q->write_ptr); 1791 1792 if (!wait_write_ptr) 1792 1793 iwl_pcie_txq_inc_wr_ptr(trans, txq); 1793 1794