FreeBSD/Linux Kernel Cross Reference
sys/net/if_atm.h
1 /* $NetBSD: if_atm.h,v 1.7 1996/11/09 23:02:27 chuck Exp $ */
2 /* $FreeBSD: releng/5.2/sys/net/if_atm.h 118548 2003-08-06 14:53:27Z 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 #define ATM_DEVICE_IDTABR25 10 /* 77252 based card 25MBit */
54 #define ATM_DEVICE_IDTABR155 11 /* 77252 based card 155MBit */
55 #define ATM_DEVICE_PROATM25 12 /* 77252 based ProSum card 25MBit */
56 #define ATM_DEVICE_PROATM155 13 /* 77252 based ProSum card 155MBit */
57
58 /* map to strings and vendors */
59 #define ATM_DEVICE_NAMES \
60 { "Unknown", "Unknown" }, \
61 { "PCA200-E", "Fore/Marconi" }, \
62 { "HE155", "Fore/Marconi" }, \
63 { "HE622", "Fore/Marconi" }, \
64 { "ENI155p", "Efficient Networks" }, \
65 { "ADP155p", "Adaptec" }, \
66 { "ForeRunnerLE25", "Fore/Marconi" }, \
67 { "ForeRunnerLE155", "Fore/Marconi" }, \
68 { "IDT77211/25", "IDT" }, \
69 { "IDT77211/155", "IDT" }, \
70 { "IDT77252/25", "IDT" }, \
71 { "IDT77252/155", "IDT" }, \
72 { "ProATM/25", "ProSum" }, \
73 { "ProATM/155", "ProSum" },
74
75 /*
76 * This is the common link layer MIB for all ATM interfaces. Much of the
77 * information here is needed for ILMI. This will be augmented by statistics
78 * at some point.
79 */
80 struct ifatm_mib {
81 /* configuration data */
82 uint8_t device; /* type of card */
83 u_char esi[6]; /* end system identifier (MAC) */
84 uint32_t serial; /* card serial number */
85 uint32_t hw_version; /* card version */
86 uint32_t sw_version; /* firmware version (if any) */
87 uint32_t pcr; /* supported peak cell rate */
88 uint32_t media; /* physical media */
89 uint8_t vpi_bits; /* number of used bits in VPI field */
90 uint8_t vci_bits; /* number of used bits in VCI field */
91 uint16_t max_vpcs; /* maximum number of VPCs */
92 uint32_t max_vccs; /* maximum number of VCCs */
93 };
94
95 /*
96 * Traffic parameters for ATM connections. This contains all parameters
97 * to accomodate UBR, UBR+MCR, CBR, VBR and ABR connections.
98 *
99 * Keep in sync with ng_atm.h
100 */
101 struct atmio_tparam {
102 uint32_t pcr; /* 24bit: Peak Cell Rate */
103 uint32_t scr; /* 24bit: VBR Sustainable Cell Rate */
104 uint32_t mbs; /* 24bit: VBR Maximum burst size */
105 uint32_t mcr; /* 24bit: ABR/VBR/UBR+MCR MCR */
106 uint32_t icr; /* 24bit: ABR ICR */
107 uint32_t tbe; /* 24bit: ABR TBE (1...2^24-1) */
108 uint8_t nrm; /* 3bit: ABR Nrm */
109 uint8_t trm; /* 3bit: ABR Trm */
110 uint16_t adtf; /* 10bit: ABR ADTF */
111 uint8_t rif; /* 4bit: ABR RIF */
112 uint8_t rdf; /* 4bit: ABR RDF */
113 uint8_t cdf; /* 3bit: ABR CDF */
114 };
115
116 /*
117 * VCC parameters
118 *
119 * Keep in sync with ng_atm.h
120 */
121 struct atmio_vcc {
122 uint16_t flags; /* VCC flags */
123 uint16_t vpi;
124 uint16_t vci;
125 uint16_t rmtu; /* maximum receive PDU */
126 uint16_t tmtu; /* maximum transmit PDU */
127 uint8_t aal; /* aal type */
128 uint8_t traffic; /* traffic type */
129 struct atmio_tparam tparam; /* traffic parameters */
130 };
131
132 /* VCC flags */
133 #define ATMIO_FLAG_LLCSNAP 0x0002 /* same as ATM_PH_LLCSNAP */
134 #define ATMIO_FLAG_NG 0x0010 /* owned by netgraph */
135 #define ATMIO_FLAG_HARP 0x0020 /* owned by HARP */
136 #define ATMIO_FLAG_NORX 0x0100 /* not receiving on this VCC */
137 #define ATMIO_FLAG_NOTX 0x0200 /* not transmitting on this VCC */
138 #define ATMIO_FLAG_PVC 0x0400 /* this is a PVC */
139 #define ATMIO_FLAG_ASYNC 0x0800 /* async open/close */
140 #define ATMIO_FLAGS "\020\2LLCSNAP\5NG\6HARP\11NORX\12NOTX\13PVC\14ASYNC"
141
142 #define ATMIO_AAL_0 0 /* pure cells */
143 #define ATMIO_AAL_34 4 /* AAL3 and 4 */
144 #define ATMIO_AAL_5 5 /* AAL5 */
145 #define ATMIO_AAL_RAW 10 /* whatever the card does */
146
147 #define ATMIO_TRAFFIC_UBR 0
148 #define ATMIO_TRAFFIC_CBR 1
149 #define ATMIO_TRAFFIC_ABR 2
150 #define ATMIO_TRAFFIC_VBR 3
151
152 /*
153 * VCC table
154 *
155 * Keep in sync with ng_atm.h
156 */
157 struct atmio_vcctable {
158 uint32_t count; /* number of vccs */
159 struct atmio_vcc vccs[0]; /* array of VCCs */
160 };
161
162 /*
163 * Peak cell rates for various physical media. Note, that there are
164 * different opinions on what the correct values are.
165 */
166 #define ATM_RATE_25_6M 59259
167 #define ATM_RATE_155M 353208
168 #define ATM_RATE_622M 1412830
169 #define ATM_RATE_2_4G 5651320
170
171 #ifdef _KERNEL
172 /*
173 * Common fields for all ATM interfaces. Each driver's softc must start with
174 * this structure.
175 */
176 struct ifatm {
177 struct ifnet ifnet; /* required by if_var.h */
178 struct ifatm_mib mib; /* exported data */
179 void *phy; /* usually SUNI */
180 void *ngpriv; /* netgraph link */
181 };
182 #endif
183
184 /*
185 * Keep structures in sync with ng_atm.h
186 *
187 * These are used by netgraph/harp to call the driver
188 * NATM uses the atm_pseudoioctl instead.
189 */
190 struct atmio_openvcc {
191 void *rxhand; /* handle argument */
192 struct atmio_vcc param; /* parameters */
193 };
194
195 struct atmio_closevcc {
196 uint16_t vpi;
197 uint16_t vci;
198 };
199
200 #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
201 #define RTALLOC1(A,B) rtalloc1((A),(B))
202 #elif defined(__FreeBSD__)
203 #define RTALLOC1(A,B) rtalloc1((A),(B),0UL)
204 #endif
205
206 /*
207 * pseudo header for packet transmission
208 */
209 struct atm_pseudohdr {
210 uint8_t atm_ph[4]; /* flags+VPI+VCI1(msb)+VCI2(lsb) */
211 };
212
213 #define ATM_PH_FLAGS(X) ((X)->atm_ph[0])
214 #define ATM_PH_VPI(X) ((X)->atm_ph[1])
215 #define ATM_PH_VCI(X) ((((X)->atm_ph[2]) << 8) | ((X)->atm_ph[3]))
216 #define ATM_PH_SETVCI(X,V) { \
217 (X)->atm_ph[2] = ((V) >> 8) & 0xff; \
218 (X)->atm_ph[3] = ((V) & 0xff); \
219 }
220
221 /* use AAL5? (0 == aal0) */
222 #define ATM_PH_AAL5 0x01
223 /* use the LLC SNAP encoding (iff aal5) */
224 #define ATM_PH_LLCSNAP ATMIO_FLAG_LLCSNAP
225
226 #define ATM_PH_DRIVER7 0x40 /* reserve for driver's use */
227 #define ATM_PH_DRIVER8 0x80 /* reserve for driver's use */
228
229 #define ATMMTU 9180 /* ATM MTU size for IP */
230 /* XXX: could be 9188 with LLC/SNAP according
231 to comer */
232
233 #define SIOCATMGETVCCS _IOW('a', 125, struct atmio_vcctable)
234 #define SIOCATMOPENVCC _IOR('a', 126, struct atmio_openvcc)
235 #define SIOCATMCLOSEVCC _IOR('a', 127, struct atmio_closevcc)
236
237 #define SIOCATMGVCCS _IOWR('i', 230, struct ifreq)
238
239 /*
240 * XXX forget all the garbage in if_llc.h and do it the easy way
241 */
242 #define ATMLLC_HDR "\252\252\3\0\0\0"
243 struct atmllc {
244 uint8_t llchdr[6]; /* aa.aa.03.00.00.00 */
245 uint8_t type[2]; /* "ethernet" type */
246 };
247
248 /* ATM_LLC macros: note type code in host byte order */
249 #define ATM_LLC_TYPE(X) (((X)->type[0] << 8) | ((X)->type[1]))
250 #define ATM_LLC_SETTYPE(X, V) do { \
251 (X)->type[0] = ((V) >> 8) & 0xff; \
252 (X)->type[1] = ((V) & 0xff); \
253 } while (0)
254
255 /*
256 * Events that are emitted by the driver. Currently the only consumer
257 * of this is the netgraph node.
258 */
259 #define ATMEV_FLOW_CONTROL 0x0001 /* channel busy state changed */
260 #define ATMEV_IFSTATE_CHANGED 0x0002 /* up/down or carrier */
261 #define ATMEV_VCC_CHANGED 0x0003 /* PVC deleted/create */
262 #define ATMEV_ACR_CHANGED 0x0004 /* ABR ACR has changed */
263
264 struct atmev_flow_control {
265 uint16_t vpi; /* channel that is changed */
266 uint16_t vci;
267 u_int busy : 1; /* != 0 -> ATM layer busy */
268 };
269
270 struct atmev_ifstate_changed {
271 u_int running : 1; /* interface is running now */
272 u_int carrier : 1; /* carrier detected (or not) */
273 };
274
275 struct atmev_vcc_changed {
276 uint16_t vpi; /* channel that is changed */
277 uint16_t vci;
278 u_int up : 1; /* 1 - created, 0 - deleted */
279 };
280
281 struct atmev_acr_changed {
282 uint16_t vpi; /* channel that is changed */
283 uint16_t vci;
284 uint32_t acr; /* new ACR */
285 };
286
287 #ifdef _KERNEL
288 void atm_ifattach(struct ifnet *);
289 void atm_ifdetach(struct ifnet *);
290 void atm_input(struct ifnet *, struct atm_pseudohdr *,
291 struct mbuf *, void *);
292 int atm_output(struct ifnet *, struct mbuf *, struct sockaddr *,
293 struct rtentry *);
294 struct atmio_vcctable *atm_getvccs(struct atmio_vcc **, u_int, u_int,
295 struct mtx *, int);
296
297 void atm_event(struct ifnet *, u_int, void *);
298
299 #define ATMEV_SEND_FLOW_CONTROL(ATMIF, VPI, VCI, BUSY) \
300 do { \
301 struct atmev_flow_control _arg; \
302 _arg.vpi = (VPI); \
303 _arg.vci = (VCI); \
304 _arg.busy = (BUSY); \
305 atm_event(&(ATMIF)->ifnet, ATMEV_FLOW_CONTROL, &_arg); \
306 } while (0)
307
308 #define ATMEV_SEND_VCC_CHANGED(ATMIF, VPI, VCI, UP) \
309 do { \
310 struct atmev_vcc_changed _arg; \
311 _arg.vpi = (VPI); \
312 _arg.vci = (VCI); \
313 _arg.up = (UP); \
314 atm_event(&(ATMIF)->ifnet, ATMEV_VCC_CHANGED, &_arg); \
315 } while (0)
316
317 #define ATMEV_SEND_IFSTATE_CHANGED(ATMIF, CARRIER) \
318 do { \
319 struct atmev_ifstate_changed _arg; \
320 _arg.running = (((ATMIF)->ifnet.if_flags & \
321 IFF_RUNNING) != 0); \
322 _arg.carrier = ((CARRIER) != 0); \
323 atm_event(&(ATMIF)->ifnet, ATMEV_IFSTATE_CHANGED, &_arg); \
324 } while (0)
325
326 #define ATMEV_SEND_ACR_CHANGED(ATMIF, VPI, VCI, ACR) \
327 do { \
328 struct atmev_acr_changed _arg; \
329 _arg.vpi = (VPI); \
330 _arg.vci = (VCI); \
331 _arg.acr= (ACR); \
332 atm_event(&(ATMIF)->ifnet, ATMEV_ACR_CHANGED, &_arg); \
333 } while (0)
334 #endif
Cache object: d234d1b9fcbe82b24d301cabd72c929a
|