History log of /freebsd-11-stable/sys/compat/linuxkpi/common/include/linux/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
370003 16-Jun-2021 emaste

LinuxKPI: add pr_err_once

Reviewed by: hselasky, emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30672

(cherry picked from commit 05c2d94a081d5948560a01c26c7f432960cde606)

Git Hash: 626ecbc91b3983e0a78c41164943ef0daba7d20f
Git Author: greg@unrelenting.technology

369549 06-Apr-2021 hselasky

Reduce chance of RCU deadlock in the LinuxKPI by implementing the section
feature of the concurrency kit, CK.

Differential Revision: https://reviews.freebsd.org/D29467
Reviewed by: kib@ and markj@
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 177772088060ab0f41bcdbdd81c4712e7f1c7621)

Git Hash: b9de88350f2e5b7d1c837d619d34b9fe3a79826e
Git Author: hselasky@FreeBSD.org

368829 30-Dec-2020 hselasky

MFC r368182:
Use function macro for sema_init() in the LinuxKPI to limit macro expansion scope.

Sponsored by: Mellanox Technologies // NVIDIA Networking

Git Hash: a703dd3cb8418252ce0af0db0eba928db3388b6b
Git Author: hselasky@FreeBSD.org

368828 30-Dec-2020 hselasky

MFC r368406:
Prefer using the MIN() function macro over the min() inline function
in the LinuxKPI. Linux defines min() to be a macro, while in FreeBSD
min() is a static inline function clamping its arguments to
"unsigned int".

Sponsored by: Mellanox Technologies // NVIDIA Networking

Git Hash: cabe7f05fa0d7e6c65c2ed2836e66b2237647de8
Git Author: hselasky@FreeBSD.org

367557 10-Nov-2020 hselasky

MFC r364860 and r366996:
Implement extensible arrays API using the existing radix tree implementation
in the LinuxKPI.

Differential Revision: https://reviews.freebsd.org/D25101
Reviewed by: kib @
Sponsored by: Mellanox Technologies // NVIDIA Networking

366889 20-Oct-2020 hselasky

MFC r349277 and r366669:
Implement more RCU list functions in the LinuxKPI.

Differential Revision: https://reviews.freebsd.org/D20719
Sponsored by: Mellanox Technologies // NVIDIA Networking

366879 20-Oct-2020 hselasky

MFC r347596 and r366432:
Populate the acquire context field of a ww_mutex in the LinuxKPI.
Bump the FreeBSD version to force recompilation of external kernel modules.

Differential Revision: https://reviews.freebsd.org/D19565
Differential Revision: https://reviews.freebsd.org/D26657
Submitted by: greg_unrelenting.technology (Greg V)
Sponsored by: Mellanox Technologies // NVIDIA Networking

364391 19-Aug-2020 hselasky

MFC r364109:
Need to clone the task struct fields related to RCU aswell in the
LinuxKPI after r359727. This fixes a minor regression issue. Else the
priority tracking won't work properly when both sleepable and
non-sleepable RCU is in use on the same thread.

Bump the __FreeBSD_version to force recompilation of external kernel
modules.

PR: 242272
Sponsored by: Mellanox Technologies

364383 19-Aug-2020 hselasky

MFC r364028:
Implement radix_tree_store() in the LinuxKPI for use with the coming
extensible arrays implementation.

While at it add some more comments explaining the current
radix_tree_insert() function and make sure to clean the root node when
the radix tree reaches the maximum height. This can happen if the
index passed is too big when the tree is empty.

The radix_tree_store() function is basically a copy of the
radix_tree_insert() function with some added functionality.

The radix_tree_store() function is local to FreeBSD and does not yet
exist in Linux.

Reviewed by: kib
Sponsored by: Mellanox Technologies

363794 03-Aug-2020 hselasky

MFC r363078:
Implement the bitmap_subset() function in the LinuxKPI. This function
checks if the bitmap pointed to by the first argument is a subset of
the bitmap pointed to by the second argument. The function returns one
on success and zero on failure.

Sponsored by: Mellanox Technologies

363792 03-Aug-2020 hselasky

MFC r363077:
Implement the array_size() function in the LinuxKPI. This function
basically multiplies its two arguments and returns SIZE_MAX if the
result overflows the size_t type. Else the product of the two
arguments is returned.

Bump the FreeBSD_version to mitigate issues with existing
implementation of array_size() in drm-devel-kmod.

Discussed with: manu@
Sponsored by: Mellanox Technologies

363791 03-Aug-2020 hselasky

MFC r361549:
Add overflow.h to the LinuxKPI.

Only add check_add_overflow and check_mul_overflow as those are the only
two needed function by DRM v5.3.
Both gcc and clang have builtin to do this check so use them directly
but throw an error if the compiler/code checker doesn't support this builtin.

Sponsored-by: The FreeBSD Foundation
Reviewed by: hselsasky
Differential Revision: https://reviews.freebsd.org/D25015

363407 21-Jul-2020 wulf

MFC 363205:

linuxkpi: Ignore NULL pointers passed to string parameter of kstr(n)dup

That follows Linux and fixes related drm-kmod-5.3 panic.

Reviewed by: imp, hselasky
Differential Revision: https://reviews.freebsd.org/D25657

363155 13-Jul-2020 hselasky

MFC r362781 and r362794:
Implement is_signed(), type_max() and type_min() function macros in the
LinuxKPI.

Sponsored by: Mellanox Technologies

363149 13-Jul-2020 hselasky

MFC r362946:
Fix include file order in io.h in the LinuxKPI.
Make sure sys/types.h is included before machine/vm.h.

PR: 247775
Submitted by: pkubaj@
Sponsored by: Mellanox Technologies

362323 18-Jun-2020 hselasky

MFC r361828:
Ensure pci_channel_offline() actually queries the PCI register space,
and not only the software cache of that register. Else
pci_channel_offline() won't detect that the PCI device is gone when
using the LinuxKPI.

Sponsored by: Mellanox Technologies

362320 18-Jun-2020 hselasky

MFC r361724:
Implement __is_constexpr() function macro in the LinuxKPI.
Bump the FreeBSD version.

Sponsored by: Mellanox Technologies

362317 18-Jun-2020 hselasky

MFC r361723:
Implement struct_size() function macro in the LinuxKPI.

Sponsored by: Mellanox Technologies

362315 18-Jun-2020 hselasky

MFC r361722:
Implement BUILD_BUG_ON_ZERO() in the LinuxKPI.
Tested using gcc and clang.

Sponsored by: Mellanox Technologies

361924 08-Jun-2020 hselasky

MFC r361110:
Implement synchronize_srcu_expedited() in the LinuxKPI.

Differential Revision: https://reviews.freebsd.org/D24798
Sponsored by: Mellanox Technologies

361206 18-May-2020 hselasky

MFC r360623:
Optimise use of sg_page_count() in __sg_page_iter_next() in the LinuxKPI.
No need to compute value twice.

No functional change intended.

Sponsored by: Mellanox Technologies

361204 18-May-2020 hselasky

MFC r360622:
Implement more scatter and gather functions in the LinuxKPI.

Differential Revision: https://reviews.freebsd.org/D24611
Submitted by: ashafer_badland.io (Austin Shafer)
Sponsored by: Mellanox Technologies

361200 18-May-2020 hselasky

MFC r360532:
Implement more PCI-express bandwidth functions in the LinuxKPI.

Submitted by: ashafer_badland.io (Austin Shafer)
Sponsored by: Mellanox Technologies

361199 18-May-2020 hselasky

MFC r345103:
Implement more PCI speed related functions and macros in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

361197 18-May-2020 hselasky

MFC r360531:
Implement mutex_lock_killable() in the LinuxKPI.

Submitted by: ashafer_badland.io (Austin Shafer)
Sponsored by: Mellanox Technologies

361195 18-May-2020 hselasky

MFC r360530:
Implement DIV64_U64_ROUND_UP() in the LinuxKPI.

Submitted by: ashafer_badland.io (Austin Shafer)
Sponsored by: Mellanox Technologies

361193 18-May-2020 hselasky

MFC r360529:
Implement more lockdep macros in the LinuxKPI.

Submitted by: ashafer_badland.io (Austin Shafer)
Sponsored by: Mellanox Technologies

361191 18-May-2020 hselasky

MFC r351003:
Fix build with DRM and INVARIANTS enabled.

The DRM drivers use the lockdep assertion macros with spinlock_t locks
which are backed by mutexes, not sx locks. This causes compile
failures since you can't use sx_assert with a mutex. Instead, change
the lockdep macros to use lock_class methods. This works by assuming
that each LinuxKPI locking primitive embeds a FreeBSD lock as its
first structure and uses a cast to get to the underlying 'struct
lock_object'.

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

361179 18-May-2020 hselasky

MFC r360119:
Implement aligned LinuxKPI types for u16, u32 and u64.
Makes a difference for 32-bit platforms mostly.

Sponsored by: Mellanox Technologies

361177 18-May-2020 hselasky

MFC r360118:
Allow test_bit() in the LinuxKPI to accept a const pointer.

Sponsored by: Mellanox Technologies

361173 18-May-2020 hselasky

MFC r360528:
Implement kstrtou64() in the LinuxKPI.

Submitted by: ashafer_badland.io (Austin Shafer)
Sponsored by: Mellanox Technologies

361163 18-May-2020 hselasky

MFC r360115:
Allow the ERR_CAST() function in the LinuxKPI to take a const void pointer.
No functional change.

Sponsored by: Mellanox Technologies

359958 15-Apr-2020 hselasky

MFC r359727:
Clone the RCU interface into a sleepable and a non-sleepable part
in the LinuxKPI.

This allows synchronize RCU to be used inside a SRCU read section.
No functional change intended.

Bump the __FreeBSD_version to force recompilation of external kernel modules.

PR: 242272
Sponsored by: Mellanox Technologies

359956 15-Apr-2020 hselasky

MFC r359726:
Some fixes for SRCU in the LinuxKPI.

- Make sure to use READ_ONCE() when deferring variables.
- Remove superfluous zero initializer.

Sponsored by: Mellanox Technologies

359527 01-Apr-2020 kib

MFC r359096, r359165 (by imp):
linuxkpi: Add infrastructure to pass FreeBSD IOV method calls into
pci_driver methods.

358700 06-Mar-2020 hselasky

MFC r358387:
Extend the range of the return value from nsecs_to_jiffies64() to support
Mesa's drm_syncobj usage, in the LinuxKPI.

While at it optimise the jiffies conversion functions to avoid repeated
and constant calculations.

Submitted by: Greg V <greg@unrelenting.technology>
Differential Revision: https://reviews.freebsd.org/D23846
Sponsored by: Mellanox Technologies

357436 03-Feb-2020 hselasky

MFC r357077:
Implement mmget_not_zero() in the LinuxKPI.

Submitted by: Austin Shafer <ashafer@badland.io>
Sponsored by: Mellanox Technologies

354616 11-Nov-2019 hselasky

MFC r354335:
Enable device class group attributes in the LinuxKPI.

Bump the __FreeBSD_version to force recompilation of
external kernel modules due to structure change.

Differential Revision: https://reviews.freebsd.org/D21564
Submitted by: Greg V <greg@unrelenting.technology>
Sponsored by: Mellanox Technologies

354615 11-Nov-2019 hselasky

MFC r351937:
LinuxKPI: Improve sysfs support.

- Add functions for creating and merging sysfs groups.
- Add sysfs_streq function to compare strings ignoring newline from the
sysctl userland call.
- Add a call to sysfs_create_groups in device_add.
- Remove duplicate header include.
- Bump __FreeBSD_version.

Differential Revision: D21542

354614 11-Nov-2019 hselasky

MFC r351701:
LinuxKPI: Add sysfs create/remove functions that handles multiple files in one call.

Differential Revision: D21475

352474 18-Sep-2019 hselasky

MFC r352205:
Fix broken DECLARE_TASKLET() macro after r347852.

Sponsored by: Mellanox Technologies

352330 14-Sep-2019 hselasky

MFC r351693:
Use DEVICE memory instead of UNCACHEABLE on aarch64 in ioremap() in the LinuxKPI.
This fixes system hangs on reading device registers on aarch64.

