1139749Simp/*-
274259Sjlemon * Copyright (c) 1995, David Greenman
374178Sjlemon * Copyright (c) 2001 Jonathan Lemon <jlemon@freebsd.org>
412510Sdg * All rights reserved.
512510Sdg *
612510Sdg * Redistribution and use in source and binary forms, with or without
712510Sdg * modification, are permitted provided that the following conditions
812510Sdg * are met:
912510Sdg * 1. Redistributions of source code must retain the above copyright
1012510Sdg *    notice unmodified, this list of conditions, and the following
1112510Sdg *    disclaimer.
1212510Sdg * 2. Redistributions in binary form must reproduce the above copyright
1312510Sdg *    notice, this list of conditions and the following disclaimer in the
1412510Sdg *    documentation and/or other materials provided with the distribution.
1512510Sdg *
1612510Sdg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1712510Sdg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1812510Sdg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1912510Sdg * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2012510Sdg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2112510Sdg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2212510Sdg * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2312510Sdg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2412510Sdg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2512510Sdg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2612510Sdg * SUCH DAMAGE.
2712510Sdg *
2850477Speter * $FreeBSD: stable/11/sys/dev/fxp/if_fxpreg.h 345186 2019-03-15 15:16:31Z markj $
2912510Sdg */
3012510Sdg
3112510Sdg#define FXP_PCI_MMBA	0x10
3212510Sdg#define FXP_PCI_IOBA	0x14
3312510Sdg
3429138Sdg/*
3529138Sdg * Control/status registers.
3629138Sdg */
3729138Sdg#define	FXP_CSR_SCB_RUSCUS	0	/* scb_rus/scb_cus (1 byte) */
3829138Sdg#define	FXP_CSR_SCB_STATACK	1	/* scb_statack (1 byte) */
3929138Sdg#define	FXP_CSR_SCB_COMMAND	2	/* scb_command (1 byte) */
4029138Sdg#define	FXP_CSR_SCB_INTRCNTL	3	/* scb_intrcntl (1 byte) */
4129138Sdg#define	FXP_CSR_SCB_GENERAL	4	/* scb_general (4 bytes) */
4229138Sdg#define	FXP_CSR_PORT		8	/* port (4 bytes) */
4329138Sdg#define	FXP_CSR_FLASHCONTROL	12	/* flash control (2 bytes) */
4429138Sdg#define	FXP_CSR_EEPROMCONTROL	14	/* eeprom control (2 bytes) */
4529138Sdg#define	FXP_CSR_MDICONTROL	16	/* mdi control (4 bytes) */
46215906Smarius#define	FXP_CSR_FC_THRESH	0x19	/* flow control (1 byte) */
47215906Smarius#define	FXP_CSR_FC_STATUS	0x1A	/* flow control status (1 byte) */
48185354Syongari#define	FXP_CSR_PMDR		0x1B	/* power management driver (1 byte) */
4982425Sjlemon#define	FXP_CSR_GENCONTROL	0x1C	/* general control (1 byte) */
5012510Sdg
5129138Sdg/*
5229138Sdg * FOR REFERENCE ONLY, the old definition of FXP_CSR_SCB_RUSCUS:
5329138Sdg *
54143167Smux *	volatile uint8_t	:2,
5529138Sdg *				scb_rus:4,
5629138Sdg *				scb_cus:2;
5729138Sdg */
5829138Sdg
5922255Sdg#define FXP_PORT_SOFTWARE_RESET		0
6022255Sdg#define FXP_PORT_SELFTEST		1
6122255Sdg#define FXP_PORT_SELECTIVE_RESET	2
6222255Sdg#define FXP_PORT_DUMP			3
6322255Sdg
6412510Sdg#define FXP_SCB_RUS_IDLE		0
6512510Sdg#define FXP_SCB_RUS_SUSPENDED		1
6612510Sdg#define FXP_SCB_RUS_NORESOURCES		2
6712510Sdg#define FXP_SCB_RUS_READY		4
6812510Sdg#define FXP_SCB_RUS_SUSP_NORBDS		9
6912510Sdg#define FXP_SCB_RUS_NORES_NORBDS	10
7012510Sdg#define FXP_SCB_RUS_READY_NORBDS	12
7112510Sdg
7212510Sdg#define FXP_SCB_CUS_IDLE		0
7312510Sdg#define FXP_SCB_CUS_SUSPENDED		1
7412510Sdg#define FXP_SCB_CUS_ACTIVE		2
7512510Sdg
7676526Sjlemon#define FXP_SCB_INTR_DISABLE		0x01	/* Disable all interrupts */
7776526Sjlemon#define FXP_SCB_INTR_SWI		0x02	/* Generate SWI */
7876526Sjlemon#define FXP_SCB_INTMASK_FCP		0x04
7976526Sjlemon#define FXP_SCB_INTMASK_ER		0x08
8076526Sjlemon#define FXP_SCB_INTMASK_RNR		0x10
8176526Sjlemon#define FXP_SCB_INTMASK_CNA		0x20
8276526Sjlemon#define FXP_SCB_INTMASK_FR		0x40
8376526Sjlemon#define FXP_SCB_INTMASK_CXTNO		0x80
8476526Sjlemon
8576526Sjlemon#define FXP_SCB_STATACK_FCP		0x01	/* Flow Control Pause */
8676526Sjlemon#define FXP_SCB_STATACK_ER		0x02	/* Early Receive */
8712510Sdg#define FXP_SCB_STATACK_SWI		0x04
8812510Sdg#define FXP_SCB_STATACK_MDI		0x08
8912510Sdg#define FXP_SCB_STATACK_RNR		0x10
9012510Sdg#define FXP_SCB_STATACK_CNA		0x20
9112510Sdg#define FXP_SCB_STATACK_FR		0x40
9212510Sdg#define FXP_SCB_STATACK_CXTNO		0x80
9312510Sdg
9412510Sdg#define FXP_SCB_COMMAND_CU_NOP		0x00
9512510Sdg#define FXP_SCB_COMMAND_CU_START	0x10
9612510Sdg#define FXP_SCB_COMMAND_CU_RESUME	0x20
9712510Sdg#define FXP_SCB_COMMAND_CU_DUMP_ADR	0x40
9812510Sdg#define FXP_SCB_COMMAND_CU_DUMP		0x50
9912510Sdg#define FXP_SCB_COMMAND_CU_BASE		0x60
10012510Sdg#define FXP_SCB_COMMAND_CU_DUMPRESET	0x70
10112510Sdg
10212510Sdg#define FXP_SCB_COMMAND_RU_NOP		0
10312510Sdg#define FXP_SCB_COMMAND_RU_START	1
10412510Sdg#define FXP_SCB_COMMAND_RU_RESUME	2
10512510Sdg#define FXP_SCB_COMMAND_RU_ABORT	4
10612510Sdg#define FXP_SCB_COMMAND_RU_LOADHDS	5
10712510Sdg#define FXP_SCB_COMMAND_RU_BASE		6
10812510Sdg#define FXP_SCB_COMMAND_RU_RBDRESUME	7
10912510Sdg
11012510Sdg/*
11112510Sdg * Command block definitions
11212510Sdg */
11312510Sdgstruct fxp_cb_nop {
114143167Smux	uint16_t cb_status;
115143167Smux	uint16_t cb_command;
116143167Smux	uint32_t link_addr;
11712510Sdg};
11812510Sdgstruct fxp_cb_ias {
119143167Smux	uint16_t cb_status;
120143167Smux	uint16_t cb_command;
121143167Smux	uint32_t link_addr;
122143167Smux	uint8_t macaddr[6];
12312510Sdg};
124113151Smux
12512510Sdg/* I hate bit-fields :-( */
126113151Smux#if BYTE_ORDER == LITTLE_ENDIAN
127113151Smux#define __FXP_BITFIELD2(a, b)			a, b
128113151Smux#define __FXP_BITFIELD3(a, b, c)		a, b, c
129113151Smux#define __FXP_BITFIELD4(a, b, c, d)		a, b, c, d
130113151Smux#define __FXP_BITFIELD5(a, b, c, d, e)		a, b, c, d, e
131113151Smux#define __FXP_BITFIELD6(a, b, c, d, e, f)	a, b, c, d, e, f
132113151Smux#define __FXP_BITFIELD7(a, b, c, d, e, f, g)	a, b, c, d, e, f, g
133113151Smux#define __FXP_BITFIELD8(a, b, c, d, e, f, g, h)	a, b, c, d, e, f, g, h
134113151Smux#else
135113151Smux#define __FXP_BITFIELD2(a, b)			b, a
136113151Smux#define __FXP_BITFIELD3(a, b, c)		c, b, a
137113151Smux#define __FXP_BITFIELD4(a, b, c, d)		d, c, b, a
138113151Smux#define __FXP_BITFIELD5(a, b, c, d, e)		e, d, c, b, a
139113151Smux#define __FXP_BITFIELD6(a, b, c, d, e, f)	f, e, d, c, b, a
140113151Smux#define __FXP_BITFIELD7(a, b, c, d, e, f, g)	g, f, e, d, c, b, a
141113151Smux#define __FXP_BITFIELD8(a, b, c, d, e, f, g, h)	h, g, f, e, d, c, b, a
142113151Smux#endif
143113151Smux
14412510Sdgstruct fxp_cb_config {
145143167Smux	uint16_t	cb_status;
146143167Smux	uint16_t	cb_command;
147143167Smux	uint32_t	link_addr;
148113151Smux
149113151Smux	/* Bytes 0 - 21 -- common to all i8255x */
150113183Smux	u_int		__FXP_BITFIELD2(byte_count:6, :2);
151113183Smux	u_int		__FXP_BITFIELD3(rx_fifo_limit:4, tx_fifo_limit:3, :1);
152143167Smux	uint8_t		adaptive_ifs;
153113183Smux	u_int		__FXP_BITFIELD5(mwi_enable:1,		/* 8,9 */
154113151Smux			    type_enable:1,			/* 8,9 */
155113151Smux			    read_align_en:1,			/* 8,9 */
156113151Smux			    end_wr_on_cl:1,			/* 8,9 */
157113151Smux			    :4);
158113183Smux	u_int		__FXP_BITFIELD2(rx_dma_bytecount:7, :1);
159113183Smux	u_int		__FXP_BITFIELD2(tx_dma_bytecount:7, dma_mbce:1);
160113183Smux	u_int		__FXP_BITFIELD8(late_scb:1,		/* 7 */
161113151Smux			    direct_dma_dis:1,			/* 8,9 */
162113151Smux			    tno_int_or_tco_en:1,		/* 7,9 */
163113151Smux			    ci_int:1,
164113151Smux			    ext_txcb_dis:1,			/* 8,9 */
165113151Smux			    ext_stats_dis:1,			/* 8,9 */
166113151Smux			    keep_overrun_rx:1,
167113151Smux			    save_bf:1);
168113183Smux	u_int		__FXP_BITFIELD6(disc_short_rx:1,
169113151Smux			    underrun_retry:2,
170113151Smux			    :2,
171113151Smux			    ext_rfa:1,				/* 550 */
172113151Smux			    two_frames:1,			/* 8,9 */
173113151Smux			    dyn_tbd:1);				/* 8,9 */
174113183Smux	u_int		__FXP_BITFIELD3(mediatype:1,		/* 7 */
175113151Smux			    :6,
176113151Smux			    csma_dis:1);			/* 8,9 */
177113183Smux	u_int		__FXP_BITFIELD6(tcp_udp_cksum:1,	/* 9 */
178113151Smux			    :3,
179113151Smux			    vlan_tco:1,				/* 8,9 */
180113151Smux			    link_wake_en:1,			/* 8,9 */
181113151Smux			    arp_wake_en:1,			/* 8 */
182113151Smux			    mc_wake_en:1);			/* 8 */
183113183Smux	u_int		__FXP_BITFIELD4(:3,
184113151Smux			    nsai:1,
185113151Smux			    preamble_length:2,
186113151Smux			    loopback:2);
187113183Smux	u_int		__FXP_BITFIELD2(linear_priority:3,	/* 7 */
188113151Smux			    :5);
189113183Smux	u_int		__FXP_BITFIELD3(linear_pri_mode:1,	/* 7 */
190113151Smux			    :3,
191113151Smux			    interfrm_spacing:4);
192113183Smux	u_int		:8;
193113183Smux	u_int		:8;
194113183Smux	u_int		__FXP_BITFIELD8(promiscuous:1,
195113151Smux			    bcast_disable:1,
196113151Smux			    wait_after_win:1,			/* 8,9 */
197113151Smux			    :1,
198113151Smux			    ignore_ul:1,			/* 8,9 */
199113151Smux			    crc16_en:1,				/* 9 */
200113151Smux			    :1,
201113151Smux			    crscdt:1);
202113183Smux	u_int		fc_delay_lsb:8;				/* 8,9 */
203113183Smux	u_int		fc_delay_msb:8;				/* 8,9 */
204113183Smux	u_int		__FXP_BITFIELD6(stripping:1,
205113151Smux			    padding:1,
206113151Smux			    rcv_crc_xfer:1,
207113151Smux			    long_rx_en:1,			/* 8,9 */
208113151Smux			    pri_fc_thresh:3,			/* 8,9 */
209113151Smux			    :1);
210113183Smux	u_int		__FXP_BITFIELD8(ia_wake_en:1,		/* 8 */
211113151Smux			    magic_pkt_dis:1,			/* 8,9,!9ER */
212113151Smux			    tx_fc_dis:1,			/* 8,9 */
213113151Smux			    rx_fc_restop:1,			/* 8,9 */
214113151Smux			    rx_fc_restart:1,			/* 8,9 */
215113151Smux			    fc_filter:1,			/* 8,9 */
216113151Smux			    force_fdx:1,
217113151Smux			    fdx_pin_en:1);
218113183Smux	u_int		__FXP_BITFIELD4(:5,
219113151Smux			    pri_fc_loc:1,			/* 8,9 */
220113151Smux			    multi_ia:1,
221113151Smux			    :1);
222113183Smux	u_int		__FXP_BITFIELD3(:3, mc_all:1, :4);
223113151Smux
224113151Smux	/* Bytes 22 - 31 -- i82550 only */
225113183Smux	u_int		__FXP_BITFIELD3(gamla_rx:1,
226185540Syongari			    vlan_strip_en:1,
227113151Smux			    :6);
228143167Smux	uint8_t		pad[9];
22912510Sdg};
23029974Sdg
23129974Sdg#define MAXMCADDR 80
23229974Sdgstruct fxp_cb_mcs {
233143167Smux	uint16_t cb_status;
234143167Smux	uint16_t cb_command;
235143167Smux	uint32_t link_addr;
236143167Smux	uint16_t mc_cnt;
237143167Smux	uint8_t mc_addr[MAXMCADDR][6];
23829974Sdg};
23929974Sdg
24085460Sjlemon#define MAXUCODESIZE 192
24185460Sjlemonstruct fxp_cb_ucode {
242143167Smux	uint16_t cb_status;
243143167Smux	uint16_t cb_command;
244143167Smux	uint32_t link_addr;
245143167Smux	uint32_t ucode[MAXUCODESIZE];
24685460Sjlemon};
24785460Sjlemon
24829974Sdg/*
249112982Smux * Number of DMA segments in a TxCB.
25029974Sdg */
251263957Syongari#define FXP_NTXSEG	35
25229974Sdg
25312510Sdgstruct fxp_tbd {
254143167Smux	uint32_t tb_addr;
255143167Smux	uint32_t tb_size;
25612510Sdg};
257111578Swpaul
258111578Swpaulstruct fxp_ipcb {
259111578Swpaul	/*
260111578Swpaul	 * The following fields are valid only when
261111578Swpaul	 * using the IPCB command block for TX checksum offload
262111578Swpaul	 * (and TCP large send, VLANs, and (I think) IPsec). To use
263111578Swpaul	 * them, you must enable extended TxCBs (available only
264111578Swpaul	 * on the 82559 and later) and use the IPCBXMIT command.
265111578Swpaul	 * Note that Intel defines the IPCB to be 32 bytes long,
266111578Swpaul	 * the last 8 bytes of which comprise the first entry
267111578Swpaul	 * in the TBD array (see note below). This means we only
268111578Swpaul	 * have to define 8 extra bytes here.
269111578Swpaul         */
270143167Smux	uint16_t ipcb_schedule_low;
271143167Smux	uint8_t ipcb_ip_schedule;
272143167Smux	uint8_t ipcb_ip_activation_high;
273143167Smux	uint16_t ipcb_vlan_id;
274143167Smux	uint8_t ipcb_ip_header_offset;
275143167Smux	uint8_t ipcb_tcp_header_offset;
276111578Swpaul};
277111578Swpaul
27812510Sdgstruct fxp_cb_tx {
279143167Smux	uint16_t cb_status;
280143167Smux	uint16_t cb_command;
281143167Smux	uint32_t link_addr;
282345186Smarkj	union {
283345186Smarkj		struct {
284345186Smarkj			uint32_t tbd_array_addr;
285345186Smarkj			uint16_t byte_count;
286345186Smarkj			uint8_t tx_threshold;
287345186Smarkj			uint8_t tbd_number;
288345186Smarkj		};
289345186Smarkj		struct fxp_tbd tbdtso;
290345186Smarkj	};
291111578Swpaul
29212510Sdg	/*
29374259Sjlemon	 * The following structure isn't actually part of the TxCB,
29474259Sjlemon	 * unless the extended TxCB feature is being used.  In this
295185269Syongari	 * case, the first two elements of the structure below are
29674259Sjlemon	 * fetched along with the TxCB.
29712510Sdg	 */
298111578Swpaul	union {
299115003Smux		struct fxp_ipcb ipcb;
300185330Syongari		struct fxp_tbd tbd[FXP_NTXSEG + 1];
301111578Swpaul	} tx_cb_u;
30212510Sdg};
30312510Sdg
304111578Swpaul#define tbd			tx_cb_u.tbd
305115003Smux#define ipcb_schedule_low	tx_cb_u.ipcb.ipcb_schedule_low
306115003Smux#define ipcb_ip_schedule	tx_cb_u.ipcb.ipcb_ip_schedule
307115003Smux#define ipcb_ip_activation_high tx_cb_u.ipcb.ipcb_ip_activation_high
308115003Smux#define ipcb_vlan_id		tx_cb_u.ipcb.ipcb_vlan_id
309115003Smux#define ipcb_ip_header_offset	tx_cb_u.ipcb.ipcb_ip_header_offset
310115003Smux#define ipcb_tcp_header_offset	tx_cb_u.ipcb.ipcb_tcp_header_offset
311111578Swpaul
31212510Sdg/*
313111578Swpaul * IPCB field definitions
314111578Swpaul */
315111578Swpaul#define FXP_IPCB_IP_CHECKSUM_ENABLE	0x10
316111578Swpaul#define FXP_IPCB_TCPUDP_CHECKSUM_ENABLE	0x20
317111578Swpaul#define FXP_IPCB_TCP_PACKET		0x40
318111578Swpaul#define FXP_IPCB_LARGESEND_ENABLE	0x80
319111578Swpaul#define FXP_IPCB_HARDWAREPARSING_ENABLE	0x01
320111578Swpaul#define FXP_IPCB_INSERTVLAN_ENABLE	0x02
321111578Swpaul
322111578Swpaul/*
32312510Sdg * Control Block (CB) definitions
32412510Sdg */
32512510Sdg
32612510Sdg/* status */
32712510Sdg#define FXP_CB_STATUS_OK	0x2000
32812510Sdg#define FXP_CB_STATUS_C		0x8000
32912510Sdg/* commands */
33012510Sdg#define FXP_CB_COMMAND_NOP	0x0
33112510Sdg#define FXP_CB_COMMAND_IAS	0x1
33212510Sdg#define FXP_CB_COMMAND_CONFIG	0x2
33329974Sdg#define FXP_CB_COMMAND_MCAS	0x3
33412510Sdg#define FXP_CB_COMMAND_XMIT	0x4
33585460Sjlemon#define FXP_CB_COMMAND_UCODE	0x5
33612510Sdg#define FXP_CB_COMMAND_DUMP	0x6
33712510Sdg#define FXP_CB_COMMAND_DIAG	0x7
338111578Swpaul#define FXP_CB_COMMAND_LOADFILT	0x8
339111578Swpaul#define FXP_CB_COMMAND_IPCBXMIT 0x9
340111578Swpaul
34112510Sdg/* command flags */
34212510Sdg#define FXP_CB_COMMAND_SF	0x0008	/* simple/flexible mode */
34312510Sdg#define FXP_CB_COMMAND_I	0x2000	/* generate interrupt on completion */
34412510Sdg#define FXP_CB_COMMAND_S	0x4000	/* suspend on completion */
34512510Sdg#define FXP_CB_COMMAND_EL	0x8000	/* end of list */
34612510Sdg
34712510Sdg/*
34812510Sdg * RFA definitions
34912510Sdg */
35012510Sdg
35112510Sdgstruct fxp_rfa {
352143167Smux	uint16_t rfa_status;
353143167Smux	uint16_t rfa_control;
354143167Smux	uint32_t link_addr;
355143167Smux	uint32_t rbd_addr;
356143167Smux	uint16_t actual_size;
357143167Smux	uint16_t size;
358111578Swpaul
359111578Swpaul	/*
360111578Swpaul	 * The following fields are only available when using
361111578Swpaul	 * extended receive mode on an 82550/82551 chipset.
362111578Swpaul	 */
363143167Smux	uint16_t rfax_vlan_id;
364143167Smux	uint8_t rfax_rx_parser_sts;
365143167Smux	uint8_t rfax_rsvd0;
366143167Smux	uint16_t rfax_security_sts;
367143167Smux	uint8_t rfax_csum_sts;
368143167Smux	uint8_t rfax_zerocopy_sts;
369143167Smux	uint8_t rfax_pad[8];
370114950Smux} __packed;
371111578Swpaul#define FXP_RFAX_LEN 16
372111578Swpaul
37312510Sdg#define FXP_RFA_STATUS_RCOL	0x0001	/* receive collision */
37412510Sdg#define FXP_RFA_STATUS_IAMATCH	0x0002	/* 0 = matches station address */
375111578Swpaul#define FXP_RFA_STATUS_NOAMATCH	0x0004	/* 1 = doesn't match anything */
376111578Swpaul#define FXP_RFA_STATUS_PARSE	0x0008	/* pkt parse ok (82550/1 only) */
37712510Sdg#define FXP_RFA_STATUS_S4	0x0010	/* receive error from PHY */
37812510Sdg#define FXP_RFA_STATUS_TL	0x0020	/* type/length */
37912510Sdg#define FXP_RFA_STATUS_FTS	0x0080	/* frame too short */
38012510Sdg#define FXP_RFA_STATUS_OVERRUN	0x0100	/* DMA overrun */
38112510Sdg#define FXP_RFA_STATUS_RNR	0x0200	/* no resources */
38212510Sdg#define FXP_RFA_STATUS_ALIGN	0x0400	/* alignment error */
38312510Sdg#define FXP_RFA_STATUS_CRC	0x0800	/* CRC error */
384185540Syongari#define FXP_RFA_STATUS_VLAN	0x1000	/* VLAN tagged frame */
38512510Sdg#define FXP_RFA_STATUS_OK	0x2000	/* packet received okay */
38612510Sdg#define FXP_RFA_STATUS_C	0x8000	/* packet reception complete */
38712510Sdg#define FXP_RFA_CONTROL_SF	0x08	/* simple/flexible memory mode */
38812510Sdg#define FXP_RFA_CONTROL_H	0x10	/* header RFD */
38912510Sdg#define FXP_RFA_CONTROL_S	0x4000	/* suspend after reception */
39012510Sdg#define FXP_RFA_CONTROL_EL	0x8000	/* end of list */
39112510Sdg
392111578Swpaul/* Bits in the 'csum_sts' byte */
393111578Swpaul#define FXP_RFDX_CS_TCPUDP_CSUM_BIT_VALID	0x10
394111578Swpaul#define FXP_RFDX_CS_TCPUDP_CSUM_VALID		0x20
395111578Swpaul#define FXP_RFDX_CS_IP_CSUM_BIT_VALID		0x01
396111578Swpaul#define FXP_RFDX_CS_IP_CSUM_VALID		0x02
397111578Swpaul
398111578Swpaul/* Bits in the 'packet parser' byte */
399111578Swpaul#define FXP_RFDX_P_PARSE_BIT			0x08
400111578Swpaul#define FXP_RFDX_P_CSUM_PROTOCOL_MASK		0x03
401111578Swpaul#define FXP_RFDX_P_TCP_PACKET			0x00
402111578Swpaul#define FXP_RFDX_P_UDP_PACKET			0x01
403111578Swpaul#define FXP_RFDX_P_IP_PACKET			0x03
404111578Swpaul
40512510Sdg/*
40612510Sdg * Statistics dump area definitions
40712510Sdg */
40812510Sdgstruct fxp_stats {
409143167Smux	uint32_t tx_good;
410143167Smux	uint32_t tx_maxcols;
411143167Smux	uint32_t tx_latecols;
412143167Smux	uint32_t tx_underruns;
413143167Smux	uint32_t tx_lostcrs;
414143167Smux	uint32_t tx_deffered;
415143167Smux	uint32_t tx_single_collisions;
416143167Smux	uint32_t tx_multiple_collisions;
417143167Smux	uint32_t tx_total_collisions;
418143167Smux	uint32_t rx_good;
419143167Smux	uint32_t rx_crc_errors;
420143167Smux	uint32_t rx_alignment_errors;
421143167Smux	uint32_t rx_rnr_errors;
422143167Smux	uint32_t rx_overrun_errors;
423143167Smux	uint32_t rx_cdt_errors;
424143167Smux	uint32_t rx_shortframes;
425207832Syongari	uint32_t tx_pause;
426207832Syongari	uint32_t rx_pause;
427207832Syongari	uint32_t rx_controls;
428207832Syongari	uint16_t tx_tco;
429207832Syongari	uint16_t rx_tco;
430143167Smux	uint32_t completion_status;
431207832Syongari	uint32_t reserved0;
432207832Syongari	uint32_t reserved1;
433207832Syongari	uint32_t reserved2;
43412510Sdg};
43512510Sdg#define FXP_STATS_DUMP_COMPLETE	0xa005
43612510Sdg#define FXP_STATS_DR_COMPLETE	0xa007
437185269Syongari
43812510Sdg/*
43912510Sdg * Serial EEPROM control register bits
44012510Sdg */
44174178Sjlemon#define FXP_EEPROM_EESK		0x01 		/* shift clock */
44274178Sjlemon#define FXP_EEPROM_EECS		0x02 		/* chip select */
44374178Sjlemon#define FXP_EEPROM_EEDI		0x04 		/* data in */
44474178Sjlemon#define FXP_EEPROM_EEDO		0x08 		/* data out */
44512510Sdg
44612510Sdg/*
44712510Sdg * Serial EEPROM opcodes, including start bit
44812510Sdg */
44912510Sdg#define FXP_EEPROM_OPC_ERASE	0x4
45012510Sdg#define FXP_EEPROM_OPC_WRITE	0x5
45112510Sdg#define FXP_EEPROM_OPC_READ	0x6
45223964Sdg
45323964Sdg/*
454233586Syongari * EEPROM map
455233586Syongari */
456233586Syongari#define	FXP_EEPROM_MAP_IA0	0x00		/* Station address */
457233586Syongari#define	FXP_EEPROM_MAP_IA1	0x01
458233586Syongari#define	FXP_EEPROM_MAP_IA2	0x02
459233586Syongari#define	FXP_EEPROM_MAP_COMPAT	0x03		/* Compatibility */
460233586Syongari#define	FXP_EEPROM_MAP_CNTR	0x05		/* Controller/connector type */
461233586Syongari#define	FXP_EEPROM_MAP_PRI_PHY	0x06		/* Primary PHY record */
462233586Syongari#define	FXP_EEPROM_MAP_SEC_PHY	0x07		/* Secondary PHY record */
463233586Syongari#define	FXP_EEPROM_MAP_PWA0	0x08		/* Printed wire assembly num. */
464233586Syongari#define	FXP_EEPROM_MAP_PWA1	0x09		/* Printed wire assembly num. */
465233586Syongari#define	FXP_EEPROM_MAP_ID	0x0A		/* EEPROM ID */
466233586Syongari#define	FXP_EEPROM_MAP_SUBSYS	0x0B		/* Subsystem ID */
467233586Syongari#define	FXP_EEPROM_MAP_SUBVEN	0x0C		/* Subsystem vendor ID */
468233586Syongari#define	FXP_EEPROM_MAP_CKSUM64	0x3F		/* 64-word EEPROM checksum */
469233586Syongari#define	FXP_EEPROM_MAP_CKSUM256	0xFF		/* 256-word EEPROM checksum */
470233586Syongari
471233586Syongari/*
47223964Sdg * Management Data Interface opcodes
47323964Sdg */
47423964Sdg#define FXP_MDI_WRITE		0x1
47523964Sdg#define FXP_MDI_READ		0x2
47623964Sdg
47723964Sdg/*
47823964Sdg * PHY device types
47923964Sdg */
48076630Sjlemon#define FXP_PHY_DEVICE_MASK	0x3f00
48174178Sjlemon#define FXP_PHY_SERIAL_ONLY	0x8000
48223964Sdg#define FXP_PHY_NONE		0
48323964Sdg#define FXP_PHY_82553A		1
48423964Sdg#define FXP_PHY_82553C		2
48523964Sdg#define FXP_PHY_82503		3
48623964Sdg#define FXP_PHY_DP83840		4
48723964Sdg#define FXP_PHY_80C240		5
48823964Sdg#define FXP_PHY_80C24		6
48926623Sdg#define FXP_PHY_82555		7
49024079Sdg#define FXP_PHY_DP83840A	10
49134014Sdg#define FXP_PHY_82555B		11
49285460Sjlemon
49385460Sjlemon/*
49485460Sjlemon * Chip revision values.
49585460Sjlemon */
49685460Sjlemon#define FXP_REV_82557		1       /* catchall 82557 chip type */
49785460Sjlemon#define FXP_REV_82558_A4	4	/* 82558 A4 stepping */
49885460Sjlemon#define FXP_REV_82558_B0	5	/* 82558 B0 stepping */
49985460Sjlemon#define FXP_REV_82559_A0	8	/* 82559 A0 stepping */
50085460Sjlemon#define FXP_REV_82559S_A	9	/* 82559S A stepping */
50185460Sjlemon#define FXP_REV_82550		12
50285460Sjlemon#define FXP_REV_82550_C		13	/* 82550 C stepping */
503145401Smux#define FXP_REV_82551_E		14	/* 82551 */
504145401Smux#define FXP_REV_82551_F		15	/* 82551 */
505145401Smux#define FXP_REV_82551_10	16	/* 82551 */
506