[Midnightbsd-cvs] src [9919] trunk/sys/ofed/include/rdma: sync with freebsd 10

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Fri May 25 09:01:21 EDT 2018


Revision: 9919
          http://svnweb.midnightbsd.org/src/?rev=9919
Author:   laffer1
Date:     2018-05-25 09:01:20 -0400 (Fri, 25 May 2018)
Log Message:
-----------
sync with freebsd 10

Modified Paths:
--------------
    trunk/sys/ofed/drivers/infiniband/Makefile
    trunk/sys/ofed/drivers/infiniband/core/Makefile
    trunk/sys/ofed/drivers/infiniband/core/addr.c
    trunk/sys/ofed/drivers/infiniband/core/agent.c
    trunk/sys/ofed/drivers/infiniband/core/agent.h
    trunk/sys/ofed/drivers/infiniband/core/cache.c
    trunk/sys/ofed/drivers/infiniband/core/cm.c
    trunk/sys/ofed/drivers/infiniband/core/cm_msgs.h
    trunk/sys/ofed/drivers/infiniband/core/cma.c
    trunk/sys/ofed/drivers/infiniband/core/core_priv.h
    trunk/sys/ofed/drivers/infiniband/core/device.c
    trunk/sys/ofed/drivers/infiniband/core/fmr_pool.c
    trunk/sys/ofed/drivers/infiniband/core/iwcm.c
    trunk/sys/ofed/drivers/infiniband/core/iwcm.h
    trunk/sys/ofed/drivers/infiniband/core/local_sa.c
    trunk/sys/ofed/drivers/infiniband/core/mad.c
    trunk/sys/ofed/drivers/infiniband/core/mad_priv.h
    trunk/sys/ofed/drivers/infiniband/core/mad_rmpp.c
    trunk/sys/ofed/drivers/infiniband/core/mad_rmpp.h
    trunk/sys/ofed/drivers/infiniband/core/multicast.c
    trunk/sys/ofed/drivers/infiniband/core/notice.c
    trunk/sys/ofed/drivers/infiniband/core/packer.c
    trunk/sys/ofed/drivers/infiniband/core/sa.h
    trunk/sys/ofed/drivers/infiniband/core/sa_query.c
    trunk/sys/ofed/drivers/infiniband/core/smi.c
    trunk/sys/ofed/drivers/infiniband/core/smi.h
    trunk/sys/ofed/drivers/infiniband/core/sysfs.c
    trunk/sys/ofed/drivers/infiniband/core/ucm.c
    trunk/sys/ofed/drivers/infiniband/core/ucma.c
    trunk/sys/ofed/drivers/infiniband/core/ud_header.c
    trunk/sys/ofed/drivers/infiniband/core/umem.c
    trunk/sys/ofed/drivers/infiniband/core/user_mad.c
    trunk/sys/ofed/drivers/infiniband/core/uverbs.h
    trunk/sys/ofed/drivers/infiniband/core/uverbs_cmd.c
    trunk/sys/ofed/drivers/infiniband/core/uverbs_main.c
    trunk/sys/ofed/drivers/infiniband/core/uverbs_marshall.c
    trunk/sys/ofed/drivers/infiniband/core/verbs.c
    trunk/sys/ofed/drivers/infiniband/debug/Makefile
    trunk/sys/ofed/drivers/infiniband/debug/memtrack.c
    trunk/sys/ofed/drivers/infiniband/debug/memtrack.h
    trunk/sys/ofed/drivers/infiniband/debug/mtrack.h
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/Makefile
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/ah.c
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/alias_GUID.c
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/cm.c
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/cq.c
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/doorbell.c
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/mad.c
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/main.c
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/mcg.c
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/mlx4_ib.h
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/mr.c
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/qp.c
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/srq.c
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/sysfs.c
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/user.h
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/wc.c
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/wc.h
    trunk/sys/ofed/drivers/infiniband/hw/mthca/Makefile
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_allocator.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_av.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_catas.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.h
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_config_reg.h
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_cq.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_dev.h
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_doorbell.h
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_mad.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_mcg.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.h
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_mr.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_pd.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_profile.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_profile.h
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.h
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_qp.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_reset.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_srq.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_uar.c
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_user.h
    trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_wqe.h
    trunk/sys/ofed/drivers/infiniband/ulp/ipoib/Makefile
    trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h
    trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c
    trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
    trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_fs.c
    trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c
    trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
    trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
    trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
    trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
    trunk/sys/ofed/drivers/infiniband/ulp/sdp/Makefile
    trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h
    trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_bcopy.c
    trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_cma.c
    trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_dbg.h
    trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
    trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_proc.c
    trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c
    trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_tx.c
    trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_zcopy.c
    trunk/sys/ofed/drivers/infiniband/util/Makefile
    trunk/sys/ofed/drivers/infiniband/util/madeye.c
    trunk/sys/ofed/drivers/net/mlx4/Makefile
    trunk/sys/ofed/drivers/net/mlx4/alloc.c
    trunk/sys/ofed/drivers/net/mlx4/catas.c
    trunk/sys/ofed/drivers/net/mlx4/cmd.c
    trunk/sys/ofed/drivers/net/mlx4/cq.c
    trunk/sys/ofed/drivers/net/mlx4/en_cq.c
    trunk/sys/ofed/drivers/net/mlx4/en_ethtool.c
    trunk/sys/ofed/drivers/net/mlx4/en_frag.c
    trunk/sys/ofed/drivers/net/mlx4/en_main.c
    trunk/sys/ofed/drivers/net/mlx4/en_netdev.c
    trunk/sys/ofed/drivers/net/mlx4/en_params.c
    trunk/sys/ofed/drivers/net/mlx4/en_port.c
    trunk/sys/ofed/drivers/net/mlx4/en_port.h
    trunk/sys/ofed/drivers/net/mlx4/en_resources.c
    trunk/sys/ofed/drivers/net/mlx4/en_rx.c
    trunk/sys/ofed/drivers/net/mlx4/en_selftest.c
    trunk/sys/ofed/drivers/net/mlx4/en_tx.c
    trunk/sys/ofed/drivers/net/mlx4/eq.c
    trunk/sys/ofed/drivers/net/mlx4/fw.c
    trunk/sys/ofed/drivers/net/mlx4/fw.h
    trunk/sys/ofed/drivers/net/mlx4/icm.c
    trunk/sys/ofed/drivers/net/mlx4/icm.h
    trunk/sys/ofed/drivers/net/mlx4/intf.c
    trunk/sys/ofed/drivers/net/mlx4/main.c
    trunk/sys/ofed/drivers/net/mlx4/mcg.c
    trunk/sys/ofed/drivers/net/mlx4/mlx4.h
    trunk/sys/ofed/drivers/net/mlx4/mlx4_en.h
    trunk/sys/ofed/drivers/net/mlx4/mlx4_stats.h
    trunk/sys/ofed/drivers/net/mlx4/mr.c
    trunk/sys/ofed/drivers/net/mlx4/pd.c
    trunk/sys/ofed/drivers/net/mlx4/port.c
    trunk/sys/ofed/drivers/net/mlx4/profile.c
    trunk/sys/ofed/drivers/net/mlx4/qp.c
    trunk/sys/ofed/drivers/net/mlx4/reset.c
    trunk/sys/ofed/drivers/net/mlx4/resource_tracker.c
    trunk/sys/ofed/drivers/net/mlx4/sense.c
    trunk/sys/ofed/drivers/net/mlx4/srq.c
    trunk/sys/ofed/drivers/net/mlx4/sys_tune.c
    trunk/sys/ofed/drivers/net/mlx4/utils.c
    trunk/sys/ofed/drivers/net/mlx4/utils.h
    trunk/sys/ofed/drivers/net/mlx4/xrcd.c
    trunk/sys/ofed/include/asm/atomic-long.h
    trunk/sys/ofed/include/asm/atomic.h
    trunk/sys/ofed/include/asm/byteorder.h
    trunk/sys/ofed/include/asm/current.h
    trunk/sys/ofed/include/asm/fcntl.h
    trunk/sys/ofed/include/asm/io.h
    trunk/sys/ofed/include/asm/page.h
    trunk/sys/ofed/include/asm/pgtable.h
    trunk/sys/ofed/include/asm/semaphore.h
    trunk/sys/ofed/include/asm/system.h
    trunk/sys/ofed/include/asm/types.h
    trunk/sys/ofed/include/asm/uaccess.h
    trunk/sys/ofed/include/linux/bitmap.h
    trunk/sys/ofed/include/linux/bitops.h
    trunk/sys/ofed/include/linux/cache.h
    trunk/sys/ofed/include/linux/cdev.h
    trunk/sys/ofed/include/linux/clocksource.h
    trunk/sys/ofed/include/linux/compat.h
    trunk/sys/ofed/include/linux/compiler.h
    trunk/sys/ofed/include/linux/completion.h
    trunk/sys/ofed/include/linux/ctype.h
    trunk/sys/ofed/include/linux/delay.h
    trunk/sys/ofed/include/linux/device.h
    trunk/sys/ofed/include/linux/dma-attrs.h
    trunk/sys/ofed/include/linux/dma-mapping.h
    trunk/sys/ofed/include/linux/dmapool.h
    trunk/sys/ofed/include/linux/err.h
    trunk/sys/ofed/include/linux/errno.h
    trunk/sys/ofed/include/linux/etherdevice.h
    trunk/sys/ofed/include/linux/ethtool.h
    trunk/sys/ofed/include/linux/file.h
    trunk/sys/ofed/include/linux/fs.h
    trunk/sys/ofed/include/linux/gfp.h
    trunk/sys/ofed/include/linux/hardirq.h
    trunk/sys/ofed/include/linux/idr.h
    trunk/sys/ofed/include/linux/if_arp.h
    trunk/sys/ofed/include/linux/if_ether.h
    trunk/sys/ofed/include/linux/if_vlan.h
    trunk/sys/ofed/include/linux/in.h
    trunk/sys/ofed/include/linux/in6.h
    trunk/sys/ofed/include/linux/inet.h
    trunk/sys/ofed/include/linux/inetdevice.h
    trunk/sys/ofed/include/linux/init.h
    trunk/sys/ofed/include/linux/interrupt.h
    trunk/sys/ofed/include/linux/io-mapping.h
    trunk/sys/ofed/include/linux/io.h
    trunk/sys/ofed/include/linux/ioctl.h
    trunk/sys/ofed/include/linux/jhash.h
    trunk/sys/ofed/include/linux/jiffies.h
    trunk/sys/ofed/include/linux/kdev_t.h
    trunk/sys/ofed/include/linux/kernel.h
    trunk/sys/ofed/include/linux/kmod.h
    trunk/sys/ofed/include/linux/kobject.h
    trunk/sys/ofed/include/linux/kref.h
    trunk/sys/ofed/include/linux/kthread.h
    trunk/sys/ofed/include/linux/ktime.h
    trunk/sys/ofed/include/linux/linux_compat.c
    trunk/sys/ofed/include/linux/linux_idr.c
    trunk/sys/ofed/include/linux/linux_radix.c
    trunk/sys/ofed/include/linux/list.h
    trunk/sys/ofed/include/linux/lockdep.h
    trunk/sys/ofed/include/linux/log2.h
    trunk/sys/ofed/include/linux/math64.h
    trunk/sys/ofed/include/linux/miscdevice.h
    trunk/sys/ofed/include/linux/mlx4/cmd.h
    trunk/sys/ofed/include/linux/mlx4/cq.h
    trunk/sys/ofed/include/linux/mlx4/device.h
    trunk/sys/ofed/include/linux/mlx4/doorbell.h
    trunk/sys/ofed/include/linux/mlx4/driver.h
    trunk/sys/ofed/include/linux/mlx4/qp.h
    trunk/sys/ofed/include/linux/mlx4/srq.h
    trunk/sys/ofed/include/linux/mm.h
    trunk/sys/ofed/include/linux/module.h
    trunk/sys/ofed/include/linux/moduleparam.h
    trunk/sys/ofed/include/linux/mount.h
    trunk/sys/ofed/include/linux/mutex.h
    trunk/sys/ofed/include/linux/net.h
    trunk/sys/ofed/include/linux/netdevice.h
    trunk/sys/ofed/include/linux/notifier.h
    trunk/sys/ofed/include/linux/page.h
    trunk/sys/ofed/include/linux/pci.h
    trunk/sys/ofed/include/linux/poll.h
    trunk/sys/ofed/include/linux/printk.h
    trunk/sys/ofed/include/linux/radix-tree.h
    trunk/sys/ofed/include/linux/random.h
    trunk/sys/ofed/include/linux/rbtree.h
    trunk/sys/ofed/include/linux/rtnetlink.h
    trunk/sys/ofed/include/linux/rwlock.h
    trunk/sys/ofed/include/linux/rwsem.h
    trunk/sys/ofed/include/linux/scatterlist.h
    trunk/sys/ofed/include/linux/sched.h
    trunk/sys/ofed/include/linux/semaphore.h
    trunk/sys/ofed/include/linux/slab.h
    trunk/sys/ofed/include/linux/socket.h
    trunk/sys/ofed/include/linux/spinlock.h
    trunk/sys/ofed/include/linux/stddef.h
    trunk/sys/ofed/include/linux/string.h
    trunk/sys/ofed/include/linux/sysfs.h
    trunk/sys/ofed/include/linux/timer.h
    trunk/sys/ofed/include/linux/types.h
    trunk/sys/ofed/include/linux/uaccess.h
    trunk/sys/ofed/include/linux/vmalloc.h
    trunk/sys/ofed/include/linux/wait.h
    trunk/sys/ofed/include/linux/workqueue.h
    trunk/sys/ofed/include/net/addrconf.h
    trunk/sys/ofed/include/net/arp.h
    trunk/sys/ofed/include/net/if_inet6.h
    trunk/sys/ofed/include/net/ip.h
    trunk/sys/ofed/include/net/ip6_route.h
    trunk/sys/ofed/include/net/ipv6.h
    trunk/sys/ofed/include/net/neighbour.h
    trunk/sys/ofed/include/net/netevent.h
    trunk/sys/ofed/include/net/tcp.h
    trunk/sys/ofed/include/rdma/ib_addr.h
    trunk/sys/ofed/include/rdma/ib_cache.h
    trunk/sys/ofed/include/rdma/ib_cm.h
    trunk/sys/ofed/include/rdma/ib_fmr_pool.h
    trunk/sys/ofed/include/rdma/ib_mad.h
    trunk/sys/ofed/include/rdma/ib_marshall.h
    trunk/sys/ofed/include/rdma/ib_pack.h
    trunk/sys/ofed/include/rdma/ib_pma.h
    trunk/sys/ofed/include/rdma/ib_sa.h
    trunk/sys/ofed/include/rdma/ib_smi.h
    trunk/sys/ofed/include/rdma/ib_umem.h
    trunk/sys/ofed/include/rdma/ib_user_cm.h
    trunk/sys/ofed/include/rdma/ib_user_mad.h
    trunk/sys/ofed/include/rdma/ib_user_sa.h
    trunk/sys/ofed/include/rdma/ib_user_verbs.h
    trunk/sys/ofed/include/rdma/ib_verbs.h
    trunk/sys/ofed/include/rdma/iw_cm.h
    trunk/sys/ofed/include/rdma/rdma_cm.h
    trunk/sys/ofed/include/rdma/rdma_cm_ib.h
    trunk/sys/ofed/include/rdma/rdma_user_cm.h
    trunk/sys/ofed/include/rdma/sdp_socket.h

Added Paths:
-----------
    trunk/sys/ofed/include/linux/srcu.h

Property Changed:
----------------
    trunk/sys/ofed/drivers/infiniband/Kconfig
    trunk/sys/ofed/drivers/infiniband/hw/mlx4/Kconfig
    trunk/sys/ofed/drivers/infiniband/hw/mthca/Kconfig
    trunk/sys/ofed/drivers/infiniband/ulp/ipoib/Kconfig
    trunk/sys/ofed/drivers/infiniband/ulp/sdp/Kconfig
    trunk/sys/ofed/drivers/infiniband/util/Kconfig
    trunk/sys/ofed/include/rdma/Kbuild

Index: trunk/sys/ofed/drivers/infiniband/Kconfig
===================================================================
--- trunk/sys/ofed/drivers/infiniband/Kconfig	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/Kconfig	2018-05-25 13:01:20 UTC (rev 9919)

Property changes on: trunk/sys/ofed/drivers/infiniband/Kconfig
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/ofed/drivers/infiniband/Makefile
===================================================================
--- trunk/sys/ofed/drivers/infiniband/Makefile	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/Makefile	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+# $MidnightBSD$
 obj-$(CONFIG_INFINIBAND)		+= core/
 obj-$(CONFIG_INFINIBAND_MTHCA)		+= hw/mthca/
 obj-$(CONFIG_INFINIBAND_IPATH)		+= hw/ipath/

Modified: trunk/sys/ofed/drivers/infiniband/core/Makefile
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/Makefile	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/Makefile	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+# $MidnightBSD$
 infiniband-$(CONFIG_INFINIBAND_ADDR_TRANS)	:= ib_addr.o rdma_cm.o
 user_access-$(CONFIG_INFINIBAND_ADDR_TRANS)	:= rdma_ucm.o
 

Modified: trunk/sys/ofed/drivers/infiniband/core/addr.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/addr.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/addr.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Voltaire Inc.  All rights reserved.
  * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
@@ -43,6 +44,8 @@
 #include <net/netevent.h>
 #include <rdma/ib_addr.h>
 #include <netinet/if_ether.h>
+#include <netinet/toecore.h>
+#include <netinet6/scope6_var.h>
 
 
 MODULE_AUTHOR("Sean Hefty");
@@ -89,19 +92,6 @@
 }
 EXPORT_SYMBOL(rdma_addr_unregister_client);
 
-#ifdef __linux__
-int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
-		     const unsigned char *dst_dev_addr)
-{
-	dev_addr->dev_type = dev->type;
-	memcpy(dev_addr->src_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
-	memcpy(dev_addr->broadcast, dev->broadcast, MAX_ADDR_LEN);
-	if (dst_dev_addr)
-		memcpy(dev_addr->dst_dev_addr, dst_dev_addr, MAX_ADDR_LEN);
-	dev_addr->bound_dev_if = dev->ifindex;
-	return 0;
-}
-#else
 int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct ifnet *dev,
 		     const unsigned char *dst_dev_addr)
 {
@@ -119,7 +109,6 @@
 	dev_addr->bound_dev_if = dev->if_index;
 	return 0;
 }
-#endif
 EXPORT_SYMBOL(rdma_copy_addr);
 
 int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
@@ -139,7 +128,7 @@
 	switch (addr->sa_family) {
 #ifdef INET
 	case AF_INET:
-		dev = ip_dev_find(NULL,
+		dev = ip_dev_find(&init_net,
 			((struct sockaddr_in *) addr)->sin_addr.s_addr);
 
 		if (!dev)
@@ -152,39 +141,18 @@
 
 #if defined(INET6)
 	case AF_INET6:
-#ifdef __linux__
-		read_lock(&dev_base_lock);
-		for_each_netdev(&init_net, dev) {
-			if (ipv6_chk_addr(&init_net,
-					  &((struct sockaddr_in6 *) addr)->sin6_addr,
-					  dev, 1)) {
-				ret = rdma_copy_addr(dev_addr, dev, NULL);
-				break;
-			}
-		}
-		read_unlock(&dev_base_lock);
-#else
-		{
-			struct sockaddr_in6 *sin6;
-			struct ifaddr *ifa;
-			in_port_t port;
+		dev = ip6_dev_find(&init_net,
+			((const struct sockaddr_in6 *)addr)->sin6_addr);
 
-			sin6 = (struct sockaddr_in6 *)addr;
-			port = sin6->sin6_port;
-			sin6->sin6_port = 0;
-			ifa = ifa_ifwithaddr(addr);
-			sin6->sin6_port = port;
-			if (ifa == NULL) {
-				ret = -ENODEV;
-				break;
-			}
-			ret = rdma_copy_addr(dev_addr, ifa->ifa_ifp, NULL);
-			ifa_free(ifa);
-			break;
-		}
+		if (!dev)
+			return ret;
+
+		ret = rdma_copy_addr(dev_addr, dev, NULL);
+		dev_put(dev);
+		break;
 #endif
+	default:
 		break;
-#endif
 	}
 	return ret;
 }
@@ -192,10 +160,10 @@
 
 static void set_timeout(unsigned long time)
 {
-	unsigned long delay;
+	int delay;	/* under FreeBSD ticks are 32-bit */
 
 	delay = time - jiffies;
-	if ((long)delay <= 0)
+	if (delay <= 0)
 		delay = 1;
 
 	mod_delayed_work(addr_wq, &work, delay);
@@ -218,127 +186,6 @@
 	mutex_unlock(&lock);
 }
 
-#ifdef __linux__
-static int addr4_resolve(struct sockaddr_in *src_in,
-			 struct sockaddr_in *dst_in,
-			 struct rdma_dev_addr *addr)
-{
-	__be32 src_ip = src_in->sin_addr.s_addr;
-	__be32 dst_ip = dst_in->sin_addr.s_addr;
-	struct flowi fl;
-	struct rtable *rt;
-	struct neighbour *neigh;
-	int ret;
-
-	memset(&fl, 0, sizeof fl);
-	fl.nl_u.ip4_u.daddr = dst_ip;
-	fl.nl_u.ip4_u.saddr = src_ip;
-	fl.oif = addr->bound_dev_if;
-
-	ret = ip_route_output_key(&init_net, &rt, &fl);
-	if (ret)
-		goto out;
-
-	src_in->sin_family = AF_INET;
-	src_in->sin_addr.s_addr = rt->rt_src;
-
-	if (rt->idev->dev->flags & IFF_LOOPBACK) {
-		ret = rdma_translate_ip((struct sockaddr *) dst_in, addr);
-		if (!ret)
-			memcpy(addr->dst_dev_addr, addr->src_dev_addr, MAX_ADDR_LEN);
-		goto put;
-	}
-
-	/* If the device does ARP internally, return 'done' */
-	if (rt->idev->dev->flags & IFF_NOARP) {
-		rdma_copy_addr(addr, rt->idev->dev, NULL);
-		goto put;
-	}
-
-	neigh = neigh_lookup(&arp_tbl, &rt->rt_gateway, rt->idev->dev);
-	if (!neigh || !(neigh->nud_state & NUD_VALID)) {
-		neigh_event_send(rt->u.dst.neighbour, NULL);
-		ret = -ENODATA;
-		if (neigh)
-			goto release;
-		goto put;
-	}
-
-	ret = rdma_copy_addr(addr, neigh->dev, neigh->ha);
-release:
-	neigh_release(neigh);
-put:
-	ip_rt_put(rt);
-out:
-	return ret;
-}
-
-#if defined(INET6)
-static int addr6_resolve(struct sockaddr_in6 *src_in,
-			 struct sockaddr_in6 *dst_in,
-			 struct rdma_dev_addr *addr)
-{
-	struct flowi fl;
-	struct neighbour *neigh;
-	struct dst_entry *dst;
-	int ret;
-
-	memset(&fl, 0, sizeof fl);
-	ipv6_addr_copy(&fl.fl6_dst, &dst_in->sin6_addr);
-	ipv6_addr_copy(&fl.fl6_src, &src_in->sin6_addr);
-	fl.oif = addr->bound_dev_if;
-
-	dst = ip6_route_output(&init_net, NULL, &fl);
-	if ((ret = dst->error))
-		goto put;
-
-	if (ipv6_addr_any(&fl.fl6_src)) {
-		ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
-					 &fl.fl6_dst, 0, &fl.fl6_src);
-		if (ret)
-			goto put;
-
-		src_in->sin6_family = AF_INET6;
-		ipv6_addr_copy(&src_in->sin6_addr, &fl.fl6_src);
-	}
-
-	if (dst->dev->flags & IFF_LOOPBACK) {
-		ret = rdma_translate_ip((struct sockaddr *) dst_in, addr);
-		if (!ret)
-			memcpy(addr->dst_dev_addr, addr->src_dev_addr, MAX_ADDR_LEN);
-		goto put;
-	}
-
-	/* If the device does ARP internally, return 'done' */
-	if (dst->dev->flags & IFF_NOARP) {
-		ret = rdma_copy_addr(addr, dst->dev, NULL);
-		goto put;
-	}
-	
-	neigh = dst->neighbour;
-	if (!neigh || !(neigh->nud_state & NUD_VALID)) {
-		neigh_event_send(dst->neighbour, NULL);
-		ret = -ENODATA;
-		goto put;
-	}
-
-	ret = rdma_copy_addr(addr, dst->dev, neigh->ha);
-put:
-	dst_release(dst);
-	return ret;
-}
-#else
-static int addr6_resolve(struct sockaddr_in6 *src_in,
-			 struct sockaddr_in6 *dst_in,
-			 struct rdma_dev_addr *addr)
-{
-	return -EADDRNOTAVAIL;
-}
-#endif
-
-#else
-#include <netinet/if_ether.h>
-
 static int addr_resolve(struct sockaddr *src_in,
 			struct sockaddr *dst_in,
 			struct rdma_dev_addr *addr)
@@ -347,16 +194,22 @@
 	struct sockaddr_in6 *sin6;
 	struct ifaddr *ifa;
 	struct ifnet *ifp;
-#if defined(INET) || defined(INET6)
+	struct rtentry *rte;
+#if defined(INET)
 	struct llentry *lle;
 #endif
-	struct rtentry *rte;
-	in_port_t port;
+#if defined(INET6)
+	struct sockaddr_in6 dstv6_tmp;
+	uint16_t vlan_id;
+#endif
 	u_char edst[MAX_ADDR_LEN];
 	int multi;
 	int bcast;
+	int is_gw = 0;
 	int error = 0;
 
+	CURVNET_SET_QUIET(&init_net);
+
 	/*
 	 * Determine whether the address is unicast, multicast, or broadcast
 	 * and whether the source interface is valid.
@@ -367,6 +220,9 @@
 	sin6 = NULL;
 	ifp = NULL;
 	rte = NULL;
+	ifa = NULL;
+	memset(edst, 0, sizeof(edst));
+
 	switch (dst_in->sa_family) {
 #ifdef INET
 	case AF_INET:
@@ -377,59 +233,63 @@
 			multi = 1;
 		sin = (struct sockaddr_in *)src_in;
 		if (sin->sin_addr.s_addr != INADDR_ANY) {
-			/*
-			 * Address comparison fails if the port is set
-			 * cache it here to be restored later.
-			 */
-			port = sin->sin_port;
-			sin->sin_port = 0;
-			memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
-		} else
-			src_in = NULL; 
+			ifp = ip_dev_find(&init_net, sin->sin_addr.s_addr);
+			if (ifp == NULL) {
+				error = ENETUNREACH;
+				goto done;
+			}
+			if (bcast || multi)
+				goto mcast;
+		}
 		break;
 #endif
 #ifdef INET6
 	case AF_INET6:
+		/* Make destination socket address writeable */
+		dstv6_tmp = *(struct sockaddr_in6 *)dst_in;
+		dst_in = (struct sockaddr *)&dstv6_tmp;
 		sin6 = (struct sockaddr_in6 *)dst_in;
 		if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
 			multi = 1;
+		/*
+		 * Make sure the scope ID gets embedded, else rtalloc1() will
+		 * resolve to the loopback interface.
+		 */
+		sin6->sin6_scope_id = addr->bound_dev_if;
+		sa6_embedscope(sin6, 0);
+
 		sin6 = (struct sockaddr_in6 *)src_in;
 		if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
-			port = sin6->sin6_port;
-			sin6->sin6_port = 0;
-		} else
-			src_in = NULL;
+			ifp = ip6_dev_find(&init_net, sin6->sin6_addr);
+			if (ifp == NULL) {
+				error = ENETUNREACH;
+				goto done;
+			}
+			if (bcast || multi)
+				goto mcast;
+		}
 		break;
 #endif
 	default:
-		return -EINVAL;
+		error = EINVAL;
+		goto done;
 	}
 	/*
-	 * If we have a source address to use look it up first and verify
-	 * that it is a local interface.
-	 */
-	if (src_in) {
-		ifa = ifa_ifwithaddr(src_in);
-		if (sin)
-			sin->sin_port = port;
-		if (sin6)
-			sin6->sin6_port = port;
-		if (ifa == NULL)
-			return -ENETUNREACH;
-		ifp = ifa->ifa_ifp;
-		ifa_free(ifa);
-		if (bcast || multi)
-			goto mcast;
-	}
-	/*
 	 * Make sure the route exists and has a valid link.
 	 */
 	rte = rtalloc1(dst_in, 1, 0);
-	if (rte == NULL || rte->rt_ifp == NULL || !RT_LINK_IS_UP(rte->rt_ifp)) {
-		if (rte) 
+	if (rte == NULL || rte->rt_ifp == NULL ||
+	    RT_LINK_IS_UP(rte->rt_ifp) == 0 ||
+	    rte->rt_ifp == V_loif) {
+		if (rte != NULL) {
 			RTFREE_LOCKED(rte);
-		return -EHOSTUNREACH;
+			rte = NULL;
+		}
+		error = EHOSTUNREACH;
+		goto done;
 	}
+	if (rte->rt_flags & RTF_GATEWAY)
+		is_gw = 1;
 	/*
 	 * If it's not multicast or broadcast and the route doesn't match the
 	 * requested interface return unreachable.  Otherwise fetch the
@@ -436,30 +296,55 @@
 	 * correct interface pointer and unlock the route.
 	 */
 	if (multi || bcast) {
-		if (ifp == NULL)
+		/* rt_ifa holds the route answer source address */
+		ifa = rte->rt_ifa;
+
+		if (ifp == NULL) {
 			ifp = rte->rt_ifp;
+			dev_hold(ifp);
+		}
 		RTFREE_LOCKED(rte);
-	} else if (ifp && ifp != rte->rt_ifp) {
+		rte = NULL;
+	} else if (ifp != NULL && ifp != rte->rt_ifp) {
 		RTFREE_LOCKED(rte);
-		return -ENETUNREACH;
+		rte = NULL;
+		error = ENETUNREACH;
+		goto done;
 	} else {
-		if (ifp == NULL)
+		/* rt_ifa holds the route answer source address */
+		ifa = rte->rt_ifa;
+
+		if (ifp == NULL) {
 			ifp = rte->rt_ifp;
+			dev_hold(ifp);
+		}
 		RT_UNLOCK(rte);
 	}
+#if defined(INET) || defined(INET6)
 mcast:
-	if (bcast)
-		return rdma_copy_addr(addr, ifp, ifp->if_broadcastaddr);
-	if (multi) {
-		struct sockaddr *llsa;
+#endif
+	if (bcast) {
+		memcpy(edst, ifp->if_broadcastaddr, ifp->if_addrlen);
+		goto done;
+	} else if (multi) {
+		struct sockaddr *llsa = NULL;
 
+		if (ifp->if_resolvemulti == NULL) {
+			error = EOPNOTSUPP;
+			goto done;
+		}
 		error = ifp->if_resolvemulti(ifp, &llsa, dst_in);
-		if (error)
-			return -error;
-		error = rdma_copy_addr(addr, ifp,
-		    LLADDR((struct sockaddr_dl *)llsa));
-		free(llsa, M_IFMADDR);
-		return error;
+		if (error == 0) {
+			if (llsa == NULL) {
+				error = EAFNOSUPPORT;
+				goto done;
+			} else {
+				memcpy(edst, LLADDR((struct sockaddr_dl *)llsa),
+				    ifp->if_addrlen);
+				free(llsa, M_IFMADDR);
+			}
+		}
+		goto done;
 	}
 	/*
 	 * Resolve the link local address.
@@ -467,28 +352,35 @@
 	switch (dst_in->sa_family) {
 #ifdef INET
 	case AF_INET:
-		error = arpresolve(ifp, rte, NULL, dst_in, edst, &lle);
+		error = arpresolve(ifp, rte, NULL, is_gw ? rte->rt_gateway : dst_in, edst, &lle);
 		break;
 #endif
 #ifdef INET6
 	case AF_INET6:
-		error = nd6_storelladdr(ifp, NULL, dst_in, (u_char *)edst, &lle);
+		error = toe_l2_resolve(NULL, ifp, is_gw ? rte->rt_gateway : dst_in, edst, &vlan_id);
 		break;
 #endif
 	default:
-		/* XXX: Shouldn't happen. */
-		error = -EINVAL;
+		KASSERT(0, ("rdma_addr_resolve: Unreachable"));
+		error = EINVAL;
+		break;
 	}
-	RTFREE(rte);
+done:
 	if (error == 0)
-		return rdma_copy_addr(addr, ifp, edst);
+		error = -rdma_copy_addr(addr, ifp, edst);
+	if (error == 0)
+		memcpy(src_in, ifa->ifa_addr, ip_addr_size(ifa->ifa_addr));
 	if (error == EWOULDBLOCK)
-		return -ENODATA;
+		error = ENODATA;
+	if (rte != NULL)
+		RTFREE(rte);
+	if (ifp != NULL)
+		dev_put(ifp);
+
+	CURVNET_RESTORE();
 	return -error;
 }
 
