if_atm.h revision 116523
1/*      $NetBSD: if_atm.h,v 1.7 1996/11/09 23:02:27 chuck Exp $       */
2/* $FreeBSD: head/sys/net/if_atm.h 116523 2003-06-18 10:53:49Z harti $ */
3
4/*
5 *
6 * Copyright (c) 1996 Charles D. Cranor and Washington University.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 *    must display the following acknowledgement:
19 *      This product includes software developed by Charles D. Cranor and
20 *	Washington University.
21 * 4. The name of the author may not be used to endorse or promote products
22 *    derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36/*
37 * net/if_atm.h
38 */
39
40/*
41 * Classification of ATM cards.
42 */
43#define	ATM_DEVICE_UNKNOWN	0
44#define	ATM_DEVICE_PCA200E	1	/* Fore/Marconi PCA200-E */
45#define	ATM_DEVICE_HE155	2	/* Fore/Marconi HE155 */
46#define	ATM_DEVICE_HE622	3	/* Fore/Marconi HE622 */
47#define	ATM_DEVICE_ENI155P	4	/* Efficient networks 155p */
48#define	ATM_DEVICE_ADP155P	5	/* Adaptec 155p */
49#define	ATM_DEVICE_FORELE25	6	/* ForeRunnerLE 25 */
50#define	ATM_DEVICE_FORELE155	7	/* ForeRunnerLE 155 */
51#define	ATM_DEVICE_NICSTAR25	8	/* other 77211 25.6MBit */
52#define	ATM_DEVICE_NICSTAR155	9	/* other 77211 155MBit */
53
54/* map to strings and vendors */
55#define	ATM_DEVICE_NAMES						\
56	{ "Unknown",		"Unknown" },				\
57	{ "PCA200-E",		"Fore/Marconi" },			\
58	{ "HE155",		"Fore/Marconi" },			\
59	{ "HE622",		"Fore/Marconi" },			\
60	{ "ENI155p",		"Efficient Networks" },			\
61	{ "ADP155p",		"Adaptec" },				\
62	{ "ForeRunnerLE25",	"Fore/Marconi" },			\
63	{ "ForeRunnerLE155",	"Fore/Marconi" },			\
64	{ "IDT77211/25",	"IDT" },				\
65	{ "IDT77211/155",	"IDT" },
66
67/*
68 * This is the common link layer MIB for all ATM interfaces. Much of the
69 * information here is needed for ILMI. This will be augmented by statistics
70 * at some point.
71 */
72struct ifatm_mib {
73	/* configuration data */
74	uint8_t		device;		/* type of card */
75	u_char		esi[6];		/* end system identifier (MAC) */
76	uint32_t	serial;		/* card serial number */
77	uint32_t	hw_version;	/* card version */
78	uint32_t	sw_version;	/* firmware version (if any) */
79	uint32_t	pcr;		/* supported peak cell rate */
80	uint32_t	media;		/* physical media */
81	uint8_t		vpi_bits;	/* number of used bits in VPI field */
82	uint8_t		vci_bits;	/* number of used bits in VCI field */
83	uint16_t	max_vpcs;	/* maximum number of VPCs */
84	uint32_t	max_vccs;	/* maximum number of VCCs */
85};
86
87/*
88 * Traffic parameters for ATM connections. This contains all parameters
89 * to accomodate UBR, UBR+MCR, CBR, VBR and ABR connections.
90 *
91 * Keep in sync with ng_atm.h
92 */
93struct atmio_tparam {
94	uint32_t	pcr;	/* 24bit: Peak Cell Rate */
95	uint32_t	scr;	/* 24bit: VBR Sustainable Cell Rate */
96	uint32_t	mbs;	/* 24bit: VBR Maximum burst size */
97	uint32_t	mcr;	/* 24bit: ABR/VBR/UBR+MCR MCR */
98	uint32_t	icr;	/* 24bit: ABR ICR */
99	uint32_t	tbe;	/* 24bit: ABR TBE (1...2^24-1) */
100	uint8_t		nrm;	/*  3bit: ABR Nrm */
101	uint8_t		trm;	/*  3bit: ABR Trm */
102	uint16_t	adtf;	/* 10bit: ABR ADTF */
103	uint8_t		rif;	/*  4bit: ABR RIF */
104	uint8_t		rdf;	/*  4bit: ABR RDF */
105	uint8_t		cdf;	/*  3bit: ABR CDF */
106};
107
108/*
109 * VCC parameters
110 *
111 * Keep in sync with ng_atm.h
112 */
113struct atmio_vcc {
114	uint16_t	flags;		/* VCC flags */
115	uint16_t	vpi;
116	uint16_t	vci;
117	uint16_t	rmtu;		/* maximum receive PDU */
118	uint16_t	tmtu;		/* maximum transmit PDU */
119	uint8_t		aal;		/* aal type */
120	uint8_t		traffic;	/* traffic type */
121	struct atmio_tparam tparam;	/* traffic parameters */
122};
123
124/* VCC flags */
125#define	ATMIO_FLAG_LLCSNAP	0x0002	/* same as ATM_PH_LLCSNAP */
126#define	ATMIO_FLAG_NG		0x0010	/* owned by netgraph */
127#define	ATMIO_FLAG_HARP		0x0020	/* owned by HARP */
128#define	ATMIO_FLAG_NORX		0x0100	/* not receiving on this VCC */
129#define	ATMIO_FLAG_NOTX		0x0200	/* not transmitting on this VCC */
130#define	ATMIO_FLAG_PVC		0x0400	/* this is a PVC */
131#define	ATMIO_FLAGS	"\020\2LLCSNAP\5NG\6HARP\11NORX\12NOTX\13PVC"
132
133#define	ATMIO_AAL_0		0	/* pure cells */
134#define	ATMIO_AAL_34		4	/* AAL3 and 4 */
135#define	ATMIO_AAL_5		5	/* AAL5 */
136#define	ATMIO_AAL_RAW		10	/* whatever the card does */
137
138#define	ATMIO_TRAFFIC_UBR	0
139#define	ATMIO_TRAFFIC_CBR	1
140#define	ATMIO_TRAFFIC_ABR	2
141#define	ATMIO_TRAFFIC_VBR	3
142
143/*
144 * VCC table
145 *
146 * Keep in sync with ng_atm.h
147 */
148struct atmio_vcctable {
149	uint32_t	count;		/* number of vccs */
150	struct atmio_vcc vccs[0];	/* array of VCCs */
151};
152
153/*
154 * Peak cell rates for various physical media. Note, that there are
155 * different opinions on what the correct values are.
156 */
157#define	ATM_RATE_25_6M		59259
158#define	ATM_RATE_155M		353208
159#define	ATM_RATE_622M		1412830
160#define	ATM_RATE_2_4G		5651320
161
162/*
163 * Common fields for all ATM interfaces. Each driver's softc must start with
164 * this structure.
165 */
166struct ifatm {
167	struct ifnet	ifnet;		/* required by if_var.h */
168	struct ifatm_mib mib;		/* exported data */
169	void		*phy;		/* usually SUNI */
170	void		*ngpriv;	/* netgraph link */
171};
172
173/*
174 * Keep structures in sync with ng_atm.h
175 *
176 * These are used by netgraph/harp to call the driver
177 * NATM uses the atm_pseudoioctl instead.
178 */
179struct atmio_openvcc {
180	void		*rxhand;	/* handle argument */
181	struct atmio_vcc param;		/* parameters */
182};
183
184struct atmio_closevcc {
185	uint16_t	vpi;
186	uint16_t	vci;
187};
188
189#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
190#define	RTALLOC1(A,B)		rtalloc1((A),(B))
191#elif defined(__FreeBSD__)
192#define	RTALLOC1(A,B)		rtalloc1((A),(B),0UL)
193#endif
194
195/*
196 * pseudo header for packet transmission
197 */
198struct atm_pseudohdr {
199	uint8_t		atm_ph[4];	/* flags+VPI+VCI1(msb)+VCI2(lsb) */
200};
201
202#define	ATM_PH_FLAGS(X)	((X)->atm_ph[0])
203#define	ATM_PH_VPI(X)	((X)->atm_ph[1])
204#define	ATM_PH_VCI(X)	((((X)->atm_ph[2]) << 8) | ((X)->atm_ph[3]))
205#define	ATM_PH_SETVCI(X,V) { \
206	(X)->atm_ph[2] = ((V) >> 8) & 0xff; \
207	(X)->atm_ph[3] = ((V) & 0xff); \
208}
209
210#define	ATM_PH_AAL5    0x01	/* use AAL5? (0 == aal0) */
211#define	ATM_PH_LLCSNAP 0x02	/* use the LLC SNAP encoding (iff aal5) */
212
213#define	ATM_PH_DRIVER7  0x40	/* reserve for driver's use */
214#define	ATM_PH_DRIVER8  0x80	/* reserve for driver's use */
215
216#define	ATMMTU		9180	/* ATM MTU size for IP */
217				/* XXX: could be 9188 with LLC/SNAP according
218					to comer */
219
220/* user's ioctl hook for raw atm mode */
221#define	SIOCRAWATM	_IOWR('a', 122, int)	/* set driver's raw mode */
222
223/* atm_pseudoioctl: turns on and off RX VCIs  [for internal use only!] */
224struct atm_pseudoioctl {
225	struct atm_pseudohdr aph;
226	void		*rxhand;
227};
228#define	SIOCATMENA	_IOWR('a', 123, struct atm_pseudoioctl) /* enable */
229#define	SIOCATMDIS	_IOWR('a', 124, struct atm_pseudoioctl) /* disable */
230#define	SIOCATMGETVCCS	_IOW('a', 125, struct atmio_vcctable)
231#define	SIOCATMOPENVCC	_IOR('a', 126, struct atmio_openvcc)
232#define	SIOCATMCLOSEVCC _IOR('a', 127, struct atmio_closevcc)
233
234#define	SIOCATMGVCCS	_IOWR('i', 230, struct ifreq)
235
236/*
237 * XXX forget all the garbage in if_llc.h and do it the easy way
238 */
239#define	ATMLLC_HDR "\252\252\3\0\0\0"
240struct atmllc {
241	uint8_t		llchdr[6];	/* aa.aa.03.00.00.00 */
242	uint8_t		type[2];	/* "ethernet" type */
243};
244
245/* ATM_LLC macros: note type code in host byte order */
246#define	ATM_LLC_TYPE(X) (((X)->type[0] << 8) | ((X)->type[1]))
247#define	ATM_LLC_SETTYPE(X, V) do {		\
248	(X)->type[0] = ((V) >> 8) & 0xff;	\
249	(X)->type[1] = ((V) & 0xff);		\
250    } while (0)
251
252#ifdef _KERNEL
253void	atm_ifattach(struct ifnet *);
254void	atm_ifdetach(struct ifnet *);
255void	atm_input(struct ifnet *, struct atm_pseudohdr *,
256	    struct mbuf *, void *);
257int	atm_output(struct ifnet *, struct mbuf *, struct sockaddr *,
258	    struct rtentry *);
259#endif
260