Tested with: Marvell MACCHIATObin (Armada8k) + mlx4en, amdgpu
Submitted by: Greg V <greg@unrelenting.technology>
Differential Revision: https://reviews.freebsd.org/D20789
Sponsored by: Mellanox Technologies

351841 05-Sep-2019 hselasky

MFC r351009:
Implement pci_enable_msi() and pci_disable_msi() in the LinuxKPI.
This patch makes the DRM graphics driver in ports usable on aarch64.

Submitted by: Greg V <greg@unrelenting.technology>
Differential Revision: https://reviews.freebsd.org/D21008
Sponsored by: Mellanox Technologies

347796 16-May-2019 hselasky

MFC r347246:
Add support for Dynamic Interrupt Moderation, DIM, in mlx5en(4).

Add support for DIM based on Linux,
with some minor adaptions specific to FreeBSD.

Linux commit
f97c3dc3c0e8d23a5c4357d182afeef4c67f5c33

Sponsored by: Mellanox Technologies

347794 16-May-2019 hselasky

MFC r347190:
Use PCIV_INVALID in pci_channel_offline() in the LinuxKPI.

Build tested drm-current-kmod prior to commit.

Submitted by: slavash@
Sponsored by: Mellanox Technologies

347793 16-May-2019 hselasky

MFC r347188:
Disabling a PCI device should only disable busmaster in the LinuxKPI.

As Linux comment for this function point:
Signal to the system that the PCI device is not in use by the system
anymore. This only involves disabling PCI bus-mastering, if active.

Build tested drm-current-kmod prior to commit.

Submitted by: slavash@
Sponsored by: Mellanox Technologies

347792 16-May-2019 hselasky

MFC r347187:
Implement print_hex_dump_debug() function macro in the LinuxKPI.

Build tested drm-current-kmod prior to commit.

Submitted by: slavash@
Sponsored by: Mellanox Technologies

347791 16-May-2019 hselasky

MFC r347185:
Allow controlling pr_debug at runtime in the LinuxKPI.

Turning on pr_debug at compile time make it non-optional at runtime.
This often means that the amount of the debugging is unbearable.
Allow developer to turn on pr_debug output only when needed.

Build tested drm-current-kmod prior to commit.

Submitted by: kib@
Sponsored by: Mellanox Technologies

346392 19-Apr-2019 bz

MFC r344700:

Add ushort and ulong to linux/types.h.

When porting code once written for Linux we find not only uints but also ushort and ulong.
Provide central typedefs as part of the linuxkpi for those as well.

345939 05-Apr-2019 hselasky

MFC r345109:
Implement sg_virt() function in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

345938 05-Apr-2019 hselasky

MFC r345108:
Define SG_CHAIN and SG_END in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

345936 05-Apr-2019 hselasky

MFC r345107:
Implement pr_info_ratelimited() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

345934 05-Apr-2019 hselasky

MFC r345106:
Define some RCU debug macros in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

345931 05-Apr-2019 hselasky

MFC r345105:
Honor SYSCTL function return values when creating sysfs nodes in the LinuxKPI.
Return proper error code upon failure.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

345930 05-Apr-2019 hselasky

MFC r345104:
Implement more malloc function macros in the LinuxKPI.
Fix arguments for currently unused kvmalloc().

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

345927 05-Apr-2019 hselasky

MFC r345101:
Implement si_meminfo() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

345926 05-Apr-2019 hselasky

MFC r345099:
Implement get_task_comm() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

345924 05-Apr-2019 hselasky

MFC r345098:
Implement current_exiting() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

345922 05-Apr-2019 hselasky

MFC r345097:
Implement list_for_each_entry_from_reverse() and
list_bulk_move_tail() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

345920 05-Apr-2019 hselasky

MFC r345096:
Implement dma_map_page_attrs() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

345917 05-Apr-2019 hselasky

MFC r345095 and r345110:
Implement ida_free() and ida_alloc_max() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

345916 05-Apr-2019 hselasky

MFC r345094:
Implement DEFINE_STATIC_SRCU() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

345914 05-Apr-2019 hselasky

MFC r345093:
Implement BITS_PER_TYPE() function macro in the LinuxKPI.
Fix some style while at it.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

345911 05-Apr-2019 hselasky

MFC r345092:
Properly define the DMA attribute values in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

345910 05-Apr-2019 hselasky

MFC r345091:
Implement dev_err_once() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

345907 05-Apr-2019 hselasky

MFC r345090:
Implement dma_set_mask_and_coherent() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Limelight Networks
Sponsored by: Mellanox Technologies

343655 01-Feb-2019 hselasky

MFC r343451:
Add full support for PCI_ANY_ID when matching PCI IDs in the LinuxKPI.

Sponsored by: Mellanox Technologies

342804 06-Jan-2019 kib

MFC r342628, r342670 (by cem):
Fix linux_destroy_dev() behaviour when there are still files open from
the destroying cdev.

Also bump __FreeBSD_version since struct linux_cdev size on i386 increased
(this is unmergeable r342629 on HEAD).

342803 06-Jan-2019 kib

MFC r342627:
Implement zap_vma_ptes() for managed device objects.

341880 12-Dec-2018 hselasky

MFC r341533:
ibcore: ip6_dev_find() needs to know the scope ID.

Else the wrong network device can be returned for link-local addresses.

Sponsored by: Mellanox Technologies

341854 12-Dec-2018 hselasky

MFC r341520:
linuxkpi: Really check if PCI is offline

Currently we always return false if for PCI offline query.
Try to read PCI config, if the return value if 0xffff probably the
PCI is offline.

Sponsored by: Mellanox Technologies

341852 12-Dec-2018 hselasky

MFC r341519:
linuxkpi: properly implement netif_carrier_ok().

Submitted by: kib@
Sponsored by: Mellanox Technologies

341850 12-Dec-2018 hselasky

MFC r341518:
linuxkpi: Fix for use-after-free when tearing down character devices.

Make sure we hold a reference on the character device for every opened file
to prevent the character device to be freed prematurely.

Sponsored by: Mellanox Technologies

341846 12-Dec-2018 hselasky

MFC r341517 and r341592:
linuxkpi: implement idr_is_empty() and ida_is_empty().

Submitted by: kib@
Sponsored by: Mellanox Technologies

340945 26-Nov-2018 hselasky

MFC r340480:
Define asm macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

340942 26-Nov-2018 hselasky

MFC r340479:
Implement ktime_get_ts64() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

340003 01-Nov-2018 hselasky

MFC r339924:
Implement the dump_stack() function in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

339997 01-Nov-2018 hselasky

MFC r339923:
Implement __KERNEL_DIV_ROUND_UP() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

339987 01-Nov-2018 hselasky

MFC r339868:
Implement dma_pool_zalloc() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

339734 25-Oct-2018 tijl

MFC r339618:

Define linuxkpi readq for 64-bit architectures. It is used by drm-kmod.
Currently the compiler picks up the definition in machine/cpufunc.h.

Add compiler memory barriers to read* and write*. The Linux x86
implementation of these functions uses inline asm with "memory" clobber.
The Linux x86 implementation of read_relaxed* and write_relaxed* uses the
same inline asm without "memory" clobber.

Implement ioread* and iowrite* in terms of read* and write* so they also
have memory barriers.

Qualify the addr parameter in write* as volatile.

Like Linux, define macros with the same name as the inline functions.

Only define 64-bit versions on 64-bit architectures because generally
32-bit architectures can't do atomic 64-bit loads and stores.

Regroup the functions a bit and add brief comments explaining what they do:
- __raw_read*, __raw_write*: atomic, no barriers, no byte swapping
- read_relaxed*, write_relaxed*: atomic, no barriers, little-endian
- read*, write*: atomic, with barriers, little-endian

Add a comment that says our implementation of ioread* and iowrite*
only handles MMIO and does not support port IO.

Reviewed by: hselasky

337898 16-Aug-2018 hselasky

MFC r337527:
Use atomic_fcmpset_XXX() instead of atomic_cmpset_XXX() when possible
in the LinuxKPI.

Suggested by: mjg @
Sponsored by: Mellanox Technologies

337897 16-Aug-2018 hselasky

MFC r337376:
Implement current_work() function in the LinuxKPI.

Tested by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

337895 16-Aug-2018 hselasky

MFC r337373:
Define __poll_t type in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

337894 16-Aug-2018 hselasky

MFC r337232:
Implement ktime_add_ms() and ktime_before() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

335435 20-Jun-2018 hselasky

MFC r334775:
Move the EXPORT_SYMBOL_XXX() function macros into own header file.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335434 20-Jun-2018 hselasky

MFC r334662:
Define the __kernel_size_t type in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335433 20-Jun-2018 hselasky

MFC r334958:
Implement the kstrtobool() and kstrtobool_from_user() functions
in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335431 20-Jun-2018 hselasky

MFC r334778:
Define ARCH_KMALLOC_MINALIGN in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335429 20-Jun-2018 hselasky

MFC r334777:
Wrap timespec64 into timespec in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335428 20-Jun-2018 hselasky

MFC r334774:
Implement the dev_pm_set_driver_flags() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335427 20-Jun-2018 hselasky

MFC r334720:
Make some list functions RCU safe in the LinuxKPI.
While at it rename hlist_add_after() into hlist_add_behind().

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335426 20-Jun-2018 hselasky

MFC r334717:
Implement the __add_wait_queue_entry_tail() function in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335425 20-Jun-2018 hselasky

MFC r334715:
Implement the might_sleep_if() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335424 20-Jun-2018 hselasky

MFC r334714:
Rename two structure field members while keeping backwards compatibility in
the LinuxKPI. Add a comment saying in which Linux version this change was made.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335423 20-Jun-2018 hselasky

MFC r334713:
Implement the init_wait_entry() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335421 20-Jun-2018 hselasky

MFC r334711:
Implement the ktime_compare() and ktime_after() functions in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335419 20-Jun-2018 hselasky

MFC r334664:
Declare and set the global "system_highpri_wq" workqueue structure pointer
in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335418 20-Jun-2018 hselasky

MFC r334663:
Implement the INIT_DELAYED_WORK_ONSTACK() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335417 20-Jun-2018 hselasky

MFC r334661:
Implement the task_pid_vnr() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335416 20-Jun-2018 hselasky

MFC r334660:
Add "access" function pointer to the "vm_operations_struct" structure
in the LinuxKPI. While at it document when to use the "virtual_address" or
the "address" field in the "vm_fault" structure.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335415 20-Jun-2018 hselasky

MFC r334659:
Implement mul_u32_u32() function in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335414 20-Jun-2018 hselasky

MFC r334658:
Implement timer_setup() and from_timer() function macros in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335413 20-Jun-2018 hselasky

MFC r334484:
Implement the __sg_alloc_table_from_pages() function based on the existing
sg_alloc_table_from_pages() function in the LinuxKPI.

This basically allow segments to have a limit, max_segment.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335412 20-Jun-2018 hselasky

MFC r334483:
Implement radix_tree_iter_delete() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335411 20-Jun-2018 hselasky

MFC r334482:
Improve high resolution timer support in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

335410 20-Jun-2018 hselasky

MFC r334481:
Add more GFP macro definitions in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

334770 07-Jun-2018 hselasky

MFC r334429:
Implement support for the PCI_BUS_NUM() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

334768 07-Jun-2018 hselasky

MFC r334428:
Implement support for the kvmalloc_array() function in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

334767 07-Jun-2018 hselasky

MFC r334427:
Correct macroname in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

334766 07-Jun-2018 hselasky

MFC r334426:
Define __initconst in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

334765 07-Jun-2018 hselasky

MFC r334425:
Implement bitmap_complement() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

334764 07-Jun-2018 hselasky

MFC r334423:
Implement idr_is_empty() in the LinuxKPI and make idr_remove() API compatible
with upstream Linux by returning the pointer to the removed element.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

334761 07-Jun-2018 hselasky

MFC r334283:
The schedule_timeout_killable() function should listen for signals
in the LinuxKPI.

Found by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

334760 07-Jun-2018 hselasky

MFC r334281:
Implement wait_event_killable() in the LinuxKPI.

Requested by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

333323 07-May-2018 hselasky

MFC r333108:
Define USEC_PER_MSEC and USEC_PER_SEC in the LinuxKPI.

Approved by: re (marius)
Sponsored by: Mellanox Technologies

