/* This function reads the host status register and compares with the provided bit mask to check if HBA completed the restart. This function will wait in a loop for the HBA to complete restart. If the HBA does not restart within 15 iterations, the function will reset the HBA again. The function returns 1 when HBA fail to restart otherwise returns zero.  */
static int lpfc_sli_brdready_s3(struct lpfc_hba *phba, uint32_t mask)
/* This function reads the host status register and compares with the provided bit mask to check if HBA completed the restart. This function will wait in a loop for the HBA to complete restart. If the HBA does not restart within 15 iterations, the function will reset the HBA again. The function returns 1 when HBA fail to restart otherwise returns zero.  */
static int lpfc_sli_brdready_s3(struct lpfc_hba *phba, uint32_t mask)
{
	uint32_t status;
	int i = 0;
	int retval = 0;
	status = readl(phba->HSregaddr);
	while (((status & mask) != mask) &&
	       !(status & HS_FFERM) &&
	       i++ < 20) {
		if (i <= 5)
			msleep(10);
		else if (i <= 10)
			msleep(500);
		else
			msleep(2500);
		if (i == 15) {
			phba->pport->port_state = LPFC_VPORT_UNKNOWN;
			lpfc_sli_brdrestart(phba);
		}
		status = readl(phba->HSregaddr);
	}
	if ((status & HS_FFERM) || (i >= 20)) {
		phba->link_state = LPFC_HBA_ERROR;
		retval = 1;
	}
	return retval;
}