Commit graph

38779 commits

Author SHA1 Message Date
Alexander Motin
88fe518973 Move time math out of disabled interrupts sections.
We don't need the result before next sleep time, so no reason to
additionally increase interrupt latency.

While there, remove extra PM ticks to microseconds conversion, making
C2/C3 sleep times look 4 times smaller than really.  The conversion
is already done by AcpiGetTimerDuration().  Now I see reported sleep
times up to 0.5s, just as expected for planned 2 wakeups per second.

MFC after:	1 month

(cherry picked from commit 2cee045b4d)
2021-04-06 20:33:59 -04:00
Alexander Motin
e6e4f79a6c Do not read timer extra time when MWAIT is used.
When we enter C2+ state via memory read, it may take chipset some
time to stop CPU.  Extra register read covers that time.  But MWAIT
makes CPU stop immediately, so we don't need to waste time after
wakeup with interrupts still disabled, increasing latency.

On my system it reduces ping localhost latency, waking up all CPUs
once a second, from 277us to 242us.

MFC after:	1 month

(cherry picked from commit 075e4807df)
2021-04-06 20:31:10 -04:00
Alexander Motin
9c27e7141b Change mwait_bm_avoidance use to match Linux.
Even though the information is very limited, it seems the intent of
this flag is to control ACPI_BITREG_BUS_MASTER_STATUS use for C3,
not force ACPI_BITREG_ARB_DISABLE manipulations for C2, where it was
never needed, and which register not really doing anything for years.
It wasted lots of CPU time on congested global ACPI hardware lock
when many CPU cores were trying to enter/exit deep C-states same time.

On idle 80-core system it pushed ping localhost latency up to 20ms,
since badport_bandlim() via counter_ratecheck() wakes up all CPUs
same time once a second just to synchronously reset the counters.
Now enabling C-states increases the latency from 0.1 to just 0.25ms.

Discussed with:	kib
MFC after:	1 month

(cherry picked from commit 455219675d)
2021-04-06 20:30:23 -04:00
Ka Ho Ng
2e107638ea virtio_pci_legacy: Allow memory space for configuration
For guests running under some kind of VMMs, configuration structure is
available in memory space but not I/O space.

Reported by:	Yuan Rui <number201724@me.com>
Reviewed by:	rpokala, bryanv, jhb
Approved by:	philip (mentor)
Differential Revision:	https://reviews.freebsd.org/D28818

(cherry picked from commit cf5d111240)
2021-04-03 14:09:50 +08:00
Ka Ho Ng
98740ead97 virtio_pci_legacy: Use the table BAR and PBA BAR from MSI-X cap
The MSI-X resource shouldn't be assumed to be always on BAR1.
The Virtio v1.1 Spec did not specify that MSI-X table and PBA BAR has to
be BAR1 either.

Reported by:	Yuan Rui <number201724@me.com>
Reviewed by:	bryanv, jhb
Approved by:	philip (mentor)
Differential Revision:	https://reviews.freebsd.org/D28817

(cherry picked from commit faf9a4e914)
2021-04-03 14:09:31 +08:00
Neel Chauhan
ea96dcc6e2 ichsmb: Add PCI IDs for Intel Comet Lake and Tiger Lake
Reviewed by:		manu
Differential Revision:	https://reviews.freebsd.org/D27859
MFC after:		2 weeks

(cherry picked from commit a94d15af26)
2021-04-02 10:22:46 -07:00
Hans Petter Selasky
484bc45f54 MFC 31070b5bc7:
Set default alternate setting when USB audio devices are not in use,
to activate power save features.

Differential Revision:	https://reviews.freebsd.org/D28032
Suggested by:	Shichun_Ma@Dell.com
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 31070b5bc7)
2021-04-01 11:13:10 +02:00
Mark Johnston
381ba4357c Fix several dev_clone callbacks to avoid out-of-bounds reads
Use strncmp() instead of bcmp(), so that we don't have to find the
minimum of the string lengths before comparing.

