1 /* $NetBSD: if_media.h,v 1.45 2006/05/18 09:05:51 liamjfoy Exp $ */ 2 /* $FreeBSD: src/sys/net/if_media.h,v 1.9.2.4 2002/07/30 06:22:40 imp Exp $ */ 3 4 /* 5 * Copyright (c) 1997 6 * Jonathan Stone and Jason R. Thorpe. All rights reserved. 7 * 8 * This software is derived from information provided by Matt Thomas. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by Jonathan Stone 21 * and Jason R. Thorpe for the NetBSD Project. 22 * 4. The names of the authors may not be used to endorse or promote products 23 * derived from this software without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 26 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 27 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 28 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 32 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 */ 37 38 #ifndef _NET_IF_MEDIA_H_ 39 #define _NET_IF_MEDIA_H_ 40 41 #ifndef _SYS_TYPES_H_ 42 #include <sys/types.h> 43 #endif 44 45 /* 46 * Prototypes and definitions for BSD/OS-compatible network interface 47 * media selection. 48 * 49 * Where it is safe to do so, this code strays slightly from the BSD/OS 50 * design. Software which uses the API (device drivers, basically) 51 * shouldn't notice any difference. 52 * 53 * Many thanks to Matt Thomas for providing the information necessary 54 * to implement this interface. 55 */ 56 57 #ifdef _KERNEL 58 59 #ifndef _SYS_QUEUE_H_ 60 #include <sys/queue.h> 61 #endif 62 63 struct ifnet; 64 struct ifreq; 65 struct ifmediareq; 66 67 /* 68 * Driver callbacks for media status and change requests. 69 */ 70 typedef int (*ifm_change_cb_t)(struct ifnet *ifp); 71 typedef void (*ifm_stat_cb_t)(struct ifnet *ifp, struct ifmediareq *req); 72 73 /* 74 * In-kernel representation of a single supported media type. 75 */ 76 struct ifmedia_entry { 77 LIST_ENTRY(ifmedia_entry) ifm_list; 78 int ifm_media; /* description of this media attachment */ 79 int ifm_data; /* for driver-specific use */ 80 void *ifm_aux; /* for driver-specific use */ 81 }; 82 83 /* 84 * One of these goes into a network interface's softc structure. 85 * It is used to keep general media state. 86 */ 87 struct ifmedia { 88 int ifm_mask; /* mask of changes we don't care about */ 89 int ifm_media; /* current user-set media word */ 90 struct ifmedia_entry *ifm_cur; /* currently selected media */ 91 LIST_HEAD(, ifmedia_entry) ifm_list; /* list of all supported media */ 92 ifm_change_cb_t ifm_change; /* media change driver callback */ 93 ifm_stat_cb_t ifm_status; /* media status driver callback */ 94 }; 95 96 /* Initialize an interface's struct if_media field. */ 97 void ifmedia_init(struct ifmedia *ifm, int dontcare_mask, 98 ifm_change_cb_t change_callback, ifm_stat_cb_t status_callback); 99 100 /* Remove all mediums from a struct ifmedia. */ 101 void ifmedia_removeall( struct ifmedia *ifm); 102 103 /* Add one supported medium to a struct ifmedia. */ 104 void ifmedia_add(struct ifmedia *ifm, int mword, int data, void *aux); 105 int ifmedia_add_nodup(struct ifmedia *ifm, int mword, int data, void *aux); 106 107 /* Add an array (of ifmedia_entry) media to a struct ifmedia. */ 108 void ifmedia_list_add(struct ifmedia *mp, struct ifmedia_entry *lp, 109 int count); 110 111 /* Set default media type on initialization. */ 112 void ifmedia_set(struct ifmedia *ifm, int mword); 113 int ifmedia_tryset(struct ifmedia *ifm, int mword); 114 115 /* Common ioctl function for getting/setting media, called by driver. */ 116 int ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, 117 struct ifmedia *ifm, u_long cmd); 118 119 /* Compute baudrate for a given media. */ 120 uint64_t ifmedia_baudrate(int); 121 #endif /*_KERNEL */ 122 123 /* 124 * if_media Options word: 125 * Bits Use 126 * ---- ------- 127 * 0-4 Media variant MAX SUBTYPE == 31!! 128 * 5-7 Media type 129 * 8-15 Type specific options (includes added variant bits on Ethernet) 130 * 16-18 Mode (for multi-mode devices) 131 * 19 RFU 132 * 20-27 Shared (global) options 133 * 28-31 Instance 134 */ 135 136 /* 137 * Ethernet 138 * 139 * In order to use more than 31 subtypes, Ethernet uses some of the option 140 * bits as part of the subtype field. See the options section below for 141 * relevant definitions 142 */ 143 #define IFM_ETHER 0x00000020 144 #define IFM_ETHER_SUBTYPE(x) (((x) & IFM_TMASK) | \ 145 (((x) & (IFM_ETH_XTYPE >> IFM_ETH_XSHIFT)) << IFM_ETH_XSHIFT)) 146 /* internal shorthand */ 147 #define IFM_X(x) IFM_ETHER_SUBTYPE(x) 148 #define IFM_ETHER_SUBTYPE_SET(x) (IFM_ETHER_SUBTYPE(x) | IFM_ETHER) 149 #define IFM_ETHER_SUBTYPE_GET(x) ((x) & (IFM_TMASK | IFM_ETH_XTYPE)) 150 #define IFM_ETHER_IS_EXTENDED(x) ((x) & IFM_ETH_XTYPE) 151 152 #define IFM_10_T 3 /* 10BaseT - RJ45 */ 153 #define IFM_10_2 4 /* 10Base2 - Thinnet */ 154 #define IFM_10_5 5 /* 10Base5 - AUI */ 155 #define IFM_100_TX 6 /* 100BaseTX - RJ45 */ 156 #define IFM_100_FX 7 /* 100BaseFX - Fiber */ 157 #define IFM_100_T4 8 /* 100BaseT4 - 4 pair cat 3 */ 158 #define IFM_100_VG 9 /* 100VG-AnyLAN */ 159 #define IFM_100_T2 10 /* 100BaseT2 */ 160 #define IFM_1000_SX 11 /* 1000BaseSX Multi-mode Fiber */ 161 #define IFM_10_STP 12 /* 10BaseT over shielded TP */ 162 #define IFM_10_FL 13 /* 10baseFL - Fiber */ 163 #define IFM_1000_LX 14 /* 1000BaseLX Single-mode Fiber */ 164 #define IFM_1000_CX 15 /* 1000BaseCX 150ohm STP */ 165 #define IFM_1000_T 16 /* 1000BaseT 4 pair cat 5 */ 166 #define IFM_HPNA_1 17 /* HomePNA media for ethernet frames */ 167 #define IFM_10G_LR 18 /* 10GBase-LR 1310nm Single-mode */ 168 #define IFM_10G_SR 19 /* 10GBase-SR 850nm Multi-mode */ 169 #define IFM_10G_CX4 20 /* 10GBase CX4 copper */ 170 #define IFM_2500_SX 21 /* 2500BaseSX - multi-mode fiber */ 171 #define IFM_10G_TWINAX 22 /* 10GBase Twinax copper */ 172 #define IFM_10G_TWINAX_LONG 23 /* 10GBase Twinax Long copper */ 173 #define IFM_10G_LRM 24 /* 10GBase-LRM 850nm Multi-mode */ 174 #define IFM_UNKNOWN 25 /* media types not defined yet */ 175 #define IFM_10G_T 26 /* 10GBase-T - RJ45 */ 176 #define IFM_40G_CR4 27 /* 40GBase-CR4 */ 177 #define IFM_40G_SR4 28 /* 40GBase-SR4 */ 178 #define IFM_40G_LR4 29 /* 40GBase-LR4 */ 179 #define IFM_1000_KX 30 /* 1000Base-KX backplane */ 180 #define IFM_OTHER 31 /* Other: one of the following */ 181 182 /* following types are not visible to old binaries using only IFM_TMASK */ 183 #define IFM_10G_KX4 IFM_X(32) /* 10GBase-KX4 backplane */ 184 #define IFM_10G_KR IFM_X(33) /* 10GBase-KR backplane */ 185 #define IFM_10G_CR1 IFM_X(34) /* 10GBase-CR1 Twinax splitter */ 186 #define IFM_20G_KR2 IFM_X(35) /* 20GBase-KR2 backplane */ 187 #define IFM_2500_KX IFM_X(36) /* 2500Base-KX backplane */ 188 #define IFM_2500_T IFM_X(37) /* 2500Base-T - RJ45 (NBaseT) */ 189 #define IFM_5000_T IFM_X(38) /* 5000Base-T - RJ45 (NBaseT) */ 190 #define IFM_50G_PCIE IFM_X(39) /* 50G Ethernet over PCIE */ 191 #define IFM_25G_PCIE IFM_X(40) /* 25G Ethernet over PCIE */ 192 #define IFM_1000_SGMII IFM_X(41) /* 1G media interface */ 193 #define IFM_10G_SFI IFM_X(42) /* 10G media interface */ 194 #define IFM_40G_XLPPI IFM_X(43) /* 40G media interface */ 195 #define IFM_1000_CX_SGMII IFM_X(44) /* 1000Base-CX-SGMII */ 196 #define IFM_40G_KR4 IFM_X(45) /* 40GBase-KR4 */ 197 #define IFM_10G_ER IFM_X(46) /* 10GBase-ER */ 198 #define IFM_100G_CR4 IFM_X(47) /* 100GBase-CR4 */ 199 #define IFM_100G_SR4 IFM_X(48) /* 100GBase-SR4 */ 200 #define IFM_100G_KR4 IFM_X(49) /* 100GBase-KR4 */ 201 #define IFM_100G_LR4 IFM_X(50) /* 100GBase-LR4 */ 202 #define IFM_56G_R4 IFM_X(51) /* 56GBase-R4 */ 203 #define IFM_100_T IFM_X(52) /* 100BaseT - RJ45 */ 204 #define IFM_25G_CR IFM_X(53) /* 25GBase-CR */ 205 #define IFM_25G_KR IFM_X(54) /* 25GBase-KR */ 206 #define IFM_25G_SR IFM_X(55) /* 25GBase-SR */ 207 #define IFM_50G_CR2 IFM_X(56) /* 50GBase-CR2 */ 208 #define IFM_50G_KR2 IFM_X(57) /* 50GBase-KR2 */ 209 /* 210 * Note IFM_X(255) is the max! 211 * 212 * Please update ieee8023ad_lacp.c:lacp_compose_key() and if_vke.c:vke_attach() 213 * after adding new ethernet media types. 214 */ 215 216 /* Ethernet option values; includes bits used for extended variant field */ 217 #define IFM_ETH_MASTER 0x00000100 /* master mode (1000baseT) */ 218 #define IFM_ETH_RXPAUSE 0x00000200 /* receive PAUSE frames */ 219 #define IFM_ETH_TXPAUSE 0x00000400 /* transmit PAUSE frames */ 220 #define IFM_ETH_FORCEPAUSE 0x00000800 /* force flow control settings */ 221 #define IFM_ETH_XTYPE 0x00007000 /* extended media variants */ 222 #define IFM_ETH_XSHIFT 7 /* shift XTYPE next to TMASK */ 223 224 /* 225 * IEEE 802.11 Wireless 226 */ 227 #define IFM_IEEE80211 0x00000080 228 /* NB: 0,1,2 are auto, manual, none defined below */ 229 #define IFM_IEEE80211_FH1 3 /* Frequency Hopping 1Mbps */ 230 #define IFM_IEEE80211_FH2 4 /* Frequency Hopping 2Mbps */ 231 #define IFM_IEEE80211_DS1 5 /* Direct Sequence 1Mbps */ 232 #define IFM_IEEE80211_DS2 6 /* Direct Sequence 2Mbps */ 233 #define IFM_IEEE80211_DS5 7 /* Direct Sequence 5.5Mbps */ 234 #define IFM_IEEE80211_DS11 8 /* Direct Sequence 11Mbps */ 235 #define IFM_IEEE80211_DS22 9 /* Direct Sequence 22Mbps */ 236 #define IFM_IEEE80211_OFDM6 10 /* OFDM 6Mbps */ 237 #define IFM_IEEE80211_OFDM9 11 /* OFDM 9Mbps */ 238 #define IFM_IEEE80211_OFDM12 12 /* OFDM 12Mbps */ 239 #define IFM_IEEE80211_OFDM18 13 /* OFDM 18Mbps */ 240 #define IFM_IEEE80211_OFDM24 14 /* OFDM 24Mbps */ 241 #define IFM_IEEE80211_OFDM36 15 /* OFDM 36Mbps */ 242 #define IFM_IEEE80211_OFDM48 16 /* OFDM 48Mbps */ 243 #define IFM_IEEE80211_OFDM54 17 /* OFDM 54Mbps */ 244 #define IFM_IEEE80211_OFDM72 18 /* OFDM 72Mbps */ 245 #define IFM_IEEE80211_DS354k 19 /* Direct Sequence 354Kbps */ 246 #define IFM_IEEE80211_DS512k 20 /* Direct Sequence 512Kbps */ 247 #define IFM_IEEE80211_OFDM3 21 /* OFDM 3Mbps */ 248 #define IFM_IEEE80211_OFDM4 22 /* OFDM 4.5Mbps */ 249 #define IFM_IEEE80211_OFDM27 23 /* OFDM 27Mbps */ 250 /* NB: not enough bits to express MCS fully */ 251 #define IFM_IEEE80211_MCS 24 /* HT MCS rate */ 252 253 #define IFM_IEEE80211_ADHOC 0x00000100 /* Operate in Adhoc mode */ 254 #define IFM_IEEE80211_HOSTAP 0x00000200 /* Operate in Host AP mode */ 255 #define IFM_IEEE80211_IBSS 0x00000400 /* Operate in IBSS mode */ 256 #define IFM_IEEE80211_WDS 0x00000800 /* Operate in WDS mode */ 257 #define IFM_IEEE80211_TURBO 0x00001000 /* Operate in turbo mode */ 258 #define IFM_IEEE80211_MONITOR 0x00002000 /* Operate in monitor mode */ 259 #define IFM_IEEE80211_MBSS 0x00004000 /* Operate in MBSS mode */ 260 261 /* operating mode for multi-mode devices */ 262 #define IFM_IEEE80211_11A 0x00010000 /* 5Ghz, OFDM mode */ 263 #define IFM_IEEE80211_11B 0x00020000 /* Direct Sequence mode */ 264 #define IFM_IEEE80211_11G 0x00030000 /* 2Ghz, CCK mode */ 265 #define IFM_IEEE80211_FH 0x00040000 /* 2Ghz, GFSK mode */ 266 #define IFM_IEEE80211_11NA 0x00050000 /* 5Ghz, HT mode */ 267 #define IFM_IEEE80211_11NG 0x00060000 /* 2Ghz, HT mode */ 268 269 270 /* 271 * ATM 272 */ 273 #define IFM_ATM 0x000000a0 274 #define IFM_ATM_UNKNOWN 3 275 #define IFM_ATM_UTP_25 4 276 #define IFM_ATM_TAXI_100 5 277 #define IFM_ATM_TAXI_140 6 278 #define IFM_ATM_MM_155 7 279 #define IFM_ATM_SM_155 8 280 #define IFM_ATM_UTP_155 9 281 #define IFM_ATM_MM_622 10 282 #define IFM_ATM_SM_622 11 283 #define IFM_ATM_VIRTUAL 12 284 #define IFM_ATM_SDH 0x00000100 /* SDH instead of SONET */ 285 #define IFM_ATM_NOSCRAMB 0x00000200 /* no scrambling */ 286 #define IFM_ATM_UNASSIGNED 0x00000400 /* unassigned cells */ 287 288 /* 289 * CARP Common Address Redundancy Protocol 290 */ 291 #define IFM_CARP 0x000000c0 292 293 /* 294 * Shared media sub-types 295 */ 296 #define IFM_AUTO 0 /* Autoselect best media */ 297 #define IFM_MANUAL 1 /* Jumper/dipswitch selects media */ 298 #define IFM_NONE 2 /* Deselect all media */ 299 300 /* 301 * Shared options 302 */ 303 #define IFM_FDX 0x00100000 /* Force full duplex */ 304 #define IFM_HDX 0x00200000 /* Force half duplex */ 305 #define IFM_FLOW 0x00400000 /* enable hardware flow control */ 306 #define IFM_FLAG0 0x01000000 /* Driver defined flag */ 307 #define IFM_FLAG1 0x02000000 /* Driver defined flag */ 308 #define IFM_FLAG2 0x04000000 /* Driver defined flag */ 309 #define IFM_LOOP 0x08000000 /* Put hardware in loopback */ 310 311 /* 312 * Masks 313 */ 314 #define IFM_NMASK 0x000000e0 /* Network type */ 315 #define IFM_TMASK 0x0000001f /* Media sub-type */ 316 #define IFM_IMASK 0xf0000000 /* Instance */ 317 #define IFM_ISHIFT 28 /* Instance shift */ 318 #define IFM_OMASK 0x0000ff00 /* Type specific options */ 319 #define IFM_MMASK 0x00070000 /* Mode */ 320 #define IFM_MSHIFT 16 /* Mode shift */ 321 #define IFM_GMASK 0x0ff00000 /* Global options */ 322 /* Ethernet flow control mask */ 323 #define IFM_ETH_FCMASK (IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE | IFM_ETH_FORCEPAUSE) 324 #define IFM_ETH_FMASK (IFM_FLOW | IFM_ETH_FCMASK) 325 326 #define IFM_NMIN IFM_ETHER /* lowest Network type */ 327 #define IFM_NMAX IFM_NMASK /* highest Network type */ 328 329 /* 330 * Status bits 331 */ 332 #define IFM_AVALID 0x00000001 /* Active bit valid */ 333 #define IFM_ACTIVE 0x00000002 /* Interface attached to working net */ 334 335 /* 336 * Macros to extract various bits of information from the media word. 337 */ 338 #define IFM_TYPE(x) ((x) & IFM_NMASK) 339 #define IFM_SUBTYPE(x) \ 340 (IFM_TYPE(x) == IFM_ETHER ? \ 341 IFM_ETHER_SUBTYPE_GET(x) : ((x) & IFM_TMASK)) 342 #define IFM_TYPE_MATCH(x,y) \ 343 (IFM_TYPE(x) == IFM_TYPE(y) && IFM_SUBTYPE(x) == IFM_SUBTYPE(y)) 344 #define IFM_TYPE_OPTIONS(x) ((x) & IFM_OMASK) 345 #define IFM_INST(x) (((x) & IFM_IMASK) >> IFM_ISHIFT) 346 #define IFM_OPTIONS(x) ((x) & (IFM_OMASK|IFM_GMASK)) 347 #define IFM_MODE(x) ((x) & IFM_MMASK) 348 349 #define IFM_INST_MAX IFM_INST(IFM_IMASK) 350 351 /* 352 * Macro to create a media word. 353 */ 354 #define IFM_MAKEWORD(type, subtype, options, instance) \ 355 ((type) | (subtype) | (options) | ((instance) << IFM_ISHIFT)) 356 #define IFM_MAKEMODE(mode) \ 357 (((mode) << IFM_MSHIFT) & IFM_MMASK) 358 359 /* 360 * NetBSD extension not defined in the BSDI API. This is used in various 361 * places to get the canonical description for a given type/subtype. 362 * 363 * NOTE: all but the top-level type descriptions must contain NO whitespace! 364 * Otherwise, parsing these in ifconfig(8) would be a nightmare. 365 */ 366 struct ifmedia_description { 367 int ifmt_word; /* word value; may be masked */ 368 const char *ifmt_string; /* description */ 369 }; 370 371 #define IFM_TYPE_DESCRIPTIONS { \ 372 { IFM_ETHER, "Ethernet" }, \ 373 { IFM_IEEE80211, "IEEE 802.11 Wireless Ethernet" }, \ 374 { IFM_CARP, "Common Address Redundancy Protocol" }, \ 375 { 0, NULL }, \ 376 } 377 378 #define IFM_SUBTYPE_ETHERNET_DESCRIPTIONS { \ 379 { IFM_10_T, "10baseT/UTP" }, \ 380 { IFM_10_2, "10base2/BNC" }, \ 381 { IFM_10_5, "10base5/AUI" }, \ 382 { IFM_100_TX, "100baseTX" }, \ 383 { IFM_100_FX, "100baseFX" }, \ 384 { IFM_100_T4, "100baseT4" }, \ 385 { IFM_100_VG, "100baseVG" }, \ 386 { IFM_100_T2, "100baseT2" }, \ 387 { IFM_1000_SX, "1000baseSX" }, \ 388 { IFM_10_STP, "10baseSTP" }, \ 389 { IFM_10_FL, "10baseFL" }, \ 390 { IFM_1000_LX, "1000baseLX" }, \ 391 { IFM_1000_CX, "1000baseCX" }, \ 392 { IFM_1000_T, "1000baseT" }, \ 393 { IFM_HPNA_1, "homePNA" }, \ 394 { IFM_10G_LR, "10GbaseLR" }, \ 395 { IFM_10G_SR, "10GbaseSR" }, \ 396 { IFM_10G_CX4, "10GbaseCX4" }, \ 397 { IFM_2500_SX, "2500baseSX" }, \ 398 { IFM_10G_TWINAX, "10GbaseTwinax" }, \ 399 { IFM_10G_TWINAX_LONG, "10GbaseTwinax-Long" }, \ 400 { IFM_10G_LRM, "10GbaseLRM" }, \ 401 { IFM_UNKNOWN, "Unknown" }, \ 402 { IFM_10G_T, "10GbaseT" }, \ 403 { IFM_40G_CR4, "40GbaseCR4" }, \ 404 { IFM_40G_SR4, "40GbaseSR4" }, \ 405 { IFM_40G_LR4, "40GbaseLR4" }, \ 406 { IFM_1000_KX, "1000baseKX" }, \ 407 { IFM_OTHER, "Other" }, \ 408 { IFM_10G_KX4, "10GbaseKX4" }, \ 409 { IFM_10G_KR, "10GbaseKR" }, \ 410 { IFM_10G_CR1, "10GbaseCR1" }, \ 411 { IFM_20G_KR2, "20GbaseKR2" }, \ 412 { IFM_2500_KX, "2500baseKX" }, \ 413 { IFM_2500_T, "2500baseT" }, \ 414 { IFM_5000_T, "5000baseT" }, \ 415 { IFM_50G_PCIE, "PCIExpress-50G" }, \ 416 { IFM_25G_PCIE, "PCIExpress-25G" }, \ 417 { IFM_1000_SGMII, "1000baseSGMII" }, \ 418 { IFM_10G_SFI, "10GbaseSFI" }, \ 419 { IFM_40G_XLPPI, "40GbaseXLPPI" }, \ 420 { IFM_1000_CX_SGMII, "1000baseCX-SGMII" }, \ 421 { IFM_40G_KR4, "40GbaseKR4" }, \ 422 { IFM_10G_ER, "10GbaseER" }, \ 423 { IFM_100G_CR4, "100GbaseCR4" }, \ 424 { IFM_100G_SR4, "100GbaseSR4" }, \ 425 { IFM_100G_KR4, "100GbaseKR4" }, \ 426 { IFM_100G_LR4, "100GbaseLR4" }, \ 427 { IFM_56G_R4, "56GbaseR4" }, \ 428 { IFM_100_T, "100baseT" }, \ 429 { IFM_25G_CR, "25GbaseCR" }, \ 430 { IFM_25G_KR, "25GbaseKR" }, \ 431 { IFM_25G_SR, "25GbaseSR" }, \ 432 { IFM_50G_CR2, "50GbaseCR2" }, \ 433 { IFM_50G_KR2, "50GbaseKR2" }, \ 434 { 0, NULL }, \ 435 } 436 437 #define IFM_SUBTYPE_ETHERNET_ALIASES { \ 438 { IFM_10_T, "UTP" }, \ 439 { IFM_10_T, "10UTP" }, \ 440 { IFM_10_2, "BNC" }, \ 441 { IFM_10_2, "10BNC" }, \ 442 { IFM_10_5, "AUI" }, \ 443 { IFM_10_5, "10AUI" }, \ 444 { IFM_100_TX, "100TX" }, \ 445 { IFM_100_FX, "100FX" }, \ 446 { IFM_100_T4, "100T4" }, \ 447 { IFM_100_VG, "100VG" }, \ 448 { IFM_100_T2, "100T2" }, \ 449 { IFM_10_STP, "10STP" }, \ 450 { IFM_10_FL, "10FL" }, \ 451 { IFM_1000_SX, "1000SX" }, \ 452 { IFM_1000_LX, "1000LX" }, \ 453 { IFM_1000_CX, "1000CX" }, \ 454 { IFM_1000_T, "1000T" }, \ 455 { IFM_2500_SX, "2500SX" }, \ 456 { 0, NULL }, \ 457 } 458 459 #define IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS { \ 460 { IFM_ETH_MASTER, "master" }, \ 461 { IFM_ETH_RXPAUSE, "rxpause" }, \ 462 { IFM_ETH_TXPAUSE, "txpause" }, \ 463 { IFM_ETH_FORCEPAUSE, "forcepause" }, \ 464 { 0, NULL }, \ 465 } 466 467 #define IFM_SUBTYPE_ETHERNET_OPTION_ALIAS { \ 468 { IFM_ETH_TXPAUSE | IFM_ETH_RXPAUSE, "flowcontrol" }, \ 469 { 0, NULL }, \ 470 } 471 472 #define IFM_SUBTYPE_IEEE80211_DESCRIPTIONS { \ 473 { IFM_IEEE80211_FH1, "FH/1Mbps" }, \ 474 { IFM_IEEE80211_FH2, "FH/2Mbps" }, \ 475 { IFM_IEEE80211_DS1, "DS/1Mbps" }, \ 476 { IFM_IEEE80211_DS2, "DS/2Mbps" }, \ 477 { IFM_IEEE80211_DS5, "DS/5.5Mbps" }, \ 478 { IFM_IEEE80211_DS11, "DS/11Mbps" }, \ 479 { IFM_IEEE80211_DS22, "DS/22Mbps" }, \ 480 { IFM_IEEE80211_OFDM6, "OFDM/6Mbps" }, \ 481 { IFM_IEEE80211_OFDM9, "OFDM/9Mbps" }, \ 482 { IFM_IEEE80211_OFDM12, "OFDM/12Mbps" }, \ 483 { IFM_IEEE80211_OFDM18, "OFDM/18Mbps" }, \ 484 { IFM_IEEE80211_OFDM24, "OFDM/24Mbps" }, \ 485 { IFM_IEEE80211_OFDM36, "OFDM/36Mbps" }, \ 486 { IFM_IEEE80211_OFDM48, "OFDM/48Mbps" }, \ 487 { IFM_IEEE80211_OFDM54, "OFDM/54Mbps" }, \ 488 { IFM_IEEE80211_OFDM72, "OFDM/72Mbps" }, \ 489 { IFM_IEEE80211_DS354k, "DS/354Kbps" }, \ 490 { IFM_IEEE80211_DS512k, "DS/512Kbps" }, \ 491 { IFM_IEEE80211_OFDM3, "OFDM/3Mbps" }, \ 492 { IFM_IEEE80211_OFDM4, "OFDM/4.5Mbps" }, \ 493 { IFM_IEEE80211_OFDM27, "OFDM/27Mbps" }, \ 494 { IFM_IEEE80211_MCS, "MCS" }, \ 495 { 0, NULL }, \ 496 } 497 498 #define IFM_SUBTYPE_IEEE80211_ALIASES { \ 499 { IFM_IEEE80211_FH1, "FH1" }, \ 500 { IFM_IEEE80211_FH2, "FH2" }, \ 501 { IFM_IEEE80211_FH1, "FrequencyHopping/1Mbps" }, \ 502 { IFM_IEEE80211_FH2, "FrequencyHopping/2Mbps" }, \ 503 { IFM_IEEE80211_DS1, "DS1" }, \ 504 { IFM_IEEE80211_DS2, "DS2" }, \ 505 { IFM_IEEE80211_DS5, "DS5.5" }, \ 506 { IFM_IEEE80211_DS11, "DS11" }, \ 507 { IFM_IEEE80211_DS22, "DS22" }, \ 508 { IFM_IEEE80211_DS1, "DirectSequence/1Mbps" }, \ 509 { IFM_IEEE80211_DS2, "DirectSequence/2Mbps" }, \ 510 { IFM_IEEE80211_DS5, "DirectSequence/5.5Mbps" }, \ 511 { IFM_IEEE80211_DS11, "DirectSequence/11Mbps" }, \ 512 { IFM_IEEE80211_DS22, "DirectSequence/22Mbps" }, \ 513 { IFM_IEEE80211_OFDM6, "OFDM6" }, \ 514 { IFM_IEEE80211_OFDM9, "OFDM9" }, \ 515 { IFM_IEEE80211_OFDM12, "OFDM12" }, \ 516 { IFM_IEEE80211_OFDM18, "OFDM18" }, \ 517 { IFM_IEEE80211_OFDM24, "OFDM24" }, \ 518 { IFM_IEEE80211_OFDM36, "OFDM36" }, \ 519 { IFM_IEEE80211_OFDM48, "OFDM48" }, \ 520 { IFM_IEEE80211_OFDM54, "OFDM54" }, \ 521 { IFM_IEEE80211_OFDM72, "OFDM72" }, \ 522 { IFM_IEEE80211_DS1, "CCK1" }, \ 523 { IFM_IEEE80211_DS2, "CCK2" }, \ 524 { IFM_IEEE80211_DS5, "CCK5.5" }, \ 525 { IFM_IEEE80211_DS11, "CCK11" }, \ 526 { IFM_IEEE80211_DS354k, "DS354K" }, \ 527 { IFM_IEEE80211_DS354k, "DirectSequence/354Kbps" }, \ 528 { IFM_IEEE80211_DS512k, "DS512K" }, \ 529 { IFM_IEEE80211_DS512k, "DirectSequence/512Kbps" }, \ 530 { IFM_IEEE80211_OFDM3, "OFDM3" }, \ 531 { IFM_IEEE80211_OFDM4, "OFDM4.5" }, \ 532 { IFM_IEEE80211_OFDM27, "OFDM27" }, \ 533 { IFM_IEEE80211_MCS, "MCS" }, \ 534 { 0, NULL }, \ 535 } 536 537 #define IFM_SUBTYPE_IEEE80211_OPTION_DESCRIPTIONS { \ 538 { IFM_IEEE80211_ADHOC, "adhoc" }, \ 539 { IFM_IEEE80211_HOSTAP, "hostap" }, \ 540 { IFM_IEEE80211_IBSS, "ibss" }, \ 541 { IFM_IEEE80211_WDS, "wds" }, \ 542 { IFM_IEEE80211_TURBO, "turbo" }, \ 543 { IFM_IEEE80211_MONITOR, "monitor" }, \ 544 { IFM_IEEE80211_MBSS, "mesh" }, \ 545 { 0, NULL }, \ 546 } 547 548 #define IFM_SUBTYPE_IEEE80211_MODE_DESCRIPTIONS { \ 549 { IFM_AUTO, "autoselect" }, \ 550 { IFM_IEEE80211_11A, "11a" }, \ 551 { IFM_IEEE80211_11B, "11b" }, \ 552 { IFM_IEEE80211_11G, "11g" }, \ 553 { IFM_IEEE80211_FH, "fh" }, \ 554 { IFM_IEEE80211_11NA, "11na" }, \ 555 { IFM_IEEE80211_11NG, "11ng" }, \ 556 { 0, NULL }, \ 557 } 558 559 #define IFM_SUBTYPE_IEEE80211_MODE_ALIASES { \ 560 { IFM_AUTO, "auto" }, \ 561 { 0, NULL }, \ 562 } 563 564 # define IFM_SUBTYPE_ATM_DESCRIPTIONS { \ 565 { IFM_ATM_UNKNOWN, "Unknown" }, \ 566 { IFM_ATM_UTP_25, "UTP/25.6MBit" }, \ 567 { IFM_ATM_TAXI_100, "Taxi/100MBit" }, \ 568 { IFM_ATM_TAXI_140, "Taxi/140MBit" }, \ 569 { IFM_ATM_MM_155, "Multi-mode/155MBit" }, \ 570 { IFM_ATM_SM_155, "Single-mode/155MBit" }, \ 571 { IFM_ATM_UTP_155, "UTP/155MBit" }, \ 572 { IFM_ATM_MM_622, "Multi-mode/622MBit" }, \ 573 { IFM_ATM_SM_622, "Single-mode/622MBit" }, \ 574 { IFM_ATM_VIRTUAL, "Virtual" }, \ 575 { 0, NULL }, \ 576 } 577 578 # define IFM_SUBTYPE_ATM_ALIASES { \ 579 { IFM_ATM_UNKNOWN, "UNKNOWN" }, \ 580 { IFM_ATM_UTP_25, "UTP-25" }, \ 581 { IFM_ATM_TAXI_100, "TAXI-100" }, \ 582 { IFM_ATM_TAXI_140, "TAXI-140" }, \ 583 { IFM_ATM_MM_155, "MM-155" }, \ 584 { IFM_ATM_SM_155, "SM-155" }, \ 585 { IFM_ATM_UTP_155, "UTP-155" }, \ 586 { IFM_ATM_MM_622, "MM-622" }, \ 587 { IFM_ATM_SM_622, "SM-622" }, \ 588 { IFM_ATM_VIRTUAL, "VIRTUAL" }, \ 589 { 0, NULL }, \ 590 } 591 592 #define IFM_SUBTYPE_ATM_OPTION_DESCRIPTIONS { \ 593 { IFM_ATM_SDH, "SDH" }, \ 594 { IFM_ATM_NOSCRAMB, "Noscramb" }, \ 595 { IFM_ATM_UNASSIGNED, "Unassigned" }, \ 596 { 0, NULL }, \ 597 } 598 599 600 #define IFM_SUBTYPE_SHARED_DESCRIPTIONS { \ 601 { IFM_AUTO, "autoselect" }, \ 602 { IFM_MANUAL, "manual" }, \ 603 { IFM_NONE, "none" }, \ 604 { 0, NULL }, \ 605 } 606 607 #define IFM_SUBTYPE_SHARED_ALIASES { \ 608 { IFM_AUTO, "auto" }, \ 609 { 0, NULL }, \ 610 } 611 612 #define IFM_SHARED_OPTION_DESCRIPTIONS { \ 613 { IFM_FDX, "full-duplex" }, \ 614 { IFM_HDX, "half-duplex" }, \ 615 { IFM_FLAG0, "flag0" }, \ 616 { IFM_FLAG1, "flag1" }, \ 617 { IFM_FLAG2, "flag2" }, \ 618 { IFM_LOOP, "hw-loopback" }, \ 619 { 0, NULL }, \ 620 } 621 622 /* 623 * Baudrate descriptions for the various media types. 624 */ 625 struct ifmedia_baudrate { 626 int ifmb_word; /* media word */ 627 uint64_t ifmb_baudrate; /* corresponding baudrate */ 628 }; 629 630 #define IFM_BAUDRATE_DESCRIPTIONS { \ 631 { IFM_ETHER|IFM_10_T, IF_Mbps(10) }, \ 632 { IFM_ETHER|IFM_10_2, IF_Mbps(10) }, \ 633 { IFM_ETHER|IFM_10_5, IF_Mbps(10) }, \ 634 { IFM_ETHER|IFM_100_TX, IF_Mbps(100) }, \ 635 { IFM_ETHER|IFM_100_FX, IF_Mbps(100) }, \ 636 { IFM_ETHER|IFM_100_T4, IF_Mbps(100) }, \ 637 { IFM_ETHER|IFM_100_VG, IF_Mbps(100) }, \ 638 { IFM_ETHER|IFM_100_T2, IF_Mbps(100) }, \ 639 { IFM_ETHER|IFM_1000_SX, IF_Mbps(1000) }, \ 640 { IFM_ETHER|IFM_10_STP, IF_Mbps(10) }, \ 641 { IFM_ETHER|IFM_10_FL, IF_Mbps(10) }, \ 642 { IFM_ETHER|IFM_1000_LX, IF_Mbps(1000) }, \ 643 { IFM_ETHER|IFM_1000_CX, IF_Mbps(1000) }, \ 644 { IFM_ETHER|IFM_1000_T, IF_Mbps(1000) }, \ 645 { IFM_ETHER|IFM_HPNA_1, IF_Mbps(1) }, \ 646 { IFM_ETHER|IFM_10G_LR, IF_Gbps(10ULL) }, \ 647 { IFM_ETHER|IFM_10G_SR, IF_Gbps(10ULL) }, \ 648 { IFM_ETHER|IFM_10G_CX4, IF_Gbps(10ULL) }, \ 649 { IFM_ETHER|IFM_2500_SX, IF_Mbps(2500ULL) }, \ 650 { IFM_ETHER|IFM_10G_TWINAX, IF_Gbps(10ULL) }, \ 651 { IFM_ETHER|IFM_10G_TWINAX_LONG,IF_Gbps(10ULL) }, \ 652 { IFM_ETHER|IFM_10G_LRM, IF_Gbps(10ULL) }, \ 653 { IFM_ETHER|IFM_10G_T, IF_Gbps(10ULL) }, \ 654 { IFM_ETHER|IFM_40G_CR4, IF_Gbps(40ULL) }, \ 655 { IFM_ETHER|IFM_40G_SR4, IF_Gbps(40ULL) }, \ 656 { IFM_ETHER|IFM_40G_LR4, IF_Gbps(40ULL) }, \ 657 { IFM_ETHER|IFM_1000_KX, IF_Mbps(1000) }, \ 658 { IFM_ETHER|IFM_10G_KX4, IF_Gbps(10ULL) }, \ 659 { IFM_ETHER|IFM_10G_KR, IF_Gbps(10ULL) }, \ 660 { IFM_ETHER|IFM_10G_CR1, IF_Gbps(10ULL) }, \ 661 { IFM_ETHER|IFM_20G_KR2, IF_Gbps(20ULL) }, \ 662 { IFM_ETHER|IFM_2500_KX, IF_Mbps(2500ULL) }, \ 663 { IFM_ETHER|IFM_2500_T, IF_Mbps(2500ULL) }, \ 664 { IFM_ETHER|IFM_5000_T, IF_Mbps(5000ULL) }, \ 665 { IFM_ETHER|IFM_50G_PCIE, IF_Gbps(50ULL) }, \ 666 { IFM_ETHER|IFM_25G_PCIE, IF_Gbps(25ULL) }, \ 667 { IFM_ETHER|IFM_1000_SGMII, IF_Mbps(1000) }, \ 668 { IFM_ETHER|IFM_10G_SFI, IF_Gbps(10ULL) }, \ 669 { IFM_ETHER|IFM_40G_XLPPI, IF_Gbps(40ULL) }, \ 670 { IFM_ETHER|IFM_1000_CX_SGMII, IF_Mbps(1000) }, \ 671 { IFM_ETHER|IFM_40G_KR4, IF_Gbps(40ULL) }, \ 672 { IFM_ETHER|IFM_10G_ER, IF_Gbps(10ULL) }, \ 673 { IFM_ETHER|IFM_100G_CR4, IF_Gbps(100ULL) }, \ 674 { IFM_ETHER|IFM_100G_SR4, IF_Gbps(100ULL) }, \ 675 { IFM_ETHER|IFM_100G_KR4, IF_Gbps(100ULL) }, \ 676 { IFM_ETHER|IFM_100G_LR4, IF_Gbps(100ULL) }, \ 677 { IFM_ETHER|IFM_56G_R4, IF_Gbps(56ULL) }, \ 678 { IFM_ETHER|IFM_100_T, IF_Mbps(100ULL) }, \ 679 { IFM_ETHER|IFM_25G_CR, IF_Gbps(25ULL) }, \ 680 { IFM_ETHER|IFM_25G_KR, IF_Gbps(25ULL) }, \ 681 { IFM_ETHER|IFM_25G_SR, IF_Gbps(25ULL) }, \ 682 { IFM_ETHER|IFM_50G_CR2, IF_Gbps(50ULL) }, \ 683 { IFM_ETHER|IFM_50G_KR2, IF_Gbps(50ULL) }, \ 684 \ 685 { IFM_IEEE80211|IFM_IEEE80211_FH1, IF_Mbps(1) }, \ 686 { IFM_IEEE80211|IFM_IEEE80211_FH2, IF_Mbps(2) }, \ 687 { IFM_IEEE80211|IFM_IEEE80211_DS1, IF_Mbps(1) }, \ 688 { IFM_IEEE80211|IFM_IEEE80211_DS2, IF_Mbps(2) }, \ 689 { IFM_IEEE80211|IFM_IEEE80211_DS5, IF_Kbps(5500) }, \ 690 { IFM_IEEE80211|IFM_IEEE80211_DS11, IF_Mbps(11) }, \ 691 { IFM_IEEE80211|IFM_IEEE80211_DS22, IF_Mbps(22) }, \ 692 { IFM_IEEE80211|IFM_IEEE80211_OFDM6, IF_Mbps(6) }, \ 693 { IFM_IEEE80211|IFM_IEEE80211_OFDM9, IF_Mbps(9) }, \ 694 { IFM_IEEE80211|IFM_IEEE80211_OFDM12, IF_Mbps(12) }, \ 695 { IFM_IEEE80211|IFM_IEEE80211_OFDM18, IF_Mbps(18) }, \ 696 { IFM_IEEE80211|IFM_IEEE80211_OFDM24, IF_Mbps(24) }, \ 697 { IFM_IEEE80211|IFM_IEEE80211_OFDM36, IF_Mbps(36) }, \ 698 { IFM_IEEE80211|IFM_IEEE80211_OFDM48, IF_Mbps(48) }, \ 699 { IFM_IEEE80211|IFM_IEEE80211_OFDM54, IF_Mbps(54) }, \ 700 { IFM_IEEE80211|IFM_IEEE80211_OFDM72, IF_Mbps(72) }, \ 701 \ 702 { 0, 0 }, \ 703 } 704 705 #ifdef _KERNEL 706 707 /* Ethernet flow control strings for tunables */ 708 #define IFM_ETH_FC_STRLEN 16 709 #define IFM_ETH_FC_FULL "full" 710 #define IFM_ETH_FC_RXPAUSE "rxpause" 711 #define IFM_ETH_FC_TXPAUSE "txpause" 712 #define IFM_ETH_FC_NONE "none" 713 #define IFM_ETH_FC_FORCE_FULL "force-full" 714 #define IFM_ETH_FC_FORCE_RXPAUSE "force-rxpause" 715 #define IFM_ETH_FC_FORCE_TXPAUSE "force-txpause" 716 #define IFM_ETH_FC_FORCE_NONE "force-none" 717 718 /* String to flow control media options */ 719 int ifmedia_str2ethfc(const char *); 720 721 #endif /* _KERNEL */ 722 723 #endif /* _NET_IF_MEDIA_H_ */ 724