Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Mar 2011 09:40:01 +0000 (UTC)
From:      Jeff Roberson <jeff@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r219819 - in head: sys/amd64/include sys/conf sys/dev/hptmv sys/i386/include sys/kern sys/net sys/netinet sys/netinet6 sys/sys sys/vm usr.sbin/config usr.sbin/ndp
Message-ID:  <201103210940.p2L9e1R5006486@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jeff
Date: Mon Mar 21 09:40:01 2011
New Revision: 219819
URL: http://svn.freebsd.org/changeset/base/219819

Log:
   - Merge changes to the base system to support OFED.  These include
     a wider arg2 for sysctl, updates to vlan code, IFT_INFINIBAND,
     and other miscellaneous small features.

Modified:
  head/sys/amd64/include/endian.h
  head/sys/conf/files
  head/sys/conf/kern.pre.mk
  head/sys/conf/options
  head/sys/dev/hptmv/hptproc.c
  head/sys/i386/include/endian.h
  head/sys/kern/kern_intr.c
  head/sys/kern/kern_jail.c
  head/sys/kern/kern_sx.c
  head/sys/kern/kern_sysctl.c
  head/sys/kern/subr_bus.c
  head/sys/net/if.c
  head/sys/net/if_arp.h
  head/sys/net/if_llatbl.h
  head/sys/net/if_types.h
  head/sys/net/if_var.h
  head/sys/net/if_vlan.c
  head/sys/net/if_vlan_var.h
  head/sys/netinet/if_ether.c
  head/sys/netinet6/in6.c
  head/sys/netinet6/nd6.c
  head/sys/netinet6/nd6_nbr.c
  head/sys/sys/bus.h
  head/sys/sys/file.h
  head/sys/sys/interrupt.h
  head/sys/sys/jail.h
  head/sys/sys/sx.h
  head/sys/sys/sysctl.h
  head/sys/vm/uma_core.c
  head/sys/vm/vm_map.c
  head/sys/vm/vm_map.h
  head/usr.sbin/config/config.h
  head/usr.sbin/config/mkmakefile.c
  head/usr.sbin/ndp/ndp.c

Modified: head/sys/amd64/include/endian.h
==============================================================================
--- head/sys/amd64/include/endian.h	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/amd64/include/endian.h	Mon Mar 21 09:40:01 2011	(r219819)
@@ -69,73 +69,59 @@ extern "C" {
 
 #if defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE_BUILTIN_CONSTANT_P)
 
-#define __byte_swap_int_var(x) \
-__extension__ ({ register __uint32_t __X = (x); \
-   __asm ("bswap %0" : "+r" (__X)); \
-   __X; })
+#define	__bswap64_const(_x)			\
+	(((_x) >> 56) |				\
+	(((_x) >> 40) & (0xffUL << 8)) |	\
+	(((_x) >> 24) & (0xffUL << 16)) |	\
+	(((_x) >> 8) & (0xffUL << 24)) |	\
+	(((_x) << 8) & (0xffUL << 32)) |	\
+	(((_x) << 24) & (0xffUL << 40)) |	\
+	(((_x) << 40) & (0xffUL << 48)) |	\
+	((_x) << 56))
+
+#define	__bswap32_const(_x)			\
+	(((_x) >> 24) |				\
+	(((_x) & (0xff << 16)) >> 8) |		\
+	(((_x) & (0xff << 8)) << 8) |		\
+	((_x) << 24))
 
-#ifdef __OPTIMIZE__
-
-#define	__byte_swap_int_const(x) \
-	((((x) & 0xff000000) >> 24) | \
-	 (((x) & 0x00ff0000) >>  8) | \
-	 (((x) & 0x0000ff00) <<  8) | \
-	 (((x) & 0x000000ff) << 24))
-#define	__byte_swap_int(x) (__builtin_constant_p(x) ? \
-	__byte_swap_int_const(x) : __byte_swap_int_var(x))
-
-#else	/* __OPTIMIZE__ */
-
-#define	__byte_swap_int(x) __byte_swap_int_var(x)
-
-#endif	/* __OPTIMIZE__ */
-
-#define __byte_swap_long_var(x) \
-__extension__ ({ register __uint64_t __X = (x); \
-   __asm ("bswap %0" : "+r" (__X)); \
-   __X; })
-
-#ifdef __OPTIMIZE__
-
-#define	__byte_swap_long_const(x) \
-	(((x >> 56) | \
-	 ((x >> 40) & 0xff00) | \
-	 ((x >> 24) & 0xff0000) | \
-	 ((x >> 8) & 0xff000000) | \
-	 ((x << 8) & (0xfful << 32)) | \
-	 ((x << 24) & (0xfful << 40)) | \
-	 ((x << 40) & (0xfful << 48)) | \
-	 ((x << 56))))
-
-#define	__byte_swap_long(x) (__builtin_constant_p(x) ? \
-	__byte_swap_long_const(x) : __byte_swap_long_var(x))
-
-#else	/* __OPTIMIZE__ */
-
-#define	__byte_swap_long(x) __byte_swap_long_var(x)
-
-#endif	/* __OPTIMIZE__ */
+#define __bswap16_const(_x)	(__uint16_t)((_x) << 8 | (_x) >> 8)
 
 static __inline __uint64_t
