Commit Graph

2209 Commits

Author SHA1 Message Date
Cy Schubert
4a7b49a0da ipfilter: Save time and cycles swapping bucket table sizes
NAT hash tables are inverted for inbound vs outbound. Rather than spend
the time and cycles swapping them, let's simply calculate the bucket
lengths inversely.

MFC after:	1 week
2021-09-29 17:44:02 -07:00
Cy Schubert
aa6cfcc820 ipfilter: Correct a comment
Correct a comment's grammar and while at it clarify its meaining.

MFC after:	3 days
2021-09-27 11:13:50 -07:00
Cy Schubert
df38343e71 ipfilter: Print the correct TCP sequence index number
TCP sequence numbers in the FTP proxy are maintained in a two dimensional
array. The debug message prints the same seq[N] for both. Fix that.

MFC after:	3 days
2021-09-27 11:13:50 -07:00
Cy Schubert
1605eaa6d2 ipfilter: Locking sysctls here is not required
Locking of data structures touched by sysctls is more finely locked
in ipflter therefore higher level locks are redundant.

MFC after:	3 days
2021-09-24 11:41:02 -07:00
Cy Schubert
73db3b64f1 ipfilter: Avoid a null if-then-else blocks
When WITHOUT_INET6 is selected we generate a null if-then-else blocks
due to incorrect placment of #if statments. Move the #if statements
reducing unnecessary runtime comparisons WITHOUT_INET6.

MFC after:	1 week
2021-09-24 11:41:02 -07:00
Konstantin Belousov
cf0ee8738e Drop cloudabi
According to https://github.com/NuxiNL/cloudlibc:
CloudABI is no longer being maintained. It was an awesome experiment,
but it never got enough traction to be sustainable.

There is no reason to keep it in FreeBSD.

Approved by:	ed (private mail)
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D31923
2021-09-22 00:18:44 +03:00
Martin Matuska
53b70c86d9 zfs: merge openzfs/zfs@4a1195ca5 (master) into main
Notable upstream pull request merges:
  #11312 Temporarily use root credentials to mount snapshots in .zfs
  #12246 arc: Drop an incorrect assert
  #12443 Fixed data integrity issue when underlying disk returns error
         to zfs
  #12522 Compressed receive with different ashift can result in incorrect
         PSIZE on disk
  #12535 Verify embedded blkptr's in arc_read()
  #12541 Allow sending corrupt snapshots even if metadata is corrupted

Obtained from:	OpenZFS
OpenZFS commit:	4a1195ca50
2021-09-15 17:30:53 +02:00
Stefan Grundmann
e673ac3ffb libnv: Fix array unpack endianness logic
When a nvlist(9) is converted into a binary buffer by nvlist_pack(9),
the host endianness is encoded in the nvlist_header of the binary
buffer. The nvlist_unpack(9) function converts a given binary buffer
to an nvlist. In the conversion process the endianness encoded in the
nvlist_header is evaluated and -- should the encoded endianness differ
from the endianess of the decoding host -- endianness conversion is
applied to nvlist_header and nvpair_header elements as well as
to some nvpair values.

In 2015 @oshogbo extended libnv with array support (in 347a39b).
The unpacking code misses the possible need to convert the endianness
of the nvph_nitems element of nvpair_headers.

The patch (re)enables libnv to unpack nvlists regardless of the
endianness of the packing host.

Pull Request:	https://github.com/freebsd/freebsd-src/pull/528
2021-09-13 21:21:14 +02:00
Martin Matuska
21b492ed51 zfs: merge openzfs/zfs@3b89d9518 (master) into main
Notable upstream pull request merges:
  #12022 Fix endianness issues with zstd
  #12319 Extend zpool-iostat to account for ZIO_PRIORITY_REBUILD
  #12458 Add hole punching support on FreeBSD version 1400032
  #12473 Initialize parity blocks before RAID-Z reconstruction benchmarking
  #12511 Make 'zpool labelclear -f' work on offlined disks
  #12514 FreeBSD: Don't remove SA xattr if not SA znode

Obtained from:	OpenZFS
OpenZFS commit:	3b89d9518d
2021-08-31 09:02:21 +02:00
Dimitry Andric
130a690ae1 Fix acpica macros that subtract null pointers
Clang 13.0.0 produces a new -Werror warning about the ACPI_TO_INTEGER(p)
and ACPI_OFFSET(d, f) macros in acpica's actypes.h:

    sys/contrib/dev/acpica/components/dispatcher/dsopcode.c:708:31: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
        ObjDesc->Region.Address = ACPI_PTR_TO_PHYSADDR (Table);
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    sys/contrib/dev/acpica/include/actypes.h:664:41: note: expanded from macro 'ACPI_PTR_TO_PHYSADDR'
    #define ACPI_PTR_TO_PHYSADDR(i)         ACPI_TO_INTEGER(i)
                                            ^~~~~~~~~~~~~~~~~~
    sys/contrib/dev/acpica/include/actypes.h:661:41: note: expanded from macro 'ACPI_TO_INTEGER'
    #define ACPI_TO_INTEGER(p)              ACPI_PTR_DIFF (p, (void *) 0)
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    sys/contrib/dev/acpica/include/actypes.h:656:82: note: expanded from macro 'ACPI_PTR_DIFF'
    #define ACPI_PTR_DIFF(a, b)             ((ACPI_SIZE) (ACPI_CAST_PTR (UINT8, (a)) - ACPI_CAST_PTR (UINT8, (b))))
                                                                                     ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.

This problem of undefined behavior was also reported to acpica by @cem
in 2018: https://github.com/acpica/acpica/issues/407, but it seems there
was never any fix committed for it upstream.

Instead fix these locally, for ACPI_TO_INTEGER by simply casting the
incoming pointer to ACPI_SIZE (which corresponds roughly to uintptr_t
and size_t), and for ACPI_OFFSET by reusing our __offsetof definition
from sys/cdefs.h.

Reviewed by:	emaste, kib, imp
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D31710
2021-08-30 21:34:34 +02:00
Ed Maste
0637070b5b ngatm: remove one of doubled semicolons
Discussed with:	harti
2021-08-30 11:39:30 -04:00
Zhenlei Huang
62e1a437f3 routing: Allow using IPv6 next-hops for IPv4 routes (RFC 5549).
Implement kernel support for RFC 5549/8950.

* Relax control plane restrictions and allow specifying IPv6 gateways
 for IPv4 routes. This behavior is controlled by the
 net.route.rib_route_ipv6_nexthop sysctl (on by default).

* Always pass final destination in ro->ro_dst in ip_forward().

* Use ro->ro_dst to exract packet family inside if_output() routines.
 Consistently use RO_GET_FAMILY() macro to handle ro=NULL case.

* Pass extracted family to nd6_resolve() to get the LLE with proper encap.
 It leverages recent lltable changes committed in c541bd368f.

Presence of the functionality can be checked using ipv4_rfc5549_support feature(3).
Example usage:
  route add -net 192.0.0.0/24 -inet6 fe80::5054:ff:fe14:e319%vtnet0

Differential Revision: https://reviews.freebsd.org/D30398
MFC after:	2 weeks
2021-08-22 22:56:08 +00:00
Alexander V. Chernikov
36e15b717e routing: Fix crashes with dpdk_lpm[46] algo.
When a prefix gets deleted from the RIB, dpdk_lpm algo needs to know
 the nexthop of the "parent" prefix to update its internal state.
The glue code, which utilises RIB as a backing route store, uses
 fib[46]_lookup_rt() for the prefix destination after its deletion
 to fetch the desired nexthop.
This approach does not work when deleting less-specific prefixes
 with most-specific ones are still present. For example, if
 10.0.0.0/24, 10.0.0.0/23 and 10.0.0.0/22 exist in RIB, deleting
 10.0.0.0/23 would result in 10.0.0.0/24 being returned as a search
 result instead of 10.0.0.0/22. This, in turn, results in the failed
 datastructure update: part of the deleted /23 prefix will still
 contain the reference to an old nexthop. This leads to the
 use-after-free behaviour, ending with the eventual crashes.

Fix the logic flaw by properly fetching the prefix "parent" via
 newly-created rt_get_inet[6]_parent() helpers.

Differential Revision: https://reviews.freebsd.org/D31546
PR:	256882,256833
MFC after:	1 week
2021-08-17 20:46:22 +00:00
Martin Matuska
2faf504d1a zfs: merge openzfs/zfs@8ae86e2ed (master) into main
Notable upstream pull request merges:
  #12422 Fix/improve dbuf hits accounting
  #12406 Increase default volblocksize from 8KB to 16KB
  #12398 Remove b_pabd/b_rabd allocation from arc_hdr_alloc()
  #12397 Run arc_evict thread at higher priority
  #12297 Avoid vq_lock drop in vdev_queue_aggregate()
  #12161 Restore FreeBSD sysctl processing for arc.min and arc.max

Obtained from:	OpenZFS
OpenZFS commit:	8ae86e2edc
2021-08-17 21:10:44 +02:00
Ed Maste
8fa63f44e6 ipfilter: remove doubled semicolons
Local commit; ipfilter upstream is inactive.

Discussed with:	cy
MFC after:	3 days
2021-08-16 13:16:42 -04:00
Mark Johnston
d75884df78 ck: Correct asm output operand widths in amd64 pointer intrinsics
This does not appear to change generated code with the default
toolchain.  However, KMSAN makes use of output operand specifications to
instrument inline asm, and with incorrect specifications we get false
positives in code that uses the CK_(S)LIST macros.

This was submitted upstream:
https://github.com/concurrencykit/ck/pull/175

The commit applies the same change locally to make KMSAN usable until
something equivalent is merged upstream.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-08-10 21:27:54 -04:00
Ed Maste
9feff969a0 Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights
These ones were unambiguous cases where the Foundation was the only
listed copyright holder (in the associated license block).

Sponsored by:	The FreeBSD Foundation
2021-08-08 10:42:24 -04:00
Martin Matuska
1f88aa0941 zfs: merge openzfs/zfs@f3678d70f (master) into main
Notable upstream pull request merges:
  #12339 Read past end of argv array in zpool_do_import()
  #12365 Fixes in persistent L2ARC
  #12383 Fixes for KMSAN reports
  #12425 Avoid small buffer copying on write
  #12428 Fix unfortunate NULL in spa_update_dspace
  #12446 Allow disabling of unmapped I/O on FreeBSD

Obtained from:	OpenZFS
OpenZFS commit:	f3678d70ff
2021-08-08 04:01:26 +02:00
Jung-uk Kim
97c0b5ab18 acpica: Import ACPICA 20210730
(cherry picked from commit 34cfdff1f386b2d7bf0a8ea873acf604753991e6)
2021-07-31 00:16:27 -04:00
John Baldwin
8843787aa1 ena: Remove redundant declaration of ena_log_level.
GCC6 raises a -Wredundant-decl error due to duplicate declarations
in ena_fbsd_log.h and ena_plat.h.

Sponsored by:	Chelsio Communications
2021-07-23 16:07:35 -07:00
Martin Matuska
3f9d360c82 zfs: merge openzfs/zfs@14b43fbd9 (master) into main
Notable upstream pull request merges:
  #12271 Tinker with slop space accounting with dedup
  #12279 Fix ARC ghost states eviction accounting
  #12284 Add Module Parameter Regarding Log Size Limit
  #12300 Introduce dsl_dir_diduse_transfer_space()
  #12314 Optimize allocation throttling
  #12348 Minor ARC optimizations
  #12350 Detect HAVE_LARGE_STACKS at compile time
  #12356 Use SET_ERROR for more errors in FreeBSD vnops
  #12375 FreeBSD: Ignore make_dev_s() errors
  #12378 FreeBSD: Switch from MAXPHYS to maxphys on FreeBSD 13+

Obtained from:	OpenZFS
OpenZFS commit:	14b43fbd9c
2021-07-23 02:50:13 +02:00
Ed Maste
79e6eb5c01 zfs: Remove zfs-images submodule
This can cause issues like 'No url found for submodule path' in
downstream or derived projects making use of submodules.

Reviewed by:	imp
2021-07-19 16:40:09 -04:00
Konstantin Belousov
dbaad75f28 zfs: add missed dependency of zfs module on zlib
Reviewed by:	mm
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D31207
2021-07-18 01:44:22 +03:00
Martin Matuska
5eb61f6c65 zfs: merge openzfs/zfs@07a4c76e9 (master) into main
Notable upstream pull request merges:
  #12299 file reference counts can get corrupted
  #12320 FreeBSD: Use unmapped I/O for scattered/gang ABD buffers

Obtained from:	OpenZFS
OpenZFS commit:	07a4c76e90
2021-07-12 23:24:45 +02:00
Hans Petter Selasky
c3987b8ea7 ibcore: Declare ib_post_send() and ib_post_recv() arguments const
Since neither ib_post_send() nor ib_post_recv() modify the data structure
their second argument points at, declare that argument const. This change
makes it necessary to declare the 'bad_wr' argument const too and also to
modify all ULPs that call ib_post_send(), ib_post_recv() or
ib_post_srq_recv(). This patch does not change any functionality but makes
it possible for the compiler to verify whether the
ib_post_(send|recv|srq_recv) really do not modify the posted work request.

Linux commit:
f696bf6d64b195b83ca1bdb7cd33c999c9dcf514
7bb1fafc2f163ad03a2007295bb2f57cfdbfb630
d34ac5cd3a73aacd11009c4fc3ba15d7ea62c411

