FreeBSD/sys/dev/cxgbe/common/t4_hw.c
/*
 * Return the specified PCI-E Configuration Space register from our Physical
 * Function.  We try first via a Firmware LDST Command (if fw_attach != 0)
 * since we prefer to let the firmware own all of these registers, but if that
 * fails we go for it directly ourselves.
 */
Return the specified PCI-E Configuration Space register from our Physical
Function.  We try first via a Firmware LDST Command (if fw_attach != 0)
since we prefer to let the firmware own all of these registers, but if that
fails we go for it directly ourselves.
Return the specified PCI - E Configuration Space register from our Physical Function . We try first via a Firmware LDST Command ( if fw_attach ! = 0 ) since we prefer to let the firmware own all of these registers but if that fails we go for it directly ourselves .
u32 t4_read_pcie_cfg4(struct adapter *adap, int reg, int drv_fw_attach)
{
	if (drv_fw_attach != 0) {
		struct fw_ldst_cmd ldst_cmd;
		int ret;
		memset(&ldst_cmd, 0, sizeof(ldst_cmd));
		ldst_cmd.op_to_addrspace =
			cpu_to_be32(V_FW_CMD_OP(FW_LDST_CMD) |
				    F_FW_CMD_REQUEST |
				    F_FW_CMD_READ |
				    V_FW_LDST_CMD_ADDRSPACE(FW_LDST_ADDRSPC_FUNC_PCIE));
		ldst_cmd.cycles_to_len16 = cpu_to_be32(FW_LEN16(ldst_cmd));
		ldst_cmd.u.pcie.select_naccess = V_FW_LDST_CMD_NACCESS(1);
		ldst_cmd.u.pcie.ctrl_to_fn =
			(F_FW_LDST_CMD_LC | V_FW_LDST_CMD_FN(adap->pf));
		ldst_cmd.u.pcie.r = reg;
		ret = t4_wr_mbox(adap, adap->mbox, &ldst_cmd, sizeof(ldst_cmd),
				 &ldst_cmd);
		if (ret == 0)
			return be32_to_cpu(ldst_cmd.u.pcie.data[0]);
		CH_WARN(adap, "Firmware failed to return "
			"Configuration Space register %d, err = %d\n",
			reg, -ret);
	}
	return t4_hw_pci_read_cfg4(adap, reg);
}
u32 t4_read_pcie_cfg4 ( struct adapter * adap , int reg , int drv_fw_attach ) { if ( drv_fw_attach != 0 ) { struct fw_ldst_cmd ldst_cmd ; int ret ; memset ( & ldst_cmd , 0 , sizeof ( ldst_cmd ) ) ; ldst_cmd . op_to_addrspace = cpu_to_be32 ( V_FW_CMD_OP ( FW_LDST_CMD ) | F_FW_CMD_REQUEST | F_FW_CMD_READ | V_FW_LDST_CMD_ADDRSPACE ( FW_LDST_ADDRSPC_FUNC_PCIE ) ) ; ldst_cmd . cycles_to_len16 = cpu_to_be32 ( FW_LEN16 ( ldst_cmd ) ) ; ldst_cmd . u . pcie . select_naccess = V_FW_LDST_CMD_NACCESS ( 1 ) ; ldst_cmd . u . pcie . ctrl_to_fn = ( F_FW_LDST_CMD_LC | V_FW_LDST_CMD_FN ( adap -> pf ) ) ; ldst_cmd . u . pcie . r = reg ; ret = t4_wr_mbox ( adap , adap -> mbox , & ldst_cmd , sizeof ( ldst_cmd ) , & ldst_cmd ) ; if ( ret == 0 ) return be32_to_cpu ( ldst_cmd . u . pcie . data [ 0 ] ) ; CH_WARN ( adap , " " " \n " , reg , - ret ) ; } return t4_hw_pci_read_cfg4 ( adap , reg ) ; }
Return the specified PCI-E Configuration Space register from our Physical
 Function.
Return the specified PCI - E Configuration Space register from our Physical Function .
/*
	 * If fw_attach != 0, construct and send the Firmware LDST Command to
	 * retrieve the specified PCI-E Configuration Space register.
	 */ /*
		 * If the LDST Command succeeds, return the result, otherwise
		 * fall through to reading it directly ourselves ...
		 */ /*
	 * Read the desired Configuration Space register via the PCI-E
	 * Backdoor mechanism.
	 */