xref: /openbmc/linux/drivers/net/ethernet/sun/cassini.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
156cb4e50SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0+ */
2e689cf4aSJeff Kirsher /* $Id: cassini.h,v 1.16 2004/08/17 21:15:16 zaumen Exp $
3e689cf4aSJeff Kirsher  * cassini.h: Definitions for Sun Microsystems Cassini(+) ethernet driver.
4e689cf4aSJeff Kirsher  *
5e689cf4aSJeff Kirsher  * Copyright (C) 2004 Sun Microsystems Inc.
6e689cf4aSJeff Kirsher  * Copyright (c) 2003 Adrian Sun (asun@darksunrising.com)
7e689cf4aSJeff Kirsher  *
8e689cf4aSJeff Kirsher  * vendor id: 0x108E (Sun Microsystems, Inc.)
9e689cf4aSJeff Kirsher  * device id: 0xabba (Cassini)
10e689cf4aSJeff Kirsher  * revision ids: 0x01 = Cassini
11e689cf4aSJeff Kirsher  *               0x02 = Cassini rev 2
12e689cf4aSJeff Kirsher  *               0x10 = Cassini+
13e689cf4aSJeff Kirsher  *               0x11 = Cassini+ 0.2u
14e689cf4aSJeff Kirsher  *
15e689cf4aSJeff Kirsher  * vendor id: 0x100b (National Semiconductor)
16e689cf4aSJeff Kirsher  * device id: 0x0035 (DP83065/Saturn)
17e689cf4aSJeff Kirsher  * revision ids: 0x30 = Saturn B2
18e689cf4aSJeff Kirsher  *
19e689cf4aSJeff Kirsher  * rings are all offset from 0.
20e689cf4aSJeff Kirsher  *
21e689cf4aSJeff Kirsher  * there are two clock domains:
22e689cf4aSJeff Kirsher  * PCI:  33/66MHz clock
23e689cf4aSJeff Kirsher  * chip: 125MHz clock
24e689cf4aSJeff Kirsher  */
25e689cf4aSJeff Kirsher 
26e689cf4aSJeff Kirsher #ifndef _CASSINI_H
27e689cf4aSJeff Kirsher #define _CASSINI_H
28e689cf4aSJeff Kirsher 
29e689cf4aSJeff Kirsher /* cassini register map: 2M memory mapped in 32-bit memory space accessible as
30e689cf4aSJeff Kirsher  * 32-bit words. there is no i/o port access. REG_ addresses are
31e689cf4aSJeff Kirsher  * shared between cassini and cassini+. REG_PLUS_ addresses only
32e689cf4aSJeff Kirsher  * appear in cassini+. REG_MINUS_ addresses only appear in cassini.
33e689cf4aSJeff Kirsher  */
34e689cf4aSJeff Kirsher #define CAS_ID_REV2          0x02
35e689cf4aSJeff Kirsher #define CAS_ID_REVPLUS       0x10
36e689cf4aSJeff Kirsher #define CAS_ID_REVPLUS02u    0x11
37e689cf4aSJeff Kirsher #define CAS_ID_REVSATURNB2   0x30
38e689cf4aSJeff Kirsher 
39e689cf4aSJeff Kirsher /** global resources **/
40e689cf4aSJeff Kirsher 
41e689cf4aSJeff Kirsher /* this register sets the weights for the weighted round robin arbiter. e.g.,
42e689cf4aSJeff Kirsher  * if rx weight == 1 and tx weight == 0, rx == 2x tx transfer credit
43e689cf4aSJeff Kirsher  * for its next turn to access the pci bus.
44e689cf4aSJeff Kirsher  * map: 0x0 = x1, 0x1 = x2, 0x2 = x4, 0x3 = x8
45e689cf4aSJeff Kirsher  * DEFAULT: 0x0, SIZE: 5 bits
46e689cf4aSJeff Kirsher  */
47e689cf4aSJeff Kirsher #define  REG_CAWR	               0x0004  /* core arbitration weight */
48e689cf4aSJeff Kirsher #define    CAWR_RX_DMA_WEIGHT_SHIFT    0
49e689cf4aSJeff Kirsher #define    CAWR_RX_DMA_WEIGHT_MASK     0x03    /* [0:1] */
50e689cf4aSJeff Kirsher #define    CAWR_TX_DMA_WEIGHT_SHIFT    2
51e689cf4aSJeff Kirsher #define    CAWR_TX_DMA_WEIGHT_MASK     0x0C    /* [3:2] */
52e689cf4aSJeff Kirsher #define    CAWR_RR_DIS                 0x10    /* [4] */
53e689cf4aSJeff Kirsher 
54e689cf4aSJeff Kirsher /* if enabled, BIM can send bursts across PCI bus > cacheline size. burst
55e689cf4aSJeff Kirsher  * sizes determined by length of packet or descriptor transfer and the
56e689cf4aSJeff Kirsher  * max length allowed by the target.
57e689cf4aSJeff Kirsher  * DEFAULT: 0x0, SIZE: 1 bit
58e689cf4aSJeff Kirsher  */
59e689cf4aSJeff Kirsher #define  REG_INF_BURST                 0x0008  /* infinite burst enable reg */
60e689cf4aSJeff Kirsher #define    INF_BURST_EN                0x1     /* enable */
61e689cf4aSJeff Kirsher 
62e689cf4aSJeff Kirsher /* top level interrupts [0-9] are auto-cleared to 0 when the status
63e689cf4aSJeff Kirsher  * register is read. second level interrupts [13 - 18] are cleared at
64e689cf4aSJeff Kirsher  * the source. tx completion register 3 is replicated in [19 - 31]
65e689cf4aSJeff Kirsher  * DEFAULT: 0x00000000, SIZE: 29 bits
66e689cf4aSJeff Kirsher  */
67e689cf4aSJeff Kirsher #define  REG_INTR_STATUS               0x000C  /* interrupt status register */
68e689cf4aSJeff Kirsher #define    INTR_TX_INTME               0x00000001  /* frame w/ INT ME desc bit set
69e689cf4aSJeff Kirsher 						      xferred from host queue to
70e689cf4aSJeff Kirsher 						      TX FIFO */
71e689cf4aSJeff Kirsher #define    INTR_TX_ALL                 0x00000002  /* all xmit frames xferred into
72e689cf4aSJeff Kirsher 						      TX FIFO. i.e.,
73e689cf4aSJeff Kirsher 						      TX Kick == TX complete. if
74e689cf4aSJeff Kirsher 						      PACED_MODE set, then TX FIFO
75e689cf4aSJeff Kirsher 						      also empty */
76e689cf4aSJeff Kirsher #define    INTR_TX_DONE                0x00000004  /* any frame xferred into tx
77e689cf4aSJeff Kirsher 						      FIFO */
78e689cf4aSJeff Kirsher #define    INTR_TX_TAG_ERROR           0x00000008  /* TX FIFO tag framing
79e689cf4aSJeff Kirsher 						      corrupted. FATAL ERROR */
80e689cf4aSJeff Kirsher #define    INTR_RX_DONE                0x00000010  /* at least 1 frame xferred
81e689cf4aSJeff Kirsher 						      from RX FIFO to host mem.
82e689cf4aSJeff Kirsher 						      RX completion reg updated.
83e689cf4aSJeff Kirsher 						      may be delayed by recv
84e689cf4aSJeff Kirsher 						      intr blanking. */
85e689cf4aSJeff Kirsher #define    INTR_RX_BUF_UNAVAIL         0x00000020  /* no more receive buffers.
86e689cf4aSJeff Kirsher 						      RX Kick == RX complete */
87e689cf4aSJeff Kirsher #define    INTR_RX_TAG_ERROR           0x00000040  /* RX FIFO tag framing
88e689cf4aSJeff Kirsher 						      corrupted. FATAL ERROR */
89e689cf4aSJeff Kirsher #define    INTR_RX_COMP_FULL           0x00000080  /* no more room in completion
90e689cf4aSJeff Kirsher 						      ring to post descriptors.
91e689cf4aSJeff Kirsher 						      RX complete head incr to
92e689cf4aSJeff Kirsher 						      almost reach RX complete
93e689cf4aSJeff Kirsher 						      tail */
94e689cf4aSJeff Kirsher #define    INTR_RX_BUF_AE              0x00000100  /* less than the
95e689cf4aSJeff Kirsher 						      programmable threshold #
96e689cf4aSJeff Kirsher 						      of free descr avail for
97e689cf4aSJeff Kirsher 						      hw use */
98e689cf4aSJeff Kirsher #define    INTR_RX_COMP_AF             0x00000200  /* less than the
99e689cf4aSJeff Kirsher 						      programmable threshold #
100e689cf4aSJeff Kirsher 						      of descr spaces for hw
101e689cf4aSJeff Kirsher 						      use in completion descr
102e689cf4aSJeff Kirsher 						      ring */
103e689cf4aSJeff Kirsher #define    INTR_RX_LEN_MISMATCH        0x00000400  /* len field from MAC !=
104e689cf4aSJeff Kirsher 						      len of non-reassembly pkt
105e689cf4aSJeff Kirsher 						      from fifo during DMA or
106e689cf4aSJeff Kirsher 						      header parser provides TCP
107e689cf4aSJeff Kirsher 						      header and payload size >
108e689cf4aSJeff Kirsher 						      MAC packet size.
109e689cf4aSJeff Kirsher 						      FATAL ERROR */
110e689cf4aSJeff Kirsher #define    INTR_SUMMARY                0x00001000  /* summary interrupt bit. this
111e689cf4aSJeff Kirsher 						      bit will be set if an interrupt
112e689cf4aSJeff Kirsher 						      generated on the pci bus. useful
113e689cf4aSJeff Kirsher 						      when driver is polling for
114e689cf4aSJeff Kirsher 						      interrupts */
115e689cf4aSJeff Kirsher #define    INTR_PCS_STATUS             0x00002000  /* PCS interrupt status register */
116e689cf4aSJeff Kirsher #define    INTR_TX_MAC_STATUS          0x00004000  /* TX MAC status register has at
117e689cf4aSJeff Kirsher 						      least 1 unmasked interrupt set */
118e689cf4aSJeff Kirsher #define    INTR_RX_MAC_STATUS          0x00008000  /* RX MAC status register has at
119e689cf4aSJeff Kirsher 						      least 1 unmasked interrupt set */
120e689cf4aSJeff Kirsher #define    INTR_MAC_CTRL_STATUS        0x00010000  /* MAC control status register has
121e689cf4aSJeff Kirsher 						      at least 1 unmasked interrupt
122e689cf4aSJeff Kirsher 						      set */
123e689cf4aSJeff Kirsher #define    INTR_MIF_STATUS             0x00020000  /* MIF status register has at least
124e689cf4aSJeff Kirsher 						      1 unmasked interrupt set */
125e689cf4aSJeff Kirsher #define    INTR_PCI_ERROR_STATUS       0x00040000  /* PCI error status register in the
126e689cf4aSJeff Kirsher 						      BIF has at least 1 unmasked
127e689cf4aSJeff Kirsher 						      interrupt set */
128e689cf4aSJeff Kirsher #define    INTR_TX_COMP_3_MASK         0xFFF80000  /* mask for TX completion
129e689cf4aSJeff Kirsher 						      3 reg data */
130e689cf4aSJeff Kirsher #define    INTR_TX_COMP_3_SHIFT        19
131e689cf4aSJeff Kirsher #define    INTR_ERROR_MASK (INTR_MIF_STATUS | INTR_PCI_ERROR_STATUS | \
132e689cf4aSJeff Kirsher                             INTR_PCS_STATUS | INTR_RX_LEN_MISMATCH | \
133e689cf4aSJeff Kirsher                             INTR_TX_MAC_STATUS | INTR_RX_MAC_STATUS | \
134e689cf4aSJeff Kirsher                             INTR_TX_TAG_ERROR | INTR_RX_TAG_ERROR | \
135e689cf4aSJeff Kirsher                             INTR_MAC_CTRL_STATUS)
136e689cf4aSJeff Kirsher 
137e689cf4aSJeff Kirsher /* determines which status events will cause an interrupt. layout same
138e689cf4aSJeff Kirsher  * as REG_INTR_STATUS.
139e689cf4aSJeff Kirsher  * DEFAULT: 0xFFFFFFFF, SIZE: 16 bits
140e689cf4aSJeff Kirsher  */
141e689cf4aSJeff Kirsher #define  REG_INTR_MASK                 0x0010  /* Interrupt mask */
142e689cf4aSJeff Kirsher 
143e689cf4aSJeff Kirsher /* top level interrupt bits that are cleared during read of REG_INTR_STATUS_ALIAS.
144e689cf4aSJeff Kirsher  * useful when driver is polling for interrupts. layout same as REG_INTR_MASK.
145e689cf4aSJeff Kirsher  * DEFAULT: 0x00000000, SIZE: 12 bits
146e689cf4aSJeff Kirsher  */
147e689cf4aSJeff Kirsher #define  REG_ALIAS_CLEAR               0x0014  /* alias clear mask
148e689cf4aSJeff Kirsher 						  (used w/ status alias) */
149e689cf4aSJeff Kirsher /* same as REG_INTR_STATUS except that only bits cleared are those selected by
150e689cf4aSJeff Kirsher  * REG_ALIAS_CLEAR
151e689cf4aSJeff Kirsher  * DEFAULT: 0x00000000, SIZE: 29 bits
152e689cf4aSJeff Kirsher  */
153e689cf4aSJeff Kirsher #define  REG_INTR_STATUS_ALIAS         0x001C  /* interrupt status alias
154e689cf4aSJeff Kirsher 						  (selective clear) */
155e689cf4aSJeff Kirsher 
156e689cf4aSJeff Kirsher /* DEFAULT: 0x0, SIZE: 3 bits */
157e689cf4aSJeff Kirsher #define  REG_PCI_ERR_STATUS            0x1000  /* PCI error status */
158e689cf4aSJeff Kirsher #define    PCI_ERR_BADACK              0x01    /* reserved in Cassini+.
159e689cf4aSJeff Kirsher 						  set if no ACK64# during ABS64 cycle
160e689cf4aSJeff Kirsher 						  in Cassini. */
161e689cf4aSJeff Kirsher #define    PCI_ERR_DTRTO               0x02    /* delayed xaction timeout. set if
162e689cf4aSJeff Kirsher 						  no read retry after 2^15 clocks */
163e689cf4aSJeff Kirsher #define    PCI_ERR_OTHER               0x04    /* other PCI errors */
164e689cf4aSJeff Kirsher #define    PCI_ERR_BIM_DMA_WRITE       0x08    /* BIM received 0 count DMA write req.
165e689cf4aSJeff Kirsher 						  unused in Cassini. */
166e689cf4aSJeff Kirsher #define    PCI_ERR_BIM_DMA_READ        0x10    /* BIM received 0 count DMA read req.
167e689cf4aSJeff Kirsher 						  unused in Cassini. */
168e689cf4aSJeff Kirsher #define    PCI_ERR_BIM_DMA_TIMEOUT     0x20    /* BIM received 255 retries during
169e689cf4aSJeff Kirsher 						  DMA. unused in cassini. */
170e689cf4aSJeff Kirsher 
171e689cf4aSJeff Kirsher /* mask for PCI status events that will set PCI_ERR_STATUS. if cleared, event
172e689cf4aSJeff Kirsher  * causes an interrupt to be generated.
173e689cf4aSJeff Kirsher  * DEFAULT: 0x7, SIZE: 3 bits
174e689cf4aSJeff Kirsher  */
175e689cf4aSJeff Kirsher #define  REG_PCI_ERR_STATUS_MASK       0x1004  /* PCI Error status mask */
176e689cf4aSJeff Kirsher 
177e689cf4aSJeff Kirsher /* used to configure PCI related parameters that are not in PCI config space.
178e689cf4aSJeff Kirsher  * DEFAULT: 0bxx000, SIZE: 5 bits
179e689cf4aSJeff Kirsher  */
180e689cf4aSJeff Kirsher #define  REG_BIM_CFG                0x1008  /* BIM Configuration */
181e689cf4aSJeff Kirsher #define    BIM_CFG_RESERVED0        0x001   /* reserved */
182e689cf4aSJeff Kirsher #define    BIM_CFG_RESERVED1        0x002   /* reserved */
183e689cf4aSJeff Kirsher #define    BIM_CFG_64BIT_DISABLE    0x004   /* disable 64-bit mode */
184e689cf4aSJeff Kirsher #define    BIM_CFG_66MHZ            0x008   /* (ro) 1 = 66MHz, 0 = < 66MHz */
185e689cf4aSJeff Kirsher #define    BIM_CFG_32BIT            0x010   /* (ro) 1 = 32-bit slot, 0 = 64-bit */
186e689cf4aSJeff Kirsher #define    BIM_CFG_DPAR_INTR_ENABLE 0x020   /* detected parity err enable */
187e689cf4aSJeff Kirsher #define    BIM_CFG_RMA_INTR_ENABLE  0x040   /* master abort intr enable */
188e689cf4aSJeff Kirsher #define    BIM_CFG_RTA_INTR_ENABLE  0x080   /* target abort intr enable */
189e689cf4aSJeff Kirsher #define    BIM_CFG_RESERVED2        0x100   /* reserved */
190e689cf4aSJeff Kirsher #define    BIM_CFG_BIM_DISABLE      0x200   /* stop BIM DMA. use before global
191e689cf4aSJeff Kirsher 					       reset. reserved in Cassini. */
192e689cf4aSJeff Kirsher #define    BIM_CFG_BIM_STATUS       0x400   /* (ro) 1 = BIM DMA suspended.
193e689cf4aSJeff Kirsher 						  reserved in Cassini. */
194e689cf4aSJeff Kirsher #define    BIM_CFG_PERROR_BLOCK     0x800  /* block PERR# to pci bus. def: 0.
195e689cf4aSJeff Kirsher 						 reserved in Cassini. */
196e689cf4aSJeff Kirsher 
197e689cf4aSJeff Kirsher /* DEFAULT: 0x00000000, SIZE: 32 bits */
198e689cf4aSJeff Kirsher #define  REG_BIM_DIAG                  0x100C  /* BIM Diagnostic */
199e689cf4aSJeff Kirsher #define    BIM_DIAG_MSTR_SM_MASK       0x3FFFFF00 /* PCI master controller state
200e689cf4aSJeff Kirsher 						     machine bits [21:0] */
201e689cf4aSJeff Kirsher #define    BIM_DIAG_BRST_SM_MASK       0x7F    /* PCI burst controller state
202e689cf4aSJeff Kirsher 						  machine bits [6:0] */
203e689cf4aSJeff Kirsher 
204e689cf4aSJeff Kirsher /* writing to SW_RESET_TX and SW_RESET_RX will issue a global
205e689cf4aSJeff Kirsher  * reset. poll until TX and RX read back as 0's for completion.
206e689cf4aSJeff Kirsher  */
207e689cf4aSJeff Kirsher #define  REG_SW_RESET                  0x1010  /* Software reset */
208e689cf4aSJeff Kirsher #define    SW_RESET_TX                 0x00000001  /* reset TX DMA engine. poll until
209e689cf4aSJeff Kirsher 						      cleared to 0.  */
210e689cf4aSJeff Kirsher #define    SW_RESET_RX                 0x00000002  /* reset RX DMA engine. poll until
211e689cf4aSJeff Kirsher 						      cleared to 0. */
212e689cf4aSJeff Kirsher #define    SW_RESET_RSTOUT             0x00000004  /* force RSTOUT# pin active (low).
213e689cf4aSJeff Kirsher 						      resets PHY and anything else
214e689cf4aSJeff Kirsher 						      connected to RSTOUT#. RSTOUT#
215e689cf4aSJeff Kirsher 						      is also activated by local PCI
216e689cf4aSJeff Kirsher 						      reset when hot-swap is being
217e689cf4aSJeff Kirsher 						      done. */
218e689cf4aSJeff Kirsher #define    SW_RESET_BLOCK_PCS_SLINK    0x00000008  /* if a global reset is done with
219e689cf4aSJeff Kirsher 						      this bit set, PCS and SLINK
220e689cf4aSJeff Kirsher 						      modules won't be reset.
221e689cf4aSJeff Kirsher 						      i.e., link won't drop. */
222e689cf4aSJeff Kirsher #define    SW_RESET_BREQ_SM_MASK       0x00007F00  /* breq state machine [6:0] */
223e689cf4aSJeff Kirsher #define    SW_RESET_PCIARB_SM_MASK     0x00070000  /* pci arbitration state bits:
224e689cf4aSJeff Kirsher 						      0b000: ARB_IDLE1
225e689cf4aSJeff Kirsher 						      0b001: ARB_IDLE2
226e689cf4aSJeff Kirsher 						      0b010: ARB_WB_ACK
227e689cf4aSJeff Kirsher 						      0b011: ARB_WB_WAT
228e689cf4aSJeff Kirsher 						      0b100: ARB_RB_ACK
229e689cf4aSJeff Kirsher 						      0b101: ARB_RB_WAT
230e689cf4aSJeff Kirsher 						      0b110: ARB_RB_END
231e689cf4aSJeff Kirsher 						      0b111: ARB_WB_END */
232e689cf4aSJeff Kirsher #define    SW_RESET_RDPCI_SM_MASK      0x00300000  /* read pci state bits:
233e689cf4aSJeff Kirsher 						      0b00: RD_PCI_WAT
234e689cf4aSJeff Kirsher 						      0b01: RD_PCI_RDY
235e689cf4aSJeff Kirsher 						      0b11: RD_PCI_ACK */
236e689cf4aSJeff Kirsher #define    SW_RESET_RDARB_SM_MASK      0x00C00000  /* read arbitration state bits:
237e689cf4aSJeff Kirsher 						      0b00: AD_IDL_RX
238e689cf4aSJeff Kirsher 						      0b01: AD_ACK_RX
239e689cf4aSJeff Kirsher 						      0b10: AD_ACK_TX
240e689cf4aSJeff Kirsher 						      0b11: AD_IDL_TX */
241e689cf4aSJeff Kirsher #define    SW_RESET_WRPCI_SM_MASK      0x06000000  /* write pci state bits
242e689cf4aSJeff Kirsher 						      0b00: WR_PCI_WAT
243e689cf4aSJeff Kirsher 						      0b01: WR_PCI_RDY
244e689cf4aSJeff Kirsher 						      0b11: WR_PCI_ACK */
245e689cf4aSJeff Kirsher #define    SW_RESET_WRARB_SM_MASK      0x38000000  /* write arbitration state bits:
246e689cf4aSJeff Kirsher 						      0b000: ARB_IDLE1
247e689cf4aSJeff Kirsher 						      0b001: ARB_IDLE2
248e689cf4aSJeff Kirsher 						      0b010: ARB_TX_ACK
249e689cf4aSJeff Kirsher 						      0b011: ARB_TX_WAT
250e689cf4aSJeff Kirsher 						      0b100: ARB_RX_ACK
251e689cf4aSJeff Kirsher 						      0b110: ARB_RX_WAT */
252e689cf4aSJeff Kirsher 
253e689cf4aSJeff Kirsher /* Cassini only. 64-bit register used to check PCI datapath. when read,
254e689cf4aSJeff Kirsher  * value written has both lower and upper 32-bit halves rotated to the right
255e689cf4aSJeff Kirsher  * one bit position. e.g., FFFFFFFF FFFFFFFF -> 7FFFFFFF 7FFFFFFF
256e689cf4aSJeff Kirsher  */
257e689cf4aSJeff Kirsher #define  REG_MINUS_BIM_DATAPATH_TEST   0x1018  /* Cassini: BIM datapath test
258e689cf4aSJeff Kirsher 						  Cassini+: reserved */
259e689cf4aSJeff Kirsher 
260e689cf4aSJeff Kirsher /* output enables are provided for each device's chip select and for the rest
261e689cf4aSJeff Kirsher  * of the outputs from cassini to its local bus devices. two sw programmable
262e689cf4aSJeff Kirsher  * bits are connected to general purpus control/status bits.
263e689cf4aSJeff Kirsher  * DEFAULT: 0x7
264e689cf4aSJeff Kirsher  */
265e689cf4aSJeff Kirsher #define  REG_BIM_LOCAL_DEV_EN          0x1020  /* BIM local device
266e689cf4aSJeff Kirsher 						  output EN. default: 0x7 */
267e689cf4aSJeff Kirsher #define    BIM_LOCAL_DEV_PAD           0x01    /* address bus, RW signal, and
268e689cf4aSJeff Kirsher 						  OE signal output enable on the
269e689cf4aSJeff Kirsher 						  local bus interface. these
270e689cf4aSJeff Kirsher 						  are shared between both local
271e689cf4aSJeff Kirsher 						  bus devices. tristate when 0. */
272e689cf4aSJeff Kirsher #define    BIM_LOCAL_DEV_PROM          0x02    /* PROM chip select */
273e689cf4aSJeff Kirsher #define    BIM_LOCAL_DEV_EXT           0x04    /* secondary local bus device chip
274e689cf4aSJeff Kirsher 						  select output enable */
275e689cf4aSJeff Kirsher #define    BIM_LOCAL_DEV_SOFT_0        0x08    /* sw programmable ctrl bit 0 */
276e689cf4aSJeff Kirsher #define    BIM_LOCAL_DEV_SOFT_1        0x10    /* sw programmable ctrl bit 1 */
277e689cf4aSJeff Kirsher #define    BIM_LOCAL_DEV_HW_RESET      0x20    /* internal hw reset. Cassini+ only. */
278e689cf4aSJeff Kirsher 
279e689cf4aSJeff Kirsher /* access 24 entry BIM read and write buffers. put address in REG_BIM_BUFFER_ADDR
280e689cf4aSJeff Kirsher  * and read/write from/to it REG_BIM_BUFFER_DATA_LOW and _DATA_HI.
281e689cf4aSJeff Kirsher  * _DATA_HI should be the last access of the sequence.
282e689cf4aSJeff Kirsher  * DEFAULT: undefined
283e689cf4aSJeff Kirsher  */
284e689cf4aSJeff Kirsher #define  REG_BIM_BUFFER_ADDR           0x1024  /* BIM buffer address. for
285e689cf4aSJeff Kirsher 						  purposes. */
286e689cf4aSJeff Kirsher #define    BIM_BUFFER_ADDR_MASK        0x3F    /* index (0 - 23) of buffer  */
287e689cf4aSJeff Kirsher #define    BIM_BUFFER_WR_SELECT        0x40    /* write buffer access = 1
288e689cf4aSJeff Kirsher 						  read buffer access = 0 */
289e689cf4aSJeff Kirsher /* DEFAULT: undefined */
290e689cf4aSJeff Kirsher #define  REG_BIM_BUFFER_DATA_LOW       0x1028  /* BIM buffer data low */
291e689cf4aSJeff Kirsher #define  REG_BIM_BUFFER_DATA_HI        0x102C  /* BIM buffer data high */
292e689cf4aSJeff Kirsher 
293e689cf4aSJeff Kirsher /* set BIM_RAM_BIST_START to start built-in self test for BIM read buffer.
294e689cf4aSJeff Kirsher  * bit auto-clears when done with status read from _SUMMARY and _PASS bits.
295e689cf4aSJeff Kirsher  */
296e689cf4aSJeff Kirsher #define  REG_BIM_RAM_BIST              0x102C  /* BIM RAM (read buffer) BIST
297e689cf4aSJeff Kirsher 						  control/status */
298e689cf4aSJeff Kirsher #define    BIM_RAM_BIST_RD_START       0x01    /* start BIST for BIM read buffer */
299e689cf4aSJeff Kirsher #define    BIM_RAM_BIST_WR_START       0x02    /* start BIST for BIM write buffer.
300e689cf4aSJeff Kirsher 						  Cassini only. reserved in
301e689cf4aSJeff Kirsher 						  Cassini+. */
302e689cf4aSJeff Kirsher #define    BIM_RAM_BIST_RD_PASS        0x04    /* summary BIST pass status for read
303e689cf4aSJeff Kirsher 						  buffer. */
304e689cf4aSJeff Kirsher #define    BIM_RAM_BIST_WR_PASS        0x08    /* summary BIST pass status for write
305e689cf4aSJeff Kirsher 						  buffer. Cassini only. reserved
306e689cf4aSJeff Kirsher 						  in Cassini+. */
307e689cf4aSJeff Kirsher #define    BIM_RAM_BIST_RD_LOW_PASS    0x10    /* read low bank passes BIST */
308e689cf4aSJeff Kirsher #define    BIM_RAM_BIST_RD_HI_PASS     0x20    /* read high bank passes BIST */
309e689cf4aSJeff Kirsher #define    BIM_RAM_BIST_WR_LOW_PASS    0x40    /* write low bank passes BIST.
310e689cf4aSJeff Kirsher 						  Cassini only. reserved in
311e689cf4aSJeff Kirsher 						  Cassini+. */
312e689cf4aSJeff Kirsher #define    BIM_RAM_BIST_WR_HI_PASS     0x80    /* write high bank passes BIST.
313e689cf4aSJeff Kirsher 						  Cassini only. reserved in
314e689cf4aSJeff Kirsher 						  Cassini+. */
315e689cf4aSJeff Kirsher 
316e689cf4aSJeff Kirsher /* ASUN: i'm not sure what this does as it's not in the spec.
317e689cf4aSJeff Kirsher  * DEFAULT: 0xFC
318e689cf4aSJeff Kirsher  */
319e689cf4aSJeff Kirsher #define  REG_BIM_DIAG_MUX              0x1030  /* BIM diagnostic probe mux
320e689cf4aSJeff Kirsher 						  select register */
321e689cf4aSJeff Kirsher 
322e689cf4aSJeff Kirsher /* enable probe monitoring mode and select data appearing on the P_A* bus. bit
323e689cf4aSJeff Kirsher  * values for _SEL_HI_MASK and _SEL_LOW_MASK:
324e689cf4aSJeff Kirsher  * 0x0: internal probe[7:0] (pci arb state, wtc empty w, wtc full w, wtc empty w,
325e689cf4aSJeff Kirsher  *                           wtc empty r, post pci)
326e689cf4aSJeff Kirsher  * 0x1: internal probe[15:8] (pci wbuf comp, pci wpkt comp, pci rbuf comp,
327e689cf4aSJeff Kirsher  *                            pci rpkt comp, txdma wr req, txdma wr ack,
328e689cf4aSJeff Kirsher  *			      txdma wr rdy, txdma wr xfr done)
329e689cf4aSJeff Kirsher  * 0x2: internal probe[23:16] (txdma rd req, txdma rd ack, txdma rd rdy, rxdma rd,
330e689cf4aSJeff Kirsher  *                             rd arb state, rd pci state)
331e689cf4aSJeff Kirsher  * 0x3: internal probe[31:24] (rxdma req, rxdma ack, rxdma rdy, wrarb state,
332e689cf4aSJeff Kirsher  *                             wrpci state)
333e689cf4aSJeff Kirsher  * 0x4: pci io probe[7:0]     0x5: pci io probe[15:8]
334e689cf4aSJeff Kirsher  * 0x6: pci io probe[23:16]   0x7: pci io probe[31:24]
335e689cf4aSJeff Kirsher  * 0x8: pci io probe[39:32]   0x9: pci io probe[47:40]
336e689cf4aSJeff Kirsher  * 0xa: pci io probe[55:48]   0xb: pci io probe[63:56]
337e689cf4aSJeff Kirsher  * the following are not available in Cassini:
338e689cf4aSJeff Kirsher  * 0xc: rx probe[7:0]         0xd: tx probe[7:0]
339e689cf4aSJeff Kirsher  * 0xe: hp probe[7:0] 	      0xf: mac probe[7:0]
340e689cf4aSJeff Kirsher  */
341e689cf4aSJeff Kirsher #define  REG_PLUS_PROBE_MUX_SELECT     0x1034 /* Cassini+: PROBE MUX SELECT */
342e689cf4aSJeff Kirsher #define    PROBE_MUX_EN                0x80000000 /* allow probe signals to be
343e689cf4aSJeff Kirsher 						     driven on local bus P_A[15:0]
344e689cf4aSJeff Kirsher 						     for debugging */
345e689cf4aSJeff Kirsher #define    PROBE_MUX_SUB_MUX_MASK      0x0000FF00 /* select sub module probe signals:
346e689cf4aSJeff Kirsher 						     0x03 = mac[1:0]
347e689cf4aSJeff Kirsher 						     0x0C = rx[1:0]
348e689cf4aSJeff Kirsher 						     0x30 = tx[1:0]
349e689cf4aSJeff Kirsher 						     0xC0 = hp[1:0] */
350e689cf4aSJeff Kirsher #define    PROBE_MUX_SEL_HI_MASK       0x000000F0 /* select which module to appear
351e689cf4aSJeff Kirsher 						     on P_A[15:8]. see above for
352e689cf4aSJeff Kirsher 						     values. */
353e689cf4aSJeff Kirsher #define    PROBE_MUX_SEL_LOW_MASK      0x0000000F /* select which module to appear
354e689cf4aSJeff Kirsher 						     on P_A[7:0]. see above for
355e689cf4aSJeff Kirsher 						     values. */
356e689cf4aSJeff Kirsher 
357e689cf4aSJeff Kirsher /* values mean the same thing as REG_INTR_MASK excep that it's for INTB.
358e689cf4aSJeff Kirsher  DEFAULT: 0x1F */
359e689cf4aSJeff Kirsher #define  REG_PLUS_INTR_MASK_1          0x1038 /* Cassini+: interrupt mask
360e689cf4aSJeff Kirsher 						 register 2 for INTB */
361e689cf4aSJeff Kirsher #define  REG_PLUS_INTRN_MASK(x)       (REG_PLUS_INTR_MASK_1 + ((x) - 1)*16)
362e689cf4aSJeff Kirsher /* bits correspond to both _MASK and _STATUS registers. _ALT corresponds to
363e689cf4aSJeff Kirsher  * all of the alternate (2-4) INTR registers while _1 corresponds to only
364e689cf4aSJeff Kirsher  * _MASK_1 and _STATUS_1 registers.
365e689cf4aSJeff Kirsher  * DEFAULT: 0x7 for MASK registers, 0x0 for ALIAS_CLEAR registers
366e689cf4aSJeff Kirsher  */
367e689cf4aSJeff Kirsher #define    INTR_RX_DONE_ALT              0x01
368e689cf4aSJeff Kirsher #define    INTR_RX_COMP_FULL_ALT         0x02
369e689cf4aSJeff Kirsher #define    INTR_RX_COMP_AF_ALT           0x04
370e689cf4aSJeff Kirsher #define    INTR_RX_BUF_UNAVAIL_1         0x08
371e689cf4aSJeff Kirsher #define    INTR_RX_BUF_AE_1              0x10 /* almost empty */
372e689cf4aSJeff Kirsher #define    INTRN_MASK_RX_EN              0x80
373e689cf4aSJeff Kirsher #define    INTRN_MASK_CLEAR_ALL          (INTR_RX_DONE_ALT | \
374e689cf4aSJeff Kirsher                                           INTR_RX_COMP_FULL_ALT | \
375e689cf4aSJeff Kirsher                                           INTR_RX_COMP_AF_ALT | \
376e689cf4aSJeff Kirsher                                           INTR_RX_BUF_UNAVAIL_1 | \
377e689cf4aSJeff Kirsher                                           INTR_RX_BUF_AE_1)
378e689cf4aSJeff Kirsher #define  REG_PLUS_INTR_STATUS_1        0x103C /* Cassini+: interrupt status
379e689cf4aSJeff Kirsher 						 register 2 for INTB. default: 0x1F */
380e689cf4aSJeff Kirsher #define  REG_PLUS_INTRN_STATUS(x)       (REG_PLUS_INTR_STATUS_1 + ((x) - 1)*16)
381e689cf4aSJeff Kirsher #define    INTR_STATUS_ALT_INTX_EN     0x80   /* generate INTX when one of the
382e689cf4aSJeff Kirsher 						 flags are set. enables desc ring. */
383e689cf4aSJeff Kirsher 
384e689cf4aSJeff Kirsher #define  REG_PLUS_ALIAS_CLEAR_1        0x1040 /* Cassini+: alias clear mask
385e689cf4aSJeff Kirsher 						 register 2 for INTB */
386e689cf4aSJeff Kirsher #define  REG_PLUS_ALIASN_CLEAR(x)      (REG_PLUS_ALIAS_CLEAR_1 + ((x) - 1)*16)
387e689cf4aSJeff Kirsher 
388e689cf4aSJeff Kirsher #define  REG_PLUS_INTR_STATUS_ALIAS_1  0x1044 /* Cassini+: interrupt status
389e689cf4aSJeff Kirsher 						 register alias 2 for INTB */
390e689cf4aSJeff Kirsher #define  REG_PLUS_INTRN_STATUS_ALIAS(x) (REG_PLUS_INTR_STATUS_ALIAS_1 + ((x) - 1)*16)
391e689cf4aSJeff Kirsher 
392e689cf4aSJeff Kirsher #define REG_SATURN_PCFG               0x106c /* pin configuration register for
393e689cf4aSJeff Kirsher 						integrated macphy */
394e689cf4aSJeff Kirsher 
395e689cf4aSJeff Kirsher #define   SATURN_PCFG_TLA             0x00000001 /* 1 = phy actled */
396e689cf4aSJeff Kirsher #define   SATURN_PCFG_FLA             0x00000002 /* 1 = phy link10led */
397e689cf4aSJeff Kirsher #define   SATURN_PCFG_CLA             0x00000004 /* 1 = phy link100led */
398e689cf4aSJeff Kirsher #define   SATURN_PCFG_LLA             0x00000008 /* 1 = phy link1000led */
399e689cf4aSJeff Kirsher #define   SATURN_PCFG_RLA             0x00000010 /* 1 = phy duplexled */
400e689cf4aSJeff Kirsher #define   SATURN_PCFG_PDS             0x00000020 /* phy debug mode.
401e689cf4aSJeff Kirsher 						    0 = normal */
402e689cf4aSJeff Kirsher #define   SATURN_PCFG_MTP             0x00000080 /* test point select */
403e689cf4aSJeff Kirsher #define   SATURN_PCFG_GMO             0x00000100 /* GMII observe. 1 =
404e689cf4aSJeff Kirsher 						    GMII on SERDES pins for
405e689cf4aSJeff Kirsher 						    monitoring. */
406e689cf4aSJeff Kirsher #define   SATURN_PCFG_FSI             0x00000200 /* 1 = freeze serdes/gmii. all
407e689cf4aSJeff Kirsher 						    pins configed as outputs.
408e689cf4aSJeff Kirsher 						    for power saving when using
409e689cf4aSJeff Kirsher 						    internal phy. */
410e689cf4aSJeff Kirsher #define   SATURN_PCFG_LAD             0x00000800 /* 0 = mac core led ctrl
411e689cf4aSJeff Kirsher 						    polarity from strapping
412e689cf4aSJeff Kirsher 						    value.
413e689cf4aSJeff Kirsher 						    1 = mac core led ctrl
414e689cf4aSJeff Kirsher 						    polarity active low. */
415e689cf4aSJeff Kirsher 
416e689cf4aSJeff Kirsher 
417e689cf4aSJeff Kirsher /** transmit dma registers **/
418e689cf4aSJeff Kirsher #define MAX_TX_RINGS_SHIFT            2
419e689cf4aSJeff Kirsher #define MAX_TX_RINGS                  (1 << MAX_TX_RINGS_SHIFT)
420e689cf4aSJeff Kirsher #define MAX_TX_RINGS_MASK             (MAX_TX_RINGS - 1)
421e689cf4aSJeff Kirsher 
422e689cf4aSJeff Kirsher /* TX configuration.
423e689cf4aSJeff Kirsher  * descr ring sizes size = 32 * (1 << n), n < 9. e.g., 0x8 = 8k. default: 0x8
424e689cf4aSJeff Kirsher  * DEFAULT: 0x3F000001
425e689cf4aSJeff Kirsher  */
426e689cf4aSJeff Kirsher #define  REG_TX_CFG                    0x2004  /* TX config */
427e689cf4aSJeff Kirsher #define    TX_CFG_DMA_EN               0x00000001  /* enable TX DMA. if cleared, DMA
428e689cf4aSJeff Kirsher 						      will stop after xfer of current
429e689cf4aSJeff Kirsher 						      buffer has been completed. */
430e689cf4aSJeff Kirsher #define    TX_CFG_FIFO_PIO_SEL         0x00000002  /* TX DMA FIFO can be
431e689cf4aSJeff Kirsher 						      accessed w/ FIFO addr
432e689cf4aSJeff Kirsher 						      and data registers.
433e689cf4aSJeff Kirsher 						      TX DMA should be
434e689cf4aSJeff Kirsher 						      disabled. */
435e689cf4aSJeff Kirsher #define    TX_CFG_DESC_RING0_MASK      0x0000003C  /* # desc entries in
436e689cf4aSJeff Kirsher 						      ring 1. */
437e689cf4aSJeff Kirsher #define    TX_CFG_DESC_RING0_SHIFT     2
438e689cf4aSJeff Kirsher #define    TX_CFG_DESC_RINGN_MASK(a)   (TX_CFG_DESC_RING0_MASK << (a)*4)
439e689cf4aSJeff Kirsher #define    TX_CFG_DESC_RINGN_SHIFT(a)  (TX_CFG_DESC_RING0_SHIFT + (a)*4)
440e689cf4aSJeff Kirsher #define    TX_CFG_PACED_MODE           0x00100000  /* TX_ALL only set after
441e689cf4aSJeff Kirsher 						      TX FIFO becomes empty.
442e689cf4aSJeff Kirsher 						      if 0, TX_ALL set
443e689cf4aSJeff Kirsher 						      if descr queue empty. */
444e689cf4aSJeff Kirsher #define    TX_CFG_DMA_RDPIPE_DIS       0x01000000  /* always set to 1 */
445e689cf4aSJeff Kirsher #define    TX_CFG_COMPWB_Q1            0x02000000  /* completion writeback happens at
446e689cf4aSJeff Kirsher 						      the end of every packet kicked
447e689cf4aSJeff Kirsher 						      through Q1. */
448e689cf4aSJeff Kirsher #define    TX_CFG_COMPWB_Q2            0x04000000  /* completion writeback happens at
449e689cf4aSJeff Kirsher 						      the end of every packet kicked
450e689cf4aSJeff Kirsher 						      through Q2. */
451e689cf4aSJeff Kirsher #define    TX_CFG_COMPWB_Q3            0x08000000  /* completion writeback happens at
452e689cf4aSJeff Kirsher 						      the end of every packet kicked
453e689cf4aSJeff Kirsher 						      through Q3 */
454e689cf4aSJeff Kirsher #define    TX_CFG_COMPWB_Q4            0x10000000  /* completion writeback happens at
455e689cf4aSJeff Kirsher 						      the end of every packet kicked
456e689cf4aSJeff Kirsher 						      through Q4 */
457e689cf4aSJeff Kirsher #define    TX_CFG_INTR_COMPWB_DIS      0x20000000  /* disable pre-interrupt completion
458e689cf4aSJeff Kirsher 						      writeback */
459e689cf4aSJeff Kirsher #define    TX_CFG_CTX_SEL_MASK         0xC0000000  /* selects tx test port
460e689cf4aSJeff Kirsher 						      connection
461e689cf4aSJeff Kirsher 						      0b00: tx mac req,
462e689cf4aSJeff Kirsher 						            tx mac retry req,
463e689cf4aSJeff Kirsher 							    tx ack and tx tag.
464e689cf4aSJeff Kirsher 						      0b01: txdma rd req,
465e689cf4aSJeff Kirsher 						            txdma rd ack,
466e689cf4aSJeff Kirsher 							    txdma rd rdy,
467e689cf4aSJeff Kirsher 							    txdma rd type0
468e689cf4aSJeff Kirsher 						      0b11: txdma wr req,
469e689cf4aSJeff Kirsher 						            txdma wr ack,
470e689cf4aSJeff Kirsher 							    txdma wr rdy,
471e689cf4aSJeff Kirsher 							    txdma wr xfr done. */
472e689cf4aSJeff Kirsher #define    TX_CFG_CTX_SEL_SHIFT        30
473e689cf4aSJeff Kirsher 
474e689cf4aSJeff Kirsher /* 11-bit counters that point to next location in FIFO to be loaded/retrieved.
475e689cf4aSJeff Kirsher  * used for diagnostics only.
476e689cf4aSJeff Kirsher  */
477e689cf4aSJeff Kirsher #define  REG_TX_FIFO_WRITE_PTR         0x2014  /* TX FIFO write pointer */
478e689cf4aSJeff Kirsher #define  REG_TX_FIFO_SHADOW_WRITE_PTR  0x2018  /* TX FIFO shadow write
479e689cf4aSJeff Kirsher 						  pointer. temp hold reg.
480e689cf4aSJeff Kirsher 					          diagnostics only. */
481e689cf4aSJeff Kirsher #define  REG_TX_FIFO_READ_PTR          0x201C  /* TX FIFO read pointer */
482e689cf4aSJeff Kirsher #define  REG_TX_FIFO_SHADOW_READ_PTR   0x2020  /* TX FIFO shadow read
483e689cf4aSJeff Kirsher 						  pointer */
484e689cf4aSJeff Kirsher 
485e689cf4aSJeff Kirsher /* (ro) 11-bit up/down counter w/ # of frames currently in TX FIFO */
486e689cf4aSJeff Kirsher #define  REG_TX_FIFO_PKT_CNT           0x2024  /* TX FIFO packet counter */
487e689cf4aSJeff Kirsher 
488e689cf4aSJeff Kirsher /* current state of all state machines in TX */
489e689cf4aSJeff Kirsher #define  REG_TX_SM_1                   0x2028  /* TX state machine reg #1 */
490e689cf4aSJeff Kirsher #define    TX_SM_1_CHAIN_MASK          0x000003FF   /* chaining state machine */
491e689cf4aSJeff Kirsher #define    TX_SM_1_CSUM_MASK           0x00000C00   /* checksum state machine */
492e689cf4aSJeff Kirsher #define    TX_SM_1_FIFO_LOAD_MASK      0x0003F000   /* FIFO load state machine.
493e689cf4aSJeff Kirsher 						       = 0x01 when TX disabled. */
494e689cf4aSJeff Kirsher #define    TX_SM_1_FIFO_UNLOAD_MASK    0x003C0000   /* FIFO unload state machine */
495e689cf4aSJeff Kirsher #define    TX_SM_1_CACHE_MASK          0x03C00000   /* desc. prefetch cache controller
496e689cf4aSJeff Kirsher 						       state machine */
497e689cf4aSJeff Kirsher #define    TX_SM_1_CBQ_ARB_MASK        0xF8000000   /* CBQ arbiter state machine */
498e689cf4aSJeff Kirsher 
499e689cf4aSJeff Kirsher #define  REG_TX_SM_2                   0x202C  /* TX state machine reg #2 */
500e689cf4aSJeff Kirsher #define    TX_SM_2_COMP_WB_MASK        0x07    /* completion writeback sm */
501e689cf4aSJeff Kirsher #define	   TX_SM_2_SUB_LOAD_MASK       0x38    /* sub load state machine */
502e689cf4aSJeff Kirsher #define	   TX_SM_2_KICK_MASK           0xC0    /* kick state machine */
503e689cf4aSJeff Kirsher 
504e689cf4aSJeff Kirsher /* 64-bit pointer to the transmit data buffer. only the 50 LSB are incremented
505e689cf4aSJeff Kirsher  * while the upper 23 bits are taken from the TX descriptor
506e689cf4aSJeff Kirsher  */
507e689cf4aSJeff Kirsher #define  REG_TX_DATA_PTR_LOW           0x2030  /* TX data pointer low */
508e689cf4aSJeff Kirsher #define  REG_TX_DATA_PTR_HI            0x2034  /* TX data pointer high */
509e689cf4aSJeff Kirsher 
510e689cf4aSJeff Kirsher /* 13 bit registers written by driver w/ descriptor value that follows
511e689cf4aSJeff Kirsher  * last valid xmit descriptor. kick # and complete # values are used by
512e689cf4aSJeff Kirsher  * the xmit dma engine to control tx descr fetching. if > 1 valid
513e689cf4aSJeff Kirsher  * tx descr is available within the cache line being read, cassini will
514e689cf4aSJeff Kirsher  * internally cache up to 4 of them. 0 on reset. _KICK = rw, _COMP = ro.
515e689cf4aSJeff Kirsher  */
516e689cf4aSJeff Kirsher #define  REG_TX_KICK0                  0x2038  /* TX kick reg #1 */
517e689cf4aSJeff Kirsher #define  REG_TX_KICKN(x)               (REG_TX_KICK0 + (x)*4)
518e689cf4aSJeff Kirsher #define  REG_TX_COMP0                  0x2048  /* TX completion reg #1 */
519e689cf4aSJeff Kirsher #define  REG_TX_COMPN(x)               (REG_TX_COMP0 + (x)*4)
520e689cf4aSJeff Kirsher 
521e689cf4aSJeff Kirsher /* values of TX_COMPLETE_1-4 are written. each completion register
522e689cf4aSJeff Kirsher  * is 2bytes in size and contiguous. 8B allocation w/ 8B alignment.
523e689cf4aSJeff Kirsher  * NOTE: completion reg values are only written back prior to TX_INTME and
524e689cf4aSJeff Kirsher  * TX_ALL interrupts. at all other times, the most up-to-date index values
525e689cf4aSJeff Kirsher  * should be obtained from the REG_TX_COMPLETE_# registers.
526e689cf4aSJeff Kirsher  * here's the layout:
527e689cf4aSJeff Kirsher  * offset from base addr      completion # byte
528e689cf4aSJeff Kirsher  *           0                TX_COMPLETE_1_MSB
529e689cf4aSJeff Kirsher  *	     1                TX_COMPLETE_1_LSB
530e689cf4aSJeff Kirsher  *           2                TX_COMPLETE_2_MSB
531e689cf4aSJeff Kirsher  *	     3                TX_COMPLETE_2_LSB
532e689cf4aSJeff Kirsher  *           4                TX_COMPLETE_3_MSB
533e689cf4aSJeff Kirsher  *	     5                TX_COMPLETE_3_LSB
534e689cf4aSJeff Kirsher  *           6                TX_COMPLETE_4_MSB
535e689cf4aSJeff Kirsher  *	     7                TX_COMPLETE_4_LSB
536e689cf4aSJeff Kirsher  */
537e689cf4aSJeff Kirsher #define  TX_COMPWB_SIZE             8
538e689cf4aSJeff Kirsher #define  REG_TX_COMPWB_DB_LOW       0x2058  /* TX completion write back
539e689cf4aSJeff Kirsher 					       base low */
540e689cf4aSJeff Kirsher #define  REG_TX_COMPWB_DB_HI        0x205C  /* TX completion write back
541e689cf4aSJeff Kirsher 					       base high */
542e689cf4aSJeff Kirsher #define    TX_COMPWB_MSB_MASK       0x00000000000000FFULL
543e689cf4aSJeff Kirsher #define    TX_COMPWB_MSB_SHIFT      0
544e689cf4aSJeff Kirsher #define    TX_COMPWB_LSB_MASK       0x000000000000FF00ULL
545e689cf4aSJeff Kirsher #define    TX_COMPWB_LSB_SHIFT      8
546e689cf4aSJeff Kirsher #define    TX_COMPWB_NEXT(x)        ((x) >> 16)
547e689cf4aSJeff Kirsher 
548e689cf4aSJeff Kirsher /* 53 MSB used as base address. 11 LSB assumed to be 0. TX desc pointer must
549e689cf4aSJeff Kirsher  * be 2KB-aligned. */
550e689cf4aSJeff Kirsher #define  REG_TX_DB0_LOW         0x2060  /* TX descriptor base low #1 */
551e689cf4aSJeff Kirsher #define  REG_TX_DB0_HI          0x2064  /* TX descriptor base hi #1 */
552e689cf4aSJeff Kirsher #define  REG_TX_DBN_LOW(x)      (REG_TX_DB0_LOW + (x)*8)
553e689cf4aSJeff Kirsher #define  REG_TX_DBN_HI(x)       (REG_TX_DB0_HI + (x)*8)
554e689cf4aSJeff Kirsher 
555e689cf4aSJeff Kirsher /* 16-bit registers hold weights for the weighted round-robin of the
556e689cf4aSJeff Kirsher  * four CBQ TX descr rings. weights correspond to # bytes xferred from
557e689cf4aSJeff Kirsher  * host to TXFIFO in a round of WRR arbitration. can be set
558e689cf4aSJeff Kirsher  * dynamically with new weights set upon completion of the current
559e689cf4aSJeff Kirsher  * packet transfer from host memory to TXFIFO. a dummy write to any of
560e689cf4aSJeff Kirsher  * these registers causes a queue1 pre-emption with all historical bw
561e689cf4aSJeff Kirsher  * deficit data reset to 0 (useful when congestion requires a
562e689cf4aSJeff Kirsher  * pre-emption/re-allocation of network bandwidth
563e689cf4aSJeff Kirsher  */
564e689cf4aSJeff Kirsher #define  REG_TX_MAXBURST_0             0x2080  /* TX MaxBurst #1 */
565e689cf4aSJeff Kirsher #define  REG_TX_MAXBURST_1             0x2084  /* TX MaxBurst #2 */
566e689cf4aSJeff Kirsher #define  REG_TX_MAXBURST_2             0x2088  /* TX MaxBurst #3 */
567e689cf4aSJeff Kirsher #define  REG_TX_MAXBURST_3             0x208C  /* TX MaxBurst #4 */
568e689cf4aSJeff Kirsher 
569e689cf4aSJeff Kirsher /* diagnostics access to any TX FIFO location. every access is 65
570e689cf4aSJeff Kirsher  * bits.  _DATA_LOW = 32 LSB, _DATA_HI_T1/T0 = 32 MSB. _TAG = tag bit.
571e689cf4aSJeff Kirsher  * writing _DATA_HI_T0 sets tag bit low, writing _DATA_HI_T1 sets tag
572e689cf4aSJeff Kirsher  * bit high.  TX_FIFO_PIO_SEL must be set for TX FIFO PIO access. if
573e689cf4aSJeff Kirsher  * TX FIFO data integrity is desired, TX DMA should be
574e689cf4aSJeff Kirsher  * disabled. _DATA_HI_Tx should be the last access of the sequence.
575e689cf4aSJeff Kirsher  */
576e689cf4aSJeff Kirsher #define  REG_TX_FIFO_ADDR              0x2104  /* TX FIFO address */
577e689cf4aSJeff Kirsher #define  REG_TX_FIFO_TAG               0x2108  /* TX FIFO tag */
578e689cf4aSJeff Kirsher #define  REG_TX_FIFO_DATA_LOW          0x210C  /* TX FIFO data low */
579e689cf4aSJeff Kirsher #define  REG_TX_FIFO_DATA_HI_T1        0x2110  /* TX FIFO data high t1 */
580e689cf4aSJeff Kirsher #define  REG_TX_FIFO_DATA_HI_T0        0x2114  /* TX FIFO data high t0 */
581e689cf4aSJeff Kirsher #define  REG_TX_FIFO_SIZE              0x2118  /* (ro) TX FIFO size = 0x090 = 9KB */
582e689cf4aSJeff Kirsher 
583e689cf4aSJeff Kirsher /* 9-bit register controls BIST of TX FIFO. bit set indicates that the BIST
584e689cf4aSJeff Kirsher  * passed for the specified memory
585e689cf4aSJeff Kirsher  */
586e689cf4aSJeff Kirsher #define  REG_TX_RAMBIST                0x211C /* TX RAMBIST control/status */
587e689cf4aSJeff Kirsher #define    TX_RAMBIST_STATE            0x01C0 /* progress state of RAMBIST
588e689cf4aSJeff Kirsher 						 controller state machine */
589e689cf4aSJeff Kirsher #define    TX_RAMBIST_RAM33A_PASS      0x0020 /* RAM33A passed */
590e689cf4aSJeff Kirsher #define    TX_RAMBIST_RAM32A_PASS      0x0010 /* RAM32A passed */
591e689cf4aSJeff Kirsher #define    TX_RAMBIST_RAM33B_PASS      0x0008 /* RAM33B passed */
592e689cf4aSJeff Kirsher #define    TX_RAMBIST_RAM32B_PASS      0x0004 /* RAM32B passed */
593e689cf4aSJeff Kirsher #define    TX_RAMBIST_SUMMARY          0x0002 /* all RAM passed */
594e689cf4aSJeff Kirsher #define    TX_RAMBIST_START            0x0001 /* write 1 to start BIST. self
595e689cf4aSJeff Kirsher 						 clears on completion. */
596e689cf4aSJeff Kirsher 
597e689cf4aSJeff Kirsher /** receive dma registers **/
598e689cf4aSJeff Kirsher #define MAX_RX_DESC_RINGS              2
599e689cf4aSJeff Kirsher #define MAX_RX_COMP_RINGS              4
600e689cf4aSJeff Kirsher 
601e689cf4aSJeff Kirsher /* receive DMA channel configuration. default: 0x80910
602e689cf4aSJeff Kirsher  * free ring size       = (1 << n)*32  -> [32 - 8k]
603e689cf4aSJeff Kirsher  * completion ring size = (1 << n)*128 -> [128 - 32k], n < 9
604e689cf4aSJeff Kirsher  * DEFAULT: 0x80910
605e689cf4aSJeff Kirsher  */
606e689cf4aSJeff Kirsher #define  REG_RX_CFG                     0x4000  /* RX config */
607e689cf4aSJeff Kirsher #define    RX_CFG_DMA_EN                0x00000001 /* enable RX DMA. 0 stops
608e689cf4aSJeff Kirsher 							 channel as soon as current
609e689cf4aSJeff Kirsher 							 frame xfer has completed.
610e689cf4aSJeff Kirsher 							 driver should disable MAC
611e689cf4aSJeff Kirsher 							 for 200ms before disabling
612e689cf4aSJeff Kirsher 							 RX */
613e689cf4aSJeff Kirsher #define    RX_CFG_DESC_RING_MASK        0x0000001E /* # desc entries in RX
614e689cf4aSJeff Kirsher 							 free desc ring.
615e689cf4aSJeff Kirsher 							 def: 0x8 = 8k */
616e689cf4aSJeff Kirsher #define    RX_CFG_DESC_RING_SHIFT       1
617e689cf4aSJeff Kirsher #define    RX_CFG_COMP_RING_MASK        0x000001E0 /* # desc entries in RX complete
618e689cf4aSJeff Kirsher 							 ring. def: 0x8 = 32k */
619e689cf4aSJeff Kirsher #define    RX_CFG_COMP_RING_SHIFT       5
620e689cf4aSJeff Kirsher #define    RX_CFG_BATCH_DIS             0x00000200 /* disable receive desc
621e689cf4aSJeff Kirsher 						      batching. def: 0x0 =
622e689cf4aSJeff Kirsher 						      enabled */
623e689cf4aSJeff Kirsher #define    RX_CFG_SWIVEL_MASK           0x00001C00 /* byte offset of the 1st
624e689cf4aSJeff Kirsher 						      data byte of the packet
625e689cf4aSJeff Kirsher 						      w/in 8 byte boundares.
626e689cf4aSJeff Kirsher 						      this swivels the data
627e689cf4aSJeff Kirsher 						      DMA'ed to header
628e689cf4aSJeff Kirsher 						      buffers, jumbo buffers
629e689cf4aSJeff Kirsher 						      when header split is not
630e689cf4aSJeff Kirsher 						      requested and MTU sized
631e689cf4aSJeff Kirsher 						      buffers. def: 0x2 */
632e689cf4aSJeff Kirsher #define    RX_CFG_SWIVEL_SHIFT          10
633e689cf4aSJeff Kirsher 
634e689cf4aSJeff Kirsher /* cassini+ only */
635e689cf4aSJeff Kirsher #define    RX_CFG_DESC_RING1_MASK       0x000F0000 /* # of desc entries in
636e689cf4aSJeff Kirsher 							 RX free desc ring 2.
637e689cf4aSJeff Kirsher 							 def: 0x8 = 8k */
638e689cf4aSJeff Kirsher #define    RX_CFG_DESC_RING1_SHIFT      16
639e689cf4aSJeff Kirsher 
640e689cf4aSJeff Kirsher 
641e689cf4aSJeff Kirsher /* the page size register allows cassini chips to do the following with
642e689cf4aSJeff Kirsher  * received data:
643e689cf4aSJeff Kirsher  * [--------------------------------------------------------------] page
644e689cf4aSJeff Kirsher  * [off][buf1][pad][off][buf2][pad][off][buf3][pad][off][buf4][pad]
645e689cf4aSJeff Kirsher  * |--------------| = PAGE_SIZE_BUFFER_STRIDE
646e689cf4aSJeff Kirsher  * page = PAGE_SIZE
647e689cf4aSJeff Kirsher  * offset = PAGE_SIZE_MTU_OFF
648e689cf4aSJeff Kirsher  * for the above example, MTU_BUFFER_COUNT = 4.
649e689cf4aSJeff Kirsher  * NOTE: as is apparent, you need to ensure that the following holds:
650e689cf4aSJeff Kirsher  * MTU_BUFFER_COUNT <= PAGE_SIZE/PAGE_SIZE_BUFFER_STRIDE
651e689cf4aSJeff Kirsher  * DEFAULT: 0x48002002 (8k pages)
652e689cf4aSJeff Kirsher  */
653e689cf4aSJeff Kirsher #define  REG_RX_PAGE_SIZE               0x4004  /* RX page size */
654e689cf4aSJeff Kirsher #define    RX_PAGE_SIZE_MASK            0x00000003 /* size of pages pointed to
655e689cf4aSJeff Kirsher 						      by receive descriptors.
656e689cf4aSJeff Kirsher 						      if jumbo buffers are
657e689cf4aSJeff Kirsher 						      supported the page size
658e689cf4aSJeff Kirsher 						      should not be < 8k.
659e689cf4aSJeff Kirsher 						      0b00 = 2k, 0b01 = 4k
660e689cf4aSJeff Kirsher 						      0b10 = 8k, 0b11 = 16k
661e689cf4aSJeff Kirsher 						      DEFAULT: 8k */
662e689cf4aSJeff Kirsher #define    RX_PAGE_SIZE_SHIFT           0
663e689cf4aSJeff Kirsher #define    RX_PAGE_SIZE_MTU_COUNT_MASK  0x00007800 /* # of MTU buffers the hw
664e689cf4aSJeff Kirsher 						      packs into a page.
665e689cf4aSJeff Kirsher 						      DEFAULT: 4 */
666e689cf4aSJeff Kirsher #define    RX_PAGE_SIZE_MTU_COUNT_SHIFT 11
667e689cf4aSJeff Kirsher #define    RX_PAGE_SIZE_MTU_STRIDE_MASK 0x18000000 /* # of bytes that separate
668e689cf4aSJeff Kirsher 							 each MTU buffer +
669e689cf4aSJeff Kirsher 							 offset from each
670e689cf4aSJeff Kirsher 							 other.
671e689cf4aSJeff Kirsher 							 0b00 = 1k, 0b01 = 2k
672e689cf4aSJeff Kirsher 							 0b10 = 4k, 0b11 = 8k
673e689cf4aSJeff Kirsher 							 DEFAULT: 0x1 */
674e689cf4aSJeff Kirsher #define    RX_PAGE_SIZE_MTU_STRIDE_SHIFT 27
675e689cf4aSJeff Kirsher #define    RX_PAGE_SIZE_MTU_OFF_MASK    0xC0000000 /* offset in each page that
676e689cf4aSJeff Kirsher 						      hw writes the MTU buffer
677e689cf4aSJeff Kirsher 						      into.
678e689cf4aSJeff Kirsher 						      0b00 = 0,
679e689cf4aSJeff Kirsher 						      0b01 = 64 bytes
680e689cf4aSJeff Kirsher 						      0b10 = 96, 0b11 = 128
681e689cf4aSJeff Kirsher 						      DEFAULT: 0x1 */
682e689cf4aSJeff Kirsher #define    RX_PAGE_SIZE_MTU_OFF_SHIFT   30
683e689cf4aSJeff Kirsher 
684e689cf4aSJeff Kirsher /* 11-bit counter points to next location in RX FIFO to be loaded/read.
685e689cf4aSJeff Kirsher  * shadow write pointers enable retries in case of early receive aborts.
686e689cf4aSJeff Kirsher  * DEFAULT: 0x0. generated on 64-bit boundaries.
687e689cf4aSJeff Kirsher  */
688e689cf4aSJeff Kirsher #define  REG_RX_FIFO_WRITE_PTR             0x4008  /* RX FIFO write pointer */
689e689cf4aSJeff Kirsher #define  REG_RX_FIFO_READ_PTR              0x400C  /* RX FIFO read pointer */
690e689cf4aSJeff Kirsher #define  REG_RX_IPP_FIFO_SHADOW_WRITE_PTR  0x4010  /* RX IPP FIFO shadow write
691e689cf4aSJeff Kirsher 						      pointer */
692e689cf4aSJeff Kirsher #define  REG_RX_IPP_FIFO_SHADOW_READ_PTR   0x4014  /* RX IPP FIFO shadow read
693e689cf4aSJeff Kirsher 						      pointer */
694e689cf4aSJeff Kirsher #define  REG_RX_IPP_FIFO_READ_PTR          0x400C  /* RX IPP FIFO read
695e689cf4aSJeff Kirsher 						      pointer. (8-bit counter) */
696e689cf4aSJeff Kirsher 
697e689cf4aSJeff Kirsher /* current state of RX DMA state engines + other info
698e689cf4aSJeff Kirsher  * DEFAULT: 0x0
699e689cf4aSJeff Kirsher  */
700e689cf4aSJeff Kirsher #define  REG_RX_DEBUG                      0x401C  /* RX debug */
701e689cf4aSJeff Kirsher #define    RX_DEBUG_LOAD_STATE_MASK        0x0000000F /* load state machine w/ MAC:
702e689cf4aSJeff Kirsher 							 0x0 = idle,   0x1 = load_bop
703e689cf4aSJeff Kirsher 							 0x2 = load 1, 0x3 = load 2
704e689cf4aSJeff Kirsher 							 0x4 = load 3, 0x5 = load 4
705e689cf4aSJeff Kirsher 							 0x6 = last detect
706e689cf4aSJeff Kirsher 							 0x7 = wait req
707e689cf4aSJeff Kirsher 							 0x8 = wait req statuss 1st
708e689cf4aSJeff Kirsher 							 0x9 = load st
709e689cf4aSJeff Kirsher 							 0xa = bubble mac
710e689cf4aSJeff Kirsher 							 0xb = error */
711e689cf4aSJeff Kirsher #define    RX_DEBUG_LM_STATE_MASK          0x00000070 /* load state machine w/ HP and
712e689cf4aSJeff Kirsher 							 RX FIFO:
713e689cf4aSJeff Kirsher 							 0x0 = idle,   0x1 = hp xfr
714e689cf4aSJeff Kirsher 							 0x2 = wait hp ready
715e689cf4aSJeff Kirsher 							 0x3 = wait flow code
716e689cf4aSJeff Kirsher 							 0x4 = fifo xfer
717e689cf4aSJeff Kirsher 							 0x5 = make status
718e689cf4aSJeff Kirsher 							 0x6 = csum ready
719e689cf4aSJeff Kirsher 							 0x7 = error */
720e689cf4aSJeff Kirsher #define    RX_DEBUG_FC_STATE_MASK          0x000000180 /* flow control state machine
721e689cf4aSJeff Kirsher 							 w/ MAC:
722e689cf4aSJeff Kirsher 							 0x0 = idle
723e689cf4aSJeff Kirsher 							 0x1 = wait xoff ack
724e689cf4aSJeff Kirsher 							 0x2 = wait xon
725e689cf4aSJeff Kirsher 							 0x3 = wait xon ack */
726e689cf4aSJeff Kirsher #define    RX_DEBUG_DATA_STATE_MASK        0x000001E00 /* unload data state machine
727e689cf4aSJeff Kirsher 							 states:
728e689cf4aSJeff Kirsher 							 0x0 = idle data
729e689cf4aSJeff Kirsher 							 0x1 = header begin
730e689cf4aSJeff Kirsher 							 0x2 = xfer header
731e689cf4aSJeff Kirsher 							 0x3 = xfer header ld
732e689cf4aSJeff Kirsher 							 0x4 = mtu begin
733e689cf4aSJeff Kirsher 							 0x5 = xfer mtu
734e689cf4aSJeff Kirsher 							 0x6 = xfer mtu ld
735e689cf4aSJeff Kirsher 							 0x7 = jumbo begin
736e689cf4aSJeff Kirsher 							 0x8 = xfer jumbo
737e689cf4aSJeff Kirsher 							 0x9 = xfer jumbo ld
738e689cf4aSJeff Kirsher 							 0xa = reas begin
739e689cf4aSJeff Kirsher 							 0xb = xfer reas
740e689cf4aSJeff Kirsher 							 0xc = flush tag
741e689cf4aSJeff Kirsher 							 0xd = xfer reas ld
742e689cf4aSJeff Kirsher 							 0xe = error
743e689cf4aSJeff Kirsher 							 0xf = bubble idle */
744e689cf4aSJeff Kirsher #define    RX_DEBUG_DESC_STATE_MASK        0x0001E000 /* unload desc state machine
745e689cf4aSJeff Kirsher 							 states:
746e689cf4aSJeff Kirsher 							 0x0 = idle desc
747e689cf4aSJeff Kirsher 							 0x1 = wait ack
748e689cf4aSJeff Kirsher 							 0x9 = wait ack 2
749e689cf4aSJeff Kirsher 							 0x2 = fetch desc 1
750e689cf4aSJeff Kirsher 							 0xa = fetch desc 2
751e689cf4aSJeff Kirsher 							 0x3 = load ptrs
752e689cf4aSJeff Kirsher 							 0x4 = wait dma
753e689cf4aSJeff Kirsher 							 0x5 = wait ack batch
754e689cf4aSJeff Kirsher 							 0x6 = post batch
755e689cf4aSJeff Kirsher 							 0x7 = xfr done */
756e689cf4aSJeff Kirsher #define    RX_DEBUG_INTR_READ_PTR_MASK     0x30000000 /* interrupt read ptr of the
757e689cf4aSJeff Kirsher 							 interrupt queue */
758e689cf4aSJeff Kirsher #define    RX_DEBUG_INTR_WRITE_PTR_MASK    0xC0000000 /* interrupt write pointer
759e689cf4aSJeff Kirsher 							 of the interrupt queue */
760e689cf4aSJeff Kirsher 
761e689cf4aSJeff Kirsher /* flow control frames are emitted using two PAUSE thresholds:
762e689cf4aSJeff Kirsher  * XOFF PAUSE uses pause time value pre-programmed in the Send PAUSE MAC reg
763e689cf4aSJeff Kirsher  * XON PAUSE uses a pause time of 0. granularity of threshold is 64bytes.
764e689cf4aSJeff Kirsher  * PAUSE thresholds defined in terms of FIFO occupancy and may be translated
765e689cf4aSJeff Kirsher  * into FIFO vacancy using RX_FIFO_SIZE. setting ON will trigger XON frames
766e689cf4aSJeff Kirsher  * when FIFO reaches 0. OFF threshold should not be > size of RX FIFO. max
767*c3178883SJilin Yuan  * value is 0x6F.
768e689cf4aSJeff Kirsher  * DEFAULT: 0x00078
769e689cf4aSJeff Kirsher  */
770e689cf4aSJeff Kirsher #define  REG_RX_PAUSE_THRESH               0x4020  /* RX pause thresholds */
771e689cf4aSJeff Kirsher #define    RX_PAUSE_THRESH_QUANTUM         64
772e689cf4aSJeff Kirsher #define    RX_PAUSE_THRESH_OFF_MASK        0x000001FF /* XOFF PAUSE emitted when
773e689cf4aSJeff Kirsher 							 RX FIFO occupancy >
774e689cf4aSJeff Kirsher 							 value*64B */
775e689cf4aSJeff Kirsher #define    RX_PAUSE_THRESH_OFF_SHIFT       0
776e689cf4aSJeff Kirsher #define    RX_PAUSE_THRESH_ON_MASK         0x001FF000 /* XON PAUSE emitted after
777e689cf4aSJeff Kirsher 							 emitting XOFF PAUSE when RX
778e689cf4aSJeff Kirsher 							 FIFO occupancy falls below
779e689cf4aSJeff Kirsher 							 this value*64B. must be
780e689cf4aSJeff Kirsher 							 < XOFF threshold. if =
781e689cf4aSJeff Kirsher 							 RX_FIFO_SIZE< XON frames are
782e689cf4aSJeff Kirsher 							 never emitted. */
783e689cf4aSJeff Kirsher #define    RX_PAUSE_THRESH_ON_SHIFT        12
784e689cf4aSJeff Kirsher 
785e689cf4aSJeff Kirsher /* 13-bit register used to control RX desc fetching and intr generation. if 4+
786e689cf4aSJeff Kirsher  * valid RX descriptors are available, Cassini will read 4 at a time.
787e689cf4aSJeff Kirsher  * writing N means that all desc up to *but* excluding N are available. N must
788e689cf4aSJeff Kirsher  * be a multiple of 4 (N % 4 = 0). first desc should be cache-line aligned.
789e689cf4aSJeff Kirsher  * DEFAULT: 0 on reset
790e689cf4aSJeff Kirsher  */
791e689cf4aSJeff Kirsher #define  REG_RX_KICK                    0x4024  /* RX kick reg */
792e689cf4aSJeff Kirsher 
793e689cf4aSJeff Kirsher /* 8KB aligned 64-bit pointer to the base of the RX free/completion rings.
794e689cf4aSJeff Kirsher  * lower 13 bits of the low register are hard-wired to 0.
795e689cf4aSJeff Kirsher  */
796e689cf4aSJeff Kirsher #define  REG_RX_DB_LOW                     0x4028  /* RX descriptor ring
797e689cf4aSJeff Kirsher 							 base low */
798e689cf4aSJeff Kirsher #define  REG_RX_DB_HI                      0x402C  /* RX descriptor ring
799e689cf4aSJeff Kirsher 							 base hi */
800e689cf4aSJeff Kirsher #define  REG_RX_CB_LOW                     0x4030  /* RX completion ring
801e689cf4aSJeff Kirsher 							 base low */
802e689cf4aSJeff Kirsher #define  REG_RX_CB_HI                      0x4034  /* RX completion ring
803e689cf4aSJeff Kirsher 							 base hi */
804e689cf4aSJeff Kirsher /* 13-bit register indicate desc used by cassini for receive frames. used
805e689cf4aSJeff Kirsher  * for diagnostic purposes.
806e689cf4aSJeff Kirsher  * DEFAULT: 0 on reset
807e689cf4aSJeff Kirsher  */
808e689cf4aSJeff Kirsher #define  REG_RX_COMP                       0x4038  /* (ro) RX completion */
809e689cf4aSJeff Kirsher 
810e689cf4aSJeff Kirsher /* HEAD and TAIL are used to control RX desc posting and interrupt
811e689cf4aSJeff Kirsher  * generation.  hw moves the head register to pass ownership to sw. sw
812e689cf4aSJeff Kirsher  * moves the tail register to pass ownership back to hw. to give all
813e689cf4aSJeff Kirsher  * entries to hw, set TAIL = HEAD.  if HEAD and TAIL indicate that no
814e689cf4aSJeff Kirsher  * more entries are available, DMA will pause and an interrupt will be
815e689cf4aSJeff Kirsher  * generated to indicate no more entries are available.  sw can use
816e689cf4aSJeff Kirsher  * this interrupt to reduce the # of times it must update the
817e689cf4aSJeff Kirsher  * completion tail register.
818e689cf4aSJeff Kirsher  * DEFAULT: 0 on reset
819e689cf4aSJeff Kirsher  */
820e689cf4aSJeff Kirsher #define  REG_RX_COMP_HEAD                  0x403C  /* RX completion head */
821e689cf4aSJeff Kirsher #define  REG_RX_COMP_TAIL                  0x4040  /* RX completion tail */
822e689cf4aSJeff Kirsher 
823e689cf4aSJeff Kirsher /* values used for receive interrupt blanking. loaded each time the ISR is read
824e689cf4aSJeff Kirsher  * DEFAULT: 0x00000000
825e689cf4aSJeff Kirsher  */
826e689cf4aSJeff Kirsher #define  REG_RX_BLANK                      0x4044  /* RX blanking register
827e689cf4aSJeff Kirsher 							 for ISR read */
828e689cf4aSJeff Kirsher #define    RX_BLANK_INTR_PKT_MASK          0x000001FF /* RX_DONE intr asserted if
829e689cf4aSJeff Kirsher 							 this many sets of completion
830e689cf4aSJeff Kirsher 							 writebacks (up to 2 packets)
831e689cf4aSJeff Kirsher 							 occur since the last time
832e689cf4aSJeff Kirsher 							 the ISR was read. 0 = no
833e689cf4aSJeff Kirsher 							 packet blanking */
834e689cf4aSJeff Kirsher #define    RX_BLANK_INTR_PKT_SHIFT         0
835e689cf4aSJeff Kirsher #define    RX_BLANK_INTR_TIME_MASK         0x3FFFF000 /* RX_DONE interrupt asserted
836e689cf4aSJeff Kirsher 							 if that many clocks were
837e689cf4aSJeff Kirsher 							 counted since last time the
838e689cf4aSJeff Kirsher 							 ISR was read.
839e689cf4aSJeff Kirsher 							 each count is 512 core
840e689cf4aSJeff Kirsher 							 clocks (125MHz). 0 = no
841e689cf4aSJeff Kirsher 							 time blanking */
842e689cf4aSJeff Kirsher #define    RX_BLANK_INTR_TIME_SHIFT        12
843e689cf4aSJeff Kirsher 
844e689cf4aSJeff Kirsher /* values used for interrupt generation based on threshold values of how
845e689cf4aSJeff Kirsher  * many free desc and completion entries are available for hw use.
846e689cf4aSJeff Kirsher  * DEFAULT: 0x00000000
847e689cf4aSJeff Kirsher  */
848e689cf4aSJeff Kirsher #define  REG_RX_AE_THRESH                  0x4048  /* RX almost empty
849e689cf4aSJeff Kirsher 							 thresholds */
850e689cf4aSJeff Kirsher #define    RX_AE_THRESH_FREE_MASK          0x00001FFF /* RX_BUF_AE will be
851e689cf4aSJeff Kirsher 							 generated if # desc
852e689cf4aSJeff Kirsher 							 avail for hw use <=
853e689cf4aSJeff Kirsher 							 # */
854e689cf4aSJeff Kirsher #define    RX_AE_THRESH_FREE_SHIFT         0
855e689cf4aSJeff Kirsher #define    RX_AE_THRESH_COMP_MASK          0x0FFFE000 /* RX_COMP_AE will be
856e689cf4aSJeff Kirsher 							 generated if # of
857e689cf4aSJeff Kirsher 							 completion entries
858e689cf4aSJeff Kirsher 							 avail for hw use <=
859e689cf4aSJeff Kirsher 							 # */
860e689cf4aSJeff Kirsher #define    RX_AE_THRESH_COMP_SHIFT         13
861e689cf4aSJeff Kirsher 
862e689cf4aSJeff Kirsher /* probabilities for random early drop (RED) thresholds on a FIFO threshold
863e689cf4aSJeff Kirsher  * basis. probability should increase when the FIFO level increases. control
864e689cf4aSJeff Kirsher  * packets are never dropped and not counted in stats. probability programmed
865e689cf4aSJeff Kirsher  * on a 12.5% granularity. e.g., 0x1 = 1/8 packets dropped.
866e689cf4aSJeff Kirsher  * DEFAULT: 0x00000000
867e689cf4aSJeff Kirsher  */
868e689cf4aSJeff Kirsher #define  REG_RX_RED                      0x404C  /* RX random early detect enable */
869e689cf4aSJeff Kirsher #define    RX_RED_4K_6K_FIFO_MASK        0x000000FF /*  4KB < FIFO thresh < 6KB */
870e689cf4aSJeff Kirsher #define    RX_RED_6K_8K_FIFO_MASK        0x0000FF00 /*  6KB < FIFO thresh < 8KB */
871e689cf4aSJeff Kirsher #define    RX_RED_8K_10K_FIFO_MASK       0x00FF0000 /*  8KB < FIFO thresh < 10KB */
872e689cf4aSJeff Kirsher #define    RX_RED_10K_12K_FIFO_MASK      0xFF000000 /* 10KB < FIFO thresh < 12KB */
873e689cf4aSJeff Kirsher 
874e689cf4aSJeff Kirsher /* FIFO fullness levels for RX FIFO, RX control FIFO, and RX IPP FIFO.
875e689cf4aSJeff Kirsher  * RX control FIFO = # of packets in RX FIFO.
876e689cf4aSJeff Kirsher  * DEFAULT: 0x0
877e689cf4aSJeff Kirsher  */
878e689cf4aSJeff Kirsher #define  REG_RX_FIFO_FULLNESS              0x4050  /* (ro) RX FIFO fullness */
879e689cf4aSJeff Kirsher #define    RX_FIFO_FULLNESS_RX_FIFO_MASK   0x3FF80000 /* level w/ 8B granularity */
880e689cf4aSJeff Kirsher #define    RX_FIFO_FULLNESS_IPP_FIFO_MASK  0x0007FF00 /* level w/ 8B granularity */
881e689cf4aSJeff Kirsher #define    RX_FIFO_FULLNESS_RX_PKT_MASK    0x000000FF /* # packets in RX FIFO */
882e689cf4aSJeff Kirsher #define  REG_RX_IPP_PACKET_COUNT           0x4054  /* RX IPP packet counter */
883e689cf4aSJeff Kirsher #define  REG_RX_WORK_DMA_PTR_LOW           0x4058  /* RX working DMA ptr low */
884e689cf4aSJeff Kirsher #define  REG_RX_WORK_DMA_PTR_HI            0x405C  /* RX working DMA ptr
885e689cf4aSJeff Kirsher 						      high */
886e689cf4aSJeff Kirsher 
887e689cf4aSJeff Kirsher /* BIST testing ro RX FIFO, RX control FIFO, and RX IPP FIFO. only RX BIST
888e689cf4aSJeff Kirsher  * START/COMPLETE is writeable. START will clear when the BIST has completed
889e689cf4aSJeff Kirsher  * checking all 17 RAMS.
890e689cf4aSJeff Kirsher  * DEFAULT: 0bxxxx xxxxx xxxx xxxx xxxx x000 0000 0000 00x0
891e689cf4aSJeff Kirsher  */
892e689cf4aSJeff Kirsher #define  REG_RX_BIST                       0x4060  /* (ro) RX BIST */
893e689cf4aSJeff Kirsher #define    RX_BIST_32A_PASS                0x80000000 /* RX FIFO 32A passed */
894e689cf4aSJeff Kirsher #define    RX_BIST_33A_PASS                0x40000000 /* RX FIFO 33A passed */
895e689cf4aSJeff Kirsher #define    RX_BIST_32B_PASS                0x20000000 /* RX FIFO 32B passed */
896e689cf4aSJeff Kirsher #define    RX_BIST_33B_PASS                0x10000000 /* RX FIFO 33B passed */
897e689cf4aSJeff Kirsher #define    RX_BIST_32C_PASS                0x08000000 /* RX FIFO 32C passed */
898e689cf4aSJeff Kirsher #define    RX_BIST_33C_PASS                0x04000000 /* RX FIFO 33C passed */
899e689cf4aSJeff Kirsher #define    RX_BIST_IPP_32A_PASS            0x02000000 /* RX IPP FIFO 33B passed */
900e689cf4aSJeff Kirsher #define    RX_BIST_IPP_33A_PASS            0x01000000 /* RX IPP FIFO 33A passed */
901e689cf4aSJeff Kirsher #define    RX_BIST_IPP_32B_PASS            0x00800000 /* RX IPP FIFO 32B passed */
902e689cf4aSJeff Kirsher #define    RX_BIST_IPP_33B_PASS            0x00400000 /* RX IPP FIFO 33B passed */
903e689cf4aSJeff Kirsher #define    RX_BIST_IPP_32C_PASS            0x00200000 /* RX IPP FIFO 32C passed */
904e689cf4aSJeff Kirsher #define    RX_BIST_IPP_33C_PASS            0x00100000 /* RX IPP FIFO 33C passed */
905e689cf4aSJeff Kirsher #define    RX_BIST_CTRL_32_PASS            0x00800000 /* RX CTRL FIFO 32 passed */
906e689cf4aSJeff Kirsher #define    RX_BIST_CTRL_33_PASS            0x00400000 /* RX CTRL FIFO 33 passed */
907e689cf4aSJeff Kirsher #define    RX_BIST_REAS_26A_PASS           0x00200000 /* RX Reas 26A passed */
908e689cf4aSJeff Kirsher #define    RX_BIST_REAS_26B_PASS           0x00100000 /* RX Reas 26B passed */
909e689cf4aSJeff Kirsher #define    RX_BIST_REAS_27_PASS            0x00080000 /* RX Reas 27 passed */
910e689cf4aSJeff Kirsher #define    RX_BIST_STATE_MASK              0x00078000 /* BIST state machine */
911e689cf4aSJeff Kirsher #define    RX_BIST_SUMMARY                 0x00000002 /* when BIST complete,
912e689cf4aSJeff Kirsher 							 summary pass bit
913e689cf4aSJeff Kirsher 							 contains AND of BIST
914e689cf4aSJeff Kirsher 							 results of all 16
915e689cf4aSJeff Kirsher 							 RAMS */
916e689cf4aSJeff Kirsher #define    RX_BIST_START                   0x00000001 /* write 1 to start
917e689cf4aSJeff Kirsher 							 BIST. self clears
918e689cf4aSJeff Kirsher 							 on completion. */
919e689cf4aSJeff Kirsher 
920e689cf4aSJeff Kirsher /* next location in RX CTRL FIFO that will be loaded w/ data from RX IPP/read
921e689cf4aSJeff Kirsher  * from to retrieve packet control info.
922e689cf4aSJeff Kirsher  * DEFAULT: 0
923e689cf4aSJeff Kirsher  */
924e689cf4aSJeff Kirsher #define  REG_RX_CTRL_FIFO_WRITE_PTR        0x4064  /* (ro) RX control FIFO
925e689cf4aSJeff Kirsher 						      write ptr */
926e689cf4aSJeff Kirsher #define  REG_RX_CTRL_FIFO_READ_PTR         0x4068  /* (ro) RX control FIFO read
927e689cf4aSJeff Kirsher 						      ptr */
928e689cf4aSJeff Kirsher 
929e689cf4aSJeff Kirsher /* receive interrupt blanking. loaded each time interrupt alias register is
930e689cf4aSJeff Kirsher  * read.
931e689cf4aSJeff Kirsher  * DEFAULT: 0x0
932e689cf4aSJeff Kirsher  */
933e689cf4aSJeff Kirsher #define  REG_RX_BLANK_ALIAS_READ           0x406C  /* RX blanking register for
934e689cf4aSJeff Kirsher 						      alias read */
935e689cf4aSJeff Kirsher #define    RX_BAR_INTR_PACKET_MASK         0x000001FF /* assert RX_DONE if #
936e689cf4aSJeff Kirsher 							 completion writebacks
937e689cf4aSJeff Kirsher 							 > # since last ISR
938e689cf4aSJeff Kirsher 							 read. 0 = no
939e689cf4aSJeff Kirsher 							 blanking. up to 2
940e689cf4aSJeff Kirsher 							 packets per
941e689cf4aSJeff Kirsher 							 completion wb. */
942e689cf4aSJeff Kirsher #define    RX_BAR_INTR_TIME_MASK           0x3FFFF000 /* assert RX_DONE if #
943e689cf4aSJeff Kirsher 							 clocks > # since last
944e689cf4aSJeff Kirsher 							 ISR read. each count
945e689cf4aSJeff Kirsher 							 is 512 core clocks
946e689cf4aSJeff Kirsher 							 (125MHz). 0 = no
947e689cf4aSJeff Kirsher 							 blanking. */
948e689cf4aSJeff Kirsher 
949e689cf4aSJeff Kirsher /* diagnostic access to RX FIFO. 32 LSB accessed via DATA_LOW. 32 MSB accessed
950e689cf4aSJeff Kirsher  * via DATA_HI_T0 or DATA_HI_T1. TAG reads the tag bit. writing HI_T0
951e689cf4aSJeff Kirsher  * will unset the tag bit while writing HI_T1 will set the tag bit. to reset
952e689cf4aSJeff Kirsher  * to normal operation after diagnostics, write to address location 0x0.
953e689cf4aSJeff Kirsher  * RX_DMA_EN bit must be set to 0x0 for RX FIFO PIO access. DATA_HI should
954e689cf4aSJeff Kirsher  * be the last write access of a write sequence.
955e689cf4aSJeff Kirsher  * DEFAULT: undefined
956e689cf4aSJeff Kirsher  */
957e689cf4aSJeff Kirsher #define  REG_RX_FIFO_ADDR                  0x4080  /* RX FIFO address */
958e689cf4aSJeff Kirsher #define  REG_RX_FIFO_TAG                   0x4084  /* RX FIFO tag */
959e689cf4aSJeff Kirsher #define  REG_RX_FIFO_DATA_LOW              0x4088  /* RX FIFO data low */
960e689cf4aSJeff Kirsher #define  REG_RX_FIFO_DATA_HI_T0            0x408C  /* RX FIFO data high T0 */
961e689cf4aSJeff Kirsher #define  REG_RX_FIFO_DATA_HI_T1            0x4090  /* RX FIFO data high T1 */
962e689cf4aSJeff Kirsher 
963e689cf4aSJeff Kirsher /* diagnostic assess to RX CTRL FIFO. 8-bit FIFO_ADDR holds address of
964e689cf4aSJeff Kirsher  * 81 bit control entry and 6 bit flow id. LOW and MID are both 32-bit
965e689cf4aSJeff Kirsher  * accesses. HI is 7-bits with 6-bit flow id and 1 bit control
966e689cf4aSJeff Kirsher  * word. RX_DMA_EN must be 0 for RX CTRL FIFO PIO access. DATA_HI
967e689cf4aSJeff Kirsher  * should be last write access of the write sequence.
968e689cf4aSJeff Kirsher  * DEFAULT: undefined
969e689cf4aSJeff Kirsher  */
970e689cf4aSJeff Kirsher #define  REG_RX_CTRL_FIFO_ADDR             0x4094  /* RX Control FIFO and
971e689cf4aSJeff Kirsher 						      Batching FIFO addr */
972e689cf4aSJeff Kirsher #define  REG_RX_CTRL_FIFO_DATA_LOW         0x4098  /* RX Control FIFO data
973e689cf4aSJeff Kirsher 						      low */
974e689cf4aSJeff Kirsher #define  REG_RX_CTRL_FIFO_DATA_MID         0x409C  /* RX Control FIFO data
975e689cf4aSJeff Kirsher 						      mid */
976e689cf4aSJeff Kirsher #define  REG_RX_CTRL_FIFO_DATA_HI          0x4100  /* RX Control FIFO data
977e689cf4aSJeff Kirsher 						      hi and flow id */
978e689cf4aSJeff Kirsher #define    RX_CTRL_FIFO_DATA_HI_CTRL       0x0001  /* upper bit of ctrl word */
979e689cf4aSJeff Kirsher #define    RX_CTRL_FIFO_DATA_HI_FLOW_MASK  0x007E  /* flow id */
980e689cf4aSJeff Kirsher 
981e689cf4aSJeff Kirsher /* diagnostic access to RX IPP FIFO. same semantics as RX_FIFO.
982e689cf4aSJeff Kirsher  * DEFAULT: undefined
983e689cf4aSJeff Kirsher  */
984e689cf4aSJeff Kirsher #define  REG_RX_IPP_FIFO_ADDR              0x4104  /* RX IPP FIFO address */
985e689cf4aSJeff Kirsher #define  REG_RX_IPP_FIFO_TAG               0x4108  /* RX IPP FIFO tag */
986e689cf4aSJeff Kirsher #define  REG_RX_IPP_FIFO_DATA_LOW          0x410C  /* RX IPP FIFO data low */
987e689cf4aSJeff Kirsher #define  REG_RX_IPP_FIFO_DATA_HI_T0        0x4110  /* RX IPP FIFO data high
988e689cf4aSJeff Kirsher 						      T0 */
989e689cf4aSJeff Kirsher #define  REG_RX_IPP_FIFO_DATA_HI_T1        0x4114  /* RX IPP FIFO data high
990e689cf4aSJeff Kirsher 						      T1 */
991e689cf4aSJeff Kirsher 
992e689cf4aSJeff Kirsher /* 64-bit pointer to receive data buffer in host memory used for headers and
993e689cf4aSJeff Kirsher  * small packets. MSB in high register. loaded by DMA state machine and
994e689cf4aSJeff Kirsher  * increments as DMA writes receive data. only 50 LSB are incremented. top
995e689cf4aSJeff Kirsher  * 13 bits taken from RX descriptor.
996e689cf4aSJeff Kirsher  * DEFAULT: undefined
997e689cf4aSJeff Kirsher  */
998e689cf4aSJeff Kirsher #define  REG_RX_HEADER_PAGE_PTR_LOW        0x4118  /* (ro) RX header page ptr
999e689cf4aSJeff Kirsher 						      low */
1000e689cf4aSJeff Kirsher #define  REG_RX_HEADER_PAGE_PTR_HI         0x411C  /* (ro) RX header page ptr
1001e689cf4aSJeff Kirsher 						      high */
1002e689cf4aSJeff Kirsher #define  REG_RX_MTU_PAGE_PTR_LOW           0x4120  /* (ro) RX MTU page pointer
1003e689cf4aSJeff Kirsher 						      low */
1004e689cf4aSJeff Kirsher #define  REG_RX_MTU_PAGE_PTR_HI            0x4124  /* (ro) RX MTU page pointer
1005e689cf4aSJeff Kirsher 						      high */
1006e689cf4aSJeff Kirsher 
1007e689cf4aSJeff Kirsher /* PIO diagnostic access to RX reassembly DMA Table RAM. 6-bit register holds
1008e689cf4aSJeff Kirsher  * one of 64 79-bit locations in the RX Reassembly DMA table and the addr of
1009e689cf4aSJeff Kirsher  * one of the 64 byte locations in the Batching table. LOW holds 32 LSB.
1010e689cf4aSJeff Kirsher  * MID holds the next 32 LSB. HIGH holds the 15 MSB. RX_DMA_EN must be set
1011e689cf4aSJeff Kirsher  * to 0 for PIO access. DATA_HIGH should be last write of write sequence.
1012e689cf4aSJeff Kirsher  * layout:
1013e689cf4aSJeff Kirsher  * reassmbl ptr [78:15] | reassmbl index [14:1] | reassmbl entry valid [0]
1014e689cf4aSJeff Kirsher  * DEFAULT: undefined
1015e689cf4aSJeff Kirsher  */
1016e689cf4aSJeff Kirsher #define  REG_RX_TABLE_ADDR             0x4128  /* RX reassembly DMA table
1017e689cf4aSJeff Kirsher 						  address */
1018e689cf4aSJeff Kirsher #define    RX_TABLE_ADDR_MASK          0x0000003F /* address mask */
1019e689cf4aSJeff Kirsher 
1020e689cf4aSJeff Kirsher #define  REG_RX_TABLE_DATA_LOW         0x412C  /* RX reassembly DMA table
1021e689cf4aSJeff Kirsher 						  data low */
1022e689cf4aSJeff Kirsher #define  REG_RX_TABLE_DATA_MID         0x4130  /* RX reassembly DMA table
1023e689cf4aSJeff Kirsher 						  data mid */
1024e689cf4aSJeff Kirsher #define  REG_RX_TABLE_DATA_HI          0x4134  /* RX reassembly DMA table
1025e689cf4aSJeff Kirsher 						  data high */
1026e689cf4aSJeff Kirsher 
1027e689cf4aSJeff Kirsher /* cassini+ only */
1028e689cf4aSJeff Kirsher /* 8KB aligned 64-bit pointer to base of RX rings. lower 13 bits hardwired to
1029e689cf4aSJeff Kirsher  * 0. same semantics as primary desc/complete rings.
1030e689cf4aSJeff Kirsher  */
1031e689cf4aSJeff Kirsher #define  REG_PLUS_RX_DB1_LOW            0x4200  /* RX descriptor ring
1032e689cf4aSJeff Kirsher 						   2 base low */
1033e689cf4aSJeff Kirsher #define  REG_PLUS_RX_DB1_HI             0x4204  /* RX descriptor ring
1034e689cf4aSJeff Kirsher 						   2 base high */
1035e689cf4aSJeff Kirsher #define  REG_PLUS_RX_CB1_LOW            0x4208  /* RX completion ring
1036e689cf4aSJeff Kirsher 						   2 base low. 4 total */
1037e689cf4aSJeff Kirsher #define  REG_PLUS_RX_CB1_HI             0x420C  /* RX completion ring
1038e689cf4aSJeff Kirsher 						   2 base high. 4 total */
1039e689cf4aSJeff Kirsher #define  REG_PLUS_RX_CBN_LOW(x)        (REG_PLUS_RX_CB1_LOW + 8*((x) - 1))
1040e689cf4aSJeff Kirsher #define  REG_PLUS_RX_CBN_HI(x)         (REG_PLUS_RX_CB1_HI + 8*((x) - 1))
1041e689cf4aSJeff Kirsher #define  REG_PLUS_RX_KICK1             0x4220  /* RX Kick 2 register */
1042e689cf4aSJeff Kirsher #define  REG_PLUS_RX_COMP1             0x4224  /* (ro) RX completion 2
1043e689cf4aSJeff Kirsher 						  reg */
1044e689cf4aSJeff Kirsher #define  REG_PLUS_RX_COMP1_HEAD        0x4228  /* (ro) RX completion 2
1045e689cf4aSJeff Kirsher 						  head reg. 4 total. */
1046e689cf4aSJeff Kirsher #define  REG_PLUS_RX_COMP1_TAIL        0x422C  /* RX completion 2
1047e689cf4aSJeff Kirsher 						  tail reg. 4 total. */
1048e689cf4aSJeff Kirsher #define  REG_PLUS_RX_COMPN_HEAD(x)    (REG_PLUS_RX_COMP1_HEAD + 8*((x) - 1))
1049e689cf4aSJeff Kirsher #define  REG_PLUS_RX_COMPN_TAIL(x)    (REG_PLUS_RX_COMP1_TAIL + 8*((x) - 1))
1050e689cf4aSJeff Kirsher #define  REG_PLUS_RX_AE1_THRESH        0x4240  /* RX almost empty 2
1051e689cf4aSJeff Kirsher 						  thresholds */
1052e689cf4aSJeff Kirsher #define    RX_AE1_THRESH_FREE_MASK     RX_AE_THRESH_FREE_MASK
1053e689cf4aSJeff Kirsher #define    RX_AE1_THRESH_FREE_SHIFT    RX_AE_THRESH_FREE_SHIFT
1054e689cf4aSJeff Kirsher 
1055e689cf4aSJeff Kirsher /** header parser registers **/
1056e689cf4aSJeff Kirsher 
1057e689cf4aSJeff Kirsher /* RX parser configuration register.
1058e689cf4aSJeff Kirsher  * DEFAULT: 0x1651004
1059e689cf4aSJeff Kirsher  */
1060e689cf4aSJeff Kirsher #define  REG_HP_CFG                       0x4140  /* header parser
1061e689cf4aSJeff Kirsher 						     configuration reg */
1062e689cf4aSJeff Kirsher #define    HP_CFG_PARSE_EN                0x00000001 /* enab header parsing */
1063e689cf4aSJeff Kirsher #define    HP_CFG_NUM_CPU_MASK            0x000000FC /* # processors
1064e689cf4aSJeff Kirsher 						      0 = 64. 0x3f = 63 */
1065e689cf4aSJeff Kirsher #define    HP_CFG_NUM_CPU_SHIFT           2
1066e689cf4aSJeff Kirsher #define    HP_CFG_SYN_INC_MASK            0x00000100 /* SYN bit won't increment
1067e689cf4aSJeff Kirsher 							TCP seq # by one when
1068e689cf4aSJeff Kirsher 							stored in FDBM */
1069e689cf4aSJeff Kirsher #define    HP_CFG_TCP_THRESH_MASK         0x000FFE00 /* # bytes of TCP data
1070e689cf4aSJeff Kirsher 							needed to be considered
1071e689cf4aSJeff Kirsher 							for reassembly */
1072e689cf4aSJeff Kirsher #define    HP_CFG_TCP_THRESH_SHIFT        9
1073e689cf4aSJeff Kirsher 
1074e689cf4aSJeff Kirsher /* access to RX Instruction RAM. 5-bit register/counter holds addr
1075e689cf4aSJeff Kirsher  * of 39 bit entry to be read/written. 32 LSB in _DATA_LOW. 7 MSB in _DATA_HI.
1076e689cf4aSJeff Kirsher  * RX_DMA_EN must be 0 for RX instr PIO access. DATA_HI should be last access
1077e689cf4aSJeff Kirsher  * of sequence.
1078e689cf4aSJeff Kirsher  * DEFAULT: undefined
1079e689cf4aSJeff Kirsher  */
1080e689cf4aSJeff Kirsher #define  REG_HP_INSTR_RAM_ADDR             0x4144  /* HP instruction RAM
1081e689cf4aSJeff Kirsher 						      address */
1082e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_ADDR_MASK          0x01F   /* 5-bit mask */
1083e689cf4aSJeff Kirsher #define  REG_HP_INSTR_RAM_DATA_LOW         0x4148  /* HP instruction RAM
1084e689cf4aSJeff Kirsher 						      data low */
1085e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_LOW_OUTMASK_MASK   0x0000FFFF
1086e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_LOW_OUTMASK_SHIFT  0
1087e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_LOW_OUTSHIFT_MASK  0x000F0000
1088e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_LOW_OUTSHIFT_SHIFT 16
1089e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_LOW_OUTEN_MASK     0x00300000
1090e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_LOW_OUTEN_SHIFT    20
1091e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_LOW_OUTARG_MASK    0xFFC00000
1092e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_LOW_OUTARG_SHIFT   22
1093e689cf4aSJeff Kirsher #define  REG_HP_INSTR_RAM_DATA_MID         0x414C  /* HP instruction RAM
1094e689cf4aSJeff Kirsher 						      data mid */
1095e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_MID_OUTARG_MASK    0x00000003
1096e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_MID_OUTARG_SHIFT   0
1097e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_MID_OUTOP_MASK     0x0000003C
1098e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_MID_OUTOP_SHIFT    2
1099e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_MID_FNEXT_MASK     0x000007C0
1100e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_MID_FNEXT_SHIFT    6
1101e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_MID_FOFF_MASK      0x0003F800
1102e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_MID_FOFF_SHIFT     11
1103e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_MID_SNEXT_MASK     0x007C0000
1104e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_MID_SNEXT_SHIFT    18
1105e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_MID_SOFF_MASK      0x3F800000
1106e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_MID_SOFF_SHIFT     23
1107e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_MID_OP_MASK        0xC0000000
1108e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_MID_OP_SHIFT       30
1109e689cf4aSJeff Kirsher #define  REG_HP_INSTR_RAM_DATA_HI          0x4150  /* HP instruction RAM
1110e689cf4aSJeff Kirsher 						      data high */
1111e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_HI_VAL_MASK        0x0000FFFF
1112e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_HI_VAL_SHIFT       0
1113e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_HI_MASK_MASK       0xFFFF0000
1114e689cf4aSJeff Kirsher #define    HP_INSTR_RAM_HI_MASK_SHIFT      16
1115e689cf4aSJeff Kirsher 
1116e689cf4aSJeff Kirsher /* PIO access into RX Header parser data RAM and flow database.
1117e689cf4aSJeff Kirsher  * 11-bit register. Data fills the LSB portion of bus if less than 32 bits.
1118e689cf4aSJeff Kirsher  * DATA_RAM: write RAM_FDB_DATA with index to access DATA_RAM.
1119e689cf4aSJeff Kirsher  * RAM bytes = 4*(x - 1) + [3:0]. e.g., 0 -> [3:0], 31 -> [123:120]
1120e689cf4aSJeff Kirsher  * FLOWDB: write DATA_RAM_FDB register and then read/write FDB1-12 to access
1121e689cf4aSJeff Kirsher  * flow database.
1122e689cf4aSJeff Kirsher  * RX_DMA_EN must be 0 for RX parser RAM PIO access. RX Parser RAM data reg
1123e689cf4aSJeff Kirsher  * should be the last write access of the write sequence.
1124e689cf4aSJeff Kirsher  * DEFAULT: undefined
1125e689cf4aSJeff Kirsher  */
1126e689cf4aSJeff Kirsher #define  REG_HP_DATA_RAM_FDB_ADDR          0x4154  /* HP data and FDB
1127e689cf4aSJeff Kirsher 						      RAM address */
1128e689cf4aSJeff Kirsher #define    HP_DATA_RAM_FDB_DATA_MASK       0x001F  /* select 1 of 86 byte
1129e689cf4aSJeff Kirsher 						      locations in header
1130e689cf4aSJeff Kirsher 						      parser data ram to
1131e689cf4aSJeff Kirsher 						      read/write */
1132e689cf4aSJeff Kirsher #define    HP_DATA_RAM_FDB_FDB_MASK        0x3F00  /* 1 of 64 353-bit locations
1133e689cf4aSJeff Kirsher 						      in the flow database */
1134e689cf4aSJeff Kirsher #define  REG_HP_DATA_RAM_DATA              0x4158  /* HP data RAM data */
1135e689cf4aSJeff Kirsher 
1136e689cf4aSJeff Kirsher /* HP flow database registers: 1 - 12, 0x415C - 0x4188, 4 8-bit bytes
1137e689cf4aSJeff Kirsher  * FLOW_DB(1) = IP_SA[127:96], FLOW_DB(2) = IP_SA[95:64]
1138e689cf4aSJeff Kirsher  * FLOW_DB(3) = IP_SA[63:32],  FLOW_DB(4) = IP_SA[31:0]
1139e689cf4aSJeff Kirsher  * FLOW_DB(5) = IP_DA[127:96], FLOW_DB(6) = IP_DA[95:64]
1140e689cf4aSJeff Kirsher  * FLOW_DB(7) = IP_DA[63:32],  FLOW_DB(8) = IP_DA[31:0]
1141e689cf4aSJeff Kirsher  * FLOW_DB(9) = {TCP_SP[15:0],TCP_DP[15:0]}
1142e689cf4aSJeff Kirsher  * FLOW_DB(10) = bit 0 has value for flow valid
1143e689cf4aSJeff Kirsher  * FLOW_DB(11) = TCP_SEQ[63:32], FLOW_DB(12) = TCP_SEQ[31:0]
1144e689cf4aSJeff Kirsher  */
1145e689cf4aSJeff Kirsher #define  REG_HP_FLOW_DB0                   0x415C  /* HP flow database 1 reg */
1146e689cf4aSJeff Kirsher #define  REG_HP_FLOW_DBN(x)                (REG_HP_FLOW_DB0 + (x)*4)
1147e689cf4aSJeff Kirsher 
1148e689cf4aSJeff Kirsher /* diagnostics for RX Header Parser block.
1149e689cf4aSJeff Kirsher  * ASUN: the header parser state machine register is used for diagnostics
1150e689cf4aSJeff Kirsher  * purposes. however, the spec doesn't have any details on it.
1151e689cf4aSJeff Kirsher  */
1152e689cf4aSJeff Kirsher #define  REG_HP_STATE_MACHINE              0x418C  /* (ro) HP state machine */
1153e689cf4aSJeff Kirsher #define  REG_HP_STATUS0                    0x4190  /* (ro) HP status 1 */
1154e689cf4aSJeff Kirsher #define    HP_STATUS0_SAP_MASK             0xFFFF0000 /* SAP */
1155e689cf4aSJeff Kirsher #define    HP_STATUS0_L3_OFF_MASK          0x0000FE00 /* L3 offset */
1156e689cf4aSJeff Kirsher #define    HP_STATUS0_LB_CPUNUM_MASK       0x000001F8 /* load balancing CPU
1157e689cf4aSJeff Kirsher 							 number */
1158e689cf4aSJeff Kirsher #define    HP_STATUS0_HRP_OPCODE_MASK      0x00000007 /* HRP opcode */
1159e689cf4aSJeff Kirsher 
1160e689cf4aSJeff Kirsher #define  REG_HP_STATUS1                    0x4194  /* (ro) HP status 2 */
1161e689cf4aSJeff Kirsher #define    HP_STATUS1_ACCUR2_MASK          0xE0000000 /* accu R2[6:4] */
1162e689cf4aSJeff Kirsher #define    HP_STATUS1_FLOWID_MASK          0x1F800000 /* flow id */
1163e689cf4aSJeff Kirsher #define    HP_STATUS1_TCP_OFF_MASK         0x007F0000 /* tcp payload offset */
1164e689cf4aSJeff Kirsher #define    HP_STATUS1_TCP_SIZE_MASK        0x0000FFFF /* tcp payload size */
1165e689cf4aSJeff Kirsher 
1166e689cf4aSJeff Kirsher #define  REG_HP_STATUS2                    0x4198  /* (ro) HP status 3 */
1167e689cf4aSJeff Kirsher #define    HP_STATUS2_ACCUR2_MASK          0xF0000000 /* accu R2[3:0] */
1168e689cf4aSJeff Kirsher #define    HP_STATUS2_CSUM_OFF_MASK        0x07F00000 /* checksum start
1169e689cf4aSJeff Kirsher 							 start offset */
1170e689cf4aSJeff Kirsher #define    HP_STATUS2_ACCUR1_MASK          0x000FE000 /* accu R1 */
1171e689cf4aSJeff Kirsher #define    HP_STATUS2_FORCE_DROP           0x00001000 /* force drop */
1172e689cf4aSJeff Kirsher #define    HP_STATUS2_BWO_REASSM           0x00000800 /* batching w/o
1173e689cf4aSJeff Kirsher 							 reassembly */
1174e689cf4aSJeff Kirsher #define    HP_STATUS2_JH_SPLIT_EN          0x00000400 /* jumbo header split
1175e689cf4aSJeff Kirsher 							 enable */
1176e689cf4aSJeff Kirsher #define    HP_STATUS2_FORCE_TCP_NOCHECK    0x00000200 /* force tcp no payload
1177e689cf4aSJeff Kirsher 							 check */
1178e689cf4aSJeff Kirsher #define    HP_STATUS2_DATA_MASK_ZERO       0x00000100 /* mask of data length
1179e689cf4aSJeff Kirsher 							 equal to zero */
1180e689cf4aSJeff Kirsher #define    HP_STATUS2_FORCE_TCP_CHECK      0x00000080 /* force tcp payload
1181e689cf4aSJeff Kirsher 							 chk */
1182e689cf4aSJeff Kirsher #define    HP_STATUS2_MASK_TCP_THRESH      0x00000040 /* mask of payload
1183e689cf4aSJeff Kirsher 							 threshold */
1184e689cf4aSJeff Kirsher #define    HP_STATUS2_NO_ASSIST            0x00000020 /* no assist */
1185e689cf4aSJeff Kirsher #define    HP_STATUS2_CTRL_PACKET_FLAG     0x00000010 /* control packet flag */
1186e689cf4aSJeff Kirsher #define    HP_STATUS2_TCP_FLAG_CHECK       0x00000008 /* tcp flag check */
1187e689cf4aSJeff Kirsher #define    HP_STATUS2_SYN_FLAG             0x00000004 /* syn flag */
1188e689cf4aSJeff Kirsher #define    HP_STATUS2_TCP_CHECK            0x00000002 /* tcp payload chk */
1189e689cf4aSJeff Kirsher #define    HP_STATUS2_TCP_NOCHECK          0x00000001 /* tcp no payload chk */
1190e689cf4aSJeff Kirsher 
1191e689cf4aSJeff Kirsher /* BIST for header parser(HP) and flow database memories (FDBM). set _START
1192e689cf4aSJeff Kirsher  * to start BIST. controller clears _START on completion. _START can also
1193e689cf4aSJeff Kirsher  * be cleared to force termination of BIST. a bit set indicates that that
1194e689cf4aSJeff Kirsher  * memory passed its BIST.
1195e689cf4aSJeff Kirsher  */
1196e689cf4aSJeff Kirsher #define  REG_HP_RAM_BIST                   0x419C  /* HP RAM BIST reg */
1197e689cf4aSJeff Kirsher #define    HP_RAM_BIST_HP_DATA_PASS        0x80000000 /* HP data ram */
1198e689cf4aSJeff Kirsher #define    HP_RAM_BIST_HP_INSTR0_PASS      0x40000000 /* HP instr ram 0 */
1199e689cf4aSJeff Kirsher #define    HP_RAM_BIST_HP_INSTR1_PASS      0x20000000 /* HP instr ram 1 */
1200e689cf4aSJeff Kirsher #define    HP_RAM_BIST_HP_INSTR2_PASS      0x10000000 /* HP instr ram 2 */
1201e689cf4aSJeff Kirsher #define    HP_RAM_BIST_FDBM_AGE0_PASS      0x08000000 /* FDBM aging RAM0 */
1202e689cf4aSJeff Kirsher #define    HP_RAM_BIST_FDBM_AGE1_PASS      0x04000000 /* FDBM aging RAM1 */
1203e689cf4aSJeff Kirsher #define    HP_RAM_BIST_FDBM_FLOWID00_PASS  0x02000000 /* FDBM flowid RAM0
1204e689cf4aSJeff Kirsher 							 bank 0 */
1205e689cf4aSJeff Kirsher #define    HP_RAM_BIST_FDBM_FLOWID10_PASS  0x01000000 /* FDBM flowid RAM1
1206e689cf4aSJeff Kirsher 							 bank 0 */
1207e689cf4aSJeff Kirsher #define    HP_RAM_BIST_FDBM_FLOWID20_PASS  0x00800000 /* FDBM flowid RAM2
1208e689cf4aSJeff Kirsher 							 bank 0 */
1209e689cf4aSJeff Kirsher #define    HP_RAM_BIST_FDBM_FLOWID30_PASS  0x00400000 /* FDBM flowid RAM3
1210e689cf4aSJeff Kirsher 							 bank 0 */
1211e689cf4aSJeff Kirsher #define    HP_RAM_BIST_FDBM_FLOWID01_PASS  0x00200000 /* FDBM flowid RAM0
1212e689cf4aSJeff Kirsher 							 bank 1 */
1213e689cf4aSJeff Kirsher #define    HP_RAM_BIST_FDBM_FLOWID11_PASS  0x00100000 /* FDBM flowid RAM1
1214e689cf4aSJeff Kirsher 							 bank 2 */
1215e689cf4aSJeff Kirsher #define    HP_RAM_BIST_FDBM_FLOWID21_PASS  0x00080000 /* FDBM flowid RAM2
1216e689cf4aSJeff Kirsher 							 bank 1 */
1217e689cf4aSJeff Kirsher #define    HP_RAM_BIST_FDBM_FLOWID31_PASS  0x00040000 /* FDBM flowid RAM3
1218e689cf4aSJeff Kirsher 							 bank 1 */
1219e689cf4aSJeff Kirsher #define    HP_RAM_BIST_FDBM_TCPSEQ_PASS    0x00020000 /* FDBM tcp sequence
1220e689cf4aSJeff Kirsher 							 RAM */
1221e689cf4aSJeff Kirsher #define    HP_RAM_BIST_SUMMARY             0x00000002 /* all BIST tests */
1222e689cf4aSJeff Kirsher #define    HP_RAM_BIST_START               0x00000001 /* start/stop BIST */
1223e689cf4aSJeff Kirsher 
1224e689cf4aSJeff Kirsher 
1225e689cf4aSJeff Kirsher /** MAC registers.  **/
1226e689cf4aSJeff Kirsher /* reset bits are set using a PIO write and self-cleared after the command
1227e689cf4aSJeff Kirsher  * execution has completed.
1228e689cf4aSJeff Kirsher  */
1229e689cf4aSJeff Kirsher #define  REG_MAC_TX_RESET                  0x6000  /* TX MAC software reset
1230e689cf4aSJeff Kirsher 						      command (default: 0x0) */
1231e689cf4aSJeff Kirsher #define  REG_MAC_RX_RESET                  0x6004  /* RX MAC software reset
1232e689cf4aSJeff Kirsher 						      command (default: 0x0) */
1233e689cf4aSJeff Kirsher /* execute a pause flow control frame transmission
1234e689cf4aSJeff Kirsher  DEFAULT: 0x0XXXX */
1235e689cf4aSJeff Kirsher #define  REG_MAC_SEND_PAUSE                0x6008  /* send pause command reg */
1236e689cf4aSJeff Kirsher #define    MAC_SEND_PAUSE_TIME_MASK        0x0000FFFF /* value of pause time
1237e689cf4aSJeff Kirsher 							 to be sent on network
1238e689cf4aSJeff Kirsher 							 in units of slot
1239e689cf4aSJeff Kirsher 							 times */
1240e689cf4aSJeff Kirsher #define    MAC_SEND_PAUSE_SEND             0x00010000 /* send pause flow ctrl
1241e689cf4aSJeff Kirsher 							 frame on network */
1242e689cf4aSJeff Kirsher 
1243e689cf4aSJeff Kirsher /* bit set indicates that event occurred. auto-cleared when status register
1244e689cf4aSJeff Kirsher  * is read and have corresponding mask bits in mask register. events will
1245e689cf4aSJeff Kirsher  * trigger an interrupt if the corresponding mask bit is 0.
1246e689cf4aSJeff Kirsher  * status register default: 0x00000000
1247e689cf4aSJeff Kirsher  * mask register default = 0xFFFFFFFF on reset
1248e689cf4aSJeff Kirsher  */
1249e689cf4aSJeff Kirsher #define  REG_MAC_TX_STATUS                 0x6010  /* TX MAC status reg */
1250e689cf4aSJeff Kirsher #define    MAC_TX_FRAME_XMIT               0x0001  /* successful frame
1251e689cf4aSJeff Kirsher 						      transmision */
1252e689cf4aSJeff Kirsher #define    MAC_TX_UNDERRUN                 0x0002  /* terminated frame
1253e689cf4aSJeff Kirsher 						      transmission due to
1254e689cf4aSJeff Kirsher 						      data starvation in the
1255e689cf4aSJeff Kirsher 						      xmit data path */
1256e689cf4aSJeff Kirsher #define    MAC_TX_MAX_PACKET_ERR           0x0004  /* frame exceeds max allowed
1257e689cf4aSJeff Kirsher 						      length passed to TX MAC
1258e689cf4aSJeff Kirsher 						      by the DMA engine */
1259e689cf4aSJeff Kirsher #define    MAC_TX_COLL_NORMAL              0x0008  /* rollover of the normal
1260e689cf4aSJeff Kirsher 						      collision counter */
1261e689cf4aSJeff Kirsher #define    MAC_TX_COLL_EXCESS              0x0010  /* rollover of the excessive
1262e689cf4aSJeff Kirsher 						      collision counter */
1263e689cf4aSJeff Kirsher #define    MAC_TX_COLL_LATE                0x0020  /* rollover of the late
1264e689cf4aSJeff Kirsher 						      collision counter */
1265e689cf4aSJeff Kirsher #define    MAC_TX_COLL_FIRST               0x0040  /* rollover of the first
1266e689cf4aSJeff Kirsher 						      collision counter */
1267e689cf4aSJeff Kirsher #define    MAC_TX_DEFER_TIMER              0x0080  /* rollover of the defer
1268e689cf4aSJeff Kirsher 						      timer */
1269e689cf4aSJeff Kirsher #define    MAC_TX_PEAK_ATTEMPTS            0x0100  /* rollover of the peak
1270e689cf4aSJeff Kirsher 						      attempts counter */
1271e689cf4aSJeff Kirsher 
1272e689cf4aSJeff Kirsher #define  REG_MAC_RX_STATUS                 0x6014  /* RX MAC status reg */
1273e689cf4aSJeff Kirsher #define    MAC_RX_FRAME_RECV               0x0001  /* successful receipt of
1274e689cf4aSJeff Kirsher 						      a frame */
1275e689cf4aSJeff Kirsher #define    MAC_RX_OVERFLOW                 0x0002  /* dropped frame due to
1276e689cf4aSJeff Kirsher 						      RX FIFO overflow */
1277e689cf4aSJeff Kirsher #define    MAC_RX_FRAME_COUNT              0x0004  /* rollover of receive frame
1278e689cf4aSJeff Kirsher 						      counter */
1279e689cf4aSJeff Kirsher #define    MAC_RX_ALIGN_ERR                0x0008  /* rollover of alignment
1280e689cf4aSJeff Kirsher 						      error counter */
1281e689cf4aSJeff Kirsher #define    MAC_RX_CRC_ERR                  0x0010  /* rollover of crc error
1282e689cf4aSJeff Kirsher 						      counter */
1283e689cf4aSJeff Kirsher #define    MAC_RX_LEN_ERR                  0x0020  /* rollover of length
1284e689cf4aSJeff Kirsher 						      error counter */
1285e689cf4aSJeff Kirsher #define    MAC_RX_VIOL_ERR                 0x0040  /* rollover of code
1286e689cf4aSJeff Kirsher 						      violation error */
1287e689cf4aSJeff Kirsher 
1288e689cf4aSJeff Kirsher /* DEFAULT: 0xXXXX0000 on reset */
1289e689cf4aSJeff Kirsher #define  REG_MAC_CTRL_STATUS               0x6018  /* MAC control status reg */
1290e689cf4aSJeff Kirsher #define    MAC_CTRL_PAUSE_RECEIVED         0x00000001  /* successful
1291e689cf4aSJeff Kirsher 							  reception of a
1292e689cf4aSJeff Kirsher 							  pause control
1293e689cf4aSJeff Kirsher 							  frame */
1294e689cf4aSJeff Kirsher #define    MAC_CTRL_PAUSE_STATE            0x00000002  /* MAC has made a
1295e689cf4aSJeff Kirsher 							  transition from
1296e689cf4aSJeff Kirsher 							  "not paused" to
1297e689cf4aSJeff Kirsher 							  "paused" */
1298e689cf4aSJeff Kirsher #define    MAC_CTRL_NOPAUSE_STATE          0x00000004  /* MAC has made a
1299e689cf4aSJeff Kirsher 							  transition from
1300e689cf4aSJeff Kirsher 							  "paused" to "not
1301e689cf4aSJeff Kirsher 							  paused" */
1302e689cf4aSJeff Kirsher #define    MAC_CTRL_PAUSE_TIME_MASK        0xFFFF0000  /* value of pause time
1303e689cf4aSJeff Kirsher 							  operand that was
1304e689cf4aSJeff Kirsher 							  received in the last
1305e689cf4aSJeff Kirsher 							  pause flow control
1306e689cf4aSJeff Kirsher 							  frame */
1307e689cf4aSJeff Kirsher 
1308e689cf4aSJeff Kirsher /* layout identical to TX MAC[8:0] */
1309e689cf4aSJeff Kirsher #define  REG_MAC_TX_MASK                   0x6020  /* TX MAC mask reg */
1310e689cf4aSJeff Kirsher /* layout identical to RX MAC[6:0] */
1311e689cf4aSJeff Kirsher #define  REG_MAC_RX_MASK                   0x6024  /* RX MAC mask reg */
1312e689cf4aSJeff Kirsher /* layout identical to CTRL MAC[2:0] */
1313e689cf4aSJeff Kirsher #define  REG_MAC_CTRL_MASK                 0x6028  /* MAC control mask reg */
1314e689cf4aSJeff Kirsher 
1315e689cf4aSJeff Kirsher /* to ensure proper operation, CFG_EN must be cleared to 0 and a delay
1316e689cf4aSJeff Kirsher  * imposed before writes to other bits in the TX_MAC_CFG register or any of
1317e689cf4aSJeff Kirsher  * the MAC parameters is performed. delay dependent upon time required to
1318e689cf4aSJeff Kirsher  * transmit a maximum size frame (= MAC_FRAMESIZE_MAX*8/Mbps). e.g.,
1319e689cf4aSJeff Kirsher  * the delay for a 1518-byte frame on a 100Mbps network is 125us.
1320e689cf4aSJeff Kirsher  * alternatively, just poll TX_CFG_EN until it reads back as 0.
1321e689cf4aSJeff Kirsher  * NOTE: on half-duplex 1Gbps, TX_CFG_CARRIER_EXTEND and
1322e689cf4aSJeff Kirsher  * RX_CFG_CARRIER_EXTEND should be set and the SLOT_TIME register should
1323e689cf4aSJeff Kirsher  * be 0x200 (slot time of 512 bytes)
1324e689cf4aSJeff Kirsher  */
1325e689cf4aSJeff Kirsher #define  REG_MAC_TX_CFG                 0x6030  /* TX MAC config reg */
1326e689cf4aSJeff Kirsher #define    MAC_TX_CFG_EN                0x0001  /* enable TX MAC. 0 will
1327e689cf4aSJeff Kirsher 						      force TXMAC state
1328e689cf4aSJeff Kirsher 						      machine to remain in
1329e689cf4aSJeff Kirsher 						      idle state or to
1330e689cf4aSJeff Kirsher 						      transition to idle state
1331e689cf4aSJeff Kirsher 						      on completion of an
1332e689cf4aSJeff Kirsher 						      ongoing packet. */
1333e689cf4aSJeff Kirsher #define    MAC_TX_CFG_IGNORE_CARRIER    0x0002  /* disable CSMA/CD deferral
1334e689cf4aSJeff Kirsher 						   process. set to 1 when
1335e689cf4aSJeff Kirsher 						   full duplex and 0 when
1336e689cf4aSJeff Kirsher 						   half duplex */
1337e689cf4aSJeff Kirsher #define    MAC_TX_CFG_IGNORE_COLL       0x0004  /* disable CSMA/CD backoff
1338e689cf4aSJeff Kirsher 						   algorithm. set to 1 when
1339e689cf4aSJeff Kirsher 						   full duplex and 0 when
1340e689cf4aSJeff Kirsher 						   half duplex */
1341e689cf4aSJeff Kirsher #define    MAC_TX_CFG_IPG_EN            0x0008  /* enable extension of the
1342e689cf4aSJeff Kirsher 						   Rx-to-TX IPG. after
1343e689cf4aSJeff Kirsher 						   receiving a frame, TX
1344e689cf4aSJeff Kirsher 						   MAC will reset its
1345e689cf4aSJeff Kirsher 						   deferral process to
1346e689cf4aSJeff Kirsher 						   carrier sense for the
1347e689cf4aSJeff Kirsher 						   amount of time = IPG0 +
1348e689cf4aSJeff Kirsher 						   IPG1 and commit to
1349e689cf4aSJeff Kirsher 						   transmission for time
1350e689cf4aSJeff Kirsher 						   specified in IPG2. when
1351e689cf4aSJeff Kirsher 						   0 or when xmitting frames
1352e689cf4aSJeff Kirsher 						   back-to-pack (Tx-to-Tx
1353e689cf4aSJeff Kirsher 						   IPG), TX MAC ignores
1354e689cf4aSJeff Kirsher 						   IPG0 and will only use
1355e689cf4aSJeff Kirsher 						   IPG1 for deferral time.
1356e689cf4aSJeff Kirsher 						   IPG2 still used. */
1357e689cf4aSJeff Kirsher #define    MAC_TX_CFG_NEVER_GIVE_UP_EN  0x0010  /* TX MAC will not easily
1358e689cf4aSJeff Kirsher 						   give up on frame
1359e689cf4aSJeff Kirsher 						   xmission. if backoff
1360e689cf4aSJeff Kirsher 						   algorithm reaches the
1361e689cf4aSJeff Kirsher 						   ATTEMPT_LIMIT, it will
1362e689cf4aSJeff Kirsher 						   clear attempts counter
1363e689cf4aSJeff Kirsher 						   and continue trying to
1364e689cf4aSJeff Kirsher 						   send the frame as
1365e689cf4aSJeff Kirsher 						   specified by
1366e689cf4aSJeff Kirsher 						   GIVE_UP_LIM. when 0,
1367e689cf4aSJeff Kirsher 						   TX MAC will execute
1368e689cf4aSJeff Kirsher 						   standard CSMA/CD prot. */
1369e689cf4aSJeff Kirsher #define    MAC_TX_CFG_NEVER_GIVE_UP_LIM 0x0020  /* when set, TX MAC will
1370e689cf4aSJeff Kirsher 						   continue to try to xmit
1371e689cf4aSJeff Kirsher 						   until successful. when
1372e689cf4aSJeff Kirsher 						   0, TX MAC will continue
1373e689cf4aSJeff Kirsher 						   to try xmitting until
1374e689cf4aSJeff Kirsher 						   successful or backoff
1375e689cf4aSJeff Kirsher 						   algorithm reaches
1376e689cf4aSJeff Kirsher 						   ATTEMPT_LIMIT*16 */
1377e689cf4aSJeff Kirsher #define    MAC_TX_CFG_NO_BACKOFF        0x0040  /* modify CSMA/CD to disable
1378e689cf4aSJeff Kirsher 						   backoff algorithm. TX
1379e689cf4aSJeff Kirsher 						   MAC will not back off
1380e689cf4aSJeff Kirsher 						   after a xmission attempt
1381e689cf4aSJeff Kirsher 						   that resulted in a
1382e689cf4aSJeff Kirsher 						   collision. */
1383e689cf4aSJeff Kirsher #define    MAC_TX_CFG_SLOW_DOWN         0x0080  /* modify CSMA/CD so that
1384e689cf4aSJeff Kirsher 						   deferral process is reset
1385e689cf4aSJeff Kirsher 						   in response to carrier
1386e689cf4aSJeff Kirsher 						   sense during the entire
1387e689cf4aSJeff Kirsher 						   duration of IPG. TX MAC
1388e689cf4aSJeff Kirsher 						   will only commit to frame
1389e689cf4aSJeff Kirsher 						   xmission after frame
1390e689cf4aSJeff Kirsher 						   xmission has actually
1391e689cf4aSJeff Kirsher 						   begun. */
1392e689cf4aSJeff Kirsher #define    MAC_TX_CFG_NO_FCS            0x0100  /* TX MAC will not generate
1393e689cf4aSJeff Kirsher 						   CRC for all xmitted
1394e689cf4aSJeff Kirsher 						   packets. when clear, CRC
1395e689cf4aSJeff Kirsher 						   generation is dependent
1396e689cf4aSJeff Kirsher 						   upon NO_CRC bit in the
1397e689cf4aSJeff Kirsher 						   xmit control word from
1398e689cf4aSJeff Kirsher 						   TX DMA */
1399e689cf4aSJeff Kirsher #define    MAC_TX_CFG_CARRIER_EXTEND    0x0200  /* enables xmit part of the
1400e689cf4aSJeff Kirsher 						   carrier extension
1401e689cf4aSJeff Kirsher 						   feature. this allows for
1402e689cf4aSJeff Kirsher 						   longer collision domains
1403e689cf4aSJeff Kirsher 						   by extending the carrier
1404e689cf4aSJeff Kirsher 						   and collision window
1405e689cf4aSJeff Kirsher 						   from the end of FCS until
1406e689cf4aSJeff Kirsher 						   the end of the slot time
1407e689cf4aSJeff Kirsher 						   if necessary. Required
1408e689cf4aSJeff Kirsher 						   for half-duplex at 1Gbps,
1409e689cf4aSJeff Kirsher 						   clear otherwise. */
1410e689cf4aSJeff Kirsher 
1411e689cf4aSJeff Kirsher /* when CRC is not stripped, reassembly packets will not contain the CRC.
1412e689cf4aSJeff Kirsher  * these will be stripped by HRP because it reassembles layer 4 data, and the
1413e689cf4aSJeff Kirsher  * CRC is layer 2. however, non-reassembly packets will still contain the CRC
1414e689cf4aSJeff Kirsher  * when passed to the host. to ensure proper operation, need to wait 3.2ms
1415e689cf4aSJeff Kirsher  * after clearing RX_CFG_EN before writing to any other RX MAC registers
1416e689cf4aSJeff Kirsher  * or other MAC parameters. alternatively, poll RX_CFG_EN until it clears
1417e689cf4aSJeff Kirsher  * to 0. similary, HASH_FILTER_EN and ADDR_FILTER_EN have the same
1418e689cf4aSJeff Kirsher  * restrictions as CFG_EN.
1419e689cf4aSJeff Kirsher  */
1420e689cf4aSJeff Kirsher #define  REG_MAC_RX_CFG                 0x6034  /* RX MAC config reg */
1421e689cf4aSJeff Kirsher #define    MAC_RX_CFG_EN                0x0001  /* enable RX MAC */
1422e689cf4aSJeff Kirsher #define    MAC_RX_CFG_STRIP_PAD         0x0002  /* always program to 0.
1423e689cf4aSJeff Kirsher 						   feature not supported */
1424e689cf4aSJeff Kirsher #define    MAC_RX_CFG_STRIP_FCS         0x0004  /* RX MAC will strip the
1425e689cf4aSJeff Kirsher 						   last 4 bytes of a
1426e689cf4aSJeff Kirsher 						   received frame. */
1427e689cf4aSJeff Kirsher #define    MAC_RX_CFG_PROMISC_EN        0x0008  /* promiscuous mode */
1428e689cf4aSJeff Kirsher #define    MAC_RX_CFG_PROMISC_GROUP_EN  0x0010  /* accept all valid
1429e689cf4aSJeff Kirsher 						   multicast frames (group
1430e689cf4aSJeff Kirsher 						   bit in DA field set) */
1431e689cf4aSJeff Kirsher #define    MAC_RX_CFG_HASH_FILTER_EN    0x0020  /* use hash table to filter
1432e689cf4aSJeff Kirsher 						   multicast addresses */
1433e689cf4aSJeff Kirsher #define    MAC_RX_CFG_ADDR_FILTER_EN    0x0040  /* cause RX MAC to use
1434e689cf4aSJeff Kirsher 						   address filtering regs
1435e689cf4aSJeff Kirsher 						   to filter both unicast
1436e689cf4aSJeff Kirsher 						   and multicast
1437e689cf4aSJeff Kirsher 						   addresses */
1438e689cf4aSJeff Kirsher #define    MAC_RX_CFG_DISABLE_DISCARD   0x0080  /* pass errored frames to
1439e689cf4aSJeff Kirsher 						   RX DMA by setting BAD
1440e689cf4aSJeff Kirsher 						   bit but not Abort bit
1441e689cf4aSJeff Kirsher 						   in the status. CRC,
1442e689cf4aSJeff Kirsher 						   framing, and length errs
1443e689cf4aSJeff Kirsher 						   will not increment
1444e689cf4aSJeff Kirsher 						   error counters. frames
1445e689cf4aSJeff Kirsher 						   which don't match dest
1446e689cf4aSJeff Kirsher 						   addr will be passed up
1447e689cf4aSJeff Kirsher 						   w/ BAD bit set. */
1448e689cf4aSJeff Kirsher #define    MAC_RX_CFG_CARRIER_EXTEND    0x0100  /* enable reception of
1449e689cf4aSJeff Kirsher 						   packet bursts generated
1450e689cf4aSJeff Kirsher 						   by carrier extension
1451e689cf4aSJeff Kirsher 						   with packet bursting
1452e689cf4aSJeff Kirsher 						   senders. only applies
1453e689cf4aSJeff Kirsher 						   to half-duplex 1Gbps */
1454e689cf4aSJeff Kirsher 
1455e689cf4aSJeff Kirsher /* DEFAULT: 0x0 */
1456e689cf4aSJeff Kirsher #define  REG_MAC_CTRL_CFG               0x6038  /* MAC control config reg */
1457e689cf4aSJeff Kirsher #define    MAC_CTRL_CFG_SEND_PAUSE_EN   0x0001  /* respond to requests for
1458e689cf4aSJeff Kirsher 						   sending pause flow ctrl
1459e689cf4aSJeff Kirsher 						   frames */
1460e689cf4aSJeff Kirsher #define    MAC_CTRL_CFG_RECV_PAUSE_EN   0x0002  /* respond to received
1461e689cf4aSJeff Kirsher 						   pause flow ctrl frames */
1462e689cf4aSJeff Kirsher #define    MAC_CTRL_CFG_PASS_CTRL       0x0004  /* pass valid MAC ctrl
1463e689cf4aSJeff Kirsher 						   packets to RX DMA */
1464e689cf4aSJeff Kirsher 
1465e689cf4aSJeff Kirsher /* to ensure proper operation, a global initialization sequence should be
1466e689cf4aSJeff Kirsher  * performed when a loopback config is entered or exited. if programmed after
1467e689cf4aSJeff Kirsher  * a hw or global sw reset, RX/TX MAC software reset and initialization
1468e689cf4aSJeff Kirsher  * should be done to ensure stable clocking.
1469e689cf4aSJeff Kirsher  * DEFAULT: 0x0
1470e689cf4aSJeff Kirsher  */
1471e689cf4aSJeff Kirsher #define  REG_MAC_XIF_CFG                0x603C  /* XIF config reg */
1472e689cf4aSJeff Kirsher #define    MAC_XIF_TX_MII_OUTPUT_EN        0x0001  /* enable output drivers
1473e689cf4aSJeff Kirsher 						      on MII xmit bus */
1474e689cf4aSJeff Kirsher #define    MAC_XIF_MII_INT_LOOPBACK        0x0002  /* loopback GMII xmit data
1475e689cf4aSJeff Kirsher 						      path to GMII recv data
1476e689cf4aSJeff Kirsher 						      path. phy mode register
1477e689cf4aSJeff Kirsher 						      clock selection must be
1478e689cf4aSJeff Kirsher 						      set to GMII mode and
1479e689cf4aSJeff Kirsher 						      GMII_MODE should be set
1480e689cf4aSJeff Kirsher 						      to 1. in loopback mode,
1481e689cf4aSJeff Kirsher 						      REFCLK will drive the
1482e689cf4aSJeff Kirsher 						      entire mac core. 0 for
1483e689cf4aSJeff Kirsher 						      normal operation. */
1484e689cf4aSJeff Kirsher #define    MAC_XIF_DISABLE_ECHO            0x0004  /* disables receive data
1485e689cf4aSJeff Kirsher 						      path during packet
1486e689cf4aSJeff Kirsher 						      xmission. clear to 0
1487e689cf4aSJeff Kirsher 						      in any full duplex mode,
1488e689cf4aSJeff Kirsher 						      in any loopback mode,
1489e689cf4aSJeff Kirsher 						      or in half-duplex SERDES
1490e689cf4aSJeff Kirsher 						      or SLINK modes. set when
1491e689cf4aSJeff Kirsher 						      in half-duplex when
1492e689cf4aSJeff Kirsher 						      using external phy. */
1493e689cf4aSJeff Kirsher #define    MAC_XIF_GMII_MODE               0x0008  /* MAC operates with GMII
1494e689cf4aSJeff Kirsher 						      clocks and datapath */
1495e689cf4aSJeff Kirsher #define    MAC_XIF_MII_BUFFER_OUTPUT_EN    0x0010  /* MII_BUF_EN pin. enable
1496e689cf4aSJeff Kirsher 						      external tristate buffer
1497e689cf4aSJeff Kirsher 						      on the MII receive
1498e689cf4aSJeff Kirsher 						      bus. */
1499e689cf4aSJeff Kirsher #define    MAC_XIF_LINK_LED                0x0020  /* LINKLED# active (low) */
1500e689cf4aSJeff Kirsher #define    MAC_XIF_FDPLX_LED               0x0040  /* FDPLXLED# active (low) */
1501e689cf4aSJeff Kirsher 
1502e689cf4aSJeff Kirsher #define  REG_MAC_IPG0                      0x6040  /* inter-packet gap0 reg.
1503e689cf4aSJeff Kirsher 						      recommended: 0x00 */
1504e689cf4aSJeff Kirsher #define  REG_MAC_IPG1                      0x6044  /* inter-packet gap1 reg
1505e689cf4aSJeff Kirsher 						      recommended: 0x08 */
1506e689cf4aSJeff Kirsher #define  REG_MAC_IPG2                      0x6048  /* inter-packet gap2 reg
1507e689cf4aSJeff Kirsher 						      recommended: 0x04 */
1508e689cf4aSJeff Kirsher #define  REG_MAC_SLOT_TIME                 0x604C  /* slot time reg
1509e689cf4aSJeff Kirsher 						      recommended: 0x40 */
1510e689cf4aSJeff Kirsher #define  REG_MAC_FRAMESIZE_MIN             0x6050  /* min frame size reg
1511e689cf4aSJeff Kirsher 						      recommended: 0x40 */
1512e689cf4aSJeff Kirsher 
1513e689cf4aSJeff Kirsher /* FRAMESIZE_MAX holds both the max frame size as well as the max burst size.
1514e689cf4aSJeff Kirsher  * recommended value:  0x2000.05EE
1515e689cf4aSJeff Kirsher  */
1516e689cf4aSJeff Kirsher #define  REG_MAC_FRAMESIZE_MAX             0x6054  /* max frame size reg */
1517e689cf4aSJeff Kirsher #define    MAC_FRAMESIZE_MAX_BURST_MASK    0x3FFF0000 /* max burst size */
1518e689cf4aSJeff Kirsher #define    MAC_FRAMESIZE_MAX_BURST_SHIFT   16
1519e689cf4aSJeff Kirsher #define    MAC_FRAMESIZE_MAX_FRAME_MASK    0x00007FFF /* max frame size */
1520e689cf4aSJeff Kirsher #define    MAC_FRAMESIZE_MAX_FRAME_SHIFT   0
1521e689cf4aSJeff Kirsher #define  REG_MAC_PA_SIZE                   0x6058  /* PA size reg. number of
1522e689cf4aSJeff Kirsher 						      preamble bytes that the
1523e689cf4aSJeff Kirsher 						      TX MAC will xmit at the
1524e689cf4aSJeff Kirsher 						      beginning of each frame
1525e689cf4aSJeff Kirsher 						      value should be 2 or
1526e689cf4aSJeff Kirsher 						      greater. recommended
1527e689cf4aSJeff Kirsher 						      value: 0x07 */
1528e689cf4aSJeff Kirsher #define  REG_MAC_JAM_SIZE                  0x605C  /* jam size reg. duration
1529e689cf4aSJeff Kirsher 						      of jam in units of media
1530e689cf4aSJeff Kirsher 						      byte time. recommended
1531e689cf4aSJeff Kirsher 						      value: 0x04 */
1532e689cf4aSJeff Kirsher #define  REG_MAC_ATTEMPT_LIMIT             0x6060  /* attempt limit reg. #
1533e689cf4aSJeff Kirsher 						      of attempts TX MAC will
1534e689cf4aSJeff Kirsher 						      make to xmit a frame
1535e689cf4aSJeff Kirsher 						      before it resets its
1536e689cf4aSJeff Kirsher 						      attempts counter. after
1537e689cf4aSJeff Kirsher 						      the limit has been
1538e689cf4aSJeff Kirsher 						      reached, TX MAC may or
1539e689cf4aSJeff Kirsher 						      may not drop the frame
1540e689cf4aSJeff Kirsher 						      dependent upon value
1541e689cf4aSJeff Kirsher 						      in TX_MAC_CFG.
1542e689cf4aSJeff Kirsher 						      recommended
1543e689cf4aSJeff Kirsher 						      value: 0x10 */
1544e689cf4aSJeff Kirsher #define  REG_MAC_CTRL_TYPE                 0x6064  /* MAC control type reg.
1545e689cf4aSJeff Kirsher 						      type field of a MAC
1546e689cf4aSJeff Kirsher 						      ctrl frame. recommended
1547e689cf4aSJeff Kirsher 						      value: 0x8808 */
1548e689cf4aSJeff Kirsher 
1549e689cf4aSJeff Kirsher /* mac address registers: 0 - 44, 0x6080 - 0x6130, 4 8-bit bytes.
1550e689cf4aSJeff Kirsher  * register           contains                   comparison
1551e689cf4aSJeff Kirsher  *    0        16 MSB of primary MAC addr        [47:32] of DA field
1552e689cf4aSJeff Kirsher  *    1        16 middle bits ""                 [31:16] of DA field
1553e689cf4aSJeff Kirsher  *    2        16 LSB ""                         [15:0] of DA field
1554e689cf4aSJeff Kirsher  *    3*x      16MSB of alt MAC addr 1-15        [47:32] of DA field
1555e689cf4aSJeff Kirsher  *    4*x      16 middle bits ""                 [31:16]
1556e689cf4aSJeff Kirsher  *    5*x      16 LSB ""                         [15:0]
1557e689cf4aSJeff Kirsher  *    42       16 MSB of MAC CTRL addr           [47:32] of DA.
1558e689cf4aSJeff Kirsher  *    43       16 middle bits ""                 [31:16]
1559e689cf4aSJeff Kirsher  *    44       16 LSB ""                         [15:0]
1560e689cf4aSJeff Kirsher  *    MAC CTRL addr must be the reserved multicast addr for MAC CTRL frames.
1561e689cf4aSJeff Kirsher  *    if there is a match, MAC will set the bit for alternative address
1562e689cf4aSJeff Kirsher  *    filter pass [15]
1563e689cf4aSJeff Kirsher 
1564e689cf4aSJeff Kirsher  *    here is the map of registers given MAC address notation: a:b:c:d:e:f
1565e689cf4aSJeff Kirsher  *                     ab             cd             ef
1566e689cf4aSJeff Kirsher  *    primary addr     reg 2          reg 1          reg 0
1567e689cf4aSJeff Kirsher  *    alt addr 1       reg 5          reg 4          reg 3
1568e689cf4aSJeff Kirsher  *    alt addr x       reg 5*x        reg 4*x        reg 3*x
1569e689cf4aSJeff Kirsher  *    ctrl addr        reg 44         reg 43         reg 42
1570e689cf4aSJeff Kirsher  */
1571e689cf4aSJeff Kirsher #define  REG_MAC_ADDR0                     0x6080  /* MAC address 0 reg */
1572e689cf4aSJeff Kirsher #define  REG_MAC_ADDRN(x)                  (REG_MAC_ADDR0 + (x)*4)
1573e689cf4aSJeff Kirsher #define  REG_MAC_ADDR_FILTER0              0x614C  /* address filter 0 reg
1574e689cf4aSJeff Kirsher 						      [47:32] */
1575e689cf4aSJeff Kirsher #define  REG_MAC_ADDR_FILTER1              0x6150  /* address filter 1 reg
1576e689cf4aSJeff Kirsher 						      [31:16] */
1577e689cf4aSJeff Kirsher #define  REG_MAC_ADDR_FILTER2              0x6154  /* address filter 2 reg
1578e689cf4aSJeff Kirsher 						      [15:0] */
1579e689cf4aSJeff Kirsher #define  REG_MAC_ADDR_FILTER2_1_MASK       0x6158  /* address filter 2 and 1
1580e689cf4aSJeff Kirsher 						      mask reg. 8-bit reg
1581e689cf4aSJeff Kirsher 						      contains nibble mask for
1582e689cf4aSJeff Kirsher 						      reg 2 and 1. */
1583e689cf4aSJeff Kirsher #define  REG_MAC_ADDR_FILTER0_MASK         0x615C  /* address filter 0 mask
1584e689cf4aSJeff Kirsher 						      reg */
1585e689cf4aSJeff Kirsher 
1586e689cf4aSJeff Kirsher /* hash table registers: 0 - 15, 0x6160 - 0x619C, 4 8-bit bytes
1587e689cf4aSJeff Kirsher  * 16-bit registers contain bits of the hash table.
1588e689cf4aSJeff Kirsher  * reg x  -> [16*(15 - x) + 15 : 16*(15 - x)].
1589e689cf4aSJeff Kirsher  * e.g., 15 -> [15:0], 0 -> [255:240]
1590e689cf4aSJeff Kirsher  */
1591e689cf4aSJeff Kirsher #define  REG_MAC_HASH_TABLE0               0x6160  /* hash table 0 reg */
1592e689cf4aSJeff Kirsher #define  REG_MAC_HASH_TABLEN(x)            (REG_MAC_HASH_TABLE0 + (x)*4)
1593e689cf4aSJeff Kirsher 
1594e689cf4aSJeff Kirsher /* statistics registers. these registers generate an interrupt on
1595e689cf4aSJeff Kirsher  * overflow. recommended initialization: 0x0000. most are 16-bits except
1596e689cf4aSJeff Kirsher  * for PEAK_ATTEMPTS register which is 8 bits.
1597e689cf4aSJeff Kirsher  */
1598e689cf4aSJeff Kirsher #define  REG_MAC_COLL_NORMAL               0x61A0 /* normal collision
1599e689cf4aSJeff Kirsher 						     counter. */
1600e689cf4aSJeff Kirsher #define  REG_MAC_COLL_FIRST                0x61A4 /* first attempt
1601e689cf4aSJeff Kirsher 						     successful collision
1602e689cf4aSJeff Kirsher 						     counter */
1603e689cf4aSJeff Kirsher #define  REG_MAC_COLL_EXCESS               0x61A8 /* excessive collision
1604e689cf4aSJeff Kirsher 						     counter */
1605e689cf4aSJeff Kirsher #define  REG_MAC_COLL_LATE                 0x61AC /* late collision counter */
1606e689cf4aSJeff Kirsher #define  REG_MAC_TIMER_DEFER               0x61B0 /* defer timer. time base
1607e689cf4aSJeff Kirsher 						     is the media byte
1608e689cf4aSJeff Kirsher 						     clock/256 */
1609e689cf4aSJeff Kirsher #define  REG_MAC_ATTEMPTS_PEAK             0x61B4 /* peak attempts reg */
1610e689cf4aSJeff Kirsher #define  REG_MAC_RECV_FRAME                0x61B8 /* receive frame counter */
1611e689cf4aSJeff Kirsher #define  REG_MAC_LEN_ERR                   0x61BC /* length error counter */
1612e689cf4aSJeff Kirsher #define  REG_MAC_ALIGN_ERR                 0x61C0 /* alignment error counter */
1613e689cf4aSJeff Kirsher #define  REG_MAC_FCS_ERR                   0x61C4 /* FCS error counter */
1614e689cf4aSJeff Kirsher #define  REG_MAC_RX_CODE_ERR               0x61C8 /* RX code violation
1615e689cf4aSJeff Kirsher 						     error counter */
1616e689cf4aSJeff Kirsher 
1617e689cf4aSJeff Kirsher /* misc registers */
1618e689cf4aSJeff Kirsher #define  REG_MAC_RANDOM_SEED               0x61CC /* random number seed reg.
1619e689cf4aSJeff Kirsher 						   10-bit register used as a
1620e689cf4aSJeff Kirsher 						   seed  for the random number
1621e689cf4aSJeff Kirsher 						   generator for the CSMA/CD
1622e689cf4aSJeff Kirsher 						   backoff algorithm. only
1623e689cf4aSJeff Kirsher 						   programmed after power-on
1624e689cf4aSJeff Kirsher 						   reset and should be a
1625e689cf4aSJeff Kirsher 						   random value which has a
1626e689cf4aSJeff Kirsher 						   high likelihood of being
1627e689cf4aSJeff Kirsher 						   unique for each MAC
1628e689cf4aSJeff Kirsher 						   attached to a network
1629e689cf4aSJeff Kirsher 						   segment (e.g., 10 LSB of
1630e689cf4aSJeff Kirsher 						   MAC address) */
1631e689cf4aSJeff Kirsher 
1632e689cf4aSJeff Kirsher /* ASUN: there's a PAUSE_TIMER (ro) described, but it's not in the address
1633e689cf4aSJeff Kirsher  *       map
1634e689cf4aSJeff Kirsher  */
1635e689cf4aSJeff Kirsher 
1636e689cf4aSJeff Kirsher /* 27-bit register has the current state for key state machines in the MAC */
1637e689cf4aSJeff Kirsher #define  REG_MAC_STATE_MACHINE             0x61D0 /* (ro) state machine reg */
1638e689cf4aSJeff Kirsher #define    MAC_SM_RLM_MASK                 0x07800000
1639e689cf4aSJeff Kirsher #define    MAC_SM_RLM_SHIFT                23
1640e689cf4aSJeff Kirsher #define    MAC_SM_RX_FC_MASK               0x00700000
1641e689cf4aSJeff Kirsher #define    MAC_SM_RX_FC_SHIFT              20
1642e689cf4aSJeff Kirsher #define    MAC_SM_TLM_MASK                 0x000F0000
1643e689cf4aSJeff Kirsher #define    MAC_SM_TLM_SHIFT                16
1644e689cf4aSJeff Kirsher #define    MAC_SM_ENCAP_SM_MASK            0x0000F000
1645e689cf4aSJeff Kirsher #define    MAC_SM_ENCAP_SM_SHIFT           12
1646e689cf4aSJeff Kirsher #define    MAC_SM_TX_REQ_MASK              0x00000C00
1647e689cf4aSJeff Kirsher #define    MAC_SM_TX_REQ_SHIFT             10
1648e689cf4aSJeff Kirsher #define    MAC_SM_TX_FC_MASK               0x000003C0
1649e689cf4aSJeff Kirsher #define    MAC_SM_TX_FC_SHIFT              6
1650e689cf4aSJeff Kirsher #define    MAC_SM_FIFO_WRITE_SEL_MASK      0x00000038
1651e689cf4aSJeff Kirsher #define    MAC_SM_FIFO_WRITE_SEL_SHIFT     3
1652e689cf4aSJeff Kirsher #define    MAC_SM_TX_FIFO_EMPTY_MASK       0x00000007
1653e689cf4aSJeff Kirsher #define    MAC_SM_TX_FIFO_EMPTY_SHIFT      0
1654e689cf4aSJeff Kirsher 
1655e689cf4aSJeff Kirsher /** MIF registers. the MIF can be programmed in either bit-bang or
1656e689cf4aSJeff Kirsher  *  frame mode.
1657e689cf4aSJeff Kirsher  **/
1658e689cf4aSJeff Kirsher #define  REG_MIF_BIT_BANG_CLOCK            0x6200 /* MIF bit-bang clock.
1659e689cf4aSJeff Kirsher 						   1 -> 0 will generate a
1660e689cf4aSJeff Kirsher 						   rising edge. 0 -> 1 will
1661e689cf4aSJeff Kirsher 						   generate a falling edge. */
1662e689cf4aSJeff Kirsher #define  REG_MIF_BIT_BANG_DATA             0x6204 /* MIF bit-bang data. 1-bit
1663e689cf4aSJeff Kirsher 						     register generates data */
1664e689cf4aSJeff Kirsher #define  REG_MIF_BIT_BANG_OUTPUT_EN        0x6208 /* MIF bit-bang output
1665e689cf4aSJeff Kirsher 						     enable. enable when
1666e689cf4aSJeff Kirsher 						     xmitting data from MIF to
1667e689cf4aSJeff Kirsher 						     transceiver. */
1668e689cf4aSJeff Kirsher 
1669e689cf4aSJeff Kirsher /* 32-bit register serves as an instruction register when the MIF is
1670e689cf4aSJeff Kirsher  * programmed in frame mode. load this register w/ a valid instruction
1671e689cf4aSJeff Kirsher  * (as per IEEE 802.3u MII spec). poll this register to check for instruction
1672e689cf4aSJeff Kirsher  * execution completion. during a read operation, this register will also
1673e689cf4aSJeff Kirsher  * contain the 16-bit data returned by the tranceiver. unless specified
1674e689cf4aSJeff Kirsher  * otherwise, fields are considered "don't care" when polling for
1675e689cf4aSJeff Kirsher  * completion.
1676e689cf4aSJeff Kirsher  */
1677e689cf4aSJeff Kirsher #define  REG_MIF_FRAME                     0x620C /* MIF frame/output reg */
1678e689cf4aSJeff Kirsher #define    MIF_FRAME_START_MASK            0xC0000000 /* start of frame.
1679e689cf4aSJeff Kirsher 							 load w/ 01 when
1680e689cf4aSJeff Kirsher 							 issuing an instr */
1681e689cf4aSJeff Kirsher #define    MIF_FRAME_ST                    0x40000000 /* STart of frame */
1682e689cf4aSJeff Kirsher #define    MIF_FRAME_OPCODE_MASK           0x30000000 /* opcode. 01 for a
1683e689cf4aSJeff Kirsher 							 write. 10 for a
1684e689cf4aSJeff Kirsher 							 read */
1685e689cf4aSJeff Kirsher #define    MIF_FRAME_OP_READ               0x20000000 /* read OPcode */
1686e689cf4aSJeff Kirsher #define    MIF_FRAME_OP_WRITE              0x10000000 /* write OPcode */
1687e689cf4aSJeff Kirsher #define    MIF_FRAME_PHY_ADDR_MASK         0x0F800000 /* phy address. when
1688e689cf4aSJeff Kirsher 							 issuing an instr,
1689e689cf4aSJeff Kirsher 							 this field should be
1690e689cf4aSJeff Kirsher 							 loaded w/ the XCVR
1691e689cf4aSJeff Kirsher 							 addr */
1692e689cf4aSJeff Kirsher #define    MIF_FRAME_PHY_ADDR_SHIFT        23
1693e689cf4aSJeff Kirsher #define    MIF_FRAME_REG_ADDR_MASK         0x007C0000 /* register address.
1694e689cf4aSJeff Kirsher 							 when issuing an instr,
1695e689cf4aSJeff Kirsher 							 addr of register
1696e689cf4aSJeff Kirsher 							 to be read/written */
1697e689cf4aSJeff Kirsher #define    MIF_FRAME_REG_ADDR_SHIFT        18
1698e689cf4aSJeff Kirsher #define    MIF_FRAME_TURN_AROUND_MSB       0x00020000 /* turn around, MSB.
1699e689cf4aSJeff Kirsher 							 when issuing an instr,
1700e689cf4aSJeff Kirsher 							 set this bit to 1 */
1701e689cf4aSJeff Kirsher #define    MIF_FRAME_TURN_AROUND_LSB       0x00010000 /* turn around, LSB.
1702e689cf4aSJeff Kirsher 							 when issuing an instr,
1703e689cf4aSJeff Kirsher 							 set this bit to 0.
1704e689cf4aSJeff Kirsher 							 when polling for
1705e689cf4aSJeff Kirsher 							 completion, 1 means
1706e689cf4aSJeff Kirsher 							 that instr execution
1707e689cf4aSJeff Kirsher 							 has been completed */
1708e689cf4aSJeff Kirsher #define    MIF_FRAME_DATA_MASK             0x0000FFFF /* instruction payload
1709e689cf4aSJeff Kirsher 							 load with 16-bit data
1710e689cf4aSJeff Kirsher 							 to be written in
1711e689cf4aSJeff Kirsher 							 transceiver reg for a
1712e689cf4aSJeff Kirsher 							 write. doesn't matter
1713e689cf4aSJeff Kirsher 							 in a read. when
1714e689cf4aSJeff Kirsher 							 polling for
1715e689cf4aSJeff Kirsher 							 completion, field is
1716e689cf4aSJeff Kirsher 							 "don't care" for write
1717e689cf4aSJeff Kirsher 							 and 16-bit data
1718e689cf4aSJeff Kirsher 							 returned by the
1719e689cf4aSJeff Kirsher 							 transceiver for a
1720e689cf4aSJeff Kirsher 							 read (if valid bit
1721e689cf4aSJeff Kirsher 							 is set) */
1722e689cf4aSJeff Kirsher #define  REG_MIF_CFG                    0x6210 /* MIF config reg */
1723e689cf4aSJeff Kirsher #define    MIF_CFG_PHY_SELECT           0x0001 /* 1 -> select MDIO_1
1724e689cf4aSJeff Kirsher 						  0 -> select MDIO_0 */
1725e689cf4aSJeff Kirsher #define    MIF_CFG_POLL_EN              0x0002 /* enable polling
1726e689cf4aSJeff Kirsher 						  mechanism. if set,
1727e689cf4aSJeff Kirsher 						  BB_MODE should be 0 */
1728e689cf4aSJeff Kirsher #define    MIF_CFG_BB_MODE              0x0004 /* 1 -> bit-bang mode
1729e689cf4aSJeff Kirsher 						  0 -> frame mode */
1730e689cf4aSJeff Kirsher #define    MIF_CFG_POLL_REG_MASK        0x00F8 /* register address to be
1731e689cf4aSJeff Kirsher 						  used by polling mode.
1732e689cf4aSJeff Kirsher 						  only meaningful if POLL_EN
1733e689cf4aSJeff Kirsher 						  is set to 1 */
1734e689cf4aSJeff Kirsher #define    MIF_CFG_POLL_REG_SHIFT       3
1735e689cf4aSJeff Kirsher #define    MIF_CFG_MDIO_0               0x0100 /* (ro) dual purpose.
1736e689cf4aSJeff Kirsher 						  when MDIO_0 is idle,
1737e689cf4aSJeff Kirsher 						  1 -> tranceiver is
1738e689cf4aSJeff Kirsher 						  connected to MDIO_0.
1739e689cf4aSJeff Kirsher 						  when MIF is communicating
1740e689cf4aSJeff Kirsher 						  w/ MDIO_0 in bit-bang
1741e689cf4aSJeff Kirsher 						  mode, this bit indicates
1742e689cf4aSJeff Kirsher 						  the incoming bit stream
1743e689cf4aSJeff Kirsher 						  during a read op */
1744e689cf4aSJeff Kirsher #define    MIF_CFG_MDIO_1               0x0200 /* (ro) dual purpose.
1745e689cf4aSJeff Kirsher 						  when MDIO_1 is idle,
1746e689cf4aSJeff Kirsher 						  1 -> transceiver is
1747e689cf4aSJeff Kirsher 						  connected to MDIO_1.
1748e689cf4aSJeff Kirsher 						  when MIF is communicating
1749e689cf4aSJeff Kirsher 						  w/ MDIO_1 in bit-bang
1750e689cf4aSJeff Kirsher 						  mode, this bit indicates
1751e689cf4aSJeff Kirsher 						  the incoming bit stream
1752e689cf4aSJeff Kirsher 						  during a read op */
1753e689cf4aSJeff Kirsher #define    MIF_CFG_POLL_PHY_MASK        0x7C00 /* tranceiver address to
1754e689cf4aSJeff Kirsher 						  be polled */
1755e689cf4aSJeff Kirsher #define    MIF_CFG_POLL_PHY_SHIFT       10
1756e689cf4aSJeff Kirsher 
1757e689cf4aSJeff Kirsher /* 16-bit register used to determine which bits in the POLL_STATUS portion of
1758e689cf4aSJeff Kirsher  * the MIF_STATUS register will cause an interrupt. if a mask bit is 0,
1759e689cf4aSJeff Kirsher  * corresponding bit of the POLL_STATUS will generate a MIF interrupt when
1760e689cf4aSJeff Kirsher  * set. DEFAULT: 0xFFFF
1761e689cf4aSJeff Kirsher  */
1762e689cf4aSJeff Kirsher #define  REG_MIF_MASK                      0x6214 /* MIF mask reg */
1763e689cf4aSJeff Kirsher 
1764e689cf4aSJeff Kirsher /* 32-bit register used when in poll mode. auto-cleared after being read */
1765e689cf4aSJeff Kirsher #define  REG_MIF_STATUS                    0x6218 /* MIF status reg */
1766e689cf4aSJeff Kirsher #define    MIF_STATUS_POLL_DATA_MASK       0xFFFF0000 /* poll data contains
1767e689cf4aSJeff Kirsher 							 the "latest image"
1768e689cf4aSJeff Kirsher 							 update of the XCVR
1769e689cf4aSJeff Kirsher 							 reg being read */
1770e689cf4aSJeff Kirsher #define    MIF_STATUS_POLL_DATA_SHIFT      16
1771e689cf4aSJeff Kirsher #define    MIF_STATUS_POLL_STATUS_MASK     0x0000FFFF /* poll status indicates
1772e689cf4aSJeff Kirsher 							 which bits in the
1773e689cf4aSJeff Kirsher 							 POLL_DATA field have
1774e689cf4aSJeff Kirsher 							 changed since the
1775e689cf4aSJeff Kirsher 							 MIF_STATUS reg was
1776e689cf4aSJeff Kirsher 							 last read */
1777e689cf4aSJeff Kirsher #define    MIF_STATUS_POLL_STATUS_SHIFT    0
1778e689cf4aSJeff Kirsher 
1779e689cf4aSJeff Kirsher /* 7-bit register has current state for all state machines in the MIF */
1780e689cf4aSJeff Kirsher #define  REG_MIF_STATE_MACHINE             0x621C /* MIF state machine reg */
1781e689cf4aSJeff Kirsher #define    MIF_SM_CONTROL_MASK             0x07   /* control state machine
1782e689cf4aSJeff Kirsher 						     state */
1783e689cf4aSJeff Kirsher #define    MIF_SM_EXECUTION_MASK           0x60   /* execution state machine
1784e689cf4aSJeff Kirsher 						     state */
1785e689cf4aSJeff Kirsher 
1786e689cf4aSJeff Kirsher /** PCS/Serialink. the following registers are equivalent to the standard
1787e689cf4aSJeff Kirsher  *  MII management registers except that they're directly mapped in
1788e689cf4aSJeff Kirsher  *  Cassini's register space.
1789e689cf4aSJeff Kirsher  **/
1790e689cf4aSJeff Kirsher 
1791e689cf4aSJeff Kirsher /* the auto-negotiation enable bit should be programmed the same at
1792e689cf4aSJeff Kirsher  * the link partner as in the local device to enable auto-negotiation to
1793e689cf4aSJeff Kirsher  * complete. when that bit is reprogrammed, auto-neg/manual config is
1794e689cf4aSJeff Kirsher  * restarted automatically.
1795e689cf4aSJeff Kirsher  * DEFAULT: 0x1040
1796e689cf4aSJeff Kirsher  */
1797e689cf4aSJeff Kirsher #define  REG_PCS_MII_CTRL                  0x9000 /* PCS MII control reg */
1798e689cf4aSJeff Kirsher #define    PCS_MII_CTRL_1000_SEL           0x0040 /* reads 1. ignored on
1799e689cf4aSJeff Kirsher 						     writes */
1800e689cf4aSJeff Kirsher #define    PCS_MII_CTRL_COLLISION_TEST     0x0080 /* COL signal at the PCS
1801e689cf4aSJeff Kirsher 						     to MAC interface is
1802e689cf4aSJeff Kirsher 						     activated regardless
1803e689cf4aSJeff Kirsher 						     of activity */
1804e689cf4aSJeff Kirsher #define    PCS_MII_CTRL_DUPLEX             0x0100 /* forced 0x0. PCS
1805e689cf4aSJeff Kirsher 						     behaviour same for
1806e689cf4aSJeff Kirsher 						     half and full dplx */
1807e689cf4aSJeff Kirsher #define    PCS_MII_RESTART_AUTONEG         0x0200 /* self clearing.
1808e689cf4aSJeff Kirsher 						     restart auto-
1809e689cf4aSJeff Kirsher 						     negotiation */
1810e689cf4aSJeff Kirsher #define    PCS_MII_ISOLATE                 0x0400 /* read as 0. ignored
1811e689cf4aSJeff Kirsher 						     on writes */
1812e689cf4aSJeff Kirsher #define    PCS_MII_POWER_DOWN              0x0800 /* read as 0. ignored
1813e689cf4aSJeff Kirsher 						     on writes */
1814e689cf4aSJeff Kirsher #define    PCS_MII_AUTONEG_EN              0x1000 /* default 1. PCS goes
1815e689cf4aSJeff Kirsher 						     through automatic
1816e689cf4aSJeff Kirsher 						     link config before it
1817e689cf4aSJeff Kirsher 						     can be used. when 0,
1818e689cf4aSJeff Kirsher 						     link can be used
1819e689cf4aSJeff Kirsher 						     w/out any link config
1820e689cf4aSJeff Kirsher 						     phase */
1821e689cf4aSJeff Kirsher #define    PCS_MII_10_100_SEL              0x2000 /* read as 0. ignored on
1822e689cf4aSJeff Kirsher 						     writes */
1823e689cf4aSJeff Kirsher #define    PCS_MII_RESET                   0x8000 /* reset PCS. self-clears
1824e689cf4aSJeff Kirsher 						     when done */
1825e689cf4aSJeff Kirsher 
1826e689cf4aSJeff Kirsher /* DEFAULT: 0x0108 */
1827e689cf4aSJeff Kirsher #define  REG_PCS_MII_STATUS                0x9004 /* PCS MII status reg */
1828e689cf4aSJeff Kirsher #define    PCS_MII_STATUS_EXTEND_CAP       0x0001 /* reads 0 */
1829e689cf4aSJeff Kirsher #define    PCS_MII_STATUS_JABBER_DETECT    0x0002 /* reads 0 */
1830e689cf4aSJeff Kirsher #define    PCS_MII_STATUS_LINK_STATUS      0x0004 /* 1 -> link up.
1831e689cf4aSJeff Kirsher 						     0 -> link down. 0 is
1832e689cf4aSJeff Kirsher 						     latched so that 0 is
1833e689cf4aSJeff Kirsher 						     kept until read. read
1834e689cf4aSJeff Kirsher 						     2x to determine if the
1835e689cf4aSJeff Kirsher 						     link has gone up again */
1836e689cf4aSJeff Kirsher #define    PCS_MII_STATUS_AUTONEG_ABLE     0x0008 /* reads 1 (able to perform
1837e689cf4aSJeff Kirsher 						     auto-neg) */
1838e689cf4aSJeff Kirsher #define    PCS_MII_STATUS_REMOTE_FAULT     0x0010 /* 1 -> remote fault detected
1839e689cf4aSJeff Kirsher 						     from received link code
1840e689cf4aSJeff Kirsher 						     word. only valid after
1841e689cf4aSJeff Kirsher 						     auto-neg completed */
1842e689cf4aSJeff Kirsher #define    PCS_MII_STATUS_AUTONEG_COMP     0x0020 /* 1 -> auto-negotiation
1843e689cf4aSJeff Kirsher 						          completed
1844e689cf4aSJeff Kirsher 						     0 -> auto-negotiation not
1845e689cf4aSJeff Kirsher 						     completed */
1846e689cf4aSJeff Kirsher #define    PCS_MII_STATUS_EXTEND_STATUS    0x0100 /* reads as 1. used as an
1847e689cf4aSJeff Kirsher 						     indication that this is
1848e689cf4aSJeff Kirsher 						     a 1000 Base-X PHY. writes
1849e689cf4aSJeff Kirsher 						     to it are ignored */
1850e689cf4aSJeff Kirsher 
1851e689cf4aSJeff Kirsher /* used during auto-negotiation.
1852e689cf4aSJeff Kirsher  * DEFAULT: 0x00E0
1853e689cf4aSJeff Kirsher  */
1854e689cf4aSJeff Kirsher #define  REG_PCS_MII_ADVERT                0x9008 /* PCS MII advertisement
1855e689cf4aSJeff Kirsher 						     reg */
1856e689cf4aSJeff Kirsher #define    PCS_MII_ADVERT_FD               0x0020  /* advertise full duplex
1857e689cf4aSJeff Kirsher 						      1000 Base-X */
1858e689cf4aSJeff Kirsher #define    PCS_MII_ADVERT_HD               0x0040  /* advertise half-duplex
1859e689cf4aSJeff Kirsher 						      1000 Base-X */
1860e689cf4aSJeff Kirsher #define    PCS_MII_ADVERT_SYM_PAUSE        0x0080  /* advertise PAUSE
1861e689cf4aSJeff Kirsher 						      symmetric capability */
1862e689cf4aSJeff Kirsher #define    PCS_MII_ADVERT_ASYM_PAUSE       0x0100  /* advertises PAUSE
1863e689cf4aSJeff Kirsher 						      asymmetric capability */
1864e689cf4aSJeff Kirsher #define    PCS_MII_ADVERT_RF_MASK          0x3000 /* remote fault. write bit13
1865e689cf4aSJeff Kirsher 						     to optionally indicate to
1866e689cf4aSJeff Kirsher 						     link partner that chip is
1867e689cf4aSJeff Kirsher 						     going off-line. bit12 will
1868e689cf4aSJeff Kirsher 						     get set when signal
1869e689cf4aSJeff Kirsher 						     detect == FAIL and will
1870e689cf4aSJeff Kirsher 						     remain set until
1871e689cf4aSJeff Kirsher 						     successful negotiation */
1872e689cf4aSJeff Kirsher #define    PCS_MII_ADVERT_ACK              0x4000 /* (ro) */
1873e689cf4aSJeff Kirsher #define    PCS_MII_ADVERT_NEXT_PAGE        0x8000 /* (ro) forced 0x0 */
1874e689cf4aSJeff Kirsher 
1875e689cf4aSJeff Kirsher /* contents updated as a result of autonegotiation. layout and definitions
1876e689cf4aSJeff Kirsher  * identical to PCS_MII_ADVERT
1877e689cf4aSJeff Kirsher  */
1878e689cf4aSJeff Kirsher #define  REG_PCS_MII_LPA                   0x900C /* PCS MII link partner
1879e689cf4aSJeff Kirsher 						     ability reg */
1880e689cf4aSJeff Kirsher #define    PCS_MII_LPA_FD             PCS_MII_ADVERT_FD
1881e689cf4aSJeff Kirsher #define    PCS_MII_LPA_HD             PCS_MII_ADVERT_HD
1882e689cf4aSJeff Kirsher #define    PCS_MII_LPA_SYM_PAUSE      PCS_MII_ADVERT_SYM_PAUSE
1883e689cf4aSJeff Kirsher #define    PCS_MII_LPA_ASYM_PAUSE     PCS_MII_ADVERT_ASYM_PAUSE
1884e689cf4aSJeff Kirsher #define    PCS_MII_LPA_RF_MASK        PCS_MII_ADVERT_RF_MASK
1885e689cf4aSJeff Kirsher #define    PCS_MII_LPA_ACK            PCS_MII_ADVERT_ACK
1886e689cf4aSJeff Kirsher #define    PCS_MII_LPA_NEXT_PAGE      PCS_MII_ADVERT_NEXT_PAGE
1887e689cf4aSJeff Kirsher 
1888e689cf4aSJeff Kirsher /* DEFAULT: 0x0 */
1889e689cf4aSJeff Kirsher #define  REG_PCS_CFG                       0x9010 /* PCS config reg */
1890e689cf4aSJeff Kirsher #define    PCS_CFG_EN                      0x01   /* enable PCS. must be
1891e689cf4aSJeff Kirsher 						     0 when modifying
1892e689cf4aSJeff Kirsher 						     PCS_MII_ADVERT */
1893e689cf4aSJeff Kirsher #define    PCS_CFG_SD_OVERRIDE             0x02   /* sets signal detect to
1894e689cf4aSJeff Kirsher 						     OK. bit is
1895e689cf4aSJeff Kirsher 						     non-resettable */
1896e689cf4aSJeff Kirsher #define    PCS_CFG_SD_ACTIVE_LOW           0x04   /* changes interpretation
1897e689cf4aSJeff Kirsher 						     of optical signal to make
1898e689cf4aSJeff Kirsher 						     signal detect okay when
1899e689cf4aSJeff Kirsher 						     signal is low */
1900e689cf4aSJeff Kirsher #define    PCS_CFG_JITTER_STUDY_MASK       0x18   /* used to make jitter
1901e689cf4aSJeff Kirsher 						     measurements. a single
1902e689cf4aSJeff Kirsher 						     code group is xmitted
1903e689cf4aSJeff Kirsher 						     regularly.
1904e689cf4aSJeff Kirsher 						     0x0 = normal operation
1905e689cf4aSJeff Kirsher 						     0x1 = high freq test
1906e689cf4aSJeff Kirsher 						           pattern, D21.5
1907e689cf4aSJeff Kirsher 						     0x2 = low freq test
1908e689cf4aSJeff Kirsher 						           pattern, K28.7
1909e689cf4aSJeff Kirsher 						     0x3 = reserved */
1910e689cf4aSJeff Kirsher #define    PCS_CFG_10MS_TIMER_OVERRIDE     0x20   /* shortens 10-20ms auto-
1911e689cf4aSJeff Kirsher 						     negotiation timer to
1912e689cf4aSJeff Kirsher 						     a few cycles for test
1913e689cf4aSJeff Kirsher 						     purposes */
1914e689cf4aSJeff Kirsher 
1915e689cf4aSJeff Kirsher /* used for diagnostic purposes. bits 20-22 autoclear on read */
1916e689cf4aSJeff Kirsher #define  REG_PCS_STATE_MACHINE             0x9014 /* (ro) PCS state machine
1917e689cf4aSJeff Kirsher 						     and diagnostic reg */
1918e689cf4aSJeff Kirsher #define    PCS_SM_TX_STATE_MASK            0x0000000F /* 0 and 1 indicate
1919e689cf4aSJeff Kirsher 							 xmission of idle.
1920e689cf4aSJeff Kirsher 							 otherwise, xmission of
1921e689cf4aSJeff Kirsher 							 a packet */
1922e689cf4aSJeff Kirsher #define    PCS_SM_RX_STATE_MASK            0x000000F0 /* 0 indicates reception
1923e689cf4aSJeff Kirsher 							 of idle. otherwise,
1924e689cf4aSJeff Kirsher 							 reception of packet */
1925e689cf4aSJeff Kirsher #define    PCS_SM_WORD_SYNC_STATE_MASK     0x00000700 /* 0 indicates loss of
1926e689cf4aSJeff Kirsher 							 sync */
1927e689cf4aSJeff Kirsher #define    PCS_SM_SEQ_DETECT_STATE_MASK    0x00001800 /* cycling through 0-3
1928e689cf4aSJeff Kirsher 							 indicates reception of
1929e689cf4aSJeff Kirsher 							 Config codes. cycling
1930e689cf4aSJeff Kirsher 							 through 0-1 indicates
1931e689cf4aSJeff Kirsher 							 reception of idles */
1932e689cf4aSJeff Kirsher #define    PCS_SM_LINK_STATE_MASK          0x0001E000
1933e689cf4aSJeff Kirsher #define        SM_LINK_STATE_UP            0x00016000 /* link state is up */
1934e689cf4aSJeff Kirsher 
1935e689cf4aSJeff Kirsher #define    PCS_SM_LOSS_LINK_C              0x00100000 /* loss of link due to
1936e689cf4aSJeff Kirsher 							 recept of Config
1937e689cf4aSJeff Kirsher 							 codes */
1938e689cf4aSJeff Kirsher #define    PCS_SM_LOSS_LINK_SYNC           0x00200000 /* loss of link due to
1939e689cf4aSJeff Kirsher 							 loss of sync */
1940e689cf4aSJeff Kirsher #define    PCS_SM_LOSS_SIGNAL_DETECT       0x00400000 /* signal detect goes
1941e689cf4aSJeff Kirsher 							 from OK to FAIL. bit29
1942e689cf4aSJeff Kirsher 							 will also be set if
1943e689cf4aSJeff Kirsher 							 this is set */
1944e689cf4aSJeff Kirsher #define    PCS_SM_NO_LINK_BREAKLINK        0x01000000 /* link not up due to
1945e689cf4aSJeff Kirsher 							receipt of breaklink
1946e689cf4aSJeff Kirsher 							C codes from partner.
1947e689cf4aSJeff Kirsher 							C codes w/ 0 content
1948e689cf4aSJeff Kirsher 							received triggering
1949e689cf4aSJeff Kirsher 							start/restart of
1950e689cf4aSJeff Kirsher 							autonegotiation.
1951e689cf4aSJeff Kirsher 							should be sent for
1952e689cf4aSJeff Kirsher 							no longer than 20ms */
1953e689cf4aSJeff Kirsher #define    PCS_SM_NO_LINK_SERDES           0x02000000 /* serdes being
1954e689cf4aSJeff Kirsher 							initialized. see serdes
1955e689cf4aSJeff Kirsher 							state reg */
1956e689cf4aSJeff Kirsher #define    PCS_SM_NO_LINK_C                0x04000000 /* C codes not stable or
1957e689cf4aSJeff Kirsher 							 not received */
1958e689cf4aSJeff Kirsher #define    PCS_SM_NO_LINK_SYNC             0x08000000 /* word sync not
1959e689cf4aSJeff Kirsher 							 achieved */
1960e689cf4aSJeff Kirsher #define    PCS_SM_NO_LINK_WAIT_C           0x10000000 /* waiting for C codes
1961e689cf4aSJeff Kirsher 							 w/ ack bit set */
1962e689cf4aSJeff Kirsher #define    PCS_SM_NO_LINK_NO_IDLE          0x20000000 /* link partner continues
1963e689cf4aSJeff Kirsher 							 to send C codes
1964e689cf4aSJeff Kirsher 							 instead of idle
1965e689cf4aSJeff Kirsher 							 symbols or pkt data */
1966e689cf4aSJeff Kirsher 
1967e689cf4aSJeff Kirsher /* this register indicates interrupt changes in specific PCS MII status bits.
1968e689cf4aSJeff Kirsher  * PCS_INT may be masked at the ISR level. only a single bit is implemented
1969e689cf4aSJeff Kirsher  * for link status change.
1970e689cf4aSJeff Kirsher  */
1971e689cf4aSJeff Kirsher #define  REG_PCS_INTR_STATUS               0x9018 /* PCS interrupt status */
1972e689cf4aSJeff Kirsher #define    PCS_INTR_STATUS_LINK_CHANGE     0x04   /* link status has changed
1973e689cf4aSJeff Kirsher 						     since last read */
1974e689cf4aSJeff Kirsher 
1975e689cf4aSJeff Kirsher /* control which network interface is used. no more than one bit should
1976e689cf4aSJeff Kirsher  * be set.
1977e689cf4aSJeff Kirsher  * DEFAULT: none
1978e689cf4aSJeff Kirsher  */
1979e689cf4aSJeff Kirsher #define  REG_PCS_DATAPATH_MODE             0x9050 /* datapath mode reg */
1980e689cf4aSJeff Kirsher #define    PCS_DATAPATH_MODE_MII           0x00 /* PCS is not used and
1981e689cf4aSJeff Kirsher 						   MII/GMII is selected.
1982e689cf4aSJeff Kirsher 						   selection between MII and
1983e689cf4aSJeff Kirsher 						   GMII is controlled by
1984e689cf4aSJeff Kirsher 						   XIF_CFG */
1985e689cf4aSJeff Kirsher #define    PCS_DATAPATH_MODE_SERDES        0x02 /* PCS is used via the
1986e689cf4aSJeff Kirsher 						   10-bit interface */
1987e689cf4aSJeff Kirsher 
1988e689cf4aSJeff Kirsher /* input to serdes chip or serialink block */
1989e689cf4aSJeff Kirsher #define  REG_PCS_SERDES_CTRL              0x9054 /* serdes control reg */
1990e689cf4aSJeff Kirsher #define    PCS_SERDES_CTRL_LOOPBACK       0x01   /* enable loopback on
1991e689cf4aSJeff Kirsher 						    serdes interface */
1992e689cf4aSJeff Kirsher #define    PCS_SERDES_CTRL_SYNCD_EN       0x02   /* enable sync carrier
1993e689cf4aSJeff Kirsher 						    detection. should be
1994e689cf4aSJeff Kirsher 						    0x0 for normal
1995e689cf4aSJeff Kirsher 						    operation */
1996e689cf4aSJeff Kirsher #define    PCS_SERDES_CTRL_LOCKREF       0x04   /* frequency-lock RBC[0:1]
1997e689cf4aSJeff Kirsher 						   to REFCLK when set.
1998e689cf4aSJeff Kirsher 						   when clear, receiver
1999e689cf4aSJeff Kirsher 						   clock locks to incoming
2000e689cf4aSJeff Kirsher 						   serial data */
2001e689cf4aSJeff Kirsher 
2002e689cf4aSJeff Kirsher /* multiplex test outputs into the PROM address (PA_3 through PA_0) pins.
2003e689cf4aSJeff Kirsher  * should be 0x0 for normal operations.
2004e689cf4aSJeff Kirsher  * 0b000          normal operation, PROM address[3:0] selected
2005e689cf4aSJeff Kirsher  * 0b001          rxdma req, rxdma ack, rxdma ready, rxdma read
2006e689cf4aSJeff Kirsher  * 0b010          rxmac req, rx ack, rx tag, rx clk shared
2007e689cf4aSJeff Kirsher  * 0b011          txmac req, tx ack, tx tag, tx retry req
2008e689cf4aSJeff Kirsher  * 0b100          tx tp3, tx tp2, tx tp1, tx tp0
2009e689cf4aSJeff Kirsher  * 0b101          R period RX, R period TX, R period HP, R period BIM
2010e689cf4aSJeff Kirsher  * DEFAULT: 0x0
2011e689cf4aSJeff Kirsher  */
2012e689cf4aSJeff Kirsher #define  REG_PCS_SHARED_OUTPUT_SEL         0x9058 /* shared output select */
2013e689cf4aSJeff Kirsher #define    PCS_SOS_PROM_ADDR_MASK          0x0007
2014e689cf4aSJeff Kirsher 
2015e689cf4aSJeff Kirsher /* used for diagnostics. this register indicates progress of the SERDES
2016e689cf4aSJeff Kirsher  * boot up.
2017e689cf4aSJeff Kirsher  * 0b00       undergoing reset
2018e689cf4aSJeff Kirsher  * 0b01       waiting 500us while lockrefn is asserted
2019e689cf4aSJeff Kirsher  * 0b10       waiting for comma detect
2020e689cf4aSJeff Kirsher  * 0b11       receive data is synchronized
2021e689cf4aSJeff Kirsher  * DEFAULT: 0x0
2022e689cf4aSJeff Kirsher  */
2023e689cf4aSJeff Kirsher #define  REG_PCS_SERDES_STATE              0x905C /* (ro) serdes state */
2024e689cf4aSJeff Kirsher #define    PCS_SERDES_STATE_MASK           0x03
2025e689cf4aSJeff Kirsher 
2026e689cf4aSJeff Kirsher /* used for diagnostics. indicates number of packets transmitted or received.
2027e689cf4aSJeff Kirsher  * counters rollover w/out generating an interrupt.
2028e689cf4aSJeff Kirsher  * DEFAULT: 0x0
2029e689cf4aSJeff Kirsher  */
2030e689cf4aSJeff Kirsher #define  REG_PCS_PACKET_COUNT              0x9060 /* (ro) PCS packet counter */
2031e689cf4aSJeff Kirsher #define    PCS_PACKET_COUNT_TX             0x000007FF /* pkts xmitted by PCS */
2032e689cf4aSJeff Kirsher #define    PCS_PACKET_COUNT_RX             0x07FF0000 /* pkts recvd by PCS
2033e689cf4aSJeff Kirsher 							 whether they
2034e689cf4aSJeff Kirsher 							 encountered an error
2035e689cf4aSJeff Kirsher 							 or not */
2036e689cf4aSJeff Kirsher 
2037e689cf4aSJeff Kirsher /** LocalBus Devices. the following provides run-time access to the
2038e689cf4aSJeff Kirsher  *  Cassini's PROM
2039e689cf4aSJeff Kirsher  ***/
2040e689cf4aSJeff Kirsher #define  REG_EXPANSION_ROM_RUN_START       0x100000 /* expansion rom run time
2041e689cf4aSJeff Kirsher 						       access */
2042e689cf4aSJeff Kirsher #define  REG_EXPANSION_ROM_RUN_END         0x17FFFF
2043e689cf4aSJeff Kirsher 
2044e689cf4aSJeff Kirsher #define  REG_SECOND_LOCALBUS_START         0x180000 /* secondary local bus
2045e689cf4aSJeff Kirsher 						       device */
2046e689cf4aSJeff Kirsher #define  REG_SECOND_LOCALBUS_END           0x1FFFFF
2047e689cf4aSJeff Kirsher 
2048e689cf4aSJeff Kirsher /* entropy device */
2049e689cf4aSJeff Kirsher #define  REG_ENTROPY_START                 REG_SECOND_LOCALBUS_START
2050e689cf4aSJeff Kirsher #define  REG_ENTROPY_DATA                  (REG_ENTROPY_START + 0x00)
2051e689cf4aSJeff Kirsher #define  REG_ENTROPY_STATUS                (REG_ENTROPY_START + 0x04)
2052e689cf4aSJeff Kirsher #define      ENTROPY_STATUS_DRDY           0x01
2053e689cf4aSJeff Kirsher #define      ENTROPY_STATUS_BUSY           0x02
2054e689cf4aSJeff Kirsher #define      ENTROPY_STATUS_CIPHER         0x04
2055e689cf4aSJeff Kirsher #define      ENTROPY_STATUS_BYPASS_MASK    0x18
2056e689cf4aSJeff Kirsher #define  REG_ENTROPY_MODE                  (REG_ENTROPY_START + 0x05)
2057e689cf4aSJeff Kirsher #define      ENTROPY_MODE_KEY_MASK         0x07
2058e689cf4aSJeff Kirsher #define      ENTROPY_MODE_ENCRYPT          0x40
2059e689cf4aSJeff Kirsher #define  REG_ENTROPY_RAND_REG              (REG_ENTROPY_START + 0x06)
2060e689cf4aSJeff Kirsher #define  REG_ENTROPY_RESET                 (REG_ENTROPY_START + 0x07)
2061e689cf4aSJeff Kirsher #define      ENTROPY_RESET_DES_IO          0x01
2062e689cf4aSJeff Kirsher #define      ENTROPY_RESET_STC_MODE        0x02
2063e689cf4aSJeff Kirsher #define      ENTROPY_RESET_KEY_CACHE       0x04
2064e689cf4aSJeff Kirsher #define      ENTROPY_RESET_IV              0x08
2065e689cf4aSJeff Kirsher #define  REG_ENTROPY_IV                    (REG_ENTROPY_START + 0x08)
2066e689cf4aSJeff Kirsher #define  REG_ENTROPY_KEY0                  (REG_ENTROPY_START + 0x10)
2067e689cf4aSJeff Kirsher #define  REG_ENTROPY_KEYN(x)               (REG_ENTROPY_KEY0 + 4*(x))
2068e689cf4aSJeff Kirsher 
2069e689cf4aSJeff Kirsher /* phys of interest w/ their special mii registers */
2070e689cf4aSJeff Kirsher #define PHY_LUCENT_B0     0x00437421
2071e689cf4aSJeff Kirsher #define   LUCENT_MII_REG      0x1F
2072e689cf4aSJeff Kirsher 
2073e689cf4aSJeff Kirsher #define PHY_NS_DP83065    0x20005c78
2074e689cf4aSJeff Kirsher #define   DP83065_MII_MEM     0x16
2075e689cf4aSJeff Kirsher #define   DP83065_MII_REGD    0x1D
2076e689cf4aSJeff Kirsher #define   DP83065_MII_REGE    0x1E
2077e689cf4aSJeff Kirsher 
2078e689cf4aSJeff Kirsher #define PHY_BROADCOM_5411 0x00206071
2079e689cf4aSJeff Kirsher #define PHY_BROADCOM_B0   0x00206050
2080e689cf4aSJeff Kirsher #define   BROADCOM_MII_REG4   0x14
2081e689cf4aSJeff Kirsher #define   BROADCOM_MII_REG5   0x15
2082e689cf4aSJeff Kirsher #define   BROADCOM_MII_REG7   0x17
2083e689cf4aSJeff Kirsher #define   BROADCOM_MII_REG8   0x18
2084e689cf4aSJeff Kirsher 
2085e689cf4aSJeff Kirsher #define   CAS_MII_ANNPTR          0x07
2086e689cf4aSJeff Kirsher #define   CAS_MII_ANNPRR          0x08
2087e689cf4aSJeff Kirsher #define   CAS_MII_1000_CTRL       0x09
2088e689cf4aSJeff Kirsher #define   CAS_MII_1000_STATUS     0x0A
2089e689cf4aSJeff Kirsher #define   CAS_MII_1000_EXTEND     0x0F
2090e689cf4aSJeff Kirsher 
2091e689cf4aSJeff Kirsher #define   CAS_BMSR_1000_EXTEND    0x0100 /* supports 1000Base-T extended status */
2092e689cf4aSJeff Kirsher /*
2093e689cf4aSJeff Kirsher  * if autoneg is disabled, here's the table:
2094e689cf4aSJeff Kirsher  * BMCR_SPEED100 = 100Mbps
2095e689cf4aSJeff Kirsher  * BMCR_SPEED1000 = 1000Mbps
2096e689cf4aSJeff Kirsher  * ~(BMCR_SPEED100 | BMCR_SPEED1000) = 10Mbps
2097e689cf4aSJeff Kirsher  */
2098e689cf4aSJeff Kirsher #define   CAS_BMCR_SPEED1000      0x0040  /* Select 1000Mbps */
2099e689cf4aSJeff Kirsher 
2100e689cf4aSJeff Kirsher #define   CAS_ADVERTISE_1000HALF   0x0100
2101e689cf4aSJeff Kirsher #define   CAS_ADVERTISE_1000FULL   0x0200
2102e689cf4aSJeff Kirsher #define   CAS_ADVERTISE_PAUSE      0x0400
2103e689cf4aSJeff Kirsher #define   CAS_ADVERTISE_ASYM_PAUSE 0x0800
2104e689cf4aSJeff Kirsher 
2105e689cf4aSJeff Kirsher /* regular lpa register */
2106e689cf4aSJeff Kirsher #define   CAS_LPA_PAUSE	           CAS_ADVERTISE_PAUSE
2107e689cf4aSJeff Kirsher #define   CAS_LPA_ASYM_PAUSE       CAS_ADVERTISE_ASYM_PAUSE
2108e689cf4aSJeff Kirsher 
2109e689cf4aSJeff Kirsher /* 1000_STATUS register */
2110e689cf4aSJeff Kirsher #define   CAS_LPA_1000HALF        0x0400
2111e689cf4aSJeff Kirsher #define   CAS_LPA_1000FULL        0x0800
2112e689cf4aSJeff Kirsher 
2113e689cf4aSJeff Kirsher #define   CAS_EXTEND_1000XFULL    0x8000
2114e689cf4aSJeff Kirsher #define   CAS_EXTEND_1000XHALF    0x4000
2115e689cf4aSJeff Kirsher #define   CAS_EXTEND_1000TFULL    0x2000
2116e689cf4aSJeff Kirsher #define   CAS_EXTEND_1000THALF    0x1000
2117e689cf4aSJeff Kirsher 
2118e689cf4aSJeff Kirsher /* cassini header parser firmware */
2119e689cf4aSJeff Kirsher typedef struct cas_hp_inst {
2120e689cf4aSJeff Kirsher 	const char *note;
2121e689cf4aSJeff Kirsher 
2122e689cf4aSJeff Kirsher 	u16 mask, val;
2123e689cf4aSJeff Kirsher 
2124e689cf4aSJeff Kirsher 	u8 op;
2125e689cf4aSJeff Kirsher 	u8 soff, snext;	/* if match succeeds, new offset and match */
2126e689cf4aSJeff Kirsher 	u8 foff, fnext;	/* if match fails, new offset and match */
2127e689cf4aSJeff Kirsher 	/* output info */
2128e689cf4aSJeff Kirsher 	u8 outop;    /* output opcode */
2129e689cf4aSJeff Kirsher 
2130e689cf4aSJeff Kirsher 	u16 outarg;  /* output argument */
2131e689cf4aSJeff Kirsher 	u8 outenab;  /* output enable: 0 = not, 1 = if match
2132e689cf4aSJeff Kirsher 			 2 = if !match, 3 = always */
2133e689cf4aSJeff Kirsher 	u8 outshift; /* barrel shift right, 4 bits */
2134e689cf4aSJeff Kirsher 	u16 outmask;
2135e689cf4aSJeff Kirsher } cas_hp_inst_t;
2136e689cf4aSJeff Kirsher 
2137e689cf4aSJeff Kirsher /* comparison */
2138e689cf4aSJeff Kirsher #define OP_EQ     0 /* packet == value */
2139e689cf4aSJeff Kirsher #define OP_LT     1 /* packet < value */
2140e689cf4aSJeff Kirsher #define OP_GT     2 /* packet > value */
2141e689cf4aSJeff Kirsher #define OP_NP     3 /* new packet */
2142e689cf4aSJeff Kirsher 
2143e689cf4aSJeff Kirsher /* output opcodes */
2144e689cf4aSJeff Kirsher #define	CL_REG	0
2145e689cf4aSJeff Kirsher #define	LD_FID	1
2146e689cf4aSJeff Kirsher #define	LD_SEQ	2
2147e689cf4aSJeff Kirsher #define	LD_CTL	3
2148e689cf4aSJeff Kirsher #define	LD_SAP	4
2149e689cf4aSJeff Kirsher #define	LD_R1	5
2150e689cf4aSJeff Kirsher #define	LD_L3	6
2151e689cf4aSJeff Kirsher #define	LD_SUM	7
2152e689cf4aSJeff Kirsher #define	LD_HDR	8
2153e689cf4aSJeff Kirsher #define	IM_FID	9
2154e689cf4aSJeff Kirsher #define	IM_SEQ	10
2155e689cf4aSJeff Kirsher #define	IM_SAP	11
2156e689cf4aSJeff Kirsher #define	IM_R1	12
2157e689cf4aSJeff Kirsher #define	IM_CTL	13
2158e689cf4aSJeff Kirsher #define	LD_LEN	14
2159e689cf4aSJeff Kirsher #define	ST_FLG	15
2160e689cf4aSJeff Kirsher 
2161e689cf4aSJeff Kirsher /* match setp #s for IP4TCP4 */
2162e689cf4aSJeff Kirsher #define S1_PCKT         0
2163e689cf4aSJeff Kirsher #define S1_VLAN         1
2164e689cf4aSJeff Kirsher #define S1_CFI          2
2165e689cf4aSJeff Kirsher #define S1_8023         3
2166e689cf4aSJeff Kirsher #define S1_LLC          4
2167e689cf4aSJeff Kirsher #define S1_LLCc         5
2168e689cf4aSJeff Kirsher #define S1_IPV4         6
2169e689cf4aSJeff Kirsher #define S1_IPV4c        7
2170e689cf4aSJeff Kirsher #define S1_IPV4F        8
2171e689cf4aSJeff Kirsher #define S1_TCP44        9
2172e689cf4aSJeff Kirsher #define S1_IPV6         10
2173e689cf4aSJeff Kirsher #define S1_IPV6L        11
2174e689cf4aSJeff Kirsher #define S1_IPV6c        12
2175e689cf4aSJeff Kirsher #define S1_TCP64        13
2176e689cf4aSJeff Kirsher #define S1_TCPSQ        14
2177e689cf4aSJeff Kirsher #define S1_TCPFG        15
2178e689cf4aSJeff Kirsher #define	S1_TCPHL	16
2179e689cf4aSJeff Kirsher #define	S1_TCPHc	17
2180e689cf4aSJeff Kirsher #define	S1_CLNP		18
2181e689cf4aSJeff Kirsher #define	S1_CLNP2	19
2182e689cf4aSJeff Kirsher #define	S1_DROP		20
2183e689cf4aSJeff Kirsher #define	S2_HTTP		21
2184e689cf4aSJeff Kirsher #define	S1_ESP4		22
2185e689cf4aSJeff Kirsher #define	S1_AH4		23
2186e689cf4aSJeff Kirsher #define	S1_ESP6		24
2187e689cf4aSJeff Kirsher #define	S1_AH6		25
2188e689cf4aSJeff Kirsher 
2189e689cf4aSJeff Kirsher #define CAS_PROG_IP46TCP4_PREAMBLE \
2190e689cf4aSJeff Kirsher { "packet arrival?", 0xffff, 0x0000, OP_NP,  6, S1_VLAN,  0, S1_PCKT,  \
2191e689cf4aSJeff Kirsher   CL_REG, 0x3ff, 1, 0x0, 0x0000}, \
2192e689cf4aSJeff Kirsher { "VLAN?", 0xffff, 0x8100, OP_EQ,  1, S1_CFI,   0, S1_8023,  \
2193e689cf4aSJeff Kirsher   IM_CTL, 0x00a,  3, 0x0, 0xffff}, \
2194e689cf4aSJeff Kirsher { "CFI?", 0x1000, 0x1000, OP_EQ,  0, S1_DROP,  1, S1_8023, \
2195e689cf4aSJeff Kirsher   CL_REG, 0x000,  0, 0x0, 0x0000}, \
2196e689cf4aSJeff Kirsher { "8023?", 0xffff, 0x0600, OP_LT,  1, S1_LLC,   0, S1_IPV4, \
2197e689cf4aSJeff Kirsher   CL_REG, 0x000,  0, 0x0, 0x0000}, \
2198e689cf4aSJeff Kirsher { "LLC?", 0xffff, 0xaaaa, OP_EQ,  1, S1_LLCc,  0, S1_CLNP, \
2199e689cf4aSJeff Kirsher   CL_REG, 0x000,  0, 0x0, 0x0000}, \
2200e689cf4aSJeff Kirsher { "LLCc?", 0xff00, 0x0300, OP_EQ,  2, S1_IPV4,  0, S1_CLNP, \
2201e689cf4aSJeff Kirsher   CL_REG, 0x000,  0, 0x0, 0x0000}, \
2202e689cf4aSJeff Kirsher { "IPV4?", 0xffff, 0x0800, OP_EQ,  1, S1_IPV4c, 0, S1_IPV6, \
2203e689cf4aSJeff Kirsher   LD_SAP, 0x100,  3, 0x0, 0xffff}, \
2204e689cf4aSJeff Kirsher { "IPV4 cont?", 0xff00, 0x4500, OP_EQ,  3, S1_IPV4F, 0, S1_CLNP, \
2205e689cf4aSJeff Kirsher   LD_SUM, 0x00a,  1, 0x0, 0x0000}, \
2206e689cf4aSJeff Kirsher { "IPV4 frag?", 0x3fff, 0x0000, OP_EQ,  1, S1_TCP44, 0, S1_CLNP, \
2207e689cf4aSJeff Kirsher   LD_LEN, 0x03e,  1, 0x0, 0xffff}, \
2208e689cf4aSJeff Kirsher { "TCP44?", 0x00ff, 0x0006, OP_EQ,  7, S1_TCPSQ, 0, S1_CLNP, \
2209e689cf4aSJeff Kirsher   LD_FID, 0x182,  1, 0x0, 0xffff}, /* FID IP4&TCP src+dst */ \
2210e689cf4aSJeff Kirsher { "IPV6?", 0xffff, 0x86dd, OP_EQ,  1, S1_IPV6L, 0, S1_CLNP,  \
2211e689cf4aSJeff Kirsher   LD_SUM, 0x015,  1, 0x0, 0x0000}, \
2212e689cf4aSJeff Kirsher { "IPV6 len", 0xf000, 0x6000, OP_EQ,  0, S1_IPV6c, 0, S1_CLNP, \
2213e689cf4aSJeff Kirsher   IM_R1,  0x128,  1, 0x0, 0xffff}, \
2214e689cf4aSJeff Kirsher { "IPV6 cont?", 0x0000, 0x0000, OP_EQ,  3, S1_TCP64, 0, S1_CLNP, \
2215e689cf4aSJeff Kirsher   LD_FID, 0x484,  1, 0x0, 0xffff}, /* FID IP6&TCP src+dst */ \
2216e689cf4aSJeff Kirsher { "TCP64?", 0xff00, 0x0600, OP_EQ, 18, S1_TCPSQ, 0, S1_CLNP, \
2217e689cf4aSJeff Kirsher   LD_LEN, 0x03f,  1, 0x0, 0xffff}
2218e689cf4aSJeff Kirsher 
2219e689cf4aSJeff Kirsher #ifdef USE_HP_IP46TCP4
2220e689cf4aSJeff Kirsher static cas_hp_inst_t cas_prog_ip46tcp4tab[] = {
2221e689cf4aSJeff Kirsher 	CAS_PROG_IP46TCP4_PREAMBLE,
2222e689cf4aSJeff Kirsher 	{ "TCP seq", /* DADDR should point to dest port */
2223e689cf4aSJeff Kirsher 	  0x0000, 0x0000, OP_EQ, 0, S1_TCPFG, 4, S1_TCPFG, LD_SEQ,
2224e689cf4aSJeff Kirsher 	  0x081,  3, 0x0, 0xffff}, /* Load TCP seq # */
2225e689cf4aSJeff Kirsher 	{ "TCP control flags", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHL, 0,
2226e689cf4aSJeff Kirsher 	  S1_TCPHL, ST_FLG, 0x045,  3, 0x0, 0x002f}, /* Load TCP flags */
2227e689cf4aSJeff Kirsher 	{ "TCP length", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHc, 0,
2228e689cf4aSJeff Kirsher 	  S1_TCPHc, LD_R1,  0x205,  3, 0xB, 0xf000},
2229e689cf4aSJeff Kirsher 	{ "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0,
2230e689cf4aSJeff Kirsher 	  S1_PCKT,  LD_HDR, 0x0ff,  3, 0x0, 0xffff},
2231e689cf4aSJeff Kirsher 	{ "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_CLNP2,  0, S1_CLNP2,
2232e689cf4aSJeff Kirsher 	  IM_CTL, 0x001,  3, 0x0, 0x0001},
2233e689cf4aSJeff Kirsher 	{ "Cleanup 2", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
2234e689cf4aSJeff Kirsher 	  IM_CTL, 0x000,  0, 0x0, 0x0000},
2235e689cf4aSJeff Kirsher 	{ "Drop packet", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
2236e689cf4aSJeff Kirsher 	  IM_CTL, 0x080,  3, 0x0, 0xffff},
2237e689cf4aSJeff Kirsher 	{ NULL },
2238e689cf4aSJeff Kirsher };
2239e689cf4aSJeff Kirsher #ifdef HP_IP46TCP4_DEFAULT
2240e689cf4aSJeff Kirsher #define CAS_HP_FIRMWARE               cas_prog_ip46tcp4tab
2241e689cf4aSJeff Kirsher #endif
2242e689cf4aSJeff Kirsher #endif
2243e689cf4aSJeff Kirsher 
2244e689cf4aSJeff Kirsher /*
2245e689cf4aSJeff Kirsher  * Alternate table load which excludes HTTP server traffic from reassembly.
2246e689cf4aSJeff Kirsher  * It is substantially similar to the basic table, with one extra state
2247e689cf4aSJeff Kirsher  * and a few extra compares. */
2248e689cf4aSJeff Kirsher #ifdef USE_HP_IP46TCP4NOHTTP
2249e689cf4aSJeff Kirsher static cas_hp_inst_t cas_prog_ip46tcp4nohttptab[] = {
2250e689cf4aSJeff Kirsher 	CAS_PROG_IP46TCP4_PREAMBLE,
2251e689cf4aSJeff Kirsher 	{ "TCP seq", /* DADDR should point to dest port */
2252e689cf4aSJeff Kirsher 	  0xFFFF, 0x0080, OP_EQ,  0, S2_HTTP,  0, S1_TCPFG, LD_SEQ,
2253e689cf4aSJeff Kirsher 	  0x081,  3, 0x0, 0xffff} , /* Load TCP seq # */
2254e689cf4aSJeff Kirsher 	{ "TCP control flags", 0xFFFF, 0x8080, OP_EQ,  0, S2_HTTP,  0,
2255e689cf4aSJeff Kirsher 	  S1_TCPHL, ST_FLG, 0x145,  2, 0x0, 0x002f, }, /* Load TCP flags */
2256e689cf4aSJeff Kirsher 	{ "TCP length", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHc, 0, S1_TCPHc,
2257e689cf4aSJeff Kirsher 	  LD_R1,  0x205,  3, 0xB, 0xf000},
2258e689cf4aSJeff Kirsher 	{ "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
2259e689cf4aSJeff Kirsher 	  LD_HDR, 0x0ff,  3, 0x0, 0xffff},
2260e689cf4aSJeff Kirsher 	{ "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_CLNP2,  0, S1_CLNP2,
2261e689cf4aSJeff Kirsher 	  IM_CTL, 0x001,  3, 0x0, 0x0001},
2262e689cf4aSJeff Kirsher 	{ "Cleanup 2", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
2263e689cf4aSJeff Kirsher 	  CL_REG, 0x002,  3, 0x0, 0x0000},
2264e689cf4aSJeff Kirsher 	{ "Drop packet", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
2265e689cf4aSJeff Kirsher 	  IM_CTL, 0x080,  3, 0x0, 0xffff},
2266e689cf4aSJeff Kirsher 	{ "No HTTP", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
2267e689cf4aSJeff Kirsher 	  IM_CTL, 0x044,  3, 0x0, 0xffff},
2268e689cf4aSJeff Kirsher 	{ NULL },
2269e689cf4aSJeff Kirsher };
2270e689cf4aSJeff Kirsher #ifdef HP_IP46TCP4NOHTTP_DEFAULT
2271e689cf4aSJeff Kirsher #define CAS_HP_FIRMWARE               cas_prog_ip46tcp4nohttptab
2272e689cf4aSJeff Kirsher #endif
2273e689cf4aSJeff Kirsher #endif
2274e689cf4aSJeff Kirsher 
2275e689cf4aSJeff Kirsher /* match step #s for IP4FRAG */
2276e689cf4aSJeff Kirsher #define	S3_IPV6c	11
2277e689cf4aSJeff Kirsher #define	S3_TCP64	12
2278e689cf4aSJeff Kirsher #define	S3_TCPSQ	13
2279e689cf4aSJeff Kirsher #define	S3_TCPFG	14
2280e689cf4aSJeff Kirsher #define	S3_TCPHL	15
2281e689cf4aSJeff Kirsher #define	S3_TCPHc	16
2282e689cf4aSJeff Kirsher #define	S3_FRAG		17
2283e689cf4aSJeff Kirsher #define	S3_FOFF		18
2284e689cf4aSJeff Kirsher #define	S3_CLNP		19
2285e689cf4aSJeff Kirsher 
2286e689cf4aSJeff Kirsher #ifdef USE_HP_IP4FRAG
2287e689cf4aSJeff Kirsher static cas_hp_inst_t cas_prog_ip4fragtab[] = {
2288e689cf4aSJeff Kirsher 	{ "packet arrival?", 0xffff, 0x0000, OP_NP,  6, S1_VLAN,  0, S1_PCKT,
2289e689cf4aSJeff Kirsher 	  CL_REG, 0x3ff, 1, 0x0, 0x0000},
2290e689cf4aSJeff Kirsher 	{ "VLAN?", 0xffff, 0x8100, OP_EQ,  1, S1_CFI,   0, S1_8023,
2291e689cf4aSJeff Kirsher 	  IM_CTL, 0x00a,  3, 0x0, 0xffff},
2292e689cf4aSJeff Kirsher 	{ "CFI?", 0x1000, 0x1000, OP_EQ,  0, S3_CLNP,  1, S1_8023,
2293e689cf4aSJeff Kirsher 	  CL_REG, 0x000,  0, 0x0, 0x0000},
2294e689cf4aSJeff Kirsher 	{ "8023?", 0xffff, 0x0600, OP_LT,  1, S1_LLC,   0, S1_IPV4,
2295e689cf4aSJeff Kirsher 	  CL_REG, 0x000,  0, 0x0, 0x0000},
2296e689cf4aSJeff Kirsher 	{ "LLC?", 0xffff, 0xaaaa, OP_EQ,  1, S1_LLCc,  0, S3_CLNP,
2297e689cf4aSJeff Kirsher 	  CL_REG, 0x000,  0, 0x0, 0x0000},
2298e689cf4aSJeff Kirsher 	{ "LLCc?",0xff00, 0x0300, OP_EQ,  2, S1_IPV4,  0, S3_CLNP,
2299e689cf4aSJeff Kirsher 	  CL_REG, 0x000,  0, 0x0, 0x0000},
2300e689cf4aSJeff Kirsher 	{ "IPV4?", 0xffff, 0x0800, OP_EQ,  1, S1_IPV4c, 0, S1_IPV6,
2301e689cf4aSJeff Kirsher 	  LD_SAP, 0x100,  3, 0x0, 0xffff},
2302e689cf4aSJeff Kirsher 	{ "IPV4 cont?", 0xff00, 0x4500, OP_EQ,  3, S1_IPV4F, 0, S3_CLNP,
2303e689cf4aSJeff Kirsher 	  LD_SUM, 0x00a,  1, 0x0, 0x0000},
2304e689cf4aSJeff Kirsher 	{ "IPV4 frag?", 0x3fff, 0x0000, OP_EQ,  1, S1_TCP44, 0, S3_FRAG,
2305e689cf4aSJeff Kirsher 	  LD_LEN, 0x03e,  3, 0x0, 0xffff},
2306e689cf4aSJeff Kirsher 	{ "TCP44?", 0x00ff, 0x0006, OP_EQ,  7, S3_TCPSQ, 0, S3_CLNP,
2307e689cf4aSJeff Kirsher 	  LD_FID, 0x182,  3, 0x0, 0xffff}, /* FID IP4&TCP src+dst */
2308e689cf4aSJeff Kirsher 	{ "IPV6?", 0xffff, 0x86dd, OP_EQ,  1, S3_IPV6c, 0, S3_CLNP,
2309e689cf4aSJeff Kirsher 	  LD_SUM, 0x015,  1, 0x0, 0x0000},
2310e689cf4aSJeff Kirsher 	{ "IPV6 cont?", 0xf000, 0x6000, OP_EQ,  3, S3_TCP64, 0, S3_CLNP,
2311e689cf4aSJeff Kirsher 	  LD_FID, 0x484,  1, 0x0, 0xffff}, /* FID IP6&TCP src+dst */
2312e689cf4aSJeff Kirsher 	{ "TCP64?", 0xff00, 0x0600, OP_EQ, 18, S3_TCPSQ, 0, S3_CLNP,
2313e689cf4aSJeff Kirsher 	  LD_LEN, 0x03f,  1, 0x0, 0xffff},
2314e689cf4aSJeff Kirsher 	{ "TCP seq",	/* DADDR should point to dest port */
2315e689cf4aSJeff Kirsher 	  0x0000, 0x0000, OP_EQ,  0, S3_TCPFG, 4, S3_TCPFG, LD_SEQ,
2316e689cf4aSJeff Kirsher 	  0x081,  3, 0x0, 0xffff}, /* Load TCP seq # */
2317e689cf4aSJeff Kirsher 	{ "TCP control flags", 0x0000, 0x0000, OP_EQ,  0, S3_TCPHL, 0,
2318e689cf4aSJeff Kirsher 	  S3_TCPHL, ST_FLG, 0x045,  3, 0x0, 0x002f}, /* Load TCP flags */
2319e689cf4aSJeff Kirsher 	{ "TCP length", 0x0000, 0x0000, OP_EQ,  0, S3_TCPHc, 0, S3_TCPHc,
2320e689cf4aSJeff Kirsher 	  LD_R1,  0x205,  3, 0xB, 0xf000},
2321e689cf4aSJeff Kirsher 	{ "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
2322e689cf4aSJeff Kirsher 	  LD_HDR, 0x0ff,  3, 0x0, 0xffff},
2323e689cf4aSJeff Kirsher 	{ "IP4 Fragment", 0x0000, 0x0000, OP_EQ,  0, S3_FOFF,  0, S3_FOFF,
2324e689cf4aSJeff Kirsher 	  LD_FID, 0x103,  3, 0x0, 0xffff}, /* FID IP4 src+dst */
2325e689cf4aSJeff Kirsher 	{ "IP4 frag offset", 0x0000, 0x0000, OP_EQ,  0, S3_FOFF,  0, S3_FOFF,
2326e689cf4aSJeff Kirsher 	  LD_SEQ, 0x040,  1, 0xD, 0xfff8},
2327e689cf4aSJeff Kirsher 	{ "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
2328e689cf4aSJeff Kirsher 	  IM_CTL, 0x001,  3, 0x0, 0x0001},
2329e689cf4aSJeff Kirsher 	{ NULL },
2330e689cf4aSJeff Kirsher };
2331e689cf4aSJeff Kirsher #ifdef HP_IP4FRAG_DEFAULT
2332e689cf4aSJeff Kirsher #define CAS_HP_FIRMWARE               cas_prog_ip4fragtab
2333e689cf4aSJeff Kirsher #endif
2334e689cf4aSJeff Kirsher #endif
2335e689cf4aSJeff Kirsher 
2336e689cf4aSJeff Kirsher /*
2337e689cf4aSJeff Kirsher  * Alternate table which does batching without reassembly
2338e689cf4aSJeff Kirsher  */
2339e689cf4aSJeff Kirsher #ifdef USE_HP_IP46TCP4BATCH
2340e689cf4aSJeff Kirsher static cas_hp_inst_t cas_prog_ip46tcp4batchtab[] = {
2341e689cf4aSJeff Kirsher 	CAS_PROG_IP46TCP4_PREAMBLE,
2342e689cf4aSJeff Kirsher 	{ "TCP seq",	/* DADDR should point to dest port */
2343e689cf4aSJeff Kirsher 	  0x0000, 0x0000, OP_EQ,  0, S1_TCPFG, 0, S1_TCPFG, LD_SEQ,
2344e689cf4aSJeff Kirsher 	  0x081,  3, 0x0, 0xffff}, /* Load TCP seq # */
2345e689cf4aSJeff Kirsher 	{ "TCP control flags", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHL, 0,
2346e689cf4aSJeff Kirsher 	  S1_TCPHL, ST_FLG, 0x000,  3, 0x0, 0x0000}, /* Load TCP flags */
2347e689cf4aSJeff Kirsher 	{ "TCP length", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHc, 0,
2348e689cf4aSJeff Kirsher 	  S1_TCPHc, LD_R1,  0x205,  3, 0xB, 0xf000},
2349e689cf4aSJeff Kirsher 	{ "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0,
2350e689cf4aSJeff Kirsher 	  S1_PCKT,  IM_CTL, 0x040,  3, 0x0, 0xffff}, /* set batch bit */
2351e689cf4aSJeff Kirsher 	{ "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
2352e689cf4aSJeff Kirsher 	  IM_CTL, 0x001,  3, 0x0, 0x0001},
2353e689cf4aSJeff Kirsher 	{ "Drop packet", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0,
2354e689cf4aSJeff Kirsher 	  S1_PCKT,  IM_CTL, 0x080,  3, 0x0, 0xffff},
2355e689cf4aSJeff Kirsher 	{ NULL },
2356e689cf4aSJeff Kirsher };
2357e689cf4aSJeff Kirsher #ifdef HP_IP46TCP4BATCH_DEFAULT
2358e689cf4aSJeff Kirsher #define CAS_HP_FIRMWARE               cas_prog_ip46tcp4batchtab
2359e689cf4aSJeff Kirsher #endif
2360e689cf4aSJeff Kirsher #endif
2361e689cf4aSJeff Kirsher 
2362e689cf4aSJeff Kirsher /* Workaround for Cassini rev2 descriptor corruption problem.
2363e689cf4aSJeff Kirsher  * Does batching without reassembly, and sets the SAP to a known
2364e689cf4aSJeff Kirsher  * data pattern for all packets.
2365e689cf4aSJeff Kirsher  */
2366e689cf4aSJeff Kirsher #ifdef USE_HP_WORKAROUND
2367e689cf4aSJeff Kirsher static cas_hp_inst_t  cas_prog_workaroundtab[] = {
2368e689cf4aSJeff Kirsher 	{ "packet arrival?", 0xffff, 0x0000, OP_NP,  6, S1_VLAN,  0,
2369e689cf4aSJeff Kirsher 	  S1_PCKT,  CL_REG, 0x3ff,  1, 0x0, 0x0000} ,
2370e689cf4aSJeff Kirsher 	{ "VLAN?", 0xffff, 0x8100, OP_EQ,  1, S1_CFI, 0, S1_8023,
2371e689cf4aSJeff Kirsher 	  IM_CTL, 0x04a,  3, 0x0, 0xffff},
2372e689cf4aSJeff Kirsher 	{ "CFI?", 0x1000, 0x1000, OP_EQ,  0, S1_CLNP,  1, S1_8023,
2373e689cf4aSJeff Kirsher 	  CL_REG, 0x000,  0, 0x0, 0x0000},
2374e689cf4aSJeff Kirsher 	{ "8023?", 0xffff, 0x0600, OP_LT,  1, S1_LLC,   0, S1_IPV4,
2375e689cf4aSJeff Kirsher 	  CL_REG, 0x000,  0, 0x0, 0x0000},
2376e689cf4aSJeff Kirsher 	{ "LLC?", 0xffff, 0xaaaa, OP_EQ,  1, S1_LLCc,  0, S1_CLNP,
2377e689cf4aSJeff Kirsher 	  CL_REG, 0x000,  0, 0x0, 0x0000},
2378e689cf4aSJeff Kirsher 	{ "LLCc?", 0xff00, 0x0300, OP_EQ,  2, S1_IPV4,  0, S1_CLNP,
2379e689cf4aSJeff Kirsher 	  CL_REG, 0x000,  0, 0x0, 0x0000},
2380e689cf4aSJeff Kirsher 	{ "IPV4?", 0xffff, 0x0800, OP_EQ,  1, S1_IPV4c, 0, S1_IPV6,
2381e689cf4aSJeff Kirsher 	  IM_SAP, 0x6AE,  3, 0x0, 0xffff},
2382e689cf4aSJeff Kirsher 	{ "IPV4 cont?", 0xff00, 0x4500, OP_EQ,  3, S1_IPV4F, 0, S1_CLNP,
2383e689cf4aSJeff Kirsher 	  LD_SUM, 0x00a,  1, 0x0, 0x0000},
2384e689cf4aSJeff Kirsher 	{ "IPV4 frag?", 0x3fff, 0x0000, OP_EQ,  1, S1_TCP44, 0, S1_CLNP,
2385e689cf4aSJeff Kirsher 	  LD_LEN, 0x03e,  1, 0x0, 0xffff},
2386e689cf4aSJeff Kirsher 	{ "TCP44?", 0x00ff, 0x0006, OP_EQ,  7, S1_TCPSQ, 0, S1_CLNP,
2387e689cf4aSJeff Kirsher 	  LD_FID, 0x182,  3, 0x0, 0xffff}, /* FID IP4&TCP src+dst */
2388e689cf4aSJeff Kirsher 	{ "IPV6?", 0xffff, 0x86dd, OP_EQ,  1, S1_IPV6L, 0, S1_CLNP,
2389e689cf4aSJeff Kirsher 	  LD_SUM, 0x015,  1, 0x0, 0x0000},
2390e689cf4aSJeff Kirsher 	{ "IPV6 len", 0xf000, 0x6000, OP_EQ,  0, S1_IPV6c, 0, S1_CLNP,
2391e689cf4aSJeff Kirsher 	  IM_R1,  0x128,  1, 0x0, 0xffff},
2392e689cf4aSJeff Kirsher 	{ "IPV6 cont?", 0x0000, 0x0000, OP_EQ,  3, S1_TCP64, 0, S1_CLNP,
2393e689cf4aSJeff Kirsher 	  LD_FID, 0x484,  1, 0x0, 0xffff}, /* FID IP6&TCP src+dst */
2394e689cf4aSJeff Kirsher 	{ "TCP64?", 0xff00, 0x0600, OP_EQ, 18, S1_TCPSQ, 0, S1_CLNP,
2395e689cf4aSJeff Kirsher 	  LD_LEN, 0x03f,  1, 0x0, 0xffff},
2396e689cf4aSJeff Kirsher 	{ "TCP seq",      /* DADDR should point to dest port */
2397e689cf4aSJeff Kirsher 	  0x0000, 0x0000, OP_EQ,  0, S1_TCPFG, 4, S1_TCPFG, LD_SEQ,
2398e689cf4aSJeff Kirsher 	  0x081,  3, 0x0, 0xffff}, /* Load TCP seq # */
2399e689cf4aSJeff Kirsher 	{ "TCP control flags", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHL, 0,
2400e689cf4aSJeff Kirsher 	  S1_TCPHL, ST_FLG, 0x045,  3, 0x0, 0x002f}, /* Load TCP flags */
2401e689cf4aSJeff Kirsher 	{ "TCP length", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHc, 0, S1_TCPHc,
2402e689cf4aSJeff Kirsher 	  LD_R1,  0x205,  3, 0xB, 0xf000},
2403e689cf4aSJeff Kirsher 	{ "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0,
2404e689cf4aSJeff Kirsher 	  S1_PCKT,  LD_HDR, 0x0ff,  3, 0x0, 0xffff},
2405e689cf4aSJeff Kirsher 	{ "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_CLNP2, 0, S1_CLNP2,
2406e689cf4aSJeff Kirsher 	  IM_SAP, 0x6AE,  3, 0x0, 0xffff} ,
2407e689cf4aSJeff Kirsher 	{ "Cleanup 2", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
2408e689cf4aSJeff Kirsher 	  IM_CTL, 0x001,  3, 0x0, 0x0001},
2409e689cf4aSJeff Kirsher 	{ NULL },
2410e689cf4aSJeff Kirsher };
2411e689cf4aSJeff Kirsher #ifdef HP_WORKAROUND_DEFAULT
2412e689cf4aSJeff Kirsher #define CAS_HP_FIRMWARE               cas_prog_workaroundtab
2413e689cf4aSJeff Kirsher #endif
2414e689cf4aSJeff Kirsher #endif
2415e689cf4aSJeff Kirsher 
2416e689cf4aSJeff Kirsher #ifdef USE_HP_ENCRYPT
2417e689cf4aSJeff Kirsher static cas_hp_inst_t  cas_prog_encryptiontab[] = {
2418e689cf4aSJeff Kirsher 	{ "packet arrival?", 0xffff, 0x0000, OP_NP,  6, S1_VLAN,  0,
2419e689cf4aSJeff Kirsher 	  S1_PCKT,  CL_REG, 0x3ff,  1, 0x0, 0x0000},
2420e689cf4aSJeff Kirsher 	{ "VLAN?", 0xffff, 0x8100, OP_EQ,  1, S1_CFI,   0, S1_8023,
2421e689cf4aSJeff Kirsher 	  IM_CTL, 0x00a,  3, 0x0, 0xffff},
2422e689cf4aSJeff Kirsher #if 0
2423e689cf4aSJeff Kirsher //"CFI?", /* 02 FIND CFI and If FIND go to S1_DROP */
2424e689cf4aSJeff Kirsher //0x1000, 0x1000, OP_EQ,  0, S1_DROP,  1, S1_8023,  CL_REG, 0x000,  0, 0x0, 0x00
2425e689cf4aSJeff Kirsher 	00,
2426e689cf4aSJeff Kirsher #endif
2427e689cf4aSJeff Kirsher 	{ "CFI?", /* FIND CFI and If FIND go to CleanUP1 (ignore and send to host) */
2428e689cf4aSJeff Kirsher 	  0x1000, 0x1000, OP_EQ,  0, S1_CLNP,  1, S1_8023,
2429e689cf4aSJeff Kirsher 	  CL_REG, 0x000,  0, 0x0, 0x0000},
2430e689cf4aSJeff Kirsher 	{ "8023?", 0xffff, 0x0600, OP_LT,  1, S1_LLC,   0, S1_IPV4,
2431e689cf4aSJeff Kirsher 	  CL_REG, 0x000,  0, 0x0, 0x0000},
2432e689cf4aSJeff Kirsher 	{ "LLC?", 0xffff, 0xaaaa, OP_EQ,  1, S1_LLCc,  0, S1_CLNP,
2433e689cf4aSJeff Kirsher 	  CL_REG, 0x000,  0, 0x0, 0x0000},
2434e689cf4aSJeff Kirsher 	{ "LLCc?", 0xff00, 0x0300, OP_EQ,  2, S1_IPV4,  0, S1_CLNP,
2435e689cf4aSJeff Kirsher 	  CL_REG, 0x000,  0, 0x0, 0x0000},
2436e689cf4aSJeff Kirsher 	{ "IPV4?", 0xffff, 0x0800, OP_EQ,  1, S1_IPV4c, 0, S1_IPV6,
2437e689cf4aSJeff Kirsher 	  LD_SAP, 0x100,  3, 0x0, 0xffff},
2438e689cf4aSJeff Kirsher 	{ "IPV4 cont?", 0xff00, 0x4500, OP_EQ,  3, S1_IPV4F, 0, S1_CLNP,
2439e689cf4aSJeff Kirsher 	  LD_SUM, 0x00a,  1, 0x0, 0x0000},
2440e689cf4aSJeff Kirsher 	{ "IPV4 frag?", 0x3fff, 0x0000, OP_EQ,  1, S1_TCP44, 0, S1_CLNP,
2441e689cf4aSJeff Kirsher 	  LD_LEN, 0x03e,  1, 0x0, 0xffff},
2442e689cf4aSJeff Kirsher 	{ "TCP44?", 0x00ff, 0x0006, OP_EQ,  7, S1_TCPSQ, 0, S1_ESP4,
2443e689cf4aSJeff Kirsher 	  LD_FID, 0x182,  1, 0x0, 0xffff}, /* FID IP4&TCP src+dst */
2444e689cf4aSJeff Kirsher 	{ "IPV6?", 0xffff, 0x86dd, OP_EQ,  1, S1_IPV6L, 0, S1_CLNP,
2445e689cf4aSJeff Kirsher 	  LD_SUM, 0x015,  1, 0x0, 0x0000},
2446e689cf4aSJeff Kirsher 	{ "IPV6 len", 0xf000, 0x6000, OP_EQ,  0, S1_IPV6c, 0, S1_CLNP,
2447e689cf4aSJeff Kirsher 	  IM_R1,  0x128,  1, 0x0, 0xffff},
2448e689cf4aSJeff Kirsher 	{ "IPV6 cont?", 0x0000, 0x0000, OP_EQ,  3, S1_TCP64, 0, S1_CLNP,
2449e689cf4aSJeff Kirsher 	  LD_FID, 0x484,  1, 0x0, 0xffff}, /*  FID IP6&TCP src+dst */
2450e689cf4aSJeff Kirsher 	{ "TCP64?",
2451e689cf4aSJeff Kirsher #if 0
2452e689cf4aSJeff Kirsher //@@@0xff00, 0x0600, OP_EQ, 18, S1_TCPSQ, 0, S1_ESP6,  LD_LEN, 0x03f,  1, 0x0, 0xffff,
2453e689cf4aSJeff Kirsher #endif
2454e689cf4aSJeff Kirsher 	  0xff00, 0x0600, OP_EQ, 12, S1_TCPSQ, 0, S1_ESP6,  LD_LEN,
2455e689cf4aSJeff Kirsher 	  0x03f,  1, 0x0, 0xffff},
2456e689cf4aSJeff Kirsher 	{ "TCP seq", /* 14:DADDR should point to dest port */
2457e689cf4aSJeff Kirsher 	  0xFFFF, 0x0080, OP_EQ,  0, S2_HTTP,  0, S1_TCPFG, LD_SEQ,
2458e689cf4aSJeff Kirsher 	  0x081,  3, 0x0, 0xffff}, /* Load TCP seq # */
2459e689cf4aSJeff Kirsher 	{ "TCP control flags", 0xFFFF, 0x8080, OP_EQ,  0, S2_HTTP,  0,
2460e689cf4aSJeff Kirsher 	  S1_TCPHL, ST_FLG, 0x145,  2, 0x0, 0x002f}, /* Load TCP flags */
2461e689cf4aSJeff Kirsher 	{ "TCP length", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHc, 0, S1_TCPHc,
2462e689cf4aSJeff Kirsher 	  LD_R1,  0x205,  3, 0xB, 0xf000} ,
2463e689cf4aSJeff Kirsher 	{ "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0,
2464e689cf4aSJeff Kirsher 	  S1_PCKT,  LD_HDR, 0x0ff,  3, 0x0, 0xffff},
2465e689cf4aSJeff Kirsher 	{ "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_CLNP2,  0, S1_CLNP2,
2466e689cf4aSJeff Kirsher 	  IM_CTL, 0x001,  3, 0x0, 0x0001},
2467e689cf4aSJeff Kirsher 	{ "Cleanup 2", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
2468e689cf4aSJeff Kirsher 	  CL_REG, 0x002,  3, 0x0, 0x0000},
2469e689cf4aSJeff Kirsher 	{ "Drop packet", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
2470e689cf4aSJeff Kirsher 	  IM_CTL, 0x080,  3, 0x0, 0xffff},
2471e689cf4aSJeff Kirsher 	{ "No HTTP", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
2472e689cf4aSJeff Kirsher 	  IM_CTL, 0x044,  3, 0x0, 0xffff},
2473e689cf4aSJeff Kirsher 	{ "IPV4 ESP encrypted?",  /* S1_ESP4 */
2474e689cf4aSJeff Kirsher 	  0x00ff, 0x0032, OP_EQ,  0, S1_CLNP2, 0, S1_AH4, IM_CTL,
2475e689cf4aSJeff Kirsher 	  0x021, 1,  0x0, 0xffff},
2476e689cf4aSJeff Kirsher 	{ "IPV4 AH encrypted?",   /* S1_AH4 */
2477e689cf4aSJeff Kirsher 	  0x00ff, 0x0033, OP_EQ,  0, S1_CLNP2, 0, S1_CLNP, IM_CTL,
2478e689cf4aSJeff Kirsher 	  0x021, 1,  0x0, 0xffff},
2479e689cf4aSJeff Kirsher 	{ "IPV6 ESP encrypted?",  /* S1_ESP6 */
2480e689cf4aSJeff Kirsher #if 0
2481e689cf4aSJeff Kirsher //@@@0x00ff, 0x0032, OP_EQ,  0, S1_CLNP2, 0, S1_AH6, IM_CTL, 0x021, 1,  0x0, 0xffff,
2482e689cf4aSJeff Kirsher #endif
2483e689cf4aSJeff Kirsher 	  0xff00, 0x3200, OP_EQ,  0, S1_CLNP2, 0, S1_AH6, IM_CTL,
2484e689cf4aSJeff Kirsher 	  0x021, 1,  0x0, 0xffff},
2485e689cf4aSJeff Kirsher 	{ "IPV6 AH encrypted?",   /* S1_AH6 */
2486e689cf4aSJeff Kirsher #if 0
2487e689cf4aSJeff Kirsher //@@@0x00ff, 0x0033, OP_EQ,  0, S1_CLNP2, 0, S1_CLNP, IM_CTL, 0x021, 1,  0x0, 0xffff,
2488e689cf4aSJeff Kirsher #endif
2489e689cf4aSJeff Kirsher 	  0xff00, 0x3300, OP_EQ,  0, S1_CLNP2, 0, S1_CLNP, IM_CTL,
2490e689cf4aSJeff Kirsher 	  0x021, 1,  0x0, 0xffff},
2491e689cf4aSJeff Kirsher 	{ NULL },
2492e689cf4aSJeff Kirsher };
2493e689cf4aSJeff Kirsher #ifdef HP_ENCRYPT_DEFAULT
2494e689cf4aSJeff Kirsher #define CAS_HP_FIRMWARE               cas_prog_encryptiontab
2495e689cf4aSJeff Kirsher #endif
2496e689cf4aSJeff Kirsher #endif
2497e689cf4aSJeff Kirsher 
2498e689cf4aSJeff Kirsher static cas_hp_inst_t cas_prog_null[] = { {NULL} };
2499e689cf4aSJeff Kirsher #ifdef HP_NULL_DEFAULT
2500e689cf4aSJeff Kirsher #define CAS_HP_FIRMWARE               cas_prog_null
2501e689cf4aSJeff Kirsher #endif
2502e689cf4aSJeff Kirsher 
2503e689cf4aSJeff Kirsher /* phy types */
2504e689cf4aSJeff Kirsher #define   CAS_PHY_UNKNOWN       0x00
2505e689cf4aSJeff Kirsher #define   CAS_PHY_SERDES        0x01
2506e689cf4aSJeff Kirsher #define   CAS_PHY_MII_MDIO0     0x02
2507e689cf4aSJeff Kirsher #define   CAS_PHY_MII_MDIO1     0x04
2508e689cf4aSJeff Kirsher #define   CAS_PHY_MII(x)        ((x) & (CAS_PHY_MII_MDIO0 | CAS_PHY_MII_MDIO1))
2509e689cf4aSJeff Kirsher 
2510e689cf4aSJeff Kirsher /* _RING_INDEX is the index for the ring sizes to be used.  _RING_SIZE
2511e689cf4aSJeff Kirsher  * is the actual size. the default index for the various rings is
2512e689cf4aSJeff Kirsher  * 8. NOTE: there a bunch of alignment constraints for the rings. to
2513e689cf4aSJeff Kirsher  * deal with that, i just allocate rings to create the desired
2514e689cf4aSJeff Kirsher  * alignment. here are the constraints:
2515e689cf4aSJeff Kirsher  *   RX DESC and COMP rings must be 8KB aligned
2516e689cf4aSJeff Kirsher  *   TX DESC must be 2KB aligned.
2517e689cf4aSJeff Kirsher  * if you change the numbers, be cognizant of how the alignment will change
2518e689cf4aSJeff Kirsher  * in INIT_BLOCK as well.
2519e689cf4aSJeff Kirsher  */
2520e689cf4aSJeff Kirsher 
2521e689cf4aSJeff Kirsher #define DESC_RING_I_TO_S(x)  (32*(1 << (x)))
2522e689cf4aSJeff Kirsher #define COMP_RING_I_TO_S(x)  (128*(1 << (x)))
2523e689cf4aSJeff Kirsher #define TX_DESC_RING_INDEX 4  /* 512 = 8k */
2524e689cf4aSJeff Kirsher #define RX_DESC_RING_INDEX 4  /* 512 = 8k */
2525e689cf4aSJeff Kirsher #define RX_COMP_RING_INDEX 4  /* 2048 = 64k: should be 4x rx ring size */
2526e689cf4aSJeff Kirsher 
2527e689cf4aSJeff Kirsher #if (TX_DESC_RING_INDEX > 8) || (TX_DESC_RING_INDEX < 0)
2528e689cf4aSJeff Kirsher #error TX_DESC_RING_INDEX must be between 0 and 8
2529e689cf4aSJeff Kirsher #endif
2530e689cf4aSJeff Kirsher 
2531e689cf4aSJeff Kirsher #if (RX_DESC_RING_INDEX > 8) || (RX_DESC_RING_INDEX < 0)
2532e689cf4aSJeff Kirsher #error RX_DESC_RING_INDEX must be between 0 and 8
2533e689cf4aSJeff Kirsher #endif
2534e689cf4aSJeff Kirsher 
2535e689cf4aSJeff Kirsher #if (RX_COMP_RING_INDEX > 8) || (RX_COMP_RING_INDEX < 0)
2536e689cf4aSJeff Kirsher #error RX_COMP_RING_INDEX must be between 0 and 8
2537e689cf4aSJeff Kirsher #endif
2538e689cf4aSJeff Kirsher 
2539e689cf4aSJeff Kirsher #define N_TX_RINGS                    MAX_TX_RINGS      /* for QoS */
2540e689cf4aSJeff Kirsher #define N_TX_RINGS_MASK               MAX_TX_RINGS_MASK
2541e689cf4aSJeff Kirsher #define N_RX_DESC_RINGS               MAX_RX_DESC_RINGS /* 1 for ipsec */
2542e689cf4aSJeff Kirsher #define N_RX_COMP_RINGS               0x1 /* for mult. PCI interrupts */
2543e689cf4aSJeff Kirsher 
2544e689cf4aSJeff Kirsher /* number of flows that can go through re-assembly */
2545e689cf4aSJeff Kirsher #define N_RX_FLOWS                    64
2546e689cf4aSJeff Kirsher 
2547e689cf4aSJeff Kirsher #define TX_DESC_RING_SIZE  DESC_RING_I_TO_S(TX_DESC_RING_INDEX)
2548e689cf4aSJeff Kirsher #define RX_DESC_RING_SIZE  DESC_RING_I_TO_S(RX_DESC_RING_INDEX)
2549e689cf4aSJeff Kirsher #define RX_COMP_RING_SIZE  COMP_RING_I_TO_S(RX_COMP_RING_INDEX)
2550e689cf4aSJeff Kirsher #define TX_DESC_RINGN_INDEX(x) TX_DESC_RING_INDEX
2551e689cf4aSJeff Kirsher #define RX_DESC_RINGN_INDEX(x) RX_DESC_RING_INDEX
2552e689cf4aSJeff Kirsher #define RX_COMP_RINGN_INDEX(x) RX_COMP_RING_INDEX
2553e689cf4aSJeff Kirsher #define TX_DESC_RINGN_SIZE(x)  TX_DESC_RING_SIZE
2554e689cf4aSJeff Kirsher #define RX_DESC_RINGN_SIZE(x)  RX_DESC_RING_SIZE
2555e689cf4aSJeff Kirsher #define RX_COMP_RINGN_SIZE(x)  RX_COMP_RING_SIZE
2556e689cf4aSJeff Kirsher 
2557e689cf4aSJeff Kirsher /* convert values */
2558e689cf4aSJeff Kirsher #define CAS_BASE(x, y)                (((y) << (x ## _SHIFT)) & (x ## _MASK))
2559e689cf4aSJeff Kirsher #define CAS_VAL(x, y)                 (((y) & (x ## _MASK)) >> (x ## _SHIFT))
2560e689cf4aSJeff Kirsher #define CAS_TX_RINGN_BASE(y)          ((TX_DESC_RINGN_INDEX(y) << \
2561e689cf4aSJeff Kirsher                                         TX_CFG_DESC_RINGN_SHIFT(y)) & \
2562e689cf4aSJeff Kirsher                                         TX_CFG_DESC_RINGN_MASK(y))
2563e689cf4aSJeff Kirsher 
2564e689cf4aSJeff Kirsher /* min is 2k, but we can't do jumbo frames unless it's at least 8k */
2565e689cf4aSJeff Kirsher #define CAS_MIN_PAGE_SHIFT            11 /* 2048 */
2566e689cf4aSJeff Kirsher #define CAS_JUMBO_PAGE_SHIFT          13 /* 8192 */
2567e689cf4aSJeff Kirsher #define CAS_MAX_PAGE_SHIFT            14 /* 16384 */
2568e689cf4aSJeff Kirsher 
2569e689cf4aSJeff Kirsher #define TX_DESC_BUFLEN_MASK         0x0000000000003FFFULL /* buffer length in
2570e689cf4aSJeff Kirsher 							     bytes. 0 - 9256 */
2571e689cf4aSJeff Kirsher #define TX_DESC_BUFLEN_SHIFT        0
2572e689cf4aSJeff Kirsher #define TX_DESC_CSUM_START_MASK     0x00000000001F8000ULL /* checksum start. #
2573e689cf4aSJeff Kirsher 							     of bytes to be
2574e689cf4aSJeff Kirsher 							     skipped before
2575e689cf4aSJeff Kirsher 							     csum calc begins.
2576e689cf4aSJeff Kirsher 							     value must be
2577e689cf4aSJeff Kirsher 							     even */
2578e689cf4aSJeff Kirsher #define TX_DESC_CSUM_START_SHIFT    15
2579e689cf4aSJeff Kirsher #define TX_DESC_CSUM_STUFF_MASK     0x000000001FE00000ULL /* checksum stuff.
2580e689cf4aSJeff Kirsher 							     byte offset w/in
2581e689cf4aSJeff Kirsher 							     the pkt for the
2582e689cf4aSJeff Kirsher 							     1st csum byte.
2583e689cf4aSJeff Kirsher 							     must be > 8 */
2584e689cf4aSJeff Kirsher #define TX_DESC_CSUM_STUFF_SHIFT    21
2585e689cf4aSJeff Kirsher #define TX_DESC_CSUM_EN             0x0000000020000000ULL /* enable checksum */
2586e689cf4aSJeff Kirsher #define TX_DESC_EOF                 0x0000000040000000ULL /* end of frame */
2587e689cf4aSJeff Kirsher #define TX_DESC_SOF                 0x0000000080000000ULL /* start of frame */
2588e689cf4aSJeff Kirsher #define TX_DESC_INTME               0x0000000100000000ULL /* interrupt me */
2589e689cf4aSJeff Kirsher #define TX_DESC_NO_CRC              0x0000000200000000ULL /* debugging only.
2590e689cf4aSJeff Kirsher 							     CRC will not be
2591e689cf4aSJeff Kirsher 							     inserted into
2592e689cf4aSJeff Kirsher 							     outgoing frame. */
2593e689cf4aSJeff Kirsher struct cas_tx_desc {
2594e689cf4aSJeff Kirsher 	__le64     control;
2595e689cf4aSJeff Kirsher 	__le64     buffer;
2596e689cf4aSJeff Kirsher };
2597e689cf4aSJeff Kirsher 
2598e689cf4aSJeff Kirsher /* descriptor ring for free buffers contains page-sized buffers. the index
2599e689cf4aSJeff Kirsher  * value is not used by the hw in any way. it's just stored and returned in
2600e689cf4aSJeff Kirsher  * the completion ring.
2601e689cf4aSJeff Kirsher  */
2602e689cf4aSJeff Kirsher struct cas_rx_desc {
2603e689cf4aSJeff Kirsher 	__le64     index;
2604e689cf4aSJeff Kirsher 	__le64     buffer;
2605e689cf4aSJeff Kirsher };
2606e689cf4aSJeff Kirsher 
2607e689cf4aSJeff Kirsher /* received packets are put on the completion ring. */
2608e689cf4aSJeff Kirsher /* word 1 */
2609e689cf4aSJeff Kirsher #define RX_COMP1_DATA_SIZE_MASK           0x0000000007FFE000ULL
2610e689cf4aSJeff Kirsher #define RX_COMP1_DATA_SIZE_SHIFT          13
2611e689cf4aSJeff Kirsher #define RX_COMP1_DATA_OFF_MASK            0x000001FFF8000000ULL
2612e689cf4aSJeff Kirsher #define RX_COMP1_DATA_OFF_SHIFT           27
2613e689cf4aSJeff Kirsher #define RX_COMP1_DATA_INDEX_MASK          0x007FFE0000000000ULL
2614e689cf4aSJeff Kirsher #define RX_COMP1_DATA_INDEX_SHIFT         41
2615e689cf4aSJeff Kirsher #define RX_COMP1_SKIP_MASK                0x0180000000000000ULL
2616e689cf4aSJeff Kirsher #define RX_COMP1_SKIP_SHIFT               55
2617e689cf4aSJeff Kirsher #define RX_COMP1_RELEASE_NEXT             0x0200000000000000ULL
2618e689cf4aSJeff Kirsher #define RX_COMP1_SPLIT_PKT                0x0400000000000000ULL
2619e689cf4aSJeff Kirsher #define RX_COMP1_RELEASE_FLOW             0x0800000000000000ULL
2620e689cf4aSJeff Kirsher #define RX_COMP1_RELEASE_DATA             0x1000000000000000ULL
2621e689cf4aSJeff Kirsher #define RX_COMP1_RELEASE_HDR              0x2000000000000000ULL
2622e689cf4aSJeff Kirsher #define RX_COMP1_TYPE_MASK                0xC000000000000000ULL
2623e689cf4aSJeff Kirsher #define RX_COMP1_TYPE_SHIFT               62
2624e689cf4aSJeff Kirsher 
2625e689cf4aSJeff Kirsher /* word 2 */
2626e689cf4aSJeff Kirsher #define RX_COMP2_NEXT_INDEX_MASK          0x00000007FFE00000ULL
2627e689cf4aSJeff Kirsher #define RX_COMP2_NEXT_INDEX_SHIFT         21
2628e689cf4aSJeff Kirsher #define RX_COMP2_HDR_SIZE_MASK            0x00000FF800000000ULL
2629e689cf4aSJeff Kirsher #define RX_COMP2_HDR_SIZE_SHIFT           35
2630e689cf4aSJeff Kirsher #define RX_COMP2_HDR_OFF_MASK             0x0003F00000000000ULL
2631e689cf4aSJeff Kirsher #define RX_COMP2_HDR_OFF_SHIFT            44
2632e689cf4aSJeff Kirsher #define RX_COMP2_HDR_INDEX_MASK           0xFFFC000000000000ULL
2633e689cf4aSJeff Kirsher #define RX_COMP2_HDR_INDEX_SHIFT          50
2634e689cf4aSJeff Kirsher 
2635e689cf4aSJeff Kirsher /* word 3 */
2636e689cf4aSJeff Kirsher #define RX_COMP3_SMALL_PKT                0x0000000000000001ULL
2637e689cf4aSJeff Kirsher #define RX_COMP3_JUMBO_PKT                0x0000000000000002ULL
2638e689cf4aSJeff Kirsher #define RX_COMP3_JUMBO_HDR_SPLIT_EN       0x0000000000000004ULL
2639e689cf4aSJeff Kirsher #define RX_COMP3_CSUM_START_MASK          0x000000000007F000ULL
2640e689cf4aSJeff Kirsher #define RX_COMP3_CSUM_START_SHIFT         12
2641e689cf4aSJeff Kirsher #define RX_COMP3_FLOWID_MASK              0x0000000001F80000ULL
2642e689cf4aSJeff Kirsher #define RX_COMP3_FLOWID_SHIFT             19
2643e689cf4aSJeff Kirsher #define RX_COMP3_OPCODE_MASK              0x000000000E000000ULL
2644e689cf4aSJeff Kirsher #define RX_COMP3_OPCODE_SHIFT             25
2645e689cf4aSJeff Kirsher #define RX_COMP3_FORCE_FLAG               0x0000000010000000ULL
2646e689cf4aSJeff Kirsher #define RX_COMP3_NO_ASSIST                0x0000000020000000ULL
2647e689cf4aSJeff Kirsher #define RX_COMP3_LOAD_BAL_MASK            0x000001F800000000ULL
2648e689cf4aSJeff Kirsher #define RX_COMP3_LOAD_BAL_SHIFT           35
2649e689cf4aSJeff Kirsher #define RX_PLUS_COMP3_ENC_PKT             0x0000020000000000ULL /* cas+ */
2650e689cf4aSJeff Kirsher #define RX_COMP3_L3_HEAD_OFF_MASK         0x0000FE0000000000ULL /* cas */
2651e689cf4aSJeff Kirsher #define RX_COMP3_L3_HEAD_OFF_SHIFT        41
2652e689cf4aSJeff Kirsher #define RX_PLUS_COMP_L3_HEAD_OFF_MASK     0x0000FC0000000000ULL /* cas+ */
2653e689cf4aSJeff Kirsher #define RX_PLUS_COMP_L3_HEAD_OFF_SHIFT    42
2654e689cf4aSJeff Kirsher #define RX_COMP3_SAP_MASK                 0xFFFF000000000000ULL
2655e689cf4aSJeff Kirsher #define RX_COMP3_SAP_SHIFT                48
2656e689cf4aSJeff Kirsher 
2657e689cf4aSJeff Kirsher /* word 4 */
2658e689cf4aSJeff Kirsher #define RX_COMP4_TCP_CSUM_MASK            0x000000000000FFFFULL
2659e689cf4aSJeff Kirsher #define RX_COMP4_TCP_CSUM_SHIFT           0
2660e689cf4aSJeff Kirsher #define RX_COMP4_PKT_LEN_MASK             0x000000003FFF0000ULL
2661e689cf4aSJeff Kirsher #define RX_COMP4_PKT_LEN_SHIFT            16
2662e689cf4aSJeff Kirsher #define RX_COMP4_PERFECT_MATCH_MASK       0x00000003C0000000ULL
2663e689cf4aSJeff Kirsher #define RX_COMP4_PERFECT_MATCH_SHIFT      30
2664e689cf4aSJeff Kirsher #define RX_COMP4_ZERO                     0x0000080000000000ULL
2665e689cf4aSJeff Kirsher #define RX_COMP4_HASH_VAL_MASK            0x0FFFF00000000000ULL
2666e689cf4aSJeff Kirsher #define RX_COMP4_HASH_VAL_SHIFT           44
2667e689cf4aSJeff Kirsher #define RX_COMP4_HASH_PASS                0x1000000000000000ULL
2668e689cf4aSJeff Kirsher #define RX_COMP4_BAD                      0x4000000000000000ULL
2669e689cf4aSJeff Kirsher #define RX_COMP4_LEN_MISMATCH             0x8000000000000000ULL
2670e689cf4aSJeff Kirsher 
2671e689cf4aSJeff Kirsher /* we encode the following: ring/index/release. only 14 bits
2672e689cf4aSJeff Kirsher  * are usable.
2673e689cf4aSJeff Kirsher  * NOTE: the encoding is dependent upon RX_DESC_RING_SIZE and
2674e689cf4aSJeff Kirsher  *       MAX_RX_DESC_RINGS. */
2675e689cf4aSJeff Kirsher #define RX_INDEX_NUM_MASK                 0x0000000000000FFFULL
2676e689cf4aSJeff Kirsher #define RX_INDEX_NUM_SHIFT                0
2677e689cf4aSJeff Kirsher #define RX_INDEX_RING_MASK                0x0000000000001000ULL
2678e689cf4aSJeff Kirsher #define RX_INDEX_RING_SHIFT               12
2679e689cf4aSJeff Kirsher #define RX_INDEX_RELEASE                  0x0000000000002000ULL
2680e689cf4aSJeff Kirsher 
2681e689cf4aSJeff Kirsher struct cas_rx_comp {
2682e689cf4aSJeff Kirsher 	__le64     word1;
2683e689cf4aSJeff Kirsher 	__le64     word2;
2684e689cf4aSJeff Kirsher 	__le64     word3;
2685e689cf4aSJeff Kirsher 	__le64     word4;
2686e689cf4aSJeff Kirsher };
2687e689cf4aSJeff Kirsher 
2688e689cf4aSJeff Kirsher enum link_state {
2689e689cf4aSJeff Kirsher 	link_down = 0,	/* No link, will retry */
2690e689cf4aSJeff Kirsher 	link_aneg,	/* Autoneg in progress */
2691e689cf4aSJeff Kirsher 	link_force_try,	/* Try Forced link speed */
2692e689cf4aSJeff Kirsher 	link_force_ret,	/* Forced mode worked, retrying autoneg */
2693e689cf4aSJeff Kirsher 	link_force_ok,	/* Stay in forced mode */
2694e689cf4aSJeff Kirsher 	link_up		/* Link is up */
2695e689cf4aSJeff Kirsher };
2696e689cf4aSJeff Kirsher 
2697e689cf4aSJeff Kirsher typedef struct cas_page {
2698e689cf4aSJeff Kirsher 	struct list_head list;
2699e689cf4aSJeff Kirsher 	struct page *buffer;
2700e689cf4aSJeff Kirsher 	dma_addr_t dma_addr;
2701e689cf4aSJeff Kirsher 	int used;
2702e689cf4aSJeff Kirsher } cas_page_t;
2703e689cf4aSJeff Kirsher 
2704e689cf4aSJeff Kirsher 
2705e689cf4aSJeff Kirsher /* some alignment constraints:
2706e689cf4aSJeff Kirsher  * TX DESC, RX DESC, and RX COMP must each be 8K aligned.
2707e689cf4aSJeff Kirsher  * TX COMPWB must be 8-byte aligned.
2708e689cf4aSJeff Kirsher  * to accomplish this, here's what we do:
2709e689cf4aSJeff Kirsher  *
2710e689cf4aSJeff Kirsher  * INIT_BLOCK_RX_COMP  = 64k (already aligned)
2711e689cf4aSJeff Kirsher  * INIT_BLOCK_RX_DESC  = 8k
2712e689cf4aSJeff Kirsher  * INIT_BLOCK_TX       = 8k
2713e689cf4aSJeff Kirsher  * INIT_BLOCK_RX1_DESC = 8k
2714e689cf4aSJeff Kirsher  * TX COMPWB
2715e689cf4aSJeff Kirsher  */
2716e689cf4aSJeff Kirsher #define INIT_BLOCK_TX           (TX_DESC_RING_SIZE)
2717e689cf4aSJeff Kirsher #define INIT_BLOCK_RX_DESC      (RX_DESC_RING_SIZE)
2718e689cf4aSJeff Kirsher #define INIT_BLOCK_RX_COMP      (RX_COMP_RING_SIZE)
2719e689cf4aSJeff Kirsher 
2720e689cf4aSJeff Kirsher struct cas_init_block {
2721e689cf4aSJeff Kirsher 	struct cas_rx_comp rxcs[N_RX_COMP_RINGS][INIT_BLOCK_RX_COMP];
2722e689cf4aSJeff Kirsher 	struct cas_rx_desc rxds[N_RX_DESC_RINGS][INIT_BLOCK_RX_DESC];
2723e689cf4aSJeff Kirsher 	struct cas_tx_desc txds[N_TX_RINGS][INIT_BLOCK_TX];
2724e689cf4aSJeff Kirsher 	__le64 tx_compwb;
2725e689cf4aSJeff Kirsher };
2726e689cf4aSJeff Kirsher 
2727e689cf4aSJeff Kirsher /* tiny buffers to deal with target abort issue. we allocate a bit
2728e689cf4aSJeff Kirsher  * over so that we don't have target abort issues with these buffers
2729e689cf4aSJeff Kirsher  * as well.
2730e689cf4aSJeff Kirsher  */
2731e689cf4aSJeff Kirsher #define TX_TINY_BUF_LEN    0x100
2732e689cf4aSJeff Kirsher #define TX_TINY_BUF_BLOCK  ((INIT_BLOCK_TX + 1)*TX_TINY_BUF_LEN)
2733e689cf4aSJeff Kirsher 
2734e689cf4aSJeff Kirsher struct cas_tiny_count {
2735e689cf4aSJeff Kirsher 	int nbufs;
2736e689cf4aSJeff Kirsher 	int used;
2737e689cf4aSJeff Kirsher };
2738e689cf4aSJeff Kirsher 
2739e689cf4aSJeff Kirsher struct cas {
2740e689cf4aSJeff Kirsher 	spinlock_t lock; /* for most bits */
2741e689cf4aSJeff Kirsher 	spinlock_t tx_lock[N_TX_RINGS]; /* tx bits */
2742e689cf4aSJeff Kirsher 	spinlock_t stat_lock[N_TX_RINGS + 1]; /* for stat gathering */
2743e689cf4aSJeff Kirsher 	spinlock_t rx_inuse_lock; /* rx inuse list */
2744e689cf4aSJeff Kirsher 	spinlock_t rx_spare_lock; /* rx spare list */
2745e689cf4aSJeff Kirsher 
2746e689cf4aSJeff Kirsher 	void __iomem *regs;
2747e689cf4aSJeff Kirsher 	int tx_new[N_TX_RINGS], tx_old[N_TX_RINGS];
2748e689cf4aSJeff Kirsher 	int rx_old[N_RX_DESC_RINGS];
2749e689cf4aSJeff Kirsher 	int rx_cur[N_RX_COMP_RINGS], rx_new[N_RX_COMP_RINGS];
2750e689cf4aSJeff Kirsher 	int rx_last[N_RX_DESC_RINGS];
2751e689cf4aSJeff Kirsher 
2752e689cf4aSJeff Kirsher 	struct napi_struct napi;
2753e689cf4aSJeff Kirsher 
2754e689cf4aSJeff Kirsher 	/* Set when chip is actually in operational state
2755e689cf4aSJeff Kirsher 	 * (ie. not power managed) */
2756e689cf4aSJeff Kirsher 	int hw_running;
2757e689cf4aSJeff Kirsher 	int opened;
2758e689cf4aSJeff Kirsher 	struct mutex pm_mutex; /* open/close/suspend/resume */
2759e689cf4aSJeff Kirsher 
2760e689cf4aSJeff Kirsher 	struct cas_init_block *init_block;
2761e689cf4aSJeff Kirsher 	struct cas_tx_desc *init_txds[MAX_TX_RINGS];
2762e689cf4aSJeff Kirsher 	struct cas_rx_desc *init_rxds[MAX_RX_DESC_RINGS];
2763e689cf4aSJeff Kirsher 	struct cas_rx_comp *init_rxcs[MAX_RX_COMP_RINGS];
2764e689cf4aSJeff Kirsher 
2765e689cf4aSJeff Kirsher 	/* we use sk_buffs for tx and pages for rx. the rx skbuffs
2766e689cf4aSJeff Kirsher 	 * are there for flow re-assembly. */
2767e689cf4aSJeff Kirsher 	struct sk_buff      *tx_skbs[N_TX_RINGS][TX_DESC_RING_SIZE];
2768e689cf4aSJeff Kirsher 	struct sk_buff_head  rx_flows[N_RX_FLOWS];
2769e689cf4aSJeff Kirsher 	cas_page_t          *rx_pages[N_RX_DESC_RINGS][RX_DESC_RING_SIZE];
2770e689cf4aSJeff Kirsher 	struct list_head     rx_spare_list, rx_inuse_list;
2771e689cf4aSJeff Kirsher 	int                  rx_spares_needed;
2772e689cf4aSJeff Kirsher 
2773e689cf4aSJeff Kirsher 	/* for small packets when copying would be quicker than
2774e689cf4aSJeff Kirsher 	   mapping */
2775e689cf4aSJeff Kirsher 	struct cas_tiny_count tx_tiny_use[N_TX_RINGS][TX_DESC_RING_SIZE];
2776e689cf4aSJeff Kirsher 	u8 *tx_tiny_bufs[N_TX_RINGS];
2777e689cf4aSJeff Kirsher 
2778e689cf4aSJeff Kirsher 	u32			msg_enable;
2779e689cf4aSJeff Kirsher 
2780e689cf4aSJeff Kirsher 	/* N_TX_RINGS must be >= N_RX_DESC_RINGS */
2781e689cf4aSJeff Kirsher 	struct net_device_stats net_stats[N_TX_RINGS + 1];
2782e689cf4aSJeff Kirsher 
2783e689cf4aSJeff Kirsher 	u32			pci_cfg[64 >> 2];
2784e689cf4aSJeff Kirsher 	u8                      pci_revision;
2785e689cf4aSJeff Kirsher 
2786e689cf4aSJeff Kirsher 	int                     phy_type;
2787e689cf4aSJeff Kirsher 	int			phy_addr;
2788e689cf4aSJeff Kirsher 	u32                     phy_id;
2789e689cf4aSJeff Kirsher #define CAS_FLAG_1000MB_CAP     0x00000001
2790e689cf4aSJeff Kirsher #define CAS_FLAG_REG_PLUS       0x00000002
2791e689cf4aSJeff Kirsher #define CAS_FLAG_TARGET_ABORT   0x00000004
2792e689cf4aSJeff Kirsher #define CAS_FLAG_SATURN         0x00000008
2793e689cf4aSJeff Kirsher #define CAS_FLAG_RXD_POST_MASK  0x000000F0
2794e689cf4aSJeff Kirsher #define CAS_FLAG_RXD_POST_SHIFT 4
2795e689cf4aSJeff Kirsher #define CAS_FLAG_RXD_POST(x)    ((1 << (CAS_FLAG_RXD_POST_SHIFT + (x))) & \
2796e689cf4aSJeff Kirsher                                  CAS_FLAG_RXD_POST_MASK)
2797e689cf4aSJeff Kirsher #define CAS_FLAG_ENTROPY_DEV    0x00000100
2798e689cf4aSJeff Kirsher #define CAS_FLAG_NO_HW_CSUM     0x00000200
2799e689cf4aSJeff Kirsher 	u32                     cas_flags;
2800e689cf4aSJeff Kirsher 	int                     packet_min; /* minimum packet size */
2801e689cf4aSJeff Kirsher 	int			tx_fifo_size;
2802e689cf4aSJeff Kirsher 	int			rx_fifo_size;
2803e689cf4aSJeff Kirsher 	int			rx_pause_off;
2804e689cf4aSJeff Kirsher 	int			rx_pause_on;
2805e689cf4aSJeff Kirsher 	int                     crc_size;      /* 4 if half-duplex */
2806e689cf4aSJeff Kirsher 
2807e689cf4aSJeff Kirsher 	int                     pci_irq_INTC;
2808e689cf4aSJeff Kirsher 	int                     min_frame_size; /* for tx fifo workaround */
2809e689cf4aSJeff Kirsher 
2810e689cf4aSJeff Kirsher 	/* page size allocation */
2811e689cf4aSJeff Kirsher 	int                     page_size;
2812e689cf4aSJeff Kirsher 	int                     page_order;
2813e689cf4aSJeff Kirsher 	int                     mtu_stride;
2814e689cf4aSJeff Kirsher 
2815e689cf4aSJeff Kirsher 	u32			mac_rx_cfg;
2816e689cf4aSJeff Kirsher 
2817e689cf4aSJeff Kirsher 	/* Autoneg & PHY control */
2818e689cf4aSJeff Kirsher 	int			link_cntl;
2819e689cf4aSJeff Kirsher 	int			link_fcntl;
2820e689cf4aSJeff Kirsher 	enum link_state		lstate;
2821e689cf4aSJeff Kirsher 	struct timer_list	link_timer;
2822e689cf4aSJeff Kirsher 	int			timer_ticks;
2823e689cf4aSJeff Kirsher 	struct work_struct	reset_task;
2824e689cf4aSJeff Kirsher #if 0
2825e689cf4aSJeff Kirsher 	atomic_t		reset_task_pending;
2826e689cf4aSJeff Kirsher #else
2827e689cf4aSJeff Kirsher 	atomic_t		reset_task_pending;
2828e689cf4aSJeff Kirsher 	atomic_t		reset_task_pending_mtu;
2829e689cf4aSJeff Kirsher 	atomic_t		reset_task_pending_spare;
2830e689cf4aSJeff Kirsher 	atomic_t		reset_task_pending_all;
2831e689cf4aSJeff Kirsher #endif
2832e689cf4aSJeff Kirsher 
2833e689cf4aSJeff Kirsher 	/* Link-down problem workaround */
2834e689cf4aSJeff Kirsher #define LINK_TRANSITION_UNKNOWN 	0
2835e689cf4aSJeff Kirsher #define LINK_TRANSITION_ON_FAILURE 	1
2836e689cf4aSJeff Kirsher #define LINK_TRANSITION_STILL_FAILED 	2
2837e689cf4aSJeff Kirsher #define LINK_TRANSITION_LINK_UP 	3
2838e689cf4aSJeff Kirsher #define LINK_TRANSITION_LINK_CONFIG	4
2839e689cf4aSJeff Kirsher #define LINK_TRANSITION_LINK_DOWN	5
2840e689cf4aSJeff Kirsher #define LINK_TRANSITION_REQUESTED_RESET	6
2841e689cf4aSJeff Kirsher 	int			link_transition;
2842e689cf4aSJeff Kirsher 	int 			link_transition_jiffies_valid;
2843e689cf4aSJeff Kirsher 	unsigned long		link_transition_jiffies;
2844e689cf4aSJeff Kirsher 
2845e689cf4aSJeff Kirsher 	/* Tuning */
2846e689cf4aSJeff Kirsher 	u8 orig_cacheline_size;	/* value when loaded */
2847e689cf4aSJeff Kirsher #define CAS_PREF_CACHELINE_SIZE	 0x20	/* Minimum desired */
2848e689cf4aSJeff Kirsher 
2849e689cf4aSJeff Kirsher 	/* Diagnostic counters and state. */
2850e689cf4aSJeff Kirsher 	int 			casreg_len; /* reg-space size for dumping */
2851e689cf4aSJeff Kirsher 	u64			pause_entered;
2852e689cf4aSJeff Kirsher 	u16			pause_last_time_recvd;
2853e689cf4aSJeff Kirsher 
2854e689cf4aSJeff Kirsher 	dma_addr_t block_dvma, tx_tiny_dvma[N_TX_RINGS];
2855e689cf4aSJeff Kirsher 	struct pci_dev *pdev;
2856e689cf4aSJeff Kirsher 	struct net_device *dev;
2857e689cf4aSJeff Kirsher #if defined(CONFIG_OF)
2858e689cf4aSJeff Kirsher 	struct device_node	*of_node;
2859e689cf4aSJeff Kirsher #endif
2860e689cf4aSJeff Kirsher 
2861e689cf4aSJeff Kirsher 	/* Firmware Info */
2862e689cf4aSJeff Kirsher 	u16			fw_load_addr;
2863e689cf4aSJeff Kirsher 	u32			fw_size;
2864e689cf4aSJeff Kirsher 	u8			*fw_data;
2865e689cf4aSJeff Kirsher };
2866e689cf4aSJeff Kirsher 
2867e689cf4aSJeff Kirsher #define TX_DESC_NEXT(r, x)  (((x) + 1) & (TX_DESC_RINGN_SIZE(r) - 1))
2868e689cf4aSJeff Kirsher #define RX_DESC_ENTRY(r, x) ((x) & (RX_DESC_RINGN_SIZE(r) - 1))
2869e689cf4aSJeff Kirsher #define RX_COMP_ENTRY(r, x) ((x) & (RX_COMP_RINGN_SIZE(r) - 1))
2870e689cf4aSJeff Kirsher 
2871e689cf4aSJeff Kirsher #define TX_BUFF_COUNT(r, x, y)    ((x) <= (y) ? ((y) - (x)) : \
2872e689cf4aSJeff Kirsher         (TX_DESC_RINGN_SIZE(r) - (x) + (y)))
2873e689cf4aSJeff Kirsher 
2874e689cf4aSJeff Kirsher #define TX_BUFFS_AVAIL(cp, i)	((cp)->tx_old[(i)] <= (cp)->tx_new[(i)] ? \
2875e689cf4aSJeff Kirsher         (cp)->tx_old[(i)] + (TX_DESC_RINGN_SIZE(i) - 1) - (cp)->tx_new[(i)] : \
2876e689cf4aSJeff Kirsher         (cp)->tx_old[(i)] - (cp)->tx_new[(i)] - 1)
2877e689cf4aSJeff Kirsher 
2878e689cf4aSJeff Kirsher #define CAS_ALIGN(addr, align) \
2879e689cf4aSJeff Kirsher      (((unsigned long) (addr) + ((align) - 1UL)) & ~((align) - 1))
2880e689cf4aSJeff Kirsher 
2881e689cf4aSJeff Kirsher #define RX_FIFO_SIZE                  16384
2882e689cf4aSJeff Kirsher #define EXPANSION_ROM_SIZE            65536
2883e689cf4aSJeff Kirsher 
2884e689cf4aSJeff Kirsher #define CAS_MC_EXACT_MATCH_SIZE       15
2885e689cf4aSJeff Kirsher #define CAS_MC_HASH_SIZE              256
2886e689cf4aSJeff Kirsher #define CAS_MC_HASH_MAX              (CAS_MC_EXACT_MATCH_SIZE + \
2887e689cf4aSJeff Kirsher                                       CAS_MC_HASH_SIZE)
2888e689cf4aSJeff Kirsher 
2889e689cf4aSJeff Kirsher #define TX_TARGET_ABORT_LEN           0x20
2890e689cf4aSJeff Kirsher #define RX_SWIVEL_OFF_VAL             0x2
2891e689cf4aSJeff Kirsher #define RX_AE_FREEN_VAL(x)            (RX_DESC_RINGN_SIZE(x) >> 1)
2892e689cf4aSJeff Kirsher #define RX_AE_COMP_VAL                (RX_COMP_RING_SIZE >> 1)
2893e689cf4aSJeff Kirsher #define RX_BLANK_INTR_PKT_VAL         0x05
2894e689cf4aSJeff Kirsher #define RX_BLANK_INTR_TIME_VAL        0x0F
2895e689cf4aSJeff Kirsher #define HP_TCP_THRESH_VAL             1530 /* reduce to enable reassembly */
2896e689cf4aSJeff Kirsher 
2897e689cf4aSJeff Kirsher #define RX_SPARE_COUNT                (RX_DESC_RING_SIZE >> 1)
2898e689cf4aSJeff Kirsher #define RX_SPARE_RECOVER_VAL          (RX_SPARE_COUNT >> 2)
2899e689cf4aSJeff Kirsher 
2900e689cf4aSJeff Kirsher #endif /* _CASSINI_H */
2901