Commit Graph

41 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
99baf303e7 [iwm] Implement apmg_wake_up_wa workaround properly for 7000 family.
* Add iwm_pcie_set_cmd_in_flight() and iwm_pcie_clear_cmd_in_flight()
  helper methods.

* Use ring->queued tracking in the command queue to set/clear the
  cmd_hold_nic_awake bit at the right points.

Taken-From: Linux iwlwifi

Obtained from:	DragonflyBSD commit ce43f57f5308b579ea21e8a5a29969114ba2247d
2017-02-08 06:53:23 +00:00
Adrian Chadd
82ba706cba [iwm] Use iwm_mvm_scan_stop_wait to properly abort scans.
* Add IWM_FLAG_SCAN_RUNNING to sc->sc_flags to track whether the firmware
  is currently running a scan, in order to decide wheter iwm_scan_end
  needs to abort a running scan.

* In iwm_scan_end, if the scan is still running, we now abort it, in order
  to keep the firmware scanning state in sync.

* Try to make things a bit simpler, by reacting on the
  IWM_SCAN_OFFLOAD_COMPLETE and IWM_SCAN_COMPLETE_UMAC notifications,
  instead of IWM_SCAN_ITERATION_COMPLETE and
  IWM_SCAN_ITERATION_COMPLETE_UMAC. This should be fine since we always
  only tell the firmware to do a single scan iteration anyway.

Obtained from:	DragonflyBSD commit 1f249c981c4e89e7cde1836a75b61cac36dc7ac5
2017-02-08 06:50:59 +00:00
Adrian Chadd
31f7edff40 [iwm] Use notification wait API to wait for calibration to complete.
Tested:

* 7260, STA mode (2g, 5g)

Obtained from:	DragonflyBSD commit 1e0cf8ec6fcd77978f5336297ece61a415790f84
2017-02-06 05:35:11 +00:00
Adrian Chadd
6e39c65025 [iwm] Add implementation of the notification wait api from iwlwifi.
Obtained from:	Linux iwlwifi
Obtained from:	DragonflyBSD commit 94dc1dadceb57b688036211262d678bc6bbdde37
2017-02-06 05:27:07 +00:00
Adrian Chadd
48f3dc7b64 [iwm] Store paging_mem_size field in firmware image information struct.
Obtained from:	DragonflyBSD commit a8524cc6c440e5ce9490ba2b0507c99ff6777c6d
2017-02-06 05:08:21 +00:00
Adrian Chadd
e89710f85f [iwm] Get rid of some gratuitous constant renaming wrt. Linux iwlwifi.
* IWM_UCODE_SECT_MAX -> IWM_UCODE_SECTION_MAX

* IWM_UCODE_TYPE_* -> IWM_UCODE_* (except for IWM_UCODE_TYPE_MAX which
  stays).

Obtained from:	DragonflyBSD commit ff4d1fc3ed002c9fb362423da6c45d711b65658a
2017-02-06 05:07:15 +00:00
Adrian Chadd
2a2476b30b [iwm] Sync valid_tx_ant and valid_rx_ant mask handling with iwlwifi.
* This fixes the phy_cfg field sent in the iwm_send_phy_cfg_cmd()
  command, which wasn't taking into account the valid_rx_ant and
  valid_tx_ant masks from nvm_data before.

Tested:

* 7260, STA mode, 2G and 5G

Obtained from:	DragonflyBSD commit cbb82693c18fd71b4eb86855b82d03995f352d65
2017-02-06 05:03:41 +00:00
Adrian Chadd
8c03b09087 [iwm] Use chipset configuration structs like iwlwifi does.
* This makes it a bit easier to factor out common parts for e.g. the
  7000 chipset family.

* Add iwm7265d config, and recognize the 7265D chipset variant via the
  hardware revision.

Tested:

* 7260, STA mode (2ghz)

Obtained from:	Dragonflybsd commit cc8d6ccf5583fd45964f3bde9b057ee4f834c0e0
2017-02-06 03:29:50 +00:00
Adrian Chadd
6349bdb30d [iwm] Sync nvm parsing code with Linux iwlwifi.
* sc->sc_nvm becomes sc->nvm_data and is now a pointer instead of an
  inlined struct.

