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