]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/net/netxen/netxen_nic.h
netxen: cut-through rx changes
[mirror_ubuntu-bionic-kernel.git] / drivers / net / netxen / netxen_nic.h
CommitLineData
3d396eb1
AK
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
80922fbc 4 *
3d396eb1
AK
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
80922fbc 9 *
3d396eb1
AK
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
80922fbc 14 *
3d396eb1
AK
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA.
80922fbc 19 *
3d396eb1
AK
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
80922fbc 22 *
3d396eb1
AK
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 */
29
30#ifndef _NETXEN_NIC_H_
31#define _NETXEN_NIC_H_
32
3d396eb1
AK
33#include <linux/module.h>
34#include <linux/kernel.h>
35#include <linux/types.h>
36#include <linux/compiler.h>
37#include <linux/slab.h>
38#include <linux/delay.h>
39#include <linux/init.h>
40#include <linux/ioport.h>
41#include <linux/pci.h>
42#include <linux/netdevice.h>
43#include <linux/etherdevice.h>
44#include <linux/ip.h>
45#include <linux/in.h>
46#include <linux/tcp.h>
47#include <linux/skbuff.h>
48#include <linux/version.h>
49
50#include <linux/ethtool.h>
51#include <linux/mii.h>
52#include <linux/interrupt.h>
53#include <linux/timer.h>
54
55#include <linux/mm.h>
56#include <linux/mman.h>
57
58#include <asm/system.h>
59#include <asm/io.h>
60#include <asm/byteorder.h>
61#include <asm/uaccess.h>
62#include <asm/pgtable.h>
63
64#include "netxen_nic_hw.h"
65
ed25ffa1 66#define _NETXEN_NIC_LINUX_MAJOR 3
6d1495f2 67#define _NETXEN_NIC_LINUX_MINOR 4
001a731e 68#define _NETXEN_NIC_LINUX_SUBVERSION 18
69#define NETXEN_NIC_LINUX_VERSIONID "3.4.18"
27d2ab54 70
0d04761d
MT
71#define NETXEN_NUM_FLASH_SECTORS (64)
72#define NETXEN_FLASH_SECTOR_SIZE (64 * 1024)
73#define NETXEN_FLASH_TOTAL_SIZE (NETXEN_NUM_FLASH_SECTORS \
74 * NETXEN_FLASH_SECTOR_SIZE)
3d396eb1 75
0c25cfe1
LCMT
76#define PHAN_VENDOR_ID 0x4040
77
3d396eb1
AK
78#define RCV_DESC_RINGSIZE \
79 (sizeof(struct rcv_desc) * adapter->max_rx_desc_count)
80#define STATUS_DESC_RINGSIZE \
81 (sizeof(struct status_desc)* adapter->max_rx_desc_count)
ed25ffa1
AK
82#define LRO_DESC_RINGSIZE \
83 (sizeof(rcvDesc_t) * adapter->max_lro_rx_desc_count)
3d396eb1
AK
84#define TX_RINGSIZE \
85 (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count)
86#define RCV_BUFFSIZE \
48bfd1e0 87 (sizeof(struct netxen_rx_buffer) * rds_ring->max_rx_desc_count)
ba53e6b4 88#define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a)))
3d396eb1 89
ed25ffa1
AK
90#define NETXEN_NETDEV_STATUS 0x1
91#define NETXEN_RCV_PRODUCER_OFFSET 0
92#define NETXEN_RCV_PEG_DB_ID 2
93#define NETXEN_HOST_DUMMY_DMA_SIZE 1024
27d2ab54 94#define FLASH_SUCCESS 0
3d396eb1
AK
95
96#define ADDR_IN_WINDOW1(off) \
97 ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0
98
4790654c
JG
99/*
100 * normalize a 64MB crb address to 32MB PCI window
3d396eb1
AK
101 * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1
102 */
80922fbc
AK
103#define NETXEN_CRB_NORMAL(reg) \
104 ((reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)
cb8011ad 105
3d396eb1 106#define NETXEN_CRB_NORMALIZE(adapter, reg) \
cb8011ad
AK
107 pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg))
108
ed25ffa1
AK
109#define DB_NORMALIZE(adapter, off) \
110 (adapter->ahw.db_base + (off))
111
112#define NX_P2_C0 0x24
113#define NX_P2_C1 0x25
e4c93c81
DP
114#define NX_P3_A0 0x30
115#define NX_P3_A2 0x30
116#define NX_P3_B0 0x40
117#define NX_P3_B1 0x41
118
119#define NX_IS_REVISION_P2(REVISION) (REVISION <= NX_P2_C1)
120#define NX_IS_REVISION_P3(REVISION) (REVISION >= NX_P3_A0)
ed25ffa1 121
cb8011ad 122#define FIRST_PAGE_GROUP_START 0
ed25ffa1 123#define FIRST_PAGE_GROUP_END 0x100000
cb8011ad 124
78403a92
MT
125#define SECOND_PAGE_GROUP_START 0x6000000
126#define SECOND_PAGE_GROUP_END 0x68BC000
cb8011ad
AK
127
128#define THIRD_PAGE_GROUP_START 0x70E4000
129#define THIRD_PAGE_GROUP_END 0x8000000
130
131#define FIRST_PAGE_GROUP_SIZE FIRST_PAGE_GROUP_END - FIRST_PAGE_GROUP_START
132#define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START
133#define THIRD_PAGE_GROUP_SIZE THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START
3d396eb1 134
e4c93c81
DP
135#define P2_MAX_MTU (8000)
136#define P3_MAX_MTU (9600)
137#define NX_ETHERMTU 1500
138#define NX_MAX_ETHERHDR 32 /* This contains some padding */
139
140#define NX_RX_NORMAL_BUF_MAX_LEN (NX_MAX_ETHERHDR + NX_ETHERMTU)
141#define NX_P2_RX_JUMBO_BUF_MAX_LEN (NX_MAX_ETHERHDR + P2_MAX_MTU)
142#define NX_P3_RX_JUMBO_BUF_MAX_LEN (NX_MAX_ETHERHDR + P3_MAX_MTU)
d9e651bc 143#define NX_CT_DEFAULT_RX_BUF_LEN 2048
e4c93c81 144
ed25ffa1 145#define MAX_RX_BUFFER_LENGTH 1760
bd56c6b1 146#define MAX_RX_JUMBO_BUFFER_LENGTH 8062
ed25ffa1
AK
147#define MAX_RX_LRO_BUFFER_LENGTH ((48*1024)-512)
148#define RX_DMA_MAP_LEN (MAX_RX_BUFFER_LENGTH - 2)
3d396eb1 149#define RX_JUMBO_DMA_MAP_LEN \
ed25ffa1
AK
150 (MAX_RX_JUMBO_BUFFER_LENGTH - 2)
151#define RX_LRO_DMA_MAP_LEN (MAX_RX_LRO_BUFFER_LENGTH - 2)
3d396eb1
AK
152
153/*
154 * Maximum number of ring contexts
155 */
156#define MAX_RING_CTX 1
157
158/* Opcodes to be used with the commands */
e4c93c81
DP
159#define TX_ETHER_PKT 0x01
160#define TX_TCP_PKT 0x02
161#define TX_UDP_PKT 0x03
162#define TX_IP_PKT 0x04
163#define TX_TCP_LSO 0x05
164#define TX_TCP_LSO6 0x06
165#define TX_IPSEC 0x07
166#define TX_IPSEC_CMD 0x0a
167#define TX_TCPV6_PKT 0x0b
168#define TX_UDPV6_PKT 0x0c
3d396eb1
AK
169
170/* The following opcodes are for internal consumption. */
171#define NETXEN_CONTROL_OP 0x10
172#define PEGNET_REQUEST 0x11
173
174#define MAX_NUM_CARDS 4
175
176#define MAX_BUFFERS_PER_CMD 32
177
178/*
179 * Following are the states of the Phantom. Phantom will set them and
180 * Host will read to check if the fields are correct.
181 */
182#define PHAN_INITIALIZE_START 0xff00
183#define PHAN_INITIALIZE_FAILED 0xffff
184#define PHAN_INITIALIZE_COMPLETE 0xff01
185
186/* Host writes the following to notify that it has done the init-handshake */
187#define PHAN_INITIALIZE_ACK 0xf00f
188
ed25ffa1 189#define NUM_RCV_DESC_RINGS 3 /* No of Rcv Descriptor contexts */
3d396eb1
AK
190
191/* descriptor types */
192#define RCV_DESC_NORMAL 0x01
193#define RCV_DESC_JUMBO 0x02
ed25ffa1 194#define RCV_DESC_LRO 0x04
3d396eb1
AK
195#define RCV_DESC_NORMAL_CTXID 0
196#define RCV_DESC_JUMBO_CTXID 1
ed25ffa1 197#define RCV_DESC_LRO_CTXID 2
3d396eb1
AK
198
199#define RCV_DESC_TYPE(ID) \
ed25ffa1
AK
200 ((ID == RCV_DESC_JUMBO_CTXID) \
201 ? RCV_DESC_JUMBO \
202 : ((ID == RCV_DESC_LRO_CTXID) \
203 ? RCV_DESC_LRO : \
204 (RCV_DESC_NORMAL)))
3d396eb1 205
ba53e6b4 206#define MAX_CMD_DESCRIPTORS 4096
bd56c6b1 207#define MAX_RCV_DESCRIPTORS 16384
6c80b18d 208#define MAX_CMD_DESCRIPTORS_HOST (MAX_CMD_DESCRIPTORS / 4)
13ba9c77 209#define MAX_RCV_DESCRIPTORS_1G (MAX_RCV_DESCRIPTORS / 4)
e4c93c81 210#define MAX_RCV_DESCRIPTORS_10G 8192
bd56c6b1
AK
211#define MAX_JUMBO_RCV_DESCRIPTORS 1024
212#define MAX_LRO_RCV_DESCRIPTORS 64
3d396eb1
AK
213#define MAX_RCVSTATUS_DESCRIPTORS MAX_RCV_DESCRIPTORS
214#define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS
215#define MAX_RCV_DESC MAX_RCV_DESCRIPTORS
216#define MAX_RCVSTATUS_DESC MAX_RCV_DESCRIPTORS
3d396eb1 217#define MAX_EPG_DESCRIPTORS (MAX_CMD_DESCRIPTORS * 8)
ed25ffa1
AK
218#define NUM_RCV_DESC (MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS + \
219 MAX_LRO_RCV_DESCRIPTORS)
3d396eb1
AK
220#define MIN_TX_COUNT 4096
221#define MIN_RX_COUNT 4096
ed25ffa1
AK
222#define NETXEN_CTX_SIGNATURE 0xdee0
223#define NETXEN_RCV_PRODUCER(ringid) (ringid)
3d396eb1
AK
224#define MAX_FRAME_SIZE 0x10000 /* 64K MAX size for LSO */
225
226#define PHAN_PEG_RCV_INITIALIZED 0xff01
227#define PHAN_PEG_RCV_START_INITIALIZE 0xff00
228
229#define get_next_index(index, length) \
230 (((index) + 1) & ((length) - 1))
231
232#define get_index_range(index,length,count) \
233 (((index) + (count)) & ((length) - 1))
234
ed25ffa1 235#define MPORT_SINGLE_FUNCTION_MODE 0x1111
3176ff3e 236#define MPORT_MULTI_FUNCTION_MODE 0x2222
ed25ffa1 237
3176ff3e 238#include "netxen_nic_phan_reg.h"
ed25ffa1
AK
239
240/*
241 * NetXen host-peg signal message structure
242 *
243 * Bit 0-1 : peg_id => 0x2 for tx and 01 for rx
244 * Bit 2 : priv_id => must be 1
245 * Bit 3-17 : count => for doorbell
246 * Bit 18-27 : ctx_id => Context id
247 * Bit 28-31 : opcode
248 */
249
250typedef u32 netxen_ctx_msg;
251
ed25ffa1 252#define netxen_set_msg_peg_id(config_word, val) \
a608ab9c 253 ((config_word) &= ~3, (config_word) |= val & 3)
ed25ffa1 254#define netxen_set_msg_privid(config_word) \
a608ab9c 255 ((config_word) |= 1 << 2)
ed25ffa1 256#define netxen_set_msg_count(config_word, val) \
a608ab9c 257 ((config_word) &= ~(0x7fff<<3), (config_word) |= (val & 0x7fff) << 3)
ed25ffa1 258#define netxen_set_msg_ctxid(config_word, val) \
a608ab9c 259 ((config_word) &= ~(0x3ff<<18), (config_word) |= (val & 0x3ff) << 18)
ed25ffa1 260#define netxen_set_msg_opcode(config_word, val) \
82581174 261 ((config_word) &= ~(0xf<<28), (config_word) |= (val & 0xf) << 28)
ed25ffa1
AK
262
263struct netxen_rcv_context {
a608ab9c
AV
264 __le64 rcv_ring_addr;
265 __le32 rcv_ring_size;
266 __le32 rsrvd;
ed25ffa1
AK
267};
268
269struct netxen_ring_ctx {
270
271 /* one command ring */
a608ab9c
AV
272 __le64 cmd_consumer_offset;
273 __le64 cmd_ring_addr;
274 __le32 cmd_ring_size;
275 __le32 rsrvd;
ed25ffa1
AK
276
277 /* three receive rings */
278 struct netxen_rcv_context rcv_ctx[3];
279
280 /* one status ring */
a608ab9c
AV
281 __le64 sts_ring_addr;
282 __le32 sts_ring_size;
ed25ffa1 283
a608ab9c 284 __le32 ctx_id;
ed25ffa1
AK
285} __attribute__ ((aligned(64)));
286
3d396eb1
AK
287/*
288 * Following data structures describe the descriptors that will be used.
289 * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when
290 * we are doing LSO (above the 1500 size packet) only.
291 */
292
293/*
294 * The size of reference handle been changed to 16 bits to pass the MSS fields
295 * for the LSO packet
296 */
297
298#define FLAGS_CHECKSUM_ENABLED 0x01
299#define FLAGS_LSO_ENABLED 0x02
300#define FLAGS_IPSEC_SA_ADD 0x04
301#define FLAGS_IPSEC_SA_DELETE 0x08
302#define FLAGS_VLAN_TAGGED 0x10
303
ed25ffa1
AK
304#define netxen_set_cmd_desc_port(cmd_desc, var) \
305 ((cmd_desc)->port_ctxid |= ((var) & 0x0F))
6c80b18d 306#define netxen_set_cmd_desc_ctxid(cmd_desc, var) \
48bfd1e0 307 ((cmd_desc)->port_ctxid |= ((var) << 4 & 0xF0))
3d396eb1 308
ed25ffa1 309#define netxen_set_cmd_desc_flags(cmd_desc, val) \
5dc16268
DP
310 (cmd_desc)->flags_opcode = ((cmd_desc)->flags_opcode & \
311 ~cpu_to_le16(0x7f)) | cpu_to_le16((val) & 0x7f)
ed25ffa1 312#define netxen_set_cmd_desc_opcode(cmd_desc, val) \
5dc16268
DP
313 (cmd_desc)->flags_opcode = ((cmd_desc)->flags_opcode & \
314 ~cpu_to_le16((u16)0x3f << 7)) | cpu_to_le16(((val) & 0x3f) << 7)
ed25ffa1
AK
315
316#define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \
5dc16268
DP
317 (cmd_desc)->num_of_buffers_total_length = \
318 ((cmd_desc)->num_of_buffers_total_length & \
319 ~cpu_to_le32(0xff)) | cpu_to_le32((val) & 0xff)
ed25ffa1 320#define netxen_set_cmd_desc_totallength(cmd_desc, val) \
5dc16268
DP
321 (cmd_desc)->num_of_buffers_total_length = \
322 ((cmd_desc)->num_of_buffers_total_length & \
323 ~cpu_to_le32((u32)0xffffff << 8)) | \
324 cpu_to_le32(((val) & 0xffffff) << 8)
ed25ffa1
AK
325
326#define netxen_get_cmd_desc_opcode(cmd_desc) \
5dc16268 327 ((le16_to_cpu((cmd_desc)->flags_opcode) >> 7) & 0x003f)
ed25ffa1 328#define netxen_get_cmd_desc_totallength(cmd_desc) \
5dc16268 329 ((le32_to_cpu((cmd_desc)->num_of_buffers_total_length) >> 8) & 0xffffff)
3d396eb1
AK
330
331struct cmd_desc_type0 {
ed25ffa1
AK
332 u8 tcp_hdr_offset; /* For LSO only */
333 u8 ip_hdr_offset; /* For LSO only */
334 /* Bit pattern: 0-6 flags, 7-12 opcode, 13-15 unused */
a608ab9c 335 __le16 flags_opcode;
ed25ffa1
AK
336 /* Bit pattern: 0-7 total number of segments,
337 8-31 Total size of the packet */
a608ab9c 338 __le32 num_of_buffers_total_length;
3d396eb1
AK
339 union {
340 struct {
a608ab9c
AV
341 __le32 addr_low_part2;
342 __le32 addr_high_part2;
3d396eb1 343 };
a608ab9c 344 __le64 addr_buffer2;
3d396eb1
AK
345 };
346
a608ab9c
AV
347 __le16 reference_handle; /* changed to u16 to add mss */
348 __le16 mss; /* passed by NDIS_PACKET for LSO */
3d396eb1
AK
349 /* Bit pattern 0-3 port, 0-3 ctx id */
350 u8 port_ctxid;
351 u8 total_hdr_length; /* LSO only : MAC+IP+TCP Hdr size */
a608ab9c 352 __le16 conn_id; /* IPSec offoad only */
3d396eb1
AK
353
354 union {
355 struct {
a608ab9c
AV
356 __le32 addr_low_part3;
357 __le32 addr_high_part3;
3d396eb1 358 };
a608ab9c 359 __le64 addr_buffer3;
3d396eb1 360 };
3d396eb1
AK
361 union {
362 struct {
a608ab9c
AV
363 __le32 addr_low_part1;
364 __le32 addr_high_part1;
3d396eb1 365 };
a608ab9c 366 __le64 addr_buffer1;
3d396eb1
AK
367 };
368
a608ab9c
AV
369 __le16 buffer1_length;
370 __le16 buffer2_length;
371 __le16 buffer3_length;
372 __le16 buffer4_length;
3d396eb1
AK
373
374 union {
375 struct {
a608ab9c
AV
376 __le32 addr_low_part4;
377 __le32 addr_high_part4;
3d396eb1 378 };
a608ab9c 379 __le64 addr_buffer4;
3d396eb1
AK
380 };
381
a608ab9c 382 __le64 unused;
ed25ffa1 383
3d396eb1
AK
384} __attribute__ ((aligned(64)));
385
386/* Note: sizeof(rcv_desc) should always be a mutliple of 2 */
387struct rcv_desc {
a608ab9c
AV
388 __le16 reference_handle;
389 __le16 reserved;
390 __le32 buffer_length; /* allocated buffer length (usually 2K) */
391 __le64 addr_buffer;
3d396eb1
AK
392};
393
394/* opcode field in status_desc */
d9e651bc
DP
395#define NETXEN_NIC_RXPKT_DESC 0x04
396#define NETXEN_OLD_RXPKT_DESC 0x3f
3d396eb1
AK
397
398/* for status field in status_desc */
399#define STATUS_NEED_CKSUM (1)
400#define STATUS_CKSUM_OK (2)
401
402/* owner bits of status_desc */
403#define STATUS_OWNER_HOST (0x1)
404#define STATUS_OWNER_PHANTOM (0x2)
405
406#define NETXEN_PROT_IP (1)
407#define NETXEN_PROT_UNKNOWN (0)
408
409/* Note: sizeof(status_desc) should always be a mutliple of 2 */
ed25ffa1
AK
410
411#define netxen_get_sts_desc_lro_cnt(status_desc) \
412 ((status_desc)->lro & 0x7F)
413#define netxen_get_sts_desc_lro_last_frag(status_desc) \
414 (((status_desc)->lro & 0x80) >> 7)
415
5dc16268
DP
416#define netxen_get_sts_port(sts_data) \
417 ((sts_data) & 0x0F)
418#define netxen_get_sts_status(sts_data) \
419 (((sts_data) >> 4) & 0x0F)
420#define netxen_get_sts_type(sts_data) \
421 (((sts_data) >> 8) & 0x0F)
422#define netxen_get_sts_totallength(sts_data) \
423 (((sts_data) >> 12) & 0xFFFF)
424#define netxen_get_sts_refhandle(sts_data) \
425 (((sts_data) >> 28) & 0xFFFF)
426#define netxen_get_sts_prot(sts_data) \
427 (((sts_data) >> 44) & 0x0F)
d9e651bc
DP
428#define netxen_get_sts_pkt_offset(sts_data) \
429 (((sts_data) >> 48) & 0x1F)
5dc16268
DP
430#define netxen_get_sts_opcode(sts_data) \
431 (((sts_data) >> 58) & 0x03F)
432
ed25ffa1 433#define netxen_get_sts_owner(status_desc) \
a608ab9c 434 ((le64_to_cpu((status_desc)->status_desc_data) >> 56) & 0x03)
5dc16268
DP
435#define netxen_set_sts_owner(status_desc, val) { \
436 (status_desc)->status_desc_data = \
437 ((status_desc)->status_desc_data & \
438 ~cpu_to_le64(0x3ULL << 56)) | \
439 cpu_to_le64((u64)((val) & 0x3) << 56); \
440}
3d396eb1
AK
441
442struct status_desc {
ed25ffa1 443 /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length
d9e651bc 444 28-43 reference_handle, 44-47 protocol, 48-52 pkt_offset
ed25ffa1
AK
445 53-55 desc_cnt, 56-57 owner, 58-63 opcode
446 */
a608ab9c 447 __le64 status_desc_data;
d9e651bc
DP
448 union {
449 struct {
450 __le32 hash_value;
451 u8 hash_type;
452 u8 msg_type;
453 u8 unused;
454 union {
455 /* Bit pattern: 0-6 lro_count indicates frag
456 * sequence, 7 last_frag indicates last frag
457 */
458 u8 lro;
459
460 /* chained buffers */
461 u8 nr_frags;
462 };
463 };
464 struct {
465 __le16 frag_handles[4];
466 };
467 };
6c80b18d 468} __attribute__ ((aligned(16)));
3d396eb1
AK
469
470enum {
471 NETXEN_RCV_PEG_0 = 0,
472 NETXEN_RCV_PEG_1
473};
474/* The version of the main data structure */
475#define NETXEN_BDINFO_VERSION 1
476
477/* Magic number to let user know flash is programmed */
478#define NETXEN_BDINFO_MAGIC 0x12345678
479
480/* Max number of Gig ports on a Phantom board */
481#define NETXEN_MAX_PORTS 4
482
483typedef enum {
484 NETXEN_BRDTYPE_P1_BD = 0x0000,
485 NETXEN_BRDTYPE_P1_SB = 0x0001,
486 NETXEN_BRDTYPE_P1_SMAX = 0x0002,
487 NETXEN_BRDTYPE_P1_SOCK = 0x0003,
488
489 NETXEN_BRDTYPE_P2_SOCK_31 = 0x0008,
490 NETXEN_BRDTYPE_P2_SOCK_35 = 0x0009,
491 NETXEN_BRDTYPE_P2_SB35_4G = 0x000a,
492 NETXEN_BRDTYPE_P2_SB31_10G = 0x000b,
493 NETXEN_BRDTYPE_P2_SB31_2G = 0x000c,
494
495 NETXEN_BRDTYPE_P2_SB31_10G_IMEZ = 0x000d,
496 NETXEN_BRDTYPE_P2_SB31_10G_HMEZ = 0x000e,
e4c93c81
DP
497 NETXEN_BRDTYPE_P2_SB31_10G_CX4 = 0x000f,
498
499 NETXEN_BRDTYPE_P3_REF_QG = 0x0021,
500 NETXEN_BRDTYPE_P3_HMEZ = 0x0022,
501 NETXEN_BRDTYPE_P3_10G_CX4_LP = 0x0023,
502 NETXEN_BRDTYPE_P3_4_GB = 0x0024,
503 NETXEN_BRDTYPE_P3_IMEZ = 0x0025,
504 NETXEN_BRDTYPE_P3_10G_SFP_PLUS = 0x0026,
505 NETXEN_BRDTYPE_P3_10000_BASE_T = 0x0027,
506 NETXEN_BRDTYPE_P3_XG_LOM = 0x0028,
507 NETXEN_BRDTYPE_P3_4_GB_MM = 0x0029,
508 NETXEN_BRDTYPE_P3_10G_CX4 = 0x0031,
509 NETXEN_BRDTYPE_P3_10G_XFP = 0x0032
510
3d396eb1
AK
511} netxen_brdtype_t;
512
513typedef enum {
514 NETXEN_BRDMFG_INVENTEC = 1
515} netxen_brdmfg;
516
517typedef enum {
518 MEM_ORG_128Mbx4 = 0x0, /* DDR1 only */
519 MEM_ORG_128Mbx8 = 0x1, /* DDR1 only */
520 MEM_ORG_128Mbx16 = 0x2, /* DDR1 only */
521 MEM_ORG_256Mbx4 = 0x3,
522 MEM_ORG_256Mbx8 = 0x4,
523 MEM_ORG_256Mbx16 = 0x5,
524 MEM_ORG_512Mbx4 = 0x6,
525 MEM_ORG_512Mbx8 = 0x7,
526 MEM_ORG_512Mbx16 = 0x8,
527 MEM_ORG_1Gbx4 = 0x9,
528 MEM_ORG_1Gbx8 = 0xa,
529 MEM_ORG_1Gbx16 = 0xb,
530 MEM_ORG_2Gbx4 = 0xc,
531 MEM_ORG_2Gbx8 = 0xd,
532 MEM_ORG_2Gbx16 = 0xe,
533 MEM_ORG_128Mbx32 = 0x10002, /* GDDR only */
534 MEM_ORG_256Mbx32 = 0x10005 /* GDDR only */
535} netxen_mn_mem_org_t;
536
537typedef enum {
538 MEM_ORG_512Kx36 = 0x0,
539 MEM_ORG_1Mx36 = 0x1,
540 MEM_ORG_2Mx36 = 0x2
541} netxen_sn_mem_org_t;
542
543typedef enum {
544 MEM_DEPTH_4MB = 0x1,
545 MEM_DEPTH_8MB = 0x2,
546 MEM_DEPTH_16MB = 0x3,
547 MEM_DEPTH_32MB = 0x4,
548 MEM_DEPTH_64MB = 0x5,
549 MEM_DEPTH_128MB = 0x6,
550 MEM_DEPTH_256MB = 0x7,
551 MEM_DEPTH_512MB = 0x8,
552 MEM_DEPTH_1GB = 0x9,
553 MEM_DEPTH_2GB = 0xa,
554 MEM_DEPTH_4GB = 0xb,
555 MEM_DEPTH_8GB = 0xc,
556 MEM_DEPTH_16GB = 0xd,
557 MEM_DEPTH_32GB = 0xe
558} netxen_mem_depth_t;
559
560struct netxen_board_info {
561 u32 header_version;
562
563 u32 board_mfg;
564 u32 board_type;
565 u32 board_num;
566 u32 chip_id;
567 u32 chip_minor;
568 u32 chip_major;
569 u32 chip_pkg;
570 u32 chip_lot;
571
572 u32 port_mask; /* available niu ports */
573 u32 peg_mask; /* available pegs */
574 u32 icache_ok; /* can we run with icache? */
575 u32 dcache_ok; /* can we run with dcache? */
576 u32 casper_ok;
577
578 u32 mac_addr_lo_0;
579 u32 mac_addr_lo_1;
580 u32 mac_addr_lo_2;
581 u32 mac_addr_lo_3;
582
583 /* MN-related config */
584 u32 mn_sync_mode; /* enable/ sync shift cclk/ sync shift mclk */
585 u32 mn_sync_shift_cclk;
586 u32 mn_sync_shift_mclk;
587 u32 mn_wb_en;
588 u32 mn_crystal_freq; /* in MHz */
589 u32 mn_speed; /* in MHz */
590 u32 mn_org;
591 u32 mn_depth;
592 u32 mn_ranks_0; /* ranks per slot */
593 u32 mn_ranks_1; /* ranks per slot */
594 u32 mn_rd_latency_0;
595 u32 mn_rd_latency_1;
596 u32 mn_rd_latency_2;
597 u32 mn_rd_latency_3;
598 u32 mn_rd_latency_4;
599 u32 mn_rd_latency_5;
600 u32 mn_rd_latency_6;
601 u32 mn_rd_latency_7;
602 u32 mn_rd_latency_8;
603 u32 mn_dll_val[18];
604 u32 mn_mode_reg; /* MIU DDR Mode Register */
605 u32 mn_ext_mode_reg; /* MIU DDR Extended Mode Register */
606 u32 mn_timing_0; /* MIU Memory Control Timing Rgister */
607 u32 mn_timing_1; /* MIU Extended Memory Ctrl Timing Register */
608 u32 mn_timing_2; /* MIU Extended Memory Ctrl Timing2 Register */
609
610 /* SN-related config */
611 u32 sn_sync_mode; /* enable/ sync shift cclk / sync shift mclk */
612 u32 sn_pt_mode; /* pass through mode */
613 u32 sn_ecc_en;
614 u32 sn_wb_en;
615 u32 sn_crystal_freq;
616 u32 sn_speed;
617 u32 sn_org;
618 u32 sn_depth;
619 u32 sn_dll_tap;
620 u32 sn_rd_latency;
621
622 u32 mac_addr_hi_0;
623 u32 mac_addr_hi_1;
624 u32 mac_addr_hi_2;
625 u32 mac_addr_hi_3;
626
627 u32 magic; /* indicates flash has been initialized */
628
629 u32 mn_rdimm;
630 u32 mn_dll_override;
631
632};
633
634#define FLASH_NUM_PORTS (4)
635
636struct netxen_flash_mac_addr {
637 u32 flash_addr[32];
638};
639
640struct netxen_user_old_info {
641 u8 flash_md5[16];
642 u8 crbinit_md5[16];
643 u8 brdcfg_md5[16];
644 /* bootloader */
645 u32 bootld_version;
646 u32 bootld_size;
647 u8 bootld_md5[16];
648 /* image */
649 u32 image_version;
650 u32 image_size;
651 u8 image_md5[16];
652 /* primary image status */
653 u32 primary_status;
654 u32 secondary_present;
655
656 /* MAC address , 4 ports */
657 struct netxen_flash_mac_addr mac_addr[FLASH_NUM_PORTS];
658};
659#define FLASH_NUM_MAC_PER_PORT 32
660struct netxen_user_info {
661 u8 flash_md5[16 * 64];
662 /* bootloader */
663 u32 bootld_version;
664 u32 bootld_size;
665 /* image */
666 u32 image_version;
667 u32 image_size;
668 /* primary image status */
669 u32 primary_status;
670 u32 secondary_present;
671
672 /* MAC address , 4 ports, 32 address per port */
673 u64 mac_addr[FLASH_NUM_PORTS * FLASH_NUM_MAC_PER_PORT];
674 u32 sub_sys_id;
675 u8 serial_num[32];
676
677 /* Any user defined data */
678};
679
680/*
681 * Flash Layout - new format.
682 */
683struct netxen_new_user_info {
684 u8 flash_md5[16 * 64];
685 /* bootloader */
686 u32 bootld_version;
687 u32 bootld_size;
688 /* image */
689 u32 image_version;
690 u32 image_size;
691 /* primary image status */
692 u32 primary_status;
693 u32 secondary_present;
694
695 /* MAC address , 4 ports, 32 address per port */
696 u64 mac_addr[FLASH_NUM_PORTS * FLASH_NUM_MAC_PER_PORT];
697 u32 sub_sys_id;
698 u8 serial_num[32];
699
700 /* Any user defined data */
701};
702
703#define SECONDARY_IMAGE_PRESENT 0xb3b4b5b6
704#define SECONDARY_IMAGE_ABSENT 0xffffffff
705#define PRIMARY_IMAGE_GOOD 0x5a5a5a5a
706#define PRIMARY_IMAGE_BAD 0xffffffff
707
708/* Flash memory map */
709typedef enum {
0d04761d
MT
710 NETXEN_CRBINIT_START = 0, /* Crbinit section */
711 NETXEN_BRDCFG_START = 0x4000, /* board config */
712 NETXEN_INITCODE_START = 0x6000, /* pegtune code */
713 NETXEN_BOOTLD_START = 0x10000, /* bootld */
714 NETXEN_IMAGE_START = 0x43000, /* compressed image */
715 NETXEN_SECONDARY_START = 0x200000, /* backup images */
716 NETXEN_PXE_START = 0x3E0000, /* user defined region */
717 NETXEN_USER_START = 0x3E8000, /* User defined region for new boards */
718 NETXEN_FIXED_START = 0x3F0000 /* backup of crbinit */
3d396eb1
AK
719} netxen_flash_map_t;
720
0d04761d
MT
721#define NETXEN_USER_START_OLD NETXEN_PXE_START /* for backward compatibility */
722
723#define NETXEN_FLASH_START (NETXEN_CRBINIT_START)
724#define NETXEN_INIT_SECTOR (0)
725#define NETXEN_PRIMARY_START (NETXEN_BOOTLD_START)
726#define NETXEN_FLASH_CRBINIT_SIZE (0x4000)
727#define NETXEN_FLASH_BRDCFG_SIZE (sizeof(struct netxen_board_info))
728#define NETXEN_FLASH_USER_SIZE (sizeof(struct netxen_user_info)/sizeof(u32))
729#define NETXEN_FLASH_SECONDARY_SIZE (NETXEN_USER_START-NETXEN_SECONDARY_START)
730#define NETXEN_NUM_PRIMARY_SECTORS (0x20)
731#define NETXEN_NUM_CONFIG_SECTORS (1)
ed25ffa1
AK
732#define PFX "NetXen: "
733extern char netxen_nic_driver_name[];
3d396eb1
AK
734
735/* Note: Make sure to not call this before adapter->port is valid */
736#if !defined(NETXEN_DEBUG)
737#define DPRINTK(klevel, fmt, args...) do { \
738 } while (0)
739#else
740#define DPRINTK(klevel, fmt, args...) do { \
741 printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\
3176ff3e
MT
742 (adapter != NULL && adapter->netdev != NULL) ? \
743 adapter->netdev->name : NULL, \
3d396eb1
AK
744 ## args); } while(0)
745#endif
746
747/* Number of status descriptors to handle per interrupt */
748#define MAX_STATUS_HANDLE (128)
749
750/*
751 * netxen_skb_frag{} is to contain mapping info for each SG list. This
752 * has to be freed when DMA is complete. This is part of netxen_tx_buffer{}.
753 */
754struct netxen_skb_frag {
755 u64 dma;
756 u32 length;
757};
758
6c80b18d
MT
759#define _netxen_set_bits(config_word, start, bits, val) {\
760 unsigned long long __tmask = (((1ULL << (bits)) - 1) << (start));\
761 unsigned long long __tvalue = (val); \
762 (config_word) &= ~__tmask; \
763 (config_word) |= (((__tvalue) << (start)) & __tmask); \
764}
4790654c 765
6c80b18d
MT
766#define _netxen_clear_bits(config_word, start, bits) {\
767 unsigned long long __tmask = (((1ULL << (bits)) - 1) << (start)); \
768 (config_word) &= ~__tmask; \
4790654c 769}
6c80b18d 770
3d396eb1
AK
771/* Following defines are for the state of the buffers */
772#define NETXEN_BUFFER_FREE 0
773#define NETXEN_BUFFER_BUSY 1
774
775/*
776 * There will be one netxen_buffer per skb packet. These will be
777 * used to save the dma info for pci_unmap_page()
778 */
779struct netxen_cmd_buffer {
780 struct sk_buff *skb;
781 struct netxen_skb_frag frag_array[MAX_BUFFERS_PER_CMD + 1];
782 u32 total_length;
783 u32 mss;
784 u16 port;
785 u8 cmd;
786 u8 frag_count;
787 unsigned long time_stamp;
788 u32 state;
3d396eb1
AK
789};
790
791/* In rx_buffer, we do not need multiple fragments as is a single buffer */
792struct netxen_rx_buffer {
d9e651bc 793 struct list_head list;
3d396eb1
AK
794 struct sk_buff *skb;
795 u64 dma;
796 u16 ref_handle;
797 u16 state;
ed25ffa1
AK
798 u32 lro_expected_frags;
799 u32 lro_current_frags;
800 u32 lro_length;
3d396eb1
AK
801};
802
803/* Board types */
804#define NETXEN_NIC_GBE 0x01
805#define NETXEN_NIC_XGBE 0x02
806
807/*
808 * One hardware_context{} per adapter
809 * contains interrupt info as well shared hardware info.
810 */
811struct netxen_hardware_context {
cb8011ad
AK
812 void __iomem *pci_base0;
813 void __iomem *pci_base1;
814 void __iomem *pci_base2;
6c80b18d
MT
815 unsigned long first_page_group_end;
816 unsigned long first_page_group_start;
ed25ffa1
AK
817 void __iomem *db_base;
818 unsigned long db_len;
3ce06a32
DP
819 unsigned long pci_len0;
820
2956640d 821 u8 cut_through;
3ce06a32
DP
822 int qdr_sn_window;
823 int ddr_mn_window;
824 unsigned long mn_win_crb;
825 unsigned long ms_win_crb;
cb8011ad 826
3d396eb1
AK
827 u8 revision_id;
828 u16 board_type;
3d396eb1 829 struct netxen_board_info boardcfg;
a97342f9 830 u32 linkup;
3d396eb1
AK
831 /* Address of cmd ring in Phantom */
832 struct cmd_desc_type0 *cmd_desc_head;
833 dma_addr_t cmd_desc_phys_addr;
834 struct netxen_adapter *adapter;
13ba9c77 835 int pci_func;
3d396eb1
AK
836};
837
ed25ffa1
AK
838#define RCV_RING_LRO RCV_DESC_LRO
839
3d396eb1
AK
840#define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */
841#define ETHERNET_FCS_SIZE 4
842
843struct netxen_adapter_stats {
3176ff3e
MT
844 u64 rcvdbadskb;
845 u64 xmitcalled;
846 u64 xmitedframes;
847 u64 xmitfinished;
848 u64 badskblen;
849 u64 nocmddescriptor;
850 u64 polled;
d1847a72 851 u64 rxdropped;
3176ff3e 852 u64 txdropped;
3176ff3e
MT
853 u64 csummed;
854 u64 no_rcv;
855 u64 rxbytes;
856 u64 txbytes;
857 u64 ints;
3d396eb1
AK
858};
859
860/*
861 * Rcv Descriptor Context. One such per Rcv Descriptor. There may
862 * be one Rcv Descriptor for normal packets, one for jumbo and may be others.
863 */
48bfd1e0 864struct nx_host_rds_ring {
3d396eb1
AK
865 u32 flags;
866 u32 producer;
3d396eb1 867 dma_addr_t phys_addr;
7830b22c 868 u32 crb_rcv_producer; /* reg offset */
3d396eb1
AK
869 struct rcv_desc *desc_head; /* address of rx ring in Phantom */
870 u32 max_rx_desc_count;
871 u32 dma_size;
872 u32 skb_size;
873 struct netxen_rx_buffer *rx_buf_arr; /* rx buffers for receive */
d9e651bc 874 struct list_head free_list;
3d396eb1
AK
875 int begin_alloc;
876};
877
878/*
879 * Receive context. There is one such structure per instance of the
880 * receive processing. Any state information that is relevant to
881 * the receive, and is must be in this structure. The global data may be
882 * present elsewhere.
883 */
884struct netxen_recv_context {
48bfd1e0
DP
885 u32 state;
886 u16 context_id;
887 u16 virt_port;
888
889 struct nx_host_rds_ring rds_rings[NUM_RCV_DESC_RINGS];
3d396eb1 890 u32 status_rx_consumer;
7830b22c 891 u32 crb_sts_consumer; /* reg offset */
3d396eb1
AK
892 dma_addr_t rcv_status_desc_phys_addr;
893 struct status_desc *rcv_status_desc_head;
894};
895
48bfd1e0
DP
896/* New HW context creation */
897
898#define NX_OS_CRB_RETRY_COUNT 4000
899#define NX_CDRP_SIGNATURE_MAKE(pcifn, version) \
900 (((pcifn) & 0xff) | (((version) & 0xff) << 8) | (0xcafe << 16))
901
902#define NX_CDRP_CLEAR 0x00000000
903#define NX_CDRP_CMD_BIT 0x80000000
904
905/*
906 * All responses must have the NX_CDRP_CMD_BIT cleared
907 * in the crb NX_CDRP_CRB_OFFSET.
908 */
909#define NX_CDRP_FORM_RSP(rsp) (rsp)
910#define NX_CDRP_IS_RSP(rsp) (((rsp) & NX_CDRP_CMD_BIT) == 0)
911
912#define NX_CDRP_RSP_OK 0x00000001
913#define NX_CDRP_RSP_FAIL 0x00000002
914#define NX_CDRP_RSP_TIMEOUT 0x00000003
915
916/*
917 * All commands must have the NX_CDRP_CMD_BIT set in
918 * the crb NX_CDRP_CRB_OFFSET.
919 */
920#define NX_CDRP_FORM_CMD(cmd) (NX_CDRP_CMD_BIT | (cmd))
921#define NX_CDRP_IS_CMD(cmd) (((cmd) & NX_CDRP_CMD_BIT) != 0)
922
923#define NX_CDRP_CMD_SUBMIT_CAPABILITIES 0x00000001
924#define NX_CDRP_CMD_READ_MAX_RDS_PER_CTX 0x00000002
925#define NX_CDRP_CMD_READ_MAX_SDS_PER_CTX 0x00000003
926#define NX_CDRP_CMD_READ_MAX_RULES_PER_CTX 0x00000004
927#define NX_CDRP_CMD_READ_MAX_RX_CTX 0x00000005
928#define NX_CDRP_CMD_READ_MAX_TX_CTX 0x00000006
929#define NX_CDRP_CMD_CREATE_RX_CTX 0x00000007
930#define NX_CDRP_CMD_DESTROY_RX_CTX 0x00000008
931#define NX_CDRP_CMD_CREATE_TX_CTX 0x00000009
932#define NX_CDRP_CMD_DESTROY_TX_CTX 0x0000000a
933#define NX_CDRP_CMD_SETUP_STATISTICS 0x0000000e
934#define NX_CDRP_CMD_GET_STATISTICS 0x0000000f
935#define NX_CDRP_CMD_DELETE_STATISTICS 0x00000010
936#define NX_CDRP_CMD_SET_MTU 0x00000012
937#define NX_CDRP_CMD_MAX 0x00000013
938
939#define NX_RCODE_SUCCESS 0
940#define NX_RCODE_NO_HOST_MEM 1
941#define NX_RCODE_NO_HOST_RESOURCE 2
942#define NX_RCODE_NO_CARD_CRB 3
943#define NX_RCODE_NO_CARD_MEM 4
944#define NX_RCODE_NO_CARD_RESOURCE 5
945#define NX_RCODE_INVALID_ARGS 6
946#define NX_RCODE_INVALID_ACTION 7
947#define NX_RCODE_INVALID_STATE 8
948#define NX_RCODE_NOT_SUPPORTED 9
949#define NX_RCODE_NOT_PERMITTED 10
950#define NX_RCODE_NOT_READY 11
951#define NX_RCODE_DOES_NOT_EXIST 12
952#define NX_RCODE_ALREADY_EXISTS 13
953#define NX_RCODE_BAD_SIGNATURE 14
954#define NX_RCODE_CMD_NOT_IMPL 15
955#define NX_RCODE_CMD_INVALID 16
956#define NX_RCODE_TIMEOUT 17
957#define NX_RCODE_CMD_FAILED 18
958#define NX_RCODE_MAX_EXCEEDED 19
959#define NX_RCODE_MAX 20
960
961#define NX_DESTROY_CTX_RESET 0
962#define NX_DESTROY_CTX_D3_RESET 1
963#define NX_DESTROY_CTX_MAX 2
964
965/*
966 * Capabilities
967 */
968#define NX_CAP_BIT(class, bit) (1 << bit)
969#define NX_CAP0_LEGACY_CONTEXT NX_CAP_BIT(0, 0)
970#define NX_CAP0_MULTI_CONTEXT NX_CAP_BIT(0, 1)
971#define NX_CAP0_LEGACY_MN NX_CAP_BIT(0, 2)
972#define NX_CAP0_LEGACY_MS NX_CAP_BIT(0, 3)
973#define NX_CAP0_CUT_THROUGH NX_CAP_BIT(0, 4)
974#define NX_CAP0_LRO NX_CAP_BIT(0, 5)
975#define NX_CAP0_LSO NX_CAP_BIT(0, 6)
976#define NX_CAP0_JUMBO_CONTIGUOUS NX_CAP_BIT(0, 7)
977#define NX_CAP0_LRO_CONTIGUOUS NX_CAP_BIT(0, 8)
978
979/*
980 * Context state
981 */
982#define NX_HOST_CTX_STATE_FREED 0
983#define NX_HOST_CTX_STATE_ALLOCATED 1
984#define NX_HOST_CTX_STATE_ACTIVE 2
985#define NX_HOST_CTX_STATE_DISABLED 3
986#define NX_HOST_CTX_STATE_QUIESCED 4
987#define NX_HOST_CTX_STATE_MAX 5
988
989/*
990 * Rx context
991 */
992
993typedef struct {
994 u64 host_phys_addr; /* Ring base addr */
995 u32 ring_size; /* Ring entries */
996 u16 msi_index;
997 u16 rsvd; /* Padding */
998} nx_hostrq_sds_ring_t;
999
1000typedef struct {
1001 u64 host_phys_addr; /* Ring base addr */
1002 u64 buff_size; /* Packet buffer size */
1003 u32 ring_size; /* Ring entries */
1004 u32 ring_kind; /* Class of ring */
1005} nx_hostrq_rds_ring_t;
1006
1007typedef struct {
1008 u64 host_rsp_dma_addr; /* Response dma'd here */
1009 u32 capabilities[4]; /* Flag bit vector */
1010 u32 host_int_crb_mode; /* Interrupt crb usage */
1011 u32 host_rds_crb_mode; /* RDS crb usage */
1012 /* These ring offsets are relative to data[0] below */
1013 u32 rds_ring_offset; /* Offset to RDS config */
1014 u32 sds_ring_offset; /* Offset to SDS config */
1015 u16 num_rds_rings; /* Count of RDS rings */
1016 u16 num_sds_rings; /* Count of SDS rings */
1017 u16 rsvd1; /* Padding */
1018 u16 rsvd2; /* Padding */
1019 u8 reserved[128]; /* reserve space for future expansion*/
1020 /* MUST BE 64-bit aligned.
1021 The following is packed:
1022 - N hostrq_rds_rings
1023 - N hostrq_sds_rings */
1024 char data[0];
1025} nx_hostrq_rx_ctx_t;
1026
1027typedef struct {
1028 u32 host_producer_crb; /* Crb to use */
1029 u32 rsvd1; /* Padding */
1030} nx_cardrsp_rds_ring_t;
1031
1032typedef struct {
1033 u32 host_consumer_crb; /* Crb to use */
1034 u32 interrupt_crb; /* Crb to use */
1035} nx_cardrsp_sds_ring_t;
1036
1037typedef struct {
1038 /* These ring offsets are relative to data[0] below */
1039 u32 rds_ring_offset; /* Offset to RDS config */
1040 u32 sds_ring_offset; /* Offset to SDS config */
1041 u32 host_ctx_state; /* Starting State */
1042 u32 num_fn_per_port; /* How many PCI fn share the port */
1043 u16 num_rds_rings; /* Count of RDS rings */
1044 u16 num_sds_rings; /* Count of SDS rings */
1045 u16 context_id; /* Handle for context */
1046 u8 phys_port; /* Physical id of port */
1047 u8 virt_port; /* Virtual/Logical id of port */
1048 u8 reserved[128]; /* save space for future expansion */
1049 /* MUST BE 64-bit aligned.
1050 The following is packed:
1051 - N cardrsp_rds_rings
1052 - N cardrs_sds_rings */
1053 char data[0];
1054} nx_cardrsp_rx_ctx_t;
1055
1056#define SIZEOF_HOSTRQ_RX(HOSTRQ_RX, rds_rings, sds_rings) \
1057 (sizeof(HOSTRQ_RX) + \
1058 (rds_rings)*(sizeof(nx_hostrq_rds_ring_t)) + \
1059 (sds_rings)*(sizeof(nx_hostrq_sds_ring_t)))
1060
1061#define SIZEOF_CARDRSP_RX(CARDRSP_RX, rds_rings, sds_rings) \
1062 (sizeof(CARDRSP_RX) + \
1063 (rds_rings)*(sizeof(nx_cardrsp_rds_ring_t)) + \
1064 (sds_rings)*(sizeof(nx_cardrsp_sds_ring_t)))
1065
1066/*
1067 * Tx context
1068 */
1069
1070typedef struct {
1071 u64 host_phys_addr; /* Ring base addr */
1072 u32 ring_size; /* Ring entries */
1073 u32 rsvd; /* Padding */
1074} nx_hostrq_cds_ring_t;
1075
1076typedef struct {
1077 u64 host_rsp_dma_addr; /* Response dma'd here */
1078 u64 cmd_cons_dma_addr; /* */
1079 u64 dummy_dma_addr; /* */
1080 u32 capabilities[4]; /* Flag bit vector */
1081 u32 host_int_crb_mode; /* Interrupt crb usage */
1082 u32 rsvd1; /* Padding */
1083 u16 rsvd2; /* Padding */
1084 u16 interrupt_ctl;
1085 u16 msi_index;
1086 u16 rsvd3; /* Padding */
1087 nx_hostrq_cds_ring_t cds_ring; /* Desc of cds ring */
1088 u8 reserved[128]; /* future expansion */
1089} nx_hostrq_tx_ctx_t;
1090
1091typedef struct {
1092 u32 host_producer_crb; /* Crb to use */
1093 u32 interrupt_crb; /* Crb to use */
1094} nx_cardrsp_cds_ring_t;
1095
1096typedef struct {
1097 u32 host_ctx_state; /* Starting state */
1098 u16 context_id; /* Handle for context */
1099 u8 phys_port; /* Physical id of port */
1100 u8 virt_port; /* Virtual/Logical id of port */
1101 nx_cardrsp_cds_ring_t cds_ring; /* Card cds settings */
1102 u8 reserved[128]; /* future expansion */
1103} nx_cardrsp_tx_ctx_t;
1104
1105#define SIZEOF_HOSTRQ_TX(HOSTRQ_TX) (sizeof(HOSTRQ_TX))
1106#define SIZEOF_CARDRSP_TX(CARDRSP_TX) (sizeof(CARDRSP_TX))
1107
1108/* CRB */
1109
1110#define NX_HOST_RDS_CRB_MODE_UNIQUE 0
1111#define NX_HOST_RDS_CRB_MODE_SHARED 1
1112#define NX_HOST_RDS_CRB_MODE_CUSTOM 2
1113#define NX_HOST_RDS_CRB_MODE_MAX 3
1114
1115#define NX_HOST_INT_CRB_MODE_UNIQUE 0
1116#define NX_HOST_INT_CRB_MODE_SHARED 1
1117#define NX_HOST_INT_CRB_MODE_NORX 2
1118#define NX_HOST_INT_CRB_MODE_NOTX 3
1119#define NX_HOST_INT_CRB_MODE_NORXTX 4
1120
1121
1122/* MAC */
1123
1124#define MC_COUNT_P2 16
1125#define MC_COUNT_P3 38
1126
1127#define NETXEN_MAC_NOOP 0
1128#define NETXEN_MAC_ADD 1
1129#define NETXEN_MAC_DEL 2
1130
1131typedef struct nx_mac_list_s {
1132 struct nx_mac_list_s *next;
1133 uint8_t mac_addr[MAX_ADDR_LEN];
1134} nx_mac_list_t;
1135
1136typedef struct {
1137 u64 qhdr;
1138 u64 req_hdr;
1139 u64 words[6];
c9fc891f 1140} nx_nic_req_t;
48bfd1e0
DP
1141
1142typedef struct {
1143 u8 op;
1144 u8 tag;
1145 u8 mac_addr[6];
1146} nx_mac_req_t;
1147
c9fc891f 1148#define MAX_PENDING_DESC_BLOCK_SIZE 64
48bfd1e0 1149
2956640d
DP
1150#define NETXEN_NIC_MSI_ENABLED 0x02
1151#define NETXEN_NIC_MSIX_ENABLED 0x04
1152#define NETXEN_IS_MSI_FAMILY(adapter) \
1153 ((adapter)->flags & (NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED))
1154
1155#define MSIX_ENTRIES_PER_ADAPTER 8
1156#define NETXEN_MSIX_TBL_SPACE 8192
1157#define NETXEN_PCI_REG_MSIX_TBL 0x44
1158
1159#define NETXEN_DB_MAPSIZE_BYTES 0x1000
ed25ffa1
AK
1160
1161struct netxen_dummy_dma {
1162 void *addr;
1163 dma_addr_t phys_addr;
1164};
3d396eb1 1165
3d396eb1
AK
1166struct netxen_adapter {
1167 struct netxen_hardware_context ahw;
4790654c 1168
3176ff3e
MT
1169 struct net_device *netdev;
1170 struct pci_dev *pdev;
2956640d 1171 int pci_using_dac;
bea3348e 1172 struct napi_struct napi;
6c80b18d 1173 struct net_device_stats net_stats;
3176ff3e
MT
1174 int mtu;
1175 int portnum;
3276fbad 1176 u8 physical_port;
48bfd1e0 1177 u16 tx_context_id;
3176ff3e 1178
623621b0
DP
1179 uint8_t mc_enabled;
1180 uint8_t max_mc_count;
c9fc891f 1181 nx_mac_list_t *mac_list;
623621b0 1182
2956640d 1183 struct netxen_legacy_intr_set legacy_intr;
48bfd1e0 1184 u32 crb_intr_mask;
2956640d 1185
3d396eb1 1186 struct work_struct watchdog_task;
3d396eb1 1187 struct timer_list watchdog_timer;
3176ff3e 1188 struct work_struct tx_timeout_task;
3d396eb1
AK
1189
1190 u32 curr_window;
3ce06a32
DP
1191 u32 crb_win;
1192 rwlock_t adapter_lock;
3d396eb1 1193
2956640d
DP
1194 uint64_t dma_mask;
1195
3d396eb1 1196 u32 cmd_producer;
f305f789 1197 __le32 *cmd_consumer;
3d396eb1 1198 u32 last_cmd_consumer;
7830b22c
DP
1199 u32 crb_addr_cmd_producer;
1200 u32 crb_addr_cmd_consumer;
ba53e6b4 1201
3d396eb1
AK
1202 u32 max_tx_desc_count;
1203 u32 max_rx_desc_count;
1204 u32 max_jumbo_rx_desc_count;
ed25ffa1 1205 u32 max_lro_rx_desc_count;
3d396eb1 1206
48bfd1e0
DP
1207 int max_rds_rings;
1208
3d396eb1
AK
1209 u32 flags;
1210 u32 irq;
1211 int driver_mismatch;
cb8011ad 1212 u32 temp;
3d396eb1 1213
2956640d
DP
1214 u32 fw_major;
1215
1216 u8 msix_supported;
1217 u8 max_possible_rss_rings;
1218 struct msix_entry msix_entries[MSIX_ENTRIES_PER_ADAPTER];
1219
3d396eb1 1220 struct netxen_adapter_stats stats;
4790654c 1221
3176ff3e
MT
1222 u16 link_speed;
1223 u16 link_duplex;
1224 u16 state;
1225 u16 link_autoneg;
200eef20 1226 int rx_csum;
3176ff3e 1227 int status;
3d396eb1
AK
1228
1229 struct netxen_cmd_buffer *cmd_buf_arr; /* Command buffers for xmit */
1230
1231 /*
1232 * Receive instances. These can be either one per port,
1233 * or one per peg, etc.
1234 */
1235 struct netxen_recv_context recv_ctx[MAX_RCV_CTX];
1236
1237 int is_up;
ed25ffa1
AK
1238 struct netxen_dummy_dma dummy_dma;
1239
1240 /* Context interface shared between card and host */
1241 struct netxen_ring_ctx *ctx_desc;
ed25ffa1 1242 dma_addr_t ctx_desc_phys_addr;
2d1a3bbd 1243 int intr_scheme;
443be796 1244 int msi_mode;
13ba9c77
MT
1245 int (*enable_phy_interrupts) (struct netxen_adapter *);
1246 int (*disable_phy_interrupts) (struct netxen_adapter *);
3176ff3e
MT
1247 int (*macaddr_set) (struct netxen_adapter *, netxen_ethernet_macaddr_t);
1248 int (*set_mtu) (struct netxen_adapter *, int);
1249 int (*set_promisc) (struct netxen_adapter *, netxen_niu_prom_mode_t);
13ba9c77
MT
1250 int (*phy_read) (struct netxen_adapter *, long reg, u32 *);
1251 int (*phy_write) (struct netxen_adapter *, long reg, u32 val);
80922fbc 1252 int (*init_port) (struct netxen_adapter *, int);
3176ff3e 1253 int (*stop_port) (struct netxen_adapter *);
3ce06a32
DP
1254
1255 int (*hw_read_wx)(struct netxen_adapter *, ulong, void *, int);
1256 int (*hw_write_wx)(struct netxen_adapter *, ulong, void *, int);
1257 int (*pci_mem_read)(struct netxen_adapter *, u64, void *, int);
1258 int (*pci_mem_write)(struct netxen_adapter *, u64, void *, int);
1259 int (*pci_write_immediate)(struct netxen_adapter *, u64, u32);
1260 u32 (*pci_read_immediate)(struct netxen_adapter *, u64);
1261 void (*pci_write_normalize)(struct netxen_adapter *, u64, u32);
1262 u32 (*pci_read_normalize)(struct netxen_adapter *, u64);
1263 unsigned long (*pci_set_window)(struct netxen_adapter *,
1264 unsigned long long);
3d396eb1
AK
1265}; /* netxen_adapter structure */
1266
96acb6eb
DP
1267/*
1268 * NetXen dma watchdog control structure
1269 *
1270 * Bit 0 : enabled => R/O: 1 watchdog active, 0 inactive
1271 * Bit 1 : disable_request => 1 req disable dma watchdog
1272 * Bit 2 : enable_request => 1 req enable dma watchdog
1273 * Bit 3-31 : unused
1274 */
1275
1276#define netxen_set_dma_watchdog_disable_req(config_word) \
1277 _netxen_set_bits(config_word, 1, 1, 1)
1278#define netxen_set_dma_watchdog_enable_req(config_word) \
1279 _netxen_set_bits(config_word, 2, 1, 1)
1280#define netxen_get_dma_watchdog_enabled(config_word) \
1281 ((config_word) & 0x1)
1282#define netxen_get_dma_watchdog_disabled(config_word) \
1283 (((config_word) >> 1) & 0x1)
1284
3d396eb1
AK
1285/* Max number of xmit producer threads that can run simultaneously */
1286#define MAX_XMIT_PRODUCERS 16
1287
cb8011ad
AK
1288#define PCI_OFFSET_FIRST_RANGE(adapter, off) \
1289 ((adapter)->ahw.pci_base0 + (off))
1290#define PCI_OFFSET_SECOND_RANGE(adapter, off) \
1291 ((adapter)->ahw.pci_base1 + (off) - SECOND_PAGE_GROUP_START)
1292#define PCI_OFFSET_THIRD_RANGE(adapter, off) \
1293 ((adapter)->ahw.pci_base2 + (off) - THIRD_PAGE_GROUP_START)
1294
1295static inline void __iomem *pci_base_offset(struct netxen_adapter *adapter,
1296 unsigned long off)
1297{
1298 if ((off < FIRST_PAGE_GROUP_END) && (off >= FIRST_PAGE_GROUP_START)) {
1299 return (adapter->ahw.pci_base0 + off);
1300 } else if ((off < SECOND_PAGE_GROUP_END) &&
1301 (off >= SECOND_PAGE_GROUP_START)) {
1302 return (adapter->ahw.pci_base1 + off - SECOND_PAGE_GROUP_START);
1303 } else if ((off < THIRD_PAGE_GROUP_END) &&
1304 (off >= THIRD_PAGE_GROUP_START)) {
1305 return (adapter->ahw.pci_base2 + off - THIRD_PAGE_GROUP_START);
1306 }
1307 return NULL;
1308}
1309
1310static inline void __iomem *pci_base(struct netxen_adapter *adapter,
1311 unsigned long off)
1312{
1313 if ((off < FIRST_PAGE_GROUP_END) && (off >= FIRST_PAGE_GROUP_START)) {
1314 return adapter->ahw.pci_base0;
1315 } else if ((off < SECOND_PAGE_GROUP_END) &&
1316 (off >= SECOND_PAGE_GROUP_START)) {
1317 return adapter->ahw.pci_base1;
1318 } else if ((off < THIRD_PAGE_GROUP_END) &&
1319 (off >= THIRD_PAGE_GROUP_START)) {
1320 return adapter->ahw.pci_base2;
1321 }
1322 return NULL;
1323}
1324
13ba9c77
MT
1325int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter);
1326int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter);
1327int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter);
1328int netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter *adapter);
13ba9c77 1329int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
a608ab9c 1330 __u32 * readval);
13ba9c77 1331int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter,
a608ab9c 1332 long reg, __u32 val);
3d396eb1
AK
1333
1334/* Functions available from netxen_nic_hw.c */
3176ff3e
MT
1335int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu);
1336int netxen_nic_set_mtu_gb(struct netxen_adapter *adapter, int new_mtu);
3d396eb1
AK
1337void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val);
1338int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off);
1339void netxen_nic_write_w0(struct netxen_adapter *adapter, u32 index, u32 value);
3ce06a32
DP
1340void netxen_nic_read_w0(struct netxen_adapter *adapter, u32 index, u32 *value);
1341void netxen_nic_write_w1(struct netxen_adapter *adapter, u32 index, u32 value);
1342void netxen_nic_read_w1(struct netxen_adapter *adapter, u32 index, u32 *value);
3d396eb1
AK
1343
1344int netxen_nic_get_board_info(struct netxen_adapter *adapter);
3ce06a32
DP
1345
1346int netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter,
1347 ulong off, void *data, int len);
1348int netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter,
1349 ulong off, void *data, int len);
1350int netxen_nic_pci_mem_read_128M(struct netxen_adapter *adapter,
1351 u64 off, void *data, int size);
1352int netxen_nic_pci_mem_write_128M(struct netxen_adapter *adapter,
1353 u64 off, void *data, int size);
1354int netxen_nic_pci_write_immediate_128M(struct netxen_adapter *adapter,
1355 u64 off, u32 data);
1356u32 netxen_nic_pci_read_immediate_128M(struct netxen_adapter *adapter, u64 off);
1357void netxen_nic_pci_write_normalize_128M(struct netxen_adapter *adapter,
1358 u64 off, u32 data);
1359u32 netxen_nic_pci_read_normalize_128M(struct netxen_adapter *adapter, u64 off);
1360unsigned long netxen_nic_pci_set_window_128M(struct netxen_adapter *adapter,
1361 unsigned long long addr);
1362void netxen_nic_pci_change_crbwindow_128M(struct netxen_adapter *adapter,
1363 u32 wndw);
1364
1365int netxen_nic_hw_read_wx_2M(struct netxen_adapter *adapter,
1366 ulong off, void *data, int len);
1367int netxen_nic_hw_write_wx_2M(struct netxen_adapter *adapter,
1368 ulong off, void *data, int len);
1369int netxen_nic_pci_mem_read_2M(struct netxen_adapter *adapter,
1370 u64 off, void *data, int size);
1371int netxen_nic_pci_mem_write_2M(struct netxen_adapter *adapter,
1372 u64 off, void *data, int size);
3d396eb1
AK
1373void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
1374 unsigned long off, int data);
3ce06a32
DP
1375int netxen_nic_pci_write_immediate_2M(struct netxen_adapter *adapter,
1376 u64 off, u32 data);
1377u32 netxen_nic_pci_read_immediate_2M(struct netxen_adapter *adapter, u64 off);
1378void netxen_nic_pci_write_normalize_2M(struct netxen_adapter *adapter,
1379 u64 off, u32 data);
1380u32 netxen_nic_pci_read_normalize_2M(struct netxen_adapter *adapter, u64 off);
1381unsigned long netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter,
1382 unsigned long long addr);
3d396eb1
AK
1383
1384/* Functions from netxen_nic_init.c */
ed25ffa1
AK
1385void netxen_free_adapter_offload(struct netxen_adapter *adapter);
1386int netxen_initialize_adapter_offload(struct netxen_adapter *adapter);
96acb6eb 1387int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
2956640d 1388int netxen_receive_peg_ready(struct netxen_adapter *adapter);
96acb6eb 1389int netxen_load_firmware(struct netxen_adapter *adapter);
3d396eb1 1390int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose);
2956640d 1391
3d396eb1 1392int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp);
4790654c 1393int netxen_rom_fast_read_words(struct netxen_adapter *adapter, int addr,
27d2ab54 1394 u8 *bytes, size_t size);
4790654c 1395int netxen_rom_fast_write_words(struct netxen_adapter *adapter, int addr,
27d2ab54
AK
1396 u8 *bytes, size_t size);
1397int netxen_flash_unlock(struct netxen_adapter *adapter);
1398int netxen_backup_crbinit(struct netxen_adapter *adapter);
1399int netxen_flash_erase_secondary(struct netxen_adapter *adapter);
1400int netxen_flash_erase_primary(struct netxen_adapter *adapter);
e45d9ab4 1401void netxen_halt_pegs(struct netxen_adapter *adapter);
27d2ab54 1402
cb8011ad 1403int netxen_rom_se(struct netxen_adapter *adapter, int addr);
3d396eb1 1404
2956640d
DP
1405int netxen_alloc_sw_resources(struct netxen_adapter *adapter);
1406void netxen_free_sw_resources(struct netxen_adapter *adapter);
1407
1408int netxen_alloc_hw_resources(struct netxen_adapter *adapter);
1409void netxen_free_hw_resources(struct netxen_adapter *adapter);
1410
1411void netxen_release_rx_buffers(struct netxen_adapter *adapter);
1412void netxen_release_tx_buffers(struct netxen_adapter *adapter);
1413
3d396eb1
AK
1414void netxen_initialize_adapter_ops(struct netxen_adapter *adapter);
1415int netxen_init_firmware(struct netxen_adapter *adapter);
3d396eb1
AK
1416void netxen_tso_check(struct netxen_adapter *adapter,
1417 struct cmd_desc_type0 *desc, struct sk_buff *skb);
3d396eb1 1418void netxen_nic_clear_stats(struct netxen_adapter *adapter);
6d5aefb8 1419void netxen_watchdog_task(struct work_struct *work);
3d396eb1
AK
1420void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx,
1421 u32 ringid);
05aaa02d 1422int netxen_process_cmd_ring(struct netxen_adapter *adapter);
3d396eb1 1423u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max);
c9fc891f
DP
1424void netxen_p2_nic_set_multi(struct net_device *netdev);
1425void netxen_p3_nic_set_multi(struct net_device *netdev);
48bfd1e0
DP
1426
1427u32 nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, u32 mtu);
3d396eb1 1428int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu);
48bfd1e0 1429
3d396eb1
AK
1430int netxen_nic_set_mac(struct net_device *netdev, void *p);
1431struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev);
1432
c9fc891f
DP
1433void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter,
1434 uint32_t crb_producer);
cb8011ad
AK
1435
1436/*
1437 * NetXen Board information
1438 */
1439
e4c93c81 1440#define NETXEN_MAX_SHORT_NAME 32
71bd7877 1441struct netxen_brdinfo {
cb8011ad
AK
1442 netxen_brdtype_t brdtype; /* type of board */
1443 long ports; /* max no of physical ports */
1444 char short_name[NETXEN_MAX_SHORT_NAME];
71bd7877 1445};
cb8011ad 1446
71bd7877 1447static const struct netxen_brdinfo netxen_boards[] = {
cb8011ad
AK
1448 {NETXEN_BRDTYPE_P2_SB31_10G_CX4, 1, "XGb CX4"},
1449 {NETXEN_BRDTYPE_P2_SB31_10G_HMEZ, 1, "XGb HMEZ"},
1450 {NETXEN_BRDTYPE_P2_SB31_10G_IMEZ, 2, "XGb IMEZ"},
1451 {NETXEN_BRDTYPE_P2_SB31_10G, 1, "XGb XFP"},
1452 {NETXEN_BRDTYPE_P2_SB35_4G, 4, "Quad Gb"},
1453 {NETXEN_BRDTYPE_P2_SB31_2G, 2, "Dual Gb"},
e4c93c81
DP
1454 {NETXEN_BRDTYPE_P3_REF_QG, 4, "Reference Quad Gig "},
1455 {NETXEN_BRDTYPE_P3_HMEZ, 2, "Dual XGb HMEZ"},
1456 {NETXEN_BRDTYPE_P3_10G_CX4_LP, 2, "Dual XGb CX4 LP"},
1457 {NETXEN_BRDTYPE_P3_4_GB, 4, "Quad Gig LP"},
1458 {NETXEN_BRDTYPE_P3_IMEZ, 2, "Dual XGb IMEZ"},
1459 {NETXEN_BRDTYPE_P3_10G_SFP_PLUS, 2, "Dual XGb SFP+ LP"},
1460 {NETXEN_BRDTYPE_P3_10000_BASE_T, 1, "XGB 10G BaseT LP"},
1461 {NETXEN_BRDTYPE_P3_XG_LOM, 2, "Dual XGb LOM"},
1462 {NETXEN_BRDTYPE_P3_4_GB_MM, 4, "Quad GB - March Madness"},
1463 {NETXEN_BRDTYPE_P3_10G_CX4, 2, "Reference Dual CX4 Option"},
1464 {NETXEN_BRDTYPE_P3_10G_XFP, 1, "Reference Single XFP Option"}
cb8011ad
AK
1465};
1466
ff8ac609 1467#define NUM_SUPPORTED_BOARDS ARRAY_SIZE(netxen_boards)
cb8011ad 1468
cb8011ad
AK
1469static inline void get_brd_name_by_type(u32 type, char *name)
1470{
1471 int i, found = 0;
1472 for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) {
1473 if (netxen_boards[i].brdtype == type) {
1474 strcpy(name, netxen_boards[i].short_name);
1475 found = 1;
1476 break;
1477 }
1478
3d396eb1 1479 }
cb8011ad
AK
1480 if (!found)
1481 name = "Unknown";
3d396eb1
AK
1482}
1483
96acb6eb
DP
1484static inline int
1485dma_watchdog_shutdown_request(struct netxen_adapter *adapter)
1486{
1487 u32 ctrl;
1488
1489 /* check if already inactive */
3ce06a32 1490 if (adapter->hw_read_wx(adapter,
96acb6eb
DP
1491 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), &ctrl, 4))
1492 printk(KERN_ERR "failed to read dma watchdog status\n");
1493
1494 if (netxen_get_dma_watchdog_enabled(ctrl) == 0)
1495 return 1;
1496
1497 /* Send the disable request */
1498 netxen_set_dma_watchdog_disable_req(ctrl);
1499 netxen_crb_writelit_adapter(adapter,
1500 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
1501
1502 return 0;
1503}
1504
1505static inline int
1506dma_watchdog_shutdown_poll_result(struct netxen_adapter *adapter)
1507{
1508 u32 ctrl;
1509
3ce06a32 1510 if (adapter->hw_read_wx(adapter,
96acb6eb
DP
1511 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), &ctrl, 4))
1512 printk(KERN_ERR "failed to read dma watchdog status\n");
1513
ceded32f 1514 return (netxen_get_dma_watchdog_enabled(ctrl) == 0);
96acb6eb
DP
1515}
1516
1517static inline int
1518dma_watchdog_wakeup(struct netxen_adapter *adapter)
1519{
1520 u32 ctrl;
1521
3ce06a32 1522 if (adapter->hw_read_wx(adapter,
96acb6eb
DP
1523 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), &ctrl, 4))
1524 printk(KERN_ERR "failed to read dma watchdog status\n");
1525
1526 if (netxen_get_dma_watchdog_enabled(ctrl))
1527 return 1;
1528
1529 /* send the wakeup request */
1530 netxen_set_dma_watchdog_enable_req(ctrl);
1531
1532 netxen_crb_writelit_adapter(adapter,
1533 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
1534
1535 return 0;
1536}
1537
1538
3d396eb1 1539int netxen_is_flash_supported(struct netxen_adapter *adapter);
f305f789 1540int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, __le64 mac[]);
3d396eb1
AK
1541extern void netxen_change_ringparam(struct netxen_adapter *adapter);
1542extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr,
1543 int *valp);
1544
1545extern struct ethtool_ops netxen_nic_ethtool_ops;
1546
1547#endif /* __NETXEN_NIC_H_ */