FreeBSD/sys/dev/cxgbe/common/t4_hw.c
/**
 *	t4_handle_fw_rpl - process a FW reply message
 *	@adap: the adapter
 *	@rpl: start of the FW message
 *
 *	Processes a FW message, such as link state change messages.
 */
process a FW reply message
@adap: the adapter
@rpl: start of the FW message

Processes a FW message, such as link state change messages.
process a FW reply message @adap : the adapter @rpl : start of the FW message Processes a FW message such as link state change messages .
int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl)
{
	u8 opcode = *(const u8 *)rpl;
	const struct fw_port_cmd *p = (const void *)rpl;
	unsigned int action =
			G_FW_PORT_CMD_ACTION(be32_to_cpu(p->action_to_len16));
	if (opcode == FW_PORT_CMD && action == FW_PORT_ACTION_GET_PORT_INFO) {
		int speed = 0, fc = 0, i;
		int chan = G_FW_PORT_CMD_PORTID(be32_to_cpu(p->op_to_portid));
		struct port_info *pi = NULL;
		struct link_config *lc;
		u32 stat = be32_to_cpu(p->u.info.lstatus_to_modtype);
		int link_ok = (stat & F_FW_PORT_CMD_LSTATUS) != 0;
		u32 mod = G_FW_PORT_CMD_MODTYPE(stat);
		if (stat & F_FW_PORT_CMD_RXPAUSE)
			fc |= PAUSE_RX;
		if (stat & F_FW_PORT_CMD_TXPAUSE)
			fc |= PAUSE_TX;
		if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_100M))
			speed = 100;
		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_1G))
			speed = 1000;
		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_10G))
			speed = 10000;
		else if (stat & V_FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_40G))
			speed = 40000;
		for_each_port(adap, i) {
			pi = adap2pinfo(adap, i);
			if (pi->tx_chan == chan)
				break;
		}
		lc = &pi->link_cfg;
		if (mod != pi->mod_type) {
			pi->mod_type = mod;
			t4_os_portmod_changed(adap, i);
		}
		if (link_ok != lc->link_ok || speed != lc->speed ||
		    fc != lc->fc) {                    
			int reason;
			if (!link_ok && lc->link_ok)
				reason = G_FW_PORT_CMD_LINKDNRC(stat);
			else
				reason = -1;
			lc->link_ok = link_ok;
			lc->speed = speed;
			lc->fc = fc;
			lc->supported = be16_to_cpu(p->u.info.pcap);
			t4_os_link_changed(adap, i, link_ok, reason);
		}
	} else {
		CH_WARN_RATELIMIT(adap, "Unknown firmware reply %d\n", opcode);
		return -EINVAL;
	}
	return 0;
}
int t4_handle_fw_rpl ( struct adapter * adap , const __be64 * rpl ) { u8 opcode = * ( const u8 * ) rpl ; const struct fw_port_cmd * p = ( const void * ) rpl ; unsigned int action = G_FW_PORT_CMD_ACTION ( be32_to_cpu ( p -> action_to_len16 ) ) ; if ( opcode == FW_PORT_CMD && action == FW_PORT_ACTION_GET_PORT_INFO ) { int speed = 0 , fc = 0 , i ; int chan = G_FW_PORT_CMD_PORTID ( be32_to_cpu ( p -> op_to_portid ) ) ; struct port_info * pi = NULL ; struct link_config * lc ; u32 stat = be32_to_cpu ( p -> u . info . lstatus_to_modtype ) ; int link_ok = ( stat & F_FW_PORT_CMD_LSTATUS ) != 0 ; u32 mod = G_FW_PORT_CMD_MODTYPE ( stat ) ; if ( stat & F_FW_PORT_CMD_RXPAUSE ) fc |= PAUSE_RX ; if ( stat & F_FW_PORT_CMD_TXPAUSE ) fc |= PAUSE_TX ; if ( stat & V_FW_PORT_CMD_LSPEED ( FW_PORT_CAP_SPEED_100M ) ) speed = 100 ; else if ( stat & V_FW_PORT_CMD_LSPEED ( FW_PORT_CAP_SPEED_1G ) ) speed = 1000 ; else if ( stat & V_FW_PORT_CMD_LSPEED ( FW_PORT_CAP_SPEED_10G ) ) speed = 10000 ; else if ( stat & V_FW_PORT_CMD_LSPEED ( FW_PORT_CAP_SPEED_40G ) ) speed = 40000 ; for_each_port ( adap , i ) { pi = adap2pinfo ( adap , i ) ; if ( pi -> tx_chan == chan ) break ; } lc = & pi -> link_cfg ; if ( mod != pi -> mod_type ) { pi -> mod_type = mod ; t4_os_portmod_changed ( adap , i ) ; } if ( link_ok != lc -> link_ok || speed != lc -> speed || fc != lc -> fc ) { int reason ; if ( ! link_ok && lc -> link_ok ) reason = G_FW_PORT_CMD_LINKDNRC ( stat ) ; else reason = -1 ; lc -> link_ok = link_ok ; lc -> speed = speed ; lc -> fc = fc ; lc -> supported = be16_to_cpu ( p -> u . info . pcap ) ; t4_os_link_changed ( adap , i , link_ok , reason ) ; } } else { CH_WARN_RATELIMIT ( adap , " \n " , opcode ) ; return - EINVAL ; } return 0 ; }
t4_handle_fw_rpl - process a FW reply message
      @adap: the adapter
      @rpl: start of the FW message
t4_handle_fw_rpl - process a FW reply message @adap : the adapter @rpl : start of the FW message
/* link/module state change message */ /* something changed */