331996 04-Apr-2018 hselasky

MFC r331828:
Optimise use of Giant in the LinuxKPI.

- Make sure Giant is locked when calling PCI device methods.
Newbus currently requires this.

- Avoid unlocking Giant right before aquiring the sleepqueue lock.
This can save a task switch.

Sponsored by: Mellanox Technologies

331994 04-Apr-2018 hselasky

MFC r331694:
Swap two instances of regular macros with function macros in the LinuxKPI,
to narrow down the substitution scope.

Sponsored by: Mellanox Technologies

331802 30-Mar-2018 hselasky

MFC r331357:
The pci_disable_device() function is also expected to clear the PCI
busmaster. This fixes LinuxKPI compliancy with Linux.

Sponsored by: Mellanox Technologies

331801 30-Mar-2018 hselasky

MFC r331355:
Clear old MSIX IRQ numbers in the LinuxKPI.

When disabling the MSIX IRQ vectors for a PCI device through the
LinuxKPI, make sure any old MSIX IRQ numbers are no longer visible to
the linux_pci_find_irq_dev() function else IRQs can be requested from
the wrong PCI device.

Sponsored by: Mellanox Technologies

331799 30-Mar-2018 hselasky

MFC r330944:
Fix compliancy of the kstrtoXXX() functions in the LinuxKPI, by skipping
one newline character at the end, if any.

Found by: greg@unrelenting.technology
Sponsored by: Mellanox Technologies

331756 30-Mar-2018 emaste

MFC r331433: linuxkpi whitespace cleanup

330867 13-Mar-2018 hselasky

MFC r330271:
Rename callout member in struct timer_list to match the one in struct
delayed_work in the LinuxKPI. This allows the timer_pending() function
macro to be used with delayed work structures.

No functional nor structural change.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

330863 13-Mar-2018 hselasky

MFC r330399:
Stub kernel_param_lock() and kernel_param_unlock() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

330862 13-Mar-2018 hselasky

MFC r330398:
Implement wait_event_lock_irq() macro function in the LinuxKPI.

Requested by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

330861 13-Mar-2018 hselasky

MFC r330395:
Implement DEFINE_WAIT_FUNC() function macro and default_wake_function()
in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

330860 13-Mar-2018 hselasky

MFC r330394:
Implement pr_err_ratelimited() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

330859 13-Mar-2018 hselasky

MFC r330393:
Implement __MODULE_STRING() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

330858 13-Mar-2018 hselasky

MFC r330392 and r330408:
Implement BUILD_BUG() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

330857 13-Mar-2018 hselasky

MFC r330391:
Implement writel_relaxed() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

330856 13-Mar-2018 hselasky

MFC r330390:
Define noinline and __maybe_unused macros in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

330855 13-Mar-2018 hselasky

MFC r330389:
Implement for_each_clear_bit() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

330854 13-Mar-2018 hselasky

MFC r330388:
Implement GENMASK_ULL() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

330853 13-Mar-2018 hselasky

MFC r330387 and r330396:
Rename the SLAB_DESTROY_BY_RCU flag into SLAB_TYPESAFE_BY_RCU in the LinuxKPI
to be compatible with Linux.

Keep the old SLAB_DESTROY_BY_RCU macro definition around in the LinuxKPI
to avoid compilation breakage in external kernel modules.

Requested by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

330851 13-Mar-2018 hselasky

MFC r330352 and r330353:
Implement msleep_interruptible() in the LinuxKPI. While at it use pause_sbt()
instead of pause() in the msleep() function to avoid rounding errors when
converting delay values forth and back. Add a guard for a delay value
of zero milliseconds which is undefined.

Suggested by: ian@
Requested by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

330849 13-Mar-2018 hselasky

MFC r330274:
Implement more lockdep stubs in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

330848 13-Mar-2018 hselasky

MFC r330273:
Implement ktime_get_raw() function in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

330847 13-Mar-2018 hselasky

MFC r330272:
Implement wait_on_bit() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

330830 13-Mar-2018 ae

MFC r330537:
Add mapping for several ethernet types used by Linux to FreeBSD
ethernet types.

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

329980 25-Feb-2018 hselasky

MFC r329471:
Implement BUILD_BUG_ON_INVALID() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

329978 25-Feb-2018 hselasky

MFC r329472:
Allow the put_user() function macro to put constant values by using the
existing __put_user() macro.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

329977 25-Feb-2018 hselasky

MFC r329509:
Update the ktime type in the LinuxKPI to be a signed 64-bit integer similarly
to Linux, to avoid compilation issues. Implement ktime_get_real_seconds().

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

329976 25-Feb-2018 hselasky

MFC r329825:
Return correct error code to user-space when a system call receives a
signal in the LinuxKPI.

The read(), write() and mmap() system calls can return either EINTR or
ERESTART upon receiving a signal. Add code to figure out the correct
return value by temporarily storing the return code from the relevant
FreeBSD kernel APIs in the Linux task structure.

Sponsored by: Mellanox Technologies

329975 25-Feb-2018 hselasky

MFC r329584:
Implement list_safe_reset_next() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

329973 25-Feb-2018 hselasky

MFC r329519:
Implement support for radix_tree_for_each_slot() and radix_tree_exception()
in the LinuxKPI and use unsigned long type for the radix tree index.

Sponsored by: Mellanox Technologies

329972 25-Feb-2018 hselasky

MFC r329516:
Implement the KMEM_CACHE() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

329971 25-Feb-2018 hselasky

MFC r329515:
Make the vm_fault structure in the LinuxKPI compatible with
newer versions of the Linux kernel. No functional change.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

329970 25-Feb-2018 hselasky

MFC r329514:
Implement the rcu_dereference_raw() function macro.
Make sure all RCU dereferencing use the READ_ONCE() function macro.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

329969 25-Feb-2018 hselasky

MFC r329513:
Implement __GFP_BITS_SHIFT and __GFP_BITS_MASK macros in the LinuxKPI.
Add compile time asserts to catch conflicts with native defines.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

329968 25-Feb-2018 hselasky

MFC r329512:
Implement __list_del_entry() helper functions in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

329967 25-Feb-2018 hselasky

MFC r329511:
Implement file_inode() and call_mmap() helper functions in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

329966 25-Feb-2018 hselasky

MFC r329510:
Refactor dentry structure into its own header file in the LinuxKPI similary
to Linux. No functional change. Implement d_inode() helper function.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks

329965 25-Feb-2018 hselasky

MFC r329477:
Implement spin_trylock_irq() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

329964 25-Feb-2018 hselasky

MFC r329476:
Stub more lockdep function macros in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

329963 25-Feb-2018 hselasky

MFC r329475:
Implement get_task_pid() function macro in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

329962 25-Feb-2018 hselasky

MFC r329470:
Add support for printk_ratelimit() function macro and improve the existing
printk_ratelimited() function macro to return a boolean stating if there
was a printout, true, or not, false.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

329961 25-Feb-2018 hselasky

MFC r329468:
Add support for kref_read() function in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

329960 25-Feb-2018 hselasky

MFC r329467:
Add support for mmgrab() function in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

329959 25-Feb-2018 hselasky

MFC r329466:
Add support for __percpu and __weak macros in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

329958 25-Feb-2018 hselasky

MFC r329465:
Move the IRQ_RETVAL() and irqreturn definitions to irqreturn.h in the
LinuxKPI to be compatible with Linux. No functional change.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

329957 25-Feb-2018 hselasky

MFC r329464:
Add checks for valid IRQ tag before setting up or tearing down an interrupt
handler in the LinuxKPI. This is needed when the interrupt handler is disabled
before freeing the interrupt.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

329955 25-Feb-2018 hselasky

MFC r329378:
Implement mutex_trylock_recursive() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

329954 25-Feb-2018 hselasky

MFC r329377:
Implement memdup_user_nul() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

329953 25-Feb-2018 hselasky

MFC r329376:
Implement tasklet_enable() and tasklet_disable() in the LinuxKPI.

Requested by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

329952 25-Feb-2018 hselasky

MFC r329372:
Implement enable_irq() and disable_irq() in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies

329638 20-Feb-2018 kib

MFC r329216:
linuxkpi: Do not leak pages on put.

329260 14-Feb-2018 hselasky

MFC r328971:
Fix implementation of ktime_add_ns() and ktime_sub_ns() in the LinuxKPI to
actually return the computed result instead of the input value.

This is a regression issue after r289572.

Found by: gcc6
Sponsored by: Mellanox Technologies

328655 01-Feb-2018 hselasky

MFC r328623:
Properly implement the cond_resched() function macro in the LinuxKPI.

Sponsored by: Mellanox Technologies

328653 01-Feb-2018 hselasky

MFC r310014-r327788:
This is an overwrite merge backport of the LinuxKPI from FreeBSD-head.
Following is a complete list of MFC'ed revisions and also partially
MFC'ed revisions in the end. The MFC'ed revision are listed in
incremental order.

Bump the __FreeBSD_version to force recompilation of any external
kernel modules.

Sponsored by: Mellanox Technologies

MFC r310014:
Remove the only user of sysctl_add_oid().

My plan is to change this function's prototype at some point in the
future to add a new label argument, which can be used to export all of
sysctl as metrics that can be scraped by Prometheus. Switch over this
caller to use the macro wrapper counterpart.

MFC r310031:
linuxkpi: Fix not-found case of linux_pci_find_irq_dev

Linux list_for_each_entry() does not neccessarily end with the iterator
NULL (it may be an offset from NULL if the list member is not the first
element of the member struct).

Reported by: Coverity
CID: 1366940
Reviewed by: hselasky@
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D8780

MFC r313806:
Whitespace fix.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r313807:
Allow passing a constant atomic_t to atomic_read().

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r313808:
Implement more LinuxKPI atomic functions and macros.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r313810:
Allow container_of() to be used with constant data pointers.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r313872:
Implement GFP_DMA32 flag in the LinuxKPI.
Define all FreeBSD native GFP bits as GFP_NATIVE_MASK.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r314040:
Make the LinuxKPI task struct persistent accross system calls.

A set of helper functions have been added to manage the life of the
LinuxKPI task struct. When an external system call or task is invoked,
a check is made to create the task struct by demand. A thread
destructor callback is registered to free the task struct when a
thread exits to avoid memory leaks.

This change lays the ground for emulating the Linux kernel more
closely which is a dependency by the code using the LinuxKPI APIs.

Add new dedicated td_lkpi_task field has been added to struct thread
instead of abusing td_retval[1].

Fix some header file inclusions to make LINT kernel build properly
after this change.

Bump the __FreeBSD_version to force a rebuild of all kernel modules.

Sponsored by: Mellanox Technologies

MFC r314043:
Add support for LinuxKPI tasklets.

Tasklets are implemented using a taskqueue and a small statemachine on
top. The additional statemachine is required to ensure all LinuxKPI
tasklets get serialized. FreeBSD taskqueues do not guarantee
serialisation of its tasks, except when there is only one worker
thread configured.

Sponsored by: Mellanox Technologies

MFC r314044:
Streamline the LinuxKPI spinlock wrappers.

1) Add better spinlock debug names when WITNESS_ALL is defined.

2) Make sure that the calling thread gets bound to the current CPU
while a spinlock is locked. Some Linux kernel code depends on that the
CPU ID doesn't change while a spinlock is locked.

3) Add support for using LinuxKPI spinlocks during a panic().

Sponsored by: Mellanox Technologies

MFC r314050:
Replace dummy implementation of RCU in the LinuxKPI with one based on
the in-kernel concurrency kit's ck_epoch API. Factor RCU hlist_xxx()
functions into own rculist.h header file.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r314105:
Improve LinuxKPI scatter list support.

The i915kms driver in Linux 4.9 reimplement parts of the scatter list
functions with regards to performance. In other words there is not so
much room for changing structure layouts and functionality if the
i915kms should be built AS-IS. This patch aligns the scatter list
support to what is expected by the i915kms driver. Remove some
comments not needed while at it.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r314106:
Optimise unmapped LinuxKPI page allocations.

When allocating unmapped pages, take advantage of the direct map on
AMD64 to get the virtual address corresponding to a page. Else all
pages allocated must be mapped because sometimes the virtual address
of a page is requested.

Move all page allocation and deallocation code into an own C-file.

