]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 months agoSchedule fast taskqueue callouts on right CPU.
Alexander Motin [Wed, 27 Dec 2023 03:30:56 +0000 (22:30 -0500)]
Schedule fast taskqueue callouts on right CPU.

With fast taskqueues using direct callouts we can reduce number of
CPU wakeups by scheduling callout on current CPU if taskqueue calls
taskqueue_enqueue_timeout() on itself.  The trick won't work for
regular taskqueues, since the callout thread will occupy the CPU.
It also may not work in case of multiple threads since we do not
know which thread will pick the task, and we do not want excessive
callout migrations.  So we optimize only the other cases we can.

In practice this allows iichid(4) taskqueue to stay on CPU where
underlying ig4(4) interrupts are routed and to not kick CPU 0 with
timer interrupts on each sampling period (every 2nd/3rd sleep).

MFC after: 1 month

(cherry picked from commit 7bbac6419d174c98cc6ea969b68fcfe0f9a9bab8)

5 months agomail: add volatile in grabh()
Lexi Winter [Thu, 4 Jan 2024 22:34:58 +0000 (22:34 +0000)]
mail: add volatile in grabh()

setjmp() requires that any stack variables modified between the setjmp
call and the longjmp() must be volatile.  This means that 'saveint' in
grabh() must be volatile, since it's modified after the setjmp().
Otherwise, the signal handler is not properly restored, resulting in a
crash (SIGBUS) if ^C is typed twice while composing.

PR: 276119
Reported by: Christopher Davidson <christopher.davidson@gmail.com>
MFC after: 2 weeks
Pull Request: https://github.com/freebsd/freebsd-src/pull/993

(cherry picked from commit 6c951b37170f1fb2ae8b4827070743e61b6eaed2)

5 months agousr.bin/gh-bc: fix missing LTO support after MFC
Stefan Eßer [Fri, 19 Jan 2024 08:19:38 +0000 (09:19 +0100)]
usr.bin/gh-bc: fix missing LTO support after MFC

Restore exclusion of powerpc64 and mips* from LTO, which has been lost
by the MFC of the fix for the WITHOUT_NLS_CATALOGS case.

5 months ago13.3: update stable/13 to -PRERELEASE
Colin Percival [Thu, 18 Jan 2024 18:30:03 +0000 (10:30 -0800)]
13.3: update stable/13 to -PRERELEASE

This marks the start of the FreeBSD 13.3 release cycle; the stable/13
tree is now in "code slush".

Developers are encouraged to prioritize fixing bugs (and/or merging bug
fixes from HEAD) over new features at this time.  Commit approval from
re@ is not required but if new features introduce problems they may be
removed from the release.

Approved by: re (implicit)

5 months agox86: Adjust base addr for PCI MCFG regions
Colin Percival [Wed, 27 Dec 2023 08:09:08 +0000 (00:09 -0800)]
x86: Adjust base addr for PCI MCFG regions

Each bus gets 1 MB of address space; the actual base address for an
MCFG bus range is the address from the table plus the starting bus
number times 1 MB.

The PCI spec is unclear on this point, but this change matches what
Linux does, which is likely enough of a de facto standard regardless
of what any de jure standard might attempt to say.

Fixes: f54a3890b1f4 ("x86: Support multiple PCI MCFG regions")
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D43206

(cherry picked from commit 61e2161367bb4e68e603f53b1107f9427f988861)

5 months agox86: Support multiple PCI MCFG regions
John Baldwin [Wed, 29 Nov 2023 18:32:39 +0000 (10:32 -0800)]
x86: Support multiple PCI MCFG regions

In particular, this enables support for PCI config access for domains
(segments) other than 0.

Reported by: cperciva
Tested by: cperciva (m7i.metal-48xl AWS instance)
Reviewed by: imp
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D42828

(cherry picked from commit f54a3890b1f419d4a9edc99000efef52b9071b8f)

5 months agox86: Refactor pcie_cfgregopen
John Baldwin [Wed, 29 Nov 2023 18:32:16 +0000 (10:32 -0800)]
x86: Refactor pcie_cfgregopen

Split out some bits of pcie_cfgregopen that only need to be executed
once into helper functions in preparation for supporting multiple MCFG
entries.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D42829

(cherry picked from commit 9893a4fd31fa4b2e19a7b9cf786f49b9de50b407)

5 months agopci_cfgreg: Add shims to preserve ABI of pci_cfgreg(read|write)
John Baldwin [Thu, 18 Jan 2024 23:19:11 +0000 (15:19 -0800)]
pci_cfgreg: Add shims to preserve ABI of pci_cfgreg(read|write)

This is a direct commit to stable/14 to preserve the ABI of the
the pci_cfgregread and pci_cfgregwrite functions.   The new routines
are renamed to add a _domain suffix and macros map the new API to
the new functions.

Note: No API compatibility has been provided as modules in ports
should not be using this internal API (normal PCI drivers use
pci_read_config and pci_write_config with a device_t).

(cherry picked from commit b5d2a06b2c4f50fd20774928602a3b5f0f27b127)

5 months agopci_cfgreg: Add a PCI domain argument to the low-level register API
John Baldwin [Wed, 29 Nov 2023 18:31:47 +0000 (10:31 -0800)]
pci_cfgreg: Add a PCI domain argument to the low-level register API

This commit changes the API of pci_cfgreg(read|write) to add a domain
argument (referred to as a segment in ACPI parlance) (note that this
is not the same as a NUMA domain, but something PCI-specific).  This
does not yet enable access to domains other than 0, but updates the
API to support domains.

Places that use hard-coded bus/slot/function addresses have been
updated to hardcode a domain of 0.  A few places that have the PCI
domain (segment) available such as the acpi_pcib_acpi.c Host-PCI
bridge driver pass the PCI domain.

The hpt27xx(4) and hptnr(4) drivers fail to attach to a device not on
domain 0 since they provide APIs to their binary blobs that only
permit bus/slot/function addressing.

The x86 non-ACPI PCI bus drivers all hardcode a domain of 0 as they do
not support multiple domains.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D42827

(cherry picked from commit 1587a9db92c03c738bb3f0fc5874b43c961e7c99)

5 months agoctladm: Fix a typo and add a FALLTHROUGH annotation
John Baldwin [Wed, 27 Dec 2023 18:10:42 +0000 (10:10 -0800)]
ctladm: Fix a typo and add a FALLTHROUGH annotation

Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D42934

(cherry picked from commit e8d83548349d8cafadd1f95667fd8b055b228931)

5 months agocltadm.8: Correct documentation of -r arg to port command
John Baldwin [Wed, 27 Dec 2023 18:10:05 +0000 (10:10 -0800)]
cltadm.8: Correct documentation of -r arg to port command

-r does not take a target port argument

Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D42932

(cherry picked from commit f12d378f4f3f3b06597d6f11eaf320d26d8318b2)

5 months agosys: Use mbufq_empty instead of comparing mbufq_len against 0
John Baldwin [Tue, 9 Jan 2024 19:00:46 +0000 (11:00 -0800)]
sys: Use mbufq_empty instead of comparing mbufq_len against 0

Reviewed by: bz, emaste
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D43338

(cherry picked from commit 8cb9b68f5821e45c63ee08d8ee3029ca523ac174)

5 months agombuf: Add mbufq_empty
John Baldwin [Tue, 9 Jan 2024 19:00:19 +0000 (11:00 -0800)]
mbuf: Add mbufq_empty

Complement to the existing mbufq_full

