/* This routine is invoked to remove all memory resources allocated to support rpis. This routine presumes the caller has released all rpis consumed by fabric or port logins and is prepared to have the header pages removed.  */
void lpfc_sli4_remove_rpi_hdrs(struct lpfc_hba *phba)
/* This routine is invoked to remove all memory resources allocated to support rpis. This routine presumes the caller has released all rpis consumed by fabric or port logins and is prepared to have the header pages removed.  */
void lpfc_sli4_remove_rpi_hdrs(struct lpfc_hba *phba)
{
	struct lpfc_rpi_hdr *rpi_hdr, *next_rpi_hdr;
	list_for_each_entry_safe(rpi_hdr, next_rpi_hdr,
				 &phba->sli4_hba.lpfc_rpi_hdr_list, list) {
		list_del(&rpi_hdr->list);
		dma_free_coherent(&phba->pcidev->dev, rpi_hdr->len,
				  rpi_hdr->dmabuf->virt, rpi_hdr->dmabuf->phys);
		kfree(rpi_hdr->dmabuf);
		kfree(rpi_hdr);
	}
	phba->sli4_hba.next_rpi = phba->sli4_hba.max_cfg_param.rpi_base;
	memset(phba->sli4_hba.rpi_bmask, 0, sizeof(*phba->sli4_hba.rpi_bmask));
}