]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agommccam: probe*: Style(9)
Emmanuel Vadot [Fri, 23 Apr 2021 12:51:13 +0000 (14:51 +0200)]
mmccam: probe*: Style(9)

(cherry picked from commit 80020d7888349168627de066b174450712930ee4)

3 years agommcprobe_done: Style(9)
Emmanuel Vadot [Fri, 23 Apr 2021 12:50:04 +0000 (14:50 +0200)]
mmcprobe_done: Style(9)

(cherry picked from commit e017c1c92c990a78ac99987a008c9eb3d5620941)

3 years agodwmmc: Add \n to a debug printf
Emmanuel Vadot [Thu, 22 Apr 2021 19:41:56 +0000 (21:41 +0200)]
dwmmc: Add \n to a debug printf

(cherry picked from commit 7cbdf8a05db7da9c78e8ac74542febc646d24abd)

3 years agommc: dwmmc: Convert driver to use the mmc_sim interface
Emmanuel Vadot [Wed, 21 Apr 2021 11:56:27 +0000 (13:56 +0200)]
mmc: dwmmc: Convert driver to use the mmc_sim interface

A lot more generic cam related things are done in mmc_sim so this simplify
the driver a lot.

Differential Revision: https://reviews.freebsd.org/D27487
Reviewed by: kibab

(cherry picked from commit f1cc48e5da505004259343392ee4a27b8338fca4)

3 years agoallwinner: aw_mmc: Convert driver to use the mmc_sim interface
Emmanuel Vadot [Wed, 21 Apr 2021 11:54:25 +0000 (13:54 +0200)]
allwinner: aw_mmc: Convert driver to use the mmc_sim interface

A lot more generic cam related things are done in mmc_sim so this simplify
the driver a lot.

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

(cherry picked from commit 2671bdb540c582e2d44681e4495916629d033e97)

3 years agommccam: Add mmc_sim, a generic sim for mmc driver to use
Emmanuel Vadot [Wed, 21 Apr 2021 11:52:29 +0000 (13:52 +0200)]
mmccam: Add mmc_sim, a generic sim for mmc driver to use

This adds a generic sim that abstract a lot of what needs to be implemented
in a driver for mmccam support.
A new interface with three methods is added :

 - mmc_sim_get_tran_settings: Use to get what the controller supports in term
   of capabilities, freq etc ...
 - mmc_sim_set_tran_settings: Use to change the speed/freq/etc of the
   sdcard host controller
 - mmc_sim_cam_request: Used for MMCIO requests

Differential Revision: https://reviews.freebsd.org/D27485
Reviewed by: kibab

(cherry picked from commit 47bde7925b41887cb639e651289bc96ccb5b1c24)

3 years agousr.sbin/pwm/pwm add support for flags
Oskar Holmund [Thu, 11 Mar 2021 08:55:23 +0000 (09:55 +0100)]
usr.sbin/pwm/pwm add support for flags

The pwm utility cant set the only flag defined (PWM_POLARITY_INVERTED) so this
patch add the option -I (capital letter i) to send it to the drivers.

None of existing PWM driver have implemented support for flags.
But soon:ish I will put up an review of a pwm driver using TI OMAP DMTimer.

Differential Revision: https://reviews.freebsd.org/D29137
MFC after:   2 weeks

(cherry picked from commit 17b14d8f7733d39397ae5fc104547e358f5f7ddf)

3 years agoshare/man/man9/pwmbus.9 fix types in arguments
Oskar Holmund [Thu, 11 Mar 2021 08:53:26 +0000 (09:53 +0100)]
share/man/man9/pwmbus.9 fix types in arguments

Fix the types of period and duty in share/man/man9/pwmbus.9 to match the one in sys/dev/pmw/pwmbus.c.

Reviewed By: rpokala
Differential Revision: https://reviews.freebsd.org/D29139
MFC after:   3 days

(cherry picked from commit 7d4a5de84d5e54242edc06573522616869e0b37a)

3 years agolibc: add mempcpy(3) and wmempcpy(3)
Konstantin Belousov [Wed, 14 Jul 2021 15:41:36 +0000 (18:41 +0300)]
libc: add mempcpy(3) and wmempcpy(3)

