Commit Graph

177 Commits

Author SHA1 Message Date
Hans Petter Selasky
b65f813c1a Widen EPOCH(9) usage in PCI WLAN drivers.
Make sure all occurrences of ieee80211_input_xxx() in sys/dev are
covered by a network epoch section. Do not depend on the interrupt
handler nor any taskqueues being in a network epoch section.

This patch should unbreak the PCI WLAN drivers after r357004.

Pointy hat:	glebius@
Sponsored by:	Mellanox Technologies
2020-01-30 10:28:01 +00:00
Mark Johnston
e7065dd1e8 iwm(4): Remove _mvm from the namespace.
This was inherited from iwlwifi, which drives devices supported by both
iwn(4) and iwm(4) in FreeBSD.  In iwm(4) _mvm is meaningless, so remove
it.  OpenBSD made the same change a long time ago.  No functional change
intended.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-27 20:32:53 +00:00
Mark Johnston
86ea3e8bb1 iwm(4): Fix version string formatting.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-27 20:32:31 +00:00
Mark Johnston
1903c60041 iwm: Sync device initialization and reset code with iwlwifi.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-07 23:39:17 +00:00
Mark Johnston
c513f15bf0 iwm: Use the default station for all transmits.
This is what iwlwifi seems to do, and the previous behaviour triggered
firmware panics during transmit on a 9560.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-07 23:38:49 +00:00
Mark Johnston
d2c7b21a56 iwm: Set flag for pad bytes in offload_assist.
Though we don't otherwise use firmware's offload capabilities, we need
to set this flag when the MAC header's size isn't a multiple of four.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-07 23:38:36 +00:00
Mark Johnston
49c76634fb iwm: Use antenna B for TX on 9000-series chips.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-07 23:38:17 +00:00
Mark Johnston
c3bfecf3df iwm: Sync with iwm_run_init_mvm_ucode() with iwlwifi.
Do not configure bluetooth on newer chips, it causes firmware panics.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-07 23:37:30 +00:00
Mark Johnston
1f0976dc58 iwm: Fix scheduler configuration for aux and cmd queue configuration.
- Configure the scheduler only for the management queue.
- Fix a bug when enabling the schduler: the queues are specified using a
  bitmask.
- Fix style in the area.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-07 23:37:17 +00:00
Mark Johnston
96c5aa2f4b iwm: Implement the new receive path.
This is the multiqueue receive code required for 9000-series chips.
Note that we still only configure a single RX queue for now.  Multiqueue
support will require MSI-X configuration and a scheme for managing a
global pool of RX buffers.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-07 23:37:02 +00:00
Mark Johnston
2ca43dacca iwm: Enable all 31 tx queues.
For now iwm only ever uses queue 0 and the management queue, but my 9560
raises a software error interrupt during initialization if this flag is
not set.  iwlwifi sets it for all 7000- and 8000-series hardware, so we
might as well do it unconditionally.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-07 23:36:46 +00:00
Mark Johnston
5b3b7a2df1 iwm: Add device configuration definitions for 9000-series chips.
Match such chips using the device ID.  We should really be checking the
subdevice as well, since a smaller number of 9460 and 9560 devices
actually belong to a new series of devices and require different
firmware, but that will require some extra logic in iwm_attach().

Submitted by:	lwhsu, Guo Wen Jun <blockk2000@gmail.com>
MFC after:	2 weeks
2019-11-07 23:35:54 +00:00
Mark Johnston
d2ec5b521b iwm: Sync the firmware tx_cmd descriptor fields with iwlwifi.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-07 23:35:29 +00:00
Mark Johnston
be05a0fd77 iwm: Use the same delays as iwlwifi when resetting the device.
This is required for initialization to succeed for newer device
families.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-07 23:35:15 +00:00
Mark Johnston
3bf2d5dd64 iwm: Add a device family definition for 9000 chips.
Convert existing device family checks to avoid assuming that the device
family is always one of IWM_DEVICE_FAMILY_7000 or _8000.

