xref: /illumos-gate/usr/src/uts/common/io/atge/atge_l1e_reg.h (revision abdf5d9abf528d6c318fd8533e09bc3cac1f228b)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _ATGE_L1E_REG_H
27 #define	_ATGE_L1E_REG_H
28 
29 #ifdef __cplusplus
30 	extern "C" {
31 #endif
32 
33 /*
34  * Number of RX Rings (or pages) we use.
35  */
36 #define	L1E_RX_PAGES		2
37 
38 #pragma	pack(1)
39 typedef	struct	rx_rs	{
40 	uint32_t	seqno;
41 	uint32_t	length;
42 	uint32_t	flags;
43 	uint32_t	vtags;
44 } rx_rs_t;
45 
46 typedef	struct	rx_cmb {
47 	uint32_t	cmb[L1E_RX_PAGES];
48 } rx_cmb_t;
49 
50 typedef	struct	atge_l1e_tx_desc {
51 	uint64_t	addr;
52 	uint32_t	len;
53 	uint32_t	flags;
54 } atge_l1e_tx_desc_t;
55 #pragma	pack()
56 
57 /*
58  * DMA CFG registers (L1E specific).
59  */
60 #define	DMA_CFG_RD_REQ_PRI		0x00000400
61 #define	DMA_CFG_RD_DELAY_CNT_MASK	0x0000F800
62 #define	DMA_CFG_WR_DELAY_CNT_MASK	0x000F0000
63 #define	DMA_CFG_TXCMB_ENB		0x00100000
64 #define	DMA_CFG_RXCMB_ENB		0x00200000
65 #define	DMA_CFG_RD_BURST_MASK		0x07
66 #define	DMA_CFG_RD_BURST_SHIFT		4
67 #define	DMA_CFG_WR_BURST_MASK		0x07
68 #define	DMA_CFG_WR_BURST_SHIFT		7
69 #define	DMA_CFG_RD_DELAY_CNT_SHIFT	11
70 #define	DMA_CFG_WR_DELAY_CNT_SHIFT	16
71 #define	DMA_CFG_RD_DELAY_CNT_DEFAULT	15
72 #define	DMA_CFG_WR_DELAY_CNT_DEFAULT	4
73 
74 #define	L1E_TX_RING_CNT			256	/* Should be multiple of 4. */
75 #define	L1E_TX_RING_CNT_MIN		32
76 #define	L1E_TX_RING_CNT_MAX		1020
77 #define	L1E_TX_RING_ALIGN		8
78 #define	L1E_RX_PAGE_ALIGN		32
79 #define	L1E_CMB_ALIGN			32
80 #define	L1E_MAX_FRAMELEN		ETHERMAX
81 
82 #define	L1E_TX_RING_SZ	\
83 	(sizeof (struct atge_l1e_tx_desc) * L1E_TX_RING_CNT)
84 #define	L1E_RX_PAGE_SZ_MIN		(8 * 1024)
85 #define	L1E_RX_PAGE_SZ_MAX		(1024 * 1024)
86 #define	L1E_RX_FRAMES_PAGE		128
87 #define	L1E_RX_PAGE_SZ	\
88 	(ROUNDUP(L1E_MAX_FRAMELEN, L1E_RX_PAGE_ALIGN) * L1E_RX_FRAMES_PAGE)
89 #define	L1E_TX_CMB_SZ			(sizeof (uint32_t))
90 #define	L1E_RX_CMB_SZ			(sizeof (uint32_t))
91 
92 #define	L1E_PROC_MAX	\
93 	((L1E_RX_PAGE_SZ * L1E_RX_PAGES) / ETHERMAX)
94 #define	L1E_PROC_DEFAULT		(L1E_PROC_MAX / 4)
95 
96 #define	L1E_INTRS                                               \
97 	(INTR_DMA_RD_TO_RST | INTR_DMA_WR_TO_RST |              \
98 	INTR_RX_PKT | INTR_TX_PKT | INTR_RX_FIFO_OFLOW |        \
99 	INTR_TX_FIFO_UNDERRUN | INTR_SMB)
100 
101 #define	L1E_RSS_IDT_TABLE0		0x1560
102 #define	L1E_RSS_CPU			0x157C
103 
104 #define	L1E_SRAM_RX_FIFO_LEN		0x1524
105 
106 #define	L1E_PHY_STATUS			0x1418
107 #define	PHY_STATUS_100M			0x00020000
108 
109 #define	L1E_SMB_STAT_TIMER		0x15C4
110 
111 #define	L1E_GPHY_CTRL			0x140C	/* 16-bits */
112 #define	GPHY_CTRL_EXT_RESET		0x0001
113 #define	GPHY_CTRL_PIPE_MOD		0x0002
114 #define	GPHY_CTRL_BERT_START		0x0010
115 #define	GPHY_CTRL_GL1E_25M_ENB		0x0020
116 #define	GPHY_CTRL_LPW_EXIT		0x0040
117 #define	GPHY_CTRL_PHY_IDDQ		0x0080
118 #define	GPHY_CTRL_PHY_IDDQ_DIS		0x0100
119 #define	GPHY_CTRL_PCLK_SEL_DIS		0x0200
120 #define	GPHY_CTRL_HIB_EN		0x0400
121 #define	GPHY_CTRL_HIB_PULSE		0x0800
122 #define	GPHY_CTRL_SEL_ANA_RESET		0x1000
123 #define	GPHY_CTRL_PHY_PLL_ON		0x2000
124 #define	GPHY_CTRL_PWDOWN_HW		0x4000
125 
126 #define	RXF_VALID			0x01
127 
128 #define	L1E_RXF0_PAGE0			0x15F4
129 #define	L1E_RXF0_PAGE1			0x15F5
130 
131 #define	L1E_RXF0_PAGE0_ADDR_LO		0x1544
132 #define	L1E_RXF0_PAGE1_ADDR_LO		0x1548
133 
134 #define	L1E_RXF_PAGE_SIZE		0x1558
135 
136 #define	L1E_INT_TRIG_THRESH		0x15C8
137 #define	INT_TRIG_TX_THRESH_MASK		0x0000FFFF
138 #define	INT_TRIG_RX_THRESH_MASK		0xFFFF0000
139 #define	INT_TRIG_TX_THRESH_SHIFT	0
140 #define	INT_TRIG_RX_THRESH_SHIFT	16
141 
142 #define	L1E_INT_TRIG_TIMER		0x15CC
143 #define	INT_TRIG_TX_TIMER_MASK		0x0000FFFF
144 #define	INT_TRIG_RX_TIMER_MASK		0x0000FFFF
145 #define	INT_TRIG_TX_TIMER_SHIFT		0
146 #define	INT_TRIG_RX_TIMER_SHIFT		16
147 
148 #define	TX_COALSC_PKT_1e		0x15C8  /* W: L1E */
149 #define	RX_COALSC_PKT_1e		0x15CA  /* W: L1E */
150 #define	TX_COALSC_TO_1e			0x15CC  /* W: L1E */
151 #define	RX_COALSC_TO_1e			0x15CE  /* W: L1E */
152 
153 #define	L1E_HOST_RXF0_PAGEOFF		0x1800
154 #define	L1E_TPD_CONS_IDX		0x1804
155 #define	L1E_HOST_RXF1_PAGEOFF		0x1808
156 #define	L1E_HOST_RXF2_PAGEOFF		0x180C
157 #define	L1E_HOST_RXF3_PAGEOFF		0x1810
158 #define	L1E_RXF0_CMB0_ADDR_LO		0x1820
159 #define	L1E_RXF0_CMB1_ADDR_LO		0x1824
160 #define	L1E_RXF1_CMB0_ADDR_LO		0x1828
161 #define	L1E_RXF1_CMB1_ADDR_LO		0x182C
162 #define	L1E_RXF2_CMB0_ADDR_LO		0x1830
163 #define	L1E_RXF2_CMB1_ADDR_LO		0x1834
164 #define	L1E_RXF3_CMB0_ADDR_LO		0x1838
165 #define	L1E_RXF3_CMB1_ADDR_LO		0x183C
166 #define	L1E_TX_CMB_ADDR_LO		0x1840
167 #define	L1E_SMB_ADDR_LO			0x1844
168 
169 #define	L1E_ISR_GPHY			0x00001000U
170 #define	L1E_ISR_ACK_GPHY		19
171 
172 
173 #define	L1E_RD_SEQNO_MASK		0x0000FFFF
174 #define	L1E_RD_HASH_MASK		0xFFFF0000
175 #define	L1E_RD_SEQNO_SHIFT		0
176 #define	L1E_RD_HASH_SHIFT		16
177 #define	L1E_RX_SEQNO(x)		\
178 	(((x) & L1E_RD_SEQNO_MASK) >> L1E_RD_SEQNO_SHIFT)
179 #define	L1E_RD_CSUM_MASK		0x0000FFFF
180 #define	L1E_RD_LEN_MASK			0x3FFF0000
181 #define	L1E_RD_CPU_MASK			0xC0000000
182 #define	L1E_RD_CSUM_SHIFT		0
183 #define	L1E_RD_LEN_SHIFT		16
184 #define	L1E_RD_CPU_SHIFT		30
185 #define	L1E_RX_CSUM(x)	\
186 	(((x) & L1E_RD_CSUM_MASK) >> L1E_RD_CSUM_SHIFT)
187 #define	L1E_RX_BYTES(x)	\
188 	(((x) & L1E_RD_LEN_MASK) >> L1E_RD_LEN_SHIFT)
189 #define	L1E_RX_CPU(x)	\
190 	(((x) & L1E_RD_CPU_MASK) >> L1E_RD_CPU_SHIFT)
191 
192 #define	L1E_RD_RSS_IPV4			0x00000001
193 #define	L1E_RD_RSS_IPV4_TCP		0x00000002
194 #define	L1E_RD_RSS_IPV6			0x00000004
195 #define	L1E_RD_RSS_IPV6_TCP		0x00000008
196 #define	L1E_RD_IPV6			0x00000010
197 #define	L1E_RD_IPV4_FRAG		0x00000020
198 #define	L1E_RD_IPV4_DF			0x00000040
199 #define	L1E_RD_802_3			0x00000080
200 #define	L1E_RD_VLAN			0x00000100
201 #define	L1E_RD_ERROR			0x00000200
202 #define	L1E_RD_IPV4			0x00000400
203 #define	L1E_RD_UDP			0x00000800
204 #define	L1E_RD_TCP			0x00001000
205 #define	L1E_RD_BCAST			0x00002000
206 #define	L1E_RD_MCAST			0x00004000
207 #define	L1E_RD_PAUSE			0x00008000
208 #define	L1E_RD_CRC			0x00010000
209 #define	L1E_RD_CODE			0x00020000
210 #define	L1E_RD_DRIBBLE			0x00040000
211 #define	L1E_RD_RUNT			0x00080000
212 #define	L1E_RD_OFLOW			0x00100000
213 #define	L1E_RD_TRUNC			0x00200000
214 #define	L1E_RD_IPCSUM_NOK		0x00400000
215 #define	L1E_RD_TCP_UDPCSUM_NOK		0x00800000
216 #define	L1E_RD_LENGTH_NOK		0x01000000
217 #define	L1E_RD_DES_ADDR_FILTERED	0x02000000
218 
219 /* TX descriptor fields */
220 #define	L1E_TD_VLAN_MASK		0xFFFF0000
221 #define	L1E_TD_PKT_INT			0x00008000
222 #define	L1E_TD_DMA_INT			0x00004000
223 #define	L1E_TD_BUFLEN_MASK		0x00003FFF
224 #define	L1E_TD_VLAN_SHIFT		16
225 #define	L1E_TX_VLAN_TAG(x)	\
226 	(((x) << 4) | ((x) >> 13) | (((x) >> 9) & 8))
227 #define	L1E_TD_BUFLEN_SHIFT		0
228 #define	L1E_TX_BYTES(x)		\
229 	(((x) << L1E_TD_BUFLEN_SHIFT) & L1E_TD_BUFLEN_MASK)
230 #define	L1E_TD_MSS			0xFFF80000
231 #define	L1E_TD_TSO_HDR			0x00040000
232 #define	L1E_TD_TCPHDR_LEN		0x0003C000
233 #define	L1E_TD_IPHDR_LEN		0x00003C00
234 #define	L1E_TD_IPV6HDR_LEN2		0x00003C00
235 #define	L1E_TD_LLC_SNAP			0x00000200
236 #define	L1E_TD_VLAN_TAGGED		0x00000100
237 #define	L1E_TD_UDPCSUM			0x00000080
238 #define	L1E_TD_TCPCSUM			0x00000040
239 #define	L1E_TD_IPCSUM			0x00000020
240 #define	L1E_TD_IPV6HDR_LEN1		0x000000E0
241 #define	L1E_TD_TSO			0x00000010
242 #define	L1E_TD_CXSUM			0x00000008
243 #define	L1E_TD_INSERT_VLAN_TAG		0x00000004
244 #define	L1E_TD_IPV6			0x00000002
245 #define	L1E_TD_EOP			0x00000001
246 
247 #define	L1E_TD_CSUM_PLOADOFFSET		0x00FF0000
248 #define	L1E_TD_CSUM_XSUMOFFSET		0xFF000000
249 #define	L1E_TD_CSUM_XSUMOFFSET_SHIFT	24
250 #define	L1E_TD_CSUM_PLOADOFFSET_SHIFT	16
251 #define	L1E_TD_MSS_SHIFT		19
252 #define	L1E_TD_TCPHDR_LEN_SHIFT		14
253 #define	L1E_TD_IPHDR_LEN_SHIFT		10
254 
255 #define	L1E_JUMBO_FRAMELEN		8132
256 
257 #define	L1E_TX_JUMBO_THRESH		0x1584
258 #define	TX_JUMBO_THRESH_MASK		0x000007FF
259 #define	TX_JUMBO_THRESH_SHIFT		0
260 #define	TX_JUMBO_THRESH_UNIT		8
261 #define	TX_JUMBO_THRESH_UNIT_SHIFT	3
262 
263 /*
264  * Statistics counters collected by the MAC.
265  * AR81xx requires register access to get MAC statistics
266  * and the format of statistics seems to be the same of L1
267  * except for tx_abort field in TX stats. So keep it separate for simplicity.
268  */
269 #define	L1E_RX_MIB_BASE			0x1700
270 #define	L1E_TX_MIB_BASE			0x1760
271 
272 #pragma	pack(1)
273 typedef	struct smb {
274 	/* Rx stats. */
275 	uint32_t rx_frames;
276 	uint32_t rx_bcast_frames;
277 	uint32_t rx_mcast_frames;
278 	uint32_t rx_pause_frames;
279 	uint32_t rx_control_frames;
280 	uint32_t rx_crcerrs;
281 	uint32_t rx_lenerrs;
282 	uint32_t rx_bytes;
283 	uint32_t rx_runts;
284 	uint32_t rx_fragments;
285 	uint32_t rx_pkts_64;
286 	uint32_t rx_pkts_65_127;
287 	uint32_t rx_pkts_128_255;
288 	uint32_t rx_pkts_256_511;
289 	uint32_t rx_pkts_512_1023;
290 	uint32_t rx_pkts_1024_1518;
291 	uint32_t rx_pkts_1519_max;
292 	uint32_t rx_pkts_truncated;
293 	uint32_t rx_fifo_oflows;
294 	uint32_t rx_rrs_errs;
295 	uint32_t rx_alignerrs;
296 	uint32_t rx_bcast_bytes;
297 	uint32_t rx_mcast_bytes;
298 	uint32_t rx_pkts_filtered;
299 	/* Tx stats. */
300 	uint32_t tx_frames;
301 	uint32_t tx_bcast_frames;
302 	uint32_t tx_mcast_frames;
303 	uint32_t tx_pause_frames;
304 	uint32_t tx_excess_defer;
305 	uint32_t tx_control_frames;
306 	uint32_t tx_deferred;
307 	uint32_t tx_bytes;
308 	uint32_t tx_pkts_64;
309 	uint32_t tx_pkts_65_127;
310 	uint32_t tx_pkts_128_255;
311 	uint32_t tx_pkts_256_511;
312 	uint32_t tx_pkts_512_1023;
313 	uint32_t tx_pkts_1024_1518;
314 	uint32_t tx_pkts_1519_max;
315 	uint32_t tx_single_colls;
316 	uint32_t tx_multi_colls;
317 	uint32_t tx_late_colls;
318 	uint32_t tx_excess_colls;
319 	uint32_t tx_abort;
320 	uint32_t tx_underrun;
321 	uint32_t tx_desc_underrun;
322 	uint32_t tx_lenerrs;
323 	uint32_t tx_pkts_truncated;
324 	uint32_t tx_bcast_bytes;
325 	uint32_t tx_mcast_bytes;
326 } atge_l1e_smb_t;
327 #pragma	pack()
328 
329 #ifdef __cplusplus
330 }
331 #endif
332 
333 #endif	/* _ATGE_L1E_REG_H */
334