FreeBSD/sys/dev/cxgbe/common/t4_hw.c
/**
 *	t4_link_l1cfg - apply link configuration to MAC/PHY
 *	@phy: the PHY to setup
 *	@mac: the MAC to setup
 *	@lc: the requested link configuration
 *
 *	Set up a port's MAC and PHY according to a desired link configuration.
 *	- If the PHY can auto-negotiate first decide what to advertise, then
 *	  enable/disable auto-negotiation as desired, and reset.
 *	- If the PHY does not auto-negotiate just reset it.
 *	- If auto-negotiation is off set the MAC to the proper speed/duplex/FC,
 *	  otherwise do it later based on the outcome of auto-negotiation.
 */
apply link configuration to MAC/PHY
@phy: the PHY to setup
@mac: the MAC to setup
@lc: the requested link configuration

Set up a port's MAC and PHY according to a desired link configuration.
- If the PHY can auto-negotiate first decide what to advertise, then
enable/disable auto-negotiation as desired, and reset.
- If the PHY does not auto-negotiate just reset it.
- If auto-negotiation is off set the MAC to the proper speed/duplex/FC,
otherwise do it later based on the outcome of auto-negotiation.
apply link configuration to MAC / PHY @phy : the PHY to setup @mac : the MAC to setup @lc : the requested link configuration Set up a port ' s MAC and PHY according to a desired link configuration . - If the PHY can auto - negotiate first decide what to advertise then enable / disable auto - negotiation as desired and reset . - If the PHY does not auto - negotiate just reset it . - If auto - negotiation is off set the MAC to the proper speed / duplex / FC otherwise do it later based on the outcome of auto - negotiation .
int t4_link_l1cfg(struct adapter *adap, unsigned int mbox, unsigned int port,
		  struct link_config *lc)
{
	struct fw_port_cmd c;
	unsigned int fc = 0, mdi = V_FW_PORT_CAP_MDI(FW_PORT_CAP_MDI_AUTO);
	lc->link_ok = 0;
	if (lc->requested_fc & PAUSE_RX)
		fc |= FW_PORT_CAP_FC_RX;
	if (lc->requested_fc & PAUSE_TX)
		fc |= FW_PORT_CAP_FC_TX;
	memset(&c, 0, sizeof(c));
	c.op_to_portid = cpu_to_be32(V_FW_CMD_OP(FW_PORT_CMD) |
				     F_FW_CMD_REQUEST | F_FW_CMD_EXEC |
				     V_FW_PORT_CMD_PORTID(port));
	c.action_to_len16 =
		cpu_to_be32(V_FW_PORT_CMD_ACTION(FW_PORT_ACTION_L1_CFG) |
			    FW_LEN16(c));
	if (!(lc->supported & FW_PORT_CAP_ANEG)) {
		c.u.l1cfg.rcap = cpu_to_be32((lc->supported & ADVERT_MASK) |
					     fc);
		lc->fc = lc->requested_fc & (PAUSE_RX | PAUSE_TX);
	} else if (lc->autoneg == AUTONEG_DISABLE) {
		c.u.l1cfg.rcap = cpu_to_be32(lc->requested_speed | fc | mdi);
		lc->fc = lc->requested_fc & (PAUSE_RX | PAUSE_TX);
	} else
		c.u.l1cfg.rcap = cpu_to_be32(lc->advertising | fc | mdi);
	return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
}
int t4_link_l1cfg ( struct adapter * adap , unsigned int mbox , unsigned int port , struct link_config * lc ) { struct fw_port_cmd c ; unsigned int fc = 0 , mdi = V_FW_PORT_CAP_MDI ( FW_PORT_CAP_MDI_AUTO ) ; lc -> link_ok = 0 ; if ( lc -> requested_fc & PAUSE_RX ) fc |= FW_PORT_CAP_FC_RX ; if ( lc -> requested_fc & PAUSE_TX ) fc |= FW_PORT_CAP_FC_TX ; memset ( & c , 0 , sizeof ( c ) ) ; c . op_to_portid = cpu_to_be32 ( V_FW_CMD_OP ( FW_PORT_CMD ) | F_FW_CMD_REQUEST | F_FW_CMD_EXEC | V_FW_PORT_CMD_PORTID ( port ) ) ; c . action_to_len16 = cpu_to_be32 ( V_FW_PORT_CMD_ACTION ( FW_PORT_ACTION_L1_CFG ) | FW_LEN16 ( c ) ) ; if ( ! ( lc -> supported & FW_PORT_CAP_ANEG ) ) { c . u . l1cfg . rcap = cpu_to_be32 ( ( lc -> supported & ADVERT_MASK ) | fc ) ; lc -> fc = lc -> requested_fc & ( PAUSE_RX | PAUSE_TX ) ; } else if ( lc -> autoneg == AUTONEG_DISABLE ) { c . u . l1cfg . rcap = cpu_to_be32 ( lc -> requested_speed | fc | mdi ) ; lc -> fc = lc -> requested_fc & ( PAUSE_RX | PAUSE_TX ) ; } else c . u . l1cfg . rcap = cpu_to_be32 ( lc -> advertising | fc | mdi ) ; return t4_wr_mbox ( adap , mbox , & c , sizeof ( c ) , NULL ) ; }
t4_link_l1cfg - apply link configuration to MAC/PHY
      @phy: the PHY to setup
      @mac: the MAC to setup
      @lc: the requested link configuration
t4_link_l1cfg - apply link configuration to MAC / PHY @phy : the PHY to setup @mac : the MAC to setup @lc : the requested link configuration