]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoFix pmbr issues > 2TB
Emrion [Tue, 13 Jul 2021 20:37:59 +0000 (14:37 -0600)]
Fix pmbr issues > 2TB

These issues have low impact because they require precise circumstances
to trigger one of them. The disk must be > 2 TiB in size and either:
- The primary GPT header is dammaged.
- The freebsd-boot partiton is located farther than the first 2 TiB of
  the disc and one of its sectors takes place at a lba value that makes
  the higher 32 bits of this very value change.
Errors and corrections folow:
- decl and incl don't affect CF, so replace with subl/addl $1
- repe uses %cx, so move size to it with movw
- moving a 64-bit value with %cx of 2 (should be 4) so addresses
  > 2TB will work.

PR: 233180
Reviewed by: imp@ (applied patch using description in bug)
Differential Revision: https://reviews.freebsd.org/D31100

(cherry picked from commit 0ca9f1d4a3b772036309fb1c14262ec77c674c5d)

2 years agocam_iosched: use tunable flag and make a bool really a bool
Warner Losh [Tue, 13 Jul 2021 06:00:33 +0000 (00:00 -0600)]
cam_iosched: use tunable flag and make a bool really a bool

kern.cam.do_dynamic_iosched is really a bool, so change its type to
bool. While I'm here, also use the CTLFLAG_TUN flag instead of a
separate tunable line for it and kern.cam.iosched_alpha_bits.

MFC After: 1 week
Sponsored by: Netflix

(cherry picked from commit a065ccb2804fae834a7c66e29b726ea3dbbceace)

2 years agoFix potential NULL pointer dereference of device physical path
Young Xiao [Tue, 21 May 2019 07:36:29 +0000 (15:36 +0800)]
Fix potential NULL pointer dereference of device physical path

In ata_dev_advinfo() and nvme_dev_advinfo(), if the physical path is
being stored and there is a malloc failure (malloc(9) is called with
M_NOWAIT), we could wind up in a situation where the device's
physpath_len is set to the length the user provided, but the physpath
itself is NULL.

If another context then comes in to fetch the physical path value, we
would wind up trying to memcpy a NULL pointer into the caller's buffer.

So, set the physpath_len to 0 when we free the physpath on entry into
the store case for the physical path.  Reset the length to a non-zero
value only after we've successfully malloced a buffer to hold it.

This code mirrors scsi_xpt.c does already as well.

Signed-off-by: Young Xiao <92siuyang@gmail.com>
Reviewed by: imp
PR: 238014

(cherry picked from commit 431ddd94360a9e86c91294eaa2c7b859911984b7)

2 years agoetc/ttys: add xen console
Julien Grall [Thu, 29 Oct 2015 14:22:35 +0000 (11:22 -0300)]
etc/ttys: add xen console

Xen VMs get a simulated serial device meant for use as a console.  Often
an xterm or other advanced terminal is used, so use xterm as the type.

Depending on configuration, FreeBSD on Xen for amd64 may instead use an
emulated serial port, but the virtual console may also be available.

Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com>
Reviewed by: imp (slightly earlier version)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D29873

(cherry picked from commit 2b2c460d7bb856a069047583a55a60976cd375a4)

2 years agoetc/ttys: merge ttys file down to single file
Elliott Mitchell [Thu, 13 May 2021 06:58:00 +0000 (03:58 -0300)]
etc/ttys: merge ttys file down to single file

The tty lists were already pretty similar and there hadn't been any real
need for them to remain distinct for some time. As such, merge to a
single file.

The RISC-V console is preserved. For systems where it doesn't exist, its
presence in /etc/ttys is harmless. The uncommented version of the
ttyv8/XDM line from ttys.amd64 was the one chosen.

Reviewed by: imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30256

(cherry picked from commit c76616f496ee7e6b0a4ed9444fad56418f137a5a)

2 years agottys: diff reduction
Warner Losh [Tue, 4 May 2021 19:49:27 +0000 (13:49 -0600)]
ttys: diff reduction

Back in the day, we used to have a number of entries that were either
'on' or 'off' directly, rather than conditionally on 'onifexists'
etc. Back then, we tried to line up the 'secure' columns by using the
construct 'on secure' or 'off secure' (one space or two). Now that these
have all moved to a conditional construct, remove the second space on
the ttys that still have it. This reduces diffs between the different
ttys and is no functional change. i386 and amd64 did this a long time
ago, and those are the only ones that affected external users (who used
to sed 's/on /off /' the entires as part of the automation).

MFC After: 3 days
Sponsored by: Netflix

(cherry picked from commit 36be84b96699310e0020e194f81fe8e4a6c3f787)

2 years agoarm64, riscv: remove reference to fsu_intr_fault
Mitchell Horne [Tue, 25 May 2021 15:22:49 +0000 (12:22 -0300)]
arm64, riscv: remove reference to fsu_intr_fault

This variable no longer exists.

MFC after: 3 days

(cherry picked from commit 6f4bb8ecc2ba2383c9c160eeb826724a2644f810)

2 years agovmm: Fix AMD-vi using wrong rid range
Ka Ho Ng [Tue, 13 Jul 2021 17:53:10 +0000 (01:53 +0800)]
vmm: Fix AMD-vi using wrong rid range

The ACPI parsing code around rid range was wrong on assuming there is
only one pair of start/end device id range. Besides, ivhd_dev_parse()
never work as supposed. The start/end rid info was always zero.

Restructure the code to build dynamic-sized tables for each IOMMU softc
holding device entries. The device entries are enumerated to find a
suitable IOMMU unit. Operations on devices not governed (e.g. the IOMMU
unit itself) are no-op from now on. There are also a minor fix on wrong
%b formatting string usage.

Tested on my EPYC 7282.

Sponsored by: The FreeBSD Foundation
Reviewed by: grehan
Differential Revision: https://reviews.freebsd.org/D30827

(cherry picked from commit b5c74dfd6434b7f4dcc59dbd61b508acc5ec3ecf)

2 years agoPartially revert previous commit.
Alexander Motin [Wed, 14 Jul 2021 19:46:22 +0000 (15:46 -0400)]
Partially revert previous commit.

ns identify does not allow nsid of 0xffffffff.  Only general identify
allows it.

MFC after: 1 week

(cherry picked from commit d1a0eab9fbc426ed8cbbddcd90720180c44ce36b)

2 years agoFor ns identify/delete allow nsid of 0xffffffff.
Alexander Motin [Wed, 14 Jul 2021 18:56:34 +0000 (14:56 -0400)]
For ns identify/delete allow nsid of 0xffffffff.

The first should report common parameters, the second should delete
all namespaces.

MFC after: 1 week

(cherry picked from commit dbf1dce8d6d2d0eedac5402c1f137a80805179ca)

2 years agoFilter out LBA formats with LBA Data Size of 0.
Alexander Motin [Wed, 14 Jul 2021 18:01:22 +0000 (14:01 -0400)]
Filter out LBA formats with LBA Data Size of 0.

According to the spec: "If the value reported is 0h, then LBA format
is not supported / used or is not currently available".

MFC after: 1 week

(cherry picked from commit d379886a4170fa3d95a5354612a5e2c15b104841)

2 years agoLinuxKPI: Implement sequence counters and sequential locks
Vladimir Kondratyev [Mon, 5 Jul 2021 00:20:55 +0000 (03:20 +0300)]
LinuxKPI: Implement sequence counters and sequential locks

