xref: /illumos-gate/usr/src/uts/common/sys/gld.h (revision 9b664393)
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
5605445d5Sdg199075  * Common Development and Distribution License (the "License").
6605445d5Sdg199075  * 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 /*
22d62bc4baSyz147064  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
24*9b664393SGarrett D'Amore  *
25*9b664393SGarrett D'Amore  * Copyright 2022 Garrett D'Amore
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate /*
297c478bd9Sstevel@tonic-gate  * gld - Generic LAN Driver support system for DLPI drivers.
307c478bd9Sstevel@tonic-gate  */
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifndef	_SYS_GLD_H
337c478bd9Sstevel@tonic-gate #define	_SYS_GLD_H
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #include <sys/ethernet.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
387c478bd9Sstevel@tonic-gate extern "C" {
397c478bd9Sstevel@tonic-gate #endif
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /*
427c478bd9Sstevel@tonic-gate  * Media specific MIB-II counters/statistics
437c478bd9Sstevel@tonic-gate  *
447c478bd9Sstevel@tonic-gate  * This only includes those that aren't in the legacy counters.
457c478bd9Sstevel@tonic-gate  */
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate typedef union media_stats {
487c478bd9Sstevel@tonic-gate 	struct dot3stat {
497c478bd9Sstevel@tonic-gate 		/* Ethernet: RFC1643 Dot3Stats (subset) */
507c478bd9Sstevel@tonic-gate 		uint32_t	first_coll;	/* SingleCollisionFrames */
517c478bd9Sstevel@tonic-gate 		uint32_t	multi_coll;	/* MultipleCollisionFrames */
527c478bd9Sstevel@tonic-gate 		uint32_t	sqe_error;	/* SQETestErrors */
537c478bd9Sstevel@tonic-gate 		uint32_t	mac_xmt_error;	/* InternalMacTransmitErrors */
547c478bd9Sstevel@tonic-gate 		uint32_t	frame_too_long;	/* FrameTooLongs */
557c478bd9Sstevel@tonic-gate 		uint32_t	mac_rcv_error;	/* InternalMacReceiveErrors */
567c478bd9Sstevel@tonic-gate 	} dot3;
577c478bd9Sstevel@tonic-gate 	struct dot5stat {
587c478bd9Sstevel@tonic-gate 		/* Token Ring: RFC1748 Dot5Stats (subset) */
597c478bd9Sstevel@tonic-gate 		uint32_t	ace_error;
607c478bd9Sstevel@tonic-gate 		uint32_t	internal_error;
617c478bd9Sstevel@tonic-gate 		uint32_t	lost_frame_error;
627c478bd9Sstevel@tonic-gate 		uint32_t	frame_copied_error;
637c478bd9Sstevel@tonic-gate 		uint32_t	token_error;
647c478bd9Sstevel@tonic-gate 		uint32_t	freq_error;
657c478bd9Sstevel@tonic-gate 	} dot5;
667c478bd9Sstevel@tonic-gate 	struct fddistat {
677c478bd9Sstevel@tonic-gate 		/* FDDI: RFC1512 (subset) */
687c478bd9Sstevel@tonic-gate 		uint32_t	mac_error;
697c478bd9Sstevel@tonic-gate 		uint32_t	mac_lost;
707c478bd9Sstevel@tonic-gate 		uint32_t	mac_token;
717c478bd9Sstevel@tonic-gate 		uint32_t	mac_tvx_expired;
727c478bd9Sstevel@tonic-gate 		uint32_t	mac_late;
737c478bd9Sstevel@tonic-gate 		uint32_t	mac_ring_op;
747c478bd9Sstevel@tonic-gate 	} fddi;
757c478bd9Sstevel@tonic-gate 	uint32_t		pad[16];
767c478bd9Sstevel@tonic-gate } media_stats_t;
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate #define	glds_dot3_first_coll		glds_media_specific.dot3.first_coll
797c478bd9Sstevel@tonic-gate #define	glds_dot3_multi_coll		glds_media_specific.dot3.multi_coll
807c478bd9Sstevel@tonic-gate #define	glds_dot3_sqe_error		glds_media_specific.dot3.sqe_error
817c478bd9Sstevel@tonic-gate #define	glds_dot3_mac_xmt_error		glds_media_specific.dot3.mac_xmt_error
827c478bd9Sstevel@tonic-gate #define	glds_dot3_mac_rcv_error		glds_media_specific.dot3.mac_rcv_error
837c478bd9Sstevel@tonic-gate #define	glds_dot3_frame_too_long	glds_media_specific.dot3.frame_too_long
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate #define	glds_dot5_line_error		glds_crc
867c478bd9Sstevel@tonic-gate #define	glds_dot5_burst_error		glds_frame
877c478bd9Sstevel@tonic-gate #define	glds_dot5_ace_error		glds_media_specific.dot5.ace_error
887c478bd9Sstevel@tonic-gate #define	glds_dot5_internal_error	glds_media_specific.dot5.internal_error
897c478bd9Sstevel@tonic-gate #define	glds_dot5_lost_frame_error   glds_media_specific.dot5.lost_frame_error
907c478bd9Sstevel@tonic-gate #define	glds_dot5_frame_copied_error glds_media_specific.dot5.frame_copied_error
917c478bd9Sstevel@tonic-gate #define	glds_dot5_token_error		glds_media_specific.dot5.token_error
927c478bd9Sstevel@tonic-gate #define	glds_dot5_signal_loss		glds_nocarrier
937c478bd9Sstevel@tonic-gate #define	glds_dot5_freq_error		glds_media_specific.dot5.freq_error
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate #define	glds_fddi_mac_error		glds_media_specific.fddi.mac_error
967c478bd9Sstevel@tonic-gate #define	glds_fddi_mac_lost		glds_media_specific.fddi.mac_lost
977c478bd9Sstevel@tonic-gate #define	glds_fddi_mac_token		glds_media_specific.fddi.mac_token
987c478bd9Sstevel@tonic-gate #define	glds_fddi_mac_tvx_expired	glds_media_specific.fddi.mac_tvx_expired
997c478bd9Sstevel@tonic-gate #define	glds_fddi_mac_late		glds_media_specific.fddi.mac_late
1007c478bd9Sstevel@tonic-gate #define	glds_fddi_mac_ring_op		glds_media_specific.fddi.mac_ring_op
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate /*
1037c478bd9Sstevel@tonic-gate  * structure for driver statistics
1047c478bd9Sstevel@tonic-gate  */
1057c478bd9Sstevel@tonic-gate struct gld_stats {
1067c478bd9Sstevel@tonic-gate 	ulong_t		glds_multixmt;	/* (G) ifOutMulticastPkts */
1077c478bd9Sstevel@tonic-gate 	ulong_t		glds_multircv;	/* (G) ifInMulticastPkts */
1087c478bd9Sstevel@tonic-gate 	ulong_t		glds_brdcstxmt;	/* (G) ifOutBroadcastPkts */
1097c478bd9Sstevel@tonic-gate 	ulong_t		glds_brdcstrcv;	/* (G) ifInBroadcastPkts */
1107c478bd9Sstevel@tonic-gate 	uint32_t	glds_blocked;	/* (G) discard: upstream flow cntrl */
1117c478bd9Sstevel@tonic-gate 	uint32_t	glds_reserved1;
1127c478bd9Sstevel@tonic-gate 	uint32_t	glds_reserved2;
1137c478bd9Sstevel@tonic-gate 	uint32_t	glds_reserved3;
1147c478bd9Sstevel@tonic-gate 	uint32_t	glds_reserved4;
1157c478bd9Sstevel@tonic-gate 	uint32_t	glds_errxmt;	/* (D) ifOutErrors */
1167c478bd9Sstevel@tonic-gate 	uint32_t	glds_errrcv;	/* (D) ifInErrors */
1177c478bd9Sstevel@tonic-gate 	uint32_t	glds_collisions; /* (e) Sun MIB's rsIfCollisions */
1187c478bd9Sstevel@tonic-gate 	uint32_t	glds_excoll;	/* (e) dot3StatsExcessiveCollisions */
1197c478bd9Sstevel@tonic-gate 	uint32_t	glds_defer;	/* (e) dot3StatsDeferredTransmissions */
1207c478bd9Sstevel@tonic-gate 	uint32_t	glds_frame;	/* (e) dot3StatsAlignErrors */
1217c478bd9Sstevel@tonic-gate 	uint32_t	glds_crc;	/* (e) dot3StatsFCSErrors */
1227c478bd9Sstevel@tonic-gate 	uint32_t	glds_overflow;	/* (D) */
1237c478bd9Sstevel@tonic-gate 	uint32_t	glds_underflow;	/* (D) */
1247c478bd9Sstevel@tonic-gate 	uint32_t	glds_short;	/* (e) */
1257c478bd9Sstevel@tonic-gate 	uint32_t	glds_missed;	/* (D) */
1267c478bd9Sstevel@tonic-gate 	uint32_t	glds_xmtlatecoll; /* (e) dot3StatsLateCollisions */
1277c478bd9Sstevel@tonic-gate 	uint32_t	glds_nocarrier; /* (e) dot3StatsCarrierSenseErrors */
1287c478bd9Sstevel@tonic-gate 	uint32_t	glds_noxmtbuf;	/* (G) ifOutDiscards */
1297c478bd9Sstevel@tonic-gate 	uint32_t	glds_norcvbuf;	/* (D) ifInDiscards */
1307c478bd9Sstevel@tonic-gate 	uint32_t	glds_intr;	/* (D) */
1317c478bd9Sstevel@tonic-gate 	uint32_t	glds_xmtretry;	/* (G) */
1327c478bd9Sstevel@tonic-gate 	uint64_t	glds_pktxmt64;	/* (G) 64-bit rsIfOutPackets */
1337c478bd9Sstevel@tonic-gate 	uint64_t	glds_pktrcv64;	/* (G) 64-bit rsIfInPackets */
1347c478bd9Sstevel@tonic-gate 	uint64_t	glds_bytexmt64;	/* (G) ifHCOutOctets */
1357c478bd9Sstevel@tonic-gate 	uint64_t	glds_bytercv64;	/* (G) ifHCInOctets */
1367c478bd9Sstevel@tonic-gate 	uint64_t	glds_speed;	/* (D) ifSpeed */
1377c478bd9Sstevel@tonic-gate 	uint32_t	glds_duplex;	/* (e) Invented for GLD */
1387c478bd9Sstevel@tonic-gate 	uint32_t	glds_media;	/* (D) Invented for GLD */
1397c478bd9Sstevel@tonic-gate 	uint32_t	glds_unknowns;	/* (G) ifInUnknownProtos */
1407c478bd9Sstevel@tonic-gate 	uint32_t	reserved[19];
1417c478bd9Sstevel@tonic-gate 	media_stats_t	glds_media_specific;
1427c478bd9Sstevel@tonic-gate 	uint32_t	glds_xmtbadinterp; /* (G) bad packet len/format */
1437c478bd9Sstevel@tonic-gate 	uint32_t	glds_rcvbadinterp; /* (G) bad packet len/format */
1447c478bd9Sstevel@tonic-gate 	uint32_t	glds_gldnorcvbuf;  /* (G) norcvbuf from inside GLD */
1457c478bd9Sstevel@tonic-gate };
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate /*
1487c478bd9Sstevel@tonic-gate  * gld_mac_info structure.  Used to define the per-board data for all
1497c478bd9Sstevel@tonic-gate  * drivers.
1507c478bd9Sstevel@tonic-gate  *
1517c478bd9Sstevel@tonic-gate  * The below definition of gld_mac_info contains GLD PRIVATE entries that must
1527c478bd9Sstevel@tonic-gate  * not be used by the device driver. Only entries marked SET BY DRIVER should
1537c478bd9Sstevel@tonic-gate  * be modified.
1547c478bd9Sstevel@tonic-gate  */
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate #define	GLD_STATS_SIZE_ORIG	(sizeof (uint32_t) * 26) /* don't change */
1577c478bd9Sstevel@tonic-gate #define	GLD_KSTAT_SIZE_ORIG (sizeof (kstat_named_t) * 26) /* don't change */
1587c478bd9Sstevel@tonic-gate #define	GLD_PAD  ((int)GLD_KSTAT_SIZE_ORIG + (int)GLD_STATS_SIZE_ORIG)
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate typedef union gld_lock {
1617c478bd9Sstevel@tonic-gate 	kmutex_t	reserved;
1627c478bd9Sstevel@tonic-gate 	krwlock_t	gldl_rw_lock;
1637c478bd9Sstevel@tonic-gate } gld_lock_t;
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate typedef struct gld_mac_info {
1667c478bd9Sstevel@tonic-gate 	struct gld_mac_info *gldm_next;			/* GLD PRIVATE */
1677c478bd9Sstevel@tonic-gate 	struct gld_mac_info *gldm_prev;			/* GLD PRIVATE */
1687c478bd9Sstevel@tonic-gate 	caddr_t		reserved1;			/* GLD PRIVATE */
1697c478bd9Sstevel@tonic-gate 	caddr_t		reserved2;			/* GLD PRIVATE */
1707c478bd9Sstevel@tonic-gate 	uint16_t	gldm_driver_version;		/* GLD PRIVATE */
1717c478bd9Sstevel@tonic-gate 	uint16_t	gldm_GLD_version;		/* GLD PRIVATE */
1727c478bd9Sstevel@tonic-gate 	uint16_t	gldm_GLD_flags;			/* GLD PRIVATE */
1737c478bd9Sstevel@tonic-gate 	uint16_t	gldm_options;			/* GLD_PRIVATE */
1747c478bd9Sstevel@tonic-gate 	dev_info_t	*gldm_devinfo;			/* SET BY DRIVER */
1757c478bd9Sstevel@tonic-gate 	uchar_t		*gldm_vendor_addr;		/* SET BY DRIVER */
1767c478bd9Sstevel@tonic-gate 	uchar_t		*gldm_broadcast_addr;		/* SET BY DRIVER */
1777c478bd9Sstevel@tonic-gate 	gld_lock_t	gldm_lock;			/* GLD PRIVATE */
1787c478bd9Sstevel@tonic-gate 	ddi_iblock_cookie_t gldm_cookie;		/* SET BY DRIVER */
179d62bc4baSyz147064 	uint32_t	gldm_margin;			/* SET BY DRIVER */
1807c478bd9Sstevel@tonic-gate 	uint32_t	reserved4;			/* GLD PRIVATE */
1817c478bd9Sstevel@tonic-gate 	uint32_t	gldm_maxpkt;			/* SET BY DRIVER */
1827c478bd9Sstevel@tonic-gate 	uint32_t	gldm_minpkt;			/* SET BY DRIVER */
1837c478bd9Sstevel@tonic-gate 	char		*gldm_ident;			/* SET BY DRIVER */
1847c478bd9Sstevel@tonic-gate 	uint32_t	gldm_type;			/* SET BY DRIVER */
1857c478bd9Sstevel@tonic-gate 	uint32_t	reserved5;			/* GLD PRIVATE */
1867c478bd9Sstevel@tonic-gate 	uint32_t	gldm_addrlen;			/* SET BY DRIVER */
1877c478bd9Sstevel@tonic-gate 	int32_t		gldm_saplen;			/* SET BY DRIVER */
1887c478bd9Sstevel@tonic-gate 							/* NOTE: MUST BE -2 */
1897c478bd9Sstevel@tonic-gate 	unsigned char	reserved7[ETHERADDRL];		/* GLD PRIVATE */
1907c478bd9Sstevel@tonic-gate 	unsigned char	reserved8[ETHERADDRL];		/* GLD PRIVATE */
1917c478bd9Sstevel@tonic-gate 	unsigned char	reserved9[ETHERADDRL];		/* GLD PRIVATE */
1927c478bd9Sstevel@tonic-gate 	t_uscalar_t	gldm_ppa;			/* SET BY DRIVER */
1937c478bd9Sstevel@tonic-gate 	int32_t		reserved10;			/* GLD PRIVATE */
1947c478bd9Sstevel@tonic-gate 	uint32_t	gldm_capabilities;		/* SET BY DRIVER */
1957c478bd9Sstevel@tonic-gate 	int32_t		gldm_linkstate;			/* GLD PRIVATE */
1967c478bd9Sstevel@tonic-gate 	uint32_t	reserved11;			/* GLD PRIVATE */
1977c478bd9Sstevel@tonic-gate 	caddr_t		reserved12;			/* GLD PRIVATE */
1987c478bd9Sstevel@tonic-gate 	int32_t		reserved13;			/* GLD PRIVATE */
1997c478bd9Sstevel@tonic-gate 	uint32_t	reserved14;			/* GLD PRIVATE */
2007c478bd9Sstevel@tonic-gate 	int32_t		reserved15;			/* GLD PRIVATE */
2017c478bd9Sstevel@tonic-gate 	caddr_t		gldm_mac_pvt;			/* GLD PRIVATE */
2027c478bd9Sstevel@tonic-gate 	caddr_t		reserved16;			/* GLD PRIVATE */
2037c478bd9Sstevel@tonic-gate 	char		reserved17[GLD_PAD];		/* GLD PRIVATE */
2047c478bd9Sstevel@tonic-gate 	caddr_t		reserved18;			/* GLD PRIVATE */
2057c478bd9Sstevel@tonic-gate 	caddr_t		gldm_private;			/* GLD PRIVATE */
2067c478bd9Sstevel@tonic-gate 	int		(*gldm_reset)();		/* SET BY DRIVER */
2077c478bd9Sstevel@tonic-gate 	int		(*gldm_start)();		/* SET BY DRIVER */
2087c478bd9Sstevel@tonic-gate 	int		(*gldm_stop)();			/* SET BY DRIVER */
2097c478bd9Sstevel@tonic-gate 	int		(*gldm_set_mac_addr)();		/* SET BY DRIVER */
2107c478bd9Sstevel@tonic-gate 	int		(*gldm_send)();			/* SET BY DRIVER */
2117c478bd9Sstevel@tonic-gate 	int		(*gldm_set_promiscuous)();	/* SET BY DRIVER */
2127c478bd9Sstevel@tonic-gate 	int		(*gldm_get_stats)();		/* SET BY DRIVER */
2137c478bd9Sstevel@tonic-gate 	int		(*gldm_ioctl)();		/* SET BY DRIVER */
2147c478bd9Sstevel@tonic-gate 	int		(*gldm_set_multicast)();	/* SET BY DRIVER */
2157c478bd9Sstevel@tonic-gate 	uint_t		(*gldm_intr)();			/* SET BY DRIVER */
2167c478bd9Sstevel@tonic-gate 	int		(*gldm_mctl)();			/* SET BY DRIVER */
2177c478bd9Sstevel@tonic-gate 	int		(*gldm_send_tagged)();		/* SET BY DRIVER */
2187c478bd9Sstevel@tonic-gate } gld_mac_info_t;
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate /* flags for physical promiscuous state */
2217c478bd9Sstevel@tonic-gate #define	GLD_MAC_PROMISC_NOOP	-1	/* leave mode unchanged		 */
2227c478bd9Sstevel@tonic-gate #define	GLD_MAC_PROMISC_NONE	0	/* promiscuous mode(s) OFF	 */
2237c478bd9Sstevel@tonic-gate #define	GLD_MAC_PROMISC_PHYS	1	/* receive all packets		 */
2247c478bd9Sstevel@tonic-gate #define	GLD_MAC_PROMISC_MULTI	2	/* receive all multicast packets */
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate #define	GLD_MULTI_ENABLE	1
2277c478bd9Sstevel@tonic-gate #define	GLD_MULTI_DISABLE	0
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate /* flags for gldm_capabilities */
2307c478bd9Sstevel@tonic-gate #define	GLD_CAP_LINKSTATE	0x00000001 /* will call gld_linkstate() */
2317c478bd9Sstevel@tonic-gate #define	GLD_CAP_CKSUM_IPHDR	0x00000008 /* IP checksum offload	*/
2327c478bd9Sstevel@tonic-gate #define	GLD_CAP_CKSUM_PARTIAL	0x00000010 /* TCP/UDP partial		*/
233ff550d0eSmasputra #define	GLD_CAP_CKSUM_FULL_V4	0x00000020 /* TCP/UDP full for IPv4	*/
2347c478bd9Sstevel@tonic-gate #define	GLD_CAP_ZEROCOPY	0x00000040 /* zerocopy */
235ff550d0eSmasputra #define	GLD_CAP_CKSUM_FULL_V6	0x00000080 /* TCP/UDP full for IPv6	*/
236ff550d0eSmasputra #define	GLD_CAP_CKSUM_ANY				\
237ff550d0eSmasputra 	(GLD_CAP_CKSUM_IPHDR|GLD_CAP_CKSUM_PARTIAL|	\
238ff550d0eSmasputra 	GLD_CAP_CKSUM_FULL_V4|GLD_CAP_CKSUM_FULL_V6)
2397c478bd9Sstevel@tonic-gate 
2407c478bd9Sstevel@tonic-gate /* values of gldm_linkstate, as passed to gld_linkstate() */
2417c478bd9Sstevel@tonic-gate #define	GLD_LINKSTATE_DOWN	-1
2427c478bd9Sstevel@tonic-gate #define	GLD_LINKSTATE_UNKNOWN	0
2437c478bd9Sstevel@tonic-gate #define	GLD_LINKSTATE_UP	1
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate /*
2467c478bd9Sstevel@tonic-gate  * media type: this identifies the media/connector currently used by the
2477c478bd9Sstevel@tonic-gate  * driver.  Possible types will be defined for each DLPI type defined in
2487c478bd9Sstevel@tonic-gate  * gldm_type.  The below definitions should be used by the device dependent
2497c478bd9Sstevel@tonic-gate  * drivers to set glds_media.
2507c478bd9Sstevel@tonic-gate  */
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate /* if driver cannot determine media/connector type  */
2537c478bd9Sstevel@tonic-gate #define	GLDM_UNKNOWN	0
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate #define	GLDM_AUI	1
2567c478bd9Sstevel@tonic-gate #define	GLDM_BNC	2
2577c478bd9Sstevel@tonic-gate #define	GLDM_TP		3
2587c478bd9Sstevel@tonic-gate #define	GLDM_FIBER	4
2597c478bd9Sstevel@tonic-gate #define	GLDM_100BT	5
2607c478bd9Sstevel@tonic-gate #define	GLDM_VGANYLAN	6
2617c478bd9Sstevel@tonic-gate #define	GLDM_10BT	7
2627c478bd9Sstevel@tonic-gate #define	GLDM_RING4	8
2637c478bd9Sstevel@tonic-gate #define	GLDM_RING16	9
2647c478bd9Sstevel@tonic-gate #define	GLDM_PHYMII	10
2657c478bd9Sstevel@tonic-gate #define	GLDM_100BTX	11
2667c478bd9Sstevel@tonic-gate #define	GLDM_100BT4	12
2677c478bd9Sstevel@tonic-gate #define	GLDM_IB		14
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate /* defines for possible duplex states (glds_duplex) */
2707c478bd9Sstevel@tonic-gate #define	GLD_DUPLEX_UNKNOWN	0
2717c478bd9Sstevel@tonic-gate #define	GLD_DUPLEX_HALF		1
2727c478bd9Sstevel@tonic-gate #define	GLD_DUPLEX_FULL		2
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate /* Values returned from driver entry points */
2757c478bd9Sstevel@tonic-gate #define	GLD_SUCCESS		0
2767c478bd9Sstevel@tonic-gate #define	GLD_NORESOURCES		1
2777c478bd9Sstevel@tonic-gate #define	GLD_NOTSUPPORTED	2
2787c478bd9Sstevel@tonic-gate #define	GLD_BADARG		3
2797c478bd9Sstevel@tonic-gate #define	GLD_NOLINK		4
2807c478bd9Sstevel@tonic-gate #define	GLD_RETRY		5
2817c478bd9Sstevel@tonic-gate #define	GLD_FAILURE		(-1)
2827c478bd9Sstevel@tonic-gate 
2837c478bd9Sstevel@tonic-gate #if defined(_KERNEL)
2847c478bd9Sstevel@tonic-gate /* Functions exported to drivers */
2857c478bd9Sstevel@tonic-gate extern gld_mac_info_t *gld_mac_alloc(dev_info_t *);
2867c478bd9Sstevel@tonic-gate extern void gld_mac_free(gld_mac_info_t *);
2877c478bd9Sstevel@tonic-gate extern int gld_register(dev_info_t *, char *, gld_mac_info_t *);
2887c478bd9Sstevel@tonic-gate extern int gld_unregister(gld_mac_info_t *);
2897c478bd9Sstevel@tonic-gate extern void gld_recv(gld_mac_info_t *, mblk_t *);
2907c478bd9Sstevel@tonic-gate extern void gld_recv_tagged(gld_mac_info_t *, mblk_t *, uint32_t);
2917c478bd9Sstevel@tonic-gate extern void gld_linkstate(gld_mac_info_t *, int32_t);
2927c478bd9Sstevel@tonic-gate extern void gld_sched(gld_mac_info_t *);
2937c478bd9Sstevel@tonic-gate extern uint_t gld_intr();
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate extern int gld_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
2967c478bd9Sstevel@tonic-gate extern int gld_open(queue_t *, dev_t *, int, int, cred_t *);
2977c478bd9Sstevel@tonic-gate extern int gld_close(queue_t *, int, cred_t *);
2987c478bd9Sstevel@tonic-gate extern int gld_wput(queue_t *, mblk_t *);
2997c478bd9Sstevel@tonic-gate extern int gld_wsrv(queue_t *);
3007c478bd9Sstevel@tonic-gate extern int gld_rsrv(queue_t *);
3017c478bd9Sstevel@tonic-gate #endif
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate /*
3047c478bd9Sstevel@tonic-gate  * VLAN tag macros
3057c478bd9Sstevel@tonic-gate  *
3067c478bd9Sstevel@tonic-gate  * Per IEEE802.1Q, a VLAN tag is made up of a 2-byte Tagged Protocol
3077c478bd9Sstevel@tonic-gate  * Identifier (TPID) and two bytes of Tag/Control information (TCI).
3087c478bd9Sstevel@tonic-gate  * All fields should be treated as unsigned, and so a VTAG is held as
3097c478bd9Sstevel@tonic-gate  * a 'uint32_t'
3107c478bd9Sstevel@tonic-gate  */
3117c478bd9Sstevel@tonic-gate #define	VTAG_SIZE	4		/* bytes (octets)		*/
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate #define	VLAN_TPID_MASK	0xffff0000u
3147c478bd9Sstevel@tonic-gate #define	VLAN_TPID_SHIFT	16
3157c478bd9Sstevel@tonic-gate #define	VLAN_TCI_MASK	0x0000ffffu
3167c478bd9Sstevel@tonic-gate #define	VLAN_TCI_SHIFT	0
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate #define	VLAN_PRI_MASK	0x0000e000u
3197c478bd9Sstevel@tonic-gate #define	VLAN_PRI_SHIFT	13
3207c478bd9Sstevel@tonic-gate #define	VLAN_CFI_MASK	0x00001000u
3217c478bd9Sstevel@tonic-gate #define	VLAN_CFI_SHIFT	12
3227c478bd9Sstevel@tonic-gate #define	VLAN_VID_MASK	0x00000fffu
3237c478bd9Sstevel@tonic-gate #define	VLAN_VID_SHIFT	0
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate #define	VLAN_TPID	0x8100u		/* Per IEEE 802.1Q standard	*/
3267c478bd9Sstevel@tonic-gate #define	VLAN_CFI_ETHER	0		/* CFI on Ethernet must be 0	*/
3277c478bd9Sstevel@tonic-gate #define	VLAN_PRI_DFLT	0
3287c478bd9Sstevel@tonic-gate #define	VLAN_PRI_MAX	7
3297c478bd9Sstevel@tonic-gate #define	VLAN_VID_NONE	0		/* Not a valid VID		*/
3307c478bd9Sstevel@tonic-gate #define	VLAN_VID_MIN	1
3317c478bd9Sstevel@tonic-gate #define	VLAN_VID_MAX	4094		/* IEEE std; 4095 is reserved	*/
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate #define	VLAN_VTAG_NONE	0		/* Special case: "untagged"	*/
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate /*
3367c478bd9Sstevel@tonic-gate  * Macros to construct a TCI or VTAG.  The user must ensure values are in
337605445d5Sdg199075  * range.  Note that in the special case of priority tag, VLAN_VID_NONE
338605445d5Sdg199075  * is also a valid argument to these constructor macros.
3397c478bd9Sstevel@tonic-gate  */
3407c478bd9Sstevel@tonic-gate #define	GLD_MAKE_TCI(pri, cfi, vid)    (((pri) << VLAN_PRI_SHIFT) |	\
3417c478bd9Sstevel@tonic-gate 					((cfi) << VLAN_CFI_SHIFT) |	\
3427c478bd9Sstevel@tonic-gate 					((vid) << VLAN_VID_SHIFT))
3437c478bd9Sstevel@tonic-gate 
344605445d5Sdg199075 #define	GLD_MAKE_VTAG(pri, cfi, vid)				\
345605445d5Sdg199075 	(((uint32_t)ETHERTYPE_VLAN << VLAN_TPID_SHIFT) |	\
346605445d5Sdg199075 	((pri) << VLAN_PRI_SHIFT) |				\
347605445d5Sdg199075 	((cfi) << VLAN_CFI_SHIFT) |				\
348605445d5Sdg199075 	((vid) << VLAN_VID_SHIFT))
349605445d5Sdg199075 
350605445d5Sdg199075 #define	GLD_TCI2VTAG(tci)	\
351605445d5Sdg199075 	(((uint32_t)ETHERTYPE_VLAN << VLAN_TPID_SHIFT) | (tci))
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate /*
3547c478bd9Sstevel@tonic-gate  * Macros to construct a prototype TCI/VTAG and then convert it to a real one
3557c478bd9Sstevel@tonic-gate  */
3567c478bd9Sstevel@tonic-gate #define	GLD_MK_PTCI(cfi, vid)	GLD_MAKE_TCI(VLAN_PRI_MAX, cfi, vid)
357605445d5Sdg199075 #define	GLD_MK_PTAG(cfi, vid)	GLD_MAKE_VTAG(VLAN_PRI_MAX, cfi, vid)
3587c478bd9Sstevel@tonic-gate #define	GLD_MK_PMSK(pri)	(((pri) << VLAN_PRI_SHIFT) | ~VLAN_PRI_MASK)
3597c478bd9Sstevel@tonic-gate #define	GLD_MK_VTAG(ptag, pri)	((ptag) & GLD_MK_PMSK(pri))
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate /*
3627c478bd9Sstevel@tonic-gate  * Deconstruct a VTAG ...
3637c478bd9Sstevel@tonic-gate  */
3647c478bd9Sstevel@tonic-gate #define	GLD_VTAG_TPID(vtag)	(((vtag) & VLAN_TPID_MASK) >> VLAN_TPID_SHIFT)
3657c478bd9Sstevel@tonic-gate #define	GLD_VTAG_TCI(vtag)	(((vtag) & VLAN_TCI_MASK) >> VLAN_TCI_SHIFT)
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate #define	GLD_VTAG_PRI(vtag)	(((vtag) & VLAN_PRI_MASK) >> VLAN_PRI_SHIFT)
3687c478bd9Sstevel@tonic-gate #define	GLD_VTAG_CFI(vtag)	(((vtag) & VLAN_CFI_MASK) >> VLAN_CFI_SHIFT)
3697c478bd9Sstevel@tonic-gate #define	GLD_VTAG_VID(vtag)	(((vtag) & VLAN_VID_MASK) >> VLAN_VID_SHIFT)
3707c478bd9Sstevel@tonic-gate 
3717c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
3727c478bd9Sstevel@tonic-gate }
3737c478bd9Sstevel@tonic-gate #endif
3747c478bd9Sstevel@tonic-gate 
3757c478bd9Sstevel@tonic-gate #endif /* _SYS_GLD_H */
376