-__bswap64(__uint64_t _x)
+__bswap64_var(__uint64_t _x)
 {
 
-	return (__byte_swap_long(_x));
+	__asm ("bswap %0" : "+r" (_x));
+	return (_x);
 }
 
 static __inline __uint32_t
-__bswap32(__uint32_t _x)
+__bswap32_var(__uint32_t _x)
 {
 
-	return (__byte_swap_int(_x));
+	__asm ("bswap %0" : "+r" (_x));
+	return (_x);
 }
 
 static __inline __uint16_t
-__bswap16(__uint16_t _x)
+__bswap16_var(__uint16_t _x)
 {
-	return (_x << 8 | _x >> 8);
+
+	return (__bswap16_const(_x));
 }
 
+#define	__bswap64(_x)					\
+	(__builtin_constant_p(_x) ?			\
+	    __bswap64_const((__uint64_t)(_x)) : __bswap64_var(_x))
+
+#define	__bswap32(_x)					\
+	(__builtin_constant_p(_x) ?			\
+	    __bswap32_const((__uint32_t)(_x)) : __bswap32_var(_x))
+
+#define	__bswap16(_x)					\
+	(__builtin_constant_p(_x) ?			\
+	    __bswap16_const((__uint16_t)(_x)) : __bswap16_var(_x))
+
 #define	__htonl(x)	__bswap32(x)
 #define	__htons(x)	__bswap16(x)
 #define	__ntohl(x)	__bswap32(x)

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/conf/files	Mon Mar 21 09:40:01 2011	(r219819)
@@ -2791,6 +2791,281 @@ nlm/nlm_prot_server.c		optional nfslockd
 nlm/nlm_prot_svc.c		optional nfslockd | nfsd
 nlm/nlm_prot_xdr.c		optional nfslockd | nfsd
 nlm/sm_inter_xdr.c		optional nfslockd | nfsd
+
+# OpenFabrics Enterprise Distribution (Infiniband)
+ofed/include/linux/linux_compat.c		optional ofed		\
+	no-depend compile-with "${OFED_C}"
+ofed/include/linux/linux_idr.c			optional ofed		\
+	no-depend compile-with "${OFED_C}"
+ofed/include/linux/linux_radix.c		optional ofed		\
+	no-depend compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/addr.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"	
+ofed/drivers/infiniband/core/agent.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/cache.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+# XXX Mad.c must be ordered before cm.c for sysinit sets to occur in
+# the correct order.
+ofed/drivers/infiniband/core/mad.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/cm.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/cma.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/device.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/fmr_pool.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/iwcm.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/local_sa.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/mad_rmpp.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/multicast.c	optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/notice.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/packer.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/sa_query.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/smi.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/sysfs.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/ucm.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/ucma.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/ud_header.c	optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/umem.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/user_mad.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/uverbs_cmd.c	optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/uverbs_main.c	optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/uverbs_marshall.c	optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/verbs.c		optional ofed		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+
+ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c	optional ipoib		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/ipoib/"
+#ofed/drivers/infiniband/ulp/ipoib/ipoib_fs.c	optional ipoib		\
+#	no-depend							\
+#	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/ipoib/"
+ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c	optional ipoib		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/ipoib/"
+ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c	optional ipoib		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/ipoib/"
+ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c	optional ipoib	\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/ipoib/"
+ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c	optional ipoib		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/ipoib/"
+#ofed/drivers/infiniband/ulp/ipoib/ipoib_vlan.c	optional ipoib		\
+#	no-depend							\
+#	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/ipoib/"
+
+ofed/drivers/infiniband/ulp/sdp/sdp_bcopy.c	optional sdp		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/sdp/"
+ofed/drivers/infiniband/ulp/sdp/sdp_main.c	optional sdp		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/sdp/"
+ofed/drivers/infiniband/ulp/sdp/sdp_rx.c	optional sdp		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/sdp/"
+ofed/drivers/infiniband/ulp/sdp/sdp_cma.c	optional sdp		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/sdp/"
+ofed/drivers/infiniband/ulp/sdp/sdp_tx.c	optional sdp		\
+	no-depend							\
+	compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/sdp/"
+
+ofed/drivers/infiniband/hw/mlx4/ah.c		optional mlx4ib		\
+	no-depend obj-prefix "mlx4ib_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
+ofed/drivers/infiniband/hw/mlx4/cq.c		optional mlx4ib		\
+	no-depend obj-prefix "mlx4ib_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
+ofed/drivers/infiniband/hw/mlx4/doorbell.c	optional mlx4ib		\
+	no-depend obj-prefix "mlx4ib_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
+ofed/drivers/infiniband/hw/mlx4/mad.c		optional mlx4ib		\
+	no-depend obj-prefix "mlx4ib_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
+ofed/drivers/infiniband/hw/mlx4/main.c		optional mlx4ib		\
+	no-depend obj-prefix "mlx4ib_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
+ofed/drivers/infiniband/hw/mlx4/mr.c		optional mlx4ib		\
+	no-depend obj-prefix "mlx4ib_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
+ofed/drivers/infiniband/hw/mlx4/qp.c		optional mlx4ib		\
+	no-depend obj-prefix "mlx4ib_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
+ofed/drivers/infiniband/hw/mlx4/srq.c		optional mlx4ib		\
+	no-depend obj-prefix "mlx4ib_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
+ofed/drivers/infiniband/hw/mlx4/wc.c		optional mlx4ib		\
+	no-depend obj-prefix "mlx4ib_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/"
+
+ofed/drivers/net/mlx4/alloc.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/catas.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/cmd.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/cq.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/eq.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/fw.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/icm.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/intf.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/main.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/mcg.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/mr.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/pd.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/port.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/profile.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/qp.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/reset.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/sense.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/srq.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/xrcd.c			optional mlx4ib | mlxen	\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+
+ofed/drivers/net/mlx4/en_cq.c			optional mlxen		\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/en_frag.c			optional mlxen		\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/en_main.c			optional mlxen		\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/en_netdev.c		optional mlxen		\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/en_port.c			optional mlxen		\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/en_resources.c		optional mlxen		\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/en_rx.c			optional mlxen		\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+ofed/drivers/net/mlx4/en_tx.c			optional mlxen		\
+	no-depend obj-prefix "mlx4_"					\
+	compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/"
+
+ofed/drivers/infiniband/hw/mthca/mthca_allocator.c	optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_av.c		optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_catas.c		optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_cmd.c		optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_cq.c		optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_eq.c		optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_mad.c		optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_main.c		optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_mcg.c		optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_memfree.c	optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_mr.c		optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_pd.c		optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_profile.c	optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_provider.c	optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_qp.c		optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_reset.c		optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_srq.c		optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+ofed/drivers/infiniband/hw/mthca/mthca_uar.c		optional mthca	\
+	no-depend compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/mthca/"
+
 # crypto support
 opencrypto/cast.c		optional crypto | ipsec
 opencrypto/criov.c		optional crypto