as a thin wrapper around native version found in sys/seqc.h.
This replaces out-of-base GPLv2-licensed code used by drm-kmod.

Reviewed by: hselasky
Differential revision: https://reviews.freebsd.org/D31006

(cherry picked from commit 8b33cb8303d3d7ff12e34327a872ef9fdb29eab9)

2 years agoLinuxKPI: Implement strscpy
Vladimir Kondratyev [Mon, 5 Jul 2021 00:20:42 +0000 (03:20 +0300)]
LinuxKPI: Implement strscpy

strscpy copies the src string, or as much of it as fits, into the dst
buffer.  The dst buffer is always NUL terminated, unless it's zero-sized.
strscpy returns the number of characters copied (not including the
trailing NUL) or -E2BIG if len is 0 or src was truncated.

Currently drm-kmod replaces strscpy with strncpy that is not quite
correct as strncpy does not NUL-terminate truncated strings and returns
different values on exit.

Reviewed by: hselasky, imp, manu
Differential revision: https://reviews.freebsd.org/D31005

(cherry picked from commit 019391bf852771070cb739900f9e20ae6c41c746)

2 years agoLinuxKPI: Use macro for implementation of some dma_map_* functions
Vladimir Kondratyev [Mon, 5 Jul 2021 00:20:23 +0000 (03:20 +0300)]
LinuxKPI: Use macro for implementation of some dma_map_* functions

This allows to remove unimplemented attrs parameter which type differs
between Linux kernel versions and to compile both drm-kmod and ofed
callers unmodified.
Also convert it to 'unsigned long' type to match modern Linuxes.

Reviewed by: hselasky
Differential revision: https://reviews.freebsd.org/D30932

(cherry picked from commit 98a6984a9e10c5c1677643eb4d9a758e3af131da)

2 years agoLinuxKPI: Implement irq_work_sync() routine.
Vladimir Kondratyev [Mon, 5 Jul 2021 00:20:06 +0000 (03:20 +0300)]
LinuxKPI: Implement irq_work_sync() routine.

irq_work_sync() performs draining of irq_work task.
Required by drm-kmod.

Reviewed by: hselasky
Differential revision: https://reviews.freebsd.org/D30818

(cherry picked from commit 864b11007ab3de9f65f28b730507225396c38b9e)

2 years agoLinuxKPI: Do not wait for a grace period in rcu_barrier()
Vladimir Kondratyev [Mon, 5 Jul 2021 00:19:50 +0000 (03:19 +0300)]
LinuxKPI: Do not wait for a grace period in rcu_barrier()

Linux docs explicitly state that this is not required [1]:

"Important note: The rcu_barrier() function is not, repeat, not,
obligated to wait for a grace period.  It is instead only required to
wait for RCU callbacks that have already been posted.  Therefore, if
there are no RCU callbacks posted anywhere in the system, rcu_barrier()
is within its rights to return immediately.  Even if there are
callbacks posted, rcu_barrier() does not necessarily need to wait for
a grace period."

[1] https://www.kernel.org/doc/Documentation/RCU/Design/Requirements/Requirements.html

Reviewed by: emaste, hselasky, manu
Differential revision: https://reviews.freebsd.org/D30809

(cherry picked from commit 1ab61a193241f832e63f97ca37880b010469cb38)

2 years agoLinuxKPI: Add compiler barriers to list_for_each_entry_lockless macro
Vladimir Kondratyev [Mon, 5 Jul 2021 00:19:35 +0000 (03:19 +0300)]
LinuxKPI: Add compiler barriers to list_for_each_entry_lockless macro

so this list-traversal primitive may safely run concurrently with the
_rcu list-mutation primitives such as list_add_rcu() as long as the
traversal is guarded by rcu_read_lock().

Do it by reusing the "list_for_each_entry_rcu" macro which does the same.
On Linux it implements some additional lockdep stuff which we skip.

Also move the macro to linux/rculist.h where it resides on Linux.

Reviewed by: hselasky
Differential revision: https://reviews.freebsd.org/D30795

(cherry picked from commit c0862b2b1fa91636d308a1a41d8dc370691d656e)

2 years agoLinuxKPI: Change flags parameter type of atomic_dec_and_lock_irqsave
Vladimir Kondratyev [Mon, 5 Jul 2021 00:19:01 +0000 (03:19 +0300)]
LinuxKPI: Change flags parameter type of atomic_dec_and_lock_irqsave

On Linux atomic_dec_and_lock_irqsave is a wrapper macro which provides
a reference to third parameter rather than parameter value itself to
implementation routine called _atomic_dec_and_lock_irqsave [1].

While here, implement a fast path.

[1] https://github.com/torvalds/linux/blob/master/include/linux/spinlock.h#L476

Reviewed by: hselasky
Differential revision: https://reviews.freebsd.org/D30781

(cherry picked from commit c77ec79b57aa92b428b940ed550a4a14ed44da48)

2 years agoLinuxKPI: Add #defines required by drm-kmod v5.5
Vladimir Kondratyev [Mon, 5 Jul 2021 00:18:47 +0000 (03:18 +0300)]
LinuxKPI: Add #defines required by drm-kmod v5.5

Reviewed by: hselasky, manu
Differential revision: https://reviews.freebsd.org/D30767

(cherry picked from commit 78a02d8b332cd46e26e1a8088cd0ba5220cd1f18)

2 years agoLinuxKPI: Allow kmem_cache_free() to be called from critical sections
Vladimir Kondratyev [Mon, 5 Jul 2021 00:18:14 +0000 (03:18 +0300)]
LinuxKPI: Allow kmem_cache_free() to be called from critical sections

as it is required by i915kms driver from Linux kernel v 5.5.
This is done with asynchronous freeing of requested memory areas from
taskqueue thread. As memory to be freed is reused to store linked list
entry, backing UMA zone item size is rounded up to pointer size.

While here, make struct linux_kmem_cache private to LKPI to reduce amount
of BSD headers included by linux/slab.h and switch RCU code to usage of
LKPI's linux_irq_work_tq taskqueue to avoid injection of current into
system-wide taskqueue_fast thread context.

Submitted by: nc (initial version for drm-kmod)
Reviewed by: manu, nc
Differential revision: https://reviews.freebsd.org/D30760

(cherry picked from commit a2b83b59db365255461a50ff8fa5e5e4e92e4d51)

2 years agotcpdump: decode packets on pfsync interfaces
Luiz Otavio O Souza [Mon, 12 Jul 2021 17:15:15 +0000 (19:15 +0200)]
tcpdump: decode packets on pfsync interfaces

Reviewed by: kp, scottl
Obtained from: pfsense
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31153

(cherry picked from commit 3f240bdf3652ea823af34b0f399e2c8be5a6320a)

2 years agofsck_ffs: fix background fsck in preen mode
Robert Wing [Sun, 11 Jul 2021 20:47:27 +0000 (12:47 -0800)]
fsck_ffs: fix background fsck in preen mode

Background checks are only allowed for mounted filesystems - don't try
to open the device for writing when performing a background check.

While here, remove a debugging printf that's commented out.

PR:             256746
Fixes: 5cc52631b3b88dfc36d8049dc8bece8573c5f9af
Reviewed by: mckusick
Differential Revision: https://reviews.freebsd.org/D30880

(cherry picked from commit 0c5a59252c8e7b80b98521ebc23a415a05ff9594)

