Commit Graph

63 Commits

Author SHA1 Message Date
Imre Vadász
bff11ce594 [iwm] Improve reliability of iwm_release on disassociation a bit.
* We need to first call ivp->iv_newstate(), to enqueue the deauth/deassoc
  mgmt frame, then flush the tx queue, before actually calling
  iwm_release().

* cycling a wlan connection via wpa_cli frontend to wpa_supplicant, by
  issuing disconnect and reconnect commandos works quite well.
  (There is still an issue when disconnecting/reconnecting too quickly)

* Reassociating or roaming via wpa_supplicant is still broken.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7943
2016-09-19 22:36:30 +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
0ba35431ee [iwm] Use IWM_DEFAULT_SCAN_CHANNELS define as default for sc_capa_n_scan_channels.
Approved by:	adrian (mentor)
Obtained from:	Linux iwlwifi
Differential Revision:	https://reviews.freebsd.org/D7938
2016-09-19 22:23:46 +00:00
Imre Vadász
22359652af [iwm] Remove deprecated scan API definitions.
* This removes deprecated scan API definitions, which have been unused
  since the upgrade to version 16 firmware in change r303327.

* Part of this change matches the header-file changes in Linux git commit
  1f9403863c080478ad78247c89b018e95bdfb027.

* No functional change.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7937
2016-09-19 22:20:46 +00:00
Imre Vadász
fbb27a30bf [iwm] Remove wrappers around iwm_dma_contig_free() calls.
No functional changes.

Inspired by:	OpenBSD
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7933
2016-09-19 22:16:03 +00:00
Imre Vadász
0cd7fa558e [iwm] Fix iwm_poll_bit() error value check in iwm_attach().
The iwm(4) iwm_poll_bit() function returns 1 on success, and 0 on failure,
whereas the iwl_poll_bit() in Linux iwlwifi returns < 0 on failure.

So the (ret < 0) check ended up ignoring any error returned by
iwm_poll_bit().

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7932
2016-09-19 22:13:08 +00:00
Imre Vadász
739e99ba69 [iwm] Fix off-by-one check in iwm_read_firmware().
This fixes a potential buffer overrun in the firmware parsing code.

Reported by:	Coverity
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7931
2016-09-19 22:11:34 +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
Imre Vadász
b47237ce60 [iwm] Use htole16 for policy field in struct iwm_time_event_cmd_v2.
The htole32 was working fine for little-endian machines, but would have
been broken on big-endian.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7929
2016-09-19 22:06:00 +00:00
Adrian Chadd
4083793433 [iwm] fix up RSSI calculations for both scan results and normal RX operations.
* hard code a noise floor of -96 for now. The noise floor update code returns
  some "interesting" values that I can't map to anything useful right now.
* Ensure a default noise floor is set - otherwise the initial scan results
  have a noise floor of '0'.
* Fix up the RSSI calculation to be correctly relative to the noise floor.
  The RSSI routines return an absolute value in dBm - so fix this up.
* Cap RSSI values appropriately.
* Ensure we pass in a 1/2 dB unit value in to net80211.

Tested:

* Intel 7260, STA mode

iwm0: <Intel Dual Band Wireless AC 7260> mem 0xf1400000-0xf1401fff irq 17 at device 0.0 on pci2
iwm0: hw rev 0x140, fw ver 16.242414.0, address xx:xx:xx:xx:xx:xx
2016-09-18 05:07:18 +00:00
Andriy Voskoboinyk
9afea60f98 iwm: fix scanning for hidden SSIDs.
Setup SSIDs in scan command so firmware will send direct probe request(s)
while scanning.

Tested by:	dbkirk@gmail.com

PR:		211519
MFC after:	1 week
2016-09-06 10:08:32 +00:00
Andriy Voskoboinyk
e796f68455 iwm: fix few comment typos. 2016-08-27 10:04:48 +00:00
Andriy Voskoboinyk
d845f44fb1 iwm: add 'command accepted' debug notification (copied from wpi(4)).
Now it should be easier to find out which command causes firmware
panics when few commands are sent in a short period of time.
2016-08-27 08:34:20 +00:00
Imre Vadász
a3c0e7f2fb [iwm] Fix iwm_poll_bit() usage in iwm_stop_device(), fixup r303418.
* iwm_poll_bit() returns 1 on success and 0 on failure, whereas
  iwl_poll_bit() in Linux's iwlwifi returns >= 0 on success and < 0 on
  failure.