Reviewed by:	kib
Reported by:	KASAN
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29463

(cherry picked from commit 3428b6c050)
2021-03-31 09:15:58 -04:00
John Baldwin
325427f71d xnb: Don't pass SIOC{ADD,DEL}MULTI to ifmedia_ioctl().
ifmedia_ioctl() doesn't handle these requests, and this matches what
xn does.

Sponsored by:	DARPA

(cherry picked from commit 71ba16a0a0)
2021-03-29 15:36:36 -07:00
John Baldwin
1a325aa204 Remove unused wrappers around kproc_create() and kproc_exit().
Sponsored by:	Netflix

(cherry picked from commit 645b15e558)
2021-03-29 11:10:43 -07:00
Wei Hu
2fbdbfaa0c Hyper-V: hn: Initialize the internal field of per packet info on tx path
The RSC support feature introduced a bit field "rm_internal" in
struct rndis_pktinfo with total size unchanged.

The guest does not use this field in the tx path. However we need to
initialize it to zero in case older hosts which are not aware of this
field.

Fixes:		a491581f ("Hyper-V: hn: Enable vSwitch RSC support")
MFC after:	2 weeks
Sponsored by:	Microsoft

(cherry picked from commit 805dbff6c3)
2021-03-29 03:21:30 -07:00
Wei Hu
cdc59163ff Hyper-V: hn: Enable vSwitch RSC support in hn netvsc driver
Receive Segment Coalescing (RSC) in the vSwitch is a feature available in
Windows Server 2019 hosts and later. It reduces the per packet processing
overhead by coalescing multiple TCP segments when possible. This happens
mostly when TCP traffics are among different guests on same host.
This patch adds netvsc driver support for this feature.

The patch also updates NVS version to 6.1 as needed for RSC
enablement.

MFC after:	2 weeks
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D29075

(cherry picked from commit a491581f3f)
2021-03-29 03:20:03 -07:00
Wei Hu
a86be0da9a Hyper-V: hn: Store host hash value in flowid
When rx packet contains hash value sent from host, store it in
the mbuf's flowid field so when the same mbuf is on the tx path,
the hash value can be used by the host to determine the outgoing
network queue.

MFC after:	2 weeks
Sponsored by:	Microsoft

(cherry picked from commit 80f39bd95f)
2021-03-29 03:18:20 -07:00
Ed Maste
a66e75d9e2 mn: report that this driver is removed in 14, not 13 2021-03-24 22:35:38 -04:00
Hans Petter Selasky
ff2e2bca31 MFC 1acf24a044:
Implement pci_get_relaxed_ordering_enabled() helper function.

Discussed with:	kib@
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 1acf24a044)
2021-03-24 08:54:52 +01:00
Alexander Motin
ed407c92e4 nvme: Replace potentially long DELAY() with pause().
In some cases like broken hardware nvme(4) may wait minutes for
controller response before timeout.  Doing so in a tight spin loop
made whole system unresponsive.

Reviewed by:	imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D29309
Sponsored by:	iXsystems, Inc.

(cherry picked from commit 4fbbe52365)
2021-03-23 21:26:00 -04:00
Vincenzo Maffione
3e4127f8f2 netmap: fix issues in nm_os_extmem_create()
- Call vm_object_reference() before vm_map_lookup_done().
- Use vm_mmap_to_errno() to convert vm_map_* return values to errno.
- Fix memory leak of e->obj.

Reported by:	markj
Reviewed by:	markj
MFC after:	1 week

(cherry picked from commit ee7ffaa2e6)
2021-03-23 21:17:23 +00:00
Michal Vanco
395e612b7b pchtherm: fix a wrong bit and a wrong register use
Probably just copy-paste errors that slipped in.

(cherry picked from commit 5084dde5f0)