Reviewed by: bz
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D43337

(cherry picked from commit 76f405ed63540aa2d989c231f70277062e76ccfb)

5 months agonet80211 amdpu: Simplify a few loops that drain an mbufq
John Baldwin [Tue, 9 Jan 2024 18:59:48 +0000 (10:59 -0800)]
net80211 amdpu: Simplify a few loops that drain an mbufq

These loops already handled a NULL return from mbufq_dequeue when the
queue was empty, so remove a redundant check of mbufq_len before
dequeueing.

Reviewed by: bz
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D43336

(cherry picked from commit 6977311633c73f594ff3dae150d6d1fe06105a8f)

5 months agosys: Style fix for M_EXT | M_EXTPG
John Baldwin [Thu, 28 Dec 2023 19:17:59 +0000 (11:17 -0800)]
sys: Style fix for M_EXT | M_EXTPG

Add a space around the | operator in places testing for either M_EXT
or M_EXTPG.

Reviewed by: imp, glebius
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D43216

(cherry picked from commit f7d5900aa063c6e9d19e6372ba981fc76aa326a2)

5 months agombuf.9: Document mtodo
John Baldwin [Thu, 28 Dec 2023 19:17:22 +0000 (11:17 -0800)]
mbuf.9: Document mtodo

mtodo() accepts an mbuf and offset and returns a void * pointer to the
requested offset into the mbuf's associated data.  Similar to mtod(),
no bounds checking is performed.

Reviewed by: imp, markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D43215

(cherry picked from commit 854e1fd692185749fea092b1431efd4a8e09c2eb)

5 months agoacpi: Only reserve resources enumerated via _CRS
John Baldwin [Tue, 9 Jan 2024 19:23:10 +0000 (11:23 -0800)]
acpi: Only reserve resources enumerated via _CRS

In particular, don't reserve resources added by drivers via other
means (e.g. acpi_bus_alloc_gas which calls bus_alloc_resource
right after adding the resource).

The intention of reserved resources is to ensure that a resource range
that a bus driver knows is assigned to a device is reserved by the
system even if no driver is attached to the device.  This prevents
other "wildcard" resource requests from conflicting with these
resources.  For ACPI, the only resources the bus driver knows about
for unattached devices are the resources returned from _CRS.  All of
these resources are already reserved now via acpi_reserve_resources
called from acpi_probe_children.

As such, remove the logic from acpi_set_resource to try to reserve
resources when they are set.  This permits RF_SHAREABLE to work with
acpi_bus_alloc_gas without requiring hacks like the current one for
CPU device resources in acpi_set_resource.

Reported by: gallatin (RF_SHAREABLE not working)
Diagnosed by: jrtc27

(cherry picked from commit c6a488511ab1fbae8d16264b9e83c85024c9e1ce)

5 months agokldxref: Workaround incorrect PT_DYNAMIC in existing powerpc kernels
John Baldwin [Tue, 9 Jan 2024 18:57:48 +0000 (10:57 -0800)]
kldxref: Workaround incorrect PT_DYNAMIC in existing powerpc kernels

Existing powerpc kernels include additional sections beyond .dynamic
in the PT_DYNAMIC segment.  Relax the requirement for an exact size
match of the section and segment for PowerPC files as a workaround.

Reported by: jrtc27
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D43123

(cherry picked from commit 6631e2f9b49e08f53c7beb560ee8509c343b3927)

5 months agokldxref: Correct contract number in license ACK
John Baldwin [Tue, 9 Jan 2024 01:01:05 +0000 (17:01 -0800)]
kldxref: Correct contract number in license ACK

Reviewed by: brooks
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D43371

(cherry picked from commit 78258ee013cfec2145060cc4c25d66f075db36d3)

5 months agokldxref: fix bootstrapping on Linux with Clang 16
Alex Richardson [Tue, 2 Jan 2024 19:06:51 +0000 (11:06 -0800)]
kldxref: fix bootstrapping on Linux with Clang 16

The glibc fts_open() callback type does not have the second const
qualifier and it appears that Clang 16 errors by default for mismatched
function pointer types. Add an ifdef to handle this case.

(cherry picked from commit 30887c7d48ead8a9151627228244dd3ed95c4c6d)

5 months agokldxref: Appease a Coverity warning
John Baldwin [Fri, 22 Dec 2023 15:49:40 +0000 (07:49 -0800)]
kldxref: Appease a Coverity warning

While parsing .dynamic, nsym is set when parsing the symbol table from
.dynsym.  That parsing also sets ef->ef_symtab to a non-NULL value.
The value of nsym isn't validated until after a check for
ef->ef_symtab being NULL, so nsym always has a valid value when it is
read.  However, that chain of events is a bit much for static analysis
to follow, so initialize nsym to 0 before parsing sections to quiet
the warning.

Reported by: Coverity Scan
CID: 1532339
Sponsored by: DARPA

(cherry picked from commit d281fece432f97b4424b852f23dfe1f974b9e30d)

5 months agokldxref: Simplify handling of ELF object files
John Baldwin [Fri, 22 Dec 2023 15:49:18 +0000 (07:49 -0800)]
kldxref: Simplify handling of ELF object files

Unlike the backend for ELF DSOs, the object file backend allocated an
aligned chunk of memory and read all of the in-memory sections from
the file into this memory even though most of the file contents were
never used.  Instead, just track a set of virtual addresses (based at
0) that each loaded section would be loaded at and only read the
necessary bits from the backing file when needed.

Reviewed by: imp
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D43126

(cherry picked from commit 0d557cdf6f0e94e909acea065f3de2a28437ae74)

5 months agokldxref: Simplify elf_read_raw_data
John Baldwin [Fri, 22 Dec 2023 15:49:03 +0000 (07:49 -0800)]
kldxref: Simplify elf_read_raw_data

Use pread as a valid offset is always passed now.  Originally the DSO
code read the .hash section in two separate requests and relied on the
implicit offset for the second read, but now the hash table is fetched
in a single call.

Reviewed by: imp
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D43125

(cherry picked from commit ed96fd7fc652d77ae5e34727e54610e87854defc)

5 months agokldxref: Tidy error handling for invalid addresses
John Baldwin [Fri, 22 Dec 2023 15:48:47 +0000 (07:48 -0800)]
kldxref: Tidy error handling for invalid addresses

- Don't print an offset value that's always zero.

- ef_get_offset can't return -1.

Reviewed by: imp
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D43124

(cherry picked from commit 6d46e2e0a7f345459fb42e666c7cb2e987c70857)

5 months agokldxref: Reduce divergence between per-architecture files
Jessica Clarke [Thu, 14 Dec 2023 20:17:20 +0000 (20:17 +0000)]
kldxref: Reduce divergence between per-architecture files

Note that relbase is always 0 for DSOs so its omission for __KLD_SHARED
architectures was not a bug in practice.

Whilst here, also parenthesise the dest offset for where to avoid
transiently creating an out-of-bounds pointer, which is UB (though even
on CHERI architectures, where capability bounds compression can result
in that creating invalid capabilities that will trap on dereference,
optimisation will reassociate to the correct form in practice and thus
work just fine).

(cherry picked from commit 2a622f14e8a588de654847ae264cdc3616528c9d)

5 months agokldxref: Implement aarch64 R_AARCH64_AB64 relocation
Jessica Clarke [Thu, 14 Dec 2023 20:17:20 +0000 (20:17 +0000)]
kldxref: Implement aarch64 R_AARCH64_AB64 relocation