MFC after:	1 week
Reviewed by:	kib
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2021-07-12 14:22:33 +02:00
Martin Matuska
7cd22ac434 zfs: merge openzfs/zfs@bdd11cbb9 (master) into main
Notable upstream pull request merges:
  #12274 Optimize txg_kick() process
  #12281 Move gethrtime() calls out of vdev queue lock
  #12287 Remove refcount from spa_config_*(
  #12289 Compact dbuf/buf hashes and lock arrays
  #12290 Remove avl_size field from struct avl_tree
  #12294 Upstream: dmu_zfetch_stream_fini leaks refcount
  #12295 Fix abd leak, kmem_free correct size of abd_t
  #12328 FreeBSD: Hardcode abd_chunk_size to PAGE_SIZE

Obtained from:	OpenZFS
OpenZFS commit:	bdd11cbb90
2021-07-07 23:31:52 +02:00
Kornel Duleba
ddb928096b dts: fsl-ls1028a: Correct ECAM PCIE window ranges
Currently all PCIE windows point to bus address 0x0, which does not match
the values obtained from hardware during EA.
Replace those values with CPU addresses, since in reality we
have a 1:1 mapping between the two.

This patch is queued for Linux v5.14 in linux-next tree:
6bee93d93111 "arm64: dts: fsl-ls1028a: Correct ECAM PCIE window ranges"
2021-07-01 20:23:40 +02:00
Emmanuel Vadot
2eb4d8dc72 Import device-tree files from Linux 5.13
Sponsored by:	Diablotin Systems
2021-07-01 17:51:01 +02:00
Emmanuel Vadot
82ea1a07b4 Import device-tree files from Linux 5.12
Sponsored by:	Diablotin Systems
2021-07-01 17:41:57 +02:00
Emmanuel Vadot
5def4c47d4 Import device-tree files from Linux 5.11
Sponsored by:	Diablotin Systems
2021-07-01 17:21:47 +02:00
Martin Matuska
2617128a21 zfs: merge openzfs/zfs@4694131a0 (master) into main
Notable upstream pull request merges:
  #12253 module/zfs: simplify ddt_stat_add() loop
  #12288 Avoid 64bit division in multilist index functions

Obtained from:	OpenZFS
OpenZFS commit:	4694131a0a
2021-06-30 08:02:44 +02:00
Martin Matuska
33b8c039a9 zfs: merge openzfs/zfs@5e2c8338b (master) into main
Notable upstream pull request merges:
  #12183 Optimize small random numbers generation
  #12227 Revert Consolidate arc_buf allocation checks
  #12266 Fix flag copying in resume case
  #12273 zfs_metaslab_mem_limit should be 25 instead of 75
  #12276 Update cache file when setting compatibility property
  #12280 Help compiller optimize out abd_verify()
  #12282 FreeBSD: fix compilation of FreeBSD world after 29274c9f6

Obtained from:	OpenZFS
OpenZFS commit:	5e2c8338bf
2021-06-26 02:21:11 +02:00
Eric Joyner
070f7812da
ice_ddp: Revert mode back to 0644
The last commit (538ef055b7) accidentally
set the executable bits for this file. This is not intended to be
executed at all. (Would that even work?)

Sponsored by:	Intel Corporation
2021-06-25 10:28:28 -07:00
Eric Joyner
538ef055b7
ice_ddp: Update to 1.3.24.0
This version is intended to be used with the 0.29.4 version of the
ice(4) driver, which will be be committed afterwards.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>

Reviewed by:	stallamr_netapp.com
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D30887
2021-06-25 10:21:39 -07:00
Marcin Wojtas
3fc5d816f8 Merge tag 'vendor/ena-com/2.4.0'
Update the driver in order not to break its compilation
and make use of the new ENA logging system

Migrate platform code to the new logging system provided by ena_com
layer.

Make ENA_INFO the new default log level.

Remove all explicit use of `device_printf`, all new logs requiring one
of the log macros to be used.
2021-06-24 16:15:18 +02:00
Martin Matuska
0d8fe23735 zfs: merge openzfs/zfs@c4c162c1e (master) into main
Notable upstream pull request merges:
  #12054 Avoid deadlock when removing L2ARC devices under I/O
  #12172 Use wmsum for arc, abd, dbuf and zfetch statistics
  #12221 vdev_draid_min_asize() ignores reserved space

Obtained from:	OpenZFS
OpenZFS commit:	c4c162c1e8
2021-06-20 09:18:44 +02:00
Martin Matuska
3ff01b231d zfs: merge openzfs/zfs@afa7b3484 (master) into main
Notable upstream pull request merges:
  #12149: Multiple man-pages: Move to appropriate section
  #12158: Re-embed multilist_t storage
  #12191: Convert non-libzpool libraries to -fvisibility=hidden
  #12196: Unify manpage makefiles, move pages to better sexions, ...
  #12210: libzutil: import filtering optimisation
  #12212: Remove pool io kstats

Obtained from:	OpenZFS
OpenZFS commit:	afa7b34845
2021-06-13 04:38:47 +02:00
Mariusz Zaborski
89d5cbb822 libnv: optimize nvlist size calculation
If we had a multiple nvlist, during nvlist_pack, we calculated the size
of every nvlist separately. For example, if we had a nvlist with three
nodes each containing another (A contains B, and B contains C), we first
calculated the size of nvlist A (which contains B, C), then we calculate
the size of B (which contains C, notice that we already did the
calculation of B, when we calculate A), and finally C. This means that
this calculation was O(N!). This was done because each time we pack
nvlist, we have to put its size in the header
(the separate header for A, B, and C).

To not break the ABI and to reduce the complexity of nvlist_size,
instead of calculating the nvlist size when requested,
we track the size of each nvlist.

Reported by:	pjd, kp
Tested by:	kp
2021-06-11 17:51:29 +02:00
Martin Matuska
1603881667 zfs: merge openzfs/zfs@75b4cbf62 (master) into main
Notable upstream pull request merges:
  #11710 Allow zfs to send replication streams with missing snapshots
  #11751 Avoid taking global lock to destroy zfsdev state
  #11786 Ratelimit deadman zevents as with delay zevents
  #11803 ZFS traverse_visitbp optimization to limit prefetch
  #11813 Allow pool names that look like Solaris disk names
  #11822 Atomically check and set dropped zevent count
  #11822 Don't scale zfs_zevent_len_max by CPU count
  #11833 Refactor zfsdev state init/destroy to share common code
  #11837 zfs get -p only outputs 3 columns if "clones" property is empty
  #11843 libzutil: zfs_isnumber(): return false if input empty
  #11849 Use dsl_scan_setup_check() to setup a scrub
  #11861 Improvements to the 'compatibility' property
  #11862 cmd/zfs receive: allow dry-run (-n) to check property args
  #11864 receive: don't fail inheriting (-x) properties on wrong dataset type
  #11877 Combine zio caches if possible
  #11881 FreeBSD: use vnlru_free_vfsops if available
  #11883 FreeBSD: add support for lockless symlink lookup
  #11884 FreeBSD: add missing seqc write begin/end around zfs_acl_chown_setattr
  #11896 Fix crash in zio_done error reporting
  #11905 zfs-send(8): Restore sorting of flags
  #11926 FreeBSD: damage control racing .. lookups in face of mkdir/rmdir
  #11930 vdev_mirror: don't scrub/resilver devices that can't be read
  #11938 Fix AVX512BW Fletcher code on AVX512-but-not-BW machines
  #11955 zfs get: don't lookup mount options when using "-s local"
  #11956 libzfs: add keylocation=https://, backed by fetch(3) or libcurl
  #11959 vdev_id: variable not getting expanded under map_slot()
  #11966 Scale worker threads and taskqs with number of CPUs
  #11994 Clean up use of zfs_log_create in zfs_dir
  #11997 FreeBSD: Don't force xattr mount option
  #11997 FreeBSD: Implement xattr=sa
  #11997 FreeBSD: Use SET_ERROR to trace xattr name errors
  #11998 Simplify/fix dnode_move() for dn_zfetch
  #12003 FreeBSD: Initialize/destroy zp->z_lock
  #12010 Fix dRAID self-healing short columns
  #12033 Revert "Fix raw sends on encrypted datasets when copying back snapshots"
  #12040 Reinstate the old zpool read label logic as a fallback
  #12046 Improve scrub maxinflight_bytes math
  #12049 FreeBSD: avoid memory allocation in arc_prune_async
  #12052 FreeBSD: incorporate changes to the VFS_QUOTACTL(9) KPI
  #12061 Fix dRAID sequential resilver silent damage handling
  #12072 Let zfs diff be more permissive
  #12077 FreeBSD: Retry OCF ENOMEM errors.
  #12088 Propagate vdev state due to invalid label corruption
  #12091 libzfs: On FreeBSD, use MNT_NOWAIT with getfsstat
  #12097 FreeBSD: Update dataset_kstats for zvols in dev mode
  #12104 FreeBSD boot code reminder after zpool upgrade
  #12114 Introduce write-mostly sums

Obtained from:	OpenZFS
OpenZFS commit:	75b4cbf625
2021-06-08 16:52:44 +02:00
Martin Matuska
ed9215c8e0 zfs: merge openzfs/zfs@3522f57b6 (master) to main
This changes branch tracking of sys/contrib/openzfs to a new
direct-import branch vendor/openzfs/master.

No functional changes.

OpenZFS tag:	2.1.0-rc1
2021-06-08 16:25:14 +02:00
Mark Johnston
e755e2776d ngatm: Handle errors from uni_msg_extend()
uni_msg_extend() may fail due to a memory allocation failure.  In this
case, though, the message is freed, so callers shouldn't touch it.

PR:		255861
Reviewed by:	harti
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D30611
2021-06-06 16:44:47 -04:00
Jung-uk Kim
1970d69303 Import ACPICA 20210604
(cherry picked from commit 395770967c3664ec744e63fa47acc19670d32f47)
2021-06-05 01:58:00 -04:00
Jason A. Harmening
a4b07a2701 VFS_QUOTACTL(9): allow implementation to indicate busy state changes
Instead of requiring all implementations of vfs_quotactl to unbusy
the mount for Q_QUOTAON and Q_QUOTAOFF, add an "mp_busy" in/out param
to VFS_QUOTACTL(9).  The implementation may then indicate to the caller
whether it needed to unbusy the mount.

Also, add stbool.h to libprocstat modules which #define _KERNEL
before including sys/mount.h.  Otherwise they'll pull in sys/types.h
before defining _KERNEL and therefore won't have the bool definition
they need for mp_busy.

Reviewed By:	kib, markj
Differential Revision: https://reviews.freebsd.org/D30556
2021-05-30 14:53:47 -07:00
Jason A. Harmening
271fcf1c28 Revert commits 6d3e78ad6c and 54256e7954
Parts of libprocstat like to pretend they're kernel components for the
sake of including mount.h, and including sys/types.h in the _KERNEL
case doesn't fix the build for some reason.  Revert both the
VFS_QUOTACTL() change and the follow-up "fix" for now.
2021-05-29 17:48:02 -07:00
Jason A. Harmening
6d3e78ad6c VFS_QUOTACTL(9): allow implementation to indicate busy state changes
Instead of requiring all implementations of vfs_quotactl to unbusy
the mount for Q_QUOTAON and Q_QUOTAOFF, add an "mp_busy" in/out param
to VFS_QUOTACTL(9).  The implementation may then indicate to the caller
whether it needed to unbusy the mount.

Reviewed By:	kib, markj
Differential Revision: https://reviews.freebsd.org/D30218
2021-05-29 14:05:39 -07:00
Cy Schubert
323a4e2c4e ipfilter: Fix ip_nat memory leak and use-after-free
Unfortunately the wrong elemet is freed, also resulting in use-after-free.