Submitted by:	lwhsu, Guo Wen Jun <blockk2000@gmail.com>
MFC after:	2 weeks
2019-11-07 23:35:01 +00:00
Mark Johnston
267c626f0d iwm: Define a name for TLV 48.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-07 23:33:58 +00:00
Mark Johnston
b41c219912 iwm: Avoid calling iwm_start() each time a descriptor is reclaimed.
Only perform the call when a qfull bit transitions.  While here, avoid
assignments in declarations in iwm_mvm_rx_tx_cmd().

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-07 23:29:57 +00:00
Mark Johnston
3cc50d22fd iwm: Call iwm_dev_check() earlier in iwm_attach().
This ensures that the driver softc reflects device capabilities as early
as possible, for use by device initialization code that is conditional
on certain capabilities.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-07 23:29:43 +00:00
Mark Johnston
eff8a9793e iwm: Simplify fw_has_{api,capa}().
No functional change intended.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-07 23:29:25 +00:00
Mark Johnston
113875bd68 iwm: Fix style in the TX path.
Also ensure that the htole* macros are applied correctly when specifying
the segment length and upper address bits.  No functional change
intended (unless you use iwm(4) on a big-endian machine).

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-11-07 23:27:54 +00:00
Mark Johnston
dda0c86204 iwm: Drain callouts after stopping the device during detach.
Otherwise there is a window where they may be rescheduled.  This
typically manifested as a page fault shortly after unloading if_iwm.ko.
Close the race by draining callouts after calling iwm_stop_device(),
which is also what Dragonfly does.

Change whitespace to reduce gratuitous diffs with Dragonfly.

Reported and tested by:	seanc
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2019-07-03 21:05:40 +00:00
Andriy Voskoboinyk
589526906c iwm(4): use correct channel list source for Intel 3168
Intel 3168 uses another EEPROM section to store channel flags;
port missing bits from iwlwifi to make it work.

PR:		230750, 236235
Tested by:	Bert JW Regeer <xistence@0x58.com>
MFC after:	3 days
2019-03-11 08:30:29 +00:00
Bjoern A. Zeeb
b294eac56b Fix logic errors in iwm_pcie_load_firmware_chunk introduced in r314065.
* There's no reason to have a while() loop here, because:
    - if msleep returns 0, that means we were woken up by the interrupt handler,
      and we are going to exit immediately as sc_fw_chunk_done will now be 1
      (there is nothing else that sleeps on sc_fw.)
    - if msleep doesn't return 0 (i.e. it returned ETIMEDOUT) then we will
      exit immediately because of the if-test.
   So, just use a single msleep() and then check sc_fw_chunk_done as before.
 * The comment said we were sleeping for 5 seconds, but the msleep was only
   for 1. Before r314065, this was 1 second and so was the comment,
   and in that commit the comment was changed and the function call wasn't.

Possibly fixes failures to initialize uCode on certain devices.

Submitted by:	Augustin Cavalier (waddlesplash gmail.com)
Obtained from:	Haiku 132990ecdcb072f2ce597b5d497ff3e5b1f09c20
MFC after:	10 days
2019-01-26 17:52:12 +00:00
Kyle Evans
e4bc6d1d19 iwm - Update alive response handling, add v4 and remove old versions.
Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (3820e2bf3331ced3541d1811a38c5a5136dfab93)
2019-01-24 03:49:35 +00:00
Kyle Evans
569556b633 iwm - Fix race during detach, where a callout is left after driver is gone.
Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (ba3b4ff9a1fc04a349df05d6d3449f4d9b15c4be)
2019-01-24 03:49:11 +00:00
Kyle Evans
93ff2218dd if_iwm - Stop iwm_watchdog callout when idle.
Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (6a8683b0e9d734f23bd9647e117da198c2b9a74e)
2019-01-24 03:48:50 +00:00
Kyle Evans
d3c83cfead iwm - Always clear watchdog timer, when bringing down firmware state.
Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (8abdc2b36a45c4e9c95fc8263ca532ea26633dcb)
2019-01-24 03:48:27 +00:00
Kyle Evans
df34d80aa7 iwm - Clear Time Event active state, when receiving End Notification.
* This hopefully avoids some firmware panics, I was occasionally seeing,
when iwm disconnects upon losing signal to an access point at some point.

* This is synchronizing the if_iwm_time_event.c file a bit more from the
corresponding Linux iwlwifi/mvm/time-event.c.

Taken-From:     Linux iwlwifi

Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (e8cb71584a6a72232c13151d60e57f7f229220eb)
2019-01-24 03:47:47 +00:00
Kyle Evans
9a949c99e6 iwm - Improve firmware Time Event handling.
* This is a mix of the OpenBSD Git 7fd9664469d1b717a307eebd74aeececbd3c41cc
change, and syncing with the Linux iwlwifi code.

Taken-From: Linux iwlwifi, and OpenBSD

Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (706a3044afd27c3fecfdf57bec1695310e53e228)
2019-01-24 03:47:04 +00:00
Kyle Evans
002c4a619b iwm - Avoid Tx watchdog timeout, when dropping a connection.
Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (3e12596fb5c55351517cdd741d72979388a8c75c)
2019-01-24 03:46:35 +00:00
Kyle Evans
8d969c53d2 iwm - Track firmware state better, and improve handling in iwm_newstate().
* This avoids firmware resets in all the cases in iwm_newstate(). Instead
iwm_bring_down_firmware() is called, which tears down all the STA
connection state, according to the sc->sc_firmware_state value.