Doing nothing seems to be sufficient but is strange, inconsistent with
other architectures, and not necessary when it's easy to support
properly.

(cherry picked from commit aaba1490ec4b17dea750b1e58dfded7aeb4e9816)

5 months agokldxref: Fix MIPS Elf_Rel addend computation
Jessica Clarke [Thu, 14 Dec 2023 20:17:19 +0000 (20:17 +0000)]
kldxref: Fix MIPS Elf_Rel addend computation

Fixes: 0299afdff145 ("kldxref: Make use of libelf to be a portable cross tool")
(cherry picked from commit ae7925cafeee1136bd1761b2ce75614ee47b0039)

5 months agokldxref: Add arm support
Jessica Clarke [Thu, 14 Dec 2023 18:27:09 +0000 (18:27 +0000)]
kldxref: Add arm support

(cherry picked from commit c88f7d8fb54051366d91acfc6c80aca6154da3b4)

5 months agokldxref: Put each ef_CPUARCH.c on its own line to prepare for ef_arm.c
Jessica Clarke [Thu, 14 Dec 2023 18:27:09 +0000 (18:27 +0000)]
kldxref: Put each ef_CPUARCH.c on its own line to prepare for ef_arm.c

Adding ef_arm.c would push this past 80 columns, so prepare for its
addition by splitting the line up.

(cherry picked from commit ada9d12f951201e13d831edc10acc36dd37d625e)

5 months agokldxref: Fix for 32-bit powerpc
Jessica Clarke [Thu, 14 Dec 2023 16:37:34 +0000 (16:37 +0000)]
kldxref: Fix for 32-bit powerpc

R_PPC_RELATIVE lost its 32-bit handling in the libelf conversion.

Reported by: bapt
Fixes: 0299afdff145 ("kldxref: Make use of libelf to be a portable cross tool")

(cherry picked from commit d1ce87ae0ddca413b098b6be8f5d3b4da87422ef)

5 months agokldxref: Cast rtype to int in ef_aarch64.c in warning
John Baldwin [Wed, 13 Dec 2023 20:17:44 +0000 (12:17 -0800)]
kldxref: Cast rtype to int in ef_aarch64.c in warning

This is consistent with the other architecture-specific relocation
handlers.

Reported by: mjg
Sponsored by: DARPA

(cherry picked from commit 894f3f48c3ea27a6f0f54850595ff48db9ee4861)

5 months agokldxref: fix build on 32 bits arches
Baptiste Daroussin [Wed, 13 Dec 2023 08:19:18 +0000 (09:19 +0100)]
kldxref: fix build on 32 bits arches

(cherry picked from commit 97530894fc142a9c44a5909e6ae668dc95a5036a)

5 months agokldxref: Make use of libelf to be a portable cross tool
John Baldwin [Tue, 12 Dec 2023 23:43:00 +0000 (15:43 -0800)]
kldxref: Make use of libelf to be a portable cross tool

This allows kldxref to operate on kernel objects from any
architecture, not just the native architecture.  In particular, this
will permit generating linker.hints files as part of a cross-arch
release build.

- elf.c is a new file that includes various wrappers around libelf
  including routines to read ELF data structures such as program and
  section headers and ELF relocations into the "generic" forms
  described in <gelf.h>.  This file also provides routines for
  converting a linker set into an array of addresses (GElf_Addr)
  as well as reading architecture-specific mod_* structures and
  converting them into "generic" Gmod_* forms where pointers are
  replaced with addresses.

- The various architecture-specific reloc handlers now use GElf_*
  types for most values (including GElf_Rel and GElf_Rela for
  relocation structures) and use routines from <sys/endian.h> to read
  and write target values.  A new linker set matches reloc handlers
  to specific ELF (class, encoding, machine) tuples.

- The bits of kldxref.c that write out linker.hints now use the
  encoding (ELFDATA2[LM]SB) of the first file encountered in a
  directory to set the endianness of the output file.  Input files
  with a different architecture in the same directory are skipped with
  a warning.  In addition, the initial version record for the file
  must be deferred until the first record is finished since the
  architecture of the output file is not known until then.

- Various places that used 'sizeof(void *)' throughout now use
  'elf_pointer_size()' to determine the size of a pointer in the
  target architecture.

Tested by: amd64 binary on both amd64 and i386 /boot/kernel
Reviewed by: imp
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D42966

(cherry picked from commit 0299afdff145e5d861797fe9c2de8b090c456fba)

5 months agokldxref: Refactor PNP entry parsing, no functional change
John Baldwin [Tue, 12 Dec 2023 23:30:16 +0000 (15:30 -0800)]
kldxref: Refactor PNP entry parsing, no functional change

- Add a free_pnp_list to complement parse_pnp_list.  Add freeing
  of 'new_desc' which was previously leaked.

- Move body of loop that checked a single pnp list element against a
  table entry into a parse_pnp_entry function to reduce indentation
  and split parse_entry into a smaller function.

- Similarly, split out a record_pnp_info function from parse_entry
  which builds the pnp_list and walks a table.

Reviewed by: imp
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D42965

(cherry picked from commit c40fa3dc98d3cd8c39605c19c9cc08026d8e72c9)

5 months agocr_bsd_visible(): Style fixes
Olivier Certner [Fri, 5 Jan 2024 15:23:19 +0000 (16:23 +0100)]
cr_bsd_visible(): Style fixes

Explicitly test for non-zero return codes.

Separate assignment and testing of 'error' in distinct lines.

Reviewed by:            emaste, kib
Approved by:            emaste (mentor)
MFC after:              1 week
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43335

(cherry picked from commit a1e37beb45d270ae9926eff3b93e9398d08c94e5)

Approved by:            markj (mentor)

5 months agolibthr: thr_attr.c: EINVAL, not ENOTSUP, on invalid arguments
Olivier Certner [Fri, 24 Nov 2023 21:21:16 +0000 (22:21 +0100)]
libthr: thr_attr.c: EINVAL, not ENOTSUP, on invalid arguments

On first read, POSIX may seem ambiguous about the return code for some
scheduling-related pthread functions on invalid arguments.  But a more
thorough reading and a bit of standards archeology strongly suggests
that this case should be handled by EINVAL and that ENOTSUP is reserved
for implementations providing only part of the functionality required by
the POSIX option POSIX_PRIORITY_SCHEDULING (e.g., if an implementation
doesn't support SCHED_FIFO, it should return ENOTSUP on a call to, e.g.,
sched_setscheduler() with 'policy' SCHED_FIFO).

This reading is supported by the second sentence of the very definition
of ENOTSUP, as worded in CAE/XSI Issue 5 and POSIX Issue 6: "The
implementation does not support this feature of the Realtime Feature
Group.", and the fact that an additional ENOTSUP case was added to
pthread_setschedparam() in Issue 6, which introduces SCHED_SPORADIC,
saying that pthread_setschedparam() may return it when attempting to
dynamically switch to SCHED_SPORADIC on systems that doesn't support
that.

glibc, illumos and NetBSD also support that reading by always returning
EINVAL, and OpenBSD as well, since it always returns EINVAL but the
corresponding code has a comment suggesting returning ENOTSUP for
SCHED_FIFO and SCHED_RR, which it effectively doesn't support.

Additionally, always returning EINVAL fixes inconsistencies where EINVAL
would be returned on some out-of-range values and ENOTSUP on others.

Reviewed by:            markj
Approved by:            markj (mentor)
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43006

(cherry picked from commit 0eccb45979a8ee3129e11b638ebc4cfa00942b80)