-#endif
-
 static void process_req(struct work_struct *work)
 {
 	struct addr_req *req, *temp_req;
@@ -602,27 +494,6 @@
 }
 EXPORT_SYMBOL(rdma_addr_cancel);
 
-static int netevent_callback(struct notifier_block *self, unsigned long event,
-	void *ctx)
-{
-	if (event == NETEVENT_NEIGH_UPDATE) {
-#ifdef __linux__
-		struct neighbour *neigh = ctx;
-
-		if (neigh->nud_state & NUD_VALID) {
-			set_timeout(jiffies);
-		}
-#else
-		set_timeout(jiffies);
-#endif
-	}
-	return 0;
-}
-
-static struct notifier_block nb = {
-	.notifier_call = netevent_callback
-};
-
 static int __init addr_init(void)
 {
 	INIT_DELAYED_WORK(&work, process_req);
@@ -630,13 +501,11 @@
 	if (!addr_wq)
 		return -ENOMEM;
 
-	register_netevent_notifier(&nb);
 	return 0;
 }
 
 static void __exit addr_cleanup(void)
 {
-	unregister_netevent_notifier(&nb);
 	destroy_workqueue(addr_wq);
 }
 

Modified: trunk/sys/ofed/drivers/infiniband/core/agent.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/agent.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/agent.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Mellanox Technologies Ltd.  All rights reserved.
  * Copyright (c) 2004, 2005 Infinicon Corporation.  All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/agent.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/agent.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/agent.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Mellanox Technologies Ltd.  All rights reserved.
  * Copyright (c) 2004 Infinicon Corporation.  All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/cache.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/cache.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/cache.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Intel Corporation. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/cm.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/cm.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/cm.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004-2007 Intel Corporation.  All rights reserved.
  * Copyright (c) 2004 Topspin Corporation.  All rights reserved.
@@ -870,6 +871,7 @@
 		cm_reject_sidr_req(cm_id_priv, IB_SIDR_REJECT);
 		break;
 	case IB_CM_REQ_SENT:
+	case IB_CM_MRA_REQ_RCVD:
 		ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
 		spin_unlock_irq(&cm_id_priv->lock);
 		ib_send_cm_rej(cm_id, IB_CM_REJ_TIMEOUT,
@@ -888,7 +890,6 @@
 				       NULL, 0, NULL, 0);
 		}
 		break;
-	case IB_CM_MRA_REQ_RCVD:
 	case IB_CM_REP_SENT:
 	case IB_CM_MRA_REP_RCVD:
 		ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);

Modified: trunk/sys/ofed/drivers/infiniband/core/cm_msgs.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/cm_msgs.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/cm_msgs.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Intel Corporation.  All rights reserved.
  * Copyright (c) 2004 Topspin Corporation.  All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/cma.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/cma.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/cma.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,8 +1,10 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Voltaire Inc.  All rights reserved.
  * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
  * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved.
  * Copyright (c) 2005-2006 Intel Corporation.  All rights reserved.
+ * Copyright (c) 2016 Chelsio Communications.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -33,6 +35,8 @@
  * SOFTWARE.
  */
 
+#define	LINUXKPI_PARAM_PREFIX ibcore_
+
 #include <linux/completion.h>
 #include <linux/in.h>
 #include <linux/in6.h>
@@ -44,6 +48,9 @@
 #include <net/tcp.h>
 #include <net/ipv6.h>
 
+#include <netinet6/scope6_var.h>
+#include <netinet6/ip6_var.h>
+
 #include <rdma/rdma_cm.h>
 #include <rdma/rdma_cm_ib.h>
 #include <rdma/ib_cache.h>
@@ -59,11 +66,6 @@
 module_param_named(tavor_quirk, tavor_quirk, int, 0644);
 MODULE_PARM_DESC(tavor_quirk, "Tavor performance quirk: limit MTU to 1K if > 0");
 
-int unify_tcp_port_space = 1;
-module_param(unify_tcp_port_space, int, 0644);
-MODULE_PARM_DESC(unify_tcp_port_space, "Unify the host TCP and RDMA port "
-		 "space allocation (default=1)");
-
 #define CMA_CM_RESPONSE_TIMEOUT 20
 #define CMA_MAX_CM_RETRIES 15
 #define CMA_CM_MRA_SETTING (IB_CM_MRA_FLAG_DELAY | 24)
@@ -168,6 +170,7 @@
 	u32			qp_num;
 	u8			srq;
 	u8			tos;
+	int unify_ps_tcp;
 };
 
 struct cma_multicast {
@@ -361,6 +364,97 @@
 	return ret;
 }
 
+static int find_gid_port(struct ib_device *device, union ib_gid *gid, u8 port_num)
+{
+	int i;
+	int err;
+	struct ib_port_attr props;
+	union ib_gid tmp;
+
+	err = ib_query_port(device, port_num, &props);
+	if (err)
+		return 1;
+
+	for (i = 0; i < props.gid_tbl_len; ++i) {
+		err = ib_query_gid(device, port_num, i, &tmp);
+		if (err)
+			return 1;
+		if (!memcmp(&tmp, gid, sizeof tmp))
+			return 0;
+	}
+
+	return -EAGAIN;
+}
+
+int
+rdma_find_cmid_laddr(struct sockaddr_in *local_addr, unsigned short dev_type,
+							void **cm_id)
+{
+	int ret;
+	u8 port;
+	int found_dev = 0, found_cmid = 0;
+	struct rdma_id_private  *id_priv;
+	struct rdma_id_private  *dev_id_priv;
+	struct cma_device	*cma_dev;
+	struct rdma_dev_addr	dev_addr;
+	union ib_gid		gid;
+	enum rdma_link_layer dev_ll = dev_type == ARPHRD_INFINIBAND ?
+		IB_LINK_LAYER_INFINIBAND : IB_LINK_LAYER_ETHERNET;
+
+	memset(&dev_addr, 0, sizeof(dev_addr));
+
+	ret = rdma_translate_ip((struct sockaddr *)local_addr,
+							&dev_addr);
+	if (ret)
+		goto err;
+
+	/* find rdma device based on MAC address/gid */
+	mutex_lock(&lock);
+
+	memcpy(&gid, dev_addr.src_dev_addr +
+	       rdma_addr_gid_offset(&dev_addr), sizeof(gid));
+
+	list_for_each_entry(cma_dev, &dev_list, list)
+		for (port = 1; port <= cma_dev->device->phys_port_cnt; ++port)
+			if ((rdma_port_get_link_layer(cma_dev->device, port) ==
+								 dev_ll) &&
+			 (rdma_node_get_transport(cma_dev->device->node_type) ==
+							RDMA_TRANSPORT_IWARP)) {
+					ret = find_gid_port(cma_dev->device,
+								&gid, port);
+					if (!ret) {
+						found_dev = 1;
+						goto out;
+					} else if (ret == 1) {
+						mutex_unlock(&lock);
+						goto err;
+					}
+			}
+out:
+	mutex_unlock(&lock);
+
+	if (!found_dev)
+		goto err;
+
+	/* Traverse through the list of listening cm_id's to find the
+	 * desired cm_id based on rdma device & port number.
+	 */
+	list_for_each_entry(id_priv, &listen_any_list, list)
+		list_for_each_entry(dev_id_priv, &id_priv->listen_list,
+						 listen_list)
+			if (dev_id_priv->cma_dev == cma_dev)
+				if (dev_id_priv->cm_id.iw->local_addr.sin_port
+						== local_addr->sin_port) {
+					*cm_id = (void *)dev_id_priv->cm_id.iw;
+					found_cmid = 1;
+				}
+	return found_cmid ? 0 : -ENODEV;
+
+err:
+	return -ENODEV;
+}
+EXPORT_SYMBOL(rdma_find_cmid_laddr);
+
 static int cma_acquire_dev(struct rdma_id_private *id_priv)
 {
 	struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
@@ -645,17 +739,16 @@
 	int ret = 0;
 
 	id_priv = container_of(id, struct rdma_id_private, id);
-	switch (rdma_node_get_transport(id_priv->id.device->node_type)) {
-	case RDMA_TRANSPORT_IB:
+	if (rdma_cap_ib_cm(id->device, id->port_num)) {
 		if (!id_priv->cm_id.ib || cma_is_ud_ps(id_priv->id.ps))
 			ret = cma_ib_init_qp_attr(id_priv, qp_attr, qp_attr_mask);
 		else
 			ret = ib_cm_init_qp_attr(id_priv->cm_id.ib, qp_attr,
 						 qp_attr_mask);
+
 		if (qp_attr->qp_state == IB_QPS_RTR)
 			qp_attr->rq_psn = id_priv->seq_num;
-		break;
-	case RDMA_TRANSPORT_IWARP:
+	} else if (rdma_cap_iw_cm(id->device, id->port_num)) {
 		if (!id_priv->cm_id.iw) {
 			qp_attr->qp_access_flags = 0;
 			*qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS;
@@ -662,11 +755,8 @@
 		} else
 			ret = iw_cm_init_qp_attr(id_priv->cm_id.iw, qp_attr,
 						 qp_attr_mask);
-		break;
-	default:
+	} else
 		ret = -ENOSYS;
-		break;
-	}
 
 	return ret;
 }
@@ -700,6 +790,12 @@
 {
 	return cma_zero_addr(addr) || cma_loopback_addr(addr);
 }
+int
+rdma_cma_any_addr(struct sockaddr *addr)
+{
+	return cma_any_addr(addr);
+}
+EXPORT_SYMBOL(rdma_cma_any_addr);
 
 static inline __be16 cma_port(struct sockaddr *addr)
 {
@@ -745,6 +841,17 @@
 	return 0;
 }
 
+static void cma_ip6_clear_scope_id(struct in6_addr *addr)
+{
+	/* make sure link local scope ID gets zeroed */
+	if (IN6_IS_SCOPE_LINKLOCAL(addr) ||
+	    IN6_IS_ADDR_MC_INTFACELOCAL(addr)) {
+		/* use byte-access to be alignment safe */
+		addr->s6_addr[2] = 0;
+		addr->s6_addr[3] = 0;
+	}
+}
+
 static void cma_save_net_info(struct rdma_addr *addr,
 			      struct rdma_addr *listen_addr,
 			      u8 ip_ver, __be16 port,
@@ -760,11 +867,15 @@
 		ip4->sin_family = listen4->sin_family;
 		ip4->sin_addr.s_addr = dst->ip4.addr;
 		ip4->sin_port = listen4->sin_port;
+		ip4->sin_len = sizeof(struct sockaddr_in);
+		memset(ip4->sin_zero, 0, sizeof(ip4->sin_zero));
 
 		ip4 = (struct sockaddr_in *) &addr->dst_addr;
 		ip4->sin_family = listen4->sin_family;
 		ip4->sin_addr.s_addr = src->ip4.addr;
 		ip4->sin_port = port;
+		ip4->sin_len = sizeof(struct sockaddr_in);
+		memset(ip4->sin_zero, 0, sizeof(ip4->sin_zero));
 		break;
 	case 6:
 		listen6 = (struct sockaddr_in6 *) &listen_addr->src_addr;
@@ -772,11 +883,17 @@
 		ip6->sin6_family = listen6->sin6_family;
 		ip6->sin6_addr = dst->ip6;
 		ip6->sin6_port = listen6->sin6_port;
+		ip6->sin6_len = sizeof(struct sockaddr_in6);
+		ip6->sin6_scope_id = listen6->sin6_scope_id;
+		cma_ip6_clear_scope_id(&ip6->sin6_addr);
 
 		ip6 = (struct sockaddr_in6 *) &addr->dst_addr;
 		ip6->sin6_family = listen6->sin6_family;
 		ip6->sin6_addr = src->ip6;
 		ip6->sin6_port = port;
+		ip6->sin6_len = sizeof(struct sockaddr_in6);
+		ip6->sin6_scope_id = listen6->sin6_scope_id;
+		cma_ip6_clear_scope_id(&ip6->sin6_addr);
 		break;
 	default:
 		break;
@@ -864,8 +981,6 @@
 		kfree(bind_list);
 	}
 	mutex_unlock(&lock);
-	if (id_priv->sock)
-		sock_release(id_priv->sock);
 }
 
 static void cma_leave_mc_groups(struct rdma_id_private *id_priv)
@@ -902,17 +1017,12 @@
 	mutex_lock(&lock);
 	if (id_priv->cma_dev) {
 		mutex_unlock(&lock);
-		switch (rdma_node_get_transport(id_priv->id.device->node_type)) {
-		case RDMA_TRANSPORT_IB:
+		if (rdma_cap_ib_cm(id_priv->id.device, 1)) {
 			if (id_priv->cm_id.ib && !IS_ERR(id_priv->cm_id.ib))
 				ib_destroy_cm_id(id_priv->cm_id.ib);
-			break;
-		case RDMA_TRANSPORT_IWARP:
+		} else if (rdma_cap_iw_cm(id_priv->id.device, 1)) {
 			if (id_priv->cm_id.iw && !IS_ERR(id_priv->cm_id.iw))
 				iw_destroy_cm_id(id_priv->cm_id.iw);
-			break;
-		default:
-			break;
 		}
 		cma_leave_mc_groups(id_priv);
 		mutex_lock(&lock);
@@ -927,6 +1037,10 @@
 	if (id_priv->internal_id)
 		cma_deref_id(id_priv->id.context);
 
+	if (id_priv->sock != NULL && !id_priv->internal_id &&
+	    !id_priv->unify_ps_tcp)
+		sock_release(id_priv->sock);
+
 	kfree(id_priv->id.route.path_rec);
 	kfree(id_priv);
 }
@@ -1272,6 +1386,7 @@
 #ifdef INET6
 	case AF_INET6:
 		ip6_addr = ((struct sockaddr_in6 *) addr)->sin6_addr;
+		cma_ip6_clear_scope_id(&ip6_addr);
 		if (ps == RDMA_PS_SDP) {
 			sdp_set_ip_ver(sdp_data, 6);
 			sdp_set_ip_ver(sdp_mask, 0xF);
@@ -1521,6 +1636,7 @@
 	dev_id_priv = container_of(id, struct rdma_id_private, id);
 
 	dev_id_priv->state = CMA_ADDR_BOUND;
+	dev_id_priv->sock = id_priv->sock;
 	memcpy(&id->route.addr.src_addr, &id_priv->id.route.addr.src_addr,
 	       ip_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr));
 
@@ -1564,18 +1680,15 @@
 
 	id_priv->backlog = backlog;
 	if (id->device) {
-		switch (rdma_node_get_transport(id->device->node_type)) {
-		case RDMA_TRANSPORT_IB:
+		if (rdma_cap_ib_cm(id->device, 1)) {
 			ret = cma_ib_listen(id_priv);
 			if (ret)
 				goto err;
-			break;
-		case RDMA_TRANSPORT_IWARP:
+		} else if (rdma_cap_iw_cm(id->device, 1)) {
 			ret = cma_iw_listen(id_priv, backlog);
 			if (ret)
 				goto err;
-			break;
-		default:
+		} else {
 			ret = -ENOSYS;
 			goto err;
 		}
@@ -1880,26 +1993,15 @@
 		return -EINVAL;
 
 	atomic_inc(&id_priv->refcount);
-	switch (rdma_node_get_transport(id->device->node_type)) {
-	case RDMA_TRANSPORT_IB:
-		switch (rdma_port_get_link_layer(id->device, id->port_num)) {
-		case IB_LINK_LAYER_INFINIBAND:
-			ret = cma_resolve_ib_route(id_priv, timeout_ms);
-			break;
-		case IB_LINK_LAYER_ETHERNET:
-			ret = cma_resolve_iboe_route(id_priv);
-			break;
-		default:
-			ret = -ENOSYS;
-		}
-		break;
-	case RDMA_TRANSPORT_IWARP:
+	if (rdma_cap_ib_sa(id->device, id->port_num))
+		ret = cma_resolve_ib_route(id_priv, timeout_ms);
+	else if (rdma_protocol_roce(id->device, id->port_num))
+		ret = cma_resolve_iboe_route(id_priv);
+	else if (rdma_protocol_iwarp(id->device, id->port_num))
 		ret = cma_resolve_iw_route(id_priv, timeout_ms);
-		break;
-	default:
+	else
 		ret = -ENOSYS;
-		break;
-	}
+
 	if (ret)
 		goto err;
 
@@ -2051,20 +2153,52 @@
 {
 	if (!src_addr || !src_addr->sa_family) {
 		src_addr = (struct sockaddr *) &id->route.addr.src_addr;
-		if ((src_addr->sa_family = dst_addr->sa_family) == AF_INET6) {
-			((struct sockaddr_in6 *) src_addr)->sin6_scope_id =
-				((struct sockaddr_in6 *) dst_addr)->sin6_scope_id;
+		src_addr->sa_family = dst_addr->sa_family;
+#ifdef INET6
+		if (dst_addr->sa_family == AF_INET6) {
+			struct sockaddr_in6 *src_addr6 = (struct sockaddr_in6 *) src_addr;
+			struct sockaddr_in6 *dst_addr6 = (struct sockaddr_in6 *) dst_addr;
+			src_addr6->sin6_scope_id = dst_addr6->sin6_scope_id;
+			if (IN6_IS_SCOPE_LINKLOCAL(&dst_addr6->sin6_addr) ||
+			    IN6_IS_ADDR_MC_INTFACELOCAL(&dst_addr6->sin6_addr))
+				id->route.addr.dev_addr.bound_dev_if = dst_addr6->sin6_scope_id;
 		}
+#endif
 	}
 	if (!cma_any_addr(src_addr))
 		return rdma_bind_addr(id, src_addr);
 	else {
-		struct sockaddr_in addr_in;
+#if defined(INET6) || defined(INET)
+		union {
+#ifdef INET
+			struct sockaddr_in in;
+#endif
+#ifdef INET6
+			struct sockaddr_in6 in6;
+#endif
+		} addr;
+#endif
 
-        	memset(&addr_in, 0, sizeof addr_in);
-        	addr_in.sin_family = dst_addr->sa_family;
-        	addr_in.sin_len = sizeof addr_in;
-        	return rdma_bind_addr(id, (struct sockaddr *) &addr_in);
+		switch(dst_addr->sa_family) {
+#ifdef INET
+		case AF_INET:
+			memset(&addr.in, 0, sizeof(addr.in));
+			addr.in.sin_family = dst_addr->sa_family;
+			addr.in.sin_len = sizeof(addr.in);
+			return rdma_bind_addr(id, (struct sockaddr *)&addr.in);
+#endif
+#ifdef INET6
+		case AF_INET6:
+			memset(&addr.in6, 0, sizeof(addr.in6));
+			addr.in6.sin6_family = dst_addr->sa_family;
+			addr.in6.sin6_len = sizeof(addr.in6);
+			addr.in6.sin6_scope_id =
+			    ((struct sockaddr_in6 *)dst_addr)->sin6_scope_id;
+			return rdma_bind_addr(id, (struct sockaddr *)&addr.in6);
+#endif
+		default:
+			return -EINVAL;
+		}
 	}
 }
 
@@ -2240,18 +2374,29 @@
 	int ret;
 	int size;
 	struct socket *sock;
+	struct sockaddr *src_addr = (struct sockaddr *)&id_priv->id.route.addr.src_addr;
 
-	ret = sock_create_kern(AF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
+	switch (src_addr->sa_family) {
+	case AF_INET:
+	case AF_INET6:
+		break;
+	default:
+		/* other address families are not handled by iWarp */
+		id_priv->unify_ps_tcp = 0;
+		return (0);
+	}
+
+	ret = sock_create_kern(src_addr->sa_family, SOCK_STREAM, IPPROTO_TCP, &sock);
 	if (ret)
 		return ret;
 #ifdef __linux__
-	ret = sock->ops->bind(sock,
-			(struct sockaddr *) &id_priv->id.route.addr.src_addr,
-			ip_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr));
+	ret = sock->ops->bind(sock, src_addr, ip_addr_size(src_addr));
 #else
-	ret = -sobind(sock,
-			(struct sockaddr *)&id_priv->id.route.addr.src_addr,
-			curthread);
+	SOCK_LOCK(sock);
+	sock->so_options |= SO_REUSEADDR;
+	SOCK_UNLOCK(sock);
+
+	ret = -sobind(sock, src_addr, curthread);
 #endif
 	if (ret) {
 		sock_release(sock);
@@ -2258,10 +2403,8 @@
 		return ret;
 	}
 
-	size = ip_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr);
-	ret = sock_getname(sock,
-			(struct sockaddr *) &id_priv->id.route.addr.src_addr,
-			&size, 0);
+	size = ip_addr_size(src_addr);
+	ret = sock_getname(sock, src_addr, &size, 0);
 	if (ret) {
 		sock_release(sock);
 		return ret;
@@ -2273,6 +2416,7 @@
 
 static int cma_get_port(struct rdma_id_private *id_priv)
 {
+	struct cma_device *cma_dev;
 	struct idr *ps;
 	int ret;
 
@@ -2282,7 +2426,18 @@
 		break;
 	case RDMA_PS_TCP:
 		ps = &tcp_ps;
-		if (unify_tcp_port_space) {
+
+		mutex_lock(&lock);
+		/* check if there are any iWarp IB devices present */
+		list_for_each_entry(cma_dev, &dev_list, list) {
+			if (rdma_protocol_iwarp(cma_dev->device, 1)) {
+				id_priv->unify_ps_tcp = 1;
+				break;
+			}
+		}
+		mutex_unlock(&lock);
+
+		if (id_priv->unify_ps_tcp) {
 			ret = cma_get_tcp_port(id_priv);
 			if (ret)
 				goto out;
@@ -2311,24 +2466,23 @@
 static int cma_check_linklocal(struct rdma_dev_addr *dev_addr,
 			       struct sockaddr *addr)
 {
-#if defined(INET6)
-	struct sockaddr_in6 *sin6;
+#ifdef INET6
+	struct sockaddr_in6 sin6;
 
 	if (addr->sa_family != AF_INET6)
 		return 0;
 
-	sin6 = (struct sockaddr_in6 *) addr;
-#ifdef __linux__
-	if ((ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) &&
-#else
-	if (IN6_IS_SCOPE_LINKLOCAL(&sin6->sin6_addr) &&
-#endif
-	    !sin6->sin6_scope_id)
+	sin6 = *(struct sockaddr_in6 *)addr;
+
+	if (IN6_IS_SCOPE_LINKLOCAL(&sin6.sin6_addr) ||
+	    IN6_IS_ADDR_MC_INTFACELOCAL(&sin6.sin6_addr)) {
+		/* check if IPv6 scope ID is set */
+		if (sa6_recoverscope(&sin6) || sin6.sin6_scope_id == 0)
 			return -EINVAL;
-
-	dev_addr->bound_dev_if = sin6->sin6_scope_id;
+		dev_addr->bound_dev_if = sin6.sin6_scope_id;
+	}
 #endif
-	return 0;
+	return (0);
 }
 
 int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
@@ -2431,6 +2585,8 @@
 			cma_hdr->src_addr.ip6 = src6->sin6_addr;
 			cma_hdr->dst_addr.ip6 = dst6->sin6_addr;
 			cma_hdr->port = src6->sin6_port;
+			cma_ip6_clear_scope_id(&cma_hdr->src_addr.ip6);
+			cma_ip6_clear_scope_id(&cma_hdr->dst_addr.ip6);
 			break;
 		}
 	}
@@ -2666,20 +2822,15 @@
 		id_priv->srq = conn_param->srq;
 	}
 
-	switch (rdma_node_get_transport(id->device->node_type)) {
-	case RDMA_TRANSPORT_IB:
+	if (rdma_cap_ib_cm(id->device, id->port_num)) {
 		if (cma_is_ud_ps(id->ps))
 			ret = cma_resolve_ib_udp(id_priv, conn_param);
 		else
 			ret = cma_connect_ib(id_priv, conn_param);
-		break;
-	case RDMA_TRANSPORT_IWARP:
+	} else if (rdma_cap_iw_cm(id->device, id->port_num))
 		ret = cma_connect_iw(id_priv, conn_param);
-		break;
-	default:
+	else
 		ret = -ENOSYS;
-		break;
-	}
 	if (ret)
 		goto err;
 
@@ -2779,8 +2930,7 @@
 		id_priv->srq = conn_param->srq;
 	}
 
-	switch (rdma_node_get_transport(id->device->node_type)) {
-	case RDMA_TRANSPORT_IB:
+	if (rdma_cap_ib_cm(id->device, id->port_num)) {
 		if (cma_is_ud_ps(id->ps))
 			ret = cma_send_sidr_rep(id_priv, IB_SIDR_SUCCESS,
 						conn_param->private_data,
@@ -2789,14 +2939,10 @@
 			ret = cma_accept_ib(id_priv, conn_param);
 		else
 			ret = cma_rep_recv(id_priv);
-		break;
-	case RDMA_TRANSPORT_IWARP:
+	} else if (rdma_cap_iw_cm(id->device, id->port_num))
 		ret = cma_accept_iw(id_priv, conn_param);
-		break;
-	default:
+	else
 		ret = -ENOSYS;
-		break;
-	}
 
 	if (ret)
 		goto reject;
@@ -2840,8 +2986,7 @@
 	if (!cma_has_cm_dev(id_priv))
 		return -EINVAL;
 
-	switch (rdma_node_get_transport(id->device->node_type)) {
-	case RDMA_TRANSPORT_IB:
+	if (rdma_cap_ib_cm(id->device, id->port_num)) {
 		if (cma_is_ud_ps(id->ps))
 			ret = cma_send_sidr_rep(id_priv, IB_SIDR_REJECT,
 						private_data, private_data_len);
@@ -2849,15 +2994,12 @@
 			ret = ib_send_cm_rej(id_priv->cm_id.ib,
 					     IB_CM_REJ_CONSUMER_DEFINED, NULL,
 					     0, private_data, private_data_len);
-		break;
-	case RDMA_TRANSPORT_IWARP:
+	} else if (rdma_cap_iw_cm(id->device, id->port_num)) {
 		ret = iw_cm_reject(id_priv->cm_id.iw,
 				   private_data, private_data_len);
-		break;
-	default:
+	} else
 		ret = -ENOSYS;
-		break;
-	}
+
 	return ret;
 }
 EXPORT_SYMBOL(rdma_reject);
@@ -2871,8 +3013,7 @@
 	if (!cma_has_cm_dev(id_priv))
 		return -EINVAL;
 
-	switch (rdma_node_get_transport(id->device->node_type)) {
-	case RDMA_TRANSPORT_IB:
+	if (rdma_cap_ib_cm(id->device, id->port_num)) {
 		ret = cma_modify_qp_err(id_priv);
 		if (ret)
 			goto out;
@@ -2879,14 +3020,11 @@
 		/* Initiate or respond to a disconnect. */
 		if (ib_send_cm_dreq(id_priv->cm_id.ib, NULL, 0))
 			ib_send_cm_drep(id_priv->cm_id.ib, NULL, 0);
-		break;
-	case RDMA_TRANSPORT_IWARP:
+	} else if (rdma_cap_iw_cm(id->device, id->port_num)) {
 		ret = iw_cm_disconnect(id_priv->cm_id.iw, 0);
-		break;
-	default:
+	} else
 		ret = -EINVAL;
-		break;
-	}
+
 out:
 	return ret;
 }
@@ -3213,17 +3351,10 @@
 
 	dev_addr = &id_priv->id.route.addr.dev_addr;
 
-#ifdef __linux__
-	if ((dev_addr->bound_dev_if == ndev->ifindex) &&
-	    memcmp(dev_addr->src_dev_addr, ndev->dev_addr, ndev->addr_len)) {
-		printk(KERN_INFO "RDMA CM addr change for ndev %s used by id %p\n",
-		       ndev->name, &id_priv->id);
-#else
 	if ((dev_addr->bound_dev_if == ndev->if_index) &&
 	    memcmp(dev_addr->src_dev_addr, IF_LLADDR(ndev), ndev->if_addrlen)) {
 		printk(KERN_INFO "RDMA CM addr change for ndev %s used by id %p\n",
 		       ndev->if_xname, &id_priv->id);
-#endif
 		work = kzalloc(sizeof *work, GFP_KERNEL);
 		if (!work)
 			return -ENOMEM;

Modified: trunk/sys/ofed/drivers/infiniband/core/core_priv.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/core_priv.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/core_priv.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/core/device.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/device.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/device.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
@@ -94,7 +95,8 @@
 		IB_MANDATORY_FUNC(poll_cq),
 		IB_MANDATORY_FUNC(req_notify_cq),
 		IB_MANDATORY_FUNC(get_dma_mr),
-		IB_MANDATORY_FUNC(dereg_mr)
+		IB_MANDATORY_FUNC(dereg_mr),
+		IB_MANDATORY_FUNC(get_port_immutable)
 	};
 	int i;
 
@@ -153,13 +155,13 @@
 	return 0;
 }
 
-static int start_port(struct ib_device *device)
+static int rdma_start_port(struct ib_device *device)
 {
 	return (device->node_type == RDMA_NODE_IB_SWITCH) ? 0 : 1;
 }
 
 
-static int end_port(struct ib_device *device)
+static int rdma_end_port(struct ib_device *device)
 {
 	return (device->node_type == RDMA_NODE_IB_SWITCH) ?
 		0 : device->phys_port_cnt;
@@ -192,6 +194,7 @@
 void ib_dealloc_device(struct ib_device *device)
 {
 	if (device->reg_state == IB_DEV_UNINITIALIZED) {
+		kfree(device->port_immutable);
 		kfree(device);
 		return;
 	}
@@ -224,43 +227,42 @@
 	return 0;
 }
 
-static int read_port_table_lengths(struct ib_device *device)
+static int verify_immutable(const struct ib_device *dev, u8 port)
 {
-	struct ib_port_attr *tprops = NULL;
-	int num_ports, ret = -ENOMEM;
-	u8 port_index;
+	return WARN_ON(!rdma_cap_ib_mad(dev, port) &&
+			    rdma_max_mad_size(dev, port) != 0);
+}
 
-	tprops = kmalloc(sizeof *tprops, GFP_KERNEL);
-	if (!tprops)
-		goto out;
+static int read_port_immutable(struct ib_device *device)
+{
+	int ret;
+	u8 start_port = rdma_start_port(device);
+	u8 end_port = rdma_end_port(device);
+	u8 port;
 
-	num_ports = end_port(device) - start_port(device) + 1;
+	/**
+	 * device->port_immutable is indexed directly by the port number to make
+	 * access to this data as efficient as possible.
+	 *
+	 * Therefore port_immutable is declared as a 1 based array with
+	 * potential empty slots at the beginning.
+	 */
+	device->port_immutable = kzalloc(sizeof(*device->port_immutable)
+					 * (end_port + 1),
+					 GFP_KERNEL);
+	if (!device->port_immutable)
+		return -ENOMEM;
 
-	device->pkey_tbl_len = kmalloc(sizeof *device->pkey_tbl_len * num_ports,
-				       GFP_KERNEL);
-	device->gid_tbl_len = kmalloc(sizeof *device->gid_tbl_len * num_ports,
-				      GFP_KERNEL);
-	if (!device->pkey_tbl_len || !device->gid_tbl_len)
-		goto err;
+	for (port = start_port; port <= end_port; ++port) {
+		ret = device->get_port_immutable(device, port,
+						 &device->port_immutable[port]);
+		if (ret)
+			return ret;
 
-	for (port_index = 0; port_index < num_ports; ++port_index) {
-		ret = ib_query_port(device, port_index + start_port(device),
-					tprops);
-		if (ret)
-			goto err;
-		device->pkey_tbl_len[port_index] = tprops->pkey_tbl_len;
-		device->gid_tbl_len[port_index]  = tprops->gid_tbl_len;
+		if (verify_immutable(device, port))
+			return -EINVAL;
 	}
-
-	ret = 0;
-	goto out;
-
-err:
-	kfree(device->gid_tbl_len);
-	kfree(device->pkey_tbl_len);
-out:
-	kfree(tprops);
-	return ret;
+	return 0;
 }
 
 /**
@@ -298,10 +300,11 @@
 	device->ib_uverbs_xrcd_table = RB_ROOT;
 	mutex_init(&device->xrcd_table_mutex);
 
-	ret = read_port_table_lengths(device);
+
+	ret = read_port_immutable(device);
 	if (ret) {
-		printk(KERN_WARNING "Couldn't create table lengths cache for device %s\n",
-		       device->name);
+		printk(KERN_WARNING "Couldn't create per port immutable data %s\n",
+			device->name);
 		goto out;
 	}
 
@@ -309,8 +312,7 @@
 	if (ret) {
 		printk(KERN_WARNING "Couldn't register device %s with driver model\n",
 		       device->name);
-		kfree(device->gid_tbl_len);
-		kfree(device->pkey_tbl_len);
+		kfree(device->port_immutable);
 		goto out;
 	}
 
@@ -352,9 +354,6 @@
 
 	list_del(&device->core_list);
 
-	kfree(device->gid_tbl_len);
-	kfree(device->pkey_tbl_len);
-
 	mutex_unlock(&device_mutex);
 
 	ib_device_unregister_sysfs(device);
@@ -579,7 +578,7 @@
 		  u8 port_num,
 		  struct ib_port_attr *port_attr)
 {
-	if (port_num < start_port(device) || port_num > end_port(device))
+	if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
 		return -EINVAL;
 
 	return device->query_port(device, port_num, port_attr);
@@ -651,7 +650,7 @@
 		   u8 port_num, int port_modify_mask,
 		   struct ib_port_modify *port_modify)
 {
-	if (port_num < start_port(device) || port_num > end_port(device))
+	if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
 		return -EINVAL;
 
 	return device->modify_port(device, port_num, port_modify_mask,
@@ -674,8 +673,8 @@
 	union ib_gid tmp_gid;
 	int ret, port, i;
 
-	for (port = start_port(device); port <= end_port(device); ++port) {
-		for (i = 0; i < device->gid_tbl_len[port - start_port(device)]; ++i) {
+	for (port = rdma_start_port(device); port <= rdma_end_port(device); ++port) {
+		for (i = 0; i < device->port_immutable[port].gid_tbl_len; ++i) {
 			ret = ib_query_gid(device, port, i, &tmp_gid);
 			if (ret)
 				return ret;
@@ -706,7 +705,7 @@
 	int ret, i;
 	u16 tmp_pkey;
 
-	for (i = 0; i < device->pkey_tbl_len[port_num - start_port(device)]; ++i) {
+	for (i = 0; i < device->port_immutable[port_num].pkey_tbl_len; ++i) {
 		ret = ib_query_pkey(device, port_num, i, &tmp_pkey);
 		if (ret)
 			return ret;
@@ -769,3 +768,4 @@
 
 MODULE_VERSION(ibcore, 1);
 DECLARE_MODULE(ibcore, ibcore_mod, SI_SUB_SMP, SI_ORDER_ANY);
+MODULE_DEPEND(ibcore, toecore, 1, 1, 1);

Modified: trunk/sys/ofed/drivers/infiniband/core/fmr_pool.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/fmr_pool.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/fmr_pool.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/iwcm.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/iwcm.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/iwcm.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Intel Corporation.  All rights reserved.
  * Copyright (c) 2004 Topspin Corporation.  All rights reserved.
@@ -5,6 +6,7 @@
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
  * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
  * Copyright (c) 2005 Network Appliance, Inc. All rights reserved.
+ * Copyright (c) 2016 Chelsio Communications.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -35,6 +37,8 @@
  * SOFTWARE.
  *
  */
+#include "opt_inet.h"
+
 #include <linux/dma-mapping.h>
 #include <linux/err.h>
 #include <linux/idr.h>
@@ -44,7 +48,10 @@
 #include <linux/workqueue.h>
 #include <linux/completion.h>
 #include <linux/string.h>
+#include <netinet/tcp.h>
+#include <sys/mutex.h>
 
+#include <rdma/rdma_cm.h>
 #include <rdma/iw_cm.h>
 #include <rdma/ib_addr.h>
 
@@ -62,7 +69,85 @@
 	struct iw_cm_event event;
 	struct list_head free_list;
 };
+struct iwcm_listen_work {
+	struct work_struct work;
+	struct iw_cm_id *cm_id;
+};
 
+static LIST_HEAD(listen_port_list);
+
+static DEFINE_MUTEX(listen_port_mutex);
+
+struct listen_port_info {
+	struct list_head list;
+	uint16_t port_num;
+	uint32_t refcnt;
+};
+
+static int32_t
+add_port_to_listenlist(uint16_t port)
+{
+	struct listen_port_info *port_info;
+	int err = 0;
+
+	mutex_lock(&listen_port_mutex);
+
+	list_for_each_entry(port_info, &listen_port_list, list)
+		if (port_info->port_num == port)
+			goto found_port;
+
+	port_info = kmalloc(sizeof(*port_info), GFP_KERNEL);
+	if (!port_info) {
+		err = -ENOMEM;
+		mutex_unlock(&listen_port_mutex);
+		goto out;
+	}
+
+	port_info->port_num = port;
+	port_info->refcnt    = 0;
+
+	list_add(&port_info->list, &listen_port_list);
+
+found_port:
+	++(port_info->refcnt);
+	mutex_unlock(&listen_port_mutex);
+	return port_info->refcnt;
+out:
+	return err;
+}
+
+static int32_t
+rem_port_from_listenlist(uint16_t port)
+{
+	struct listen_port_info *port_info;
+	int ret, found_port = 0;
+
+	mutex_lock(&listen_port_mutex);
+
+	list_for_each_entry(port_info, &listen_port_list, list)
+		if (port_info->port_num == port) {
+			found_port = 1;
+			break;
+		}
+
+	if (found_port) {
+		--(port_info->refcnt);
+		ret = port_info->refcnt;
+		if (port_info->refcnt == 0) {
+			/* Remove this entry from the list as there are no
+			 * more listeners for this port_num.
+			 */
+			list_del(&port_info->list);
+			kfree(port_info);
+		}
+	} else {
+		ret = -EINVAL;
+	}
+	mutex_unlock(&listen_port_mutex);
+	return ret;
+
+}
+
 /*
  * The following services provide a mechanism for pre-allocating iwcm_work
  * elements.  The design pre-allocates them  based on the cm_id type:
@@ -179,9 +264,16 @@
 static void rem_ref(struct iw_cm_id *cm_id)
 {
 	struct iwcm_id_private *cm_id_priv;
+	int cb_destroy;
+
 	cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
-	if (iwcm_deref_id(cm_id_priv) &&
-	    test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags)) {
+
+	/*
+	 * Test bit before deref in case the cm_id gets freed on another
+	 * thread.
+	 */
+	cb_destroy = test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags);
+	if (iwcm_deref_id(cm_id_priv) && cb_destroy) {
 		BUG_ON(!list_empty(&cm_id_priv->work_list));
 		free_cm_id(cm_id_priv);
 	}
@@ -317,6 +409,154 @@
 }
 EXPORT_SYMBOL(iw_cm_disconnect);
 
+static struct socket *
+dequeue_socket(struct socket *head)
+{
+	struct socket *so;
+	struct sockaddr_in *remote;
+
+	ACCEPT_LOCK();
+	so = TAILQ_FIRST(&head->so_comp);
+	if (!so) {
+		ACCEPT_UNLOCK();
+		return NULL;
+	}
+
+	SOCK_LOCK(so);
+	/*
+	 * Before changing the flags on the socket, we have to bump the
+	 * reference count.  Otherwise, if the protocol calls sofree(),
+	 * the socket will be released due to a zero refcount.
+	 */
+	soref(so);
+	TAILQ_REMOVE(&head->so_comp, so, so_list);
+	head->so_qlen--;
+	so->so_qstate &= ~SQ_COMP;
+	so->so_head = NULL;
+	so->so_state |= SS_NBIO;
+	SOCK_UNLOCK(so);
+	ACCEPT_UNLOCK();
+	remote = NULL;
+	soaccept(so, (struct sockaddr **)&remote);
+
+	free(remote, M_SONAME);
+	return so;
+}
+static void
+iw_so_event_handler(struct work_struct *_work)
+{
+#ifdef INET
+	struct	iwcm_listen_work *work = container_of(_work,
+						struct iwcm_listen_work, work);
+	struct	iw_cm_id *listen_cm_id = work->cm_id;
+	struct	iwcm_id_private *cm_id_priv;
+	struct	iw_cm_id *real_cm_id;
+	struct	sockaddr_in *local;
+	struct	socket *so;
+
+	cm_id_priv = container_of(listen_cm_id, struct iwcm_id_private, id);
+
+	if (cm_id_priv->state != IW_CM_STATE_LISTEN) {
+		kfree(work);
+		return;
+	}
+
+	/* Dequeue & process  all new 'so' connection requests for this cmid */
+	while ((so = dequeue_socket(work->cm_id->so)) != NULL) {
+		if (rdma_cma_any_addr((struct sockaddr *)
+					&listen_cm_id->local_addr)) {
+			in_getsockaddr(so, (struct sockaddr **)&local);
+			if (rdma_find_cmid_laddr(local, ARPHRD_ETHER,
+					(void **) &real_cm_id)) {
+				free(local, M_SONAME);
+				goto err;
+			}
+			free(local, M_SONAME);
+
+			real_cm_id->device->iwcm->newconn(real_cm_id, so);
+		} else {
+			listen_cm_id->device->iwcm->newconn(listen_cm_id, so);
+		}
+	}
+err:
+	kfree(work);
+#endif
+	return;
+}
+static int
+iw_so_upcall(struct socket *parent_so, void *arg, int waitflag)
+{
+	struct iwcm_listen_work *work;
+	struct socket *so;
+	struct iw_cm_id *cm_id = arg;
+
+	/* check whether iw_so_event_handler() already dequeued this 'so' */
+	so = TAILQ_FIRST(&parent_so->so_comp);
+	if (!so)
+		return SU_OK;
+	work = kzalloc(sizeof(*work), M_NOWAIT);
+	if (!work)
+		return -ENOMEM;
+	work->cm_id = cm_id;
+
+	INIT_WORK(&work->work, iw_so_event_handler);
+	queue_work(iwcm_wq, &work->work);
+
+	return SU_OK;
+}
+
+static void
+iw_init_sock(struct iw_cm_id *cm_id)
+{
+	struct sockopt sopt;
+	struct socket *so = cm_id->so;
+	int on = 1;
+
+	SOCK_LOCK(so);
+	soupcall_set(so, SO_RCV, iw_so_upcall, cm_id);
+	so->so_state |= SS_NBIO;
+	SOCK_UNLOCK(so);
+	sopt.sopt_dir = SOPT_SET;
+	sopt.sopt_level = IPPROTO_TCP;
+	sopt.sopt_name = TCP_NODELAY;
+	sopt.sopt_val = (caddr_t)&on;
+	sopt.sopt_valsize = sizeof(on);
+	sopt.sopt_td = NULL;
+	sosetopt(so, &sopt);
+}
+
+static int
+iw_uninit_socket(struct iw_cm_id *cm_id)
+{
+	struct socket *so = cm_id->so;
+
+	SOCK_LOCK(so);
+	soupcall_clear(so, SO_RCV);
+	SOCK_UNLOCK(so);
+
+	return (0);
+}
+
+static int
+iw_create_listen(struct iw_cm_id *cm_id, int backlog)
+{
+	int rc;
+
+	iw_init_sock(cm_id);
+	rc = -solisten(cm_id->so, backlog, curthread);
+	if (rc != 0)
+		iw_uninit_socket(cm_id);
+	return (rc);
+}
+
+static int
+iw_destroy_listen(struct iw_cm_id *cm_id)
+{
+
+	return (iw_uninit_socket(cm_id));
+}
+
+
 /*
  * CM_ID <-- DESTROYING
  *
@@ -327,7 +567,7 @@
 {
 	struct iwcm_id_private *cm_id_priv;
 	unsigned long flags;
-	int ret;
+	int ret = 0, refcnt;
 
 	cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
 	/*
@@ -342,8 +582,18 @@
 	case IW_CM_STATE_LISTEN:
 		cm_id_priv->state = IW_CM_STATE_DESTROYING;
 		spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-		/* destroy the listening endpoint */
-		ret = cm_id->device->iwcm->destroy_listen(cm_id);
+		if (rdma_cma_any_addr((struct sockaddr *)&cm_id->local_addr)) {
+			refcnt =
+			  rem_port_from_listenlist(cm_id->local_addr.sin_port);
+
+			if (refcnt == 0)
+				ret = iw_destroy_listen(cm_id);
+
+			cm_id->device->iwcm->destroy_listen_ep(cm_id);
+		} else {
+			ret = iw_destroy_listen(cm_id);
+			cm_id->device->iwcm->destroy_listen_ep(cm_id);
+		}
 		spin_lock_irqsave(&cm_id_priv->lock, flags);
 		break;
 	case IW_CM_STATE_ESTABLISHED:
@@ -401,6 +651,9 @@
 
 	wait_for_completion(&cm_id_priv->destroy_comp);
 
+	if (cm_id->so)
+		sock_release(cm_id->so);
+
 	free_cm_id(cm_id_priv);
 }
 EXPORT_SYMBOL(iw_destroy_cm_id);
@@ -415,7 +668,7 @@
 {
 	struct iwcm_id_private *cm_id_priv;
 	unsigned long flags;
-	int ret;
+	int ret, refcnt;
 
 	cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
 
@@ -428,9 +681,33 @@
 	case IW_CM_STATE_IDLE:
 		cm_id_priv->state = IW_CM_STATE_LISTEN;
 		spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-		ret = cm_id->device->iwcm->create_listen(cm_id, backlog);
-		if (ret)
+
+		if (rdma_cma_any_addr((struct sockaddr *)&cm_id->local_addr)) {
+			refcnt =
+			  add_port_to_listenlist(cm_id->local_addr.sin_port);
+
+			if (refcnt == 1) {
+				ret = iw_create_listen(cm_id, backlog);
+			} else if (refcnt <= 0) {
+				ret = -EINVAL;
+			} else {
+				/* if refcnt > 1, a socket listener created
+				 * already. And we need not create socket
+				 * listener on other rdma devices/listen cm_id's
+				 * due to TOE. That is when a socket listener is
+				 * created with INADDR_ANY all registered TOE
+				 * devices will get a call to start
+				 * hardware listeners.
+				 */
+			}
+		} else {
+			ret = iw_create_listen(cm_id, backlog);
+		}
+		if (!ret)
+			cm_id->device->iwcm->create_listen_ep(cm_id, backlog);
+		else
 			cm_id_priv->state = IW_CM_STATE_IDLE;
+
 		spin_lock_irqsave(&cm_id_priv->lock, flags);
 		break;
 	default:
@@ -873,6 +1150,8 @@
 			}
 			return;
 		}