2 years agoarm: replace byte-by-byte memcmp with an already existing asm variant
Mateusz Guzik [Mon, 19 Jul 2021 09:54:18 +0000 (09:54 +0000)]
arm: replace byte-by-byte memcmp with an already existing asm variant

So happens bcmp as found in support.S is in fact renamed memcmp, add
memcmp back as a symbol.

This is a direct commit to keep the old symbol around, see
9ef5b65085ed2acd ("arm: bcmp -> memcmp") in main for reference.

Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agortwn: make sure to not write in upper bits of txdseq
Andriy Gapon [Mon, 21 Jun 2021 08:05:04 +0000 (11:05 +0300)]
rtwn: make sure to not write in upper bits of txdseq

ni_txseqs is kept as 16-bit counter, but we need to trim the upper four
bits as they may have special meanings for the firmware / hardware.
For instance, bit 15 enables hardware / firmware generation of sequence
numbers that overrides sequence numbers programmed by the driver.

Reviewed by: adrian

(cherry picked from commit 7544c1d20d8b7127ed3511edeb94e01d328daebb)

2 years agopmc(3): mandoc clean ups
Gordon Bergling [Mon, 12 Jul 2021 04:28:03 +0000 (06:28 +0200)]
pmc(3): mandoc clean ups

- new sentence, new line
- tab in filled text
- unusual Xr order
- skipping paragraph macro: Pp before Ss

Reviewed by: bcr
Differential Revision: https://reviews.freebsd.org/D31143

(cherry picked from commit 0b1293252543802b809b5f13f554e5d6391d3445)

2 years agolibcasper(3): Correct some warnings found by mandoc
Gordon Bergling [Mon, 12 Jul 2021 04:16:55 +0000 (06:16 +0200)]
libcasper(3): Correct some warnings found by mandoc

- inserting missing end of block: Sh breaks Bl
- moving content out of list: Pp
- missing comma before name: Nm cap_*
- comma in function argument: cap_*
- skipping paragraph macro: Pp after Sh
- sections out of conventional order: Sh AUTHORS

Reviewed by: bcr
Differential Revision: https://reviews.freebsd.org/D31144

(cherry picked from commit 3251ad29f4295ad73668a46727c5bbf7bbac0cf7)

2 years agonfsd: Fix some issues found by mandoc
Gordon Bergling [Mon, 12 Jul 2021 04:31:54 +0000 (06:31 +0200)]
nfsd: Fix some issues found by mandoc

- consider using OS macro: Fx

Reviewed by: bcr
Differential Revision: https://reviews.freebsd.org/D31145

(cherry picked from commit 4c87085d3521dd25009f597161734e085cd47570)

2 years agoAdd missing libkern/strnstr.c file
Greg V [Thu, 15 Jul 2021 00:56:03 +0000 (17:56 -0700)]
Add missing libkern/strnstr.c file

Apparently it wasn't picked up by git.

Reviewed by: bz, hselasky, nc
Differential Revision: https://reviews.freebsd.org/D31131

(cherry picked from commit 4211457e40e07f6f820c4171c7db81f028fd23af)

2 years agolibkern: import strnstr from libc
Greg V [Thu, 15 Jul 2021 00:52:32 +0000 (17:52 -0700)]
libkern: import strnstr from libc

Required for drm-kmod 5.6 (amdgpu).

Reviewed by: bz, hselasky, nc
Differential Revision: https://reviews.freebsd.org/D31131

(cherry picked from commit f39d9c91318569a1ab7507d46e15147f5fef659e)

2 years agolinuxkpi: Add spin_trylock_irqsave() macro
Neel Chauhan [Thu, 15 Jul 2021 14:52:42 +0000 (07:52 -0700)]
linuxkpi: Add spin_trylock_irqsave() macro

This is needed by the drm-kmod 5.6 update.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30706

(cherry picked from commit 086cfe4df8ab237f0cf156e95d36657250931981)

2 years agoBump __FreeBSD_version to 1300512 for LinuxKPI changes and OFED cleanup
Bjoern A. Zeeb [Sat, 17 Jul 2021 21:48:13 +0000 (21:48 +0000)]
Bump __FreeBSD_version to 1300512 for LinuxKPI changes and OFED cleanup
from linux netdevice.h.  drm-kmod needs rebuilding after this.

2 years agoLinuxKPI: firmware, implement deferred loading for "nowait"
Bjoern A. Zeeb [Sun, 20 Jun 2021 13:49:46 +0000 (13:49 +0000)]
LinuxKPI: firmware, implement deferred loading for "nowait"

Change linuxkpi_request_firmware_nowait() to deferred firmware loading
scheduling a task.  This changes behaviour in some cases that we
return from loading the driver before the driver is finished
initialising if the driver does not deal with it (wait).
This brings the behaviour one would expect from when this function is
called and I implemented it to see if it would help a specific case.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky, imp (earlier version)
Differential Revision: https://reviews.freebsd.org/D30830

(cherry picked from commit 399da52fff81a33b1f2c0cee3e8574bc3c63166f)

2 years agoLinuxKPI: avoid userret: Returning with with pinned thread
Bjoern A. Zeeb [Wed, 9 Jun 2021 18:53:16 +0000 (18:53 +0000)]
LinuxKPI: avoid userret: Returning with with pinned thread

Some code manually calls local_bh_disable() and spin_lock() but
then calls spin_unlock_bh() (or vice versa).
Our code then calls local_bh_disable() again from spin_lock()
which means we have the thread pin count increased twice and that
means we get out of synch and are still pinned when returning to
user space.

Avoid this by adding the explicit local_bh_{enable,disable}() to
the spin_[un]lock_bh() versions.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30711

(cherry picked from commit 46ae23a4024b792c44a2b6c5f80429c40dac120b)

2 years agoLinuxKPI: fix sg_pcopy_from_buffer()
Bjoern A. Zeeb [Mon, 7 Jun 2021 15:00:19 +0000 (15:00 +0000)]
LinuxKPI: fix sg_pcopy_from_buffer()

In sg_pcopy_from_buffer() is an error in that skip can underflow
and lead to bogus page arithmetics which may lead to memory corruption
or more likely panics.  Once we found a s/g page to copy into there
is nothing to skip anymore so simply set skip to 0.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30676

(cherry picked from commit edfcdffefc1671b7688c8806ae1f59484954dcc7)

2 years agoLinuxKPI: pci: cleanup some code and add support for "pcim" (managed)
Bjoern A. Zeeb [Sun, 30 May 2021 16:41:13 +0000 (16:41 +0000)]
LinuxKPI: pci: cleanup some code and add support for "pcim" (managed)

Restructure some code and add support for various "managed" versions
for PCI resource management.
This is beyond of what iwlwifi needs but some was found with other
wireless drivers and it mostly all goes together.
Add one FreeBSD sepcific feature returning the resource rather than
the handle to allow us to use bus_*() functions in drivers directly.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30558

(cherry picked from commit d4a4960c6559caa890af0901a21296e75b961210)
(cherry picked from commit 5f88df77a6a0c7609700e2f2c35b0dbcb211f1bb)
(cherry picked from commit 539228d372fae8c4cc401b7ba4620f27783be5a4)

2 years agoLinuxKPI: fix pci device devres initialisation
Bjoern A. Zeeb [Mon, 7 Jun 2021 17:26:14 +0000 (17:26 +0000)]
LinuxKPI: fix pci device devres initialisation

