--- /dev/null	Thu Dec 10 09:27:28 2015
+++ new/usr/src/uts/common/io/i40e/i40e_osdep.h	Thu Dec 10 09:27:28 2015
@@ -0,0 +1,258 @@
+/******************************************************************************
+
+  Copyright (c) 2013-2015, Intel Corporation 
+  All rights reserved.
+  
+  Redistribution and use in source and binary forms, with or without 
+  modification, are permitted provided that the following conditions are met:
+  
+   1. Redistributions of source code must retain the above copyright notice, 
+      this list of conditions and the following disclaimer.
+  
+   2. Redistributions in binary form must reproduce the above copyright 
+      notice, this list of conditions and the following disclaimer in the 
+      documentation and/or other materials provided with the distribution.
+  
+   3. Neither the name of the Intel Corporation nor the names of its 
+      contributors may be used to endorse or promote products derived from 
+      this software without specific prior written permission.
+  
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+  POSSIBILITY OF SUCH DAMAGE.
+
+******************************************************************************/
+/*$FreeBSD: head/sys/dev/ixl/i40e_osdep.h 284049 2015-06-05 22:52:42Z jfv $*/
+
+#ifndef _I40E_OSDEP_H_
+#define _I40E_OSDEP_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/types.h>
+#include <sys/conf.h>
+#include <sys/debug.h>
+#include <sys/stropts.h>
+#include <sys/stream.h>
+#include <sys/strsun.h>
+#include <sys/strlog.h>
+#include <sys/kmem.h>
+#include <sys/stat.h>
+#include <sys/kstat.h>
+#include <sys/modctl.h>
+#include <sys/errno.h>
+#include <sys/dlpi.h>
+#include <sys/mac_provider.h>
+#include <sys/mac_ether.h>
+#include <sys/vlan.h>
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+#include <sys/pci.h>
+#include <sys/pci_cap.h>
+#include <sys/pcie.h>
+#include <sys/sdt.h>
+#include <sys/ethernet.h>
+#include <sys/pattr.h>
+#include <sys/strsubr.h>
+#include <sys/netlb.h>
+#include <sys/random.h>
+#include <inet/common.h>
+#include <inet/tcp.h>
+#include <inet/ip.h>
+#include <inet/mi.h>
+#include <inet/nd.h>
+#include <sys/bitmap.h>
+#include <sys/ddifm.h>
+#include <sys/fm/protocol.h>
+#include <sys/fm/util.h>
+#include <sys/disp.h>
+#include <sys/fm/io/ddi.h>
+
+
+/*
+ * On the off chance we need to hack Intel-written code, define I40E_ILLUMOS
+ * here so we can have #ifdef I40E_ILLUMOS in (hopefully) very rare case.
+ */
+#define	I40E_ILLUMOS 1
+
+#define i40e_usec_delay(x) drv_usecwait(x)
+#define i40e_msec_delay(x) drv_usecwait(1000 * (x))
+
+/* XXX KEBE ASKS Better alternatives to printf()? */
+#define DBG 0 
+#define MSGOUT(S, A, B)     printf(S "\n", A, B)
+#define DEBUGFUNC(F)        DEBUGOUT(F);
+#if DBG
+	#define DEBUGOUT(S)         printf(S "\n")
+	#define DEBUGOUT1(S,A)      printf(S "\n",A)
+	#define DEBUGOUT2(S,A,B)    printf(S "\n",A,B)
+	#define DEBUGOUT3(S,A,B,C)  printf(S "\n",A,B,C)
+	#define DEBUGOUT7(S,A,B,C,D,E,F,G)  printf(S "\n",A,B,C,D,E,F,G)
+#else
+	#define DEBUGOUT(S)
+	#define DEBUGOUT1(S,A)
+	#define DEBUGOUT2(S,A,B)
+	#define DEBUGOUT3(S,A,B,C)
+	#define DEBUGOUT6(S,A,B,C,D,E,F)
+	#define DEBUGOUT7(S,A,B,C,D,E,F,G)
+#endif
+
+#define UNREFERENCED_XPARAMETER
+#define UNREFERENCED_PARAMETER(_p)
+#define UNREFERENCED_1PARAMETER(_p)
+#define UNREFERENCED_2PARAMETER(_p, _q)
+#define UNREFERENCED_3PARAMETER(_p, _q, _r)
+#define UNREFERENCED_4PARAMETER(_p, _q, _r, _s)
+
+#define STATIC	static
+#define INLINE  inline
+
+#define FALSE               B_FALSE
+#define false               B_FALSE /* shared code requires this */
+#define TRUE                B_TRUE
+#define true                B_TRUE
+#define CMD_MEM_WRT_INVALIDATE          0x0010  /* BIT_4 */
+#define PCI_COMMAND_REGISTER            0x04	/* stolen from ixgbe_osdep.h */
+
+/* XXX KEBE ASKS --> best implementations of bcopy? memcpy? memset? */
+#define i40e_memset(a, b, c, d)  memset((a), (b), (c))
+#define i40e_memcpy(a, b, c, d)  bcopy((b), (a), (c))
+
+/* illumos LE_XX() macros do these little-to-native/native-to-little ops. */
+#define CPU_TO_LE16(o)	LE_16(o)
+#define CPU_TO_LE32(s)	LE_32(s)
+#define CPU_TO_LE64(h)	LE_64(h)
+#define LE16_TO_CPU(a)	LE_16(a)
+#define LE32_TO_CPU(c)	LE_32(c)
+#define LE64_TO_CPU(k)	LE_64(k)
+
+#define I40E_NTOHS(a)	ntohs(a)
+#define I40E_NTOHL(a)	ntohl(a)
+#define I40E_HTONS(a)	htons(a)
+#define I40E_HTONL(a)	htonl(a)
+
+#define FIELD_SIZEOF(x, y) (sizeof(((x*)0)->y))
+
+#define BIT(a) 		(1UL << (a))
+#define BIT_ULL(a) 	(1ULL << (a))
+
+typedef boolean_t	bool;
+
+typedef uint8_t		u8;
+typedef int8_t		s8;
+typedef uint16_t	u16;
+typedef int16_t		s16;
+typedef uint32_t	u32;
+typedef int32_t		s32;
+typedef uint64_t	u64;
+
+/* long string relief */
+typedef enum i40e_status_code i40e_status;
+
+#define __le16  u16
+#define __le32  u32
+#define __le64  u64
+#define __be16  u16
+#define __be32  u32
+#define __be64  u64
+
+/* SW spinlock */
+struct i40e_spinlock {
+        /* struct mtx mutex; */
+	kmutex_t mutex;
+};
+
+#if defined(__amd64__) || defined(i386)
+/* NOTE:  According to asm/cpu.h -> This is an SSE extension. Be careful. */
+#define	prefetch(x) prefetch_read_many(x)
+#else
+#define	prefetch(x)
+#endif
+
+struct i40e_osdep {
+	ddi_acc_handle_t reg_handle;
+	ddi_acc_handle_t cfg_handle;
+	struct i40e_s *i40e;
+};
+
+struct i40e_hw; /* forward decl */
+#define	OS_DEP(hw) ((struct i40e_osdep *)((hw)->back))
+/*
+u16	i40e_read_pci_cfg(struct i40e_hw *, u32);
+void	i40e_write_pci_cfg(struct i40e_hw *, u32, u16);
+*/
+#define i40e_read_pci_cfg(hw, reg) \
+	(pci_config_get16(OS_DEP(hw)->cfg_handle, (reg)))
+#define	i40e_write_pci_cfg(hw, reg, value) \
+	(pci_config_put16(OS_DEP(hw)->cfg_handle, (reg), (value)))
+
+/* wr32/rd32 are peppered throughout the Intel-written code. */
+#define	wr32(hw, reg, value) \
+	ddi_put32(OS_DEP(hw)->reg_handle, \
+	    (uint32_t *)((uintptr_t)(hw)->hw_addr + (reg)), (value))
+#define	rd32(hw, reg) \
+	ddi_get32(OS_DEP(hw)->reg_handle, \
+	    (uint32_t *)((uintptr_t)(hw)->hw_addr + (reg)))
+
+/*
+ * I40E_GLGEN_STAT is only for physical function, but that's all we do for
+ * now.
+ */
+#define	i40e_flush(hw) (void) rd32(hw, I40E_GLGEN_STAT)
+	
+
+/* #define i40e_debug(h, m, s, ...)  i40e_debug_d(h, m, s, ##__VA_ARGS__) */
+/* extern void i40e_debug_d(void *hw, u32 mask, char *fmt_str, ...); */
+extern void i40e_debug(void *, u32, char *, ...);
+extern boolean_t i40e_set_hw_bus_info(struct i40e_hw *);
+
+struct i40e_virt_mem {
+        void *va;
+        u32 size;
+};
+
+struct i40e_dma_mem {
+        void                    *va;	/* Virtual address. */
+        u64                     pa;	/* Physical (DMA/Hardware) address. */
+        size_t			size;	/* Buffer size. */
+
+	/* Illumos DDI data. */
+	ddi_acc_handle_t	acc_handle;	/* Data access handle */
+	ddi_dma_handle_t	dma_handle;	/* DMA handle */
+
+        int                     nseg;
+        int                     flags;
+};
+
+/*
+** This hardware supports either 16 or 32 byte rx descriptors
+** we default here to the larger size.
+*/
+#define i40e_rx_desc i40e_32byte_rx_desc
+
+/*
+ * XXX KEBE SAYS WE MAY NEED DEFS FOR:
+ *
+ * void rd32_osdep(struct i40e_osdep *osdep, uint32_t reg)
+ * void wr32_osdep(struct i40e_osdep *osdep, uint32_t reg, uint32_t value)
+ * void i40e_flush_osdep(struct i40e_osdep *)
+ * rd64(a, reg)
+ * wr64(a, reg, value)
+ * i40e_flush()
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _I40E_OSDEP_H_ */
