Commit graph

40170 commits

Author SHA1 Message Date
John Baldwin
587ab8e019 msk: Use a void cast to mark values of dummy reads as unused.
Note that this required adding missing ()'s around the outermost level
of MSK_READ_MIB*.  Otherwise, the void cast was only applied to the
first register read.  This also meant that MSK_READ_MIB64 was pretty
broken as the uint64_t cast only applied to the first 16-bit register
read in each MSK_READ_MIB32 invocation and the 32-bit shift was only
applied to the second register read of the pair.

Reviewed by:	imp, emaste
Reported by:	GCC -Wunused-value
Differential Revision:	https://reviews.freebsd.org/D36777

(cherry picked from commit ae70e8838c)
2022-11-11 10:18:54 -08:00
John Baldwin
d77e67e9d5 msk: Don't bother reading spare stats registers.
msk_stats_update reads stats registers named "spare" whose values are
discarded.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D36871

(cherry picked from commit aabbe26939)
2022-11-11 10:18:54 -08:00
Warner Losh
2498e94fb6 msk: Remove write only variables, but leave hardware reads in place
Sponsored by:		Netflix

(cherry picked from commit 7e5c042cce)
2022-11-11 10:18:54 -08:00
John Baldwin
44c1914ee6 powerpc_nvram: Fix a bug in the adler32 checksum.
The Adler32 digest consists of two 16-bit words whose values are
calculated modulo 65521 (largest prime < 2^16).  To avoid two division
instructions per byte, this version copies an optimization found in
zlib which defers the modulus until close to the point that the
intermediate sums can overflow 2^32.  (zlib uses NMAX == 5552 for
this, this version uses 5000)

The bug is that in the deferred modulus case, the modulus was
only applied to the high word (and twice at that) but not to
the low word.  The fix is to apply it to both words.

Reviewed by:	jhibbits
Reported by:	Miod Vallat <miod@openbsd.org>
Differential Revision:	https://reviews.freebsd.org/D36798

(cherry picked from commit e0df0dce71)
2022-11-11 10:18:53 -08:00
John Baldwin
32560694f7 Fix various places which cast a pointer to a vm_paddr_t or vice versa.
GCC warns about the mismatched sizes on i386 where vm_paddr_t is 64
bits.

Reviewed by:	imp, markj
Differential Revision:	https://reviews.freebsd.org/D36750

(cherry picked from commit a9fca3b987)
2022-11-11 10:18:53 -08:00
John Baldwin
54c65cbb24 ntb: Use uintmax_t casts and %j to print physical addresses.
This fixes -Wint-to-pointer-cast errors with GCC when compiling on
i386 where physical addresses are not the same size as pointers.

Reviewed by:	mav, imp
Differential Revision:	https://reviews.freebsd.org/D36751

(cherry picked from commit 124e46735e)
2022-11-11 10:18:52 -08:00
John Baldwin
f771c03297 cxgbe: Use secq(9) to manage the timestamp generations.
This is mostly cosmetic, but it also doesn't leave a gap of time where
no structures are valid.  Instead, we permit the ISR to continue to
use the previous structure if the write to update cal_current isn't
yet visible.

Reviewed by:	gallatin
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D36669

(cherry picked from commit cee4fc7cad)
2022-11-10 17:26:44 -08:00
John Baldwin
2800e3a8ae cxgbe: Compute timestamps via sbintime_t.
This uses fixed-point math already used elsewhere in the kernel for
sub-second time values.  To avoid overflows this does require updating
the calibration once a second rather than once every 30 seconds.  Note
that the cxgbe driver already queries multiple registers once a second
for the statistics timers.  This version also uses fewer instructions
with no branches (for the math portion) in the per-packet fast path.

Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D36663

(cherry picked from commit 2c74c9dac3)
2022-11-10 17:26:27 -08:00
Navdeep Parhar
4546011557 cxgbe(4): Fix potential integer overflow in t4_tstmp_to_ns.
Coverity flagged this in its latest run but it is not a problem in
practice as the card's core clock would have to be > 4.2GHz for any
overflow to occur.