* Improve the behaviour of the LED blinking a bit, so it only blinks when
there really is a wireless scan going on.

* Print the newstate arg in debug output of iwm_newstate(), to help in
debugging.

This is inspired by the firmware state maintaining change in OpenBSD's iwm,
by stsp@openbsd.org (OpenBSD Git 0ddb056fb7370664b1d4b84392697cb17d1a414a).

Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (8a41b10ac639d0609878696808387a6799d39b57)
2019-01-24 03:45:55 +00:00
Kyle Evans
9612bbf423 if_iwm - Configure the PCIe LTR, fix PCI express capability accesses.
Taken-From: Linux iwlwifi

Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (08a7ad5a5ff65aaaf2df6a609be7a4e1df43efc3)
2019-01-24 03:44:48 +00:00
Kyle Evans
f33c830939 iwm - Reduce gratuitous differences with Linux iwlwifi in struct naming.
* Rename some structs and struct members for firmware handling.

Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (4b1006a6e4d0f61d48c67b46e1f791e30837db67)
2019-01-24 03:43:45 +00:00
Kyle Evans
797b6586c6 if_iwm - Check sc->sc_attached flag in suspend/resume callbacks.
* There is (almost) nothing to do in suspend/resume if if_iwm has failed
during initialization (e.g. because of firmware load failure) and was
already uninitialized by iwm_detach_local().

Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (67b5e090efb225654815fed91020db6cfc16bb19)
2019-01-24 03:42:59 +00:00
Kyle Evans
544b40d85e if_iwm - Move iwm_read_firmware() call into iwm_attach().
* We should load the firmware exactly once before the driver really
initializes the hardware the first time, and unload it at detach time.
There is no need to retrieve the firmware during execution of
iwm_mvm_load_ucode_wait_alive(), we should make sure we already have the
firmware data at hand before that.

* The existing sc_preinit_hook code fails to deal with the case where
if_iwm is loaded by the loader (or is statically linked) and the
firmware needs to be loaded from disk. So we can just call
iwm_read_firmware() from iwm_attach() directly.

* A separate solution will have to be added to properly defer the firmware
loading during bootup, until the necessary filesystem is mounted.

Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (0104ee1f4cb6a2313c00c2526c6ae98d42e5041d)
2019-01-24 03:42:23 +00:00
Kyle Evans
aa0972c6ce if_iwm - The iwm_prepare_card_hw() in iwm_attach() is only needed on 8K hw.
* Doing the iwm_prepare_card_hw() call in iwm_attach() only on Family 8000
hardware matches the code in Linux iwlwifi.

* While there remove DEFAULT_MAX_TX_POWER definition which is unused, and
has a value different from IWL_DEFAULT_MAX_TX_POWER in iwlwifi.

Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (e8560f8dc58df12a7c79a6bb4e6ccb156e001085)
2019-01-24 03:41:44 +00:00
Kyle Evans
95d69da4e0 if_iwm - Update firmware rs table, instead of indexing the table in tx cmds.
* Rather than providing a non-zero index into the firmware RS table,
we should always use index 0 and update the firmware RS table whenever
our chosen tx rate for data-frames changes.

* Send IWM_LQ_CMD updates when the tx rate gets updated by the net80211
rate control (which is after we tell the tx status to the net80211
rate-control in iwm_mvm_rx_tx_cmd_single()).

* Disregard frames transferred with a different tx rate than the currently
selected rate for the rate-control calculations. This way we avoid
counting management frames (which are sent at a slow, and fixed rate),
as well as frames we added to the tx queue just before a new IWM_LQ_CMD
update took effect.

Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (5d6b465e288ac5b52d7115688d4e6516acbbea1c)
2019-01-24 03:41:09 +00:00
Kyle Evans
afbc939b81 iwm(4): Fix possible null pointer indirection
Obtained from:	DragonFlyBSD (obtained from Haiku)
MFC after:	1 week
2019-01-21 01:45:35 +00:00
Bjoern A. Zeeb
b20d0a438e With the sync from Dragonfly BSD in r318216 a bug slipped in (also still present
upstream it seems).

The tlv variable was changed to a pointer but the advancement of the data pointer
was left as sizeof(tlv).  While the sizeof the (now) pointer equals the
sizeof 2 x uint32_t (size of the struct) on 64bit platforms, on 32bit platforms
the size of the advancement of the data pointer was wrong leading to
firmware load issues.

Correctly advance the data pointer by the size of the structure and not by
the size of a pointer.

PR:		219683
Submitted by:	waddlesplash gamil.com (Haiku) on irc
MFC after:	1 week
2019-01-15 22:31:54 +00:00
Bjoern A. Zeeb
ef08929f90 Fix the MODULE_PNP_INFO() for iwm(4) where I got the bus and module
arguments wrong in r339020.

