Commit Graph

36127 Commits

Author SHA1 Message Date
Andriy Voskoboinyk
701957cbb6 rsu(4): do not ignore mgmtrate / mcastrate / ucastrate.
Enforce net80211 rates for control / management / multicast / EAPOL frames
and allow to override rate for unicast frames via ifconfig(8) 'ucastrate'
option; by default it still uses f/w rate adaptation for unicast frames.

MFC after:	1 week
2019-01-28 11:39:54 +00:00
Andriy Voskoboinyk
6bda1ad8a2 rtwn_usb(4): add new USB id.
Submitted by:	<yklaxds@gmail.com>
Github issue:	https://github.com/s3erios/rtwn/issues/4
MFC after:	5 days
2019-01-28 02:15:41 +00:00
Michal Meloun
1289ca623e Properly define and declare phynode_topo_lock,
it should be single global variable.

X-MFC with:	r340845
Noticed by:	phynode_topo_lock
2019-01-27 15:50:36 +00:00
Andriy Voskoboinyk
21b56f2920 pcf(4): fix parentheses in if condition
PR:		210709
Submitted by:	David Binderman <dcb314@hotmail.com>
MFC after:	5 days
2019-01-27 15:19:28 +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
Andriy Voskoboinyk
b84b36380e Remove 2GHz channel list copies from wireless drivers.
Wrap ieee80211_add_channel_list_2ghz into another function
which supplies default (1-14) channel list to it and drop
its copies from drivers.

Checked with RTL8188EE, country US / JP / KR / UA.

MFC after:	2 weeks
2019-01-26 17:00:55 +00:00
Oleksandr Tymoshenko
f913a5749f Fix format/arg mismatch
USe correct format for int arguments

PR:		229549
Submitted by:	David Binderman <dcb314@hotmail.com>
MFC after:	1 week
2019-01-25 21:38:28 +00:00
John Baldwin
cecf8bebe7 Fix a few more places to handle ofld tx queues for RATELIMIT.
- Drain offload transmit queues when RATELIMIT is enabled but
  TCP_OFFLOAD is not.
- Expose the per-VI nofldtxq and first_ofld_txq sysctls when
  RATELIMIT is enabled but TCP_OFFLOAD is not.
- Clear offload transmit queue stats as part of a 'cxgbetool clearstats'
  request when RATELIMIT is enabled but TCP_OFFLOAD is not.

Reviewed by:	np
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D18966
2019-01-25 20:54:18 +00:00
Hans Petter Selasky
ee3da13fc6 Add new USB quirk.
PR:			235202
Differential Revision:	https://reviews.freebsd.org/D18917
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2019-01-25 20:20:27 +00:00
Takanori Watanabe
877fc2e350 Use ACPI TPM2 table to probe tpmtis and tpmcrb device.
Differential Revision: https://reviews.freebsd.org/D18937
2019-01-25 16:16:10 +00:00
Andriy Voskoboinyk
9df9e9361c net80211: reuse TICKS_2_MSEC / MSEC_2_TICKS macros from sys/time.h
Replace in-place implementation with system-wide one; since it
guarantees non-zero result drop all less-than-one checks from
drivers and net80211.

MFC after:	2 weeks
2019-01-25 01:05:18 +00:00
Vincenzo Maffione
aa4dd64dfe netmap: fix crash with monitors and VALE ports
Crash report described here:
    https://github.com/luigirizzo/netmap/issues/583
Fixed by providing dummy sync callback in case it is missing.
2019-01-24 22:09:26 +00:00
Kyle Evans
bdf95b7398 iwm - Remove unused TX_CMD_NEXT_FRAME_*
Taken-From: Linux git b1e06c65fb69c5e3fddcd91987561e225eaa9bfa

Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (b0c6116f364a121ab6b9d634ca1997d4167fa747)
2019-01-24 03:50:27 +00:00
Kyle Evans
37ac41d30f iwm - Remove unused REPLY_MAX
Taken-From: Linux git e4eb275ac5cfe71686612d929a9829345b2a4ada

Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (92a727c99d6ec5abf14bb6853e95e3a187a0cd4e)
2019-01-24 03:50:03 +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
ef217a3417 if_iwm - Add firmware API definitions for TX power commands.
* While there remove unused IWM_UCODE_TLV_CAPA_LMAC_UPLOAD definition,
which isn't defined in iwlwifi.

Taken-From: Linux iwlwifi

Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (fd4f9de8bc72ea961e50829b45b59d0549040b7d)
2019-01-24 03:45:24 +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
27898346e2 if_iwm - Update struct iwm_scan_results_notif. Remove old/unused definitions
* Remove outdated notifications IWM_SCAN_ABORT_CMD,
IWM_SCAN_START_NOTIFICATION and IWM_SCAN_RESULTS_NOTIFICATION.

* Remove unused enum iwm_scan_complete_status.

