37 #include <linux/netdevice.h>
40 #include <linux/kernel.h>
42 #include <linux/pci.h>
45 #include <linux/slab.h>
55 #define NES_SEND_FIRST_WRITE
57 #define QUEUE_DISCONNECTS
59 #define DRV_NAME "iw_nes"
60 #define DRV_VERSION "1.5.0.1"
61 #define PFX DRV_NAME ": "
66 #ifndef PCI_VENDOR_ID_NETEFFECT
67 #define PCI_VENDOR_ID_NETEFFECT 0x1678
68 #define PCI_DEVICE_ID_NETEFFECT_NE020 0x0100
69 #define PCI_DEVICE_ID_NETEFFECT_NE020_KR 0x0110
78 #define RX_BUF_SIZE (1536 + 8)
79 #define NES_REG0_SIZE (4 * 1024)
80 #define NES_TX_TIMEOUT (6*HZ)
81 #define NES_FIRST_QPN 64
82 #define NES_SW_CONTEXT_ALIGN 1024
84 #define NES_NIC_MAX_NICS 16
85 #define NES_MAX_ARP_TABLE_SIZE 4096
87 #define NES_NIC_CEQ_SIZE 8
89 #define NES_CCEQ_SIZE ((nesadapter->max_cq / nesadapter->port_count) - 32)
91 #define NES_MAX_PORT_COUNT 4
93 #define MAX_DPC_ITERATIONS 128
95 #define NES_DRV_OPT_ENABLE_MPA_VER_0 0x00000001
96 #define NES_DRV_OPT_DISABLE_MPA_CRC 0x00000002
97 #define NES_DRV_OPT_DISABLE_FIRST_WRITE 0x00000004
98 #define NES_DRV_OPT_DISABLE_INTF 0x00000008
99 #define NES_DRV_OPT_ENABLE_MSI 0x00000010
100 #define NES_DRV_OPT_DUAL_LOGICAL_PORT 0x00000020
101 #define NES_DRV_OPT_SUPRESS_OPTION_BC 0x00000040
102 #define NES_DRV_OPT_NO_INLINE_DATA 0x00000080
103 #define NES_DRV_OPT_DISABLE_INT_MOD 0x00000100
104 #define NES_DRV_OPT_DISABLE_VIRT_WQ 0x00000200
105 #define NES_DRV_OPT_ENABLE_PAU 0x00000400
107 #define NES_AEQ_EVENT_TIMEOUT 2500
108 #define NES_DISCONNECT_EVENT_TIMEOUT 2000
112 #define NES_DBG_HW 0x00000001
113 #define NES_DBG_INIT 0x00000002
114 #define NES_DBG_ISR 0x00000004
115 #define NES_DBG_PHY 0x00000008
116 #define NES_DBG_NETDEV 0x00000010
117 #define NES_DBG_CM 0x00000020
118 #define NES_DBG_CM1 0x00000040
119 #define NES_DBG_NIC_RX 0x00000080
120 #define NES_DBG_NIC_TX 0x00000100
121 #define NES_DBG_CQP 0x00000200
122 #define NES_DBG_MMAP 0x00000400
123 #define NES_DBG_MR 0x00000800
124 #define NES_DBG_PD 0x00001000
125 #define NES_DBG_CQ 0x00002000
126 #define NES_DBG_QP 0x00004000
127 #define NES_DBG_MOD_QP 0x00008000
128 #define NES_DBG_AEQ 0x00010000
129 #define NES_DBG_IW_RX 0x00020000
130 #define NES_DBG_IW_TX 0x00040000
131 #define NES_DBG_SHUTDOWN 0x00080000
132 #define NES_DBG_PAU 0x00100000
133 #define NES_DBG_RSVD1 0x10000000
134 #define NES_DBG_RSVD2 0x20000000
135 #define NES_DBG_RSVD3 0x40000000
136 #define NES_DBG_RSVD4 0x80000000
137 #define NES_DBG_ALL 0xffffffff
139 #ifdef CONFIG_INFINIBAND_NES_DEBUG
140 #define nes_debug(level, fmt, args...) \
142 if (level & nes_debug_level) \
143 printk(KERN_ERR PFX "%s[%u]: " fmt, __func__, __LINE__, ##args); \
146 #define assert(expr) \
149 printk(KERN_ERR PFX "Assertion failed! %s, %s, %s, line %d\n", \
150 #expr, __FILE__, __func__, __LINE__); \
154 #define NES_EVENT_TIMEOUT 1200000
156 #define nes_debug(level, fmt, args...)
157 #define assert(expr) do {} while (0)
159 #define NES_EVENT_TIMEOUT 100000
170 #define max_frame_len (max_mtu+ETH_HLEN)
312 set_wqe_32bit_value(
__le32 *wqe_words,
u32 index,
u32 value)
335 value = ((
u32)((
unsigned long) nesqp)) |
head;
342 static inline u32 nes_read_indexed(
struct nes_device *nesdev,
u32 reg_index)
357 static inline u32 nes_read32(
const void __iomem *addr)
362 static inline u16 nes_read16(
const void __iomem *addr)
367 static inline u8 nes_read8(
const void __iomem *addr)
386 static inline void nes_write32(
void __iomem *addr,
u32 val)
391 static inline void nes_write16(
void __iomem *addr,
u16 val)
396 static inline void nes_write8(
void __iomem *addr,
u8 val)
412 static inline int nes_alloc_resource(
struct nes_adapter *nesadapter,
413 unsigned long *resource_array,
u32 max_resources,
422 if (resource_num >= max_resources) {
424 if (resource_num >= max_resources) {
425 printk(
KERN_ERR PFX "%s: No available resources [type=%u].\n", __func__, resource_type);
430 set_bit(resource_num, resource_array);
431 *next = resource_num+1;
432 if (*next == max_resources) {
436 *req_resource_num = resource_num;
441 static inline int nes_is_resource_allocated(
struct nes_adapter *nesadapter,
442 unsigned long *resource_array,
u32 resource_num)
449 bit_is_set =
test_bit(resource_num, resource_array);
451 resource_num, (bit_is_set ?
"":
" not"));
457 static inline void nes_free_resource(
struct nes_adapter *nesadapter,
458 unsigned long *resource_array,
u32 resource_num)