Modified: head/sys/conf/kern.pre.mk
==============================================================================
--- head/sys/conf/kern.pre.mk	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/conf/kern.pre.mk	Mon Mar 21 09:40:01 2011	(r219819)
@@ -142,6 +142,14 @@ NORMAL_CTFCONVERT= [ -z "${CTFCONVERT}" 
 
 NORMAL_LINT=	${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC}
 
+# Infiniband C flags.  Correct include paths and omit errors that linux
+# does not honor.
+OFEDINCLUDES=	-I$S/ofed/include/
+OFEDNOERR=	-Wno-cast-qual -Wno-pointer-arith -fms-extensions
+OFEDCFLAGS=	${CFLAGS:N-I*} ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR}
+OFED_C_NOIMP=	${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR} ${PROF}
+OFED_C=		${OFED_C_NOIMP} ${.IMPSRC}
+
 GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
 SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}

Modified: head/sys/conf/options
==============================================================================
--- head/sys/conf/options	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/conf/options	Mon Mar 21 09:40:01 2011	(r219819)
@@ -862,3 +862,11 @@ X86BIOS
 # Flattened device tree options
 FDT		opt_platform.h
 FDT_DTB_STATIC	opt_platform.h
+
+# OFED Infiniband stack
+OFED		opt_ofed.h
+OFED_DEBUG_INIT	opt_ofed.h
+SDP		opt_ofed.h
+SDP_DEBUG	opt_ofed.h
+IPOIB_DEBUG	opt_ofed.h
+IPOIB_CM	opt_ofed.h

Modified: head/sys/dev/hptmv/hptproc.c
==============================================================================
--- head/sys/dev/hptmv/hptproc.c	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/dev/hptmv/hptproc.c	Mon Mar 21 09:40:01 2011	(r219819)
@@ -51,8 +51,8 @@ int hpt_rescan_all(void);
 static char hptproc_buffer[256];
 extern char DRIVER_VERSION[];
 
-#define FORMAL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, int arg2, \
-	struct sysctl_req *req
+#define FORMAL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1,	\
+	intptr_t arg2, struct sysctl_req *req
 #define REAL_HANDLER_ARGS oidp, arg1, arg2, req
 typedef struct sysctl_req HPT_GET_INFO;
 

