Commit Graph

145 Commits

Author SHA1 Message Date
Adrian Chadd
b168d62f00 [iwm] Recognize IWM_FW_PAGING_BLOCK_CMD wide cmd response correctly.
Obtained from:	dragonflybsd.git ef688cebb9b29b67f7a011846589971987949e0d
2017-05-12 06:35:20 +00:00
Adrian Chadd
2df3ab2828 [iwm] Revert "if_iwm - SCAN_ABORT_UMAC response doesn't use a wide id"
This reverts commit cef47a9cbb0a3ce5f18369fed9403d2764884bc2.

Obtained from:	dragonflybsd.git f62d325820ee7f7c2bcf721ada9cef8b70f74471
2017-05-12 06:34:43 +00:00
Adrian Chadd
26ce1fcd09 [iwm] Fix iwm_mvm_send_cmd_pdu(_status) declarations. Make id a uint32_t.
* This fixes cases where the group id of wide commands got lost, e.g. this
  happened to the IWM_SCAN_ABORT_UMAC command.

Obtained from:	dragonflybsd.git 71310fab0caca79bb5da43d9d642e77a4c27eea2
2017-05-12 06:33:55 +00:00
Adrian Chadd
c048736782 [iwm] Adjust if_iwm_sta.h prototypes, don't pass iwm_node to rm_sta().
* Since a RUN -> INIT/SCAN transition seems to immediately destroy the
  ieee80211_node for the AP, we can't read the in_assoc value from there.
  Instead just directly pass that information via a boolean_t argument.

* Adds iwm_mvm_rm_sta_id() function, which just unconditionally removes
  the station from the firmware.

* The iwm_mvm_rm_sta() function shouldn't actually remove the station from
  firmware when we are still associated (i.e. during a RUN -> INIT/SCAN
  transition).

 * So when disassociating we will first call iwm_mvm_rm_sta() to drain the
   queues/fifos. Later during disassociation we will then use
   iwm_mvm_rm_sta_id() to actually remove the station.

Inspired-By: Linux iwlwifi

Obtained from:	dragonflybsd.git 81b3c1fe9122fa22f33d97103039cc375f656231
2017-05-12 06:33:07 +00:00
Adrian Chadd
be793bcd46 [iwm] Make powersaving more similar to Linux iwlwifi behaviour.
* Add a per-vap ps_disabled flag, and use it for a workaround which fixes
  an association issue when powersaving is enabled.

* Compute flag that should correpsond to the mvmif->bss_conf.ps flag in
  Linux's iwlwifi (e.g. this disallows powersaving when not associated
  yet).

Inspired-By: Linux iwlwifi

Obtained from:	dragonflybsd.git dc2e69bdfe8c9d7049c8a28da0adffbfbc6de5c0
2017-05-12 06:31:57 +00:00
Adrian Chadd
a8f12a3682 [iwm] Clean up if_iwm_power.c a bit. Fix iwm_power_scheme debug print.
Obtained from:	dragonflybsd.git 52c3adbee676d8558065618e5ad694ea5c6697e0
2017-05-12 06:30:50 +00:00
Adrian Chadd
48452813cb [iwm] Switch arguments from iwm_node* to iwm_vap* in if_iwm_power.c.
* Power management handling is per-vap, not per-node, so we should pass
  the iwm_vap in these arguments.

Obtained from:	dragonflybsd.git 62a4e7957a736b4de38938b02fa7eb9b45bc5d0d
2017-05-12 06:30:06 +00:00
Adrian Chadd
f1bd8a14fa [iwm] Already call iwm_mvm_power_update_mac() during SCAN<->AUTH paths.
* Otherwise we would never update powersaving settings until we complete
  an association, after the first authentication attempt.

* This corresponds to what Linux iwlwifi seems to do.

Obtained from:	dragonflybsd.git aa128dc02a17c2e616232ef0fa997121e969c995
2017-05-12 06:21:03 +00:00
Adrian Chadd
f7be9693b2 [iwm] Refuse connection to APs with beacon interval < 16.
Obtained from:	dragonflybsd.git aba448de727e9b122adadeb36fd00a8ad6018d4f
2017-05-12 06:16:11 +00:00
Adrian Chadd
00f22ee771 [iwm] Handle AUTH->SCAN/INIT and ASSOC->SCAN/INIT better
* Tear down the relevant firmware state (i.e. the station, the vif binding)
  in these transition cases.