Approved by:            markj (mentor)

5 months agolibthr: thr_attr.c: Clarity, whitespace and style
Olivier Certner [Fri, 24 Nov 2023 16:00:53 +0000 (17:00 +0100)]
libthr: thr_attr.c: Clarity, whitespace and style

Also, remove most comments, which don't add value.

Reviewed by:            emaste
Approved by:            markj (mentor)
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43005

(cherry picked from commit bd61c1e89dc4a40ba696de1785d423978e1c2147)

Approved by:            markj (mentor)

5 months agouart(4): Honor hardware state of NS8250-class for tsw_busy
Marius Strobl [Fri, 12 Jan 2024 22:27:07 +0000 (23:27 +0100)]
uart(4): Honor hardware state of NS8250-class for tsw_busy

In 9750d9e5, I brought the equivalent of the TS_BUSY flag back in a
mostly hardware-agnostic way in order to fix tty_drain() and, thus,
TIOCDRAIN for UARTs with TX FIFOs. This proved to be sufficient for
fixing the regression reported. So in light of the release cycle of
FreeBSD 10.3, I decided that this change was be good enough for the
time being and opted to go with the smallest possible yet generic
(for all UARTs driven by uart(4)) solution addressing the problem at
hand.

However, at least for the NS8250-class the above isn't a complete
fix as these UARTs only trigger an interrupt when the TX FIFO became
empty. At this point, there still can be an outstanding character
left in the transmit shift register as indicated via the LSR. Thus,
this change adds the 3rd (besides the tty(4) and generic uart(4) bits)
part I had in my tree ever since, adding a uart_txbusy method to be
queried in addition for tsw_busy and hooking it up as appropriate
for the NS8250-class.

As it turns out, the exact equivalent of this 3rd part later on was
implemented for uftdi(4) in 9ad221a5.

While at it, explain the rational behind the deliberately missing
locking in uart_tty_busy() (also applying to the generic sc_txbusy
testing already present).

(cherry picked from commit 353e4c5a068d06b0d6dcfa9eb736ecb16e9eae45)

5 months agoigb(4): Remove disconnected SYSCTL
Marius Strobl [Tue, 9 Jan 2024 22:01:46 +0000 (23:01 +0100)]
igb(4): Remove disconnected SYSCTL

The global hw.igb.rx_process_limit knob never was adhered to by the
in-tree version of this driver but similar functionality is available
via the device-specific dev.igb.N.iflib.rx_budget.

While at it, remove the - besides initialization of tx_process_limit -
unused {r,t}x_process_limit members.

(cherry picked from commit f221d35be7a5749e2a1246c81adc9c03c1dc545c)

5 months agoe1000(4): Remove disconnected SYSCTL
Marius Strobl [Tue, 9 Jan 2024 21:41:49 +0000 (22:41 +0100)]
e1000(4): Remove disconnected SYSCTL

The global hw.em.rx_process_limit knob has been replaced by the device-
specific dev.IF.N.iflib.rx_budget along with the conversion to iflib(4).

While at it, remove the - besides initialization of tx_process_limit -
unused {r,t}x_process_limit members.

(cherry picked from commit 0d6d28ce5650d1cd23dbe4bbac87fb103b3e2d3d)

5 months agousr.bin/gh-bc: fix Makefile for WITHOUT_NLS_CATALOGS case
Stefan Eßer [Sat, 29 Jul 2023 18:52:53 +0000 (20:52 +0200)]
usr.bin/gh-bc: fix Makefile for WITHOUT_NLS_CATALOGS case

Some macro definitions had been moved into a Makefile section
that depends on MK_NLS_CATALOGS != "no", leading to LTO and the
installation of tests being disabled in the WITHOUT_NLS_CATALOGS
case.

Reported by: Yuri <yuri@aetern.org>

(cherry picked from commit 382af2f8d7bf576ff583543737e1134701ccc63d)

5 months agovendor/bc: MFC upgrade from version 6,6.0 to 6.7.5
Stefan Eßer [Mon, 30 Oct 2023 09:10:24 +0000 (10:10 +0100)]
vendor/bc: MFC upgrade from version 6,6.0 to 6.7.5

This is a squashed updated consisting of:

vendor/bc: upgrade to version 6.7.2

This update improves the implementation of the power function p() and
adds 3 new functions to the extended math library: min(), max(), and
i2rand().

(cherry picked from commit aa339f1d5df9e38f36a34eb522355c4eebcae6c4)

vendor/bc: upgrade to version 6.7.4

Documentation updates only, no functional changes to the software.

(cherry picked from commit e6857bd4d7b4bf39ea32b9dcd34f8371164c356e)

vendor/bc: upgrade to version 6.7.5

This update fixes a bug where line breaks in printed numbers may not
match the line length set by the user. The value is printed correctly,
just not split as specified in some situations.

(cherry picked from commit f4fbc49d201f81c481a33fac6ba28e19faf96260)

5 months agoAdd vnode_pager_clean_{a,}sync(9)
Konstantin Belousov [Mon, 8 Jan 2024 05:18:40 +0000 (07:18 +0200)]
Add vnode_pager_clean_{a,}sync(9)

(cherry picked from commit b068bb09a1a82d9fef0e939ad6135443a959e290)

5 months agovnode_pager_generic_putpages(): rename maxblksz local to max_offset
Konstantin Belousov [Tue, 9 Jan 2024 11:32:39 +0000 (13:32 +0200)]
vnode_pager_generic_putpages(): rename maxblksz local to max_offset

(cherry picked from commit ed1a88a3116a59b4fd37912099a575b4c8f559dc)

5 months agovnode_pager_generic_putpages(): correctly handle clean block at EOF
Konstantin Belousov [Mon, 8 Jan 2024 13:21:06 +0000 (15:21 +0200)]
vnode_pager_generic_putpages(): correctly handle clean block at EOF

PR: 276191

(cherry picked from commit bdb46c21a3e68d4395d6e0b6a205187e655532b0)

5 months agouniq: Replace NetBSD's unit tests with our own.
Dag-Erling Smørgrav [Fri, 12 Jan 2024 15:40:26 +0000 (16:40 +0100)]
uniq: Replace NetBSD's unit tests with our own.

These new tests cover more functionality and are easier to extend.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D43381

(cherry picked from commit e762fd81e253d4ae9b9f7d2e65cf448633bbe527)

uniq: Fix interactive use.

Output a line as soon as it is possible to determine that it will have
to be output.  For the basic case, this means output each line as it is
read unless it is identical to the previous one.  For the -d case, it
means output the first instance as soon as the second is read, unless
the -c option was also given.  The -D and -u cases were already fine.

Add test cases for interactive use with no options and with -d.

Explicitly ignore -d when -D is also specified.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: rew, kevans
Differential Revision: https://reviews.freebsd.org/D43382

(cherry picked from commit 11715600e626cf6cc4b4f564af97f6ae1e5fb0be)

uniq: Clean up and test obsolete options.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D43402

(cherry picked from commit e2ec8ee02a33e39b8ff86a56e8a1ef5e84ac7e62)

uniq: Error out if writing to the output failed.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D43407

(cherry picked from commit 899837e8f5741f9a847b63d9e7c8b76ccc033ab5)

5 months agouniq(1): use strtonum to parse options
Daniel Tameling [Sat, 25 Feb 2023 17:25:51 +0000 (10:25 -0700)]
uniq(1): use strtonum to parse options

