xref: /freebsd/sys/net/if_media.h (revision d09c5f16b069577f843236706c04017264977743)
1f94bb788SPeter Wemm /*	$NetBSD: if_media.h,v 1.3 1997/03/26 01:19:27 thorpej Exp $	*/
2c3aac50fSPeter Wemm /* $FreeBSD$ */
3f94bb788SPeter Wemm 
4c398230bSWarner Losh /*-
5f94bb788SPeter Wemm  * Copyright (c) 1997
6f94bb788SPeter Wemm  *	Jonathan Stone and Jason R. Thorpe.  All rights reserved.
7f94bb788SPeter Wemm  *
8f94bb788SPeter Wemm  * This software is derived from information provided by Matt Thomas.
9f94bb788SPeter Wemm  *
10f94bb788SPeter Wemm  * Redistribution and use in source and binary forms, with or without
11f94bb788SPeter Wemm  * modification, are permitted provided that the following conditions
12f94bb788SPeter Wemm  * are met:
13f94bb788SPeter Wemm  * 1. Redistributions of source code must retain the above copyright
14f94bb788SPeter Wemm  *    notice, this list of conditions and the following disclaimer.
15f94bb788SPeter Wemm  * 2. Redistributions in binary form must reproduce the above copyright
16f94bb788SPeter Wemm  *    notice, this list of conditions and the following disclaimer in the
17f94bb788SPeter Wemm  *    documentation and/or other materials provided with the distribution.
18f94bb788SPeter Wemm  * 3. All advertising materials mentioning features or use of this software
19f94bb788SPeter Wemm  *    must display the following acknowledgement:
20f94bb788SPeter Wemm  *	This product includes software developed by Jonathan Stone
21f94bb788SPeter Wemm  *	and Jason R. Thorpe for the NetBSD Project.
22f94bb788SPeter Wemm  * 4. The names of the authors may not be used to endorse or promote products
23f94bb788SPeter Wemm  *    derived from this software without specific prior written permission.
24f94bb788SPeter Wemm  *
25f94bb788SPeter Wemm  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
26f94bb788SPeter Wemm  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27f94bb788SPeter Wemm  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28f94bb788SPeter Wemm  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
29f94bb788SPeter Wemm  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30f94bb788SPeter Wemm  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31f94bb788SPeter Wemm  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
32f94bb788SPeter Wemm  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33f94bb788SPeter Wemm  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34f94bb788SPeter Wemm  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35f94bb788SPeter Wemm  * SUCH DAMAGE.
36f94bb788SPeter Wemm  */
37f94bb788SPeter Wemm 
38f94bb788SPeter Wemm #ifndef _NET_IF_MEDIA_H_
39f94bb788SPeter Wemm #define	_NET_IF_MEDIA_H_
40f94bb788SPeter Wemm 
41f94bb788SPeter Wemm /*
42f94bb788SPeter Wemm  * Prototypes and definitions for BSD/OS-compatible network interface
43f94bb788SPeter Wemm  * media selection.
44f94bb788SPeter Wemm  *
45f94bb788SPeter Wemm  * Where it is safe to do so, this code strays slightly from the BSD/OS
46f94bb788SPeter Wemm  * design.  Software which uses the API (device drivers, basically)
47f94bb788SPeter Wemm  * shouldn't notice any difference.
48f94bb788SPeter Wemm  *
49f94bb788SPeter Wemm  * Many thanks to Matt Thomas for providing the information necessary
50f94bb788SPeter Wemm  * to implement this interface.
51f94bb788SPeter Wemm  */
52f94bb788SPeter Wemm 
53664a31e4SPeter Wemm #ifdef _KERNEL
54f94bb788SPeter Wemm 
55f94bb788SPeter Wemm #include <sys/queue.h>
56f94bb788SPeter Wemm 
57f94bb788SPeter Wemm /*
58f94bb788SPeter Wemm  * Driver callbacks for media status and change requests.
59f94bb788SPeter Wemm  */
60929ddbbbSAlfred Perlstein typedef	int (*ifm_change_cb_t)(struct ifnet *ifp);
61929ddbbbSAlfred Perlstein typedef	void (*ifm_stat_cb_t)(struct ifnet *ifp, struct ifmediareq *req);
62f94bb788SPeter Wemm 
63f94bb788SPeter Wemm /*
64f94bb788SPeter Wemm  * In-kernel representation of a single supported media type.
65f94bb788SPeter Wemm  */
66f94bb788SPeter Wemm struct ifmedia_entry {
67e3975643SJake Burkholder 	LIST_ENTRY(ifmedia_entry) ifm_list;
68f94bb788SPeter Wemm 	int	ifm_media;	/* description of this media attachment */
69f94bb788SPeter Wemm 	int	ifm_data;	/* for driver-specific use */
70f94bb788SPeter Wemm 	void	*ifm_aux;	/* for driver-specific use */
71f94bb788SPeter Wemm };
72f94bb788SPeter Wemm 
73f94bb788SPeter Wemm /*
74f94bb788SPeter Wemm  * One of these goes into a network interface's softc structure.
75f94bb788SPeter Wemm  * It is used to keep general media state.
76f94bb788SPeter Wemm  */
77f94bb788SPeter Wemm struct ifmedia {
78f94bb788SPeter Wemm 	int	ifm_mask;	/* mask of changes we don't care about */
79f94bb788SPeter Wemm 	int	ifm_media;	/* current user-set media word */
80f94bb788SPeter Wemm 	struct ifmedia_entry *ifm_cur;	/* currently selected media */
81e3975643SJake Burkholder 	LIST_HEAD(, ifmedia_entry) ifm_list; /* list of all supported media */
82f94bb788SPeter Wemm 	ifm_change_cb_t	ifm_change;	/* media change driver callback */
83f94bb788SPeter Wemm 	ifm_stat_cb_t	ifm_status;	/* media status driver callback */
84f94bb788SPeter Wemm };
85f94bb788SPeter Wemm 
86f94bb788SPeter Wemm /* Initialize an interface's struct if_media field. */
87929ddbbbSAlfred Perlstein void	ifmedia_init(struct ifmedia *ifm, int dontcare_mask,
88929ddbbbSAlfred Perlstein 	    ifm_change_cb_t change_callback, ifm_stat_cb_t status_callback);
89f94bb788SPeter Wemm 
906182fdbdSPeter Wemm /* Remove all mediums from a struct ifmedia.  */
91929ddbbbSAlfred Perlstein void	ifmedia_removeall( struct ifmedia *ifm);
926182fdbdSPeter Wemm 
93f94bb788SPeter Wemm /* Add one supported medium to a struct ifmedia. */
94929ddbbbSAlfred Perlstein void	ifmedia_add(struct ifmedia *ifm, int mword, int data, void *aux);
95f94bb788SPeter Wemm 
96f94bb788SPeter Wemm /* Add an array (of ifmedia_entry) media to a struct ifmedia. */
97f94bb788SPeter Wemm void	ifmedia_list_add(struct ifmedia *mp, struct ifmedia_entry *lp,
98f94bb788SPeter Wemm 	    int count);
99f94bb788SPeter Wemm 
100f94bb788SPeter Wemm /* Set default media type on initialization. */
101929ddbbbSAlfred Perlstein void	ifmedia_set(struct ifmedia *ifm, int mword);
102f94bb788SPeter Wemm 
103f94bb788SPeter Wemm /* Common ioctl function for getting/setting media, called by driver. */
104929ddbbbSAlfred Perlstein int	ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr,
105929ddbbbSAlfred Perlstein 	    struct ifmedia *ifm, u_long cmd);
106f94bb788SPeter Wemm 
107efd19b8fSGleb Smirnoff /* Compute baudrate for a given media. */
108efd19b8fSGleb Smirnoff uint64_t	ifmedia_baudrate(int);
109efd19b8fSGleb Smirnoff 
110664a31e4SPeter Wemm #endif /*_KERNEL */
111f94bb788SPeter Wemm 
112f94bb788SPeter Wemm /*
113f94bb788SPeter Wemm  * if_media Options word:
114f94bb788SPeter Wemm  *	Bits	Use
115f94bb788SPeter Wemm  *	----	-------
11662811dadSJulian Elischer  *	0-4	Media variant
117f94bb788SPeter Wemm  *	5-7	Media type
118f94bb788SPeter Wemm  *	8-15	Type specific options
1191311709aSSam Leffler  *	16-18	Mode (for multi-mode devices)
1201311709aSSam Leffler  *	19	RFU
121f94bb788SPeter Wemm  *	20-27	Shared (global) options
122f94bb788SPeter Wemm  *	28-31	Instance
123f94bb788SPeter Wemm  */
124f94bb788SPeter Wemm 
125f94bb788SPeter Wemm /*
126f94bb788SPeter Wemm  * Ethernet
127f94bb788SPeter Wemm  */
128f94bb788SPeter Wemm #define	IFM_ETHER	0x00000020
129f94bb788SPeter Wemm #define	IFM_10_T	3		/* 10BaseT - RJ45 */
130f94bb788SPeter Wemm #define	IFM_10_2	4		/* 10Base2 - Thinnet */
131f94bb788SPeter Wemm #define	IFM_10_5	5		/* 10Base5 - AUI */
132f94bb788SPeter Wemm #define	IFM_100_TX	6		/* 100BaseTX - RJ45 */
133f94bb788SPeter Wemm #define	IFM_100_FX	7		/* 100BaseFX - Fiber */
134f94bb788SPeter Wemm #define	IFM_100_T4	8		/* 100BaseT4 - 4 pair cat 3 */
135f94bb788SPeter Wemm #define	IFM_100_VG	9		/* 100VG-AnyLAN */
136f94bb788SPeter Wemm #define	IFM_100_T2	10		/* 100BaseT2 */
13745521525SPoul-Henning Kamp #define	IFM_1000_SX	11		/* 1000BaseSX - multi-mode fiber */
13827ab138fSBill Paul #define	IFM_10_STP	12		/* 10BaseT over shielded TP */
13945521525SPoul-Henning Kamp #define	IFM_10_FL	13		/* 10BaseFL - Fiber */
14045521525SPoul-Henning Kamp #define	IFM_1000_LX	14		/* 1000baseLX - single-mode fiber */
14145521525SPoul-Henning Kamp #define	IFM_1000_CX	15		/* 1000baseCX - 150ohm STP */
14245521525SPoul-Henning Kamp #define	IFM_1000_T	16		/* 1000baseT - 4 pair cat 5 */
14345521525SPoul-Henning Kamp #define	IFM_HPNA_1	17		/* HomePNA 1.0 (1Mb/s) */
144efd19b8fSGleb Smirnoff #define	IFM_10G_LR	18		/* 10GBase-LR 1310nm Single-mode */
145efd19b8fSGleb Smirnoff #define	IFM_10G_SR	19		/* 10GBase-SR 850nm Multi-mode */
1464ec449aeSGleb Smirnoff #define	IFM_10G_CX4	20		/* 10GBase CX4 copper */
147051e7561SDavid Christensen #define	IFM_2500_SX	21		/* 2500BaseSX - multi-mode fiber */
148a6c8d997SGeorge V. Neville-Neil #define	IFM_10G_TWINAX	22		/* 10GBase Twinax copper */
149a6c8d997SGeorge V. Neville-Neil #define	IFM_10G_TWINAX_LONG	23	/* 10GBase Twinax Long copper */
150a6c8d997SGeorge V. Neville-Neil #define	IFM_10G_LRM	24		/* 10GBase-LRM 850nm Multi-mode */
15152d9cb12SNavdeep Parhar #define	IFM_UNKNOWN	25		/* media types not defined yet */
152456ae550SNavdeep Parhar #define	IFM_10G_T	26		/* 10GBase-T - RJ45 */
153a6c8d997SGeorge V. Neville-Neil 
15462811dadSJulian Elischer /* note 31 is the max! */
155f94bb788SPeter Wemm 
15645521525SPoul-Henning Kamp #define	IFM_ETH_MASTER	0x00000100	/* master mode (1000baseT) */
157efd4fc3fSMarius Strobl #define	IFM_ETH_RXPAUSE	0x00000200	/* receive PAUSE frames */
158efd4fc3fSMarius Strobl #define	IFM_ETH_TXPAUSE	0x00000400	/* transmit PAUSE frames */
15945521525SPoul-Henning Kamp 
160f94bb788SPeter Wemm /*
161f94bb788SPeter Wemm  * Token ring
162f94bb788SPeter Wemm  */
163f94bb788SPeter Wemm #define	IFM_TOKEN	0x00000040
164f94bb788SPeter Wemm #define	IFM_TOK_STP4	3		/* Shielded twisted pair 4m - DB9 */
165f94bb788SPeter Wemm #define	IFM_TOK_STP16	4		/* Shielded twisted pair 16m - DB9 */
166f94bb788SPeter Wemm #define	IFM_TOK_UTP4	5		/* Unshielded twisted pair 4m - RJ45 */
167f94bb788SPeter Wemm #define	IFM_TOK_UTP16	6		/* Unshielded twisted pair 16m - RJ45 */
168722012ccSJulian Elischer #define	IFM_TOK_STP100  7		/* Shielded twisted pair 100m - DB9 */
169722012ccSJulian Elischer #define	IFM_TOK_UTP100  8		/* Unshielded twisted pair 100m - RJ45 */
170f94bb788SPeter Wemm #define	IFM_TOK_ETR	0x00000200	/* Early token release */
171f94bb788SPeter Wemm #define	IFM_TOK_SRCRT	0x00000400	/* Enable source routing features */
172f94bb788SPeter Wemm #define	IFM_TOK_ALLR	0x00000800	/* All routes / Single route bcast */
173722012ccSJulian Elischer #define	IFM_TOK_DTR	0x00002000	/* Dedicated token ring */
174722012ccSJulian Elischer #define	IFM_TOK_CLASSIC	0x00004000	/* Classic token ring */
175722012ccSJulian Elischer #define	IFM_TOK_AUTO	0x00008000	/* Automatic Dedicate/Classic token ring */
176f94bb788SPeter Wemm 
177f94bb788SPeter Wemm /*
178f94bb788SPeter Wemm  * FDDI
179f94bb788SPeter Wemm  */
180f94bb788SPeter Wemm #define	IFM_FDDI	0x00000060
181f94bb788SPeter Wemm #define	IFM_FDDI_SMF	3		/* Single-mode fiber */
182f94bb788SPeter Wemm #define	IFM_FDDI_MMF	4		/* Multi-mode fiber */
183f94bb788SPeter Wemm #define	IFM_FDDI_UTP	5		/* CDDI / UTP */
184f94bb788SPeter Wemm #define	IFM_FDDI_DA	0x00000100	/* Dual attach / single attach */
185f94bb788SPeter Wemm 
186f94bb788SPeter Wemm /*
187419d8080SPoul-Henning Kamp  * IEEE 802.11 Wireless
188419d8080SPoul-Henning Kamp  */
189419d8080SPoul-Henning Kamp #define	IFM_IEEE80211	0x00000080
1901311709aSSam Leffler /* NB: 0,1,2 are auto, manual, none defined below */
191419d8080SPoul-Henning Kamp #define	IFM_IEEE80211_FH1	3	/* Frequency Hopping 1Mbps */
192419d8080SPoul-Henning Kamp #define	IFM_IEEE80211_FH2	4	/* Frequency Hopping 2Mbps */
193419d8080SPoul-Henning Kamp #define	IFM_IEEE80211_DS1	5	/* Direct Sequence 1Mbps */
194419d8080SPoul-Henning Kamp #define	IFM_IEEE80211_DS2	6	/* Direct Sequence 2Mbps */
195419d8080SPoul-Henning Kamp #define	IFM_IEEE80211_DS5	7	/* Direct Sequence 5.5Mbps */
196419d8080SPoul-Henning Kamp #define	IFM_IEEE80211_DS11	8	/* Direct Sequence 11Mbps */
197419d8080SPoul-Henning Kamp #define	IFM_IEEE80211_DS22	9	/* Direct Sequence 22Mbps */
1981311709aSSam Leffler #define	IFM_IEEE80211_OFDM6	10	/* OFDM 6Mbps */
1991311709aSSam Leffler #define	IFM_IEEE80211_OFDM9	11	/* OFDM 9Mbps */
2001311709aSSam Leffler #define	IFM_IEEE80211_OFDM12	12	/* OFDM 12Mbps */
2011311709aSSam Leffler #define	IFM_IEEE80211_OFDM18	13	/* OFDM 18Mbps */
2021311709aSSam Leffler #define	IFM_IEEE80211_OFDM24	14	/* OFDM 24Mbps */
2031311709aSSam Leffler #define	IFM_IEEE80211_OFDM36	15	/* OFDM 36Mbps */
2041311709aSSam Leffler #define	IFM_IEEE80211_OFDM48	16	/* OFDM 48Mbps */
2051311709aSSam Leffler #define	IFM_IEEE80211_OFDM54	17	/* OFDM 54Mbps */
2061311709aSSam Leffler #define	IFM_IEEE80211_OFDM72	18	/* OFDM 72Mbps */
20794251138SMax Khon #define	IFM_IEEE80211_DS354k	19	/* Direct Sequence 354Kbps */
20894251138SMax Khon #define	IFM_IEEE80211_DS512k	20	/* Direct Sequence 512Kbps */
20941b3c790SSam Leffler #define	IFM_IEEE80211_OFDM3	21	/* OFDM 3Mbps */
21041b3c790SSam Leffler #define	IFM_IEEE80211_OFDM4	22	/* OFDM 4.5Mbps */
21141b3c790SSam Leffler #define	IFM_IEEE80211_OFDM27	23	/* OFDM 27Mbps */
21268e8e04eSSam Leffler /* NB: not enough bits to express MCS fully */
21368e8e04eSSam Leffler #define	IFM_IEEE80211_MCS	24	/* HT MCS rate */
2144844aa7dSAtsushi Onoe 
215419d8080SPoul-Henning Kamp #define	IFM_IEEE80211_ADHOC	0x00000100	/* Operate in Adhoc mode */
21673ce5facSWarner Losh #define	IFM_IEEE80211_HOSTAP	0x00000200	/* Operate in Host AP mode */
217f6462e80SWarner Losh #define	IFM_IEEE80211_IBSS	0x00000400	/* Operate in IBSS mode */
218acaf1de6SSam Leffler #define	IFM_IEEE80211_WDS	0x00000800	/* Operate in WDS mode */
2191311709aSSam Leffler #define	IFM_IEEE80211_TURBO	0x00001000	/* Operate in turbo mode */
2202bbe529dSSam Leffler #define	IFM_IEEE80211_MONITOR	0x00002000	/* Operate in monitor mode */
22159aa14a9SRui Paulo #define	IFM_IEEE80211_MBSS	0x00004000	/* Operate in MBSS mode */
2224844aa7dSAtsushi Onoe 
2231311709aSSam Leffler /* operating mode for multi-mode devices */
2244844aa7dSAtsushi Onoe #define	IFM_IEEE80211_11A	0x00010000	/* 5Ghz, OFDM mode */
2254844aa7dSAtsushi Onoe #define	IFM_IEEE80211_11B	0x00020000	/* Direct Sequence mode */
2264844aa7dSAtsushi Onoe #define	IFM_IEEE80211_11G	0x00030000	/* 2Ghz, CCK mode */
2274844aa7dSAtsushi Onoe #define	IFM_IEEE80211_FH	0x00040000	/* 2Ghz, GFSK mode */
22868e8e04eSSam Leffler #define	IFM_IEEE80211_11NA	0x00050000	/* 5Ghz, HT mode */
22968e8e04eSSam Leffler #define	IFM_IEEE80211_11NG	0x00060000	/* 2Ghz, HT mode */
230419d8080SPoul-Henning Kamp 
231419d8080SPoul-Henning Kamp /*
2322b75e097SHartmut Brandt  * ATM
2332b75e097SHartmut Brandt  */
2342b75e097SHartmut Brandt #define	IFM_ATM	0x000000a0
2352b75e097SHartmut Brandt #define	IFM_ATM_UNKNOWN		3
2362b75e097SHartmut Brandt #define	IFM_ATM_UTP_25		4
2372b75e097SHartmut Brandt #define	IFM_ATM_TAXI_100	5
2382b75e097SHartmut Brandt #define	IFM_ATM_TAXI_140	6
2392b75e097SHartmut Brandt #define	IFM_ATM_MM_155		7
2402b75e097SHartmut Brandt #define	IFM_ATM_SM_155		8
2412b75e097SHartmut Brandt #define	IFM_ATM_UTP_155		9
2422b75e097SHartmut Brandt #define	IFM_ATM_MM_622		10
2432b75e097SHartmut Brandt #define	IFM_ATM_SM_622		11
2446eadc708SHartmut Brandt #define	IFM_ATM_VIRTUAL		12
2452b75e097SHartmut Brandt #define	IFM_ATM_SDH		0x00000100	/* SDH instead of SONET */
2462b75e097SHartmut Brandt #define	IFM_ATM_NOSCRAMB	0x00000200	/* no scrambling */
2472b75e097SHartmut Brandt #define	IFM_ATM_UNASSIGNED	0x00000400	/* unassigned cells */
2482b75e097SHartmut Brandt 
2492b75e097SHartmut Brandt /*
250a9771948SGleb Smirnoff  * CARP Common Address Redundancy Protocol
251a9771948SGleb Smirnoff  */
252a9771948SGleb Smirnoff #define	IFM_CARP	0x000000c0
253a9771948SGleb Smirnoff 
254a9771948SGleb Smirnoff /*
255f94bb788SPeter Wemm  * Shared media sub-types
256f94bb788SPeter Wemm  */
257f94bb788SPeter Wemm #define	IFM_AUTO	0		/* Autoselect best media */
258f94bb788SPeter Wemm #define	IFM_MANUAL	1		/* Jumper/dipswitch selects media */
259f94bb788SPeter Wemm #define	IFM_NONE	2		/* Deselect all media */
260f94bb788SPeter Wemm 
261f94bb788SPeter Wemm /*
262f94bb788SPeter Wemm  * Shared options
263f94bb788SPeter Wemm  */
264f94bb788SPeter Wemm #define	IFM_FDX		0x00100000	/* Force full duplex */
265f94bb788SPeter Wemm #define	IFM_HDX		0x00200000	/* Force half duplex */
266efd4fc3fSMarius Strobl #define	IFM_FLOW	0x00400000	/* enable hardware flow control */
267f94bb788SPeter Wemm #define	IFM_FLAG0	0x01000000	/* Driver defined flag */
268f94bb788SPeter Wemm #define	IFM_FLAG1	0x02000000	/* Driver defined flag */
269f94bb788SPeter Wemm #define	IFM_FLAG2	0x04000000	/* Driver defined flag */
270f94bb788SPeter Wemm #define	IFM_LOOP	0x08000000	/* Put hardware in loopback */
271f94bb788SPeter Wemm 
272f94bb788SPeter Wemm /*
273f94bb788SPeter Wemm  * Masks
274f94bb788SPeter Wemm  */
275f94bb788SPeter Wemm #define	IFM_NMASK	0x000000e0	/* Network type */
27662811dadSJulian Elischer #define	IFM_TMASK	0x0000001f	/* Media sub-type */
277f94bb788SPeter Wemm #define	IFM_IMASK	0xf0000000	/* Instance */
278f94bb788SPeter Wemm #define	IFM_ISHIFT	28		/* Instance shift */
279f94bb788SPeter Wemm #define	IFM_OMASK	0x0000ff00	/* Type specific options */
2801311709aSSam Leffler #define	IFM_MMASK	0x00070000	/* Mode */
2811311709aSSam Leffler #define	IFM_MSHIFT	16		/* Mode shift */
282f94bb788SPeter Wemm #define	IFM_GMASK	0x0ff00000	/* Global options */
283f94bb788SPeter Wemm 
284efd4fc3fSMarius Strobl /* Ethernet flow control mask */
285efd4fc3fSMarius Strobl #define	IFM_ETH_FMASK	(IFM_FLOW | IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE)
286efd4fc3fSMarius Strobl 
287f94bb788SPeter Wemm /*
288f94bb788SPeter Wemm  * Status bits
289f94bb788SPeter Wemm  */
290f94bb788SPeter Wemm #define	IFM_AVALID	0x00000001	/* Active bit valid */
291f94bb788SPeter Wemm #define	IFM_ACTIVE	0x00000002	/* Interface attached to working net */
292f94bb788SPeter Wemm 
293e4bd8f10SAndre Oppermann /* Mask of "status valid" bits, for ifconfig(8). */
294e4bd8f10SAndre Oppermann #define	IFM_STATUS_VALID	IFM_AVALID
295e4bd8f10SAndre Oppermann 
296e4bd8f10SAndre Oppermann /* List of "status valid" bits, for ifconfig(8). */
297e4bd8f10SAndre Oppermann #define	IFM_STATUS_VALID_LIST {						\
298e4bd8f10SAndre Oppermann 	IFM_AVALID,							\
299e4bd8f10SAndre Oppermann 	0								\
300e4bd8f10SAndre Oppermann }
301e4bd8f10SAndre Oppermann 
302f94bb788SPeter Wemm /*
303f94bb788SPeter Wemm  * Macros to extract various bits of information from the media word.
304f94bb788SPeter Wemm  */
305f94bb788SPeter Wemm #define	IFM_TYPE(x)		((x) & IFM_NMASK)
306f94bb788SPeter Wemm #define	IFM_SUBTYPE(x)		((x) & IFM_TMASK)
307722012ccSJulian Elischer #define	IFM_TYPE_OPTIONS(x)	((x) & IFM_OMASK)
308f94bb788SPeter Wemm #define	IFM_INST(x)		(((x) & IFM_IMASK) >> IFM_ISHIFT)
30927ab138fSBill Paul #define	IFM_OPTIONS(x)		((x) & (IFM_OMASK | IFM_GMASK))
310c66380c1SAtsushi Onoe #define	IFM_MODE(x)		((x) & IFM_MMASK)
31127ab138fSBill Paul 
31227ab138fSBill Paul #define	IFM_INST_MAX		IFM_INST(IFM_IMASK)
31327ab138fSBill Paul 
31427ab138fSBill Paul /*
31527ab138fSBill Paul  * Macro to create a media word.
31627ab138fSBill Paul  */
31727ab138fSBill Paul #define	IFM_MAKEWORD(type, subtype, options, instance)			\
31827ab138fSBill Paul 	((type) | (subtype) | (options) | ((instance) << IFM_ISHIFT))
3191311709aSSam Leffler #define	IFM_MAKEMODE(mode) \
3201311709aSSam Leffler 	(((mode) << IFM_MSHIFT) & IFM_MMASK)
321f94bb788SPeter Wemm 
322f94bb788SPeter Wemm /*
323f94bb788SPeter Wemm  * NetBSD extension not defined in the BSDI API.  This is used in various
324f94bb788SPeter Wemm  * places to get the canonical description for a given type/subtype.
325f94bb788SPeter Wemm  *
326f94bb788SPeter Wemm  * NOTE: all but the top-level type descriptions must contain NO whitespace!
327f94bb788SPeter Wemm  * Otherwise, parsing these in ifconfig(8) would be a nightmare.
328f94bb788SPeter Wemm  */
329f94bb788SPeter Wemm struct ifmedia_description {
330f94bb788SPeter Wemm 	int	ifmt_word;		/* word value; may be masked */
331f94bb788SPeter Wemm 	const char *ifmt_string;	/* description */
332f94bb788SPeter Wemm };
333f94bb788SPeter Wemm 
334f94bb788SPeter Wemm #define	IFM_TYPE_DESCRIPTIONS {						\
335f94bb788SPeter Wemm 	{ IFM_ETHER,		"Ethernet" },				\
336f94bb788SPeter Wemm 	{ IFM_TOKEN,		"Token ring" },				\
337f94bb788SPeter Wemm 	{ IFM_FDDI,		"FDDI" },				\
338419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211,	"IEEE 802.11 Wireless Ethernet" },	\
3392b75e097SHartmut Brandt 	{ IFM_ATM,		"ATM" },				\
340a9771948SGleb Smirnoff 	{ IFM_CARP,		"Common Address Redundancy Protocol" }, \
341f94bb788SPeter Wemm 	{ 0, NULL },							\
342f94bb788SPeter Wemm }
343f94bb788SPeter Wemm 
344f94bb788SPeter Wemm #define	IFM_SUBTYPE_ETHERNET_DESCRIPTIONS {				\
345f94bb788SPeter Wemm 	{ IFM_10_T,	"10baseT/UTP" },				\
346f94bb788SPeter Wemm 	{ IFM_10_2,	"10base2/BNC" },				\
347f94bb788SPeter Wemm 	{ IFM_10_5,	"10base5/AUI" },				\
348f94bb788SPeter Wemm 	{ IFM_100_TX,	"100baseTX" },					\
349f94bb788SPeter Wemm 	{ IFM_100_FX,	"100baseFX" },					\
350f94bb788SPeter Wemm 	{ IFM_100_T4,	"100baseT4" },					\
351f94bb788SPeter Wemm 	{ IFM_100_VG,	"100baseVG" },					\
352f94bb788SPeter Wemm 	{ IFM_100_T2,	"100baseT2" },					\
35327ab138fSBill Paul 	{ IFM_10_STP,	"10baseSTP" },					\
35427ab138fSBill Paul 	{ IFM_10_FL,	"10baseFL" },					\
3556b3cb593SBill Paul 	{ IFM_1000_SX,	"1000baseSX" },					\
3566b3cb593SBill Paul 	{ IFM_1000_LX,	"1000baseLX" },					\
3576b3cb593SBill Paul 	{ IFM_1000_CX,	"1000baseCX" },					\
35869237b10SAntoine Brodin 	{ IFM_1000_T,	"1000baseT" },					\
35945521525SPoul-Henning Kamp 	{ IFM_HPNA_1,	"homePNA" },					\
360a7c959feSGleb Smirnoff 	{ IFM_10G_LR,	"10Gbase-LR" },					\
361a7c959feSGleb Smirnoff 	{ IFM_10G_SR,	"10Gbase-SR" },					\
3624ec449aeSGleb Smirnoff 	{ IFM_10G_CX4,	"10Gbase-CX4" },				\
363051e7561SDavid Christensen 	{ IFM_2500_SX,	"2500BaseSX" },					\
364a6c8d997SGeorge V. Neville-Neil 	{ IFM_10G_LRM,	"10Gbase-LRM" },				\
365a6c8d997SGeorge V. Neville-Neil 	{ IFM_10G_TWINAX,	"10Gbase-Twinax" },			\
366a6c8d997SGeorge V. Neville-Neil 	{ IFM_10G_TWINAX_LONG,	"10Gbase-Twinax-Long" },		\
367a6c8d997SGeorge V. Neville-Neil 	{ IFM_UNKNOWN,	"Unknown" },					\
368456ae550SNavdeep Parhar 	{ IFM_10G_T,	"10Gbase-T" },					\
369f94bb788SPeter Wemm 	{ 0, NULL },							\
370f94bb788SPeter Wemm }
371f94bb788SPeter Wemm 
372f94bb788SPeter Wemm #define	IFM_SUBTYPE_ETHERNET_ALIASES {					\
373*d09c5f16SMarius Strobl 	{ IFM_10_T,	"10baseT" },					\
374f94bb788SPeter Wemm 	{ IFM_10_T,	"UTP" },					\
375f94bb788SPeter Wemm 	{ IFM_10_T,	"10UTP" },					\
376f94bb788SPeter Wemm 	{ IFM_10_2,	"BNC" },					\
377f94bb788SPeter Wemm 	{ IFM_10_2,	"10BNC" },					\
378f94bb788SPeter Wemm 	{ IFM_10_5,	"AUI" },					\
379f94bb788SPeter Wemm 	{ IFM_10_5,	"10AUI" },					\
380f94bb788SPeter Wemm 	{ IFM_100_TX,	"100TX" },					\
381f94bb788SPeter Wemm 	{ IFM_100_T4,	"100T4" },					\
382f94bb788SPeter Wemm 	{ IFM_100_VG,	"100VG" },					\
383f94bb788SPeter Wemm 	{ IFM_100_T2,	"100T2" },					\
38427ab138fSBill Paul 	{ IFM_10_STP,	"10STP" },					\
38527ab138fSBill Paul 	{ IFM_10_FL,	"10FL" },					\
38645521525SPoul-Henning Kamp 	{ IFM_1000_SX,	"1000SX" },					\
38745521525SPoul-Henning Kamp 	{ IFM_1000_LX,	"1000LX" },					\
38845521525SPoul-Henning Kamp 	{ IFM_1000_CX,	"1000CX" },					\
38969237b10SAntoine Brodin 	{ IFM_1000_T,	"1000baseTX" },					\
39045521525SPoul-Henning Kamp 	{ IFM_1000_T,	"1000TX" },					\
39145521525SPoul-Henning Kamp 	{ IFM_1000_T,	"1000T" },					\
392051e7561SDavid Christensen 	{ IFM_2500_SX,	"2500SX" },					\
393*d09c5f16SMarius Strobl 									\
394*d09c5f16SMarius Strobl 	/*								\
395*d09c5f16SMarius Strobl 	 * Shorthands for common media+option combinations as announced	\
396*d09c5f16SMarius Strobl 	 * by miibus(4)							\
397*d09c5f16SMarius Strobl 	 */								\
398*d09c5f16SMarius Strobl 	{ IFM_10_T | IFM_FDX,			"10baseT-FDX" },	\
399*d09c5f16SMarius Strobl 	{ IFM_10_T | IFM_FDX | IFM_FLOW,	"10baseT-FDX-flow" },	\
400*d09c5f16SMarius Strobl 	{ IFM_100_TX | IFM_FDX,			"100baseTX-FDX" },	\
401*d09c5f16SMarius Strobl 	{ IFM_100_TX | IFM_FDX | IFM_FLOW,	"100baseTX-FDX-flow" },	\
402*d09c5f16SMarius Strobl 	{ IFM_1000_T | IFM_FDX,			"1000baseT-FDX" },	\
403*d09c5f16SMarius Strobl 	{ IFM_1000_T | IFM_FDX | IFM_FLOW,	"1000baseT-FDX-flow" },	\
404*d09c5f16SMarius Strobl 	{ IFM_1000_T | IFM_FDX | IFM_FLOW | IFM_ETH_MASTER,		\
405*d09c5f16SMarius Strobl 	    "1000baseT-FDX-flow-master" },				\
406*d09c5f16SMarius Strobl 	{ IFM_1000_T | IFM_FDX | IFM_ETH_MASTER,			\
407*d09c5f16SMarius Strobl 	    "1000baseT-FDX-master" },					\
408*d09c5f16SMarius Strobl 	{ IFM_1000_T | IFM_ETH_MASTER,		"1000baseT-master" },	\
409*d09c5f16SMarius Strobl 									\
410f94bb788SPeter Wemm 	{ 0, NULL },							\
411f94bb788SPeter Wemm }
412f94bb788SPeter Wemm 
413f94bb788SPeter Wemm #define	IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS {			\
414efd4fc3fSMarius Strobl 	{ IFM_ETH_MASTER,	"master" },				\
415efd4fc3fSMarius Strobl 	{ IFM_ETH_RXPAUSE,	"rxpause" },				\
416efd4fc3fSMarius Strobl 	{ IFM_ETH_TXPAUSE,	"txpause" },				\
417f94bb788SPeter Wemm 	{ 0, NULL },							\
418f94bb788SPeter Wemm }
419f94bb788SPeter Wemm 
420f94bb788SPeter Wemm #define	IFM_SUBTYPE_TOKENRING_DESCRIPTIONS {				\
421f94bb788SPeter Wemm 	{ IFM_TOK_STP4,	"DB9/4Mbit" },					\
422f94bb788SPeter Wemm 	{ IFM_TOK_STP16, "DB9/16Mbit" },				\
423f94bb788SPeter Wemm 	{ IFM_TOK_UTP4,	"UTP/4Mbit" },					\
424f94bb788SPeter Wemm 	{ IFM_TOK_UTP16, "UTP/16Mbit" },				\
425722012ccSJulian Elischer 	{ IFM_TOK_STP100, "STP/100Mbit" },				\
426722012ccSJulian Elischer 	{ IFM_TOK_UTP100, "UTP/100Mbit" },				\
427f94bb788SPeter Wemm 	{ 0, NULL },							\
428f94bb788SPeter Wemm }
429f94bb788SPeter Wemm 
430f94bb788SPeter Wemm #define	IFM_SUBTYPE_TOKENRING_ALIASES {					\
431f94bb788SPeter Wemm 	{ IFM_TOK_STP4,	"4STP" },					\
432f94bb788SPeter Wemm 	{ IFM_TOK_STP16, "16STP" },					\
433f94bb788SPeter Wemm 	{ IFM_TOK_UTP4,	"4UTP" },					\
434f94bb788SPeter Wemm 	{ IFM_TOK_UTP16, "16UTP" },					\
435722012ccSJulian Elischer 	{ IFM_TOK_STP100, "100STP" },					\
436722012ccSJulian Elischer 	{ IFM_TOK_UTP100, "100UTP" },					\
437f94bb788SPeter Wemm 	{ 0, NULL },							\
438f94bb788SPeter Wemm }
439f94bb788SPeter Wemm 
440f94bb788SPeter Wemm #define	IFM_SUBTYPE_TOKENRING_OPTION_DESCRIPTIONS {			\
441f94bb788SPeter Wemm 	{ IFM_TOK_ETR,	"EarlyTokenRelease" },				\
442f94bb788SPeter Wemm 	{ IFM_TOK_SRCRT, "SourceRouting" },				\
443f94bb788SPeter Wemm 	{ IFM_TOK_ALLR,	"AllRoutes" },					\
444722012ccSJulian Elischer 	{ IFM_TOK_DTR,	"Dedicated" },					\
445722012ccSJulian Elischer 	{ IFM_TOK_CLASSIC,"Classic" },					\
446722012ccSJulian Elischer 	{ IFM_TOK_AUTO,	" " },						\
447f94bb788SPeter Wemm 	{ 0, NULL },							\
448f94bb788SPeter Wemm }
449f94bb788SPeter Wemm 
450f94bb788SPeter Wemm #define	IFM_SUBTYPE_FDDI_DESCRIPTIONS {					\
451f94bb788SPeter Wemm 	{ IFM_FDDI_SMF, "Single-mode" },				\
452f94bb788SPeter Wemm 	{ IFM_FDDI_MMF, "Multi-mode" },					\
453f94bb788SPeter Wemm 	{ IFM_FDDI_UTP, "UTP" },					\
454f94bb788SPeter Wemm 	{ 0, NULL },							\
455f94bb788SPeter Wemm }
456f94bb788SPeter Wemm 
457f94bb788SPeter Wemm #define	IFM_SUBTYPE_FDDI_ALIASES {					\
458f94bb788SPeter Wemm 	{ IFM_FDDI_SMF,	"SMF" },					\
459f94bb788SPeter Wemm 	{ IFM_FDDI_MMF,	"MMF" },					\
460f94bb788SPeter Wemm 	{ IFM_FDDI_UTP,	"CDDI" },					\
461f94bb788SPeter Wemm 	{ 0, NULL },							\
462f94bb788SPeter Wemm }
463f94bb788SPeter Wemm 
464f94bb788SPeter Wemm #define	IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS {				\
465f94bb788SPeter Wemm 	{ IFM_FDDI_DA, "Dual-attach" },					\
466f94bb788SPeter Wemm 	{ 0, NULL },							\
467f94bb788SPeter Wemm }
468f94bb788SPeter Wemm 
469419d8080SPoul-Henning Kamp #define	IFM_SUBTYPE_IEEE80211_DESCRIPTIONS {				\
470419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_FH1, "FH/1Mbps" },				\
471419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_FH2, "FH/2Mbps" },				\
472419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_DS1, "DS/1Mbps" },				\
473419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_DS2, "DS/2Mbps" },				\
474419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_DS5, "DS/5.5Mbps" },				\
475419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_DS11, "DS/11Mbps" },				\
476419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_DS22, "DS/22Mbps" },				\
4771311709aSSam Leffler 	{ IFM_IEEE80211_OFDM6, "OFDM/6Mbps" },				\
4781311709aSSam Leffler 	{ IFM_IEEE80211_OFDM9, "OFDM/9Mbps" },				\
4791311709aSSam Leffler 	{ IFM_IEEE80211_OFDM12, "OFDM/12Mbps" },			\
4801311709aSSam Leffler 	{ IFM_IEEE80211_OFDM18, "OFDM/18Mbps" },			\
4811311709aSSam Leffler 	{ IFM_IEEE80211_OFDM24, "OFDM/24Mbps" },			\
4821311709aSSam Leffler 	{ IFM_IEEE80211_OFDM36, "OFDM/36Mbps" },			\
4831311709aSSam Leffler 	{ IFM_IEEE80211_OFDM48, "OFDM/48Mbps" },			\
4841311709aSSam Leffler 	{ IFM_IEEE80211_OFDM54, "OFDM/54Mbps" },			\
4851311709aSSam Leffler 	{ IFM_IEEE80211_OFDM72, "OFDM/72Mbps" },			\
48694251138SMax Khon 	{ IFM_IEEE80211_DS354k, "DS/354Kbps" },				\
48794251138SMax Khon 	{ IFM_IEEE80211_DS512k, "DS/512Kbps" },				\
48841b3c790SSam Leffler 	{ IFM_IEEE80211_OFDM3, "OFDM/3Mbps" },				\
48941b3c790SSam Leffler 	{ IFM_IEEE80211_OFDM4, "OFDM/4.5Mbps" },			\
49041b3c790SSam Leffler 	{ IFM_IEEE80211_OFDM27, "OFDM/27Mbps" },			\
49159fe4a8cSRui Paulo 	{ IFM_IEEE80211_MCS, "MCS" },					\
492419d8080SPoul-Henning Kamp 	{ 0, NULL },							\
493419d8080SPoul-Henning Kamp }
494419d8080SPoul-Henning Kamp 
495419d8080SPoul-Henning Kamp #define	IFM_SUBTYPE_IEEE80211_ALIASES {					\
496419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_FH1, "FH1" },					\
497419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_FH2, "FH2" },					\
498419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_FH1, "FrequencyHopping/1Mbps" },		\
499419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_FH2, "FrequencyHopping/2Mbps" },		\
500419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_DS1, "DS1" },					\
501419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_DS2, "DS2" },					\
502419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_DS5, "DS5.5" },					\
503419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_DS11, "DS11" },					\
504419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_DS22, "DS22" },					\
505419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_DS1, "DirectSequence/1Mbps" },			\
506419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_DS2, "DirectSequence/2Mbps" },			\
507419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_DS5, "DirectSequence/5.5Mbps" },		\
508419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_DS11, "DirectSequence/11Mbps" },		\
509419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_DS22, "DirectSequence/22Mbps" },		\
5101311709aSSam Leffler 	{ IFM_IEEE80211_OFDM6, "OFDM6" },				\
5111311709aSSam Leffler 	{ IFM_IEEE80211_OFDM9, "OFDM9" },				\
5121311709aSSam Leffler 	{ IFM_IEEE80211_OFDM12, "OFDM12" },				\
5131311709aSSam Leffler 	{ IFM_IEEE80211_OFDM18, "OFDM18" },				\
5141311709aSSam Leffler 	{ IFM_IEEE80211_OFDM24, "OFDM24" },				\
5151311709aSSam Leffler 	{ IFM_IEEE80211_OFDM36, "OFDM36" },				\
5161311709aSSam Leffler 	{ IFM_IEEE80211_OFDM48, "OFDM48" },				\
5171311709aSSam Leffler 	{ IFM_IEEE80211_OFDM54, "OFDM54" },				\
5181311709aSSam Leffler 	{ IFM_IEEE80211_OFDM72, "OFDM72" },				\
5191311709aSSam Leffler 	{ IFM_IEEE80211_DS1, "CCK1" },					\
5201311709aSSam Leffler 	{ IFM_IEEE80211_DS2, "CCK2" },					\
5211311709aSSam Leffler 	{ IFM_IEEE80211_DS5, "CCK5.5" },				\
5221311709aSSam Leffler 	{ IFM_IEEE80211_DS11, "CCK11" },				\
52394251138SMax Khon 	{ IFM_IEEE80211_DS354k, "DS354K" },				\
52494251138SMax Khon 	{ IFM_IEEE80211_DS354k, "DirectSequence/354Kbps" },		\
52594251138SMax Khon 	{ IFM_IEEE80211_DS512k, "DS512K" },				\
52694251138SMax Khon 	{ IFM_IEEE80211_DS512k, "DirectSequence/512Kbps" },		\
52741b3c790SSam Leffler 	{ IFM_IEEE80211_OFDM3, "OFDM3" },				\
52841b3c790SSam Leffler 	{ IFM_IEEE80211_OFDM4, "OFDM4.5" },				\
52941b3c790SSam Leffler 	{ IFM_IEEE80211_OFDM27, "OFDM27" },				\
53059fe4a8cSRui Paulo 	{ IFM_IEEE80211_MCS, "MCS" },					\
531419d8080SPoul-Henning Kamp 	{ 0, NULL },							\
532419d8080SPoul-Henning Kamp }
533419d8080SPoul-Henning Kamp 
534419d8080SPoul-Henning Kamp #define	IFM_SUBTYPE_IEEE80211_OPTION_DESCRIPTIONS {			\
535419d8080SPoul-Henning Kamp 	{ IFM_IEEE80211_ADHOC, "adhoc" },				\
53673ce5facSWarner Losh 	{ IFM_IEEE80211_HOSTAP, "hostap" },				\
537f6462e80SWarner Losh 	{ IFM_IEEE80211_IBSS, "ibss" },					\
538acaf1de6SSam Leffler 	{ IFM_IEEE80211_WDS, "wds" },					\
5391311709aSSam Leffler 	{ IFM_IEEE80211_TURBO, "turbo" },				\
5402bbe529dSSam Leffler 	{ IFM_IEEE80211_MONITOR, "monitor" },				\
54159aa14a9SRui Paulo 	{ IFM_IEEE80211_MBSS, "mesh" },					\
5421311709aSSam Leffler 	{ 0, NULL },							\
5431311709aSSam Leffler }
5441311709aSSam Leffler 
5451311709aSSam Leffler #define	IFM_SUBTYPE_IEEE80211_MODE_DESCRIPTIONS {			\
5462dd59091SSam Leffler 	{ IFM_AUTO, "autoselect" },					\
5471311709aSSam Leffler 	{ IFM_IEEE80211_11A, "11a" },					\
5481311709aSSam Leffler 	{ IFM_IEEE80211_11B, "11b" },					\
5491311709aSSam Leffler 	{ IFM_IEEE80211_11G, "11g" },					\
5504844aa7dSAtsushi Onoe 	{ IFM_IEEE80211_FH, "fh" },					\
55168e8e04eSSam Leffler 	{ IFM_IEEE80211_11NA, "11na" },					\
55268e8e04eSSam Leffler 	{ IFM_IEEE80211_11NG, "11ng" },					\
553419d8080SPoul-Henning Kamp 	{ 0, NULL },							\
554419d8080SPoul-Henning Kamp }
555419d8080SPoul-Henning Kamp 
5562dd59091SSam Leffler #define	IFM_SUBTYPE_IEEE80211_MODE_ALIASES {				\
5572dd59091SSam Leffler 	{ IFM_AUTO, "auto" },						\
5582dd59091SSam Leffler 	{ 0, NULL },							\
5592dd59091SSam Leffler }
5602dd59091SSam Leffler 
5612b75e097SHartmut Brandt #define	IFM_SUBTYPE_ATM_DESCRIPTIONS {					\
5622b75e097SHartmut Brandt 	{ IFM_ATM_UNKNOWN,	"Unknown" },				\
5632b75e097SHartmut Brandt 	{ IFM_ATM_UTP_25,	"UTP/25.6MBit" },			\
5642b75e097SHartmut Brandt 	{ IFM_ATM_TAXI_100,	"Taxi/100MBit" },			\
5652b75e097SHartmut Brandt 	{ IFM_ATM_TAXI_140,	"Taxi/140MBit" },			\
5662b75e097SHartmut Brandt 	{ IFM_ATM_MM_155,	"Multi-mode/155MBit" },			\
5672b75e097SHartmut Brandt 	{ IFM_ATM_SM_155,	"Single-mode/155MBit" },		\
5682b75e097SHartmut Brandt 	{ IFM_ATM_UTP_155,	"UTP/155MBit" },			\
569d68d53d4SHartmut Brandt 	{ IFM_ATM_MM_622,	"Multi-mode/622MBit" },			\
5702b75e097SHartmut Brandt 	{ IFM_ATM_SM_622,	"Single-mode/622MBit" },		\
5716eadc708SHartmut Brandt 	{ IFM_ATM_VIRTUAL,	"Virtual" },				\
5722b75e097SHartmut Brandt 	{ 0, NULL },							\
5732b75e097SHartmut Brandt }
5742b75e097SHartmut Brandt 
5752b75e097SHartmut Brandt #define	IFM_SUBTYPE_ATM_ALIASES {					\
5762b75e097SHartmut Brandt 	{ IFM_ATM_UNKNOWN,	"UNKNOWN" },				\
5772b75e097SHartmut Brandt 	{ IFM_ATM_UTP_25,	"UTP-25" },				\
5782b75e097SHartmut Brandt 	{ IFM_ATM_TAXI_100,	"TAXI-100" },				\
5792b75e097SHartmut Brandt 	{ IFM_ATM_TAXI_140,	"TAXI-140" },				\
5802b75e097SHartmut Brandt 	{ IFM_ATM_MM_155,	"MM-155" },				\
5812b75e097SHartmut Brandt 	{ IFM_ATM_SM_155,	"SM-155" },				\
5822b75e097SHartmut Brandt 	{ IFM_ATM_UTP_155,	"UTP-155" },				\
5832b75e097SHartmut Brandt 	{ IFM_ATM_MM_622,	"MM-622" },				\
5842b75e097SHartmut Brandt 	{ IFM_ATM_SM_622,	"SM-622" },				\
5856eadc708SHartmut Brandt 	{ IFM_ATM_VIRTUAL,	"VIRTUAL" },				\
5862b75e097SHartmut Brandt 	{ 0, NULL },							\
5872b75e097SHartmut Brandt }
5882b75e097SHartmut Brandt 
5892b75e097SHartmut Brandt #define	IFM_SUBTYPE_ATM_OPTION_DESCRIPTIONS {				\
5902b75e097SHartmut Brandt 	{ IFM_ATM_SDH, "SDH" },						\
5912b75e097SHartmut Brandt 	{ IFM_ATM_NOSCRAMB, "Noscramb" },				\
5922b75e097SHartmut Brandt 	{ IFM_ATM_UNASSIGNED, "Unassigned" },				\
5932b75e097SHartmut Brandt 	{ 0, NULL },							\
5942b75e097SHartmut Brandt }
5952b75e097SHartmut Brandt 
596f94bb788SPeter Wemm #define	IFM_SUBTYPE_SHARED_DESCRIPTIONS {				\
597f94bb788SPeter Wemm 	{ IFM_AUTO,	"autoselect" },					\
598f94bb788SPeter Wemm 	{ IFM_MANUAL,	"manual" },					\
599f94bb788SPeter Wemm 	{ IFM_NONE,	"none" },					\
600f94bb788SPeter Wemm 	{ 0, NULL },							\
601f94bb788SPeter Wemm }
602f94bb788SPeter Wemm 
603f94bb788SPeter Wemm #define	IFM_SUBTYPE_SHARED_ALIASES {					\
604f94bb788SPeter Wemm 	{ IFM_AUTO,	"auto" },					\
605*d09c5f16SMarius Strobl 									\
606*d09c5f16SMarius Strobl 	/*								\
607*d09c5f16SMarius Strobl 	 * Shorthands for common media+option combinations as announced	\
608*d09c5f16SMarius Strobl 	 * by miibus(4)							\
609*d09c5f16SMarius Strobl 	 */								\
610*d09c5f16SMarius Strobl 	{ IFM_AUTO | IFM_FLOW,	"auto-flow" },				\
611*d09c5f16SMarius Strobl 									\
612f94bb788SPeter Wemm 	{ 0, NULL },							\
613f94bb788SPeter Wemm }
614f94bb788SPeter Wemm 
615f94bb788SPeter Wemm #define	IFM_SHARED_OPTION_DESCRIPTIONS {				\
616f94bb788SPeter Wemm 	{ IFM_FDX,	"full-duplex" },				\
617f94bb788SPeter Wemm 	{ IFM_HDX,	"half-duplex" },				\
618efd4fc3fSMarius Strobl 	{ IFM_FLOW,	"flowcontrol" },				\
619f94bb788SPeter Wemm 	{ IFM_FLAG0,	"flag0" },					\
620f94bb788SPeter Wemm 	{ IFM_FLAG1,	"flag1" },					\
621f94bb788SPeter Wemm 	{ IFM_FLAG2,	"flag2" },					\
622f94bb788SPeter Wemm 	{ IFM_LOOP,	"hw-loopback" },				\
623f94bb788SPeter Wemm 	{ 0, NULL },							\
624f94bb788SPeter Wemm }
625f94bb788SPeter Wemm 
626a0fc3825SMarius Strobl #define	IFM_SHARED_OPTION_ALIASES {					\
627a0fc3825SMarius Strobl 	{ IFM_FDX,	"fdx" },					\
628a0fc3825SMarius Strobl 	{ IFM_HDX,	"hdx" },					\
629a0fc3825SMarius Strobl 	{ IFM_FLOW,	"flow" },					\
630a0fc3825SMarius Strobl 	{ IFM_LOOP,	"loop" },					\
631a0fc3825SMarius Strobl 	{ IFM_LOOP,	"loopback" },					\
632a0fc3825SMarius Strobl 	{ 0, NULL },							\
633a0fc3825SMarius Strobl }
634a0fc3825SMarius Strobl 
635efd19b8fSGleb Smirnoff /*
636efd19b8fSGleb Smirnoff  * Baudrate descriptions for the various media types.
637efd19b8fSGleb Smirnoff  */
638efd19b8fSGleb Smirnoff struct ifmedia_baudrate {
639efd19b8fSGleb Smirnoff 	int		ifmb_word;		/* media word */
640efd19b8fSGleb Smirnoff 	uint64_t	ifmb_baudrate;		/* corresponding baudrate */
641efd19b8fSGleb Smirnoff };
642efd19b8fSGleb Smirnoff 
643efd19b8fSGleb Smirnoff #define	IFM_BAUDRATE_DESCRIPTIONS {					\
644efd19b8fSGleb Smirnoff 	{ IFM_ETHER | IFM_10_T,		IF_Mbps(10) },			\
645efd19b8fSGleb Smirnoff 	{ IFM_ETHER | IFM_10_2,		IF_Mbps(10) },			\
646efd19b8fSGleb Smirnoff 	{ IFM_ETHER | IFM_10_5,		IF_Mbps(10) },			\
647efd19b8fSGleb Smirnoff 	{ IFM_ETHER | IFM_100_TX,	IF_Mbps(100) },			\
648efd19b8fSGleb Smirnoff 	{ IFM_ETHER | IFM_100_FX,	IF_Mbps(100) },			\
649efd19b8fSGleb Smirnoff 	{ IFM_ETHER | IFM_100_T4,	IF_Mbps(100) },			\
650efd19b8fSGleb Smirnoff 	{ IFM_ETHER | IFM_100_VG,	IF_Mbps(100) },			\
651efd19b8fSGleb Smirnoff 	{ IFM_ETHER | IFM_100_T2,	IF_Mbps(100) },			\
652efd19b8fSGleb Smirnoff 	{ IFM_ETHER | IFM_1000_SX,	IF_Mbps(1000) },		\
653efd19b8fSGleb Smirnoff 	{ IFM_ETHER | IFM_10_STP,	IF_Mbps(10) },			\
654efd19b8fSGleb Smirnoff 	{ IFM_ETHER | IFM_10_FL,	IF_Mbps(10) },			\
655efd19b8fSGleb Smirnoff 	{ IFM_ETHER | IFM_1000_LX,	IF_Mbps(1000) },		\
656efd19b8fSGleb Smirnoff 	{ IFM_ETHER | IFM_1000_CX,	IF_Mbps(1000) },		\
657efd19b8fSGleb Smirnoff 	{ IFM_ETHER | IFM_1000_T,	IF_Mbps(1000) },		\
658efd19b8fSGleb Smirnoff 	{ IFM_ETHER | IFM_HPNA_1,	IF_Mbps(1) },			\
659efd19b8fSGleb Smirnoff 	{ IFM_ETHER | IFM_10G_LR,	IF_Gbps(10ULL) },		\
6604ec449aeSGleb Smirnoff 	{ IFM_ETHER | IFM_10G_SR,	IF_Gbps(10ULL) },		\
6614ec449aeSGleb Smirnoff 	{ IFM_ETHER | IFM_10G_CX4,	IF_Gbps(10ULL) },		\
662051e7561SDavid Christensen 	{ IFM_ETHER | IFM_2500_SX,	IF_Mbps(2500ULL) },		\
663a6c8d997SGeorge V. Neville-Neil 	{ IFM_ETHER | IFM_10G_TWINAX,	IF_Gbps(10ULL) },		\
664a6c8d997SGeorge V. Neville-Neil 	{ IFM_ETHER | IFM_10G_TWINAX_LONG,	IF_Gbps(10ULL) },	\
665a6c8d997SGeorge V. Neville-Neil 	{ IFM_ETHER | IFM_10G_LRM,	IF_Gbps(10ULL) },		\
666456ae550SNavdeep Parhar 	{ IFM_ETHER | IFM_10G_T,	IF_Gbps(10ULL) },		\
667efd19b8fSGleb Smirnoff 									\
668efd19b8fSGleb Smirnoff 	{ IFM_TOKEN | IFM_TOK_STP4,	IF_Mbps(4) },			\
669efd19b8fSGleb Smirnoff 	{ IFM_TOKEN | IFM_TOK_STP16,	IF_Mbps(16) },			\
670efd19b8fSGleb Smirnoff 	{ IFM_TOKEN | IFM_TOK_UTP4,	IF_Mbps(4) },			\
671efd19b8fSGleb Smirnoff 	{ IFM_TOKEN | IFM_TOK_UTP16,	IF_Mbps(16) },			\
672efd19b8fSGleb Smirnoff 									\
673efd19b8fSGleb Smirnoff 	{ IFM_FDDI | IFM_FDDI_SMF,	IF_Mbps(100) },			\
674efd19b8fSGleb Smirnoff 	{ IFM_FDDI | IFM_FDDI_MMF,	IF_Mbps(100) },			\
675efd19b8fSGleb Smirnoff 	{ IFM_FDDI | IFM_FDDI_UTP,	IF_Mbps(100) },			\
676efd19b8fSGleb Smirnoff 									\
677efd19b8fSGleb Smirnoff 	{ IFM_IEEE80211 | IFM_IEEE80211_FH1,	IF_Mbps(1) },		\
678efd19b8fSGleb Smirnoff 	{ IFM_IEEE80211 | IFM_IEEE80211_FH2,	IF_Mbps(2) },		\
679efd19b8fSGleb Smirnoff 	{ IFM_IEEE80211 | IFM_IEEE80211_DS2,	IF_Mbps(2) },		\
680efd19b8fSGleb Smirnoff 	{ IFM_IEEE80211 | IFM_IEEE80211_DS5,	IF_Kbps(5500) },	\
681efd19b8fSGleb Smirnoff 	{ IFM_IEEE80211 | IFM_IEEE80211_DS11,	IF_Mbps(11) },		\
682efd19b8fSGleb Smirnoff 	{ IFM_IEEE80211 | IFM_IEEE80211_DS1,	IF_Mbps(1) },		\
683efd19b8fSGleb Smirnoff 	{ IFM_IEEE80211 | IFM_IEEE80211_DS22,	IF_Mbps(22) },		\
684efd19b8fSGleb Smirnoff 	{ IFM_IEEE80211 | IFM_IEEE80211_OFDM6,	IF_Mbps(6) },		\
685efd19b8fSGleb Smirnoff 	{ IFM_IEEE80211 | IFM_IEEE80211_OFDM9,	IF_Mbps(9) },		\
686efd19b8fSGleb Smirnoff 	{ IFM_IEEE80211 | IFM_IEEE80211_OFDM12,	IF_Mbps(12) },		\
687efd19b8fSGleb Smirnoff 	{ IFM_IEEE80211 | IFM_IEEE80211_OFDM18,	IF_Mbps(18) },		\
688efd19b8fSGleb Smirnoff 	{ IFM_IEEE80211 | IFM_IEEE80211_OFDM24,	IF_Mbps(24) },		\
689efd19b8fSGleb Smirnoff 	{ IFM_IEEE80211 | IFM_IEEE80211_OFDM36,	IF_Mbps(36) },		\
690efd19b8fSGleb Smirnoff 	{ IFM_IEEE80211 | IFM_IEEE80211_OFDM48,	IF_Mbps(48) },		\
691efd19b8fSGleb Smirnoff 	{ IFM_IEEE80211 | IFM_IEEE80211_OFDM54,	IF_Mbps(54) },		\
692efd19b8fSGleb Smirnoff 	{ IFM_IEEE80211 | IFM_IEEE80211_OFDM72,	IF_Mbps(72) },		\
693efd19b8fSGleb Smirnoff 									\
694efd19b8fSGleb Smirnoff 	{ 0, 0 },							\
695efd19b8fSGleb Smirnoff }
696efd19b8fSGleb Smirnoff 
697e4bd8f10SAndre Oppermann /*
698e4bd8f10SAndre Oppermann  * Status descriptions for the various media types.
699e4bd8f10SAndre Oppermann  */
700e4bd8f10SAndre Oppermann struct ifmedia_status_description {
701e4bd8f10SAndre Oppermann 	int	   ifms_type;
702e4bd8f10SAndre Oppermann 	int	   ifms_valid;
703e4bd8f10SAndre Oppermann 	int	   ifms_bit;
704e4bd8f10SAndre Oppermann 	const char *ifms_string[2];
705e4bd8f10SAndre Oppermann };
706e4bd8f10SAndre Oppermann 
707e4bd8f10SAndre Oppermann #define	IFM_STATUS_DESC(ifms, bit)					\
708e4bd8f10SAndre Oppermann 	(ifms)->ifms_string[((ifms)->ifms_bit & (bit)) ? 1 : 0]
709e4bd8f10SAndre Oppermann 
710e4bd8f10SAndre Oppermann #define	IFM_STATUS_DESCRIPTIONS {					\
711e4bd8f10SAndre Oppermann 	{ IFM_ETHER,		IFM_AVALID,	IFM_ACTIVE,		\
712e4bd8f10SAndre Oppermann 	    { "no carrier", "active" } },				\
713e4bd8f10SAndre Oppermann 	{ IFM_FDDI,		IFM_AVALID,	IFM_ACTIVE,		\
714e4bd8f10SAndre Oppermann 	    { "no ring", "inserted" } },				\
715e4bd8f10SAndre Oppermann 	{ IFM_TOKEN,		IFM_AVALID,	IFM_ACTIVE,		\
716e4bd8f10SAndre Oppermann 	    { "no ring", "inserted" } },				\
717e4bd8f10SAndre Oppermann 	{ IFM_IEEE80211,	IFM_AVALID,	IFM_ACTIVE,		\
718e4bd8f10SAndre Oppermann 	    { "no network", "active" } },				\
719e4bd8f10SAndre Oppermann 	{ IFM_ATM,		IFM_AVALID,	IFM_ACTIVE,		\
720e4bd8f10SAndre Oppermann 	    { "no network", "active" } },				\
721e4bd8f10SAndre Oppermann 	{ IFM_CARP,		IFM_AVALID,	IFM_ACTIVE,		\
722e4bd8f10SAndre Oppermann 	    { "backup", "master" } },					\
723e4bd8f10SAndre Oppermann 	{ 0,			0,		0,			\
724e4bd8f10SAndre Oppermann 	    { NULL, NULL } }						\
725e4bd8f10SAndre Oppermann }
726f94bb788SPeter Wemm #endif	/* _NET_IF_MEDIA_H_ */
727