Modified: head/sys/i386/include/endian.h
==============================================================================
--- head/sys/i386/include/endian.h	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/i386/include/endian.h	Mon Mar 21 09:40:01 2011	(r219819)
@@ -69,50 +69,59 @@ extern "C" {
 
 #if defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE_BUILTIN_CONSTANT_P)
 
-#define __byte_swap_int_var(x) \
-__extension__ ({ register __uint32_t __X = (x); \
-   __asm ("bswap %0" : "+r" (__X)); \
-   __X; })
-
-#ifdef __OPTIMIZE__
-
-#define	__byte_swap_int_const(x) \
-	((((x) & 0xff000000) >> 24) | \
-	 (((x) & 0x00ff0000) >>  8) | \
-	 (((x) & 0x0000ff00) <<  8) | \
-	 (((x) & 0x000000ff) << 24))
-#define	__byte_swap_int(x) (__builtin_constant_p(x) ? \
-	__byte_swap_int_const(x) : __byte_swap_int_var(x))
+#define	__bswap64_const(_x)			\
+	(((_x) >> 56) |				\
+	(((_x) >> 40) & (0xffULL << 8)) |	\
+	(((_x) >> 24) & (0xffULL << 16)) |	\
+	(((_x) >> 8) & (0xffULL << 24)) |	\
+	(((_x) << 8) & (0xffULL << 32)) |	\
+	(((_x) << 24) & (0xffULL << 40)) |	\
+	(((_x) << 40) & (0xffULL << 48)) |	\
+	((_x) << 56))
+
+#define	__bswap32_const(_x)			\
+	(((_x) >> 24) |				\
+	(((_x) & (0xff << 16)) >> 8) |		\
+	(((_x) & (0xff << 8)) << 8) |		\
+	((_x) << 24))
 
-#else	/* __OPTIMIZE__ */
-
-#define	__byte_swap_int(x) __byte_swap_int_var(x)
-
-#endif	/* __OPTIMIZE__ */
+#define __bswap16_const(_x)	(__uint16_t)((_x) << 8 | (_x) >> 8)
 
 static __inline __uint64_t
-__bswap64(__uint64_t _x)
+__bswap64_var(__uint64_t __x)
 {
 
-	return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) |
-	    ((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) |
-	    ((_x << 24) & ((__uint64_t)0xff << 40)) |
-	    ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
+	return __bswap64_const(__x);
 }
 
+
 static __inline __uint32_t
-__bswap32(__uint32_t _x)
+__bswap32_var(__uint32_t _x)
 {
 
-	return (__byte_swap_int(_x));
+	__asm ("bswap %0" : "+r" (_x));
+	return (_x);
 }
 
 static __inline __uint16_t
-__bswap16(__uint16_t _x)
+__bswap16_var(__uint16_t _x)
 {
-	return (_x << 8 | _x >> 8);
+
+	return (__bswap16_const(_x));
 }
 
+#define	__bswap64(_x)					\
+	(__builtin_constant_p(_x) ?			\
+	    __bswap64_const((__uint64_t)(_x)) : __bswap64_var(_x))
+
+#define	__bswap32(_x)					\
+	(__builtin_constant_p(_x) ?			\
+	    __bswap32_const((__uint32_t)(_x)) : __bswap32_var(_x))
+
+#define	__bswap16(_x)					\
+	(__builtin_constant_p(_x) ?			\
+	    __bswap16_const((__uint16_t)(_x)) : __bswap16_var(_x))
+
 #define	__htonl(x)	__bswap32(x)
 #define	__htons(x)	__bswap16(x)
 #define	__ntohl(x)	__bswap32(x)

Modified: head/sys/kern/kern_intr.c
==============================================================================
--- head/sys/kern/kern_intr.c	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/kern/kern_intr.c	Mon Mar 21 09:40:01 2011	(r219819)
@@ -74,6 +74,7 @@ struct intr_thread {
 
 /* Interrupt thread flags kept in it_flags */
 #define	IT_DEAD		0x000001	/* Thread is waiting to exit. */
+#define	IT_WAIT		0x000002	/* Thread is waiting for completion. */
 
 struct	intr_entropy {
 	struct	thread *td;
@@ -735,6 +736,39 @@ intr_handler_source(void *cookie)
 	return (ie->ie_source);
 }
 
+/*
+ * Sleep until an ithread finishes executing an interrupt handler.
+ *
+ * XXX Doesn't currently handle interrupt filters or fast interrupt
+ * handlers.  This is intended for compatibility with linux drivers
+ * only.  Do not use in BSD code.
+ */
+void
+_intr_drain(int irq)
+{
+	struct mtx *mtx;
+	struct intr_event *ie;
+	struct intr_thread *ithd;
+	struct thread *td;
+
+	ie = intr_lookup(irq);
+	if (ie == NULL)
+		return;
+	if (ie->ie_thread == NULL)
+		return;
+	ithd = ie->ie_thread;
+	td = ithd->it_thread;
+	thread_lock(td);
+	mtx = td->td_lock;
+	if (!TD_AWAITING_INTR(td)) {
+		ithd->it_flags |= IT_WAIT;
+		msleep_spin(ithd, mtx, "isync", 0);
+	}
+	mtx_unlock_spin(mtx);
+	return;
+}
+
+
 #ifndef INTR_FILTER
 int
 intr_event_remove_handler(void *cookie)
@@ -1271,6 +1305,7 @@ ithread_loop(void *arg)
 	struct intr_event *ie;
 	struct thread *td;
 	struct proc *p;
+	int wake;
 
 	td = curthread;
 	p = td->td_proc;
@@ -1279,6 +1314,7 @@ ithread_loop(void *arg)
 	    ("%s: ithread and proc linkage out of sync", __func__));
 	ie = ithd->it_event;
 	ie->ie_count = 0;
