]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/net/netxen/netxen_nic.h
149bb60b0c46f3224c17d48279921b8daff28ec9
[linux-2.6-omap-h63xx.git] / drivers / net / netxen / netxen_nic.h
1 /*
2  * Copyright (C) 2003 - 2006 NetXen, Inc.
3  * All rights reserved.
4  *
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.
9  *
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.
14  *
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.
19  *
20  * The full GNU General Public License is included in this distribution
21  * in the file called LICENSE.
22  *
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
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
66 #define _NETXEN_NIC_LINUX_MAJOR 3
67 #define _NETXEN_NIC_LINUX_MINOR 4
68 #define _NETXEN_NIC_LINUX_SUBVERSION 18
69 #define NETXEN_NIC_LINUX_VERSIONID  "3.4.18"
70
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)
75
76 #define PHAN_VENDOR_ID 0x4040
77
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)
82 #define LRO_DESC_RINGSIZE       \
83         (sizeof(rcvDesc_t) * adapter->max_lro_rx_desc_count)
84 #define TX_RINGSIZE     \
85         (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count)
86 #define RCV_BUFFSIZE    \
87         (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count)
88 #define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a)))
89
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
94 #define FLASH_SUCCESS 0
95
96 #define ADDR_IN_WINDOW1(off)    \
97         ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0
98
99 /*
100  * normalize a 64MB crb address to 32MB PCI window
101  * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1
102  */
103 #define NETXEN_CRB_NORMAL(reg)  \
104         ((reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)
105
106 #define NETXEN_CRB_NORMALIZE(adapter, reg) \
107         pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg))
108
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
114
115 #define FIRST_PAGE_GROUP_START  0
116 #define FIRST_PAGE_GROUP_END    0x100000
117
118 #define SECOND_PAGE_GROUP_START 0x6000000
119 #define SECOND_PAGE_GROUP_END   0x68BC000
120
121 #define THIRD_PAGE_GROUP_START  0x70E4000
122 #define THIRD_PAGE_GROUP_END    0x8000000
123
124 #define FIRST_PAGE_GROUP_SIZE  FIRST_PAGE_GROUP_END - FIRST_PAGE_GROUP_START
125 #define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START
126 #define THIRD_PAGE_GROUP_SIZE  THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START
127
128 #define MAX_RX_BUFFER_LENGTH            1760
129 #define MAX_RX_JUMBO_BUFFER_LENGTH      8062
130 #define MAX_RX_LRO_BUFFER_LENGTH        ((48*1024)-512)
131 #define RX_DMA_MAP_LEN                  (MAX_RX_BUFFER_LENGTH - 2)
132 #define RX_JUMBO_DMA_MAP_LEN    \
133         (MAX_RX_JUMBO_BUFFER_LENGTH - 2)
134 #define RX_LRO_DMA_MAP_LEN              (MAX_RX_LRO_BUFFER_LENGTH - 2)
135
136 /*
137  * Maximum number of ring contexts
138  */
139 #define MAX_RING_CTX 1
140
141 /* Opcodes to be used with the commands */
142 enum {
143         TX_ETHER_PKT = 0x01,
144 /* The following opcodes are for IP checksum    */
145         TX_TCP_PKT,
146         TX_UDP_PKT,
147         TX_IP_PKT,
148         TX_TCP_LSO,
149         TX_IPSEC,
150         TX_IPSEC_CMD
151 };
152
153 /* The following opcodes are for internal consumption. */
154 #define NETXEN_CONTROL_OP       0x10
155 #define PEGNET_REQUEST          0x11
156
157 #define MAX_NUM_CARDS           4
158
159 #define MAX_BUFFERS_PER_CMD     32
160
161 /*
162  * Following are the states of the Phantom. Phantom will set them and
163  * Host will read to check if the fields are correct.
164  */
165 #define PHAN_INITIALIZE_START           0xff00
166 #define PHAN_INITIALIZE_FAILED          0xffff
167 #define PHAN_INITIALIZE_COMPLETE        0xff01
168
169 /* Host writes the following to notify that it has done the init-handshake */
170 #define PHAN_INITIALIZE_ACK     0xf00f
171
172 #define NUM_RCV_DESC_RINGS      3       /* No of Rcv Descriptor contexts */
173
174 /* descriptor types */
175 #define RCV_DESC_NORMAL         0x01
176 #define RCV_DESC_JUMBO          0x02
177 #define RCV_DESC_LRO            0x04
178 #define RCV_DESC_NORMAL_CTXID   0
179 #define RCV_DESC_JUMBO_CTXID    1
180 #define RCV_DESC_LRO_CTXID      2
181
182 #define RCV_DESC_TYPE(ID) \
183         ((ID == RCV_DESC_JUMBO_CTXID)   \
184                 ? RCV_DESC_JUMBO        \
185                 : ((ID == RCV_DESC_LRO_CTXID)   \
186                         ? RCV_DESC_LRO :        \
187                         (RCV_DESC_NORMAL)))
188
189 #define MAX_CMD_DESCRIPTORS             4096
190 #define MAX_RCV_DESCRIPTORS             16384
191 #define MAX_CMD_DESCRIPTORS_HOST        (MAX_CMD_DESCRIPTORS / 4)
192 #define MAX_RCV_DESCRIPTORS_1G          (MAX_RCV_DESCRIPTORS / 4)
193 #define MAX_JUMBO_RCV_DESCRIPTORS       1024
194 #define MAX_LRO_RCV_DESCRIPTORS         64
195 #define MAX_RCVSTATUS_DESCRIPTORS       MAX_RCV_DESCRIPTORS
196 #define MAX_JUMBO_RCV_DESC      MAX_JUMBO_RCV_DESCRIPTORS
197 #define MAX_RCV_DESC            MAX_RCV_DESCRIPTORS
198 #define MAX_RCVSTATUS_DESC      MAX_RCV_DESCRIPTORS
199 #define MAX_EPG_DESCRIPTORS     (MAX_CMD_DESCRIPTORS * 8)
200 #define NUM_RCV_DESC            (MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS + \
201                                  MAX_LRO_RCV_DESCRIPTORS)
202 #define MIN_TX_COUNT    4096
203 #define MIN_RX_COUNT    4096
204 #define NETXEN_CTX_SIGNATURE    0xdee0
205 #define NETXEN_RCV_PRODUCER(ringid)     (ringid)
206 #define MAX_FRAME_SIZE  0x10000 /* 64K MAX size for LSO */
207
208 #define PHAN_PEG_RCV_INITIALIZED        0xff01
209 #define PHAN_PEG_RCV_START_INITIALIZE   0xff00
210
211 #define get_next_index(index, length)   \
212         (((index) + 1) & ((length) - 1))
213
214 #define get_index_range(index,length,count)     \
215         (((index) + (count)) & ((length) - 1))
216
217 #define MPORT_SINGLE_FUNCTION_MODE 0x1111
218 #define MPORT_MULTI_FUNCTION_MODE 0x2222
219
220 #include "netxen_nic_phan_reg.h"
221
222 /*
223  * NetXen host-peg signal message structure
224  *
225  *      Bit 0-1         : peg_id => 0x2 for tx and 01 for rx
226  *      Bit 2           : priv_id => must be 1
227  *      Bit 3-17        : count => for doorbell
228  *      Bit 18-27       : ctx_id => Context id
229  *      Bit 28-31       : opcode
230  */
231
232 typedef u32 netxen_ctx_msg;
233
234 #define netxen_set_msg_peg_id(config_word, val) \
235         ((config_word) &= ~3, (config_word) |= val & 3)
236 #define netxen_set_msg_privid(config_word)      \
237         ((config_word) |= 1 << 2)
238 #define netxen_set_msg_count(config_word, val)  \
239         ((config_word) &= ~(0x7fff<<3), (config_word) |= (val & 0x7fff) << 3)
240 #define netxen_set_msg_ctxid(config_word, val)  \
241         ((config_word) &= ~(0x3ff<<18), (config_word) |= (val & 0x3ff) << 18)
242 #define netxen_set_msg_opcode(config_word, val) \
243         ((config_word) &= ~(0xf<<28), (config_word) |= (val & 0xf) << 28)
244
245 struct netxen_rcv_context {
246         __le64 rcv_ring_addr;
247         __le32 rcv_ring_size;
248         __le32 rsrvd;
249 };
250
251 struct netxen_ring_ctx {
252
253         /* one command ring */
254         __le64 cmd_consumer_offset;
255         __le64 cmd_ring_addr;
256         __le32 cmd_ring_size;
257         __le32 rsrvd;
258
259         /* three receive rings */
260         struct netxen_rcv_context rcv_ctx[3];
261
262         /* one status ring */
263         __le64 sts_ring_addr;
264         __le32 sts_ring_size;
265
266         __le32 ctx_id;
267 } __attribute__ ((aligned(64)));
268
269 /*
270  * Following data structures describe the descriptors that will be used.
271  * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when
272  * we are doing LSO (above the 1500 size packet) only.
273  */
274
275 /*
276  * The size of reference handle been changed to 16 bits to pass the MSS fields
277  * for the LSO packet
278  */
279
280 #define FLAGS_CHECKSUM_ENABLED  0x01
281 #define FLAGS_LSO_ENABLED       0x02
282 #define FLAGS_IPSEC_SA_ADD      0x04
283 #define FLAGS_IPSEC_SA_DELETE   0x08
284 #define FLAGS_VLAN_TAGGED       0x10
285
286 #define netxen_set_cmd_desc_port(cmd_desc, var) \
287         ((cmd_desc)->port_ctxid |= ((var) & 0x0F))
288 #define netxen_set_cmd_desc_ctxid(cmd_desc, var)        \
289         ((cmd_desc)->port_ctxid |= ((var) & 0xF0))
290
291 #define netxen_set_cmd_desc_flags(cmd_desc, val)        \
292         (cmd_desc)->flags_opcode = ((cmd_desc)->flags_opcode & \
293                 ~cpu_to_le16(0x7f)) | cpu_to_le16((val) & 0x7f)
294 #define netxen_set_cmd_desc_opcode(cmd_desc, val)       \
295         (cmd_desc)->flags_opcode = ((cmd_desc)->flags_opcode & \
296                 ~cpu_to_le16((u16)0x3f << 7)) | cpu_to_le16(((val) & 0x3f) << 7)
297
298 #define netxen_set_cmd_desc_num_of_buff(cmd_desc, val)  \
299         (cmd_desc)->num_of_buffers_total_length = \
300                 ((cmd_desc)->num_of_buffers_total_length & \
301                 ~cpu_to_le32(0xff)) | cpu_to_le32((val) & 0xff)
302 #define netxen_set_cmd_desc_totallength(cmd_desc, val)  \
303         (cmd_desc)->num_of_buffers_total_length = \
304                 ((cmd_desc)->num_of_buffers_total_length & \
305                 ~cpu_to_le32((u32)0xffffff << 8)) | \
306                 cpu_to_le32(((val) & 0xffffff) << 8)
307
308 #define netxen_get_cmd_desc_opcode(cmd_desc)    \
309         ((le16_to_cpu((cmd_desc)->flags_opcode) >> 7) & 0x003f)
310 #define netxen_get_cmd_desc_totallength(cmd_desc)       \
311         ((le32_to_cpu((cmd_desc)->num_of_buffers_total_length) >> 8) & 0xffffff)
312
313 struct cmd_desc_type0 {
314         u8 tcp_hdr_offset;      /* For LSO only */
315         u8 ip_hdr_offset;       /* For LSO only */
316         /* Bit pattern: 0-6 flags, 7-12 opcode, 13-15 unused */
317         __le16 flags_opcode;
318         /* Bit pattern: 0-7 total number of segments,
319            8-31 Total size of the packet */
320         __le32 num_of_buffers_total_length;
321         union {
322                 struct {
323                         __le32 addr_low_part2;
324                         __le32 addr_high_part2;
325                 };
326                 __le64 addr_buffer2;
327         };
328
329         __le16 reference_handle;        /* changed to u16 to add mss */
330         __le16 mss;             /* passed by NDIS_PACKET for LSO */
331         /* Bit pattern 0-3 port, 0-3 ctx id */
332         u8 port_ctxid;
333         u8 total_hdr_length;    /* LSO only : MAC+IP+TCP Hdr size */
334         __le16 conn_id;         /* IPSec offoad only */
335
336         union {
337                 struct {
338                         __le32 addr_low_part3;
339                         __le32 addr_high_part3;
340                 };
341                 __le64 addr_buffer3;
342         };
343         union {
344                 struct {
345                         __le32 addr_low_part1;
346                         __le32 addr_high_part1;
347                 };
348                 __le64 addr_buffer1;
349         };
350
351         __le16 buffer1_length;
352         __le16 buffer2_length;
353         __le16 buffer3_length;
354         __le16 buffer4_length;
355
356         union {
357                 struct {
358                         __le32 addr_low_part4;
359                         __le32 addr_high_part4;
360                 };
361                 __le64 addr_buffer4;
362         };
363
364         __le64 unused;
365
366 } __attribute__ ((aligned(64)));
367
368 /* Note: sizeof(rcv_desc) should always be a mutliple of 2 */
369 struct rcv_desc {
370         __le16 reference_handle;
371         __le16 reserved;
372         __le32 buffer_length;   /* allocated buffer length (usually 2K) */
373         __le64 addr_buffer;
374 };
375
376 /* opcode field in status_desc */
377 #define RCV_NIC_PKT     (0xA)
378 #define STATUS_NIC_PKT  ((RCV_NIC_PKT) << 12)
379
380 /* for status field in status_desc */
381 #define STATUS_NEED_CKSUM       (1)
382 #define STATUS_CKSUM_OK         (2)
383
384 /* owner bits of status_desc */
385 #define STATUS_OWNER_HOST       (0x1)
386 #define STATUS_OWNER_PHANTOM    (0x2)
387
388 #define NETXEN_PROT_IP          (1)
389 #define NETXEN_PROT_UNKNOWN     (0)
390
391 /* Note: sizeof(status_desc) should always be a mutliple of 2 */
392
393 #define netxen_get_sts_desc_lro_cnt(status_desc)        \
394         ((status_desc)->lro & 0x7F)
395 #define netxen_get_sts_desc_lro_last_frag(status_desc)  \
396         (((status_desc)->lro & 0x80) >> 7)
397
398 #define netxen_get_sts_port(sts_data)   \
399         ((sts_data) & 0x0F)
400 #define netxen_get_sts_status(sts_data) \
401         (((sts_data) >> 4) & 0x0F)
402 #define netxen_get_sts_type(sts_data)   \
403         (((sts_data) >> 8) & 0x0F)
404 #define netxen_get_sts_totallength(sts_data)    \
405         (((sts_data) >> 12) & 0xFFFF)
406 #define netxen_get_sts_refhandle(sts_data)      \
407         (((sts_data) >> 28) & 0xFFFF)
408 #define netxen_get_sts_prot(sts_data)   \
409         (((sts_data) >> 44) & 0x0F)
410 #define netxen_get_sts_opcode(sts_data) \
411         (((sts_data) >> 58) & 0x03F)
412
413 #define netxen_get_sts_owner(status_desc)       \
414         ((le64_to_cpu((status_desc)->status_desc_data) >> 56) & 0x03)
415 #define netxen_set_sts_owner(status_desc, val)  { \
416         (status_desc)->status_desc_data = \
417                 ((status_desc)->status_desc_data & \
418                 ~cpu_to_le64(0x3ULL << 56)) | \
419                 cpu_to_le64((u64)((val) & 0x3) << 56); \
420 }
421
422 struct status_desc {
423         /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length
424            28-43 reference_handle, 44-47 protocol, 48-52 unused
425            53-55 desc_cnt, 56-57 owner, 58-63 opcode
426          */
427         __le64 status_desc_data;
428         __le32 hash_value;
429         u8 hash_type;
430         u8 msg_type;
431         u8 unused;
432         /* Bit pattern: 0-6 lro_count indicates frag sequence,
433            7 last_frag indicates last frag */
434         u8 lro;
435 } __attribute__ ((aligned(16)));
436
437 enum {
438         NETXEN_RCV_PEG_0 = 0,
439         NETXEN_RCV_PEG_1
440 };
441 /* The version of the main data structure */
442 #define NETXEN_BDINFO_VERSION 1
443
444 /* Magic number to let user know flash is programmed */
445 #define NETXEN_BDINFO_MAGIC 0x12345678
446
447 /* Max number of Gig ports on a Phantom board */
448 #define NETXEN_MAX_PORTS 4
449
450 typedef enum {
451         NETXEN_BRDTYPE_P1_BD = 0x0000,
452         NETXEN_BRDTYPE_P1_SB = 0x0001,
453         NETXEN_BRDTYPE_P1_SMAX = 0x0002,
454         NETXEN_BRDTYPE_P1_SOCK = 0x0003,
455
456         NETXEN_BRDTYPE_P2_SOCK_31 = 0x0008,
457         NETXEN_BRDTYPE_P2_SOCK_35 = 0x0009,
458         NETXEN_BRDTYPE_P2_SB35_4G = 0x000a,
459         NETXEN_BRDTYPE_P2_SB31_10G = 0x000b,
460         NETXEN_BRDTYPE_P2_SB31_2G = 0x000c,
461
462         NETXEN_BRDTYPE_P2_SB31_10G_IMEZ = 0x000d,
463         NETXEN_BRDTYPE_P2_SB31_10G_HMEZ = 0x000e,
464         NETXEN_BRDTYPE_P2_SB31_10G_CX4 = 0x000f
465 } netxen_brdtype_t;
466
467 typedef enum {
468         NETXEN_BRDMFG_INVENTEC = 1
469 } netxen_brdmfg;
470
471 typedef enum {
472         MEM_ORG_128Mbx4 = 0x0,  /* DDR1 only */
473         MEM_ORG_128Mbx8 = 0x1,  /* DDR1 only */
474         MEM_ORG_128Mbx16 = 0x2, /* DDR1 only */
475         MEM_ORG_256Mbx4 = 0x3,
476         MEM_ORG_256Mbx8 = 0x4,
477         MEM_ORG_256Mbx16 = 0x5,
478         MEM_ORG_512Mbx4 = 0x6,
479         MEM_ORG_512Mbx8 = 0x7,
480         MEM_ORG_512Mbx16 = 0x8,
481         MEM_ORG_1Gbx4 = 0x9,
482         MEM_ORG_1Gbx8 = 0xa,
483         MEM_ORG_1Gbx16 = 0xb,
484         MEM_ORG_2Gbx4 = 0xc,
485         MEM_ORG_2Gbx8 = 0xd,
486         MEM_ORG_2Gbx16 = 0xe,
487         MEM_ORG_128Mbx32 = 0x10002,     /* GDDR only */
488         MEM_ORG_256Mbx32 = 0x10005      /* GDDR only */
489 } netxen_mn_mem_org_t;
490
491 typedef enum {
492         MEM_ORG_512Kx36 = 0x0,
493         MEM_ORG_1Mx36 = 0x1,
494         MEM_ORG_2Mx36 = 0x2
495 } netxen_sn_mem_org_t;
496
497 typedef enum {
498         MEM_DEPTH_4MB = 0x1,
499         MEM_DEPTH_8MB = 0x2,
500         MEM_DEPTH_16MB = 0x3,
501         MEM_DEPTH_32MB = 0x4,
502         MEM_DEPTH_64MB = 0x5,
503         MEM_DEPTH_128MB = 0x6,
504         MEM_DEPTH_256MB = 0x7,
505         MEM_DEPTH_512MB = 0x8,
506         MEM_DEPTH_1GB = 0x9,
507         MEM_DEPTH_2GB = 0xa,
508         MEM_DEPTH_4GB = 0xb,
509         MEM_DEPTH_8GB = 0xc,
510         MEM_DEPTH_16GB = 0xd,
511         MEM_DEPTH_32GB = 0xe
512 } netxen_mem_depth_t;
513
514 struct netxen_board_info {
515         u32 header_version;
516
517         u32 board_mfg;
518         u32 board_type;
519         u32 board_num;
520         u32 chip_id;
521         u32 chip_minor;
522         u32 chip_major;
523         u32 chip_pkg;
524         u32 chip_lot;
525
526         u32 port_mask;          /* available niu ports */
527         u32 peg_mask;           /* available pegs */
528         u32 icache_ok;          /* can we run with icache? */
529         u32 dcache_ok;          /* can we run with dcache? */
530         u32 casper_ok;
531
532         u32 mac_addr_lo_0;
533         u32 mac_addr_lo_1;
534         u32 mac_addr_lo_2;
535         u32 mac_addr_lo_3;
536
537         /* MN-related config */
538         u32 mn_sync_mode;       /* enable/ sync shift cclk/ sync shift mclk */
539         u32 mn_sync_shift_cclk;
540         u32 mn_sync_shift_mclk;
541         u32 mn_wb_en;
542         u32 mn_crystal_freq;    /* in MHz */
543         u32 mn_speed;           /* in MHz */
544         u32 mn_org;
545         u32 mn_depth;
546         u32 mn_ranks_0;         /* ranks per slot */
547         u32 mn_ranks_1;         /* ranks per slot */
548         u32 mn_rd_latency_0;
549         u32 mn_rd_latency_1;
550         u32 mn_rd_latency_2;
551         u32 mn_rd_latency_3;
552         u32 mn_rd_latency_4;
553         u32 mn_rd_latency_5;
554         u32 mn_rd_latency_6;
555         u32 mn_rd_latency_7;
556         u32 mn_rd_latency_8;
557         u32 mn_dll_val[18];
558         u32 mn_mode_reg;        /* MIU DDR Mode Register */
559         u32 mn_ext_mode_reg;    /* MIU DDR Extended Mode Register */
560         u32 mn_timing_0;        /* MIU Memory Control Timing Rgister */
561         u32 mn_timing_1;        /* MIU Extended Memory Ctrl Timing Register */
562         u32 mn_timing_2;        /* MIU Extended Memory Ctrl Timing2 Register */
563
564         /* SN-related config */
565         u32 sn_sync_mode;       /* enable/ sync shift cclk / sync shift mclk */
566         u32 sn_pt_mode;         /* pass through mode */
567         u32 sn_ecc_en;
568         u32 sn_wb_en;
569         u32 sn_crystal_freq;
570         u32 sn_speed;
571         u32 sn_org;
572         u32 sn_depth;
573         u32 sn_dll_tap;
574         u32 sn_rd_latency;
575
576         u32 mac_addr_hi_0;
577         u32 mac_addr_hi_1;
578         u32 mac_addr_hi_2;
579         u32 mac_addr_hi_3;
580
581         u32 magic;              /* indicates flash has been initialized */
582
583         u32 mn_rdimm;
584         u32 mn_dll_override;
585
586 };
587
588 #define FLASH_NUM_PORTS         (4)
589
590 struct netxen_flash_mac_addr {
591         u32 flash_addr[32];
592 };
593
594 struct netxen_user_old_info {
595         u8 flash_md5[16];
596         u8 crbinit_md5[16];
597         u8 brdcfg_md5[16];
598         /* bootloader */
599         u32 bootld_version;
600         u32 bootld_size;
601         u8 bootld_md5[16];
602         /* image */
603         u32 image_version;
604         u32 image_size;
605         u8 image_md5[16];
606         /* primary image status */
607         u32 primary_status;
608         u32 secondary_present;
609
610         /* MAC address , 4 ports */
611         struct netxen_flash_mac_addr mac_addr[FLASH_NUM_PORTS];
612 };
613 #define FLASH_NUM_MAC_PER_PORT  32
614 struct netxen_user_info {
615         u8 flash_md5[16 * 64];
616         /* bootloader */
617         u32 bootld_version;
618         u32 bootld_size;
619         /* image */
620         u32 image_version;
621         u32 image_size;
622         /* primary image status */
623         u32 primary_status;
624         u32 secondary_present;
625
626         /* MAC address , 4 ports, 32 address per port */
627         u64 mac_addr[FLASH_NUM_PORTS * FLASH_NUM_MAC_PER_PORT];
628         u32 sub_sys_id;
629         u8 serial_num[32];
630
631         /* Any user defined data */
632 };
633
634 /*
635  * Flash Layout - new format.
636  */
637 struct netxen_new_user_info {
638         u8 flash_md5[16 * 64];
639         /* bootloader */
640         u32 bootld_version;
641         u32 bootld_size;
642         /* image */
643         u32 image_version;
644         u32 image_size;
645         /* primary image status */
646         u32 primary_status;
647         u32 secondary_present;
648
649         /* MAC address , 4 ports, 32 address per port */
650         u64 mac_addr[FLASH_NUM_PORTS * FLASH_NUM_MAC_PER_PORT];
651         u32 sub_sys_id;
652         u8 serial_num[32];
653
654         /* Any user defined data */
655 };
656
657 #define SECONDARY_IMAGE_PRESENT 0xb3b4b5b6
658 #define SECONDARY_IMAGE_ABSENT  0xffffffff
659 #define PRIMARY_IMAGE_GOOD      0x5a5a5a5a
660 #define PRIMARY_IMAGE_BAD       0xffffffff
661
662 /* Flash memory map */
663 typedef enum {
664         NETXEN_CRBINIT_START = 0,       /* Crbinit section */
665         NETXEN_BRDCFG_START = 0x4000,   /* board config */
666         NETXEN_INITCODE_START = 0x6000, /* pegtune code */
667         NETXEN_BOOTLD_START = 0x10000,  /* bootld */
668         NETXEN_IMAGE_START = 0x43000,   /* compressed image */
669         NETXEN_SECONDARY_START = 0x200000,      /* backup images */
670         NETXEN_PXE_START = 0x3E0000,    /* user defined region */
671         NETXEN_USER_START = 0x3E8000,   /* User defined region for new boards */
672         NETXEN_FIXED_START = 0x3F0000   /* backup of crbinit */
673 } netxen_flash_map_t;
674
675 #define NETXEN_USER_START_OLD NETXEN_PXE_START  /* for backward compatibility */
676
677 #define NETXEN_FLASH_START              (NETXEN_CRBINIT_START)
678 #define NETXEN_INIT_SECTOR              (0)
679 #define NETXEN_PRIMARY_START            (NETXEN_BOOTLD_START)
680 #define NETXEN_FLASH_CRBINIT_SIZE       (0x4000)
681 #define NETXEN_FLASH_BRDCFG_SIZE        (sizeof(struct netxen_board_info))
682 #define NETXEN_FLASH_USER_SIZE          (sizeof(struct netxen_user_info)/sizeof(u32))
683 #define NETXEN_FLASH_SECONDARY_SIZE     (NETXEN_USER_START-NETXEN_SECONDARY_START)
684 #define NETXEN_NUM_PRIMARY_SECTORS      (0x20)
685 #define NETXEN_NUM_CONFIG_SECTORS       (1)
686 #define PFX "NetXen: "
687 extern char netxen_nic_driver_name[];
688
689 /* Note: Make sure to not call this before adapter->port is valid */
690 #if !defined(NETXEN_DEBUG)
691 #define DPRINTK(klevel, fmt, args...)   do { \
692         } while (0)
693 #else
694 #define DPRINTK(klevel, fmt, args...)   do { \
695         printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\
696                 (adapter != NULL && adapter->netdev != NULL) ? \
697                 adapter->netdev->name : NULL, \
698                 ## args); } while(0)
699 #endif
700
701 /* Number of status descriptors to handle per interrupt */
702 #define MAX_STATUS_HANDLE       (128)
703
704 /*
705  * netxen_skb_frag{} is to contain mapping info for each SG list. This
706  * has to be freed when DMA is complete. This is part of netxen_tx_buffer{}.
707  */
708 struct netxen_skb_frag {
709         u64 dma;
710         u32 length;
711 };
712
713 #define _netxen_set_bits(config_word, start, bits, val) {\
714         unsigned long long __tmask = (((1ULL << (bits)) - 1) << (start));\
715         unsigned long long __tvalue = (val);    \
716         (config_word) &= ~__tmask;      \
717         (config_word) |= (((__tvalue) << (start)) & __tmask); \
718 }
719
720 #define _netxen_clear_bits(config_word, start, bits) {\
721         unsigned long long __tmask = (((1ULL << (bits)) - 1) << (start));  \
722         (config_word) &= ~__tmask; \
723 }
724
725 /*    Following defines are for the state of the buffers    */
726 #define NETXEN_BUFFER_FREE      0
727 #define NETXEN_BUFFER_BUSY      1
728
729 /*
730  * There will be one netxen_buffer per skb packet.    These will be
731  * used to save the dma info for pci_unmap_page()
732  */
733 struct netxen_cmd_buffer {
734         struct sk_buff *skb;
735         struct netxen_skb_frag frag_array[MAX_BUFFERS_PER_CMD + 1];
736         u32 total_length;
737         u32 mss;
738         u16 port;
739         u8 cmd;
740         u8 frag_count;
741         unsigned long time_stamp;
742         u32 state;
743 };
744
745 /* In rx_buffer, we do not need multiple fragments as is a single buffer */
746 struct netxen_rx_buffer {
747         struct sk_buff *skb;
748         u64 dma;
749         u16 ref_handle;
750         u16 state;
751         u32 lro_expected_frags;
752         u32 lro_current_frags;
753         u32 lro_length;
754 };
755
756 /* Board types */
757 #define NETXEN_NIC_GBE  0x01
758 #define NETXEN_NIC_XGBE 0x02
759
760 /*
761  * One hardware_context{} per adapter
762  * contains interrupt info as well shared hardware info.
763  */
764 struct netxen_hardware_context {
765         void __iomem *pci_base0;
766         void __iomem *pci_base1;
767         void __iomem *pci_base2;
768         unsigned long first_page_group_end;
769         unsigned long first_page_group_start;
770         void __iomem *db_base;
771         unsigned long db_len;
772
773         u8 revision_id;
774         u16 board_type;
775         struct netxen_board_info boardcfg;
776         u32 xg_linkup;
777         u32 qg_linksup;
778         /* Address of cmd ring in Phantom */
779         struct cmd_desc_type0 *cmd_desc_head;
780         dma_addr_t cmd_desc_phys_addr;
781         struct netxen_adapter *adapter;
782         int pci_func;
783 };
784
785 #define RCV_RING_LRO    RCV_DESC_LRO
786
787 #define MINIMUM_ETHERNET_FRAME_SIZE     64      /* With FCS */
788 #define ETHERNET_FCS_SIZE               4
789
790 struct netxen_adapter_stats {
791         u64  rcvdbadskb;
792         u64  xmitcalled;
793         u64  xmitedframes;
794         u64  xmitfinished;
795         u64  badskblen;
796         u64  nocmddescriptor;
797         u64  polled;
798         u64  rxdropped;
799         u64  txdropped;
800         u64  csummed;
801         u64  no_rcv;
802         u64  rxbytes;
803         u64  txbytes;
804         u64  ints;
805 };
806
807 /*
808  * Rcv Descriptor Context. One such per Rcv Descriptor. There may
809  * be one Rcv Descriptor for normal packets, one for jumbo and may be others.
810  */
811 struct netxen_rcv_desc_ctx {
812         u32 flags;
813         u32 producer;
814         dma_addr_t phys_addr;
815         u32 crb_rcv_producer;   /* reg offset */
816         struct rcv_desc *desc_head;     /* address of rx ring in Phantom */
817         u32 max_rx_desc_count;
818         u32 dma_size;
819         u32 skb_size;
820         struct netxen_rx_buffer *rx_buf_arr;    /* rx buffers for receive   */
821         int begin_alloc;
822 };
823
824 /*
825  * Receive context. There is one such structure per instance of the
826  * receive processing. Any state information that is relevant to
827  * the receive, and is must be in this structure. The global data may be
828  * present elsewhere.
829  */
830 struct netxen_recv_context {
831         struct netxen_rcv_desc_ctx rcv_desc[NUM_RCV_DESC_RINGS];
832         u32 status_rx_consumer;
833         u32 crb_sts_consumer;   /* reg offset */
834         dma_addr_t rcv_status_desc_phys_addr;
835         struct status_desc *rcv_status_desc_head;
836 };
837
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 };
846
847 struct netxen_adapter {
848         struct netxen_hardware_context ahw;
849
850         struct net_device *netdev;
851         struct pci_dev *pdev;
852         struct napi_struct napi;
853         struct net_device_stats net_stats;
854         unsigned char mac_addr[ETH_ALEN];
855         int mtu;
856         int portnum;
857         u8 physical_port;
858
859         struct work_struct watchdog_task;
860         struct timer_list watchdog_timer;
861         struct work_struct  tx_timeout_task;
862
863         u32 curr_window;
864
865         u32 cmd_producer;
866         __le32 *cmd_consumer;
867         u32 last_cmd_consumer;
868         u32 crb_addr_cmd_producer;
869         u32 crb_addr_cmd_consumer;
870
871         u32 max_tx_desc_count;
872         u32 max_rx_desc_count;
873         u32 max_jumbo_rx_desc_count;
874         u32 max_lro_rx_desc_count;
875
876         u32 flags;
877         u32 irq;
878         int driver_mismatch;
879         u32 temp;
880
881         struct netxen_adapter_stats stats;
882
883         u16 link_speed;
884         u16 link_duplex;
885         u16 state;
886         u16 link_autoneg;
887         int rx_csum;
888         int status;
889
890         struct netxen_cmd_buffer *cmd_buf_arr;  /* Command buffers for xmit */
891
892         /*
893          * Receive instances. These can be either one per port,
894          * or one per peg, etc.
895          */
896         struct netxen_recv_context recv_ctx[MAX_RCV_CTX];
897
898         int is_up;
899         struct netxen_dummy_dma dummy_dma;
900
901         /* Context interface shared between card and host */
902         struct netxen_ring_ctx *ctx_desc;
903         dma_addr_t ctx_desc_phys_addr;
904         int intr_scheme;
905         int msi_mode;
906         int (*enable_phy_interrupts) (struct netxen_adapter *);
907         int (*disable_phy_interrupts) (struct netxen_adapter *);
908         void (*handle_phy_intr) (struct netxen_adapter *);
909         int (*macaddr_set) (struct netxen_adapter *, netxen_ethernet_macaddr_t);
910         int (*set_mtu) (struct netxen_adapter *, int);
911         int (*set_promisc) (struct netxen_adapter *, netxen_niu_prom_mode_t);
912         int (*unset_promisc) (struct netxen_adapter *, netxen_niu_prom_mode_t);
913         int (*phy_read) (struct netxen_adapter *, long reg, u32 *);
914         int (*phy_write) (struct netxen_adapter *, long reg, u32 val);
915         int (*init_port) (struct netxen_adapter *, int);
916         void (*init_niu) (struct netxen_adapter *);
917         int (*stop_port) (struct netxen_adapter *);
918 };                              /* netxen_adapter structure */
919
920 /*
921  * NetXen dma watchdog control structure
922  *
923  *      Bit 0           : enabled => R/O: 1 watchdog active, 0 inactive
924  *      Bit 1           : disable_request => 1 req disable dma watchdog
925  *      Bit 2           : enable_request =>  1 req enable dma watchdog
926  *      Bit 3-31        : unused
927  */
928
929 #define netxen_set_dma_watchdog_disable_req(config_word) \
930         _netxen_set_bits(config_word, 1, 1, 1)
931 #define netxen_set_dma_watchdog_enable_req(config_word) \
932         _netxen_set_bits(config_word, 2, 1, 1)
933 #define netxen_get_dma_watchdog_enabled(config_word) \
934         ((config_word) & 0x1)
935 #define netxen_get_dma_watchdog_disabled(config_word) \
936         (((config_word) >> 1) & 0x1)
937
938 /* Max number of xmit producer threads that can run simultaneously */
939 #define MAX_XMIT_PRODUCERS              16
940
941 #define PCI_OFFSET_FIRST_RANGE(adapter, off)    \
942         ((adapter)->ahw.pci_base0 + (off))
943 #define PCI_OFFSET_SECOND_RANGE(adapter, off)   \
944         ((adapter)->ahw.pci_base1 + (off) - SECOND_PAGE_GROUP_START)
945 #define PCI_OFFSET_THIRD_RANGE(adapter, off)    \
946         ((adapter)->ahw.pci_base2 + (off) - THIRD_PAGE_GROUP_START)
947
948 static inline void __iomem *pci_base_offset(struct netxen_adapter *adapter,
949                                             unsigned long off)
950 {
951         if ((off < FIRST_PAGE_GROUP_END) && (off >= FIRST_PAGE_GROUP_START)) {
952                 return (adapter->ahw.pci_base0 + off);
953         } else if ((off < SECOND_PAGE_GROUP_END) &&
954                    (off >= SECOND_PAGE_GROUP_START)) {
955                 return (adapter->ahw.pci_base1 + off - SECOND_PAGE_GROUP_START);
956         } else if ((off < THIRD_PAGE_GROUP_END) &&
957                    (off >= THIRD_PAGE_GROUP_START)) {
958                 return (adapter->ahw.pci_base2 + off - THIRD_PAGE_GROUP_START);
959         }
960         return NULL;
961 }
962
963 static inline void __iomem *pci_base(struct netxen_adapter *adapter,
964                                      unsigned long off)
965 {
966         if ((off < FIRST_PAGE_GROUP_END) && (off >= FIRST_PAGE_GROUP_START)) {
967                 return adapter->ahw.pci_base0;
968         } else if ((off < SECOND_PAGE_GROUP_END) &&
969                    (off >= SECOND_PAGE_GROUP_START)) {
970                 return adapter->ahw.pci_base1;
971         } else if ((off < THIRD_PAGE_GROUP_END) &&
972                    (off >= THIRD_PAGE_GROUP_START)) {
973                 return adapter->ahw.pci_base2;
974         }
975         return NULL;
976 }
977
978 int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter);
979 int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter);
980 int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter);
981 int netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter *adapter);
982 void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter);
983 void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter);
984 int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
985                             __u32 * readval);
986 int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter,
987                              long reg, __u32 val);
988
989 /* Functions available from netxen_nic_hw.c */
990 int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu);
991 int netxen_nic_set_mtu_gb(struct netxen_adapter *adapter, int new_mtu);
992 void netxen_nic_init_niu_gb(struct netxen_adapter *adapter);
993 void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw);
994 void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val);
995 int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off);
996 void netxen_nic_write_w0(struct netxen_adapter *adapter, u32 index, u32 value);
997 void netxen_nic_read_w0(struct netxen_adapter *adapter, u32 index, u32 * value);
998
999 int netxen_nic_get_board_info(struct netxen_adapter *adapter);
1000 int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off, void *data,
1001                           int len);
1002 int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data,
1003                            int len);
1004 void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
1005                                  unsigned long off, int data);
1006
1007 /* Functions from netxen_nic_init.c */
1008 void netxen_free_adapter_offload(struct netxen_adapter *adapter);
1009 int netxen_initialize_adapter_offload(struct netxen_adapter *adapter);
1010 int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
1011 int netxen_load_firmware(struct netxen_adapter *adapter);
1012 int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose);
1013 int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp);
1014 int netxen_rom_fast_read_words(struct netxen_adapter *adapter, int addr,
1015                                 u8 *bytes, size_t size);
1016 int netxen_rom_fast_write_words(struct netxen_adapter *adapter, int addr,
1017                                 u8 *bytes, size_t size);
1018 int netxen_flash_unlock(struct netxen_adapter *adapter);
1019 int netxen_backup_crbinit(struct netxen_adapter *adapter);
1020 int netxen_flash_erase_secondary(struct netxen_adapter *adapter);
1021 int netxen_flash_erase_primary(struct netxen_adapter *adapter);
1022 void netxen_halt_pegs(struct netxen_adapter *adapter);
1023
1024 int netxen_rom_se(struct netxen_adapter *adapter, int addr);
1025
1026 /* Functions from netxen_nic_isr.c */
1027 void netxen_initialize_adapter_sw(struct netxen_adapter *adapter);
1028 void netxen_initialize_adapter_ops(struct netxen_adapter *adapter);
1029 int netxen_init_firmware(struct netxen_adapter *adapter);
1030 void netxen_free_hw_resources(struct netxen_adapter *adapter);
1031 void netxen_tso_check(struct netxen_adapter *adapter,
1032                       struct cmd_desc_type0 *desc, struct sk_buff *skb);
1033 int netxen_nic_hw_resources(struct netxen_adapter *adapter);
1034 void netxen_nic_clear_stats(struct netxen_adapter *adapter);
1035 void netxen_watchdog_task(struct work_struct *work);
1036 void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx,
1037                             u32 ringid);
1038 int netxen_process_cmd_ring(struct netxen_adapter *adapter);
1039 u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max);
1040 void netxen_nic_set_multi(struct net_device *netdev);
1041 int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu);
1042 int netxen_nic_set_mac(struct net_device *netdev, void *p);
1043 struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev);
1044
1045
1046 /*
1047  * NetXen Board information
1048  */
1049
1050 #define NETXEN_MAX_SHORT_NAME 16
1051 struct netxen_brdinfo {
1052         netxen_brdtype_t brdtype;       /* type of board */
1053         long ports;             /* max no of physical ports */
1054         char short_name[NETXEN_MAX_SHORT_NAME];
1055 };
1056
1057 static const struct netxen_brdinfo netxen_boards[] = {
1058         {NETXEN_BRDTYPE_P2_SB31_10G_CX4, 1, "XGb CX4"},
1059         {NETXEN_BRDTYPE_P2_SB31_10G_HMEZ, 1, "XGb HMEZ"},
1060         {NETXEN_BRDTYPE_P2_SB31_10G_IMEZ, 2, "XGb IMEZ"},
1061         {NETXEN_BRDTYPE_P2_SB31_10G, 1, "XGb XFP"},
1062         {NETXEN_BRDTYPE_P2_SB35_4G, 4, "Quad Gb"},
1063         {NETXEN_BRDTYPE_P2_SB31_2G, 2, "Dual Gb"},
1064 };
1065
1066 #define NUM_SUPPORTED_BOARDS ARRAY_SIZE(netxen_boards)
1067
1068 static inline void get_brd_name_by_type(u32 type, char *name)
1069 {
1070         int i, found = 0;
1071         for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) {
1072                 if (netxen_boards[i].brdtype == type) {
1073                         strcpy(name, netxen_boards[i].short_name);
1074                         found = 1;
1075                         break;
1076                 }
1077
1078         }
1079         if (!found)
1080                 name = "Unknown";
1081 }
1082
1083 static inline int
1084 dma_watchdog_shutdown_request(struct netxen_adapter *adapter)
1085 {
1086         u32 ctrl;
1087
1088         /* check if already inactive */
1089         if (netxen_nic_hw_read_wx(adapter,
1090             NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), &ctrl, 4))
1091                 printk(KERN_ERR "failed to read dma watchdog status\n");
1092
1093         if (netxen_get_dma_watchdog_enabled(ctrl) == 0)
1094                 return 1;
1095
1096         /* Send the disable request */
1097         netxen_set_dma_watchdog_disable_req(ctrl);
1098         netxen_crb_writelit_adapter(adapter,
1099                 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
1100
1101         return 0;
1102 }
1103
1104 static inline int
1105 dma_watchdog_shutdown_poll_result(struct netxen_adapter *adapter)
1106 {
1107         u32 ctrl;
1108
1109         if (netxen_nic_hw_read_wx(adapter,
1110             NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), &ctrl, 4))
1111                 printk(KERN_ERR "failed to read dma watchdog status\n");
1112
1113         return (netxen_get_dma_watchdog_enabled(ctrl) == 0);
1114 }
1115
1116 static inline int
1117 dma_watchdog_wakeup(struct netxen_adapter *adapter)
1118 {
1119         u32 ctrl;
1120
1121         if (netxen_nic_hw_read_wx(adapter,
1122                 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), &ctrl, 4))
1123                 printk(KERN_ERR "failed to read dma watchdog status\n");
1124
1125         if (netxen_get_dma_watchdog_enabled(ctrl))
1126                 return 1;
1127
1128         /* send the wakeup request */
1129         netxen_set_dma_watchdog_enable_req(ctrl);
1130
1131         netxen_crb_writelit_adapter(adapter,
1132                 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
1133
1134         return 0;
1135 }
1136
1137
1138 int netxen_is_flash_supported(struct netxen_adapter *adapter);
1139 int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, __le64 mac[]);
1140 extern void netxen_change_ringparam(struct netxen_adapter *adapter);
1141 extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr,
1142                                 int *valp);
1143
1144 extern struct ethtool_ops netxen_nic_ethtool_ops;
1145
1146 #endif                          /* __NETXEN_NIC_H_ */