xref: /freebsd/sys/dev/ae/if_aereg.h (revision 62cfcf62f627e5093fb37026a6d8c98e4d2ef04c)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2008 Stanislav Sedov <stas@FreeBSD.org>.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * $FreeBSD$
28  */
29 
30 /*
31  * Master configuration register
32  */
33 #define	AE_MASTER_REG		0x1400
34 
35 #define	AE_MASTER_SOFT_RESET	0x1	/* Reset adapter. */
36 #define	AE_MASTER_MTIMER_EN	0x2	/* Unknown. */
37 #define	AE_MASTER_IMT_EN	0x4	/* Interrupt moderation timer enable. */
38 #define	AE_MASTER_MANUAL_INT	0x8	/* Software manual interrupt. */
39 #define	AE_MASTER_REVNUM_SHIFT	16	/* Chip revision number. */
40 #define	AE_MASTER_REVNUM_MASK	0xff
41 #define	AE_MASTER_DEVID_SHIFT	24	/* PCI device id. */
42 #define	AE_MASTER_DEVID_MASK	0xff
43 
44 /*
45  * Interrupt status register
46  */
47 #define	AE_ISR_REG		0x1600
48 #define	AE_ISR_TIMER		0x00000001	/* Counter expired. */
49 #define	AE_ISR_MANUAL		0x00000002	/* Manual interrupt occuried. */
50 #define	AE_ISR_RXF_OVERFLOW	0x00000004	/* RxF overflow occuried. */
51 #define	AE_ISR_TXF_UNDERRUN	0x00000008	/* TxF underrun occuried. */
52 #define	AE_ISR_TXS_OVERFLOW	0x00000010	/* TxS overflow occuried. */
53 #define	AE_ISR_RXS_OVERFLOW	0x00000020	/* Internal RxS ring overflow. */
54 #define	AE_ISR_LINK_CHG		0x00000040	/* Link state changed. */
55 #define	AE_ISR_TXD_UNDERRUN	0x00000080	/* TxD underrun occuried. */
56 #define	AE_ISR_RXD_OVERFLOW	0x00000100	/* RxD overflow occuried. */
57 #define	AE_ISR_DMAR_TIMEOUT	0x00000200	/* DMA read timeout. */
58 #define	AE_ISR_DMAW_TIMEOUT	0x00000400	/* DMA write timeout. */
59 #define	AE_ISR_PHY		0x00000800	/* PHY interrupt. */
60 #define	AE_ISR_TXS_UPDATED	0x00010000	/* Tx status updated. */
61 #define	AE_ISR_RXD_UPDATED	0x00020000	/* Rx status updated. */
62 #define	AE_ISR_TX_EARLY		0x00040000	/* TxMAC started transmit. */
63 #define	AE_ISR_FIFO_UNDERRUN	0x01000000	/* FIFO underrun. */
64 #define	AE_ISR_FRAME_ERROR	0x02000000	/* Frame receive error. */
65 #define	AE_ISR_FRAME_SUCCESS	0x04000000	/* Frame receive success. */
66 #define	AE_ISR_CRC_ERROR	0x08000000	/* CRC error occuried. */
67 #define	AE_ISR_PHY_LINKDOWN	0x10000000	/* PHY link down. */
68 #define	AE_ISR_DISABLE		0x80000000	/* Disable interrupts. */
69 
70 #define	AE_ISR_TX_EVENT		(AE_ISR_TXF_UNDERRUN | AE_ISR_TXS_OVERFLOW | \
71 				 AE_ISR_TXD_UNDERRUN | AE_ISR_TXS_UPDATED | \
72 				 AE_ISR_TX_EARLY)
73 #define	AE_ISR_RX_EVENT		(AE_ISR_RXF_OVERFLOW | AE_ISR_RXS_OVERFLOW | \
74 				 AE_ISR_RXD_OVERFLOW | AE_ISR_RXD_UPDATED)
75 
76 /* Interrupt mask register. */
77 #define	AE_IMR_REG		0x1604
78 
79 #define	AE_IMR_DEFAULT		(AE_ISR_DMAR_TIMEOUT | AE_ISR_DMAW_TIMEOUT | \
80 				 AE_ISR_PHY_LINKDOWN | \
81 				 AE_ISR_TXS_UPDATED | AE_ISR_RXD_UPDATED )
82 
83 /*
84  * Ethernet address register.
85  */
86 #define	AE_EADDR0_REG		0x1488	/* 5 - 2 bytes */
87 #define	AE_EADDR1_REG		0x148c	/* 1 - 0 bytes */
88 
89 /*
90  * Desriptor rings registers.
91  * L2 supports 64-bit addressing but all rings base addresses
92  * should have the same high 32 bits of address.
93  */
94 #define	AE_DESC_ADDR_HI_REG	0x1540	/* High 32 bits of ring base address. */
95 #define	AE_RXD_ADDR_LO_REG	0x1554	/* Low 32 bits of RxD ring address. */
96 #define	AE_TXD_ADDR_LO_REG	0x1544	/* Low 32 bits of TxD ring address. */
97 #define	AE_TXS_ADDR_LO_REG	0x154c	/* Low 32 bits of TxS ring address. */
98 #define	AE_RXD_COUNT_REG	0x1558	/* Number of RxD descriptors in ring.
99 					   Should be 120-byte aligned (i.e.
100 					   the 'data' field of RxD should
101 					   have 128-byte alignment). */
102 #define	AE_TXD_BUFSIZE_REG	0x1548	/* Size of TxD ring in 4-byte units.
103 					   Should be 4-byte aligned. */
104 #define	AE_TXS_COUNT_REG	0x1550	/* Number of TxS descriptors in ring.
105 					   4 byte alignment. */
106 #define	AE_RXD_COUNT_MIN	16
107 #define	AE_RXD_COUNT_MAX	512
108 #define	AE_RXD_COUNT_DEFAULT	64
109 /* Padding to align frames on a 128-byte boundary. */
110 #define	AE_RXD_PADDING		120
111 
112 #define	AE_TXD_BUFSIZE_MIN	4096
113 #define	AE_TXD_BUFSIZE_MAX	65536
114 #define	AE_TXD_BUFSIZE_DEFAULT	8192
115 
116 #define	AE_TXS_COUNT_MIN	8	/* Not sure. */
117 #define	AE_TXS_COUNT_MAX	160
118 #define	AE_TXS_COUNT_DEFAULT	64	/* AE_TXD_BUFSIZE_DEFAULT / 128 */
119 
120 /*
121  * Inter-frame gap configuration register.
122  */
123 #define	AE_IFG_REG		0x1484
124 
125 #define	AE_IFG_TXIPG_DEFAULT	0x60	/* 96-bit IFG time. */
126 #define	AE_IFG_TXIPG_SHIFT	0
127 #define	AE_IFG_TXIPG_MASK	0x7f
128 
129 #define	AE_IFG_RXIPG_DEFAULT	0x50	/* 80-bit IFG time. */
130 #define	AE_IFG_RXIPG_SHIFT	8
131 #define	AE_IFG_RXIPG_MASK	0xff00
132 
133 #define	AE_IFG_IPGR1_DEFAULT	0x40	/* Carrier-sense window. */
134 #define	AE_IFG_IPGR1_SHIFT	16
135 #define	AE_IFG_IPGR1_MASK	0x7f0000
136 
137 #define	AE_IFG_IPGR2_DEFAULT	0x60	/* IFG window. */
138 #define	AE_IFG_IPGR2_SHIFT	24
139 #define	AE_IFG_IPGR2_MASK	0x7f000000
140 
141 /*
142  * Half-duplex mode configuration register.
143  */
144 #define	AE_HDPX_REG		0x1498
145 
146 /* Collision window. */
147 #define	AE_HDPX_LCOL_SHIFT	0
148 #define	AE_HDPX_LCOL_MASK	0x000003ff
149 #define	AE_HDPX_LCOL_DEFAULT	0x37
150 
151 /* Max retransmission time, after that the packet will be discarded. */
152 #define	AE_HDPX_RETRY_SHIFT	12
153 #define	AE_HDPX_RETRY_MASK	0x0000f000
154 #define	AE_HDPX_RETRY_DEFAULT	0x0f
155 
156 /* Alternative binary exponential back-off time. */
157 #define	AE_HDPX_ABEBT_SHIFT	20
158 #define	AE_HDPX_ABEBT_MASK	0x00f00000
159 #define	AE_HDPX_ABEBT_DEFAULT	0x0a
160 
161 /* IFG to start JAM for collision based flow control (8-bit time units).*/
162 #define	AE_HDPX_JAMIPG_SHIFT	24
163 #define	AE_HDPX_JAMIPG_MASK	0x0f000000
164 #define	AE_HDPX_JAMIPG_DEFAULT	0x07
165 
166 /* Allow the transmission of a packet which has been excessively deferred. */
167 #define	AE_HDPX_EXC_EN		0x00010000
168 /* No back-off on collision, immediately start the retransmission. */
169 #define	AE_HDPX_NO_BACK_C	0x00020000
170 /* No back-off on backpressure, immediately start the transmission. */
171 #define	AE_HDPX_NO_BACK_P	0x00040000
172 /* Alternative binary exponential back-off enable. */
173 #define	AE_HDPX_ABEBE		0x00080000
174 
175 /*
176  * Interrupt moderation timer configuration register.
177  */
178 #define	AE_IMT_REG		0x1408	/* Timer value in 2 us units. */
179 #define	AE_IMT_MAX		65000
180 #define	AE_IMT_MIN		50
181 #define	AE_IMT_DEFAULT		100	/* 200 microseconds. */
182 
183 /*
184  * Interrupt clearing timer configuration register.
185  */
186 #define	AE_ICT_REG		0x140e	/* Maximum time allowed to clear
187 					   interrupt. In 2 us units.  */
188 #define	AE_ICT_DEFAULT		50000	/* 100ms */
189 
190 /*
191  * MTU configuration register.
192  */
193 #define	AE_MTU_REG		0x149c	/* MTU size in bytes. */
194 
195 /*
196  * Cut-through configuration register.
197  */
198 #define	AE_CUT_THRESH_REG	0x1590	/* Cut-through threshold in unknown units. */
199 #define	AE_CUT_THRESH_DEFAULT   0x177
200 
201 /*
202  * Flow-control configuration registers.
203  */
204 #define	AE_FLOW_THRESH_HI_REG	0x15a8	/* High watermark of RxD
205 					   overflow threshold. */
206 #define	AE_FLOW_THRESH_LO_REG	0x15aa	/* Lower watermark of RxD
207 					   overflow threshold */
208 
209 /*
210  * Mailbox configuration registers.
211 */
212 #define	AE_MB_TXD_IDX_REG	0x15f0	/* TxD read index. */
213 #define	AE_MB_RXD_IDX_REG	0x15f4	/* RxD write index. */
214 
215 /*
216  * DMA configuration registers.
217  */
218 #define	AE_DMAREAD_REG		0x1580	/* Read DMA configuration register. */
219 #define	AE_DMAREAD_EN		1
220 #define	AE_DMAWRITE_REG		0x15a0	/* Write DMA configuration register. */
221 #define	AE_DMAWRITE_EN		1
222 
223 /*
224  * MAC configuration register.
225  */
226 #define	AE_MAC_REG		0x1480
227 
228 #define	AE_MAC_TX_EN		0x00000001	/* Enable transmit. */
229 #define	AE_MAC_RX_EN		0x00000002	/* Enable receive. */
230 #define	AE_MAC_TX_FLOW_EN	0x00000004	/* Enable Tx flow control. */
231 #define	AE_MAC_RX_FLOW_EN	0x00000008	/* Enable Rx flow control. */
232 #define	AE_MAC_LOOPBACK		0x00000010	/* Loopback at MII. */
233 #define	AE_MAC_FULL_DUPLEX	0x00000020	/* Enable full-duplex. */
234 #define	AE_MAC_TX_CRC_EN	0x00000040	/* Enable CRC generation. */
235 #define	AE_MAC_TX_AUTOPAD	0x00000080	/* Pad short frames. */
236 #define	AE_MAC_PREAMBLE_MASK	0x00003c00	/* Preamble length. */
237 #define	AE_MAC_PREAMBLE_SHIFT	10
238 #define	AE_MAC_PREAMBLE_DEFAULT	0x07		/* By standard. */
239 #define	AE_MAC_RMVLAN_EN	0x00004000	/* Remove VLAN tags in
240 						   incoming packets. */
241 #define	AE_MAC_PROMISC_EN	0x00008000	/* Enable promiscue mode. */
242 #define	AE_MAC_TX_MAXBACKOFF	0x00100000	/* Unknown. */
243 #define	AE_MAC_MCAST_EN		0x02000000	/* Pass all multicast frames. */
244 #define	AE_MAC_BCAST_EN		0x04000000	/* Pass all broadcast frames. */
245 #define	AE_MAC_CLK_PHY		0x08000000	/* If 1 uses loopback clock
246 						   PHY, if 0 - system clock. */
247 #define	AE_HALFBUF_MASK		0xf0000000	/* Half-duplex retry buffer. */
248 #define	AE_HALFBUF_SHIFT	28
249 #define	AE_HALFBUF_DEFAULT	2		/* XXX: From Linux. */
250 
251 /*
252  * MDIO control register.
253  */
254 #define	AE_MDIO_REG		0x1414
255 #define	AE_MDIO_DATA_MASK	0xffff
256 #define	AE_MDIO_DATA_SHIFT	0
257 #define	AE_MDIO_REGADDR_MASK	0x1f0000
258 #define	AE_MDIO_REGADDR_SHIFT	16
259 #define	AE_MDIO_READ		0x00200000	/* Read operation. */
260 #define	AE_MDIO_SUP_PREAMBLE	0x00400000	/* Suppress preamble. */
261 #define	AE_MDIO_START		0x00800000	/* Initiate MDIO transfer. */
262 #define	AE_MDIO_CLK_SHIFT	24		/* Clock selection. */
263 #define	AE_MDIO_CLK_MASK	0x07000000	/* Clock selection. */
264 #define	AE_MDIO_CLK_25_4	0		/* Dividers? */
265 #define	AE_MDIO_CLK_25_6	2
266 #define	AE_MDIO_CLK_25_8	3
267 #define	AE_MDIO_CLK_25_10	4
268 #define	AE_MDIO_CLK_25_14	5
269 #define	AE_MDIO_CLK_25_20	6
270 #define	AE_MDIO_CLK_25_28	7
271 #define	AE_MDIO_BUSY		0x08000000	/* MDIO is busy. */
272 
273 /*
274  * Idle status register.
275  */
276 #define	AE_IDLE_REG		0x1410
277 
278 /*
279  * Idle status bits.
280  * If bit is set then the corresponding module is in non-idle state.
281  */
282 #define	AE_IDLE_RXMAC		1
283 #define	AE_IDLE_TXMAC		2
284 #define	AE_IDLE_DMAREAD		8
285 #define	AE_IDLE_DMAWRITE	4
286 
287 /*
288  * Multicast hash tables registers.
289  */
290 #define	AE_REG_MHT0		0x1490
291 #define	AE_REG_MHT1		0x1494
292 
293 /*
294  * Wake on lan (WOL).
295  */
296 #define	AE_WOL_REG		0x14a0
297 #define	AE_WOL_MAGIC		0x00000004
298 #define	AE_WOL_MAGIC_PME	0x00000008
299 #define	AE_WOL_LNKCHG		0x00000010
300 #define	AE_WOL_LNKCHG_PME	0x00000020
301 
302 /*
303  * PCIE configuration registers. Descriptions unknown.
304  */
305 #define	AE_PCIE_LTSSM_TESTMODE_REG	0x12fc
306 #define	AE_PCIE_LTSSM_TESTMODE_DEFAULT	0x6500
307 #define	AE_PCIE_DLL_TX_CTRL_REG		0x1104
308 #define	AE_PCIE_DLL_TX_CTRL_SEL_NOR_CLK	0x0400
309 #define	AE_PCIE_DLL_TX_CTRL_DEFAULT	0x0568
310 #define	AE_PCIE_PHYMISC_REG		0x1000
311 #define	AE_PCIE_PHYMISC_FORCE_RCV_DET	0x4
312 
313 /*
314  * PHY enable register.
315  */
316 #define	AE_PHY_ENABLE_REG	0x140c
317 #define	AE_PHY_ENABLE		1
318 
319 /*
320  * VPD registers.
321  */
322 #define	AE_VPD_CAP_REG		0x6c	/* Command register. */
323 #define	AE_VPD_CAP_ID_MASK	0xff
324 #define	AE_VPD_CAP_ID_SHIFT	0
325 #define	AE_VPD_CAP_NEXT_MASK	0xff00
326 #define	AE_VPD_CAP_NEXT_SHIFT	8
327 #define	AE_VPD_CAP_ADDR_MASK	0x7fff0000
328 #define	AE_VPD_CAP_ADDR_SHIFT	16
329 #define	AE_VPD_CAP_DONE		0x80000000
330 
331 #define	AE_VPD_DATA_REG		0x70	/* Data register. */
332 
333 #define	AE_VPD_NREGS		64	/* Maximum number of VPD regs. */
334 #define	AE_VPD_SIG_MASK		0xff
335 #define	AE_VPD_SIG		0x5a	/* VPD block signature. */
336 #define	AE_VPD_REG_SHIFT	16	/* Register id offset. */
337 
338 /*
339  * SPI registers.
340  */
341 #define	AE_SPICTL_REG		0x200
342 #define	AE_SPICTL_VPD_EN	0x2000	/* Enable VPD. */
343 
344 /*
345  * PHY-specific registers constants.
346  */
347 #define	AE_PHY_DBG_ADDR		0x1d
348 #define	AE_PHY_DBG_DATA		0x1e
349 #define	AE_PHY_DBG_POWERSAVE	0x1000
350 
351 /*
352  * TxD flags.
353  */
354 #define	AE_TXD_INSERT_VTAG	0x8000	/* Insert VLAN tag on transfer. */
355 
356 /*
357  * TxS flags.
358  */
359 #define	AE_TXS_SUCCESS		0x0001	/* Packed transmitted successfully. */
360 #define	AE_TXS_BCAST		0x0002	/* Transmitted broadcast frame. */
361 #define	AE_TXS_MCAST		0x0004	/* Transmitted multicast frame. */
362 #define	AE_TXS_PAUSE		0x0008	/* Transmitted pause frame. */
363 #define	AE_TXS_CTRL		0x0010	/* Transmitted control frame. */
364 #define	AE_TXS_DEFER		0x0020	/* Frame transmitted with defer. */
365 #define	AE_TXS_EXCDEFER		0x0040	/* Excessive collision. */
366 #define	AE_TXS_SINGLECOL	0x0080	/* Single collision occuried. */
367 #define	AE_TXS_MULTICOL		0x0100	/* Multiple collisions occuried. */
368 #define	AE_TXS_LATECOL		0x0200	/* Late collision occuried. */
369 #define	AE_TXS_ABORTCOL		0x0400	/* Frame abort due to collisions. */
370 #define	AE_TXS_UNDERRUN		0x0800	/* Tx SRAM underrun occuried. */
371 #define	AE_TXS_UPDATE		0x8000
372 
373 /*
374  * RxD flags.
375  */
376 #define	AE_RXD_SUCCESS		0x0001
377 #define	AE_RXD_BCAST		0x0002	/* Broadcast frame received. */
378 #define	AE_RXD_MCAST		0x0004	/* Multicast frame received. */
379 #define	AE_RXD_PAUSE		0x0008	/* Pause frame received. */
380 #define	AE_RXD_CTRL		0x0010	/* Control frame received. */
381 #define	AE_RXD_CRCERR		0x0020	/* Invalid frame CRC. */
382 #define	AE_RXD_CODEERR		0x0040	/* Invalid frame opcode. */
383 #define	AE_RXD_RUNT		0x0080	/* Runt frame received. */
384 #define	AE_RXD_FRAG		0x0100	/* Collision fragment received. */
385 #define	AE_RXD_TRUNC		0x0200	/* The frame was truncated due
386 					   to Rx SRAM underrun. */
387 #define	AE_RXD_ALIGN		0x0400	/* Frame alignment error. */
388 #define	AE_RXD_HAS_VLAN		0x0800	/* VLAN tag present. */
389 #define	AE_RXD_UPDATE		0x8000
390