9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * This file and its contents are supplied under the terms of the
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * Common Development and Distribution License ("CDDL"), version 1.0.
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * You may only use this file in accordance with the terms of version
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * 1.0 of the CDDL.
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * A full copy of the text of the CDDL should have accompanied this
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * source. A copy of the CDDL is also available via the Internet at
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * Copyright 2016 Joyent, Inc.
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * For the moment, we use this to basically deal with a few custom changes
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * particularly around the use of sprintf() in the common code. The DDI defines
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * sprintf() in a rather different way than the rest of the world expects it.
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * This is currently necessary to indicate that we should use an alternate
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#define DEBUGOUT1(S, A) i40e_debug(NULL, 0, S, A)
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#define DEBUGOUT2(S, A, B) i40e_debug(NULL, 0, S, A, B)
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#define DEBUGOUT3(S, A, B, C) i40e_debug(NULL, 0, S, A, B, C)
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi i40e_debug(NULL, 0, S, A, B, C, D, E, F, G)
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#define UNREFERENCED_PARAMETER(x) _NOTE(ARGUNUSED(x))
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#define UNREFERENCED_1PARAMETER(_p) UNREFERENCED_PARAMETER(_p)
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#define UNREFERENCED_2PARAMETER(_p, _q) _NOTE(ARGUNUSED(_p, _q))
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#define UNREFERENCED_3PARAMETER(_p, _q, _r) _NOTE(ARGUNUSED(_p, _q, _r))
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#define UNREFERENCED_4PARAMETER(_p, _q, _r, _s) _NOTE(ARGUNUSED(_p, _q, _r, _s))
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * The mdb dmod needs to use this code as well, but mdb already defines TRUE and
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * FALSE in the module API. Thus we don't define these if we're building the
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * dmod, as indicated by _I40E_MDB_DMOD. However, if we don't define these, then
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * the shared code will be upset.
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#endif /* _I40E_MDB_DMOD */
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#define i40e_memset(a, b, c, d) memset((a), (b), (c))
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#define i40e_memcpy(a, b, c, d) bcopy((b), (a), (c))
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#define i40e_msec_delay(x) drv_usecwait(1000 * (x))
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#define FIELD_SIZEOF(x, y) (sizeof (((x*)0)->y))
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi/* long string relief */
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * Most other systems use spin locks for interrupts. However, illumos always
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * uses a single kmutex_t for both and we decide what to do based on IPL (hint:
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * it's not going to be a true spin lock, we'll use an adaptive mutex).
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * Note, while prefetch is strictly not present on all architectures, (it's an
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * SSE extension on i386), it is expected that the platforms provide it.
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * This structure and its members are defined by the common code. This means we
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * cannot structure prefix it, even if we want to.
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * The first three members of this structure are defined by the common code.
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * This means we cannot structure prefix them, even if we wanted to.
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi u64 pa; /* Physical (DMA/Hardware) address. */
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi /* illumos-private members */
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi ddi_acc_handle_t idm_acc_handle; /* Data access handle */
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi ddi_dma_handle_t idm_dma_handle; /* DMA handle */
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi uint32_t idm_alignment; /* Requested alignment */
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#define OS_DEP(hw) ((struct i40e_osdep *)((hw)->back))
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi (pci_config_get16(OS_DEP(hw)->ios_cfg_handle, (reg)))
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#define i40e_write_pci_cfg(hw, reg, value) \
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi (pci_config_put16(OS_DEP(hw)->ios_cfg_handle, (reg), (value)))
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * Intel expects that the symbol wr32 and rd32 be defined to something which can
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * read and write the 32-bit register in PCI space.
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * To make it easier for readers and satisfy the general agreement that macros
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * should be in all capitals, we use our own versions of these macros.
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi (uint32_t *)((uintptr_t)(hw)->hw_addr + (reg)), (value))
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi (uint32_t *)((uintptr_t)(hw)->hw_addr + (reg)))
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * The use of GLGEN_STAT presumes that we're only using this file for a PF
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi * driver. If we end up doing a VF driver, then we'll want to logically change
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#define i40e_flush(hw) (void) rd32(hw, I40E_GLGEN_STAT)
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchiextern void i40e_debug(void *, u32, char *, ...);
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchiextern boolean_t i40e_set_hw_bus_info(struct i40e_hw *);
9d26e4fc021e249c93c2861629cc665e4f5bd4d6Robert Mustacchi#endif /* _I40E_OSDEP_H */