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