if_atm.h revision 117721
1186121Skmacy/*      $NetBSD: if_atm.h,v 1.7 1996/11/09 23:02:27 chuck Exp $       */
2186121Skmacy/* $FreeBSD: head/sys/net/if_atm.h 117721 2003-07-18 08:40:45Z harti $ */
3186121Skmacy
4186121Skmacy/*
5186121Skmacy *
6186121Skmacy * Copyright (c) 1996 Charles D. Cranor and Washington University.
7186121Skmacy * All rights reserved.
8186121Skmacy *
9186121Skmacy * Redistribution and use in source and binary forms, with or without
10186121Skmacy * modification, are permitted provided that the following conditions
11186121Skmacy * are met:
12186121Skmacy * 1. Redistributions of source code must retain the above copyright
13186121Skmacy *    notice, this list of conditions and the following disclaimer.
14186121Skmacy * 2. Redistributions in binary form must reproduce the above copyright
15186121Skmacy *    notice, this list of conditions and the following disclaimer in the
16186121Skmacy *    documentation and/or other materials provided with the distribution.
17186121Skmacy * 3. All advertising materials mentioning features or use of this software
18186121Skmacy *    must display the following acknowledgement:
19186121Skmacy *      This product includes software developed by Charles D. Cranor and
20186121Skmacy *	Washington University.
21186121Skmacy * 4. The name of the author may not be used to endorse or promote products
22186121Skmacy *    derived from this software without specific prior written permission.
23186121Skmacy *
24186121Skmacy * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25186121Skmacy * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26186121Skmacy * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27186121Skmacy * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28186121Skmacy * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29186121Skmacy * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30186121Skmacy * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31186121Skmacy * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32186121Skmacy * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33219819Sjeff * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34219819Sjeff */
35186121Skmacy
36186121Skmacy/*
37186121Skmacy * net/if_atm.h
38186121Skmacy */
39186121Skmacy
40186121Skmacy/*
41186121Skmacy * Classification of ATM cards.
42186121Skmacy */
43186121Skmacy#define	ATM_DEVICE_UNKNOWN	0
44186121Skmacy#define	ATM_DEVICE_PCA200E	1	/* Fore/Marconi PCA200-E */
45186121Skmacy#define	ATM_DEVICE_HE155	2	/* Fore/Marconi HE155 */
46196535Srwatson#define	ATM_DEVICE_HE622	3	/* Fore/Marconi HE622 */
47196535Srwatson#define	ATM_DEVICE_ENI155P	4	/* Efficient networks 155p */
48196535Srwatson#define	ATM_DEVICE_ADP155P	5	/* Adaptec 155p */
49196535Srwatson#define	ATM_DEVICE_FORELE25	6	/* ForeRunnerLE 25 */
50196535Srwatson#define	ATM_DEVICE_FORELE155	7	/* ForeRunnerLE 155 */
51196535Srwatson#define	ATM_DEVICE_NICSTAR25	8	/* other 77211 25.6MBit */
52196535Srwatson#define	ATM_DEVICE_NICSTAR155	9	/* other 77211 155MBit */
53186121Skmacy#define	ATM_DEVICE_IDTABR25	10	/* 77252 based card 25MBit */
54186121Skmacy#define	ATM_DEVICE_IDTABR155	11	/* 77252 based card 155MBit */
55186121Skmacy#define	ATM_DEVICE_PROATM25	12	/* 77252 based ProSum card 25MBit */
56186121Skmacy#define	ATM_DEVICE_PROATM155	13	/* 77252 based ProSum card 155MBit */
57186121Skmacy
58186121Skmacy/* map to strings and vendors */
59186121Skmacy#define	ATM_DEVICE_NAMES						\
60186121Skmacy	{ "Unknown",		"Unknown" },				\
61186121Skmacy	{ "PCA200-E",		"Fore/Marconi" },			\
62186121Skmacy	{ "HE155",		"Fore/Marconi" },			\
63215207Sgnn	{ "HE622",		"Fore/Marconi" },			\
64186121Skmacy	{ "ENI155p",		"Efficient Networks" },			\
65186121Skmacy	{ "ADP155p",		"Adaptec" },				\
66186121Skmacy	{ "ForeRunnerLE25",	"Fore/Marconi" },			\
67186121Skmacy	{ "ForeRunnerLE155",	"Fore/Marconi" },			\
68186121Skmacy	{ "IDT77211/25",	"IDT" },				\
69186121Skmacy	{ "IDT77211/155",	"IDT" },				\
70186121Skmacy	{ "IDT77252/25",	"IDT" },				\
71186121Skmacy	{ "IDT77252/155",	"IDT" },				\
72186121Skmacy	{ "ProATM/25",		"ProSum" },				\
73186121Skmacy	{ "ProATM/155",		"ProSum" },
74186121Skmacy
75186121Skmacy/*
76186121Skmacy * This is the common link layer MIB for all ATM interfaces. Much of the
77219819Sjeff * information here is needed for ILMI. This will be augmented by statistics
78219819Sjeff * at some point.
79219819Sjeff */
80186121Skmacystruct ifatm_mib {
81186121Skmacy	/* configuration data */
82186121Skmacy	uint8_t		device;		/* type of card */
83186121Skmacy	u_char		esi[6];		/* end system identifier (MAC) */
84186121Skmacy	uint32_t	serial;		/* card serial number */
85186121Skmacy	uint32_t	hw_version;	/* card version */
86186121Skmacy	uint32_t	sw_version;	/* firmware version (if any) */
87186121Skmacy	uint32_t	pcr;		/* supported peak cell rate */
88186121Skmacy	uint32_t	media;		/* physical media */
89186121Skmacy	uint8_t		vpi_bits;	/* number of used bits in VPI field */
90186121Skmacy	uint8_t		vci_bits;	/* number of used bits in VCI field */
91186121Skmacy	uint16_t	max_vpcs;	/* maximum number of VPCs */
92186121Skmacy	uint32_t	max_vccs;	/* maximum number of VCCs */
93186121Skmacy};
94186121Skmacy
95186121Skmacy/*
96186121Skmacy * Traffic parameters for ATM connections. This contains all parameters
97186149Skmacy * to accomodate UBR, UBR+MCR, CBR, VBR and ABR connections.
98186121Skmacy *
99186121Skmacy * Keep in sync with ng_atm.h
100186121Skmacy */
101186121Skmacystruct atmio_tparam {
102186121Skmacy	uint32_t	pcr;	/* 24bit: Peak Cell Rate */
103186121Skmacy	uint32_t	scr;	/* 24bit: VBR Sustainable Cell Rate */
104186121Skmacy	uint32_t	mbs;	/* 24bit: VBR Maximum burst size */
105186121Skmacy	uint32_t	mcr;	/* 24bit: ABR/VBR/UBR+MCR MCR */
106186121Skmacy	uint32_t	icr;	/* 24bit: ABR ICR */
107186121Skmacy	uint32_t	tbe;	/* 24bit: ABR TBE (1...2^24-1) */
108186121Skmacy	uint8_t		nrm;	/*  3bit: ABR Nrm */
109186121Skmacy	uint8_t		trm;	/*  3bit: ABR Trm */
110186121Skmacy	uint16_t	adtf;	/* 10bit: ABR ADTF */
111186121Skmacy	uint8_t		rif;	/*  4bit: ABR RIF */
112186121Skmacy	uint8_t		rdf;	/*  4bit: ABR RDF */
113186121Skmacy	uint8_t		cdf;	/*  3bit: ABR CDF */
114186121Skmacy};
115186121Skmacy
116186121Skmacy/*
117186121Skmacy * VCC parameters
118186121Skmacy *
119186121Skmacy * Keep in sync with ng_atm.h
120186121Skmacy */
121186121Skmacystruct atmio_vcc {
122186121Skmacy	uint16_t	flags;		/* VCC flags */
123186121Skmacy	uint16_t	vpi;
124216859Sbz	uint16_t	vci;
125186121Skmacy	uint16_t	rmtu;		/* maximum receive PDU */
126186121Skmacy	uint16_t	tmtu;		/* maximum transmit PDU */
127186121Skmacy	uint8_t		aal;		/* aal type */
128186121Skmacy	uint8_t		traffic;	/* traffic type */
129216859Sbz	struct atmio_tparam tparam;	/* traffic parameters */
130186121Skmacy};
131186121Skmacy
132186121Skmacy/* VCC flags */
133186121Skmacy#define	ATMIO_FLAG_LLCSNAP	0x0002	/* same as ATM_PH_LLCSNAP */
134186121Skmacy#define	ATMIO_FLAG_NG		0x0010	/* owned by netgraph */
135186121Skmacy#define	ATMIO_FLAG_HARP		0x0020	/* owned by HARP */
136186121Skmacy#define	ATMIO_FLAG_NORX		0x0100	/* not receiving on this VCC */
137186121Skmacy#define	ATMIO_FLAG_NOTX		0x0200	/* not transmitting on this VCC */
138186121Skmacy#define	ATMIO_FLAG_PVC		0x0400	/* this is a PVC */
139186121Skmacy#define	ATMIO_FLAGS	"\020\2LLCSNAP\5NG\6HARP\11NORX\12NOTX\13PVC"
140186121Skmacy
141186121Skmacy#define	ATMIO_AAL_0		0	/* pure cells */
142186121Skmacy#define	ATMIO_AAL_34		4	/* AAL3 and 4 */
143186121Skmacy#define	ATMIO_AAL_5		5	/* AAL5 */
144186121Skmacy#define	ATMIO_AAL_RAW		10	/* whatever the card does */
145186121Skmacy
146186121Skmacy#define	ATMIO_TRAFFIC_UBR	0
147186121Skmacy#define	ATMIO_TRAFFIC_CBR	1
148186121Skmacy#define	ATMIO_TRAFFIC_ABR	2
149186121Skmacy#define	ATMIO_TRAFFIC_VBR	3
150186121Skmacy
151186121Skmacy/*
152186121Skmacy * VCC table
153186121Skmacy *
154186121Skmacy * Keep in sync with ng_atm.h
155186121Skmacy */
156192476Sqinglistruct atmio_vcctable {
157192476Sqingli	uint32_t	count;		/* number of vccs */
158192476Sqingli	struct atmio_vcc vccs[0];	/* array of VCCs */
159186121Skmacy};
160186121Skmacy
161201282Sqingli/*
162186121Skmacy * Peak cell rates for various physical media. Note, that there are
163186121Skmacy * different opinions on what the correct values are.
164186121Skmacy */
165186121Skmacy#define	ATM_RATE_25_6M		59259
166186121Skmacy#define	ATM_RATE_155M		353208
167186121Skmacy#define	ATM_RATE_622M		1412830
168186121Skmacy#define	ATM_RATE_2_4G		5651320
169186121Skmacy
170186121Skmacy#ifdef _KERNEL
171186121Skmacy/*
172186121Skmacy * Common fields for all ATM interfaces. Each driver's softc must start with
173186121Skmacy * this structure.
174186121Skmacy */
175186121Skmacystruct ifatm {
176186121Skmacy	struct ifnet	ifnet;		/* required by if_var.h */
177186121Skmacy	struct ifatm_mib mib;		/* exported data */
178186121Skmacy	void		*phy;		/* usually SUNI */
179186121Skmacy	void		*ngpriv;	/* netgraph link */
180186121Skmacy};
181186121Skmacy#endif
182186121Skmacy
183186121Skmacy/*
184186121Skmacy * Keep structures in sync with ng_atm.h
185186121Skmacy *
186192476Sqingli * These are used by netgraph/harp to call the driver
187192476Sqingli * NATM uses the atm_pseudoioctl instead.
188213929Sbz */
189186121Skmacystruct atmio_openvcc {
190213929Sbz	void		*rxhand;	/* handle argument */
191186121Skmacy	struct atmio_vcc param;		/* parameters */
192186121Skmacy};
193215207Sgnn
194191154Skmacystruct atmio_closevcc {
195205066Skmacy	uint16_t	vpi;
196186121Skmacy	uint16_t	vci;
197186121Skmacy};
198186121Skmacy
199186121Skmacy#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
200186121Skmacy#define	RTALLOC1(A,B)		rtalloc1((A),(B))
201186121Skmacy#elif defined(__FreeBSD__)
202186121Skmacy#define	RTALLOC1(A,B)		rtalloc1((A),(B),0UL)
203186121Skmacy#endif
204186121Skmacy
205186121Skmacy/*
206186121Skmacy * pseudo header for packet transmission
207186121Skmacy */
208struct atm_pseudohdr {
209	uint8_t		atm_ph[4];	/* flags+VPI+VCI1(msb)+VCI2(lsb) */
210};
211
212#define	ATM_PH_FLAGS(X)	((X)->atm_ph[0])
213#define	ATM_PH_VPI(X)	((X)->atm_ph[1])
214#define	ATM_PH_VCI(X)	((((X)->atm_ph[2]) << 8) | ((X)->atm_ph[3]))
215#define	ATM_PH_SETVCI(X,V) { \
216	(X)->atm_ph[2] = ((V) >> 8) & 0xff; \
217	(X)->atm_ph[3] = ((V) & 0xff); \
218}
219
220/* use AAL5? (0 == aal0) */
221#define	ATM_PH_AAL5    0x01
222/* use the LLC SNAP encoding (iff aal5) */
223#define	ATM_PH_LLCSNAP ATMIO_FLAG_LLCSNAP
224
225#define	ATM_PH_DRIVER7  0x40	/* reserve for driver's use */
226#define	ATM_PH_DRIVER8  0x80	/* reserve for driver's use */
227
228#define	ATMMTU		9180	/* ATM MTU size for IP */
229				/* XXX: could be 9188 with LLC/SNAP according
230					to comer */
231
232/* user's ioctl hook for raw atm mode */
233#define	SIOCRAWATM	_IOWR('a', 122, int)	/* set driver's raw mode */
234
235/* atm_pseudoioctl: turns on and off RX VCIs  [for internal use only!] */
236struct atm_pseudoioctl {
237	struct atm_pseudohdr aph;
238	void		*rxhand;
239};
240#define	SIOCATMENA	_IOWR('a', 123, struct atm_pseudoioctl) /* enable */
241#define	SIOCATMDIS	_IOWR('a', 124, struct atm_pseudoioctl) /* disable */
242#define	SIOCATMGETVCCS	_IOW('a', 125, struct atmio_vcctable)
243#define	SIOCATMOPENVCC	_IOR('a', 126, struct atmio_openvcc)
244#define	SIOCATMCLOSEVCC _IOR('a', 127, struct atmio_closevcc)
245
246#define	SIOCATMGVCCS	_IOWR('i', 230, struct ifreq)
247
248/*
249 * XXX forget all the garbage in if_llc.h and do it the easy way
250 */
251#define	ATMLLC_HDR "\252\252\3\0\0\0"
252struct atmllc {
253	uint8_t		llchdr[6];	/* aa.aa.03.00.00.00 */
254	uint8_t		type[2];	/* "ethernet" type */
255};
256
257/* ATM_LLC macros: note type code in host byte order */
258#define	ATM_LLC_TYPE(X) (((X)->type[0] << 8) | ((X)->type[1]))
259#define	ATM_LLC_SETTYPE(X, V) do {		\
260	(X)->type[0] = ((V) >> 8) & 0xff;	\
261	(X)->type[1] = ((V) & 0xff);		\
262    } while (0)
263
264#ifdef _KERNEL
265void	atm_ifattach(struct ifnet *);
266void	atm_ifdetach(struct ifnet *);
267void	atm_input(struct ifnet *, struct atm_pseudohdr *,
268	    struct mbuf *, void *);
269int	atm_output(struct ifnet *, struct mbuf *, struct sockaddr *,
270	    struct rtentry *);
271struct atmio_vcctable *atm_getvccs(struct atmio_vcc **, u_int, u_int,
272	    struct mtx *, int);
273#endif
274