xref: /freebsd/sys/contrib/ncsw/inc/flib/fsl_fman_dtsec.h (revision c2c014f24c10f90d85126ac5fbd4d8524de32b1c)
1*852ba100SJustin Hibbits /*
2*852ba100SJustin Hibbits  * Copyright 2008-2012 Freescale Semiconductor Inc.
3*852ba100SJustin Hibbits  *
4*852ba100SJustin Hibbits  * Redistribution and use in source and binary forms, with or without
5*852ba100SJustin Hibbits  * modification, are permitted provided that the following conditions are met:
6*852ba100SJustin Hibbits  *     * Redistributions of source code must retain the above copyright
7*852ba100SJustin Hibbits  *       notice, this list of conditions and the following disclaimer.
8*852ba100SJustin Hibbits  *     * Redistributions in binary form must reproduce the above copyright
9*852ba100SJustin Hibbits  *       notice, this list of conditions and the following disclaimer in the
10*852ba100SJustin Hibbits  *       documentation and/or other materials provided with the distribution.
11*852ba100SJustin Hibbits  *     * Neither the name of Freescale Semiconductor nor the
12*852ba100SJustin Hibbits  *       names of its contributors may be used to endorse or promote products
13*852ba100SJustin Hibbits  *       derived from this software without specific prior written permission.
14*852ba100SJustin Hibbits  *
15*852ba100SJustin Hibbits  *
16*852ba100SJustin Hibbits  * ALTERNATIVELY, this software may be distributed under the terms of the
17*852ba100SJustin Hibbits  * GNU General Public License ("GPL") as published by the Free Software
18*852ba100SJustin Hibbits  * Foundation, either version 2 of that License or (at your option) any
19*852ba100SJustin Hibbits  * later version.
20*852ba100SJustin Hibbits  *
21*852ba100SJustin Hibbits  * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
22*852ba100SJustin Hibbits  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23*852ba100SJustin Hibbits  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24*852ba100SJustin Hibbits  * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
25*852ba100SJustin Hibbits  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26*852ba100SJustin Hibbits  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27*852ba100SJustin Hibbits  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28*852ba100SJustin Hibbits  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29*852ba100SJustin Hibbits  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30*852ba100SJustin Hibbits  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*852ba100SJustin Hibbits  */
32*852ba100SJustin Hibbits 
33*852ba100SJustin Hibbits #ifndef __FSL_FMAN_DTSEC_H
34*852ba100SJustin Hibbits #define __FSL_FMAN_DTSEC_H
35*852ba100SJustin Hibbits 
36*852ba100SJustin Hibbits #include "common/general.h"
37*852ba100SJustin Hibbits #include "fsl_enet.h"
38*852ba100SJustin Hibbits 
39*852ba100SJustin Hibbits /**
40*852ba100SJustin Hibbits  * DOC: dTSEC Init sequence
41*852ba100SJustin Hibbits  *
42*852ba100SJustin Hibbits  * To prepare dTSEC block for transfer use the following call sequence:
43*852ba100SJustin Hibbits  *
44*852ba100SJustin Hibbits  * - fman_dtsec_defconfig() - This step is optional and yet recommended. Its
45*852ba100SJustin Hibbits  * use is to obtain the default dTSEC configuration parameters.
46*852ba100SJustin Hibbits  *
47*852ba100SJustin Hibbits  * - Change dtsec configuration in &dtsec_cfg. This structure will be used
48*852ba100SJustin Hibbits  * to customize the dTSEC behavior.
49*852ba100SJustin Hibbits  *
50*852ba100SJustin Hibbits  * - fman_dtsec_init() - Applies the configuration on dTSEC hardware.  Note that
51*852ba100SJustin Hibbits  * dTSEC is initialized while both Tx and Rx are disabled.
52*852ba100SJustin Hibbits  *
53*852ba100SJustin Hibbits  * - fman_dtsec_set_mac_address() - Set the station address (mac address).
54*852ba100SJustin Hibbits  * This is used by dTSEC to match against received packets.
55*852ba100SJustin Hibbits  *
56*852ba100SJustin Hibbits  * - fman_dtsec_adjust_link() - Set the link speed and duplex parameters
57*852ba100SJustin Hibbits  * after the PHY establishes the link.
58*852ba100SJustin Hibbits  *
59*852ba100SJustin Hibbits  * - dtsec_enable_tx() and dtsec_enable_rx() to enable transmission and
60*852ba100SJustin Hibbits  * reception.
61*852ba100SJustin Hibbits  */
62*852ba100SJustin Hibbits 
63*852ba100SJustin Hibbits /**
64*852ba100SJustin Hibbits  * DOC: dTSEC Graceful stop
65*852ba100SJustin Hibbits  *
66*852ba100SJustin Hibbits  * To temporary stop dTSEC activity use fman_dtsec_stop_tx() and
67*852ba100SJustin Hibbits  * fman_dtsec_stop_rx(). Note that these functions request dTSEC graceful stop
68*852ba100SJustin Hibbits  * but return before this stop is complete.  To query for graceful stop
69*852ba100SJustin Hibbits  * completion use fman_dtsec_get_event() and check DTSEC_IEVENT_GTSC and
70*852ba100SJustin Hibbits  * DTSEC_IEVENT_GRSC bits. Alternatively the dTSEC interrupt mask can be set to
71*852ba100SJustin Hibbits  * enable graceful stop interrupts.
72*852ba100SJustin Hibbits  *
73*852ba100SJustin Hibbits  * To resume operation after graceful stop use fman_dtsec_start_tx() and
74*852ba100SJustin Hibbits  * fman_dtsec_start_rx().
75*852ba100SJustin Hibbits  */
76*852ba100SJustin Hibbits 
77*852ba100SJustin Hibbits /**
78*852ba100SJustin Hibbits  * DOC: dTSEC interrupt handling
79*852ba100SJustin Hibbits  *
80*852ba100SJustin Hibbits  * This code does not provide an interrupt handler for dTSEC.  Instead this
81*852ba100SJustin Hibbits  * handler should be implemented and registered to the operating system by the
82*852ba100SJustin Hibbits  * caller.  Some primitives for accessing the event status and mask registers
83*852ba100SJustin Hibbits  * are provided.
84*852ba100SJustin Hibbits  *
85*852ba100SJustin Hibbits  * See "dTSEC Events" section for a list of events that dTSEC can generate.
86*852ba100SJustin Hibbits  */
87*852ba100SJustin Hibbits 
88*852ba100SJustin Hibbits /**
89*852ba100SJustin Hibbits  * DOC: dTSEC Events
90*852ba100SJustin Hibbits  *
91*852ba100SJustin Hibbits  * Interrupt events cause dTSEC event bits to be set.  Software may poll the
92*852ba100SJustin Hibbits  * event register at any time to check for pending interrupts.  If an event
93*852ba100SJustin Hibbits  * occurs and its corresponding enable bit is set in the interrupt mask
94*852ba100SJustin Hibbits  * register, the event also causes a hardware interrupt at the PIC.
95*852ba100SJustin Hibbits  *
96*852ba100SJustin Hibbits  * To poll for event status use the fman_dtsec_get_event() function.
97*852ba100SJustin Hibbits  * To configure the interrupt mask use fman_dtsec_enable_interrupt() and
98*852ba100SJustin Hibbits  * fman_dtsec_disable_interrupt() functions.
99*852ba100SJustin Hibbits  * After servicing a dTSEC interrupt use fman_dtsec_ack_event to reset the
100*852ba100SJustin Hibbits  * serviced event bit.
101*852ba100SJustin Hibbits  *
102*852ba100SJustin Hibbits  * The following events may be signaled by dTSEC hardware:
103*852ba100SJustin Hibbits  *
104*852ba100SJustin Hibbits  * %DTSEC_IEVENT_BABR - Babbling receive error.  This bit indicates that
105*852ba100SJustin Hibbits  * a frame was received with length in excess of the MAC's maximum frame length
106*852ba100SJustin Hibbits  * register.
107*852ba100SJustin Hibbits  *
108*852ba100SJustin Hibbits  * %DTSEC_IEVENT_RXC - Receive control (pause frame) interrupt.  A pause
109*852ba100SJustin Hibbits  * control frame was received while Rx pause frame handling is enabled.
110*852ba100SJustin Hibbits  * Also see fman_dtsec_handle_rx_pause().
111*852ba100SJustin Hibbits  *
112*852ba100SJustin Hibbits  * %DTSEC_IEVENT_MSRO - MIB counter overflow.  The count for one of the MIB
113*852ba100SJustin Hibbits  * counters has exceeded the size of its register.
114*852ba100SJustin Hibbits  *
115*852ba100SJustin Hibbits  * %DTSEC_IEVENT_GTSC - Graceful transmit stop complete.  Graceful stop is now
116*852ba100SJustin Hibbits  * complete. The transmitter is in a stopped state, in which only pause frames
117*852ba100SJustin Hibbits  * can be transmitted.
118*852ba100SJustin Hibbits  * Also see fman_dtsec_stop_tx().
119*852ba100SJustin Hibbits  *
120*852ba100SJustin Hibbits  * %DTSEC_IEVENT_BABT - Babbling transmit error.  The transmitted frame length
121*852ba100SJustin Hibbits  * has exceeded the value in the MAC's Maximum Frame Length register.
122*852ba100SJustin Hibbits  *
123*852ba100SJustin Hibbits  * %DTSEC_IEVENT_TXC - Transmit control (pause frame) interrupt.  his bit
124*852ba100SJustin Hibbits  * indicates that a control frame was transmitted.
125*852ba100SJustin Hibbits  *
126*852ba100SJustin Hibbits  * %DTSEC_IEVENT_TXE - Transmit error.  This bit indicates that an error
127*852ba100SJustin Hibbits  * occurred on the transmitted channel.  This bit is set whenever any transmit
128*852ba100SJustin Hibbits  * error occurs which causes the dTSEC to discard all or part of a frame
129*852ba100SJustin Hibbits  * (LC, CRL, XFUN).
130*852ba100SJustin Hibbits  *
131*852ba100SJustin Hibbits  * %DTSEC_IEVENT_LC - Late collision.  This bit indicates that a collision
132*852ba100SJustin Hibbits  * occurred beyond the collision window (slot time) in half-duplex mode.
133*852ba100SJustin Hibbits  * The frame is truncated with a bad CRC and the remainder of the frame
134*852ba100SJustin Hibbits  * is discarded.
135*852ba100SJustin Hibbits  *
136*852ba100SJustin Hibbits  * %DTSEC_IEVENT_CRL - Collision retry limit.  is bit indicates that the number
137*852ba100SJustin Hibbits  * of successive transmission collisions has exceeded the MAC's half-duplex
138*852ba100SJustin Hibbits  * register's retransmission maximum count.  The frame is discarded without
139*852ba100SJustin Hibbits  * being transmitted and transmission of the next frame commences.  This only
140*852ba100SJustin Hibbits  * occurs while in half-duplex mode.
141*852ba100SJustin Hibbits  * The number of retransmit attempts can be set in
142*852ba100SJustin Hibbits  * &dtsec_halfdup_cfg.@retransmit before calling fman_dtsec_init().
143*852ba100SJustin Hibbits  *
144*852ba100SJustin Hibbits  * %DTSEC_IEVENT_XFUN - Transmit FIFO underrun.  This bit indicates that the
145*852ba100SJustin Hibbits  * transmit FIFO became empty before the complete frame was transmitted.
146*852ba100SJustin Hibbits  * The frame is truncated with a bad CRC and the remainder of the frame is
147*852ba100SJustin Hibbits  * discarded.
148*852ba100SJustin Hibbits  *
149*852ba100SJustin Hibbits  * %DTSEC_IEVENT_MAG - TBD
150*852ba100SJustin Hibbits  *
151*852ba100SJustin Hibbits  * %DTSEC_IEVENT_MMRD - MII management read completion.
152*852ba100SJustin Hibbits  *
153*852ba100SJustin Hibbits  * %DTSEC_IEVENT_MMWR - MII management write completion.
154*852ba100SJustin Hibbits  *
155*852ba100SJustin Hibbits  * %DTSEC_IEVENT_GRSC - Graceful receive stop complete.  It allows the user to
156*852ba100SJustin Hibbits  * know if the system has completed the stop and it is safe to write to receive
157*852ba100SJustin Hibbits  * registers (status, control or configuration registers) that are used by the
158*852ba100SJustin Hibbits  * system during normal operation.
159*852ba100SJustin Hibbits  *
160*852ba100SJustin Hibbits  * %DTSEC_IEVENT_TDPE - Internal data error on transmit.  This bit indicates
161*852ba100SJustin Hibbits  * that the dTSEC has detected a parity error on its stored transmit data, which
162*852ba100SJustin Hibbits  * is likely to compromise the validity of recently transferred frames.
163*852ba100SJustin Hibbits  *
164*852ba100SJustin Hibbits  * %DTSEC_IEVENT_RDPE - Internal data error on receive.  This bit indicates that
165*852ba100SJustin Hibbits  * the dTSEC has detected a parity error on its stored receive data, which is
166*852ba100SJustin Hibbits  * likely to compromise the validity of recently transferred frames.
167*852ba100SJustin Hibbits  */
168*852ba100SJustin Hibbits /* Interrupt Mask Register (IMASK) */
169*852ba100SJustin Hibbits #define DTSEC_IMASK_BREN	0x80000000
170*852ba100SJustin Hibbits #define DTSEC_IMASK_RXCEN	0x40000000
171*852ba100SJustin Hibbits #define DTSEC_IMASK_MSROEN	0x04000000
172*852ba100SJustin Hibbits #define DTSEC_IMASK_GTSCEN	0x02000000
173*852ba100SJustin Hibbits #define DTSEC_IMASK_BTEN	0x01000000
174*852ba100SJustin Hibbits #define DTSEC_IMASK_TXCEN	0x00800000
175*852ba100SJustin Hibbits #define DTSEC_IMASK_TXEEN	0x00400000
176*852ba100SJustin Hibbits #define DTSEC_IMASK_LCEN	0x00040000
177*852ba100SJustin Hibbits #define DTSEC_IMASK_CRLEN	0x00020000
178*852ba100SJustin Hibbits #define DTSEC_IMASK_XFUNEN	0x00010000
179*852ba100SJustin Hibbits #define DTSEC_IMASK_ABRTEN	0x00008000
180*852ba100SJustin Hibbits #define DTSEC_IMASK_IFERREN	0x00004000
181*852ba100SJustin Hibbits #define DTSEC_IMASK_MAGEN	0x00000800
182*852ba100SJustin Hibbits #define DTSEC_IMASK_MMRDEN	0x00000400
183*852ba100SJustin Hibbits #define DTSEC_IMASK_MMWREN	0x00000200
184*852ba100SJustin Hibbits #define DTSEC_IMASK_GRSCEN	0x00000100
185*852ba100SJustin Hibbits #define DTSEC_IMASK_TDPEEN	0x00000002
186*852ba100SJustin Hibbits #define DTSEC_IMASK_RDPEEN	0x00000001
187*852ba100SJustin Hibbits 
188*852ba100SJustin Hibbits #define DTSEC_EVENTS_MASK					\
189*852ba100SJustin Hibbits 	((uint32_t)(DTSEC_IMASK_BREN    | \
190*852ba100SJustin Hibbits 				DTSEC_IMASK_RXCEN   | \
191*852ba100SJustin Hibbits 				DTSEC_IMASK_BTEN    | \
192*852ba100SJustin Hibbits 				DTSEC_IMASK_TXCEN   | \
193*852ba100SJustin Hibbits 				DTSEC_IMASK_TXEEN   | \
194*852ba100SJustin Hibbits 				DTSEC_IMASK_ABRTEN  | \
195*852ba100SJustin Hibbits 				DTSEC_IMASK_LCEN    | \
196*852ba100SJustin Hibbits 				DTSEC_IMASK_CRLEN   | \
197*852ba100SJustin Hibbits 				DTSEC_IMASK_XFUNEN  | \
198*852ba100SJustin Hibbits 				DTSEC_IMASK_IFERREN | \
199*852ba100SJustin Hibbits 				DTSEC_IMASK_MAGEN   | \
200*852ba100SJustin Hibbits 				DTSEC_IMASK_TDPEEN  | \
201*852ba100SJustin Hibbits 				DTSEC_IMASK_RDPEEN))
202*852ba100SJustin Hibbits 
203*852ba100SJustin Hibbits /* dtsec timestamp event bits */
204*852ba100SJustin Hibbits #define TMR_PEMASK_TSREEN	0x00010000
205*852ba100SJustin Hibbits #define TMR_PEVENT_TSRE		0x00010000
206*852ba100SJustin Hibbits 
207*852ba100SJustin Hibbits /* Group address bit indication */
208*852ba100SJustin Hibbits #define MAC_GROUP_ADDRESS	0x0000010000000000ULL
209*852ba100SJustin Hibbits /* size in bytes of L2 address */
210*852ba100SJustin Hibbits #define MAC_ADDRLEN		6
211*852ba100SJustin Hibbits 
212*852ba100SJustin Hibbits #define DEFAULT_HALFDUP_ON		FALSE
213*852ba100SJustin Hibbits #define DEFAULT_HALFDUP_RETRANSMIT	0xf
214*852ba100SJustin Hibbits #define DEFAULT_HALFDUP_COLL_WINDOW	0x37
215*852ba100SJustin Hibbits #define DEFAULT_HALFDUP_EXCESS_DEFER	TRUE
216*852ba100SJustin Hibbits #define DEFAULT_HALFDUP_NO_BACKOFF	FALSE
217*852ba100SJustin Hibbits #define DEFAULT_HALFDUP_BP_NO_BACKOFF	FALSE
218*852ba100SJustin Hibbits #define DEFAULT_HALFDUP_ALT_BACKOFF_VAL	0x0A
219*852ba100SJustin Hibbits #define DEFAULT_HALFDUP_ALT_BACKOFF_EN	FALSE
220*852ba100SJustin Hibbits #define DEFAULT_RX_DROP_BCAST		FALSE
221*852ba100SJustin Hibbits #define DEFAULT_RX_SHORT_FRM		TRUE
222*852ba100SJustin Hibbits #define DEFAULT_RX_LEN_CHECK		FALSE
223*852ba100SJustin Hibbits #define DEFAULT_TX_PAD_CRC		TRUE
224*852ba100SJustin Hibbits #define DEFAULT_TX_CRC			FALSE
225*852ba100SJustin Hibbits #define DEFAULT_RX_CTRL_ACC		FALSE
226*852ba100SJustin Hibbits #define DEFAULT_TX_PAUSE_TIME		0xf000
227*852ba100SJustin Hibbits #define DEFAULT_TBIPA			5
228*852ba100SJustin Hibbits #define DEFAULT_RX_PREPEND		0
229*852ba100SJustin Hibbits #define DEFAULT_PTP_TSU_EN		TRUE
230*852ba100SJustin Hibbits #define DEFAULT_PTP_EXCEPTION_EN	TRUE
231*852ba100SJustin Hibbits #define DEFAULT_PREAMBLE_LEN		7
232*852ba100SJustin Hibbits #define DEFAULT_RX_PREAMBLE		FALSE
233*852ba100SJustin Hibbits #define DEFAULT_TX_PREAMBLE		FALSE
234*852ba100SJustin Hibbits #define DEFAULT_LOOPBACK		FALSE
235*852ba100SJustin Hibbits #define DEFAULT_RX_TIME_STAMP_EN	FALSE
236*852ba100SJustin Hibbits #define DEFAULT_TX_TIME_STAMP_EN	FALSE
237*852ba100SJustin Hibbits #define DEFAULT_RX_FLOW			TRUE
238*852ba100SJustin Hibbits #define DEFAULT_TX_FLOW			TRUE
239*852ba100SJustin Hibbits #define DEFAULT_RX_GROUP_HASH_EXD	FALSE
240*852ba100SJustin Hibbits #define DEFAULT_TX_PAUSE_TIME_EXTD	0
241*852ba100SJustin Hibbits #define DEFAULT_RX_PROMISC		FALSE
242*852ba100SJustin Hibbits #define DEFAULT_NON_BACK_TO_BACK_IPG1	0x40
243*852ba100SJustin Hibbits #define DEFAULT_NON_BACK_TO_BACK_IPG2	0x60
244*852ba100SJustin Hibbits #define DEFAULT_MIN_IFG_ENFORCEMENT	0x50
245*852ba100SJustin Hibbits #define DEFAULT_BACK_TO_BACK_IPG	0x60
246*852ba100SJustin Hibbits #define DEFAULT_MAXIMUM_FRAME		0x600
247*852ba100SJustin Hibbits #define DEFAULT_TBI_PHY_ADDR		5
248*852ba100SJustin Hibbits #define DEFAULT_WAKE_ON_LAN			FALSE
249*852ba100SJustin Hibbits 
250*852ba100SJustin Hibbits /* register related defines (bits, field offsets..) */
251*852ba100SJustin Hibbits #define DTSEC_ID1_ID			0xffff0000
252*852ba100SJustin Hibbits #define DTSEC_ID1_REV_MJ		0x0000FF00
253*852ba100SJustin Hibbits #define DTSEC_ID1_REV_MN		0x000000ff
254*852ba100SJustin Hibbits 
255*852ba100SJustin Hibbits #define DTSEC_ID2_INT_REDUCED_OFF	0x00010000
256*852ba100SJustin Hibbits #define DTSEC_ID2_INT_NORMAL_OFF	0x00020000
257*852ba100SJustin Hibbits 
258*852ba100SJustin Hibbits #define DTSEC_ECNTRL_CLRCNT		0x00004000
259*852ba100SJustin Hibbits #define DTSEC_ECNTRL_AUTOZ		0x00002000
260*852ba100SJustin Hibbits #define DTSEC_ECNTRL_STEN		0x00001000
261*852ba100SJustin Hibbits #define DTSEC_ECNTRL_CFG_RO		0x80000000
262*852ba100SJustin Hibbits #define DTSEC_ECNTRL_GMIIM		0x00000040
263*852ba100SJustin Hibbits #define DTSEC_ECNTRL_TBIM		0x00000020
264*852ba100SJustin Hibbits #define DTSEC_ECNTRL_SGMIIM		0x00000002
265*852ba100SJustin Hibbits #define DTSEC_ECNTRL_RPM		0x00000010
266*852ba100SJustin Hibbits #define DTSEC_ECNTRL_R100M		0x00000008
267*852ba100SJustin Hibbits #define DTSEC_ECNTRL_RMM		0x00000004
268*852ba100SJustin Hibbits #define DTSEC_ECNTRL_QSGMIIM		0x00000001
269*852ba100SJustin Hibbits 
270*852ba100SJustin Hibbits #define DTSEC_TCTRL_THDF		0x00000800
271*852ba100SJustin Hibbits #define DTSEC_TCTRL_TTSE		0x00000040
272*852ba100SJustin Hibbits #define DTSEC_TCTRL_GTS			0x00000020
273*852ba100SJustin Hibbits #define DTSEC_TCTRL_TFC_PAUSE		0x00000010
274*852ba100SJustin Hibbits 
275*852ba100SJustin Hibbits /* PTV offsets */
276*852ba100SJustin Hibbits #define PTV_PTE_OFST		16
277*852ba100SJustin Hibbits 
278*852ba100SJustin Hibbits #define RCTRL_CFA		0x00008000
279*852ba100SJustin Hibbits #define RCTRL_GHTX		0x00000400
280*852ba100SJustin Hibbits #define RCTRL_RTSE		0x00000040
281*852ba100SJustin Hibbits #define RCTRL_GRS		0x00000020
282*852ba100SJustin Hibbits #define RCTRL_BC_REJ		0x00000010
283*852ba100SJustin Hibbits #define RCTRL_MPROM		0x00000008
284*852ba100SJustin Hibbits #define RCTRL_RSF		0x00000004
285*852ba100SJustin Hibbits #define RCTRL_UPROM		0x00000001
286*852ba100SJustin Hibbits #define RCTRL_PROM		(RCTRL_UPROM | RCTRL_MPROM)
287*852ba100SJustin Hibbits 
288*852ba100SJustin Hibbits #define TMR_CTL_ESFDP		0x00000800
289*852ba100SJustin Hibbits #define TMR_CTL_ESFDE		0x00000400
290*852ba100SJustin Hibbits 
291*852ba100SJustin Hibbits #define MACCFG1_SOFT_RESET	0x80000000
292*852ba100SJustin Hibbits #define MACCFG1_LOOPBACK	0x00000100
293*852ba100SJustin Hibbits #define MACCFG1_RX_FLOW		0x00000020
294*852ba100SJustin Hibbits #define MACCFG1_TX_FLOW		0x00000010
295*852ba100SJustin Hibbits #define MACCFG1_TX_EN		0x00000001
296*852ba100SJustin Hibbits #define MACCFG1_RX_EN		0x00000004
297*852ba100SJustin Hibbits #define MACCFG1_RESET_RxMC	0x00080000
298*852ba100SJustin Hibbits #define MACCFG1_RESET_TxMC	0x00040000
299*852ba100SJustin Hibbits #define MACCFG1_RESET_RxFUN	0x00020000
300*852ba100SJustin Hibbits #define MACCFG1_RESET_TxFUN	0x00010000
301*852ba100SJustin Hibbits 
302*852ba100SJustin Hibbits #define MACCFG2_NIBBLE_MODE	0x00000100
303*852ba100SJustin Hibbits #define MACCFG2_BYTE_MODE	0x00000200
304*852ba100SJustin Hibbits #define MACCFG2_PRE_AM_Rx_EN	0x00000080
305*852ba100SJustin Hibbits #define MACCFG2_PRE_AM_Tx_EN	0x00000040
306*852ba100SJustin Hibbits #define MACCFG2_LENGTH_CHECK	0x00000010
307*852ba100SJustin Hibbits #define MACCFG2_MAGIC_PACKET_EN	0x00000008
308*852ba100SJustin Hibbits #define MACCFG2_PAD_CRC_EN	0x00000004
309*852ba100SJustin Hibbits #define MACCFG2_CRC_EN		0x00000002
310*852ba100SJustin Hibbits #define MACCFG2_FULL_DUPLEX	0x00000001
311*852ba100SJustin Hibbits 
312*852ba100SJustin Hibbits #define PREAMBLE_LENGTH_SHIFT	12
313*852ba100SJustin Hibbits 
314*852ba100SJustin Hibbits #define IPGIFG_NON_BACK_TO_BACK_IPG_1_SHIFT	24
315*852ba100SJustin Hibbits #define IPGIFG_NON_BACK_TO_BACK_IPG_2_SHIFT	16
316*852ba100SJustin Hibbits #define IPGIFG_MIN_IFG_ENFORCEMENT_SHIFT	8
317*852ba100SJustin Hibbits 
318*852ba100SJustin Hibbits #define IPGIFG_NON_BACK_TO_BACK_IPG_1	0x7F000000
319*852ba100SJustin Hibbits #define IPGIFG_NON_BACK_TO_BACK_IPG_2	0x007F0000
320*852ba100SJustin Hibbits #define IPGIFG_MIN_IFG_ENFORCEMENT	0x0000FF00
321*852ba100SJustin Hibbits #define IPGIFG_BACK_TO_BACK_IPG		0x0000007F
322*852ba100SJustin Hibbits 
323*852ba100SJustin Hibbits #define HAFDUP_ALT_BEB			0x00080000
324*852ba100SJustin Hibbits #define HAFDUP_BP_NO_BACKOFF		0x00040000
325*852ba100SJustin Hibbits #define HAFDUP_NO_BACKOFF		0x00020000
326*852ba100SJustin Hibbits #define HAFDUP_EXCESS_DEFER		0x00010000
327*852ba100SJustin Hibbits #define HAFDUP_COLLISION_WINDOW		0x000003ff
328*852ba100SJustin Hibbits 
329*852ba100SJustin Hibbits #define HAFDUP_ALTERNATE_BEB_TRUNCATION_SHIFT	20
330*852ba100SJustin Hibbits #define HAFDUP_RETRANSMISSION_MAX_SHIFT		12
331*852ba100SJustin Hibbits #define HAFDUP_RETRANSMISSION_MAX		0x0000f000
332*852ba100SJustin Hibbits 
333*852ba100SJustin Hibbits #define NUM_OF_HASH_REGS	8 /* Number of hash table registers */
334*852ba100SJustin Hibbits 
335*852ba100SJustin Hibbits /* CAR1/2 bits */
336*852ba100SJustin Hibbits #define DTSEC_CAR1_TR64		0x80000000
337*852ba100SJustin Hibbits #define DTSEC_CAR1_TR127	0x40000000
338*852ba100SJustin Hibbits #define DTSEC_CAR1_TR255	0x20000000
339*852ba100SJustin Hibbits #define DTSEC_CAR1_TR511	0x10000000
340*852ba100SJustin Hibbits #define DTSEC_CAR1_TRK1		0x08000000
341*852ba100SJustin Hibbits #define DTSEC_CAR1_TRMAX	0x04000000
342*852ba100SJustin Hibbits #define DTSEC_CAR1_TRMGV	0x02000000
343*852ba100SJustin Hibbits 
344*852ba100SJustin Hibbits #define DTSEC_CAR1_RBYT		0x00010000
345*852ba100SJustin Hibbits #define DTSEC_CAR1_RPKT		0x00008000
346*852ba100SJustin Hibbits #define DTSEC_CAR1_RFCS		0x00004000
347*852ba100SJustin Hibbits #define DTSEC_CAR1_RMCA		0x00002000
348*852ba100SJustin Hibbits #define DTSEC_CAR1_RBCA		0x00001000
349*852ba100SJustin Hibbits #define DTSEC_CAR1_RXCF		0x00000800
350*852ba100SJustin Hibbits #define DTSEC_CAR1_RXPF		0x00000400
351*852ba100SJustin Hibbits #define DTSEC_CAR1_RXUO		0x00000200
352*852ba100SJustin Hibbits #define DTSEC_CAR1_RALN		0x00000100
353*852ba100SJustin Hibbits #define DTSEC_CAR1_RFLR		0x00000080
354*852ba100SJustin Hibbits #define DTSEC_CAR1_RCDE		0x00000040
355*852ba100SJustin Hibbits #define DTSEC_CAR1_RCSE		0x00000020
356*852ba100SJustin Hibbits #define DTSEC_CAR1_RUND		0x00000010
357*852ba100SJustin Hibbits #define DTSEC_CAR1_ROVR		0x00000008
358*852ba100SJustin Hibbits #define DTSEC_CAR1_RFRG		0x00000004
359*852ba100SJustin Hibbits #define DTSEC_CAR1_RJBR		0x00000002
360*852ba100SJustin Hibbits #define DTSEC_CAR1_RDRP		0x00000001
361*852ba100SJustin Hibbits 
362*852ba100SJustin Hibbits #define DTSEC_CAR2_TJBR		0x00080000
363*852ba100SJustin Hibbits #define DTSEC_CAR2_TFCS		0x00040000
364*852ba100SJustin Hibbits #define DTSEC_CAR2_TXCF		0x00020000
365*852ba100SJustin Hibbits #define DTSEC_CAR2_TOVR		0x00010000
366*852ba100SJustin Hibbits #define DTSEC_CAR2_TUND		0x00008000
367*852ba100SJustin Hibbits #define DTSEC_CAR2_TFRG		0x00004000
368*852ba100SJustin Hibbits #define DTSEC_CAR2_TBYT		0x00002000
369*852ba100SJustin Hibbits #define DTSEC_CAR2_TPKT		0x00001000
370*852ba100SJustin Hibbits #define DTSEC_CAR2_TMCA		0x00000800
371*852ba100SJustin Hibbits #define DTSEC_CAR2_TBCA		0x00000400
372*852ba100SJustin Hibbits #define DTSEC_CAR2_TXPF		0x00000200
373*852ba100SJustin Hibbits #define DTSEC_CAR2_TDFR		0x00000100
374*852ba100SJustin Hibbits #define DTSEC_CAR2_TEDF		0x00000080
375*852ba100SJustin Hibbits #define DTSEC_CAR2_TSCL		0x00000040
376*852ba100SJustin Hibbits #define DTSEC_CAR2_TMCL		0x00000020
377*852ba100SJustin Hibbits #define DTSEC_CAR2_TLCL		0x00000010
378*852ba100SJustin Hibbits #define DTSEC_CAR2_TXCL		0x00000008
379*852ba100SJustin Hibbits #define DTSEC_CAR2_TNCL		0x00000004
380*852ba100SJustin Hibbits #define DTSEC_CAR2_TDRP		0x00000001
381*852ba100SJustin Hibbits 
382*852ba100SJustin Hibbits #define CAM1_ERRORS_ONLY \
383*852ba100SJustin Hibbits 	(DTSEC_CAR1_RXPF | DTSEC_CAR1_RALN | DTSEC_CAR1_RFLR \
384*852ba100SJustin Hibbits 	| DTSEC_CAR1_RCDE | DTSEC_CAR1_RCSE | DTSEC_CAR1_RUND \
385*852ba100SJustin Hibbits 	| DTSEC_CAR1_ROVR | DTSEC_CAR1_RFRG | DTSEC_CAR1_RJBR \
386*852ba100SJustin Hibbits 	| DTSEC_CAR1_RDRP)
387*852ba100SJustin Hibbits 
388*852ba100SJustin Hibbits #define CAM2_ERRORS_ONLY (DTSEC_CAR2_TFCS | DTSEC_CAR2_TXPF | DTSEC_CAR2_TDRP)
389*852ba100SJustin Hibbits 
390*852ba100SJustin Hibbits /*
391*852ba100SJustin Hibbits  * Group of dTSEC specific counters relating to the standard RMON MIB Group 1
392*852ba100SJustin Hibbits  * (or Ethernet) statistics.
393*852ba100SJustin Hibbits  */
394*852ba100SJustin Hibbits #define CAM1_MIB_GRP_1 \
395*852ba100SJustin Hibbits 	(DTSEC_CAR1_RDRP | DTSEC_CAR1_RBYT | DTSEC_CAR1_RPKT | DTSEC_CAR1_RMCA\
396*852ba100SJustin Hibbits 	| DTSEC_CAR1_RBCA | DTSEC_CAR1_RALN | DTSEC_CAR1_RUND | DTSEC_CAR1_ROVR\
397*852ba100SJustin Hibbits 	| DTSEC_CAR1_RFRG | DTSEC_CAR1_RJBR \
398*852ba100SJustin Hibbits 	| DTSEC_CAR1_TR64 | DTSEC_CAR1_TR127 | DTSEC_CAR1_TR255 \
399*852ba100SJustin Hibbits 	| DTSEC_CAR1_TR511 | DTSEC_CAR1_TRMAX)
400*852ba100SJustin Hibbits 
401*852ba100SJustin Hibbits #define CAM2_MIB_GRP_1 (DTSEC_CAR2_TNCL | DTSEC_CAR2_TDRP)
402*852ba100SJustin Hibbits 
403*852ba100SJustin Hibbits /* memory map */
404*852ba100SJustin Hibbits 
405*852ba100SJustin Hibbits struct dtsec_regs {
406*852ba100SJustin Hibbits 	/* dTSEC General Control and Status Registers */
407*852ba100SJustin Hibbits 	uint32_t tsec_id;	/* 0x000 ETSEC_ID register */
408*852ba100SJustin Hibbits 	uint32_t tsec_id2;	/* 0x004 ETSEC_ID2 register */
409*852ba100SJustin Hibbits 	uint32_t ievent;	/* 0x008 Interrupt event register */
410*852ba100SJustin Hibbits 	uint32_t imask;		/* 0x00C Interrupt mask register */
411*852ba100SJustin Hibbits 	uint32_t reserved0010[1];
412*852ba100SJustin Hibbits 	uint32_t ecntrl;	/* 0x014 E control register */
413*852ba100SJustin Hibbits 	uint32_t ptv;		/* 0x018 Pause time value register */
414*852ba100SJustin Hibbits 	uint32_t tbipa;		/* 0x01C TBI PHY address register */
415*852ba100SJustin Hibbits 	uint32_t tmr_ctrl;	/* 0x020 Time-stamp Control register */
416*852ba100SJustin Hibbits 	uint32_t tmr_pevent;	/* 0x024 Time-stamp event register */
417*852ba100SJustin Hibbits 	uint32_t tmr_pemask;	/* 0x028 Timer event mask register */
418*852ba100SJustin Hibbits 	uint32_t reserved002c[5];
419*852ba100SJustin Hibbits 	uint32_t tctrl;		/* 0x040 Transmit control register */
420*852ba100SJustin Hibbits 	uint32_t reserved0044[3];
421*852ba100SJustin Hibbits 	uint32_t rctrl;		/* 0x050 Receive control register */
422*852ba100SJustin Hibbits 	uint32_t reserved0054[11];
423*852ba100SJustin Hibbits 	uint32_t igaddr[8]; 	/* 0x080-0x09C Individual/group address */
424*852ba100SJustin Hibbits 	uint32_t gaddr[8];	/* 0x0A0-0x0BC Group address registers 0-7 */
425*852ba100SJustin Hibbits 	uint32_t reserved00c0[16];
426*852ba100SJustin Hibbits 	uint32_t maccfg1;		/* 0x100 MAC configuration #1 */
427*852ba100SJustin Hibbits 	uint32_t maccfg2;		/* 0x104 MAC configuration #2 */
428*852ba100SJustin Hibbits 	uint32_t ipgifg;		/* 0x108 IPG/IFG */
429*852ba100SJustin Hibbits 	uint32_t hafdup;		/* 0x10C Half-duplex */
430*852ba100SJustin Hibbits 	uint32_t maxfrm;		/* 0x110 Maximum frame */
431*852ba100SJustin Hibbits 	uint32_t reserved0114[10];
432*852ba100SJustin Hibbits 	uint32_t ifstat;		/* 0x13C Interface status */
433*852ba100SJustin Hibbits 	uint32_t macstnaddr1;		/* 0x140 Station Address,part 1 */
434*852ba100SJustin Hibbits 	uint32_t macstnaddr2;		/* 0x144 Station Address,part 2  */
435*852ba100SJustin Hibbits 	struct {
436*852ba100SJustin Hibbits 	    uint32_t exact_match1; /* octets 1-4 */
437*852ba100SJustin Hibbits 	    uint32_t exact_match2; /* octets 5-6 */
438*852ba100SJustin Hibbits 	} macaddr[15];	/* 0x148-0x1BC mac exact match addresses 1-15 */
439*852ba100SJustin Hibbits 	uint32_t reserved01c0[16];
440*852ba100SJustin Hibbits 	uint32_t tr64;	/* 0x200 transmit and receive 64 byte frame counter */
441*852ba100SJustin Hibbits 	uint32_t tr127;	/* 0x204 transmit and receive 65 to 127 byte frame
442*852ba100SJustin Hibbits 			 * counter */
443*852ba100SJustin Hibbits 	uint32_t tr255;	/* 0x208 transmit and receive 128 to 255 byte frame
444*852ba100SJustin Hibbits 			 * counter */
445*852ba100SJustin Hibbits 	uint32_t tr511;	/* 0x20C transmit and receive 256 to 511 byte frame
446*852ba100SJustin Hibbits 			 * counter */
447*852ba100SJustin Hibbits 	uint32_t tr1k;	/* 0x210 transmit and receive 512 to 1023 byte frame
448*852ba100SJustin Hibbits 			 * counter */
449*852ba100SJustin Hibbits 	uint32_t trmax;	/* 0x214 transmit and receive 1024 to 1518 byte frame
450*852ba100SJustin Hibbits 			 * counter */
451*852ba100SJustin Hibbits 	uint32_t trmgv;	/* 0x218 transmit and receive 1519 to 1522 byte good
452*852ba100SJustin Hibbits 			 * VLAN frame count */
453*852ba100SJustin Hibbits 	uint32_t rbyt;	/* 0x21C receive byte counter */
454*852ba100SJustin Hibbits 	uint32_t rpkt;	/* 0x220 receive packet counter */
455*852ba100SJustin Hibbits 	uint32_t rfcs;	/* 0x224 receive FCS error counter */
456*852ba100SJustin Hibbits 	uint32_t rmca;	/* 0x228 RMCA receive multicast packet counter */
457*852ba100SJustin Hibbits 	uint32_t rbca;	/* 0x22C receive broadcast packet counter */
458*852ba100SJustin Hibbits 	uint32_t rxcf;	/* 0x230 receive control frame packet counter */
459*852ba100SJustin Hibbits 	uint32_t rxpf;	/* 0x234 receive pause frame packet counter */
460*852ba100SJustin Hibbits 	uint32_t rxuo;	/* 0x238 receive unknown OP code counter */
461*852ba100SJustin Hibbits 	uint32_t raln;	/* 0x23C receive alignment error counter */
462*852ba100SJustin Hibbits 	uint32_t rflr;	/* 0x240 receive frame length error counter */
463*852ba100SJustin Hibbits 	uint32_t rcde;	/* 0x244 receive code error counter */
464*852ba100SJustin Hibbits 	uint32_t rcse;	/* 0x248 receive carrier sense error counter */
465*852ba100SJustin Hibbits 	uint32_t rund;	/* 0x24C receive undersize packet counter */
466*852ba100SJustin Hibbits 	uint32_t rovr;	/* 0x250 receive oversize packet counter */
467*852ba100SJustin Hibbits 	uint32_t rfrg;	/* 0x254 receive fragments counter */
468*852ba100SJustin Hibbits 	uint32_t rjbr;	/* 0x258 receive jabber counter */
469*852ba100SJustin Hibbits 	uint32_t rdrp;	/* 0x25C receive drop */
470*852ba100SJustin Hibbits 	uint32_t tbyt;	/* 0x260 transmit byte counter */
471*852ba100SJustin Hibbits 	uint32_t tpkt;	/* 0x264 transmit packet counter */
472*852ba100SJustin Hibbits 	uint32_t tmca;	/* 0x268 transmit multicast packet counter */
473*852ba100SJustin Hibbits 	uint32_t tbca;	/* 0x26C transmit broadcast packet counter */
474*852ba100SJustin Hibbits 	uint32_t txpf;	/* 0x270 transmit pause control frame counter */
475*852ba100SJustin Hibbits 	uint32_t tdfr;	/* 0x274 transmit deferral packet counter */
476*852ba100SJustin Hibbits 	uint32_t tedf;	/* 0x278 transmit excessive deferral packet counter */
477*852ba100SJustin Hibbits 	uint32_t tscl;	/* 0x27C transmit single collision packet counter */
478*852ba100SJustin Hibbits 	uint32_t tmcl;	/* 0x280 transmit multiple collision packet counter */
479*852ba100SJustin Hibbits 	uint32_t tlcl;	/* 0x284 transmit late collision packet counter */
480*852ba100SJustin Hibbits 	uint32_t txcl;	/* 0x288 transmit excessive collision packet counter */
481*852ba100SJustin Hibbits 	uint32_t tncl;	/* 0x28C transmit total collision counter */
482*852ba100SJustin Hibbits 	uint32_t reserved0290[1];
483*852ba100SJustin Hibbits 	uint32_t tdrp;	/* 0x294 transmit drop frame counter */
484*852ba100SJustin Hibbits 	uint32_t tjbr;	/* 0x298 transmit jabber frame counter */
485*852ba100SJustin Hibbits 	uint32_t tfcs;	/* 0x29C transmit FCS error counter */
486*852ba100SJustin Hibbits 	uint32_t txcf;	/* 0x2A0 transmit control frame counter */
487*852ba100SJustin Hibbits 	uint32_t tovr;	/* 0x2A4 transmit oversize frame counter */
488*852ba100SJustin Hibbits 	uint32_t tund;	/* 0x2A8 transmit undersize frame counter */
489*852ba100SJustin Hibbits 	uint32_t tfrg;	/* 0x2AC transmit fragments frame counter */
490*852ba100SJustin Hibbits 	uint32_t car1;	/* 0x2B0 carry register one register* */
491*852ba100SJustin Hibbits 	uint32_t car2;	/* 0x2B4 carry register two register* */
492*852ba100SJustin Hibbits 	uint32_t cam1;	/* 0x2B8 carry register one mask register */
493*852ba100SJustin Hibbits 	uint32_t cam2;	/* 0x2BC carry register two mask register */
494*852ba100SJustin Hibbits 	uint32_t reserved02c0[848];
495*852ba100SJustin Hibbits };
496*852ba100SJustin Hibbits 
497*852ba100SJustin Hibbits /**
498*852ba100SJustin Hibbits  * struct dtsec_mib_grp_1_counters - MIB counter overflows
499*852ba100SJustin Hibbits  *
500*852ba100SJustin Hibbits  * @tr64:	Transmit and Receive 64 byte frame count.  Increment for each
501*852ba100SJustin Hibbits  *		good or bad frame, of any type, transmitted or received, which
502*852ba100SJustin Hibbits  *		is 64 bytes in length.
503*852ba100SJustin Hibbits  * @tr127:	Transmit and Receive 65 to 127 byte frame count.  Increments for
504*852ba100SJustin Hibbits  *		each good or bad frame of any type, transmitted or received,
505*852ba100SJustin Hibbits  *		which is 65-127 bytes in length.
506*852ba100SJustin Hibbits  * @tr255:	Transmit and Receive 128 to 255 byte frame count.  Increments
507*852ba100SJustin Hibbits  *		for each good or bad frame, of any type, transmitted or
508*852ba100SJustin Hibbits  *		received, which is 128-255 bytes in length.
509*852ba100SJustin Hibbits  * @tr511:	Transmit and Receive 256 to 511 byte frame count.  Increments
510*852ba100SJustin Hibbits  *		for each good or bad frame, of any type, transmitted or
511*852ba100SJustin Hibbits  *		received, which is 256-511 bytes in length.
512*852ba100SJustin Hibbits  * @tr1k:	Transmit and Receive 512 to 1023 byte frame count.  Increments
513*852ba100SJustin Hibbits  *		for each good or bad frame, of any type, transmitted or
514*852ba100SJustin Hibbits  *		received, which is 512-1023 bytes in length.
515*852ba100SJustin Hibbits  * @trmax:	Transmit and Receive 1024 to 1518 byte frame count.  Increments
516*852ba100SJustin Hibbits  *		for each good or bad frame, of any type, transmitted or
517*852ba100SJustin Hibbits  *		received, which is 1024-1518 bytes in length.
518*852ba100SJustin Hibbits  * @rfrg:	Receive fragments count.  Increments for each received frame
519*852ba100SJustin Hibbits  *		which is less than 64 bytes in length and contains an invalid
520*852ba100SJustin Hibbits  *		FCS.  This includes integral and non-integral lengths.
521*852ba100SJustin Hibbits  * @rjbr:	Receive jabber count.  Increments for received frames which
522*852ba100SJustin Hibbits  *		exceed 1518 (non VLAN) or 1522 (VLAN) bytes and contain an
523*852ba100SJustin Hibbits  *		invalid FCS.  This includes alignment errors.
524*852ba100SJustin Hibbits  * @rdrp:	Receive dropped packets count.  Increments for received frames
525*852ba100SJustin Hibbits  *		which are streamed to system but are later dropped due to lack
526*852ba100SJustin Hibbits  *		of system resources.  Does not increment for frames rejected due
527*852ba100SJustin Hibbits  *		to address filtering.
528*852ba100SJustin Hibbits  * @raln:	Receive alignment error count.  Increments for each received
529*852ba100SJustin Hibbits  *		frame from 64 to 1518 (non VLAN) or 1522 (VLAN) which contains
530*852ba100SJustin Hibbits  *		an invalid FCS and is not an integral number of bytes.
531*852ba100SJustin Hibbits  * @rund:	Receive undersize packet count.  Increments each time a frame is
532*852ba100SJustin Hibbits  *		received which is less than 64 bytes in length and contains a
533*852ba100SJustin Hibbits  *		valid FCS and is otherwise well formed.  This count does not
534*852ba100SJustin Hibbits  *		include range length errors.
535*852ba100SJustin Hibbits  * @rovr:	Receive oversize packet count.  Increments each time a frame is
536*852ba100SJustin Hibbits  *		received which exceeded 1518 (non VLAN) or 1522 (VLAN) and
537*852ba100SJustin Hibbits  *		contains a valid FCS and is otherwise well formed.
538*852ba100SJustin Hibbits  * @rbyt:	Receive byte count.  Increments by the byte count of frames
539*852ba100SJustin Hibbits  *		received, including those in bad packets, excluding preamble and
540*852ba100SJustin Hibbits  *		SFD but including FCS bytes.
541*852ba100SJustin Hibbits  * @rpkt:	Receive packet count.  Increments for each received frame
542*852ba100SJustin Hibbits  *		(including bad packets, all unicast, broadcast, and multicast
543*852ba100SJustin Hibbits  *		packets).
544*852ba100SJustin Hibbits  * @rmca:	Receive multicast packet count.  Increments for each multicast
545*852ba100SJustin Hibbits  *		frame with valid CRC and of lengths 64 to 1518 (non VLAN) or
546*852ba100SJustin Hibbits  *		1522 (VLAN), excluding broadcast frames. This count does not
547*852ba100SJustin Hibbits  *		include range/length errors.
548*852ba100SJustin Hibbits  * @rbca:	Receive broadcast packet count.  Increments for each broadcast
549*852ba100SJustin Hibbits  *		frame with valid CRC and of lengths 64 to 1518 (non VLAN) or
550*852ba100SJustin Hibbits  *		1522 (VLAN), excluding multicast frames. Does not include
551*852ba100SJustin Hibbits  *		range/length errors.
552*852ba100SJustin Hibbits  * @tdrp:	Transmit drop frame count.  Increments each time a memory error
553*852ba100SJustin Hibbits  *		or an underrun has occurred.
554*852ba100SJustin Hibbits  * @tncl:	Transmit total collision counter. Increments by the number of
555*852ba100SJustin Hibbits  *		collisions experienced during the transmission of a frame. Does
556*852ba100SJustin Hibbits  *		not increment for aborted frames.
557*852ba100SJustin Hibbits  *
558*852ba100SJustin Hibbits  * The structure contains a group of dTSEC HW specific counters relating to the
559*852ba100SJustin Hibbits  * standard RMON MIB Group 1 (or Ethernet statistics) counters.  This structure
560*852ba100SJustin Hibbits  * is counting only the carry events of the corresponding HW counters.
561*852ba100SJustin Hibbits  *
562*852ba100SJustin Hibbits  * tr64 to trmax notes: Frame sizes specified are considered excluding preamble
563*852ba100SJustin Hibbits  * and SFD but including FCS bytes.
564*852ba100SJustin Hibbits  */
565*852ba100SJustin Hibbits struct dtsec_mib_grp_1_counters {
566*852ba100SJustin Hibbits 	uint64_t	rdrp;
567*852ba100SJustin Hibbits 	uint64_t	tdrp;
568*852ba100SJustin Hibbits 	uint64_t	rbyt;
569*852ba100SJustin Hibbits 	uint64_t	rpkt;
570*852ba100SJustin Hibbits 	uint64_t	rbca;
571*852ba100SJustin Hibbits 	uint64_t	rmca;
572*852ba100SJustin Hibbits 	uint64_t	raln;
573*852ba100SJustin Hibbits 	uint64_t	rund;
574*852ba100SJustin Hibbits 	uint64_t	rovr;
575*852ba100SJustin Hibbits 	uint64_t	rfrg;
576*852ba100SJustin Hibbits 	uint64_t	rjbr;
577*852ba100SJustin Hibbits 	uint64_t	tncl;
578*852ba100SJustin Hibbits 	uint64_t	tr64;
579*852ba100SJustin Hibbits 	uint64_t	tr127;
580*852ba100SJustin Hibbits 	uint64_t	tr255;
581*852ba100SJustin Hibbits 	uint64_t	tr511;
582*852ba100SJustin Hibbits 	uint64_t	tr1k;
583*852ba100SJustin Hibbits 	uint64_t	trmax;
584*852ba100SJustin Hibbits };
585*852ba100SJustin Hibbits 
586*852ba100SJustin Hibbits enum dtsec_stat_counters {
587*852ba100SJustin Hibbits 	E_DTSEC_STAT_TR64,
588*852ba100SJustin Hibbits 	E_DTSEC_STAT_TR127,
589*852ba100SJustin Hibbits 	E_DTSEC_STAT_TR255,
590*852ba100SJustin Hibbits 	E_DTSEC_STAT_TR511,
591*852ba100SJustin Hibbits 	E_DTSEC_STAT_TR1K,
592*852ba100SJustin Hibbits 	E_DTSEC_STAT_TRMAX,
593*852ba100SJustin Hibbits 	E_DTSEC_STAT_TRMGV,
594*852ba100SJustin Hibbits 	E_DTSEC_STAT_RBYT,
595*852ba100SJustin Hibbits 	E_DTSEC_STAT_RPKT,
596*852ba100SJustin Hibbits 	E_DTSEC_STAT_RMCA,
597*852ba100SJustin Hibbits 	E_DTSEC_STAT_RBCA,
598*852ba100SJustin Hibbits 	E_DTSEC_STAT_RXPF,
599*852ba100SJustin Hibbits 	E_DTSEC_STAT_RALN,
600*852ba100SJustin Hibbits 	E_DTSEC_STAT_RFLR,
601*852ba100SJustin Hibbits 	E_DTSEC_STAT_RCDE,
602*852ba100SJustin Hibbits 	E_DTSEC_STAT_RCSE,
603*852ba100SJustin Hibbits 	E_DTSEC_STAT_RUND,
604*852ba100SJustin Hibbits 	E_DTSEC_STAT_ROVR,
605*852ba100SJustin Hibbits 	E_DTSEC_STAT_RFRG,
606*852ba100SJustin Hibbits 	E_DTSEC_STAT_RJBR,
607*852ba100SJustin Hibbits 	E_DTSEC_STAT_RDRP,
608*852ba100SJustin Hibbits 	E_DTSEC_STAT_TFCS,
609*852ba100SJustin Hibbits 	E_DTSEC_STAT_TBYT,
610*852ba100SJustin Hibbits 	E_DTSEC_STAT_TPKT,
611*852ba100SJustin Hibbits 	E_DTSEC_STAT_TMCA,
612*852ba100SJustin Hibbits 	E_DTSEC_STAT_TBCA,
613*852ba100SJustin Hibbits 	E_DTSEC_STAT_TXPF,
614*852ba100SJustin Hibbits 	E_DTSEC_STAT_TNCL,
615*852ba100SJustin Hibbits 	E_DTSEC_STAT_TDRP
616*852ba100SJustin Hibbits };
617*852ba100SJustin Hibbits 
618*852ba100SJustin Hibbits enum dtsec_stat_level {
619*852ba100SJustin Hibbits 	/* No statistics */
620*852ba100SJustin Hibbits 	E_MAC_STAT_NONE = 0,
621*852ba100SJustin Hibbits 	/* Only RMON MIB group 1 (ether stats). Optimized for performance */
622*852ba100SJustin Hibbits 	E_MAC_STAT_MIB_GRP1,
623*852ba100SJustin Hibbits 	/* Only error counters are available. Optimized for performance */
624*852ba100SJustin Hibbits 	E_MAC_STAT_PARTIAL,
625*852ba100SJustin Hibbits 	/* All counters available. Not optimized for performance */
626*852ba100SJustin Hibbits 	E_MAC_STAT_FULL
627*852ba100SJustin Hibbits };
628*852ba100SJustin Hibbits 
629*852ba100SJustin Hibbits 
630*852ba100SJustin Hibbits /**
631*852ba100SJustin Hibbits  * struct dtsec_cfg - dTSEC configuration
632*852ba100SJustin Hibbits  *
633*852ba100SJustin Hibbits  * @halfdup_on:		Transmit half-duplex flow control, under software
634*852ba100SJustin Hibbits  *			control for 10/100-Mbps half-duplex media. If set,
635*852ba100SJustin Hibbits  *			back pressure is applied to media by raising carrier.
636*852ba100SJustin Hibbits  * @halfdup_retransmit:	Number of retransmission attempts following a collision.
637*852ba100SJustin Hibbits  *			If this is exceeded dTSEC aborts transmission due to
638*852ba100SJustin Hibbits  *			excessive collisions. The standard specifies the
639*852ba100SJustin Hibbits  *			attempt limit to be 15.
640*852ba100SJustin Hibbits  * @halfdup_coll_window:The number of bytes of the frame during which
641*852ba100SJustin Hibbits  *			collisions may occur. The default value of 55
642*852ba100SJustin Hibbits  *			corresponds to the frame byte at the end of the
643*852ba100SJustin Hibbits  *			standard 512-bit slot time window. If collisions are
644*852ba100SJustin Hibbits  *			detected after this byte, the late collision event is
645*852ba100SJustin Hibbits  *			asserted and transmission of current frame is aborted.
646*852ba100SJustin Hibbits  * @rx_drop_bcast:	Discard broadcast frames.  If set, all broadcast frames
647*852ba100SJustin Hibbits  *			will be discarded by dTSEC.
648*852ba100SJustin Hibbits  * @rx_short_frm:	Accept short frames.  If set, dTSEC will accept frames
649*852ba100SJustin Hibbits  *			of length 14..63 bytes.
650*852ba100SJustin Hibbits  * @rx_len_check:	Length check for received frames.  If set, the MAC
651*852ba100SJustin Hibbits  *			checks the frame's length field on receive to ensure it
652*852ba100SJustin Hibbits  *			matches the actual data field length. This only works
653*852ba100SJustin Hibbits  *			for received frames with length field less than 1500.
654*852ba100SJustin Hibbits  *			No check is performed for larger frames.
655*852ba100SJustin Hibbits  * @tx_pad_crc:		Pad and append CRC.  If set, the MAC pads all
656*852ba100SJustin Hibbits  *			transmitted short frames and appends a CRC to every
657*852ba100SJustin Hibbits  *			frame regardless of padding requirement.
658*852ba100SJustin Hibbits  * @tx_crc:		Transmission CRC enable.  If set, the MAC appends a CRC
659*852ba100SJustin Hibbits  *			to all frames.  If frames presented to the MAC have a
660*852ba100SJustin Hibbits  *			valid length and contain a valid CRC, @tx_crc should be
661*852ba100SJustin Hibbits  *			reset.
662*852ba100SJustin Hibbits  *			This field is ignored if @tx_pad_crc is set.
663*852ba100SJustin Hibbits  * @rx_ctrl_acc:	Control frame accept.  If set, this overrides 802.3
664*852ba100SJustin Hibbits  *			standard control frame behavior, and all Ethernet frames
665*852ba100SJustin Hibbits  *			that have an ethertype of 0x8808 are treated as normal
666*852ba100SJustin Hibbits  *			Ethernet frames and passed up to the packet interface on
667*852ba100SJustin Hibbits  *			a DA match.  Received pause control frames are passed to
668*852ba100SJustin Hibbits  *			the packet interface only if Rx flow control is also
669*852ba100SJustin Hibbits  *			disabled.  See fman_dtsec_handle_rx_pause() function.
670*852ba100SJustin Hibbits  * @tx_pause_time:	Transmit pause time value.  This pause value is used as
671*852ba100SJustin Hibbits  *			part of the pause frame to be sent when a transmit pause
672*852ba100SJustin Hibbits  *			frame is initiated.  If set to 0 this disables
673*852ba100SJustin Hibbits  *			transmission of pause frames.
674*852ba100SJustin Hibbits  * @rx_preamble:	Receive preamble enable.  If set, the MAC recovers the
675*852ba100SJustin Hibbits  *			received Ethernet 7-byte preamble and passes it to the
676*852ba100SJustin Hibbits  *			packet interface at the start of each received frame.
677*852ba100SJustin Hibbits  *			This field should be reset for internal MAC loop-back
678*852ba100SJustin Hibbits  *			mode.
679*852ba100SJustin Hibbits  * @tx_preamble:	User defined preamble enable for transmitted frames.
680*852ba100SJustin Hibbits  *			If set, a user-defined preamble must passed to the MAC
681*852ba100SJustin Hibbits  *			and it is transmitted instead of the standard preamble.
682*852ba100SJustin Hibbits  * @preamble_len:	Length, in bytes, of the preamble field preceding each
683*852ba100SJustin Hibbits  *			Ethernet start-of-frame delimiter byte.  The default
684*852ba100SJustin Hibbits  *			value of 0x7 should be used in order to guarantee
685*852ba100SJustin Hibbits  *			reliable operation with IEEE 802.3 compliant hardware.
686*852ba100SJustin Hibbits  * @rx_prepend:		Packet alignment padding length.  The specified number
687*852ba100SJustin Hibbits  *			of bytes (1-31) of zero padding are inserted before the
688*852ba100SJustin Hibbits  *			start of each received frame.  For Ethernet, where
689*852ba100SJustin Hibbits  *			optional preamble extraction is enabled, the padding
690*852ba100SJustin Hibbits  *			appears before the preamble, otherwise the padding
691*852ba100SJustin Hibbits  *			precedes the layer 2 header.
692*852ba100SJustin Hibbits  *
693*852ba100SJustin Hibbits  * This structure contains basic dTSEC configuration and must be passed to
694*852ba100SJustin Hibbits  * fman_dtsec_init() function.  A default set of configuration values can be
695*852ba100SJustin Hibbits  * obtained by calling fman_dtsec_defconfig().
696*852ba100SJustin Hibbits  */
697*852ba100SJustin Hibbits struct dtsec_cfg {
698*852ba100SJustin Hibbits 	bool		halfdup_on;
699*852ba100SJustin Hibbits 	bool		halfdup_alt_backoff_en;
700*852ba100SJustin Hibbits 	bool		halfdup_excess_defer;
701*852ba100SJustin Hibbits 	bool		halfdup_no_backoff;
702*852ba100SJustin Hibbits 	bool		halfdup_bp_no_backoff;
703*852ba100SJustin Hibbits 	uint8_t		halfdup_alt_backoff_val;
704*852ba100SJustin Hibbits 	uint16_t	halfdup_retransmit;
705*852ba100SJustin Hibbits 	uint16_t	halfdup_coll_window;
706*852ba100SJustin Hibbits 	bool		rx_drop_bcast;
707*852ba100SJustin Hibbits 	bool		rx_short_frm;
708*852ba100SJustin Hibbits 	bool		rx_len_check;
709*852ba100SJustin Hibbits 	bool		tx_pad_crc;
710*852ba100SJustin Hibbits 	bool		tx_crc;
711*852ba100SJustin Hibbits 	bool		rx_ctrl_acc;
712*852ba100SJustin Hibbits 	unsigned short	tx_pause_time;
713*852ba100SJustin Hibbits 	unsigned short	tbipa;
714*852ba100SJustin Hibbits 	bool		ptp_tsu_en;
715*852ba100SJustin Hibbits 	bool		ptp_exception_en;
716*852ba100SJustin Hibbits 	bool		rx_preamble;
717*852ba100SJustin Hibbits 	bool		tx_preamble;
718*852ba100SJustin Hibbits 	unsigned char	preamble_len;
719*852ba100SJustin Hibbits 	unsigned char	rx_prepend;
720*852ba100SJustin Hibbits 	bool		loopback;
721*852ba100SJustin Hibbits 	bool		rx_time_stamp_en;
722*852ba100SJustin Hibbits 	bool		tx_time_stamp_en;
723*852ba100SJustin Hibbits 	bool		rx_flow;
724*852ba100SJustin Hibbits 	bool		tx_flow;
725*852ba100SJustin Hibbits 	bool		rx_group_hash_exd;
726*852ba100SJustin Hibbits 	bool		rx_promisc;
727*852ba100SJustin Hibbits 	uint8_t		tbi_phy_addr;
728*852ba100SJustin Hibbits 	uint16_t	tx_pause_time_extd;
729*852ba100SJustin Hibbits 	uint16_t	maximum_frame;
730*852ba100SJustin Hibbits 	uint32_t	non_back_to_back_ipg1;
731*852ba100SJustin Hibbits 	uint32_t	non_back_to_back_ipg2;
732*852ba100SJustin Hibbits 	uint32_t	min_ifg_enforcement;
733*852ba100SJustin Hibbits 	uint32_t	back_to_back_ipg;
734*852ba100SJustin Hibbits 	bool		wake_on_lan;
735*852ba100SJustin Hibbits };
736*852ba100SJustin Hibbits 
737*852ba100SJustin Hibbits 
738*852ba100SJustin Hibbits /**
739*852ba100SJustin Hibbits  * fman_dtsec_defconfig() - Get default dTSEC configuration
740*852ba100SJustin Hibbits  * @cfg:	pointer to configuration structure.
741*852ba100SJustin Hibbits  *
742*852ba100SJustin Hibbits  * Call this function to obtain a default set of configuration values for
743*852ba100SJustin Hibbits  * initializing dTSEC.  The user can overwrite any of the values before calling
744*852ba100SJustin Hibbits  * fman_dtsec_init(), if specific configuration needs to be applied.
745*852ba100SJustin Hibbits  */
746*852ba100SJustin Hibbits void fman_dtsec_defconfig(struct dtsec_cfg *cfg);
747*852ba100SJustin Hibbits 
748*852ba100SJustin Hibbits /**
749*852ba100SJustin Hibbits  * fman_dtsec_init() - Init dTSEC hardware block
750*852ba100SJustin Hibbits  * @regs:		Pointer to dTSEC register block
751*852ba100SJustin Hibbits  * @cfg:		dTSEC configuration data
752*852ba100SJustin Hibbits  * @iface_mode:		dTSEC interface mode, the type of MAC - PHY interface.
753*852ba100SJustin Hibbits  * @iface_speed:	1G or 10G
754*852ba100SJustin Hibbits  * @macaddr:		MAC station address to be assigned to the device
755*852ba100SJustin Hibbits  * @fm_rev_maj:		major rev number
756*852ba100SJustin Hibbits  * @fm_rev_min:		minor rev number
757*852ba100SJustin Hibbits  * @exceptions_mask:	initial exceptions mask
758*852ba100SJustin Hibbits  *
759*852ba100SJustin Hibbits  * This function initializes dTSEC and applies basic configuration.
760*852ba100SJustin Hibbits  *
761*852ba100SJustin Hibbits  * dTSEC initialization sequence:
762*852ba100SJustin Hibbits  * Before enabling Rx/Tx call dtsec_set_address() to set MAC address,
763*852ba100SJustin Hibbits  * fman_dtsec_adjust_link() to configure interface speed and duplex and finally
764*852ba100SJustin Hibbits  * dtsec_enable_tx()/dtsec_enable_rx() to start transmission and reception.
765*852ba100SJustin Hibbits  *
766*852ba100SJustin Hibbits  * Returns: 0 if successful, an error code otherwise.
767*852ba100SJustin Hibbits  */
768*852ba100SJustin Hibbits int fman_dtsec_init(struct dtsec_regs *regs, struct dtsec_cfg *cfg,
769*852ba100SJustin Hibbits 	enum enet_interface iface_mode,
770*852ba100SJustin Hibbits 	enum enet_speed iface_speed,
771*852ba100SJustin Hibbits 	uint8_t *macaddr, uint8_t fm_rev_maj,
772*852ba100SJustin Hibbits 	uint8_t fm_rev_min,
773*852ba100SJustin Hibbits 	uint32_t exception_mask);
774*852ba100SJustin Hibbits 
775*852ba100SJustin Hibbits /**
776*852ba100SJustin Hibbits  * fman_dtsec_enable() - Enable dTSEC Tx and Tx
777*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
778*852ba100SJustin Hibbits  * @apply_rx:	enable rx side
779*852ba100SJustin Hibbits  * @apply_tx:	enable tx side
780*852ba100SJustin Hibbits  *
781*852ba100SJustin Hibbits  * This function resets Tx and Rx graceful stop bit and enables dTSEC Tx and Rx.
782*852ba100SJustin Hibbits  */
783*852ba100SJustin Hibbits void fman_dtsec_enable(struct dtsec_regs *regs, bool apply_rx, bool apply_tx);
784*852ba100SJustin Hibbits 
785*852ba100SJustin Hibbits /**
786*852ba100SJustin Hibbits  * fman_dtsec_disable() - Disable dTSEC Tx and Rx
787*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
788*852ba100SJustin Hibbits  * @apply_rx:	disable rx side
789*852ba100SJustin Hibbits  * @apply_tx:	disable tx side
790*852ba100SJustin Hibbits  *
791*852ba100SJustin Hibbits  * This function disables Tx and Rx in dTSEC.
792*852ba100SJustin Hibbits  */
793*852ba100SJustin Hibbits void fman_dtsec_disable(struct dtsec_regs *regs, bool apply_rx, bool apply_tx);
794*852ba100SJustin Hibbits 
795*852ba100SJustin Hibbits /**
796*852ba100SJustin Hibbits  * fman_dtsec_get_revision() - Get dTSEC hardware revision
797*852ba100SJustin Hibbits  * @regs:   Pointer to dTSEC register block
798*852ba100SJustin Hibbits  *
799*852ba100SJustin Hibbits  * Returns dtsec_id content
800*852ba100SJustin Hibbits  *
801*852ba100SJustin Hibbits  * Call this function to obtain the dTSEC hardware version.
802*852ba100SJustin Hibbits  */
803*852ba100SJustin Hibbits uint32_t fman_dtsec_get_revision(struct dtsec_regs *regs);
804*852ba100SJustin Hibbits 
805*852ba100SJustin Hibbits /**
806*852ba100SJustin Hibbits  * fman_dtsec_set_mac_address() - Set MAC station address
807*852ba100SJustin Hibbits  * @regs:   Pointer to dTSEC register block
808*852ba100SJustin Hibbits  * @macaddr:    MAC address array
809*852ba100SJustin Hibbits  *
810*852ba100SJustin Hibbits  * This function sets MAC station address.  To enable unicast reception call
811*852ba100SJustin Hibbits  * this after fman_dtsec_init().  While promiscuous mode is disabled dTSEC will
812*852ba100SJustin Hibbits  * match the destination address of received unicast frames against this
813*852ba100SJustin Hibbits  * address.
814*852ba100SJustin Hibbits  */
815*852ba100SJustin Hibbits void fman_dtsec_set_mac_address(struct dtsec_regs *regs, uint8_t *macaddr);
816*852ba100SJustin Hibbits 
817*852ba100SJustin Hibbits /**
818*852ba100SJustin Hibbits  * fman_dtsec_get_mac_address() - Query MAC station address
819*852ba100SJustin Hibbits  * @regs:   Pointer to dTSEC register block
820*852ba100SJustin Hibbits  * @macaddr:    MAC address array
821*852ba100SJustin Hibbits  */
822*852ba100SJustin Hibbits void fman_dtsec_get_mac_address(struct dtsec_regs *regs, uint8_t *macaddr);
823*852ba100SJustin Hibbits 
824*852ba100SJustin Hibbits /**
825*852ba100SJustin Hibbits  * fman_dtsec_set_uc_promisc() - Sets unicast promiscuous mode
826*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
827*852ba100SJustin Hibbits  * @enable:	Enable unicast promiscuous mode
828*852ba100SJustin Hibbits  *
829*852ba100SJustin Hibbits  * Use this function to enable/disable dTSEC L2 address filtering.  If the
830*852ba100SJustin Hibbits  * address filtering is disabled all unicast packets are accepted.
831*852ba100SJustin Hibbits  * To set dTSEC in promiscuous mode call both fman_dtsec_set_uc_promisc() and
832*852ba100SJustin Hibbits  * fman_dtsec_set_mc_promisc() to disable filtering for both unicast and
833*852ba100SJustin Hibbits  * multicast addresses.
834*852ba100SJustin Hibbits  */
835*852ba100SJustin Hibbits void fman_dtsec_set_uc_promisc(struct dtsec_regs *regs, bool enable);
836*852ba100SJustin Hibbits 
837*852ba100SJustin Hibbits /**
838*852ba100SJustin Hibbits  * fman_dtsec_set_wol() - Enable/Disable wake on lan
839*852ba100SJustin Hibbits  *                        (magic packet support)
840*852ba100SJustin Hibbits  * @regs:   Pointer to dTSEC register block
841*852ba100SJustin Hibbits  * @en:     Enable Wake On Lan support in dTSEC
842*852ba100SJustin Hibbits  *
843*852ba100SJustin Hibbits  */
844*852ba100SJustin Hibbits void fman_dtsec_set_wol(struct dtsec_regs *regs, bool en);
845*852ba100SJustin Hibbits 
846*852ba100SJustin Hibbits /**
847*852ba100SJustin Hibbits  * fman_dtsec_adjust_link() - Adjust dTSEC speed/duplex settings
848*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
849*852ba100SJustin Hibbits  * @iface_mode: dTSEC interface mode
850*852ba100SJustin Hibbits  * @speed:	Link speed
851*852ba100SJustin Hibbits  * @full_dx:	True for full-duplex, false for half-duplex.
852*852ba100SJustin Hibbits  *
853*852ba100SJustin Hibbits  * This function configures the MAC to function and the desired rates.  Use it
854*852ba100SJustin Hibbits  * to configure dTSEC after fman_dtsec_init() and whenever the link speed
855*852ba100SJustin Hibbits  * changes (for instance following PHY auto-negociation).
856*852ba100SJustin Hibbits  *
857*852ba100SJustin Hibbits  * Returns: 0 if successful, an error code otherwise.
858*852ba100SJustin Hibbits  */
859*852ba100SJustin Hibbits int fman_dtsec_adjust_link(struct dtsec_regs *regs,
860*852ba100SJustin Hibbits 	enum enet_interface iface_mode,
861*852ba100SJustin Hibbits 	enum enet_speed speed, bool full_dx);
862*852ba100SJustin Hibbits 
863*852ba100SJustin Hibbits /**
864*852ba100SJustin Hibbits  * fman_dtsec_set_tbi_phy_addr() - Updates TBI address field
865*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
866*852ba100SJustin Hibbits  * @address:	Valid PHY address in the range of 1 to 31. 0 is reserved.
867*852ba100SJustin Hibbits  *
868*852ba100SJustin Hibbits  * In SGMII mode, the dTSEC's TBIPA field must contain a valid TBI PHY address
869*852ba100SJustin Hibbits  * so that the associated TBI PHY (i.e. the link) may be initialized.
870*852ba100SJustin Hibbits  *
871*852ba100SJustin Hibbits  * Returns: 0 if successful, an error code otherwise.
872*852ba100SJustin Hibbits  */
873*852ba100SJustin Hibbits int fman_dtsec_set_tbi_phy_addr(struct dtsec_regs *regs,
874*852ba100SJustin Hibbits 	uint8_t addr);
875*852ba100SJustin Hibbits 
876*852ba100SJustin Hibbits /**
877*852ba100SJustin Hibbits  * fman_dtsec_set_max_frame_len() - Set max frame length
878*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
879*852ba100SJustin Hibbits  * @length:	Max frame length.
880*852ba100SJustin Hibbits  *
881*852ba100SJustin Hibbits  * Sets maximum frame length for received and transmitted frames.  Frames that
882*852ba100SJustin Hibbits  * exceeds this length are truncated.
883*852ba100SJustin Hibbits  */
884*852ba100SJustin Hibbits void fman_dtsec_set_max_frame_len(struct dtsec_regs *regs, uint16_t length);
885*852ba100SJustin Hibbits 
886*852ba100SJustin Hibbits /**
887*852ba100SJustin Hibbits  * fman_dtsec_get_max_frame_len() - Query max frame length
888*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
889*852ba100SJustin Hibbits  *
890*852ba100SJustin Hibbits  * Returns: the current value of the maximum frame length.
891*852ba100SJustin Hibbits  */
892*852ba100SJustin Hibbits uint16_t fman_dtsec_get_max_frame_len(struct dtsec_regs *regs);
893*852ba100SJustin Hibbits 
894*852ba100SJustin Hibbits /**
895*852ba100SJustin Hibbits  * fman_dtsec_handle_rx_pause() - Configure pause frame handling
896*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
897*852ba100SJustin Hibbits  * @en:		Enable pause frame handling in dTSEC
898*852ba100SJustin Hibbits  *
899*852ba100SJustin Hibbits  * If enabled, dTSEC will handle pause frames internally.  This must be disabled
900*852ba100SJustin Hibbits  * if dTSEC is set in half-duplex mode.
901*852ba100SJustin Hibbits  * If pause frame handling is disabled and &dtsec_cfg.rx_ctrl_acc is set, pause
902*852ba100SJustin Hibbits  * frames will be transferred to the packet interface just like regular Ethernet
903*852ba100SJustin Hibbits  * frames.
904*852ba100SJustin Hibbits  */
905*852ba100SJustin Hibbits void fman_dtsec_handle_rx_pause(struct dtsec_regs *regs, bool en);
906*852ba100SJustin Hibbits 
907*852ba100SJustin Hibbits /**
908*852ba100SJustin Hibbits  * fman_dtsec_set_tx_pause_frames() - Configure Tx pause time
909*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
910*852ba100SJustin Hibbits  * @time:	Time value included in pause frames
911*852ba100SJustin Hibbits  *
912*852ba100SJustin Hibbits  * Call this function to set the time value used in transmitted pause frames.
913*852ba100SJustin Hibbits  * If time is 0, transmission of pause frames is disabled
914*852ba100SJustin Hibbits  */
915*852ba100SJustin Hibbits void fman_dtsec_set_tx_pause_frames(struct dtsec_regs *regs, uint16_t time);
916*852ba100SJustin Hibbits 
917*852ba100SJustin Hibbits /**
918*852ba100SJustin Hibbits  * fman_dtsec_ack_event() - Acknowledge handled events
919*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
920*852ba100SJustin Hibbits  * @ev_mask:	Events to acknowledge
921*852ba100SJustin Hibbits  *
922*852ba100SJustin Hibbits  * After handling events signaled by dTSEC in either polling or interrupt mode,
923*852ba100SJustin Hibbits  * call this function to reset the associated status bits in dTSEC event
924*852ba100SJustin Hibbits  * register.
925*852ba100SJustin Hibbits  */
926*852ba100SJustin Hibbits void fman_dtsec_ack_event(struct dtsec_regs *regs, uint32_t ev_mask);
927*852ba100SJustin Hibbits 
928*852ba100SJustin Hibbits /**
929*852ba100SJustin Hibbits  * fman_dtsec_get_event() - Returns currently asserted events
930*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
931*852ba100SJustin Hibbits  * @ev_mask:	Mask of relevant events
932*852ba100SJustin Hibbits  *
933*852ba100SJustin Hibbits  * Call this function to obtain a bit-mask of events that are currently asserted
934*852ba100SJustin Hibbits  * in dTSEC, taken from IEVENT register.
935*852ba100SJustin Hibbits  *
936*852ba100SJustin Hibbits  * Returns: a bit-mask of events asserted in dTSEC.
937*852ba100SJustin Hibbits  */
938*852ba100SJustin Hibbits uint32_t fman_dtsec_get_event(struct dtsec_regs *regs, uint32_t ev_mask);
939*852ba100SJustin Hibbits 
940*852ba100SJustin Hibbits /**
941*852ba100SJustin Hibbits  * fman_dtsec_get_interrupt_mask() - Returns a bit-mask of enabled interrupts
942*852ba100SJustin Hibbits  * @regs:   Pointer to dTSEC register block
943*852ba100SJustin Hibbits  *
944*852ba100SJustin Hibbits  * Call this function to obtain a bit-mask of enabled interrupts
945*852ba100SJustin Hibbits  * in dTSEC, taken from IMASK register.
946*852ba100SJustin Hibbits  *
947*852ba100SJustin Hibbits  * Returns: a bit-mask of enabled interrupts in dTSEC.
948*852ba100SJustin Hibbits  */
949*852ba100SJustin Hibbits uint32_t fman_dtsec_get_interrupt_mask(struct dtsec_regs *regs);
950*852ba100SJustin Hibbits 
951*852ba100SJustin Hibbits void fman_dtsec_clear_addr_in_paddr(struct dtsec_regs *regs,
952*852ba100SJustin Hibbits 	uint8_t paddr_num);
953*852ba100SJustin Hibbits 
954*852ba100SJustin Hibbits void fman_dtsec_add_addr_in_paddr(struct dtsec_regs *regs,
955*852ba100SJustin Hibbits 	uint64_t addr,
956*852ba100SJustin Hibbits 	uint8_t paddr_num);
957*852ba100SJustin Hibbits 
958*852ba100SJustin Hibbits void fman_dtsec_enable_tmr_interrupt (struct dtsec_regs *regs);
959*852ba100SJustin Hibbits 
960*852ba100SJustin Hibbits void fman_dtsec_disable_tmr_interrupt(struct dtsec_regs *regs);
961*852ba100SJustin Hibbits 
962*852ba100SJustin Hibbits /**
963*852ba100SJustin Hibbits  * fman_dtsec_disable_interrupt() - Disables interrupts for the specified events
964*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
965*852ba100SJustin Hibbits  * @ev_mask:	Mask of relevant events
966*852ba100SJustin Hibbits  *
967*852ba100SJustin Hibbits  * Call this function to disable interrupts in dTSEC for the specified events.
968*852ba100SJustin Hibbits  * To enable interrupts use fman_dtsec_enable_interrupt().
969*852ba100SJustin Hibbits  */
970*852ba100SJustin Hibbits void fman_dtsec_disable_interrupt(struct dtsec_regs *regs, uint32_t ev_mask);
971*852ba100SJustin Hibbits 
972*852ba100SJustin Hibbits /**
973*852ba100SJustin Hibbits  * fman_dtsec_enable_interrupt() - Enable interrupts for the specified events
974*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
975*852ba100SJustin Hibbits  * @ev_mask:	Mask of relevant events
976*852ba100SJustin Hibbits  *
977*852ba100SJustin Hibbits  * Call this function to enable interrupts in dTSEC for the specified events.
978*852ba100SJustin Hibbits  * To disable interrupts use fman_dtsec_disable_interrupt().
979*852ba100SJustin Hibbits  */
980*852ba100SJustin Hibbits void fman_dtsec_enable_interrupt(struct dtsec_regs *regs, uint32_t ev_mask);
981*852ba100SJustin Hibbits 
982*852ba100SJustin Hibbits /**
983*852ba100SJustin Hibbits  * fman_dtsec_set_ts() - Enables dTSEC timestamps
984*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
985*852ba100SJustin Hibbits  * @en:		true to enable timestamps, false to disable them
986*852ba100SJustin Hibbits  *
987*852ba100SJustin Hibbits  * Call this function to enable/disable dTSEC timestamps.  This affects both
988*852ba100SJustin Hibbits  * Tx and Rx.
989*852ba100SJustin Hibbits  */
990*852ba100SJustin Hibbits void fman_dtsec_set_ts(struct dtsec_regs *regs, bool en);
991*852ba100SJustin Hibbits 
992*852ba100SJustin Hibbits /**
993*852ba100SJustin Hibbits  * fman_dtsec_set_bucket() - Enables/disables a filter bucket
994*852ba100SJustin Hibbits  * @regs:   Pointer to dTSEC register block
995*852ba100SJustin Hibbits  * @bucket: Bucket index
996*852ba100SJustin Hibbits  * @enable: true/false to enable/disable this bucket
997*852ba100SJustin Hibbits  *
998*852ba100SJustin Hibbits  * This function enables or disables the specified bucket.  Enabling a bucket
999*852ba100SJustin Hibbits  * associated with an address configures dTSEC to accept received packets
1000*852ba100SJustin Hibbits  * with that destination address.
1001*852ba100SJustin Hibbits  * Multiple addresses may be associated with the same bucket.  Disabling a
1002*852ba100SJustin Hibbits  * bucket will affect all addresses associated with that bucket. A bucket that
1003*852ba100SJustin Hibbits  * is enabled requires further filtering and verification in the upper layers
1004*852ba100SJustin Hibbits  *
1005*852ba100SJustin Hibbits  */
1006*852ba100SJustin Hibbits void fman_dtsec_set_bucket(struct dtsec_regs *regs, int bucket, bool enable);
1007*852ba100SJustin Hibbits 
1008*852ba100SJustin Hibbits /**
1009*852ba100SJustin Hibbits  * dtsec_set_hash_table() - insert a crc code into thr filter table
1010*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
1011*852ba100SJustin Hibbits  * @crc:	crc to insert
1012*852ba100SJustin Hibbits  * @mcast:	true is this is a multicast address
1013*852ba100SJustin Hibbits  * @ghtx:	true if we are in ghtx mode
1014*852ba100SJustin Hibbits  *
1015*852ba100SJustin Hibbits  * This function inserts a crc code into the filter table.
1016*852ba100SJustin Hibbits  */
1017*852ba100SJustin Hibbits void fman_dtsec_set_hash_table(struct dtsec_regs *regs, uint32_t crc,
1018*852ba100SJustin Hibbits 	bool mcast, bool ghtx);
1019*852ba100SJustin Hibbits 
1020*852ba100SJustin Hibbits /**
1021*852ba100SJustin Hibbits  * fman_dtsec_reset_filter_table() - Resets the address filtering table
1022*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
1023*852ba100SJustin Hibbits  * @mcast:	Reset multicast entries
1024*852ba100SJustin Hibbits  * @ucast:	Reset unicast entries
1025*852ba100SJustin Hibbits  *
1026*852ba100SJustin Hibbits  * Resets all entries in L2 address filter table.  After calling this function
1027*852ba100SJustin Hibbits  * all buckets enabled using fman_dtsec_set_bucket() will be disabled.
1028*852ba100SJustin Hibbits  * If dtsec_init_filter_table() was called with @unicast_hash set to false,
1029*852ba100SJustin Hibbits  * @ucast argument is ignored.
1030*852ba100SJustin Hibbits  * This does not affect the primary nor the 15 additional addresses configured
1031*852ba100SJustin Hibbits  * using dtsec_set_address() or dtsec_set_match_address().
1032*852ba100SJustin Hibbits  */
1033*852ba100SJustin Hibbits void fman_dtsec_reset_filter_table(struct dtsec_regs *regs, bool mcast,
1034*852ba100SJustin Hibbits 	bool ucast);
1035*852ba100SJustin Hibbits 
1036*852ba100SJustin Hibbits /**
1037*852ba100SJustin Hibbits  * fman_dtsec_set_mc_promisc() - Set multicast promiscuous mode
1038*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
1039*852ba100SJustin Hibbits  * @enable:	Enable multicast promiscuous mode
1040*852ba100SJustin Hibbits  *
1041*852ba100SJustin Hibbits  * Call this to enable/disable L2 address filtering for multicast packets.
1042*852ba100SJustin Hibbits  */
1043*852ba100SJustin Hibbits void fman_dtsec_set_mc_promisc(struct dtsec_regs *regs, bool enable);
1044*852ba100SJustin Hibbits 
1045*852ba100SJustin Hibbits /* statistics APIs */
1046*852ba100SJustin Hibbits 
1047*852ba100SJustin Hibbits /**
1048*852ba100SJustin Hibbits  * fman_dtsec_set_stat_level() - Enable a group of MIB statistics counters
1049*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
1050*852ba100SJustin Hibbits  * @level:	Specifies a certain group of dTSEC MIB HW counters or _all_,
1051*852ba100SJustin Hibbits  *		to specify all the existing counters.
1052*852ba100SJustin Hibbits  *		If set to _none_, it disables all the counters.
1053*852ba100SJustin Hibbits  *
1054*852ba100SJustin Hibbits  * Enables the MIB statistics hw counters and sets up the carry interrupt
1055*852ba100SJustin Hibbits  * masks for the counters corresponding to the @level input parameter.
1056*852ba100SJustin Hibbits  *
1057*852ba100SJustin Hibbits  * Returns: error if invalid @level value given.
1058*852ba100SJustin Hibbits  */
1059*852ba100SJustin Hibbits int fman_dtsec_set_stat_level(struct dtsec_regs *regs,
1060*852ba100SJustin Hibbits 	enum dtsec_stat_level level);
1061*852ba100SJustin Hibbits 
1062*852ba100SJustin Hibbits /**
1063*852ba100SJustin Hibbits  * fman_dtsec_reset_stat() - Completely resets all dTSEC HW counters
1064*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
1065*852ba100SJustin Hibbits  */
1066*852ba100SJustin Hibbits void fman_dtsec_reset_stat(struct dtsec_regs *regs);
1067*852ba100SJustin Hibbits 
1068*852ba100SJustin Hibbits /**
1069*852ba100SJustin Hibbits  * fman_dtsec_get_clear_carry_regs() - Read and clear carry bits (CAR1-2 registers)
1070*852ba100SJustin Hibbits  * @regs:	Pointer to dTSEC register block
1071*852ba100SJustin Hibbits  * @car1:	car1 register value
1072*852ba100SJustin Hibbits  * @car2:	car2 register value
1073*852ba100SJustin Hibbits  *
1074*852ba100SJustin Hibbits  * When set, the carry bits signal that an overflow occurred on the
1075*852ba100SJustin Hibbits  * corresponding counters.
1076*852ba100SJustin Hibbits  * Note that the carry bits (CAR1-2 registers) will assert the
1077*852ba100SJustin Hibbits  * %DTSEC_IEVENT_MSRO interrupt if unmasked (via CAM1-2 regs).
1078*852ba100SJustin Hibbits  *
1079*852ba100SJustin Hibbits  * Returns: true if overflow occurred, otherwise - false
1080*852ba100SJustin Hibbits  */
1081*852ba100SJustin Hibbits bool fman_dtsec_get_clear_carry_regs(struct dtsec_regs *regs,
1082*852ba100SJustin Hibbits 	uint32_t *car1, uint32_t *car2);
1083*852ba100SJustin Hibbits 
1084*852ba100SJustin Hibbits uint32_t fman_dtsec_check_and_clear_tmr_event(struct dtsec_regs *regs);
1085*852ba100SJustin Hibbits 
1086*852ba100SJustin Hibbits uint32_t fman_dtsec_get_stat_counter(struct dtsec_regs *regs,
1087*852ba100SJustin Hibbits 	enum dtsec_stat_counters reg_name);
1088*852ba100SJustin Hibbits 
1089*852ba100SJustin Hibbits void fman_dtsec_start_tx(struct dtsec_regs *regs);
1090*852ba100SJustin Hibbits void fman_dtsec_start_rx(struct dtsec_regs *regs);
1091*852ba100SJustin Hibbits void fman_dtsec_stop_tx(struct dtsec_regs *regs);
1092*852ba100SJustin Hibbits void fman_dtsec_stop_rx(struct dtsec_regs *regs);
1093*852ba100SJustin Hibbits uint32_t fman_dtsec_get_rctrl(struct dtsec_regs *regs);
1094*852ba100SJustin Hibbits 
1095*852ba100SJustin Hibbits 
1096*852ba100SJustin Hibbits #endif /* __FSL_FMAN_DTSEC_H */
1097