FreeBSD/sys/dev/e1000/if_em.c
/*********************************************************************
 *
 *  Media Ioctl callback
 *
 *  This routine is called whenever the user queries the status of
 *  the interface using ifconfig.
 *
 **********************************************************************/
Media Ioctl callback
This routine is called whenever the user queries the status of
the interface using ifconfig.
Media Ioctl callback This routine is called whenever the user queries the status of the interface using ifconfig .
static void
em_media_status(if_t ifp, struct ifmediareq *ifmr)
{
	struct adapter *adapter = if_getsoftc(ifp);
	u_char fiber_type = IFM_1000_SX;
	INIT_DEBUGOUT("em_media_status: begin");
	EM_CORE_LOCK(adapter);
	em_update_link_status(adapter);
	ifmr->ifm_status = IFM_AVALID;
	ifmr->ifm_active = IFM_ETHER;
	if (!adapter->link_active) {
		EM_CORE_UNLOCK(adapter);
		return;
	}
	ifmr->ifm_status |= IFM_ACTIVE;
	if ((adapter->hw.phy.media_type == e1000_media_type_fiber) ||
	    (adapter->hw.phy.media_type == e1000_media_type_internal_serdes)) {
		ifmr->ifm_active |= fiber_type | IFM_FDX;
	} else {
		switch (adapter->link_speed) {
		case 10:
			ifmr->ifm_active |= IFM_10_T;
			break;
		case 100:
			ifmr->ifm_active |= IFM_100_TX;
			break;
		case 1000:
			ifmr->ifm_active |= IFM_1000_T;
			break;
		}
		if (adapter->link_duplex == FULL_DUPLEX)
			ifmr->ifm_active |= IFM_FDX;
		else
			ifmr->ifm_active |= IFM_HDX;
	}
	EM_CORE_UNLOCK(adapter);
}
static void em_media_status ( if_t ifp , struct ifmediareq * ifmr ) { struct adapter * adapter = if_getsoftc ( ifp ) ; u_char fiber_type = IFM_1000_SX ; INIT_DEBUGOUT ( " " ) ; EM_CORE_LOCK ( adapter ) ; em_update_link_status ( adapter ) ; ifmr -> ifm_status = IFM_AVALID ; ifmr -> ifm_active = IFM_ETHER ; if ( ! adapter -> link_active ) { EM_CORE_UNLOCK ( adapter ) ; return ; } ifmr -> ifm_status |= IFM_ACTIVE ; if ( ( adapter -> hw . phy . media_type == e1000_media_type_fiber ) || ( adapter -> hw . phy . media_type == e1000_media_type_internal_serdes ) ) { ifmr -> ifm_active |= fiber_type | IFM_FDX ; } else { switch ( adapter -> link_speed ) { case 10 : ifmr -> ifm_active |= IFM_10_T ; break ; case 100 : ifmr -> ifm_active |= IFM_100_TX ; break ; case 1000 : ifmr -> ifm_active |= IFM_1000_T ; break ; } if ( adapter -> link_duplex == FULL_DUPLEX ) ifmr -> ifm_active |= IFM_FDX ; else ifmr -> ifm_active |= IFM_HDX ; } EM_CORE_UNLOCK ( adapter ) ; }
Media Ioctl callback
  This routine is called whenever the user queries the status of
  the interface using ifconfig.
Media Ioctl callback This routine is called whenever the user queries the status of the interface using ifconfig .