CID 1498303:  Integer handling issues  (OVERFLOW_BEFORE_WIDEN)
Potentially overflowing expression "sc->params.vpd.cclk * 1000U" with type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "uint64_t" (64 bits, unsigned).

Reported by:	Coverity Scan (CID 1498303)
Sponsored by:	Chelsio Communications

(cherry picked from commit 02fac928ab)
2022-11-10 17:26:17 -08:00
Konstantin Belousov
cbc43d4f1c cxgbe: fix kernel build without TCP_OFFLOAD or RATELIMIT
Reviewed by:	np
Fixes:	e398922eaf
Sponsored by:	Nvidia networking
Differential revision:	https://reviews.freebsd.org/D36648

(cherry picked from commit 8d42019058)
2022-11-10 17:26:05 -08:00
Mateusz Guzik
42e8cd31c1 cxgbe: fix the build after e398922eaf
(cherry picked from commit d0b235c715)
2022-11-10 17:25:57 -08:00
Randall Stewart
fb99512f32 Enable M_TSTMP in Chelsio cxgbe driver by creating a mechanism that can sync the time.
Chelsio has always been recording a timestamp in the mbuf (rcv_tstmp) but
not setting the M_TSTMP bit in the mbuf flags. This is because the timestamp
was just the free running 60bit clock. This change fixes that so that
we keep a synchronization by periodically (every 30 seconds after startup)
getting the timestamp and the current nanosecond time. We always keep
several sets around and the current one we always keep the current pair
and the previous pair of timestamps. This allows us to setup a ratio
between the two so we can correctly translate the time. Note that
we use special care to split the timestamp into seconds (per the clock tick)
and nanoseconds otherwise 64bit math would overflow.

Reviewed by: np
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D36315

(cherry picked from commit e398922eaf)
2022-11-10 17:25:52 -08:00
John Baldwin
56dad65305 cxgbe TOE TLS: Simplify a few routines.
Remove a few more remnants from the old pre-KTLS support and instead
assume that each work request sends a single TLS record.

Sponsored by:	Chelsio Communications

(cherry picked from commit c6b3a3772c)
2022-11-10 16:36:01 -08:00
John Baldwin
034af6afc5 cxgbe: Handle requests for TLS key allocations with no TLS key storage.
If an adapter advertises support for TLS keys but an empty TLS key
storage area in on-board memory, fail the request rather than invoking
vmem_alloc on an uninitialized vmem.

Sponsored by:	Chelsio Communications

(cherry picked from commit 1ca4f45ea8)
2022-11-10 16:35:47 -08:00
John Baldwin
38168ab37f cxgbe: Rename t4_kern_tls.c to t6_kern_tls.c.
This implementation of NIC TLS is specific to T6 adapters.

Sponsored by:	Chelsio Communications

(cherry picked from commit bbb2f53715)
2022-11-10 16:35:35 -08:00
John Baldwin
e0f86b61a0 cxgbe: De-duplicate some of the code for managing TLS key contexts.
The NIC TLS and TOE TLS modes in cxgbe(4) both work with TLS key
contexts.  Previously, TOE TLS supported TLS key contexts created by
two different methods, and NIC TLS had a separate bit of code copied
from NIC TLS but specific to KTLS.  Now that TOE TLS only supports
KTLS, pull common code for creating TLS key contexts and programming
them into on-card memory into t4_keyctx.c.

Sponsored by:	Chelsio Communications

(cherry picked from commit 18c69734e9)
2022-11-10 16:16:53 -08:00
John Baldwin
93cec8fde7 cxgbe tom: Remove orphaned function max_imm_tls_space().
Reported by:	markj
Fixes:		789f2d4b3f cxgbe tom: Remove support for non-KTLS TLS offload.
Sponsored by:	Chelsio Communications

