]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Finish process of moving the LinuxKPI module into the default kernel build.
authorhselasky <hselasky@FreeBSD.org>
Thu, 29 Oct 2015 08:28:39 +0000 (08:28 +0000)
committerhselasky <hselasky@FreeBSD.org>
Thu, 29 Oct 2015 08:28:39 +0000 (08:28 +0000)
- 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

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

diff --git a/sys/compat/linuxkpi/common/include/asm/atomic-long.h b/sys/compat/linuxkpi/common/include/asm/atomic-long.h
new file mode 100644 (file)
index 0000000..f522af8
--- /dev/null
@@ -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_ */
diff --git a/sys/compat/linuxkpi/common/include/asm/atomic.h b/sys/compat/linuxkpi/common/include/asm/atomic.h
new file mode 100644 (file)
index 0000000..fc22a39
--- /dev/null
@@ -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_ */
diff --git a/sys/compat/linuxkpi/common/include/asm/byteorder.h b/sys/compat/linuxkpi/common/include/asm/byteorder.h
new file mode 100644 (file)
index 0000000..7168e49
--- /dev/null
@@ -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_ */
diff --git a/sys/compat/linuxkpi/common/include/asm/fcntl.h b/sys/compat/linuxkpi/common/include/asm/fcntl.h
new file mode 100644 (file)
index 0000000..f24624e
--- /dev/null
@@ -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_ */
diff --git a/sys/compat/linuxkpi/common/include/asm/io.h b/sys/compat/linuxkpi/common/include/asm/io.h
new file mode 100644 (file)
index 0000000..24d350f
--- /dev/null
@@ -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_ */
diff --git a/sys/compat/linuxkpi/common/include/asm/pgtable.h b/sys/compat/linuxkpi/common/include/asm/pgtable.h
new file mode 100644 (file)
index 0000000..7bdab1c
--- /dev/null
@@ -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_ */
diff --git a/sys/compat/linuxkpi/common/include/asm/types.h b/sys/compat/linuxkpi/common/include/asm/types.h
new file mode 100644 (file)
index 0000000..fb2fd56
--- /dev/null
@@ -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_ */
diff --git a/sys/compat/linuxkpi/common/include/asm/uaccess.h b/sys/compat/linuxkpi/common/include/asm/uaccess.h
new file mode 100644 (file)
index 0000000..ce90355
--- /dev/null
@@ -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_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/bitops.h b/sys/compat/linuxkpi/common/include/linux/bitops.h
new file mode 100644 (file)
index 0000000..8b985a9
--- /dev/null
@@ -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);
+}
+
+
+#define for_each_set_bit(bit, addr, size) \
+       for ((bit) = find_first_bit((addr), (size));            \
+            (bit) < (size);                                    \
+            (bit) = find_next_bit((addr), (size), (bit) + 1))
+
+#endif /* _LINUX_BITOPS_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/cache.h b/sys/compat/linuxkpi/common/include/linux/cache.h
new file mode 100644 (file)
index 0000000..a269e55
--- /dev/null
@@ -0,0 +1,37 @@
+/*-
+ * 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        _LINUX_CACHE_H_
+#define _LINUX_CACHE_H_
+
+#define        cache_line_size()       CACHE_LINE_SIZE
+#define        L1_CACHE_BYTES          CACHE_LINE_SIZE
+
+#endif /* _LINUX_CACHE_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/cdev.h b/sys/compat/linuxkpi/common/include/linux/cdev.h
new file mode 100644 (file)
index 0000000..9d5b3fb
--- /dev/null
@@ -0,0 +1,131 @@
+/*-
+ * 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        _LINUX_CDEV_H_
+#define        _LINUX_CDEV_H_
+
+#include <linux/kobject.h>
+#include <linux/kdev_t.h>
+#include <linux/list.h>
+
+struct file_operations;
+struct inode;
+struct module;
+
+extern struct cdevsw linuxcdevsw;
+
+struct linux_cdev {
+       struct kobject  kobj;
+       struct module   *owner;
+       struct cdev     *cdev;
+       dev_t           dev;
+       const struct file_operations *ops;
+};
+
+static inline void
+cdev_release(struct kobject *kobj)
+{
+       struct linux_cdev *cdev;
+
+       cdev = container_of(kobj, struct linux_cdev, kobj);
+       if (cdev->cdev)
+               destroy_dev(cdev->cdev);
+       kfree(cdev);
+}
+
+static inline void
+cdev_static_release(struct kobject *kobj)
+{
+       struct linux_cdev *cdev;
+
+       cdev = container_of(kobj, struct linux_cdev, kobj);
+       if (cdev->cdev)
+               destroy_dev(cdev->cdev);
+}
+
+static struct kobj_type cdev_ktype = {
+       .release = cdev_release,
+};
+
+static struct kobj_type cdev_static_ktype = {
+       .release = cdev_static_release,
+};
+
+static inline void
+cdev_init(struct linux_cdev *cdev, const struct file_operations *ops)
+{
+
+       kobject_init(&cdev->kobj, &cdev_static_ktype);
+       cdev->ops = ops;
+}
+
+static inline struct linux_cdev *
+cdev_alloc(void)
+{
+       struct linux_cdev *cdev;
+
+       cdev = kzalloc(sizeof(struct linux_cdev), M_WAITOK);
+       if (cdev)
+               kobject_init(&cdev->kobj, &cdev_ktype);
+       return (cdev);
+}
+
+static inline void
+cdev_put(struct linux_cdev *p)
+{
+       kobject_put(&p->kobj);
+}
+
+static inline int
+cdev_add(struct linux_cdev *cdev, dev_t dev, unsigned count)
+{
+       if (count != 1)
+               panic("cdev_add: Unsupported count: %d", count);
+       cdev->cdev = make_dev(&linuxcdevsw, MINOR(dev), 0, 0, 0700, 
+           "%s", kobject_name(&cdev->kobj));
+       cdev->dev = dev;
+       cdev->cdev->si_drv1 = cdev;
+
+       return (0);
+}
+
+static inline void
+cdev_del(struct linux_cdev *cdev)
+{
+       if (cdev->cdev) {
+               destroy_dev(cdev->cdev);
+               cdev->cdev = NULL;
+       }
+       kobject_put(&cdev->kobj);
+}
+
+#define        cdev    linux_cdev
+
+#endif /* _LINUX_CDEV_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/clocksource.h b/sys/compat/linuxkpi/common/include/linux/clocksource.h
new file mode 100644 (file)
index 0000000..7a4835c
--- /dev/null
@@ -0,0 +1,38 @@
+/*-
+ * 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 _LINUX_CLOCKSOURCE_H
+#define _LINUX_CLOCKSOURCE_H
+
+/* clocksource cycle base type */
+typedef u64 cycle_t;
+
+
+#endif /* _LINUX_CLOCKSOURCE_H */
diff --git a/sys/compat/linuxkpi/common/include/linux/compat.h b/sys/compat/linuxkpi/common/include/linux/compat.h
new file mode 100644 (file)
index 0000000..74ce9ec
--- /dev/null
@@ -0,0 +1,38 @@
+/*-
+ * 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        _LINUX_COMPAT_H_
+#define        _LINUX_COMPAT_H_
+
+#define is_multicast_ether_addr(x) 0
+#define is_broadcast_ether_addr(x) 0
+
+
+#endif /* _LINUX_COMPAT_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/compiler.h b/sys/compat/linuxkpi/common/include/linux/compiler.h
new file mode 100644 (file)
index 0000000..6381358
--- /dev/null
@@ -0,0 +1,75 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
+ * Copyright (c) 2015 François Tigeot
+ * 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_COMPILER_H_
+#define        _LINUX_COMPILER_H_
+
+#include <sys/cdefs.h>
+
+#define __user
+#define __kernel
+#define __safe
+#define __force
+#define __nocast
+#define __iomem
+#define __chk_user_ptr(x)              0
+#define __chk_io_ptr(x)                        0
+#define __builtin_warning(x, y...)     (1)
+#define __acquires(x)
+#define __releases(x)
+#define __acquire(x)                   0
+#define __release(x)                   0
+#define __cond_lock(x,c)               (c)
+#define        __bitwise
+#define __devinitdata
+#define __init
+#define        __devinit
+#define        __devexit
+#define __exit
+#define        __stringify(x)                  #x
+#define        __attribute_const__             __attribute__((__const__))
+#undef __always_inline
+#define        __always_inline                 inline
+
+#define        likely(x)                       __builtin_expect(!!(x), 1)
+#define        unlikely(x)                     __builtin_expect(!!(x), 0)
+#define typeof(x)                      __typeof(x)
+
+#define        uninitialized_var(x)            x = x
+#define        __read_mostly __attribute__((__section__(".data.read_mostly")))
+#define        __always_unused                 __unused
+#define        __must_check                    __result_use_check
+
+#define        __printf(a,b)                   __printflike(a,b)
+
+#define        barrier()                       __asm__ __volatile__("": : :"memory")
+
+#endif /* _LINUX_COMPILER_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/completion.h b/sys/compat/linuxkpi/common/include/linux/completion.h
new file mode 100644 (file)
index 0000000..7cfb10d
--- /dev/null
@@ -0,0 +1,67 @@
+/*-
+ * 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        _LINUX_COMPLETION_H_
+#define        _LINUX_COMPLETION_H_
+
+#include <linux/errno.h>
+
+struct completion {
+       unsigned int done;
+};
+
+#define        INIT_COMPLETION(c) \
+       ((c).done = 0)
+#define        init_completion(c) \
+       ((c)->done = 0)
+#define        complete(c)                             \
+       linux_complete_common((c), 0)
+#define        complete_all(c)                         \
+       linux_complete_common((c), 1)
+#define        wait_for_completion(c)                  \
+       linux_wait_for_common((c), 0)
+#define        wait_for_completion_interuptible(c)     \
+       linux_wait_for_common((c), 1)
+#define        wait_for_completion_timeout(c, timeout) \
+       linux_wait_for_timeout_common((c), (timeout), 0)
+#define        wait_for_completion_interruptible_timeout(c, timeout)   \
+       linux_wait_for_timeout_common((c), (timeout), 1)
+#define        try_wait_for_completion(c) \
+       linux_try_wait_for_completion(c)
+#define        completion_done(c) \
+       linux_completion_done(c)
+
+extern void linux_complete_common(struct completion *, int);
+extern long linux_wait_for_common(struct completion *, int);
+extern long linux_wait_for_timeout_common(struct completion *, long, int);
+extern int linux_try_wait_for_completion(struct completion *);
+extern int linux_completion_done(struct completion *);
+
+#endif                                 /* _LINUX_COMPLETION_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/delay.h b/sys/compat/linuxkpi/common/include/linux/delay.h
new file mode 100644 (file)
index 0000000..da38662
--- /dev/null
@@ -0,0 +1,68 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
+ * Copyright (c) 2014 François Tigeot
+ * 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_DELAY_H_
+#define        _LINUX_DELAY_H_
+
+#include <linux/jiffies.h>
+#include <sys/systm.h>
+
+static inline void
+linux_msleep(int ms)
+{
+       pause("lnxsleep", msecs_to_jiffies(ms));
+}
+
+#undef msleep
+#define        msleep  linux_msleep
+
+#define        udelay(t)       DELAY(t)
+
+static inline void
+mdelay(unsigned long msecs)
+{
+       while (msecs--)
+               DELAY(1000);
+}
+
+static inline void
+ndelay(unsigned long x)
+{
+       DELAY(howmany(x, 1000));
+}
+
+static inline void
+usleep_range(unsigned long min, unsigned long max)
+{
+       DELAY(min);
+}
+
+#endif /* _LINUX_DELAY_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/device.h b/sys/compat/linuxkpi/common/include/linux/device.h
new file mode 100644 (file)
index 0000000..3459a5c
--- /dev/null
@@ -0,0 +1,424 @@
+/*-
+ * 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        _LINUX_DEVICE_H_
+#define        _LINUX_DEVICE_H_
+
+#include <linux/types.h>
+#include <linux/kobject.h>
+#include <linux/list.h>
+#include <linux/compiler.h>
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/workqueue.h>
+#include <linux/sysfs.h>
+#include <linux/kdev_t.h>
+#include <asm/atomic.h>
+
+#include <sys/bus.h>
+
+enum irqreturn { IRQ_NONE = 0, IRQ_HANDLED, IRQ_WAKE_THREAD, };
+typedef enum irqreturn irqreturn_t;
+
+struct class {
+       const char      *name;
+       struct module   *owner;
+       struct kobject  kobj;
+       devclass_t      bsdclass;
+       void            (*class_release)(struct class *class);
+       void            (*dev_release)(struct device *dev);
+       char *          (*devnode)(struct device *dev, umode_t *mode);
+};
+
+struct device {
+       struct device   *parent;
+       struct list_head irqents;
+       device_t        bsddev;
+       dev_t           devt;
+       struct class    *class;
+       void            (*release)(struct device *dev);
+       struct kobject  kobj;
+       uint64_t        *dma_mask;
+       void            *driver_data;
+       unsigned int    irq;
+       unsigned int    msix;
+       unsigned int    msix_max;
+};
+
+extern struct device linux_rootdev;
+extern struct kobject class_root;
+
+struct class_attribute {
+        struct attribute attr;
+        ssize_t (*show)(struct class *, struct class_attribute *, char *);
+        ssize_t (*store)(struct class *, struct class_attribute *, const char *, size_t);
+        const void *(*namespace)(struct class *, const struct class_attribute *);
+};
+
+#define        CLASS_ATTR(_name, _mode, _show, _store)                         \
+       struct class_attribute class_attr_##_name =                     \
+           { { #_name, NULL, _mode }, _show, _store }
+
+struct device_attribute {
+       struct attribute        attr;
+       ssize_t                 (*show)(struct device *,
+                                       struct device_attribute *, char *);
+       ssize_t                 (*store)(struct device *,
+                                       struct device_attribute *, const char *,
+                                       size_t);
+};
+
+#define        DEVICE_ATTR(_name, _mode, _show, _store)                        \
+       struct device_attribute dev_attr_##_name =                      \
+           { { #_name, NULL, _mode }, _show, _store }
+
+/* Simple class attribute that is just a static string */
+struct class_attribute_string {
+       struct class_attribute attr;
+       char *str;
+};
+
+static inline ssize_t
+show_class_attr_string(struct class *class,
+                               struct class_attribute *attr, char *buf)
+{
+       struct class_attribute_string *cs;
+       cs = container_of(attr, struct class_attribute_string, attr);
+       return snprintf(buf, PAGE_SIZE, "%s\n", cs->str);
+}
+
+/* Currently read-only only */
+#define _CLASS_ATTR_STRING(_name, _mode, _str) \
+       { __ATTR(_name, _mode, show_class_attr_string, NULL), _str }
+#define CLASS_ATTR_STRING(_name, _mode, _str) \
+       struct class_attribute_string class_attr_##_name = \
+               _CLASS_ATTR_STRING(_name, _mode, _str)
+
+#define        dev_err(dev, fmt, ...)  device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
+#define        dev_warn(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
+#define        dev_info(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
+#define        dev_printk(lvl, dev, fmt, ...)                                  \
+           device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
+
+static inline void *
+dev_get_drvdata(struct device *dev)
+{
+
+       return dev->driver_data;
+}
+
+static inline void
+dev_set_drvdata(struct device *dev, void *data)
+{
+
+       dev->driver_data = data;
+}
+
+static inline struct device *
+get_device(struct device *dev)
+{
+
+       if (dev)
+               kobject_get(&dev->kobj);
+
+       return (dev);
+}
+
+static inline char *
+dev_name(const struct device *dev)
+{
+
+       return kobject_name(&dev->kobj);
+}
+
+#define        dev_set_name(_dev, _fmt, ...)                                   \
+       kobject_set_name(&(_dev)->kobj, (_fmt), ##__VA_ARGS__)
+
+static inline void
+put_device(struct device *dev)
+{
+
+       if (dev)
+               kobject_put(&dev->kobj);
+}
+
+static inline ssize_t
+class_show(struct kobject *kobj, struct attribute *attr, char *buf)
+{
+       struct class_attribute *dattr;
+       ssize_t error;
+
+       dattr = container_of(attr, struct class_attribute, attr);
+       error = -EIO;
+       if (dattr->show)
+               error = dattr->show(container_of(kobj, struct class, kobj),
+                   dattr, buf);
+       return (error);
+}
+
+static inline ssize_t
+class_store(struct kobject *kobj, struct attribute *attr, const char *buf,
+    size_t count)
+{
+       struct class_attribute *dattr;
+       ssize_t error;
+
+       dattr = container_of(attr, struct class_attribute, attr);
+       error = -EIO;
+       if (dattr->store)
+               error = dattr->store(container_of(kobj, struct class, kobj),
+                   dattr, buf, count);
+       return (error);
+}
+
+static inline void
+class_release(struct kobject *kobj)
+{
+       struct class *class;
+
+       class = container_of(kobj, struct class, kobj);
+       if (class->class_release)
+               class->class_release(class);
+}
+
+static struct sysfs_ops class_sysfs = {
+       .show  = class_show,
+       .store = class_store,
+};
+static struct kobj_type class_ktype = {
+       .release = class_release,
+       .sysfs_ops = &class_sysfs
+};
+
+static inline int
+class_register(struct class *class)
+{
+
+       class->bsdclass = devclass_create(class->name);
+       kobject_init(&class->kobj, &class_ktype);
+       kobject_set_name(&class->kobj, class->name);
+       kobject_add(&class->kobj, &class_root, class->name);
+
+       return (0);
+}
+
+static inline void
+class_unregister(struct class *class)
+{
+
+       kobject_put(&class->kobj);
+}
+
+static inline void
+device_release(struct kobject *kobj)
+{
+       struct device *dev;
+
+       dev = container_of(kobj, struct device, kobj);
+       /* This is the precedence defined by linux. */
+       if (dev->release)
+               dev->release(dev);
+       else if (dev->class && dev->class->dev_release)
+               dev->class->dev_release(dev);
+}
+
+static inline ssize_t
+dev_show(struct kobject *kobj, struct attribute *attr, char *buf)
+{
+       struct device_attribute *dattr;
+       ssize_t error;
+
+       dattr = container_of(attr, struct device_attribute, attr);
+       error = -EIO;
+       if (dattr->show)
+               error = dattr->show(container_of(kobj, struct device, kobj),
+                   dattr, buf);
+       return (error);
+}
+
+static inline ssize_t
+dev_store(struct kobject *kobj, struct attribute *attr, const char *buf,
+    size_t count)
+{
+       struct device_attribute *dattr;
+       ssize_t error;
+
+       dattr = container_of(attr, struct device_attribute, attr);
+       error = -EIO;
+       if (dattr->store)
+               error = dattr->store(container_of(kobj, struct device, kobj),
+                   dattr, buf, count);
+       return (error);
+}
+
+static struct sysfs_ops dev_sysfs = { .show  = dev_show, .store = dev_store, };
+static struct kobj_type dev_ktype = {
+       .release = device_release,
+       .sysfs_ops = &dev_sysfs
+};
+
+/*
+ * Devices are registered and created for exporting to sysfs.  create
+ * implies register and register assumes the device fields have been
+ * setup appropriately before being called.
+ */
+static inline int
+device_register(struct device *dev)
+{
+       device_t bsddev;
+       int unit;
+
+       bsddev = NULL;
+       if (dev->devt) {
+               unit = MINOR(dev->devt);
+               bsddev = devclass_get_device(dev->class->bsdclass, unit);
+       } else
+               unit = -1;
+       if (bsddev == NULL)
+               bsddev = device_add_child(dev->parent->bsddev,
+                   dev->class->kobj.name, unit);
+       if (bsddev) {
+               if (dev->devt == 0)
+                       dev->devt = makedev(0, device_get_unit(bsddev));
+               device_set_softc(bsddev, dev);
+       }
+       dev->bsddev = bsddev;
+       kobject_init(&dev->kobj, &dev_ktype);
+       kobject_add(&dev->kobj, &dev->class->kobj, dev_name(dev));
+
+       return (0);
+}
+
+static inline void
+device_unregister(struct device *dev)
+{
+       device_t bsddev;
+
+       bsddev = dev->bsddev;
+       mtx_lock(&Giant);
+       if (bsddev)
+               device_delete_child(device_get_parent(bsddev), bsddev);
+       mtx_unlock(&Giant);
+       put_device(dev);
+}
+
+struct device *device_create(struct class *class, struct device *parent,
+           dev_t devt, void *drvdata, const char *fmt, ...);
+
+static inline void
+device_destroy(struct class *class, dev_t devt)
+{
+       device_t bsddev;
+       int unit;
+
+       unit = MINOR(devt);
+       bsddev = devclass_get_device(class->bsdclass, unit);
+       if (bsddev)
+               device_unregister(device_get_softc(bsddev));
+}
+
+static inline void
+class_kfree(struct class *class)
+{
+
+       kfree(class);
+}
+
+static inline struct class *
+class_create(struct module *owner, const char *name)
+{
+       struct class *class;
+       int error;
+
+       class = kzalloc(sizeof(*class), M_WAITOK);
+       class->owner = owner;
+       class->name= name;
+       class->class_release = class_kfree;
+       error = class_register(class);
+       if (error) {
+               kfree(class);
+               return (NULL);
+       }
+
+       return (class);
+}
+
+static inline void
+class_destroy(struct class *class)
+{
+
+       if (class == NULL)
+               return;
+       class_unregister(class);
+}
+
+static inline int
+device_create_file(struct device *dev, const struct device_attribute *attr)
+{
+
+       if (dev)
+               return sysfs_create_file(&dev->kobj, &attr->attr);
+       return -EINVAL;
+}
+
+static inline void
+device_remove_file(struct device *dev, const struct device_attribute *attr)
+{
+
+       if (dev)
+               sysfs_remove_file(&dev->kobj, &attr->attr);
+}
+
+static inline int
+class_create_file(struct class *class, const struct class_attribute *attr)
+{
+
+       if (class)
+               return sysfs_create_file(&class->kobj, &attr->attr);
+       return -EINVAL;
+}
+
+static inline void
+class_remove_file(struct class *class, const struct class_attribute *attr)
+{
+
+       if (class)
+               sysfs_remove_file(&class->kobj, &attr->attr);
+}
+
+static inline int dev_to_node(struct device *dev)
+{
+                return -1;
+}
+
+char *kvasprintf(gfp_t, const char *, va_list);
+char *kasprintf(gfp_t, const char *, ...);
+
+#endif /* _LINUX_DEVICE_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/dma-attrs.h b/sys/compat/linuxkpi/common/include/linux/dma-attrs.h
new file mode 100644 (file)
index 0000000..fda2282
--- /dev/null
@@ -0,0 +1,50 @@
+/*-
+ * 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        _LINUX_DMA_ATTR_H_
+#define        _LINUX_DMA_ATTR_H_
+
+enum dma_attr { DMA_ATTR_WRITE_BARRIER, DMA_ATTR_WEAK_ORDERING, DMA_ATTR_MAX, };
+
+#define __DMA_ATTRS_LONGS BITS_TO_LONGS(DMA_ATTR_MAX)
+
+struct dma_attrs {
+       unsigned long flags;
+};
+#define DEFINE_DMA_ATTRS(x) struct dma_attrs x = { }
+
+static inline void
+init_dma_attrs(struct dma_attrs *attrs)
+{
+       attrs->flags = 0;
+}
+
+#endif /* _LINUX_DMA_ATTR_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/dma-mapping.h b/sys/compat/linuxkpi/common/include/linux/dma-mapping.h
new file mode 100644 (file)
index 0000000..da08751
--- /dev/null
@@ -0,0 +1,281 @@
+/*-
+ * 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        _LINUX_DMA_MAPPING_H_
+#define _LINUX_DMA_MAPPING_H_
+
+#include <linux/types.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/dma-attrs.h>
+#include <linux/scatterlist.h>
+#include <linux/mm.h>
+#include <linux/page.h>
+
+#include <sys/systm.h>
+#include <sys/malloc.h>
+
+#include <vm/vm.h>
+#include <vm/vm_page.h>
+#include <vm/pmap.h>
+
+#include <machine/bus.h>
+#include <machine/pmap.h>
+
+enum dma_data_direction {
+       DMA_BIDIRECTIONAL = 0,
+       DMA_TO_DEVICE = 1,
+       DMA_FROM_DEVICE = 2,
+       DMA_NONE = 3,
+};
+
+struct dma_map_ops {
+       void* (*alloc_coherent)(struct device *dev, size_t size,
+           dma_addr_t *dma_handle, gfp_t gfp);
+       void (*free_coherent)(struct device *dev, size_t size,
+           void *vaddr, dma_addr_t dma_handle);
+       dma_addr_t (*map_page)(struct device *dev, struct page *page,
+           unsigned long offset, size_t size, enum dma_data_direction dir,
+           struct dma_attrs *attrs);
+       void (*unmap_page)(struct device *dev, dma_addr_t dma_handle,
+           size_t size, enum dma_data_direction dir, struct dma_attrs *attrs);
+       int (*map_sg)(struct device *dev, struct scatterlist *sg,
+           int nents, enum dma_data_direction dir, struct dma_attrs *attrs);
+       void (*unmap_sg)(struct device *dev, struct scatterlist *sg, int nents,
+           enum dma_data_direction dir, struct dma_attrs *attrs);
+       void (*sync_single_for_cpu)(struct device *dev, dma_addr_t dma_handle,
+           size_t size, enum dma_data_direction dir);
+       void (*sync_single_for_device)(struct device *dev,
+           dma_addr_t dma_handle, size_t size, enum dma_data_direction dir);
+       void (*sync_single_range_for_cpu)(struct device *dev,
+           dma_addr_t dma_handle, unsigned long offset, size_t size,
+           enum dma_data_direction dir);
+       void (*sync_single_range_for_device)(struct device *dev,
+           dma_addr_t dma_handle, unsigned long offset, size_t size,
+           enum dma_data_direction dir);
+       void (*sync_sg_for_cpu)(struct device *dev, struct scatterlist *sg,
+           int nents, enum dma_data_direction dir);
+       void (*sync_sg_for_device)(struct device *dev, struct scatterlist *sg,
+           int nents, enum dma_data_direction dir);
+       int (*mapping_error)(struct device *dev, dma_addr_t dma_addr);
+       int (*dma_supported)(struct device *dev, u64 mask);
+       int is_phys;
+};
+
+#define        DMA_BIT_MASK(n) ((2ULL << ((n) - 1)) - 1ULL)
+
+static inline int
+dma_supported(struct device *dev, u64 mask)
+{
+
+       /* XXX busdma takes care of this elsewhere. */
+       return (1);
+}
+static inline int
+dma_set_mask(struct device *dev, u64 dma_mask)
+{
+
+       if (!dev->dma_mask || !dma_supported(dev, dma_mask))
+               return -EIO;
+
+       *dev->dma_mask = dma_mask;
+       return (0);
+}
+
+static inline int
+dma_set_coherent_mask(struct device *dev, u64 mask)
+{
+
+       if (!dma_supported(dev, mask))
+               return -EIO;
+       /* XXX Currently we don't support a seperate coherent mask. */
+       return 0;
+}
+
+static inline void *
+dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
+    gfp_t flag)
+{
+       vm_paddr_t high;
+       size_t align;
+       void *mem;
+
+       if (dev->dma_mask)
+               high = *dev->dma_mask;
+       else
+               high = BUS_SPACE_MAXADDR_32BIT;
+       align = PAGE_SIZE << get_order(size);
+       mem = (void *)kmem_alloc_contig(kmem_arena, size, flag, 0, high, align,
+           0, VM_MEMATTR_DEFAULT);
+       if (mem)
+               *dma_handle = vtophys(mem);
+       else
+               *dma_handle = 0;
+       return (mem);
+}
+
+static inline void *
+dma_zalloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
+    gfp_t flag)
+{
+
+       return (dma_alloc_coherent(dev, size, dma_handle, flag | __GFP_ZERO));
+}
+                       
+static inline void
+dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
+    dma_addr_t dma_handle)
+{
+
+       kmem_free(kmem_arena, (vm_offset_t)cpu_addr, size);
+}
+
+/* XXX This only works with no iommu. */
+static inline dma_addr_t
+dma_map_single_attrs(struct device *dev, void *ptr, size_t size,
+    enum dma_data_direction dir, struct dma_attrs *attrs)
+{
+
+       return vtophys(ptr);
+}
+
+static inline void
+dma_unmap_single_attrs(struct device *dev, dma_addr_t addr, size_t size,
+    enum dma_data_direction dir, struct dma_attrs *attrs)
+{
+}
+
+static inline int
+dma_map_sg_attrs(struct device *dev, struct scatterlist *sgl, int nents,
+    enum dma_data_direction dir, struct dma_attrs *attrs)
+{
+       struct scatterlist *sg;
+       int i;
+       
+       for_each_sg(sgl, sg, nents, i)
+               sg_dma_address(sg) = sg_phys(sg);
+
+       return (nents);
+}
+
+static inline void
+dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg, int nents,
+    enum dma_data_direction dir, struct dma_attrs *attrs)
+{
+}
+static inline dma_addr_t
+dma_map_page(struct device *dev, struct page *page,
+    unsigned long offset, size_t size, enum dma_data_direction direction)
+{
+
+       return VM_PAGE_TO_PHYS(page) + offset;
+}
+
+static inline void
+dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
+    enum dma_data_direction direction)
+{
+}
+
+static inline void
+dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
+    enum dma_data_direction direction)
+{
+}
+
+static inline void
+dma_sync_single(struct device *dev, dma_addr_t addr, size_t size,
+    enum dma_data_direction dir)
+{
+       dma_sync_single_for_cpu(dev, addr, size, dir);
+}
+
+static inline void
+dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
+    size_t size, enum dma_data_direction direction)
+{
+}
+
+static inline void
+dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
+    enum dma_data_direction direction)
+{
+}
+
+static inline void
+dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
+    enum dma_data_direction direction)
+{
+}
+
+static inline void
+dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
+    unsigned long offset, size_t size, int direction)
+{
+}
+
+static inline void
+dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
+    unsigned long offset, size_t size, int direction)
+{
+}
+
+static inline int
+dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
+{
+
+       return (0);
+}
+
+static inline unsigned int dma_set_max_seg_size(struct device *dev,
+                                                 unsigned int size)
+{
+        return (0);
+}
+
+
+#define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, NULL)
+#define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, NULL)
+#define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, NULL)
+#define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, NULL)
+
+#define        DEFINE_DMA_UNMAP_ADDR(name)             dma_addr_t name
+#define        DEFINE_DMA_UNMAP_LEN(name)              __u32 name
+#define        dma_unmap_addr(p, name)                 ((p)->name)
+#define        dma_unmap_addr_set(p, name, v)          (((p)->name) = (v))
+#define        dma_unmap_len(p, name)                  ((p)->name)
+#define        dma_unmap_len_set(p, name, v)           (((p)->name) = (v))
+
+extern int uma_align_cache;
+#define        dma_get_cache_alignment()       uma_align_cache
+
+#endif /* _LINUX_DMA_MAPPING_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/dmapool.h b/sys/compat/linuxkpi/common/include/linux/dmapool.h
new file mode 100644 (file)
index 0000000..3ea2d5b
--- /dev/null
@@ -0,0 +1,87 @@
+/*-
+ * 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 _LINUX_DMAPOOL_H_
+#define        _LINUX_DMAPOOL_H_
+
+#include <linux/types.h>
+#include <linux/io.h>
+#include <linux/scatterlist.h>
+#include <linux/device.h>
+#include <linux/slab.h>
+
+struct dma_pool {
+       uma_zone_t      pool_zone;
+};
+
+static inline struct dma_pool *
+dma_pool_create(char *name, struct device *dev, size_t size,
+    size_t align, size_t boundary)
+{
+       struct dma_pool *pool;
+
+       pool = kmalloc(sizeof(*pool), GFP_KERNEL);
+       align--;
+       /*
+        * XXX Eventually this could use a seperate allocf to honor boundary
+        * and physical address requirements of the device.
+        */
+       pool->pool_zone = uma_zcreate(name, size, NULL, NULL, NULL, NULL,
+           align, UMA_ZONE_OFFPAGE|UMA_ZONE_HASH);
+
+       return (pool);
+}
+
+static inline void
+dma_pool_destroy(struct dma_pool *pool)
+{
+       uma_zdestroy(pool->pool_zone);
+       kfree(pool);
+}
+
+static inline void *
+dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags, dma_addr_t *handle)
+{
+       void *vaddr;
+
+       vaddr = uma_zalloc(pool->pool_zone, mem_flags);
+       if (vaddr)
+               *handle = vtophys(vaddr);
+       return (vaddr);
+}
+
+static inline void
+dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr)
+{
+       uma_zfree(pool->pool_zone, vaddr);
+}
+
+
+#endif /* _LINUX_DMAPOOL_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/err.h b/sys/compat/linuxkpi/common/include/linux/err.h
new file mode 100644 (file)
index 0000000..2366130
--- /dev/null
@@ -0,0 +1,79 @@
+/*-
+ * 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_ERR_H_
+#define        _LINUX_ERR_H_
+
+#define MAX_ERRNO      4095
+
+#define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO)
+
+static inline void *
+ERR_PTR(long error)
+{
+       return (void *)error;
+}
+
+static inline long
+PTR_ERR(const void *ptr)
+{
+       return (long)ptr;
+}
+
+static inline long
+IS_ERR(const void *ptr)
+{
+       return IS_ERR_VALUE((unsigned long)ptr);
+}
+
+static inline long
+IS_ERR_OR_NULL(const void *ptr)
+{
+       return !ptr || IS_ERR_VALUE((unsigned long)ptr);
+}
+
+static inline void *
+ERR_CAST(void *ptr)
+{
+       return (void *)ptr;
+}
+
+static inline int
+PTR_ERR_OR_ZERO(const void *ptr)
+{
+        if (IS_ERR(ptr))
+                return PTR_ERR(ptr);
+        else
+                return 0;
+}
+
+#define PTR_RET(p) PTR_ERR_OR_ZERO(p)
+
+#endif /* _LINUX_ERR_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/errno.h b/sys/compat/linuxkpi/common/include/linux/errno.h
new file mode 100644 (file)
index 0000000..a043a3d
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * 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        _LINUX_ERRNO_H_
+#define        _LINUX_ERRNO_H_
+
+#include <sys/errno.h>
+
+#define        ECHRNG          EDOM
+#define        ETIME           ETIMEDOUT
+#define        ECOMM           ESTALE
+#define        ENODATA         ECONNREFUSED
+#define        ENOIOCTLCMD     ENOIOCTL
+#define        ERESTARTSYS     ERESTART
+#define        ENOTSUPP        EOPNOTSUPP
+#define        ENONET          EHOSTDOWN
+
+#endif                                 /* _LINUX_ERRNO_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/etherdevice.h b/sys/compat/linuxkpi/common/include/linux/etherdevice.h
new file mode 100644 (file)
index 0000000..12ea345
--- /dev/null
@@ -0,0 +1,62 @@
+/*-
+ * Copyright (c) 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_ETHERDEVICE
+#define        _LINUX_ETHERDEVICE
+
+#include <linux/types.h>
+
+static inline bool 
+is_zero_ether_addr(const u8 * addr)
+{
+       return ((addr[0] + addr[1] + addr[2] + addr[3] + addr[4] + addr[5]) == 0x00);
+}
+
+static inline bool 
+is_multicast_ether_addr(const u8 * addr)
+{
+       return (0x01 & addr[0]);
+}
+
+static inline bool 
+is_broadcast_ether_addr(const u8 * addr)
+{
+       return ((addr[0] + addr[1] + addr[2] + addr[3] + addr[4] + addr[5]) == (6 * 0xff));
+}
+
+static inline bool 
+is_valid_ether_addr(const u8 * addr)
+{
+       return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr);
+}
+
+static inline void 
+ether_addr_copy(u8 * dst, const u8 * src)
+{
+       memcpy(dst, src, 6);
+}
+
+#endif                                 /* _LINUX_ETHERDEVICE */
diff --git a/sys/compat/linuxkpi/common/include/linux/file.h b/sys/compat/linuxkpi/common/include/linux/file.h
new file mode 100644 (file)
index 0000000..b23c971
--- /dev/null
@@ -0,0 +1,160 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013 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_FILE_H_
+#define        _LINUX_FILE_H_
+
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/refcount.h>
+#include <sys/capsicum.h>
+#include <sys/proc.h>
+
+#include <linux/fs.h>
+
+struct linux_file;
+
+#undef file
+
+extern struct fileops linuxfileops;
+
+static inline struct linux_file *
+linux_fget(unsigned int fd)
+{
+       cap_rights_t rights;
+       struct file *file;
+
+       if (fget_unlocked(curthread->td_proc->p_fd, fd,
+           cap_rights_init(&rights), &file, NULL) != 0) {
+               return (NULL);
+       }
+       return (struct linux_file *)file->f_data;
+}
+
+static inline void
+fput(struct linux_file *filp)
+{
+       if (filp->_file == NULL) {
+               kfree(filp);
+               return;
+       }
+       if (refcount_release(&filp->_file->f_count)) {
+               _fdrop(filp->_file, curthread);
+               kfree(filp);
+       }
+}
+
+static inline void
+put_unused_fd(unsigned int fd)
+{
+       cap_rights_t rights;
+       struct file *file;
+
+       if (fget_unlocked(curthread->td_proc->p_fd, fd,
+           cap_rights_init(&rights), &file, NULL) != 0) {
+               return;
+       }
+       /*
+        * NOTE: We should only get here when the "fd" has not been
+        * installed, so no need to free the associated Linux file
+        * structure.
+        */
+       fdclose(curthread, file, fd);
+
+       /* drop extra reference */
+       fdrop(file, curthread);
+}
+
+static inline void
+fd_install(unsigned int fd, struct linux_file *filp)
+{
+       cap_rights_t rights;
+       struct file *file;
+
+       if (fget_unlocked(curthread->td_proc->p_fd, fd,
+           cap_rights_init(&rights), &file, NULL) != 0) {
+               file = NULL;
+       }
+       filp->_file = file;
+       finit(file, filp->f_mode, DTYPE_DEV, filp, &linuxfileops);
+
+       /* drop the extra reference */
+       fput(filp);
+}
+
+static inline int
+get_unused_fd(void)
+{
+       struct file *file;
+       int error;
+       int fd;
+
+       error = falloc(curthread, &file, &fd, 0);
+       if (error)
+               return -error;
+       /* drop the extra reference */
+       fdrop(file, curthread);
+       return fd;
+}
+
+static inline struct linux_file *
+alloc_file(int mode, const struct file_operations *fops)
+{
+       struct linux_file *filp;
+
+       filp = kzalloc(sizeof(*filp), GFP_KERNEL);
+       if (filp == NULL)
+               return (NULL);
+       filp->f_op = fops;
+       filp->f_mode = mode;
+
+       return filp;
+}
+
+struct fd {
+       struct linux_file *linux_file;
+};
+
+static inline void fdput(struct fd fd)
+{
+       fput(fd.linux_file);
+}
+
+static inline struct fd fdget(unsigned int fd)
+{
+       struct linux_file *f = linux_fget(fd);
+       return (struct fd){f};
+}
+
+#define        file    linux_file
+#define        fget    linux_fget
+
+#endif /* _LINUX_FILE_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/fs.h b/sys/compat/linuxkpi/common/include/linux/fs.h
new file mode 100644 (file)
index 0000000..797b816
--- /dev/null
@@ -0,0 +1,215 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013 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_FS_H_
+#define        _LINUX_FS_H_
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/vnode.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <linux/types.h>
+#include <linux/wait.h>
+#include <linux/semaphore.h>
+
+struct module;
+struct kiocb;
+struct iovec;
+struct dentry;
+struct page;
+struct file_lock;
+struct pipe_inode_info;
+struct vm_area_struct;
+struct poll_table_struct;
+struct files_struct;
+
+#define        inode   vnode
+#define        i_cdev  v_rdev
+
+#define        S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH)
+#define        S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH)
+
+
+typedef struct files_struct *fl_owner_t;
+
+struct dentry {
+       struct inode    *d_inode;
+};
+
+struct file_operations;
+
+struct linux_file {
+       struct file     *_file;
+       const struct file_operations    *f_op;
+       void            *private_data;
+       int             f_flags;
+       int             f_mode; /* Just starting mode. */
+       struct dentry   *f_dentry;
+       struct dentry   f_dentry_store;
+       struct selinfo  f_selinfo;
+       struct sigio    *f_sigio;
+       struct vnode    *f_vnode;
+};
+
+#define        file            linux_file
+#define        fasync_struct   sigio *
+
+#define        fasync_helper(fd, filp, on, queue)                              \
+({                                                                     \
+       if ((on))                                                       \
+               *(queue) = &(filp)->f_sigio;                            \
+       else                                                            \
+               *(queue) = NULL;                                        \
+       0;                                                              \
+})
+
+#define        kill_fasync(queue, sig, pollstat)                               \
+do {                                                                   \
+       if (*(queue) != NULL)                                           \
+               pgsigio(*(queue), (sig), 0);                            \
+} while (0)
+
+typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned);
+
+struct file_operations {
+       struct module *owner;
+       ssize_t (*read)(struct file *, char __user *, size_t, loff_t *);
+       ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *);
+       unsigned int (*poll) (struct file *, struct poll_table_struct *);
+       long (*unlocked_ioctl)(struct file *, unsigned int, unsigned long);
+       int (*mmap)(struct file *, struct vm_area_struct *);
+       int (*open)(struct inode *, struct file *);
+       int (*release)(struct inode *, struct file *);
+       int (*fasync)(int, struct file *, int);
+
+/* Although not supported in FreeBSD, to align with Linux code
+ * we are adding llseek() only when it is mapped to no_llseek which returns 
+ * an illegal seek error
+ */
+       loff_t (*llseek)(struct file *, loff_t, int);
+#if 0
+       /* We do not support these methods.  Don't permit them to compile. */
+       loff_t (*llseek)(struct file *, loff_t, int);
+       ssize_t (*aio_read)(struct kiocb *, const struct iovec *,
+           unsigned long, loff_t);
+       ssize_t (*aio_write)(struct kiocb *, const struct iovec *,
+           unsigned long, loff_t);
+       int (*readdir)(struct file *, void *, filldir_t);
+       int (*ioctl)(struct inode *, struct file *, unsigned int,
+           unsigned long);
+       long (*compat_ioctl)(struct file *, unsigned int, unsigned long);
+       int (*flush)(struct file *, fl_owner_t id);
+       int (*fsync)(struct file *, struct dentry *, int datasync);
+       int (*aio_fsync)(struct kiocb *, int datasync);
+       int (*lock)(struct file *, int, struct file_lock *);
+       ssize_t (*sendpage)(struct file *, struct page *, int, size_t,
+           loff_t *, int);
+       unsigned long (*get_unmapped_area)(struct file *, unsigned long,
+           unsigned long, unsigned long, unsigned long);
+       int (*check_flags)(int);
+       int (*flock)(struct file *, int, struct file_lock *);
+       ssize_t (*splice_write)(struct pipe_inode_info *, struct file *,
+           loff_t *, size_t, unsigned int);
+       ssize_t (*splice_read)(struct file *, loff_t *,
+           struct pipe_inode_info *, size_t, unsigned int);
+       int (*setlease)(struct file *, long, struct file_lock **);
+#endif
+};
+#define        fops_get(fops)  (fops)
+
+#define        FMODE_READ      FREAD
+#define        FMODE_WRITE     FWRITE
+#define        FMODE_EXEC      FEXEC
+
+static inline int
+register_chrdev_region(dev_t dev, unsigned range, const char *name)
+{
+
+       return 0;
+}
+
+static inline void
+unregister_chrdev_region(dev_t dev, unsigned range)
+{
+
+       return;
+}
+
+static inline int
+alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count,
+                       const char *name)
+{
+
+       return 0;
+}
+
+/* No current support for seek op in FreeBSD */
+static inline int
+nonseekable_open(struct inode *inode, struct file *filp)
+{
+       return 0;
+}
+
+static inline dev_t
+iminor(struct inode *inode)
+{
+
+       return dev2unit(inode->v_rdev);
+}
+
+static inline struct inode *
+igrab(struct inode *inode)
+{
+       int error;
+
+       error = vget(inode, 0, curthread);
+       if (error)
+               return (NULL);
+
+       return (inode);
+}
+
+static inline void
+iput(struct inode *inode)
+{
+
+       vrele(inode);
+}
+
+static inline loff_t 
+no_llseek(struct file *file, loff_t offset, int whence)
+{
+        return -ESPIPE;
+}
+
+#endif /* _LINUX_FS_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/gfp.h b/sys/compat/linuxkpi/common/include/linux/gfp.h
new file mode 100644 (file)
index 0000000..a82f30d
--- /dev/null
@@ -0,0 +1,149 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013 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_GFP_H_
+#define        _LINUX_GFP_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+
+#include <linux/page.h>
+
+#include <vm/vm_param.h>
+#include <vm/vm_object.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_kern.h>
+
+#define        __GFP_NOWARN    0
+#define        __GFP_HIGHMEM   0
+#define        __GFP_ZERO      M_ZERO
+
+#define        GFP_NOWAIT      M_NOWAIT
+#define        GFP_ATOMIC      (M_NOWAIT | M_USE_RESERVE)
+#define        GFP_KERNEL      M_WAITOK
+#define        GFP_USER        M_WAITOK
+#define        GFP_HIGHUSER    M_WAITOK
+#define        GFP_HIGHUSER_MOVABLE    M_WAITOK
+#define        GFP_IOFS        M_NOWAIT
+
+static inline void *
+page_address(struct page *page)
+{
+
+       if (page->object != kmem_object && page->object != kernel_object)
+               return (NULL);
+       return ((void *)(uintptr_t)(VM_MIN_KERNEL_ADDRESS +
+           IDX_TO_OFF(page->pindex)));
+}
+
+static inline unsigned long
+_get_page(gfp_t mask)
+{
+
+       return kmem_malloc(kmem_arena, PAGE_SIZE, mask);
+}
+
+#define        get_zeroed_page(mask)   _get_page((mask) | M_ZERO)
+#define        alloc_page(mask)        virt_to_page(_get_page((mask)))
+#define        __get_free_page(mask)   _get_page((mask))
+
+static inline void
+free_page(unsigned long page)
+{
+
+       if (page == 0)
+               return;
+       kmem_free(kmem_arena, page, PAGE_SIZE);
+}
+
+static inline void
+__free_page(struct page *m)
+{
+
+       if (m->object != kmem_object)
+               panic("__free_page:  Freed page %p not allocated via wrappers.",
+                   m);
+       kmem_free(kmem_arena, (vm_offset_t)page_address(m), PAGE_SIZE);
+}
+
+static inline void
+__free_pages(struct page *m, unsigned int order)
+{
+       size_t size;
+
+       if (m == NULL)
+               return;
+       size = PAGE_SIZE << order;
+       kmem_free(kmem_arena, (vm_offset_t)page_address(m), size);
+}
+
+static inline void free_pages(uintptr_t addr, unsigned int order)
+{
+       if (addr == 0)
+               return;
+       __free_pages(virt_to_page((void *)addr), order);
+}
+
+/*
+ * Alloc pages allocates directly from the buddy allocator on linux so
+ * order specifies a power of two bucket of pages and the results
+ * are expected to be aligned on the size as well.
+ */
+static inline struct page *
+alloc_pages(gfp_t gfp_mask, unsigned int order)
+{
+       unsigned long page;
+       size_t size;
+
+       size = PAGE_SIZE << order;
+       page = kmem_alloc_contig(kmem_arena, size, gfp_mask, 0, -1,
+           size, 0, VM_MEMATTR_DEFAULT);
+       if (page == 0)
+               return (NULL);
+        return (virt_to_page(page));
+}
+
+static inline uintptr_t __get_free_pages(gfp_t gfp_mask, unsigned int order)
+{
+       struct page *page;
+
+       page = alloc_pages(gfp_mask, order);
+       if (page == NULL)
+               return (0);
+       return ((uintptr_t)page_address(page));
+}
+
+#define alloc_pages_node(node, mask, order)     alloc_pages(mask, order)
+
+#define kmalloc_node(chunk, mask, node)         kmalloc(chunk, mask)
+
+#endif /* _LINUX_GFP_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/hardirq.h b/sys/compat/linuxkpi/common/include/linux/hardirq.h
new file mode 100644 (file)
index 0000000..b8e4c95
--- /dev/null
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013 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_HARDIRQ_H_
+#define        _LINUX_HARDIRQ_H_
+
+#include <linux/types.h>
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/interrupt.h>
+
+#define        synchronize_irq(irq)    _intr_drain((irq))
+
+#endif /* _LINUX_HARDIRQ_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/idr.h b/sys/compat/linuxkpi/common/include/linux/idr.h
new file mode 100644 (file)
index 0000000..9beec68
--- /dev/null
@@ -0,0 +1,76 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013 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_IDR_H_
+#define        _LINUX_IDR_H_
+
+#include <sys/kernel.h>
+
+#define        IDR_BITS        5
+#define        IDR_SIZE        (1 << IDR_BITS)
+#define        IDR_MASK        (IDR_SIZE - 1)
+
+#define        MAX_ID_SHIFT    ((sizeof(int) * NBBY) - 1)
+#define        MAX_ID_BIT      (1U << MAX_ID_SHIFT)
+#define        MAX_ID_MASK     (MAX_ID_BIT - 1)
+#define        MAX_LEVEL       (MAX_ID_SHIFT + IDR_BITS - 1) / IDR_BITS
+
+#define MAX_IDR_SHIFT (sizeof(int)*8 - 1)
+#define MAX_IDR_BIT (1U << MAX_IDR_SHIFT)
+#define MAX_IDR_MASK (MAX_IDR_BIT - 1)
+
+struct idr_layer {
+       unsigned long           bitmap;
+       struct idr_layer        *ary[IDR_SIZE];
+};
+
+struct idr {
+       struct mtx              lock;
+       struct idr_layer        *top;
+       struct idr_layer        *free;
+       int                     layers;
+};
+
+#define DEFINE_IDR(name)                                               \
+       struct idr name;                                                \
+       SYSINIT(name##_idr_sysinit, SI_SUB_DRIVERS, SI_ORDER_FIRST,     \
+           idr_init, &(name));
+
+void   *idr_find(struct idr *idp, int id);
+int    idr_pre_get(struct idr *idp, gfp_t gfp_mask);
+int    idr_get_new(struct idr *idp, void *ptr, int *id);
+int    idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id);
+void   *idr_replace(struct idr *idp, void *ptr, int id);
+void   idr_remove(struct idr *idp, int id);
+void   idr_remove_all(struct idr *idp);
+void   idr_destroy(struct idr *idp);
+void   idr_init(struct idr *idp);
+
+#endif /* _LINUX_IDR_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/if_arp.h b/sys/compat/linuxkpi/common/include/linux/if_arp.h
new file mode 100644 (file)
index 0000000..6233aac
--- /dev/null
@@ -0,0 +1,35 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013 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_IF_ARP_H_
+#define        _LINUX_IF_ARP_H_
+#include <sys/socket.h>
+#include <net/if_arp.h>
+#endif /* _LINUX_IF_ARP_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/if_ether.h b/sys/compat/linuxkpi/common/include/linux/if_ether.h
new file mode 100644 (file)
index 0000000..c89e1e2
--- /dev/null
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013 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_IF_ETHER_H_
+#define        _LINUX_IF_ETHER_H_
+
+#include <linux/types.h>
+
+#include <net/ethernet.h>
+
+#define        ETH_P_8021Q     ETHERTYPE_VLAN
+
+#define ETH_HLEN        ETHER_HDR_LEN   /* Total octets in header.                              */
+#ifndef ETH_ALEN
+#define ETH_ALEN        ETHER_ADDR_LEN
+#endif
+#define ETH_FCS_LEN     4               /* Octets in the FCS                                    */
+#define VLAN_HLEN       4               /* The additional bytes (on top of the Ethernet header)
+                                         * that VLAN requires.                                  */
+/*
+ * defined Ethernet Protocol ID's.
+ */
+#define ETH_P_IP        0x0800          /* Internet Protocol packet                             */
+
+#endif /* _LINUX_IF_ETHER_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/if_vlan.h b/sys/compat/linuxkpi/common/include/linux/if_vlan.h
new file mode 100644 (file)
index 0000000..4a8808f
--- /dev/null
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013 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_IF_VLAN_H_
+#define        _LINUX_IF_VLAN_H_
+
+#include <sys/socket.h>
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_vlan_var.h>
+
+#define VLAN_N_VID              4096
+
+#endif /* _LINUX_IF_VLAN_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/in.h b/sys/compat/linuxkpi/common/include/linux/in.h
new file mode 100644 (file)
index 0000000..f390c1d
--- /dev/null
@@ -0,0 +1,45 @@
+/*-
+ * 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        _LINUX_IN_H_
+#define        _LINUX_IN_H_
+
+#include "opt_inet.h"
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <netinet/in.h>
+#include <asm/byteorder.h>
+
+#define        ipv4_is_zeronet(be)     IN_ZERONET(ntohl(be))
+#define        ipv4_is_loopback(be)    IN_LOOPBACK(ntohl(be))
+
+#endif /* _LINUX_IN_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/in6.h b/sys/compat/linuxkpi/common/include/linux/in6.h
new file mode 100644 (file)
index 0000000..ef012dd
--- /dev/null
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013 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_IN6_H_
+#define        _LINUX_IN6_H_
+
+#ifndef KLD_MODULE
+#include "opt_inet6.h"
+#endif
+
+#endif /* _LINUX_IN6_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/inetdevice.h b/sys/compat/linuxkpi/common/include/linux/inetdevice.h
new file mode 100644 (file)
index 0000000..12d7544
--- /dev/null
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013 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_INETDEVICE_H_
+#define        _LINUX_INETDEVICE_H_
+
+#include <linux/netdevice.h>
+
+static inline struct net_device *
+ip_dev_find(struct net *net, uint32_t addr)
+{
+       struct sockaddr_in sin;
+       struct ifaddr *ifa;
+       struct ifnet *ifp;
+
+       ifp = NULL;
+       memset(&sin, 0, sizeof(sin));
+       sin.sin_addr.s_addr = addr;
+       sin.sin_port = 0;
+       sin.sin_len = sizeof(sin);
+       sin.sin_family = AF_INET;
+       ifa = ifa_ifwithaddr((struct sockaddr *)&sin);
+       if (ifa) {
+               ifp = ifa->ifa_ifp;
+               if_ref(ifp);
+               ifa_free(ifa);
+       }
+       return (ifp);
+}
+
+#endif /* _LINUX_INETDEVICE_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/interrupt.h b/sys/compat/linuxkpi/common/include/linux/interrupt.h
new file mode 100644 (file)
index 0000000..4c0ad80
--- /dev/null
@@ -0,0 +1,158 @@
+/*-
+ * 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_INTERRUPT_H_
+#define        _LINUX_INTERRUPT_H_
+
+#include <linux/device.h>
+#include <linux/pci.h>
+
+#include <sys/bus.h>
+#include <sys/rman.h>
+
+typedef        irqreturn_t     (*irq_handler_t)(int, void *);
+
+#define        IRQ_RETVAL(x)   ((x) != IRQ_NONE)
+
+#define        IRQF_SHARED     RF_SHAREABLE
+
+struct irq_ent {
+       struct list_head        links;
+       struct device   *dev;
+       struct resource *res;
+       void            *arg;
+       irqreturn_t     (*handler)(int, void *);
+       void            *tag;
+       int              irq;
+};
+
+static inline int
+_irq_rid(struct device *dev, int irq)
+{
+       if (irq == dev->irq)
+               return (0);
+       return irq - dev->msix + 1;
+}
+
+static void
+_irq_handler(void *ent)
+{
+       struct irq_ent *irqe;
+
+       irqe = ent;
+       irqe->handler(irqe->irq, irqe->arg);
+}
+
+static inline struct irq_ent *
+_irq_ent(struct device *dev, int irq)
+{
+       struct irq_ent *irqe;
+
+       list_for_each_entry(irqe, &dev->irqents, links)
+               if (irqe->irq == irq)
+                       return (irqe);
+
+       return (NULL);
+}
+
+static inline int
+request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
+    const char *name, void *arg)
+{
+       struct resource *res;
+       struct irq_ent *irqe;
+       struct device *dev;
+       int error;
+       int rid;
+
+       dev = _pci_find_irq_dev(irq);
+       if (dev == NULL)
+               return -ENXIO;
+       rid = _irq_rid(dev, irq);
+       res = bus_alloc_resource_any(dev->bsddev, SYS_RES_IRQ, &rid,
+           flags | RF_ACTIVE);
+       if (res == NULL)
+               return (-ENXIO);
+       irqe = kmalloc(sizeof(*irqe), GFP_KERNEL);
+       irqe->dev = dev;
+       irqe->res = res;
+       irqe->arg = arg;
+       irqe->handler = handler;
+       irqe->irq = irq;
+       error = bus_setup_intr(dev->bsddev, res, INTR_TYPE_NET | INTR_MPSAFE,
+           NULL, _irq_handler, irqe, &irqe->tag);
+       if (error) {
+               bus_release_resource(dev->bsddev, SYS_RES_IRQ, rid, irqe->res);
+               kfree(irqe);
+               return (-error);
+       }
+       list_add(&irqe->links, &dev->irqents);
+
+       return 0;
+}
+
+static inline int
+bind_irq_to_cpu(unsigned int irq, int cpu_id)
+{
+       struct irq_ent *irqe;
+       struct device *dev;
+
+       dev = _pci_find_irq_dev(irq);
+       if (dev == NULL)
+               return (-ENOENT);
+
+       irqe = _irq_ent(dev, irq);
+       if (irqe == NULL)
+               return (-ENOENT);
+
+       return (-bus_bind_intr(dev->bsddev, irqe->res, cpu_id));
+}
+
+static inline void
+free_irq(unsigned int irq, void *device)
+{
+       struct irq_ent *irqe;
+       struct device *dev;
+       int rid;
+
+       dev = _pci_find_irq_dev(irq);
+       if (dev == NULL)
+               return;
+       rid = _irq_rid(dev, irq);
+       irqe = _irq_ent(dev, irq);
+       if (irqe == NULL)
+               return;
+       bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag);
+       bus_release_resource(dev->bsddev, SYS_RES_IRQ, rid, irqe->res);
+       list_del(&irqe->links);
+       kfree(irqe);
+}
+
+#endif /* _LINUX_INTERRUPT_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/io-mapping.h b/sys/compat/linuxkpi/common/include/linux/io-mapping.h
new file mode 100644 (file)
index 0000000..8650dba
--- /dev/null
@@ -0,0 +1,79 @@
+/*-
+ * 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        _LINUX_IO_MAPPING_H_
+#define        _LINUX_IO_MAPPING_H_
+
+#include <linux/types.h>
+#include <linux/io.h>
+
+struct io_mapping;
+
+static inline struct io_mapping *
+io_mapping_create_wc(resource_size_t base, unsigned long size)
+{
+
+       return ioremap_wc(base, size);
+}
+
+static inline void
+io_mapping_free(struct io_mapping *mapping)
+{
+
+       iounmap(mapping);
+}
+
+static inline void *
+io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset)
+{
+
+       return (((char *)mapping) + offset);
+}
+
+static inline void
+io_mapping_unmap_atomic(void *vaddr)
+{
+
+}
+
+static inline void *
+io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset)
+{
+
+       return (((char *) mapping) + offset);
+}
+
+static inline void
+io_mapping_unmap(void *vaddr)
+{
+
+}
+
+#endif /* _LINUX_IO_MAPPING_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/io.h b/sys/compat/linuxkpi/common/include/linux/io.h
new file mode 100644 (file)
index 0000000..16543ff
--- /dev/null
@@ -0,0 +1,142 @@
+/*-
+ * 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        _LINUX_IO_H_
+#define        _LINUX_IO_H_
+
+#include <machine/vm.h>
+#include <sys/endian.h>
+
+static inline uint32_t
+__raw_readl(const volatile void *addr)
+{
+       return *(const volatile uint32_t *)addr;
+}
+
+static inline void
+__raw_writel(uint32_t b, volatile void *addr)
+{
+       *(volatile uint32_t *)addr = b;
+}
+
+static inline uint64_t
+__raw_readq(const volatile void *addr)
+{
+       return *(const volatile uint64_t *)addr;
+}
+
+static inline void
+__raw_writeq(uint64_t b, volatile void *addr)
+{
+       *(volatile uint64_t *)addr = b;
+}
+
+/*
+ * XXX This is all x86 specific.  It should be bus space access.
+ */
+#define mmiowb()
+
+#undef writel
+static inline void
+writel(uint32_t b, void *addr)
+{
+        *(volatile uint32_t *)addr = b;
+}
+
+#undef writeq
+static inline void
+writeq(uint64_t b, void *addr)
+{
+        *(volatile uint64_t *)addr = b;
+}
+
+#undef writeb
+static inline void
+writeb(uint8_t b, void *addr)
+{
+        *(volatile uint8_t *)addr = b;
+}
+
+#undef writew
+static inline void
+writew(uint16_t b, void *addr)
+{
+        *(volatile uint16_t *)addr = b;
+}
+
+#undef ioread32be
+static inline uint32_t
+ioread32be(const volatile void *addr)
+{
+       return be32toh(*(const volatile uint32_t *)addr);
+}
+
+#undef iowrite32be
+static inline void
+iowrite32be(uint32_t v, volatile void *addr)
+{
+       *(volatile uint32_t *)addr = htobe32(v);
+}
+
+void *_ioremap_attr(vm_paddr_t phys_addr, unsigned long size, int attr);
+#define        ioremap_nocache(addr, size)                                     \
+    _ioremap_attr((addr), (size), VM_MEMATTR_UNCACHEABLE)
+#define        ioremap_wc(addr, size)                                          \
+    _ioremap_attr((addr), (size), VM_MEMATTR_WRITE_COMBINING)
+#define        ioremap ioremap_nocache
+void iounmap(void *addr);
+
+#define        memset_io(a, b, c)      memset((a), (b), (c))
+#define        memcpy_fromio(a, b, c)  memcpy((a), (b), (c))
+#define        memcpy_toio(a, b, c)    memcpy((a), (b), (c))
+
+static inline void
+__iowrite64_copy(void *to, void *from, size_t count)
+{
+#ifdef __LP64__
+       uint64_t *src;
+       uint64_t *dst;
+       int i;
+
+       for (i = 0, src = from, dst = to; i < count; i++, src++, dst++)
+               __raw_writeq(*src, dst);
+#else
+       uint32_t *src;
+       uint32_t *dst;
+       int i;
+
+       count *= 2;
+       for (i = 0, src = from, dst = to; i < count; i++, src++, dst++)
+               __raw_writel(*src, dst);
+#endif
+}
+
+
+#endif /* _LINUX_IO_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/ioctl.h b/sys/compat/linuxkpi/common/include/linux/ioctl.h
new file mode 100644 (file)
index 0000000..6f57906
--- /dev/null
@@ -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        _LINUX_IOCTL_H_
+#define        _LINUX_IOCTL_H_
+
+#include <sys/ioccom.h>
+
+#endif /* _LINUX_IOCTL_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/jhash.h b/sys/compat/linuxkpi/common/include/linux/jhash.h
new file mode 100644 (file)
index 0000000..f31829e
--- /dev/null
@@ -0,0 +1,145 @@
+#ifndef        _LINUX_JHASH_H_
+#define        _LINUX_JHASH_H_
+
+/* jhash.h: Jenkins hash support.
+ *
+ * Copyright (C) 1996 Bob Jenkins (bob_jenkins@burtleburtle.net)
+ *
+ * http://burtleburtle.net/bob/hash/
+ *
+ * These are the credits from Bob's sources:
+ *
+ * lookup2.c, by Bob Jenkins, December 1996, Public Domain.
+ * hash(), hash2(), hash3, and mix() are externally useful functions.
+ * Routines to test the hash are included if SELF_TEST is defined.
+ * You can use this free for any purpose.  It has no warranty.
+ *
+ * Copyright (C) 2003 David S. Miller (davem@redhat.com)
+ *
+ * I've modified Bob's hash to be useful in the Linux kernel, and
+ * any bugs present are surely my fault.  -DaveM
+ *
+ * $FreeBSD$
+ */
+
+/* NOTE: Arguments are modified. */
+#define __jhash_mix(a, b, c) \
+{ \
+  a -= b; a -= c; a ^= (c>>13); \
+  b -= c; b -= a; b ^= (a<<8); \
+  c -= a; c -= b; c ^= (b>>13); \
+  a -= b; a -= c; a ^= (c>>12);  \
+  b -= c; b -= a; b ^= (a<<16); \
+  c -= a; c -= b; c ^= (b>>5); \
+  a -= b; a -= c; a ^= (c>>3);  \
+  b -= c; b -= a; b ^= (a<<10); \
+  c -= a; c -= b; c ^= (b>>15); \
+}
+
+/* The golden ration: an arbitrary value */
+#define JHASH_GOLDEN_RATIO     0x9e3779b9
+
+/* The most generic version, hashes an arbitrary sequence
+ * of bytes.  No alignment or length assumptions are made about
+ * the input key.
+ */
+static inline u32 jhash(const void *key, u32 length, u32 initval)
+{
+       u32 a, b, c, len;
+       const u8 *k = key;
+
+       len = length;
+       a = b = JHASH_GOLDEN_RATIO;
+       c = initval;
+
+       while (len >= 12) {
+               a += (k[0] +((u32)k[1]<<8) +((u32)k[2]<<16) +((u32)k[3]<<24));
+               b += (k[4] +((u32)k[5]<<8) +((u32)k[6]<<16) +((u32)k[7]<<24));
+               c += (k[8] +((u32)k[9]<<8) +((u32)k[10]<<16)+((u32)k[11]<<24));
+
+               __jhash_mix(a,b,c);
+
+               k += 12;
+               len -= 12;
+       }
+
+       c += length;
+       switch (len) {
+       case 11: c += ((u32)k[10]<<24);
+       case 10: c += ((u32)k[9]<<16);
+       case 9 : c += ((u32)k[8]<<8);
+       case 8 : b += ((u32)k[7]<<24);
+       case 7 : b += ((u32)k[6]<<16);
+       case 6 : b += ((u32)k[5]<<8);
+       case 5 : b += k[4];
+       case 4 : a += ((u32)k[3]<<24);
+       case 3 : a += ((u32)k[2]<<16);
+       case 2 : a += ((u32)k[1]<<8);
+       case 1 : a += k[0];
+       };
+
+       __jhash_mix(a,b,c);
+
+       return c;
+}
+
+/* A special optimized version that handles 1 or more of u32s.
+ * The length parameter here is the number of u32s in the key.
+ */
+static inline u32 jhash2(const u32 *k, u32 length, u32 initval)
+{
+       u32 a, b, c, len;
+
+       a = b = JHASH_GOLDEN_RATIO;
+       c = initval;
+       len = length;
+
+       while (len >= 3) {
+               a += k[0];
+               b += k[1];
+               c += k[2];
+               __jhash_mix(a, b, c);
+               k += 3; len -= 3;
+       }
+
+       c += length * 4;
+
+       switch (len) {
+       case 2 : b += k[1];
+       case 1 : a += k[0];
+       };
+
+       __jhash_mix(a,b,c);
+
+       return c;
+}
+
+
+/* A special ultra-optimized versions that knows they are hashing exactly
+ * 3, 2 or 1 word(s).
+ *
+ * NOTE: In partilar the "c += length; __jhash_mix(a,b,c);" normally
+ *       done at the end is not done here.
+ */
+static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval)
+{
+       a += JHASH_GOLDEN_RATIO;
+       b += JHASH_GOLDEN_RATIO;
+       c += initval;
+
+       __jhash_mix(a, b, c);
+
+       return c;
+}
+
+static inline u32 jhash_2words(u32 a, u32 b, u32 initval)
+{
+       return jhash_3words(a, b, 0, initval);
+}
+
+static inline u32 jhash_1word(u32 a, u32 initval)
+{
+       return jhash_3words(a, 0, 0, initval);
+}
+
+#endif /* _LINUX_JHASH_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/jiffies.h b/sys/compat/linuxkpi/common/include/linux/jiffies.h
new file mode 100644 (file)
index 0000000..f7bc529
--- /dev/null
@@ -0,0 +1,98 @@
+/*-
+ * 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        _LINUX_JIFFIES_H_
+#define        _LINUX_JIFFIES_H_
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/time.h>
+
+#include <sys/time.h>
+#include <sys/kernel.h>
+#include <sys/limits.h>
+
+static inline int
+msecs_to_jiffies(int msec)
+{
+       struct timeval tv;
+
+       tv.tv_sec = msec / 1000;
+       tv.tv_usec = (msec % 1000) * 1000;
+       return (tvtohz(&tv) - 1);
+}
+
+#define jiffies                 ticks
+#define        jiffies_64              ticks
+#define jiffies_to_msecs(x)     (((int64_t)(x)) * 1000 / hz)
+
+#define        MAX_JIFFY_OFFSET        ((INT_MAX >> 1) - 1)
+
+#define        time_after(a, b)        ((int)((b) - (a)) < 0)
+#define        time_before(a, b)       time_after(b,a)
+#define        time_after_eq(a, b)     ((int)((a) - (b)) >= 0)
+#define        time_before_eq(a, b)    time_after_eq(b, a)
+#define        time_in_range(a,b,c)    \
+       (time_after_eq(a,b) && time_before_eq(a,c))
+
+#define        HZ      hz
+
+static inline int
+timespec_to_jiffies(const struct timespec *ts)
+{
+       u64 result;
+
+       result = ((u64)hz * ts->tv_sec) +
+           (((u64)hz * ts->tv_nsec + NSEC_PER_SEC - 1) / NSEC_PER_SEC);
+       if (result > MAX_JIFFY_OFFSET)
+               result = MAX_JIFFY_OFFSET;
+
+       return ((int)result);
+}
+
+static inline int
+usecs_to_jiffies(const unsigned int u)
+{
+       u64 result;
+
+       result = ((u64)u * hz + 1000000 - 1) / 1000000;
+       if (result > MAX_JIFFY_OFFSET)
+               result = MAX_JIFFY_OFFSET;
+
+       return ((int)result);
+}
+
+static inline u64
+get_jiffies_64(void)
+{
+       return ((u64)(unsigned)ticks);
+}
+
+#endif /* _LINUX_JIFFIES_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/kdev_t.h b/sys/compat/linuxkpi/common/include/linux/kdev_t.h
new file mode 100644 (file)
index 0000000..8dea1ab
--- /dev/null
@@ -0,0 +1,38 @@
+/*-
+ * 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        _LINUX_KDEV_T_H_
+#define        _LINUX_KDEV_T_H_
+
+#define MAJOR(dev)      major((dev))
+#define MINOR(dev)      minor((dev))
+#define MKDEV(ma, mi)   makedev((ma), (mi))
+
+#endif /* _LINUX_KDEV_T_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h
new file mode 100644 (file)
index 0000000..bfc3b7d
--- /dev/null
@@ -0,0 +1,219 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
+ * Copyright (c) 2014-2015 François Tigeot
+ * 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_KERNEL_H_
+#define        _LINUX_KERNEL_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/param.h>
+#include <sys/libkern.h>
+#include <sys/stat.h>
+#include <sys/smp.h>
+#include <sys/stddef.h>
+#include <sys/syslog.h>
+
+#include <linux/bitops.h>
+#include <linux/compiler.h>
+#include <linux/errno.h>
+#include <linux/kthread.h>
+#include <linux/types.h>
+#include <linux/jiffies.h>
+#include <linux/wait.h>
+#include <linux/log2.h> 
+#include <asm/byteorder.h>
+
+#define KERN_CONT       ""
+#define        KERN_EMERG      "<0>"
+#define        KERN_ALERT      "<1>"
+#define        KERN_CRIT       "<2>"
+#define        KERN_ERR        "<3>"
+#define        KERN_WARNING    "<4>"
+#define        KERN_NOTICE     "<5>"
+#define        KERN_INFO       "<6>"
+#define        KERN_DEBUG      "<7>"
+
+#define        BUILD_BUG_ON(x)         CTASSERT(!(x))
+
+#define BUG()                  panic("BUG")
+#define BUG_ON(condition)      do { if (condition) BUG(); } while(0)
+#define        WARN_ON                 BUG_ON
+
+#undef ALIGN
+#define        ALIGN(x, y)             roundup2((x), (y))
+#undef PTR_ALIGN
+#define        PTR_ALIGN(p, a)         ((__typeof(p))ALIGN((uintptr_t)(p), (a)))
+#define        DIV_ROUND_UP(x, n)      howmany(x, n)
+#define        DIV_ROUND_UP_ULL(x, n)  DIV_ROUND_UP((unsigned long long)(x), (n))
+#define        FIELD_SIZEOF(t, f)      sizeof(((t *)0)->f)
+
+#define        printk(X...)            printf(X)
+
+/*
+ * The "pr_debug()" and "pr_devel()" macros should produce zero code
+ * unless DEBUG is defined:
+ */
+#ifdef DEBUG
+#define pr_debug(fmt, ...) \
+        log(LOG_DEBUG, fmt, ##__VA_ARGS__)
+#define pr_devel(fmt, ...) \
+       log(LOG_DEBUG, pr_fmt(fmt), ##__VA_ARGS__)
+#else
+#define pr_debug(fmt, ...) \
+        ({ if (0) log(LOG_DEBUG, fmt, ##__VA_ARGS__); 0; })
+#define pr_devel(fmt, ...) \
+       ({ if (0) log(LOG_DEBUG, pr_fmt(fmt), ##__VA_ARGS__); 0; })
+#endif
+
+#ifndef pr_fmt
+#define pr_fmt(fmt) fmt
+#endif
+
+/*
+ * Print a one-time message (analogous to WARN_ONCE() et al):
+ */
+#define printk_once(...) do {                  \
+       static bool __print_once;               \
+                                               \
+       if (!__print_once) {                    \
+               __print_once = true;            \
+               printk(__VA_ARGS__);            \
+       }                                       \
+} while (0)
+
+/*
+ * Log a one-time message (analogous to WARN_ONCE() et al):
+ */
+#define log_once(level,...) do {               \
+       static bool __log_once;                 \
+                                               \
+       if (!__log_once) {                      \
+               __log_once = true;              \
+               log(level, __VA_ARGS__);        \
+       }                                       \
+} while (0)
+
+#define pr_emerg(fmt, ...) \
+       log(LOG_EMERG, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_alert(fmt, ...) \
+       log(LOG_ALERT, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_crit(fmt, ...) \
+       log(LOG_CRIT, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_err(fmt, ...) \
+       log(LOG_ERR, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warning(fmt, ...) \
+       log(LOG_WARNING, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warn pr_warning
+#define pr_notice(fmt, ...) \
+       log(LOG_NOTICE, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_info(fmt, ...) \
+       log(LOG_INFO, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_info_once(fmt, ...) \
+       log_once(LOG_INFO, pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_cont(fmt, ...) \
+       printk(KERN_CONT fmt, ##__VA_ARGS__)
+
+#ifndef WARN
+#define WARN(condition, format...) ({                                   \
+        int __ret_warn_on = !!(condition);                              \
+        if (unlikely(__ret_warn_on))                                    \
+                pr_warning(format);                                     \
+        unlikely(__ret_warn_on);                                        \
+})
+#endif
+
+#define container_of(ptr, type, member)                                \
+({                                                             \
+       __typeof(((type *)0)->member) *_p = (ptr);              \
+       (type *)((char *)_p - offsetof(type, member));          \
+})
+  
+#define        ARRAY_SIZE(x)   (sizeof(x) / sizeof((x)[0]))
+
+#define        simple_strtoul  strtoul
+#define        simple_strtol   strtol
+#define kstrtol(a,b,c) ({*(c) = strtol(a,0,b);})
+
+#define min(x, y)      ((x) < (y) ? (x) : (y))
+#define max(x, y)      ((x) > (y) ? (x) : (y))
+
+#define min3(a, b, c)  min(a, min(b,c))
+#define max3(a, b, c)  max(a, max(b,c))
+
+#define min_t(type, _x, _y)    ((type)(_x) < (type)(_y) ? (type)(_x) : (type)(_y))
+#define max_t(type, _x, _y)    ((type)(_x) > (type)(_y) ? (type)(_x) : (type)(_y))
+
+#define clamp_t(type, _x, min, max)    min_t(type, max_t(type, _x, min), max)
+#define clamp(x, lo, hi)               min( max(x,lo), hi)
+
+/*
+ * This looks more complex than it should be. But we need to
+ * get the type for the ~ right in round_down (it needs to be
+ * as wide as the result!), and we want to evaluate the macro
+ * arguments just once each.
+ */
+#define __round_mask(x, y) ((__typeof__(x))((y)-1))
+#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
+#define round_down(x, y) ((x) & ~__round_mask(x, y))
+
+#define        num_possible_cpus()     mp_ncpus
+#define        num_online_cpus()       mp_ncpus
+
+typedef struct pm_message {
+        int event;
+} pm_message_t;
+
+/* Swap values of a and b */
+#define swap(a, b) do {                        \
+       typeof(a) _swap_tmp = a;        \
+       a = b;                          \
+       b = _swap_tmp;                  \
+} while (0)
+
+#define        DIV_ROUND_CLOSEST(x, divisor)   (((x) + ((divisor) / 2)) / (divisor))
+
+static inline uintmax_t
+mult_frac(uintmax_t x, uintmax_t multiplier, uintmax_t divisor)
+{
+       uintmax_t q = (x / divisor);
+       uintmax_t r = (x % divisor);
+
+       return ((q * multiplier) + ((r * multiplier) / divisor));
+}
+
+static inline int64_t
+abs64(int64_t x)
+{
+       return (x < 0 ? -x : x);
+}
+
+#endif /* _LINUX_KERNEL_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/kmod.h b/sys/compat/linuxkpi/common/include/linux/kmod.h
new file mode 100644 (file)
index 0000000..c943dc5
--- /dev/null
@@ -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        _LINUX_KMOD_H_
+#define        _LINUX_KMOD_H_
+
+#include <sys/types.h>
+#include <sys/syscallsubr.h>
+#include <sys/refcount.h>
+#include <sys/sbuf.h>
+#include <machine/stdarg.h>
+#include <sys/proc.h>
+
+#define        request_module(...) \
+({\
+       char modname[128]; \
+        int fileid; \
+       snprintf(modname, sizeof(modname), __VA_ARGS__); \
+       kern_kldload(curthread, modname, &fileid); \
+})
+
+#define request_module_nowait request_module
+
+
+#endif /* _LINUX_KMOD_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/kobject.h b/sys/compat/linuxkpi/common/include/linux/kobject.h
new file mode 100644 (file)
index 0000000..63fbc56
--- /dev/null
@@ -0,0 +1,171 @@
+/*-
+ * 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        _LINUX_KOBJECT_H_
+#define        _LINUX_KOBJECT_H_
+
+#include <machine/stdarg.h>
+
+#include <linux/kernel.h>
+#include <linux/kref.h>
+#include <linux/slab.h>
+
+struct kobject;
+struct sysctl_oid;
+
+struct kobj_type {
+       void (*release)(struct kobject *kobj);
+       const struct sysfs_ops *sysfs_ops;
+       struct attribute **default_attrs;
+};
+
+extern struct kobj_type kfree_type;
+
+struct kobject {
+       struct kobject          *parent;
+       char                    *name;
+       struct kref             kref;
+       struct kobj_type        *ktype;
+       struct list_head        entry;
+       struct sysctl_oid       *oidp;
+};
+
+extern struct kobject *mm_kobj;
+
+static inline void
+kobject_init(struct kobject *kobj, struct kobj_type *ktype)
+{
+
+       kref_init(&kobj->kref);
+       INIT_LIST_HEAD(&kobj->entry);
+       kobj->ktype = ktype;
+       kobj->oidp = NULL;
+}
+
+static inline void kobject_put(struct kobject *kobj);
+void kobject_release(struct kref *kref);
+
+static inline void
+kobject_put(struct kobject *kobj)
+{
+
+       if (kobj)
+               kref_put(&kobj->kref, kobject_release);
+}
+
+static inline struct kobject *
+kobject_get(struct kobject *kobj)
+{
+
+       if (kobj)
+               kref_get(&kobj->kref);
+       return kobj;
+}
+
+static inline int
+kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list args)
+{
+       char *old;
+       char *name;
+
+       old = kobj->name;
+
+       if (old && !fmt)
+               return 0;
+
+       name = kzalloc(MAXPATHLEN, GFP_KERNEL);
+       if (!name)
+               return -ENOMEM;
+       vsnprintf(name, MAXPATHLEN, fmt, args);
+       kobj->name = name;
+       kfree(old);
+       for (; *name != '\0'; name++)
+               if (*name == '/')
+                       *name = '!';
+       return (0);
+}
+
+int    kobject_add(struct kobject *kobj, struct kobject *parent,
+           const char *fmt, ...);
+
+static inline struct kobject *
+kobject_create(void)
+{
+       struct kobject *kobj;
+
+       kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
+       if (kobj == NULL)
+               return (NULL);
+       kobject_init(kobj, &kfree_type);
+
+       return (kobj);
+}
+
+static inline struct kobject *
+kobject_create_and_add(const char *name, struct kobject *parent)
+{
+       struct kobject *kobj;
+
+       kobj = kobject_create();
+       if (kobj == NULL)
+               return (NULL);
+       if (kobject_add(kobj, parent, "%s", name) == 0)
+               return (kobj);
+       kobject_put(kobj);
+
+       return (NULL);
+}
+
+
+static inline char *
+kobject_name(const struct kobject *kobj)
+{
+
+       return kobj->name;
+}
+
+int    kobject_set_name(struct kobject *kobj, const char *fmt, ...);
+int    kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype,
+           struct kobject *parent, const char *fmt, ...);
+
+/* sysfs.h calles for 'kobject' which is defined here, 
+ * so we need to add the include only after the 'kobject' def.
+ */
+#include <linux/sysfs.h>
+
+struct kobj_attribute {
+        struct attribute attr;
+        ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
+                        char *buf);
+        ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
+                         const char *buf, size_t count);
+};
+
+#endif /* _LINUX_KOBJECT_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/kref.h b/sys/compat/linuxkpi/common/include/linux/kref.h
new file mode 100644 (file)
index 0000000..de5ddaa
--- /dev/null
@@ -0,0 +1,90 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013 François Tigeot
+ * 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_KREF_H_
+#define _LINUX_KREF_H_
+
+#include <sys/types.h>
+#include <sys/refcount.h>
+
+#include <asm/atomic.h>
+
+struct kref {
+       atomic_t refcount;
+};
+
+static inline void
+kref_init(struct kref *kref)
+{
+
+       refcount_init(&kref->refcount.counter, 1);
+}
+
+static inline void
+kref_get(struct kref *kref)
+{
+
+       refcount_acquire(&kref->refcount.counter);
+}
+
+static inline int
+kref_put(struct kref *kref, void (*rel)(struct kref *kref))
+{
+
+       if (refcount_release(&kref->refcount.counter)) {
+               rel(kref);
+               return 1;
+       }
+       return 0;
+}
+
+static inline int
+kref_sub(struct kref *kref, unsigned int count,
+    void (*rel)(struct kref *kref))
+{
+
+       while (count--) {
+               if (refcount_release(&kref->refcount.counter)) {
+                       rel(kref);
+                       return 1;
+               }
+       }
+       return 0;
+}
+
+static inline int __must_check
+kref_get_unless_zero(struct kref *kref)
+{
+
+       return atomic_add_unless(&kref->refcount, 1, 0);
+}
+
+#endif /* _LINUX_KREF_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/kthread.h b/sys/compat/linuxkpi/common/include/linux/kthread.h
new file mode 100644 (file)
index 0000000..fa8e9ba
--- /dev/null
@@ -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        _LINUX_KTHREAD_H_
+#define        _LINUX_KTHREAD_H_
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/kernel.h>
+#include <sys/kthread.h>
+#include <sys/sleepqueue.h>
+
+#include <linux/slab.h>
+#include <linux/sched.h>
+
+static inline void
+_kthread_fn(void *arg)
+{
+       struct task_struct *task;
+
+       task = arg;
+       task_struct_set(curthread, task);
+       if (task->should_stop == 0)
+               task->task_ret = task->task_fn(task->task_data);
+       PROC_LOCK(task->task_thread->td_proc);
+       task->should_stop = TASK_STOPPED;
+       wakeup(task);
+       PROC_UNLOCK(task->task_thread->td_proc);
+       kthread_exit();
+}
+
+static inline struct task_struct *
+_kthread_create(int (*threadfn)(void *data), void *data)
+{
+       struct task_struct *task;
+
+       task = kzalloc(sizeof(*task), GFP_KERNEL);
+       task->task_fn = threadfn;
+       task->task_data = data;
+
+       return (task);
+}
+
+struct task_struct *kthread_create(int (*threadfn)(void *data),
+                                   void *data,
+                                   const char namefmt[], ...)
+        __attribute__((format(printf, 3, 4)));
+
+#define        kthread_run(fn, data, fmt, ...)                                 \
+({                                                                     \
+       struct task_struct *_task;                                      \
+                                                                       \
+       _task = _kthread_create((fn), (data));                          \
+       if (kthread_add(_kthread_fn, _task, NULL, &_task->task_thread,  \
+           0, 0, fmt, ## __VA_ARGS__)) {                               \
+               kfree(_task);                                           \
+               _task = NULL;                                           \
+       } else                                                          \
+               task_struct_set(_task->task_thread, _task);             \
+       _task;                                                          \
+})
+
+#define        kthread_should_stop()   current->should_stop
+
+static inline int
+kthread_stop(struct task_struct *task)
+{
+
+       PROC_LOCK(task->task_thread->td_proc);
+       task->should_stop = TASK_SHOULD_STOP;
+       wake_up_process(task);
+       while (task->should_stop != TASK_STOPPED)
+               msleep(task, &task->task_thread->td_proc->p_mtx, PWAIT,
+                   "kstop", hz);
+       PROC_UNLOCK(task->task_thread->td_proc);
+       return task->task_ret;
+}
+
+#endif /* _LINUX_KTHREAD_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/ktime.h b/sys/compat/linuxkpi/common/include/linux/ktime.h
new file mode 100644 (file)
index 0000000..c9fa81c
--- /dev/null
@@ -0,0 +1,135 @@
+/*-
+ * Copyright (c) 2014-2015 Mellanox Technologies, Ltd.
+ * Copyright (c) 2015 François Tigeot
+ * 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_KTIME_H
+#define _LINUX_KTIME_H
+
+#include <linux/types.h>
+#include <linux/time.h>
+#include <linux/jiffies.h>
+
+#define ktime_get_ts(x) getnanouptime(x)
+
+/* time values in nanoseconds */
+union ktime {
+       int64_t tv64;
+};
+
+typedef union ktime ktime_t;
+
+#define KTIME_MAX                       ((s64)~((u64)1 << 63))
+#define KTIME_SEC_MAX                   (KTIME_MAX / NSEC_PER_SEC)
+
+static inline int64_t
+ktime_to_ns(ktime_t kt)
+{
+       return kt.tv64;
+}
+
+static inline struct timeval
+ktime_to_timeval(ktime_t kt)
+{
+       return ns_to_timeval(kt.tv64);
+}
+
+static inline ktime_t
+ktime_add_ns(ktime_t kt, int64_t ns)
+{
+       ktime_t res;
+
+       res.tv64 = kt.tv64 + ns;
+       return kt;
+}
+
+static inline ktime_t
+ktime_sub_ns(ktime_t kt, int64_t ns)
+{
+       ktime_t res;
+
+       res.tv64 = kt.tv64 - ns;
+       return kt;
+}
+
+static inline ktime_t
+ktime_set(const long secs, const unsigned long nsecs)
+{
+       ktime_t retval = { (s64)secs * NSEC_PER_SEC + (s64)nsecs };
+       return (retval);
+}
+
+static inline ktime_t
+ktime_sub(ktime_t lhs, ktime_t rhs)
+{
+       lhs.tv64 -= rhs.tv64;
+       return (lhs);
+}
+
+static inline ktime_t
+ktime_add(ktime_t lhs, ktime_t rhs)
+{
+       lhs.tv64 += rhs.tv64;
+       return (lhs);
+}
+
+static inline ktime_t
+timespec_to_ktime(struct timespec ts)
+{
+       return (ktime_set(ts.tv_sec, ts.tv_nsec));
+}
+
+static inline ktime_t
+timeval_to_ktime(struct timeval tv)
+{
+       return (ktime_set(tv.tv_sec, tv.tv_usec * NSEC_PER_USEC));
+}
+
+#define ktime_to_timespec(kt)          ns_to_timespec((kt).tv64)
+#define ktime_to_timeval(kt)           ns_to_timeval((kt).tv64)
+#define ktime_to_ns(kt)                        ((kt).tv64)
+
+static inline s64
+ktime_get_ns(void)
+{
+       struct timespec ts;
+       ktime_t kt;
+
+       ktime_get_ts(&ts);
+       kt = timespec_to_ktime(ts);
+       return (ktime_to_ns(kt));
+}
+
+static inline ktime_t
+ktime_get(void)
+{
+       struct timespec ts;
+
+       ktime_get_ts(&ts);
+       return (timespec_to_ktime(ts));
+}
+
+#endif /* _LINUX_KTIME_H */
diff --git a/sys/compat/linuxkpi/common/include/linux/list.h b/sys/compat/linuxkpi/common/include/linux/list.h
new file mode 100644 (file)
index 0000000..bfa7d97
--- /dev/null
@@ -0,0 +1,432 @@
+/*-
+ * 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 _LINUX_LIST_H_
+#define _LINUX_LIST_H_
+
+/*
+ * Since LIST_HEAD conflicts with the linux definition we must include any
+ * FreeBSD header which requires it here so it is resolved with the correct
+ * definition prior to the undef.
+ */
+#include <linux/types.h>
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/queue.h>
+#include <sys/cpuset.h>
+#include <sys/jail.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/proc.h>
+#include <sys/vnode.h>
+#include <sys/conf.h>
+#include <sys/socket.h>
+#include <sys/mbuf.h>
+
+#include <net/bpf.h>
+#include <net/if.h>
+#include <net/if_var.h>
+#include <net/if_types.h>
+#include <net/if_media.h>
+#include <net/vnet.h>
+
+#include <netinet/in.h>
+#include <netinet/in_pcb.h>
+#include <netinet/in_var.h>
+
+#include <netinet6/in6_var.h>
+#include <netinet6/nd6.h>
+
+#include <vm/vm.h>
+#include <vm/vm_object.h>
+
+#define        prefetch(x)
+
+struct list_head {
+       struct list_head *next;
+       struct list_head *prev;
+};
+
+static inline void
+INIT_LIST_HEAD(struct list_head *list)
+{
+
+       list->next = list->prev = list;
+}
+static inline int
+list_empty(const struct list_head *head)
+{
+
+       return (head->next == head);
+}
+
+static inline void
+list_del(struct list_head *entry)
+{
+
+       entry->next->prev = entry->prev;
+       entry->prev->next = entry->next;
+}
+
+static inline void
+list_replace(struct list_head *old, struct list_head *new)
+{
+       new->next = old->next;
+       new->next->prev = new;
+       new->prev = old->prev;
+       new->prev->next = new;
+}
+
+static inline void
+_list_add(struct list_head *new, struct list_head *prev,
+    struct list_head *next)
+{
+
+       next->prev = new;
+       new->next = next;
+       new->prev = prev;
+       prev->next = new;
+}
+
+static inline void
+list_del_init(struct list_head *entry)
+{      
+
+       list_del(entry);
+       INIT_LIST_HEAD(entry);
+}
+
+#define        list_entry(ptr, type, field)    container_of(ptr, type, field)
+
+#define list_first_entry(ptr, type, member) \
+        list_entry((ptr)->next, type, member)
+
+#define        list_next_entry(ptr, member)                                    \
+       list_entry(((ptr)->member.next), typeof(*(ptr)), member)
+
+#define        list_for_each(p, head)                                          \
+       for (p = (head)->next; p != (head); p = p->next)
+
+#define        list_for_each_safe(p, n, head)                                  \
+       for (p = (head)->next, n = p->next; p != (head); p = n, n = p->next)
+
+#define list_for_each_entry(p, h, field)                               \
+       for (p = list_entry((h)->next, typeof(*p), field); &p->field != (h); \
+           p = list_entry(p->field.next, typeof(*p), field))
+
+#define list_for_each_entry_safe(p, n, h, field)                       \
+       for (p = list_entry((h)->next, typeof(*p), field),              \
+           n = list_entry(p->field.next, typeof(*p), field); &p->field != (h);\
+           p = n, n = list_entry(n->field.next, typeof(*n), field))
+
+#define        list_for_each_entry_continue(p, h, field)                       \
+       for (p = list_next_entry((p), field); &p->field != (h);         \
+           p = list_next_entry((p), field))
+
+#define        list_for_each_entry_safe_from(pos, n, head, member)                     \
+       for (n = list_entry(pos->member.next, typeof(*pos), member);            \
+            &pos->member != (head);                                            \
+            pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+#define        list_for_each_entry_reverse(p, h, field)                        \
+       for (p = list_entry((h)->prev, typeof(*p), field); &p->field != (h); \
+           p = list_entry(p->field.prev, typeof(*p), field))
+
+#define        list_for_each_prev(p, h) for (p = (h)->prev; p != (h); p = p->prev)
+
+static inline void
+list_add(struct list_head *new, struct list_head *head)
+{
+
+       _list_add(new, head, head->next);
+}
+
+static inline void
+list_add_tail(struct list_head *new, struct list_head *head)
+{
+
+       _list_add(new, head->prev, head);
+}
+
+static inline void
+list_move(struct list_head *list, struct list_head *head)
+{
+
+       list_del(list);
+       list_add(list, head);
+}
+
+static inline void
+list_move_tail(struct list_head *entry, struct list_head *head)
+{
+
+       list_del(entry);
+       list_add_tail(entry, head);
+}
+
+static inline void
+_list_splice(const struct list_head *list, struct list_head *prev,  
+    struct list_head *next)
+{
+       struct list_head *first;
+       struct list_head *last;
+
+       if (list_empty(list))
+               return;
+       first = list->next;
+       last = list->prev;
+       first->prev = prev;
+       prev->next = first;
+       last->next = next;
+       next->prev = last;
+}
+
+static inline void
+list_splice(const struct list_head *list, struct list_head *head)
+{
+
+       _list_splice(list, head, head->next);
+} 
+
+static inline void
+list_splice_tail(struct list_head *list, struct list_head *head)
+{
+
+       _list_splice(list, head->prev, head);
+}
+static inline void
+list_splice_init(struct list_head *list, struct list_head *head)
+{
+
+       _list_splice(list, head, head->next);
+       INIT_LIST_HEAD(list);   
+}
+static inline void
+list_splice_tail_init(struct list_head *list, struct list_head *head)
+{
+
+       _list_splice(list, head->prev, head);
+       INIT_LIST_HEAD(list);
+}
+
+#undef LIST_HEAD
+#define LIST_HEAD(name)        struct list_head name = { &(name), &(name) }
+
+
+struct hlist_head {
+       struct hlist_node *first;
+};
+
+struct hlist_node {
+       struct hlist_node *next, **pprev;
+};
+
+#define        HLIST_HEAD_INIT { }
+#define        HLIST_HEAD(name) struct hlist_head name = HLIST_HEAD_INIT
+#define        INIT_HLIST_HEAD(head) (head)->first = NULL
+#define        INIT_HLIST_NODE(node)                                           \
+do {                                                                   \
+       (node)->next = NULL;                                            \
+       (node)->pprev = NULL;                                           \
+} while (0)
+
+static inline int
+hlist_unhashed(const struct hlist_node *h)
+{
+
+       return !h->pprev;
+}
+
+static inline int
+hlist_empty(const struct hlist_head *h)
+{
+
+       return !h->first;
+}
+
+static inline void
+hlist_del(struct hlist_node *n)
+{
+
+        if (n->next)
+                n->next->pprev = n->pprev;
+        *n->pprev = n->next;
+}
+
+static inline void
+hlist_del_init(struct hlist_node *n)
+{
+
+       if (hlist_unhashed(n))
+               return;
+       hlist_del(n);
+       INIT_HLIST_NODE(n);
+}
+
+static inline void
+hlist_add_head(struct hlist_node *n, struct hlist_head *h)
+{
+
+       n->next = h->first;
+       if (h->first)
+               h->first->pprev = &n->next;
+       h->first = n;
+       n->pprev = &h->first;
+}
+
+static inline void
+hlist_add_before(struct hlist_node *n, struct hlist_node *next)
+{
+
+       n->pprev = next->pprev;
+       n->next = next;
+       next->pprev = &n->next;
+       *(n->pprev) = n;
+}
+static inline void
+hlist_add_after(struct hlist_node *n, struct hlist_node *next)
+{
+
+       next->next = n->next;
+       n->next = next;
+       next->pprev = &n->next;
+       if (next->next)
+               next->next->pprev = &next->next;
+}
+static inline void
+hlist_move_list(struct hlist_head *old, struct hlist_head *new)
+{
+
+       new->first = old->first;
+       if (new->first)
+               new->first->pprev = &new->first;
+       old->first = NULL;
+}
+
+/**
+ * list_is_singular - tests whether a list has just one entry.
+ * @head: the list to test.
+ */
+static inline int list_is_singular(const struct list_head *head)
+{
+       return !list_empty(head) && (head->next == head->prev);
+}
+
+static inline void __list_cut_position(struct list_head *list,
+               struct list_head *head, struct list_head *entry)
+{
+       struct list_head *new_first = entry->next;
+       list->next = head->next;
+       list->next->prev = list;
+       list->prev = entry;
+       entry->next = list;
+       head->next = new_first;
+       new_first->prev = head;
+}
+
+/**
+ * list_cut_position - cut a list into two
+ * @list: a new list to add all removed entries
+ * @head: a list with entries
+ * @entry: an entry within head, could be the head itself
+ *     and if so we won't cut the list
+ *
+ * This helper moves the initial part of @head, up to and
+ * including @entry, from @head to @list. You should
+ * pass on @entry an element you know is on @head. @list
+ * should be an empty list or a list you do not care about
+ * losing its data.
+ *
+ */
+static inline void list_cut_position(struct list_head *list,
+               struct list_head *head, struct list_head *entry)
+{
+       if (list_empty(head))
+               return;
+       if (list_is_singular(head) &&
+               (head->next != entry && head != entry))
+               return;
+       if (entry == head)
+               INIT_LIST_HEAD(list);
+       else
+               __list_cut_position(list, head, entry);
+}
+
+/**
+ *  list_is_last - tests whether @list is the last entry in list @head
+ *   @list: the entry to test
+ *    @head: the head of the list
+ */
+static inline int list_is_last(const struct list_head *list,
+                                const struct list_head *head)
+{
+        return list->next == head;
+}
+#define        hlist_entry(ptr, type, field)   container_of(ptr, type, field)
+
+#define        hlist_for_each(p, head)                                         \
+       for (p = (head)->first; p; p = p->next)
+
+#define        hlist_for_each_safe(p, n, head)                                 \
+       for (p = (head)->first; p && ({ n = p->next; 1; }); p = n)
+
+#define        hlist_entry_safe(ptr, type, member) \
+       ((ptr) ? hlist_entry(ptr, type, member) : NULL)
+
+#define        hlist_for_each_entry(pos, head, member)                         \
+       for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\
+            pos;                                                       \
+            pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
+
+#define hlist_for_each_entry_continue(tp, p, field)                    \
+       for (p = (p)->next;                                             \
+           p ? (tp = hlist_entry(p, typeof(*tp), field)): NULL; p = p->next)
+
+#define        hlist_for_each_entry_from(tp, p, field)                         \
+       for (; p ? (tp = hlist_entry(p, typeof(*tp), field)): NULL; p = p->next)
+
+#define hlist_for_each_entry_safe(tpos, pos, n, head, member)           \
+       for (pos = (head)->first;                                        \
+            (pos) != 0 && ({ n = (pos)->next; \
+                tpos = hlist_entry((pos), typeof(*(tpos)), member); 1;}); \
+            pos = (n))
+
+#define        hlist_add_head_rcu(n, h)        hlist_add_head(n, h)
+
+#define        hlist_del_init_rcu(n)           hlist_del_init(n)
+
+#endif /* _LINUX_LIST_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/lockdep.h b/sys/compat/linuxkpi/common/include/linux/lockdep.h
new file mode 100644 (file)
index 0000000..2738693
--- /dev/null
@@ -0,0 +1,41 @@
+/*-
+ * 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        _LINUX_LOCKDEP_H_
+#define        _LINUX_LOCKDEP_H_
+
+struct lock_class_key {
+};
+
+#define lockdep_set_class(lock, key)
+
+#define lockdep_set_class_and_name(lock, key, name)
+
+#endif  /* _LINUX_LOCKDEP_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/log2.h b/sys/compat/linuxkpi/common/include/linux/log2.h
new file mode 100644 (file)
index 0000000..a44c560
--- /dev/null
@@ -0,0 +1,131 @@
+/*-
+ * 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_LOG2_H_
+#define        _LINUX_LOG2_H_
+
+#include <linux/types.h>
+
+#include <sys/libkern.h>
+
+static inline unsigned long
+roundup_pow_of_two(unsigned long x)
+{
+       return (1UL << flsl(x - 1));
+}
+
+static inline int
+is_power_of_2(unsigned long n)
+{
+       return (n == roundup_pow_of_two(n));
+}
+
+static inline unsigned long
+rounddown_pow_of_two(unsigned long x)
+{
+        return (1UL << (flsl(x) - 1));
+}
+
+#define        ilog2(n)                                \
+(                                              \
+       __builtin_constant_p(n) ? (             \
+               (n) < 1 ? -1 :                  \
+               (n) & (1ULL << 63) ? 63 :       \
+               (n) & (1ULL << 62) ? 62 :       \
+               (n) & (1ULL << 61) ? 61 :       \
+               (n) & (1ULL << 60) ? 60 :       \
+               (n) & (1ULL << 59) ? 59 :       \
+               (n) & (1ULL << 58) ? 58 :       \
+               (n) & (1ULL << 57) ? 57 :       \
+               (n) & (1ULL << 56) ? 56 :       \
+               (n) & (1ULL << 55) ? 55 :       \
+               (n) & (1ULL << 54) ? 54 :       \
+               (n) & (1ULL << 53) ? 53 :       \
+               (n) & (1ULL << 52) ? 52 :       \
+               (n) & (1ULL << 51) ? 51 :       \
+               (n) & (1ULL << 50) ? 50 :       \
+               (n) & (1ULL << 49) ? 49 :       \
+               (n) & (1ULL << 48) ? 48 :       \
+               (n) & (1ULL << 47) ? 47 :       \
+               (n) & (1ULL << 46) ? 46 :       \
+               (n) & (1ULL << 45) ? 45 :       \
+               (n) & (1ULL << 44) ? 44 :       \
+               (n) & (1ULL << 43) ? 43 :       \
+               (n) & (1ULL << 42) ? 42 :       \
+               (n) & (1ULL << 41) ? 41 :       \
+               (n) & (1ULL << 40) ? 40 :       \
+               (n) & (1ULL << 39) ? 39 :       \
+               (n) & (1ULL << 38) ? 38 :       \
+               (n) & (1ULL << 37) ? 37 :       \
+               (n) & (1ULL << 36) ? 36 :       \
+               (n) & (1ULL << 35) ? 35 :       \
+               (n) & (1ULL << 34) ? 34 :       \
+               (n) & (1ULL << 33) ? 33 :       \
+               (n) & (1ULL << 32) ? 32 :       \
+               (n) & (1ULL << 31) ? 31 :       \
+               (n) & (1ULL << 30) ? 30 :       \
+               (n) & (1ULL << 29) ? 29 :       \
+               (n) & (1ULL << 28) ? 28 :       \
+               (n) & (1ULL << 27) ? 27 :       \
+               (n) & (1ULL << 26) ? 26 :       \
+               (n) & (1ULL << 25) ? 25 :       \
+               (n) & (1ULL << 24) ? 24 :       \
+               (n) & (1ULL << 23) ? 23 :       \
+               (n) & (1ULL << 22) ? 22 :       \
+               (n) & (1ULL << 21) ? 21 :       \
+               (n) & (1ULL << 20) ? 20 :       \
+               (n) & (1ULL << 19) ? 19 :       \
+               (n) & (1ULL << 18) ? 18 :       \
+               (n) & (1ULL << 17) ? 17 :       \
+               (n) & (1ULL << 16) ? 16 :       \
+               (n) & (1ULL << 15) ? 15 :       \
+               (n) & (1ULL << 14) ? 14 :       \
+               (n) & (1ULL << 13) ? 13 :       \
+               (n) & (1ULL << 12) ? 12 :       \
+               (n) & (1ULL << 11) ? 11 :       \
+               (n) & (1ULL << 10) ? 10 :       \
+               (n) & (1ULL <<  9) ?  9 :       \
+               (n) & (1ULL <<  8) ?  8 :       \
+               (n) & (1ULL <<  7) ?  7 :       \
+               (n) & (1ULL <<  6) ?  6 :       \
+               (n) & (1ULL <<  5) ?  5 :       \
+               (n) & (1ULL <<  4) ?  4 :       \
+               (n) & (1ULL <<  3) ?  3 :       \
+               (n) & (1ULL <<  2) ?  2 :       \
+               (n) & (1ULL <<  1) ?  1 :       \
+               (n) & (1ULL <<  0) ?  0 :       \
+               -1) :                           \
+       (sizeof(n) <= 4) ?                      \
+       fls((u32)(n)) - 1 : flsll((u64)(n)) - 1 \
+)
+
+#define        order_base_2(x) ilog2(roundup_pow_of_two(x))
+
+#endif /* _LINUX_LOG2_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/math64.h b/sys/compat/linuxkpi/common/include/linux/math64.h
new file mode 100644 (file)
index 0000000..2a488f1
--- /dev/null
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 2007 Cisco Systems, Inc.  All rights reserved.
+ * Copyright (c) 2014-2015 Mellanox Technologies, Ltd. All rights reserved.
+ * 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_MATH64_H
+#define        _LINUX_MATH64_H
+
+#include <sys/stdint.h>
+
+#define        do_div(n, base) ({                      \
+       uint32_t __base = (base);               \
+       uint32_t __rem;                         \
+       __rem = ((uint64_t)(n)) % __base;       \
+       (n) = ((uint64_t)(n)) / __base;         \
+       __rem;                                  \
+})
+
+static inline uint64_t
+div_u64_rem(uint64_t dividend, uint32_t divisor, uint32_t *remainder)
+{
+       *remainder = dividend % divisor;
+       return (dividend / divisor);
+}
+
+static inline uint64_t
+div_u64(uint64_t dividend, uint32_t divisor)
+{
+       return (dividend / divisor);
+}
+
+#endif                                 /* _LINUX_MATH64_H */
diff --git a/sys/compat/linuxkpi/common/include/linux/miscdevice.h b/sys/compat/linuxkpi/common/include/linux/miscdevice.h
new file mode 100644 (file)
index 0000000..96d8fe7
--- /dev/null
@@ -0,0 +1,76 @@
+/*-
+ * 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        _LINUX_MISCDEVICE_H_
+#define        _LINUX_MISCDEVICE_H_
+
+#define        MISC_DYNAMIC_MINOR      -1
+
+#include <linux/device.h>
+#include <linux/cdev.h>
+
+struct miscdevice  {
+       const char      *name;
+       struct device   *this_device;
+       const struct file_operations *fops;
+       struct cdev     *cdev;
+       int             minor;
+       const char *nodename;
+       umode_t mode;
+};
+
+extern struct class    miscclass;
+
+static inline int
+misc_register(struct miscdevice *misc)
+{
+       misc->this_device = device_create(&miscclass, &linux_rootdev, 0, misc, 
+           misc->name);
+       misc->cdev = cdev_alloc();
+       if (misc->cdev == NULL)
+               return -ENOMEM;
+       misc->cdev->owner = THIS_MODULE;
+       misc->cdev->ops = misc->fops;
+       kobject_set_name(&misc->cdev->kobj, misc->name);
+        if (cdev_add(misc->cdev, misc->this_device->devt, 1))
+               return -EINVAL;
+       return (0);
+}
+
+static inline int
+misc_deregister(struct miscdevice *misc)
+{
+       device_destroy(&miscclass, misc->this_device->devt);
+       cdev_del(misc->cdev);
+
+       return (0);
+}
+
+#endif /* _LINUX_MISCDEVICE_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/mm.h b/sys/compat/linuxkpi/common/include/linux/mm.h
new file mode 100644 (file)
index 0000000..3835e34
--- /dev/null
@@ -0,0 +1,111 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
+ * Copyright (c) 2015 François Tigeot
+ * Copyright (c) 2015 Matthew Dillon <dillon@backplane.com>
+ * 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_MM_H_
+#define        _LINUX_MM_H_
+
+#include <linux/spinlock.h>
+#include <linux/gfp.h>
+#include <linux/kernel.h>
+
+#define        PAGE_ALIGN(x)   ALIGN(x, PAGE_SIZE)
+
+struct vm_area_struct {
+       vm_offset_t     vm_start;
+       vm_offset_t     vm_end;
+       vm_offset_t     vm_pgoff;
+       vm_paddr_t      vm_pfn;         /* PFN For mmap. */
+       vm_size_t       vm_len;         /* length for mmap. */
+       vm_memattr_t    vm_page_prot;
+};
+
+/*
+ * Compute log2 of the power of two rounded up count of pages
+ * needed for size bytes.
+ */
+static inline int
+get_order(unsigned long size)
+{
+       int order;
+
+       size = (size - 1) >> PAGE_SHIFT;
+       order = 0;
+       while (size) {
+               order++;
+               size >>= 1;
+       }
+       return (order);
+}
+
+static inline void *
+lowmem_page_address(struct page *page)
+{
+
+       return page_address(page);
+}
+
+/*
+ * This only works via mmap ops.
+ */
+static inline int
+io_remap_pfn_range(struct vm_area_struct *vma,
+    unsigned long addr, unsigned long pfn, unsigned long size,
+    vm_memattr_t prot)
+{
+       vma->vm_page_prot = prot;
+       vma->vm_pfn = pfn;
+       vma->vm_len = size;
+
+       return (0);
+}
+
+static inline unsigned long
+vma_pages(struct vm_area_struct *vma)
+{
+       return ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT);
+}
+
+#define        offset_in_page(off)     ((off) & (PAGE_SIZE - 1))
+
+static inline void
+set_page_dirty(struct vm_page *page)
+{
+       vm_page_dirty(page);
+}
+
+static inline void
+get_page(struct vm_page *page)
+{
+       vm_page_hold(page);
+}
+
+#endif /* _LINUX_MM_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/module.h b/sys/compat/linuxkpi/common/include/linux/module.h
new file mode 100644 (file)
index 0000000..0caa2b0
--- /dev/null
@@ -0,0 +1,101 @@
+/*-
+ * 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        _LINUX_MODULE_H_
+#define        _LINUX_MODULE_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/module.h>
+
+#include <linux/list.h>
+#include <linux/compiler.h>
+#include <linux/kobject.h>
+#include <linux/moduleparam.h>
+#include <linux/slab.h>
+
+#define MODULE_AUTHOR(name)
+#define MODULE_DESCRIPTION(name)
+#define MODULE_LICENSE(name)
+
+#define        THIS_MODULE     ((struct module *)0)
+
+#define        EXPORT_SYMBOL(name)
+#define        EXPORT_SYMBOL_GPL(name)
+
+/* OFED pre-module initialization */
+#define        SI_SUB_OFED_PREINIT     (SI_SUB_ROOT_CONF - 2)
+/* OFED default module initialization */
+#define        SI_SUB_OFED_MODINIT     (SI_SUB_ROOT_CONF - 1)
+
+#include <sys/linker.h>
+
+static inline void
+_module_run(void *arg)
+{
+       void (*fn)(void);
+#ifdef OFED_DEBUG_INIT
+       char name[1024];
+       caddr_t pc;
+       long offset;
+
+       pc = (caddr_t)arg;
+       if (linker_search_symbol_name(pc, name, sizeof(name), &offset) != 0)
+               printf("Running ??? (%p)\n", pc);
+       else
+               printf("Running %s (%p)\n", name, pc);
+#endif
+       fn = arg;
+       DROP_GIANT();
+       fn();
+       PICKUP_GIANT();
+}
+
+#define        module_init(fn)                                                 \
+       SYSINIT(fn, SI_SUB_OFED_MODINIT, SI_ORDER_FIRST, _module_run, (fn))
+
+#define        module_exit(fn)                                         \
+       SYSUNINIT(fn, SI_SUB_OFED_MODINIT, SI_ORDER_SECOND, _module_run, (fn))
+
+/*
+ * The following two macros are a workaround for not having a module
+ * load and unload order resolver:
+ */
+#define        module_init_order(fn, order)                                    \
+       SYSINIT(fn, SI_SUB_OFED_MODINIT, (order), _module_run, (fn))
+
+#define        module_exit_order(fn, order)                            \
+       SYSUNINIT(fn, SI_SUB_OFED_MODINIT, (order), _module_run, (fn))
+
+#define        module_get(module)
+#define        module_put(module)
+#define        try_module_get(module)  1
+
+#endif /* _LINUX_MODULE_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/moduleparam.h b/sys/compat/linuxkpi/common/include/linux/moduleparam.h
new file mode 100644 (file)
index 0000000..9699b33
--- /dev/null
@@ -0,0 +1,234 @@
+/*-
+ * 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        _LINUX_MODULEPARAM_H_
+#define        _LINUX_MODULEPARAM_H_
+
+#include <linux/types.h>
+
+/*
+ * These are presently not hooked up to anything.  In linux the parameters
+ * can be set when modules are loaded.  On FreeBSD these could be mapped
+ * to kenv in the future.
+ */
+struct kernel_param;
+
+typedef int (*param_set_fn)(const char *val, struct kernel_param *kp);
+typedef int (*param_get_fn)(char *buffer, struct kernel_param *kp);
+
+struct kernel_param {
+       const char      *name;
+       u16             perm;
+       u16             flags;
+       param_set_fn    set;
+       param_get_fn    get;
+       union {
+               void    *arg;
+               struct kparam_string    *str;
+               struct kparam_array     *arr;
+       } un;
+};
+
+#define        KPARAM_ISBOOL   2
+
+struct kparam_string {
+       unsigned int maxlen;
+       char *string;
+};
+
+struct kparam_array
+{
+       unsigned int    max;
+       unsigned int    *num;
+       param_set_fn    set;
+       param_get_fn    get;
+       unsigned int    elemsize;
+       void            *elem;
+};
+
+static inline void
+param_sysinit(struct kernel_param *param)
+{
+}
+
+#define        module_param_call(name, set, get, arg, perm)                    \
+       static struct kernel_param __param_##name =                     \
+           { #name, perm, 0, set, get, { arg } };                      \
+       SYSINIT(name##_param_sysinit, SI_SUB_DRIVERS, SI_ORDER_FIRST,   \
+           param_sysinit, &__param_##name);
+
+#define        module_param_string(name, string, len, perm)
+
+#define        module_param_named(name, var, type, mode)                       \
+       module_param_call(name, param_set_##type, param_get_##type, &var, mode)
+
+#define        module_param(var, type, mode)                                   \
+       module_param_named(var, var, type, mode)
+
+#define module_param_array(var, type, addr_argc, mode)                  \
+        module_param_named(var, var, type, mode)
+
+#define        MODULE_PARM_DESC(name, desc)
+
+static inline int
+param_set_byte(const char *val, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+static inline int
+param_get_byte(char *buffer, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+
+static inline int
+param_set_short(const char *val, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+static inline int
+param_get_short(char *buffer, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+
+static inline int
+param_set_ushort(const char *val, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+static inline int
+param_get_ushort(char *buffer, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+
+static inline int
+param_set_int(const char *val, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+static inline int
+param_get_int(char *buffer, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+
+static inline int
+param_set_uint(const char *val, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+static inline int
+param_get_uint(char *buffer, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+
+static inline int
+param_set_long(const char *val, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+static inline int
+param_get_long(char *buffer, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+
+static inline int
+param_set_ulong(const char *val, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+static inline int
+param_get_ulong(char *buffer, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+
+static inline int
+param_set_charp(const char *val, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+static inline int
+param_get_charp(char *buffer, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+
+static inline int
+param_set_bool(const char *val, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+static inline int
+param_get_bool(char *buffer, struct kernel_param *kp)
+{
+
+       return 0;
+}
+
+#endif /* _LINUX_MODULEPARAM_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/mutex.h b/sys/compat/linuxkpi/common/include/linux/mutex.h
new file mode 100644 (file)
index 0000000..aee34cf
--- /dev/null
@@ -0,0 +1,64 @@
+/*-
+ * 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        _LINUX_MUTEX_H_
+#define        _LINUX_MUTEX_H_
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/sx.h>
+
+#include <linux/spinlock.h>
+
+typedef struct mutex {
+       struct sx sx;
+} mutex_t;
+
+#define        mutex_lock(_m)                  sx_xlock(&(_m)->sx)
+#define        mutex_lock_nested(_m, _s)       mutex_lock(_m)
+#define        mutex_lock_interruptible(_m)    ({ mutex_lock((_m)); 0; })
+#define        mutex_unlock(_m)                sx_xunlock(&(_m)->sx)
+#define        mutex_trylock(_m)               !!sx_try_xlock(&(_m)->sx)
+
+#define DEFINE_MUTEX(lock)                                             \
+       mutex_t lock;                                                   \
+       SX_SYSINIT_FLAGS(lock, &(lock).sx, "lnxmtx", SX_NOWITNESS)
+
+static inline void
+linux_mutex_init(mutex_t *m)
+{
+
+       memset(&m->sx, 0, sizeof(m->sx));
+       sx_init_flags(&m->sx, "lnxmtx",  SX_NOWITNESS);
+}
+
+#define        mutex_init      linux_mutex_init
+
+#endif /* _LINUX_MUTEX_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/net.h b/sys/compat/linuxkpi/common/include/linux/net.h
new file mode 100644 (file)
index 0000000..166b750
--- /dev/null
@@ -0,0 +1,75 @@
+/*-
+ * 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        _LINUX_NET_H_
+#define        _LINUX_NET_H_
+
+#include <sys/protosw.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+
+static inline int
+sock_create_kern(int family, int type, int proto, struct socket **res)
+{
+       return -socreate(family, res, type, proto, curthread->td_ucred,
+           curthread);
+}
+
+static inline int
+sock_getname(struct socket *so, struct sockaddr *addr, int *sockaddr_len,
+    int peer)
+{
+       struct sockaddr *nam;
+       int error;
+
+       nam = NULL;
+       if (peer) {
+               if ((so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0)
+                       return (-ENOTCONN);
+
+               error = (*so->so_proto->pr_usrreqs->pru_peeraddr)(so, &nam);
+       } else
+               error = (*so->so_proto->pr_usrreqs->pru_sockaddr)(so, &nam);
+       if (error)
+               return (-error);
+       *addr = *nam;
+       *sockaddr_len = addr->sa_len;
+
+       free(nam, M_SONAME);
+       return (0);
+}
+
+static inline void
+sock_release(struct socket *so)
+{
+       soclose(so);
+}
+
+#endif /* _LINUX_NET_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/netdevice.h b/sys/compat/linuxkpi/common/include/linux/netdevice.h
new file mode 100644 (file)
index 0000000..1b1f8bf
--- /dev/null
@@ -0,0 +1,205 @@
+/*-
+ * 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        _LINUX_NETDEVICE_H_
+#define        _LINUX_NETDEVICE_H_
+
+#include <linux/types.h>
+
+#include <sys/socket.h>
+
+#include <net/if_types.h>
+#include <net/if.h>
+#include <net/if_var.h>
+#include <net/if_dl.h>
+
+#include <linux/completion.h>
+#include <linux/device.h>
+#include <linux/workqueue.h>
+#include <linux/net.h>
+#include <linux/notifier.h>
+
+struct net {
+};
+
+extern struct net init_net;
+
+#define        MAX_ADDR_LEN            20
+
+#define        net_device      ifnet
+
+#define        dev_get_by_index(n, idx)        ifnet_byindex_ref((idx))
+#define        dev_hold(d)     if_ref((d))
+#define        dev_put(d)      if_rele((d))
+
+#define        netif_running(dev)      !!((dev)->if_drv_flags & IFF_DRV_RUNNING)
+#define        netif_oper_up(dev)      !!((dev)->if_flags & IFF_UP)
+#define        netif_carrier_ok(dev)   netif_running(dev)
+
+static inline void *
+netdev_priv(const struct net_device *dev)
+{
+       return (dev->if_softc);
+}
+
+static inline void
+_handle_ifnet_link_event(void *arg, struct ifnet *ifp, int linkstate)
+{
+       struct notifier_block *nb;
+
+       nb = arg;
+       if (linkstate == LINK_STATE_UP)
+               nb->notifier_call(nb, NETDEV_UP, ifp);
+       else
+               nb->notifier_call(nb, NETDEV_DOWN, ifp);
+}
+
+static inline void
+_handle_ifnet_arrival_event(void *arg, struct ifnet *ifp)
+{
+       struct notifier_block *nb;
+
+       nb = arg;
+       nb->notifier_call(nb, NETDEV_REGISTER, ifp);
+}
+
+static inline void
+_handle_ifnet_departure_event(void *arg, struct ifnet *ifp)
+{
+       struct notifier_block *nb;
+
+       nb = arg;
+       nb->notifier_call(nb, NETDEV_UNREGISTER, ifp);
+}
+
+static inline void
+_handle_iflladdr_event(void *arg, struct ifnet *ifp)
+{
+       struct notifier_block *nb;
+
+       nb = arg;
+       nb->notifier_call(nb, NETDEV_CHANGEADDR, ifp);
+}
+
+static inline void
+_handle_ifaddr_event(void *arg, struct ifnet *ifp)
+{
+       struct notifier_block *nb;
+
+       nb = arg;
+       nb->notifier_call(nb, NETDEV_CHANGEIFADDR, ifp);
+}
+
+static inline int
+register_netdevice_notifier(struct notifier_block *nb)
+{
+
+       nb->tags[NETDEV_UP] = EVENTHANDLER_REGISTER(
+           ifnet_link_event, _handle_ifnet_link_event, nb, 0);
+       nb->tags[NETDEV_REGISTER] = EVENTHANDLER_REGISTER(
+           ifnet_arrival_event, _handle_ifnet_arrival_event, nb, 0);
+       nb->tags[NETDEV_UNREGISTER] = EVENTHANDLER_REGISTER(
+           ifnet_departure_event, _handle_ifnet_departure_event, nb, 0);
+       nb->tags[NETDEV_CHANGEADDR] = EVENTHANDLER_REGISTER(
+           iflladdr_event, _handle_iflladdr_event, nb, 0);
+
+       return (0);
+}
+
+static inline int
+register_inetaddr_notifier(struct notifier_block *nb)
+{
+
+        nb->tags[NETDEV_CHANGEIFADDR] = EVENTHANDLER_REGISTER(
+            ifaddr_event, _handle_ifaddr_event, nb, 0);
+        return (0);
+}
+
+static inline int
+unregister_netdevice_notifier(struct notifier_block *nb)
+{
+
+        EVENTHANDLER_DEREGISTER(ifnet_link_event, nb->tags[NETDEV_UP]);
+        EVENTHANDLER_DEREGISTER(ifnet_arrival_event, nb->tags[NETDEV_REGISTER]);
+        EVENTHANDLER_DEREGISTER(ifnet_departure_event,
+           nb->tags[NETDEV_UNREGISTER]);
+        EVENTHANDLER_DEREGISTER(iflladdr_event,
+            nb->tags[NETDEV_CHANGEADDR]);
+
+       return (0);
+}
+
+static inline int
+unregister_inetaddr_notifier(struct notifier_block *nb)
+{
+
+        EVENTHANDLER_DEREGISTER(ifaddr_event,
+            nb->tags[NETDEV_CHANGEIFADDR]);
+
+        return (0);
+}
+
+
+#define        rtnl_lock()
+#define        rtnl_unlock()
+
+static inline int
+dev_mc_delete(struct net_device *dev, void *addr, int alen, int all)
+{
+       struct sockaddr_dl sdl;
+
+       if (alen > sizeof(sdl.sdl_data))
+               return (-EINVAL);
+       memset(&sdl, 0, sizeof(sdl));
+       sdl.sdl_len = sizeof(sdl);
+       sdl.sdl_family = AF_LINK;
+       sdl.sdl_alen = alen;
+       memcpy(&sdl.sdl_data, addr, alen);
+
+       return -if_delmulti(dev, (struct sockaddr *)&sdl);
+}
+
+static inline int
+dev_mc_add(struct net_device *dev, void *addr, int alen, int newonly)
+{
+       struct sockaddr_dl sdl;
+
+       if (alen > sizeof(sdl.sdl_data))
+               return (-EINVAL);
+       memset(&sdl, 0, sizeof(sdl));
+       sdl.sdl_len = sizeof(sdl);
+       sdl.sdl_family = AF_LINK;
+       sdl.sdl_alen = alen;
+       memcpy(&sdl.sdl_data, addr, alen);
+
+       return -if_addmulti(dev, (struct sockaddr *)&sdl, NULL);
+}
+
+#endif /* _LINUX_NETDEVICE_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/notifier.h b/sys/compat/linuxkpi/common/include/linux/notifier.h
new file mode 100644 (file)
index 0000000..ca750e0
--- /dev/null
@@ -0,0 +1,58 @@
+/*-
+ * 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        _LINUX_NOTIFIER_H_
+#define        _LINUX_NOTIFIER_H_
+
+#include <sys/eventhandler.h>
+
+/*
+ * Max number of FreeBSD events to map to Linux events per notify type.
+ */
+#define        NOTIFY_DONE     0
+#define        _NOTIFY_COUNT   7
+
+struct notifier_block {
+       int (*notifier_call)(struct notifier_block *, unsigned long, void *);
+       struct notifier_block   *next;
+       int                     priority;
+       eventhandler_tag        tags[_NOTIFY_COUNT];
+};
+
+/* Values must be less than NOTIFY_COUNT */
+#define        NETDEV_UP               0x0001
+#define        NETDEV_DOWN             0x0002
+#define        NETDEV_REGISTER         0x0003
+#define        NETDEV_UNREGISTER       0x0004
+#define        NETDEV_CHANGEADDR       0x0005
+#define        NETDEV_CHANGEIFADDR     0x0006
+
+
+#endif /* _LINUX_NOTIFIER_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/page.h b/sys/compat/linuxkpi/common/include/linux/page.h
new file mode 100644 (file)
index 0000000..acc9f03
--- /dev/null
@@ -0,0 +1,53 @@
+/*-
+ * 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        _LINUX_PAGE_H_
+#define _LINUX_PAGE_H_
+
+#include <linux/types.h>
+
+#include <sys/param.h>
+
+#include <machine/atomic.h>
+#include <vm/vm.h>
+#include <vm/vm_page.h>
+
+#define page   vm_page
+
+#define        virt_to_page(x) PHYS_TO_VM_PAGE(vtophys((x)))
+
+#define        clear_page(page)                memset((page), 0, PAGE_SIZE)
+#define        pgprot_noncached(prot)          VM_MEMATTR_UNCACHEABLE
+#define        pgprot_writecombine(prot)       VM_MEMATTR_WRITE_COMBINING
+
+#undef PAGE_MASK
+#define        PAGE_MASK       (~(PAGE_SIZE-1))
+
+#endif /* _LINUX_PAGE_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h
new file mode 100644 (file)
index 0000000..54ea99c
--- /dev/null
@@ -0,0 +1,735 @@
+/*-
+ * 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        _LINUX_PCI_H_
+#define        _LINUX_PCI_H_
+
+#define        CONFIG_PCI_MSI
+
+#include <linux/types.h>
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/pciio.h>
+#include <sys/rman.h>
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pci_private.h>
+
+#include <machine/resource.h>
+
+#include <linux/list.h>
+#include <linux/dmapool.h>
+#include <linux/dma-mapping.h>
+#include <linux/compiler.h>
+#include <linux/errno.h>
+#include <asm/atomic.h>
+#include <linux/device.h>
+
+struct pci_device_id {
+       uint32_t        vendor;
+       uint32_t        device;
+        uint32_t       subvendor;
+       uint32_t        subdevice;
+       uint32_t        class_mask;
+       uintptr_t       driver_data;
+};
+
+#define        MODULE_DEVICE_TABLE(bus, table)
+#define        PCI_ANY_ID              (-1)
+#define        PCI_VENDOR_ID_MELLANOX                  0x15b3
+#define        PCI_VENDOR_ID_TOPSPIN                   0x1867
+#define        PCI_DEVICE_ID_MELLANOX_TAVOR            0x5a44
+#define        PCI_DEVICE_ID_MELLANOX_TAVOR_BRIDGE     0x5a46
+#define        PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT     0x6278
+#define        PCI_DEVICE_ID_MELLANOX_ARBEL            0x6282
+#define        PCI_DEVICE_ID_MELLANOX_SINAI_OLD        0x5e8c
+#define        PCI_DEVICE_ID_MELLANOX_SINAI            0x6274
+
+#define PCI_DEVFN(slot, func)   ((((slot) & 0x1f) << 3) | ((func) & 0x07))
+#define PCI_SLOT(devfn)         (((devfn) >> 3) & 0x1f)
+#define PCI_FUNC(devfn)         ((devfn) & 0x07)
+
+#define PCI_VDEVICE(_vendor, _device)                                  \
+           .vendor = PCI_VENDOR_ID_##_vendor, .device = (_device),     \
+           .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
+#define        PCI_DEVICE(_vendor, _device)                                    \
+           .vendor = (_vendor), .device = (_device),                   \
+           .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
+
+#define        to_pci_dev(n)   container_of(n, struct pci_dev, dev)
+
+#define        PCI_VENDOR_ID           PCIR_DEVVENDOR
+#define        PCI_COMMAND             PCIR_COMMAND
+#define        PCI_EXP_DEVCTL          PCIER_DEVICE_CTL                /* Device Control */
+#define        PCI_EXP_LNKCTL          PCIER_LINK_CTL                  /* Link Control */
+#define        PCI_EXP_FLAGS_TYPE      PCIEM_FLAGS_TYPE                /* Device/Port type */
+#define        PCI_EXP_DEVCAP          PCIER_DEVICE_CAP                /* Device capabilities */
+#define        PCI_EXP_DEVSTA          PCIER_DEVICE_STA                /* Device Status */
+#define        PCI_EXP_LNKCAP          PCIER_LINK_CAP                  /* Link Capabilities */
+#define        PCI_EXP_LNKSTA          PCIER_LINK_STA                  /* Link Status */
+#define        PCI_EXP_SLTCAP          PCIER_SLOT_CAP                  /* Slot Capabilities */
+#define        PCI_EXP_SLTCTL          PCIER_SLOT_CTL                  /* Slot Control */
+#define        PCI_EXP_SLTSTA          PCIER_SLOT_STA                  /* Slot Status */
+#define        PCI_EXP_RTCTL           PCIER_ROOT_CTL                  /* Root Control */
+#define        PCI_EXP_RTCAP           PCIER_ROOT_CAP                  /* Root Capabilities */
+#define        PCI_EXP_RTSTA           PCIER_ROOT_STA                  /* Root Status */
+#define        PCI_EXP_DEVCAP2         PCIER_DEVICE_CAP2               /* Device Capabilities 2 */
+#define        PCI_EXP_DEVCTL2         PCIER_DEVICE_CTL2               /* Device Control 2 */
+#define        PCI_EXP_LNKCAP2         PCIER_LINK_CAP2                 /* Link Capabilities 2 */
+#define        PCI_EXP_LNKCTL2         PCIER_LINK_CTL2                 /* Link Control 2 */
+#define        PCI_EXP_LNKSTA2         PCIER_LINK_STA2                 /* Link Status 2 */
+#define        PCI_EXP_FLAGS           PCIER_FLAGS                     /* Capabilities register */
+#define        PCI_EXP_FLAGS_VERS      PCIEM_FLAGS_VERSION             /* Capability version */
+#define        PCI_EXP_TYPE_ROOT_PORT  PCIEM_TYPE_ROOT_PORT            /* Root Port */
+#define        PCI_EXP_TYPE_ENDPOINT   PCIEM_TYPE_ENDPOINT             /* Express Endpoint */
+#define        PCI_EXP_TYPE_LEG_END    PCIEM_TYPE_LEGACY_ENDPOINT      /* Legacy Endpoint */
+#define        PCI_EXP_TYPE_DOWNSTREAM PCIEM_TYPE_DOWNSTREAM_PORT      /* Downstream Port */
+#define        PCI_EXP_FLAGS_SLOT      PCIEM_FLAGS_SLOT                /* Slot implemented */
+#define        PCI_EXP_TYPE_RC_EC      PCIEM_TYPE_ROOT_EC              /* Root Complex Event Collector */
+
+
+#define        IORESOURCE_MEM  SYS_RES_MEMORY
+#define        IORESOURCE_IO   SYS_RES_IOPORT
+#define        IORESOURCE_IRQ  SYS_RES_IRQ
+
+struct pci_dev;
+
+
+struct pci_driver {
+       struct list_head                links;
+       char                            *name;
+       const struct pci_device_id              *id_table;
+       int  (*probe)(struct pci_dev *dev, const struct pci_device_id *id);
+       void (*remove)(struct pci_dev *dev);
+        int  (*suspend) (struct pci_dev *dev, pm_message_t state);      /* Device suspended */
+        int  (*resume) (struct pci_dev *dev);                   /* Device woken up */
+       driver_t                        driver;
+       devclass_t                      bsdclass;
+        const struct pci_error_handlers       *err_handler;
+};
+
+extern struct list_head pci_drivers;
+extern struct list_head pci_devices;
+extern spinlock_t pci_lock;
+
+#define        __devexit_p(x)  x
+
+struct pci_dev {
+       struct device           dev;
+       struct list_head        links;
+       struct pci_driver       *pdrv;
+       uint64_t                dma_mask;
+       uint16_t                device;
+       uint16_t                vendor;
+       unsigned int            irq;
+       unsigned int            devfn;
+       u8                      revision;
+};
+
+static inline struct resource_list_entry *
+_pci_get_rle(struct pci_dev *pdev, int type, int rid)
+{
+       struct pci_devinfo *dinfo;
+       struct resource_list *rl;
+
+       dinfo = device_get_ivars(pdev->dev.bsddev);
+       rl = &dinfo->resources;
+       return resource_list_find(rl, type, rid);
+}
+
+static inline struct resource_list_entry *
+_pci_get_bar(struct pci_dev *pdev, int bar)
+{
+       struct resource_list_entry *rle;
+
+       bar = PCIR_BAR(bar);
+       if ((rle = _pci_get_rle(pdev, SYS_RES_MEMORY, bar)) == NULL)
+               rle = _pci_get_rle(pdev, SYS_RES_IOPORT, bar);
+       return (rle);
+}
+
+static inline struct device *
+_pci_find_irq_dev(unsigned int irq)
+{
+       struct pci_dev *pdev;
+
+       spin_lock(&pci_lock);
+       list_for_each_entry(pdev, &pci_devices, links) {
+               if (irq == pdev->dev.irq)
+                       break;
+               if (irq >= pdev->dev.msix && irq < pdev->dev.msix_max)
+                       break;
+       }
+       spin_unlock(&pci_lock);
+       if (pdev)
+               return &pdev->dev;
+       return (NULL);
+}
+
+static inline unsigned long
+pci_resource_start(struct pci_dev *pdev, int bar)
+{
+       struct resource_list_entry *rle;
+
+       if ((rle = _pci_get_bar(pdev, bar)) == NULL)
+               return (0);
+       return rle->start;
+}
+
+static inline unsigned long
+pci_resource_len(struct pci_dev *pdev, int bar)
+{
+       struct resource_list_entry *rle;
+
+       if ((rle = _pci_get_bar(pdev, bar)) == NULL)
+               return (0);
+       return rle->count;
+}
+
+/*
+ * All drivers just seem to want to inspect the type not flags.
+ */
+static inline int
+pci_resource_flags(struct pci_dev *pdev, int bar)
+{
+       struct resource_list_entry *rle;
+
+       if ((rle = _pci_get_bar(pdev, bar)) == NULL)
+               return (0);
+       return rle->type;
+}
+
+static inline const char *
+pci_name(struct pci_dev *d)
+{
+
+       return device_get_desc(d->dev.bsddev);
+}
+
+static inline void *
+pci_get_drvdata(struct pci_dev *pdev)
+{
+
+       return dev_get_drvdata(&pdev->dev);
+}
+
+static inline void
+pci_set_drvdata(struct pci_dev *pdev, void *data)
+{
+
+       dev_set_drvdata(&pdev->dev, data);
+}
+
+static inline int
+pci_enable_device(struct pci_dev *pdev)
+{
+
+       pci_enable_io(pdev->dev.bsddev, SYS_RES_IOPORT);
+       pci_enable_io(pdev->dev.bsddev, SYS_RES_MEMORY);
+       return (0);
+}
+
+static inline void
+pci_disable_device(struct pci_dev *pdev)
+{
+}
+
+static inline int
+pci_set_master(struct pci_dev *pdev)
+{
+
+       pci_enable_busmaster(pdev->dev.bsddev);
+       return (0);
+}
+
+static inline int
+pci_clear_master(struct pci_dev *pdev)
+{
+
+       pci_disable_busmaster(pdev->dev.bsddev);
+       return (0);
+}
+
+static inline int
+pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
+{
+       int rid;
+       int type;
+
+       type = pci_resource_flags(pdev, bar);
+       if (type == 0)
+               return (-ENODEV);
+       rid = PCIR_BAR(bar);
+       if (bus_alloc_resource_any(pdev->dev.bsddev, type, &rid,
+           RF_ACTIVE) == NULL)
+               return (-EINVAL);
+       return (0);
+}
+
+static inline void
+pci_release_region(struct pci_dev *pdev, int bar)
+{
+       struct resource_list_entry *rle;
+
+       if ((rle = _pci_get_bar(pdev, bar)) == NULL)
+               return;
+       bus_release_resource(pdev->dev.bsddev, rle->type, rle->rid, rle->res);
+}
+
+static inline void
+pci_release_regions(struct pci_dev *pdev)
+{
+       int i;
+
+       for (i = 0; i <= PCIR_MAX_BAR_0; i++)
+               pci_release_region(pdev, i);
+}
+
+static inline int
+pci_request_regions(struct pci_dev *pdev, const char *res_name)
+{
+       int error;
+       int i;
+
+       for (i = 0; i <= PCIR_MAX_BAR_0; i++) {
+               error = pci_request_region(pdev, i, res_name);
+               if (error && error != -ENODEV) {
+                       pci_release_regions(pdev);
+                       return (error);
+               }
+       }
+       return (0);
+}
+
+static inline void
+pci_disable_msix(struct pci_dev *pdev)
+{
+
+       pci_release_msi(pdev->dev.bsddev);
+}
+
+#define        PCI_CAP_ID_EXP  PCIY_EXPRESS
+#define        PCI_CAP_ID_PCIX PCIY_PCIX
+
+
+static inline int
+pci_find_capability(struct pci_dev *pdev, int capid)
+{
+       int reg;
+
+       if (pci_find_cap(pdev->dev.bsddev, capid, &reg))
+               return (0);
+       return (reg);
+}
+
+
+
+
+/**
+ * pci_pcie_cap - get the saved PCIe capability offset
+ * @dev: PCI device
+ *
+ * PCIe capability offset is calculated at PCI device initialization
+ * time and saved in the data structure. This function returns saved
+ * PCIe capability offset. Using this instead of pci_find_capability()
+ * reduces unnecessary search in the PCI configuration space. If you
+ * need to calculate PCIe capability offset from raw device for some
+ * reasons, please use pci_find_capability() instead.
+ */
+static inline int pci_pcie_cap(struct pci_dev *dev)
+{
+        return pci_find_capability(dev, PCI_CAP_ID_EXP);
+}
+
+
+static inline int
+pci_read_config_byte(struct pci_dev *pdev, int where, u8 *val)
+{
+
+       *val = (u8)pci_read_config(pdev->dev.bsddev, where, 1);
+       return (0);
+}
+
+static inline int
+pci_read_config_word(struct pci_dev *pdev, int where, u16 *val)
+{
+
+       *val = (u16)pci_read_config(pdev->dev.bsddev, where, 2);
+       return (0);
+}
+
+static inline int
+pci_read_config_dword(struct pci_dev *pdev, int where, u32 *val)
+{
+
+       *val = (u32)pci_read_config(pdev->dev.bsddev, where, 4);
+       return (0);
+} 
+
+static inline int
+pci_write_config_byte(struct pci_dev *pdev, int where, u8 val)
+{
+
+       pci_write_config(pdev->dev.bsddev, where, val, 1);
+       return (0);
+}
+
+static inline int
+pci_write_config_word(struct pci_dev *pdev, int where, u16 val)
+{
+
+       pci_write_config(pdev->dev.bsddev, where, val, 2);
+       return (0);
+}
+
+static inline int
+pci_write_config_dword(struct pci_dev *pdev, int where, u32 val)
+{ 
+
+       pci_write_config(pdev->dev.bsddev, where, val, 4);
+       return (0);
+}
+
+extern int pci_register_driver(struct pci_driver *pdrv);
+extern void pci_unregister_driver(struct pci_driver *pdrv);
+
+struct msix_entry {
+       int entry;
+       int vector;
+};
+
+/*
+ * Enable msix, positive errors indicate actual number of available
+ * vectors.  Negative errors are failures.
+ *
+ * NB: define added to prevent this definition of pci_enable_msix from
+ * clashing with the native FreeBSD version.
+ */
+#define        pci_enable_msix         linux_pci_enable_msix
+static inline int
+pci_enable_msix(struct pci_dev *pdev, struct msix_entry *entries, int nreq)
+{
+       struct resource_list_entry *rle;
+       int error;
+       int avail;
+       int i;
+
+       avail = pci_msix_count(pdev->dev.bsddev);
+       if (avail < nreq) {
+               if (avail == 0)
+                       return -EINVAL;
+               return avail;
+       }
+       avail = nreq;
+       if ((error = -pci_alloc_msix(pdev->dev.bsddev, &avail)) != 0)
+               return error;
+       /*
+        * Handle case where "pci_alloc_msix()" may allocate less
+        * interrupts than available and return with no error:
+        */
+       if (avail < nreq) {
+               pci_release_msi(pdev->dev.bsddev);
+               return avail;
+       }
+       rle = _pci_get_rle(pdev, SYS_RES_IRQ, 1);
+       pdev->dev.msix = rle->start;
+       pdev->dev.msix_max = rle->start + avail;
+       for (i = 0; i < nreq; i++)
+               entries[i].vector = pdev->dev.msix + i;
+       return (0);
+}
+
+#define        pci_enable_msix_range   linux_pci_enable_msix_range
+static inline int
+pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries,
+    int minvec, int maxvec)
+{
+       int nvec = maxvec;
+       int rc;
+
+       if (maxvec < minvec)
+               return (-ERANGE);
+
+       do {
+               rc = pci_enable_msix(dev, entries, nvec);
+               if (rc < 0) {
+                       return (rc);
+               } else if (rc > 0) {
+                       if (rc < minvec)
+                               return (-ENOSPC);
+                       nvec = rc;
+               }
+       } while (rc);
+       return (nvec);
+}
+
+static inline int pci_channel_offline(struct pci_dev *pdev)
+{
+        return false;
+}
+
+static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
+{
+        return -ENODEV;
+}
+static inline void pci_disable_sriov(struct pci_dev *dev)
+{
+}
+
+/**
+ * DEFINE_PCI_DEVICE_TABLE - macro used to describe a pci device table
+ * @_table: device table name
+ *
+ * This macro is used to create a struct pci_device_id array (a device table)
+ * in a generic manner.
+ */
+#define DEFINE_PCI_DEVICE_TABLE(_table) \
+       const struct pci_device_id _table[] __devinitdata
+
+
+/* XXX This should not be necessary. */
+#define        pcix_set_mmrbc(d, v)    0
+#define        pcix_get_max_mmrbc(d)   0
+#define        pcie_set_readrq(d, v)   0
+
+#define        PCI_DMA_BIDIRECTIONAL   0
+#define        PCI_DMA_TODEVICE        1
+#define        PCI_DMA_FROMDEVICE      2
+#define        PCI_DMA_NONE            3
+
+#define        pci_pool                dma_pool
+#define pci_pool_destroy       dma_pool_destroy
+#define pci_pool_alloc         dma_pool_alloc
+#define pci_pool_free          dma_pool_free
+#define        pci_pool_create(_name, _pdev, _size, _align, _alloc)            \
+           dma_pool_create(_name, &(_pdev)->dev, _size, _align, _alloc)
+#define        pci_free_consistent(_hwdev, _size, _vaddr, _dma_handle)         \
+           dma_free_coherent((_hwdev) == NULL ? NULL : &(_hwdev)->dev, \
+               _size, _vaddr, _dma_handle)
+#define        pci_map_sg(_hwdev, _sg, _nents, _dir)                           \
+           dma_map_sg((_hwdev) == NULL ? NULL : &(_hwdev->dev),        \
+               _sg, _nents, (enum dma_data_direction)_dir)
+#define        pci_map_single(_hwdev, _ptr, _size, _dir)                       \
+           dma_map_single((_hwdev) == NULL ? NULL : &(_hwdev->dev),    \
+               (_ptr), (_size), (enum dma_data_direction)_dir)
+#define        pci_unmap_single(_hwdev, _addr, _size, _dir)                    \
+           dma_unmap_single((_hwdev) == NULL ? NULL : &(_hwdev)->dev,  \
+               _addr, _size, (enum dma_data_direction)_dir)
+#define        pci_unmap_sg(_hwdev, _sg, _nents, _dir)                         \
+           dma_unmap_sg((_hwdev) == NULL ? NULL : &(_hwdev)->dev,      \
+               _sg, _nents, (enum dma_data_direction)_dir)
+#define        pci_map_page(_hwdev, _page, _offset, _size, _dir)               \
+           dma_map_page((_hwdev) == NULL ? NULL : &(_hwdev)->dev, _page,\
+               _offset, _size, (enum dma_data_direction)_dir)
+#define        pci_unmap_page(_hwdev, _dma_address, _size, _dir)               \
+           dma_unmap_page((_hwdev) == NULL ? NULL : &(_hwdev)->dev,    \
+               _dma_address, _size, (enum dma_data_direction)_dir)
+#define        pci_set_dma_mask(_pdev, mask)   dma_set_mask(&(_pdev)->dev, (mask))
+#define        pci_dma_mapping_error(_pdev, _dma_addr)                         \
+           dma_mapping_error(&(_pdev)->dev, _dma_addr)
+#define        pci_set_consistent_dma_mask(_pdev, _mask)                       \
+           dma_set_coherent_mask(&(_pdev)->dev, (_mask))
+#define        DECLARE_PCI_UNMAP_ADDR(x)       DEFINE_DMA_UNMAP_ADDR(x);
+#define        DECLARE_PCI_UNMAP_LEN(x)        DEFINE_DMA_UNMAP_LEN(x);
+#define        pci_unmap_addr          dma_unmap_addr
+#define        pci_unmap_addr_set      dma_unmap_addr_set
+#define        pci_unmap_len           dma_unmap_len
+#define        pci_unmap_len_set       dma_unmap_len_set
+
+typedef unsigned int __bitwise pci_channel_state_t;
+typedef unsigned int __bitwise pci_ers_result_t;
+
+enum pci_channel_state {
+        /* I/O channel is in normal state */
+        pci_channel_io_normal = (__force pci_channel_state_t) 1,
+
+        /* I/O to channel is blocked */
+        pci_channel_io_frozen = (__force pci_channel_state_t) 2,
+
+        /* PCI card is dead */
+        pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
+};
+
+enum pci_ers_result {
+        /* no result/none/not supported in device driver */
+        PCI_ERS_RESULT_NONE = (__force pci_ers_result_t) 1,
+
+        /* Device driver can recover without slot reset */
+        PCI_ERS_RESULT_CAN_RECOVER = (__force pci_ers_result_t) 2,
+
+        /* Device driver wants slot to be reset. */
+        PCI_ERS_RESULT_NEED_RESET = (__force pci_ers_result_t) 3,
+
+        /* Device has completely failed, is unrecoverable */
+        PCI_ERS_RESULT_DISCONNECT = (__force pci_ers_result_t) 4,
+
+        /* Device driver is fully recovered and operational */
+        PCI_ERS_RESULT_RECOVERED = (__force pci_ers_result_t) 5,
+};
+
+
+/* PCI bus error event callbacks */
+struct pci_error_handlers {
+        /* PCI bus error detected on this device */
+        pci_ers_result_t (*error_detected)(struct pci_dev *dev,
+                        enum pci_channel_state error);
+
+        /* MMIO has been re-enabled, but not DMA */
+        pci_ers_result_t (*mmio_enabled)(struct pci_dev *dev);
+
+        /* PCI Express link has been reset */
+        pci_ers_result_t (*link_reset)(struct pci_dev *dev);
+
+        /* PCI slot has been reset */
+        pci_ers_result_t (*slot_reset)(struct pci_dev *dev);
+
+        /* Device driver may resume normal operations */
+        void (*resume)(struct pci_dev *dev);
+};
+
+/* freeBSD does not support SRIOV - yet */
+static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
+{
+        return dev;
+}
+
+static inline bool pci_is_pcie(struct pci_dev *dev)
+{
+        return !!pci_pcie_cap(dev);
+}
+
+static inline u16 pcie_flags_reg(struct pci_dev *dev)
+{
+        int pos;
+        u16 reg16;
+
+        pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
+        if (!pos)
+                return 0;
+
+        pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &reg16);
+
+        return reg16;
+}
+
+
+static inline int pci_pcie_type(struct pci_dev *dev)
+{
+        return (pcie_flags_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4;
+}
+
+static inline int pcie_cap_version(struct pci_dev *dev)
+{
+        return pcie_flags_reg(dev) & PCI_EXP_FLAGS_VERS;
+}
+
+static inline bool pcie_cap_has_lnkctl(struct pci_dev *dev)
+{
+        int type = pci_pcie_type(dev);
+
+        return pcie_cap_version(dev) > 1 ||
+               type == PCI_EXP_TYPE_ROOT_PORT ||
+               type == PCI_EXP_TYPE_ENDPOINT ||
+               type == PCI_EXP_TYPE_LEG_END;
+}
+
+static inline bool pcie_cap_has_devctl(const struct pci_dev *dev)
+{
+                return true;
+}
+
+static inline bool pcie_cap_has_sltctl(struct pci_dev *dev)
+{
+        int type = pci_pcie_type(dev);
+
+        return pcie_cap_version(dev) > 1 ||
+               type == PCI_EXP_TYPE_ROOT_PORT ||
+               (type == PCI_EXP_TYPE_DOWNSTREAM &&
+                pcie_flags_reg(dev) & PCI_EXP_FLAGS_SLOT);
+}
+
+static inline bool pcie_cap_has_rtctl(struct pci_dev *dev)
+{
+        int type = pci_pcie_type(dev);
+
+        return pcie_cap_version(dev) > 1 ||
+               type == PCI_EXP_TYPE_ROOT_PORT ||
+               type == PCI_EXP_TYPE_RC_EC;
+}
+
+static bool pcie_capability_reg_implemented(struct pci_dev *dev, int pos)
+{
+        if (!pci_is_pcie(dev))
+                return false;
+
+        switch (pos) {
+        case PCI_EXP_FLAGS_TYPE:
+                return true;
+        case PCI_EXP_DEVCAP:
+        case PCI_EXP_DEVCTL:
+        case PCI_EXP_DEVSTA:
+                return pcie_cap_has_devctl(dev);
+        case PCI_EXP_LNKCAP:
+        case PCI_EXP_LNKCTL:
+        case PCI_EXP_LNKSTA:
+                return pcie_cap_has_lnkctl(dev);
+        case PCI_EXP_SLTCAP:
+        case PCI_EXP_SLTCTL:
+        case PCI_EXP_SLTSTA:
+                return pcie_cap_has_sltctl(dev);
+        case PCI_EXP_RTCTL:
+        case PCI_EXP_RTCAP:
+        case PCI_EXP_RTSTA:
+                return pcie_cap_has_rtctl(dev);
+        case PCI_EXP_DEVCAP2:
+        case PCI_EXP_DEVCTL2:
+        case PCI_EXP_LNKCAP2:
+        case PCI_EXP_LNKCTL2:
+        case PCI_EXP_LNKSTA2:
+                return pcie_cap_version(dev) > 1;
+        default:
+                return false;
+        }
+}
+
+static inline int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val)
+{
+        if (pos & 1)
+                return -EINVAL;
+
+        if (!pcie_capability_reg_implemented(dev, pos))
+                return 0;
+
+        return pci_write_config_word(dev, pci_pcie_cap(dev) + pos, val);
+}
+
+#endif /* _LINUX_PCI_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/poll.h b/sys/compat/linuxkpi/common/include/linux/poll.h
new file mode 100644 (file)
index 0000000..e4f7417
--- /dev/null
@@ -0,0 +1,46 @@
+/*-
+ * 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        _LINUX_POLL_H_
+#define        _LINUX_POLL_H_
+
+#include <sys/poll.h>
+#include <sys/fcntl.h>
+
+typedef struct poll_table_struct {
+} poll_table;
+
+static inline void
+poll_wait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p)
+{
+       selrecord(curthread, &filp->f_selinfo);
+}
+
+#endif /* _LINUX_POLL_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/printk.h b/sys/compat/linuxkpi/common/include/linux/printk.h
new file mode 100644 (file)
index 0000000..b160594
--- /dev/null
@@ -0,0 +1,41 @@
+/*-
+ * 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 _FBSD_PRINTK_H_
+#define        _FBSD_PRINTK_H_
+
+/* GID printing macros */
+#define        GID_PRINT_FMT                   "%.4x:%.4x:%.4x:%.4x:%.4x:%.4x:%.4x:%.4x"
+#define        GID_PRINT_ARGS(gid_raw)         htons(((u16 *)gid_raw)[0]), htons(((u16 *)gid_raw)[1]),\
+                                       htons(((u16 *)gid_raw)[2]), htons(((u16 *)gid_raw)[3]),\
+                                       htons(((u16 *)gid_raw)[4]), htons(((u16 *)gid_raw)[5]),\
+                                       htons(((u16 *)gid_raw)[6]), htons(((u16 *)gid_raw)[7])
+
+#endif                                 /* _FBSD_PRINTK_H */
diff --git a/sys/compat/linuxkpi/common/include/linux/radix-tree.h b/sys/compat/linuxkpi/common/include/linux/radix-tree.h
new file mode 100644 (file)
index 0000000..838b81c
--- /dev/null
@@ -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        _LINUX_RADIX_TREE_H_
+#define        _LINUX_RADIX_TREE_H_
+
+#define        RADIX_TREE_MAP_SHIFT    6
+#define        RADIX_TREE_MAP_SIZE     (1 << RADIX_TREE_MAP_SHIFT)
+#define        RADIX_TREE_MAP_MASK     (RADIX_TREE_MAP_SIZE - 1)
+#define        RADIX_TREE_MAX_HEIGHT                                           \
+           DIV_ROUND_UP((sizeof(long) * NBBY), RADIX_TREE_MAP_SHIFT)
+
+struct radix_tree_node {
+       void            *slots[RADIX_TREE_MAP_SIZE];
+       int             count;
+};
+
+struct radix_tree_root {
+       struct radix_tree_node  *rnode;
+       gfp_t                   gfp_mask;
+       int                     height;
+};
+
+#define        RADIX_TREE_INIT(mask)                                           \
+           { .rnode = NULL, .gfp_mask = mask, .height = 0 };
+#define        INIT_RADIX_TREE(root, mask)                                     \
+           { (root)->rnode = NULL; (root)->gfp_mask = mask; (root)->height = 0; }
+#define        RADIX_TREE(name, mask)                                          \
+           struct radix_tree_root name = RADIX_TREE_INIT(mask)
+
+void   *radix_tree_lookup(struct radix_tree_root *, unsigned long);
+void   *radix_tree_delete(struct radix_tree_root *, unsigned long);
+int    radix_tree_insert(struct radix_tree_root *, unsigned long, void *);
+
+#endif /* _LINUX_RADIX_TREE_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/random.h b/sys/compat/linuxkpi/common/include/linux/random.h
new file mode 100644 (file)
index 0000000..caae7b3
--- /dev/null
@@ -0,0 +1,42 @@
+/*-
+ * 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        _LINUX_RANDOM_H_
+#define        _LINUX_RANDOM_H_
+
+#include <sys/random.h>
+
+static inline void
+get_random_bytes(void *buf, int nbytes)
+{
+       read_random(buf, nbytes);
+}
+
+#endif /* _LINUX_RANDOM_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/rbtree.h b/sys/compat/linuxkpi/common/include/linux/rbtree.h
new file mode 100644 (file)
index 0000000..c4478ca
--- /dev/null
@@ -0,0 +1,114 @@
+/*-
+ * 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        _LINUX_RBTREE_H_
+#define        _LINUX_RBTREE_H_
+
+#include <sys/stddef.h>
+#include <sys/tree.h>
+
+struct rb_node {
+       RB_ENTRY(rb_node)       __entry;
+};
+#define        rb_left         __entry.rbe_left
+#define        rb_right        __entry.rbe_right
+
+/*
+ * We provide a false structure that has the same bit pattern as tree.h
+ * presents so it matches the member names expected by linux.
+ */
+struct rb_root {
+       struct  rb_node *rb_node;
+};
+
+/*
+ * In linux all of the comparisons are done by the caller.
+ */
+int panic_cmp(struct rb_node *one, struct rb_node *two);
+
+RB_HEAD(linux_root, rb_node);
+RB_PROTOTYPE(linux_root, rb_node, __entry, panic_cmp);
+
+#define        rb_parent(r)    RB_PARENT(r, __entry)
+#define        rb_color(r)     RB_COLOR(r, __entry)
+#define        rb_is_red(r)    (rb_color(r) == RB_RED)
+#define        rb_is_black(r)  (rb_color(r) == RB_BLACK)
+#define        rb_set_parent(r, p)     rb_parent((r)) = (p)
+#define        rb_set_color(r, c)      rb_color((r)) = (c)
+#define        rb_entry(ptr, type, member)     container_of(ptr, type, member)
+
+#define RB_EMPTY_ROOT(root)     RB_EMPTY((struct linux_root *)root)
+#define RB_EMPTY_NODE(node)     (rb_parent(node) == node)
+#define RB_CLEAR_NODE(node)     (rb_set_parent(node, node))
+
+#define        rb_insert_color(node, root)                                     \
+       linux_root_RB_INSERT_COLOR((struct linux_root *)(root), (node))
+#define        rb_erase(node, root)                                            \
+       linux_root_RB_REMOVE((struct linux_root *)(root), (node))
+#define        rb_next(node)   RB_NEXT(linux_root, NULL, (node))
+#define        rb_prev(node)   RB_PREV(linux_root, NULL, (node))
+#define        rb_first(root)  RB_MIN(linux_root, (struct linux_root *)(root))
+#define        rb_last(root)   RB_MAX(linux_root, (struct linux_root *)(root))
+
+static inline void
+rb_link_node(struct rb_node *node, struct rb_node *parent,
+    struct rb_node **rb_link)
+{
+       rb_set_parent(node, parent);
+       rb_set_color(node, RB_RED);
+       node->__entry.rbe_left = node->__entry.rbe_right = NULL;
+       *rb_link = node;
+}
+
+static inline void
+rb_replace_node(struct rb_node *victim, struct rb_node *new,
+    struct rb_root *root)
+{
+       struct rb_node *p;
+
+       p = rb_parent(victim);
+       if (p) {
+               if (p->rb_left == victim)
+                       p->rb_left = new;
+               else
+                       p->rb_right = new;
+       } else
+               root->rb_node = new;
+       if (victim->rb_left)
+               rb_set_parent(victim->rb_left, new);
+       if (victim->rb_right)
+               rb_set_parent(victim->rb_right, new);
+       *new = *victim;
+}
+
+#undef RB_ROOT
+#define RB_ROOT                (struct rb_root) { NULL }
+
+#endif /* _LINUX_RBTREE_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/rwlock.h b/sys/compat/linuxkpi/common/include/linux/rwlock.h
new file mode 100644 (file)
index 0000000..e7c6301
--- /dev/null
@@ -0,0 +1,66 @@
+/*-
+ * 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        _LINUX_RWLOCK_H_
+#define        _LINUX_RWLOCK_H_
+
+#include <sys/lock.h>
+#include <sys/rwlock.h>
+
+typedef struct {
+       struct rwlock rw;
+} rwlock_t;
+
+#define        read_lock(_l)           rw_rlock(&(_l)->rw)
+#define        write_lock(_l)          rw_wlock(&(_l)->rw)
+#define        read_unlock(_l)         rw_runlock(&(_l)->rw)
+#define        write_unlock(_l)        rw_wunlock(&(_l)->rw)
+#define        read_lock_irq(lock)     read_lock((lock))
+#define        read_unlock_irq(lock)   read_unlock((lock))
+#define        write_lock_irq(lock)    write_lock((lock))
+#define        write_unlock_irq(lock)  write_unlock((lock))
+#define        read_lock_irqsave(lock, flags)                                  \
+    do {(flags) = 0; read_lock(lock); } while (0)
+#define        write_lock_irqsave(lock, flags)                                 \
+    do {(flags) = 0; write_lock(lock); } while (0)
+#define        read_unlock_irqrestore(lock, flags)                             \
+    do { read_unlock(lock); } while (0)
+#define        write_unlock_irqrestore(lock, flags)                            \
+    do { write_unlock(lock); } while (0)
+
+static inline void
+rwlock_init(rwlock_t *lock)
+{
+
+       memset(&lock->rw, 0, sizeof(lock->rw));
+       rw_init_flags(&lock->rw, "lnxrw", RW_NOWITNESS);
+}
+
+#endif /* _LINUX_RWLOCK_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/rwsem.h b/sys/compat/linuxkpi/common/include/linux/rwsem.h
new file mode 100644 (file)
index 0000000..22ad4dc
--- /dev/null
@@ -0,0 +1,59 @@
+/*-
+ * 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        _LINUX_RWSEM_H_
+#define        _LINUX_RWSEM_H_
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/sx.h>
+
+struct rw_semaphore {
+       struct sx sx;
+};
+
+#define        down_write(_rw)                 sx_xlock(&(_rw)->sx)
+#define        up_write(_rw)                   sx_xunlock(&(_rw)->sx)
+#define        down_read(_rw)                  sx_slock(&(_rw)->sx)
+#define        up_read(_rw)                    sx_sunlock(&(_rw)->sx)
+#define        down_read_trylock(_rw)          !!sx_try_slock(&(_rw)->sx)
+#define        down_write_trylock(_rw)         !!sx_try_xlock(&(_rw)->sx)
+#define        downgrade_write(_rw)            sx_downgrade(&(_rw)->sx)
+#define        down_read_nested(_rw, _sc)      down_read(_rw)
+
+static inline void
+init_rwsem(struct rw_semaphore *rw)
+{
+
+       memset(&rw->sx, 0, sizeof(rw->sx));
+       sx_init_flags(&rw->sx, "lnxrwsem", SX_NOWITNESS);
+}
+
+#endif /* _LINUX_RWSEM_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/scatterlist.h b/sys/compat/linuxkpi/common/include/linux/scatterlist.h
new file mode 100644 (file)
index 0000000..5aa8d65
--- /dev/null
@@ -0,0 +1,279 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
+ * Copyright (c) 2015 Matthew Dillon <dillon@backplane.com>
+ * 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_SCATTERLIST_H_
+#define        _LINUX_SCATTERLIST_H_
+
+#include <linux/page.h>
+#include <linux/slab.h>
+
+struct scatterlist {
+       union {
+               struct page *page;
+               struct scatterlist *sg;
+       }       sl_un;
+       dma_addr_t address;
+       unsigned long offset;
+       uint32_t length;
+       uint32_t flags;
+};
+
+struct sg_table {
+       struct scatterlist *sgl;
+       unsigned int nents;
+       unsigned int orig_nents;
+};
+
+struct sg_page_iter {
+       struct scatterlist *sg;
+       unsigned int sg_pgoffset;
+       unsigned int maxents;
+};
+
+#define        SG_MAX_SINGLE_ALLOC     (PAGE_SIZE / sizeof(struct scatterlist))
+
+#define        sg_dma_address(sg)      (sg)->address
+#define        sg_dma_len(sg)          (sg)->length
+#define        sg_page(sg)             (sg)->sl_un.page
+#define        sg_scatternext(sg)      (sg)->sl_un.sg
+
+#define        SG_END          0x01
+#define        SG_CHAIN        0x02
+
+static inline void
+sg_set_page(struct scatterlist *sg, struct page *page, unsigned int len,
+    unsigned int offset)
+{
+       sg_page(sg) = page;
+       sg_dma_len(sg) = len;
+       sg->offset = offset;
+       if (offset > PAGE_SIZE)
+               panic("sg_set_page: Invalid offset %d\n", offset);
+}
+
+static inline void
+sg_set_buf(struct scatterlist *sg, const void *buf, unsigned int buflen)
+{
+       sg_set_page(sg, virt_to_page(buf), buflen,
+           ((uintptr_t)buf) & (PAGE_SIZE - 1));
+}
+
+static inline void
+sg_init_table(struct scatterlist *sg, unsigned int nents)
+{
+       bzero(sg, sizeof(*sg) * nents);
+       sg[nents - 1].flags = SG_END;
+}
+
+static inline struct scatterlist *
+sg_next(struct scatterlist *sg)
+{
+       if (sg->flags & SG_END)
+               return (NULL);
+       sg++;
+       if (sg->flags & SG_CHAIN)
+               sg = sg_scatternext(sg);
+       return (sg);
+}
+
+static inline vm_paddr_t
+sg_phys(struct scatterlist *sg)
+{
+       return sg_page(sg)->phys_addr + sg->offset;
+}
+
+static inline void
+sg_chain(struct scatterlist *prv, unsigned int prv_nents,
+    struct scatterlist *sgl)
+{
+       struct scatterlist *sg = &prv[prv_nents - 1];
+
+       sg->offset = 0;
+       sg->length = 0;
+       sg->flags = SG_CHAIN;
+       sg->sl_un.sg = sgl;
+}
+
+static inline void 
+sg_mark_end(struct scatterlist *sg)
+{
+       sg->flags = SG_END;
+}
+
+static inline void
+__sg_free_table(struct sg_table *table, unsigned int max_ents)
+{
+       struct scatterlist *sgl, *next;
+
+       if (unlikely(!table->sgl))
+               return;
+
+       sgl = table->sgl;
+       while (table->orig_nents) {
+               unsigned int alloc_size = table->orig_nents;
+               unsigned int sg_size;
+
+               if (alloc_size > max_ents) {
+                       next = sgl[max_ents - 1].sl_un.sg;
+                       alloc_size = max_ents;
+                       sg_size = alloc_size - 1;
+               } else {
+                       sg_size = alloc_size;
+                       next = NULL;
+               }
+
+               table->orig_nents -= sg_size;
+               kfree(sgl);
+               sgl = next;
+       }
+
+       table->sgl = NULL;
+}
+
+static inline void
+sg_free_table(struct sg_table *table)
+{
+       __sg_free_table(table, SG_MAX_SINGLE_ALLOC);
+}
+
+static inline int
+__sg_alloc_table(struct sg_table *table, unsigned int nents,
+    unsigned int max_ents, gfp_t gfp_mask)
+{
+       struct scatterlist *sg, *prv;
+       unsigned int left;
+
+       memset(table, 0, sizeof(*table));
+
+       if (nents == 0)
+               return -EINVAL;
+       left = nents;
+       prv = NULL;
+       do {
+               unsigned int sg_size;
+               unsigned int alloc_size = left;
+
+               if (alloc_size > max_ents) {
+                       alloc_size = max_ents;
+                       sg_size = alloc_size - 1;
+               } else
+                       sg_size = alloc_size;
+
+               left -= sg_size;
+
+               sg = kmalloc(alloc_size * sizeof(struct scatterlist), gfp_mask);
+               if (unlikely(!sg)) {
+                       if (prv)
+                               table->nents = ++table->orig_nents;
+
+                       return -ENOMEM;
+               }
+               sg_init_table(sg, alloc_size);
+               table->nents = table->orig_nents += sg_size;
+
+               if (prv)
+                       sg_chain(prv, max_ents, sg);
+               else
+                       table->sgl = sg;
+
+               if (!left)
+                       sg_mark_end(&sg[sg_size - 1]);
+
+               prv = sg;
+       } while (left);
+
+       return 0;
+}
+
+static inline int
+sg_alloc_table(struct sg_table *table, unsigned int nents, gfp_t gfp_mask)
+{
+       int ret;
+
+       ret = __sg_alloc_table(table, nents, SG_MAX_SINGLE_ALLOC,
+           gfp_mask);
+       if (unlikely(ret))
+               __sg_free_table(table, SG_MAX_SINGLE_ALLOC);
+
+       return ret;
+}
+
+static inline void
+_sg_iter_next(struct sg_page_iter *iter)
+{
+       struct scatterlist *sg;
+       unsigned int pgcount;
+
+       sg = iter->sg;
+       pgcount = (sg->offset + sg->length + PAGE_SIZE - 1) >> PAGE_SHIFT;
+
+       ++iter->sg_pgoffset;
+       while (iter->sg_pgoffset >= pgcount) {
+               iter->sg_pgoffset -= pgcount;
+               sg = sg_next(sg);
+               --iter->maxents;
+               if (sg == NULL || iter->maxents == 0)
+                       break;
+               pgcount = (sg->offset + sg->length + PAGE_SIZE - 1) >> PAGE_SHIFT;
+       }
+       iter->sg = sg;
+}
+
+static inline void
+_sg_iter_init(struct scatterlist *sgl, struct sg_page_iter *iter,
+    unsigned int nents, unsigned long pgoffset)
+{
+       if (nents) {
+               iter->sg = sgl;
+               iter->sg_pgoffset = pgoffset - 1;
+               iter->maxents = nents;
+               _sg_iter_next(iter);
+       } else {
+               iter->sg = NULL;
+               iter->sg_pgoffset = 0;
+               iter->maxents = 0;
+       }
+}
+
+static inline dma_addr_t
+sg_page_iter_dma_address(struct sg_page_iter *spi)
+{
+       return spi->sg->address + (spi->sg_pgoffset << PAGE_SHIFT);
+}
+
+#define        for_each_sg_page(sgl, iter, nents, pgoffset)                    \
+       for (_sg_iter_init(sgl, iter, nents, pgoffset);                 \
+            (iter)->sg; _sg_iter_next(iter))
+
+#define        for_each_sg(sglist, sg, sgmax, _itr)                            \
+       for (_itr = 0, sg = (sglist); _itr < (sgmax); _itr++, sg = sg_next(sg))
+
+#endif                                 /* _LINUX_SCATTERLIST_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/sched.h b/sys/compat/linuxkpi/common/include/linux/sched.h
new file mode 100644 (file)
index 0000000..c2d66d7
--- /dev/null
@@ -0,0 +1,126 @@
+/*-
+ * 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        _LINUX_SCHED_H_
+#define        _LINUX_SCHED_H_
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/sched.h>
+#include <sys/sleepqueue.h>
+
+#define        MAX_SCHEDULE_TIMEOUT    LONG_MAX
+
+#define        TASK_RUNNING            0
+#define        TASK_INTERRUPTIBLE      1
+#define        TASK_UNINTERRUPTIBLE    2
+#define        TASK_DEAD               64
+#define        TASK_WAKEKILL           128
+#define        TASK_WAKING             256
+
+#define        TASK_SHOULD_STOP        1
+#define        TASK_STOPPED            2
+
+/*
+ * A task_struct is only provided for those tasks created with kthread.
+ * Using these routines with threads not started via kthread will cause
+ * panics because no task_struct is allocated and td_retval[1] is
+ * overwritten by syscalls which kernel threads will not make use of.
+ */
+struct task_struct {
+       struct  thread *task_thread;
+       int     (*task_fn)(void *data);
+       void    *task_data;
+       int     task_ret;
+       int     state;
+       int     should_stop;
+};
+
+#define        current                 task_struct_get(curthread)
+#define        task_struct_get(x)      ((struct task_struct *)(uintptr_t)(x)->td_retval[1])
+#define        task_struct_set(x, y)   (x)->td_retval[1] = (uintptr_t)(y)
+
+/* ensure the task_struct pointer fits into the td_retval[1] field */
+CTASSERT(sizeof(((struct thread *)0)->td_retval[1]) >= sizeof(uintptr_t));
+
+#define        set_current_state(x)                                            \
+       atomic_store_rel_int((volatile int *)&current->state, (x))
+#define        __set_current_state(x)  current->state = (x)
+
+
+#define        schedule()                                                      \
+do {                                                                   \
+       void *c;                                                        \
+                                                                       \
+       if (cold)                                                       \
+               break;                                                  \
+       c = curthread;                                                  \
+       sleepq_lock(c);                                                 \
+       if (current->state == TASK_INTERRUPTIBLE ||                     \
+           current->state == TASK_UNINTERRUPTIBLE) {                   \
+               sleepq_add(c, NULL, "task", SLEEPQ_SLEEP, 0);           \
+               sleepq_wait(c, 0);                                      \
+       } else {                                                        \
+               sleepq_release(c);                                      \
+               sched_relinquish(curthread);                            \
+       }                                                               \
+} while (0)
+
+#define        wake_up_process(x)                                              \
+do {                                                                   \
+       int wakeup_swapper;                                             \
+       void *c;                                                        \
+                                                                       \
+       c = (x)->task_thread;                                           \
+       sleepq_lock(c);                                                 \
+       (x)->state = TASK_RUNNING;                                      \
+       wakeup_swapper = sleepq_signal(c, SLEEPQ_SLEEP, 0, 0);          \
+       sleepq_release(c);                                              \
+       if (wakeup_swapper)                                             \
+               kick_proc0();                                           \
+} while (0)
+
+#define        cond_resched()  if (!cold)      sched_relinquish(curthread)
+
+#define        sched_yield()   sched_relinquish(curthread)
+
+static inline long
+schedule_timeout(signed long timeout)
+{
+       if (timeout < 0)
+               return 0;
+
+       pause("lstim", timeout);
+
+       return 0;
+}
+
+#endif /* _LINUX_SCHED_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/semaphore.h b/sys/compat/linuxkpi/common/include/linux/semaphore.h
new file mode 100644 (file)
index 0000000..022a016
--- /dev/null
@@ -0,0 +1,69 @@
+/*-
+ * 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 _LINUX_SEMAPHORE_H_
+#define _LINUX_SEMAPHORE_H_
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/sema.h>
+
+/*
+ * XXX BSD semaphores are disused and slow.  They also do not provide a
+ * sema_wait_sig method.  This must be resolved eventually.
+ */
+struct semaphore {
+       struct sema     sema;
+};
+
+#define        down(_sem)                      sema_wait(&(_sem)->sema)
+#define        down_interruptible(_sem)        sema_wait(&(_sem)->sema), 0
+#define        down_trylock(_sem)              !sema_trywait(&(_sem)->sema)
+#define        up(_sem)                        sema_post(&(_sem)->sema)
+
+static inline void
+linux_sema_init(struct semaphore *sem, int val)
+{
+
+       memset(&sem->sema, 0, sizeof(sem->sema));
+       sema_init(&sem->sema, val, "lnxsema");
+}
+
+static inline void
+init_MUTEX(struct semaphore *sem)
+{
+
+       memset(&sem->sema, 0, sizeof(sem->sema));
+       sema_init(&sem->sema, 1, "lnxsema");
+}
+
+#define        sema_init       linux_sema_init
+
+#endif /* _LINUX_SEMAPHORE_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h b/sys/compat/linuxkpi/common/include/linux/slab.h
new file mode 100644 (file)
index 0000000..1b56b55
--- /dev/null
@@ -0,0 +1,112 @@
+/*-
+ * 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        _LINUX_SLAB_H_
+#define        _LINUX_SLAB_H_
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <vm/uma.h>
+
+#include <linux/types.h>
+#include <linux/gfp.h>
+
+MALLOC_DECLARE(M_KMALLOC);
+
+#define        kmalloc(size, flags)            malloc((size), M_KMALLOC, (flags))
+#define        kvmalloc(size)                  kmalloc((size), 0)
+#define        kzalloc(size, flags)            kmalloc((size), (flags) | M_ZERO)
+#define        kzalloc_node(size, flags, node) kzalloc(size, flags)
+#define        kfree(ptr)                      free(__DECONST(void *, (ptr)), M_KMALLOC)
+#define        krealloc(ptr, size, flags)      realloc((ptr), (size), M_KMALLOC, (flags))
+#define        kcalloc(n, size, flags)         kmalloc((n) * (size), flags | M_ZERO)
+#define        vzalloc(size)                   kzalloc(size, GFP_KERNEL | __GFP_NOWARN)
+#define        vfree(arg)                      kfree(arg)
+#define        kvfree(arg)                     kfree(arg)
+#define        vmalloc(size)                   kmalloc(size, GFP_KERNEL)
+#define        vmalloc_node(size, node)        kmalloc(size, GFP_KERNEL)
+
+struct kmem_cache {
+       uma_zone_t      cache_zone;
+       void            (*cache_ctor)(void *);
+};
+
+#define        SLAB_HWCACHE_ALIGN      0x0001
+
+static inline int
+kmem_ctor(void *mem, int size, void *arg, int flags)
+{
+       void (*ctor)(void *);
+
+       ctor = arg;
+       ctor(mem);
+
+       return (0);
+}
+
+static inline struct kmem_cache *
+kmem_cache_create(char *name, size_t size, size_t align, u_long flags,
+    void (*ctor)(void *))
+{
+       struct kmem_cache *c;
+
+       c = malloc(sizeof(*c), M_KMALLOC, M_WAITOK);
+       if (align)
+               align--;
+       if (flags & SLAB_HWCACHE_ALIGN)
+               align = UMA_ALIGN_CACHE;
+       c->cache_zone = uma_zcreate(name, size, ctor ? kmem_ctor : NULL,
+           NULL, NULL, NULL, align, 0);
+       c->cache_ctor = ctor;
+
+       return c;
+}
+
+static inline void *
+kmem_cache_alloc(struct kmem_cache *c, int flags)
+{
+       return uma_zalloc_arg(c->cache_zone, c->cache_ctor, flags);
+}
+
+static inline void
+kmem_cache_free(struct kmem_cache *c, void *m)
+{
+       uma_zfree(c->cache_zone, m);
+}
+
+static inline void
+kmem_cache_destroy(struct kmem_cache *c)
+{
+       uma_zdestroy(c->cache_zone);
+       free(c, M_KMALLOC);
+}
+
+#endif /* _LINUX_SLAB_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/socket.h b/sys/compat/linuxkpi/common/include/linux/socket.h
new file mode 100644 (file)
index 0000000..a9a952e
--- /dev/null
@@ -0,0 +1,69 @@
+/*-
+ * 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        _LINUX_SOCKET_H_
+#define        _LINUX_SOCKET_H_
+
+#include <sys/socket.h>
+
+#ifdef notyet
+static inline int
+memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len)
+{
+       struct uio uio;
+       int error;
+
+       uio.uio_iov = v;
+       uio.uio_iovcnt = -1;
+       uio.uio_offset = 0;
+       uio.uio_resid = len;
+       uio.uio_segflag = UIO_USERSPACE;
+       uio.uio_rw = UIO_READ;
+       error = -uiomove(kdata, len, &uio);
+       return (error);
+}
+
+static inline int
+memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len)
+{
+       struct uio uio;
+       int error;
+
+       uio.uio_iov = v;
+       uio.uio_iovcnt = -1;
+       uio.uio_offset = 0;
+       uio.uio_resid = len;
+       uio.uio_segflag = UIO_USERSPACE;
+       uio.uio_rw = UIO_WRITE;
+       error = -uiomove(kdata, len, &uio);
+}
+#endif
+
+#endif /* _LINUX_SOCKET_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/spinlock.h b/sys/compat/linuxkpi/common/include/linux/spinlock.h
new file mode 100644 (file)
index 0000000..97c83e0
--- /dev/null
@@ -0,0 +1,70 @@
+/*-
+ * 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        _LINUX_SPINLOCK_H_
+#define        _LINUX_SPINLOCK_H_
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+
+#include <linux/compiler.h>
+#include <linux/kernel.h>
+#include <linux/rwlock.h>
+
+typedef struct {
+       struct mtx m;
+} spinlock_t;
+
+#define        spin_lock(_l)           mtx_lock(&(_l)->m)
+#define        spin_unlock(_l)         mtx_unlock(&(_l)->m)
+#define        spin_trylock(_l)        mtx_trylock(&(_l)->m)
+#define        spin_lock_nested(_l, _n) mtx_lock_flags(&(_l)->m, MTX_DUPOK)
+#define        spin_lock_irq(lock)     spin_lock(lock)
+#define        spin_unlock_irq(lock)   spin_unlock(lock)
+#define        spin_lock_irqsave(lock, flags)                                  \
+    do {(flags) = 0; spin_lock(lock); } while (0)
+#define        spin_unlock_irqrestore(lock, flags)                             \
+    do { spin_unlock(lock); } while (0)
+
+static inline void
+spin_lock_init(spinlock_t *lock)
+{
+
+       memset(&lock->m, 0, sizeof(lock->m));
+       mtx_init(&lock->m, "lnxspin", NULL, MTX_DEF | MTX_NOWITNESS);
+}
+
+#define        DEFINE_SPINLOCK(lock)                                           \
+       spinlock_t lock;                                                \
+       MTX_SYSINIT(lock, &(lock).m, "lnxspin", MTX_DEF)
+
+#endif /* _LINUX_SPINLOCK_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h
new file mode 100644 (file)
index 0000000..cf55b09
--- /dev/null
@@ -0,0 +1,54 @@
+/*-
+ * 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        _LINUX_STRING_H_
+#define        _LINUX_STRING_H_
+
+#include <linux/types.h>
+#include <linux/gfp.h>
+#include <linux/slab.h>
+
+#include <sys/libkern.h>
+
+#define strnicmp strncasecmp
+
+
+static inline void *
+kmemdup(const void *src, size_t len, gfp_t gfp)
+{
+       void *dst;
+
+       dst = kmalloc(len, gfp);
+       if (dst)
+               memcpy(dst, src, len);
+       return (dst);
+}
+
+#endif /* _LINUX_STRING_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/sysfs.h b/sys/compat/linuxkpi/common/include/linux/sysfs.h
new file mode 100644 (file)
index 0000000..e565e43
--- /dev/null
@@ -0,0 +1,192 @@
+/*-
+ * 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        _LINUX_SYSFS_H_
+#define        _LINUX_SYSFS_H_
+
+#include <sys/sysctl.h>
+
+struct attribute {
+       const char      *name;
+       struct module   *owner;
+       mode_t          mode;
+};
+
+struct sysfs_ops {
+       ssize_t (*show)(struct kobject *, struct attribute *, char *);
+       ssize_t (*store)(struct kobject *, struct attribute *, const char *,
+           size_t);
+};
+
+struct attribute_group {
+       const char              *name;
+       mode_t                  (*is_visible)(struct kobject *,
+                                   struct attribute *, int);
+       struct attribute        **attrs;
+};
+
+#define        __ATTR(_name, _mode, _show, _store) {                           \
+       .attr = { .name = __stringify(_name), .mode = _mode },          \
+        .show = _show, .store  = _store,                               \
+}
+
+#define        __ATTR_RO(_name) {                                              \
+       .attr = { .name = __stringify(_name), .mode = 0444 },           \
+       .show   = _name##_show,                                         \
+}
+
+#define        __ATTR_NULL     { .attr = { .name = NULL } }
+
+/*
+ * Handle our generic '\0' terminated 'C' string.
+ * Two cases:
+ *      a variable string:  point arg1 at it, arg2 is max length.
+ *      a constant string:  point arg1 at it, arg2 is zero.
+ */
+
+static inline int
+sysctl_handle_attr(SYSCTL_HANDLER_ARGS)
+{
+       struct kobject *kobj;
+       struct attribute *attr;
+       const struct sysfs_ops *ops;
+       char *buf;
+       int error;
+       ssize_t len;
+
+       kobj = arg1;
+       attr = (struct attribute *)arg2;
+       if (kobj->ktype == NULL || kobj->ktype->sysfs_ops == NULL)
+               return (ENODEV);
+       buf = (char *)get_zeroed_page(GFP_KERNEL);
+       if (buf == NULL)
+               return (ENOMEM);
+       ops = kobj->ktype->sysfs_ops;
+       if (ops->show) {
+               len = ops->show(kobj, attr, buf);
+               /*
+                * It's valid to not have a 'show' so just return an
+                * empty string.
+                */
+               if (len < 0) {
+                       error = -len;
+                       if (error != EIO)
+                               goto out;
+                       buf[0] = '\0';
+               } else if (len) {
+                       len--;
+                       if (len >= PAGE_SIZE)
+                               len = PAGE_SIZE - 1;
+                       /* Trim trailing newline. */
+                       buf[len] = '\0';
+               }
+       }
+
+       /* Leave one trailing byte to append a newline. */
+       error = sysctl_handle_string(oidp, buf, PAGE_SIZE - 1, req);
+       if (error != 0 || req->newptr == NULL || ops->store == NULL)
+               goto out;
+       len = strlcat(buf, "\n", PAGE_SIZE);
+       KASSERT(len < PAGE_SIZE, ("new attribute truncated"));
+       len = ops->store(kobj, attr, buf, len);
+       if (len < 0)
+               error = -len;
+out:
+       free_page((unsigned long)buf);
+
+       return (error);
+}
+
+static inline int
+sysfs_create_file(struct kobject *kobj, const struct attribute *attr)
+{
+
+       sysctl_add_oid(NULL, SYSCTL_CHILDREN(kobj->oidp), OID_AUTO,
+           attr->name, CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_MPSAFE, kobj,
+           (uintptr_t)attr, sysctl_handle_attr, "A", "");
+
+       return (0);
+}
+
+static inline void
+sysfs_remove_file(struct kobject *kobj, const struct attribute *attr)
+{
+
+       if (kobj->oidp)
+               sysctl_remove_name(kobj->oidp, attr->name, 1, 1);
+}
+
+static inline void
+sysfs_remove_group(struct kobject *kobj, const struct attribute_group *grp)
+{
+
+       if (kobj->oidp)
+               sysctl_remove_name(kobj->oidp, grp->name, 1, 1);
+}
+
+static inline int
+sysfs_create_group(struct kobject *kobj, const struct attribute_group *grp)
+{
+       struct attribute **attr;
+       struct sysctl_oid *oidp;
+
+       oidp = SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(kobj->oidp),
+           OID_AUTO, grp->name, CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, grp->name);
+       for (attr = grp->attrs; *attr != NULL; attr++) {
+               sysctl_add_oid(NULL, SYSCTL_CHILDREN(oidp), OID_AUTO,
+                   (*attr)->name, CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_MPSAFE,
+                   kobj, (uintptr_t)*attr, sysctl_handle_attr, "A", "");
+       }
+
+       return (0);
+}
+
+static inline int
+sysfs_create_dir(struct kobject *kobj)
+{
+
+       kobj->oidp = SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(kobj->parent->oidp),
+           OID_AUTO, kobj->name, CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, kobj->name);
+
+        return (0);
+}
+
+static inline void
+sysfs_remove_dir(struct kobject *kobj)
+{
+
+       if (kobj->oidp == NULL)
+               return;
+       sysctl_remove_oid(kobj->oidp, 1, 1);
+}
+
+#define sysfs_attr_init(attr) do {} while(0)
+
+#endif /* _LINUX_SYSFS_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/time.h b/sys/compat/linuxkpi/common/include/linux/time.h
new file mode 100644 (file)
index 0000000..27516a4
--- /dev/null
@@ -0,0 +1,131 @@
+/*-
+ * Copyright (c) 2014-2015 François Tigeot
+ * 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_TIME_H_
+#define        _LINUX_TIME_H_
+
+#define        NSEC_PER_USEC   1000L
+#define        NSEC_PER_SEC    1000000000L
+
+#include <sys/time.h>
+#include <sys/stdint.h>
+
+static inline struct timeval
+ns_to_timeval(const int64_t nsec)
+{
+       struct timeval tv;
+       long rem;
+
+       if (nsec == 0) {
+               tv.tv_sec = 0;
+               tv.tv_usec = 0;
+               return (tv);
+       }
+
+       tv.tv_sec = nsec / NSEC_PER_SEC;
+       rem = nsec % NSEC_PER_SEC;
+       if (rem < 0) {
+               tv.tv_sec--;
+               rem += NSEC_PER_SEC;
+       }
+       tv.tv_usec = rem / 1000;
+       return (tv);
+}
+
+static inline int64_t
+timeval_to_ns(const struct timeval *tv)
+{
+       return ((int64_t)tv->tv_sec * NSEC_PER_SEC) +
+               tv->tv_usec * NSEC_PER_USEC;
+}
+
+#define getrawmonotonic(ts)    nanouptime(ts)
+
+static inline struct timespec
+timespec_sub(struct timespec lhs, struct timespec rhs)
+{
+       struct timespec ts;
+
+       ts.tv_sec = lhs.tv_sec;
+       ts.tv_nsec = lhs.tv_nsec;
+       timespecsub(&ts, &rhs);
+
+       return ts;
+}
+
+static inline void
+set_normalized_timespec(struct timespec *ts, time_t sec, int64_t nsec)
+{
+       /* XXX: this doesn't actually normalize anything */
+       ts->tv_sec = sec;
+       ts->tv_nsec = nsec;
+}
+
+static inline int64_t
+timespec_to_ns(const struct timespec *ts)
+{
+       return ((ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec);
+}
+
+static inline struct timespec
+ns_to_timespec(const int64_t nsec)
+{
+       struct timespec ts;
+       int32_t rem;
+
+       if (nsec == 0) {
+               ts.tv_sec = 0;
+               ts.tv_nsec = 0;
+               return (ts);
+       }
+
+       ts.tv_sec = nsec / NSEC_PER_SEC;
+       rem = nsec % NSEC_PER_SEC;
+       if (rem < 0) {
+               ts.tv_sec--;
+               rem += NSEC_PER_SEC;
+       }
+       ts.tv_nsec = rem;
+       return (ts);
+}
+
+static inline int
+timespec_valid(const struct timespec *ts)
+{
+       if (ts->tv_sec < 0 || ts->tv_sec > 100000000 ||
+           ts->tv_nsec < 0 || ts->tv_nsec >= 1000000000)
+               return (0);
+       return (1);
+}
+
+static inline unsigned long
+get_seconds(void)
+{
+       return time_uptime;
+}
+
+#endif /* _LINUX_TIME_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/timer.h b/sys/compat/linuxkpi/common/include/linux/timer.h
new file mode 100644 (file)
index 0000000..a794c13
--- /dev/null
@@ -0,0 +1,74 @@
+/*-
+ * 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 _LINUX_TIMER_H_
+#define        _LINUX_TIMER_H_
+
+#include <linux/types.h>
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/callout.h>
+
+struct timer_list {
+       struct callout timer_callout;
+       void    (*function) (unsigned long);
+       unsigned long data;
+       unsigned long expires;
+};
+
+extern unsigned long linux_timer_hz_mask;
+
+#define        setup_timer(timer, func, dat)                                   \
+do {                                                                   \
+       (timer)->function = (func);                                     \
+       (timer)->data = (dat);                                          \
+       callout_init(&(timer)->timer_callout, 1);                       \
+} while (0)
+
+#define        init_timer(timer)                                               \
+do {                                                                   \
+       (timer)->function = NULL;                                       \
+       (timer)->data = 0;                                              \
+       callout_init(&(timer)->timer_callout, 1);                       \
+} while (0)
+
+extern void mod_timer(struct timer_list *, unsigned long);
+extern void add_timer(struct timer_list *);
+
+#define        del_timer(timer)        callout_stop(&(timer)->timer_callout)
+#define        del_timer_sync(timer)   callout_drain(&(timer)->timer_callout)
+#define        timer_pending(timer)    callout_pending(&(timer)->timer_callout)
+#define        round_jiffies(j) \
+       ((unsigned long)(((j) + linux_timer_hz_mask) & ~linux_timer_hz_mask))
+#define        round_jiffies_relative(j) \
+       round_jiffies(j)
+
+#endif                                 /* _LINUX_TIMER_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/types.h b/sys/compat/linuxkpi/common/include/linux/types.h
new file mode 100644 (file)
index 0000000..c9c3728
--- /dev/null
@@ -0,0 +1,66 @@
+/*-
+ * 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        _LINUX_TYPES_H_
+#define        _LINUX_TYPES_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <linux/compiler.h>
+#include <asm/types.h>
+
+#ifndef __bitwise__
+#ifdef __CHECKER__
+#define __bitwise__ __attribute__((bitwise))
+#else
+#define __bitwise__
+#endif
+#endif
+
+typedef uint16_t __le16;
+typedef uint16_t __be16;
+typedef uint32_t __le32;
+typedef uint32_t __be32;
+typedef uint64_t __le64;
+typedef uint64_t __be64;
+
+typedef unsigned int    uint;
+typedef unsigned gfp_t;
+typedef uint64_t loff_t;
+typedef vm_paddr_t resource_size_t;
+
+typedef u64 phys_addr_t;
+
+#define        DECLARE_BITMAP(n, bits)                                         \
+       unsigned long n[howmany(bits, sizeof(long) * 8)]
+
+#endif /* _LINUX_TYPES_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/uaccess.h b/sys/compat/linuxkpi/common/include/linux/uaccess.h
new file mode 100644 (file)
index 0000000..87d1bab
--- /dev/null
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
+ * Copyright (c) 2015 François Tigeot
+ * 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_UACCESS_H_
+#define        _LINUX_UACCESS_H_
+
+#include <linux/compiler.h>
+
+#define        get_user(_x, _p)        -copyin((_p), &(_x), sizeof(*(_p)))
+#define        put_user(_x, _p)        -copyout(&(_x), (_p), sizeof(*(_p)))
+
+/*
+ * NOTE: The returned value from pagefault_disable() must be stored
+ * and passed to pagefault_enable(). Else possible recursion on the
+ * state can be lost.
+ */
+static inline int __must_check
+pagefault_disable(void)
+{
+       return (vm_fault_disable_pagefaults());
+}
+
+static inline void
+pagefault_enable(int save)
+{
+       vm_fault_enable_pagefaults(save);
+}
+
+#endif /* _LINUX_UACCESS_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/usb.h b/sys/compat/linuxkpi/common/include/linux/usb.h
new file mode 100644 (file)
index 0000000..1f00d4b
--- /dev/null
@@ -0,0 +1,310 @@
+/* $FreeBSD$ */
+/*-
+ * Copyright (c) 2007 Luigi Rizzo - Universita` di Pisa. All rights reserved.
+ * Copyright (c) 2007 Hans Petter Selasky. 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, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+ */
+
+#ifndef _USB_COMPAT_LINUX_H
+#define        _USB_COMPAT_LINUX_H
+
+struct usb_device;
+struct usb_interface;
+struct usb_driver;
+struct urb;
+
+typedef void *pm_message_t;
+typedef void (usb_complete_t)(struct urb *);
+
+#define        USB_MAX_FULL_SPEED_ISOC_FRAMES (60 * 1)
+#define        USB_MAX_HIGH_SPEED_ISOC_FRAMES (60 * 8)
+
+#define        USB_DEVICE_ID_MATCH_DEVICE \
+       (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT)
+
+#define        USB_DEVICE(vend,prod) \
+       .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = (vend), \
+       .idProduct = (prod)
+
+/* The "usb_driver" structure holds the Linux USB device driver
+ * callbacks, and a pointer to device ID's which this entry should
+ * match against. Usually this entry is exposed to the USB emulation
+ * layer using the "USB_DRIVER_EXPORT()" macro, which is defined
+ * below.
+ */
+struct usb_driver {
+       const char *name;
+
+       int     (*probe) (struct usb_interface *intf,
+               const   struct usb_device_id *id);
+
+       void    (*disconnect) (struct usb_interface *intf);
+
+       int     (*ioctl) (struct usb_interface *intf, unsigned int code,
+               void  *buf);
+
+       int     (*suspend) (struct usb_interface *intf, pm_message_t message);
+       int     (*resume) (struct usb_interface *intf);
+
+       const struct usb_device_id *id_table;
+
+       void    (*shutdown) (struct usb_interface *intf);
+
+       LIST_ENTRY(usb_driver) linux_driver_list;
+};
+
+#define        USB_DRIVER_EXPORT(id,p_usb_drv) \
+  SYSINIT(id,SI_SUB_KLD,SI_ORDER_FIRST,usb_linux_register,p_usb_drv); \
+  SYSUNINIT(id,SI_SUB_KLD,SI_ORDER_ANY,usb_linux_deregister,p_usb_drv)
+
+#define        USB_DT_ENDPOINT_SIZE            7
+#define        USB_DT_ENDPOINT_AUDIO_SIZE      9
+
+/*
+ * Endpoints
+ */
+#define        USB_ENDPOINT_NUMBER_MASK        0x0f    /* in bEndpointAddress */
+#define        USB_ENDPOINT_DIR_MASK           0x80
+
+#define        USB_ENDPOINT_XFERTYPE_MASK      0x03    /* in bmAttributes */
+#define        USB_ENDPOINT_XFER_CONTROL       0
+#define        USB_ENDPOINT_XFER_ISOC          1
+#define        USB_ENDPOINT_XFER_BULK          2
+#define        USB_ENDPOINT_XFER_INT           3
+#define        USB_ENDPOINT_MAX_ADJUSTABLE     0x80
+
+/* CONTROL REQUEST SUPPORT */
+
+/*
+ * Definition of direction mask for
+ * "bEndpointAddress" and "bmRequestType":
+ */
+#define        USB_DIR_MASK                    0x80
+#define        USB_DIR_OUT                     0x00    /* write to USB device */
+#define        USB_DIR_IN                      0x80    /* read from USB device */
+
+/*
+ * Definition of type mask for
+ * "bmRequestType":
+ */
+#define        USB_TYPE_MASK                   (0x03 << 5)
+#define        USB_TYPE_STANDARD               (0x00 << 5)
+#define        USB_TYPE_CLASS                  (0x01 << 5)
+#define        USB_TYPE_VENDOR                 (0x02 << 5)
+#define        USB_TYPE_RESERVED               (0x03 << 5)
+
+/*
+ * Definition of receiver mask for
+ * "bmRequestType":
+ */
+#define        USB_RECIP_MASK                  0x1f
+#define        USB_RECIP_DEVICE                0x00
+#define        USB_RECIP_INTERFACE             0x01
+#define        USB_RECIP_ENDPOINT              0x02
+#define        USB_RECIP_OTHER                 0x03
+
+/*
+ * Definition of standard request values for
+ * "bRequest":
+ */
+#define        USB_REQ_GET_STATUS              0x00
+#define        USB_REQ_CLEAR_FEATURE           0x01
+#define        USB_REQ_SET_FEATURE             0x03
+#define        USB_REQ_SET_ADDRESS             0x05
+#define        USB_REQ_GET_DESCRIPTOR          0x06
+#define        USB_REQ_SET_DESCRIPTOR          0x07
+#define        USB_REQ_GET_CONFIGURATION       0x08
+#define        USB_REQ_SET_CONFIGURATION       0x09
+#define        USB_REQ_GET_INTERFACE           0x0A
+#define        USB_REQ_SET_INTERFACE           0x0B
+#define        USB_REQ_SYNCH_FRAME             0x0C
+
+#define        USB_REQ_SET_ENCRYPTION          0x0D    /* Wireless USB */
+#define        USB_REQ_GET_ENCRYPTION          0x0E
+#define        USB_REQ_SET_HANDSHAKE           0x0F
+#define        USB_REQ_GET_HANDSHAKE           0x10
+#define        USB_REQ_SET_CONNECTION          0x11
+#define        USB_REQ_SET_SECURITY_DATA       0x12
+#define        USB_REQ_GET_SECURITY_DATA       0x13
+#define        USB_REQ_SET_WUSB_DATA           0x14
+#define        USB_REQ_LOOPBACK_DATA_WRITE     0x15
+#define        USB_REQ_LOOPBACK_DATA_READ      0x16
+#define        USB_REQ_SET_INTERFACE_DS        0x17
+
+/*
+ * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and
+ * are read as a bit array returned by USB_REQ_GET_STATUS.  (So there
+ * are at most sixteen features of each type.)
+ */
+#define        USB_DEVICE_SELF_POWERED         0       /* (read only) */
+#define        USB_DEVICE_REMOTE_WAKEUP        1       /* dev may initiate wakeup */
+#define        USB_DEVICE_TEST_MODE            2       /* (wired high speed only) */
+#define        USB_DEVICE_BATTERY              2       /* (wireless) */
+#define        USB_DEVICE_B_HNP_ENABLE         3       /* (otg) dev may initiate HNP */
+#define        USB_DEVICE_WUSB_DEVICE          3       /* (wireless) */
+#define        USB_DEVICE_A_HNP_SUPPORT        4       /* (otg) RH port supports HNP */
+#define        USB_DEVICE_A_ALT_HNP_SUPPORT    5       /* (otg) other RH port does */
+#define        USB_DEVICE_DEBUG_MODE           6       /* (special devices only) */
+
+#define        USB_ENDPOINT_HALT               0       /* IN/OUT will STALL */
+
+#define        PIPE_ISOCHRONOUS                0x01    /* UE_ISOCHRONOUS */
+#define        PIPE_INTERRUPT                  0x03    /* UE_INTERRUPT */
+#define        PIPE_CONTROL                    0x00    /* UE_CONTROL */
+#define        PIPE_BULK                       0x02    /* UE_BULK */
+
+/* Whenever Linux references an USB endpoint:
+ * a) to initialize "urb->endpoint"
+ * b) second argument passed to "usb_control_msg()"
+ *
+ * Then it uses one of the following macros. The "endpoint" argument
+ * is the physical endpoint value masked by 0xF. The "dev" argument
+ * is a pointer to "struct usb_device".
+ */
+#define        usb_sndctrlpipe(dev,endpoint) \
+  usb_find_host_endpoint(dev, PIPE_CONTROL, (endpoint) | USB_DIR_OUT)
+
+#define        usb_rcvctrlpipe(dev,endpoint) \
+  usb_find_host_endpoint(dev, PIPE_CONTROL, (endpoint) | USB_DIR_IN)
+
+#define        usb_sndisocpipe(dev,endpoint) \
+  usb_find_host_endpoint(dev, PIPE_ISOCHRONOUS, (endpoint) | USB_DIR_OUT)
+
+#define        usb_rcvisocpipe(dev,endpoint) \
+  usb_find_host_endpoint(dev, PIPE_ISOCHRONOUS, (endpoint) | USB_DIR_IN)
+
+#define        usb_sndbulkpipe(dev,endpoint) \
+  usb_find_host_endpoint(dev, PIPE_BULK, (endpoint) | USB_DIR_OUT)
+
+#define        usb_rcvbulkpipe(dev,endpoint) \
+  usb_find_host_endpoint(dev, PIPE_BULK, (endpoint) | USB_DIR_IN)
+
+#define        usb_sndintpipe(dev,endpoint) \
+  usb_find_host_endpoint(dev, PIPE_INTERRUPT, (endpoint) | USB_DIR_OUT)
+
+#define        usb_rcvintpipe(dev,endpoint) \
+  usb_find_host_endpoint(dev, PIPE_INTERRUPT, (endpoint) | USB_DIR_IN)
+
+/*
+ * The following structure is used to extend "struct urb" when we are
+ * dealing with an isochronous endpoint. It contains information about
+ * the data offset and data length of an isochronous packet.
+ * The "actual_length" field is updated before the "complete"
+ * callback in the "urb" structure is called.
+ */
+struct usb_iso_packet_descriptor {
+       uint32_t offset;                /* depreciated buffer offset (the
+                                        * packets are usually back to back) */
+       uint16_t length;                /* expected length */
+       uint16_t actual_length;
+        int16_t status;                /* transfer status */
+};
+
+/*
+ * The following structure holds various information about an USB
+ * transfer. This structure is used for all kinds of USB transfers.
+ *
+ * URB is short for USB Request Block.
+ */
+struct urb {
+       TAILQ_ENTRY(urb) bsd_urb_list;
+       struct cv cv_wait;
+
+       struct usb_device *dev;         /* (in) pointer to associated device */
+       struct usb_host_endpoint *endpoint;     /* (in) pipe pointer */
+       uint8_t *setup_packet;          /* (in) setup packet (control only) */
+       uint8_t *bsd_data_ptr;
+       void   *transfer_buffer;        /* (in) associated data buffer */
+       void   *context;                /* (in) context for completion */
+       usb_complete_t *complete;       /* (in) completion routine */
+
+       usb_size_t transfer_buffer_length;/* (in) data buffer length */
+       usb_size_t bsd_length_rem;
+       usb_size_t actual_length;       /* (return) actual transfer length */
+       usb_timeout_t timeout;          /* FreeBSD specific */
+
+       uint16_t transfer_flags;        /* (in) */
+#define        URB_SHORT_NOT_OK        0x0001  /* report short transfers like errors */
+#define        URB_ISO_ASAP            0x0002  /* ignore "start_frame" field */
+#define        URB_ZERO_PACKET         0x0004  /* the USB transfer ends with a short
+                                        * packet */
+#define        URB_NO_TRANSFER_DMA_MAP 0x0008  /* "transfer_dma" is valid on submit */
+#define        URB_WAIT_WAKEUP         0x0010  /* custom flags */
+#define        URB_IS_SLEEPING         0x0020  /* custom flags */
+
+       usb_frcount_t start_frame;      /* (modify) start frame (ISO) */
+       usb_frcount_t number_of_packets;        /* (in) number of ISO packets */
+       uint16_t interval;              /* (modify) transfer interval
+                                        * (INT/ISO) */
+       uint16_t error_count;           /* (return) number of ISO errors */
+       int16_t status;                 /* (return) status */
+
+       uint8_t setup_dma;              /* (in) not used on FreeBSD */
+       uint8_t transfer_dma;           /* (in) not used on FreeBSD */
+       uint8_t bsd_isread;
+       uint8_t kill_count;             /* FreeBSD specific */
+
+       struct usb_iso_packet_descriptor iso_frame_desc[];      /* (in) ISO ONLY */
+};
+
+/* various prototypes */
+
+int    usb_submit_urb(struct urb *urb, uint16_t mem_flags);
+int    usb_unlink_urb(struct urb *urb);
+int    usb_clear_halt(struct usb_device *dev, struct usb_host_endpoint *uhe);
+int    usb_control_msg(struct usb_device *dev, struct usb_host_endpoint *ep,
+           uint8_t request, uint8_t requesttype, uint16_t value,
+           uint16_t index, void *data, uint16_t size, usb_timeout_t timeout);
+int    usb_set_interface(struct usb_device *dev, uint8_t ifnum,
+           uint8_t alternate);
+int    usb_setup_endpoint(struct usb_device *dev,
+           struct usb_host_endpoint *uhe, usb_frlength_t bufsize);
+
+struct usb_host_endpoint *usb_find_host_endpoint(struct usb_device *dev,
+           uint8_t type, uint8_t ep);
+struct urb *usb_alloc_urb(uint16_t iso_packets, uint16_t mem_flags);
+struct usb_host_interface *usb_altnum_to_altsetting(
+           const struct usb_interface *intf, uint8_t alt_index);
+struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, uint8_t iface_no);
+
+void   *usb_buffer_alloc(struct usb_device *dev, usb_size_t size,
+           uint16_t mem_flags, uint8_t *dma_addr);
+void   *usbd_get_intfdata(struct usb_interface *intf);
+
+void   usb_buffer_free(struct usb_device *dev, usb_size_t size, void *addr, uint8_t dma_addr);
+void   usb_free_urb(struct urb *urb);
+void   usb_init_urb(struct urb *urb);
+void   usb_kill_urb(struct urb *urb);
+void   usb_set_intfdata(struct usb_interface *intf, void *data);
+void   usb_linux_register(void *arg);
+void   usb_linux_deregister(void *arg);
+
+void   usb_fill_bulk_urb(struct urb *, struct usb_device *,
+           struct usb_host_endpoint *, void *, int, usb_complete_t, void *);
+int    usb_bulk_msg(struct usb_device *, struct usb_host_endpoint *,
+           void *, int, uint16_t *, usb_timeout_t);
+
+#define        interface_to_usbdev(intf) (intf)->linux_udev
+#define        interface_to_bsddev(intf) (intf)->linux_udev
+
+#endif                                 /* _USB_COMPAT_LINUX_H */
diff --git a/sys/compat/linuxkpi/common/include/linux/vmalloc.h b/sys/compat/linuxkpi/common/include/linux/vmalloc.h
new file mode 100644 (file)
index 0000000..5317831
--- /dev/null
@@ -0,0 +1,43 @@
+/*-
+ * 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 _LINUX_VMALLOC_H_
+#define        _LINUX_VMALLOC_H_
+
+#include <linux/page.h>
+
+#define        VM_MAP          0x0000
+#define        PAGE_KERNEL     0x0000
+
+void *vmap(struct page **pages, unsigned int count, unsigned long flags,
+    int prot);
+void vunmap(void *addr);
+
+#endif /* _LINUX_VMALLOC_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/wait.h b/sys/compat/linuxkpi/common/include/linux/wait.h
new file mode 100644 (file)
index 0000000..c62f735
--- /dev/null
@@ -0,0 +1,135 @@
+/*-
+ * 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        _LINUX_WAIT_H_
+#define        _LINUX_WAIT_H_
+
+#include <linux/spinlock.h>
+#include <linux/sched.h>
+#include <linux/list.h>
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/sleepqueue.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+
+typedef struct {
+} wait_queue_t;
+
+typedef struct {
+       unsigned int    wchan;
+} wait_queue_head_t;
+
+#define        init_waitqueue_head(x) \
+    do { } while (0)
+
+static inline void
+__wake_up(wait_queue_head_t *q, int all)
+{
+       int wakeup_swapper;
+       void *c;
+
+       c = &q->wchan;
+       sleepq_lock(c);
+       if (all)
+               wakeup_swapper = sleepq_broadcast(c, SLEEPQ_SLEEP, 0, 0);
+       else
+               wakeup_swapper = sleepq_signal(c, SLEEPQ_SLEEP, 0, 0);
+       sleepq_release(c);
+       if (wakeup_swapper)
+               kick_proc0();
+}
+
+#define        wake_up(q)                              __wake_up(q, 0)
+#define        wake_up_nr(q, nr)                       __wake_up(q, 1)
+#define        wake_up_all(q)                          __wake_up(q, 1)
+#define        wake_up_interruptible(q)                __wake_up(q, 0)
+#define        wake_up_interruptible_nr(q, nr)         __wake_up(q, 1)
+#define        wake_up_interruptible_all(q, nr)        __wake_up(q, 1)
+
+#define        wait_event(q, cond)                                             \
+do {                                                                   \
+       void *c = &(q).wchan;                                           \
+       if (!(cond)) {                                                  \
+               for (;;) {                                              \
+                       sleepq_lock(c);                                 \
+                       if (cond) {                                     \
+                               sleepq_release(c);                      \
+                               break;                                  \
+                       }                                               \
+                       sleepq_add(c, NULL, "completion", SLEEPQ_SLEEP, 0); \
+                       sleepq_wait(c, 0);                              \
+               }                                                       \
+       }                                                               \
+} while (0)
+
+#define        wait_event_interruptible(q, cond)                               \
+({                                                                     \
+       void *c = &(q).wchan;                                           \
+       int _error;                                                     \
+                                                                       \
+       _error = 0;                                                     \
+       if (!(cond)) {                                                  \
+               for (; _error == 0;) {                                  \
+                       sleepq_lock(c);                                 \
+                       if (cond) {                                     \
+                               sleepq_release(c);                      \
+                               break;                                  \
+                       }                                               \
+                       sleepq_add(c, NULL, "completion",               \
+                           SLEEPQ_SLEEP | SLEEPQ_INTERRUPTIBLE, 0);    \
+                       if (sleepq_wait_sig(c, 0))                      \
+                               _error = -ERESTARTSYS;                  \
+               }                                                       \
+       }                                                               \
+       -_error;                                                        \
+})
+
+static inline int
+waitqueue_active(wait_queue_head_t *q)
+{
+       return 0;       /* XXX: not really implemented */
+}
+
+#define DEFINE_WAIT(name)      \
+       wait_queue_t name = {}
+
+static inline void
+prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state)
+{
+}
+
+static inline void
+finish_wait(wait_queue_head_t *q, wait_queue_t *wait)
+{
+}
+
+#endif /* _LINUX_WAIT_H_ */
diff --git a/sys/compat/linuxkpi/common/include/linux/workqueue.h b/sys/compat/linuxkpi/common/include/linux/workqueue.h
new file mode 100644 (file)
index 0000000..e9a6f5a
--- /dev/null
@@ -0,0 +1,231 @@
+/*-
+ * 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        _LINUX_WORKQUEUE_H_
+#define        _LINUX_WORKQUEUE_H_
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/timer.h>
+#include <linux/slab.h>
+
+#include <sys/taskqueue.h>
+
+struct workqueue_struct {
+       struct taskqueue        *taskqueue;
+};
+
+struct work_struct {
+       struct  task            work_task;
+       struct  taskqueue       *taskqueue;
+       void                    (*fn)(struct work_struct *);
+};
+
+struct delayed_work {
+       struct work_struct      work;
+       struct callout          timer;
+};
+
+static inline struct delayed_work *
+to_delayed_work(struct work_struct *work)
+{
+
+       return container_of(work, struct delayed_work, work);
+}
+
+
+static inline void
+_work_fn(void *context, int pending)
+{
+       struct work_struct *work;
+
+       work = context;
+       work->fn(work);
+}
+
+#define        INIT_WORK(work, func)                                           \
+do {                                                                   \
+       (work)->fn = (func);                                            \
+       (work)->taskqueue = NULL;                                       \
+       TASK_INIT(&(work)->work_task, 0, _work_fn, (work));             \
+} while (0)
+
+#define        INIT_DELAYED_WORK(_work, func)                                  \
+do {                                                                   \
+       INIT_WORK(&(_work)->work, func);                                \
+       callout_init(&(_work)->timer, 1);                               \
+} while (0)
+
+#define        INIT_DEFERRABLE_WORK    INIT_DELAYED_WORK
+
+#define        schedule_work(work)                                             \
+do {                                                                   \
+       (work)->taskqueue = taskqueue_thread;                           \
+       taskqueue_enqueue(taskqueue_thread, &(work)->work_task);        \
+} while (0)
+
+#define        flush_scheduled_work()  flush_taskqueue(taskqueue_thread)
+
+static inline int queue_work(struct workqueue_struct *q, struct work_struct *work)
+{
+       (work)->taskqueue = (q)->taskqueue;
+       /* Return opposite val to align with Linux logic */
+       return !taskqueue_enqueue((q)->taskqueue, &(work)->work_task);
+}
+
+static inline void
+_delayed_work_fn(void *arg)
+{
+       struct delayed_work *work;
+
+       work = arg;
+       taskqueue_enqueue(work->work.taskqueue, &work->work.work_task);
+}
+
+static inline int
+queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *work,
+    unsigned long delay)
+{
+       int pending;
+
+       pending = work->work.work_task.ta_pending;
+       work->work.taskqueue = wq->taskqueue;
+       if (delay != 0)
+               callout_reset(&work->timer, delay, _delayed_work_fn, work);
+       else
+               _delayed_work_fn((void *)work);
+
+       return (!pending);
+}
+
+static inline bool schedule_delayed_work(struct delayed_work *dwork,
+                                         unsigned long delay)
+{
+        struct workqueue_struct wq;
+        wq.taskqueue = taskqueue_thread;
+        return queue_delayed_work(&wq, dwork, delay);
+}
+
+static inline struct workqueue_struct *
+_create_workqueue_common(char *name, int cpus)
+{
+       struct workqueue_struct *wq;
+
+       wq = kmalloc(sizeof(*wq), M_WAITOK);
+       wq->taskqueue = taskqueue_create((name), M_WAITOK,
+           taskqueue_thread_enqueue,  &wq->taskqueue);
+       taskqueue_start_threads(&wq->taskqueue, cpus, PWAIT, "%s", name);
+
+       return (wq);
+}
+
+
+#define        create_singlethread_workqueue(name)                             \
+       _create_workqueue_common(name, 1)
+
+#define        create_workqueue(name)                                          \
+       _create_workqueue_common(name, MAXCPU)
+
+#define        alloc_ordered_workqueue(name, flags)                            \
+       _create_workqueue_common(name, 1)
+
+#define        alloc_workqueue(name, flags, max_active)                        \
+       _create_workqueue_common(name, max_active)
+
+static inline void
+destroy_workqueue(struct workqueue_struct *wq)
+{
+       taskqueue_free(wq->taskqueue);
+       kfree(wq);
+}
+
+#define        flush_workqueue(wq)     flush_taskqueue((wq)->taskqueue)
+
+static inline void
+_flush_fn(void *context, int pending)
+{
+}
+
+static inline void
+flush_taskqueue(struct taskqueue *tq)
+{
+       struct task flushtask;
+
+       PHOLD(curproc);
+       TASK_INIT(&flushtask, 0, _flush_fn, NULL);
+       taskqueue_enqueue(tq, &flushtask);
+       taskqueue_drain(tq, &flushtask);
+       PRELE(curproc);
+}
+
+static inline int
+cancel_work_sync(struct work_struct *work)
+{
+       if (work->taskqueue &&
+           taskqueue_cancel(work->taskqueue, &work->work_task, NULL))
+               taskqueue_drain(work->taskqueue, &work->work_task);
+       return 0;
+}
+
+/*
+ * This may leave work running on another CPU as it does on Linux.
+ */
+static inline int
+cancel_delayed_work(struct delayed_work *work)
+{
+
+       callout_stop(&work->timer);
+       if (work->work.taskqueue)
+               return (taskqueue_cancel(work->work.taskqueue,
+                   &work->work.work_task, NULL) == 0);
+       return 0;
+}
+
+static inline int
+cancel_delayed_work_sync(struct delayed_work *work)
+{
+
+        callout_drain(&work->timer);
+        if (work->work.taskqueue &&
+            taskqueue_cancel(work->work.taskqueue, &work->work.work_task, NULL))
+                taskqueue_drain(work->work.taskqueue, &work->work.work_task);
+        return 0;
+}
+
+static inline bool
+mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork,
+                                     unsigned long delay)
+{
+       cancel_delayed_work(dwork);
+       queue_delayed_work(wq, dwork, delay);
+       return false;
+}
+
+#endif /* _LINUX_WORKQUEUE_H_ */
diff --git a/sys/compat/linuxkpi/common/include/net/if_inet6.h b/sys/compat/linuxkpi/common/include/net/if_inet6.h
new file mode 100644 (file)
index 0000000..df853fd
--- /dev/null
@@ -0,0 +1,48 @@
+/*-
+ * 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 _NET_IF_INET6_H_
+#define        _NET_IF_INET6_H_
+
+static inline void ipv6_eth_mc_map(const struct in6_addr *addr, char *buf)
+{
+/*
+ *      +-------+-------+-------+-------+-------+-------+
+ *      |   33  |   33  | DST13 | DST14 | DST15 | DST16 |
+ *      +-------+-------+-------+-------+-------+-------+
+ */
+
+        buf[0]= 0x33;
+        buf[1]= 0x33;
+
+        memcpy(buf + 2, &addr->s6_addr32[3], sizeof(__u32));
+}
+
+#endif /* _NET_IF_INET6_H_ */
diff --git a/sys/compat/linuxkpi/common/include/net/ip.h b/sys/compat/linuxkpi/common/include/net/ip.h
new file mode 100644 (file)
index 0000000..7fbe9d9
--- /dev/null
@@ -0,0 +1,88 @@
+/*-
+ * 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 _LINUX_NET_IP_H_
+#define        _LINUX_NET_IP_H_
+
+#include "opt_inet.h"
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <net/if_types.h>
+#include <net/if.h>
+#include <net/if_var.h>
+
+#include <netinet/in.h>
+#include <netinet/in_pcb.h>
+
+static inline void inet_get_local_port_range(int *low, int *high)
+{
+#ifdef INET
+       CURVNET_SET_QUIET(TD_TO_VNET(curthread));
+       *low = V_ipport_firstauto;
+       *high = V_ipport_lastauto;
+       CURVNET_RESTORE();
+#else
+       *low = IPPORT_EPHEMERALFIRST;     /* 10000 */
+       *high = IPPORT_EPHEMERALLAST;     /* 65535 */
+#endif
+}
+
+static inline void
+ip_ib_mc_map(uint32_t addr, const unsigned char *bcast, char *buf)
+{
+       unsigned char scope;
+
+       addr = ntohl(addr);
+       scope = bcast[5] & 0xF;
+       buf[0] = 0;
+       buf[1] = 0xff;
+       buf[2] = 0xff;
+       buf[3] = 0xff;
+       buf[4] = 0xff;
+       buf[5] = 0x10 | scope;
+       buf[6] = 0x40;
+       buf[7] = 0x1b;
+       buf[8] = bcast[8];
+       buf[9] = bcast[9];
+       buf[10] = 0;
+       buf[11] = 0;
+       buf[12] = 0;
+       buf[13] = 0;
+       buf[14] = 0;
+       buf[15] = 0;
+       buf[16] = (addr >> 24) & 0xff;
+       buf[17] = (addr >> 16) & 0xff;
+       buf[18] = (addr >> 8) & 0xff;
+       buf[19] = addr & 0xff;
+}
+
+#endif /* _LINUX_NET_IP_H_ */
diff --git a/sys/compat/linuxkpi/common/include/net/ipv6.h b/sys/compat/linuxkpi/common/include/net/ipv6.h
new file mode 100644 (file)
index 0000000..1244706
--- /dev/null
@@ -0,0 +1,111 @@
+/*-
+ * 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 _LINUX_NET_IPV6_H_
+#define        _LINUX_NET_IPV6_H_
+
+#include "opt_inet6.h"
+
+#define        ipv6_addr_loopback IN6_IS_ADDR_LOOPBACK
+#define        ipv6_addr_copy(dst, src)                                        \
+       memcpy((dst), (src), sizeof(struct in6_addr))
+
+#ifdef INET6
+static inline void
+ipv6_ib_mc_map(const struct in6_addr *addr, const unsigned char *broadcast,
+    char *buf)
+{
+       unsigned char scope;
+
+       scope = broadcast[5] & 0xF;
+       buf[0]  = 0;
+       buf[1]  = 0xff;
+       buf[2]  = 0xff;
+       buf[3]  = 0xff;
+       buf[4]  = 0xff;
+       buf[5]  = 0x10 | scope;
+       buf[6]  = 0x60;
+       buf[7]  = 0x1b;
+       buf[8]  = broadcast[8];
+       buf[9]  = broadcast[9];
+       memcpy(&buf[10], &addr->s6_addr[6], 10);
+}
+#endif
+
+static inline void __ipv6_addr_set_half(__be32 *addr,
+                                        __be32 wh, __be32 wl)
+{
+#if BITS_PER_LONG == 64
+#if defined(__BIG_ENDIAN)
+        if (__builtin_constant_p(wh) && __builtin_constant_p(wl)) {
+                *(__force u64 *)addr = ((__force u64)(wh) << 32 | (__force u64)(wl));
+                return;
+        }
+#elif defined(__LITTLE_ENDIAN)
+        if (__builtin_constant_p(wl) && __builtin_constant_p(wh)) {
+                *(__force u64 *)addr = ((__force u64)(wl) << 32 | (__force u64)(wh));
+                return;
+        }
+#endif
+#endif
+        addr[0] = wh;
+        addr[1] = wl;
+}
+
+static inline void ipv6_addr_set(struct in6_addr *addr,
+                                     __be32 w1, __be32 w2,
+                                     __be32 w3, __be32 w4)
+{
+        __ipv6_addr_set_half(&addr->s6_addr32[0], w1, w2);
+        __ipv6_addr_set_half(&addr->s6_addr32[2], w3, w4);
+}
+
+static inline void ipv6_addr_set_v4mapped(const __be32 addr,
+                                         struct in6_addr *v4mapped)
+{
+       ipv6_addr_set(v4mapped,
+                       0, 0,
+                       htonl(0x0000FFFF),
+                       addr);
+}
+
+static inline int ipv6_addr_v4mapped(const struct in6_addr *a)
+{
+       return ((a->s6_addr32[0] | a->s6_addr32[1] |
+               (a->s6_addr32[2] ^ htonl(0x0000ffff))) == 0);
+}
+
+static inline int ipv6_addr_cmp(const struct in6_addr *a1, const struct in6_addr *a2)
+{
+        return memcmp(a1, a2, sizeof(struct in6_addr));
+}
+
+
+#endif /* _LINUX_NET_IPV6_H_ */
diff --git a/sys/compat/linuxkpi/common/include/net/netevent.h b/sys/compat/linuxkpi/common/include/net/netevent.h
new file mode 100644 (file)
index 0000000..d2d37c0
--- /dev/null
@@ -0,0 +1,72 @@
+/*-
+ * 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        _LINUX_NET_NETEVENT_H_
+#define        _LINUX_NET_NETEVENT_H_
+
+#include <netinet/if_ether.h>
+
+enum netevent_notif_type {
+       NETEVENT_NEIGH_UPDATE = 0,
+#if 0 /* Unsupported events. */
+        NETEVENT_PMTU_UPDATE,
+        NETEVENT_REDIRECT,
+#endif
+};
+
+struct llentry;
+
+static inline void
+_handle_arp_update_event(void *arg, struct llentry *lle, int evt __unused)
+{
+       struct notifier_block *nb;
+
+       nb = arg;
+       nb->notifier_call(nb, NETEVENT_NEIGH_UPDATE, lle);
+}
+
+static inline int
+register_netevent_notifier(struct notifier_block *nb)
+{
+       nb->tags[NETEVENT_NEIGH_UPDATE] = EVENTHANDLER_REGISTER(
+           lle_event, _handle_arp_update_event, nb, 0);
+       return (0);
+}
+
+static inline int
+unregister_netevent_notifier(struct notifier_block *nb)
+{
+
+       EVENTHANDLER_DEREGISTER(lle_event, nb->tags[NETEVENT_NEIGH_UPDATE]);
+
+       return (0);
+}
+
+#endif /* _LINUX_NET_NETEVENT_H_ */
diff --git a/sys/compat/linuxkpi/common/include/net/tcp.h b/sys/compat/linuxkpi/common/include/net/tcp.h
new file mode 100644 (file)
index 0000000..3f15619
--- /dev/null
@@ -0,0 +1,40 @@
+/*-
+ * 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 _LINUX_NET_TCP_H_
+#define        _LINUX_NET_TCP_H_
+
+#include <linux/list.h>
+#include <linux/slab.h>
+#include <linux/kref.h>
+
+#include <net/ip.h>
+
+#endif /* _LINUX_NET_TCP_H_ */
diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c
new file mode 100644 (file)
index 0000000..26df7db
--- /dev/null
@@ -0,0 +1,954 @@
+/*-
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <sys/sysctl.h>
+#include <sys/proc.h>
+#include <sys/sglist.h>
+#include <sys/sleepqueue.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/bus.h>
+#include <sys/fcntl.h>
+#include <sys/file.h>
+#include <sys/filio.h>
+#include <sys/rwlock.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <machine/stdarg.h>
+#include <machine/pmap.h>
+
+#include <linux/kobject.h>
+#include <linux/device.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/cdev.h>
+#include <linux/file.h>
+#include <linux/sysfs.h>
+#include <linux/mm.h>
+#include <linux/io.h>
+#include <linux/vmalloc.h>
+#include <linux/netdevice.h>
+#include <linux/timer.h>
+
+#include <vm/vm_pager.h>
+
+MALLOC_DEFINE(M_KMALLOC, "linux", "Linux kmalloc compat");
+
+#include <linux/rbtree.h>
+/* Undo Linux compat changes. */
+#undef RB_ROOT
+#undef file
+#undef cdev
+#define        RB_ROOT(head)   (head)->rbh_root
+
+struct kobject class_root;
+struct device linux_rootdev;
+struct class miscclass;
+struct list_head pci_drivers;
+struct list_head pci_devices;
+struct net init_net;
+spinlock_t pci_lock;
+
+unsigned long linux_timer_hz_mask;
+
+int
+panic_cmp(struct rb_node *one, struct rb_node *two)
+{
+       panic("no cmp");
+}
+
+RB_GENERATE(linux_root, rb_node, __entry, panic_cmp);
+int
+kobject_set_name(struct kobject *kobj, const char *fmt, ...)
+{
+       va_list args;
+       int error;
+
+       va_start(args, fmt);
+       error = kobject_set_name_vargs(kobj, fmt, args);
+       va_end(args);
+
+       return (error);
+}
+
+static inline int
+kobject_add_complete(struct kobject *kobj, struct kobject *parent)
+{
+       struct kobj_type *t;
+       int error;
+
+       kobj->parent = kobject_get(parent);
+       error = sysfs_create_dir(kobj);
+       if (error == 0 && kobj->ktype && kobj->ktype->default_attrs) {
+               struct attribute **attr;
+               t = kobj->ktype;
+
+               for (attr = t->default_attrs; *attr != NULL; attr++) {
+                       error = sysfs_create_file(kobj, *attr);
+                       if (error)
+                               break;
+               }
+               if (error)
+                       sysfs_remove_dir(kobj);
+               
+       }
+       return (error);
+}
+
+int
+kobject_add(struct kobject *kobj, struct kobject *parent, const char *fmt, ...)
+{
+       va_list args;
+       int error;
+
+       va_start(args, fmt);
+       error = kobject_set_name_vargs(kobj, fmt, args);
+       va_end(args);
+       if (error)
+               return (error);
+
+       return kobject_add_complete(kobj, parent);
+}
+
+void
+kobject_release(struct kref *kref)
+{
+       struct kobject *kobj;
+       char *name;
+
+       kobj = container_of(kref, struct kobject, kref);
+       sysfs_remove_dir(kobj);
+       if (kobj->parent)
+               kobject_put(kobj->parent);
+       kobj->parent = NULL;
+       name = kobj->name;
+       if (kobj->ktype && kobj->ktype->release)
+               kobj->ktype->release(kobj);
+       kfree(name);
+}
+
+static void
+kobject_kfree(struct kobject *kobj)
+{
+       kfree(kobj);
+}
+
+static void
+kobject_kfree_name(struct kobject *kobj)
+{
+       if (kobj) {
+               kfree(kobj->name);
+       }
+}
+
+struct kobj_type kfree_type = { .release = kobject_kfree };
+
+static void
+dev_release(struct device *dev)
+{
+       pr_debug("dev_release: %s\n", dev_name(dev));
+       kfree(dev);
+}
+
+struct device *
+device_create(struct class *class, struct device *parent, dev_t devt,
+    void *drvdata, const char *fmt, ...)
+{
+       struct device *dev;
+       va_list args;
+
+       dev = kzalloc(sizeof(*dev), M_WAITOK);
+       dev->parent = parent;
+       dev->class = class;
+       dev->devt = devt;
+       dev->driver_data = drvdata;
+       dev->release = dev_release;
+       va_start(args, fmt);
+       kobject_set_name_vargs(&dev->kobj, fmt, args);
+       va_end(args);
+       device_register(dev);
+
+       return (dev);
+}
+
+int
+kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype,
+    struct kobject *parent, const char *fmt, ...)
+{
+       va_list args;
+       int error;
+
+       kobject_init(kobj, ktype);
+       kobj->ktype = ktype;
+       kobj->parent = parent;
+       kobj->name = NULL;
+
+       va_start(args, fmt);
+       error = kobject_set_name_vargs(kobj, fmt, args);
+       va_end(args);
+       if (error)
+               return (error);
+       return kobject_add_complete(kobj, parent);
+}
+
+static void
+linux_file_dtor(void *cdp)
+{
+       struct linux_file *filp;
+
+       filp = cdp;
+       filp->f_op->release(filp->f_vnode, filp);
+       vdrop(filp->f_vnode);
+       kfree(filp);
+}
+
+static int
+linux_dev_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
+{
+       struct linux_cdev *ldev;
+       struct linux_file *filp;
+       struct file *file;
+       int error;
+
+       file = curthread->td_fpop;
+       ldev = dev->si_drv1;
+       if (ldev == NULL)
+               return (ENODEV);
+       filp = kzalloc(sizeof(*filp), GFP_KERNEL);
+       filp->f_dentry = &filp->f_dentry_store;
+       filp->f_op = ldev->ops;
+       filp->f_flags = file->f_flag;
+       vhold(file->f_vnode);
+       filp->f_vnode = file->f_vnode;
+       if (filp->f_op->open) {
+               error = -filp->f_op->open(file->f_vnode, filp);
+               if (error) {
+                       kfree(filp);
+                       return (error);
+               }
+       }
+       error = devfs_set_cdevpriv(filp, linux_file_dtor);
+       if (error) {
+               filp->f_op->release(file->f_vnode, filp);
+               kfree(filp);
+               return (error);
+       }
+
+       return 0;
+}
+
+static int
+linux_dev_close(struct cdev *dev, int fflag, int devtype, struct thread *td)
+{
+       struct linux_cdev *ldev;
+       struct linux_file *filp;
+       struct file *file;
+       int error;
+
+       file = curthread->td_fpop;
+       ldev = dev->si_drv1;
+       if (ldev == NULL)
+               return (0);
+       if ((error = devfs_get_cdevpriv((void **)&filp)) != 0)
+               return (error);
+       filp->f_flags = file->f_flag;
+        devfs_clear_cdevpriv();
+        
+
+       return (0);
+}
+
+static int
+linux_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
+    struct thread *td)
+{
+       struct linux_cdev *ldev;
+       struct linux_file *filp;
+       struct file *file;
+       int error;
+
+       file = curthread->td_fpop;
+       ldev = dev->si_drv1;
+       if (ldev == NULL)
+               return (0);
+       if ((error = devfs_get_cdevpriv((void **)&filp)) != 0)
+               return (error);
+       filp->f_flags = file->f_flag;
+       /*
+        * Linux does not have a generic ioctl copyin/copyout layer.  All
+        * linux ioctls must be converted to void ioctls which pass a
+        * pointer to the address of the data.  We want the actual user
+        * address so we dereference here.
+        */
+       data = *(void **)data;
+       if (filp->f_op->unlocked_ioctl)
+               error = -filp->f_op->unlocked_ioctl(filp, cmd, (u_long)data);
+       else
+               error = ENOTTY;
+
+       return (error);
+}
+
+static int
+linux_dev_read(struct cdev *dev, struct uio *uio, int ioflag)
+{
+       struct linux_cdev *ldev;
+       struct linux_file *filp;
+       struct file *file;
+       ssize_t bytes;
+       int error;
+
+       file = curthread->td_fpop;
+       ldev = dev->si_drv1;
+       if (ldev == NULL)
+               return (0);
+       if ((error = devfs_get_cdevpriv((void **)&filp)) != 0)
+               return (error);
+       filp->f_flags = file->f_flag;
+       if (uio->uio_iovcnt != 1)
+               panic("linux_dev_read: uio %p iovcnt %d",
+                   uio, uio->uio_iovcnt);
+       if (filp->f_op->read) {
+               bytes = filp->f_op->read(filp, uio->uio_iov->iov_base,
+                   uio->uio_iov->iov_len, &uio->uio_offset);
+               if (bytes >= 0) {
+                       uio->uio_iov->iov_base =
+                           ((uint8_t *)uio->uio_iov->iov_base) + bytes;
+                       uio->uio_iov->iov_len -= bytes;
+                       uio->uio_resid -= bytes;
+               } else
+                       error = -bytes;
+       } else
+               error = ENXIO;
+
+       return (error);
+}
+
+static int
+linux_dev_write(struct cdev *dev, struct uio *uio, int ioflag)
+{
+       struct linux_cdev *ldev;
+       struct linux_file *filp;
+       struct file *file;
+       ssize_t bytes;
+       int error;
+
+       file = curthread->td_fpop;
+       ldev = dev->si_drv1;
+       if (ldev == NULL)
+               return (0);
+       if ((error = devfs_get_cdevpriv((void **)&filp)) != 0)
+               return (error);
+       filp->f_flags = file->f_flag;
+       if (uio->uio_iovcnt != 1)
+               panic("linux_dev_write: uio %p iovcnt %d",
+                   uio, uio->uio_iovcnt);
+       if (filp->f_op->write) {
+               bytes = filp->f_op->write(filp, uio->uio_iov->iov_base,
+                   uio->uio_iov->iov_len, &uio->uio_offset);
+               if (bytes >= 0) {
+                       uio->uio_iov->iov_base =
+                           ((uint8_t *)uio->uio_iov->iov_base) + bytes;
+                       uio->uio_iov->iov_len -= bytes;
+                       uio->uio_resid -= bytes;
+               } else
+                       error = -bytes;
+       } else
+               error = ENXIO;
+
+       return (error);
+}
+
+static int
+linux_dev_poll(struct cdev *dev, int events, struct thread *td)
+{
+       struct linux_cdev *ldev;
+       struct linux_file *filp;
+       struct file *file;
+       int revents;
+       int error;
+
+       file = curthread->td_fpop;
+       ldev = dev->si_drv1;
+       if (ldev == NULL)
+               return (0);
+       if ((error = devfs_get_cdevpriv((void **)&filp)) != 0)
+               return (error);
+       filp->f_flags = file->f_flag;
+       if (filp->f_op->poll)
+               revents = filp->f_op->poll(filp, NULL) & events;
+       else
+               revents = 0;
+
+       return (revents);
+}
+
+static int
+linux_dev_mmap_single(struct cdev *dev, vm_ooffset_t *offset,
+    vm_size_t size, struct vm_object **object, int nprot)
+{
+       struct linux_cdev *ldev;
+       struct linux_file *filp;
+       struct file *file;
+       struct vm_area_struct vma;
+       int error;
+
+       file = curthread->td_fpop;
+       ldev = dev->si_drv1;
+       if (ldev == NULL)
+               return (ENODEV);
+       if ((error = devfs_get_cdevpriv((void **)&filp)) != 0)
+               return (error);
+       filp->f_flags = file->f_flag;
+       vma.vm_start = 0;
+       vma.vm_end = size;
+       vma.vm_pgoff = *offset / PAGE_SIZE;
+       vma.vm_pfn = 0;
+       vma.vm_page_prot = 0;
+       if (filp->f_op->mmap) {
+               error = -filp->f_op->mmap(filp, &vma);
+               if (error == 0) {
+                       struct sglist *sg;
+
+                       sg = sglist_alloc(1, M_WAITOK);
+                       sglist_append_phys(sg,
+                           (vm_paddr_t)vma.vm_pfn << PAGE_SHIFT, vma.vm_len);
+                       *object = vm_pager_allocate(OBJT_SG, sg, vma.vm_len,
+                           nprot, 0, curthread->td_ucred);
+                       if (*object == NULL) {
+                               sglist_free(sg);
+                               return (EINVAL);
+                       }
+                       *offset = 0;
+                       if (vma.vm_page_prot != VM_MEMATTR_DEFAULT) {
+                               VM_OBJECT_WLOCK(*object);
+                               vm_object_set_memattr(*object,
+                                   vma.vm_page_prot);
+                               VM_OBJECT_WUNLOCK(*object);
+                       }
+               }
+       } else
+               error = ENODEV;
+
+       return (error);
+}
+
+struct cdevsw linuxcdevsw = {
+       .d_version = D_VERSION,
+       .d_flags = D_TRACKCLOSE,
+       .d_open = linux_dev_open,
+       .d_close = linux_dev_close,
+       .d_read = linux_dev_read,
+       .d_write = linux_dev_write,
+       .d_ioctl = linux_dev_ioctl,
+       .d_mmap_single = linux_dev_mmap_single,
+       .d_poll = linux_dev_poll,
+};
+
+static int
+linux_file_read(struct file *file, struct uio *uio, struct ucred *active_cred,
+    int flags, struct thread *td)
+{
+       struct linux_file *filp;
+       ssize_t bytes;
+       int error;
+
+       error = 0;
+       filp = (struct linux_file *)file->f_data;
+       filp->f_flags = file->f_flag;
+       if (uio->uio_iovcnt != 1)
+               panic("linux_file_read: uio %p iovcnt %d",
+                   uio, uio->uio_iovcnt);
+       if (filp->f_op->read) {
+               bytes = filp->f_op->read(filp, uio->uio_iov->iov_base,
+                   uio->uio_iov->iov_len, &uio->uio_offset);
+               if (bytes >= 0) {
+                       uio->uio_iov->iov_base =
+                           ((uint8_t *)uio->uio_iov->iov_base) + bytes;
+                       uio->uio_iov->iov_len -= bytes;
+                       uio->uio_resid -= bytes;
+               } else
+                       error = -bytes;
+       } else
+               error = ENXIO;
+
+       return (error);
+}
+
+static int
+linux_file_poll(struct file *file, int events, struct ucred *active_cred,
+    struct thread *td)
+{
+       struct linux_file *filp;
+       int revents;
+
+       filp = (struct linux_file *)file->f_data;
+       filp->f_flags = file->f_flag;
+       if (filp->f_op->poll)
+               revents = filp->f_op->poll(filp, NULL) & events;
+       else
+               revents = 0;
+
+       return (0);
+}
+
+static int
+linux_file_close(struct file *file, struct thread *td)
+{
+       struct linux_file *filp;
+       int error;
+
+       filp = (struct linux_file *)file->f_data;
+       filp->f_flags = file->f_flag;
+       error = -filp->f_op->release(NULL, filp);
+       funsetown(&filp->f_sigio);
+       kfree(filp);
+
+       return (error);
+}
+
+static int
+linux_file_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *cred,
+    struct thread *td)
+{
+       struct linux_file *filp;
+       int error;
+
+       filp = (struct linux_file *)fp->f_data;
+       filp->f_flags = fp->f_flag;
+       error = 0;
+
+       switch (cmd) {
+       case FIONBIO:
+               break;
+       case FIOASYNC:
+               if (filp->f_op->fasync == NULL)
+                       break;
+               error = filp->f_op->fasync(0, filp, fp->f_flag & FASYNC);
+               break;
+       case FIOSETOWN:
+               error = fsetown(*(int *)data, &filp->f_sigio);
+               if (error == 0)
+                       error = filp->f_op->fasync(0, filp,
+                           fp->f_flag & FASYNC);
+               break;
+       case FIOGETOWN:
+               *(int *)data = fgetown(&filp->f_sigio);
+               break;
+       default:
+               error = ENOTTY;
+               break;
+       }
+       return (error);
+}
+
+static int
+linux_file_stat(struct file *fp, struct stat *sb, struct ucred *active_cred,
+    struct thread *td)
+{
+
+       return (EOPNOTSUPP);
+}
+
+static int
+linux_file_fill_kinfo(struct file *fp, struct kinfo_file *kif,
+    struct filedesc *fdp)
+{
+
+       return (0);
+}
+
+struct fileops linuxfileops = {
+       .fo_read = linux_file_read,
+       .fo_write = invfo_rdwr,
+       .fo_truncate = invfo_truncate,
+       .fo_kqfilter = invfo_kqfilter,
+       .fo_stat = linux_file_stat,
+       .fo_fill_kinfo = linux_file_fill_kinfo,
+       .fo_poll = linux_file_poll,
+       .fo_close = linux_file_close,
+       .fo_ioctl = linux_file_ioctl,
+       .fo_chmod = invfo_chmod,
+       .fo_chown = invfo_chown,
+       .fo_sendfile = invfo_sendfile,
+};
+
+/*
+ * Hash of vmmap addresses.  This is infrequently accessed and does not
+ * need to be particularly large.  This is done because we must store the
+ * caller's idea of the map size to properly unmap.
+ */
+struct vmmap {
+       LIST_ENTRY(vmmap)       vm_next;
+       void                    *vm_addr;
+       unsigned long           vm_size;
+};
+
+struct vmmaphd {
+       struct vmmap *lh_first;
+};
+#define        VMMAP_HASH_SIZE 64
+#define        VMMAP_HASH_MASK (VMMAP_HASH_SIZE - 1)
+#define        VM_HASH(addr)   ((uintptr_t)(addr) >> PAGE_SHIFT) & VMMAP_HASH_MASK
+static struct vmmaphd vmmaphead[VMMAP_HASH_SIZE];
+static struct mtx vmmaplock;
+
+static void
+vmmap_add(void *addr, unsigned long size)
+{
+       struct vmmap *vmmap;
+
+       vmmap = kmalloc(sizeof(*vmmap), GFP_KERNEL);
+       mtx_lock(&vmmaplock);
+       vmmap->vm_size = size;
+       vmmap->vm_addr = addr;
+       LIST_INSERT_HEAD(&vmmaphead[VM_HASH(addr)], vmmap, vm_next);
+       mtx_unlock(&vmmaplock);
+}
+
+static struct vmmap *
+vmmap_remove(void *addr)
+{
+       struct vmmap *vmmap;
+
+       mtx_lock(&vmmaplock);
+       LIST_FOREACH(vmmap, &vmmaphead[VM_HASH(addr)], vm_next)
+               if (vmmap->vm_addr == addr)
+                       break;
+       if (vmmap)
+               LIST_REMOVE(vmmap, vm_next);
+       mtx_unlock(&vmmaplock);
+
+       return (vmmap);
+}
+
+void *
+_ioremap_attr(vm_paddr_t phys_addr, unsigned long size, int attr)
+{
+       void *addr;
+
+#if defined(__i386__) || defined(__amd64__)
+       addr = pmap_mapdev_attr(phys_addr, size, attr);
+#else
+       addr = NULL;
+#endif
+       if (addr == NULL)
+               return (NULL);
+       vmmap_add(addr, size);
+
+       return (addr);
+}
+
+void
+iounmap(void *addr)
+{
+       struct vmmap *vmmap;
+
+       vmmap = vmmap_remove(addr);
+       if (vmmap == NULL)
+               return;
+#if defined(__i386__) || defined(__amd64__)
+       pmap_unmapdev((vm_offset_t)addr, vmmap->vm_size);
+#endif
+       kfree(vmmap);
+}
+
+
+void *
+vmap(struct page **pages, unsigned int count, unsigned long flags, int prot)
+{
+       vm_offset_t off;
+       size_t size;
+
+       size = count * PAGE_SIZE;
+       off = kva_alloc(size);
+       if (off == 0)
+               return (NULL);
+       vmmap_add((void *)off, size);
+       pmap_qenter(off, pages, count);
+
+       return ((void *)off);
+}
+
+void
+vunmap(void *addr)
+{
+       struct vmmap *vmmap;
+
+       vmmap = vmmap_remove(addr);
+       if (vmmap == NULL)
+               return;
+       pmap_qremove((vm_offset_t)addr, vmmap->vm_size / PAGE_SIZE);
+       kva_free((vm_offset_t)addr, vmmap->vm_size);
+       kfree(vmmap);
+}
+
+char *
+kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
+{
+       unsigned int len;
+       char *p;
+       va_list aq;
+
+       va_copy(aq, ap);
+       len = vsnprintf(NULL, 0, fmt, aq);
+       va_end(aq);
+
+       p = kmalloc(len + 1, gfp);
+       if (p != NULL)
+               vsnprintf(p, len + 1, fmt, ap);
+
+       return (p);
+}
+
+char *
+kasprintf(gfp_t gfp, const char *fmt, ...)
+{
+       va_list ap;
+       char *p;
+
+       va_start(ap, fmt);
+       p = kvasprintf(gfp, fmt, ap);
+       va_end(ap);
+
+       return (p);
+}
+
+static int
+linux_timer_jiffies_until(unsigned long expires)
+{
+       int delta = expires - jiffies;
+       /* guard against already expired values */
+       if (delta < 1)
+               delta = 1;
+       return (delta);
+}
+
+static void
+linux_timer_callback_wrapper(void *context)
+{
+       struct timer_list *timer;
+
+       timer = context;
+       timer->function(timer->data);
+}
+
+void
+mod_timer(struct timer_list *timer, unsigned long expires)
+{
+
+       timer->expires = expires;
+       callout_reset(&timer->timer_callout,                  
+           linux_timer_jiffies_until(expires),
+           &linux_timer_callback_wrapper, timer);
+}
+
+void
+add_timer(struct timer_list *timer)
+{
+
+       callout_reset(&timer->timer_callout,
+           linux_timer_jiffies_until(timer->expires),
+           &linux_timer_callback_wrapper, timer);
+}
+
+static void
+linux_timer_init(void *arg)
+{
+
+       /*
+        * Compute an internal HZ value which can divide 2**32 to
+        * avoid timer rounding problems when the tick value wraps
+        * around 2**32:
+        */
+       linux_timer_hz_mask = 1;
+       while (linux_timer_hz_mask < (unsigned long)hz)
+               linux_timer_hz_mask *= 2;
+       linux_timer_hz_mask--;
+}
+SYSINIT(linux_timer, SI_SUB_DRIVERS, SI_ORDER_FIRST, linux_timer_init, NULL);
+
+void
+linux_complete_common(struct completion *c, int all)
+{
+       int wakeup_swapper;
+
+       sleepq_lock(c);
+       c->done++;
+       if (all)
+               wakeup_swapper = sleepq_broadcast(c, SLEEPQ_SLEEP, 0, 0);
+       else
+               wakeup_swapper = sleepq_signal(c, SLEEPQ_SLEEP, 0, 0);
+       sleepq_release(c);
+       if (wakeup_swapper)
+               kick_proc0();
+}
+
+/*
+ * Indefinite wait for done != 0 with or without signals.
+ */
+long
+linux_wait_for_common(struct completion *c, int flags)
+{
+
+       if (flags != 0)
+               flags = SLEEPQ_INTERRUPTIBLE | SLEEPQ_SLEEP;
+       else
+               flags = SLEEPQ_SLEEP;
+       for (;;) {
+               sleepq_lock(c);
+               if (c->done)
+                       break;
+               sleepq_add(c, NULL, "completion", flags, 0);
+               if (flags & SLEEPQ_INTERRUPTIBLE) {
+                       if (sleepq_wait_sig(c, 0) != 0)
+                               return (-ERESTARTSYS);
+               } else
+                       sleepq_wait(c, 0);
+       }
+       c->done--;
+       sleepq_release(c);
+
+       return (0);
+}
+
+/*
+ * Time limited wait for done != 0 with or without signals.
+ */
+long
+linux_wait_for_timeout_common(struct completion *c, long timeout, int flags)
+{
+       long end = jiffies + timeout;
+
+       if (flags != 0)
+               flags = SLEEPQ_INTERRUPTIBLE | SLEEPQ_SLEEP;
+       else
+               flags = SLEEPQ_SLEEP;
+       for (;;) {
+               int ret;
+
+               sleepq_lock(c);
+               if (c->done)
+                       break;
+               sleepq_add(c, NULL, "completion", flags, 0);
+               sleepq_set_timeout(c, linux_timer_jiffies_until(end));
+               if (flags & SLEEPQ_INTERRUPTIBLE)
+                       ret = sleepq_timedwait_sig(c, 0);
+               else
+                       ret = sleepq_timedwait(c, 0);
+               if (ret != 0) {
+                       /* check for timeout or signal */
+                       if (ret == EWOULDBLOCK)
+                               return (0);
+                       else
+                               return (-ERESTARTSYS);
+               }
+       }
+       c->done--;
+       sleepq_release(c);
+
+       /* return how many jiffies are left */
+       return (linux_timer_jiffies_until(end));
+}
+
+int
+linux_try_wait_for_completion(struct completion *c)
+{
+       int isdone;
+
+       isdone = 1;
+       sleepq_lock(c);
+       if (c->done)
+               c->done--;
+       else
+               isdone = 0;
+       sleepq_release(c);
+       return (isdone);
+}
+
+int
+linux_completion_done(struct completion *c)
+{
+       int isdone;
+
+       isdone = 1;
+       sleepq_lock(c);
+       if (c->done == 0)
+               isdone = 0;
+       sleepq_release(c);
+       return (isdone);
+}
+
+static void
+linux_compat_init(void *arg)
+{
+       struct sysctl_oid *rootoid;
+       int i;
+
+       rootoid = SYSCTL_ADD_ROOT_NODE(NULL,
+           OID_AUTO, "sys", CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, "sys");
+       kobject_init(&class_root, &class_ktype);
+       kobject_set_name(&class_root, "class");
+       class_root.oidp = SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(rootoid),
+           OID_AUTO, "class", CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, "class");
+       kobject_init(&linux_rootdev.kobj, &dev_ktype);
+       kobject_set_name(&linux_rootdev.kobj, "device");
+       linux_rootdev.kobj.oidp = SYSCTL_ADD_NODE(NULL,
+           SYSCTL_CHILDREN(rootoid), OID_AUTO, "device", CTLFLAG_RD, NULL,
+           "device");
+       linux_rootdev.bsddev = root_bus;
+       miscclass.name = "misc";
+       class_register(&miscclass);
+       INIT_LIST_HEAD(&pci_drivers);
+       INIT_LIST_HEAD(&pci_devices);
+       spin_lock_init(&pci_lock);
+       mtx_init(&vmmaplock, "IO Map lock", NULL, MTX_DEF);
+       for (i = 0; i < VMMAP_HASH_SIZE; i++)
+               LIST_INIT(&vmmaphead[i]);
+}
+SYSINIT(linux_compat, SI_SUB_DRIVERS, SI_ORDER_SECOND, linux_compat_init, NULL);
+
+static void
+linux_compat_uninit(void *arg)
+{
+       kobject_kfree_name(&class_root);
+       kobject_kfree_name(&linux_rootdev.kobj);
+       kobject_kfree_name(&miscclass.kobj);
+}
+SYSUNINIT(linux_compat, SI_SUB_DRIVERS, SI_ORDER_SECOND, linux_compat_uninit, NULL);
diff --git a/sys/compat/linuxkpi/common/src/linux_idr.c b/sys/compat/linuxkpi/common/src/linux_idr.c
new file mode 100644 (file)
index 0000000..fa98622
--- /dev/null
@@ -0,0 +1,462 @@
+/*-
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <sys/sysctl.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+
+#include <machine/stdarg.h>
+
+#include <linux/bitops.h>
+#include <linux/kobject.h>
+#include <linux/slab.h>
+#include <linux/idr.h>
+#include <linux/err.h>
+
+/*
+ * IDR Implementation.
+ *
+ * This is quick and dirty and not as re-entrant as the linux version
+ * however it should be fairly fast.  It is basically a radix tree with
+ * a builtin bitmap for allocation.
+ */
+static MALLOC_DEFINE(M_IDR, "idr", "Linux IDR compat");
+
+static inline int
+idr_max(struct idr *idr)
+{
+       return (1 << (idr->layers * IDR_BITS)) - 1;
+}
+
+static inline int
+idr_pos(int id, int layer)
+{
+       return (id >> (IDR_BITS * layer)) & IDR_MASK;
+}
+
+void
+idr_init(struct idr *idr)
+{
+       bzero(idr, sizeof(*idr));
+       mtx_init(&idr->lock, "idr", NULL, MTX_DEF);
+}
+
+/* Only frees cached pages. */
+void
+idr_destroy(struct idr *idr)
+{
+       struct idr_layer *il, *iln;
+
+       idr_remove_all(idr);
+       mtx_lock(&idr->lock);
+       for (il = idr->free; il != NULL; il = iln) {
+               iln = il->ary[0];
+               free(il, M_IDR);
+       }
+       mtx_unlock(&idr->lock);
+}
+
+static void
+idr_remove_layer(struct idr_layer *il, int layer)
+{
+       int i;
+
+       if (il == NULL)
+               return;
+       if (layer == 0) {
+               free(il, M_IDR);
+               return;
+       }
+       for (i = 0; i < IDR_SIZE; i++)
+               if (il->ary[i])
+                       idr_remove_layer(il->ary[i], layer - 1);
+}
+
+void
+idr_remove_all(struct idr *idr)
+{
+
+       mtx_lock(&idr->lock);
+       idr_remove_layer(idr->top, idr->layers - 1);
+       idr->top = NULL;
+       idr->layers = 0;
+       mtx_unlock(&idr->lock);
+}
+
+void
+idr_remove(struct idr *idr, int id)
+{
+       struct idr_layer *il;
+       int layer;
+       int idx;
+
+       id &= MAX_ID_MASK;
+       mtx_lock(&idr->lock);
+       il = idr->top;
+       layer = idr->layers - 1;
+       if (il == NULL || id > idr_max(idr)) {
+               mtx_unlock(&idr->lock);
+               return;
+       }
+       /*
+        * Walk down the tree to this item setting bitmaps along the way
+        * as we know at least one item will be free along this path.
+        */
+       while (layer && il) {
+               idx = idr_pos(id, layer);
+               il->bitmap |= 1 << idx;
+               il = il->ary[idx];
+               layer--;
+       }
+       idx = id & IDR_MASK;
+       /*
+        * At this point we've set free space bitmaps up the whole tree.
+        * We could make this non-fatal and unwind but linux dumps a stack
+        * and a warning so I don't think it's necessary.
+        */
+       if (il == NULL || (il->bitmap & (1 << idx)) != 0)
+               panic("idr_remove: Item %d not allocated (%p, %p)\n",
+                   id, idr, il);
+       il->ary[idx] = NULL;
+       il->bitmap |= 1 << idx;
+       mtx_unlock(&idr->lock);
+       return;
+}
+
+void *
+idr_replace(struct idr *idr, void *ptr, int id)
+{
+       struct idr_layer *il;
+       void *res;
+       int layer;
+       int idx;
+
+       res = ERR_PTR(-EINVAL);
+       id &= MAX_ID_MASK;
+       mtx_lock(&idr->lock);
+       il = idr->top;
+       layer = idr->layers - 1;
+       if (il == NULL || id > idr_max(idr))
+               goto out;
+       while (layer && il) {
+               il = il->ary[idr_pos(id, layer)];
+               layer--;
+       }
+       idx = id & IDR_MASK;
+       /*
+        * Replace still returns an error if the item was not allocated.
+        */
+       if (il != NULL && (il->bitmap & (1 << idx)) != 0) {
+               res = il->ary[idx];
+               il->ary[idx] = ptr;
+       }
+out:
+       mtx_unlock(&idr->lock);
+       return (res);
+}
+
+static inline void *
+idr_find_locked(struct idr *idr, int id)
+{
+       struct idr_layer *il;
+       void *res;
+       int layer;
+
+       mtx_assert(&idr->lock, MA_OWNED);
+
+       id &= MAX_ID_MASK;
+       res = NULL;
+       il = idr->top;
+       layer = idr->layers - 1;
+       if (il == NULL || id > idr_max(idr))
+               return (NULL);
+       while (layer && il) {
+               il = il->ary[idr_pos(id, layer)];
+               layer--;
+       }
+       if (il != NULL)
+               res = il->ary[id & IDR_MASK];
+       return (res);
+}
+
+void *
+idr_find(struct idr *idr, int id)
+{
+       void *res;
+
+       mtx_lock(&idr->lock);
+       res = idr_find_locked(idr, id);
+       mtx_unlock(&idr->lock);
+       return (res);
+}
+
+int
+idr_pre_get(struct idr *idr, gfp_t gfp_mask)
+{
+       struct idr_layer *il, *iln;
+       struct idr_layer *head;
+       int need;
+
+       mtx_lock(&idr->lock);
+       for (;;) {
+               need = idr->layers + 1;
+               for (il = idr->free; il != NULL; il = il->ary[0])
+                       need--;
+               mtx_unlock(&idr->lock);
+               if (need <= 0)
+                       break;
+               for (head = NULL; need; need--) {
+                       iln = malloc(sizeof(*il), M_IDR, M_ZERO | gfp_mask);
+                       if (iln == NULL)
+                               break;
+                       bitmap_fill(&iln->bitmap, IDR_SIZE);
+                       if (head != NULL) {
+                               il->ary[0] = iln;
+                               il = iln;
+                       } else
+                               head = il = iln;
+               }
+               if (head == NULL)
+                       return (0);
+               mtx_lock(&idr->lock);
+               il->ary[0] = idr->free;
+               idr->free = head;
+       }
+       return (1);
+}
+
+static inline struct idr_layer *
+idr_get(struct idr *idr)
+{
+       struct idr_layer *il;
+
+       il = idr->free;
+       if (il) {
+               idr->free = il->ary[0];
+               il->ary[0] = NULL;
+               return (il);
+       }
+       il = malloc(sizeof(*il), M_IDR, M_ZERO | M_NOWAIT);
+       bitmap_fill(&il->bitmap, IDR_SIZE);
+       return (il);
+}
+
+/*
+ * Could be implemented as get_new_above(idr, ptr, 0, idp) but written
+ * first for simplicity sake.
+ */
+int
+idr_get_new(struct idr *idr, void *ptr, int *idp)
+{
+       struct idr_layer *stack[MAX_LEVEL];
+       struct idr_layer *il;
+       int error;
+       int layer;
+       int idx;
+       int id;
+
+       error = -EAGAIN;
+       mtx_lock(&idr->lock);
+       /*
+        * Expand the tree until there is free space.
+        */
+       if (idr->top == NULL || idr->top->bitmap == 0) {
+               if (idr->layers == MAX_LEVEL + 1) {
+                       error = -ENOSPC;
+                       goto out;
+               }
+               il = idr_get(idr);
+               if (il == NULL)
+                       goto out;
+               il->ary[0] = idr->top;
+               if (idr->top)
+                       il->bitmap &= ~1;
+               idr->top = il;
+               idr->layers++;
+       }
+       il = idr->top;
+       id = 0;
+       /*
+        * Walk the tree following free bitmaps, record our path.
+        */
+       for (layer = idr->layers - 1;; layer--) {
+               stack[layer] = il;
+               idx = ffsl(il->bitmap);
+               if (idx == 0)
+                       panic("idr_get_new: Invalid leaf state (%p, %p)\n",
+                           idr, il);
+               idx--;
+               id |= idx << (layer * IDR_BITS);
+               if (layer == 0)
+                       break;
+               if (il->ary[idx] == NULL) {
+                       il->ary[idx] = idr_get(idr);
+                       if (il->ary[idx] == NULL)
+                               goto out;
+               }
+               il = il->ary[idx];
+       }
+       /*
+        * Allocate the leaf to the consumer.
+        */
+       il->bitmap &= ~(1 << idx);
+       il->ary[idx] = ptr;
+       *idp = id;
+       /*
+        * Clear bitmaps potentially up to the root.
+        */
+       while (il->bitmap == 0 && ++layer < idr->layers) {
+               il = stack[layer];
+               il->bitmap &= ~(1 << idr_pos(id, layer));
+       }
+       error = 0;
+out:
+#ifdef INVARIANTS
+       if (error == 0 && idr_find_locked(idr, id) != ptr) {
+               panic("idr_get_new: Failed for idr %p, id %d, ptr %p\n",
+                   idr, id, ptr);
+       }
+#endif
+       mtx_unlock(&idr->lock);
+       return (error);
+}
+
+int
+idr_get_new_above(struct idr *idr, void *ptr, int starting_id, int *idp)
+{
+       struct idr_layer *stack[MAX_LEVEL];
+       struct idr_layer *il;
+       int error;
+       int layer;
+       int idx, sidx;
+       int id;
+
+       error = -EAGAIN;
+       mtx_lock(&idr->lock);
+       /*
+        * Compute the layers required to support starting_id and the mask
+        * at the top layer.
+        */
+restart:
+       idx = starting_id;
+       layer = 0;
+       while (idx & ~IDR_MASK) {
+               layer++;
+               idx >>= IDR_BITS;
+       }
+       if (layer == MAX_LEVEL + 1) {
+               error = -ENOSPC;
+               goto out;
+       }
+       /*
+        * Expand the tree until there is free space at or beyond starting_id.
+        */
+       while (idr->layers <= layer ||
+           idr->top->bitmap < (1 << idr_pos(starting_id, idr->layers - 1))) {
+               if (idr->layers == MAX_LEVEL + 1) {
+                       error = -ENOSPC;
+                       goto out;
+               }
+               il = idr_get(idr);
+               if (il == NULL)
+                       goto out;
+               il->ary[0] = idr->top;
+               if (idr->top && idr->top->bitmap == 0)
+                       il->bitmap &= ~1;
+               idr->top = il;
+               idr->layers++;
+       }
+       il = idr->top;
+       id = 0;
+       /*
+        * Walk the tree following free bitmaps, record our path.
+        */
+       for (layer = idr->layers - 1;; layer--) {
+               stack[layer] = il;
+               sidx = idr_pos(starting_id, layer);
+               /* Returns index numbered from 0 or size if none exists. */
+               idx = find_next_bit(&il->bitmap, IDR_SIZE, sidx);
+               if (idx == IDR_SIZE && sidx == 0)
+                       panic("idr_get_new: Invalid leaf state (%p, %p)\n",
+                           idr, il);
+               /*
+                * We may have walked a path where there was a free bit but
+                * it was lower than what we wanted.  Restart the search with
+                * a larger starting id.  id contains the progress we made so
+                * far.  Search the leaf one above this level.  This may
+                * restart as many as MAX_LEVEL times but that is expected
+                * to be rare.
+                */
+               if (idx == IDR_SIZE) {
+                       starting_id = id + (1 << ((layer + 1) * IDR_BITS));
+                       goto restart;
+               }
+               if (idx > sidx)
+                       starting_id = 0;        /* Search the whole subtree. */
+               id |= idx << (layer * IDR_BITS);
+               if (layer == 0)
+                       break;
+               if (il->ary[idx] == NULL) {
+                       il->ary[idx] = idr_get(idr);
+                       if (il->ary[idx] == NULL)
+                               goto out;
+               }
+               il = il->ary[idx];
+       }
+       /*
+        * Allocate the leaf to the consumer.
+        */
+       il->bitmap &= ~(1 << idx);
+       il->ary[idx] = ptr;
+       *idp = id;
+       /*
+        * Clear bitmaps potentially up to the root.
+        */
+       while (il->bitmap == 0 && ++layer < idr->layers) {
+               il = stack[layer];
+               il->bitmap &= ~(1 << idr_pos(id, layer));
+       }
+       error = 0;
+out:
+#ifdef INVARIANTS
+       if (error == 0 && idr_find_locked(idr, id) != ptr) {
+               panic("idr_get_new_above: Failed for idr %p, id %d, ptr %p\n",
+                   idr, id, ptr);
+       }
+#endif
+       mtx_unlock(&idr->lock);
+       return (error);
+}
diff --git a/sys/compat/linuxkpi/common/src/linux_kmod.c b/sys/compat/linuxkpi/common/src/linux_kmod.c
new file mode 100644 (file)
index 0000000..efe16fb
--- /dev/null
@@ -0,0 +1,35 @@
+/*-
+ * Copyright (c) 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/module.h>
+
+MODULE_VERSION(linuxkpi, 1);
+MODULE_DEPEND(linuxkpi, pci, 1, 1, 1);
+
diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c
new file mode 100644 (file)
index 0000000..2d3d03b
--- /dev/null
@@ -0,0 +1,208 @@
+/*-
+ * Copyright (c) 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <sys/sysctl.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/bus.h>
+#include <sys/fcntl.h>
+#include <sys/file.h>
+#include <sys/filio.h>
+#include <sys/rwlock.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <machine/stdarg.h>
+#include <machine/pmap.h>
+
+#include <linux/kobject.h>
+#include <linux/device.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/cdev.h>
+#include <linux/file.h>
+#include <linux/sysfs.h>
+#include <linux/mm.h>
+#include <linux/io.h>
+#include <linux/vmalloc.h>
+#include <linux/pci.h>
+
+static device_probe_t linux_pci_probe;
+static device_attach_t linux_pci_attach;
+static device_detach_t linux_pci_detach;
+
+static device_method_t pci_methods[] = {
+       DEVMETHOD(device_probe, linux_pci_probe),
+       DEVMETHOD(device_attach, linux_pci_attach),
+       DEVMETHOD(device_detach, linux_pci_detach),
+       DEVMETHOD_END
+};
+
+static struct pci_driver *
+linux_pci_find(device_t dev, const struct pci_device_id **idp)
+{
+       const struct pci_device_id *id;
+       struct pci_driver *pdrv;
+       uint16_t vendor;
+       uint16_t device;
+
+       vendor = pci_get_vendor(dev);
+       device = pci_get_device(dev);
+
+       spin_lock(&pci_lock);
+       list_for_each_entry(pdrv, &pci_drivers, links) {
+               for (id = pdrv->id_table; id->vendor != 0; id++) {
+                       if (vendor == id->vendor && device == id->device) {
+                               *idp = id;
+                               spin_unlock(&pci_lock);
+                               return (pdrv);
+                       }
+               }
+       }
+       spin_unlock(&pci_lock);
+       return (NULL);
+}
+
+static int
+linux_pci_probe(device_t dev)
+{
+       const struct pci_device_id *id;
+       struct pci_driver *pdrv;
+
+       if ((pdrv = linux_pci_find(dev, &id)) == NULL)
+               return (ENXIO);
+       if (device_get_driver(dev) != &pdrv->driver)
+               return (ENXIO);
+       device_set_desc(dev, pdrv->name);
+       return (0);
+}
+
+static int
+linux_pci_attach(device_t dev)
+{
+       struct resource_list_entry *rle;
+       struct pci_dev *pdev;
+       struct pci_driver *pdrv;
+       const struct pci_device_id *id;
+       int error;
+
+       pdrv = linux_pci_find(dev, &id);
+       pdev = device_get_softc(dev);
+       pdev->dev.parent = &linux_rootdev;
+       pdev->dev.bsddev = dev;
+       INIT_LIST_HEAD(&pdev->dev.irqents);
+       pdev->device = id->device;
+       pdev->vendor = id->vendor;
+       pdev->dev.dma_mask = &pdev->dma_mask;
+       pdev->pdrv = pdrv;
+       kobject_init(&pdev->dev.kobj, &dev_ktype);
+       kobject_set_name(&pdev->dev.kobj, device_get_nameunit(dev));
+       kobject_add(&pdev->dev.kobj, &linux_rootdev.kobj,
+           kobject_name(&pdev->dev.kobj));
+       rle = _pci_get_rle(pdev, SYS_RES_IRQ, 0);
+       if (rle)
+               pdev->dev.irq = rle->start;
+       else
+               pdev->dev.irq = 0;
+       pdev->irq = pdev->dev.irq;
+       mtx_unlock(&Giant);
+       spin_lock(&pci_lock);
+       list_add(&pdev->links, &pci_devices);
+       spin_unlock(&pci_lock);
+       error = pdrv->probe(pdev, id);
+       mtx_lock(&Giant);
+       if (error) {
+               spin_lock(&pci_lock);
+               list_del(&pdev->links);
+               spin_unlock(&pci_lock);
+               put_device(&pdev->dev);
+               return (-error);
+       }
+       return (0);
+}
+
+static int
+linux_pci_detach(device_t dev)
+{
+       struct pci_dev *pdev;
+
+       pdev = device_get_softc(dev);
+       mtx_unlock(&Giant);
+       pdev->pdrv->remove(pdev);
+       mtx_lock(&Giant);
+       spin_lock(&pci_lock);
+       list_del(&pdev->links);
+       spin_unlock(&pci_lock);
+       put_device(&pdev->dev);
+
+       return (0);
+}
+
+int
+pci_register_driver(struct pci_driver *pdrv)
+{
+       devclass_t bus;
+       int error = 0;
+
+       bus = devclass_find("pci");
+
+       spin_lock(&pci_lock);
+       list_add(&pdrv->links, &pci_drivers);
+       spin_unlock(&pci_lock);
+       pdrv->driver.name = pdrv->name;
+       pdrv->driver.methods = pci_methods;
+       pdrv->driver.size = sizeof(struct pci_dev);
+       mtx_lock(&Giant);
+       if (bus != NULL) {
+               error = devclass_add_driver(bus, &pdrv->driver, BUS_PASS_DEFAULT,
+                   &pdrv->bsdclass);
+       }
+       mtx_unlock(&Giant);
+       return (-error);
+}
+
+void
+pci_unregister_driver(struct pci_driver *pdrv)
+{
+       devclass_t bus;
+
+       bus = devclass_find("pci");
+
+       list_del(&pdrv->links);
+       mtx_lock(&Giant);
+       if (bus != NULL)
+               devclass_delete_driver(bus, &pdrv->driver);
+       mtx_unlock(&Giant);
+}
+
diff --git a/sys/compat/linuxkpi/common/src/linux_radix.c b/sys/compat/linuxkpi/common/src/linux_radix.c
new file mode 100644 (file)
index 0000000..1cd9e45
--- /dev/null
@@ -0,0 +1,218 @@
+/*-
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <sys/sysctl.h>
+
+#include <linux/slab.h>
+#include <linux/kernel.h>
+#include <linux/radix-tree.h>
+#include <linux/err.h>
+
+static MALLOC_DEFINE(M_RADIX, "radix", "Linux radix compat");
+
+static inline int
+radix_max(struct radix_tree_root *root)
+{
+       return (1 << (root->height * RADIX_TREE_MAP_SHIFT)) - 1;
+}
+
+static inline int
+radix_pos(long id, int height)
+{
+       return (id >> (RADIX_TREE_MAP_SHIFT * height)) & RADIX_TREE_MAP_MASK;
+}
+
+void *
+radix_tree_lookup(struct radix_tree_root *root, unsigned long index)
+{
+       struct radix_tree_node *node;
+       void *item;
+       int height;
+
+       item = NULL;
+       node = root->rnode;
+       height = root->height - 1;
+       if (index > radix_max(root))
+               goto out;
+       while (height && node)
+               node = node->slots[radix_pos(index, height--)];
+       if (node)
+               item = node->slots[radix_pos(index, 0)];
+
+out:
+       return (item);
+}
+
+void *
+radix_tree_delete(struct radix_tree_root *root, unsigned long index)
+{
+       struct radix_tree_node *stack[RADIX_TREE_MAX_HEIGHT];
+       struct radix_tree_node *node;
+       void *item;
+       int height;
+       int idx;
+
+       item = NULL;
+       node = root->rnode;
+       height = root->height - 1;
+       if (index > radix_max(root))
+               goto out;
+       /*
+        * Find the node and record the path in stack.
+        */
+       while (height && node) {
+               stack[height] = node;
+               node = node->slots[radix_pos(index, height--)];
+       }
+       idx = radix_pos(index, 0);
+       if (node)
+               item = node->slots[idx];
+       /*
+        * If we removed something reduce the height of the tree.
+        */
+       if (item)
+               for (;;) {
+                       node->slots[idx] = NULL;
+                       node->count--;
+                       if (node->count > 0)
+                               break;
+                       free(node, M_RADIX);
+                       if (node == root->rnode) {
+                               root->rnode = NULL;
+                               root->height = 0;
+                               break;
+                       }
+                       height++;
+                       node = stack[height];
+                       idx = radix_pos(index, height);
+               }
+out:
+       return (item);
+}
+
+int
+radix_tree_insert(struct radix_tree_root *root, unsigned long index, void *item)
+{
+       struct radix_tree_node *node;
+       struct radix_tree_node *temp[RADIX_TREE_MAX_HEIGHT - 1];
+       int height;
+       int idx;
+
+       /* bail out upon insertion of a NULL item */
+       if (item == NULL)
+               return (-EINVAL);
+
+       /* get root node, if any */
+       node = root->rnode;
+
+       /* allocate root node, if any */
+       if (node == NULL) {
+               node = malloc(sizeof(*node), M_RADIX, root->gfp_mask | M_ZERO);
+               if (node == NULL)
+                       return (-ENOMEM);
+               root->rnode = node;
+               root->height++;
+       }
+
+       /* expand radix tree as needed */
+       while (radix_max(root) < index) {
+
+               /* check if the radix tree is getting too big */
+               if (root->height == RADIX_TREE_MAX_HEIGHT)
+                       return (-E2BIG);
+
+               /*
+                * If the root radix level is not empty, we need to
+                * allocate a new radix level:
+                */
+               if (node->count != 0) {
+                       node = malloc(sizeof(*node), M_RADIX, root->gfp_mask | M_ZERO);
+                       if (node == NULL)
+                               return (-ENOMEM);
+                       node->slots[0] = root->rnode;
+                       node->count++;
+                       root->rnode = node;
+               }
+               root->height++;
+       }
+
+       /* get radix tree height index */
+       height = root->height - 1;
+
+       /* walk down the tree until the first missing node, if any */
+       for ( ; height != 0; height--) {
+               idx = radix_pos(index, height);
+               if (node->slots[idx] == NULL)
+                       break;
+               node = node->slots[idx];
+       }
+
+       /* allocate the missing radix levels, if any */
+       for (idx = 0; idx != height; idx++) {
+               temp[idx] = malloc(sizeof(*node), M_RADIX,
+                   root->gfp_mask | M_ZERO);
+               if (temp[idx] == NULL) {
+                       while(idx--)
+                               free(temp[idx], M_RADIX);
+                       /* check if we should free the root node aswell */
+                       if (root->rnode->count == 0) {
+                               free(root->rnode, M_RADIX);
+                               root->rnode = NULL;
+                               root->height = 0;
+                       }
+                       return (-ENOMEM);
+               }
+       }
+
+       /* setup new radix levels, if any */
+       for ( ; height != 0; height--) {
+               idx = radix_pos(index, height);
+               node->slots[idx] = temp[height - 1];
+               node->count++;
+               node = node->slots[idx];
+       }
+
+       /*
+        * Insert and adjust count if the item does not already exist.
+        */
+       idx = radix_pos(index, 0);
+       if (node->slots[idx])
+               return (-EEXIST);
+       node->slots[idx] = item;
+       node->count++;
+       
+       return (0);
+}
diff --git a/sys/compat/linuxkpi/common/src/linux_usb.c b/sys/compat/linuxkpi/common/src/linux_usb.c
new file mode 100644 (file)
index 0000000..b7ef538
--- /dev/null
@@ -0,0 +1,1746 @@
+/* $FreeBSD$ */
+/*-
+ * Copyright (c) 2007 Luigi Rizzo - Universita` di Pisa. All rights reserved.
+ * Copyright (c) 2007 Hans Petter Selasky. 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, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+ */
+
+#ifdef USB_GLOBAL_INCLUDE_FILE
+#include USB_GLOBAL_INCLUDE_FILE
+#else
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+
+#define        USB_DEBUG_VAR usb_debug
+
+#include <dev/usb/usb_core.h>
+#include <linux/usb.h>
+#include <dev/usb/usb_process.h>
+#include <dev/usb/usb_device.h>
+#include <dev/usb/usb_util.h>
+#include <dev/usb/usb_busdma.h>
+#include <dev/usb/usb_transfer.h>
+#include <dev/usb/usb_hub.h>
+#include <dev/usb/usb_request.h>
+#include <dev/usb/usb_debug.h>
+#include <dev/usb/usb_dynamic.h>
+#endif                 /* USB_GLOBAL_INCLUDE_FILE */
+
+struct usb_linux_softc {
+       LIST_ENTRY(usb_linux_softc) sc_attached_list;
+
+       device_t sc_fbsd_dev;
+       struct usb_device *sc_fbsd_udev;
+       struct usb_interface *sc_ui;
+       struct usb_driver *sc_udrv;
+};
+
+/* prototypes */
+static device_probe_t usb_linux_probe;
+static device_attach_t usb_linux_attach;
+static device_detach_t usb_linux_detach;
+static device_suspend_t usb_linux_suspend;
+static device_resume_t usb_linux_resume;
+
+static usb_callback_t usb_linux_isoc_callback;
+static usb_callback_t usb_linux_non_isoc_callback;
+
+static usb_complete_t usb_linux_wait_complete;
+
+static uint16_t        usb_max_isoc_frames(struct usb_device *);
+static int     usb_start_wait_urb(struct urb *, usb_timeout_t, uint16_t *);
+static const struct usb_device_id *usb_linux_lookup_id(
+                   const struct usb_device_id *, struct usb_attach_arg *);
+static struct  usb_driver *usb_linux_get_usb_driver(struct usb_linux_softc *);
+static int     usb_linux_create_usb_device(struct usb_device *, device_t);
+static void    usb_linux_cleanup_interface(struct usb_device *,
+                   struct usb_interface *);
+static void    usb_linux_complete(struct usb_xfer *);
+static int     usb_unlink_urb_sub(struct urb *, uint8_t);
+
+/*------------------------------------------------------------------------*
+ * FreeBSD USB interface
+ *------------------------------------------------------------------------*/
+
+static LIST_HEAD(, usb_linux_softc) usb_linux_attached_list;
+static LIST_HEAD(, usb_driver) usb_linux_driver_list;
+
+static device_method_t usb_linux_methods[] = {
+       /* Device interface */
+       DEVMETHOD(device_probe, usb_linux_probe),
+       DEVMETHOD(device_attach, usb_linux_attach),
+       DEVMETHOD(device_detach, usb_linux_detach),
+       DEVMETHOD(device_suspend, usb_linux_suspend),
+       DEVMETHOD(device_resume, usb_linux_resume),
+
+       DEVMETHOD_END
+};
+
+static driver_t usb_linux_driver = {
+       .name = "usb_linux",
+       .methods = usb_linux_methods,
+       .size = sizeof(struct usb_linux_softc),
+};
+
+static devclass_t usb_linux_devclass;
+
+DRIVER_MODULE(usb_linux, uhub, usb_linux_driver, usb_linux_devclass, NULL, 0);
+MODULE_VERSION(usb_linux, 1);
+
+/*------------------------------------------------------------------------*
+ *     usb_linux_lookup_id
+ *
+ * This functions takes an array of "struct usb_device_id" and tries
+ * to match the entries with the information in "struct usb_attach_arg".
+ * If it finds a match the matching entry will be returned.
+ * Else "NULL" will be returned.
+ *------------------------------------------------------------------------*/
+static const struct usb_device_id *
+usb_linux_lookup_id(const struct usb_device_id *id, struct usb_attach_arg *uaa)
+{
+       if (id == NULL) {
+               goto done;
+       }
+       /*
+        * Keep on matching array entries until we find one with
+        * "match_flags" equal to zero, which indicates the end of the
+        * array:
+        */
+       for (; id->match_flags; id++) {
+
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
+                   (id->idVendor != uaa->info.idVendor)) {
+                       continue;
+               }
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
+                   (id->idProduct != uaa->info.idProduct)) {
+                       continue;
+               }
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
+                   (id->bcdDevice_lo > uaa->info.bcdDevice)) {
+                       continue;
+               }
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
+                   (id->bcdDevice_hi < uaa->info.bcdDevice)) {
+                       continue;
+               }
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
+                   (id->bDeviceClass != uaa->info.bDeviceClass)) {
+                       continue;
+               }
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
+                   (id->bDeviceSubClass != uaa->info.bDeviceSubClass)) {
+                       continue;
+               }
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
+                   (id->bDeviceProtocol != uaa->info.bDeviceProtocol)) {
+                       continue;
+               }
+               if ((uaa->info.bDeviceClass == 0xFF) &&
+                   !(id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
+                   (id->match_flags & (USB_DEVICE_ID_MATCH_INT_CLASS |
+                   USB_DEVICE_ID_MATCH_INT_SUBCLASS |
+                   USB_DEVICE_ID_MATCH_INT_PROTOCOL))) {
+                       continue;
+               }
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) &&
+                   (id->bInterfaceClass != uaa->info.bInterfaceClass)) {
+                       continue;
+               }
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) &&
+                   (id->bInterfaceSubClass != uaa->info.bInterfaceSubClass)) {
+                       continue;
+               }
+               if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) &&
+                   (id->bInterfaceProtocol != uaa->info.bInterfaceProtocol)) {
+                       continue;
+               }
+               /* we found a match! */
+               return (id);
+       }
+
+done:
+       return (NULL);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_linux_probe
+ *
+ * This function is the FreeBSD probe callback. It is called from the
+ * FreeBSD USB stack through the "device_probe_and_attach()" function.
+ *------------------------------------------------------------------------*/
+static int
+usb_linux_probe(device_t dev)
+{
+       struct usb_attach_arg *uaa = device_get_ivars(dev);
+       struct usb_driver *udrv;
+       int err = ENXIO;
+
+       if (uaa->usb_mode != USB_MODE_HOST) {
+               return (ENXIO);
+       }
+       mtx_lock(&Giant);
+       LIST_FOREACH(udrv, &usb_linux_driver_list, linux_driver_list) {
+               if (usb_linux_lookup_id(udrv->id_table, uaa)) {
+                       err = 0;
+                       break;
+               }
+       }
+       mtx_unlock(&Giant);
+
+       return (err);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_linux_get_usb_driver
+ *
+ * This function returns the pointer to the "struct usb_driver" where
+ * the Linux USB device driver "struct usb_device_id" match was found.
+ * We apply a lock before reading out the pointer to avoid races.
+ *------------------------------------------------------------------------*/
+static struct usb_driver *
+usb_linux_get_usb_driver(struct usb_linux_softc *sc)
+{
+       struct usb_driver *udrv;
+
+       mtx_lock(&Giant);
+       udrv = sc->sc_udrv;
+       mtx_unlock(&Giant);
+       return (udrv);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_linux_attach
+ *
+ * This function is the FreeBSD attach callback. It is called from the
+ * FreeBSD USB stack through the "device_probe_and_attach()" function.
+ * This function is called when "usb_linux_probe()" returns zero.
+ *------------------------------------------------------------------------*/
+static int
+usb_linux_attach(device_t dev)
+{
+       struct usb_attach_arg *uaa = device_get_ivars(dev);
+       struct usb_linux_softc *sc = device_get_softc(dev);
+       struct usb_driver *udrv;
+       const struct usb_device_id *id = NULL;
+
+       mtx_lock(&Giant);
+       LIST_FOREACH(udrv, &usb_linux_driver_list, linux_driver_list) {
+               id = usb_linux_lookup_id(udrv->id_table, uaa);
+               if (id)
+                       break;
+       }
+       mtx_unlock(&Giant);
+
+       if (id == NULL) {
+               return (ENXIO);
+       }
+       if (usb_linux_create_usb_device(uaa->device, dev) != 0)
+               return (ENOMEM);
+       device_set_usb_desc(dev);
+
+       sc->sc_fbsd_udev = uaa->device;
+       sc->sc_fbsd_dev = dev;
+       sc->sc_udrv = udrv;
+       sc->sc_ui = usb_ifnum_to_if(uaa->device, uaa->info.bIfaceNum);
+       if (sc->sc_ui == NULL) {
+               return (EINVAL);
+       }
+       if (udrv->probe) {
+               if ((udrv->probe) (sc->sc_ui, id)) {
+                       return (ENXIO);
+               }
+       }
+       mtx_lock(&Giant);
+       LIST_INSERT_HEAD(&usb_linux_attached_list, sc, sc_attached_list);
+       mtx_unlock(&Giant);
+
+       /* success */
+       return (0);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_linux_detach
+ *
+ * This function is the FreeBSD detach callback. It is called from the
+ * FreeBSD USB stack through the "device_detach()" function.
+ *------------------------------------------------------------------------*/
+static int
+usb_linux_detach(device_t dev)
+{
+       struct usb_linux_softc *sc = device_get_softc(dev);
+       struct usb_driver *udrv = NULL;
+
+       mtx_lock(&Giant);
+       if (sc->sc_attached_list.le_prev) {
+               LIST_REMOVE(sc, sc_attached_list);
+               sc->sc_attached_list.le_prev = NULL;
+               udrv = sc->sc_udrv;
+               sc->sc_udrv = NULL;
+       }
+       mtx_unlock(&Giant);
+
+       if (udrv && udrv->disconnect) {
+               (udrv->disconnect) (sc->sc_ui);
+       }
+       /*
+        * Make sure that we free all FreeBSD USB transfers belonging to
+        * this Linux "usb_interface", hence they will most likely not be
+        * needed any more.
+        */
+       usb_linux_cleanup_interface(sc->sc_fbsd_udev, sc->sc_ui);
+       return (0);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_linux_suspend
+ *
+ * This function is the FreeBSD suspend callback. Usually it does nothing.
+ *------------------------------------------------------------------------*/
+static int
+usb_linux_suspend(device_t dev)
+{
+       struct usb_linux_softc *sc = device_get_softc(dev);
+       struct usb_driver *udrv = usb_linux_get_usb_driver(sc);
+       int err;
+
+       if (udrv && udrv->suspend) {
+               err = (udrv->suspend) (sc->sc_ui, 0);
+       }
+       return (0);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_linux_resume
+ *
+ * This function is the FreeBSD resume callback. Usually it does nothing.
+ *------------------------------------------------------------------------*/
+static int
+usb_linux_resume(device_t dev)
+{
+       struct usb_linux_softc *sc = device_get_softc(dev);
+       struct usb_driver *udrv = usb_linux_get_usb_driver(sc);
+       int err;
+
+       if (udrv && udrv->resume) {
+               err = (udrv->resume) (sc->sc_ui);
+       }
+       return (0);
+}
+
+/*------------------------------------------------------------------------*
+ * Linux emulation layer
+ *------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------------*
+ *     usb_max_isoc_frames
+ *
+ * The following function returns the maximum number of isochronous
+ * frames that we support per URB. It is not part of the Linux USB API.
+ *------------------------------------------------------------------------*/
+static uint16_t
+usb_max_isoc_frames(struct usb_device *dev)
+{
+       ;                               /* indent fix */
+       switch (usbd_get_speed(dev)) {
+       case USB_SPEED_LOW:
+       case USB_SPEED_FULL:
+               return (USB_MAX_FULL_SPEED_ISOC_FRAMES);
+       default:
+               return (USB_MAX_HIGH_SPEED_ISOC_FRAMES);
+       }
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_submit_urb
+ *
+ * This function is used to queue an URB after that it has been
+ * initialized. If it returns non-zero, it means that the URB was not
+ * queued.
+ *------------------------------------------------------------------------*/
+int
+usb_submit_urb(struct urb *urb, uint16_t mem_flags)
+{
+       struct usb_host_endpoint *uhe;
+       uint8_t do_unlock;
+       int err;
+
+       if (urb == NULL)
+               return (-EINVAL);
+
+       do_unlock = mtx_owned(&Giant) ? 0 : 1;
+       if (do_unlock)
+               mtx_lock(&Giant);
+
+       if (urb->endpoint == NULL) {
+               err = -EINVAL;
+               goto done;
+       }
+
+       /*
+         * Check to see if the urb is in the process of being killed
+         * and stop a urb that is in the process of being killed from
+         * being re-submitted (e.g. from its completion callback
+         * function).
+         */
+       if (urb->kill_count != 0) {
+               err = -EPERM;
+               goto done;
+       }
+
+       uhe = urb->endpoint;
+
+       /*
+        * Check that we have got a FreeBSD USB transfer that will dequeue
+        * the URB structure and do the real transfer. If there are no USB
+        * transfers, then we return an error.
+        */
+       if (uhe->bsd_xfer[0] ||
+           uhe->bsd_xfer[1]) {
+               /* we are ready! */
+
+               TAILQ_INSERT_TAIL(&uhe->bsd_urb_list, urb, bsd_urb_list);
+
+               urb->status = -EINPROGRESS;
+
+               usbd_transfer_start(uhe->bsd_xfer[0]);
+               usbd_transfer_start(uhe->bsd_xfer[1]);
+               err = 0;
+       } else {
+               /* no pipes have been setup yet! */
+               urb->status = -EINVAL;
+               err = -EINVAL;
+       }
+done:
+       if (do_unlock)
+               mtx_unlock(&Giant);
+       return (err);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_unlink_urb
+ *
+ * This function is used to stop an URB after that it is been
+ * submitted, but before the "complete" callback has been called. On
+ *------------------------------------------------------------------------*/
+int
+usb_unlink_urb(struct urb *urb)
+{
+       return (usb_unlink_urb_sub(urb, 0));
+}
+
+static void
+usb_unlink_bsd(struct usb_xfer *xfer,
+    struct urb *urb, uint8_t drain)
+{
+       if (xfer == NULL)
+               return;
+       if (!usbd_transfer_pending(xfer))
+               return;
+       if (xfer->priv_fifo == (void *)urb) {
+               if (drain) {
+                       mtx_unlock(&Giant);
+                       usbd_transfer_drain(xfer);
+                       mtx_lock(&Giant);
+               } else {
+                       usbd_transfer_stop(xfer);
+               }
+               usbd_transfer_start(xfer);
+       }
+}
+
+static int
+usb_unlink_urb_sub(struct urb *urb, uint8_t drain)
+{
+       struct usb_host_endpoint *uhe;
+       uint16_t x;
+       uint8_t do_unlock;
+       int err;
+
+       if (urb == NULL)
+               return (-EINVAL);
+
+       do_unlock = mtx_owned(&Giant) ? 0 : 1;
+       if (do_unlock)
+               mtx_lock(&Giant);
+       if (drain)
+               urb->kill_count++;
+
+       if (urb->endpoint == NULL) {
+               err = -EINVAL;
+               goto done;
+       }
+       uhe = urb->endpoint;
+
+       if (urb->bsd_urb_list.tqe_prev) {
+
+               /* not started yet, just remove it from the queue */
+               TAILQ_REMOVE(&uhe->bsd_urb_list, urb, bsd_urb_list);
+               urb->bsd_urb_list.tqe_prev = NULL;
+               urb->status = -ECONNRESET;
+               urb->actual_length = 0;
+
+               for (x = 0; x < urb->number_of_packets; x++) {
+                       urb->iso_frame_desc[x].actual_length = 0;
+               }
+
+               if (urb->complete) {
+                       (urb->complete) (urb);
+               }
+       } else {
+
+               /*
+                * If the URB is not on the URB list, then check if one of
+                * the FreeBSD USB transfer are processing the current URB.
+                * If so, re-start that transfer, which will lead to the
+                * termination of that URB:
+                */
+               usb_unlink_bsd(uhe->bsd_xfer[0], urb, drain);
+               usb_unlink_bsd(uhe->bsd_xfer[1], urb, drain);
+       }
+       err = 0;
+done:
+       if (drain)
+               urb->kill_count--;
+       if (do_unlock)
+               mtx_unlock(&Giant);
+       return (err);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_clear_halt
+ *
+ * This function must always be used to clear the stall. Stall is when
+ * an USB endpoint returns a stall message to the USB host controller.
+ * Until the stall is cleared, no data can be transferred.
+ *------------------------------------------------------------------------*/
+int
+usb_clear_halt(struct usb_device *dev, struct usb_host_endpoint *uhe)
+{
+       struct usb_config cfg[1];
+       struct usb_endpoint *ep;
+       uint8_t type;
+       uint8_t addr;
+
+       if (uhe == NULL)
+               return (-EINVAL);
+
+       type = uhe->desc.bmAttributes & UE_XFERTYPE;
+       addr = uhe->desc.bEndpointAddress;
+
+       memset(cfg, 0, sizeof(cfg));
+
+       cfg[0].type = type;
+       cfg[0].endpoint = addr & UE_ADDR;
+       cfg[0].direction = addr & (UE_DIR_OUT | UE_DIR_IN);
+
+       ep = usbd_get_endpoint(dev, uhe->bsd_iface_index, cfg);
+       if (ep == NULL)
+               return (-EINVAL);
+
+       usbd_clear_data_toggle(dev, ep);
+
+       return (usb_control_msg(dev, &dev->ep0,
+           UR_CLEAR_FEATURE, UT_WRITE_ENDPOINT,
+           UF_ENDPOINT_HALT, addr, NULL, 0, 1000));
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_start_wait_urb
+ *
+ * This is an internal function that is used to perform synchronous
+ * Linux USB transfers.
+ *------------------------------------------------------------------------*/
+static int
+usb_start_wait_urb(struct urb *urb, usb_timeout_t timeout, uint16_t *p_actlen)
+{
+       int err;
+       uint8_t do_unlock;
+
+       /* you must have a timeout! */
+       if (timeout == 0) {
+               timeout = 1;
+       }
+       urb->complete = &usb_linux_wait_complete;
+       urb->timeout = timeout;
+       urb->transfer_flags |= URB_WAIT_WAKEUP;
+       urb->transfer_flags &= ~URB_IS_SLEEPING;
+
+       do_unlock = mtx_owned(&Giant) ? 0 : 1;
+       if (do_unlock)
+               mtx_lock(&Giant);
+       err = usb_submit_urb(urb, 0);
+       if (err)
+               goto done;
+
+       /*
+        * the URB might have completed before we get here, so check that by
+        * using some flags!
+        */
+       while (urb->transfer_flags & URB_WAIT_WAKEUP) {
+               urb->transfer_flags |= URB_IS_SLEEPING;
+               cv_wait(&urb->cv_wait, &Giant);
+               urb->transfer_flags &= ~URB_IS_SLEEPING;
+       }
+
+       err = urb->status;
+
+done:
+       if (do_unlock)
+               mtx_unlock(&Giant);
+       if (p_actlen != NULL) {
+               if (err)
+                       *p_actlen = 0;
+               else
+                       *p_actlen = urb->actual_length;
+       }
+       return (err);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_control_msg
+ *
+ * The following function performs a control transfer sequence one any
+ * control, bulk or interrupt endpoint, specified by "uhe". A control
+ * transfer means that you transfer an 8-byte header first followed by
+ * a data-phase as indicated by the 8-byte header. The "timeout" is
+ * given in milliseconds.
+ *
+ * Return values:
+ *   0: Success
+ * < 0: Failure
+ * > 0: Acutal length
+ *------------------------------------------------------------------------*/
+int
+usb_control_msg(struct usb_device *dev, struct usb_host_endpoint *uhe,
+    uint8_t request, uint8_t requesttype,
+    uint16_t value, uint16_t index, void *data,
+    uint16_t size, usb_timeout_t timeout)
+{
+       struct usb_device_request req;
+       struct urb *urb;
+       int err;
+       uint16_t actlen;
+       uint8_t type;
+       uint8_t addr;
+
+       req.bmRequestType = requesttype;
+       req.bRequest = request;
+       USETW(req.wValue, value);
+       USETW(req.wIndex, index);
+       USETW(req.wLength, size);
+
+       if (uhe == NULL) {
+               return (-EINVAL);
+       }
+       type = (uhe->desc.bmAttributes & UE_XFERTYPE);
+       addr = (uhe->desc.bEndpointAddress & UE_ADDR);
+
+       if (type != UE_CONTROL) {
+               return (-EINVAL);
+       }
+       if (addr == 0) {
+               /*
+                * The FreeBSD USB stack supports standard control
+                * transfers on control endpoint zero:
+                */
+               err = usbd_do_request_flags(dev,
+                   NULL, &req, data, USB_SHORT_XFER_OK,
+                   &actlen, timeout);
+               if (err) {
+                       err = -EPIPE;
+               } else {
+                       err = actlen;
+               }
+               return (err);
+       }
+       if (dev->flags.usb_mode != USB_MODE_HOST) {
+               /* not supported */
+               return (-EINVAL);
+       }
+       err = usb_setup_endpoint(dev, uhe, 1 /* dummy */ );
+
+       /*
+        * NOTE: we need to allocate real memory here so that we don't
+        * transfer data to/from the stack!
+        *
+        * 0xFFFF is a FreeBSD specific magic value.
+        */
+       urb = usb_alloc_urb(0xFFFF, size);
+       if (urb == NULL)
+               return (-ENOMEM);
+
+       urb->dev = dev;
+       urb->endpoint = uhe;
+
+       memcpy(urb->setup_packet, &req, sizeof(req));
+
+       if (size && (!(req.bmRequestType & UT_READ))) {
+               /* move the data to a real buffer */
+               memcpy(USB_ADD_BYTES(urb->setup_packet, sizeof(req)),
+                   data, size);
+       }
+       err = usb_start_wait_urb(urb, timeout, &actlen);
+
+       if (req.bmRequestType & UT_READ) {
+               if (actlen) {
+                       bcopy(USB_ADD_BYTES(urb->setup_packet,
+                           sizeof(req)), data, actlen);
+               }
+       }
+       usb_free_urb(urb);
+
+       if (err == 0) {
+               err = actlen;
+       }
+       return (err);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_set_interface
+ *
+ * The following function will select which alternate setting of an
+ * USB interface you plan to use. By default alternate setting with
+ * index zero is selected. Note that "iface_no" is not the interface
+ * index, but rather the value of "bInterfaceNumber".
+ *------------------------------------------------------------------------*/
+int
+usb_set_interface(struct usb_device *dev, uint8_t iface_no, uint8_t alt_index)
+{
+       struct usb_interface *p_ui = usb_ifnum_to_if(dev, iface_no);
+       int err;
+
+       if (p_ui == NULL)
+               return (-EINVAL);
+       if (alt_index >= p_ui->num_altsetting)
+               return (-EINVAL);
+       usb_linux_cleanup_interface(dev, p_ui);
+       err = -usbd_set_alt_interface_index(dev,
+           p_ui->bsd_iface_index, alt_index);
+       if (err == 0) {
+               p_ui->cur_altsetting = p_ui->altsetting + alt_index;
+       }
+       return (err);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_setup_endpoint
+ *
+ * The following function is an extension to the Linux USB API that
+ * allows you to set a maximum buffer size for a given USB endpoint.
+ * The maximum buffer size is per URB. If you don't call this function
+ * to set a maximum buffer size, the endpoint will not be functional.
+ * Note that for isochronous endpoints the maximum buffer size must be
+ * a non-zero dummy, hence this function will base the maximum buffer
+ * size on "wMaxPacketSize".
+ *------------------------------------------------------------------------*/
+int
+usb_setup_endpoint(struct usb_device *dev,
+    struct usb_host_endpoint *uhe, usb_size_t bufsize)
+{
+       struct usb_config cfg[2];
+       uint8_t type = uhe->desc.bmAttributes & UE_XFERTYPE;
+       uint8_t addr = uhe->desc.bEndpointAddress;
+
+       if (uhe->fbsd_buf_size == bufsize) {
+               /* optimize */
+               return (0);
+       }
+       usbd_transfer_unsetup(uhe->bsd_xfer, 2);
+
+       uhe->fbsd_buf_size = bufsize;
+
+       if (bufsize == 0) {
+               return (0);
+       }
+       memset(cfg, 0, sizeof(cfg));
+
+       if (type == UE_ISOCHRONOUS) {
+
+               /*
+                * Isochronous transfers are special in that they don't fit
+                * into the BULK/INTR/CONTROL transfer model.
+                */
+
+               cfg[0].type = type;
+               cfg[0].endpoint = addr & UE_ADDR;
+               cfg[0].direction = addr & (UE_DIR_OUT | UE_DIR_IN);
+               cfg[0].callback = &usb_linux_isoc_callback;
+               cfg[0].bufsize = 0;     /* use wMaxPacketSize */
+               cfg[0].frames = usb_max_isoc_frames(dev);
+               cfg[0].flags.proxy_buffer = 1;
+#if 0
+               /*
+                * The Linux USB API allows non back-to-back
+                * isochronous frames which we do not support. If the
+                * isochronous frames are not back-to-back we need to
+                * do a copy, and then we need a buffer for
+                * that. Enable this at your own risk.
+                */
+               cfg[0].flags.ext_buffer = 1;
+#endif
+               cfg[0].flags.short_xfer_ok = 1;
+
+               bcopy(cfg, cfg + 1, sizeof(*cfg));
+
+               /* Allocate and setup two generic FreeBSD USB transfers */
+
+               if (usbd_transfer_setup(dev, &uhe->bsd_iface_index,
+                   uhe->bsd_xfer, cfg, 2, uhe, &Giant)) {
+                       return (-EINVAL);
+               }
+       } else {
+               if (bufsize > (1 << 22)) {
+                       /* limit buffer size */
+                       bufsize = (1 << 22);
+               }
+               /* Allocate and setup one generic FreeBSD USB transfer */
+
+               cfg[0].type = type;
+               cfg[0].endpoint = addr & UE_ADDR;
+               cfg[0].direction = addr & (UE_DIR_OUT | UE_DIR_IN);
+               cfg[0].callback = &usb_linux_non_isoc_callback;
+               cfg[0].bufsize = bufsize;
+               cfg[0].flags.ext_buffer = 1;    /* enable zero-copy */
+               cfg[0].flags.proxy_buffer = 1;
+               cfg[0].flags.short_xfer_ok = 1;
+
+               if (usbd_transfer_setup(dev, &uhe->bsd_iface_index,
+                   uhe->bsd_xfer, cfg, 1, uhe, &Giant)) {
+                       return (-EINVAL);
+               }
+       }
+       return (0);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_linux_create_usb_device
+ *
+ * The following function is used to build up a per USB device
+ * structure tree, that mimics the Linux one. The root structure
+ * is returned by this function.
+ *------------------------------------------------------------------------*/
+static int
+usb_linux_create_usb_device(struct usb_device *udev, device_t dev)
+{
+       struct usb_config_descriptor *cd = usbd_get_config_descriptor(udev);
+       struct usb_descriptor *desc;
+       struct usb_interface_descriptor *id;
+       struct usb_endpoint_descriptor *ed;
+       struct usb_interface *p_ui = NULL;
+       struct usb_host_interface *p_uhi = NULL;
+       struct usb_host_endpoint *p_uhe = NULL;
+       usb_size_t size;
+       uint16_t niface_total;
+       uint16_t nedesc;
+       uint16_t iface_no_curr;
+       uint16_t iface_index;
+       uint8_t pass;
+       uint8_t iface_no;
+
+       /*
+        * We do two passes. One pass for computing necessary memory size
+        * and one pass to initialize all the allocated memory structures.
+        */
+       for (pass = 0; pass < 2; pass++) {
+
+               iface_no_curr = 0xFFFF;
+               niface_total = 0;
+               iface_index = 0;
+               nedesc = 0;
+               desc = NULL;
+
+               /*
+                * Iterate over all the USB descriptors. Use the USB config
+                * descriptor pointer provided by the FreeBSD USB stack.
+                */
+               while ((desc = usb_desc_foreach(cd, desc))) {
+
+                       /*
+                        * Build up a tree according to the descriptors we
+                        * find:
+                        */
+                       switch (desc->bDescriptorType) {
+                       case UDESC_DEVICE:
+                               break;
+
+                       case UDESC_ENDPOINT:
+                               ed = (void *)desc;
+                               if ((ed->bLength < sizeof(*ed)) ||
+                                   (iface_index == 0))
+                                       break;
+                               if (p_uhe) {
+                                       bcopy(ed, &p_uhe->desc, sizeof(p_uhe->desc));
+                                       p_uhe->bsd_iface_index = iface_index - 1;
+                                       TAILQ_INIT(&p_uhe->bsd_urb_list);
+                                       p_uhe++;
+                               }
+                               if (p_uhi) {
+                                       (p_uhi - 1)->desc.bNumEndpoints++;
+                               }
+                               nedesc++;
+                               break;
+
+                       case UDESC_INTERFACE:
+                               id = (void *)desc;
+                               if (id->bLength < sizeof(*id))
+                                       break;
+                               if (p_uhi) {
+                                       bcopy(id, &p_uhi->desc, sizeof(p_uhi->desc));
+                                       p_uhi->desc.bNumEndpoints = 0;
+                                       p_uhi->endpoint = p_uhe;
+                                       p_uhi->string = "";
+                                       p_uhi->bsd_iface_index = iface_index;
+                                       p_uhi++;
+                               }
+                               iface_no = id->bInterfaceNumber;
+                               niface_total++;
+                               if (iface_no_curr != iface_no) {
+                                       if (p_ui) {
+                                               p_ui->altsetting = p_uhi - 1;
+                                               p_ui->cur_altsetting = p_uhi - 1;
+                                               p_ui->num_altsetting = 1;
+                                               p_ui->bsd_iface_index = iface_index;
+                                               p_ui->linux_udev = udev;
+                                               p_ui++;
+                                       }
+                                       iface_no_curr = iface_no;
+                                       iface_index++;
+                               } else {
+                                       if (p_ui) {
+                                               (p_ui - 1)->num_altsetting++;
+                                       }
+                               }
+                               break;
+
+                       default:
+                               break;
+                       }
+               }
+
+               if (pass == 0) {
+
+                       size = (sizeof(*p_uhe) * nedesc) +
+                           (sizeof(*p_ui) * iface_index) +
+                           (sizeof(*p_uhi) * niface_total);
+
+                       p_uhe = malloc(size, M_USBDEV, M_WAITOK | M_ZERO);
+                       p_ui = (void *)(p_uhe + nedesc);
+                       p_uhi = (void *)(p_ui + iface_index);
+
+                       udev->linux_iface_start = p_ui;
+                       udev->linux_iface_end = p_ui + iface_index;
+                       udev->linux_endpoint_start = p_uhe;
+                       udev->linux_endpoint_end = p_uhe + nedesc;
+                       udev->devnum = device_get_unit(dev);
+                       bcopy(&udev->ddesc, &udev->descriptor,
+                           sizeof(udev->descriptor));
+                       bcopy(udev->ctrl_ep.edesc, &udev->ep0.desc,
+                           sizeof(udev->ep0.desc));
+               }
+       }
+       return (0);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_alloc_urb
+ *
+ * This function should always be used when you allocate an URB for
+ * use with the USB Linux stack. In case of an isochronous transfer
+ * you must specifiy the maximum number of "iso_packets" which you
+ * plan to transfer per URB. This function is always blocking, and
+ * "mem_flags" are not regarded like on Linux.
+ *------------------------------------------------------------------------*/
+struct urb *
+usb_alloc_urb(uint16_t iso_packets, uint16_t mem_flags)
+{
+       struct urb *urb;
+       usb_size_t size;
+
+       if (iso_packets == 0xFFFF) {
+               /*
+                * FreeBSD specific magic value to ask for control transfer
+                * memory allocation:
+                */
+               size = sizeof(*urb) + sizeof(struct usb_device_request) + mem_flags;
+       } else {
+               size = sizeof(*urb) + (iso_packets * sizeof(urb->iso_frame_desc[0]));
+       }
+
+       urb = malloc(size, M_USBDEV, M_WAITOK | M_ZERO);
+       if (urb) {
+
+               cv_init(&urb->cv_wait, "URBWAIT");
+               if (iso_packets == 0xFFFF) {
+                       urb->setup_packet = (void *)(urb + 1);
+                       urb->transfer_buffer = (void *)(urb->setup_packet +
+                           sizeof(struct usb_device_request));
+               } else {
+                       urb->number_of_packets = iso_packets;
+               }
+       }
+       return (urb);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_find_host_endpoint
+ *
+ * The following function will return the Linux USB host endpoint
+ * structure that matches the given endpoint type and endpoint
+ * value. If no match is found, NULL is returned. This function is not
+ * part of the Linux USB API and is only used internally.
+ *------------------------------------------------------------------------*/
+struct usb_host_endpoint *
+usb_find_host_endpoint(struct usb_device *dev, uint8_t type, uint8_t ep)
+{
+       struct usb_host_endpoint *uhe;
+       struct usb_host_endpoint *uhe_end;
+       struct usb_host_interface *uhi;
+       struct usb_interface *ui;
+       uint8_t ea;
+       uint8_t at;
+       uint8_t mask;
+
+       if (dev == NULL) {
+               return (NULL);
+       }
+       if (type == UE_CONTROL) {
+               mask = UE_ADDR;
+       } else {
+               mask = (UE_DIR_IN | UE_DIR_OUT | UE_ADDR);
+       }
+
+       ep &= mask;
+
+       /*
+        * Iterate over all the interfaces searching the selected alternate
+        * setting only, and all belonging endpoints.
+        */
+       for (ui = dev->linux_iface_start;
+           ui != dev->linux_iface_end;
+           ui++) {
+               uhi = ui->cur_altsetting;
+               if (uhi) {
+                       uhe_end = uhi->endpoint + uhi->desc.bNumEndpoints;
+                       for (uhe = uhi->endpoint;
+                           uhe != uhe_end;
+                           uhe++) {
+                               ea = uhe->desc.bEndpointAddress;
+                               at = uhe->desc.bmAttributes;
+
+                               if (((ea & mask) == ep) &&
+                                   ((at & UE_XFERTYPE) == type)) {
+                                       return (uhe);
+                               }
+                       }
+               }
+       }
+
+       if ((type == UE_CONTROL) && ((ep & UE_ADDR) == 0)) {
+               return (&dev->ep0);
+       }
+       return (NULL);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_altnum_to_altsetting
+ *
+ * The following function returns a pointer to an alternate setting by
+ * index given a "usb_interface" pointer. If the alternate setting by
+ * index does not exist, NULL is returned. And alternate setting is a
+ * variant of an interface, but usually with slightly different
+ * characteristics.
+ *------------------------------------------------------------------------*/
+struct usb_host_interface *
+usb_altnum_to_altsetting(const struct usb_interface *intf, uint8_t alt_index)
+{
+       if (alt_index >= intf->num_altsetting) {
+               return (NULL);
+       }
+       return (intf->altsetting + alt_index);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_ifnum_to_if
+ *
+ * The following function searches up an USB interface by
+ * "bInterfaceNumber". If no match is found, NULL is returned.
+ *------------------------------------------------------------------------*/
+struct usb_interface *
+usb_ifnum_to_if(struct usb_device *dev, uint8_t iface_no)
+{
+       struct usb_interface *p_ui;
+
+       for (p_ui = dev->linux_iface_start;
+           p_ui != dev->linux_iface_end;
+           p_ui++) {
+               if ((p_ui->num_altsetting > 0) &&
+                   (p_ui->altsetting->desc.bInterfaceNumber == iface_no)) {
+                       return (p_ui);
+               }
+       }
+       return (NULL);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_buffer_alloc
+ *------------------------------------------------------------------------*/
+void   *
+usb_buffer_alloc(struct usb_device *dev, usb_size_t size, uint16_t mem_flags, uint8_t *dma_addr)
+{
+       return (malloc(size, M_USBDEV, M_WAITOK | M_ZERO));
+}
+
+/*------------------------------------------------------------------------*
+ *     usbd_get_intfdata
+ *------------------------------------------------------------------------*/
+void   *
+usbd_get_intfdata(struct usb_interface *intf)
+{
+       return (intf->bsd_priv_sc);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_linux_register
+ *
+ * The following function is used by the "USB_DRIVER_EXPORT()" macro,
+ * and is used to register a Linux USB driver, so that its
+ * "usb_device_id" structures gets searched a probe time. This
+ * function is not part of the Linux USB API, and is for internal use
+ * only.
+ *------------------------------------------------------------------------*/
+void
+usb_linux_register(void *arg)
+{
+       struct usb_driver *drv = arg;
+
+       mtx_lock(&Giant);
+       LIST_INSERT_HEAD(&usb_linux_driver_list, drv, linux_driver_list);
+       mtx_unlock(&Giant);
+
+       usb_needs_explore_all();
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_linux_deregister
+ *
+ * The following function is used by the "USB_DRIVER_EXPORT()" macro,
+ * and is used to deregister a Linux USB driver. This function will
+ * ensure that all driver instances belonging to the Linux USB device
+ * driver in question, gets detached before the driver is
+ * unloaded. This function is not part of the Linux USB API, and is
+ * for internal use only.
+ *------------------------------------------------------------------------*/
+void
+usb_linux_deregister(void *arg)
+{
+       struct usb_driver *drv = arg;
+       struct usb_linux_softc *sc;
+
+repeat:
+       mtx_lock(&Giant);
+       LIST_FOREACH(sc, &usb_linux_attached_list, sc_attached_list) {
+               if (sc->sc_udrv == drv) {
+                       mtx_unlock(&Giant);
+                       device_detach(sc->sc_fbsd_dev);
+                       goto repeat;
+               }
+       }
+       LIST_REMOVE(drv, linux_driver_list);
+       mtx_unlock(&Giant);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_linux_free_device
+ *
+ * The following function is only used by the FreeBSD USB stack, to
+ * cleanup and free memory after that a Linux USB device was attached.
+ *------------------------------------------------------------------------*/
+void
+usb_linux_free_device(struct usb_device *dev)
+{
+       struct usb_host_endpoint *uhe;
+       struct usb_host_endpoint *uhe_end;
+       int err;
+
+       uhe = dev->linux_endpoint_start;
+       uhe_end = dev->linux_endpoint_end;
+       while (uhe != uhe_end) {
+               err = usb_setup_endpoint(dev, uhe, 0);
+               uhe++;
+       }
+       err = usb_setup_endpoint(dev, &dev->ep0, 0);
+       free(dev->linux_endpoint_start, M_USBDEV);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_buffer_free
+ *------------------------------------------------------------------------*/
+void
+usb_buffer_free(struct usb_device *dev, usb_size_t size,
+    void *addr, uint8_t dma_addr)
+{
+       free(addr, M_USBDEV);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_free_urb
+ *------------------------------------------------------------------------*/
+void
+usb_free_urb(struct urb *urb)
+{
+       if (urb == NULL) {
+               return;
+       }
+       /* make sure that the current URB is not active */
+       usb_kill_urb(urb);
+
+       /* destroy condition variable */
+       cv_destroy(&urb->cv_wait);
+
+       /* just free it */
+       free(urb, M_USBDEV);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_init_urb
+ *
+ * The following function can be used to initialize a custom URB. It
+ * is not recommended to use this function. Use "usb_alloc_urb()"
+ * instead.
+ *------------------------------------------------------------------------*/
+void
+usb_init_urb(struct urb *urb)
+{
+       if (urb == NULL) {
+               return;
+       }
+       memset(urb, 0, sizeof(*urb));
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_kill_urb
+ *------------------------------------------------------------------------*/
+void
+usb_kill_urb(struct urb *urb)
+{
+       usb_unlink_urb_sub(urb, 1);
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_set_intfdata
+ *
+ * The following function sets the per Linux USB interface private
+ * data pointer. It is used by most Linux USB device drivers.
+ *------------------------------------------------------------------------*/
+void
+usb_set_intfdata(struct usb_interface *intf, void *data)
+{
+       intf->bsd_priv_sc = data;
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_linux_cleanup_interface
+ *
+ * The following function will release all FreeBSD USB transfers
+ * associated with a Linux USB interface. It is for internal use only.
+ *------------------------------------------------------------------------*/
+static void
+usb_linux_cleanup_interface(struct usb_device *dev, struct usb_interface *iface)
+{
+       struct usb_host_interface *uhi;
+       struct usb_host_interface *uhi_end;
+       struct usb_host_endpoint *uhe;
+       struct usb_host_endpoint *uhe_end;
+       int err;
+
+       uhi = iface->altsetting;
+       uhi_end = iface->altsetting + iface->num_altsetting;
+       while (uhi != uhi_end) {
+               uhe = uhi->endpoint;
+               uhe_end = uhi->endpoint + uhi->desc.bNumEndpoints;
+               while (uhe != uhe_end) {
+                       err = usb_setup_endpoint(dev, uhe, 0);
+                       uhe++;
+               }
+               uhi++;
+       }
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_linux_wait_complete
+ *
+ * The following function is used by "usb_start_wait_urb()" to wake it
+ * up, when an USB transfer has finished.
+ *------------------------------------------------------------------------*/
+static void
+usb_linux_wait_complete(struct urb *urb)
+{
+       if (urb->transfer_flags & URB_IS_SLEEPING) {
+               cv_signal(&urb->cv_wait);
+       }
+       urb->transfer_flags &= ~URB_WAIT_WAKEUP;
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_linux_complete
+ *------------------------------------------------------------------------*/
+static void
+usb_linux_complete(struct usb_xfer *xfer)
+{
+       struct urb *urb;
+
+       urb = usbd_xfer_get_priv(xfer);
+       usbd_xfer_set_priv(xfer, NULL);
+       if (urb->complete) {
+               (urb->complete) (urb);
+       }
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_linux_isoc_callback
+ *
+ * The following is the FreeBSD isochronous USB callback. Isochronous
+ * frames are USB packets transferred 1000 or 8000 times per second,
+ * depending on whether a full- or high- speed USB transfer is
+ * used.
+ *------------------------------------------------------------------------*/
+static void
+usb_linux_isoc_callback(struct usb_xfer *xfer, usb_error_t error)
+{
+       usb_frlength_t max_frame = xfer->max_frame_size;
+       usb_frlength_t offset;
+       usb_frcount_t x;
+       struct urb *urb = usbd_xfer_get_priv(xfer);
+       struct usb_host_endpoint *uhe = usbd_xfer_softc(xfer);
+       struct usb_iso_packet_descriptor *uipd;
+
+       DPRINTF("\n");
+
+       switch (USB_GET_STATE(xfer)) {
+       case USB_ST_TRANSFERRED:
+
+               if (urb->bsd_isread) {
+
+                       /* copy in data with regard to the URB */
+
+                       offset = 0;
+
+                       for (x = 0; x < urb->number_of_packets; x++) {
+                               uipd = urb->iso_frame_desc + x;
+                               if (uipd->length > xfer->frlengths[x]) {
+                                       if (urb->transfer_flags & URB_SHORT_NOT_OK) {
+                                               /* XXX should be EREMOTEIO */
+                                               uipd->status = -EPIPE;
+                                       } else {
+                                               uipd->status = 0;
+                                       }
+                               } else {
+                                       uipd->status = 0;
+                               }
+                               uipd->actual_length = xfer->frlengths[x];
+                               if (!xfer->flags.ext_buffer) {
+                                       usbd_copy_out(xfer->frbuffers, offset,
+                                           USB_ADD_BYTES(urb->transfer_buffer,
+                                           uipd->offset), uipd->actual_length);
+                               }
+                               offset += max_frame;
+                       }
+               } else {
+                       for (x = 0; x < urb->number_of_packets; x++) {
+                               uipd = urb->iso_frame_desc + x;
+                               uipd->actual_length = xfer->frlengths[x];
+                               uipd->status = 0;
+                       }
+               }
+
+               urb->actual_length = xfer->actlen;
+
+               /* check for short transfer */
+               if (xfer->actlen < xfer->sumlen) {
+                       /* short transfer */
+                       if (urb->transfer_flags & URB_SHORT_NOT_OK) {
+                               /* XXX should be EREMOTEIO */
+                               urb->status = -EPIPE;
+                       } else {
+                               urb->status = 0;
+                       }
+               } else {
+                       /* success */
+                       urb->status = 0;
+               }
+
+               /* call callback */
+               usb_linux_complete(xfer);
+
+       case USB_ST_SETUP:
+tr_setup:
+
+               if (xfer->priv_fifo == NULL) {
+
+                       /* get next transfer */
+                       urb = TAILQ_FIRST(&uhe->bsd_urb_list);
+                       if (urb == NULL) {
+                               /* nothing to do */
+                               return;
+                       }
+                       TAILQ_REMOVE(&uhe->bsd_urb_list, urb, bsd_urb_list);
+                       urb->bsd_urb_list.tqe_prev = NULL;
+
+                       x = xfer->max_frame_count;
+                       if (urb->number_of_packets > x) {
+                               /* XXX simply truncate the transfer */
+                               urb->number_of_packets = x;
+                       }
+               } else {
+                       DPRINTF("Already got a transfer\n");
+
+                       /* already got a transfer (should not happen) */
+                       urb = usbd_xfer_get_priv(xfer);
+               }
+
+               urb->bsd_isread = (uhe->desc.bEndpointAddress & UE_DIR_IN) ? 1 : 0;
+
+               if (xfer->flags.ext_buffer) {
+                       /* set virtual address to load */
+                       usbd_xfer_set_frame_data(xfer, 0, urb->transfer_buffer, 0);
+               }
+               if (!(urb->bsd_isread)) {
+
+                       /* copy out data with regard to the URB */
+
+                       offset = 0;
+
+                       for (x = 0; x < urb->number_of_packets; x++) {
+                               uipd = urb->iso_frame_desc + x;
+                               usbd_xfer_set_frame_len(xfer, x, uipd->length);
+                               if (!xfer->flags.ext_buffer) {
+                                       usbd_copy_in(xfer->frbuffers, offset,
+                                           USB_ADD_BYTES(urb->transfer_buffer,
+                                           uipd->offset), uipd->length);
+                               }
+                               offset += uipd->length;
+                       }
+               } else {
+
+                       /*
+                        * compute the transfer length into the "offset"
+                        * variable
+                        */
+
+                       offset = urb->number_of_packets * max_frame;
+
+                       /* setup "frlengths" array */
+
+                       for (x = 0; x < urb->number_of_packets; x++) {
+                               uipd = urb->iso_frame_desc + x;
+                               usbd_xfer_set_frame_len(xfer, x, max_frame);
+                       }
+               }
+               usbd_xfer_set_priv(xfer, urb);
+               xfer->flags.force_short_xfer = 0;
+               xfer->timeout = urb->timeout;
+               xfer->nframes = urb->number_of_packets;
+               usbd_transfer_submit(xfer);
+               return;
+
+       default:                        /* Error */
+               if (xfer->error == USB_ERR_CANCELLED) {
+                       urb->status = -ECONNRESET;
+               } else {
+                       urb->status = -EPIPE;   /* stalled */
+               }
+
+               /* Set zero for "actual_length" */
+               urb->actual_length = 0;
+
+               /* Set zero for "actual_length" */
+               for (x = 0; x < urb->number_of_packets; x++) {
+                       urb->iso_frame_desc[x].actual_length = 0;
+                       urb->iso_frame_desc[x].status = urb->status;
+               }
+
+               /* call callback */
+               usb_linux_complete(xfer);
+
+               if (xfer->error == USB_ERR_CANCELLED) {
+                       /* we need to return in this case */
+                       return;
+               }
+               goto tr_setup;
+
+       }
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_linux_non_isoc_callback
+ *
+ * The following is the FreeBSD BULK/INTERRUPT and CONTROL USB
+ * callback. It dequeues Linux USB stack compatible URB's, transforms
+ * the URB fields into a FreeBSD USB transfer, and defragments the USB
+ * transfer as required. When the transfer is complete the "complete"
+ * callback is called.
+ *------------------------------------------------------------------------*/
+static void
+usb_linux_non_isoc_callback(struct usb_xfer *xfer, usb_error_t error)
+{
+       enum {
+               REQ_SIZE = sizeof(struct usb_device_request)
+       };
+       struct urb *urb = usbd_xfer_get_priv(xfer);
+       struct usb_host_endpoint *uhe = usbd_xfer_softc(xfer);
+       uint8_t *ptr;
+       usb_frlength_t max_bulk = usbd_xfer_max_len(xfer);
+       uint8_t data_frame = xfer->flags_int.control_xfr ? 1 : 0;
+
+       DPRINTF("\n");
+
+       switch (USB_GET_STATE(xfer)) {
+       case USB_ST_TRANSFERRED:
+
+               if (xfer->flags_int.control_xfr) {
+
+                       /* don't transfer the setup packet again: */
+
+                       usbd_xfer_set_frame_len(xfer, 0, 0);
+               }
+               if (urb->bsd_isread && (!xfer->flags.ext_buffer)) {
+                       /* copy in data with regard to the URB */
+                       usbd_copy_out(xfer->frbuffers + data_frame, 0,
+                           urb->bsd_data_ptr, xfer->frlengths[data_frame]);
+               }
+               urb->bsd_length_rem -= xfer->frlengths[data_frame];
+               urb->bsd_data_ptr += xfer->frlengths[data_frame];
+               urb->actual_length += xfer->frlengths[data_frame];
+
+               /* check for short transfer */
+               if (xfer->actlen < xfer->sumlen) {
+                       urb->bsd_length_rem = 0;
+
+                       /* short transfer */
+                       if (urb->transfer_flags & URB_SHORT_NOT_OK) {
+                               urb->status = -EPIPE;
+                       } else {
+                               urb->status = 0;
+                       }
+               } else {
+                       /* check remainder */
+                       if (urb->bsd_length_rem > 0) {
+                               goto setup_bulk;
+                       }
+                       /* success */
+                       urb->status = 0;
+               }
+
+               /* call callback */
+               usb_linux_complete(xfer);
+
+       case USB_ST_SETUP:
+tr_setup:
+               /* get next transfer */
+               urb = TAILQ_FIRST(&uhe->bsd_urb_list);
+               if (urb == NULL) {
+                       /* nothing to do */
+                       return;
+               }
+               TAILQ_REMOVE(&uhe->bsd_urb_list, urb, bsd_urb_list);
+               urb->bsd_urb_list.tqe_prev = NULL;
+
+               usbd_xfer_set_priv(xfer, urb);
+               xfer->flags.force_short_xfer = 0;
+               xfer->timeout = urb->timeout;
+
+               if (xfer->flags_int.control_xfr) {
+
+                       /*
+                        * USB control transfers need special handling.
+                        * First copy in the header, then copy in data!
+                        */
+                       if (!xfer->flags.ext_buffer) {
+                               usbd_copy_in(xfer->frbuffers, 0,
+                                   urb->setup_packet, REQ_SIZE);
+                               usbd_xfer_set_frame_len(xfer, 0, REQ_SIZE);
+                       } else {
+                               /* set virtual address to load */
+                               usbd_xfer_set_frame_data(xfer, 0,
+                                   urb->setup_packet, REQ_SIZE);
+                       }
+
+                       ptr = urb->setup_packet;
+
+                       /* setup data transfer direction and length */
+                       urb->bsd_isread = (ptr[0] & UT_READ) ? 1 : 0;
+                       urb->bsd_length_rem = ptr[6] | (ptr[7] << 8);
+
+               } else {
+
+                       /* setup data transfer direction */
+
+                       urb->bsd_length_rem = urb->transfer_buffer_length;
+                       urb->bsd_isread = (uhe->desc.bEndpointAddress &
+                           UE_DIR_IN) ? 1 : 0;
+               }
+
+               urb->bsd_data_ptr = urb->transfer_buffer;
+               urb->actual_length = 0;
+
+setup_bulk:
+               if (max_bulk > urb->bsd_length_rem) {
+                       max_bulk = urb->bsd_length_rem;
+               }
+               /* check if we need to force a short transfer */
+
+               if ((max_bulk == urb->bsd_length_rem) &&
+                   (urb->transfer_flags & URB_ZERO_PACKET) &&
+                   (!xfer->flags_int.control_xfr)) {
+                       xfer->flags.force_short_xfer = 1;
+               }
+               /* check if we need to copy in data */
+
+               if (xfer->flags.ext_buffer) {
+                       /* set virtual address to load */
+                       usbd_xfer_set_frame_data(xfer, data_frame,
+                           urb->bsd_data_ptr, max_bulk);
+               } else if (!urb->bsd_isread) {
+                       /* copy out data with regard to the URB */
+                       usbd_copy_in(xfer->frbuffers + data_frame, 0,
+                           urb->bsd_data_ptr, max_bulk);
+                       usbd_xfer_set_frame_len(xfer, data_frame, max_bulk);
+               }
+               if (xfer->flags_int.control_xfr) {
+                       if (max_bulk > 0) {
+                               xfer->nframes = 2;
+                       } else {
+                               xfer->nframes = 1;
+                       }
+               } else {
+                       xfer->nframes = 1;
+               }
+               usbd_transfer_submit(xfer);
+               return;
+
+       default:
+               if (xfer->error == USB_ERR_CANCELLED) {
+                       urb->status = -ECONNRESET;
+               } else {
+                       urb->status = -EPIPE;
+               }
+
+               /* Set zero for "actual_length" */
+               urb->actual_length = 0;
+
+               /* call callback */
+               usb_linux_complete(xfer);
+
+               if (xfer->error == USB_ERR_CANCELLED) {
+                       /* we need to return in this case */
+                       return;
+               }
+               goto tr_setup;
+       }
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_fill_bulk_urb
+ *------------------------------------------------------------------------*/
+void
+usb_fill_bulk_urb(struct urb *urb, struct usb_device *udev,
+    struct usb_host_endpoint *uhe, void *buf,
+    int length, usb_complete_t callback, void *arg)
+{
+       urb->dev = udev;
+       urb->endpoint = uhe;
+       urb->transfer_buffer = buf;
+       urb->transfer_buffer_length = length;
+       urb->complete = callback;
+       urb->context = arg;
+}
+
+/*------------------------------------------------------------------------*
+ *     usb_bulk_msg
+ *
+ * NOTE: This function can also be used for interrupt endpoints!
+ *
+ * Return values:
+ *    0: Success
+ * Else: Failure
+ *------------------------------------------------------------------------*/
+int
+usb_bulk_msg(struct usb_device *udev, struct usb_host_endpoint *uhe,
+    void *data, int len, uint16_t *pactlen, usb_timeout_t timeout)
+{
+       struct urb *urb;
+       int err;
+
+       if (uhe == NULL)
+               return (-EINVAL);
+       if (len < 0)
+               return (-EINVAL);
+
+       err = usb_setup_endpoint(udev, uhe, 4096 /* bytes */);
+       if (err)
+               return (err);
+
+       urb = usb_alloc_urb(0, 0);
+       if (urb == NULL)
+               return (-ENOMEM);
+
+        usb_fill_bulk_urb(urb, udev, uhe, data, len,
+           usb_linux_wait_complete, NULL);
+
+       err = usb_start_wait_urb(urb, timeout, pactlen);
+
+       usb_free_urb(urb);
+
+       return (err);
+}
+MODULE_DEPEND(linuxkpi, usb, 1, 1, 1);
+
+static void
+usb_linux_init(void *arg)
+{
+       /* register our function */
+       usb_linux_free_device_p = &usb_linux_free_device;
+}
+SYSINIT(usb_linux_init, SI_SUB_LOCK, SI_ORDER_FIRST, usb_linux_init, NULL);
+SYSUNINIT(usb_linux_unload, SI_SUB_LOCK, SI_ORDER_ANY, usb_linux_unload, NULL);
index c1210e240191e8d0e087f0a0a5ff585923c9eb66..1afefdba081a08d31cc8726c573839f3839d95b2 100644 (file)
@@ -359,6 +359,9 @@ options     COMPAT_FREEBSD9
 # Enable FreeBSD10 compatibility syscalls
 options        COMPAT_FREEBSD10
 
+# Enable Linux Kernel Programming Interface
+options        COMPAT_LINUXKPI
+
 #
 # These three options provide support for System V Interface
 # Definition-style interprocess communication, in the form of shared
index 9a6dec43a8b4a4c28383705017a646a5b0bcd6d4..c07cf408a6d5cc94538d56e5e04679761fd4cd5f 100644 (file)
@@ -2574,7 +2574,6 @@ dev/usb/storage/ustorage_fs.c     optional usfs
 # USB core
 #
 dev/usb/usb_busdma.c           optional usb
-dev/usb/usb_compat_linux.c     optional usb
 dev/usb/usb_core.c             optional usb
 dev/usb/usb_debug.c            optional usb
 dev/usb/usb_dev.c              optional usb
@@ -3796,17 +3795,20 @@ nlm/nlm_prot_svc.c              optional nfslockd | nfsd
 nlm/nlm_prot_xdr.c             optional nfslockd | nfsd
 nlm/sm_inter_xdr.c             optional nfslockd | nfsd
 
-# Linux Kernel Compatibility API
-ofed/include/linux/linux_kmod.c                        optional ofed | compat_linuxkpi \
-       no-depend compile-with "${OFED_C}"
-ofed/include/linux/linux_compat.c              optional ofed | compat_linuxkpi \
-       no-depend compile-with "${OFED_C}"
-ofed/include/linux/linux_pci.c                 optional ofed | compat_linuxkpi \
-       no-depend compile-with "${OFED_C}"
-ofed/include/linux/linux_idr.c                 optional ofed | compat_linuxkpi \
-       no-depend compile-with "${OFED_C}"
-ofed/include/linux/linux_radix.c               optional ofed | compat_linuxkpi \
-       no-depend compile-with "${OFED_C}"
+# Linux Kernel Programming Interface
+compat/linuxkpi/common/src/linux_kmod.c                optional compat_linuxkpi \
+       no-depend compile-with "${LINUXKPI_C}"
+compat/linuxkpi/common/src/linux_compat.c      optional compat_linuxkpi \
+       no-depend compile-with "${LINUXKPI_C}"
+compat/linuxkpi/common/src/linux_pci.c         optional compat_linuxkpi pci \
+       no-depend compile-with "${LINUXKPI_C}"
+compat/linuxkpi/common/src/linux_idr.c         optional compat_linuxkpi \
+       no-depend compile-with "${LINUXKPI_C}"
+compat/linuxkpi/common/src/linux_radix.c       optional compat_linuxkpi \
+       no-depend compile-with "${LINUXKPI_C}"
+compat/linuxkpi/common/src/linux_usb.c         optional compat_linuxkpi usb \
+       no-depend compile-with "${LINUXKPI_C}"
+
 # OpenFabrics Enterprise Distribution (Infiniband)
 ofed/drivers/infiniband/core/addr.c            optional ofed           \
        no-depend                                                       \
index 3783881d322e379c0c2ed5c7d5de18dd7cf854ba..4328749447a5a205db4b87dc2df49fb1e3ebbcac 100644 (file)
@@ -177,9 +177,13 @@ NORMAL_CTFCONVERT= @:
 
 NORMAL_LINT=   ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
 
+# Linux Kernel Programming Interface C-flags
+LINUXKPI_INCLUDES=     -I$S/compat/linuxkpi/common/include
+LINUXKPI_C=            ${NORMAL_C} ${LINUXKPI_INCLUDES}
+
 # Infiniband C flags.  Correct include paths and omit errors that linux
 # does not honor.
-OFEDINCLUDES=  -I$S/ofed/include/
+OFEDINCLUDES=  -I$S/ofed/include ${LINUXKPI_INCLUDES}
 OFEDNOERR=     -Wno-cast-qual -Wno-pointer-arith
 OFEDCFLAGS=    ${CFLAGS:N-I*} ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR}
 OFED_C_NOIMP=  ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR} ${PROF}
diff --git a/sys/dev/usb/usb_compat_linux.c b/sys/dev/usb/usb_compat_linux.c
deleted file mode 100644 (file)
index 56caf06..0000000
+++ /dev/null
@@ -1,1735 +0,0 @@
-/* $FreeBSD$ */
-/*-
- * Copyright (c) 2007 Luigi Rizzo - Universita` di Pisa. All rights reserved.
- * Copyright (c) 2007 Hans Petter Selasky. 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, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- */
-
-#ifdef USB_GLOBAL_INCLUDE_FILE
-#include USB_GLOBAL_INCLUDE_FILE
-#else
-#include <sys/stdint.h>
-#include <sys/stddef.h>
-#include <sys/param.h>
-#include <sys/queue.h>
-#include <sys/types.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/bus.h>
-#include <sys/module.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/condvar.h>
-#include <sys/sysctl.h>
-#include <sys/sx.h>
-#include <sys/unistd.h>
-#include <sys/callout.h>
-#include <sys/malloc.h>
-#include <sys/priv.h>
-
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
-#include <dev/usb/usbdi_util.h>
-
-#define        USB_DEBUG_VAR usb_debug
-
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_compat_linux.h>
-#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_device.h>
-#include <dev/usb/usb_util.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_transfer.h>
-#include <dev/usb/usb_hub.h>
-#include <dev/usb/usb_request.h>
-#include <dev/usb/usb_debug.h>
-#endif                 /* USB_GLOBAL_INCLUDE_FILE */
-
-struct usb_linux_softc {
-       LIST_ENTRY(usb_linux_softc) sc_attached_list;
-
-       device_t sc_fbsd_dev;
-       struct usb_device *sc_fbsd_udev;
-       struct usb_interface *sc_ui;
-       struct usb_driver *sc_udrv;
-};
-
-/* prototypes */
-static device_probe_t usb_linux_probe;
-static device_attach_t usb_linux_attach;
-static device_detach_t usb_linux_detach;
-static device_suspend_t usb_linux_suspend;
-static device_resume_t usb_linux_resume;
-
-static usb_callback_t usb_linux_isoc_callback;
-static usb_callback_t usb_linux_non_isoc_callback;
-
-static usb_complete_t usb_linux_wait_complete;
-
-static uint16_t        usb_max_isoc_frames(struct usb_device *);
-static int     usb_start_wait_urb(struct urb *, usb_timeout_t, uint16_t *);
-static const struct usb_device_id *usb_linux_lookup_id(
-                   const struct usb_device_id *, struct usb_attach_arg *);
-static struct  usb_driver *usb_linux_get_usb_driver(struct usb_linux_softc *);
-static int     usb_linux_create_usb_device(struct usb_device *, device_t);
-static void    usb_linux_cleanup_interface(struct usb_device *,
-                   struct usb_interface *);
-static void    usb_linux_complete(struct usb_xfer *);
-static int     usb_unlink_urb_sub(struct urb *, uint8_t);
-
-/*------------------------------------------------------------------------*
- * FreeBSD USB interface
- *------------------------------------------------------------------------*/
-
-static LIST_HEAD(, usb_linux_softc) usb_linux_attached_list;
-static LIST_HEAD(, usb_driver) usb_linux_driver_list;
-
-static device_method_t usb_linux_methods[] = {
-       /* Device interface */
-       DEVMETHOD(device_probe, usb_linux_probe),
-       DEVMETHOD(device_attach, usb_linux_attach),
-       DEVMETHOD(device_detach, usb_linux_detach),
-       DEVMETHOD(device_suspend, usb_linux_suspend),
-       DEVMETHOD(device_resume, usb_linux_resume),
-
-       DEVMETHOD_END
-};
-
-static driver_t usb_linux_driver = {
-       .name = "usb_linux",
-       .methods = usb_linux_methods,
-       .size = sizeof(struct usb_linux_softc),
-};
-
-static devclass_t usb_linux_devclass;
-
-DRIVER_MODULE(usb_linux, uhub, usb_linux_driver, usb_linux_devclass, NULL, 0);
-MODULE_VERSION(usb_linux, 1);
-
-/*------------------------------------------------------------------------*
- *     usb_linux_lookup_id
- *
- * This functions takes an array of "struct usb_device_id" and tries
- * to match the entries with the information in "struct usb_attach_arg".
- * If it finds a match the matching entry will be returned.
- * Else "NULL" will be returned.
- *------------------------------------------------------------------------*/
-static const struct usb_device_id *
-usb_linux_lookup_id(const struct usb_device_id *id, struct usb_attach_arg *uaa)
-{
-       if (id == NULL) {
-               goto done;
-       }
-       /*
-        * Keep on matching array entries until we find one with
-        * "match_flags" equal to zero, which indicates the end of the
-        * array:
-        */
-       for (; id->match_flags; id++) {
-
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
-                   (id->idVendor != uaa->info.idVendor)) {
-                       continue;
-               }
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
-                   (id->idProduct != uaa->info.idProduct)) {
-                       continue;
-               }
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
-                   (id->bcdDevice_lo > uaa->info.bcdDevice)) {
-                       continue;
-               }
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
-                   (id->bcdDevice_hi < uaa->info.bcdDevice)) {
-                       continue;
-               }
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
-                   (id->bDeviceClass != uaa->info.bDeviceClass)) {
-                       continue;
-               }
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
-                   (id->bDeviceSubClass != uaa->info.bDeviceSubClass)) {
-                       continue;
-               }
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
-                   (id->bDeviceProtocol != uaa->info.bDeviceProtocol)) {
-                       continue;
-               }
-               if ((uaa->info.bDeviceClass == 0xFF) &&
-                   !(id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
-                   (id->match_flags & (USB_DEVICE_ID_MATCH_INT_CLASS |
-                   USB_DEVICE_ID_MATCH_INT_SUBCLASS |
-                   USB_DEVICE_ID_MATCH_INT_PROTOCOL))) {
-                       continue;
-               }
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) &&
-                   (id->bInterfaceClass != uaa->info.bInterfaceClass)) {
-                       continue;
-               }
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) &&
-                   (id->bInterfaceSubClass != uaa->info.bInterfaceSubClass)) {
-                       continue;
-               }
-               if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) &&
-                   (id->bInterfaceProtocol != uaa->info.bInterfaceProtocol)) {
-                       continue;
-               }
-               /* we found a match! */
-               return (id);
-       }
-
-done:
-       return (NULL);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_linux_probe
- *
- * This function is the FreeBSD probe callback. It is called from the
- * FreeBSD USB stack through the "device_probe_and_attach()" function.
- *------------------------------------------------------------------------*/
-static int
-usb_linux_probe(device_t dev)
-{
-       struct usb_attach_arg *uaa = device_get_ivars(dev);
-       struct usb_driver *udrv;
-       int err = ENXIO;
-
-       if (uaa->usb_mode != USB_MODE_HOST) {
-               return (ENXIO);
-       }
-       mtx_lock(&Giant);
-       LIST_FOREACH(udrv, &usb_linux_driver_list, linux_driver_list) {
-               if (usb_linux_lookup_id(udrv->id_table, uaa)) {
-                       err = 0;
-                       break;
-               }
-       }
-       mtx_unlock(&Giant);
-
-       return (err);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_linux_get_usb_driver
- *
- * This function returns the pointer to the "struct usb_driver" where
- * the Linux USB device driver "struct usb_device_id" match was found.
- * We apply a lock before reading out the pointer to avoid races.
- *------------------------------------------------------------------------*/
-static struct usb_driver *
-usb_linux_get_usb_driver(struct usb_linux_softc *sc)
-{
-       struct usb_driver *udrv;
-
-       mtx_lock(&Giant);
-       udrv = sc->sc_udrv;
-       mtx_unlock(&Giant);
-       return (udrv);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_linux_attach
- *
- * This function is the FreeBSD attach callback. It is called from the
- * FreeBSD USB stack through the "device_probe_and_attach()" function.
- * This function is called when "usb_linux_probe()" returns zero.
- *------------------------------------------------------------------------*/
-static int
-usb_linux_attach(device_t dev)
-{
-       struct usb_attach_arg *uaa = device_get_ivars(dev);
-       struct usb_linux_softc *sc = device_get_softc(dev);
-       struct usb_driver *udrv;
-       const struct usb_device_id *id = NULL;
-
-       mtx_lock(&Giant);
-       LIST_FOREACH(udrv, &usb_linux_driver_list, linux_driver_list) {
-               id = usb_linux_lookup_id(udrv->id_table, uaa);
-               if (id)
-                       break;
-       }
-       mtx_unlock(&Giant);
-
-       if (id == NULL) {
-               return (ENXIO);
-       }
-       if (usb_linux_create_usb_device(uaa->device, dev) != 0)
-               return (ENOMEM);
-       device_set_usb_desc(dev);
-
-       sc->sc_fbsd_udev = uaa->device;
-       sc->sc_fbsd_dev = dev;
-       sc->sc_udrv = udrv;
-       sc->sc_ui = usb_ifnum_to_if(uaa->device, uaa->info.bIfaceNum);
-       if (sc->sc_ui == NULL) {
-               return (EINVAL);
-       }
-       if (udrv->probe) {
-               if ((udrv->probe) (sc->sc_ui, id)) {
-                       return (ENXIO);
-               }
-       }
-       mtx_lock(&Giant);
-       LIST_INSERT_HEAD(&usb_linux_attached_list, sc, sc_attached_list);
-       mtx_unlock(&Giant);
-
-       /* success */
-       return (0);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_linux_detach
- *
- * This function is the FreeBSD detach callback. It is called from the
- * FreeBSD USB stack through the "device_detach()" function.
- *------------------------------------------------------------------------*/
-static int
-usb_linux_detach(device_t dev)
-{
-       struct usb_linux_softc *sc = device_get_softc(dev);
-       struct usb_driver *udrv = NULL;
-
-       mtx_lock(&Giant);
-       if (sc->sc_attached_list.le_prev) {
-               LIST_REMOVE(sc, sc_attached_list);
-               sc->sc_attached_list.le_prev = NULL;
-               udrv = sc->sc_udrv;
-               sc->sc_udrv = NULL;
-       }
-       mtx_unlock(&Giant);
-
-       if (udrv && udrv->disconnect) {
-               (udrv->disconnect) (sc->sc_ui);
-       }
-       /*
-        * Make sure that we free all FreeBSD USB transfers belonging to
-        * this Linux "usb_interface", hence they will most likely not be
-        * needed any more.
-        */
-       usb_linux_cleanup_interface(sc->sc_fbsd_udev, sc->sc_ui);
-       return (0);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_linux_suspend
- *
- * This function is the FreeBSD suspend callback. Usually it does nothing.
- *------------------------------------------------------------------------*/
-static int
-usb_linux_suspend(device_t dev)
-{
-       struct usb_linux_softc *sc = device_get_softc(dev);
-       struct usb_driver *udrv = usb_linux_get_usb_driver(sc);
-       int err;
-
-       if (udrv && udrv->suspend) {
-               err = (udrv->suspend) (sc->sc_ui, 0);
-       }
-       return (0);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_linux_resume
- *
- * This function is the FreeBSD resume callback. Usually it does nothing.
- *------------------------------------------------------------------------*/
-static int
-usb_linux_resume(device_t dev)
-{
-       struct usb_linux_softc *sc = device_get_softc(dev);
-       struct usb_driver *udrv = usb_linux_get_usb_driver(sc);
-       int err;
-
-       if (udrv && udrv->resume) {
-               err = (udrv->resume) (sc->sc_ui);
-       }
-       return (0);
-}
-
-/*------------------------------------------------------------------------*
- * Linux emulation layer
- *------------------------------------------------------------------------*/
-
-/*------------------------------------------------------------------------*
- *     usb_max_isoc_frames
- *
- * The following function returns the maximum number of isochronous
- * frames that we support per URB. It is not part of the Linux USB API.
- *------------------------------------------------------------------------*/
-static uint16_t
-usb_max_isoc_frames(struct usb_device *dev)
-{
-       ;                               /* indent fix */
-       switch (usbd_get_speed(dev)) {
-       case USB_SPEED_LOW:
-       case USB_SPEED_FULL:
-               return (USB_MAX_FULL_SPEED_ISOC_FRAMES);
-       default:
-               return (USB_MAX_HIGH_SPEED_ISOC_FRAMES);
-       }
-}
-
-/*------------------------------------------------------------------------*
- *     usb_submit_urb
- *
- * This function is used to queue an URB after that it has been
- * initialized. If it returns non-zero, it means that the URB was not
- * queued.
- *------------------------------------------------------------------------*/
-int
-usb_submit_urb(struct urb *urb, uint16_t mem_flags)
-{
-       struct usb_host_endpoint *uhe;
-       uint8_t do_unlock;
-       int err;
-
-       if (urb == NULL)
-               return (-EINVAL);
-
-       do_unlock = mtx_owned(&Giant) ? 0 : 1;
-       if (do_unlock)
-               mtx_lock(&Giant);
-
-       if (urb->endpoint == NULL) {
-               err = -EINVAL;
-               goto done;
-       }
-
-       /*
-         * Check to see if the urb is in the process of being killed
-         * and stop a urb that is in the process of being killed from
-         * being re-submitted (e.g. from its completion callback
-         * function).
-         */
-       if (urb->kill_count != 0) {
-               err = -EPERM;
-               goto done;
-       }
-
-       uhe = urb->endpoint;
-
-       /*
-        * Check that we have got a FreeBSD USB transfer that will dequeue
-        * the URB structure and do the real transfer. If there are no USB
-        * transfers, then we return an error.
-        */
-       if (uhe->bsd_xfer[0] ||
-           uhe->bsd_xfer[1]) {
-               /* we are ready! */
-
-               TAILQ_INSERT_TAIL(&uhe->bsd_urb_list, urb, bsd_urb_list);
-
-               urb->status = -EINPROGRESS;
-
-               usbd_transfer_start(uhe->bsd_xfer[0]);
-               usbd_transfer_start(uhe->bsd_xfer[1]);
-               err = 0;
-       } else {
-               /* no pipes have been setup yet! */
-               urb->status = -EINVAL;
-               err = -EINVAL;
-       }
-done:
-       if (do_unlock)
-               mtx_unlock(&Giant);
-       return (err);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_unlink_urb
- *
- * This function is used to stop an URB after that it is been
- * submitted, but before the "complete" callback has been called. On
- *------------------------------------------------------------------------*/
-int
-usb_unlink_urb(struct urb *urb)
-{
-       return (usb_unlink_urb_sub(urb, 0));
-}
-
-static void
-usb_unlink_bsd(struct usb_xfer *xfer,
-    struct urb *urb, uint8_t drain)
-{
-       if (xfer == NULL)
-               return;
-       if (!usbd_transfer_pending(xfer))
-               return;
-       if (xfer->priv_fifo == (void *)urb) {
-               if (drain) {
-                       mtx_unlock(&Giant);
-                       usbd_transfer_drain(xfer);
-                       mtx_lock(&Giant);
-               } else {
-                       usbd_transfer_stop(xfer);
-               }
-               usbd_transfer_start(xfer);
-       }
-}
-
-static int
-usb_unlink_urb_sub(struct urb *urb, uint8_t drain)
-{
-       struct usb_host_endpoint *uhe;
-       uint16_t x;
-       uint8_t do_unlock;
-       int err;
-
-       if (urb == NULL)
-               return (-EINVAL);
-
-       do_unlock = mtx_owned(&Giant) ? 0 : 1;
-       if (do_unlock)
-               mtx_lock(&Giant);
-       if (drain)
-               urb->kill_count++;
-
-       if (urb->endpoint == NULL) {
-               err = -EINVAL;
-               goto done;
-       }
-       uhe = urb->endpoint;
-
-       if (urb->bsd_urb_list.tqe_prev) {
-
-               /* not started yet, just remove it from the queue */
-               TAILQ_REMOVE(&uhe->bsd_urb_list, urb, bsd_urb_list);
-               urb->bsd_urb_list.tqe_prev = NULL;
-               urb->status = -ECONNRESET;
-               urb->actual_length = 0;
-
-               for (x = 0; x < urb->number_of_packets; x++) {
-                       urb->iso_frame_desc[x].actual_length = 0;
-               }
-
-               if (urb->complete) {
-                       (urb->complete) (urb);
-               }
-       } else {
-
-               /*
-                * If the URB is not on the URB list, then check if one of
-                * the FreeBSD USB transfer are processing the current URB.
-                * If so, re-start that transfer, which will lead to the
-                * termination of that URB:
-                */
-               usb_unlink_bsd(uhe->bsd_xfer[0], urb, drain);
-               usb_unlink_bsd(uhe->bsd_xfer[1], urb, drain);
-       }
-       err = 0;
-done:
-       if (drain)
-               urb->kill_count--;
-       if (do_unlock)
-               mtx_unlock(&Giant);
-       return (err);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_clear_halt
- *
- * This function must always be used to clear the stall. Stall is when
- * an USB endpoint returns a stall message to the USB host controller.
- * Until the stall is cleared, no data can be transferred.
- *------------------------------------------------------------------------*/
-int
-usb_clear_halt(struct usb_device *dev, struct usb_host_endpoint *uhe)
-{
-       struct usb_config cfg[1];
-       struct usb_endpoint *ep;
-       uint8_t type;
-       uint8_t addr;
-
-       if (uhe == NULL)
-               return (-EINVAL);
-
-       type = uhe->desc.bmAttributes & UE_XFERTYPE;
-       addr = uhe->desc.bEndpointAddress;
-
-       memset(cfg, 0, sizeof(cfg));
-
-       cfg[0].type = type;
-       cfg[0].endpoint = addr & UE_ADDR;
-       cfg[0].direction = addr & (UE_DIR_OUT | UE_DIR_IN);
-
-       ep = usbd_get_endpoint(dev, uhe->bsd_iface_index, cfg);
-       if (ep == NULL)
-               return (-EINVAL);
-
-       usbd_clear_data_toggle(dev, ep);
-
-       return (usb_control_msg(dev, &dev->ep0,
-           UR_CLEAR_FEATURE, UT_WRITE_ENDPOINT,
-           UF_ENDPOINT_HALT, addr, NULL, 0, 1000));
-}
-
-/*------------------------------------------------------------------------*
- *     usb_start_wait_urb
- *
- * This is an internal function that is used to perform synchronous
- * Linux USB transfers.
- *------------------------------------------------------------------------*/
-static int
-usb_start_wait_urb(struct urb *urb, usb_timeout_t timeout, uint16_t *p_actlen)
-{
-       int err;
-       uint8_t do_unlock;
-
-       /* you must have a timeout! */
-       if (timeout == 0) {
-               timeout = 1;
-       }
-       urb->complete = &usb_linux_wait_complete;
-       urb->timeout = timeout;
-       urb->transfer_flags |= URB_WAIT_WAKEUP;
-       urb->transfer_flags &= ~URB_IS_SLEEPING;
-
-       do_unlock = mtx_owned(&Giant) ? 0 : 1;
-       if (do_unlock)
-               mtx_lock(&Giant);
-       err = usb_submit_urb(urb, 0);
-       if (err)
-               goto done;
-
-       /*
-        * the URB might have completed before we get here, so check that by
-        * using some flags!
-        */
-       while (urb->transfer_flags & URB_WAIT_WAKEUP) {
-               urb->transfer_flags |= URB_IS_SLEEPING;
-               cv_wait(&urb->cv_wait, &Giant);
-               urb->transfer_flags &= ~URB_IS_SLEEPING;
-       }
-
-       err = urb->status;
-
-done:
-       if (do_unlock)
-               mtx_unlock(&Giant);
-       if (p_actlen != NULL) {
-               if (err)
-                       *p_actlen = 0;
-               else
-                       *p_actlen = urb->actual_length;
-       }
-       return (err);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_control_msg
- *
- * The following function performs a control transfer sequence one any
- * control, bulk or interrupt endpoint, specified by "uhe". A control
- * transfer means that you transfer an 8-byte header first followed by
- * a data-phase as indicated by the 8-byte header. The "timeout" is
- * given in milliseconds.
- *
- * Return values:
- *   0: Success
- * < 0: Failure
- * > 0: Acutal length
- *------------------------------------------------------------------------*/
-int
-usb_control_msg(struct usb_device *dev, struct usb_host_endpoint *uhe,
-    uint8_t request, uint8_t requesttype,
-    uint16_t value, uint16_t index, void *data,
-    uint16_t size, usb_timeout_t timeout)
-{
-       struct usb_device_request req;
-       struct urb *urb;
-       int err;
-       uint16_t actlen;
-       uint8_t type;
-       uint8_t addr;
-
-       req.bmRequestType = requesttype;
-       req.bRequest = request;
-       USETW(req.wValue, value);
-       USETW(req.wIndex, index);
-       USETW(req.wLength, size);
-
-       if (uhe == NULL) {
-               return (-EINVAL);
-       }
-       type = (uhe->desc.bmAttributes & UE_XFERTYPE);
-       addr = (uhe->desc.bEndpointAddress & UE_ADDR);
-
-       if (type != UE_CONTROL) {
-               return (-EINVAL);
-       }
-       if (addr == 0) {
-               /*
-                * The FreeBSD USB stack supports standard control
-                * transfers on control endpoint zero:
-                */
-               err = usbd_do_request_flags(dev,
-                   NULL, &req, data, USB_SHORT_XFER_OK,
-                   &actlen, timeout);
-               if (err) {
-                       err = -EPIPE;
-               } else {
-                       err = actlen;
-               }
-               return (err);
-       }
-       if (dev->flags.usb_mode != USB_MODE_HOST) {
-               /* not supported */
-               return (-EINVAL);
-       }
-       err = usb_setup_endpoint(dev, uhe, 1 /* dummy */ );
-
-       /*
-        * NOTE: we need to allocate real memory here so that we don't
-        * transfer data to/from the stack!
-        *
-        * 0xFFFF is a FreeBSD specific magic value.
-        */
-       urb = usb_alloc_urb(0xFFFF, size);
-       if (urb == NULL)
-               return (-ENOMEM);
-
-       urb->dev = dev;
-       urb->endpoint = uhe;
-
-       memcpy(urb->setup_packet, &req, sizeof(req));
-
-       if (size && (!(req.bmRequestType & UT_READ))) {
-               /* move the data to a real buffer */
-               memcpy(USB_ADD_BYTES(urb->setup_packet, sizeof(req)),
-                   data, size);
-       }
-       err = usb_start_wait_urb(urb, timeout, &actlen);
-
-       if (req.bmRequestType & UT_READ) {
-               if (actlen) {
-                       bcopy(USB_ADD_BYTES(urb->setup_packet,
-                           sizeof(req)), data, actlen);
-               }
-       }
-       usb_free_urb(urb);
-
-       if (err == 0) {
-               err = actlen;
-       }
-       return (err);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_set_interface
- *
- * The following function will select which alternate setting of an
- * USB interface you plan to use. By default alternate setting with
- * index zero is selected. Note that "iface_no" is not the interface
- * index, but rather the value of "bInterfaceNumber".
- *------------------------------------------------------------------------*/
-int
-usb_set_interface(struct usb_device *dev, uint8_t iface_no, uint8_t alt_index)
-{
-       struct usb_interface *p_ui = usb_ifnum_to_if(dev, iface_no);
-       int err;
-
-       if (p_ui == NULL)
-               return (-EINVAL);
-       if (alt_index >= p_ui->num_altsetting)
-               return (-EINVAL);
-       usb_linux_cleanup_interface(dev, p_ui);
-       err = -usbd_set_alt_interface_index(dev,
-           p_ui->bsd_iface_index, alt_index);
-       if (err == 0) {
-               p_ui->cur_altsetting = p_ui->altsetting + alt_index;
-       }
-       return (err);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_setup_endpoint
- *
- * The following function is an extension to the Linux USB API that
- * allows you to set a maximum buffer size for a given USB endpoint.
- * The maximum buffer size is per URB. If you don't call this function
- * to set a maximum buffer size, the endpoint will not be functional.
- * Note that for isochronous endpoints the maximum buffer size must be
- * a non-zero dummy, hence this function will base the maximum buffer
- * size on "wMaxPacketSize".
- *------------------------------------------------------------------------*/
-int
-usb_setup_endpoint(struct usb_device *dev,
-    struct usb_host_endpoint *uhe, usb_size_t bufsize)
-{
-       struct usb_config cfg[2];
-       uint8_t type = uhe->desc.bmAttributes & UE_XFERTYPE;
-       uint8_t addr = uhe->desc.bEndpointAddress;
-
-       if (uhe->fbsd_buf_size == bufsize) {
-               /* optimize */
-               return (0);
-       }
-       usbd_transfer_unsetup(uhe->bsd_xfer, 2);
-
-       uhe->fbsd_buf_size = bufsize;
-
-       if (bufsize == 0) {
-               return (0);
-       }
-       memset(cfg, 0, sizeof(cfg));
-
-       if (type == UE_ISOCHRONOUS) {
-
-               /*
-                * Isochronous transfers are special in that they don't fit
-                * into the BULK/INTR/CONTROL transfer model.
-                */
-
-               cfg[0].type = type;
-               cfg[0].endpoint = addr & UE_ADDR;
-               cfg[0].direction = addr & (UE_DIR_OUT | UE_DIR_IN);
-               cfg[0].callback = &usb_linux_isoc_callback;
-               cfg[0].bufsize = 0;     /* use wMaxPacketSize */
-               cfg[0].frames = usb_max_isoc_frames(dev);
-               cfg[0].flags.proxy_buffer = 1;
-#if 0
-               /*
-                * The Linux USB API allows non back-to-back
-                * isochronous frames which we do not support. If the
-                * isochronous frames are not back-to-back we need to
-                * do a copy, and then we need a buffer for
-                * that. Enable this at your own risk.
-                */
-               cfg[0].flags.ext_buffer = 1;
-#endif
-               cfg[0].flags.short_xfer_ok = 1;
-
-               bcopy(cfg, cfg + 1, sizeof(*cfg));
-
-               /* Allocate and setup two generic FreeBSD USB transfers */
-
-               if (usbd_transfer_setup(dev, &uhe->bsd_iface_index,
-                   uhe->bsd_xfer, cfg, 2, uhe, &Giant)) {
-                       return (-EINVAL);
-               }
-       } else {
-               if (bufsize > (1 << 22)) {
-                       /* limit buffer size */
-                       bufsize = (1 << 22);
-               }
-               /* Allocate and setup one generic FreeBSD USB transfer */
-
-               cfg[0].type = type;
-               cfg[0].endpoint = addr & UE_ADDR;
-               cfg[0].direction = addr & (UE_DIR_OUT | UE_DIR_IN);
-               cfg[0].callback = &usb_linux_non_isoc_callback;
-               cfg[0].bufsize = bufsize;
-               cfg[0].flags.ext_buffer = 1;    /* enable zero-copy */
-               cfg[0].flags.proxy_buffer = 1;
-               cfg[0].flags.short_xfer_ok = 1;
-
-               if (usbd_transfer_setup(dev, &uhe->bsd_iface_index,
-                   uhe->bsd_xfer, cfg, 1, uhe, &Giant)) {
-                       return (-EINVAL);
-               }
-       }
-       return (0);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_linux_create_usb_device
- *
- * The following function is used to build up a per USB device
- * structure tree, that mimics the Linux one. The root structure
- * is returned by this function.
- *------------------------------------------------------------------------*/
-static int
-usb_linux_create_usb_device(struct usb_device *udev, device_t dev)
-{
-       struct usb_config_descriptor *cd = usbd_get_config_descriptor(udev);
-       struct usb_descriptor *desc;
-       struct usb_interface_descriptor *id;
-       struct usb_endpoint_descriptor *ed;
-       struct usb_interface *p_ui = NULL;
-       struct usb_host_interface *p_uhi = NULL;
-       struct usb_host_endpoint *p_uhe = NULL;
-       usb_size_t size;
-       uint16_t niface_total;
-       uint16_t nedesc;
-       uint16_t iface_no_curr;
-       uint16_t iface_index;
-       uint8_t pass;
-       uint8_t iface_no;
-
-       /*
-        * We do two passes. One pass for computing necessary memory size
-        * and one pass to initialize all the allocated memory structures.
-        */
-       for (pass = 0; pass < 2; pass++) {
-
-               iface_no_curr = 0xFFFF;
-               niface_total = 0;
-               iface_index = 0;
-               nedesc = 0;
-               desc = NULL;
-
-               /*
-                * Iterate over all the USB descriptors. Use the USB config
-                * descriptor pointer provided by the FreeBSD USB stack.
-                */
-               while ((desc = usb_desc_foreach(cd, desc))) {
-
-                       /*
-                        * Build up a tree according to the descriptors we
-                        * find:
-                        */
-                       switch (desc->bDescriptorType) {
-                       case UDESC_DEVICE:
-                               break;
-
-                       case UDESC_ENDPOINT:
-                               ed = (void *)desc;
-                               if ((ed->bLength < sizeof(*ed)) ||
-                                   (iface_index == 0))
-                                       break;
-                               if (p_uhe) {
-                                       bcopy(ed, &p_uhe->desc, sizeof(p_uhe->desc));
-                                       p_uhe->bsd_iface_index = iface_index - 1;
-                                       TAILQ_INIT(&p_uhe->bsd_urb_list);
-                                       p_uhe++;
-                               }
-                               if (p_uhi) {
-                                       (p_uhi - 1)->desc.bNumEndpoints++;
-                               }
-                               nedesc++;
-                               break;
-
-                       case UDESC_INTERFACE:
-                               id = (void *)desc;
-                               if (id->bLength < sizeof(*id))
-                                       break;
-                               if (p_uhi) {
-                                       bcopy(id, &p_uhi->desc, sizeof(p_uhi->desc));
-                                       p_uhi->desc.bNumEndpoints = 0;
-                                       p_uhi->endpoint = p_uhe;
-                                       p_uhi->string = "";
-                                       p_uhi->bsd_iface_index = iface_index;
-                                       p_uhi++;
-                               }
-                               iface_no = id->bInterfaceNumber;
-                               niface_total++;
-                               if (iface_no_curr != iface_no) {
-                                       if (p_ui) {
-                                               p_ui->altsetting = p_uhi - 1;
-                                               p_ui->cur_altsetting = p_uhi - 1;
-                                               p_ui->num_altsetting = 1;
-                                               p_ui->bsd_iface_index = iface_index;
-                                               p_ui->linux_udev = udev;
-                                               p_ui++;
-                                       }
-                                       iface_no_curr = iface_no;
-                                       iface_index++;
-                               } else {
-                                       if (p_ui) {
-                                               (p_ui - 1)->num_altsetting++;
-                                       }
-                               }
-                               break;
-
-                       default:
-                               break;
-                       }
-               }
-
-               if (pass == 0) {
-
-                       size = (sizeof(*p_uhe) * nedesc) +
-                           (sizeof(*p_ui) * iface_index) +
-                           (sizeof(*p_uhi) * niface_total);
-
-                       p_uhe = malloc(size, M_USBDEV, M_WAITOK | M_ZERO);
-                       p_ui = (void *)(p_uhe + nedesc);
-                       p_uhi = (void *)(p_ui + iface_index);
-
-                       udev->linux_iface_start = p_ui;
-                       udev->linux_iface_end = p_ui + iface_index;
-                       udev->linux_endpoint_start = p_uhe;
-                       udev->linux_endpoint_end = p_uhe + nedesc;
-                       udev->devnum = device_get_unit(dev);
-                       bcopy(&udev->ddesc, &udev->descriptor,
-                           sizeof(udev->descriptor));
-                       bcopy(udev->ctrl_ep.edesc, &udev->ep0.desc,
-                           sizeof(udev->ep0.desc));
-               }
-       }
-       return (0);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_alloc_urb
- *
- * This function should always be used when you allocate an URB for
- * use with the USB Linux stack. In case of an isochronous transfer
- * you must specifiy the maximum number of "iso_packets" which you
- * plan to transfer per URB. This function is always blocking, and
- * "mem_flags" are not regarded like on Linux.
- *------------------------------------------------------------------------*/
-struct urb *
-usb_alloc_urb(uint16_t iso_packets, uint16_t mem_flags)
-{
-       struct urb *urb;
-       usb_size_t size;
-
-       if (iso_packets == 0xFFFF) {
-               /*
-                * FreeBSD specific magic value to ask for control transfer
-                * memory allocation:
-                */
-               size = sizeof(*urb) + sizeof(struct usb_device_request) + mem_flags;
-       } else {
-               size = sizeof(*urb) + (iso_packets * sizeof(urb->iso_frame_desc[0]));
-       }
-
-       urb = malloc(size, M_USBDEV, M_WAITOK | M_ZERO);
-       if (urb) {
-
-               cv_init(&urb->cv_wait, "URBWAIT");
-               if (iso_packets == 0xFFFF) {
-                       urb->setup_packet = (void *)(urb + 1);
-                       urb->transfer_buffer = (void *)(urb->setup_packet +
-                           sizeof(struct usb_device_request));
-               } else {
-                       urb->number_of_packets = iso_packets;
-               }
-       }
-       return (urb);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_find_host_endpoint
- *
- * The following function will return the Linux USB host endpoint
- * structure that matches the given endpoint type and endpoint
- * value. If no match is found, NULL is returned. This function is not
- * part of the Linux USB API and is only used internally.
- *------------------------------------------------------------------------*/
-struct usb_host_endpoint *
-usb_find_host_endpoint(struct usb_device *dev, uint8_t type, uint8_t ep)
-{
-       struct usb_host_endpoint *uhe;
-       struct usb_host_endpoint *uhe_end;
-       struct usb_host_interface *uhi;
-       struct usb_interface *ui;
-       uint8_t ea;
-       uint8_t at;
-       uint8_t mask;
-
-       if (dev == NULL) {
-               return (NULL);
-       }
-       if (type == UE_CONTROL) {
-               mask = UE_ADDR;
-       } else {
-               mask = (UE_DIR_IN | UE_DIR_OUT | UE_ADDR);
-       }
-
-       ep &= mask;
-
-       /*
-        * Iterate over all the interfaces searching the selected alternate
-        * setting only, and all belonging endpoints.
-        */
-       for (ui = dev->linux_iface_start;
-           ui != dev->linux_iface_end;
-           ui++) {
-               uhi = ui->cur_altsetting;
-               if (uhi) {
-                       uhe_end = uhi->endpoint + uhi->desc.bNumEndpoints;
-                       for (uhe = uhi->endpoint;
-                           uhe != uhe_end;
-                           uhe++) {
-                               ea = uhe->desc.bEndpointAddress;
-                               at = uhe->desc.bmAttributes;
-
-                               if (((ea & mask) == ep) &&
-                                   ((at & UE_XFERTYPE) == type)) {
-                                       return (uhe);
-                               }
-                       }
-               }
-       }
-
-       if ((type == UE_CONTROL) && ((ep & UE_ADDR) == 0)) {
-               return (&dev->ep0);
-       }
-       return (NULL);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_altnum_to_altsetting
- *
- * The following function returns a pointer to an alternate setting by
- * index given a "usb_interface" pointer. If the alternate setting by
- * index does not exist, NULL is returned. And alternate setting is a
- * variant of an interface, but usually with slightly different
- * characteristics.
- *------------------------------------------------------------------------*/
-struct usb_host_interface *
-usb_altnum_to_altsetting(const struct usb_interface *intf, uint8_t alt_index)
-{
-       if (alt_index >= intf->num_altsetting) {
-               return (NULL);
-       }
-       return (intf->altsetting + alt_index);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_ifnum_to_if
- *
- * The following function searches up an USB interface by
- * "bInterfaceNumber". If no match is found, NULL is returned.
- *------------------------------------------------------------------------*/
-struct usb_interface *
-usb_ifnum_to_if(struct usb_device *dev, uint8_t iface_no)
-{
-       struct usb_interface *p_ui;
-
-       for (p_ui = dev->linux_iface_start;
-           p_ui != dev->linux_iface_end;
-           p_ui++) {
-               if ((p_ui->num_altsetting > 0) &&
-                   (p_ui->altsetting->desc.bInterfaceNumber == iface_no)) {
-                       return (p_ui);
-               }
-       }
-       return (NULL);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_buffer_alloc
- *------------------------------------------------------------------------*/
-void   *
-usb_buffer_alloc(struct usb_device *dev, usb_size_t size, uint16_t mem_flags, uint8_t *dma_addr)
-{
-       return (malloc(size, M_USBDEV, M_WAITOK | M_ZERO));
-}
-
-/*------------------------------------------------------------------------*
- *     usbd_get_intfdata
- *------------------------------------------------------------------------*/
-void   *
-usbd_get_intfdata(struct usb_interface *intf)
-{
-       return (intf->bsd_priv_sc);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_linux_register
- *
- * The following function is used by the "USB_DRIVER_EXPORT()" macro,
- * and is used to register a Linux USB driver, so that its
- * "usb_device_id" structures gets searched a probe time. This
- * function is not part of the Linux USB API, and is for internal use
- * only.
- *------------------------------------------------------------------------*/
-void
-usb_linux_register(void *arg)
-{
-       struct usb_driver *drv = arg;
-
-       mtx_lock(&Giant);
-       LIST_INSERT_HEAD(&usb_linux_driver_list, drv, linux_driver_list);
-       mtx_unlock(&Giant);
-
-       usb_needs_explore_all();
-}
-
-/*------------------------------------------------------------------------*
- *     usb_linux_deregister
- *
- * The following function is used by the "USB_DRIVER_EXPORT()" macro,
- * and is used to deregister a Linux USB driver. This function will
- * ensure that all driver instances belonging to the Linux USB device
- * driver in question, gets detached before the driver is
- * unloaded. This function is not part of the Linux USB API, and is
- * for internal use only.
- *------------------------------------------------------------------------*/
-void
-usb_linux_deregister(void *arg)
-{
-       struct usb_driver *drv = arg;
-       struct usb_linux_softc *sc;
-
-repeat:
-       mtx_lock(&Giant);
-       LIST_FOREACH(sc, &usb_linux_attached_list, sc_attached_list) {
-               if (sc->sc_udrv == drv) {
-                       mtx_unlock(&Giant);
-                       device_detach(sc->sc_fbsd_dev);
-                       goto repeat;
-               }
-       }
-       LIST_REMOVE(drv, linux_driver_list);
-       mtx_unlock(&Giant);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_linux_free_device
- *
- * The following function is only used by the FreeBSD USB stack, to
- * cleanup and free memory after that a Linux USB device was attached.
- *------------------------------------------------------------------------*/
-void
-usb_linux_free_device(struct usb_device *dev)
-{
-       struct usb_host_endpoint *uhe;
-       struct usb_host_endpoint *uhe_end;
-       int err;
-
-       uhe = dev->linux_endpoint_start;
-       uhe_end = dev->linux_endpoint_end;
-       while (uhe != uhe_end) {
-               err = usb_setup_endpoint(dev, uhe, 0);
-               uhe++;
-       }
-       err = usb_setup_endpoint(dev, &dev->ep0, 0);
-       free(dev->linux_endpoint_start, M_USBDEV);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_buffer_free
- *------------------------------------------------------------------------*/
-void
-usb_buffer_free(struct usb_device *dev, usb_size_t size,
-    void *addr, uint8_t dma_addr)
-{
-       free(addr, M_USBDEV);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_free_urb
- *------------------------------------------------------------------------*/
-void
-usb_free_urb(struct urb *urb)
-{
-       if (urb == NULL) {
-               return;
-       }
-       /* make sure that the current URB is not active */
-       usb_kill_urb(urb);
-
-       /* destroy condition variable */
-       cv_destroy(&urb->cv_wait);
-
-       /* just free it */
-       free(urb, M_USBDEV);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_init_urb
- *
- * The following function can be used to initialize a custom URB. It
- * is not recommended to use this function. Use "usb_alloc_urb()"
- * instead.
- *------------------------------------------------------------------------*/
-void
-usb_init_urb(struct urb *urb)
-{
-       if (urb == NULL) {
-               return;
-       }
-       memset(urb, 0, sizeof(*urb));
-}
-
-/*------------------------------------------------------------------------*
- *     usb_kill_urb
- *------------------------------------------------------------------------*/
-void
-usb_kill_urb(struct urb *urb)
-{
-       usb_unlink_urb_sub(urb, 1);
-}
-
-/*------------------------------------------------------------------------*
- *     usb_set_intfdata
- *
- * The following function sets the per Linux USB interface private
- * data pointer. It is used by most Linux USB device drivers.
- *------------------------------------------------------------------------*/
-void
-usb_set_intfdata(struct usb_interface *intf, void *data)
-{
-       intf->bsd_priv_sc = data;
-}
-
-/*------------------------------------------------------------------------*
- *     usb_linux_cleanup_interface
- *
- * The following function will release all FreeBSD USB transfers
- * associated with a Linux USB interface. It is for internal use only.
- *------------------------------------------------------------------------*/
-static void
-usb_linux_cleanup_interface(struct usb_device *dev, struct usb_interface *iface)
-{
-       struct usb_host_interface *uhi;
-       struct usb_host_interface *uhi_end;
-       struct usb_host_endpoint *uhe;
-       struct usb_host_endpoint *uhe_end;
-       int err;
-
-       uhi = iface->altsetting;
-       uhi_end = iface->altsetting + iface->num_altsetting;
-       while (uhi != uhi_end) {
-               uhe = uhi->endpoint;
-               uhe_end = uhi->endpoint + uhi->desc.bNumEndpoints;
-               while (uhe != uhe_end) {
-                       err = usb_setup_endpoint(dev, uhe, 0);
-                       uhe++;
-               }
-               uhi++;
-       }
-}
-
-/*------------------------------------------------------------------------*
- *     usb_linux_wait_complete
- *
- * The following function is used by "usb_start_wait_urb()" to wake it
- * up, when an USB transfer has finished.
- *------------------------------------------------------------------------*/
-static void
-usb_linux_wait_complete(struct urb *urb)
-{
-       if (urb->transfer_flags & URB_IS_SLEEPING) {
-               cv_signal(&urb->cv_wait);
-       }
-       urb->transfer_flags &= ~URB_WAIT_WAKEUP;
-}
-
-/*------------------------------------------------------------------------*
- *     usb_linux_complete
- *------------------------------------------------------------------------*/
-static void
-usb_linux_complete(struct usb_xfer *xfer)
-{
-       struct urb *urb;
-
-       urb = usbd_xfer_get_priv(xfer);
-       usbd_xfer_set_priv(xfer, NULL);
-       if (urb->complete) {
-               (urb->complete) (urb);
-       }
-}
-
-/*------------------------------------------------------------------------*
- *     usb_linux_isoc_callback
- *
- * The following is the FreeBSD isochronous USB callback. Isochronous
- * frames are USB packets transferred 1000 or 8000 times per second,
- * depending on whether a full- or high- speed USB transfer is
- * used.
- *------------------------------------------------------------------------*/
-static void
-usb_linux_isoc_callback(struct usb_xfer *xfer, usb_error_t error)
-{
-       usb_frlength_t max_frame = xfer->max_frame_size;
-       usb_frlength_t offset;
-       usb_frcount_t x;
-       struct urb *urb = usbd_xfer_get_priv(xfer);
-       struct usb_host_endpoint *uhe = usbd_xfer_softc(xfer);
-       struct usb_iso_packet_descriptor *uipd;
-
-       DPRINTF("\n");
-
-       switch (USB_GET_STATE(xfer)) {
-       case USB_ST_TRANSFERRED:
-
-               if (urb->bsd_isread) {
-
-                       /* copy in data with regard to the URB */
-
-                       offset = 0;
-
-                       for (x = 0; x < urb->number_of_packets; x++) {
-                               uipd = urb->iso_frame_desc + x;
-                               if (uipd->length > xfer->frlengths[x]) {
-                                       if (urb->transfer_flags & URB_SHORT_NOT_OK) {
-                                               /* XXX should be EREMOTEIO */
-                                               uipd->status = -EPIPE;
-                                       } else {
-                                               uipd->status = 0;
-                                       }
-                               } else {
-                                       uipd->status = 0;
-                               }
-                               uipd->actual_length = xfer->frlengths[x];
-                               if (!xfer->flags.ext_buffer) {
-                                       usbd_copy_out(xfer->frbuffers, offset,
-                                           USB_ADD_BYTES(urb->transfer_buffer,
-                                           uipd->offset), uipd->actual_length);
-                               }
-                               offset += max_frame;
-                       }
-               } else {
-                       for (x = 0; x < urb->number_of_packets; x++) {
-                               uipd = urb->iso_frame_desc + x;
-                               uipd->actual_length = xfer->frlengths[x];
-                               uipd->status = 0;
-                       }
-               }
-
-               urb->actual_length = xfer->actlen;
-
-               /* check for short transfer */
-               if (xfer->actlen < xfer->sumlen) {
-                       /* short transfer */
-                       if (urb->transfer_flags & URB_SHORT_NOT_OK) {
-                               /* XXX should be EREMOTEIO */
-                               urb->status = -EPIPE;
-                       } else {
-                               urb->status = 0;
-                       }
-               } else {
-                       /* success */
-                       urb->status = 0;
-               }
-
-               /* call callback */
-               usb_linux_complete(xfer);
-
-       case USB_ST_SETUP:
-tr_setup:
-
-               if (xfer->priv_fifo == NULL) {
-
-                       /* get next transfer */
-                       urb = TAILQ_FIRST(&uhe->bsd_urb_list);
-                       if (urb == NULL) {
-                               /* nothing to do */
-                               return;
-                       }
-                       TAILQ_REMOVE(&uhe->bsd_urb_list, urb, bsd_urb_list);
-                       urb->bsd_urb_list.tqe_prev = NULL;
-
-                       x = xfer->max_frame_count;
-                       if (urb->number_of_packets > x) {
-                               /* XXX simply truncate the transfer */
-                               urb->number_of_packets = x;
-                       }
-               } else {
-                       DPRINTF("Already got a transfer\n");
-
-                       /* already got a transfer (should not happen) */
-                       urb = usbd_xfer_get_priv(xfer);
-               }
-
-               urb->bsd_isread = (uhe->desc.bEndpointAddress & UE_DIR_IN) ? 1 : 0;
-
-               if (xfer->flags.ext_buffer) {
-                       /* set virtual address to load */
-                       usbd_xfer_set_frame_data(xfer, 0, urb->transfer_buffer, 0);
-               }
-               if (!(urb->bsd_isread)) {
-
-                       /* copy out data with regard to the URB */
-
-                       offset = 0;
-
-                       for (x = 0; x < urb->number_of_packets; x++) {
-                               uipd = urb->iso_frame_desc + x;
-                               usbd_xfer_set_frame_len(xfer, x, uipd->length);
-                               if (!xfer->flags.ext_buffer) {
-                                       usbd_copy_in(xfer->frbuffers, offset,
-                                           USB_ADD_BYTES(urb->transfer_buffer,
-                                           uipd->offset), uipd->length);
-                               }
-                               offset += uipd->length;
-                       }
-               } else {
-
-                       /*
-                        * compute the transfer length into the "offset"
-                        * variable
-                        */
-
-                       offset = urb->number_of_packets * max_frame;
-
-                       /* setup "frlengths" array */
-
-                       for (x = 0; x < urb->number_of_packets; x++) {
-                               uipd = urb->iso_frame_desc + x;
-                               usbd_xfer_set_frame_len(xfer, x, max_frame);
-                       }
-               }
-               usbd_xfer_set_priv(xfer, urb);
-               xfer->flags.force_short_xfer = 0;
-               xfer->timeout = urb->timeout;
-               xfer->nframes = urb->number_of_packets;
-               usbd_transfer_submit(xfer);
-               return;
-
-       default:                        /* Error */
-               if (xfer->error == USB_ERR_CANCELLED) {
-                       urb->status = -ECONNRESET;
-               } else {
-                       urb->status = -EPIPE;   /* stalled */
-               }
-
-               /* Set zero for "actual_length" */
-               urb->actual_length = 0;
-
-               /* Set zero for "actual_length" */
-               for (x = 0; x < urb->number_of_packets; x++) {
-                       urb->iso_frame_desc[x].actual_length = 0;
-                       urb->iso_frame_desc[x].status = urb->status;
-               }
-
-               /* call callback */
-               usb_linux_complete(xfer);
-
-               if (xfer->error == USB_ERR_CANCELLED) {
-                       /* we need to return in this case */
-                       return;
-               }
-               goto tr_setup;
-
-       }
-}
-
-/*------------------------------------------------------------------------*
- *     usb_linux_non_isoc_callback
- *
- * The following is the FreeBSD BULK/INTERRUPT and CONTROL USB
- * callback. It dequeues Linux USB stack compatible URB's, transforms
- * the URB fields into a FreeBSD USB transfer, and defragments the USB
- * transfer as required. When the transfer is complete the "complete"
- * callback is called.
- *------------------------------------------------------------------------*/
-static void
-usb_linux_non_isoc_callback(struct usb_xfer *xfer, usb_error_t error)
-{
-       enum {
-               REQ_SIZE = sizeof(struct usb_device_request)
-       };
-       struct urb *urb = usbd_xfer_get_priv(xfer);
-       struct usb_host_endpoint *uhe = usbd_xfer_softc(xfer);
-       uint8_t *ptr;
-       usb_frlength_t max_bulk = usbd_xfer_max_len(xfer);
-       uint8_t data_frame = xfer->flags_int.control_xfr ? 1 : 0;
-
-       DPRINTF("\n");
-
-       switch (USB_GET_STATE(xfer)) {
-       case USB_ST_TRANSFERRED:
-
-               if (xfer->flags_int.control_xfr) {
-
-                       /* don't transfer the setup packet again: */
-
-                       usbd_xfer_set_frame_len(xfer, 0, 0);
-               }
-               if (urb->bsd_isread && (!xfer->flags.ext_buffer)) {
-                       /* copy in data with regard to the URB */
-                       usbd_copy_out(xfer->frbuffers + data_frame, 0,
-                           urb->bsd_data_ptr, xfer->frlengths[data_frame]);
-               }
-               urb->bsd_length_rem -= xfer->frlengths[data_frame];
-               urb->bsd_data_ptr += xfer->frlengths[data_frame];
-               urb->actual_length += xfer->frlengths[data_frame];
-
-               /* check for short transfer */
-               if (xfer->actlen < xfer->sumlen) {
-                       urb->bsd_length_rem = 0;
-
-                       /* short transfer */
-                       if (urb->transfer_flags & URB_SHORT_NOT_OK) {
-                               urb->status = -EPIPE;
-                       } else {
-                               urb->status = 0;
-                       }
-               } else {
-                       /* check remainder */
-                       if (urb->bsd_length_rem > 0) {
-                               goto setup_bulk;
-                       }
-                       /* success */
-                       urb->status = 0;
-               }
-
-               /* call callback */
-               usb_linux_complete(xfer);
-
-       case USB_ST_SETUP:
-tr_setup:
-               /* get next transfer */
-               urb = TAILQ_FIRST(&uhe->bsd_urb_list);
-               if (urb == NULL) {
-                       /* nothing to do */
-                       return;
-               }
-               TAILQ_REMOVE(&uhe->bsd_urb_list, urb, bsd_urb_list);
-               urb->bsd_urb_list.tqe_prev = NULL;
-
-               usbd_xfer_set_priv(xfer, urb);
-               xfer->flags.force_short_xfer = 0;
-               xfer->timeout = urb->timeout;
-
-               if (xfer->flags_int.control_xfr) {
-
-                       /*
-                        * USB control transfers need special handling.
-                        * First copy in the header, then copy in data!
-                        */
-                       if (!xfer->flags.ext_buffer) {
-                               usbd_copy_in(xfer->frbuffers, 0,
-                                   urb->setup_packet, REQ_SIZE);
-                               usbd_xfer_set_frame_len(xfer, 0, REQ_SIZE);
-                       } else {
-                               /* set virtual address to load */
-                               usbd_xfer_set_frame_data(xfer, 0,
-                                   urb->setup_packet, REQ_SIZE);
-                       }
-
-                       ptr = urb->setup_packet;
-
-                       /* setup data transfer direction and length */
-                       urb->bsd_isread = (ptr[0] & UT_READ) ? 1 : 0;
-                       urb->bsd_length_rem = ptr[6] | (ptr[7] << 8);
-
-               } else {
-
-                       /* setup data transfer direction */
-
-                       urb->bsd_length_rem = urb->transfer_buffer_length;
-                       urb->bsd_isread = (uhe->desc.bEndpointAddress &
-                           UE_DIR_IN) ? 1 : 0;
-               }
-
-               urb->bsd_data_ptr = urb->transfer_buffer;
-               urb->actual_length = 0;
-
-setup_bulk:
-               if (max_bulk > urb->bsd_length_rem) {
-                       max_bulk = urb->bsd_length_rem;
-               }
-               /* check if we need to force a short transfer */
-
-               if ((max_bulk == urb->bsd_length_rem) &&
-                   (urb->transfer_flags & URB_ZERO_PACKET) &&
-                   (!xfer->flags_int.control_xfr)) {
-                       xfer->flags.force_short_xfer = 1;
-               }
-               /* check if we need to copy in data */
-
-               if (xfer->flags.ext_buffer) {
-                       /* set virtual address to load */
-                       usbd_xfer_set_frame_data(xfer, data_frame,
-                           urb->bsd_data_ptr, max_bulk);
-               } else if (!urb->bsd_isread) {
-                       /* copy out data with regard to the URB */
-                       usbd_copy_in(xfer->frbuffers + data_frame, 0,
-                           urb->bsd_data_ptr, max_bulk);
-                       usbd_xfer_set_frame_len(xfer, data_frame, max_bulk);
-               }
-               if (xfer->flags_int.control_xfr) {
-                       if (max_bulk > 0) {
-                               xfer->nframes = 2;
-                       } else {
-                               xfer->nframes = 1;
-                       }
-               } else {
-                       xfer->nframes = 1;
-               }
-               usbd_transfer_submit(xfer);
-               return;
-
-       default:
-               if (xfer->error == USB_ERR_CANCELLED) {
-                       urb->status = -ECONNRESET;
-               } else {
-                       urb->status = -EPIPE;
-               }
-
-               /* Set zero for "actual_length" */
-               urb->actual_length = 0;
-
-               /* call callback */
-               usb_linux_complete(xfer);
-
-               if (xfer->error == USB_ERR_CANCELLED) {
-                       /* we need to return in this case */
-                       return;
-               }
-               goto tr_setup;
-       }
-}
-
-/*------------------------------------------------------------------------*
- *     usb_fill_bulk_urb
- *------------------------------------------------------------------------*/
-void
-usb_fill_bulk_urb(struct urb *urb, struct usb_device *udev,
-    struct usb_host_endpoint *uhe, void *buf,
-    int length, usb_complete_t callback, void *arg)
-{
-       urb->dev = udev;
-       urb->endpoint = uhe;
-       urb->transfer_buffer = buf;
-       urb->transfer_buffer_length = length;
-       urb->complete = callback;
-       urb->context = arg;
-}
-
-/*------------------------------------------------------------------------*
- *     usb_bulk_msg
- *
- * NOTE: This function can also be used for interrupt endpoints!
- *
- * Return values:
- *    0: Success
- * Else: Failure
- *------------------------------------------------------------------------*/
-int
-usb_bulk_msg(struct usb_device *udev, struct usb_host_endpoint *uhe,
-    void *data, int len, uint16_t *pactlen, usb_timeout_t timeout)
-{
-       struct urb *urb;
-       int err;
-
-       if (uhe == NULL)
-               return (-EINVAL);
-       if (len < 0)
-               return (-EINVAL);
-
-       err = usb_setup_endpoint(udev, uhe, 4096 /* bytes */);
-       if (err)
-               return (err);
-
-       urb = usb_alloc_urb(0, 0);
-       if (urb == NULL)
-               return (-ENOMEM);
-
-        usb_fill_bulk_urb(urb, udev, uhe, data, len,
-           usb_linux_wait_complete, NULL);
-
-       err = usb_start_wait_urb(urb, timeout, pactlen);
-
-       usb_free_urb(urb);
-
-       return (err);
-}
diff --git a/sys/dev/usb/usb_compat_linux.h b/sys/dev/usb/usb_compat_linux.h
deleted file mode 100644 (file)
index 1f00d4b..0000000
+++ /dev/null
@@ -1,310 +0,0 @@
-/* $FreeBSD$ */
-/*-
- * Copyright (c) 2007 Luigi Rizzo - Universita` di Pisa. All rights reserved.
- * Copyright (c) 2007 Hans Petter Selasky. 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, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- */
-
-#ifndef _USB_COMPAT_LINUX_H
-#define        _USB_COMPAT_LINUX_H
-
-struct usb_device;
-struct usb_interface;
-struct usb_driver;
-struct urb;
-
-typedef void *pm_message_t;
-typedef void (usb_complete_t)(struct urb *);
-
-#define        USB_MAX_FULL_SPEED_ISOC_FRAMES (60 * 1)
-#define        USB_MAX_HIGH_SPEED_ISOC_FRAMES (60 * 8)
-
-#define        USB_DEVICE_ID_MATCH_DEVICE \
-       (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT)
-
-#define        USB_DEVICE(vend,prod) \
-       .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = (vend), \
-       .idProduct = (prod)
-
-/* The "usb_driver" structure holds the Linux USB device driver
- * callbacks, and a pointer to device ID's which this entry should
- * match against. Usually this entry is exposed to the USB emulation
- * layer using the "USB_DRIVER_EXPORT()" macro, which is defined
- * below.
- */
-struct usb_driver {
-       const char *name;
-
-       int     (*probe) (struct usb_interface *intf,
-               const   struct usb_device_id *id);
-
-       void    (*disconnect) (struct usb_interface *intf);
-
-       int     (*ioctl) (struct usb_interface *intf, unsigned int code,
-               void  *buf);
-
-       int     (*suspend) (struct usb_interface *intf, pm_message_t message);
-       int     (*resume) (struct usb_interface *intf);
-
-       const struct usb_device_id *id_table;
-
-       void    (*shutdown) (struct usb_interface *intf);
-
-       LIST_ENTRY(usb_driver) linux_driver_list;
-};
-
-#define        USB_DRIVER_EXPORT(id,p_usb_drv) \
-  SYSINIT(id,SI_SUB_KLD,SI_ORDER_FIRST,usb_linux_register,p_usb_drv); \
-  SYSUNINIT(id,SI_SUB_KLD,SI_ORDER_ANY,usb_linux_deregister,p_usb_drv)
-
-#define        USB_DT_ENDPOINT_SIZE            7
-#define        USB_DT_ENDPOINT_AUDIO_SIZE      9
-
-/*
- * Endpoints
- */
-#define        USB_ENDPOINT_NUMBER_MASK        0x0f    /* in bEndpointAddress */
-#define        USB_ENDPOINT_DIR_MASK           0x80
-
-#define        USB_ENDPOINT_XFERTYPE_MASK      0x03    /* in bmAttributes */
-#define        USB_ENDPOINT_XFER_CONTROL       0
-#define        USB_ENDPOINT_XFER_ISOC          1
-#define        USB_ENDPOINT_XFER_BULK          2
-#define        USB_ENDPOINT_XFER_INT           3
-#define        USB_ENDPOINT_MAX_ADJUSTABLE     0x80
-
-/* CONTROL REQUEST SUPPORT */
-
-/*
- * Definition of direction mask for
- * "bEndpointAddress" and "bmRequestType":
- */
-#define        USB_DIR_MASK                    0x80
-#define        USB_DIR_OUT                     0x00    /* write to USB device */
-#define        USB_DIR_IN                      0x80    /* read from USB device */
-
-/*
- * Definition of type mask for
- * "bmRequestType":
- */
-#define        USB_TYPE_MASK                   (0x03 << 5)
-#define        USB_TYPE_STANDARD               (0x00 << 5)
-#define        USB_TYPE_CLASS                  (0x01 << 5)
-#define        USB_TYPE_VENDOR                 (0x02 << 5)
-#define        USB_TYPE_RESERVED               (0x03 << 5)
-
-/*
- * Definition of receiver mask for
- * "bmRequestType":
- */
-#define        USB_RECIP_MASK                  0x1f
-#define        USB_RECIP_DEVICE                0x00
-#define        USB_RECIP_INTERFACE             0x01
-#define        USB_RECIP_ENDPOINT              0x02
-#define        USB_RECIP_OTHER                 0x03
-
-/*
- * Definition of standard request values for
- * "bRequest":
- */
-#define        USB_REQ_GET_STATUS              0x00
-#define        USB_REQ_CLEAR_FEATURE           0x01
-#define        USB_REQ_SET_FEATURE             0x03
-#define        USB_REQ_SET_ADDRESS             0x05
-#define        USB_REQ_GET_DESCRIPTOR          0x06
-#define        USB_REQ_SET_DESCRIPTOR          0x07
-#define        USB_REQ_GET_CONFIGURATION       0x08
-#define        USB_REQ_SET_CONFIGURATION       0x09
-#define        USB_REQ_GET_INTERFACE           0x0A
-#define        USB_REQ_SET_INTERFACE           0x0B
-#define        USB_REQ_SYNCH_FRAME             0x0C
-
-#define        USB_REQ_SET_ENCRYPTION          0x0D    /* Wireless USB */
-#define        USB_REQ_GET_ENCRYPTION          0x0E
-#define        USB_REQ_SET_HANDSHAKE           0x0F
-#define        USB_REQ_GET_HANDSHAKE           0x10
-#define        USB_REQ_SET_CONNECTION          0x11
-#define        USB_REQ_SET_SECURITY_DATA       0x12
-#define        USB_REQ_GET_SECURITY_DATA       0x13
-#define        USB_REQ_SET_WUSB_DATA           0x14
-#define        USB_REQ_LOOPBACK_DATA_WRITE     0x15
-#define        USB_REQ_LOOPBACK_DATA_READ      0x16
-#define        USB_REQ_SET_INTERFACE_DS        0x17
-
-/*
- * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and
- * are read as a bit array returned by USB_REQ_GET_STATUS.  (So there
- * are at most sixteen features of each type.)
- */
-#define        USB_DEVICE_SELF_POWERED         0       /* (read only) */
-#define        USB_DEVICE_REMOTE_WAKEUP        1       /* dev may initiate wakeup */
-#define        USB_DEVICE_TEST_MODE            2       /* (wired high speed only) */
-#define        USB_DEVICE_BATTERY              2       /* (wireless) */
-#define        USB_DEVICE_B_HNP_ENABLE         3       /* (otg) dev may initiate HNP */
-#define        USB_DEVICE_WUSB_DEVICE          3       /* (wireless) */
-#define        USB_DEVICE_A_HNP_SUPPORT        4       /* (otg) RH port supports HNP */
-#define        USB_DEVICE_A_ALT_HNP_SUPPORT    5       /* (otg) other RH port does */
-#define        USB_DEVICE_DEBUG_MODE           6       /* (special devices only) */
-
-#define        USB_ENDPOINT_HALT               0       /* IN/OUT will STALL */
-
-#define        PIPE_ISOCHRONOUS                0x01    /* UE_ISOCHRONOUS */
-#define        PIPE_INTERRUPT                  0x03    /* UE_INTERRUPT */
-#define        PIPE_CONTROL                    0x00    /* UE_CONTROL */
-#define        PIPE_BULK                       0x02    /* UE_BULK */
-
-/* Whenever Linux references an USB endpoint:
- * a) to initialize "urb->endpoint"
- * b) second argument passed to "usb_control_msg()"
- *
- * Then it uses one of the following macros. The "endpoint" argument
- * is the physical endpoint value masked by 0xF. The "dev" argument
- * is a pointer to "struct usb_device".
- */
-#define        usb_sndctrlpipe(dev,endpoint) \
-  usb_find_host_endpoint(dev, PIPE_CONTROL, (endpoint) | USB_DIR_OUT)
-
-#define        usb_rcvctrlpipe(dev,endpoint) \
-  usb_find_host_endpoint(dev, PIPE_CONTROL, (endpoint) | USB_DIR_IN)
-
-#define        usb_sndisocpipe(dev,endpoint) \
-  usb_find_host_endpoint(dev, PIPE_ISOCHRONOUS, (endpoint) | USB_DIR_OUT)
-
-#define        usb_rcvisocpipe(dev,endpoint) \
-  usb_find_host_endpoint(dev, PIPE_ISOCHRONOUS, (endpoint) | USB_DIR_IN)
-
-#define        usb_sndbulkpipe(dev,endpoint) \
-  usb_find_host_endpoint(dev, PIPE_BULK, (endpoint) | USB_DIR_OUT)
-
-#define        usb_rcvbulkpipe(dev,endpoint) \
-  usb_find_host_endpoint(dev, PIPE_BULK, (endpoint) | USB_DIR_IN)
-
-#define        usb_sndintpipe(dev,endpoint) \
-  usb_find_host_endpoint(dev, PIPE_INTERRUPT, (endpoint) | USB_DIR_OUT)
-
-#define        usb_rcvintpipe(dev,endpoint) \
-  usb_find_host_endpoint(dev, PIPE_INTERRUPT, (endpoint) | USB_DIR_IN)
-
-/*
- * The following structure is used to extend "struct urb" when we are
- * dealing with an isochronous endpoint. It contains information about
- * the data offset and data length of an isochronous packet.
- * The "actual_length" field is updated before the "complete"
- * callback in the "urb" structure is called.
- */
-struct usb_iso_packet_descriptor {
-       uint32_t offset;                /* depreciated buffer offset (the
-                                        * packets are usually back to back) */
-       uint16_t length;                /* expected length */
-       uint16_t actual_length;
-        int16_t status;                /* transfer status */
-};
-
-/*
- * The following structure holds various information about an USB
- * transfer. This structure is used for all kinds of USB transfers.
- *
- * URB is short for USB Request Block.
- */
-struct urb {
-       TAILQ_ENTRY(urb) bsd_urb_list;
-       struct cv cv_wait;
-
-       struct usb_device *dev;         /* (in) pointer to associated device */
-       struct usb_host_endpoint *endpoint;     /* (in) pipe pointer */
-       uint8_t *setup_packet;          /* (in) setup packet (control only) */
-       uint8_t *bsd_data_ptr;
-       void   *transfer_buffer;        /* (in) associated data buffer */
-       void   *context;                /* (in) context for completion */
-       usb_complete_t *complete;       /* (in) completion routine */
-
-       usb_size_t transfer_buffer_length;/* (in) data buffer length */
-       usb_size_t bsd_length_rem;
-       usb_size_t actual_length;       /* (return) actual transfer length */
-       usb_timeout_t timeout;          /* FreeBSD specific */
-
-       uint16_t transfer_flags;        /* (in) */
-#define        URB_SHORT_NOT_OK        0x0001  /* report short transfers like errors */
-#define        URB_ISO_ASAP            0x0002  /* ignore "start_frame" field */
-#define        URB_ZERO_PACKET         0x0004  /* the USB transfer ends with a short
-                                        * packet */
-#define        URB_NO_TRANSFER_DMA_MAP 0x0008  /* "transfer_dma" is valid on submit */
-#define        URB_WAIT_WAKEUP         0x0010  /* custom flags */
-#define        URB_IS_SLEEPING         0x0020  /* custom flags */
-
-       usb_frcount_t start_frame;      /* (modify) start frame (ISO) */
-       usb_frcount_t number_of_packets;        /* (in) number of ISO packets */
-       uint16_t interval;              /* (modify) transfer interval
-                                        * (INT/ISO) */
-       uint16_t error_count;           /* (return) number of ISO errors */
-       int16_t status;                 /* (return) status */
-
-       uint8_t setup_dma;              /* (in) not used on FreeBSD */
-       uint8_t transfer_dma;           /* (in) not used on FreeBSD */
-       uint8_t bsd_isread;
-       uint8_t kill_count;             /* FreeBSD specific */
-
-       struct usb_iso_packet_descriptor iso_frame_desc[];      /* (in) ISO ONLY */
-};
-
-/* various prototypes */
-
-int    usb_submit_urb(struct urb *urb, uint16_t mem_flags);
-int    usb_unlink_urb(struct urb *urb);
-int    usb_clear_halt(struct usb_device *dev, struct usb_host_endpoint *uhe);
-int    usb_control_msg(struct usb_device *dev, struct usb_host_endpoint *ep,
-           uint8_t request, uint8_t requesttype, uint16_t value,
-           uint16_t index, void *data, uint16_t size, usb_timeout_t timeout);
-int    usb_set_interface(struct usb_device *dev, uint8_t ifnum,
-           uint8_t alternate);
-int    usb_setup_endpoint(struct usb_device *dev,
-           struct usb_host_endpoint *uhe, usb_frlength_t bufsize);
-
-struct usb_host_endpoint *usb_find_host_endpoint(struct usb_device *dev,
-           uint8_t type, uint8_t ep);
-struct urb *usb_alloc_urb(uint16_t iso_packets, uint16_t mem_flags);
-struct usb_host_interface *usb_altnum_to_altsetting(
-           const struct usb_interface *intf, uint8_t alt_index);
-struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, uint8_t iface_no);
-
-void   *usb_buffer_alloc(struct usb_device *dev, usb_size_t size,
-           uint16_t mem_flags, uint8_t *dma_addr);
-void   *usbd_get_intfdata(struct usb_interface *intf);
-
-void   usb_buffer_free(struct usb_device *dev, usb_size_t size, void *addr, uint8_t dma_addr);
-void   usb_free_urb(struct urb *urb);
-void   usb_init_urb(struct urb *urb);
-void   usb_kill_urb(struct urb *urb);
-void   usb_set_intfdata(struct usb_interface *intf, void *data);
-void   usb_linux_register(void *arg);
-void   usb_linux_deregister(void *arg);
-
-void   usb_fill_bulk_urb(struct urb *, struct usb_device *,
-           struct usb_host_endpoint *, void *, int, usb_complete_t, void *);
-int    usb_bulk_msg(struct usb_device *, struct usb_host_endpoint *,
-           void *, int, uint16_t *, usb_timeout_t);
-
-#define        interface_to_usbdev(intf) (intf)->linux_udev
-#define        interface_to_bsddev(intf) (intf)->linux_udev
-
-#endif                                 /* _USB_COMPAT_LINUX_H */
index 13e2c145400b666ce931c86b0c5053a6adcde434..8940171459a0c223667f2274917442ee362d333b 100644 (file)
@@ -506,8 +506,8 @@ usb_unconfigure(struct usb_device *udev, uint8_t flag)
 
 #if USB_HAVE_COMPAT_LINUX
        /* free Linux compat device, if any */
-       if (udev->linux_endpoint_start) {
-               usb_linux_free_device(udev);
+       if (udev->linux_endpoint_start != NULL) {
+               usb_linux_free_device_p(udev);
                udev->linux_endpoint_start = NULL;
        }
 #endif
index d08e7f84afd866c878275f1162d78d8aa5d99ab0..24c13f9f5dc19de49db114f2ca87ab290e5724d8 100644 (file)
@@ -59,6 +59,9 @@
 /* function prototypes */
 static usb_handle_req_t usb_temp_get_desc_w;
 static usb_temp_setup_by_index_t usb_temp_setup_by_index_w;
+#if USB_HAVE_COMPAT_LINUX
+static usb_linux_free_device_t usb_linux_free_device_w;
+#endif
 static usb_temp_unsetup_t usb_temp_unsetup_w;
 static usb_test_quirk_t usb_test_quirk_w;
 static usb_quirk_ioctl_t usb_quirk_ioctl_w;
@@ -66,6 +69,9 @@ static usb_quirk_ioctl_t usb_quirk_ioctl_w;
 /* global variables */
 usb_handle_req_t *usb_temp_get_desc_p = &usb_temp_get_desc_w;
 usb_temp_setup_by_index_t *usb_temp_setup_by_index_p = &usb_temp_setup_by_index_w;
+#if USB_HAVE_COMPAT_LINUX
+usb_linux_free_device_t *usb_linux_free_device_p = &usb_linux_free_device_w;
+#endif
 usb_temp_unsetup_t *usb_temp_unsetup_p = &usb_temp_unsetup_w;
 usb_test_quirk_t *usb_test_quirk_p = &usb_test_quirk_w;
 usb_quirk_ioctl_t *usb_quirk_ioctl_p = &usb_quirk_ioctl_w;
@@ -103,6 +109,14 @@ usb_temp_unsetup_w(struct usb_device *udev)
        udev->usb_template_ptr = NULL;
 }
 
+#if USB_HAVE_COMPAT_LINUX
+static void
+usb_linux_free_device_w(struct usb_device *udev)
+{
+       /* NOP */
+}
+#endif
+
 void
 usb_quirk_unload(void *arg)
 {
@@ -147,3 +161,19 @@ usb_bus_unload(void *arg)
 
        pause("WAIT", hz);
 }
+
+#if USB_HAVE_COMPAT_LINUX
+void
+usb_linux_unload(void *arg)
+{
+       /* reset function pointers */
+
+       usb_linux_free_device_p = &usb_linux_free_device_w;
+  
+       /* wait for CPU to exit the loaded functions, if any */
+
+       /* XXX this is a tradeoff */
+
+       pause("WAIT", hz);
+}
+#endif
index 568494204c17ca07f3b7fc341220ebd8a63d8c5e..e52c46fb75b8db26223349cfa435389ffc4c9716 100644 (file)
@@ -42,11 +42,13 @@ typedef uint8_t             (usb_test_quirk_t)(const struct usbd_lookup_info *info,
 typedef int            (usb_quirk_ioctl_t)(unsigned long cmd, caddr_t data,
                            int fflag, struct thread *td);
 typedef void           (usb_temp_unsetup_t)(struct usb_device *udev);
+typedef void           (usb_linux_free_device_t)(struct usb_device *udev);
 
 /* global function pointers */
 
 extern usb_handle_req_t *usb_temp_get_desc_p;
 extern usb_temp_setup_by_index_t *usb_temp_setup_by_index_p;
+extern usb_linux_free_device_t *usb_linux_free_device_p;
 extern usb_temp_unsetup_t *usb_temp_unsetup_p;
 extern usb_test_quirk_t *usb_test_quirk_p;
 extern usb_quirk_ioctl_t *usb_quirk_ioctl_p;
@@ -54,6 +56,7 @@ extern devclass_t usb_devclass_ptr;
 
 /* function prototypes */
 
+void   usb_linux_unload(void *);
 void   usb_temp_unload(void *);
 void   usb_quirk_unload(void *);
 void   usb_bus_unload(void *);
index 8df1ffc280056970cd65045c69d13fd7b6c29739..57a7c6030732e74b3b31a6d7aa6221208fcc818f 100644 (file)
@@ -10,5 +10,6 @@ SRCS+=  iw_cxgb_ev.c iw_cxgb_mem.c iw_cxgb_dbg.c iw_cxgb_cq.c
 SRCS+=  bus_if.h device_if.h opt_sched.h pci_if.h pcib_if.h opt_ktr.h
 SRCS+=  opt_inet.h opt_ofed.h vnode_if.h
 CFLAGS+= -I${CXGB} -I${.CURDIR}/../../../ofed/include -DLINUX_TYPES_DEFINED
+CFLAGS+= -I${.CURDIR}/../../../compat/linuxkpi/common/include
 
 .include <bsd.kmod.mk>
index e1f362aa0b975c572405ba39a4be7e8c5ff95cb0..d4c041f009106a075dcdb96e246d0f7403d84fdc 100644 (file)
@@ -24,5 +24,6 @@ SRCS+=        resource.c
 SRCS+= vnode_if.h
 
 CFLAGS+= -I${CXGBE} -I${.CURDIR}/../../../ofed/include -DLINUX_TYPES_DEFINED
+CFLAGS+= -I${.CURDIR}/../../../compat/linuxkpi/common/include
 
 .include <bsd.kmod.mk>
index 60ec8dd3cace89271023eb3856f829e17ca03268..490a11a879b3b674ef60a8e0855cc3ce618827ed 100644 (file)
@@ -1,6 +1,5 @@
 # $FreeBSD$
 .PATH:  ${.CURDIR}/../../ofed/drivers/infiniband/core
-.PATH:  ${.CURDIR}/../../ofed/include/linux
 
 KMOD=  ibcore
 SRCS=  addr.c iwcm.c sa_query.c ucma.c uverbs_cmd.c \
@@ -12,8 +11,8 @@ SRCS= addr.c iwcm.c sa_query.c ucma.c uverbs_cmd.c \
        opt_inet.h opt_inet6.h
 
 CFLAGS+= -I${.CURDIR}/../../ofed/drivers/infiniband/core
-CFLAGS+= -I${.CURDIR}/../mlx4ib
-CFLAGS+= -I${.CURDIR}/../../ofed/include/
+CFLAGS+= -I${.CURDIR}/../../ofed/include
+CFLAGS+= -I${.CURDIR}/../../compat/linuxkpi/common/include
 CFLAGS+= -DINET6 -DINET
 
 .include <bsd.kmod.mk>
index ba8c6d35a6acaa6d1ec31b84c66a8419dfb58b1f..908187c96f393d8d3cea6c0a7d36e6df2812cbe4 100644 (file)
@@ -1,6 +1,5 @@
 # $FreeBSD$
 .PATH:  ${.CURDIR}/../../ofed/drivers/infiniband/ulp/ipoib
-.PATH:  ${.CURDIR}/../../ofed/include/linux
 
 KMOD=  ipoib
 SRCS=  device_if.h bus_if.h vnode_if.h pci_if.h \
@@ -9,8 +8,8 @@ SRCS=   device_if.h bus_if.h vnode_if.h pci_if.h \
        ipoib_multicast.c ipoib_verbs.c
 
 CFLAGS+= -I${.CURDIR}/../../ofed/drivers/infiniband/ulp/ipoib
-CFLAGS+= -I${.CURDIR}/../ibcore
-CFLAGS+= -I${.CURDIR}/../../ofed/include/
+CFLAGS+= -I${.CURDIR}/../../ofed/include
+CFLAGS+= -I${.CURDIR}/../../compat/linuxkpi/common/include
 CFLAGS+= -DINET6 -DINET
 
 .include <bsd.kmod.mk>
index 47aa6cdd13d182a1c8e6d1adcff8ff4c79d57bad..bcfb03a6ae3ec282969d1749e0753710622102d4 100644 (file)
@@ -1,18 +1,21 @@
 # $FreeBSD$
-.PATH: ${.CURDIR}/../../ofed/include/linux
+.PATH: ${.CURDIR}/../../compat/linuxkpi/common/src
 
 KMOD=  linuxkpi
 SRCS=  linux_kmod.c \
        linux_compat.c \
        linux_pci.c \
        linux_radix.c \
-       linux_idr.c
+       linux_idr.c \
+       linux_usb.c
 
 SRCS+= bus_if.h \
        device_if.h \
        pci_if.h \
-       vnode_if.h
+       vnode_if.h \
+       usb_if.h \
+       opt_usb.h
 
-CFLAGS+= -I${.CURDIR}/../../ofed/include/
+CFLAGS+= -I${.CURDIR}/../../compat/linuxkpi/common/include
 
 .include <bsd.kmod.mk>
index cd2b177f13b4de62890f1ae5173249e63f60f5b3..0aed17d61555667f3b1035f258a1a2b0fea132ea 100644 (file)
@@ -1,6 +1,5 @@
 # $FreeBSD$
 .PATH:  ${.CURDIR}/../../ofed/drivers/net/mlx4
-.PATH:  ${.CURDIR}/../../ofed/include/linux
 
 KMOD=  mlx4
 SRCS=  device_if.h bus_if.h vnode_if.h pci_if.h \
@@ -11,7 +10,8 @@ SRCS= device_if.h bus_if.h vnode_if.h pci_if.h \
        srq.c resource_tracker.c sys_tune.c
 
 CFLAGS+= -I${.CURDIR}/../../ofed/drivers/net/mlx4
-CFLAGS+= -I${.CURDIR}/../../ofed/include/
+CFLAGS+= -I${.CURDIR}/../../ofed/include
+CFLAGS+= -I${.CURDIR}/../../compat/linuxkpi/common/include
 
 .include <bsd.kmod.mk>
 
index 7bfcb4a61a5a1b2a972ba540213f2bb2ec2bbef2..4885bf712ec4495af295c03df2a86b181f4fb055 100644 (file)
@@ -1,6 +1,5 @@
 # $FreeBSD$
 .PATH:  ${.CURDIR}/../../ofed/drivers/infiniband/hw/mlx4
-.PATH:  ${.CURDIR}/../../ofed/include/linux
 
 KMOD=  mlx4ib
 SRCS=  device_if.h bus_if.h vnode_if.h pci_if.h \
@@ -10,7 +9,8 @@ SRCS=  device_if.h bus_if.h vnode_if.h pci_if.h \
        doorbell.c mad.c main.c mr.c qp.c srq.c wc.c cm.c
 
 CFLAGS+= -I${.CURDIR}/../../ofed/drivers/infiniband/hw/mlx4
-CFLAGS+= -I${.CURDIR}/../../ofed/include/
+CFLAGS+= -I${.CURDIR}/../../ofed/include
+CFLAGS+= -I${.CURDIR}/../../compat/linuxkpi/common/include
 CFLAGS+= -DCONFIG_INFINIBAND_USER_MEM
 CFLAGS+= -DINET6 -DINET
 
index 02cca400f741ae09134ceb451294be128a77f97f..11925d4a7fb1d726bc8795b1559fd40b11b6d5d5 100644 (file)
@@ -7,7 +7,8 @@ SRCS    += en_cq.c en_main.c en_netdev.c en_port.c en_resources.c
 SRCS   += en_rx.c en_tx.c
 SRCS   += opt_inet.h opt_inet6.h
 CFLAGS+= -I${.CURDIR}/../../ofed/drivers/net/mlx4
-CFLAGS+= -I${.CURDIR}/../../ofed/include/
+CFLAGS+= -I${.CURDIR}/../../ofed/include
+CFLAGS+= -I${.CURDIR}/../../compat/linuxkpi/common/include
 
 .include <bsd.kmod.mk>
 
index 31fcebd1828ed4d6f5c2e9d4da80eaf48f54cd6b..95157e28058fd4582f3d03252c70874624ce1f95 100644 (file)
@@ -1,5 +1,4 @@
 # $FreeBSD$
-
 .PATH:  ${.CURDIR}/../../ofed/drivers/infiniband/hw/mthca
 
 KMOD    = mthca
@@ -11,6 +10,7 @@ SRCS+=        mthca_reset.c mthca_srq.c mthca_uar.c
 SRCS+= opt_inet.h opt_inet6.h
 
 CFLAGS+= -I${.CURDIR}/../../ofed/include
+CFLAGS+= -I${.CURDIR}/../../compat/linuxkpi/common/include
 
 .include <bsd.kmod.mk>
 
index 1bbc0e4a7b3c1a96fd2eb9d269d54459eaa23ba1..ecc24a5f014f70b921bd744da70a70ce86f55155 100644 (file)
@@ -1,12 +1,11 @@
 # $FreeBSD$
-
-RDMA= ${.CURDIR}/../../../contrib/rdma/krping
-.PATH: ${RDMA}
+.PATH: ${.CURDIR}/../../../contrib/rdma/krping
 
 KMOD= krping
 SRCS= krping.c krping_dev.c getopt.c
 SRCS+=  bus_if.h device_if.h pci_if.h pcib_if.h vnode_if.h
 SRCS+=  opt_sched.h opt_inet.h opt_inet6.h
 CFLAGS+= -I${.CURDIR}/../../../ofed/include
+CFLAGS+= -I${.CURDIR}/../../../compat/linuxkpi/common/include
 
 .include <bsd.kmod.mk>
index 5bae119aaae67e60a1221e2b8c071032b760549e..704895ec8ec3800ab28e625089006ba654382667 100644 (file)
@@ -33,7 +33,7 @@ KMOD= usb
 SRCS=  bus_if.h device_if.h usb_if.h usb_if.c vnode_if.h \
        opt_usb.h opt_bus.h opt_ddb.h \
        usb_pf.h usbdevs.h usbdevs_data.h \
-       usb_busdma.c usb_controller.c usb_compat_linux.c usb_core.c usb_debug.c \
+       usb_busdma.c usb_controller.c usb_core.c usb_debug.c \
        usb_dev.c usb_device.c usb_dynamic.c usb_error.c usb_generic.c \
        usb_handle_request.c usb_hid.c usb_hub.c usb_lookup.c usb_mbuf.c \
        usb_msctest.c usb_parse.c usb_pf.c usb_process.c usb_request.c \
diff --git a/sys/ofed/include/asm/atomic-long.h b/sys/ofed/include/asm/atomic-long.h
deleted file mode 100644 (file)
index f522af8..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-
- * 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_ */
diff --git a/sys/ofed/include/asm/atomic.h b/sys/ofed/include/asm/atomic.h
deleted file mode 100644 (file)
index fc22a39..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * 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_ */
diff --git a/sys/ofed/include/asm/byteorder.h b/sys/ofed/include/asm/byteorder.h
deleted file mode 100644 (file)
index 7168e49..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * 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_ */
diff --git a/sys/ofed/include/asm/fcntl.h b/sys/ofed/include/asm/fcntl.h
deleted file mode 100644 (file)
index f24624e..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * 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_ */
diff --git a/sys/ofed/include/asm/io.h b/sys/ofed/include/asm/io.h
deleted file mode 100644 (file)
index 24d350f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * 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_ */
diff --git a/sys/ofed/include/asm/pgtable.h b/sys/ofed/include/asm/pgtable.h
deleted file mode 100644 (file)
index 7bdab1c..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * 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_ */
diff --git a/sys/ofed/include/asm/types.h b/sys/ofed/include/asm/types.h
deleted file mode 100644 (file)
index fb2fd56..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * 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_ */
diff --git a/sys/ofed/include/asm/uaccess.h b/sys/ofed/include/asm/uaccess.h
deleted file mode 100644 (file)
index ce90355..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * 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_ */
diff --git a/sys/ofed/include/linux/bitops.h b/sys/ofed/include/linux/bitops.h
deleted file mode 100644 (file)
index 8b985a9..0000000
+++ /dev/null
@@ -1,475 +0,0 @@
-/*-
- * 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);
-}
-
-
-#define for_each_set_bit(bit, addr, size) \
-       for ((bit) = find_first_bit((addr), (size));            \
-            (bit) < (size);                                    \
-            (bit) = find_next_bit((addr), (size), (bit) + 1))
-
-#endif /* _LINUX_BITOPS_H_ */
diff --git a/sys/ofed/include/linux/cache.h b/sys/ofed/include/linux/cache.h
deleted file mode 100644 (file)
index a269e55..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * 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        _LINUX_CACHE_H_
-#define _LINUX_CACHE_H_
-
-#define        cache_line_size()       CACHE_LINE_SIZE
-#define        L1_CACHE_BYTES          CACHE_LINE_SIZE
-
-#endif /* _LINUX_CACHE_H_ */
diff --git a/sys/ofed/include/linux/cdev.h b/sys/ofed/include/linux/cdev.h
deleted file mode 100644 (file)
index 9d5b3fb..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*-
- * 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        _LINUX_CDEV_H_
-#define        _LINUX_CDEV_H_
-
-#include <linux/kobject.h>
-#include <linux/kdev_t.h>
-#include <linux/list.h>
-
-struct file_operations;
-struct inode;
-struct module;
-
-extern struct cdevsw linuxcdevsw;
-
-struct linux_cdev {
-       struct kobject  kobj;
-       struct module   *owner;
-       struct cdev     *cdev;
-       dev_t           dev;
-       const struct file_operations *ops;
-};
-
-static inline void
-cdev_release(struct kobject *kobj)
-{
-       struct linux_cdev *cdev;
-
-       cdev = container_of(kobj, struct linux_cdev, kobj);
-       if (cdev->cdev)
-               destroy_dev(cdev->cdev);
-       kfree(cdev);
-}
-
-static inline void
-cdev_static_release(struct kobject *kobj)
-{
-       struct linux_cdev *cdev;
-
-       cdev = container_of(kobj, struct linux_cdev, kobj);
-       if (cdev->cdev)
-               destroy_dev(cdev->cdev);
-}
-
-static struct kobj_type cdev_ktype = {
-       .release = cdev_release,
-};
-
-static struct kobj_type cdev_static_ktype = {
-       .release = cdev_static_release,
-};
-
-static inline void
-cdev_init(struct linux_cdev *cdev, const struct file_operations *ops)
-{
-
-       kobject_init(&cdev->kobj, &cdev_static_ktype);
-       cdev->ops = ops;
-}
-
-static inline struct linux_cdev *
-cdev_alloc(void)
-{
-       struct linux_cdev *cdev;
-
-       cdev = kzalloc(sizeof(struct linux_cdev), M_WAITOK);
-       if (cdev)
-               kobject_init(&cdev->kobj, &cdev_ktype);
-       return (cdev);
-}
-
-static inline void
-cdev_put(struct linux_cdev *p)
-{
-       kobject_put(&p->kobj);
-}
-
-static inline int
-cdev_add(struct linux_cdev *cdev, dev_t dev, unsigned count)
-{
-       if (count != 1)
-               panic("cdev_add: Unsupported count: %d", count);
-       cdev->cdev = make_dev(&linuxcdevsw, MINOR(dev), 0, 0, 0700, 
-           "%s", kobject_name(&cdev->kobj));
-       cdev->dev = dev;
-       cdev->cdev->si_drv1 = cdev;
-
-       return (0);
-}
-
-static inline void
-cdev_del(struct linux_cdev *cdev)
-{
-       if (cdev->cdev) {
-               destroy_dev(cdev->cdev);
-               cdev->cdev = NULL;
-       }
-       kobject_put(&cdev->kobj);
-}
-
-#define        cdev    linux_cdev
-
-#endif /* _LINUX_CDEV_H_ */
diff --git a/sys/ofed/include/linux/clocksource.h b/sys/ofed/include/linux/clocksource.h
deleted file mode 100644 (file)
index 7a4835c..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-
- * 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 _LINUX_CLOCKSOURCE_H
-#define _LINUX_CLOCKSOURCE_H
-
-/* clocksource cycle base type */
-typedef u64 cycle_t;
-
-
-#endif /* _LINUX_CLOCKSOURCE_H */
diff --git a/sys/ofed/include/linux/compat.h b/sys/ofed/include/linux/compat.h
deleted file mode 100644 (file)
index 74ce9ec..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-
- * 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        _LINUX_COMPAT_H_
-#define        _LINUX_COMPAT_H_
-
-#define is_multicast_ether_addr(x) 0
-#define is_broadcast_ether_addr(x) 0
-
-
-#endif /* _LINUX_COMPAT_H_ */
diff --git a/sys/ofed/include/linux/compiler.h b/sys/ofed/include/linux/compiler.h
deleted file mode 100644 (file)
index 6381358..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
- * Copyright (c) 2015 François Tigeot
- * 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_COMPILER_H_
-#define        _LINUX_COMPILER_H_
-
-#include <sys/cdefs.h>
-
-#define __user
-#define __kernel
-#define __safe
-#define __force
-#define __nocast
-#define __iomem
-#define __chk_user_ptr(x)              0
-#define __chk_io_ptr(x)                        0
-#define __builtin_warning(x, y...)     (1)
-#define __acquires(x)
-#define __releases(x)
-#define __acquire(x)                   0
-#define __release(x)                   0
-#define __cond_lock(x,c)               (c)
-#define        __bitwise
-#define __devinitdata
-#define __init
-#define        __devinit
-#define        __devexit
-#define __exit
-#define        __stringify(x)                  #x
-#define        __attribute_const__             __attribute__((__const__))
-#undef __always_inline
-#define        __always_inline                 inline
-
-#define        likely(x)                       __builtin_expect(!!(x), 1)
-#define        unlikely(x)                     __builtin_expect(!!(x), 0)
-#define typeof(x)                      __typeof(x)
-
-#define        uninitialized_var(x)            x = x
-#define        __read_mostly __attribute__((__section__(".data.read_mostly")))
-#define        __always_unused                 __unused
-#define        __must_check                    __result_use_check
-
-#define        __printf(a,b)                   __printflike(a,b)
-
-#define        barrier()                       __asm__ __volatile__("": : :"memory")
-
-#endif /* _LINUX_COMPILER_H_ */
diff --git a/sys/ofed/include/linux/completion.h b/sys/ofed/include/linux/completion.h
deleted file mode 100644 (file)
index 7cfb10d..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * 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        _LINUX_COMPLETION_H_
-#define        _LINUX_COMPLETION_H_
-
-#include <linux/errno.h>
-
-struct completion {
-       unsigned int done;
-};
-
-#define        INIT_COMPLETION(c) \
-       ((c).done = 0)
-#define        init_completion(c) \
-       ((c)->done = 0)
-#define        complete(c)                             \
-       linux_complete_common((c), 0)
-#define        complete_all(c)                         \
-       linux_complete_common((c), 1)
-#define        wait_for_completion(c)                  \
-       linux_wait_for_common((c), 0)
-#define        wait_for_completion_interuptible(c)     \
-       linux_wait_for_common((c), 1)
-#define        wait_for_completion_timeout(c, timeout) \
-       linux_wait_for_timeout_common((c), (timeout), 0)
-#define        wait_for_completion_interruptible_timeout(c, timeout)   \
-       linux_wait_for_timeout_common((c), (timeout), 1)
-#define        try_wait_for_completion(c) \
-       linux_try_wait_for_completion(c)
-#define        completion_done(c) \
-       linux_completion_done(c)
-
-extern void linux_complete_common(struct completion *, int);
-extern long linux_wait_for_common(struct completion *, int);
-extern long linux_wait_for_timeout_common(struct completion *, long, int);
-extern int linux_try_wait_for_completion(struct completion *);
-extern int linux_completion_done(struct completion *);
-
-#endif                                 /* _LINUX_COMPLETION_H_ */
diff --git a/sys/ofed/include/linux/delay.h b/sys/ofed/include/linux/delay.h
deleted file mode 100644 (file)
index da38662..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
- * Copyright (c) 2014 François Tigeot
- * 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_DELAY_H_
-#define        _LINUX_DELAY_H_
-
-#include <linux/jiffies.h>
-#include <sys/systm.h>
-
-static inline void
-linux_msleep(int ms)
-{
-       pause("lnxsleep", msecs_to_jiffies(ms));
-}
-
-#undef msleep
-#define        msleep  linux_msleep
-
-#define        udelay(t)       DELAY(t)
-
-static inline void
-mdelay(unsigned long msecs)
-{
-       while (msecs--)
-               DELAY(1000);
-}
-
-static inline void
-ndelay(unsigned long x)
-{
-       DELAY(howmany(x, 1000));
-}
-
-static inline void
-usleep_range(unsigned long min, unsigned long max)
-{
-       DELAY(min);
-}
-
-#endif /* _LINUX_DELAY_H_ */
diff --git a/sys/ofed/include/linux/device.h b/sys/ofed/include/linux/device.h
deleted file mode 100644 (file)
index 3459a5c..0000000
+++ /dev/null
@@ -1,424 +0,0 @@
-/*-
- * 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        _LINUX_DEVICE_H_
-#define        _LINUX_DEVICE_H_
-
-#include <linux/types.h>
-#include <linux/kobject.h>
-#include <linux/list.h>
-#include <linux/compiler.h>
-#include <linux/types.h>
-#include <linux/module.h>
-#include <linux/workqueue.h>
-#include <linux/sysfs.h>
-#include <linux/kdev_t.h>
-#include <asm/atomic.h>
-
-#include <sys/bus.h>
-
-enum irqreturn { IRQ_NONE = 0, IRQ_HANDLED, IRQ_WAKE_THREAD, };
-typedef enum irqreturn irqreturn_t;
-
-struct class {
-       const char      *name;
-       struct module   *owner;
-       struct kobject  kobj;
-       devclass_t      bsdclass;
-       void            (*class_release)(struct class *class);
-       void            (*dev_release)(struct device *dev);
-       char *          (*devnode)(struct device *dev, umode_t *mode);
-};
-
-struct device {
-       struct device   *parent;
-       struct list_head irqents;
-       device_t        bsddev;
-       dev_t           devt;
-       struct class    *class;
-       void            (*release)(struct device *dev);
-       struct kobject  kobj;
-       uint64_t        *dma_mask;
-       void            *driver_data;
-       unsigned int    irq;
-       unsigned int    msix;
-       unsigned int    msix_max;
-};
-
-extern struct device linux_rootdev;
-extern struct kobject class_root;
-
-struct class_attribute {
-        struct attribute attr;
-        ssize_t (*show)(struct class *, struct class_attribute *, char *);
-        ssize_t (*store)(struct class *, struct class_attribute *, const char *, size_t);
-        const void *(*namespace)(struct class *, const struct class_attribute *);
-};
-
-#define        CLASS_ATTR(_name, _mode, _show, _store)                         \
-       struct class_attribute class_attr_##_name =                     \
-           { { #_name, NULL, _mode }, _show, _store }
-
-struct device_attribute {
-       struct attribute        attr;
-       ssize_t                 (*show)(struct device *,
-                                       struct device_attribute *, char *);
-       ssize_t                 (*store)(struct device *,
-                                       struct device_attribute *, const char *,
-                                       size_t);
-};
-
-#define        DEVICE_ATTR(_name, _mode, _show, _store)                        \
-       struct device_attribute dev_attr_##_name =                      \
-           { { #_name, NULL, _mode }, _show, _store }
-
-/* Simple class attribute that is just a static string */
-struct class_attribute_string {
-       struct class_attribute attr;
-       char *str;
-};
-
-static inline ssize_t
-show_class_attr_string(struct class *class,
-                               struct class_attribute *attr, char *buf)
-{
-       struct class_attribute_string *cs;
-       cs = container_of(attr, struct class_attribute_string, attr);
-       return snprintf(buf, PAGE_SIZE, "%s\n", cs->str);
-}
-
-/* Currently read-only only */
-#define _CLASS_ATTR_STRING(_name, _mode, _str) \
-       { __ATTR(_name, _mode, show_class_attr_string, NULL), _str }
-#define CLASS_ATTR_STRING(_name, _mode, _str) \
-       struct class_attribute_string class_attr_##_name = \
-               _CLASS_ATTR_STRING(_name, _mode, _str)
-
-#define        dev_err(dev, fmt, ...)  device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
-#define        dev_warn(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
-#define        dev_info(dev, fmt, ...) device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
-#define        dev_printk(lvl, dev, fmt, ...)                                  \
-           device_printf((dev)->bsddev, fmt, ##__VA_ARGS__)
-
-static inline void *
-dev_get_drvdata(struct device *dev)
-{
-
-       return dev->driver_data;
-}
-
-static inline void
-dev_set_drvdata(struct device *dev, void *data)
-{
-
-       dev->driver_data = data;
-}
-
-static inline struct device *
-get_device(struct device *dev)
-{
-
-       if (dev)
-               kobject_get(&dev->kobj);
-
-       return (dev);
-}
-
-static inline char *
-dev_name(const struct device *dev)
-{
-
-       return kobject_name(&dev->kobj);
-}
-
-#define        dev_set_name(_dev, _fmt, ...)                                   \
-       kobject_set_name(&(_dev)->kobj, (_fmt), ##__VA_ARGS__)
-
-static inline void
-put_device(struct device *dev)
-{
-
-       if (dev)
-               kobject_put(&dev->kobj);
-}
-
-static inline ssize_t
-class_show(struct kobject *kobj, struct attribute *attr, char *buf)
-{
-       struct class_attribute *dattr;
-       ssize_t error;
-
-       dattr = container_of(attr, struct class_attribute, attr);
-       error = -EIO;
-       if (dattr->show)
-               error = dattr->show(container_of(kobj, struct class, kobj),
-                   dattr, buf);
-       return (error);
-}
-
-static inline ssize_t
-class_store(struct kobject *kobj, struct attribute *attr, const char *buf,
-    size_t count)
-{
-       struct class_attribute *dattr;
-       ssize_t error;
-
-       dattr = container_of(attr, struct class_attribute, attr);
-       error = -EIO;
-       if (dattr->store)
-               error = dattr->store(container_of(kobj, struct class, kobj),
-                   dattr, buf, count);
-       return (error);
-}
-
-static inline void
-class_release(struct kobject *kobj)
-{
-       struct class *class;
-
-       class = container_of(kobj, struct class, kobj);
-       if (class->class_release)
-               class->class_release(class);
-}
-
-static struct sysfs_ops class_sysfs = {
-       .show  = class_show,
-       .store = class_store,
-};
-static struct kobj_type class_ktype = {
-       .release = class_release,
-       .sysfs_ops = &class_sysfs
-};
-
-static inline int
-class_register(struct class *class)
-{
-
-       class->bsdclass = devclass_create(class->name);
-       kobject_init(&class->kobj, &class_ktype);
-       kobject_set_name(&class->kobj, class->name);
-       kobject_add(&class->kobj, &class_root, class->name);
-
-       return (0);
-}
-
-static inline void
-class_unregister(struct class *class)
-{
-
-       kobject_put(&class->kobj);
-}
-
-static inline void
-device_release(struct kobject *kobj)
-{
-       struct device *dev;
-
-       dev = container_of(kobj, struct device, kobj);
-       /* This is the precedence defined by linux. */
-       if (dev->release)
-               dev->release(dev);
-       else if (dev->class && dev->class->dev_release)
-               dev->class->dev_release(dev);
-}
-
-static inline ssize_t
-dev_show(struct kobject *kobj, struct attribute *attr, char *buf)
-{
-       struct device_attribute *dattr;
-       ssize_t error;
-
-       dattr = container_of(attr, struct device_attribute, attr);
-       error = -EIO;
-       if (dattr->show)
-               error = dattr->show(container_of(kobj, struct device, kobj),
-                   dattr, buf);
-       return (error);
-}
-
-static inline ssize_t
-dev_store(struct kobject *kobj, struct attribute *attr, const char *buf,
-    size_t count)
-{
-       struct device_attribute *dattr;
-       ssize_t error;
-
-       dattr = container_of(attr, struct device_attribute, attr);
-       error = -EIO;
-       if (dattr->store)
-               error = dattr->store(container_of(kobj, struct device, kobj),
-                   dattr, buf, count);
-       return (error);
-}
-
-static struct sysfs_ops dev_sysfs = { .show  = dev_show, .store = dev_store, };
-static struct kobj_type dev_ktype = {
-       .release = device_release,
-       .sysfs_ops = &dev_sysfs
-};
-
-/*
- * Devices are registered and created for exporting to sysfs.  create
- * implies register and register assumes the device fields have been
- * setup appropriately before being called.
- */
-static inline int
-device_register(struct device *dev)
-{
-       device_t bsddev;
-       int unit;
-
-       bsddev = NULL;
-       if (dev->devt) {
-               unit = MINOR(dev->devt);
-               bsddev = devclass_get_device(dev->class->bsdclass, unit);
-       } else
-               unit = -1;
-       if (bsddev == NULL)
-               bsddev = device_add_child(dev->parent->bsddev,
-                   dev->class->kobj.name, unit);
-       if (bsddev) {
-               if (dev->devt == 0)
-                       dev->devt = makedev(0, device_get_unit(bsddev));
-               device_set_softc(bsddev, dev);
-       }
-       dev->bsddev = bsddev;
-       kobject_init(&dev->kobj, &dev_ktype);
-       kobject_add(&dev->kobj, &dev->class->kobj, dev_name(dev));
-
-       return (0);
-}
-
-static inline void
-device_unregister(struct device *dev)
-{
-       device_t bsddev;
-
-       bsddev = dev->bsddev;
-       mtx_lock(&Giant);
-       if (bsddev)
-               device_delete_child(device_get_parent(bsddev), bsddev);
-       mtx_unlock(&Giant);
-       put_device(dev);
-}
-
-struct device *device_create(struct class *class, struct device *parent,
-           dev_t devt, void *drvdata, const char *fmt, ...);
-
-static inline void
-device_destroy(struct class *class, dev_t devt)
-{
-       device_t bsddev;
-       int unit;
-
-       unit = MINOR(devt);
-       bsddev = devclass_get_device(class->bsdclass, unit);
-       if (bsddev)
-               device_unregister(device_get_softc(bsddev));
-}
-
-static inline void
-class_kfree(struct class *class)
-{
-
-       kfree(class);
-}
-
-static inline struct class *
-class_create(struct module *owner, const char *name)
-{
-       struct class *class;
-       int error;
-
-       class = kzalloc(sizeof(*class), M_WAITOK);
-       class->owner = owner;
-       class->name= name;
-       class->class_release = class_kfree;
-       error = class_register(class);
-       if (error) {
-               kfree(class);
-               return (NULL);
-       }
-
-       return (class);
-}
-
-static inline void
-class_destroy(struct class *class)
-{
-
-       if (class == NULL)
-               return;
-       class_unregister(class);
-}
-
-static inline int
-device_create_file(struct device *dev, const struct device_attribute *attr)
-{
-
-       if (dev)
-               return sysfs_create_file(&dev->kobj, &attr->attr);
-       return -EINVAL;
-}
-
-static inline void
-device_remove_file(struct device *dev, const struct device_attribute *attr)
-{
-
-       if (dev)
-               sysfs_remove_file(&dev->kobj, &attr->attr);
-}
-
-static inline int
-class_create_file(struct class *class, const struct class_attribute *attr)
-{
-
-       if (class)
-               return sysfs_create_file(&class->kobj, &attr->attr);
-       return -EINVAL;
-}
-
-static inline void
-class_remove_file(struct class *class, const struct class_attribute *attr)
-{
-
-       if (class)
-               sysfs_remove_file(&class->kobj, &attr->attr);
-}
-
-static inline int dev_to_node(struct device *dev)
-{
-                return -1;
-}
-
-char *kvasprintf(gfp_t, const char *, va_list);
-char *kasprintf(gfp_t, const char *, ...);
-
-#endif /* _LINUX_DEVICE_H_ */
diff --git a/sys/ofed/include/linux/dma-attrs.h b/sys/ofed/include/linux/dma-attrs.h
deleted file mode 100644 (file)
index fda2282..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * 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        _LINUX_DMA_ATTR_H_
-#define        _LINUX_DMA_ATTR_H_
-
-enum dma_attr { DMA_ATTR_WRITE_BARRIER, DMA_ATTR_WEAK_ORDERING, DMA_ATTR_MAX, };
-
-#define __DMA_ATTRS_LONGS BITS_TO_LONGS(DMA_ATTR_MAX)
-
-struct dma_attrs {
-       unsigned long flags;
-};
-#define DEFINE_DMA_ATTRS(x) struct dma_attrs x = { }
-
-static inline void
-init_dma_attrs(struct dma_attrs *attrs)
-{
-       attrs->flags = 0;
-}
-
-#endif /* _LINUX_DMA_ATTR_H_ */
diff --git a/sys/ofed/include/linux/dma-mapping.h b/sys/ofed/include/linux/dma-mapping.h
deleted file mode 100644 (file)
index da08751..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-/*-
- * 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        _LINUX_DMA_MAPPING_H_
-#define _LINUX_DMA_MAPPING_H_
-
-#include <linux/types.h>
-#include <linux/device.h>
-#include <linux/err.h>
-#include <linux/dma-attrs.h>
-#include <linux/scatterlist.h>
-#include <linux/mm.h>
-#include <linux/page.h>
-
-#include <sys/systm.h>
-#include <sys/malloc.h>
-
-#include <vm/vm.h>
-#include <vm/vm_page.h>
-#include <vm/pmap.h>
-
-#include <machine/bus.h>
-#include <machine/pmap.h>
-
-enum dma_data_direction {
-       DMA_BIDIRECTIONAL = 0,
-       DMA_TO_DEVICE = 1,
-       DMA_FROM_DEVICE = 2,
-       DMA_NONE = 3,
-};
-
-struct dma_map_ops {
-       void* (*alloc_coherent)(struct device *dev, size_t size,
-           dma_addr_t *dma_handle, gfp_t gfp);
-       void (*free_coherent)(struct device *dev, size_t size,
-           void *vaddr, dma_addr_t dma_handle);
-       dma_addr_t (*map_page)(struct device *dev, struct page *page,
-           unsigned long offset, size_t size, enum dma_data_direction dir,
-           struct dma_attrs *attrs);
-       void (*unmap_page)(struct device *dev, dma_addr_t dma_handle,
-           size_t size, enum dma_data_direction dir, struct dma_attrs *attrs);
-       int (*map_sg)(struct device *dev, struct scatterlist *sg,
-           int nents, enum dma_data_direction dir, struct dma_attrs *attrs);
-       void (*unmap_sg)(struct device *dev, struct scatterlist *sg, int nents,
-           enum dma_data_direction dir, struct dma_attrs *attrs);
-       void (*sync_single_for_cpu)(struct device *dev, dma_addr_t dma_handle,
-           size_t size, enum dma_data_direction dir);
-       void (*sync_single_for_device)(struct device *dev,
-           dma_addr_t dma_handle, size_t size, enum dma_data_direction dir);
-       void (*sync_single_range_for_cpu)(struct device *dev,
-           dma_addr_t dma_handle, unsigned long offset, size_t size,
-           enum dma_data_direction dir);
-       void (*sync_single_range_for_device)(struct device *dev,
-           dma_addr_t dma_handle, unsigned long offset, size_t size,
-           enum dma_data_direction dir);
-       void (*sync_sg_for_cpu)(struct device *dev, struct scatterlist *sg,
-           int nents, enum dma_data_direction dir);
-       void (*sync_sg_for_device)(struct device *dev, struct scatterlist *sg,
-           int nents, enum dma_data_direction dir);
-       int (*mapping_error)(struct device *dev, dma_addr_t dma_addr);
-       int (*dma_supported)(struct device *dev, u64 mask);
-       int is_phys;
-};
-
-#define        DMA_BIT_MASK(n) ((2ULL << ((n) - 1)) - 1ULL)
-
-static inline int
-dma_supported(struct device *dev, u64 mask)
-{
-
-       /* XXX busdma takes care of this elsewhere. */
-       return (1);
-}
-static inline int
-dma_set_mask(struct device *dev, u64 dma_mask)
-{
-
-       if (!dev->dma_mask || !dma_supported(dev, dma_mask))
-               return -EIO;
-
-       *dev->dma_mask = dma_mask;
-       return (0);
-}
-
-static inline int
-dma_set_coherent_mask(struct device *dev, u64 mask)
-{
-
-       if (!dma_supported(dev, mask))
-               return -EIO;
-       /* XXX Currently we don't support a seperate coherent mask. */
-       return 0;
-}
-
-static inline void *
-dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
-    gfp_t flag)
-{
-       vm_paddr_t high;
-       size_t align;
-       void *mem;
-
-       if (dev->dma_mask)
-               high = *dev->dma_mask;
-       else
-               high = BUS_SPACE_MAXADDR_32BIT;
-       align = PAGE_SIZE << get_order(size);
-       mem = (void *)kmem_alloc_contig(kmem_arena, size, flag, 0, high, align,
-           0, VM_MEMATTR_DEFAULT);
-       if (mem)
-               *dma_handle = vtophys(mem);
-       else
-               *dma_handle = 0;
-       return (mem);
-}
-
-static inline void *
-dma_zalloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
-    gfp_t flag)
-{
-
-       return (dma_alloc_coherent(dev, size, dma_handle, flag | __GFP_ZERO));
-}
-                       
-static inline void
-dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
-    dma_addr_t dma_handle)
-{
-
-       kmem_free(kmem_arena, (vm_offset_t)cpu_addr, size);
-}
-
-/* XXX This only works with no iommu. */
-static inline dma_addr_t
-dma_map_single_attrs(struct device *dev, void *ptr, size_t size,
-    enum dma_data_direction dir, struct dma_attrs *attrs)
-{
-
-       return vtophys(ptr);
-}
-
-static inline void
-dma_unmap_single_attrs(struct device *dev, dma_addr_t addr, size_t size,
-    enum dma_data_direction dir, struct dma_attrs *attrs)
-{
-}
-
-static inline int
-dma_map_sg_attrs(struct device *dev, struct scatterlist *sgl, int nents,
-    enum dma_data_direction dir, struct dma_attrs *attrs)
-{
-       struct scatterlist *sg;
-       int i;
-       
-       for_each_sg(sgl, sg, nents, i)
-               sg_dma_address(sg) = sg_phys(sg);
-
-       return (nents);
-}
-
-static inline void
-dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg, int nents,
-    enum dma_data_direction dir, struct dma_attrs *attrs)
-{
-}
-static inline dma_addr_t
-dma_map_page(struct device *dev, struct page *page,
-    unsigned long offset, size_t size, enum dma_data_direction direction)
-{
-
-       return VM_PAGE_TO_PHYS(page) + offset;
-}
-
-static inline void
-dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
-    enum dma_data_direction direction)
-{
-}
-
-static inline void
-dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
-    enum dma_data_direction direction)
-{
-}
-
-static inline void
-dma_sync_single(struct device *dev, dma_addr_t addr, size_t size,
-    enum dma_data_direction dir)
-{
-       dma_sync_single_for_cpu(dev, addr, size, dir);
-}
-
-static inline void
-dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
-    size_t size, enum dma_data_direction direction)
-{
-}
-
-static inline void
-dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
-    enum dma_data_direction direction)
-{
-}
-
-static inline void
-dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
-    enum dma_data_direction direction)
-{
-}
-
-static inline void
-dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
-    unsigned long offset, size_t size, int direction)
-{
-}
-
-static inline void
-dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
-    unsigned long offset, size_t size, int direction)
-{
-}
-
-static inline int
-dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
-{
-
-       return (0);
-}
-
-static inline unsigned int dma_set_max_seg_size(struct device *dev,
-                                                 unsigned int size)
-{
-        return (0);
-}
-
-
-#define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, NULL)
-#define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, NULL)
-#define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, NULL)
-#define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, NULL)
-
-#define        DEFINE_DMA_UNMAP_ADDR(name)             dma_addr_t name
-#define        DEFINE_DMA_UNMAP_LEN(name)              __u32 name
-#define        dma_unmap_addr(p, name)                 ((p)->name)
-#define        dma_unmap_addr_set(p, name, v)          (((p)->name) = (v))
-#define        dma_unmap_len(p, name)                  ((p)->name)
-#define        dma_unmap_len_set(p, name, v)           (((p)->name) = (v))
-
-extern int uma_align_cache;
-#define        dma_get_cache_alignment()       uma_align_cache
-
-#endif /* _LINUX_DMA_MAPPING_H_ */
diff --git a/sys/ofed/include/linux/dmapool.h b/sys/ofed/include/linux/dmapool.h
deleted file mode 100644 (file)
index 3ea2d5b..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*-
- * 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 _LINUX_DMAPOOL_H_
-#define        _LINUX_DMAPOOL_H_
-
-#include <linux/types.h>
-#include <linux/io.h>
-#include <linux/scatterlist.h>
-#include <linux/device.h>
-#include <linux/slab.h>
-
-struct dma_pool {
-       uma_zone_t      pool_zone;
-};
-
-static inline struct dma_pool *
-dma_pool_create(char *name, struct device *dev, size_t size,
-    size_t align, size_t boundary)
-{
-       struct dma_pool *pool;
-
-       pool = kmalloc(sizeof(*pool), GFP_KERNEL);
-       align--;
-       /*
-        * XXX Eventually this could use a seperate allocf to honor boundary
-        * and physical address requirements of the device.
-        */
-       pool->pool_zone = uma_zcreate(name, size, NULL, NULL, NULL, NULL,
-           align, UMA_ZONE_OFFPAGE|UMA_ZONE_HASH);
-
-       return (pool);
-}
-
-static inline void
-dma_pool_destroy(struct dma_pool *pool)
-{
-       uma_zdestroy(pool->pool_zone);
-       kfree(pool);
-}
-
-static inline void *
-dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags, dma_addr_t *handle)
-{
-       void *vaddr;
-
-       vaddr = uma_zalloc(pool->pool_zone, mem_flags);
-       if (vaddr)
-               *handle = vtophys(vaddr);
-       return (vaddr);
-}
-
-static inline void
-dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr)
-{
-       uma_zfree(pool->pool_zone, vaddr);
-}
-
-
-#endif /* _LINUX_DMAPOOL_H_ */
diff --git a/sys/ofed/include/linux/err.h b/sys/ofed/include/linux/err.h
deleted file mode 100644 (file)
index 2366130..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*-
- * 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_ERR_H_
-#define        _LINUX_ERR_H_
-
-#define MAX_ERRNO      4095
-
-#define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO)
-
-static inline void *
-ERR_PTR(long error)
-{
-       return (void *)error;
-}
-
-static inline long
-PTR_ERR(const void *ptr)
-{
-       return (long)ptr;
-}
-
-static inline long
-IS_ERR(const void *ptr)
-{
-       return IS_ERR_VALUE((unsigned long)ptr);
-}
-
-static inline long
-IS_ERR_OR_NULL(const void *ptr)
-{
-       return !ptr || IS_ERR_VALUE((unsigned long)ptr);
-}
-
-static inline void *
-ERR_CAST(void *ptr)
-{
-       return (void *)ptr;
-}
-
-static inline int
-PTR_ERR_OR_ZERO(const void *ptr)
-{
-        if (IS_ERR(ptr))
-                return PTR_ERR(ptr);
-        else
-                return 0;
-}
-
-#define PTR_RET(p) PTR_ERR_OR_ZERO(p)
-
-#endif /* _LINUX_ERR_H_ */
diff --git a/sys/ofed/include/linux/errno.h b/sys/ofed/include/linux/errno.h
deleted file mode 100644 (file)
index a043a3d..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * 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        _LINUX_ERRNO_H_
-#define        _LINUX_ERRNO_H_
-
-#include <sys/errno.h>
-
-#define        ECHRNG          EDOM
-#define        ETIME           ETIMEDOUT
-#define        ECOMM           ESTALE
-#define        ENODATA         ECONNREFUSED
-#define        ENOIOCTLCMD     ENOIOCTL
-#define        ERESTARTSYS     ERESTART
-#define        ENOTSUPP        EOPNOTSUPP
-#define        ENONET          EHOSTDOWN
-
-#endif                                 /* _LINUX_ERRNO_H_ */
diff --git a/sys/ofed/include/linux/etherdevice.h b/sys/ofed/include/linux/etherdevice.h
deleted file mode 100644 (file)
index 12ea345..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * Copyright (c) 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_ETHERDEVICE
-#define        _LINUX_ETHERDEVICE
-
-#include <linux/types.h>
-
-static inline bool 
-is_zero_ether_addr(const u8 * addr)
-{
-       return ((addr[0] + addr[1] + addr[2] + addr[3] + addr[4] + addr[5]) == 0x00);
-}
-
-static inline bool 
-is_multicast_ether_addr(const u8 * addr)
-{
-       return (0x01 & addr[0]);
-}
-
-static inline bool 
-is_broadcast_ether_addr(const u8 * addr)
-{
-       return ((addr[0] + addr[1] + addr[2] + addr[3] + addr[4] + addr[5]) == (6 * 0xff));
-}
-
-static inline bool 
-is_valid_ether_addr(const u8 * addr)
-{
-       return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr);
-}
-
-static inline void 
-ether_addr_copy(u8 * dst, const u8 * src)
-{
-       memcpy(dst, src, 6);
-}
-
-#endif                                 /* _LINUX_ETHERDEVICE */
diff --git a/sys/ofed/include/linux/file.h b/sys/ofed/include/linux/file.h
deleted file mode 100644 (file)
index b23c971..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013 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_FILE_H_
-#define        _LINUX_FILE_H_
-
-#include <sys/param.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/refcount.h>
-#include <sys/capsicum.h>
-#include <sys/proc.h>
-
-#include <linux/fs.h>
-
-struct linux_file;
-
-#undef file
-
-extern struct fileops linuxfileops;
-
-static inline struct linux_file *
-linux_fget(unsigned int fd)
-{
-       cap_rights_t rights;
-       struct file *file;
-
-       if (fget_unlocked(curthread->td_proc->p_fd, fd,
-           cap_rights_init(&rights), &file, NULL) != 0) {
-               return (NULL);
-       }
-       return (struct linux_file *)file->f_data;
-}
-
-static inline void
-fput(struct linux_file *filp)
-{
-       if (filp->_file == NULL) {
-               kfree(filp);
-               return;
-       }
-       if (refcount_release(&filp->_file->f_count)) {
-               _fdrop(filp->_file, curthread);
-               kfree(filp);
-       }
-}
-
-static inline void
-put_unused_fd(unsigned int fd)
-{
-       cap_rights_t rights;
-       struct file *file;
-
-       if (fget_unlocked(curthread->td_proc->p_fd, fd,
-           cap_rights_init(&rights), &file, NULL) != 0) {
-               return;
-       }
-       /*
-        * NOTE: We should only get here when the "fd" has not been
-        * installed, so no need to free the associated Linux file
-        * structure.
-        */
-       fdclose(curthread, file, fd);
-
-       /* drop extra reference */
-       fdrop(file, curthread);
-}
-
-static inline void
-fd_install(unsigned int fd, struct linux_file *filp)
-{
-       cap_rights_t rights;
-       struct file *file;
-
-       if (fget_unlocked(curthread->td_proc->p_fd, fd,
-           cap_rights_init(&rights), &file, NULL) != 0) {
-               file = NULL;
-       }
-       filp->_file = file;
-       finit(file, filp->f_mode, DTYPE_DEV, filp, &linuxfileops);
-
-       /* drop the extra reference */
-       fput(filp);
-}
-
-static inline int
-get_unused_fd(void)
-{
-       struct file *file;
-       int error;
-       int fd;
-
-       error = falloc(curthread, &file, &fd, 0);
-       if (error)
-               return -error;
-       /* drop the extra reference */
-       fdrop(file, curthread);
-       return fd;
-}
-
-static inline struct linux_file *
-alloc_file(int mode, const struct file_operations *fops)
-{
-       struct linux_file *filp;
-
-       filp = kzalloc(sizeof(*filp), GFP_KERNEL);
-       if (filp == NULL)
-               return (NULL);
-       filp->f_op = fops;
-       filp->f_mode = mode;
-
-       return filp;
-}
-
-struct fd {
-       struct linux_file *linux_file;
-};
-
-static inline void fdput(struct fd fd)
-{
-       fput(fd.linux_file);
-}
-
-static inline struct fd fdget(unsigned int fd)
-{
-       struct linux_file *f = linux_fget(fd);
-       return (struct fd){f};
-}
-
-#define        file    linux_file
-#define        fget    linux_fget
-
-#endif /* _LINUX_FILE_H_ */
diff --git a/sys/ofed/include/linux/fs.h b/sys/ofed/include/linux/fs.h
deleted file mode 100644 (file)
index 797b816..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013 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_FS_H_
-#define        _LINUX_FS_H_
-
-#include <sys/cdefs.h>
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/vnode.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <linux/types.h>
-#include <linux/wait.h>
-#include <linux/semaphore.h>
-
-struct module;
-struct kiocb;
-struct iovec;
-struct dentry;
-struct page;
-struct file_lock;
-struct pipe_inode_info;
-struct vm_area_struct;
-struct poll_table_struct;
-struct files_struct;
-
-#define        inode   vnode
-#define        i_cdev  v_rdev
-
-#define        S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH)
-#define        S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH)
-
-
-typedef struct files_struct *fl_owner_t;
-
-struct dentry {
-       struct inode    *d_inode;
-};
-
-struct file_operations;
-
-struct linux_file {
-       struct file     *_file;
-       const struct file_operations    *f_op;
-       void            *private_data;
-       int             f_flags;
-       int             f_mode; /* Just starting mode. */
-       struct dentry   *f_dentry;
-       struct dentry   f_dentry_store;
-       struct selinfo  f_selinfo;
-       struct sigio    *f_sigio;
-       struct vnode    *f_vnode;
-};
-
-#define        file            linux_file
-#define        fasync_struct   sigio *
-
-#define        fasync_helper(fd, filp, on, queue)                              \
-({                                                                     \
-       if ((on))                                                       \
-               *(queue) = &(filp)->f_sigio;                            \
-       else                                                            \
-               *(queue) = NULL;                                        \
-       0;                                                              \
-})
-
-#define        kill_fasync(queue, sig, pollstat)                               \
-do {                                                                   \
-       if (*(queue) != NULL)                                           \
-               pgsigio(*(queue), (sig), 0);                            \
-} while (0)
-
-typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned);
-
-struct file_operations {
-       struct module *owner;
-       ssize_t (*read)(struct file *, char __user *, size_t, loff_t *);
-       ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *);
-       unsigned int (*poll) (struct file *, struct poll_table_struct *);
-       long (*unlocked_ioctl)(struct file *, unsigned int, unsigned long);
-       int (*mmap)(struct file *, struct vm_area_struct *);
-       int (*open)(struct inode *, struct file *);
-       int (*release)(struct inode *, struct file *);
-       int (*fasync)(int, struct file *, int);
-
-/* Although not supported in FreeBSD, to align with Linux code
- * we are adding llseek() only when it is mapped to no_llseek which returns 
- * an illegal seek error
- */
-       loff_t (*llseek)(struct file *, loff_t, int);
-#if 0
-       /* We do not support these methods.  Don't permit them to compile. */
-       loff_t (*llseek)(struct file *, loff_t, int);
-       ssize_t (*aio_read)(struct kiocb *, const struct iovec *,
-           unsigned long, loff_t);
-       ssize_t (*aio_write)(struct kiocb *, const struct iovec *,
-           unsigned long, loff_t);
-       int (*readdir)(struct file *, void *, filldir_t);
-       int (*ioctl)(struct inode *, struct file *, unsigned int,
-           unsigned long);
-       long (*compat_ioctl)(struct file *, unsigned int, unsigned long);
-       int (*flush)(struct file *, fl_owner_t id);
-       int (*fsync)(struct file *, struct dentry *, int datasync);
-       int (*aio_fsync)(struct kiocb *, int datasync);
-       int (*lock)(struct file *, int, struct file_lock *);
-       ssize_t (*sendpage)(struct file *, struct page *, int, size_t,
-           loff_t *, int);
-       unsigned long (*get_unmapped_area)(struct file *, unsigned long,
-           unsigned long, unsigned long, unsigned long);
-       int (*check_flags)(int);
-       int (*flock)(struct file *, int, struct file_lock *);
-       ssize_t (*splice_write)(struct pipe_inode_info *, struct file *,
-           loff_t *, size_t, unsigned int);
-       ssize_t (*splice_read)(struct file *, loff_t *,
-           struct pipe_inode_info *, size_t, unsigned int);
-       int (*setlease)(struct file *, long, struct file_lock **);
-#endif
-};
-#define        fops_get(fops)  (fops)
-
-#define        FMODE_READ      FREAD
-#define        FMODE_WRITE     FWRITE
-#define        FMODE_EXEC      FEXEC
-
-static inline int
-register_chrdev_region(dev_t dev, unsigned range, const char *name)
-{
-
-       return 0;
-}
-
-static inline void
-unregister_chrdev_region(dev_t dev, unsigned range)
-{
-
-       return;
-}
-
-static inline int
-alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count,
-                       const char *name)
-{
-
-       return 0;
-}
-
-/* No current support for seek op in FreeBSD */
-static inline int
-nonseekable_open(struct inode *inode, struct file *filp)
-{
-       return 0;
-}
-
-static inline dev_t
-iminor(struct inode *inode)
-{
-
-       return dev2unit(inode->v_rdev);
-}
-
-static inline struct inode *
-igrab(struct inode *inode)
-{
-       int error;
-
-       error = vget(inode, 0, curthread);
-       if (error)
-               return (NULL);
-
-       return (inode);
-}
-
-static inline void
-iput(struct inode *inode)
-{
-
-       vrele(inode);
-}
-
-static inline loff_t 
-no_llseek(struct file *file, loff_t offset, int whence)
-{
-        return -ESPIPE;
-}
-
-#endif /* _LINUX_FS_H_ */
diff --git a/sys/ofed/include/linux/gfp.h b/sys/ofed/include/linux/gfp.h
deleted file mode 100644 (file)
index a82f30d..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013 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_GFP_H_
-#define        _LINUX_GFP_H_
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-
-#include <linux/page.h>
-
-#include <vm/vm_param.h>
-#include <vm/vm_object.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_kern.h>
-
-#define        __GFP_NOWARN    0
-#define        __GFP_HIGHMEM   0
-#define        __GFP_ZERO      M_ZERO
-
-#define        GFP_NOWAIT      M_NOWAIT
-#define        GFP_ATOMIC      (M_NOWAIT | M_USE_RESERVE)
-#define        GFP_KERNEL      M_WAITOK
-#define        GFP_USER        M_WAITOK
-#define        GFP_HIGHUSER    M_WAITOK
-#define        GFP_HIGHUSER_MOVABLE    M_WAITOK
-#define        GFP_IOFS        M_NOWAIT
-
-static inline void *
-page_address(struct page *page)
-{
-
-       if (page->object != kmem_object && page->object != kernel_object)
-               return (NULL);
-       return ((void *)(uintptr_t)(VM_MIN_KERNEL_ADDRESS +
-           IDX_TO_OFF(page->pindex)));
-}
-
-static inline unsigned long
-_get_page(gfp_t mask)
-{
-
-       return kmem_malloc(kmem_arena, PAGE_SIZE, mask);
-}
-
-#define        get_zeroed_page(mask)   _get_page((mask) | M_ZERO)
-#define        alloc_page(mask)        virt_to_page(_get_page((mask)))
-#define        __get_free_page(mask)   _get_page((mask))
-
-static inline void
-free_page(unsigned long page)
-{
-
-       if (page == 0)
-               return;
-       kmem_free(kmem_arena, page, PAGE_SIZE);
-}
-
-static inline void
-__free_page(struct page *m)
-{
-
-       if (m->object != kmem_object)
-               panic("__free_page:  Freed page %p not allocated via wrappers.",
-                   m);
-       kmem_free(kmem_arena, (vm_offset_t)page_address(m), PAGE_SIZE);
-}
-
-static inline void
-__free_pages(struct page *m, unsigned int order)
-{
-       size_t size;
-
-       if (m == NULL)
-               return;
-       size = PAGE_SIZE << order;
-       kmem_free(kmem_arena, (vm_offset_t)page_address(m), size);
-}
-
-static inline void free_pages(uintptr_t addr, unsigned int order)
-{
-       if (addr == 0)
-               return;
-       __free_pages(virt_to_page((void *)addr), order);
-}
-
-/*
- * Alloc pages allocates directly from the buddy allocator on linux so
- * order specifies a power of two bucket of pages and the results
- * are expected to be aligned on the size as well.
- */
-static inline struct page *
-alloc_pages(gfp_t gfp_mask, unsigned int order)
-{
-       unsigned long page;
-       size_t size;
-
-       size = PAGE_SIZE << order;
-       page = kmem_alloc_contig(kmem_arena, size, gfp_mask, 0, -1,
-           size, 0, VM_MEMATTR_DEFAULT);
-       if (page == 0)
-               return (NULL);
-        return (virt_to_page(page));
-}
-
-static inline uintptr_t __get_free_pages(gfp_t gfp_mask, unsigned int order)
-{
-       struct page *page;
-
-       page = alloc_pages(gfp_mask, order);
-       if (page == NULL)
-               return (0);
-       return ((uintptr_t)page_address(page));
-}
-
-#define alloc_pages_node(node, mask, order)     alloc_pages(mask, order)
-
-#define kmalloc_node(chunk, mask, node)         kmalloc(chunk, mask)
-
-#endif /* _LINUX_GFP_H_ */
diff --git a/sys/ofed/include/linux/hardirq.h b/sys/ofed/include/linux/hardirq.h
deleted file mode 100644 (file)
index b8e4c95..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013 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_HARDIRQ_H_
-#define        _LINUX_HARDIRQ_H_
-
-#include <linux/types.h>
-
-#include <sys/param.h>
-#include <sys/bus.h>
-#include <sys/interrupt.h>
-
-#define        synchronize_irq(irq)    _intr_drain((irq))
-
-#endif /* _LINUX_HARDIRQ_H_ */
diff --git a/sys/ofed/include/linux/idr.h b/sys/ofed/include/linux/idr.h
deleted file mode 100644 (file)
index 9beec68..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013 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_IDR_H_
-#define        _LINUX_IDR_H_
-
-#include <sys/kernel.h>
-
-#define        IDR_BITS        5
-#define        IDR_SIZE        (1 << IDR_BITS)
-#define        IDR_MASK        (IDR_SIZE - 1)
-
-#define        MAX_ID_SHIFT    ((sizeof(int) * NBBY) - 1)
-#define        MAX_ID_BIT      (1U << MAX_ID_SHIFT)
-#define        MAX_ID_MASK     (MAX_ID_BIT - 1)
-#define        MAX_LEVEL       (MAX_ID_SHIFT + IDR_BITS - 1) / IDR_BITS
-
-#define MAX_IDR_SHIFT (sizeof(int)*8 - 1)
-#define MAX_IDR_BIT (1U << MAX_IDR_SHIFT)
-#define MAX_IDR_MASK (MAX_IDR_BIT - 1)
-
-struct idr_layer {
-       unsigned long           bitmap;
-       struct idr_layer        *ary[IDR_SIZE];
-};
-
-struct idr {
-       struct mtx              lock;
-       struct idr_layer        *top;
-       struct idr_layer        *free;
-       int                     layers;
-};
-
-#define DEFINE_IDR(name)                                               \
-       struct idr name;                                                \
-       SYSINIT(name##_idr_sysinit, SI_SUB_DRIVERS, SI_ORDER_FIRST,     \
-           idr_init, &(name));
-
-void   *idr_find(struct idr *idp, int id);
-int    idr_pre_get(struct idr *idp, gfp_t gfp_mask);
-int    idr_get_new(struct idr *idp, void *ptr, int *id);
-int    idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id);
-void   *idr_replace(struct idr *idp, void *ptr, int id);
-void   idr_remove(struct idr *idp, int id);
-void   idr_remove_all(struct idr *idp);
-void   idr_destroy(struct idr *idp);
-void   idr_init(struct idr *idp);
-
-#endif /* _LINUX_IDR_H_ */
diff --git a/sys/ofed/include/linux/if_arp.h b/sys/ofed/include/linux/if_arp.h
deleted file mode 100644 (file)
index 6233aac..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013 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_IF_ARP_H_
-#define        _LINUX_IF_ARP_H_
-#include <sys/socket.h>
-#include <net/if_arp.h>
-#endif /* _LINUX_IF_ARP_H_ */
diff --git a/sys/ofed/include/linux/if_ether.h b/sys/ofed/include/linux/if_ether.h
deleted file mode 100644 (file)
index c89e1e2..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013 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_IF_ETHER_H_
-#define        _LINUX_IF_ETHER_H_
-
-#include <linux/types.h>
-
-#include <net/ethernet.h>
-
-#define        ETH_P_8021Q     ETHERTYPE_VLAN
-
-#define ETH_HLEN        ETHER_HDR_LEN   /* Total octets in header.                              */
-#ifndef ETH_ALEN
-#define ETH_ALEN        ETHER_ADDR_LEN
-#endif
-#define ETH_FCS_LEN     4               /* Octets in the FCS                                    */
-#define VLAN_HLEN       4               /* The additional bytes (on top of the Ethernet header)
-                                         * that VLAN requires.                                  */
-/*
- * defined Ethernet Protocol ID's.
- */
-#define ETH_P_IP        0x0800          /* Internet Protocol packet                             */
-
-#endif /* _LINUX_IF_ETHER_H_ */
diff --git a/sys/ofed/include/linux/if_vlan.h b/sys/ofed/include/linux/if_vlan.h
deleted file mode 100644 (file)
index 4a8808f..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013 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_IF_VLAN_H_
-#define        _LINUX_IF_VLAN_H_
-
-#include <sys/socket.h>
-#include <net/if.h>
-#include <net/ethernet.h>
-#include <net/if_vlan_var.h>
-
-#define VLAN_N_VID              4096
-
-#endif /* _LINUX_IF_VLAN_H_ */
diff --git a/sys/ofed/include/linux/in.h b/sys/ofed/include/linux/in.h
deleted file mode 100644 (file)
index f390c1d..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * 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        _LINUX_IN_H_
-#define        _LINUX_IN_H_
-
-#include "opt_inet.h"
-
-#include <sys/cdefs.h>
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <netinet/in.h>
-#include <asm/byteorder.h>
-
-#define        ipv4_is_zeronet(be)     IN_ZERONET(ntohl(be))
-#define        ipv4_is_loopback(be)    IN_LOOPBACK(ntohl(be))
-
-#endif /* _LINUX_IN_H_ */
diff --git a/sys/ofed/include/linux/in6.h b/sys/ofed/include/linux/in6.h
deleted file mode 100644 (file)
index ef012dd..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013 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_IN6_H_
-#define        _LINUX_IN6_H_
-
-#ifndef KLD_MODULE
-#include "opt_inet6.h"
-#endif
-
-#endif /* _LINUX_IN6_H_ */
diff --git a/sys/ofed/include/linux/inetdevice.h b/sys/ofed/include/linux/inetdevice.h
deleted file mode 100644 (file)
index 12d7544..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013 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_INETDEVICE_H_
-#define        _LINUX_INETDEVICE_H_
-
-#include <linux/netdevice.h>
-
-static inline struct net_device *
-ip_dev_find(struct net *net, uint32_t addr)
-{
-       struct sockaddr_in sin;
-       struct ifaddr *ifa;
-       struct ifnet *ifp;
-
-       ifp = NULL;
-       memset(&sin, 0, sizeof(sin));
-       sin.sin_addr.s_addr = addr;
-       sin.sin_port = 0;
-       sin.sin_len = sizeof(sin);
-       sin.sin_family = AF_INET;
-       ifa = ifa_ifwithaddr((struct sockaddr *)&sin);
-       if (ifa) {
-               ifp = ifa->ifa_ifp;
-               if_ref(ifp);
-               ifa_free(ifa);
-       }
-       return (ifp);
-}
-
-#endif /* _LINUX_INETDEVICE_H_ */
diff --git a/sys/ofed/include/linux/interrupt.h b/sys/ofed/include/linux/interrupt.h
deleted file mode 100644 (file)
index 4c0ad80..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*-
- * 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_INTERRUPT_H_
-#define        _LINUX_INTERRUPT_H_
-
-#include <linux/device.h>
-#include <linux/pci.h>
-
-#include <sys/bus.h>
-#include <sys/rman.h>
-
-typedef        irqreturn_t     (*irq_handler_t)(int, void *);
-
-#define        IRQ_RETVAL(x)   ((x) != IRQ_NONE)
-
-#define        IRQF_SHARED     RF_SHAREABLE
-
-struct irq_ent {
-       struct list_head        links;
-       struct device   *dev;
-       struct resource *res;
-       void            *arg;
-       irqreturn_t     (*handler)(int, void *);
-       void            *tag;
-       int              irq;
-};
-
-static inline int
-_irq_rid(struct device *dev, int irq)
-{
-       if (irq == dev->irq)
-               return (0);
-       return irq - dev->msix + 1;
-}
-
-static void
-_irq_handler(void *ent)
-{
-       struct irq_ent *irqe;
-
-       irqe = ent;
-       irqe->handler(irqe->irq, irqe->arg);
-}
-
-static inline struct irq_ent *
-_irq_ent(struct device *dev, int irq)
-{
-       struct irq_ent *irqe;
-
-       list_for_each_entry(irqe, &dev->irqents, links)
-               if (irqe->irq == irq)
-                       return (irqe);
-
-       return (NULL);
-}
-
-static inline int
-request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
-    const char *name, void *arg)
-{
-       struct resource *res;
-       struct irq_ent *irqe;
-       struct device *dev;
-       int error;
-       int rid;
-
-       dev = _pci_find_irq_dev(irq);
-       if (dev == NULL)
-               return -ENXIO;
-       rid = _irq_rid(dev, irq);
-       res = bus_alloc_resource_any(dev->bsddev, SYS_RES_IRQ, &rid,
-           flags | RF_ACTIVE);
-       if (res == NULL)
-               return (-ENXIO);
-       irqe = kmalloc(sizeof(*irqe), GFP_KERNEL);
-       irqe->dev = dev;
-       irqe->res = res;
-       irqe->arg = arg;
-       irqe->handler = handler;
-       irqe->irq = irq;
-       error = bus_setup_intr(dev->bsddev, res, INTR_TYPE_NET | INTR_MPSAFE,
-           NULL, _irq_handler, irqe, &irqe->tag);
-       if (error) {
-               bus_release_resource(dev->bsddev, SYS_RES_IRQ, rid, irqe->res);
-               kfree(irqe);
-               return (-error);
-       }
-       list_add(&irqe->links, &dev->irqents);
-
-       return 0;
-}
-
-static inline int
-bind_irq_to_cpu(unsigned int irq, int cpu_id)
-{
-       struct irq_ent *irqe;
-       struct device *dev;
-
-       dev = _pci_find_irq_dev(irq);
-       if (dev == NULL)
-               return (-ENOENT);
-
-       irqe = _irq_ent(dev, irq);
-       if (irqe == NULL)
-               return (-ENOENT);
-
-       return (-bus_bind_intr(dev->bsddev, irqe->res, cpu_id));
-}
-
-static inline void
-free_irq(unsigned int irq, void *device)
-{
-       struct irq_ent *irqe;
-       struct device *dev;
-       int rid;
-
-       dev = _pci_find_irq_dev(irq);
-       if (dev == NULL)
-               return;
-       rid = _irq_rid(dev, irq);
-       irqe = _irq_ent(dev, irq);
-       if (irqe == NULL)
-               return;
-       bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag);
-       bus_release_resource(dev->bsddev, SYS_RES_IRQ, rid, irqe->res);
-       list_del(&irqe->links);
-       kfree(irqe);
-}
-
-#endif /* _LINUX_INTERRUPT_H_ */
diff --git a/sys/ofed/include/linux/io-mapping.h b/sys/ofed/include/linux/io-mapping.h
deleted file mode 100644 (file)
index 8650dba..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*-
- * 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        _LINUX_IO_MAPPING_H_
-#define        _LINUX_IO_MAPPING_H_
-
-#include <linux/types.h>
-#include <linux/io.h>
-
-struct io_mapping;
-
-static inline struct io_mapping *
-io_mapping_create_wc(resource_size_t base, unsigned long size)
-{
-
-       return ioremap_wc(base, size);
-}
-
-static inline void
-io_mapping_free(struct io_mapping *mapping)
-{
-
-       iounmap(mapping);
-}
-
-static inline void *
-io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset)
-{
-
-       return (((char *)mapping) + offset);
-}
-
-static inline void
-io_mapping_unmap_atomic(void *vaddr)
-{
-
-}
-
-static inline void *
-io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset)
-{
-
-       return (((char *) mapping) + offset);
-}
-
-static inline void
-io_mapping_unmap(void *vaddr)
-{
-
-}
-
-#endif /* _LINUX_IO_MAPPING_H_ */
diff --git a/sys/ofed/include/linux/io.h b/sys/ofed/include/linux/io.h
deleted file mode 100644 (file)
index 16543ff..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*-
- * 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        _LINUX_IO_H_
-#define        _LINUX_IO_H_
-
-#include <machine/vm.h>
-#include <sys/endian.h>
-
-static inline uint32_t
-__raw_readl(const volatile void *addr)
-{
-       return *(const volatile uint32_t *)addr;
-}
-
-static inline void
-__raw_writel(uint32_t b, volatile void *addr)
-{
-       *(volatile uint32_t *)addr = b;
-}
-
-static inline uint64_t
-__raw_readq(const volatile void *addr)
-{
-       return *(const volatile uint64_t *)addr;
-}
-
-static inline void
-__raw_writeq(uint64_t b, volatile void *addr)
-{
-       *(volatile uint64_t *)addr = b;
-}
-
-/*
- * XXX This is all x86 specific.  It should be bus space access.
- */
-#define mmiowb()
-
-#undef writel
-static inline void
-writel(uint32_t b, void *addr)
-{
-        *(volatile uint32_t *)addr = b;
-}
-
-#undef writeq
-static inline void
-writeq(uint64_t b, void *addr)
-{
-        *(volatile uint64_t *)addr = b;
-}
-
-#undef writeb
-static inline void
-writeb(uint8_t b, void *addr)
-{
-        *(volatile uint8_t *)addr = b;
-}
-
-#undef writew
-static inline void
-writew(uint16_t b, void *addr)
-{
-        *(volatile uint16_t *)addr = b;
-}
-
-#undef ioread32be
-static inline uint32_t
-ioread32be(const volatile void *addr)
-{
-       return be32toh(*(const volatile uint32_t *)addr);
-}
-
-#undef iowrite32be
-static inline void
-iowrite32be(uint32_t v, volatile void *addr)
-{
-       *(volatile uint32_t *)addr = htobe32(v);
-}
-
-void *_ioremap_attr(vm_paddr_t phys_addr, unsigned long size, int attr);
-#define        ioremap_nocache(addr, size)                                     \
-    _ioremap_attr((addr), (size), VM_MEMATTR_UNCACHEABLE)
-#define        ioremap_wc(addr, size)                                          \
-    _ioremap_attr((addr), (size), VM_MEMATTR_WRITE_COMBINING)
-#define        ioremap ioremap_nocache
-void iounmap(void *addr);
-
-#define        memset_io(a, b, c)      memset((a), (b), (c))
-#define        memcpy_fromio(a, b, c)  memcpy((a), (b), (c))
-#define        memcpy_toio(a, b, c)    memcpy((a), (b), (c))
-
-static inline void
-__iowrite64_copy(void *to, void *from, size_t count)
-{
-#ifdef __LP64__
-       uint64_t *src;
-       uint64_t *dst;
-       int i;
-
-       for (i = 0, src = from, dst = to; i < count; i++, src++, dst++)
-               __raw_writeq(*src, dst);
-#else
-       uint32_t *src;
-       uint32_t *dst;
-       int i;
-
-       count *= 2;
-       for (i = 0, src = from, dst = to; i < count; i++, src++, dst++)
-               __raw_writel(*src, dst);
-#endif
-}
-
-
-#endif /* _LINUX_IO_H_ */
diff --git a/sys/ofed/include/linux/ioctl.h b/sys/ofed/include/linux/ioctl.h
deleted file mode 100644 (file)
index 6f57906..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * 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        _LINUX_IOCTL_H_
-#define        _LINUX_IOCTL_H_
-
-#include <sys/ioccom.h>
-
-#endif /* _LINUX_IOCTL_H_ */
diff --git a/sys/ofed/include/linux/jhash.h b/sys/ofed/include/linux/jhash.h
deleted file mode 100644 (file)
index f31829e..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-#ifndef        _LINUX_JHASH_H_
-#define        _LINUX_JHASH_H_
-
-/* jhash.h: Jenkins hash support.
- *
- * Copyright (C) 1996 Bob Jenkins (bob_jenkins@burtleburtle.net)
- *
- * http://burtleburtle.net/bob/hash/
- *
- * These are the credits from Bob's sources:
- *
- * lookup2.c, by Bob Jenkins, December 1996, Public Domain.
- * hash(), hash2(), hash3, and mix() are externally useful functions.
- * Routines to test the hash are included if SELF_TEST is defined.
- * You can use this free for any purpose.  It has no warranty.
- *
- * Copyright (C) 2003 David S. Miller (davem@redhat.com)
- *
- * I've modified Bob's hash to be useful in the Linux kernel, and
- * any bugs present are surely my fault.  -DaveM
- *
- * $FreeBSD$
- */
-
-/* NOTE: Arguments are modified. */
-#define __jhash_mix(a, b, c) \
-{ \
-  a -= b; a -= c; a ^= (c>>13); \
-  b -= c; b -= a; b ^= (a<<8); \
-  c -= a; c -= b; c ^= (b>>13); \
-  a -= b; a -= c; a ^= (c>>12);  \
-  b -= c; b -= a; b ^= (a<<16); \
-  c -= a; c -= b; c ^= (b>>5); \
-  a -= b; a -= c; a ^= (c>>3);  \
-  b -= c; b -= a; b ^= (a<<10); \
-  c -= a; c -= b; c ^= (b>>15); \
-}
-
-/* The golden ration: an arbitrary value */
-#define JHASH_GOLDEN_RATIO     0x9e3779b9
-
-/* The most generic version, hashes an arbitrary sequence
- * of bytes.  No alignment or length assumptions are made about
- * the input key.
- */
-static inline u32 jhash(const void *key, u32 length, u32 initval)
-{
-       u32 a, b, c, len;
-       const u8 *k = key;
-
-       len = length;
-       a = b = JHASH_GOLDEN_RATIO;
-       c = initval;
-
-       while (len >= 12) {
-               a += (k[0] +((u32)k[1]<<8) +((u32)k[2]<<16) +((u32)k[3]<<24));
-               b += (k[4] +((u32)k[5]<<8) +((u32)k[6]<<16) +((u32)k[7]<<24));
-               c += (k[8] +((u32)k[9]<<8) +((u32)k[10]<<16)+((u32)k[11]<<24));
-
-               __jhash_mix(a,b,c);
-
-               k += 12;
-               len -= 12;
-       }
-
-       c += length;
-       switch (len) {
-       case 11: c += ((u32)k[10]<<24);
-       case 10: c += ((u32)k[9]<<16);
-       case 9 : c += ((u32)k[8]<<8);
-       case 8 : b += ((u32)k[7]<<24);
-       case 7 : b += ((u32)k[6]<<16);
-       case 6 : b += ((u32)k[5]<<8);
-       case 5 : b += k[4];
-       case 4 : a += ((u32)k[3]<<24);
-       case 3 : a += ((u32)k[2]<<16);
-       case 2 : a += ((u32)k[1]<<8);
-       case 1 : a += k[0];
-       };
-
-       __jhash_mix(a,b,c);
-
-       return c;
-}
-
-/* A special optimized version that handles 1 or more of u32s.
- * The length parameter here is the number of u32s in the key.
- */
-static inline u32 jhash2(const u32 *k, u32 length, u32 initval)
-{
-       u32 a, b, c, len;
-
-       a = b = JHASH_GOLDEN_RATIO;
-       c = initval;
-       len = length;
-
-       while (len >= 3) {
-               a += k[0];
-               b += k[1];
-               c += k[2];
-               __jhash_mix(a, b, c);
-               k += 3; len -= 3;
-       }
-
-       c += length * 4;
-
-       switch (len) {
-       case 2 : b += k[1];
-       case 1 : a += k[0];
-       };
-
-       __jhash_mix(a,b,c);
-
-       return c;
-}
-
-
-/* A special ultra-optimized versions that knows they are hashing exactly
- * 3, 2 or 1 word(s).
- *
- * NOTE: In partilar the "c += length; __jhash_mix(a,b,c);" normally
- *       done at the end is not done here.
- */
-static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval)
-{
-       a += JHASH_GOLDEN_RATIO;
-       b += JHASH_GOLDEN_RATIO;
-       c += initval;
-
-       __jhash_mix(a, b, c);
-
-       return c;
-}
-
-static inline u32 jhash_2words(u32 a, u32 b, u32 initval)
-{
-       return jhash_3words(a, b, 0, initval);
-}
-
-static inline u32 jhash_1word(u32 a, u32 initval)
-{
-       return jhash_3words(a, 0, 0, initval);
-}
-
-#endif /* _LINUX_JHASH_H_ */
diff --git a/sys/ofed/include/linux/jiffies.h b/sys/ofed/include/linux/jiffies.h
deleted file mode 100644 (file)
index f7bc529..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*-
- * 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        _LINUX_JIFFIES_H_
-#define        _LINUX_JIFFIES_H_
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/time.h>
-
-#include <sys/time.h>
-#include <sys/kernel.h>
-#include <sys/limits.h>
-
-static inline int
-msecs_to_jiffies(int msec)
-{
-       struct timeval tv;
-
-       tv.tv_sec = msec / 1000;
-       tv.tv_usec = (msec % 1000) * 1000;
-       return (tvtohz(&tv) - 1);
-}
-
-#define jiffies                 ticks
-#define        jiffies_64              ticks
-#define jiffies_to_msecs(x)     (((int64_t)(x)) * 1000 / hz)
-
-#define        MAX_JIFFY_OFFSET        ((INT_MAX >> 1) - 1)
-
-#define        time_after(a, b)        ((int)((b) - (a)) < 0)
-#define        time_before(a, b)       time_after(b,a)
-#define        time_after_eq(a, b)     ((int)((a) - (b)) >= 0)
-#define        time_before_eq(a, b)    time_after_eq(b, a)
-#define        time_in_range(a,b,c)    \
-       (time_after_eq(a,b) && time_before_eq(a,c))
-
-#define        HZ      hz
-
-static inline int
-timespec_to_jiffies(const struct timespec *ts)
-{
-       u64 result;
-
-       result = ((u64)hz * ts->tv_sec) +
-           (((u64)hz * ts->tv_nsec + NSEC_PER_SEC - 1) / NSEC_PER_SEC);
-       if (result > MAX_JIFFY_OFFSET)
-               result = MAX_JIFFY_OFFSET;
-
-       return ((int)result);
-}
-
-static inline int
-usecs_to_jiffies(const unsigned int u)
-{
-       u64 result;
-
-       result = ((u64)u * hz + 1000000 - 1) / 1000000;
-       if (result > MAX_JIFFY_OFFSET)
-               result = MAX_JIFFY_OFFSET;
-
-       return ((int)result);
-}
-
-static inline u64
-get_jiffies_64(void)
-{
-       return ((u64)(unsigned)ticks);
-}
-
-#endif /* _LINUX_JIFFIES_H_ */
diff --git a/sys/ofed/include/linux/kdev_t.h b/sys/ofed/include/linux/kdev_t.h
deleted file mode 100644 (file)
index 8dea1ab..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-
- * 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        _LINUX_KDEV_T_H_
-#define        _LINUX_KDEV_T_H_
-
-#define MAJOR(dev)      major((dev))
-#define MINOR(dev)      minor((dev))
-#define MKDEV(ma, mi)   makedev((ma), (mi))
-
-#endif /* _LINUX_KDEV_T_H_ */
diff --git a/sys/ofed/include/linux/kernel.h b/sys/ofed/include/linux/kernel.h
deleted file mode 100644 (file)
index bfc3b7d..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
- * Copyright (c) 2014-2015 François Tigeot
- * 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_KERNEL_H_
-#define        _LINUX_KERNEL_H_
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/systm.h>
-#include <sys/param.h>
-#include <sys/libkern.h>
-#include <sys/stat.h>
-#include <sys/smp.h>
-#include <sys/stddef.h>
-#include <sys/syslog.h>
-
-#include <linux/bitops.h>
-#include <linux/compiler.h>
-#include <linux/errno.h>
-#include <linux/kthread.h>
-#include <linux/types.h>
-#include <linux/jiffies.h>
-#include <linux/wait.h>
-#include <linux/log2.h> 
-#include <asm/byteorder.h>
-
-#define KERN_CONT       ""
-#define        KERN_EMERG      "<0>"
-#define        KERN_ALERT      "<1>"
-#define        KERN_CRIT       "<2>"
-#define        KERN_ERR        "<3>"
-#define        KERN_WARNING    "<4>"
-#define        KERN_NOTICE     "<5>"
-#define        KERN_INFO       "<6>"
-#define        KERN_DEBUG      "<7>"
-
-#define        BUILD_BUG_ON(x)         CTASSERT(!(x))
-
-#define BUG()                  panic("BUG")
-#define BUG_ON(condition)      do { if (condition) BUG(); } while(0)
-#define        WARN_ON                 BUG_ON
-
-#undef ALIGN
-#define        ALIGN(x, y)             roundup2((x), (y))
-#undef PTR_ALIGN
-#define        PTR_ALIGN(p, a)         ((__typeof(p))ALIGN((uintptr_t)(p), (a)))
-#define        DIV_ROUND_UP(x, n)      howmany(x, n)
-#define        DIV_ROUND_UP_ULL(x, n)  DIV_ROUND_UP((unsigned long long)(x), (n))
-#define        FIELD_SIZEOF(t, f)      sizeof(((t *)0)->f)
-
-#define        printk(X...)            printf(X)
-
-/*
- * The "pr_debug()" and "pr_devel()" macros should produce zero code
- * unless DEBUG is defined:
- */
-#ifdef DEBUG
-#define pr_debug(fmt, ...) \
-        log(LOG_DEBUG, fmt, ##__VA_ARGS__)
-#define pr_devel(fmt, ...) \
-       log(LOG_DEBUG, pr_fmt(fmt), ##__VA_ARGS__)
-#else
-#define pr_debug(fmt, ...) \
-        ({ if (0) log(LOG_DEBUG, fmt, ##__VA_ARGS__); 0; })
-#define pr_devel(fmt, ...) \
-       ({ if (0) log(LOG_DEBUG, pr_fmt(fmt), ##__VA_ARGS__); 0; })
-#endif
-
-#ifndef pr_fmt
-#define pr_fmt(fmt) fmt
-#endif
-
-/*
- * Print a one-time message (analogous to WARN_ONCE() et al):
- */
-#define printk_once(...) do {                  \
-       static bool __print_once;               \
-                                               \
-       if (!__print_once) {                    \
-               __print_once = true;            \
-               printk(__VA_ARGS__);            \
-       }                                       \
-} while (0)
-
-/*
- * Log a one-time message (analogous to WARN_ONCE() et al):
- */
-#define log_once(level,...) do {               \
-       static bool __log_once;                 \
-                                               \
-       if (!__log_once) {                      \
-               __log_once = true;              \
-               log(level, __VA_ARGS__);        \
-       }                                       \
-} while (0)
-
-#define pr_emerg(fmt, ...) \
-       log(LOG_EMERG, pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_alert(fmt, ...) \
-       log(LOG_ALERT, pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_crit(fmt, ...) \
-       log(LOG_CRIT, pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_err(fmt, ...) \
-       log(LOG_ERR, pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_warning(fmt, ...) \
-       log(LOG_WARNING, pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_warn pr_warning
-#define pr_notice(fmt, ...) \
-       log(LOG_NOTICE, pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_info(fmt, ...) \
-       log(LOG_INFO, pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_info_once(fmt, ...) \
-       log_once(LOG_INFO, pr_fmt(fmt), ##__VA_ARGS__)
-#define pr_cont(fmt, ...) \
-       printk(KERN_CONT fmt, ##__VA_ARGS__)
-
-#ifndef WARN
-#define WARN(condition, format...) ({                                   \
-        int __ret_warn_on = !!(condition);                              \
-        if (unlikely(__ret_warn_on))                                    \
-                pr_warning(format);                                     \
-        unlikely(__ret_warn_on);                                        \
-})
-#endif
-
-#define container_of(ptr, type, member)                                \
-({                                                             \
-       __typeof(((type *)0)->member) *_p = (ptr);              \
-       (type *)((char *)_p - offsetof(type, member));          \
-})
-  
-#define        ARRAY_SIZE(x)   (sizeof(x) / sizeof((x)[0]))
-
-#define        simple_strtoul  strtoul
-#define        simple_strtol   strtol
-#define kstrtol(a,b,c) ({*(c) = strtol(a,0,b);})
-
-#define min(x, y)      ((x) < (y) ? (x) : (y))
-#define max(x, y)      ((x) > (y) ? (x) : (y))
-
-#define min3(a, b, c)  min(a, min(b,c))
-#define max3(a, b, c)  max(a, max(b,c))
-
-#define min_t(type, _x, _y)    ((type)(_x) < (type)(_y) ? (type)(_x) : (type)(_y))
-#define max_t(type, _x, _y)    ((type)(_x) > (type)(_y) ? (type)(_x) : (type)(_y))
-
-#define clamp_t(type, _x, min, max)    min_t(type, max_t(type, _x, min), max)
-#define clamp(x, lo, hi)               min( max(x,lo), hi)
-
-/*
- * This looks more complex than it should be. But we need to
- * get the type for the ~ right in round_down (it needs to be
- * as wide as the result!), and we want to evaluate the macro
- * arguments just once each.
- */
-#define __round_mask(x, y) ((__typeof__(x))((y)-1))
-#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
-#define round_down(x, y) ((x) & ~__round_mask(x, y))
-
-#define        num_possible_cpus()     mp_ncpus
-#define        num_online_cpus()       mp_ncpus
-
-typedef struct pm_message {
-        int event;
-} pm_message_t;
-
-/* Swap values of a and b */
-#define swap(a, b) do {                        \
-       typeof(a) _swap_tmp = a;        \
-       a = b;                          \
-       b = _swap_tmp;                  \
-} while (0)
-
-#define        DIV_ROUND_CLOSEST(x, divisor)   (((x) + ((divisor) / 2)) / (divisor))
-
-static inline uintmax_t
-mult_frac(uintmax_t x, uintmax_t multiplier, uintmax_t divisor)
-{
-       uintmax_t q = (x / divisor);
-       uintmax_t r = (x % divisor);
-
-       return ((q * multiplier) + ((r * multiplier) / divisor));
-}
-
-static inline int64_t
-abs64(int64_t x)
-{
-       return (x < 0 ? -x : x);
-}
-
-#endif /* _LINUX_KERNEL_H_ */
diff --git a/sys/ofed/include/linux/kmod.h b/sys/ofed/include/linux/kmod.h
deleted file mode 100644 (file)
index c943dc5..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * 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        _LINUX_KMOD_H_
-#define        _LINUX_KMOD_H_
-
-#include <sys/types.h>
-#include <sys/syscallsubr.h>
-#include <sys/refcount.h>
-#include <sys/sbuf.h>
-#include <machine/stdarg.h>
-#include <sys/proc.h>
-
-#define        request_module(...) \
-({\
-       char modname[128]; \
-        int fileid; \
-       snprintf(modname, sizeof(modname), __VA_ARGS__); \
-       kern_kldload(curthread, modname, &fileid); \
-})
-
-#define request_module_nowait request_module
-
-
-#endif /* _LINUX_KMOD_H_ */
diff --git a/sys/ofed/include/linux/kobject.h b/sys/ofed/include/linux/kobject.h
deleted file mode 100644 (file)
index 63fbc56..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/*-
- * 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        _LINUX_KOBJECT_H_
-#define        _LINUX_KOBJECT_H_
-
-#include <machine/stdarg.h>
-
-#include <linux/kernel.h>
-#include <linux/kref.h>
-#include <linux/slab.h>
-
-struct kobject;
-struct sysctl_oid;
-
-struct kobj_type {
-       void (*release)(struct kobject *kobj);
-       const struct sysfs_ops *sysfs_ops;
-       struct attribute **default_attrs;
-};
-
-extern struct kobj_type kfree_type;
-
-struct kobject {
-       struct kobject          *parent;
-       char                    *name;
-       struct kref             kref;
-       struct kobj_type        *ktype;
-       struct list_head        entry;
-       struct sysctl_oid       *oidp;
-};
-
-extern struct kobject *mm_kobj;
-
-static inline void
-kobject_init(struct kobject *kobj, struct kobj_type *ktype)
-{
-
-       kref_init(&kobj->kref);
-       INIT_LIST_HEAD(&kobj->entry);
-       kobj->ktype = ktype;
-       kobj->oidp = NULL;
-}
-
-static inline void kobject_put(struct kobject *kobj);
-void kobject_release(struct kref *kref);
-
-static inline void
-kobject_put(struct kobject *kobj)
-{
-
-       if (kobj)
-               kref_put(&kobj->kref, kobject_release);
-}
-
-static inline struct kobject *
-kobject_get(struct kobject *kobj)
-{
-
-       if (kobj)
-               kref_get(&kobj->kref);
-       return kobj;
-}
-
-static inline int
-kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list args)
-{
-       char *old;
-       char *name;
-
-       old = kobj->name;
-
-       if (old && !fmt)
-               return 0;
-
-       name = kzalloc(MAXPATHLEN, GFP_KERNEL);
-       if (!name)
-               return -ENOMEM;
-       vsnprintf(name, MAXPATHLEN, fmt, args);
-       kobj->name = name;
-       kfree(old);
-       for (; *name != '\0'; name++)
-               if (*name == '/')
-                       *name = '!';
-       return (0);
-}
-
-int    kobject_add(struct kobject *kobj, struct kobject *parent,
-           const char *fmt, ...);
-
-static inline struct kobject *
-kobject_create(void)
-{
-       struct kobject *kobj;
-
-       kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
-       if (kobj == NULL)
-               return (NULL);
-       kobject_init(kobj, &kfree_type);
-
-       return (kobj);
-}
-
-static inline struct kobject *
-kobject_create_and_add(const char *name, struct kobject *parent)
-{
-       struct kobject *kobj;
-
-       kobj = kobject_create();
-       if (kobj == NULL)
-               return (NULL);
-       if (kobject_add(kobj, parent, "%s", name) == 0)
-               return (kobj);
-       kobject_put(kobj);
-
-       return (NULL);
-}
-
-
-static inline char *
-kobject_name(const struct kobject *kobj)
-{
-
-       return kobj->name;
-}
-
-int    kobject_set_name(struct kobject *kobj, const char *fmt, ...);
-int    kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype,
-           struct kobject *parent, const char *fmt, ...);
-
-/* sysfs.h calles for 'kobject' which is defined here, 
- * so we need to add the include only after the 'kobject' def.
- */
-#include <linux/sysfs.h>
-
-struct kobj_attribute {
-        struct attribute attr;
-        ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
-                        char *buf);
-        ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
-                         const char *buf, size_t count);
-};
-
-#endif /* _LINUX_KOBJECT_H_ */
diff --git a/sys/ofed/include/linux/kref.h b/sys/ofed/include/linux/kref.h
deleted file mode 100644 (file)
index de5ddaa..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
- * Copyright (c) 2013 François Tigeot
- * 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_KREF_H_
-#define _LINUX_KREF_H_
-
-#include <sys/types.h>
-#include <sys/refcount.h>
-
-#include <asm/atomic.h>
-
-struct kref {
-       atomic_t refcount;
-};
-
-static inline void
-kref_init(struct kref *kref)
-{
-
-       refcount_init(&kref->refcount.counter, 1);
-}
-
-static inline void
-kref_get(struct kref *kref)
-{
-
-       refcount_acquire(&kref->refcount.counter);
-}
-
-static inline int
-kref_put(struct kref *kref, void (*rel)(struct kref *kref))
-{
-
-       if (refcount_release(&kref->refcount.counter)) {
-               rel(kref);
-               return 1;
-       }
-       return 0;
-}
-
-static inline int
-kref_sub(struct kref *kref, unsigned int count,
-    void (*rel)(struct kref *kref))
-{
-
-       while (count--) {
-               if (refcount_release(&kref->refcount.counter)) {
-                       rel(kref);
-                       return 1;
-               }
-       }
-       return 0;
-}
-
-static inline int __must_check
-kref_get_unless_zero(struct kref *kref)
-{
-
-       return atomic_add_unless(&kref->refcount, 1, 0);
-}
-
-#endif /* _LINUX_KREF_H_ */
diff --git a/sys/ofed/include/linux/kthread.h b/sys/ofed/include/linux/kthread.h
deleted file mode 100644 (file)
index fa8e9ba..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * 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        _LINUX_KTHREAD_H_
-#define        _LINUX_KTHREAD_H_
-
-#include <sys/param.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/kernel.h>
-#include <sys/kthread.h>
-#include <sys/sleepqueue.h>
-
-#include <linux/slab.h>
-#include <linux/sched.h>
-
-static inline void
-_kthread_fn(void *arg)
-{
-       struct task_struct *task;
-
-       task = arg;
-       task_struct_set(curthread, task);
-       if (task->should_stop == 0)
-               task->task_ret = task->task_fn(task->task_data);
-       PROC_LOCK(task->task_thread->td_proc);
-       task->should_stop = TASK_STOPPED;
-       wakeup(task);
-       PROC_UNLOCK(task->task_thread->td_proc);
-       kthread_exit();
-}
-
-static inline struct task_struct *
-_kthread_create(int (*threadfn)(void *data), void *data)
-{
-       struct task_struct *task;
-
-       task = kzalloc(sizeof(*task), GFP_KERNEL);
-       task->task_fn = threadfn;
-       task->task_data = data;
-
-       return (task);
-}
-
-struct task_struct *kthread_create(int (*threadfn)(void *data),
-                                   void *data,
-                                   const char namefmt[], ...)
-        __attribute__((format(printf, 3, 4)));
-
-#define        kthread_run(fn, data, fmt, ...)                                 \
-({                                                                     \
-       struct task_struct *_task;                                      \
-                                                                       \
-       _task = _kthread_create((fn), (data));                          \
-       if (kthread_add(_kthread_fn, _task, NULL, &_task->task_thread,  \
-           0, 0, fmt, ## __VA_ARGS__)) {                               \
-               kfree(_task);                                           \
-               _task = NULL;                                           \
-       } else                                                          \
-               task_struct_set(_task->task_thread, _task);             \
-       _task;                                                          \
-})
-
-#define        kthread_should_stop()   current->should_stop
-
-static inline int
-kthread_stop(struct task_struct *task)
-{
-
-       PROC_LOCK(task->task_thread->td_proc);
-       task->should_stop = TASK_SHOULD_STOP;
-       wake_up_process(task);
-       while (task->should_stop != TASK_STOPPED)
-               msleep(task, &task->task_thread->td_proc->p_mtx, PWAIT,
-                   "kstop", hz);
-       PROC_UNLOCK(task->task_thread->td_proc);
-       return task->task_ret;
-}
-
-#endif /* _LINUX_KTHREAD_H_ */
diff --git a/sys/ofed/include/linux/ktime.h b/sys/ofed/include/linux/ktime.h
deleted file mode 100644 (file)
index c9fa81c..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*-
- * Copyright (c) 2014-2015 Mellanox Technologies, Ltd.
- * Copyright (c) 2015 François Tigeot
- * 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_KTIME_H
-#define _LINUX_KTIME_H
-
-#include <linux/types.h>
-#include <linux/time.h>
-#include <linux/jiffies.h>
-
-#define ktime_get_ts(x) getnanouptime(x)
-
-/* time values in nanoseconds */
-union ktime {
-       int64_t tv64;
-};
-
-typedef union ktime ktime_t;
-
-#define KTIME_MAX                       ((s64)~((u64)1 << 63))
-#define KTIME_SEC_MAX                   (KTIME_MAX / NSEC_PER_SEC)
-
-static inline int64_t
-ktime_to_ns(ktime_t kt)
-{
-       return kt.tv64;
-}
-
-static inline struct timeval
-ktime_to_timeval(ktime_t kt)
-{
-       return ns_to_timeval(kt.tv64);
-}
-
-static inline ktime_t
-ktime_add_ns(ktime_t kt, int64_t ns)
-{
-       ktime_t res;
-
-       res.tv64 = kt.tv64 + ns;
-       return kt;
-}
-
-static inline ktime_t
-ktime_sub_ns(ktime_t kt, int64_t ns)
-{
-       ktime_t res;
-
-       res.tv64 = kt.tv64 - ns;
-       return kt;
-}
-
-static inline ktime_t
-ktime_set(const long secs, const unsigned long nsecs)
-{
-       ktime_t retval = { (s64)secs * NSEC_PER_SEC + (s64)nsecs };
-       return (retval);
-}
-
-static inline ktime_t
-ktime_sub(ktime_t lhs, ktime_t rhs)
-{
-       lhs.tv64 -= rhs.tv64;
-       return (lhs);
-}
-
-static inline ktime_t
-ktime_add(ktime_t lhs, ktime_t rhs)
-{
-       lhs.tv64 += rhs.tv64;
-       return (lhs);
-}
-
-static inline ktime_t
-timespec_to_ktime(struct timespec ts)
-{
-       return (ktime_set(ts.tv_sec, ts.tv_nsec));
-}
-
-static inline ktime_t
-timeval_to_ktime(struct timeval tv)
-{
-       return (ktime_set(tv.tv_sec, tv.tv_usec * NSEC_PER_USEC));
-}
-
-#define ktime_to_timespec(kt)          ns_to_timespec((kt).tv64)
-#define ktime_to_timeval(kt)           ns_to_timeval((kt).tv64)
-#define ktime_to_ns(kt)                        ((kt).tv64)
-
-static inline s64
-ktime_get_ns(void)
-{
-       struct timespec ts;
-       ktime_t kt;
-
-       ktime_get_ts(&ts);
-       kt = timespec_to_ktime(ts);
-       return (ktime_to_ns(kt));
-}
-
-static inline ktime_t
-ktime_get(void)
-{
-       struct timespec ts;
-
-       ktime_get_ts(&ts);
-       return (timespec_to_ktime(ts));
-}
-
-#endif /* _LINUX_KTIME_H */
diff --git a/sys/ofed/include/linux/linux_compat.c b/sys/ofed/include/linux/linux_compat.c
deleted file mode 100644 (file)
index 26df7db..0000000
+++ /dev/null
@@ -1,954 +0,0 @@
-/*-
- * 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/proc.h>
-#include <sys/sglist.h>
-#include <sys/sleepqueue.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/bus.h>
-#include <sys/fcntl.h>
-#include <sys/file.h>
-#include <sys/filio.h>
-#include <sys/rwlock.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <machine/stdarg.h>
-#include <machine/pmap.h>
-
-#include <linux/kobject.h>
-#include <linux/device.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/cdev.h>
-#include <linux/file.h>
-#include <linux/sysfs.h>
-#include <linux/mm.h>
-#include <linux/io.h>
-#include <linux/vmalloc.h>
-#include <linux/netdevice.h>
-#include <linux/timer.h>
-
-#include <vm/vm_pager.h>
-
-MALLOC_DEFINE(M_KMALLOC, "linux", "Linux kmalloc compat");
-
-#include <linux/rbtree.h>
-/* Undo Linux compat changes. */
-#undef RB_ROOT
-#undef file
-#undef cdev
-#define        RB_ROOT(head)   (head)->rbh_root
-
-struct kobject class_root;
-struct device linux_rootdev;
-struct class miscclass;
-struct list_head pci_drivers;
-struct list_head pci_devices;
-struct net init_net;
-spinlock_t pci_lock;
-
-unsigned long linux_timer_hz_mask;
-
-int
-panic_cmp(struct rb_node *one, struct rb_node *two)
-{
-       panic("no cmp");
-}
-
-RB_GENERATE(linux_root, rb_node, __entry, panic_cmp);
-int
-kobject_set_name(struct kobject *kobj, const char *fmt, ...)
-{
-       va_list args;
-       int error;
-
-       va_start(args, fmt);
-       error = kobject_set_name_vargs(kobj, fmt, args);
-       va_end(args);
-
-       return (error);
-}
-
-static inline int
-kobject_add_complete(struct kobject *kobj, struct kobject *parent)
-{
-       struct kobj_type *t;
-       int error;
-
-       kobj->parent = kobject_get(parent);
-       error = sysfs_create_dir(kobj);
-       if (error == 0 && kobj->ktype && kobj->ktype->default_attrs) {
-               struct attribute **attr;
-               t = kobj->ktype;
-
-               for (attr = t->default_attrs; *attr != NULL; attr++) {
-                       error = sysfs_create_file(kobj, *attr);
-                       if (error)
-                               break;
-               }
-               if (error)
-                       sysfs_remove_dir(kobj);
-               
-       }
-       return (error);
-}
-
-int
-kobject_add(struct kobject *kobj, struct kobject *parent, const char *fmt, ...)
-{
-       va_list args;
-       int error;
-
-       va_start(args, fmt);
-       error = kobject_set_name_vargs(kobj, fmt, args);
-       va_end(args);
-       if (error)
-               return (error);
-
-       return kobject_add_complete(kobj, parent);
-}
-
-void
-kobject_release(struct kref *kref)
-{
-       struct kobject *kobj;
-       char *name;
-
-       kobj = container_of(kref, struct kobject, kref);
-       sysfs_remove_dir(kobj);
-       if (kobj->parent)
-               kobject_put(kobj->parent);
-       kobj->parent = NULL;
-       name = kobj->name;
-       if (kobj->ktype && kobj->ktype->release)
-               kobj->ktype->release(kobj);
-       kfree(name);
-}
-
-static void
-kobject_kfree(struct kobject *kobj)
-{
-       kfree(kobj);
-}
-
-static void
-kobject_kfree_name(struct kobject *kobj)
-{
-       if (kobj) {
-               kfree(kobj->name);
-       }
-}
-
-struct kobj_type kfree_type = { .release = kobject_kfree };
-
-static void
-dev_release(struct device *dev)
-{
-       pr_debug("dev_release: %s\n", dev_name(dev));
-       kfree(dev);
-}
-
-struct device *
-device_create(struct class *class, struct device *parent, dev_t devt,
-    void *drvdata, const char *fmt, ...)
-{
-       struct device *dev;
-       va_list args;
-
-       dev = kzalloc(sizeof(*dev), M_WAITOK);
-       dev->parent = parent;
-       dev->class = class;
-       dev->devt = devt;
-       dev->driver_data = drvdata;
-       dev->release = dev_release;
-       va_start(args, fmt);
-       kobject_set_name_vargs(&dev->kobj, fmt, args);
-       va_end(args);
-       device_register(dev);
-
-       return (dev);
-}
-
-int
-kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype,
-    struct kobject *parent, const char *fmt, ...)
-{
-       va_list args;
-       int error;
-
-       kobject_init(kobj, ktype);
-       kobj->ktype = ktype;
-       kobj->parent = parent;
-       kobj->name = NULL;
-
-       va_start(args, fmt);
-       error = kobject_set_name_vargs(kobj, fmt, args);
-       va_end(args);
-       if (error)
-               return (error);
-       return kobject_add_complete(kobj, parent);
-}
-
-static void
-linux_file_dtor(void *cdp)
-{
-       struct linux_file *filp;
-
-       filp = cdp;
-       filp->f_op->release(filp->f_vnode, filp);
-       vdrop(filp->f_vnode);
-       kfree(filp);
-}
-
-static int
-linux_dev_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
-{
-       struct linux_cdev *ldev;
-       struct linux_file *filp;
-       struct file *file;
-       int error;
-
-       file = curthread->td_fpop;
-       ldev = dev->si_drv1;
-       if (ldev == NULL)
-               return (ENODEV);
-       filp = kzalloc(sizeof(*filp), GFP_KERNEL);
-       filp->f_dentry = &filp->f_dentry_store;
-       filp->f_op = ldev->ops;
-       filp->f_flags = file->f_flag;
-       vhold(file->f_vnode);
-       filp->f_vnode = file->f_vnode;
-       if (filp->f_op->open) {
-               error = -filp->f_op->open(file->f_vnode, filp);
-               if (error) {
-                       kfree(filp);
-                       return (error);
-               }
-       }
-       error = devfs_set_cdevpriv(filp, linux_file_dtor);
-       if (error) {
-               filp->f_op->release(file->f_vnode, filp);
-               kfree(filp);
-               return (error);
-       }
-
-       return 0;
-}
-
-static int
-linux_dev_close(struct cdev *dev, int fflag, int devtype, struct thread *td)
-{
-       struct linux_cdev *ldev;
-       struct linux_file *filp;
-       struct file *file;
-       int error;
-
-       file = curthread->td_fpop;
-       ldev = dev->si_drv1;
-       if (ldev == NULL)
-               return (0);
-       if ((error = devfs_get_cdevpriv((void **)&filp)) != 0)
-               return (error);
-       filp->f_flags = file->f_flag;
-        devfs_clear_cdevpriv();
-        
-
-       return (0);
-}
-
-static int
-linux_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
-    struct thread *td)
-{
-       struct linux_cdev *ldev;
-       struct linux_file *filp;
-       struct file *file;
-       int error;
-
-       file = curthread->td_fpop;
-       ldev = dev->si_drv1;
-       if (ldev == NULL)
-               return (0);
-       if ((error = devfs_get_cdevpriv((void **)&filp)) != 0)
-               return (error);
-       filp->f_flags = file->f_flag;
-       /*
-        * Linux does not have a generic ioctl copyin/copyout layer.  All
-        * linux ioctls must be converted to void ioctls which pass a
-        * pointer to the address of the data.  We want the actual user
-        * address so we dereference here.
-        */
-       data = *(void **)data;
-       if (filp->f_op->unlocked_ioctl)
-               error = -filp->f_op->unlocked_ioctl(filp, cmd, (u_long)data);
-       else
-               error = ENOTTY;
-
-       return (error);
-}
-
-static int
-linux_dev_read(struct cdev *dev, struct uio *uio, int ioflag)
-{
-       struct linux_cdev *ldev;
-       struct linux_file *filp;
-       struct file *file;
-       ssize_t bytes;
-       int error;
-
-       file = curthread->td_fpop;
-       ldev = dev->si_drv1;
-       if (ldev == NULL)
-               return (0);
-       if ((error = devfs_get_cdevpriv((void **)&filp)) != 0)
-               return (error);
-       filp->f_flags = file->f_flag;
-       if (uio->uio_iovcnt != 1)
-               panic("linux_dev_read: uio %p iovcnt %d",
-                   uio, uio->uio_iovcnt);
-       if (filp->f_op->read) {
-               bytes = filp->f_op->read(filp, uio->uio_iov->iov_base,
-                   uio->uio_iov->iov_len, &uio->uio_offset);
-               if (bytes >= 0) {
-                       uio->uio_iov->iov_base =
-                           ((uint8_t *)uio->uio_iov->iov_base) + bytes;
-                       uio->uio_iov->iov_len -= bytes;
-                       uio->uio_resid -= bytes;
-               } else
-                       error = -bytes;
-       } else
-               error = ENXIO;
-
-       return (error);
-}
-
-static int
-linux_dev_write(struct cdev *dev, struct uio *uio, int ioflag)
-{
-       struct linux_cdev *ldev;
-       struct linux_file *filp;
-       struct file *file;
-       ssize_t bytes;
-       int error;
-
-       file = curthread->td_fpop;
-       ldev = dev->si_drv1;
-       if (ldev == NULL)
-               return (0);
-       if ((error = devfs_get_cdevpriv((void **)&filp)) != 0)
-               return (error);
-       filp->f_flags = file->f_flag;
-       if (uio->uio_iovcnt != 1)
-               panic("linux_dev_write: uio %p iovcnt %d",
-                   uio, uio->uio_iovcnt);
-       if (filp->f_op->write) {
-               bytes = filp->f_op->write(filp, uio->uio_iov->iov_base,
-                   uio->uio_iov->iov_len, &uio->uio_offset);
-               if (bytes >= 0) {
-                       uio->uio_iov->iov_base =
-                           ((uint8_t *)uio->uio_iov->iov_base) + bytes;
-                       uio->uio_iov->iov_len -= bytes;
-                       uio->uio_resid -= bytes;
-               } else
-                       error = -bytes;
-       } else
-               error = ENXIO;
-
-       return (error);
-}
-
-static int
-linux_dev_poll(struct cdev *dev, int events, struct thread *td)
-{
-       struct linux_cdev *ldev;
-       struct linux_file *filp;
-       struct file *file;
-       int revents;
-       int error;
-
-       file = curthread->td_fpop;
-       ldev = dev->si_drv1;
-       if (ldev == NULL)
-               return (0);
-       if ((error = devfs_get_cdevpriv((void **)&filp)) != 0)
-               return (error);
-       filp->f_flags = file->f_flag;
-       if (filp->f_op->poll)
-               revents = filp->f_op->poll(filp, NULL) & events;
-       else
-               revents = 0;
-
-       return (revents);
-}
-
-static int
-linux_dev_mmap_single(struct cdev *dev, vm_ooffset_t *offset,
-    vm_size_t size, struct vm_object **object, int nprot)
-{
-       struct linux_cdev *ldev;
-       struct linux_file *filp;
-       struct file *file;
-       struct vm_area_struct vma;
-       int error;
-
-       file = curthread->td_fpop;
-       ldev = dev->si_drv1;
-       if (ldev == NULL)
-               return (ENODEV);
-       if ((error = devfs_get_cdevpriv((void **)&filp)) != 0)
-               return (error);
-       filp->f_flags = file->f_flag;
-       vma.vm_start = 0;
-       vma.vm_end = size;
-       vma.vm_pgoff = *offset / PAGE_SIZE;
-       vma.vm_pfn = 0;
-       vma.vm_page_prot = 0;
-       if (filp->f_op->mmap) {
-               error = -filp->f_op->mmap(filp, &vma);
-               if (error == 0) {
-                       struct sglist *sg;
-
-                       sg = sglist_alloc(1, M_WAITOK);
-                       sglist_append_phys(sg,
-                           (vm_paddr_t)vma.vm_pfn << PAGE_SHIFT, vma.vm_len);
-                       *object = vm_pager_allocate(OBJT_SG, sg, vma.vm_len,
-                           nprot, 0, curthread->td_ucred);
-                       if (*object == NULL) {
-                               sglist_free(sg);
-                               return (EINVAL);
-                       }
-                       *offset = 0;
-                       if (vma.vm_page_prot != VM_MEMATTR_DEFAULT) {
-                               VM_OBJECT_WLOCK(*object);
-                               vm_object_set_memattr(*object,
-                                   vma.vm_page_prot);
-                               VM_OBJECT_WUNLOCK(*object);
-                       }
-               }
-       } else
-               error = ENODEV;
-
-       return (error);
-}
-
-struct cdevsw linuxcdevsw = {
-       .d_version = D_VERSION,
-       .d_flags = D_TRACKCLOSE,
-       .d_open = linux_dev_open,
-       .d_close = linux_dev_close,
-       .d_read = linux_dev_read,
-       .d_write = linux_dev_write,
-       .d_ioctl = linux_dev_ioctl,
-       .d_mmap_single = linux_dev_mmap_single,
-       .d_poll = linux_dev_poll,
-};
-
-static int
-linux_file_read(struct file *file, struct uio *uio, struct ucred *active_cred,
-    int flags, struct thread *td)
-{
-       struct linux_file *filp;
-       ssize_t bytes;
-       int error;
-
-       error = 0;
-       filp = (struct linux_file *)file->f_data;
-       filp->f_flags = file->f_flag;
-       if (uio->uio_iovcnt != 1)
-               panic("linux_file_read: uio %p iovcnt %d",
-                   uio, uio->uio_iovcnt);
-       if (filp->f_op->read) {
-               bytes = filp->f_op->read(filp, uio->uio_iov->iov_base,
-                   uio->uio_iov->iov_len, &uio->uio_offset);
-               if (bytes >= 0) {
-                       uio->uio_iov->iov_base =
-                           ((uint8_t *)uio->uio_iov->iov_base) + bytes;
-                       uio->uio_iov->iov_len -= bytes;
-                       uio->uio_resid -= bytes;
-               } else
-                       error = -bytes;
-       } else
-               error = ENXIO;
-
-       return (error);
-}
-
-static int
-linux_file_poll(struct file *file, int events, struct ucred *active_cred,
-    struct thread *td)
-{
-       struct linux_file *filp;
-       int revents;
-
-       filp = (struct linux_file *)file->f_data;
-       filp->f_flags = file->f_flag;
-       if (filp->f_op->poll)
-               revents = filp->f_op->poll(filp, NULL) & events;
-       else
-               revents = 0;
-
-       return (0);
-}
-
-static int
-linux_file_close(struct file *file, struct thread *td)
-{
-       struct linux_file *filp;
-       int error;
-
-       filp = (struct linux_file *)file->f_data;
-       filp->f_flags = file->f_flag;
-       error = -filp->f_op->release(NULL, filp);
-       funsetown(&filp->f_sigio);
-       kfree(filp);
-
-       return (error);
-}
-
-static int
-linux_file_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *cred,
-    struct thread *td)
-{
-       struct linux_file *filp;
-       int error;
-
-       filp = (struct linux_file *)fp->f_data;
-       filp->f_flags = fp->f_flag;
-       error = 0;
-
-       switch (cmd) {
-       case FIONBIO:
-               break;
-       case FIOASYNC:
-               if (filp->f_op->fasync == NULL)
-                       break;
-               error = filp->f_op->fasync(0, filp, fp->f_flag & FASYNC);
-               break;
-       case FIOSETOWN:
-               error = fsetown(*(int *)data, &filp->f_sigio);
-               if (error == 0)
-                       error = filp->f_op->fasync(0, filp,
-                           fp->f_flag & FASYNC);
-               break;
-       case FIOGETOWN:
-               *(int *)data = fgetown(&filp->f_sigio);
-               break;
-       default:
-               error = ENOTTY;
-               break;
-       }
-       return (error);
-}
-
-static int
-linux_file_stat(struct file *fp, struct stat *sb, struct ucred *active_cred,
-    struct thread *td)
-{
-
-       return (EOPNOTSUPP);
-}
-
-static int
-linux_file_fill_kinfo(struct file *fp, struct kinfo_file *kif,
-    struct filedesc *fdp)
-{
-
-       return (0);
-}
-
-struct fileops linuxfileops = {
-       .fo_read = linux_file_read,
-       .fo_write = invfo_rdwr,
-       .fo_truncate = invfo_truncate,
-       .fo_kqfilter = invfo_kqfilter,
-       .fo_stat = linux_file_stat,
-       .fo_fill_kinfo = linux_file_fill_kinfo,
-       .fo_poll = linux_file_poll,
-       .fo_close = linux_file_close,
-       .fo_ioctl = linux_file_ioctl,
-       .fo_chmod = invfo_chmod,
-       .fo_chown = invfo_chown,
-       .fo_sendfile = invfo_sendfile,
-};
-
-/*
- * Hash of vmmap addresses.  This is infrequently accessed and does not
- * need to be particularly large.  This is done because we must store the
- * caller's idea of the map size to properly unmap.
- */
-struct vmmap {
-       LIST_ENTRY(vmmap)       vm_next;
-       void                    *vm_addr;
-       unsigned long           vm_size;
-};
-
-struct vmmaphd {
-       struct vmmap *lh_first;
-};
-#define        VMMAP_HASH_SIZE 64
-#define        VMMAP_HASH_MASK (VMMAP_HASH_SIZE - 1)
-#define        VM_HASH(addr)   ((uintptr_t)(addr) >> PAGE_SHIFT) & VMMAP_HASH_MASK
-static struct vmmaphd vmmaphead[VMMAP_HASH_SIZE];
-static struct mtx vmmaplock;
-
-static void
-vmmap_add(void *addr, unsigned long size)
-{
-       struct vmmap *vmmap;
-
-       vmmap = kmalloc(sizeof(*vmmap), GFP_KERNEL);
-       mtx_lock(&vmmaplock);
-       vmmap->vm_size = size;
-       vmmap->vm_addr = addr;
-       LIST_INSERT_HEAD(&vmmaphead[VM_HASH(addr)], vmmap, vm_next);
-       mtx_unlock(&vmmaplock);
-}
-
-static struct vmmap *
-vmmap_remove(void *addr)
-{
-       struct vmmap *vmmap;
-
-       mtx_lock(&vmmaplock);
-       LIST_FOREACH(vmmap, &vmmaphead[VM_HASH(addr)], vm_next)
-               if (vmmap->vm_addr == addr)
-                       break;
-       if (vmmap)
-               LIST_REMOVE(vmmap, vm_next);
-       mtx_unlock(&vmmaplock);
-
-       return (vmmap);
-}
-
-void *
-_ioremap_attr(vm_paddr_t phys_addr, unsigned long size, int attr)
-{
-       void *addr;
-
-#if defined(__i386__) || defined(__amd64__)
-       addr = pmap_mapdev_attr(phys_addr, size, attr);
-#else
-       addr = NULL;
-#endif
-       if (addr == NULL)
-               return (NULL);
-       vmmap_add(addr, size);
-
-       return (addr);
-}
-
-void
-iounmap(void *addr)
-{
-       struct vmmap *vmmap;
-
-       vmmap = vmmap_remove(addr);
-       if (vmmap == NULL)
-               return;
-#if defined(__i386__) || defined(__amd64__)
-       pmap_unmapdev((vm_offset_t)addr, vmmap->vm_size);
-#endif
-       kfree(vmmap);
-}
-
-
-void *
-vmap(struct page **pages, unsigned int count, unsigned long flags, int prot)
-{
-       vm_offset_t off;
-       size_t size;
-
-       size = count * PAGE_SIZE;
-       off = kva_alloc(size);
-       if (off == 0)
-               return (NULL);
-       vmmap_add((void *)off, size);
-       pmap_qenter(off, pages, count);
-
-       return ((void *)off);
-}
-
-void
-vunmap(void *addr)
-{
-       struct vmmap *vmmap;
-
-       vmmap = vmmap_remove(addr);
-       if (vmmap == NULL)
-               return;
-       pmap_qremove((vm_offset_t)addr, vmmap->vm_size / PAGE_SIZE);
-       kva_free((vm_offset_t)addr, vmmap->vm_size);
-       kfree(vmmap);
-}
-
-char *
-kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
-{
-       unsigned int len;
-       char *p;
-       va_list aq;
-
-       va_copy(aq, ap);
-       len = vsnprintf(NULL, 0, fmt, aq);
-       va_end(aq);
-
-       p = kmalloc(len + 1, gfp);
-       if (p != NULL)
-               vsnprintf(p, len + 1, fmt, ap);
-
-       return (p);
-}
-
-char *
-kasprintf(gfp_t gfp, const char *fmt, ...)
-{
-       va_list ap;
-       char *p;
-
-       va_start(ap, fmt);
-       p = kvasprintf(gfp, fmt, ap);
-       va_end(ap);
-
-       return (p);
-}
-
-static int
-linux_timer_jiffies_until(unsigned long expires)
-{
-       int delta = expires - jiffies;
-       /* guard against already expired values */
-       if (delta < 1)
-               delta = 1;
-       return (delta);
-}
-
-static void
-linux_timer_callback_wrapper(void *context)
-{
-       struct timer_list *timer;
-
-       timer = context;
-       timer->function(timer->data);
-}
-
-void
-mod_timer(struct timer_list *timer, unsigned long expires)
-{
-
-       timer->expires = expires;
-       callout_reset(&timer->timer_callout,                  
-           linux_timer_jiffies_until(expires),
-           &linux_timer_callback_wrapper, timer);
-}
-
-void
-add_timer(struct timer_list *timer)
-{
-
-       callout_reset(&timer->timer_callout,
-           linux_timer_jiffies_until(timer->expires),
-           &linux_timer_callback_wrapper, timer);
-}
-
-static void
-linux_timer_init(void *arg)
-{
-
-       /*
-        * Compute an internal HZ value which can divide 2**32 to
-        * avoid timer rounding problems when the tick value wraps
-        * around 2**32:
-        */
-       linux_timer_hz_mask = 1;
-       while (linux_timer_hz_mask < (unsigned long)hz)
-               linux_timer_hz_mask *= 2;
-       linux_timer_hz_mask--;
-}
-SYSINIT(linux_timer, SI_SUB_DRIVERS, SI_ORDER_FIRST, linux_timer_init, NULL);
-
-void
-linux_complete_common(struct completion *c, int all)
-{
-       int wakeup_swapper;
-
-       sleepq_lock(c);
-       c->done++;
-       if (all)
-               wakeup_swapper = sleepq_broadcast(c, SLEEPQ_SLEEP, 0, 0);
-       else
-               wakeup_swapper = sleepq_signal(c, SLEEPQ_SLEEP, 0, 0);
-       sleepq_release(c);
-       if (wakeup_swapper)
-               kick_proc0();
-}
-
-/*
- * Indefinite wait for done != 0 with or without signals.
- */
-long
-linux_wait_for_common(struct completion *c, int flags)
-{
-
-       if (flags != 0)
-               flags = SLEEPQ_INTERRUPTIBLE | SLEEPQ_SLEEP;
-       else
-               flags = SLEEPQ_SLEEP;
-       for (;;) {
-               sleepq_lock(c);
-               if (c->done)
-                       break;
-               sleepq_add(c, NULL, "completion", flags, 0);
-               if (flags & SLEEPQ_INTERRUPTIBLE) {
-                       if (sleepq_wait_sig(c, 0) != 0)
-                               return (-ERESTARTSYS);
-               } else
-                       sleepq_wait(c, 0);
-       }
-       c->done--;
-       sleepq_release(c);
-
-       return (0);
-}
-
-/*
- * Time limited wait for done != 0 with or without signals.
- */
-long
-linux_wait_for_timeout_common(struct completion *c, long timeout, int flags)
-{
-       long end = jiffies + timeout;
-
-       if (flags != 0)
-               flags = SLEEPQ_INTERRUPTIBLE | SLEEPQ_SLEEP;
-       else
-               flags = SLEEPQ_SLEEP;
-       for (;;) {
-               int ret;
-
-               sleepq_lock(c);
-               if (c->done)
-                       break;
-               sleepq_add(c, NULL, "completion", flags, 0);
-               sleepq_set_timeout(c, linux_timer_jiffies_until(end));
-               if (flags & SLEEPQ_INTERRUPTIBLE)
-                       ret = sleepq_timedwait_sig(c, 0);
-               else
-                       ret = sleepq_timedwait(c, 0);
-               if (ret != 0) {
-                       /* check for timeout or signal */
-                       if (ret == EWOULDBLOCK)
-                               return (0);
-                       else
-                               return (-ERESTARTSYS);
-               }
-       }
-       c->done--;
-       sleepq_release(c);
-
-       /* return how many jiffies are left */
-       return (linux_timer_jiffies_until(end));
-}
-
-int
-linux_try_wait_for_completion(struct completion *c)
-{
-       int isdone;
-
-       isdone = 1;
-       sleepq_lock(c);
-       if (c->done)
-               c->done--;
-       else
-               isdone = 0;
-       sleepq_release(c);
-       return (isdone);
-}
-
-int
-linux_completion_done(struct completion *c)
-{
-       int isdone;
-
-       isdone = 1;
-       sleepq_lock(c);
-       if (c->done == 0)
-               isdone = 0;
-       sleepq_release(c);
-       return (isdone);
-}
-
-static void
-linux_compat_init(void *arg)
-{
-       struct sysctl_oid *rootoid;
-       int i;
-
-       rootoid = SYSCTL_ADD_ROOT_NODE(NULL,
-           OID_AUTO, "sys", CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, "sys");
-       kobject_init(&class_root, &class_ktype);
-       kobject_set_name(&class_root, "class");
-       class_root.oidp = SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(rootoid),
-           OID_AUTO, "class", CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, "class");
-       kobject_init(&linux_rootdev.kobj, &dev_ktype);
-       kobject_set_name(&linux_rootdev.kobj, "device");
-       linux_rootdev.kobj.oidp = SYSCTL_ADD_NODE(NULL,
-           SYSCTL_CHILDREN(rootoid), OID_AUTO, "device", CTLFLAG_RD, NULL,
-           "device");
-       linux_rootdev.bsddev = root_bus;
-       miscclass.name = "misc";
-       class_register(&miscclass);
-       INIT_LIST_HEAD(&pci_drivers);
-       INIT_LIST_HEAD(&pci_devices);
-       spin_lock_init(&pci_lock);
-       mtx_init(&vmmaplock, "IO Map lock", NULL, MTX_DEF);
-       for (i = 0; i < VMMAP_HASH_SIZE; i++)
-               LIST_INIT(&vmmaphead[i]);
-}
-SYSINIT(linux_compat, SI_SUB_DRIVERS, SI_ORDER_SECOND, linux_compat_init, NULL);
-
-static void
-linux_compat_uninit(void *arg)
-{
-       kobject_kfree_name(&class_root);
-       kobject_kfree_name(&linux_rootdev.kobj);
-       kobject_kfree_name(&miscclass.kobj);
-}
-SYSUNINIT(linux_compat, SI_SUB_DRIVERS, SI_ORDER_SECOND, linux_compat_uninit, NULL);
diff --git a/sys/ofed/include/linux/linux_idr.c b/sys/ofed/include/linux/linux_idr.c
deleted file mode 100644 (file)
index fa98622..0000000
+++ /dev/null
@@ -1,462 +0,0 @@
-/*-
- * 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-
-#include <machine/stdarg.h>
-
-#include <linux/bitops.h>
-#include <linux/kobject.h>
-#include <linux/slab.h>
-#include <linux/idr.h>
-#include <linux/err.h>
-
-/*
- * IDR Implementation.
- *
- * This is quick and dirty and not as re-entrant as the linux version
- * however it should be fairly fast.  It is basically a radix tree with
- * a builtin bitmap for allocation.
- */
-static MALLOC_DEFINE(M_IDR, "idr", "Linux IDR compat");
-
-static inline int
-idr_max(struct idr *idr)
-{
-       return (1 << (idr->layers * IDR_BITS)) - 1;
-}
-
-static inline int
-idr_pos(int id, int layer)
-{
-       return (id >> (IDR_BITS * layer)) & IDR_MASK;
-}
-
-void
-idr_init(struct idr *idr)
-{
-       bzero(idr, sizeof(*idr));
-       mtx_init(&idr->lock, "idr", NULL, MTX_DEF);
-}
-
-/* Only frees cached pages. */
-void
-idr_destroy(struct idr *idr)
-{
-       struct idr_layer *il, *iln;
-
-       idr_remove_all(idr);
-       mtx_lock(&idr->lock);
-       for (il = idr->free; il != NULL; il = iln) {
-               iln = il->ary[0];
-               free(il, M_IDR);
-       }
-       mtx_unlock(&idr->lock);
-}
-
-static void
-idr_remove_layer(struct idr_layer *il, int layer)
-{
-       int i;
-
-       if (il == NULL)
-               return;
-       if (layer == 0) {
-               free(il, M_IDR);
-               return;
-       }
-       for (i = 0; i < IDR_SIZE; i++)
-               if (il->ary[i])
-                       idr_remove_layer(il->ary[i], layer - 1);
-}
-
-void
-idr_remove_all(struct idr *idr)
-{
-
-       mtx_lock(&idr->lock);
-       idr_remove_layer(idr->top, idr->layers - 1);
-       idr->top = NULL;
-       idr->layers = 0;
-       mtx_unlock(&idr->lock);
-}
-
-void
-idr_remove(struct idr *idr, int id)
-{
-       struct idr_layer *il;
-       int layer;
-       int idx;
-
-       id &= MAX_ID_MASK;
-       mtx_lock(&idr->lock);
-       il = idr->top;
-       layer = idr->layers - 1;
-       if (il == NULL || id > idr_max(idr)) {
-               mtx_unlock(&idr->lock);
-               return;
-       }
-       /*
-        * Walk down the tree to this item setting bitmaps along the way
-        * as we know at least one item will be free along this path.
-        */
-       while (layer && il) {
-               idx = idr_pos(id, layer);
-               il->bitmap |= 1 << idx;
-               il = il->ary[idx];
-               layer--;
-       }
-       idx = id & IDR_MASK;
-       /*
-        * At this point we've set free space bitmaps up the whole tree.
-        * We could make this non-fatal and unwind but linux dumps a stack
-        * and a warning so I don't think it's necessary.
-        */
-       if (il == NULL || (il->bitmap & (1 << idx)) != 0)
-               panic("idr_remove: Item %d not allocated (%p, %p)\n",
-                   id, idr, il);
-       il->ary[idx] = NULL;
-       il->bitmap |= 1 << idx;
-       mtx_unlock(&idr->lock);
-       return;
-}
-
-void *
-idr_replace(struct idr *idr, void *ptr, int id)
-{
-       struct idr_layer *il;
-       void *res;
-       int layer;
-       int idx;
-
-       res = ERR_PTR(-EINVAL);
-       id &= MAX_ID_MASK;
-       mtx_lock(&idr->lock);
-       il = idr->top;
-       layer = idr->layers - 1;
-       if (il == NULL || id > idr_max(idr))
-               goto out;
-       while (layer && il) {
-               il = il->ary[idr_pos(id, layer)];
-               layer--;
-       }
-       idx = id & IDR_MASK;
-       /*
-        * Replace still returns an error if the item was not allocated.
-        */
-       if (il != NULL && (il->bitmap & (1 << idx)) != 0) {
-               res = il->ary[idx];
-               il->ary[idx] = ptr;
-       }
-out:
-       mtx_unlock(&idr->lock);
-       return (res);
-}
-
-static inline void *
-idr_find_locked(struct idr *idr, int id)
-{
-       struct idr_layer *il;
-       void *res;
-       int layer;
-
-       mtx_assert(&idr->lock, MA_OWNED);
-
-       id &= MAX_ID_MASK;
-       res = NULL;
-       il = idr->top;
-       layer = idr->layers - 1;
-       if (il == NULL || id > idr_max(idr))
-               return (NULL);
-       while (layer && il) {
-               il = il->ary[idr_pos(id, layer)];
-               layer--;
-       }
-       if (il != NULL)
-               res = il->ary[id & IDR_MASK];
-       return (res);
-}
-
-void *
-idr_find(struct idr *idr, int id)
-{
-       void *res;
-
-       mtx_lock(&idr->lock);
-       res = idr_find_locked(idr, id);
-       mtx_unlock(&idr->lock);
-       return (res);
-}
-
-int
-idr_pre_get(struct idr *idr, gfp_t gfp_mask)
-{
-       struct idr_layer *il, *iln;
-       struct idr_layer *head;
-       int need;
-
-       mtx_lock(&idr->lock);
-       for (;;) {
-               need = idr->layers + 1;
-               for (il = idr->free; il != NULL; il = il->ary[0])
-                       need--;
-               mtx_unlock(&idr->lock);
-               if (need <= 0)
-                       break;
-               for (head = NULL; need; need--) {
-                       iln = malloc(sizeof(*il), M_IDR, M_ZERO | gfp_mask);
-                       if (iln == NULL)
-                               break;
-                       bitmap_fill(&iln->bitmap, IDR_SIZE);
-                       if (head != NULL) {
-                               il->ary[0] = iln;
-                               il = iln;
-                       } else
-                               head = il = iln;
-               }
-               if (head == NULL)
-                       return (0);
-               mtx_lock(&idr->lock);
-               il->ary[0] = idr->free;
-               idr->free = head;
-       }
-       return (1);
-}
-
-static inline struct idr_layer *
-idr_get(struct idr *idr)
-{
-       struct idr_layer *il;
-
-       il = idr->free;
-       if (il) {
-               idr->free = il->ary[0];
-               il->ary[0] = NULL;
-               return (il);
-       }
-       il = malloc(sizeof(*il), M_IDR, M_ZERO | M_NOWAIT);
-       bitmap_fill(&il->bitmap, IDR_SIZE);
-       return (il);
-}
-
-/*
- * Could be implemented as get_new_above(idr, ptr, 0, idp) but written
- * first for simplicity sake.
- */
-int
-idr_get_new(struct idr *idr, void *ptr, int *idp)
-{
-       struct idr_layer *stack[MAX_LEVEL];
-       struct idr_layer *il;
-       int error;
-       int layer;
-       int idx;
-       int id;
-
-       error = -EAGAIN;
-       mtx_lock(&idr->lock);
-       /*
-        * Expand the tree until there is free space.
-        */
-       if (idr->top == NULL || idr->top->bitmap == 0) {
-               if (idr->layers == MAX_LEVEL + 1) {
-                       error = -ENOSPC;
-                       goto out;
-               }
-               il = idr_get(idr);
-               if (il == NULL)
-                       goto out;
-               il->ary[0] = idr->top;
-               if (idr->top)
-                       il->bitmap &= ~1;
-               idr->top = il;
-               idr->layers++;
-       }
-       il = idr->top;
-       id = 0;
-       /*
-        * Walk the tree following free bitmaps, record our path.
-        */
-       for (layer = idr->layers - 1;; layer--) {
-               stack[layer] = il;
-               idx = ffsl(il->bitmap);
-               if (idx == 0)
-                       panic("idr_get_new: Invalid leaf state (%p, %p)\n",
-                           idr, il);
-               idx--;
-               id |= idx << (layer * IDR_BITS);
-               if (layer == 0)
-                       break;
-               if (il->ary[idx] == NULL) {
-                       il->ary[idx] = idr_get(idr);
-                       if (il->ary[idx] == NULL)
-                               goto out;
-               }
-               il = il->ary[idx];
-       }
-       /*
-        * Allocate the leaf to the consumer.
-        */
-       il->bitmap &= ~(1 << idx);
-       il->ary[idx] = ptr;
-       *idp = id;
-       /*
-        * Clear bitmaps potentially up to the root.
-        */
-       while (il->bitmap == 0 && ++layer < idr->layers) {
-               il = stack[layer];
-               il->bitmap &= ~(1 << idr_pos(id, layer));
-       }
-       error = 0;
-out:
-#ifdef INVARIANTS
-       if (error == 0 && idr_find_locked(idr, id) != ptr) {
-               panic("idr_get_new: Failed for idr %p, id %d, ptr %p\n",
-                   idr, id, ptr);
-       }
-#endif
-       mtx_unlock(&idr->lock);
-       return (error);
-}
-
-int
-idr_get_new_above(struct idr *idr, void *ptr, int starting_id, int *idp)
-{
-       struct idr_layer *stack[MAX_LEVEL];
-       struct idr_layer *il;
-       int error;
-       int layer;
-       int idx, sidx;
-       int id;
-
-       error = -EAGAIN;
-       mtx_lock(&idr->lock);
-       /*
-        * Compute the layers required to support starting_id and the mask
-        * at the top layer.
-        */
-restart:
-       idx = starting_id;
-       layer = 0;
-       while (idx & ~IDR_MASK) {
-               layer++;
-               idx >>= IDR_BITS;
-       }
-       if (layer == MAX_LEVEL + 1) {
-               error = -ENOSPC;
-               goto out;
-       }
-       /*
-        * Expand the tree until there is free space at or beyond starting_id.
-        */
-       while (idr->layers <= layer ||
-           idr->top->bitmap < (1 << idr_pos(starting_id, idr->layers - 1))) {
-               if (idr->layers == MAX_LEVEL + 1) {
-                       error = -ENOSPC;
-                       goto out;
-               }
-               il = idr_get(idr);
-               if (il == NULL)
-                       goto out;
-               il->ary[0] = idr->top;
-               if (idr->top && idr->top->bitmap == 0)
-                       il->bitmap &= ~1;
-               idr->top = il;
-               idr->layers++;
-       }
-       il = idr->top;
-       id = 0;
-       /*
-        * Walk the tree following free bitmaps, record our path.
-        */
-       for (layer = idr->layers - 1;; layer--) {
-               stack[layer] = il;
-               sidx = idr_pos(starting_id, layer);
-               /* Returns index numbered from 0 or size if none exists. */
-               idx = find_next_bit(&il->bitmap, IDR_SIZE, sidx);
-               if (idx == IDR_SIZE && sidx == 0)
-                       panic("idr_get_new: Invalid leaf state (%p, %p)\n",
-                           idr, il);
-               /*
-                * We may have walked a path where there was a free bit but
-                * it was lower than what we wanted.  Restart the search with
-                * a larger starting id.  id contains the progress we made so
-                * far.  Search the leaf one above this level.  This may
-                * restart as many as MAX_LEVEL times but that is expected
-                * to be rare.
-                */
-               if (idx == IDR_SIZE) {
-                       starting_id = id + (1 << ((layer + 1) * IDR_BITS));
-                       goto restart;
-               }
-               if (idx > sidx)
-                       starting_id = 0;        /* Search the whole subtree. */
-               id |= idx << (layer * IDR_BITS);
-               if (layer == 0)
-                       break;
-               if (il->ary[idx] == NULL) {
-                       il->ary[idx] = idr_get(idr);
-                       if (il->ary[idx] == NULL)
-                               goto out;
-               }
-               il = il->ary[idx];
-       }
-       /*
-        * Allocate the leaf to the consumer.
-        */
-       il->bitmap &= ~(1 << idx);
-       il->ary[idx] = ptr;
-       *idp = id;
-       /*
-        * Clear bitmaps potentially up to the root.
-        */
-       while (il->bitmap == 0 && ++layer < idr->layers) {
-               il = stack[layer];
-               il->bitmap &= ~(1 << idr_pos(id, layer));
-       }
-       error = 0;
-out:
-#ifdef INVARIANTS
-       if (error == 0 && idr_find_locked(idr, id) != ptr) {
-               panic("idr_get_new_above: Failed for idr %p, id %d, ptr %p\n",
-                   idr, id, ptr);
-       }
-#endif
-       mtx_unlock(&idr->lock);
-       return (error);
-}
diff --git a/sys/ofed/include/linux/linux_kmod.c b/sys/ofed/include/linux/linux_kmod.c
deleted file mode 100644 (file)
index efe16fb..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * Copyright (c) 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/module.h>
-
-MODULE_VERSION(linuxkpi, 1);
-MODULE_DEPEND(linuxkpi, pci, 1, 1, 1);
-
diff --git a/sys/ofed/include/linux/linux_pci.c b/sys/ofed/include/linux/linux_pci.c
deleted file mode 100644 (file)
index 2d3d03b..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/*-
- * Copyright (c) 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/bus.h>
-#include <sys/fcntl.h>
-#include <sys/file.h>
-#include <sys/filio.h>
-#include <sys/rwlock.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <machine/stdarg.h>
-#include <machine/pmap.h>
-
-#include <linux/kobject.h>
-#include <linux/device.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/cdev.h>
-#include <linux/file.h>
-#include <linux/sysfs.h>
-#include <linux/mm.h>
-#include <linux/io.h>
-#include <linux/vmalloc.h>
-#include <linux/pci.h>
-
-static device_probe_t linux_pci_probe;
-static device_attach_t linux_pci_attach;
-static device_detach_t linux_pci_detach;
-
-static device_method_t pci_methods[] = {
-       DEVMETHOD(device_probe, linux_pci_probe),
-       DEVMETHOD(device_attach, linux_pci_attach),
-       DEVMETHOD(device_detach, linux_pci_detach),
-       DEVMETHOD_END
-};
-
-static struct pci_driver *
-linux_pci_find(device_t dev, const struct pci_device_id **idp)
-{
-       const struct pci_device_id *id;
-       struct pci_driver *pdrv;
-       uint16_t vendor;
-       uint16_t device;
-
-       vendor = pci_get_vendor(dev);
-       device = pci_get_device(dev);
-
-       spin_lock(&pci_lock);
-       list_for_each_entry(pdrv, &pci_drivers, links) {
-               for (id = pdrv->id_table; id->vendor != 0; id++) {
-                       if (vendor == id->vendor && device == id->device) {
-                               *idp = id;
-                               spin_unlock(&pci_lock);
-                               return (pdrv);
-                       }
-               }
-       }
-       spin_unlock(&pci_lock);
-       return (NULL);
-}
-
-static int
-linux_pci_probe(device_t dev)
-{
-       const struct pci_device_id *id;
-       struct pci_driver *pdrv;
-
-       if ((pdrv = linux_pci_find(dev, &id)) == NULL)
-               return (ENXIO);
-       if (device_get_driver(dev) != &pdrv->driver)
-               return (ENXIO);
-       device_set_desc(dev, pdrv->name);
-       return (0);
-}
-
-static int
-linux_pci_attach(device_t dev)
-{
-       struct resource_list_entry *rle;
-       struct pci_dev *pdev;
-       struct pci_driver *pdrv;
-       const struct pci_device_id *id;
-       int error;
-
-       pdrv = linux_pci_find(dev, &id);
-       pdev = device_get_softc(dev);
-       pdev->dev.parent = &linux_rootdev;
-       pdev->dev.bsddev = dev;
-       INIT_LIST_HEAD(&pdev->dev.irqents);
-       pdev->device = id->device;
-       pdev->vendor = id->vendor;
-       pdev->dev.dma_mask = &pdev->dma_mask;
-       pdev->pdrv = pdrv;
-       kobject_init(&pdev->dev.kobj, &dev_ktype);
-       kobject_set_name(&pdev->dev.kobj, device_get_nameunit(dev));
-       kobject_add(&pdev->dev.kobj, &linux_rootdev.kobj,
-           kobject_name(&pdev->dev.kobj));
-       rle = _pci_get_rle(pdev, SYS_RES_IRQ, 0);
-       if (rle)
-               pdev->dev.irq = rle->start;
-       else
-               pdev->dev.irq = 0;
-       pdev->irq = pdev->dev.irq;
-       mtx_unlock(&Giant);
-       spin_lock(&pci_lock);
-       list_add(&pdev->links, &pci_devices);
-       spin_unlock(&pci_lock);
-       error = pdrv->probe(pdev, id);
-       mtx_lock(&Giant);
-       if (error) {
-               spin_lock(&pci_lock);
-               list_del(&pdev->links);
-               spin_unlock(&pci_lock);
-               put_device(&pdev->dev);
-               return (-error);
-       }
-       return (0);
-}
-
-static int
-linux_pci_detach(device_t dev)
-{
-       struct pci_dev *pdev;
-
-       pdev = device_get_softc(dev);
-       mtx_unlock(&Giant);
-       pdev->pdrv->remove(pdev);
-       mtx_lock(&Giant);
-       spin_lock(&pci_lock);
-       list_del(&pdev->links);
-       spin_unlock(&pci_lock);
-       put_device(&pdev->dev);
-
-       return (0);
-}
-
-int
-pci_register_driver(struct pci_driver *pdrv)
-{
-       devclass_t bus;
-       int error = 0;
-
-       bus = devclass_find("pci");
-
-       spin_lock(&pci_lock);
-       list_add(&pdrv->links, &pci_drivers);
-       spin_unlock(&pci_lock);
-       pdrv->driver.name = pdrv->name;
-       pdrv->driver.methods = pci_methods;
-       pdrv->driver.size = sizeof(struct pci_dev);
-       mtx_lock(&Giant);
-       if (bus != NULL) {
-               error = devclass_add_driver(bus, &pdrv->driver, BUS_PASS_DEFAULT,
-                   &pdrv->bsdclass);
-       }
-       mtx_unlock(&Giant);
-       return (-error);
-}
-
-void
-pci_unregister_driver(struct pci_driver *pdrv)
-{
-       devclass_t bus;
-
-       bus = devclass_find("pci");
-
-       list_del(&pdrv->links);
-       mtx_lock(&Giant);
-       if (bus != NULL)
-               devclass_delete_driver(bus, &pdrv->driver);
-       mtx_unlock(&Giant);
-}
-
diff --git a/sys/ofed/include/linux/linux_radix.c b/sys/ofed/include/linux/linux_radix.c
deleted file mode 100644 (file)
index 1cd9e45..0000000
+++ /dev/null
@@ -1,218 +0,0 @@
-/*-
- * 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-
-#include <linux/slab.h>
-#include <linux/kernel.h>
-#include <linux/radix-tree.h>
-#include <linux/err.h>
-
-static MALLOC_DEFINE(M_RADIX, "radix", "Linux radix compat");
-
-static inline int
-radix_max(struct radix_tree_root *root)
-{
-       return (1 << (root->height * RADIX_TREE_MAP_SHIFT)) - 1;
-}
-
-static inline int
-radix_pos(long id, int height)
-{
-       return (id >> (RADIX_TREE_MAP_SHIFT * height)) & RADIX_TREE_MAP_MASK;
-}
-
-void *
-radix_tree_lookup(struct radix_tree_root *root, unsigned long index)
-{
-       struct radix_tree_node *node;
-       void *item;
-       int height;
-
-       item = NULL;
-       node = root->rnode;
-       height = root->height - 1;
-       if (index > radix_max(root))
-               goto out;
-       while (height && node)
-               node = node->slots[radix_pos(index, height--)];
-       if (node)
-               item = node->slots[radix_pos(index, 0)];
-
-out:
-       return (item);
-}
-
-void *
-radix_tree_delete(struct radix_tree_root *root, unsigned long index)
-{
-       struct radix_tree_node *stack[RADIX_TREE_MAX_HEIGHT];
-       struct radix_tree_node *node;
-       void *item;
-       int height;
-       int idx;
-
-       item = NULL;
-       node = root->rnode;
-       height = root->height - 1;
-       if (index > radix_max(root))
-               goto out;
-       /*
-        * Find the node and record the path in stack.
-        */
-       while (height && node) {
-               stack[height] = node;
-               node = node->slots[radix_pos(index, height--)];
-       }
-       idx = radix_pos(index, 0);
-       if (node)
-               item = node->slots[idx];
-       /*
-        * If we removed something reduce the height of the tree.
-        */
-       if (item)
-               for (;;) {
-                       node->slots[idx] = NULL;
-                       node->count--;
-                       if (node->count > 0)
-                               break;
-                       free(node, M_RADIX);
-                       if (node == root->rnode) {
-                               root->rnode = NULL;
-                               root->height = 0;
-                               break;
-                       }
-                       height++;
-                       node = stack[height];
-                       idx = radix_pos(index, height);
-               }
-out:
-       return (item);
-}
-
-int
-radix_tree_insert(struct radix_tree_root *root, unsigned long index, void *item)
-{
-       struct radix_tree_node *node;
-       struct radix_tree_node *temp[RADIX_TREE_MAX_HEIGHT - 1];
-       int height;
-       int idx;
-
-       /* bail out upon insertion of a NULL item */
-       if (item == NULL)
-               return (-EINVAL);
-
-       /* get root node, if any */
-       node = root->rnode;
-
-       /* allocate root node, if any */
-       if (node == NULL) {
-               node = malloc(sizeof(*node), M_RADIX, root->gfp_mask | M_ZERO);
-               if (node == NULL)
-                       return (-ENOMEM);
-               root->rnode = node;
-               root->height++;
-       }
-
-       /* expand radix tree as needed */
-       while (radix_max(root) < index) {
-
-               /* check if the radix tree is getting too big */
-               if (root->height == RADIX_TREE_MAX_HEIGHT)
-                       return (-E2BIG);
-
-               /*
-                * If the root radix level is not empty, we need to
-                * allocate a new radix level:
-                */
-               if (node->count != 0) {
-                       node = malloc(sizeof(*node), M_RADIX, root->gfp_mask | M_ZERO);
-                       if (node == NULL)
-                               return (-ENOMEM);
-                       node->slots[0] = root->rnode;
-                       node->count++;
-                       root->rnode = node;
-               }
-               root->height++;
-       }
-
-       /* get radix tree height index */
-       height = root->height - 1;
-
-       /* walk down the tree until the first missing node, if any */
-       for ( ; height != 0; height--) {
-               idx = radix_pos(index, height);
-               if (node->slots[idx] == NULL)
-                       break;
-               node = node->slots[idx];
-       }
-
-       /* allocate the missing radix levels, if any */
-       for (idx = 0; idx != height; idx++) {
-               temp[idx] = malloc(sizeof(*node), M_RADIX,
-                   root->gfp_mask | M_ZERO);
-               if (temp[idx] == NULL) {
-                       while(idx--)
-                               free(temp[idx], M_RADIX);
-                       /* check if we should free the root node aswell */
-                       if (root->rnode->count == 0) {
-                               free(root->rnode, M_RADIX);
-                               root->rnode = NULL;
-                               root->height = 0;
-                       }
-                       return (-ENOMEM);
-               }
-       }
-
-       /* setup new radix levels, if any */
-       for ( ; height != 0; height--) {
-               idx = radix_pos(index, height);
-               node->slots[idx] = temp[height - 1];
-               node->count++;
-               node = node->slots[idx];
-       }
-
-       /*
-        * Insert and adjust count if the item does not already exist.
-        */
-       idx = radix_pos(index, 0);
-       if (node->slots[idx])
-               return (-EEXIST);
-       node->slots[idx] = item;
-       node->count++;
-       
-       return (0);
-}
diff --git a/sys/ofed/include/linux/list.h b/sys/ofed/include/linux/list.h
deleted file mode 100644 (file)
index bfa7d97..0000000
+++ /dev/null
@@ -1,432 +0,0 @@
-/*-
- * 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 _LINUX_LIST_H_
-#define _LINUX_LIST_H_
-
-/*
- * Since LIST_HEAD conflicts with the linux definition we must include any
- * FreeBSD header which requires it here so it is resolved with the correct
- * definition prior to the undef.
- */
-#include <linux/types.h>
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/queue.h>
-#include <sys/cpuset.h>
-#include <sys/jail.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <sys/conf.h>
-#include <sys/socket.h>
-#include <sys/mbuf.h>
-
-#include <net/bpf.h>
-#include <net/if.h>
-#include <net/if_var.h>
-#include <net/if_types.h>
-#include <net/if_media.h>
-#include <net/vnet.h>
-
-#include <netinet/in.h>
-#include <netinet/in_pcb.h>
-#include <netinet/in_var.h>
-
-#include <netinet6/in6_var.h>
-#include <netinet6/nd6.h>
-
-#include <vm/vm.h>
-#include <vm/vm_object.h>
-
-#define        prefetch(x)
-
-struct list_head {
-       struct list_head *next;
-       struct list_head *prev;
-};
-
-static inline void
-INIT_LIST_HEAD(struct list_head *list)
-{
-
-       list->next = list->prev = list;
-}
-static inline int
-list_empty(const struct list_head *head)
-{
-
-       return (head->next == head);
-}
-
-static inline void
-list_del(struct list_head *entry)
-{
-
-       entry->next->prev = entry->prev;
-       entry->prev->next = entry->next;
-}
-
-static inline void
-list_replace(struct list_head *old, struct list_head *new)
-{
-       new->next = old->next;
-       new->next->prev = new;
-       new->prev = old->prev;
-       new->prev->next = new;
-}
-
-static inline void
-_list_add(struct list_head *new, struct list_head *prev,
-    struct list_head *next)
-{
-
-       next->prev = new;
-       new->next = next;
-       new->prev = prev;
-       prev->next = new;
-}
-
-static inline void
-list_del_init(struct list_head *entry)
-{      
-
-       list_del(entry);
-       INIT_LIST_HEAD(entry);
-}
-
-#define        list_entry(ptr, type, field)    container_of(ptr, type, field)
-
-#define list_first_entry(ptr, type, member) \
-        list_entry((ptr)->next, type, member)
-
-#define        list_next_entry(ptr, member)                                    \
-       list_entry(((ptr)->member.next), typeof(*(ptr)), member)
-
-#define        list_for_each(p, head)                                          \
-       for (p = (head)->next; p != (head); p = p->next)
-
-#define        list_for_each_safe(p, n, head)                                  \
-       for (p = (head)->next, n = p->next; p != (head); p = n, n = p->next)
-
-#define list_for_each_entry(p, h, field)                               \
-       for (p = list_entry((h)->next, typeof(*p), field); &p->field != (h); \
-           p = list_entry(p->field.next, typeof(*p), field))
-
-#define list_for_each_entry_safe(p, n, h, field)                       \
-       for (p = list_entry((h)->next, typeof(*p), field),              \
-           n = list_entry(p->field.next, typeof(*p), field); &p->field != (h);\
-           p = n, n = list_entry(n->field.next, typeof(*n), field))
-
-#define        list_for_each_entry_continue(p, h, field)                       \
-       for (p = list_next_entry((p), field); &p->field != (h);         \
-           p = list_next_entry((p), field))
-
-#define        list_for_each_entry_safe_from(pos, n, head, member)                     \
-       for (n = list_entry(pos->member.next, typeof(*pos), member);            \
-            &pos->member != (head);                                            \
-            pos = n, n = list_entry(n->member.next, typeof(*n), member))
-
-#define        list_for_each_entry_reverse(p, h, field)                        \
-       for (p = list_entry((h)->prev, typeof(*p), field); &p->field != (h); \
-           p = list_entry(p->field.prev, typeof(*p), field))
-
-#define        list_for_each_prev(p, h) for (p = (h)->prev; p != (h); p = p->prev)
-
-static inline void
-list_add(struct list_head *new, struct list_head *head)
-{
-
-       _list_add(new, head, head->next);
-}
-
-static inline void
-list_add_tail(struct list_head *new, struct list_head *head)
-{
-
-       _list_add(new, head->prev, head);
-}
-
-static inline void
-list_move(struct list_head *list, struct list_head *head)
-{
-
-       list_del(list);
-       list_add(list, head);
-}
-
-static inline void
-list_move_tail(struct list_head *entry, struct list_head *head)
-{
-
-       list_del(entry);
-       list_add_tail(entry, head);
-}
-
-static inline void
-_list_splice(const struct list_head *list, struct list_head *prev,  
-    struct list_head *next)
-{
-       struct list_head *first;
-       struct list_head *last;
-
-       if (list_empty(list))
-               return;
-       first = list->next;
-       last = list->prev;
-       first->prev = prev;
-       prev->next = first;
-       last->next = next;
-       next->prev = last;
-}
-
-static inline void
-list_splice(const struct list_head *list, struct list_head *head)
-{
-
-       _list_splice(list, head, head->next);
-} 
-
-static inline void
-list_splice_tail(struct list_head *list, struct list_head *head)
-{
-
-       _list_splice(list, head->prev, head);
-}
-static inline void
-list_splice_init(struct list_head *list, struct list_head *head)
-{
-
-       _list_splice(list, head, head->next);
-       INIT_LIST_HEAD(list);   
-}
-static inline void
-list_splice_tail_init(struct list_head *list, struct list_head *head)
-{
-
-       _list_splice(list, head->prev, head);
-       INIT_LIST_HEAD(list);
-}
-
-#undef LIST_HEAD
-#define LIST_HEAD(name)        struct list_head name = { &(name), &(name) }
-
-
-struct hlist_head {
-       struct hlist_node *first;
-};
-
-struct hlist_node {
-       struct hlist_node *next, **pprev;
-};
-
-#define        HLIST_HEAD_INIT { }
-#define        HLIST_HEAD(name) struct hlist_head name = HLIST_HEAD_INIT
-#define        INIT_HLIST_HEAD(head) (head)->first = NULL
-#define        INIT_HLIST_NODE(node)                                           \
-do {                                                                   \
-       (node)->next = NULL;                                            \
-       (node)->pprev = NULL;                                           \
-} while (0)
-
-static inline int
-hlist_unhashed(const struct hlist_node *h)
-{
-
-       return !h->pprev;
-}
-
-static inline int
-hlist_empty(const struct hlist_head *h)
-{
-
-       return !h->first;
-}
-
-static inline void
-hlist_del(struct hlist_node *n)
-{
-
-        if (n->next)
-                n->next->pprev = n->pprev;
-        *n->pprev = n->next;
-}
-
-static inline void
-hlist_del_init(struct hlist_node *n)
-{
-
-       if (hlist_unhashed(n))
-               return;
-       hlist_del(n);
-       INIT_HLIST_NODE(n);
-}
-
-static inline void
-hlist_add_head(struct hlist_node *n, struct hlist_head *h)
-{
-
-       n->next = h->first;
-       if (h->first)
-               h->first->pprev = &n->next;
-       h->first = n;
-       n->pprev = &h->first;
-}
-
-static inline void
-hlist_add_before(struct hlist_node *n, struct hlist_node *next)
-{
-
-       n->pprev = next->pprev;
-       n->next = next;
-       next->pprev = &n->next;
-       *(n->pprev) = n;
-}
-static inline void
-hlist_add_after(struct hlist_node *n, struct hlist_node *next)
-{
-
-       next->next = n->next;
-       n->next = next;
-       next->pprev = &n->next;
-       if (next->next)
-               next->next->pprev = &next->next;
-}
-static inline void
-hlist_move_list(struct hlist_head *old, struct hlist_head *new)
-{
-
-       new->first = old->first;
-       if (new->first)
-               new->first->pprev = &new->first;
-       old->first = NULL;
-}
-
-/**
- * list_is_singular - tests whether a list has just one entry.
- * @head: the list to test.
- */
-static inline int list_is_singular(const struct list_head *head)
-{
-       return !list_empty(head) && (head->next == head->prev);
-}
-
-static inline void __list_cut_position(struct list_head *list,
-               struct list_head *head, struct list_head *entry)
-{
-       struct list_head *new_first = entry->next;
-       list->next = head->next;
-       list->next->prev = list;
-       list->prev = entry;
-       entry->next = list;
-       head->next = new_first;
-       new_first->prev = head;
-}
-
-/**
- * list_cut_position - cut a list into two
- * @list: a new list to add all removed entries
- * @head: a list with entries
- * @entry: an entry within head, could be the head itself
- *     and if so we won't cut the list
- *
- * This helper moves the initial part of @head, up to and
- * including @entry, from @head to @list. You should
- * pass on @entry an element you know is on @head. @list
- * should be an empty list or a list you do not care about
- * losing its data.
- *
- */
-static inline void list_cut_position(struct list_head *list,
-               struct list_head *head, struct list_head *entry)
-{
-       if (list_empty(head))
-               return;
-       if (list_is_singular(head) &&
-               (head->next != entry && head != entry))
-               return;
-       if (entry == head)
-               INIT_LIST_HEAD(list);
-       else
-               __list_cut_position(list, head, entry);
-}
-
-/**
- *  list_is_last - tests whether @list is the last entry in list @head
- *   @list: the entry to test
- *    @head: the head of the list
- */
-static inline int list_is_last(const struct list_head *list,
-                                const struct list_head *head)
-{
-        return list->next == head;
-}
-#define        hlist_entry(ptr, type, field)   container_of(ptr, type, field)
-
-#define        hlist_for_each(p, head)                                         \
-       for (p = (head)->first; p; p = p->next)
-
-#define        hlist_for_each_safe(p, n, head)                                 \
-       for (p = (head)->first; p && ({ n = p->next; 1; }); p = n)
-
-#define        hlist_entry_safe(ptr, type, member) \
-       ((ptr) ? hlist_entry(ptr, type, member) : NULL)
-
-#define        hlist_for_each_entry(pos, head, member)                         \
-       for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\
-            pos;                                                       \
-            pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
-
-#define hlist_for_each_entry_continue(tp, p, field)                    \
-       for (p = (p)->next;                                             \
-           p ? (tp = hlist_entry(p, typeof(*tp), field)): NULL; p = p->next)
-
-#define        hlist_for_each_entry_from(tp, p, field)                         \
-       for (; p ? (tp = hlist_entry(p, typeof(*tp), field)): NULL; p = p->next)
-
-#define hlist_for_each_entry_safe(tpos, pos, n, head, member)           \
-       for (pos = (head)->first;                                        \
-            (pos) != 0 && ({ n = (pos)->next; \
-                tpos = hlist_entry((pos), typeof(*(tpos)), member); 1;}); \
-            pos = (n))
-
-#define        hlist_add_head_rcu(n, h)        hlist_add_head(n, h)
-
-#define        hlist_del_init_rcu(n)           hlist_del_init(n)
-
-#endif /* _LINUX_LIST_H_ */
diff --git a/sys/ofed/include/linux/lockdep.h b/sys/ofed/include/linux/lockdep.h
deleted file mode 100644 (file)
index 2738693..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * 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        _LINUX_LOCKDEP_H_
-#define        _LINUX_LOCKDEP_H_
-
-struct lock_class_key {
-};
-
-#define lockdep_set_class(lock, key)
-
-#define lockdep_set_class_and_name(lock, key, name)
-
-#endif  /* _LINUX_LOCKDEP_H_ */
diff --git a/sys/ofed/include/linux/log2.h b/sys/ofed/include/linux/log2.h
deleted file mode 100644 (file)
index a44c560..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*-
- * 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_LOG2_H_
-#define        _LINUX_LOG2_H_
-
-#include <linux/types.h>
-
-#include <sys/libkern.h>
-
-static inline unsigned long
-roundup_pow_of_two(unsigned long x)
-{
-       return (1UL << flsl(x - 1));
-}
-
-static inline int
-is_power_of_2(unsigned long n)
-{
-       return (n == roundup_pow_of_two(n));
-}
-
-static inline unsigned long
-rounddown_pow_of_two(unsigned long x)
-{
-        return (1UL << (flsl(x) - 1));
-}
-
-#define        ilog2(n)                                \
-(                                              \
-       __builtin_constant_p(n) ? (             \
-               (n) < 1 ? -1 :                  \
-               (n) & (1ULL << 63) ? 63 :       \
-               (n) & (1ULL << 62) ? 62 :       \
-               (n) & (1ULL << 61) ? 61 :       \
-               (n) & (1ULL << 60) ? 60 :       \
-               (n) & (1ULL << 59) ? 59 :       \
-               (n) & (1ULL << 58) ? 58 :       \
-               (n) & (1ULL << 57) ? 57 :       \
-               (n) & (1ULL << 56) ? 56 :       \
-               (n) & (1ULL << 55) ? 55 :       \
-               (n) & (1ULL << 54) ? 54 :       \
-               (n) & (1ULL << 53) ? 53 :       \
-               (n) & (1ULL << 52) ? 52 :       \
-               (n) & (1ULL << 51) ? 51 :       \
-               (n) & (1ULL << 50) ? 50 :       \
-               (n) & (1ULL << 49) ? 49 :       \
-               (n) & (1ULL << 48) ? 48 :       \
-               (n) & (1ULL << 47) ? 47 :       \
-               (n) & (1ULL << 46) ? 46 :       \
-               (n) & (1ULL << 45) ? 45 :       \
-               (n) & (1ULL << 44) ? 44 :       \
-               (n) & (1ULL << 43) ? 43 :       \
-               (n) & (1ULL << 42) ? 42 :       \
-               (n) & (1ULL << 41) ? 41 :       \
-               (n) & (1ULL << 40) ? 40 :       \
-               (n) & (1ULL << 39) ? 39 :       \
-               (n) & (1ULL << 38) ? 38 :       \
-               (n) & (1ULL << 37) ? 37 :       \
-               (n) & (1ULL << 36) ? 36 :       \
-               (n) & (1ULL << 35) ? 35 :       \
-               (n) & (1ULL << 34) ? 34 :       \
-               (n) & (1ULL << 33) ? 33 :       \
-               (n) & (1ULL << 32) ? 32 :       \
-               (n) & (1ULL << 31) ? 31 :       \
-               (n) & (1ULL << 30) ? 30 :       \
-               (n) & (1ULL << 29) ? 29 :       \
-               (n) & (1ULL << 28) ? 28 :       \
-               (n) & (1ULL << 27) ? 27 :       \
-               (n) & (1ULL << 26) ? 26 :       \
-               (n) & (1ULL << 25) ? 25 :       \
-               (n) & (1ULL << 24) ? 24 :       \
-               (n) & (1ULL << 23) ? 23 :       \
-               (n) & (1ULL << 22) ? 22 :       \
-               (n) & (1ULL << 21) ? 21 :       \
-               (n) & (1ULL << 20) ? 20 :       \
-               (n) & (1ULL << 19) ? 19 :       \
-               (n) & (1ULL << 18) ? 18 :       \
-               (n) & (1ULL << 17) ? 17 :       \
-               (n) & (1ULL << 16) ? 16 :       \
-               (n) & (1ULL << 15) ? 15 :       \
-               (n) & (1ULL << 14) ? 14 :       \
-               (n) & (1ULL << 13) ? 13 :       \
-               (n) & (1ULL << 12) ? 12 :       \
-               (n) & (1ULL << 11) ? 11 :       \
-               (n) & (1ULL << 10) ? 10 :       \
-               (n) & (1ULL <<  9) ?  9 :       \
-               (n) & (1ULL <<  8) ?  8 :       \
-               (n) & (1ULL <<  7) ?  7 :       \
-               (n) & (1ULL <<  6) ?  6 :       \
-               (n) & (1ULL <<  5) ?  5 :       \
-               (n) & (1ULL <<  4) ?  4 :       \
-               (n) & (1ULL <<  3) ?  3 :       \
-               (n) & (1ULL <<  2) ?  2 :       \
-               (n) & (1ULL <<  1) ?  1 :       \
-               (n) & (1ULL <<  0) ?  0 :       \
-               -1) :                           \
-       (sizeof(n) <= 4) ?                      \
-       fls((u32)(n)) - 1 : flsll((u64)(n)) - 1 \
-)
-
-#define        order_base_2(x) ilog2(roundup_pow_of_two(x))
-
-#endif /* _LINUX_LOG2_H_ */
diff --git a/sys/ofed/include/linux/math64.h b/sys/ofed/include/linux/math64.h
deleted file mode 100644 (file)
index 2a488f1..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * Copyright (c) 2007 Cisco Systems, Inc.  All rights reserved.
- * Copyright (c) 2014-2015 Mellanox Technologies, Ltd. All rights reserved.
- * 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_MATH64_H
-#define        _LINUX_MATH64_H
-
-#include <sys/stdint.h>
-
-#define        do_div(n, base) ({                      \
-       uint32_t __base = (base);               \
-       uint32_t __rem;                         \
-       __rem = ((uint64_t)(n)) % __base;       \
-       (n) = ((uint64_t)(n)) / __base;         \
-       __rem;                                  \
-})
-
-static inline uint64_t
-div_u64_rem(uint64_t dividend, uint32_t divisor, uint32_t *remainder)
-{
-       *remainder = dividend % divisor;
-       return (dividend / divisor);
-}
-
-static inline uint64_t
-div_u64(uint64_t dividend, uint32_t divisor)
-{
-       return (dividend / divisor);
-}
-
-#endif                                 /* _LINUX_MATH64_H */
diff --git a/sys/ofed/include/linux/miscdevice.h b/sys/ofed/include/linux/miscdevice.h
deleted file mode 100644 (file)
index 96d8fe7..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*-
- * 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        _LINUX_MISCDEVICE_H_
-#define        _LINUX_MISCDEVICE_H_
-
-#define        MISC_DYNAMIC_MINOR      -1
-
-#include <linux/device.h>
-#include <linux/cdev.h>
-
-struct miscdevice  {
-       const char      *name;
-       struct device   *this_device;
-       const struct file_operations *fops;
-       struct cdev     *cdev;
-       int             minor;
-       const char *nodename;
-       umode_t mode;
-};
-
-extern struct class    miscclass;
-
-static inline int
-misc_register(struct miscdevice *misc)
-{
-       misc->this_device = device_create(&miscclass, &linux_rootdev, 0, misc, 
-           misc->name);
-       misc->cdev = cdev_alloc();
-       if (misc->cdev == NULL)
-               return -ENOMEM;
-       misc->cdev->owner = THIS_MODULE;
-       misc->cdev->ops = misc->fops;
-       kobject_set_name(&misc->cdev->kobj, misc->name);
-        if (cdev_add(misc->cdev, misc->this_device->devt, 1))
-               return -EINVAL;
-       return (0);
-}
-
-static inline int
-misc_deregister(struct miscdevice *misc)
-{
-       device_destroy(&miscclass, misc->this_device->devt);
-       cdev_del(misc->cdev);
-
-       return (0);
-}
-
-#endif /* _LINUX_MISCDEVICE_H_ */
diff --git a/sys/ofed/include/linux/mm.h b/sys/ofed/include/linux/mm.h
deleted file mode 100644 (file)
index 3835e34..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
- * Copyright (c) 2015 François Tigeot
- * Copyright (c) 2015 Matthew Dillon <dillon@backplane.com>
- * 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_MM_H_
-#define        _LINUX_MM_H_
-
-#include <linux/spinlock.h>
-#include <linux/gfp.h>
-#include <linux/kernel.h>
-
-#define        PAGE_ALIGN(x)   ALIGN(x, PAGE_SIZE)
-
-struct vm_area_struct {
-       vm_offset_t     vm_start;
-       vm_offset_t     vm_end;
-       vm_offset_t     vm_pgoff;
-       vm_paddr_t      vm_pfn;         /* PFN For mmap. */
-       vm_size_t       vm_len;         /* length for mmap. */
-       vm_memattr_t    vm_page_prot;
-};
-
-/*
- * Compute log2 of the power of two rounded up count of pages
- * needed for size bytes.
- */
-static inline int
-get_order(unsigned long size)
-{
-       int order;
-
-       size = (size - 1) >> PAGE_SHIFT;
-       order = 0;
-       while (size) {
-               order++;
-               size >>= 1;
-       }
-       return (order);
-}
-
-static inline void *
-lowmem_page_address(struct page *page)
-{
-
-       return page_address(page);
-}
-
-/*
- * This only works via mmap ops.
- */
-static inline int
-io_remap_pfn_range(struct vm_area_struct *vma,
-    unsigned long addr, unsigned long pfn, unsigned long size,
-    vm_memattr_t prot)
-{
-       vma->vm_page_prot = prot;
-       vma->vm_pfn = pfn;
-       vma->vm_len = size;
-
-       return (0);
-}
-
-static inline unsigned long
-vma_pages(struct vm_area_struct *vma)
-{
-       return ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT);
-}
-
-#define        offset_in_page(off)     ((off) & (PAGE_SIZE - 1))
-
-static inline void
-set_page_dirty(struct vm_page *page)
-{
-       vm_page_dirty(page);
-}
-
-static inline void
-get_page(struct vm_page *page)
-{
-       vm_page_hold(page);
-}
-
-#endif /* _LINUX_MM_H_ */
diff --git a/sys/ofed/include/linux/module.h b/sys/ofed/include/linux/module.h
deleted file mode 100644 (file)
index 0caa2b0..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*-
- * 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        _LINUX_MODULE_H_
-#define        _LINUX_MODULE_H_
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/module.h>
-
-#include <linux/list.h>
-#include <linux/compiler.h>
-#include <linux/kobject.h>
-#include <linux/moduleparam.h>
-#include <linux/slab.h>
-
-#define MODULE_AUTHOR(name)
-#define MODULE_DESCRIPTION(name)
-#define MODULE_LICENSE(name)
-
-#define        THIS_MODULE     ((struct module *)0)
-
-#define        EXPORT_SYMBOL(name)
-#define        EXPORT_SYMBOL_GPL(name)
-
-/* OFED pre-module initialization */
-#define        SI_SUB_OFED_PREINIT     (SI_SUB_ROOT_CONF - 2)
-/* OFED default module initialization */
-#define        SI_SUB_OFED_MODINIT     (SI_SUB_ROOT_CONF - 1)
-
-#include <sys/linker.h>
-
-static inline void
-_module_run(void *arg)
-{
-       void (*fn)(void);
-#ifdef OFED_DEBUG_INIT
-       char name[1024];
-       caddr_t pc;
-       long offset;
-
-       pc = (caddr_t)arg;
-       if (linker_search_symbol_name(pc, name, sizeof(name), &offset) != 0)
-               printf("Running ??? (%p)\n", pc);
-       else
-               printf("Running %s (%p)\n", name, pc);
-#endif
-       fn = arg;
-       DROP_GIANT();
-       fn();
-       PICKUP_GIANT();
-}
-
-#define        module_init(fn)                                                 \
-       SYSINIT(fn, SI_SUB_OFED_MODINIT, SI_ORDER_FIRST, _module_run, (fn))
-
-#define        module_exit(fn)                                         \
-       SYSUNINIT(fn, SI_SUB_OFED_MODINIT, SI_ORDER_SECOND, _module_run, (fn))
-
-/*
- * The following two macros are a workaround for not having a module
- * load and unload order resolver:
- */
-#define        module_init_order(fn, order)                                    \
-       SYSINIT(fn, SI_SUB_OFED_MODINIT, (order), _module_run, (fn))
-
-#define        module_exit_order(fn, order)                            \
-       SYSUNINIT(fn, SI_SUB_OFED_MODINIT, (order), _module_run, (fn))
-
-#define        module_get(module)
-#define        module_put(module)
-#define        try_module_get(module)  1
-
-#endif /* _LINUX_MODULE_H_ */
diff --git a/sys/ofed/include/linux/moduleparam.h b/sys/ofed/include/linux/moduleparam.h
deleted file mode 100644 (file)
index 9699b33..0000000
+++ /dev/null
@@ -1,234 +0,0 @@
-/*-
- * 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        _LINUX_MODULEPARAM_H_
-#define        _LINUX_MODULEPARAM_H_
-
-#include <linux/types.h>
-
-/*
- * These are presently not hooked up to anything.  In linux the parameters
- * can be set when modules are loaded.  On FreeBSD these could be mapped
- * to kenv in the future.
- */
-struct kernel_param;
-
-typedef int (*param_set_fn)(const char *val, struct kernel_param *kp);
-typedef int (*param_get_fn)(char *buffer, struct kernel_param *kp);
-
-struct kernel_param {
-       const char      *name;
-       u16             perm;
-       u16             flags;
-       param_set_fn    set;
-       param_get_fn    get;
-       union {
-               void    *arg;
-               struct kparam_string    *str;
-               struct kparam_array     *arr;
-       } un;
-};
-
-#define        KPARAM_ISBOOL   2
-
-struct kparam_string {
-       unsigned int maxlen;
-       char *string;
-};
-
-struct kparam_array
-{
-       unsigned int    max;
-       unsigned int    *num;
-       param_set_fn    set;
-       param_get_fn    get;
-       unsigned int    elemsize;
-       void            *elem;
-};
-
-static inline void
-param_sysinit(struct kernel_param *param)
-{
-}
-
-#define        module_param_call(name, set, get, arg, perm)                    \
-       static struct kernel_param __param_##name =                     \
-           { #name, perm, 0, set, get, { arg } };                      \
-       SYSINIT(name##_param_sysinit, SI_SUB_DRIVERS, SI_ORDER_FIRST,   \
-           param_sysinit, &__param_##name);
-
-#define        module_param_string(name, string, len, perm)
-
-#define        module_param_named(name, var, type, mode)                       \
-       module_param_call(name, param_set_##type, param_get_##type, &var, mode)
-
-#define        module_param(var, type, mode)                                   \
-       module_param_named(var, var, type, mode)
-
-#define module_param_array(var, type, addr_argc, mode)                  \
-        module_param_named(var, var, type, mode)
-
-#define        MODULE_PARM_DESC(name, desc)
-
-static inline int
-param_set_byte(const char *val, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-static inline int
-param_get_byte(char *buffer, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-
-static inline int
-param_set_short(const char *val, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-static inline int
-param_get_short(char *buffer, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-
-static inline int
-param_set_ushort(const char *val, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-static inline int
-param_get_ushort(char *buffer, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-
-static inline int
-param_set_int(const char *val, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-static inline int
-param_get_int(char *buffer, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-
-static inline int
-param_set_uint(const char *val, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-static inline int
-param_get_uint(char *buffer, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-
-static inline int
-param_set_long(const char *val, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-static inline int
-param_get_long(char *buffer, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-
-static inline int
-param_set_ulong(const char *val, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-static inline int
-param_get_ulong(char *buffer, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-
-static inline int
-param_set_charp(const char *val, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-static inline int
-param_get_charp(char *buffer, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-
-static inline int
-param_set_bool(const char *val, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-static inline int
-param_get_bool(char *buffer, struct kernel_param *kp)
-{
-
-       return 0;
-}
-
-#endif /* _LINUX_MODULEPARAM_H_ */
diff --git a/sys/ofed/include/linux/mutex.h b/sys/ofed/include/linux/mutex.h
deleted file mode 100644 (file)
index aee34cf..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * 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        _LINUX_MUTEX_H_
-#define        _LINUX_MUTEX_H_
-
-#include <sys/param.h>
-#include <sys/lock.h>
-#include <sys/sx.h>
-
-#include <linux/spinlock.h>
-
-typedef struct mutex {
-       struct sx sx;
-} mutex_t;
-
-#define        mutex_lock(_m)                  sx_xlock(&(_m)->sx)
-#define        mutex_lock_nested(_m, _s)       mutex_lock(_m)
-#define        mutex_lock_interruptible(_m)    ({ mutex_lock((_m)); 0; })
-#define        mutex_unlock(_m)                sx_xunlock(&(_m)->sx)
-#define        mutex_trylock(_m)               !!sx_try_xlock(&(_m)->sx)
-
-#define DEFINE_MUTEX(lock)                                             \
-       mutex_t lock;                                                   \
-       SX_SYSINIT_FLAGS(lock, &(lock).sx, "lnxmtx", SX_NOWITNESS)
-
-static inline void
-linux_mutex_init(mutex_t *m)
-{
-
-       memset(&m->sx, 0, sizeof(m->sx));
-       sx_init_flags(&m->sx, "lnxmtx",  SX_NOWITNESS);
-}
-
-#define        mutex_init      linux_mutex_init
-
-#endif /* _LINUX_MUTEX_H_ */
diff --git a/sys/ofed/include/linux/net.h b/sys/ofed/include/linux/net.h
deleted file mode 100644 (file)
index 166b750..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * 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        _LINUX_NET_H_
-#define        _LINUX_NET_H_
-
-#include <sys/protosw.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-
-static inline int
-sock_create_kern(int family, int type, int proto, struct socket **res)
-{
-       return -socreate(family, res, type, proto, curthread->td_ucred,
-           curthread);
-}
-
-static inline int
-sock_getname(struct socket *so, struct sockaddr *addr, int *sockaddr_len,
-    int peer)
-{
-       struct sockaddr *nam;
-       int error;
-
-       nam = NULL;
-       if (peer) {
-               if ((so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0)
-                       return (-ENOTCONN);
-
-               error = (*so->so_proto->pr_usrreqs->pru_peeraddr)(so, &nam);
-       } else
-               error = (*so->so_proto->pr_usrreqs->pru_sockaddr)(so, &nam);
-       if (error)
-               return (-error);
-       *addr = *nam;
-       *sockaddr_len = addr->sa_len;
-
-       free(nam, M_SONAME);
-       return (0);
-}
-
-static inline void
-sock_release(struct socket *so)
-{
-       soclose(so);
-}
-
-#endif /* _LINUX_NET_H_ */
diff --git a/sys/ofed/include/linux/netdevice.h b/sys/ofed/include/linux/netdevice.h
deleted file mode 100644 (file)
index 1b1f8bf..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-/*-
- * 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        _LINUX_NETDEVICE_H_
-#define        _LINUX_NETDEVICE_H_
-
-#include <linux/types.h>
-
-#include <sys/socket.h>
-
-#include <net/if_types.h>
-#include <net/if.h>
-#include <net/if_var.h>
-#include <net/if_dl.h>
-
-#include <linux/completion.h>
-#include <linux/device.h>
-#include <linux/workqueue.h>
-#include <linux/net.h>
-#include <linux/notifier.h>
-
-struct net {
-};
-
-extern struct net init_net;
-
-#define        MAX_ADDR_LEN            20
-
-#define        net_device      ifnet
-
-#define        dev_get_by_index(n, idx)        ifnet_byindex_ref((idx))
-#define        dev_hold(d)     if_ref((d))
-#define        dev_put(d)      if_rele((d))
-
-#define        netif_running(dev)      !!((dev)->if_drv_flags & IFF_DRV_RUNNING)
-#define        netif_oper_up(dev)      !!((dev)->if_flags & IFF_UP)
-#define        netif_carrier_ok(dev)   netif_running(dev)
-
-static inline void *
-netdev_priv(const struct net_device *dev)
-{
-       return (dev->if_softc);
-}
-
-static inline void
-_handle_ifnet_link_event(void *arg, struct ifnet *ifp, int linkstate)
-{
-       struct notifier_block *nb;
-
-       nb = arg;
-       if (linkstate == LINK_STATE_UP)
-               nb->notifier_call(nb, NETDEV_UP, ifp);
-       else
-               nb->notifier_call(nb, NETDEV_DOWN, ifp);
-}
-
-static inline void
-_handle_ifnet_arrival_event(void *arg, struct ifnet *ifp)
-{
-       struct notifier_block *nb;
-
-       nb = arg;
-       nb->notifier_call(nb, NETDEV_REGISTER, ifp);
-}
-
-static inline void
-_handle_ifnet_departure_event(void *arg, struct ifnet *ifp)
-{
-       struct notifier_block *nb;
-
-       nb = arg;
-       nb->notifier_call(nb, NETDEV_UNREGISTER, ifp);
-}
-
-static inline void
-_handle_iflladdr_event(void *arg, struct ifnet *ifp)
-{
-       struct notifier_block *nb;
-
-       nb = arg;
-       nb->notifier_call(nb, NETDEV_CHANGEADDR, ifp);
-}
-
-static inline void
-_handle_ifaddr_event(void *arg, struct ifnet *ifp)
-{
-       struct notifier_block *nb;
-
-       nb = arg;
-       nb->notifier_call(nb, NETDEV_CHANGEIFADDR, ifp);
-}
-
-static inline int
-register_netdevice_notifier(struct notifier_block *nb)
-{
-
-       nb->tags[NETDEV_UP] = EVENTHANDLER_REGISTER(
-           ifnet_link_event, _handle_ifnet_link_event, nb, 0);
-       nb->tags[NETDEV_REGISTER] = EVENTHANDLER_REGISTER(
-           ifnet_arrival_event, _handle_ifnet_arrival_event, nb, 0);
-       nb->tags[NETDEV_UNREGISTER] = EVENTHANDLER_REGISTER(
-           ifnet_departure_event, _handle_ifnet_departure_event, nb, 0);
-       nb->tags[NETDEV_CHANGEADDR] = EVENTHANDLER_REGISTER(
-           iflladdr_event, _handle_iflladdr_event, nb, 0);
-
-       return (0);
-}
-
-static inline int
-register_inetaddr_notifier(struct notifier_block *nb)
-{
-
-        nb->tags[NETDEV_CHANGEIFADDR] = EVENTHANDLER_REGISTER(
-            ifaddr_event, _handle_ifaddr_event, nb, 0);
-        return (0);
-}
-
-static inline int
-unregister_netdevice_notifier(struct notifier_block *nb)
-{
-
-        EVENTHANDLER_DEREGISTER(ifnet_link_event, nb->tags[NETDEV_UP]);
-        EVENTHANDLER_DEREGISTER(ifnet_arrival_event, nb->tags[NETDEV_REGISTER]);
-        EVENTHANDLER_DEREGISTER(ifnet_departure_event,
-           nb->tags[NETDEV_UNREGISTER]);
-        EVENTHANDLER_DEREGISTER(iflladdr_event,
-            nb->tags[NETDEV_CHANGEADDR]);
-
-       return (0);
-}
-
-static inline int
-unregister_inetaddr_notifier(struct notifier_block *nb)
-{
-
-        EVENTHANDLER_DEREGISTER(ifaddr_event,
-            nb->tags[NETDEV_CHANGEIFADDR]);
-
-        return (0);
-}
-
-
-#define        rtnl_lock()
-#define        rtnl_unlock()
-
-static inline int
-dev_mc_delete(struct net_device *dev, void *addr, int alen, int all)
-{
-       struct sockaddr_dl sdl;
-
-       if (alen > sizeof(sdl.sdl_data))
-               return (-EINVAL);
-       memset(&sdl, 0, sizeof(sdl));
-       sdl.sdl_len = sizeof(sdl);
-       sdl.sdl_family = AF_LINK;
-       sdl.sdl_alen = alen;
-       memcpy(&sdl.sdl_data, addr, alen);
-
-       return -if_delmulti(dev, (struct sockaddr *)&sdl);
-}
-
-static inline int
-dev_mc_add(struct net_device *dev, void *addr, int alen, int newonly)
-{
-       struct sockaddr_dl sdl;
-
-       if (alen > sizeof(sdl.sdl_data))
-               return (-EINVAL);
-       memset(&sdl, 0, sizeof(sdl));
-       sdl.sdl_len = sizeof(sdl);
-       sdl.sdl_family = AF_LINK;
-       sdl.sdl_alen = alen;
-       memcpy(&sdl.sdl_data, addr, alen);
-
-       return -if_addmulti(dev, (struct sockaddr *)&sdl, NULL);
-}
-
-#endif /* _LINUX_NETDEVICE_H_ */
diff --git a/sys/ofed/include/linux/notifier.h b/sys/ofed/include/linux/notifier.h
deleted file mode 100644 (file)
index ca750e0..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * 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        _LINUX_NOTIFIER_H_
-#define        _LINUX_NOTIFIER_H_
-
-#include <sys/eventhandler.h>
-
-/*
- * Max number of FreeBSD events to map to Linux events per notify type.
- */
-#define        NOTIFY_DONE     0
-#define        _NOTIFY_COUNT   7
-
-struct notifier_block {
-       int (*notifier_call)(struct notifier_block *, unsigned long, void *);
-       struct notifier_block   *next;
-       int                     priority;
-       eventhandler_tag        tags[_NOTIFY_COUNT];
-};
-
-/* Values must be less than NOTIFY_COUNT */
-#define        NETDEV_UP               0x0001
-#define        NETDEV_DOWN             0x0002
-#define        NETDEV_REGISTER         0x0003
-#define        NETDEV_UNREGISTER       0x0004
-#define        NETDEV_CHANGEADDR       0x0005
-#define        NETDEV_CHANGEIFADDR     0x0006
-
-
-#endif /* _LINUX_NOTIFIER_H_ */
diff --git a/sys/ofed/include/linux/page.h b/sys/ofed/include/linux/page.h
deleted file mode 100644 (file)
index acc9f03..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * 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        _LINUX_PAGE_H_
-#define _LINUX_PAGE_H_
-
-#include <linux/types.h>
-
-#include <sys/param.h>
-
-#include <machine/atomic.h>
-#include <vm/vm.h>
-#include <vm/vm_page.h>
-
-#define page   vm_page
-
-#define        virt_to_page(x) PHYS_TO_VM_PAGE(vtophys((x)))
-
-#define        clear_page(page)                memset((page), 0, PAGE_SIZE)
-#define        pgprot_noncached(prot)          VM_MEMATTR_UNCACHEABLE
-#define        pgprot_writecombine(prot)       VM_MEMATTR_WRITE_COMBINING
-
-#undef PAGE_MASK
-#define        PAGE_MASK       (~(PAGE_SIZE-1))
-
-#endif /* _LINUX_PAGE_H_ */
diff --git a/sys/ofed/include/linux/pci.h b/sys/ofed/include/linux/pci.h
deleted file mode 100644 (file)
index 54ea99c..0000000
+++ /dev/null
@@ -1,735 +0,0 @@
-/*-
- * 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        _LINUX_PCI_H_
-#define        _LINUX_PCI_H_
-
-#define        CONFIG_PCI_MSI
-
-#include <linux/types.h>
-
-#include <sys/param.h>
-#include <sys/bus.h>
-#include <sys/pciio.h>
-#include <sys/rman.h>
-#include <dev/pci/pcivar.h>
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pci_private.h>
-
-#include <machine/resource.h>
-
-#include <linux/list.h>
-#include <linux/dmapool.h>
-#include <linux/dma-mapping.h>
-#include <linux/compiler.h>
-#include <linux/errno.h>
-#include <asm/atomic.h>
-#include <linux/device.h>
-
-struct pci_device_id {
-       uint32_t        vendor;
-       uint32_t        device;
-        uint32_t       subvendor;
-       uint32_t        subdevice;
-       uint32_t        class_mask;
-       uintptr_t       driver_data;
-};
-
-#define        MODULE_DEVICE_TABLE(bus, table)
-#define        PCI_ANY_ID              (-1)
-#define        PCI_VENDOR_ID_MELLANOX                  0x15b3
-#define        PCI_VENDOR_ID_TOPSPIN                   0x1867
-#define        PCI_DEVICE_ID_MELLANOX_TAVOR            0x5a44
-#define        PCI_DEVICE_ID_MELLANOX_TAVOR_BRIDGE     0x5a46
-#define        PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT     0x6278
-#define        PCI_DEVICE_ID_MELLANOX_ARBEL            0x6282
-#define        PCI_DEVICE_ID_MELLANOX_SINAI_OLD        0x5e8c
-#define        PCI_DEVICE_ID_MELLANOX_SINAI            0x6274
-
-#define PCI_DEVFN(slot, func)   ((((slot) & 0x1f) << 3) | ((func) & 0x07))
-#define PCI_SLOT(devfn)         (((devfn) >> 3) & 0x1f)
-#define PCI_FUNC(devfn)         ((devfn) & 0x07)
-
-#define PCI_VDEVICE(_vendor, _device)                                  \
-           .vendor = PCI_VENDOR_ID_##_vendor, .device = (_device),     \
-           .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
-#define        PCI_DEVICE(_vendor, _device)                                    \
-           .vendor = (_vendor), .device = (_device),                   \
-           .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
-
-#define        to_pci_dev(n)   container_of(n, struct pci_dev, dev)
-
-#define        PCI_VENDOR_ID           PCIR_DEVVENDOR
-#define        PCI_COMMAND             PCIR_COMMAND
-#define        PCI_EXP_DEVCTL          PCIER_DEVICE_CTL                /* Device Control */
-#define        PCI_EXP_LNKCTL          PCIER_LINK_CTL                  /* Link Control */
-#define        PCI_EXP_FLAGS_TYPE      PCIEM_FLAGS_TYPE                /* Device/Port type */
-#define        PCI_EXP_DEVCAP          PCIER_DEVICE_CAP                /* Device capabilities */
-#define        PCI_EXP_DEVSTA          PCIER_DEVICE_STA                /* Device Status */
-#define        PCI_EXP_LNKCAP          PCIER_LINK_CAP                  /* Link Capabilities */
-#define        PCI_EXP_LNKSTA          PCIER_LINK_STA                  /* Link Status */
-#define        PCI_EXP_SLTCAP          PCIER_SLOT_CAP                  /* Slot Capabilities */
-#define        PCI_EXP_SLTCTL          PCIER_SLOT_CTL                  /* Slot Control */
-#define        PCI_EXP_SLTSTA          PCIER_SLOT_STA                  /* Slot Status */
-#define        PCI_EXP_RTCTL           PCIER_ROOT_CTL                  /* Root Control */
-#define        PCI_EXP_RTCAP           PCIER_ROOT_CAP                  /* Root Capabilities */
-#define        PCI_EXP_RTSTA           PCIER_ROOT_STA                  /* Root Status */
-#define        PCI_EXP_DEVCAP2         PCIER_DEVICE_CAP2               /* Device Capabilities 2 */
-#define        PCI_EXP_DEVCTL2         PCIER_DEVICE_CTL2               /* Device Control 2 */
-#define        PCI_EXP_LNKCAP2         PCIER_LINK_CAP2                 /* Link Capabilities 2 */
-#define        PCI_EXP_LNKCTL2         PCIER_LINK_CTL2                 /* Link Control 2 */
-#define        PCI_EXP_LNKSTA2         PCIER_LINK_STA2                 /* Link Status 2 */
-#define        PCI_EXP_FLAGS           PCIER_FLAGS                     /* Capabilities register */
-#define        PCI_EXP_FLAGS_VERS      PCIEM_FLAGS_VERSION             /* Capability version */
-#define        PCI_EXP_TYPE_ROOT_PORT  PCIEM_TYPE_ROOT_PORT            /* Root Port */
-#define        PCI_EXP_TYPE_ENDPOINT   PCIEM_TYPE_ENDPOINT             /* Express Endpoint */
-#define        PCI_EXP_TYPE_LEG_END    PCIEM_TYPE_LEGACY_ENDPOINT      /* Legacy Endpoint */
-#define        PCI_EXP_TYPE_DOWNSTREAM PCIEM_TYPE_DOWNSTREAM_PORT      /* Downstream Port */
-#define        PCI_EXP_FLAGS_SLOT      PCIEM_FLAGS_SLOT                /* Slot implemented */
-#define        PCI_EXP_TYPE_RC_EC      PCIEM_TYPE_ROOT_EC              /* Root Complex Event Collector */
-
-
-#define        IORESOURCE_MEM  SYS_RES_MEMORY
-#define        IORESOURCE_IO   SYS_RES_IOPORT
-#define        IORESOURCE_IRQ  SYS_RES_IRQ
-
-struct pci_dev;
-
-
-struct pci_driver {
-       struct list_head                links;
-       char                            *name;
-       const struct pci_device_id              *id_table;
-       int  (*probe)(struct pci_dev *dev, const struct pci_device_id *id);
-       void (*remove)(struct pci_dev *dev);
-        int  (*suspend) (struct pci_dev *dev, pm_message_t state);      /* Device suspended */
-        int  (*resume) (struct pci_dev *dev);                   /* Device woken up */
-       driver_t                        driver;
-       devclass_t                      bsdclass;
-        const struct pci_error_handlers       *err_handler;
-};
-
-extern struct list_head pci_drivers;
-extern struct list_head pci_devices;
-extern spinlock_t pci_lock;
-
-#define        __devexit_p(x)  x
-
-struct pci_dev {
-       struct device           dev;
-       struct list_head        links;
-       struct pci_driver       *pdrv;
-       uint64_t                dma_mask;
-       uint16_t                device;
-       uint16_t                vendor;
-       unsigned int            irq;
-       unsigned int            devfn;
-       u8                      revision;
-};
-
-static inline struct resource_list_entry *
-_pci_get_rle(struct pci_dev *pdev, int type, int rid)
-{
-       struct pci_devinfo *dinfo;
-       struct resource_list *rl;
-
-       dinfo = device_get_ivars(pdev->dev.bsddev);
-       rl = &dinfo->resources;
-       return resource_list_find(rl, type, rid);
-}
-
-static inline struct resource_list_entry *
-_pci_get_bar(struct pci_dev *pdev, int bar)
-{
-       struct resource_list_entry *rle;
-
-       bar = PCIR_BAR(bar);
-       if ((rle = _pci_get_rle(pdev, SYS_RES_MEMORY, bar)) == NULL)
-               rle = _pci_get_rle(pdev, SYS_RES_IOPORT, bar);
-       return (rle);
-}
-
-static inline struct device *
-_pci_find_irq_dev(unsigned int irq)
-{
-       struct pci_dev *pdev;
-
-       spin_lock(&pci_lock);
-       list_for_each_entry(pdev, &pci_devices, links) {
-               if (irq == pdev->dev.irq)
-                       break;
-               if (irq >= pdev->dev.msix && irq < pdev->dev.msix_max)
-                       break;
-       }
-       spin_unlock(&pci_lock);
-       if (pdev)
-               return &pdev->dev;
-       return (NULL);
-}
-
-static inline unsigned long
-pci_resource_start(struct pci_dev *pdev, int bar)
-{
-       struct resource_list_entry *rle;
-
-       if ((rle = _pci_get_bar(pdev, bar)) == NULL)
-               return (0);
-       return rle->start;
-}
-
-static inline unsigned long
-pci_resource_len(struct pci_dev *pdev, int bar)
-{
-       struct resource_list_entry *rle;
-
-       if ((rle = _pci_get_bar(pdev, bar)) == NULL)
-               return (0);
-       return rle->count;
-}
-
-/*
- * All drivers just seem to want to inspect the type not flags.
- */
-static inline int
-pci_resource_flags(struct pci_dev *pdev, int bar)
-{
-       struct resource_list_entry *rle;
-
-       if ((rle = _pci_get_bar(pdev, bar)) == NULL)
-               return (0);
-       return rle->type;
-}
-
-static inline const char *
-pci_name(struct pci_dev *d)
-{
-
-       return device_get_desc(d->dev.bsddev);
-}
-
-static inline void *
-pci_get_drvdata(struct pci_dev *pdev)
-{
-
-       return dev_get_drvdata(&pdev->dev);
-}
-
-static inline void
-pci_set_drvdata(struct pci_dev *pdev, void *data)
-{
-
-       dev_set_drvdata(&pdev->dev, data);
-}
-
-static inline int
-pci_enable_device(struct pci_dev *pdev)
-{
-
-       pci_enable_io(pdev->dev.bsddev, SYS_RES_IOPORT);
-       pci_enable_io(pdev->dev.bsddev, SYS_RES_MEMORY);
-       return (0);
-}
-
-static inline void
-pci_disable_device(struct pci_dev *pdev)
-{
-}
-
-static inline int
-pci_set_master(struct pci_dev *pdev)
-{
-
-       pci_enable_busmaster(pdev->dev.bsddev);
-       return (0);
-}
-
-static inline int
-pci_clear_master(struct pci_dev *pdev)
-{
-
-       pci_disable_busmaster(pdev->dev.bsddev);
-       return (0);
-}
-
-static inline int
-pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
-{
-       int rid;
-       int type;
-
-       type = pci_resource_flags(pdev, bar);
-       if (type == 0)
-               return (-ENODEV);
-       rid = PCIR_BAR(bar);
-       if (bus_alloc_resource_any(pdev->dev.bsddev, type, &rid,
-           RF_ACTIVE) == NULL)
-               return (-EINVAL);
-       return (0);
-}
-
-static inline void
-pci_release_region(struct pci_dev *pdev, int bar)
-{
-       struct resource_list_entry *rle;
-
-       if ((rle = _pci_get_bar(pdev, bar)) == NULL)
-               return;
-       bus_release_resource(pdev->dev.bsddev, rle->type, rle->rid, rle->res);
-}
-
-static inline void
-pci_release_regions(struct pci_dev *pdev)
-{
-       int i;
-
-       for (i = 0; i <= PCIR_MAX_BAR_0; i++)
-               pci_release_region(pdev, i);
-}
-
-static inline int
-pci_request_regions(struct pci_dev *pdev, const char *res_name)
-{
-       int error;
-       int i;
-
-       for (i = 0; i <= PCIR_MAX_BAR_0; i++) {
-               error = pci_request_region(pdev, i, res_name);
-               if (error && error != -ENODEV) {
-                       pci_release_regions(pdev);
-                       return (error);
-               }
-       }
-       return (0);
-}
-
-static inline void
-pci_disable_msix(struct pci_dev *pdev)
-{
-
-       pci_release_msi(pdev->dev.bsddev);
-}
-
-#define        PCI_CAP_ID_EXP  PCIY_EXPRESS
-#define        PCI_CAP_ID_PCIX PCIY_PCIX
-
-
-static inline int
-pci_find_capability(struct pci_dev *pdev, int capid)
-{
-       int reg;
-
-       if (pci_find_cap(pdev->dev.bsddev, capid, &reg))
-               return (0);
-       return (reg);
-}
-
-
-
-
-/**
- * pci_pcie_cap - get the saved PCIe capability offset
- * @dev: PCI device
- *
- * PCIe capability offset is calculated at PCI device initialization
- * time and saved in the data structure. This function returns saved
- * PCIe capability offset. Using this instead of pci_find_capability()
- * reduces unnecessary search in the PCI configuration space. If you
- * need to calculate PCIe capability offset from raw device for some
- * reasons, please use pci_find_capability() instead.
- */
-static inline int pci_pcie_cap(struct pci_dev *dev)
-{
-        return pci_find_capability(dev, PCI_CAP_ID_EXP);
-}
-
-
-static inline int
-pci_read_config_byte(struct pci_dev *pdev, int where, u8 *val)
-{
-
-       *val = (u8)pci_read_config(pdev->dev.bsddev, where, 1);
-       return (0);
-}
-
-static inline int
-pci_read_config_word(struct pci_dev *pdev, int where, u16 *val)
-{
-
-       *val = (u16)pci_read_config(pdev->dev.bsddev, where, 2);
-       return (0);
-}
-
-static inline int
-pci_read_config_dword(struct pci_dev *pdev, int where, u32 *val)
-{
-
-       *val = (u32)pci_read_config(pdev->dev.bsddev, where, 4);
-       return (0);
-} 
-
-static inline int
-pci_write_config_byte(struct pci_dev *pdev, int where, u8 val)
-{
-
-       pci_write_config(pdev->dev.bsddev, where, val, 1);
-       return (0);
-}
-
-static inline int
-pci_write_config_word(struct pci_dev *pdev, int where, u16 val)
-{
-
-       pci_write_config(pdev->dev.bsddev, where, val, 2);
-       return (0);
-}
-
-static inline int
-pci_write_config_dword(struct pci_dev *pdev, int where, u32 val)
-{ 
-
-       pci_write_config(pdev->dev.bsddev, where, val, 4);
-       return (0);
-}
-
-extern int pci_register_driver(struct pci_driver *pdrv);
-extern void pci_unregister_driver(struct pci_driver *pdrv);
-
-struct msix_entry {
-       int entry;
-       int vector;
-};
-
-/*
- * Enable msix, positive errors indicate actual number of available
- * vectors.  Negative errors are failures.
- *
- * NB: define added to prevent this definition of pci_enable_msix from
- * clashing with the native FreeBSD version.
- */
-#define        pci_enable_msix         linux_pci_enable_msix
-static inline int
-pci_enable_msix(struct pci_dev *pdev, struct msix_entry *entries, int nreq)
-{
-       struct resource_list_entry *rle;
-       int error;
-       int avail;
-       int i;
-
-       avail = pci_msix_count(pdev->dev.bsddev);
-       if (avail < nreq) {
-               if (avail == 0)
-                       return -EINVAL;
-               return avail;
-       }
-       avail = nreq;
-       if ((error = -pci_alloc_msix(pdev->dev.bsddev, &avail)) != 0)
-               return error;
-       /*
-        * Handle case where "pci_alloc_msix()" may allocate less
-        * interrupts than available and return with no error:
-        */
-       if (avail < nreq) {
-               pci_release_msi(pdev->dev.bsddev);
-               return avail;
-       }
-       rle = _pci_get_rle(pdev, SYS_RES_IRQ, 1);
-       pdev->dev.msix = rle->start;
-       pdev->dev.msix_max = rle->start + avail;
-       for (i = 0; i < nreq; i++)
-               entries[i].vector = pdev->dev.msix + i;
-       return (0);
-}
-
-#define        pci_enable_msix_range   linux_pci_enable_msix_range
-static inline int
-pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries,
-    int minvec, int maxvec)
-{
-       int nvec = maxvec;
-       int rc;
-
-       if (maxvec < minvec)
-               return (-ERANGE);
-
-       do {
-               rc = pci_enable_msix(dev, entries, nvec);
-               if (rc < 0) {
-                       return (rc);
-               } else if (rc > 0) {
-                       if (rc < minvec)
-                               return (-ENOSPC);
-                       nvec = rc;
-               }
-       } while (rc);
-       return (nvec);
-}
-
-static inline int pci_channel_offline(struct pci_dev *pdev)
-{
-        return false;
-}
-
-static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
-{
-        return -ENODEV;
-}
-static inline void pci_disable_sriov(struct pci_dev *dev)
-{
-}
-
-/**
- * DEFINE_PCI_DEVICE_TABLE - macro used to describe a pci device table
- * @_table: device table name
- *
- * This macro is used to create a struct pci_device_id array (a device table)
- * in a generic manner.
- */
-#define DEFINE_PCI_DEVICE_TABLE(_table) \
-       const struct pci_device_id _table[] __devinitdata
-
-
-/* XXX This should not be necessary. */
-#define        pcix_set_mmrbc(d, v)    0
-#define        pcix_get_max_mmrbc(d)   0
-#define        pcie_set_readrq(d, v)   0
-
-#define        PCI_DMA_BIDIRECTIONAL   0
-#define        PCI_DMA_TODEVICE        1
-#define        PCI_DMA_FROMDEVICE      2
-#define        PCI_DMA_NONE            3
-
-#define        pci_pool                dma_pool
-#define pci_pool_destroy       dma_pool_destroy
-#define pci_pool_alloc         dma_pool_alloc
-#define pci_pool_free          dma_pool_free
-#define        pci_pool_create(_name, _pdev, _size, _align, _alloc)            \
-           dma_pool_create(_name, &(_pdev)->dev, _size, _align, _alloc)
-#define        pci_free_consistent(_hwdev, _size, _vaddr, _dma_handle)         \
-           dma_free_coherent((_hwdev) == NULL ? NULL : &(_hwdev)->dev, \
-               _size, _vaddr, _dma_handle)
-#define        pci_map_sg(_hwdev, _sg, _nents, _dir)                           \
-           dma_map_sg((_hwdev) == NULL ? NULL : &(_hwdev->dev),        \
-               _sg, _nents, (enum dma_data_direction)_dir)
-#define        pci_map_single(_hwdev, _ptr, _size, _dir)                       \
-           dma_map_single((_hwdev) == NULL ? NULL : &(_hwdev->dev),    \
-               (_ptr), (_size), (enum dma_data_direction)_dir)
-#define        pci_unmap_single(_hwdev, _addr, _size, _dir)                    \
-           dma_unmap_single((_hwdev) == NULL ? NULL : &(_hwdev)->dev,  \
-               _addr, _size, (enum dma_data_direction)_dir)
-#define        pci_unmap_sg(_hwdev, _sg, _nents, _dir)                         \
-           dma_unmap_sg((_hwdev) == NULL ? NULL : &(_hwdev)->dev,      \
-               _sg, _nents, (enum dma_data_direction)_dir)
-#define        pci_map_page(_hwdev, _page, _offset, _size, _dir)               \
-           dma_map_page((_hwdev) == NULL ? NULL : &(_hwdev)->dev, _page,\
-               _offset, _size, (enum dma_data_direction)_dir)
-#define        pci_unmap_page(_hwdev, _dma_address, _size, _dir)               \
-           dma_unmap_page((_hwdev) == NULL ? NULL : &(_hwdev)->dev,    \
-               _dma_address, _size, (enum dma_data_direction)_dir)
-#define        pci_set_dma_mask(_pdev, mask)   dma_set_mask(&(_pdev)->dev, (mask))
-#define        pci_dma_mapping_error(_pdev, _dma_addr)                         \
-           dma_mapping_error(&(_pdev)->dev, _dma_addr)
-#define        pci_set_consistent_dma_mask(_pdev, _mask)                       \
-           dma_set_coherent_mask(&(_pdev)->dev, (_mask))
-#define        DECLARE_PCI_UNMAP_ADDR(x)       DEFINE_DMA_UNMAP_ADDR(x);
-#define        DECLARE_PCI_UNMAP_LEN(x)        DEFINE_DMA_UNMAP_LEN(x);
-#define        pci_unmap_addr          dma_unmap_addr
-#define        pci_unmap_addr_set      dma_unmap_addr_set
-#define        pci_unmap_len           dma_unmap_len
-#define        pci_unmap_len_set       dma_unmap_len_set
-
-typedef unsigned int __bitwise pci_channel_state_t;
-typedef unsigned int __bitwise pci_ers_result_t;
-
-enum pci_channel_state {
-        /* I/O channel is in normal state */
-        pci_channel_io_normal = (__force pci_channel_state_t) 1,
-
-        /* I/O to channel is blocked */
-        pci_channel_io_frozen = (__force pci_channel_state_t) 2,
-
-        /* PCI card is dead */
-        pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
-};
-
-enum pci_ers_result {
-        /* no result/none/not supported in device driver */
-        PCI_ERS_RESULT_NONE = (__force pci_ers_result_t) 1,
-
-        /* Device driver can recover without slot reset */
-        PCI_ERS_RESULT_CAN_RECOVER = (__force pci_ers_result_t) 2,
-
-        /* Device driver wants slot to be reset. */
-        PCI_ERS_RESULT_NEED_RESET = (__force pci_ers_result_t) 3,
-
-        /* Device has completely failed, is unrecoverable */
-        PCI_ERS_RESULT_DISCONNECT = (__force pci_ers_result_t) 4,
-
-        /* Device driver is fully recovered and operational */
-        PCI_ERS_RESULT_RECOVERED = (__force pci_ers_result_t) 5,
-};
-
-
-/* PCI bus error event callbacks */
-struct pci_error_handlers {
-        /* PCI bus error detected on this device */
-        pci_ers_result_t (*error_detected)(struct pci_dev *dev,
-                        enum pci_channel_state error);
-
-        /* MMIO has been re-enabled, but not DMA */
-        pci_ers_result_t (*mmio_enabled)(struct pci_dev *dev);
-
-        /* PCI Express link has been reset */
-        pci_ers_result_t (*link_reset)(struct pci_dev *dev);
-
-        /* PCI slot has been reset */
-        pci_ers_result_t (*slot_reset)(struct pci_dev *dev);
-
-        /* Device driver may resume normal operations */
-        void (*resume)(struct pci_dev *dev);
-};
-
-/* freeBSD does not support SRIOV - yet */
-static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
-{
-        return dev;
-}
-
-static inline bool pci_is_pcie(struct pci_dev *dev)
-{
-        return !!pci_pcie_cap(dev);
-}
-
-static inline u16 pcie_flags_reg(struct pci_dev *dev)
-{
-        int pos;
-        u16 reg16;
-
-        pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
-        if (!pos)
-                return 0;
-
-        pci_read_config_word(dev, pos + PCI_EXP_FLAGS, &reg16);
-
-        return reg16;
-}
-
-
-static inline int pci_pcie_type(struct pci_dev *dev)
-{
-        return (pcie_flags_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4;
-}
-
-static inline int pcie_cap_version(struct pci_dev *dev)
-{
-        return pcie_flags_reg(dev) & PCI_EXP_FLAGS_VERS;
-}
-
-static inline bool pcie_cap_has_lnkctl(struct pci_dev *dev)
-{
-        int type = pci_pcie_type(dev);
-
-        return pcie_cap_version(dev) > 1 ||
-               type == PCI_EXP_TYPE_ROOT_PORT ||
-               type == PCI_EXP_TYPE_ENDPOINT ||
-               type == PCI_EXP_TYPE_LEG_END;
-}
-
-static inline bool pcie_cap_has_devctl(const struct pci_dev *dev)
-{
-                return true;
-}
-
-static inline bool pcie_cap_has_sltctl(struct pci_dev *dev)
-{
-        int type = pci_pcie_type(dev);
-
-        return pcie_cap_version(dev) > 1 ||
-               type == PCI_EXP_TYPE_ROOT_PORT ||
-               (type == PCI_EXP_TYPE_DOWNSTREAM &&
-                pcie_flags_reg(dev) & PCI_EXP_FLAGS_SLOT);
-}
-
-static inline bool pcie_cap_has_rtctl(struct pci_dev *dev)
-{
-        int type = pci_pcie_type(dev);
-
-        return pcie_cap_version(dev) > 1 ||
-               type == PCI_EXP_TYPE_ROOT_PORT ||
-               type == PCI_EXP_TYPE_RC_EC;
-}
-
-static bool pcie_capability_reg_implemented(struct pci_dev *dev, int pos)
-{
-        if (!pci_is_pcie(dev))
-                return false;
-
-        switch (pos) {
-        case PCI_EXP_FLAGS_TYPE:
-                return true;
-        case PCI_EXP_DEVCAP:
-        case PCI_EXP_DEVCTL:
-        case PCI_EXP_DEVSTA:
-                return pcie_cap_has_devctl(dev);
-        case PCI_EXP_LNKCAP:
-        case PCI_EXP_LNKCTL:
-        case PCI_EXP_LNKSTA:
-                return pcie_cap_has_lnkctl(dev);
-        case PCI_EXP_SLTCAP:
-        case PCI_EXP_SLTCTL:
-        case PCI_EXP_SLTSTA:
-                return pcie_cap_has_sltctl(dev);
-        case PCI_EXP_RTCTL:
-        case PCI_EXP_RTCAP:
-        case PCI_EXP_RTSTA:
-                return pcie_cap_has_rtctl(dev);
-        case PCI_EXP_DEVCAP2:
-        case PCI_EXP_DEVCTL2:
-        case PCI_EXP_LNKCAP2:
-        case PCI_EXP_LNKCTL2:
-        case PCI_EXP_LNKSTA2:
-                return pcie_cap_version(dev) > 1;
-        default:
-                return false;
-        }
-}
-
-static inline int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val)
-{
-        if (pos & 1)
-                return -EINVAL;
-
-        if (!pcie_capability_reg_implemented(dev, pos))
-                return 0;
-
-        return pci_write_config_word(dev, pci_pcie_cap(dev) + pos, val);
-}
-
-#endif /* _LINUX_PCI_H_ */
diff --git a/sys/ofed/include/linux/poll.h b/sys/ofed/include/linux/poll.h
deleted file mode 100644 (file)
index e4f7417..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * 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        _LINUX_POLL_H_
-#define        _LINUX_POLL_H_
-
-#include <sys/poll.h>
-#include <sys/fcntl.h>
-
-typedef struct poll_table_struct {
-} poll_table;
-
-static inline void
-poll_wait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p)
-{
-       selrecord(curthread, &filp->f_selinfo);
-}
-
-#endif /* _LINUX_POLL_H_ */
diff --git a/sys/ofed/include/linux/printk.h b/sys/ofed/include/linux/printk.h
deleted file mode 100644 (file)
index b160594..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * 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 _FBSD_PRINTK_H_
-#define        _FBSD_PRINTK_H_
-
-/* GID printing macros */
-#define        GID_PRINT_FMT                   "%.4x:%.4x:%.4x:%.4x:%.4x:%.4x:%.4x:%.4x"
-#define        GID_PRINT_ARGS(gid_raw)         htons(((u16 *)gid_raw)[0]), htons(((u16 *)gid_raw)[1]),\
-                                       htons(((u16 *)gid_raw)[2]), htons(((u16 *)gid_raw)[3]),\
-                                       htons(((u16 *)gid_raw)[4]), htons(((u16 *)gid_raw)[5]),\
-                                       htons(((u16 *)gid_raw)[6]), htons(((u16 *)gid_raw)[7])
-
-#endif                                 /* _FBSD_PRINTK_H */
diff --git a/sys/ofed/include/linux/radix-tree.h b/sys/ofed/include/linux/radix-tree.h
deleted file mode 100644 (file)
index 838b81c..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * 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        _LINUX_RADIX_TREE_H_
-#define        _LINUX_RADIX_TREE_H_
-
-#define        RADIX_TREE_MAP_SHIFT    6
-#define        RADIX_TREE_MAP_SIZE     (1 << RADIX_TREE_MAP_SHIFT)
-#define        RADIX_TREE_MAP_MASK     (RADIX_TREE_MAP_SIZE - 1)
-#define        RADIX_TREE_MAX_HEIGHT                                           \
-           DIV_ROUND_UP((sizeof(long) * NBBY), RADIX_TREE_MAP_SHIFT)
-
-struct radix_tree_node {
-       void            *slots[RADIX_TREE_MAP_SIZE];
-       int             count;
-};
-
-struct radix_tree_root {
-       struct radix_tree_node  *rnode;
-       gfp_t                   gfp_mask;
-       int                     height;
-};
-
-#define        RADIX_TREE_INIT(mask)                                           \
-           { .rnode = NULL, .gfp_mask = mask, .height = 0 };
-#define        INIT_RADIX_TREE(root, mask)                                     \
-           { (root)->rnode = NULL; (root)->gfp_mask = mask; (root)->height = 0; }
-#define        RADIX_TREE(name, mask)                                          \
-           struct radix_tree_root name = RADIX_TREE_INIT(mask)
-
-void   *radix_tree_lookup(struct radix_tree_root *, unsigned long);
-void   *radix_tree_delete(struct radix_tree_root *, unsigned long);
-int    radix_tree_insert(struct radix_tree_root *, unsigned long, void *);
-
-#endif /* _LINUX_RADIX_TREE_H_ */
diff --git a/sys/ofed/include/linux/random.h b/sys/ofed/include/linux/random.h
deleted file mode 100644 (file)
index caae7b3..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * 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        _LINUX_RANDOM_H_
-#define        _LINUX_RANDOM_H_
-
-#include <sys/random.h>
-
-static inline void
-get_random_bytes(void *buf, int nbytes)
-{
-       read_random(buf, nbytes);
-}
-
-#endif /* _LINUX_RANDOM_H_ */
diff --git a/sys/ofed/include/linux/rbtree.h b/sys/ofed/include/linux/rbtree.h
deleted file mode 100644 (file)
index c4478ca..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*-
- * 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        _LINUX_RBTREE_H_
-#define        _LINUX_RBTREE_H_
-
-#include <sys/stddef.h>
-#include <sys/tree.h>
-
-struct rb_node {
-       RB_ENTRY(rb_node)       __entry;
-};
-#define        rb_left         __entry.rbe_left
-#define        rb_right        __entry.rbe_right
-
-/*
- * We provide a false structure that has the same bit pattern as tree.h
- * presents so it matches the member names expected by linux.
- */
-struct rb_root {
-       struct  rb_node *rb_node;
-};
-
-/*
- * In linux all of the comparisons are done by the caller.
- */
-int panic_cmp(struct rb_node *one, struct rb_node *two);
-
-RB_HEAD(linux_root, rb_node);
-RB_PROTOTYPE(linux_root, rb_node, __entry, panic_cmp);
-
-#define        rb_parent(r)    RB_PARENT(r, __entry)
-#define        rb_color(r)     RB_COLOR(r, __entry)
-#define        rb_is_red(r)    (rb_color(r) == RB_RED)
-#define        rb_is_black(r)  (rb_color(r) == RB_BLACK)
-#define        rb_set_parent(r, p)     rb_parent((r)) = (p)
-#define        rb_set_color(r, c)      rb_color((r)) = (c)
-#define        rb_entry(ptr, type, member)     container_of(ptr, type, member)
-
-#define RB_EMPTY_ROOT(root)     RB_EMPTY((struct linux_root *)root)
-#define RB_EMPTY_NODE(node)     (rb_parent(node) == node)
-#define RB_CLEAR_NODE(node)     (rb_set_parent(node, node))
-
-#define        rb_insert_color(node, root)                                     \
-       linux_root_RB_INSERT_COLOR((struct linux_root *)(root), (node))
-#define        rb_erase(node, root)                                            \
-       linux_root_RB_REMOVE((struct linux_root *)(root), (node))
-#define        rb_next(node)   RB_NEXT(linux_root, NULL, (node))
-#define        rb_prev(node)   RB_PREV(linux_root, NULL, (node))
-#define        rb_first(root)  RB_MIN(linux_root, (struct linux_root *)(root))
-#define        rb_last(root)   RB_MAX(linux_root, (struct linux_root *)(root))
-
-static inline void
-rb_link_node(struct rb_node *node, struct rb_node *parent,
-    struct rb_node **rb_link)
-{
-       rb_set_parent(node, parent);
-       rb_set_color(node, RB_RED);
-       node->__entry.rbe_left = node->__entry.rbe_right = NULL;
-       *rb_link = node;
-}
-
-static inline void
-rb_replace_node(struct rb_node *victim, struct rb_node *new,
-    struct rb_root *root)
-{
-       struct rb_node *p;
-
-       p = rb_parent(victim);
-       if (p) {
-               if (p->rb_left == victim)
-                       p->rb_left = new;
-               else
-                       p->rb_right = new;
-       } else
-               root->rb_node = new;
-       if (victim->rb_left)
-               rb_set_parent(victim->rb_left, new);
-       if (victim->rb_right)
-               rb_set_parent(victim->rb_right, new);
-       *new = *victim;
-}
-
-#undef RB_ROOT
-#define RB_ROOT                (struct rb_root) { NULL }
-
-#endif /* _LINUX_RBTREE_H_ */
diff --git a/sys/ofed/include/linux/rwlock.h b/sys/ofed/include/linux/rwlock.h
deleted file mode 100644 (file)
index e7c6301..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * 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        _LINUX_RWLOCK_H_
-#define        _LINUX_RWLOCK_H_
-
-#include <sys/lock.h>
-#include <sys/rwlock.h>
-
-typedef struct {
-       struct rwlock rw;
-} rwlock_t;
-
-#define        read_lock(_l)           rw_rlock(&(_l)->rw)
-#define        write_lock(_l)          rw_wlock(&(_l)->rw)
-#define        read_unlock(_l)         rw_runlock(&(_l)->rw)
-#define        write_unlock(_l)        rw_wunlock(&(_l)->rw)
-#define        read_lock_irq(lock)     read_lock((lock))
-#define        read_unlock_irq(lock)   read_unlock((lock))
-#define        write_lock_irq(lock)    write_lock((lock))
-#define        write_unlock_irq(lock)  write_unlock((lock))
-#define        read_lock_irqsave(lock, flags)                                  \
-    do {(flags) = 0; read_lock(lock); } while (0)
-#define        write_lock_irqsave(lock, flags)                                 \
-    do {(flags) = 0; write_lock(lock); } while (0)
-#define        read_unlock_irqrestore(lock, flags)                             \
-    do { read_unlock(lock); } while (0)
-#define        write_unlock_irqrestore(lock, flags)                            \
-    do { write_unlock(lock); } while (0)
-
-static inline void
-rwlock_init(rwlock_t *lock)
-{
-
-       memset(&lock->rw, 0, sizeof(lock->rw));
-       rw_init_flags(&lock->rw, "lnxrw", RW_NOWITNESS);
-}
-
-#endif /* _LINUX_RWLOCK_H_ */
diff --git a/sys/ofed/include/linux/rwsem.h b/sys/ofed/include/linux/rwsem.h
deleted file mode 100644 (file)
index 22ad4dc..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * 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        _LINUX_RWSEM_H_
-#define        _LINUX_RWSEM_H_
-
-#include <sys/param.h>
-#include <sys/lock.h>
-#include <sys/sx.h>
-
-struct rw_semaphore {
-       struct sx sx;
-};
-
-#define        down_write(_rw)                 sx_xlock(&(_rw)->sx)
-#define        up_write(_rw)                   sx_xunlock(&(_rw)->sx)
-#define        down_read(_rw)                  sx_slock(&(_rw)->sx)
-#define        up_read(_rw)                    sx_sunlock(&(_rw)->sx)
-#define        down_read_trylock(_rw)          !!sx_try_slock(&(_rw)->sx)
-#define        down_write_trylock(_rw)         !!sx_try_xlock(&(_rw)->sx)
-#define        downgrade_write(_rw)            sx_downgrade(&(_rw)->sx)
-#define        down_read_nested(_rw, _sc)      down_read(_rw)
-
-static inline void
-init_rwsem(struct rw_semaphore *rw)
-{
-
-       memset(&rw->sx, 0, sizeof(rw->sx));
-       sx_init_flags(&rw->sx, "lnxrwsem", SX_NOWITNESS);
-}
-
-#endif /* _LINUX_RWSEM_H_ */
diff --git a/sys/ofed/include/linux/scatterlist.h b/sys/ofed/include/linux/scatterlist.h
deleted file mode 100644 (file)
index 5aa8d65..0000000
+++ /dev/null
@@ -1,279 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
- * Copyright (c) 2015 Matthew Dillon <dillon@backplane.com>
- * 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_SCATTERLIST_H_
-#define        _LINUX_SCATTERLIST_H_
-
-#include <linux/page.h>
-#include <linux/slab.h>
-
-struct scatterlist {
-       union {
-               struct page *page;
-               struct scatterlist *sg;
-       }       sl_un;
-       dma_addr_t address;
-       unsigned long offset;
-       uint32_t length;
-       uint32_t flags;
-};
-
-struct sg_table {
-       struct scatterlist *sgl;
-       unsigned int nents;
-       unsigned int orig_nents;
-};
-
-struct sg_page_iter {
-       struct scatterlist *sg;
-       unsigned int sg_pgoffset;
-       unsigned int maxents;
-};
-
-#define        SG_MAX_SINGLE_ALLOC     (PAGE_SIZE / sizeof(struct scatterlist))
-
-#define        sg_dma_address(sg)      (sg)->address
-#define        sg_dma_len(sg)          (sg)->length
-#define        sg_page(sg)             (sg)->sl_un.page
-#define        sg_scatternext(sg)      (sg)->sl_un.sg
-
-#define        SG_END          0x01
-#define        SG_CHAIN        0x02
-
-static inline void
-sg_set_page(struct scatterlist *sg, struct page *page, unsigned int len,
-    unsigned int offset)
-{
-       sg_page(sg) = page;
-       sg_dma_len(sg) = len;
-       sg->offset = offset;
-       if (offset > PAGE_SIZE)
-               panic("sg_set_page: Invalid offset %d\n", offset);
-}
-
-static inline void
-sg_set_buf(struct scatterlist *sg, const void *buf, unsigned int buflen)
-{
-       sg_set_page(sg, virt_to_page(buf), buflen,
-           ((uintptr_t)buf) & (PAGE_SIZE - 1));
-}
-
-static inline void
-sg_init_table(struct scatterlist *sg, unsigned int nents)
-{
-       bzero(sg, sizeof(*sg) * nents);
-       sg[nents - 1].flags = SG_END;
-}
-
-static inline struct scatterlist *
-sg_next(struct scatterlist *sg)
-{
-       if (sg->flags & SG_END)
-               return (NULL);
-       sg++;
-       if (sg->flags & SG_CHAIN)
-               sg = sg_scatternext(sg);
-       return (sg);
-}
-
-static inline vm_paddr_t
-sg_phys(struct scatterlist *sg)
-{
-       return sg_page(sg)->phys_addr + sg->offset;
-}
-
-static inline void
-sg_chain(struct scatterlist *prv, unsigned int prv_nents,
-    struct scatterlist *sgl)
-{
-       struct scatterlist *sg = &prv[prv_nents - 1];
-
-       sg->offset = 0;
-       sg->length = 0;
-       sg->flags = SG_CHAIN;
-       sg->sl_un.sg = sgl;
-}
-
-static inline void 
-sg_mark_end(struct scatterlist *sg)
-{
-       sg->flags = SG_END;
-}
-
-static inline void
-__sg_free_table(struct sg_table *table, unsigned int max_ents)
-{
-       struct scatterlist *sgl, *next;
-
-       if (unlikely(!table->sgl))
-               return;
-
-       sgl = table->sgl;
-       while (table->orig_nents) {
-               unsigned int alloc_size = table->orig_nents;
-               unsigned int sg_size;
-
-               if (alloc_size > max_ents) {
-                       next = sgl[max_ents - 1].sl_un.sg;
-                       alloc_size = max_ents;
-                       sg_size = alloc_size - 1;
-               } else {
-                       sg_size = alloc_size;
-                       next = NULL;
-               }
-
-               table->orig_nents -= sg_size;
-               kfree(sgl);
-               sgl = next;
-       }
-
-       table->sgl = NULL;
-}
-
-static inline void
-sg_free_table(struct sg_table *table)
-{
-       __sg_free_table(table, SG_MAX_SINGLE_ALLOC);
-}
-
-static inline int
-__sg_alloc_table(struct sg_table *table, unsigned int nents,
-    unsigned int max_ents, gfp_t gfp_mask)
-{
-       struct scatterlist *sg, *prv;
-       unsigned int left;
-
-       memset(table, 0, sizeof(*table));
-
-       if (nents == 0)
-               return -EINVAL;
-       left = nents;
-       prv = NULL;
-       do {
-               unsigned int sg_size;
-               unsigned int alloc_size = left;
-
-               if (alloc_size > max_ents) {
-                       alloc_size = max_ents;
-                       sg_size = alloc_size - 1;
-               } else
-                       sg_size = alloc_size;
-
-               left -= sg_size;
-
-               sg = kmalloc(alloc_size * sizeof(struct scatterlist), gfp_mask);
-               if (unlikely(!sg)) {
-                       if (prv)
-                               table->nents = ++table->orig_nents;
-
-                       return -ENOMEM;
-               }
-               sg_init_table(sg, alloc_size);
-               table->nents = table->orig_nents += sg_size;
-
-               if (prv)
-                       sg_chain(prv, max_ents, sg);
-               else
-                       table->sgl = sg;
-
-               if (!left)
-                       sg_mark_end(&sg[sg_size - 1]);
-
-               prv = sg;
-       } while (left);
-
-       return 0;
-}
-
-static inline int
-sg_alloc_table(struct sg_table *table, unsigned int nents, gfp_t gfp_mask)
-{
-       int ret;
-
-       ret = __sg_alloc_table(table, nents, SG_MAX_SINGLE_ALLOC,
-           gfp_mask);
-       if (unlikely(ret))
-               __sg_free_table(table, SG_MAX_SINGLE_ALLOC);
-
-       return ret;
-}
-
-static inline void
-_sg_iter_next(struct sg_page_iter *iter)
-{
-       struct scatterlist *sg;
-       unsigned int pgcount;
-
-       sg = iter->sg;
-       pgcount = (sg->offset + sg->length + PAGE_SIZE - 1) >> PAGE_SHIFT;
-
-       ++iter->sg_pgoffset;
-       while (iter->sg_pgoffset >= pgcount) {
-               iter->sg_pgoffset -= pgcount;
-               sg = sg_next(sg);
-               --iter->maxents;
-               if (sg == NULL || iter->maxents == 0)
-                       break;
-               pgcount = (sg->offset + sg->length + PAGE_SIZE - 1) >> PAGE_SHIFT;
-       }
-       iter->sg = sg;
-}
-
-static inline void
-_sg_iter_init(struct scatterlist *sgl, struct sg_page_iter *iter,
-    unsigned int nents, unsigned long pgoffset)
-{
-       if (nents) {
-               iter->sg = sgl;
-               iter->sg_pgoffset = pgoffset - 1;
-               iter->maxents = nents;
-               _sg_iter_next(iter);
-       } else {
-               iter->sg = NULL;
-               iter->sg_pgoffset = 0;
-               iter->maxents = 0;
-       }
-}
-
-static inline dma_addr_t
-sg_page_iter_dma_address(struct sg_page_iter *spi)
-{
-       return spi->sg->address + (spi->sg_pgoffset << PAGE_SHIFT);
-}
-
-#define        for_each_sg_page(sgl, iter, nents, pgoffset)                    \
-       for (_sg_iter_init(sgl, iter, nents, pgoffset);                 \
-            (iter)->sg; _sg_iter_next(iter))
-
-#define        for_each_sg(sglist, sg, sgmax, _itr)                            \
-       for (_itr = 0, sg = (sglist); _itr < (sgmax); _itr++, sg = sg_next(sg))
-
-#endif                                 /* _LINUX_SCATTERLIST_H_ */
diff --git a/sys/ofed/include/linux/sched.h b/sys/ofed/include/linux/sched.h
deleted file mode 100644 (file)
index c2d66d7..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*-
- * 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        _LINUX_SCHED_H_
-#define        _LINUX_SCHED_H_
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/sched.h>
-#include <sys/sleepqueue.h>
-
-#define        MAX_SCHEDULE_TIMEOUT    LONG_MAX
-
-#define        TASK_RUNNING            0
-#define        TASK_INTERRUPTIBLE      1
-#define        TASK_UNINTERRUPTIBLE    2
-#define        TASK_DEAD               64
-#define        TASK_WAKEKILL           128
-#define        TASK_WAKING             256
-
-#define        TASK_SHOULD_STOP        1
-#define        TASK_STOPPED            2
-
-/*
- * A task_struct is only provided for those tasks created with kthread.
- * Using these routines with threads not started via kthread will cause
- * panics because no task_struct is allocated and td_retval[1] is
- * overwritten by syscalls which kernel threads will not make use of.
- */
-struct task_struct {
-       struct  thread *task_thread;
-       int     (*task_fn)(void *data);
-       void    *task_data;
-       int     task_ret;
-       int     state;
-       int     should_stop;
-};
-
-#define        current                 task_struct_get(curthread)
-#define        task_struct_get(x)      ((struct task_struct *)(uintptr_t)(x)->td_retval[1])
-#define        task_struct_set(x, y)   (x)->td_retval[1] = (uintptr_t)(y)
-
-/* ensure the task_struct pointer fits into the td_retval[1] field */
-CTASSERT(sizeof(((struct thread *)0)->td_retval[1]) >= sizeof(uintptr_t));
-
-#define        set_current_state(x)                                            \
-       atomic_store_rel_int((volatile int *)&current->state, (x))
-#define        __set_current_state(x)  current->state = (x)
-
-
-#define        schedule()                                                      \
-do {                                                                   \
-       void *c;                                                        \
-                                                                       \
-       if (cold)                                                       \
-               break;                                                  \
-       c = curthread;                                                  \
-       sleepq_lock(c);                                                 \
-       if (current->state == TASK_INTERRUPTIBLE ||                     \
-           current->state == TASK_UNINTERRUPTIBLE) {                   \
-               sleepq_add(c, NULL, "task", SLEEPQ_SLEEP, 0);           \
-               sleepq_wait(c, 0);                                      \
-       } else {                                                        \
-               sleepq_release(c);                                      \
-               sched_relinquish(curthread);                            \
-       }                                                               \
-} while (0)
-
-#define        wake_up_process(x)                                              \
-do {                                                                   \
-       int wakeup_swapper;                                             \
-       void *c;                                                        \
-                                                                       \
-       c = (x)->task_thread;                                           \
-       sleepq_lock(c);                                                 \
-       (x)->state = TASK_RUNNING;                                      \
-       wakeup_swapper = sleepq_signal(c, SLEEPQ_SLEEP, 0, 0);          \
-       sleepq_release(c);                                              \
-       if (wakeup_swapper)                                             \
-               kick_proc0();                                           \
-} while (0)
-
-#define        cond_resched()  if (!cold)      sched_relinquish(curthread)
-
-#define        sched_yield()   sched_relinquish(curthread)
-
-static inline long
-schedule_timeout(signed long timeout)
-{
-       if (timeout < 0)
-               return 0;
-
-       pause("lstim", timeout);
-
-       return 0;
-}
-
-#endif /* _LINUX_SCHED_H_ */
diff --git a/sys/ofed/include/linux/semaphore.h b/sys/ofed/include/linux/semaphore.h
deleted file mode 100644 (file)
index 022a016..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * 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 _LINUX_SEMAPHORE_H_
-#define _LINUX_SEMAPHORE_H_
-
-#include <sys/param.h>
-#include <sys/lock.h>
-#include <sys/sema.h>
-
-/*
- * XXX BSD semaphores are disused and slow.  They also do not provide a
- * sema_wait_sig method.  This must be resolved eventually.
- */
-struct semaphore {
-       struct sema     sema;
-};
-
-#define        down(_sem)                      sema_wait(&(_sem)->sema)
-#define        down_interruptible(_sem)        sema_wait(&(_sem)->sema), 0
-#define        down_trylock(_sem)              !sema_trywait(&(_sem)->sema)
-#define        up(_sem)                        sema_post(&(_sem)->sema)
-
-static inline void
-linux_sema_init(struct semaphore *sem, int val)
-{
-
-       memset(&sem->sema, 0, sizeof(sem->sema));
-       sema_init(&sem->sema, val, "lnxsema");
-}
-
-static inline void
-init_MUTEX(struct semaphore *sem)
-{
-
-       memset(&sem->sema, 0, sizeof(sem->sema));
-       sema_init(&sem->sema, 1, "lnxsema");
-}
-
-#define        sema_init       linux_sema_init
-
-#endif /* _LINUX_SEMAPHORE_H_ */
diff --git a/sys/ofed/include/linux/slab.h b/sys/ofed/include/linux/slab.h
deleted file mode 100644 (file)
index 1b56b55..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*-
- * 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        _LINUX_SLAB_H_
-#define        _LINUX_SLAB_H_
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <vm/uma.h>
-
-#include <linux/types.h>
-#include <linux/gfp.h>
-
-MALLOC_DECLARE(M_KMALLOC);
-
-#define        kmalloc(size, flags)            malloc((size), M_KMALLOC, (flags))
-#define        kvmalloc(size)                  kmalloc((size), 0)
-#define        kzalloc(size, flags)            kmalloc((size), (flags) | M_ZERO)
-#define        kzalloc_node(size, flags, node) kzalloc(size, flags)
-#define        kfree(ptr)                      free(__DECONST(void *, (ptr)), M_KMALLOC)
-#define        krealloc(ptr, size, flags)      realloc((ptr), (size), M_KMALLOC, (flags))
-#define        kcalloc(n, size, flags)         kmalloc((n) * (size), flags | M_ZERO)
-#define        vzalloc(size)                   kzalloc(size, GFP_KERNEL | __GFP_NOWARN)
-#define        vfree(arg)                      kfree(arg)
-#define        kvfree(arg)                     kfree(arg)
-#define        vmalloc(size)                   kmalloc(size, GFP_KERNEL)
-#define        vmalloc_node(size, node)        kmalloc(size, GFP_KERNEL)
-
-struct kmem_cache {
-       uma_zone_t      cache_zone;
-       void            (*cache_ctor)(void *);
-};
-
-#define        SLAB_HWCACHE_ALIGN      0x0001
-
-static inline int
-kmem_ctor(void *mem, int size, void *arg, int flags)
-{
-       void (*ctor)(void *);
-
-       ctor = arg;
-       ctor(mem);
-
-       return (0);
-}
-
-static inline struct kmem_cache *
-kmem_cache_create(char *name, size_t size, size_t align, u_long flags,
-    void (*ctor)(void *))
-{
-       struct kmem_cache *c;
-
-       c = malloc(sizeof(*c), M_KMALLOC, M_WAITOK);
-       if (align)
-               align--;
-       if (flags & SLAB_HWCACHE_ALIGN)
-               align = UMA_ALIGN_CACHE;
-       c->cache_zone = uma_zcreate(name, size, ctor ? kmem_ctor : NULL,
-           NULL, NULL, NULL, align, 0);
-       c->cache_ctor = ctor;
-
-       return c;
-}
-
-static inline void *
-kmem_cache_alloc(struct kmem_cache *c, int flags)
-{
-       return uma_zalloc_arg(c->cache_zone, c->cache_ctor, flags);
-}
-
-static inline void
-kmem_cache_free(struct kmem_cache *c, void *m)
-{
-       uma_zfree(c->cache_zone, m);
-}
-
-static inline void
-kmem_cache_destroy(struct kmem_cache *c)
-{
-       uma_zdestroy(c->cache_zone);
-       free(c, M_KMALLOC);
-}
-
-#endif /* _LINUX_SLAB_H_ */
diff --git a/sys/ofed/include/linux/socket.h b/sys/ofed/include/linux/socket.h
deleted file mode 100644 (file)
index a9a952e..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * 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        _LINUX_SOCKET_H_
-#define        _LINUX_SOCKET_H_
-
-#include <sys/socket.h>
-
-#ifdef notyet
-static inline int
-memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len)
-{
-       struct uio uio;
-       int error;
-
-       uio.uio_iov = v;
-       uio.uio_iovcnt = -1;
-       uio.uio_offset = 0;
-       uio.uio_resid = len;
-       uio.uio_segflag = UIO_USERSPACE;
-       uio.uio_rw = UIO_READ;
-       error = -uiomove(kdata, len, &uio);
-       return (error);
-}
-
-static inline int
-memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len)
-{
-       struct uio uio;
-       int error;
-
-       uio.uio_iov = v;
-       uio.uio_iovcnt = -1;
-       uio.uio_offset = 0;
-       uio.uio_resid = len;
-       uio.uio_segflag = UIO_USERSPACE;
-       uio.uio_rw = UIO_WRITE;
-       error = -uiomove(kdata, len, &uio);
-}
-#endif
-
-#endif /* _LINUX_SOCKET_H_ */
diff --git a/sys/ofed/include/linux/spinlock.h b/sys/ofed/include/linux/spinlock.h
deleted file mode 100644 (file)
index 97c83e0..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * 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        _LINUX_SPINLOCK_H_
-#define        _LINUX_SPINLOCK_H_
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-
-#include <linux/compiler.h>
-#include <linux/kernel.h>
-#include <linux/rwlock.h>
-
-typedef struct {
-       struct mtx m;
-} spinlock_t;
-
-#define        spin_lock(_l)           mtx_lock(&(_l)->m)
-#define        spin_unlock(_l)         mtx_unlock(&(_l)->m)
-#define        spin_trylock(_l)        mtx_trylock(&(_l)->m)
-#define        spin_lock_nested(_l, _n) mtx_lock_flags(&(_l)->m, MTX_DUPOK)
-#define        spin_lock_irq(lock)     spin_lock(lock)
-#define        spin_unlock_irq(lock)   spin_unlock(lock)
-#define        spin_lock_irqsave(lock, flags)                                  \
-    do {(flags) = 0; spin_lock(lock); } while (0)
-#define        spin_unlock_irqrestore(lock, flags)                             \
-    do { spin_unlock(lock); } while (0)
-
-static inline void
-spin_lock_init(spinlock_t *lock)
-{
-
-       memset(&lock->m, 0, sizeof(lock->m));
-       mtx_init(&lock->m, "lnxspin", NULL, MTX_DEF | MTX_NOWITNESS);
-}
-
-#define        DEFINE_SPINLOCK(lock)                                           \
-       spinlock_t lock;                                                \
-       MTX_SYSINIT(lock, &(lock).m, "lnxspin", MTX_DEF)
-
-#endif /* _LINUX_SPINLOCK_H_ */
diff --git a/sys/ofed/include/linux/string.h b/sys/ofed/include/linux/string.h
deleted file mode 100644 (file)
index cf55b09..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * 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        _LINUX_STRING_H_
-#define        _LINUX_STRING_H_
-
-#include <linux/types.h>
-#include <linux/gfp.h>
-#include <linux/slab.h>
-
-#include <sys/libkern.h>
-
-#define strnicmp strncasecmp
-
-
-static inline void *
-kmemdup(const void *src, size_t len, gfp_t gfp)
-{
-       void *dst;
-
-       dst = kmalloc(len, gfp);
-       if (dst)
-               memcpy(dst, src, len);
-       return (dst);
-}
-
-#endif /* _LINUX_STRING_H_ */
diff --git a/sys/ofed/include/linux/sysfs.h b/sys/ofed/include/linux/sysfs.h
deleted file mode 100644 (file)
index e565e43..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/*-
- * 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        _LINUX_SYSFS_H_
-#define        _LINUX_SYSFS_H_
-
-#include <sys/sysctl.h>
-
-struct attribute {
-       const char      *name;
-       struct module   *owner;
-       mode_t          mode;
-};
-
-struct sysfs_ops {
-       ssize_t (*show)(struct kobject *, struct attribute *, char *);
-       ssize_t (*store)(struct kobject *, struct attribute *, const char *,
-           size_t);
-};
-
-struct attribute_group {
-       const char              *name;
-       mode_t                  (*is_visible)(struct kobject *,
-                                   struct attribute *, int);
-       struct attribute        **attrs;
-};
-
-#define        __ATTR(_name, _mode, _show, _store) {                           \
-       .attr = { .name = __stringify(_name), .mode = _mode },          \
-        .show = _show, .store  = _store,                               \
-}
-
-#define        __ATTR_RO(_name) {                                              \
-       .attr = { .name = __stringify(_name), .mode = 0444 },           \
-       .show   = _name##_show,                                         \
-}
-
-#define        __ATTR_NULL     { .attr = { .name = NULL } }
-
-/*
- * Handle our generic '\0' terminated 'C' string.
- * Two cases:
- *      a variable string:  point arg1 at it, arg2 is max length.
- *      a constant string:  point arg1 at it, arg2 is zero.
- */
-
-static inline int
-sysctl_handle_attr(SYSCTL_HANDLER_ARGS)
-{
-       struct kobject *kobj;
-       struct attribute *attr;
-       const struct sysfs_ops *ops;
-       char *buf;
-       int error;
-       ssize_t len;
-
-       kobj = arg1;
-       attr = (struct attribute *)arg2;
-       if (kobj->ktype == NULL || kobj->ktype->sysfs_ops == NULL)
-               return (ENODEV);
-       buf = (char *)get_zeroed_page(GFP_KERNEL);
-       if (buf == NULL)
-               return (ENOMEM);
-       ops = kobj->ktype->sysfs_ops;
-       if (ops->show) {
-               len = ops->show(kobj, attr, buf);
-               /*
-                * It's valid to not have a 'show' so just return an
-                * empty string.
-                */
-               if (len < 0) {
-                       error = -len;
-                       if (error != EIO)
-                               goto out;
-                       buf[0] = '\0';
-               } else if (len) {
-                       len--;
-                       if (len >= PAGE_SIZE)
-                               len = PAGE_SIZE - 1;
-                       /* Trim trailing newline. */
-                       buf[len] = '\0';
-               }
-       }
-
-       /* Leave one trailing byte to append a newline. */
-       error = sysctl_handle_string(oidp, buf, PAGE_SIZE - 1, req);
-       if (error != 0 || req->newptr == NULL || ops->store == NULL)
-               goto out;
-       len = strlcat(buf, "\n", PAGE_SIZE);
-       KASSERT(len < PAGE_SIZE, ("new attribute truncated"));
-       len = ops->store(kobj, attr, buf, len);
-       if (len < 0)
-               error = -len;
-out:
-       free_page((unsigned long)buf);
-
-       return (error);
-}
-
-static inline int
-sysfs_create_file(struct kobject *kobj, const struct attribute *attr)
-{
-
-       sysctl_add_oid(NULL, SYSCTL_CHILDREN(kobj->oidp), OID_AUTO,
-           attr->name, CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_MPSAFE, kobj,
-           (uintptr_t)attr, sysctl_handle_attr, "A", "");
-
-       return (0);
-}
-
-static inline void
-sysfs_remove_file(struct kobject *kobj, const struct attribute *attr)
-{
-
-       if (kobj->oidp)
-               sysctl_remove_name(kobj->oidp, attr->name, 1, 1);
-}
-
-static inline void
-sysfs_remove_group(struct kobject *kobj, const struct attribute_group *grp)
-{
-
-       if (kobj->oidp)
-               sysctl_remove_name(kobj->oidp, grp->name, 1, 1);
-}
-
-static inline int
-sysfs_create_group(struct kobject *kobj, const struct attribute_group *grp)
-{
-       struct attribute **attr;
-       struct sysctl_oid *oidp;
-
-       oidp = SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(kobj->oidp),
-           OID_AUTO, grp->name, CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, grp->name);
-       for (attr = grp->attrs; *attr != NULL; attr++) {
-               sysctl_add_oid(NULL, SYSCTL_CHILDREN(oidp), OID_AUTO,
-                   (*attr)->name, CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_MPSAFE,
-                   kobj, (uintptr_t)*attr, sysctl_handle_attr, "A", "");
-       }
-
-       return (0);
-}
-
-static inline int
-sysfs_create_dir(struct kobject *kobj)
-{
-
-       kobj->oidp = SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(kobj->parent->oidp),
-           OID_AUTO, kobj->name, CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, kobj->name);
-
-        return (0);
-}
-
-static inline void
-sysfs_remove_dir(struct kobject *kobj)
-{
-
-       if (kobj->oidp == NULL)
-               return;
-       sysctl_remove_oid(kobj->oidp, 1, 1);
-}
-
-#define sysfs_attr_init(attr) do {} while(0)
-
-#endif /* _LINUX_SYSFS_H_ */
diff --git a/sys/ofed/include/linux/time.h b/sys/ofed/include/linux/time.h
deleted file mode 100644 (file)
index 27516a4..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*-
- * Copyright (c) 2014-2015 François Tigeot
- * 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_TIME_H_
-#define        _LINUX_TIME_H_
-
-#define        NSEC_PER_USEC   1000L
-#define        NSEC_PER_SEC    1000000000L
-
-#include <sys/time.h>
-#include <sys/stdint.h>
-
-static inline struct timeval
-ns_to_timeval(const int64_t nsec)
-{
-       struct timeval tv;
-       long rem;
-
-       if (nsec == 0) {
-               tv.tv_sec = 0;
-               tv.tv_usec = 0;
-               return (tv);
-       }
-
-       tv.tv_sec = nsec / NSEC_PER_SEC;
-       rem = nsec % NSEC_PER_SEC;
-       if (rem < 0) {
-               tv.tv_sec--;
-               rem += NSEC_PER_SEC;
-       }
-       tv.tv_usec = rem / 1000;
-       return (tv);
-}
-
-static inline int64_t
-timeval_to_ns(const struct timeval *tv)
-{
-       return ((int64_t)tv->tv_sec * NSEC_PER_SEC) +
-               tv->tv_usec * NSEC_PER_USEC;
-}
-
-#define getrawmonotonic(ts)    nanouptime(ts)
-
-static inline struct timespec
-timespec_sub(struct timespec lhs, struct timespec rhs)
-{
-       struct timespec ts;
-
-       ts.tv_sec = lhs.tv_sec;
-       ts.tv_nsec = lhs.tv_nsec;
-       timespecsub(&ts, &rhs);
-
-       return ts;
-}
-
-static inline void
-set_normalized_timespec(struct timespec *ts, time_t sec, int64_t nsec)
-{
-       /* XXX: this doesn't actually normalize anything */
-       ts->tv_sec = sec;
-       ts->tv_nsec = nsec;
-}
-
-static inline int64_t
-timespec_to_ns(const struct timespec *ts)
-{
-       return ((ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec);
-}
-
-static inline struct timespec
-ns_to_timespec(const int64_t nsec)
-{
-       struct timespec ts;
-       int32_t rem;
-
-       if (nsec == 0) {
-               ts.tv_sec = 0;
-               ts.tv_nsec = 0;
-               return (ts);
-       }
-
-       ts.tv_sec = nsec / NSEC_PER_SEC;
-       rem = nsec % NSEC_PER_SEC;
-       if (rem < 0) {
-               ts.tv_sec--;
-               rem += NSEC_PER_SEC;
-       }
-       ts.tv_nsec = rem;
-       return (ts);
-}
-
-static inline int
-timespec_valid(const struct timespec *ts)
-{
-       if (ts->tv_sec < 0 || ts->tv_sec > 100000000 ||
-           ts->tv_nsec < 0 || ts->tv_nsec >= 1000000000)
-               return (0);
-       return (1);
-}
-
-static inline unsigned long
-get_seconds(void)
-{
-       return time_uptime;
-}
-
-#endif /* _LINUX_TIME_H_ */
diff --git a/sys/ofed/include/linux/timer.h b/sys/ofed/include/linux/timer.h
deleted file mode 100644 (file)
index a794c13..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * 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 _LINUX_TIMER_H_
-#define        _LINUX_TIMER_H_
-
-#include <linux/types.h>
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/callout.h>
-
-struct timer_list {
-       struct callout timer_callout;
-       void    (*function) (unsigned long);
-       unsigned long data;
-       unsigned long expires;
-};
-
-extern unsigned long linux_timer_hz_mask;
-
-#define        setup_timer(timer, func, dat)                                   \
-do {                                                                   \
-       (timer)->function = (func);                                     \
-       (timer)->data = (dat);                                          \
-       callout_init(&(timer)->timer_callout, 1);                       \
-} while (0)
-
-#define        init_timer(timer)                                               \
-do {                                                                   \
-       (timer)->function = NULL;                                       \
-       (timer)->data = 0;                                              \
-       callout_init(&(timer)->timer_callout, 1);                       \
-} while (0)
-
-extern void mod_timer(struct timer_list *, unsigned long);
-extern void add_timer(struct timer_list *);
-
-#define        del_timer(timer)        callout_stop(&(timer)->timer_callout)
-#define        del_timer_sync(timer)   callout_drain(&(timer)->timer_callout)
-#define        timer_pending(timer)    callout_pending(&(timer)->timer_callout)
-#define        round_jiffies(j) \
-       ((unsigned long)(((j) + linux_timer_hz_mask) & ~linux_timer_hz_mask))
-#define        round_jiffies_relative(j) \
-       round_jiffies(j)
-
-#endif                                 /* _LINUX_TIMER_H_ */
diff --git a/sys/ofed/include/linux/types.h b/sys/ofed/include/linux/types.h
deleted file mode 100644 (file)
index c9c3728..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * 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        _LINUX_TYPES_H_
-#define        _LINUX_TYPES_H_
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <linux/compiler.h>
-#include <asm/types.h>
-
-#ifndef __bitwise__
-#ifdef __CHECKER__
-#define __bitwise__ __attribute__((bitwise))
-#else
-#define __bitwise__
-#endif
-#endif
-
-typedef uint16_t __le16;
-typedef uint16_t __be16;
-typedef uint32_t __le32;
-typedef uint32_t __be32;
-typedef uint64_t __le64;
-typedef uint64_t __be64;
-
-typedef unsigned int    uint;
-typedef unsigned gfp_t;
-typedef uint64_t loff_t;
-typedef vm_paddr_t resource_size_t;
-
-typedef u64 phys_addr_t;
-
-#define        DECLARE_BITMAP(n, bits)                                         \
-       unsigned long n[howmany(bits, sizeof(long) * 8)]
-
-#endif /* _LINUX_TYPES_H_ */
diff --git a/sys/ofed/include/linux/uaccess.h b/sys/ofed/include/linux/uaccess.h
deleted file mode 100644 (file)
index 87d1bab..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
- * Copyright (c) 2015 François Tigeot
- * 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_UACCESS_H_
-#define        _LINUX_UACCESS_H_
-
-#include <linux/compiler.h>
-
-#define        get_user(_x, _p)        -copyin((_p), &(_x), sizeof(*(_p)))
-#define        put_user(_x, _p)        -copyout(&(_x), (_p), sizeof(*(_p)))
-
-/*
- * NOTE: The returned value from pagefault_disable() must be stored
- * and passed to pagefault_enable(). Else possible recursion on the
- * state can be lost.
- */
-static inline int __must_check
-pagefault_disable(void)
-{
-       return (vm_fault_disable_pagefaults());
-}
-
-static inline void
-pagefault_enable(int save)
-{
-       vm_fault_enable_pagefaults(save);
-}
-
-#endif /* _LINUX_UACCESS_H_ */
diff --git a/sys/ofed/include/linux/vmalloc.h b/sys/ofed/include/linux/vmalloc.h
deleted file mode 100644 (file)
index 5317831..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * 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 _LINUX_VMALLOC_H_
-#define        _LINUX_VMALLOC_H_
-
-#include <linux/page.h>
-
-#define        VM_MAP          0x0000
-#define        PAGE_KERNEL     0x0000
-
-void *vmap(struct page **pages, unsigned int count, unsigned long flags,
-    int prot);
-void vunmap(void *addr);
-
-#endif /* _LINUX_VMALLOC_H_ */
diff --git a/sys/ofed/include/linux/wait.h b/sys/ofed/include/linux/wait.h
deleted file mode 100644 (file)
index c62f735..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*-
- * 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        _LINUX_WAIT_H_
-#define        _LINUX_WAIT_H_
-
-#include <linux/spinlock.h>
-#include <linux/sched.h>
-#include <linux/list.h>
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sleepqueue.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-
-typedef struct {
-} wait_queue_t;
-
-typedef struct {
-       unsigned int    wchan;
-} wait_queue_head_t;
-
-#define        init_waitqueue_head(x) \
-    do { } while (0)
-
-static inline void
-__wake_up(wait_queue_head_t *q, int all)
-{
-       int wakeup_swapper;
-       void *c;
-
-       c = &q->wchan;
-       sleepq_lock(c);
-       if (all)
-               wakeup_swapper = sleepq_broadcast(c, SLEEPQ_SLEEP, 0, 0);
-       else
-               wakeup_swapper = sleepq_signal(c, SLEEPQ_SLEEP, 0, 0);
-       sleepq_release(c);
-       if (wakeup_swapper)
-               kick_proc0();
-}
-
-#define        wake_up(q)                              __wake_up(q, 0)
-#define        wake_up_nr(q, nr)                       __wake_up(q, 1)
-#define        wake_up_all(q)                          __wake_up(q, 1)
-#define        wake_up_interruptible(q)                __wake_up(q, 0)
-#define        wake_up_interruptible_nr(q, nr)         __wake_up(q, 1)
-#define        wake_up_interruptible_all(q, nr)        __wake_up(q, 1)
-
-#define        wait_event(q, cond)                                             \
-do {                                                                   \
-       void *c = &(q).wchan;                                           \
-       if (!(cond)) {                                                  \
-               for (;;) {                                              \
-                       sleepq_lock(c);                                 \
-                       if (cond) {                                     \
-                               sleepq_release(c);                      \
-                               break;                                  \
-                       }                                               \
-                       sleepq_add(c, NULL, "completion", SLEEPQ_SLEEP, 0); \
-                       sleepq_wait(c, 0);                              \
-               }                                                       \
-       }                                                               \
-} while (0)
-
-#define        wait_event_interruptible(q, cond)                               \
-({                                                                     \
-       void *c = &(q).wchan;                                           \
-       int _error;                                                     \
-                                                                       \
-       _error = 0;                                                     \
-       if (!(cond)) {                                                  \
-               for (; _error == 0;) {                                  \
-                       sleepq_lock(c);                                 \
-                       if (cond) {                                     \
-                               sleepq_release(c);                      \
-                               break;                                  \
-                       }                                               \
-                       sleepq_add(c, NULL, "completion",               \
-                           SLEEPQ_SLEEP | SLEEPQ_INTERRUPTIBLE, 0);    \
-                       if (sleepq_wait_sig(c, 0))                      \
-                               _error = -ERESTARTSYS;                  \
-               }                                                       \
-       }                                                               \
-       -_error;                                                        \
-})
-
-static inline int
-waitqueue_active(wait_queue_head_t *q)
-{
-       return 0;       /* XXX: not really implemented */
-}
-
-#define DEFINE_WAIT(name)      \
-       wait_queue_t name = {}
-
-static inline void
-prepare_to_wait(wait_queue_head_t *q, wait_queue_t *wait, int state)
-{
-}
-
-static inline void
-finish_wait(wait_queue_head_t *q, wait_queue_t *wait)
-{
-}
-
-#endif /* _LINUX_WAIT_H_ */
diff --git a/sys/ofed/include/linux/workqueue.h b/sys/ofed/include/linux/workqueue.h
deleted file mode 100644 (file)
index e9a6f5a..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/*-
- * 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        _LINUX_WORKQUEUE_H_
-#define        _LINUX_WORKQUEUE_H_
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/timer.h>
-#include <linux/slab.h>
-
-#include <sys/taskqueue.h>
-
-struct workqueue_struct {
-       struct taskqueue        *taskqueue;
-};
-
-struct work_struct {
-       struct  task            work_task;
-       struct  taskqueue       *taskqueue;
-       void                    (*fn)(struct work_struct *);
-};
-
-struct delayed_work {
-       struct work_struct      work;
-       struct callout          timer;
-};
-
-static inline struct delayed_work *
-to_delayed_work(struct work_struct *work)
-{
-
-       return container_of(work, struct delayed_work, work);
-}
-
-
-static inline void
-_work_fn(void *context, int pending)
-{
-       struct work_struct *work;
-
-       work = context;
-       work->fn(work);
-}
-
-#define        INIT_WORK(work, func)                                           \
-do {                                                                   \
-       (work)->fn = (func);                                            \
-       (work)->taskqueue = NULL;                                       \
-       TASK_INIT(&(work)->work_task, 0, _work_fn, (work));             \
-} while (0)
-
-#define        INIT_DELAYED_WORK(_work, func)                                  \
-do {                                                                   \
-       INIT_WORK(&(_work)->work, func);                                \
-       callout_init(&(_work)->timer, 1);                               \
-} while (0)
-
-#define        INIT_DEFERRABLE_WORK    INIT_DELAYED_WORK
-
-#define        schedule_work(work)                                             \
-do {                                                                   \
-       (work)->taskqueue = taskqueue_thread;                           \
-       taskqueue_enqueue(taskqueue_thread, &(work)->work_task);        \
-} while (0)
-
-#define        flush_scheduled_work()  flush_taskqueue(taskqueue_thread)
-
-static inline int queue_work(struct workqueue_struct *q, struct work_struct *work)
-{
-       (work)->taskqueue = (q)->taskqueue;
-       /* Return opposite val to align with Linux logic */
-       return !taskqueue_enqueue((q)->taskqueue, &(work)->work_task);
-}
-
-static inline void
-_delayed_work_fn(void *arg)
-{
-       struct delayed_work *work;
-
-       work = arg;
-       taskqueue_enqueue(work->work.taskqueue, &work->work.work_task);
-}
-
-static inline int
-queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *work,
-    unsigned long delay)
-{
-       int pending;
-
-       pending = work->work.work_task.ta_pending;
-       work->work.taskqueue = wq->taskqueue;
-       if (delay != 0)
-               callout_reset(&work->timer, delay, _delayed_work_fn, work);
-       else
-               _delayed_work_fn((void *)work);
-
-       return (!pending);
-}
-
-static inline bool schedule_delayed_work(struct delayed_work *dwork,
-                                         unsigned long delay)
-{
-        struct workqueue_struct wq;
-        wq.taskqueue = taskqueue_thread;
-        return queue_delayed_work(&wq, dwork, delay);
-}
-
-static inline struct workqueue_struct *
-_create_workqueue_common(char *name, int cpus)
-{
-       struct workqueue_struct *wq;
-
-       wq = kmalloc(sizeof(*wq), M_WAITOK);
-       wq->taskqueue = taskqueue_create((name), M_WAITOK,
-           taskqueue_thread_enqueue,  &wq->taskqueue);
-       taskqueue_start_threads(&wq->taskqueue, cpus, PWAIT, "%s", name);
-
-       return (wq);
-}
-
-
-#define        create_singlethread_workqueue(name)                             \
-       _create_workqueue_common(name, 1)
-
-#define        create_workqueue(name)                                          \
-       _create_workqueue_common(name, MAXCPU)
-
-#define        alloc_ordered_workqueue(name, flags)                            \
-       _create_workqueue_common(name, 1)
-
-#define        alloc_workqueue(name, flags, max_active)                        \
-       _create_workqueue_common(name, max_active)
-
-static inline void
-destroy_workqueue(struct workqueue_struct *wq)
-{
-       taskqueue_free(wq->taskqueue);
-       kfree(wq);
-}
-
-#define        flush_workqueue(wq)     flush_taskqueue((wq)->taskqueue)
-
-static inline void
-_flush_fn(void *context, int pending)
-{
-}
-
-static inline void
-flush_taskqueue(struct taskqueue *tq)
-{
-       struct task flushtask;
-
-       PHOLD(curproc);
-       TASK_INIT(&flushtask, 0, _flush_fn, NULL);
-       taskqueue_enqueue(tq, &flushtask);
-       taskqueue_drain(tq, &flushtask);
-       PRELE(curproc);
-}
-
-static inline int
-cancel_work_sync(struct work_struct *work)
-{
-       if (work->taskqueue &&
-           taskqueue_cancel(work->taskqueue, &work->work_task, NULL))
-               taskqueue_drain(work->taskqueue, &work->work_task);
-       return 0;
-}
-
-/*
- * This may leave work running on another CPU as it does on Linux.
- */
-static inline int
-cancel_delayed_work(struct delayed_work *work)
-{
-
-       callout_stop(&work->timer);
-       if (work->work.taskqueue)
-               return (taskqueue_cancel(work->work.taskqueue,
-                   &work->work.work_task, NULL) == 0);
-       return 0;
-}
-
-static inline int
-cancel_delayed_work_sync(struct delayed_work *work)
-{
-
-        callout_drain(&work->timer);
-        if (work->work.taskqueue &&
-            taskqueue_cancel(work->work.taskqueue, &work->work.work_task, NULL))
-                taskqueue_drain(work->work.taskqueue, &work->work.work_task);
-        return 0;
-}
-
-static inline bool
-mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork,
-                                     unsigned long delay)
-{
-       cancel_delayed_work(dwork);
-       queue_delayed_work(wq, dwork, delay);
-       return false;
-}
-
-#endif /* _LINUX_WORKQUEUE_H_ */
diff --git a/sys/ofed/include/net/if_inet6.h b/sys/ofed/include/net/if_inet6.h
deleted file mode 100644 (file)
index df853fd..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * 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 _NET_IF_INET6_H_
-#define        _NET_IF_INET6_H_
-
-static inline void ipv6_eth_mc_map(const struct in6_addr *addr, char *buf)
-{
-/*
- *      +-------+-------+-------+-------+-------+-------+
- *      |   33  |   33  | DST13 | DST14 | DST15 | DST16 |
- *      +-------+-------+-------+-------+-------+-------+
- */
-
-        buf[0]= 0x33;
-        buf[1]= 0x33;
-
-        memcpy(buf + 2, &addr->s6_addr32[3], sizeof(__u32));
-}
-
-#endif /* _NET_IF_INET6_H_ */
diff --git a/sys/ofed/include/net/ip.h b/sys/ofed/include/net/ip.h
deleted file mode 100644 (file)
index 7fbe9d9..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-
- * 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 _LINUX_NET_IP_H_
-#define        _LINUX_NET_IP_H_
-
-#include "opt_inet.h"
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <net/if_types.h>
-#include <net/if.h>
-#include <net/if_var.h>
-
-#include <netinet/in.h>
-#include <netinet/in_pcb.h>
-
-static inline void inet_get_local_port_range(int *low, int *high)
-{
-#ifdef INET
-       CURVNET_SET_QUIET(TD_TO_VNET(curthread));
-       *low = V_ipport_firstauto;
-       *high = V_ipport_lastauto;
-       CURVNET_RESTORE();
-#else
-       *low = IPPORT_EPHEMERALFIRST;     /* 10000 */
-       *high = IPPORT_EPHEMERALLAST;     /* 65535 */
-#endif
-}
-
-static inline void
-ip_ib_mc_map(uint32_t addr, const unsigned char *bcast, char *buf)
-{
-       unsigned char scope;
-
-       addr = ntohl(addr);
-       scope = bcast[5] & 0xF;
-       buf[0] = 0;
-       buf[1] = 0xff;
-       buf[2] = 0xff;
-       buf[3] = 0xff;
-       buf[4] = 0xff;
-       buf[5] = 0x10 | scope;
-       buf[6] = 0x40;
-       buf[7] = 0x1b;
-       buf[8] = bcast[8];
-       buf[9] = bcast[9];
-       buf[10] = 0;
-       buf[11] = 0;
-       buf[12] = 0;
-       buf[13] = 0;
-       buf[14] = 0;
-       buf[15] = 0;
-       buf[16] = (addr >> 24) & 0xff;
-       buf[17] = (addr >> 16) & 0xff;
-       buf[18] = (addr >> 8) & 0xff;
-       buf[19] = addr & 0xff;
-}
-
-#endif /* _LINUX_NET_IP_H_ */
diff --git a/sys/ofed/include/net/ipv6.h b/sys/ofed/include/net/ipv6.h
deleted file mode 100644 (file)
index 1244706..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * 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 _LINUX_NET_IPV6_H_
-#define        _LINUX_NET_IPV6_H_
-
-#include "opt_inet6.h"
-
-#define        ipv6_addr_loopback IN6_IS_ADDR_LOOPBACK
-#define        ipv6_addr_copy(dst, src)                                        \
-       memcpy((dst), (src), sizeof(struct in6_addr))
-
-#ifdef INET6
-static inline void
-ipv6_ib_mc_map(const struct in6_addr *addr, const unsigned char *broadcast,
-    char *buf)
-{
-       unsigned char scope;
-
-       scope = broadcast[5] & 0xF;
-       buf[0]  = 0;
-       buf[1]  = 0xff;
-       buf[2]  = 0xff;
-       buf[3]  = 0xff;
-       buf[4]  = 0xff;
-       buf[5]  = 0x10 | scope;
-       buf[6]  = 0x60;
-       buf[7]  = 0x1b;
-       buf[8]  = broadcast[8];
-       buf[9]  = broadcast[9];
-       memcpy(&buf[10], &addr->s6_addr[6], 10);
-}
-#endif
-
-static inline void __ipv6_addr_set_half(__be32 *addr,
-                                        __be32 wh, __be32 wl)
-{
-#if BITS_PER_LONG == 64
-#if defined(__BIG_ENDIAN)
-        if (__builtin_constant_p(wh) && __builtin_constant_p(wl)) {
-                *(__force u64 *)addr = ((__force u64)(wh) << 32 | (__force u64)(wl));
-                return;
-        }
-#elif defined(__LITTLE_ENDIAN)
-        if (__builtin_constant_p(wl) && __builtin_constant_p(wh)) {
-                *(__force u64 *)addr = ((__force u64)(wl) << 32 | (__force u64)(wh));
-                return;
-        }
-#endif
-#endif
-        addr[0] = wh;
-        addr[1] = wl;
-}
-
-static inline void ipv6_addr_set(struct in6_addr *addr,
-                                     __be32 w1, __be32 w2,
-                                     __be32 w3, __be32 w4)
-{
-        __ipv6_addr_set_half(&addr->s6_addr32[0], w1, w2);
-        __ipv6_addr_set_half(&addr->s6_addr32[2], w3, w4);
-}
-
-static inline void ipv6_addr_set_v4mapped(const __be32 addr,
-                                         struct in6_addr *v4mapped)
-{
-       ipv6_addr_set(v4mapped,
-                       0, 0,
-                       htonl(0x0000FFFF),
-                       addr);
-}
-
-static inline int ipv6_addr_v4mapped(const struct in6_addr *a)
-{
-       return ((a->s6_addr32[0] | a->s6_addr32[1] |
-               (a->s6_addr32[2] ^ htonl(0x0000ffff))) == 0);
-}
-
-static inline int ipv6_addr_cmp(const struct in6_addr *a1, const struct in6_addr *a2)
-{
-        return memcmp(a1, a2, sizeof(struct in6_addr));
-}
-
-
-#endif /* _LINUX_NET_IPV6_H_ */
diff --git a/sys/ofed/include/net/netevent.h b/sys/ofed/include/net/netevent.h
deleted file mode 100644 (file)
index d2d37c0..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * 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        _LINUX_NET_NETEVENT_H_
-#define        _LINUX_NET_NETEVENT_H_
-
-#include <netinet/if_ether.h>
-
-enum netevent_notif_type {
-       NETEVENT_NEIGH_UPDATE = 0,
-#if 0 /* Unsupported events. */
-        NETEVENT_PMTU_UPDATE,
-        NETEVENT_REDIRECT,
-#endif
-};
-
-struct llentry;
-
-static inline void
-_handle_arp_update_event(void *arg, struct llentry *lle, int evt __unused)
-{
-       struct notifier_block *nb;
-
-       nb = arg;
-       nb->notifier_call(nb, NETEVENT_NEIGH_UPDATE, lle);
-}
-
-static inline int
-register_netevent_notifier(struct notifier_block *nb)
-{
-       nb->tags[NETEVENT_NEIGH_UPDATE] = EVENTHANDLER_REGISTER(
-           lle_event, _handle_arp_update_event, nb, 0);
-       return (0);
-}
-
-static inline int
-unregister_netevent_notifier(struct notifier_block *nb)
-{
-
-       EVENTHANDLER_DEREGISTER(lle_event, nb->tags[NETEVENT_NEIGH_UPDATE]);
-
-       return (0);
-}
-
-#endif /* _LINUX_NET_NETEVENT_H_ */
diff --git a/sys/ofed/include/net/tcp.h b/sys/ofed/include/net/tcp.h
deleted file mode 100644 (file)
index 3f15619..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * 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 _LINUX_NET_TCP_H_
-#define        _LINUX_NET_TCP_H_
-
-#include <linux/list.h>
-#include <linux/slab.h>
-#include <linux/kref.h>
-
-#include <net/ip.h>
-
-#endif /* _LINUX_NET_TCP_H_ */
index 9df3c9ce3a6366079b44512b683741968a28f249..aa8606e4983a1838e85a74e2f20457a1cab3f407 100644 (file)
@@ -58,7 +58,7 @@
  *             in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1100083      /* Master, propagated to newvers */
+#define __FreeBSD_version 1100084      /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,