PR:		253915
Reported by:	Michal Vanco <michal.vanco@gmail.com>
2021-03-23 13:01:20 +02:00
John Baldwin
6a1dbc8ba9 iscsi: Mark iSCSI CAM sims as non-pollable.
Previously, iscsi_poll() just panicked.  This meant if you got a panic
on a box when using the iSCSI initiator, the attempt to shutdown would
trigger a nested panic and never write out a core.  Now, CCB's sent to
iSCSI devices (such as the sychronize-cache request in dashutdown())
just fail with a timeout during a panic shutdown.

Sponsored by:	Chelsio

(cherry picked from commit 47769bc557)
2021-03-22 13:37:46 -07:00
Mark Johnston
46f44865e3 iflib: Make if_shared_ctx_t a pointer to const
This structure is shared among multiple instances of a driver, so we
should ensure that it doesn't somehow get treated as if there's a
separate instance per interface.  This is especially important for
software-only drivers like wg.

DEVICE_REGISTER() still returns a void * and so the per-driver sctx
structures are not yet defined with the const qualifier.

Reviewed by:	gallatin, erj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29102

(cherry picked from commit ffe3def903)
2021-03-22 11:42:18 -04:00
Leandro Lupori
3aa6cc000f ofwfb: fix boot on LE
Some framebuffer properties obtained from the device tree were not being
properly converted to host endian.
Replace OF_getprop calls by OF_getencprop where needed to fix this.

This fixes boot on PowerPC64 LE, when using ofwfb as the system console.

Reviewed by:    bdragon
Sponsored by:   Eldorado Research Institute (eldorado.org.br)
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D27475

(cherry picked from commit 043577b721)
2021-03-22 10:48:46 -03:00
Michael Tuexen
6064ea8172 vtnet: fix TSO for TCP/IPv6
The decision whether a TCP packet is sent over IPv4 or IPv6 was
based on ethertype, which works correctly. In D27926 the criteria
was changed to checking if the CSUM_IP_TSO flag is set in the
csum-flags and then considering it to be TCP/IPv4.
However, the TCP stack sets the flag to CSUM_TSO for IPv4 and IPv6,
where CSUM_TSO is defined as CSUM_IP_TSO|CSUM_IP6_TSO.
Therefore TCP/IPv6 packets gets mis-classified as TCP/IPv4,
which breaks TSO for TCP/IPv6.
This patch bases the check again on the ethertype.
This fix is instantly MFCed.

Approved by:		re(gjb)
PR:			254366
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D29331

(cherry picked from commit d4697a6b56)
2021-03-18 21:33:32 +01:00
Vincenzo Maffione
120a4bd4e9 netmap: fix memory leak in NETMAP_REQ_PORT_INFO_GET
The netmap_ioctl() function has a reference counting bug in case of
NETMAP_REQ_PORT_INFO_GET command. When `hdr->nr_name[0] == '\0'`,
the function does not decrease the refcount of "nmd", which is
increased by netmap_mem_find(), causing a refcount leak.

Reported by:	Xiyu Yang <sherllyyang00@gmail.com>
Submitted by:	Carl Smith <carl.smith@alliedtelesis.co.nz>
MFC after: 3 days
PR:	254311

(cherry picked from commit 0ab5902e8a)
2021-03-18 16:40:23 +00:00
Scott Long
b65d2c31b1 base: remove if_wg(4) and associated utilities, manpage
After length decisions, we've decided that the if_wg(4) driver and
   related work is not yet ready to live in the tree.  This driver has
   larger security implications than many, and thus will be held to
   more scrutiny than other drivers.

Requested by: secteam
Approved by: re
2021-03-18 07:07:56 +00:00
Mark Johnston
10e8aac9bb ath_hal: Stop printing messages during boot
ath_hal is compiled into the kernel by default and so always prints a
message to dmesg even when the system has no ath hardware.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 0e72eb4602)
2021-03-15 11:39:08 -04:00
Mark Johnston
d18a65a535 wg: Style
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d8cebef50e)
2021-03-15 11:38:15 -04:00
Mitchell Horne
17d301f7b5 ns8250: don't drop IER_TXRDY on bus_grab/ungrab
It has been observed that some systems are often unable to resume from
ddb after entering with debug.kdb.enter=1. Checking the status further
shows the terminal is blocked waiting in tty_drain(), but it never makes
progress in clearing the output queue, because sc->sc_txbusy is high.

