Commit Graph

68 Commits

Author SHA1 Message Date
msaitoh 835fd7148a Fix previous comment change for ifm_media. It was correct.
The real problem is that some driver misuse ifm_media as the current active
media. struct mii_data has the current active media(mii_media_active). If a
driver use mii(4), it can be use mii->mii_media_active for this purpose.
struct ifmedia has no entry for this purpose. Some drivers have an entry
in their own softc to keep the value, but some other's don't have it and
they mistakenly use ifm_media.

 We might add a new entry to struct ifmedia in future to avoid this confusion
and for simplify.
2019-12-05 05:29:27 +00:00
msaitoh b27a0e3447 Fix comment. The ifm_media member of struct ifmedia is NOT user-set media
word but the current "active" media.

 The user-set media word is one of the ifmedia_entry's ifm_media(A) that
ifm_cur points to (e.g. IFM_AUTO). It can be taken as ifmediareq's ifm_current
entry. The current active media word is the ifm_media(B) entry of struct
ifmedia (e.g 1000baseTX-FDX as the result of auto negotiation). It can be
taken as ifmediareq's ifm_active entry.

struct ifmedia_entry {
	TAILQ_ENTRY(ifmedia_entry) ifm_list;
	u_int	ifm_media;	/* IFMWD: description of this media */ /* A */
	u_int	ifm_data;	/* for driver-specific use */
	void	*ifm_aux;	/* for driver-specific use */
};

struct ifmedia {
	u_int	ifm_mask;	/* IFMWD: mask of changes we don't care */
	u_int	ifm_media;	/* IFMWD: current active media word */ /* B */
	struct ifmedia_entry *ifm_cur;	/* current user-selected media */
	TAILQ_HEAD(, ifmedia_entry) ifm_list; /* list of all supported media */
	ifm_change_cb_t	ifm_change;	/* media change driver callback */
	ifm_stat_cb_t	ifm_status;	/* media status driver callback */
};

So:

			in kernel		SIOCGIFMEDIA(ifmediareq)
	-----------------------------------------------------------------
	user-setting:	ifm->ifm_cur->ifm_media	ifm_current
	current active:	ifm->ifm_media		ifm_active

It would be good to rename some members to make those meaning clear.
2019-11-28 14:08:22 +00:00
jmcneill b766b1586c Add IFM_IEEE80211_VHT subtype, IFM_IEEE80211_11AC operating mode, and missing descriptions 2019-10-03 14:41:14 +00:00
msaitoh bf354a0797 The max subtype of the ifmedia word is 31. It's too small for Ethernet now.
We currently use use it up to 30. We should extend the limit to be able to use
more than 10Gbps speeds. Our ifmedia(4) is inconvenience and have some problem
so we should redesign the interface, but it's too late for netbsd-9 to do it.
So, we keep the data structure size and modify the structure a bit. The
strategy is almost the same as FreeBSD. Many bits of IFM_OMASK for Ethernet
have not used, so use some of them for Ethernet's subtype.

The differences against FreeBSD are:
 - We use NetBSD style compat code (i.e. no SIOCGIFXMEDIA).
 - FreeBSD's IFM_ETH_XTYPE's bit location is from 11 to "14" even though
   IFM_OMASK is from 8 to "15". We use _IFM_ETH_XTMASK from bit 13 to "15".
 - FreeBSD changed the meaning of IFM_TYPE_MATCH(). I think we should
   not do it. We keep it not changing and added new IFM_TYPE_SUBTYPE_MATCH()
   macro for matching both TYPE and SUBTYPE.
 - Added up to 400GBASE-SR16.

New layout of the media word is as follows (from ifmedia_h):

 * if_media Options word:
 *	Bits	Use
 *	----	-------
 *	0-4	Media subtype	MAX SUBTYPE == 255 for ETH and 31 for others
 *	5-7	Media type
 *	8-15	Type specific options
 *	16-18	Mode (for multi-mode devices)
 *	19	(Reserved for Future Use)
 *	20-27	Shared (global) options
 *	28-31	Instance
 *
 *   3                     2                   1
 *   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
 *  +-------+---------------+-+-----+---------------+-----+---------+
 *  |       |               |R|     |               |     |         |
 *  | IMASK |     GMASK     |F|MMASK+-----+ OMASK   |NMASK|  TMASK  |
 *  |       |               |U|     |XTMSK|         |     |         |
 *  +-------+---------------+-+-----+-----+---------+-----+---------+
 *   <----->                   <--->                 <--->
 *  IFM_INST()               IFM_MODE()            IFM_TYPE()
 *
 *                              IFM_SUBTYPE(other than ETH)<------->
 *
 *                                   <---> IFM_SUBTYPE(ETH)<------->
 *
 *
 *           <------------->         <------------->
 *                        IFM_OPTIONS()
