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