Previously strtol was used and the result was directly cast to an int
without checking for an overflow. Use strtonum instead since it is
safer and tells us what went wrong.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/643

(cherry picked from commit e052829e3e16dfd82d0adcbb69fd0e30f47a3a6c)

5 months agologin: Use getpwnam_r() instead of getpwnam().
Dag-Erling Smørgrav [Fri, 12 Jan 2024 15:40:22 +0000 (16:40 +0100)]
login: Use getpwnam_r() instead of getpwnam().

Since we expect the entry to still be valid after calling into PAM,
which may call getpwnam() itself, we need to use getpwnam_r().

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, imp, allanjude, markj
Differential Revision: https://reviews.freebsd.org/D43376

(cherry picked from commit a3d80dd8aa6ac15877e00102ab174b417ac81d79)

login: Missed an instance of getpwnam().

Fixes: a3d80dd8aa6ac15877e00102ab174b417ac81d79
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D43423

(cherry picked from commit 1e25eb287f3fdd763df98065dbf2e1eb201e4000)

5 months agoasa: Rewrite to fix line termination issue.
Dag-Erling Smørgrav [Tue, 9 Jan 2024 14:09:41 +0000 (15:09 +0100)]
asa: Rewrite to fix line termination issue.

The standard is somewhat unclear, but on the balance, I believe that the
phrase “the rest of the input line” should be interpreted to mean the
rest of the input line including the terminating newline if and only if
there is one.  This means the current implementation is incorrect on two
points:

- First, it suppresses the previous line's newline in the '1' case.

- Second, it unconditionally emits a newline at the end of the output
  for non-empty input, even if the input did not end with a newline.

Resolve this by rewriting the main loop.  Instead of special-casing the
first line and then assuming that every line ends with a newline, we
remember how each line ends and emit that either at the beginning of
the next line or at the end of the file except in the one case ('+')
where the standard explicitly says not to.

While here, try to reduce diff to upstream a little and update their
RCS tag to reflect the fact that while we've diverged significantly
from them, we've incorporated all their changes.  Remove the useless
second RCS tag.

We also update the tests to account for the change in interpretation
of the '1' case and add a test case for unterminated input.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D43326

(cherry picked from commit c2356a440db91c106867d45c94b3d6d7bc0e50f0)

5 months agofind: Add a warning about -delete.
Dag-Erling Smørgrav [Thu, 21 Dec 2023 23:41:05 +0000 (00:41 +0100)]
find: Add a warning about -delete.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: pauamma_gundo.com
Differential Revision: https://reviews.freebsd.org/D43162

(cherry picked from commit 45438f9c8b5b91ebf5606b4a98e891559913d25b)

5 months agocp: Add tests for hard link case.
Dag-Erling Smørgrav [Wed, 13 Dec 2023 21:31:05 +0000 (22:31 +0100)]
cp: Add tests for hard link case.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D43052

(cherry picked from commit 1fead66b64822f3f8106ad09bef0b9656836fa1a)

cp: Add tests for symbolic link case.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, allanjude
Differential Revision: https://reviews.freebsd.org/D43054

(cherry picked from commit d3a8e9b43b4cef5b80e3845dfa8fd1fec6e568f9)

cp: Refactor the core logic.

Rewrite `copy_file()` so the lflag and sflag are handled as early as
possible instead of constantly checking that they're not set and then
handling them at the end.  This also opens the door to changing the
failure logic at some future point (for instance, we might decide to
fall back to copying if `errno` indicates that the file system does not
support links).

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, allanjude
Differential Revision: https://reviews.freebsd.org/D43055

(cherry picked from commit d002316fd7bf0b359ea2f5518f3c10f6ad89a9ac)

cp: Split the basic_symlink test case in two.

This test case tests two different things: first, that copying a symlink
results in a file with the same contents as the target of the symlink,
rather than a second symlink, and second, that cp will refuse to copy a
file to itself, or to a link to itself, or a link to its target.  Leave
the first part in basic_symlink, move the second part to a new test case
named samefile, and slightly expand both cases.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D43062

(cherry picked from commit ac56b9d83c75f548667912ffe422be6bd4f5c27e)

cp: Move the flags around a bit.

- The HLPR flags are grouped together at the beginning because they are
  the standard flags for programs using FTS.  Move the N flag out from
  among them to its correct place in the sequence.
- The Pflag variable isn't used outside main(), but moving it out lets
  us skip initialization and keeps it with its friends H, L and R.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D43063

(cherry picked from commit 0f4467ce444b201468d2268958130f495951ca3c)

cp: Further simplify the core logic.

If the destination file exists but we decide unlink it, set the dne
flag.  This means we don't need to re-check the conditions that would
have caused us to delete the file when we later need to decide whether
to create or replace it.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D43064

(cherry picked from commit 38509270663f336103273878cc8ddc88a225b9d8)

cp: Move the -N flag in the manual page.

This accidentally got left out of 0f4467ce444b.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, allanjude
Differential Revision: https://reviews.freebsd.org/D43067

(cherry picked from commit 53fc8e190241233d94e183f8a39ec39f2154dfa8)

5 months agocp: Add -N flag, inspired by NetBSD's similar flag
Warner Losh [Thu, 7 Dec 2023 19:32:27 +0000 (12:32 -0700)]
cp: Add -N flag, inspired by NetBSD's similar flag

Add -N to supress copying of file flags when -p is specified (explicitly
or implicitly). Often times we don't care about the flags or wish to be
able to copy to NFS, and this comes in handy for that. FreeBSD's and
NetBSD's cp are somewhat different, so I had to reimplement all but one
of the patch hunks...

Obtained from: NetBSD (cp.1 1.25, cp.c 1.37, utils.c 1.28 by elad)
Sponsored by: Netflix

Differential Revision: https://reviews.freebsd.org/D42673

(cherry picked from commit 5a52e3d00dd5e0209f6fcb1e41b5985191e6f4e7)

cp: Don't warn for chflags() failing with EOPNOTSUPP if flags == 0

From NetBSD's utils.c 1.5 importing importing BSDI change, with light
formatting changes:
    Author: cgd <cgd@NetBSD.org>
    Date:   Wed Feb 26 14:40:51 1997 +0000

    Patch from BSDI (via Keith Bostic):
    >NFS doesn't support chflags; ignore errors unless there's reason
    >to believe we're losing bits.  (Note, this still won't be right
    >if the server supports flags and we were trying to *remove* flags
    >on a file that we copied, i.e., that we didn't create.)

    CVS Info: utils.c 1.6

Obtained from: NetBSD
Sponsored by: Netflix

Differential Revision: https://reviews.freebsd.org/D42674

(cherry picked from commit 3e7e3b5bdf902a375decc11b95179fd2fbc0da2a)

5 months agogzip: Add support for decompressing zstd files.
Dag-Erling Smørgrav [Wed, 2 Nov 2022 13:41:44 +0000 (14:41 +0100)]
gzip: Add support for decompressing zstd files.

Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37236

(cherry picked from commit f9349d427431eaa5b3bd7e9e7e87725a138facd1)

5 months agoRemove SMALL conditionals from gzip
Tom Jones [Thu, 27 Jan 2022 17:24:45 +0000 (17:24 +0000)]
Remove SMALL conditionals from gzip

gzip has SMALL conditionals which enable building a reduced size version
of the binary. These exist as part of the introduction of BSD licensed
gzip in 2004 in NetBSD and appear to have been required to reach a size
for inclusion in their install media. For more information see commits
to gzip in the NetBSD tree on the 28th of March 2004.

