if_alcreg.h revision 1.1 1 1.1 jmcneill /* $OpenBSD: if_alcreg.h,v 1.1 2009/08/08 09:31:13 kevlo Exp $ */
2 1.1 jmcneill /*-
3 1.1 jmcneill * Copyright (c) 2009, Pyun YongHyeon <yongari (at) FreeBSD.org>
4 1.1 jmcneill * All rights reserved.
5 1.1 jmcneill *
6 1.1 jmcneill * Redistribution and use in source and binary forms, with or without
7 1.1 jmcneill * modification, are permitted provided that the following conditions
8 1.1 jmcneill * are met:
9 1.1 jmcneill * 1. Redistributions of source code must retain the above copyright
10 1.1 jmcneill * notice unmodified, this list of conditions, and the following
11 1.1 jmcneill * disclaimer.
12 1.1 jmcneill * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 jmcneill * notice, this list of conditions and the following disclaimer in the
14 1.1 jmcneill * documentation and/or other materials provided with the distribution.
15 1.1 jmcneill *
16 1.1 jmcneill * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 1.1 jmcneill * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 1.1 jmcneill * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 1.1 jmcneill * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 1.1 jmcneill * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.1 jmcneill * DAMATES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 1.1 jmcneill * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.1 jmcneill * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 1.1 jmcneill * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1 jmcneill * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1 jmcneill * SUCH DAMATE.
27 1.1 jmcneill *
28 1.1 jmcneill * $FreeBSD: src/sys/dev/alc/if_alcreg.h,v 1.1 2009/06/10 02:07:58 yongari Exp $
29 1.1 jmcneill */
30 1.1 jmcneill
31 1.1 jmcneill #ifndef _IF_ALCREG_H
32 1.1 jmcneill #define _IF_ALCREG_H
33 1.1 jmcneill
34 1.1 jmcneill #define ALC_PCIR_BAR 0x10
35 1.1 jmcneill
36 1.1 jmcneill /* 0x0000 - 0x02FF : PCIe configuration space */
37 1.1 jmcneill
38 1.1 jmcneill #define ALC_PEX_UNC_ERR_SEV 0x10C
39 1.1 jmcneill #define PEX_UNC_ERR_SEV_TRN 0x00000001
40 1.1 jmcneill #define PEX_UNC_ERR_SEV_DLP 0x00000010
41 1.1 jmcneill #define PEX_UNC_ERR_SEV_PSN_TLP 0x00001000
42 1.1 jmcneill #define PEX_UNC_ERR_SEV_FCP 0x00002000
43 1.1 jmcneill #define PEX_UNC_ERR_SEV_CPL_TO 0x00004000
44 1.1 jmcneill #define PEX_UNC_ERR_SEV_CA 0x00008000
45 1.1 jmcneill #define PEX_UNC_ERR_SEV_UC 0x00010000
46 1.1 jmcneill #define PEX_UNC_ERR_SEV_ROV 0x00020000
47 1.1 jmcneill #define PEX_UNC_ERR_SEV_MLFP 0x00040000
48 1.1 jmcneill #define PEX_UNC_ERR_SEV_ECRC 0x00080000
49 1.1 jmcneill #define PEX_UNC_ERR_SEV_UR 0x00100000
50 1.1 jmcneill
51 1.1 jmcneill #define ALC_TWSI_CFG 0x218
52 1.1 jmcneill #define TWSI_CFG_SW_LD_START 0x00000800
53 1.1 jmcneill #define TWSI_CFG_HW_LD_START 0x00001000
54 1.1 jmcneill #define TWSI_CFG_LD_EXIST 0x00400000
55 1.1 jmcneill
56 1.1 jmcneill #define ALC_PCIE_PHYMISC 0x1000
57 1.1 jmcneill #define PCIE_PHYMISC_FORCE_RCV_DET 0x00000004
58 1.1 jmcneill
59 1.1 jmcneill #define ALC_TWSI_DEBUG 0x1108
60 1.1 jmcneill #define TWSI_DEBUG_DEV_EXIST 0x20000000
61 1.1 jmcneill
62 1.1 jmcneill #define ALC_EEPROM_CFG 0x12C0
63 1.1 jmcneill #define EEPROM_CFG_DATA_HI_MASK 0x0000FFFF
64 1.1 jmcneill #define EEPROM_CFG_ADDR_MASK 0x03FF0000
65 1.1 jmcneill #define EEPROM_CFG_ACK 0x40000000
66 1.1 jmcneill #define EEPROM_CFG_RW 0x80000000
67 1.1 jmcneill #define EEPROM_CFG_DATA_HI_SHIFT 0
68 1.1 jmcneill #define EEPROM_CFG_ADDR_SHIFT 16
69 1.1 jmcneill
70 1.1 jmcneill #define ALC_EEPROM_DATA_LO 0x12C4
71 1.1 jmcneill
72 1.1 jmcneill #define ALC_OPT_CFG 0x12F0
73 1.1 jmcneill #define OPT_CFG_CLK_ENB 0x00000002
74 1.1 jmcneill
75 1.1 jmcneill #define ALC_PM_CFG 0x12F8
76 1.1 jmcneill #define PM_CFG_SERDES_ENB 0x00000001
77 1.1 jmcneill #define PM_CFG_RBER_ENB 0x00000002
78 1.1 jmcneill #define PM_CFG_CLK_REQ_ENB 0x00000004
79 1.1 jmcneill #define PM_CFG_ASPM_L1_ENB 0x00000008
80 1.1 jmcneill #define PM_CFG_SERDES_L1_ENB 0x00000010
81 1.1 jmcneill #define PM_CFG_SERDES_PLL_L1_ENB 0x00000020
82 1.1 jmcneill #define PM_CFG_SERDES_PD_EX_L1 0x00000040
83 1.1 jmcneill #define PM_CFG_SERDES_BUDS_RX_L1_ENB 0x00000080
84 1.1 jmcneill #define PM_CFG_L0S_ENTRY_TIMER_MASK 0x00000F00
85 1.1 jmcneill #define PM_CFG_ASPM_L0S_ENB 0x00001000
86 1.1 jmcneill #define PM_CFG_CLK_SWH_L1 0x00002000
87 1.1 jmcneill #define PM_CFG_CLK_PWM_VER1_1 0x00004000
88 1.1 jmcneill #define PM_CFG_PCIE_RECV 0x00008000
89 1.1 jmcneill #define PM_CFG_L1_ENTRY_TIMER_MASK 0x000F0000
90 1.1 jmcneill #define PM_CFG_PM_REQ_TIMER_MASK 0x00F00000
91 1.1 jmcneill #define PM_CFG_LCKDET_TIMER_MASK 0x3F000000
92 1.1 jmcneill #define PM_CFG_MAC_ASPM_CHK 0x40000000
93 1.1 jmcneill #define PM_CFG_HOTRST 0x80000000
94 1.1 jmcneill #define PM_CFG_L0S_ENTRY_TIMER_SHIFT 8
95 1.1 jmcneill #define PM_CFG_L1_ENTRY_TIMER_SHIFT 16
96 1.1 jmcneill #define PM_CFG_PM_REQ_TIMER_SHIFT 20
97 1.1 jmcneill #define PM_CFG_LCKDET_TIMER_SHIFT 24
98 1.1 jmcneill
99 1.1 jmcneill #define ALC_MASTER_CFG 0x1400
100 1.1 jmcneill #define MASTER_RESET 0x00000001
101 1.1 jmcneill #define MASTER_BERT_START 0x00000010
102 1.1 jmcneill #define MASTER_TEST_MODE_MASK 0x000000C0
103 1.1 jmcneill #define MASTER_MTIMER_ENB 0x00000100
104 1.1 jmcneill #define MASTER_MANUAL_INTR_ENB 0x00000200
105 1.1 jmcneill #define MASTER_IM_TX_TIMER_ENB 0x00000400
106 1.1 jmcneill #define MASTER_IM_RX_TIMER_ENB 0x00000800
107 1.1 jmcneill #define MASTER_CLK_SEL_DIS 0x00001000
108 1.1 jmcneill #define MASTER_CLK_SWH_MODE 0x00002000
109 1.1 jmcneill #define MASTER_INTR_RD_CLR 0x00004000
110 1.1 jmcneill #define MASTER_CHIP_REV_MASK 0x00FF0000
111 1.1 jmcneill #define MASTER_CHIP_ID_MASK 0x7F000000
112 1.1 jmcneill #define MASTER_OTP_SEL 0x80000000
113 1.1 jmcneill #define MASTER_TEST_MODE_SHIFT 2
114 1.1 jmcneill #define MASTER_CHIP_REV_SHIFT 16
115 1.1 jmcneill #define MASTER_CHIP_ID_SHIFT 24
116 1.1 jmcneill
117 1.1 jmcneill /* Number of ticks per usec for AR8131/AR8132. */
118 1.1 jmcneill #define ALC_TICK_USECS 2
119 1.1 jmcneill #define ALC_USECS(x) ((x) / ALC_TICK_USECS)
120 1.1 jmcneill
121 1.1 jmcneill #define ALC_MANUAL_TIMER 0x1404
122 1.1 jmcneill
123 1.1 jmcneill #define ALC_IM_TIMER 0x1408
124 1.1 jmcneill #define IM_TIMER_TX_MASK 0x0000FFFF
125 1.1 jmcneill #define IM_TIMER_RX_MASK 0xFFFF0000
126 1.1 jmcneill #define IM_TIMER_TX_SHIFT 0
127 1.1 jmcneill #define IM_TIMER_RX_SHIFT 16
128 1.1 jmcneill #define ALC_IM_TIMER_MIN 0
129 1.1 jmcneill #define ALC_IM_TIMER_MAX 130000 /* 130ms */
130 1.1 jmcneill /*
131 1.1 jmcneill * 100us will ensure alc(4) wouldn't generate more than 10000 Rx
132 1.1 jmcneill * interrupts in a second.
133 1.1 jmcneill */
134 1.1 jmcneill #define ALC_IM_RX_TIMER_DEFAULT 100 /* 100us */
135 1.1 jmcneill /*
136 1.1 jmcneill * alc(4) does not rely on Tx completion interrupts, so set it
137 1.1 jmcneill * somewhat large value to reduce Tx completion interrupts.
138 1.1 jmcneill */
139 1.1 jmcneill #define ALC_IM_TX_TIMER_DEFAULT 50000 /* 50ms */
140 1.1 jmcneill
141 1.1 jmcneill #define ALC_GPHY_CFG 0x140C /* 16bits */
142 1.1 jmcneill #define GPHY_CFG_EXT_RESET 0x0001
143 1.1 jmcneill #define GPHY_CFG_RTL_MODE 0x0002
144 1.1 jmcneill #define GPHY_CFG_LED_MODE 0x0004
145 1.1 jmcneill #define GPHY_CFG_ANEG_NOW 0x0008
146 1.1 jmcneill #define GPHY_CFG_RECV_ANEG 0x0010
147 1.1 jmcneill #define GPHY_CFG_GATE_25M_ENB 0x0020
148 1.1 jmcneill #define GPHY_CFG_LPW_EXIT 0x0040
149 1.1 jmcneill #define GPHY_CFG_PHY_IDDQ 0x0080
150 1.1 jmcneill #define GPHY_CFG_PHY_IDDQ_DIS 0x0100
151 1.1 jmcneill #define GPHY_CFG_PCLK_SEL_DIS 0x0200
152 1.1 jmcneill #define GPHY_CFG_HIB_EN 0x0400
153 1.1 jmcneill #define GPHY_CFG_HIB_PULSE 0x0800
154 1.1 jmcneill #define GPHY_CFG_SEL_ANA_RESET 0x1000
155 1.1 jmcneill #define GPHY_CFG_PHY_PLL_ON 0x2000
156 1.1 jmcneill #define GPHY_CFG_PWDOWN_HW 0x4000
157 1.1 jmcneill #define GPHY_CFG_PHY_PLL_BYPASS 0x8000
158 1.1 jmcneill
159 1.1 jmcneill #define ALC_IDLE_STATUS 0x1410
160 1.1 jmcneill #define IDLE_STATUS_RXMAC 0x00000001
161 1.1 jmcneill #define IDLE_STATUS_TXMAC 0x00000002
162 1.1 jmcneill #define IDLE_STATUS_RXQ 0x00000004
163 1.1 jmcneill #define IDLE_STATUS_TXQ 0x00000008
164 1.1 jmcneill #define IDLE_STATUS_DMARD 0x00000010
165 1.1 jmcneill #define IDLE_STATUS_DMAWR 0x00000020
166 1.1 jmcneill #define IDLE_STATUS_SMB 0x00000040
167 1.1 jmcneill #define IDLE_STATUS_CMB 0x00000080
168 1.1 jmcneill
169 1.1 jmcneill #define ALC_MDIO 0x1414
170 1.1 jmcneill #define MDIO_DATA_MASK 0x0000FFFF
171 1.1 jmcneill #define MDIO_REG_ADDR_MASK 0x001F0000
172 1.1 jmcneill #define MDIO_OP_READ 0x00200000
173 1.1 jmcneill #define MDIO_OP_WRITE 0x00000000
174 1.1 jmcneill #define MDIO_SUP_PREAMBLE 0x00400000
175 1.1 jmcneill #define MDIO_OP_EXECUTE 0x00800000
176 1.1 jmcneill #define MDIO_CLK_25_4 0x00000000
177 1.1 jmcneill #define MDIO_CLK_25_6 0x02000000
178 1.1 jmcneill #define MDIO_CLK_25_8 0x03000000
179 1.1 jmcneill #define MDIO_CLK_25_10 0x04000000
180 1.1 jmcneill #define MDIO_CLK_25_14 0x05000000
181 1.1 jmcneill #define MDIO_CLK_25_20 0x06000000
182 1.1 jmcneill #define MDIO_CLK_25_28 0x07000000
183 1.1 jmcneill #define MDIO_OP_BUSY 0x08000000
184 1.1 jmcneill #define MDIO_AP_ENB 0x10000000
185 1.1 jmcneill #define MDIO_DATA_SHIFT 0
186 1.1 jmcneill #define MDIO_REG_ADDR_SHIFT 16
187 1.1 jmcneill
188 1.1 jmcneill #define MDIO_REG_ADDR(x) \
189 1.1 jmcneill (((x) << MDIO_REG_ADDR_SHIFT) & MDIO_REG_ADDR_MASK)
190 1.1 jmcneill /* Default PHY address. */
191 1.1 jmcneill #define ALC_PHY_ADDR 0
192 1.1 jmcneill
193 1.1 jmcneill #define ALC_PHY_STATUS 0x1418
194 1.1 jmcneill #define PHY_STATUS_RECV_ENB 0x00000001
195 1.1 jmcneill #define PHY_STATUS_GENERAL_MASK 0x0000FFFF
196 1.1 jmcneill #define PHY_STATUS_OE_PWSP_MASK 0x07FF0000
197 1.1 jmcneill #define PHY_STATUS_LPW_STATE 0x80000000
198 1.1 jmcneill #define PHY_STATIS_OE_PWSP_SHIFT 16
199 1.1 jmcneill
200 1.1 jmcneill /* Packet memory BIST. */
201 1.1 jmcneill #define ALC_BIST0 0x141C
202 1.1 jmcneill #define BIST0_ENB 0x00000001
203 1.1 jmcneill #define BIST0_SRAM_FAIL 0x00000002
204 1.1 jmcneill #define BIST0_FUSE_FLAG 0x00000004
205 1.1 jmcneill
206 1.1 jmcneill /* PCIe retry buffer BIST. */
207 1.1 jmcneill #define ALC_BIST1 0x1420
208 1.1 jmcneill #define BIST1_ENB 0x00000001
209 1.1 jmcneill #define BIST1_SRAM_FAIL 0x00000002
210 1.1 jmcneill #define BIST1_FUSE_FLAG 0x00000004
211 1.1 jmcneill
212 1.1 jmcneill #define ALC_SERDES_LOCK 0x1424
213 1.1 jmcneill #define SERDES_LOCK_DET 0x00000001
214 1.1 jmcneill #define SERDES_LOCK_DET_ENB 0x00000002
215 1.1 jmcneill
216 1.1 jmcneill #define ALC_MAC_CFG 0x1480
217 1.1 jmcneill #define MAC_CFG_TX_ENB 0x00000001
218 1.1 jmcneill #define MAC_CFG_RX_ENB 0x00000002
219 1.1 jmcneill #define MAC_CFG_TX_FC 0x00000004
220 1.1 jmcneill #define MAC_CFG_RX_FC 0x00000008
221 1.1 jmcneill #define MAC_CFG_LOOP 0x00000010
222 1.1 jmcneill #define MAC_CFG_FULL_DUPLEX 0x00000020
223 1.1 jmcneill #define MAC_CFG_TX_CRC_ENB 0x00000040
224 1.1 jmcneill #define MAC_CFG_TX_AUTO_PAD 0x00000080
225 1.1 jmcneill #define MAC_CFG_TX_LENCHK 0x00000100
226 1.1 jmcneill #define MAC_CFG_RX_JUMBO_ENB 0x00000200
227 1.1 jmcneill #define MAC_CFG_PREAMBLE_MASK 0x00003C00
228 1.1 jmcneill #define MAC_CFG_VLAN_TAG_STRIP 0x00004000
229 1.1 jmcneill #define MAC_CFG_PROMISC 0x00008000
230 1.1 jmcneill #define MAC_CFG_TX_PAUSE 0x00010000
231 1.1 jmcneill #define MAC_CFG_SCNT 0x00020000
232 1.1 jmcneill #define MAC_CFG_SYNC_RST_TX 0x00040000
233 1.1 jmcneill #define MAC_CFG_SIM_RST_TX 0x00080000
234 1.1 jmcneill #define MAC_CFG_SPEED_MASK 0x00300000
235 1.1 jmcneill #define MAC_CFG_SPEED_10_100 0x00100000
236 1.1 jmcneill #define MAC_CFG_SPEED_1000 0x00200000
237 1.1 jmcneill #define MAC_CFG_DBG_TX_BACKOFF 0x00400000
238 1.1 jmcneill #define MAC_CFG_TX_JUMBO_ENB 0x00800000
239 1.1 jmcneill #define MAC_CFG_RXCSUM_ENB 0x01000000
240 1.1 jmcneill #define MAC_CFG_ALLMULTI 0x02000000
241 1.1 jmcneill #define MAC_CFG_BCAST 0x04000000
242 1.1 jmcneill #define MAC_CFG_DBG 0x08000000
243 1.1 jmcneill #define MAC_CFG_SINGLE_PAUSE_ENB 0x10000000
244 1.1 jmcneill #define MAC_CFG_PREAMBLE_SHIFT 10
245 1.1 jmcneill #define MAC_CFG_PREAMBLE_DEFAULT 7
246 1.1 jmcneill
247 1.1 jmcneill #define ALC_IPG_IFG_CFG 0x1484
248 1.1 jmcneill #define IPG_IFG_IPGT_MASK 0x0000007F
249 1.1 jmcneill #define IPG_IFG_MIFG_MASK 0x0000FF00
250 1.1 jmcneill #define IPG_IFG_IPG1_MASK 0x007F0000
251 1.1 jmcneill #define IPG_IFG_IPG2_MASK 0x7F000000
252 1.1 jmcneill #define IPG_IFG_IPGT_SHIFT 0
253 1.1 jmcneill #define IPG_IFG_IPGT_DEFAULT 0x60
254 1.1 jmcneill #define IPG_IFG_MIFG_SHIFT 8
255 1.1 jmcneill #define IPG_IFG_MIFG_DEFAULT 0x50
256 1.1 jmcneill #define IPG_IFG_IPG1_SHIFT 16
257 1.1 jmcneill #define IPG_IFG_IPG1_DEFAULT 0x40
258 1.1 jmcneill #define IPG_IFG_IPG2_SHIFT 24
259 1.1 jmcneill #define IPG_IFG_IPG2_DEFAULT 0x60
260 1.1 jmcneill
261 1.1 jmcneill /* Station address. */
262 1.1 jmcneill #define ALC_PAR0 0x1488
263 1.1 jmcneill #define ALC_PAR1 0x148C
264 1.1 jmcneill
265 1.1 jmcneill /* 64bit multicast hash register. */
266 1.1 jmcneill #define ALC_MAR0 0x1490
267 1.1 jmcneill #define ALC_MAR1 0x1494
268 1.1 jmcneill
269 1.1 jmcneill /* half-duplex parameter configuration. */
270 1.1 jmcneill #define ALC_HDPX_CFG 0x1498
271 1.1 jmcneill #define HDPX_CFG_LCOL_MASK 0x000003FF
272 1.1 jmcneill #define HDPX_CFG_RETRY_MASK 0x0000F000
273 1.1 jmcneill #define HDPX_CFG_EXC_DEF_EN 0x00010000
274 1.1 jmcneill #define HDPX_CFG_NO_BACK_C 0x00020000
275 1.1 jmcneill #define HDPX_CFG_NO_BACK_P 0x00040000
276 1.1 jmcneill #define HDPX_CFG_ABEBE 0x00080000
277 1.1 jmcneill #define HDPX_CFG_ABEBT_MASK 0x00F00000
278 1.1 jmcneill #define HDPX_CFG_JAMIPG_MASK 0x0F000000
279 1.1 jmcneill #define HDPX_CFG_LCOL_SHIFT 0
280 1.1 jmcneill #define HDPX_CFG_LCOL_DEFAULT 0x37
281 1.1 jmcneill #define HDPX_CFG_RETRY_SHIFT 12
282 1.1 jmcneill #define HDPX_CFG_RETRY_DEFAULT 0x0F
283 1.1 jmcneill #define HDPX_CFG_ABEBT_SHIFT 20
284 1.1 jmcneill #define HDPX_CFG_ABEBT_DEFAULT 0x0A
285 1.1 jmcneill #define HDPX_CFG_JAMIPG_SHIFT 24
286 1.1 jmcneill #define HDPX_CFG_JAMIPG_DEFAULT 0x07
287 1.1 jmcneill
288 1.1 jmcneill #define ALC_FRAME_SIZE 0x149C
289 1.1 jmcneill
290 1.1 jmcneill #define ALC_WOL_CFG 0x14A0
291 1.1 jmcneill #define WOL_CFG_PATTERN 0x00000001
292 1.1 jmcneill #define WOL_CFG_PATTERN_ENB 0x00000002
293 1.1 jmcneill #define WOL_CFG_MAGIC 0x00000004
294 1.1 jmcneill #define WOL_CFG_MAGIC_ENB 0x00000008
295 1.1 jmcneill #define WOL_CFG_LINK_CHG 0x00000010
296 1.1 jmcneill #define WOL_CFG_LINK_CHG_ENB 0x00000020
297 1.1 jmcneill #define WOL_CFG_PATTERN_DET 0x00000100
298 1.1 jmcneill #define WOL_CFG_MAGIC_DET 0x00000200
299 1.1 jmcneill #define WOL_CFG_LINK_CHG_DET 0x00000400
300 1.1 jmcneill #define WOL_CFG_CLK_SWITCH_ENB 0x00008000
301 1.1 jmcneill #define WOL_CFG_PATTERN0 0x00010000
302 1.1 jmcneill #define WOL_CFG_PATTERN1 0x00020000
303 1.1 jmcneill #define WOL_CFG_PATTERN2 0x00040000
304 1.1 jmcneill #define WOL_CFG_PATTERN3 0x00080000
305 1.1 jmcneill #define WOL_CFG_PATTERN4 0x00100000
306 1.1 jmcneill #define WOL_CFG_PATTERN5 0x00200000
307 1.1 jmcneill #define WOL_CFG_PATTERN6 0x00400000
308 1.1 jmcneill
309 1.1 jmcneill /* WOL pattern length. */
310 1.1 jmcneill #define ALC_PATTERN_CFG0 0x14A4
311 1.1 jmcneill #define PATTERN_CFG_0_LEN_MASK 0x0000007F
312 1.1 jmcneill #define PATTERN_CFG_1_LEN_MASK 0x00007F00
313 1.1 jmcneill #define PATTERN_CFG_2_LEN_MASK 0x007F0000
314 1.1 jmcneill #define PATTERN_CFG_3_LEN_MASK 0x7F000000
315 1.1 jmcneill
316 1.1 jmcneill #define ALC_PATTERN_CFG1 0x14A8
317 1.1 jmcneill #define PATTERN_CFG_4_LEN_MASK 0x0000007F
318 1.1 jmcneill #define PATTERN_CFG_5_LEN_MASK 0x00007F00
319 1.1 jmcneill #define PATTERN_CFG_6_LEN_MASK 0x007F0000
320 1.1 jmcneill
321 1.1 jmcneill /* RSS */
322 1.1 jmcneill #define ALC_RSS_KEY0 0x14B0
323 1.1 jmcneill
324 1.1 jmcneill #define ALC_RSS_KEY1 0x14B4
325 1.1 jmcneill
326 1.1 jmcneill #define ALC_RSS_KEY2 0x14B8
327 1.1 jmcneill
328 1.1 jmcneill #define ALC_RSS_KEY3 0x14BC
329 1.1 jmcneill
330 1.1 jmcneill #define ALC_RSS_KEY4 0x14C0
331 1.1 jmcneill
332 1.1 jmcneill #define ALC_RSS_KEY5 0x14C4
333 1.1 jmcneill
334 1.1 jmcneill #define ALC_RSS_KEY6 0x14C8
335 1.1 jmcneill
336 1.1 jmcneill #define ALC_RSS_KEY7 0x14CC
337 1.1 jmcneill
338 1.1 jmcneill #define ALC_RSS_KEY8 0x14D0
339 1.1 jmcneill
340 1.1 jmcneill #define ALC_RSS_KEY9 0x14D4
341 1.1 jmcneill
342 1.1 jmcneill #define ALC_RSS_IDT_TABLE0 0x14E0
343 1.1 jmcneill
344 1.1 jmcneill #define ALC_RSS_IDT_TABLE1 0x14E4
345 1.1 jmcneill
346 1.1 jmcneill #define ALC_RSS_IDT_TABLE2 0x14E8
347 1.1 jmcneill
348 1.1 jmcneill #define ALC_RSS_IDT_TABLE3 0x14EC
349 1.1 jmcneill
350 1.1 jmcneill #define ALC_RSS_IDT_TABLE4 0x14F0
351 1.1 jmcneill
352 1.1 jmcneill #define ALC_RSS_IDT_TABLE5 0x14F4
353 1.1 jmcneill
354 1.1 jmcneill #define ALC_RSS_IDT_TABLE6 0x14F8
355 1.1 jmcneill
356 1.1 jmcneill #define ALC_RSS_IDT_TABLE7 0x14FC
357 1.1 jmcneill
358 1.1 jmcneill #define ALC_SRAM_RD0_ADDR 0x1500
359 1.1 jmcneill
360 1.1 jmcneill #define ALC_SRAM_RD1_ADDR 0x1504
361 1.1 jmcneill
362 1.1 jmcneill #define ALC_SRAM_RD2_ADDR 0x1508
363 1.1 jmcneill
364 1.1 jmcneill #define ALC_SRAM_RD3_ADDR 0x150C
365 1.1 jmcneill
366 1.1 jmcneill #define RD_HEAD_ADDR_MASK 0x000003FF
367 1.1 jmcneill #define RD_TAIL_ADDR_MASK 0x03FF0000
368 1.1 jmcneill #define RD_HEAD_ADDR_SHIFT 0
369 1.1 jmcneill #define RD_TAIL_ADDR_SHIFT 16
370 1.1 jmcneill
371 1.1 jmcneill #define ALC_RD_NIC_LEN0 0x1510 /* 8 bytes unit */
372 1.1 jmcneill #define RD_NIC_LEN_MASK 0x000003FF
373 1.1 jmcneill
374 1.1 jmcneill #define ALC_RD_NIC_LEN1 0x1514
375 1.1 jmcneill
376 1.1 jmcneill #define ALC_SRAM_TD_ADDR 0x1518
377 1.1 jmcneill #define TD_HEAD_ADDR_MASK 0x000003FF
378 1.1 jmcneill #define TD_TAIL_ADDR_MASK 0x03FF0000
379 1.1 jmcneill #define TD_HEAD_ADDR_SHIFT 0
380 1.1 jmcneill #define TD_TAIL_ADDR_SHIFT 16
381 1.1 jmcneill
382 1.1 jmcneill #define ALC_SRAM_TD_LEN 0x151C /* 8 bytes unit */
383 1.1 jmcneill #define SRAM_TD_LEN_MASK 0x000003FF
384 1.1 jmcneill
385 1.1 jmcneill #define ALC_SRAM_RX_FIFO_ADDR 0x1520
386 1.1 jmcneill
387 1.1 jmcneill #define ALC_SRAM_RX_FIFO_LEN 0x1524
388 1.1 jmcneill
389 1.1 jmcneill #define ALC_SRAM_TX_FIFO_ADDR 0x1528
390 1.1 jmcneill
391 1.1 jmcneill #define ALC_SRAM_TX_FIFO_LEN 0x152C
392 1.1 jmcneill
393 1.1 jmcneill #define ALC_SRAM_TCPH_ADDR 0x1530
394 1.1 jmcneill #define SRAM_TCPH_ADDR_MASK 0x00000FFF
395 1.1 jmcneill #define SRAM_PATH_ADDR_MASK 0x0FFF0000
396 1.1 jmcneill #define SRAM_TCPH_ADDR_SHIFT 0
397 1.1 jmcneill #define SRAM_PKTH_ADDR_SHIFT 16
398 1.1 jmcneill
399 1.1 jmcneill #define ALC_DMA_BLOCK 0x1534
400 1.1 jmcneill #define DMA_BLOCK_LOAD 0x00000001
401 1.1 jmcneill
402 1.1 jmcneill #define ALC_RX_BASE_ADDR_HI 0x1540
403 1.1 jmcneill
404 1.1 jmcneill #define ALC_TX_BASE_ADDR_HI 0x1544
405 1.1 jmcneill
406 1.1 jmcneill #define ALC_SMB_BASE_ADDR_HI 0x1548
407 1.1 jmcneill
408 1.1 jmcneill #define ALC_SMB_BASE_ADDR_LO 0x154C
409 1.1 jmcneill
410 1.1 jmcneill #define ALC_RD0_HEAD_ADDR_LO 0x1550
411 1.1 jmcneill
412 1.1 jmcneill #define ALC_RD1_HEAD_ADDR_LO 0x1554
413 1.1 jmcneill
414 1.1 jmcneill #define ALC_RD2_HEAD_ADDR_LO 0x1558
415 1.1 jmcneill
416 1.1 jmcneill #define ALC_RD3_HEAD_ADDR_LO 0x155C
417 1.1 jmcneill
418 1.1 jmcneill #define ALC_RD_RING_CNT 0x1560
419 1.1 jmcneill #define RD_RING_CNT_MASK 0x00000FFF
420 1.1 jmcneill #define RD_RING_CNT_SHIFT 0
421 1.1 jmcneill
422 1.1 jmcneill #define ALC_RX_BUF_SIZE 0x1564
423 1.1 jmcneill #define RX_BUF_SIZE_MASK 0x0000FFFF
424 1.1 jmcneill /*
425 1.1 jmcneill * If larger buffer size than 1536 is specified the controller
426 1.1 jmcneill * will be locked up. This is hardware limitation.
427 1.1 jmcneill */
428 1.1 jmcneill #define RX_BUF_SIZE_MAX 1536
429 1.1 jmcneill
430 1.1 jmcneill #define ALC_RRD0_HEAD_ADDR_LO 0x1568
431 1.1 jmcneill
432 1.1 jmcneill #define ALC_RRD1_HEAD_ADDR_LO 0x156C
433 1.1 jmcneill
434 1.1 jmcneill #define ALC_RRD2_HEAD_ADDR_LO 0x1570
435 1.1 jmcneill
436 1.1 jmcneill #define ALC_RRD3_HEAD_ADDR_LO 0x1574
437 1.1 jmcneill
438 1.1 jmcneill #define ALC_RRD_RING_CNT 0x1578
439 1.1 jmcneill #define RRD_RING_CNT_MASK 0x00000FFF
440 1.1 jmcneill #define RRD_RING_CNT_SHIFT 0
441 1.1 jmcneill
442 1.1 jmcneill #define ALC_TDH_HEAD_ADDR_LO 0x157C
443 1.1 jmcneill
444 1.1 jmcneill #define ALC_TDL_HEAD_ADDR_LO 0x1580
445 1.1 jmcneill
446 1.1 jmcneill #define ALC_TD_RING_CNT 0x1584
447 1.1 jmcneill #define TD_RING_CNT_MASK 0x0000FFFF
448 1.1 jmcneill #define TD_RING_CNT_SHIFT 0
449 1.1 jmcneill
450 1.1 jmcneill #define ALC_CMB_BASE_ADDR_LO 0x1588
451 1.1 jmcneill
452 1.1 jmcneill #define ALC_TXQ_CFG 0x1590
453 1.1 jmcneill #define TXQ_CFG_TD_BURST_MASK 0x0000000F
454 1.1 jmcneill #define TXQ_CFG_IP_OPTION_ENB 0x00000010
455 1.1 jmcneill #define TXQ_CFG_ENB 0x00000020
456 1.1 jmcneill #define TXQ_CFG_ENHANCED_MODE 0x00000040
457 1.1 jmcneill #define TXQ_CFG_8023_ENB 0x00000080
458 1.1 jmcneill #define TXQ_CFG_TX_FIFO_BURST_MASK 0xFFFF0000
459 1.1 jmcneill #define TXQ_CFG_TD_BURST_SHIFT 0
460 1.1 jmcneill #define TXQ_CFG_TD_BURST_DEFAULT 5
461 1.1 jmcneill #define TXQ_CFG_TX_FIFO_BURST_SHIFT 16
462 1.1 jmcneill
463 1.1 jmcneill #define ALC_TSO_OFFLOAD_THRESH 0x1594 /* 8 bytes unit */
464 1.1 jmcneill #define TSO_OFFLOAD_THRESH_MASK 0x000007FF
465 1.1 jmcneill #define TSO_OFFLOAD_THRESH_SHIFT 0
466 1.1 jmcneill #define TSO_OFFLOAD_THRESH_UNIT 8
467 1.1 jmcneill #define TSO_OFFLOAD_THRESH_UNIT_SHIFT 3
468 1.1 jmcneill
469 1.1 jmcneill #define ALC_TXF_WATER_MARK 0x1598 /* 8 bytes unit */
470 1.1 jmcneill #define TXF_WATER_MARK_HI_MASK 0x00000FFF
471 1.1 jmcneill #define TXF_WATER_MARK_LO_MASK 0x0FFF0000
472 1.1 jmcneill #define TXF_WATER_MARK_BURST_ENB 0x80000000
473 1.1 jmcneill #define TXF_WATER_MARK_LO_SHIFT 0
474 1.1 jmcneill #define TXF_WATER_MARK_HI_SHIFT 16
475 1.1 jmcneill
476 1.1 jmcneill #define ALC_THROUGHPUT_MON 0x159C
477 1.1 jmcneill #define THROUGHPUT_MON_RATE_MASK 0x00000003
478 1.1 jmcneill #define THROUGHPUT_MON_ENB 0x00000080
479 1.1 jmcneill #define THROUGHPUT_MON_RATE_SHIFT 0
480 1.1 jmcneill
481 1.1 jmcneill #define ALC_RXQ_CFG 0x15A0
482 1.1 jmcneill #define RXQ_CFG_ASPM_THROUGHPUT_LIMIT_MASK 0x00000003
483 1.1 jmcneill #define RXQ_CFG_ASPM_THROUGHPUT_LIMIT_NONE 0x00000000
484 1.1 jmcneill #define RXQ_CFG_ASPM_THROUGHPUT_LIMIT_1M 0x00000001
485 1.1 jmcneill #define RXQ_CFG_ASPM_THROUGHPUT_LIMIT_10M 0x00000002
486 1.1 jmcneill #define RXQ_CFG_ASPM_THROUGHPUT_LIMIT_100M 0x00000003
487 1.1 jmcneill #define RXQ_CFG_QUEUE1_ENB 0x00000010
488 1.1 jmcneill #define RXQ_CFG_QUEUE2_ENB 0x00000020
489 1.1 jmcneill #define RXQ_CFG_QUEUE3_ENB 0x00000040
490 1.1 jmcneill #define RXQ_CFG_IPV6_CSUM_ENB 0x00000080
491 1.1 jmcneill #define RXQ_CFG_RSS_HASH_TBL_LEN_MASK 0x0000FF00
492 1.1 jmcneill #define RXQ_CFG_RSS_HASH_IPV4 0x00010000
493 1.1 jmcneill #define RXQ_CFG_RSS_HASH_IPV4_TCP 0x00020000
494 1.1 jmcneill #define RXQ_CFG_RSS_HASH_IPV6 0x00040000
495 1.1 jmcneill #define RXQ_CFG_RSS_HASH_IPV6_TCP 0x00080000
496 1.1 jmcneill #define RXQ_CFG_RD_BURST_MASK 0x03F00000
497 1.1 jmcneill #define RXQ_CFG_RSS_MODE_DIS 0x00000000
498 1.1 jmcneill #define RXQ_CFG_RSS_MODE_SQSINT 0x04000000
499 1.1 jmcneill #define RXQ_CFG_RSS_MODE_MQUESINT 0x08000000
500 1.1 jmcneill #define RXQ_CFG_RSS_MODE_MQUEMINT 0x0C000000
501 1.1 jmcneill #define RXQ_CFG_NIP_QUEUE_SEL_TBL 0x10000000
502 1.1 jmcneill #define RXQ_CFG_RSS_HASH_ENB 0x20000000
503 1.1 jmcneill #define RXQ_CFG_CUT_THROUGH_ENB 0x40000000
504 1.1 jmcneill #define RXQ_CFG_QUEUE0_ENB 0x80000000
505 1.1 jmcneill #define RXQ_CFG_RSS_HASH_TBL_LEN_SHIFT 8
506 1.1 jmcneill #define RXQ_CFG_RD_BURST_DEFAULT 8
507 1.1 jmcneill #define RXQ_CFG_RD_BURST_SHIFT 20
508 1.1 jmcneill #define RXQ_CFG_ENB \
509 1.1 jmcneill (RXQ_CFG_QUEUE0_ENB | RXQ_CFG_QUEUE1_ENB | \
510 1.1 jmcneill RXQ_CFG_QUEUE2_ENB | RXQ_CFG_QUEUE3_ENB)
511 1.1 jmcneill
512 1.1 jmcneill #define ALC_RX_RD_FREE_THRESH 0x15A4 /* 8 bytes unit. */
513 1.1 jmcneill #define RX_RD_FREE_THRESH_HI_MASK 0x0000003F
514 1.1 jmcneill #define RX_RD_FREE_THRESH_LO_MASK 0x00000FC0
515 1.1 jmcneill #define RX_RD_FREE_THRESH_HI_SHIFT 0
516 1.1 jmcneill #define RX_RD_FREE_THRESH_LO_SHIFT 6
517 1.1 jmcneill #define RX_RD_FREE_THRESH_HI_DEFAULT 16
518 1.1 jmcneill #define RX_RD_FREE_THRESH_LO_DEFAULT 8
519 1.1 jmcneill
520 1.1 jmcneill #define ALC_RX_FIFO_PAUSE_THRESH 0x15A8
521 1.1 jmcneill #define RX_FIFO_PAUSE_THRESH_LO_MASK 0x00000FFF
522 1.1 jmcneill #define RX_FIFO_PAUSE_THRESH_HI_MASK 0x0FFF0000
523 1.1 jmcneill #define RX_FIFO_PAUSE_THRESH_LO_SHIFT 0
524 1.1 jmcneill #define RX_FIFO_PAUSE_THRESH_HI_SHIFT 16
525 1.1 jmcneill
526 1.1 jmcneill #define ALC_RD_DMA_CFG 0x15AC
527 1.1 jmcneill #define RD_DMA_CFG_THRESH_MASK 0x00000FFF /* 8 bytes unit */
528 1.1 jmcneill #define RD_DMA_CFG_TIMER_MASK 0xFFFF0000
529 1.1 jmcneill #define RD_DMA_CFG_THRESH_SHIFT 0
530 1.1 jmcneill #define RD_DMA_CFG_TIMER_SHIFT 16
531 1.1 jmcneill #define RD_DMA_CFG_THRESH_DEFAULT 0x100
532 1.1 jmcneill #define RD_DMA_CFG_TIMER_DEFAULT 0
533 1.1 jmcneill #define RD_DMA_CFG_TICK_USECS 8
534 1.1 jmcneill #define ALC_RD_DMA_CFG_USECS(x) ((x) / RD_DMA_CFG_TICK_USECS)
535 1.1 jmcneill
536 1.1 jmcneill #define ALC_RSS_HASH_VALUE 0x15B0
537 1.1 jmcneill
538 1.1 jmcneill #define ALC_RSS_HASH_FLAG 0x15B4
539 1.1 jmcneill
540 1.1 jmcneill #define ALC_RSS_CPU 0x15B8
541 1.1 jmcneill
542 1.1 jmcneill #define ALC_DMA_CFG 0x15C0
543 1.1 jmcneill #define DMA_CFG_IN_ORDER 0x00000001
544 1.1 jmcneill #define DMA_CFG_ENH_ORDER 0x00000002
545 1.1 jmcneill #define DMA_CFG_OUT_ORDER 0x00000004
546 1.1 jmcneill #define DMA_CFG_RCB_64 0x00000000
547 1.1 jmcneill #define DMA_CFG_RCB_128 0x00000008
548 1.1 jmcneill #define DMA_CFG_RD_BURST_128 0x00000000
549 1.1 jmcneill #define DMA_CFG_RD_BURST_256 0x00000010
550 1.1 jmcneill #define DMA_CFG_RD_BURST_512 0x00000020
551 1.1 jmcneill #define DMA_CFG_RD_BURST_1024 0x00000030
552 1.1 jmcneill #define DMA_CFG_RD_BURST_2048 0x00000040
553 1.1 jmcneill #define DMA_CFG_RD_BURST_4096 0x00000050
554 1.1 jmcneill #define DMA_CFG_WR_BURST_128 0x00000000
555 1.1 jmcneill #define DMA_CFG_WR_BURST_256 0x00000080
556 1.1 jmcneill #define DMA_CFG_WR_BURST_512 0x00000100
557 1.1 jmcneill #define DMA_CFG_WR_BURST_1024 0x00000180
558 1.1 jmcneill #define DMA_CFG_WR_BURST_2048 0x00000200
559 1.1 jmcneill #define DMA_CFG_WR_BURST_4096 0x00000280
560 1.1 jmcneill #define DMA_CFG_RD_REQ_PRI 0x00000400
561 1.1 jmcneill #define DMA_CFG_RD_DELAY_CNT_MASK 0x0000F800
562 1.1 jmcneill #define DMA_CFG_WR_DELAY_CNT_MASK 0x000F0000
563 1.1 jmcneill #define DMA_CFG_CMB_ENB 0x00100000
564 1.1 jmcneill #define DMA_CFG_SMB_ENB 0x00200000
565 1.1 jmcneill #define DMA_CFG_CMB_NOW 0x00400000
566 1.1 jmcneill #define DMA_CFG_SMB_DIS 0x01000000
567 1.1 jmcneill #define DMA_CFG_SMB_NOW 0x80000000
568 1.1 jmcneill #define DMA_CFG_RD_BURST_MASK 0x07
569 1.1 jmcneill #define DMA_CFG_RD_BURST_SHIFT 4
570 1.1 jmcneill #define DMA_CFG_WR_BURST_MASK 0x07
571 1.1 jmcneill #define DMA_CFG_WR_BURST_SHIFT 7
572 1.1 jmcneill #define DMA_CFG_RD_DELAY_CNT_SHIFT 11
573 1.1 jmcneill #define DMA_CFG_WR_DELAY_CNT_SHIFT 16
574 1.1 jmcneill #define DMA_CFG_RD_DELAY_CNT_DEFAULT 15
575 1.1 jmcneill #define DMA_CFG_WR_DELAY_CNT_DEFAULT 4
576 1.1 jmcneill
577 1.1 jmcneill #define ALC_SMB_STAT_TIMER 0x15C4
578 1.1 jmcneill #define SMB_STAT_TIMER_MASK 0x00FFFFFF
579 1.1 jmcneill #define SMB_STAT_TIMER_SHIFT 0
580 1.1 jmcneill
581 1.1 jmcneill #define ALC_CMB_TD_THRESH 0x15C8
582 1.1 jmcneill #define CMB_TD_THRESH_MASK 0x0000FFFF
583 1.1 jmcneill #define CMB_TD_THRESH_SHIFT 0
584 1.1 jmcneill
585 1.1 jmcneill #define ALC_CMB_TX_TIMER 0x15CC
586 1.1 jmcneill #define CMB_TX_TIMER_MASK 0x0000FFFF
587 1.1 jmcneill #define CMB_TX_TIMER_SHIFT 0
588 1.1 jmcneill
589 1.1 jmcneill #define ALC_MBOX_RD0_PROD_IDX 0x15E0
590 1.1 jmcneill
591 1.1 jmcneill #define ALC_MBOX_RD1_PROD_IDX 0x15E4
592 1.1 jmcneill
593 1.1 jmcneill #define ALC_MBOX_RD2_PROD_IDX 0x15E8
594 1.1 jmcneill
595 1.1 jmcneill #define ALC_MBOX_RD3_PROD_IDX 0x15EC
596 1.1 jmcneill
597 1.1 jmcneill #define ALC_MBOX_RD_PROD_MASK 0x0000FFFF
598 1.1 jmcneill #define MBOX_RD_PROD_SHIFT 0
599 1.1 jmcneill
600 1.1 jmcneill #define ALC_MBOX_TD_PROD_IDX 0x15F0
601 1.1 jmcneill #define MBOX_TD_PROD_HI_IDX_MASK 0x0000FFFF
602 1.1 jmcneill #define MBOX_TD_PROD_LO_IDX_MASK 0xFFFF0000
603 1.1 jmcneill #define MBOX_TD_PROD_HI_IDX_SHIFT 0
604 1.1 jmcneill #define MBOX_TD_PROD_LO_IDX_SHIFT 16
605 1.1 jmcneill
606 1.1 jmcneill #define ALC_MBOX_TD_CONS_IDX 0x15F4
607 1.1 jmcneill #define MBOX_TD_CONS_HI_IDX_MASK 0x0000FFFF
608 1.1 jmcneill #define MBOX_TD_CONS_LO_IDX_MASK 0xFFFF0000
609 1.1 jmcneill #define MBOX_TD_CONS_HI_IDX_SHIFT 0
610 1.1 jmcneill #define MBOX_TD_CONS_LO_IDX_SHIFT 16
611 1.1 jmcneill
612 1.1 jmcneill #define ALC_MBOX_RD01_CONS_IDX 0x15F8
613 1.1 jmcneill #define MBOX_RD0_CONS_IDX_MASK 0x0000FFFF
614 1.1 jmcneill #define MBOX_RD1_CONS_IDX_MASK 0xFFFF0000
615 1.1 jmcneill #define MBOX_RD0_CONS_IDX_SHIFT 0
616 1.1 jmcneill #define MBOX_RD1_CONS_IDX_SHIFT 16
617 1.1 jmcneill
618 1.1 jmcneill #define ALC_MBOX_RD23_CONS_IDX 0x15FC
619 1.1 jmcneill #define MBOX_RD2_CONS_IDX_MASK 0x0000FFFF
620 1.1 jmcneill #define MBOX_RD3_CONS_IDX_MASK 0xFFFF0000
621 1.1 jmcneill #define MBOX_RD2_CONS_IDX_SHIFT 0
622 1.1 jmcneill #define MBOX_RD3_CONS_IDX_SHIFT 16
623 1.1 jmcneill
624 1.1 jmcneill #define ALC_INTR_STATUS 0x1600
625 1.1 jmcneill #define INTR_SMB 0x00000001
626 1.1 jmcneill #define INTR_TIMER 0x00000002
627 1.1 jmcneill #define INTR_MANUAL_TIMER 0x00000004
628 1.1 jmcneill #define INTR_RX_FIFO_OFLOW 0x00000008
629 1.1 jmcneill #define INTR_RD0_UNDERRUN 0x00000010
630 1.1 jmcneill #define INTR_RD1_UNDERRUN 0x00000020
631 1.1 jmcneill #define INTR_RD2_UNDERRUN 0x00000040
632 1.1 jmcneill #define INTR_RD3_UNDERRUN 0x00000080
633 1.1 jmcneill #define INTR_TX_FIFO_UNDERRUN 0x00000100
634 1.1 jmcneill #define INTR_DMA_RD_TO_RST 0x00000200
635 1.1 jmcneill #define INTR_DMA_WR_TO_RST 0x00000400
636 1.1 jmcneill #define INTR_TX_CREDIT 0x00000800
637 1.1 jmcneill #define INTR_GPHY 0x00001000
638 1.1 jmcneill #define INTR_GPHY_LOW_PW 0x00002000
639 1.1 jmcneill #define INTR_TXQ_TO_RST 0x00004000
640 1.1 jmcneill #define INTR_TX_PKT 0x00008000
641 1.1 jmcneill #define INTR_RX_PKT0 0x00010000
642 1.1 jmcneill #define INTR_RX_PKT1 0x00020000
643 1.1 jmcneill #define INTR_RX_PKT2 0x00040000
644 1.1 jmcneill #define INTR_RX_PKT3 0x00080000
645 1.1 jmcneill #define INTR_MAC_RX 0x00100000
646 1.1 jmcneill #define INTR_MAC_TX 0x00200000
647 1.1 jmcneill #define INTR_UNDERRUN 0x00400000
648 1.1 jmcneill #define INTR_FRAME_ERROR 0x00800000
649 1.1 jmcneill #define INTR_FRAME_OK 0x01000000
650 1.1 jmcneill #define INTR_CSUM_ERROR 0x02000000
651 1.1 jmcneill #define INTR_PHY_LINK_DOWN 0x04000000
652 1.1 jmcneill #define INTR_DIS_INT 0x80000000
653 1.1 jmcneill
654 1.1 jmcneill /* Interrupt Mask Register */
655 1.1 jmcneill #define ALC_INTR_MASK 0x1604
656 1.1 jmcneill
657 1.1 jmcneill #ifdef notyet
658 1.1 jmcneill #define INTR_RX_PKT \
659 1.1 jmcneill (INTR_RX_PKT0 | INTR_RX_PKT1 | INTR_RX_PKT2 | \
660 1.1 jmcneill INTR_RX_PKT3)
661 1.1 jmcneill #define INTR_RD_UNDERRUN \
662 1.1 jmcneill (INTR_RD0_UNDERRUN | INTR_RD1_UNDERRUN | \
663 1.1 jmcneill INTR_RD2_UNDERRUN | INTR_RD3_UNDERRUN)
664 1.1 jmcneill #else
665 1.1 jmcneill #define INTR_RX_PKT INTR_RX_PKT0
666 1.1 jmcneill #define INTR_RD_UNDERRUN INTR_RD0_UNDERRUN
667 1.1 jmcneill #endif
668 1.1 jmcneill
669 1.1 jmcneill #define ALC_INTRS \
670 1.1 jmcneill (INTR_DMA_RD_TO_RST | INTR_DMA_WR_TO_RST | \
671 1.1 jmcneill INTR_TXQ_TO_RST | INTR_RX_PKT | INTR_TX_PKT | \
672 1.1 jmcneill INTR_RX_FIFO_OFLOW | INTR_RD_UNDERRUN | \
673 1.1 jmcneill INTR_TX_FIFO_UNDERRUN)
674 1.1 jmcneill
675 1.1 jmcneill #define ALC_INTR_RETRIG_TIMER 0x1608
676 1.1 jmcneill #define INTR_RETRIG_TIMER_MASK 0x0000FFFF
677 1.1 jmcneill #define INTR_RETRIG_TIMER_SHIFT 0
678 1.1 jmcneill
679 1.1 jmcneill #define ALC_HDS_CFG 0x160C
680 1.1 jmcneill #define HDS_CFG_ENB 0x00000001
681 1.1 jmcneill #define HDS_CFG_BACKFILLSIZE_MASK 0x000FFF00
682 1.1 jmcneill #define HDS_CFG_MAX_HDRSIZE_MASK 0xFFF00000
683 1.1 jmcneill #define HDS_CFG_BACKFILLSIZE_SHIFT 8
684 1.1 jmcneill #define HDS_CFG_MAX_HDRSIZE_SHIFT 20
685 1.1 jmcneill
686 1.1 jmcneill /* AR8131/AR8132 registers for MAC statistics */
687 1.1 jmcneill #define ALC_RX_MIB_BASE 0x1700
688 1.1 jmcneill
689 1.1 jmcneill #define ALC_TX_MIB_BASE 0x1760
690 1.1 jmcneill
691 1.1 jmcneill #define ALC_DEBUG_DATA0 0x1900
692 1.1 jmcneill
693 1.1 jmcneill #define ALC_DEBUG_DATA1 0x1904
694 1.1 jmcneill
695 1.1 jmcneill #define ALC_MII_DBG_ADDR 0x1D
696 1.1 jmcneill #define ALC_MII_DBG_DATA 0x1E
697 1.1 jmcneill
698 1.1 jmcneill #define MII_ANA_CFG0 0x00
699 1.1 jmcneill #define ANA_RESTART_CAL 0x0001
700 1.1 jmcneill #define ANA_MANUL_SWICH_ON_MASK 0x001E
701 1.1 jmcneill #define ANA_MAN_ENABLE 0x0020
702 1.1 jmcneill #define ANA_SEL_HSP 0x0040
703 1.1 jmcneill #define ANA_EN_HB 0x0080
704 1.1 jmcneill #define ANA_EN_HBIAS 0x0100
705 1.1 jmcneill #define ANA_OEN_125M 0x0200
706 1.1 jmcneill #define ANA_EN_LCKDT 0x0400
707 1.1 jmcneill #define ANA_LCKDT_PHY 0x0800
708 1.1 jmcneill #define ANA_AFE_MODE 0x1000
709 1.1 jmcneill #define ANA_VCO_SLOW 0x2000
710 1.1 jmcneill #define ANA_VCO_FAST 0x4000
711 1.1 jmcneill #define ANA_SEL_CLK125M_DSP 0x8000
712 1.1 jmcneill #define ANA_MANUL_SWICH_ON_SHIFT 1
713 1.1 jmcneill
714 1.1 jmcneill #define MII_ANA_CFG4 0x04
715 1.1 jmcneill #define ANA_IECHO_ADJ_MASK 0x0F
716 1.1 jmcneill #define ANA_IECHO_ADJ_3_MASK 0x000F
717 1.1 jmcneill #define ANA_IECHO_ADJ_2_MASK 0x00F0
718 1.1 jmcneill #define ANA_IECHO_ADJ_1_MASK 0x0F00
719 1.1 jmcneill #define ANA_IECHO_ADJ_0_MASK 0xF000
720 1.1 jmcneill #define ANA_IECHO_ADJ_3_SHIFT 0
721 1.1 jmcneill #define ANA_IECHO_ADJ_2_SHIFT 4
722 1.1 jmcneill #define ANA_IECHO_ADJ_1_SHIFT 8
723 1.1 jmcneill #define ANA_IECHO_ADJ_0_SHIFT 12
724 1.1 jmcneill
725 1.1 jmcneill #define MII_ANA_CFG5 0x05
726 1.1 jmcneill #define ANA_SERDES_CDR_BW_MASK 0x0003
727 1.1 jmcneill #define ANA_MS_PAD_DBG 0x0004
728 1.1 jmcneill #define ANA_SPEEDUP_DBG 0x0008
729 1.1 jmcneill #define ANA_SERDES_TH_LOS_MASK 0x0030
730 1.1 jmcneill #define ANA_SERDES_EN_DEEM 0x0040
731 1.1 jmcneill #define ANA_SERDES_TXELECIDLE 0x0080
732 1.1 jmcneill #define ANA_SERDES_BEACON 0x0100
733 1.1 jmcneill #define ANA_SERDES_HALFTXDR 0x0200
734 1.1 jmcneill #define ANA_SERDES_SEL_HSP 0x0400
735 1.1 jmcneill #define ANA_SERDES_EN_PLL 0x0800
736 1.1 jmcneill #define ANA_SERDES_EN 0x1000
737 1.1 jmcneill #define ANA_SERDES_EN_LCKDT 0x2000
738 1.1 jmcneill #define ANA_SERDES_CDR_BW_SHIFT 0
739 1.1 jmcneill #define ANA_SERDES_TH_LOS_SHIFT 4
740 1.1 jmcneill
741 1.1 jmcneill #define MII_ANA_CFG11 0x0B
742 1.1 jmcneill #define ANA_PS_HIB_EN 0x8000
743 1.1 jmcneill
744 1.1 jmcneill #define MII_ANA_CFG18 0x12
745 1.1 jmcneill #define ANA_TEST_MODE_10BT_01MASK 0x0003
746 1.1 jmcneill #define ANA_LOOP_SEL_10BT 0x0004
747 1.1 jmcneill #define ANA_RGMII_MODE_SW 0x0008
748 1.1 jmcneill #define ANA_EN_LONGECABLE 0x0010
749 1.1 jmcneill #define ANA_TEST_MODE_10BT_2 0x0020
750 1.1 jmcneill #define ANA_EN_10BT_IDLE 0x0400
751 1.1 jmcneill #define ANA_EN_MASK_TB 0x0800
752 1.1 jmcneill #define ANA_TRIGGER_SEL_TIMER_MASK 0x3000
753 1.1 jmcneill #define ANA_INTERVAL_SEL_TIMER_MASK 0xC000
754 1.1 jmcneill #define ANA_TEST_MODE_10BT_01SHIFT 0
755 1.1 jmcneill #define ANA_TRIGGER_SEL_TIMER_SHIFT 12
756 1.1 jmcneill #define ANA_INTERVAL_SEL_TIMER_SHIFT 14
757 1.1 jmcneill
758 1.1 jmcneill #define MII_ANA_CFG41 0x29
759 1.1 jmcneill #define ANA_TOP_PS_EN 0x8000
760 1.1 jmcneill
761 1.1 jmcneill #define MII_ANA_CFG54 0x36
762 1.1 jmcneill #define ANA_LONG_CABLE_TH_100_MASK 0x003F
763 1.1 jmcneill #define ANA_DESERVED 0x0040
764 1.1 jmcneill #define ANA_EN_LIT_CH 0x0080
765 1.1 jmcneill #define ANA_SHORT_CABLE_TH_100_MASK 0x3F00
766 1.1 jmcneill #define ANA_BP_BAD_LINK_ACCUM 0x4000
767 1.1 jmcneill #define ANA_BP_SMALL_BW 0x8000
768 1.1 jmcneill #define ANA_LONG_CABLE_TH_100_SHIFT 0
769 1.1 jmcneill #define ANA_SHORT_CABLE_TH_100_SHIFT 8
770 1.1 jmcneill
771 1.1 jmcneill /* Statistics counters collected by the MAC. */
772 1.1 jmcneill struct smb {
773 1.1 jmcneill /* Rx stats. */
774 1.1 jmcneill uint32_t rx_frames;
775 1.1 jmcneill uint32_t rx_bcast_frames;
776 1.1 jmcneill uint32_t rx_mcast_frames;
777 1.1 jmcneill uint32_t rx_pause_frames;
778 1.1 jmcneill uint32_t rx_control_frames;
779 1.1 jmcneill uint32_t rx_crcerrs;
780 1.1 jmcneill uint32_t rx_lenerrs;
781 1.1 jmcneill uint32_t rx_bytes;
782 1.1 jmcneill uint32_t rx_runts;
783 1.1 jmcneill uint32_t rx_fragments;
784 1.1 jmcneill uint32_t rx_pkts_64;
785 1.1 jmcneill uint32_t rx_pkts_65_127;
786 1.1 jmcneill uint32_t rx_pkts_128_255;
787 1.1 jmcneill uint32_t rx_pkts_256_511;
788 1.1 jmcneill uint32_t rx_pkts_512_1023;
789 1.1 jmcneill uint32_t rx_pkts_1024_1518;
790 1.1 jmcneill uint32_t rx_pkts_1519_max;
791 1.1 jmcneill uint32_t rx_pkts_truncated;
792 1.1 jmcneill uint32_t rx_fifo_oflows;
793 1.1 jmcneill uint32_t rx_rrs_errs;
794 1.1 jmcneill uint32_t rx_alignerrs;
795 1.1 jmcneill uint32_t rx_bcast_bytes;
796 1.1 jmcneill uint32_t rx_mcast_bytes;
797 1.1 jmcneill uint32_t rx_pkts_filtered;
798 1.1 jmcneill /* Tx stats. */
799 1.1 jmcneill uint32_t tx_frames;
800 1.1 jmcneill uint32_t tx_bcast_frames;
801 1.1 jmcneill uint32_t tx_mcast_frames;
802 1.1 jmcneill uint32_t tx_pause_frames;
803 1.1 jmcneill uint32_t tx_excess_defer;
804 1.1 jmcneill uint32_t tx_control_frames;
805 1.1 jmcneill uint32_t tx_deferred;
806 1.1 jmcneill uint32_t tx_bytes;
807 1.1 jmcneill uint32_t tx_pkts_64;
808 1.1 jmcneill uint32_t tx_pkts_65_127;
809 1.1 jmcneill uint32_t tx_pkts_128_255;
810 1.1 jmcneill uint32_t tx_pkts_256_511;
811 1.1 jmcneill uint32_t tx_pkts_512_1023;
812 1.1 jmcneill uint32_t tx_pkts_1024_1518;
813 1.1 jmcneill uint32_t tx_pkts_1519_max;
814 1.1 jmcneill uint32_t tx_single_colls;
815 1.1 jmcneill uint32_t tx_multi_colls;
816 1.1 jmcneill uint32_t tx_late_colls;
817 1.1 jmcneill uint32_t tx_excess_colls;
818 1.1 jmcneill uint32_t tx_abort;
819 1.1 jmcneill uint32_t tx_underrun;
820 1.1 jmcneill uint32_t tx_desc_underrun;
821 1.1 jmcneill uint32_t tx_lenerrs;
822 1.1 jmcneill uint32_t tx_pkts_truncated;
823 1.1 jmcneill uint32_t tx_bcast_bytes;
824 1.1 jmcneill uint32_t tx_mcast_bytes;
825 1.1 jmcneill uint32_t updated;
826 1.1 jmcneill };
827 1.1 jmcneill
828 1.1 jmcneill /* CMB(Coalesing message block) */
829 1.1 jmcneill struct cmb {
830 1.1 jmcneill uint32_t cons;
831 1.1 jmcneill };
832 1.1 jmcneill
833 1.1 jmcneill /* Rx free descriptor */
834 1.1 jmcneill struct rx_desc {
835 1.1 jmcneill uint64_t addr;
836 1.1 jmcneill };
837 1.1 jmcneill
838 1.1 jmcneill /* Rx return descriptor */
839 1.1 jmcneill struct rx_rdesc {
840 1.1 jmcneill uint32_t rdinfo;
841 1.1 jmcneill #define RRD_CSUM_MASK 0x0000FFFF
842 1.1 jmcneill #define RRD_RD_CNT_MASK 0x000F0000
843 1.1 jmcneill #define RRD_RD_IDX_MASK 0xFFF00000
844 1.1 jmcneill #define RRD_CSUM_SHIFT 0
845 1.1 jmcneill #define RRD_RD_CNT_SHIFT 16
846 1.1 jmcneill #define RRD_RD_IDX_SHIFT 20
847 1.1 jmcneill #define RRD_CSUM(x) \
848 1.1 jmcneill (((x) & RRD_CSUM_MASK) >> RRD_CSUM_SHIFT)
849 1.1 jmcneill #define RRD_RD_CNT(x) \
850 1.1 jmcneill (((x) & RRD_RD_CNT_MASK) >> RRD_RD_CNT_SHIFT)
851 1.1 jmcneill #define RRD_RD_IDX(x) \
852 1.1 jmcneill (((x) & RRD_RD_IDX_MASK) >> RRD_RD_IDX_SHIFT)
853 1.1 jmcneill uint32_t rss;
854 1.1 jmcneill uint32_t vtag;
855 1.1 jmcneill #define RRD_VLAN_MASK 0x0000FFFF
856 1.1 jmcneill #define RRD_HEAD_LEN_MASK 0x00FF0000
857 1.1 jmcneill #define RRD_HDS_MASK 0x03000000
858 1.1 jmcneill #define RRD_HDS_NONE 0x00000000
859 1.1 jmcneill #define RRD_HDS_HEAD 0x01000000
860 1.1 jmcneill #define RRD_HDS_DATA 0x02000000
861 1.1 jmcneill #define RRD_CPU_MASK 0x0C000000
862 1.1 jmcneill #define RRD_HASH_FLAG_MASK 0xF0000000
863 1.1 jmcneill #define RRD_VLAN_SHIFT 0
864 1.1 jmcneill #define RRD_HEAD_LEN_SHIFT 16
865 1.1 jmcneill #define RRD_HDS_SHIFT 24
866 1.1 jmcneill #define RRD_CPU_SHIFT 26
867 1.1 jmcneill #define RRD_HASH_FLAG_SHIFT 28
868 1.1 jmcneill #define RRD_VLAN(x) \
869 1.1 jmcneill (((x) & RRD_VLAN_MASK) >> RRD_VLAN_SHIFT)
870 1.1 jmcneill #define RRD_HEAD_LEN(x) \
871 1.1 jmcneill (((x) & RRD_HEAD_LEN_MASK) >> RRD_HEAD_LEN_SHIFT)
872 1.1 jmcneill #define RRD_CPU(x) \
873 1.1 jmcneill (((x) & RRD_CPU_MASK) >> RRD_CPU_SHIFT)
874 1.1 jmcneill uint32_t status;
875 1.1 jmcneill #define RRD_LEN_MASK 0x00003FFF
876 1.1 jmcneill #define RRD_LEN_SHIFT 0
877 1.1 jmcneill #define RRD_TCP_UDPCSUM_NOK 0x00004000
878 1.1 jmcneill #define RRD_IPCSUM_NOK 0x00008000
879 1.1 jmcneill #define RRD_VLAN_TAG 0x00010000
880 1.1 jmcneill #define RRD_PROTO_MASK 0x000E0000
881 1.1 jmcneill #define RRD_PROTO_IPV4 0x00020000
882 1.1 jmcneill #define RRD_PROTO_IPV6 0x000C0000
883 1.1 jmcneill #define RRD_ERR_SUM 0x00100000
884 1.1 jmcneill #define RRD_ERR_CRC 0x00200000
885 1.1 jmcneill #define RRD_ERR_ALIGN 0x00400000
886 1.1 jmcneill #define RRD_ERR_TRUNC 0x00800000
887 1.1 jmcneill #define RRD_ERR_RUNT 0x01000000
888 1.1 jmcneill #define RRD_ERR_ICMP 0x02000000
889 1.1 jmcneill #define RRD_BCAST 0x04000000
890 1.1 jmcneill #define RRD_MCAST 0x08000000
891 1.1 jmcneill #define RRD_SNAP_LLC 0x10000000
892 1.1 jmcneill #define RRD_ETHER 0x00000000
893 1.1 jmcneill #define RRD_FIFO_FULL 0x20000000
894 1.1 jmcneill #define RRD_ERR_LENGTH 0x40000000
895 1.1 jmcneill #define RRD_VALID 0x80000000
896 1.1 jmcneill #define RRD_BYTES(x) \
897 1.1 jmcneill (((x) & RRD_LEN_MASK) >> RRD_LEN_SHIFT)
898 1.1 jmcneill #define RRD_IPV4(x) \
899 1.1 jmcneill (((x) & RRD_PROTO_MASK) == RRD_PROTO_IPV4)
900 1.1 jmcneill };
901 1.1 jmcneill
902 1.1 jmcneill /* Tx descriptor */
903 1.1 jmcneill struct tx_desc {
904 1.1 jmcneill uint32_t len;
905 1.1 jmcneill #define TD_BUFLEN_MASK 0x00003FFF
906 1.1 jmcneill #define TD_VLAN_MASK 0xFFFF0000
907 1.1 jmcneill #define TD_BUFLEN_SHIFT 0
908 1.1 jmcneill #define TX_BYTES(x) \
909 1.1 jmcneill (((x) << TD_BUFLEN_SHIFT) & TD_BUFLEN_MASK)
910 1.1 jmcneill #define TD_VLAN_SHIFT 16
911 1.1 jmcneill uint32_t flags;
912 1.1 jmcneill #define TD_L4HDR_OFFSET_MASK 0x000000FF /* byte unit */
913 1.1 jmcneill #define TD_TCPHDR_OFFSET_MASK 0x000000FF /* byte unit */
914 1.1 jmcneill #define TD_PLOAD_OFFSET_MASK 0x000000FF /* 2 bytes unit */
915 1.1 jmcneill #define TD_CUSTOM_CSUM 0x00000100
916 1.1 jmcneill #define TD_IPCSUM 0x00000200
917 1.1 jmcneill #define TD_TCPCSUM 0x00000400
918 1.1 jmcneill #define TD_UDPCSUM 0x00000800
919 1.1 jmcneill #define TD_TSO 0x00001000
920 1.1 jmcneill #define TD_TSO_DESCV1 0x00000000
921 1.1 jmcneill #define TD_TSO_DESCV2 0x00002000
922 1.1 jmcneill #define TD_CON_VLAN_TAG 0x00004000
923 1.1 jmcneill #define TD_INS_VLAN_TAG 0x00008000
924 1.1 jmcneill #define TD_IPV4_DESCV2 0x00010000
925 1.1 jmcneill #define TD_LLC_SNAP 0x00020000
926 1.1 jmcneill #define TD_ETHERNET 0x00000000
927 1.1 jmcneill #define TD_CUSTOM_CSUM_OFFSET_MASK 0x03FC0000 /* 2 bytes unit */
928 1.1 jmcneill #define TD_CUSTOM_CSUM_EVEN_PAD 0x40000000
929 1.1 jmcneill #define TD_MSS_MASK 0x7FFC0000
930 1.1 jmcneill #define TD_EOP 0x80000000
931 1.1 jmcneill #define TD_L4HDR_OFFSET_SHIFT 0
932 1.1 jmcneill #define TD_TCPHDR_OFFSET_SHIFT 0
933 1.1 jmcneill #define TD_PLOAD_OFFSET_SHIFT 0
934 1.1 jmcneill #define TD_CUSTOM_CSUM_OFFSET_SHIFT 18
935 1.1 jmcneill #define TD_MSS_SHIFT 18
936 1.1 jmcneill uint64_t addr;
937 1.1 jmcneill };
938 1.1 jmcneill
939 1.1 jmcneill #define ALC_TX_RING_CNT 256
940 1.1 jmcneill #define ALC_TX_RING_ALIGN sizeof(struct tx_desc)
941 1.1 jmcneill #define ALC_RX_RING_CNT 256
942 1.1 jmcneill #define ALC_RX_RING_ALIGN sizeof(struct rx_desc)
943 1.1 jmcneill #define ALC_RX_BUF_ALIGN 4
944 1.1 jmcneill #define ALC_RR_RING_CNT ALC_RX_RING_CNT
945 1.1 jmcneill #define ALC_RR_RING_ALIGN sizeof(struct rx_rdesc)
946 1.1 jmcneill #define ALC_CMB_ALIGN 8
947 1.1 jmcneill #define ALC_SMB_ALIGN 8
948 1.1 jmcneill
949 1.1 jmcneill #define ALC_TSO_MAXSEGSIZE 4096
950 1.1 jmcneill #define ALC_TSO_MAXSIZE (65535 + sizeof(struct ether_vlan_header))
951 1.1 jmcneill #define ALC_MAXTXSEGS 32
952 1.1 jmcneill
953 1.1 jmcneill #define ALC_ADDR_LO(x) ((uint64_t) (x) & 0xFFFFFFFF)
954 1.1 jmcneill #define ALC_ADDR_HI(x) ((uint64_t) (x) >> 32)
955 1.1 jmcneill
956 1.1 jmcneill #define ALC_DESC_INC(x, y) ((x) = ((x) + 1) % (y))
957 1.1 jmcneill
958 1.1 jmcneill /* Water mark to kick reclaiming Tx buffers. */
959 1.1 jmcneill #define ALC_TX_DESC_HIWAT ((ALC_TX_RING_CNT * 6) / 10)
960 1.1 jmcneill
961 1.1 jmcneill #define ALC_MSI_MESSAGES 1
962 1.1 jmcneill #define ALC_MSIX_MESSAGES 1
963 1.1 jmcneill
964 1.1 jmcneill #define ALC_TX_RING_SZ \
965 1.1 jmcneill (sizeof(struct tx_desc) * ALC_TX_RING_CNT)
966 1.1 jmcneill #define ALC_RX_RING_SZ \
967 1.1 jmcneill (sizeof(struct rx_desc) * ALC_RX_RING_CNT)
968 1.1 jmcneill #define ALC_RR_RING_SZ \
969 1.1 jmcneill (sizeof(struct rx_rdesc) * ALC_RR_RING_CNT)
970 1.1 jmcneill #define ALC_CMB_SZ (sizeof(struct cmb))
971 1.1 jmcneill #define ALC_SMB_SZ (sizeof(struct smb))
972 1.1 jmcneill
973 1.1 jmcneill #define ALC_PROC_MIN 16
974 1.1 jmcneill #define ALC_PROC_MAX (ALC_RX_RING_CNT - 1)
975 1.1 jmcneill #define ALC_PROC_DEFAULT (ALC_RX_RING_CNT / 4)
976 1.1 jmcneill
977 1.1 jmcneill #define ALC_JUMBO_FRAMELEN (9 * 1024)
978 1.1 jmcneill #define ALC_JUMBO_MTU \
979 1.1 jmcneill (ALC_JUMBO_FRAMELEN - sizeof(struct ether_vlan_header) - ETHER_CRC_LEN)
980 1.1 jmcneill #define ALC_MAX_FRAMELEN (ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN)
981 1.1 jmcneill
982 1.1 jmcneill /*
983 1.1 jmcneill * The number of bits reserved for MSS in AR8121/AR8132 controllers
984 1.1 jmcneill * are 13 bits. This limits the maximum interface MTU size in TSO
985 1.1 jmcneill * case(8191 + sizeof(struct ip) + sizeof(struct tcphdr)) as upper
986 1.1 jmcneill * stack should not generate TCP segments with MSS greater than the
987 1.1 jmcneill * limit. Also Atheros says that maximum MTU for TSO is 6KB.
988 1.1 jmcneill */
989 1.1 jmcneill #define ALC_TSO_MTU (6 * 1024)
990 1.1 jmcneill
991 1.1 jmcneill struct alc_rxdesc {
992 1.1 jmcneill struct mbuf *rx_m;
993 1.1 jmcneill bus_dmamap_t rx_dmamap;
994 1.1 jmcneill struct rx_desc *rx_desc;
995 1.1 jmcneill };
996 1.1 jmcneill
997 1.1 jmcneill struct alc_txdesc {
998 1.1 jmcneill struct mbuf *tx_m;
999 1.1 jmcneill bus_dmamap_t tx_dmamap;
1000 1.1 jmcneill };
1001 1.1 jmcneill
1002 1.1 jmcneill struct alc_ring_data {
1003 1.1 jmcneill struct tx_desc *alc_tx_ring;
1004 1.1 jmcneill bus_dma_segment_t alc_tx_ring_seg;
1005 1.1 jmcneill bus_addr_t alc_tx_ring_paddr;
1006 1.1 jmcneill struct rx_desc *alc_rx_ring;
1007 1.1 jmcneill bus_dma_segment_t alc_rx_ring_seg;
1008 1.1 jmcneill bus_addr_t alc_rx_ring_paddr;
1009 1.1 jmcneill struct rx_rdesc *alc_rr_ring;
1010 1.1 jmcneill bus_dma_segment_t alc_rr_ring_seg;
1011 1.1 jmcneill bus_addr_t alc_rr_ring_paddr;
1012 1.1 jmcneill struct cmb *alc_cmb;
1013 1.1 jmcneill bus_dma_segment_t alc_cmb_seg;
1014 1.1 jmcneill bus_addr_t alc_cmb_paddr;
1015 1.1 jmcneill struct smb *alc_smb;
1016 1.1 jmcneill bus_dma_segment_t alc_smb_seg;
1017 1.1 jmcneill bus_addr_t alc_smb_paddr;
1018 1.1 jmcneill };
1019 1.1 jmcneill
1020 1.1 jmcneill struct alc_chain_data {
1021 1.1 jmcneill struct alc_txdesc alc_txdesc[ALC_TX_RING_CNT];
1022 1.1 jmcneill struct alc_rxdesc alc_rxdesc[ALC_RX_RING_CNT];
1023 1.1 jmcneill bus_dmamap_t alc_tx_ring_map;
1024 1.1 jmcneill bus_dma_segment_t alc_tx_ring_seg;
1025 1.1 jmcneill bus_dmamap_t alc_rx_ring_map;
1026 1.1 jmcneill bus_dma_segment_t alc_rx_ring_seg;
1027 1.1 jmcneill bus_dmamap_t alc_rr_ring_map;
1028 1.1 jmcneill bus_dma_segment_t alc_rr_ring_seg;
1029 1.1 jmcneill bus_dmamap_t alc_rx_sparemap;
1030 1.1 jmcneill bus_dmamap_t alc_cmb_map;
1031 1.1 jmcneill bus_dma_segment_t alc_cmb_seg;
1032 1.1 jmcneill bus_dmamap_t alc_smb_map;
1033 1.1 jmcneill bus_dma_segment_t alc_smb_seg;
1034 1.1 jmcneill
1035 1.1 jmcneill int alc_tx_prod;
1036 1.1 jmcneill int alc_tx_cons;
1037 1.1 jmcneill int alc_tx_cnt;
1038 1.1 jmcneill int alc_rx_cons;
1039 1.1 jmcneill int alc_rr_cons;
1040 1.1 jmcneill int alc_rxlen;
1041 1.1 jmcneill
1042 1.1 jmcneill struct mbuf *alc_rxhead;
1043 1.1 jmcneill struct mbuf *alc_rxtail;
1044 1.1 jmcneill struct mbuf *alc_rxprev_tail;
1045 1.1 jmcneill };
1046 1.1 jmcneill
1047 1.1 jmcneill struct alc_hw_stats {
1048 1.1 jmcneill /* Rx stats. */
1049 1.1 jmcneill uint32_t rx_frames;
1050 1.1 jmcneill uint32_t rx_bcast_frames;
1051 1.1 jmcneill uint32_t rx_mcast_frames;
1052 1.1 jmcneill uint32_t rx_pause_frames;
1053 1.1 jmcneill uint32_t rx_control_frames;
1054 1.1 jmcneill uint32_t rx_crcerrs;
1055 1.1 jmcneill uint32_t rx_lenerrs;
1056 1.1 jmcneill uint64_t rx_bytes;
1057 1.1 jmcneill uint32_t rx_runts;
1058 1.1 jmcneill uint32_t rx_fragments;
1059 1.1 jmcneill uint32_t rx_pkts_64;
1060 1.1 jmcneill uint32_t rx_pkts_65_127;
1061 1.1 jmcneill uint32_t rx_pkts_128_255;
1062 1.1 jmcneill uint32_t rx_pkts_256_511;
1063 1.1 jmcneill uint32_t rx_pkts_512_1023;
1064 1.1 jmcneill uint32_t rx_pkts_1024_1518;
1065 1.1 jmcneill uint32_t rx_pkts_1519_max;
1066 1.1 jmcneill uint32_t rx_pkts_truncated;
1067 1.1 jmcneill uint32_t rx_fifo_oflows;
1068 1.1 jmcneill uint32_t rx_rrs_errs;
1069 1.1 jmcneill uint32_t rx_alignerrs;
1070 1.1 jmcneill uint64_t rx_bcast_bytes;
1071 1.1 jmcneill uint64_t rx_mcast_bytes;
1072 1.1 jmcneill uint32_t rx_pkts_filtered;
1073 1.1 jmcneill /* Tx stats. */
1074 1.1 jmcneill uint32_t tx_frames;
1075 1.1 jmcneill uint32_t tx_bcast_frames;
1076 1.1 jmcneill uint32_t tx_mcast_frames;
1077 1.1 jmcneill uint32_t tx_pause_frames;
1078 1.1 jmcneill uint32_t tx_excess_defer;
1079 1.1 jmcneill uint32_t tx_control_frames;
1080 1.1 jmcneill uint32_t tx_deferred;
1081 1.1 jmcneill uint64_t tx_bytes;
1082 1.1 jmcneill uint32_t tx_pkts_64;
1083 1.1 jmcneill uint32_t tx_pkts_65_127;
1084 1.1 jmcneill uint32_t tx_pkts_128_255;
1085 1.1 jmcneill uint32_t tx_pkts_256_511;
1086 1.1 jmcneill uint32_t tx_pkts_512_1023;
1087 1.1 jmcneill uint32_t tx_pkts_1024_1518;
1088 1.1 jmcneill uint32_t tx_pkts_1519_max;
1089 1.1 jmcneill uint32_t tx_single_colls;
1090 1.1 jmcneill uint32_t tx_multi_colls;
1091 1.1 jmcneill uint32_t tx_late_colls;
1092 1.1 jmcneill uint32_t tx_excess_colls;
1093 1.1 jmcneill uint32_t tx_abort;
1094 1.1 jmcneill uint32_t tx_underrun;
1095 1.1 jmcneill uint32_t tx_desc_underrun;
1096 1.1 jmcneill uint32_t tx_lenerrs;
1097 1.1 jmcneill uint32_t tx_pkts_truncated;
1098 1.1 jmcneill uint64_t tx_bcast_bytes;
1099 1.1 jmcneill uint64_t tx_mcast_bytes;
1100 1.1 jmcneill };
1101 1.1 jmcneill
1102 1.1 jmcneill /*
1103 1.1 jmcneill * Software state per device.
1104 1.1 jmcneill */
1105 1.1 jmcneill struct alc_softc {
1106 1.1 jmcneill device_t sc_dev;
1107 1.1 jmcneill struct ethercom sc_ec;
1108 1.1 jmcneill
1109 1.1 jmcneill bus_space_tag_t sc_mem_bt;
1110 1.1 jmcneill bus_space_handle_t sc_mem_bh;
1111 1.1 jmcneill bus_size_t sc_mem_size;
1112 1.1 jmcneill bus_dma_tag_t sc_dmat;
1113 1.1 jmcneill pci_chipset_tag_t sc_pct;
1114 1.1 jmcneill pcitag_t sc_pcitag;
1115 1.1 jmcneill
1116 1.1 jmcneill void *sc_irq_handle;
1117 1.1 jmcneill
1118 1.1 jmcneill struct mii_data sc_miibus;
1119 1.1 jmcneill int alc_rev;
1120 1.1 jmcneill int alc_chip_rev;
1121 1.1 jmcneill int alc_phyaddr;
1122 1.1 jmcneill uint8_t alc_eaddr[ETHER_ADDR_LEN];
1123 1.1 jmcneill uint32_t alc_dma_rd_burst;
1124 1.1 jmcneill uint32_t alc_dma_wr_burst;
1125 1.1 jmcneill uint32_t alc_rcb;
1126 1.1 jmcneill int alc_flags;
1127 1.1 jmcneill #define ALC_FLAG_PCIE 0x0001
1128 1.1 jmcneill #define ALC_FLAG_PCIX 0x0002
1129 1.1 jmcneill #define ALC_FLAG_MSI 0x0004
1130 1.1 jmcneill #define ALC_FLAG_MSIX 0x0008
1131 1.1 jmcneill #define ALC_FLAG_FASTETHER 0x0020
1132 1.1 jmcneill #define ALC_FLAG_JUMBO 0x0040
1133 1.1 jmcneill #define ALC_FLAG_ASPM_MON 0x0080
1134 1.1 jmcneill #define ALC_FLAG_CMB_BUG 0x0100
1135 1.1 jmcneill #define ALC_FLAG_SMB_BUG 0x0200
1136 1.1 jmcneill #define ALC_FLAG_DETACH 0x4000
1137 1.1 jmcneill #define ALC_FLAG_LINK 0x8000
1138 1.1 jmcneill
1139 1.1 jmcneill callout_t sc_tick_ch;
1140 1.1 jmcneill struct alc_hw_stats alc_stats;
1141 1.1 jmcneill struct alc_chain_data alc_cdata;
1142 1.1 jmcneill struct alc_ring_data alc_rdata;
1143 1.1 jmcneill int alc_int_rx_mod;
1144 1.1 jmcneill int alc_int_tx_mod;
1145 1.1 jmcneill int alc_buf_size;
1146 1.1 jmcneill };
1147 1.1 jmcneill
1148 1.1 jmcneill /* Register access macros. */
1149 1.1 jmcneill #define CSR_WRITE_4(_sc, reg, val) \
1150 1.1 jmcneill bus_space_write_4((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg), (val))
1151 1.1 jmcneill #define CSR_WRITE_2(_sc, reg, val) \
1152 1.1 jmcneill bus_space_write_2((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg), (val))
1153 1.1 jmcneill #define CSR_WRITE_1(_sc, reg, val) \
1154 1.1 jmcneill bus_space_write_1((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg), (val))
1155 1.1 jmcneill #define CSR_READ_2(_sc, reg) \
1156 1.1 jmcneill bus_space_read_2((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg))
1157 1.1 jmcneill #define CSR_READ_4(_sc, reg) \
1158 1.1 jmcneill bus_space_read_4((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg))
1159 1.1 jmcneill
1160 1.1 jmcneill #define ALC_RXCHAIN_RESET(_sc) \
1161 1.1 jmcneill do { \
1162 1.1 jmcneill (_sc)->alc_cdata.alc_rxhead = NULL; \
1163 1.1 jmcneill (_sc)->alc_cdata.alc_rxtail = NULL; \
1164 1.1 jmcneill (_sc)->alc_cdata.alc_rxprev_tail = NULL; \
1165 1.1 jmcneill (_sc)->alc_cdata.alc_rxlen = 0; \
1166 1.1 jmcneill } while (0)
1167 1.1 jmcneill
1168 1.1 jmcneill #define ALC_TX_TIMEOUT 5
1169 1.1 jmcneill #define ALC_RESET_TIMEOUT 100
1170 1.1 jmcneill #define ALC_TIMEOUT 1000
1171 1.1 jmcneill #define ALC_PHY_TIMEOUT 1000
1172 1.1 jmcneill
1173 1.1 jmcneill #endif /* _IF_ALCREG_H */
1174