* Because of the wrong iwm_poll_bit return code check, no warning was
  printed if tx DMA stopping failed.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7371
2016-07-30 19:03:32 +00:00
Imre Vadász
34938c3085 [iwm] When stopping TX DMA, wait for all channels at once.
* Makes the TX DMA stopping more similar to Linux code, and potentially
      a bit faster. Also, output an error message when TX DMA idling fails.

    Taken-From: Linux iwlwifi

Tested:

* AC3165, STA mode

Approved by:	adrian (mentor)
Obtained from:	DragonFlyBSD git 2ee486ddff973ac552ff787c17e8d83e8ae0f24c
Differential Revision:	https://reviews.freebsd.org/D7325
2016-07-27 20:51:31 +00:00
Imre Vadász
2b8cf46a68 [iwm] Set different pm_timeout for action frames.
When building a Tx Command for management frames, we are lacking
    a check for action frames, for which we should set a different
    pm_timeout.  This cause the fw to stay awake for 100TU after each
    such frame is transmitted, resulting an excessive power consumption.

    Taken-From: Linux iwlwifi (git b084a35663c3f1f7)

Approved by:	adrian (mentor)
Obtained from:	Linux git b084a35663c3f1f7de1c45c4ae3006864c940fe7
Obtained from:	DragonFlyBSD git ba00f0e3ae873d6f0d5743e22c3ebc49c44dfdac
Differential Revision:	https://reviews.freebsd.org/D7324
2016-07-27 20:46:51 +00:00
Imre Vadász
74adf80539 [iwm] Fix inverted logic in iwm_tx().
The PROT_REQUIRE flag in should be set for data frames above a certain
    length, but we were setting it for !data frames above a certain length,
    which makes no sense at all.

    Taken-From: OpenBSD, Linux iwlwifi

Approved by:	adrian (mentor)
Obtained from:	DragonFlyBSD git 8cc03924a36c572c2908e659e624f44636dc2b33
Differential Revision:	https://reviews.freebsd.org/D7323
2016-07-27 20:43:08 +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
1eccf20376 [iwm] Use mbuf for large firmware commands, like OpenBSD does.
We also need to consider the size of large firmware commands in iwm_alloc_tx_ring(),
in the dma tag creation, when qid == IWM_MVM_CMD_QUEUE. The old code apparently
only allocated a 2KB (MCLBYTES) sized buffer when it actually expected 4KB.

Submitted by:	Imre Vadasz <imre@vdsz.com>
Approved by:	re (gjb)
Differential Revision:	https://reviews.freebsd.org/D6824
2016-06-23 01:13:30 +00:00
Adrian Chadd
8a1660e16a [iwm] Add and use iwm_phy_db_free(), to plug phy_db memory leak.
(Together with other iwm(4) memory leak fixes) Memory leakage in M_DEVBUF
is now at ca. 2KB for each iwm(4) module load/unload cycle.

Submitted by:	Imre Vadasz <imre@vdsz.com>
Approved by:	re (gjb)
Obtained from:	DragonflyBSD git eaf551a1d464c643e98ce5781971dd32124e9af1
Differential Revision:	https://reviews.freebsd.org/D6819
2016-06-23 01:11:52 +00:00
Adrian Chadd
f6ea76fb7e [iwm] Fix iwm_dma_contig_free(). dma->map is always NULL here.
* When bus_dmamem_alloc is used, the bus_dmamap_t is usually set to NULL, so
  we were never actually freeing any dma memory allocations done via
  iwm_dma_contig_alloc(). So we should check dma->vaddr instead of dma->map here.

* Also, the dmamap is actually supposed to be invalidated as part of
  bus_dmamem_free(), so bus_dmamap_destroy() is never needed here.

