FreeBSD/sys/dev/ixl/ixl_pf_main.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 .
void
ixl_media_status(struct ifnet * ifp, struct ifmediareq * ifmr)
{
	struct ixl_vsi	*vsi = ifp->if_softc;
	struct ixl_pf	*pf = vsi->back;
	struct i40e_hw  *hw = &pf->hw;
	INIT_DEBUGOUT("ixl_media_status: begin");
	IXL_PF_LOCK(pf);
	hw->phy.get_link_info = TRUE;
	i40e_get_link_status(hw, &pf->link_up);
	ixl_update_link_status(pf);
	ifmr->ifm_status = IFM_AVALID;
	ifmr->ifm_active = IFM_ETHER;
	if (!pf->link_up) {
		IXL_PF_UNLOCK(pf);
		return;
	}
	ifmr->ifm_status |= IFM_ACTIVE;
	ifmr->ifm_active |= IFM_FDX;
	switch (hw->phy.link_info.phy_type) {
		case I40E_PHY_TYPE_100BASE_TX:
			ifmr->ifm_active |= IFM_100_TX;
			break;
		case I40E_PHY_TYPE_1000BASE_T:
			ifmr->ifm_active |= IFM_1000_T;
			break;
		case I40E_PHY_TYPE_1000BASE_SX:
			ifmr->ifm_active |= IFM_1000_SX;
			break;
		case I40E_PHY_TYPE_1000BASE_LX:
			ifmr->ifm_active |= IFM_1000_LX;
			break;
		case I40E_PHY_TYPE_1000BASE_T_OPTICAL:
			ifmr->ifm_active |= IFM_OTHER;
			break;
		case I40E_PHY_TYPE_10GBASE_SFPP_CU:
			ifmr->ifm_active |= IFM_10G_TWINAX;
			break;
		case I40E_PHY_TYPE_10GBASE_SR:
			ifmr->ifm_active |= IFM_10G_SR;
			break;
		case I40E_PHY_TYPE_10GBASE_LR:
			ifmr->ifm_active |= IFM_10G_LR;
			break;
		case I40E_PHY_TYPE_10GBASE_T:
			ifmr->ifm_active |= IFM_10G_T;
			break;
		case I40E_PHY_TYPE_XAUI:
		case I40E_PHY_TYPE_XFI:
		case I40E_PHY_TYPE_10GBASE_AOC:
			ifmr->ifm_active |= IFM_OTHER;
			break;
		case I40E_PHY_TYPE_40GBASE_CR4:
		case I40E_PHY_TYPE_40GBASE_CR4_CU:
			ifmr->ifm_active |= IFM_40G_CR4;
			break;
		case I40E_PHY_TYPE_40GBASE_SR4:
			ifmr->ifm_active |= IFM_40G_SR4;
			break;
		case I40E_PHY_TYPE_40GBASE_LR4:
			ifmr->ifm_active |= IFM_40G_LR4;
			break;
		case I40E_PHY_TYPE_XLAUI:
			ifmr->ifm_active |= IFM_OTHER;
			break;
		case I40E_PHY_TYPE_1000BASE_KX:
			ifmr->ifm_active |= IFM_1000_KX;
			break;
		case I40E_PHY_TYPE_SGMII:
			ifmr->ifm_active |= IFM_1000_SGMII;
			break;
		case I40E_PHY_TYPE_10GBASE_CR1_CU:
		case I40E_PHY_TYPE_10GBASE_CR1:
			ifmr->ifm_active |= IFM_10G_CR1;
			break;
		case I40E_PHY_TYPE_10GBASE_KX4:
			ifmr->ifm_active |= IFM_10G_KX4;
			break;
		case I40E_PHY_TYPE_10GBASE_KR:
			ifmr->ifm_active |= IFM_10G_KR;
			break;
		case I40E_PHY_TYPE_SFI:
			ifmr->ifm_active |= IFM_10G_SFI;
			break;
		case I40E_PHY_TYPE_20GBASE_KR2:
			ifmr->ifm_active |= IFM_20G_KR2;
			break;
		case I40E_PHY_TYPE_40GBASE_KR4:
			ifmr->ifm_active |= IFM_40G_KR4;
			break;
		case I40E_PHY_TYPE_XLPPI:
		case I40E_PHY_TYPE_40GBASE_AOC:
			ifmr->ifm_active |= IFM_40G_XLPPI;
			break;
		default:
			ifmr->ifm_active |= IFM_UNKNOWN;
			break;
	}
	if (hw->phy.link_info.an_info & I40E_AQ_LINK_PAUSE_TX)
		ifmr->ifm_active |= IFM_ETH_TXPAUSE;
	if (hw->phy.link_info.an_info & I40E_AQ_LINK_PAUSE_RX)
		ifmr->ifm_active |= IFM_ETH_RXPAUSE;
	IXL_PF_UNLOCK(pf);
}
void ixl_media_status ( struct ifnet * ifp , struct ifmediareq * ifmr ) { struct ixl_vsi * vsi = ifp -> if_softc ; struct ixl_pf * pf = vsi -> back ; struct i40e_hw * hw = & pf -> hw ; INIT_DEBUGOUT ( " " ) ; IXL_PF_LOCK ( pf ) ; hw -> phy . get_link_info = TRUE ; i40e_get_link_status ( hw , & pf -> link_up ) ; ixl_update_link_status ( pf ) ; ifmr -> ifm_status = IFM_AVALID ; ifmr -> ifm_active = IFM_ETHER ; if ( ! pf -> link_up ) { IXL_PF_UNLOCK ( pf ) ; return ; } ifmr -> ifm_status |= IFM_ACTIVE ; ifmr -> ifm_active |= IFM_FDX ; switch ( hw -> phy . link_info . phy_type ) { case I40E_PHY_TYPE_100BASE_TX : ifmr -> ifm_active |= IFM_100_TX ; break ; case I40E_PHY_TYPE_1000BASE_T : ifmr -> ifm_active |= IFM_1000_T ; break ; case I40E_PHY_TYPE_1000BASE_SX : ifmr -> ifm_active |= IFM_1000_SX ; break ; case I40E_PHY_TYPE_1000BASE_LX : ifmr -> ifm_active |= IFM_1000_LX ; break ; case I40E_PHY_TYPE_1000BASE_T_OPTICAL : ifmr -> ifm_active |= IFM_OTHER ; break ; case I40E_PHY_TYPE_10GBASE_SFPP_CU : ifmr -> ifm_active |= IFM_10G_TWINAX ; break ; case I40E_PHY_TYPE_10GBASE_SR : ifmr -> ifm_active |= IFM_10G_SR ; break ; case I40E_PHY_TYPE_10GBASE_LR : ifmr -> ifm_active |= IFM_10G_LR ; break ; case I40E_PHY_TYPE_10GBASE_T : ifmr -> ifm_active |= IFM_10G_T ; break ; case I40E_PHY_TYPE_XAUI : case I40E_PHY_TYPE_XFI : case I40E_PHY_TYPE_10GBASE_AOC : ifmr -> ifm_active |= IFM_OTHER ; break ; case I40E_PHY_TYPE_40GBASE_CR4 : case I40E_PHY_TYPE_40GBASE_CR4_CU : ifmr -> ifm_active |= IFM_40G_CR4 ; break ; case I40E_PHY_TYPE_40GBASE_SR4 : ifmr -> ifm_active |= IFM_40G_SR4 ; break ; case I40E_PHY_TYPE_40GBASE_LR4 : ifmr -> ifm_active |= IFM_40G_LR4 ; break ; case I40E_PHY_TYPE_XLAUI : ifmr -> ifm_active |= IFM_OTHER ; break ; case I40E_PHY_TYPE_1000BASE_KX : ifmr -> ifm_active |= IFM_1000_KX ; break ; case I40E_PHY_TYPE_SGMII : ifmr -> ifm_active |= IFM_1000_SGMII ; break ; case I40E_PHY_TYPE_10GBASE_CR1_CU : case I40E_PHY_TYPE_10GBASE_CR1 : ifmr -> ifm_active |= IFM_10G_CR1 ; break ; case I40E_PHY_TYPE_10GBASE_KX4 : ifmr -> ifm_active |= IFM_10G_KX4 ; break ; case I40E_PHY_TYPE_10GBASE_KR : ifmr -> ifm_active |= IFM_10G_KR ; break ; case I40E_PHY_TYPE_SFI : ifmr -> ifm_active |= IFM_10G_SFI ; break ; case I40E_PHY_TYPE_20GBASE_KR2 : ifmr -> ifm_active |= IFM_20G_KR2 ; break ; case I40E_PHY_TYPE_40GBASE_KR4 : ifmr -> ifm_active |= IFM_40G_KR4 ; break ; case I40E_PHY_TYPE_XLPPI : case I40E_PHY_TYPE_40GBASE_AOC : ifmr -> ifm_active |= IFM_40G_XLPPI ; break ; default : ifmr -> ifm_active |= IFM_UNKNOWN ; break ; } if ( hw -> phy . link_info . an_info & I40E_AQ_LINK_PAUSE_TX ) ifmr -> ifm_active |= IFM_ETH_TXPAUSE ; if ( hw -> phy . link_info . an_info & I40E_AQ_LINK_PAUSE_RX ) ifmr -> ifm_active |= IFM_ETH_RXPAUSE ; IXL_PF_UNLOCK ( pf ) ; }
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 .
/* Hardware always does full-duplex */ /* 100 M */ /* 1 G */ /* 10 G */ /* 40 G */ /* ERJ: What's the difference between these? */ /* Our single 20G media type */ /* Unknown to driver */ /* Report flow control status as well */