+		if (empty)
+			return;
 		spin_lock_irqsave(&cm_id_priv->lock, flags);
 	}
 	spin_unlock_irqrestore(&cm_id_priv->lock, flags);

Modified: trunk/sys/ofed/drivers/infiniband/core/iwcm.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/iwcm.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/iwcm.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Network Appliance, Inc. All rights reserved.
  * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/local_sa.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/local_sa.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/local_sa.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006 Intel Corporation.  All rights reserved.
  *
@@ -54,24 +55,8 @@
 	SA_DB_MAX_RETRY_TIMER	 = 256000 /* 256 sec */
 };
 
-static int set_paths_per_dest(const char *val, struct kernel_param *kp);
 static unsigned long paths_per_dest = 0;
-module_param_call(paths_per_dest, set_paths_per_dest, param_get_ulong,
-		  &paths_per_dest, 0644);
-MODULE_PARM_DESC(paths_per_dest, "Maximum number of paths to retrieve "
-				 "to each destination (DGID).  Set to 0 "
-				 "to disable cache.");
-
-static int set_subscribe_inform_info(const char *val, struct kernel_param *kp);
 static char subscribe_inform_info = 1;
-module_param_call(subscribe_inform_info, set_subscribe_inform_info,
-		  param_get_bool, &subscribe_inform_info, 0644);
-MODULE_PARM_DESC(subscribe_inform_info,
-		 "Subscribe for SA InformInfo/Notice events.");
-
-static int do_refresh(const char *val, struct kernel_param *kp);
-module_param_call(refresh, do_refresh, NULL, NULL, 0200);
-
 static unsigned long retry_timer = SA_DB_MIN_RETRY_TIMER;
 
 enum sa_db_lookup_method {
@@ -79,13 +64,7 @@
 	SA_DB_LOOKUP_RANDOM
 };
 
-static int set_lookup_method(const char *val, struct kernel_param *kp);
-static int get_lookup_method(char *buf, struct kernel_param *kp);
 static unsigned long lookup_method;
-module_param_call(lookup_method, set_lookup_method, get_lookup_method,
-		  &lookup_method, 0644);
-MODULE_PARM_DESC(lookup_method, "Method used to return path records when "
-				"multiple paths exist to a given destination.");
 
 static void sa_db_add_dev(struct ib_device *device);
 static void sa_db_remove_dev(struct ib_device *device);
@@ -735,73 +714,6 @@
 		refresh_dev_db(dev);
 }
 
-static int do_refresh(const char *val, struct kernel_param *kp)
-{
-	mutex_lock(&lock);
-	refresh_db();
-	mutex_unlock(&lock);
-	return 0;
-}
-
-static int get_lookup_method(char *buf, struct kernel_param *kp)
-{
-	return sprintf(buf,
-		       "%c %d round robin\n"
-		       "%c %d random",
-		       (lookup_method == SA_DB_LOOKUP_LEAST_USED) ? '*' : ' ',
-		       SA_DB_LOOKUP_LEAST_USED,
-		       (lookup_method == SA_DB_LOOKUP_RANDOM) ? '*' : ' ',
-		       SA_DB_LOOKUP_RANDOM);
-}
-
-static int set_lookup_method(const char *val, struct kernel_param *kp)
-{
-	unsigned long method;
-	int ret = 0;
-
-	method = simple_strtoul(val, NULL, 0);
-
-	switch (method) {
-	case SA_DB_LOOKUP_LEAST_USED:
-	case SA_DB_LOOKUP_RANDOM:
-		lookup_method = method;
-		break;
-	default:
-		ret = -EINVAL;
-		break;
-	}
-
-	return ret;
-}
-
-static int set_paths_per_dest(const char *val, struct kernel_param *kp)
-{
-	int ret;
-
-	mutex_lock(&lock);
-	ret = param_set_ulong(val, kp);
-	if (ret)
-		goto out;
-
-	if (paths_per_dest > SA_DB_MAX_PATHS_PER_DEST)
-		paths_per_dest = SA_DB_MAX_PATHS_PER_DEST;
-	refresh_db();
-out:
-	mutex_unlock(&lock);
-	return ret;
-}
-
-static int set_subscribe_inform_info(const char *val, struct kernel_param *kp)
-{
-	int ret;
-
-	ret = param_set_bool(val, kp);
-	if (ret)
-		return ret;
-
-	return do_refresh(val, kp);
-}
-
 static void port_work_handler(struct work_struct *work)
 {
 	struct sa_db_port *port;

Modified: trunk/sys/ofed/drivers/infiniband/core/mad.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/mad.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/mad.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
  * Copyright (c) 2005 Intel Corporation.  All rights reserved.
@@ -33,6 +34,9 @@
  * SOFTWARE.
  *
  */
+
+#define	LINUXKPI_PARAM_PREFIX ibcore_
+
 #include <linux/dma-mapping.h>
 #include <rdma/ib_cache.h>
 

Modified: trunk/sys/ofed/drivers/infiniband/core/mad_priv.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/mad_priv.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/mad_priv.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005, Voltaire, Inc. All rights reserved.
  * Copyright (c) 2005 Intel Corporation. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/mad_rmpp.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/mad_rmpp.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/mad_rmpp.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Intel Inc. All rights reserved.
  * Copyright (c) 2005-2006 Voltaire, Inc. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/mad_rmpp.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/mad_rmpp.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/mad_rmpp.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Intel Inc. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/core/multicast.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/multicast.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/multicast.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006 Intel Corporation.  All rights reserved.
  *
@@ -30,6 +31,8 @@
  * SOFTWARE.
  */
 
+#define	LINUXKPI_PARAM_PREFIX ibcore_
+
 #include <linux/completion.h>
 #include <linux/dma-mapping.h>
 #include <linux/err.h>

Modified: trunk/sys/ofed/drivers/infiniband/core/notice.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/notice.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/notice.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006 Intel Corporation.  All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/core/packer.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/packer.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/packer.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Corporation.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/sa.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/sa.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/sa.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Voltaire, Inc.  All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/sa_query.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/sa_query.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/sa_query.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Voltaire, Inc.  All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/smi.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/smi.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/smi.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Mellanox Technologies Ltd.  All rights reserved.
  * Copyright (c) 2004, 2005 Infinicon Corporation.  All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/smi.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/smi.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/smi.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Mellanox Technologies Ltd.  All rights reserved.
  * Copyright (c) 2004 Infinicon Corporation.  All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/sysfs.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/sysfs.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/sysfs.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Mellanox Technologies Ltd.  All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/ucm.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/ucm.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/ucm.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Intel Corporation.  All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/ucma.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/ucma.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/ucma.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005-2006 Intel Corporation.  All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/core/ud_header.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/ud_header.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/ud_header.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Corporation.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/umem.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/umem.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/umem.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Cisco Systems.  All rights reserved.
@@ -32,6 +33,8 @@
  * SOFTWARE.
  */
 
+#define	LINUXKPI_PARAM_PREFIX ibcore_
+
 #include <linux/mm.h>
 #include <linux/dma-mapping.h>
 #include <linux/sched.h>
@@ -52,7 +55,7 @@
 #include "uverbs.h"
 
 static int allow_weak_ordering;
-module_param(allow_weak_ordering, bool, 0444);
+module_param(allow_weak_ordering, int, 0444);
 MODULE_PARM_DESC(allow_weak_ordering,  "Allow weak ordering for data registered memory");
 
 #define IB_UMEM_MAX_PAGE_CHUNK						\
@@ -140,10 +143,10 @@
 			struct page *page = sg_page(&chunk->page_list[i]);
 			if (umem->writable && dirty) {
 				if (object && object != page->object)
-					VM_OBJECT_UNLOCK(object);
+					VM_OBJECT_WUNLOCK(object);
 				if (object != page->object) {
 					object = page->object;
-					VM_OBJECT_LOCK(object);
+					VM_OBJECT_WLOCK(object);
 				}
 				vm_page_dirty(page);
 			}
@@ -151,7 +154,7 @@
 		kfree(chunk);
 	}
 	if (object)
-		VM_OBJECT_UNLOCK(object);
+		VM_OBJECT_WUNLOCK(object);
 
 #endif
 }

Modified: trunk/sys/ofed/drivers/infiniband/core/user_mad.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/user_mad.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/user_mad.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Voltaire, Inc. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/uverbs.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/uverbs.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/uverbs.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/core/uverbs_cmd.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/uverbs_cmd.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/uverbs_cmd.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005, 2006, 2007 Cisco Systems.  All rights reserved.
@@ -33,6 +34,8 @@
  * SOFTWARE.
  */
 
+#define	LINUXKPI_PARAM_PREFIX ibcore_
+
 #include <linux/file.h>
 #include <linux/fs.h>
 #include <linux/lockdep.h>

