xref: /onnv-gate/usr/src/uts/common/sys/gld.h (revision 5895:f251acdd9bdc)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52760Sdg199075  * Common Development and Distribution License (the "License").
62760Sdg199075  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*5895Syz147064  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate /*
270Sstevel@tonic-gate  * gld - Generic LAN Driver support system for DLPI drivers.
280Sstevel@tonic-gate  */
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #ifndef	_SYS_GLD_H
310Sstevel@tonic-gate #define	_SYS_GLD_H
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #include <sys/ethernet.h>
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #ifdef	__cplusplus
380Sstevel@tonic-gate extern "C" {
390Sstevel@tonic-gate #endif
400Sstevel@tonic-gate 
410Sstevel@tonic-gate /*
420Sstevel@tonic-gate  * Media specific MIB-II counters/statistics
430Sstevel@tonic-gate  *
440Sstevel@tonic-gate  * This only includes those that aren't in the legacy counters.
450Sstevel@tonic-gate  */
460Sstevel@tonic-gate 
470Sstevel@tonic-gate typedef union media_stats {
480Sstevel@tonic-gate 	struct dot3stat {
490Sstevel@tonic-gate 		/* Ethernet: RFC1643 Dot3Stats (subset) */
500Sstevel@tonic-gate 		uint32_t	first_coll;	/* SingleCollisionFrames */
510Sstevel@tonic-gate 		uint32_t	multi_coll;	/* MultipleCollisionFrames */
520Sstevel@tonic-gate 		uint32_t	sqe_error;	/* SQETestErrors */
530Sstevel@tonic-gate 		uint32_t	mac_xmt_error;	/* InternalMacTransmitErrors */
540Sstevel@tonic-gate 		uint32_t	frame_too_long;	/* FrameTooLongs */
550Sstevel@tonic-gate 		uint32_t	mac_rcv_error;	/* InternalMacReceiveErrors */
560Sstevel@tonic-gate 	} dot3;
570Sstevel@tonic-gate 	struct dot5stat {
580Sstevel@tonic-gate 		/* Token Ring: RFC1748 Dot5Stats (subset) */
590Sstevel@tonic-gate 		uint32_t	ace_error;
600Sstevel@tonic-gate 		uint32_t	internal_error;
610Sstevel@tonic-gate 		uint32_t	lost_frame_error;
620Sstevel@tonic-gate 		uint32_t	frame_copied_error;
630Sstevel@tonic-gate 		uint32_t	token_error;
640Sstevel@tonic-gate 		uint32_t	freq_error;
650Sstevel@tonic-gate 	} dot5;
660Sstevel@tonic-gate 	struct fddistat {
670Sstevel@tonic-gate 		/* FDDI: RFC1512 (subset) */
680Sstevel@tonic-gate 		uint32_t	mac_error;
690Sstevel@tonic-gate 		uint32_t	mac_lost;
700Sstevel@tonic-gate 		uint32_t	mac_token;
710Sstevel@tonic-gate 		uint32_t	mac_tvx_expired;
720Sstevel@tonic-gate 		uint32_t	mac_late;
730Sstevel@tonic-gate 		uint32_t	mac_ring_op;
740Sstevel@tonic-gate 	} fddi;
750Sstevel@tonic-gate 	uint32_t		pad[16];
760Sstevel@tonic-gate } media_stats_t;
770Sstevel@tonic-gate 
780Sstevel@tonic-gate #define	glds_dot3_first_coll		glds_media_specific.dot3.first_coll
790Sstevel@tonic-gate #define	glds_dot3_multi_coll		glds_media_specific.dot3.multi_coll
800Sstevel@tonic-gate #define	glds_dot3_sqe_error		glds_media_specific.dot3.sqe_error
810Sstevel@tonic-gate #define	glds_dot3_mac_xmt_error		glds_media_specific.dot3.mac_xmt_error
820Sstevel@tonic-gate #define	glds_dot3_mac_rcv_error		glds_media_specific.dot3.mac_rcv_error
830Sstevel@tonic-gate #define	glds_dot3_frame_too_long	glds_media_specific.dot3.frame_too_long
840Sstevel@tonic-gate 
850Sstevel@tonic-gate #define	glds_dot5_line_error		glds_crc
860Sstevel@tonic-gate #define	glds_dot5_burst_error		glds_frame
870Sstevel@tonic-gate #define	glds_dot5_ace_error		glds_media_specific.dot5.ace_error
880Sstevel@tonic-gate #define	glds_dot5_internal_error	glds_media_specific.dot5.internal_error
890Sstevel@tonic-gate #define	glds_dot5_lost_frame_error   glds_media_specific.dot5.lost_frame_error
900Sstevel@tonic-gate #define	glds_dot5_frame_copied_error glds_media_specific.dot5.frame_copied_error
910Sstevel@tonic-gate #define	glds_dot5_token_error		glds_media_specific.dot5.token_error
920Sstevel@tonic-gate #define	glds_dot5_signal_loss		glds_nocarrier
930Sstevel@tonic-gate #define	glds_dot5_freq_error		glds_media_specific.dot5.freq_error
940Sstevel@tonic-gate 
950Sstevel@tonic-gate #define	glds_fddi_mac_error		glds_media_specific.fddi.mac_error
960Sstevel@tonic-gate #define	glds_fddi_mac_lost		glds_media_specific.fddi.mac_lost
970Sstevel@tonic-gate #define	glds_fddi_mac_token		glds_media_specific.fddi.mac_token
980Sstevel@tonic-gate #define	glds_fddi_mac_tvx_expired	glds_media_specific.fddi.mac_tvx_expired
990Sstevel@tonic-gate #define	glds_fddi_mac_late		glds_media_specific.fddi.mac_late
1000Sstevel@tonic-gate #define	glds_fddi_mac_ring_op		glds_media_specific.fddi.mac_ring_op
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate /*
1030Sstevel@tonic-gate  * structure for driver statistics
1040Sstevel@tonic-gate  */
1050Sstevel@tonic-gate struct gld_stats {
1060Sstevel@tonic-gate 	ulong_t		glds_multixmt;	/* (G) ifOutMulticastPkts */
1070Sstevel@tonic-gate 	ulong_t		glds_multircv;	/* (G) ifInMulticastPkts */
1080Sstevel@tonic-gate 	ulong_t		glds_brdcstxmt;	/* (G) ifOutBroadcastPkts */
1090Sstevel@tonic-gate 	ulong_t		glds_brdcstrcv;	/* (G) ifInBroadcastPkts */
1100Sstevel@tonic-gate 	uint32_t	glds_blocked;	/* (G) discard: upstream flow cntrl */
1110Sstevel@tonic-gate 	uint32_t	glds_reserved1;
1120Sstevel@tonic-gate 	uint32_t	glds_reserved2;
1130Sstevel@tonic-gate 	uint32_t	glds_reserved3;
1140Sstevel@tonic-gate 	uint32_t	glds_reserved4;
1150Sstevel@tonic-gate 	uint32_t	glds_errxmt;	/* (D) ifOutErrors */
1160Sstevel@tonic-gate 	uint32_t	glds_errrcv;	/* (D) ifInErrors */
1170Sstevel@tonic-gate 	uint32_t	glds_collisions; /* (e) Sun MIB's rsIfCollisions */
1180Sstevel@tonic-gate 	uint32_t	glds_excoll;	/* (e) dot3StatsExcessiveCollisions */
1190Sstevel@tonic-gate 	uint32_t	glds_defer;	/* (e) dot3StatsDeferredTransmissions */
1200Sstevel@tonic-gate 	uint32_t	glds_frame;	/* (e) dot3StatsAlignErrors */
1210Sstevel@tonic-gate 	uint32_t	glds_crc;	/* (e) dot3StatsFCSErrors */
1220Sstevel@tonic-gate 	uint32_t	glds_overflow;	/* (D) */
1230Sstevel@tonic-gate 	uint32_t	glds_underflow;	/* (D) */
1240Sstevel@tonic-gate 	uint32_t	glds_short;	/* (e) */
1250Sstevel@tonic-gate 	uint32_t	glds_missed;	/* (D) */
1260Sstevel@tonic-gate 	uint32_t	glds_xmtlatecoll; /* (e) dot3StatsLateCollisions */
1270Sstevel@tonic-gate 	uint32_t	glds_nocarrier; /* (e) dot3StatsCarrierSenseErrors */
1280Sstevel@tonic-gate 	uint32_t	glds_noxmtbuf;	/* (G) ifOutDiscards */
1290Sstevel@tonic-gate 	uint32_t	glds_norcvbuf;	/* (D) ifInDiscards */
1300Sstevel@tonic-gate 	uint32_t	glds_intr;	/* (D) */
1310Sstevel@tonic-gate 	uint32_t	glds_xmtretry;	/* (G) */
1320Sstevel@tonic-gate 	uint64_t	glds_pktxmt64;	/* (G) 64-bit rsIfOutPackets */
1330Sstevel@tonic-gate 	uint64_t	glds_pktrcv64;	/* (G) 64-bit rsIfInPackets */
1340Sstevel@tonic-gate 	uint64_t	glds_bytexmt64;	/* (G) ifHCOutOctets */
1350Sstevel@tonic-gate 	uint64_t	glds_bytercv64;	/* (G) ifHCInOctets */
1360Sstevel@tonic-gate 	uint64_t	glds_speed;	/* (D) ifSpeed */
1370Sstevel@tonic-gate 	uint32_t	glds_duplex;	/* (e) Invented for GLD */
1380Sstevel@tonic-gate 	uint32_t	glds_media;	/* (D) Invented for GLD */
1390Sstevel@tonic-gate 	uint32_t	glds_unknowns;	/* (G) ifInUnknownProtos */
1400Sstevel@tonic-gate 	uint32_t	reserved[19];
1410Sstevel@tonic-gate 	media_stats_t	glds_media_specific;
1420Sstevel@tonic-gate 	uint32_t	glds_xmtbadinterp; /* (G) bad packet len/format */
1430Sstevel@tonic-gate 	uint32_t	glds_rcvbadinterp; /* (G) bad packet len/format */
1440Sstevel@tonic-gate 	uint32_t	glds_gldnorcvbuf;  /* (G) norcvbuf from inside GLD */
1450Sstevel@tonic-gate };
1460Sstevel@tonic-gate 
1470Sstevel@tonic-gate /*
1480Sstevel@tonic-gate  * gld_mac_info structure.  Used to define the per-board data for all
1490Sstevel@tonic-gate  * drivers.
1500Sstevel@tonic-gate  *
1510Sstevel@tonic-gate  * The below definition of gld_mac_info contains GLD PRIVATE entries that must
1520Sstevel@tonic-gate  * not be used by the device driver. Only entries marked SET BY DRIVER should
1530Sstevel@tonic-gate  * be modified.
1540Sstevel@tonic-gate  */
1550Sstevel@tonic-gate 
1560Sstevel@tonic-gate #define	GLD_STATS_SIZE_ORIG	(sizeof (uint32_t) * 26) /* don't change */
1570Sstevel@tonic-gate #define	GLD_KSTAT_SIZE_ORIG (sizeof (kstat_named_t) * 26) /* don't change */
1580Sstevel@tonic-gate #define	GLD_PAD  ((int)GLD_KSTAT_SIZE_ORIG + (int)GLD_STATS_SIZE_ORIG)
1590Sstevel@tonic-gate 
1600Sstevel@tonic-gate typedef union gld_lock {
1610Sstevel@tonic-gate 	kmutex_t	reserved;
1620Sstevel@tonic-gate 	krwlock_t	gldl_rw_lock;
1630Sstevel@tonic-gate } gld_lock_t;
1640Sstevel@tonic-gate 
1650Sstevel@tonic-gate typedef struct gld_mac_info {
1660Sstevel@tonic-gate 	struct gld_mac_info *gldm_next;			/* GLD PRIVATE */
1670Sstevel@tonic-gate 	struct gld_mac_info *gldm_prev;			/* GLD PRIVATE */
1680Sstevel@tonic-gate 	caddr_t		reserved1;			/* GLD PRIVATE */
1690Sstevel@tonic-gate 	caddr_t		reserved2;			/* GLD PRIVATE */
1700Sstevel@tonic-gate 	uint16_t	gldm_driver_version;		/* GLD PRIVATE */
1710Sstevel@tonic-gate 	uint16_t	gldm_GLD_version;		/* GLD PRIVATE */
1720Sstevel@tonic-gate 	uint16_t	gldm_GLD_flags;			/* GLD PRIVATE */
1730Sstevel@tonic-gate 	uint16_t	gldm_options;			/* GLD_PRIVATE */
1740Sstevel@tonic-gate 	dev_info_t	*gldm_devinfo;			/* SET BY DRIVER */
1750Sstevel@tonic-gate 	uchar_t		*gldm_vendor_addr;		/* SET BY DRIVER */
1760Sstevel@tonic-gate 	uchar_t		*gldm_broadcast_addr;		/* SET BY DRIVER */
1770Sstevel@tonic-gate 	gld_lock_t	gldm_lock;			/* GLD PRIVATE */
1780Sstevel@tonic-gate 	ddi_iblock_cookie_t gldm_cookie;		/* SET BY DRIVER */
179*5895Syz147064 	uint32_t	gldm_margin;			/* SET BY DRIVER */
1800Sstevel@tonic-gate 	uint32_t	reserved4;			/* GLD PRIVATE */
1810Sstevel@tonic-gate 	uint32_t	gldm_maxpkt;			/* SET BY DRIVER */
1820Sstevel@tonic-gate 	uint32_t	gldm_minpkt;			/* SET BY DRIVER */
1830Sstevel@tonic-gate 	char		*gldm_ident;			/* SET BY DRIVER */
1840Sstevel@tonic-gate 	uint32_t	gldm_type;			/* SET BY DRIVER */
1850Sstevel@tonic-gate 	uint32_t	reserved5;			/* GLD PRIVATE */
1860Sstevel@tonic-gate 	uint32_t	gldm_addrlen;			/* SET BY DRIVER */
1870Sstevel@tonic-gate 	int32_t		gldm_saplen;			/* SET BY DRIVER */
1880Sstevel@tonic-gate 							/* NOTE: MUST BE -2 */
1890Sstevel@tonic-gate 	unsigned char	reserved7[ETHERADDRL];		/* GLD PRIVATE */
1900Sstevel@tonic-gate 	unsigned char	reserved8[ETHERADDRL];		/* GLD PRIVATE */
1910Sstevel@tonic-gate 	unsigned char	reserved9[ETHERADDRL];		/* GLD PRIVATE */
1920Sstevel@tonic-gate 	t_uscalar_t	gldm_ppa;			/* SET BY DRIVER */
1930Sstevel@tonic-gate 	int32_t		reserved10;			/* GLD PRIVATE */
1940Sstevel@tonic-gate 	uint32_t	gldm_capabilities; 		/* SET BY DRIVER */
1950Sstevel@tonic-gate 	int32_t		gldm_linkstate;			/* GLD PRIVATE */
1960Sstevel@tonic-gate 	uint32_t	reserved11;			/* GLD PRIVATE */
1970Sstevel@tonic-gate 	caddr_t		reserved12;			/* GLD PRIVATE */
1980Sstevel@tonic-gate 	int32_t		reserved13;			/* GLD PRIVATE */
1990Sstevel@tonic-gate 	uint32_t	reserved14;			/* GLD PRIVATE */
2000Sstevel@tonic-gate 	int32_t		reserved15;			/* GLD PRIVATE */
2010Sstevel@tonic-gate 	caddr_t		gldm_mac_pvt;			/* GLD PRIVATE */
2020Sstevel@tonic-gate 	caddr_t		reserved16;			/* GLD PRIVATE */
2030Sstevel@tonic-gate 	char		reserved17[GLD_PAD];		/* GLD PRIVATE */
2040Sstevel@tonic-gate 	caddr_t		reserved18;			/* GLD PRIVATE */
2050Sstevel@tonic-gate 	caddr_t		gldm_private;			/* GLD PRIVATE */
2060Sstevel@tonic-gate 	int		(*gldm_reset)();		/* SET BY DRIVER */
2070Sstevel@tonic-gate 	int		(*gldm_start)();		/* SET BY DRIVER */
2080Sstevel@tonic-gate 	int		(*gldm_stop)();			/* SET BY DRIVER */
2090Sstevel@tonic-gate 	int		(*gldm_set_mac_addr)();		/* SET BY DRIVER */
2100Sstevel@tonic-gate 	int		(*gldm_send)();			/* SET BY DRIVER */
2110Sstevel@tonic-gate 	int		(*gldm_set_promiscuous)();	/* SET BY DRIVER */
2120Sstevel@tonic-gate 	int		(*gldm_get_stats)();		/* SET BY DRIVER */
2130Sstevel@tonic-gate 	int		(*gldm_ioctl)();		/* SET BY DRIVER */
2140Sstevel@tonic-gate 	int		(*gldm_set_multicast)(); 	/* SET BY DRIVER */
2150Sstevel@tonic-gate 	uint_t		(*gldm_intr)();			/* SET BY DRIVER */
2160Sstevel@tonic-gate 	int		(*gldm_mctl)();			/* SET BY DRIVER */
2170Sstevel@tonic-gate 	int		(*gldm_send_tagged)();		/* SET BY DRIVER */
2180Sstevel@tonic-gate 	/*
2190Sstevel@tonic-gate 	 * The following MDT related entry points are Sun private,
2200Sstevel@tonic-gate 	 * meant only for use by Sun's IPoIB (ibd) driver.
2210Sstevel@tonic-gate 	 */
2220Sstevel@tonic-gate 	int		(*gldm_mdt_pre)();		/* SET BY DRIVER */
2230Sstevel@tonic-gate 	void		(*gldm_mdt_send)();		/* SET BY DRIVER */
2240Sstevel@tonic-gate 	void		(*gldm_mdt_post)();		/* SET BY DRIVER */
2250Sstevel@tonic-gate 	int		gldm_mdt_sgl;			/* SET BY DRIVER */
2260Sstevel@tonic-gate 	int		gldm_mdt_segs;			/* SET BY DRIVER */
2270Sstevel@tonic-gate } gld_mac_info_t;
2280Sstevel@tonic-gate 
2290Sstevel@tonic-gate /* flags for physical promiscuous state */
2300Sstevel@tonic-gate #define	GLD_MAC_PROMISC_NOOP	-1	/* leave mode unchanged		 */
2310Sstevel@tonic-gate #define	GLD_MAC_PROMISC_NONE	0	/* promiscuous mode(s) OFF	 */
2320Sstevel@tonic-gate #define	GLD_MAC_PROMISC_PHYS	1	/* receive all packets		 */
2330Sstevel@tonic-gate #define	GLD_MAC_PROMISC_MULTI	2	/* receive all multicast packets */
2340Sstevel@tonic-gate 
2350Sstevel@tonic-gate #define	GLD_MULTI_ENABLE	1
2360Sstevel@tonic-gate #define	GLD_MULTI_DISABLE	0
2370Sstevel@tonic-gate 
2380Sstevel@tonic-gate /* flags for gldm_capabilities */
2390Sstevel@tonic-gate #define	GLD_CAP_LINKSTATE	0x00000001 /* will call gld_linkstate() */
2400Sstevel@tonic-gate #define	GLD_CAP_CKSUM_IPHDR	0x00000008 /* IP checksum offload	*/
2410Sstevel@tonic-gate #define	GLD_CAP_CKSUM_PARTIAL	0x00000010 /* TCP/UDP partial		*/
242741Smasputra #define	GLD_CAP_CKSUM_FULL_V4	0x00000020 /* TCP/UDP full for IPv4	*/
2430Sstevel@tonic-gate #define	GLD_CAP_ZEROCOPY	0x00000040 /* zerocopy */
244741Smasputra #define	GLD_CAP_CKSUM_FULL_V6	0x00000080 /* TCP/UDP full for IPv6	*/
245741Smasputra #define	GLD_CAP_CKSUM_ANY				\
246741Smasputra 	(GLD_CAP_CKSUM_IPHDR|GLD_CAP_CKSUM_PARTIAL|	\
247741Smasputra 	GLD_CAP_CKSUM_FULL_V4|GLD_CAP_CKSUM_FULL_V6)
2480Sstevel@tonic-gate 
2490Sstevel@tonic-gate /* values of gldm_linkstate, as passed to gld_linkstate() */
2500Sstevel@tonic-gate #define	GLD_LINKSTATE_DOWN	-1
2510Sstevel@tonic-gate #define	GLD_LINKSTATE_UNKNOWN	0
2520Sstevel@tonic-gate #define	GLD_LINKSTATE_UP	1
2530Sstevel@tonic-gate 
2540Sstevel@tonic-gate /*
2550Sstevel@tonic-gate  * media type: this identifies the media/connector currently used by the
2560Sstevel@tonic-gate  * driver.  Possible types will be defined for each DLPI type defined in
2570Sstevel@tonic-gate  * gldm_type.  The below definitions should be used by the device dependent
2580Sstevel@tonic-gate  * drivers to set glds_media.
2590Sstevel@tonic-gate  */
2600Sstevel@tonic-gate 
2610Sstevel@tonic-gate /* if driver cannot determine media/connector type  */
2620Sstevel@tonic-gate #define	GLDM_UNKNOWN	0
2630Sstevel@tonic-gate 
2640Sstevel@tonic-gate #define	GLDM_AUI	1
2650Sstevel@tonic-gate #define	GLDM_BNC	2
2660Sstevel@tonic-gate #define	GLDM_TP		3
2670Sstevel@tonic-gate #define	GLDM_FIBER	4
2680Sstevel@tonic-gate #define	GLDM_100BT	5
2690Sstevel@tonic-gate #define	GLDM_VGANYLAN	6
2700Sstevel@tonic-gate #define	GLDM_10BT	7
2710Sstevel@tonic-gate #define	GLDM_RING4	8
2720Sstevel@tonic-gate #define	GLDM_RING16	9
2730Sstevel@tonic-gate #define	GLDM_PHYMII	10
2740Sstevel@tonic-gate #define	GLDM_100BTX	11
2750Sstevel@tonic-gate #define	GLDM_100BT4	12
2760Sstevel@tonic-gate #define	GLDM_IB		14
2770Sstevel@tonic-gate 
2780Sstevel@tonic-gate /* defines for possible duplex states (glds_duplex) */
2790Sstevel@tonic-gate #define	GLD_DUPLEX_UNKNOWN	0
2800Sstevel@tonic-gate #define	GLD_DUPLEX_HALF		1
2810Sstevel@tonic-gate #define	GLD_DUPLEX_FULL		2
2820Sstevel@tonic-gate 
2830Sstevel@tonic-gate /* Values returned from driver entry points */
2840Sstevel@tonic-gate #define	GLD_SUCCESS		0
2850Sstevel@tonic-gate #define	GLD_NORESOURCES		1
2860Sstevel@tonic-gate #define	GLD_NOTSUPPORTED	2
2870Sstevel@tonic-gate #define	GLD_BADARG		3
2880Sstevel@tonic-gate #define	GLD_NOLINK		4
2890Sstevel@tonic-gate #define	GLD_RETRY		5
2900Sstevel@tonic-gate #define	GLD_FAILURE		(-1)
2910Sstevel@tonic-gate 
2920Sstevel@tonic-gate #if defined(_KERNEL)
2930Sstevel@tonic-gate /* Functions exported to drivers */
2940Sstevel@tonic-gate extern gld_mac_info_t *gld_mac_alloc(dev_info_t *);
2950Sstevel@tonic-gate extern void gld_mac_free(gld_mac_info_t *);
2960Sstevel@tonic-gate extern int gld_register(dev_info_t *, char *, gld_mac_info_t *);
2970Sstevel@tonic-gate extern int gld_unregister(gld_mac_info_t *);
2980Sstevel@tonic-gate extern void gld_recv(gld_mac_info_t *, mblk_t *);
2990Sstevel@tonic-gate extern void gld_recv_tagged(gld_mac_info_t *, mblk_t *, uint32_t);
3000Sstevel@tonic-gate extern void gld_linkstate(gld_mac_info_t *, int32_t);
3010Sstevel@tonic-gate extern void gld_sched(gld_mac_info_t *);
3020Sstevel@tonic-gate extern uint_t gld_intr();
3030Sstevel@tonic-gate 
3040Sstevel@tonic-gate extern int gld_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
3050Sstevel@tonic-gate extern int gld_open(queue_t *, dev_t *, int, int, cred_t *);
3060Sstevel@tonic-gate extern int gld_close(queue_t *, int, cred_t *);
3070Sstevel@tonic-gate extern int gld_wput(queue_t *, mblk_t *);
3080Sstevel@tonic-gate extern int gld_wsrv(queue_t *);
3090Sstevel@tonic-gate extern int gld_rsrv(queue_t *);
3100Sstevel@tonic-gate #endif
3110Sstevel@tonic-gate 
3120Sstevel@tonic-gate /*
3130Sstevel@tonic-gate  * VLAN tag macros
3140Sstevel@tonic-gate  *
3150Sstevel@tonic-gate  * Per IEEE802.1Q, a VLAN tag is made up of a 2-byte Tagged Protocol
3160Sstevel@tonic-gate  * Identifier (TPID) and two bytes of Tag/Control information (TCI).
3170Sstevel@tonic-gate  * All fields should be treated as unsigned, and so a VTAG is held as
3180Sstevel@tonic-gate  * a 'uint32_t'
3190Sstevel@tonic-gate  */
3200Sstevel@tonic-gate #define	VTAG_SIZE	4		/* bytes (octets)		*/
3210Sstevel@tonic-gate 
3220Sstevel@tonic-gate #define	VLAN_TPID_MASK	0xffff0000u
3230Sstevel@tonic-gate #define	VLAN_TPID_SHIFT	16
3240Sstevel@tonic-gate #define	VLAN_TCI_MASK	0x0000ffffu
3250Sstevel@tonic-gate #define	VLAN_TCI_SHIFT	0
3260Sstevel@tonic-gate 
3270Sstevel@tonic-gate #define	VLAN_PRI_MASK	0x0000e000u
3280Sstevel@tonic-gate #define	VLAN_PRI_SHIFT	13
3290Sstevel@tonic-gate #define	VLAN_CFI_MASK	0x00001000u
3300Sstevel@tonic-gate #define	VLAN_CFI_SHIFT	12
3310Sstevel@tonic-gate #define	VLAN_VID_MASK	0x00000fffu
3320Sstevel@tonic-gate #define	VLAN_VID_SHIFT	0
3330Sstevel@tonic-gate 
3340Sstevel@tonic-gate #define	VLAN_TPID	0x8100u		/* Per IEEE 802.1Q standard	*/
3350Sstevel@tonic-gate #define	VLAN_CFI_ETHER	0		/* CFI on Ethernet must be 0	*/
3360Sstevel@tonic-gate #define	VLAN_PRI_DFLT	0
3370Sstevel@tonic-gate #define	VLAN_PRI_MAX	7
3380Sstevel@tonic-gate #define	VLAN_VID_NONE	0		/* Not a valid VID		*/
3390Sstevel@tonic-gate #define	VLAN_VID_MIN	1
3400Sstevel@tonic-gate #define	VLAN_VID_MAX	4094		/* IEEE std; 4095 is reserved	*/
3410Sstevel@tonic-gate 
3420Sstevel@tonic-gate #define	VLAN_VTAG_NONE	0		/* Special case: "untagged"	*/
3430Sstevel@tonic-gate 
3440Sstevel@tonic-gate /*
3450Sstevel@tonic-gate  * Macros to construct a TCI or VTAG.  The user must ensure values are in
3462760Sdg199075  * range.  Note that in the special case of priority tag, VLAN_VID_NONE
3472760Sdg199075  * is also a valid argument to these constructor macros.
3480Sstevel@tonic-gate  */
3490Sstevel@tonic-gate #define	GLD_MAKE_TCI(pri, cfi, vid)    (((pri) << VLAN_PRI_SHIFT) |	\
3500Sstevel@tonic-gate 					((cfi) << VLAN_CFI_SHIFT) |	\
3510Sstevel@tonic-gate 					((vid) << VLAN_VID_SHIFT))
3520Sstevel@tonic-gate 
3532760Sdg199075 #define	GLD_MAKE_VTAG(pri, cfi, vid)				\
3542760Sdg199075 	(((uint32_t)ETHERTYPE_VLAN << VLAN_TPID_SHIFT) |	\
3552760Sdg199075 	((pri) << VLAN_PRI_SHIFT) |				\
3562760Sdg199075 	((cfi) << VLAN_CFI_SHIFT) |				\
3572760Sdg199075 	((vid) << VLAN_VID_SHIFT))
3582760Sdg199075 
3592760Sdg199075 #define	GLD_TCI2VTAG(tci)	\
3602760Sdg199075 	(((uint32_t)ETHERTYPE_VLAN << VLAN_TPID_SHIFT) | (tci))
3610Sstevel@tonic-gate 
3620Sstevel@tonic-gate /*
3630Sstevel@tonic-gate  * Macros to construct a prototype TCI/VTAG and then convert it to a real one
3640Sstevel@tonic-gate  */
3650Sstevel@tonic-gate #define	GLD_MK_PTCI(cfi, vid)	GLD_MAKE_TCI(VLAN_PRI_MAX, cfi, vid)
3662760Sdg199075 #define	GLD_MK_PTAG(cfi, vid)	GLD_MAKE_VTAG(VLAN_PRI_MAX, cfi, vid)
3670Sstevel@tonic-gate #define	GLD_MK_PMSK(pri)	(((pri) << VLAN_PRI_SHIFT) | ~VLAN_PRI_MASK)
3680Sstevel@tonic-gate #define	GLD_MK_VTAG(ptag, pri)	((ptag) & GLD_MK_PMSK(pri))
3690Sstevel@tonic-gate 
3700Sstevel@tonic-gate /*
3710Sstevel@tonic-gate  * Deconstruct a VTAG ...
3720Sstevel@tonic-gate  */
3730Sstevel@tonic-gate #define	GLD_VTAG_TPID(vtag)	(((vtag) & VLAN_TPID_MASK) >> VLAN_TPID_SHIFT)
3740Sstevel@tonic-gate #define	GLD_VTAG_TCI(vtag)	(((vtag) & VLAN_TCI_MASK) >> VLAN_TCI_SHIFT)
3750Sstevel@tonic-gate 
3760Sstevel@tonic-gate #define	GLD_VTAG_PRI(vtag)	(((vtag) & VLAN_PRI_MASK) >> VLAN_PRI_SHIFT)
3770Sstevel@tonic-gate #define	GLD_VTAG_CFI(vtag)	(((vtag) & VLAN_CFI_MASK) >> VLAN_CFI_SHIFT)
3780Sstevel@tonic-gate #define	GLD_VTAG_VID(vtag)	(((vtag) & VLAN_VID_MASK) >> VLAN_VID_SHIFT)
3790Sstevel@tonic-gate 
3800Sstevel@tonic-gate #ifdef	__cplusplus
3810Sstevel@tonic-gate }
3820Sstevel@tonic-gate #endif
3830Sstevel@tonic-gate 
3840Sstevel@tonic-gate #endif /* _SYS_GLD_H */
385