xref: /onnv-gate/usr/src/uts/common/sys/gld.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate /*
28*0Sstevel@tonic-gate  * gld - Generic LAN Driver support system for DLPI drivers.
29*0Sstevel@tonic-gate  */
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate #ifndef	_SYS_GLD_H
32*0Sstevel@tonic-gate #define	_SYS_GLD_H
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #include <sys/ethernet.h>
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate #ifdef	__cplusplus
39*0Sstevel@tonic-gate extern "C" {
40*0Sstevel@tonic-gate #endif
41*0Sstevel@tonic-gate 
42*0Sstevel@tonic-gate /*
43*0Sstevel@tonic-gate  * Media specific MIB-II counters/statistics
44*0Sstevel@tonic-gate  *
45*0Sstevel@tonic-gate  * This only includes those that aren't in the legacy counters.
46*0Sstevel@tonic-gate  */
47*0Sstevel@tonic-gate 
48*0Sstevel@tonic-gate typedef union media_stats {
49*0Sstevel@tonic-gate 	struct dot3stat {
50*0Sstevel@tonic-gate 		/* Ethernet: RFC1643 Dot3Stats (subset) */
51*0Sstevel@tonic-gate 		uint32_t	first_coll;	/* SingleCollisionFrames */
52*0Sstevel@tonic-gate 		uint32_t	multi_coll;	/* MultipleCollisionFrames */
53*0Sstevel@tonic-gate 		uint32_t	sqe_error;	/* SQETestErrors */
54*0Sstevel@tonic-gate 		uint32_t	mac_xmt_error;	/* InternalMacTransmitErrors */
55*0Sstevel@tonic-gate 		uint32_t	frame_too_long;	/* FrameTooLongs */
56*0Sstevel@tonic-gate 		uint32_t	mac_rcv_error;	/* InternalMacReceiveErrors */
57*0Sstevel@tonic-gate 	} dot3;
58*0Sstevel@tonic-gate 	struct dot5stat {
59*0Sstevel@tonic-gate 		/* Token Ring: RFC1748 Dot5Stats (subset) */
60*0Sstevel@tonic-gate 		uint32_t	ace_error;
61*0Sstevel@tonic-gate 		uint32_t	internal_error;
62*0Sstevel@tonic-gate 		uint32_t	lost_frame_error;
63*0Sstevel@tonic-gate 		uint32_t	frame_copied_error;
64*0Sstevel@tonic-gate 		uint32_t	token_error;
65*0Sstevel@tonic-gate 		uint32_t	freq_error;
66*0Sstevel@tonic-gate 	} dot5;
67*0Sstevel@tonic-gate 	struct fddistat {
68*0Sstevel@tonic-gate 		/* FDDI: RFC1512 (subset) */
69*0Sstevel@tonic-gate 		uint32_t	mac_error;
70*0Sstevel@tonic-gate 		uint32_t	mac_lost;
71*0Sstevel@tonic-gate 		uint32_t	mac_token;
72*0Sstevel@tonic-gate 		uint32_t	mac_tvx_expired;
73*0Sstevel@tonic-gate 		uint32_t	mac_late;
74*0Sstevel@tonic-gate 		uint32_t	mac_ring_op;
75*0Sstevel@tonic-gate 	} fddi;
76*0Sstevel@tonic-gate 	uint32_t		pad[16];
77*0Sstevel@tonic-gate } media_stats_t;
78*0Sstevel@tonic-gate 
79*0Sstevel@tonic-gate #define	glds_dot3_first_coll		glds_media_specific.dot3.first_coll
80*0Sstevel@tonic-gate #define	glds_dot3_multi_coll		glds_media_specific.dot3.multi_coll
81*0Sstevel@tonic-gate #define	glds_dot3_sqe_error		glds_media_specific.dot3.sqe_error
82*0Sstevel@tonic-gate #define	glds_dot3_mac_xmt_error		glds_media_specific.dot3.mac_xmt_error
83*0Sstevel@tonic-gate #define	glds_dot3_mac_rcv_error		glds_media_specific.dot3.mac_rcv_error
84*0Sstevel@tonic-gate #define	glds_dot3_frame_too_long	glds_media_specific.dot3.frame_too_long
85*0Sstevel@tonic-gate 
86*0Sstevel@tonic-gate #define	glds_dot5_line_error		glds_crc
87*0Sstevel@tonic-gate #define	glds_dot5_burst_error		glds_frame
88*0Sstevel@tonic-gate #define	glds_dot5_ace_error		glds_media_specific.dot5.ace_error
89*0Sstevel@tonic-gate #define	glds_dot5_internal_error	glds_media_specific.dot5.internal_error
90*0Sstevel@tonic-gate #define	glds_dot5_lost_frame_error   glds_media_specific.dot5.lost_frame_error
91*0Sstevel@tonic-gate #define	glds_dot5_frame_copied_error glds_media_specific.dot5.frame_copied_error
92*0Sstevel@tonic-gate #define	glds_dot5_token_error		glds_media_specific.dot5.token_error
93*0Sstevel@tonic-gate #define	glds_dot5_signal_loss		glds_nocarrier
94*0Sstevel@tonic-gate #define	glds_dot5_freq_error		glds_media_specific.dot5.freq_error
95*0Sstevel@tonic-gate 
96*0Sstevel@tonic-gate #define	glds_fddi_mac_error		glds_media_specific.fddi.mac_error
97*0Sstevel@tonic-gate #define	glds_fddi_mac_lost		glds_media_specific.fddi.mac_lost
98*0Sstevel@tonic-gate #define	glds_fddi_mac_token		glds_media_specific.fddi.mac_token
99*0Sstevel@tonic-gate #define	glds_fddi_mac_tvx_expired	glds_media_specific.fddi.mac_tvx_expired
100*0Sstevel@tonic-gate #define	glds_fddi_mac_late		glds_media_specific.fddi.mac_late
101*0Sstevel@tonic-gate #define	glds_fddi_mac_ring_op		glds_media_specific.fddi.mac_ring_op
102*0Sstevel@tonic-gate 
103*0Sstevel@tonic-gate /*
104*0Sstevel@tonic-gate  * structure for driver statistics
105*0Sstevel@tonic-gate  */
106*0Sstevel@tonic-gate struct gld_stats {
107*0Sstevel@tonic-gate 	ulong_t		glds_multixmt;	/* (G) ifOutMulticastPkts */
108*0Sstevel@tonic-gate 	ulong_t		glds_multircv;	/* (G) ifInMulticastPkts */
109*0Sstevel@tonic-gate 	ulong_t		glds_brdcstxmt;	/* (G) ifOutBroadcastPkts */
110*0Sstevel@tonic-gate 	ulong_t		glds_brdcstrcv;	/* (G) ifInBroadcastPkts */
111*0Sstevel@tonic-gate 	uint32_t	glds_blocked;	/* (G) discard: upstream flow cntrl */
112*0Sstevel@tonic-gate 	uint32_t	glds_reserved1;
113*0Sstevel@tonic-gate 	uint32_t	glds_reserved2;
114*0Sstevel@tonic-gate 	uint32_t	glds_reserved3;
115*0Sstevel@tonic-gate 	uint32_t	glds_reserved4;
116*0Sstevel@tonic-gate 	uint32_t	glds_errxmt;	/* (D) ifOutErrors */
117*0Sstevel@tonic-gate 	uint32_t	glds_errrcv;	/* (D) ifInErrors */
118*0Sstevel@tonic-gate 	uint32_t	glds_collisions; /* (e) Sun MIB's rsIfCollisions */
119*0Sstevel@tonic-gate 	uint32_t	glds_excoll;	/* (e) dot3StatsExcessiveCollisions */
120*0Sstevel@tonic-gate 	uint32_t	glds_defer;	/* (e) dot3StatsDeferredTransmissions */
121*0Sstevel@tonic-gate 	uint32_t	glds_frame;	/* (e) dot3StatsAlignErrors */
122*0Sstevel@tonic-gate 	uint32_t	glds_crc;	/* (e) dot3StatsFCSErrors */
123*0Sstevel@tonic-gate 	uint32_t	glds_overflow;	/* (D) */
124*0Sstevel@tonic-gate 	uint32_t	glds_underflow;	/* (D) */
125*0Sstevel@tonic-gate 	uint32_t	glds_short;	/* (e) */
126*0Sstevel@tonic-gate 	uint32_t	glds_missed;	/* (D) */
127*0Sstevel@tonic-gate 	uint32_t	glds_xmtlatecoll; /* (e) dot3StatsLateCollisions */
128*0Sstevel@tonic-gate 	uint32_t	glds_nocarrier; /* (e) dot3StatsCarrierSenseErrors */
129*0Sstevel@tonic-gate 	uint32_t	glds_noxmtbuf;	/* (G) ifOutDiscards */
130*0Sstevel@tonic-gate 	uint32_t	glds_norcvbuf;	/* (D) ifInDiscards */
131*0Sstevel@tonic-gate 	uint32_t	glds_intr;	/* (D) */
132*0Sstevel@tonic-gate 	uint32_t	glds_xmtretry;	/* (G) */
133*0Sstevel@tonic-gate 	uint64_t	glds_pktxmt64;	/* (G) 64-bit rsIfOutPackets */
134*0Sstevel@tonic-gate 	uint64_t	glds_pktrcv64;	/* (G) 64-bit rsIfInPackets */
135*0Sstevel@tonic-gate 	uint64_t	glds_bytexmt64;	/* (G) ifHCOutOctets */
136*0Sstevel@tonic-gate 	uint64_t	glds_bytercv64;	/* (G) ifHCInOctets */
137*0Sstevel@tonic-gate 	uint64_t	glds_speed;	/* (D) ifSpeed */
138*0Sstevel@tonic-gate 	uint32_t	glds_duplex;	/* (e) Invented for GLD */
139*0Sstevel@tonic-gate 	uint32_t	glds_media;	/* (D) Invented for GLD */
140*0Sstevel@tonic-gate 	uint32_t	glds_unknowns;	/* (G) ifInUnknownProtos */
141*0Sstevel@tonic-gate 	uint32_t	reserved[19];
142*0Sstevel@tonic-gate 	media_stats_t	glds_media_specific;
143*0Sstevel@tonic-gate 	uint32_t	glds_xmtbadinterp; /* (G) bad packet len/format */
144*0Sstevel@tonic-gate 	uint32_t	glds_rcvbadinterp; /* (G) bad packet len/format */
145*0Sstevel@tonic-gate 	uint32_t	glds_gldnorcvbuf;  /* (G) norcvbuf from inside GLD */
146*0Sstevel@tonic-gate };
147*0Sstevel@tonic-gate 
148*0Sstevel@tonic-gate /*
149*0Sstevel@tonic-gate  * gld_mac_info structure.  Used to define the per-board data for all
150*0Sstevel@tonic-gate  * drivers.
151*0Sstevel@tonic-gate  *
152*0Sstevel@tonic-gate  * The below definition of gld_mac_info contains GLD PRIVATE entries that must
153*0Sstevel@tonic-gate  * not be used by the device driver. Only entries marked SET BY DRIVER should
154*0Sstevel@tonic-gate  * be modified.
155*0Sstevel@tonic-gate  */
156*0Sstevel@tonic-gate 
157*0Sstevel@tonic-gate #define	GLD_STATS_SIZE_ORIG	(sizeof (uint32_t) * 26) /* don't change */
158*0Sstevel@tonic-gate #define	GLD_KSTAT_SIZE_ORIG (sizeof (kstat_named_t) * 26) /* don't change */
159*0Sstevel@tonic-gate #define	GLD_PAD  ((int)GLD_KSTAT_SIZE_ORIG + (int)GLD_STATS_SIZE_ORIG)
160*0Sstevel@tonic-gate 
161*0Sstevel@tonic-gate typedef union gld_lock {
162*0Sstevel@tonic-gate 	kmutex_t	reserved;
163*0Sstevel@tonic-gate 	krwlock_t	gldl_rw_lock;
164*0Sstevel@tonic-gate } gld_lock_t;
165*0Sstevel@tonic-gate 
166*0Sstevel@tonic-gate typedef struct gld_mac_info {
167*0Sstevel@tonic-gate 	struct gld_mac_info *gldm_next;			/* GLD PRIVATE */
168*0Sstevel@tonic-gate 	struct gld_mac_info *gldm_prev;			/* GLD PRIVATE */
169*0Sstevel@tonic-gate 	caddr_t		reserved1;			/* GLD PRIVATE */
170*0Sstevel@tonic-gate 	caddr_t		reserved2;			/* GLD PRIVATE */
171*0Sstevel@tonic-gate 	uint16_t	gldm_driver_version;		/* GLD PRIVATE */
172*0Sstevel@tonic-gate 	uint16_t	gldm_GLD_version;		/* GLD PRIVATE */
173*0Sstevel@tonic-gate 	uint16_t	gldm_GLD_flags;			/* GLD PRIVATE */
174*0Sstevel@tonic-gate 	uint16_t	gldm_options;			/* GLD_PRIVATE */
175*0Sstevel@tonic-gate 	dev_info_t	*gldm_devinfo;			/* SET BY DRIVER */
176*0Sstevel@tonic-gate 	uchar_t		*gldm_vendor_addr;		/* SET BY DRIVER */
177*0Sstevel@tonic-gate 	uchar_t		*gldm_broadcast_addr;		/* SET BY DRIVER */
178*0Sstevel@tonic-gate 	gld_lock_t	gldm_lock;			/* GLD PRIVATE */
179*0Sstevel@tonic-gate 	ddi_iblock_cookie_t gldm_cookie;		/* SET BY DRIVER */
180*0Sstevel@tonic-gate 	uint32_t	reserved3;			/* GLD PRIVATE */
181*0Sstevel@tonic-gate 	uint32_t	reserved4;			/* GLD PRIVATE */
182*0Sstevel@tonic-gate 	uint32_t	gldm_maxpkt;			/* SET BY DRIVER */
183*0Sstevel@tonic-gate 	uint32_t	gldm_minpkt;			/* SET BY DRIVER */
184*0Sstevel@tonic-gate 	char		*gldm_ident;			/* SET BY DRIVER */
185*0Sstevel@tonic-gate 	uint32_t	gldm_type;			/* SET BY DRIVER */
186*0Sstevel@tonic-gate 	uint32_t	reserved5;			/* GLD PRIVATE */
187*0Sstevel@tonic-gate 	uint32_t	gldm_addrlen;			/* SET BY DRIVER */
188*0Sstevel@tonic-gate 	int32_t		gldm_saplen;			/* SET BY DRIVER */
189*0Sstevel@tonic-gate 							/* NOTE: MUST BE -2 */
190*0Sstevel@tonic-gate 	unsigned char	reserved7[ETHERADDRL];		/* GLD PRIVATE */
191*0Sstevel@tonic-gate 	unsigned char	reserved8[ETHERADDRL];		/* GLD PRIVATE */
192*0Sstevel@tonic-gate 	unsigned char	reserved9[ETHERADDRL];		/* GLD PRIVATE */
193*0Sstevel@tonic-gate 	t_uscalar_t	gldm_ppa;			/* SET BY DRIVER */
194*0Sstevel@tonic-gate 	int32_t		reserved10;			/* GLD PRIVATE */
195*0Sstevel@tonic-gate 	uint32_t	gldm_capabilities; 		/* SET BY DRIVER */
196*0Sstevel@tonic-gate 	int32_t		gldm_linkstate;			/* GLD PRIVATE */
197*0Sstevel@tonic-gate 	uint32_t	reserved11;			/* GLD PRIVATE */
198*0Sstevel@tonic-gate 	caddr_t		reserved12;			/* GLD PRIVATE */
199*0Sstevel@tonic-gate 	int32_t		reserved13;			/* GLD PRIVATE */
200*0Sstevel@tonic-gate 	uint32_t	reserved14;			/* GLD PRIVATE */
201*0Sstevel@tonic-gate 	int32_t		reserved15;			/* GLD PRIVATE */
202*0Sstevel@tonic-gate 	caddr_t		gldm_mac_pvt;			/* GLD PRIVATE */
203*0Sstevel@tonic-gate 	caddr_t		reserved16;			/* GLD PRIVATE */
204*0Sstevel@tonic-gate 	char		reserved17[GLD_PAD];		/* GLD PRIVATE */
205*0Sstevel@tonic-gate 	caddr_t		reserved18;			/* GLD PRIVATE */
206*0Sstevel@tonic-gate 	caddr_t		gldm_private;			/* GLD PRIVATE */
207*0Sstevel@tonic-gate 	int		(*gldm_reset)();		/* SET BY DRIVER */
208*0Sstevel@tonic-gate 	int		(*gldm_start)();		/* SET BY DRIVER */
209*0Sstevel@tonic-gate 	int		(*gldm_stop)();			/* SET BY DRIVER */
210*0Sstevel@tonic-gate 	int		(*gldm_set_mac_addr)();		/* SET BY DRIVER */
211*0Sstevel@tonic-gate 	int		(*gldm_send)();			/* SET BY DRIVER */
212*0Sstevel@tonic-gate 	int		(*gldm_set_promiscuous)();	/* SET BY DRIVER */
213*0Sstevel@tonic-gate 	int		(*gldm_get_stats)();		/* SET BY DRIVER */
214*0Sstevel@tonic-gate 	int		(*gldm_ioctl)();		/* SET BY DRIVER */
215*0Sstevel@tonic-gate 	int		(*gldm_set_multicast)(); 	/* SET BY DRIVER */
216*0Sstevel@tonic-gate 	uint_t		(*gldm_intr)();			/* SET BY DRIVER */
217*0Sstevel@tonic-gate 	int		(*gldm_mctl)();			/* SET BY DRIVER */
218*0Sstevel@tonic-gate 	int		(*gldm_send_tagged)();		/* SET BY DRIVER */
219*0Sstevel@tonic-gate 	/*
220*0Sstevel@tonic-gate 	 * The following MDT related entry points are Sun private,
221*0Sstevel@tonic-gate 	 * meant only for use by Sun's IPoIB (ibd) driver.
222*0Sstevel@tonic-gate 	 */
223*0Sstevel@tonic-gate 	int		(*gldm_mdt_pre)();		/* SET BY DRIVER */
224*0Sstevel@tonic-gate 	void		(*gldm_mdt_send)();		/* SET BY DRIVER */
225*0Sstevel@tonic-gate 	void		(*gldm_mdt_post)();		/* SET BY DRIVER */
226*0Sstevel@tonic-gate 	int		gldm_mdt_sgl;			/* SET BY DRIVER */
227*0Sstevel@tonic-gate 	int		gldm_mdt_segs;			/* SET BY DRIVER */
228*0Sstevel@tonic-gate } gld_mac_info_t;
229*0Sstevel@tonic-gate 
230*0Sstevel@tonic-gate /* flags for physical promiscuous state */
231*0Sstevel@tonic-gate #define	GLD_MAC_PROMISC_NOOP	-1	/* leave mode unchanged		 */
232*0Sstevel@tonic-gate #define	GLD_MAC_PROMISC_NONE	0	/* promiscuous mode(s) OFF	 */
233*0Sstevel@tonic-gate #define	GLD_MAC_PROMISC_PHYS	1	/* receive all packets		 */
234*0Sstevel@tonic-gate #define	GLD_MAC_PROMISC_MULTI	2	/* receive all multicast packets */
235*0Sstevel@tonic-gate 
236*0Sstevel@tonic-gate #define	GLD_MULTI_ENABLE	1
237*0Sstevel@tonic-gate #define	GLD_MULTI_DISABLE	0
238*0Sstevel@tonic-gate 
239*0Sstevel@tonic-gate /* flags for gldm_capabilities */
240*0Sstevel@tonic-gate #define	GLD_CAP_LINKSTATE	0x00000001 /* will call gld_linkstate() */
241*0Sstevel@tonic-gate #define	GLD_CAP_CKSUM_IPHDR	0x00000008 /* IP checksum offload	*/
242*0Sstevel@tonic-gate #define	GLD_CAP_CKSUM_PARTIAL	0x00000010 /* TCP/UDP partial		*/
243*0Sstevel@tonic-gate #define	GLD_CAP_CKSUM_FULL_V4	0x00000020 /* TCP/UDP full		*/
244*0Sstevel@tonic-gate #define	GLD_CAP_CKSUM_ANY	0x00000038 /* any or all of the above	*/
245*0Sstevel@tonic-gate #define	GLD_CAP_ZEROCOPY	0x00000040 /* zerocopy */
246*0Sstevel@tonic-gate 
247*0Sstevel@tonic-gate /* values of gldm_linkstate, as passed to gld_linkstate() */
248*0Sstevel@tonic-gate #define	GLD_LINKSTATE_DOWN	-1
249*0Sstevel@tonic-gate #define	GLD_LINKSTATE_UNKNOWN	0
250*0Sstevel@tonic-gate #define	GLD_LINKSTATE_UP	1
251*0Sstevel@tonic-gate 
252*0Sstevel@tonic-gate /*
253*0Sstevel@tonic-gate  * media type: this identifies the media/connector currently used by the
254*0Sstevel@tonic-gate  * driver.  Possible types will be defined for each DLPI type defined in
255*0Sstevel@tonic-gate  * gldm_type.  The below definitions should be used by the device dependent
256*0Sstevel@tonic-gate  * drivers to set glds_media.
257*0Sstevel@tonic-gate  */
258*0Sstevel@tonic-gate 
259*0Sstevel@tonic-gate /* if driver cannot determine media/connector type  */
260*0Sstevel@tonic-gate #define	GLDM_UNKNOWN	0
261*0Sstevel@tonic-gate 
262*0Sstevel@tonic-gate #define	GLDM_AUI	1
263*0Sstevel@tonic-gate #define	GLDM_BNC	2
264*0Sstevel@tonic-gate #define	GLDM_TP		3
265*0Sstevel@tonic-gate #define	GLDM_FIBER	4
266*0Sstevel@tonic-gate #define	GLDM_100BT	5
267*0Sstevel@tonic-gate #define	GLDM_VGANYLAN	6
268*0Sstevel@tonic-gate #define	GLDM_10BT	7
269*0Sstevel@tonic-gate #define	GLDM_RING4	8
270*0Sstevel@tonic-gate #define	GLDM_RING16	9
271*0Sstevel@tonic-gate #define	GLDM_PHYMII	10
272*0Sstevel@tonic-gate #define	GLDM_100BTX	11
273*0Sstevel@tonic-gate #define	GLDM_100BT4	12
274*0Sstevel@tonic-gate #define	GLDM_IB		14
275*0Sstevel@tonic-gate 
276*0Sstevel@tonic-gate /* defines for possible duplex states (glds_duplex) */
277*0Sstevel@tonic-gate #define	GLD_DUPLEX_UNKNOWN	0
278*0Sstevel@tonic-gate #define	GLD_DUPLEX_HALF		1
279*0Sstevel@tonic-gate #define	GLD_DUPLEX_FULL		2
280*0Sstevel@tonic-gate 
281*0Sstevel@tonic-gate /* Values returned from driver entry points */
282*0Sstevel@tonic-gate #define	GLD_SUCCESS		0
283*0Sstevel@tonic-gate #define	GLD_NORESOURCES		1
284*0Sstevel@tonic-gate #define	GLD_NOTSUPPORTED	2
285*0Sstevel@tonic-gate #define	GLD_BADARG		3
286*0Sstevel@tonic-gate #define	GLD_NOLINK		4
287*0Sstevel@tonic-gate #define	GLD_RETRY		5
288*0Sstevel@tonic-gate #define	GLD_FAILURE		(-1)
289*0Sstevel@tonic-gate 
290*0Sstevel@tonic-gate #if defined(_KERNEL)
291*0Sstevel@tonic-gate /* Functions exported to drivers */
292*0Sstevel@tonic-gate extern gld_mac_info_t *gld_mac_alloc(dev_info_t *);
293*0Sstevel@tonic-gate extern void gld_mac_free(gld_mac_info_t *);
294*0Sstevel@tonic-gate extern int gld_register(dev_info_t *, char *, gld_mac_info_t *);
295*0Sstevel@tonic-gate extern int gld_unregister(gld_mac_info_t *);
296*0Sstevel@tonic-gate extern void gld_recv(gld_mac_info_t *, mblk_t *);
297*0Sstevel@tonic-gate extern void gld_recv_tagged(gld_mac_info_t *, mblk_t *, uint32_t);
298*0Sstevel@tonic-gate extern void gld_linkstate(gld_mac_info_t *, int32_t);
299*0Sstevel@tonic-gate extern void gld_sched(gld_mac_info_t *);
300*0Sstevel@tonic-gate extern uint_t gld_intr();
301*0Sstevel@tonic-gate 
302*0Sstevel@tonic-gate extern int gld_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
303*0Sstevel@tonic-gate extern int gld_open(queue_t *, dev_t *, int, int, cred_t *);
304*0Sstevel@tonic-gate extern int gld_close(queue_t *, int, cred_t *);
305*0Sstevel@tonic-gate extern int gld_wput(queue_t *, mblk_t *);
306*0Sstevel@tonic-gate extern int gld_wsrv(queue_t *);
307*0Sstevel@tonic-gate extern int gld_rsrv(queue_t *);
308*0Sstevel@tonic-gate #endif
309*0Sstevel@tonic-gate 
310*0Sstevel@tonic-gate /*
311*0Sstevel@tonic-gate  * VLAN tag macros
312*0Sstevel@tonic-gate  *
313*0Sstevel@tonic-gate  * Per IEEE802.1Q, a VLAN tag is made up of a 2-byte Tagged Protocol
314*0Sstevel@tonic-gate  * Identifier (TPID) and two bytes of Tag/Control information (TCI).
315*0Sstevel@tonic-gate  * All fields should be treated as unsigned, and so a VTAG is held as
316*0Sstevel@tonic-gate  * a 'uint32_t'
317*0Sstevel@tonic-gate  */
318*0Sstevel@tonic-gate #define	VTAG_SIZE	4		/* bytes (octets)		*/
319*0Sstevel@tonic-gate 
320*0Sstevel@tonic-gate #define	VLAN_TPID_MASK	0xffff0000u
321*0Sstevel@tonic-gate #define	VLAN_TPID_SHIFT	16
322*0Sstevel@tonic-gate #define	VLAN_TCI_MASK	0x0000ffffu
323*0Sstevel@tonic-gate #define	VLAN_TCI_SHIFT	0
324*0Sstevel@tonic-gate 
325*0Sstevel@tonic-gate #define	VLAN_PRI_MASK	0x0000e000u
326*0Sstevel@tonic-gate #define	VLAN_PRI_SHIFT	13
327*0Sstevel@tonic-gate #define	VLAN_CFI_MASK	0x00001000u
328*0Sstevel@tonic-gate #define	VLAN_CFI_SHIFT	12
329*0Sstevel@tonic-gate #define	VLAN_VID_MASK	0x00000fffu
330*0Sstevel@tonic-gate #define	VLAN_VID_SHIFT	0
331*0Sstevel@tonic-gate 
332*0Sstevel@tonic-gate #define	VLAN_TPID	0x8100u		/* Per IEEE 802.1Q standard	*/
333*0Sstevel@tonic-gate #define	VLAN_CFI_ETHER	0		/* CFI on Ethernet must be 0	*/
334*0Sstevel@tonic-gate #define	VLAN_PRI_DFLT	0
335*0Sstevel@tonic-gate #define	VLAN_PRI_MAX	7
336*0Sstevel@tonic-gate #define	VLAN_VID_NONE	0		/* Not a valid VID		*/
337*0Sstevel@tonic-gate #define	VLAN_VID_MIN	1
338*0Sstevel@tonic-gate #define	VLAN_VID_MAX	4094		/* IEEE std; 4095 is reserved	*/
339*0Sstevel@tonic-gate 
340*0Sstevel@tonic-gate #define	VLAN_VTAG_NONE	0		/* Special case: "untagged"	*/
341*0Sstevel@tonic-gate 
342*0Sstevel@tonic-gate /*
343*0Sstevel@tonic-gate  * Macros to construct a TCI or VTAG.  The user must ensure values are in
344*0Sstevel@tonic-gate  * range.  In particular, VID 0 is not a valid argument to these constructor
345*0Sstevel@tonic-gate  * macros; when the VID is 0 (VLAN_VID_NONE), the whole VTAG should be 0
346*0Sstevel@tonic-gate  * (VLAN_VTAG_NONE), not 0x81000000.
347*0Sstevel@tonic-gate  */
348*0Sstevel@tonic-gate #define	GLD_MAKE_TCI(pri, cfi, vid)    (((pri) << VLAN_PRI_SHIFT) |	\
349*0Sstevel@tonic-gate 					((cfi) << VLAN_CFI_SHIFT) |	\
350*0Sstevel@tonic-gate 					((vid) << VLAN_VID_SHIFT))
351*0Sstevel@tonic-gate 
352*0Sstevel@tonic-gate #define	GLD_MAKE_VTAG(tci)	((VLAN_TPID << VLAN_TPID_SHIFT) | (tci))
353*0Sstevel@tonic-gate 
354*0Sstevel@tonic-gate /*
355*0Sstevel@tonic-gate  * Macros to construct a prototype TCI/VTAG and then convert it to a real one
356*0Sstevel@tonic-gate  */
357*0Sstevel@tonic-gate #define	GLD_MK_PTCI(cfi, vid)	GLD_MAKE_TCI(VLAN_PRI_MAX, cfi, vid)
358*0Sstevel@tonic-gate #define	GLD_MK_PTAG(cfi, vid)	GLD_MAKE_VTAG(GLD_MK_PTCI(cfi, vid))
359*0Sstevel@tonic-gate #define	GLD_MK_PMSK(pri)	(((pri) << VLAN_PRI_SHIFT) | ~VLAN_PRI_MASK)
360*0Sstevel@tonic-gate #define	GLD_MK_VTAG(ptag, pri)	((ptag) & GLD_MK_PMSK(pri))
361*0Sstevel@tonic-gate 
362*0Sstevel@tonic-gate /*
363*0Sstevel@tonic-gate  * Deconstruct a VTAG ...
364*0Sstevel@tonic-gate  */
365*0Sstevel@tonic-gate #define	GLD_VTAG_TPID(vtag)	(((vtag) & VLAN_TPID_MASK) >> VLAN_TPID_SHIFT)
366*0Sstevel@tonic-gate #define	GLD_VTAG_TCI(vtag)	(((vtag) & VLAN_TCI_MASK) >> VLAN_TCI_SHIFT)
367*0Sstevel@tonic-gate 
368*0Sstevel@tonic-gate #define	GLD_VTAG_PRI(vtag)	(((vtag) & VLAN_PRI_MASK) >> VLAN_PRI_SHIFT)
369*0Sstevel@tonic-gate #define	GLD_VTAG_CFI(vtag)	(((vtag) & VLAN_CFI_MASK) >> VLAN_CFI_SHIFT)
370*0Sstevel@tonic-gate #define	GLD_VTAG_VID(vtag)	(((vtag) & VLAN_VID_MASK) >> VLAN_VID_SHIFT)
371*0Sstevel@tonic-gate 
372*0Sstevel@tonic-gate #ifdef	__cplusplus
373*0Sstevel@tonic-gate }
374*0Sstevel@tonic-gate #endif
375*0Sstevel@tonic-gate 
376*0Sstevel@tonic-gate #endif /* _SYS_GLD_H */
377