Lines Matching refs:phba

75 	struct beiscsi_hba *phba = iscsi_host_priv(shost); \
77 phba->attr_##_name);\
82 beiscsi_##_name##_change(struct beiscsi_hba *phba, uint32_t val)\
85 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
88 phba->attr_##_name, val); \
89 phba->attr_##_name = val;\
92 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, \
106 struct beiscsi_hba *phba = iscsi_host_priv(shost);\
112 if (beiscsi_##_name##_change(phba, param_val) == 0) \
120 beiscsi_##_name##_init(struct beiscsi_hba *phba, uint32_t val) \
123 phba->attr_##_name = val;\
126 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\
130 phba->attr_##_name = _defval;\
227 struct beiscsi_hba *phba; in beiscsi_eh_abort() local
252 phba = beiscsi_conn->phba; in beiscsi_eh_abort()
254 if (is_chip_be2_be3r(phba)) { in beiscsi_eh_abort()
265 rc = beiscsi_mgmt_invalidate_icds(phba, &inv_tbl, 1); in beiscsi_eh_abort()
268 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH, in beiscsi_eh_abort()
287 struct beiscsi_hba *phba; in beiscsi_eh_device_reset() local
304 phba = beiscsi_conn->phba; in beiscsi_eh_device_reset()
309 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH, in beiscsi_eh_device_reset()
344 if (is_chip_be2_be3r(phba)) { in beiscsi_eh_device_reset()
365 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH, in beiscsi_eh_device_reset()
371 if (beiscsi_mgmt_invalidate_icds(phba, &inv_tbl->tbl[0], nents)) { in beiscsi_eh_device_reset()
372 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH, in beiscsi_eh_device_reset()
428 struct beiscsi_hba *phba; in beiscsi_hba_alloc() local
431 shost = iscsi_host_alloc(&beiscsi_sht, sizeof(*phba), 0); in beiscsi_hba_alloc()
442 phba = iscsi_host_priv(shost); in beiscsi_hba_alloc()
443 memset(phba, 0, sizeof(*phba)); in beiscsi_hba_alloc()
444 phba->shost = shost; in beiscsi_hba_alloc()
445 phba->pcidev = pci_dev_get(pcidev); in beiscsi_hba_alloc()
446 pci_set_drvdata(pcidev, phba); in beiscsi_hba_alloc()
447 phba->interface_handle = 0xFFFFFFFF; in beiscsi_hba_alloc()
449 return phba; in beiscsi_hba_alloc()
452 static void beiscsi_unmap_pci_function(struct beiscsi_hba *phba) in beiscsi_unmap_pci_function() argument
454 if (phba->csr_va) { in beiscsi_unmap_pci_function()
455 iounmap(phba->csr_va); in beiscsi_unmap_pci_function()
456 phba->csr_va = NULL; in beiscsi_unmap_pci_function()
458 if (phba->db_va) { in beiscsi_unmap_pci_function()
459 iounmap(phba->db_va); in beiscsi_unmap_pci_function()
460 phba->db_va = NULL; in beiscsi_unmap_pci_function()
462 if (phba->pci_va) { in beiscsi_unmap_pci_function()
463 iounmap(phba->pci_va); in beiscsi_unmap_pci_function()
464 phba->pci_va = NULL; in beiscsi_unmap_pci_function()
468 static int beiscsi_map_pci_bars(struct beiscsi_hba *phba, in beiscsi_map_pci_bars() argument
478 phba->ctrl.csr = addr; in beiscsi_map_pci_bars()
479 phba->csr_va = addr; in beiscsi_map_pci_bars()
484 phba->ctrl.db = addr; in beiscsi_map_pci_bars()
485 phba->db_va = addr; in beiscsi_map_pci_bars()
487 if (phba->generation == BE_GEN2) in beiscsi_map_pci_bars()
497 phba->ctrl.pcicfg = addr; in beiscsi_map_pci_bars()
498 phba->pci_va = addr; in beiscsi_map_pci_bars()
502 beiscsi_unmap_pci_function(phba); in beiscsi_map_pci_bars()
543 static int be_ctrl_init(struct beiscsi_hba *phba, struct pci_dev *pdev) in be_ctrl_init() argument
545 struct be_ctrl_info *ctrl = &phba->ctrl; in be_ctrl_init()
551 status = beiscsi_map_pci_bars(phba, pdev); in be_ctrl_init()
558 beiscsi_unmap_pci_function(phba); in be_ctrl_init()
567 spin_lock_init(&phba->ctrl.mcc_lock); in be_ctrl_init()
576 static void beiscsi_get_params(struct beiscsi_hba *phba) in beiscsi_get_params() argument
582 total_cid_count = BEISCSI_GET_CID_COUNT(phba, BEISCSI_ULP0) + in beiscsi_get_params()
583 BEISCSI_GET_CID_COUNT(phba, BEISCSI_ULP1); in beiscsi_get_params()
592 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in beiscsi_get_params()
593 icd_start = phba->fw_config.iscsi_icd_start[ulp_num]; in beiscsi_get_params()
594 icd_count = phba->fw_config.iscsi_icd_count[ulp_num]; in beiscsi_get_params()
606 phba->fw_config. in beiscsi_get_params()
621 phba->fw_config.iscsi_icd_count[ulp_num] = (icd_count - in beiscsi_get_params()
624 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_get_params()
629 phba->fw_config. in beiscsi_get_params()
631 phba->fw_config. in beiscsi_get_params()
638 total_icd_count = phba->fw_config.iscsi_icd_count[ulp_num]; in beiscsi_get_params()
639 phba->params.ios_per_ctrl = (total_icd_count - in beiscsi_get_params()
642 phba->params.cxns_per_ctrl = total_cid_count; in beiscsi_get_params()
643 phba->params.icds_per_ctrl = total_icd_count; in beiscsi_get_params()
644 phba->params.num_sge_per_io = BE2_SGE; in beiscsi_get_params()
645 phba->params.defpdu_hdr_sz = BE2_DEFPDU_HDR_SZ; in beiscsi_get_params()
646 phba->params.defpdu_data_sz = BE2_DEFPDU_DATA_SZ; in beiscsi_get_params()
647 phba->params.num_eq_entries = 1024; in beiscsi_get_params()
648 phba->params.num_cq_entries = 1024; in beiscsi_get_params()
649 phba->params.wrbs_per_cxn = 256; in beiscsi_get_params()
652 static void hwi_ring_eq_db(struct beiscsi_hba *phba, in hwi_ring_eq_db() argument
675 iowrite32(val, phba->db_va + DB_EQ_OFFSET); in hwi_ring_eq_db()
685 struct beiscsi_hba *phba; in be_isr_mcc() local
694 phba = pbe_eq->phba; in be_isr_mcc()
695 mcc = &phba->ctrl.mcc_obj.cq; in be_isr_mcc()
712 queue_work(phba->wq, &pbe_eq->mcc_work); in be_isr_mcc()
713 hwi_ring_eq_db(phba, eq->id, 1, mcc_events, 1, 1); in be_isr_mcc()
725 struct beiscsi_hba *phba; in be_isr_msix() local
732 phba = pbe_eq->phba; in be_isr_msix()
734 hwi_ring_eq_db(phba, eq->id, 1, 0, 0, 1); in be_isr_msix()
747 struct beiscsi_hba *phba; in be_isr() local
758 phba = dev_id; in be_isr()
759 ctrl = &phba->ctrl; in be_isr()
765 phwi_ctrlr = phba->phwi_ctrlr; in be_isr()
770 mcc = &phba->ctrl.mcc_obj.cq; in be_isr()
792 queue_work(phba->wq, &pbe_eq->mcc_work); in be_isr()
798 hwi_ring_eq_db(phba, eq->id, 0, (io_events + mcc_events), rearm, 1); in be_isr()
802 static void beiscsi_free_irqs(struct beiscsi_hba *phba) in beiscsi_free_irqs() argument
807 if (!phba->pcidev->msix_enabled) { in beiscsi_free_irqs()
808 if (phba->pcidev->irq) in beiscsi_free_irqs()
809 free_irq(phba->pcidev->irq, phba); in beiscsi_free_irqs()
813 phwi_context = phba->phwi_ctrlr->phwi_ctxt; in beiscsi_free_irqs()
814 for (i = 0; i <= phba->num_cpus; i++) { in beiscsi_free_irqs()
815 free_irq(pci_irq_vector(phba->pcidev, i), in beiscsi_free_irqs()
817 kfree(phba->msi_name[i]); in beiscsi_free_irqs()
821 static int beiscsi_init_irqs(struct beiscsi_hba *phba) in beiscsi_init_irqs() argument
823 struct pci_dev *pcidev = phba->pcidev; in beiscsi_init_irqs()
828 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_init_irqs()
832 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_init_irqs()
833 phba->msi_name[i] = kasprintf(GFP_KERNEL, in beiscsi_init_irqs()
835 phba->shost->host_no, i); in beiscsi_init_irqs()
836 if (!phba->msi_name[i]) { in beiscsi_init_irqs()
842 be_isr_msix, 0, phba->msi_name[i], in beiscsi_init_irqs()
845 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_irqs()
848 kfree(phba->msi_name[i]); in beiscsi_init_irqs()
852 phba->msi_name[i] = kasprintf(GFP_KERNEL, "beiscsi_mcc_%02x", in beiscsi_init_irqs()
853 phba->shost->host_no); in beiscsi_init_irqs()
854 if (!phba->msi_name[i]) { in beiscsi_init_irqs()
859 phba->msi_name[i], &phwi_context->be_eq[i]); in beiscsi_init_irqs()
861 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_irqs()
864 kfree(phba->msi_name[i]); in beiscsi_init_irqs()
870 "beiscsi", phba); in beiscsi_init_irqs()
872 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_irqs()
882 kfree(phba->msi_name[j]); in beiscsi_init_irqs()
887 void hwi_ring_cq_db(struct beiscsi_hba *phba, in hwi_ring_cq_db() argument
906 iowrite32(val, phba->db_va + DB_CQ_OFFSET); in hwi_ring_cq_db()
909 static struct sgl_handle *alloc_io_sgl_handle(struct beiscsi_hba *phba) in alloc_io_sgl_handle() argument
914 spin_lock_irqsave(&phba->io_sgl_lock, flags); in alloc_io_sgl_handle()
915 if (phba->io_sgl_hndl_avbl) { in alloc_io_sgl_handle()
916 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, in alloc_io_sgl_handle()
919 phba->io_sgl_alloc_index); in alloc_io_sgl_handle()
921 psgl_handle = phba->io_sgl_hndl_base[phba-> in alloc_io_sgl_handle()
923 phba->io_sgl_hndl_base[phba->io_sgl_alloc_index] = NULL; in alloc_io_sgl_handle()
924 phba->io_sgl_hndl_avbl--; in alloc_io_sgl_handle()
925 if (phba->io_sgl_alloc_index == (phba->params. in alloc_io_sgl_handle()
927 phba->io_sgl_alloc_index = 0; in alloc_io_sgl_handle()
929 phba->io_sgl_alloc_index++; in alloc_io_sgl_handle()
932 spin_unlock_irqrestore(&phba->io_sgl_lock, flags); in alloc_io_sgl_handle()
937 free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) in free_io_sgl_handle() argument
941 spin_lock_irqsave(&phba->io_sgl_lock, flags); in free_io_sgl_handle()
942 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, in free_io_sgl_handle()
944 phba->io_sgl_free_index); in free_io_sgl_handle()
946 if (phba->io_sgl_hndl_base[phba->io_sgl_free_index]) { in free_io_sgl_handle()
951 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, in free_io_sgl_handle()
953 phba->io_sgl_free_index, in free_io_sgl_handle()
954 phba->io_sgl_hndl_base[phba->io_sgl_free_index]); in free_io_sgl_handle()
955 spin_unlock_irqrestore(&phba->io_sgl_lock, flags); in free_io_sgl_handle()
958 phba->io_sgl_hndl_base[phba->io_sgl_free_index] = psgl_handle; in free_io_sgl_handle()
959 phba->io_sgl_hndl_avbl++; in free_io_sgl_handle()
960 if (phba->io_sgl_free_index == (phba->params.ios_per_ctrl - 1)) in free_io_sgl_handle()
961 phba->io_sgl_free_index = 0; in free_io_sgl_handle()
963 phba->io_sgl_free_index++; in free_io_sgl_handle()
964 spin_unlock_irqrestore(&phba->io_sgl_lock, flags); in free_io_sgl_handle()
1001 struct wrb_handle *alloc_wrb_handle(struct beiscsi_hba *phba, unsigned int cid, in alloc_wrb_handle() argument
1008 phwi_ctrlr = phba->phwi_ctrlr; in alloc_wrb_handle()
1012 return beiscsi_get_wrb_handle(pwrb_context, phba->params.wrbs_per_cxn); in alloc_wrb_handle()
1042 free_wrb_handle(struct beiscsi_hba *phba, struct hwi_wrb_context *pwrb_context, in free_wrb_handle() argument
1047 phba->params.wrbs_per_cxn); in free_wrb_handle()
1048 beiscsi_log(phba, KERN_INFO, in free_wrb_handle()
1056 static struct sgl_handle *alloc_mgmt_sgl_handle(struct beiscsi_hba *phba) in alloc_mgmt_sgl_handle() argument
1061 spin_lock_irqsave(&phba->mgmt_sgl_lock, flags); in alloc_mgmt_sgl_handle()
1062 if (phba->eh_sgl_hndl_avbl) { in alloc_mgmt_sgl_handle()
1063 psgl_handle = phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index]; in alloc_mgmt_sgl_handle()
1064 phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index] = NULL; in alloc_mgmt_sgl_handle()
1065 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, in alloc_mgmt_sgl_handle()
1067 phba->eh_sgl_alloc_index, in alloc_mgmt_sgl_handle()
1068 phba->eh_sgl_alloc_index); in alloc_mgmt_sgl_handle()
1070 phba->eh_sgl_hndl_avbl--; in alloc_mgmt_sgl_handle()
1071 if (phba->eh_sgl_alloc_index == in alloc_mgmt_sgl_handle()
1072 (phba->params.icds_per_ctrl - phba->params.ios_per_ctrl - in alloc_mgmt_sgl_handle()
1074 phba->eh_sgl_alloc_index = 0; in alloc_mgmt_sgl_handle()
1076 phba->eh_sgl_alloc_index++; in alloc_mgmt_sgl_handle()
1079 spin_unlock_irqrestore(&phba->mgmt_sgl_lock, flags); in alloc_mgmt_sgl_handle()
1084 free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) in free_mgmt_sgl_handle() argument
1088 spin_lock_irqsave(&phba->mgmt_sgl_lock, flags); in free_mgmt_sgl_handle()
1089 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, in free_mgmt_sgl_handle()
1092 phba->eh_sgl_free_index); in free_mgmt_sgl_handle()
1094 if (phba->eh_sgl_hndl_base[phba->eh_sgl_free_index]) { in free_mgmt_sgl_handle()
1099 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, in free_mgmt_sgl_handle()
1102 phba->eh_sgl_free_index); in free_mgmt_sgl_handle()
1103 spin_unlock_irqrestore(&phba->mgmt_sgl_lock, flags); in free_mgmt_sgl_handle()
1106 phba->eh_sgl_hndl_base[phba->eh_sgl_free_index] = psgl_handle; in free_mgmt_sgl_handle()
1107 phba->eh_sgl_hndl_avbl++; in free_mgmt_sgl_handle()
1108 if (phba->eh_sgl_free_index == in free_mgmt_sgl_handle()
1109 (phba->params.icds_per_ctrl - phba->params.ios_per_ctrl - 1)) in free_mgmt_sgl_handle()
1110 phba->eh_sgl_free_index = 0; in free_mgmt_sgl_handle()
1112 phba->eh_sgl_free_index++; in free_mgmt_sgl_handle()
1113 spin_unlock_irqrestore(&phba->mgmt_sgl_lock, flags); in free_mgmt_sgl_handle()
1234 struct beiscsi_hba *phba, struct sol_cqe *psol) in hwi_complete_drvr_msgs() argument
1243 phwi_ctrlr = phba->phwi_ctrlr; in hwi_complete_drvr_msgs()
1244 if (is_chip_be2_be3r(phba)) { in hwi_complete_drvr_msgs()
1287 static void adapter_get_sol_cqe(struct beiscsi_hba *phba, in adapter_get_sol_cqe() argument
1291 if (is_chip_be2_be3r(phba)) { in adapter_get_sol_cqe()
1342 struct beiscsi_hba *phba, struct sol_cqe *psol) in hwi_complete_cmd() argument
1354 phwi_ctrlr = phba->phwi_ctrlr; in hwi_complete_cmd()
1357 adapter_get_sol_cqe(phba, psol, &csol_cqe); in hwi_complete_cmd()
1391 beiscsi_log(phba, KERN_ERR, in hwi_complete_cmd()
1402 beiscsi_log(phba, KERN_WARNING, in hwi_complete_cmd()
1427 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_complete_pdu() local
1445 beiscsi_log(phba, KERN_ERR, in beiscsi_complete_pdu()
1457 beiscsi_log(phba, KERN_WARNING, in beiscsi_complete_pdu()
1478 beiscsi_hdl_purge_handles(struct beiscsi_hba *phba, in beiscsi_hdl_purge_handles() argument
1501 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_hdl_get_handle() local
1518 if (is_chip_be2_be3r(phba)) { in beiscsi_hdl_get_handle()
1565 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI, in beiscsi_hdl_get_handle()
1584 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI, in beiscsi_hdl_get_handle()
1587 beiscsi_hdl_purge_handles(phba, pasync_ctx, cri); in beiscsi_hdl_get_handle()
1610 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_hdl_fwd_pdu() local
1641 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI, in beiscsi_hdl_fwd_pdu()
1652 beiscsi_hdl_purge_handles(phba, pasync_ctx, cri); in beiscsi_hdl_fwd_pdu()
1664 struct beiscsi_hba *phba; in beiscsi_hdl_gather_pdu() local
1668 phba = beiscsi_conn->phba; in beiscsi_hdl_gather_pdu()
1709 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI, in beiscsi_hdl_gather_pdu()
1718 beiscsi_hdl_purge_handles(phba, pasync_ctx, cri); in beiscsi_hdl_gather_pdu()
1724 beiscsi_hdq_post_handles(struct beiscsi_hba *phba, in beiscsi_hdq_post_handles() argument
1735 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_hdq_post_handles()
1777 iowrite32(doorbell, phba->db_va + doorbell_offset); in beiscsi_hdq_post_handles()
1784 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_hdq_process_compl() local
1791 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_hdq_process_compl()
1797 if (is_chip_be2_be3r(phba)) in beiscsi_hdq_process_compl()
1807 beiscsi_hdq_post_handles(phba, header, ulp_num, 8 * consumed); in beiscsi_hdq_process_compl()
1810 void beiscsi_process_mcc_cq(struct beiscsi_hba *phba) in beiscsi_process_mcc_cq() argument
1816 mcc_cq = &phba->ctrl.mcc_obj.cq; in beiscsi_process_mcc_cq()
1820 if (beiscsi_hba_in_error(phba)) in beiscsi_process_mcc_cq()
1824 hwi_ring_cq_db(phba, mcc_cq->id, in beiscsi_process_mcc_cq()
1829 beiscsi_process_async_event(phba, mcc_compl); in beiscsi_process_mcc_cq()
1831 beiscsi_process_mcc_compl(&phba->ctrl, mcc_compl); in beiscsi_process_mcc_cq()
1842 hwi_ring_cq_db(phba, mcc_cq->id, num_processed, 1); in beiscsi_process_mcc_cq()
1848 struct beiscsi_hba *phba; in beiscsi_mcc_work() local
1851 phba = pbe_eq->phba; in beiscsi_mcc_work()
1852 beiscsi_process_mcc_cq(phba); in beiscsi_mcc_work()
1854 if (!beiscsi_hba_in_error(phba)) in beiscsi_mcc_work()
1855 hwi_ring_eq_db(phba, pbe_eq->q.id, 0, 0, 1, 1); in beiscsi_mcc_work()
1877 struct beiscsi_hba *phba; in beiscsi_process_cq() local
1881 phba = pbe_eq->phba; in beiscsi_process_cq()
1885 if (beiscsi_hba_in_error(phba)) in beiscsi_process_cq()
1894 if (is_chip_be2_be3r(phba)) { in beiscsi_process_cq()
1909 ep = phba->ep_array[cri_index]; in beiscsi_process_cq()
1915 beiscsi_log(phba, KERN_WARNING, in beiscsi_process_cq()
1927 hwi_ring_cq_db(phba, cq->id, 32, 0); in beiscsi_process_cq()
1934 hwi_complete_cmd(beiscsi_conn, phba, sol); in beiscsi_process_cq()
1937 beiscsi_log(phba, KERN_INFO, in beiscsi_process_cq()
1942 hwi_complete_drvr_msgs(beiscsi_conn, phba, sol); in beiscsi_process_cq()
1945 beiscsi_log(phba, KERN_INFO, in beiscsi_process_cq()
1950 spin_lock_bh(&phba->async_pdu_lock); in beiscsi_process_cq()
1953 spin_unlock_bh(&phba->async_pdu_lock); in beiscsi_process_cq()
1956 beiscsi_log(phba, KERN_INFO, in beiscsi_process_cq()
1961 spin_lock_bh(&phba->async_pdu_lock); in beiscsi_process_cq()
1964 spin_unlock_bh(&phba->async_pdu_lock); in beiscsi_process_cq()
1969 beiscsi_log(phba, KERN_ERR, in beiscsi_process_cq()
1976 beiscsi_log(phba, KERN_ERR, in beiscsi_process_cq()
1988 beiscsi_log(phba, KERN_ERR, in beiscsi_process_cq()
1994 beiscsi_log(phba, KERN_ERR, in beiscsi_process_cq()
1998 spin_lock_bh(&phba->async_pdu_lock); in beiscsi_process_cq()
2002 spin_unlock_bh(&phba->async_pdu_lock); in beiscsi_process_cq()
2019 beiscsi_log(phba, KERN_ERR, in beiscsi_process_cq()
2028 beiscsi_log(phba, KERN_ERR, in beiscsi_process_cq()
2044 hwi_ring_cq_db(phba, cq->id, num_processed, 1); in beiscsi_process_cq()
2051 struct beiscsi_hba *phba; in be_iopoll() local
2057 phba = pbe_eq->phba; in be_iopoll()
2058 if (beiscsi_hba_in_error(phba)) { in be_iopoll()
2073 hwi_ring_eq_db(phba, eq->id, 1, io_events, 0, 1); in be_iopoll()
2079 beiscsi_log(phba, KERN_INFO, in be_iopoll()
2083 if (!beiscsi_hba_in_error(phba)) in be_iopoll()
2084 hwi_ring_eq_db(phba, pbe_eq->q.id, 0, 0, 1, 1); in be_iopoll()
2282 struct beiscsi_hba *phba = beiscsi_conn->phba; in hwi_write_buffer() local
2296 if (is_chip_be2_be3r(phba)) in hwi_write_buffer()
2305 io_task->mtask_addr = dma_map_single(&phba->pcidev->dev, in hwi_write_buffer()
2309 if (dma_mapping_error(&phba->pcidev->dev, in hwi_write_buffer()
2363 static void beiscsi_find_mem_req(struct beiscsi_hba *phba) in beiscsi_find_mem_req() argument
2370 phba->params.hwi_ws_sz = sizeof(struct hwi_controller); in beiscsi_find_mem_req()
2372 phba->mem_req[ISCSI_MEM_GLOBAL_HEADER] = 2 * in beiscsi_find_mem_req()
2374 phba->mem_req[HWI_MEM_ADDN_CONTEXT] = in beiscsi_find_mem_req()
2378 phba->mem_req[HWI_MEM_WRB] = sizeof(struct iscsi_wrb) in beiscsi_find_mem_req()
2379 * (phba->params.wrbs_per_cxn) in beiscsi_find_mem_req()
2380 * phba->params.cxns_per_ctrl; in beiscsi_find_mem_req()
2382 (phba->params.wrbs_per_cxn); in beiscsi_find_mem_req()
2383 phba->mem_req[HWI_MEM_WRBH] = roundup_pow_of_two((wrb_sz_per_cxn) * in beiscsi_find_mem_req()
2384 phba->params.cxns_per_ctrl); in beiscsi_find_mem_req()
2386 phba->mem_req[HWI_MEM_SGLH] = sizeof(struct sgl_handle) * in beiscsi_find_mem_req()
2387 phba->params.icds_per_ctrl; in beiscsi_find_mem_req()
2388 phba->mem_req[HWI_MEM_SGE] = sizeof(struct iscsi_sge) * in beiscsi_find_mem_req()
2389 phba->params.num_sge_per_io * phba->params.icds_per_ctrl; in beiscsi_find_mem_req()
2391 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in beiscsi_find_mem_req()
2395 phba, ulp_num) * in beiscsi_find_mem_req()
2400 phba, ulp_num) * in beiscsi_find_mem_req()
2401 phba->params.defpdu_hdr_sz); in beiscsi_find_mem_req()
2405 phba, ulp_num) * in beiscsi_find_mem_req()
2406 phba->params.defpdu_data_sz); in beiscsi_find_mem_req()
2410 phba, ulp_num) * in beiscsi_find_mem_req()
2415 phba->mem_req[mem_descr_index] = in beiscsi_find_mem_req()
2416 BEISCSI_GET_CID_COUNT(phba, ulp_num) * in beiscsi_find_mem_req()
2421 phba->mem_req[mem_descr_index] = in beiscsi_find_mem_req()
2427 phba->mem_req[mem_descr_index] = in beiscsi_find_mem_req()
2433 phba->mem_req[mem_descr_index] = in beiscsi_find_mem_req()
2439 phba->mem_req[mem_descr_index] = in beiscsi_find_mem_req()
2445 phba->mem_req[mem_descr_index] = in beiscsi_find_mem_req()
2446 BEISCSI_ASYNC_HDQ_SIZE(phba, ulp_num) * in beiscsi_find_mem_req()
2451 phba->mem_req[mem_descr_index] = in beiscsi_find_mem_req()
2452 BEISCSI_ASYNC_HDQ_SIZE(phba, ulp_num) * in beiscsi_find_mem_req()
2457 phba->mem_req[mem_descr_index] = in beiscsi_find_mem_req()
2459 (BEISCSI_ASYNC_HDQ_SIZE(phba, ulp_num) * in beiscsi_find_mem_req()
2465 static int beiscsi_alloc_mem(struct beiscsi_hba *phba) in beiscsi_alloc_mem() argument
2473 phba->phwi_ctrlr = kzalloc(phba->params.hwi_ws_sz, GFP_KERNEL); in beiscsi_alloc_mem()
2474 if (!phba->phwi_ctrlr) in beiscsi_alloc_mem()
2478 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_alloc_mem()
2479 phwi_ctrlr->wrb_context = kcalloc(phba->params.cxns_per_ctrl, in beiscsi_alloc_mem()
2483 kfree(phba->phwi_ctrlr); in beiscsi_alloc_mem()
2487 phba->init_mem = kcalloc(SE_MEM_MAX, sizeof(*mem_descr), in beiscsi_alloc_mem()
2489 if (!phba->init_mem) { in beiscsi_alloc_mem()
2491 kfree(phba->phwi_ctrlr); in beiscsi_alloc_mem()
2499 kfree(phba->init_mem); in beiscsi_alloc_mem()
2501 kfree(phba->phwi_ctrlr); in beiscsi_alloc_mem()
2505 mem_descr = phba->init_mem; in beiscsi_alloc_mem()
2507 if (!phba->mem_req[i]) { in beiscsi_alloc_mem()
2515 alloc_size = phba->mem_req[i]; in beiscsi_alloc_mem()
2521 dma_alloc_coherent(&phba->pcidev->dev, in beiscsi_alloc_mem()
2544 mem_descr->size_in_bytes = phba->mem_req[i]; in beiscsi_alloc_mem()
2560 dma_free_coherent(&phba->pcidev->dev, in beiscsi_alloc_mem()
2575 kfree(phba->init_mem); in beiscsi_alloc_mem()
2576 kfree(phba->phwi_ctrlr->wrb_context); in beiscsi_alloc_mem()
2577 kfree(phba->phwi_ctrlr); in beiscsi_alloc_mem()
2581 static int beiscsi_get_memory(struct beiscsi_hba *phba) in beiscsi_get_memory() argument
2583 beiscsi_find_mem_req(phba); in beiscsi_get_memory()
2584 return beiscsi_alloc_mem(phba); in beiscsi_get_memory()
2587 static void iscsi_init_global_templates(struct beiscsi_hba *phba) in iscsi_init_global_templates() argument
2593 mem_descr = phba->init_mem; in iscsi_init_global_templates()
2612 static int beiscsi_init_wrb_handle(struct beiscsi_hba *phba) in beiscsi_init_wrb_handle() argument
2623 mem_descr_wrbh = phba->init_mem; in beiscsi_init_wrb_handle()
2626 mem_descr_wrb = phba->init_mem; in beiscsi_init_wrb_handle()
2628 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_init_wrb_handle()
2632 phwi_ctxt->be_wrbq = kcalloc(phba->params.cxns_per_ctrl, in beiscsi_init_wrb_handle()
2636 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_wrb_handle()
2641 for (index = 0; index < phba->params.cxns_per_ctrl; index++) { in beiscsi_init_wrb_handle()
2644 kcalloc(phba->params.wrbs_per_cxn, in beiscsi_init_wrb_handle()
2648 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_wrb_handle()
2653 kcalloc(phba->params.wrbs_per_cxn, in beiscsi_init_wrb_handle()
2657 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_wrb_handle()
2666 phba->params.wrbs_per_cxn)); in beiscsi_init_wrb_handle()
2674 for (j = 0; j < phba->params.wrbs_per_cxn; j++) { in beiscsi_init_wrb_handle()
2687 for (index = 0; index < phba->params.cxns_per_ctrl; index++) { in beiscsi_init_wrb_handle()
2693 phba->params.wrbs_per_cxn)); in beiscsi_init_wrb_handle()
2698 for (j = 0; j < phba->params.wrbs_per_cxn; j++) { in beiscsi_init_wrb_handle()
2717 static int hwi_init_async_pdu_ctx(struct beiscsi_hba *phba) in hwi_init_async_pdu_ctx() argument
2721 struct hba_parameters *p = &phba->params; in hwi_init_async_pdu_ctx()
2728 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in hwi_init_async_pdu_ctx()
2730 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2734 phwi_ctrlr = phba->phwi_ctrlr; in hwi_init_async_pdu_ctx()
2747 pasync_ctx->num_entries = BEISCSI_ASYNC_HDQ_SIZE(phba, in hwi_init_async_pdu_ctx()
2750 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2754 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_async_pdu_ctx()
2761 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2776 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2780 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_async_pdu_ctx()
2787 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2796 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2800 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_async_pdu_ctx()
2807 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2816 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2820 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_async_pdu_ctx()
2827 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2836 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2840 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2856 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2860 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_async_pdu_ctx()
2867 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2882 phba->params.defpdu_data_sz); in hwi_init_async_pdu_ctx()
2886 (phba, ulp_num); index++) { in hwi_init_async_pdu_ctx()
2925 phba->params.defpdu_data_sz); in hwi_init_async_pdu_ctx()
2972 hwi_build_be_sgl_arr(struct beiscsi_hba *phba, in hwi_build_be_sgl_arr() argument
2984 hwi_build_be_sgl_by_offset(struct beiscsi_hba *phba, in hwi_build_be_sgl_by_offset() argument
3011 static int beiscsi_create_eqs(struct beiscsi_hba *phba, in beiscsi_create_eqs() argument
3021 num_eq_pages = PAGES_REQUIRED(phba->params.num_eq_entries * in beiscsi_create_eqs()
3024 if (phba->pcidev->msix_enabled) in beiscsi_create_eqs()
3028 for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) { in beiscsi_create_eqs()
3031 phwi_context->be_eq[i].phba = phba; in beiscsi_create_eqs()
3032 eq_vaddress = dma_alloc_coherent(&phba->pcidev->dev, in beiscsi_create_eqs()
3041 ret = be_fill_queue(eq, phba->params.num_eq_entries, in beiscsi_create_eqs()
3044 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_eqs()
3050 ret = beiscsi_cmd_eq_create(&phba->ctrl, eq, in beiscsi_create_eqs()
3053 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_eqs()
3058 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_create_eqs()
3065 for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) { in beiscsi_create_eqs()
3069 dma_free_coherent(&phba->pcidev->dev, num_eq_pages in beiscsi_create_eqs()
3076 static int beiscsi_create_cqs(struct beiscsi_hba *phba, in beiscsi_create_cqs() argument
3087 num_cq_pages = PAGES_REQUIRED(phba->params.num_cq_entries * in beiscsi_create_cqs()
3090 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_create_cqs()
3095 pbe_eq->phba = phba; in beiscsi_create_cqs()
3097 cq_vaddress = dma_alloc_coherent(&phba->pcidev->dev, in beiscsi_create_cqs()
3105 ret = be_fill_queue(cq, phba->params.num_cq_entries, in beiscsi_create_cqs()
3108 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_cqs()
3114 ret = beiscsi_cmd_cq_create(&phba->ctrl, cq, eq, false, in beiscsi_create_cqs()
3117 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_cqs()
3121 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_create_cqs()
3128 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_create_cqs()
3132 dma_free_coherent(&phba->pcidev->dev, num_cq_pages in beiscsi_create_cqs()
3140 beiscsi_create_def_hdr(struct beiscsi_hba *phba, in beiscsi_create_def_hdr() argument
3156 mem_descr = phba->init_mem; in beiscsi_create_def_hdr()
3164 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_def_hdr()
3172 ret = be_cmd_create_default_pdu_queue(&phba->ctrl, cq, dq, in beiscsi_create_def_hdr()
3174 phba->params.defpdu_hdr_sz, in beiscsi_create_def_hdr()
3177 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_def_hdr()
3184 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_create_def_hdr()
3192 beiscsi_create_def_data(struct beiscsi_hba *phba, in beiscsi_create_def_data() argument
3208 mem_descr = phba->init_mem; in beiscsi_create_def_data()
3216 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_def_data()
3225 ret = be_cmd_create_default_pdu_queue(&phba->ctrl, cq, dataq, in beiscsi_create_def_data()
3227 phba->params.defpdu_data_sz, in beiscsi_create_def_data()
3230 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_def_data()
3237 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_create_def_data()
3242 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_create_def_data()
3250 beiscsi_post_template_hdr(struct beiscsi_hba *phba) in beiscsi_post_template_hdr() argument
3258 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in beiscsi_post_template_hdr()
3259 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in beiscsi_post_template_hdr()
3264 hwi_build_be_sgl_arr(phba, pm_arr, &sgl); in beiscsi_post_template_hdr()
3266 &phba->ctrl, &sgl); in beiscsi_post_template_hdr()
3269 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_post_template_hdr()
3275 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_post_template_hdr()
3284 beiscsi_post_pages(struct beiscsi_hba *phba) in beiscsi_post_pages() argument
3292 mem_descr = phba->init_mem; in beiscsi_post_pages()
3297 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) in beiscsi_post_pages()
3300 page_offset = (sizeof(struct iscsi_sge) * phba->params.num_sge_per_io * in beiscsi_post_pages()
3301 phba->fw_config.iscsi_icd_start[ulp_num]) / PAGE_SIZE; in beiscsi_post_pages()
3303 hwi_build_be_sgl_arr(phba, pm_arr, &sgl); in beiscsi_post_pages()
3304 status = be_cmd_iscsi_post_sgl_pages(&phba->ctrl, &sgl, in beiscsi_post_pages()
3309 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_post_pages()
3315 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_post_pages()
3320 static void be_queue_free(struct beiscsi_hba *phba, struct be_queue_info *q) in be_queue_free() argument
3324 dma_free_coherent(&phba->pcidev->dev, mem->size, in be_queue_free()
3330 static int be_queue_alloc(struct beiscsi_hba *phba, struct be_queue_info *q, in be_queue_alloc() argument
3339 mem->va = dma_alloc_coherent(&phba->pcidev->dev, mem->size, &mem->dma, in be_queue_alloc()
3347 beiscsi_create_wrb_rings(struct beiscsi_hba *phba, in beiscsi_create_wrb_rings() argument
3364 mem_descr = phba->init_mem; in beiscsi_create_wrb_rings()
3366 pwrb_arr = kmalloc_array(phba->params.cxns_per_ctrl, in beiscsi_create_wrb_rings()
3370 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_wrb_rings()
3377 (phba->params.wrbs_per_cxn * sizeof(struct iscsi_wrb)); in beiscsi_create_wrb_rings()
3379 for (num = 0; num < phba->params.cxns_per_ctrl; num++) { in beiscsi_create_wrb_rings()
3383 pwrb_arr[num].size = phba->params.wrbs_per_cxn * in beiscsi_create_wrb_rings()
3394 (phba->params.wrbs_per_cxn * in beiscsi_create_wrb_rings()
3398 pwrb_arr[num].size = phba->params.wrbs_per_cxn * in beiscsi_create_wrb_rings()
3408 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in beiscsi_create_wrb_rings()
3412 BEISCSI_GET_CID_COUNT(phba, ulp_num); in beiscsi_create_wrb_rings()
3415 for (i = 0; i < phba->params.cxns_per_ctrl; i++) { in beiscsi_create_wrb_rings()
3427 hwi_build_be_sgl_by_offset(phba, &pwrb_arr[i], &sgl); in beiscsi_create_wrb_rings()
3428 status = be_cmd_wrbq_create(&phba->ctrl, &sgl, in beiscsi_create_wrb_rings()
3433 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_wrb_rings()
3445 static void free_wrb_handles(struct beiscsi_hba *phba) in free_wrb_handles() argument
3451 phwi_ctrlr = phba->phwi_ctrlr; in free_wrb_handles()
3452 for (index = 0; index < phba->params.cxns_per_ctrl; index++) { in free_wrb_handles()
3459 static void be_mcc_queues_destroy(struct beiscsi_hba *phba) in be_mcc_queues_destroy() argument
3461 struct be_ctrl_info *ctrl = &phba->ctrl; in be_mcc_queues_destroy()
3466 q = &phba->ctrl.mcc_obj.q; in be_mcc_queues_destroy()
3510 be_queue_free(phba, q); in be_mcc_queues_destroy()
3513 q = &phba->ctrl.mcc_obj.cq; in be_mcc_queues_destroy()
3516 be_queue_free(phba, q); in be_mcc_queues_destroy()
3520 static int be_mcc_queues_create(struct beiscsi_hba *phba, in be_mcc_queues_create() argument
3524 struct be_ctrl_info *ctrl = &phba->ctrl; in be_mcc_queues_create()
3527 cq = &phba->ctrl.mcc_obj.cq; in be_mcc_queues_create()
3528 if (be_queue_alloc(phba, cq, MCC_CQ_LEN, in be_mcc_queues_create()
3532 if (phba->pcidev->msix_enabled) { in be_mcc_queues_create()
3534 &phwi_context->be_eq[phba->num_cpus].q, in be_mcc_queues_create()
3544 q = &phba->ctrl.mcc_obj.q; in be_mcc_queues_create()
3545 if (be_queue_alloc(phba, q, MCC_Q_LEN, sizeof(struct be_mcc_wrb))) in be_mcc_queues_create()
3549 if (beiscsi_cmd_mccq_create(phba, q, cq)) in be_mcc_queues_create()
3555 be_queue_free(phba, q); in be_mcc_queues_create()
3559 be_queue_free(phba, cq); in be_mcc_queues_create()
3564 static void be2iscsi_enable_msix(struct beiscsi_hba *phba) in be2iscsi_enable_msix() argument
3568 switch (phba->generation) { in be2iscsi_enable_msix()
3574 nvec = phba->fw_config.eqid_count; in be2iscsi_enable_msix()
3585 if (pci_alloc_irq_vectors_affinity(phba->pcidev, 2, nvec, in be2iscsi_enable_msix()
3587 phba->num_cpus = nvec - 1; in be2iscsi_enable_msix()
3592 phba->num_cpus = 1; in be2iscsi_enable_msix()
3595 static void hwi_purge_eq(struct beiscsi_hba *phba) in hwi_purge_eq() argument
3604 if (beiscsi_hba_in_error(phba)) in hwi_purge_eq()
3607 phwi_ctrlr = phba->phwi_ctrlr; in hwi_purge_eq()
3609 if (phba->pcidev->msix_enabled) in hwi_purge_eq()
3614 for (i = 0; i < (phba->num_cpus + eq_msix); i++) { in hwi_purge_eq()
3627 hwi_ring_eq_db(phba, eq->id, 1, num_processed, 1, 1); in hwi_purge_eq()
3631 static void hwi_cleanup_port(struct beiscsi_hba *phba) in hwi_cleanup_port() argument
3634 struct be_ctrl_info *ctrl = &phba->ctrl; in hwi_cleanup_port()
3640 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) in hwi_cleanup_port()
3641 beiscsi_cmd_iscsi_cleanup(phba, ulp_num); in hwi_cleanup_port()
3648 hwi_purge_eq(phba); in hwi_cleanup_port()
3650 phwi_ctrlr = phba->phwi_ctrlr; in hwi_cleanup_port()
3655 for (i = 0; i < phba->params.cxns_per_ctrl; i++) { in hwi_cleanup_port()
3661 free_wrb_handles(phba); in hwi_cleanup_port()
3664 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in hwi_cleanup_port()
3678 for (i = 0; i < (phba->num_cpus); i++) { in hwi_cleanup_port()
3681 be_queue_free(phba, q); in hwi_cleanup_port()
3686 be_mcc_queues_destroy(phba); in hwi_cleanup_port()
3687 if (phba->pcidev->msix_enabled) in hwi_cleanup_port()
3691 for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) { in hwi_cleanup_port()
3694 be_queue_free(phba, q); in hwi_cleanup_port()
3699 beiscsi_cmd_function_reset(phba); in hwi_cleanup_port()
3701 beiscsi_cmd_special_wrb(&phba->ctrl, 0); in hwi_cleanup_port()
3704 static int hwi_init_port(struct beiscsi_hba *phba) in hwi_init_port() argument
3709 struct be_ctrl_info *ctrl = &phba->ctrl; in hwi_init_port()
3713 phwi_ctrlr = phba->phwi_ctrlr; in hwi_init_port()
3716 phba->optic_state = 0xff; in hwi_init_port()
3718 status = beiscsi_create_eqs(phba, phwi_context); in hwi_init_port()
3720 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3725 status = be_mcc_queues_create(phba, phwi_context); in hwi_init_port()
3729 status = beiscsi_check_supported_fw(ctrl, phba); in hwi_init_port()
3731 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3736 status = beiscsi_create_cqs(phba, phwi_context); in hwi_init_port()
3738 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3744 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in hwi_init_port()
3748 status = beiscsi_create_def_hdr(phba, phwi_context, in hwi_init_port()
3753 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3759 status = beiscsi_create_def_data(phba, phwi_context, in hwi_init_port()
3764 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3773 beiscsi_hdq_post_handles(phba, BEISCSI_DEFQ_HDR, in hwi_init_port()
3775 beiscsi_hdq_post_handles(phba, BEISCSI_DEFQ_DATA, in hwi_init_port()
3780 status = beiscsi_post_pages(phba); in hwi_init_port()
3782 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3787 status = beiscsi_post_template_hdr(phba); in hwi_init_port()
3789 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3793 status = beiscsi_create_wrb_rings(phba, phwi_context, phwi_ctrlr); in hwi_init_port()
3795 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3803 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in hwi_init_port()
3810 phba->params.cxns_per_ctrl; cri++) { in hwi_init_port()
3820 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_port()
3825 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3827 hwi_cleanup_port(phba); in hwi_init_port()
3831 static int hwi_init_controller(struct beiscsi_hba *phba) in hwi_init_controller() argument
3835 phwi_ctrlr = phba->phwi_ctrlr; in hwi_init_controller()
3836 if (1 == phba->init_mem[HWI_MEM_ADDN_CONTEXT].num_elements) { in hwi_init_controller()
3837 phwi_ctrlr->phwi_ctxt = (struct hwi_context_memory *)phba-> in hwi_init_controller()
3839 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_controller()
3843 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_controller()
3849 iscsi_init_global_templates(phba); in hwi_init_controller()
3850 if (beiscsi_init_wrb_handle(phba)) in hwi_init_controller()
3853 if (hwi_init_async_pdu_ctx(phba)) { in hwi_init_controller()
3854 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_controller()
3859 if (hwi_init_port(phba) != 0) { in hwi_init_controller()
3860 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_controller()
3868 static void beiscsi_free_mem(struct beiscsi_hba *phba) in beiscsi_free_mem() argument
3873 mem_descr = phba->init_mem; in beiscsi_free_mem()
3876 dma_free_coherent(&phba->pcidev->dev, in beiscsi_free_mem()
3886 kfree(phba->init_mem); in beiscsi_free_mem()
3887 kfree(phba->phwi_ctrlr->wrb_context); in beiscsi_free_mem()
3888 kfree(phba->phwi_ctrlr); in beiscsi_free_mem()
3891 static int beiscsi_init_sgl_handle(struct beiscsi_hba *phba) in beiscsi_init_sgl_handle() argument
3899 phba->io_sgl_hndl_avbl = 0; in beiscsi_init_sgl_handle()
3900 phba->eh_sgl_hndl_avbl = 0; in beiscsi_init_sgl_handle()
3902 mem_descr_sglh = phba->init_mem; in beiscsi_init_sgl_handle()
3905 phba->io_sgl_hndl_base = kcalloc(phba->params.ios_per_ctrl, in beiscsi_init_sgl_handle()
3908 if (!phba->io_sgl_hndl_base) { in beiscsi_init_sgl_handle()
3909 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_sgl_handle()
3913 phba->eh_sgl_hndl_base = in beiscsi_init_sgl_handle()
3914 kcalloc(phba->params.icds_per_ctrl - in beiscsi_init_sgl_handle()
3915 phba->params.ios_per_ctrl, in beiscsi_init_sgl_handle()
3917 if (!phba->eh_sgl_hndl_base) { in beiscsi_init_sgl_handle()
3918 kfree(phba->io_sgl_hndl_base); in beiscsi_init_sgl_handle()
3919 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_sgl_handle()
3924 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_sgl_handle()
3937 if (arr_index < phba->params.ios_per_ctrl) { in beiscsi_init_sgl_handle()
3938 phba->io_sgl_hndl_base[arr_index] = psgl_handle; in beiscsi_init_sgl_handle()
3939 phba->io_sgl_hndl_avbl++; in beiscsi_init_sgl_handle()
3942 phba->eh_sgl_hndl_base[arr_index - in beiscsi_init_sgl_handle()
3943 phba->params.ios_per_ctrl] = in beiscsi_init_sgl_handle()
3946 phba->eh_sgl_hndl_avbl++; in beiscsi_init_sgl_handle()
3952 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_init_sgl_handle()
3955 phba->io_sgl_hndl_avbl, in beiscsi_init_sgl_handle()
3956 phba->eh_sgl_hndl_avbl); in beiscsi_init_sgl_handle()
3958 mem_descr_sg = phba->init_mem; in beiscsi_init_sgl_handle()
3960 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_init_sgl_handle()
3965 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) in beiscsi_init_sgl_handle()
3968 ulp_icd_start = phba->fw_config.iscsi_icd_start[ulp_num]; in beiscsi_init_sgl_handle()
3977 (sizeof(struct iscsi_sge) * phba->params.num_sge_per_io); in beiscsi_init_sgl_handle()
3979 if (arr_index < phba->params.ios_per_ctrl) in beiscsi_init_sgl_handle()
3980 psgl_handle = phba->io_sgl_hndl_base[arr_index]; in beiscsi_init_sgl_handle()
3982 psgl_handle = phba->eh_sgl_hndl_base[arr_index - in beiscsi_init_sgl_handle()
3983 phba->params.ios_per_ctrl]; in beiscsi_init_sgl_handle()
3987 pfrag += phba->params.num_sge_per_io; in beiscsi_init_sgl_handle()
3992 phba->io_sgl_free_index = 0; in beiscsi_init_sgl_handle()
3993 phba->io_sgl_alloc_index = 0; in beiscsi_init_sgl_handle()
3994 phba->eh_sgl_free_index = 0; in beiscsi_init_sgl_handle()
3995 phba->eh_sgl_alloc_index = 0; in beiscsi_init_sgl_handle()
3999 static int hba_setup_cid_tbls(struct beiscsi_hba *phba) in hba_setup_cid_tbls() argument
4006 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { in hba_setup_cid_tbls()
4017 kcalloc(BEISCSI_GET_CID_COUNT(phba, ulp_num), in hba_setup_cid_tbls()
4028 phba, ulp_num); in hba_setup_cid_tbls()
4031 phba->cid_array_info[ulp_num] = ptr_cid_info; in hba_setup_cid_tbls()
4034 phba->ep_array = kcalloc(phba->params.cxns_per_ctrl, in hba_setup_cid_tbls()
4037 if (!phba->ep_array) { in hba_setup_cid_tbls()
4043 phba->conn_table = kcalloc(phba->params.cxns_per_ctrl, in hba_setup_cid_tbls()
4046 if (!phba->conn_table) { in hba_setup_cid_tbls()
4047 kfree(phba->ep_array); in hba_setup_cid_tbls()
4048 phba->ep_array = NULL; in hba_setup_cid_tbls()
4054 for (i = 0; i < phba->params.cxns_per_ctrl; i++) { in hba_setup_cid_tbls()
4055 ulp_num = phba->phwi_ctrlr->wrb_context[i].ulp_num; in hba_setup_cid_tbls()
4057 ptr_cid_info = phba->cid_array_info[ulp_num]; in hba_setup_cid_tbls()
4059 phba->phwi_ctrlr->wrb_context[i].cid; in hba_setup_cid_tbls()
4064 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { in hba_setup_cid_tbls()
4065 ptr_cid_info = phba->cid_array_info[ulp_num]; in hba_setup_cid_tbls()
4075 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { in hba_setup_cid_tbls()
4076 ptr_cid_info = phba->cid_array_info[ulp_num]; in hba_setup_cid_tbls()
4081 phba->cid_array_info[ulp_num] = NULL; in hba_setup_cid_tbls()
4089 static void hwi_enable_intr(struct beiscsi_hba *phba) in hwi_enable_intr() argument
4091 struct be_ctrl_info *ctrl = &phba->ctrl; in hwi_enable_intr()
4099 phwi_ctrlr = phba->phwi_ctrlr; in hwi_enable_intr()
4109 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_enable_intr()
4114 if (!phba->pcidev->msix_enabled) { in hwi_enable_intr()
4116 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_enable_intr()
4119 hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1); in hwi_enable_intr()
4121 for (i = 0; i <= phba->num_cpus; i++) { in hwi_enable_intr()
4123 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_enable_intr()
4125 hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1); in hwi_enable_intr()
4130 static void hwi_disable_intr(struct beiscsi_hba *phba) in hwi_disable_intr() argument
4132 struct be_ctrl_info *ctrl = &phba->ctrl; in hwi_disable_intr()
4142 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, in hwi_disable_intr()
4146 static int beiscsi_init_port(struct beiscsi_hba *phba) in beiscsi_init_port() argument
4150 ret = hwi_init_controller(phba); in beiscsi_init_port()
4152 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_port()
4156 ret = beiscsi_init_sgl_handle(phba); in beiscsi_init_port()
4158 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_port()
4163 ret = hba_setup_cid_tbls(phba); in beiscsi_init_port()
4165 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_port()
4167 kfree(phba->io_sgl_hndl_base); in beiscsi_init_port()
4168 kfree(phba->eh_sgl_hndl_base); in beiscsi_init_port()
4174 hwi_cleanup_port(phba); in beiscsi_init_port()
4178 static void beiscsi_cleanup_port(struct beiscsi_hba *phba) in beiscsi_cleanup_port() argument
4183 kfree(phba->io_sgl_hndl_base); in beiscsi_cleanup_port()
4184 kfree(phba->eh_sgl_hndl_base); in beiscsi_cleanup_port()
4185 kfree(phba->ep_array); in beiscsi_cleanup_port()
4186 kfree(phba->conn_table); in beiscsi_cleanup_port()
4189 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { in beiscsi_cleanup_port()
4190 ptr_cid_info = phba->cid_array_info[ulp_num]; in beiscsi_cleanup_port()
4195 phba->cid_array_info[ulp_num] = NULL; in beiscsi_cleanup_port()
4213 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_free_mgmt_task_handles() local
4219 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_free_mgmt_task_handles()
4225 free_wrb_handle(phba, pwrb_context, io_task->pwrb_handle); in beiscsi_free_mgmt_task_handles()
4230 free_mgmt_sgl_handle(phba, io_task->psgl_handle); in beiscsi_free_mgmt_task_handles()
4235 dma_unmap_single(&phba->pcidev->dev, in beiscsi_free_mgmt_task_handles()
4253 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_cleanup_task() local
4260 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_cleanup_task()
4272 free_wrb_handle(phba, pwrb_context, in beiscsi_cleanup_task()
4278 free_io_sgl_handle(phba, io_task->psgl_handle); in beiscsi_cleanup_task()
4299 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_offload_connection() local
4313 pwrb_handle = alloc_wrb_handle(phba, beiscsi_conn->beiscsi_conn_cid, in beiscsi_offload_connection()
4317 if (is_chip_be2_be3r(phba)) in beiscsi_offload_connection()
4319 phba->init_mem, in beiscsi_offload_connection()
4332 iowrite32(doorbell, phba->db_va + in beiscsi_offload_connection()
4342 phba->params.wrbs_per_cxn); in beiscsi_offload_connection()
4343 beiscsi_log(phba, KERN_INFO, in beiscsi_offload_connection()
4373 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_alloc_pdu() local
4395 io_task->psgl_handle = alloc_io_sgl_handle(phba); in beiscsi_alloc_pdu()
4397 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4404 io_task->pwrb_handle = alloc_wrb_handle(phba, in beiscsi_alloc_pdu()
4408 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4421 alloc_mgmt_sgl_handle(phba); in beiscsi_alloc_pdu()
4423 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4436 alloc_wrb_handle(phba, in beiscsi_alloc_pdu()
4440 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4458 io_task->psgl_handle = alloc_mgmt_sgl_handle(phba); in beiscsi_alloc_pdu()
4460 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4469 alloc_wrb_handle(phba, in beiscsi_alloc_pdu()
4473 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4492 free_io_sgl_handle(phba, io_task->psgl_handle); in beiscsi_alloc_pdu()
4495 free_mgmt_sgl_handle(phba, io_task->psgl_handle); in beiscsi_alloc_pdu()
4498 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_alloc_pdu()
4503 free_wrb_handle(phba, pwrb_context, io_task->pwrb_handle); in beiscsi_alloc_pdu()
4518 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_iotask_v2() local
4566 iowrite32(doorbell, phba->db_va + in beiscsi_iotask_v2()
4579 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_iotask() local
4627 iowrite32(doorbell, phba->db_va + in beiscsi_iotask()
4637 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_mtask() local
4647 if (is_chip_be2_be3r(phba)) { in beiscsi_mtask()
4695 if (is_chip_be2_be3r(phba)) in beiscsi_mtask()
4703 if (is_chip_be2_be3r(phba)) in beiscsi_mtask()
4726 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, in beiscsi_mtask()
4737 io_task->wrb_type = (is_chip_be2_be3r(phba)) ? in beiscsi_mtask()
4745 iowrite32(doorbell, phba->db_va + in beiscsi_mtask()
4754 struct beiscsi_hba *phba; in beiscsi_task_xmit() local
4759 phba = io_task->conn->phba; in beiscsi_task_xmit()
4765 if (!beiscsi_hba_is_online(phba)) in beiscsi_task_xmit()
4778 beiscsi_log(phba, KERN_ERR, in beiscsi_task_xmit()
4799 return phba->iotask_fn(task, sg, num_sg, xferlen, writedir); in beiscsi_task_xmit()
4809 struct beiscsi_hba *phba; in beiscsi_bsg_request() local
4819 phba = iscsi_host_priv(shost); in beiscsi_bsg_request()
4821 if (!beiscsi_hba_is_online(phba)) { in beiscsi_bsg_request()
4822 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, in beiscsi_bsg_request()
4823 "BM_%d : HBA in error 0x%lx\n", phba->state); in beiscsi_bsg_request()
4829 nonemb_cmd.va = dma_alloc_coherent(&phba->ctrl.pdev->dev, in beiscsi_bsg_request()
4833 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, in beiscsi_bsg_request()
4838 tag = mgmt_vendor_specific_fw_cmd(&phba->ctrl, phba, job, in beiscsi_bsg_request()
4841 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, in beiscsi_bsg_request()
4844 dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size, in beiscsi_bsg_request()
4850 phba->ctrl.mcc_wait[tag], in beiscsi_bsg_request()
4851 phba->ctrl.mcc_tag_status[tag], in beiscsi_bsg_request()
4855 if (!test_bit(BEISCSI_HBA_ONLINE, &phba->state)) { in beiscsi_bsg_request()
4857 &phba->ctrl.ptag_state[tag].tag_state); in beiscsi_bsg_request()
4858 dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size, in beiscsi_bsg_request()
4862 extd_status = (phba->ctrl.mcc_tag_status[tag] & in beiscsi_bsg_request()
4864 status = phba->ctrl.mcc_tag_status[tag] & CQE_STATUS_MASK; in beiscsi_bsg_request()
4865 free_mcc_wrb(&phba->ctrl, tag); in beiscsi_bsg_request()
4875 dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size, in beiscsi_bsg_request()
4878 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, in beiscsi_bsg_request()
4890 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, in beiscsi_bsg_request()
4899 static void beiscsi_hba_attrs_init(struct beiscsi_hba *phba) in beiscsi_hba_attrs_init() argument
4902 beiscsi_log_enable_init(phba, beiscsi_log_enable); in beiscsi_hba_attrs_init()
4905 void beiscsi_start_boot_work(struct beiscsi_hba *phba, unsigned int s_handle) in beiscsi_start_boot_work() argument
4907 if (phba->boot_struct.boot_kset) in beiscsi_start_boot_work()
4911 if (test_and_set_bit(BEISCSI_HBA_BOOT_WORK, &phba->state)) in beiscsi_start_boot_work()
4914 phba->boot_struct.retry = 3; in beiscsi_start_boot_work()
4915 phba->boot_struct.tag = 0; in beiscsi_start_boot_work()
4916 phba->boot_struct.s_handle = s_handle; in beiscsi_start_boot_work()
4917 phba->boot_struct.action = BEISCSI_BOOT_GET_SHANDLE; in beiscsi_start_boot_work()
4918 schedule_work(&phba->boot_work); in beiscsi_start_boot_work()
4930 struct beiscsi_hba *phba = data; in beiscsi_show_boot_tgt_info() local
4931 struct mgmt_session_info *boot_sess = &phba->boot_struct.boot_sess; in beiscsi_show_boot_tgt_info()
4994 struct beiscsi_hba *phba = data; in beiscsi_show_boot_ini_info() local
5001 phba->boot_struct.boot_sess.initiator_iscsiname); in beiscsi_show_boot_ini_info()
5009 struct beiscsi_hba *phba = data; in beiscsi_show_boot_eth_info() local
5021 rc = beiscsi_get_macaddr(str, phba); in beiscsi_show_boot_eth_info()
5075 struct beiscsi_hba *phba = data; in beiscsi_boot_kobj_release() local
5077 scsi_host_put(phba->shost); in beiscsi_boot_kobj_release()
5080 static int beiscsi_boot_create_kset(struct beiscsi_hba *phba) in beiscsi_boot_create_kset() argument
5082 struct boot_struct *bs = &phba->boot_struct; in beiscsi_boot_create_kset()
5086 __beiscsi_log(phba, KERN_ERR, in beiscsi_boot_create_kset()
5091 bs->boot_kset = iscsi_boot_create_host_kset(phba->shost->host_no); in beiscsi_boot_create_kset()
5093 __beiscsi_log(phba, KERN_ERR, in beiscsi_boot_create_kset()
5099 if (!scsi_host_get(phba->shost)) in beiscsi_boot_create_kset()
5102 boot_kobj = iscsi_boot_create_target(bs->boot_kset, 0, phba, in beiscsi_boot_create_kset()
5109 if (!scsi_host_get(phba->shost)) in beiscsi_boot_create_kset()
5112 boot_kobj = iscsi_boot_create_initiator(bs->boot_kset, 0, phba, in beiscsi_boot_create_kset()
5119 if (!scsi_host_get(phba->shost)) in beiscsi_boot_create_kset()
5122 boot_kobj = iscsi_boot_create_ethernet(bs->boot_kset, 0, phba, in beiscsi_boot_create_kset()
5132 scsi_host_put(phba->shost); in beiscsi_boot_create_kset()
5141 struct beiscsi_hba *phba = in beiscsi_boot_work() local
5143 struct boot_struct *bs = &phba->boot_struct; in beiscsi_boot_work()
5146 if (!beiscsi_hba_is_online(phba)) in beiscsi_boot_work()
5149 beiscsi_log(phba, KERN_INFO, in beiscsi_boot_work()
5152 __func__, phba->boot_struct.action); in beiscsi_boot_work()
5154 switch (phba->boot_struct.action) { in beiscsi_boot_work()
5156 tag = beiscsi_boot_reopen_sess(phba); in beiscsi_boot_work()
5159 tag = __beiscsi_boot_get_shandle(phba, 1); in beiscsi_boot_work()
5162 tag = beiscsi_boot_get_sinfo(phba); in beiscsi_boot_work()
5165 tag = beiscsi_boot_logout_sess(phba); in beiscsi_boot_work()
5168 beiscsi_boot_create_kset(phba); in beiscsi_boot_work()
5174 clear_bit(BEISCSI_HBA_BOOT_WORK, &phba->state); in beiscsi_boot_work()
5179 schedule_work(&phba->boot_work); in beiscsi_boot_work()
5181 clear_bit(BEISCSI_HBA_BOOT_WORK, &phba->state); in beiscsi_boot_work()
5191 struct beiscsi_hba *phba; in beiscsi_eqd_update_work() local
5197 phba = container_of(work, struct beiscsi_hba, eqd_update.work); in beiscsi_eqd_update_work()
5198 if (!beiscsi_hba_is_online(phba)) in beiscsi_eqd_update_work()
5201 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_eqd_update_work()
5204 for (i = 0; i <= phba->num_cpus; i++) { in beiscsi_eqd_update_work()
5205 aic = &phba->aic_obj[i]; in beiscsi_eqd_update_work()
5235 beiscsi_modify_eq_delay(phba, set_eqd, num); in beiscsi_eqd_update_work()
5237 schedule_delayed_work(&phba->eqd_update, in beiscsi_eqd_update_work()
5243 struct beiscsi_hba *phba = timer_container_of(phba, t, hw_check); in beiscsi_hw_tpe_check() local
5247 if (!beiscsi_detect_tpe(phba)) in beiscsi_hw_tpe_check()
5252 if (phba->ue2rp > BEISCSI_UE_DETECT_INTERVAL) in beiscsi_hw_tpe_check()
5253 wait = phba->ue2rp - BEISCSI_UE_DETECT_INTERVAL; in beiscsi_hw_tpe_check()
5254 queue_delayed_work(phba->wq, &phba->recover_port, in beiscsi_hw_tpe_check()
5260 struct beiscsi_hba *phba = timer_container_of(phba, t, hw_check); in beiscsi_hw_health_check() local
5262 beiscsi_detect_ue(phba); in beiscsi_hw_health_check()
5263 if (beiscsi_detect_ue(phba)) { in beiscsi_hw_health_check()
5264 __beiscsi_log(phba, KERN_ERR, in beiscsi_hw_health_check()
5265 "BM_%d : port in error: %lx\n", phba->state); in beiscsi_hw_health_check()
5267 queue_work(phba->wq, &phba->sess_work); in beiscsi_hw_health_check()
5270 if (!test_bit(BEISCSI_HBA_UER_SUPP, &phba->state)) in beiscsi_hw_health_check()
5273 phba->hw_check.function = beiscsi_hw_tpe_check; in beiscsi_hw_health_check()
5276 mod_timer(&phba->hw_check, in beiscsi_hw_health_check()
5288 static int beiscsi_enable_port(struct beiscsi_hba *phba) in beiscsi_enable_port() argument
5295 if (test_bit(BEISCSI_HBA_ONLINE, &phba->state)) { in beiscsi_enable_port()
5296 __beiscsi_log(phba, KERN_ERR, in beiscsi_enable_port()
5298 __func__, phba->state); in beiscsi_enable_port()
5302 ret = beiscsi_init_sliport(phba); in beiscsi_enable_port()
5306 be2iscsi_enable_msix(phba); in beiscsi_enable_port()
5308 beiscsi_get_params(phba); in beiscsi_enable_port()
5309 beiscsi_set_host_data(phba); in beiscsi_enable_port()
5311 beiscsi_set_uer_feature(phba); in beiscsi_enable_port()
5313 phba->shost->max_id = phba->params.cxns_per_ctrl - 1; in beiscsi_enable_port()
5314 phba->shost->can_queue = phba->params.ios_per_ctrl; in beiscsi_enable_port()
5315 ret = beiscsi_init_port(phba); in beiscsi_enable_port()
5317 __beiscsi_log(phba, KERN_ERR, in beiscsi_enable_port()
5323 init_waitqueue_head(&phba->ctrl.mcc_wait[i + 1]); in beiscsi_enable_port()
5324 phba->ctrl.mcc_tag[i] = i + 1; in beiscsi_enable_port()
5325 phba->ctrl.mcc_tag_status[i + 1] = 0; in beiscsi_enable_port()
5326 phba->ctrl.mcc_tag_available++; in beiscsi_enable_port()
5329 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_enable_port()
5331 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_enable_port()
5336 i = (phba->pcidev->msix_enabled) ? i : 0; in beiscsi_enable_port()
5341 ret = beiscsi_init_irqs(phba); in beiscsi_enable_port()
5343 __beiscsi_log(phba, KERN_ERR, in beiscsi_enable_port()
5347 hwi_enable_intr(phba); in beiscsi_enable_port()
5349 set_bit(BEISCSI_HBA_ONLINE, &phba->state); in beiscsi_enable_port()
5350 __beiscsi_log(phba, KERN_INFO, in beiscsi_enable_port()
5351 "BM_%d : port online: 0x%lx\n", phba->state); in beiscsi_enable_port()
5354 schedule_delayed_work(&phba->eqd_update, in beiscsi_enable_port()
5361 phba->hw_check.function = beiscsi_hw_health_check; in beiscsi_enable_port()
5362 mod_timer(&phba->hw_check, in beiscsi_enable_port()
5367 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_enable_port()
5371 hwi_cleanup_port(phba); in beiscsi_enable_port()
5374 pci_free_irq_vectors(phba->pcidev); in beiscsi_enable_port()
5386 static void beiscsi_disable_port(struct beiscsi_hba *phba, int unload) in beiscsi_disable_port() argument
5393 if (!test_and_clear_bit(BEISCSI_HBA_ONLINE, &phba->state)) in beiscsi_disable_port()
5396 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_disable_port()
5398 hwi_disable_intr(phba); in beiscsi_disable_port()
5399 beiscsi_free_irqs(phba); in beiscsi_disable_port()
5400 pci_free_irq_vectors(phba->pcidev); in beiscsi_disable_port()
5402 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_disable_port()
5406 cancel_delayed_work_sync(&phba->eqd_update); in beiscsi_disable_port()
5407 cancel_work_sync(&phba->boot_work); in beiscsi_disable_port()
5409 if (!unload && beiscsi_hba_in_error(phba)) { in beiscsi_disable_port()
5413 hwi_cleanup_port(phba); in beiscsi_disable_port()
5414 beiscsi_cleanup_port(phba); in beiscsi_disable_port()
5419 struct beiscsi_hba *phba; in beiscsi_sess_work() local
5421 phba = container_of(work, struct beiscsi_hba, sess_work); in beiscsi_sess_work()
5427 iscsi_host_for_each_session(phba->shost, beiscsi_session_fail); in beiscsi_sess_work()
5432 struct beiscsi_hba *phba; in beiscsi_recover_port() local
5434 phba = container_of(work, struct beiscsi_hba, recover_port.work); in beiscsi_recover_port()
5435 beiscsi_disable_port(phba, 0); in beiscsi_recover_port()
5436 beiscsi_enable_port(phba); in beiscsi_recover_port()
5442 struct beiscsi_hba *phba = NULL; in beiscsi_eeh_err_detected() local
5444 phba = (struct beiscsi_hba *)pci_get_drvdata(pdev); in beiscsi_eeh_err_detected()
5445 set_bit(BEISCSI_HBA_PCI_ERR, &phba->state); in beiscsi_eeh_err_detected()
5447 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_eeh_err_detected()
5451 timer_delete_sync(&phba->hw_check); in beiscsi_eeh_err_detected()
5452 cancel_delayed_work_sync(&phba->recover_port); in beiscsi_eeh_err_detected()
5455 iscsi_host_for_each_session(phba->shost, beiscsi_session_fail); in beiscsi_eeh_err_detected()
5456 beiscsi_disable_port(phba, 0); in beiscsi_eeh_err_detected()
5459 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_eeh_err_detected()
5480 struct beiscsi_hba *phba = NULL; in beiscsi_eeh_reset() local
5483 phba = (struct beiscsi_hba *)pci_get_drvdata(pdev); in beiscsi_eeh_reset()
5485 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_eeh_reset()
5496 status = beiscsi_check_fw_rdy(phba); in beiscsi_eeh_reset()
5498 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, in beiscsi_eeh_reset()
5501 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, in beiscsi_eeh_reset()
5511 struct beiscsi_hba *phba; in beiscsi_eeh_resume() local
5514 phba = (struct beiscsi_hba *)pci_get_drvdata(pdev); in beiscsi_eeh_resume()
5517 ret = beiscsi_enable_port(phba); in beiscsi_eeh_resume()
5519 __beiscsi_log(phba, KERN_ERR, in beiscsi_eeh_resume()
5528 struct beiscsi_hba *phba = NULL; in beiscsi_dev_probe() local
5540 phba = beiscsi_hba_alloc(pcidev); in beiscsi_dev_probe()
5541 if (!phba) { in beiscsi_dev_probe()
5551 beiscsi_hba_attrs_init(phba); in beiscsi_dev_probe()
5553 phba->mac_addr_set = false; in beiscsi_dev_probe()
5559 phba->generation = BE_GEN2; in beiscsi_dev_probe()
5560 phba->iotask_fn = beiscsi_iotask; in beiscsi_dev_probe()
5566 phba->generation = BE_GEN3; in beiscsi_dev_probe()
5567 phba->iotask_fn = beiscsi_iotask; in beiscsi_dev_probe()
5570 phba->generation = BE_GEN4; in beiscsi_dev_probe()
5571 phba->iotask_fn = beiscsi_iotask_v2; in beiscsi_dev_probe()
5574 phba->generation = 0; in beiscsi_dev_probe()
5577 ret = be_ctrl_init(phba, pcidev); in beiscsi_dev_probe()
5579 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5584 ret = beiscsi_init_sliport(phba); in beiscsi_dev_probe()
5588 spin_lock_init(&phba->io_sgl_lock); in beiscsi_dev_probe()
5589 spin_lock_init(&phba->mgmt_sgl_lock); in beiscsi_dev_probe()
5590 spin_lock_init(&phba->async_pdu_lock); in beiscsi_dev_probe()
5591 ret = beiscsi_get_fw_config(&phba->ctrl, phba); in beiscsi_dev_probe()
5593 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5597 beiscsi_get_port_name(&phba->ctrl, phba); in beiscsi_dev_probe()
5598 beiscsi_get_params(phba); in beiscsi_dev_probe()
5599 beiscsi_set_host_data(phba); in beiscsi_dev_probe()
5600 beiscsi_set_uer_feature(phba); in beiscsi_dev_probe()
5602 be2iscsi_enable_msix(phba); in beiscsi_dev_probe()
5604 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5606 phba->num_cpus); in beiscsi_dev_probe()
5608 phba->shost->max_id = phba->params.cxns_per_ctrl; in beiscsi_dev_probe()
5609 phba->shost->can_queue = phba->params.ios_per_ctrl; in beiscsi_dev_probe()
5610 ret = beiscsi_get_memory(phba); in beiscsi_dev_probe()
5612 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5617 ret = beiscsi_init_port(phba); in beiscsi_dev_probe()
5619 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5621 beiscsi_free_mem(phba); in beiscsi_dev_probe()
5626 init_waitqueue_head(&phba->ctrl.mcc_wait[i + 1]); in beiscsi_dev_probe()
5627 phba->ctrl.mcc_tag[i] = i + 1; in beiscsi_dev_probe()
5628 phba->ctrl.mcc_tag_status[i + 1] = 0; in beiscsi_dev_probe()
5629 phba->ctrl.mcc_tag_available++; in beiscsi_dev_probe()
5630 memset(&phba->ctrl.ptag_state[i].tag_mem_state, 0, in beiscsi_dev_probe()
5634 phba->ctrl.mcc_alloc_index = phba->ctrl.mcc_free_index = 0; in beiscsi_dev_probe()
5636 phba->wq = alloc_workqueue("beiscsi_%02x_wq", WQ_MEM_RECLAIM, 1, in beiscsi_dev_probe()
5637 phba->shost->host_no); in beiscsi_dev_probe()
5638 if (!phba->wq) { in beiscsi_dev_probe()
5639 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5646 INIT_DELAYED_WORK(&phba->eqd_update, beiscsi_eqd_update_work); in beiscsi_dev_probe()
5648 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_dev_probe()
5651 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_dev_probe()
5656 i = (phba->pcidev->msix_enabled) ? i : 0; in beiscsi_dev_probe()
5661 ret = beiscsi_init_irqs(phba); in beiscsi_dev_probe()
5663 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5668 hwi_enable_intr(phba); in beiscsi_dev_probe()
5670 ret = iscsi_host_add(phba->shost, &phba->pcidev->dev); in beiscsi_dev_probe()
5675 set_bit(BEISCSI_HBA_ONLINE, &phba->state); in beiscsi_dev_probe()
5676 __beiscsi_log(phba, KERN_INFO, in beiscsi_dev_probe()
5677 "BM_%d : port online: 0x%lx\n", phba->state); in beiscsi_dev_probe()
5679 INIT_WORK(&phba->boot_work, beiscsi_boot_work); in beiscsi_dev_probe()
5680 ret = beiscsi_boot_get_shandle(phba, &s_handle); in beiscsi_dev_probe()
5682 beiscsi_start_boot_work(phba, s_handle); in beiscsi_dev_probe()
5688 set_bit(BEISCSI_HBA_BOOT_FOUND, &phba->state); in beiscsi_dev_probe()
5691 beiscsi_iface_create_default(phba); in beiscsi_dev_probe()
5692 schedule_delayed_work(&phba->eqd_update, in beiscsi_dev_probe()
5695 INIT_WORK(&phba->sess_work, beiscsi_sess_work); in beiscsi_dev_probe()
5696 INIT_DELAYED_WORK(&phba->recover_port, beiscsi_recover_port); in beiscsi_dev_probe()
5701 timer_setup(&phba->hw_check, beiscsi_hw_health_check, 0); in beiscsi_dev_probe()
5702 mod_timer(&phba->hw_check, in beiscsi_dev_probe()
5704 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5709 hwi_disable_intr(phba); in beiscsi_dev_probe()
5710 beiscsi_free_irqs(phba); in beiscsi_dev_probe()
5712 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_dev_probe()
5716 destroy_workqueue(phba->wq); in beiscsi_dev_probe()
5718 hwi_cleanup_port(phba); in beiscsi_dev_probe()
5719 beiscsi_cleanup_port(phba); in beiscsi_dev_probe()
5720 beiscsi_free_mem(phba); in beiscsi_dev_probe()
5722 dma_free_coherent(&phba->pcidev->dev, in beiscsi_dev_probe()
5723 phba->ctrl.mbox_mem_alloced.size, in beiscsi_dev_probe()
5724 phba->ctrl.mbox_mem_alloced.va, in beiscsi_dev_probe()
5725 phba->ctrl.mbox_mem_alloced.dma); in beiscsi_dev_probe()
5726 beiscsi_unmap_pci_function(phba); in beiscsi_dev_probe()
5728 pci_disable_msix(phba->pcidev); in beiscsi_dev_probe()
5729 pci_dev_put(phba->pcidev); in beiscsi_dev_probe()
5730 iscsi_host_free(phba->shost); in beiscsi_dev_probe()
5740 struct beiscsi_hba *phba = NULL; in beiscsi_remove() local
5742 phba = pci_get_drvdata(pcidev); in beiscsi_remove()
5743 if (!phba) { in beiscsi_remove()
5749 timer_delete_sync(&phba->hw_check); in beiscsi_remove()
5750 cancel_delayed_work_sync(&phba->recover_port); in beiscsi_remove()
5751 cancel_work_sync(&phba->sess_work); in beiscsi_remove()
5753 beiscsi_iface_destroy_default(phba); in beiscsi_remove()
5754 iscsi_host_remove(phba->shost, false); in beiscsi_remove()
5755 beiscsi_disable_port(phba, 1); in beiscsi_remove()
5758 iscsi_boot_destroy_kset(phba->boot_struct.boot_kset); in beiscsi_remove()
5761 destroy_workqueue(phba->wq); in beiscsi_remove()
5762 beiscsi_free_mem(phba); in beiscsi_remove()
5765 beiscsi_unmap_pci_function(phba); in beiscsi_remove()
5766 dma_free_coherent(&phba->pcidev->dev, in beiscsi_remove()
5767 phba->ctrl.mbox_mem_alloced.size, in beiscsi_remove()
5768 phba->ctrl.mbox_mem_alloced.va, in beiscsi_remove()
5769 phba->ctrl.mbox_mem_alloced.dma); in beiscsi_remove()
5771 pci_dev_put(phba->pcidev); in beiscsi_remove()
5772 iscsi_host_free(phba->shost); in beiscsi_remove()