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