+	wake = 0;
 
 	/*
 	 * As long as we have interrupts outstanding, go through the
@@ -1319,12 +1355,20 @@ ithread_loop(void *arg)
 		 * set again, so we have to check it again.
 		 */
 		thread_lock(td);
-		if (!ithd->it_need && !(ithd->it_flags & IT_DEAD)) {
+		if (!ithd->it_need && !(ithd->it_flags & (IT_DEAD | IT_WAIT))) {
 			TD_SET_IWAIT(td);
 			ie->ie_count = 0;
 			mi_switch(SW_VOL | SWT_IWAIT, NULL);
 		}
+		if (ithd->it_flags & IT_WAIT) {
+			wake = 1;
+			ithd->it_flags &= ~IT_WAIT;
+		}
 		thread_unlock(td);
+		if (wake) {
+			wakeup(ithd);
+			wake = 0;
+		}
 	}
 }
 
@@ -1439,6 +1483,7 @@ ithread_loop(void *arg)
 	struct thread *td;
 	struct proc *p;
 	int priv;
+	int wake;
 
 	td = curthread;
 	p = td->td_proc;
@@ -1449,6 +1494,7 @@ ithread_loop(void *arg)
 	    ("%s: ithread and proc linkage out of sync", __func__));
 	ie = ithd->it_event;
 	ie->ie_count = 0;
+	wake = 0;
 
 	/*
 	 * As long as we have interrupts outstanding, go through the
@@ -1492,12 +1538,20 @@ ithread_loop(void *arg)
 		 * set again, so we have to check it again.
 		 */
 		thread_lock(td);
-		if (!ithd->it_need && !(ithd->it_flags & IT_DEAD)) {
+		if (!ithd->it_need && !(ithd->it_flags & (IT_DEAD | IT_WAIT))) {
 			TD_SET_IWAIT(td);
 			ie->ie_count = 0;
 			mi_switch(SW_VOL | SWT_IWAIT, NULL);
 		}
+		if (ithd->it_flags & IT_WAIT) {
+			wake = 1;
+			ithd->it_flags &= ~IT_WAIT;
+		}
 		thread_unlock(td);
+		if (wake) {
+			wakeup(ithd);
+			wake = 0;
+		}
 	}
 }
 

Modified: head/sys/kern/kern_jail.c
==============================================================================
--- head/sys/kern/kern_jail.c	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/kern/kern_jail.c	Mon Mar 21 09:40:01 2011	(r219819)
@@ -4182,7 +4182,7 @@ sysctl_jail_param(SYSCTL_HANDLER_ARGS)
 		i = 0;
 		return (SYSCTL_OUT(req, &i, sizeof(i)));
 	case CTLTYPE_STRING:
-		snprintf(numbuf, sizeof(numbuf), "%d", arg2);
+		snprintf(numbuf, sizeof(numbuf), "%jd", (intmax_t)arg2);
 		return
 		    (sysctl_handle_string(oidp, numbuf, sizeof(numbuf), req));
 	case CTLTYPE_STRUCT:

Modified: head/sys/kern/kern_sx.c
==============================================================================
--- head/sys/kern/kern_sx.c	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/kern/kern_sx.c	Mon Mar 21 09:40:01 2011	(r219819)
@@ -194,7 +194,7 @@ sx_sysinit(void *arg)
 {
 	struct sx_args *sargs = arg;
 
-	sx_init(sargs->sa_sx, sargs->sa_desc);
+	sx_init_flags(sargs->sa_sx, sargs->sa_desc, sargs->sa_flags);
 }
 
 void

Modified: head/sys/kern/kern_sysctl.c
==============================================================================
--- head/sys/kern/kern_sysctl.c	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/kern/kern_sysctl.c	Mon Mar 21 09:40:01 2011	(r219819)
@@ -365,10 +365,31 @@ sysctl_remove_oid(struct sysctl_oid *oid
 	return (error);
 }
 
