AM_CONDITIONAL([SUSE], [test x$SUSE_KERNEL = xyes])
AM_CONDITIONAL([UBUNTU], [test x$UBUNTU_KERNEL = xyes])
-# Sanity check for PCLMULQDQ instruction availability
-# PCLMULQDQ instruction is a new instruction available beginning with
-# the all new Core processor family based on the 32nm microarchitecture
-# codename Westmere. So, $target_cpu = x86_64 should have this instruction
-# except MIC microarchitecture (k1om).
-AM_CONDITIONAL(HAVE_PCLMULQDQ, test x$target_cpu = "xx86_64" -a x$target_vendor != "xk1om")
-AS_IF([test x$target_cpu = "xx86_64" -a x$target_vendor != "xk1om"],
- [AC_DEFINE(HAVE_PCLMULQDQ, 1, [have PCLMULQDQ instruction])])
-
-LIBCFS_CONDITIONALS
LN_CONDITIONALS
LC_CONDITIONALS
]) # LB_CONDITIONALS
]) # LIBCFS_CONFIG_PANIC_DUMPLOG
#
-# LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
-#
-# 2.6.32-30.el6 adds a new 'walk_stack' field in 'struct stacktrace_ops'
-#
-AC_DEFUN([LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK], [
-LB_CHECK_COMPILE([if 'struct stacktrace_ops' has 'walk_stack' field],
-stacktrace_ops_walk_stack, [
- #include <asm/stacktrace.h>
-],[
- ((struct stacktrace_ops *)0)->walk_stack(NULL, NULL, 0, NULL, NULL, NULL, NULL);
-],[
- AC_DEFINE(STACKTRACE_OPS_HAVE_WALK_STACK, 1,
- ['struct stacktrace_ops' has 'walk_stack' field])
-])
-]) # LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
-
-#
-# LIBCFS_STACKTRACE_WARNING
-#
-# 3.0 removes stacktrace_ops warning* functions
-#
-AC_DEFUN([LIBCFS_STACKTRACE_WARNING], [
-LB_CHECK_COMPILE([if 'stacktrace_ops.warning' is exist],
-stacktrace_ops_warning, [
- struct task_struct;
- struct pt_regs;
- #include <asm/stacktrace.h>
-],[
- ((struct stacktrace_ops *)0)->warning(NULL, NULL);
-],[
- AC_DEFINE(HAVE_STACKTRACE_WARNING, 1,
- [stacktrace_ops.warning is exist])
-])
-]) # LIBCFS_STACKTRACE_WARNING
-
-#
-# LC_SHRINKER_WANT_SHRINK_PTR
-#
-# RHEL6/2.6.32 want to have pointer to shrinker self pointer in handler function
-#
-AC_DEFUN([LC_SHRINKER_WANT_SHRINK_PTR], [
-LB_CHECK_COMPILE([if 'shrinker' want self pointer in handler],
-shrink_self_pointer, [
- #include <linux/mm.h>
-],[
- struct shrinker *tmp = NULL;
- tmp->shrink(tmp, 0, 0);
-],[
- AC_DEFINE(HAVE_SHRINKER_WANT_SHRINK_PTR, 1,
- [shrinker want self pointer in handler])
-])
-]) # LC_SHRINKER_WANT_SHRINK_PTR
-
-#
-# LIBCFS_SYSCTL_CTLNAME
-#
-# 2.6.33 no longer has ctl_name & strategy field in struct ctl_table.
-#
-AC_DEFUN([LIBCFS_SYSCTL_CTLNAME], [
-LB_CHECK_COMPILE([if 'ctl_table' has a 'ctl_name' field],
-ctl_table_ctl_name, [
- #include <linux/sysctl.h>
-],[
- struct ctl_table ct;
- ct.ctl_name = sizeof(ct);
-],[
- AC_DEFINE(HAVE_SYSCTL_CTLNAME, 1,
- [ctl_table has ctl_name field])
-])
-]) # LIBCFS_SYSCTL_CTLNAME
-
-#
-# LIBCFS_MODULE_LOCKING
-#
-# 2.6.36 introduced locking to module params. RHEL6 lacks this support
-#
-AC_DEFUN([LIBCFS_MODULE_LOCKING],[
-LB_CHECK_COMPILE([does the kernel support module param locking],
-module_param_locking, [
- #include <linux/moduleparam.h>
-],[
- __kernel_param_lock(NULL);
- __kernel_param_unlock(NULL);
-],[
- AC_DEFINE(HAVE_MODULE_PARAM_LOCKING, 1,
- [locking module param is supported])
-])
-]) # LIBCFS_MODULE_LOCKING
-
-#
-# LIBCFS_KSTRTOUL
-#
-# 2.6.38 kstrtoul is added
-#
-AC_DEFUN([LIBCFS_KSTRTOUL], [
-LB_CHECK_COMPILE([if Linux kernel has 'kstrtoul'],
-kstrtoul, [
- #include <linux/kernel.h>
-],[
- unsigned long result;
- return kstrtoul("12345", 0, &result);
-],[
- AC_DEFINE(HAVE_KSTRTOUL, 1,
- [kernel has kstrtoul])
-])
-]) # LIBCFS_KSTRTOUL
-
-#
-# LIBCFS_DUMP_TRACE_ADDRESS
-#
-# 2.6.39 adds a base pointer address argument to dump_trace
-#
-AC_DEFUN([LIBCFS_DUMP_TRACE_ADDRESS], [
-LB_CHECK_COMPILE([if 'dump_trace' want address],
-dump_trace_address, [
- struct task_struct;
- struct pt_regs;
- #include <asm/stacktrace.h>
-],[
- dump_trace(NULL, NULL, NULL, 0, NULL, NULL);
-],[
- AC_DEFINE(HAVE_DUMP_TRACE_ADDRESS, 1,
- [dump_trace want address argument])
-])
-]) # LIBCFS_DUMP_TRACE_ADDRESS
-
-#
-# LC_SHRINK_CONTROL
-#
-# FC15 2.6.40-5 backported the "shrink_control" parameter to the memory
-# pressure shrinker from Linux 3.0
-#
-AC_DEFUN([LC_SHRINK_CONTROL], [
-LB_CHECK_COMPILE([if 'shrink_control' is present],
-shrink_control, [
- #include <linux/atomic.h>
- #include <linux/mm.h>
-],[
- struct shrink_control tmp = {0};
- tmp.nr_to_scan = sizeof(tmp);
-],[
- AC_DEFINE(HAVE_SHRINK_CONTROL, 1,
- [shrink_control is present])
-])
-]) # LC_SHRINK_CONTROL
-
-#
-# LIBCFS_PROCESS_NAMESPACE
-#
-# 3.5 introduced process namespace
-AC_DEFUN([LIBCFS_PROCESS_NAMESPACE], [
-LB_CHECK_LINUX_HEADER([linux/uidgid.h], [
- AC_DEFINE(HAVE_UIDGID_HEADER, 1,
- [uidgid.h is present])])
-]) # LIBCFS_PROCESS_NAMESPACE
-
-#
-# LIBCFS_I_UID_READ
-#
-# 3.5 added helpers to read the new uid/gid types from VFS structures
-# SLE11 SP3 has uidgid.h but not the helpers
-#
-AC_DEFUN([LIBCFS_I_UID_READ], [
-LB_CHECK_COMPILE([if 'i_uid_read' is present],
-i_uid_read, [
- #include <linux/fs.h>
-],[
- i_uid_read(NULL);
-],[
- AC_DEFINE(HAVE_I_UID_READ, 1, [i_uid_read is present])
-])
-]) # LIBCFS_I_UID_READ
-
-#
-# LIBCFS_HAVE_CRC32
-#
-AC_DEFUN([LIBCFS_HAVE_CRC32], [
-LB_CHECK_CONFIG_IM([CRC32],
- [have_crc32="yes"], [have_crc32="no"])
-AS_IF([test "x$have_crc32" = xyes],
- [AC_DEFINE(HAVE_CRC32, 1,
- [kernel compiled with CRC32 functions])])
-]) # LIBCFS_HAVE_CRC32
-
-#
-# LIBCFS_ENABLE_CRC32_ACCEL
-#
-AC_DEFUN([LIBCFS_ENABLE_CRC32_ACCEL], [
-LB_CHECK_CONFIG_IM([CRYPTO_CRC32_PCLMUL],
- [enable_crc32_crypto="no"], [enable_crc32_crypto="yes"])
-AS_IF([test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes], [
- AC_DEFINE(NEED_CRC32_ACCEL, 1, [need pclmulqdq based crc32])
- AC_MSG_WARN([No crc32 pclmulqdq crypto api found, enable internal pclmulqdq based crc32])])
-]) # LIBCFS_ENABLE_CRC32_ACCEL
-
-#
-# LIBCFS_ENABLE_CRC32C_ACCEL
-#
-AC_DEFUN([LIBCFS_ENABLE_CRC32C_ACCEL], [
-LB_CHECK_CONFIG_IM([CRYPTO_CRC32C_INTEL],
- [enable_crc32c_crypto="no"], [enable_crc32c_crypto="yes"])
-AS_IF([test "x$enable_crc32c_crypto" = xyes], [
- AC_DEFINE(NEED_CRC32C_ACCEL, 1, [need pclmulqdq based crc32c])
- AC_MSG_WARN([No crc32c pclmulqdq crypto api found, enable internal pclmulqdq based crc32c])])
-]) # LIBCFS_ENABLE_CRC32C_ACCEL
-
-#
# Kernel version 3.11 introduced ktime_get_ts64
#
AC_DEFUN([LIBCFS_KTIME_GET_TS64],[
]) # LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
#
-# Kernel version 4.2 commit df6b35f409af0a8ff1ef62f552b8402f3fef8665
-# header file i387.h was renamed to fpu/api.h
-#
-AC_DEFUN([LIBCFS_FPU_API], [
-LB_CHECK_LINUX_HEADER([asm/fpu/api.h], [
- AC_DEFINE(HAVE_FPU_API_HEADER, 1,
- [fpu/api.h is present])])
-]) # LIBCFS_FPU_API
-
-#
# Kernel version 4.4 commit ef951599074ba4fad2d0efa0a977129b41e6d203
# introduced kstrtobool and kstrtobool_from_user.
#
==============================================================================])
LIBCFS_CONFIG_PANIC_DUMPLOG
-# 2.6.32
-LIBCFS_STACKTRACE_OPS_HAVE_WALK_STACK
-LC_SHRINKER_WANT_SHRINK_PTR
-# 2.6.33
-LIBCFS_SYSCTL_CTLNAME
-# 2.6.36
-LIBCFS_MODULE_LOCKING
-# 2.6.38
-LIBCFS_KSTRTOUL
-# 2.6.39
-LIBCFS_DUMP_TRACE_ADDRESS
-# 2.6.40 fc15
-LC_SHRINK_CONTROL
-# 3.0
-LIBCFS_STACKTRACE_WARNING
-# 3.5
-LIBCFS_PROCESS_NAMESPACE
-LIBCFS_I_UID_READ
-# 3.8
-LIBCFS_HAVE_CRC32
-LIBCFS_ENABLE_CRC32_ACCEL
-# 3.10
-LIBCFS_ENABLE_CRC32C_ACCEL
# 3.11
LIBCFS_KTIME_GET_TS64
# 3.12
LIBCFS_KERNEL_PARAM_LOCK
# 4.2
LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
-LIBCFS_FPU_API
# 4.4
LIBCFS_KSTRTOBOOL_FROM_USER
# 4.5
]) # LIBCFS_CONFIGURE
#
-# LIBCFS_CONDITIONALS
-#
-AC_DEFUN([LIBCFS_CONDITIONALS], [
-AM_CONDITIONAL(HAVE_CRC32, [test "x$have_crc32" = xyes])
-AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32, [test "x$have_crc32" = xyes -a "x$enable_crc32_crypto" = xyes])
-AM_CONDITIONAL(NEED_PCLMULQDQ_CRC32C, [test "x$enable_crc32c_crypto" = xyes])
-]) # LIBCFS_CONDITIONALS
-
-#
# LIBCFS_CONFIG_FILES
#
# files that should be generated with AC_OUTPUT
*/
/**
- * Functions for start/stop shash CRC32 algorithm.
- */
-int cfs_crypto_crc32_register(void);
-void cfs_crypto_crc32_unregister(void);
-
-/**
* Functions for start/stop shash adler32 algorithm.
*/
int cfs_crypto_adler32_register(void);
void cfs_crypto_adler32_unregister(void);
-
-/**
- * Functions for start/stop shash crc32 pclmulqdq
- */
-int cfs_crypto_crc32_pclmul_register(void);
-void cfs_crypto_crc32_pclmul_unregister(void);
-
-/**
- * Functions for start/stop shash crc32c pclmulqdq
- */
-int cfs_crypto_crc32c_pclmul_register(void);
-void cfs_crypto_crc32c_pclmul_unregister(void);
/*
* Shrinker
*/
-#ifdef HAVE_SHRINK_CONTROL
# define SHRINKER_ARGS(sc, nr_to_scan, gfp_mask) \
struct shrinker *shrinker, \
struct shrink_control *sc
# define shrink_param(sc, var) ((sc)->var)
-#else
-struct shrink_control {
- gfp_t gfp_mask;
- unsigned long nr_to_scan;
-};
-# ifdef HAVE_SHRINKER_WANT_SHRINK_PTR
-# define SHRINKER_ARGS(sc, nr_to_scan, gfp_mask) \
- struct shrinker *shrinker, \
- int nr_to_scan, gfp_t gfp_mask
-# else
-# define SHRINKER_ARGS(sc, nr_to_scan, gfp_mask) \
- int nr_to_scan, gfp_t gfp_mask
-# endif
- /* avoid conflict with spl mm_compat.h */
-# define HAVE_SHRINK_CONTROL_STRUCT 1
-# define shrink_param(sc, var) (var)
-#endif
#ifdef HAVE_SHRINKER_COUNT
struct shrinker_var {
#include <linux/user_namespace.h>
#include <linux/uio.h>
-#ifdef HAVE_SYSCTL_CTLNAME
-#define INIT_CTL_NAME .ctl_name = CTL_UNNUMBERED,
-#define INIT_STRATEGY .strategy = &sysctl_intvec,
-#else
-#define INIT_CTL_NAME
-#define INIT_STRATEGY
-#endif
-
#ifndef HAVE_IOV_ITER_TYPE
#ifdef HAVE_IOV_ITER_HAS_TYPE_MEMBER
#define iter_is_iovec(iter) ((iter)->type & ITER_IOVEC)
#endif
#endif /* HAVE_IOV_ITER_TYPE */
-#ifndef HAVE_MODULE_PARAM_LOCKING
-static DEFINE_MUTEX(param_lock);
-#endif
-
-#ifndef HAVE_UIDGID_HEADER
-
-#ifndef _LINUX_UIDGID_H
-#define _LINUX_UIDGID_H
-
-typedef uid_t kuid_t;
-typedef gid_t kgid_t;
-
-#define INVALID_UID -1
-#define INVALID_GID -1
-
-#define GLOBAL_ROOT_UID 0
-#define GLOBAL_ROOT_GID 0
-
-static inline uid_t __kuid_val(kuid_t uid)
-{
- return uid;
-}
-
-static inline gid_t __kgid_val(kgid_t gid)
-{
- return gid;
-}
-
-static inline kuid_t make_kuid(struct user_namespace *from, uid_t uid)
-{
- return uid;
-}
-
-static inline kgid_t make_kgid(struct user_namespace *from, gid_t gid)
-{
- return gid;
-}
-
-static inline uid_t from_kuid(struct user_namespace *to, kuid_t uid)
-{
- return uid;
-}
-
-static inline gid_t from_kgid(struct user_namespace *to, kgid_t gid)
-{
- return gid;
-}
-
-static inline bool uid_eq(kuid_t left, kuid_t right)
-{
- return left == right;
-}
-
-static inline bool uid_valid(kuid_t uid)
-{
- return uid != (typeof(uid))INVALID_UID;
-}
-
-static inline bool gid_valid(kgid_t gid)
-{
- return gid != (typeof(gid))INVALID_GID;
-}
-#endif /* _LINUX_UIDGID_H */
-
-#endif
-
int cfs_get_environ(const char *key, char *value, int *val_len);
int cfs_kernel_write(struct file *filp, const void *buf, size_t count,
#ifndef HAVE_KERNEL_PARAM_LOCK
static inline void kernel_param_unlock(struct module *mod)
{
-#ifndef HAVE_MODULE_PARAM_LOCKING
- mutex_unlock(¶m_lock);
-#else
__kernel_param_unlock();
-#endif
}
static inline void kernel_param_lock(struct module *mod)
{
-#ifndef HAVE_MODULE_PARAM_LOCKING
- mutex_lock(¶m_lock);
-#else
__kernel_param_lock();
-#endif
}
#endif /* ! HAVE_KERNEL_PARAM_LOCK */
-#ifndef HAVE_KSTRTOUL
-static inline int kstrtoul(const char *s, unsigned int base, unsigned long *res)
-{
- char *end = (char *)s;
-
- *res = simple_strtoul(s, &end, base);
- if (end - s == 0)
- return -EINVAL;
- return 0;
-}
-#endif /* !HAVE_KSTRTOUL */
-
#ifndef HAVE_KSTRTOBOOL_FROM_USER
#define kstrtobool strtobool
libcfs-linux-objs += linux-hash.o
libcfs-linux-objs += linux-crypto.o linux-crypto-adler.o
libcfs-linux-objs += linux-wait.o
-@HAVE_CRC32_TRUE@libcfs-linux-objs += linux-crypto-crc32.o
-@HAVE_PCLMULQDQ_TRUE@@NEED_PCLMULQDQ_CRC32_TRUE@libcfs-linux-objs += linux-crypto-crc32pclmul.o crc32-pclmul_asm.o
-@HAVE_PCLMULQDQ_TRUE@@NEED_PCLMULQDQ_CRC32C_TRUE@libcfs-linux-objs += linux-crypto-crc32c-pclmul.o crc32c-pcl-intel-asm_64.o
default: all
* RHEL6 does not support any kind of locking so we have to provide
* our own
*/
-#if !defined(HAVE_MODULE_PARAM_LOCKING) && !defined(HAVE_KERNEL_PARAM_LOCK)
- kernel_param_lock(THIS_MODULE);
-#endif
if (!*((unsigned int *)kp->arg)) {
*((unsigned int *)kp->arg) = num;
-
-#if !defined(HAVE_MODULE_PARAM_LOCKING) && !defined(HAVE_KERNEL_PARAM_LOCK)
- kernel_param_unlock(THIS_MODULE);
-#endif
return 0;
}
if (!rc)
*((unsigned int *)kp->arg) = cfs_trace_get_debug_mb();
-#if !defined(HAVE_MODULE_PARAM_LOCKING) && !defined(HAVE_KERNEL_PARAM_LOCK)
- kernel_param_unlock(THIS_MODULE);
-#endif
return rc;
}
EXTRA_DIST = linux-debug.c linux-prim.c linux-tracefile.c \
linux-curproc.c linux-hash.c linux-wait.c\
- linux-crypto.c linux-crypto-crc32.c linux-crypto-adler.c\
- linux-crypto-crc32pclmul.c linux-crypto-crc32c-pclmul.c \
- crc32-pclmul_asm.S crc32c-pcl-intel-asm_64.S inst.h
+ linux-crypto.c linux-crypto-adler.c
+++ /dev/null
-/* GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see http://www.gnu.org/licenses
- *
- * Please visit http://www.xyratex.com/contact if you need additional
- * information or have any questions.
- *
- * GPL HEADER END
- */
-
-/*
- * Copyright 2012 Xyratex Technology Limited
- *
- * Using hardware provided PCLMULQDQ instruction to accelerate the CRC32
- * calculation.
- * CRC32 polynomial:0x04c11db7(BE)/0xEDB88320(LE)
- * PCLMULQDQ is a new instruction in Intel SSE4.2, the reference can be found
- * at:
- * http://www.intel.com/products/processor/manuals/
- * Intel(R) 64 and IA-32 Architectures Software Developer's Manual
- * Volume 2B: Instruction Set Reference, N-Z
- *
- * Authors: Gregory Prestas <Gregory_Prestas@us.xyratex.com>
- * Alexander Boyko <Alexander_Boyko@xyratex.com>
- */
-
-#define __ASSEMBLY__ 1
-#include "inst.h"
-
-.align 16
-/*
- * [x4*128+32 mod P(x) << 32)]' << 1 = 0x154442bd4
- * #define CONSTANT_R1 0x154442bd4LL
- *
- * [(x4*128-32 mod P(x) << 32)]' << 1 = 0x1c6e41596
- * #define CONSTANT_R2 0x1c6e41596LL
- */
-.Lconstant_R2R1:
- .octa 0x00000001c6e415960000000154442bd4
-/*
- * [(x128+32 mod P(x) << 32)]' << 1 = 0x1751997d0
- * #define CONSTANT_R3 0x1751997d0LL
- *
- * [(x128-32 mod P(x) << 32)]' << 1 = 0x0ccaa009e
- * #define CONSTANT_R4 0x0ccaa009eLL
- */
-.Lconstant_R4R3:
- .octa 0x00000000ccaa009e00000001751997d0
-/*
- * [(x64 mod P(x) << 32)]' << 1 = 0x163cd6124
- * #define CONSTANT_R5 0x163cd6124LL
- */
-.Lconstant_R5:
- .octa 0x00000000000000000000000163cd6124
-.Lconstant_mask32:
- .octa 0x000000000000000000000000FFFFFFFF
-/*
- * #define CRCPOLY_TRUE_LE_FULL 0x1DB710641LL
- *
- * Barrett Reduction constant (u64`) = u` = (x**64 / P(x))` = 0x1F7011641LL
- * #define CONSTANT_RU 0x1F7011641LL
- */
-.Lconstant_RUpoly:
- .octa 0x00000001F701164100000001DB710641
-
-#define CONSTANT %xmm0
-
-#ifdef __x86_64__
-#define BUF %rdi
-#define LEN %rsi
-#define CRC %edx
-#else
-#define BUF %eax
-#define LEN %edx
-#define CRC %ecx
-#endif
-
-.text
-/**
- * Calculate crc32
- * BUF - buffer (16 bytes aligned)
- * LEN - sizeof buffer (16 bytes aligned), LEN should be grater than 63
- * CRC - initial crc32
- * return %eax crc32
- * uint crc32_pclmul_le_16(unsigned char const *buffer,
- * size_t len, uint crc32)
- */
-.globl crc32_pclmul_le_16
-.align 4, 0x90
-crc32_pclmul_le_16:/* buffer and buffer size are 16 bytes aligned */
- movdqa (BUF), %xmm1
- movdqa 0x10(BUF), %xmm2
- movdqa 0x20(BUF), %xmm3
- movdqa 0x30(BUF), %xmm4
- movd CRC, CONSTANT
- pxor CONSTANT, %xmm1
- sub $0x40, LEN
- add $0x40, BUF
-#ifndef __x86_64__
- /* This is for position independed code(-fPIC) support for 32bit */
- call delta
-delta:
- pop %ecx
-#endif
- cmp $0x40, LEN
- jb less_64
-
-#ifdef __x86_64__
- movdqa .Lconstant_R2R1(%rip), CONSTANT
-#else
- movdqa .Lconstant_R2R1 - delta(%ecx), CONSTANT
-#endif
-
-loop_64:/* 64 bytes Full cache line folding */
- prefetchnta 0x40(BUF)
- movdqa %xmm1, %xmm5
- movdqa %xmm2, %xmm6
- movdqa %xmm3, %xmm7
-#ifdef __x86_64__
- movdqa %xmm4, %xmm8
-#endif
- PCLMULQDQ 00, CONSTANT, %xmm1
- PCLMULQDQ 00, CONSTANT, %xmm2
- PCLMULQDQ 00, CONSTANT, %xmm3
-#ifdef __x86_64__
- PCLMULQDQ 00, CONSTANT, %xmm4
-#endif
- PCLMULQDQ 0x11, CONSTANT, %xmm5
- PCLMULQDQ 0x11, CONSTANT, %xmm6
- PCLMULQDQ 0x11, CONSTANT, %xmm7
-#ifdef __x86_64__
- PCLMULQDQ 0x11, CONSTANT, %xmm8
-#endif
- pxor %xmm5, %xmm1
- pxor %xmm6, %xmm2
- pxor %xmm7, %xmm3
-#ifdef __x86_64__
- pxor %xmm8, %xmm4
-#else
- /* xmm8 unsupported for x32 */
- movdqa %xmm4, %xmm5
- PCLMULQDQ 00, CONSTANT, %xmm4
- PCLMULQDQ 0x11, CONSTANT, %xmm5
- pxor %xmm5, %xmm4
-#endif
-
- pxor (BUF), %xmm1
- pxor 0x10(BUF), %xmm2
- pxor 0x20(BUF), %xmm3
- pxor 0x30(BUF), %xmm4
-
- sub $0x40, LEN
- add $0x40, BUF
- cmp $0x40, LEN
- jge loop_64
-less_64:/* Folding cache line into 128bit */
-#ifdef __x86_64__
- movdqa .Lconstant_R4R3(%rip), CONSTANT
-#else
- movdqa .Lconstant_R4R3 - delta(%ecx), CONSTANT
-#endif
- prefetchnta (BUF)
-
- movdqa %xmm1, %xmm5
- PCLMULQDQ 0x00, CONSTANT, %xmm1
- PCLMULQDQ 0x11, CONSTANT, %xmm5
- pxor %xmm5, %xmm1
- pxor %xmm2, %xmm1
-
- movdqa %xmm1, %xmm5
- PCLMULQDQ 0x00, CONSTANT, %xmm1
- PCLMULQDQ 0x11, CONSTANT, %xmm5
- pxor %xmm5, %xmm1
- pxor %xmm3, %xmm1
-
- movdqa %xmm1, %xmm5
- PCLMULQDQ 0x00, CONSTANT, %xmm1
- PCLMULQDQ 0x11, CONSTANT, %xmm5
- pxor %xmm5, %xmm1
- pxor %xmm4, %xmm1
-
- cmp $0x10, LEN
- jb fold_64
-loop_16:/* Folding rest buffer into 128bit */
- movdqa %xmm1, %xmm5
- PCLMULQDQ 0x00, CONSTANT, %xmm1
- PCLMULQDQ 0x11, CONSTANT, %xmm5
- pxor %xmm5, %xmm1
- pxor (BUF), %xmm1
- sub $0x10, LEN
- add $0x10, BUF
- cmp $0x10, LEN
- jge loop_16
-
-fold_64:
- /* perform the last 64 bit fold, also adds 32 zeroes
- * to the input stream */
- PCLMULQDQ 0x01, %xmm1, CONSTANT /* R4 * xmm1.low */
- psrldq $0x08, %xmm1
- pxor CONSTANT, %xmm1
-
- /* final 32-bit fold */
- movdqa %xmm1, %xmm2
-#ifdef __x86_64__
- movdqa .Lconstant_R5(%rip), CONSTANT
- movdqa .Lconstant_mask32(%rip), %xmm3
-#else
- movdqa .Lconstant_R5 - delta(%ecx), CONSTANT
- movdqa .Lconstant_mask32 - delta(%ecx), %xmm3
-#endif
- psrldq $0x04, %xmm2
- pand %xmm3, %xmm1
- PCLMULQDQ 0x00, CONSTANT, %xmm1
- pxor %xmm2, %xmm1
-
- /* Finish up with the bit-reversed barrett reduction 64 ==> 32 bits */
-#ifdef __x86_64__
- movdqa .Lconstant_RUpoly(%rip), CONSTANT
-#else
- movdqa .Lconstant_RUpoly - delta(%ecx), CONSTANT
-#endif
- movdqa %xmm1, %xmm2
- pand %xmm3, %xmm1
- PCLMULQDQ 0x10, CONSTANT, %xmm1
- pand %xmm3, %xmm1
- PCLMULQDQ 0x00, CONSTANT, %xmm1
- pxor %xmm2, %xmm1
- PEXTRD 0x01, %xmm1, %eax
-
- ret
+++ /dev/null
-/*
- * Implement fast CRC32C with PCLMULQDQ instructions. (x86_64)
- *
- * The white papers on CRC32C calculations with PCLMULQDQ instruction can be
- * downloaded from:
- * http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/crc-iscsi-polynomial-crc32-instruction-paper.pdf
- * http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-paper.pdf
- *
- * Copyright (C) 2012 Intel Corporation.
- *
- * Authors:
- * Wajdi Feghali <wajdi.k.feghali@intel.com>
- * James Guilford <james.guilford@intel.com>
- * David Cote <david.m.cote@intel.com>
- * Tim Chen <tim.c.chen@linux.intel.com>
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/linkage.h>
-#include "inst.h"
-
-## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
-
-.macro LABEL prefix n
-\prefix\n\():
-.endm
-
-.macro JMPTBL_ENTRY i
-.word crc_\i - crc_array
-.endm
-
-.macro JNC_LESS_THAN j
- jnc less_than_\j
-.endm
-
-# Define threshold where buffers are considered "small" and routed to more
-# efficient "by-1" code. This "by-1" code only handles up to 255 bytes, so
-# SMALL_SIZE can be no larger than 255.
-
-#define SMALL_SIZE 200
-
-.if (SMALL_SIZE > 255)
-.error "SMALL_SIZE must be < 256"
-.endif
-
-# unsigned int crc_pcl(u8 *buffer, int len, unsigned int crc_init);
-
-ENTRY(crc_pcl)
-#define bufp %rdi
-#define bufp_dw %edi
-#define bufp_w %di
-#define bufp_b %dil
-#define bufptmp %rcx
-#define block_0 %rcx
-#define block_1 %rdx
-#define block_2 %r11
-#define len %rsi
-#define len_dw %esi
-#define len_w %si
-#define len_b %sil
-#define crc_init_arg %rdx
-#define tmp %rbx
-#define crc_init %r8
-#define crc_init_dw %r8d
-#define crc1 %r9
-#define crc2 %r10
-
- pushq %rbx
- pushq %rdi
- pushq %rsi
-
- ## Move crc_init for Linux to a different
- mov crc_init_arg, crc_init
-
- ################################################################
- ## 1) ALIGN:
- ################################################################
-
- mov bufp, bufptmp # rdi = *buf
- neg bufp
- and $7, bufp # calculate the unalignment amount of
- # the address
- je proc_block # Skip if aligned
-
- ## If len is less than 8 and we're unaligned, we need to jump
- ## to special code to avoid reading beyond the end of the buffer
- cmp $8, len
- jae do_align
- # less_than_8 expects length in upper 3 bits of len_dw
- # less_than_8_post_shl1 expects length = carryflag * 8 + len_dw[31:30]
- shl $32-3+1, len_dw
- jmp less_than_8_post_shl1
-
-do_align:
- #### Calculate CRC of unaligned bytes of the buffer (if any)
- movq (bufptmp), tmp # load a quadward from the buffer
- add bufp, bufptmp # align buffer pointer for quadword
- # processing
- sub bufp, len # update buffer length
-align_loop:
- crc32b %bl, crc_init_dw # compute crc32 of 1-byte
- shr $8, tmp # get next byte
- dec bufp
- jne align_loop
-
-proc_block:
-
- ################################################################
- ## 2) PROCESS BLOCKS:
- ################################################################
-
- ## compute num of bytes to be processed
- movq len, tmp # save num bytes in tmp
-
- cmpq $128*24, len
- jae full_block
-
-continue_block:
- cmpq $SMALL_SIZE, len
- jb small
-
- ## len < 128*24
- movq $2731, %rax # 2731 = ceil(2^16 / 24)
- mul len_dw
- shrq $16, %rax
-
- ## eax contains floor(bytes / 24) = num 24-byte chunks to do
-
- ## process rax 24-byte chunks (128 >= rax >= 0)
-
- ## compute end address of each block
- ## block 0 (base addr + RAX * 8)
- ## block 1 (base addr + RAX * 16)
- ## block 2 (base addr + RAX * 24)
- lea (bufptmp, %rax, 8), block_0
- lea (block_0, %rax, 8), block_1
- lea (block_1, %rax, 8), block_2
-
- xor crc1, crc1
- xor crc2, crc2
-
- ## branch into array
- lea jump_table(%rip), bufp
- movzxw (bufp, %rax, 2), len
- offset=crc_array-jump_table
- lea offset(bufp, len, 1), bufp
- jmp *bufp
-
- ################################################################
- ## 2a) PROCESS FULL BLOCKS:
- ################################################################
-full_block:
- movq $128,%rax
- lea 128*8*2(block_0), block_1
- lea 128*8*3(block_0), block_2
- add $128*8*1, block_0
-
- xor crc1,crc1
- xor crc2,crc2
-
- # Fall thruogh into top of crc array (crc_128)
-
- ################################################################
- ## 3) CRC Array:
- ################################################################
-
-crc_array:
- i=128
-.rept 128-1
-.altmacro
-LABEL crc_ %i
-.noaltmacro
- crc32q -i*8(block_0), crc_init
- crc32q -i*8(block_1), crc1
- crc32q -i*8(block_2), crc2
- i=(i-1)
-.endr
-
-.altmacro
-LABEL crc_ %i
-.noaltmacro
- crc32q -i*8(block_0), crc_init
- crc32q -i*8(block_1), crc1
-# SKIP crc32 -i*8(block_2), crc2 ; Don't do this one yet
-
- mov block_2, block_0
-
- ################################################################
- ## 4) Combine three results:
- ################################################################
-
- lea (K_table-16)(%rip), bufp # first entry is for idx 1
- shlq $3, %rax # rax *= 8
- subq %rax, tmp # tmp -= rax*8
- shlq $1, %rax
- subq %rax, tmp # tmp -= rax*16
- # (total tmp -= rax*24)
- addq %rax, bufp
-
- movdqa (bufp), %xmm0 # 2 consts: K1:K2
-
- movq crc_init, %xmm1 # CRC for block 1
- PCLMULQDQ 0x00,%xmm0,%xmm1 # Multiply by K2
-
- movq crc1, %xmm2 # CRC for block 2
- PCLMULQDQ 0x10, %xmm0, %xmm2 # Multiply by K1
-
- pxor %xmm2,%xmm1
- movq %xmm1, %rax
- xor -i*8(block_2), %rax
- mov crc2, crc_init
- crc32 %rax, crc_init
-
-################################################################
-## 5) Check for end:
-################################################################
-
-LABEL crc_ 0
- mov tmp, len
- cmp $128*24, tmp
- jae full_block
- cmp $24, tmp
- jae continue_block
-
-less_than_24:
- shl $32-4, len_dw # less_than_16 expects length
- # in upper 4 bits of len_dw
- jnc less_than_16
- crc32q (bufptmp), crc_init
- crc32q 8(bufptmp), crc_init
- jz do_return
- add $16, bufptmp
- # len is less than 8 if we got here
- # less_than_8 expects length in upper 3 bits of len_dw
- # less_than_8_post_shl1 expects length = carryflag * 8 + len_dw[31:30]
- shl $2, len_dw
- jmp less_than_8_post_shl1
-
- #######################################################################
- ## 6) LESS THAN 256-bytes REMAIN AT THIS POINT (8-bits of len are full)
- #######################################################################
-small:
- shl $32-8, len_dw # Prepare len_dw for less_than_256
- j=256
-.rept 5 # j = {256, 128, 64, 32, 16}
-.altmacro
-LABEL less_than_ %j # less_than_j: Length should be in
- # upper lg(j) bits of len_dw
- j=(j/2)
- shl $1, len_dw # Get next MSB
- JNC_LESS_THAN %j
-.noaltmacro
- i=0
-.rept (j/8)
- crc32q i(bufptmp), crc_init # Compute crc32 of 8-byte data
- i=i+8
-.endr
- jz do_return # Return if remaining length is zero
- add $j, bufptmp # Advance buf
-.endr
-
-less_than_8: # Length should be stored in
- # upper 3 bits of len_dw
- shl $1, len_dw
-less_than_8_post_shl1:
- jnc less_than_4
- crc32l (bufptmp), crc_init_dw # CRC of 4 bytes
- jz do_return # return if remaining data is zero
- add $4, bufptmp
-less_than_4: # Length should be stored in
- # upper 2 bits of len_dw
- shl $1, len_dw
- jnc less_than_2
- crc32w (bufptmp), crc_init_dw # CRC of 2 bytes
- jz do_return # return if remaining data is zero
- add $2, bufptmp
-less_than_2: # Length should be stored in the MSB
- # of len_dw
- shl $1, len_dw
- jnc less_than_1
- crc32b (bufptmp), crc_init_dw # CRC of 1 byte
-less_than_1: # Length should be zero
-do_return:
- movq crc_init, %rax
- popq %rsi
- popq %rdi
- popq %rbx
- ret
-
- ################################################################
- ## jump table Table is 129 entries x 2 bytes each
- ################################################################
-.align 4
-jump_table:
- i=0
-.rept 129
-.altmacro
-JMPTBL_ENTRY %i
-.noaltmacro
- i=i+1
-.endr
-
-ENDPROC(crc_pcl)
-
- ################################################################
- ## PCLMULQDQ tables
- ## Table is 128 entries x 2 quad words each
- ################################################################
-.data
-.align 64
-K_table:
- .quad 0x14cd00bd6,0x105ec76f0
- .quad 0x0ba4fc28e,0x14cd00bd6
- .quad 0x1d82c63da,0x0f20c0dfe
- .quad 0x09e4addf8,0x0ba4fc28e
- .quad 0x039d3b296,0x1384aa63a
- .quad 0x102f9b8a2,0x1d82c63da
- .quad 0x14237f5e6,0x01c291d04
- .quad 0x00d3b6092,0x09e4addf8
- .quad 0x0c96cfdc0,0x0740eef02
- .quad 0x18266e456,0x039d3b296
- .quad 0x0daece73e,0x0083a6eec
- .quad 0x0ab7aff2a,0x102f9b8a2
- .quad 0x1248ea574,0x1c1733996
- .quad 0x083348832,0x14237f5e6
- .quad 0x12c743124,0x02ad91c30
- .quad 0x0b9e02b86,0x00d3b6092
- .quad 0x018b33a4e,0x06992cea2
- .quad 0x1b331e26a,0x0c96cfdc0
- .quad 0x17d35ba46,0x07e908048
- .quad 0x1bf2e8b8a,0x18266e456
- .quad 0x1a3e0968a,0x11ed1f9d8
- .quad 0x0ce7f39f4,0x0daece73e
- .quad 0x061d82e56,0x0f1d0f55e
- .quad 0x0d270f1a2,0x0ab7aff2a
- .quad 0x1c3f5f66c,0x0a87ab8a8
- .quad 0x12ed0daac,0x1248ea574
- .quad 0x065863b64,0x08462d800
- .quad 0x11eef4f8e,0x083348832
- .quad 0x1ee54f54c,0x071d111a8
- .quad 0x0b3e32c28,0x12c743124
- .quad 0x0064f7f26,0x0ffd852c6
- .quad 0x0dd7e3b0c,0x0b9e02b86
- .quad 0x0f285651c,0x0dcb17aa4
- .quad 0x010746f3c,0x018b33a4e
- .quad 0x1c24afea4,0x0f37c5aee
- .quad 0x0271d9844,0x1b331e26a
- .quad 0x08e766a0c,0x06051d5a2
- .quad 0x093a5f730,0x17d35ba46
- .quad 0x06cb08e5c,0x11d5ca20e
- .quad 0x06b749fb2,0x1bf2e8b8a
- .quad 0x1167f94f2,0x021f3d99c
- .quad 0x0cec3662e,0x1a3e0968a
- .quad 0x19329634a,0x08f158014
- .quad 0x0e6fc4e6a,0x0ce7f39f4
- .quad 0x08227bb8a,0x1a5e82106
- .quad 0x0b0cd4768,0x061d82e56
- .quad 0x13c2b89c4,0x188815ab2
- .quad 0x0d7a4825c,0x0d270f1a2
- .quad 0x10f5ff2ba,0x105405f3e
- .quad 0x00167d312,0x1c3f5f66c
- .quad 0x0f6076544,0x0e9adf796
- .quad 0x026f6a60a,0x12ed0daac
- .quad 0x1a2adb74e,0x096638b34
- .quad 0x19d34af3a,0x065863b64
- .quad 0x049c3cc9c,0x1e50585a0
- .quad 0x068bce87a,0x11eef4f8e
- .quad 0x1524fa6c6,0x19f1c69dc
- .quad 0x16cba8aca,0x1ee54f54c
- .quad 0x042d98888,0x12913343e
- .quad 0x1329d9f7e,0x0b3e32c28
- .quad 0x1b1c69528,0x088f25a3a
- .quad 0x02178513a,0x0064f7f26
- .quad 0x0e0ac139e,0x04e36f0b0
- .quad 0x0170076fa,0x0dd7e3b0c
- .quad 0x141a1a2e2,0x0bd6f81f8
- .quad 0x16ad828b4,0x0f285651c
- .quad 0x041d17b64,0x19425cbba
- .quad 0x1fae1cc66,0x010746f3c
- .quad 0x1a75b4b00,0x18db37e8a
- .quad 0x0f872e54c,0x1c24afea4
- .quad 0x01e41e9fc,0x04c144932
- .quad 0x086d8e4d2,0x0271d9844
- .quad 0x160f7af7a,0x052148f02
- .quad 0x05bb8f1bc,0x08e766a0c
- .quad 0x0a90fd27a,0x0a3c6f37a
- .quad 0x0b3af077a,0x093a5f730
- .quad 0x04984d782,0x1d22c238e
- .quad 0x0ca6ef3ac,0x06cb08e5c
- .quad 0x0234e0b26,0x063ded06a
- .quad 0x1d88abd4a,0x06b749fb2
- .quad 0x04597456a,0x04d56973c
- .quad 0x0e9e28eb4,0x1167f94f2
- .quad 0x07b3ff57a,0x19385bf2e
- .quad 0x0c9c8b782,0x0cec3662e
- .quad 0x13a9cba9e,0x0e417f38a
- .quad 0x093e106a4,0x19329634a
- .quad 0x167001a9c,0x14e727980
- .quad 0x1ddffc5d4,0x0e6fc4e6a
- .quad 0x00df04680,0x0d104b8fc
- .quad 0x02342001e,0x08227bb8a
- .quad 0x00a2a8d7e,0x05b397730
- .quad 0x168763fa6,0x0b0cd4768
- .quad 0x1ed5a407a,0x0e78eb416
- .quad 0x0d2c3ed1a,0x13c2b89c4
- .quad 0x0995a5724,0x1641378f0
- .quad 0x19b1afbc4,0x0d7a4825c
- .quad 0x109ffedc0,0x08d96551c
- .quad 0x0f2271e60,0x10f5ff2ba
- .quad 0x00b0bf8ca,0x00bf80dd2
- .quad 0x123888b7a,0x00167d312
- .quad 0x1e888f7dc,0x18dcddd1c
- .quad 0x002ee03b2,0x0f6076544
- .quad 0x183e8d8fe,0x06a45d2b2
- .quad 0x133d7a042,0x026f6a60a
- .quad 0x116b0f50c,0x1dd3e10e8
- .quad 0x05fabe670,0x1a2adb74e
- .quad 0x130004488,0x0de87806c
- .quad 0x000bcf5f6,0x19d34af3a
- .quad 0x18f0c7078,0x014338754
- .quad 0x017f27698,0x049c3cc9c
- .quad 0x058ca5f00,0x15e3e77ee
- .quad 0x1af900c24,0x068bce87a
- .quad 0x0b5cfca28,0x0dd07448e
- .quad 0x0ded288f8,0x1524fa6c6
- .quad 0x059f229bc,0x1d8048348
- .quad 0x06d390dec,0x16cba8aca
- .quad 0x037170390,0x0a3e3e02c
- .quad 0x06353c1cc,0x042d98888
- .quad 0x0c4584f5c,0x0d73c7bea
- .quad 0x1f16a3418,0x1329d9f7e
- .quad 0x0531377e2,0x185137662
- .quad 0x1d8d9ca7c,0x1b1c69528
- .quad 0x0b25b29f2,0x18a08b5bc
- .quad 0x19fb2a8b0,0x02178513a
- .quad 0x1a08fe6ac,0x1da758ae0
- .quad 0x045cddf4e,0x0e0ac139e
- .quad 0x1a91647f2,0x169cf9eb0
- .quad 0x1a0f717c4,0x0170076fa
+++ /dev/null
-/*
- * Generate .byte code for some instructions not supported by old
- * binutils.
- */
-#ifndef X86_ASM_INST_H
-#define X86_ASM_INST_H
-
-#ifdef __ASSEMBLY__
-
-#define REG_NUM_INVALID 100
-
-#define REG_TYPE_R32 0
-#define REG_TYPE_R64 1
-#define REG_TYPE_XMM 2
-#define REG_TYPE_INVALID 100
-
- .macro R32_NUM opd r32
- \opd = REG_NUM_INVALID
- .ifc \r32,%eax
- \opd = 0
- .endif
- .ifc \r32,%ecx
- \opd = 1
- .endif
- .ifc \r32,%edx
- \opd = 2
- .endif
- .ifc \r32,%ebx
- \opd = 3
- .endif
- .ifc \r32,%esp
- \opd = 4
- .endif
- .ifc \r32,%ebp
- \opd = 5
- .endif
- .ifc \r32,%esi
- \opd = 6
- .endif
- .ifc \r32,%edi
- \opd = 7
- .endif
-#ifdef CONFIG_X86_64
- .ifc \r32,%r8d
- \opd = 8
- .endif
- .ifc \r32,%r9d
- \opd = 9
- .endif
- .ifc \r32,%r10d
- \opd = 10
- .endif
- .ifc \r32,%r11d
- \opd = 11
- .endif
- .ifc \r32,%r12d
- \opd = 12
- .endif
- .ifc \r32,%r13d
- \opd = 13
- .endif
- .ifc \r32,%r14d
- \opd = 14
- .endif
- .ifc \r32,%r15d
- \opd = 15
- .endif
-#endif
- .endm
-
- .macro R64_NUM opd r64
- \opd = REG_NUM_INVALID
-#ifdef CONFIG_X86_64
- .ifc \r64,%rax
- \opd = 0
- .endif
- .ifc \r64,%rcx
- \opd = 1
- .endif
- .ifc \r64,%rdx
- \opd = 2
- .endif
- .ifc \r64,%rbx
- \opd = 3
- .endif
- .ifc \r64,%rsp
- \opd = 4
- .endif
- .ifc \r64,%rbp
- \opd = 5
- .endif
- .ifc \r64,%rsi
- \opd = 6
- .endif
- .ifc \r64,%rdi
- \opd = 7
- .endif
- .ifc \r64,%r8
- \opd = 8
- .endif
- .ifc \r64,%r9
- \opd = 9
- .endif
- .ifc \r64,%r10
- \opd = 10
- .endif
- .ifc \r64,%r11
- \opd = 11
- .endif
- .ifc \r64,%r12
- \opd = 12
- .endif
- .ifc \r64,%r13
- \opd = 13
- .endif
- .ifc \r64,%r14
- \opd = 14
- .endif
- .ifc \r64,%r15
- \opd = 15
- .endif
-#endif
- .endm
-
- .macro XMM_NUM opd xmm
- \opd = REG_NUM_INVALID
- .ifc \xmm,%xmm0
- \opd = 0
- .endif
- .ifc \xmm,%xmm1
- \opd = 1
- .endif
- .ifc \xmm,%xmm2
- \opd = 2
- .endif
- .ifc \xmm,%xmm3
- \opd = 3
- .endif
- .ifc \xmm,%xmm4
- \opd = 4
- .endif
- .ifc \xmm,%xmm5
- \opd = 5
- .endif
- .ifc \xmm,%xmm6
- \opd = 6
- .endif
- .ifc \xmm,%xmm7
- \opd = 7
- .endif
- .ifc \xmm,%xmm8
- \opd = 8
- .endif
- .ifc \xmm,%xmm9
- \opd = 9
- .endif
- .ifc \xmm,%xmm10
- \opd = 10
- .endif
- .ifc \xmm,%xmm11
- \opd = 11
- .endif
- .ifc \xmm,%xmm12
- \opd = 12
- .endif
- .ifc \xmm,%xmm13
- \opd = 13
- .endif
- .ifc \xmm,%xmm14
- \opd = 14
- .endif
- .ifc \xmm,%xmm15
- \opd = 15
- .endif
- .endm
-
- .macro REG_TYPE type reg
- R32_NUM reg_type_r32 \reg
- R64_NUM reg_type_r64 \reg
- XMM_NUM reg_type_xmm \reg
- .if reg_type_r64 <> REG_NUM_INVALID
- \type = REG_TYPE_R64
- .elseif reg_type_r32 <> REG_NUM_INVALID
- \type = REG_TYPE_R32
- .elseif reg_type_xmm <> REG_NUM_INVALID
- \type = REG_TYPE_XMM
- .else
- \type = REG_TYPE_INVALID
- .endif
- .endm
-
- .macro PFX_OPD_SIZE
- .byte 0x66
- .endm
-
- .macro PFX_REX opd1 opd2 W=0
- .if ((\opd1 | \opd2) & 8) || \W
- .byte 0x40 | ((\opd1 & 8) >> 3) | ((\opd2 & 8) >> 1) | (\W << 3)
- .endif
- .endm
-
- .macro MODRM mod opd1 opd2
- .byte \mod | (\opd1 & 7) | ((\opd2 & 7) << 3)
- .endm
-
- .macro PSHUFB_XMM xmm1 xmm2
- XMM_NUM pshufb_opd1 \xmm1
- XMM_NUM pshufb_opd2 \xmm2
- PFX_OPD_SIZE
- PFX_REX pshufb_opd1 pshufb_opd2
- .byte 0x0f, 0x38, 0x00
- MODRM 0xc0 pshufb_opd1 pshufb_opd2
- .endm
-
- .macro PCLMULQDQ imm8 xmm1 xmm2
- XMM_NUM clmul_opd1 \xmm1
- XMM_NUM clmul_opd2 \xmm2
- PFX_OPD_SIZE
- PFX_REX clmul_opd1 clmul_opd2
- .byte 0x0f, 0x3a, 0x44
- MODRM 0xc0 clmul_opd1 clmul_opd2
- .byte \imm8
- .endm
-
- .macro PEXTRD imm8 xmm gpr
- R32_NUM extrd_opd1 \gpr
- XMM_NUM extrd_opd2 \xmm
- PFX_OPD_SIZE
- PFX_REX extrd_opd1 extrd_opd2
- .byte 0x0f, 0x3a, 0x16
- MODRM 0xc0 extrd_opd1 extrd_opd2
- .byte \imm8
- .endm
-
- .macro AESKEYGENASSIST rcon xmm1 xmm2
- XMM_NUM aeskeygen_opd1 \xmm1
- XMM_NUM aeskeygen_opd2 \xmm2
- PFX_OPD_SIZE
- PFX_REX aeskeygen_opd1 aeskeygen_opd2
- .byte 0x0f, 0x3a, 0xdf
- MODRM 0xc0 aeskeygen_opd1 aeskeygen_opd2
- .byte \rcon
- .endm
-
- .macro AESIMC xmm1 xmm2
- XMM_NUM aesimc_opd1 \xmm1
- XMM_NUM aesimc_opd2 \xmm2
- PFX_OPD_SIZE
- PFX_REX aesimc_opd1 aesimc_opd2
- .byte 0x0f, 0x38, 0xdb
- MODRM 0xc0 aesimc_opd1 aesimc_opd2
- .endm
-
- .macro AESENC xmm1 xmm2
- XMM_NUM aesenc_opd1 \xmm1
- XMM_NUM aesenc_opd2 \xmm2
- PFX_OPD_SIZE
- PFX_REX aesenc_opd1 aesenc_opd2
- .byte 0x0f, 0x38, 0xdc
- MODRM 0xc0 aesenc_opd1 aesenc_opd2
- .endm
-
- .macro AESENCLAST xmm1 xmm2
- XMM_NUM aesenclast_opd1 \xmm1
- XMM_NUM aesenclast_opd2 \xmm2
- PFX_OPD_SIZE
- PFX_REX aesenclast_opd1 aesenclast_opd2
- .byte 0x0f, 0x38, 0xdd
- MODRM 0xc0 aesenclast_opd1 aesenclast_opd2
- .endm
-
- .macro AESDEC xmm1 xmm2
- XMM_NUM aesdec_opd1 \xmm1
- XMM_NUM aesdec_opd2 \xmm2
- PFX_OPD_SIZE
- PFX_REX aesdec_opd1 aesdec_opd2
- .byte 0x0f, 0x38, 0xde
- MODRM 0xc0 aesdec_opd1 aesdec_opd2
- .endm
-
- .macro AESDECLAST xmm1 xmm2
- XMM_NUM aesdeclast_opd1 \xmm1
- XMM_NUM aesdeclast_opd2 \xmm2
- PFX_OPD_SIZE
- PFX_REX aesdeclast_opd1 aesdeclast_opd2
- .byte 0x0f, 0x38, 0xdf
- MODRM 0xc0 aesdeclast_opd1 aesdeclast_opd2
- .endm
-
- .macro MOVQ_R64_XMM opd1 opd2
- REG_TYPE movq_r64_xmm_opd1_type \opd1
- .if movq_r64_xmm_opd1_type == REG_TYPE_XMM
- XMM_NUM movq_r64_xmm_opd1 \opd1
- R64_NUM movq_r64_xmm_opd2 \opd2
- .else
- R64_NUM movq_r64_xmm_opd1 \opd1
- XMM_NUM movq_r64_xmm_opd2 \opd2
- .endif
- PFX_OPD_SIZE
- PFX_REX movq_r64_xmm_opd1 movq_r64_xmm_opd2 1
- .if movq_r64_xmm_opd1_type == REG_TYPE_XMM
- .byte 0x0f, 0x7e
- .else
- .byte 0x0f, 0x6e
- .endif
- MODRM 0xc0 movq_r64_xmm_opd1 movq_r64_xmm_opd2
- .endm
-#endif
-
-#endif
+++ /dev/null
-/* GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see http://www.gnu.org/licenses
- *
- * Please visit http://www.xyratex.com/contact if you need additional
- * information or have any questions.
- *
- * GPL HEADER END
- */
-
-/*
- * Copyright 2012 Xyratex Technology Limited
- */
-
-/*
- * This is crypto api shash wrappers to crc32_le.
- */
-
-#include <linux/module.h>
-#include <linux/crc32.h>
-#include <libcfs/linux/linux-crypto.h>
-#include <crypto/internal/hash.h>
-
-#define CHKSUM_BLOCK_SIZE 1
-#define CHKSUM_DIGEST_SIZE 4
-
-static u32 __crc32_le(u32 crc, unsigned char const *p, size_t len)
-{
- return crc32_le(crc, p, len);
-}
-
-/** No default init with ~0 */
-static int crc32_cra_init(struct crypto_tfm *tfm)
-{
- u32 *key = crypto_tfm_ctx(tfm);
-
- *key = 0;
-
- return 0;
-}
-
-
-/*
- * Setting the seed allows arbitrary accumulators and flexible XOR policy
- * If your algorithm starts with ~0, then XOR with ~0 before you set
- * the seed.
- */
-static int crc32_setkey(struct crypto_shash *hash, const u8 *key,
- unsigned int keylen)
-{
- u32 *mctx = crypto_shash_ctx(hash);
-
- if (keylen != sizeof(u32)) {
- crypto_shash_set_flags(hash, CRYPTO_TFM_RES_BAD_KEY_LEN);
- return -EINVAL;
- }
- *mctx = le32_to_cpup((__le32 *)key);
- return 0;
-}
-
-static int crc32_init(struct shash_desc *desc)
-{
- u32 *mctx = crypto_shash_ctx(desc->tfm);
- u32 *crcp = shash_desc_ctx(desc);
-
- *crcp = *mctx;
-
- return 0;
-}
-
-static int crc32_update(struct shash_desc *desc, const u8 *data,
- unsigned int len)
-{
- u32 *crcp = shash_desc_ctx(desc);
-
- *crcp = __crc32_le(*crcp, data, len);
- return 0;
-}
-/* No final XOR 0xFFFFFFFF, like crc32_le */
-static int __crc32_finup(u32 *crcp, const u8 *data, unsigned int len,
- u8 *out)
-{
- *(__le32 *)out = cpu_to_le32(__crc32_le(*crcp, data, len));
- return 0;
-}
-
-static int crc32_finup(struct shash_desc *desc, const u8 *data,
- unsigned int len, u8 *out)
-{
- return __crc32_finup(shash_desc_ctx(desc), data, len, out);
-}
-
-static int crc32_final(struct shash_desc *desc, u8 *out)
-{
- u32 *crcp = shash_desc_ctx(desc);
-
- *(__le32 *)out = cpu_to_le32p(crcp);
- return 0;
-}
-
-static int crc32_digest(struct shash_desc *desc, const u8 *data,
- unsigned int len, u8 *out)
-{
- return __crc32_finup(crypto_shash_ctx(desc->tfm), data, len,
- out);
-}
-static struct shash_alg alg = {
- .setkey = crc32_setkey,
- .init = crc32_init,
- .update = crc32_update,
- .final = crc32_final,
- .finup = crc32_finup,
- .digest = crc32_digest,
- .descsize = sizeof(u32),
- .digestsize = CHKSUM_DIGEST_SIZE,
- .base = {
- .cra_name = "crc32",
- .cra_driver_name = "crc32-table",
- .cra_priority = 100,
- .cra_blocksize = CHKSUM_BLOCK_SIZE,
- .cra_ctxsize = sizeof(u32),
- .cra_module = THIS_MODULE,
- .cra_init = crc32_cra_init,
- }
-};
-
-int cfs_crypto_crc32_register(void)
-{
- return crypto_register_shash(&alg);
-}
-
-void cfs_crypto_crc32_unregister(void)
-{
- crypto_unregister_shash(&alg);
-}
+++ /dev/null
-/* GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see http://www.gnu.org/licenses
- *
- * Please visit http://www.xyratex.com/contact if you need additional
- * information or have any questions.
- *
- * GPL HEADER END
- */
-
-/*
- * Wrappers for kernel crypto shash api to pclmulqdq crc32c imlementation.
- *
- * Author: James Simmons <jsimmons@infradead.org>
- */
-#include <linux/crc32.h>
-#include <crypto/internal/hash.h>
-#include <linux/crc32.h>
-#include <asm/cpufeature.h>
-#ifdef HAVE_FPU_API_HEADER
-#include <asm/fpu/api.h>
-#else
-#include <asm/i387.h>
-#endif
-#include <libcfs/libcfs.h>
-
-#define CHKSUM_BLOCK_SIZE 1
-#define CHKSUM_DIGEST_SIZE 4
-
-asmlinkage unsigned int crc_pcl(const u8 *buffer, int len,
- unsigned int crc_init);
-
-static int crc32c_pclmul_cra_init(struct crypto_tfm *tfm)
-{
- u32 *key = crypto_tfm_ctx(tfm);
-
- *key = ~0;
- return 0;
-}
-
-/*
- * Setting the seed allows arbitrary accumulators and flexible XOR policy
- * If your algorithm starts with ~0, then XOR with ~0 before you set
- * the seed.
- */
-static int crc32c_pclmul_setkey(struct crypto_shash *hash, const u8 *key,
- unsigned int keylen)
-{
- u32 *mctx = crypto_shash_ctx(hash);
-
- if (keylen != sizeof(u32)) {
- crypto_shash_set_flags(hash, CRYPTO_TFM_RES_BAD_KEY_LEN);
- return -EINVAL;
- }
- *mctx = le32_to_cpup((__le32 *)key);
- return 0;
-}
-
-static int crc32c_pclmul_init(struct shash_desc *desc)
-{
- u32 *mctx = crypto_shash_ctx(desc->tfm);
- u32 *crcp = shash_desc_ctx(desc);
-
- *crcp = *mctx;
- return 0;
-}
-
-static int crc32c_pclmul_update(struct shash_desc *desc, const u8 *data,
- unsigned int len)
-{
- u32 *crcp = shash_desc_ctx(desc);
-
- kernel_fpu_begin();
- *crcp = crc_pcl(data, len, *crcp);
- kernel_fpu_end();
- return 0;
-}
-
-/* No final XOR 0xFFFFFFFF, like crc32_le */
-static int __crc32c_pclmul_finup(u32 *crcp, const u8 *data, unsigned int len,
- u8 *out)
-{
- kernel_fpu_begin();
- *(__le32 *)out = ~cpu_to_le32(crc_pcl(data, len, *crcp));
- kernel_fpu_end();
- return 0;
-}
-
-static int crc32c_pclmul_finup(struct shash_desc *desc, const u8 *data,
- unsigned int len, u8 *out)
-{
- return __crc32c_pclmul_finup(shash_desc_ctx(desc), data, len, out);
-}
-
-static int crc32c_pclmul_digest(struct shash_desc *desc, const u8 *data,
- unsigned int len, u8 *out)
-{
- return __crc32c_pclmul_finup(crypto_shash_ctx(desc->tfm), data, len,
- out);
-}
-
-static int crc32c_pclmul_final(struct shash_desc *desc, u8 *out)
-{
- u32 *crcp = shash_desc_ctx(desc);
-
- *(__le32 *)out = ~cpu_to_le32p(crcp);
- return 0;
-}
-
-static struct shash_alg alg = {
- .setkey = crc32c_pclmul_setkey,
- .init = crc32c_pclmul_init,
- .update = crc32c_pclmul_update,
- .final = crc32c_pclmul_final,
- .finup = crc32c_pclmul_finup,
- .digest = crc32c_pclmul_digest,
- .descsize = sizeof(u32),
- .digestsize = CHKSUM_DIGEST_SIZE,
- .base = {
- .cra_name = "crc32c",
- .cra_driver_name = "crc32c-pclmul",
- .cra_priority = 150,
- .cra_blocksize = CHKSUM_BLOCK_SIZE,
- .cra_ctxsize = sizeof(u32),
- .cra_module = THIS_MODULE,
- .cra_init = crc32c_pclmul_cra_init,
- }
-};
-
-#ifndef X86_FEATURE_XMM4_2
-#define X86_FEATURE_XMM4_2 (4*32+20) /* "sse4_2" SSE-4.2 */
-#endif
-
-int cfs_crypto_crc32c_pclmul_register(void)
-{
- if (!boot_cpu_has(X86_FEATURE_XMM4_2)) {
- CDEBUG(D_INFO, "CRC32 instruction is not detected.\n");
- return -ENODEV;
- }
- return crypto_register_shash(&alg);
-}
-
-void cfs_crypto_crc32c_pclmul_unregister(void)
-{
- crypto_unregister_shash(&alg);
-}
+++ /dev/null
-/* GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see http://www.gnu.org/licenses
- *
- * Please visit http://www.xyratex.com/contact if you need additional
- * information or have any questions.
- *
- * GPL HEADER END
- */
-
-/*
- * Copyright 2012 Xyratex Technology Limited
- *
- * Wrappers for kernel crypto shash api to pclmulqdq crc32 imlementation.
- *
- * Author: Alexander Boyko <Alexander_Boyko@xyratex.com>
- */
-#include <linux/crc32.h>
-#include <crypto/internal/hash.h>
-#include <linux/crc32.h>
-#include <asm/cpufeature.h>
-#ifdef HAVE_FPU_API_HEADER
-#include <asm/fpu/api.h>
-#else
-#include <asm/i387.h>
-#endif
-#include <libcfs/libcfs.h>
-
-#define CHKSUM_BLOCK_SIZE 1
-#define CHKSUM_DIGEST_SIZE 4
-
-#define PCLMUL_MIN_LEN 64L /* minimum size of buffer
- * for crc32_pclmul_le_16 */
-#define SCALE_F 16L /* size of xmm register */
-#define SCALE_F_MASK (SCALE_F - 1)
-
-u32 crc32_pclmul_le_16(unsigned char const *buffer, size_t len, u32 crc32);
-
-static u32 __attribute__((pure))
- crc32_pclmul_le(u32 crc, unsigned char const *p, size_t len)
-{
- unsigned int iquotient;
- unsigned int iremainder;
- unsigned int prealign;
-
- if (len < PCLMUL_MIN_LEN + SCALE_F_MASK)
- return crc32_le(crc, p, len);
-
- if ((long)p & SCALE_F_MASK) {
- /* align p to 16 byte */
- prealign = SCALE_F - ((long)p & SCALE_F_MASK);
-
- crc = crc32_le(crc, p, prealign);
- len -= prealign;
- p = (unsigned char *)(((unsigned long)p + SCALE_F_MASK) &
- ~SCALE_F_MASK);
- }
- iquotient = len & (~SCALE_F_MASK);
- iremainder = len & SCALE_F_MASK;
-
- kernel_fpu_begin();
- crc = crc32_pclmul_le_16(p, iquotient, crc);
- kernel_fpu_end();
-
- if (iremainder)
- crc = crc32_le(crc, p + iquotient, iremainder);
-
- return crc;
-}
-
-static int crc32_pclmul_cra_init(struct crypto_tfm *tfm)
-{
- u32 *key = crypto_tfm_ctx(tfm);
-
- *key = 0;
-
- return 0;
-}
-
-/*
- * Setting the seed allows arbitrary accumulators and flexible XOR policy
- * If your algorithm starts with ~0, then XOR with ~0 before you set
- * the seed.
- */
-static int crc32_pclmul_setkey(struct crypto_shash *hash, const u8 *key,
- unsigned int keylen)
-{
- u32 *mctx = crypto_shash_ctx(hash);
-
- if (keylen != sizeof(u32)) {
- crypto_shash_set_flags(hash, CRYPTO_TFM_RES_BAD_KEY_LEN);
- return -EINVAL;
- }
- *mctx = le32_to_cpup((__le32 *)key);
- return 0;
-}
-
-static int crc32_pclmul_init(struct shash_desc *desc)
-{
- u32 *mctx = crypto_shash_ctx(desc->tfm);
- u32 *crcp = shash_desc_ctx(desc);
-
- *crcp = *mctx;
-
- return 0;
-}
-
-static int crc32_pclmul_update(struct shash_desc *desc, const u8 *data,
- unsigned int len)
-{
- u32 *crcp = shash_desc_ctx(desc);
-
- *crcp = crc32_pclmul_le(*crcp, data, len);
- return 0;
-}
-
-/* No final XOR 0xFFFFFFFF, like crc32_le */
-static int __crc32_pclmul_finup(u32 *crcp, const u8 *data, unsigned int len,
- u8 *out)
-{
- *(__le32 *)out = cpu_to_le32(crc32_pclmul_le(*crcp, data, len));
- return 0;
-}
-
-static int crc32_pclmul_finup(struct shash_desc *desc, const u8 *data,
- unsigned int len, u8 *out)
-{
- return __crc32_pclmul_finup(shash_desc_ctx(desc), data, len, out);
-}
-
-static int crc32_pclmul_final(struct shash_desc *desc, u8 *out)
-{
- u32 *crcp = shash_desc_ctx(desc);
-
- *(__le32 *)out = cpu_to_le32p(crcp);
- return 0;
-}
-
-static int crc32_pclmul_digest(struct shash_desc *desc, const u8 *data,
- unsigned int len, u8 *out)
-{
- return __crc32_pclmul_finup(crypto_shash_ctx(desc->tfm), data, len,
- out);
-}
-
-static struct shash_alg alg = {
- .setkey = crc32_pclmul_setkey,
- .init = crc32_pclmul_init,
- .update = crc32_pclmul_update,
- .final = crc32_pclmul_final,
- .finup = crc32_pclmul_finup,
- .digest = crc32_pclmul_digest,
- .descsize = sizeof(u32),
- .digestsize = CHKSUM_DIGEST_SIZE,
- .base = {
- .cra_name = "crc32",
- .cra_driver_name = "crc32-pclmul",
- .cra_priority = 200,
- .cra_blocksize = CHKSUM_BLOCK_SIZE,
- .cra_ctxsize = sizeof(u32),
- .cra_module = THIS_MODULE,
- .cra_init = crc32_pclmul_cra_init,
- }
-};
-
-#ifndef X86_FEATURE_PCLMULQDQ
-#define X86_FEATURE_PCLMULQDQ (4*32+1) /* PCLMULQDQ instruction */
-#endif
-
-int cfs_crypto_crc32_pclmul_register(void)
-{
- if (!boot_cpu_has(X86_FEATURE_PCLMULQDQ)) {
- CDEBUG(D_INFO, "PCLMULQDQ-NI instructions are not detected.\n");
- return -ENODEV;
- }
- return crypto_register_shash(&alg);
-}
-
-void cfs_crypto_crc32_pclmul_unregister(void)
-{
- crypto_unregister_shash(&alg);
-}
static int adler32;
-#ifdef HAVE_CRC32
-static int crc32;
-#endif
-#ifdef HAVE_PCLMULQDQ
-#ifdef NEED_CRC32_ACCEL
-static int crc32_pclmul;
-#endif
-#ifdef NEED_CRC32C_ACCEL
-static int crc32c_pclmul;
-#endif
-#endif /* HAVE_PCLMULQDQ */
-
/**
* Register available hash functions
*
{
request_module("crc32c");
- adler32 = cfs_crypto_adler32_register();
-
-#ifdef HAVE_CRC32
- crc32 = cfs_crypto_crc32_register();
-#endif
-#ifdef HAVE_PCLMULQDQ
-#ifdef NEED_CRC32_ACCEL
- crc32_pclmul = cfs_crypto_crc32_pclmul_register();
-#endif
-#ifdef NEED_CRC32C_ACCEL
- crc32c_pclmul = cfs_crypto_crc32c_pclmul_register();
-#endif
-#endif /* HAVE_PCLMULQDQ */
+ if (cfs_crypto_adler32_register() == 0)
+ adler32 = 1;
/* check all algorithms and do performance test */
cfs_crypto_test_hashes();
*/
void cfs_crypto_unregister(void)
{
- if (adler32 == 0)
+ if (adler32)
cfs_crypto_adler32_unregister();
-
-#ifdef HAVE_CRC32
- if (crc32 == 0)
- cfs_crypto_crc32_unregister();
-#endif
-#ifdef HAVE_PCLMULQDQ
-#ifdef NEED_CRC32_ACCEL
- if (crc32_pclmul == 0)
- cfs_crypto_crc32_pclmul_unregister();
-#endif
-#ifdef NEED_CRC32C_ACCEL
- if (crc32c_pclmul == 0)
- cfs_crypto_crc32c_pclmul_unregister();
-#endif
-#endif /* HAVE_PCLMULQDQ */
+ adler32 = 0;
}
#include <asm/stacktrace.h>
#ifdef HAVE_STACKTRACE_OPS
-#ifdef HAVE_STACKTRACE_WARNING
-static void
-print_trace_warning_symbol(void *data, char *msg, unsigned long symbol)
-{
- printk("%s", (char *)data);
- print_symbol(msg, symbol);
- printk("\n");
-}
-
-static void print_trace_warning(void *data, char *msg)
-{
- printk("%s%s\n", (char *)data, msg);
-}
-#endif
-
static int print_trace_stack(void *data, char *name)
{
printk(" <%s> ", name);
}
static const struct stacktrace_ops print_trace_ops = {
-#ifdef HAVE_STACKTRACE_WARNING
- .warning = print_trace_warning,
- .warning_symbol = print_trace_warning_symbol,
-#endif
.stack = print_trace_stack,
.address = print_trace_address,
-#ifdef STACKTRACE_OPS_HAVE_WALK_STACK
.walk_stack = print_context_stack,
-#endif
};
#endif /* HAVE_STACKTRACE_OPS */
#ifdef HAVE_STACKTRACE_OPS
printk("Pid: %d, comm: %.20s\n", tsk->pid, tsk->comm);
printk("\nCall Trace:\n");
- dump_trace(tsk, NULL, NULL,
-#ifdef HAVE_DUMP_TRACE_ADDRESS
- 0,
-#endif /* HAVE_DUMP_TRACE_ADDRESS */
- &print_trace_ops, NULL);
+ dump_trace(tsk, NULL, NULL, 0, &print_trace_ops, NULL);
printk("\n");
#else /* !HAVE_STACKTRACE_OPS */
if (tsk == current)
static struct ctl_table lnet_table[] = {
{
- INIT_CTL_NAME
.procname = "debug",
.data = &libcfs_debug,
.maxlen = sizeof(int),
.proc_handler = &proc_dobitmasks,
},
{
- INIT_CTL_NAME
.procname = "subsystem_debug",
.data = &libcfs_subsystem_debug,
.maxlen = sizeof(int),
.proc_handler = &proc_dobitmasks,
},
{
- INIT_CTL_NAME
.procname = "printk",
.data = &libcfs_printk,
.maxlen = sizeof(int),
.proc_handler = &proc_dobitmasks,
},
{
- INIT_CTL_NAME
.procname = "cpu_partition_table",
.maxlen = 128,
.mode = 0444,
.proc_handler = &proc_cpt_table,
},
{
- INIT_CTL_NAME
.procname = "cpu_partition_distance",
.maxlen = 128,
.mode = 0444,
.proc_handler = &proc_cpt_distance,
},
{
- INIT_CTL_NAME
.procname = "debug_log_upcall",
.data = lnet_debug_log_upcall,
.maxlen = sizeof(lnet_debug_log_upcall),
.proc_handler = &proc_dostring,
},
{
- INIT_CTL_NAME
.procname = "lnet_memused",
.data = (int *)&libcfs_kmemory.counter,
.maxlen = sizeof(int),
.proc_handler = &proc_dointvec,
},
{
- INIT_CTL_NAME
.procname = "catastrophe",
.data = &libcfs_catastrophe,
.maxlen = sizeof(int),
.proc_handler = &proc_dointvec,
},
{
- INIT_CTL_NAME
.procname = "dump_kernel",
.maxlen = 256,
.mode = 0200,
.proc_handler = &proc_dump_kernel,
},
{
- INIT_CTL_NAME
.procname = "daemon_file",
.mode = 0644,
.maxlen = 256,
.proc_handler = &proc_daemon_file,
},
{
- INIT_CTL_NAME
.procname = "watchdog_ratelimit",
.data = &libcfs_watchdog_ratelimit,
.maxlen = sizeof(int),
.extra2 = &max_watchdog_ratelimit,
},
{
- INIT_CTL_NAME
.procname = "force_lbug",
.data = NULL,
.maxlen = 0,
.proc_handler = &libcfs_force_lbug
},
{
- INIT_CTL_NAME
.procname = "fail_loc",
.data = &cfs_fail_loc,
.maxlen = sizeof(cfs_fail_loc),
.proc_handler = &proc_fail_loc
},
{
- INIT_CTL_NAME
.procname = "fail_val",
.data = &cfs_fail_val,
.maxlen = sizeof(int),
.proc_handler = &proc_dointvec
},
{
- INIT_CTL_NAME
.procname = "fail_err",
.data = &cfs_fail_err,
.maxlen = sizeof(cfs_fail_err),
* to go via /proc for portability.
*/
{
- INIT_CTL_NAME
.procname = "version",
.data = LUSTRE_VERSION_STRING,
.maxlen = sizeof(LUSTRE_VERSION_STRING),
.proc_handler = &proc_dostring
},
{
- INIT_CTL_NAME
.procname = "thread_pause",
.data = &kgnilnd_sysctl.ksd_pause_trigger,
.maxlen = sizeof(int),
.proc_handler = &proc_toggle_thread_pause,
},
{
- INIT_CTL_NAME
.procname = "hw_quiesce",
.data = &kgnilnd_sysctl.ksd_quiesce_secs,
.maxlen = sizeof(__u32),
.proc_handler = &proc_hw_quiesce,
},
{
- INIT_CTL_NAME
.procname = "stack_reset",
.data = NULL,
.maxlen = sizeof(int),
.proc_handler = &proc_trigger_stack_reset,
},
{
- INIT_CTL_NAME
.procname = "rdmaq_override",
.data = &kgnilnd_sysctl.ksd_rdmaq_override,
.maxlen = sizeof(int),
.proc_handler = &proc_toggle_rdmaq_override,
},
{
- INIT_CTL_NAME
.procname = "peer_state",
.data = kgnilnd_sysctl.ksd_peer_state,
.maxlen = GNILND_PEERSTATE_STRLEN,
static struct ctl_table kgnilnd_top_table[2] = {
{
- INIT_CTL_NAME
.procname = "kgnilnd",
.data = NULL,
.maxlen = 0,
* to go via /proc for portability.
*/
{
- INIT_CTL_NAME
.procname = "stats",
.mode = 0644,
.proc_handler = &proc_lnet_stats,
},
{
- INIT_CTL_NAME
.procname = "routes",
.mode = 0444,
.proc_handler = &proc_lnet_routes,
},
{
- INIT_CTL_NAME
.procname = "routers",
.mode = 0444,
.proc_handler = &proc_lnet_routers,
},
{
- INIT_CTL_NAME
.procname = "peers",
.mode = 0644,
.proc_handler = &proc_lnet_peers,
},
{
- INIT_CTL_NAME
.procname = "buffers",
.mode = 0444,
.proc_handler = &proc_lnet_buffers,
},
{
- INIT_CTL_NAME
.procname = "nis",
.mode = 0644,
.proc_handler = &proc_lnet_nis,
},
{
- INIT_CTL_NAME
.procname = "portal_rotor",
.mode = 0644,
.proc_handler = &proc_lnet_portal_rotor,
#include <linux/version.h>
#include <linux/security.h>
#include <linux/user_namespace.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
#include <linux/uaccess.h>
#include <linux/buffer_head.h> // for wait_on_buffer
#include <linux/pagevec.h>
#include <linux/file.h>
#include <linux/sched.h>
#include <linux/user_namespace.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
#include <uapi/linux/lustre/lustre_ioctl.h>
#include <lustre_swab.h>
#include <linux/mm.h>
#include <linux/user_namespace.h>
#include <linux/delay.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
#include <linux/security.h>
#include <uapi/linux/lustre/lustre_ioctl.h>
#include <linux/version.h>
#include <linux/user_namespace.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
+
#include <uapi/linux/lustre/lustre_param.h>
#include <lprocfs_status.h>
#include <obd_support.h>
#include <linux/pagemap.h>
#include <linux/security.h>
#include <linux/user_namespace.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
#define DEBUG_SUBSYSTEM S_LLITE
#define DEBUG_SUBSYSTEM S_LLITE
#include <linux/user_namespace.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
+
#include <libcfs/libcfs.h>
#include <obd.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/user_namespace.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
#include <linux/slab.h>
#include <linux/pagemap.h>
#include <linux/mm.h>
#define DEBUG_SUBSYSTEM S_MDC
#include <linux/user_namespace.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
+
#include <lustre_net.h>
#include <obd_class.h>
#include <obd.h>
#include <linux/user_namespace.h>
#include <linux/utsname.h>
#include <linux/delay.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
#include <lustre_errno.h>
#define DEBUG_SUBSYSTEM S_MDS
#include <linux/user_namespace.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
+
#include "mdt_internal.h"
#include <uapi/linux/lnet/nidstr.h>
#include <lustre_nodemap.h>
#include <linux/miscdevice.h>
#include <linux/user_namespace.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
#include <linux/atomic.h>
#include <linux/list.h>
#define DEBUG_SUBSYSTEM S_SEC
#include <linux/user_namespace.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
+
#include <lustre_idmap.h>
#include <upcall_cache.h>
#include <md_object.h>
#define DEBUG_SUBSYSTEM S_RPC
#include <linux/user_namespace.h>
-#ifdef HAVE_UIDGID_HEADER
#include <linux/uidgid.h>
-#endif
#include <linux/utsname.h>
#include <libcfs/libcfs.h>
.nr_to_scan = shrink_param(sc, nr_to_scan),
.gfp_mask = shrink_param(sc, gfp_mask)
};
-#if !defined(HAVE_SHRINKER_WANT_SHRINK_PTR) && !defined(HAVE_SHRINK_CONTROL)
- struct shrinker* shrinker = NULL;
-#endif
-
CDEBUG(D_INODE, "Shrink %lu objects\n", scv.nr_to_scan);
#define DEBUG_SUBSYSTEM S_CLASS
#include <linux/user_namespace.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
+
#include <obd_class.h>
#include <lustre_obdo.h>
#define DEBUG_SUBSYSTEM S_ECHO
#include <linux/user_namespace.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
-#include <libcfs/libcfs.h>
+#include <linux/uidgid.h>
+#include <libcfs/libcfs.h>
#include <obd.h>
#include <obd_support.h>
#include <obd_class.h>
.nr_to_scan = shrink_param(sc, nr_to_scan),
.gfp_mask = shrink_param(sc, gfp_mask)
};
-#if !defined(HAVE_SHRINKER_WANT_SHRINK_PTR) && !defined(HAVE_SHRINK_CONTROL)
- struct shrinker *shrinker = NULL;
-#endif
-
(void)osc_cache_shrink_scan(shrinker, &scv);
return osc_cache_shrink_count(shrinker, &scv);
#include <linux/kallsyms.h>
#include <linux/module.h>
#include <linux/user_namespace.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
/* prerequisite for linux/xattr.h */
#include <linux/types.h>
union lquota_rec *quota_rec);
void osd_quota_unpack(struct osd_object *obj, const struct dt_rec *rec);
-#ifndef HAVE_I_UID_READ
-static inline uid_t i_uid_read(const struct inode *inode)
-{
- return inode->i_uid;
-}
-
-static inline gid_t i_gid_read(const struct inode *inode)
-{
- return inode->i_gid;
-}
-
-static inline void i_uid_write(struct inode *inode, uid_t uid)
-{
- inode->i_uid = uid;
-}
-
-static inline void i_gid_write(struct inode *inode, gid_t gid)
-{
- inode->i_gid = gid;
-}
-#endif
-
#ifdef HAVE_PROJECT_QUOTA
static inline __u32 i_projid_read(struct inode *inode)
{
#define DEBUG_SUBSYSTEM S_SEC
#include <linux/user_namespace.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
#include <linux/crypto.h>
#include <linux/key.h>
.nr_to_scan = shrink_param(sc, nr_to_scan),
.gfp_mask = shrink_param(sc, gfp_mask)
};
-#if !defined(HAVE_SHRINKER_WANT_SHRINK_PTR) && !defined(HAVE_SHRINK_CONTROL)
- struct shrinker *shrinker = NULL;
-#endif
-
enc_pools_shrink_scan(shrinker, &scv);
return enc_pools_shrink_count(shrinker, &scv);
#include <linux/user_namespace.h>
#include <linux/delay.h>
-#ifdef HAVE_UIDGID_HEADER
-# include <linux/uidgid.h>
-#endif
+#include <linux/uidgid.h>
#include <obd.h>
#include <obd_class.h>