svn commit: r290135 - in head/sys: compat/linuxkpi/common/include/asm compat/linuxkpi/common/include/linux compat/linuxkpi/common/include/net compat/linuxkpi/common/src conf dev/usb modules/cxgb/iw...

Hans Petter Selasky hselasky at FreeBSD.org
Thu Oct 29 08:28:42 UTC 2015


Author: hselasky
Date: Thu Oct 29 08:28:39 2015
New Revision: 290135
URL: https://svnweb.freebsd.org/changeset/base/290135

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

Added:
  head/sys/compat/linuxkpi/common/include/asm/atomic-long.h
     - copied unchanged from r290045, head/sys/ofed/include/asm/atomic-long.h
  head/sys/compat/linuxkpi/common/include/asm/atomic.h
     - copied unchanged from r290042, head/sys/ofed/include/asm/atomic.h
  head/sys/compat/linuxkpi/common/include/asm/byteorder.h
     - copied unchanged from r290042, head/sys/ofed/include/asm/byteorder.h
  head/sys/compat/linuxkpi/common/include/asm/fcntl.h
     - copied unchanged from r290042, head/sys/ofed/include/asm/fcntl.h
  head/sys/compat/linuxkpi/common/include/asm/io.h
     - copied unchanged from r290042, head/sys/ofed/include/asm/io.h
  head/sys/compat/linuxkpi/common/include/asm/pgtable.h
     - copied unchanged from r290042, head/sys/ofed/include/asm/pgtable.h
  head/sys/compat/linuxkpi/common/include/asm/types.h
     - copied unchanged from r290042, head/sys/ofed/include/asm/types.h
  head/sys/compat/linuxkpi/common/include/asm/uaccess.h
     - copied unchanged from r290042, head/sys/ofed/include/asm/uaccess.h
  head/sys/compat/linuxkpi/common/include/linux/bitops.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/bitops.h
  head/sys/compat/linuxkpi/common/include/linux/cache.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/cache.h
  head/sys/compat/linuxkpi/common/include/linux/cdev.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/cdev.h
  head/sys/compat/linuxkpi/common/include/linux/clocksource.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/clocksource.h
  head/sys/compat/linuxkpi/common/include/linux/compat.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/compat.h
  head/sys/compat/linuxkpi/common/include/linux/compiler.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/compiler.h
  head/sys/compat/linuxkpi/common/include/linux/completion.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/completion.h
  head/sys/compat/linuxkpi/common/include/linux/delay.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/delay.h
  head/sys/compat/linuxkpi/common/include/linux/device.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/device.h
  head/sys/compat/linuxkpi/common/include/linux/dma-attrs.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/dma-attrs.h
  head/sys/compat/linuxkpi/common/include/linux/dma-mapping.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/dma-mapping.h
  head/sys/compat/linuxkpi/common/include/linux/dmapool.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/dmapool.h
  head/sys/compat/linuxkpi/common/include/linux/err.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/err.h
  head/sys/compat/linuxkpi/common/include/linux/errno.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/errno.h
  head/sys/compat/linuxkpi/common/include/linux/etherdevice.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/etherdevice.h
  head/sys/compat/linuxkpi/common/include/linux/file.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/file.h
  head/sys/compat/linuxkpi/common/include/linux/fs.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/fs.h
  head/sys/compat/linuxkpi/common/include/linux/gfp.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/gfp.h
  head/sys/compat/linuxkpi/common/include/linux/hardirq.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/hardirq.h
  head/sys/compat/linuxkpi/common/include/linux/idr.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/idr.h
  head/sys/compat/linuxkpi/common/include/linux/if_arp.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/if_arp.h
  head/sys/compat/linuxkpi/common/include/linux/if_ether.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/if_ether.h
  head/sys/compat/linuxkpi/common/include/linux/if_vlan.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/if_vlan.h
  head/sys/compat/linuxkpi/common/include/linux/in.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/in.h
  head/sys/compat/linuxkpi/common/include/linux/in6.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/in6.h
  head/sys/compat/linuxkpi/common/include/linux/inetdevice.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/inetdevice.h
  head/sys/compat/linuxkpi/common/include/linux/interrupt.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/interrupt.h
  head/sys/compat/linuxkpi/common/include/linux/io-mapping.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/io-mapping.h
  head/sys/compat/linuxkpi/common/include/linux/io.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/io.h
  head/sys/compat/linuxkpi/common/include/linux/ioctl.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/ioctl.h
  head/sys/compat/linuxkpi/common/include/linux/jhash.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/jhash.h
  head/sys/compat/linuxkpi/common/include/linux/jiffies.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/jiffies.h
  head/sys/compat/linuxkpi/common/include/linux/kdev_t.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/kdev_t.h
  head/sys/compat/linuxkpi/common/include/linux/kernel.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/kernel.h
  head/sys/compat/linuxkpi/common/include/linux/kmod.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/kmod.h
  head/sys/compat/linuxkpi/common/include/linux/kobject.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/kobject.h
  head/sys/compat/linuxkpi/common/include/linux/kref.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/kref.h
  head/sys/compat/linuxkpi/common/include/linux/kthread.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/kthread.h
  head/sys/compat/linuxkpi/common/include/linux/ktime.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/ktime.h
  head/sys/compat/linuxkpi/common/include/linux/list.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/list.h
  head/sys/compat/linuxkpi/common/include/linux/lockdep.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/lockdep.h
  head/sys/compat/linuxkpi/common/include/linux/log2.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/log2.h
  head/sys/compat/linuxkpi/common/include/linux/math64.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/math64.h
  head/sys/compat/linuxkpi/common/include/linux/miscdevice.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/miscdevice.h
  head/sys/compat/linuxkpi/common/include/linux/mm.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/mm.h
  head/sys/compat/linuxkpi/common/include/linux/module.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/module.h
  head/sys/compat/linuxkpi/common/include/linux/moduleparam.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/moduleparam.h
  head/sys/compat/linuxkpi/common/include/linux/mutex.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/mutex.h
  head/sys/compat/linuxkpi/common/include/linux/net.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/net.h
  head/sys/compat/linuxkpi/common/include/linux/netdevice.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/netdevice.h
  head/sys/compat/linuxkpi/common/include/linux/notifier.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/notifier.h
  head/sys/compat/linuxkpi/common/include/linux/page.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/page.h
  head/sys/compat/linuxkpi/common/include/linux/pci.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/pci.h
  head/sys/compat/linuxkpi/common/include/linux/poll.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/poll.h
  head/sys/compat/linuxkpi/common/include/linux/printk.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/printk.h
  head/sys/compat/linuxkpi/common/include/linux/radix-tree.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/radix-tree.h
  head/sys/compat/linuxkpi/common/include/linux/random.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/random.h
  head/sys/compat/linuxkpi/common/include/linux/rbtree.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/rbtree.h
  head/sys/compat/linuxkpi/common/include/linux/rwlock.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/rwlock.h
  head/sys/compat/linuxkpi/common/include/linux/rwsem.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/rwsem.h
  head/sys/compat/linuxkpi/common/include/linux/scatterlist.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/scatterlist.h
  head/sys/compat/linuxkpi/common/include/linux/sched.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/sched.h
  head/sys/compat/linuxkpi/common/include/linux/semaphore.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/semaphore.h
  head/sys/compat/linuxkpi/common/include/linux/slab.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/slab.h
  head/sys/compat/linuxkpi/common/include/linux/socket.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/socket.h
  head/sys/compat/linuxkpi/common/include/linux/spinlock.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/spinlock.h
  head/sys/compat/linuxkpi/common/include/linux/string.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/string.h
  head/sys/compat/linuxkpi/common/include/linux/sysfs.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/sysfs.h
  head/sys/compat/linuxkpi/common/include/linux/time.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/time.h
  head/sys/compat/linuxkpi/common/include/linux/timer.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/timer.h
  head/sys/compat/linuxkpi/common/include/linux/types.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/types.h
  head/sys/compat/linuxkpi/common/include/linux/uaccess.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/uaccess.h
  head/sys/compat/linuxkpi/common/include/linux/usb.h
     - copied unchanged from r290045, head/sys/dev/usb/usb_compat_linux.h
  head/sys/compat/linuxkpi/common/include/linux/vmalloc.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/vmalloc.h
  head/sys/compat/linuxkpi/common/include/linux/wait.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/wait.h
  head/sys/compat/linuxkpi/common/include/linux/workqueue.h
     - copied unchanged from r290042, head/sys/ofed/include/linux/workqueue.h
  head/sys/compat/linuxkpi/common/include/net/
     - copied from r290045, head/sys/ofed/include/net/
  head/sys/compat/linuxkpi/common/src/linux_compat.c
     - copied unchanged from r290042, head/sys/ofed/include/linux/linux_compat.c
  head/sys/compat/linuxkpi/common/src/linux_idr.c
     - copied unchanged from r290042, head/sys/ofed/include/linux/linux_idr.c
  head/sys/compat/linuxkpi/common/src/linux_kmod.c
     - copied unchanged from r290042, head/sys/ofed/include/linux/linux_kmod.c
  head/sys/compat/linuxkpi/common/src/linux_pci.c
     - copied unchanged from r290042, head/sys/ofed/include/linux/linux_pci.c
  head/sys/compat/linuxkpi/common/src/linux_radix.c
     - copied unchanged from r290042, head/sys/ofed/include/linux/linux_radix.c
  head/sys/compat/linuxkpi/common/src/linux_usb.c
     - copied, changed from r290134, head/sys/dev/usb/usb_compat_linux.c
