FreeBSD/sys/dev/etherswitch/arswitch/arswitch.c
/*
 * Convert port status to ifmedia.
 */
Convert port status to ifmedia.
Convert port status to ifmedia .
static void
arswitch_update_ifmedia(int portstatus, u_int *media_status, u_int *media_active)
{
	*media_active = IFM_ETHER;
	*media_status = IFM_AVALID;
	if ((portstatus & AR8X16_PORT_STS_LINK_UP) != 0)
		*media_status |= IFM_ACTIVE;
	else {
		*media_active |= IFM_NONE;
		return;
	}
	switch (portstatus & AR8X16_PORT_STS_SPEED_MASK) {
	case AR8X16_PORT_STS_SPEED_10:
		*media_active |= IFM_10_T;
		break;
	case AR8X16_PORT_STS_SPEED_100:
		*media_active |= IFM_100_TX;
		break;
	case AR8X16_PORT_STS_SPEED_1000:
		*media_active |= IFM_1000_T;
		break;
	}
	if ((portstatus & AR8X16_PORT_STS_DUPLEX) == 0)
		*media_active |= IFM_FDX;
	else
		*media_active |= IFM_HDX;
	if ((portstatus & AR8X16_PORT_STS_TXFLOW) != 0)
		*media_active |= IFM_ETH_TXPAUSE;
	if ((portstatus & AR8X16_PORT_STS_RXFLOW) != 0)
		*media_active |= IFM_ETH_RXPAUSE;
}
static void arswitch_update_ifmedia ( int portstatus , u_int * media_status , u_int * media_active ) { * media_active = IFM_ETHER ; * media_status = IFM_AVALID ; if ( ( portstatus & AR8X16_PORT_STS_LINK_UP ) != 0 ) * media_status |= IFM_ACTIVE ; else { * media_active |= IFM_NONE ; return ; } switch ( portstatus & AR8X16_PORT_STS_SPEED_MASK ) { case AR8X16_PORT_STS_SPEED_10 : * media_active |= IFM_10_T ; break ; case AR8X16_PORT_STS_SPEED_100 : * media_active |= IFM_100_TX ; break ; case AR8X16_PORT_STS_SPEED_1000 : * media_active |= IFM_1000_T ; break ; } if ( ( portstatus & AR8X16_PORT_STS_DUPLEX ) == 0 ) * media_active |= IFM_FDX ; else * media_active |= IFM_HDX ; if ( ( portstatus & AR8X16_PORT_STS_TXFLOW ) != 0 ) * media_active |= IFM_ETH_TXPAUSE ; if ( ( portstatus & AR8X16_PORT_STS_RXFLOW ) != 0 ) * media_active |= IFM_ETH_RXPAUSE ; }
Convert port status to ifmedia.
Convert port status to ifmedia .