SMALL doesn't appear to be hooked up to our build system and
complicates gzip quite a bit.

Reviewed by: kevans, imp
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D34047

(cherry picked from commit 4669f23ef76bd5ff7d122546ca5ed3e8575f1c73)

5 months agoFix test output when gzip is run with -tlv
Tom Jones [Thu, 27 Jan 2022 17:17:13 +0000 (17:17 +0000)]
Fix test output when gzip is run with -tlv

When run with test, verbose and list we need to parse the file otherwise
the test output is "NOT OK" even for the file is valid.

Reviewed by: kevans, allanjude, imp
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D34046

(cherry picked from commit 21c966a6b9f2e9110b8dc2a822ad2b4583f4f18b)

5 months agoncl_bioread(): check for vp->v_object before accessing it
Konstantin Belousov [Mon, 15 Jan 2024 11:49:14 +0000 (13:49 +0200)]
ncl_bioread(): check for vp->v_object before accessing it

(cherry picked from commit 503f72a828c7d0d938ec73ffbf62406038c69d47)

5 months agobhyveload: use a dirfd to support -h
Kyle Evans [Wed, 3 Jan 2024 22:17:59 +0000 (16:17 -0600)]
bhyveload: use a dirfd to support -h

Don't allow lookups from the loader scripts, which in rare cases may be
in guest control depending on the setup, to leave the specified host
root.  Open the root dir and strictly do RESOLVE_BENEATH lookups from
there.

cb_open() has been restructured a bit to work nicely with this, using
fdopendir() in the directory case and just using the fd we already
opened in the regular file case.

hostbase_open() was split out to provide an obvious place to apply
rights(4) if that's something we care to do.

Reviewed by: allanjude (earlier version), markj

(cherry picked from commit 6779d44bd878e3cf4723f7386b11da6508ab5431)

5 months agoRevert "fix using man(1) with multiple pages"
Wolfram Schneider [Mon, 15 Jan 2024 19:05:08 +0000 (19:05 +0000)]
Revert "fix using man(1) with multiple pages"

This reverts commit 79e7fef944f7f4bb6865d2b5d0d38b7933ed6e79.

man.sh on stable/13 is missing some new features.
Unfortunately this means that this fix is not working as on stable/14.
Be patient and wait until the following 2 commits are ready to merge.

5 months agoIncrease the size of riscv GENERICSD images to 6 GB
Mike Karels [Sun, 14 Jan 2024 17:01:19 +0000 (11:01 -0600)]
Increase the size of riscv GENERICSD images to 6 GB

The stable/13 snapshot this week failed to build the riscv GENERICSD
image because it ran out of space.  Checking main and stable/14
snapshots, they are also low on space, around 100% or more of
capacity.  Increase them all from 5 GB to 6 GB.  Note, this is the
only riscv image configuration.

Discussed with: cperciva

(cherry picked from commit 6137b5f7b8c183ee8806d79b3f1d8e5e3ddb3df3)

5 months agoresolv: Add a required include to resolv.h
Jan Beich [Mon, 8 Jan 2024 11:52:08 +0000 (20:52 +0900)]
resolv: Add a required include to resolv.h

Add a required include to resolv.h for sockaddr_in.  This should reduce
patching required when porting code written with Linux or NetBSD in mind.

PR: 182466
MFC after: 1 week

(cherry picked from commit 58cf91d3b72a01777bacf72d66a648a744ae3143)

5 months agokern linker: Do not retry loading modules on EEXIST
Zhenlei Huang [Tue, 7 Nov 2023 04:45:25 +0000 (12:45 +0800)]
kern linker: Do not retry loading modules on EEXIST

LINKER_LOAD_FILE() calls linker_load_dependencies() which will return
EEXIST in case the module to be loaded has already been compiled into
the kernel. Since the format of the module is now recognized then there
is no need to retry loading with a different linker, otherwise the
userland will get misleading error number ENOEXEC.

PR: 274936
Reviewed by: dfr
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D42474

(cherry picked from commit ecf710f0e04e3314a492747124166ccb7cf4019e)
(cherry picked from commit e7fd435d3d4e888d9894d8c212c29ae6e2768f74)

5 months agomii: Fix memory leak in micphy.
Jiahao LI [Mon, 8 Jan 2024 07:39:56 +0000 (16:39 +0900)]
mii: Fix memory leak in micphy.

PR: 270040
MFC after: 1 week

(cherry picked from commit 9a622787244c4cda76d1509b0eae168bf4fd1952)

5 months agopuc: Add support for Exar XR17V354 Quad PCI Express UART.
Teerayut Hiruntaraporn [Mon, 8 Jan 2024 06:31:19 +0000 (15:31 +0900)]
puc: Add support for Exar XR17V354 Quad PCI Express UART.

PR: 257207
MFC after: 1 week

(cherry picked from commit 5704277ae58b3498fbee2d041cd18d2444f5cf98)

5 months agoheimdal: Fix man page and documentation typos
Cy Schubert [Thu, 4 Jan 2024 18:34:50 +0000 (10:34 -0800)]
heimdal: Fix man page and documentation typos

Reported by: Jens Schweikhardt <schweikh@schweikhardt.net>

(cherry picked from commit fc55c20355d889bf3d3f81d94b3614a0c4253fa0)

5 months agotcp: prevent spurious empty segments and fix uncommon panic
Richard Scheffenegger [Mon, 8 Jan 2024 08:25:39 +0000 (09:25 +0100)]
tcp: prevent spurious empty segments and fix uncommon panic

Only try sending more data on pure ACKs when there is
more data available in the send buffer.

In the case of a retransmitted SYN not being sent due to
an internal error, the snd_una/snd_nxt accounting could
be off, leading to a panic. Pulling snd_nxt up to snd_una
prevents this from happening.

Reported by:           fengdreamer@126.com
Reviewed by:           cc, tuexen, #transport
MFC after:             1 week
Sponsored by:          NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D43343

(cherry picked from commit f4574e2dc5a4719379496338257526aba484751b)

5 months agofix using man(1) with multiple pages
Wolfram Schneider [Mon, 8 Jan 2024 15:53:11 +0000 (15:53 +0000)]
fix using man(1) with multiple pages

PR: 275978
Reported by: Mohamed Akram
Fixes: 789480702e490818244af11279868ba4f3dabe6b
MFC after: 1 week

(cherry picked from commit 1e82d882ed3372bcaf82451bfb865483a409ab1f)

5 months agoreleng-gce: Advertise the availability of gVNIC support in GCE images.
Xin LI [Fri, 12 Jan 2024 05:38:04 +0000 (21:38 -0800)]
releng-gce: Advertise the availability of gVNIC support in GCE images.

This marks FreeBSD GCE images as gVNIC capable by adding the
--guest-os-features=GVNIC flag at creation time as suggested in GCE
documentation[1].  This allows Generation 3 and newer GCE instances
to leverage advanced networking capabilities and performance
enhancements provided by gVNIC.  Users will benefit from these
improvements without needing to create custom images.

[1] https://cloud.google.com/compute/docs/networking/using-gvnic#create_a_vm_with_gvnic_support

Reviewed by: cperciva
Differential Revision: https://reviews.freebsd.org/D43411

(cherry picked from commit e872a4013fc325460924772f935b599151bd3d25)

5 months agoena: Update driver version to v2.7.0
Osama Abboud [Mon, 30 Oct 2023 11:12:24 +0000 (11:12 +0000)]
ena: Update driver version to v2.7.0