(cherry picked from commit 6e26b4f8f4)
2022-11-10 16:16:05 -08:00
John Baldwin
9395c3cd96 cxgbe tom: Remove support for non-KTLS TLS offload.
TOE TLS offload was first supported via a customized OpenSSL developed
by Chelsio with proprietary socket options prior to KTLS being present
either in FreeBSD or upstream OpenSSL.  With the addition of KTLS in
both places, cxgbe's TOE driver was extended to support TLS offload
via KTLS as well.  This change removes the older interface leaving
only the KTLS bindings for TOE TLS.

Since KTLS was added to TOE TLS second, it was somehat shoe-horned
into the existing code.  In addition to removing the non-KTLS TLS
offload, refactor and simplify the code to assume KTLS, e.g. not
copying keys into a helper structure that mimic'ed the non-KTLS mode,
but using the KTLS session object directly when constructing key
contexts.

This also removes some unused code to send TX keys inline in work
requests for TOE TLS.  This code was never enabled, and was arguably
sending the wrong thing (it was not sending the raw key context as we
do for NIC TLS when using inline keys).

Sponsored by:	Chelsio Communications

(cherry picked from commit 789f2d4b3f)
2022-11-10 16:15:52 -08:00
John Baldwin
2c273cf4ce cxgbei: Return limits for the specific adapter the socket is on.
Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D34929

(cherry picked from commit 43d5661a9d)
2022-11-10 13:48:36 -08:00
John Baldwin
73c8e321ad iscsi: Fetch limits based on a socket rather than assuming global limits.
cxgbei needs the ability to return different limits based on the
connection (e.g. if the connection is over a T5 adapter or a T6
adapter as well as factoring in the MTU).

This change plumbs through the changes in the ioctls without changing
any of the backends.  The limits callback passed to icl_register now
accepts a second socket argument which holds the integer file
descriptor.  To support ABI compatiblity for old binaries, the
callback should return "global" values if the socket fd is zero.

The CTL_ISCSI_LIMITS argument used with CTL_ISCSI by ctld(8) now
accepts the socket fd in a field that was previously part of a
reserved spare field.  Old binaries zero this request which results in
passing a socket fd of 0 to the limits callback.

The ISCSIDREQUEST ioctl no longer returns limits.  Instead, iscsid(8)
invokes a new ISCSIDLIMITS ioctl after establishing the connection via
connect(2).  For ABI compat, if the old ISCSIDREQUEST is invoked, the
global limits are still fetched (with a socket fd of 0) and returned.

Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D34928

(cherry picked from commit 7b02c1e8c6)
2022-11-10 13:48:36 -08:00
John Baldwin
f5858d5551 arm64 hwpmc: Support restricting counters to user or kernel mode.
Support the "usr" and "os" qualifiers on arm64 events to restrict
event counting to either usermode or the kernel, respectively.  If
neither qualifier is given, events are counted in both.

Reviewed by:	emaste
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D34527

(cherry picked from commit 6bb7ba4aa1)
2022-11-10 13:04:56 -08:00
Gordon Bergling
d1e77e8fca mpt(4): Fix two typos in debug statements
- s/Intermidiate/Intermediate/

Obtained from:	NetBSD

(cherry picked from commit 00b0158d2c)
2022-11-10 09:02:02 +01:00
Gordon Bergling
bf72896aae smartpqi(4): Fix two typos in kernel error messages
- s/runnning/running/

(cherry picked from commit d53e97bb54)
2022-11-08 08:06:34 +01:00
Tetsuya Uemura
f5d1d22f25 nxprtc: Fix timing issue with register access.
My Adafruit PCF8523 RTC on either RPi2B or RPi3B+ failed to work around
80 ~ 90 % of boot-ups, by printing the following log lines.

nxprtc0: <NXP PCF8523 RTC> at addr 0xd0 on iicbus0
nxprtc0: cannot set up timer
Warning: no time-of-day clock registered, system time will not be set accurately