PR:		255859
Submitted by:	lylgood@foxmail.com
Reported by:	lylgood@foxmail.com
MFC after:	3 days
2021-05-25 11:58:14 -07:00
Ceri Davies
c1a148873d sys/*/conf/*, docs: fix links to handbook
While here, fix all links to older en_US.ISO8859-1 documentation
in the src/ tree.

PR:             255026
Reported by:    Michael Büker <freebsd@michael-bueker.de>
Reviewed by:    dbaio
Approved by:    blackend (mentor), re (gjb)
MFC after:      10 days
Differential Revision: https://reviews.freebsd.org/D30265
2021-05-20 09:27:10 +01:00
Martin Matuska
9f1dc86c46 zfs: restore copyright disclaimer change from 4b84b4cca
The change will be pull-requested to upstream.

X-MFC-with:	4b84b4cca4
2021-04-26 22:16:50 +02:00
Martin Matuska
4b84b4cca4 zfs: fix non-functional mismerges from vendor/openzfs
- fix copyright in module/os/freebsd/spl/spl_acl.c
- fix mismerge in non-processed module/os/linux/zfs/zfs_uio.c

MFC after:      3 days
Obtained from:  OpenZFS
2021-04-26 03:05:13 +02:00
Mateusz Guzik
7ea3223c78 zfs: use vn_seqc_read_notmodify for racing .. lookups
Catching an in-flight unlocked vnode is fine here.

Reported by;	pho
2021-04-22 13:18:39 +00:00
Mateusz Guzik
9c651561a2 zfs: damage control racing .. lookups in face of mkdir/rmdir
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D29769
2021-04-21 15:25:32 +00:00
Adrian Chadd
bed90bf8ed [ath_hal] Add get/set NAV functions
The NAV (network allocation vector) register reflects the current MAC
tracking of NAV - when it will stay quiet before transmitting.

Other devices transmit their frame durations in their 802.11 PHY headers
and all devices that hear a frame - even if it's one in an encoding
they don't understand - will understand the low bitrate PHY header that
includes the frame duration.  So, they'll set NAV to this value so
they'll stay quiet until the transmit completes.

Anyway, sometimes the PHY NAV header is garbled and sometimes, notably
older broadcom devices, will fake a long NAV so they can get "cleaner" air
for local calibration.  When this happens, the hardware will stay quiet
for quite some time and this can lead to missed/stuck beacons, or
(for Very Large Values) a MAC hang.

This code just adds the ability to get/set the NAV; the driver will
need to take care of using it during transmit hangs and beacon misses
to see if it's due to a trash looking NAV.
2021-04-18 22:52:31 -07:00
Adrian Chadd
dead34f822 [ath_hal] ar9300: save TSF across full chip reset
This saves the TSF across a a full reset.  The TSF is otherwise cleared
and subsequent beaconing stops until the TSF catches up to nexttbtt.
2021-04-18 22:49:54 -07:00
Justin Hibbits
6525c2d4de mips/octeon SDK: Fix __cvmx_cmd_queue_lock asm for clang 11
The 'ticket' and 'my_ticket' arguments are both read and written within
the same asm block.  Clang is stricter with the constraints than gcc4
was, so accepts the '=r' at face value and will happily overwrite
registers that "should" be preserved.

Mark these operands to not clobber other operands, so they get their own
registers.

This fixes a panic on bringing up the octe interfaces.
2021-04-18 12:05:55 -05:00
Martin Matuska
6db169e920 zfs: merge openzfs/zfs@3522f57b6 (master)
Notable upstream pull request merges:
  #11742 When specifying raidz vdev name, parity count should match
  #11744 Use a helper function to clarify gang block size
  #11771 Support running FreeBSD buildworld on Arm-based macOS hosts

This is the last update that will be MFCed into stable/13.

From now on, the tracking of OpenZFS branches will be different:
- main continues tracking openzfs/zfs/master
- stable/13 is going to track openzfs/zfs/zfs-2.1-release

Obtained from:	OpenZFS
MFC after:	1 week
2021-04-14 12:51:51 +02:00
Mateusz Guzik
97ed4babb5 zfs: avoid memory allocation in arc_prune_async 2021-04-11 07:19:56 +02:00
Mateusz Guzik
feea35bed0 zfs: make vnlru_free_vfsops use conditional on version
Diff reduction against upstream.
2021-04-11 04:57:26 +00:00
Mateusz Guzik
a7fbfdee73 zfs: change format string in zio_fini to get rid of the cast 2021-04-10 20:33:43 +00:00
Kristof Provost
ab8d25880e libnv: Allow use in non-sleepable contexts
44c125c4ce switched the nvlist allocations
to be M_WAITOK, but this precludes the use in non-sleepable contexts.
(E.g. with a nonsleepable lock held).

All callers for these allocation functions already cope with memory
alloation failures, so there's no reason to allow sleeping during
allocations.

Reviewed by:	melifaro, oshogbo
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29556
2021-04-07 15:54:10 +02:00
Jung-uk Kim
429f71bf08 ACPICA: Fix build with options ACPI_DEBUG 2021-04-01 21:18:49 -04:00
Jung-uk Kim
cfd1ed4681 Merge ACPICA 20210331.
(cherry picked from commit 1e02e5b0ba8634758c128dcb43c67342c7219cd4)
2021-04-01 19:36:59 -04:00
Jessica Clarke
3a314eb5bb zfs: Cherry-pick upstream commit ef977fce66 to fix macOS/arm64 bootstrap
Upstream commit message:

  Support running FreeBSD buildworld on Arm-based macOS hosts

  Arm-based Macs are like FreeBSD and provide a full 64-bit stat from the
  start, so have no stat64 variants. Thus, define stat64 and fstat64 as
  aliases for the normal versions.

  Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
  Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com>
  Closes #11771

MFC after:	1 week
2021-03-27 02:23:59 +00:00
Cy Schubert
874b1a3548 ipfilter: simplify ipf_proxy_check() return codes
ipf_proxy_check() returns -1 for an error and 0 or 1 for success.
ipf_proxy_check()'s callers check for error and if the return code
is 0, they change it to 1 prior to returning to their callers. Simply
by returning -1 or 1 we reduce complexity and cycles burned changing
0 to 1.

MFC after:	1 week
2021-03-24 01:57:56 -07:00
Emmanuel Vadot
6be3386466 Update DTS files from Linux v5.10 2021-03-23 15:00:35 +01:00
Martin Matuska
f9693bef8d zfs: merge OpenZFS master-891568c99
Notable upstream pull request merges:
  #11652 Split dmu_zfetch() speculation and execution parts
  #11682 Fix zfs_get_data access to files with wrong generation
  #11735 Clean up RAIDZ/DRAID ereport code
  #11737 Initialize metaslab range trees in metaslab_init
  #11739 FreeBSD: make seqc asserts conditional on replay
  #11763 Allow setting bootfs property on pools with indirect vdevs
  #11767 FreeBSD: Fix memory leaks in kstats

Obtained from:	OpenZFS
MFC after:	2 weeks
2021-03-21 02:17:59 +01:00
Mateusz Guzik
e9272225e6 vfs: fix vnlru marker handling for filtered/unfiltered cases
The global list has a marker with an invariant that free vnodes are
placed somewhere past that. A caller which performs filtering (like ZFS)
can move said marker all the way to the end, across free vnodes which
don't match. Then a caller which does not perform filtering will fail to
find them. This makes vn_alloc_hard sleep for 1 second instead of
reclaiming, resulting in significant stalls.

Fix the problem by requiring an explicit marker by callers which do
filtering.

As a temporary measure extend vnlru_free to restart if it fails to
reclaim anything.

Big thanks go to the reporter for testing several iterations of the
patch.

Reported by:	Yamagi <lists yamagi.org>
Tested by:	Yamagi <lists yamagi.org>
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D29324
2021-03-18 14:59:03 +00:00
Martin Matuska
9db44a8e5d zfs: merge OpenZFS master-9305ff2ed
Notable upstream pull request merges:
  #11153 Scalable teardown lock for FreeBSD
  #11651 Don't bomb out when using keylocation=file://
  #11667 zvol: call zil_replaying() during replay
  #11683 abd_get_offset_struct() may allocate new abd
  #11693 Intentionally allow ZFS_READONLY in zfs_write
  #11716 zpool import cachefile improvements
  #11720 FreeBSD: Clean up zfsdev_close to match Linux
  #11730 FreeBSD: bring back possibility to rewind the
         checkpoint from bootloader

Obtained from:	OpenZFS
MFC after:	2 weeks
2021-03-14 02:32:14 +01:00
Mariusz Zaborski
653ed678c7 zfs: bring back possibility to rewind the checkpoint from
Add parsing of the rewind options.

When I was upstreaming the change [1], I omitted the part where we
detect that the pool should be rewind. When the FreeBSD repo has
synced with the OpenZFS, this part of the code was removed.

[1] FreeBSD repo: 277f38abff
[2] OpenZFS repo: f2c027bd6a

Originally reviewed by:		tsoome, allanjude
Originally reviewed by:		kevans (ok from high-level overview)

Signed-off-by: Mariusz Zaborski <oshogbo@vexillium.org>

PR:		254152
Reported by:	Zhenlei Huang <zlei.huang at gmail.com>
Obtained from:	https://github.com/openzfs/zfs/pull/11730
2021-03-13 12:56:17 +01:00
Mateusz Guzik
59146a6921 zfs: make seqc asserts conditional on replay
Avoids tripping on asserts when doing pool recovery.
2021-03-13 09:31:49 +00:00
Alexander V. Chernikov
d5be41beb7 Fix dpdk/ldradix fib lookup algorithm preference calculation.
The current preference number were copied from IPv4 code,
 assuming 500k routes to be the full-view. Adjust with the current
 reality (100k full-view).

Reported by:	Marek Zarychta <zarychtam at plan-b.pwste.edu.pl>
MFC after:	3 days
2021-03-07 22:17:53 +00:00
Martin Matuska
caed7b1c39 zfs: merge OpenZFS master-bedbc13da
Notable upstream commits:
  8e43fa12c Fix vdev_rebuild_thread deadlock
  03ef8f09e Add missing checks for unsupported features
  2e160dee9 Fix assert in FreeBSD-specific dmu_read_pages
  bedbc13da Cancel TRIM / initialize on FAULTED non-writeable vdevs

MFC after:	1 week
Obtained from:	OpenZFS
2021-03-03 02:15:33 +01:00
Mateusz Guzik
1d8510c1a6 zfs: add missing seqc write begin/end around zfs_acl_chown_setattr
It happens to trip over an assert but does not matter for correctness at
this time. However, do it for future proofing.

Reported by:	avg
2021-02-27 22:29:50 +00:00
Martin Matuska
c170aa9f37 zfs: add missing checks for unsupported features
After the merge of OpenZFS master-9312e0fd1 it has become possible to
import ZFS pools witn an active org.illumos:edonr feature on FreeBSD,
leading to a panic.

In addition, "zpool status" reported all pools without edonr as upgradable
and "zpool upgrade -v" lists edonr in the list of upgradable features.

This is an accepted but not yet included bugfix by upstream.

Obtained from:		https://github.com/openzfs/zfs/pull/11653
Differential Revision:	https://reviews.freebsd.org/D28935
Reported by:		garga (on freebsd-current@)
Reviewed by:		freqlabs
X-MFC-with:		ba27dd8be8
2021-02-27 00:05:50 +01:00
Eric Joyner
a7ac518bff ice_ddp: Update package file to 1.3.19.0
This package is intended to be used with ice(4) version 0.28.1-k.
That update will happen in a forthcoming commit.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Sponsored by: Intel Corporation
2021-02-22 18:02:19 -08:00
Cy Schubert
a805ffbcbc ipfilter: Make LARGE_NAT a tunable.
LARGE_NAT is a C macro that increases
	NAT_SIZE from 127 to 2047,
	RDR_SIZE from 127 to 2047,
	HOSTMAP_SIZE from 2047 to 8191,
	NAT_TABLE_MAX from 30000 to 180000, and
	NAT_TABLE_SZ from 2047 to 16383.

These values can be altered at runtime using the ipf -T command however
some adminstrators of large firewalls rebuild the kernel to enable
LARGE_NAT at boot. This revision adds the tunable net.inet.ipf.large_nat
which allows an administrator to set this option at boot instead of build
time. Setting the LARGE_NAT macro to 1 is unaffected allowing build-time
users to continue using the old way.
2021-02-22 11:20:18 -08:00
Martin Matuska
ba27dd8be8 zfs: merge OpenZFS master-9312e0fd1
Notable upstream changes:
  778869fa1 Fix reporting of mount progress
  e7adccf7f Disable use of hardware crypto offload drivers on FreeBSD
  03e02e5b5 Fix checksum errors not being counted on repeated repair
  64e0fe14f Restore FreeBSD resource usage accounting
  11f2e9a49 Fix panic if scrubbing after removing a slog device

MFC after:	2 weeks
2021-02-22 13:01:17 +01:00
Martin Matuska
ee36e25a86 zfs: merge OpenZFS master-bf156c966
Notable upstream changes:
    bf156c966 Remove unused abd_alloc_scatter_offset_chunkcnt
    658fb8020 Add "compatibility" property for zpool feature sets

This update introduces a new pool property called "compatibility"
that can be used to enable a limited set of pool features on pool
creation and "stick" to it, so the "zpool upgrade" does not
accidentally enable features that are not desired. The value of
this property may then be changed later.

See zpool-features(5) for more information about the "compatibility"
pool property.

Obtained from:	OpenZFS
MFC after:	2 weeks
2021-02-18 15:19:35 +01:00
Martin Matuska
afcb3c4cb4 zfs: change file mode of all merged tests
If the ksh files are not executable then the tests are not run
and reported as failed.

MFC after:	2 weeks
X-MFC-with:	6b52139eb8
2021-02-16 12:23:43 +01:00
Martin Matuska
184c1b9439 zfs: merge OpenZFS master-436ab35a5
- speed up writing to ZFS pools without ZIL devices (aa755b3)
- speed up importing ZFS pools (2d8f72d, a0e0199, cf0977a)
...

MFC after:		2 weeks
Reviewed by:		mjg (partial)
Tested by:		pho
Differential Revision:	https://reviews.freebsd.org/D28677
2021-02-16 02:46:28 +01:00
Martin Matuska
5dce03847f zfs: Avoid updating the L2ARC device header unnecessarily
From openzfs-master 0ae184a6b commit message:
  If we do not write any buffers to the cache device and the evict hand
  has not advanced do not update the cache device header.

Cherry-picked from openzfs 0ae184a6ba
Patch Author:   George Amanakis <gamanakis@gmail.com>

MFC after:	        3 days
Reviewed by:            delphij
Differential Revision:  https://reviews.freebsd.org/D28682
2021-02-15 10:56:08 +01:00
Martin Matuska
f15e18a642 zfs: fix RAIDZ2/3 not healing parity with 2+ bad disks
From openzfs-master 62d4287f2 commit message:
  When scrubbing, (non-sequential) resilvering, or correcting a checksum
  error using RAIDZ parity, ZFS should heal any incorrect RAIDZ parity by
  overwriting it.  For example, if P disks are silently corrupted (P being
  the number of failures tolerated; e.g. RAIDZ2 has P=2), `zpool scrub`
  should detect and heal all the bad state on these disks, including
  parity.  This way if there is a subsequent failure we are fully
  protected.

  With RAIDZ2 or RAIDZ3, a block can have silent damage to a parity
  sector, and also damage (silent or known) to a data sector.  In this
  case the parity should be healed but it is not.

Cherry-picked from openzfs 62d4287f27
Patch Author:	Matthew Ahrens <matthew.ahrens@delphix.com>

MFC after:		3 days
Reviewed by:		delphij
Differential Revision:	https://reviews.freebsd.org/D28681
2021-02-15 10:50:10 +01:00
Cy Schubert
1e811efbc5 Fix non-IPv6 build post 57785538c6.
57785538c6 change the test for FreeBSD
from __FreeBSD_version to __FreeBSD__. However this test was performed
before sys/param.h was included, therefore __FreeBSD_version was never
defined. As the test was never true opt_random_ip_id.h was never included.

Submitted by:	bdragon
Reported by:	bdragon
MFC after:	1 week
X-MFC with:	57785538c6
2021-02-09 17:18:25 -08:00
Antonio Russo
e9d419a053 Set file mode during zfs_write
Apply https://github.com/openzfs/zfs/pull/11576

Direct commit from upstream openzfs. Full commit message below:

Set file mode during zfs_write

3d40b65 refactored zfs_vnops.c, which shared much code verbatim between
Linux and BSD.  After a successful write, the suid/sgid bits are reset,
and the mode to be written is stored in newmode.  On Linux, this was
propagated to both the in-memory inode and znode, which is then updated
with sa_update.

3d40b65 accidentally removed the initialization of newmode, which
happened to occur on the same line as the inode update (which has been
moved out of the function).

The uninitialized newmode can be saved to disk, leading to a crash on
stat() of that file, in addition to a merely incorrect file mode.

Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Antonio Russo <aerusso@aerusso.net>
Closes #11474
Closes #11576

Obtained from:	openzfs/zfs@f8ce8aed0
MFC after:	0 days
Sponsored by:	iXsystems, Inc.
2021-02-09 12:30:06 -05:00
Cy Schubert
57785538c6 Simplify the FreeBSD check using __FreeBSD__ compiler macro.
Rather than rely on __FreeBSD_version, defined in sys/param.h, use
__FreeBSD__ defined by the compiler.

Reported by:	emaste
MFC after:	1 week
2021-02-08 16:36:27 -08:00
Cy Schubert
344f1083e1 ipfilter: Use the softn (NAT softc) host map size in ip_nat6 calculation.
The ipfilter NAT table host map size is a tunable that defaults to
a macro value defined at build time. HOSTMAP_SIZE is saved in softn
(the ipnat softc) at initialization. It can be tuned (changed) at runtime
using the ipf -T command. If the hostmap_size tunable is adjusted the
calculation to determine where to put new entries in the table was
incorrect. Use the tunable in the NAT softc instead of the static build
time value.

MFC after:	1 week
2021-02-05 18:39:38 -08:00
Cy Schubert
e673debe7d Simplify BSD macro tests.
All FreeBSD and NetBSD are BSD >= 199306 and have been for a long time.

MFC after:	1 week
2021-02-05 18:39:38 -08:00
Cy Schubert
0f34c80f37 Replace the redundant MENTAT macro with SOLARIS.
MENTAT and SOLARIS are synonymous. Remove the extraneous duplicate
macro.

MFC after:	1 week
2021-02-01 17:19:15 -08:00
Cy Schubert
7071734fae Indentation cleanup resulting from the cleanup of #ifdefs.
The conscious decision was made not to perform any indentation or
whitespace cleanup while cleaning out old redunant #ifdefs. The
reason for this was to avoid confusing future readers of history and
diffs with cosmetic changes, making bisection of any possible bugs
introduced more difficult. This commit cleans up the whitespace
detritus left behind from the previous #ifdef cleanup commits.

MFC after:	1 week
2021-02-01 17:19:15 -08:00
Cy Schubert
4cd1807c7d Retire the K&R/STD C __P prototype declarations.
In the old days when K&R C and STD C were each in use a workaround
(read hack) was required to allow the same code to work on each
without modification. All C compilers support STD C. We can finally
put the __P prototype to rest.

MFC after:	1 week
2021-02-01 17:19:15 -08:00
Mateusz Guzik
69c5fa5cd1 zfs: remove incomplete ifdefs for lockless symlink support
This wil be handled differently upstream and merged later.
2021-02-01 13:18:27 +01:00
Jung-uk Kim
29f37e9bcc acpica: Import ACPICA 20210105.
(cherry picked from commit a61ec1492c58c40bd0d968794c380668c157e2ef)
2021-01-29 20:53:07 -05:00
Jung-uk Kim
385fb5d933 acpica: Import ACPICA 20201217.
(cherry picked from commit a4634ed7779f0905e3bfeb781e58d40a5bdf9bb7)
2021-01-29 19:48:02 -05:00
Cy Schubert
83edbc3cb5 ipfilter: Retire pre-standard C support.
All C compilers in 2021 support standard C and architectures that did
not were retired long ago. Simplify by removing now redundant
pre-standard C code.

MFC after:	1 week
2021-01-25 14:46:45 -08:00
Mateusz Guzik
7af02ef0b2 zfs: use atomic_load_consume_ptr for z_cached_symlink 2021-01-25 22:40:15 +00:00
Mateusz Guzik
cc96f92a57 atomic: make atomic_store_ptr type-aware 2021-01-25 22:40:15 +00:00
Mateusz Guzik
f40d6217f2 zfs: fix panics with invariant kernels from zfs_replay_setattr 2021-01-25 22:40:14 +00:00
Mateusz Guzik
3110d4ebd6 zfs: add support for lockless symlink lookup
Reviewed by:	kib (previous version)
Tested by:	pho (previous version)
Differential Revision:	https://reviews.freebsd.org/D27488
2021-01-23 15:04:43 +00:00
John Baldwin
d86d319495 Simplify dynamic ipfilter sysctls.
Pass the structure offset in arg2 instead of arg1.  This avoids
having to undo the pointer arithmetic on arg1.  Instead arg2 can
be used directly as an offset relative to the desired structure.

Reviewed by:	cy
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D27961
2021-01-20 16:34:25 -08:00
Emmanuel Vadot
19775aa7bc Re-apply f81b2b9a8a to the new device-tree import 2021-01-15 20:07:13 +01:00
Emmanuel Vadot
78abc9e2e6 Revert upstream commit 27c90e5e48d0
It changed the #pinctrl-cells value to be equal to 2 and the macro
that generates the values.
Based on the bindings docs a value of 2 is only acceptable if the node
used pinctrl-single,bits and not pinctrl-single,pins

This allow booting further on the beaglebone black with 5.9 DTS
2021-01-15 20:07:08 +01:00
Emmanuel Vadot
c66ec88fed Add 'sys/contrib/device-tree/' from commit '5ee353c36d3c9c7f63df7c7671875e73fba70958'
git-subtree-dir: sys/contrib/device-tree
git-subtree-mainline: 94611a8388
git-subtree-split: 5ee353c36d
2021-01-15 12:28:57 +01:00
Alan Somers
58a08f9e99 [skip ci] Delete an accidentally-committed comment
MFC-With:	19cca0b961
2021-01-11 17:01:22 -07:00
Alan Somers
19cca0b961 aio: fix the tests when ZFS is not available
Don't try to cleanup the zpool if we couldn't create a zpool in the
first place.

Submitted by:	tmunro
MFC-with:	022ca2fc7f
2021-01-09 17:16:38 -07:00
Alexander V. Chernikov
537d134373 Bring DPDK route lookups to FreeBSD.
This change introduces loadable fib lookup modules based on
 DPDK rte_lpm lib targeted for high-speed lookups in large-scale tables.
It is based on the lookup framework described in D27401.

IPv4 module is called dpdk_lpm4. It wraps around rte_lpm [1] library.
This library implements variation of DIR24-8 [2] lookup algorithm.
Module provide lockless route lookups and in-place incremental updates,
 allowing for good RIB performance.

IPv6 module is called dpdk_lpm6. It wraps around rte_lpm6 [3] library.
Implementation can be seen as multi-bit trie where the stride or number of bits
 inspected on each level varies from level to level.
It can vary from 1 to 14 memory accesses, with 5 being the average value
 for the lengths that are most commonly used in IPv6.
Module provide lockless route lookups for global unicast addresses
 and in-place incremental updates, allowing for good RIB performance.

Implementation details:
* wrapper code lives in `sys/contrib/dpdk_rte_lpm/dpdk_lpm[6].c`.
* rte_lpm[6] implementation contains both RIB and FIB code.
 . RIB ("rule_") code, backed by array of hash tables part has been commented out,
 as base radix already provides all the necessary primitives.
* link-local lookups are currently implemented as base radix lookup.
 This part should be converted to something like read-only radix trie.

Usage detail:
Compile kernel with option FIB_ALGO and load dpdk_lpm4/dpdk_lpm6
 module at any time. They will be picked up automatically when
 amount of routes raises to several thousand.

[1]: https://doc.dpdk.org/guides/prog_guide/lpm_lib.html
[2]: http://yuba.stanford.edu/~nickm/papers/Infocom98_lookup.pdf
[3]: https://doc.dpdk.org/guides/prog_guide/lpm6_lib.html

Differential Revision: https://reviews.freebsd.org/D27412
2021-01-09 12:41:04 +00:00
Hans Petter Selasky
376e130b47 Fix memory leaks in error paths in krping.
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking
2021-01-08 12:35:55 +01:00
Matt Macy
b363d3d52a OpenZFS: Fix issues caused by reversed commits + rebase 2021-01-07 17:42:10 -08:00
Matt Macy
7877fdebee OpenZFS merge main-gf11b09
- add dRAID support
- fix duplicate close handling
- fix memory leak in prefetch
- fix problem with SIMD benchmarking on FreeBSD boot
...
2021-01-07 16:55:59 -08:00
Thomas Munro
a5e284038e open(2): Add O_DSYNC flag.
POSIX O_DSYNC means that writes include an implicit fdatasync(2), just
as O_SYNC implies fsync(2).

VOP_WRITE() functions that understand the new IO_DATASYNC flag can act
accordingly, but we'll still pass down IO_SYNC so that file systems that
don't understand it will continue to provide the stronger O_SYNC
behaviour.

Flag also applies to fcntl(2).

Reviewed by: kib, delphij
Differential Revision: https://reviews.freebsd.org/D25090
2021-01-08 13:15:56 +13:00
Conrad Meyer
98689d0ffb libprivatezstd: Restrict symbol visibility similar to upstream
We have to relax three symbols to dynamically link zstd(1), but the rest
are the same.
2021-01-03 11:26:46 -08:00
Conrad Meyer
bcae12b591 zstd: Fix non-FreeBSD CI libzstd build
Fix non-FreeBSD CI build after v1.4.8.  This definition was only used in
zstd(1), which isn't part of non-FreeBSD CI (I guess).  The ifdef was
added in v1.4.5 import.

Upstream does not currently support shared-linked zstd(1), but I have
proposed https://github.com/facebook/zstd/pull/2450 .  If that is
adopted, we can add -DZSTD_PROGRAMS_LINK_SHARED to our libzstd build and
drop some diffs.

Reported by:	uqs
2021-01-03 07:42:00 -08:00
Mateusz Guzik
82397d7919 vfs: denote vnode being a mount point with VIRF_MOUNTPOINT
Reviewed by:	kib (previous version)
Differential Revision:	https://reviews.freebsd.org/D27794
2021-01-03 06:50:06 +00:00
Hans Petter Selasky
aca12148b1 Improve error message printing in krping.
Don't print completion queue flush as an error.

MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2020-12-28 14:37:09 +01:00
Ryan Libby
f2d48b5e2c Merge commit d8a09b3a0 from openzfs git (by Ryan Libby):
lua: avoid gcc -Wreturn-local-addr bug

  Avoid a bug with gcc's -Wreturn-local-addr warning with some
  obfuscation.  In buggy versions of gcc, if a return value is an
  expression that involves the address of a local variable, and even if
  that address is legally converted to a non-pointer type, a warning may
  be emitted and the value of the address may be replaced with zero.
  Howerver, buggy versions don't emit the warning or replace the value
  when simply returning a local variable of non-pointer type.

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90737

  Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
  Signed-off-by: Ryan Libby <rlibby@FreeBSD.org>
  Closes #11337
2020-12-27 14:33:13 -08:00
Ryan Libby
21ce674e3c Merge commit 956f94010 from openzfs git (by Ryan Libby):
spa: avoid type narrowing warning

  Building the spa module for i386 caused gcc to emit
  -Wint-to-pointer-cast "cast to pointer from integer of different size"
  because spa.spa_did was uint64_t but pthread_join (via thread_join in
  spa_deactivate) takes a pointer (32-bit on i386).  Define spa_did to be
  pointer-size instead.  For now spa_did is in fact never non-zero and the
  thread_join could instead be ifdef'd out, but changing the size of
  spa_did may be more useful for the future.

  Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
  Signed-off-by: Ryan Libby <rlibby@FreeBSD.org>
  Closes #11336
2020-12-27 14:33:13 -08:00
Ryan Libby
48184e7661 Merge commit c7500ded3 from openzfs git (by Ryan Libby):
FreeBSD libzfs: gcc requires __thread after static

  Building libzfs with gcc on FreeBSD failed because gcc is picky about
  the order of keywords in declarations with __thread, whereas clang is
  more relaxed.

  https://gcc.gnu.org/onlinedocs/gcc/Thread-Local.html

  Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
  Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
  Signed-off-by: Ryan Libby <rlibby@FreeBSD.org>
  Closes #11331
2020-12-27 14:33:13 -08:00
Ryan Libby
e67d933d9c Merge commit 3fcd73747 from openzfs git (by Adrian Chadd):
Fix compiling on FreeBSD + gcc - don't assume illmnos bits

  This looks like it was once from the illumnos compat code.
  FreeBSD doesn't have cmn_err as a compiler format attribute, so
  it definitely errors out.

  It doesn't show up on LLVM because it doesn't trigger at all.

  Add in the format flags but keep them behind #if 0 for now;
  there are too many format issues that trigger when one does
  format checking in the shared code.

  Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
  Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
  Signed-off-by: adrian chadd <adrian@freebsd.org>
  Closes #11068
  Closes #11069
2020-12-27 14:33:13 -08:00
Ryan Libby
913f2d2e0c Merge commit 79a357c2a from openzfs git (by Adrian Chadd):
Fix pointer-is-uint64_t-sized assumption in the ioctl path

  This shows up when compiling freebsd-head on amd64 using gcc-6.4.
  The lib32 compat build ends up tripping over this assumption.

  Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
  Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
  Signed-off-by: adrian chadd <adrian@freebsd.org>
  Closes #11068
  Closes #11069
2020-12-27 14:33:13 -08:00
Michal Meloun
b9cbd68d1c ARM: Enhance common Nvidia Tegra drivers by support for Tegra210 SoC.
MFC after:	4 weeks
2020-12-26 19:13:10 +01:00
Conrad Meyer
f7cd7fe51c sys/contrib/zstd: Import zstd 1.4.8
Merge commit 'f6ae97673c28bdb9ae795bd235ab6f26f2536a2d' into main

Changes from 1.4.5:
  * https://github.com/facebook/zstd/releases/tag/v1.4.8
  * https://github.com/facebook/zstd/releases/tag/v1.4.7
  (and there was no public v1.4.6)

Conflicts:
	sys/contrib/zstd/lib/common/zstd_internal.h (new ZSTD_NO_INTRINSICS)
2020-12-25 07:42:41 -08:00
Konstantin Belousov
cd85379104 Make MAXPHYS tunable. Bump MAXPHYS to 1M.
Replace MAXPHYS by runtime variable maxphys. It is initialized from
MAXPHYS by default, but can be also adjusted with the tunable kern.maxphys.

Make b_pages[] array in struct buf flexible.  Size b_pages[] for buffer
cache buffers exactly to atop(maxbcachebuf) (currently it is sized to
atop(MAXPHYS)), and b_pages[] for pbufs is sized to atop(maxphys) + 1.
The +1 for pbufs allow several pbuf consumers, among them vmapbuf(),
to use unaligned buffers still sized to maxphys, esp. when such
buffers come from userspace (*).  Overall, we save significant amount
of otherwise wasted memory in b_pages[] for buffer cache buffers,
while bumping MAXPHYS to desired high value.

Eliminate all direct uses of the MAXPHYS constant in kernel and driver
sources, except a place which initialize maxphys.  Some random (and
arguably weird) uses of MAXPHYS, e.g. in linuxolator, are converted
straight.  Some drivers, which use MAXPHYS to size embeded structures,
get private MAXPHYS-like constant; their convertion is out of scope
for this work.

Changes to cam/, dev/ahci, dev/ata, dev/mpr, dev/mpt, dev/mvs,
dev/siis, where either submitted by, or based on changes by mav.

Suggested by: mav (*)
Reviewed by:	imp, mav, imp, mckusick, scottl (intermediate versions)
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D27225
2020-11-28 12:12:51 +00:00
Ian Lepore
a7623790fb Add the firmware blob required to use the sdma hardware in the imx6
processor, and its associated license text (which is similar to a
bsd-3-clause, but with a prohibition against decompiling).  Install a copy
of the license in /usr/share/doc/legal/imx, to comply with the license terms
that requires a copy of the license to be delivered along with the firmware.

Obtained from:	https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/imx/sdma/sdma-imx6q.bin https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/LICENSE.sdma_firmware
2020-11-26 01:40:04 +00:00
Marcin Wojtas
9eb1615f33 Adjust ENA driver files to latest ena-com changes
* Use the new API of ena_trace_*
* Fix typo syndrom --> syndrome
* Remove validation of the Rx req ID (already performed in the ena-com)
* Remove usage of deprecated ENA_ASSERT macro

Submitted by:   Ido Segev <idose@amazon.com>
Submitted by:   Michal Krawczyk <mk@semihalf.com>
Obtained from:  Semihalf
Sponsored by:   Amazon, Inc
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D27115
2020-11-18 14:59:22 +00:00
Marcin Wojtas
4f8f476e73 Fix completion descriptors alignment for the ENA
The latest generation hardware requires IO CQ (completion queue)
descriptors memory to be aligned to a 4K. It needs that feature for
the best performance.

Allocating unaligned descriptors will have a big performance impact as
the packet processing in a HW won't be optimized properly. For that
purpose adjust ena_dma_alloc() to support it.

It's a critical fix, especially for the arm64 EC2 instances.

Submitted by: Ido Segev <idose@amazon.com>
Obtained from: Amazon, Inc
MFC after: 1 week
Differential revision:  https://reviews.freebsd.org/D27114
2020-11-18 14:50:12 +00:00
Cy Schubert
dd4f81cd06 Restore identification of VDEVs using non-native block size.
NAME         STATE     READ WRITE CKSUM
    dsk02        ONLINE       0     0     0
      mirror-0   ONLINE       0     0     0
        ada1s4a  ONLINE       0     0     0
        ada2s4a  ONLINE       0     0     0  block size: 512B configured,
					     4096B native

Reviewed by:		tsoome (previous FreeBSD phab version)
Differential Revision:	https://reviews.freebsd.org/D26880

Upstream commit:	3928ec5339
Reviewed-by:		Matt Macy <mmacy@FreeBSD.org>
Reviewed-by:		Toomas Soome <tsoome@me.com>
Reviewed-by:		Brian Behlendorf <behlendorf1@llnl.gov>
Signed off by:		Cy Schubert <cy@FreeBSD.org>
Closes #11088
2020-11-18 01:18:45 +00:00
Emmanuel Vadot
04b8208fc0 vchiq: Rename timer func so they do not conflict with linuxkpi 2020-11-17 14:41:23 +00:00
Mateusz Guzik
5596f836e7 zfs: disable periodic arc updates
They are only there to provide less innacurate statistics for debuggers.
However, this is quite heavy-weight and instead it would be better to
teach debuggers how to obtain the necessary information.
2020-11-14 19:23:07 +00:00
Jung-uk Kim
fbde34778b MFV: r367652
Merge ACPICA 20201113.
2020-11-13 22:45:26 +00:00
Mateusz Guzik
4426311a3c zfs: combine zio caches if possible
This deduplicates 2 sets of caches using the same sizes.

Memory savings fluctuate a lot, one sample result is buildworld on zfs
saving ~180MB RAM in reduced page count associated with zio caches.
2020-11-10 14:23:46 +00:00
Mateusz Guzik
41ce62251c zfs: g/c unused data_alloc_arena 2020-11-10 14:21:23 +00:00
Mariusz Zaborski
36d6566e59 Check if the ZVOL has been written before calling zil_async_to_sync.
The ZIL will be opened on the first write, not earlier.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Mariusz Zaborski <oshogbo@vexillium.org>
OpenZFS Pull Request: https://github.com/openzfs/zfs/pull/11152
PR:		250934
2020-11-08 14:08:00 +00:00
Mateusz Guzik
ff19fd6242 zfs: remove 2 assertions that teardown lock is not held
They are not very useful and hard to implement with rms.

This has a side effect of simplying the code.
2020-11-07 16:58:38 +00:00
Mark Johnston
acb5785aae Add firmware modules for qat(4), take two
My script to convert git commits to svn patch does not handle binary
files correctly, and r367387 committed a set of empty files as a result.

MFC with:	r367387
Sponsored by:	Rubicon Communications, LLC (Netgate)
2020-11-06 16:12:06 +00:00
Mark Johnston
f078c492a9 Add firmware modules for qat(4)
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC (Netgate)
2020-11-05 16:00:30 +00:00
Mateusz Guzik
aebc96831f zfs: lz4: add optional kmem_alloc support
lz4 port from illumos to Linux added a 16KB per-CPU cache to accommodate for
the missing 16KB malloc. FreeBSD supports this size, making the extra cache
harmful as it can't share buckets.
2020-11-05 03:25:23 +00:00
Mateusz Guzik
926ad187fd zfs: use rms lock for teardown handling
This deserializes otherwise non-contending operations.

The previous scheme of using 17 locks hashed by curthread runs into
conflicts very quickly.
2020-11-04 21:22:41 +00:00
Mateusz Guzik
4008dd4581 zfs: macroify teardown handling 2020-11-04 21:19:54 +00:00
Mateusz Guzik
ae5642a670 zfs: rename teardown inactive macros to mimick rrm convention 2020-11-04 21:19:25 +00:00
Mateusz Guzik
4a0b7fd502 zfs: add branch prediction to ZFS_ENTER and ZFS_VERIFY_ZP macros
They are expected to fail only in corner cases.
2020-11-04 21:18:51 +00:00
Mateusz Guzik
8ce21ae6ba zfs: even up assert 2020-11-04 21:18:27 +00:00
Mateusz Guzik
36639c3942 zfs: zstd: short-circuit cleaning buffers if none exist
This avoids a barrage of locking every minute.
2020-11-02 17:39:59 +00:00
Brandon Bergren
bd5e074531 Fix 32-bit build after r367229.
The use of atomic_sub_64() in zfs_zstd.c was breaking the 32-bit build on
platforms without native 64-bit atomics due to atomic_sub_64() not being
available, and no fallback being provided in _STANDALONE.

Provide a standalone stub to match atomic_add_64() using simple math.

While this is not actually atomic, it does not matter in libsa context,
since it always runs single-threaded and does not run under a scheduler.

Reviewed by: mjg (in email)
2020-10-31 21:11:34 +00:00
Mateusz Guzik
4a58b4ab28 zfs: zstd: track allocator statistics
This applies:
commit c4ede65bdf
Author: Mateusz Guzik <mjguzik@gmail.com>
Date:   Fri Oct 30 23:26:10 2020 +0100

    zstd: track allocator statistics

    Note that this only tracks sizes as requested by the caller.
    Actual allocated space will almost always be bigger (e.g., rounded up to
    the next power of 2 or page size). Additionally the allocated buffer may
    be holding other areas hostage. Nonetheless, this is a starting point
    for tracking memory usage in zstd.

from openzfs
2020-10-31 19:07:32 +00:00
Mateusz Guzik
4bfebc8d2c cache: add cache_vop_mkdir and rename cache_rename to cache_vop_rename 2020-10-30 10:46:35 +00:00
Edward Tomasz Napierala
bce7ee9d41 Drop "All rights reserved" from all my stuff. This includes
Foundation copyrights, approved by emaste@.  It does not include
files which carry other people's copyrights; if you're one
of those people, feel free to make similar change.

Reviewed by:	emaste, imp, gbe (manpages)
Differential Revision:	https://reviews.freebsd.org/D26980
2020-10-28 13:46:11 +00:00
Mateusz Guzik
c90590dd92 zfs: remove unused support for zfs_znode_move 2020-10-26 08:17:41 +00:00
Ryan Moeller
b19cdab345 Skip RAW kstat sysctls by default
hese kstats are often expensive to compute so we want to avoid them
unless specifically requested.

The following kstats are affected by this change:

kstat.zfs.${pool}.multihost
kstat.zfs.${pool}.misc.state
kstat.zfs.${pool}.txgs
kstat.zfs.misc.fletcher_4_bench
kstat.zfs.misc.vdev_raidz_bench
kstat.zfs.misc.dbufs
kstat.zfs.misc.dbgmsg

PR:		249258
Reported by:	mjg
Reviewed by:	mjg, allanjude
Obtained from:	https://github.com/openzfs/zfs/pull/11099
Sponsored by:	iXsystems, Inc.
2020-10-24 16:25:52 +00:00
Mateusz Guzik
25fb30bd9a vfs: drop spurious cache_purge on rmdir
The removed directory gets cache_purged which is sufficient to remove any entries
related to the parent.

Note only tmpfs, ufs and zfs are patched.
2020-10-23 15:50:49 +00:00
Mateusz Guzik
ab21ed17ed vfs: drop the de facto curthread argument from VOP_INACTIVE 2020-10-20 07:19:03 +00:00
Mateusz Guzik
8ecd87a3e7 vfs: drop spurious cred argument from VOP_VPTOCNP 2020-10-20 07:18:27 +00:00
Matt Macy
180f822596 Update OpenZFS to 2.0.0-rc3-gfc5966
- fix panic due to tqid overflow
- Improve libzfs_error_init messages
- Expose zfetch_max_idistance tunable
- Make dbufstat work on FreeBSD
- Fix EIO after resuming receive of new dataset over an existing one
2020-10-17 01:06:04 +00:00
Mateusz Guzik
e8796aca1c zfs: g/c unused vop_vector zfsctl_ops_shares_dir 2020-10-15 05:04:57 +00:00
Mateusz Guzik
b820822823 zfs: add missing fplookup vops
Some vnodes come with a hack which inherits the fplookup flag despite having vops
which don't provide the routine.

Reported by:	YAMAMOTO Shigeru <shigeru@os-hackers.jp>
2020-10-15 04:49:34 +00:00
Mateusz Guzik
c3f8f86efd FreeBSD: fix panic due to tqid overflow
The 32-bit counter eventually wraps to 0 which is a sentinel for invalid
id.

Make it 64-bit on LP64 platforms and 0-check otherwise.

Note: Linux counterpart uses id stored per queue instead of a global.
I did not check going that way is feasible with the goal being the
minimal fix doing the job.

Reported by:	YAMAMOTO Shigeru <shigeru@os-hackers.jp>
Reviewed by:	mav
Differential Revision:	https://reviews.freebsd.org/D26759
2020-10-13 20:40:09 +00:00
Warner Losh
2fec3ae896 Add zstd support to the boot loader.
Add support to the _STANDALONE environment enough bits of the kernel
that we can compile it. We still have a small zstd_shim.c since there
were 3 items that were a bit hard to nail down and may be cleaned up
in the future. These go hand in hand with a number of commits to
sys/sys in the past weeks, should this need be MFCd.

Discussed with: mmacy (in review and on IRC/Slack)
Reviewed by: freqlabs (on openzfs repo)
Differential Revision: https://reviews.freebsd.org/D26218
2020-10-12 22:19:07 +00:00
Mateusz Guzik
a4bcd20486 zfs: use cache_rename 2020-10-10 04:18:49 +00:00
Jung-uk Kim
f15e9afb1f MFV: r366539
Merge ACPICA 20200925.
2020-10-09 05:27:02 +00:00
Ryan Moeller
3331a1d173 Explicit CTLFLAG_DYN not needed
Dynamically created OIDs automatically get this flag set.

Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D26561
2020-10-04 19:37:15 +00:00
Matt Macy
11322826a4 OpenZFS: don't call fpu_kern_thread on i386 2020-10-02 01:25:08 +00:00
Matt Macy
c40487d49b OpenZFS: MFV 2.0-rc3-gfc5966
- Annotate FreeBSD sysctls with CTLFLAG_MPSAFE
- Reduce stack usage of Lua
- Don't save user FPU context in kernel threads
- Add support for procfs_list
- Code cleanup in zio_crypt
- Add DB_RF_NOPREFETCH to dbuf_read()s in dnode.c
- Drop references when skipping dmu_send due to EXDEV
- Eliminate gratuitous bzeroing in dbuf_stats_hash_table_data
- Fix legacy compat for platform IOCs
2020-10-01 23:28:21 +00:00
Cy Schubert
d9bc41a1c2 Continued ipfilter #ifdef cleanup. The r343701 log entry contains a
complete description.

MFC after:	1 week
2020-09-30 08:26:25 +00:00
Mark Johnston
752c1d14e3 ZFS: Fix a logic bug in the FreeBSD getpages VOP
This was introduced when I merged r361287 to OpenZFS and has been fixed
there already, commit 3f6bb6e43fd68e.

Reported by:	swills
Reviewed by:	allanjude, freqlabs, mmacy
2020-09-29 13:41:47 +00:00
Cy Schubert
c4390e6da6 Remove extraneous bracket.
MFC after:	3 days
2020-09-27 18:39:15 +00:00
Mateusz Guzik
a3d9bf49b5 cache: drop the force flag from purgevfs
The optional scan is wasteful, thus it is removed altogether from unmount.

Callers which always want it anyway remain unaffected.
2020-09-23 10:46:07 +00:00
D Scott Phillips
191dad8b0a vchi: rename bitset macros to avoid collision with bitset(9)
An upcoming change to include bitset(9) macros from vm_page.h
causes a macro name collision with vchi's custom bitset macros.

This change was performed mechanically by:

  sed -i .orig s/BITSET/VCHI_BITSET/g $(grep -rl BITSET sys/contrib/vchiq)

Reviewed by:	andrew
Approved by:	scottl (implicit)
MFC after:	1 week
Sponsored by:	Ampere Computing, Inc.
Differential Revision:	https://reviews.freebsd.org/D26177
2020-09-21 22:18:09 +00:00
Matt Macy
2c48331d28 MFV 2.0-rc2
- Fixes divide by zero for unusual hz
- remove cryptodev dependency
2020-09-18 23:21:24 +00:00
Ed Maste
11224884f2 ys/contrib/dev/ath: remove unintentional double semicolon
Approved by:	adrian
2020-09-18 18:35:18 +00:00
Konstantin Belousov
96474d2a3f Do not copy vp into f_data for DTYPE_VNODE files.
The pointer to vnode is already stored into f_vnode, so f_data can be
reused.  Fix all found users of f_data for DTYPE_VNODE.

Provide finit_vnode() helper to initialize file of DTYPE_VNODE type.

Reviewed by:	markj (previous version)
Discussed with:	freqlabs (openzfs chunk)
Tested by:	pho (previous version)
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D26346
2020-09-15 21:55:21 +00:00
Eric Joyner
cf08d707d4 ice_ddp: Fix 1.3.16.0 package
The version uploaded in the previous commit was far too small. This one
should be the right size.

MFC after:	1 day
Sponsored by:	Intel Corporation
2020-09-10 04:00:13 +00:00
Matt Macy
eac7052fde ZFS: MFV 2.0-rc1-gfd20a8
- fixes jail delegation
- fixes raw kstat unsupported complaints
- exposes dbgmsg, dbuf, and checksum benchmark stats
- restore rename -u support
2020-09-04 22:25:14 +00:00
Eric Joyner
1bd641af2b ice_ddp: Update package file to 1.3.16.0
This package is intended to be used with ice(4) version 0.26.16. That
update will happen in a forthcoming commit.

MFC after:	3 days
Sponsored by:	Intel Corporation
2020-09-04 17:37:58 +00:00
Matt Macy
ac0bf12ee5 ZFS: MFV 2.0-rc1-ga00c61 2020-08-28 18:53:45 +00:00
Toomas Soome
f6385d921b remove pragma ident lines
The #pragma ident is historical relict and not needed any more, this
pragma is actually unknown for common compilers and is only causing
trouble.
2020-08-26 07:29:17 +00:00
Matt Macy
eda14cbc26 Initial import from vendor-sys branch of openzfs 2020-08-24 23:31:26 +00:00
Conrad Meyer
43eccfe9b4 pcg-c: Add 'static' to inline function definitions
Make the inlines static to avoid kernel build failure with Clang 11 on i386.
(The issue was not observed with Clang 10, currently in tree; reproduction
depends on compiler inlining choices.)

The compiler may choose not to inline 'bare' C inlines, and in that case
expects a symbol of the same name will be available.  It does not
automatically define that symbol at use, because of traditional C linking
semantics. (In contrast, C++ does define it, and then deduplicates redundant
definitions at link).  As we do not instantiate the C99 inline ('extern
inline ...;'), the linker errors with "undefined symbol."

Reported by:	dim
Tested by:	dim
Fixes:		r364219
2020-08-15 18:46:26 +00:00
Conrad Meyer
8a0edc914f Add prng(9) API
Add prng(9) as a replacement for random(9) in the kernel.

There are two major differences from random(9) and random(3):

- General prng(9) APIs (prng32(9), etc) do not guarantee an
  implementation or particular sequence; they should not be used for
  repeatable simulations.

- However, specific named API families are also exposed (for now: PCG),
  and those are expected to be repeatable (when so-guaranteed by the named
  algorithm).

Some minor differences from random(3) and earlier random(9):

- PRNG state for the general prng(9) APIs is per-CPU; this eliminates
  contention on PRNG state in SMP workloads.  Each PCPU generator in an
  SMP system produces a unique sequence.

- Better statistical properties than the Park-Miller ("minstd") PRNG
  (longer period, uniform distribution in all bits, passes
  BigCrush/PractRand analysis).

- Faster than Park-Miller ("minstd") PRNG -- no division is required to
  step PCG-family PRNGs.

For now, random(9) becomes a thin shim around prng32().  Eventually I
would like to mechanically switch consumers over to the explicit API.

Reviewed by:	kib, markj (previous version both)
Discussed with:	markm
Differential Revision:	https://reviews.freebsd.org/D25916
2020-08-13 20:48:14 +00:00
Conrad Meyer
9119bafbaf Import PCG-C into sys/contrib
The intended (future) use is to provide fast pseudo-random numbers in non-
cryptographic applications.
2020-07-30 23:54:25 +00:00
Jung-uk Kim
61b180362a MFV: r363292
Merge ACPICA 20200717.
2020-07-18 07:35:34 +00:00
Cy Schubert
4fbd491ee3 Fix incorrect byte order in ipfstat -f output.
- make sure frag is initialized to 0
- initialize ipfr_p field

NetBSD PR:	55137
Submitted by:	christos@NetBSD.org
Reported by:	christos@NetBSD.org
Obtained from:	NetBSD fil.c r1.32, ip_frag.c r1.8
MFC after:	2 weeks
2020-07-17 19:07:59 +00:00
Cy Schubert
1b5e9f7d1e pfil_run_hooks() can be called recursively, so we have to
define FASTROUTE_RECURSION in fil.c

Submitted by:	christos@NetBSD.org
Reported by:	christos@NetBSD.org
Obtained from:	NetBSD r1.31
MFC after:	2 weeks
2020-07-17 19:07:56 +00:00
Matt Macy
56e5ad5ff7 Rename nvpair.c to bsd_nvpair.c to not conflict with openzfs' version. 2020-06-27 00:55:03 +00:00
Mitchell Horne
7814aaf5a9 Document upgrade procedure in FREEBSD-upgrade
It was pointed out to me that this is the convention for documenting upgrade
instructions, rather than just leaving the instructions in the commit message.
It's possible these commands won't be used again before we transition to git,
but then at least they'll give a path forward for whoever touches this next.

Suggested by:	lwhsu
2020-06-04 20:48:57 +00:00
Mitchell Horne
3245fa215a Update edk2 headers to stable202005
We use these to compile libefivar. The particular motivation for this update is
the inclusion of the RISC-V machine definitions that allow us to build the
library on the platform. This support could easily have been submitted as a
small local diff, but the timing of the release coincided with this work, and
it has been over 3 years since these sources were initially imported.

Note that this comes with a license change from regular BSD 2-clause to the
BSD+Patent license. This has been approved by core@ for this particular
project [1].

As with the original import, we retain only the subset of headers that we
actually need to build libefivar. I adapted imp@'s process slightly for this
update:

    # Generate list of the headers needed to build
    cp -r ../vendor/edk2/dist/MdePkg/Include sys/contrib/edk2
    cd lib/libefivar
    make
    pushd `make -V .OBJDIR`
    cat .depend*.o | grep sys/contrib | cut -d' ' -f 3 |
        sort -u | sed -e 's=/full/path/sys/contrib/edk2/==' > /tmp/xxx
    popd

    # Merge the needed files
    cd ../../sys/contrib/edk2
    svn revert -R .
    for i in `cat /tmp/xxx`; do
        svn merge -c VendorRevision svn+ssh://repo.freebsd.org/base/vendor/edk2/dist/MdePkg/$i $i
    done
    svn merge -c VendorRevision svn+ssh://repo.freebsd.org/base/vendor/edk2/dist/MdePkg/MdePkg.dec MdePkg.dec

[1] https://www.freebsd.org/internal/software-license.html
2020-06-04 19:21:41 +00:00
Jung-uk Kim
0b229c80ae MFV: r361597
Import ACPICA 20200528.
2020-05-28 21:19:44 +00:00
Eric Joyner
71d104536b ice(4): Introduce new driver for Intel E800 Ethernet controllers
The ice(4) driver is the driver for the Intel E8xx series Ethernet
controllers; currently with codenames Columbiaville and
Columbia Park.

These new controllers support 100G speeds, as well as introducing
more queues, better virtualization support, and more offload
capabilities. Future work will enable virtual functions (like
in ixl(4)) and the other functionality outlined above.

For full functionality, the kernel should be compiled with
"device ice_ddp" like in the amd64 NOTES file, and/or
ice_ddp_load="YES" should be added to /boot/loader.conf so that
the DDP package file included in this commit can be downloaded
to the adapter. Otherwise, the adapter will fall back to a single
queue mode with limited functionality.

A man page for this driver will be forthcoming.

MFC after:	1 month
Relnotes:	yes
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D21959
2020-05-26 23:35:10 +00:00
Marcin Wojtas
8483b844e7 Adjust ENA driver to the new HAL
* Removed adaptive interrupt moderation (not suported on FreeBSD).
* Use ena_com_free_q_entries instead of ena_com_free_desc.
* Don't use ENA_MEM_FREE outside of the ena_com.
* Don't use barriers before calling doorbells as it's already done in
  the HAL.
* Add function that generates random RSS key, common for all driver's
  interfaces.
* Change admin stats sysctls to U64.

Submitted by:  Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
Sponsored by:  Amazon, Inc.
2020-05-26 15:29:19 +00:00
Adrian Chadd
8c01c3dc46 [ath] [ath_hal] Propagate the HAL_RESET_TYPE through to the chip reset; set it during ath_reset()
Although I added the reset type field to ath_hal_reset() years ago,
I never finished adding it both throughout the HALs and in if_ath.c.

This will eventually deprecate the ath_hal force_full_reset option
because it can be requested at the driver layer.

So:

* Teach ar5416ChipReset() and ar9300_chip_reset() about the HAL type
* Use it in ar5416Reset() and ar9300_reset() when doing a full chip reset
* Extend ath_reset() to include the HAL_RESET_TYPE parameter added in the above functions
* Use HAL_RESET_NORMAL in most calls to ath_reset()
* .. but use HAL_RESET_BBPANIC for the BB panics, and HAL_RESET_FORCE_COLD during fatal, beacon miss and other hardware related hangs.

This should be a glorified no-op outside of actual hardware issues.
I've tested things with ath_hal force_full_reset set to 1 for years now,
so I know that feature and a full reset works (albeit much slower than
a warm reset!) and it does unwedge hardware.

The eventual aim is to use this for all the places where the driver
detects a potential hang as well as if long calibration - ie, noise floor
calibration - fails to complete. That's one of the big hardware related
things that causes station mode operation to hang without easy recovery.

Differential Revision:	https://reviews.freebsd.org/D24981
2020-05-25 22:31:45 +00:00
Conrad Meyer
b6be5f6405 Unbreak ARM64 kernel build after r361426
X-MFC-With:	r361426
2020-05-23 23:10:03 +00:00
Conrad Meyer
37f1f2684f Update to Zstandard 1.4.5
As usual, the full release notes are found on Github:

  https://github.com/facebook/zstd/releases/tag/v1.4.5

Notable changes include:

* Improved decompress performance on amd64 and arm (5-10%
  and 15-50%, respectively).
* '--patch-from' zstd(1) CLI option, which provides something like a very fast
  version of bspatch(1) with slightly worse compression.  See release notes.

In this update, I dropped the 3-year old -O0 workaround for an LLVM ARM bug;
the bug was fixed in LLVM SVN in 2017, but we didn't remove this workaround
from our tree until now.

MFC after:	I won't, but feel free
Relnotes:	yes
2020-05-23 21:23:46 +00:00
Conrad Meyer
c0f419ec56 contrib/zstd: Revise Xlist for 1.4.5 import 2020-05-23 20:39:36 +00:00
Adrian Chadd
43f12c5b66 [ath_hal_ar9300] Ensure AH_BYTE_ORDER is defined before used.
Same deal here - ensure endian bits are set here first!
2020-05-12 02:23:11 +00:00
Adrian Chadd
41137b0604 [ath_hal] [ath_hal_ar9300] Fix endian macros to work in and out of kernel tree.
Yes, people shouldn't use bitfields in C for structure parsing.
If someone ever wants a cleanup task then it'd be great to remove them
from this vendor code and other places in the ar9285/ar9287 HALs.

Alas, here we are.

AH_BYTE_ORDER wasn't defined and neither were the two values it could be.
So when compiling ath_ee_print_9300 it'd default to the big endian struct
layout and get a WHOLE lot of stuff wrong.

So:

* move AH_BYTE_ORDER into ath_hal/ah.h where it can be used by everyone.
* ensure that AH_BYTE_ORDER is actually defined before using it!

This should work on both big and little endian platforms.
2020-05-12 02:20:27 +00:00
Adrian Chadd
6851341a33 [ar9300] Disable unconditionally reducing transmit power in the case of FCC.
Ok, yeah, the commit title is a bit misleading.

This has to do with CDD (cyclic delay diversity) - how this and later
wifi hardware transmits lower rates over more antennas.  Eg, if you're
transmitting legacy 11abg rates on 2 or 3 antennas, you COULD just
send them all at the same time or you could delay each by tens/hundreds
of nanoseconds to try and get some better diversity characteristics.

However, this has a fun side effect - the antenna pattern is no longer
a bunch of interacting dipoles, but are a bunch of interacting dipoles
plus a bunch of changing phases.  And it's frequency dependent - 50-200nS
is not exactly the same fraction of a wavelength across all of 2GHz or 5GHz!

Thus the power spectral density and maximum directional gain that you're
effectively getting is not .. well, as flat as it once was.

For more information, look up FCC/OET 13TR1003 in the FCC technical report
database.  It has pretty graphics and everything.

Anyway, the problem lies thusly - the CDD code just subtracts another 3dB
or 5dB for the lower rates based on transmit antenna configuration.
However, it's not done based on operating configuration and it doesn't
take into account how far from any regulatory limits the hardware is at.
It also doesn't let us do things like transmit legacy rates and frames
on a single antenna without losing up to 5dB when we absolutely don't
need to in that case (there's no CDD used when one antenna is used!)

This shows up as the hardware behaving even worse for longer distance links
at 20MHz because, well, those are the exact rates losing a bunch more
transmit power.

* For lower power NICs (ie the majority of what is out there!) it's highly
  unlikely we're going to hit anywhere near the PSD limits.
* It's doing it based on the existing limits from the CTL table (conformance
  testing limits) - this isn't the regulatory max!  It's what the NIC is
  allowed to put out in each frequency and rate configuration!  So things like
  band edges, power amplifier behaviour and maximum current draw apply here.
  Blindly subtracting 3 to 5dB from /this/ value is /very/ conservative..
* /and/ ath9k just plainly doesn't do any of this at all.

So, for now disable it and get the TX power back, thus matching what ath9k
in Linux is doing.  If/once I get some more cycles I'll look at making it
a bit more adaptive and really only kick in if we're a few dB away from
hard regulatory limits.

Tested:

* AR9344 (2GHz + SoC, 2x2 configuration) - AP and STA modes
* QCA9580 (5GHz 2x2 and 3x3 configurations) - AP and STA modes
2020-05-11 05:53:12 +00:00
Jung-uk Kim
08ddfe8657 MFV: r360512
Merge ACPICA 20200430.
2020-05-01 01:26:36 +00:00
Cy Schubert
0de1739f53 Convert ipfilter to the new routing KPI.
Reviewed by:	melifaro (previous version)
2020-04-19 17:01:17 +00:00
Cy Schubert
486d32182a fib4_free_nh_ext is an empty function. It does nothing. Don't call it.
MFC after:	2 weeks
2020-04-19 17:01:14 +00:00
Olivier Houchard
77a1348b3c Remove FreeBSD/armv4 specific bits from CK.
Now that armv4/v5 is gone, remove the bits that implemented atomic operations
by disabling interrupts.
Those were specific to FreeBSD and never reached upstream.
2020-04-13 23:16:32 +00:00
Jung-uk Kim
3ee58df503 Merge ACPICA 20200326. 2020-03-27 00:29:33 +00:00
Alex Richardson
02f4a9dd96 Fix misleading indentation warning in OCTEON1 kernel
This is required to switch MIPS to compile with LLVM by default (D23204).

Reviewed By:	brooks
Differential Revision: https://reviews.freebsd.org/D24091
2020-03-17 11:59:45 +00:00
Cy Schubert
8b1e4b7c63 Retire macros:
BSD_GE_YEAR
	BSD_GT_YEAR
	BSD_LT_YEAR

MFC after:	3 days
2020-03-02 23:25:02 +00:00
Cy Schubert
060abae563 Remove the now unused FREEBSD_GE_REV, FREEBSD_GT_REV, and FREEBSD_LT_REV
macros.

MFC after:	3 days
2020-03-02 23:24:58 +00:00
Cy Schubert
20746e11f7 Continuing the effort started in r343701, #ifdef cleanup, checking for
__FreeBSD_version > 3.0 and 5.0 is redundant.

MFC after:	3 days
2020-03-02 23:24:53 +00:00
Cy Schubert
a0df113ce2 With the planned removal of GIANT (sysctl uses GIANT), make future-proof
ipfilter by making it sysctl locking mpsafe.

Reviewed by:	kaktus
Differential Revision:	https://reviews.freebsd.org/D23839
2020-02-26 20:18:38 +00:00
Pawel Biernacki
7029da5c36 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE.  All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by:	kib (mentor, blanket)
Commented by:	kib, gallatin, melifaro
Differential Revision:	https://reviews.freebsd.org/D23718
2020-02-26 14:26:36 +00:00
Brandon Bergren
f55185bcd8 [PowerPC] [Book-E] Remove obsolete interrupt binding workaround
Remove an old workaround that is no longer necessary since rS343824.

There used to be a problem with FMan interrupts firing on multiple CPUS
at the same time.

This ended up being due to multicast interrupts being unsupported in the
Freescale PIC (so instead of using a selection algorithm, it would do some
unspecified action, such as interrupting multiple cpus at random.)

Reviewed by:	jhibbits
Sponsored by:	Tag1 Consulting, Inc.
Differential Revision:	https://reviews.freebsd.org/D23829
2020-02-25 22:03:30 +00:00
Brandon Bergren
b9931c0786 [PowerPC] [Book-E] Fix dpaa interrupt binding.
After the network epoch was added, we lost the ability to migrate the
ithread in the middle of dispatch, as being in the network epoch will pin
the current thread (for safety reasons.)

Luckily, we don't actually have to do this workaround in the first place,
as we can just bind it to the correct cpu when we preallocate it.

Pass dev through to XX_PreallocAndBindIntr() and actually bind it to the
cpu like it was supposed to in the first place, instad of leaving it
floating and moving it to the correct cpu the first time it fires.

This fixes panics while bringing up dtsec on my X5000.

Reviewed by:	jhibbits
Sponsored by:	Tag1 Consulting, Inc.
Differential Revision:	https://reviews.freebsd.org/D23826
2020-02-25 03:35:52 +00:00
Pawel Biernacki
c5a017219f Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (8 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Approved by:	kib (mentor, blanket)
Differential Revision:	https://reviews.freebsd.org/D23628
2020-02-24 10:35:58 +00:00
Matt Macy
bbb7a2c7c3 Add chacha20poly1305 support to crypto build
This is a dependency for in-kernel wireguard.

Reviewed by:	cem@
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC (Netgate)
Differential Revision:	https://reviews.freebsd.org/D23689
2020-02-16 00:03:09 +00:00
Jung-uk Kim
ec0234b4c2 MFV: r357927
Merge ACPICA 20200214.
2020-02-15 03:47:25 +00:00
Warner Losh
58aa35d429 Remove sparc64 kernel support
Remove all sparc64 specific files
Remove all sparc64 ifdefs
Removee indireeect sparc64 ifdefs
2020-02-03 17:35:11 +00:00
Jung-uk Kim
f425b8be7e MFV: r356607
Import ACPICA 20200110.
2020-01-10 22:49:14 +00:00
Brandon Bergren
e99c4e4d64 [PowerPC] Clang powerpcspe build fixes
* Fix a couple of format errors.
* Add some extra compiler flags needed to force clang to build SPE code.
  (These are temporary until the target triple is fixed)
2019-12-27 05:01:13 +00:00
Gleb Popov
3f791e31fd Don't shift 32-bit value by more than 32 bits.
PR:		207854
Approved by:	emaste
2019-12-21 11:38:48 +00:00
Jung-uk Kim
f9a6772ec3 MFV: r355716
Merge ACPICA 20191213.
2019-12-13 23:28:52 +00:00
Cy Schubert
2716484cbc Rather than pass the address of the packet information control block to
ipf_pcksum6(), directly pass the adddress of the mbuf to it. This reduces
one pointer dereference. ipf_pcksum6() doesn't use the packet information
control block except to obtain the mbuf address.

MFC after:	3 days
2019-12-12 20:44:49 +00:00
Cy Schubert
55cab13b31 in6_cksum() returns zero when checksums are good.
PR:		203275
Reported by:	Frank Volf <frank@deze.org>
MFC after:	3 days
2019-12-12 20:44:46 +00:00
Cy Schubert
81c2e8a6f2 Include fin, the packet information structure (fr_info_t), in the
l4sums DTrace probe, making more information available for the diagnosis
of IPv6 checksum errors.

MFC after:	3 days
2019-11-28 00:46:33 +00:00
Cy Schubert
9b7459d396 Move ipf_pcksum6() to its rightful place, in ip_fil_freebsd.c. This
FreeBSD-only function should live in the O/S specific source file.

This essentially reverts r349929 Now that ipftest and ipfreplay are
disabled in FreeBSD 11-stable.

MFC after:	3 days
2019-11-27 20:08:42 +00:00
Cy Schubert
c21bae587d Save a little stack by removing a used once intermediate variable.
MFC after:	3 days
2019-11-27 20:08:39 +00:00
Cy Schubert
89d74deb55 Remove redundant #ifdef'd function definitions.
MFC after:	3 days
2019-11-27 20:08:35 +00:00
Conrad Meyer
9cbefe25d4 Update to Zstandard 1.4.4
The full release notes can be found on Github:

  https://github.com/facebook/zstd/releases/tag/v1.4.4

Notable changes in this release include improved decompression speed (about
10%).  See the Github release notes for more details.

MFC after:	I'm not going to, but feel free
Relnotes:	yes
2019-11-16 16:39:08 +00:00
Hans Petter Selasky
ae9a8ec99f Correct MR length field to be 64-bit in ibcore.
Linux commit:
edd31551148c09608feee6b8756ad148d550ee3b

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-11-15 11:45:14 +00:00
Conrad Meyer
51ee1719f9 zstd: Add an Xlist and document use during import
No functional change.
2019-11-06 06:50:02 +00:00
Mark Johnston
50b5a6cc0a Downgrade the firmware images imported in r354201.
Version 43 requires further modifications to iwm(4), and this was not
caught in some initial testing.  Version 34 works and is the version
available on Intel's web site.

MFC with:	r354201
Sponsored by:	The FreeBSD Foundation
2019-11-03 03:23:27 +00:00
Marcin Wojtas
d17b7d87ee Introduce NETMAP support in ENA
Mock implementation of NETMAP routines is located in ena_netmap.c/.h
files. All code is protected under the DEV_NETMAP macro. Makefile was
updated with files and flag.

As ENA driver provide own implementations of (un)likely it must be
undefined before including NETMAP headers.

ena_netmap_attach function is called on the end of NIC attach. It fills
structure with NIC configuration and callbacks. Then provides it to
netmap_attach. Similarly netmap_detach is called during ena_detach.

Three callbacks are used.
nm_register is implemented by ena_netmap_reg. It is called when user
space application open or close NIC in NETMAP mode. Current action is
recognized based on onoff parameter: true means on and false off. As
NICs rings need to be reconfigured ena_down and ena_up are reused.
When user space application wants to receive new packets from NIC
nm_rxsync is called, and when there are new packets ready for Tx
nm_txsync is called.

Differential Revision: https://reviews.freebsd.org/D21934
Submitted by: Rafal Kozik <rk@semihalf.com>
              Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
Sponsored by:  Amazon, Inc.
2019-10-31 15:51:18 +00:00
Mark Johnston
988a7cd1a6 Add firmware images for Intel 9000-series wifi chips.
This is in preparation for adding the corresponding support to iwm(4).

Version 46 is the latest but contains unrecognized TLVs, so use version
43 for now.

Obtained from:	linux-firmware
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2019-10-30 19:36:50 +00:00
Jung-uk Kim
a009b7dcab Merge ACPICA 20191018. 2019-10-19 14:56:44 +00:00
Brandon Bergren
9f15304d32 Fix read past end of struct in ncsw glue code.
The logic in XX_IsPortalIntr() was reading past the end of XX_PInfo.
This was causing it to erroneously return 1 instead of 0 in some
circumstances, causing a panic on the AmigaOne X5000 due to mixing
exclusive and nonexclusive interrupts on the same interrupt line.

Since this code is only called a couple of times during startup, use
a simple double loop instead of the complex read-ahead single loop.

This also fixes a bug where it would never check cpu=0 on type=1.

Approved by: jhibbits (mentor)
Differential Revision: https://reviews.freebsd.org/D21988
2019-10-12 23:16:17 +00:00
Gleb Smirnoff
b8a6e03fac Widen NET_EPOCH coverage.
When epoch(9) was introduced to network stack, it was basically
dropped in place of existing locking, which was mutexes and
rwlocks. For the sake of performance mutex covered areas were
as small as possible, so became epoch covered areas.

However, epoch doesn't introduce any contention, it just delays
memory reclaim. So, there is no point to minimise epoch covered
areas in sense of performance. Meanwhile entering/exiting epoch
also has non-zero CPU usage, so doing this less often is a win.

Not the least is also code maintainability. In the new paradigm
we can assume that at any stage of processing a packet, we are
inside network epoch. This makes coding both input and output
path way easier.

On output path we already enter epoch quite early - in the
ip_output(), in the ip6_output().

This patch does the same for the input path. All ISR processing,
network related callouts, other ways of packet injection to the
network stack shall be performed in net_epoch. Any leaf function
that walks network configuration now asserts epoch.

Tricky part is configuration code paths - ioctls, sysctls. They
also call into leaf functions, so some need to be changed.

This patch would introduce more epoch recursions (see EPOCH_TRACE)
than we had before. They will be cleaned up separately, as several
of them aren't trivial. Note, that unlike a lock recursion the
epoch recursion is safe and just wastes a bit of resources.

Reviewed by:	gallatin, hselasky, cy, adrian, kristof
Differential Revision:	https://reviews.freebsd.org/D19111
2019-10-07 22:40:05 +00:00
Cy Schubert
289850db1c Add missing definition in DEBUG code.
MFC after:	3 days
2019-10-04 22:10:38 +00:00
Hans Petter Selasky
e8f206cc60 Notify all sleeping threads of device removal in krping.
Implement d_purge for krping_cdevsw.

Submitted by:	slavash@
MFC after:	3 days
Sponsored by:	Mellanox Technologies
2019-10-02 09:03:48 +00:00
Justin Hibbits
4f0796edf8 dpaa(4): Fix memcpy size for threshold copy in NCSW contrib
On 64-bit platforms uintptr_t makes the copy twice as large as it should be.
This code isn't actually used in FreeBSD, since it's for guest mode only,
not hypervisor mode, but fixing it for completeness sake.

Reported by:	bdragon (clang9 build)
2019-09-28 02:49:46 +00:00
Cy Schubert
d096bd7911 ipf mistakenly regards UDP packets with a checksum of 0xffff as bad.
Obtained from:	NetBSD fil.c r1.30, NetBSD PR/54443
MFC after:	3 days
2019-09-26 03:09:42 +00:00
Kyle Evans
da0a7834ac octeon-sdk: suppress another set of warnings under clang
Clang sees this construct and warns that adding an int to a string like this
does not concatenate the two. Fortunately, this is not what octeon-sdk
actually intended to do, so we take the path towards remediation that clang
offers: use array indexing instead.
2019-09-22 18:32:05 +00:00
Mark Johnston
fee2a2fa39 Change synchonization rules for vm_page reference counting.
There are several mechanisms by which a vm_page reference is held,
preventing the page from being freed back to the page allocator.  In
particular, holding the page's object lock is sufficient to prevent the
page from being freed; holding the busy lock or a wiring is sufficent as
well.  These references are protected by the page lock, which must
therefore be acquired for many per-page operations.  This results in
false sharing since the page locks are external to the vm_page
structures themselves and each lock protects multiple structures.

Transition to using an atomically updated per-page reference counter.
The object's reference is counted using a flag bit in the counter.  A
second flag bit is used to atomically block new references via
pmap_extract_and_hold() while removing managed mappings of a page.
Thus, the reference count of a page is guaranteed not to increase if the
page is unbusied, unmapped, and the object's write lock is held.  As
a consequence of this, the page lock no longer protects a page's
identity; operations which move pages between objects are now
synchronized solely by the objects' locks.

The vm_page_wire() and vm_page_unwire() KPIs are changed.  The former
requires that either the object lock or the busy lock is held.  The
latter no longer has a return value and may free the page if it releases
the last reference to that page.  vm_page_unwire_noq() behaves the same
as before; the caller is responsible for checking its return value and
freeing or enqueuing the page as appropriate.  vm_page_wire_mapped() is
introduced for use in pmap_extract_and_hold().  It fails if the page is
concurrently being unmapped, typically triggering a fallback to the
fault handler.  vm_page_wire() no longer requires the page lock and
vm_page_unwire() now internally acquires the page lock when releasing
the last wiring of a page (since the page lock still protects a page's
queue state).  In particular, synchronization details are no longer
leaked into the caller.

The change excises the page lock from several frequently executed code
paths.  In particular, vm_object_terminate() no longer bounces between
page locks as it releases an object's pages, and direct I/O and
sendfile(SF_NOCACHE) completions no longer require the page lock.  In
these latter cases we now get linear scalability in the common scenario
where different threads are operating on different files.

__FreeBSD_version is bumped.  The DRM ports have been updated to
accomodate the KPI changes.

Reviewed by:	jeff (earlier version)
Tested by:	gallatin (earlier version), pho
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D20486
2019-09-09 21:32:42 +00:00
Cy Schubert
d8deeff04d Document ipf_nat_hashtab_add() return codes.
MFC after:	3 days
2019-08-28 04:55:17 +00:00
Cy Schubert
d49ffa7664 Destroy the mutex in case of error.
Obtained from:	NetBSD ip_nat.c r1.7
MFC after:	3 days
2019-08-28 04:55:03 +00:00
Cy Schubert
6d7534d8ea Fixup typo in comment.
Obtained from:	NetBSD ip_nat.c r1.7
MFC after:	3 days
2019-08-28 04:54:26 +00:00
Xin LI
110f229794 MFV r351500: Fix CLEAR_HASH macro to be usable as a single statement.
MFC after:	2 weeks
2019-08-26 00:46:39 +00:00
Cy Schubert
4d93130daf Specifying array sizes for fully initialized tables at compile time is
redundant.

MFC after:	1 week
2019-08-22 03:33:10 +00:00
Bjoern A. Zeeb
e303ee524e athhal: disable unused function (big endian only)
Disable ar9300_swap_tx_desc() for the moment.  It is an unused
function only tried to compile on big endian systems.

Found by:	s390x buildkernel
MFC after:	3 months
2019-08-21 10:42:31 +00:00
Justin Hibbits
aef13f050c dpaa: Fix warnings in dtsec(4) found by clang
These are all trivial warnings that have no real functional change.
2019-08-21 02:26:22 +00:00
Jung-uk Kim
37d7a5bcc0 MFV: r351091
Fix the reported boot failures and revert r350510.

Note this commit is effectively merging ACPICA 20190703 again and applying
an upstream patch.

https://github.com/acpica/acpica/commit/73f6372

Tested by:	scottl
2019-08-15 17:43:36 +00:00
Jung-uk Kim
d632f88e20 Enable ACPICA mutex debugging in INVARIANTS case.
This lets us detect lock order reversal in ACPICA code to avoid deadlock.
2019-08-15 16:04:22 +00:00
Cy Schubert
263a6508a3 Initialize the frentry (the control block that defines a rule) checksum
to zero. Matching checksums save time and effort by mitigating the need
for full rule compare.

MFC after:	3 days
2019-08-12 02:42:47 +00:00
Cy Schubert
fa99b3234a Calculate the number interface array elements using the new FR_NUM macro
instead of the hard-coded value of 4. This is a precursor to increasing
the number of interfaces speficied in "on {interface, ..., interface}".
Note that though this feature is coded in ipf_y.y, it is partially
supported in the ipfilter kld, meaning it does not work yet (and is yet
to be documented in ipf.5 too).

MFC after:	2 weeks
2019-08-11 23:54:52 +00:00
Cy Schubert
fef510763d r272552 applied the patch from ipfilter upstream fil.c r1.129 to fix
broken ipfilter rule matches (upstream bug #554). The upstream patch
was incomplete, it resolved all but one rule compare issue. The issue
fixed here is when "{to, reply-to, dup-to} interface" are used in
conjuncion with "on interface". The match was only made if the on keyword
was specified in the same order in each case referencing the same rule.
This commit fixes this.

The reason for this is that interface name strings and comment keyword
comments are stored in a a variable length field starting at fr_names
in the frentry struct. These strings are placed into this variable length
in the order they are encountered by ipf_y.y and indexed through index
pointers in fr_ifnames, fr_comment or one of the frdest struct fd_name
fields. (Three frdest structs are within frentry.) Order matters and
this patch takes this into account.

While in here it was discovered that though ipfilter is designed to
support multiple interface specifiations per rule (up to four), this
undocumented (the man page makes no mention of it) feature does not work.
A todo is to fix the multiple interfaces feature at a later date. To
understand the design decision as to why only four were intended, it is
suspected that the decision was made because Sun workstations and PCs
rarely if ever exceeded four NICs at the time, this is not true in 2019.

PR:		238796
Reported by:	WHR <msl0000023508@gmail.com>
MFC after:	2 weeks
2019-08-11 23:54:49 +00:00
Warner Losh
5e34c4c505 Stopgap fix for gcc platforms.
Our in-tree gcc doesn't have a no-tree-vectorize optimization knob, so we get a
warning that it's unused. This causes the build to fail on all our gcc platforms.
Add a quick version check as a stop-gap measure to get CI building again.
2019-08-08 20:09:36 +00:00
Conrad Meyer
4d3f1eafc9 Update to Zstandard 1.4.2
The full release notes for 1.4.1 (skipped) and 1.4.2 can be found on Github:

  https://github.com/facebook/zstd/releases/tag/v1.4.1
  https://github.com/facebook/zstd/releases/tag/v1.4.2

These are mostly minor updates; 1.4.1 purportedly brings something like 7%
faster decompression speed.

Relnotes:	yes
2019-08-08 16:54:22 +00:00
Xin LI
a15cb219c6 Expose zlib's utility functions in Z_SOLO library when building kernel.
This allows kernel code to reuse zlib's implementation.

PR:		229763
Reviewed by:	Yoshihiro Ota <ota j email ne jp>
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D21156
2019-08-07 01:41:17 +00:00
Cy Schubert
a1601073bf Resolve ipfilter kld unload issues related to VNET jails.
When the ipfilter kld is loaded, used within VNET jail, and unloaded,
then subsequent loading, use, and unloading of another packet filters
will cause the subsequently loaded netpfil kld's to panic.

The scenario is as follows:

cd /usr/tests/sys/netpfil/common

kldunload ipl
kldunload pfsync
kldunload ipfw

kyua test pass_block

kldload ipl
kyua test pass_block
kldunload ipl

kldload pfsync
kyua test pass_block
kldunload pfsync
-- page fault panic occurs here --

Reported by:	"Ahsan Barkati" <ahsanbarkati@g.....com> via kp@
Discussed with:	kp@
Tested by:	kp@
MFC after:	3 days
2019-08-04 12:47:38 +00:00