diff options
author | Amit S. Kale <amitkale@netxen.com> | 2006-12-04 12:23:25 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-12-04 18:36:03 -0500 |
commit | ed25ffa16434724f5ed825aa48734c7f3aefa203 (patch) | |
tree | 71cff36d0b2f43adf20e67ac6cc3ba3020f94ff2 /drivers/net/netxen/netxen_nic.h | |
parent | 80922fbcb6f00127e91580e7565bb665947ac5d3 (diff) |
[PATCH] NetXen: multiport firmware support, ioctl interface
NetXen: 1G/10G Ethernet driver updates
- Multiport and newer firmware support
- ioctl interface for user level tools
- Cast error fix for multiport
Signed-off-by: Amit S. Kale <amitkale@netxen.com>
netxen_nic.h | 281 +++++++++++++++++++++++++-------
netxen_nic_ethtool.c | 12 -
netxen_nic_hw.c | 429 +++++++++++++++++++++++++++++++++++++++++---------
netxen_nic_init.c | 301 ++++++++++++++++++++++++++++++-----
netxen_nic_ioctl.h | 2
netxen_nic_isr.c | 3
netxen_nic_main.c | 260 ++++++++++++++++++------------
netxen_nic_niu.c | 22 +-
netxen_nic_phan_reg.h | 228 ++++++++++++++++----------
9 files changed, 1161 insertions(+), 377 deletions(-)
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/netxen/netxen_nic.h')
-rw-r--r-- | drivers/net/netxen/netxen_nic.h | 281 |
1 files changed, 219 insertions, 62 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index d51f43709cb5..3151aaa7906e 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h | |||
@@ -63,27 +63,49 @@ | |||
63 | 63 | ||
64 | #include "netxen_nic_hw.h" | 64 | #include "netxen_nic_hw.h" |
65 | 65 | ||
66 | #define NETXEN_NIC_BUILD_NO "5" | 66 | #define NETXEN_NIC_BUILD_NO "1" |
67 | #define _NETXEN_NIC_LINUX_MAJOR 2 | 67 | #define _NETXEN_NIC_LINUX_MAJOR 3 |
68 | #define _NETXEN_NIC_LINUX_MINOR 3 | 68 | #define _NETXEN_NIC_LINUX_MINOR 3 |
69 | #define _NETXEN_NIC_LINUX_SUBVERSION 59 | 69 | #define _NETXEN_NIC_LINUX_SUBVERSION 2 |
70 | #define NETXEN_NIC_LINUX_VERSIONID "2.3.59" "-" NETXEN_NIC_BUILD_NO | 70 | #define NETXEN_NIC_LINUX_VERSIONID "3.3.2" "-" NETXEN_NIC_BUILD_NO |
71 | #define NETXEN_NIC_FW_VERSIONID "2.3.59" | 71 | #define NETXEN_NIC_FW_VERSIONID "3.3.2" |
72 | 72 | ||
73 | #define RCV_DESC_RINGSIZE \ | 73 | #define RCV_DESC_RINGSIZE \ |
74 | (sizeof(struct rcv_desc) * adapter->max_rx_desc_count) | 74 | (sizeof(struct rcv_desc) * adapter->max_rx_desc_count) |
75 | #define STATUS_DESC_RINGSIZE \ | 75 | #define STATUS_DESC_RINGSIZE \ |
76 | (sizeof(struct status_desc)* adapter->max_rx_desc_count) | 76 | (sizeof(struct status_desc)* adapter->max_rx_desc_count) |
77 | #define LRO_DESC_RINGSIZE \ | ||
78 | (sizeof(rcvDesc_t) * adapter->max_lro_rx_desc_count) | ||
77 | #define TX_RINGSIZE \ | 79 | #define TX_RINGSIZE \ |
78 | (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count) | 80 | (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count) |
79 | #define RCV_BUFFSIZE \ | 81 | #define RCV_BUFFSIZE \ |
80 | (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count) | 82 | (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count) |
81 | #define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a))) | 83 | #define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a))) |
82 | 84 | ||
83 | #define NETXEN_NETDEV_STATUS 0x1 | 85 | #define NETXEN_NETDEV_STATUS 0x1 |
86 | #define NETXEN_RCV_PRODUCER_OFFSET 0 | ||
87 | #define NETXEN_RCV_PEG_DB_ID 2 | ||
88 | #define NETXEN_HOST_DUMMY_DMA_SIZE 1024 | ||
84 | 89 | ||
85 | #define ADDR_IN_WINDOW1(off) \ | 90 | #define ADDR_IN_WINDOW1(off) \ |
86 | ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0 | 91 | ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0 |
92 | /* | ||
93 | * In netxen_nic_down(), we must wait for any pending callback requests into | ||
94 | * netxen_watchdog_task() to complete; eg otherwise the watchdog_timer could be | ||
95 | * reenabled right after it is deleted in netxen_nic_down(). FLUSH_SCHEDULED_WORK() | ||
96 | * does this synchronization. | ||
97 | * | ||
98 | * Normally, schedule_work()/flush_scheduled_work() could have worked, but | ||
99 | * netxen_nic_close() is invoked with kernel rtnl lock held. netif_carrier_off() | ||
100 | * call in netxen_nic_close() triggers a schedule_work(&linkwatch_work), and a | ||
101 | * subsequent call to flush_scheduled_work() in netxen_nic_down() would cause | ||
102 | * linkwatch_event() to be executed which also attempts to acquire the rtnl | ||
103 | * lock thus causing a deadlock. | ||
104 | */ | ||
105 | |||
106 | #define SCHEDULE_WORK(tp) queue_work(netxen_workq, tp) | ||
107 | #define FLUSH_SCHEDULED_WORK() flush_workqueue(netxen_workq) | ||
108 | extern struct workqueue_struct *netxen_workq; | ||
87 | 109 | ||
88 | /* | 110 | /* |
89 | * normalize a 64MB crb address to 32MB PCI window | 111 | * normalize a 64MB crb address to 32MB PCI window |
@@ -95,8 +117,14 @@ | |||
95 | #define NETXEN_CRB_NORMALIZE(adapter, reg) \ | 117 | #define NETXEN_CRB_NORMALIZE(adapter, reg) \ |
96 | pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg)) | 118 | pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg)) |
97 | 119 | ||
120 | #define DB_NORMALIZE(adapter, off) \ | ||
121 | (adapter->ahw.db_base + (off)) | ||
122 | |||
123 | #define NX_P2_C0 0x24 | ||
124 | #define NX_P2_C1 0x25 | ||
125 | |||
98 | #define FIRST_PAGE_GROUP_START 0 | 126 | #define FIRST_PAGE_GROUP_START 0 |
99 | #define FIRST_PAGE_GROUP_END 0x400000 | 127 | #define FIRST_PAGE_GROUP_END 0x100000 |
100 | 128 | ||
101 | #define SECOND_PAGE_GROUP_START 0x4000000 | 129 | #define SECOND_PAGE_GROUP_START 0x4000000 |
102 | #define SECOND_PAGE_GROUP_END 0x66BC000 | 130 | #define SECOND_PAGE_GROUP_END 0x66BC000 |
@@ -108,11 +136,13 @@ | |||
108 | #define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START | 136 | #define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START |
109 | #define THIRD_PAGE_GROUP_SIZE THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START | 137 | #define THIRD_PAGE_GROUP_SIZE THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START |
110 | 138 | ||
111 | #define MAX_RX_BUFFER_LENGTH 2000 | 139 | #define MAX_RX_BUFFER_LENGTH 1760 |
112 | #define MAX_RX_JUMBO_BUFFER_LENGTH 9046 | 140 | #define MAX_RX_JUMBO_BUFFER_LENGTH 9046 |
113 | #define RX_DMA_MAP_LEN (MAX_RX_BUFFER_LENGTH - NET_IP_ALIGN) | 141 | #define MAX_RX_LRO_BUFFER_LENGTH ((48*1024)-512) |
142 | #define RX_DMA_MAP_LEN (MAX_RX_BUFFER_LENGTH - 2) | ||
114 | #define RX_JUMBO_DMA_MAP_LEN \ | 143 | #define RX_JUMBO_DMA_MAP_LEN \ |
115 | (MAX_RX_JUMBO_BUFFER_LENGTH - NET_IP_ALIGN) | 144 | (MAX_RX_JUMBO_BUFFER_LENGTH - 2) |
145 | #define RX_LRO_DMA_MAP_LEN (MAX_RX_LRO_BUFFER_LENGTH - 2) | ||
116 | #define NETXEN_ROM_ROUNDUP 0x80000000ULL | 146 | #define NETXEN_ROM_ROUNDUP 0x80000000ULL |
117 | 147 | ||
118 | /* | 148 | /* |
@@ -151,30 +181,38 @@ enum { | |||
151 | /* Host writes the following to notify that it has done the init-handshake */ | 181 | /* Host writes the following to notify that it has done the init-handshake */ |
152 | #define PHAN_INITIALIZE_ACK 0xf00f | 182 | #define PHAN_INITIALIZE_ACK 0xf00f |
153 | 183 | ||
154 | #define NUM_RCV_DESC_RINGS 2 /* No of Rcv Descriptor contexts */ | 184 | #define NUM_RCV_DESC_RINGS 3 /* No of Rcv Descriptor contexts */ |
155 | 185 | ||
156 | /* descriptor types */ | 186 | /* descriptor types */ |
157 | #define RCV_DESC_NORMAL 0x01 | 187 | #define RCV_DESC_NORMAL 0x01 |
158 | #define RCV_DESC_JUMBO 0x02 | 188 | #define RCV_DESC_JUMBO 0x02 |
189 | #define RCV_DESC_LRO 0x04 | ||
159 | #define RCV_DESC_NORMAL_CTXID 0 | 190 | #define RCV_DESC_NORMAL_CTXID 0 |
160 | #define RCV_DESC_JUMBO_CTXID 1 | 191 | #define RCV_DESC_JUMBO_CTXID 1 |
192 | #define RCV_DESC_LRO_CTXID 2 | ||
161 | 193 | ||
162 | #define RCV_DESC_TYPE(ID) \ | 194 | #define RCV_DESC_TYPE(ID) \ |
163 | ((ID == RCV_DESC_JUMBO_CTXID) ? RCV_DESC_JUMBO : RCV_DESC_NORMAL) | 195 | ((ID == RCV_DESC_JUMBO_CTXID) \ |
196 | ? RCV_DESC_JUMBO \ | ||
197 | : ((ID == RCV_DESC_LRO_CTXID) \ | ||
198 | ? RCV_DESC_LRO : \ | ||
199 | (RCV_DESC_NORMAL))) | ||
164 | 200 | ||
165 | #define MAX_CMD_DESCRIPTORS 1024 | 201 | #define MAX_CMD_DESCRIPTORS 1024 |
166 | #define MAX_RCV_DESCRIPTORS 32768 | 202 | #define MAX_RCV_DESCRIPTORS 32768 |
167 | #define MAX_JUMBO_RCV_DESCRIPTORS 4096 | 203 | #define MAX_JUMBO_RCV_DESCRIPTORS 4096 |
204 | #define MAX_LRO_RCV_DESCRIPTORS 2048 | ||
168 | #define MAX_RCVSTATUS_DESCRIPTORS MAX_RCV_DESCRIPTORS | 205 | #define MAX_RCVSTATUS_DESCRIPTORS MAX_RCV_DESCRIPTORS |
169 | #define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS | 206 | #define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS |
170 | #define MAX_RCV_DESC MAX_RCV_DESCRIPTORS | 207 | #define MAX_RCV_DESC MAX_RCV_DESCRIPTORS |
171 | #define MAX_RCVSTATUS_DESC MAX_RCV_DESCRIPTORS | 208 | #define MAX_RCVSTATUS_DESC MAX_RCV_DESCRIPTORS |
172 | #define NUM_RCV_DESC (MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS) | ||
173 | #define MAX_EPG_DESCRIPTORS (MAX_CMD_DESCRIPTORS * 8) | 209 | #define MAX_EPG_DESCRIPTORS (MAX_CMD_DESCRIPTORS * 8) |
174 | 210 | #define NUM_RCV_DESC (MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS + \ | |
211 | MAX_LRO_RCV_DESCRIPTORS) | ||
175 | #define MIN_TX_COUNT 4096 | 212 | #define MIN_TX_COUNT 4096 |
176 | #define MIN_RX_COUNT 4096 | 213 | #define MIN_RX_COUNT 4096 |
177 | 214 | #define NETXEN_CTX_SIGNATURE 0xdee0 | |
215 | #define NETXEN_RCV_PRODUCER(ringid) (ringid) | ||
178 | #define MAX_FRAME_SIZE 0x10000 /* 64K MAX size for LSO */ | 216 | #define MAX_FRAME_SIZE 0x10000 /* 64K MAX size for LSO */ |
179 | 217 | ||
180 | #define PHAN_PEG_RCV_INITIALIZED 0xff01 | 218 | #define PHAN_PEG_RCV_INITIALIZED 0xff01 |
@@ -186,6 +224,67 @@ enum { | |||
186 | #define get_index_range(index,length,count) \ | 224 | #define get_index_range(index,length,count) \ |
187 | (((index) + (count)) & ((length) - 1)) | 225 | (((index) + (count)) & ((length) - 1)) |
188 | 226 | ||
227 | #define MPORT_SINGLE_FUNCTION_MODE 0x1111 | ||
228 | |||
229 | extern unsigned long long netxen_dma_mask; | ||
230 | |||
231 | /* | ||
232 | * NetXen host-peg signal message structure | ||
233 | * | ||
234 | * Bit 0-1 : peg_id => 0x2 for tx and 01 for rx | ||
235 | * Bit 2 : priv_id => must be 1 | ||
236 | * Bit 3-17 : count => for doorbell | ||
237 | * Bit 18-27 : ctx_id => Context id | ||
238 | * Bit 28-31 : opcode | ||
239 | */ | ||
240 | |||
241 | typedef u32 netxen_ctx_msg; | ||
242 | |||
243 | #define _netxen_set_bits(config_word, start, bits, val) {\ | ||
244 | unsigned long long mask = (((1ULL << (bits)) - 1) << (start)); \ | ||
245 | unsigned long long value = (val); \ | ||
246 | (config_word) &= ~mask; \ | ||
247 | (config_word) |= (((value) << (start)) & mask); \ | ||
248 | } | ||
249 | |||
250 | #define netxen_set_msg_peg_id(config_word, val) \ | ||
251 | _netxen_set_bits(config_word, 0, 2, val) | ||
252 | #define netxen_set_msg_privid(config_word) \ | ||
253 | set_bit(2, (unsigned long*)&config_word) | ||
254 | #define netxen_set_msg_count(config_word, val) \ | ||
255 | _netxen_set_bits(config_word, 3, 15, val) | ||
256 | #define netxen_set_msg_ctxid(config_word, val) \ | ||
257 | _netxen_set_bits(config_word, 18, 10, val) | ||
258 | #define netxen_set_msg_opcode(config_word, val) \ | ||
259 | _netxen_set_bits(config_word, 28, 4, val) | ||
260 | |||
261 | struct netxen_rcv_context { | ||
262 | u32 rcv_ring_addr_lo; | ||
263 | u32 rcv_ring_addr_hi; | ||
264 | u32 rcv_ring_size; | ||
265 | u32 rsrvd; | ||
266 | }; | ||
267 | |||
268 | struct netxen_ring_ctx { | ||
269 | |||
270 | /* one command ring */ | ||
271 | u64 cmd_consumer_offset; | ||
272 | u32 cmd_ring_addr_lo; | ||
273 | u32 cmd_ring_addr_hi; | ||
274 | u32 cmd_ring_size; | ||
275 | u32 rsrvd; | ||
276 | |||
277 | /* three receive rings */ | ||
278 | struct netxen_rcv_context rcv_ctx[3]; | ||
279 | |||
280 | /* one status ring */ | ||
281 | u32 sts_ring_addr_lo; | ||
282 | u32 sts_ring_addr_hi; | ||
283 | u32 sts_ring_size; | ||
284 | |||
285 | u32 ctx_id; | ||
286 | } __attribute__ ((aligned(64))); | ||
287 | |||
189 | /* | 288 | /* |
190 | * Following data structures describe the descriptors that will be used. | 289 | * Following data structures describe the descriptors that will be used. |
191 | * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when | 290 | * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when |
@@ -203,22 +302,32 @@ enum { | |||
203 | #define FLAGS_IPSEC_SA_DELETE 0x08 | 302 | #define FLAGS_IPSEC_SA_DELETE 0x08 |
204 | #define FLAGS_VLAN_TAGGED 0x10 | 303 | #define FLAGS_VLAN_TAGGED 0x10 |
205 | 304 | ||
206 | #define CMD_DESC_TOTAL_LENGTH(cmd_desc) \ | 305 | #define netxen_set_cmd_desc_port(cmd_desc, var) \ |
207 | ((cmd_desc)->length_tcp_hdr & 0x00FFFFFF) | 306 | ((cmd_desc)->port_ctxid |= ((var) & 0x0F)) |
208 | #define CMD_DESC_TCP_HDR_OFFSET(cmd_desc) \ | ||
209 | (((cmd_desc)->length_tcp_hdr >> 24) & 0x0FF) | ||
210 | #define CMD_DESC_PORT(cmd_desc) ((cmd_desc)->port_ctxid & 0x0F) | ||
211 | #define CMD_DESC_CTX_ID(cmd_desc) (((cmd_desc)->port_ctxid >> 4) & 0x0F) | ||
212 | 307 | ||
213 | #define CMD_DESC_TOTAL_LENGTH_WRT(cmd_desc, var) \ | 308 | #define netxen_set_cmd_desc_flags(cmd_desc, val) \ |
214 | ((cmd_desc)->length_tcp_hdr |= ((var) & 0x00FFFFFF)) | 309 | _netxen_set_bits((cmd_desc)->flags_opcode, 0, 7, val) |
215 | #define CMD_DESC_TCP_HDR_OFFSET_WRT(cmd_desc, var) \ | 310 | #define netxen_set_cmd_desc_opcode(cmd_desc, val) \ |
216 | ((cmd_desc)->length_tcp_hdr |= (((var) << 24) & 0xFF000000)) | 311 | _netxen_set_bits((cmd_desc)->flags_opcode, 7, 6, val) |
217 | #define CMD_DESC_PORT_WRT(cmd_desc, var) \ | 312 | |
218 | ((cmd_desc)->port_ctxid |= ((var) & 0x0F)) | 313 | #define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \ |
314 | _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 0, 8, val); | ||
315 | #define netxen_set_cmd_desc_totallength(cmd_desc, val) \ | ||
316 | _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 8, 24, val); | ||
317 | |||
318 | #define netxen_get_cmd_desc_opcode(cmd_desc) \ | ||
319 | (((cmd_desc)->flags_opcode >> 7) & 0x003F) | ||
320 | #define netxen_get_cmd_desc_totallength(cmd_desc) \ | ||
321 | (((cmd_desc)->num_of_buffers_total_length >> 8) & 0x0FFFFFF) | ||
219 | 322 | ||
220 | struct cmd_desc_type0 { | 323 | struct cmd_desc_type0 { |
221 | u64 netxen_next; /* for fragments handled by Phantom */ | 324 | u8 tcp_hdr_offset; /* For LSO only */ |
325 | u8 ip_hdr_offset; /* For LSO only */ | ||
326 | /* Bit pattern: 0-6 flags, 7-12 opcode, 13-15 unused */ | ||
327 | u16 flags_opcode; | ||
328 | /* Bit pattern: 0-7 total number of segments, | ||
329 | 8-31 Total size of the packet */ | ||
330 | u32 num_of_buffers_total_length; | ||
222 | union { | 331 | union { |
223 | struct { | 332 | struct { |
224 | u32 addr_low_part2; | 333 | u32 addr_low_part2; |
@@ -227,13 +336,6 @@ struct cmd_desc_type0 { | |||
227 | u64 addr_buffer2; | 336 | u64 addr_buffer2; |
228 | }; | 337 | }; |
229 | 338 | ||
230 | /* Bit pattern: 0-23 total length, 24-32 tcp header offset */ | ||
231 | u32 length_tcp_hdr; | ||
232 | u8 ip_hdr_offset; /* For LSO only */ | ||
233 | u8 num_of_buffers; /* total number of segments */ | ||
234 | u8 flags; /* as defined above */ | ||
235 | u8 opcode; | ||
236 | |||
237 | u16 reference_handle; /* changed to u16 to add mss */ | 339 | u16 reference_handle; /* changed to u16 to add mss */ |
238 | u16 mss; /* passed by NDIS_PACKET for LSO */ | 340 | u16 mss; /* passed by NDIS_PACKET for LSO */ |
239 | /* Bit pattern 0-3 port, 0-3 ctx id */ | 341 | /* Bit pattern 0-3 port, 0-3 ctx id */ |
@@ -248,7 +350,6 @@ struct cmd_desc_type0 { | |||
248 | }; | 350 | }; |
249 | u64 addr_buffer3; | 351 | u64 addr_buffer3; |
250 | }; | 352 | }; |
251 | |||
252 | union { | 353 | union { |
253 | struct { | 354 | struct { |
254 | u32 addr_low_part1; | 355 | u32 addr_low_part1; |
@@ -270,6 +371,8 @@ struct cmd_desc_type0 { | |||
270 | u64 addr_buffer4; | 371 | u64 addr_buffer4; |
271 | }; | 372 | }; |
272 | 373 | ||
374 | u64 unused; | ||
375 | |||
273 | } __attribute__ ((aligned(64))); | 376 | } __attribute__ ((aligned(64))); |
274 | 377 | ||
275 | /* Note: sizeof(rcv_desc) should always be a mutliple of 2 */ | 378 | /* Note: sizeof(rcv_desc) should always be a mutliple of 2 */ |
@@ -296,22 +399,49 @@ struct rcv_desc { | |||
296 | #define NETXEN_PROT_UNKNOWN (0) | 399 | #define NETXEN_PROT_UNKNOWN (0) |
297 | 400 | ||
298 | /* Note: sizeof(status_desc) should always be a mutliple of 2 */ | 401 | /* Note: sizeof(status_desc) should always be a mutliple of 2 */ |
299 | #define STATUS_DESC_PORT(status_desc) \ | 402 | |
300 | ((status_desc)->port_status_type_op & 0x0F) | 403 | #define netxen_get_sts_desc_lro_cnt(status_desc) \ |
301 | #define STATUS_DESC_STATUS(status_desc) \ | 404 | ((status_desc)->lro & 0x7F) |
302 | (((status_desc)->port_status_type_op >> 4) & 0x0F) | 405 | #define netxen_get_sts_desc_lro_last_frag(status_desc) \ |
303 | #define STATUS_DESC_TYPE(status_desc) \ | 406 | (((status_desc)->lro & 0x80) >> 7) |
304 | (((status_desc)->port_status_type_op >> 8) & 0x0F) | 407 | |
305 | #define STATUS_DESC_OPCODE(status_desc) \ | 408 | #define netxen_get_sts_port(status_desc) \ |
306 | (((status_desc)->port_status_type_op >> 12) & 0x0F) | 409 | ((status_desc)->status_desc_data & 0x0F) |
410 | #define netxen_get_sts_status(status_desc) \ | ||
411 | (((status_desc)->status_desc_data >> 4) & 0x0F) | ||
412 | #define netxen_get_sts_type(status_desc) \ | ||
413 | (((status_desc)->status_desc_data >> 8) & 0x0F) | ||
414 | #define netxen_get_sts_totallength(status_desc) \ | ||
415 | (((status_desc)->status_desc_data >> 12) & 0xFFFF) | ||
416 | #define netxen_get_sts_refhandle(status_desc) \ | ||
417 | (((status_desc)->status_desc_data >> 28) & 0xFFFF) | ||
418 | #define netxen_get_sts_prot(status_desc) \ | ||
419 | (((status_desc)->status_desc_data >> 44) & 0x0F) | ||
420 | #define netxen_get_sts_owner(status_desc) \ | ||
421 | (((status_desc)->status_desc_data >> 56) & 0x03) | ||
422 | #define netxen_get_sts_opcode(status_desc) \ | ||
423 | (((status_desc)->status_desc_data >> 58) & 0x03F) | ||
424 | |||
425 | #define netxen_clear_sts_owner(status_desc) \ | ||
426 | ((status_desc)->status_desc_data &= \ | ||
427 | ~(((unsigned long long)3) << 56 )) | ||
428 | #define netxen_set_sts_owner(status_desc, val) \ | ||
429 | ((status_desc)->status_desc_data |= \ | ||
430 | (((unsigned long long)((val) & 0x3)) << 56 )) | ||
307 | 431 | ||
308 | struct status_desc { | 432 | struct status_desc { |
309 | /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-15 opcode */ | 433 | /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length |
310 | u16 port_status_type_op; | 434 | 28-43 reference_handle, 44-47 protocol, 48-52 unused |
311 | u16 total_length; /* NIC mode */ | 435 | 53-55 desc_cnt, 56-57 owner, 58-63 opcode |
312 | u16 reference_handle; /* handle for the associated packet */ | 436 | */ |
313 | /* Bit pattern: 0-1 owner, 2-5 protocol */ | 437 | u64 status_desc_data; |
314 | u16 owner; /* Owner of the descriptor */ | 438 | u32 hash_value; |
439 | u8 hash_type; | ||
440 | u8 msg_type; | ||
441 | u8 unused; | ||
442 | /* Bit pattern: 0-6 lro_count indicates frag sequence, | ||
443 | 7 last_frag indicates last frag */ | ||
444 | u8 lro; | ||
315 | } __attribute__ ((aligned(8))); | 445 | } __attribute__ ((aligned(8))); |
316 | 446 | ||
317 | enum { | 447 | enum { |
@@ -563,7 +693,8 @@ typedef enum { | |||
563 | #define FLASH_SECONDARY_SIZE (USER_START-SECONDARY_START) | 693 | #define FLASH_SECONDARY_SIZE (USER_START-SECONDARY_START) |
564 | #define NUM_PRIMARY_SECTORS (0x20) | 694 | #define NUM_PRIMARY_SECTORS (0x20) |
565 | #define NUM_CONFIG_SECTORS (1) | 695 | #define NUM_CONFIG_SECTORS (1) |
566 | #define PFX "netxen: " | 696 | #define PFX "NetXen: " |
697 | extern char netxen_nic_driver_name[]; | ||
567 | 698 | ||
568 | /* Note: Make sure to not call this before adapter->port is valid */ | 699 | /* Note: Make sure to not call this before adapter->port is valid */ |
569 | #if !defined(NETXEN_DEBUG) | 700 | #if !defined(NETXEN_DEBUG) |
@@ -609,7 +740,6 @@ struct netxen_cmd_buffer { | |||
609 | u8 frag_count; | 740 | u8 frag_count; |
610 | unsigned long time_stamp; | 741 | unsigned long time_stamp; |
611 | u32 state; | 742 | u32 state; |
612 | u32 no_of_descriptors; | ||
613 | }; | 743 | }; |
614 | 744 | ||
615 | /* In rx_buffer, we do not need multiple fragments as is a single buffer */ | 745 | /* In rx_buffer, we do not need multiple fragments as is a single buffer */ |
@@ -618,6 +748,9 @@ struct netxen_rx_buffer { | |||
618 | u64 dma; | 748 | u64 dma; |
619 | u16 ref_handle; | 749 | u16 ref_handle; |
620 | u16 state; | 750 | u16 state; |
751 | u32 lro_expected_frags; | ||
752 | u32 lro_current_frags; | ||
753 | u32 lro_length; | ||
621 | }; | 754 | }; |
622 | 755 | ||
623 | /* Board types */ | 756 | /* Board types */ |
@@ -633,6 +766,8 @@ struct netxen_hardware_context { | |||
633 | void __iomem *pci_base0; | 766 | void __iomem *pci_base0; |
634 | void __iomem *pci_base1; | 767 | void __iomem *pci_base1; |
635 | void __iomem *pci_base2; | 768 | void __iomem *pci_base2; |
769 | void __iomem *db_base; | ||
770 | unsigned long db_len; | ||
636 | 771 | ||
637 | u8 revision_id; | 772 | u8 revision_id; |
638 | u16 board_type; | 773 | u16 board_type; |
@@ -642,14 +777,13 @@ struct netxen_hardware_context { | |||
642 | u32 qg_linksup; | 777 | u32 qg_linksup; |
643 | /* Address of cmd ring in Phantom */ | 778 | /* Address of cmd ring in Phantom */ |
644 | struct cmd_desc_type0 *cmd_desc_head; | 779 | struct cmd_desc_type0 *cmd_desc_head; |
645 | char *pauseaddr; | ||
646 | struct pci_dev *cmd_desc_pdev; | 780 | struct pci_dev *cmd_desc_pdev; |
647 | dma_addr_t cmd_desc_phys_addr; | 781 | dma_addr_t cmd_desc_phys_addr; |
648 | dma_addr_t pause_physaddr; | ||
649 | struct pci_dev *pause_pdev; | ||
650 | struct netxen_adapter *adapter; | 782 | struct netxen_adapter *adapter; |
651 | }; | 783 | }; |
652 | 784 | ||
785 | #define RCV_RING_LRO RCV_DESC_LRO | ||
786 | |||
653 | #define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */ | 787 | #define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */ |
654 | #define ETHERNET_FCS_SIZE 4 | 788 | #define ETHERNET_FCS_SIZE 4 |
655 | 789 | ||
@@ -702,6 +836,13 @@ struct netxen_recv_context { | |||
702 | }; | 836 | }; |
703 | 837 | ||
704 | #define NETXEN_NIC_MSI_ENABLED 0x02 | 838 | #define NETXEN_NIC_MSI_ENABLED 0x02 |
839 | #define NETXEN_DMA_MASK 0xfffffffe | ||
840 | #define NETXEN_DB_MAPSIZE_BYTES 0x1000 | ||
841 | |||
842 | struct netxen_dummy_dma { | ||
843 | void *addr; | ||
844 | dma_addr_t phys_addr; | ||
845 | }; | ||
705 | 846 | ||
706 | struct netxen_adapter { | 847 | struct netxen_adapter { |
707 | struct netxen_hardware_context ahw; | 848 | struct netxen_hardware_context ahw; |
@@ -711,18 +852,19 @@ struct netxen_adapter { | |||
711 | spinlock_t tx_lock; | 852 | spinlock_t tx_lock; |
712 | spinlock_t lock; | 853 | spinlock_t lock; |
713 | struct work_struct watchdog_task; | 854 | struct work_struct watchdog_task; |
714 | struct work_struct tx_timeout_task; | 855 | struct work_struct tx_timeout_task[NETXEN_MAX_PORTS]; |
715 | struct timer_list watchdog_timer; | 856 | struct timer_list watchdog_timer; |
716 | 857 | ||
717 | u32 curr_window; | 858 | u32 curr_window; |
718 | 859 | ||
719 | u32 cmd_producer; | 860 | u32 cmd_producer; |
720 | u32 cmd_consumer; | 861 | u32 *cmd_consumer; |
721 | 862 | ||
722 | u32 last_cmd_consumer; | 863 | u32 last_cmd_consumer; |
723 | u32 max_tx_desc_count; | 864 | u32 max_tx_desc_count; |
724 | u32 max_rx_desc_count; | 865 | u32 max_rx_desc_count; |
725 | u32 max_jumbo_rx_desc_count; | 866 | u32 max_jumbo_rx_desc_count; |
867 | u32 max_lro_rx_desc_count; | ||
726 | /* Num of instances active on cmd buffer ring */ | 868 | /* Num of instances active on cmd buffer ring */ |
727 | u32 proc_cmd_buf_counter; | 869 | u32 proc_cmd_buf_counter; |
728 | 870 | ||
@@ -744,6 +886,13 @@ struct netxen_adapter { | |||
744 | struct netxen_recv_context recv_ctx[MAX_RCV_CTX]; | 886 | struct netxen_recv_context recv_ctx[MAX_RCV_CTX]; |
745 | 887 | ||
746 | int is_up; | 888 | int is_up; |
889 | int number; | ||
890 | struct netxen_dummy_dma dummy_dma; | ||
891 | |||
892 | /* Context interface shared between card and host */ | ||
893 | struct netxen_ring_ctx *ctx_desc; | ||
894 | struct pci_dev *ctx_desc_pdev; | ||
895 | dma_addr_t ctx_desc_phys_addr; | ||
747 | int (*enable_phy_interrupts) (struct netxen_adapter *, int); | 896 | int (*enable_phy_interrupts) (struct netxen_adapter *, int); |
748 | int (*disable_phy_interrupts) (struct netxen_adapter *, int); | 897 | int (*disable_phy_interrupts) (struct netxen_adapter *, int); |
749 | void (*handle_phy_intr) (struct netxen_adapter *); | 898 | void (*handle_phy_intr) (struct netxen_adapter *); |
@@ -758,7 +907,6 @@ struct netxen_adapter { | |||
758 | int (*init_port) (struct netxen_adapter *, int); | 907 | int (*init_port) (struct netxen_adapter *, int); |
759 | void (*init_niu) (struct netxen_adapter *); | 908 | void (*init_niu) (struct netxen_adapter *); |
760 | int (*stop_port) (struct netxen_adapter *, int); | 909 | int (*stop_port) (struct netxen_adapter *, int); |
761 | |||
762 | }; /* netxen_adapter structure */ | 910 | }; /* netxen_adapter structure */ |
763 | 911 | ||
764 | /* Max number of xmit producer threads that can run simultaneously */ | 912 | /* Max number of xmit producer threads that can run simultaneously */ |
@@ -840,8 +988,6 @@ static inline void __iomem *pci_base(struct netxen_adapter *adapter, | |||
840 | return NULL; | 988 | return NULL; |
841 | } | 989 | } |
842 | 990 | ||
843 | extern char netxen_nic_driver_name[]; | ||
844 | |||
845 | int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter, | 991 | int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter, |
846 | int port); | 992 | int port); |
847 | int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter, | 993 | int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter, |
@@ -880,10 +1026,20 @@ int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off, void *data, | |||
880 | int len); | 1026 | int len); |
881 | int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data, | 1027 | int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data, |
882 | int len); | 1028 | int len); |
1029 | int netxen_nic_hw_read_ioctl(struct netxen_adapter *adapter, u64 off, | ||
1030 | void *data, int len); | ||
1031 | int netxen_nic_hw_write_ioctl(struct netxen_adapter *adapter, u64 off, | ||
1032 | void *data, int len); | ||
1033 | int netxen_nic_pci_mem_write_ioctl(struct netxen_adapter *adapter, | ||
1034 | u64 off, void *data, int size); | ||
1035 | int netxen_nic_pci_mem_read_ioctl(struct netxen_adapter *adapter, | ||
1036 | u64 off, void *data, int size); | ||
883 | void netxen_crb_writelit_adapter(struct netxen_adapter *adapter, | 1037 | void netxen_crb_writelit_adapter(struct netxen_adapter *adapter, |
884 | unsigned long off, int data); | 1038 | unsigned long off, int data); |
885 | 1039 | ||
886 | /* Functions from netxen_nic_init.c */ | 1040 | /* Functions from netxen_nic_init.c */ |
1041 | void netxen_free_adapter_offload(struct netxen_adapter *adapter); | ||
1042 | int netxen_initialize_adapter_offload(struct netxen_adapter *adapter); | ||
887 | void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val); | 1043 | void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val); |
888 | void netxen_load_firmware(struct netxen_adapter *adapter); | 1044 | void netxen_load_firmware(struct netxen_adapter *adapter); |
889 | int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose); | 1045 | int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose); |
@@ -918,7 +1074,9 @@ int netxen_nic_tx_has_work(struct netxen_adapter *adapter); | |||
918 | void netxen_watchdog_task(unsigned long v); | 1074 | void netxen_watchdog_task(unsigned long v); |
919 | void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, | 1075 | void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, |
920 | u32 ringid); | 1076 | u32 ringid); |
921 | void netxen_process_cmd_ring(unsigned long data); | 1077 | void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, u32 ctx, |
1078 | u32 ringid); | ||
1079 | int netxen_process_cmd_ring(unsigned long data); | ||
922 | u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max); | 1080 | u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max); |
923 | void netxen_nic_set_multi(struct net_device *netdev); | 1081 | void netxen_nic_set_multi(struct net_device *netdev); |
924 | int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu); | 1082 | int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu); |
@@ -1012,7 +1170,6 @@ static inline void get_brd_name_by_type(u32 type, char *name) | |||
1012 | 1170 | ||
1013 | int netxen_is_flash_supported(struct netxen_adapter *adapter); | 1171 | int netxen_is_flash_supported(struct netxen_adapter *adapter); |
1014 | int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]); | 1172 | int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]); |
1015 | |||
1016 | extern void netxen_change_ringparam(struct netxen_adapter *adapter); | 1173 | extern void netxen_change_ringparam(struct netxen_adapter *adapter); |
1017 | extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, | 1174 | extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, |
1018 | int *valp); | 1175 | int *valp); |