This is due to pcf8523_start_timer(sc) returned non-zero in
nxprtc_start() due to a register read failure of PCF8523_R_TMR_A_FREQ or
PCF8523_R_TMR_CLKOUT or a failure to program a new value.

The pause_sbt("nxpbat") sleep was too short and caused the register
access failures.

PR: 266093
(cherry picked from commit e2386f18ec)
2022-11-04 15:50:05 -06:00
Gordon Bergling
4139292c45 isci(4): Fix a typo in a source code comment
- s/interrutp/interrupt/

(cherry picked from commit 5014dc958f)
2022-11-04 06:06:16 +01:00
Gordon Bergling
442fb2ee10 isci(4): Fix common typos in source code comments
- s/assinged/assigned/

(cherry picked from commit 816d5c1e98)
2022-11-04 06:06:02 +01:00
Gordon Bergling
d7561c0423 bxe(4): Fix a typo in a source code comment
- s/interrutps/interrupts/

(cherry picked from commit e902e62644)
2022-11-04 06:05:32 +01:00
Kyle Evans
cd36563956 extres: regulator: fix the build without FDT
The regnode interface is currently only built for FDT, thus not
applicable to ACPI-only kernels.  Move the "regnode_if.h" include
underneath a previously existing FDT cpp segment.

Reviewed by:	andrew, imp, manu

(cherry picked from commit 23c318ed86)
2022-11-02 12:02:25 -05:00
Kyle Evans
3c631d2f19 extres: syscon: pull in sys/malloc.h (fix !FDT)
syscon currently includes sys/malloc.h via header pollution from
dev/ofw/ofw_bus.h -> dev/ofw/openfirm.h.  Fix the build without FDT
defined by including sys/malloc.h directly.

Reviewed by:	andrew, imp, manu

(cherry picked from commit 79794d5c18)
2022-11-02 12:02:25 -05:00
Kyle Evans
af0995b7f3 uart: uart_cpu_arm64: fix the build without FDT
clang 14 doesn't properly determine that we're unconditionally returning
if we have ACPI but not FDT.  Push FDT setup entirely into a new
function, much like we currently do with ACPI, and just return ENXIO if
that doesn't succeed.

Reviewed by:	andrew, manu (earlier version)

(cherry picked from commit 4a4ad02da3)
2022-11-02 12:02:24 -05:00
Mitchell Horne
501f703023 usb: musb_otg_allwinner: de-constify bus_space_tags
The SAN interceptors simply take a bus_space_tag_t, so we're
dropping qualifiers here.  const semantics with a ptr typedef mean we'd
have to drop or change the bus_space_tag_t abstraction used in the SAN
sanitizers in order to make a compatible change there, which likely
isn't worth it.

Reviewed by:	andrew, markj
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.

(cherry picked from commit 26d786331b)
2022-11-02 12:02:24 -05:00
Kyle Evans
4a7fe8305e psci: set psci_present as early as possible
psci_attach is way too late to provide the intended semantics for
psci_present.  psci calls can be made immediately after psci_init(),
called way earlier at SI_SUB_CPU + SI_ORDER_FIRST, and we need it to
be valid as early as we can possibly call a psci function.

This fixes booting RPi3+4 with the in-review spintable patch;
rpi3-psci-monitor patches the FDT to add a PSCI node, but it doesn't
patch each cpus' enable-method.  Because of this, we would stall the
boot while enabling CPU 1 as we saw a valid looking enable-method and
"no" functional PSCI and attempted to use the spintable rather than
simply not starting secondary APs.

Fixes:	2218070b2c ("psci: finish psci_present implementation")
Reported by:	karels

(cherry picked from commit 866beaa0aa)
2022-11-01 23:11:09 -05:00
Gordon Bergling
fe557f61e7 ocs_fc(4): Fix a typo in an error message
- s/faild/failed/

(cherry picked from commit dabebd0ba2)
2022-10-30 04:41:21 +01:00
Gordon Bergling
c89b2fb09a firewire(4): Fix a typo in an error message
- s/faild/failed/