Features:
* Introduce customer and SRD metrics through sysctl
* Introduce spreading IRQs to CPUs capability using sysctl
* Upgrade ena-com to v2.7.0

Bug Fixes:
* Remove outdated APIs

Minor Changes:
* Introduce a shared stats sample interval for all stats

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 4e2688cc762d94b190029f0c5efab9c4bb5521be)

5 months agoena: Update the license dating to 2023
Osama Abboud [Mon, 23 Oct 2023 17:16:38 +0000 (17:16 +0000)]
ena: Update the license dating to 2023

Some of the files are using outdated linceses.
Update the license to be 2023.

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 246aa273244e91a30d70997a3be790a29f9eb29c)

5 months agoena: Support srd metrics with sysctl
Osama Abboud [Tue, 12 Sep 2023 11:17:45 +0000 (11:17 +0000)]
ena: Support srd metrics with sysctl

This commit introduces SRD metrics through sysctl.
The metrics can be queried using the following sysctl node:
sysctl dev.ena.<device index>.ena_srd_info

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 36d42c862f4a5643f6e2395e8d7b7e5c4580499a)

5 months agoena: Support customer metric with sysctl
Osama Abboud [Tue, 12 Sep 2023 10:17:03 +0000 (10:17 +0000)]
ena: Support customer metric with sysctl

This commit adds sysctl support for customer metrics.
Different customer metrics can be found in the following sysctl node:
sysctl dev.ena.<device index>.customer_metrics

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit f97993ad7b9c9e4787bd198d11f348c271af513e)

5 months agoena: Introduce shared sample interval for all stats
Osama Abboud [Tue, 12 Sep 2023 10:13:48 +0000 (10:13 +0000)]
ena: Introduce shared sample interval for all stats

Rename sample_interval node to stats_sample_interval and move
it up in the sysctl tree to make it clear that it's relevant for
all the stats and not only ENI metrics (Currently, sample interval node
is found under eni_metrics node).

Path to node:
dev.ena.<device_index>.stats_sample_interval

Once this parameter is set it will set the sample interval for all the
stats node including SRD/customer metrics.

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 5b925280d9a54eaefd85827bf6e84049aea8fa98)

5 months agoena: Remove CQ tail pointer update API
Osama Abboud [Mon, 11 Sep 2023 08:43:08 +0000 (08:43 +0000)]
ena: Remove CQ tail pointer update API

This commit removes the usage of this API from the freebsd driver since
the relevant functionality is not supported by the device.

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 2835752e075f2fa3edcb596df8306c570ec4cae6)

5 months agoena: Update ena_com_update_intr_reg API usage
Osama Abboud [Mon, 11 Sep 2023 08:38:39 +0000 (08:38 +0000)]
ena: Update ena_com_update_intr_reg API usage

This commit fixes the usage of this function to be compatible with the
new API introduced by ena-com update to v2.7.0

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 72e34ebdd08854dc896f267b0461e241c4040241)

5 months agoena: Change measurement unit of time since last tx cleanup to ms
Arthur Kiyanovski [Wed, 14 Jun 2023 10:12:16 +0000 (10:12 +0000)]
ena: Change measurement unit of time since last tx cleanup to ms

This commit:
1. Sets the time since last cleanup to milliseconds.
2. Fixes incorrect indentations.

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 9272e45c04c0d4fcb5d767e962783f3ab192f64e)

5 months agoena: Add sysctl support for spreading IRQs
Osama Abboud [Mon, 30 Oct 2023 11:27:03 +0000 (11:27 +0000)]
ena: Add sysctl support for spreading IRQs

This commit allows spreading IO IRQs over different CPUs through sysctl.
Two sysctl nodes are introduced:
1- base_cpu: servers as the first CPU to which the first IO IRQ
will be bound.
2- cpu_stride: sets the distance between every two CPUs to which every
two consecutive IO IRQs are bound.

For example for doing the following IO IRQs / CPU binding:

IRQ idx |  CPU
----------------
   1    |   0
   2    |   2
   3    |   4
   4    |   6

Run the following commands:
sysctl dev.ena.<device index>.irq_affinity.base_cpu=0
sysctl dev.ena.<device_index>.irq_affinity.cpu_stride=2

Also introduced rss_enabled field, which is intended to replace
'#ifdef RSS' in multiple places, in order to prevent code duplication.

We want to bind interrupts to CPUs in case of rss set OR in case
the newly defined sysctl paremeter is set. This requires to remove a
couple of '#ifdef RSS' as well in the structs, since we'll be using the
relevant parameters in the CPU binding code.

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit f9e1d9471077109c19fd7d6dc9c1d35432efdede)

5 months agoena: Upgrade ena-com to freebsd v2.7.0
Arthur Kiyanovski [Thu, 28 Dec 2023 13:52:31 +0000 (13:52 +0000)]
ena: Upgrade ena-com to freebsd v2.7.0

Merge commit '04cf7cee5ae0c6bb29eb21ce85bab7ca7386a95f'

Approved by: cperciva (mentor)
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit adfed2d835a7f9382941896d15a487dac6fe659c)

5 months agoif_tuntap: fix NOIP build
Gleb Smirnoff [Mon, 4 Dec 2023 18:18:56 +0000 (10:18 -0800)]
if_tuntap: fix NOIP build

Note: this removes one TUNDEBUG() for the sake of not having one more
ifdefed variable declaration and for the overall code brevity.  The call
from tuntap into LRO can be so easily traced with dtrace(1) that an
80-ish printf(9)-based debugging can be omitted.

Fixes: 99c79cab422705f92f05a2924a29bdf823372ebf
(cherry picked from commit 5b0010b4678d778967a5a82fb38507e46a071e38)

5 months agoif_tuntap: add LRO support to tap devices
Michael Tuexen [Sun, 19 Nov 2023 14:57:53 +0000 (15:57 +0100)]
if_tuntap: add LRO support to tap devices

This allows testing the LRO code with packetdrill in local mode.

Reviewed by: rscheff
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D42548

(cherry picked from commit 99c79cab422705f92f05a2924a29bdf823372ebf)

5 months agoif_tuntap: remove redundant check
Michael Tuexen [Thu, 9 Nov 2023 10:43:54 +0000 (11:43 +0100)]
if_tuntap: remove redundant check

eh can't be NULL, so there is no need to check for it.
Reported by: zlei
Sponsored by: Netflix, Inc.

(cherry picked from commit 44669b76504991ef3ac10ef10bc0fa931ae79c45)

5 months agoif_tuntap: support receive checksum offloading for tap interfaces
Michael Tuexen [Thu, 9 Nov 2023 10:37:27 +0000 (11:37 +0100)]
if_tuntap: support receive checksum offloading for tap interfaces

When enabled, pretend that the IPv4 and transport layer checksum
is correct for packets injected via the character device.
This is a prerequisite for adding support for LRO, which will
be added next. Then packetdrill can be used to test the LRO
code in local mode.

Reviewed by: rscheff, zlei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D42477

(cherry picked from commit ff69d13a50d1d07601de0885fd94f6a09a7ba383)

5 months agoif_tuntap: trigger the bpf hook on transmitting for the tap interface
Michael Tuexen [Sun, 5 Nov 2023 19:32:46 +0000 (20:32 +0100)]
if_tuntap: trigger the bpf hook on transmitting for the tap interface

The tun interface triggers the bpf hook when a packet is transmitted,
the tap interface triggers it when the packet is read from the
character device. This is inconsistent.
So fix the tap device such that it behaves like the tun device.
This is needed for adding support for the tap device to packetdrill.