Given we are manually setting up the "device" in PCI in some cases,
we need to initialise the list and lock for device devres here as well
as otherwise we will panic on the uninitialised lock.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30681

(cherry picked from commit c3518147ceb301b01763c3754697731a24410565)

2 years agoLinuxKPI: enhance the irq KPI for managed and threaded operations.
Bjoern A. Zeeb [Sun, 30 May 2021 13:54:13 +0000 (13:54 +0000)]
LinuxKPI: enhance the irq KPI for managed and threaded operations.

Move request_irq() to an internal function which serves request_irq()
and the newly added request_threaded_irq() and devm_request_threaded_irq().
Likewise factor out parts of free_irq() to also be used with
devm_free_irq().  Add the storage and call to a thread_handler in case
of IRQ_WAKE_THREAD.
This is needed for the iwlwifi driver.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30549

(cherry picked from commit d16b6cb17837162d685c960deb28f26f716fa440)

2 years agoLinuxKPI: extend pci.h by various functions for wireless driver
Bjoern A. Zeeb [Fri, 28 May 2021 11:16:12 +0000 (11:16 +0000)]
LinuxKPI: extend pci.h by various functions for wireless driver

Add dummy functions for dealing with "HotPlug" events which we currently
do not support.

Add pci_dev_get(), pci_find_ext_capability() and pci_pme_capable().

The added pcie_find_root_port() is a bit special as we need to create
another linux pci device;  for that make lkpinew_pci_dev() public
which is also helpful for other cases when we want to use the Linux
routines to check for device identifiers only and need a container
for the "bsddev" to use natively.  This has proven to avoid basic
checking code for the sake of rewriting it to native field names
elsewhere.  Given we cache the newly created "root" we also need to
make sure we clean it up.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30521

(cherry picked from commit 8e106c5230c1f0683ffc473db5c2e0d01b2bfeea)

2 years agoLinuxKPI: add dmam_pool_create() support
Bjoern A. Zeeb [Fri, 28 May 2021 11:11:28 +0000 (11:11 +0000)]
LinuxKPI: add dmam_pool_create() support

dmam_pool_create() is a "managed" version of dma_pool_create() which
will cleanup everything left when the device goes away using the
devres framework.  For that add an internal cleanup function to be
called from devres release.
This is used by at least one wireless driver.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30520

(cherry picked from commit 2afeed13b58653578c6ce5154afa6fb59f6b47f0)

2 years agoLinuxKPI: add device_reprobe() and device_release_driver()
Bjoern A. Zeeb [Fri, 28 May 2021 11:04:34 +0000 (11:04 +0000)]
LinuxKPI: add device_reprobe() and device_release_driver()

Add two new (though untested) functions to linux/device.h which are
dealing with manually managing the device/driver and are used by
at least one wireless driver.  We may have to re-fine them in the
future.
Move the devres declarations further up so they can be used earlier
in the file.

Sponsored by: The FreeBSD Foundation
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D30519

(cherry picked from commit 644b4f117634e3b571031026be87429bea0c30dd)

2 years agomlx4/OFED: replace the struct net_device with struct ifnet
Bjoern A. Zeeb [Fri, 4 Jun 2021 15:36:08 +0000 (15:36 +0000)]
mlx4/OFED: replace the struct net_device with struct ifnet

Given all the code does operate on struct ifnet, the last step in this
longer series of changes now is to rename struct net_device to
struct ifnet (that is what it was defined to in the LinuxKPi code).
While mlx4 and OFED are "shared" code the decision was made years ago
to not write it based on the netdevice KPI but the native ifnet KPI
for most of it.  This commit simply spells this out and with that
frees "struct netdevice" to be re-done on LinuxKPI to become a more
native/mixed implementation over time as needed by, e.g., wireless
drivers.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30515

(cherry picked from commit 1411f52facc2b955584f2cb453b912a903e319ed)

2 years agoLinuxKPI: add KPI for netdev_notifier_info returning ifp
Bjoern A. Zeeb [Fri, 28 May 2021 12:44:16 +0000 (12:44 +0000)]
LinuxKPI: add KPI for netdev_notifier_info returning ifp

While currently the ifp gets cast to a net_device and then returned
and consumers are expecting an ifp again, allow parallel usage now and
in the future by extending and also passing the ifp directly back in
the netdev_notifier_info.  Add a function to return the ifp instead of
the net_device.

Sponsored by: The FreeBSD Foundation
Suggested by: hselasky
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30522

(cherry picked from commit 801cf532e70f6b0ebfb2d536b235f166b2e6f0a4)

2 years agonet80211/LinuxKPI: add more radiotap definitions
Bjoern A. Zeeb [Fri, 4 Jun 2021 17:38:38 +0000 (17:38 +0000)]
net80211/LinuxKPI: add more radiotap definitions

Add more raditap definitions based on "names" found in actual drivers
and based on documentation from radiotap.org (where avail).

Leave one specific "duplicate" in the LinuxKPI implementation but
otherwise manage it all in net80211.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky, adrian, sam
Differential Revision: https://reviews.freebsd.org/D30641

(cherry picked from commit b5d37e5a20ab1b189499e2824dc269d998c31989)

2 years agoLinuxKPI: add HWEIGHT32()
Bjoern A. Zeeb [Thu, 27 May 2021 13:09:40 +0000 (13:09 +0000)]
LinuxKPI: add HWEIGHT32()

Add HWEIGHT32() macro needed by iwlwifi and while here add the 8/16/64
variants likewise.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30501

(cherry picked from commit 4cc8a9da491d10f1b4bad6a50730b67dd5e899c7)

2 years agoLinuxKPI: netdevice.h remove more ifnet operating macros
Bjoern A. Zeeb [Wed, 26 May 2021 17:55:21 +0000 (17:55 +0000)]
LinuxKPI: netdevice.h remove more ifnet operating macros

Now that mlx4 and ofed either are operating on ifnet functions
directly or have a private copy of these macros, we can remove them
from linux/netdevice.h.
With this only the #define for net_device to ifnet is left.

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

(cherry picked from commit 9b6835f3ab7f05728caeaaa2ade09e80f1c5e825)

2 years agoOFED: migrate LinuxKPI net_device/ifnet macros into ofed
Bjoern A. Zeeb [Wed, 26 May 2021 17:51:24 +0000 (17:51 +0000)]
OFED: migrate LinuxKPI net_device/ifnet macros into ofed

The LinuxKPI net_device actually is an ifnet; in order to further
clean that up so we can extend "net_device" migrate the few macros
left into ofed and make sure the header is included in all files
which need access to the macros.

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

(cherry picked from commit 825b7d4c9d1d7cb0c79ffe002bc1bd58f28e1a67)

2 years agomlx4: replace LinuxKPI macros with ifnet functions
Bjoern A. Zeeb [Wed, 26 May 2021 17:47:02 +0000 (17:47 +0000)]
mlx4: replace LinuxKPI macros with ifnet functions

The LinuxKPI net_device actually is an ifnet;  in order to further
clean that up so we can extend "net_device" replace the few macros
inline in mlx4.

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

(cherry picked from commit 60afad6fc307815ad2b70a9974d908b6d5d50674)

2 years agoLinuxKPI/OFED/mlx4: cleanup netdevice.h some more
Bjoern A. Zeeb [Wed, 26 May 2021 12:27:26 +0000 (12:27 +0000)]
LinuxKPI/OFED/mlx4: cleanup netdevice.h some more