(cherry picked from commit c03e35accc)
2022-10-30 04:41:04 +01:00
Gordon Bergling
2293e1df00 qlnxe(4): Fix a typo in a source code comment
- s/defult/default/

(cherry picked from commit 5daf88ea5e)
2022-10-29 07:04:54 +02:00
Gordon Bergling
29ed1247ea arcmsr(4): Fix a typo in a source code comment
- s/faild/failed/

(cherry picked from commit 24a630de81)
2022-10-28 10:56:03 +02:00
Alexander Motin
7e53019b06 Add random VMware device IDs.
Just to make dmesg look nicer there.

MFC after:	1 week

(cherry picked from commit 2a31a06bf1)
2022-10-26 22:48:56 -04:00
Doug Moore
d0fb642b64 rb_tree: let insert search start from next node
When the node to insert in the rb_tree is known to precede or follow a
particular node, new methods RB_INSERT_PREV and RB_INSERT_NEXT,
defined here, allow the search for where to insert the new node begin
with that particular node, rather than at the root, to save a bit of
time.

Using those methods, instead of RB_INSERT, in managing a tree in
iommu_gas.c, saves a little time.

Reviewed by:	kib
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D35516

(cherry picked from commit 368ee2f86a)
2022-10-23 19:43:22 -05:00
Kenneth D. Merry
2edc70060d Fix mpr(4) panic during a firmware update.
Issue Description:
The RequestCredits field of IOCFacts got changed between the Phase23
firmware to Phase24 firmware. So as part of firmware update operation,
driver has to free the resources & pools which are created with the Phase23
Firmware's IOCFacts data (i.e. during driver load time) and has to
reallocate the resources and pools using Phase24's IOCFacts data. Here
driver has freed the interrupts but missed to reallocate the interrupts and
hence config page read operation is getting timed out and controller is
going for recursive reinit (controller reset) operations and leading to
kernel panic.

Fix:
Reallocate the interrupts if the interrupts are disabled as part of
firmware update/downgrade operation.

Submitted by:	Sreekanth Ready <sreekanth.reddy@broadcom.com>
Tested by:	ken
MFC after:	3 days

(cherry picked from commit 11778fca4a)
2022-10-20 11:01:03 -04:00
Alexander Motin
c68313cdf5 ioat: Add Ice Lake ID.
MFC after:	2 weeks

(cherry picked from commit e4e91353c6)
2022-10-20 10:22:23 -04:00
Alexander Motin
b106d43705 vmd: Add DID 8086:7D0B and 8086:AD0B for Intel MTL SKUs
MFC after:	2 weeks

(cherry picked from commit 9bce114106)
2022-10-20 10:22:23 -04:00
Alexander Motin
5e98842589 vmd: Bypass MSI/MSI-X remapping when possible.
By default all VMD devices remap children MSI/MSI-X interrupts into their
own.  It creates additional isolation, but also complicates things due to
sharing, etc.  Fortunately some VMD devices can bypass the remapping.
Add tunable to control it for remap testing or if something go wrong.

MFC after:	2 weeks

(cherry picked from commit c28220d866)
2022-10-20 10:22:23 -04:00
Warner Losh
f51c1d1dd5 pvscsi: Advertise maxio of 256k.
While the PV SCSI SG list can handle 512k of SG entries, it can only do
so for I/O that's aligned to 4k or better. newfs_msdos does unaligned
I/O, so triggers too long for host errors in cam when a 512k I/O is
attempted. Prefer power of 2 256k to the absolute maximum 508k, though
that can be revisited should the latter show to give significant
performance improvement.

MFC After:		3 days
Tested by:		darius on discord (508k version of patch)
Sponsored by:		Netflix

(cherry picked from commit 9a5a5c1576)
2022-10-19 13:47:45 -04:00
Mitchell Horne
b34de75d61 Downgrade tty_intr_event from a global
It can be static within uart_tty.c. It is an open question whether there
remains any real benefit to having uart instances share a swi thread.