PR:			231625
Reported by:		Yuri Pankov (yuripv yuripv.net)
Reviewed by:		cem, Yuri Pankov (yuripv yuripv.net)
Approved by:		re (kib)
Pointyhat to:		bz (a rather big one for this one)
2018-10-01 10:44:33 +00:00
Bjoern A. Zeeb
916023bda9 Provide MODULE_PNP_INFO() for iwm(4) so that devmatch(8) can
do its job.

PR:		231625
Submitted by:	Yuri Pankov (yuripv yuripv.net)
Approved by:	re (kib)
2018-09-29 21:14:54 +00:00
Eitan Adler
6472fa9a9d [iwm] Add support for iwm 3168 cards
```
iwm0@pci0:5:0:0:        class=0x028000 card=0x21108086 chip=0x24fb8086
rev=0x10 hdr=0x00
vendor     = 'Intel Corporation'
device     = 'Dual Band Wireless-AC 3168NGW [Stone Peak]'
class      = network
[94829] iwm0: <Intel(R) Dual Band Wireless AC 3168> mem
0xef700000-0xef701fff at device 0.0 on pci5
[94829] iwm0: hw rev 0x220, fw ver 22.361476.0, address
28:c6:3f:15:43:c5
```

MFC After:	2 weeks
Reviewed by:	ivadasz (over IRC)
PR:		224886
Differential Revision:	https://reviews.freebsd.org/D14865
2018-03-28 07:59:16 +00:00
Adrian Chadd
9fbe631a1a [net80211] convert all of the WME use over to a temporary copy of WME info.
This removes the direct WME info access in the ieee80211com struct and instead
provides a method of fetching the data.  Right now it's a no-op but eventually
it'll turn into a per-VAP method for drivers that support it (eg iwn, iwm,
upcoming ath10k work) as things like p2p support require this kind of behaviour.

Tested:

* ath(4), STA and AP mode

TODO:

* yes, this is slightly stack size-y, but it is an important first step
  to get drivers migrated over to a sensible WME API.  A lot of per-phy things
  need to be converted to per-VAP before P2P, 11ac firmware, etc stuff shows up.
2018-01-02 00:07:28 +00:00
George V. Neville-Neil
851ca7068f Add support for Intel 8265 WiFi
Obtained from:	OpenBSD
MFC after:	1 month
2017-10-09 15:48:56 +00:00
Adrian Chadd
f55c604bdf [iwm] Add iwm_mvm_send_lq_cmd() from Linux iwlwifi to if_iwm_util.c.
Obtained from:	dragonflybsd.git 8a5dd7783e407856754093f5b1c9c757c64534b7
2017-07-26 05:51:31 +00:00
Adrian Chadd
1ecccab8fe [iwm] Sync statistics API definitions with Linux iwlwifi.
Obtained from:	dragonflybsd.git 75895a53a9c1ba60d75be9b4bf6e49a37f91a7cf
2017-07-26 05:40:52 +00:00
Adrian Chadd
7a3e63e7b3 [iwm] Cleanup mbufq draining. Add iwm_xmit_queue_drain() like in iwn(4).
* iwm_xmit_queue_drain() calls ieee80211_free_node(), removing a possible
  memory leak, compared to using just mbufq_drain().

* Remove duplicate mbufq_drain() from iwm_mvm_rm_sta(), this should be
  handled in the caller.

Obtained from:	dragonflybsd.git 339d45fda40072e0aca5ece639173204716f11fe
2017-07-26 05:29:08 +00:00
Adrian Chadd
d17a5d1bce [iwm] Remove support for fw older than -17 and -22
* iwm(4) didn't use any of these definitions yet, anyway.

Obtained from:	dragonflybsd.git f95003b8f1f7382c8396a6d408e3072632afdd3d
2017-06-04 21:28:52 +00:00
Adrian Chadd
50c5bb10c5 [iwm] Ignore IWM_DEBUG_LOG_MSG notifications.
* Firmware versions 21 and 22 generate some IWM_DEBUG_LOG_MSG notifications,
  which seem to be harmless. Avoid spamming the system log with
  "frame ... UNHANDLED (this should not happen)" messages.

Obtained from:	dragonflybsd.git dda889ac57d8e5b46bb1b1ecf53c17a18481c7c8
2017-06-04 21:14:23 +00:00
Adrian Chadd
51382483c4 [iwm] Set command code for PHY_DB as well.
Obtained from:	dragonflybsd.git 58318c956a74382d1286ccabaf767012fdcfe1a2
2017-06-04 21:13:13 +00:00