xref: /illumos-gate/usr/src/uts/sun/io/eri/eri.h (revision bd78278b)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5d64540e3Sgd  * Common Development and Distribution License (the "License").
6d64540e3Sgd  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*bd78278bSGarrett D'Amore  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_ERI_H
277c478bd9Sstevel@tonic-gate #define	_SYS_ERI_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #ifdef _KERNEL
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate /* Named Dispatch Parameter Management Structure */
377c478bd9Sstevel@tonic-gate typedef struct param_s {
387c478bd9Sstevel@tonic-gate 	uint32_t param_min;
397c478bd9Sstevel@tonic-gate 	uint32_t param_max;
407c478bd9Sstevel@tonic-gate 	uint32_t param_val;
417c478bd9Sstevel@tonic-gate 	char   *param_name;
427c478bd9Sstevel@tonic-gate } param_t;
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #define	ERI_PARAM_CNT	51
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate typedef enum  {
477c478bd9Sstevel@tonic-gate 	MIF_POLL_STOP,
487c478bd9Sstevel@tonic-gate 	MIF_POLL_START
497c478bd9Sstevel@tonic-gate } soft_mif_enable_t;
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * kstats
547c478bd9Sstevel@tonic-gate  */
557c478bd9Sstevel@tonic-gate typedef struct stats {
567c478bd9Sstevel@tonic-gate 	/*
577c478bd9Sstevel@tonic-gate 	 * Link Input/Output stats
587c478bd9Sstevel@tonic-gate 	 * ifspeed is now in bits/second.
597c478bd9Sstevel@tonic-gate 	 */
607c478bd9Sstevel@tonic-gate 	uint64_t	ipackets64;
617c478bd9Sstevel@tonic-gate 	uint64_t	iipackets64;
627c478bd9Sstevel@tonic-gate 	uint32_t	ierrors;
637c478bd9Sstevel@tonic-gate 	uint64_t	opackets64;
647c478bd9Sstevel@tonic-gate 	uint64_t	oerrors;
657c478bd9Sstevel@tonic-gate 	uint32_t	collisions;
667c478bd9Sstevel@tonic-gate 	uint64_t	ifspeed;
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate 	/*
697c478bd9Sstevel@tonic-gate 	 * MAC TX Event stats
707c478bd9Sstevel@tonic-gate 	 */
717c478bd9Sstevel@tonic-gate 	uint32_t	txmac_urun;
727c478bd9Sstevel@tonic-gate 	uint32_t	txmac_maxpkt_err;
737c478bd9Sstevel@tonic-gate 	uint32_t	excessive_coll;
747c478bd9Sstevel@tonic-gate 	uint32_t	late_coll;
757c478bd9Sstevel@tonic-gate 	uint32_t	first_coll;
767c478bd9Sstevel@tonic-gate 	uint32_t	defer_timer_exp;
777c478bd9Sstevel@tonic-gate 	uint32_t	peak_attempt_cnt;
787c478bd9Sstevel@tonic-gate 	uint32_t	tx_hang;
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate 	/*
817c478bd9Sstevel@tonic-gate 	 * MAC RX Event stats
827c478bd9Sstevel@tonic-gate 	 */
837c478bd9Sstevel@tonic-gate 	uint32_t	rx_corr;
847c478bd9Sstevel@tonic-gate 	uint32_t	no_free_rx_desc;	/* no free rx desc. */
857c478bd9Sstevel@tonic-gate 	uint32_t	rx_overflow;
867c478bd9Sstevel@tonic-gate 	uint32_t	rx_ovrflpkts;
877c478bd9Sstevel@tonic-gate 	uint32_t	rx_hang;
887c478bd9Sstevel@tonic-gate 	uint32_t	rx_align_err;
897c478bd9Sstevel@tonic-gate 	uint32_t	rx_crc_err;
907c478bd9Sstevel@tonic-gate 	uint32_t	rx_length_err;
917c478bd9Sstevel@tonic-gate 	uint32_t	rx_code_viol_err;
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate 	/*
947c478bd9Sstevel@tonic-gate 	 * MAC Control event stats
957c478bd9Sstevel@tonic-gate 	 */
967c478bd9Sstevel@tonic-gate 	uint32_t	pause_rxcount;	/* PAUSE Receive cnt */
977c478bd9Sstevel@tonic-gate 	uint32_t	pause_oncount;
987c478bd9Sstevel@tonic-gate 	uint32_t	pause_offcount;
997c478bd9Sstevel@tonic-gate 	uint32_t	pause_time_count;
100d64540e3Sgd 	uint32_t	pausing;
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate 	/*
1037c478bd9Sstevel@tonic-gate 	 * Software event stats
1047c478bd9Sstevel@tonic-gate 	 */
1057c478bd9Sstevel@tonic-gate 	uint32_t	inits;
1067c478bd9Sstevel@tonic-gate 	uint32_t	rx_inits;
1077c478bd9Sstevel@tonic-gate 	uint32_t	tx_inits;
1087c478bd9Sstevel@tonic-gate 	uint32_t	tnocar;	/* Link down counter */
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate 	uint32_t	jab;
1117c478bd9Sstevel@tonic-gate 	uint32_t	notmds;
1127c478bd9Sstevel@tonic-gate 	uint32_t	nocanput;
1137c478bd9Sstevel@tonic-gate 	uint32_t	allocbfail;
1147c478bd9Sstevel@tonic-gate 	uint32_t	drop;
1157c478bd9Sstevel@tonic-gate 	uint32_t	rx_corrupted;
1167c478bd9Sstevel@tonic-gate 	uint32_t	rx_bad_pkts;
1177c478bd9Sstevel@tonic-gate 	uint32_t	rx_runt;
1187c478bd9Sstevel@tonic-gate 	uint32_t	rx_toolong_pkts;
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate 	/*
1227c478bd9Sstevel@tonic-gate 	 * Fatal errors
1237c478bd9Sstevel@tonic-gate 	 */
1247c478bd9Sstevel@tonic-gate 	uint32_t	rxtag_err;
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate 	/*
1277c478bd9Sstevel@tonic-gate 	 * parity error
1287c478bd9Sstevel@tonic-gate 	 */
1297c478bd9Sstevel@tonic-gate 	uint32_t	parity_error;
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate 	/*
1327c478bd9Sstevel@tonic-gate 	 * Fatal error stats
1337c478bd9Sstevel@tonic-gate 	 */
1347c478bd9Sstevel@tonic-gate 	uint32_t	pci_error_int;	/* PCI error interrupt */
1357c478bd9Sstevel@tonic-gate 	uint32_t	unknown_fatal;	/* unknown fatal errors */
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate 	/*
1387c478bd9Sstevel@tonic-gate 	 * PCI Configuration space staus register
1397c478bd9Sstevel@tonic-gate 	 */
1407c478bd9Sstevel@tonic-gate 	uint32_t	pci_data_parity_err;	/* Data parity err */
1417c478bd9Sstevel@tonic-gate 	uint32_t	pci_signal_target_abort;
1427c478bd9Sstevel@tonic-gate 	uint32_t	pci_rcvd_target_abort;
1437c478bd9Sstevel@tonic-gate 	uint32_t	pci_rcvd_master_abort;
1447c478bd9Sstevel@tonic-gate 	uint32_t	pci_signal_system_err;
1457c478bd9Sstevel@tonic-gate 	uint32_t	pci_det_parity_err;
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate 	/*
1487c478bd9Sstevel@tonic-gate 	 * MIB II variables
1497c478bd9Sstevel@tonic-gate 	 */
1507c478bd9Sstevel@tonic-gate 	uint64_t	rbytes64;	/* # bytes received */
1517c478bd9Sstevel@tonic-gate 	uint64_t	obytes64;	/* # bytes transmitted */
1527c478bd9Sstevel@tonic-gate 	uint32_t	multircv;	/* # multicast packets received */
1537c478bd9Sstevel@tonic-gate 	uint32_t	multixmt;	/* # multicast packets for xmit */
1547c478bd9Sstevel@tonic-gate 	uint32_t	brdcstrcv;	/* # broadcast packets received */
1557c478bd9Sstevel@tonic-gate 	uint32_t	brdcstxmt;	/* # broadcast packets for xmit */
1567c478bd9Sstevel@tonic-gate 	uint32_t	norcvbuf;	/* # rcv packets discarded */
1577c478bd9Sstevel@tonic-gate 	uint32_t	noxmtbuf;	/* # xmit packets discarded */
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate 	uint32_t	pmcap;		/* power management */
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate 	/*
1627c478bd9Sstevel@tonic-gate 	 * Link Status
1637c478bd9Sstevel@tonic-gate 	 */
1647c478bd9Sstevel@tonic-gate 	uint32_t	link_up;
1657c478bd9Sstevel@tonic-gate 	uint32_t	link_duplex;
1667c478bd9Sstevel@tonic-gate } stats_t;
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate #define	HSTAT(erip, x)		erip->stats.x++;
1697c478bd9Sstevel@tonic-gate #define	HSTATN(erip, x, n)	erip->stats.x += n;
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate 
1727c478bd9Sstevel@tonic-gate #define	RX_BCOPY_MAX		704	/* bcopy for packets < 704 bytes */
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate /*
1757c478bd9Sstevel@tonic-gate  * Per-Stream instance state information.
1767c478bd9Sstevel@tonic-gate  *
1777c478bd9Sstevel@tonic-gate  * Each instance is dynamically allocated at open() and free'd
1787c478bd9Sstevel@tonic-gate  * at close().  Each per-Stream instance points to at most one
1797c478bd9Sstevel@tonic-gate  * per-device structure using the sb_erip field.  All instances
1807c478bd9Sstevel@tonic-gate  * are threaded together into one list of active instances
1817c478bd9Sstevel@tonic-gate  * ordered on minor device number.
1827c478bd9Sstevel@tonic-gate  */
1837c478bd9Sstevel@tonic-gate 
1847c478bd9Sstevel@tonic-gate #define	NMCFILTER_BITS	256		/* # of multicast filter bits */
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate /*
1887c478bd9Sstevel@tonic-gate  * Maximum number of receive descriptors posted to the chip.
1897c478bd9Sstevel@tonic-gate  */
1907c478bd9Sstevel@tonic-gate #define	ERI_RPENDING		(erip->rpending)
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate /*
1937c478bd9Sstevel@tonic-gate  * Maximum number of transmit descriptors for lazy reclaim.
1947c478bd9Sstevel@tonic-gate  */
1957c478bd9Sstevel@tonic-gate #define	ERI_TPENDING	(erip->tpending)
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate /*
1987c478bd9Sstevel@tonic-gate  * Return the address of an adjacent descriptor in the given ring.
1997c478bd9Sstevel@tonic-gate  */
2007c478bd9Sstevel@tonic-gate #define	NEXTRMD(erip, rmdp)	(((rmdp) + 1) == (erip)->rmdlimp ?	\
2017c478bd9Sstevel@tonic-gate 	(erip)->rmdp : ((rmdp) + 1))
2027c478bd9Sstevel@tonic-gate #define	NEXTTMD(erip, tmdp)	(((tmdp) + 1) == (erip)->eri_tmdlimp ?	\
2037c478bd9Sstevel@tonic-gate 	(erip)->eri_tmdp : ((tmdp) + 1))
2047c478bd9Sstevel@tonic-gate #define	PREVTMD(erip, tmdp)	((tmdp) == (erip)->eri_tmdp ?		\
2057c478bd9Sstevel@tonic-gate 	((erip)->eri_tmdlimp - 1) : ((tmdp) - 1))
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate #define	MSECOND(t)	t
2087c478bd9Sstevel@tonic-gate #define	SECOND(t)	t*1000
2097c478bd9Sstevel@tonic-gate #define	ERI_TICKS	MSECOND(100)
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate #define	ERI_NTRIES_LOW		(SECOND(5)/ERI_TICKS)   /* 5 Seconds */
2127c478bd9Sstevel@tonic-gate #define	ERI_NTRIES_HIGH		(SECOND(5)/ERI_TICKS)   /* 5 Seconds */
2137c478bd9Sstevel@tonic-gate #define	ERI_NTRIES_LOW_10	(SECOND(2)/ERI_TICKS)   /* 2 Seconds */
2147c478bd9Sstevel@tonic-gate #define	ERI_LINKDOWN_TIME	(SECOND(2)/ERI_TICKS)   /* 2 Seconds */
2157c478bd9Sstevel@tonic-gate 
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate /*
2187c478bd9Sstevel@tonic-gate  * ERI ASIC Revision Numbers
2197c478bd9Sstevel@tonic-gate  */
2207c478bd9Sstevel@tonic-gate #define	ERI_ERIREV_1_0	0x1
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate /*
2237c478bd9Sstevel@tonic-gate  * Link poll interval for detecting change of transceivers
2247c478bd9Sstevel@tonic-gate  */
2257c478bd9Sstevel@tonic-gate #define	ERI_LINKCHECK_TIMER	SECOND(3)
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate /*
2287c478bd9Sstevel@tonic-gate  * Parallel detection Fault restart timer
2297c478bd9Sstevel@tonic-gate  */
2307c478bd9Sstevel@tonic-gate #define	ERI_P_FAULT_TIMER	SECOND(3)
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate /*
2337c478bd9Sstevel@tonic-gate  * Check rmac hang restart timer
2347c478bd9Sstevel@tonic-gate  */
2357c478bd9Sstevel@tonic-gate #define	ERI_CHECK_HANG_TIMER	MSECOND(400)
2367c478bd9Sstevel@tonic-gate #define	ERI_RMAC_HANG_WORKAROUND
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate /*
2397c478bd9Sstevel@tonic-gate  * undefine ERI_PM_WORKAROUND this time. With ERI_PM_WORKAROUND defined,
2407c478bd9Sstevel@tonic-gate  * each non_fatal error causes pci clock to go up for 30 seconds. Therefore,
2417c478bd9Sstevel@tonic-gate  * no TXMAC_UNDERRUN or excessive RXFIFO_OVERFLOW should happen.
2427c478bd9Sstevel@tonic-gate  */
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate /*
2467c478bd9Sstevel@tonic-gate  * Link bringup modes
2477c478bd9Sstevel@tonic-gate  */
2487c478bd9Sstevel@tonic-gate #define	ERI_AUTO_BRINGUP	0
2497c478bd9Sstevel@tonic-gate #define	ERI_FORCED_BRINGUP	1
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate /*
2527c478bd9Sstevel@tonic-gate  * Transceivers selected for use by the driver.
2537c478bd9Sstevel@tonic-gate  */
2547c478bd9Sstevel@tonic-gate #define	NO_XCVR		2
2557c478bd9Sstevel@tonic-gate #define	INTERNAL_XCVR	0
2567c478bd9Sstevel@tonic-gate #define	EXTERNAL_XCVR	1
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate /*
2597c478bd9Sstevel@tonic-gate  * states for manually creating the link down condition
2607c478bd9Sstevel@tonic-gate  */
2617c478bd9Sstevel@tonic-gate #define	ERI_LINKDOWN_OK		0
2627c478bd9Sstevel@tonic-gate #define	ERI_FORCE_LINKDOWN	1
2637c478bd9Sstevel@tonic-gate #define	ERI_LINKDOWN_STARTED	2
2647c478bd9Sstevel@tonic-gate #define	ERI_LINKDOWN_DONE	3
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate /*
2677c478bd9Sstevel@tonic-gate  * states for bringing up the link in auto-negotiation mode
2687c478bd9Sstevel@tonic-gate  */
2697c478bd9Sstevel@tonic-gate #define	ERI_HWAN_TRY		0 /* Try Hardware autonegotiation */
2707c478bd9Sstevel@tonic-gate #define	ERI_HWAN_INPROGRESS	1 /* Hardware autonegotiation in progress */
2717c478bd9Sstevel@tonic-gate #define	ERI_HWAN_SUCCESFUL	2 /* Hardware autonegotiation succesful */
2727c478bd9Sstevel@tonic-gate #define	ERI_HWAN_FAILED		3 /* Hardware autonegotiation failed */
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate /*
2757c478bd9Sstevel@tonic-gate  * states for resetting the transceiver
2767c478bd9Sstevel@tonic-gate  */
2777c478bd9Sstevel@tonic-gate #define	RESET_TO_BE_ISSUED	0 /* Reset command to be issued to the PHY */
2787c478bd9Sstevel@tonic-gate #define	RESET_ISSUED		1 /* Reset command has been issued */
2797c478bd9Sstevel@tonic-gate #define	ISOLATE_ISSUED		2 /* Isolate-remove command has been issued */
2807c478bd9Sstevel@tonic-gate 
2817c478bd9Sstevel@tonic-gate /*
2827c478bd9Sstevel@tonic-gate  * ERI Supported PHY devices
2837c478bd9Sstevel@tonic-gate  * ERI ASIC supports a built in Gigabit Serial LInk Interface and MII
2847c478bd9Sstevel@tonic-gate  * External SERDES interfaces with shared pins.
2857c478bd9Sstevel@tonic-gate  * On some product implementations, the built-in Serial Link may not be present
2867c478bd9Sstevel@tonic-gate  * either because the Serial Link circuitry does not work or because the product
2877c478bd9Sstevel@tonic-gate  * needs to use only the MII interface.
2887c478bd9Sstevel@tonic-gate  * When both the Serial Link and MII PHY's are present, the driver normally
2897c478bd9Sstevel@tonic-gate  * tries to bring up both the links. If both of them come up, it will select the
2907c478bd9Sstevel@tonic-gate  * link defined by the "eri_default_link" variable by default.
2917c478bd9Sstevel@tonic-gate  * The user may use the configuration variable
2927c478bd9Sstevel@tonic-gate  * eri_select_link to manually select
2937c478bd9Sstevel@tonic-gate  * either the Serial Link or the MII PHY to be used.
2947c478bd9Sstevel@tonic-gate  */
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate /*
2977c478bd9Sstevel@tonic-gate  * Values for the eri_serial_link field
2987c478bd9Sstevel@tonic-gate  */
2997c478bd9Sstevel@tonic-gate #define	ERI_SERIAL_LINK_NOT_PRESENT	0
3007c478bd9Sstevel@tonic-gate #define	ERI_SERIAL_LINK_PRESENT		1
3017c478bd9Sstevel@tonic-gate 
3027c478bd9Sstevel@tonic-gate /*
3037c478bd9Sstevel@tonic-gate  * Values for the eri_non-serial-link field
3047c478bd9Sstevel@tonic-gate  */
3057c478bd9Sstevel@tonic-gate #define	ERI_NO_SHARED_PIN_PHY		0
3067c478bd9Sstevel@tonic-gate #define	ERI_MII_PRESENT			1
3077c478bd9Sstevel@tonic-gate #define	ERI_SERDES_PRESENT		2
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate /*
3107c478bd9Sstevel@tonic-gate  * Values for the default selection when both the serial link and
3117c478bd9Sstevel@tonic-gate  * the MII links are present.
3127c478bd9Sstevel@tonic-gate  */
3137c478bd9Sstevel@tonic-gate #define	ERI_DEFAULT_SERIAL_LINK	0
3147c478bd9Sstevel@tonic-gate #define	ERI_DEFAULT_MII_LINK	1
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate /*
3177c478bd9Sstevel@tonic-gate  * Values for the eri_select_link field to manually select the PHY
3187c478bd9Sstevel@tonic-gate  */
3197c478bd9Sstevel@tonic-gate #define	ERI_AUTO_PHY			0	/* Select PHY automatically */
3207c478bd9Sstevel@tonic-gate #define	ERI_USE_SERIAL_LINK		1	/* Select serial-link */
3217c478bd9Sstevel@tonic-gate #define	ERI_USE_NON_SERIAL_LINK		2	/* Select non-serial-link */
3227c478bd9Sstevel@tonic-gate 
3237c478bd9Sstevel@tonic-gate /*
3247c478bd9Sstevel@tonic-gate  * eri_linkup_state" definitions
3257c478bd9Sstevel@tonic-gate  */
3267c478bd9Sstevel@tonic-gate #define	ERI_START_LINK_BRINGUP	0
3277c478bd9Sstevel@tonic-gate #define	ERI_SERIAL_LINK_BRINGUP	1
3287c478bd9Sstevel@tonic-gate #define	ERI_SERDES_LINK_BRINGUP	2
3297c478bd9Sstevel@tonic-gate #define	ERI_MII_LINK_BRINGUP	3
3307c478bd9Sstevel@tonic-gate #define	ERI_DEFAULT_LINK_BRINGUP	4
3317c478bd9Sstevel@tonic-gate #define	ERI_ALT_LINK_BRINGUP	5
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate /*
3347c478bd9Sstevel@tonic-gate  * structure used to detect tx hang condition
3357c478bd9Sstevel@tonic-gate  */
3367c478bd9Sstevel@tonic-gate struct	erisave {
3377c478bd9Sstevel@tonic-gate 	ulong_t	starts;		  /* # of tx packets posted to the hw */
3387c478bd9Sstevel@tonic-gate 	uint64_t reclaim_opackets; /* # of tx packets reclaimed */
3397c478bd9Sstevel@tonic-gate };
3407c478bd9Sstevel@tonic-gate 
3417c478bd9Sstevel@tonic-gate /*
3427c478bd9Sstevel@tonic-gate  * ERI Device Channel instance state information.
3437c478bd9Sstevel@tonic-gate  *
3447c478bd9Sstevel@tonic-gate  * Each instance is dynamically allocated on first attach.
3457c478bd9Sstevel@tonic-gate  */
3467c478bd9Sstevel@tonic-gate struct	eri {
347d64540e3Sgd 	mac_handle_t		mh;		/* GLDv3 handle */
348d64540e3Sgd 	dev_info_t		*dip;		/* associated dev_info */
3497c478bd9Sstevel@tonic-gate 	uint_t			instance;	/* instance */
3507c478bd9Sstevel@tonic-gate 
3517c478bd9Sstevel@tonic-gate 	int			pci_mode;	/* sbus/pci device (future) */
3527c478bd9Sstevel@tonic-gate 	int			cpci_mode;	/* compact pci dev (future) */
3537c478bd9Sstevel@tonic-gate 	int			low_power_mode; /* E* (low power) */
3547c478bd9Sstevel@tonic-gate 	int			asic_rev;	/* ERI ASIC rev no. */
3557c478bd9Sstevel@tonic-gate 	int			board_rev;	/* ERI ASIC rev no. */
356d64540e3Sgd 	int			burstsizes;	/* binary encoded val */
3577c478bd9Sstevel@tonic-gate 	int			pagesize;	/* btop(9f) */
358d64540e3Sgd 	uint32_t		rxfifo_size;	/* RX FIFO size */
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate 	int			rpending;	/* Max.no. of RX bufs post */
3617c478bd9Sstevel@tonic-gate 	int			tpending;	/* Max.no. of tX bufs post */
3627c478bd9Sstevel@tonic-gate 	int			tx_cur_cnt;	/* # of packets for int_me */
3637c478bd9Sstevel@tonic-gate 
364d64540e3Sgd 	uint_t			multi_refcnt;
365d64540e3Sgd 	boolean_t		promisc;
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate 	int			mifpoll_enable;
3687c478bd9Sstevel@tonic-gate 	int			frame_enable;
3697c478bd9Sstevel@tonic-gate 	int			lance_mode_enable;
3707c478bd9Sstevel@tonic-gate 	int			ngu_enable;
3717c478bd9Sstevel@tonic-gate 	int			link_pulse_disabled;
3727c478bd9Sstevel@tonic-gate 	int			xmit_dma_mode;
3737c478bd9Sstevel@tonic-gate 	int			rcv_dma_mode;
374d64540e3Sgd 	uint8_t			ouraddr[ETHERADDRL];	/* unicast address */
375d64540e3Sgd 	uint32_t		flags;		/* misc. flags */
3767c478bd9Sstevel@tonic-gate 	uint32_t		alloc_flag;	/* Buff alloc. status flags */
377d64540e3Sgd 	boolean_t		wantw;		/* xmit: out of resources */
378d64540e3Sgd 
379d64540e3Sgd 	uint16_t		ladrf[NMCFILTER_BITS/16]; /* Multicast filter */
380d64540e3Sgd 	uint16_t		ladrf_refcnt[NMCFILTER_BITS];
3817c478bd9Sstevel@tonic-gate 
3827c478bd9Sstevel@tonic-gate 	volatile struct	global	*globregp;	/* ERI global regs */
3837c478bd9Sstevel@tonic-gate 	volatile struct	etx	*etxregp;	/* ERI ETX regs */
3847c478bd9Sstevel@tonic-gate 	volatile struct	erx	*erxregp;	/* ERI ERX regs */
3857c478bd9Sstevel@tonic-gate 
3867c478bd9Sstevel@tonic-gate 	volatile struct	bmac	*bmacregp;	/* MAC regs */
3877c478bd9Sstevel@tonic-gate 	volatile struct	mif	*mifregp;	/* ERI transceiver */
3887c478bd9Sstevel@tonic-gate 	volatile struct	pcslink	*pcsregp;	/* ERI PCS regs */
3897c478bd9Sstevel@tonic-gate 
3907c478bd9Sstevel@tonic-gate 	uint32_t		*sw_reset_reg;
3917c478bd9Sstevel@tonic-gate 
3927c478bd9Sstevel@tonic-gate 	uint32_t		rx_kick;	/* RX kick register val */
3937c478bd9Sstevel@tonic-gate 	uint32_t		rx_completion;	/* RX completion reg val */
3947c478bd9Sstevel@tonic-gate #ifdef	RCV_OVRFLOW_CORRUPTION_BUG
3957c478bd9Sstevel@tonic-gate 	uint32_t		rx_ovrflpks;	/* RX recompute checksum */
3967c478bd9Sstevel@tonic-gate #endif
3977c478bd9Sstevel@tonic-gate 	uint32_t		tx_kick;	/* TX kick register val */
3987c478bd9Sstevel@tonic-gate 	uint32_t		tx_completion;	/* TX completion reg val */
3997c478bd9Sstevel@tonic-gate 
4007c478bd9Sstevel@tonic-gate 	struct	rmd		*rmdp;		/* rcv descript  ring start */
4017c478bd9Sstevel@tonic-gate 	struct	rmd		*rmdlimp;	/* rcv  descript ring end */
4027c478bd9Sstevel@tonic-gate 	struct	eri_tmd		*eri_tmdp;	/* xmit descript ring start */
4037c478bd9Sstevel@tonic-gate 	struct	eri_tmd		*eri_tmdlimp;	/* xmit descript ring end */
4047c478bd9Sstevel@tonic-gate 	volatile struct	rmd	*rnextp;	/* next chip rmd */
4057c478bd9Sstevel@tonic-gate 	volatile struct	rmd	*rlastp;	/* last free rmd */
4067c478bd9Sstevel@tonic-gate 	volatile struct	eri_tmd	*tnextp;	/* next free tmd */
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate 	volatile struct	eri_tmd	*tcurp;	/* nxt tmd to reclaim(used) */
4097c478bd9Sstevel@tonic-gate 	/*
4107c478bd9Sstevel@tonic-gate 	 * these are handles for the dvma resources reserved
4117c478bd9Sstevel@tonic-gate 	 * by dvma_reserve
4127c478bd9Sstevel@tonic-gate 	 */
4137c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t	eri_dvmarh;	/* dvma recv handle */
4147c478bd9Sstevel@tonic-gate 
4157c478bd9Sstevel@tonic-gate 	/*
4167c478bd9Sstevel@tonic-gate 	 * these are used if dvma reserve fails, and we have to fall
4177c478bd9Sstevel@tonic-gate 	 * back on the older ddi_dma_addr_setup routines
4187c478bd9Sstevel@tonic-gate 	 */
4197c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t	ndmarh[ERI_RMDMAX];
4207c478bd9Sstevel@tonic-gate 
4217c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t	tbuf_handle;
422*bd78278bSGarrett D'Amore 	ddi_acc_handle_t	tbuf_acch;
4237c478bd9Sstevel@tonic-gate 	caddr_t			tbuf_kaddr;
4247c478bd9Sstevel@tonic-gate 	uint32_t		tbuf_ioaddr;
4257c478bd9Sstevel@tonic-gate 
4267c478bd9Sstevel@tonic-gate 	int			rcv_handle_cnt;
4277c478bd9Sstevel@tonic-gate 
4287c478bd9Sstevel@tonic-gate 	int			rx_reset_issued;
4297c478bd9Sstevel@tonic-gate 	int			tx_reset_issued;
4307c478bd9Sstevel@tonic-gate 	int			rxmac_reset_issued;
4317c478bd9Sstevel@tonic-gate 	int			txmac_reset_issued;
4327c478bd9Sstevel@tonic-gate 
4337c478bd9Sstevel@tonic-gate 	int			global_reset_issued;
4347c478bd9Sstevel@tonic-gate 	uint32_t		rpending_mask;
4357c478bd9Sstevel@tonic-gate 	int			rmdmax_mask;
4367c478bd9Sstevel@tonic-gate 	int			init_macregs;
4377c478bd9Sstevel@tonic-gate 
4387c478bd9Sstevel@tonic-gate 	int			phyad;	/* addr of the PHY in use */
4397c478bd9Sstevel@tonic-gate 	int			xcvr;  /* current PHY in use */
4407c478bd9Sstevel@tonic-gate 
4417c478bd9Sstevel@tonic-gate 	int			openloop_autoneg;
4427c478bd9Sstevel@tonic-gate 
4437c478bd9Sstevel@tonic-gate 	uint16_t		mif_config;
4447c478bd9Sstevel@tonic-gate 	uint16_t		mif_mask;
4457c478bd9Sstevel@tonic-gate 
4467c478bd9Sstevel@tonic-gate 	uint32_t		tx_config;
4477c478bd9Sstevel@tonic-gate 
4487c478bd9Sstevel@tonic-gate 	uint32_t		vendor_id;	/* Vendor ID	*/
4497c478bd9Sstevel@tonic-gate 	uint16_t		device_id;	/* Device Model	*/
4507c478bd9Sstevel@tonic-gate 	uint16_t		device_rev;	/* Device Rev.	*/
4517c478bd9Sstevel@tonic-gate 	uint32_t		phy_address;	/* PHY Address	*/
4527c478bd9Sstevel@tonic-gate 	uint32_t		xcvr_status;	/* xcvr_status	*/
4537c478bd9Sstevel@tonic-gate 	uint32_t		xcvr_state;	/* xcvr_state	*/
4547c478bd9Sstevel@tonic-gate 	uint32_t		bringup_mode;	/* Bringup Mode	*/
4557c478bd9Sstevel@tonic-gate 	uint32_t		speed;		/* Current speed */
4567c478bd9Sstevel@tonic-gate 	uint32_t		duplex;		/* Xcvr Duplex	*/
4577c478bd9Sstevel@tonic-gate 	uint32_t		capability;	/* Xcvr Capability */
4587c478bd9Sstevel@tonic-gate 
4597c478bd9Sstevel@tonic-gate 	uint16_t		mii_control;
4607c478bd9Sstevel@tonic-gate 	uint16_t		mii_status;
4617c478bd9Sstevel@tonic-gate 	uint16_t		mii_anar;
4627c478bd9Sstevel@tonic-gate 	uint16_t		mii_lpanar;
4637c478bd9Sstevel@tonic-gate 
4647c478bd9Sstevel@tonic-gate 	int			autoneg;
4657c478bd9Sstevel@tonic-gate 	int			force_linkdown;
4667c478bd9Sstevel@tonic-gate 	int			mode;
4677c478bd9Sstevel@tonic-gate 
4687c478bd9Sstevel@tonic-gate 	int			linkup_10;
4697c478bd9Sstevel@tonic-gate 	int			pace_count;	/* pacing pkt count */
4707c478bd9Sstevel@tonic-gate 
4717c478bd9Sstevel@tonic-gate 	int			nlasttries;
4727c478bd9Sstevel@tonic-gate 	int			ntries;
4737c478bd9Sstevel@tonic-gate 	int			delay;
4747c478bd9Sstevel@tonic-gate 	int			linkup_attempts;
4757c478bd9Sstevel@tonic-gate 
4767c478bd9Sstevel@tonic-gate 	int			polling_on;
4777c478bd9Sstevel@tonic-gate 	int			mifpoll_data;
4787c478bd9Sstevel@tonic-gate 	int			mifpoll_flag; /* indicates MIF intr */
4797c478bd9Sstevel@tonic-gate 
4807c478bd9Sstevel@tonic-gate 	int			pauseTX;	/* pcs link-pause TX enable */
4817c478bd9Sstevel@tonic-gate 	int			pauseRX;	/* pcs link-pause RX enable */
4827c478bd9Sstevel@tonic-gate 	int			macfdx;	/* mac full-duplex mode */
4837c478bd9Sstevel@tonic-gate 	timeout_id_t		timerid;	/* timer id for links */
4847c478bd9Sstevel@tonic-gate 	int			linkup_cnt;
4857c478bd9Sstevel@tonic-gate 
4867c478bd9Sstevel@tonic-gate 	uint16_t		aner;	/* MII ANER register */
4877c478bd9Sstevel@tonic-gate 
4887c478bd9Sstevel@tonic-gate 	int			linkup;		/* selected link status */
4897c478bd9Sstevel@tonic-gate 	int			linkup_state; /* link bringup state */
4907c478bd9Sstevel@tonic-gate 	int			linkup_changed; /* link bringup state */
4917c478bd9Sstevel@tonic-gate 
4927c478bd9Sstevel@tonic-gate 	int			linkcheck;
4937c478bd9Sstevel@tonic-gate 	caddr_t			g_nd;	/* head of the */
4947c478bd9Sstevel@tonic-gate 						/* named dispatch table */
4957c478bd9Sstevel@tonic-gate 
4967c478bd9Sstevel@tonic-gate 	ddi_device_acc_attr_t	dev_attr;
4977c478bd9Sstevel@tonic-gate 	ddi_iblock_cookie_t	cookie;	/* interrupt cookie */
4987c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t	globregh;   /* ERI global regs */
4997c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t	etxregh;    /* ERI ETX regs */
5007c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t	erxregh;    /* ERI ERX regs */
5017c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t	bmacregh;   /* BigMAC registers */
5027c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t	mifregh;    /* ERI transceiver */
5037c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t	pcsregh;    /* ERI PCS regs */
5047c478bd9Sstevel@tonic-gate 
5057c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t	sw_reset_regh;	/* ERI Reset Reg */
5067c478bd9Sstevel@tonic-gate 
5077c478bd9Sstevel@tonic-gate 	ddi_dma_cookie_t	md_c;	/* trmd dma cookie */
5087c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t	mdm_h;	/* trmd memory handle */
5097c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t	md_h;	/* trmdp dma handle */
5107c478bd9Sstevel@tonic-gate 
5117c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t	pci_config_handle; /* ERI PCI config */
5127c478bd9Sstevel@tonic-gate 
5137c478bd9Sstevel@tonic-gate 	/*
5147c478bd9Sstevel@tonic-gate 	 * DDI dma handle, kernel virtual base,
5157c478bd9Sstevel@tonic-gate 	 * and io virtual base of IOPB area.
5167c478bd9Sstevel@tonic-gate 	 */
5177c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t	iopbhandle;
5187c478bd9Sstevel@tonic-gate 	uintptr_t		iopbkbase;
5197c478bd9Sstevel@tonic-gate 	uintptr_t		iopbiobase;
5207c478bd9Sstevel@tonic-gate 	kstat_t			*ksp;		/* kstat pointer */
5217c478bd9Sstevel@tonic-gate 
5227c478bd9Sstevel@tonic-gate 	kmutex_t		xmitlock;	/* protect xmit-side fields */
5237c478bd9Sstevel@tonic-gate 	kmutex_t		xcvrlock;	/* */
5247c478bd9Sstevel@tonic-gate 	kmutex_t		intrlock;	/* protect intr-side fields */
5257c478bd9Sstevel@tonic-gate 	kmutex_t		linklock;	/* protect link-side fields */
5267c478bd9Sstevel@tonic-gate 
5277c478bd9Sstevel@tonic-gate 	mblk_t		*tmblkp[ERI_TMDMAX]; /* mblks assoc with TMD */
5287c478bd9Sstevel@tonic-gate 	mblk_t		*rmblkp[ERI_RMDMAX]; /* mblks assoc with RMD */
5297c478bd9Sstevel@tonic-gate 	param_t		param_arr[ERI_PARAM_CNT];
5307c478bd9Sstevel@tonic-gate 
5317c478bd9Sstevel@tonic-gate 	struct	stats stats;	/* kstats */
5327c478bd9Sstevel@tonic-gate 
5337c478bd9Sstevel@tonic-gate 	/*
5347c478bd9Sstevel@tonic-gate 	 * Check if transmitter is hung
5357c478bd9Sstevel@tonic-gate 	 */
5367c478bd9Sstevel@tonic-gate 	uint32_t	starts;
5377c478bd9Sstevel@tonic-gate 	uint32_t	txhung;
5387c478bd9Sstevel@tonic-gate 	struct		erisave erisave;
5397c478bd9Sstevel@tonic-gate 
5407c478bd9Sstevel@tonic-gate 	uint64_t	ifspeed_old;
5417c478bd9Sstevel@tonic-gate 
5427c478bd9Sstevel@tonic-gate #ifdef ERI_RMAC_HANG_WORKAROUND
5437c478bd9Sstevel@tonic-gate 	uint32_t	check_rmac_hang;
5447c478bd9Sstevel@tonic-gate 	uint32_t	check2_rmac_hang;
5457c478bd9Sstevel@tonic-gate 	uint32_t	rxfifo_wr_ptr;
5467c478bd9Sstevel@tonic-gate 	uint32_t	rxfifo_rd_ptr;
5477c478bd9Sstevel@tonic-gate 	uint32_t	rxfifo_wr_ptr_c;
5487c478bd9Sstevel@tonic-gate 	uint32_t	rxfifo_rd_ptr_c;
5497c478bd9Sstevel@tonic-gate #endif
5507c478bd9Sstevel@tonic-gate 	uint32_t	tx_int_me;
5517c478bd9Sstevel@tonic-gate };
5527c478bd9Sstevel@tonic-gate 
553d64540e3Sgd /*
554d64540e3Sgd  * LADRF bit array manipulation macros.  These are for working within the
555d64540e3Sgd  * array of words defined by erip->ladrf, converting a bit (0-255) into
556d64540e3Sgd  * the index and offset in the ladrf bit array.  Note that the array is
557d64540e3Sgd  * provided in "Big Endian" order.
558d64540e3Sgd  */
559d64540e3Sgd #define	LADRF_MASK(bit)		(1 << ((bit) % 16))
560d64540e3Sgd #define	LADRF_WORD(erip, bit)	erip->ladrf[(15 - ((bit) / 16))]
561d64540e3Sgd #define	LADRF_SET(erip, bit)	(LADRF_WORD(erip, bit) |= LADRF_MASK(bit))
562d64540e3Sgd #define	LADRF_CLR(erip, bit)	(LADRF_WORD(erip, bit) &= ~LADRF_MASK(bit))
5637c478bd9Sstevel@tonic-gate 
5647c478bd9Sstevel@tonic-gate /*
5657c478bd9Sstevel@tonic-gate  * ERI IOCTLS.
5667c478bd9Sstevel@tonic-gate  * Change : TODO : MBE
5677c478bd9Sstevel@tonic-gate  */
5687c478bd9Sstevel@tonic-gate #define	ERIIOC		('G' << 8)
5697c478bd9Sstevel@tonic-gate #define	ERI_SET_LOOP_MODE	(ERIIOC|1)	/* Set Rio Loopback mode */
5707c478bd9Sstevel@tonic-gate #define	ERI_GET_LOOP_MODE	(ERIIOC|2)	/* Get Rio Loopback modes */
5717c478bd9Sstevel@tonic-gate #define	ERI_GET_LOOP_IFCNT	(ERIIOC|4)	/* Get Rio IF Count */
5727c478bd9Sstevel@tonic-gate 
5737c478bd9Sstevel@tonic-gate /*
5747c478bd9Sstevel@tonic-gate  * Loopback modes: For diagnostic testing purposes the ERI card
5757c478bd9Sstevel@tonic-gate  * can be placed in loopback mode.
5767c478bd9Sstevel@tonic-gate  * There are three modes of loopback provided by the driver,
5777c478bd9Sstevel@tonic-gate  * Mac loopback, PCS loopback and Serdes loopback.
5787c478bd9Sstevel@tonic-gate  */
5797c478bd9Sstevel@tonic-gate #define	ERI_LOOPBACK_OFF		0
5807c478bd9Sstevel@tonic-gate #define	ERI_MAC_LOOPBACK_ON		1
5817c478bd9Sstevel@tonic-gate #define	ERI_PCS_LOOPBACK_ON 		2
5827c478bd9Sstevel@tonic-gate #define	ERI_SER_LOOPBACK_ON 		4
5837c478bd9Sstevel@tonic-gate typedef struct {
5847c478bd9Sstevel@tonic-gate 	int loopback;
5857c478bd9Sstevel@tonic-gate } loopback_t;
5867c478bd9Sstevel@tonic-gate 
5877c478bd9Sstevel@tonic-gate 
5887c478bd9Sstevel@tonic-gate /*
5897c478bd9Sstevel@tonic-gate  * flags
5907c478bd9Sstevel@tonic-gate  * TODO : MBE
5917c478bd9Sstevel@tonic-gate  */
5927c478bd9Sstevel@tonic-gate #define	ERI_UNKOWN	0x00	/* unknown state	*/
5937c478bd9Sstevel@tonic-gate #define	ERI_RUNNING	0x01	/* chip is initialized	*/
594d64540e3Sgd #define	ERI_STARTED	0x02	/* mac layer started */
5957c478bd9Sstevel@tonic-gate #define	ERI_SUSPENDED	0x08	/* suspended interface	*/
5967c478bd9Sstevel@tonic-gate #define	ERI_INITIALIZED	0x10	/* interface initialized */
5977c478bd9Sstevel@tonic-gate #define	ERI_NOTIMEOUTS	0x20	/* disallow timeout rescheduling */
5987c478bd9Sstevel@tonic-gate #define	ERI_TXINIT	0x40	/* TX Portion Init'ed	*/
5997c478bd9Sstevel@tonic-gate #define	ERI_RXINIT	0x80	/* RX Portion Init'ed	*/
6007c478bd9Sstevel@tonic-gate #define	ERI_MACLOOPBACK	0x100	/* device has MAC int lpbk (DIAG) */
6017c478bd9Sstevel@tonic-gate #define	ERI_SERLOOPBACK	0x200	/* device has SERDES int lpbk (DIAG) */
6027c478bd9Sstevel@tonic-gate #define	ERI_DLPI_LINKUP	0x400	/* */
6037c478bd9Sstevel@tonic-gate 
6047c478bd9Sstevel@tonic-gate /*
6057c478bd9Sstevel@tonic-gate  * Mac address flags
6067c478bd9Sstevel@tonic-gate  */
6077c478bd9Sstevel@tonic-gate #define	ERI_FACTADDR_PRESENT	0x01	/* factory MAC id present */
6087c478bd9Sstevel@tonic-gate #define	ERI_FACTADDR_USE	0x02	/* use factory MAC id */
6097c478bd9Sstevel@tonic-gate 
6107c478bd9Sstevel@tonic-gate struct erikstat {
6117c478bd9Sstevel@tonic-gate 	/*
6127c478bd9Sstevel@tonic-gate 	 * Software event stats
6137c478bd9Sstevel@tonic-gate 	 */
6147c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_inits;
6157c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_rx_inits;
6167c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_tx_inits;
6177c478bd9Sstevel@tonic-gate 
6187c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_allocbfail;
6197c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_drop;
6207c478bd9Sstevel@tonic-gate 
6217c478bd9Sstevel@tonic-gate 	/*
6227c478bd9Sstevel@tonic-gate 	 * MAC Control event stats
6237c478bd9Sstevel@tonic-gate 	 */
6247c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_pause_rxcount; /* PAUSE Receive count */
6257c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_pause_oncount;
6267c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_pause_offcount;
6277c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_pause_time_count;
6287c478bd9Sstevel@tonic-gate 
6297c478bd9Sstevel@tonic-gate 	/*
6307c478bd9Sstevel@tonic-gate 	 * MAC TX Event stats
6317c478bd9Sstevel@tonic-gate 	 */
6327c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_txmac_maxpkt_err;
6337c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_defer_timer_exp;
6347c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_peak_attempt_cnt;
6357c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_jab;
6367c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_notmds;
6377c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_tx_hang;
6387c478bd9Sstevel@tonic-gate 
6397c478bd9Sstevel@tonic-gate 	/*
6407c478bd9Sstevel@tonic-gate 	 * MAC RX Event stats
6417c478bd9Sstevel@tonic-gate 	 */
6427c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_no_free_rx_desc; /* no free rx desc. */
6437c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_rx_hang;
6447c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_rx_length_err;
6457c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_rx_code_viol_err;
6467c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_rx_bad_pkts;
6477c478bd9Sstevel@tonic-gate 
6487c478bd9Sstevel@tonic-gate 	/*
6497c478bd9Sstevel@tonic-gate 	 * Fatal errors
6507c478bd9Sstevel@tonic-gate 	 */
6517c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_rxtag_err;
6527c478bd9Sstevel@tonic-gate 
6537c478bd9Sstevel@tonic-gate 	/*
6547c478bd9Sstevel@tonic-gate 	 * Parity error
6557c478bd9Sstevel@tonic-gate 	 */
6567c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_parity_error;
6577c478bd9Sstevel@tonic-gate 
6587c478bd9Sstevel@tonic-gate 	/*
6597c478bd9Sstevel@tonic-gate 	 * PCI fatal error stats
6607c478bd9Sstevel@tonic-gate 	 */
6617c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_pci_error_int;  /* PCI error interrupt */
6627c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_unknown_fatal;	/* unknow fatal error */
6637c478bd9Sstevel@tonic-gate 
6647c478bd9Sstevel@tonic-gate 	/*
6657c478bd9Sstevel@tonic-gate 	 * PCI Configuration space staus register
6667c478bd9Sstevel@tonic-gate 	 */
6677c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_pci_data_parity_err; /* dparity err */
6687c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_pci_signal_target_abort;
6697c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_pci_rcvd_target_abort;
6707c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_pci_rcvd_master_abort;
6717c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_pci_signal_system_err;
6727c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_pci_det_parity_err;
6737c478bd9Sstevel@tonic-gate 
6747c478bd9Sstevel@tonic-gate 
6757c478bd9Sstevel@tonic-gate 	struct kstat_named	erik_pmcap;	/* Power management */
6767c478bd9Sstevel@tonic-gate };
6777c478bd9Sstevel@tonic-gate 
6787c478bd9Sstevel@tonic-gate /* TBD: new value ? */
6797c478bd9Sstevel@tonic-gate #define	ERI_DRAINTIME	(400000)	/* # microseconds xmit drain */
6807c478bd9Sstevel@tonic-gate 
6817c478bd9Sstevel@tonic-gate #define	ROUNDUP(a, n)	(((a) + ((n) - 1)) & ~((n) - 1))
6827c478bd9Sstevel@tonic-gate #define	ROUNDUP2(a, n)	(uchar_t *)((((uintptr_t)(a)) + ((n) - 1)) & ~((n) - 1))
6837c478bd9Sstevel@tonic-gate 
6847c478bd9Sstevel@tonic-gate /*
6857c478bd9Sstevel@tonic-gate  * Xmit/receive buffer structure.
6867c478bd9Sstevel@tonic-gate  * This structure is organized to meet the following requirements:
6877c478bd9Sstevel@tonic-gate  * - hb_buf starts on an ERI_BURSTSIZE boundary.
6887c478bd9Sstevel@tonic-gate  * - eribuf is an even multiple of ERI_BURSTSIZE
6897c478bd9Sstevel@tonic-gate  * - hb_buf[] is large enough to contain max frame (1518) plus
6907c478bd9Sstevel@tonic-gate  *   (3 x ERI_BURSTSIZE) rounded up to the next ERI_BURSTSIZE
6917c478bd9Sstevel@tonic-gate  */
6927c478bd9Sstevel@tonic-gate /*
6937c478bd9Sstevel@tonic-gate  * #define		ERI_BURSTSIZE	(64)
6947c478bd9Sstevel@tonic-gate  */
6957c478bd9Sstevel@tonic-gate #define		ERI_BURSTSIZE	(128)
6967c478bd9Sstevel@tonic-gate #define		ERI_BURSTMASK	(ERIBURSTSIZE - 1)
6977c478bd9Sstevel@tonic-gate #define		ERI_BUFSIZE	(1728)	/* (ETHERMTU + 228) */
6987c478bd9Sstevel@tonic-gate #define		ERI_HEADROOM	(34)
6997c478bd9Sstevel@tonic-gate 
7007c478bd9Sstevel@tonic-gate /* Offset for the first byte in the receive buffer */
7017c478bd9Sstevel@tonic-gate #define	ERI_FSTBYTE_OFFSET	2
7027c478bd9Sstevel@tonic-gate #define	ERI_CKSUM_OFFSET	14
7037c478bd9Sstevel@tonic-gate 
7047c478bd9Sstevel@tonic-gate 
7057c478bd9Sstevel@tonic-gate #define	ERI_PMCAP_NONE	0
7067c478bd9Sstevel@tonic-gate #define	ERI_PMCAP_4MHZ	4
7077c478bd9Sstevel@tonic-gate 
7087c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
7097c478bd9Sstevel@tonic-gate 
7107c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
7117c478bd9Sstevel@tonic-gate }
7127c478bd9Sstevel@tonic-gate #endif
7137c478bd9Sstevel@tonic-gate 
7147c478bd9Sstevel@tonic-gate #endif	/* _SYS_ERI_H */
715