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