FreeBSD/sys/dev/e1000/if_em.c
/*********************************************************************
 *
 *  Media Ioctl callback
 *
 *  This routine is called when the user changes speed/duplex using
 *  media/mediopt option with ifconfig.
 *
 **********************************************************************/
Media Ioctl callback
This routine is called when the user changes speed/duplex using
media/mediopt option with ifconfig.
Media Ioctl callback This routine is called when the user changes speed / duplex using media / mediopt option with ifconfig .
static int
em_media_change(if_t ifp)
{
	struct adapter *adapter = if_getsoftc(ifp);
	struct ifmedia  *ifm = &adapter->media;
	INIT_DEBUGOUT("em_media_change: begin");
	if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
		return (EINVAL);
	EM_CORE_LOCK(adapter);
	switch (IFM_SUBTYPE(ifm->ifm_media)) {
	case IFM_AUTO:
		adapter->hw.mac.autoneg = DO_AUTO_NEG;
		adapter->hw.phy.autoneg_advertised = AUTONEG_ADV_DEFAULT;
		break;
	case IFM_1000_LX:
	case IFM_1000_SX:
	case IFM_1000_T:
		adapter->hw.mac.autoneg = DO_AUTO_NEG;
		adapter->hw.phy.autoneg_advertised = ADVERTISE_1000_FULL;
		break;
	case IFM_100_TX:
		adapter->hw.mac.autoneg = FALSE;
		adapter->hw.phy.autoneg_advertised = 0;
		if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX)
			adapter->hw.mac.forced_speed_duplex = ADVERTISE_100_FULL;
		else
			adapter->hw.mac.forced_speed_duplex = ADVERTISE_100_HALF;
		break;
	case IFM_10_T:
		adapter->hw.mac.autoneg = FALSE;
		adapter->hw.phy.autoneg_advertised = 0;
		if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX)
			adapter->hw.mac.forced_speed_duplex = ADVERTISE_10_FULL;
		else
			adapter->hw.mac.forced_speed_duplex = ADVERTISE_10_HALF;
		break;
	default:
		device_printf(adapter->dev, "Unsupported media type\n");
	}
	em_init_locked(adapter);
	EM_CORE_UNLOCK(adapter);
	return (0);
}
static int em_media_change ( if_t ifp ) { struct adapter * adapter = if_getsoftc ( ifp ) ; struct ifmedia * ifm = & adapter -> media ; INIT_DEBUGOUT ( " " ) ; if ( IFM_TYPE ( ifm -> ifm_media ) != IFM_ETHER ) return ( EINVAL ) ; EM_CORE_LOCK ( adapter ) ; switch ( IFM_SUBTYPE ( ifm -> ifm_media ) ) { case IFM_AUTO : adapter -> hw . mac . autoneg = DO_AUTO_NEG ; adapter -> hw . phy . autoneg_advertised = AUTONEG_ADV_DEFAULT ; break ; case IFM_1000_LX : case IFM_1000_SX : case IFM_1000_T : adapter -> hw . mac . autoneg = DO_AUTO_NEG ; adapter -> hw . phy . autoneg_advertised = ADVERTISE_1000_FULL ; break ; case IFM_100_TX : adapter -> hw . mac . autoneg = FALSE ; adapter -> hw . phy . autoneg_advertised = 0 ; if ( ( ifm -> ifm_media & IFM_GMASK ) == IFM_FDX ) adapter -> hw . mac . forced_speed_duplex = ADVERTISE_100_FULL ; else adapter -> hw . mac . forced_speed_duplex = ADVERTISE_100_HALF ; break ; case IFM_10_T : adapter -> hw . mac . autoneg = FALSE ; adapter -> hw . phy . autoneg_advertised = 0 ; if ( ( ifm -> ifm_media & IFM_GMASK ) == IFM_FDX ) adapter -> hw . mac . forced_speed_duplex = ADVERTISE_10_FULL ; else adapter -> hw . mac . forced_speed_duplex = ADVERTISE_10_HALF ; break ; default : device_printf ( adapter -> dev , " \n " ) ; } em_init_locked ( adapter ) ; EM_CORE_UNLOCK ( adapter ) ; return ( 0 ) ; }
Media Ioctl callback
  This routine is called when the user changes speed/duplex using
  media/mediopt option with ifconfig.
Media Ioctl callback This routine is called when the user changes speed / duplex using media / mediopt option with ifconfig .