1 /* $NetBSD: if_atm.h,v 1.7 1996/11/09 23:02:27 chuck Exp $ */
6 * Copyright (c) 1996 Charles D. Cranor and Washington University.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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.
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.
41 * Classification of ATM cards.
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) */
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" },
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
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 */
98 * Traffic parameters for ATM connections. This contains all parameters
99 * to accomodate UBR, UBR+MCR, CBR, VBR and ABR connections.
101 * Keep in sync with ng_atm.h
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 */
121 * Keep in sync with ng_atm.h
124 uint16_t flags; /* VCC flags */
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 */
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"
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 */
149 #define ATMIO_TRAFFIC_UBR 0
150 #define ATMIO_TRAFFIC_CBR 1
151 #define ATMIO_TRAFFIC_ABR 2
152 #define ATMIO_TRAFFIC_VBR 3
157 * Keep in sync with ng_atm.h
159 struct atmio_vcctable {
160 uint32_t count; /* number of vccs */
161 struct atmio_vcc vccs[0]; /* array of VCCs */
165 * Peak cell rates for various physical media. Note, that there are
166 * different opinions on what the correct values are.
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
175 * Common fields for all ATM interfaces. Each driver's softc must start with
180 struct ifatm_mib mib; /* exported data */
181 void *phy; /* usually SUNI */
182 void *ngpriv; /* netgraph link */
184 #define IFP2IFATM(ifp) ((struct ifatm *)(ifp)->if_l2com)
188 * Keep structures in sync with ng_atm.h
190 * These are used by netgraph/harp to call the driver
191 * NATM uses the atm_pseudoioctl instead.
193 struct atmio_openvcc {
194 void *rxhand; /* handle argument */
195 struct atmio_vcc param; /* parameters */
198 struct atmio_closevcc {
203 #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
204 #define RTALLOC1(A,B) rtalloc1((A),(B))
205 #elif defined(__FreeBSD__)
206 #define RTALLOC1(A,B) rtalloc1((A),(B),0UL)
210 * pseudo header for packet transmission
212 struct atm_pseudohdr {
213 uint8_t atm_ph[4]; /* flags+VPI+VCI1(msb)+VCI2(lsb) */
216 #define ATM_PH_FLAGS(X) ((X)->atm_ph[0])
217 #define ATM_PH_VPI(X) ((X)->atm_ph[1])
218 #define ATM_PH_VCI(X) ((((X)->atm_ph[2]) << 8) | ((X)->atm_ph[3]))
219 #define ATM_PH_SETVCI(X,V) { \
220 (X)->atm_ph[2] = ((V) >> 8) & 0xff; \
221 (X)->atm_ph[3] = ((V) & 0xff); \
224 /* use AAL5? (0 == aal0) */
225 #define ATM_PH_AAL5 0x01
226 /* use the LLC SNAP encoding (iff aal5) */
227 #define ATM_PH_LLCSNAP ATMIO_FLAG_LLCSNAP
229 #define ATM_PH_DRIVER7 0x40 /* reserve for driver's use */
230 #define ATM_PH_DRIVER8 0x80 /* reserve for driver's use */
232 #define ATMMTU 9180 /* ATM MTU size for IP */
233 /* XXX: could be 9188 with LLC/SNAP according
236 #define SIOCATMGETVCCS _IOW('a', 125, struct atmio_vcctable)
237 #define SIOCATMOPENVCC _IOR('a', 126, struct atmio_openvcc)
238 #define SIOCATMCLOSEVCC _IOR('a', 127, struct atmio_closevcc)
240 #define SIOCATMGVCCS _IOWR('i', 230, struct ifreq)
243 * XXX forget all the garbage in if_llc.h and do it the easy way
245 #define ATMLLC_HDR "\252\252\3\0\0\0"
247 uint8_t llchdr[6]; /* aa.aa.03.00.00.00 */
248 uint8_t type[2]; /* "ethernet" type */
251 /* ATM_LLC macros: note type code in host byte order */
252 #define ATM_LLC_TYPE(X) (((X)->type[0] << 8) | ((X)->type[1]))
253 #define ATM_LLC_SETTYPE(X, V) do { \
254 (X)->type[0] = ((V) >> 8) & 0xff; \
255 (X)->type[1] = ((V) & 0xff); \
259 * Events that are emitted by the driver. Currently the only consumer
260 * of this is the netgraph node.
262 #define ATMEV_FLOW_CONTROL 0x0001 /* channel busy state changed */
263 #define ATMEV_IFSTATE_CHANGED 0x0002 /* up/down or carrier */
264 #define ATMEV_VCC_CHANGED 0x0003 /* PVC deleted/create */
265 #define ATMEV_ACR_CHANGED 0x0004 /* ABR ACR has changed */
267 struct atmev_flow_control {
268 uint16_t vpi; /* channel that is changed */
270 u_int busy : 1; /* != 0 -> ATM layer busy */
273 struct atmev_ifstate_changed {
274 u_int running : 1; /* interface is running now */
275 u_int carrier : 1; /* carrier detected (or not) */
278 struct atmev_vcc_changed {
279 uint16_t vpi; /* channel that is changed */
281 u_int up : 1; /* 1 - created, 0 - deleted */
284 struct atmev_acr_changed {
285 uint16_t vpi; /* channel that is changed */
287 uint32_t acr; /* new ACR */
291 void atm_ifattach(struct ifnet *);
292 void atm_ifdetach(struct ifnet *);
293 void atm_input(struct ifnet *, struct atm_pseudohdr *,
294 struct mbuf *, void *);
295 int atm_output(struct ifnet *, struct mbuf *, const struct sockaddr *,
297 struct atmio_vcctable *atm_getvccs(struct atmio_vcc **, u_int, u_int,
300 void atm_event(struct ifnet *, u_int, void *);
302 #define ATMEV_SEND_FLOW_CONTROL(ATMIF, VPI, VCI, BUSY) \
304 struct atmev_flow_control _arg; \
307 _arg.busy = (BUSY); \
308 atm_event((ATMIF)->ifp, ATMEV_FLOW_CONTROL, &_arg); \
311 #define ATMEV_SEND_VCC_CHANGED(ATMIF, VPI, VCI, UP) \
313 struct atmev_vcc_changed _arg; \
317 atm_event((ATMIF)->ifp, ATMEV_VCC_CHANGED, &_arg); \
320 #define ATMEV_SEND_IFSTATE_CHANGED(ATMIF, CARRIER) \
322 struct atmev_ifstate_changed _arg; \
323 _arg.running = (((ATMIF)->ifp->if_drv_flags & \
324 IFF_DRV_RUNNING) != 0); \
325 _arg.carrier = ((CARRIER) != 0); \
326 atm_event((ATMIF)->ifp, ATMEV_IFSTATE_CHANGED, &_arg); \
329 #define ATMEV_SEND_ACR_CHANGED(ATMIF, VPI, VCI, ACR) \
331 struct atmev_acr_changed _arg; \
335 atm_event((ATMIF)->ifp, ATMEV_ACR_CHANGED, &_arg); \