(cherry picked from commit ee37f64cf875255338f917a9da76c643cf59786c)

3 years agoCreate namespace for the symbols added during 14-CURRENT cycle.
Konstantin Belousov [Wed, 14 Jul 2021 15:41:05 +0000 (18:41 +0300)]
Create namespace for the symbols added during 14-CURRENT cycle.

(cherry picked from commit 8c3ea3f4c4f343e5ecf653e2a50e1fb178cd0b02)

3 years agotcp: fix RACK and BBR when using VIMAGE enabled kernel
Michael Tuexen [Mon, 19 Jul 2021 22:29:18 +0000 (00:29 +0200)]
tcp: fix RACK and BBR when using VIMAGE enabled kernel

Fix a bug in VNET handling, which occurs when using specific NICs.
PR: 257195
Reviewed by: rrs
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D31212

(cherry picked from commit a730d82378d3cdf5356775ec0c23ad2ca40c5edb)

3 years agocloudabi and linux ABIs: do not call umtx_thread_cleanup() from thr_exit syscall
Konstantin Belousov [Thu, 1 Jul 2021 22:30:59 +0000 (01:30 +0300)]
cloudabi and linux ABIs: do not call umtx_thread_cleanup() from thr_exit syscall

(cherry picked from commit 747a6b7ace3dd9401289bde8c4e7fc91b8dc18dc)

3 years agoDo not call FreeBSD-ABI specific code for all ABIs
Konstantin Belousov [Thu, 1 Jul 2021 18:00:29 +0000 (21:00 +0300)]
Do not call FreeBSD-ABI specific code for all ABIs

(cherry picked from commit 28a66fc3da3460850520389971e1194f5327f560)

3 years agoMove sv_onexit() sysentvec hook slightly later
Konstantin Belousov [Thu, 1 Jul 2021 18:06:42 +0000 (21:06 +0300)]
Move sv_onexit() sysentvec hook slightly later

(cherry picked from commit 55976ce11a10765dee6c71b7ed6eac016bd560ef)

3 years agoAdd sv_onexec_old() sysent hook for exec event
Konstantin Belousov [Thu, 1 Jul 2021 18:04:06 +0000 (21:04 +0300)]
Add sv_onexec_old() sysent hook for exec event

(cherry picked from commit 71ab344524a14f00f21c4c5638906d7b965d2b64)

3 years agoAdd __diagused
Mateusz Guzik [Thu, 15 Jul 2021 14:01:02 +0000 (14:01 +0000)]
Add __diagused

This can be used for variables which are only used with either
INVARIANTS or WITNESS. Without any annotation they run into dead store
warnings from cc --analyze and always annotating with __unused may hide
bad vars when it should not.

Reviewed by: kib, markj
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31185

(cherry picked from commit b9296725cf99696b48926270a553044522d6e344)

3 years agocam: Mark the qos data is valid in xpd_done_direct() too.
Warner Losh [Sat, 17 Jul 2021 22:10:46 +0000 (16:10 -0600)]
cam: Mark the qos data is valid in xpd_done_direct() too.

Sponsored by: Netflix

(cherry picked from commit abea0c6b0ddc969d1f3b9cab1fd90df00de1f2e4)

3 years agodevd: remove pccard entries
Warner Losh [Thu, 15 Jul 2021 22:17:33 +0000 (16:17 -0600)]
devd: remove pccard entries

The pccard entries are now obsolete, remove them.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31184

(cherry picked from commit a53541355645080cb6d94466f5363db0941da4fa)

3 years agonvme: Enable interrupts after qpair fully constructed
Warner Losh [Thu, 15 Jul 2021 22:17:23 +0000 (16:17 -0600)]
nvme: Enable interrupts after qpair fully constructed

To guard against the ill effects of a spurious interrupt during
construction (or one that was bogusly pending), enable interrupts after
the qpair is completely constructed. Otherwise, we can die with null
pointer dereferences in nvme_qpair_process_completions. This has been
observed in at least one pre-release NVMe drive where the MSIX interrupt
fired while the queue was being created, before we'd started the NVMe
controller card.