Modified: trunk/sys/ofed/drivers/infiniband/core/uverbs_main.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/uverbs_main.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/uverbs_main.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.
@@ -782,7 +783,7 @@
 {
 	struct ib_uverbs_device *dev = dev_get_drvdata(device);
 
-	if (!dev)
+	if (!dev || !dev->ib_dev->dma_device)
 		return -ENODEV;
 
 	return sprintf(buf, "0x%04x\n",
@@ -795,7 +796,7 @@
 {
 	struct ib_uverbs_device *dev = dev_get_drvdata(device);
 
-	if (!dev)
+	if (!dev || !dev->ib_dev->dma_device)
 		return -ENODEV;
 
 	return sprintf(buf, "0x%04x\n",

Modified: trunk/sys/ofed/drivers/infiniband/core/uverbs_marshall.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/uverbs_marshall.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/uverbs_marshall.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Intel Corporation.  All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/core/verbs.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/core/verbs.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/core/verbs.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Mellanox Technologies Ltd.  All rights reserved.
  * Copyright (c) 2004 Infinicon Corporation.  All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/debug/Makefile
===================================================================
--- trunk/sys/ofed/drivers/infiniband/debug/Makefile	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/debug/Makefile	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+# $MidnightBSD$
 EXTRA_CFLAGS :=  $(subst $(KERNEL_MEMTRACK_CFLAGS),,$(EXTRA_CFLAGS))
 
 obj-m += memtrack.o

Modified: trunk/sys/ofed/drivers/infiniband/debug/memtrack.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/debug/memtrack.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/debug/memtrack.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
   This software is available to you under a choice of one of two
   licenses.  You may choose to be licensed under the terms of the GNU
@@ -19,6 +20,8 @@
   Copyright (c) 2004 Mellanox Technologies Ltd.  All rights reserved.
 */
 
+#define	LINUXKPI_PARAM_PREFIX memtrack_
+
 #define C_MEMTRACK_C
 
 #ifdef kmalloc

Modified: trunk/sys/ofed/drivers/infiniband/debug/memtrack.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/debug/memtrack.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/debug/memtrack.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
   This software is available to you under a choice of one of two
   licenses.  You may choose to be licensed under the terms of the GNU

Modified: trunk/sys/ofed/drivers/infiniband/debug/mtrack.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/debug/mtrack.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/debug/mtrack.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #ifndef __mtrack_h_
 #define __mtrack_h_
 

Index: trunk/sys/ofed/drivers/infiniband/hw/mlx4/Kconfig
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/Kconfig	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/Kconfig	2018-05-25 13:01:20 UTC (rev 9919)

Property changes on: trunk/sys/ofed/drivers/infiniband/hw/mlx4/Kconfig
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/Makefile
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/Makefile	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/Makefile	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+# $MidnightBSD$
 # $FreeBSD$
 #.PATH:  ${.CURDIR}/../../ofed/drivers/infiniband/hw/mlx4
 #.PATH:  ${.CURDIR}/../../../../include/linux
@@ -28,4 +29,4 @@
 
 .include <bsd.kmod.mk>
 
-CFLAGS+= -Wno-cast-qual -Wno-pointer-arith -fms-extensions
+CFLAGS+= -Wno-cast-qual -Wno-pointer-arith ${GCC_MS_EXTENSIONS}

Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/ah.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/ah.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/ah.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/alias_GUID.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/alias_GUID.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/alias_GUID.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2012 Mellanox Technologies. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/cm.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/cm.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/cm.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2012 Mellanox Technologies. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/cq.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/cq.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/cq.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
  * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/doorbell.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/doorbell.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/doorbell.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/mad.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/mad.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/mad.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
  *
@@ -593,7 +594,7 @@
 		is_eth = 1;
 
 	if (is_eth) {
-		if (!wc->wc_flags & IB_WC_GRH) {
+		if (!(wc->wc_flags & IB_WC_GRH)) {
 			mlx4_ib_warn(ibdev, "RoCE grh not present.\n");
 			return -EINVAL;
 		}
@@ -963,7 +964,7 @@
 	int err;
 	u32 counter_index = dev->counters[port_num - 1] & 0xffff;
 	u8 mode;
-	char				counter_buf[MLX4_IF_STAT_SZ(1)];
+	char				counter_buf[MLX4_IF_STAT_SZ(1)] __aligned(8);
 	union  mlx4_counter		*counter = (union mlx4_counter *)
 						   counter_buf;
 

Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/main.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/main.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/main.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
  * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
@@ -31,6 +32,8 @@
  * SOFTWARE.
  */
 
+#define	LINUXKPI_PARAM_PREFIX mlx4_
+
 #include <linux/module.h>
 
 #ifdef __linux__
@@ -1862,6 +1865,38 @@
 			    "is incorrect. The parameter value is discarded!");
 }
 
+static int mlx4_port_immutable(struct ib_device *ibdev, u8 port_num,
+			       struct ib_port_immutable *immutable)
+{
+	struct ib_port_attr attr;
+	struct mlx4_ib_dev *mdev = to_mdev(ibdev);
+	int err;
+
+	if (mlx4_ib_port_link_layer(ibdev, port_num) == IB_LINK_LAYER_INFINIBAND) {
+		immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB;
+		immutable->max_mad_size = IB_MGMT_MAD_SIZE;
+	} else {
+		if (mdev->dev->caps.flags & MLX4_DEV_CAP_FLAG_IBOE)
+			immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE;
+		if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCEV2)
+			immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE |
+				RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP;
+		immutable->core_cap_flags |= RDMA_CORE_PORT_RAW_PACKET;
+		if (immutable->core_cap_flags & (RDMA_CORE_PORT_IBA_ROCE |
+		    RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP))
+			immutable->max_mad_size = IB_MGMT_MAD_SIZE;
+	}
+
+	err = ib_query_port(ibdev, port_num, &attr);
+	if (err)
+		return err;
+
+	immutable->pkey_tbl_len = attr.pkey_tbl_len;
+	immutable->gid_tbl_len = attr.gid_tbl_len;
+
+	return 0;
+}
+
 static void *mlx4_ib_add(struct mlx4_dev *dev)
 {
 	struct mlx4_ib_dev *ibdev;
@@ -1991,6 +2026,7 @@
 	ibdev->ib_dev.attach_flow	= mlx4_ib_flow_attach;
 	ibdev->ib_dev.detach_flow	= mlx4_ib_flow_detach;
 	ibdev->ib_dev.process_mad	= mlx4_ib_process_mad;
+	ibdev->ib_dev.get_port_immutable = mlx4_port_immutable;
 
 	if (!mlx4_is_slave(ibdev->dev)) {
 		ibdev->ib_dev.alloc_fmr		= mlx4_ib_fmr_alloc;
@@ -2416,6 +2452,7 @@
         .name = "mlx4ib",
         .evhand = mlx4ib_evhand,
 };
+
 DECLARE_MODULE(mlx4ib, mlx4ib_mod, SI_SUB_OFED_PREINIT, SI_ORDER_ANY);
 MODULE_DEPEND(mlx4ib, mlx4, 1, 1, 1);
 MODULE_DEPEND(mlx4ib, ibcore, 1, 1, 1);

Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/mcg.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/mcg.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/mcg.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2012 Mellanox Technologies. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/mlx4_ib.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/mlx4_ib.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/mlx4_ib.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006, 2007 Cisco Systems.  All rights reserved.
  * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/mr.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/mr.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/mr.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
  * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/qp.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/qp.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/qp.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
  * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
@@ -274,7 +275,7 @@
 	wmb();
 
 	ctrl->owner_opcode = cpu_to_be32(MLX4_OPCODE_NOP | MLX4_WQE_CTRL_NEC) |
-		(n & qp->sq.wqe_cnt ? cpu_to_be32(1 << 31) : 0);
+		(n & qp->sq.wqe_cnt ? cpu_to_be32(1U << 31) : 0);
 
 	stamp_send_wqe(qp, n + qp->sq_spare_wqes, size);
 }
@@ -2072,7 +2073,7 @@
 
 		for (i = 0; i < qp->sq.wqe_cnt; ++i) {
 			ctrl = get_send_wqe(qp, i);
-			ctrl->owner_opcode = cpu_to_be32(1 << 31);
+			ctrl->owner_opcode = cpu_to_be32(1U << 31);
 			if (qp->sq_max_wqes_per_wr == 1)
 				ctrl->fence_size = 1 << (qp->sq.wqe_shift - 4);
 
@@ -2833,7 +2834,7 @@
 	 */
 	wmb();
 
-	iseg->byte_count = cpu_to_be32((1 << 31) | 4);
+	iseg->byte_count = cpu_to_be32((1U << 31) | 4);
 }
 
 static void set_data_seg(struct mlx4_wqe_data_seg *dseg, struct ib_sge *sg)
@@ -2901,7 +2902,7 @@
 {
 	struct mlx4_wqe_inline_seg *inl = wqe;
 	memset(wqe, 0, 16);
-	inl->byte_count = cpu_to_be32(1 << 31);
+	inl->byte_count = cpu_to_be32(1U << 31);
 }
 
 static int lay_inline_data(struct mlx4_ib_qp *qp, struct ib_send_wr *wr,
@@ -3253,7 +3254,7 @@
 		}
 
 		ctrl->owner_opcode = mlx4_ib_opcode[wr->opcode] |
-			(ind & qp->sq.wqe_cnt ? cpu_to_be32(1 << 31) : 0) | blh;
+			(ind & qp->sq.wqe_cnt ? cpu_to_be32(1U << 31) : 0) | blh;
 
 		stamp = ind + qp->sq_spare_wqes;
 		ind += DIV_ROUND_UP(size * 16, 1U << qp->sq.wqe_shift);

Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/srq.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/srq.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/srq.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
  * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/sysfs.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/sysfs.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/sysfs.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2012 Mellanox Technologies.  All rights reserved.
  *
@@ -79,7 +80,7 @@
 		container_of(attr, struct mlx4_ib_iov_sysfs_attr, dentry);
 	struct mlx4_ib_iov_port *port = mlx4_ib_iov_dentry->ctx;
 	struct mlx4_ib_dev *mdev = port->dev;
-	u64 sysadmin_ag_val;
+	unsigned long long sysadmin_ag_val;
 
 	record_num = mlx4_ib_iov_dentry->entry_num / 8;
 	guid_index_in_rec = mlx4_ib_iov_dentry->entry_num % 8;

Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/user.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/user.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/user.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
  * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/wc.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/wc.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/wc.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006-2007 Mellanox Technologies. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/hw/mlx4/wc.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mlx4/wc.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mlx4/wc.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006-2007 Mellanox Technologies. All rights reserved.
  *

Index: trunk/sys/ofed/drivers/infiniband/hw/mthca/Kconfig
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/Kconfig	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/Kconfig	2018-05-25 13:01:20 UTC (rev 9919)

Property changes on: trunk/sys/ofed/drivers/infiniband/hw/mthca/Kconfig
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/Makefile
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/Makefile	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/Makefile	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+# $MidnightBSD$
 obj-$(CONFIG_INFINIBAND_MTHCA) += ib_mthca.o
 
 ib_mthca-y :=	mthca_main.o mthca_cmd.o mthca_profile.o mthca_reset.o \

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_allocator.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_allocator.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_allocator.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_av.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_av.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_av.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_catas.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_catas.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_catas.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Cisco Systems.  All rights reserved.
  *
@@ -30,6 +31,8 @@
  * SOFTWARE.
  */
 
+#define	LINUXKPI_PARAM_PREFIX mthca_
+
 #include <linux/jiffies.h>
 #include <linux/timer.h>
 #include <linux/workqueue.h>

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
@@ -32,6 +33,8 @@
  * SOFTWARE.
  */
 
+#define	LINUXKPI_PARAM_PREFIX mthca_
+
 #include <linux/completion.h>
 #include <linux/pci.h>
 #include <linux/errno.h>

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_config_reg.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_config_reg.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_config_reg.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_cq.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_cq.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_cq.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_dev.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_dev.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_dev.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_doorbell.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_doorbell.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_doorbell.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_mad.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_mad.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_mad.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
@@ -32,6 +33,8 @@
  * SOFTWARE.
  */
 
+#define	LINUXKPI_PARAM_PREFIX mthca_
+
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/pci.h>

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_mcg.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_mcg.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_mcg.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  *
@@ -173,13 +174,13 @@
 	}
 
 	for (i = 0; i < MTHCA_QP_PER_MGM; ++i)
-		if (mgm->qp[i] == cpu_to_be32(ibqp->qp_num | (1 << 31))) {
+		if (mgm->qp[i] == cpu_to_be32(ibqp->qp_num | (1U << 31))) {
 			mthca_dbg(dev, "QP %06x already a member of MGM\n",
 				  ibqp->qp_num);
 			err = 0;
 			goto out;
-		} else if (!(mgm->qp[i] & cpu_to_be32(1 << 31))) {
-			mgm->qp[i] = cpu_to_be32(ibqp->qp_num | (1 << 31));
+		} else if (!(mgm->qp[i] & cpu_to_be32(1U << 31))) {
+			mgm->qp[i] = cpu_to_be32(ibqp->qp_num | (1U << 31));
 			break;
 		}
 
@@ -260,9 +261,9 @@
 	}
 
 	for (loc = -1, i = 0; i < MTHCA_QP_PER_MGM; ++i) {
-		if (mgm->qp[i] == cpu_to_be32(ibqp->qp_num | (1 << 31)))
+		if (mgm->qp[i] == cpu_to_be32(ibqp->qp_num | (1U << 31)))
 			loc = i;
-		if (!(mgm->qp[i] & cpu_to_be32(1 << 31)))
+		if (!(mgm->qp[i] & cpu_to_be32(1U << 31)))
 			break;
 	}
 

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Cisco Systems.  All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Cisco Systems.  All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_mr.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_mr.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_mr.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_pd.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_pd.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_pd.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Cisco Systems.  All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_profile.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_profile.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_profile.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_profile.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_profile.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_profile.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
@@ -1297,6 +1298,25 @@
 	return err;
 }
 
+static int mthca_port_immutable(struct ib_device *ibdev, u8 port_num,
+			        struct ib_port_immutable *immutable)
+{
+	struct ib_port_attr attr;
+	int err;
+
+	immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB;
+
+	err = ib_query_port(ibdev, port_num, &attr);
+	if (err)
+		return err;
+
+	immutable->pkey_tbl_len = attr.pkey_tbl_len;
+	immutable->gid_tbl_len = attr.gid_tbl_len;
+	immutable->max_mad_size = IB_MGMT_MAD_SIZE;
+
+	return 0;
+}
+
 int mthca_register_device(struct mthca_dev *dev)
 {
 	int ret;
@@ -1376,6 +1396,7 @@
 	dev->ib_dev.reg_phys_mr          = mthca_reg_phys_mr;
 	dev->ib_dev.reg_user_mr          = mthca_reg_user_mr;
 	dev->ib_dev.dereg_mr             = mthca_dereg_mr;
+	dev->ib_dev.get_port_immutable   = mthca_port_immutable;
 
 	if (dev->mthca_flags & MTHCA_FLAG_FMR) {
 		dev->ib_dev.alloc_fmr            = mthca_alloc_fmr;

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_qp.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_qp.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_qp.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Cisco Systems. All rights reserved.
@@ -1756,7 +1757,7 @@
 		/* Add one more inline data segment for ICRC */
 		if (qp->transport == MLX) {
 			((struct mthca_data_seg *) wqe)->byte_count =
-				cpu_to_be32((1 << 31) | 4);
+				cpu_to_be32((1U << 31) | 4);
 			((u32 *) wqe)[1] = 0;
 			wqe += sizeof (struct mthca_data_seg);
 			size += sizeof (struct mthca_data_seg) / 16;
@@ -2097,7 +2098,7 @@
 		/* Add one more inline data segment for ICRC */
 		if (qp->transport == MLX) {
 			((struct mthca_data_seg *) wqe)->byte_count =
-				cpu_to_be32((1 << 31) | 4);
+				cpu_to_be32((1U << 31) | 4);
 			((u32 *) wqe)[1] = 0;
 			wqe += sizeof (struct mthca_data_seg);
 			size += sizeof (struct mthca_data_seg) / 16;

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_reset.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_reset.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_reset.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_srq.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_srq.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_srq.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Cisco Systems. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_uar.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_uar.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_uar.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_user.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_user.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_user.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_wqe.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_wqe.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/hw/mthca/mthca_wqe.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Cisco Systems. All rights reserved.
  *

Index: trunk/sys/ofed/drivers/infiniband/ulp/ipoib/Kconfig
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/ipoib/Kconfig	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/ipoib/Kconfig	2018-05-25 13:01:20 UTC (rev 9919)

Property changes on: trunk/sys/ofed/drivers/infiniband/ulp/ipoib/Kconfig
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/ofed/drivers/infiniband/ulp/ipoib/Makefile
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/ipoib/Makefile	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/ipoib/Makefile	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+# $MidnightBSD$
 obj-$(CONFIG_INFINIBAND_IPOIB)			+= ib_ipoib.o
 
 ib_ipoib-y					:= ipoib_main.o \

Modified: trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
@@ -35,6 +36,8 @@
 #ifndef _IPOIB_H
 #define _IPOIB_H
 
+#define	LINUXKPI_PARAM_PREFIX ipoib_
+
 #include "opt_inet.h"
 #include "opt_inet6.h"
 #include "opt_ofed.h"

Modified: trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006 Mellanox Technologies. All rights reserved
  *

Modified: trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Mellanox Technologies. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_fs.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_fs.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_fs.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
@@ -287,7 +288,7 @@
 	}
 	i--;
 	if (i >= max) {
-		tx_req->mb = mb = m_defrag(mb, M_DONTWAIT);
+		tx_req->mb = mb = m_defrag(mb, M_NOWAIT);
 		if (mb == NULL)
 			return -EIO;
 		for (m = mb, i = 0; m != NULL; m = m->m_next, i++);

Modified: trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
@@ -87,7 +88,7 @@
 static void ipoib_remove_one(struct ib_device *device);
 static void ipoib_start(struct ifnet *dev);
 static int ipoib_output(struct ifnet *ifp, struct mbuf *m,
-	    struct sockaddr *dst, struct route *ro);
+	    const struct sockaddr *dst, struct route *ro);
 static int ipoib_ioctl(struct ifnet *ifp, u_long command, caddr_t data);
 static void ipoib_input(struct ifnet *ifp, struct mbuf *m);
 
@@ -293,13 +294,8 @@
 		break;
 
 	case SIOCGIFADDR:
-		{
-			struct sockaddr *sa;
-
-			sa = (struct sockaddr *) & ifr->ifr_data;
-			bcopy(IF_LLADDR(ifp),
-			      (caddr_t) sa->sa_data, INFINIBAND_ALEN);
-		}
+		bcopy(IF_LLADDR(ifp), &ifr->ifr_addr.sa_data[0],
+		    INFINIBAND_ALEN);
 		break;
 
 	case SIOCSIFMTU:
@@ -880,7 +876,7 @@
 	dev->if_output = ipoib_output;
 	dev->if_input = ipoib_input;
 	dev->if_resolvemulti = ipoib_resolvemulti;
-	dev->if_baudrate = IF_Gbps(10UL);
+	if_initbaudrate(dev, IF_Gbps(10));
 	dev->if_broadcastaddr = priv->broadcastaddr;
 	dev->if_snd.ifq_maxlen = ipoib_sendq_size * 2;
 	sdl = (struct sockaddr_dl *)dev->if_addr->ifa_addr;
@@ -1258,7 +1254,7 @@
  */
 static int
 ipoib_output(struct ifnet *ifp, struct mbuf *m,
-	struct sockaddr *dst, struct route *ro)
+	const struct sockaddr *dst, struct route *ro)
 {
 	u_char edst[INFINIBAND_ALEN];
 	struct llentry *lle = NULL;
@@ -1352,7 +1348,7 @@
 	 * Add local net header.  If no space in first mbuf,
 	 * allocate another.
 	 */
-	M_PREPEND(m, IPOIB_HEADER_LEN, M_DONTWAIT);
+	M_PREPEND(m, IPOIB_HEADER_LEN, M_NOWAIT);
 	if (m == NULL) {
 		error = ENOBUFS;
 		goto bad;
@@ -1448,7 +1444,7 @@
 	 * Strip off Infiniband header.
 	 */
 	m->m_flags &= ~M_VLANTAG;
-	m->m_flags &= ~(M_PROTOFLAGS);
+	m_clrprotoflags(m);
 	m_adj(m, IPOIB_HEADER_LEN);
 
 	if (IPOIB_IS_MULTICAST(eh->hwaddr)) {

Modified: trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_vlan.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_vlan.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  *

Index: trunk/sys/ofed/drivers/infiniband/ulp/sdp/Kconfig
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/sdp/Kconfig	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/sdp/Kconfig	2018-05-25 13:01:20 UTC (rev 9919)

Property changes on: trunk/sys/ofed/drivers/infiniband/ulp/sdp/Kconfig
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/ofed/drivers/infiniband/ulp/sdp/Makefile
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/sdp/Makefile	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/sdp/Makefile	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+# $MidnightBSD$
 EXTRA_CFLAGS += -Idrivers/infiniband/include
 EXTRA_CFLAGS += -ggdb
 

Modified: trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,6 +1,9 @@
+/* $MidnightBSD$ */
 #ifndef _SDP_H_
 #define _SDP_H_
 
+#define	LINUXKPI_PARAM_PREFIX ib_sdp_
+
 #include "opt_ddb.h"
 #include "opt_inet.h"
 #include "opt_ofed.h"

Modified: trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_bcopy.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_bcopy.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_bcopy.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006 Mellanox Technologies Ltd.  All rights reserved.
  *
@@ -151,7 +152,7 @@
 	if (ssk->state == TCPS_CLOSED)
 		return;
 	ssk->nagle_last_unacked = 0;
-	sdp_post_sends(ssk, M_DONTWAIT);
+	sdp_post_sends(ssk, M_NOWAIT);
 
 	sowwakeup(ssk->socket);
 out:

Modified: trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_cma.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_cma.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_cma.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006 Mellanox Technologies Ltd.  All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_dbg.h
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_dbg.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_dbg.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #ifndef _SDP_DBG_H_
 #define _SDP_DBG_H_
 

Modified: trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 
 /*-
  * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
@@ -928,12 +929,12 @@
 	ssk = sdp_sk(so);
 	KASSERT(m->m_flags & M_PKTHDR,
 	    ("sdp_send: %p no packet header", m));
-	M_PREPEND(m, SDP_HEAD_SIZE, M_WAIT);
+	M_PREPEND(m, SDP_HEAD_SIZE, M_WAITOK);
 	mtod(m, struct sdp_bsdh *)->mid = SDP_MID_DATA; 
 	for (n = m, cnt = 0; n->m_next; n = n->m_next)
 		cnt++;
 	if (cnt > SDP_MAX_SEND_SGES) {
-		n = m_collapse(m, M_WAIT, SDP_MAX_SEND_SGES);
+		n = m_collapse(m, M_WAITOK, SDP_MAX_SEND_SGES);
 		if (n == NULL) {
 			m_freem(m);
 			return (EMSGSIZE);
@@ -1196,7 +1197,7 @@
 
 	KASSERT(flags & MSG_OOB, ("soreceive_rcvoob: (flags & MSG_OOB) == 0"));
 
-	m = m_get(M_WAIT, MT_DATA);
+	m = m_get(M_WAITOK, MT_DATA);
 	error = (*pr->pr_usrreqs->pru_rcvoob)(so, m, flags & MSG_PEEK);
 	if (error)
 		goto bad;
@@ -1351,7 +1352,7 @@
 			KASSERT(sb->sb_mb != NULL,
 			    ("%s: len > 0 && sb->sb_mb empty", __func__));
 
-			m = m_copym(sb->sb_mb, 0, len, M_DONTWAIT);
+			m = m_copym(sb->sb_mb, 0, len, M_NOWAIT);
 			if (m == NULL)
 				len = 0;	/* Don't flush data from sockbuf. */
 			else

Modified: trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_proc.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_proc.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_proc.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2008 Mellanox Technologies Ltd.  All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2009 Mellanox Technologies Ltd.  All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_tx.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_tx.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_tx.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2009 Mellanox Technologies Ltd.  All rights reserved.
  *
@@ -297,7 +298,7 @@
 	} while (n == SDP_NUM_WC);
 
 	if (wc_processed) {
-		sdp_post_sends(ssk, M_DONTWAIT);
+		sdp_post_sends(ssk, M_NOWAIT);
 		sdp_prf1(sk, NULL, "Waking sendmsg. inflight=%d", 
 				(u32) tx_ring_posted(ssk));
 		sowwakeup(ssk->socket);

Modified: trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_zcopy.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_zcopy.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/ulp/sdp/sdp_zcopy.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006 Mellanox Technologies Ltd.  All rights reserved.
  *

Index: trunk/sys/ofed/drivers/infiniband/util/Kconfig
===================================================================
--- trunk/sys/ofed/drivers/infiniband/util/Kconfig	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/util/Kconfig	2018-05-25 13:01:20 UTC (rev 9919)

Property changes on: trunk/sys/ofed/drivers/infiniband/util/Kconfig
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/ofed/drivers/infiniband/util/Makefile
===================================================================
--- trunk/sys/ofed/drivers/infiniband/util/Makefile	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/util/Makefile	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+# $MidnightBSD$
 obj-$(CONFIG_INFINIBAND_MADEYE)	+= ib_madeye.o
 
 ib_madeye-y := madeye.o

Modified: trunk/sys/ofed/drivers/infiniband/util/madeye.c
===================================================================
--- trunk/sys/ofed/drivers/infiniband/util/madeye.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/infiniband/util/madeye.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Intel Corporation.  All rights reserved.
  * Copyright (c) 2005, 2006 Voltaire Inc.  All rights reserved.
@@ -32,6 +33,9 @@
  *
  * $Id$
  */
+
+#define	LINUXKPI_PARAM_PREFIX ib_madeye_
+
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/err.h>

Modified: trunk/sys/ofed/drivers/net/mlx4/Makefile
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/Makefile	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/Makefile	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+# $MidnightBSD$
 # $FreeBSD$
 #.PATH:  ${.CURDIR}/../../ofed/drivers/net/mlx4:${.CURDIR}/../../ofed/include/linux
 .PATH:  ${.CURDIR}/../../../../../include/linux
@@ -30,4 +31,4 @@
 
 .include <bsd.kmod.mk>
 
-CFLAGS+= -Wno-cast-qual -Wno-pointer-arith -fms-extensions
+CFLAGS+= -Wno-cast-qual -Wno-pointer-arith ${GCC_MS_EXTENSIONS}

Modified: trunk/sys/ofed/drivers/net/mlx4/alloc.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/alloc.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/alloc.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006, 2007 Cisco Systems, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008, 2014 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/net/mlx4/catas.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/catas.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/catas.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
  * Copyright (c) 2007, 2008, 2014 Mellanox Technologies. All rights reserved.
@@ -31,6 +32,8 @@
  * SOFTWARE.
  */
 
+#define	LINUXKPI_PARAM_PREFIX mlx4_
+
 #include <linux/workqueue.h>
 #include <linux/module.h>
 

Modified: trunk/sys/ofed/drivers/net/mlx4/cmd.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/cmd.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/cmd.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/net/mlx4/cq.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/cq.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/cq.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.

Modified: trunk/sys/ofed/drivers/net/mlx4/en_cq.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/en_cq.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/en_cq.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/net/mlx4/en_ethtool.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/en_ethtool.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/en_ethtool.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Mellanox Technologies. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/net/mlx4/en_frag.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/en_frag.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/en_frag.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Mellanox Technologies. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/net/mlx4/en_main.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/en_main.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/en_main.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved.
  *
@@ -31,6 +32,8 @@
  *
  */
 
+#define	LINUXKPI_PARAM_PREFIX mlx4_
+
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>

Modified: trunk/sys/ofed/drivers/net/mlx4/en_netdev.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/en_netdev.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/en_netdev.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved.
  *
@@ -54,7 +55,6 @@
 
 static void mlx4_en_sysctl_stat(struct mlx4_en_priv *priv);
 static void mlx4_en_sysctl_conf(struct mlx4_en_priv *priv);
-static int mlx4_en_unit;
 
 #ifdef CONFIG_NET_RX_BUSY_POLL
 /* must be called with local_bh_disable()d */
@@ -1379,8 +1379,6 @@
 	/* Schedule multicast task to populate multicast list */
 	queue_work(mdev->workqueue, &priv->rx_mode_task);
 
-	mlx4_set_stats_bitmap(mdev->dev, priv->stats_bitmap);
-
 	priv->port_up = true;
 
         /* Enable the queues. */
@@ -1640,7 +1638,7 @@
 			mlx4_en_destroy_cq(priv, &priv->rx_cq[i]);
 	}
 
-	if (priv->sysctl)
+	if (priv->stat_sysctl != NULL)
 		sysctl_ctx_free(&priv->stat_ctx);
 }
 
@@ -1732,13 +1730,12 @@
 		mutex_unlock(&mdev->state_lock);
 	}
 
-	if (priv->allocated)
-		mlx4_free_hwq_res(mdev->dev, &priv->res, MLX4_EN_PAGE_SIZE);
-
 	mutex_lock(&mdev->state_lock);
 	mlx4_en_stop_port(dev);
 	mutex_unlock(&mdev->state_lock);
 
+	if (priv->allocated)
+		mlx4_free_hwq_res(mdev->dev, &priv->res, MLX4_EN_PAGE_SIZE);
 
 	cancel_delayed_work(&priv->stats_task);
 	cancel_delayed_work(&priv->service_task);
@@ -1755,7 +1752,7 @@
 	mlx4_en_free_resources(priv);
 
 	/* freeing the sysctl conf cannot be called from within mlx4_en_free_resources */
-	if (priv->sysctl)
+	if (priv->conf_sysctl != NULL)
 		sysctl_ctx_free(&priv->conf_ctx);
 
 	kfree(priv->tx_ring);
@@ -1776,7 +1773,8 @@
 	       (unsigned)dev->if_mtu, (unsigned)new_mtu);
 
 	if ((new_mtu < MLX4_EN_MIN_MTU) || (new_mtu > priv->max_mtu)) {
-		en_err(priv, "Bad MTU size:%d.\n", new_mtu);
+		en_err(priv, "Bad MTU size:%d, max %u.\n", new_mtu,
+		    priv->max_mtu);
 		return -EPERM;
 	}
 	mutex_lock(&mdev->state_lock);
@@ -1947,7 +1945,7 @@
 			if (IFCAP_TSO4 & dev->if_capenable &&
 			    !(IFCAP_TXCSUM & dev->if_capenable)) {
 				dev->if_capenable &= ~IFCAP_TSO4;
-				dev->if_hwassist &= ~CSUM_TSO;
+				dev->if_hwassist &= ~CSUM_IP_TSO;
 				if_printf(dev,
 				    "tso4 disabled due to -txcsum.\n");
 			}
@@ -1959,7 +1957,7 @@
 			if (IFCAP_TSO6 & dev->if_capenable &&
 			    !(IFCAP_TXCSUM_IPV6 & dev->if_capenable)) {
 				dev->if_capenable &= ~IFCAP_TSO6;
-				dev->if_hwassist &= ~CSUM_TSO;
+				dev->if_hwassist &= ~CSUM_IP6_TSO;
 				if_printf(dev,
 				    "tso6 disabled due to -txcsum6.\n");
 			}
@@ -1977,6 +1975,7 @@
 				goto out;
 			}
 			dev->if_capenable ^= IFCAP_TSO4;
+			dev->if_hwassist ^= CSUM_IP_TSO;
 		}
 		if (mask & IFCAP_TSO6) {
 			if (!(IFCAP_TSO6 & dev->if_capenable) &&
@@ -1986,11 +1985,8 @@
 				goto out;
 			}
 			dev->if_capenable ^= IFCAP_TSO6;
+			dev->if_hwassist ^= CSUM_IP6_TSO;
 		}
-		if (dev->if_capenable & (IFCAP_TSO4 | IFCAP_TSO6))
-			dev->if_hwassist |= CSUM_TSO;
-		else
-			dev->if_hwassist &= ~CSUM_TSO;
 		if (mask & IFCAP_LRO)
 			dev->if_capenable ^= IFCAP_LRO;
 		if (mask & IFCAP_VLAN_HWTAGGING)
@@ -2056,7 +2052,8 @@
 		return -ENOMEM;
 	}
 	dev->if_softc = priv;
-	if_initname(dev, "mlxen", atomic_fetchadd_int(&mlx4_en_unit, 1));
+	if_initname(dev, "mlxen", (device_get_unit(
+	    mdev->pdev->dev.bsddev) * MLX4_MAX_PORTS) + port - 1);
 	dev->if_mtu = ETHERMTU;
 	dev->if_init = mlx4_en_open;
 	dev->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
@@ -2168,6 +2165,7 @@
 	dev->if_capabilities |= IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWFILTER;
 	dev->if_capabilities |= IFCAP_LINKSTATE | IFCAP_JUMBO_MTU;
 	dev->if_capabilities |= IFCAP_LRO;
+	dev->if_capabilities |= IFCAP_HWSTATS;
 
 	if (mdev->LSO_support)
 		dev->if_capabilities |= IFCAP_TSO4 | IFCAP_TSO6 | IFCAP_VLAN_HWTSO;
@@ -2573,9 +2571,9 @@
 	pnameunit = device_get_nameunit(priv->mdev->pdev->dev.bsddev);
 
         sysctl_ctx_init(ctx);
-        priv->sysctl = SYSCTL_ADD_NODE(ctx, SYSCTL_STATIC_CHILDREN(_hw),
+        priv->conf_sysctl = SYSCTL_ADD_NODE(ctx, SYSCTL_STATIC_CHILDREN(_hw),
             OID_AUTO, dev->if_xname, CTLFLAG_RD, 0, "mlx4 10gig ethernet");
-        node = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(priv->sysctl), OID_AUTO,
+        node = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(priv->conf_sysctl), OID_AUTO,
             "conf", CTLFLAG_RD, NULL, "Configuration");
         node_list = SYSCTL_CHILDREN(node);
 
@@ -2638,7 +2636,6 @@
 static void mlx4_en_sysctl_stat(struct mlx4_en_priv *priv)
 {
 	struct sysctl_ctx_list *ctx;
-	struct sysctl_oid *node;
 	struct sysctl_oid_list *node_list;
 	struct sysctl_oid *ring_node;
 	struct sysctl_oid_list *ring_list;
@@ -2649,9 +2646,9 @@
 
 	ctx = &priv->stat_ctx;
 	sysctl_ctx_init(ctx);
-	node = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(priv->sysctl), OID_AUTO,
+	priv->stat_sysctl = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(priv->conf_sysctl), OID_AUTO,
 	    "stat", CTLFLAG_RD, NULL, "Statistics");
-	node_list = SYSCTL_CHILDREN(node);
+	node_list = SYSCTL_CHILDREN(priv->stat_sysctl);
 
 #ifdef MLX4_EN_PERF_STAT
 	SYSCTL_ADD_UINT(ctx, node_list, OID_AUTO, "tx_poll", CTLFLAG_RD,
@@ -2685,6 +2682,8 @@
 	SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_chksum_offload",
 	    CTLFLAG_RD, &priv->port_stats.tx_chksum_offload,
 	    "TX checksum offloads");
+	SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "defrag_attempts", CTLFLAG_RD,
+	    &priv->port_stats.defrag_attempts, "Oversized chains defragged");
 
 	/* Could strdup the names and add in a loop.  This is simpler. */
 	SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "rx_bytes", CTLFLAG_RD,
@@ -2734,28 +2733,6 @@
 	    &priv->pkstats.rx_gt_1548_bytes_packets,
 	    "RX Greater Then 1548 bytes Packets");
 
-struct mlx4_en_pkt_stats {
-	unsigned long tx_packets;
-	unsigned long tx_bytes;
-	unsigned long tx_multicast_packets;
-	unsigned long tx_broadcast_packets;
-	unsigned long tx_errors;
-	unsigned long tx_dropped;
-	unsigned long tx_lt_64_bytes_packets;
-	unsigned long tx_127_bytes_packets;
-	unsigned long tx_255_bytes_packets;
-	unsigned long tx_511_bytes_packets;
-	unsigned long tx_1023_bytes_packets;
-	unsigned long tx_1518_bytes_packets;
-	unsigned long tx_1522_bytes_packets;
-	unsigned long tx_1548_bytes_packets;
-	unsigned long tx_gt_1548_bytes_packets;
-	unsigned long rx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS];
-	unsigned long tx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS];
-#define NUM_PKT_STATS		72
-};
-
-
 	SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_packets", CTLFLAG_RD,
 	    &priv->pkstats.tx_packets, "TX packets");
 	SYSCTL_ADD_ULONG(ctx, node_list, OID_AUTO, "tx_bytes", CTLFLAG_RD,
@@ -2800,6 +2777,10 @@
 		    CTLFLAG_RD, &tx_ring->packets, "TX packets");
 		SYSCTL_ADD_ULONG(ctx, ring_list, OID_AUTO, "bytes",
 		    CTLFLAG_RD, &tx_ring->bytes, "TX bytes");
+		SYSCTL_ADD_ULONG(ctx, ring_list, OID_AUTO, "tso_packets",
+		    CTLFLAG_RD, &tx_ring->tso_packets, "TSO packets");
+		SYSCTL_ADD_ULONG(ctx, ring_list, OID_AUTO, "defrag_attempts",
+		    CTLFLAG_RD, &tx_ring->defrag_attempts, "Oversized chains defragged");
 	}
 
 	for (i = 0; i < priv->rx_ring_num; i++) {

Modified: trunk/sys/ofed/drivers/net/mlx4/en_params.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/en_params.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/en_params.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -0,0 +1 @@
+/* $MidnightBSD$ */

Modified: trunk/sys/ofed/drivers/net/mlx4/en_port.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/en_port.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/en_port.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved.
  *
@@ -124,11 +125,45 @@
 	return err;
 }
 
+static void mlx4_en_fold_software_stats(struct net_device *dev)
+{
+	struct mlx4_en_priv *priv = netdev_priv(dev);
+	struct mlx4_en_dev *mdev = priv->mdev;
+	u64 packets, bytes;
+	int i;
+
+	if (!priv->port_up || mlx4_is_master(mdev->dev))
+		return;
+
+	packets = 0;
+	bytes = 0;
+	for (i = 0; i < priv->rx_ring_num; i++) {
+		const struct mlx4_en_rx_ring *ring = priv->rx_ring[i];
+
+		packets += READ_ONCE(ring->packets);
+		bytes += READ_ONCE(ring->bytes);
+	}
+	priv->pkstats.rx_packets = packets;
+	priv->pkstats.rx_bytes = bytes;
+
+	packets = 0;
+	bytes = 0;
+	for (i = 0; i < priv->tx_ring_num; i++) {
+		const struct mlx4_en_tx_ring *ring = priv->tx_ring[i];
+
+		packets += READ_ONCE(ring->packets);
+		bytes += READ_ONCE(ring->bytes);
+	}
+	priv->pkstats.tx_packets = packets;
+	priv->pkstats.tx_bytes = bytes;
+}
+
 int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
 {
 	struct mlx4_en_stat_out_mbox *mlx4_en_stats;
 	struct mlx4_en_stat_out_flow_control_mbox *flowstats;
-	struct mlx4_en_priv *priv = netdev_priv(mdev->pndev[port]);
+	struct net_device *dev = mdev->pndev[port];
+	struct mlx4_en_priv *priv = netdev_priv(dev);
 	struct mlx4_en_vport_stats *vport_stats = &priv->vport_stats;
 	struct mlx4_cmd_mailbox *mailbox = NULL;
 	struct mlx4_cmd_mailbox *mailbox_flow = NULL;
@@ -138,7 +173,6 @@
 	int do_if_stat = 1;
 	unsigned long period = (unsigned long) (jiffies - priv->last_ifq_jiffies);
 	struct mlx4_en_vport_stats tmp_vport_stats;
-        struct net_device *dev;
 
 	if (jiffies_to_msecs(period) < EN_IFQ_MIN_INTERVAL ||
 				priv->counter_index == 0xff)
@@ -191,11 +225,16 @@
 	priv->port_stats.tx_chksum_offload = 0;
 	priv->port_stats.queue_stopped = 0;
 	priv->port_stats.wake_queue = 0;
+	priv->port_stats.oversized_packets = 0;
+	priv->port_stats.tso_packets = 0;
+	priv->port_stats.defrag_attempts = 0;
 	for (i = 0; i < priv->tx_ring_num; i++) {
 		priv->port_stats.tx_chksum_offload += priv->tx_ring[i]->tx_csum;
 		priv->port_stats.queue_stopped += priv->tx_ring[i]->queue_stopped;
 		priv->port_stats.wake_queue += priv->tx_ring[i]->wake_queue;
 		priv->port_stats.oversized_packets += priv->tx_ring[i]->oversized_packets;
+		priv->port_stats.tso_packets += priv->tx_ring[i]->tso_packets;
+		priv->port_stats.defrag_attempts += priv->tx_ring[i]->defrag_attempts;
 	}
 	/* RX Statistics */
 	priv->pkstats.rx_packets = be64_to_cpu(mlx4_en_stats->RTOT_prio_0) +
@@ -523,8 +562,12 @@
 			be64_to_cpu(flowstats[i].tx_pause_transition);
 	}
 
+	mlx4_en_fold_software_stats(dev);
+
+	spin_unlock(&priv->stats_lock);
+
 	memset(&tmp_vport_stats, 0, sizeof(tmp_vport_stats));
-	spin_unlock(&priv->stats_lock);
+
 	err = mlx4_get_vport_ethtool_stats(mdev->dev, port,
 					   &tmp_vport_stats, reset);
 	spin_lock(&priv->stats_lock);
@@ -547,19 +590,37 @@
 		vport_stats->tx_errors = tmp_vport_stats.tx_errors;
 	}
 