* Use the updated FW Api version 3 of struct iwm_scan_results_notif.

* No functional change, since struct iwm_scan_results_notif is never
accessed in iwm at the moment.

Taken-From: Linux iwlwifi commits 1083fd7391e989be52022f0f338e9dadc048b063
	and 75118fdb63496e4611ab50380499ddd62b9de69f.

Submitted by:	Augustin Cavalier <waddlesplash@gmail.com> (Haiku)
Obtained from:	DragonFlyBSD (c947b0b8dc96dabefd63f7b70d53695e36c7b64f)
2019-01-24 03:44:20 +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
Eric Joyner
2de16a737f ixl(4): Fix handling data passed with ioctl from NVM update tool
From Krzysztof:

Ensure that the entire data buffer passed from the NVM update tool is copied in
to kernel space and copied back out to user space using copyin() and copyout().

PR:		234104
Submitted by:	Krzysztof Galazka <krzysztof.galazka@intel.com>
Reported by:	Finn <ixbug@riseup.net>
MFC after:	5 days
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D18817
2019-01-24 01:08:37 +00:00
Eric Joyner
088a0b27ad intel iflib drivers: correct initialization of tx_cidx_processed
From Jake:

In r341156 ("Fix first-packet completion", 2018-11-28) a hack to work
around a delta calculation determining how many descriptors were used
was added to ixl_isc_tx_credits_update_dwb.

The same fix was also applied to the em and igb drivers in r340310, and
to ix in r341156.

The hack checked the case where prev and cur were equal, and then added
one. This works, because by the time we do the delta check, we already
know there is at least one packet available, so the delta should be at
least one.

However, it's not a complete fix, and as indicated by the comment is
really a hack to work around the real bug.

The real problem is that the first time that we transmit a packet,
tx_cidx_processed will be set to point to the start of the ring.
Ultimately, the credits_update function expects it to point to the
*last* descriptor that was processed. Since we haven't yet processed any
descriptors, pointing it to 0 results in this incorrect calculation.

Fix the initialization code to have it point to the end of the ring
instead. One way to think about this, is that we are setting the value
to be one prior to the first available descriptor.

Doing so, corrects the delta calculation in all cases. The original fix
only works if the first packet has exactly one descriptor. Otherwise, we
will report 1 less than the correct value.

As part of this fix, also update the MPASS assertions to match the real
expectations. First, ensure that prev is not equal to cur, since this
should never happen. Second, remove the assertion about prev==0 || delta
!= 0. It looks like that originated from when the em driver was
converted to iflib. It seems like it was supposed to ensure that delta
was non-zero. However, because we originally returned 0 delta for the
first calculation, the "prev == 0" was tacked on.

Instead, replace this with a check that delta is greater than zero,
after the correction necessary when the ring pointers wrap around.

This new solution should fix the same bug as r341156 did, but in a more
robust way.

Submitted by:	Jacob Keller <jacob.e.keller@intel.com>
Reviewed by:	shurd@
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D18545
2019-01-24 01:03:00 +00:00
Hans Petter Selasky
05d3471d5d Add USB quirk.
Submitted by:		Gary Jennejohn <gljennjohn@gmail.com>
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2019-01-23 18:53:13 +00:00
Ram Kishore Vegesna
4915e5c719 Fixed issues reported by coverity scan.
Approved by: mav
MFC after: 3 weeks
2019-01-23 17:34:01 +00:00
Mark Johnston
f9be23fd42 ocs_fc: Ensure that we zero-initialize memory before copying it out.
Note that the affected interface is available only to root.

admbugs:	765
Reported by:	Vlad Tsyrklevich <vlad@tsyrklevich.net>
Reviewed by:	emaste, ram
MFC after:	1 day
Security:	Kernel memory disclosure
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18914
2019-01-23 17:28:39 +00:00
Vincenzo Maffione
f79ba6d75b netmap: improvements to the netmap kloop (CSB mode)
Changelist:
    - Add the proper memory barriers in the kloop ring processing
      functions.
    - Fix memory barriers usage in the user helpers (nm_sync_kloop_appl_write,
      nm_sync_kloop_appl_read).
    - Fix nm_kr_txempty() helper to look at rhead rather than rcur. This
      is important since the kloop can read a value of rcur which is ahead
      of the value of rhead (see explanation in nm_sync_kloop_appl_write)
    - Remove obsolete ptnetmap_guest_write_kring_csb() and
      ptnet_guest_read_kring_csb(), and update if_ptnet(4) to use those.
    - Prepare in advance the arguments for netmap_sync_kloop_[tr]x_ring(),
      to make the kloop faster.
    - Provide kernel and user implementation for nm_ldld_barrier() and
      nm_ldst_barrier()