Reviewed by:	imp, markj, jhb
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36938

(cherry picked from commit 05b727fee5)
2022-10-19 10:46:46 -03:00
Yan Ka Chiu
95d3300d22
ixl(4): Fix SR-IOV panics
The hw and ifp of a vsi will be NULL if such ixl_vsi is allocated
for a VF. When ixl_reconfigure_filters called, it is trying to
access vsi->ifp and hw->mac.addr and therefore is casuing panic.

This commit add checks to determine if vsi is a VF by checking
if vsi->hw is NULL, before adding IXL_VLAN_ANY filter (which
is already in a VF vsi's filter list) and VLAN filters.

(erj's Note: The SR-IOV flows need revisiting; this will help
prevent panics for now)

Reviewed by:	krzysztof.galazka@intel.com, erj@
Differential Revision:	https://reviews.freebsd.org/D35649

(cherry picked from commit e706512a2b)
2022-10-17 21:19:41 -07:00
Krzysztof Galazka
2ff0054334
ixl(4): Add support for I710 devices and remove non-inclusive language
Intel introduces a new line of 1G Ethernet adapters
with Device ID 0x0DD2. While at that also remove
non-inclusive language.

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

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

(cherry picked from commit b7b40e4a38)
2022-10-17 21:19:41 -07:00
Eric Joyner
152fa6f5b0
ice(4): Add RDMA Client Interface
This allows the "irdma" driver to communicate with the ice(4)
driver to allow it access to the underlying device's hardware
resources as well as synchronize access to shared resources.

This interface already existed in the standalone out-of-tree
1.34.2 driver; this commit adds and enables it in the in-kernel
driver.

Note:

Adds hack to module Makefile to compile interface/.m files

These are required for the RDMA client interface, but they don't
build as-is like the normal .c files. The source directory doesn't
seem to be included by default, so add lines that specifically
add them as libraries so that ice_rdma.h can be found and the
interface files will compile.

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

Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D30889

(cherry picked from commit 8a13362d49)
(cherry picked from commit d8cce8145c)
2022-10-17 21:19:36 -07:00
Alexander Motin
03acc85e3f pci: Disable Electromechanical Interlock.
Add sysctl/tunable to control Electromechanical Interlock support.
Disable it by default since Linux does not do it either and it seems
the number of systems having it broken is higher than having working.

This fixes NVMe backplane operation on ASUS RS500A-E11-RS12U server
with AMD EPYC 7402 CPU, where attempts to control reported interlock
for some reason end up in PCIe link loss, while interlock status does
not change (it is not really there).

MFC after:	2 weeks

(cherry picked from commit a58536b91a)
2022-10-17 21:02:36 -04:00
Kyle Evans
2258cf3624 pci_host_generic: stop address translation in bus_alloc_resource
Translating the provided range prior to rman_reserve_resource(9) is
decidedly wrong; the caller may be trying to do a wildcard allocation,
for which the implementation is expected to DTRT and clamp the range to
what's actually feasible.

We don't use the resulting translation here anyways, so just remove it
entirely -- the rman in the default implementation is derived from
sc->ranges, so the translation should trivially succeed every time as
long as the reservation succeeded.  If something has gone awry in a
derived driver, we'll detect it when we translate prior to activation,
so there's likely no diagnostic value in retaining the translation after
reservation either.

Reviewed by:	andrew
Noticed by:	jhb

(cherry picked from commit bd93b5f79a)
2022-10-17 10:36:59 -05:00
Kevin Bowling
0f95623db5 igc: Fix up hw vlan ops
Adapt 2796f7cab1 to igc(4)

* Don't reset the entire adapter for vlan changes, fix up the problems
* Remove the VFTA, this hardware doesn't seem to implement it

Approved by:	grehan
Differential Revision:	https://reviews.freebsd.org/D31979

(cherry picked from commit 2eaef8ec4a)
2022-10-16 20:36:01 -07:00