FreeBSD/sys/dev/vnic/thunder_bgx.c
/* Configure BGX LMAC in internal loopback mode */
Configure BGX LMAC in internal loopback mode
Configure BGX LMAC in internal loopback mode
void
bgx_lmac_internal_loopback(int node, int bgx_idx,
    int lmac_idx, boolean_t enable)
{
	struct bgx *bgx;
	struct lmac *lmac;
	uint64_t cfg;
	bgx = bgx_vnic[(node * MAX_BGX_PER_CN88XX) + bgx_idx];
	if (bgx == NULL)
		return;
	lmac = &bgx->lmac[lmac_idx];
	if (lmac->is_sgmii) {
		cfg = bgx_reg_read(bgx, lmac_idx, BGX_GMP_PCS_MRX_CTL);
		if (enable)
			cfg |= PCS_MRX_CTL_LOOPBACK1;
		else
			cfg &= ~PCS_MRX_CTL_LOOPBACK1;
		bgx_reg_write(bgx, lmac_idx, BGX_GMP_PCS_MRX_CTL, cfg);
	} else {
		cfg = bgx_reg_read(bgx, lmac_idx, BGX_SPUX_CONTROL1);
		if (enable)
			cfg |= SPU_CTL_LOOPBACK;
		else
			cfg &= ~SPU_CTL_LOOPBACK;
		bgx_reg_write(bgx, lmac_idx, BGX_SPUX_CONTROL1, cfg);
	}
}
void bgx_lmac_internal_loopback ( int node , int bgx_idx , int lmac_idx , boolean_t enable ) { struct bgx * bgx ; struct lmac * lmac ; uint64_t cfg ; bgx = bgx_vnic [ ( node * MAX_BGX_PER_CN88XX ) + bgx_idx ] ; if ( bgx == NULL ) return ; lmac = & bgx -> lmac [ lmac_idx ] ; if ( lmac -> is_sgmii ) { cfg = bgx_reg_read ( bgx , lmac_idx , BGX_GMP_PCS_MRX_CTL ) ; if ( enable ) cfg |= PCS_MRX_CTL_LOOPBACK1 ; else cfg &= ~ PCS_MRX_CTL_LOOPBACK1 ; bgx_reg_write ( bgx , lmac_idx , BGX_GMP_PCS_MRX_CTL , cfg ) ; } else { cfg = bgx_reg_read ( bgx , lmac_idx , BGX_SPUX_CONTROL1 ) ; if ( enable ) cfg |= SPU_CTL_LOOPBACK ; else cfg &= ~ SPU_CTL_LOOPBACK ; bgx_reg_write ( bgx , lmac_idx , BGX_SPUX_CONTROL1 , cfg ) ; } }
Configure BGX LMAC in internal loopback mode
Configure BGX LMAC in internal loopback mode