I noticed that when entering polling mode for the debugger, IER_TXRDY is
set in the failure case. Since this bit is never tracked by the softc,
it will not be restored by ns8250_bus_ungrab(). This creates a race in
which a TX interrupt can be lost, creating the hang described above.
Ensuring that this bit is restored is enough to prevent this, and resume
from ddb as expected.

The solution is to track this bit in the sc->ier field, for the same
lifetime that TX interrupts are enabled.

PR:		223917, 240122
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 7e7f7beee7)
2021-03-15 11:22:17 -03:00
Alexander Motin
aae8e02dfc Move ic_check_send_space clear to the actual check.
It closes tiny race when the flag could be set between being cleared
and the space is checked, that would create us some more work.  The
flag setting is protected by both locks, so we can clear it in either
place, but in between both locks are dropped.

MFC after:	1 week

(cherry picked from commit afc3e54eee)
2021-03-14 22:36:21 -04:00
Alexander Motin
8b0101da80 Restore condition removed in df3747c660.
I think it allowed to avoid some TX thread wakeups while the socket
buffer is full.  But add there another options if ic_check_send_space
is set, which means socket just reported that new space appeared, so
it may have sense to pull more data from ic_to_send for better TX
coalescing.

MFC after:	1 week

(cherry picked from commit aff9b9ee89)
2021-03-14 22:36:13 -04:00
Alexander Motin
2f77e2810a Replace STAILQ_SWAP() with simpler STAILQ_CONCAT().
Also remove stray STAILQ_REMOVE_AFTER(), not causing problems only
because STAILQ_SWAP() fixed corrupted stqh_last.

MFC after:	1 week

(cherry picked from commit df3747c660)
2021-03-14 22:36:04 -04:00
Alexander Motin
fb419e0ffb Fix initiator panic after 6895f89fe5.
There are sessions without socket that are not disconnecting yet.

MFC after:	3 weeks

(cherry picked from commit 06e9c71099)
2021-03-14 22:35:47 -04:00
Alexander Motin
6b409a8b32 Optimize TX coalescing by keeping pointer to last mbuf.
Before m_cat() each time traversed through all the coalesced chain.

MFC after:	1 week

(cherry picked from commit b85a67f54a)
2021-03-14 22:35:37 -04:00
Alexander Motin
31d41a6a9b Coalesce socket reads in software iSCSI.
Instead of 2-4 socket reads per PDU this can do as low as one read
per megabyte, dramatically reducing TCP overhead and lock contention.

With this on iSCSI target I can write more than 4GB/s through a
single connection.

MFC after:	1 month

(cherry picked from commit 6895f89fe5)
2021-03-14 22:34:28 -04:00
Alexander Motin
a4bea2f2a6 Refactor CTL datamove KPI.
- Make frontends call unified CTL core method ctl_datamove_done()
to report move completion.  It allows to reduce code duplication
in differerent backends by accounting DMA time in common code.
 - Add to ctl_datamove_done() and be_move_done() callback samethr
argument, reporting whether the callback is called in the same
context as ctl_datamove().  It allows for some cases like iSCSI
write with immediate data or camsim frontend write save one context
switch, since we know that the context is sleepable.
 - Remove data_move_done() methods from struct ctl_backend_driver,
unused since forever.

MFC after:	 1 month

(cherry picked from commit 2c7dc6bae9)
2021-03-14 22:34:08 -04:00
Mark Johnston
2b0aa5833c netmap: Stop printing a line to the dmesg in netmap_init()
netmap is compiled into the kernel by default so initialization was
always reported, and netmap uses a formatting convention not used in the
rest of the kernel.