+int
+sysctl_remove_name(struct sysctl_oid *parent, const char *name,
+    int del, int recurse)
+{
+	struct sysctl_oid *p, *tmp;
+	int error;
+
+	error = ENOENT;
+	SYSCTL_XLOCK();
+	SLIST_FOREACH_SAFE(p, SYSCTL_CHILDREN(parent), oid_link, tmp) {
+		if (strcmp(p->oid_name, name) == 0) {
+			error = sysctl_remove_oid_locked(p, del, recurse);
+			break;
+		}
+	}
+	SYSCTL_XUNLOCK();
+
+	return (error);
+}
+
+
 static int
 sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, int recurse)
 {
-	struct sysctl_oid *p;
+	struct sysctl_oid *p, *tmp;
 	int error;
 
 	SYSCTL_ASSERT_XLOCKED();
@@ -387,7 +408,8 @@ sysctl_remove_oid_locked(struct sysctl_o
 	 */
 	if ((oidp->oid_kind & CTLTYPE) == CTLTYPE_NODE) {
 		if (oidp->oid_refcnt == 1) {
-			SLIST_FOREACH(p, SYSCTL_CHILDREN(oidp), oid_link) {
+			SLIST_FOREACH_SAFE(p,
+			    SYSCTL_CHILDREN(oidp), oid_link, tmp) {
 				if (!recurse)
 					return (ENOTEMPTY);
 				error = sysctl_remove_oid_locked(p, del,
@@ -428,14 +450,13 @@ sysctl_remove_oid_locked(struct sysctl_o
 	}
 	return (0);
 }
-
 /*
  * Create new sysctls at run time.
  * clist may point to a valid context initialized with sysctl_ctx_init().
  */
 struct sysctl_oid *
 sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent,
-	int number, const char *name, int kind, void *arg1, int arg2,
+	int number, const char *name, int kind, void *arg1, intptr_t arg2,
 	int (*handler)(SYSCTL_HANDLER_ARGS), const char *fmt, const char *descr)
 {
 	struct sysctl_oid *oidp;
@@ -479,6 +500,7 @@ sysctl_add_oid(struct sysctl_ctx_list *c
 		SYSCTL_CHILDREN_SET(oidp, malloc(sizeof(struct sysctl_oid_list),
 		    M_SYSCTLOID, M_WAITOK));
 		SLIST_INIT(SYSCTL_CHILDREN(oidp));
+		oidp->oid_arg2 = arg2;
 	} else {
 		oidp->oid_arg1 = arg1;
 		oidp->oid_arg2 = arg2;

Modified: head/sys/kern/subr_bus.c
==============================================================================
--- head/sys/kern/subr_bus.c	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/kern/subr_bus.c	Mon Mar 21 09:40:01 2011	(r219819)
@@ -1038,7 +1038,7 @@ devclass_driver_added(devclass_t dc, dri
  * @param dc		the devclass to edit
  * @param driver	the driver to register
  */
-static int
+int
 devclass_add_driver(devclass_t dc, driver_t *driver, int pass, devclass_t *dcp)
 {
 	driverlink_t dl;
@@ -1172,7 +1172,7 @@ devclass_driver_deleted(devclass_t buscl
  * @param dc		the devclass to edit
  * @param driver	the driver to unregister
  */
-static int
+int
 devclass_delete_driver(devclass_t busclass, driver_t *driver)
 {
 	devclass_t dc = devclass_find(driver->name);

Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/net/if.c	Mon Mar 21 09:40:01 2011	(r219819)
@@ -1881,6 +1881,11 @@ if_route(struct ifnet *ifp, int flag, in
 
 void	(*vlan_link_state_p)(struct ifnet *);	/* XXX: private from if_vlan */
 void	(*vlan_trunk_cap_p)(struct ifnet *);		/* XXX: private from if_vlan */
+struct ifnet *(*vlan_trunkdev_p)(struct ifnet *);
+struct	ifnet *(*vlan_devat_p)(struct ifnet *, uint16_t);
+int	(*vlan_tag_p)(struct ifnet *, uint16_t *);
+int	(*vlan_setcookie_p)(struct ifnet *, void *);
+void	*(*vlan_cookie_p)(struct ifnet *);
 
 /*
  * Handle a change in the interface link state. To avoid LORs
@@ -1935,6 +1940,7 @@ do_link_state_change(void *arg, int pend
 	if (log_link_state_change)
 		log(LOG_NOTICE, "%s: link state changed to %s\n", ifp->if_xname,
 		    (link_state == LINK_STATE_UP) ? "UP" : "DOWN" );
+	EVENTHANDLER_INVOKE(ifnet_link_event, ifp, ifp->if_link_state);
 	CURVNET_RESTORE();
 }
 

Modified: head/sys/net/if_arp.h
==============================================================================
--- head/sys/net/if_arp.h	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/net/if_arp.h	Mon Mar 21 09:40:01 2011	(r219819)
@@ -50,6 +50,7 @@ struct	arphdr {
 #define ARPHRD_ARCNET	7	/* arcnet hardware format */
 #define ARPHRD_FRELAY 	15	/* frame relay hardware format */
 #define ARPHRD_IEEE1394	24	/* firewire hardware format */
+#define ARPHRD_INFINIBAND 32	/* infiniband hardware format */
 	u_short	ar_pro;		/* format of protocol address */
 	u_char	ar_hln;		/* length of hardware address */
 	u_char	ar_pln;		/* length of protocol address */

Modified: head/sys/net/if_llatbl.h
==============================================================================
--- head/sys/net/if_llatbl.h	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/net/if_llatbl.h	Mon Mar 21 09:40:01 2011	(r219819)
@@ -30,6 +30,8 @@ __FBSDID("$FreeBSD$");
 #ifndef	_NET_IF_LLATBL_H_
 #define	_NET_IF_LLATBL_H_
 
+#include "opt_ofed.h"
+
 #include <sys/_rwlock.h>
 #include <netinet/in.h>
 
@@ -72,6 +74,9 @@ struct llentry {
 	union {
 		uint64_t	mac_aligned;
 		uint16_t	mac16[3];
+#ifdef OFED
+		uint8_t		mac8[20];	/* IB needs 20 bytes. */
+#endif
 	} ll_addr;
 
 	/* XXX af-private? */

Modified: head/sys/net/if_types.h
==============================================================================
--- head/sys/net/if_types.h	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/net/if_types.h	Mon Mar 21 09:40:01 2011	(r219819)
@@ -238,6 +238,7 @@
 #define	IFT_ATMVCIENDPT		   0xc2 /* ATM VCI End Point */
 #define	IFT_OPTICALCHANNEL	   0xc3 /* Optical Channel */
 #define	IFT_OPTICALTRANSPORT	   0xc4 /* Optical Transport */
+#define	IFT_INFINIBAND		   0xc7	/* Infiniband */
 #define	IFT_BRIDGE		   0xd1 /* Transparent bridge interface */
 
 #define	IFT_STF			   0xd7	/* 6to4 interface */

Modified: head/sys/net/if_var.h
==============================================================================
--- head/sys/net/if_var.h	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/net/if_var.h	Mon Mar 21 09:40:01 2011	(r219819)
@@ -352,6 +352,9 @@ EVENTHANDLER_DECLARE(ifnet_arrival_event
 /* interface departure event */
 typedef void (*ifnet_departure_event_handler_t)(void *, struct ifnet *);
 EVENTHANDLER_DECLARE(ifnet_departure_event, ifnet_departure_event_handler_t);
+/* Interface link state change event */
+typedef void (*ifnet_link_event_handler_t)(void *, struct ifnet *, int);
+EVENTHANDLER_DECLARE(ifnet_link_event, ifnet_link_event_handler_t);
 
 /*
  * interface groups

Modified: head/sys/net/if_vlan.c
==============================================================================
--- head/sys/net/if_vlan.c	Mon Mar 21 08:54:59 2011	(r219818)
+++ head/sys/net/if_vlan.c	Mon Mar 21 09:40:01 2011	(r219819)
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/sockio.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
+#include <sys/sx.h>
 
 #include <net/bpf.h>
 #include <net/ethernet.h>
@@ -90,13 +91,14 @@ struct ifvlantrunk {
 };
 
 struct vlan_mc_entry {
-	struct ether_addr		mc_addr;
+	struct sockaddr_dl		mc_addr;
 	SLIST_ENTRY(vlan_mc_entry)	mc_entries;
 };
 
 struct	ifvlan {
 	struct	ifvlantrunk *ifv_trunk;
 	struct	ifnet *ifv_ifp;
+	void	*ifv_cookie;
 #define	TRUNK(ifv)	((ifv)->ifv_trunk)
 #define	PARENT(ifv)	((ifv)->ifv_trunk->parent)
 	int	ifv_pflags;	/* special flags we have set on parent */
@@ -153,12 +155,12 @@ static eventhandler_tag iflladdr_tag;
  * however on practice it does not. Probably this is because array
  * is too big to fit into CPU cache.
  */
-static struct mtx ifv_mtx;
-#define	VLAN_LOCK_INIT()	mtx_init(&ifv_mtx, "vlan_global", NULL, MTX_DEF)
-#define	VLAN_LOCK_DESTROY()	mtx_destroy(&ifv_mtx)
-#define	VLAN_LOCK_ASSERT()	mtx_assert(&ifv_mtx, MA_OWNED)
-#define	VLAN_LOCK()		mtx_lock(&ifv_mtx)
-#define	VLAN_UNLOCK()		mtx_unlock(&ifv_mtx)
+static struct sx ifv_lock;
+#define	VLAN_LOCK_INIT()	sx_init(&ifv_lock, "vlan_global")
+#define	VLAN_LOCK_DESTROY()	sx_destroy(&ifv_lock)
+#define	VLAN_LOCK_ASSERT()	sx_assert(&ifv_lock, SA_LOCKED)
+#define	VLAN_LOCK()		sx_xlock(&ifv_lock)
+#define	VLAN_UNLOCK()		sx_xunlock(&ifv_lock)
 #define	TRUNK_LOCK_INIT(trunk)	rw_init(&(trunk)->rw, VLANNAME)
 #define	TRUNK_LOCK_DESTROY(trunk) rw_destroy(&(trunk)->rw)
 #define	TRUNK_LOCK(trunk)	rw_wlock(&(trunk)->rw)
@@ -386,6 +388,47 @@ vlan_dumphash(struct ifvlantrunk *trunk)
 	}
 }
 #endif /* 0 */
+#else
+
+static __inline struct ifvlan *
+vlan_gethash(struct ifvlantrunk *trunk, uint16_t tag)
+{
+
+	return trunk->vlans[tag];
+}
+
+static __inline int
+vlan_inshash(struct ifvlantrunk *trunk, struct ifvlan *ifv)
+{
+
+	if (trunk->vlans[ifv->ifv_tag] != NULL)
+		return EEXIST;
+	trunk->vlans[ifv->ifv_tag] = ifv;
+	trunk->refcnt++;
+
+	return (0);
+}
+
+static __inline int
+vlan_remhash(struct ifvlantrunk *trunk, struct ifvlan *ifv)
+{
+
+	trunk->vlans[ifv->ifv_tag] = NULL;
+	trunk->refcnt--;
+
+	return (0);
+}
+
+static __inline void
+vlan_freehash(struct ifvlantrunk *trunk)
+{
+}
+
+static __inline void
+vlan_inithash(struct ifvlantrunk *trunk)
+{
+}
+
 #endif /* !VLAN_ARRAY */
 
 static void
@@ -394,9 +437,7 @@ trunk_destroy(struct ifvlantrunk *trunk)
 	VLAN_LOCK_ASSERT();
 
 	TRUNK_LOCK(trunk);
-#ifndef VLAN_ARRAY
 	vlan_freehash(trunk);
-#endif
 	trunk->parent->if_vlantrunk = NULL;
 	TRUNK_UNLOCK(trunk);
 	TRUNK_LOCK_DESTROY(trunk);
@@ -421,7 +462,6 @@ vlan_setmulti(struct ifnet *ifp)
 	struct ifmultiaddr	*ifma, *rifma = NULL;
 	struct ifvlan		*sc;
 	struct vlan_mc_entry	*mc;
-	struct sockaddr_dl	sdl;
 	int			error;
 
 	/*VLAN_LOCK_ASSERT();*/
@@ -432,17 +472,9 @@ vlan_setmulti(struct ifnet *ifp)
 
 	CURVNET_SET_QUIET(ifp_p->if_vnet);
 
-	bzero((char *)&sdl, sizeof(sdl));
-	sdl.sdl_len = sizeof(sdl);
-	sdl.sdl_family = AF_LINK;
-	sdl.sdl_index = ifp_p->if_index;
-	sdl.sdl_type = IFT_ETHER;
-	sdl.sdl_alen = ETHER_ADDR_LEN;
-
 	/* First, remove any existing filter entries. */
 	while ((mc = SLIST_FIRST(&sc->vlan_mc_listhead)) != NULL) {
-		bcopy((char *)&mc->mc_addr, LLADDR(&sdl), ETHER_ADDR_LEN);
-		error = if_delmulti(ifp_p, (struct sockaddr *)&sdl);
+		error = if_delmulti(ifp_p, (struct sockaddr *)&mc->mc_addr);
 		if (error)
 			return (error);
 		SLIST_REMOVE_HEAD(&sc->vlan_mc_listhead, mc_entries);
@@ -456,12 +488,11 @@ vlan_setmulti(struct ifnet *ifp)
 		mc = malloc(sizeof(struct vlan_mc_entry), M_VLAN, M_NOWAIT);
 		if (mc == NULL)
 			return (ENOMEM);
-		bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
-		    (char *)&mc->mc_addr, ETHER_ADDR_LEN);
+		bcopy(ifma->ifma_addr, &mc->mc_addr, ifma->ifma_addr->sa_len);
+		mc->mc_addr.sdl_index = ifp_p->if_index;
 		SLIST_INSERT_HEAD(&sc->vlan_mc_listhead, mc, mc_entries);
-		bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
-		    LLADDR(&sdl), ETHER_ADDR_LEN);
-		error = if_addmulti(ifp_p, (struct sockaddr *)&sdl, &rifma);
+		error = if_addmulti(ifp_p, (struct sockaddr *)&mc->mc_addr,
+		    &rifma);
 		if (error)
 			return (error);
 	}
@@ -503,7 +534,8 @@ vlan_iflladdr(void *arg __unused, struct
 		LIST_FOREACH_SAFE(ifv, &ifp->if_vlantrunk->hash[i], ifv_list, next) {
 #endif /* VLAN_ARRAY */
 			VLAN_UNLOCK();
-			if_setlladdr(ifv->ifv_ifp, IF_LLADDR(ifp), ETHER_ADDR_LEN);
+			if_setlladdr(ifv->ifv_ifp, IF_LLADDR(ifp),
+			    ifp->if_addrlen);
 			VLAN_LOCK();
 		}
 	VLAN_UNLOCK();

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103210940.p2L9e1R5006486>