Submitted by:	Imre Vadasz <imre@vdsz.com>
Approved by:	re (gjb)
Obtained from:	DragonflyBSD git ef2b29a7ba6ca8a9d2c82ab591c0622227ff84cb
2016-06-23 01:00:13 +00:00
Adrian Chadd
bc6cd01d38 [iwm] Use vap->iv_myaddr instead of ic->ic_macaddr when vap != NULL.
ic_macaddr is only used for the initial mac address provided by NVM. We should
rather use vap->iv_myaddr when vap != NULL, to allow the MAC address
to be changed later with ifconfig(8).

Submitted by:	Imre Vadasz <imre@vdsz.com>
Reviewed by:	avos
Approved by:	re (gjb)
Obtained from:	DragonflyBSD git 4aee7a78275676d22d14c04177bd0c9377d91478
Differential Revision:	https://reviews.freebsd.org/D6743
2016-06-23 00:56:54 +00:00
Adrian Chadd
5b4dc397af [iwm] free RX ring / NVM memory after they're used.
* Free RX ring during detach
* Free NVM memory after parsing

Tested:

* 7260, STA mode

Submitted by:	Imre Vadasz <imre@vdsz.com>
Approved by:	re (gjb)
Obtained from:	dragonflybsd
Differential Revision:	https://reviews.freebsd.org/D6817
2016-06-16 17:59:15 +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
0e92cf939f [iwm] valid_{tx,rx}_ant from radio_cfg is only needed for 8000 family.
* The "if (!data->valid_tx_ant || !data->valid_rx_ant) {" check was getting
  triggered with a 3165 chipset.

Submitted by:	Imre Vadasz <imre@vdsz.com>
Obtained from:	DragonflyBSD 3655dfb6fc311fc83e5ce8370dd91b4cd4a37991
2016-06-02 06:22:59 +00:00
Adrian Chadd
88b6e4f33a [iwm] Fix several nitpicks in iwm(4).
Move some declarations to if_iwmreg.h.
    Remove iwm_fw_alive(); just call iwm_post_alive() directly.
    Simplify iwm_mvm_add_sta().
    Return timeout error from iwm_apm_init().
    Print a message when init (i.e. boot) firmware fails to load.
    Remove some commented-out code which wouldn't compile anyway.
    Move iwm_mvm_tx_fifo to if_iwmreg.h to match better where Linux puts it.

    Taken-From: OpenBSD (if_iwm.c r1.80 and if_iwmreg.h r1.11)

Submitted by:	 Imre Vadasz <imre@vdsz.com>
Obtained from:	DragonflyBSD 29fcb331e5620ae145a6ab9cdda830e22fff626a
2016-06-02 05:43:16 +00:00
Adrian Chadd
3028d11c3e [iwm] Add bit-polling in Rx-DMA init code path.
Taken-From: OpenBSD (if_iwm.c r1.80)

Submitted by:	Imre Vadasz <imre@vdsz.com>
Obtained from:	DragonflyBSD ed35558754288911048cb607e57c688273ebd8d4
2016-06-02 05:00:52 +00:00
Adrian Chadd
ebb6ea5662 [iwm] Clean up iwm(4) scanning logic a bit.
Submitted by:	Imre Vadasz <imre@vdsz.com>
Obtained from:	DragonflyBSD 8f3ffab9136e33263d424275ec28f57ad2096437
2016-06-02 04:54:56 +00:00
Adrian Chadd
7a8b94e1d2 [iwm] Use IWM_MAX_CMD_PAYLOAD_SIZE to improve command length checks.
Taken-From: OpenBSD (parts of if_iwm.c r1.57 and if_iwmreg.h r1.10)

Obtained from:	DragonflyBSD b70c1eaad06257c5c7f4d8110d21642ebec14f42
2016-06-02 04:53:28 +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
Andriy Voskoboinyk
b789292fd8 iwm: add 'opt_wlan.h' include into source files.
Include net80211 options file, so IEEE80211_DEBUG_REFCNT option will be
handled correctly.
2016-05-19 23:31:00 +00:00
Andriy Voskoboinyk
ace1dfdd0b iwm: restart device after watchdog timeouts. 2016-05-19 22:43:21 +00:00
Eitan Adler
cef367e6a1 Don't repeat the the word 'the'
(one manual change to fix grammar)

