FreeBSD/sys/dev/cxgb/common/cxgb_xgmac.c
/**
 *	t3_mac_enable - enable the MAC in the given directions
 *	@mac: the MAC to configure
 *	@which: bitmap indicating which directions to enable
 *
 *	Enables the MAC for operation in the given directions.
 *	%MAC_DIRECTION_TX enables the Tx direction, and %MAC_DIRECTION_RX
 *	enables the Rx one.
 */
enable the MAC in the given directions
@mac: the MAC to configure
@which: bitmap indicating which directions to enable

Enables the MAC for operation in the given directions.
%MAC_DIRECTION_TX enables the Tx direction, and %MAC_DIRECTION_RX
enables the Rx one.
enable the MAC in the given directions @mac : the MAC to configure @which : bitmap indicating which directions to enable Enables the MAC for operation in the given directions . %MAC_DIRECTION_TX enables the Tx direction and %MAC_DIRECTION_RX enables the Rx one .
int t3_mac_enable(struct cmac *mac, int which)
{
	int idx = macidx(mac);
	adapter_t *adap = mac->adapter;
	unsigned int oft = mac->offset;
	struct mac_stats *s = &mac->stats;
	if (mac->multiport)
		return t3_vsc7323_enable(adap, mac->ext_port, which);
	if (which & MAC_DIRECTION_TX) {
		t3_write_reg(adap, A_TP_PIO_ADDR, A_TP_TX_DROP_CFG_CH0 + idx);
		t3_write_reg(adap, A_TP_PIO_DATA,
			     adap->params.rev == T3_REV_C ?
			     0xc4ffff01 : 0xc0ede401);
		t3_write_reg(adap, A_TP_PIO_ADDR, A_TP_TX_DROP_MODE);
		t3_set_reg_field(adap, A_TP_PIO_DATA, 1 << idx,
				 adap->params.rev == T3_REV_C ?
				 0 : 1 << idx);
		t3_write_reg(adap, A_XGM_TX_CTRL + oft, F_TXEN);
		t3_write_reg(adap, A_TP_PIO_ADDR, A_TP_TX_DROP_CNT_CH0 + idx);
		mac->tx_mcnt = s->tx_frames;
		mac->tx_tcnt = (G_TXDROPCNTCH0RCVD(t3_read_reg(adap,
							       A_TP_PIO_DATA)));
		mac->tx_xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap,
						A_XGM_TX_SPI4_SOP_EOP_CNT +
						oft)));
		mac->rx_mcnt = s->rx_frames;
		mac->rx_pause = s->rx_pause;
		mac->rx_xcnt = (G_TXSPI4SOPCNT(t3_read_reg(adap,
						A_XGM_RX_SPI4_SOP_EOP_CNT +
						oft)));
		mac->rx_ocnt = s->rx_fifo_ovfl;
		mac->txen = F_TXEN;
		mac->toggle_cnt = 0;
	}
	if (which & MAC_DIRECTION_RX)
		t3_write_reg(adap, A_XGM_RX_CTRL + oft, F_RXEN);
	return 0;
}
int t3_mac_enable ( struct cmac * mac , int which ) { int idx = macidx ( mac ) ; adapter_t * adap = mac -> adapter ; unsigned int oft = mac -> offset ; struct mac_stats * s = & mac -> stats ; if ( mac -> multiport ) return t3_vsc7323_enable ( adap , mac -> ext_port , which ) ; if ( which & MAC_DIRECTION_TX ) { t3_write_reg ( adap , A_TP_PIO_ADDR , A_TP_TX_DROP_CFG_CH0 + idx ) ; t3_write_reg ( adap , A_TP_PIO_DATA , adap -> params . rev == T3_REV_C ? 0xc4ffff01 : 0xc0ede401 ) ; t3_write_reg ( adap , A_TP_PIO_ADDR , A_TP_TX_DROP_MODE ) ; t3_set_reg_field ( adap , A_TP_PIO_DATA , 1 << idx , adap -> params . rev == T3_REV_C ? 0 : 1 << idx ) ; t3_write_reg ( adap , A_XGM_TX_CTRL + oft , F_TXEN ) ; t3_write_reg ( adap , A_TP_PIO_ADDR , A_TP_TX_DROP_CNT_CH0 + idx ) ; mac -> tx_mcnt = s -> tx_frames ; mac -> tx_tcnt = ( G_TXDROPCNTCH0RCVD ( t3_read_reg ( adap , A_TP_PIO_DATA ) ) ) ; mac -> tx_xcnt = ( G_TXSPI4SOPCNT ( t3_read_reg ( adap , A_XGM_TX_SPI4_SOP_EOP_CNT + oft ) ) ) ; mac -> rx_mcnt = s -> rx_frames ; mac -> rx_pause = s -> rx_pause ; mac -> rx_xcnt = ( G_TXSPI4SOPCNT ( t3_read_reg ( adap , A_XGM_RX_SPI4_SOP_EOP_CNT + oft ) ) ) ; mac -> rx_ocnt = s -> rx_fifo_ovfl ; mac -> txen = F_TXEN ; mac -> toggle_cnt = 0 ; } if ( which & MAC_DIRECTION_RX ) t3_write_reg ( adap , A_XGM_RX_CTRL + oft , F_RXEN ) ; return 0 ; }
t3_mac_enable - enable the MAC in the given directions
      @mac: the MAC to configure
      @which: bitmap indicating which directions to enable
t3_mac_enable - enable the MAC in the given directions @mac : the MAC to configure @which : bitmap indicating which directions to enable