* Add sc->eeprom_size and sc->nvm_hw_section_num configuration values to
  struct iwm_softc.

* For now continue to avoid negative error return-values, and use pointer
  variables for some return values, as before.

* Continue to omit LAR (location aware regulatory) related code as well.

Tested:

* Intel 7260, STA mode (2GHz)

Obtained from:	dragonflybsd commit 39f8331b1a6f295291e08c377da12a8e7a5436c0
2017-02-06 03:06:11 +00:00
Adrian Chadd
59e6427fbf [iwm] make sure we call iwm_detach_local() only once.
Obtained from:	DragonflyBSD git ebd4ceab76a6f161362029cbfd08efaedaab0519
2017-02-06 02:20:05 +00:00
Adrian Chadd
30a0fd92c9 [iwm] Sync if_iwm_phy_db code with Linux iwlwifi.
Obtained from:	Dragonflybsd commit c1019b6bfff36c856f7b4fccbdf3bb13ac27750c
2017-02-06 02:14:34 +00:00
Adrian Chadd
a994fb3be1 [iwm] The HW Revision stepping constants should be in if_iwmreg.h.
Obtained from:	dragonflybsd 84292f0c38594c462c719c0e59da5908b93aba5f
2017-02-06 02:01:22 +00:00
Andriy Voskoboinyk
f6930bec33 net80211: ieee80211_ratectl*: switch to reusable KPI
Replace various void * / int argument combinations with common structures:
- ieee80211_ratectl_tx_status for *_tx_complete();
- ieee80211_ratectl_tx_stats for *_tx_update();

While here, improve amrr_tx_update() for a bit:
1. In case, if receiver is not known (typical for Ralink USB drivers),
refresh Tx rate for all nodes on the interface.
2. There was a misuse:
- otus(4) sends non-decreasing counters (as originally intended);
- but ural(4), rum(4) and run(4) are using 'read & clear' registers
to obtain statistics for some period of time (and those 'last period'
values are used as arguments for tx_update()). If arguments are not big
enough, they are just discarded after the next call.

Fix: move counting into *_tx_update()
(now otus(4) will zero out all node counters after every tx_update() call)

Tested with:
- Intel 3945BG (wpi(4)), STA mode.
- WUSB54GC (rum(4)), STA / HOSTAP mode.
- RTL8188EU (urtwn(4)), STA mode.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D8037
2016-10-02 20:35:55 +00:00
Imre Vadász
e4dc86e060 [iwm] Remove dead fw_totlen from struct iwm_fw_sects; clean up struct iwm_nvm_data.
* No functional change, none of these values were ever read.

* The values removed from struct iwm_nvm_data are only used for old dvm
  devices in Linux iwlwifi, and irrelevant to iwm hence.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7945
2016-09-19 22:26:37 +00:00
Imre Vadász
ef81578c9f [iwm] Remove unused field from iwm_rx_data. Use uint32_t instead of enum type.
The wantresp field in struct iwm_rx_data has never been used for anything,
so we can just delete it.

Apparently struct iwm_sf_cfg_cmd was compiled correctly (using a 32bit
value to represent the enum), but it still seems like a very bad idea to use
an enum type in a __packed struct.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7930
2016-09-19 22:08:47 +00:00
Sean Bruno
6a5bc1d1ee iwm(4) synchronize driver to DragonFlyBSD version and recent f/w update.
Submitted by:	Kevin Bowling (kevin.bowling@kev009.com)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D6967
2016-07-26 00:02:17 +00:00
Sean Bruno
33c7715f9b iwm(4): switch to ieee80211_runtask()
Submitted by:	Andiry Voskoboinyk (s3erios@gmail.com)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D5054
2016-07-25 23:44:44 +00:00
Adrian Chadd
5799c2bce7 [iwm] Fix up busdma use in the RX path
When allocating a new mbuf or bus_dmamap_load()-ing it fails,
we can just keep the old mbuf since we are dropping that packet anyway.
Instead of doing bus_dmamap_create() and bus_dmamap_destroy() all the time,
create an extra bus_dmamap_t which we can use to safely try
bus_dmamap_load()-ing the new mbuf. On success we just swap the spare
bus_dmamap_t with the data->map of that ring entry.

Tested:

