Commit Graph

135825 Commits

Author SHA1 Message Date
Mark Johnston
98d788c867 opencrypto: Fix assignment of crypto completions to worker threads
Since r336439 we simply take the session pointer value mod the number of
worker threads (ncpu by default).  On small systems this ends up
funneling all completion work through a single thread, which becomes a
bottleneck when processing IPSec traffic using hardware crypto drivers.
(Software drivers such as aesni(4) are unaffected since they invoke
completion handlers synchonously.)

Instead, maintain an incrementing counter with a unique value per
session, and use that to distribute work to completion threads.

Reviewed by:	cem, jhb
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D28159
2021-01-19 20:34:35 -05:00
Mark Johnston
d181624889 opencrypto: Embed the driver softc in the session structure
Store the driver softc below the fields owned by opencrypto.  This is
a bit simpler and saves a pointer dereference when fetching the driver
softc when processing a request.

Get rid of the crypto session UMA zone.  Session allocations are
frequent or performance-critical enough to warrant a dedicated zone.

No functional change intended.

Reviewed by:	cem, jhb
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D28158
2021-01-19 20:34:35 -05:00
Robert Watson
adc96a51a5 Add a new FreeBSD/arm64 kernel configuration, GENERIC-MMCCAM-NODEBUG,
which is the same as GENERIC-MMCCAM but using a nodebug baseline.

Reviewed by:		andrew, br (earlier version), jrtc27 (earlier version)
Differential revision:	https://reviews.freebsd.org/D28091
2021-01-19 22:26:20 +00:00
Alex Richardson
a81c165bce Require uint32_t alignment for ipfw_insn
There are many casts of this struct to uint32_t, so we also need to ensure
that it is sufficiently aligned to safely perform this cast on architectures
that don't allow unaligned accesses. This fixes lots of -Wcast-align warnings.

Reviewed By:	ae
Differential Revision: https://reviews.freebsd.org/D27879
2021-01-19 21:23:25 +00:00
Alex Richardson
be5972695f libalias: Fix remaining compiler warnings
This fixes some sign-compare warnings and adds a missing static to a
variable declaration.

Differential Revision: https://reviews.freebsd.org/D27883
2021-01-19 21:23:24 +00:00
Alex Richardson
bc596e5632 libalias: Fix -Wcast-align compiler warnings
This fixes -Wcast-align warnings caused by the underaligned `struct ip`.
This also silences them in the public functions by changing the function
signature from char * to void *. This is source and binary compatible and
avoids the -Wcast-align warning.

Reviewed By:	ae, gbe (manpages)
Differential Revision: https://reviews.freebsd.org/D27882
2021-01-19 21:23:24 +00:00
John Baldwin
8e9313caa6 Convert unmapped mbufs before computing checksums in IPsec.
This is similar to the logic used in ip_output() to convert mbufs
prior to computing checksums.  Unmapped mbufs can be sent when using
sendfile() over IPsec or using KTLS over IPsec.

Reported by:	Sony Arpita Das @ Chelsio QA
Reviewed by:	np
Sponsored by:	Chelsio
Differential Revision:	https://reviews.freebsd.org/D28187
2021-01-19 11:52:00 -08:00
John Baldwin
c6e27f5697 arm64: Clear FPU flags in the pcb in cpu_copy_thread().
New threads start off with clean FPU state instead of inheriting state
from the parent thread.

PR:		247945
Sponsored by:	Netflix
2021-01-19 11:05:48 -08:00
John Baldwin
c7f3aa34cf arm64: Trim duplicate code from cpu_fork_kthread_handler().
cpu_fork_kthread_handler() is always called after either cpu_fork() or
cpu_copy_thread().  The arm64 version was duplicating some of the work
already done by both of those functions.

Sponsored by:	Netflix
2021-01-19 11:05:41 -08:00
Lutz Donnerhacke
fa6662b368 ixl: Permit 802.1ad frames to pass though the chip
This patch is a quick hack to change the internal Ethertype used
within the chip.  All frames with this type are dropped silently.
This patch allows you to overwrite the factory default 0x88a8, which
is used by IEEE 802.1ad VLAN stacking.

Reviewed by:	kp, philip, brueffer
Approved by:	kp (mentor)
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D24179
2021-01-19 16:01:09 +01:00
Andriy Gapon
2c98edd6d6 htu21: driver for HTU21D I2C temperature and humidity sensor
MFC after:	2 weeks
Relnotes:	perhaps
2021-01-19 15:08:51 +02:00
Mateusz Guzik
38baca17e0 lockmgr: fix upgrade
TRYUPGRADE requests kept failing when they should not have due to wrong
macro used to count readers.

Fixes:	f6b091fbbd ("lockmgr: rewrite upgrade to stop always dropping the lock")
Noted by:	asomers
Differential Revision:	https://reviews.freebsd.org/D27947
2021-01-19 12:21:38 +00:00
Michal Meloun
f635cef2a4 arm64 busdma: Fix loading of small bounced buffers.
- Don't oversize the buffer fragment. PAGE_SIZE - (curaddr & PAGE_MASK)
   may be greater than the total length of the buffer.
 - Don't use roundup2(len, alignment) to calculate the buffer fragment
   size. The length of current bounced fragment is not subject to alignment
   restriction, and next fragment should start at the page boundary.

