/* Setups the link between PHY and MAC and returns the status of connection. */
int32_t MSS_MAC_auto_setup_link(void)
/* Setups the link between PHY and MAC and returns the status of connection. */
int32_t MSS_MAC_auto_setup_link(void)
{
	int32_t link;
    PHY_auto_negotiate();
    link = MSS_MAC_link_status();
    if( (link & MSS_MAC_LINK_STATUS_LINK) != 0u ) {
    	int32_t ret;
	    ret = MAC_stop_transmission();
	    MAC_CHECK( ret == MAC_OK, ret );
	    ret = MAC_stop_receiving();
	    MAC_CHECK( ret == MAC_OK, ret );
        MAC_BITBAND->CSR6_TTM = (uint32_t)((((uint32_t)link & MSS_MAC_LINK_STATUS_100MB) != 0u) ? 1u : 0u );
        MAC_BITBAND->CSR6_FD = (uint32_t)((((uint32_t)link & MSS_MAC_LINK_STATUS_FDX) != 0u) ? 1u : 1u );
	    MAC_start_transmission();
	    MAC_start_receiving();
    }
    return link;
}