This removes all unused bits from linux/netdevice.h and migrates two
inline functions into the mlx4 and ofed code respectively.

This gets the mlx4/ofed (struct ifnet) specific bits down to 7 lines
in netdevice.h.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky, kib
Differential Revision: https://reviews.freebsd.org/D30461

(cherry picked from commit c35034b338eb4de6fb42fd855865bce21c81a225)

2 years agoLinuxKPI: add addrconf_addr_solict_mult()
Bjoern A. Zeeb [Mon, 24 May 2021 17:49:12 +0000 (17:49 +0000)]
LinuxKPI: add addrconf_addr_solict_mult()

Introduce net/addrconf.h with an implementation to
addrconf_addr_solict_mult() used by WiFi drivers.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30416

(cherry picked from commit 095f018e4915bf63447ecd6be3beae0dd1a5ff52)

2 years agoLinuxKPI: add Exponentially Weighted Moving Average implementation
Bjoern A. Zeeb [Mon, 24 May 2021 17:42:25 +0000 (17:42 +0000)]
LinuxKPI: add Exponentially Weighted Moving Average implementation

Add DECLARE_EWMA() which expands to a per-name EWMA implementation
as used by multiple wireless drivers.

Sposnored by: The FreeBSD Foundation
Reviewed by: hselasky, cperciva, dwmalone
Differential Revision: https://reviews.freebsd.org/D30415

(cherry picked from commit 32f753f27032849de685c15c471034cbc945a544)

2 years agoLinuxKPI: add linux/bsearch.h for sort(9)
Bjoern A. Zeeb [Mon, 24 May 2021 17:52:02 +0000 (17:52 +0000)]
LinuxKPI: add linux/bsearch.h for sort(9)

Add linux/bsearch.h which only includes libkern.h as the sort(9)
functions seem to be compatible.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30417

(cherry picked from commit f4a145b136ad88f7a9f38e3f7732bc5a8b5cb517)

2 years agoLinuxKPI: byteorder.h
Bjoern A. Zeeb [Mon, 24 May 2021 17:54:16 +0000 (17:54 +0000)]
LinuxKPI: byteorder.h

Add a few more le<n>_{tp,add}_cpu*() #defines/functions found in
wireless drivers.  While here fill most of the combinatorics gaps
and also add the remaining combinations [1].

Suggested by: emaste [1] (for one part)
Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30418

(cherry picked from commit 5aeeab54b0e1042b09dcea43540994c1ce43eebd)

2 years agoLinuxKPI: cache.h add SMP_CACHE_BYTES
Bjoern A. Zeeb [Mon, 24 May 2021 17:56:53 +0000 (17:56 +0000)]
LinuxKPI: cache.h add SMP_CACHE_BYTES

Add a definition for SMP_CACHE_BYTES and while here include sys/param.h
for CACHE_LINE_SIZE as otherwise code might not compile standalone.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30419

(cherry picked from commit e21652c13c7c161efac7fd0b247c73914312212a)

2 years agoLinuxKPI: compiler.h add three more defines
Bjoern A. Zeeb [Mon, 24 May 2021 17:59:13 +0000 (17:59 +0000)]
LinuxKPI: compiler.h add three more defines

Add fallthrough, ____cacheline_aligned_in_smp, and smp_mb() to
linux/compiler.h.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30420

(cherry picked from commit da717031c9fd914343e19ba87f19c7a9a7006721)

2 years agoLinuxKPI: add cpu.h for cpumask_*()
Bjoern A. Zeeb [Mon, 24 May 2021 18:01:59 +0000 (18:01 +0000)]
LinuxKPI: add cpu.h for cpumask_*()

Add linux/cpu.h for cpumask_*() functions found in wireless drivers
and make sure cpu_online_mask is always initialised.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30421

(cherry picked from commit 5fce802722cd4435a748d89043615324db4efe5e)

2 years agoLinuxKPI: add devcoredump.h
Bjoern A. Zeeb [Mon, 24 May 2021 18:04:31 +0000 (18:04 +0000)]
LinuxKPI: add devcoredump.h

Add linux/devcoredump.h with stub implementation of dev_coredumpv()
and dev_coredumpsg() which only free the passed in SG table as needed
for iwlwifi.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30423

(cherry picked from commit 29923fea032a6ac7c0defd74d0b23468b16fda93)

2 years agoLinuxKPI: add dev_crit() to linux/device.h
Bjoern A. Zeeb [Mon, 24 May 2021 18:07:31 +0000 (18:07 +0000)]
LinuxKPI: add dev_crit() to linux/device.h

Sponsored by: The FreeBSD Foundation
Reviewed by: emaste, hselasky
Differential Revision: https://reviews.freebsd.org/D30424

(cherry picked from commit e7a0b685405f8d51597079e3531f313d9e44b4a4)

2 years agoLinuxKPI: add ether_addr_equal_unaligned()
Bjoern A. Zeeb [Mon, 24 May 2021 18:09:37 +0000 (18:09 +0000)]
LinuxKPI: add ether_addr_equal_unaligned()

Replace the implementation for ether_addr_equal() with
ether_addr_equal_unaligned() and add a define for ether_addr_equal()
pointing to the now ether_addr_equal_unaligned() implementation.
This way ether_addr_equal_unaligned() cannot be broken by accident [1].

Suggested by: emaste [1]
Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30425

(cherry picked from commit 834227ba6e80dc0899d2372ae8986241f5658c4e)

2 years agoLinuxKPI: net/if_inet6.h add struct inet6_dev { }
Bjoern A. Zeeb [Mon, 24 May 2021 18:11:56 +0000 (18:11 +0000)]
LinuxKPI: net/if_inet6.h add struct inet6_dev { }

Add a dummy struct inet6_dev {}; to net/if_inet6.h.  This is currently
not used for anything but in a declaration.  Just needs to be there.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30426

(cherry picked from commit ff09f9133f2fb80f705c2c742fc34291b05140af)

2 years agoLinuxKPI: add irq_set_affinity_hint()
Bjoern A. Zeeb [Mon, 24 May 2021 18:14:37 +0000 (18:14 +0000)]
LinuxKPI: add irq_set_affinity_hint()

Add an implementation for irq_set_affinity_hint() to linux/interrupt.h
and include linux/hardirq.h for synchronize_irq() as needed by
wireless drivers.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30427

(cherry picked from commit 602e4e433d3e7dbb03d4fd30a4720a02cdeca6aa)

2 years agoLinuxKPI: add linux/{ip,tcp,udp}.h
Bjoern A. Zeeb [Mon, 24 May 2021 18:17:30 +0000 (18:17 +0000)]
LinuxKPI: add linux/{ip,tcp,udp}.h

Add header files for struct and accessors for IPv4, UDP, and TCP.
Only parts of the fields of the structs have been seen while working
on wireless drivers.  The remaining field names are filled up with
the FreeBSD field names for now.  If you have insights into their
correct naming in Linux, feel free to adjust.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30428

(cherry picked from commit b26fb63f2b96fddf640260dc4a5acd703c7d425c)

2 years agoLinuxKPI: ipv6.h add missing #include
Bjoern A. Zeeb [Mon, 24 May 2021 18:21:55 +0000 (18:21 +0000)]
LinuxKPI: ipv6.h add missing #include