Reviewed by: kevans, rscheff
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D42467

(cherry picked from commit 35af22ac986c4f3e8160c943a478492e748b6f23)

5 months agoif_tuntap: improve code consistency
Michael Tuexen [Sat, 4 Nov 2023 09:22:42 +0000 (10:22 +0100)]
if_tuntap: improve code consistency

No functional change intended.

Reviewed by: rscheff
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D42462

(cherry picked from commit 4ffe410e40e90c265c20cb4675ed74a40dc1fcc4)

5 months agosctp: minor clean
Michael Tuexen [Mon, 6 Nov 2023 10:04:15 +0000 (11:04 +0100)]
sctp: minor clean

No functional change intended.

(cherry picked from commit 3bbbfc8dcd3622b49907e359c8e9682def0bae25)

5 months agoudplite: make socketoption available on IPv6 sockets
Michael Tuexen [Sun, 5 Nov 2023 14:28:54 +0000 (15:28 +0100)]
udplite: make socketoption available on IPv6 sockets

This patch allows the IPPROTO_UDPLITE-level socket options
UDPLITE_SEND_CSCOV and UDPLITE_RECV_CSCOV to be used on
AF_INET6 sockets in addition to AF_INET sockets.

Reviewed by: ae, rscheff
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42430

(cherry picked from commit 03c3a70abe5e9fa259b954de78ae69229fa9c99f)

5 months agoudplite: fix checksum computation on the sender side
Michael Tuexen [Wed, 1 Nov 2023 09:24:56 +0000 (10:24 +0100)]
udplite: fix checksum computation on the sender side

Don't fill the fields of the UDP/IP header not used for the
checksum computation before performing the checksum computation.

Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D42275

(cherry picked from commit aa64a8f5c35c13b1c325f1a4597c987a37bec5da)

5 months agoffs/ffs_rawread.c: clean up includes
Konstantin Belousov [Mon, 8 Jan 2024 05:36:33 +0000 (07:36 +0200)]
ffs/ffs_rawread.c: clean up includes

(cherry picked from commit 8a4577423e82c54942a9390658d059f1169187b1)

5 months agonfsclient: limit situations when we do unlocked read-ahead by nfsiod
Konstantin Belousov [Mon, 1 Jan 2024 22:22:44 +0000 (00:22 +0200)]
nfsclient: limit situations when we do unlocked read-ahead by nfsiod

(cherry picked from commit 70dc6b2ce314a0f32755005ad02802fca7ed186e)

5 months agovtruncbuf: improve the check for meta buffer
Konstantin Belousov [Sun, 31 Dec 2023 20:46:53 +0000 (22:46 +0200)]
vtruncbuf: improve the check for meta buffer

(cherry picked from commit 2d33ad48bd37f27925e4c46c798f8f2d23a2b501)

5 months agovtruncbuf: add a comment explaining the purpose of the loop
Konstantin Belousov [Sun, 31 Dec 2023 20:46:04 +0000 (22:46 +0200)]
vtruncbuf: add a comment explaining the purpose of the loop

(cherry picked from commit 4c41d10f1538c232174d5200d245e5fcd9936958)

5 months agonfsclient: eliminate ncl_writebp()
Konstantin Belousov [Sat, 30 Dec 2023 18:46:31 +0000 (20:46 +0200)]
nfsclient: eliminate ncl_writebp()

(cherry picked from commit 656d2e83d9eef204c132f879d55782affede2ca9)

5 months agonfsclient: flush dirty pages of the vnode
Konstantin Belousov [Sat, 30 Dec 2023 00:15:50 +0000 (02:15 +0200)]
nfsclient: flush dirty pages of the vnode

PR: 276002

(cherry picked from commit 47ec00d9d6071bbb0ee5ed0bdca3c4a468334d9d)

5 months agonfsclient copy_file_range(): flush dst vnode data
Konstantin Belousov [Fri, 29 Dec 2023 23:22:40 +0000 (01:22 +0200)]
nfsclient copy_file_range(): flush dst vnode data

PR: 276002

(cherry picked from commit 7dae1467d72ae1f5c8f7be0f7444da23a457d98b)

5 months agomlx5(4): only detach IOV children if iov was successfully initialized
Konstantin Belousov [Fri, 29 Dec 2023 03:14:56 +0000 (05:14 +0200)]
mlx5(4): only detach IOV children if iov was successfully initialized

(cherry picked from commit 987446fa39e8f6887ea16ad49f00f699b2efd210)

5 months agosysctl: Don't pass CTLFLAG_MPSAFE to SYSCTL_STRING
Mark Johnston [Thu, 4 Jan 2024 13:33:05 +0000 (08:33 -0500)]
sysctl: Don't pass CTLFLAG_MPSAFE to SYSCTL_STRING

It is redundant.  No functional change intended.

MFC after: 1 week

(cherry picked from commit 969fc091343e593f15f0f3326f65292b435423d5)

5 months agoidentcpu: Let the hw.model be readable in capability mode
Mark Johnston [Thu, 4 Jan 2024 13:26:53 +0000 (08:26 -0500)]
identcpu: Let the hw.model be readable in capability mode

On some platforms this static information can be derived directly from
the CPU, and there doesn't seem much use in restricting it.

Reviewed by: emaste, imp, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43281

(cherry picked from commit 0aba5dd2af57ea3ae90eb49d7745c4c5b6f0ab6b)

5 months agolinprocfs: Avoid using a sysctl to get the CPU model string
Mark Johnston [Thu, 4 Jan 2024 13:25:05 +0000 (08:25 -0500)]
linprocfs: Avoid using a sysctl to get the CPU model string

This will fail if the reading process is in capability mode.  Just copy
the string directly.

PR: 276043
Reviewed by: emaste, imp, kib
Reported and tested by: Ricardo Branco <rbranco@suse.com>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43281

(cherry picked from commit d74a742704eb81f0c6f4aa83e4cb0de26a81c400)

5 months agox86: Make cpu_model[] public
Mark Johnston [Thu, 4 Jan 2024 13:24:04 +0000 (08:24 -0500)]
x86: Make cpu_model[] public

No functional change intended.

Reviewed by: emaste, imp, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43281

(cherry picked from commit d63ea03674007451682334fa3897918c5c3711a4)

5 months agonetinet: Define IPv6 ECN mask
Jose Luis Duran [Sat, 28 Oct 2023 02:50:18 +0000 (02:50 +0000)]
netinet: Define IPv6 ECN mask

Define a mask for the code point used for ECN in the Traffic Class field
(2 bits) of an IPv6 header.

     BE:    0       0       3       0       0       0       0       0
    Bit: 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |Version| Traffic Class |           Flow Label                  |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |                              ...                              |

For BE (Big Endian), or network-byte order, this corresponds to 0x00300000.
For Little Endian, it corresponds to 0x00003000.

Reviewed by: imp, markj
MFC after: 1 week
Pull Request: https://github.com/freebsd/freebsd-src/pull/879

(cherry picked from commit b0e13f785b336670bdf39b83a78435b00d00f43c)

5 months agosetfib.2: Consistently capitalize "FIB"
Mark Johnston [Wed, 3 Jan 2024 20:19:41 +0000 (15:19 -0500)]
setfib.2: Consistently capitalize "FIB"

MFC after: 1 week
Sponsored by: Klara, Inc.

(cherry picked from commit ee7d5ba1b55441476643983d3f70df5ee9ea97c4)