if_media.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /* $OpenBSD: if_media.h,v 1.32 2014/12/05 15:50:04 mpi Exp $ */
  2. /* $NetBSD: if_media.h,v 1.22 2000/02/17 21:53:16 sommerfeld Exp $ */
  3. /*-
  4. * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
  5. * All rights reserved.
  6. *
  7. * This code is derived from software contributed to The NetBSD Foundation
  8. * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
  9. * NASA Ames Research Center.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. * 2. Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  21. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  22. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  23. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  24. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30. * POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. /*
  33. * Copyright (c) 1997
  34. * Jonathan Stone and Jason R. Thorpe. All rights reserved.
  35. *
  36. * This software is derived from information provided by Matt Thomas.
  37. *
  38. * Redistribution and use in source and binary forms, with or without
  39. * modification, are permitted provided that the following conditions
  40. * are met:
  41. * 1. Redistributions of source code must retain the above copyright
  42. * notice, this list of conditions and the following disclaimer.
  43. * 2. Redistributions in binary form must reproduce the above copyright
  44. * notice, this list of conditions and the following disclaimer in the
  45. * documentation and/or other materials provided with the distribution.
  46. * 3. All advertising materials mentioning features or use of this software
  47. * must display the following acknowledgement:
  48. * This product includes software developed by Jonathan Stone
  49. * and Jason R. Thorpe for the NetBSD Project.
  50. * 4. The names of the authors may not be used to endorse or promote products
  51. * derived from this software without specific prior written permission.
  52. *
  53. * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
  54. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  55. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  56. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  57. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  58. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  59. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  60. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  61. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  62. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  63. * SUCH DAMAGE.
  64. */
  65. #ifndef _NET_IF_MEDIA_H_
  66. #define _NET_IF_MEDIA_H_
  67. /*
  68. * Prototypes and definitions for BSD/OS-compatible network interface
  69. * media selection.
  70. *
  71. * Where it is safe to do so, this code strays slightly from the BSD/OS
  72. * design. Software which uses the API (device drivers, basically)
  73. * shouldn't notice any difference.
  74. *
  75. * Many thanks to Matt Thomas for providing the information necessary
  76. * to implement this interface.
  77. */
  78. #ifdef _KERNEL
  79. struct ifnet;
  80. #include <sys/queue.h>
  81. /*
  82. * Driver callbacks for media status and change requests.
  83. */
  84. typedef int (*ifm_change_cb_t)(struct ifnet *);
  85. typedef void (*ifm_stat_cb_t)(struct ifnet *, struct ifmediareq *);
  86. /*
  87. * In-kernel representation of a single supported media type.
  88. */
  89. struct ifmedia_entry {
  90. TAILQ_ENTRY(ifmedia_entry) ifm_list;
  91. u_int ifm_media; /* description of this media attachment */
  92. u_int ifm_data; /* for driver-specific use */
  93. void *ifm_aux; /* for driver-specific use */
  94. };
  95. /*
  96. * One of these goes into a network interface's softc structure.
  97. * It is used to keep general media state.
  98. */
  99. struct ifmedia {
  100. u_int ifm_mask; /* mask of changes we don't care about */
  101. u_int ifm_media; /* current user-set media word */
  102. struct ifmedia_entry *ifm_cur; /* currently selected media */
  103. TAILQ_HEAD(, ifmedia_entry) ifm_list; /* list of all supported media */
  104. ifm_change_cb_t ifm_change; /* media change driver callback */
  105. ifm_stat_cb_t ifm_status; /* media status driver callback */
  106. };
  107. /* Initialize an interface's struct if_media field. */
  108. void ifmedia_init(struct ifmedia *, int, ifm_change_cb_t,
  109. ifm_stat_cb_t);
  110. /* Add one supported medium to a struct ifmedia. */
  111. void ifmedia_add(struct ifmedia *, int, int, void *);
  112. /* Add an array (of ifmedia_entry) media to a struct ifmedia. */
  113. void ifmedia_list_add(struct ifmedia *, struct ifmedia_entry *,
  114. int);
  115. /* Set default media type on initialization. */
  116. void ifmedia_set(struct ifmedia *, int);
  117. /* Common ioctl function for getting/setting media, called by driver. */
  118. int ifmedia_ioctl(struct ifnet *, struct ifreq *, struct ifmedia *,
  119. u_long);
  120. /* Locate a media entry */
  121. struct ifmedia_entry *ifmedia_match(struct ifmedia *, u_int, u_int);
  122. /* Delete all media for a given media instance */
  123. void ifmedia_delete_instance(struct ifmedia *, u_int);
  124. /* Compute baudrate for a given media. */
  125. u_int64_t ifmedia_baudrate(int);
  126. #endif /*_KERNEL */
  127. /*
  128. * if_media Options word:
  129. * Bits Use
  130. * ---- -------
  131. * 0-4 Media subtype MAX SUBTYPE == 31!
  132. * 5-7 Media type
  133. * 8-15 Type specific options
  134. * 16-19 RFU
  135. * 20-27 Shared (global) options
  136. * 28-31 Instance
  137. */
  138. /*
  139. * Ethernet
  140. */
  141. #define IFM_ETHER 0x00000020
  142. #define IFM_10_T 3 /* 10BaseT - RJ45 */
  143. #define IFM_10_2 4 /* 10Base2 - Thinnet */
  144. #define IFM_10_5 5 /* 10Base5 - AUI */
  145. #define IFM_100_TX 6 /* 100BaseTX - RJ45 */
  146. #define IFM_100_FX 7 /* 100BaseFX - Fiber */
  147. #define IFM_100_T4 8 /* 100BaseT4 - 4 pair cat 3 */
  148. #define IFM_100_VG 9 /* 100VG-AnyLAN */
  149. #define IFM_100_T2 10 /* 100BaseT2 */
  150. #define IFM_1000_SX 11 /* 1000BaseSX - multi-mode fiber */
  151. #define IFM_10_STP 12 /* 10BaseT over shielded TP */
  152. #define IFM_10_FL 13 /* 10BaseFL - Fiber */
  153. #define IFM_1000_LX 14 /* 1000baseLX - single-mode fiber */
  154. #define IFM_1000_CX 15 /* 1000baseCX - 150ohm STP */
  155. #define IFM_1000_T 16 /* 1000baseT - 4 pair cat 5 */
  156. #define IFM_1000_TX IFM_1000_T /* for backwards compatibility */
  157. #define IFM_HPNA_1 17 /* HomePNA 1.0 (1Mb/s) */
  158. #define IFM_10G_LR 18 /* 10GBase-LR - single-mode fiber */
  159. #define IFM_10G_SR 19 /* 10GBase-SR - multi-mode fiber */
  160. #define IFM_10G_CX4 20 /* 10GBase-CX4 - copper */
  161. #define IFM_2500_SX 21 /* 2500baseSX - multi-mode fiber */
  162. #define IFM_10G_T 22 /* 10GbaseT cat 6 */
  163. #define IFM_10G_SFP_CU 23 /* 10G SFP+ direct attached cable */
  164. #define IFM_ETH_MASTER 0x00000100 /* master mode (1000baseT) */
  165. #define IFM_ETH_RXPAUSE 0x00000200 /* receive PAUSE frames */
  166. #define IFM_ETH_TXPAUSE 0x00000400 /* transmit PAUSE frames */
  167. /*
  168. * FDDI
  169. */
  170. #define IFM_FDDI 0x00000060
  171. #define IFM_FDDI_SMF 3 /* Single-mode fiber */
  172. #define IFM_FDDI_MMF 4 /* Multi-mode fiber */
  173. #define IFM_FDDI_UTP 5 /* CDDI / UTP */
  174. #define IFM_FDDI_DA 0x00000100 /* Dual attach / single attach */
  175. /*
  176. * IEEE 802.11 Wireless
  177. */
  178. #define IFM_IEEE80211 0x00000080
  179. #define IFM_IEEE80211_FH1 3 /* Frequency Hopping 1Mbps */
  180. #define IFM_IEEE80211_FH2 4 /* Frequency Hopping 2Mbps */
  181. #define IFM_IEEE80211_DS2 5 /* Direct Sequence 2Mbps */
  182. #define IFM_IEEE80211_DS5 6 /* Direct Sequence 5Mbps*/
  183. #define IFM_IEEE80211_DS11 7 /* Direct Sequence 11Mbps*/
  184. #define IFM_IEEE80211_DS1 8 /* Direct Sequence 1Mbps*/
  185. #define IFM_IEEE80211_DS22 9 /* Direct Sequence 22Mbps */
  186. #define IFM_IEEE80211_OFDM6 10 /* OFDM 6Mbps */
  187. #define IFM_IEEE80211_OFDM9 11 /* OFDM 9Mbps */
  188. #define IFM_IEEE80211_OFDM12 12 /* OFDM 12Mbps */
  189. #define IFM_IEEE80211_OFDM18 13 /* OFDM 18Mbps */
  190. #define IFM_IEEE80211_OFDM24 14 /* OFDM 24Mbps */
  191. #define IFM_IEEE80211_OFDM36 15 /* OFDM 36Mbps */
  192. #define IFM_IEEE80211_OFDM48 16 /* OFDM 48Mbps */
  193. #define IFM_IEEE80211_OFDM54 17 /* OFDM 54Mbps */
  194. #define IFM_IEEE80211_OFDM72 18 /* OFDM 72Mbps */
  195. #define IFM_IEEE80211_ADHOC 0x100 /* Operate in Adhoc mode */
  196. #define IFM_IEEE80211_HOSTAP 0x200 /* Operate in Host AP mode */
  197. #define IFM_IEEE80211_IBSS 0x400 /* Operate in IBSS mode */
  198. #define IFM_IEEE80211_IBSSMASTER 0x800 /* Operate as an IBSS master */
  199. #define IFM_IEEE80211_MONITOR 0x1000 /* Operate in Monitor mode */
  200. #define IFM_IEEE80211_TURBO 0x2000 /* Operate in Turbo mode */
  201. /* operating mode for multi-mode devices */
  202. #define IFM_IEEE80211_11A 0x00010000 /* 5GHz, OFDM mode */
  203. #define IFM_IEEE80211_11B 0x00020000 /* Direct Sequence mode */
  204. #define IFM_IEEE80211_11G 0x00030000 /* 2GHz, CCK mode */
  205. #define IFM_IEEE80211_FH 0x00040000 /* 2GHz, GFSK mode */
  206. /*
  207. * Digitally multiplexed "Carrier" Serial Interfaces
  208. */
  209. #define IFM_TDM 0x000000a0
  210. #define IFM_TDM_T1 3 /* T1 B8ZS+ESF 24 ts */
  211. #define IFM_TDM_T1_AMI 4 /* T1 AMI+SF 24 ts */
  212. #define IFM_TDM_E1 5 /* E1 HDB3+G.703 clearchannel 32 ts */
  213. #define IFM_TDM_E1_G704 6 /* E1 HDB3+G.703+G.704 channelized 31 ts */
  214. #define IFM_TDM_E1_AMI 7 /* E1 AMI+G.703 32 ts */
  215. #define IFM_TDM_E1_AMI_G704 8 /* E1 AMI+G.703+G.704 31 ts */
  216. #define IFM_TDM_T3 9 /* T3 B3ZS+C-bit 672 ts */
  217. #define IFM_TDM_T3_M13 10 /* T3 B3ZS+M13 672 ts */
  218. #define IFM_TDM_E3 11 /* E3 HDB3+G.751 512? ts */
  219. #define IFM_TDM_E3_G751 12 /* E3 G.751 512 ts */
  220. #define IFM_TDM_E3_G832 13 /* E3 G.832 512 ts */
  221. #define IFM_TDM_E1_G704_CRC4 14 /* E1 HDB3+G.703+G.704 31 ts + CRC4 */
  222. /*
  223. * 6 major ways that networks talk: Drivers enforce independent selection,
  224. * meaning, a driver will ensure that only one of these is set at a time.
  225. * Default is cisco hdlc mode with 32 bit CRC.
  226. */
  227. #define IFM_TDM_HDLC_CRC16 0x0100 /* Use 16-bit CRC for HDLC instead */
  228. #define IFM_TDM_PPP 0x0200 /* SPPP (dumb) */
  229. #define IFM_TDM_FR_ANSI 0x0400 /* Frame Relay + LMI ANSI "Annex D" */
  230. #define IFM_TDM_FR_CISCO 0x0800 /* Frame Relay + LMI Cisco */
  231. #define IFM_TDM_FR_ITU 0x1000 /* Frame Relay + LMI ITU "Q933A" */
  232. /* operating mode */
  233. #define IFM_TDM_MASTER 0x00010000 /* aka clock source internal */
  234. /*
  235. * Common Access Redundancy Protocol
  236. */
  237. #define IFM_CARP 0x000000c0
  238. /*
  239. * Shared media sub-types
  240. */
  241. #define IFM_AUTO 0 /* Autoselect best media */
  242. #define IFM_MANUAL 1 /* Jumper/dipswitch selects media */
  243. #define IFM_NONE 2 /* Deselect all media */
  244. /*
  245. * Shared options
  246. */
  247. #define IFM_FDX 0x00100000 /* Force full duplex */
  248. #define IFM_HDX 0x00200000 /* Force half duplex */
  249. #define IFM_FLOW 0x00400000 /* enable hardware flow control */
  250. #define IFM_FLAG0 0x01000000 /* Driver defined flag */
  251. #define IFM_FLAG1 0x02000000 /* Driver defined flag */
  252. #define IFM_FLAG2 0x04000000 /* Driver defined flag */
  253. #define IFM_LOOP 0x08000000 /* Put hardware in loopback */
  254. /*
  255. * Masks
  256. */
  257. #define IFM_NMASK 0x000000e0 /* Network type */
  258. #define IFM_TMASK 0x0000001f /* Media sub-type */
  259. #define IFM_IMASK 0xf0000000 /* Instance */
  260. #define IFM_ISHIFT 28 /* Instance shift */
  261. #define IFM_OMASK 0x0000ff00 /* Type specific options */
  262. #define IFM_MMASK 0x00070000 /* Mode */
  263. #define IFM_MSHIFT 16 /* Mode shift */
  264. #define IFM_GMASK 0x0ff00000 /* Global options */
  265. /* Ethernet flow control mask */
  266. #define IFM_ETH_FMASK (IFM_FLOW|IFM_ETH_RXPAUSE|IFM_ETH_TXPAUSE)
  267. #define IFM_NMIN IFM_ETHER /* lowest Network type */
  268. #define IFM_NMAX IFM_NMASK /* highest Network type */
  269. /*
  270. * Status bits
  271. */
  272. #define IFM_AVALID 0x00000001 /* Active bit valid */
  273. #define IFM_ACTIVE 0x00000002 /* Interface attached to working net */
  274. /* Mask of "status valid" bits, for ifconfig(8). */
  275. #define IFM_STATUS_VALID IFM_AVALID
  276. /* List of "status valid" bits, for ifconfig(8). */
  277. #define IFM_STATUS_VALID_LIST { \
  278. IFM_AVALID, \
  279. 0 \
  280. }
  281. /*
  282. * Macros to extract various bits of information from the media word.
  283. */
  284. #define IFM_TYPE(x) ((x) & IFM_NMASK)
  285. #define IFM_SUBTYPE(x) ((x) & IFM_TMASK)
  286. #define IFM_INST(x) (((x) & IFM_IMASK) >> IFM_ISHIFT)
  287. #define IFM_OPTIONS(x) ((x) & (IFM_OMASK|IFM_GMASK))
  288. #define IFM_MODE(x) ((x) & IFM_MMASK)
  289. #define IFM_INST_MAX IFM_INST(IFM_IMASK)
  290. #define IFM_INST_ANY ((u_int) -1)
  291. /*
  292. * Macro to create a media word.
  293. */
  294. #define IFM_MAKEWORD(type, subtype, options, instance) \
  295. ((type) | (subtype) | (options) | ((instance) << IFM_ISHIFT))
  296. #define IFM_MAKEMODE(mode) \
  297. (((mode) << IFM_MSHIFT) & IFM_MMASK)
  298. /*
  299. * NetBSD extension not defined in the BSDI API. This is used in various
  300. * places to get the canonical description for a given type/subtype.
  301. *
  302. * In the subtype and mediaopt descriptions, the valid TYPE bits are OR'd
  303. * in to indicate which TYPE the subtype/option corresponds to. If no
  304. * TYPE is present, it is a shared media/mediaopt.
  305. *
  306. * Note that these are parsed case-insensitive.
  307. *
  308. * Order is important. The first matching entry is the canonical name
  309. * for a media type; subsequent matches are aliases.
  310. */
  311. struct ifmedia_description {
  312. int ifmt_word; /* word value; may be masked */
  313. const char *ifmt_string; /* description */
  314. };
  315. #define IFM_TYPE_DESCRIPTIONS { \
  316. { IFM_ETHER, "Ethernet" }, \
  317. { IFM_ETHER, "ether" }, \
  318. { IFM_FDDI, "FDDI" }, \
  319. { IFM_IEEE80211, "IEEE802.11" }, \
  320. { IFM_TDM, "TDM" }, \
  321. { IFM_CARP, "CARP" }, \
  322. { 0, NULL }, \
  323. }
  324. #define IFM_TYPE_MATCH(dt, t) \
  325. (IFM_TYPE((dt)) == 0 || IFM_TYPE((dt)) == IFM_TYPE((t)))
  326. #define IFM_SUBTYPE_DESCRIPTIONS { \
  327. { IFM_AUTO, "autoselect" }, \
  328. { IFM_AUTO, "auto" }, \
  329. { IFM_MANUAL, "manual" }, \
  330. { IFM_NONE, "none" }, \
  331. \
  332. { IFM_ETHER|IFM_10_T, "10baseT" }, \
  333. { IFM_ETHER|IFM_10_T, "10baseT/UTP" }, \
  334. { IFM_ETHER|IFM_10_T, "UTP" }, \
  335. { IFM_ETHER|IFM_10_T, "10UTP" }, \
  336. { IFM_ETHER|IFM_10_2, "10base2" }, \
  337. { IFM_ETHER|IFM_10_2, "10base2/BNC" }, \
  338. { IFM_ETHER|IFM_10_2, "BNC" }, \
  339. { IFM_ETHER|IFM_10_2, "10BNC" }, \
  340. { IFM_ETHER|IFM_10_5, "10base5" }, \
  341. { IFM_ETHER|IFM_10_5, "10base5/AUI" }, \
  342. { IFM_ETHER|IFM_10_5, "AUI" }, \
  343. { IFM_ETHER|IFM_10_5, "10AUI" }, \
  344. { IFM_ETHER|IFM_100_TX, "100baseTX" }, \
  345. { IFM_ETHER|IFM_100_TX, "100TX" }, \
  346. { IFM_ETHER|IFM_100_FX, "100baseFX" }, \
  347. { IFM_ETHER|IFM_100_FX, "100FX" }, \
  348. { IFM_ETHER|IFM_100_T4, "100baseT4" }, \
  349. { IFM_ETHER|IFM_100_T4, "100T4" }, \
  350. { IFM_ETHER|IFM_100_VG, "100baseVG" }, \
  351. { IFM_ETHER|IFM_100_VG, "100VG" }, \
  352. { IFM_ETHER|IFM_100_T2, "100baseT2" }, \
  353. { IFM_ETHER|IFM_100_T2, "100T2" }, \
  354. { IFM_ETHER|IFM_1000_SX, "1000baseSX" }, \
  355. { IFM_ETHER|IFM_1000_SX, "1000SX" }, \
  356. { IFM_ETHER|IFM_10_STP, "10baseSTP" }, \
  357. { IFM_ETHER|IFM_10_STP, "STP" }, \
  358. { IFM_ETHER|IFM_10_STP, "10STP" }, \
  359. { IFM_ETHER|IFM_10_FL, "10baseFL" }, \
  360. { IFM_ETHER|IFM_10_FL, "FL" }, \
  361. { IFM_ETHER|IFM_10_FL, "10FL" }, \
  362. { IFM_ETHER|IFM_1000_LX, "1000baseLX" }, \
  363. { IFM_ETHER|IFM_1000_LX, "1000LX" }, \
  364. { IFM_ETHER|IFM_1000_CX, "1000baseCX" }, \
  365. { IFM_ETHER|IFM_1000_CX, "1000CX" }, \
  366. { IFM_ETHER|IFM_1000_T, "1000baseT" }, \
  367. { IFM_ETHER|IFM_1000_T, "1000T" }, \
  368. { IFM_ETHER|IFM_1000_T, "1000baseTX" }, \
  369. { IFM_ETHER|IFM_1000_T, "1000TX" }, \
  370. { IFM_ETHER|IFM_HPNA_1, "HomePNA1" }, \
  371. { IFM_ETHER|IFM_HPNA_1, "HPNA1" }, \
  372. { IFM_ETHER|IFM_10G_LR, "10GbaseLR" }, \
  373. { IFM_ETHER|IFM_10G_LR, "10GLR" }, \
  374. { IFM_ETHER|IFM_10G_LR, "10GBASE-LR" }, \
  375. { IFM_ETHER|IFM_10G_SR, "10GbaseSR" }, \
  376. { IFM_ETHER|IFM_10G_SR, "10GSR" }, \
  377. { IFM_ETHER|IFM_10G_SR, "10GBASE-SR" }, \
  378. { IFM_ETHER|IFM_10G_CX4, "10GbaseCX4" }, \
  379. { IFM_ETHER|IFM_10G_CX4, "10GCX4" }, \
  380. { IFM_ETHER|IFM_10G_CX4, "10GBASE-CX4" }, \
  381. { IFM_ETHER|IFM_2500_SX, "2500baseSX" }, \
  382. { IFM_ETHER|IFM_2500_SX, "2500SX" }, \
  383. { IFM_ETHER|IFM_10G_T, "10GbaseT" }, \
  384. { IFM_ETHER|IFM_10G_T, "10GT" }, \
  385. { IFM_ETHER|IFM_10G_T, "10GBASE-T" }, \
  386. { IFM_ETHER|IFM_10G_SFP_CU, "10GSFP+Cu" }, \
  387. { IFM_ETHER|IFM_10G_SFP_CU, "10GCu" }, \
  388. \
  389. { IFM_FDDI|IFM_FDDI_SMF, "Single-mode" }, \
  390. { IFM_FDDI|IFM_FDDI_SMF, "SMF" }, \
  391. { IFM_FDDI|IFM_FDDI_MMF, "Multi-mode" }, \
  392. { IFM_FDDI|IFM_FDDI_MMF, "MMF" }, \
  393. { IFM_FDDI|IFM_FDDI_UTP, "UTP" }, \
  394. { IFM_FDDI|IFM_FDDI_UTP, "CDDI" }, \
  395. \
  396. { IFM_IEEE80211|IFM_IEEE80211_FH1, "FH1" }, \
  397. { IFM_IEEE80211|IFM_IEEE80211_FH2, "FH2" }, \
  398. { IFM_IEEE80211|IFM_IEEE80211_DS2, "DS2" }, \
  399. { IFM_IEEE80211|IFM_IEEE80211_DS5, "DS5" }, \
  400. { IFM_IEEE80211|IFM_IEEE80211_DS11, "DS11" }, \
  401. { IFM_IEEE80211|IFM_IEEE80211_DS1, "DS1" }, \
  402. { IFM_IEEE80211|IFM_IEEE80211_DS22, "DS22" }, \
  403. { IFM_IEEE80211|IFM_IEEE80211_OFDM6, "OFDM6" }, \
  404. { IFM_IEEE80211|IFM_IEEE80211_OFDM9, "OFDM9" }, \
  405. { IFM_IEEE80211|IFM_IEEE80211_OFDM12, "OFDM12" }, \
  406. { IFM_IEEE80211|IFM_IEEE80211_OFDM18, "OFDM18" }, \
  407. { IFM_IEEE80211|IFM_IEEE80211_OFDM24, "OFDM24" }, \
  408. { IFM_IEEE80211|IFM_IEEE80211_OFDM36, "OFDM36" }, \
  409. { IFM_IEEE80211|IFM_IEEE80211_OFDM48, "OFDM48" }, \
  410. { IFM_IEEE80211|IFM_IEEE80211_OFDM54, "OFDM54" }, \
  411. { IFM_IEEE80211|IFM_IEEE80211_OFDM72, "OFDM72" }, \
  412. \
  413. { IFM_TDM|IFM_TDM_T1, "t1" }, \
  414. { IFM_TDM|IFM_TDM_T1_AMI, "t1-ami" }, \
  415. { IFM_TDM|IFM_TDM_E1, "e1" }, \
  416. { IFM_TDM|IFM_TDM_E1_G704, "e1-g.704" }, \
  417. { IFM_TDM|IFM_TDM_E1_AMI, "e1-ami" }, \
  418. { IFM_TDM|IFM_TDM_E1_AMI_G704, "e1-ami-g.704" }, \
  419. { IFM_TDM|IFM_TDM_T3, "t3" }, \
  420. { IFM_TDM|IFM_TDM_T3_M13, "t3-m13" }, \
  421. { IFM_TDM|IFM_TDM_E3, "e3" }, \
  422. { IFM_TDM|IFM_TDM_E3_G751, "e3-g.751" }, \
  423. { IFM_TDM|IFM_TDM_E3_G832, "e3-g.832" }, \
  424. { IFM_TDM|IFM_TDM_E1_G704_CRC4, "e1-g.704-crc4" }, \
  425. \
  426. { 0, NULL }, \
  427. }
  428. #define IFM_MODE_DESCRIPTIONS { \
  429. { IFM_AUTO, "autoselect" }, \
  430. { IFM_AUTO, "auto" }, \
  431. { IFM_IEEE80211|IFM_IEEE80211_11A, "11a" }, \
  432. { IFM_IEEE80211|IFM_IEEE80211_11B, "11b" }, \
  433. { IFM_IEEE80211|IFM_IEEE80211_11G, "11g" }, \
  434. { IFM_IEEE80211|IFM_IEEE80211_FH, "fh" }, \
  435. { IFM_TDM|IFM_TDM_MASTER, "master" }, \
  436. { 0, NULL }, \
  437. }
  438. #define IFM_OPTION_DESCRIPTIONS { \
  439. { IFM_FDX, "full-duplex" }, \
  440. { IFM_FDX, "fdx" }, \
  441. { IFM_HDX, "half-duplex" }, \
  442. { IFM_HDX, "hdx" }, \
  443. { IFM_FLAG0, "flag0" }, \
  444. { IFM_FLAG1, "flag1" }, \
  445. { IFM_FLAG2, "flag2" }, \
  446. { IFM_LOOP, "loopback" }, \
  447. { IFM_LOOP, "hw-loopback"}, \
  448. { IFM_LOOP, "loop" }, \
  449. \
  450. { IFM_ETHER|IFM_ETH_MASTER, "master" }, \
  451. { IFM_ETHER|IFM_ETH_RXPAUSE, "rxpause" }, \
  452. { IFM_ETHER|IFM_ETH_TXPAUSE, "txpause" }, \
  453. \
  454. { IFM_FDDI|IFM_FDDI_DA, "dual-attach" }, \
  455. { IFM_FDDI|IFM_FDDI_DA, "das" }, \
  456. \
  457. { IFM_IEEE80211|IFM_IEEE80211_ADHOC, "adhoc" }, \
  458. { IFM_IEEE80211|IFM_IEEE80211_HOSTAP, "hostap" }, \
  459. { IFM_IEEE80211|IFM_IEEE80211_IBSS, "ibss" }, \
  460. { IFM_IEEE80211|IFM_IEEE80211_IBSSMASTER, "ibss-master" }, \
  461. { IFM_IEEE80211|IFM_IEEE80211_MONITOR, "monitor" }, \
  462. { IFM_IEEE80211|IFM_IEEE80211_TURBO, "turbo" }, \
  463. \
  464. { IFM_TDM|IFM_TDM_HDLC_CRC16, "hdlc-crc16" }, \
  465. { IFM_TDM|IFM_TDM_PPP, "ppp" }, \
  466. { IFM_TDM|IFM_TDM_FR_ANSI, "framerelay-ansi" }, \
  467. { IFM_TDM|IFM_TDM_FR_CISCO, "framerelay-cisco" }, \
  468. { IFM_TDM|IFM_TDM_FR_ANSI, "framerelay-itu" }, \
  469. \
  470. { 0, NULL }, \
  471. }
  472. /*
  473. * Baudrate descriptions for the various media types.
  474. */
  475. struct ifmedia_baudrate {
  476. int ifmb_word; /* media word */
  477. u_int64_t ifmb_baudrate; /* corresponding baudrate */
  478. };
  479. #define IFM_BAUDRATE_DESCRIPTIONS { \
  480. { IFM_ETHER|IFM_10_T, IF_Mbps(10) }, \
  481. { IFM_ETHER|IFM_10_2, IF_Mbps(10) }, \
  482. { IFM_ETHER|IFM_10_5, IF_Mbps(10) }, \
  483. { IFM_ETHER|IFM_100_TX, IF_Mbps(100) }, \
  484. { IFM_ETHER|IFM_100_FX, IF_Mbps(100) }, \
  485. { IFM_ETHER|IFM_100_T4, IF_Mbps(100) }, \
  486. { IFM_ETHER|IFM_100_VG, IF_Mbps(100) }, \
  487. { IFM_ETHER|IFM_100_T2, IF_Mbps(100) }, \
  488. { IFM_ETHER|IFM_1000_SX, IF_Mbps(1000) }, \
  489. { IFM_ETHER|IFM_10_STP, IF_Mbps(10) }, \
  490. { IFM_ETHER|IFM_10_FL, IF_Mbps(10) }, \
  491. { IFM_ETHER|IFM_1000_LX, IF_Mbps(1000) }, \
  492. { IFM_ETHER|IFM_1000_CX, IF_Mbps(1000) }, \
  493. { IFM_ETHER|IFM_1000_T, IF_Mbps(1000) }, \
  494. { IFM_ETHER|IFM_HPNA_1, IF_Mbps(1) }, \
  495. { IFM_ETHER|IFM_10G_LR, IF_Gbps(10) }, \
  496. { IFM_ETHER|IFM_10G_SR, IF_Gbps(10) }, \
  497. { IFM_ETHER|IFM_10G_CX4, IF_Gbps(10) }, \
  498. { IFM_ETHER|IFM_2500_SX, IF_Mbps(2500) }, \
  499. { IFM_ETHER|IFM_10G_T, IF_Gbps(10) }, \
  500. { IFM_ETHER|IFM_10G_SFP_CU, IF_Gbps(10) }, \
  501. \
  502. { IFM_FDDI|IFM_FDDI_SMF, IF_Mbps(100) }, \
  503. { IFM_FDDI|IFM_FDDI_MMF, IF_Mbps(100) }, \
  504. { IFM_FDDI|IFM_FDDI_UTP, IF_Mbps(100) }, \
  505. \
  506. { IFM_IEEE80211|IFM_IEEE80211_FH1, IF_Mbps(1) }, \
  507. { IFM_IEEE80211|IFM_IEEE80211_FH2, IF_Mbps(2) }, \
  508. { IFM_IEEE80211|IFM_IEEE80211_DS1, IF_Mbps(1) }, \
  509. { IFM_IEEE80211|IFM_IEEE80211_DS2, IF_Mbps(2) }, \
  510. { IFM_IEEE80211|IFM_IEEE80211_DS5, IF_Mbps(5) }, \
  511. { IFM_IEEE80211|IFM_IEEE80211_DS11, IF_Mbps(11) }, \
  512. { IFM_IEEE80211|IFM_IEEE80211_DS22, IF_Mbps(22) }, \
  513. { IFM_IEEE80211|IFM_IEEE80211_OFDM6, IF_Mbps(6) }, \
  514. { IFM_IEEE80211|IFM_IEEE80211_OFDM9, IF_Mbps(9) }, \
  515. { IFM_IEEE80211|IFM_IEEE80211_OFDM12, IF_Mbps(12) }, \
  516. { IFM_IEEE80211|IFM_IEEE80211_OFDM18, IF_Mbps(18) }, \
  517. { IFM_IEEE80211|IFM_IEEE80211_OFDM24, IF_Mbps(24) }, \
  518. { IFM_IEEE80211|IFM_IEEE80211_OFDM36, IF_Mbps(36) }, \
  519. { IFM_IEEE80211|IFM_IEEE80211_OFDM48, IF_Mbps(48) }, \
  520. { IFM_IEEE80211|IFM_IEEE80211_OFDM54, IF_Mbps(54) }, \
  521. { IFM_IEEE80211|IFM_IEEE80211_OFDM72, IF_Mbps(72) }, \
  522. \
  523. { IFM_TDM|IFM_TDM_T1, IF_Kbps(1536) }, \
  524. { IFM_TDM|IFM_TDM_T1_AMI, IF_Kbps(1536) }, \
  525. { IFM_TDM|IFM_TDM_E1, IF_Kbps(2048) }, \
  526. { IFM_TDM|IFM_TDM_E1_G704, IF_Kbps(2048) }, \
  527. { IFM_TDM|IFM_TDM_E1_AMI, IF_Kbps(2048) }, \
  528. { IFM_TDM|IFM_TDM_E1_AMI_G704, IF_Kbps(2048) }, \
  529. { IFM_TDM|IFM_TDM_T3, IF_Kbps(44736) }, \
  530. { IFM_TDM|IFM_TDM_T3_M13, IF_Kbps(44736) }, \
  531. { IFM_TDM|IFM_TDM_E3, IF_Kbps(34368) }, \
  532. { IFM_TDM|IFM_TDM_E3_G751, IF_Kbps(34368) }, \
  533. { IFM_TDM|IFM_TDM_E3_G832, IF_Kbps(34368) }, \
  534. { IFM_TDM|IFM_TDM_E1_G704_CRC4, IF_Kbps(2048) }, \
  535. \
  536. { 0, 0 }, \
  537. }
  538. /*
  539. * Status bit descriptions for the various media types.
  540. */
  541. struct ifmedia_status_description {
  542. int ifms_type;
  543. int ifms_valid;
  544. int ifms_bit;
  545. const char *ifms_string[2];
  546. };
  547. #define IFM_STATUS_DESC(ifms, bit) \
  548. (ifms)->ifms_string[((ifms)->ifms_bit & (bit)) ? 1 : 0]
  549. #define IFM_STATUS_DESCRIPTIONS { \
  550. { IFM_ETHER, IFM_AVALID, IFM_ACTIVE, \
  551. { "no carrier", "active" } }, \
  552. { IFM_FDDI, IFM_AVALID, IFM_ACTIVE, \
  553. { "no ring", "inserted" } }, \
  554. { IFM_IEEE80211, IFM_AVALID, IFM_ACTIVE, \
  555. { "no network", "active" } }, \
  556. { IFM_TDM, IFM_AVALID, IFM_ACTIVE, \
  557. { "no carrier", "active" } }, \
  558. { IFM_CARP, IFM_AVALID, IFM_ACTIVE, \
  559. { "backup", "master" } }, \
  560. { 0, 0, 0, \
  561. { NULL, NULL } } \
  562. }
  563. #endif /* _NET_IF_MEDIA_H_ */