]> granicus.if.org Git - zfs/commitdiff
OpenZFS restructuring - move platform specific headers
authorMatthew Macy <mmacy@mattmacy.io>
Thu, 5 Sep 2019 16:34:54 +0000 (09:34 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 5 Sep 2019 16:34:54 +0000 (09:34 -0700)
Move platform specific Linux headers under include/os/linux/.
Update the build system accordingly to detect the platform.
This lays some of the initial groundwork to supporting building
for other platforms.

As part of this change it was necessary to create both a user
and kernel space sys/simd.h header which can be included in
either context.  No functional change, the source has been
refactored and the relevant #include's updated.

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Signed-off-by: Matthew Macy <mmacy@FreeBSD.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #9198

116 files changed:
config/always-system.m4 [new file with mode: 0644]
config/zfs-build.m4
configure.ac
copy-builtin
include/.gitignore
include/Makefile.am
include/linux/Makefile.am [deleted file]
include/os/Makefile.am [new file with mode: 0644]
include/os/linux/Makefile.am [new file with mode: 0644]
include/os/linux/kernel/Makefile.am [new file with mode: 0644]
include/os/linux/kernel/linux/Makefile.am [new file with mode: 0644]
include/os/linux/kernel/linux/blkdev_compat.h [moved from include/linux/blkdev_compat.h with 100% similarity]
include/os/linux/kernel/linux/compiler_compat.h [moved from include/linux/compiler_compat.h with 100% similarity]
include/os/linux/kernel/linux/dcache_compat.h [moved from include/linux/dcache_compat.h with 100% similarity]
include/os/linux/kernel/linux/kmap_compat.h [moved from include/linux/kmap_compat.h with 100% similarity]
include/os/linux/kernel/linux/mod_compat.h [moved from include/linux/mod_compat.h with 100% similarity]
include/os/linux/kernel/linux/page_compat.h [moved from include/linux/page_compat.h with 100% similarity]
include/os/linux/kernel/linux/simd.h [moved from include/linux/simd.h with 92% similarity]
include/os/linux/kernel/linux/simd_aarch64.h [moved from include/linux/simd_aarch64.h with 79% similarity]
include/os/linux/kernel/linux/simd_x86.h [moved from include/linux/simd_x86.h with 59% similarity]
include/os/linux/kernel/linux/utsname_compat.h [moved from include/linux/utsname_compat.h with 100% similarity]
include/os/linux/kernel/linux/vfs_compat.h [moved from include/linux/vfs_compat.h with 100% similarity]
include/os/linux/kernel/linux/xattr_compat.h [moved from include/linux/xattr_compat.h with 100% similarity]
include/os/linux/spl/Makefile.am [moved from include/spl/Makefile.am with 100% similarity]
include/os/linux/spl/rpc/Makefile.am [moved from include/spl/rpc/Makefile.am with 72% similarity]
include/os/linux/spl/rpc/xdr.h [moved from include/spl/rpc/xdr.h with 100% similarity]
include/os/linux/spl/sys/Makefile.am [new file with mode: 0644]
include/os/linux/spl/sys/acl.h [moved from include/spl/sys/acl.h with 100% similarity]
include/os/linux/spl/sys/atomic.h [moved from include/spl/sys/atomic.h with 100% similarity]
include/os/linux/spl/sys/byteorder.h [moved from include/spl/sys/byteorder.h with 100% similarity]
include/os/linux/spl/sys/callb.h [moved from include/spl/sys/callb.h with 100% similarity]
include/os/linux/spl/sys/callo.h [moved from include/spl/sys/callo.h with 100% similarity]
include/os/linux/spl/sys/cmn_err.h [moved from include/spl/sys/cmn_err.h with 100% similarity]
include/os/linux/spl/sys/condvar.h [moved from include/spl/sys/condvar.h with 100% similarity]
include/os/linux/spl/sys/console.h [moved from include/spl/sys/console.h with 100% similarity]
include/os/linux/spl/sys/cred.h [moved from include/spl/sys/cred.h with 100% similarity]
include/os/linux/spl/sys/ctype.h [moved from include/spl/sys/ctype.h with 100% similarity]
include/os/linux/spl/sys/debug.h [moved from include/spl/sys/debug.h with 100% similarity]
include/os/linux/spl/sys/disp.h [moved from include/spl/sys/disp.h with 100% similarity]
include/os/linux/spl/sys/dkio.h [moved from include/spl/sys/dkio.h with 100% similarity]
include/os/linux/spl/sys/errno.h [moved from include/spl/sys/errno.h with 100% similarity]
include/os/linux/spl/sys/fcntl.h [moved from include/spl/sys/fcntl.h with 100% similarity]
include/os/linux/spl/sys/file.h [moved from include/spl/sys/file.h with 100% similarity]
include/os/linux/spl/sys/inttypes.h [moved from include/spl/sys/inttypes.h with 100% similarity]
include/os/linux/spl/sys/isa_defs.h [moved from include/spl/sys/isa_defs.h with 100% similarity]
include/os/linux/spl/sys/kmem.h [moved from include/spl/sys/kmem.h with 100% similarity]
include/os/linux/spl/sys/kmem_cache.h [moved from include/spl/sys/kmem_cache.h with 100% similarity]
include/os/linux/spl/sys/kobj.h [moved from include/spl/sys/kobj.h with 100% similarity]
include/os/linux/spl/sys/kstat.h [moved from include/spl/sys/kstat.h with 100% similarity]
include/os/linux/spl/sys/list.h [moved from include/spl/sys/list.h with 100% similarity]
include/os/linux/spl/sys/mode.h [moved from include/spl/sys/mode.h with 100% similarity]
include/os/linux/spl/sys/mutex.h [moved from include/spl/sys/mutex.h with 100% similarity]
include/os/linux/spl/sys/param.h [moved from include/spl/sys/param.h with 100% similarity]
include/os/linux/spl/sys/proc.h [moved from include/spl/sys/proc.h with 100% similarity]
include/os/linux/spl/sys/processor.h [moved from include/spl/sys/processor.h with 100% similarity]
include/os/linux/spl/sys/procfs_list.h [moved from include/spl/sys/procfs_list.h with 100% similarity]
include/os/linux/spl/sys/random.h [moved from include/spl/sys/random.h with 100% similarity]
include/os/linux/spl/sys/rwlock.h [moved from include/spl/sys/rwlock.h with 100% similarity]
include/os/linux/spl/sys/shrinker.h [moved from include/spl/sys/shrinker.h with 100% similarity]
include/os/linux/spl/sys/sid.h [moved from include/spl/sys/sid.h with 100% similarity]
include/os/linux/spl/sys/signal.h [moved from include/spl/sys/signal.h with 100% similarity]
include/os/linux/spl/sys/simd.h [new file with mode: 0644]
include/os/linux/spl/sys/stat.h [moved from include/spl/sys/stat.h with 100% similarity]
include/os/linux/spl/sys/strings.h [moved from include/spl/sys/strings.h with 100% similarity]
include/os/linux/spl/sys/sunddi.h [moved from include/spl/sys/sunddi.h with 100% similarity]
include/os/linux/spl/sys/sysmacros.h [moved from include/spl/sys/sysmacros.h with 100% similarity]
include/os/linux/spl/sys/systeminfo.h [moved from include/spl/sys/systeminfo.h with 100% similarity]
include/os/linux/spl/sys/taskq.h [moved from include/spl/sys/taskq.h with 100% similarity]
include/os/linux/spl/sys/thread.h [moved from include/spl/sys/thread.h with 100% similarity]
include/os/linux/spl/sys/time.h [moved from include/spl/sys/time.h with 100% similarity]
include/os/linux/spl/sys/timer.h [moved from include/spl/sys/timer.h with 100% similarity]
include/os/linux/spl/sys/tsd.h [moved from include/spl/sys/tsd.h with 100% similarity]
include/os/linux/spl/sys/types.h [moved from include/spl/sys/types.h with 100% similarity]
include/os/linux/spl/sys/types32.h [moved from include/spl/sys/types32.h with 100% similarity]
include/os/linux/spl/sys/uio.h [moved from include/spl/sys/uio.h with 100% similarity]
include/os/linux/spl/sys/user.h [moved from include/spl/sys/user.h with 100% similarity]
include/os/linux/spl/sys/vfs.h [moved from include/spl/sys/vfs.h with 100% similarity]
include/os/linux/spl/sys/vmem.h [moved from include/spl/sys/vmem.h with 100% similarity]
include/os/linux/spl/sys/vmsystm.h [moved from include/spl/sys/vmsystm.h with 100% similarity]
include/os/linux/spl/sys/vnode.h [moved from include/spl/sys/vnode.h with 100% similarity]
include/os/linux/spl/sys/wait.h [moved from include/spl/sys/wait.h with 100% similarity]
include/os/linux/spl/sys/zmod.h [moved from include/spl/sys/zmod.h with 100% similarity]
include/os/linux/spl/sys/zone.h [moved from include/spl/sys/zone.h with 100% similarity]
include/os/linux/zfs/Makefile.am [new file with mode: 0644]
include/os/linux/zfs/sys/Makefile.am [new file with mode: 0644]
include/os/linux/zfs/sys/policy.h [moved from include/sys/policy.h with 100% similarity]
include/os/linux/zfs/sys/zfs_ctldir.h [moved from include/sys/zfs_ctldir.h with 100% similarity]
include/os/linux/zfs/sys/zfs_dir.h [moved from include/sys/zfs_dir.h with 100% similarity]
include/os/linux/zfs/sys/zfs_vfsops.h [moved from include/sys/zfs_vfsops.h with 100% similarity]
include/os/linux/zfs/sys/zfs_vnops.h [moved from include/sys/zfs_vnops.h with 100% similarity]
include/os/linux/zfs/sys/zpl.h [moved from include/sys/zpl.h with 100% similarity]
include/spl/sys/Makefile.am [deleted file]
include/sys/Makefile.am
lib/libspl/include/sys/Makefile.am
lib/libspl/include/sys/simd.h [new file with mode: 0644]
module/Makefile.in
module/icp/algs/aes/aes_impl.c
module/icp/algs/aes/aes_impl_aesni.c
module/icp/algs/aes/aes_impl_x86-64.c
module/icp/algs/modes/gcm.c
module/icp/algs/modes/gcm_pclmulqdq.c
module/icp/io/aes.c
module/spl/spl-taskq.c
module/spl/spl-thread.c
module/zcommon/zfs_fletcher.c
module/zcommon/zfs_fletcher_aarch64_neon.c
module/zcommon/zfs_fletcher_avx512.c
module/zcommon/zfs_fletcher_intel.c
module/zcommon/zfs_fletcher_sse.c
module/zfs/vdev_raidz_math.c
module/zfs/vdev_raidz_math_aarch64_neon_common.h
module/zfs/vdev_raidz_math_avx2.c
module/zfs/vdev_raidz_math_avx512bw.c
module/zfs/vdev_raidz_math_avx512f.c
module/zfs/vdev_raidz_math_sse2.c
module/zfs/vdev_raidz_math_ssse3.c

diff --git a/config/always-system.m4 b/config/always-system.m4
new file mode 100644 (file)
index 0000000..3225a52
--- /dev/null
@@ -0,0 +1,26 @@
+dnl #
+dnl # Set the target system
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_SYSTEM], [
+       AC_MSG_CHECKING([for system type ($host_os)])
+       case $host_os in
+               *linux*)
+                       AC_DEFINE([SYSTEM_LINUX], [1],
+                               [True if ZFS is to be compiled for a Linux system])
+                       ac_system="Linux"
+                       ;;
+               *freebsd*)
+                       AC_DEFINE([SYSTEM_FREEBSD], [1],
+                               [True if ZFS is to be compiled for a FreeBSD system])
+                       ac_system="FreeBSD"
+                       ;;
+               *)
+                       ac_system="unknown"
+                       ;;
+       esac
+       AC_MSG_RESULT([$ac_system])
+       AC_SUBST([ac_system])
+
+       AM_CONDITIONAL([BUILD_LINUX], [test "x$ac_system" = "xLinux"])
+       AM_CONDITIONAL([BUILD_FREEBSD], [test "x$ac_system" = "xFreeBSD"])
+])
index c2e5bb25fe2e39c78be88b72ef994bb4da0b1a67..da8cccc39314aaaa1eb1a364cc6518f268f4647d 100644 (file)
@@ -160,6 +160,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
        ZFS_AC_CONFIG_ALWAYS_CC_NO_OMIT_FRAME_POINTER
        ZFS_AC_CONFIG_ALWAYS_CC_ASAN
        ZFS_AC_CONFIG_ALWAYS_TOOLCHAIN_SIMD
