1 /*!\file net/if_media.h
2 * Network interface media selection.
5 /* $NetBSD: if_media.h,v 1.3 1997/03/26 01:19:27 thorpej Exp $ */
9 * Jonathan Stone and Jason R. Thorpe. All rights reserved.
11 * This software is derived from information provided by Matt Thomas.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by Jonathan Stone
24 * and Jason R. Thorpe for the NetBSD Project.
25 * 4. The names of the authors may not be used to endorse or promote products
26 * derived from this software without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
29 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
31 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
35 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 #ifndef __NET_IF_MEDIA_H
42 #define __NET_IF_MEDIA_H
45 * Prototypes and definitions for BSD/OS-compatible network interface
48 * Where it is safe to do so, this code strays slightly from the BSD/OS
49 * design. Software which uses the API (device drivers, basically)
50 * shouldn't notice any difference.
52 * Many thanks to Matt Thomas for providing the information necessary
53 * to implement this interface.
58 * if_media Options word:
64 * 8-15 Type specific options
66 * 20-27 Shared (global) options
73 #define IFM_ETHER 0x00000020
74 #define IFM_10_T 3 /* 10BaseT - RJ45 */
75 #define IFM_10_2 4 /* 10Base2 - Thinnet */
76 #define IFM_10_5 5 /* 10Base5 - AUI */
77 #define IFM_100_TX 6 /* 100BaseTX - RJ45 */
78 #define IFM_100_FX 7 /* 100BaseFX - Fiber */
79 #define IFM_100_T4 8 /* 100BaseT4 - 4 pair cat 3 */
80 #define IFM_100_VG 9 /* 100VG-AnyLAN */
81 #define IFM_100_T2 10 /* 100BaseT2 */
86 #define IFM_TOKEN 0x00000040
87 #define IFM_TOK_STP4 3 /* Shielded twisted pair 4m - DB9 */
88 #define IFM_TOK_STP16 4 /* Shielded twisted pair 16m - DB9 */
89 #define IFM_TOK_UTP4 5 /* Unshielded twisted pair 4m - RJ45 */
90 #define IFM_TOK_UTP16 6 /* Unshielded twisted pair 16m - RJ45 */
91 #define IFM_TOK_ETR 0x00000200 /* Early token release */
92 #define IFM_TOK_SRCRT 0x00000400 /* Enable source routing features */
93 #define IFM_TOK_ALLR 0x00000800 /* All routes / Single route bcast */
98 #define IFM_FDDI 0x00000060
99 #define IFM_FDDI_SMF 3 /* Single-mode fiber */
100 #define IFM_FDDI_MMF 4 /* Multi-mode fiber */
101 #define IFM_FDDI_UTP 5 /* CDDI / UTP */
102 #define IFM_FDDI_DA 0x00000100 /* Dual attach / single attach */
105 * Shared media sub-types
107 #define IFM_AUTO 0 /* Autoselect best media */
108 #define IFM_MANUAL 1 /* Jumper/dipswitch selects media */
109 #define IFM_NONE 2 /* Deselect all media */
114 #define IFM_FDX 0x00100000 /* Force full duplex */
115 #define IFM_HDX 0x00200000 /* Force half duplex */
116 #define IFM_FLAG0 0x01000000 /* Driver defined flag */
117 #define IFM_FLAG1 0x02000000 /* Driver defined flag */
118 #define IFM_FLAG2 0x04000000 /* Driver defined flag */
119 #define IFM_LOOP 0x08000000 /* Put hardware in loopback */
124 #define IFM_NMASK 0x000000e0 /* Network type */
125 #define IFM_TMASK 0x0000000f /* Media sub-type */
126 #define IFM_IMASK 0xf0000000 /* Instance */
127 #define IFM_ISHIFT 28 /* Instance shift */
128 #define IFM_OMASK 0x0000ff00 /* Type specific options */
129 #define IFM_GMASK 0x0ff00000 /* Global options */
134 #define IFM_AVALID 0x00000001 /* Active bit valid */
135 #define IFM_ACTIVE 0x00000002 /* Interface attached to working net */
138 * Macros to extract various bits of information from the media word.
140 #define IFM_TYPE(x) ((x) & IFM_NMASK)
141 #define IFM_SUBTYPE(x) ((x) & IFM_TMASK)
142 #define IFM_INST(x) (((x) & IFM_IMASK) >> IFM_ISHIFT)
145 * NetBSD extension not defined in the BSDI API. This is used in various
146 * places to get the canonical description for a given type/subtype.
148 * NOTE: all but the top-level type descriptions must contain NO whitespace!
149 * Otherwise, parsing these in ifconfig(8) would be a nightmare.
151 struct ifmedia_description {
152 int ifmt_word; /* word value; may be masked */
153 const char *ifmt_string; /* description */
156 #define IFM_TYPE_DESCRIPTIONS { \
157 { IFM_ETHER, "Ethernet" }, \
158 { IFM_TOKEN, "Token ring" }, \
159 { IFM_FDDI, "FDDI" }, \
163 #define IFM_SUBTYPE_ETHERNET_DESCRIPTIONS { \
164 { IFM_10_T, "10baseT/UTP" }, \
165 { IFM_10_2, "10base2/BNC" }, \
166 { IFM_10_5, "10base5/AUI" }, \
167 { IFM_100_TX, "100baseTX" }, \
168 { IFM_100_FX, "100baseFX" }, \
169 { IFM_100_T4, "100baseT4" }, \
170 { IFM_100_VG, "100baseVG" }, \
171 { IFM_100_T2, "100baseT2" }, \
175 #define IFM_SUBTYPE_ETHERNET_ALIASES { \
176 { IFM_10_T, "UTP" }, \
177 { IFM_10_T, "10UTP" }, \
178 { IFM_10_2, "BNC" }, \
179 { IFM_10_2, "10BNC" }, \
180 { IFM_10_5, "AUI" }, \
181 { IFM_10_5, "10AUI" }, \
182 { IFM_100_TX, "100TX" }, \
183 { IFM_100_FX, "100FX" }, \
184 { IFM_100_T4, "100T4" }, \
185 { IFM_100_VG, "100VG" }, \
186 { IFM_100_T2, "100T2" }, \
190 #define IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS { \
194 #define IFM_SUBTYPE_TOKENRING_DESCRIPTIONS { \
195 { IFM_TOK_STP4, "DB9/4Mbit" }, \
196 { IFM_TOK_STP16, "DB9/16Mbit" }, \
197 { IFM_TOK_UTP4, "UTP/4Mbit" }, \
198 { IFM_TOK_UTP16, "UTP/16Mbit" }, \
202 #define IFM_SUBTYPE_TOKENRING_ALIASES { \
203 { IFM_TOK_STP4, "4STP" }, \
204 { IFM_TOK_STP16, "16STP" }, \
205 { IFM_TOK_UTP4, "4UTP" }, \
206 { IFM_TOK_UTP16, "16UTP" }, \
210 #define IFM_SUBTYPE_TOKENRING_OPTION_DESCRIPTIONS { \
211 { IFM_TOK_ETR, "EarlyTokenRelease" }, \
212 { IFM_TOK_SRCRT, "SourceRouting" }, \
213 { IFM_TOK_ALLR, "AllRoutes" }, \
217 #define IFM_SUBTYPE_FDDI_DESCRIPTIONS { \
218 { IFM_FDDI_SMF, "Single-mode" }, \
219 { IFM_FDDI_MMF, "Multi-mode" }, \
220 { IFM_FDDI_UTP, "UTP" }, \
224 #define IFM_SUBTYPE_FDDI_ALIASES { \
225 { IFM_FDDI_SMF, "SMF" }, \
226 { IFM_FDDI_MMF, "MMF" }, \
227 { IFM_FDDI_UTP, "CDDI" }, \
231 #define IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS { \
232 { IFM_FDDI_DA, "Dual-attach" }, \
236 #define IFM_SUBTYPE_SHARED_DESCRIPTIONS { \
237 { IFM_AUTO, "autoselect" }, \
238 { IFM_MANUAL, "manual" }, \
239 { IFM_NONE, "none" }, \
243 #define IFM_SUBTYPE_SHARED_ALIASES { \
244 { IFM_AUTO, "auto" }, \
248 #define IFM_SHARED_OPTION_DESCRIPTIONS { \
249 { IFM_FDX, "full-duplex" }, \
250 { IFM_HDX, "half-duplex" }, \
251 { IFM_FLAG0, "flag0" }, \
252 { IFM_FLAG1, "flag1" }, \
253 { IFM_FLAG2, "flag2" }, \
254 { IFM_LOOP, "hw-loopback" }, \