Deleted:
  head/sys/dev/usb/usb_compat_linux.c
  head/sys/dev/usb/usb_compat_linux.h
  head/sys/ofed/include/asm/
  head/sys/ofed/include/linux/bitops.h
  head/sys/ofed/include/linux/cache.h
  head/sys/ofed/include/linux/cdev.h
  head/sys/ofed/include/linux/clocksource.h
  head/sys/ofed/include/linux/compat.h
  head/sys/ofed/include/linux/compiler.h
  head/sys/ofed/include/linux/completion.h
  head/sys/ofed/include/linux/delay.h
  head/sys/ofed/include/linux/device.h
  head/sys/ofed/include/linux/dma-attrs.h
  head/sys/ofed/include/linux/dma-mapping.h
  head/sys/ofed/include/linux/dmapool.h
  head/sys/ofed/include/linux/err.h
  head/sys/ofed/include/linux/errno.h
  head/sys/ofed/include/linux/etherdevice.h
  head/sys/ofed/include/linux/file.h
  head/sys/ofed/include/linux/fs.h
  head/sys/ofed/include/linux/gfp.h
  head/sys/ofed/include/linux/hardirq.h
  head/sys/ofed/include/linux/idr.h
  head/sys/ofed/include/linux/if_arp.h
  head/sys/ofed/include/linux/if_ether.h
  head/sys/ofed/include/linux/if_vlan.h
  head/sys/ofed/include/linux/in.h
  head/sys/ofed/include/linux/in6.h
  head/sys/ofed/include/linux/inetdevice.h
  head/sys/ofed/include/linux/interrupt.h
  head/sys/ofed/include/linux/io-mapping.h
  head/sys/ofed/include/linux/io.h
  head/sys/ofed/include/linux/ioctl.h
  head/sys/ofed/include/linux/jhash.h
  head/sys/ofed/include/linux/jiffies.h
  head/sys/ofed/include/linux/kdev_t.h
  head/sys/ofed/include/linux/kernel.h
  head/sys/ofed/include/linux/kmod.h
  head/sys/ofed/include/linux/kobject.h
  head/sys/ofed/include/linux/kref.h
  head/sys/ofed/include/linux/kthread.h
  head/sys/ofed/include/linux/ktime.h
  head/sys/ofed/include/linux/linux_compat.c
  head/sys/ofed/include/linux/linux_idr.c
  head/sys/ofed/include/linux/linux_kmod.c
  head/sys/ofed/include/linux/linux_pci.c
  head/sys/ofed/include/linux/linux_radix.c
  head/sys/ofed/include/linux/list.h
  head/sys/ofed/include/linux/lockdep.h
  head/sys/ofed/include/linux/log2.h
  head/sys/ofed/include/linux/math64.h
  head/sys/ofed/include/linux/miscdevice.h
  head/sys/ofed/include/linux/mm.h
  head/sys/ofed/include/linux/module.h
  head/sys/ofed/include/linux/moduleparam.h
  head/sys/ofed/include/linux/mutex.h
  head/sys/ofed/include/linux/net.h
  head/sys/ofed/include/linux/netdevice.h
  head/sys/ofed/include/linux/notifier.h
  head/sys/ofed/include/linux/page.h
  head/sys/ofed/include/linux/pci.h
  head/sys/ofed/include/linux/poll.h
  head/sys/ofed/include/linux/printk.h
  head/sys/ofed/include/linux/radix-tree.h
  head/sys/ofed/include/linux/random.h
  head/sys/ofed/include/linux/rbtree.h
  head/sys/ofed/include/linux/rwlock.h
  head/sys/ofed/include/linux/rwsem.h
  head/sys/ofed/include/linux/scatterlist.h
  head/sys/ofed/include/linux/sched.h
  head/sys/ofed/include/linux/semaphore.h
  head/sys/ofed/include/linux/slab.h
  head/sys/ofed/include/linux/socket.h
  head/sys/ofed/include/linux/spinlock.h
  head/sys/ofed/include/linux/string.h
  head/sys/ofed/include/linux/sysfs.h
  head/sys/ofed/include/linux/time.h
  head/sys/ofed/include/linux/timer.h
  head/sys/ofed/include/linux/types.h
  head/sys/ofed/include/linux/uaccess.h
  head/sys/ofed/include/linux/vmalloc.h
  head/sys/ofed/include/linux/wait.h
  head/sys/ofed/include/linux/workqueue.h
  head/sys/ofed/include/net/
