1/* $NetBSD: if_atm.h,v 1.7 1996/11/09 23:02:27 chuck Exp $ */ 2/* $FreeBSD$ */ 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 */ 82struct 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 accommodate UBR, UBR+MCR, CBR, VBR and ABR connections. 100 * 101 * Keep in sync with ng_atm.h 102 */ 103struct 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 */ 123struct 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 */ 159struct 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 */ 178struct ifatm { 179 struct ifnet *ifp; 180 struct ifatm_mib mib; /* exported data */ 181 void *phy; /* usually SUNI */ 182 void *ngpriv; /* netgraph link */ 183}; 184#define IFP2IFATM(ifp) ((struct ifatm *)(ifp)->if_l2com) 185#endif 186 187/* 188 * Keep structures in sync with ng_atm.h 189 * 190 * These are used by netgraph/harp to call the driver 191 * NATM uses the atm_pseudoioctl instead. 192 */ 193struct atmio_openvcc { 194 void *rxhand; /* handle argument */ 195 struct atmio_vcc param; /* parameters */ 196}; 197 198struct atmio_closevcc { 199 uint16_t vpi; 200 uint16_t vci; 201}; 202 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) 207#endif 208 209/* 210 * pseudo header for packet transmission 211 */ 212struct atm_pseudohdr { 213 uint8_t atm_ph[4]; /* flags+VPI+VCI1(msb)+VCI2(lsb) */ 214}; 215 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); \ 222} 223 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 228 229#define ATM_PH_DRIVER7 0x40 /* reserve for driver's use */ 230#define ATM_PH_DRIVER8 0x80 /* reserve for driver's use */ 231 232#define ATMMTU 9180 /* ATM MTU size for IP */ 233 /* XXX: could be 9188 with LLC/SNAP according 234 to comer */ 235 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) 239 240#define SIOCATMGVCCS _IOWR('i', 230, struct ifreq) 241 242/* 243 * XXX forget all the garbage in if_llc.h and do it the easy way 244 */ 245#define ATMLLC_HDR "\252\252\3\0\0\0" 246struct atmllc { 247 uint8_t llchdr[6]; /* aa.aa.03.00.00.00 */ 248 uint8_t type[2]; /* "ethernet" type */ 249}; 250 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); \ 256 } while (0) 257 258/* 259 * Events that are emitted by the driver. Currently the only consumer 260 * of this is the netgraph node. 261 */ 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 */ 266 267struct atmev_flow_control { 268 uint16_t vpi; /* channel that is changed */ 269 uint16_t vci; 270 u_int busy : 1; /* != 0 -> ATM layer busy */ 271}; 272 273struct atmev_ifstate_changed { 274 u_int running : 1; /* interface is running now */ 275 u_int carrier : 1; /* carrier detected (or not) */ 276}; 277 278struct atmev_vcc_changed { 279 uint16_t vpi; /* channel that is changed */ 280 uint16_t vci; 281 u_int up : 1; /* 1 - created, 0 - deleted */ 282}; 283 284struct atmev_acr_changed { 285 uint16_t vpi; /* channel that is changed */ 286 uint16_t vci; 287 uint32_t acr; /* new ACR */ 288}; 289 290#ifdef _KERNEL 291void atm_ifattach(struct ifnet *); 292void atm_ifdetach(struct ifnet *); 293void atm_input(struct ifnet *, struct atm_pseudohdr *, 294 struct mbuf *, void *); 295int atm_output(struct ifnet *, struct mbuf *, const struct sockaddr *, 296 struct route *); 297struct atmio_vcctable *atm_getvccs(struct atmio_vcc **, u_int, u_int, 298 struct mtx *, int); 299 300void atm_event(struct ifnet *, u_int, void *); 301 302#define ATMEV_SEND_FLOW_CONTROL(ATMIF, VPI, VCI, BUSY) \ 303 do { \ 304 struct atmev_flow_control _arg; \ 305 _arg.vpi = (VPI); \ 306 _arg.vci = (VCI); \ 307 _arg.busy = (BUSY); \ 308 atm_event((ATMIF)->ifp, ATMEV_FLOW_CONTROL, &_arg); \ 309 } while (0) 310 311#define ATMEV_SEND_VCC_CHANGED(ATMIF, VPI, VCI, UP) \ 312 do { \ 313 struct atmev_vcc_changed _arg; \ 314 _arg.vpi = (VPI); \ 315 _arg.vci = (VCI); \ 316 _arg.up = (UP); \ 317 atm_event((ATMIF)->ifp, ATMEV_VCC_CHANGED, &_arg); \ 318 } while (0) 319 320#define ATMEV_SEND_IFSTATE_CHANGED(ATMIF, CARRIER) \ 321 do { \ 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); \ 327 } while (0) 328 329#define ATMEV_SEND_ACR_CHANGED(ATMIF, VPI, VCI, ACR) \ 330 do { \ 331 struct atmev_acr_changed _arg; \ 332 _arg.vpi = (VPI); \ 333 _arg.vci = (VCI); \ 334 _arg.acr= (ACR); \ 335 atm_event((ATMIF)->ifp, ATMEV_ACR_CHANGED, &_arg); \ 336 } while (0) 337#endif 338