xref: /titanic_53/usr/src/uts/common/sys/gldpriv.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*
28*7c478bd9Sstevel@tonic-gate  * gldpriv.h - Private interfaces/structures needed by gld.c
29*7c478bd9Sstevel@tonic-gate  *
30*7c478bd9Sstevel@tonic-gate  * The definitions in this file are private to GLD and may change at any time.
31*7c478bd9Sstevel@tonic-gate  * They must not be used by any driver.
32*7c478bd9Sstevel@tonic-gate  */
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_GLDPRIV_H
35*7c478bd9Sstevel@tonic-gate #define	_SYS_GLDPRIV_H
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
40*7c478bd9Sstevel@tonic-gate extern "C" {
41*7c478bd9Sstevel@tonic-gate #endif
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate #ifdef	DEBUG
44*7c478bd9Sstevel@tonic-gate #define	GLD_DEBUG 1
45*7c478bd9Sstevel@tonic-gate #endif
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate /*
48*7c478bd9Sstevel@tonic-gate  * The version number should not be changed.
49*7c478bd9Sstevel@tonic-gate  */
50*7c478bd9Sstevel@tonic-gate #define	GLD_VERSION_200		0x200			/* version 2.0 */
51*7c478bd9Sstevel@tonic-gate #define	GLD_VERSION		GLD_VERSION_200		/* current version */
52*7c478bd9Sstevel@tonic-gate #define	GLD_VERSION_STRING	"v2"			/* in modinfo string */
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate /* gld_global_options bits */
55*7c478bd9Sstevel@tonic-gate #define	GLD_OPT_NO_IPQ		0x00000001	/* don't use IP shortcut */
56*7c478bd9Sstevel@tonic-gate #define	GLD_OPT_NO_FASTPATH	0x00000002	/* don't implement fastpath */
57*7c478bd9Sstevel@tonic-gate #define	GLD_OPT_NO_ETHRXSNAP	0x00000008	/* don't interp SNAP on ether */
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate /* gld per instance options */
60*7c478bd9Sstevel@tonic-gate #define	GLDOPT_FAST_RECV	0x40
61*7c478bd9Sstevel@tonic-gate #define	GLDOPT_CANONICAL_ADDR	0x08
62*7c478bd9Sstevel@tonic-gate #define	GLDOPT_MDT		0x100
63*7c478bd9Sstevel@tonic-gate 
64*7c478bd9Sstevel@tonic-gate /*
65*7c478bd9Sstevel@tonic-gate  * This version of GLD allows a "Virtual-LAN-PPA" to be specified in
66*7c478bd9Sstevel@tonic-gate  * the same manner as Cassini: the virtual PPA number is composed of
67*7c478bd9Sstevel@tonic-gate  * the VLAN tag number (1-4094), multiplied by 1000(!), plus the real
68*7c478bd9Sstevel@tonic-gate  * (hardware) PPA.  Thus "bge23001" refers to the "device" which
69*7c478bd9Sstevel@tonic-gate  * transports packets with tag VLAN "23" over the hardware of "bge1".
70*7c478bd9Sstevel@tonic-gate  *
71*7c478bd9Sstevel@tonic-gate  * This scheme limits the number of physical devices of a single type to
72*7c478bd9Sstevel@tonic-gate  * 1000 e.g. bge0 .. bge999 (since bge1000 would instead be interpreted
73*7c478bd9Sstevel@tonic-gate  * as VLAN1 over bge0).
74*7c478bd9Sstevel@tonic-gate  */
75*7c478bd9Sstevel@tonic-gate #define	GLD_VLAN_SCALE		1000
76*7c478bd9Sstevel@tonic-gate #define	GLD_MAX_PPA		(GLD_VLAN_SCALE-1)
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate /*
79*7c478bd9Sstevel@tonic-gate  * Minor numbers:
80*7c478bd9Sstevel@tonic-gate  *
81*7c478bd9Sstevel@tonic-gate  * For each device type, GLD creates a single "style 2" node with minor 0.
82*7c478bd9Sstevel@tonic-gate  * For each instance of that device type, GLD also creates a "style 1"
83*7c478bd9Sstevel@tonic-gate  * node with minor number one greater than the PPA.  Thus, nodes with
84*7c478bd9Sstevel@tonic-gate  * minor numbers 0..1000 may exist in the /dev* filesystem.
85*7c478bd9Sstevel@tonic-gate  *
86*7c478bd9Sstevel@tonic-gate  * So, on open:
87*7c478bd9Sstevel@tonic-gate  *
88*7c478bd9Sstevel@tonic-gate  * Minor 0 implies DLPI "style 2": the STREAM is not intrinsically
89*7c478bd9Sstevel@tonic-gate  * associated with any particular device/PPA.  The association is set
90*7c478bd9Sstevel@tonic-gate  * (and may be changed) dynamically, by DLPI_ATTACH/DETACH messages.
91*7c478bd9Sstevel@tonic-gate  *
92*7c478bd9Sstevel@tonic-gate  * Minors 1..1000 are "style 1", where the PPA is entirely defined by
93*7c478bd9Sstevel@tonic-gate  * the minor; GLD defines the mapping as PPA=minor-1 (minor=PPA+1).
94*7c478bd9Sstevel@tonic-gate  * Note that the upper bound of 1000 is (now) limited by the VLAN
95*7c478bd9Sstevel@tonic-gate  * mapping scheme set out above.
96*7c478bd9Sstevel@tonic-gate  *
97*7c478bd9Sstevel@tonic-gate  * GLD devices are "self-cloning": each new open will cause a new minor
98*7c478bd9Sstevel@tonic-gate  * number to be allocated; these are selected from the range 1001..0x3ffff.
99*7c478bd9Sstevel@tonic-gate  * This minor number is only associated with the open stream and doesn't
100*7c478bd9Sstevel@tonic-gate  * appear in the /dev* filesystem; manually created nodes with minors in
101*7c478bd9Sstevel@tonic-gate  * this range will be rejected by gld_open().
102*7c478bd9Sstevel@tonic-gate  */
103*7c478bd9Sstevel@tonic-gate #define	GLD_USE_STYLE2		0
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate #define	GLD_MIN_STYLE1_MINOR	1
106*7c478bd9Sstevel@tonic-gate #define	GLD_MAX_STYLE1_MINOR	(GLD_MAX_PPA+1)
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate #define	GLD_STYLE1_MINOR_TO_PPA(minor)	(minor - 1)
109*7c478bd9Sstevel@tonic-gate #define	GLD_STYLE1_PPA_TO_MINOR(ppa)	(ppa + 1)
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate #define	GLD_MIN_CLONE_MINOR	(GLD_MAX_STYLE1_MINOR+1)
112*7c478bd9Sstevel@tonic-gate #define	GLD_MAX_CLONE_MINOR	0x3ffff
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate /* gldm_GLD_flags */
115*7c478bd9Sstevel@tonic-gate #define	GLD_MAC_READY 0x0001	/* this mac has succeeded gld_register */
116*7c478bd9Sstevel@tonic-gate #define	GLD_INTR_READY 0x0001	/* v0 compat name */
117*7c478bd9Sstevel@tonic-gate #define	GLD_INTR_WAIT 0x0002	/* v1: waiting for interrupt to do scheduling */
118*7c478bd9Sstevel@tonic-gate #define	GLD_LOCK_INITED 0x0004	/* maclock is currently initialized */
119*7c478bd9Sstevel@tonic-gate #define	GLD_UNREGISTERED 0x0008	/* this mac has succeeded gld_unregister */
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate /* This is the largest macaddr currently supported by GLD */
122*7c478bd9Sstevel@tonic-gate #define	GLD_MAX_ADDRLEN		32	/* Largest mac addr in all media  */
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate #define	GLD_MAX_MULTICAST	64	/* default multicast table size */
125*7c478bd9Sstevel@tonic-gate 
126*7c478bd9Sstevel@tonic-gate /* multicast structures */
127*7c478bd9Sstevel@tonic-gate typedef struct gld_multicast_addr {
128*7c478bd9Sstevel@tonic-gate 	int		gldm_refcnt;	/* number of streams referring */
129*7c478bd9Sstevel@tonic-gate 					/* to this per-mac entry */
130*7c478bd9Sstevel@tonic-gate 	unsigned char	gldm_addr[GLD_MAX_ADDRLEN];
131*7c478bd9Sstevel@tonic-gate } gld_mcast_t;
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate /* gld_flag bits -- GLD PRIVATE */
134*7c478bd9Sstevel@tonic-gate #define	GLD_RAW		0x0001	/* lower stream is in RAW mode */
135*7c478bd9Sstevel@tonic-gate #define	GLD_FAST	0x0002	/* use "fast" path */
136*7c478bd9Sstevel@tonic-gate #define	GLD_PROM_PHYS	0x0004	/* stream is in physical promiscuous mode */
137*7c478bd9Sstevel@tonic-gate #define	GLD_PROM_SAP	0x0008
138*7c478bd9Sstevel@tonic-gate #define	GLD_PROM_MULT	0x0010
139*7c478bd9Sstevel@tonic-gate #define	GLD_STR_CLOSING	0x0020	/* stream is closing; don't putnext */
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate /*
142*7c478bd9Sstevel@tonic-gate  * gld structure.  Used to define the per-stream information required to
143*7c478bd9Sstevel@tonic-gate  * implement DLPI.
144*7c478bd9Sstevel@tonic-gate  */
145*7c478bd9Sstevel@tonic-gate typedef struct gld {
146*7c478bd9Sstevel@tonic-gate 	struct gld	*gld_next, *gld_prev;
147*7c478bd9Sstevel@tonic-gate 	caddr_t		gld_dummy1;
148*7c478bd9Sstevel@tonic-gate 	int32_t		gld_state;	/* DL_UNATTACHED, DL_UNBOUND, DL_IDLE */
149*7c478bd9Sstevel@tonic-gate 	int32_t		gld_style;	/* open style 1 or style 2 */
150*7c478bd9Sstevel@tonic-gate 	int32_t		gld_minor;	/* cloned minor number */
151*7c478bd9Sstevel@tonic-gate 	int32_t		gld_type;	/* DL_ETHER, DL_TPR, DL_FDDI, etc */
152*7c478bd9Sstevel@tonic-gate 	int32_t		gld_sap;	/* Bound SAP */
153*7c478bd9Sstevel@tonic-gate 	int32_t		gld_flags;	/* flags defined in gldpriv.h */
154*7c478bd9Sstevel@tonic-gate 	int32_t		gld_multicnt;	/* # of stream multicast addresses */
155*7c478bd9Sstevel@tonic-gate 	gld_mcast_t	**gld_mcast;	/* multicast table or NULL */
156*7c478bd9Sstevel@tonic-gate 	queue_t		*gld_qptr;	/* pointer to streams queue */
157*7c478bd9Sstevel@tonic-gate 	caddr_t		gld_dummy2;
158*7c478bd9Sstevel@tonic-gate 	caddr_t		gld_dummy3;
159*7c478bd9Sstevel@tonic-gate 	struct gld_mac_info *gld_mac_info;	/* if not DL_UNATTACHED */
160*7c478bd9Sstevel@tonic-gate 	caddr_t		gld_dummy4;
161*7c478bd9Sstevel@tonic-gate 	struct glddevice *gld_device;	/* per-major structure */
162*7c478bd9Sstevel@tonic-gate 
163*7c478bd9Sstevel@tonic-gate 	volatile boolean_t gld_xwait;		/* want an xmit qenable */
164*7c478bd9Sstevel@tonic-gate 	volatile boolean_t gld_sched_ran;	/* gld_sched examined this Q */
165*7c478bd9Sstevel@tonic-gate 	volatile boolean_t gld_in_unbind;	/* DL_UNBIND in progress */
166*7c478bd9Sstevel@tonic-gate 	volatile uint32_t gld_wput_count; /* number of threads in wput=>start */
167*7c478bd9Sstevel@tonic-gate 	volatile boolean_t gld_in_wsrv;	/* Q thread currently running in wsrv */
168*7c478bd9Sstevel@tonic-gate 
169*7c478bd9Sstevel@tonic-gate 	boolean_t	gld_ethertype;	/* ethertype/LLC stream */
170*7c478bd9Sstevel@tonic-gate 	uint32_t	gld_notifications;
171*7c478bd9Sstevel@tonic-gate 	uint32_t	gld_upri;	/* user priority */
172*7c478bd9Sstevel@tonic-gate 	void		*gld_vlan;
173*7c478bd9Sstevel@tonic-gate 	int (*gld_send)();
174*7c478bd9Sstevel@tonic-gate } gld_t;
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate /*
177*7c478bd9Sstevel@tonic-gate  * definitions for the per driver class structure
178*7c478bd9Sstevel@tonic-gate  */
179*7c478bd9Sstevel@tonic-gate typedef struct glddevice {
180*7c478bd9Sstevel@tonic-gate 	struct glddevice *gld_next, *gld_prev;
181*7c478bd9Sstevel@tonic-gate 	int		gld_ndevice;	/* number of mac devices linked */
182*7c478bd9Sstevel@tonic-gate 	gld_mac_info_t	*gld_mac_next, *gld_mac_prev;	/* the various macs */
183*7c478bd9Sstevel@tonic-gate 	gld_t		*gld_str_next, *gld_str_prev;	/* open, unattached, */
184*7c478bd9Sstevel@tonic-gate 							/* style 2 streams */
185*7c478bd9Sstevel@tonic-gate 	char		gld_name[16];	/* name of device */
186*7c478bd9Sstevel@tonic-gate 	kmutex_t	gld_devlock;	/* used to serialize read/write locks */
187*7c478bd9Sstevel@tonic-gate 	int		gld_nextminor;	/* next unused minor number for clone */
188*7c478bd9Sstevel@tonic-gate 	int		gld_major;	/* device's major number */
189*7c478bd9Sstevel@tonic-gate 	int		gld_multisize;	/* # of multicast entries to alloc */
190*7c478bd9Sstevel@tonic-gate 	int		gld_type;	/* for use before attach */
191*7c478bd9Sstevel@tonic-gate 	int		gld_minsdu;
192*7c478bd9Sstevel@tonic-gate 	int		gld_maxsdu;
193*7c478bd9Sstevel@tonic-gate 	int		gld_addrlen;	/* physical address length */
194*7c478bd9Sstevel@tonic-gate 	int		gld_saplen;	/* sap length, neg appends */
195*7c478bd9Sstevel@tonic-gate 	unsigned char	*gld_broadcast;	/* pointer to broadcast address */
196*7c478bd9Sstevel@tonic-gate 	int		gld_styles;	/* provider styles */
197*7c478bd9Sstevel@tonic-gate } glddev_t;
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate typedef struct pktinfo {
200*7c478bd9Sstevel@tonic-gate 	uint_t		isBroadcast:1;
201*7c478bd9Sstevel@tonic-gate 	uint_t		isMulticast:1;
202*7c478bd9Sstevel@tonic-gate 	uint_t		isLooped:1;
203*7c478bd9Sstevel@tonic-gate 	uint_t		isForMe:1;
204*7c478bd9Sstevel@tonic-gate 	uint_t		isLLC:1;
205*7c478bd9Sstevel@tonic-gate 	uint_t		user_pri:3;
206*7c478bd9Sstevel@tonic-gate 	uint_t		cfi:1;
207*7c478bd9Sstevel@tonic-gate 	uint_t		vid:12;
208*7c478bd9Sstevel@tonic-gate 	uint_t		wasAccepted:1;
209*7c478bd9Sstevel@tonic-gate 	uint_t		nosource:1;
210*7c478bd9Sstevel@tonic-gate 	uint_t		macLen;
211*7c478bd9Sstevel@tonic-gate 	uint_t		hdrLen;
212*7c478bd9Sstevel@tonic-gate 	uint_t		pktLen;
213*7c478bd9Sstevel@tonic-gate 	uchar_t		dhost[GLD_MAX_ADDRLEN];
214*7c478bd9Sstevel@tonic-gate 	uchar_t		shost[GLD_MAX_ADDRLEN];
215*7c478bd9Sstevel@tonic-gate 	uint_t		ethertype;
216*7c478bd9Sstevel@tonic-gate } pktinfo_t;
217*7c478bd9Sstevel@tonic-gate 
218*7c478bd9Sstevel@tonic-gate /*
219*7c478bd9Sstevel@tonic-gate  * Flags input to the gld_interpret_*() interpreter routines.
220*7c478bd9Sstevel@tonic-gate  */
221*7c478bd9Sstevel@tonic-gate typedef enum packet_flag {
222*7c478bd9Sstevel@tonic-gate 	GLD_RXQUICK,
223*7c478bd9Sstevel@tonic-gate 	GLD_RXLOOP,
224*7c478bd9Sstevel@tonic-gate 	GLD_RX,
225*7c478bd9Sstevel@tonic-gate 	GLD_TX
226*7c478bd9Sstevel@tonic-gate } packet_flag_t;
227*7c478bd9Sstevel@tonic-gate 
228*7c478bd9Sstevel@tonic-gate /*
229*7c478bd9Sstevel@tonic-gate  * Flags input to the gld_interpret_mdt_*() interpreter routines.
230*7c478bd9Sstevel@tonic-gate  */
231*7c478bd9Sstevel@tonic-gate typedef enum mdt_packet_flag {
232*7c478bd9Sstevel@tonic-gate 	GLD_MDT_TX,
233*7c478bd9Sstevel@tonic-gate 	GLD_MDT_TXPKT,
234*7c478bd9Sstevel@tonic-gate 	GLD_MDT_RXLOOP
235*7c478bd9Sstevel@tonic-gate } mdt_packet_flag_t;
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate /*
238*7c478bd9Sstevel@tonic-gate  * Describes characteristics of the Media Access Layer.
239*7c478bd9Sstevel@tonic-gate  * The mac_type is one of the supported DLPI media types (see <sys/dlpi.h>).
240*7c478bd9Sstevel@tonic-gate  * The mtu_size is the size of the largest frame.
241*7c478bd9Sstevel@tonic-gate  * The interpreter is the function that "knows" how to interpret the frame.
242*7c478bd9Sstevel@tonic-gate  * The interpreter_mdt routine knows how to interpret/format MDT packets.
243*7c478bd9Sstevel@tonic-gate  * Other routines create and/or add headers to packets.
244*7c478bd9Sstevel@tonic-gate  */
245*7c478bd9Sstevel@tonic-gate typedef struct {
246*7c478bd9Sstevel@tonic-gate 	uint_t	mac_type;
247*7c478bd9Sstevel@tonic-gate 	uint_t	mtu_size;
248*7c478bd9Sstevel@tonic-gate 	int	hdr_size;
249*7c478bd9Sstevel@tonic-gate 	int	(*interpreter)(gld_mac_info_t *, mblk_t *, pktinfo_t *, int);
250*7c478bd9Sstevel@tonic-gate 	void	(*interpreter_mdt)(gld_mac_info_t *, mblk_t *,
251*7c478bd9Sstevel@tonic-gate 		    struct pdescinfo_s *, pktinfo_t *, int);
252*7c478bd9Sstevel@tonic-gate 	mblk_t	*(*mkfastpath)(gld_t *, mblk_t *);
253*7c478bd9Sstevel@tonic-gate 	mblk_t	*(*mkunitdata)(gld_t *, mblk_t *);
254*7c478bd9Sstevel@tonic-gate 	void	(*init)(gld_mac_info_t *);
255*7c478bd9Sstevel@tonic-gate 	void	(*uninit)(gld_mac_info_t *);
256*7c478bd9Sstevel@tonic-gate 	char	*mac_string;
257*7c478bd9Sstevel@tonic-gate } gld_interface_t;
258*7c478bd9Sstevel@tonic-gate 
259*7c478bd9Sstevel@tonic-gate /*
260*7c478bd9Sstevel@tonic-gate  * structure for names stat structure usage as required by "netstat"
261*7c478bd9Sstevel@tonic-gate  */
262*7c478bd9Sstevel@tonic-gate typedef union media_kstats {
263*7c478bd9Sstevel@tonic-gate 	struct dot3kstat {
264*7c478bd9Sstevel@tonic-gate 		kstat_named_t	first_coll;
265*7c478bd9Sstevel@tonic-gate 		kstat_named_t	multi_coll;
266*7c478bd9Sstevel@tonic-gate 		kstat_named_t	sqe_error;
267*7c478bd9Sstevel@tonic-gate 		kstat_named_t	mac_xmt_error;
268*7c478bd9Sstevel@tonic-gate 		kstat_named_t	frame_too_long;
269*7c478bd9Sstevel@tonic-gate 		kstat_named_t	mac_rcv_error;
270*7c478bd9Sstevel@tonic-gate 	} dot3;
271*7c478bd9Sstevel@tonic-gate 	struct dot5kstat {
272*7c478bd9Sstevel@tonic-gate 		kstat_named_t	ace_error;
273*7c478bd9Sstevel@tonic-gate 		kstat_named_t	internal_error;
274*7c478bd9Sstevel@tonic-gate 		kstat_named_t	lost_frame_error;
275*7c478bd9Sstevel@tonic-gate 		kstat_named_t	frame_copied_error;
276*7c478bd9Sstevel@tonic-gate 		kstat_named_t	token_error;
277*7c478bd9Sstevel@tonic-gate 		kstat_named_t	freq_error;
278*7c478bd9Sstevel@tonic-gate 	} dot5;
279*7c478bd9Sstevel@tonic-gate 	struct fddikstat {
280*7c478bd9Sstevel@tonic-gate 		kstat_named_t	mac_error;
281*7c478bd9Sstevel@tonic-gate 		kstat_named_t	mac_lost;
282*7c478bd9Sstevel@tonic-gate 		kstat_named_t	mac_token;
283*7c478bd9Sstevel@tonic-gate 		kstat_named_t	mac_tvx_expired;
284*7c478bd9Sstevel@tonic-gate 		kstat_named_t	mac_late;
285*7c478bd9Sstevel@tonic-gate 		kstat_named_t	mac_ring_op;
286*7c478bd9Sstevel@tonic-gate 	} fddi;
287*7c478bd9Sstevel@tonic-gate } media_kstats_t;
288*7c478bd9Sstevel@tonic-gate 
289*7c478bd9Sstevel@tonic-gate struct gldkstats {
290*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_pktxmt;
291*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_pktrcv;
292*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_errxmt;
293*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_errrcv;
294*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_collisions;
295*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_bytexmt;
296*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_bytercv;
297*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_multixmt;
298*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_multircv;	/* multicast but not broadcast */
299*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_brdcstxmt;
300*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_brdcstrcv;
301*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_unknowns;
302*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_blocked;	/* discard due to upstream flow */
303*7c478bd9Sstevel@tonic-gate 					/* control */
304*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_excoll;
305*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_defer;
306*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_frame;
307*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_crc;
308*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_overflow;
309*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_underflow;
310*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_short;
311*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_missed;
312*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_xmtlatecoll;
313*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_nocarrier;
314*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_noxmtbuf;
315*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_norcvbuf;
316*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_xmtbadinterp;
317*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_rcvbadinterp;
318*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_intr;
319*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_xmtretry;
320*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_pktxmt64;
321*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_pktrcv64;
322*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_bytexmt64;
323*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_bytercv64;
324*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_speed;
325*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_duplex;
326*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_media;
327*7c478bd9Sstevel@tonic-gate 	kstat_named_t	glds_prom;
328*7c478bd9Sstevel@tonic-gate 	media_kstats_t	glds_media_specific;
329*7c478bd9Sstevel@tonic-gate };
330*7c478bd9Sstevel@tonic-gate 
331*7c478bd9Sstevel@tonic-gate typedef struct gld_mac_pvt gld_mac_pvt_t;
332*7c478bd9Sstevel@tonic-gate 
333*7c478bd9Sstevel@tonic-gate typedef struct gld_vlan {
334*7c478bd9Sstevel@tonic-gate 	struct gld_vlan *gldv_next, *gldv_prev;
335*7c478bd9Sstevel@tonic-gate 	uint32_t		gldv_id;
336*7c478bd9Sstevel@tonic-gate 	uint32_t		gldv_ptag;
337*7c478bd9Sstevel@tonic-gate 	int			gldv_nstreams;
338*7c478bd9Sstevel@tonic-gate 	gld_mac_info_t		*gldv_mac;
339*7c478bd9Sstevel@tonic-gate 	queue_t			*gldv_ipq;
340*7c478bd9Sstevel@tonic-gate 	queue_t			*gldv_ipv6q;
341*7c478bd9Sstevel@tonic-gate 	uint8_t			gldv_ipq_flags;
342*7c478bd9Sstevel@tonic-gate 	struct gld		*gldv_str_next;	/* list of attached streams */
343*7c478bd9Sstevel@tonic-gate 	struct gld		*gldv_str_prev;
344*7c478bd9Sstevel@tonic-gate 	kstat_t			*gldv_kstatp;
345*7c478bd9Sstevel@tonic-gate 	struct gld_stats	*gldv_stats;
346*7c478bd9Sstevel@tonic-gate } gld_vlan_t;
347*7c478bd9Sstevel@tonic-gate 
348*7c478bd9Sstevel@tonic-gate #define	IPQ_DISABLED	0x01
349*7c478bd9Sstevel@tonic-gate #define	IPQ_FORBIDDEN	0x02
350*7c478bd9Sstevel@tonic-gate 
351*7c478bd9Sstevel@tonic-gate #define	VLAN_HASHSZ	23
352*7c478bd9Sstevel@tonic-gate 
353*7c478bd9Sstevel@tonic-gate /* Per-mac info used by GLD */
354*7c478bd9Sstevel@tonic-gate struct gld_mac_pvt {
355*7c478bd9Sstevel@tonic-gate 	gld_interface_t	*interfacep;
356*7c478bd9Sstevel@tonic-gate 	kmutex_t	datalock;	/* data lock for "data" */
357*7c478bd9Sstevel@tonic-gate 	caddr_t		data;		/* media specific private data */
358*7c478bd9Sstevel@tonic-gate 	gld_vlan_t	*vlan_hash[VLAN_HASHSZ];
359*7c478bd9Sstevel@tonic-gate 	struct gld	*last_sched;	/* last scheduled stream */
360*7c478bd9Sstevel@tonic-gate 	struct glddevice *major_dev;	/* per-major device struct */
361*7c478bd9Sstevel@tonic-gate 	int		nvlan;		/* VLANs in use on this mac */
362*7c478bd9Sstevel@tonic-gate 	int		nprom;		/* num streams in promiscuous mode */
363*7c478bd9Sstevel@tonic-gate 	int		nprom_multi;	/* streams in promiscuous multicast */
364*7c478bd9Sstevel@tonic-gate 	gld_mcast_t	*mcast_table;	/* per device multicast table */
365*7c478bd9Sstevel@tonic-gate 	unsigned char	*curr_macaddr;	/* Currently programmed mac address */
366*7c478bd9Sstevel@tonic-gate 	kstat_t		*kstatp;
367*7c478bd9Sstevel@tonic-gate 	struct gld_stats *statistics;	/* The ones the driver updates */
368*7c478bd9Sstevel@tonic-gate 	int		rde_enabled;	/* RDE (Source Routing) Enabled */
369*7c478bd9Sstevel@tonic-gate 	int		rde_str_indicator_ste;	/* use STE when no SR info */
370*7c478bd9Sstevel@tonic-gate 	int		rde_timeout;	/* route link inactivity timeout */
371*7c478bd9Sstevel@tonic-gate 	uint32_t	notifications;	/* DL_NOTE options supported */
372*7c478bd9Sstevel@tonic-gate 	boolean_t	started;	/* Has the MAC been started? */
373*7c478bd9Sstevel@tonic-gate };
374*7c478bd9Sstevel@tonic-gate 
375*7c478bd9Sstevel@tonic-gate /* return values from gld_cmds */
376*7c478bd9Sstevel@tonic-gate #define	GLDE_OK		(-1)	/* internal procedure status is OK */
377*7c478bd9Sstevel@tonic-gate #define	GLDE_RETRY	0x1002	/* want to retry later */
378*7c478bd9Sstevel@tonic-gate 
379*7c478bd9Sstevel@tonic-gate /* caller argument to gld_start */
380*7c478bd9Sstevel@tonic-gate #define	GLD_WPUT	0
381*7c478bd9Sstevel@tonic-gate #define	GLD_WSRV	1
382*7c478bd9Sstevel@tonic-gate 
383*7c478bd9Sstevel@tonic-gate #define	GLD_MAX_802_SAP	0xff
384*7c478bd9Sstevel@tonic-gate 
385*7c478bd9Sstevel@tonic-gate /*
386*7c478bd9Sstevel@tonic-gate  * definitions for debug tracing
387*7c478bd9Sstevel@tonic-gate  */
388*7c478bd9Sstevel@tonic-gate #define	GLDTRACE	0x0001	/* basic procedure level tracing */
389*7c478bd9Sstevel@tonic-gate #define	GLDERRS		0x0002	/* trace errors */
390*7c478bd9Sstevel@tonic-gate #define	GLDRECV		0x0004	/* trace receive path */
391*7c478bd9Sstevel@tonic-gate #define	GLDSEND		0x0008	/* trace send path */
392*7c478bd9Sstevel@tonic-gate #define	GLDPROT		0x0010	/* trace DLPI protocol */
393*7c478bd9Sstevel@tonic-gate #define	GLDNOBR		0x0020	/* do not show broadcast messages */
394*7c478bd9Sstevel@tonic-gate #define	GLDETRACE	0x0040	/* trace "normal case" errors */
395*7c478bd9Sstevel@tonic-gate #define	GLDRDE		0x0080	/* netstat -k dump routing table */
396*7c478bd9Sstevel@tonic-gate 
397*7c478bd9Sstevel@tonic-gate /*
398*7c478bd9Sstevel@tonic-gate  * Lock manipulation macros for GLDM_LOCK. Conceptually, the
399*7c478bd9Sstevel@tonic-gate  * GLD layer treats the lock as a rw lock; for v0 binary and
400*7c478bd9Sstevel@tonic-gate  * semantic compatibility, the underlying implementation still
401*7c478bd9Sstevel@tonic-gate  * uses a mutex, whereas for v2 drivers, the more scalable rwlock
402*7c478bd9Sstevel@tonic-gate  * is used instead. See notes in gld.h.
403*7c478bd9Sstevel@tonic-gate  */
404*7c478bd9Sstevel@tonic-gate #define	GLDM_LOCK_INIT(macinfo)						\
405*7c478bd9Sstevel@tonic-gate 	rw_init(&(macinfo)->gldm_lock.gldl_rw_lock, NULL,		\
406*7c478bd9Sstevel@tonic-gate 	    RW_DRIVER, (macinfo)->gldm_cookie);				\
407*7c478bd9Sstevel@tonic-gate 	(macinfo)->gldm_GLD_flags |= GLD_LOCK_INITED
408*7c478bd9Sstevel@tonic-gate 
409*7c478bd9Sstevel@tonic-gate #define	GLDM_LOCK_INITED(macinfo)					\
410*7c478bd9Sstevel@tonic-gate 	((macinfo)->gldm_GLD_flags & GLD_LOCK_INITED)
411*7c478bd9Sstevel@tonic-gate 
412*7c478bd9Sstevel@tonic-gate #define	GLDM_LOCK_DESTROY(macinfo)					\
413*7c478bd9Sstevel@tonic-gate 	if ((macinfo)->gldm_GLD_flags & GLD_LOCK_INITED) {		\
414*7c478bd9Sstevel@tonic-gate 		rw_destroy(&(macinfo)->gldm_lock.gldl_rw_lock);		\
415*7c478bd9Sstevel@tonic-gate 		(macinfo)->gldm_GLD_flags &= ~GLD_LOCK_INITED;		\
416*7c478bd9Sstevel@tonic-gate 	}
417*7c478bd9Sstevel@tonic-gate 
418*7c478bd9Sstevel@tonic-gate #define	GLDM_LOCK(macinfo, rw)						\
419*7c478bd9Sstevel@tonic-gate 	rw_enter(&(macinfo)->gldm_lock.gldl_rw_lock, (rw))
420*7c478bd9Sstevel@tonic-gate 
421*7c478bd9Sstevel@tonic-gate #define	GLDM_UNLOCK(macinfo)						\
422*7c478bd9Sstevel@tonic-gate 	rw_exit(&(macinfo)->gldm_lock.gldl_rw_lock)
423*7c478bd9Sstevel@tonic-gate 
424*7c478bd9Sstevel@tonic-gate #define	GLDM_TRYLOCK(macinfo, rw)					\
425*7c478bd9Sstevel@tonic-gate 	rw_tryenter(&(macinfo)->gldm_lock.gldl_rw_lock, (rw))
426*7c478bd9Sstevel@tonic-gate 
427*7c478bd9Sstevel@tonic-gate /* lock held in read or write mode? */
428*7c478bd9Sstevel@tonic-gate #define	GLDM_LOCK_HELD(macinfo)						\
429*7c478bd9Sstevel@tonic-gate 	rw_lock_held(&(macinfo)->gldm_lock.gldl_rw_lock)
430*7c478bd9Sstevel@tonic-gate 
431*7c478bd9Sstevel@tonic-gate /* lock held in write mode? */
432*7c478bd9Sstevel@tonic-gate #define	GLDM_LOCK_HELD_WRITE(macinfo)					\
433*7c478bd9Sstevel@tonic-gate 	rw_write_held(&(macinfo)->gldm_lock.gldl_rw_lock)
434*7c478bd9Sstevel@tonic-gate 
435*7c478bd9Sstevel@tonic-gate /*
436*7c478bd9Sstevel@tonic-gate  * Compare/copy two MAC addresses.
437*7c478bd9Sstevel@tonic-gate  * Note that unlike bcmp, we return zero if they are different.
438*7c478bd9Sstevel@tonic-gate  */
439*7c478bd9Sstevel@tonic-gate #define	mac_eq(a, b, l) (bcmp((caddr_t)(a), (caddr_t)(b), (l)) == 0)
440*7c478bd9Sstevel@tonic-gate #define	mac_copy(a, b, l) (bcopy((caddr_t)(a), (caddr_t)(b), (l)))
441*7c478bd9Sstevel@tonic-gate /* copy a mac address to/from canonical form */
442*7c478bd9Sstevel@tonic-gate #define	cmac_copy(a, b, l, macinfo) {					\
443*7c478bd9Sstevel@tonic-gate 	    if ((macinfo)->gldm_options & GLDOPT_CANONICAL_ADDR)	\
444*7c478bd9Sstevel@tonic-gate 		gld_bitrevcopy((caddr_t)(a), (caddr_t)(b), (l));	\
445*7c478bd9Sstevel@tonic-gate 	    else							\
446*7c478bd9Sstevel@tonic-gate 		mac_copy((a), (b), (l));				\
447*7c478bd9Sstevel@tonic-gate 	}
448*7c478bd9Sstevel@tonic-gate 
449*7c478bd9Sstevel@tonic-gate /*
450*7c478bd9Sstevel@tonic-gate  * Macros to access possibly-unaligned variables
451*7c478bd9Sstevel@tonic-gate  */
452*7c478bd9Sstevel@tonic-gate 
453*7c478bd9Sstevel@tonic-gate #if	(_ALIGNMENT_REQUIRED == 0)
454*7c478bd9Sstevel@tonic-gate 
455*7c478bd9Sstevel@tonic-gate #define	REF_HOST_USHORT(lvalue) (lvalue)
456*7c478bd9Sstevel@tonic-gate #define	REF_NET_USHORT(lvalue) (ntohs(lvalue))
457*7c478bd9Sstevel@tonic-gate #define	SET_NET_USHORT(lvalue, val) ((lvalue) = htons(val))
458*7c478bd9Sstevel@tonic-gate 
459*7c478bd9Sstevel@tonic-gate #else	/* ALIGNMENT_REQUIRED */
460*7c478bd9Sstevel@tonic-gate 
461*7c478bd9Sstevel@tonic-gate #define	REF_NET_USHORT(lvalue) \
462*7c478bd9Sstevel@tonic-gate 	((ushort_t)((((uchar_t *)(&(lvalue)))[0]<<8) | \
463*7c478bd9Sstevel@tonic-gate 	((uchar_t *)(&(lvalue)))[1]))
464*7c478bd9Sstevel@tonic-gate 
465*7c478bd9Sstevel@tonic-gate #define	SET_NET_USHORT(lvalue, val) { \
466*7c478bd9Sstevel@tonic-gate 	((uchar_t *)(&(lvalue)))[0] = (uchar_t)((val)>>8); \
467*7c478bd9Sstevel@tonic-gate 	((uchar_t *)(&(lvalue)))[1] = (uchar_t)(val); \
468*7c478bd9Sstevel@tonic-gate }
469*7c478bd9Sstevel@tonic-gate 
470*7c478bd9Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN)
471*7c478bd9Sstevel@tonic-gate 
472*7c478bd9Sstevel@tonic-gate #define	REF_HOST_USHORT(lvalue) \
473*7c478bd9Sstevel@tonic-gate 	((ushort_t)((((uchar_t *)(&(lvalue)))[1]<<8) | \
474*7c478bd9Sstevel@tonic-gate 	((uchar_t *)(&(lvalue)))[0]))
475*7c478bd9Sstevel@tonic-gate 
476*7c478bd9Sstevel@tonic-gate #elif defined(_BIG_ENDIAN)
477*7c478bd9Sstevel@tonic-gate 
478*7c478bd9Sstevel@tonic-gate #define	REF_HOST_USHORT(lvalue) \
479*7c478bd9Sstevel@tonic-gate 	((ushort_t)((((uchar_t *)(&(lvalue)))[0]<<8) | \
480*7c478bd9Sstevel@tonic-gate 	((uchar_t *)(&(lvalue)))[1]))
481*7c478bd9Sstevel@tonic-gate 
482*7c478bd9Sstevel@tonic-gate #else	/* unknown endian */
483*7c478bd9Sstevel@tonic-gate #error	"what endian is this machine?"
484*7c478bd9Sstevel@tonic-gate #endif	/* endian */
485*7c478bd9Sstevel@tonic-gate 
486*7c478bd9Sstevel@tonic-gate #endif	/* ALIGNMENT_REQUIRED */
487*7c478bd9Sstevel@tonic-gate 
488*7c478bd9Sstevel@tonic-gate /* ================================================================ */
489*7c478bd9Sstevel@tonic-gate /* Route Determination Entity definitions (IEEE 802.2 1994 edition) */
490*7c478bd9Sstevel@tonic-gate /* ================================================================ */
491*7c478bd9Sstevel@tonic-gate 
492*7c478bd9Sstevel@tonic-gate struct rde_pdu {
493*7c478bd9Sstevel@tonic-gate 	uchar_t	rde_ver;
494*7c478bd9Sstevel@tonic-gate 	uchar_t	rde_ptype;
495*7c478bd9Sstevel@tonic-gate 	uchar_t	rde_target_mac[6];
496*7c478bd9Sstevel@tonic-gate 	uchar_t	rde_orig_mac[6];
497*7c478bd9Sstevel@tonic-gate 	uchar_t	rde_target_sap;
498*7c478bd9Sstevel@tonic-gate 	uchar_t	rde_orig_sap;
499*7c478bd9Sstevel@tonic-gate };
500*7c478bd9Sstevel@tonic-gate 
501*7c478bd9Sstevel@tonic-gate #define	LSAP_RDE	0xa6	/* IEEE 802.2 section 3.3.1.2 */
502*7c478bd9Sstevel@tonic-gate #define	RDE_RQC		0x01	/* Route Query Command */
503*7c478bd9Sstevel@tonic-gate #define	RDE_RQR		0x02	/* Route Query Response */
504*7c478bd9Sstevel@tonic-gate #define	RDE_RS		0x03	/* Route Selected */
505*7c478bd9Sstevel@tonic-gate 
506*7c478bd9Sstevel@tonic-gate /* ============================================================= */
507*7c478bd9Sstevel@tonic-gate /* Source Routing fields and definitions (IEEE 802.2 and 802.1D) */
508*7c478bd9Sstevel@tonic-gate /* ============================================================= */
509*7c478bd9Sstevel@tonic-gate 
510*7c478bd9Sstevel@tonic-gate #define	MAX_RDFLDS	14	/* changed to 14 from 8 as per IEEE */
511*7c478bd9Sstevel@tonic-gate 
512*7c478bd9Sstevel@tonic-gate /*
513*7c478bd9Sstevel@tonic-gate  * Source Routing Route Information field.
514*7c478bd9Sstevel@tonic-gate  */
515*7c478bd9Sstevel@tonic-gate struct gld_ri {
516*7c478bd9Sstevel@tonic-gate #if defined(_BIT_FIELDS_LTOH)
517*7c478bd9Sstevel@tonic-gate 	uchar_t len:5;			/* length */
518*7c478bd9Sstevel@tonic-gate 	uchar_t rt:3;			/* routing type */
519*7c478bd9Sstevel@tonic-gate 	uchar_t res:4;			/* reserved */
520*7c478bd9Sstevel@tonic-gate 	uchar_t mtu:3;			/* largest frame */
521*7c478bd9Sstevel@tonic-gate 	uchar_t dir:1;			/* direction bit */
522*7c478bd9Sstevel@tonic-gate 	struct tr_rd {			/* route designator fields */
523*7c478bd9Sstevel@tonic-gate 		ushort_t bridge:4;	/* Note: assumes network order... */
524*7c478bd9Sstevel@tonic-gate 		ushort_t ring:12;	/* ...(Big Endian) -- needs ntohs() */
525*7c478bd9Sstevel@tonic-gate 	} rd[MAX_RDFLDS];
526*7c478bd9Sstevel@tonic-gate #elif defined(_BIT_FIELDS_HTOL)
527*7c478bd9Sstevel@tonic-gate 	uchar_t rt:3;			/* routing type */
528*7c478bd9Sstevel@tonic-gate 	uchar_t len:5;			/* length */
529*7c478bd9Sstevel@tonic-gate 	uchar_t dir:1;			/* direction bit */
530*7c478bd9Sstevel@tonic-gate 	uchar_t mtu:3;			/* largest frame */
531*7c478bd9Sstevel@tonic-gate 	uchar_t res:4;			/* reserved */
532*7c478bd9Sstevel@tonic-gate 	struct tr_rd {			/* route designator fields */
533*7c478bd9Sstevel@tonic-gate 		ushort_t ring:12;
534*7c478bd9Sstevel@tonic-gate 		ushort_t bridge:4;
535*7c478bd9Sstevel@tonic-gate 	} rd[MAX_RDFLDS];
536*7c478bd9Sstevel@tonic-gate #else
537*7c478bd9Sstevel@tonic-gate #error	"which way do bit fields get allocated?"
538*7c478bd9Sstevel@tonic-gate #endif
539*7c478bd9Sstevel@tonic-gate };
540*7c478bd9Sstevel@tonic-gate 
541*7c478bd9Sstevel@tonic-gate #define	RT_SRF		0x0		/* 0xx: specifically routed frame */
542*7c478bd9Sstevel@tonic-gate #define	RT_ARE		0x4		/* 10x: all routes explorer frame */
543*7c478bd9Sstevel@tonic-gate #define	RT_STE		0x6		/* 11x: spanning tree explorer frame */
544*7c478bd9Sstevel@tonic-gate 
545*7c478bd9Sstevel@tonic-gate #define	RT_MTU_MAX	0x7		/* Max MTU field (base only) */
546*7c478bd9Sstevel@tonic-gate 
547*7c478bd9Sstevel@tonic-gate /*
548*7c478bd9Sstevel@tonic-gate  * Source route table info
549*7c478bd9Sstevel@tonic-gate  */
550*7c478bd9Sstevel@tonic-gate struct srtab {
551*7c478bd9Sstevel@tonic-gate 	struct srtab	*sr_next;		/* next in linked list */
552*7c478bd9Sstevel@tonic-gate 	uchar_t		sr_mac[6];		/* MAC address */
553*7c478bd9Sstevel@tonic-gate 	struct		gld_ri sr_ri;		/* routing information */
554*7c478bd9Sstevel@tonic-gate 	clock_t		sr_timer;
555*7c478bd9Sstevel@tonic-gate };
556*7c478bd9Sstevel@tonic-gate 
557*7c478bd9Sstevel@tonic-gate #define	SR_HASH_SIZE	256		/* Number of bins */
558*7c478bd9Sstevel@tonic-gate 
559*7c478bd9Sstevel@tonic-gate /* ================================================================= */
560*7c478bd9Sstevel@tonic-gate /* Media dependent defines for media dependent routines in gldutil.c */
561*7c478bd9Sstevel@tonic-gate /* ================================================================= */
562*7c478bd9Sstevel@tonic-gate 
563*7c478bd9Sstevel@tonic-gate /*
564*7c478bd9Sstevel@tonic-gate  * Some "semi-generic" defines used by ether, token, and fddi,
565*7c478bd9Sstevel@tonic-gate  * and probably anything else with addrlen == 6 && saplen == -2.
566*7c478bd9Sstevel@tonic-gate  */
567*7c478bd9Sstevel@tonic-gate 
568*7c478bd9Sstevel@tonic-gate struct gld_dlsap {
569*7c478bd9Sstevel@tonic-gate 	unsigned char   glda_addr[ETHERADDRL];
570*7c478bd9Sstevel@tonic-gate 	unsigned short  glda_sap;
571*7c478bd9Sstevel@tonic-gate };
572*7c478bd9Sstevel@tonic-gate 
573*7c478bd9Sstevel@tonic-gate #define	DLSAP(p, offset) ((struct gld_dlsap *)((caddr_t)(p)+offset))
574*7c478bd9Sstevel@tonic-gate 
575*7c478bd9Sstevel@tonic-gate typedef uchar_t mac_addr_t[ETHERADDRL];
576*7c478bd9Sstevel@tonic-gate 
577*7c478bd9Sstevel@tonic-gate struct llc_snap_hdr {
578*7c478bd9Sstevel@tonic-gate 	uchar_t  d_lsap;		/* destination service access point */
579*7c478bd9Sstevel@tonic-gate 	uchar_t  s_lsap;		/* source link service access point */
580*7c478bd9Sstevel@tonic-gate 	uchar_t  control;		/* short control field */
581*7c478bd9Sstevel@tonic-gate 	uchar_t  org[3];		/* Ethernet style organization field */
582*7c478bd9Sstevel@tonic-gate 	ushort_t type;			/* Ethernet style type field */
583*7c478bd9Sstevel@tonic-gate };
584*7c478bd9Sstevel@tonic-gate 
585*7c478bd9Sstevel@tonic-gate #define	LLC_HDR1_LEN		3	/* Length of the LLC1 header */
586*7c478bd9Sstevel@tonic-gate #define	LLC_SNAP_HDR_LEN	8	/* Full length of SNAP header */
587*7c478bd9Sstevel@tonic-gate #define	LSAP_SNAP		0xaa	/* SAP for SubNet Access Protocol */
588*7c478bd9Sstevel@tonic-gate #define	CNTL_LLC_UI		0x03	/* un-numbered information packet */
589*7c478bd9Sstevel@tonic-gate 
590*7c478bd9Sstevel@tonic-gate /* ============================ */
591*7c478bd9Sstevel@tonic-gate /* Ethernet related definitions */
592*7c478bd9Sstevel@tonic-gate /* ============================ */
593*7c478bd9Sstevel@tonic-gate 
594*7c478bd9Sstevel@tonic-gate struct ether_mac_frm {
595*7c478bd9Sstevel@tonic-gate 	mac_addr_t	ether_dhost;
596*7c478bd9Sstevel@tonic-gate 	mac_addr_t	ether_shost;
597*7c478bd9Sstevel@tonic-gate 	ushort_t	ether_type;
598*7c478bd9Sstevel@tonic-gate };
599*7c478bd9Sstevel@tonic-gate 
600*7c478bd9Sstevel@tonic-gate /* ======================== */
601*7c478bd9Sstevel@tonic-gate /* FDDI related definitions */
602*7c478bd9Sstevel@tonic-gate /* ======================== */
603*7c478bd9Sstevel@tonic-gate 
604*7c478bd9Sstevel@tonic-gate struct	fddi_mac_frm {
605*7c478bd9Sstevel@tonic-gate 	uchar_t		fddi_fc;
606*7c478bd9Sstevel@tonic-gate 	mac_addr_t	fddi_dhost;
607*7c478bd9Sstevel@tonic-gate 	mac_addr_t	fddi_shost;
608*7c478bd9Sstevel@tonic-gate };
609*7c478bd9Sstevel@tonic-gate 
610*7c478bd9Sstevel@tonic-gate /* ============================== */
611*7c478bd9Sstevel@tonic-gate /* Token Ring related definitions */
612*7c478bd9Sstevel@tonic-gate /* ============================== */
613*7c478bd9Sstevel@tonic-gate 
614*7c478bd9Sstevel@tonic-gate struct tr_mac_frm_nori {
615*7c478bd9Sstevel@tonic-gate 	uchar_t		tr_ac;
616*7c478bd9Sstevel@tonic-gate 	uchar_t		tr_fc;
617*7c478bd9Sstevel@tonic-gate 	mac_addr_t	tr_dhost;
618*7c478bd9Sstevel@tonic-gate 	mac_addr_t	tr_shost;
619*7c478bd9Sstevel@tonic-gate };
620*7c478bd9Sstevel@tonic-gate 
621*7c478bd9Sstevel@tonic-gate struct tr_mac_frm {
622*7c478bd9Sstevel@tonic-gate 	uchar_t		tr_ac;
623*7c478bd9Sstevel@tonic-gate 	uchar_t		tr_fc;
624*7c478bd9Sstevel@tonic-gate 	mac_addr_t	tr_dhost;
625*7c478bd9Sstevel@tonic-gate 	mac_addr_t	tr_shost;
626*7c478bd9Sstevel@tonic-gate 	struct gld_ri	tr_ri;		/* Routing Information Field */
627*7c478bd9Sstevel@tonic-gate };
628*7c478bd9Sstevel@tonic-gate 
629*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
630*7c478bd9Sstevel@tonic-gate }
631*7c478bd9Sstevel@tonic-gate #endif
632*7c478bd9Sstevel@tonic-gate 
633*7c478bd9Sstevel@tonic-gate #endif /* _SYS_GLDPRIV_H */
634