Confirmed With: db
Approved by: secteam (not really, but this is a comment typo fix)
2016-05-17 12:52:31 +00:00
Kevin Lo
cbb62fa6aa Follow-up r298818: hide size of 'bands' array behind a macro. 2016-05-16 02:27:28 +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
d35192e513 iwm: fix parameters for iwm_add_channel_band()
It accepts <first index, max index + 1>, not
<first index, number of entries>.

Reported by:	adrian
2016-05-02 19:07:44 +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
82f860283c [iwn] fill in the TX command rate info flags consistently.
The Linux driver sets the rate_n_flags regardless of whether it's being
sent using firmware rate control or local rate control.  This includes
the antenna configuration.

Thanks to Kyle Evans <kevans91@ksu.edu> for pointing this out to me
and doing some investigation/testing on his end.

Tested:

* Intel 7260 STA, 2G and 5G networks
2016-05-01 05:01:10 +00:00
Dmitry Chagin
e27428fd1c The iwm_nic_error() defined if IWM_DEBUG is defined. 2016-04-29 19:10:22 +00:00
Conrad Meyer
2cb2bed294 iwm(4): Don't dereference potentially NULL pointer before NULL check
Introduced in r298594.  There is no path before the 'vap == NULL' check where
vap is not already dereferenced.

Reported by:	Coverity
CID:		1354979
Sponsored by:	EMC / Isilon Storage Division
2016-04-26 19:06:28 +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
Adrian Chadd
5a4e447647 [iwm] add extra transmit setup/completion logging so I can see what's going on.
I'm seeing 5GHz association work but data not work until the rate drops,
so I need way more information about what's being programmed into the
transmit descriptors.

Tested:

* 7260AC, STA mode
2016-04-26 03:24:28 +00:00
Adrian Chadd
cc418e44a0 [iwm] restart the VAP if there's a firmware panic.
Always print out the firmware panic info before restarting; don't
put it behind IWM_DEBUG.

Submitted by:	bapt
Differential Revision:	https://reviews.freebsd.org/D6081
2016-04-25 22:00:05 +00:00
Adrian Chadd
8d170e6ac1 [iwn] fix firmware command use in iwm_auth().
The iwm firmware has separate commands for add, modify and delete for
various things (mac, phy context, etc.)  The openbsd driver has a habit
of just completely resetting the NIC each time, which is technically
mostly okay (as long as the reset doesn't actually fail!) but it means
a lot of the code is doing ADD when it should do MODIFY.

The firmware responds in kind - it just asserts.

This fixes auth attempts that occur after the NIC has been already
configured.

(I'm sure there are more instances of this!)

Tested:

iwm0: <Intel Dual Band Wireless AC 7260> mem 0xf1400000-0xf1401fff irq 17 at device 0.0 on pci2
iwm0: revision: 0x140, firmware 25.228 (API ver. 9)

.. STA mode.

Submitted by:	Masachika ISHIZUKA <ish@amail.plala.or.jp>
2016-04-25 16:13:04 +00:00
Adrian Chadd
88ecff8b96 [iwm] fix up the rate control setup code to initialise rates in the order
we want to use it.

The rate table was being initialised in low->high, but the link quality
table was being initialised high->low. So, when we did a lookup, we
would get the indexes wrong.

This started by a patch from dragonflybsd which reversed how the ni->in_ridx[]
array is being used; I'd rather it all be consistent.  So, this is consistent.

Inspired by: what I did to iwn(4) a while ago
Inspired by: DragonflyBSD; <imre@vdsz.com>
2016-01-18 05:43:34 +00:00
Andriy Voskoboinyk
430384523d iwm: revert r293178
This optimization is not proper (and causes kernel panic),
since driver checks fw_status to optimize away parsing stage
if it was already done.

Reported by:	dchagin
2016-01-05 20:09:26 +00:00
Andriy Voskoboinyk
e8d24c2011 iwm: free firmware related resources after uploading it to the hardware
iwn(4) / wpi(4) works in the same way
(read_firmware() -> hw_init() -> firmware_put())

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D4766
2016-01-04 21:07:08 +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