rge: Make the TX watchdog reset the chip
If the cable is pulled, and re-inserted, the driver does not
re-establish any connections, inet nor inet6. rge_init_locked() returns
too early when IFF_DRV_RUNNING is set, so the watchdog's reset doesn't
help, only a full ifconfig rge0 down/up is sufficient.
Clearing the flag & calling rge_init_locked() addresses this, but it
takes around 5 seconds to completely recover.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D62221
rge(4): Implement RTL8125 UDP hardware workaround
Directly quoting Kevin Lo <kevlo at openbsd.org>
"The RTL8125/RTL8125B parses short udp frames for ptp messages.
If a frame shorter than 175 bytes reads port 319 or 320 where the chip
expects the udp destination port and fewer than 47 bytes of udp data follow,
the transmitter stops for good."
Separately, the hw doesn't checksum frames shorter than 60 bytes
properly.
We get around both by padding and computing the checksums for these frames.
Both OpenBSD and Linux have implemented a similar workaround [1][2].
[1] https://marc.info/?l=openbsd-tech&m=179358733449818&w=2
[2] https://github.com/torvalds/linux/commit/8d520b4de3edca4f4fb242b5ddc659b6a9b9e65e
Signed-off-by: Aaron Espinoza <acesp25 at freebsd.org>
[3 lines not shown]
sglist: Cosmetic cleanups to sglist_join
- Don't create an out-of-bounds pointer in flast. Instead, use NULL
for the case that first is empty for a more deterministic failure.
- Use a helper variable to de-duplicate an expression
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D62005
sglist: Correct order of operands to bcopy in sglist_join
This was trashing the second list with uninitialized garbage from the
first list.
Reviewed by: markj
Fixes: b36cfff75df4 ("Add a simple API to manage scatter/gather...")
Differential Revision: https://reviews.freebsd.org/D62004
sglist: Avoid an out-of-bounds access in sglist_append_sglist
If the destination sglist is empty, then the first matching segment
from the source sglist should be added as the first segment in the
destination list. This happened to work by accident when sg_nseg was
a u_short as ss pointed to the sglist header which never had a
matching paddr so _sglist_append_range fell through to appending a new
range, but that was still buggy. After sg_nseg changed to an unsigned
int, the initial ss now points way out of range on 64-bit platforms
resulting in reading from a random (possibly unmapped) kernel address.
Reported by: llm-postcr
Reviewed by: markj
Fixes: 00f6cd3f5682 ("Add sglist_append_sglist().")
Differential Revision: https://reviews.freebsd.org/D62003
mgb: Add PCI11010 support
The Microchip PCI11010 is a PCIe switch with embedded multi-Gigabit
Ethernet controller. Only a new PCI ID is needed, as commit
da8a529bc01f ("mgb: support for PCI11414.") added required new
functionality.
Reviewed by: br
Sponsored by: The FreeBSD Foundation
Sponsored by: Microchip (hardware)
Differential Revision: https://reviews.freebsd.org/D62208
nvme: do not submit Abort commands with the qpair lock held
The Abort for a timed-out admin command is submitted to the queue
whose lock the watchdog holds. For an I/O command, a failed admin
queue completes the Abort during submission, and nvme_abort_complete()
takes the I/O takes the I/O qpair lock again.
Either way the thread recurses on a non-recursive mutex.
Abort command: NVM Express Base Specification 2.4, section 5.2.1.
Fixes: 2a6b7055a980 ("nvme: Timeout expired transactions")
Reviewed by: rz_fabmicro.ru, ngie
Differential Revision: https://reviews.freebsd.org/D61625
unr(9): fix iterator with trivial unit allocations
Hoist the check that we've scanned all the unrs to the top of the
loop since none might have been allocated e.g., if we've only used
allocated units in order with alloc_unr() and never freed any.
Add a test of the trivial case.
Reviewed by: kib, markj
Sponsored by: Innovate UK
Fixes: a014e0a3987a ("unr(9): add iterator interface")
Differential Revision: https://reviews.freebsd.org/D62139
dummynet: mark sysctls as CTLFLAG_VNET
sysctl_hash_size() and sysctl_limits() read and write V_dn_cfg, the current
VNET's dummynet configuration, but their sysctls lack CTLFLAG_VNET, so a VNET
jail reads its own values (100 slots, 64 buckets) and cannot set them: a queue
longer than 100 packets cannot be configured in a jail, and the host's setting
Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")
pf: fix error handling in pf_ioctl_addrule()
If we bail out of pf_ioctl_addrule() before the pf_addr_setup() calls
the subsequent pf_free_rule() will end up dereferencing a NULL pointer.
Check for NULL before freeing dynaddr or tables.
PR: 301184
Submitted by: laamalif at proton.me
Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")
pfsync: account for second tickover in bulk updates
When one peer requests a bulk update it keeps track of when it sent this
request. The exporting peer includes 'endtime', indicating how long it
took to send the entire update along with its final message.
That allows the receiving peer to verify that the entire update was done
in response to its most recent request. However, due to different second
tickovers this calculation might be off by one.
Use milliseconds internally. This does not change the wire protocol,
'endtime' is still expressed in seconds. When the exporting peer
computes this value it will implicitly round down.
PR: 300824
Sponsored by: Rubicon Communications, LLC ("Netgate")
cpufreq_dt: Do not use an uninitialised OPP when restoring the state
cpufreq_dt_set() only looks up the current OPP (copp) when the voltage
cannot be read from the regulator. When it can, which is the usual
case, copp is never set but the two error paths that restore the
previous state still use it: a failure to set the clock reads the
voltage limits of copp and a failure to lower the voltage reads its
frequency.
Restore the frequency with the one that was read from the clock before
the change, and look up the current OPP when the voltage has to be
restored, skipping it if there is none.
Fixes: a701764e9c50 ("Improve cpufreq_dt.")
Reported by: llm-postcr
cpufreq_dt: Use all the OPPs when the hardware version is unknown
An OPP with opp-supported-hw is only used if the hardware version, given
by the vendor specific code, matches it. When no vendor class handles
the OPP table, for example the ones of the TI and i.MX SoCs, the version
is unknown, so every OPP that has the property was dropped and the table
ended up empty. The driver still attached and cpufreq_dt_find_opp()
returned a pointer to an entry that does not exist, using an
uninitialised index.
Use all the OPPs when the hardware version is unknown, as if the
property was not there, which is what the driver did before the
property was honored. Also make cpufreq_dt_find_opp() return NULL for
an empty table, as its callers already expect.
Fixes: 7178a47a4ffd ("cpufreq_dt: Honor opp-supported-hw and opp-microvolt-<name>")
Reported by: llm-postcr
rtwn: fix the build without RTWN_DEBUG
RTWN_DPRINTF() compiles to nothing without RTWN_DEBUG, which leaves four
of the IQK result copies in r92f_iq_calib() set but never read. Kernels
with "device rtwn" in their config, LINT among them, then fail with
-Werror,-Wunused-but-set-variable. The module build does not hit this
because its generated opt_rtwn.h always defines RTWN_DEBUG.
Print the result array directly and drop the four locals.
Fixes: 1f0e186e1832 ("rtwn: added support for Realtek RTL8192FU...")
Sponsored by: Rubicon Communications, LLC ("Netgate")
amd64: Avoid redundant CR0 writes on switches to kernel threads
fpu_activate_sw() sets CR0.TS whenever it switches to a kernel thread,
or to a thread inside fpu_kern_enter(). The bit is clear only while a
thread owns the FPU, and at a context switch the only possible owner is
the old thread. When fpcurthread is NULL the bit is already set and
the write to CR0, which is serializing, changes nothing. That is the
common case for switches between kernel threads, such as the idle
thread and interrupt threads on a router.
Write CR0 only when fpcurthread was set, as cpu_switch() did before
the eager FPU switch became the default in d1a07e31e5cc, and assert
that TS is set otherwise.
Reviewed by: kib
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D62206
nfsclrdma: Fix a few things in the RDMA client module
This patch fixes a few things in the nfsclrdma module:
- A typo that caused _rpcrdma_get_srcaddr() to return 0
when it should have returned 1.
- Don't consider a server returning RPC_SYSTEMERROR or
RPC_FAILED as needing a new connection, to be compatible
with clnt_vc.c for TCP.
- Fix off by one checks in the KASSERT()s for the RPC index.
Reported by: llm-postcr
MFC after: 1 month
Fixes: 80bee4d83637 ("nfsclrdma: Add code to support client side NFS over RDMA")
libsys: do not link in csu, and compile as freestanding
This is a library below implementation of the C runtime. It should not
(and really cannot) use any of that.
In particular, libsys no longer has undef __cxa_finalize.
Reviewed by: brooks, jrtc27
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D62131
libsys: this is libsys, not libc
Reviewed by: brooks, jrtc27
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D62131
libsys: link internal copies of fls*(3), str*(3), and mem*(3) functions used by libsys
To avoid undef symbols which get resolved from libc.
Reviewed by: brooks, jrtc27
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D62131