Reviewed by:	vmaffione
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D29099

(cherry picked from commit fef8450971)
2021-03-12 12:20:59 -05:00
Mark Johnston
47495bf648 wg: Avoid leaking mbufs when the input handshake queue is full
Reviewed by:	grehan
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D29011

(cherry picked from commit a11009dccb)
2021-03-11 10:53:12 -05:00
Eric Joyner
1da549169d ice(4): Update to version 0.28.1-k
This updates the driver to align with the version included in
the "Intel Ethernet Adapter Complete Driver Pack", version 25.6.

There are no major functional changes; this mostly contains
bug fixes and changes to prepare for new features. This version
of the driver uses the previously committed ice_ddp package
1.3.19.0.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>

Tested by:	jeffrey.e.pieper@intel.com
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D28640

(cherry picked from commit d08b8680e1)
2021-03-09 14:35:54 -08:00
Alfredo Dal'Ava Junior
c80a1c1072 mpr: big-endian support
This fixes mpr driver on big-endian devices.
Tested on powerpc64 and powerpc64le targets using a SAS9300-8i card
(LSISAS3008 pci vendor=0x1000 device=0x0097)

Submitted by:	Andre Fernando da Silva <andre.silva@eldorado.org.br>
Reviewed by:	luporl, alfredo, Sreekanth Reddy <sreekanth.reddy@broadcom.com> (by email)
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D25785

(cherry picked from commit 71900a794d)
2021-03-09 21:09:24 -03:00
Jessica Clarke
e3394851b5 if_vtbe: Add missing includes to fix build
PR:		254137
Reported by:	Mina Galić <me@igalic.co>
Fixes:		f8bc74e2f4 ("tap: add support for virtio-net offloads")

(cherry picked from commit f2f8405cf6)
2021-03-08 21:04:40 +00:00
Xin LI
e298c1c3c2 arcmsr(4): Fixed no action of hot plugging device on type_F adapter.
Many thanks to Areca for continuing to support FreeBSD.

Submitted by:	黃清隆 <ching2048 areca com tw>
MFC after:	3 days

(cherry picked from commit 5842073a9b)
2021-03-05 17:46:04 -08:00
Peter Grehan
96aabea8bd Import wireguard fixes from pfSense 2.5
Merge the following fixes from https://github.com/pfsense/FreeBSD-src
 1940e7d3  Save	address	of ingress packets to allow wg to work on HA
 8f5531f1  Fix connection to IPv6 endpoint
 825ed9ee  Fix tcpdump for wg IPv6 rx tunnel traffic
 2ec232d3  Fix issue with replying to INITIATION messages in server mode
 ec77593a  Return immediately in wg_init if in DETACH'd state
 0f0dde6f  Remove unnecessary wg debug printf on transmit
 2766dc94  Detect and fix case in wg_init() where sockets weren't cleaned up
 b62cc7ac  Close the UDP tunnel sockets when the interface has been stopped

Obtained from:	pfSense 2.5
Relnotes:	yes
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 95331c228a)
2021-03-05 11:23:14 +10:00
Krzysztof Galazka
2b94bda05a ixl(4): Add ability to control link state on ifconfig down
Add sysctl link_active_on_if_down, which allows user to control
if interface is kept in active state when it is brought
down with ifconfig. Set it to enabled by default to preserve
backwards compatibility.

Reviewed by:	erj
Tested by:	gowtham.kumar.ks@intel.com
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D28028

(cherry picked from commit 21802a127d)
2021-03-04 17:23:19 -08:00
Krzysztof Galazka
b149f7c23d ixl(4): Report RX errors as sum of all RX error counters
HW keeps track of RX errors using several counters, each for
specific type of errors. Report RX errors to OS as sum
of all those counters: CRC errors, illegal bytes, checksum,
length, undersize, fragment, oversize and jabber errors.