Include linux/bitops.h for a definition of BITS_PER_LONG so that this
file can be used independently.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30429

(cherry picked from commit 762efb2d6dd67f7b999d40b10d58828efb473236)

2 years agoLinuxKPI: add time_is_after_jiffies() definition
Bjoern A. Zeeb [Mon, 24 May 2021 18:24:13 +0000 (18:24 +0000)]
LinuxKPI: add time_is_after_jiffies() definition

This is used by wireless drivers.  Use the time_after() macro as
done for the "after_eq" version.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30430

(cherry picked from commit 8620fe4c10922b12492155d97b913deb6c5d82c6)

2 years agoLinuxKPI: change BUILD_BUG_ON()
Bjoern A. Zeeb [Mon, 24 May 2021 18:26:41 +0000 (18:26 +0000)]
LinuxKPI: change BUILD_BUG_ON()

BUILD_BUG_ON() can be used inside functions where the definition to
CTASSERT() (_Static_assert()) seems to not work.
Go back to an old-style CTASSERT() implementation but also add a
variable dclaration to avoid "unsued typedef" errors and dummy-use
the variable to avoid "unusued variable" errors.  Given it is all
self-contained in a block and not used outside this should be
optimised away.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30431

(cherry picked from commit 1082490cd867a4d443862523c37ce947735342d0)

2 years agoLinuxKPI: add ktime_get_boottime_ns() implementation to ktime.h
Bjoern A. Zeeb [Mon, 24 May 2021 18:30:33 +0000 (18:30 +0000)]
LinuxKPI: add ktime_get_boottime_ns() implementation to ktime.h

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30432

(cherry picked from commit 18d303b05f28acf005dad3f2ffbbec4895181dde)

2 years agoLinuxKPI: add LINUXKPI_PARAM_charp()
Bjoern A. Zeeb [Mon, 24 May 2021 18:32:11 +0000 (18:32 +0000)]
LinuxKPI: add LINUXKPI_PARAM_charp()

Add yet another version of the various module_param_named() use cases.
This one deals with "charp".

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30433

(cherry picked from commit c1661d59e68e29a817c870f421a6871563039dbb)

2 years agoLinuxKPI: add more #defines to pci.h
Bjoern A. Zeeb [Mon, 24 May 2021 18:36:18 +0000 (18:36 +0000)]
LinuxKPI: add more #defines to pci.h

Add more definitions for various PCI uses to linux/pci.h.  Almost all
are defined to their FreeBSD counterparts which are described there.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30434

(cherry picked from commit fc1d840901b1aefe22924d772781e2c835edb096)

2 years agoLinuxKPI: add prandom_u32() as used by wireless drivers.
Bjoern A. Zeeb [Mon, 24 May 2021 18:38:58 +0000 (18:38 +0000)]
LinuxKPI: add prandom_u32() as used by wireless drivers.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30435

(cherry picked from commit 10096cb60619984eefc628471f219d4723867bb1)

2 years agoLinuxKPI: add rcu_dereference_check()
Bjoern A. Zeeb [Mon, 24 May 2021 18:40:42 +0000 (18:40 +0000)]
LinuxKPI: add rcu_dereference_check()

Add a define for rcu_dereference_check() to rcu_dereference_protected()
which ignores the check argument.  Our lockdep compat implementation
for use cases found in iwlwifi would return 1 anyway.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30436

(cherry picked from commit fa58da02f708a22200a89032b8eaf35e1c8ef4a6)

2 years agoLinuxKPI: add kfree_sensitive() using zfree().
Bjoern A. Zeeb [Mon, 24 May 2021 18:43:33 +0000 (18:43 +0000)]
LinuxKPI: add kfree_sensitive() using zfree().

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30437

(cherry picked from commit abcac97f8202d91b61ae4846794ba60166a56cfe)

2 years agoLinuxKPI: extract stringify() in their own header file
Bjoern A. Zeeb [Mon, 24 May 2021 18:53:28 +0000 (18:53 +0000)]
LinuxKPI: extract stringify() in their own header file

Add linux/stringify.h as directly included by drivers.  Remove the
definitions from compiler.h and include the new header in places
where the stringify macros are already used without linuxkpi.

I have adjusted the Copyright of the new file according to the commit
originaly adding the macros (99e690772adbcb78c9e8441bedcf1913d72ea72f).

Sposnored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30440

(cherry picked from commit 43b4c00643bacb9d1ba3aa1022648104bc7ff4a2)

2 years agoLinuxKPI: add kernel_ulong_t typedef in linux/kernel.h.
Bjoern A. Zeeb [Mon, 24 May 2021 18:47:49 +0000 (18:47 +0000)]
LinuxKPI: add kernel_ulong_t typedef in linux/kernel.h.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30438

(cherry picked from commit 5878c7c7b090c8579316ae4479e962684d49a499)

2 years agoLinuxKPI: add guid_t for ACPI consumers.
Bjoern A. Zeeb [Mon, 24 May 2021 18:50:10 +0000 (18:50 +0000)]
LinuxKPI: add guid_t for ACPI consumers.

Add a placeholder struct for guid_t which is needed by ACPI consumers
in at least one wireless driver.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30439

(cherry picked from commit cae1683120e2bf8e39901d29a17c473401653985)

2 years agoLinuxKPI: treat firmware file names more lenient
Bjoern A. Zeeb [Wed, 31 Mar 2021 15:25:01 +0000 (15:25 +0000)]
LinuxKPI: treat firmware file names more lenient

A lot of firmware files have a "-" in the name.  That "-" is a problem
when dealing with shell variables or loader (e.g., auto-loading .ko).
It may thus often be convenient to generate firmware kernel object files
with s/-/_/g in the name.  In order to automatically find them from
drivers using LinuxKPI also substitue the '-' for a '_' like we do
for '/' and '.' already.

Reviewed by: hselasky, manu (ok)
Differential Revision: https://reviews.freebsd.org/D29514

(cherry picked from commit 37c3241a43160dd236bd4767fce46e846cb17227)

2 years agomlx5: remove dependency on ifnet specifics of linux/netdevice.h
Bjoern A. Zeeb [Tue, 30 Mar 2021 15:58:55 +0000 (15:58 +0000)]
mlx5: remove dependency on ifnet specifics of linux/netdevice.h

Rename the last remaining bits depending on ifnet from linux/netdevice.h
instead of using the compat macros. This helps clearing up
struct netdevice being struct ifnet from linux/netdevice.h.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky, kib
Differential Revision: https://reviews.freebsd.org/D29497

(cherry picked from commit 4ded022d3b8948e92c8f8353364ff2c79d720e68)

2 years agoLinuxKPI/OFED: (re)move inetdevice.h implementation
Bjoern A. Zeeb [Fri, 26 Mar 2021 17:52:24 +0000 (17:52 +0000)]
LinuxKPI/OFED: (re)move inetdevice.h implementation

The two functions in linux/inetdevice.h are highly FreeBSD/ifnet
specific.  This is a result of struct net_device being mapped to
struct ifnet.

The only known consumer of these functions are two files in the
ofed/infiniband code.

As a first step of cleaning up copy linux/inetdevice.h to
rdma/ib_addr_freebsd.h. (It stayed a separate file to preserve
copyright and license of the original file; otherwise it could be
merged into ib_addr.h where more EPOCH/vnet/.. are already used).