Tested with Intel AC7260, verified with vmstat -m that new kernel no
longer visibly leaks memory from the M_DEVBUF malloc type.
Before, leakage was 1KB every few seconds while ping(8)-ing over the wlan
connection.

Submitted by:	Imre Vadasz <imre@vdsz.com>
Approved by:	re@
Obtained from:	DragonflyBSD.git cc440b26818b5dfdd9af504d71c1b0e6522b53ef
Differential Revision:	https://reviews.freebsd.org/D6742
2016-06-13 00:13:20 +00:00
Adrian Chadd
ee55925e29 [iwm] add LED blinking for iwm hardware that supports it.
Submitted by:	Imre Vadasz <imre@vdsz.com>
Obtained from:	DragonflyBSD, Linux iwlwifi/mvm
2016-06-02 04:42:28 +00:00
Adrian Chadd
63b3f62ab3 [iwm] remove dead code.
if_iwm - GC some dead code, left by a partially applied OpenBSD change.

Taken-From: OpenBSD (if_iwm.c r1.69)

Submitted by:	Imre Vadasz <imre@vdsz.com>
Obtained from:	DragonflyBSD git 07dfed32ea39b980b0b80d27ff938e7c3ca4c0b5
2016-05-27 07:10:11 +00:00
Pedro F. Giffuni
453130d9bf sys/dev: minor spelling fixes.
Most affect comments, very few have user-visible effects.
2016-05-03 03:41:25 +00:00
Andriy Voskoboinyk
5c1f6e21a5 iwm: switch to ieee80211_add_channel()
- Switch to ieee80211_add_channel().
- Parse/set more channel flags (DFS, NOADHOC).
- Add ic_getradiocaps() method.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D6150
2016-05-01 14:27:27 +00:00
Adrian Chadd
125b570110 [iwm] implement suspend/resume through ieee80211_{suspend,resume}_all
This allows wifi to associate correctly after a suspend/resume cycle.

Yes, I'm using this now day to day.

Tested:

* Intel 7260AC, STA mode
2016-04-26 04:40:59 +00:00
Andriy Voskoboinyk
1b3ae3ba63 iwm: store pointer for 'struct firmware' instead of
'size_t' and 'void *' pair.

Approved by:	adrian (mentor)
Obtained from:	DragonFlyBSD
Differential Revision:	https://reviews.freebsd.org/D4765
2016-01-04 21:03:01 +00:00
Andriy Voskoboinyk
612d1816a8 iwm: reorganize if_iwmvar.h
- Change order of data in if_iwmvar.h
(like it is in other drivers: defines, data structures,
vap/node structures, softc struct and locks); use indentation.
- Fix IWM_LOCK(_sc) / IWM_UNLOCK(_sc) macro.
- Add IWM_LOCK_INIT / DESTROY(sc) + fix mtx_init() usage.
- Wrap iwm_node casts into IWM_NODE() macro.
- Drop some fields:
 * wt_hwqueue from Tx radiotap header;
 * macaddr[6] from iwm_vap;

Approved by:	adrian
Differential Revision:	https://reviews.freebsd.org/D4753
2016-01-03 10:06:10 +00:00
Adrian Chadd
4f4a7a03ce net80211 drivers: eliminate any references to sc_rxtap_len/sc_txtap_len (never used here)
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3776
2015-10-12 05:21:51 +00:00
Gleb Smirnoff
7a79cebfba Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.

Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.

Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:

- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
  the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
  driver about any changes: number of wlan(4) interfaces, number of them
  in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
  driver experiences errors and can not attribute them to any specific
  interface, driver updates ic_oerrors or ic_ierrors counters.

Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
  now provided by net.wlan.devices sysctl.

Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.

Reviewed by:	adrian
Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2015-08-27 08:56:39 +00:00
Rui Paulo
d4886179cb Import OpenBSD's iwm WiFi driver for Intel 3160/7260/7265.
There are still several bugs, but I've been using it for a while now.
Thanks to all the testers and to Adrian for his help with this
driver.

This driver isn't connected to the build yet, but it will be soon.

There's no MFC planned because the driver isn't very stable yet.

Reviewed by:	adrian
Obtained from:	https://github.com/rpaulo/iwm
Tested by:	adrian, gjb, dumbbell (others that I forgot).
Relnotes:	yes
2015-08-08 06:06:48 +00:00