xref: /illumos-gate/usr/src/uts/common/sys/llc1.h (revision 2d6eb4a5)
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  * llc1 - an LLC Class 1 MUX compatible with SunConnect LLC2 uses DLPI
24*7c478bd9Sstevel@tonic-gate  * interface.
25*7c478bd9Sstevel@tonic-gate  *
26*7c478bd9Sstevel@tonic-gate  * Copyrighted as an unpublished work.
27*7c478bd9Sstevel@tonic-gate  * Copyright 1992-2002 Sun Microsystems, Inc.  All rights reserved.
28*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
29*7c478bd9Sstevel@tonic-gate  */
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #ifndef _SYS_LLC1_H
32*7c478bd9Sstevel@tonic-gate #define	_SYS_LLC1_H
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
35*7c478bd9Sstevel@tonic-gate extern "C" {
36*7c478bd9Sstevel@tonic-gate #endif
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate struct llc_stats {
39*7c478bd9Sstevel@tonic-gate 	long	llcs_nobuffer;
40*7c478bd9Sstevel@tonic-gate 	long	llcs_multixmt;
41*7c478bd9Sstevel@tonic-gate 	long	llcs_multircv;	/* multicast but note broadcast */
42*7c478bd9Sstevel@tonic-gate 	long	llcs_brdcstxmt;
43*7c478bd9Sstevel@tonic-gate 	long	llcs_brdcstrcv;
44*7c478bd9Sstevel@tonic-gate 	long	llcs_blocked;	/* discard due to upstream being flow */
45*7c478bd9Sstevel@tonic-gate 				/* controlled */
46*7c478bd9Sstevel@tonic-gate 	long	llcs_pktxmt;
47*7c478bd9Sstevel@tonic-gate 	long	llcs_pktrcv;
48*7c478bd9Sstevel@tonic-gate 	long	llcs_bytexmt;
49*7c478bd9Sstevel@tonic-gate 	long	llcs_bytercv;
50*7c478bd9Sstevel@tonic-gate 	long	llcs_xidxmt;
51*7c478bd9Sstevel@tonic-gate 	long	llcs_xidrcv;
52*7c478bd9Sstevel@tonic-gate 	long	llcs_testxmt;
53*7c478bd9Sstevel@tonic-gate 	long	llcs_testrcv;
54*7c478bd9Sstevel@tonic-gate 	long	llcs_ierrors;
55*7c478bd9Sstevel@tonic-gate 	long	llcs_oerrors;
56*7c478bd9Sstevel@tonic-gate };
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate #define	LLCS_NOBUFFER	0
59*7c478bd9Sstevel@tonic-gate #define	LLCS_MULTIXMT	1
60*7c478bd9Sstevel@tonic-gate #define	LLCS_MULTIRCV	2
61*7c478bd9Sstevel@tonic-gate #define	LLCS_BRDCSTXMT	3
62*7c478bd9Sstevel@tonic-gate #define	LLCS_BRDCSTRCV	4
63*7c478bd9Sstevel@tonic-gate #define	LLCS_BLOCKED	5
64*7c478bd9Sstevel@tonic-gate #define	LLCS_PKTXMT	6
65*7c478bd9Sstevel@tonic-gate #define	LLCS_PKTRCV	7
66*7c478bd9Sstevel@tonic-gate #define	LLCS_BYTEXMT	8
67*7c478bd9Sstevel@tonic-gate #define	LLCS_BYTERCV	9
68*7c478bd9Sstevel@tonic-gate #define	LLCS_XIDXMT	10
69*7c478bd9Sstevel@tonic-gate #define	LLCS_XIDRCV	11
70*7c478bd9Sstevel@tonic-gate #define	LLCS_TESTXMT	12
71*7c478bd9Sstevel@tonic-gate #define	LLCS_TESTRCV	13
72*7c478bd9Sstevel@tonic-gate #define	LLCS_IERRORS	14
73*7c478bd9Sstevel@tonic-gate #define	LLCS_OERRORS	15
74*7c478bd9Sstevel@tonic-gate 
75*7c478bd9Sstevel@tonic-gate /* multicast structures */
76*7c478bd9Sstevel@tonic-gate typedef struct llc1_multicast_addr {
77*7c478bd9Sstevel@tonic-gate 	int		llcm_refcnt;	/* number of streams referring to */
78*7c478bd9Sstevel@tonic-gate 					/* entry */
79*7c478bd9Sstevel@tonic-gate 	unsigned char	llcm_addr[ETHERADDRL];
80*7c478bd9Sstevel@tonic-gate } llc_mcast_t;
81*7c478bd9Sstevel@tonic-gate #define	LLC1_MAX_MULTICAST	16	/* default max multicast table size */
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate typedef
84*7c478bd9Sstevel@tonic-gate struct llc_mac_info {
85*7c478bd9Sstevel@tonic-gate 	struct llc_mac_info *llcp_next, *llcp_prev;
86*7c478bd9Sstevel@tonic-gate 	long		llcp_flags;
87*7c478bd9Sstevel@tonic-gate 	long		llcp_maxpkt;
88*7c478bd9Sstevel@tonic-gate 	long		llcp_minpkt;
89*7c478bd9Sstevel@tonic-gate 	long		llcp_type;
90*7c478bd9Sstevel@tonic-gate 	long		llcp_addrlen;	/* usually 6 but could be 2 */
91*7c478bd9Sstevel@tonic-gate 	unsigned char	llcp_macaddr[ETHERADDRL];
92*7c478bd9Sstevel@tonic-gate 	unsigned char	llcp_broadcast[ETHERADDRL];
93*7c478bd9Sstevel@tonic-gate 	queue_t		*llcp_queue;	/* queue to MAC device */
94*7c478bd9Sstevel@tonic-gate 	long		llcp_lindex;	/* link index for unlink */
95*7c478bd9Sstevel@tonic-gate 	long		llcp_ppa;	/* the PPA number */
96*7c478bd9Sstevel@tonic-gate 	long		llcp_sap;	/* when doing auto bind on lower */
97*7c478bd9Sstevel@tonic-gate 					/* stream */
98*7c478bd9Sstevel@tonic-gate 	mblk_t		*llcp_data;	/* temporarily hold data */
99*7c478bd9Sstevel@tonic-gate 	queue_t		*llcp_lqtop;	/* queue for ioctls */
100*7c478bd9Sstevel@tonic-gate 	mblk_t		*llcp_mb;
101*7c478bd9Sstevel@tonic-gate 	long		llcp_nstreams;
102*7c478bd9Sstevel@tonic-gate 	llc_mcast_t	*llcp_mcast;	/* per device multicast table */
103*7c478bd9Sstevel@tonic-gate 	struct llc_stats llcp_stats;
104*7c478bd9Sstevel@tonic-gate 	kstat_t		*llcp_kstatp;
105*7c478bd9Sstevel@tonic-gate 	uint_t		llcp_iocid;	/* outstanding ioc_id */
106*7c478bd9Sstevel@tonic-gate } llc_mac_info_t;
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate /* flags for mac info (link) status */
109*7c478bd9Sstevel@tonic-gate #define	LLC1_LINKED	0x0001	/* there is a stream linked but not ready */
110*7c478bd9Sstevel@tonic-gate #define	LLC1_AVAILABLE	0x0002	/* linked stream is now ready */
111*7c478bd9Sstevel@tonic-gate #define	LLC1_INFO_WAIT	0x0004	/* waiting on info_ack */
112*7c478bd9Sstevel@tonic-gate #define	LLC1_DEF_PPA	0x0008	/* default (system assigned PPA) */
113*7c478bd9Sstevel@tonic-gate #define	LLC1_RAW_WAIT	0x0010	/* waiting for DLIOCRAW to happen */
114*7c478bd9Sstevel@tonic-gate #define	LLC1_USING_RAW	0x0020	/* lower driver is using DLIOCRAW mode */
115*7c478bd9Sstevel@tonic-gate #define	LLC1_AUTO_XID	0x0040	/* automatically respond to XID */
116*7c478bd9Sstevel@tonic-gate #define	LLC1_AUTO_TEST	0x0080	/* automatically respond to TEST */
117*7c478bd9Sstevel@tonic-gate #define	LLC1_BINDING	0x0100	/* autmatically binding the lower stream */
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate typedef struct llc1 {
120*7c478bd9Sstevel@tonic-gate 	struct llc1	*llc_next, *llc_prev;
121*7c478bd9Sstevel@tonic-gate 	mblk_t		*llc_mb;
122*7c478bd9Sstevel@tonic-gate 	long		llc_state;
123*7c478bd9Sstevel@tonic-gate 	long		llc_style;
124*7c478bd9Sstevel@tonic-gate 	long		llc_minor;
125*7c478bd9Sstevel@tonic-gate 	long		llc_type;
126*7c478bd9Sstevel@tonic-gate 	long		llc_sap;
127*7c478bd9Sstevel@tonic-gate 	uchar_t		llc_snap[5];	/* SNAP header */
128*7c478bd9Sstevel@tonic-gate 	long		llc_waiting_for;	/* DL request to lower layer */
129*7c478bd9Sstevel@tonic-gate 	long		llc_flags;	/* flags used for controlling things */
130*7c478bd9Sstevel@tonic-gate 	long		llc_multicnt;	/* number of multicast addresses for */
131*7c478bd9Sstevel@tonic-gate 					/* stream */
132*7c478bd9Sstevel@tonic-gate 	llc_mcast_t	**llc_mcast;	/* multicast table if multicast is */
133*7c478bd9Sstevel@tonic-gate 					/* enabled */
134*7c478bd9Sstevel@tonic-gate 	queue_t		*llc_qptr;
135*7c478bd9Sstevel@tonic-gate 	kmutex_t	llc_lock;
136*7c478bd9Sstevel@tonic-gate 	struct llc_mac_info *llc_mac_info;
137*7c478bd9Sstevel@tonic-gate 	struct llc_stats *llc_stats;
138*7c478bd9Sstevel@tonic-gate } llc1_t;
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate /* llc_flag bits */
141*7c478bd9Sstevel@tonic-gate #define	LLC_RAW		0x0001	/* lower stream is in RAW mode */
142*7c478bd9Sstevel@tonic-gate #define	LLC_FAST	0x0002	/* use "fast" path */
143*7c478bd9Sstevel@tonic-gate #define	LLC_PROM	0x0004	/* stream is in physical promiscuous mode */
144*7c478bd9Sstevel@tonic-gate #define	LLC_SNAP	0x0008	/* stream is using SNAP header */
145*7c478bd9Sstevel@tonic-gate #define	LLC_SNAP_OID	0x0010	/* stream is SNAP, OID is defined */
146*7c478bd9Sstevel@tonic-gate 
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate typedef struct llc1device {
149*7c478bd9Sstevel@tonic-gate 	long		llc1_status;
150*7c478bd9Sstevel@tonic-gate 	krwlock_t	llc1_rwlock;	/* used to serialize read/write locks */
151*7c478bd9Sstevel@tonic-gate 	int		llc1_minors;
152*7c478bd9Sstevel@tonic-gate 	int		llc1_multisize;
153*7c478bd9Sstevel@tonic-gate 	llc_mac_info_t	*llc1_mac_next, *llc1_mac_prev;	/* the various mac */
154*7c478bd9Sstevel@tonic-gate 							/* layers */
155*7c478bd9Sstevel@tonic-gate 	int		llc1_ndevice;	/* number of devices linked */
156*7c478bd9Sstevel@tonic-gate 	int		llc1_nextppa;	/* number to use for next PPA default */
157*7c478bd9Sstevel@tonic-gate 	llc1_t		*llc1_str_next, *llc1_str_prev;	/* open streams */
158*7c478bd9Sstevel@tonic-gate } llc1dev_t;
159*7c478bd9Sstevel@tonic-gate 
160*7c478bd9Sstevel@tonic-gate #define	LLC1_ATTACHED	0x0001	/* board is attached so mutexes are */
161*7c478bd9Sstevel@tonic-gate 				/* initialized */
162*7c478bd9Sstevel@tonic-gate 
163*7c478bd9Sstevel@tonic-gate 
164*7c478bd9Sstevel@tonic-gate /*
165*7c478bd9Sstevel@tonic-gate  * definitions for debug tracing
166*7c478bd9Sstevel@tonic-gate  */
167*7c478bd9Sstevel@tonic-gate #define	LLCTRACE	0x0001	/* basic procedure level tracing */
168*7c478bd9Sstevel@tonic-gate #define	LLCERRS		0x0002	/* trace errors */
169*7c478bd9Sstevel@tonic-gate #define	LLCRECV		0x0004	/* trace receive path */
170*7c478bd9Sstevel@tonic-gate #define	LLCSEND		0x0008	/* trace send path */
171*7c478bd9Sstevel@tonic-gate #define	LLCPROT		0x0010	/* trace DLPI protocol */
172*7c478bd9Sstevel@tonic-gate 
173*7c478bd9Sstevel@tonic-gate /*
174*7c478bd9Sstevel@tonic-gate  * other definitions
175*7c478bd9Sstevel@tonic-gate  */
176*7c478bd9Sstevel@tonic-gate #define	LLCE_OK		-1	/* internal procedure status is OK */
177*7c478bd9Sstevel@tonic-gate #define	LLCE_NOBUFFER	0x1001	/* couldn't allocate a buffer */
178*7c478bd9Sstevel@tonic-gate 
179*7c478bd9Sstevel@tonic-gate 
180*7c478bd9Sstevel@tonic-gate /*
181*7c478bd9Sstevel@tonic-gate  * definitions for module_info
182*7c478bd9Sstevel@tonic-gate  */
183*7c478bd9Sstevel@tonic-gate #define	LLC1IDNUM	0x8022
184*7c478bd9Sstevel@tonic-gate #define	LLC1_HIWATER	32000	/* high water mark for flow control */
185*7c478bd9Sstevel@tonic-gate #define	LLC1_LOWATER	4096	/* low water mark for flow control */
186*7c478bd9Sstevel@tonic-gate #define	LLC1_DEFMAX	4096	/* default max packet size */
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate /* address format for unitdata */
189*7c478bd9Sstevel@tonic-gate 
190*7c478bd9Sstevel@tonic-gate struct llcaddr {
191*7c478bd9Sstevel@tonic-gate 	unsigned char   llca_addr[ETHERADDRL];
192*7c478bd9Sstevel@tonic-gate 	unsigned char   llca_sap;
193*7c478bd9Sstevel@tonic-gate };
194*7c478bd9Sstevel@tonic-gate #define	LLCADDR(p, offset) ((struct llcaddr *)(((caddr_t)(p))+(offset)))
195*7c478bd9Sstevel@tonic-gate 
196*7c478bd9Sstevel@tonic-gate struct llcsaddr {
197*7c478bd9Sstevel@tonic-gate 	unsigned char   llca_saddr[ETHERADDRL];
198*7c478bd9Sstevel@tonic-gate 	unsigned short  llca_ssap;
199*7c478bd9Sstevel@tonic-gate };
200*7c478bd9Sstevel@tonic-gate #define	LLCSADDR(p, offset) ((struct llcsaddr *)(((caddr_t)(p))+(offset)))
201*7c478bd9Sstevel@tonic-gate 
202*7c478bd9Sstevel@tonic-gate /*
203*7c478bd9Sstevel@tonic-gate  * 802.2 specific declarations
204*7c478bd9Sstevel@tonic-gate  */
205*7c478bd9Sstevel@tonic-gate struct llchdr {
206*7c478bd9Sstevel@tonic-gate 	unsigned char   llc_dsap;
207*7c478bd9Sstevel@tonic-gate 	unsigned char   llc_ssap;
208*7c478bd9Sstevel@tonic-gate 	unsigned char   llc_ctl;
209*7c478bd9Sstevel@tonic-gate };
210*7c478bd9Sstevel@tonic-gate struct llchdr_xid {
211*7c478bd9Sstevel@tonic-gate 	unsigned char   llcx_format;
212*7c478bd9Sstevel@tonic-gate 	unsigned char   llcx_class;
213*7c478bd9Sstevel@tonic-gate 	unsigned char   llcx_window;
214*7c478bd9Sstevel@tonic-gate };
215*7c478bd9Sstevel@tonic-gate struct snaphdr {
216*7c478bd9Sstevel@tonic-gate 	uchar_t		snap_oid[3];
217*7c478bd9Sstevel@tonic-gate 	uchar_t		snap_type[2];
218*7c478bd9Sstevel@tonic-gate };
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate #define	LLC_UI		0x3
221*7c478bd9Sstevel@tonic-gate #define	LLC_XID 	0xAF
222*7c478bd9Sstevel@tonic-gate #define	LLC_TEST	0xE3
223*7c478bd9Sstevel@tonic-gate #define	LLC_P		0x10	/* P bit for use with XID/TEST */
224*7c478bd9Sstevel@tonic-gate #define	LLC_XID_FMTID	0x81	/* XID format identifier */
225*7c478bd9Sstevel@tonic-gate #define	LLC_SERVICES	0x01	/* Services supported */
226*7c478bd9Sstevel@tonic-gate #define	LLC_GLOBAL_SAP	0XFF	/* Global SAP address */
227*7c478bd9Sstevel@tonic-gate #define	LLC_NULL_SAP	0x00
228*7c478bd9Sstevel@tonic-gate #define	LLC_SNAP_SAP	0xAA	/* SNAP SAP */
229*7c478bd9Sstevel@tonic-gate #define	LLC_GROUP_ADDR	0x01	/* indication in DSAP of a group address */
230*7c478bd9Sstevel@tonic-gate #define	LLC_RESPONSE	0x01	/* indication in SSAP of a response */
231*7c478bd9Sstevel@tonic-gate #define	LLC_NOVELL_SAP	-1	/* indicator that Novell 802.3 mode is used */
232*7c478bd9Sstevel@tonic-gate 
233*7c478bd9Sstevel@tonic-gate #define	LLC_XID_INFO_SIZE	3	/* length of the INFO field */
234*7c478bd9Sstevel@tonic-gate #define	LLC_XID_CLASS_I		(0x01)	/* Class I */
235*7c478bd9Sstevel@tonic-gate #define	LLC_XID_CLASS_II	(0x03)	/* Class II */
236*7c478bd9Sstevel@tonic-gate #define	LLC_XID_CLASS_III	(0x05)	/* Class III */
237*7c478bd9Sstevel@tonic-gate #define	LLC_XID_CLASS_IV	(0x07)	/* Class IV */
238*7c478bd9Sstevel@tonic-gate 
239*7c478bd9Sstevel@tonic-gate /* Types can be or'd together */
240*7c478bd9Sstevel@tonic-gate #define	LLC_XID_TYPE_1		(0x01)	/* Type 1 */
241*7c478bd9Sstevel@tonic-gate #define	LLC_XID_TYPE_2		(0x02)	/* Type 2 */
242*7c478bd9Sstevel@tonic-gate #define	LLC_XID_TYPE_3		(0x04)	/* Type 3 */
243*7c478bd9Sstevel@tonic-gate 
244*7c478bd9Sstevel@tonic-gate #define	LLC1_CSMACD_HDR_SIZE	(2*ETHERADDRL+2)
245*7c478bd9Sstevel@tonic-gate 
246*7c478bd9Sstevel@tonic-gate #define	ismulticast(cp) ((*(caddr_t)(cp)) & 0x01)
247*7c478bd9Sstevel@tonic-gate 
248*7c478bd9Sstevel@tonic-gate /*
249*7c478bd9Sstevel@tonic-gate  * special ioctl calls for SunSelect LLC2 conformance
250*7c478bd9Sstevel@tonic-gate  */
251*7c478bd9Sstevel@tonic-gate #define	L_GETPPA	(('L'<<8)|1)
252*7c478bd9Sstevel@tonic-gate #define	L_SETPPA	(('L'<<8)|2)
253*7c478bd9Sstevel@tonic-gate #define	L_GETSTATS	(('L'<<8)|5)
254*7c478bd9Sstevel@tonic-gate #define	L_ZEROSTATS	(('L'<<8)|6)
255*7c478bd9Sstevel@tonic-gate 
256*7c478bd9Sstevel@tonic-gate #define	LI_SPPA		0x02	/* type of snioc structure */
257*7c478bd9Sstevel@tonic-gate 
258*7c478bd9Sstevel@tonic-gate struct ll_snioc {
259*7c478bd9Sstevel@tonic-gate 	uchar_t		lli_type;
260*7c478bd9Sstevel@tonic-gate 	uchar_t		lli_spare[3];
261*7c478bd9Sstevel@tonic-gate 	int		lli_ppa;
262*7c478bd9Sstevel@tonic-gate 	int		lli_index;
263*7c478bd9Sstevel@tonic-gate };
264*7c478bd9Sstevel@tonic-gate 
265*7c478bd9Sstevel@tonic-gate /*
266*7c478bd9Sstevel@tonic-gate  * version of insque/remque for use by this driver
267*7c478bd9Sstevel@tonic-gate  */
268*7c478bd9Sstevel@tonic-gate struct qelem {
269*7c478bd9Sstevel@tonic-gate 	struct qelem   *q_forw;
270*7c478bd9Sstevel@tonic-gate 	struct qelem   *q_back;
271*7c478bd9Sstevel@tonic-gate 	/* rest of structure */
272*7c478bd9Sstevel@tonic-gate };
273*7c478bd9Sstevel@tonic-gate 
274*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
275*7c478bd9Sstevel@tonic-gate }
276*7c478bd9Sstevel@tonic-gate #endif
277*7c478bd9Sstevel@tonic-gate 
278*7c478bd9Sstevel@tonic-gate #endif /* _SYS_LLC1_H */
279