Slightly rename the function to not conflict with LinuxKPI
in the future.

Remove the three last, now unneeded includes of inetdevice.h and
zap linux/inetdevice.h to an empty header file with only the forward
include to netdevice.h remaining.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky, kib
Differential Revision: https://reviews.freebsd.org/D29434

(cherry picked from commit 7069b4c6a4e516e1435d8beb7a436d88193156d3)

2 years agocxgbe: remove unused linux headers
Bjoern A. Zeeb [Fri, 26 Mar 2021 16:10:25 +0000 (16:10 +0000)]
cxgbe: remove unused linux headers

Remove unused #includes of LinuxKPI headers noticed while trying to
solve LinuxKPI struct net_device and related functions.
Neither netdevice.h nor inetdevice.h nor notifier.h seem to be needed.
This takes cxgbe(4) out of the picture of D29366.

Sponsored by: The FreeBSD Foundation
Reviewed by: np
Differential Revision: https://reviews.freebsd.org/D29432

(cherry picked from commit 0a7b99553f5c1e68868e3cbaccb3160eb1a7d1d6)

2 years agoqlnxr: remove netdevice.h
Bjoern A. Zeeb [Fri, 26 Mar 2021 17:17:10 +0000 (17:17 +0000)]
qlnxr: remove netdevice.h

Remove unused #includes of a LinuxKPI header noticed while trying to
solve LinuxKPI struct net_device and related functions.
This takes qlnxr out of the picture of D29366.

Sponsored by: The FreeBSD Foundation
(cherry picked from commit 6c8dd7c863f111a22c8548ebf5d7e889117a964d)

2 years agomlx4: remove no longer needed header
Bjoern A. Zeeb [Fri, 26 Mar 2021 15:28:24 +0000 (15:28 +0000)]
mlx4: remove no longer needed header

Remove linux/inetdevice.h as neither of the two inline functions there
are used here.

Sposored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D29428

(cherry picked from commit 5a461a86cf5bb0ac4ffde3caf03df0386ddad6cc)

2 years agoLinuxKPI: netdevice notifier callback argument
Bjoern A. Zeeb [Sun, 21 Mar 2021 21:18:34 +0000 (21:18 +0000)]
LinuxKPI: netdevice notifier callback argument

Introduce struct netdev_notifier_info as a container to pass
net_device to the callback functions.
Adjust netdev_notifier_info_to_dev() to return the net_device field.

Add explicit casts from ifp to ni->dev even though currently
struct net_device is defined to struct ifnet.  This is needed in
preparation for untangling this and improving the net_device compat
code.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D29365

(cherry picked from commit fdcfe8a298e23bef9588cafad2672e0c5f48a327)

2 years agoLinuxKPI: add net_ratelimit()
Bjoern A. Zeeb [Tue, 23 Mar 2021 17:00:22 +0000 (17:00 +0000)]
LinuxKPI: add net_ratelimit()

Add a net_ratelimit() compat implementation based on ppsratecheck().
Add a sysctl to allow tuning of the number of messages.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D29399

(cherry picked from commit bc042266b2bfc3f52f685df7ccdd6e857b4b9da9)

2 years agoqlnxr: remove duplicate defines
Bjoern A. Zeeb [Tue, 23 Mar 2021 14:31:37 +0000 (14:31 +0000)]
qlnxr: remove duplicate defines

upper_32_bits() and lower_32_bits() are defined twice in this file.
With the extra conditinal removed on LinuxKPI in 3b1ecc9fa1b5
they are also included from there already.  Use the LinuxKPI version
and remove the two local ones.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D29392

(cherry picked from commit 5df6f7a8405899fac795f227de96ebadd10d60af)

2 years agoLinuxKPI: remove < 5.0 version support
Bjoern A. Zeeb [Tue, 23 Mar 2021 14:24:49 +0000 (14:24 +0000)]
LinuxKPI: remove < 5.0 version support

We are not aware of any out-of-tree consumers anymore
which would need KPI support for before Linux version 5.
Update the two in-tree consumers to use the new KPI.
This allows us to remove the extra version check and
will also give access to {lower,upper}_32_bits() unconditionally.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky, rlibby, rstone
X-MFC: to 13 only
Differential Revision: https://reviews.freebsd.org/D29391

(cherry picked from commit 3b1ecc9fa1b57ca7a1c86661e9a323bc41c97ecc)

2 years agoLinuxKPI: add lockdep_map
Bjoern A. Zeeb [Tue, 23 Mar 2021 16:51:08 +0000 (16:51 +0000)]
LinuxKPI: add lockdep_map

Add stubs for struct lockdep_map and three accessor functions
used by iwlwifi.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D29398

(cherry picked from commit f1069375d97384754a9e8ee8bc21a32d3ad10987)

2 years agoLinuxKPI: add pci_ids.h
Bjoern A. Zeeb [Tue, 23 Mar 2021 17:13:15 +0000 (17:13 +0000)]
LinuxKPI: add pci_ids.h

brcm80211 include pci_ids.h directly while historically we were tracking
IDs in pci.h.  Move the current set of IDs from pci.h to pci_ids.h and
while here add IDs for Realtek and Broadcom as well as a network class
as needed by their wireless drivers.

We still include pci_ids.h from pci.h so this should not change anything.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D29400

(cherry picked from commit 5a402a3ae3975abb573ca9b53ff8cfe204c3771f)

2 years agoLinuxKPI: if_ether additions
Bjoern A. Zeeb [Tue, 23 Mar 2021 16:44:56 +0000 (16:44 +0000)]
LinuxKPI: if_ether additions

Add various protocol IDs found in various wireless drivers.
Also add ETH_FRAME_LEN and struct ethhdr.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D29397

(cherry picked from commit 3cce818c46f58c0089d34a00478c3b7fa3b57c09)

2 years agoLinuxKPI: add more linux-specific errno
Bjoern A. Zeeb [Tue, 23 Mar 2021 16:37:35 +0000 (16:37 +0000)]
LinuxKPI: add more linux-specific errno

Add ERFKILL and EBADE found in iwlwifi and brcmfmac wireless drivers.
While here add a comment above the block of error numbers above 500 to
document expectations.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D29396

(cherry picked from commit 4b0632cfc5c86587668b1d5d2ddc26d445072b03)

2 years agoofed/linuxkpi: use proper accessor function
Bjoern A. Zeeb [Sun, 21 Mar 2021 21:07:45 +0000 (21:07 +0000)]
ofed/linuxkpi: use proper accessor function

In the notifier event callback function rather than casting directly
to the expected type use the proper accessor function as the mlx drivers
already do.
This is preparational work to allow us to improve the struct net_device
is struct ifnet compat code shortcut in the future.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D29364

(cherry picked from commit a29bbfe6c6e41691bdd3bd0e5be89089523485d6)

2 years agolinuxkpi: add ieee80211_node.h to headers to include before LIST_HEAD
Bjoern A. Zeeb [Thu, 18 Mar 2021 22:23:15 +0000 (22:23 +0000)]
linuxkpi: add ieee80211_node.h to headers to include before LIST_HEAD

ieee80211_node.h uses LIST_HEAD() which LinuxKPI redefines and this
can lead to problems (see comment there).  Make sure the net80211
header file is handled correctly by adding it to the list of files
to include before re-defining the macro.
Also add header files needed as dependencies.