Modified:
  head/sys/conf/NOTES
  head/sys/conf/files
  head/sys/conf/kern.pre.mk
  head/sys/dev/usb/usb_device.c
  head/sys/dev/usb/usb_dynamic.c
  head/sys/dev/usb/usb_dynamic.h
  head/sys/modules/cxgb/iw_cxgb/Makefile
  head/sys/modules/cxgbe/iw_cxgbe/Makefile
  head/sys/modules/ibcore/Makefile
  head/sys/modules/ipoib/Makefile
  head/sys/modules/linuxkpi/Makefile
  head/sys/modules/mlx4/Makefile
  head/sys/modules/mlx4ib/Makefile
  head/sys/modules/mlxen/Makefile
  head/sys/modules/mthca/Makefile
  head/sys/modules/rdma/krping/Makefile
  head/sys/modules/usb/usb/Makefile
  head/sys/sys/param.h

Copied: head/sys/compat/linuxkpi/common/include/asm/atomic-long.h (from r290045, head/sys/ofed/include/asm/atomic-long.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/compat/linuxkpi/common/include/asm/atomic-long.h	Thu Oct 29 08:28:39 2015	(r290135, copy of r290045, head/sys/ofed/include/asm/atomic-long.h)
@@ -0,0 +1,82 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_ATOMIC_LONG_H_
+#define	_ATOMIC_LONG_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <machine/atomic.h>
+
+typedef struct {
+	volatile u_long counter;
+} atomic_long_t;
+
+#define	atomic_long_add(i, v)		atomic_long_add_return((i), (v))
+#define	atomic_long_inc_return(v)	atomic_long_add_return(1, (v))
+
+static inline long
+atomic_long_add_return(long i, atomic_long_t *v)
+{
+	return i + atomic_fetchadd_long(&v->counter, i);
+}
+
+static inline void
+atomic_long_set(atomic_long_t *v, long i)
+{
+	atomic_store_rel_long(&v->counter, i);
+}
+
+static inline long
+atomic_long_read(atomic_long_t *v)
+{
+	return atomic_load_acq_long(&v->counter);
+}
+
+static inline long
+atomic_long_inc(atomic_long_t *v)
+{
+	return atomic_fetchadd_long(&v->counter, 1) + 1;
+}
+
+static inline long
+atomic_long_dec(atomic_long_t *v)
+{
+	return atomic_fetchadd_long(&v->counter, -1) - 1;
+}
+
+static inline long
+atomic_long_dec_and_test(atomic_long_t *v)
+{
+	long i = atomic_long_add(-1, v);
+	return i == 0 ;
+}
+
+#endif	/* _ATOMIC_LONG_H_ */

Copied: head/sys/compat/linuxkpi/common/include/asm/atomic.h (from r290042, head/sys/ofed/include/asm/atomic.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/compat/linuxkpi/common/include/asm/atomic.h	Thu Oct 29 08:28:39 2015	(r290135, copy of r290042, head/sys/ofed/include/asm/atomic.h)
@@ -0,0 +1,107 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_ASM_ATOMIC_H_
+#define	_ASM_ATOMIC_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <machine/atomic.h>
+
+typedef struct {
+	volatile u_int counter;
+} atomic_t;
+
+#define	atomic_add(i, v)		atomic_add_return((i), (v))
+#define	atomic_sub(i, v)		atomic_sub_return((i), (v))
+#define	atomic_inc_return(v)		atomic_add_return(1, (v))
+#define	atomic_add_negative(i, v)	(atomic_add_return((i), (v)) < 0)
+#define	atomic_sub_and_test(i, v)	(atomic_sub_return((i), (v)) == 0)
+#define	atomic_dec_and_test(v)		(atomic_sub_return(1, (v)) == 0)
+#define	atomic_inc_and_test(v)		(atomic_add_return(1, (v)) == 0)
+#define atomic_dec_return(v)             atomic_sub_return(1, (v))
+
+static inline int
+atomic_add_return(int i, atomic_t *v)
+{
+	return i + atomic_fetchadd_int(&v->counter, i);
+}
+
+static inline int
+atomic_sub_return(int i, atomic_t *v)
+{
+	return atomic_fetchadd_int(&v->counter, -i) - i;
+}
+
+static inline void
+atomic_set(atomic_t *v, int i)
+{
+	atomic_store_rel_int(&v->counter, i);
+}
+
+static inline int
+atomic_read(atomic_t *v)
+{
+	return atomic_load_acq_int(&v->counter);
+}
+
+static inline int
+atomic_inc(atomic_t *v)
+{
+	return atomic_fetchadd_int(&v->counter, 1) + 1;
+}
+
+static inline int
+atomic_dec(atomic_t *v)
+{
+	return atomic_fetchadd_int(&v->counter, -1) - 1;
+}
+
+static inline int atomic_add_unless(atomic_t *v, int a, int u)
+{
+        int c, old;
+        c = atomic_read(v);
+        for (;;) {
+                if (unlikely(c == (u)))
+                        break;
+                old = atomic_cmpset_int(&v->counter, c, c + (a));
+                if (likely(old == c))
+                        break;
+                c = old;
+        }
+        return c != (u);
+}
+
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+
+
+
+
+#endif	/* _ASM_ATOMIC_H_ */

Copied: head/sys/compat/linuxkpi/common/include/asm/byteorder.h (from r290042, head/sys/ofed/include/asm/byteorder.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/compat/linuxkpi/common/include/asm/byteorder.h	Thu Oct 29 08:28:39 2015	(r290135, copy of r290042, head/sys/ofed/include/asm/byteorder.h)
@@ -0,0 +1,94 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_ASM_BYTEORDER_H_
+#define	_ASM_BYTEORDER_H_
+
+#include <sys/types.h>
+#include <sys/endian.h>
+#include <asm/types.h>
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define	__LITTLE_ENDIAN
+#else
+#define	__BIG_ENDIAN
+#endif
+
+#define	cpu_to_le64	htole64
+#define	le64_to_cpu	le64toh
+#define	cpu_to_le32	htole32
+#define	le32_to_cpu	le32toh
+#define	cpu_to_le16	htole16
+#define	le16_to_cpu	le16toh
+#define	cpu_to_be64	htobe64
+#define	be64_to_cpu	be64toh
+#define	cpu_to_be32	htobe32
+#define	be32_to_cpu	be32toh
+#define	cpu_to_be16	htobe16
+#define	be16_to_cpu	be16toh
+#define	__be16_to_cpu	be16toh
+
+#define	cpu_to_le64p(x)	htole64(*((uint64_t *)x))
+#define	le64_to_cpup(x)	le64toh(*((uint64_t *)x))
+#define	cpu_to_le32p(x)	htole32(*((uint32_t *)x))
+#define	le32_to_cpup(x)	le32toh(*((uint32_t *)x))
+#define	cpu_to_le16p(x)	htole16(*((uint16_t *)x))
+#define	le16_to_cpup(x)	le16toh(*((uint16_t *)x))
+#define	cpu_to_be64p(x)	htobe64(*((uint64_t *)x))
+#define	be64_to_cpup(x)	be64toh(*((uint64_t *)x))
+#define	cpu_to_be32p(x)	htobe32(*((uint32_t *)x))
+#define	be32_to_cpup(x)	be32toh(*((uint32_t *)x))
+#define	cpu_to_be16p(x)	htobe16(*((uint16_t *)x))
+#define	be16_to_cpup(x)	be16toh(*((uint16_t *)x))
+
+#define	cpu_to_le64s(x)	do { *((uint64_t *)x) = cpu_to_le64p((x)) } while (0)
+#define	le64_to_cpus(x)	do { *((uint64_t *)x) = le64_to_cpup((x)) } while (0)
+#define	cpu_to_le32s(x)	do { *((uint32_t *)x) = cpu_to_le32p((x)) } while (0)
+#define	le32_to_cpus(x)	do { *((uint32_t *)x) = le32_to_cpup((x)) } while (0)
+#define	cpu_to_le16s(x)	do { *((uint16_t *)x) = cpu_to_le16p((x)) } while (0)
+#define	le16_to_cpus(x)	do { *((uint16_t *)x) = le16_to_cpup((x)) } while (0)
+#define	cpu_to_be64s(x)	do { *((uint64_t *)x) = cpu_to_be64p((x)) } while (0)
+#define	be64_to_cpus(x)	do { *((uint64_t *)x) = be64_to_cpup((x)) } while (0)
+#define	cpu_to_be32s(x)	do { *((uint32_t *)x) = cpu_to_be32p((x)) } while (0)
+#define	be32_to_cpus(x)	do { *((uint32_t *)x) = be32_to_cpup((x)) } while (0)
+#define	cpu_to_be16s(x)	do { *((uint16_t *)x) = cpu_to_be16p((x)) } while (0)
+#define	be16_to_cpus(x)	do { *((uint16_t *)x) = be16_to_cpup((x)) } while (0)
+
+#define	swab16	bswap16
+#define	swab32	bswap32
+#define	swab64	bswap64
+
+static inline void
+be16_add_cpu(u16 *var, u16 val)
+{ 
+	*var = cpu_to_be16(be16_to_cpu(*var) + val);
+}
+
+#endif	/* _ASM_BYTEORDER_H_ */

Copied: head/sys/compat/linuxkpi/common/include/asm/fcntl.h (from r290042, head/sys/ofed/include/asm/fcntl.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/compat/linuxkpi/common/include/asm/fcntl.h	Thu Oct 29 08:28:39 2015	(r290135, copy of r290042, head/sys/ofed/include/asm/fcntl.h)
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef _ASM_FCNTL_H_
+#define	_ASM_FCNTL_H_
+
+#include <sys/fcntl.h>
+
+#endif	/* _ASM_FCNTL_H_ */

Copied: head/sys/compat/linuxkpi/common/include/asm/io.h (from r290042, head/sys/ofed/include/asm/io.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/compat/linuxkpi/common/include/asm/io.h	Thu Oct 29 08:28:39 2015	(r290135, copy of r290042, head/sys/ofed/include/asm/io.h)
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef _ASM_IO_H_
+#define _ASM_IO_H_
+
+#include <linux/io.h>
+
+#endif	/* _ASM_IO_H_ */

Copied: head/sys/compat/linuxkpi/common/include/asm/pgtable.h (from r290042, head/sys/ofed/include/asm/pgtable.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/compat/linuxkpi/common/include/asm/pgtable.h	Thu Oct 29 08:28:39 2015	(r290135, copy of r290042, head/sys/ofed/include/asm/pgtable.h)
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef _ASM_PGTABLE_H_
+#define	_ASM_PGTABLE_H_
+
+typedef int	pgprot_t;
+
+#endif	/* _ASM_PGTABLE_H_ */

Copied: head/sys/compat/linuxkpi/common/include/asm/types.h (from r290042, head/sys/ofed/include/asm/types.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/compat/linuxkpi/common/include/asm/types.h	Thu Oct 29 08:28:39 2015	(r290135, copy of r290042, head/sys/ofed/include/asm/types.h)
@@ -0,0 +1,62 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_ASM_TYPES_H_
+#define	_ASM_TYPES_H_
+
+#ifdef _KERNEL
+
+typedef uint8_t u8;
+typedef uint8_t __u8;
+typedef uint16_t u16;
+typedef uint16_t __u16;
+typedef uint32_t u32;
+typedef uint32_t __u32;
+typedef uint64_t u64;
+typedef uint64_t __u64;
+
+typedef int8_t s8;
+typedef int8_t __s8;
+typedef int16_t s16;
+typedef int16_t __s16;
+typedef int32_t s32;
+typedef int32_t __s32;
+typedef int64_t s64;
+typedef int64_t __s64;
+
+/* DMA addresses come in generic and 64-bit flavours.  */
+typedef vm_paddr_t dma_addr_t;
+typedef vm_paddr_t dma64_addr_t;
+
+typedef unsigned short umode_t;
+
+#endif	/* _KERNEL */
+
+#endif	/* _ASM_TYPES_H_ */

Copied: head/sys/compat/linuxkpi/common/include/asm/uaccess.h (from r290042, head/sys/ofed/include/asm/uaccess.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/compat/linuxkpi/common/include/asm/uaccess.h	Thu Oct 29 08:28:39 2015	(r290135, copy of r290042, head/sys/ofed/include/asm/uaccess.h)
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef _ASM_UACCESS_H_
+#define _ASM_UACCESS_H_
+
+#include <linux/uaccess.h>
+
+static inline long
+copy_to_user(void *to, const void *from, unsigned long n)
+{
+	if (copyout(from, to, n) != 0)
+		return n;
+	return 0;
+}
+
+static inline long
+copy_from_user(void *to, const void *from, unsigned long n)
+{
+	if (copyin(from, to, n) != 0)
+		return n;
+	return 0;
+}
+
+#endif	/* _ASM_UACCESS_H_ */

Copied: head/sys/compat/linuxkpi/common/include/linux/bitops.h (from r290042, head/sys/ofed/include/linux/bitops.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/compat/linuxkpi/common/include/linux/bitops.h	Thu Oct 29 08:28:39 2015	(r290135, copy of r290042, head/sys/ofed/include/linux/bitops.h)
@@ -0,0 +1,475 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef	_LINUX_BITOPS_H_
+#define	_LINUX_BITOPS_H_
+
+#include <sys/types.h>
+#include <sys/systm.h>
+
+#define	BIT(nr)			(1UL << (nr))
+#ifdef __LP64__
+#define	BITS_PER_LONG		64
+#else
+#define	BITS_PER_LONG		32
+#endif
+#define	BITMAP_FIRST_WORD_MASK(start)	(~0UL << ((start) % BITS_PER_LONG))
+#define	BITMAP_LAST_WORD_MASK(n)	(~0UL >> (BITS_PER_LONG - (n)))
+#define	BITS_TO_LONGS(n)	howmany((n), BITS_PER_LONG)
+#define	BIT_MASK(nr)		(1UL << ((nr) & (BITS_PER_LONG - 1)))
+#define BIT_WORD(nr)		((nr) / BITS_PER_LONG)
+#define	GENMASK(lo, hi)		(((2UL << ((hi) - (lo))) - 1UL) << (lo))
+#define BITS_PER_BYTE           8
+
+static inline int
+__ffs(int mask)
+{
+	return (ffs(mask) - 1);
+}
+
+static inline int
+__fls(int mask)
+{
+	return (fls(mask) - 1);
+}
+
+static inline int
+__ffsl(long mask)
+{
+	return (ffsl(mask) - 1);
+}
+
+static inline int
+__flsl(long mask)
+{
+	return (flsl(mask) - 1);
+}
+
+
+#define	ffz(mask)	__ffs(~(mask))
+
+static inline int get_count_order(unsigned int count)
+{
+        int order;
+
+        order = fls(count) - 1;
+        if (count & (count - 1))
+                order++;
+        return order;
+}
+
+static inline unsigned long
+find_first_bit(unsigned long *addr, unsigned long size)
+{
+	long mask;
+	int bit;
+
+	for (bit = 0; size >= BITS_PER_LONG;
+	    size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) {
+		if (*addr == 0)
+			continue;
+		return (bit + __ffsl(*addr));
+	}
+	if (size) {
+		mask = (*addr) & BITMAP_LAST_WORD_MASK(size);
+		if (mask)
+			bit += __ffsl(mask);
+		else
+			bit += size;
+	}
+	return (bit);
+}
+
+static inline unsigned long
+find_first_zero_bit(unsigned long *addr, unsigned long size)
+{
+	long mask;
+	int bit;
+
+	for (bit = 0; size >= BITS_PER_LONG;
+	    size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) {
+		if (~(*addr) == 0)
+			continue;
+		return (bit + __ffsl(~(*addr)));
+	}
+	if (size) {
+		mask = ~(*addr) & BITMAP_LAST_WORD_MASK(size);
+		if (mask)
+			bit += __ffsl(mask);
+		else
+			bit += size;
+	}
+	return (bit);
+}
+
+static inline unsigned long
+find_last_bit(unsigned long *addr, unsigned long size)
+{
+	long mask;
+	int offs;
+	int bit;
+	int pos;
+
+	pos = size / BITS_PER_LONG;
+	offs = size % BITS_PER_LONG;
+	bit = BITS_PER_LONG * pos;
+	addr += pos;
+	if (offs) {
+		mask = (*addr) & BITMAP_LAST_WORD_MASK(offs);
+		if (mask)
+			return (bit + __flsl(mask));
+	}
+	while (--pos) {
+		addr--;
+		bit -= BITS_PER_LONG;
+		if (*addr)
+			return (bit + __flsl(mask));
+	}
+	return (size);
+}
+
+static inline unsigned long
+find_next_bit(unsigned long *addr, unsigned long size, unsigned long offset)
+{
+	long mask;
+	int offs;
+	int bit;
+	int pos;
+
+	if (offset >= size)
+		return (size);
+	pos = offset / BITS_PER_LONG;
+	offs = offset % BITS_PER_LONG;
+	bit = BITS_PER_LONG * pos;
+	addr += pos;
+	if (offs) {
+		mask = (*addr) & ~BITMAP_LAST_WORD_MASK(offs);
+		if (mask)
+			return (bit + __ffsl(mask));
+		if (size - bit <= BITS_PER_LONG)
+			return (size);
+		bit += BITS_PER_LONG;
+		addr++;
+	}
+	for (size -= bit; size >= BITS_PER_LONG;
+	    size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) {
+		if (*addr == 0)
+			continue;
+		return (bit + __ffsl(*addr));
+	}
+	if (size) {
+		mask = (*addr) & BITMAP_LAST_WORD_MASK(size);
+		if (mask)
+			bit += __ffsl(mask);
+		else
+			bit += size;
+	}
+	return (bit);
+}
+
+static inline unsigned long
+find_next_zero_bit(unsigned long *addr, unsigned long size,
+    unsigned long offset)
+{
+	long mask;
+	int offs;
+	int bit;
+	int pos;
+
+	if (offset >= size)
+		return (size);
+	pos = offset / BITS_PER_LONG;
+	offs = offset % BITS_PER_LONG;
+	bit = BITS_PER_LONG * pos;
+	addr += pos;
+	if (offs) {
+		mask = ~(*addr) & ~BITMAP_LAST_WORD_MASK(offs);
+		if (mask)
+			return (bit + __ffsl(mask));
+		if (size - bit <= BITS_PER_LONG)
+			return (size);
+		bit += BITS_PER_LONG;
+		addr++;
+	}
+	for (size -= bit; size >= BITS_PER_LONG;
+	    size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) {
+		if (~(*addr) == 0)
+			continue;
+		return (bit + __ffsl(~(*addr)));
+	}
+	if (size) {
+		mask = ~(*addr) & BITMAP_LAST_WORD_MASK(size);
+		if (mask)
+			bit += __ffsl(mask);
+		else
+			bit += size;
+	}
+	return (bit);
+}
+
+static inline void
+bitmap_zero(unsigned long *addr, int size)
+{
+	int len;
+
+	len = BITS_TO_LONGS(size) * sizeof(long);
+	memset(addr, 0, len);
+}
+
+static inline void
+bitmap_fill(unsigned long *addr, int size)
+{
+	int tail;
+	int len;
+
+	len = (size / BITS_PER_LONG) * sizeof(long);
+	memset(addr, 0xff, len);
+	tail = size & (BITS_PER_LONG - 1);
+	if (tail) 
+		addr[size / BITS_PER_LONG] = BITMAP_LAST_WORD_MASK(tail);
+}
+
+static inline int
+bitmap_full(unsigned long *addr, int size)
+{
+	unsigned long mask;
+	int tail;
+	int len;
+	int i;
+
+	len = size / BITS_PER_LONG;
+	for (i = 0; i < len; i++)
+		if (addr[i] != ~0UL)
+			return (0);
+	tail = size & (BITS_PER_LONG - 1);
+	if (tail) {
+		mask = BITMAP_LAST_WORD_MASK(tail);
+		if ((addr[i] & mask) != mask)
+			return (0);
+	}
+	return (1);
+}
+
+static inline int
+bitmap_empty(unsigned long *addr, int size)
+{
+	unsigned long mask;
+	int tail;
+	int len;
+	int i;
+
+	len = size / BITS_PER_LONG;
+	for (i = 0; i < len; i++)
+		if (addr[i] != 0)
+			return (0);
+	tail = size & (BITS_PER_LONG - 1);
+	if (tail) {
+		mask = BITMAP_LAST_WORD_MASK(tail);
+		if ((addr[i] & mask) != 0)
+			return (0);
+	}
+	return (1);
+}
+
+#define	__set_bit(i, a)							\
+    atomic_set_long(&((volatile long *)(a))[BIT_WORD(i)], BIT_MASK(i))
+
+#define	set_bit(i, a)							\
+    atomic_set_long(&((volatile long *)(a))[BIT_WORD(i)], BIT_MASK(i))
+
+#define	__clear_bit(i, a)						\
+    atomic_clear_long(&((volatile long *)(a))[BIT_WORD(i)], BIT_MASK(i))
+
+#define	clear_bit(i, a)							\
+    atomic_clear_long(&((volatile long *)(a))[BIT_WORD(i)], BIT_MASK(i))
+
+#define	test_bit(i, a)							\
+    !!(atomic_load_acq_long(&((volatile long *)(a))[BIT_WORD(i)]) &	\
+    BIT_MASK(i))
+
+static inline long
+test_and_clear_bit(long bit, long *var)
+{
+	long val;
+
+	var += BIT_WORD(bit);
+	bit %= BITS_PER_LONG;
+	bit = (1UL << bit);
+	do {
+		val = *(volatile long *)var;
+	} while (atomic_cmpset_long(var, val, val & ~bit) == 0);
+
+	return !!(val & bit);
+}
+
+static inline long
+test_and_set_bit(long bit, long *var)
+{
+	long val;
+
+	var += BIT_WORD(bit);
+	bit %= BITS_PER_LONG;
+	bit = (1UL << bit);
+	do {
+		val = *(volatile long *)var;
+	} while (atomic_cmpset_long(var, val, val | bit) == 0);
+
+	return !!(val & bit);
+}
+
+static inline void
+bitmap_set(unsigned long *map, int start, int nr)
+{
+	unsigned long *p = map + BIT_WORD(start);
+	const int size = start + nr;
+	int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
+	unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);
+
+	while (nr - bits_to_set >= 0) {
+		*p |= mask_to_set;
+		nr -= bits_to_set;
+		bits_to_set = BITS_PER_LONG;
+		mask_to_set = ~0UL;
+		p++;
+	}
+	if (nr) {
+		mask_to_set &= BITMAP_LAST_WORD_MASK(size);
+		*p |= mask_to_set;
+	}
+}
+
+static inline void
+bitmap_clear(unsigned long *map, int start, int nr)
+{
+	unsigned long *p = map + BIT_WORD(start);
+	const int size = start + nr;
+	int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
+	unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
+
+	while (nr - bits_to_clear >= 0) {
+		*p &= ~mask_to_clear;
+		nr -= bits_to_clear;
+		bits_to_clear = BITS_PER_LONG;
+		mask_to_clear = ~0UL;
+		p++;
+	}
+	if (nr) {
+		mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
+		*p &= ~mask_to_clear;
+	}
+}
+
+enum {
+        REG_OP_ISFREE,
+        REG_OP_ALLOC,
+        REG_OP_RELEASE,
+};
+
+static int __reg_op(unsigned long *bitmap, int pos, int order, int reg_op)
+{
+        int nbits_reg;
+        int index;
+        int offset;
+        int nlongs_reg;
+        int nbitsinlong;
+        unsigned long mask;
+        int i;
+        int ret = 0;
+
+        nbits_reg = 1 << order;
+        index = pos / BITS_PER_LONG;
+        offset = pos - (index * BITS_PER_LONG);
+        nlongs_reg = BITS_TO_LONGS(nbits_reg);
+        nbitsinlong = min(nbits_reg,  BITS_PER_LONG);
+
+        mask = (1UL << (nbitsinlong - 1));
+        mask += mask - 1;
+        mask <<= offset;
+
+        switch (reg_op) {
+        case REG_OP_ISFREE:
+                for (i = 0; i < nlongs_reg; i++) {
+                        if (bitmap[index + i] & mask)
+                                goto done;
+                }
+                ret = 1;
+                break;
+
+        case REG_OP_ALLOC:
+                for (i = 0; i < nlongs_reg; i++)
+                        bitmap[index + i] |= mask;
+                break;
+
+        case REG_OP_RELEASE:
+                for (i = 0; i < nlongs_reg; i++)
+                        bitmap[index + i] &= ~mask;
+                break;
+        }
+done:
+        return ret;
+}
+
+static inline int 
+bitmap_find_free_region(unsigned long *bitmap, int bits, int order)
+{
+        int pos;
+        int end;
+
+        for (pos = 0 ; (end = pos + (1 << order)) <= bits; pos = end) {
+                if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
+                        continue;
+                __reg_op(bitmap, pos, order, REG_OP_ALLOC);
+                return pos;
+        }
+        return -ENOMEM;
+}
+
+static inline int
+bitmap_allocate_region(unsigned long *bitmap, int pos, int order)
+{
+        if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
+                return -EBUSY;
+        __reg_op(bitmap, pos, order, REG_OP_ALLOC);
+        return 0;
+}
+
+static inline void 
+bitmap_release_region(unsigned long *bitmap, int pos, int order)
+{
+        __reg_op(bitmap, pos, order, REG_OP_RELEASE);
+}
+

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-all mailing list