Tested by:	bz, s199p.wa1k9r@gmail.com
2021-01-19 13:09:17 +01:00
Edward Tomasz Napierala
c987d6a677 linux: map EBUSY returned by ptrace into ESRCH
The ptrace(2) Linux man page claims the syscall returns ESRCH,
if the tracee is not stopped; the native ptrace(2) returns EBUSY.

Sponsored by:	The FreeBSD Foundation
2021-01-19 11:21:55 +00:00
Edward Tomasz Napierala
47f7345bab linux: fix PTRACE_POKEDATA and PTRACE_POKETEXT.
Sponsored by:	The FreeBSD Foundation
2021-01-19 10:30:55 +00:00
Edward Tomasz Napierala
7d3310c4fc linux: remove spurious newline.
Sponsored by:	The FreeBSD Foundation
2021-01-19 09:56:45 +00:00
Mateusz Guzik
57dab0292a cache: fix some typos 2021-01-19 10:17:14 +01:00
Mateusz Guzik
84ab77ad27 cache: drop-write only var from cache_fplookup_preparse 2021-01-19 10:13:30 +01:00
Mateusz Guzik
6d386b4c8a cache: save a branch in cache_fplookup_next
Previously the code would branch on top find out whether it should
branch on SDT probe and bumping the numposhits counter, depending
on cache_fplookup_cross_mount.

Arguably it should be done regardless of what said function returns.
2021-01-19 10:08:24 +01:00
Bryan Venteicher
e6cc42f181 virtio: Handle possible failure of virtio_finalize_features()
Try to standardize how drivers negotiate feature and the
function names

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27930
2021-01-19 04:55:26 +00:00
Bryan Venteicher
2bfab35774 if_vtnet: Add counter for received host LRO
Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27928
2021-01-19 04:55:26 +00:00
Bryan Venteicher
475a60aec7 if_vtnet: Misc Tx path cleanup
- Add and fix a few error path counters
  - Improve sysctl descriptions
  - Use flags consistently to determine IPv4 vs IPv6

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27926
2021-01-19 04:55:26 +00:00
Bryan Venteicher
6b53aeed91 if_vtnet: Set lro_nsegs for host LRO packets
Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27933
2021-01-19 04:55:25 +00:00
Bryan Venteicher
74cd316a09 if_vtnet: Resort softc fields
Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27925
2021-01-19 04:55:25 +00:00
Bryan Venteicher
33b5433fd7 if_vtnet: Remove unnecessary TUNABLE_INTs because of CTLFLAG_RDTUN
Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27923
2021-01-19 04:55:25 +00:00
Bryan Venteicher
4f18e23f84 if_vtnet: Schedule Rx task if pending items when enabling interrupt
Prior to V1, the driver would enable interrupts and then notify the
host that DRIVER_OK. Since for V1, DRIVER_OK needs to be set before
notifying the virtqueues, there may be items in the queues waiting
to be processed by the time interrupts are enabled.

This fixes a bug where the Rx queue would appear stuck, only being
usable after an interface down/up cycle.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27922
2021-01-19 04:55:25 +00:00
Bryan Venteicher
c3187190c7 if_vtnet: Disable F_MTU feature if MTU is invalid
Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27931
2021-01-19 04:55:25 +00:00
Bryan Venteicher
bd8809df20 if_vtnet: Limit allocations of unused virtqueues
For multiqueue, we may use fewer than the provided maximum number of
queues. Try to limit allocations of the unused queues: no interrupts,
no indirect descriptors, and no taskqueues.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27921
2021-01-19 04:55:25 +00:00
Bryan Venteicher
b470419ea5 if_vtnet: Rework 4be723f63 max multiqueue pairs check
Verify the max_virtqueue_pairs is within the range allowed by
the spec.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27920
2021-01-19 04:55:25 +00:00
Bryan Venteicher
42343a6316 if_vtnet: Add support for software LRO
This useful when running on hosts that support checksum offloading
but not the GUEST_TSO (LRO) feature. Or potentially, some GRO-like
support when doing forwarding.

Only enable SW LRO when the host LRO is not available since both
tends to be harmful, and difficult to enable/disable selectively
with only a single IFCAP_LRO flag.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27919
2021-01-19 04:55:25 +00:00
Bryan Venteicher
177761e4c4 if_vtnet: Set the interface max TSO values
Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27917
2021-01-19 04:55:25 +00:00
Bryan Venteicher
e36a6b1b1f if_vtnet: Add support for CTRL_GUEST_OFFLOADS feature
This allows the Rx checksum and LRO to be modified without a full
reinit of the device.

Remove IFCAP_RXCSUM_IPV6 from the interface capabilities since in
VirtIO Rx checksums are just enabled or disabled for all protocols.

