FreeBSD/sys/dev/cxgb/cxgb_main.c
/*
 * Rebuilds the ifmedia list for this port, and sets the current media.
 */
Rebuilds the ifmedia list for this port, and sets the current media.
Rebuilds the ifmedia list for this port and sets the current media .
static void
cxgb_build_medialist(struct port_info *p)
{
	struct cphy *phy = &p->phy;
	struct ifmedia *media = &p->media;
	int mod = phy->modtype;
	int m = IFM_ETHER | IFM_FDX;
	PORT_LOCK(p);
	ifmedia_removeall(media);
	if (phy->caps & SUPPORTED_TP && phy->caps & SUPPORTED_Autoneg) {
		if (phy->caps & SUPPORTED_10000baseT_Full)
			ifmedia_add(media, m | IFM_10G_T, mod, NULL);
		if (phy->caps & SUPPORTED_1000baseT_Full)
			ifmedia_add(media, m | IFM_1000_T, mod, NULL);
		if (phy->caps & SUPPORTED_100baseT_Full)
			ifmedia_add(media, m | IFM_100_TX, mod, NULL);
		if (phy->caps & SUPPORTED_10baseT_Full)
			ifmedia_add(media, m | IFM_10_T, mod, NULL);
		ifmedia_add(media, IFM_ETHER | IFM_AUTO, mod, NULL);
		ifmedia_set(media, IFM_ETHER | IFM_AUTO);
	} else if (phy->caps & SUPPORTED_TP) {
		KASSERT(phy->caps & SUPPORTED_10000baseT_Full,
			("%s: unexpected cap 0x%x", __func__, phy->caps));
		ifmedia_add(media, m | IFM_10G_CX4, mod, NULL);
		ifmedia_set(media, m | IFM_10G_CX4);
	} else if (phy->caps & SUPPORTED_FIBRE &&
		   phy->caps & SUPPORTED_10000baseT_Full) {
		m |= cxgb_ifm_type(mod);
		if (IFM_SUBTYPE(m) == IFM_NONE)
			m &= ~IFM_FDX;
		ifmedia_add(media, m, mod, NULL);
		ifmedia_set(media, m);
	} else if (phy->caps & SUPPORTED_FIBRE &&
		   phy->caps & SUPPORTED_1000baseT_Full) {
		ifmedia_add(media, m | IFM_1000_SX, mod, NULL);
		ifmedia_set(media, m | IFM_1000_SX);
	} else {
		KASSERT(0, ("%s: don't know how to handle 0x%x.", __func__,
			    phy->caps));
	}
	PORT_UNLOCK(p);
}
static void cxgb_build_medialist ( struct port_info * p ) { struct cphy * phy = & p -> phy ; struct ifmedia * media = & p -> media ; int mod = phy -> modtype ; int m = IFM_ETHER | IFM_FDX ; PORT_LOCK ( p ) ; ifmedia_removeall ( media ) ; if ( phy -> caps & SUPPORTED_TP && phy -> caps & SUPPORTED_Autoneg ) { if ( phy -> caps & SUPPORTED_10000baseT_Full ) ifmedia_add ( media , m | IFM_10G_T , mod , NULL ) ; if ( phy -> caps & SUPPORTED_1000baseT_Full ) ifmedia_add ( media , m | IFM_1000_T , mod , NULL ) ; if ( phy -> caps & SUPPORTED_100baseT_Full ) ifmedia_add ( media , m | IFM_100_TX , mod , NULL ) ; if ( phy -> caps & SUPPORTED_10baseT_Full ) ifmedia_add ( media , m | IFM_10_T , mod , NULL ) ; ifmedia_add ( media , IFM_ETHER | IFM_AUTO , mod , NULL ) ; ifmedia_set ( media , IFM_ETHER | IFM_AUTO ) ; } else if ( phy -> caps & SUPPORTED_TP ) { KASSERT ( phy -> caps & SUPPORTED_10000baseT_Full , ( " " , __func__ , phy -> caps ) ) ; ifmedia_add ( media , m | IFM_10G_CX4 , mod , NULL ) ; ifmedia_set ( media , m | IFM_10G_CX4 ) ; } else if ( phy -> caps & SUPPORTED_FIBRE && phy -> caps & SUPPORTED_10000baseT_Full ) { m |= cxgb_ifm_type ( mod ) ; if ( IFM_SUBTYPE ( m ) == IFM_NONE ) m &= ~ IFM_FDX ; ifmedia_add ( media , m , mod , NULL ) ; ifmedia_set ( media , m ) ; } else if ( phy -> caps & SUPPORTED_FIBRE && phy -> caps & SUPPORTED_1000baseT_Full ) { ifmedia_add ( media , m | IFM_1000_SX , mod , NULL ) ; ifmedia_set ( media , m | IFM_1000_SX ) ; } else { KASSERT ( 0 , ( " " , __func__ , phy -> caps ) ) ; } PORT_UNLOCK ( p ) ; }
Rebuilds the ifmedia list for this port, and sets the current media.
Rebuilds the ifmedia list for this port and sets the current media .
/* Copper (RJ45) */ /* Copper (CX4) */ /* 10G optical (but includes SFP+ twinax) */ /* 1G optical */ /* XXX: Lie and claim to be SX, could actually be any 1G-X */