-	if (!mlx4_is_mfunc(mdev->dev)) {
-		/* netdevice stats format */
-                dev                     = mdev->pndev[port];
-		dev->if_ipackets        = priv->pkstats.rx_packets;
-		dev->if_opackets        = priv->pkstats.tx_packets;
-		dev->if_ibytes          = priv->pkstats.rx_bytes;
-		dev->if_obytes          = priv->pkstats.tx_bytes;
-		dev->if_ierrors         = priv->pkstats.rx_errors;
-		dev->if_iqdrops         = priv->pkstats.rx_dropped;
-		dev->if_imcasts         = priv->pkstats.rx_multicast_packets;
-                dev->if_omcasts         = priv->pkstats.tx_multicast_packets;
-                dev->if_collisions      = 0;
+#if __FreeBSD_version >= 1100000
+	if (reset == 0) {
+		if_inc_counter(dev, IFCOUNTER_IPACKETS,
+		    priv->pkstats.rx_packets - priv->pkstats_last.rx_packets);
+		if_inc_counter(dev, IFCOUNTER_OPACKETS,
+		    priv->pkstats.tx_packets - priv->pkstats_last.tx_packets);
+		if_inc_counter(dev, IFCOUNTER_IBYTES,
+		    priv->pkstats.rx_bytes - priv->pkstats_last.rx_bytes);
+		if_inc_counter(dev, IFCOUNTER_OBYTES,
+		    priv->pkstats.tx_bytes - priv->pkstats_last.tx_bytes);
+		if_inc_counter(dev, IFCOUNTER_IERRORS,
+		    priv->pkstats.rx_errors - priv->pkstats_last.rx_errors);
+		if_inc_counter(dev, IFCOUNTER_IQDROPS,
+		    priv->pkstats.rx_dropped - priv->pkstats_last.rx_dropped);
+		if_inc_counter(dev, IFCOUNTER_IMCASTS,
+		    priv->pkstats.rx_multicast_packets - priv->pkstats_last.rx_multicast_packets);
+		if_inc_counter(dev, IFCOUNTER_OMCASTS,
+		    priv->pkstats.tx_multicast_packets - priv->pkstats_last.tx_multicast_packets);
 	}
+	priv->pkstats_last = priv->pkstats;
+#else
+	dev->if_ipackets        = priv->pkstats.rx_packets;
+	dev->if_opackets        = priv->pkstats.tx_packets;
+	dev->if_ibytes          = priv->pkstats.rx_bytes;
+	dev->if_obytes          = priv->pkstats.tx_bytes;
+	dev->if_ierrors         = priv->pkstats.rx_errors;
+	dev->if_iqdrops         = priv->pkstats.rx_dropped;
+	dev->if_imcasts         = priv->pkstats.rx_multicast_packets;
+	dev->if_omcasts         = priv->pkstats.tx_multicast_packets;
+	dev->if_collisions      = 0;
+#endif
 
 	spin_unlock(&priv->stats_lock);
 

Modified: trunk/sys/ofed/drivers/net/mlx4/en_port.h
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/en_port.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/en_port.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/net/mlx4/en_resources.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/en_resources.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/en_resources.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/net/mlx4/en_rx.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/en_rx.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/en_rx.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved.
  *
@@ -394,8 +395,14 @@
                 ring->rx_mb_size = priv->rx_mb_size;
 
 		ring->stride = stride;
-		if (ring->stride <= TXBB_SIZE)
+		if (ring->stride <= TXBB_SIZE) {
+			/* Stamp first unused send wqe */
+			__be32 *ptr = (__be32 *)ring->buf;
+			__be32 stamp = cpu_to_be32(1 << STAMP_SHIFT);
+			*ptr = stamp;
+			/* Move pointer to start of rx section */	
 			ring->buf += TXBB_SIZE;
+		}
 
 		ring->log_stride = ffs(ring->stride) - 1;
 		ring->buf_size = ring->size * ring->stride;
@@ -622,7 +629,7 @@
 
 		/* forward Toeplitz compatible hash value */
 		mb->m_pkthdr.flowid = be32_to_cpu(cqe->immed_rss_invalid);
-		mb->m_flags |= M_FLOWID;
+		M_HASHTYPE_SET(mb, M_HASHTYPE_OPAQUE);
 		mb->m_pkthdr.rcvif = dev;
 		if (be32_to_cpu(cqe->vlan_my_qpn) &
 		    MLX4_CQE_VLAN_PRESENT_MASK) {

Modified: trunk/sys/ofed/drivers/net/mlx4/en_selftest.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/en_selftest.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/en_selftest.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Mellanox Technologies. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/net/mlx4/en_tx.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/en_tx.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/en_tx.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved.
  *
@@ -31,6 +32,8 @@
  *
  */
 
+#define	LINUXKPI_PARAM_PREFIX mlx4_
+
 #include <linux/page.h>
 #include <linux/mlx4/cq.h>
 #include <linux/slab.h>
@@ -646,7 +649,6 @@
 	        up = (vlan_tag >> 13) % MLX4_EN_NUM_UP;
 	}
 #endif
-	/* hash mbuf */
 	queue_index = mlx4_en_hashmbuf(MLX4_F_HASHL3 | MLX4_F_HASHL4, mb, hashrandom);
 
 	return ((queue_index % rings_p_up) + (up * rings_p_up));
@@ -657,18 +659,6 @@
 	__iowrite64_copy(dst, __DEVOLATILE(void *, src), bytecnt / 8);
 }
 
-static u64 mlx4_en_mac_to_u64(u8 *addr)
-{
-        u64 mac = 0;
-        int i;
-
-        for (i = 0; i < ETHER_ADDR_LEN; i++) {
-                mac <<= 8;
-                mac |= addr[i];
-        }
-        return mac;
-}
-
 static int mlx4_en_xmit(struct mlx4_en_priv *priv, int tx_ind, struct mbuf **mbp)
 {
 	enum {
@@ -703,20 +693,19 @@
 
 	/* check if TX ring is full */
 	if (unlikely(mlx4_en_tx_ring_is_full(ring))) {
-			/* every full native Tx ring stops queue */
-			if (ring->blocked == 0)
-				atomic_add_int(&priv->blocked, 1);
-			/* Set HW-queue-is-full flag */
-			atomic_set_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE);
-			priv->port_stats.queue_stopped++;
+		/* every full native Tx ring stops queue */
+		if (ring->blocked == 0)
+			atomic_add_int(&priv->blocked, 1);
+		/* Set HW-queue-is-full flag */
+		atomic_set_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE);
+		priv->port_stats.queue_stopped++;
 		ring->blocked = 1;
-		priv->port_stats.queue_stopped++;
 		ring->queue_stopped++;
 
 		/* Use interrupts to find out when queue opened */
 		mlx4_en_arm_cq(priv, priv->tx_cq[tx_ind]);
 		return (ENOBUFS);
-        }
+	}
 
 	/* sanity check we are not wrapping around */
 	KASSERT(((~ring->prod) & ring->size_mask) >=
@@ -767,8 +756,18 @@
 		tx_desc->ctrl.ins_vlan = 0;
 	}
 
-	/* clear immediate field */
-	tx_desc->ctrl.imm = 0;
+	if (unlikely(mlx4_is_mfunc(priv->mdev->dev) || priv->validate_loopback)) {
+		/*
+		 * Copy destination MAC address to WQE. This allows
+		 * loopback in eSwitch, so that VFs and PF can
+		 * communicate with each other:
+		 */
+		m_copydata(mb, 0, 2, __DEVOLATILE(void *, &tx_desc->ctrl.srcrb_flags16[0]));
+		m_copydata(mb, 2, 4, __DEVOLATILE(void *, &tx_desc->ctrl.imm));
+	} else {
+		/* clear immediate field */
+		tx_desc->ctrl.imm = 0;
+	}
 
 	/* Handle LSO (TSO) packets */
 	if (mb->m_pkthdr.csum_flags & CSUM_TSO) {
@@ -792,7 +791,7 @@
 			num_pkts = DIV_ROUND_UP(payload_len, mss);
 		ring->bytes += payload_len + (num_pkts * ihs);
 		ring->packets += num_pkts;
-		priv->port_stats.tso_packets++;
+		ring->tso_packets++;
 		/* store pointer to inline header */
 		dseg_inline = dseg;
 		/* copy data inline */
@@ -813,20 +812,11 @@
 	}
 	m_adj(mb, ihs);
 
-	/* trim off empty mbufs */
-	while (mb->m_len == 0) {
-		mb = m_free(mb);
-		/* check if all data has been inlined */
-		if (mb == NULL) {
-			nr_segs = 0;
-			goto skip_dma;
-		}
-	}
-
 	err = bus_dmamap_load_mbuf_sg(ring->dma_tag, tx_info->dma_map,
 	    mb, segs, &nr_segs, BUS_DMA_NOWAIT);
 	if (unlikely(err == EFBIG)) {
 		/* Too many mbuf fragments */
+		ring->defrag_attempts++;
 		m = m_defrag(mb, M_NOWAIT);
 		if (m == NULL) {
 			ring->oversized_packets++;
@@ -842,11 +832,18 @@
 		ring->oversized_packets++;
 		goto tx_drop;
 	}
-	/* make sure all mbuf data is written to RAM */
-	bus_dmamap_sync(ring->dma_tag, tx_info->dma_map,
-	    BUS_DMASYNC_PREWRITE);
+	/* If there were no errors and we didn't load anything, don't sync. */
+	if (nr_segs != 0) {
+		/* make sure all mbuf data is written to RAM */
+		bus_dmamap_sync(ring->dma_tag, tx_info->dma_map,
+		    BUS_DMASYNC_PREWRITE);
+	} else {
+		/* All data was inlined, free the mbuf. */
+		bus_dmamap_unload(ring->dma_tag, tx_info->dma_map);
+		m_freem(mb);
+		mb = NULL;
+	}
 
-skip_dma:
 	/* compute number of DS needed */
 	ds_cnt = (dseg - ((volatile struct mlx4_wqe_data_seg *)tx_desc)) + nr_segs;
 
@@ -927,22 +924,6 @@
 	else
 		mlx4_en_store_inline_header(dseg_inline, ihs, owner_bit);
 
-	if (unlikely(priv->validate_loopback)) {
-		/* Copy dst mac address to wqe */
-                struct ether_header *ethh;
-                u64 mac;
-                u32 mac_l, mac_h;
-
-                ethh = mtod(mb, struct ether_header *);
-                mac = mlx4_en_mac_to_u64(ethh->ether_dhost);
-                if (mac) {
-                        mac_h = (u32) ((mac & 0xffff00000000ULL) >> 16);
-                        mac_l = (u32) (mac & 0xffffffff);
-                        tx_desc->ctrl.srcrb_flags |= cpu_to_be32(mac_h);
-                        tx_desc->ctrl.imm = cpu_to_be32(mac_l);
-                }
-	}
-
 	/* update producer counter */
 	ring->prod += tx_info->nr_txbb;
 
@@ -1021,9 +1002,6 @@
 		}
 		drbr_advance(dev, ring->br);
 		enqueued++;
-		dev->if_obytes += next->m_pkthdr.len;
-		if (next->m_flags & M_MCAST)
-			dev->if_omcasts++;
 		if ((dev->if_drv_flags & IFF_DRV_RUNNING) == 0)
 			break;
 	}
@@ -1072,7 +1050,7 @@
 	}
 
 	/* Compute which queue to use */
-	if (m->m_flags & M_FLOWID) {
+	if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) {
 		i = (m->m_pkthdr.flowid % 128) % priv->tx_ring_num;
 	}
 	else {

Modified: trunk/sys/ofed/drivers/net/mlx4/eq.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/eq.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/eq.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved.
  * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved.
@@ -1136,8 +1137,12 @@
 		goto err_out_free;
 	}
 
-	err = mlx4_bitmap_init(&priv->eq_table.bitmap, dev->caps.num_eqs,
-			       dev->caps.num_eqs - 1, dev->caps.reserved_eqs, 0);
+	err = mlx4_bitmap_init(&priv->eq_table.bitmap,
+				roundup_pow_of_two(dev->caps.num_eqs),
+				dev->caps.num_eqs - 1,
+				dev->caps.reserved_eqs,
+				roundup_pow_of_two(dev->caps.num_eqs) -
+					dev->caps.num_eqs);
 	if (err)
 		goto err_out_free;
 
@@ -1165,8 +1170,7 @@
 	}
 
 	for (i = 0; i < dev->caps.num_comp_vectors; ++i) {
-		err = mlx4_create_eq(dev, dev->caps.num_cqs -
-					  dev->caps.reserved_cqs +
+		err = mlx4_create_eq(dev, dev->quotas.cq +
 					  MLX4_NUM_SPARE_EQE,
 				     (dev->flags & MLX4_FLAG_MSI_X) ? i : 0,
 				     &priv->eq_table.eq[i]);
@@ -1186,8 +1190,7 @@
 	for (i = dev->caps.num_comp_vectors + 1;
 	      i < dev->caps.num_comp_vectors + dev->caps.comp_pool + 1; ++i) {
 
-		err = mlx4_create_eq(dev, dev->caps.num_cqs -
-					  dev->caps.reserved_cqs +
+		err = mlx4_create_eq(dev, dev->quotas.cq +
 					  MLX4_NUM_SPARE_EQE,
 				     (dev->flags & MLX4_FLAG_MSI_X) ? i : 0,
 				     &priv->eq_table.eq[i]);

Modified: trunk/sys/ofed/drivers/net/mlx4/fw.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/fw.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/fw.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved.
@@ -32,6 +33,8 @@
  * SOFTWARE.
  */
 
+#define	LINUXKPI_PARAM_PREFIX mlx4_
+
 #include <linux/etherdevice.h>
 #include <linux/mlx4/cmd.h>
 #include <linux/module.h>
@@ -49,8 +52,8 @@
 extern void __buggy_use_of_MLX4_GET(void);
 extern void __buggy_use_of_MLX4_PUT(void);
 
-static bool enable_qos;
-module_param(enable_qos, bool, 0444);
+static int enable_qos;
+module_param(enable_qos, int, 0444);
 MODULE_PARM_DESC(enable_qos, "Enable Quality of Service support in the HCA (default: off)");
 
 #define MLX4_GET(dest, source, offset)				      \
@@ -177,6 +180,60 @@
 	return err;
 }
 
+int mlx4_QUERY_FUNC(struct mlx4_dev *dev, struct mlx4_func *func, int slave)
+{
+	struct mlx4_cmd_mailbox *mailbox;
+	u32 *outbox;
+	u8 in_modifier;
+	u8 field;
+	u16 field16;
+	int err;
+
+#define QUERY_FUNC_BUS_OFFSET			0x00
+#define QUERY_FUNC_DEVICE_OFFSET		0x01
+#define QUERY_FUNC_FUNCTION_OFFSET		0x01
+#define QUERY_FUNC_PHYSICAL_FUNCTION_OFFSET	0x03
+#define QUERY_FUNC_RSVD_EQS_OFFSET		0x04
+#define QUERY_FUNC_MAX_EQ_OFFSET		0x06
+#define QUERY_FUNC_RSVD_UARS_OFFSET		0x0b
+
+	mailbox = mlx4_alloc_cmd_mailbox(dev);
+	if (IS_ERR(mailbox))
+		return PTR_ERR(mailbox);
+	outbox = mailbox->buf;
+
+	in_modifier = slave;
+
+	err = mlx4_cmd_box(dev, 0, mailbox->dma, in_modifier, 0,
+			MLX4_CMD_QUERY_FUNC,
+			MLX4_CMD_TIME_CLASS_A,
+			MLX4_CMD_NATIVE);
+	if (err)
+	        goto out;
+
+	MLX4_GET(field, outbox, QUERY_FUNC_BUS_OFFSET);
+	func->bus = field & 0xf;
+	MLX4_GET(field, outbox, QUERY_FUNC_DEVICE_OFFSET);
+	func->device = field & 0xf1;
+	MLX4_GET(field, outbox, QUERY_FUNC_FUNCTION_OFFSET);
+	func->function = field & 0x7;
+	MLX4_GET(field, outbox, QUERY_FUNC_PHYSICAL_FUNCTION_OFFSET);
+	func->physical_function = field & 0xf;
+	MLX4_GET(field16, outbox, QUERY_FUNC_RSVD_EQS_OFFSET);
+	func->rsvd_eqs = field16 & 0xffff;
+	MLX4_GET(field16, outbox, QUERY_FUNC_MAX_EQ_OFFSET);
+	func->max_eq = field16 & 0xffff;
+	MLX4_GET(field, outbox, QUERY_FUNC_RSVD_UARS_OFFSET);
+	func->rsvd_uars = field & 0x0f;
+
+	mlx4_dbg(dev, "Bus: %d, Device: %d, Function: %d, Physical function: %d, Max EQs: %d, Reserved EQs: %d, Reserved UARs: %d\n",
+		func->bus, func->device, func->function, func->physical_function,
+		func->max_eq, func->rsvd_eqs, func->rsvd_uars);
+out:
+	mlx4_free_cmd_mailbox(dev, mailbox);
+	return err;
+}
+
 int mlx4_QUERY_FUNC_CAP_wrapper(struct mlx4_dev *dev, int slave,
 				struct mlx4_vhcr *vhcr,
 				struct mlx4_cmd_mailbox *inbox,
@@ -187,6 +244,7 @@
 	u8	field, port;
 	u32	size;
 	int	err = 0;
+	struct mlx4_func func;
 
 #define QUERY_FUNC_CAP_FLAGS_OFFSET		0x0
 #define QUERY_FUNC_CAP_NUM_PORTS_OFFSET		0x1
@@ -208,11 +266,16 @@
 #define QUERY_FUNC_CAP_MTT_QUOTA_OFFSET		0x64
 #define QUERY_FUNC_CAP_MCG_QUOTA_OFFSET		0x68
 
+#define QUERY_FUNC_CAP_EXTRA_FLAGS_OFFSET	0x6c
+
 #define QUERY_FUNC_CAP_FMR_FLAG			0x80
 #define QUERY_FUNC_CAP_FLAG_RDMA		0x40
 #define QUERY_FUNC_CAP_FLAG_ETH			0x80
 #define QUERY_FUNC_CAP_FLAG_QUOTAS		0x10
+#define QUERY_FUNC_CAP_FLAG_VALID_MAILBOX	0x04
 
+#define QUERY_FUNC_CAP_EXTRA_FLAGS_BF_QP_ALLOC_FLAG	(1UL << 31)
+
 /* when opcode modifier = 1 */
 #define QUERY_FUNC_CAP_PHYS_PORT_OFFSET		0x3
 #define QUERY_FUNC_CAP_FLAGS0_OFFSET		0x8
@@ -229,6 +292,7 @@
 #define QUERY_FUNC_CAP_PROPS_DEF_COUNTER	0x20
 
 #define QUERY_FUNC_CAP_RDMA_PROPS_FORCE_PHY_WQE_GID 0x80
+#define QUERY_FUNC_CAP_SUPPORTS_NON_POWER_OF_2_NUM_EQS (1 << 31)
 
 	if (vhcr->op_modifier == 1) {
 		port = vhcr->in_modifier; /* phys-port = logical-port */
@@ -264,7 +328,7 @@
 	} else if (vhcr->op_modifier == 0) {
 		/* enable rdma and ethernet interfaces, and new quota locations */
 		field = (QUERY_FUNC_CAP_FLAG_ETH | QUERY_FUNC_CAP_FLAG_RDMA |
-			 QUERY_FUNC_CAP_FLAG_QUOTAS);
+			 QUERY_FUNC_CAP_FLAG_QUOTAS | QUERY_FUNC_CAP_FLAG_VALID_MAILBOX);
 		MLX4_PUT(outbox->buf, field, QUERY_FUNC_CAP_FLAGS_OFFSET);
 
 		field = dev->caps.num_ports;
@@ -291,12 +355,25 @@
 		size = dev->caps.num_cqs;
 		MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_CQ_QUOTA_OFFSET_DEP);
 
-		size = dev->caps.num_eqs;
-		MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MAX_EQ_OFFSET);
+		if (!(dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_SYS_EQS) ||
+		    mlx4_QUERY_FUNC(dev, &func, slave)) {
+			size = vhcr->in_modifier &
+				QUERY_FUNC_CAP_SUPPORTS_NON_POWER_OF_2_NUM_EQS ?
+				dev->caps.num_eqs :
+				rounddown_pow_of_two(dev->caps.num_eqs);
+			MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MAX_EQ_OFFSET);
+			size = dev->caps.reserved_eqs;
+			MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_RESERVED_EQ_OFFSET);
+		} else {
+			size = vhcr->in_modifier &
+				QUERY_FUNC_CAP_SUPPORTS_NON_POWER_OF_2_NUM_EQS ?
+				func.max_eq :
+				rounddown_pow_of_two(func.max_eq);
+			MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MAX_EQ_OFFSET);
+			size = func.rsvd_eqs;
+			MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_RESERVED_EQ_OFFSET);
+		}
 
-		size = dev->caps.reserved_eqs;
-		MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_RESERVED_EQ_OFFSET);
-
 		size = priv->mfunc.master.res_tracker.res_alloc[RES_MPT].quota[slave];
 		MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MPT_QUOTA_OFFSET);
 		size = dev->caps.num_mpts;
@@ -311,6 +388,8 @@
 		MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MCG_QUOTA_OFFSET);
 		MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_MCG_QUOTA_OFFSET_DEP);
 
+		size = QUERY_FUNC_CAP_EXTRA_FLAGS_BF_QP_ALLOC_FLAG;
+		MLX4_PUT(outbox->buf, size, QUERY_FUNC_CAP_EXTRA_FLAGS_OFFSET);
 	} else
 		err = -EINVAL;
 
@@ -325,14 +404,17 @@
 	u8			field, op_modifier;
 	u32			size;
 	int			err = 0, quotas = 0;
+	u32                     in_modifier;
 
 	op_modifier = !!gen_or_port; /* 0 = general, 1 = logical port */
+	in_modifier = op_modifier ? gen_or_port :
+		QUERY_FUNC_CAP_SUPPORTS_NON_POWER_OF_2_NUM_EQS;
 
 	mailbox = mlx4_alloc_cmd_mailbox(dev);
 	if (IS_ERR(mailbox))
 		return PTR_ERR(mailbox);
 
-	err = mlx4_cmd_box(dev, 0, mailbox->dma, gen_or_port, op_modifier,
+	err = mlx4_cmd_box(dev, 0, mailbox->dma, in_modifier, op_modifier,
 			   MLX4_CMD_QUERY_FUNC_CAP,
 			   MLX4_CMD_TIME_CLASS_A, MLX4_CMD_WRAPPED);
 	if (err)
@@ -400,6 +482,17 @@
 		MLX4_GET(size, outbox, QUERY_FUNC_CAP_RESERVED_EQ_OFFSET);
 		func_cap->reserved_eq = size & 0xFFFFFF;
 
+		func_cap->extra_flags = 0;
+
+		/* Mailbox data from 0x6c and onward should only be treated if
+		 * QUERY_FUNC_CAP_FLAG_VALID_MAILBOX is set in func_cap->flags
+		 */
+		if (func_cap->flags & QUERY_FUNC_CAP_FLAG_VALID_MAILBOX) {
+			MLX4_GET(size, outbox, QUERY_FUNC_CAP_EXTRA_FLAGS_OFFSET);
+			if (size & QUERY_FUNC_CAP_EXTRA_FLAGS_BF_QP_ALLOC_FLAG)
+				func_cap->extra_flags |= MLX4_QUERY_FUNC_FLAGS_BF_RES_QP;
+		}
+
 		goto out;
 	}
 
@@ -502,6 +595,7 @@
 #define QUERY_DEV_CAP_MAX_MRW_SZ_OFFSET		0x21
 #define QUERY_DEV_CAP_RSVD_MRW_OFFSET		0x22
 #define QUERY_DEV_CAP_MAX_MTT_SEG_OFFSET	0x23
+#define QUERY_DEV_CAP_NUM_SYS_EQ_OFFSET		0x26
 #define QUERY_DEV_CAP_MAX_AV_OFFSET		0x27
 #define QUERY_DEV_CAP_MAX_REQ_QP_OFFSET		0x29
 #define QUERY_DEV_CAP_MAX_RES_QP_OFFSET		0x2b
@@ -599,6 +693,8 @@
 	dev_cap->reserved_mrws = 1 << (field & 0xf);
 	MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_MTT_SEG_OFFSET);
 	dev_cap->max_mtt_seg = 1 << (field & 0x3f);
+	MLX4_GET(size, outbox, QUERY_DEV_CAP_NUM_SYS_EQ_OFFSET);
+	dev_cap->num_sys_eqs = size & 0xfff;
 	MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_REQ_QP_OFFSET);
 	dev_cap->max_requester_per_qp = 1 << (field & 0x3f);
 	MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_RES_QP_OFFSET);
@@ -825,8 +921,11 @@
 	 * we can't use any EQs whose doorbell falls on that page,
 	 * even if the EQ itself isn't reserved.
 	 */
-	dev_cap->reserved_eqs = max(dev_cap->reserved_uars * 4,
-				    dev_cap->reserved_eqs);
+	if (dev_cap->num_sys_eqs == 0)
+		dev_cap->reserved_eqs = max(dev_cap->reserved_uars * 4,
+					    dev_cap->reserved_eqs);
+	else
+		dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_SYS_EQS;
 
 	mlx4_dbg(dev, "Max ICM size %lld MB\n",
 		 (unsigned long long) dev_cap->max_icm_sz >> 20);
@@ -836,8 +935,9 @@
 		 dev_cap->max_srqs, dev_cap->reserved_srqs, dev_cap->srq_entry_sz);
 	mlx4_dbg(dev, "Max CQs: %d, reserved CQs: %d, entry size: %d\n",
 		 dev_cap->max_cqs, dev_cap->reserved_cqs, dev_cap->cqc_entry_sz);
-	mlx4_dbg(dev, "Max EQs: %d, reserved EQs: %d, entry size: %d\n",
-		 dev_cap->max_eqs, dev_cap->reserved_eqs, dev_cap->eqc_entry_sz);
+	mlx4_dbg(dev, "Num sys EQs: %d, max EQs: %d, reserved EQs: %d, entry size: %d\n",
+		dev_cap->num_sys_eqs, dev_cap->max_eqs, dev_cap->reserved_eqs,
+		dev_cap->eqc_entry_sz);
 	mlx4_dbg(dev, "reserved MPTs: %d, reserved MTTs: %d\n",
 		 dev_cap->reserved_mrws, dev_cap->reserved_mtts);
 	mlx4_dbg(dev, "Max PDs: %d, reserved PDs: %d, reserved UARs: %d\n",
@@ -1339,6 +1439,7 @@
 #define	 INIT_HCA_AUXC_BASE_OFFSET	 (INIT_HCA_QPC_OFFSET + 0x50)
 #define	 INIT_HCA_EQC_BASE_OFFSET	 (INIT_HCA_QPC_OFFSET + 0x60)
 #define	 INIT_HCA_LOG_EQ_OFFSET		 (INIT_HCA_QPC_OFFSET + 0x67)
+#define	INIT_HCA_NUM_SYS_EQS_OFFSET	(INIT_HCA_QPC_OFFSET + 0x6a)
 #define	 INIT_HCA_RDMARC_BASE_OFFSET	 (INIT_HCA_QPC_OFFSET + 0x70)
 #define	 INIT_HCA_LOG_RD_OFFSET		 (INIT_HCA_QPC_OFFSET + 0x77)
 #define INIT_HCA_MCAST_OFFSET		 0x0c0
@@ -1447,6 +1548,7 @@
 	MLX4_PUT(inbox, param->auxc_base,     INIT_HCA_AUXC_BASE_OFFSET);
 	MLX4_PUT(inbox, param->eqc_base,      INIT_HCA_EQC_BASE_OFFSET);
 	MLX4_PUT(inbox, param->log_num_eqs,   INIT_HCA_LOG_EQ_OFFSET);
+	MLX4_PUT(inbox, param->num_sys_eqs,   INIT_HCA_NUM_SYS_EQS_OFFSET);
 	MLX4_PUT(inbox, param->rdmarc_base,   INIT_HCA_RDMARC_BASE_OFFSET);
 	MLX4_PUT(inbox, param->log_rd_per_qp, INIT_HCA_LOG_RD_OFFSET);
 
@@ -1553,6 +1655,7 @@
 	MLX4_GET(param->auxc_base,     outbox, INIT_HCA_AUXC_BASE_OFFSET);
 	MLX4_GET(param->eqc_base,      outbox, INIT_HCA_EQC_BASE_OFFSET);
 	MLX4_GET(param->log_num_eqs,   outbox, INIT_HCA_LOG_EQ_OFFSET);
+	MLX4_GET(param->num_sys_eqs,   outbox, INIT_HCA_NUM_SYS_EQS_OFFSET);
 	MLX4_GET(param->rdmarc_base,   outbox, INIT_HCA_RDMARC_BASE_OFFSET);
 	MLX4_GET(param->log_rd_per_qp, outbox, INIT_HCA_LOG_RD_OFFSET);
 

Modified: trunk/sys/ofed/drivers/net/mlx4/fw.h
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/fw.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/fw.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved.
@@ -56,6 +57,7 @@
 	int max_mpts;
 	int reserved_eqs;
 	int max_eqs;
+	int num_sys_eqs;
 	int reserved_mtts;
 	int max_mrw_sz;
 	int reserved_mrws;
@@ -144,8 +146,19 @@
 	u8	physical_port;
 	u8	port_flags;
 	u8	def_counter_index;
+	u8	extra_flags;
 };
 