* Before this case would leave the firmware state lying around, resulting
  in errors and firmware panics in the subsequent association attempts.

Obtained from:	dragonflybsd.git 94b501399fde6368ae388a669c95b099a6e66e93
2017-05-12 06:05:34 +00:00
Adrian Chadd
f48f696087 [iwm] Factor out firmware station handling into if_iwm_sta.c.
* This adds iwm_mvm_rm_sta(), which will be used to tear down firmware
  state for better/cleaner iwm_newstate() handling.

* Makes iwm_enable_txq() and iwm_mvm_flush_tx_path() non-static, add
  the declarations to if_iwm_util.h for now.

Obtained from:	dragonflybsd.git 85d1c6190c4c3564b1a347f253e823aa95c202b2
2017-05-12 06:03:23 +00:00
Adrian Chadd
16604ae07c [iwm] Deduplicate code in iwm_auth() from an if condition.
Obtained from:	dragonflybsd.git 03c6e6970115727c9d39f9358e0500ab4f4634cd
2017-05-12 05:53:28 +00:00
Adrian Chadd
f7f5c0102c [iwm] No need for iwm_assoc() in AUTH->ASSOC transition.
* Hence no need to keep stuff in separate iwm_assoc() function, just
  inline the stuff into iwm_newstate().

Obtained from:	dragonflybsd.git e8f7d88e0d030f138f95ecdb7c1a729d9fb0d6ab
2017-05-12 05:51:50 +00:00
Adrian Chadd
b80e7ca55b [iwm] Properly implement iwm_wme_update callback function.
* Inspired by iwn(4) and Linux iwlwifi.

* Read wme parameters into a buffer within struct iwm_vap in
  iwm_wme_update().

* If we aren't associated yet, the new settings will soon be sent
  by iwm_mvm_mac_ctxt_changed() during association.

* If we are already associated, explicitly call iwm_mvm_mac_ctxt_changed()
  from iwm_wme_update() to send the new settings to the firmware.

* Change iwm_mvm_ac_to_tx_fifo mapping, to fit the freebsd net80211
  WME stream class numbering, instead of Linux's enum ieee80211_ac_numbers.

Obtained from:	dragonflybsd.git b8bd6cd746d1f45e616ccfcbeed06dfe452a1108
2017-05-12 05:50:38 +00:00
Adrian Chadd
702287e43a [iwm] Process multiple frames per RX buffer.
* Factor out iwm_handle_rxb() function from iwm_notif_intr().

* Removing the IWM_FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK flag allows
  the device to put multiple frames (both command responses and 80211
  frames) into a single RX buffer.

* Uses m_copym() to split up the receive buffers when multiple 80211
  frames are received in one RX buffer. The effect is basically the same
  as when using m_split(), but we want to keep the original mbuf around
  when calling iwm_mvm_rx_rx_mpdu() to make error handling a bit easier
  for now.

* Contains a small optimization to avoid the m_copym() when only a single
  80211 frame is received in one RX buffer (i.e. matching the existing
  behaviour).

Obtained from:	dragonflybsd.git b5eb43f0280bbcfd26af51cf5a4b8e8ff3590b67
2017-05-12 05:49:24 +00:00
Adrian Chadd
5f39493aa4 [iwm] Change UCODE_TLV_API #define-s from bitmasks to indexes.
* Fixes oversight from commit 757eecf0e6c92745aa2eee95811e573c8300850e.
  fw_has_api now uses the isset macro instead of a simple logical-and.

Obtained from:	dragonflybsd.git c00575de8491dc402abf52c8c7e1cca1ef79e257
2017-05-12 05:30:01 +00:00
Adrian Chadd
a88f1dbf42 [iwm] Sync iwm_read_firmware()'s loop to iwlwifi's code.
Obtained from:	dragonflybsd.git d1c10ccfcf2d6d2a664f17197add0b4f93333181
2017-05-12 05:28:49 +00:00
Adrian Chadd
b72d4b835b [iwm] change the check for ADD_STA status, use IWM_ADD_STA_STATUS_MASK.
Obtained from:	dragonflybsd.git 74d41163ddac72b0d7ea7b7873d53fe134723a12
2017-05-12 05:22:29 +00:00
Adrian Chadd
5d2fcafc23 [iwm] Sanity check channel for IEEE80211_CHAN_ANYC in if_iwm_mac_ctxt.c.
* This avoids panicing in some broken vap state handling cases.