The alternative of only turning on the interrupts after the rest was
tried, but was insufficient to work around this bug and made the code
more complicated w/o benefit.

Reviewed by: mav, chuck
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31182

(cherry picked from commit fc9a0840231770bc7e7dcfe4616babdc6d4389a6)

3 years agonanobsd: Bump rescue size to 8GB
Warner Losh [Thu, 15 Jul 2021 22:11:15 +0000 (16:11 -0600)]
nanobsd: Bump rescue size to 8GB

Bump the rescue size from 1.2GB to just shy of 8GB as things have grown
somewhat. Also make it possible to build rescue somewhere other than
/usr/src.

Sponsored by: Netflix

(cherry picked from commit 998abf5a1274609f9b74b3301dc0dabe659bd36b)

3 years agopcengines: Fix kernel config
Warner Losh [Thu, 15 Jul 2021 22:11:11 +0000 (16:11 -0600)]
pcengines: Fix kernel config

Update the old ALIX config to remove devices, add iflib and remove
trailing white space.

Sponsored by: Netflix

(cherry picked from commit e44c62068170987e37ed2d8dea6a035fdc691fc2)

3 years agonanobsd: default to -j $hw.ncpu
Warner Losh [Thu, 15 Jul 2021 22:07:51 +0000 (16:07 -0600)]
nanobsd: default to -j $hw.ncpu

For paralllel builds, default to using all the CPUs on the system. The
old default of -j 3 was too few.

Sponsored by: Netflix

(cherry picked from commit 7e3a794be3752d21fe760cfb2a38665532c4b6b4)

3 years agonanobsd: Use gpart and create code image before full disk image
Arrigo Marchiori [Thu, 15 Jul 2021 22:06:51 +0000 (16:06 -0600)]
nanobsd: Use gpart and create code image before full disk image

The attached patch brings two main changes to the nanobsd script:
 1- gpart is used instead of fdisk;
 2- the code image is created first, and then used to ``assemble'' the
    full disk image.

The patch was first proposed on the freebsd-embedded list:
http://lists.freebsd.org/pipermail/freebsd-embedded/2012-June/001580.html
and is currently under discussion:
http://lists.freebsd.org/pipermail/freebsd-embedded/2014-January/002216.html

Another effect is that the -f option ("suppress code slice extraction")
now imples the -i option ("suppress disk image build").

imp@ applied Patch by hand to new legacy.sh, plus tweaked for NANO_LOG vs
NANO_OBJ confusion in original.

PR: 186030
Reviewed by: imp@
Differential Revision: https://reviews.freebsd.org/D31102

(cherry picked from commit 587c054bea0f652fdbd86baf5807f21c904ac2ad)

3 years agoloader: make sure CPUTYPE is ignored when building
Warner Losh [Thu, 15 Jul 2021 03:06:08 +0000 (21:06 -0600)]
loader: make sure CPUTYPE is ignored when building

CPUTYPE?=native causes -march=native to be added to the command
line. When the host machine is haswell, this causes some versions of
clang to generate code that can't execute in the efi boot loader
environment. Set _CPUCFLAGS= to undo what's done bsd.cpu.mk. bsd.cpu.mk
is included too early to control with NO_CPU_CFLAGS here. The only other
option is to put that in all the Makefiles, and this is less tedious and
error prone.

PR: 194641
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31187
MFC After: 1 week

(cherry picked from commit 7a0c0ff7ee25ff1efa3dbedcb20d2c80178639cc)

3 years agoRemove incorrect __restricted labels from strcspn
Alfonso Gregory [Wed, 14 Jul 2021 21:48:35 +0000 (15:48 -0600)]
Remove incorrect __restricted labels from strcspn

strcspn should never have had the __restrict keywords. While both of
these strings are const, it may have unindended side effects. While this
is the kernel, the POSIX definition also omits restrict.

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

(cherry picked from commit 56d33e86b74b197a36f42255824b56715c96a596)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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")

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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.

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)

3 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)