Add NetXen 1G/10G ethernet driver.
[linux-2.6-block.git] / drivers / net / netxen / netxen_nic_phan_reg.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 __NIC_PHAN_REG_H_
31 #define __NIC_PHAN_REG_H_
32
33 /* 
34  * CRB Registers or queue message done only at initialization time.
35  */
36
37 /*
38  * The following 2 are the base adresses for the CRB registers and their
39  * offsets will be added to get addresses for the index addresses.
40  */
41 #define NIC_CRB_BASE_PORT1      NETXEN_CAM_RAM(0x200)
42 #define NIC_CRB_BASE_PORT2      NETXEN_CAM_RAM(0x250)
43
44 #define NETXEN_NIC_REG(X)       (NIC_CRB_BASE_PORT1+(X))
45
46 /*
47  * CrbPortPhanCntrHi/Lo is used to pass the address of HostPhantomIndex address
48  * which can be read by the Phantom host to get producer/consumer indexes from
49  * Phantom/Casper. If it is not HOST_SHARED_MEMORY, then the following
50  * registers will be used for the addresses of the ring's shared memory
51  * on the Phantom.
52  */
53
54 #define CRB_PHAN_CNTRL_LO_OFFSET        NETXEN_NIC_REG(0x00)
55 #define CRB_PHAN_CNTRL_HI_OFFSET        NETXEN_NIC_REG(0x04)
56
57 /* point to the indexes */
58 #define CRB_CMD_PRODUCER_OFFSET         NETXEN_NIC_REG(0x08)
59 #define CRB_CMD_CONSUMER_OFFSET         NETXEN_NIC_REG(0x0c)
60
61 /* address of command descriptors in the host memory */
62 #define CRB_HOST_CMD_ADDR_HI            NETXEN_NIC_REG(0x30)
63 #define CRB_HOST_CMD_ADDR_LO            NETXEN_NIC_REG(0x34)
64
65 /* The following 4 CRB registers are for doing performance coal */
66 #define CRB_CMD_INTR_LOOP               NETXEN_NIC_REG(0x38)
67 #define CRB_CMD_DMA_LOOP                NETXEN_NIC_REG(0x3c)
68 #define CRB_RCV_INTR_LOOP               NETXEN_NIC_REG(0x40)
69 #define CRB_RCV_DMA_LOOP                NETXEN_NIC_REG(0x44)
70
71 /* Needed by the host to find out the state of Phantom's initialization */
72 #define CRB_ENABLE_TX_INTR              NETXEN_NIC_REG(0x4c)
73 #define CRB_CMDPEG_STATE                NETXEN_NIC_REG(0x50)
74 #define CRB_CMDPEG_CMDRING              NETXEN_NIC_REG(0x54)
75
76 /* Interrupt coalescing parameters */
77 #define CRB_GLOBAL_INT_COAL             NETXEN_NIC_REG(0x80)
78 #define CRB_INT_COAL_MODE               NETXEN_NIC_REG(0x84)
79 #define CRB_MAX_RCV_BUFS                NETXEN_NIC_REG(0x88)
80 #define CRB_TX_INT_THRESHOLD            NETXEN_NIC_REG(0x8c)
81 #define CRB_RX_PKT_TIMER                NETXEN_NIC_REG(0x90)
82 #define CRB_TX_PKT_TIMER                NETXEN_NIC_REG(0x94)
83 #define CRB_RX_PKT_CNT                  NETXEN_NIC_REG(0x98)
84 #define CRB_RX_TMR_CNT                  NETXEN_NIC_REG(0x9c)
85
86 /* Register for communicating XG link status */
87 #define CRB_XG_STATE                    NETXEN_NIC_REG(0xa0)
88
89 /* Debug registers for controlling NIC pkt gen agent */
90 #define CRB_AGENT_GO                    NETXEN_NIC_REG(0xb0)
91 #define CRB_AGENT_TX_SIZE               NETXEN_NIC_REG(0xb4)
92 #define CRB_AGENT_TX_TYPE               NETXEN_NIC_REG(0xb8)
93 #define CRB_AGENT_TX_ADDR               NETXEN_NIC_REG(0xbc)
94 #define CRB_AGENT_TX_MSS                NETXEN_NIC_REG(0xc0)
95
96 /* Debug registers for observing NIC performance */
97 #define CRB_TX_STATE                    NETXEN_NIC_REG(0xd0)
98 #define CRB_TX_COUNT                    NETXEN_NIC_REG(0xd4)
99 #define CRB_RX_STATE                    NETXEN_NIC_REG(0xd8)
100
101 /* CRB registers per Rcv Descriptor ring */
102 struct netxen_rcv_desc_crb {
103         u32 crb_rcv_producer_offset __attribute__ ((aligned(512)));
104         u32 crb_rcv_consumer_offset;
105         u32 crb_globalrcv_ring;
106 };
107
108 /*
109  * CRB registers used by the receive peg logic. One instance of these
110  * needs to be instantiated per instance of the receive peg.
111  */
112
113 struct netxen_recv_crb {
114         struct netxen_rcv_desc_crb rcv_desc_crb[NUM_RCV_DESC_RINGS];
115         u32 crb_rcvstatus_ring;
116         u32 crb_rcv_status_producer;
117         u32 crb_rcv_status_consumer;
118         u32 crb_rcvpeg_state;
119 };
120
121 #if defined(DEFINE_GLOBAL_RECV_CRB)
122 struct netxen_recv_crb recv_crb_registers[] = {
123         /*
124          * Instance 0.
125          */
126         {
127          /* rcv_desc_crb: */
128          {
129           {
130            /* crb_rcv_producer_offset: */
131            NETXEN_NIC_REG(0x18),
132            /* crb_rcv_consumer_offset: */
133            NETXEN_NIC_REG(0x1c),
134            /* crb_gloablrcv_ring: */
135            NETXEN_NIC_REG(0x20),
136            },
137           /* Jumbo frames */
138           {
139            /* crb_rcv_producer_offset: */
140            NETXEN_NIC_REG(0x100),
141            /* crb_rcv_consumer_offset: */
142            NETXEN_NIC_REG(0x104),
143            /* crb_gloablrcv_ring: */
144            NETXEN_NIC_REG(0x108),
145            }
146           },
147          /* crb_rcvstatus_ring: */
148          NETXEN_NIC_REG(0x24),
149          /* crb_rcv_status_producer: */
150          NETXEN_NIC_REG(0x28),
151          /* crb_rcv_status_consumer: */
152          NETXEN_NIC_REG(0x2c),
153          /* crb_rcvpeg_state: */
154          NETXEN_NIC_REG(0x48),
155
156          },
157         /*
158          * Instance 1,
159          */
160         {
161          /* rcv_desc_crb: */
162          {
163           {
164            /* crb_rcv_producer_offset: */
165            NETXEN_NIC_REG(0x80),
166            /* crb_rcv_consumer_offset: */
167            NETXEN_NIC_REG(0x84),
168            /* crb_globalrcv_ring: */
169            NETXEN_NIC_REG(0x88),
170            },
171           /* Jumbo frames */
172           {
173            /* crb_rcv_producer_offset: */
174            NETXEN_NIC_REG(0x10C),
175            /* crb_rcv_consumer_offset: */
176            NETXEN_NIC_REG(0x110),
177            /* crb_globalrcv_ring: */
178            NETXEN_NIC_REG(0x114),
179            }
180           },
181          /* crb_rcvstatus_ring: */
182          NETXEN_NIC_REG(0x8c),
183          /* crb_rcv_status_producer: */
184          NETXEN_NIC_REG(0x90),
185          /* crb_rcv_status_consumer: */
186          NETXEN_NIC_REG(0x94),
187          /* crb_rcvpeg_state: */
188          NETXEN_NIC_REG(0x98),
189          },
190 };
191 #else
192 extern struct netxen_recv_crb recv_crb_registers[];
193 #endif                          /* DEFINE_GLOBAL_RECEIVE_CRB */
194
195 #endif                          /* __NIC_PHAN_REG_H_ */