Obtained from:	dragonflybsd.git 10d5b77b5421e7cbcc426160edbe858d1d610a29
2017-05-12 05:21:50 +00:00
Adrian Chadd
2863c11c8f [if_iwm] Get rid of another usage of the IWM_DEFAULT_MACID/_COLOR constant.
Obtained from:	dragonflybsd.git c009badecf7b1389cd86adde9fd35f6113c75b5b
2017-05-12 05:21:02 +00:00
Adrian Chadd
bdba683047 [if_iwm] Partly sync if_iwm_binding.c to Linux iwlwifi code.
* Store macid and color values in struct iwm_vap, to avoid hardcoded
  constants a bit.

* Add iwm_mvm_binding_remove_vif() function (will be used in disconnecting
  from an access point without resetting the whole device).

* Not adding code from Linux iwlwifi yet, to handle one PHY context to
  be bound to several VAPs/virtual-interfaces, it's definitely not needed
  in the near future.

Obtained from:	dragonflybsd.git f16ef74977e51e1bfc7a625dd18b98b02158e0e5
2017-05-12 05:19:08 +00:00
Adrian Chadd
f32adafde1 [iwm] Move in_phyctxt from struct iwm_node to phy_ctxt in struct iwm_vap.
* This better matches how things are organized in Linux's iwlwifi.

Obtained from:	dragonflybsd.git 0cf16dd2e0e09a3e5140e50222ac2e69bcdb19a2
2017-05-09 05:32:35 +00:00
Adrian Chadd
c44c4d8d92 [iwm] Allow listening on both chains/atennas to get diversity.
This might improve throughput slightly when far from the accesspoint,
apparently by allowing the firmware to listen on either of the two
antennas (if there are two, i.e. on 7260/7265/8260), whichever has
a better reception.

Obtained from:	dragonflybsd.git 3b7fc5aac51f81062da0a2c8fdac23e683fbd548
2017-05-09 05:31:38 +00:00
Adrian Chadd
08e1076cf6 [iwm] Add basic powermanagement support via ifconfig wlan0 powersave.
* The DEVICE_POWER_FLAGS_CAM_MSK flag was removed in the upstream iwlwifi
  in Linux commit ceef91c89480dd18bb3ac51e91280a233d0ca41f.

* Add sc_ps_disabled flag to struct iwm_softc, which corresponds to
  mvm->ps_disabled in struct iwl_mvm in Linux iwlwifi.

* Adds a hw.iwm.power_scheme tunable which corresponds to the power_scheme
  module parameter in Linux iwlwifi. Set this to 1 for completely
  disabling power management, 2 (default) for balanced powermanagement,
  and 3 for lowerpower mode (which does dtim period skipping).

* Imports the constants.h file from iwlwifi as if_iwm_constants.h.

* This doesn't allow changing the powermanagement setting while connected,
  also one can only choose between enabled and disabled powersaving with
  ifconfig (so switching between balanced and low-power mode requires
  rebooting to change the tunable).

* After any changes to powermanagement (i.e. "ifconfig wlan0 powersave" to
  enable powermanagement, or "ifconfig wlan0 -powersave" for disabling
  powermanagement), one has to disconnect and reconnect to the accespoint
  for the change to take effect.

Obtained from:	dragonflybsd.git d7002a7990d077c92585978ea998474af50f91e0
2017-05-09 04:15:07 +00:00
Adrian Chadd
522f6fe474 [iwm] Add iwm_nic_unlock() calls missing from previous commit.
Obtained from:	dragonflybsd.git f88ab372284e63c4c13da93e9026a203b9b4cdc5
2017-05-09 02:42:53 +00:00
Adrian Chadd
ab492a5732 [iwm] iwm_{read,write}_prph() don't grab the nic lock in iwm themselves.
* Fix a couple of cases where the nic lock ended up not being grabbed
  during an iwm_read_prph() or iwm_write_prph().

Obtained from:	dragonflybsd.git 6c5470f2db219c61e362c981fea969d97e1b8293
2017-05-09 02:41:33 +00:00
Adrian Chadd
616201d1f7 [iwm] include opt_iwm.h and opt_wlan.h consistently in all files. 2017-05-09 02:38:23 +00:00
Andriy Voskoboinyk
7beeab43a1 iwm: fix build without IWM_DEBUG.
Reported by:	O. Hartmann <ohartmann@walstatt.org>
Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D10146
2017-03-27 07:02:27 +00:00
Adrian Chadd
6c3c52590e [iwm] Add the BSS's basic rates to iwm's LQ command, not all the rates.
Makes the firmware use appropriate Tx rates for ACKs.