+struct mlx4_func {
+	int	bus;
+	int	device;
+	int	function;
+	int	physical_function;
+	int	rsvd_eqs;
+	int	max_eq;
+	int	rsvd_uars;
+};
+
 struct mlx4_adapter {
 	u16 vsd_vendor_id;
 	char board_id[MLX4_BOARD_ID_LEN];
@@ -173,6 +186,7 @@
 	u8  log_num_srqs;
 	u8  log_num_cqs;
 	u8  log_num_eqs;
+	u16 num_sys_eqs;
 	u8  log_rd_per_qp;
 	u8  log_mc_table_sz;
 	u8  log_mpt_sz;
@@ -225,6 +239,7 @@
 int mlx4_SET_ICM_SIZE(struct mlx4_dev *dev, u64 icm_size, u64 *aux_pages);
 int mlx4_NOP(struct mlx4_dev *dev);
 int mlx4_MOD_STAT_CFG(struct mlx4_dev *dev, struct mlx4_mod_stat_cfg *cfg);
+int mlx4_QUERY_FUNC(struct mlx4_dev *dev, struct mlx4_func *func, int slave);
 void mlx4_opreq_action(struct work_struct *work);
 
 #endif /* MLX4_FW_H */

Modified: trunk/sys/ofed/drivers/net/mlx4/icm.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/icm.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/icm.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved.
  * Copyright (c) 2006, 2007 Cisco Systems, Inc.  All rights reserved.

Modified: trunk/sys/ofed/drivers/net/mlx4/icm.h
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/icm.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/icm.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved.
  * Copyright (c) 2006, 2007 Cisco Systems, Inc.  All rights reserved.

Modified: trunk/sys/ofed/drivers/net/mlx4/intf.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/intf.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/intf.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
  * Copyright (c) 2007, 2008, 2014 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/net/mlx4/main.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/main.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/main.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
@@ -33,6 +34,8 @@
  * SOFTWARE.
  */
 
+#define	LINUXKPI_PARAM_PREFIX mlx4_
+
 #include <linux/kmod.h>
 /* 
  * kmod.h must be included before module.h since it includes (indirectly) sys/module.h
@@ -592,6 +595,29 @@
 		dev->caps.port_mask[i] = dev->caps.port_type[i];
 }
 
+enum {
+	MLX4_QUERY_FUNC_NUM_SYS_EQS = 1 << 0,
+};
+
+static int mlx4_query_func(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
+{
+	int err = 0;
+	struct mlx4_func func;
+
+	if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_SYS_EQS) {
+		err = mlx4_QUERY_FUNC(dev, &func, 0);
+		if (err) {
+			mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting.\n");
+			return err;
+		}
+		dev_cap->max_eqs = func.max_eq;
+		dev_cap->reserved_eqs = func.rsvd_eqs;
+		dev_cap->reserved_uars = func.rsvd_uars;
+		err |= MLX4_QUERY_FUNC_NUM_SYS_EQS;
+	}
+	return err;
+}
+
 static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
 {
 	int err;
@@ -625,7 +651,10 @@
 	}
 
 	dev->caps.num_ports	     = dev_cap->num_ports;
-	dev->phys_caps.num_phys_eqs  = MLX4_MAX_EQ_NUM;
+       dev->caps.num_sys_eqs = dev_cap->num_sys_eqs;
+       dev->phys_caps.num_phys_eqs = dev_cap->flags2 & MLX4_DEV_CAP_FLAG2_SYS_EQS ?
+                                     dev->caps.num_sys_eqs :
+                                     MLX4_MAX_EQ_NUM;
 	for (i = 1; i <= dev->caps.num_ports; ++i) {
 		dev->caps.vl_cap[i]	    = dev_cap->max_vl[i];
 		dev->caps.ib_mtu_cap[i]	    = dev_cap->ib_mtu[i];
@@ -825,6 +854,11 @@
 	if (!mlx4_is_slave(dev)) {
 		for (i = 0; i < dev->caps.num_ports; ++i)
 			dev->caps.def_counter_index[i] = i << 1;
+
+		dev->caps.alloc_res_qp_mask =
+			(dev->caps.bf_reg_size ? MLX4_RESERVE_ETH_BF_QP : 0);
+	} else {
+		dev->caps.alloc_res_qp_mask = 0;
 	}
 
 	return 0;
@@ -1090,6 +1124,10 @@
 
 	slave_adjust_steering_mode(dev, &dev_cap, &hca_param);
 
+	if (func_cap.extra_flags & MLX4_QUERY_FUNC_FLAGS_BF_RES_QP &&
+	    dev->caps.bf_reg_size)
+		dev->caps.alloc_res_qp_mask |= MLX4_RESERVE_ETH_BF_QP;
+
 	return 0;
 
 err_mem:
@@ -1467,8 +1505,7 @@
 	if (err)
 		goto err_srq;
 
-	num_eqs = (mlx4_is_master(dev)) ? dev->phys_caps.num_phys_eqs :
-		  dev->caps.num_eqs;
+	num_eqs = dev->phys_caps.num_phys_eqs;
 	err = mlx4_init_icm_table(dev, &priv->eq_table.cmpt_table,
 				  cmpt_base +
 				  ((u64) (MLX4_CMPT_TYPE_EQ *
@@ -1530,8 +1567,7 @@
 	}
 
 
-	num_eqs = (mlx4_is_master(dev)) ? dev->phys_caps.num_phys_eqs :
-		   dev->caps.num_eqs;
+	num_eqs = dev->phys_caps.num_phys_eqs;
 	err = mlx4_init_icm_table(dev, &priv->eq_table.table,
 				  init_hca->eqc_base, dev_cap->eqc_entry_sz,
 				  num_eqs, num_eqs, 0, 0);
@@ -1762,10 +1798,10 @@
 		io_mapping_free(mlx4_priv(dev)->bf_mapping);
 }
 
-int mlx4_read_clock(struct mlx4_dev *dev)
+s64 mlx4_read_clock(struct mlx4_dev *dev)
 {
 	u32 clockhi, clocklo, clockhi1;
-	cycle_t cycles;
+	s64 cycles;
 	int i;
 	struct mlx4_priv *priv = mlx4_priv(dev);
 
@@ -1782,7 +1818,7 @@
 
 	cycles = (u64) clockhi << 32 | (u64) clocklo;
 
-	return cycles;
+	return cycles & CORE_CLOCK_MASK;
 }
 EXPORT_SYMBOL_GPL(mlx4_read_clock);
 
@@ -2067,6 +2103,18 @@
 			goto err_free_icm;
 		}
 
+		if (dev_cap->flags2 & MLX4_DEV_CAP_FLAG2_SYS_EQS) {
+			err = mlx4_query_func(dev, dev_cap);
+			if (err < 0) {
+				mlx4_err(dev, "QUERY_FUNC command failed, aborting.\n");
+				goto err_stop_fw;
+			} else if (err & MLX4_QUERY_FUNC_NUM_SYS_EQS) {
+				dev->caps.num_eqs = dev_cap->max_eqs;
+				dev->caps.reserved_eqs = dev_cap->reserved_eqs;
+				dev->caps.reserved_uars = dev_cap->reserved_uars;
+			}
+		}
+
 		/*
 		 * Read HCA frequency by QUERY_HCA command
 		 */
@@ -2907,13 +2955,12 @@
 {
 	struct mlx4_priv *priv = mlx4_priv(dev);
 	struct msix_entry *entries;
-	int nreq = min_t(int, dev->caps.num_ports *
-			 min_t(int, num_possible_cpus() + 1, MAX_MSIX_P_PORT)
-				+ MSIX_LEGACY_SZ, MAX_MSIX);
 	int err;
 	int i;
 
 	if (msi_x) {
+		int nreq = dev->caps.num_ports * num_online_cpus() + MSIX_LEGACY_SZ;
+
 		nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs,
 			     nreq);
 
@@ -3404,6 +3451,8 @@
 			goto err_free_eq;
 	}
 
+	mlx4_init_quotas(dev);
+
 	err = mlx4_setup_hca(dev);
 	if (err == -EBUSY && (dev->flags & MLX4_FLAG_MSI_X) &&
 	    !mlx4_is_mfunc(dev)) {
@@ -3417,7 +3466,6 @@
 	if (err)
 		goto err_steer;
 
-	mlx4_init_quotas(dev);
 	mlx4_init_hca_info(dev);
 
 	for (port = 1; port <= dev->caps.num_ports; port++) {
@@ -3637,47 +3685,61 @@
 
 static DEFINE_PCI_DEVICE_TABLE(mlx4_pci_table) = {
 	/* MT25408 "Hermon" SDR */
-	{ PCI_VDEVICE(MELLANOX, 0x6340), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+	{ PCI_VDEVICE(MELLANOX, 0x6340),
+		.driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
 	/* MT25408 "Hermon" DDR */
-	{ PCI_VDEVICE(MELLANOX, 0x634a), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+	{ PCI_VDEVICE(MELLANOX, 0x634a),
+		.driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
 	/* MT25408 "Hermon" QDR */
-	{ PCI_VDEVICE(MELLANOX, 0x6354), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+	{ PCI_VDEVICE(MELLANOX, 0x6354),
+		.driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
 	/* MT25408 "Hermon" DDR PCIe gen2 */
-	{ PCI_VDEVICE(MELLANOX, 0x6732), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+	{ PCI_VDEVICE(MELLANOX, 0x6732),
+		.driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
 	/* MT25408 "Hermon" QDR PCIe gen2 */
-	{ PCI_VDEVICE(MELLANOX, 0x673c), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+	{ PCI_VDEVICE(MELLANOX, 0x673c),
+		.driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
 	/* MT25408 "Hermon" EN 10GigE */
-	{ PCI_VDEVICE(MELLANOX, 0x6368), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+	{ PCI_VDEVICE(MELLANOX, 0x6368),
+		.driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
 	/* MT25408 "Hermon" EN 10GigE PCIe gen2 */
-	{ PCI_VDEVICE(MELLANOX, 0x6750), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+	{ PCI_VDEVICE(MELLANOX, 0x6750),
+		.driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
 	/* MT25458 ConnectX EN 10GBASE-T 10GigE */
-	{ PCI_VDEVICE(MELLANOX, 0x6372), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+	{ PCI_VDEVICE(MELLANOX, 0x6372),
+		.driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
 	/* MT25458 ConnectX EN 10GBASE-T+Gen2 10GigE */
-	{ PCI_VDEVICE(MELLANOX, 0x675a), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+	{ PCI_VDEVICE(MELLANOX, 0x675a),
+		.driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
 	/* MT26468 ConnectX EN 10GigE PCIe gen2*/
-	{ PCI_VDEVICE(MELLANOX, 0x6764), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+	{ PCI_VDEVICE(MELLANOX, 0x6764),
+		.driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
 	/* MT26438 ConnectX EN 40GigE PCIe gen2 5GT/s */
-	{ PCI_VDEVICE(MELLANOX, 0x6746), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+	{ PCI_VDEVICE(MELLANOX, 0x6746),
+		.driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
 	/* MT26478 ConnectX2 40GigE PCIe gen2 */
-	{ PCI_VDEVICE(MELLANOX, 0x676e), MLX4_PCI_DEV_FORCE_SENSE_PORT },
+	{ PCI_VDEVICE(MELLANOX, 0x676e),
+		.driver_data = MLX4_PCI_DEV_FORCE_SENSE_PORT },
 	/* MT25400 Family [ConnectX-2 Virtual Function] */
-	{ PCI_VDEVICE(MELLANOX, 0x1002), MLX4_PCI_DEV_IS_VF },
+	{ PCI_VDEVICE(MELLANOX, 0x1002),
+		.driver_data = MLX4_PCI_DEV_IS_VF },
 	/* MT27500 Family [ConnectX-3] */
-	{ PCI_VDEVICE(MELLANOX, 0x1003), 0 },
+	{ PCI_VDEVICE(MELLANOX, 0x1003) },
 	/* MT27500 Family [ConnectX-3 Virtual Function] */
-	{ PCI_VDEVICE(MELLANOX, 0x1004), MLX4_PCI_DEV_IS_VF },
-	{ PCI_VDEVICE(MELLANOX, 0x1005), 0 }, /* MT27510 Family */
-	{ PCI_VDEVICE(MELLANOX, 0x1006), 0 }, /* MT27511 Family */
-	{ PCI_VDEVICE(MELLANOX, 0x1007), 0 }, /* MT27520 Family */
-	{ PCI_VDEVICE(MELLANOX, 0x1008), 0 }, /* MT27521 Family */
-	{ PCI_VDEVICE(MELLANOX, 0x1009), 0 }, /* MT27530 Family */
-	{ PCI_VDEVICE(MELLANOX, 0x100a), 0 }, /* MT27531 Family */
-	{ PCI_VDEVICE(MELLANOX, 0x100b), 0 }, /* MT27540 Family */
-	{ PCI_VDEVICE(MELLANOX, 0x100c), 0 }, /* MT27541 Family */
-	{ PCI_VDEVICE(MELLANOX, 0x100d), 0 }, /* MT27550 Family */
-	{ PCI_VDEVICE(MELLANOX, 0x100e), 0 }, /* MT27551 Family */
-	{ PCI_VDEVICE(MELLANOX, 0x100f), 0 }, /* MT27560 Family */
-	{ PCI_VDEVICE(MELLANOX, 0x1010), 0 }, /* MT27561 Family */
+	{ PCI_VDEVICE(MELLANOX, 0x1004),
+		.driver_data = MLX4_PCI_DEV_IS_VF },
+	{ PCI_VDEVICE(MELLANOX, 0x1005) }, /* MT27510 Family */
+	{ PCI_VDEVICE(MELLANOX, 0x1006) }, /* MT27511 Family */
+	{ PCI_VDEVICE(MELLANOX, 0x1007) }, /* MT27520 Family */
+	{ PCI_VDEVICE(MELLANOX, 0x1008) }, /* MT27521 Family */
+	{ PCI_VDEVICE(MELLANOX, 0x1009) }, /* MT27530 Family */
+	{ PCI_VDEVICE(MELLANOX, 0x100a) }, /* MT27531 Family */
+	{ PCI_VDEVICE(MELLANOX, 0x100b) }, /* MT27540 Family */
+	{ PCI_VDEVICE(MELLANOX, 0x100c) }, /* MT27541 Family */
+	{ PCI_VDEVICE(MELLANOX, 0x100d) }, /* MT27550 Family */
+	{ PCI_VDEVICE(MELLANOX, 0x100e) }, /* MT27551 Family */
+	{ PCI_VDEVICE(MELLANOX, 0x100f) }, /* MT27560 Family */
+	{ PCI_VDEVICE(MELLANOX, 0x1010) }, /* MT27561 Family */
 	{ 0, }
 };
 

Modified: trunk/sys/ofed/drivers/net/mlx4/mcg.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/mcg.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/mcg.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006, 2007 Cisco Systems, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008, 2014 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/net/mlx4/mlx4.h
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/mlx4.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/mlx4.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.

Modified: trunk/sys/ofed/drivers/net/mlx4/mlx4_en.h
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/mlx4_en.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/mlx4_en.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved.
  *
@@ -278,6 +279,8 @@
 	unsigned long queue_stopped;
 	unsigned long oversized_packets;
 	unsigned long wake_queue;
+	unsigned long tso_packets;
+	unsigned long defrag_attempts;
 	struct mlx4_bf bf;
 	bool bf_enabled;
 	int hwtstamp_tx_type;
@@ -571,7 +574,6 @@
 	struct mlx4_en_port_stats port_stats;
 	struct mlx4_en_vport_stats vport_stats;
 	struct mlx4_en_vf_stats vf_stats;
-	DECLARE_BITMAP(stats_bitmap, NUM_ALL_STATS);
 	struct list_head mc_list;
 	struct list_head curr_list;
 	u64 broadcast_id;
@@ -586,7 +588,8 @@
 	struct callout watchdog_timer;
         struct ifmedia media;
 	volatile int blocked;
-	struct sysctl_oid *sysctl;
+	struct sysctl_oid *conf_sysctl;
+	struct sysctl_oid *stat_sysctl;
 	struct sysctl_ctx_list conf_ctx;
 	struct sysctl_ctx_list stat_ctx;
 #define MLX4_EN_MAC_HASH_IDX 5

Modified: trunk/sys/ofed/drivers/net/mlx4/mlx4_stats.h
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/mlx4_stats.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/mlx4_stats.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2014 Mellanox Technologies Ltd.  All rights reserved.
  *
@@ -82,7 +83,6 @@
 	unsigned long tx_gt_1548_bytes_packets;
 	unsigned long rx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS];
 	unsigned long tx_prio[NUM_PRIORITIES][NUM_PRIORITY_STATS];
-#define NUM_PKT_STATS		72
 };
 
 struct mlx4_en_vf_stats {
@@ -97,7 +97,6 @@
 	unsigned long tx_multicast_packets;
 	unsigned long tx_broadcast_packets;
 	unsigned long tx_errors;
-#define NUM_VF_STATS		11
 };
 
 struct mlx4_en_vport_stats {
@@ -116,7 +115,6 @@
 	unsigned long tx_broadcast_packets;
 	unsigned long tx_broadcast_bytes;
 	unsigned long tx_errors;
-#define NUM_VPORT_STATS		15
 };
 
 struct mlx4_en_port_stats {
@@ -129,7 +127,7 @@
 	unsigned long rx_chksum_good;
 	unsigned long rx_chksum_none;
 	unsigned long tx_chksum_offload;
-#define NUM_PORT_STATS		8
+	unsigned long defrag_attempts;
 };
 
 struct mlx4_en_perf_stats {
@@ -139,7 +137,6 @@
 	u16 tx_coal_avg;
 	u16 rx_coal_avg;
 	u32 napi_quota;
-#define NUM_PERF_COUNTERS		6
 };
 
 struct mlx4_en_flow_stats {
@@ -151,8 +148,6 @@
 	u64 tx_pause_transition;
 };
 #define MLX4_NUM_PRIORITIES	8
-#define NUM_FLOW_PRIORITY_STATS	6
-#define NUM_FLOW_STATS		(NUM_FLOW_PRIORITY_STATS*MLX4_NUM_PRIORITIES)
 
 
 struct mlx4_en_stat_out_flow_control_mbox {
@@ -180,6 +175,4 @@
                          struct mlx4_en_vport_stats *vport_stats,
                          int reset);
 
-#define NUM_ALL_STATS	(NUM_PKT_STATS + NUM_FLOW_STATS + NUM_VPORT_STATS + \
-			 NUM_VF_STATS + NUM_PORT_STATS + NUM_PERF_STATS)
 #endif

Modified: trunk/sys/ofed/drivers/net/mlx4/mr.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/mr.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/mr.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/net/mlx4/pd.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/pd.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/pd.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006, 2007 Cisco Systems, Inc.  All rights reserved.
  * Copyright (c) 2005, 2014 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/net/mlx4/port.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/port.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/port.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved.
  *
@@ -30,6 +31,8 @@
  * SOFTWARE.
  */
 
+#define	LINUXKPI_PARAM_PREFIX mlx4_
+
 #include <linux/errno.h>
 #include <linux/if_ether.h>
 #include <linux/module.h>
@@ -980,38 +983,6 @@
 	return 0;
 }
 
-void mlx4_set_stats_bitmap(struct mlx4_dev *dev, unsigned long *stats_bitmap)
-{
-	int last_i = 0;
-
-	bitmap_zero(stats_bitmap, NUM_ALL_STATS);
-
-	if (mlx4_is_slave(dev)) {
-		last_i = dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN ?
-			NUM_PKT_STATS + NUM_FLOW_STATS : NUM_PKT_STATS;
-	} else {
-		bitmap_set(stats_bitmap, last_i, NUM_PKT_STATS);
-		last_i = NUM_PKT_STATS;
-
-		if (dev->caps.flags2 &
-		    MLX4_DEV_CAP_FLAG2_FLOWSTATS_EN) {
-			bitmap_set(stats_bitmap, last_i, NUM_FLOW_STATS);
-			last_i += NUM_FLOW_STATS;
-		}
-	}
-
-	if (mlx4_is_slave(dev))
-		bitmap_set(stats_bitmap, last_i, NUM_VF_STATS);
-	last_i += NUM_VF_STATS;
-
-	if (mlx4_is_master(dev))
-		bitmap_set(stats_bitmap, last_i, NUM_VPORT_STATS);
-	last_i += NUM_VPORT_STATS;
-
-	bitmap_set(stats_bitmap, last_i, NUM_PORT_STATS);
-}
-EXPORT_SYMBOL(mlx4_set_stats_bitmap);
-
 int mlx4_get_slave_from_roce_gid(struct mlx4_dev *dev, int port, u8 *gid, int *slave_id)
 {
 	struct mlx4_priv *priv = mlx4_priv(dev);

Modified: trunk/sys/ofed/drivers/net/mlx4/profile.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/profile.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/profile.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005, 2014 Mellanox Technologies. All rights reserved.
@@ -199,10 +200,17 @@
 			init_hca->log_num_cqs = profile[i].log_num;
 			break;
 		case MLX4_RES_EQ:
-			dev->caps.num_eqs     = roundup_pow_of_two(min_t(unsigned, dev_cap->max_eqs,
-									 MAX_MSIX));
-			init_hca->eqc_base    = profile[i].start;
-			init_hca->log_num_eqs = ilog2(dev->caps.num_eqs);
+			if (dev_cap->flags2 & MLX4_DEV_CAP_FLAG2_SYS_EQS) {
+				init_hca->log_num_eqs	= 0x1f;
+				init_hca->eqc_base	= profile[i].start;
+				init_hca->num_sys_eqs	= dev_cap->num_sys_eqs;
+			} else {
+				 dev->caps.num_eqs	= roundup_pow_of_two(
+					min_t(unsigned,
+						dev_cap->max_eqs, MAX_MSIX));
+				init_hca->eqc_base	= profile[i].start;
+				init_hca->log_num_eqs	= ilog2(dev->caps.num_eqs);
+			}
 			break;
 		case MLX4_RES_DMPT:
 			dev->caps.num_mpts	= profile[i].num;

Modified: trunk/sys/ofed/drivers/net/mlx4/qp.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/qp.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/qp.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved.
@@ -242,6 +243,9 @@
 	u64 out_param;
 	int err;
 
+	/* Turn off all unsupported QP allocation flags */
+	flags &= dev->caps.alloc_res_qp_mask;
+
 	if (mlx4_is_mfunc(dev)) {
 		set_param_l(&in_param, (((u32) flags) << 24) | (u32) cnt);
 		set_param_h(&in_param, align);

Modified: trunk/sys/ofed/drivers/net/mlx4/reset.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/reset.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/reset.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006, 2007 Cisco Systems, Inc.  All rights reserved.
  * Copyright (c) 2007, 2008, 2014 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/net/mlx4/resource_tracker.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/resource_tracker.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/resource_tracker.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005, 2006, 2007, 2008, 2014 Mellanox Technologies.
@@ -1544,7 +1545,10 @@
 	switch (op) {
 	case RES_OP_RESERVE:
 		count = get_param_l(&in_param) & 0xffffff;
-		flags = get_param_l(&in_param) >> 24;
+		/* Turn off all unsupported QP allocation flags that the
+		 * slave tries to set.
+		 */
+		flags = (get_param_l(&in_param) >> 24) & dev->caps.alloc_res_qp_mask;
 		align = get_param_h(&in_param);
 		err = mlx4_grant_resource(dev, slave, RES_QP, count, 0);
 		if (err)

Modified: trunk/sys/ofed/drivers/net/mlx4/sense.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/sense.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/sense.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007, 2014 Mellanox Technologies. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/net/mlx4/srq.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/srq.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/srq.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
  * Copyright (c) 2007, 2008, 2014 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/drivers/net/mlx4/sys_tune.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/sys_tune.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/sys_tune.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2010, 2014 Mellanox Technologies. All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/net/mlx4/utils.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/utils.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/utils.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*	$OpenBSD: if_trunk.c,v 1.30 2007/01/31 06:20:19 reyk Exp $	*/
 
 /*

Modified: trunk/sys/ofed/drivers/net/mlx4/utils.h
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/utils.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/utils.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2014 Mellanox Technologies Ltd.  All rights reserved.
  *

Modified: trunk/sys/ofed/drivers/net/mlx4/xrcd.c
===================================================================
--- trunk/sys/ofed/drivers/net/mlx4/xrcd.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/drivers/net/mlx4/xrcd.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006, 2007 Cisco Systems, Inc.  All rights reserved.
  * Copyright (c) 2007 Mellanox Technologies. All rights reserved.

Modified: trunk/sys/ofed/include/asm/atomic-long.h
===================================================================
--- trunk/sys/ofed/include/asm/atomic-long.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/asm/atomic-long.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/asm/atomic.h
===================================================================
--- trunk/sys/ofed/include/asm/atomic.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/asm/atomic.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/asm/byteorder.h
===================================================================
--- trunk/sys/ofed/include/asm/byteorder.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/asm/byteorder.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/asm/current.h
===================================================================
--- trunk/sys/ofed/include/asm/current.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/asm/current.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/asm/fcntl.h
===================================================================
--- trunk/sys/ofed/include/asm/fcntl.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/asm/fcntl.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/asm/io.h
===================================================================
--- trunk/sys/ofed/include/asm/io.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/asm/io.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/asm/page.h
===================================================================
--- trunk/sys/ofed/include/asm/page.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/asm/page.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/asm/pgtable.h
===================================================================
--- trunk/sys/ofed/include/asm/pgtable.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/asm/pgtable.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/asm/semaphore.h
===================================================================
--- trunk/sys/ofed/include/asm/semaphore.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/asm/semaphore.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/asm/system.h
===================================================================
--- trunk/sys/ofed/include/asm/system.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/asm/system.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/asm/types.h
===================================================================
--- trunk/sys/ofed/include/asm/types.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/asm/types.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/asm/uaccess.h
===================================================================
--- trunk/sys/ofed/include/asm/uaccess.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/asm/uaccess.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/bitmap.h
===================================================================
--- trunk/sys/ofed/include/linux/bitmap.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/bitmap.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/bitops.h
===================================================================
--- trunk/sys/ofed/include/linux/bitops.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/bitops.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
@@ -165,6 +166,8 @@
 		mask = (*addr) & ~BIT_MASK(offs);
 		if (mask)
 			return (bit + __ffsl(mask));
+		if (size - bit <= BITS_PER_LONG)
+			return (size);
 		bit += BITS_PER_LONG;
 		addr++;
 	}
@@ -203,6 +206,8 @@
 		mask = ~(*addr) & ~BIT_MASK(offs);
 		if (mask)
 			return (bit + __ffsl(mask));
+		if (size - bit <= BITS_PER_LONG)
+			return (size);
 		bit += BITS_PER_LONG;
 		addr++;
 	}

Modified: trunk/sys/ofed/include/linux/cache.h
===================================================================
--- trunk/sys/ofed/include/linux/cache.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/cache.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/cdev.h
===================================================================
--- trunk/sys/ofed/include/linux/cdev.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/cdev.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/clocksource.h
===================================================================
--- trunk/sys/ofed/include/linux/clocksource.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/clocksource.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/compat.h
===================================================================
--- trunk/sys/ofed/include/linux/compat.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/compat.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/compiler.h
===================================================================
--- trunk/sys/ofed/include/linux/compiler.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/compiler.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,8 +1,10 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * 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
@@ -62,5 +64,29 @@
 #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")
+
+#define	ACCESS_ONCE(x)			(*(volatile __typeof(x) *)&(x))
+  
+#define	WRITE_ONCE(x,v) do {		\
+	barrier();			\
+	ACCESS_ONCE(x) = (v);		\
+	barrier();			\
+} while (0)
+
+#define	READ_ONCE(x) ({			\
+	__typeof(x) __var = ({		\
+		barrier();		\
+		ACCESS_ONCE(x);		\
+	});				\
+	barrier();			\
+	__var;				\
+})
+
 #endif	/* _LINUX_COMPILER_H_ */

Modified: trunk/sys/ofed/include/linux/completion.h
===================================================================
--- trunk/sys/ofed/include/linux/completion.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/completion.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/ctype.h
===================================================================
--- trunk/sys/ofed/include/linux/ctype.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/ctype.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/delay.h
===================================================================
--- trunk/sys/ofed/include/linux/delay.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/delay.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/device.h
===================================================================
--- trunk/sys/ofed/include/linux/device.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/device.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,8 +1,9 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -294,15 +295,19 @@
 	int unit;
 
 	bsddev = NULL;
+	unit = -1;
+
 	if (dev->devt) {
 		unit = MINOR(dev->devt);
 		bsddev = devclass_get_device(dev->class->bsdclass, unit);
-	} else
-		unit = -1;
-	if (bsddev == NULL)
+	} else if (dev->parent == NULL) {
+		bsddev = devclass_get_device(dev->class->bsdclass, 0);
+	}
+	if (bsddev == NULL && dev->parent != NULL) {
 		bsddev = device_add_child(dev->parent->bsddev,
 		    dev->class->kobj.name, unit);
-	if (bsddev) {
+	}
+	if (bsddev != NULL) {
 		if (dev->devt == 0)
 			dev->devt = makedev(0, device_get_unit(bsddev));
 		device_set_softc(bsddev, dev);

Modified: trunk/sys/ofed/include/linux/dma-attrs.h
===================================================================
--- trunk/sys/ofed/include/linux/dma-attrs.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/dma-attrs.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/dma-mapping.h
===================================================================
--- trunk/sys/ofed/include/linux/dma-mapping.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/dma-mapping.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
@@ -126,12 +127,12 @@
 	size_t align;
 	void *mem;
 
-	if (dev->dma_mask)
+	if (dev != NULL && 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_map, size, flag, 0, high, align,
+	mem = (void *)kmem_alloc_contig(kmem_arena, size, flag, 0, high, align,
 	    0, VM_MEMATTR_DEFAULT);
 	if (mem)
 		*dma_handle = vtophys(mem);
@@ -153,7 +154,7 @@
     dma_addr_t dma_handle)
 {
 
-	kmem_free(kmem_map, (vm_offset_t)cpu_addr, size);
+	kmem_free(kmem_arena, (vm_offset_t)cpu_addr, size);
 }
 
 /* XXX This only works with no iommu. */

Modified: trunk/sys/ofed/include/linux/dmapool.h
===================================================================
--- trunk/sys/ofed/include/linux/dmapool.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/dmapool.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/err.h
===================================================================
--- trunk/sys/ofed/include/linux/err.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/err.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/errno.h
===================================================================
--- trunk/sys/ofed/include/linux/errno.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/errno.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/etherdevice.h
===================================================================
--- trunk/sys/ofed/include/linux/etherdevice.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/etherdevice.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007 Cisco Systems, Inc.  All rights reserved.
  * Copyright (c) 2014 Mellanox Technologies, Ltd. All rights reserved.
@@ -37,6 +38,9 @@
 
 #include <linux/types.h>
 
+#include <sys/random.h>
+#include <sys/libkern.h>
+
 #define	ETH_MODULE_SFF_8079		1
 #define	ETH_MODULE_SFF_8079_LEN		256
 #define	ETH_MODULE_SFF_8472		2
@@ -113,4 +117,32 @@
 	memcpy(dst, src, 6);
 }
 
+static inline bool
+ether_addr_equal(const u8 *pa, const u8 *pb)
+{
+	return (memcmp(pa, pb, 6) == 0);
+}
+
+static inline bool
+ether_addr_equal_64bits(const u8 *pa, const u8 *pb)
+{
+	return (memcmp(pa, pb, 6) == 0);
+}
+
+static inline void
+eth_broadcast_addr(u8 *pa)
+{
+	memset(pa, 0xff, 6);
+}
+
+static inline void
+random_ether_addr(u8 * dst)
+{
+	if (read_random(dst, 6) == 0)
+		arc4rand(dst, 6, 0);
+
+	dst[0] &= 0xfe;
+	dst[0] |= 0x02;
+}
+
 #endif /* _LINUX_ETHERDEVICE */

Modified: trunk/sys/ofed/include/linux/ethtool.h
===================================================================
--- trunk/sys/ofed/include/linux/ethtool.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/ethtool.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/file.h
===================================================================
--- trunk/sys/ofed/include/linux/file.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/file.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,8 +1,9 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -48,7 +49,10 @@
 {
 	struct file *file;
 
-	file = fget_unlocked(curthread->td_proc->p_fd, fd);
+	if (fget_unlocked(curthread->td_proc->p_fd, fd, NULL, 0, &file,
+	    NULL) != 0) {
+		return (NULL);
+	}
 	return (struct linux_file *)file->f_data;
 }
 
@@ -70,15 +74,16 @@
 {
 	struct file *file;
 
-	file = fget_unlocked(curthread->td_proc->p_fd, fd);
-	if (file == NULL)
+	if (fget_unlocked(curthread->td_proc->p_fd, fd, NULL, 0, &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->td_proc->p_fd, file, fd, curthread);
+	fdclose(curthread, file, fd);
 
 	/* drop extra reference */
 	fdrop(file, curthread);
@@ -89,8 +94,8 @@
 {
 	struct file *file;
 
-	file = fget_unlocked(curthread->td_proc->p_fd, fd);
-	if (file == NULL) {
+	if (fget_unlocked(curthread->td_proc->p_fd, fd, NULL, 0, &file,
+	    NULL) != 0) {
 		filp->_file = NULL;
 	} else {
 		filp->_file = file;
@@ -116,6 +121,21 @@
 	return fd;
 }
 
+static inline int
+get_unused_fd_flags(int flags)
+{
+	struct file *file;
+	int error;
+	int fd;
+
+	error = falloc(curthread, &file, &fd, flags);
+	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)
 {

Modified: trunk/sys/ofed/include/linux/fs.h
===================================================================
--- trunk/sys/ofed/include/linux/fs.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/fs.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/gfp.h
===================================================================
--- trunk/sys/ofed/include/linux/gfp.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/gfp.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
@@ -68,7 +69,7 @@
 _get_page(gfp_t mask)
 {
 
-	return kmem_malloc(kmem_map, PAGE_SIZE, mask);
+	return kmem_malloc(kmem_arena, PAGE_SIZE, mask);
 }
 
 #define	get_zeroed_page(mask)	_get_page((mask) | M_ZERO)
@@ -81,7 +82,7 @@
 
 	if (page == 0)
 		return;
-	kmem_free(kmem_map, page, PAGE_SIZE);
+	kmem_free(kmem_arena, page, PAGE_SIZE);
 }
 
 static inline void
@@ -91,18 +92,18 @@
 	if (m->object != kmem_object)
 		panic("__free_page:  Freed page %p not allocated via wrappers.",
 		    m);
-	kmem_free(kmem_map, (vm_offset_t)page_address(m), PAGE_SIZE);
+	kmem_free(kmem_arena, (vm_offset_t)page_address(m), PAGE_SIZE);
 }
 
 static inline void
-__free_pages(void *p, unsigned int order)
+__free_pages(struct page *m, unsigned int order)
 {
 	size_t size;
 
-	if (p == 0)
+	if (m == NULL)
 		return;
 	size = PAGE_SIZE << order;
-	kmem_free(kmem_map, (vm_offset_t)p, size);
+	kmem_free(kmem_arena, (vm_offset_t)page_address(m), size);
 }
 
 static inline void free_pages(uintptr_t addr, unsigned int order)
@@ -124,7 +125,7 @@
 	size_t size;
 
 	size = PAGE_SIZE << order;
-	page = kmem_alloc_contig(kmem_map, size, gfp_mask, 0, -1,
+	page = kmem_alloc_contig(kmem_arena, size, gfp_mask, 0, -1,
 	    size, 0, VM_MEMATTR_DEFAULT);
 	if (page == 0)
 		return (NULL);

Modified: trunk/sys/ofed/include/linux/hardirq.h
===================================================================
--- trunk/sys/ofed/include/linux/hardirq.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/hardirq.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/idr.h
===================================================================
--- trunk/sys/ofed/include/linux/idr.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/idr.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/if_arp.h
===================================================================
--- trunk/sys/ofed/include/linux/if_arp.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/if_arp.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/if_ether.h
===================================================================
--- trunk/sys/ofed/include/linux/if_ether.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/if_ether.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/if_vlan.h
===================================================================
--- trunk/sys/ofed/include/linux/if_vlan.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/if_vlan.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/in.h
===================================================================
--- trunk/sys/ofed/include/linux/in.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/in.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
@@ -37,7 +38,7 @@
 #include <netinet/in.h>
 #include <asm/byteorder.h>
 
-#define	ipv4_is_zeronet		IN_ZERONET
-#define	ipv4_is_loopback	IN_LOOPBACK
+#define	ipv4_is_zeronet(be)	IN_ZERONET(ntohl(be))
+#define	ipv4_is_loopback(be)	IN_LOOPBACK(ntohl(be))
 
 #endif	/* _LINUX_IN_H_ */

Modified: trunk/sys/ofed/include/linux/in6.h
===================================================================
--- trunk/sys/ofed/include/linux/in6.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/in6.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
@@ -30,8 +31,6 @@
 #ifndef	_LINUX_IN6_H_
 #define	_LINUX_IN6_H_
 
-#ifndef KLD_MODULE
 #include "opt_inet6.h"
-#endif
 
 #endif	/* _LINUX_IN6_H_ */

Modified: trunk/sys/ofed/include/linux/inet.h
===================================================================
--- trunk/sys/ofed/include/linux/inet.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/inet.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/inetdevice.h
===================================================================
--- trunk/sys/ofed/include/linux/inetdevice.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/inetdevice.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,8 +1,9 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,6 +26,7 @@
  * 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	_LINUX_INETDEVICE_H_
@@ -33,25 +35,61 @@
 #include <linux/netdevice.h>
 
 static inline struct net_device *
-ip_dev_find(struct net *net, uint32_t addr)
+ip_dev_find(struct vnet *vnet, 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;
+	CURVNET_SET_QUIET(vnet);
 	ifa = ifa_ifwithaddr((struct sockaddr *)&sin);
+	CURVNET_RESTORE();
 	if (ifa) {
 		ifp = ifa->ifa_ifp;
 		if_ref(ifp);
 		ifa_free(ifa);
+	} else {
+		ifp = NULL;
 	}
 	return (ifp);
 }
 
+static inline struct net_device *
+ip6_dev_find(struct vnet *vnet, struct in6_addr addr)
+{
+	struct sockaddr_in6 sin6;
+	struct ifaddr *ifa = NULL;
+	struct ifnet *ifp = NULL;
+	int x;
+
+	memset(&sin6, 0, sizeof(sin6));
+	sin6.sin6_addr = addr;
+	sin6.sin6_len = sizeof(sin6);
+	sin6.sin6_family = AF_INET6;
+	CURVNET_SET_QUIET(vnet);
+	if (IN6_IS_SCOPE_LINKLOCAL(&addr) ||
+	    IN6_IS_ADDR_MC_INTFACELOCAL(&addr)) {
+		/* XXX need to search all scope ID's */
+		for (x = 0; x <= V_if_index && x < 65536; x++) {
+			sin6.sin6_addr.s6_addr16[1] = htons(x);
+			ifa = ifa_ifwithaddr((struct sockaddr *)&sin6);
+			if (ifa != NULL)
+				break;
+		}
+	} else {
+		ifa = ifa_ifwithaddr((struct sockaddr *)&sin6);
+	}
+	if (ifa != NULL) {
+		ifp = ifa->ifa_ifp;
+		if_ref(ifp);
+		ifa_free(ifa);
+	}
+	CURVNET_RESTORE();
+	return (ifp);
+}
+
 #endif	/* _LINUX_INETDEVICE_H_ */

Modified: trunk/sys/ofed/include/linux/init.h
===================================================================
--- trunk/sys/ofed/include/linux/init.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/init.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/interrupt.h
===================================================================
--- trunk/sys/ofed/include/linux/interrupt.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/interrupt.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
@@ -118,6 +119,39 @@
 }
 
 static inline int
+enable_irq(unsigned int irq)
+{
+	struct irq_ent *irqe;
+	struct device *dev;
+
+	dev = _pci_find_irq_dev(irq);
+	if (dev == NULL)
+		return -EINVAL;
+	irqe = _irq_ent(dev, irq);
+	if (irqe == NULL || irqe->tag != NULL)
+		return -EINVAL;
+	return -bus_setup_intr(dev->bsddev, irqe->res, INTR_TYPE_NET | INTR_MPSAFE,
+	    NULL, _irq_handler, irqe, &irqe->tag);
+}
+
+static inline void
+disable_irq(unsigned int irq)
+{
+	struct irq_ent *irqe;
+	struct device *dev;
+
+	dev = _pci_find_irq_dev(irq);
+	if (dev == NULL)
+		return;
+	irqe = _irq_ent(dev, irq);
+	if (irqe == NULL)
+		return;
+	if (irqe->tag != NULL)
+		bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag);
+	irqe->tag = NULL;
+}
+
+static inline int
 bind_irq_to_cpu(unsigned int irq, int cpu_id)
 {
 	struct irq_ent *irqe;
@@ -148,7 +182,8 @@
 	irqe = _irq_ent(dev, irq);
 	if (irqe == NULL)
 		return;
-	bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag);
+	if (irqe->tag != NULL)
+		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);

Modified: trunk/sys/ofed/include/linux/io-mapping.h
===================================================================
--- trunk/sys/ofed/include/linux/io-mapping.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/io-mapping.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/io.h
===================================================================
--- trunk/sys/ofed/include/linux/io.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/io.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/ioctl.h
===================================================================
--- trunk/sys/ofed/include/linux/ioctl.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/ioctl.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/jhash.h
===================================================================
--- trunk/sys/ofed/include/linux/jhash.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/jhash.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #ifndef	_LINUX_JHASH_H_
 #define	_LINUX_JHASH_H_
 

Modified: trunk/sys/ofed/include/linux/jiffies.h
===================================================================
--- trunk/sys/ofed/include/linux/jiffies.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/jiffies.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
@@ -42,7 +43,7 @@
 
 	tv.tv_sec = msec / 1000;
 	tv.tv_usec = (msec % 1000) * 1000;
-	return (tvtohz(&tv));
+	return (tvtohz(&tv) - 1);
 }
 
 #define jiffies                 ticks

Modified: trunk/sys/ofed/include/linux/kdev_t.h
===================================================================
--- trunk/sys/ofed/include/linux/kdev_t.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/kdev_t.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/kernel.h
===================================================================
--- trunk/sys/ofed/include/linux/kernel.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/kernel.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
@@ -63,7 +64,14 @@
 
 #define BUG()			panic("BUG")
 #define BUG_ON(condition)	do { if (condition) BUG(); } while(0)
-#define	WARN_ON			BUG_ON
+#define	WARN_ON(cond) ({					\
+      bool __ret = (cond);					\
+      if (__ret) {						\
+		printf("WARNING %s failed at %s:%d\n",		\
+		    __stringify(cond), __FILE__, __LINE__);	\
+      }								\
+      unlikely(__ret);						\
+})
 
 #undef	ALIGN
 #define	ALIGN(x, y)		roundup2((x), (y))

Modified: trunk/sys/ofed/include/linux/kmod.h
===================================================================
--- trunk/sys/ofed/include/linux/kmod.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/kmod.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/kobject.h
===================================================================
--- trunk/sys/ofed/include/linux/kobject.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/kobject.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
@@ -87,29 +88,7 @@
 	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_set_name_vargs(struct kobject *kobj, const char *fmt, va_list);
 int	kobject_add(struct kobject *kobj, struct kobject *parent,
 	    const char *fmt, ...);
 

Modified: trunk/sys/ofed/include/linux/kref.h
===================================================================
--- trunk/sys/ofed/include/linux/kref.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/kref.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,8 +1,10 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * 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
@@ -32,8 +34,10 @@
 #include <sys/types.h>
 #include <sys/refcount.h>
 
+#include <asm/atomic.h>
+
 struct kref {
-        volatile u_int count;
+	atomic_t refcount;
 };
 
 static inline void
@@ -40,7 +44,7 @@
 kref_init(struct kref *kref)
 {
 
-	refcount_init(&kref->count, 1);
+	refcount_init(&kref->refcount.counter, 1);
 }
 
 static inline void
@@ -47,7 +51,7 @@
 kref_get(struct kref *kref)
 {
 
-	refcount_acquire(&kref->count);
+	refcount_acquire(&kref->refcount.counter);
 }
 
 static inline int
@@ -54,7 +58,7 @@
 kref_put(struct kref *kref, void (*rel)(struct kref *kref))
 {
 
-	if (refcount_release(&kref->count)) {
+	if (refcount_release(&kref->refcount.counter)) {
 		rel(kref);
 		return 1;
 	}
@@ -61,4 +65,25 @@
 	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_ */

Modified: trunk/sys/ofed/include/linux/kthread.h
===================================================================
--- trunk/sys/ofed/include/linux/kthread.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/kthread.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/ktime.h
===================================================================
--- trunk/sys/ofed/include/linux/ktime.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/ktime.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2014 Mellanox Technologies, Ltd.
  * All rights reserved.

Modified: trunk/sys/ofed/include/linux/linux_compat.c
===================================================================
--- trunk/sys/ofed/include/linux/linux_compat.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/linux_compat.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
@@ -41,6 +42,7 @@
 #include <sys/fcntl.h>
 #include <sys/file.h>
 #include <sys/filio.h>
+#include <sys/rwlock.h>
 
 #include <vm/vm.h>
 #include <vm/pmap.h>
@@ -52,6 +54,7 @@
 #include <linux/device.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/moduleparam.h>
 #include <linux/cdev.h>
 #include <linux/file.h>
 #include <linux/sysfs.h>
@@ -63,6 +66,10 @@
 
 #include <vm/vm_pager.h>
 
+#include <linux/workqueue.h>
+
+SYSCTL_NODE(_compat, OID_AUTO, linuxkpi, CTLFLAG_RW, 0, "LinuxKPI parameters");
+
 MALLOC_DEFINE(M_KMALLOC, "linux", "Linux kmalloc compat");
 
 #include <linux/rbtree.h>
@@ -77,7 +84,6 @@
 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;
@@ -89,8 +95,51 @@
 }
 
 RB_GENERATE(linux_root, rb_node, __entry, panic_cmp);
- 
+
 int
+kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list args)
+{
+	va_list tmp_va;
+	int len;
+	char *old;
+	char *name;
+	char dummy;
+
+	old = kobj->name;
+
+	if (old && fmt == NULL)
+		return (0);
+
+	/* compute length of string */
+	va_copy(tmp_va, args);
+	len = vsnprintf(&dummy, 0, fmt, tmp_va);
+	va_end(tmp_va);
+
+	/* account for zero termination */
+	len++;
+
+	/* check for error */
+	if (len < 1)
+		return (-EINVAL);
+
+	/* allocate memory for string */
+	name = kzalloc(len, GFP_KERNEL);
+	if (name == NULL)
+		return (-ENOMEM);
+	vsnprintf(name, len, fmt, args);
+	kobj->name = name;
+
+	/* free old string */
+	kfree(old);
+
+	/* filter new string */
+	for (; *name != '\0'; name++)
+		if (*name == '/')
+			*name = '!';
+	return (0);
+}
+
+int
 kobject_set_name(struct kobject *kobj, const char *fmt, ...)
 {
 	va_list args;
@@ -451,10 +500,10 @@
 			}
 			*offset = 0;
 			if (vma.vm_page_prot != VM_MEMATTR_DEFAULT) {
-				VM_OBJECT_LOCK(*object);
+				VM_OBJECT_WLOCK(*object);
 				vm_object_set_memattr(*object,
 				    vma.vm_page_prot);
-				VM_OBJECT_UNLOCK(*object);
+				VM_OBJECT_WUNLOCK(*object);
 			}
 		}
 	} else
@@ -578,6 +627,7 @@
 	.fo_ioctl = linux_file_ioctl,
 	.fo_chmod = invfo_chmod,
 	.fo_chown = invfo_chown,
+	.fo_sendfile = invfo_sendfile,
 };
 
 /*
@@ -662,7 +712,7 @@
 	size_t size;
 
 	size = count * PAGE_SIZE;
-	off = kmem_alloc_nofault(kernel_map, size);
+	off = kva_alloc(size);
 	if (off == 0)
 		return (NULL);
 	vmmap_add((void *)off, size);
@@ -680,7 +730,7 @@
 	if (vmmap == NULL)
 		return;
 	pmap_qremove((vm_offset_t)addr, vmmap->vm_size / PAGE_SIZE);
-	kmem_free(kernel_map, (vm_offset_t)addr, vmmap->vm_size);
+	kva_free((vm_offset_t)addr, vmmap->vm_size);
 	kfree(vmmap);
 }
 
@@ -880,6 +930,50 @@
 	return (isdone);
 }
 
+void
+linux_delayed_work_fn(void *arg)
+{
+	struct delayed_work *work;
+
+	work = arg;
+	taskqueue_enqueue(work->work.taskqueue, &work->work.work_task);
+}
+
+void
+linux_work_fn(void *context, int pending)
+{
+	struct work_struct *work;
+
+	work = context;
+	work->fn(work);
+}
+
+void
+linux_flush_fn(void *context, int pending)
+{
+}
+
+struct workqueue_struct *
+linux_create_workqueue_common(const 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);
+	atomic_set(&wq->draining, 0);
+	taskqueue_start_threads(&wq->taskqueue, cpus, PWAIT, "%s", name);
+
+	return (wq);
+}
+
+void
+destroy_workqueue(struct workqueue_struct *wq)
+{
+	taskqueue_free(wq->taskqueue);
+	kfree(wq);
+}
+
 static void
 linux_compat_init(void *arg)
 {

Modified: trunk/sys/ofed/include/linux/linux_idr.c
===================================================================
--- trunk/sys/ofed/include/linux/linux_idr.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/linux_idr.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
@@ -185,20 +186,21 @@
 	return (res);
 }
 
-void *
-idr_find(struct idr *idr, int id)
+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;
-	id &= MAX_ID_MASK;
-	mtx_lock(&idr->lock);
 	il = idr->top;
 	layer = idr->layers - 1;
 	if (il == NULL || id > idr_max(idr))
-		goto out;
+		return (NULL);
 	while (layer && il) {
 		il = il->ary[idr_pos(id, layer)];
 		layer--;
@@ -205,7 +207,16 @@
 	}
 	if (il != NULL)
 		res = il->ary[id & IDR_MASK];
-out:
+	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);
 }
@@ -257,7 +268,8 @@
 		return (il);
 	}
 	il = malloc(sizeof(*il), M_IDR, M_ZERO | M_NOWAIT);
-	bitmap_fill(&il->bitmap, IDR_SIZE);
+	if (il != NULL)
+		bitmap_fill(&il->bitmap, IDR_SIZE);
 	return (il);
 }
 
@@ -331,13 +343,13 @@
 	}
 	error = 0;
 out:
-	mtx_unlock(&idr->lock);
 #ifdef INVARIANTS
-	if (error == 0 && idr_find(idr, id) != ptr) {
+	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);
 }
 
@@ -408,7 +420,7 @@
 		 * to be rare.
 		 */
 		if (idx == IDR_SIZE) {
-			starting_id = id + (1 << (layer+1 * IDR_BITS));
+			starting_id = id + (1 << ((layer + 1) * IDR_BITS));
 			goto restart;
 		}
 		if (idx > sidx)
@@ -438,12 +450,12 @@
 	}
 	error = 0;
 out:
-	mtx_unlock(&idr->lock);
 #ifdef INVARIANTS
-	if (error == 0 && idr_find(idr, id) != ptr) {
+	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);
 }

Modified: trunk/sys/ofed/include/linux/linux_radix.c
===================================================================
--- trunk/sys/ofed/include/linux/linux_radix.c	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/linux_radix.c	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/list.h
===================================================================
--- trunk/sys/ofed/include/linux/list.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/list.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/lockdep.h
===================================================================
--- trunk/sys/ofed/include/linux/lockdep.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/lockdep.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/log2.h
===================================================================
--- trunk/sys/ofed/include/linux/log2.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/log2.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/math64.h
===================================================================
--- trunk/sys/ofed/include/linux/math64.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/math64.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007 Cisco Systems, Inc.  All rights reserved.
  * Copyright (c) 2014 Mellanox Technologies, Ltd. All rights reserved.

Modified: trunk/sys/ofed/include/linux/miscdevice.h
===================================================================
--- trunk/sys/ofed/include/linux/miscdevice.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/miscdevice.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/mlx4/cmd.h
===================================================================
--- trunk/sys/ofed/include/linux/mlx4/cmd.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/mlx4/cmd.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006 Cisco Systems, Inc.  All rights reserved.
  *

Modified: trunk/sys/ofed/include/linux/mlx4/cq.h
===================================================================
--- trunk/sys/ofed/include/linux/mlx4/cq.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/mlx4/cq.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Cisco Systems, Inc.  All rights reserved.
  *

Modified: trunk/sys/ofed/include/linux/mlx4/device.h
===================================================================
--- trunk/sys/ofed/include/linux/mlx4/device.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/mlx4/device.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006, 2007 Cisco Systems, Inc.  All rights reserved.
  *
@@ -199,6 +200,7 @@
 	MLX4_DEV_CAP_FLAG2_EQE_STRIDE		= 1LL <<  23,
 	MLX4_DEV_CAP_FLAG2_UPDATE_QP_SRC_CHECK_LB = 1LL << 24,
 	MLX4_DEV_CAP_FLAG2_RX_CSUM_MODE		= 1LL <<  25,
+	MLX4_DEV_CAP_FLAG2_SYS_EQS		= 1LL <<  26,
 };
 
 /* bit enums for an 8-bit flags field indicating special use
@@ -218,6 +220,23 @@
 };
 
 enum {
+	MLX4_QUERY_FUNC_FLAGS_BF_RES_QP	= 1LL << 0
+};
+
+/* bit enums for an 8-bit flags field indicating special use
+ * QPs which require special handling in qp_reserve_range.
+ * Currently, this only includes QPs used by the ETH interface,
+ * where we expect to use blueflame.  These QPs must not have
+ * bits 6 and 7 set in their qp number.
+ *
+ * This enum may use only bits 0..7.
+ */
+enum {
+	MLX4_RESERVE_ETH_BF_QP		= 1 << 7,
+};
+
+
+enum {
 	MLX4_DEV_CAP_64B_EQE_ENABLED	= 1LL << 0,
 	MLX4_DEV_CAP_64B_CQE_ENABLED	= 1LL << 1
 };
@@ -473,6 +492,7 @@
 	int			num_cqs;
 	int			max_cqes;
 	int			reserved_cqs;
+	int			num_sys_eqs;
 	int			num_eqs;
 	int			reserved_eqs;
 	int			num_comp_vectors;
@@ -531,6 +551,7 @@
 	u32			max_basic_counters;
 	u32			max_extended_counters;
 	u8			def_counter_index[MLX4_MAX_PORTS + 1];
+	u8			alloc_res_qp_mask;
 };
 
 struct mlx4_buf_list {
@@ -1253,7 +1274,6 @@
 void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac);
 int mlx4_get_base_qpn(struct mlx4_dev *dev, u8 port);
 int __mlx4_replace_mac(struct mlx4_dev *dev, u8 port, int qpn, u64 new_mac);
-void mlx4_set_stats_bitmap(struct mlx4_dev *dev, unsigned long *stats_bitmap);
 int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu,
 			  u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx);
 int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn,
@@ -1317,7 +1337,7 @@
 
 int mlx4_FLOW_STEERING_IB_UC_QP_RANGE(struct mlx4_dev *dev, u32 min_range_qpn, u32 max_range_qpn);
 
-int mlx4_read_clock(struct mlx4_dev *dev);
+s64 mlx4_read_clock(struct mlx4_dev *dev);
 int mlx4_get_internal_clock_params(struct mlx4_dev *dev,
 				   struct mlx4_clock_params *params);
 

Modified: trunk/sys/ofed/include/linux/mlx4/doorbell.h
===================================================================
--- trunk/sys/ofed/include/linux/mlx4/doorbell.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/mlx4/doorbell.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.

Modified: trunk/sys/ofed/include/linux/mlx4/driver.h
===================================================================
--- trunk/sys/ofed/include/linux/mlx4/driver.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/mlx4/driver.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006 Cisco Systems, Inc.  All rights reserved.
  *

Modified: trunk/sys/ofed/include/linux/mlx4/qp.h
===================================================================
--- trunk/sys/ofed/include/linux/mlx4/qp.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/mlx4/qp.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Cisco Systems, Inc.  All rights reserved.
  *

Modified: trunk/sys/ofed/include/linux/mlx4/srq.h
===================================================================
--- trunk/sys/ofed/include/linux/mlx4/srq.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/mlx4/srq.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Cisco Systems, Inc.  All rights reserved.
  *

Modified: trunk/sys/ofed/include/linux/mm.h
===================================================================
--- trunk/sys/ofed/include/linux/mm.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/mm.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/module.h
===================================================================
--- trunk/sys/ofed/include/linux/module.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/module.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/moduleparam.h
===================================================================
--- trunk/sys/ofed/include/linux/moduleparam.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/moduleparam.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,8 +1,9 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -25,209 +26,106 @@
  * 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: head/sys/compat/linuxkpi/common/include/linux/moduleparam.h 300721 2016-05-26 09:04:14Z hselasky $
  */
-
 #ifndef	_LINUX_MODULEPARAM_H_
 #define	_LINUX_MODULEPARAM_H_
 
+#include <sys/types.h>
+#include <sys/sysctl.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;
+#ifndef LINUXKPI_PARAM_PARENT
+#define	LINUXKPI_PARAM_PARENT	_compat_linuxkpi
+#endif
 
-typedef int (*param_set_fn)(const char *val, struct kernel_param *kp);
-typedef int (*param_get_fn)(char *buffer, struct kernel_param *kp);
+#ifndef LINUXKPI_PARAM_PREFIX
+#define	LINUXKPI_PARAM_PREFIX	/* empty prefix is the default */
+#endif
 
-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;
-};
+#ifndef LINUXKPI_PARAM_PERM
+#define	LINUXKPI_PARAM_PERM(perm) (((perm) & 0222) ? CTLFLAG_RWTUN : CTLFLAG_RDTUN)
+#endif
 
-#define	KPARAM_ISBOOL	2
+#define	LINUXKPI_PARAM_CONCAT_SUB(a,b,c,d) a##b##c##d
+#define	LINUXKPI_PARAM_CONCAT(...) LINUXKPI_PARAM_CONCAT_SUB(__VA_ARGS__)
+#define	LINUXKPI_PARAM_PASS(...) __VA_ARGS__
+#define	LINUXKPI_PARAM_DESC(name) LINUXKPI_PARAM_CONCAT(linuxkpi_,LINUXKPI_PARAM_PREFIX,name,_desc)
+#define	LINUXKPI_PARAM_NAME(name) LINUXKPI_PARAM_CONCAT(LINUXKPI_PARAM_PREFIX,name,,)
 
-struct kparam_string {
-	unsigned int maxlen;
-	char *string;
-};
+#define	LINUXKPI_PARAM_bool(name, var, perm)				\
+	extern const char LINUXKPI_PARAM_DESC(name)[];			\
+	LINUXKPI_PARAM_PASS(SYSCTL_BOOL(LINUXKPI_PARAM_PARENT, OID_AUTO,\
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
+	LINUXKPI_PARAM_DESC(name)))
 
-struct kparam_array
-{
-	unsigned int	max;
-	unsigned int	*num;
-	param_set_fn	set;
-	param_get_fn	get;
-	unsigned int	elemsize;
-	void 		*elem;
-};
+#define	LINUXKPI_PARAM_byte(name, var, perm)				\
+	extern const char LINUXKPI_PARAM_DESC(name)[];			\
+	LINUXKPI_PARAM_PASS(SYSCTL_U8(LINUXKPI_PARAM_PARENT, OID_AUTO,	\
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
+	LINUXKPI_PARAM_DESC(name)))
 
-static inline void
-param_sysinit(struct kernel_param *param)
-{
-}
+#define	LINUXKPI_PARAM_short(name, var, perm)				\
+	extern const char LINUXKPI_PARAM_DESC(name)[];			\
+	LINUXKPI_PARAM_PASS(SYSCTL_S16(LINUXKPI_PARAM_PARENT, OID_AUTO,	\
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
+	LINUXKPI_PARAM_DESC(name)))
 
-#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	LINUXKPI_PARAM_ushort(name, var, perm)				\
+	extern const char LINUXKPI_PARAM_DESC(name)[];			\
+	LINUXKPI_PARAM_PASS(SYSCTL_U16(LINUXKPI_PARAM_PARENT, OID_AUTO,	\
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
+	LINUXKPI_PARAM_DESC(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	LINUXKPI_PARAM_int(name, var, perm)				\
+	extern const char LINUXKPI_PARAM_DESC(name)[];			\
+	LINUXKPI_PARAM_PASS(SYSCTL_INT(LINUXKPI_PARAM_PARENT, OID_AUTO,	\
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0,\
+	LINUXKPI_PARAM_DESC(name)))
 
-#define	module_param(var, type, mode)					\
-	module_param_named(var, var, type, mode)
+#define	LINUXKPI_PARAM_uint(name, var, perm)				\
+	extern const char LINUXKPI_PARAM_DESC(name)[];			\
+	LINUXKPI_PARAM_PASS(SYSCTL_UINT(LINUXKPI_PARAM_PARENT, OID_AUTO, \
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
+	LINUXKPI_PARAM_DESC(name)))
 
-#define module_param_array(var, type, addr_argc, mode)                  \
-        module_param_named(var, var, type, mode)
+#define	LINUXKPI_PARAM_long(name, var, perm)				\
+	extern const char LINUXKPI_PARAM_DESC(name)[];			\
+	LINUXKPI_PARAM_PASS(SYSCTL_LONG(LINUXKPI_PARAM_PARENT, OID_AUTO, \
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
+	LINUXKPI_PARAM_DESC(name)))
 
-#define	MODULE_PARM_DESC(name, desc)
+#define	LINUXKPI_PARAM_ulong(name, var, perm)				\
+	extern const char LINUXKPI_PARAM_DESC(name)[];			\
+	LINUXKPI_PARAM_PASS(SYSCTL_ULONG(LINUXKPI_PARAM_PARENT, OID_AUTO, \
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
+	LINUXKPI_PARAM_DESC(name)))
 
-static inline int
-param_set_byte(const char *val, struct kernel_param *kp)
-{
+#define	module_param_string(name, str, len, perm)			\
+	extern const char LINUXKPI_PARAM_DESC(name)[];			\
+	LINUXKPI_PARAM_PASS(SYSCTL_STRING(LINUXKPI_PARAM_PARENT, OID_AUTO, \
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), (str), (len), \
+	LINUXKPI_PARAM_DESC(name)))
 
-	return 0;
-}
+#define	module_param_named(name, var, type, mode)	\
+	LINUXKPI_PARAM_##type(name, var, mode)
 
-static inline int
-param_get_byte(char *buffer, struct kernel_param *kp)
-{
+#define	module_param(var, type, mode)	\
+	LINUXKPI_PARAM_##type(var, var, mode)
 
-	return 0;
-}
+#define	module_param_named_unsafe(name, var, type, mode) \
+	LINUXKPI_PARAM_##type(name, var, mode)
 
+#define	module_param_unsafe(var, type, mode) \
+	LINUXKPI_PARAM_##type(var, var, mode)
 
-static inline int
-param_set_short(const char *val, struct kernel_param *kp)
-{
+#define	module_param_array(var, type, addr_argc, mode)
 
-	return 0;
-}
+#define	MODULE_PARM_DESC(name, desc) \
+	const char LINUXKPI_PARAM_DESC(name)[] = { desc }
 
-static inline int 
-param_get_short(char *buffer, struct kernel_param *kp)
-{
+SYSCTL_DECL(_compat_linuxkpi);
 
-	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_ */
+#endif					/* _LINUX_MODULEPARAM_H_ */

Modified: trunk/sys/ofed/include/linux/mount.h
===================================================================
--- trunk/sys/ofed/include/linux/mount.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/mount.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/mutex.h
===================================================================
--- trunk/sys/ofed/include/linux/mutex.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/mutex.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/net.h
===================================================================
--- trunk/sys/ofed/include/linux/net.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/net.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/netdevice.h
===================================================================
--- trunk/sys/ofed/include/linux/netdevice.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/netdevice.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,8 +1,9 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2017 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -38,6 +39,7 @@
 #include <net/if_var.h>
 #include <net/if_dl.h>
 
+#include <linux/list.h>
 #include <linux/completion.h>
 #include <linux/device.h>
 #include <linux/workqueue.h>
@@ -44,19 +46,34 @@
 #include <linux/net.h>
 #include <linux/notifier.h>
 
-struct net {
-};
+#ifdef VIMAGE
+#define	init_net *vnet0
+#else
+#define	init_net *((struct vnet *)0)
+#endif
 
-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))
+static inline struct ifnet *
+dev_get_by_index(struct vnet *vnet, int if_index)
+{
+	struct ifnet *retval;
 
+	CURVNET_SET(vnet);
+	retval = ifnet_byindex_ref(if_index);
+	CURVNET_RESTORE();
+
+	return (retval);
+}
+
+#define	dev_hold(d)	if_ref(d)
+#define	dev_put(d)	if_rele(d)
+#define	dev_net(d)	((d)->if_vnet)
+
+#define	net_eq(a,b)	((a) == (b))
+
 #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)

Modified: trunk/sys/ofed/include/linux/notifier.h
===================================================================
--- trunk/sys/ofed/include/linux/notifier.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/notifier.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/page.h
===================================================================
--- trunk/sys/ofed/include/linux/page.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/page.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
@@ -33,6 +34,7 @@
 
 #include <sys/param.h>
 
+#include <machine/atomic.h>
 #include <vm/vm.h>
 #include <vm/vm_page.h>
 

Modified: trunk/sys/ofed/include/linux/pci.h
===================================================================
--- trunk/sys/ofed/include/linux/pci.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/pci.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,8 +1,9 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -115,9 +116,9 @@
 #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
+#define	IORESOURCE_MEM	(1 << SYS_RES_MEMORY)
+#define	IORESOURCE_IO	(1 << SYS_RES_IOPORT)
+#define	IORESOURCE_IRQ	(1 << SYS_RES_IRQ)
 
 struct pci_dev;
 
@@ -213,6 +214,21 @@
 	return rle->count;
 }
 
+static inline int
+pci_resource_type(struct pci_dev *pdev, int bar)
+{
+	struct pci_map *pm;
+
+	pm = pci_find_bar(pdev->dev.bsddev, PCIR_BAR(bar));
+	if (!pm)
+		return (-1);
+
+	if (PCI_BAR_IO(pm->pm_value))
+		return (SYS_RES_IOPORT);
+	else
+		return (SYS_RES_MEMORY);
+}
+
 /*
  * All drivers just seem to want to inspect the type not flags.
  */
@@ -219,11 +235,12 @@
 static inline int
 pci_resource_flags(struct pci_dev *pdev, int bar)
 {
-	struct resource_list_entry *rle;
+	int type;
 
-	if ((rle = _pci_get_bar(pdev, bar)) == NULL)
+	type = pci_resource_type(pdev, bar);
+	if (type < 0)
 		return (0);
-	return rle->type;
+	return (1 << type);
 }
 
 static inline const char *
@@ -283,8 +300,8 @@
 	int rid;
 	int type;
 
-	type = pci_resource_flags(pdev, bar);
-	if (type == 0)
+	type = pci_resource_type(pdev, bar);
+	if (type < 0)
 		return (-ENODEV);
 	rid = PCIR_BAR(bar);
 	if (bus_alloc_resource_any(pdev->dev.bsddev, type, &rid,
@@ -333,6 +350,15 @@
 {
 
 	pci_release_msi(pdev->dev.bsddev);
+
+	/*
+	 * The MSIX IRQ numbers associated with this PCI device are no
+	 * longer valid and might be re-assigned. Make sure
+	 * linux_pci_find_irq_dev() does no longer see them by
+	 * resetting their references to zero:
+	 */
+	pdev->dev.msix = 0;
+	pdev->dev.msix_max = 0;
 }
 
 #define	PCI_CAP_ID_EXP	PCIY_EXPRESS
@@ -566,7 +592,11 @@
 /*
  * 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)
 {

Modified: trunk/sys/ofed/include/linux/poll.h
===================================================================
--- trunk/sys/ofed/include/linux/poll.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/poll.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/printk.h
===================================================================
--- trunk/sys/ofed/include/linux/printk.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/printk.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/radix-tree.h
===================================================================
--- trunk/sys/ofed/include/linux/radix-tree.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/radix-tree.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/random.h
===================================================================
--- trunk/sys/ofed/include/linux/random.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/random.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,8 +1,9 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,11 +32,13 @@
 #define	_LINUX_RANDOM_H_
 
 #include <sys/random.h>
+#include <sys/libkern.h>
 
 static inline void
 get_random_bytes(void *buf, int nbytes)
 {
-	read_random(buf, nbytes);
+	if (read_random(buf, nbytes) == 0)
+		arc4rand(buf, nbytes, 0);
 }
 
 #endif	/* _LINUX_RANDOM_H_ */

Modified: trunk/sys/ofed/include/linux/rbtree.h
===================================================================
--- trunk/sys/ofed/include/linux/rbtree.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/rbtree.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/rtnetlink.h
===================================================================
--- trunk/sys/ofed/include/linux/rtnetlink.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/rtnetlink.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/rwlock.h
===================================================================
--- trunk/sys/ofed/include/linux/rwlock.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/rwlock.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/rwsem.h
===================================================================
--- trunk/sys/ofed/include/linux/rwsem.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/rwsem.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/scatterlist.h
===================================================================
--- trunk/sys/ofed/include/linux/scatterlist.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/scatterlist.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/sched.h
===================================================================
--- trunk/sys/ofed/include/linux/sched.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/sched.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
@@ -103,7 +104,7 @@
 		kick_proc0();						\
 } while (0)
 
-#define	cond_resched()	if (!cold)	sched_relinquish(curthread)
+#define	cond_resched()	do { if (!cold) sched_relinquish(curthread); } while (0)
 
 #define	sched_yield()	sched_relinquish(curthread)
 

Modified: trunk/sys/ofed/include/linux/semaphore.h
===================================================================
--- trunk/sys/ofed/include/linux/semaphore.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/semaphore.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/slab.h
===================================================================
--- trunk/sys/ofed/include/linux/slab.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/slab.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/socket.h
===================================================================
--- trunk/sys/ofed/include/linux/socket.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/socket.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/spinlock.h
===================================================================
--- trunk/sys/ofed/include/linux/spinlock.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/spinlock.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Added: trunk/sys/ofed/include/linux/srcu.h
===================================================================
--- trunk/sys/ofed/include/linux/srcu.h	                        (rev 0)
+++ trunk/sys/ofed/include/linux/srcu.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -0,0 +1,73 @@
+/* $MidnightBSD$ */
+/*-
+ * 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: stable/10/sys/ofed/include/linux/srcu.h 293151 2016-01-04 09:37:05Z hselasky $
+ */
+#ifndef	_LINUX_SRCU_H_
+#define	_LINUX_SRCU_H_
+
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/sx.h>
+
+struct srcu_struct {
+	struct sx sx;
+};
+
+static inline int
+init_srcu_struct(struct srcu_struct *srcu)
+{
+	sx_init(&srcu->sx, "SleepableRCU");
+	return (0);
+}
+
+static inline void
+cleanup_srcu_struct(struct srcu_struct *srcu)
+{
+	sx_destroy(&srcu->sx);
+}
+
+static inline int
+srcu_read_lock(struct srcu_struct *srcu)
+{
+	sx_slock(&srcu->sx);
+	return (0);
+}
+
+static inline void
+srcu_read_unlock(struct srcu_struct *srcu, int key)
+{
+	sx_sunlock(&srcu->sx);
+}
+
+static inline void
+synchronize_srcu(struct srcu_struct *srcu)
+{
+	sx_xlock(&srcu->sx);
+	sx_xunlock(&srcu->sx);
+}
+
+#endif					/* _LINUX_SRCU_H_ */


Property changes on: trunk/sys/ofed/include/linux/srcu.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/sys/ofed/include/linux/stddef.h
===================================================================
--- trunk/sys/ofed/include/linux/stddef.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/stddef.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/string.h
===================================================================
--- trunk/sys/ofed/include/linux/string.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/string.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/sysfs.h
===================================================================
--- trunk/sys/ofed/include/linux/sysfs.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/sysfs.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/timer.h
===================================================================
--- trunk/sys/ofed/include/linux/timer.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/timer.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
@@ -48,7 +49,7 @@
 do {									\
 	(timer)->function = (func);					\
 	(timer)->data = (dat);						\
-	callout_init(&(timer)->timer_callout, CALLOUT_MPSAFE);		\
+	callout_init(&(timer)->timer_callout, 1);			\
 } while (0)
 
 #define	init_timer(timer)						\
@@ -55,7 +56,7 @@
 do {									\
 	(timer)->function = NULL;					\
 	(timer)->data = 0;						\
-	callout_init(&(timer)->timer_callout, CALLOUT_MPSAFE);		\
+	callout_init(&(timer)->timer_callout, 1);			\
 } while (0)
 
 extern void mod_timer(struct timer_list *, unsigned long);

Modified: trunk/sys/ofed/include/linux/types.h
===================================================================
--- trunk/sys/ofed/include/linux/types.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/types.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
@@ -36,8 +37,6 @@
 #include <linux/compiler.h>
 #include <asm/types.h>
 
-#define	__read_mostly __attribute__((__section__(".data.read_mostly")))
-
 #ifndef __bitwise__
 #ifdef __CHECKER__
 #define __bitwise__ __attribute__((bitwise))

Modified: trunk/sys/ofed/include/linux/uaccess.h
===================================================================
--- trunk/sys/ofed/include/linux/uaccess.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/uaccess.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/vmalloc.h
===================================================================
--- trunk/sys/ofed/include/linux/vmalloc.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/vmalloc.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/wait.h
===================================================================
--- trunk/sys/ofed/include/linux/wait.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/wait.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/linux/workqueue.h
===================================================================
--- trunk/sys/ofed/include/linux/workqueue.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/linux/workqueue.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,8 +1,9 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -34,10 +35,13 @@
 #include <linux/timer.h>
 #include <linux/slab.h>
 
+#include <asm/atomic.h>
+
 #include <sys/taskqueue.h>
 
 struct workqueue_struct {
 	struct taskqueue	*taskqueue;
+	atomic_t		draining;
 };
 
 struct work_struct {
@@ -46,11 +50,19 @@
 	void			(*fn)(struct work_struct *);
 };
 
+typedef __typeof(((struct work_struct *)0)->fn) work_func_t;
+
 struct delayed_work {
 	struct work_struct	work;
 	struct callout		timer;
 };
 
+extern void linux_work_fn(void *, int);
+extern void linux_flush_fn(void *, int);
+extern void linux_delayed_work_fn(void *);
+extern struct workqueue_struct *linux_create_workqueue_common(const char *, int);
+extern void destroy_workqueue(struct workqueue_struct *);
+
 static inline struct delayed_work *
 to_delayed_work(struct work_struct *work)
 {
@@ -58,30 +70,20 @@
  	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));		\
+	TASK_INIT(&(work)->work_task, 0, linux_work_fn, (work));		\
 } while (0)
 
 #define	INIT_DELAYED_WORK(_work, func)					\
 do {									\
 	INIT_WORK(&(_work)->work, func);				\
-	callout_init(&(_work)->timer, CALLOUT_MPSAFE);			\
+	callout_init(&(_work)->timer, 1);				\
 } while (0)
 
-#define	INIT_DEFERRABLE_WORK	INIT_DELAYED_WORK
+#define	INIT_DEFERRABLE_WORK(...) INIT_DELAYED_WORK(__VA_ARGS__)
 
 #define	schedule_work(work)						\
 do {									\
@@ -91,22 +93,17 @@
 
 #define	flush_scheduled_work()	flush_taskqueue(taskqueue_thread)
 
-static inline int queue_work (struct workqueue_struct *q, struct work_struct *work)
+static inline int
+queue_work(struct workqueue_struct *wq, struct work_struct *work)
 {
-	(work)->taskqueue = (q)->taskqueue;
-	/* Return opposite val to align with Linux logic */
-        return !taskqueue_enqueue((q)->taskqueue, &(work)->work_task);
+	work->taskqueue = wq->taskqueue;
+	/* Check for draining */
+	if (atomic_read(&wq->draining) != 0)
+		return (!work->work_task.ta_pending);
+	/* Return opposite value to align with Linux logic */
+	return (!taskqueue_enqueue(wq->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)
@@ -113,70 +110,65 @@
 {
 	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);
-
+	if (atomic_read(&wq->draining) != 0) {
+	  	pending = work->work.work_task.ta_pending;
+	} else if (delay != 0) {
+		pending = work->work.work_task.ta_pending;
+		callout_reset(&work->timer, delay, linux_delayed_work_fn, work);
+	} else {
+		callout_stop(&work->timer);
+		pending = taskqueue_enqueue(work->work.taskqueue,
+		    &work->work.work_task);
+	}
 	return (!pending);
 }
 
-static inline bool schedule_delayed_work(struct delayed_work *dwork,
-                                         unsigned long delay)
+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);
-}
+	struct workqueue_struct wq;
 
-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);
+	wq.taskqueue = taskqueue_thread;
+	atomic_set(&wq.draining, 0);
+	return (queue_delayed_work(&wq, dwork, delay));
 }
 
-
 #define	create_singlethread_workqueue(name)				\
-	_create_workqueue_common(name, 1)
+	linux_create_workqueue_common(name, 1)
 
 #define	create_workqueue(name)						\
-	_create_workqueue_common(name, MAXCPU)
+	linux_create_workqueue_common(name, MAXCPU)
 
-static inline void
-destroy_workqueue(struct workqueue_struct *wq)
-{
-	taskqueue_free(wq->taskqueue);
-	kfree(wq);
-}
+#define	alloc_ordered_workqueue(name, flags)				\
+	linux_create_workqueue_common(name, 1)
 
+#define	alloc_workqueue(name, flags, max_active)			\
+	linux_create_workqueue_common(name, max_active)
+
 #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);
+	TASK_INIT(&flushtask, 0, linux_flush_fn, NULL);
 	taskqueue_enqueue(tq, &flushtask);
 	taskqueue_drain(tq, &flushtask);
 	PRELE(curproc);
 }
 
+static inline void
+drain_workqueue(struct workqueue_struct *wq)
+{
+	atomic_inc(&wq->draining);
+	flush_taskqueue(wq->taskqueue);
+	atomic_dec(&wq->draining);
+}
+
 static inline int
 cancel_work_sync(struct work_struct *work)
 {
@@ -213,7 +205,7 @@
 
 static inline bool
 mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork,
-		                      unsigned long delay)
+    unsigned long delay)
 {
 	cancel_delayed_work(dwork);
 	queue_delayed_work(wq, dwork, delay);

Modified: trunk/sys/ofed/include/net/addrconf.h
===================================================================
--- trunk/sys/ofed/include/net/addrconf.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/net/addrconf.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/net/arp.h
===================================================================
--- trunk/sys/ofed/include/net/arp.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/net/arp.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/net/if_inet6.h
===================================================================
--- trunk/sys/ofed/include/net/if_inet6.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/net/if_inet6.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/net/ip.h
===================================================================
--- trunk/sys/ofed/include/net/ip.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/net/ip.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/net/ip6_route.h
===================================================================
--- trunk/sys/ofed/include/net/ip6_route.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/net/ip6_route.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/net/ipv6.h
===================================================================
--- trunk/sys/ofed/include/net/ipv6.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/net/ipv6.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/net/neighbour.h
===================================================================
--- trunk/sys/ofed/include/net/neighbour.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/net/neighbour.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/net/netevent.h
===================================================================
--- trunk/sys/ofed/include/net/netevent.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/net/netevent.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Modified: trunk/sys/ofed/include/net/tcp.h
===================================================================
--- trunk/sys/ofed/include/net/tcp.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/net/tcp.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.

Index: trunk/sys/ofed/include/rdma/Kbuild
===================================================================
--- trunk/sys/ofed/include/rdma/Kbuild	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/Kbuild	2018-05-25 13:01:20 UTC (rev 9919)

Property changes on: trunk/sys/ofed/include/rdma/Kbuild
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/ofed/include/rdma/ib_addr.h
===================================================================
--- trunk/sys/ofed/include/rdma/ib_addr.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/ib_addr.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Voltaire Inc.  All rights reserved.
  * Copyright (c) 2005 Intel Corporation.  All rights reserved.
@@ -246,17 +247,21 @@
 #else
 static inline int iboe_get_rate(struct net_device *dev)
 {
-#ifdef __amd64__
-	if (dev->if_baudrate >= IF_Gbps(40ULL))
+	uintmax_t baudrate;
+	int exp;
+
+	baudrate = dev->if_baudrate;
+	for (exp = dev->if_baudrate_pf; exp > 0; exp--)
+		baudrate *= 10;
+	if (baudrate >= IF_Gbps(40))
 		return IB_RATE_40_GBPS;
-	else if (dev->if_baudrate >= IF_Gbps(30ULL))
+	else if (baudrate >= IF_Gbps(30))
 		return IB_RATE_30_GBPS;
-	else if (dev->if_baudrate >= IF_Gbps(20ULL))
+	else if (baudrate >= IF_Gbps(20))
 		return IB_RATE_20_GBPS;
-	else if (dev->if_baudrate >= IF_Gbps(10ULL))
+	else if (baudrate >= IF_Gbps(10))
 		return IB_RATE_10_GBPS;
 	else
-#endif
 		return IB_RATE_PORT_CURRENT;
 }
 #endif

Modified: trunk/sys/ofed/include/rdma/ib_cache.h
===================================================================
--- trunk/sys/ofed/include/rdma/ib_cache.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/ib_cache.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Intel Corporation. All rights reserved.

Modified: trunk/sys/ofed/include/rdma/ib_cm.h
===================================================================
--- trunk/sys/ofed/include/rdma/ib_cm.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/ib_cm.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004, 2005 Intel Corporation.  All rights reserved.
  * Copyright (c) 2004 Topspin Corporation.  All rights reserved.

Modified: trunk/sys/ofed/include/rdma/ib_fmr_pool.h
===================================================================
--- trunk/sys/ofed/include/rdma/ib_fmr_pool.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/ib_fmr_pool.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Corporation.  All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.

Modified: trunk/sys/ofed/include/rdma/ib_mad.h
===================================================================
--- trunk/sys/ofed/include/rdma/ib_mad.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/ib_mad.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Mellanox Technologies Ltd.  All rights reserved.
  * Copyright (c) 2004 Infinicon Corporation.  All rights reserved.
@@ -125,6 +126,7 @@
 	IB_MGMT_SA_DATA = 200,
 	IB_MGMT_DEVICE_HDR = 64,
 	IB_MGMT_DEVICE_DATA = 192,
+	IB_MGMT_MAD_SIZE = IB_MGMT_MAD_HDR + IB_MGMT_MAD_DATA,
 };
 
 struct ib_mad_hdr {

Modified: trunk/sys/ofed/include/rdma/ib_marshall.h
===================================================================
--- trunk/sys/ofed/include/rdma/ib_marshall.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/ib_marshall.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005-2006 Intel Corporation.  All rights reserved.
  *

Modified: trunk/sys/ofed/include/rdma/ib_pack.h
===================================================================
--- trunk/sys/ofed/include/rdma/ib_pack.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/ib_pack.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Corporation.  All rights reserved.
  *

Modified: trunk/sys/ofed/include/rdma/ib_pma.h
===================================================================
--- trunk/sys/ofed/include/rdma/ib_pma.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/ib_pma.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation.
  * All rights reserved.

Modified: trunk/sys/ofed/include/rdma/ib_sa.h
===================================================================
--- trunk/sys/ofed/include/rdma/ib_sa.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/ib_sa.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Voltaire, Inc.  All rights reserved.

Modified: trunk/sys/ofed/include/rdma/ib_smi.h
===================================================================
--- trunk/sys/ofed/include/rdma/ib_smi.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/ib_smi.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Mellanox Technologies Ltd.  All rights reserved.
  * Copyright (c) 2004 Infinicon Corporation.  All rights reserved.

Modified: trunk/sys/ofed/include/rdma/ib_umem.h
===================================================================
--- trunk/sys/ofed/include/rdma/ib_umem.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/ib_umem.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Cisco Systems.  All rights reserved.
  *

Modified: trunk/sys/ofed/include/rdma/ib_user_cm.h
===================================================================
--- trunk/sys/ofed/include/rdma/ib_user_cm.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/ib_user_cm.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Intel Corporation.  All rights reserved.

Modified: trunk/sys/ofed/include/rdma/ib_user_mad.h
===================================================================
--- trunk/sys/ofed/include/rdma/ib_user_mad.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/ib_user_mad.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Voltaire, Inc. All rights reserved.

Modified: trunk/sys/ofed/include/rdma/ib_user_sa.h
===================================================================
--- trunk/sys/ofed/include/rdma/ib_user_sa.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/ib_user_sa.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Intel Corporation.  All rights reserved.
  *

Modified: trunk/sys/ofed/include/rdma/ib_user_verbs.h
===================================================================
--- trunk/sys/ofed/include/rdma/ib_user_verbs.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/ib_user_verbs.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.

Modified: trunk/sys/ofed/include/rdma/ib_verbs.h
===================================================================
--- trunk/sys/ofed/include/rdma/ib_verbs.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/ib_verbs.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2004 Mellanox Technologies Ltd.  All rights reserved.
  * Copyright (c) 2004 Infinicon Corporation.  All rights reserved.
@@ -306,6 +307,56 @@
 	struct iw_protocol_stats	iw;
 };
 
+/* Define bits for the various functionality this port needs to be supported by
+ * the core.
+ */
+/* Management                           0x00000FFF */
+#define RDMA_CORE_CAP_IB_MAD            0x00000001
+#define RDMA_CORE_CAP_IB_SMI            0x00000002
+#define RDMA_CORE_CAP_IB_CM             0x00000004
+#define RDMA_CORE_CAP_IW_CM             0x00000008
+#define RDMA_CORE_CAP_IB_SA             0x00000010
+#define RDMA_CORE_CAP_OPA_MAD           0x00000020
+
+/* Address format                       0x000FF000 */
+#define RDMA_CORE_CAP_AF_IB             0x00001000
+#define RDMA_CORE_CAP_ETH_AH            0x00002000
+#define RDMA_CORE_CAP_OPA_AH            0x00004000
+
+/* Protocol                             0xFFF00000 */
+#define RDMA_CORE_CAP_PROT_IB           0x00100000
+#define RDMA_CORE_CAP_PROT_ROCE         0x00200000
+#define RDMA_CORE_CAP_PROT_IWARP        0x00400000
+#define RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP 0x00800000
+#define RDMA_CORE_CAP_PROT_RAW_PACKET   0x01000000
+#define RDMA_CORE_CAP_PROT_USNIC        0x02000000
+
+#define RDMA_CORE_PORT_IBA_IB          (RDMA_CORE_CAP_PROT_IB  \
+					| RDMA_CORE_CAP_IB_MAD \
+					| RDMA_CORE_CAP_IB_SMI \
+					| RDMA_CORE_CAP_IB_CM  \
+					| RDMA_CORE_CAP_IB_SA  \
+					| RDMA_CORE_CAP_AF_IB)
+#define RDMA_CORE_PORT_IBA_ROCE        (RDMA_CORE_CAP_PROT_ROCE \
+					| RDMA_CORE_CAP_IB_MAD  \
+					| RDMA_CORE_CAP_IB_CM   \
+					| RDMA_CORE_CAP_AF_IB   \
+					| RDMA_CORE_CAP_ETH_AH)
+#define RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP			\
+					(RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP \
+					| RDMA_CORE_CAP_IB_MAD  \
+					| RDMA_CORE_CAP_IB_CM   \
+					| RDMA_CORE_CAP_AF_IB   \
+					| RDMA_CORE_CAP_ETH_AH)
+#define RDMA_CORE_PORT_IWARP           (RDMA_CORE_CAP_PROT_IWARP \
+					| RDMA_CORE_CAP_IW_CM)
+#define RDMA_CORE_PORT_INTEL_OPA       (RDMA_CORE_PORT_IBA_IB  \
+					| RDMA_CORE_CAP_OPA_MAD)
+
+#define RDMA_CORE_PORT_RAW_PACKET	(RDMA_CORE_CAP_PROT_RAW_PACKET)
+
+#define RDMA_CORE_PORT_USNIC		(RDMA_CORE_CAP_PROT_USNIC)
+
 struct ib_port_attr {
 	enum ib_port_state	state;
 	enum ib_mtu		max_mtu;
@@ -1170,6 +1221,13 @@
 
 struct iw_cm_verbs;
 
+struct ib_port_immutable {
+	int                           pkey_tbl_len;
+	int                           gid_tbl_len;
+	u32                           core_cap_flags;
+	u32                           max_mad_size;
+};
+
 struct ib_device {
 	struct device                *dma_device;
 
@@ -1183,8 +1241,10 @@
 	struct list_head              client_data_list;
 
 	struct ib_cache               cache;
-	int                          *pkey_tbl_len;
-	int                          *gid_tbl_len;
+	/**
+	 * port_immutable is indexed by port number
+	 */
+	struct ib_port_immutable     *port_immutable;
 
 	int			      num_comp_vectors;
 
@@ -1387,6 +1447,14 @@
 	u8                           phys_port_cnt;
 	struct rb_root		     ib_uverbs_xrcd_table;
 	struct mutex		     xrcd_table_mutex;
+
+	/**
+	 * The following mandatory functions are used only at device
+	 * registration.  Keep functions such as these at the end of this
+	 * structure to avoid cache line misses when accessing struct ib_device
+	 * in fast paths.
+	 */
+	int (*get_port_immutable)(struct ib_device *, u8, struct ib_port_immutable *);
 };
 
 struct ib_client {
@@ -1453,6 +1521,252 @@
 enum rdma_link_layer rdma_port_get_link_layer(struct ib_device *device,
 					       u8 port_num);
 
+static inline bool rdma_protocol_ib(const struct ib_device *device, u8 port_num)
+{
+	return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_IB;
+}
+
+static inline bool rdma_protocol_roce(const struct ib_device *device, u8 port_num)
+{
+	return device->port_immutable[port_num].core_cap_flags &
+		(RDMA_CORE_CAP_PROT_ROCE | RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP);
+}
+
+static inline bool rdma_protocol_roce_udp_encap(const struct ib_device *device, u8 port_num)
+{
+	return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP;
+}
+
+static inline bool rdma_protocol_roce_eth_encap(const struct ib_device *device, u8 port_num)
+{
+	return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_ROCE;
+}
+
+static inline bool rdma_protocol_iwarp(const struct ib_device *device, u8 port_num)
+{
+	return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_IWARP;
+}
+
+static inline bool rdma_ib_or_roce(const struct ib_device *device, u8 port_num)
+{
+	return rdma_protocol_ib(device, port_num) ||
+		rdma_protocol_roce(device, port_num);
+}
+
+/**
+ * rdma_cap_ib_mad - Check if the port of a device supports Infiniband
+ * Management Datagrams.
+ * @device: Device to check
+ * @port_num: Port number to check
+ *
+ * Management Datagrams (MAD) are a required part of the InfiniBand
+ * specification and are supported on all InfiniBand devices.  A slightly
+ * extended version are also supported on OPA interfaces.
+ *
+ * Return: true if the port supports sending/receiving of MAD packets.
+ */
+static inline bool rdma_cap_ib_mad(const struct ib_device *device, u8 port_num)
+{
+	return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IB_MAD;
+}
+
+/**
+ * rdma_cap_opa_mad - Check if the port of device provides support for OPA
+ * Management Datagrams.
+ * @device: Device to check
+ * @port_num: Port number to check
+ *
+ * Intel OmniPath devices extend and/or replace the InfiniBand Management
+ * datagrams with their own versions.  These OPA MADs share many but not all of
+ * the characteristics of InfiniBand MADs.
+ *
+ * OPA MADs differ in the following ways:
+ *
+ *    1) MADs are variable size up to 2K
+ *       IBTA defined MADs remain fixed at 256 bytes
+ *    2) OPA SMPs must carry valid PKeys
+ *    3) OPA SMP packets are a different format
+ *
+ * Return: true if the port supports OPA MAD packet formats.
+ */
+static inline bool rdma_cap_opa_mad(struct ib_device *device, u8 port_num)
+{
+	return (device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_OPA_MAD)
+		== RDMA_CORE_CAP_OPA_MAD;
+}
+
+/**
+ * rdma_cap_ib_smi - Check if the port of a device provides an Infiniband
+ * Subnet Management Agent (SMA) on the Subnet Management Interface (SMI).
+ * @device: Device to check
+ * @port_num: Port number to check
+ *
+ * Each InfiniBand node is required to provide a Subnet Management Agent
+ * that the subnet manager can access.  Prior to the fabric being fully
+ * configured by the subnet manager, the SMA is accessed via a well known
+ * interface called the Subnet Management Interface (SMI).  This interface
+ * uses directed route packets to communicate with the SM to get around the
+ * chicken and egg problem of the SM needing to know what's on the fabric
+ * in order to configure the fabric, and needing to configure the fabric in
+ * order to send packets to the devices on the fabric.  These directed
+ * route packets do not need the fabric fully configured in order to reach
+ * their destination.  The SMI is the only method allowed to send
+ * directed route packets on an InfiniBand fabric.
+ *
+ * Return: true if the port provides an SMI.
+ */
+static inline bool rdma_cap_ib_smi(const struct ib_device *device, u8 port_num)
+{
+	return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IB_SMI;
+}
+
+/**
+ * rdma_cap_ib_cm - Check if the port of device has the capability Infiniband
+ * Communication Manager.
+ * @device: Device to check
+ * @port_num: Port number to check
+ *
+ * The InfiniBand Communication Manager is one of many pre-defined General
+ * Service Agents (GSA) that are accessed via the General Service
+ * Interface (GSI).  It's role is to facilitate establishment of connections
+ * between nodes as well as other management related tasks for established
+ * connections.
+ *
+ * Return: true if the port supports an IB CM (this does not guarantee that
+ * a CM is actually running however).
+ */
+static inline bool rdma_cap_ib_cm(const struct ib_device *device, u8 port_num)
+{
+	return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IB_CM;
+}
+
+/**
+ * rdma_cap_iw_cm - Check if the port of device has the capability IWARP
+ * Communication Manager.
+ * @device: Device to check
+ * @port_num: Port number to check
+ *
+ * Similar to above, but specific to iWARP connections which have a different
+ * managment protocol than InfiniBand.
+ *
+ * Return: true if the port supports an iWARP CM (this does not guarantee that
+ * a CM is actually running however).
+ */
+static inline bool rdma_cap_iw_cm(const struct ib_device *device, u8 port_num)
+{
+	return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IW_CM;
+}
+
+/**
+ * rdma_cap_ib_sa - Check if the port of device has the capability Infiniband
+ * Subnet Administration.
+ * @device: Device to check
+ * @port_num: Port number to check
+ *
+ * An InfiniBand Subnet Administration (SA) service is a pre-defined General
+ * Service Agent (GSA) provided by the Subnet Manager (SM).  On InfiniBand
+ * fabrics, devices should resolve routes to other hosts by contacting the
+ * SA to query the proper route.
+ *
+ * Return: true if the port should act as a client to the fabric Subnet
+ * Administration interface.  This does not imply that the SA service is
+ * running locally.
+ */
+static inline bool rdma_cap_ib_sa(const struct ib_device *device, u8 port_num)
+{
+	return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IB_SA;
+}
+
+/**
+ * rdma_cap_ib_mcast - Check if the port of device has the capability Infiniband
+ * Multicast.
+ * @device: Device to check
+ * @port_num: Port number to check
+ *
+ * InfiniBand multicast registration is more complex than normal IPv4 or
+ * IPv6 multicast registration.  Each Host Channel Adapter must register
+ * with the Subnet Manager when it wishes to join a multicast group.  It
+ * should do so only once regardless of how many queue pairs it subscribes
+ * to this group.  And it should leave the group only after all queue pairs
+ * attached to the group have been detached.
+ *
+ * Return: true if the port must undertake the additional adminstrative
+ * overhead of registering/unregistering with the SM and tracking of the
+ * total number of queue pairs attached to the multicast group.
+ */
+static inline bool rdma_cap_ib_mcast(const struct ib_device *device, u8 port_num)
+{
+	return rdma_cap_ib_sa(device, port_num);
+}
+
+/**
+ * rdma_cap_af_ib - Check if the port of device has the capability
+ * Native Infiniband Address.
+ * @device: Device to check
+ * @port_num: Port number to check
+ *
+ * InfiniBand addressing uses a port's GUID + Subnet Prefix to make a default
+ * GID.  RoCE uses a different mechanism, but still generates a GID via
+ * a prescribed mechanism and port specific data.
+ *
+ * Return: true if the port uses a GID address to identify devices on the
+ * network.
+ */
+static inline bool rdma_cap_af_ib(const struct ib_device *device, u8 port_num)
+{
+	return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_AF_IB;
+}
+
+/**
+ * rdma_cap_eth_ah - Check if the port of device has the capability
+ * Ethernet Address Handle.
+ * @device: Device to check
+ * @port_num: Port number to check
+ *
+ * RoCE is InfiniBand over Ethernet, and it uses a well defined technique
+ * to fabricate GIDs over Ethernet/IP specific addresses native to the
+ * port.  Normally, packet headers are generated by the sending host
+ * adapter, but when sending connectionless datagrams, we must manually
+ * inject the proper headers for the fabric we are communicating over.
+ *
+ * Return: true if we are running as a RoCE port and must force the
+ * addition of a Global Route Header built from our Ethernet Address
+ * Handle into our header list for connectionless packets.
+ */
+static inline bool rdma_cap_eth_ah(const struct ib_device *device, u8 port_num)
+{
+	return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_ETH_AH;
+}
+
+/**
+ * rdma_max_mad_size - Return the max MAD size required by this RDMA Port.
+ *
+ * @device: Device
+ * @port_num: Port number
+ *
+ * This MAD size includes the MAD headers and MAD payload.  No other headers
+ * are included.
+ *
+ * Return the max MAD size required by the Port.  Will return 0 if the port
+ * does not support MADs
+ */
+static inline size_t rdma_max_mad_size(const struct ib_device *device, u8 port_num)
+{
+	return device->port_immutable[port_num].max_mad_size;
+}
+
+/*
+ * Check if the device supports READ W/ INVALIDATE.
+ */
+static inline bool rdma_cap_read_inv(struct ib_device *dev, u32 port_num)
+{
+	/*
+	 * iWarp drivers must support READ W/ INVALIDATE.  No other protocol
+	 * has support for it yet.
+	 */
+	return rdma_protocol_iwarp(dev, port_num);
+}
+
 int ib_query_gid(struct ib_device *device,
 		 u8 port_num, int index, union ib_gid *gid);
 

Modified: trunk/sys/ofed/include/rdma/iw_cm.h
===================================================================
--- trunk/sys/ofed/include/rdma/iw_cm.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/iw_cm.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,6 +1,8 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Network Appliance, Inc. All rights reserved.
  * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
+ * Copyright (c) 2016 Chelsio Communications.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -64,6 +66,8 @@
 	u8 private_data_len;
 	void *provider_data;
 	struct socket *so;
+	u8 ord;
+	u8 ird;
 };
 
 /**
@@ -127,10 +131,13 @@
 	int		(*reject)(struct iw_cm_id *cm_id,
 				  const void *pdata, u8 pdata_len);
 
-	int		(*create_listen)(struct iw_cm_id *cm_id,
+	int		(*create_listen_ep)(struct iw_cm_id *cm_id,
 					 int backlog);
 
-	int		(*destroy_listen)(struct iw_cm_id *cm_id);
+	void		(*destroy_listen_ep)(struct iw_cm_id *cm_id);
+
+	void		(*newconn)(struct iw_cm_id *parent_cm_id,
+						struct socket *so);
 };
 
 /**

Modified: trunk/sys/ofed/include/rdma/rdma_cm.h
===================================================================
--- trunk/sys/ofed/include/rdma/rdma_cm.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/rdma_cm.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,6 +1,8 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 Voltaire Inc.  All rights reserved.
  * Copyright (c) 2005 Intel Corporation.  All rights reserved.
+ * Copyright (c) 2016 Chelsio Communications.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -330,4 +332,7 @@
  */
 void rdma_set_service_type(struct rdma_cm_id *id, int tos);
 
+int rdma_cma_any_addr(struct sockaddr *addr);
+int rdma_find_cmid_laddr(struct sockaddr_in *local_addr,
+		unsigned short dev_type, void **cm_id);
 #endif /* RDMA_CM_H */

Modified: trunk/sys/ofed/include/rdma/rdma_cm_ib.h
===================================================================
--- trunk/sys/ofed/include/rdma/rdma_cm_ib.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/rdma_cm_ib.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2006 Intel Corporation.  All rights reserved.
  *

Modified: trunk/sys/ofed/include/rdma/rdma_user_cm.h
===================================================================
--- trunk/sys/ofed/include/rdma/rdma_user_cm.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/rdma_user_cm.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005-2006 Intel Corporation.  All rights reserved.
  *

Modified: trunk/sys/ofed/include/rdma/sdp_socket.h
===================================================================
--- trunk/sys/ofed/include/rdma/sdp_socket.h	2018-05-25 12:57:02 UTC (rev 9918)
+++ trunk/sys/ofed/include/rdma/sdp_socket.h	2018-05-25 13:01:20 UTC (rev 9919)
@@ -1,8 +1,16 @@
+/* $MidnightBSD$ */
 /* Stuff that should go into include/linux/socket.h */
 
 #ifndef SDP_SOCKET_H
 #define SDP_SOCKET_H
 
+#ifndef __FreeBSD__
+#ifndef AF_INET_SDP
+#define AF_INET_SDP 27
+#define PF_INET_SDP AF_INET_SDP
+#endif
+#endif
+
 #ifndef SDP_ZCOPY_THRESH
 #define SDP_ZCOPY_THRESH 80
 #endif



More information about the Midnightbsd-cvs mailing list