2019-05-17 07:37:11 +00:00
msaitoh d39d3b7cbe Remove extra parenthesis. 2019-05-10 06:33:14 +00:00
msaitoh 2d2e9967e8 No functional change:
- IFM_AVALID and IFM_ACTIVE are NOT for the media word. Fix comment.
 - RFU stands for Reserved for Future Use.
2019-04-24 05:07:20 +00:00
msaitoh 9cbcc61c49 Tabify. No functional change. 2019-04-17 07:04:03 +00:00
msaitoh 3a978cd9a9 Add 2.5GBASE-T and 5GBASE-T. 2017-10-04 07:08:01 +00:00
msaitoh 14fe90e75f All Ethernet media more than 1000Mbps don't support half duplex.
For the convinience, ifconfig without "mediaopt fullduplex" sets IFM_FDX
automatically for those medias. Without this change, "ifconfig xxN mediaopt
10Gbase-T" (without "mediaopt fullduplex") returns EINVAL if a
driver doesn't call ifmedia_add() without IFM_FDX because ifmedia_match()
returns NULL.
2017-10-04 07:07:16 +00:00
msaitoh d6348fce0d - Add some missing baudrate entries
- Add 1000BASE-KX and 2500BASE-KX
2017-06-08 02:27:30 +00:00
msaitoh 0be9b65b46 No functional change:
- Relocate definitions in the following order to be easy to understand.
 0) IFM_*MASK
 1) macros to extract various bits of information from the media word.
 2) Media type.
 3) Shared media sub-type.
 4) Status bits.
 5) Shared (global) options
 6) Media dependent definitions.
 7) kernel function declarations.
 7) userland function declarations.
- Add comments.

This change makes me realize that:
 0) RFU bit have never used.
 1) bit 1..0 are shared between Shared media sub-type and Status bits.
    It's little dangerous.
 2) No. 5 of Media type is not used (hole).
 3) Only IEEE80211 uses IFM_MMASK(IFM_MODE()) bits.
 4) IFM_TOKEN's OMASK bits doesn't start from 0x00000100 but starts from
    0x00000200. Is this for BSD/OS compatibility?
2017-06-05 08:50:07 +00:00
roy 169f562155 Introduce IFM_GENERIC.
This allows use of the media interface, but without media as such.
It's sole purpose is to facilitate the reporting of the link status.
2016-09-14 11:43:08 +00:00
msaitoh 11dd166429 Add 1000baseT-FDX. 2012-10-25 10:59:43 +00:00
cegger 126af76cac add MBSS. From FreeBSD. 2011-02-20 13:51:17 +00:00
dyoung 7617f65929 Add some 10-gigabit media words used by Intel 82599. 2011-01-26 00:57:47 +00:00
dyoung 7b7a580067 Replace u_quad_t with uint64_t. u_quad_t is just a typedef for
uint64_t, so no ABI/API breakage will result from this change.
2009-10-05 21:25:05 +00:00
msaitoh 7dc1329052 Add 1000BASE-BX10. 2009-08-12 11:17:17 +00:00
mhitch 70a12d51ab Add support for SerDes controllers; from the OpenBSD driver. Tested on a
Dell Blade server by me, and an HP Blade server by Havard.
2008-09-09 20:12:18 +00:00
christos ab4f03ff74 - Add more definitions from FreeBSD
- Add ifmedia_removeall from FreeBSD
2008-06-15 16:33:58 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
skrll 5bdccff36c CARP is Common *Address* Redundancy Protocol 2008-02-13 09:25:24 +00:00
dyoung 72fea72bb2 Add a helper subroutine for ethernet drivers, ifmedia_change(). 2008-01-10 08:00:22 +00:00
ragge cb7f51a59d Add IFM_10G_SR and IFM_10G_CX4, to keep in sync with FreeBSD.
Kindly requested by Gleb Smirnoff at FreeBSD.
2006-06-03 12:43:28 +00:00
liamjfoy 4876c304b1 Integrate Common Address Redundancy Procotol (CARP) from OpenBSD
'pseudo-device	carp'