Add support for GFP_DMA32, GFP_KERNEL, GFP_ATOMIC and __GFP_ZERO
allocation flags.

Make a clear separation between mapped and unmapped allocations.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r314109:
Convert magic values into macros in the LinuxKPI scatterlist
implementation.

Suggested by: cem @
Sponsored by: Mellanox Technologies

MFC r314136:
Implement __test_and_clear_bit() and __test_and_set_bit() in the LinuxKPI.

The clang compiler will optimise these functions down to three AMD64
instructions if the bit argument is a constant during compilation.

Sponsored by: Mellanox Technologies

MFC r314205:
Implement BIT_ULL() macro in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r314207:
Implement srcu_dereference() macro in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r314214:
Prototype device structure to ensure LinuxKPI header file can be
included standalone.

Sponsored by: Mellanox Technologies

MFC r314215:
Implement more string functions in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r314336:
Define __sum16 type in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r314337:
Implement more bit operation functions in the LinuxKPI.
Some minor whitespace nits while at it.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r314604:
Update the LinuxKPI RCU and SRCU wrappers for the concurrency kit, CK.

- Optimise the RCU implementation to not allocate and free
ck_epoch_records during runtime. Instead allocate two sets of
ck_epoch_records per CPU for general purpose use. The first set is
only used for reader locks and the second set is only used for
synchronization and barriers and is protected with a regular mutex to
prevent simultaneous issues.

- Move the task structure away from the rcu_head structure and into
the per-CPU structures. This allows the size of the rcu_head structure
to be reduced down to the size of two pointers.

- Fix a bug where the linux_rcu_barrier() function only waited for one
per-CPU epoch record to be completed instead of all.

- Use a critical section or a mutex to protect ck_epoch_begin() and
ck_epoch_end() depending on RCU or SRCU type. All the ck_epoch_xxx()
functions, except ck_epoch_register(), ck_epoch_unregister() and
ck_epoch_recycle() are not re-entrant and needs a critical section or
a mutex to operate in the LinuxKPI, after inspecting the CK
implementation of the above mentioned functions. The simultaneous
issues arise from per-CPU epoch records being shared between multiple
threads depending on the amount of taskswitching and how many threads
are involved with the RCU and SRCU operations.

- Properly free all epoch records by using safe list traversal at
LinuxKPI module unload. It turns out the ck_epoch_recycle() always
have the records on an internal list and use a flag in the epoch
record to track allocated and free entries. This would lead to use
after free during module unload.

- Remove redundant synchronize_rcu() call from the
linux_compat_uninit() function. Let the linux_rcu_runtime_uninit()
function do the final rcu_barrier() instead.

Sponsored by: Mellanox Technologies

MFC r314675:
Remove duplicate prototype in the LinuxKPI to fix compilation warning.

Reported by: emaste @
Sponsored by: Mellanox Technologies

MFC r314771:
Give LinuxKPI Read-Write semaphores better debug names when
WITNESS_ALL is defined. The lock name is based on the filename and
line number where the initialisation happens.

Sponsored by: Mellanox Technologies

MFC r314772:
Implement DECLARE_RWSEM() macro in the LinuxKPI to initialize a
Read-Write semaphore during module init time.

Sponsored by: Mellanox Technologies

MFC r314774:
Implement add_timer_on() function in the LinuxKPI.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r314843:
LinuxKPI workqueue cleanup.

This change makes the workqueue implementation behave more like in
Linux, both functionality wise and structure wise.

All workqueue code has been moved to linux_work.c

Add an atomic based statemachine to the work_struct to ensure proper
operation. Prior to this change struct_work was directly mapped to a
FreeBSD task. When a taskqueue has multiple threads the same task may
end up being executed on more than one worker thread simultaneously.
This might cause problems with code coming from Linux, which expects
serial behaviour, similar to Linux tasklets.

Move all global workqueue function names into the linux_xxx domain to
avoid symbol name clashes in the future.

Implement a few more workqueue related functions and macros.

Create two multithreaded taskqueues for the LinuxKPI during module
load, one for time-consuming callbacks and one for non-time consuming
callbacks.

Sponsored by: Mellanox Technologies

MFC r314853:
Use grouptaskqueue for tasklets in the LinuxKPI.

This avoids creating own per-CPU threads and also ensures the tasklet
execution happens on the same CPU core invoking the tasklet.

Sponsored by: Mellanox Technologies

MFC r314859:
Make sure jiffies value is cast to an integer in the LinuxKPI before
doing millisecond conversion. Under FreeBSD jiffies are 32-bit.

Sponsored by: Mellanox Technologies

MFC r314861:
Implement time_is_after_eq_jiffies() function in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r314904:
Implement eth_zero_addr() in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r314905:
Cleanup the LinuxKPI slab implementation.

Put large functions into linux_slab.c instead of declaring them static
inline.

Add support for more memory allocation wrappers like kmalloc_array()
and __vmalloc().

Make sure either the M_WAITOK or the M_NOWAIT flag is set and mask
away unused memory allocation flags before calling FreeBSD's malloc()
routine.

Move kmalloc_node() definition to slab.h where it belongs.

Implement support for the SLAB_DESTROY_BY_RCU feature when creating a
kmem_cache which basically means kmem_cache memory is freed using
call_rcu().

Sponsored by: Mellanox Technologies

MFC r314920:
Fix compilation warning for powerpc64 by not using const keyword in
return types:

Type qualifiers ignored on function return type [-Wreturn-type]

Reported by: andreast @
Sponsored by: Mellanox Technologies

MFC r314953:
Don't create any threads before SI_SUB_INIT_IF in the LinuxKPI. Else
kthread_add() will assert it is called too soon. This fixes a startup
issue when COMPAT_LINUXKPI is in enabled the kernel configuration
file.

Reported by: Michael Butler <imb@protected-networks.net>
Sponsored by: Mellanox Technologies

MFC r314965:
Cleanup the LinuxKPI mutex wrappers.

Add support for using mutexes during KDB and shutdown. This is also
required for doing mode-switching during panic for drm-next.

Add new mutex functions mutex_init_witness() and mutex_destroy()
allowing LinuxKPI mutexes to be tracked by witness.

Declare mutex_is_locked() and mutex_is_owned() like inline functions
to get cleaner warnings. These functions are used inside WARN_ON()
statements which might look a bit odd if these functions get fully
expanded.

Give mutexes better debug names through the mutex_name() macro when
WITNESS_ALL is defined. The mutex_name() macro can prefix parts of the
filename and line number before the mutex name.

Sponsored by: Mellanox Technologies

MFC r314970:
Implement support for mutexes with deadlock avoidance in the LinuxKPI.

When locking a mutex and deadlock is detected the first mutex lock
call that sees the deadlock will return -EDEADLK .

Sponsored by: Mellanox Technologies

MFC r314971:
Fix implementation of the DECLARE_WORK() macro in the LinuxKPI to fully
initialize the declared work structure and not only the function callback
pointer.

Sponsored by: Mellanox Technologies

MFC r315244:
Set "current" pointer for LinuxKPI interrupts and timer callbacks.

Sponsored by: Mellanox Technologies

MFC r315410:
Define some more LinuxKPI task related macros.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r315419:
Implement more userspace memory access functions in the LinuxKPI.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r315420:
The LinuxKPI pagefault disable and enable functions can only be used
pairwise to support the FreeBSD way of pushing and popping the page
fault flags. Ensure this by requiring every occurrence of pagefault
disable function call to have a corresponding pagefault enable call.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r315422:
Use __LP64__ to detect presence of suword64() to fix linking and
loading of the LinuxKPI on 32-bit platforms.

Reported by: lwhsu @
Sponsored by: Mellanox Technologies

MFC r315442:
Add comment describing the use of pagefault_disable() and
pagefault_enable() in the LinuxKPI.

Suggested by: rpokala@
Sponsored by: Mellanox Technologies

MFC r315443:
Implement minimalistic memory mapping structure, struct mm_struct, and
some associated helper functions in the LinuxKPI. Let the existing
linux_alloc_current() function allocate and initialize the new
structure and let linux_free_current() drop the refcount on the memory
mapping structure. When the mm_struct's refcount reaches zero, the
structure is freed.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r315457:
Implement get_pid_task(), pid_task() and some other PID helper
functions in the LinuxKPI. Add a usage atomic to the task_struct
structure to facilitate refcounting the task structure when returned
from get_pid_task(). The get_task_struct() and put_task_struct()
function is used to manage atomic refcounting. After this change the
task_struct should only be freed through put_task_struct().

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r315713:
Add support for more IPv4 and IPv6 related macros in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r315714:
Add full VNET support to the inet_get_local_port_range() function in
the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r315719:
Extend cmpxchg() to support 8- and 16-bit values, and add xchg().

These are needed to support updated revisions of the DRM code.

Reviewed by: hselasky (previous version)

MFC r315856:
Add support for ratelimited printouts in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r315859:
Function macros are preferred in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r315863:
Add proper error checking for the string to number conversion
functions in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r315864:
Use ppsratecheck() for ratelimiting in the LinuxKPI.

Suggested by: cem @
Sponsored by: Mellanox Technologies

MFC r316033:
Implement a series of physical page management related functions in
the LinuxKPI for accessing user-space memory in the kernel.

Add functions to hold and wire physical page(s) based on a given range
of user-space virtual addresses.

Add functions to get and put a reference on, wire, hold, mark
accessed, copy and dirty a physical page.

Add new VM related structures and defines as a preparation step for
advancing the memory map capabilities of the LinuxKPI.

Add function to figure out if a virtual address was allocated using
malloc().

Add function to convert a virtual kernel address into its physical
page pointer.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r316034:
Add more platforms supporting the direct map feature in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r316035:
Implement vmalloc_32() in the LinuxKPI.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r316521:
Implement down_write_killable() in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r316522:
Unify error handling when si_drv1 is NULL in the LinuxKPI.

Make sure the character device poll callback function does not return
an error code, but a POLLXXX value, in case of failure.

Sponsored by: Mellanox Technologies

MFC r316561:
Before registering a new mm_struct in the LinuxKPI check if other
tasks in the belonging procedure already have a valid mm_struct and
reference that instead.

The mm_struct in the LinuxKPI should be shared among all tasks
belonging to the same procedure. This has to do with with the mmap_sem
semaphore which should serialize all VM operations inside a given
procedure. Linux based drivers depend on this behaviour.

Sponsored by: Mellanox Technologies

MFC r316562:
Implement proper support for memory map operations in the LinuxKPI,
like open, close and fault using the character device pager.

Some notes about the implementation:

1) Linux drivers set the vm_ops and vm_private_data fields during a
mmap() call to indicate that the driver wants to use the LinuxKPI VM
operations. Else these operations are not used.

2) The vm_private_data pointer is associated with a VM area structure
and inserted into an internal LinuxKPI list. If the vm_private_data
pointer already exists, the existing VM area structure is used instead
of the allocated one which gets freed.

3) The LinuxKPI's vm_private_data pointer is used as the callback
handle for the FreeBSD VM object. The VM subsystem in FreeBSD has a
similar list to identify equal handles and will only call the
character device pager's close function once.

4) All LinuxKPI VM operations are serialized through the mmap_sem
sempaphore, which is per procedure, which prevents simultaneous access
to the shared VM area structure when receiving page faults.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r316563:
Fix implementation of task_pid_group_leader() in the LinuxKPI.

In FreeBSD thread IDs and procedure IDs have distinct number
spaces. When asking for the group leader task ID in the LinuxKPI,
return the procedure ID and let this resolve to the first task in the
procedure having a valid LinuxKPI task structure pointer.

Sponsored by: Mellanox Technologies

MFC r316564:
Implement need_resched() in the LinuxKPI.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r316565:
Define VM_READ, VM_WRITE and VM_EXEC in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r316568:
Cleanup the bitmap_xxx() functions in the LinuxKPI:

- Move all bitmap related functions from bitops.h to bitmap.h, similar
to what Linux does.

- Apply some minor code cleanup and simplifications to optimize the
generated code when using static inline functions.

- Implement the following list of bitmap functions which are needed by
drm-next and ibcore:
- bitmap_find_next_zero_area_off()
- bitmap_find_next_zero_area()
- bitmap_or()
- bitmap_and()
- bitmap_xor()

