if_devar.h revision 121816
1/*	$NetBSD: if_devar.h,v 1.32 1999/04/01 14:55:25 tsubai Exp $	*/
2
3/* $FreeBSD: head/sys/dev/de/if_devar.h 121816 2003-10-31 18:32:15Z brooks $ */
4
5/*-
6 * Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 * 2. The name of the author may not be used to endorse or promote products
15 *    derived from this software without specific prior written permission
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Id: if_devar.h,v 1.28 1997/07/03 16:55:07 thomas Exp
29 */
30
31#if !defined(_DEVAR_H)
32#define _DEVAR_H
33
34typedef bus_addr_t tulip_csrptr_t;
35
36#define	TULIP_PCI_CSRSIZE	8
37#define	TULIP_PCI_CSROFFSET	0
38
39#define TULIP_CSR_READ(sc, csr)			\
40	bus_space_read_4((sc)->tulip_csrs_bst,	\
41			 (sc)->tulip_csrs_bsh,	\
42			 (sc)->tulip_csrs.csr)
43#define TULIP_CSR_WRITE(sc, csr, val)			\
44	bus_space_write_4((sc)->tulip_csrs_bst,		\
45			  (sc)->tulip_csrs_bsh,		\
46			  (sc)->tulip_csrs.csr, val)
47
48#define TULIP_CSR_READBYTE(sc, csr)		\
49	bus_space_read_1((sc)->tulip_csrs_bst,	\
50			 (sc)->tulip_csrs_bsh,	\
51			 (sc)->tulip_csrs.csr)
52#define TULIP_CSR_WRITEBYTE(sc, csr, val)		\
53	bus_space_write_1((sc)->tulip_csrs_bst,		\
54			  (sc)->tulip_csrs_bsh,		\
55			  (sc)->tulip_csrs.csr, val)
56
57/*
58 * This structure contains "pointers" for the registers on
59 * the various 21x4x chips.  CSR0 through CSR8 are common
60 * to all chips.  After that, it gets messy...
61 */
62typedef struct {
63    tulip_csrptr_t csr_busmode;			/* CSR0 */
64    tulip_csrptr_t csr_txpoll;			/* CSR1 */
65    tulip_csrptr_t csr_rxpoll;			/* CSR2 */
66    tulip_csrptr_t csr_rxlist;			/* CSR3 */
67    tulip_csrptr_t csr_txlist;			/* CSR4 */
68    tulip_csrptr_t csr_status;			/* CSR5 */
69    tulip_csrptr_t csr_command;			/* CSR6 */
70    tulip_csrptr_t csr_intr;			/* CSR7 */
71    tulip_csrptr_t csr_missed_frames;		/* CSR8 */
72    tulip_csrptr_t csr_9;			/* CSR9 */
73    tulip_csrptr_t csr_10;			/* CSR10 */
74    tulip_csrptr_t csr_11;			/* CSR11 */
75    tulip_csrptr_t csr_12;			/* CSR12 */
76    tulip_csrptr_t csr_13;			/* CSR13 */
77    tulip_csrptr_t csr_14;			/* CSR14 */
78    tulip_csrptr_t csr_15;			/* CSR15 */
79} tulip_regfile_t;
80
81#define	csr_enetrom		csr_9	/* 21040 */
82#define	csr_reserved		csr_10	/* 21040 */
83#define	csr_full_duplex		csr_11	/* 21040 */
84#define	csr_bootrom		csr_10	/* 21041/21140A/?? */
85#define	csr_gp			csr_12	/* 21140* */
86#define	csr_watchdog		csr_15	/* 21140* */
87#define	csr_gp_timer		csr_11	/* 21041/21140* */
88#define	csr_srom_mii		csr_9	/* 21041/21140* */
89#define	csr_sia_status		csr_12	/* 2104x */
90#define csr_sia_connectivity	csr_13	/* 2104x */
91#define csr_sia_tx_rx		csr_14	/* 2104x */
92#define csr_sia_general		csr_15	/* 2104x */
93
94/*
95 * While 21x4x allows chaining of its descriptors, this driver
96 * doesn't take advantage of it.  We keep the descriptors in a
97 * traditional FIFO ring.
98 */
99typedef struct {
100    tulip_desc_t *ri_first;	/* first entry in ring */
101    tulip_desc_t *ri_last;	/* one after last entry */
102    tulip_desc_t *ri_nextin;	/* next to processed by host */
103    tulip_desc_t *ri_nextout;	/* next to processed by adapter */
104    int ri_max;
105    int ri_free;
106} tulip_ringinfo_t;
107
108/*
109 * The 21040 has a stupid restriction in that the receive
110 * buffers must be longword aligned.  But since Ethernet
111 * headers are not a multiple of longwords in size this forces
112 * the data to non-longword aligned.  Since IP requires the
113 * data to be longword aligned, we need to copy it after it has
114 * been DMA'ed in our memory.
115 *
116 * Since we have to copy it anyways, we might as well as allocate
117 * dedicated receive space for the input.  This allows to use a
118 * small receive buffer size and more ring entries to be able to
119 * better keep with a flood of tiny Ethernet packets.
120 *
121 * The receive space MUST ALWAYS be a multiple of the page size.
122 * And the number of receive descriptors multiplied by the size
123 * of the receive buffers must equal the recevive space.  This
124 * is so that we can manipulate the page tables so that even if a
125 * packet wraps around the end of the receive space, we can
126 * treat it as virtually contiguous.
127 *
128 * The above used to be true (the stupid restriction is still true)
129 * but we gone to directly DMA'ing into MBUFs (unless it's on an
130 * architecture which can't handle unaligned accesses) because with
131 * 100Mb/s cards the copying is just too much of a hit.
132 */
133#if !defined(__i386__)
134#define	TULIP_COPY_RXDATA	1
135#endif
136
137#define	TULIP_DATA_PER_DESC	2032
138#define	TULIP_TXTIMER		4
139#define	TULIP_RXDESCS		48
140#define	TULIP_TXDESCS		128
141#define	TULIP_RXQ_TARGET	32
142#if TULIP_RXQ_TARGET >= TULIP_RXDESCS
143#error TULIP_RXQ_TARGET must be less than TULIP_RXDESCS
144#endif
145#define	TULIP_RX_BUFLEN		((MCLBYTES < 2048 ? MCLBYTES : 2048) - 16)
146
147/*
148 * Forward reference to make C happy.
149 */
150typedef struct _tulip_softc_t tulip_softc_t;
151
152/*
153 * The various controllers support.
154 */
155
156typedef enum {
157    TULIP_21040,
158    TULIP_21041,
159    TULIP_21140, TULIP_21140A, TULIP_21142,
160    TULIP_21143,
161    TULIP_CHIPID_UNKNOWN
162} tulip_chipid_t;
163
164/*
165 * Various physical media types supported.
166 * BNCAUI is BNC or AUI since on the 21040 you can't really tell
167 * which is in use.
168 */
169typedef enum {
170    TULIP_MEDIA_UNKNOWN,
171    TULIP_MEDIA_10BASET,
172    TULIP_MEDIA_10BASET_FD,
173    TULIP_MEDIA_BNC,
174    TULIP_MEDIA_AUI,
175    TULIP_MEDIA_EXTSIA,
176    TULIP_MEDIA_AUIBNC,
177    TULIP_MEDIA_100BASETX,
178    TULIP_MEDIA_100BASETX_FD,
179    TULIP_MEDIA_100BASET4,
180    TULIP_MEDIA_100BASEFX,
181    TULIP_MEDIA_100BASEFX_FD,
182    TULIP_MEDIA_MAX
183} tulip_media_t;
184
185#define	TULIP_BIT(b)		(1L << ((int)(b)))
186#define	TULIP_FDBIT(m)		(1L << ((int)TULIP_MEDIA_ ## m ## _FD))
187#define	TULIP_MBIT(m)		(1L << ((int)TULIP_MEDIA_ ## m ))
188#define	TULIP_IS_MEDIA_FD(m)	(TULIP_BIT(m) & \
189				 (TULIP_FDBIT(10BASET) \
190				  |TULIP_FDBIT(100BASETX) \
191				  |TULIP_FDBIT(100BASEFX)))
192#define	TULIP_CAN_MEDIA_FD(m)	(TULIP_BIT(m) & \
193				 (TULIP_MBIT(10BASET) \
194				  |TULIP_MBIT(100BASETX) \
195				  |TULIP_MBIT(100BASEFX)))
196#define	TULIP_FD_MEDIA_OF(m)	((tulip_media_t)((m) + 1))
197#define	TULIP_HD_MEDIA_OF(m)	((tulip_media_t)((m) - 1))
198#define	TULIP_IS_MEDIA_100MB(m)	((m) >= TULIP_MEDIA_100BASETX)
199#define	TULIP_IS_MEDIA_TP(m)	((TULIP_BIT(m) & \
200				  (TULIP_MBIT(BNC) \
201				   |TULIP_MBIT(AUI) \
202				   |TULIP_MBIT(AUIBNC) \
203				   |TULIP_MBIT(EXTSIA))) == 0)
204
205#define	TULIP_SROM_ATTR_MII		0x0100
206#define	TULIP_SROM_ATTR_NWAY		0x0200
207#define	TULIP_SROM_ATTR_AUTOSENSE	0x0400
208#define	TULIP_SROM_ATTR_POWERUP		0x0800
209#define	TULIP_SROM_ATTR_NOLINKPASS	0x1000
210
211typedef struct {
212    enum {
213	TULIP_MEDIAINFO_NONE,
214	TULIP_MEDIAINFO_SIA,
215	TULIP_MEDIAINFO_GPR,
216	TULIP_MEDIAINFO_MII,
217	TULIP_MEDIAINFO_RESET,
218	TULIP_MEDIAINFO_SYM
219    } mi_type;
220    union {
221	struct {
222	    u_int16_t sia_connectivity;
223	    u_int16_t sia_tx_rx;
224	    u_int16_t sia_general;
225	    u_int32_t sia_gp_control;	/* 21142/21143 */
226	    u_int32_t sia_gp_data;	/* 21142/21143 */
227	} un_sia;
228	struct {
229	    u_int32_t gpr_cmdmode;
230	    u_int32_t gpr_gpcontrol;	/* 21142/21143 */
231	    u_int32_t gpr_gpdata;
232	    u_int8_t gpr_actmask;
233	    u_int8_t gpr_actdata;
234	    u_int    gpr_default : 1;
235	} un_gpr;
236	struct {
237	    u_int32_t mii_mediamask;
238	    u_int16_t mii_capabilities;
239	    u_int16_t mii_advertisement;
240	    u_int16_t mii_full_duplex;
241	    u_int16_t mii_tx_threshold;
242	    u_int16_t mii_interrupt;	/* 21142/21143 */
243	    u_int8_t mii_phyaddr;
244	    u_int8_t mii_gpr_length;
245	    u_int8_t mii_gpr_offset;
246	    u_int8_t mii_reset_length;
247	    u_int8_t mii_reset_offset;
248	    u_int32_t mii_phyid;
249	} un_mii;
250    } mi_un;
251} tulip_media_info_t;
252
253#define	mi_sia_connectivity	mi_un.un_sia.sia_connectivity
254#define	mi_sia_tx_rx		mi_un.un_sia.sia_tx_rx
255#define mi_sia_general		mi_un.un_sia.sia_general
256#define	mi_sia_gp_control	mi_un.un_sia.sia_gp_control
257#define	mi_sia_gp_data		mi_un.un_sia.sia_gp_data
258
259#define	mi_gpcontrol		mi_un.un_gpr.gpr_gpcontrol
260#define	mi_gpdata		mi_un.un_gpr.gpr_gpdata
261#define	mi_actmask		mi_un.un_gpr.gpr_actmask
262#define	mi_actdata		mi_un.un_gpr.gpr_actdata
263#define	mi_default		mi_un.un_gpr.gpr_default
264#define	mi_cmdmode		mi_un.un_gpr.gpr_cmdmode
265
266#define	mi_phyaddr		mi_un.un_mii.mii_phyaddr
267#define	mi_gpr_length		mi_un.un_mii.mii_gpr_length
268#define	mi_gpr_offset		mi_un.un_mii.mii_gpr_offset
269#define	mi_reset_length		mi_un.un_mii.mii_reset_length
270#define	mi_reset_offset		mi_un.un_mii.mii_reset_offset
271#define	mi_capabilities		mi_un.un_mii.mii_capabilities
272#define	mi_advertisement	mi_un.un_mii.mii_advertisement
273#define	mi_full_duplex		mi_un.un_mii.mii_full_duplex
274#define	mi_tx_threshold		mi_un.un_mii.mii_tx_threshold
275#define	mi_mediamask		mi_un.un_mii.mii_mediamask
276#define	mi_mii_interrupt	mi_un.un_mii.mii_interrupt
277#define	mi_phyid		mi_un.un_mii.mii_phyid
278
279#define	TULIP_MEDIAINFO_SIA_INIT(sc, mi, chipid, media) do { \
280    (mi)->mi_type = TULIP_MEDIAINFO_SIA; \
281    sc->tulip_mediums[TULIP_MEDIA_ ## media] = (mi); \
282    (mi)->mi_sia_connectivity = TULIP_ ## chipid ## _SIACONN_ ## media; \
283    (mi)->mi_sia_tx_rx        = TULIP_ ## chipid ## _SIATXRX_ ## media; \
284    (mi)->mi_sia_general      = TULIP_ ## chipid ## _SIAGEN_ ## media; \
285} while (0)
286
287#define TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, media) do {	\
288    if ((sc)->tulip_mediums[TULIP_MEDIA_ ## media] == NULL	\
289	    && ((mi)->mi_capabilities & PHYSTS_ ## media)) {	\
290	(sc)->tulip_mediums[TULIP_MEDIA_ ## media] = (mi);	\
291	(mi)->mi_mediamask |= TULIP_BIT(TULIP_MEDIA_ ## media);	\
292    } \
293} while (0)
294
295#define	TULIP_MII_NOPHY		32
296/*
297 * Some boards need to treated specially.  The following enumeration
298 * identifies the cards with quirks (or those we just want to single
299 * out for special merit or scorn).
300 */
301typedef enum {
302    TULIP_21040_GENERIC,		/* Generic 21040 (works with most any board) */
303    TULIP_21140_ISV,			/* Digital Semicondutor 21140 ISV SROM Format */
304    TULIP_21142_ISV,			/* Digital Semicondutor 21142 ISV SROM Format */
305    TULIP_21143_ISV,			/* Digital Semicondutor 21143 ISV SROM Format */
306    TULIP_21140_DEC_EB,			/* Digital Semicondutor 21140 Evaluation Board */
307    TULIP_21140_MII,			/* 21140[A] with MII */
308    TULIP_21140_DEC_DE500,		/* Digital DE500-?? 10/100 */
309    TULIP_21140_SMC_9332,		/* SMC 9332 */
310    TULIP_21140_COGENT_EM100,		/* Cogent EM100 100 only */
311    TULIP_21140_ZNYX_ZX34X,		/* ZNYX ZX342 10/100 */
312    TULIP_21140_ASANTE,			/* AsanteFast 10/100 */
313    TULIP_21140_EN1207,			/* Accton EN2107 10/100 BNC */
314    TULIP_21041_GENERIC			/* Generic 21041 card */
315} tulip_board_t;
316
317typedef enum {
318    TULIP_MEDIAPOLL_TIMER,		/* 100ms timer fired */
319    TULIP_MEDIAPOLL_FASTTIMER,		/* <100ms timer fired */
320    TULIP_MEDIAPOLL_LINKFAIL,		/* called from interrupt routine */
321    TULIP_MEDIAPOLL_LINKPASS,		/* called from interrupt routine */
322    TULIP_MEDIAPOLL_START,		/* start a media probe (called from reset) */
323    TULIP_MEDIAPOLL_TXPROBE_OK,		/* txprobe succeeded */
324    TULIP_MEDIAPOLL_TXPROBE_FAILED,	/* txprobe failed */
325    TULIP_MEDIAPOLL_MAX
326} tulip_mediapoll_event_t;
327
328typedef enum {
329    TULIP_LINK_DOWN,			/* Link is down */
330    TULIP_LINK_UP,			/* link is ok */
331    TULIP_LINK_UNKNOWN			/* we can't tell either way */
332} tulip_link_status_t;
333
334
335/*
336 * This data structure is used to abstract out the quirks.
337 * media_probe  = tries to determine the media type.
338 * media_select = enables the current media (or autosenses)
339 * media_poll	= autosenses media
340 * media_preset = 21140, etal requires bit to set before the
341 *		  the software reset; hence pre-set.  Should be
342 *		  pre-reset but that's ugly.
343 */
344
345typedef struct {
346    tulip_board_t bd_type;
347    void (*bd_media_probe)(tulip_softc_t * const sc);
348    void (*bd_media_select)(tulip_softc_t * const sc);
349    void (*bd_media_poll)(tulip_softc_t * const sc, tulip_mediapoll_event_t event);
350    void (*bd_media_preset)(tulip_softc_t * const sc);
351} tulip_boardsw_t;
352
353/*
354 * The next few declarations are for MII/PHY based board.
355 *
356 *    The first enumeration identifies a superset of various datums
357 * that can be obtained from various PHY chips.  Not all PHYs will
358 * support all datums.
359 *    The modedata structure indicates what register contains
360 * a datum, what mask is applied the register contents, and what the
361 * result should be.
362 *    The attr structure records information about a supported PHY.
363 *    The phy structure records information about a PHY instance.
364 */
365
366typedef enum {
367    PHY_MODE_10T,
368    PHY_MODE_100TX,
369    PHY_MODE_100T4,
370    PHY_MODE_FULLDUPLEX,
371    PHY_MODE_MAX
372} tulip_phy_mode_t;
373
374typedef struct {
375    u_int16_t pm_regno;
376    u_int16_t pm_mask;
377    u_int16_t pm_value;
378} tulip_phy_modedata_t;
379
380typedef struct {
381    u_int32_t attr_id;
382    u_int16_t attr_flags;
383#define	PHY_NEED_HARD_RESET	0x0001
384#define	PHY_DUAL_CYCLE_TA	0x0002
385    tulip_phy_modedata_t attr_modes[PHY_MODE_MAX];
386#ifdef TULIP_DEBUG
387    const char *attr_name;
388#endif
389} tulip_phy_attr_t;
390
391/*
392 * Various probe states used when trying to autosense the media.
393 */
394
395typedef enum {
396    TULIP_PROBE_INACTIVE,
397    TULIP_PROBE_PHYRESET,
398    TULIP_PROBE_PHYAUTONEG,
399    TULIP_PROBE_GPRTEST,
400    TULIP_PROBE_MEDIATEST,
401    TULIP_PROBE_FAILED
402} tulip_probe_state_t;
403
404typedef struct {
405    /*
406     * Transmit Statistics
407     */
408    u_int32_t dot3StatsSingleCollisionFrames;
409    u_int32_t dot3StatsMultipleCollisionFrames;
410    u_int32_t dot3StatsSQETestErrors;
411    u_int32_t dot3StatsDeferredTransmissions;
412    u_int32_t dot3StatsLateCollisions;
413    u_int32_t dot3StatsExcessiveCollisions;
414    u_int32_t dot3StatsCarrierSenseErrors;
415    u_int32_t dot3StatsInternalMacTransmitErrors;
416    u_int32_t dot3StatsInternalTransmitUnderflows;	/* not in rfc1650! */
417    u_int32_t dot3StatsInternalTransmitBabbles;		/* not in rfc1650! */
418    /*
419     * Receive Statistics
420     */
421    u_int32_t dot3StatsMissedFrames;	/* not in rfc1650! */
422    u_int32_t dot3StatsAlignmentErrors;
423    u_int32_t dot3StatsFCSErrors;
424    u_int32_t dot3StatsFrameTooLongs;
425    u_int32_t dot3StatsInternalMacReceiveErrors;
426} tulip_dot3_stats_t;
427
428/*
429 * Now to important stuff.  This is softc structure (where does softc
430 * come from??? No idea) for the tulip device.
431 */
432struct _tulip_softc_t {
433    struct ifmedia tulip_ifmedia;
434    int tulip_unit;
435#if defined(TULIP_BUS_DMA)
436    bus_dma_tag_t tulip_dmatag;		/* bus DMA tag */
437#if !defined(TULIP_BUS_DMA_NOTX)
438    bus_dmamap_t tulip_setupmap;
439    bus_dmamap_t tulip_txdescmap;
440    bus_dmamap_t tulip_txmaps[TULIP_TXDESCS];
441    unsigned tulip_txmaps_free;
442#endif
443#if !defined(TULIP_BUS_DMA_NORX)
444    bus_dmamap_t tulip_rxdescmap;
445    bus_dmamap_t tulip_rxmaps[TULIP_RXDESCS];
446    unsigned tulip_rxmaps_free;
447#endif
448#endif
449    struct arpcom tulip_ac;
450    bus_space_tag_t tulip_csrs_bst;
451    bus_space_handle_t tulip_csrs_bsh;
452    tulip_regfile_t tulip_csrs;
453    u_int32_t tulip_flags;
454#define	TULIP_WANTSETUP		0x00000001
455#define	TULIP_WANTHASHPERFECT	0x00000002
456#define	TULIP_WANTHASHONLY	0x00000004
457#define	TULIP_DOINGSETUP	0x00000008
458#define	TULIP_PRINTMEDIA	0x00000010
459#define	TULIP_TXPROBE_ACTIVE	0x00000020
460#define	TULIP_ALLMULTI		0x00000040
461#define	TULIP_WANTRXACT		0x00000080
462#define	TULIP_RXACT		0x00000100
463#define	TULIP_INRESET		0x00000200
464#define	TULIP_NEEDRESET		0x00000400
465#define	TULIP_SQETEST		0x00000800
466#define	TULIP_xxxxxx0		0x00001000
467#define	TULIP_xxxxxx1		0x00002000
468#define	TULIP_WANTTXSTART	0x00004000
469#define	TULIP_NEWTXTHRESH	0x00008000
470#define	TULIP_NOAUTOSENSE	0x00010000
471#define	TULIP_PRINTLINKUP	0x00020000
472#define	TULIP_LINKUP		0x00040000
473#define	TULIP_RXBUFSLOW		0x00080000
474#define	TULIP_NOMESSAGES	0x00100000
475#define	TULIP_SYSTEMERROR	0x00200000
476#define	TULIP_TIMEOUTPENDING	0x00400000
477#define	TULIP_xxxxxx2		0x00800000
478#define	TULIP_TRYNWAY		0x01000000
479#define	TULIP_DIDNWAY		0x02000000
480#define	TULIP_RXIGNORE		0x04000000
481#define	TULIP_PROBE1STPASS	0x08000000
482#define	TULIP_DEVICEPROBE	0x10000000
483#define	TULIP_PROMISC		0x20000000
484#define	TULIP_HASHONLY		0x40000000
485#define	TULIP_xxxxxx3		0x80000000
486    /* only 4 bits left! */
487    u_int32_t tulip_features;	/* static bits indicating features of chip */
488#define	TULIP_HAVE_GPR		0x00000001	/* have gp register (140[A]) */
489#define	TULIP_HAVE_RXBADOVRFLW	0x00000002	/* RX corrupts on overflow */
490#define	TULIP_HAVE_POWERMGMT	0x00000004	/* Snooze/sleep modes */
491#define	TULIP_HAVE_MII		0x00000008	/* Some medium on MII */
492#define	TULIP_HAVE_SIANWAY	0x00000010	/* SIA does NWAY */
493#define	TULIP_HAVE_DUALSENSE	0x00000020	/* SIA senses both AUI & TP */
494#define	TULIP_HAVE_SIAGP	0x00000040	/* SIA has a GP port */
495#define	TULIP_HAVE_BROKEN_HASH	0x00000080	/* Broken Multicast Hash */
496#define	TULIP_HAVE_ISVSROM	0x00000100	/* uses ISV SROM Format */
497#define	TULIP_HAVE_BASEROM	0x00000200	/* Board ROM can be cloned */
498#define	TULIP_HAVE_SLAVEDROM	0x00000400	/* Board ROM cloned */
499#define	TULIP_HAVE_SLAVEDINTR	0x00000800	/* Board slaved interrupt */
500#define	TULIP_HAVE_SHAREDINTR	0x00001000	/* Board shares interrupts */
501#define	TULIP_HAVE_OKROM	0x00002000	/* ROM was recognized */
502#define	TULIP_HAVE_NOMEDIA	0x00004000	/* did not detect any media */
503#define	TULIP_HAVE_STOREFWD	0x00008000	/* have CMD_STOREFWD */
504#define	TULIP_HAVE_SIA100	0x00010000	/* has LS100 in SIA status */
505#define	TULIP_HAVE_OKSROM	0x00020000	/* SROM CRC is OK */
506    u_int32_t tulip_intrmask;	/* our copy of csr_intr */
507    u_int32_t tulip_cmdmode;	/* our copy of csr_cmdmode */
508    u_int32_t tulip_last_system_error : 3;	/* last system error (only value is TULIP_SYSTEMERROR is also set) */
509    u_int32_t tulip_txtimer : 2;	/* transmission timer */
510    u_int32_t tulip_system_errors;	/* number of system errors encountered */
511    u_int32_t tulip_statusbits;	/* status bits from CSR5 that may need to be printed */
512
513    tulip_media_info_t *tulip_mediums[TULIP_MEDIA_MAX];	/* indexes into mediainfo */
514    tulip_media_t tulip_media;			/* current media type */
515    u_int32_t tulip_abilities;	/* remote system's abiltities (as defined in IEEE 802.3u) */
516
517    u_int8_t tulip_revinfo;			/* revision of chip */
518    u_int8_t tulip_phyaddr;			/* 0..31 -- address of current phy */
519    u_int8_t tulip_gpinit;			/* active pins on 21140 */
520    u_int8_t tulip_gpdata;			/* default gpdata for 21140 */
521
522    struct {
523	u_int8_t probe_count;			/* count of probe operations */
524	int32_t probe_timeout;			/* time in ms of probe timeout */
525	tulip_probe_state_t probe_state;	/* current media probe state */
526	tulip_media_t probe_media;		/* current media being probed */
527	u_int32_t probe_mediamask;		/* medias checked */
528	u_int32_t probe_passes;			/* times autosense failed */
529	u_int32_t probe_txprobes;		/* txprobes attempted */
530    } tulip_probe;
531#define	tulip_probe_count	tulip_probe.probe_count
532#define	tulip_probe_timeout	tulip_probe.probe_timeout
533#define	tulip_probe_state	tulip_probe.probe_state
534#define	tulip_probe_media	tulip_probe.probe_media
535#define	tulip_probe_mediamask	tulip_probe.probe_mediamask
536#define	tulip_probe_passes	tulip_probe.probe_passes
537
538    tulip_chipid_t tulip_chipid;		/* type of chip we are using */
539    const tulip_boardsw_t *tulip_boardsw;	/* board/chip characteristics */
540    tulip_softc_t *tulip_slaves;		/* slaved devices (ZX3xx) */
541#if defined(TULIP_DEBUG)
542    /*
543     * Debugging/Statistical information
544     */
545    struct {
546	tulip_media_t dbg_last_media;
547	u_int32_t dbg_intrs;
548	u_int32_t dbg_media_probes;
549	u_int32_t dbg_txprobe_nocarr;
550	u_int32_t dbg_txprobe_exccoll;
551	u_int32_t dbg_link_downed;
552	u_int32_t dbg_link_suspected;
553	u_int32_t dbg_link_intrs;
554	u_int32_t dbg_link_pollintrs;
555	u_int32_t dbg_link_failures;
556	u_int32_t dbg_nway_starts;
557	u_int32_t dbg_nway_failures;
558	u_int16_t dbg_phyregs[32][4];
559	u_int32_t dbg_rxlowbufs;
560	u_int32_t dbg_rxintrs;
561	u_int32_t dbg_last_rxintrs;
562	u_int32_t dbg_high_rxintrs_hz;
563	u_int32_t dbg_no_txmaps;
564	u_int32_t dbg_txput_finishes[8];
565	u_int32_t dbg_txprobes_ok[TULIP_MEDIA_MAX];
566	u_int32_t dbg_txprobes_failed[TULIP_MEDIA_MAX];
567	u_int32_t dbg_events[TULIP_MEDIAPOLL_MAX];
568	u_int32_t dbg_rxpktsperintr[TULIP_RXDESCS];
569    } tulip_dbg;
570#endif
571#if defined(TULIP_PERFSTATS)
572#define	TULIP_PERF_CURRENT	0
573#define	TULIP_PERF_PREVIOUS	1
574#define	TULIP_PERF_TOTAL	2
575#define	TULIP_PERF_MAX		3
576    struct tulip_perfstats {
577	u_quad_t perf_intr_cycles;
578	u_quad_t perf_ifstart_cycles;
579	u_quad_t perf_ifstart_one_cycles;
580	u_quad_t perf_ifioctl_cycles;
581	u_quad_t perf_ifwatchdog_cycles;
582	u_quad_t perf_timeout_cycles;
583	u_quad_t perf_txput_cycles;
584	u_quad_t perf_txintr_cycles;
585	u_quad_t perf_rxintr_cycles;
586	u_quad_t perf_rxget_cycles;
587	unsigned perf_intr;
588	unsigned perf_ifstart;
589	unsigned perf_ifstart_one;
590	unsigned perf_ifioctl;
591	unsigned perf_ifwatchdog;
592	unsigned perf_timeout;
593	unsigned perf_txput;
594	unsigned perf_txintr;
595	unsigned perf_rxintr;
596	unsigned perf_rxget;
597    } tulip_perfstats[TULIP_PERF_MAX];
598#define	tulip_curperfstats		tulip_perfstats[TULIP_PERF_CURRENT]
599#endif
600    struct ifqueue tulip_txq;
601    struct ifqueue tulip_rxq;
602    tulip_dot3_stats_t tulip_dot3stats;
603    tulip_ringinfo_t tulip_rxinfo;
604    tulip_ringinfo_t tulip_txinfo;
605    tulip_media_info_t tulip_mediainfo[10];
606    /*
607     * The setup buffers for sending the setup frame to the chip.
608     * one is the one being sent while the other is the one being
609     * filled.
610     */
611    u_int32_t tulip_setupbuf[192/sizeof(u_int32_t)];
612    u_int32_t tulip_setupdata[192/sizeof(u_int32_t)];
613    char tulip_boardid[24];	/* buffer for board ID */
614    u_int8_t tulip_rombuf[128]; /* must be aligned */
615    u_int8_t tulip_pci_busno;	/* needed for multiport boards */
616    u_int8_t tulip_pci_devno;	/* needed for multiport boards */
617    u_int8_t tulip_connidx;
618    tulip_srom_connection_t tulip_conntype;
619    tulip_desc_t *tulip_rxdescs;
620    tulip_desc_t *tulip_txdescs;
621};
622
623#define	TULIP_DO_AUTOSENSE(sc)	(IFM_SUBTYPE((sc)->tulip_ifmedia.ifm_media) == IFM_AUTO)
624
625
626#if defined(TULIP_HDR_DATA)
627static const char * const tulip_chipdescs[] = {
628    "21040 [10Mb/s]",
629    "21041 [10Mb/s]",
630    "21140 [10-100Mb/s]",
631    "21140A [10-100Mb/s]",
632    "21142 [10-100Mb/s]",
633    "21143 [10-100Mb/s]",
634};
635
636static const char * const tulip_mediums[] = {
637    "unknown",			/* TULIP_MEDIA_UNKNOWN */
638    "10baseT",			/* TULIP_MEDIA_10BASET */
639    "Full Duplex 10baseT",	/* TULIP_MEDIA_10BASET_FD */
640    "BNC",			/* TULIP_MEDIA_BNC */
641    "AUI",			/* TULIP_MEDIA_AUI */
642    "External SIA",		/* TULIP_MEDIA_EXTSIA */
643    "AUI/BNC",			/* TULIP_MEDIA_AUIBNC */
644    "100baseTX",		/* TULIP_MEDIA_100BASET */
645    "Full Duplex 100baseTX",	/* TULIP_MEDIA_100BASET_FD */
646    "100baseT4",		/* TULIP_MEDIA_100BASET4 */
647    "100baseFX",		/* TULIP_MEDIA_100BASEFX */
648    "Full Duplex 100baseFX",	/* TULIP_MEDIA_100BASEFX_FD */
649};
650
651static const int tulip_media_to_ifmedia[] = {
652    IFM_ETHER | IFM_NONE,		/* TULIP_MEDIA_UNKNOWN */
653    IFM_ETHER | IFM_10_T,		/* TULIP_MEDIA_10BASET */
654    IFM_ETHER | IFM_10_T | IFM_FDX,	/* TULIP_MEDIA_10BASET_FD */
655    IFM_ETHER | IFM_10_2,		/* TULIP_MEDIA_BNC */
656    IFM_ETHER | IFM_10_5,		/* TULIP_MEDIA_AUI */
657    IFM_ETHER | IFM_MANUAL,		/* TULIP_MEDIA_EXTSIA */
658    IFM_ETHER | IFM_10_5,		/* TULIP_MEDIA_AUIBNC */
659    IFM_ETHER | IFM_100_TX,		/* TULIP_MEDIA_100BASET */
660    IFM_ETHER | IFM_100_TX | IFM_FDX,	/* TULIP_MEDIA_100BASET_FD */
661    IFM_ETHER | IFM_100_T4,		/* TULIP_MEDIA_100BASET4 */
662    IFM_ETHER | IFM_100_FX,		/* TULIP_MEDIA_100BASEFX */
663    IFM_ETHER | IFM_100_FX | IFM_FDX,	/* TULIP_MEDIA_100BASEFX_FD */
664};
665
666static const char * const tulip_system_errors[] = {
667    "parity error",
668    "master abort",
669    "target abort",
670    "reserved #3",
671    "reserved #4",
672    "reserved #5",
673    "reserved #6",
674    "reserved #7",
675};
676
677static const char * const tulip_status_bits[] = {
678    NULL,
679    "transmit process stopped",
680    NULL,
681    "transmit jabber timeout",
682
683    NULL,
684    "transmit underflow",
685    NULL,
686    "receive underflow",
687
688    "receive process stopped",
689    "receive watchdog timeout",
690    NULL,
691    NULL,
692
693    "link failure",
694    NULL,
695    NULL,
696};
697
698static const struct {
699    tulip_srom_connection_t sc_type;
700    tulip_media_t sc_media;
701    u_int32_t sc_attrs;
702} tulip_srom_conninfo[] = {
703    { TULIP_SROM_CONNTYPE_10BASET,		TULIP_MEDIA_10BASET },
704    { TULIP_SROM_CONNTYPE_BNC,			TULIP_MEDIA_BNC },
705    { TULIP_SROM_CONNTYPE_AUI,			TULIP_MEDIA_AUI },
706    { TULIP_SROM_CONNTYPE_100BASETX,		TULIP_MEDIA_100BASETX },
707    { TULIP_SROM_CONNTYPE_100BASET4,		TULIP_MEDIA_100BASET4 },
708    { TULIP_SROM_CONNTYPE_100BASEFX,		TULIP_MEDIA_100BASEFX },
709    { TULIP_SROM_CONNTYPE_MII_10BASET,		TULIP_MEDIA_10BASET,
710		TULIP_SROM_ATTR_MII },
711    { TULIP_SROM_CONNTYPE_MII_100BASETX,	TULIP_MEDIA_100BASETX,
712		TULIP_SROM_ATTR_MII },
713    { TULIP_SROM_CONNTYPE_MII_100BASET4,	TULIP_MEDIA_100BASET4,
714		TULIP_SROM_ATTR_MII },
715    { TULIP_SROM_CONNTYPE_MII_100BASEFX,	TULIP_MEDIA_100BASEFX,
716		TULIP_SROM_ATTR_MII },
717    { TULIP_SROM_CONNTYPE_10BASET_NWAY,		TULIP_MEDIA_10BASET,
718		TULIP_SROM_ATTR_NWAY },
719    { TULIP_SROM_CONNTYPE_10BASET_FD,		TULIP_MEDIA_10BASET_FD },
720    { TULIP_SROM_CONNTYPE_MII_10BASET_FD,	TULIP_MEDIA_10BASET_FD,
721		TULIP_SROM_ATTR_MII },
722    { TULIP_SROM_CONNTYPE_100BASETX_FD,		TULIP_MEDIA_100BASETX_FD },
723    { TULIP_SROM_CONNTYPE_MII_100BASETX_FD,	TULIP_MEDIA_100BASETX_FD,
724		TULIP_SROM_ATTR_MII },
725    { TULIP_SROM_CONNTYPE_10BASET_NOLINKPASS,	TULIP_MEDIA_10BASET,
726		TULIP_SROM_ATTR_NOLINKPASS },
727    { TULIP_SROM_CONNTYPE_AUTOSENSE,		TULIP_MEDIA_UNKNOWN,
728		TULIP_SROM_ATTR_AUTOSENSE },
729    { TULIP_SROM_CONNTYPE_AUTOSENSE_POWERUP,	TULIP_MEDIA_UNKNOWN,
730		TULIP_SROM_ATTR_AUTOSENSE|TULIP_SROM_ATTR_POWERUP },
731    { TULIP_SROM_CONNTYPE_AUTOSENSE_NWAY,	TULIP_MEDIA_UNKNOWN,
732		TULIP_SROM_ATTR_AUTOSENSE|TULIP_SROM_ATTR_NWAY },
733    { TULIP_SROM_CONNTYPE_NOT_USED,		TULIP_MEDIA_UNKNOWN }
734};
735#define	TULIP_SROM_LASTCONNIDX	\
736		(sizeof(tulip_srom_conninfo)/sizeof(tulip_srom_conninfo[0]) - 1)
737
738static const struct {
739    tulip_media_t sm_type;
740    tulip_srom_media_t sm_srom_type;
741} tulip_srom_mediums[] = {
742    { 	TULIP_MEDIA_100BASEFX_FD,	TULIP_SROM_MEDIA_100BASEFX_FD	},
743    {	TULIP_MEDIA_100BASEFX,		TULIP_SROM_MEDIA_100BASEFX	},
744    {	TULIP_MEDIA_100BASET4,		TULIP_SROM_MEDIA_100BASET4	},
745    {	TULIP_MEDIA_100BASETX_FD,	TULIP_SROM_MEDIA_100BASETX_FD	},
746    {	TULIP_MEDIA_100BASETX,		TULIP_SROM_MEDIA_100BASETX	},
747    {	TULIP_MEDIA_10BASET_FD,		TULIP_SROM_MEDIA_10BASET_FD	},
748    {	TULIP_MEDIA_AUI,		TULIP_SROM_MEDIA_AUI		},
749    {	TULIP_MEDIA_BNC,		TULIP_SROM_MEDIA_BNC		},
750    {	TULIP_MEDIA_10BASET,		TULIP_SROM_MEDIA_10BASET	},
751    {	TULIP_MEDIA_UNKNOWN						}
752};
753#endif /* TULIP_HDR_DATA */
754
755/*
756 * This driver supports a maximum of 32 tulip boards.
757 * This should be enough for the forseeable future.
758 */
759#define	TULIP_MAX_DEVICES	32
760
761#if defined(TULIP_USE_SOFTINTR) && defined(TULIP_HDR_DATA)
762static u_int32_t tulip_softintr_mask;
763static int tulip_softintr_last_unit;
764static int tulip_softintr_max_unit;
765static void tulip_softintr(void);
766#endif
767
768#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
769#define TULIP_RXDESC_PRESYNC(sc, di, s)	\
770	bus_dmamap_sync((sc)->tulip_dmatag, (sc)->tulip_rxdescmap, \
771		   (caddr_t) di - (caddr_t) (sc)->tulip_rxdescs, \
772		   (s), BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
773#define TULIP_RXDESC_POSTSYNC(sc, di, s)	\
774	bus_dmamap_sync((sc)->tulip_dmatag, (sc)->tulip_rxdescmap, \
775		   (caddr_t) di - (caddr_t) (sc)->tulip_rxdescs, \
776		   (s), BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
777#define	TULIP_RXMAP_PRESYNC(sc, map) \
778	bus_dmamap_sync((sc)->tulip_dmatag, (map), 0, (map)->dm_mapsize, \
779			BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
780#define	TULIP_RXMAP_POSTSYNC(sc, map) \
781	bus_dmamap_sync((sc)->tulip_dmatag, (map), 0, (map)->dm_mapsize, \
782			BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
783#define	TULIP_RXMAP_CREATE(sc, mapp) \
784	bus_dmamap_create((sc)->tulip_dmatag, TULIP_RX_BUFLEN, 2, \
785			  TULIP_DATA_PER_DESC, 0, \
786			  BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW, (mapp))
787#else
788#ifdef __alpha__
789#define TULIP_RXDESC_PRESYNC(sc, di, s)		alpha_mb()
790#define TULIP_RXDESC_POSTSYNC(sc, di, s)	alpha_mb()
791#define TULIP_RXMAP_PRESYNC(sc, map)		alpha_mb()
792#define TULIP_RXMAP_POSTSYNC(sc, map)		alpha_mb()
793#else
794#define TULIP_RXDESC_PRESYNC(sc, di, s)		do { } while (0)
795#define TULIP_RXDESC_POSTSYNC(sc, di, s)	do { } while (0)
796#define TULIP_RXMAP_PRESYNC(sc, map)		do { } while (0)
797#define TULIP_RXMAP_POSTSYNC(sc, map)		do { } while (0)
798#endif
799#define TULIP_RXMAP_CREATE(sc, mapp)		do { } while (0)
800#endif
801
802#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
803#define TULIP_TXDESC_PRESYNC(sc, di, s)	\
804	bus_dmamap_sync((sc)->tulip_dmatag, (sc)->tulip_txdescmap, \
805			(caddr_t) di - (caddr_t) (sc)->tulip_txdescs, \
806			(s), BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
807#define TULIP_TXDESC_POSTSYNC(sc, di, s)	\
808	bus_dmamap_sync((sc)->tulip_dmatag, (sc)->tulip_txdescmap, \
809			(caddr_t) di - (caddr_t) (sc)->tulip_txdescs, \
810			(s), BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
811#define	TULIP_TXMAP_PRESYNC(sc, map) \
812	bus_dmamap_sync((sc)->tulip_dmatag, (map), 0, (map)->dm_mapsize, \
813			BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
814#define	TULIP_TXMAP_POSTSYNC(sc, map) \
815	bus_dmamap_sync((sc)->tulip_dmatag, (map), 0, (map)->dm_mapsize, \
816			BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
817#define	TULIP_TXMAP_CREATE(sc, mapp) \
818	bus_dmamap_create((sc)->tulip_dmatag, TULIP_DATA_PER_DESC, \
819			  TULIP_MAX_TXSEG, TULIP_DATA_PER_DESC, \
820			  0, BUS_DMA_NOWAIT, (mapp))
821#else
822#ifdef __alpha__
823#define TULIP_TXDESC_PRESYNC(sc, di, s)		alpha_mb()
824#define TULIP_TXDESC_POSTSYNC(sc, di, s)	alpha_mb()
825#define TULIP_TXMAP_PRESYNC(sc, map)		alpha_mb()
826#define TULIP_TXMAP_POSTSYNC(sc, map)		alpha_mb()
827#else
828#define TULIP_TXDESC_PRESYNC(sc, di, s)		do { } while (0)
829#define TULIP_TXDESC_POSTSYNC(sc, di, s)	do { } while (0)
830#define TULIP_TXMAP_PRESYNC(sc, map)		do { } while (0)
831#define TULIP_TXMAP_POSTSYNC(sc, map)		do { } while (0)
832#endif
833#define TULIP_TXMAP_CREATE(sc, mapp)		do { } while (0)
834#endif
835
836#ifdef notyet
837#define	SIOCGADDRROM		_IOW('i', 240, struct ifreq)	/* get 128 bytes of ROM */
838#define	SIOCGCHIPID		_IOWR('i', 241, struct ifreq)	/* get chipid */
839#endif
840
841#if defined(TULIP_HDR_DATA)
842static tulip_softc_t *tulips[TULIP_MAX_DEVICES];
843#endif
844
845#if defined(TULIP_USE_SOFTINTR)
846NETISR_SET(NETISR_DE, tulip_softintr);
847#endif
848
849#define	loudprintf			if (bootverbose) printf
850
851#ifndef	tulip_if
852#define	tulip_if	tulip_ac.ac_if
853#endif
854#define	tulip_xname	tulip_if.if_xname
855#ifndef tulip_enaddr
856#define	tulip_enaddr	tulip_ac.ac_enaddr
857#endif
858
859#if !defined(TULIP_KVATOPHYS) && (!defined(TULIP_BUS_DMA) || defined(TULIP_BUS_DMA_NORX) || defined(TULIP_BUS_DMA_NOTX))
860#if defined(__alpha__)
861/* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */
862#define vtobus(va)	alpha_XXX_dmamap((vm_offset_t)va)
863#else
864#define vtobus(va)	vtophys(va)
865#endif
866#define	TULIP_KVATOPHYS(sc, va)		vtobus(va)
867#endif
868
869#if defined(TULIP_PERFSTATS)
870#define	TULIP_PERFMERGE(sc, member) \
871	do { (sc)->tulip_perfstats[TULIP_PERF_TOTAL].member \
872	     += (sc)->tulip_perfstats[TULIP_PERF_CURRENT].member; \
873	 (sc)->tulip_perfstats[TULIP_PERF_PREVIOUS].member \
874	      = (sc)->tulip_perfstats[TULIP_PERF_CURRENT].member; \
875	    (sc)->tulip_perfstats[TULIP_PERF_CURRENT].member = 0; } while (0)
876#define	TULIP_PERFSTART(name) const tulip_cycle_t perfstart_ ## name = TULIP_PERFREAD();
877#define	TULIP_PERFEND(name)	do { \
878	    (sc)->tulip_curperfstats.perf_ ## name ## _cycles += TULIP_PERFDIFF(perfstart_ ## name, TULIP_PERFREAD()); \
879	    (sc)->tulip_curperfstats.perf_ ## name ++; \
880	} while (0)
881#if defined(__i386__)
882typedef u_quad_t tulip_cycle_t;
883static __inline__ tulip_cycle_t
884TULIP_PERFREAD(
885    void)
886{
887    tulip_cycle_t x;
888    __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
889    return x;
890}
891#define	TULIP_PERFDIFF(s, f)	((f) - (s))
892#elif defined(__alpha__)
893typedef unsigned long tulip_cycle_t;
894static __inline__ tulip_cycle_t
895TULIP_PERFREAD(
896    void)
897{
898    tulip_cycle_t x;
899    __asm__ volatile ("rpcc %0" : "=r" (x));
900    return x;
901}
902#define	TULIP_PERFDIFF(s, f)	((unsigned int) ((f) - (s)))
903#endif
904#else
905#define	TULIP_PERFSTART(name)
906#define	TULIP_PERFEND(name)	do { } while (0)
907#define	TULIP_PERFMERGE(s,n)	do { } while (0)
908#endif /* TULIP_PERFSTATS */
909
910#define	TULIP_CRC32_POLY	0xEDB88320UL	/* CRC-32 Poly -- Little Endian */
911#define	TULIP_MAX_TXSEG		30
912
913#define	TULIP_ADDREQUAL(a1, a2) \
914	(((u_int16_t *)a1)[0] == ((u_int16_t *)a2)[0] \
915	 && ((u_int16_t *)a1)[1] == ((u_int16_t *)a2)[1] \
916	 && ((u_int16_t *)a1)[2] == ((u_int16_t *)a2)[2])
917#define	TULIP_ADDRBRDCST(a1) \
918	(((u_int16_t *)a1)[0] == 0xFFFFU \
919	 && ((u_int16_t *)a1)[1] == 0xFFFFU \
920	 && ((u_int16_t *)a1)[2] == 0xFFFFU)
921
922#endif /* !defined(_DEVAR_H) */
923