Obtained from: dragonflybsd.git ab1d3efc208e797c1e09759cd506c95c0aeaa06e
2017-03-25 02:55:13 +00:00
Adrian Chadd
cd20383e4a [iwm] Enable Energy Based Scan (EBS).
This can significantly reduce scan duration thus saving time and power.
EBS failure reported by FW disables EBS for current connection. It is
re-enabled upon new connection attempt on any WLAN interface.

Obtained from:	dragonflybsd.git 89f579e9823a5c446ca172cf82bbc210d6a054a4
2017-03-25 02:49:20 +00:00
Adrian Chadd
5f00681c7d [iwm] GC unused code from if_iwm_scan.c, copyied from iwn or iwlwifi/dvm.
Obtained from:	dragonflybsd.git 10881df269b93c26e5ee6af629c36db5672e6e52
2017-03-25 02:44:25 +00:00
Adrian Chadd
8d3bbea007 [iwm] Tiny cleanup in iwm_rx_addbuf().
Obtained from:	dragonflybsd.git 3370bc5504ebb3c1b9bb960a185cd0c8052a2845
2017-03-25 02:42:52 +00:00
Adrian Chadd
a00bfbb19d [iwm] Make ucode capabilities and api flags handling more like iwlwifi.
Obtained from:	dragonflybsd.git 757eecf0e6c92745aa2eee95811e573c8300850e
2017-03-23 04:50:38 +00:00
Adrian Chadd
d045c744f1 [iwm] Remove a couple of unneeded IWM_UCODE_TLV_FLAGS_* flags.
* All the supported firmwares have these flags set.

* This removes the following flags:
  IWM_UCODE_TLV_FLAGS_PM_CMD_SUPPORT,
  IWM_UCODE_TLV_FLAGS_NEWBT_COEX,
  IWM_UCODE_TLV_FLAGS_BF_UPDATED,
  IWM_UCODE_TLV_FLAGS_D3_CONTINUITY_API,
  IWM_UCODE_TLV_FLAGS_STA_KEY_CMD,
  IWM_UCODE_TLV_FLAGS_DEVICE_PS_CMD,
  IWM_UCODE_TLV_FLAGS_SCHED_SCAN,
  IWM_UCODE_TLV_FLAGS_RX_ENERGY_API,
  IWM_UCODE_TLV_FLAGS_TIME_EVENT_API_V2

* Also remove definitions and code for dealing with the v1 time-event api.

* Remove unneeded calc_rssi() function.

Obtained from:	dragonflybsd.git d078c812418d0e2c3392e99fa25fc776d07bdfad
2017-03-23 04:43:04 +00:00
Adrian Chadd
51c2814518 [iwm] Move mbuf hacks after sanity checks in iwm_mvm_rx_rx_mpdu().
* This avoids leaving the mbuf in a weird state, when dropping a packet.

Obtained from:	dragonflybsd.git 96eaecf93d9f731459a0df8efc72cfad034320bd
2017-03-23 04:34:25 +00:00
Adrian Chadd
6d218ca4c9 [iwm] Get rid of struct iwm_rx_data argument for iwm_mvm_rx_rx_mpdu.
Obtained from:	dragonflybsd.git b5cdd8067951dc90271ab104ef555b3b5a4d5d5a
2017-03-23 04:33:15 +00:00
Andriy Voskoboinyk
f631357540 net80211 drivers: fix rate setup for EAPOL frames, obtain Tx parameters
directly from the node.

- Use ni_txparms directly instead of calculating them manually every time
- Move M_EAPOL flag check upper; otherwise it may be skipped due to
'ucastrate' / 'mcastrate' check
- Use 'mgtrate' for control frames too (see ifconfig(8), mgtrate parameter)
- Add few more M_EAPOL checks where it was missing (zyd(4), ural(4),
urtw(4))
- Few unrelated cleanups

Tested with:
 - Intel 6205 (iwn(4)), STA mode;
 - WUSB54GC (rum(4)), HOSTAP mode + RTL8188EU (rtwn(4)), STA mode.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D9811
2017-02-26 20:49:35 +00:00
Adrian Chadd
9c8efa1dfb [iwm] add if_iwm_fw.c. 2017-02-24 15:17:43 +00:00
Adrian Chadd
ad35d47138 [iwm] Add support for Firmware paging, needed for newer 8000C firmware.
* Uses the IWM_FW_PAGING_BLOCK_CMD firmware command to tell the firmware
  what memory ranges to use for paging.