- Add missing include directives to the qlnxe driver
(davidcs@ has been notified)

Sponsored by: Mellanox Technologies

MFC r316606:
The __stringify() macro in the LinuxKPI should expand any macros
before stringifying.

Sponsored by: Mellanox Technologies

MFC r316609:
Create the LinuxKPI current task structure on the fly if it doesn't
exist when the current macro is used.

Sponsored by: Mellanox Technologies

MFC r316656:
Fix compilation of LinuxKPI for PowerPC.

Found by: emaste @
Sponsored by: Mellanox Technologies

MFC r317135:
Zero number of CPUs should be translated into the default number of
CPUs when allocating a LinuxKPI workqueue. This also ensures that the
created taskqueue always have a non-zero number of worker threads.

Sponsored by: Mellanox Technologies

MFC r317137:
Fix problem regarding priority inversion when using the concurrency
kit, CK, in the LinuxKPI.

When threads are pinned to a CPU core or when there is only one CPU,
it can happen that a higher priority thread can call the CK
synchronize function while a lower priority thread holds the read
lock. Because the CK's synchronize is a simple wait loop this can lead
to a deadlock situation. To solve this problem use the recently
introduced CK's wait callback function.

When detecting a CK blocking condition figure out the lowest priority
among the blockers and update the calling thread's priority and
yield. If another CPU core is holding the read lock, pin the thread to
the blocked CPU core and update the priority. The calling threads
priority and CPU bindings are restored before return.

If a thread holding a CK read lock is detected to be sleeping, pause()
will be used instead of yield().

Sponsored by: Mellanox Technologies

MFC r317138:
Use __typeof() instead of typeof() in some RCU related macros in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r317504:
Prefer to use real virtual address over direct map address in the
linux_page_address() function in the LinuxKPI. This solves an issue
where the return value from linux_page_address() is passed to
kmem_free().

Sponsored by: Mellanox Technologies

MFC r317651:
Add on_each_cpu() and wbinvd_on_all_cpus().

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

MFC r317828:
Fix for use after free in the LinuxKPI.

Background:
The same VM object might be shared by multiple processes and the
mm_struct is usually freed when a process exits.

Grab a reference on the mm_struct while the vmap is in the
linux_vma_head list in case the first process which inserted a VM
object has exited.

Tested by: kwm @
Sponsored by: Mellanox Technologies

MFC r317839:
Use pmap_invalidate_cache() to implement wbinvd_on_all_cpus().

Suggested by: jhb
X-MFC with: r317651

MFC r318026:
Fix init order in the LinuxKPI for RCU support.

CPU_FOREACH() is not available until SI_SUB_CPU at SI_ORDER_ANY
when the LinuxKPI is loaded as part of the kernel.

Sponsored by: Mellanox Technologies

MFC r318590:
Add get_cpu() and put_cpu().

MFC r319229:
Add some miscellaneous definitions to support DRM drivers.

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

MFC r319312:
Make sure the thread's priority is restored for all three cases inside
linux_synchronize_rcu_cb() in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r319316:
Fixes for refcounting "struct linux_file" in the LinuxKPI.

- Allow "struct linux_file" to be refcounted when its "_file" member
is NULL by using its "f_count" field. The reference counts are
transferred to the file structure when the file descriptor is
installed.

- Add missing vdrop() calls for error cases during open().

- Set the "_file" member of "struct linux_file" during open. This
allows use of refcounting through get_file() and fput() with LinuxKPI
character devices.

Sponsored by: Mellanox Technologies

MFC r319317:
Fix a reference count leak in the LinuxKPI due to calling VM open when
it shouldn't be called.

Background:
The Linux VM open operation is called when a new VMA is
created on top of the current VMA. This is done through either mremap
flow or split_vma, usually due to mlock, madvise, munmap and so
on. This is currently not supported by the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r319318:
Don't acquire a reference on the VM-space when allocating the LinuxKPI
task structure to avoid deadlock when tearing down the VM object
during a process exit.

Found by: markj @
Sponsored by: Mellanox Technologies

MFC r319319:
Remove the VMA handle from its list before calling the LinuxKPI VMA
close operation to prevent other threads from reusing the VM object
handle pointer.

Sponsored by: Mellanox Technologies

MFC r319320:
Make sure the VMAP's "vm_file" field is referenced in a Linux
compatible way by the linux_dev_mmap_single() function in the
LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r319321:
Properly set the .d_name field in the cdevsw structure for the
LinuxKPI.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r319338:
Implement in_atomic() function in the LinuxKPI.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r319340:
Properly implement idr_preload() and idr_preload_end() in the
LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r319341:
Implement print_hex_dump(), print_hex_dump_bytes() and
printk_ratelimited() in the LinuxKPI.

While at it fix the inclusion guard of printk.h to be similar to the
rest of the LinuxKPI header files.

Sponsored by: Mellanox Technologies

