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