Sponsored by: The FreeBSD Foundation
Reviewed by: philip, hselasky
Differential Revision: https://reviews.freebsd.org/D29336

(cherry picked from commit de8a7cc703f1d3eab293d53fbc8269e1aca3a6ab)

2 years agoLinuxKPI: add support for crc32_le()
Bjoern A. Zeeb [Wed, 10 Mar 2021 15:01:10 +0000 (15:01 +0000)]
LinuxKPI: add support for crc32_le()

Add support for crc32_le() as a wrapper around crc32_raw().

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D29187

(cherry picked from commit 0c7b75f12840a31206ae24acca1f5ee35c8e341d)

2 years agoifconfig: 80211, add line break after key info
Bjoern A. Zeeb [Tue, 23 Mar 2021 15:08:46 +0000 (15:08 +0000)]
ifconfig: 80211, add line break after key info

Beauty correction for verbose mode or in case we print multiple key
information to not continue with the next options directly after
as we did so far, e.g.:
AES-CCM 2:128-bit
AES-CCM 3:128-bit powersavemode ...

Sponsored by: The FreeBSD Foundation
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D29393

(cherry picked from commit 5ba4c8de15210bbc026c41b77b23d5af06613fe6)

2 years agonet80211: prefix get_random_bytes() with net80211_
Bjoern A. Zeeb [Thu, 18 Mar 2021 22:15:00 +0000 (22:15 +0000)]
net80211: prefix get_random_bytes() with net80211_

Both linux/random.h and net80211 have a function named
get_random_bytes().  With overlapping files included these collide.
Arguably the function could be renamed in linuxkpi but the generic
name should also not be used in net80211 so rename it there.

Sponsored by: The FreeBSD Foundation
Reviewed by: philip, adrian
Differential Revision: https://reviews.freebsd.org/D29335

(cherry picked from commit af7d9f8e31c4c185f277b27059e470ec8a5627a7)

2 years agolib80211: Start adding 11ac ETSI bits to regdomain.xml
Bjoern A. Zeeb [Sun, 18 Jul 2021 00:32:41 +0000 (00:32 +0000)]
lib80211: Start adding 11ac ETSI bits to regdomain.xml

This change currently (partially) duplicates AC1 freqbands as AC2
as they are not fully overlapping.
It then adds the 11ac netband to the "etsi" domain including
"indoor" and "dfs" flags, which we can deal with, as well as
appropriate (round down) maxpower values.
Comments are left for the actual frequency bands as we do use the
centerfreq for the first/last (chansep sized) channel in the
freqband and their "id" name, which can be confusing.

Reviewed by: philip, adrian
Differential Revision: https://reviews.freebsd.org/D25999

(cherry picked from commit 2ad93dade70a9c98174fc87d0cd24fd54bd0d120)

2 years agonet80211: split up ieee80211_probereq()
Bjoern A. Zeeb [Sun, 18 Jul 2021 00:32:19 +0000 (00:32 +0000)]
net80211: split up ieee80211_probereq()

Factor out ieee80211_probereq_ie() and ieee80211_probereq_ie_len()
and make the length dynamic rather than static max.  The latter is
needed as our current fixed length was longer than some "hw scan",
e.g. that of ath10k, will take.  This way we can pass what we have.
Should this not be sufficient in the future we might have to deal
with filtering and much more error handling.

This also removes a duplicate calculation for ieee80211_ie_wpa [1].

c338cf2c6d5eacdee813191d5976aa531d450ee7 split up ieee80211_probereq_ie().
For HW scans we usually do not want to add a SSID to the IEs.
During that split we allocate memory based on the length which will
always include the length of the SSID and only later we reduced the
length but never updated the value passed back to the caller.
Split the SSID handling up and reduce the length before malloc().
This not only makes us not over-allocate in these situatoins but also
fixes the length returned to the caller and with that usually directly
passed to firmware.

Repoprted by: Martin Husemann <martin NetBSD.org> [1]
Sponsored by: Rubicon Communications, LLC ("Netgate")
Sponsored by: The FreeBSD Foundation (update for alloc)
Reviewed by: adrian, martin NetBSD.org (earlier version)
Reviewed by: philip
Differential Revision: https://reviews.freebsd.org/D26545
Differential Revision: https://reviews.freebsd.org/D30813

(cherry picked from commit c338cf2c6d5eacdee813191d5976aa531d450ee7)
(cherry picked from commit 243b95978debac3db06df6d26ca9f8d84f6cbd83)

2 years agonet80211: ratectl header guard against multiple inclusions
Bjoern A. Zeeb [Sun, 7 Mar 2021 17:35:58 +0000 (17:35 +0000)]
net80211: ratectl header guard against multiple inclusions

Add missing #ifndef/#define/#endif guards against multiple inclusions
to ieee80211_ratectl.h as they are missing.

(cherry picked from commit 3fca90af438ac4232d6b33ee4874297089997dd6)

2 years agonet80211: rx_stats add 160Mhz channel width.
Bjoern A. Zeeb [Sun, 28 Feb 2021 19:24:22 +0000 (19:24 +0000)]
net80211: rx_stats add 160Mhz channel width.

Add the missing receive stat(u)s flag for 160Mhz channel width.
While here correct the comment for c_phytype to reference the correct
flags.

(cherry picked from commit a9cc796fa73de2e80a2d989ba7c2c5a7c7ce9f2e)

2 years agotermios: add more speeds
Bjoern A. Zeeb [Wed, 10 Mar 2021 22:17:07 +0000 (22:17 +0000)]
termios: add more speeds

A lot of small arm64 gadgets are using 1500000 as console speed.
While cu can perfectly deal with this some 3rd party software, e.g.,
comms/conserver-con add speeds based on B<n> being defined.
Having it defined here simplifies enhancing other software.

Obtained from: NetBSD sys/sys/termios.h 1.36
Reviewed by: philip (,okayed by imp)
Differential Revision: https://reviews.freebsd.org/D29209

(cherry picked from commit 0209400ceaed553a3f06a5f3759de992ddb58037)

2 years agopci: enhance printf for leaked MSI[-X] vectors
Bjoern A. Zeeb [Tue, 23 Mar 2021 15:47:24 +0000 (15:47 +0000)]
pci: enhance printf for leaked MSI[-X] vectors

When debugging leaked MSI/MSI-X vectors through LinuxKPI I found
the informational printf unhelpful.  Rather than just stating we
leaked also tell how many MSI or MSI-X vectors we leak.

Sponsored by: The FreeBSD Foundation
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D29394

(cherry picked from commit a9f0367b04b385e7bed47914662badf5ab18bc88)

2 years agoprocctl(PROC_ASLR_STATUS): fix vmspace leak
Konstantin Belousov [Wed, 14 Jul 2021 23:40:04 +0000 (02:40 +0300)]
procctl(PROC_ASLR_STATUS): fix vmspace leak

(cherry picked from commit 0bdb2cbf9d7c4366a0668b4563c8630538a50086)

2 years agoUse sleepq_signal(SLEEPQ_DROP) in cv_signal().
Alexander Motin [Sat, 10 Jul 2021 00:52:40 +0000 (20:52 -0400)]
Use sleepq_signal(SLEEPQ_DROP) in cv_signal().

Same as wakeup_one()/wakeup_any() commit before it reduces the lock
hold time and so contention.

MFC after: 1 week

(cherry picked from commit 63ca9ea4f34d887b66c7b9f1710f5e4be543ebed)