17 #include <linux/list.h>
18 #include <linux/slab.h>
21 #ifndef VXGE_CACHE_LINE_SIZE
22 #define VXGE_CACHE_LINE_SIZE 128
26 #define VXGE_ALIGN(adrs, size) \
27 (((size) - (((u64)adrs) & ((size)-1))) & ((size)-1))
30 #define VXGE_HW_MIN_MTU 68
31 #define VXGE_HW_MAX_MTU 9600
32 #define VXGE_HW_DEFAULT_MTU 1500
34 #define VXGE_HW_MAX_ROM_IMAGES 8
43 #ifdef VXGE_DEBUG_ASSERT
54 #define vxge_assert(test) BUG_ON(!(test))
56 #define vxge_assert(test)
77 #define NULL_VPID 0xFFFFFFFF
78 #ifdef CONFIG_VXGE_DEBUG_TRACE_ALL
79 #define VXGE_DEBUG_MODULE_MASK 0xffffffff
80 #define VXGE_DEBUG_TRACE_MASK 0xffffffff
81 #define VXGE_DEBUG_ERR_MASK 0xffffffff
82 #define VXGE_DEBUG_MASK 0x000001ff
84 #define VXGE_DEBUG_MODULE_MASK 0x20000000
85 #define VXGE_DEBUG_TRACE_MASK 0x20000000
86 #define VXGE_DEBUG_ERR_MASK 0x20000000
87 #define VXGE_DEBUG_MASK 0x00000001
98 #define VXGE_COMPONENT_LL 0x20000000
99 #define VXGE_COMPONENT_ALL 0xffffffff
101 #define VXGE_HW_BASE_INF 100
102 #define VXGE_HW_BASE_ERR 200
103 #define VXGE_HW_BASE_BADCFG 300
212 #define VXGE_HW_FW_STRLEN 32
253 #define VXGE_HW_FIFO_ENABLE 1
254 #define VXGE_HW_FIFO_DISABLE 0
257 #define VXGE_HW_MIN_FIFO_BLOCKS 2
258 #define VXGE_HW_MAX_FIFO_BLOCKS 128
261 #define VXGE_HW_MIN_FIFO_FRAGS 1
262 #define VXGE_HW_MAX_FIFO_FRAGS 256
265 #define VXGE_HW_MIN_FIFO_MEMBLOCK_SIZE VXGE_HW_BLOCK_SIZE
266 #define VXGE_HW_MAX_FIFO_MEMBLOCK_SIZE 131072
267 #define VXGE_HW_DEF_FIFO_MEMBLOCK_SIZE 8096
270 #define VXGE_HW_MIN_FIFO_ALIGNMENT_SIZE 0
271 #define VXGE_HW_MAX_FIFO_ALIGNMENT_SIZE 65536
272 #define VXGE_HW_DEF_FIFO_ALIGNMENT_SIZE VXGE_CACHE_LINE_SIZE
275 #define VXGE_HW_FIFO_QUEUE_INTR_ENABLE 1
276 #define VXGE_HW_FIFO_QUEUE_INTR_DISABLE 0
277 #define VXGE_HW_FIFO_QUEUE_INTR_DEFAULT 0
280 #define VXGE_HW_FIFO_NO_SNOOP_DISABLED 0
281 #define VXGE_HW_FIFO_NO_SNOOP_TXD 1
282 #define VXGE_HW_FIFO_NO_SNOOP_FRM 2
283 #define VXGE_HW_FIFO_NO_SNOOP_ALL 3
284 #define VXGE_HW_FIFO_NO_SNOOP_DEFAULT 0
314 #define VXGE_HW_RING_ENABLE 1
315 #define VXGE_HW_RING_DISABLE 0
316 #define VXGE_HW_RING_DEFAULT 1
319 #define VXGE_HW_MIN_RING_BLOCKS 1
320 #define VXGE_HW_MAX_RING_BLOCKS 128
321 #define VXGE_HW_DEF_RING_BLOCKS 2
324 #define VXGE_HW_RING_RXD_BUFFER_MODE_1 1
325 #define VXGE_HW_RING_RXD_BUFFER_MODE_3 3
326 #define VXGE_HW_RING_RXD_BUFFER_MODE_5 5
327 #define VXGE_HW_RING_RXD_BUFFER_MODE_DEFAULT 1
330 #define VXGE_HW_RING_SCATTER_MODE_A 0
331 #define VXGE_HW_RING_SCATTER_MODE_B 1
332 #define VXGE_HW_RING_SCATTER_MODE_C 2
333 #define VXGE_HW_RING_SCATTER_MODE_USE_FLASH_DEFAULT 0xffffffff
336 #define VXGE_HW_DEF_RING_RXDS_LIMIT 44
363 #define VXGE_HW_VPATH_PRIORITY_MIN 0
364 #define VXGE_HW_VPATH_PRIORITY_MAX 16
365 #define VXGE_HW_VPATH_PRIORITY_DEFAULT 0
368 #define VXGE_HW_VPATH_BANDWIDTH_MIN 0
369 #define VXGE_HW_VPATH_BANDWIDTH_MAX 100
370 #define VXGE_HW_VPATH_BANDWIDTH_DEFAULT 0
378 #define VXGE_HW_VPATH_MIN_INITIAL_MTU VXGE_HW_MIN_MTU
379 #define VXGE_HW_VPATH_MAX_INITIAL_MTU VXGE_HW_MAX_MTU
380 #define VXGE_HW_VPATH_USE_FLASH_DEFAULT_INITIAL_MTU 0xffffffff
383 #define VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_ENABLE 1
384 #define VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_DISABLE 0
385 #define VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_USE_FLASH_DEFAULT 0xffffffff
418 #define VXGE_HW_MIN_DEVICE_POLL_MILLIS 1
419 #define VXGE_HW_MAX_DEVICE_POLL_MILLIS 100000
420 #define VXGE_HW_DEF_DEVICE_POLL_MILLIS 1000
424 #define VXGE_HW_MIN_DMA_BLOCK_POOL_SIZE 0
425 #define VXGE_HW_INITIAL_DMA_BLOCK_POOL_SIZE 0
426 #define VXGE_HW_INCR_DMA_BLOCK_POOL_SIZE 4
427 #define VXGE_HW_MAX_DMA_BLOCK_POOL_SIZE 4096
429 #define VXGE_HW_MAX_PAYLOAD_SIZE_512 2
432 #define VXGE_HW_INTR_MODE_IRQLINE 0
433 #define VXGE_HW_INTR_MODE_MSIX 1
434 #define VXGE_HW_INTR_MODE_MSIX_ONE_SHOT 2
436 #define VXGE_HW_INTR_MODE_DEF 0
439 #define VXGE_HW_RTH_DISABLE 0
440 #define VXGE_HW_RTH_ENABLE 1
441 #define VXGE_HW_RTH_DEFAULT 0
444 #define VXGE_HW_RTH_IT_TYPE_SOLO_IT 0
445 #define VXGE_HW_RTH_IT_TYPE_MULTI_IT 1
446 #define VXGE_HW_RTH_IT_TYPE_DEFAULT 0
449 #define VXGE_HW_RTS_MAC_DISABLE 0
450 #define VXGE_HW_RTS_MAC_ENABLE 1
451 #define VXGE_HW_RTS_MAC_DEFAULT 0
454 #define VXGE_HW_HWTS_DISABLE 0
455 #define VXGE_HW_HWTS_ENABLE 1
456 #define VXGE_HW_HWTS_DEFAULT 1
678 #define VXGE_HW_VP_NOT_OPEN 0
679 #define VXGE_HW_VP_OPEN 1
735 #define VXGE_HW_DEVICE_MAGIC 0x12345678
736 #define VXGE_HW_DEVICE_DEAD 0xDEADDEAD
748 #define VXGE_HW_DEVICE_ACCESS_RIGHT_VPATH 0x1
749 #define VXGE_HW_DEVICE_ACCESS_RIGHT_SRPCIM 0x2
750 #define VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM 0x4
780 #define VXGE_HW_INFO_LEN 64
798 #define VXGE_HW_NO_MR_NO_SR_NORMAL_FUNCTION 0
799 #define VXGE_HW_MR_NO_SR_VH0_BASE_FUNCTION 1
800 #define VXGE_HW_NO_MR_SR_VH0_FUNCTION0 2
801 #define VXGE_HW_NO_MR_SR_VH0_VIRTUAL_FUNCTION 3
802 #define VXGE_HW_MR_SR_VH0_INVALID_CONFIG 4
803 #define VXGE_HW_SR_VH_FUNCTION0 5
804 #define VXGE_HW_SR_VH_VIRTUAL_FUNCTION 6
805 #define VXGE_HW_VH_NORMAL_FUNCTION 7
807 #define VXGE_HW_FUNCTION_MODE_SINGLE_FUNCTION 0
808 #define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION 1
809 #define VXGE_HW_FUNCTION_MODE_SRIOV 2
810 #define VXGE_HW_FUNCTION_MODE_MRIOV 3
811 #define VXGE_HW_FUNCTION_MODE_MRIOV_8 4
812 #define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION_17 5
813 #define VXGE_HW_FUNCTION_MODE_SRIOV_8 6
814 #define VXGE_HW_FUNCTION_MODE_SRIOV_4 7
815 #define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION_2 8
816 #define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION_4 9
817 #define VXGE_HW_FUNCTION_MODE_MRIOV_4 10
846 #define VXGE_HW_DEVICE_LINK_STATE_SET(hldev, ls) (hldev->link_state = ls)
848 #define VXGE_HW_DEVICE_TIM_INT_MASK_SET(m0, m1, i) { \
850 m0[0] |= vxge_vBIT(0x8, (i*4), 4); \
851 m0[1] |= vxge_vBIT(0x4, (i*4), 4); \
854 m1[0] = 0x80000000; \
855 m1[1] = 0x40000000; \
859 #define VXGE_HW_DEVICE_TIM_INT_MASK_RESET(m0, m1, i) { \
861 m0[0] &= ~vxge_vBIT(0x8, (i*4), 4); \
862 m0[1] &= ~vxge_vBIT(0x4, (i*4), 4); \
870 #define VXGE_HW_DEVICE_STATS_PIO_READ(loc, offset) { \
871 status = vxge_hw_mrpcim_stats_access(hldev, \
872 VXGE_HW_STATS_OP_READ, \
876 if (status != VXGE_HW_OK) \
1113 #define VXGE_HW_NODBW_GET_TYPE(ctrl0) vxge_bVALn(ctrl0, 0, 8)
1114 #define VXGE_HW_NODBW_TYPE(val) vxge_vBIT(val, 0, 8)
1115 #define VXGE_HW_NODBW_TYPE_NODBW 0
1117 #define VXGE_HW_NODBW_GET_LAST_TXD_NUMBER(ctrl0) vxge_bVALn(ctrl0, 32, 8)
1118 #define VXGE_HW_NODBW_LAST_TXD_NUMBER(val) vxge_vBIT(val, 32, 8)
1120 #define VXGE_HW_NODBW_GET_NO_SNOOP(ctrl0) vxge_bVALn(ctrl0, 56, 8)
1121 #define VXGE_HW_NODBW_LIST_NO_SNOOP(val) vxge_vBIT(val, 56, 8)
1122 #define VXGE_HW_NODBW_LIST_NO_SNOOP_TXD_READ_TXD0_WRITE 0x2
1123 #define VXGE_HW_NODBW_LIST_NO_SNOOP_TX_FRAME_DATA_READ 0x1
1261 #define VXGE_HW_FIFO_TXD_LIST_OWN_ADAPTER vxge_mBIT(7)
1263 #define VXGE_HW_FIFO_TXD_T_CODE_GET(ctrl0) vxge_bVALn(ctrl0, 12, 4)
1264 #define VXGE_HW_FIFO_TXD_T_CODE(val) vxge_vBIT(val, 12, 4)
1265 #define VXGE_HW_FIFO_TXD_T_CODE_UNUSED VXGE_HW_FIFO_T_CODE_UNUSED
1268 #define VXGE_HW_FIFO_TXD_GATHER_CODE(val) vxge_vBIT(val, 22, 2)
1269 #define VXGE_HW_FIFO_TXD_GATHER_CODE_FIRST VXGE_HW_FIFO_GATHER_CODE_FIRST
1270 #define VXGE_HW_FIFO_TXD_GATHER_CODE_LAST VXGE_HW_FIFO_GATHER_CODE_LAST
1273 #define VXGE_HW_FIFO_TXD_LSO_EN vxge_mBIT(30)
1275 #define VXGE_HW_FIFO_TXD_LSO_MSS(val) vxge_vBIT(val, 34, 14)
1277 #define VXGE_HW_FIFO_TXD_BUFFER_SIZE(val) vxge_vBIT(val, 48, 16)
1280 #define VXGE_HW_FIFO_TXD_TX_CKO_IPV4_EN vxge_mBIT(5)
1281 #define VXGE_HW_FIFO_TXD_TX_CKO_TCP_EN vxge_mBIT(6)
1282 #define VXGE_HW_FIFO_TXD_TX_CKO_UDP_EN vxge_mBIT(7)
1283 #define VXGE_HW_FIFO_TXD_VLAN_ENABLE vxge_mBIT(15)
1285 #define VXGE_HW_FIFO_TXD_VLAN_TAG(val) vxge_vBIT(val, 16, 16)
1287 #define VXGE_HW_FIFO_TXD_INT_NUMBER(val) vxge_vBIT(val, 34, 6)
1289 #define VXGE_HW_FIFO_TXD_INT_TYPE_PER_LIST vxge_mBIT(46)
1290 #define VXGE_HW_FIFO_TXD_INT_TYPE_UTILZ vxge_mBIT(47)
1388 #define VXGE_HW_RING_RXD_RTH_BUCKET_GET(ctrl0) vxge_bVALn(ctrl0, 0, 7)
1390 #define VXGE_HW_RING_RXD_LIST_OWN_ADAPTER vxge_mBIT(7)
1392 #define VXGE_HW_RING_RXD_FAST_PATH_ELIGIBLE_GET(ctrl0) vxge_bVALn(ctrl0, 8, 1)
1394 #define VXGE_HW_RING_RXD_L3_CKSUM_CORRECT_GET(ctrl0) vxge_bVALn(ctrl0, 9, 1)
1396 #define VXGE_HW_RING_RXD_L4_CKSUM_CORRECT_GET(ctrl0) vxge_bVALn(ctrl0, 10, 1)
1398 #define VXGE_HW_RING_RXD_T_CODE_GET(ctrl0) vxge_bVALn(ctrl0, 12, 4)
1399 #define VXGE_HW_RING_RXD_T_CODE(val) vxge_vBIT(val, 12, 4)
1401 #define VXGE_HW_RING_RXD_T_CODE_UNUSED VXGE_HW_RING_T_CODE_UNUSED
1403 #define VXGE_HW_RING_RXD_SYN_GET(ctrl0) vxge_bVALn(ctrl0, 16, 1)
1405 #define VXGE_HW_RING_RXD_IS_ICMP_GET(ctrl0) vxge_bVALn(ctrl0, 17, 1)
1407 #define VXGE_HW_RING_RXD_RTH_SPDM_HIT_GET(ctrl0) vxge_bVALn(ctrl0, 18, 1)
1409 #define VXGE_HW_RING_RXD_RTH_IT_HIT_GET(ctrl0) vxge_bVALn(ctrl0, 19, 1)
1411 #define VXGE_HW_RING_RXD_RTH_HASH_TYPE_GET(ctrl0) vxge_bVALn(ctrl0, 20, 4)
1413 #define VXGE_HW_RING_RXD_IS_VLAN_GET(ctrl0) vxge_bVALn(ctrl0, 24, 1)
1415 #define VXGE_HW_RING_RXD_ETHER_ENCAP_GET(ctrl0) vxge_bVALn(ctrl0, 25, 2)
1417 #define VXGE_HW_RING_RXD_FRAME_PROTO_GET(ctrl0) vxge_bVALn(ctrl0, 27, 5)
1419 #define VXGE_HW_RING_RXD_L3_CKSUM_GET(ctrl0) vxge_bVALn(ctrl0, 32, 16)
1421 #define VXGE_HW_RING_RXD_L4_CKSUM_GET(ctrl0) vxge_bVALn(ctrl0, 48, 16)
1425 #define VXGE_HW_RING_RXD_1_BUFFER0_SIZE_GET(ctrl1) vxge_bVALn(ctrl1, 2, 14)
1426 #define VXGE_HW_RING_RXD_1_BUFFER0_SIZE(val) vxge_vBIT(val, 2, 14)
1427 #define VXGE_HW_RING_RXD_1_BUFFER0_SIZE_MASK vxge_vBIT(0x3FFF, 2, 14)
1429 #define VXGE_HW_RING_RXD_1_RTH_HASH_VAL_GET(ctrl1) vxge_bVALn(ctrl1, 16, 32)
1431 #define VXGE_HW_RING_RXD_VLAN_TAG_GET(ctrl1) vxge_bVALn(ctrl1, 48, 16)
1481 static inline u32 vxge_hw_ring_rxd_size_get(
u32 buf_mode)
1492 static inline u32 vxge_hw_ring_rxds_per_block_get(
u32 buf_mode)
1514 void vxge_hw_ring_rxd_1b_set(
1540 void vxge_hw_ring_rxd_1b_get(
1562 void vxge_hw_ring_rxd_1b_info_get(
1612 static inline void *vxge_hw_ring_rxd_private_get(
void *rxdh)
1634 static inline void vxge_hw_fifo_txdl_cksum_set_bits(
void *txdlh,
u64 cksum_bits)
1654 static inline void vxge_hw_fifo_txdl_mss_set(
void *txdlh,
int mss)
1670 static inline void vxge_hw_fifo_txdl_vlan_set(
void *txdlh,
u16 vlan_tag)
1689 static inline void *vxge_hw_fifo_txdl_private_get(
void *txdlh)
1823 int nr_skb,
int *more);
1897 static inline void *vxge_os_dma_malloc(
struct pci_dev *pdev,
1904 unsigned long misaligned = 0;
1905 int realloc_flag = 0;
1906 *p_dma_acch = *p_dmah =
NULL;
1913 vaddr =
kmalloc((size), flags);
1931 *(
unsigned long *)p_dma_acch = misaligned;
1932 vaddr = (
void *)((
u8 *)vaddr + misaligned);
1936 static inline void vxge_os_dma_free(
struct pci_dev *pdev,
const void *vaddr,
1939 unsigned long misaligned = *(
unsigned long *)p_dma_acch;
1949 __vxge_hw_mempool_item_priv(
1953 u32 *memblock_item_idx)
1959 offset = (
u32)((
u8 *)item - (
u8 *)memblock);
1962 (*memblock_item_idx) = (
u32) offset / mempool->
item_size;
2018 ret =
readl(addr + 4);
2034 static inline void __vxge_hw_pio_mem_write32_upper(
u32 val,
void __iomem *addr)
2039 static inline void __vxge_hw_pio_mem_write32_lower(
u32 val,
void __iomem *addr)
2063 #if (VXGE_COMPONENT_LL & VXGE_DEBUG_MODULE_MASK)
2064 #define vxge_debug_ll(level, mask, fmt, ...) do { \
2065 if ((level >= VXGE_ERR && VXGE_COMPONENT_LL & VXGE_DEBUG_ERR_MASK) || \
2066 (level >= VXGE_TRACE && VXGE_COMPONENT_LL & VXGE_DEBUG_TRACE_MASK))\
2067 if ((mask & VXGE_DEBUG_MASK) == mask) \
2068 printk(fmt "\n", __VA_ARGS__); \
2071 #define vxge_debug_ll(level, mask, fmt, ...)
2090 #define VXGE_HW_MIN_SUCCESSIVE_IDLE_COUNT 5
2091 #define VXGE_HW_MAX_POLLING_COUNT 100