Obtained from:	dragonflybsd.git 8a5b199964f8e7bdb00039f0b48817a01b402f18
2017-02-24 07:07:58 +00:00
Adrian Chadd
b28a6ab3bd [iwm] Move iwm_dma_contig_alloc/_free functions to if_iwm_util.c.
Obtained from:	dragonflybsd.git 83a1185edeede081051a6c00417d4c5a8f5988eb
2017-02-22 05:11:24 +00:00
Adrian Chadd
2fd963796d [iwm] Switch 7265D and 3165 devices to 7265D firmware.
Obtained from:	dragonflybsd.git 0cb0a810cb4e04b30937cb4260e779f717a86492
2017-02-22 04:53:33 +00:00
Adrian Chadd
6c2c3bd86d [iwm] Move struct iwm_cfg chipset configs to if_iwm_7000.c and _8000.c
* This is more similar to how code/definitions are distributed in
  Linux's iwlwifi.

* This should make recognizing new chipset variants, and adding additional
  flags from the Linux iwlwifi code easier, without blowing up if_iwm.c

Obtained from:	dragonflybsd.git 27d11320e707d2c41424efc1983762f6799941d6
2017-02-22 04:35:53 +00:00
Adrian Chadd
10e7a12c26 [iwm] Simplify device id matching code a bit.
* Just add the struct iwm_cfg pointers to the iwm_devices array, to get
  rid of the large switch clause.

Obtained from:	dragonflybsd.git 35f0e6c86c1654323d6b19f7a077f4ab8ac85868
2017-02-22 04:28:10 +00:00
Adrian Chadd
e5beb03bc6 [iwm] Remove OpenBSD-specific comment. Beautify pci cfg space accesses.
Obtained from:	dragonflybsd.git 710fdd011c30a1bd9f53b87c843fb8907c4a6cfd
2017-02-22 04:27:07 +00:00
Adrian Chadd
0a68d61092 [iwm] Fix typo in commit a7697ea01c11fd493aec52260a02f31df680eb91.
* The sc->sc_uc.uc_error_event_table value is now at sc->error_event_table,
  and not sc->umac_error_event_table.

Obtained from:	dragonflybsd.git 612855b1a8c321ec9ba34f63edf913e7ecff8363
2017-02-22 02:51:30 +00:00
Adrian Chadd
dfdbaed494 [iwm] Get rid of unneeded IWM_FWDMASEGSZ and IWM_FWMAXSIZE constants
* We only need IWM_FH_MEM_TB_MAX_LENGTH bytes for the fw_dma memory.

Obtained from:	dragonflybsd.git f414b8da30816705e32573cc58097cacac34f161
2017-02-22 02:49:57 +00:00
Adrian Chadd
dae82c37b0 [iwm] With the previous commits, this DELAY no longer seems to be needed.
Obtained from:	dragonflybsd.git 516272d3d02c821ace16a91cfdeb28540ac74ecc
2017-02-22 02:24:42 +00:00
Adrian Chadd
9df5244309 [iwm] Sync IWM_MVM_ALIVE waiting and start_fw handling with iwlwifi.
* Use the notification wait API, like it's done in the Linux iwlwifi code,
  to wait for the IWM_MVM_ALIVE notification.

* This also should fix some firmware load interrupt issues, and errors
  in the nic lock using.

Tested:

* (adrian) Intel 7260, STA mode

Obtained from:	dragonflybsd.git a7697ea01c11fd493aec52260a02f31df680eb91
2017-02-22 02:23:14 +00:00
Adrian Chadd
e97a1048d1 [iwm] Synchronize firmware loading code with Linux iwlwifi.
* While there, rename some functions to match the names and functionality
  of the similarly named functions in Linux iwlwifi.

Obtained from:	dragonflybsd.git e98ee77a816bfd8b4912047b93dfb2c560788f24
2017-02-22 02:18:04 +00:00
Adrian Chadd
20724b17b4 [iwm] Remove 1s delay after fw loading. Can't reproduce issues on AC8260.
The 1s delay was added in the update to version 16 fw, where Family 8000
support was added.

Obtained from:	DragonflyBSD commit bb480ca679a7ea530bdca6e41082d5755e9751dc
2017-02-08 07:09:10 +00:00