if_atm.h revision 118157
1/* $NetBSD: if_atm.h,v 1.7 1996/11/09 23:02:27 chuck Exp $ */ 2/* $FreeBSD: head/sys/net/if_atm.h 118157 2003-07-29 13:04:52Z 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 */ 80struct 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 */ 101struct 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 */ 121struct 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_FLAGS "\020\2LLCSNAP\5NG\6HARP\11NORX\12NOTX\13PVC" 140 141#define ATMIO_AAL_0 0 /* pure cells */ 142#define ATMIO_AAL_34 4 /* AAL3 and 4 */ 143#define ATMIO_AAL_5 5 /* AAL5 */ 144#define ATMIO_AAL_RAW 10 /* whatever the card does */ 145 146#define ATMIO_TRAFFIC_UBR 0 147#define ATMIO_TRAFFIC_CBR 1 148#define ATMIO_TRAFFIC_ABR 2 149#define ATMIO_TRAFFIC_VBR 3 150 151/* 152 * VCC table 153 * 154 * Keep in sync with ng_atm.h 155 */ 156struct atmio_vcctable { 157 uint32_t count; /* number of vccs */ 158 struct atmio_vcc vccs[0]; /* array of VCCs */ 159}; 160 161/* 162 * Peak cell rates for various physical media. Note, that there are 163 * different opinions on what the correct values are. 164 */ 165#define ATM_RATE_25_6M 59259 166#define ATM_RATE_155M 353208 167#define ATM_RATE_622M 1412830 168#define ATM_RATE_2_4G 5651320 169 170#ifdef _KERNEL 171/* 172 * Common fields for all ATM interfaces. Each driver's softc must start with 173 * this structure. 174 */ 175struct ifatm { 176 struct ifnet ifnet; /* required by if_var.h */ 177 struct ifatm_mib mib; /* exported data */ 178 void *phy; /* usually SUNI */ 179 void *ngpriv; /* netgraph link */ 180}; 181#endif 182 183/* 184 * Keep structures in sync with ng_atm.h 185 * 186 * These are used by netgraph/harp to call the driver 187 * NATM uses the atm_pseudoioctl instead. 188 */ 189struct atmio_openvcc { 190 void *rxhand; /* handle argument */ 191 struct atmio_vcc param; /* parameters */ 192}; 193 194struct atmio_closevcc { 195 uint16_t vpi; 196 uint16_t vci; 197}; 198 199#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) 200#define RTALLOC1(A,B) rtalloc1((A),(B)) 201#elif defined(__FreeBSD__) 202#define RTALLOC1(A,B) rtalloc1((A),(B),0UL) 203#endif 204 205/* 206 * pseudo header for packet transmission 207 */ 208struct atm_pseudohdr { 209 uint8_t atm_ph[4]; /* flags+VPI+VCI1(msb)+VCI2(lsb) */ 210}; 211 212#define ATM_PH_FLAGS(X) ((X)->atm_ph[0]) 213#define ATM_PH_VPI(X) ((X)->atm_ph[1]) 214#define ATM_PH_VCI(X) ((((X)->atm_ph[2]) << 8) | ((X)->atm_ph[3])) 215#define ATM_PH_SETVCI(X,V) { \ 216 (X)->atm_ph[2] = ((V) >> 8) & 0xff; \ 217 (X)->atm_ph[3] = ((V) & 0xff); \ 218} 219 220/* use AAL5? (0 == aal0) */ 221#define ATM_PH_AAL5 0x01 222/* use the LLC SNAP encoding (iff aal5) */ 223#define ATM_PH_LLCSNAP ATMIO_FLAG_LLCSNAP 224 225#define ATM_PH_DRIVER7 0x40 /* reserve for driver's use */ 226#define ATM_PH_DRIVER8 0x80 /* reserve for driver's use */ 227 228#define ATMMTU 9180 /* ATM MTU size for IP */ 229 /* XXX: could be 9188 with LLC/SNAP according 230 to comer */ 231 232/* user's ioctl hook for raw atm mode */ 233#define SIOCRAWATM _IOWR('a', 122, int) /* set driver's raw mode */ 234 235/* atm_pseudoioctl: turns on and off RX VCIs [for internal use only!] */ 236struct atm_pseudoioctl { 237 struct atm_pseudohdr aph; 238 void *rxhand; 239}; 240#define SIOCATMENA _IOWR('a', 123, struct atm_pseudoioctl) /* enable */ 241#define SIOCATMDIS _IOWR('a', 124, struct atm_pseudoioctl) /* disable */ 242#define SIOCATMGETVCCS _IOW('a', 125, struct atmio_vcctable) 243#define SIOCATMOPENVCC _IOR('a', 126, struct atmio_openvcc) 244#define SIOCATMCLOSEVCC _IOR('a', 127, struct atmio_closevcc) 245 246#define SIOCATMGVCCS _IOWR('i', 230, struct ifreq) 247 248/* 249 * XXX forget all the garbage in if_llc.h and do it the easy way 250 */ 251#define ATMLLC_HDR "\252\252\3\0\0\0" 252struct atmllc { 253 uint8_t llchdr[6]; /* aa.aa.03.00.00.00 */ 254 uint8_t type[2]; /* "ethernet" type */ 255}; 256 257/* ATM_LLC macros: note type code in host byte order */ 258#define ATM_LLC_TYPE(X) (((X)->type[0] << 8) | ((X)->type[1])) 259#define ATM_LLC_SETTYPE(X, V) do { \ 260 (X)->type[0] = ((V) >> 8) & 0xff; \ 261 (X)->type[1] = ((V) & 0xff); \ 262 } while (0) 263 264/* 265 * Events that are emitted by the driver. Currently the only consumer 266 * of this is the netgraph node. 267 */ 268#define ATMEV_FLOW_CONTROL 0x0001 /* channel busy state changed */ 269#define ATMEV_IFSTATE_CHANGED 0x0002 /* up/down or carrier */ 270#define ATMEV_VCC_CHANGED 0x0003 /* PVC deleted/create */ 271#define ATMEV_ACR_CHANGED 0x0004 /* ABR ACR has changed */ 272 273struct atmev_flow_control { 274 uint16_t vpi; /* channel that is changed */ 275 uint16_t vci; 276 u_int busy : 1; /* != 0 -> ATM layer busy */ 277}; 278 279struct atmev_ifstate_changed { 280 u_int running : 1; /* interface is running now */ 281 u_int carrier : 1; /* carrier detected (or not) */ 282}; 283 284struct atmev_vcc_changed { 285 uint16_t vpi; /* channel that is changed */ 286 uint16_t vci; 287 u_int up : 1; /* 1 - created, 0 - deleted */ 288}; 289 290struct atmev_acr_changed { 291 uint16_t vpi; /* channel that is changed */ 292 uint16_t vci; 293 uint32_t acr; /* new ACR */ 294}; 295 296#ifdef _KERNEL 297void atm_ifattach(struct ifnet *); 298void atm_ifdetach(struct ifnet *); 299void atm_input(struct ifnet *, struct atm_pseudohdr *, 300 struct mbuf *, void *); 301int atm_output(struct ifnet *, struct mbuf *, struct sockaddr *, 302 struct rtentry *); 303struct atmio_vcctable *atm_getvccs(struct atmio_vcc **, u_int, u_int, 304 struct mtx *, int); 305 306void atm_event(struct ifnet *, u_int, void *); 307 308#define ATMEV_SEND_FLOW_CONTROL(ATMIF, VPI, VCI, BUSY) \ 309 do { \ 310 struct atmev_flow_control _arg; \ 311 _arg.vpi = (VPI); \ 312 _arg.vci = (VCI); \ 313 _arg.busy = (BUSY); \ 314 atm_event(&(ATMIF)->ifnet, ATMEV_FLOW_CONTROL, &_arg); \ 315 } while (0) 316 317#define ATMEV_SEND_VCC_CHANGED(ATMIF, VPI, VCI, UP) \ 318 do { \ 319 struct atmev_vcc_changed _arg; \ 320 _arg.vpi = (VPI); \ 321 _arg.vci = (VCI); \ 322 _arg.up = (UP); \ 323 atm_event(&(ATMIF)->ifnet, ATMEV_VCC_CHANGED, &_arg); \ 324 } while (0) 325 326#define ATMEV_SEND_IFSTATE_CHANGED(ATMIF, CARRIER) \ 327 do { \ 328 struct atmev_ifstate_changed _arg; \ 329 _arg.running = (((ATMIF)->ifnet.if_flags & \ 330 IFF_RUNNING) != 0); \ 331 _arg.carrier = ((CARRIER) != 0); \ 332 atm_event(&(ATMIF)->ifnet, ATMEV_IFSTATE_CHANGED, &_arg); \ 333 } while (0) 334 335#define ATMEV_SEND_ACR_CHANGED(ATMIF, VPI, VCI, ACR) \ 336 do { \ 337 struct atmev_acr_changed _arg; \ 338 _arg.vpi = (VPI); \ 339 _arg.vci = (VCI); \ 340 _arg.acr= (ACR); \ 341 atm_event(&(ATMIF)->ifnet, ATMEV_ACR_CHANGED, &_arg); \ 342 } while (0) 343#endif 344