Properly update IFCAP_LRO if LRO is becomes disabled when Rx
checksums are disabled.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27916
2021-01-19 04:55:25 +00:00
Bryan Venteicher
dc9029d863 if_vtnet: Move ioctl handlers into separate functions
Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27914 https://reviews.freebsd.org/D27915
2021-01-19 04:55:25 +00:00
Bryan Venteicher
44559b26af if_vtnet: Cleanup the reinit process
In modern VirtIO, the virtqueues cannot be notified before setting
DRIVER_OK status.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27932
2021-01-19 04:55:25 +00:00
Bryan Venteicher
32e0493c92 if_vtnet: Cleanup the interface setup methods
Defer the ether_ifattach until the interface capabilities
are configured

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27913
2021-01-19 04:55:25 +00:00
Bryan Venteicher
2520cd3821 if_vtnet: Only set IFCAP_JUMBO_MTU when jumbo MTU is supported
Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27912
2021-01-19 04:55:24 +00:00
Bryan Venteicher
baa5234fbe if_vtnet: Move the Tx interrupt threshold into the Txq structure
Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27911
2021-01-19 04:55:24 +00:00
Bryan Venteicher
05041794d0 if_vtnet: Defer updating generated MAC address until attached
This improves spec compliance because the driver is not suppose
to notify the device prior to setting the DRIVER_OK status, which
could happen with the VIRTIO_NET_F_CTRL_MAC_ADDR.

The VIRTIO_NET_F_MAC feature should always be negotiated so would
be a rare situation.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27910
2021-01-19 04:55:24 +00:00
Bryan Venteicher
25dbc30ef5 if_vtnet: Remove at attach PROMISC handling
This may have been required in an early, early, early version of the
specification but I cannot find any reference to it, and a promiscuous
default seems very odd so remove this code.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27909
2021-01-19 04:55:24 +00:00
Bryan Venteicher
6a73339365 if_vtnet: Support VIRTIO_NET_F_SPEED_DUPLEX
This features lets the guest driver know the speed and duplex of
the "link". Instead of trying to support many media types based
on the possible/likely speeds/duplexes, only use the speed to
set the interface baudrate.

Cleanup ifmedia code to match other drivers.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27908
2021-01-19 04:55:24 +00:00
Bryan Venteicher
aabdf5b6e8 if_vtnet: Support VIRTIO_NET_F_MTU
This feature lets the guest driver know the maximum MTU size
supported by the host device. If set, use this to limit the
acceptable MTUs, and improve how the receive mbuf cluster size
then is selected.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27907
2021-01-19 04:55:24 +00:00
Bryan Venteicher
fa7ca1e332 if_vtnet: Rx path cleanup
- Fix the NEEDS_CSUM and DATA_VALID checksum flags. The NEEDS_CSUM
    checksum is incomplete (partial) so offer a fallback for the driver
    to calculate the checksum. Simplify DATA_VALID because we know
    the host has validated the checksum.

  - Default 4K mbuf clusters for mergeable buffers. May need to
    scale this down to 2K clusters in certain configurations such
    many queue pairs, big queues (like 4096 in GCP), and low memory.

  - Use the MTU when calculated the receive mbuf cluster size
    when not doing TSO/LRO. This will need more adjustment once
    the MTU feature is supported.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27906
2021-01-19 04:55:24 +00:00
Bryan Venteicher
149ab110dd virtio_blk: Use DISKFLAG_WRITE_PROTECT for RO disks
Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27905
2021-01-19 04:55:24 +00:00
Bryan Venteicher
5e22081177 if_vtnet: Add initial modern (V1) support
Very basic support to get packets flowing on modern QEMU but still
several conformance issues remain that will be addressed in later
commits.

First of many passes at cleaning up various accumulated cruft

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27904
2021-01-19 04:55:24 +00:00
Bryan Venteicher
15be49535d virtio_scsi: Add modern (V1) support
Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27903
2021-01-19 04:55:24 +00:00
Bryan Venteicher
d7f979bed0 virtio_blk: Add modern (V1) support
Rework the header file changes from 2cc8a52 to use our
canonical upstream, Linux.

geom_disk already checks DISKFLAG_CANDELETE for BIO_DELETE
so remove an unnecessary check.

Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27902
2021-01-19 04:55:24 +00:00
Bryan Venteicher
edf7c8ddce virtio_console: Add modern (V1) support
Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27901
2021-01-19 04:55:24 +00:00
Bryan Venteicher
f7f9c266e4 virtio_balloon: Add modern (V1) support
Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27900
2021-01-19 04:55:23 +00:00
Bryan Venteicher
d2536a25cc virtio_random: Add modern (V1) support
Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27899
2021-01-19 04:55:23 +00:00
Bryan Venteicher
703f17d60f virtio_pci: Add sysctl to show current features
Reviewed by: grehan (mentor)
Differential Revision: https://reviews.freebsd.org/D27898
2021-01-19 04:55:23 +00:00