There is no HW counter for frames with invalid L3/L4 checksums
so add a SW one.

Also add a "rx_errors" sysctl with a copy of netstat IERRORS
counter value to make it easier accessible from scripts.

Reviewed By:	erj
Tested By:	gowtham.kumar.ks@intel.com
Sponsored By:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D27639

(cherry picked from commit 9f99061ef9)
2021-03-04 17:23:18 -08:00
Piotr Pietruszewski
8fa11f8922 ix(4): Report RX errors as sum of all RX error counters
HW keeps track of RX errors using several counters, each for
specific type of errors. Report RX errors to OS as sum
of all those counters: CRC errors, illegal bytes, checksum,
length, undersize, fragment, oversize and jabber errors.

Also, add new "rx_errs" sysctl in the dev.ix.N.mac_stats tree. This is
to provide an another way to display the sum of RX errors.

Signed-off-by: Piotr Pietruszewski <piotr.pietruszewski@intel.com>

Reviewed By: erj
Tested By: gowtham.kumar.ks@intel.com
Sponsored By: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D27191

(cherry picked from commit afb1aa4e6d)
2021-03-04 17:23:18 -08:00
Krzysztof Galazka
7e166d608e ixl(4): Fix VLAN HW filtering
X700 family of controllers has limited number of available VLAN
HW filters. Driver did not handle properly a case when user
assigned more VLANs to the interface which had all filters
already in use. Fix that by disabling HW filtering when
it is impossible to create filters for all requested VLANs.
Keep track of registered VLANs using bitstring to be able
to re-enable HW filtering when number of requested VLANs
drops below the limit.

Also switch all allocations to use M_IXL malloc type
to ease detecting memory leaks in the driver.

Reviewed by:	erj
Tested by:	gowtham.kumar.ks@intel.com
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28137

(cherry picked from commit 7d4dceec10)
2021-03-04 17:23:18 -08:00
Alexander Motin
a00bf7d9bb Make DataSN counter of solicited Data-Out local.
DataSN for solicited Data-Out is per-R2T.  Since we handle whole R2T
in one go, we don't need to store it anywhere, especially in global
per-command structure.  This may allow us to handle multiple R2T per
command at once, if we decide, or may be relax locking.

Rename the second use of that field to io_referenced_task_tag.

MFC after:	1 month

(cherry picked from commit 3dd2a7a5ea)
2021-03-04 09:39:43 -05:00
Brett Mastbergen
135fa1610f pwm_backlight: Add MODULE_DEPEND on backlight
Make the pwm_backlight module depend on backlight, so it
has access to the backlight interface symbols.  Otherwise you'll
get an error like:

link_elf: symbol backlight_get_info_desc undefined

Signed-off-by: Brett Mastbergen <brett.mastbergen@gmail.com>
MFC after:	3 days
PR: 		253765
(cherry picked from commit 43d4dfac96)
2021-03-02 14:02:13 +01:00
Warner Losh
b22315c798 cardbus: Be sure to acquire Giant when calling into newbus
Acquire Giant in cardbus_detach_card. This used to be done above us, but no
more.

Tested by: kargl@
MFC After: 3 days

(cherry picked from commit c01da939b0)
2021-03-01 18:07:50 -07:00
Alexander Motin
1f3cff343b cxgb(4): Rework my commit 9dc7c250.
The previous implementation was reported to try to coalesce packets
in situations when it should not, that resulted in assertion later.
This implementation better checks the first packet of the chain for
the coallescing elligibility.

(cherry picked from commit d510bf133d)
2021-02-24 20:40:29 -05:00
Warner Losh
0b90164992 nvme: Make nvme_ctrlr_hw_reset static
nvme_ctrlr_hw_reset is no longer used outside of nvme_ctrlr.c, so
make it static. If we need to change this in the future we can.

(cherry picked from commit dd2516fc07)
2021-02-24 11:10:51 -07:00