MFC r319409:
Add generic kqueue() and kevent() support to the LinuxKPI character
devices. The implementation allows read and write filters to be
created and piggybacks on the poll() file operation to determine when
a filter should trigger. The piggyback mechanism is simply to check
for the EWOULDBLOCK or EAGAIN return code from read(), write() or
ioctl() system calls and then update the kqueue() polling state bits.
The implementation is similar to the one found in the cuse(3) module.
Refer to sys/fs/cuse/*.[ch] for more details.

Sponsored by: Mellanox Technologies

MFC r319410:
Translate the ERESTARTSYS error code into ERESTART in the LinuxKPI
ioctl(), read() and write() system call handlers. This error code is
internal to the kernel and should not be seen by user-space programs
according to Linux.

Submitted by: Yanko Yankulov <yanko.yankulov@gmail.com>
Sponsored by: Mellanox Technologies

MFC r319444:
Make sure the selrecord() function is only called from within system
polling contexts in the LinuxKPI.

After the kqueue() support was added to the LinuxKPI in r319409 the
Linux poll file operation will be used outside the system file polling
callback function, which can cause a NULL-pointer panic inside
selrecord() because curthread->td_sel is set to NULL. This patch moves
the selrecord() call away from poll_wait() and to the system file poll
callback function in the LinuxKPI, which essentially wraps the Linux
one. This is similar to what the cuse(3) module is currently doing.
Refer to sys/fs/cuse/*.[ch] for more details.

Sponsored by: Mellanox Technologies

MFC r319500:
Add support for setting the non-blocking I/O flag for LinuxKPI
character devices. In Linux the FIONBIO IOCTL is handled by the kernel
and not the drivers. Also need return success for the FIOASYNC ioctl
due to existing logic in kern_fcntl() even though it is not supported
currently.

Sponsored by: Mellanox Technologies

MFC r319501:
Improve kqueue() support in the LinuxKPI. Some applications using the
kqueue() does not set non-blocking I/O mode for event driven read of
file descriptors. This means the LinuxKPI internal kqueue read and
write event flags must be updated before the next read and/or write
system call. Else the read and/or write system call may block. This
can happen when there is no more data to read following a previous
read event. Then the application also gets blocked from processing
other events. This situation can also be solved by the applications
setting and using non-blocking I/O mode.

Sponsored by: Mellanox Technologies

MFC r319620:
Fix init order in the LinuxKPI for IDR support after recent changes.

CPU_FOREACH() is not available until SI_SUB_CPU at SI_ORDER_ANY
when the LinuxKPI is loaded as part of the kernel.

Sponsored by: Mellanox Technologies

MFC r319656:
Add more #ifdef arch checks to the linuxkpi

arm, mips, and powerpc all implement pmap_mapdev_attr() and pmap_unmapdev(),
so add those archs to the checks. powerpc also includes the atomic_swap_*()
functions, so add that to the supported list as well. Not tested except by
compiling powerpc.

Reviewed by: markj

MFC r319675:
Remove ARM and MIPS from linuxkpi ioremap_attr definition

ARM and MIPS fail universe builds.

ARM and MIPS are missing the following:
* VM_MEMATTR_WRITE_THROUGH
* VM_MEMATTR_WRITE_COMBINING

Pointy-hat to: jhibbits

MFC r319757:
Augment wait queue support in the LinuxKPI.

In particular:
- Don't evaluate event conditions with a sleepqueue lock held, since such
code may attempt to acquire arbitrary locks.
- Fix the return value for wait_event_interruptible() in the case that the
wait is interrupted by a signal.
- Implement wait_on_bit_timeout() and wait_on_atomic_t().
- Implement some functions used to test for pending signals.
- Implement a number of wait_event_*() variants and unify the existing
implementations.
- Unify the mechanism used by wait_event_*() and schedule() to put the
calling thread to sleep.

This is required to support updated DRM drivers. Thanks to hselasky for
finding and fixing a number of bugs in the original revision.

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

MFC r319758:
Implement pci_disable_device() in the LinuxKPI.

Submitted by: kmacy

MFC r320063:
Remove prototypes for unimplemented LinuxKPI functions.

MFC r320072:
Avoid including list.h in LinuxKPI headers.

list.h includes a number of FreeBSD headers as a workaround for the
LIST_HEAD name collision. To reduce pollution, avoid including list.h
in commonly used headers when it is not explicitly needed.

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

MFC r320078:
Add kthread parking support to the LinuxKPI.

Submitted by: kmacy (original version)
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D11264

MFC r320189:
Allow the VM fault handler to be NULL in the LinuxKPI when handling a
memory map request. When the VM fault handler is NULL a return code of
VM_PAGER_BAD is returned from the character device's pager populate
handler. This fixes compatibility with Linux.

Sponsored by: Mellanox Technologies

MFC r320192:
Add a lockdep macro to the LinuxKPI.

Also fix some nearby style issues.

MFC r320193:
Include kmod.h from the LinuxKPI's module.h.

MFC r320194:
Add missing lock destructor invocations to the LinuxKPI unload handler.

MFC r320196:
Update io-mapping.h in the LinuxKPI.

Add io_mapping_init_wc() and add a third (unused) parameter to
io_mapping_map_wc().

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

MFC r320333:
Add noop_lseek() to the LinuxKPI.

MFC r320334:
Add the thaw_early method to struct dev_pm_ops in the LinuxKPI.

MFC r320335:
Add a couple of macros to lockdep.h in the LinuxKPI.

MFC r320336:
Add ns_to_ktime() to the LinuxKPI.

MFC r320337:
Add u64_to_user_ptr() to the LinuxKPI.

MFC r320364:
Implement parts of the hrtimer API in the LinuxKPI.

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

MFC r320580:
Let io_mapping_init_wc() fall back to an uncacheable mapping.

This allows usage of the function on architectures that don't support
write-combining.

Reported by: bz, emaste
X-MFC With: r320196

MFC r320627:
Hold the PCI device list lock when removing an element.

MFC r320633:
Rename the "driver" field to "bsddriver" to avoid a name collision.

MFC r320634:
Add some PCI class definitions.

MFC r320635:
Add a field for the class code to struct pci_driver.

Fill out some previously uninitialized fields as well.

MFC r320636:
Add some auxiliary types for device driver support.

MFC r320656:
Invoke suspend/resume methods from the driver pmops if available.

Obtained from: kmacy (original version)

MFC r320774:
Fix a bug in synchronize RCU when the calling thread is bound to a CPU.

Set "td_pinned" to zero after "sched_unbind()" to prevent "td_pinned"
from temporarily becoming negative during "sched_bind()". This can
happen if "sched_bind()" uses "sched_pin()" and "sched_unpin()".

Sponsored by: Mellanox Technologies

MFC r320775:
Complete r320189 which allows a NULL VM fault handler in the LinuxKPI.
Instead of mapping a dummy page upon a page fault, map the page
pointed to by the physical address given by IDX_TO_OFF(vmap->vm_pfn).
To simplify the implementation use OBJT_DEVICE to implement our own
linux_cdev_pager_fault() instead of using the existing
linux_cdev_pager_populate().

Some minor code factoring while at it.

Reviewed by: markj @
Sponsored by: Mellanox Technologies

MFC r320810:
Add TASK_COMM_LEN to the LinuxKPI.

MFC r320811:
Add device_is_registered() to the LinuxKPI.

MFC r320812:
Fix the definitions of pgprot_{noncached,writecombine} after r316562.

MFC r320813:
Add some helper definitions to fs.h in the LinuxKPI.

Add a field to struct linux_file to allow the creation of anonymous
shmem objects.

MFC r320852:
Free existing per-thread task structs when unloading linuxkpi.ko.

They are otherwise leaked.

Reported and tested by: ae

MFC r320853:
Add a few functions to ktime.h in the LinuxKPI, and fix nearby style.

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

MFC r320854:
Add some functions to math64.h in the LinuxKPI, and fix nearby style.

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

MFC r320956:
Add some functions to jiffies.h.

Also add some checks for overflow to existing functions.

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

MFC r321773:
Remove cycle_t type from the LinuxKPI similar to Linux upstream.

Sponsored by: Mellanox Technologies

MFC r321926:
Fix LinuxKPI regression after r321920. The mda_unit and si_drv0 fields are not
wide enough to hold the full 64-bit dev_t. Instead use the "dev" field in
the "linux_cdev" structure to store and lookup this value.

While at it remove superfluous use of parenthesis inside the
MAJOR(), MINOR() and MKDEV() macros in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r322028:
Add subsystem vendor and device ID fields to struct pci_dev.

MFC r322169:
Fix hrtimer_active() in case of cancellation.

While there, switch to FreeBSD internal callout active status.

Reviewed by: markj, hselasky
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D11900

MFC r322212:
Add macros for defining attribute groups and for WO and RW attributes.

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

MFC r322213:
Add round_jiffies_up(), local_clock() and __setup_timer() to the LinuxKPI.

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

MFC r322272:
Fix few issues of LinuxKPI workqueue.

LinuxKPI workqueue wrappers reported "successful" cancellation for works
already completed in normal way. This change brings reported status and
real cancellation fact into sync. This required for drm-next operation.

Reviewed by: hselasky (earlier version)
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D11904

MFC r322354:
Make sure the linux_wait_event_common() function in the LinuxKPI properly
handles a timeout value of MAX_SCHEDULE_TIMEOUT which basically means there
is no timeout. This is a regression issue after r319757.

While at it change the type of returned variable from "long" to "int" to
match the actual return type.

Sponsored by: Mellanox Technologies

MFC r322355:
Fixes for wait event in the LinuxKPI. These are regression issues
after r319757.

1) Correct the return value from __wait_event_common() from 1 to 0 in
case the timeout is specified as MAX_SCHEDULE_TIMEOUT. In the other
case __ret is zero and will be substituted in the last part of the
macro with the appropriate value before return.

2) Make sure the "timeout" argument is casted to "int" before
evaluating negativity. Else the signedness of a "long" might be
checked instead of the signedness of an integer.

3) The wait_event() function should not have a return value.

Found by: KrishnamRaju ErapaRaju <Krishna2@chelsio.com>
Sponsored by: Mellanox Technologies

MFC r322357:
Use integer type to pass around jiffies and/or ticks values in the
LinuxKPI because in FreeBSD ticks are 32-bit.

Sponsored by: Mellanox Technologies

MFC r322392:
Add a specialized function for DRM drivers to register themselves.

Such drivers attach to a vgapci bus rather than directly to a pci bus. For
the rest of the LinuxKPI to work correctly in this case, we override the
vgapci bus' ivars with those of the grandparent.

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

MFC r322397:
Make sure the "vm_flags" and "vm_page_prot" fields get set correctly
in the VM area structure in the LinuxKPI when doing mmap() and that
unsupported bits are masked away.

While at it fix some redundant use of parenthesing inside some related
macros.

Found by: KrishnamRaju ErapaRaju <Krishna2@chelsio.com>
Sponsored by: Mellanox Technologies

MFC r322567:
Add device resource management fields to struct device.

MFC r322713:
Add a couple of trivial headers to the LinuxKPI.

MFC r322714:
Define prefetch() only if it hasn't already been defined.

MFC r322746:
Fix for deadlock situation in the LinuxKPI's RCU synchronize API.

Deadlock condition:
The return value of TDQ_LOCKPTR(td) is the same for two threads.

1) The first thread signals a wakeup while keeping the rcu_read_lock().
This invokes sched_add() which in turn will try to lock TDQ_LOCK().

2) The second thread is calling synchronize_rcu() calling mi_switch() over
and over again trying to yield(). This prevents the first thread from running
and releasing the RCU reader lock.

Solution:
Release the thread lock while yielding to allow other threads to acquire the
lock pointed to by TDQ_LOCKPTR(td).

Found by: KrishnamRaju ErapaRaju <Krishna2@chelsio.com>
Sponsored by: Mellanox Technologies

MFC r322795:
Add some miscellaneous definitions to support the DRM drivers.

MFC r322816:
Set the bus number field when attaching a PCI device.

MFC r323347:
Add more sanity checks to linux_fget() in the LinuxKPI. This prevents
returning pointers to file descriptors which were not created by the
LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r323349:
Properly implement poll_wait() in the LinuxKPI. This prevents direct
use of the linux_poll_wakeup() function from unsafe contexts, which
can lead to use-after-free issues.

Instead of calling linux_poll_wakeup() directly use the wake_up()
family of functions in the LinuxKPI to do this.

Bump the FreeBSD version to force recompilation of external kernel modules.

Sponsored by: Mellanox Technologies

MFC r323703:
Add support for shared memory functions to the LinuxKPI.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

MFC r323704:
Only wire pages in the LinuxKPI instead of holding and wiring them.
This prevents the page daemon from regularly scanning the held pages.

Suggested by: kib @
Sponsored by: Mellanox Technologies

MFC r323705:
The LinuxKPI atomics do not have acquire nor release semantics unless
specified. Fix code to use READ_ONCE() and WRITE_ONCE() where appropriate.

Suggested by: kib @
Sponsored by: Mellanox Technologies

MFC r323910:
Add support for 32-bit compatibility IOCTLs in the LinuxKPI.

Bump the FreeBSD version to force recompilation of external
kernel modules due to structure change.

PR: 222504
Submitted by: Greg V <greg@unrelenting.technology>
Sponsored by: Mellanox Technologies

MFC r324278:
Make sure the timer belonging to the delayed work in the LinuxKPI
gets drained before invoking the work function. Else the timer
mutex may still be in use which can lead to use-after-free situations,
because the work function might free the work structure before returning.

Sponsored by: Mellanox Technologies

MFC r324285:
Add get_random_{int,long} to the LinuxKPI.

Fix some whitespace bugs while here.

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

MFC r324597:
Don't call selrecord() outside the select system call in the LinuxKPI, because
then td->td_sel is NULL and this will result in a segfault inside selrecord().
This happens when only using kqueue() to poll for read and write events.
If select() and kqueue() is mixed there won't be a segfault.

Reported by: Johannes Lundberg
Sponsored by: Mellanox Technologies

MFC r324606:
Make the PHOLD in linux_wait_event_common() unconditional.

After some in-progress work is committed, this would otherwise be the only
instance of #if(n)def NO_SWAPPING in the tree. Moreover, the requisite
opt_vm.h include was missing, so the PHOLD/PRELE calls were always being
compiled in anyway.

MFC r325279:
Implement ioread16be() in the LinuxKPI.

Sponsored by: Mellanox Technologies

MFC r325360:
Remove redundant dev->si_drv1 NULL checks in the LinuxKPI.
This pointer is checked during the linux_dev_open() callback and does
not need to be NULL checked again. It should always be set for
character devices belonging to the "linuxcdevsw" and technically
there is no need to NULL check this pointer at all.

Suggested by: kib @
Sponsored by: Mellanox Technologies

MFC r325635:
Remove some not needed comments in the LinuxKPI. Use the Linux source tree
to lookup documentation for the functions implemented in the LinuxKPI
instead.

Sponsored by: Mellanox Technologies

MFC r325707:
Mask away return codes from del_timer() and del_timer_sync() because
they are not the same like in Linux.

Sponsored by: Mellanox Technologies

MFC r325708:
Remove release and acquire semantics when accessing the "state" field of the
LinuxKPI task struct. Change type of "state" variable from "int" to
"atomic_t" to simplify code and avoid unneccessary casting.

Sponsored by: Mellanox Technologies

MFC r325767:
Properly handle the case where the linux_cdev_handle_insert() function
in the LinuxKPI returns NULL. This happens when the VM area's private
data handle already exists and could cause a so-called NULL pointer
dereferencing issue prior to this fix.

Found by: greg@unrelenting.technology
Sponsored by: Mellanox Technologies

MFC r327676:
linuxkpi: Implement kcalloc() based on mallocarray()

This means we now get integer overflow protection, which Linux code
might expect as it is also provided by kcalloc() in Linux.

MFC r327788:
linuxkpi: Simplify kmalloc_array.

kmalloc_array seems what we call mallocarray(9).

MFC r312926: (partial, no mergeinfo)
Revert r312923 a better approach will be taken later

MFC r312927: (partial, no mergeinfo)
Revert crap accidentally committed

MFC r316665: (partial, no mergeinfo)
Import CK as of commit 6b141c0bdd21ce8b3e14147af8f87f22b20ecf32
This brings us changes we needed in ck_epoch.

MFC r317053: (partial, no mergeinfo)
Remove unneeded include of vm_phys.h.

MFC r317055: (partial, no mergeinfo)
All these files need sys/vmmeter.h, but now they got it implicitly
included via sys/pcpu.h.

MFC r322168: (partial, no mergeinfo)
o Replace __riscv__ with __riscv
o Replace __riscv64 with (__riscv && __riscv_xlen == 64)

This is required to support new GCC 7.1 compiler.
This is compatible with current GCC 6.1 compiler.

RISC-V is extensible ISA and the idea here is to have built-in define
per each extension, so together with __riscv we will have some subset
of these as well (depending on -march string passed to compiler):

__riscv_compressed
__riscv_atomic
__riscv_mul
__riscv_div
__riscv_muldiv
__riscv_fdiv
__riscv_fsqrt
__riscv_float_abi_soft
__riscv_float_abi_single
__riscv_float_abi_double
__riscv_cmodel_medlow
__riscv_cmodel_medany
__riscv_cmodel_pic
__riscv_xlen

Reviewed by: ngie
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D11901

MFC r322672: (partial, no mergeinfo)
Move some other SI_SUB_INIT_IF initializations to SI_SUB_TASKQ

Drop the EARLY_AP_STARTUP gtaskqueue code, as gtaskqueues are now
initialized before APs are started.

Reviewed by: hselasky@, jhb@
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D12054

MFC r326984: (partial, no mergeinfo)
Update Matthew Macy contact info

Email address has changed, uses consistent name (Matthew, not Matt)

Reported by: Matthew Macy <mmacy@mattmacy.io>
Differential Revision: https://reviews.freebsd.org/D13537


/freebsd-11-stable/sys/compat/linuxkpi/common/include/asm/atomic-long.h
/freebsd-11-stable/sys/compat/linuxkpi/common/include/asm/atomic.h
/freebsd-11-stable/sys/compat/linuxkpi/common/include/asm/atomic64.h
/freebsd-11-stable/sys/compat/linuxkpi/common/include/asm/msr.h
/freebsd-11-stable/sys/compat/linuxkpi/common/include/asm/pgtable.h
/freebsd-11-stable/sys/compat/linuxkpi/common/include/asm/smp.h
atomic.h
bitmap.h
bitops.h
bottom_half.h
cdev.h
clocksource.h
compat.h
compiler.h
completion.h
device.h
dma-mapping.h
etherdevice.h
file.h
fs.h
gfp.h
hrtimer.h
idr.h
in.h
interrupt.h
io-mapping.h
io.h
jiffies.h
kdev_t.h
kernel.h
kobject.h
kthread.h
ktime.h
list.h
lockdep.h
math64.h
mm.h
mm_types.h
module.h
mutex.h
page.h
pci.h
pfn.h
pfn_t.h
pid.h
poll.h
preempt.h
printk.h
random.h
rculist.h
rcupdate.h
rwlock.h
rwsem.h
scatterlist.h
sched.h
semaphore.h
slab.h
smp.h
spinlock.h
srcu.h
string.h
sysfs.h
timer.h
types.h
uaccess.h
wait.h
workqueue.h
ww_mutex.h
/freebsd-11-stable/sys/compat/linuxkpi/common/include/net/ip.h
/freebsd-11-stable/sys/compat/linuxkpi/common/include/net/ipv6.h
/freebsd-11-stable/sys/compat/linuxkpi/common/src/linux_compat.c
/freebsd-11-stable/sys/compat/linuxkpi/common/src/linux_current.c
/freebsd-11-stable/sys/compat/linuxkpi/common/src/linux_hrtimer.c
/freebsd-11-stable/sys/compat/linuxkpi/common/src/linux_idr.c
/freebsd-11-stable/sys/compat/linuxkpi/common/src/linux_kthread.c
/freebsd-11-stable/sys/compat/linuxkpi/common/src/linux_lock.c
/freebsd-11-stable/sys/compat/linuxkpi/common/src/linux_page.c
/freebsd-11-stable/sys/compat/linuxkpi/common/src/linux_pci.c
/freebsd-11-stable/sys/compat/linuxkpi/common/src/linux_rcu.c
/freebsd-11-stable/sys/compat/linuxkpi/common/src/linux_schedule.c
/freebsd-11-stable/sys/compat/linuxkpi/common/src/linux_slab.c
/freebsd-11-stable/sys/compat/linuxkpi/common/src/linux_tasklet.c
/freebsd-11-stable/sys/compat/linuxkpi/common/src/linux_work.c
/freebsd-11-stable/sys/conf/files
/freebsd-11-stable/sys/conf/files.amd64
/freebsd-11-stable/sys/contrib/rdma/krping/krping.c
/freebsd-11-stable/sys/dev/mlx5/mlx5_core/mlx5_uar.c
/freebsd-11-stable/sys/dev/qlnx/qlnxe/bcm_osal.h
/freebsd-11-stable/sys/modules/linuxkpi/Makefile
/freebsd-11-stable/sys/modules/qlnx/qlnxe/Makefile
/freebsd-11-stable/sys/ofed/drivers/infiniband/core/cma.c
/freebsd-11-stable/sys/ofed/drivers/infiniband/core/fmr_pool.c
/freebsd-11-stable/sys/ofed/drivers/infiniband/core/iwcm.c
/freebsd-11-stable/sys/ofed/drivers/infiniband/core/umem.c
/freebsd-11-stable/sys/ofed/drivers/infiniband/hw/mthca/mthca_dev.h
/freebsd-11-stable/sys/ofed/drivers/net/mlx4/pd.c
/freebsd-11-stable/sys/sys/param.h
/freebsd-11-stable/sys/sys/proc.h
325936 17-Nov-2017 hselasky

MFC r325533:
Make the dma_alloc_coherent() function in the LinuxKPI NULL safe with regard
to the "dev" argument.

Submitted by: Krishnamraju Eraparaju @ Chelsio
Sponsored by: Chelsio Communications

325612 09-Nov-2017 hselasky

MFC r325278:
Unconditionally include "opt_inet6.h" in the LinuxKPI.
This makes sure the INET6 macro gets properly defined,
also for kernel module builds.

Sponsored by: Mellanox Technologies

324526 11-Oct-2017 hselasky

MFC r315404:
Add basic support for VIMAGE to the LinuxKPI and ibcore.

Support is implemented by mapping Linux's "struct net" into FreeBSD's
"struct vnet". Currently only vnet0 is supported by ibcore.

Sponsored by: Mellanox Technologies

324524 11-Oct-2017 hselasky

MFC r315405, r323351 and r323364:
Add helper function similar to ip_dev_find() to the LinuxKPI to lookup
a network device by its IPv6 address in the given VNET.

Sponsored by: Mellanox Technologies

323214 06-Sep-2017 rlibby

MFC r321376:

linuxkpi compiler.h: avoid gcc -Wunused-value in dummy expressions

322498 14-Aug-2017 hselasky

MFC r314878:
Add support for constant pointer constructs to READ_ONCE() in the
LinuxKPI. When the type of the argument is constant the temporary
variable cannot be assigned after the barrier. Instead assign the
temporary variable by initialization.

Sponsored by: Mellanox Technologies

315284 14-Mar-2017 mjg

MFC r312888:

Introduce __read_mostly and __exclusive_cache_line macros.

The intended use is to annotate frequently used globals which either rarely
change (and thus can be grouped in the same cacheline) or are an atomic counter
(which means it may benefit from being the only variable in the cacheline).

Linker script support is provided only for amd64. Architectures without it risk
having other variables put in, i.e. as if they were not annotated. This is
harmless from correctness point of view.

311803 09-Jan-2017 hselasky

MFC r310559 and r310583:
Implement register and unregister chrdev in the LinuxKPI.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

311802 09-Jan-2017 hselasky

MFC r310589:
Implement more list header file functions.
Add definition guard for the list_head structure.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

311801 09-Jan-2017 hselasky

MFC r310553:
Improve LinuxKPI device support. Only delete own BSD devices and not
the ones obtained through devclass_get_device(). Some minor code
cleanups while at it.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

311800 09-Jan-2017 hselasky

MFC r310557:
Use correct integer type when computing the maximum physical address
for kmem_alloc_contig().

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

310252 19-Dec-2016 hselasky

MFC r309737:
Add more LinuxKPI PCI definitions.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

310251 19-Dec-2016 hselasky

MFC r309736:
Prefer function macros over regular macros in the LinuxKPI.

Sponsored by: Mellanox Technologies

310250 19-Dec-2016 hselasky

MFC r309732:
Prefix some _pci_xxx() functions in the Linux KPI with linux_ and make
sure the IRQ number used by these functions is unsigned.

Sponsored by: Mellanox Technologies

310247 19-Dec-2016 hselasky

MFC r309731:
Prefix the Linux KPI's kmem_xxx() functions with linux_ to avoid
conflict with the opensolaris kernel module.

This patch solves a problem where the kernel linker will incorrectly
resolve opensolaris kmem_xxx() functions as linuxkpi ones, which leads
to a panic when these functions are used.

Submitted by: gallatin @
Sponsored by: Mellanox Technologies

310246 19-Dec-2016 hselasky

MFC r309733:
MSIX can support more than 256 IRQs. Make sure the invalid IRQ number
set in the LinuxKPI is big enough.

Sponsored by: Mellanox Technologies

310245 19-Dec-2016 hselasky

MFC r309734:
Avoid malloc() warnings when using the LinuxKPI by zero-checking
the allocation flags.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies

307010 11-Oct-2016 sephe

MFC 306480

linuxkpi: Fix PCI BAR lazy allocation support.

FreeBSD supports lazy allocation of PCI BAR, that is, when a device
driver's attach method is invoked, even if the device's PCI BAR
address wasn't initialized, the invocation of bus_alloc_resource_any()
(the call chain: pci_alloc_resource() -> pci_alloc_multi_resource() ->
pci_reserve_map() -> pci_write_bar()) would allocate a proper address
for the PCI BAR and write this 'lazy allocated' address into the PCI
BAR.

This model works fine for native FreeBSD device drivers, but _not_ for
device drivers shared with Linux (e.g. dev/mlx5/mlx5_core/mlx5_main.c
and ofed/drivers/net/mlx4/main.c. Both of them use
pci_request_regions(), which doesn't work properly with the PCI BAR
lazy allocation, because pci_resource_type() -> _pci_get_rle() always
returns NULL, so pci_request_regions() doesn't have the opportunity to
invoke bus_alloc_resource_any(). We now use pci_find_bar() in
pci_resource_type(), which is able to locate all available PCI BARs
even if some of them will be lazy allocated.

Submitted by: Dexuan Cui <decui microsoft com>
Reviewed by: hps
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8071

306949 10-Oct-2016 hselasky

MFC r306451:
The IORESOURCE_XXX defines should resemble a bitmask while SYS_RES_XXX
are not bitmasks. Fix return value of pci_resource_flags() to reflect
this change.

Sponsored by: Mellanox Technologies

302408 08-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
301544 07-Jun-2016 hselasky

Fallback to arc4rand() in the LinuxKPI when read_random() returns
zero. This can happen for virtual machines.

MFC after: 1 week
Sponsored by: Mellanox Technologies


300835 27-May-2016 hselasky

The SCHEDULER_STOPPED() macro already contains a predict false statement.
Remove superfluous unlikely() wrapper.

Suggested by: glebius
MFC after: 1 week
Sponsored by: Mellanox Technologies


300721 26-May-2016 hselasky

Add support for runtime modifiable module parameters in the LinuxKPI.

Linux module parameters have a permissions value. If any write bits
are set we are allowed to modify the module parameter runtime. Reflect
this when creating the static SYSCTL nodes.

Sponsored by: Mellanox Technologies
MFC after: 1 week


300720 26-May-2016 hselasky

Add more module parameter macros to the LinuxKPI.

Obtained from: kmacy @
Sponsored by: Mellanox Technologies


300719 26-May-2016 hselasky

Add support for boolean module parameters in the LinuxKPI.

Requested by: kmacy @
Sponsored by: Mellanox Technologies


300677 25-May-2016 hselasky

Implement Linux module parameters as read-only tunable SYSCTLs.

Bool module parameters are no longer supported, because there is no
equivalent in FreeBSD.

There are two macros available which control the behaviour of the
LinuxKPI module parameters:

- LINUXKPI_PARAM_PARENT allows the consumer to set the SYSCTL parent
where the modules parameters will be created.

- LINUXKPI_PARAM_PREFIX defines a parameter name prefix, which is
added to all created module parameters.

Sponsored by: Mellanox Technologies
MFC after: 1 week


300671 25-May-2016 hselasky

Add checks for SCHEDULER_STOPPED() so that code using the LinuxKPI can
run after a panic(). This for example allows a LinuxKPI based graphics
stack to receive prints during a panic.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


300594 24-May-2016 kevlo

Add __iowrite32_copy() to the Linux kernel compatibility layer.

Reviewed by: hselasky


300590 24-May-2016 hselasky

Set "current" for all PCI enumeration callbacks.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


300575 24-May-2016 hselasky

Use make_dev_s() instead of make_dev() to avoid race setting
"si_drv1". Convert panic() into regular error while at it.

Suggested by: jhb @
MFC after: 1 week
Sponsored by: Mellanox Technologies


300507 23-May-2016 hselasky

A missing definition needed by ktime_to_ms().

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


300506 23-May-2016 hselasky

Fix some data types and add "inline" keyword for __reg_op() function.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


300503 23-May-2016 hselasky

Implement ror32() in the LinuxKPI.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


300500 23-May-2016 hselasky

Add more printf() related functions to the LinuxKPI.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


300498 23-May-2016 hselasky

Add more ktime related functions to the LinuxKPI.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


300497 23-May-2016 hselasky

Implement "kref_put_mutex()" for the LinuxKPI.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


300496 23-May-2016 hselasky

Add more list_xxx() functions to the LinuxKPI.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


300495 23-May-2016 hselasky

Make header file standalone by including definitions for needed
linux_wait_xxx() functions.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


300494 23-May-2016 hselasky

Implement "_outb()" to the LinuxKPI for i386 and amd64 only.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


300493 23-May-2016 hselasky

Add support for "cdev_add_ext()" to the LinuxKPI.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


300492 23-May-2016 hselasky

Add more GFP related defines to the LinuxKPI.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


300490 23-May-2016 hselasky

Add support for atomic_long_inc_not_zero() to the LinuxKPI.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


299960 16-May-2016 hselasky

Only lock Giant when needed in the LinuxKPI.

Suggested by: ngie @
MFC after: 1 week
Sponsored by: Mellanox Technologies


299933 16-May-2016 hselasky

Implement more Linux device related functions in the LinuxKPI. While
at it use NULL for some pointer checks.

Bump the FreeBSD version to force recompilation of all kernel modules
due to a structure size change.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


299931 16-May-2016 hselasky

Don't dereference parent pointer when it is NULL.

MFC after: 1 week
Sponsored by: Mellanox Technologies


299930 16-May-2016 hselasky

Properly implement "cpu_has_clflush" macro.

Suggested by: kib, jhb
MFC after: 1 week
Sponsored by: Mellanox Technologies


299674 13-May-2016 hselasky

Handle case of class being set, but not parent when calling
device_register() in the LinuxKPI.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


299673 13-May-2016 hselasky

Add more PAGE related defines to the LinuxKPI. Move the definition of
"pgprot_t" to "linux/page.h" similar to what Linux does.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


299665 13-May-2016 hselasky

Implement "old_encode_dev()" for the LinuxKPI.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


299664 13-May-2016 hselasky

Define _IOC_SIZE() in the LinuxKPI.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


299663 13-May-2016 hselasky

Add unlikely() statement to optimise the IS_ERR_VALUE() macro.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


299656 13-May-2016 hselasky

Implement nsecs_to_jiffies() in the LinuxKPI and while at it
streamline the rest of the xxx_to_jiffies() functions to have a
constant 64-bit argument and use identical range checks for the
result.

Specifically preserve msecs_to_jiffies(0) returning 0. See r282743 for
further details.

MFC after: 1 week
Sponsored by: Mellanox Technologies


299653 13-May-2016 hselasky

Add more Linux defines. Improve some existing ones.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


299641 13-May-2016 hselasky

The Linux error defines should all be positive, else frequently used
error code checks might fail. ERESTART is in the BSD world defined as
-1. While at it add more Linux error codes.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


299530 12-May-2016 hselasky

Fix handling of IOCTLs in the LinuxKPI.

Linux requires that all IOCTL data resides in userspace. FreeBSD
always moves the main IOCTL structure into a kernel buffer before
invoking the IOCTL handler and then copies it back into userspace,
before returning. Hide this difference in the "linux_copyin()" and
"linux_copyout()" functions by remapping userspace addresses in the
range from 0x10000 to 0x20000, to the kernel IOCTL data buffer.

It is assumed that the userspace code, data and stack segments starts
no lower than memory address 0x400000, which is also stated by "man 1
ld", which means any valid userspace pointer can be passed to regular
LinuxKPI handled IOCTLs.

Bump the FreeBSD version to force recompilation of all kernel modules.

Discussed with: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


299527 12-May-2016 hselasky

Remove redundant "task_struct_set()".
This is done by the "linux_kthread_fn()".

MFC after: 1 week
Sponsored by: Mellanox Technologies


299526 12-May-2016 hselasky

Create a dummy "task_struct" on the stack which is returned by
"current" inside all LinuxKPI file operation callbacks. The "current"
is frequently used for various debug prints, printing the thread name
and thread ID for example.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


299427 11-May-2016 hselasky

Add more IDR and IDA related functions to the LinuxKPI.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


299379 10-May-2016 hselasky

Implement ioremap_wt() and use that in the MEMREMAP_WT case for i386
and amd64.

Suggested by: cem @
Discussed with: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


299364 10-May-2016 hselasky

Add more LinuxKPI I/O functions.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


298829 30-Apr-2016 pfg

sys/compat/linux*: spelling fixes.

Mostly on comments but there are some user-visible messages as well.

MFC after: 2 weeks


297483 01-Apr-2016 sephe

tcp/lro: Change SLIST to LIST, so that removing an entry is O(1)

This is kinda critical to the performance when the CPU is slow and
network bandwidth is high, e.g. in the hypervisor.

Reviewed by: rrs, gallatin, Dexuan Cui <decui microsoft com>
Sponsored by: Microsoft OSTC
Differential Revision: https://reviews.freebsd.org/D5765


297459 31-Mar-2016 np

Add wait_event_interruptible_timeout to linuxkpi.

Submitted by: Krishnamraju Eraparaju @ Chelsio
Reviewed by: hselasky@
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D5776


297444 31-Mar-2016 hselasky

Fix bugs in currently unused bit searching loop.

MFC after: 3 days
Sponsored by: Mellanox Technologies


296344 03-Mar-2016 hselasky

Add more functions to the LinuxKPI.

Define strnicmp as a function macro instead of a regular macro while
at it.

MFC after: 1 week
Sponsored by: Mellanox Technologies


295880 22-Feb-2016 skra

As <machine/pmap.h> is included from <vm/pmap.h>, there is no need to
include it explicitly when <vm/pmap.h> is already included.

Reviewed by: alc, kib
Differential Revision: https://reviews.freebsd.org/D5373


294839 26-Jan-2016 hselasky

Update and add various macros to the LinuxKPI and resolve a macro
redefinition issue in the cxgb driver.

MFC after: 1 week
Sponsored by: Mellanox Technologies
Reviewed by: np @


294837 26-Jan-2016 hselasky

LinuxKPI list updates:
- Add some new hlist macros.
- Update existing hlist macros removing the need for a temporary
iteration variable.
- Properly define the RCU hlist macros to be SMP safe with regard
to RCU.
- Safe list macro arguments by adding a pair of parentheses.
- Prefix the _list_add() and _list_splice() functions with "linux"
to reflect they are LinuxKPI internal functions.

Obtained from: Linux
MFC after: 1 week
Sponsored by: Mellanox Technologies


294832 26-Jan-2016 hselasky

Implement ether_addr_equal(), ether_addr_equal_64bits() and
random_ether_addr() for the LinuxKPI.

MFC after: 1 week
Sponsored by: Mellanox Technologies


294830 26-Jan-2016 hselasky

Implement is_vlan_dev() and vlan_dev_vlan_id() for the LinuxKPI.

MFC after: 1 week
Sponsored by: Mellanox Technologies


294829 26-Jan-2016 hselasky

Implement bitmap_weight() and bitmap_equal() for the LinuxKPI.

MFC after: 1 week
Sponsored by: Mellanox Technologies


294827 26-Jan-2016 hselasky

Add more network related macros and functions to the LinuxKPI.

MFC after: 1 week
Sponsored by: Mellanox Technologies


294826 26-Jan-2016 hselasky

Add definition for the NETDEV_CHANGE event and tidy up the LinuxKPI
notifier header file a bit while at it.

MFC after: 1 week
Sponsored by: Mellanox Technologies


294825 26-Jan-2016 hselasky

Define __get_user() and __put_user() for the LinuxKPI.

MFC after: 1 week
Sponsored by: Mellanox Technologies


294824 26-Jan-2016 hselasky

Add more LinuxKPI PCI related functions and defines.
Removed comments deriving from Linux.

MFC after: 1 week
Sponsored by: Mellanox Technologies


294518 21-Jan-2016 hselasky

Use function macro instead of non-function macro to reduce chance of
incorrect expansion.

MFC after: 1 week
Sponsored by: Mellanox Technologies


294505 21-Jan-2016 hselasky

Implement idr_preload(), idr_preload_end(), idr_alloc() and
idr_alloc_cyclic() in the LinuxKPI. Bump the FreeBSD version to
force recompilation of all KLDs due to IDR structure size change.

MFC after: 2 weeks
Sponsored by: Mellanox Technologies


294086 15-Jan-2016 hselasky

Implement support for PCI suspend, resume and shutdown events in the
LinuxKPI. Fix a few spaces to tabs. Bump the FreeBSD version to force
recompilation of existing KMODs.

MFC after: 1 week
Sponsored by: Mellanox Technologies


293419 08-Jan-2016 hselasky

LinuxKPI style changes:
- Properly prefix internal functions with "linux_" instead of only a
single underscore to avoid future namespace collisions.
- Make some functions global instead of inline to ease debugging and
to avoid unnecessary code duplication.
- Remove no longer existing kthread_create() function's prototype.

MFC after: 1 week
Sponsored by: Mellanox Technologies


293194 05-Jan-2016 hselasky

Implement RCU mechanism using shared exclusive locks.

MFC after: 1 week
Sponsored by: Mellanox Technologies


292989 31-Dec-2015 hselasky

Handle when filedescriptors are closed before initialized. An early
fdclose() call can cause fget_unlocked() to fail.

Found by: mjg @
MFC after: 1 week
Reviewed by: Mark Block <markb@mellanox.com>
Sponsored by: Mellanox Technologies
Differential Revision: https://reviews.freebsd.org/D4351


292987 31-Dec-2015 hselasky

Minor LinuxKPI code cleanup:
- Declare some static functions in linux_compat.c instead if inside
various header files.
- Prefix FreeBSD local functions in the LinuxKPI with "linux_" to
avoid symbol name conflicts in the future and to make debugging
easier.
- Make the "struct kobj_ktype" declaractions constant to shave off a
few bytes from the data segment.

MFC after: 1 week
Sponsored by: Mellanox Technologies


292986 31-Dec-2015 hselasky

Make the kobject refcounting compliant with Linux. Refcounting on the
parent kobject cannot be factored out and must be done by the kobject
consumers.

MFC after: 1 week
Sponsored by: Mellanox Technologies


292834 28-Dec-2015 hselasky

Reduce memory consumption when allocating kobject strings in the
LinuxKPI. Compute string length before allocating memory instead of
using fixed size allocations. Make kobject_set_name_vargs() global
instead of inline to save some bytes when compiling.

MFC after: 1 week
Sponsored by: Mellanox Technologies


292544 21-Dec-2015 hselasky

Implement drain_workqueue() function.

MFC after: 1 week
Sponsored by: Mellanox Technologies


292543 21-Dec-2015 hselasky

In the zero delay case in queue_delayed_work() use the return value
from taskqueue_enqueue() instead of reading "ta_pending" unlocked and
also ensure the callout is stopped before proceeding.

MFC after: 1 week
Sponsored by: Mellanox Technologies


292542 21-Dec-2015 hselasky

Minor workqueue cleanup:
- Make some functions global instead of inline to ease debugging.
- Fix some minor style issues.

MFC after: 1 week
Sponsored by: Mellanox Technologies


292538 21-Dec-2015 hselasky

Implement sleepable RCU mechanism using shared exclusive locks.

MFC after: 1 week
Sponsored by: Mellanox Technologies


292537 21-Dec-2015 hselasky

Implement ACCESS_ONCE(), WRITE_ONCE() and READ_ONCE().

MFC after: 1 week
Sponsored by: Mellanox Technologies


291693 03-Dec-2015 hselasky

Add some structures and defines which will be used when decoding small
form factor, SFF, standards compliant ethernet EEPROMs.

MFC after: 1 week
Obtained from: Linux
Sponsored by: Mellanox Technologies


291690 03-Dec-2015 hselasky

Remove incorrect defines. The proper version of these macros is
defined in linux/etherdevice.h.

MFC after: 1 week
Sponsored by: Mellanox Technologies


291481 30-Nov-2015 hselasky

Add more functions and types to the LinuxKPI.

MFC after: 1 week
Sponsored by: Mellanox Technologies


290706 12-Nov-2015 hselasky

Build fixes:
- Add some missing I/O functions for non-i386 and amd64 platforms.
- Stub ioremap() to NULL using a macro to ensure non-existing memory
attributes are not referred when they do not exist.
- Add more header files to linux/list.h to resolve driver compilation
issues on Sparc64 and PowerPC platforms.

Sponsored by: Mellanox Technologies


290613 09-Nov-2015 cem

linuxkpi/sysfs.h: Cast arg2 through intptr_t to avoid GCC warning

The code compiles fine under Clang, but GCC on PPC is less permissive about
integer and pointer sizes. (An intmax_t is clearly *large enough* to hold a
pointer value.)

Another follow-up to r290475.

Reported by: jhibbits
Sponsored by: EMC / Isilon Storage Division


290335 03-Nov-2015 hselasky

Make all the LinuxKPI include files compile standalone.

Sponsored by: Mellanox Technologies


290135 29-Oct-2015 hselasky

Finish process of moving the LinuxKPI module into the default kernel build.

- Move all files related to the LinuxKPI into sys/compat/linuxkpi and
its subfolders.
- Update sys/conf/files and some Makefiles to use new file locations.
- Added description of COMPAT_LINUXKPI to sys/conf/NOTES which in turn
adds the LinuxKPI to all LINT builds.
- The LinuxKPI can be added to the kernel by setting the
COMPAT_LINUXKPI option. The OFED kernel option no longer builds the
LinuxKPI into the kernel. This was done to keep the build rules for
the LinuxKPI in sys/conf/files simple.
- Extend the LinuxKPI module to include support for USB by moving the
Linux USB compat from usb.ko to linuxkpi.ko.
- Bump the FreeBSD_version.
- A universe kernel build has been done.

Reviewed by: np @ (cxgb and cxgbe related changes only)
Sponsored by: Mellanox Technologies


289700 21-Oct-2015 hselasky

Start process of moving the LinuxKPI into the default kernel build by
creating an empty directory tree.

Sponsored by: Mellanox Technologies