• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**  <at> file
2 *  Prototypes and definitions for BSD/OS-compatible network interface media selection.
3 *
4 *  Copyright (c) 2011-2016, ARM Limited. All rights reserved.
5 *
6 *  This program and the accompanying materials
7 *  are licensed and made available under the terms and conditions of the BSD License
8 *  which accompanies this distribution.  The full text of the license may be found at
9 *  http://opensource.org/licenses/bsd-license.php
10 *
11 *  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 *  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 *
14 **/
15 /*  $NetBSD: if_media.h,v 1.3 1997/03/26 01:19:27 thorpej Exp $  */
16 /* $FreeBSD: src/sys/net/if_media.h,v 1.47.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $ */
17 
18 /*-
19  * Copyright (c) 1997
20  *  Jonathan Stone and Jason R. Thorpe.  All rights reserved.
21  *
22  * This software is derived from information provided by Matt Thomas.
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  * 1. Redistributions of source code must retain the above copyright
28  *    notice, this list of conditions and the following disclaimer.
29  * 2. Redistributions in binary form must reproduce the above copyright
30  *    notice, this list of conditions and the following disclaimer in the
31  *    documentation and/or other materials provided with the distribution.
32  * 3. All advertising materials mentioning features or use of this software
33  *    must display the following acknowledgement:
34  *  This product includes software developed by Jonathan Stone
35  *  and Jason R. Thorpe for the NetBSD Project.
36  * 4. The names of the authors may not be used to endorse or promote products
37  *    derived from this software without specific prior written permission.
38  *
39  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
40  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
41  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
42  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
43  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
46  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
48  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49  * SUCH DAMAGE.
50  */
51 
52 #ifndef _NET_IF_MEDIA_H_
53 #define _NET_IF_MEDIA_H_
54 
55 /*
56  * Prototypes and definitions for BSD/OS-compatible network interface
57  * media selection.
58  *
59  * Where it is safe to do so, this code strays slightly from the BSD/OS
60  * design.  Software which uses the API (device drivers, basically)
61  * shouldn't notice any difference.
62  *
63  * Many thanks to Matt Thomas for providing the information necessary
64  * to implement this interface.
65  */
66 
67 /*
68  * if_media Options word:
69  *  Bits  Use
70  *  ----  -------
71  *  0-4  Media variant
72  *  5-7  Media type
73  *  8-15  Type specific options
74  *  16-18  Mode (for multi-mode devices)
75  *  19  RFU
76  *  20-27  Shared (global) options
77  *  28-31  Instance
78  */
79 
80 /*
81  * Ethernet
82  */
83 #define  IFM_ETHER          0x00000020
84 #define  IFM_10_T           3   /* 10BaseT - RJ45 */
85 #define  IFM_10_2           4   /* 10Base2 - Thinnet */
86 #define  IFM_10_5           5   /* 10Base5 - AUI */
87 #define  IFM_100_TX         6   /* 100BaseTX - RJ45 */
88 #define  IFM_100_FX         7   /* 100BaseFX - Fiber */
89 #define  IFM_100_T4         8   /* 100BaseT4 - 4 pair cat 3 */
90 #define  IFM_100_VG         9   /* 100VG-AnyLAN */
91 #define  IFM_100_T2         10  /* 100BaseT2 */
92 #define  IFM_1000_SX        11  /* 1000BaseSX - multi-mode fiber */
93 #define  IFM_10_STP         12  /* 10BaseT over shielded TP */
94 #define  IFM_10_FL          13  /* 10BaseFL - Fiber */
95 #define  IFM_1000_LX        14  /* 1000baseLX - single-mode fiber */
96 #define  IFM_1000_CX        15  /* 1000baseCX - 150ohm STP */
97 #define  IFM_1000_T         16  /* 1000baseT - 4 pair cat 5 */
98 #define  IFM_HPNA_1         17  /* HomePNA 1.0 (1Mb/s) */
99 #define  IFM_10G_LR         18  /* 10GBase-LR 1310nm Single-mode */
100 #define  IFM_10G_SR         19  /* 10GBase-SR 850nm Multi-mode */
101 #define  IFM_10G_CX4        20  /* 10GBase CX4 copper */
102 #define IFM_2500_SX         21  /* 2500BaseSX - multi-mode fiber */
103 #define IFM_10G_TWINAX      22  /* 10GBase Twinax copper */
104 #define IFM_10G_TWINAX_LONG 23  /* 10GBase Twinax Long copper */
105 #define IFM_10G_LRM         24  /* 10GBase-LRM 850nm Multi-mode */
106 #define IFM_UNKNOWN         25  /* media types not defined yet */
107 #define IFM_10G_T           26  /* 10GBase-T - RJ45 */
108 
109 
110 /* note 31 is the max! */
111 
112 #define  IFM_ETH_MASTER  0x00000100  /* master mode (1000baseT) */
113 
114 /*
115  * Token ring
116  */
117 #define  IFM_TOKEN        0x00000040
118 #define  IFM_TOK_STP4     3    /* Shielded twisted pair 4m - DB9 */
119 #define  IFM_TOK_STP16    4    /* Shielded twisted pair 16m - DB9 */
120 #define  IFM_TOK_UTP4     5    /* Unshielded twisted pair 4m - RJ45 */
121 #define  IFM_TOK_UTP16    6    /* Unshielded twisted pair 16m - RJ45 */
122 #define  IFM_TOK_STP100   7    /* Shielded twisted pair 100m - DB9 */
123 #define  IFM_TOK_UTP100   8    /* Unshielded twisted pair 100m - RJ45 */
124 #define  IFM_TOK_ETR      0x00000200  /* Early token release */
125 #define  IFM_TOK_SRCRT    0x00000400  /* Enable source routing features */
126 #define  IFM_TOK_ALLR     0x00000800  /* All routes / Single route bcast */
127 #define  IFM_TOK_DTR      0x00002000  /* Dedicated token ring */
128 #define  IFM_TOK_CLASSIC  0x00004000  /* Classic token ring */
129 #define  IFM_TOK_AUTO     0x00008000  /* Automatic Dedicate/Classic token ring */
130 
131 /*
132  * FDDI
133  */
134 #define  IFM_FDDI       0x00000060
135 #define  IFM_FDDI_SMF   3    /* Single-mode fiber */
136 #define  IFM_FDDI_MMF   4    /* Multi-mode fiber */
137 #define  IFM_FDDI_UTP   5    /* CDDI / UTP */
138 #define  IFM_FDDI_DA    0x00000100  /* Dual attach / single attach */
139 
140 /*
141  * IEEE 802.11 Wireless
142  */
143 #define  IFM_IEEE80211          0x00000080
144 /* NB: 0,1,2 are auto, manual, none defined below */
145 #define  IFM_IEEE80211_FH1      3  /* Frequency Hopping 1Mbps */
146 #define  IFM_IEEE80211_FH2      4  /* Frequency Hopping 2Mbps */
147 #define  IFM_IEEE80211_DS1      5  /* Direct Sequence 1Mbps */
148 #define  IFM_IEEE80211_DS2      6  /* Direct Sequence 2Mbps */
149 #define  IFM_IEEE80211_DS5      7  /* Direct Sequence 5.5Mbps */
150 #define  IFM_IEEE80211_DS11     8  /* Direct Sequence 11Mbps */
151 #define  IFM_IEEE80211_DS22     9  /* Direct Sequence 22Mbps */
152 #define  IFM_IEEE80211_OFDM6    10  /* OFDM 6Mbps */
153 #define  IFM_IEEE80211_OFDM9    11  /* OFDM 9Mbps */
154 #define  IFM_IEEE80211_OFDM12   12  /* OFDM 12Mbps */
155 #define  IFM_IEEE80211_OFDM18   13  /* OFDM 18Mbps */
156 #define  IFM_IEEE80211_OFDM24   14  /* OFDM 24Mbps */
157 #define  IFM_IEEE80211_OFDM36   15  /* OFDM 36Mbps */
158 #define  IFM_IEEE80211_OFDM48   16  /* OFDM 48Mbps */
159 #define  IFM_IEEE80211_OFDM54   17  /* OFDM 54Mbps */
160 #define  IFM_IEEE80211_OFDM72   18  /* OFDM 72Mbps */
161 #define  IFM_IEEE80211_DS354k   19  /* Direct Sequence 354Kbps */
162 #define  IFM_IEEE80211_DS512k   20  /* Direct Sequence 512Kbps */
163 #define  IFM_IEEE80211_OFDM3    21  /* OFDM 3Mbps */
164 #define  IFM_IEEE80211_OFDM4    22  /* OFDM 4.5Mbps */
165 #define  IFM_IEEE80211_OFDM27   23  /* OFDM 27Mbps */
166 /* NB: not enough bits to express MCS fully */
167 #define  IFM_IEEE80211_MCS      24  /* HT MCS rate */
168 
169 #define  IFM_IEEE80211_ADHOC    0x00000100  /* Operate in Adhoc mode */
170 #define  IFM_IEEE80211_HOSTAP   0x00000200  /* Operate in Host AP mode */
171 #define  IFM_IEEE80211_IBSS     0x00000400  /* Operate in IBSS mode */
172 #define  IFM_IEEE80211_WDS      0x00000800  /* Operate in WDS mode */
173 #define  IFM_IEEE80211_TURBO    0x00001000  /* Operate in turbo mode */
174 #define  IFM_IEEE80211_MONITOR  0x00002000  /* Operate in monitor mode */
175 #define  IFM_IEEE80211_MBSS     0x00004000  /* Operate in MBSS mode */
176 
177 /* operating mode for multi-mode devices */
178 #define  IFM_IEEE80211_11A      0x00010000  /* 5Ghz, OFDM mode */
179 #define  IFM_IEEE80211_11B      0x00020000  /* Direct Sequence mode */
180 #define  IFM_IEEE80211_11G      0x00030000  /* 2Ghz, CCK mode */
181 #define  IFM_IEEE80211_FH       0x00040000  /* 2Ghz, GFSK mode */
182 #define  IFM_IEEE80211_11NA     0x00050000  /* 5Ghz, HT mode */
183 #define  IFM_IEEE80211_11NG     0x00060000  /* 2Ghz, HT mode */
184 
185 /*
186  * ATM
187  */
188 #define IFM_ATM             0x000000a0
189 #define IFM_ATM_UNKNOWN     3
190 #define IFM_ATM_UTP_25      4
191 #define IFM_ATM_TAXI_100    5
192 #define IFM_ATM_TAXI_140    6
193 #define IFM_ATM_MM_155      7
194 #define IFM_ATM_SM_155      8
195 #define IFM_ATM_UTP_155     9
196 #define IFM_ATM_MM_622      10
197 #define IFM_ATM_SM_622      11
198 #define  IFM_ATM_VIRTUAL    12
199 #define IFM_ATM_SDH         0x00000100  /* SDH instead of SONET */
200 #define IFM_ATM_NOSCRAMB    0x00000200  /* no scrambling */
201 #define IFM_ATM_UNASSIGNED  0x00000400  /* unassigned cells */
202 
203 /*
204  * CARP Common Address Redundancy Protocol
205  */
206 #define  IFM_CARP  0x000000c0
207 
208 /*
209  * Shared media sub-types
210  */
211 #define  IFM_AUTO   0    /* Autoselect best media */
212 #define  IFM_MANUAL 1    /* Jumper/dipswitch selects media */
213 #define  IFM_NONE   2    /* Deselect all media */
214 
215 /*
216  * Shared options
217  */
218 #define  IFM_FDX   0x00100000  /* Force full duplex */
219 #define  IFM_HDX   0x00200000  /* Force half duplex */
220 #define  IFM_FLAG0 0x01000000  /* Driver defined flag */
221 #define  IFM_FLAG1 0x02000000  /* Driver defined flag */
222 #define  IFM_FLAG2 0x04000000  /* Driver defined flag */
223 #define  IFM_LOOP  0x08000000  /* Put hardware in loopback */
224 
225 /*
226  * Masks
227  */
228 #define  IFM_NMASK  0x000000e0  /* Network type */
229 #define  IFM_TMASK  0x0000001f  /* Media sub-type */
230 #define  IFM_IMASK  0xf0000000  /* Instance */
231 #define  IFM_ISHIFT 28    /* Instance shift */
232 #define  IFM_OMASK  0x0000ff00  /* Type specific options */
233 #define  IFM_MMASK  0x00070000  /* Mode */
234 #define  IFM_MSHIFT 16    /* Mode shift */
235 #define  IFM_GMASK  0x0ff00000  /* Global options */
236 
237 /*
238  * Status bits
239  */
240 #define  IFM_AVALID  0x00000001  /* Active bit valid */
241 #define  IFM_ACTIVE  0x00000002  /* Interface attached to working net */
242 
243 /* Mask of "status valid" bits, for ifconfig(8). */
244 #define  IFM_STATUS_VALID  IFM_AVALID
245 
246 /* List of "status valid" bits, for ifconfig(8). */
247 #define IFM_STATUS_VALID_LIST {            \
248   IFM_AVALID,              \
249   0                \
250   }
251 
252 /*
253  * Macros to extract various bits of information from the media word.
254  */
255 #define  IFM_TYPE(x)         ((x) & IFM_NMASK)
256 #define  IFM_SUBTYPE(x)      ((x) & IFM_TMASK)
257 #define  IFM_TYPE_OPTIONS(x) ((x) & IFM_OMASK)
258 #define  IFM_INST(x)         (((x) & IFM_IMASK) >> IFM_ISHIFT)
259 #define  IFM_OPTIONS(x)      ((x) & (IFM_OMASK|IFM_GMASK))
260 #define  IFM_MODE(x)         ((x) & IFM_MMASK)
261 
262 #define  IFM_INST_MAX  IFM_INST(IFM_IMASK)
263 
264 /*
265  * Macro to create a media word.
266  */
267 #define  IFM_MAKEWORD(type, subtype, options, instance)      \
268   ((type) | (subtype) | (options) | ((instance) << IFM_ISHIFT))
269 #define  IFM_MAKEMODE(mode) \
270   (((mode) << IFM_MSHIFT) & IFM_MMASK)
271 
272 
273 #endif  /* _NET_IF_MEDIA_H_ */
274