FreeBSD/sys/dev/qlxgbe/ql_misc.c
/*
 * Name: ql_rdwr_indreg32
 * Function: Read/Write an Indirect Register
 */
ql_rdwr_indreg32
Function: Read/Write an Indirect Register
ql_rdwr_indreg32 Function : Read / Write an Indirect Register
int
ql_rdwr_indreg32(qla_host_t *ha, uint32_t addr, uint32_t *val, uint32_t rd)
{
	uint32_t wnd_reg;
	uint32_t count = 100;
	wnd_reg = (Q8_CRB_WINDOW_PF0 | (ha->pci_func << 2));
	WRITE_REG32(ha, wnd_reg, addr);
	while (count--) {
		if (READ_REG32(ha, wnd_reg) == addr)
			break;
		qla_mdelay(__func__, 1);
	}
	if (!count || QL_ERR_INJECT(ha, INJCT_RDWR_INDREG_FAILURE)) {
		device_printf(ha->pci_dev, "%s: [0x%08x, 0x%08x, %d] failed\n",
			__func__, addr, *val, rd);
		ha->qla_initiate_recovery = 1;
		return -1;
	}
	if (rd) {
		*val = READ_REG32(ha, Q8_WILD_CARD);
	} else {
		WRITE_REG32(ha, Q8_WILD_CARD, *val);
	}
	return 0;
}
int ql_rdwr_indreg32 ( qla_host_t * ha , uint32_t addr , uint32_t * val , uint32_t rd ) { uint32_t wnd_reg ; uint32_t count = 100 ; wnd_reg = ( Q8_CRB_WINDOW_PF0 | ( ha -> pci_func << 2 ) ) ; WRITE_REG32 ( ha , wnd_reg , addr ) ; while ( count -- ) { if ( READ_REG32 ( ha , wnd_reg ) == addr ) break ; qla_mdelay ( __func__ , 1 ) ; } if ( ! count || QL_ERR_INJECT ( ha , INJCT_RDWR_INDREG_FAILURE ) ) { device_printf ( ha -> pci_dev , " \n " , __func__ , addr , * val , rd ) ; ha -> qla_initiate_recovery = 1 ; return -1 ; } if ( rd ) { * val = READ_REG32 ( ha , Q8_WILD_CARD ) ; } else { WRITE_REG32 ( ha , Q8_WILD_CARD , * val ) ; } return 0 ; }
Name: ql_rdwr_indreg32
 Function: Read/Write an Indirect Register
Name : ql_rdwr_indreg32 Function : Read / Write an Indirect Register