2 * Copyright (c) 2016 QLogic Corporation.
6 * See LICENSE.qede_pmd for copyright and licensing details.
9 #ifndef __ECORE_UTILS_H__
10 #define __ECORE_UTILS_H__
12 /* dma_addr_t manip */
13 #define DMA_LO(x) ((u32)(((dma_addr_t)(x)) & 0xffffffff))
14 #define DMA_HI(x) ((u32)(((dma_addr_t)(x)) >> 32))
16 #define DMA_LO_LE(x) OSAL_CPU_TO_LE32(DMA_LO(x))
17 #define DMA_HI_LE(x) OSAL_CPU_TO_LE32(DMA_HI(x))
19 /* It's assumed that whoever includes this has previously included an hsi
20 * file defining the regpair.
22 #define DMA_REGPAIR_LE(x, val) (x).hi = DMA_HI_LE((val)); \
23 (x).lo = DMA_LO_LE((val))
25 #define HILO_GEN(hi, lo, type) ((((type)(hi)) << 32) + (lo))
26 #define HILO_DMA(hi, lo) HILO_GEN(hi, lo, dma_addr_t)
27 #define HILO_64(hi, lo) HILO_GEN(hi, lo, u64)
28 #define HILO_DMA_REGPAIR(regpair) (HILO_DMA(regpair.hi, regpair.lo))
29 #define HILO_64_REGPAIR(regpair) (HILO_64(regpair.hi, regpair.lo))