MFC after:	2 weeks
2019-01-23 14:51:36 +00:00
Vincenzo Maffione
8c9874f5b1 netmap: fix knote() argument to match the mutex state
The nm_os_selwakeup function needs to call knote() to wake up kqueue(9)
users. However, this function can be called from different code paths,
with different lock requirements.
This patch fixes the knote() call argument to match the relavant lock state.
Also, comments have been updated to reflect current code.

PR:	https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=219846
Reported by:	Aleksandr Fedorov <aleksandr.fedorov@itglobal.com>
Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D18876
2019-01-23 14:21:23 +00:00
Vladimir Kondratyev
20694769bd Add quirk to enable mic and headphones redirection on HP Spectre laptops.
Tested on HP AF006UR.

MFC after:	2 weeks
2019-01-22 22:39:46 +00:00
Andriy Voskoboinyk
264eeebe12 iwn(4): drop i_seq field initialization for A-MPDU frames.
It is done by net80211 since r319460.

MFC after:	24 days
X-MFC-With:	343094
2019-01-22 01:44:47 +00:00
Patrick Kelsey
8f82136aec onvert vmx(4) to being an iflib driver.
Also, expose IFLIB_MAX_RX_SEGS to iflib drivers and add
iflib_dma_alloc_align() to the iflib API.

Performance is generally better with the tunable/sysctl
dev.vmx.<index>.iflib.tx_abdicate=1.

Reviewed by:	shurd
MFC after:	1 week
Relnotes:	yes
Sponsored by:	RG Nets
Differential Revision:	https://reviews.freebsd.org/D18761
2019-01-22 01:11:17 +00:00
Navdeep Parhar
2a857082dc cxgbe(4): Allow negative values in hw.cxgbe.fw_install and take them to
mean that the driver should taste the firmware in the KLD and use that
firmware's version for all its fw_install checks.

The driver gets firmware version information from compiled-in values by
default and this change allows custom (or older/newer) firmware modules
to be used with the stock driver.

There is no change in default behavior.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2019-01-21 18:42:16 +00:00
Mark Johnston
8f77f60f94 hwpmc: Plug memory disclosures from PMC_OP_{GETPMCINFO,GETCPUINFO}.
admbugs:	765
Reported by:	Vlad Tsyrklevich <vlad@tsyrklevich.net>
MFC after:	1 day
Security:	Kernel memory disclosure
Sponsored by:	The FreeBSD Foundation
2019-01-21 18:07:02 +00:00
Navdeep Parhar
8d5106760c cxgbe(4): Use a truncated firmware header for version checks. All the
version numbers are towards the begining of the header.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2019-01-21 17:58:06 +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
Andriy Voskoboinyk
c15f336dae urtw(4): add length checks in Rx path.
- Check if buffer can contain Rx descriptor before accessing it.
- Verify upper / lower bounds for frame length.
- Do not pass too short frames into ieee80211_find_rxnode().

While here:
- Move cleanup to the function end.
- Reuse IEEE80211_IS_DATA() macro.

MFC after:	1 week
2019-01-21 00:53:38 +00:00
Andriy Voskoboinyk
d4e1661a09 iwn(4): drop return code from iwn_*attach functions (they cannot fail)
While here, add missing trace 'end' marker in iwn5000_attach().

MFC after:	1 week
2019-01-21 00:09:54 +00:00
Andriy Voskoboinyk
fb10d4ee38 run(4): add more length checks in Rx path.
- Discard frames that are bigger than MCLBYTES (to prevent buffer overrun).
- Check buffer length before accessing its contents.
- Fix len <-> dmalen check - the last includes Rx Wireless information
structure size.
- Fix out-of-bounds read during Rx node search for ACK / CTS frames
(monitor mode only).

While here:
- Mark few suspicious places with comments.
- Move common cleanup to the function end.

MFC after:	1 week
2019-01-21 00:03:35 +00:00
Navdeep Parhar
6baf1e4803 cxgbe(4): Clear the reply-pending status of a hashfilter when the reply
indicates an error.  Also, do not remove it twice from the hf list in
this case.

Submitted by:	Krishnamraju Eraparaju @ Chelsio
MFC after:	1 week
Sponsored by:	Chelsio Communicatons
2019-01-20 23:30:16 +00:00
Oleksandr Tymoshenko
30cef2b7f9 Add KBD_BOOTPROTO quirk for Logitech G510s USB keyboard
PR:		232136
Submitted by:	dgilbert@eicat.ca
MFC after:	1 week
2019-01-20 20:29:26 +00:00
Toomas Soome
be9f17db85 ixgbe: this statement may fall through warnings with gcc
The recent gcc versions (7 and 8 at least) can check for switch case
statements for fall through (implicit-fallthrough). When fall through
is intentional, the default method for warning suppression is to place
comment /* FALLTHROUGH */ exactly before next case statement.

Differential Revision:	https://reviews.freebsd.org/D18577
2019-01-19 20:45:41 +00:00