Thanks to: joerg@ christos@ riz@ and others who tested
Ok: core@
2006-05-18 09:05:49 +00:00
lukem a1f606d3fd Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.
Add a space between numbers and Hz unit.
2006-03-08 23:46:22 +00:00
elad 976bf6cfdd Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.
2005-12-10 23:21:38 +00:00
dsl de3f63a902 Add prototypes for functions that convert media to/from strings.
In libutil/if_media.c (moved from ifconfig.c so that they can be shared
in crunched binaries)
2004-11-11 20:34:30 +00:00
dsl 43dde40d82 Put spaces either side of '|' for clarity ('|' looks too much like 'I' or 'l') 2004-10-16 11:11:04 +00:00
thorpej 15921b5f23 De-__P'ify. 2004-04-09 20:44:57 +00:00
thorpej 13357b24dd Add flow control-related media bits / descriptions.
From HITOSHI Osada.
2004-04-09 20:30:28 +00:00
keihan 2ece851d2e Add 10GBASE-LR to IFM_10G_LR. 2004-03-10 14:42:10 +00:00
ragge 9a3ec25f87 Add media type 10GbaseLR. Change ifmb_baudrate and ifmedia_baudrate()
to u_quad_t instead of int (common speed today exceeds 2Gbit).
2004-02-19 11:58:30 +00:00
dyoung dd813020b9 Add constants and strings for 802.11 radios with OFDM PHY (802.11a,
802.11g).

Add constants and strings for multi-mode devices (a/b/g).

From FreeBSD/Sam Leffler.
2003-10-13 05:06:44 +00:00
itojun 91b11e1eba prototype must not have variable name 2003-07-08 07:13:50 +00:00
bjh21 c4987984da Accept standard IEEE 802.3 names for Ethernet medium types.
Suggested by Christos, IIRC.
2003-04-23 23:16:43 +00:00
dyoung 595c6d88b2 Add support for Prism monitor mode. From Kevin Lahey
<kml@patheticgeek.net>.

This patch does NOT add monitor mode support for the Lucent radios.

awi(4) was only modified for compatibility with the new mediaopt.
It does NOT support monitor mode.

Tested by Kevin, Daniel Carosone, and I.
2003-02-25 01:57:35 +00:00
thorpej f5c6a07c43 Fix more signed/unsigned comparison warnings. 2002-11-07 08:00:47 +00:00
thorpej 079b24a323 Make ifm_data unsigned. 2002-11-07 07:53:37 +00:00
thorpej facf465586 Make media and mask unsigned. 2002-11-07 07:42:24 +00:00
onoe 23ab1acf02 Change ifmb_baudrate for IFM_IEEE80211_DS5: 5Mbps -> 5.5Mbps 2002-09-27 05:27:20 +00:00
onoe 63a1f2ed02 Delete IFM_IEEE80211_IBSS [ibss] and IFM_IEEE80211_IBSSMASTER [ibss-master]
from media options, since IEEE80211_ADHOC [adhoc] is already defined for
IBSS.  Instead, [ibss] is assigned as an alias for IEEE80211_ADHOC.
2002-08-21 03:22:04 +00:00
thorpej 0eee4f1a69 Add "hostap", "ibss", and "ibss-master" 802.11 media options.
From OpenBSD.
2002-08-10 23:21:58 +00:00
kleink e2d6ca2037 Rename an IFM_1000_TX occurrence missed in previous. 2001-06-30 21:23:39 +00:00
bjh21 8d829065a6 IFM_1000_TX -> IFM_1000_T, as (breifly) discussed on tech-net. 2001-06-30 17:53:58 +00:00
thorpej a6e732946b Add an Ethernet option bit for master mode (for 1000baseTX, the link
master provides the clock -- this is normally the switch, but if you
are doing back-to-back NICs, you need to tell one side to be the master).
2001-05-31 16:30:04 +00:00
thorpej 877704d33e Add ifmedia_baudrate(), which returns a value suitable for ifi_baudrate
given a media word, or 0 for unknown.
2000-03-06 20:50:29 +00:00
sommerfeld a00eb27e1a More 802.11 subtypes: there's also 1MB/s DS
(the BayStack 660 firmware claims to support it).
2000-02-17 21:53:16 +00:00
thorpej d87b838524 Fix TMASK to use all 5 lower bits of the media word, and add HomePNA 1.0. 2000-02-16 18:03:14 +00:00
thorpej 3302e4f5a2 Add a way to delete all media for a specified instance. 2000-01-26 21:58:17 +00:00
thorpej 52ee0b9f98 IFM_1000_FX -> IFM_1000_SX, like it's supposed to be, and add a few
more gigabit Ethernet tyes from FreeBSD.
2000-01-25 20:18:52 +00:00