blob: 98e4b95788b7a075d80e3247952e05515432dcc6 [file] [log] [blame]
Amit S. Kale3d396eb2006-10-21 15:33:03 -04001/*
Dhananjay Phadke5d242f12009-02-25 15:57:56 +00002 * Copyright (C) 2003 - 2009 NetXen, Inc.
Amit S. Kale3d396eb2006-10-21 15:33:03 -04003 * All rights reserved.
Amit S. Kale80922fb2006-12-04 09:18:00 -08004 *
Amit S. Kale3d396eb2006-10-21 15:33:03 -04005 * 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.
Mithlesh Thukral3176ff32007-04-20 07:52:37 -07009 *
Amit S. Kale3d396eb2006-10-21 15:33:03 -040010 * 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.
Mithlesh Thukral3176ff32007-04-20 07:52:37 -070014 *
Amit S. Kale3d396eb2006-10-21 15:33:03 -040015 * 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.
Amit S. Kale80922fb2006-12-04 09:18:00 -080019 *
Amit S. Kale3d396eb2006-10-21 15:33:03 -040020 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
Amit S. Kale80922fb2006-12-04 09:18:00 -080022 *
Amit S. Kale3d396eb2006-10-21 15:33:03 -040023 * Contact Information:
24 * info@netxen.com
Dhananjay Phadke5d242f12009-02-25 15:57:56 +000025 * NetXen Inc,
26 * 18922 Forge Drive
27 * Cupertino, CA 95014-0701
Amit S. Kale3d396eb2006-10-21 15:33:03 -040028 *
29 */
30
31#ifndef __NETXEN_NIC_HW_H_
32#define __NETXEN_NIC_HW_H_
33
Amit S. Kale3d396eb2006-10-21 15:33:03 -040034/* Hardware memory size of 128 meg */
35#define NETXEN_MEMADDR_MAX (128 * 1024 * 1024)
36
Amit S. Kale3d396eb2006-10-21 15:33:03 -040037struct netxen_adapter;
38
39#define NETXEN_PCI_MAPSIZE_BYTES (NETXEN_PCI_MAPSIZE << 20)
40
Mithlesh Thukral3176ff32007-04-20 07:52:37 -070041void netxen_nic_set_link_parameters(struct netxen_adapter *adapter);
Amit S. Kale3d396eb2006-10-21 15:33:03 -040042
Amit S. Kale3d396eb2006-10-21 15:33:03 -040043/* Nibble or Byte mode for phy interface (GbE mode only) */
Amit S. Kale3d396eb2006-10-21 15:33:03 -040044
45#define _netxen_crb_get_bit(var, bit) ((var >> bit) & 0x1)
46
47/*
48 * NIU GB MAC Config Register 0 (applies to GB0, GB1, GB2, GB3)
49 *
50 * Bit 0 : enable_tx => 1:enable frame xmit, 0:disable
51 * Bit 1 : tx_synced => R/O: xmit enable synched to xmit stream
52 * Bit 2 : enable_rx => 1:enable frame recv, 0:disable
53 * Bit 3 : rx_synced => R/O: recv enable synched to recv stream
54 * Bit 4 : tx_flowctl => 1:enable pause frame generation, 0:disable
55 * Bit 5 : rx_flowctl => 1:act on recv'd pause frames, 0:ignore
56 * Bit 8 : loopback => 1:loop MAC xmits to MAC recvs, 0:normal
57 * Bit 16: tx_reset_pb => 1:reset frame xmit protocol blk, 0:no-op
58 * Bit 17: rx_reset_pb => 1:reset frame recv protocol blk, 0:no-op
59 * Bit 18: tx_reset_mac => 1:reset data/ctl multiplexer blk, 0:no-op
60 * Bit 19: rx_reset_mac => 1:reset ctl frames & timers blk, 0:no-op
61 * Bit 31: soft_reset => 1:reset the MAC and the SERDES, 0:no-op
62 */
63
Amit S. Kale3d396eb2006-10-21 15:33:03 -040064#define netxen_gb_tx_flowctl(config_word) \
Al Viroa608ab92007-01-02 10:39:10 +000065 ((config_word) |= 1 << 4)
Amit S. Kale3d396eb2006-10-21 15:33:03 -040066#define netxen_gb_rx_flowctl(config_word) \
Al Viroa608ab92007-01-02 10:39:10 +000067 ((config_word) |= 1 << 5)
Amit S. Kale3d396eb2006-10-21 15:33:03 -040068#define netxen_gb_tx_reset_pb(config_word) \
Al Viroa608ab92007-01-02 10:39:10 +000069 ((config_word) |= 1 << 16)
Amit S. Kale3d396eb2006-10-21 15:33:03 -040070#define netxen_gb_rx_reset_pb(config_word) \
Al Viroa608ab92007-01-02 10:39:10 +000071 ((config_word) |= 1 << 17)
Amit S. Kale3d396eb2006-10-21 15:33:03 -040072#define netxen_gb_tx_reset_mac(config_word) \
Al Viroa608ab92007-01-02 10:39:10 +000073 ((config_word) |= 1 << 18)
Amit S. Kale3d396eb2006-10-21 15:33:03 -040074#define netxen_gb_rx_reset_mac(config_word) \
Al Viroa608ab92007-01-02 10:39:10 +000075 ((config_word) |= 1 << 19)
Amit S. Kale3d396eb2006-10-21 15:33:03 -040076
77#define netxen_gb_unset_tx_flowctl(config_word) \
Al Viroa608ab92007-01-02 10:39:10 +000078 ((config_word) &= ~(1 << 4))
Amit S. Kale3d396eb2006-10-21 15:33:03 -040079#define netxen_gb_unset_rx_flowctl(config_word) \
Al Viroa608ab92007-01-02 10:39:10 +000080 ((config_word) &= ~(1 << 5))
Amit S. Kale3d396eb2006-10-21 15:33:03 -040081
82#define netxen_gb_get_tx_synced(config_word) \
83 _netxen_crb_get_bit((config_word), 1)
84#define netxen_gb_get_rx_synced(config_word) \
85 _netxen_crb_get_bit((config_word), 3)
86#define netxen_gb_get_tx_flowctl(config_word) \
87 _netxen_crb_get_bit((config_word), 4)
88#define netxen_gb_get_rx_flowctl(config_word) \
89 _netxen_crb_get_bit((config_word), 5)
90#define netxen_gb_get_soft_reset(config_word) \
91 _netxen_crb_get_bit((config_word), 31)
92
Amit S. Kale3d396eb2006-10-21 15:33:03 -040093#define netxen_gb_get_stationaddress_low(config_word) ((config_word) >> 16)
94
95#define netxen_gb_set_mii_mgmt_clockselect(config_word, val) \
96 ((config_word) |= ((val) & 0x07))
97#define netxen_gb_mii_mgmt_reset(config_word) \
Al Viroa608ab92007-01-02 10:39:10 +000098 ((config_word) |= 1 << 31)
Amit S. Kale3d396eb2006-10-21 15:33:03 -040099#define netxen_gb_mii_mgmt_unset(config_word) \
Al Viroa608ab92007-01-02 10:39:10 +0000100 ((config_word) &= ~(1 << 31))
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400101
102/*
103 * NIU GB MII Mgmt Command Register (applies to GB0, GB1, GB2, GB3)
104 * Bit 0 : read_cycle => 1:perform single read cycle, 0:no-op
105 * Bit 1 : scan_cycle => 1:perform continuous read cycles, 0:no-op
106 */
107
108#define netxen_gb_mii_mgmt_set_read_cycle(config_word) \
Al Viroa608ab92007-01-02 10:39:10 +0000109 ((config_word) |= 1 << 0)
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400110#define netxen_gb_mii_mgmt_reg_addr(config_word, val) \
111 ((config_word) |= ((val) & 0x1F))
112#define netxen_gb_mii_mgmt_phy_addr(config_word, val) \
113 ((config_word) |= (((val) & 0x1F) << 8))
114
115/*
116 * NIU GB MII Mgmt Indicators Register (applies to GB0, GB1, GB2, GB3)
117 * Read-only register.
118 * Bit 0 : busy => 1:performing an MII mgmt cycle, 0:idle
119 * Bit 1 : scanning => 1:scan operation in progress, 0:idle
120 * Bit 2 : notvalid => :mgmt result data not yet valid, 0:idle
121 */
122#define netxen_get_gb_mii_mgmt_busy(config_word) \
123 _netxen_crb_get_bit(config_word, 0)
124#define netxen_get_gb_mii_mgmt_scanning(config_word) \
125 _netxen_crb_get_bit(config_word, 1)
126#define netxen_get_gb_mii_mgmt_notvalid(config_word) \
127 _netxen_crb_get_bit(config_word, 2)
Mithlesh Thukral6c80b182007-04-20 07:55:26 -0700128/*
129 * NIU XG Pause Ctl Register
130 *
131 * Bit 0 : xg0_mask => 1:disable tx pause frames
132 * Bit 1 : xg0_request => 1:request single pause frame
133 * Bit 2 : xg0_on_off => 1:request is pause on, 0:off
134 * Bit 3 : xg1_mask => 1:disable tx pause frames
135 * Bit 4 : xg1_request => 1:request single pause frame
136 * Bit 5 : xg1_on_off => 1:request is pause on, 0:off
137 */
138
139#define netxen_xg_set_xg0_mask(config_word) \
140 ((config_word) |= 1 << 0)
141#define netxen_xg_set_xg1_mask(config_word) \
142 ((config_word) |= 1 << 3)
Jeff Garzik47906542007-11-23 21:23:36 -0500143
Mithlesh Thukral6c80b182007-04-20 07:55:26 -0700144#define netxen_xg_get_xg0_mask(config_word) \
145 _netxen_crb_get_bit((config_word), 0)
146#define netxen_xg_get_xg1_mask(config_word) \
147 _netxen_crb_get_bit((config_word), 3)
148
149#define netxen_xg_unset_xg0_mask(config_word) \
150 ((config_word) &= ~(1 << 0))
151#define netxen_xg_unset_xg1_mask(config_word) \
152 ((config_word) &= ~(1 << 3))
153
154/*
155 * NIU XG Pause Ctl Register
156 *
157 * Bit 0 : xg0_mask => 1:disable tx pause frames
158 * Bit 1 : xg0_request => 1:request single pause frame
159 * Bit 2 : xg0_on_off => 1:request is pause on, 0:off
160 * Bit 3 : xg1_mask => 1:disable tx pause frames
161 * Bit 4 : xg1_request => 1:request single pause frame
162 * Bit 5 : xg1_on_off => 1:request is pause on, 0:off
163 */
164#define netxen_gb_set_gb0_mask(config_word) \
165 ((config_word) |= 1 << 0)
166#define netxen_gb_set_gb1_mask(config_word) \
167 ((config_word) |= 1 << 2)
168#define netxen_gb_set_gb2_mask(config_word) \
169 ((config_word) |= 1 << 4)
170#define netxen_gb_set_gb3_mask(config_word) \
171 ((config_word) |= 1 << 6)
172
173#define netxen_gb_get_gb0_mask(config_word) \
174 _netxen_crb_get_bit((config_word), 0)
175#define netxen_gb_get_gb1_mask(config_word) \
176 _netxen_crb_get_bit((config_word), 2)
177#define netxen_gb_get_gb2_mask(config_word) \
178 _netxen_crb_get_bit((config_word), 4)
179#define netxen_gb_get_gb3_mask(config_word) \
180 _netxen_crb_get_bit((config_word), 6)
Jeff Garzik47906542007-11-23 21:23:36 -0500181
Mithlesh Thukral6c80b182007-04-20 07:55:26 -0700182#define netxen_gb_unset_gb0_mask(config_word) \
183 ((config_word) &= ~(1 << 0))
184#define netxen_gb_unset_gb1_mask(config_word) \
185 ((config_word) &= ~(1 << 2))
186#define netxen_gb_unset_gb2_mask(config_word) \
187 ((config_word) &= ~(1 << 4))
188#define netxen_gb_unset_gb3_mask(config_word) \
189 ((config_word) &= ~(1 << 6))
190
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400191
192/*
193 * PHY-Specific MII control/status registers.
194 */
Dhananjay Phadkee98e3352009-04-07 22:50:38 +0000195#define NETXEN_NIU_GB_MII_MGMT_ADDR_CONTROL 0
196#define NETXEN_NIU_GB_MII_MGMT_ADDR_STATUS 1
197#define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_0 2
198#define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_1 3
199#define NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG 4
200#define NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART 5
201#define NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG_MORE 6
202#define NETXEN_NIU_GB_MII_MGMT_ADDR_NEXTPAGE_XMIT 7
203#define NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART_NEXTPAGE 8
204#define NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_CONTROL 9
205#define NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_STATUS 10
206#define NETXEN_NIU_GB_MII_MGMT_ADDR_EXTENDED_STATUS 15
207#define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL 16
208#define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS 17
209#define NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE 18
210#define NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS 19
211#define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE 20
212#define NETXEN_NIU_GB_MII_MGMT_ADDR_RECV_ERROR_COUNT 21
213#define NETXEN_NIU_GB_MII_MGMT_ADDR_LED_CONTROL 24
214#define NETXEN_NIU_GB_MII_MGMT_ADDR_LED_OVERRIDE 25
215#define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE_YET 26
216#define NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS_MORE 27
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400217
218/*
219 * PHY-Specific Status Register (reg 17).
220 *
221 * Bit 0 : jabber => 1:jabber detected, 0:not
222 * Bit 1 : polarity => 1:polarity reversed, 0:normal
223 * Bit 2 : recvpause => 1:receive pause enabled, 0:disabled
224 * Bit 3 : xmitpause => 1:transmit pause enabled, 0:disabled
225 * Bit 4 : energydetect => 1:sleep, 0:active
226 * Bit 5 : downshift => 1:downshift, 0:no downshift
227 * Bit 6 : crossover => 1:MDIX (crossover), 0:MDI (no crossover)
228 * Bits 7-9 : cablelen => not valid in 10Mb/s mode
229 * 0:<50m, 1:50-80m, 2:80-110m, 3:110-140m, 4:>140m
230 * Bit 10 : link => 1:link up, 0:link down
231 * Bit 11 : resolved => 1:speed and duplex resolved, 0:not yet
232 * Bit 12 : pagercvd => 1:page received, 0:page not received
233 * Bit 13 : duplex => 1:full duplex, 0:half duplex
234 * Bits 14-15 : speed => 0:10Mb/s, 1:100Mb/s, 2:1000Mb/s, 3:rsvd
235 */
236
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400237#define netxen_get_phy_speed(config_word) (((config_word) >> 14) & 0x03)
238
239#define netxen_set_phy_speed(config_word, val) \
240 ((config_word) |= ((val & 0x03) << 14))
241#define netxen_set_phy_duplex(config_word) \
Al Viroa608ab92007-01-02 10:39:10 +0000242 ((config_word) |= 1 << 13)
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400243#define netxen_clear_phy_duplex(config_word) \
Al Viroa608ab92007-01-02 10:39:10 +0000244 ((config_word) &= ~(1 << 13))
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400245
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400246#define netxen_get_phy_link(config_word) \
247 _netxen_crb_get_bit(config_word, 10)
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400248#define netxen_get_phy_duplex(config_word) \
249 _netxen_crb_get_bit(config_word, 13)
250
251/*
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400252 * NIU Mode Register.
253 * Bit 0 : enable FibreChannel
254 * Bit 1 : enable 10/100/1000 Ethernet
255 * Bit 2 : enable 10Gb Ethernet
256 */
257
258#define netxen_get_niu_enable_ge(config_word) \
259 _netxen_crb_get_bit(config_word, 1)
260
Dhananjay Phadke9ad27642008-08-01 03:14:59 -0700261#define NETXEN_NIU_NON_PROMISC_MODE 0
262#define NETXEN_NIU_PROMISC_MODE 1
263#define NETXEN_NIU_ALLMULTI_MODE 2
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400264
265/*
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400266 * NIU XG MAC Config Register
267 *
268 * Bit 0 : tx_enable => 1:enable frame xmit, 0:disable
269 * Bit 2 : rx_enable => 1:enable frame recv, 0:disable
270 * Bit 4 : soft_reset => 1:reset the MAC , 0:no-op
271 * Bit 27: xaui_framer_reset
272 * Bit 28: xaui_rx_reset
273 * Bit 29: xaui_tx_reset
274 * Bit 30: xg_ingress_afifo_reset
275 * Bit 31: xg_egress_afifo_reset
276 */
277
278#define netxen_xg_soft_reset(config_word) \
Al Viroa608ab92007-01-02 10:39:10 +0000279 ((config_word) |= 1 << 4)
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400280
Dhananjay Phadke3ce06a32008-07-21 19:44:03 -0700281typedef struct {
282 unsigned valid;
283 unsigned start_128M;
284 unsigned end_128M;
285 unsigned start_2M;
286} crb_128M_2M_sub_block_map_t;
287
288typedef struct {
289 crb_128M_2M_sub_block_map_t sub_block[16];
290} crb_128M_2M_block_map_t;
291
Amit S. Kale3d396eb2006-10-21 15:33:03 -0400292#endif /* __NETXEN_NIC_HW_H_ */