+       ZFS_AC_CONFIG_ALWAYS_SYSTEM
        ZFS_AC_CONFIG_ALWAYS_ARCH
        ZFS_AC_CONFIG_ALWAYS_PYTHON
        ZFS_AC_CONFIG_ALWAYS_PYZFS
index 973ae307c36f631985f2da9ca5acabade570821d..eccc09c28a06bc81074952e059e7807ec7846397 100644 (file)
@@ -146,10 +146,15 @@ AC_CONFIG_FILES([
        module/icp/Makefile
        module/spl/Makefile
        include/Makefile
-       include/linux/Makefile
-       include/spl/Makefile
-       include/spl/rpc/Makefile
-       include/spl/sys/Makefile
+       include/os/Makefile
+       include/os/linux/Makefile
+       include/os/linux/kernel/Makefile
+       include/os/linux/kernel/linux/Makefile
+       include/os/linux/spl/Makefile
+       include/os/linux/spl/rpc/Makefile
+       include/os/linux/spl/sys/Makefile
+       include/os/linux/zfs/Makefile
+       include/os/linux/zfs/sys/Makefile
        include/sys/Makefile
        include/sys/fs/Makefile
        include/sys/fm/Makefile
index 1dcfcb961ee8025d08e0d842affb2f05da1f9edd..adb3bd544c0a4b5b2148a5b3692fc90fb0800a5d 100755 (executable)
@@ -62,7 +62,9 @@ EOF
 {
        cat <<-"EOF"
        ZFS_MODULE_CFLAGS  = -I$(srctree)/include/zfs
-       ZFS_MODULE_CFLAGS += -I$(srctree)/include/zfs/spl
+       ZFS_MODULE_CFLAGS += -I$(srctree)/include/zfs/os/linux/spl
+       ZFS_MODULE_CFLAGS += -I$(srctree)/include/zfs/os/linux/zfs
+       ZFS_MODULE_CFLAGS += -I$(srctree)/include/zfs/os/linux/kernel
        ZFS_MODULE_CFLAGS += -include $(srctree)/include/zfs/zfs_config.h
        ZFS_MODULE_CFLAGS += -std=gnu99 -Wno-declaration-after-statement
        ZFS_MODULE_CPPFLAGS  = -D_KERNEL
index e6eb2116fa295a8b7bb13de4a4bf1d253fb0dea3..416f36b9e77dc1ddf646d1f7a0a8517592556883 100644 (file)
@@ -1 +1,2 @@
 /zfs_gitrev.h
+/spl
index bac47d98d9de6f69fd7405d1912de85b2b543ef7..5b37dc765d26d50b12d5d9a8257c12518133ecb3 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = linux spl sys
+SUBDIRS = sys os
 
 COMMON_H = \
        $(top_srcdir)/include/zfeature_common.h \
diff --git a/include/linux/Makefile.am b/include/linux/Makefile.am
deleted file mode 100644 (file)
index 2455759..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-COMMON_H =
-
-KERNEL_H = \
-       $(top_srcdir)/include/linux/dcache_compat.h \
-       $(top_srcdir)/include/linux/xattr_compat.h \
-       $(top_srcdir)/include/linux/vfs_compat.h \
-       $(top_srcdir)/include/linux/blkdev_compat.h \
-       $(top_srcdir)/include/linux/utsname_compat.h \
-       $(top_srcdir)/include/linux/kmap_compat.h \
-       $(top_srcdir)/include/linux/simd.h \
-       $(top_srcdir)/include/linux/simd_x86.h \
-       $(top_srcdir)/include/linux/simd_aarch64.h \
-       $(top_srcdir)/include/linux/mod_compat.h \
-       $(top_srcdir)/include/linux/page_compat.h \
-       $(top_srcdir)/include/linux/compiler_compat.h
-
-USER_H =
-
-EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
-
-if CONFIG_USER
-libzfsdir = $(includedir)/libzfs/linux
-libzfs_HEADERS = $(COMMON_H) $(USER_H)
-endif
-
-if CONFIG_KERNEL
-kerneldir = @prefix@/src/zfs-$(VERSION)/include/linux
-kernel_HEADERS = $(COMMON_H) $(KERNEL_H)
-endif
diff --git a/include/os/Makefile.am b/include/os/Makefile.am
new file mode 100644 (file)
index 0000000..09c0bee
--- /dev/null
@@ -0,0 +1,3 @@
+if BUILD_LINUX
+SUBDIRS = linux
+endif
diff --git a/include/os/linux/Makefile.am b/include/os/linux/Makefile.am
new file mode 100644 (file)
index 0000000..605a1fc
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = kernel spl zfs
diff --git a/include/os/linux/kernel/Makefile.am b/include/os/linux/kernel/Makefile.am
new file mode 100644 (file)
index 0000000..08b2f5f
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = linux
diff --git a/include/os/linux/kernel/linux/Makefile.am b/include/os/linux/kernel/linux/Makefile.am
new file mode 100644 (file)
index 0000000..06ce7c7
--- /dev/null
@@ -0,0 +1,29 @@
+COMMON_H =
+
+KERNEL_H = \
+       $(top_srcdir)/include/os/linux/kernel/linux/dcache_compat.h \
+       $(top_srcdir)/include/os/linux/kernel/linux/xattr_compat.h \
+       $(top_srcdir)/include/os/linux/kernel/linux/vfs_compat.h \
+       $(top_srcdir)/include/os/linux/kernel/linux/blkdev_compat.h \
+       $(top_srcdir)/include/os/linux/kernel/linux/utsname_compat.h \
+       $(top_srcdir)/include/os/linux/kernel/linux/kmap_compat.h \
+       $(top_srcdir)/include/os/linux/kernel/linux/simd.h \
+       $(top_srcdir)/include/os/linux/kernel/linux/simd_x86.h \
+       $(top_srcdir)/include/os/linux/kernel/linux/simd_aarch64.h \
+       $(top_srcdir)/include/os/linux/kernel/linux/mod_compat.h \
+       $(top_srcdir)/include/os/linux/kernel/linux/page_compat.h \
+       $(top_srcdir)/include/os/linux/kernel/linux/compiler_compat.h
+
+USER_H =
+
+EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)
+
+if CONFIG_USER
+libzfsdir = $(includedir)/libzfs/linux
+libzfs_HEADERS = $(COMMON_H) $(USER_H)
+endif
+
+if CONFIG_KERNEL
+kerneldir = @prefix@/src/zfs-$(VERSION)/include/linux
+kernel_HEADERS = $(COMMON_H) $(KERNEL_H)
+endif
similarity index 92%
rename from include/linux/simd.h
rename to include/os/linux/kernel/linux/simd.h
index d2b60996a4955c97ab054201deffd593049d10af..1f6574a90e49c5b0783489d3d90bd1b7b5f64790 100644 (file)
@@ -22,8 +22,8 @@
  * Copyright (C) 2019 Lawrence Livermore National Security, LLC.
  */
 
-#ifndef _SIMD_H
-#define        _SIMD_H
+#ifndef _LINUX_SIMD_H
+#define        _LINUX_SIMD_H
 
 #if defined(__x86)
 #include <linux/simd_x86.h>
 #include <linux/simd_aarch64.h>
 #else
 
-#define        kfpu_allowed()          1
+#define        kfpu_allowed()          0
 #define        kfpu_initialize(tsk)    do {} while (0)
 #define        kfpu_begin()            do {} while (0)
 #define        kfpu_end()              do {} while (0)
 
 #endif
-#endif /* _SIMD_H */
+#endif /* _LINUX_SIMD_H */
similarity index 79%
rename from include/linux/simd_aarch64.h
rename to include/os/linux/kernel/linux/simd_aarch64.h
index b45d31c48167105df1c2943cc89708f221ee594b..ac530d920015b4c70e738a5457196f515a70dcfa 100644 (file)
  *     kfpu_end()
  */
 
-#ifndef _SIMD_AARCH64_H
-#define        _SIMD_AARCH64_H
+#ifndef _LINUX_SIMD_AARCH64_H
+#define        _LINUX_SIMD_AARCH64_H
 
 #include <sys/isa_defs.h>
 
 #if defined(__aarch64__)
 
 #include <sys/types.h>
-
-#if defined(_KERNEL)
 #include <asm/neon.h>
+
 #define        kfpu_allowed()          1
 #define        kfpu_initialize(tsk)    do {} while (0)
 #define        kfpu_begin()            kernel_neon_begin()
 #define        kfpu_end()              kernel_neon_end()
-#else
-/*
- * fpu dummy methods for userspace
- */
-#define        kfpu_allowed()          1
-#define        kfpu_initialize(tsk)    do {} while (0)
-#define        kfpu_begin()            do {} while (0)
-#define        kfpu_end()              do {} while (0)
-#endif /* defined(_KERNEL) */
 
 #endif /* __aarch64__ */
 
-#endif /* _SIMD_AARCH64_H */
+#endif /* _LINUX_SIMD_AARCH64_H */
similarity index 59%
rename from include/linux/simd_x86.h
rename to include/os/linux/kernel/linux/simd_x86.h
index edd4560981a655194c7d2f6f028f0f54df8914a7..c59ba4174d978dc1584cec6857db9bab49c2cdd9 100644 (file)
  *                     also add zfs_avx512vl_available() to feature check.
  */
 
-#ifndef _SIMD_X86_H
-#define        _SIMD_X86_H
-
-#include <sys/isa_defs.h>
+#ifndef _LINUX_SIMD_X86_H
+#define        _LINUX_SIMD_X86_H
 
 /* only for __x86 */
 #if defined(__x86)
 
 #include <sys/types.h>
-
-#if defined(_KERNEL)
 #include <asm/cpufeature.h>
-#else
-#include <cpuid.h>
-#endif
-
-#if defined(_KERNEL)
 
 /*
  * Disable the WARN_ON_FPU() macro to prevent additional dependencies
@@ -222,185 +213,9 @@ kfpu_end(void)
 }
 #endif /* defined(HAVE_KERNEL_FPU) */
 
-#else /* defined(_KERNEL) */
-/*
- * FPU dummy methods for user space.
- */
-#define        kfpu_allowed()          1
-#define        kfpu_initialize(tsk)    do {} while (0)
-#define        kfpu_begin()            do {} while (0)
-#define        kfpu_end()              do {} while (0)
-#endif /* defined(_KERNEL) */
-
-/*
- * CPUID feature tests for user-space. Linux kernel provides an interface for
- * CPU feature testing.
- */
-#if !defined(_KERNEL)
-
-/*
- * x86 registers used implicitly by CPUID
- */
-typedef enum cpuid_regs {
-       EAX = 0,
-       EBX,
-       ECX,
-       EDX,
-       CPUID_REG_CNT = 4
-} cpuid_regs_t;
-
-/*
- * List of instruction sets identified by CPUID
- */
-typedef enum cpuid_inst_sets {
-       SSE = 0,
-       SSE2,
-       SSE3,
-       SSSE3,
-       SSE4_1,
-       SSE4_2,
-       OSXSAVE,
-       AVX,
-       AVX2,
-       BMI1,
-       BMI2,
-       AVX512F,
-       AVX512CD,
-       AVX512DQ,
-       AVX512BW,
-       AVX512IFMA,
-       AVX512VBMI,
-       AVX512PF,
-       AVX512ER,
-       AVX512VL,
-       AES,
-       PCLMULQDQ
-} cpuid_inst_sets_t;
-
-/*
- * Instruction set descriptor.
- */
-typedef struct cpuid_feature_desc {
-       uint32_t leaf;          /* CPUID leaf */
-       uint32_t subleaf;       /* CPUID sub-leaf */
-       uint32_t flag;          /* bit mask of the feature */
-       cpuid_regs_t reg;       /* which CPUID return register to test */
-} cpuid_feature_desc_t;
-
-#define        _AVX512F_BIT            (1U << 16)
-#define        _AVX512CD_BIT           (_AVX512F_BIT | (1U << 28))
-#define        _AVX512DQ_BIT           (_AVX512F_BIT | (1U << 17))
-#define        _AVX512BW_BIT           (_AVX512F_BIT | (1U << 30))
-#define        _AVX512IFMA_BIT         (_AVX512F_BIT | (1U << 21))
-#define        _AVX512VBMI_BIT         (1U << 1) /* AVX512F_BIT is on another leaf  */
-#define        _AVX512PF_BIT           (_AVX512F_BIT | (1U << 26))
-#define        _AVX512ER_BIT           (_AVX512F_BIT | (1U << 27))
-#define        _AVX512VL_BIT           (1U << 31) /* if used also check other levels */
-#define        _AES_BIT                (1U << 25)
-#define        _PCLMULQDQ_BIT          (1U << 1)
-
-/*
- * Descriptions of supported instruction sets
- */
-static const cpuid_feature_desc_t cpuid_features[] = {
-       [SSE]           = {1U, 0U,      1U << 25,       EDX     },
-       [SSE2]          = {1U, 0U,      1U << 26,       EDX     },
-       [SSE3]          = {1U, 0U,      1U << 0,        ECX     },
-       [SSSE3]         = {1U, 0U,      1U << 9,        ECX     },
-       [SSE4_1]        = {1U, 0U,      1U << 19,       ECX     },
-       [SSE4_2]        = {1U, 0U,      1U << 20,       ECX     },
-       [OSXSAVE]       = {1U, 0U,      1U << 27,       ECX     },
-       [AVX]           = {1U, 0U,      1U << 28,       ECX     },
-       [AVX2]          = {7U, 0U,      1U << 5,        EBX     },
-       [BMI1]          = {7U, 0U,      1U << 3,        EBX     },
-       [BMI2]          = {7U, 0U,      1U << 8,        EBX     },
-       [AVX512F]       = {7U, 0U, _AVX512F_BIT,        EBX     },
-       [AVX512CD]      = {7U, 0U, _AVX512CD_BIT,       EBX     },
-       [AVX512DQ]      = {7U, 0U, _AVX512DQ_BIT,       EBX     },
-       [AVX512BW]      = {7U, 0U, _AVX512BW_BIT,       EBX     },
-       [AVX512IFMA]    = {7U, 0U, _AVX512IFMA_BIT,     EBX     },
-       [AVX512VBMI]    = {7U, 0U, _AVX512VBMI_BIT,     ECX     },
-       [AVX512PF]      = {7U, 0U, _AVX512PF_BIT,       EBX     },
-       [AVX512ER]      = {7U, 0U, _AVX512ER_BIT,       EBX     },
-       [AVX512VL]      = {7U, 0U, _AVX512ER_BIT,       EBX     },
-       [AES]           = {1U, 0U, _AES_BIT,            ECX     },
-       [PCLMULQDQ]     = {1U, 0U, _PCLMULQDQ_BIT,      ECX     },
-};
-
-/*
- * Check if OS supports AVX and AVX2 by checking XCR0
- * Only call this function if CPUID indicates that AVX feature is
- * supported by the CPU, otherwise it might be an illegal instruction.
- */
-static inline uint64_t
-xgetbv(uint32_t index)
-{
-       uint32_t eax, edx;
-       /* xgetbv - instruction byte code */
-       __asm__ __volatile__(".byte 0x0f; .byte 0x01; .byte 0xd0"
-           : "=a" (eax), "=d" (edx)
-           : "c" (index));
-
-       return ((((uint64_t)edx)<<32) | (uint64_t)eax);
-}
-
-/*
- * Check if CPU supports a feature
- */
-static inline boolean_t
-__cpuid_check_feature(const cpuid_feature_desc_t *desc)
-{
-       uint32_t r[CPUID_REG_CNT];
-
-       if (__get_cpuid_max(0, NULL) >= desc->leaf) {
-               /*
-                * __cpuid_count is needed to properly check
-                * for AVX2. It is a macro, so return parameters
-                * are passed by value.
-                */
-               __cpuid_count(desc->leaf, desc->subleaf,
-                   r[EAX], r[EBX], r[ECX], r[EDX]);
-               return ((r[desc->reg] & desc->flag) == desc->flag);
-       }
-       return (B_FALSE);
-}
-
-#define        CPUID_FEATURE_CHECK(name, id)                           \
-static inline boolean_t                                                \
-__cpuid_has_ ## name(void)                                     \
-{                                                              \
-       return (__cpuid_check_feature(&cpuid_features[id]));    \
-}
-
 /*
- * Define functions for user-space CPUID features testing
+ * Linux kernel provides an interface for CPU feature testing.
  */
-CPUID_FEATURE_CHECK(sse, SSE);
-CPUID_FEATURE_CHECK(sse2, SSE2);
-CPUID_FEATURE_CHECK(sse3, SSE3);
-CPUID_FEATURE_CHECK(ssse3, SSSE3);
-CPUID_FEATURE_CHECK(sse4_1, SSE4_1);
-CPUID_FEATURE_CHECK(sse4_2, SSE4_2);
-CPUID_FEATURE_CHECK(avx, AVX);
-CPUID_FEATURE_CHECK(avx2, AVX2);
-CPUID_FEATURE_CHECK(osxsave, OSXSAVE);
-CPUID_FEATURE_CHECK(bmi1, BMI1);
-CPUID_FEATURE_CHECK(bmi2, BMI2);
-CPUID_FEATURE_CHECK(avx512f, AVX512F);
-CPUID_FEATURE_CHECK(avx512cd, AVX512CD);
-CPUID_FEATURE_CHECK(avx512dq, AVX512DQ);
-CPUID_FEATURE_CHECK(avx512bw, AVX512BW);
-CPUID_FEATURE_CHECK(avx512ifma, AVX512IFMA);
-CPUID_FEATURE_CHECK(avx512vbmi, AVX512VBMI);
-CPUID_FEATURE_CHECK(avx512pf, AVX512PF);
-CPUID_FEATURE_CHECK(avx512er, AVX512ER);
-CPUID_FEATURE_CHECK(avx512vl, AVX512VL);
-CPUID_FEATURE_CHECK(aes, AES);
-CPUID_FEATURE_CHECK(pclmulqdq, PCLMULQDQ);
-
-#endif /* !defined(_KERNEL) */
-
-
 /*
  * Detect register set support
  */
@@ -410,16 +225,11 @@ __simd_state_enabled(const uint64_t state)
        boolean_t has_osxsave;
        uint64_t xcr0;
 
-#if defined(_KERNEL)
 #if defined(X86_FEATURE_OSXSAVE)
        has_osxsave = !!boot_cpu_has(X86_FEATURE_OSXSAVE);
 #else
        has_osxsave = B_FALSE;
 #endif
-#elif !defined(_KERNEL)
-       has_osxsave = __cpuid_has_osxsave();
-#endif
-
        if (!has_osxsave)
                return (B_FALSE);
 
@@ -433,18 +243,13 @@ __simd_state_enabled(const uint64_t state)
 #define        __ymm_enabled() __simd_state_enabled(_XSTATE_SSE_AVX)
 #define        __zmm_enabled() __simd_state_enabled(_XSTATE_AVX512)
 
-
 /*
  * Check if SSE instruction set is available
  */
 static inline boolean_t
 zfs_sse_available(void)
 {
-#if defined(_KERNEL)
        return (!!boot_cpu_has(X86_FEATURE_XMM));
-#elif !defined(_KERNEL)
-       return (__cpuid_has_sse());
-#endif
 }
 
 /*
@@ -453,11 +258,7 @@ zfs_sse_available(void)
 static inline boolean_t
 zfs_sse2_available(void)
 {
-#if defined(_KERNEL)
        return (!!boot_cpu_has(X86_FEATURE_XMM2));
-#elif !defined(_KERNEL)
-       return (__cpuid_has_sse2());
-#endif
 }
 
 /*
@@ -466,11 +267,7 @@ zfs_sse2_available(void)
 static inline boolean_t
 zfs_sse3_available(void)
 {
-#if defined(_KERNEL)
        return (!!boot_cpu_has(X86_FEATURE_XMM3));
-#elif !defined(_KERNEL)
-       return (__cpuid_has_sse3());
-#endif
 }
 
 /*
@@ -479,11 +276,7 @@ zfs_sse3_available(void)
 static inline boolean_t
 zfs_ssse3_available(void)
 {
-#if defined(_KERNEL)
        return (!!boot_cpu_has(X86_FEATURE_SSSE3));
-#elif !defined(_KERNEL)
-       return (__cpuid_has_ssse3());
-#endif
 }
 
 /*
@@ -492,11 +285,7 @@ zfs_ssse3_available(void)
 static inline boolean_t
 zfs_sse4_1_available(void)
 {
-#if defined(_KERNEL)
        return (!!boot_cpu_has(X86_FEATURE_XMM4_1));
-#elif !defined(_KERNEL)
-       return (__cpuid_has_sse4_1());
-#endif
 }
 
 /*
@@ -505,11 +294,7 @@ zfs_sse4_1_available(void)
 static inline boolean_t
 zfs_sse4_2_available(void)
 {
-#if defined(_KERNEL)
        return (!!boot_cpu_has(X86_FEATURE_XMM4_2));
-#elif !defined(_KERNEL)
-       return (__cpuid_has_sse4_2());
-#endif
 }
 
 /*
@@ -518,14 +303,7 @@ zfs_sse4_2_available(void)
 static inline boolean_t
 zfs_avx_available(void)
 {
-       boolean_t has_avx;
-#if defined(_KERNEL)
-       has_avx = !!boot_cpu_has(X86_FEATURE_AVX);
-#elif !defined(_KERNEL)
-       has_avx = __cpuid_has_avx();
-#endif
-
-       return (has_avx && __ymm_enabled());
+       return (boot_cpu_has(X86_FEATURE_AVX) && __ymm_enabled());
 }
 
 /*
@@ -534,14 +312,7 @@ zfs_avx_available(void)
 static inline boolean_t
 zfs_avx2_available(void)
 {
-       boolean_t has_avx2;
-#if defined(_KERNEL)
-       has_avx2 = !!boot_cpu_has(X86_FEATURE_AVX2);
-#elif !defined(_KERNEL)
-       has_avx2 = __cpuid_has_avx2();
-#endif
-
-       return (has_avx2 && __ymm_enabled());
+       return (boot_cpu_has(X86_FEATURE_AVX2) && __ymm_enabled());
 }
 
 /*
@@ -550,15 +321,11 @@ zfs_avx2_available(void)
 static inline boolean_t
 zfs_bmi1_available(void)
 {
-#if defined(_KERNEL)
 #if defined(X86_FEATURE_BMI1)
        return (!!boot_cpu_has(X86_FEATURE_BMI1));
 #else
        return (B_FALSE);
 #endif
-#elif !defined(_KERNEL)
-       return (__cpuid_has_bmi1());
-#endif
 }
 
 /*
@@ -567,15 +334,11 @@ zfs_bmi1_available(void)
 static inline boolean_t
 zfs_bmi2_available(void)
 {
-#if defined(_KERNEL)
 #if defined(X86_FEATURE_BMI2)
        return (!!boot_cpu_has(X86_FEATURE_BMI2));
 #else
        return (B_FALSE);
 #endif
-#elif !defined(_KERNEL)
-       return (__cpuid_has_bmi2());
-#endif
 }
 
 /*
@@ -584,15 +347,11 @@ zfs_bmi2_available(void)
 static inline boolean_t
 zfs_aes_available(void)
 {
-#if defined(_KERNEL)
 #if defined(X86_FEATURE_AES)
        return (!!boot_cpu_has(X86_FEATURE_AES));
 #else
        return (B_FALSE);
 #endif
-#elif !defined(_KERNEL)
-       return (__cpuid_has_aes());
-#endif
 }
 
 /*
@@ -601,15 +360,11 @@ zfs_aes_available(void)
 static inline boolean_t
 zfs_pclmulqdq_available(void)
 {
-#if defined(_KERNEL)
 #if defined(X86_FEATURE_PCLMULQDQ)
        return (!!boot_cpu_has(X86_FEATURE_PCLMULQDQ));
 #else
        return (B_FALSE);
 #endif
-#elif !defined(_KERNEL)
-       return (__cpuid_has_pclmulqdq());
-#endif
 }
 
 /*
@@ -628,187 +383,141 @@ zfs_pclmulqdq_available(void)
  * AVX512VBMI  Vector Byte Manipulation Instructions
  */
 
-
-/* Check if AVX512F instruction set is available */
+/*
+ * Check if AVX512F instruction set is available
+ */
 static inline boolean_t
 zfs_avx512f_available(void)
 {
        boolean_t has_avx512 = B_FALSE;
 
-#if defined(_KERNEL)
 #if defined(X86_FEATURE_AVX512F)
        has_avx512 = !!boot_cpu_has(X86_FEATURE_AVX512F);
-#else
-       has_avx512 = B_FALSE;
 #endif
-#elif !defined(_KERNEL)
-       has_avx512 = __cpuid_has_avx512f();
-#endif
-
        return (has_avx512 && __zmm_enabled());
 }
 
-/* Check if AVX512CD instruction set is available */
+/*
+ * Check if AVX512CD instruction set is available
+ */
 static inline boolean_t
 zfs_avx512cd_available(void)
 {
        boolean_t has_avx512 = B_FALSE;
 
-#if defined(_KERNEL)
 #if defined(X86_FEATURE_AVX512CD)
        has_avx512 = boot_cpu_has(X86_FEATURE_AVX512F) &&
            boot_cpu_has(X86_FEATURE_AVX512CD);
-#else
-       has_avx512 = B_FALSE;
-#endif
-#elif !defined(_KERNEL)
-       has_avx512 = __cpuid_has_avx512cd();
 #endif
-
        return (has_avx512 && __zmm_enabled());
 }
 
-/* Check if AVX512ER instruction set is available */
+/*
+ * Check if AVX512ER instruction set is available
+ */
 static inline boolean_t
 zfs_avx512er_available(void)
 {
        boolean_t has_avx512 = B_FALSE;
 
-#if defined(_KERNEL)
 #if defined(X86_FEATURE_AVX512ER)
        has_avx512 = boot_cpu_has(X86_FEATURE_AVX512F) &&
            boot_cpu_has(X86_FEATURE_AVX512ER);
-#else
-       has_avx512 = B_FALSE;
-#endif
-#elif !defined(_KERNEL)
-       has_avx512 = __cpuid_has_avx512er();
 #endif
-
        return (has_avx512 && __zmm_enabled());
 }
 
-/* Check if AVX512PF instruction set is available */
+/*
+ * Check if AVX512PF instruction set is available
+ */
 static inline boolean_t
 zfs_avx512pf_available(void)
 {
        boolean_t has_avx512 = B_FALSE;
 
-#if defined(_KERNEL)
 #if defined(X86_FEATURE_AVX512PF)
        has_avx512 = boot_cpu_has(X86_FEATURE_AVX512F) &&
            boot_cpu_has(X86_FEATURE_AVX512PF);
-#else
-       has_avx512 = B_FALSE;
-#endif
-#elif !defined(_KERNEL)
-       has_avx512 = __cpuid_has_avx512pf();
 #endif
-
        return (has_avx512 && __zmm_enabled());
 }
 
-/* Check if AVX512BW instruction set is available */
+/*
+ * Check if AVX512BW instruction set is available
+ */
 static inline boolean_t
 zfs_avx512bw_available(void)
 {
        boolean_t has_avx512 = B_FALSE;
 
-#if defined(_KERNEL)
 #if defined(X86_FEATURE_AVX512BW)
        has_avx512 = boot_cpu_has(X86_FEATURE_AVX512F) &&
            boot_cpu_has(X86_FEATURE_AVX512BW);
-#else
-       has_avx512 = B_FALSE;
-#endif
-#elif !defined(_KERNEL)
-       has_avx512 = __cpuid_has_avx512bw();
 #endif
 
        return (has_avx512 && __zmm_enabled());
 }
 
-/* Check if AVX512DQ instruction set is available */
+/*
+ * Check if AVX512DQ instruction set is available
+ */
 static inline boolean_t
 zfs_avx512dq_available(void)
 {
        boolean_t has_avx512 = B_FALSE;
 
-#if defined(_KERNEL)
 #if defined(X86_FEATURE_AVX512DQ)
        has_avx512 = boot_cpu_has(X86_FEATURE_AVX512F) &&
            boot_cpu_has(X86_FEATURE_AVX512DQ);
-#else
-       has_avx512 = B_FALSE;
-#endif
-#elif !defined(_KERNEL)
-       has_avx512 = __cpuid_has_avx512dq();
 #endif
-
        return (has_avx512 && __zmm_enabled());
 }
 
-/* Check if AVX512VL instruction set is available */
+/*
+ * Check if AVX512VL instruction set is available
+ */
 static inline boolean_t
 zfs_avx512vl_available(void)
 {
        boolean_t has_avx512 = B_FALSE;
 
-#if defined(_KERNEL)
 #if defined(X86_FEATURE_AVX512VL)
        has_avx512 = boot_cpu_has(X86_FEATURE_AVX512F) &&
            boot_cpu_has(X86_FEATURE_AVX512VL);
-#else
-       has_avx512 = B_FALSE;
-#endif
-#elif !defined(_KERNEL)
-       has_avx512 = __cpuid_has_avx512vl();
 #endif
-
        return (has_avx512 && __zmm_enabled());
 }
 
-/* Check if AVX512IFMA instruction set is available */
+/*
+ * Check if AVX512IFMA instruction set is available
+ */
 static inline boolean_t
 zfs_avx512ifma_available(void)
 {
        boolean_t has_avx512 = B_FALSE;
 
-#if defined(_KERNEL)
 #if defined(X86_FEATURE_AVX512IFMA)
        has_avx512 = boot_cpu_has(X86_FEATURE_AVX512F) &&
            boot_cpu_has(X86_FEATURE_AVX512IFMA);
-#else
-       has_avx512 = B_FALSE;
-#endif
-#elif !defined(_KERNEL)
-       has_avx512 = __cpuid_has_avx512ifma();
 #endif
-
        return (has_avx512 && __zmm_enabled());
 }
 
-/* Check if AVX512VBMI instruction set is available */
+/*
+ * Check if AVX512VBMI instruction set is available
+ */
 static inline boolean_t
 zfs_avx512vbmi_available(void)
 {
        boolean_t has_avx512 = B_FALSE;
 
-#if defined(_KERNEL)
 #if defined(X86_FEATURE_AVX512VBMI)
        has_avx512 = boot_cpu_has(X86_FEATURE_AVX512F) &&
            boot_cpu_has(X86_FEATURE_AVX512VBMI);
-#else
-       has_avx512 = B_FALSE;
 #endif
-#elif !defined(_KERNEL)
-       has_avx512 = __cpuid_has_avx512f() &&
-           __cpuid_has_avx512vbmi();
-#endif
-
        return (has_avx512 && __zmm_enabled());
 }
 
 #endif /* defined(__x86) */
 
-#endif /* _SIMD_X86_H */
+#endif /* _LINUX_SIMD_X86_H */
similarity index 72%
rename from include/spl/rpc/Makefile.am
rename to include/os/linux/spl/rpc/Makefile.am
index 5110cc0f0c5803d4f89a822416e585401aaea6d3..9477dd59d82a44fad9e84a91cb733fd59cbf6389 100644 (file)
@@ -1,5 +1,5 @@
 KERNEL_H = \
-       $(top_srcdir)/include/spl/rpc/xdr.h
+       $(top_srcdir)/include/os/linux/spl/rpc/xdr.h
 
 if CONFIG_KERNEL
 kerneldir = @prefix@/src/zfs-$(VERSION)/include/spl/rpc
diff --git a/include/os/linux/spl/sys/Makefile.am b/include/os/linux/spl/sys/Makefile.am
new file mode 100644 (file)
index 0000000..de2f74d
--- /dev/null
@@ -0,0 +1,62 @@
+KERNEL_H = \
+       $(top_srcdir)/include/os/linux/spl/sys/acl.h \
+       $(top_srcdir)/include/os/linux/spl/sys/atomic.h \
+       $(top_srcdir)/include/os/linux/spl/sys/byteorder.h \
+       $(top_srcdir)/include/os/linux/spl/sys/callb.h \
+       $(top_srcdir)/include/os/linux/spl/sys/callo.h \
+       $(top_srcdir)/include/os/linux/spl/sys/cmn_err.h \
+       $(top_srcdir)/include/os/linux/spl/sys/condvar.h \
+       $(top_srcdir)/include/os/linux/spl/sys/console.h \
+       $(top_srcdir)/include/os/linux/spl/sys/cred.h \
+       $(top_srcdir)/include/os/linux/spl/sys/ctype.h \
+       $(top_srcdir)/include/os/linux/spl/sys/debug.h \
+       $(top_srcdir)/include/os/linux/spl/sys/disp.h \
+       $(top_srcdir)/include/os/linux/spl/sys/dkio.h \
+       $(top_srcdir)/include/os/linux/spl/sys/errno.h \
+       $(top_srcdir)/include/os/linux/spl/sys/fcntl.h \
+       $(top_srcdir)/include/os/linux/spl/sys/file.h \
+       $(top_srcdir)/include/os/linux/spl/sys/inttypes.h \
+       $(top_srcdir)/include/os/linux/spl/sys/isa_defs.h \
+       $(top_srcdir)/include/os/linux/spl/sys/kmem_cache.h \
+       $(top_srcdir)/include/os/linux/spl/sys/kmem.h \
+       $(top_srcdir)/include/os/linux/spl/sys/kobj.h \
+       $(top_srcdir)/include/os/linux/spl/sys/kstat.h \
+       $(top_srcdir)/include/os/linux/spl/sys/list.h \
+       $(top_srcdir)/include/os/linux/spl/sys/mode.h \
+       $(top_srcdir)/include/os/linux/spl/sys/mutex.h \
+       $(top_srcdir)/include/os/linux/spl/sys/param.h \
+       $(top_srcdir)/include/os/linux/spl/sys/processor.h \
+       $(top_srcdir)/include/os/linux/spl/sys/proc.h \
+       $(top_srcdir)/include/os/linux/spl/sys/procfs_list.h \
+       $(top_srcdir)/include/os/linux/spl/sys/random.h \
+       $(top_srcdir)/include/os/linux/spl/sys/rwlock.h \
+       $(top_srcdir)/include/os/linux/spl/sys/shrinker.h \
+       $(top_srcdir)/include/os/linux/spl/sys/sid.h \
+       $(top_srcdir)/include/os/linux/spl/sys/signal.h \
+       $(top_srcdir)/include/os/linux/spl/sys/simd.h \
+       $(top_srcdir)/include/os/linux/spl/sys/stat.h \
+       $(top_srcdir)/include/os/linux/spl/sys/strings.h \
+       $(top_srcdir)/include/os/linux/spl/sys/sunddi.h \
+       $(top_srcdir)/include/os/linux/spl/sys/sysmacros.h \
+       $(top_srcdir)/include/os/linux/spl/sys/systeminfo.h \
+       $(top_srcdir)/include/os/linux/spl/sys/taskq.h \
+       $(top_srcdir)/include/os/linux/spl/sys/thread.h \
+       $(top_srcdir)/include/os/linux/spl/sys/time.h \
+       $(top_srcdir)/include/os/linux/spl/sys/timer.h \
+       $(top_srcdir)/include/os/linux/spl/sys/tsd.h \
+       $(top_srcdir)/include/os/linux/spl/sys/types32.h \
+       $(top_srcdir)/include/os/linux/spl/sys/types.h \
+       $(top_srcdir)/include/os/linux/spl/sys/uio.h \
+       $(top_srcdir)/include/os/linux/spl/sys/user.h \
+       $(top_srcdir)/include/os/linux/spl/sys/vfs.h \
+       $(top_srcdir)/include/os/linux/spl/sys/vmem.h \
+       $(top_srcdir)/include/os/linux/spl/sys/vmsystm.h \
+       $(top_srcdir)/include/os/linux/spl/sys/vnode.h \
+       $(top_srcdir)/include/os/linux/spl/sys/wait.h \
+       $(top_srcdir)/include/os/linux/spl/sys/zmod.h \
+       $(top_srcdir)/include/os/linux/spl/sys/zone.h
+
+if CONFIG_KERNEL
+kerneldir = @prefix@/src/zfs-$(VERSION)/include/spl/sys
+kernel_HEADERS = $(KERNEL_H)
+endif
diff --git a/include/os/linux/spl/sys/simd.h b/include/os/linux/spl/sys/simd.h
new file mode 100644 (file)
index 0000000..f2048d9
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ *  Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
+ *  Copyright (C) 2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Brian Behlendorf <behlendorf1@llnl.gov>.
+ *  UCRL-CODE-235197
+ *
+ *  This file is part of the SPL, Solaris Porting Layer.
+ *  For details, see <http://zfsonlinux.org/>.
+ *
+ *  The SPL is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License as published by the
+ *  Free Software Foundation; either version 2 of the License, or (at your
+ *  option) any later version.
+ *
+ *  The SPL is distributed in the hope that it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with the SPL.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _SPL_SYS_SIMD_H
+#define        _SPL_SYS_SIMD_H
+
+#include <sys/isa_defs.h>
+#include <linux/simd.h>
+
+#endif /* _SPL_SYS_SIMD_H */
diff --git a/include/os/linux/zfs/Makefile.am b/include/os/linux/zfs/Makefile.am
new file mode 100644 (file)
index 0000000..081839c
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = sys
diff --git a/include/os/linux/zfs/sys/Makefile.am b/include/os/linux/zfs/sys/Makefile.am
new file mode 100644 (file)
index 0000000..5aa87da
--- /dev/null
@@ -0,0 +1,12 @@
+KERNEL_H = \
+       $(top_srcdir)/include/os/linux/zfs/sys/policy.h \
+       $(top_srcdir)/include/os/linux/zfs/sys/zfs_ctldir.h \
+       $(top_srcdir)/include/os/linux/zfs/sys/zfs_dir.h \
+       $(top_srcdir)/include/os/linux/zfs/sys/zfs_vfsops.h \
+       $(top_srcdir)/include/os/linux/zfs/sys/zfs_vnops.h \
+       $(top_srcdir)/include/os/linux/zfs/sys/zpl.h
+
+if CONFIG_KERNEL
+kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys
+kernel_HEADERS = $(KERNEL_H)
+endif
diff --git a/include/spl/sys/Makefile.am b/include/spl/sys/Makefile.am
deleted file mode 100644 (file)
index 3b5b275..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-KERNEL_H = \
-       $(top_srcdir)/include/spl/sys/acl.h \
-       $(top_srcdir)/include/spl/sys/atomic.h \
-       $(top_srcdir)/include/spl/sys/byteorder.h \
-       $(top_srcdir)/include/spl/sys/callb.h \
-       $(top_srcdir)/include/spl/sys/callo.h \
-       $(top_srcdir)/include/spl/sys/cmn_err.h \
-       $(top_srcdir)/include/spl/sys/condvar.h \
-       $(top_srcdir)/include/spl/sys/console.h \
-       $(top_srcdir)/include/spl/sys/cred.h \
-       $(top_srcdir)/include/spl/sys/ctype.h \
-       $(top_srcdir)/include/spl/sys/debug.h \
-       $(top_srcdir)/include/spl/sys/disp.h \
-       $(top_srcdir)/include/spl/sys/dkio.h \
-       $(top_srcdir)/include/spl/sys/errno.h \
-       $(top_srcdir)/include/spl/sys/fcntl.h \
-       $(top_srcdir)/include/spl/sys/file.h \
-       $(top_srcdir)/include/spl/sys/inttypes.h \
-       $(top_srcdir)/include/spl/sys/isa_defs.h \
-       $(top_srcdir)/include/spl/sys/kmem_cache.h \
-       $(top_srcdir)/include/spl/sys/kmem.h \
-       $(top_srcdir)/include/spl/sys/kobj.h \
-       $(top_srcdir)/include/spl/sys/kstat.h \
-       $(top_srcdir)/include/spl/sys/list.h \
-       $(top_srcdir)/include/spl/sys/mode.h \
-       $(top_srcdir)/include/spl/sys/mutex.h \
-       $(top_srcdir)/include/spl/sys/param.h \
-       $(top_srcdir)/include/spl/sys/processor.h \
-       $(top_srcdir)/include/spl/sys/proc.h \
-       $(top_srcdir)/include/spl/sys/procfs_list.h \
-       $(top_srcdir)/include/spl/sys/random.h \
-       $(top_srcdir)/include/spl/sys/rwlock.h \
-       $(top_srcdir)/include/spl/sys/shrinker.h \
-       $(top_srcdir)/include/spl/sys/sid.h \
-       $(top_srcdir)/include/spl/sys/signal.h \
-       $(top_srcdir)/include/spl/sys/stat.h \
-       $(top_srcdir)/include/spl/sys/strings.h \
-       $(top_srcdir)/include/spl/sys/sunddi.h \
-       $(top_srcdir)/include/spl/sys/sysmacros.h \
-       $(top_srcdir)/include/spl/sys/systeminfo.h \
-       $(top_srcdir)/include/spl/sys/taskq.h \
-       $(top_srcdir)/include/spl/sys/thread.h \
-       $(top_srcdir)/include/spl/sys/time.h \
-       $(top_srcdir)/include/spl/sys/timer.h \
-       $(top_srcdir)/include/spl/sys/tsd.h \
-       $(top_srcdir)/include/spl/sys/types32.h \
-       $(top_srcdir)/include/spl/sys/types.h \
-       $(top_srcdir)/include/spl/sys/uio.h \
-       $(top_srcdir)/include/spl/sys/user.h \
-       $(top_srcdir)/include/spl/sys/vfs.h \
-       $(top_srcdir)/include/spl/sys/vmem.h \
-       $(top_srcdir)/include/spl/sys/vmsystm.h \
-       $(top_srcdir)/include/spl/sys/vnode.h \
-       $(top_srcdir)/include/spl/sys/wait.h \
-       $(top_srcdir)/include/spl/sys/zmod.h \
-       $(top_srcdir)/include/spl/sys/zone.h
-
-if CONFIG_KERNEL
-kerneldir = @prefix@/src/zfs-$(VERSION)/include/spl/sys
-kernel_HEADERS = $(KERNEL_H)
-endif
index c5d64f9fd4d86ecce7194b1f41116303bccae927..b3845cb95b46e27fb4a6ca52f5b8e7acffad8e25 100644 (file)
@@ -52,7 +52,6 @@ COMMON_H = \
        $(top_srcdir)/include/sys/nvpair_impl.h \
        $(top_srcdir)/include/sys/objlist.h \
        $(top_srcdir)/include/sys/pathname.h \
-       $(top_srcdir)/include/sys/policy.h \
        $(top_srcdir)/include/sys/range_tree.h \
        $(top_srcdir)/include/sys/refcount.h \
        $(top_srcdir)/include/sys/rrwlock.h \
@@ -116,10 +115,8 @@ COMMON_H = \
        $(top_srcdir)/include/sys/zfeature.h \
        $(top_srcdir)/include/sys/zfs_acl.h \
        $(top_srcdir)/include/sys/zfs_context.h \
-       $(top_srcdir)/include/sys/zfs_ctldir.h \
        $(top_srcdir)/include/sys/zfs_debug.h \
        $(top_srcdir)/include/sys/zfs_delay.h \
-       $(top_srcdir)/include/sys/zfs_dir.h \
        $(top_srcdir)/include/sys/zfs_fuid.h \
        $(top_srcdir)/include/sys/zfs_project.h \
        $(top_srcdir)/include/sys/zfs_ratelimit.h \
@@ -127,8 +124,6 @@ COMMON_H = \
        $(top_srcdir)/include/sys/zfs_sa.h \
        $(top_srcdir)/include/sys/zfs_stat.h \
        $(top_srcdir)/include/sys/zfs_sysfs.h \
-       $(top_srcdir)/include/sys/zfs_vfsops.h \
-       $(top_srcdir)/include/sys/zfs_vnops.h \
        $(top_srcdir)/include/sys/zfs_znode.h \
        $(top_srcdir)/include/sys/zil.h \
        $(top_srcdir)/include/sys/zil_impl.h \
@@ -144,7 +139,6 @@ COMMON_H = \
 KERNEL_H = \
        $(top_srcdir)/include/sys/zfs_ioctl.h \
        $(top_srcdir)/include/sys/zfs_onexit.h \
-       ${top_srcdir}/include/sys/zpl.h \
        $(top_srcdir)/include/sys/zvol.h
 
 USER_H =
index e7af317e0c6ca9078b61d5ba65f7bbbd93301416..5156e2912ca5f3b79a6f6d6a7663d34b4ced8185 100644 (file)
@@ -33,6 +33,7 @@ libspl_HEADERS = \
        $(top_srcdir)/lib/libspl/include/sys/priv.h \
        $(top_srcdir)/lib/libspl/include/sys/processor.h \
        $(top_srcdir)/lib/libspl/include/sys/signal.h \
+       $(top_srcdir)/lib/libspl/include/sys/simd.h \
        $(top_srcdir)/lib/libspl/include/sys/stack.h \
        $(top_srcdir)/lib/libspl/include/sys/stat.h \
        $(top_srcdir)/lib/libspl/include/sys/stdtypes.h \
diff --git a/lib/libspl/include/sys/simd.h b/lib/libspl/include/sys/simd.h
new file mode 100644 (file)
index 0000000..6a2b3a0
--- /dev/null
@@ -0,0 +1,448 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _LIBSPL_SYS_SIMD_H
+#define        _LIBSPL_SYS_SIMD_H
+
+#include <sys/isa_defs.h>
+#include <sys/types.h>
+
+#if defined(__x86)
+#include <cpuid.h>
+
+#define        kfpu_allowed()          1
+#define        kfpu_initialize(tsk)    do {} while (0)
+#define        kfpu_begin()            do {} while (0)
+#define        kfpu_end()              do {} while (0)
+
+/*
+ * CPUID feature tests for user-space.
+ *
+ * x86 registers used implicitly by CPUID
+ */
+typedef enum cpuid_regs {
+       EAX = 0,
+       EBX,
+       ECX,
+       EDX,
+       CPUID_REG_CNT = 4
+} cpuid_regs_t;
+
+/*
+ * List of instruction sets identified by CPUID
+ */
+typedef enum cpuid_inst_sets {
+       SSE = 0,
+       SSE2,
+       SSE3,
+       SSSE3,
+       SSE4_1,
+       SSE4_2,
+       OSXSAVE,
+       AVX,
+       AVX2,
+       BMI1,
+       BMI2,
+       AVX512F,
+       AVX512CD,
+       AVX512DQ,
+       AVX512BW,
+       AVX512IFMA,
+       AVX512VBMI,
+       AVX512PF,
+       AVX512ER,
+       AVX512VL,
+       AES,
+       PCLMULQDQ
+} cpuid_inst_sets_t;
+
+/*
+ * Instruction set descriptor.
+ */
+typedef struct cpuid_feature_desc {
+       uint32_t leaf;          /* CPUID leaf */
+       uint32_t subleaf;       /* CPUID sub-leaf */
+       uint32_t flag;          /* bit mask of the feature */
+       cpuid_regs_t reg;       /* which CPUID return register to test */
+} cpuid_feature_desc_t;
+
+#define        _AVX512F_BIT            (1U << 16)
+#define        _AVX512CD_BIT           (_AVX512F_BIT | (1U << 28))
+#define        _AVX512DQ_BIT           (_AVX512F_BIT | (1U << 17))
+#define        _AVX512BW_BIT           (_AVX512F_BIT | (1U << 30))
+#define        _AVX512IFMA_BIT         (_AVX512F_BIT | (1U << 21))
+#define        _AVX512VBMI_BIT         (1U << 1) /* AVX512F_BIT is on another leaf  */
+#define        _AVX512PF_BIT           (_AVX512F_BIT | (1U << 26))
+#define        _AVX512ER_BIT           (_AVX512F_BIT | (1U << 27))
+#define        _AVX512VL_BIT           (1U << 31) /* if used also check other levels */
+#define        _AES_BIT                (1U << 25)
+#define        _PCLMULQDQ_BIT          (1U << 1)
+
+/*
+ * Descriptions of supported instruction sets
+ */
+static const cpuid_feature_desc_t cpuid_features[] = {
+       [SSE]           = {1U, 0U,      1U << 25,       EDX     },
+       [SSE2]          = {1U, 0U,      1U << 26,       EDX     },
+       [SSE3]          = {1U, 0U,      1U << 0,        ECX     },
+       [SSSE3]         = {1U, 0U,      1U << 9,        ECX     },
+       [SSE4_1]        = {1U, 0U,      1U << 19,       ECX     },
+       [SSE4_2]        = {1U, 0U,      1U << 20,       ECX     },
+       [OSXSAVE]       = {1U, 0U,      1U << 27,       ECX     },
+       [AVX]           = {1U, 0U,      1U << 28,       ECX     },
+       [AVX2]          = {7U, 0U,      1U << 5,        EBX     },
+       [BMI1]          = {7U, 0U,      1U << 3,        EBX     },
+       [BMI2]          = {7U, 0U,      1U << 8,        EBX     },
+       [AVX512F]       = {7U, 0U, _AVX512F_BIT,        EBX     },
+       [AVX512CD]      = {7U, 0U, _AVX512CD_BIT,       EBX     },
+       [AVX512DQ]      = {7U, 0U, _AVX512DQ_BIT,       EBX     },
+       [AVX512BW]      = {7U, 0U, _AVX512BW_BIT,       EBX     },
+       [AVX512IFMA]    = {7U, 0U, _AVX512IFMA_BIT,     EBX     },
+       [AVX512VBMI]    = {7U, 0U, _AVX512VBMI_BIT,     ECX     },
+       [AVX512PF]      = {7U, 0U, _AVX512PF_BIT,       EBX     },
+       [AVX512ER]      = {7U, 0U, _AVX512ER_BIT,       EBX     },
+       [AVX512VL]      = {7U, 0U, _AVX512ER_BIT,       EBX     },
+       [AES]           = {1U, 0U, _AES_BIT,            ECX     },
+       [PCLMULQDQ]     = {1U, 0U, _PCLMULQDQ_BIT,      ECX     },
+};
+
+/*
+ * Check if OS supports AVX and AVX2 by checking XCR0
+ * Only call this function if CPUID indicates that AVX feature is
+ * supported by the CPU, otherwise it might be an illegal instruction.
+ */
+static inline uint64_t
+xgetbv(uint32_t index)
+{
+       uint32_t eax, edx;
+       /* xgetbv - instruction byte code */
+       __asm__ __volatile__(".byte 0x0f; .byte 0x01; .byte 0xd0"
+           : "=a" (eax), "=d" (edx)
+           : "c" (index));
+
+       return ((((uint64_t)edx)<<32) | (uint64_t)eax);
+}
+
+/*
+ * Check if CPU supports a feature
+ */
+static inline boolean_t
+__cpuid_check_feature(const cpuid_feature_desc_t *desc)
+{
+       uint32_t r[CPUID_REG_CNT];
+
+       if (__get_cpuid_max(0, NULL) >= desc->leaf) {
+               /*
+                * __cpuid_count is needed to properly check
+                * for AVX2. It is a macro, so return parameters
+                * are passed by value.
+                */
+               __cpuid_count(desc->leaf, desc->subleaf,
+                   r[EAX], r[EBX], r[ECX], r[EDX]);
+               return ((r[desc->reg] & desc->flag) == desc->flag);
+       }
+       return (B_FALSE);
+}
+
+#define        CPUID_FEATURE_CHECK(name, id)                           \
+static inline boolean_t                                                \
+__cpuid_has_ ## name(void)                                     \
+{                                                              \
+       return (__cpuid_check_feature(&cpuid_features[id]));    \
+}
+
+/*
+ * Define functions for user-space CPUID features testing
+ */
+CPUID_FEATURE_CHECK(sse, SSE);
+CPUID_FEATURE_CHECK(sse2, SSE2);
+CPUID_FEATURE_CHECK(sse3, SSE3);
+CPUID_FEATURE_CHECK(ssse3, SSSE3);
+CPUID_FEATURE_CHECK(sse4_1, SSE4_1);
+CPUID_FEATURE_CHECK(sse4_2, SSE4_2);
+CPUID_FEATURE_CHECK(avx, AVX);
+CPUID_FEATURE_CHECK(avx2, AVX2);
+CPUID_FEATURE_CHECK(osxsave, OSXSAVE);
+CPUID_FEATURE_CHECK(bmi1, BMI1);
+CPUID_FEATURE_CHECK(bmi2, BMI2);
+CPUID_FEATURE_CHECK(avx512f, AVX512F);
+CPUID_FEATURE_CHECK(avx512cd, AVX512CD);
+CPUID_FEATURE_CHECK(avx512dq, AVX512DQ);
+CPUID_FEATURE_CHECK(avx512bw, AVX512BW);
+CPUID_FEATURE_CHECK(avx512ifma, AVX512IFMA);
+CPUID_FEATURE_CHECK(avx512vbmi, AVX512VBMI);
+CPUID_FEATURE_CHECK(avx512pf, AVX512PF);
+CPUID_FEATURE_CHECK(avx512er, AVX512ER);
+CPUID_FEATURE_CHECK(avx512vl, AVX512VL);
+CPUID_FEATURE_CHECK(aes, AES);
+CPUID_FEATURE_CHECK(pclmulqdq, PCLMULQDQ);
+
+/*
+ * Detect register set support
+ */
+static inline boolean_t
+__simd_state_enabled(const uint64_t state)
+{
+       boolean_t has_osxsave;
+       uint64_t xcr0;
+
+       has_osxsave = __cpuid_has_osxsave();
+       if (!has_osxsave)
+               return (B_FALSE);
+
+       xcr0 = xgetbv(0);
+       return ((xcr0 & state) == state);
+}
+
+#define        _XSTATE_SSE_AVX         (0x2 | 0x4)
+#define        _XSTATE_AVX512          (0xE0 | _XSTATE_SSE_AVX)
+
+#define        __ymm_enabled()         __simd_state_enabled(_XSTATE_SSE_AVX)
+#define        __zmm_enabled()         __simd_state_enabled(_XSTATE_AVX512)
+
+/*
+ * Check if SSE instruction set is available
+ */
+static inline boolean_t
+zfs_sse_available(void)
+{
+       return (__cpuid_has_sse());
+}
+
+/*
+ * Check if SSE2 instruction set is available
+ */
+static inline boolean_t
+zfs_sse2_available(void)
+{
+       return (__cpuid_has_sse2());
+}
+
+/*
+ * Check if SSE3 instruction set is available
+ */
+static inline boolean_t
+zfs_sse3_available(void)
+{
+       return (__cpuid_has_sse3());
+}
+
+/*
+ * Check if SSSE3 instruction set is available
+ */
+static inline boolean_t
+zfs_ssse3_available(void)
+{
+       return (__cpuid_has_ssse3());
+}
+
+/*
+ * Check if SSE4.1 instruction set is available
+ */
+static inline boolean_t
+zfs_sse4_1_available(void)
+{
+       return (__cpuid_has_sse4_1());
+}
+
+/*
+ * Check if SSE4.2 instruction set is available
+ */
+static inline boolean_t
+zfs_sse4_2_available(void)
+{
+       return (__cpuid_has_sse4_2());
+}
+
+/*
+ * Check if AVX instruction set is available
+ */
+static inline boolean_t
+zfs_avx_available(void)
+{
+       return (__cpuid_has_avx() && __ymm_enabled());
+}
+
+/*
+ * Check if AVX2 instruction set is available
+ */
+static inline boolean_t
+zfs_avx2_available(void)
+{
+       return (__cpuid_has_avx2() && __ymm_enabled());
+}
+
+/*
+ * Check if BMI1 instruction set is available
+ */
+static inline boolean_t
+zfs_bmi1_available(void)
+{
+       return (__cpuid_has_bmi1());
+}
+
+/*
+ * Check if BMI2 instruction set is available
+ */
+static inline boolean_t
+zfs_bmi2_available(void)
+{
+       return (__cpuid_has_bmi2());
+}
+
+/*
+ * Check if AES instruction set is available
+ */
+static inline boolean_t
+zfs_aes_available(void)
+{
+       return (__cpuid_has_aes());
+}
+
+/*
+ * Check if PCLMULQDQ instruction set is available
+ */
+static inline boolean_t
+zfs_pclmulqdq_available(void)
+{
+       return (__cpuid_has_pclmulqdq());
+}
+
+/*
+ * AVX-512 family of instruction sets:
+ *
+ * AVX512F     Foundation
+ * AVX512CD    Conflict Detection Instructions
+ * AVX512ER    Exponential and Reciprocal Instructions
+ * AVX512PF    Prefetch Instructions
+ *
+ * AVX512BW    Byte and Word Instructions
+ * AVX512DQ    Double-word and Quadword Instructions
+ * AVX512VL    Vector Length Extensions
+ *
+ * AVX512IFMA  Integer Fused Multiply Add (Not supported by kernel 4.4)
+ * AVX512VBMI  Vector Byte Manipulation Instructions
+ */
+
+/*
+ * Check if AVX512F instruction set is available
+ */
+static inline boolean_t
+zfs_avx512f_available(void)
+{
+       return (__cpuid_has_avx512f() && __zmm_enabled());
+}
+
+/*
+ * Check if AVX512CD instruction set is available
+ */
+static inline boolean_t
+zfs_avx512cd_available(void)
+{
+       return (__cpuid_has_avx512cd() && __zmm_enabled());
+}
+
+/*
+ * Check if AVX512ER instruction set is available
+ */
+static inline boolean_t
+zfs_avx512er_available(void)
+{
+       return (__cpuid_has_avx512er() && __zmm_enabled());
+}
+
+/*
+ * Check if AVX512PF instruction set is available
+ */
+static inline boolean_t
+zfs_avx512pf_available(void)
+{
+       return (__cpuid_has_avx512pf() && __zmm_enabled());
+}
+
+/*
+ * Check if AVX512BW instruction set is available
+ */
+static inline boolean_t
+zfs_avx512bw_available(void)
+{
+       return (__cpuid_has_avx512bw() && __zmm_enabled());
+}
+
+/*
+ * Check if AVX512DQ instruction set is available
+ */
+static inline boolean_t
+zfs_avx512dq_available(void)
+{
+       return (__cpuid_has_avx512dq() && __zmm_enabled());
+}
+
+/*
+ * Check if AVX512VL instruction set is available
+ */
+static inline boolean_t
+zfs_avx512vl_available(void)
+{
+       return (__cpuid_has_avx512vl() && __zmm_enabled());
+}
+
+/*
+ * Check if AVX512IFMA instruction set is available
+ */
+static inline boolean_t
+zfs_avx512ifma_available(void)
+{
+       return (__cpuid_has_avx512ifma() && __zmm_enabled());
+}
+
+/*
+ * Check if AVX512VBMI instruction set is available
+ */
+static inline boolean_t
+zfs_avx512vbmi_available(void)
+{
+       return (__cpuid_has_avx512f() && __cpuid_has_avx512vbmi() &&
+           __zmm_enabled());
+}
+
+#elif defined(__aarch64__)
+
+#define        kfpu_allowed()          1
+#define        kfpu_initialize(tsk)    do {} while (0)
+#define        kfpu_begin()            do {} while (0)
+#define        kfpu_end()              do {} while (0)
+
+#else
+
+#define        kfpu_allowed()          0
+#define        kfpu_initialize(tsk)    do {} while (0)
+#define        kfpu_begin()            do {} while (0)
+#define        kfpu_end()              do {} while (0)
+
+#endif
+
+#endif /* _LIBSPL_SYS_SIMD_H */
index 7477dbe56509421267b63683de540626085d35eb..bf0eb101c06cf41f64e2dc2c8f6e386abd447f04 100644 (file)
@@ -12,7 +12,9 @@ INSTALL_MOD_DIR ?= extra
 ZFS_MODULE_CFLAGS += -std=gnu99 -Wno-declaration-after-statement
 ZFS_MODULE_CFLAGS += @KERNEL_DEBUG_CFLAGS@
 ZFS_MODULE_CFLAGS += -include @abs_top_builddir@/zfs_config.h
-ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/include/spl
+ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/include/os/linux/kernel
+ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/include/os/linux/spl
+ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/include/os/linux/zfs
 ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/include
 
 ZFS_MODULE_CPPFLAGS += -D_KERNEL
index 0f11f9999ff9181ca4b8f988bccd648aa9e3a774..b60b16cc01d3f3e05f0c37ef906839b71078c90c 100644 (file)
@@ -25,9 +25,9 @@
 #include <sys/zfs_context.h>
 #include <sys/crypto/icp.h>
 #include <sys/crypto/spi.h>
+#include <sys/simd.h>
 #include <modes/modes.h>
 #include <aes/aes_impl.h>
-#include <linux/simd.h>
 
 /*
  * Initialize AES encryption and decryption key schedules.
index 222c176aabab4248b74ef8d7ca6b2fa6d8f1cb1b..4b5eefd71b17f2d81796d8cfc8b35e1cd8e70af2 100644 (file)
@@ -24,7 +24,8 @@
 
 #if defined(__x86_64) && defined(HAVE_AES)
 
-#include <linux/simd_x86.h>
+#include <sys/simd.h>
+#include <sys/types.h>
 
 /* These functions are used to execute AES-NI instructions: */
 extern int rijndael_key_setup_enc_intel(uint32_t rk[],
index b4515fa22cbab61f8e88549a033f38b3ef5f5839..0ee7ee99c3cd158b1c4682ce8b9e8ba060f9c19c 100644 (file)
@@ -24,7 +24,7 @@
 
 #if defined(__x86_64)
 
-#include <linux/simd_x86.h>
+#include <sys/simd.h>
 
 /* These functions are used to execute amd64 instructions for AMD or Intel: */
 extern int rijndael_key_setup_enc_amd64(uint32_t rk[],
index 423b70e2c86b6573ade37d02421adaf7c7ee029f..1fb8e256a52b35d12425ec17842d3eaf696b362c 100644 (file)
@@ -28,8 +28,8 @@
 #include <sys/crypto/icp.h>
 #include <sys/crypto/impl.h>
 #include <sys/byteorder.h>
+#include <sys/simd.h>
 #include <modes/gcm_impl.h>
-#include <linux/simd.h>
 
 #define        GHASH(c, d, t, o) \
        xor_block((uint8_t *)(d), (uint8_t *)(c)->gcm_ghash); \
index 8a43ba33a6e5c8b73c66957fb9a5147e969efe81..05920115ce863fffee6a202958cfb966d38ace3b 100644 (file)
 
 #if defined(__x86_64) && defined(HAVE_PCLMULQDQ)
 
-#include <linux/simd_x86.h>
+#include <sys/types.h>
+#include <sys/simd.h>
 
 /* These functions are used to execute pclmulqdq based assembly methods */
 extern void gcm_mul_pclmulqdq(uint64_t *, uint64_t *, uint64_t *);
 
-
 #include <modes/gcm_impl.h>
 
 /*
index 51538bc607805c51b6ec53c3e1da1e612c87a871..4b2dbd6e170eed4e16dacd6849184fa937619ede 100644 (file)
@@ -212,8 +212,8 @@ aes_mod_init(void)
         * are run in dedicated kernel threads to allow Linux 5.0+ kernels
         * to use SIMD operations.  If for some reason this isn't possible,
         * fallback to the generic implementations.  See the comment in
-        * include/linux/simd_x86.h for additional details.  Additionally,
-        * this has the benefit of allowing them to be run in parallel.
+        * linux/simd_x86.h for additional details.  Additionally, this has
+        * the benefit of allowing them to be run in parallel.
         */
        taskqid_t aes_id = taskq_dispatch(system_taskq, aes_impl_init,
            NULL, TQ_SLEEP);
index 69d591ff74af16dfca6a3aeb581a7ace331f03da..90e1d0a4d4d045a1e57adfa0200c1eb0d058a410 100644 (file)
@@ -28,7 +28,7 @@
 #include <sys/taskq.h>
 #include <sys/kmem.h>
 #include <sys/tsd.h>
-#include <linux/simd.h>
+#include <sys/simd.h>
 
 int spl_taskq_thread_bind = 0;
 module_param(spl_taskq_thread_bind, int, 0644);
index 07e3a1bfff297f38a8ca488fbfcb153233e3b41c..29de9252a48a45a9451ca7a08cc350354281c2c9 100644 (file)
@@ -27,7 +27,7 @@
 #include <sys/thread.h>
 #include <sys/kmem.h>
 #include <sys/tsd.h>
-#include <linux/simd.h>
+#include <sys/simd.h>
 
 /*
  * Thread interfaces
index 9187a7c1ed5f27bc69fff5aa2b5c8095a46aaa6d..c14c95fa22850bd9bf596e4fad831dbe9699f0bd 100644 (file)
 #include <sys/sysmacros.h>
 #include <sys/byteorder.h>
 #include <sys/spa.h>
+#include <sys/simd.h>
 #include <sys/zio_checksum.h>
 #include <sys/zfs_context.h>
 #include <zfs_fletcher.h>
-#include <linux/simd.h>
 
 #define        FLETCHER_MIN_SIMD_SIZE  64
 
@@ -773,7 +773,7 @@ fletcher_4_init(void)
        /*
         * For 5.0 and latter Linux kernels the fletcher 4 benchmarks are
         * run in a kernel threads.  This is needed to take advantage of the
-        * SIMD functionality, see include/linux/simd_x86.h for details.
+        * SIMD functionality, see linux/simd_x86.h for details.
         */
        taskqid_t id = taskq_dispatch(system_taskq, fletcher_4_benchmark,
            NULL, TQ_SLEEP);
index 3b3c1b52b804b0d7e75ee366d20de39940699935..c95a71681584544ccdeec7d7779a91687f968b41 100644 (file)
@@ -43,7 +43,7 @@
 
 #if defined(__aarch64__)
 
-#include <linux/simd_aarch64.h>
+#include <sys/simd.h>
 #include <sys/spa_checksum.h>
 #include <sys/strings.h>
 #include <zfs_fletcher.h>
index 0d4cff21a5064b47f549786cfdfd1a2c5628675e..43806f264e5ecbabf69c8479b2b31101d6f9601e 100644 (file)
 
 #if defined(__x86_64) && defined(HAVE_AVX512F)
 
-#include <linux/simd_x86.h>
 #include <sys/byteorder.h>
 #include <sys/frame.h>
 #include <sys/spa_checksum.h>
 #include <sys/strings.h>
+#include <sys/simd.h>
 #include <zfs_fletcher.h>
 
 #define        __asm __asm__ __volatile__
index 7f12efe6d8c5c25c64eccd6484edf3065cdee511..5136a01eca5186912a1502c65e37aa8a84d10c76 100644 (file)
@@ -42,8 +42,8 @@
 
 #if defined(HAVE_AVX) && defined(HAVE_AVX2)
 
-#include <linux/simd_x86.h>
 #include <sys/spa_checksum.h>
+#include <sys/simd.h>
 #include <sys/strings.h>
 #include <zfs_fletcher.h>
 
index e6389d6e5db86d4087ae326b1f0485fcf8f6d9ec..15ce9b07ffbe984208ef30d15e7298bb97ca458d 100644 (file)
@@ -43,7 +43,7 @@
 
 #if defined(HAVE_SSE2)
 
-#include <linux/simd_x86.h>
+#include <sys/simd.h>
 #include <sys/spa_checksum.h>
 #include <sys/byteorder.h>
 #include <sys/strings.h>
index ef514e9e102a357eae9cd6fd51472011b76b6180..86d4aabdc032282042a92953fd46557cf22ac068 100644 (file)
@@ -29,7 +29,7 @@
 #include <sys/zfs_debug.h>
 #include <sys/vdev_raidz.h>
 #include <sys/vdev_raidz_impl.h>
-#include <linux/simd.h>
+#include <sys/simd.h>
 
 extern boolean_t raidz_will_scalar_work(void);
 
index 0ea2ad611c773edfba917db9b34e915c9f83fa77..5312b9094d9e885e707e613081fa5eb472e1f2d3 100644 (file)
@@ -23,7 +23,7 @@
  */
 
 #include <sys/types.h>
-#include <linux/simd_aarch64.h>
+#include <sys/simd.h>
 
 #define        __asm __asm__ __volatile__
 
index a12eb672081fb87fc7fdd0fa654fd43e7c255ef2..008e848d4c5e56cf5c116a4705fdad71e8106d07 100644 (file)
@@ -26,7 +26,7 @@
 #if defined(__x86_64) && defined(HAVE_AVX2)
 
 #include <sys/types.h>
-#include <linux/simd_x86.h>
+#include <sys/simd.h>
 
 #define        __asm __asm__ __volatile__
 
index 2f545c9ec07835655581fdfb330c4f764bf93541..38cdbedf75f3c62e15c245e8b686a386a2c7028f 100644 (file)
@@ -28,7 +28,7 @@
 #if defined(__x86_64) && defined(HAVE_AVX512BW)
 
 #include <sys/types.h>
-#include <linux/simd_x86.h>
+#include <sys/simd.h>
 
 #define        __asm __asm__ __volatile__
 
index 75af7a8eea96709cac8472e8b32cebb365e56483..adbe9b0ef185a60f7bd1e17a96b724b6826d4a9d 100644 (file)
@@ -28,7 +28,7 @@
 #if defined(__x86_64) && defined(HAVE_AVX512F)
 
 #include <sys/types.h>
-#include <linux/simd_x86.h>
+#include <sys/simd.h>
 
 #define        __asm __asm__ __volatile__
 
index 5b3a9385c9d88ff7788471c4ca84408a722a699e..70a21c10c87eaccd25a7b69f1d3f6a0b57642001 100644 (file)
@@ -27,7 +27,7 @@
 #if defined(__x86_64) && defined(HAVE_SSE2)
 
 #include <sys/types.h>
-#include <linux/simd_x86.h>
+#include <sys/simd.h>
 
 #define        __asm __asm__ __volatile__
 
index 62247cf8eb8d9093349f579081746b26c7cb384a..d5776a38a2e447aaaed9c621b8864a2c5457011a 100644 (file)
@@ -27,7 +27,7 @@
 #if defined(__x86_64) && defined(HAVE_SSSE3)
 
 #include <sys/types.h>
-#include <linux/simd_x86.h>
+#include <sys/simd.h>
 
 #define        __asm __asm__ __volatile__