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