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()
2716 static int hwi_init_async_pdu_ctx(struct beiscsi_hba *phba) in hwi_init_async_pdu_ctx() argument
2720 struct hba_parameters *p = &phba->params; in hwi_init_async_pdu_ctx()
2727 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in hwi_init_async_pdu_ctx()
2729 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2733 phwi_ctrlr = phba->phwi_ctrlr; in hwi_init_async_pdu_ctx()
2746 pasync_ctx->num_entries = BEISCSI_ASYNC_HDQ_SIZE(phba, in hwi_init_async_pdu_ctx()
2749 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2753 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_async_pdu_ctx()
2760 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2775 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2779 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_async_pdu_ctx()
2786 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2795 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2799 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_async_pdu_ctx()
2806 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2815 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2819 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_async_pdu_ctx()
2826 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2835 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2839 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2855 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2859 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_async_pdu_ctx()
2866 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2881 phba->params.defpdu_data_sz); in hwi_init_async_pdu_ctx()
2885 (phba, ulp_num); index++) { in hwi_init_async_pdu_ctx()
2924 phba->params.defpdu_data_sz); in hwi_init_async_pdu_ctx()
2971 hwi_build_be_sgl_arr(struct beiscsi_hba *phba, in hwi_build_be_sgl_arr() argument
2983 hwi_build_be_sgl_by_offset(struct beiscsi_hba *phba, in hwi_build_be_sgl_by_offset() argument
3010 static int beiscsi_create_eqs(struct beiscsi_hba *phba, in beiscsi_create_eqs() argument
3020 num_eq_pages = PAGES_REQUIRED(phba->params.num_eq_entries * in beiscsi_create_eqs()
3023 if (phba->pcidev->msix_enabled) in beiscsi_create_eqs()
3027 for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) { in beiscsi_create_eqs()
3030 phwi_context->be_eq[i].phba = phba; in beiscsi_create_eqs()
3031 eq_vaddress = dma_alloc_coherent(&phba->pcidev->dev, in beiscsi_create_eqs()
3040 ret = be_fill_queue(eq, phba->params.num_eq_entries, in beiscsi_create_eqs()
3043 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_eqs()
3049 ret = beiscsi_cmd_eq_create(&phba->ctrl, eq, in beiscsi_create_eqs()
3052 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_eqs()
3057 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_create_eqs()
3064 for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) { in beiscsi_create_eqs()
3068 dma_free_coherent(&phba->pcidev->dev, num_eq_pages in beiscsi_create_eqs()
3075 static int beiscsi_create_cqs(struct beiscsi_hba *phba, in beiscsi_create_cqs() argument
3086 num_cq_pages = PAGES_REQUIRED(phba->params.num_cq_entries * in beiscsi_create_cqs()
3089 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_create_cqs()
3094 pbe_eq->phba = phba; in beiscsi_create_cqs()
3096 cq_vaddress = dma_alloc_coherent(&phba->pcidev->dev, in beiscsi_create_cqs()
3104 ret = be_fill_queue(cq, phba->params.num_cq_entries, in beiscsi_create_cqs()
3107 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_cqs()
3113 ret = beiscsi_cmd_cq_create(&phba->ctrl, cq, eq, false, in beiscsi_create_cqs()
3116 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_cqs()
3120 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_create_cqs()
3127 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_create_cqs()
3131 dma_free_coherent(&phba->pcidev->dev, num_cq_pages in beiscsi_create_cqs()
3139 beiscsi_create_def_hdr(struct beiscsi_hba *phba, in beiscsi_create_def_hdr() argument
3155 mem_descr = phba->init_mem; in beiscsi_create_def_hdr()
3163 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_def_hdr()
3171 ret = be_cmd_create_default_pdu_queue(&phba->ctrl, cq, dq, in beiscsi_create_def_hdr()
3173 phba->params.defpdu_hdr_sz, in beiscsi_create_def_hdr()
3176 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_def_hdr()
3183 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_create_def_hdr()
3191 beiscsi_create_def_data(struct beiscsi_hba *phba, in beiscsi_create_def_data() argument
3207 mem_descr = phba->init_mem; in beiscsi_create_def_data()
3215 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_def_data()
3224 ret = be_cmd_create_default_pdu_queue(&phba->ctrl, cq, dataq, in beiscsi_create_def_data()
3226 phba->params.defpdu_data_sz, in beiscsi_create_def_data()
3229 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_def_data()
3236 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_create_def_data()
3241 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_create_def_data()
3249 beiscsi_post_template_hdr(struct beiscsi_hba *phba) in beiscsi_post_template_hdr() argument
3257 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in beiscsi_post_template_hdr()
3258 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in beiscsi_post_template_hdr()
3263 hwi_build_be_sgl_arr(phba, pm_arr, &sgl); in beiscsi_post_template_hdr()
3265 &phba->ctrl, &sgl); in beiscsi_post_template_hdr()
3268 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_post_template_hdr()
3274 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_post_template_hdr()
3283 beiscsi_post_pages(struct beiscsi_hba *phba) in beiscsi_post_pages() argument
3291 mem_descr = phba->init_mem; in beiscsi_post_pages()
3296 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) in beiscsi_post_pages()
3299 page_offset = (sizeof(struct iscsi_sge) * phba->params.num_sge_per_io * in beiscsi_post_pages()
3300 phba->fw_config.iscsi_icd_start[ulp_num]) / PAGE_SIZE; in beiscsi_post_pages()
3302 hwi_build_be_sgl_arr(phba, pm_arr, &sgl); in beiscsi_post_pages()
3303 status = be_cmd_iscsi_post_sgl_pages(&phba->ctrl, &sgl, in beiscsi_post_pages()
3308 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_post_pages()
3314 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_post_pages()
3319 static void be_queue_free(struct beiscsi_hba *phba, struct be_queue_info *q) in be_queue_free() argument
3323 dma_free_coherent(&phba->pcidev->dev, mem->size, in be_queue_free()
3329 static int be_queue_alloc(struct beiscsi_hba *phba, struct be_queue_info *q, in be_queue_alloc() argument
3338 mem->va = dma_alloc_coherent(&phba->pcidev->dev, mem->size, &mem->dma, in be_queue_alloc()
3346 beiscsi_create_wrb_rings(struct beiscsi_hba *phba, in beiscsi_create_wrb_rings() argument
3363 mem_descr = phba->init_mem; in beiscsi_create_wrb_rings()
3365 pwrb_arr = kmalloc_array(phba->params.cxns_per_ctrl, in beiscsi_create_wrb_rings()
3369 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_wrb_rings()
3376 (phba->params.wrbs_per_cxn * sizeof(struct iscsi_wrb)); in beiscsi_create_wrb_rings()
3378 for (num = 0; num < phba->params.cxns_per_ctrl; num++) { in beiscsi_create_wrb_rings()
3382 pwrb_arr[num].size = phba->params.wrbs_per_cxn * in beiscsi_create_wrb_rings()
3393 (phba->params.wrbs_per_cxn * in beiscsi_create_wrb_rings()
3397 pwrb_arr[num].size = phba->params.wrbs_per_cxn * in beiscsi_create_wrb_rings()
3407 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in beiscsi_create_wrb_rings()
3411 BEISCSI_GET_CID_COUNT(phba, ulp_num); in beiscsi_create_wrb_rings()
3414 for (i = 0; i < phba->params.cxns_per_ctrl; i++) { in beiscsi_create_wrb_rings()
3426 hwi_build_be_sgl_by_offset(phba, &pwrb_arr[i], &sgl); in beiscsi_create_wrb_rings()
3427 status = be_cmd_wrbq_create(&phba->ctrl, &sgl, in beiscsi_create_wrb_rings()
3432 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_wrb_rings()
3444 static void free_wrb_handles(struct beiscsi_hba *phba) in free_wrb_handles() argument
3450 phwi_ctrlr = phba->phwi_ctrlr; in free_wrb_handles()
3451 for (index = 0; index < phba->params.cxns_per_ctrl; index++) { in free_wrb_handles()
3458 static void be_mcc_queues_destroy(struct beiscsi_hba *phba) in be_mcc_queues_destroy() argument
3460 struct be_ctrl_info *ctrl = &phba->ctrl; in be_mcc_queues_destroy()
3465 q = &phba->ctrl.mcc_obj.q; in be_mcc_queues_destroy()
3509 be_queue_free(phba, q); in be_mcc_queues_destroy()
3512 q = &phba->ctrl.mcc_obj.cq; in be_mcc_queues_destroy()
3515 be_queue_free(phba, q); in be_mcc_queues_destroy()
3519 static int be_mcc_queues_create(struct beiscsi_hba *phba, in be_mcc_queues_create() argument
3523 struct be_ctrl_info *ctrl = &phba->ctrl; in be_mcc_queues_create()
3526 cq = &phba->ctrl.mcc_obj.cq; in be_mcc_queues_create()
3527 if (be_queue_alloc(phba, cq, MCC_CQ_LEN, in be_mcc_queues_create()
3531 if (phba->pcidev->msix_enabled) { in be_mcc_queues_create()
3533 &phwi_context->be_eq[phba->num_cpus].q, in be_mcc_queues_create()
3543 q = &phba->ctrl.mcc_obj.q; in be_mcc_queues_create()
3544 if (be_queue_alloc(phba, q, MCC_Q_LEN, sizeof(struct be_mcc_wrb))) in be_mcc_queues_create()
3548 if (beiscsi_cmd_mccq_create(phba, q, cq)) in be_mcc_queues_create()
3554 be_queue_free(phba, q); in be_mcc_queues_create()
3558 be_queue_free(phba, cq); in be_mcc_queues_create()
3563 static void be2iscsi_enable_msix(struct beiscsi_hba *phba) in be2iscsi_enable_msix() argument
3567 switch (phba->generation) { in be2iscsi_enable_msix()
3573 nvec = phba->fw_config.eqid_count; in be2iscsi_enable_msix()
3584 if (pci_alloc_irq_vectors_affinity(phba->pcidev, 2, nvec, in be2iscsi_enable_msix()
3586 phba->num_cpus = nvec - 1; in be2iscsi_enable_msix()
3591 phba->num_cpus = 1; in be2iscsi_enable_msix()
3594 static void hwi_purge_eq(struct beiscsi_hba *phba) in hwi_purge_eq() argument
3603 if (beiscsi_hba_in_error(phba)) in hwi_purge_eq()
3606 phwi_ctrlr = phba->phwi_ctrlr; in hwi_purge_eq()
3608 if (phba->pcidev->msix_enabled) in hwi_purge_eq()
3613 for (i = 0; i < (phba->num_cpus + eq_msix); i++) { in hwi_purge_eq()
3626 hwi_ring_eq_db(phba, eq->id, 1, num_processed, 1, 1); in hwi_purge_eq()
3630 static void hwi_cleanup_port(struct beiscsi_hba *phba) in hwi_cleanup_port() argument
3633 struct be_ctrl_info *ctrl = &phba->ctrl; in hwi_cleanup_port()
3639 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) in hwi_cleanup_port()
3640 beiscsi_cmd_iscsi_cleanup(phba, ulp_num); in hwi_cleanup_port()
3647 hwi_purge_eq(phba); in hwi_cleanup_port()
3649 phwi_ctrlr = phba->phwi_ctrlr; in hwi_cleanup_port()
3654 for (i = 0; i < phba->params.cxns_per_ctrl; i++) { in hwi_cleanup_port()
3660 free_wrb_handles(phba); in hwi_cleanup_port()
3663 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in hwi_cleanup_port()
3677 for (i = 0; i < (phba->num_cpus); i++) { in hwi_cleanup_port()
3680 be_queue_free(phba, q); in hwi_cleanup_port()
3685 be_mcc_queues_destroy(phba); in hwi_cleanup_port()
3686 if (phba->pcidev->msix_enabled) in hwi_cleanup_port()
3690 for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) { in hwi_cleanup_port()
3693 be_queue_free(phba, q); in hwi_cleanup_port()
3698 beiscsi_cmd_function_reset(phba); in hwi_cleanup_port()
3700 beiscsi_cmd_special_wrb(&phba->ctrl, 0); in hwi_cleanup_port()
3703 static int hwi_init_port(struct beiscsi_hba *phba) in hwi_init_port() argument
3708 struct be_ctrl_info *ctrl = &phba->ctrl; in hwi_init_port()
3712 phwi_ctrlr = phba->phwi_ctrlr; in hwi_init_port()
3715 phba->optic_state = 0xff; in hwi_init_port()
3717 status = beiscsi_create_eqs(phba, phwi_context); in hwi_init_port()
3719 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3724 status = be_mcc_queues_create(phba, phwi_context); in hwi_init_port()
3728 status = beiscsi_check_supported_fw(ctrl, phba); in hwi_init_port()
3730 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3735 status = beiscsi_create_cqs(phba, phwi_context); in hwi_init_port()
3737 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3743 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in hwi_init_port()
3747 status = beiscsi_create_def_hdr(phba, phwi_context, in hwi_init_port()
3752 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3758 status = beiscsi_create_def_data(phba, phwi_context, in hwi_init_port()
3763 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3772 beiscsi_hdq_post_handles(phba, BEISCSI_DEFQ_HDR, in hwi_init_port()
3774 beiscsi_hdq_post_handles(phba, BEISCSI_DEFQ_DATA, in hwi_init_port()
3779 status = beiscsi_post_pages(phba); in hwi_init_port()
3781 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3786 status = beiscsi_post_template_hdr(phba); in hwi_init_port()
3788 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3792 status = beiscsi_create_wrb_rings(phba, phwi_context, phwi_ctrlr); in hwi_init_port()
3794 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3802 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in hwi_init_port()
3809 phba->params.cxns_per_ctrl; cri++) { in hwi_init_port()
3819 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_port()
3824 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3826 hwi_cleanup_port(phba); in hwi_init_port()
3830 static int hwi_init_controller(struct beiscsi_hba *phba) in hwi_init_controller() argument
3834 phwi_ctrlr = phba->phwi_ctrlr; in hwi_init_controller()
3835 if (1 == phba->init_mem[HWI_MEM_ADDN_CONTEXT].num_elements) { in hwi_init_controller()
3836 phwi_ctrlr->phwi_ctxt = (struct hwi_context_memory *)phba-> in hwi_init_controller()
3838 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_controller()
3842 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_controller()
3848 iscsi_init_global_templates(phba); in hwi_init_controller()
3849 if (beiscsi_init_wrb_handle(phba)) in hwi_init_controller()
3852 if (hwi_init_async_pdu_ctx(phba)) { in hwi_init_controller()
3853 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_controller()
3858 if (hwi_init_port(phba) != 0) { in hwi_init_controller()
3859 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_controller()
3867 static void beiscsi_free_mem(struct beiscsi_hba *phba) in beiscsi_free_mem() argument
3872 mem_descr = phba->init_mem; in beiscsi_free_mem()
3875 dma_free_coherent(&phba->pcidev->dev, in beiscsi_free_mem()
3885 kfree(phba->init_mem); in beiscsi_free_mem()
3886 kfree(phba->phwi_ctrlr->wrb_context); in beiscsi_free_mem()
3887 kfree(phba->phwi_ctrlr); in beiscsi_free_mem()
3890 static int beiscsi_init_sgl_handle(struct beiscsi_hba *phba) in beiscsi_init_sgl_handle() argument
3898 phba->io_sgl_hndl_avbl = 0; in beiscsi_init_sgl_handle()
3899 phba->eh_sgl_hndl_avbl = 0; in beiscsi_init_sgl_handle()
3901 mem_descr_sglh = phba->init_mem; in beiscsi_init_sgl_handle()
3904 phba->io_sgl_hndl_base = kcalloc(phba->params.ios_per_ctrl, in beiscsi_init_sgl_handle()
3907 if (!phba->io_sgl_hndl_base) { in beiscsi_init_sgl_handle()
3908 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_sgl_handle()
3912 phba->eh_sgl_hndl_base = in beiscsi_init_sgl_handle()
3913 kcalloc(phba->params.icds_per_ctrl - in beiscsi_init_sgl_handle()
3914 phba->params.ios_per_ctrl, in beiscsi_init_sgl_handle()
3916 if (!phba->eh_sgl_hndl_base) { in beiscsi_init_sgl_handle()
3917 kfree(phba->io_sgl_hndl_base); in beiscsi_init_sgl_handle()
3918 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_sgl_handle()
3923 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_sgl_handle()
3936 if (arr_index < phba->params.ios_per_ctrl) { in beiscsi_init_sgl_handle()
3937 phba->io_sgl_hndl_base[arr_index] = psgl_handle; in beiscsi_init_sgl_handle()
3938 phba->io_sgl_hndl_avbl++; in beiscsi_init_sgl_handle()
3941 phba->eh_sgl_hndl_base[arr_index - in beiscsi_init_sgl_handle()
3942 phba->params.ios_per_ctrl] = in beiscsi_init_sgl_handle()
3945 phba->eh_sgl_hndl_avbl++; in beiscsi_init_sgl_handle()
3951 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_init_sgl_handle()
3954 phba->io_sgl_hndl_avbl, in beiscsi_init_sgl_handle()
3955 phba->eh_sgl_hndl_avbl); in beiscsi_init_sgl_handle()
3957 mem_descr_sg = phba->init_mem; in beiscsi_init_sgl_handle()
3959 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_init_sgl_handle()
3964 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) in beiscsi_init_sgl_handle()
3967 ulp_icd_start = phba->fw_config.iscsi_icd_start[ulp_num]; in beiscsi_init_sgl_handle()
3976 (sizeof(struct iscsi_sge) * phba->params.num_sge_per_io); in beiscsi_init_sgl_handle()
3978 if (arr_index < phba->params.ios_per_ctrl) in beiscsi_init_sgl_handle()
3979 psgl_handle = phba->io_sgl_hndl_base[arr_index]; in beiscsi_init_sgl_handle()
3981 psgl_handle = phba->eh_sgl_hndl_base[arr_index - in beiscsi_init_sgl_handle()
3982 phba->params.ios_per_ctrl]; in beiscsi_init_sgl_handle()
3986 pfrag += phba->params.num_sge_per_io; in beiscsi_init_sgl_handle()
3991 phba->io_sgl_free_index = 0; in beiscsi_init_sgl_handle()
3992 phba->io_sgl_alloc_index = 0; in beiscsi_init_sgl_handle()
3993 phba->eh_sgl_free_index = 0; in beiscsi_init_sgl_handle()
3994 phba->eh_sgl_alloc_index = 0; in beiscsi_init_sgl_handle()
3998 static int hba_setup_cid_tbls(struct beiscsi_hba *phba) in hba_setup_cid_tbls() argument
4005 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { in hba_setup_cid_tbls()
4016 kcalloc(BEISCSI_GET_CID_COUNT(phba, ulp_num), in hba_setup_cid_tbls()
4027 phba, ulp_num); in hba_setup_cid_tbls()
4030 phba->cid_array_info[ulp_num] = ptr_cid_info; in hba_setup_cid_tbls()
4033 phba->ep_array = kcalloc(phba->params.cxns_per_ctrl, in hba_setup_cid_tbls()
4036 if (!phba->ep_array) { in hba_setup_cid_tbls()
4042 phba->conn_table = kcalloc(phba->params.cxns_per_ctrl, in hba_setup_cid_tbls()
4045 if (!phba->conn_table) { in hba_setup_cid_tbls()
4046 kfree(phba->ep_array); in hba_setup_cid_tbls()
4047 phba->ep_array = NULL; in hba_setup_cid_tbls()
4053 for (i = 0; i < phba->params.cxns_per_ctrl; i++) { in hba_setup_cid_tbls()
4054 ulp_num = phba->phwi_ctrlr->wrb_context[i].ulp_num; in hba_setup_cid_tbls()
4056 ptr_cid_info = phba->cid_array_info[ulp_num]; in hba_setup_cid_tbls()
4058 phba->phwi_ctrlr->wrb_context[i].cid; in hba_setup_cid_tbls()
4063 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { in hba_setup_cid_tbls()
4064 ptr_cid_info = phba->cid_array_info[ulp_num]; in hba_setup_cid_tbls()
4074 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { in hba_setup_cid_tbls()
4075 ptr_cid_info = phba->cid_array_info[ulp_num]; in hba_setup_cid_tbls()
4080 phba->cid_array_info[ulp_num] = NULL; in hba_setup_cid_tbls()
4088 static void hwi_enable_intr(struct beiscsi_hba *phba) in hwi_enable_intr() argument
4090 struct be_ctrl_info *ctrl = &phba->ctrl; in hwi_enable_intr()
4098 phwi_ctrlr = phba->phwi_ctrlr; in hwi_enable_intr()
4108 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_enable_intr()
4113 if (!phba->pcidev->msix_enabled) { in hwi_enable_intr()
4115 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_enable_intr()
4118 hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1); in hwi_enable_intr()
4120 for (i = 0; i <= phba->num_cpus; i++) { in hwi_enable_intr()
4122 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_enable_intr()
4124 hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1); in hwi_enable_intr()
4129 static void hwi_disable_intr(struct beiscsi_hba *phba) in hwi_disable_intr() argument
4131 struct be_ctrl_info *ctrl = &phba->ctrl; in hwi_disable_intr()
4141 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, in hwi_disable_intr()
4145 static int beiscsi_init_port(struct beiscsi_hba *phba) in beiscsi_init_port() argument
4149 ret = hwi_init_controller(phba); in beiscsi_init_port()
4151 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_port()
4155 ret = beiscsi_init_sgl_handle(phba); in beiscsi_init_port()
4157 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_port()
4162 ret = hba_setup_cid_tbls(phba); in beiscsi_init_port()
4164 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_port()
4166 kfree(phba->io_sgl_hndl_base); in beiscsi_init_port()
4167 kfree(phba->eh_sgl_hndl_base); in beiscsi_init_port()
4173 hwi_cleanup_port(phba); in beiscsi_init_port()
4177 static void beiscsi_cleanup_port(struct beiscsi_hba *phba) in beiscsi_cleanup_port() argument
4182 kfree(phba->io_sgl_hndl_base); in beiscsi_cleanup_port()
4183 kfree(phba->eh_sgl_hndl_base); in beiscsi_cleanup_port()
4184 kfree(phba->ep_array); in beiscsi_cleanup_port()
4185 kfree(phba->conn_table); in beiscsi_cleanup_port()
4188 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { in beiscsi_cleanup_port()
4189 ptr_cid_info = phba->cid_array_info[ulp_num]; in beiscsi_cleanup_port()
4194 phba->cid_array_info[ulp_num] = NULL; in beiscsi_cleanup_port()
4212 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_free_mgmt_task_handles() local
4218 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_free_mgmt_task_handles()
4224 free_wrb_handle(phba, pwrb_context, io_task->pwrb_handle); in beiscsi_free_mgmt_task_handles()
4229 free_mgmt_sgl_handle(phba, io_task->psgl_handle); in beiscsi_free_mgmt_task_handles()
4234 dma_unmap_single(&phba->pcidev->dev, in beiscsi_free_mgmt_task_handles()
4252 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_cleanup_task() local
4259 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_cleanup_task()
4271 free_wrb_handle(phba, pwrb_context, in beiscsi_cleanup_task()
4277 free_io_sgl_handle(phba, io_task->psgl_handle); in beiscsi_cleanup_task()
4298 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_offload_connection() local
4312 pwrb_handle = alloc_wrb_handle(phba, beiscsi_conn->beiscsi_conn_cid, in beiscsi_offload_connection()
4316 if (is_chip_be2_be3r(phba)) in beiscsi_offload_connection()
4318 phba->init_mem, in beiscsi_offload_connection()
4331 iowrite32(doorbell, phba->db_va + in beiscsi_offload_connection()
4341 phba->params.wrbs_per_cxn); in beiscsi_offload_connection()
4342 beiscsi_log(phba, KERN_INFO, in beiscsi_offload_connection()
4372 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_alloc_pdu() local
4394 io_task->psgl_handle = alloc_io_sgl_handle(phba); in beiscsi_alloc_pdu()
4396 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4403 io_task->pwrb_handle = alloc_wrb_handle(phba, in beiscsi_alloc_pdu()
4407 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4420 alloc_mgmt_sgl_handle(phba); in beiscsi_alloc_pdu()
4422 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4435 alloc_wrb_handle(phba, in beiscsi_alloc_pdu()
4439 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4457 io_task->psgl_handle = alloc_mgmt_sgl_handle(phba); in beiscsi_alloc_pdu()
4459 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4468 alloc_wrb_handle(phba, in beiscsi_alloc_pdu()
4472 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4491 free_io_sgl_handle(phba, io_task->psgl_handle); in beiscsi_alloc_pdu()
4494 free_mgmt_sgl_handle(phba, io_task->psgl_handle); in beiscsi_alloc_pdu()
4497 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_alloc_pdu()
4502 free_wrb_handle(phba, pwrb_context, io_task->pwrb_handle); in beiscsi_alloc_pdu()
4517 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_iotask_v2() local
4565 iowrite32(doorbell, phba->db_va + in beiscsi_iotask_v2()
4578 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_iotask() local
4626 iowrite32(doorbell, phba->db_va + in beiscsi_iotask()
4636 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_mtask() local
4646 if (is_chip_be2_be3r(phba)) { in beiscsi_mtask()
4694 if (is_chip_be2_be3r(phba)) in beiscsi_mtask()
4702 if (is_chip_be2_be3r(phba)) in beiscsi_mtask()
4725 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, in beiscsi_mtask()
4736 io_task->wrb_type = (is_chip_be2_be3r(phba)) ? in beiscsi_mtask()
4744 iowrite32(doorbell, phba->db_va + in beiscsi_mtask()
4753 struct beiscsi_hba *phba; in beiscsi_task_xmit() local
4758 phba = io_task->conn->phba; in beiscsi_task_xmit()
4764 if (!beiscsi_hba_is_online(phba)) in beiscsi_task_xmit()
4777 beiscsi_log(phba, KERN_ERR, in beiscsi_task_xmit()
4798 return phba->iotask_fn(task, sg, num_sg, xferlen, writedir); in beiscsi_task_xmit()
4808 struct beiscsi_hba *phba; in beiscsi_bsg_request() local
4818 phba = iscsi_host_priv(shost); in beiscsi_bsg_request()
4820 if (!beiscsi_hba_is_online(phba)) { in beiscsi_bsg_request()
4821 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, in beiscsi_bsg_request()
4822 "BM_%d : HBA in error 0x%lx\n", phba->state); in beiscsi_bsg_request()
4828 nonemb_cmd.va = dma_alloc_coherent(&phba->ctrl.pdev->dev, in beiscsi_bsg_request()
4832 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, in beiscsi_bsg_request()
4837 tag = mgmt_vendor_specific_fw_cmd(&phba->ctrl, phba, job, in beiscsi_bsg_request()
4840 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, in beiscsi_bsg_request()
4843 dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size, in beiscsi_bsg_request()
4849 phba->ctrl.mcc_wait[tag], in beiscsi_bsg_request()
4850 phba->ctrl.mcc_tag_status[tag], in beiscsi_bsg_request()
4854 if (!test_bit(BEISCSI_HBA_ONLINE, &phba->state)) { in beiscsi_bsg_request()
4856 &phba->ctrl.ptag_state[tag].tag_state); in beiscsi_bsg_request()
4857 dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size, in beiscsi_bsg_request()
4861 extd_status = (phba->ctrl.mcc_tag_status[tag] & in beiscsi_bsg_request()
4863 status = phba->ctrl.mcc_tag_status[tag] & CQE_STATUS_MASK; in beiscsi_bsg_request()
4864 free_mcc_wrb(&phba->ctrl, tag); in beiscsi_bsg_request()
4874 dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size, in beiscsi_bsg_request()
4877 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, in beiscsi_bsg_request()
4889 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, in beiscsi_bsg_request()
4898 static void beiscsi_hba_attrs_init(struct beiscsi_hba *phba) in beiscsi_hba_attrs_init() argument
4901 beiscsi_log_enable_init(phba, beiscsi_log_enable); in beiscsi_hba_attrs_init()
4904 void beiscsi_start_boot_work(struct beiscsi_hba *phba, unsigned int s_handle) in beiscsi_start_boot_work() argument
4906 if (phba->boot_struct.boot_kset) in beiscsi_start_boot_work()
4910 if (test_and_set_bit(BEISCSI_HBA_BOOT_WORK, &phba->state)) in beiscsi_start_boot_work()
4913 phba->boot_struct.retry = 3; in beiscsi_start_boot_work()
4914 phba->boot_struct.tag = 0; in beiscsi_start_boot_work()
4915 phba->boot_struct.s_handle = s_handle; in beiscsi_start_boot_work()
4916 phba->boot_struct.action = BEISCSI_BOOT_GET_SHANDLE; in beiscsi_start_boot_work()
4917 schedule_work(&phba->boot_work); in beiscsi_start_boot_work()
4929 struct beiscsi_hba *phba = data; in beiscsi_show_boot_tgt_info() local
4930 struct mgmt_session_info *boot_sess = &phba->boot_struct.boot_sess; in beiscsi_show_boot_tgt_info()
4993 struct beiscsi_hba *phba = data; in beiscsi_show_boot_ini_info() local
5000 phba->boot_struct.boot_sess.initiator_iscsiname); in beiscsi_show_boot_ini_info()
5008 struct beiscsi_hba *phba = data; in beiscsi_show_boot_eth_info() local
5020 rc = beiscsi_get_macaddr(str, phba); in beiscsi_show_boot_eth_info()
5074 struct beiscsi_hba *phba = data; in beiscsi_boot_kobj_release() local
5076 scsi_host_put(phba->shost); in beiscsi_boot_kobj_release()
5079 static int beiscsi_boot_create_kset(struct beiscsi_hba *phba) in beiscsi_boot_create_kset() argument
5081 struct boot_struct *bs = &phba->boot_struct; in beiscsi_boot_create_kset()
5085 __beiscsi_log(phba, KERN_ERR, in beiscsi_boot_create_kset()
5090 bs->boot_kset = iscsi_boot_create_host_kset(phba->shost->host_no); in beiscsi_boot_create_kset()
5092 __beiscsi_log(phba, KERN_ERR, in beiscsi_boot_create_kset()
5098 if (!scsi_host_get(phba->shost)) in beiscsi_boot_create_kset()
5101 boot_kobj = iscsi_boot_create_target(bs->boot_kset, 0, phba, in beiscsi_boot_create_kset()
5108 if (!scsi_host_get(phba->shost)) in beiscsi_boot_create_kset()
5111 boot_kobj = iscsi_boot_create_initiator(bs->boot_kset, 0, phba, in beiscsi_boot_create_kset()
5118 if (!scsi_host_get(phba->shost)) in beiscsi_boot_create_kset()
5121 boot_kobj = iscsi_boot_create_ethernet(bs->boot_kset, 0, phba, in beiscsi_boot_create_kset()
5131 scsi_host_put(phba->shost); in beiscsi_boot_create_kset()
5140 struct beiscsi_hba *phba = in beiscsi_boot_work() local
5142 struct boot_struct *bs = &phba->boot_struct; in beiscsi_boot_work()
5145 if (!beiscsi_hba_is_online(phba)) in beiscsi_boot_work()
5148 beiscsi_log(phba, KERN_INFO, in beiscsi_boot_work()
5151 __func__, phba->boot_struct.action); in beiscsi_boot_work()
5153 switch (phba->boot_struct.action) { in beiscsi_boot_work()
5155 tag = beiscsi_boot_reopen_sess(phba); in beiscsi_boot_work()
5158 tag = __beiscsi_boot_get_shandle(phba, 1); in beiscsi_boot_work()
5161 tag = beiscsi_boot_get_sinfo(phba); in beiscsi_boot_work()
5164 tag = beiscsi_boot_logout_sess(phba); in beiscsi_boot_work()
5167 beiscsi_boot_create_kset(phba); in beiscsi_boot_work()
5173 clear_bit(BEISCSI_HBA_BOOT_WORK, &phba->state); in beiscsi_boot_work()
5178 schedule_work(&phba->boot_work); in beiscsi_boot_work()
5180 clear_bit(BEISCSI_HBA_BOOT_WORK, &phba->state); in beiscsi_boot_work()
5190 struct beiscsi_hba *phba; in beiscsi_eqd_update_work() local
5196 phba = container_of(work, struct beiscsi_hba, eqd_update.work); in beiscsi_eqd_update_work()
5197 if (!beiscsi_hba_is_online(phba)) in beiscsi_eqd_update_work()
5200 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_eqd_update_work()
5203 for (i = 0; i <= phba->num_cpus; i++) { in beiscsi_eqd_update_work()
5204 aic = &phba->aic_obj[i]; in beiscsi_eqd_update_work()
5234 beiscsi_modify_eq_delay(phba, set_eqd, num); in beiscsi_eqd_update_work()
5236 schedule_delayed_work(&phba->eqd_update, in beiscsi_eqd_update_work()
5242 struct beiscsi_hba *phba = from_timer(phba, t, hw_check); in beiscsi_hw_tpe_check() local
5246 if (!beiscsi_detect_tpe(phba)) in beiscsi_hw_tpe_check()
5251 if (phba->ue2rp > BEISCSI_UE_DETECT_INTERVAL) in beiscsi_hw_tpe_check()
5252 wait = phba->ue2rp - BEISCSI_UE_DETECT_INTERVAL; in beiscsi_hw_tpe_check()
5253 queue_delayed_work(phba->wq, &phba->recover_port, in beiscsi_hw_tpe_check()
5259 struct beiscsi_hba *phba = from_timer(phba, t, hw_check); in beiscsi_hw_health_check() local
5261 beiscsi_detect_ue(phba); in beiscsi_hw_health_check()
5262 if (beiscsi_detect_ue(phba)) { in beiscsi_hw_health_check()
5263 __beiscsi_log(phba, KERN_ERR, in beiscsi_hw_health_check()
5264 "BM_%d : port in error: %lx\n", phba->state); in beiscsi_hw_health_check()
5266 queue_work(phba->wq, &phba->sess_work); in beiscsi_hw_health_check()
5269 if (!test_bit(BEISCSI_HBA_UER_SUPP, &phba->state)) in beiscsi_hw_health_check()
5272 phba->hw_check.function = beiscsi_hw_tpe_check; in beiscsi_hw_health_check()
5275 mod_timer(&phba->hw_check, in beiscsi_hw_health_check()
5287 static int beiscsi_enable_port(struct beiscsi_hba *phba) in beiscsi_enable_port() argument
5294 if (test_bit(BEISCSI_HBA_ONLINE, &phba->state)) { in beiscsi_enable_port()
5295 __beiscsi_log(phba, KERN_ERR, in beiscsi_enable_port()
5297 __func__, phba->state); in beiscsi_enable_port()
5301 ret = beiscsi_init_sliport(phba); in beiscsi_enable_port()
5305 be2iscsi_enable_msix(phba); in beiscsi_enable_port()
5307 beiscsi_get_params(phba); in beiscsi_enable_port()
5308 beiscsi_set_host_data(phba); in beiscsi_enable_port()
5310 beiscsi_set_uer_feature(phba); in beiscsi_enable_port()
5312 phba->shost->max_id = phba->params.cxns_per_ctrl - 1; in beiscsi_enable_port()
5313 phba->shost->can_queue = phba->params.ios_per_ctrl; in beiscsi_enable_port()
5314 ret = beiscsi_init_port(phba); in beiscsi_enable_port()
5316 __beiscsi_log(phba, KERN_ERR, in beiscsi_enable_port()
5322 init_waitqueue_head(&phba->ctrl.mcc_wait[i + 1]); in beiscsi_enable_port()
5323 phba->ctrl.mcc_tag[i] = i + 1; in beiscsi_enable_port()
5324 phba->ctrl.mcc_tag_status[i + 1] = 0; in beiscsi_enable_port()
5325 phba->ctrl.mcc_tag_available++; in beiscsi_enable_port()
5328 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_enable_port()
5330 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_enable_port()
5335 i = (phba->pcidev->msix_enabled) ? i : 0; in beiscsi_enable_port()
5340 ret = beiscsi_init_irqs(phba); in beiscsi_enable_port()
5342 __beiscsi_log(phba, KERN_ERR, in beiscsi_enable_port()
5346 hwi_enable_intr(phba); in beiscsi_enable_port()
5348 set_bit(BEISCSI_HBA_ONLINE, &phba->state); in beiscsi_enable_port()
5349 __beiscsi_log(phba, KERN_INFO, in beiscsi_enable_port()
5350 "BM_%d : port online: 0x%lx\n", phba->state); in beiscsi_enable_port()
5353 schedule_delayed_work(&phba->eqd_update, in beiscsi_enable_port()
5360 phba->hw_check.function = beiscsi_hw_health_check; in beiscsi_enable_port()
5361 mod_timer(&phba->hw_check, in beiscsi_enable_port()
5366 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_enable_port()
5370 hwi_cleanup_port(phba); in beiscsi_enable_port()
5373 pci_free_irq_vectors(phba->pcidev); in beiscsi_enable_port()
5385 static void beiscsi_disable_port(struct beiscsi_hba *phba, int unload) in beiscsi_disable_port() argument
5392 if (!test_and_clear_bit(BEISCSI_HBA_ONLINE, &phba->state)) in beiscsi_disable_port()
5395 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_disable_port()
5397 hwi_disable_intr(phba); in beiscsi_disable_port()
5398 beiscsi_free_irqs(phba); in beiscsi_disable_port()
5399 pci_free_irq_vectors(phba->pcidev); in beiscsi_disable_port()
5401 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_disable_port()
5405 cancel_delayed_work_sync(&phba->eqd_update); in beiscsi_disable_port()
5406 cancel_work_sync(&phba->boot_work); in beiscsi_disable_port()
5408 if (!unload && beiscsi_hba_in_error(phba)) { in beiscsi_disable_port()
5412 hwi_cleanup_port(phba); in beiscsi_disable_port()
5413 beiscsi_cleanup_port(phba); in beiscsi_disable_port()
5418 struct beiscsi_hba *phba; in beiscsi_sess_work() local
5420 phba = container_of(work, struct beiscsi_hba, sess_work); in beiscsi_sess_work()
5426 iscsi_host_for_each_session(phba->shost, beiscsi_session_fail); in beiscsi_sess_work()
5431 struct beiscsi_hba *phba; in beiscsi_recover_port() local
5433 phba = container_of(work, struct beiscsi_hba, recover_port.work); in beiscsi_recover_port()
5434 beiscsi_disable_port(phba, 0); in beiscsi_recover_port()
5435 beiscsi_enable_port(phba); in beiscsi_recover_port()
5441 struct beiscsi_hba *phba = NULL; in beiscsi_eeh_err_detected() local
5443 phba = (struct beiscsi_hba *)pci_get_drvdata(pdev); in beiscsi_eeh_err_detected()
5444 set_bit(BEISCSI_HBA_PCI_ERR, &phba->state); in beiscsi_eeh_err_detected()
5446 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_eeh_err_detected()
5450 del_timer_sync(&phba->hw_check); in beiscsi_eeh_err_detected()
5451 cancel_delayed_work_sync(&phba->recover_port); in beiscsi_eeh_err_detected()
5454 iscsi_host_for_each_session(phba->shost, beiscsi_session_fail); in beiscsi_eeh_err_detected()
5455 beiscsi_disable_port(phba, 0); in beiscsi_eeh_err_detected()
5458 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_eeh_err_detected()
5479 struct beiscsi_hba *phba = NULL; in beiscsi_eeh_reset() local
5482 phba = (struct beiscsi_hba *)pci_get_drvdata(pdev); in beiscsi_eeh_reset()
5484 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_eeh_reset()
5495 status = beiscsi_check_fw_rdy(phba); in beiscsi_eeh_reset()
5497 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, in beiscsi_eeh_reset()
5500 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, in beiscsi_eeh_reset()
5510 struct beiscsi_hba *phba; in beiscsi_eeh_resume() local
5513 phba = (struct beiscsi_hba *)pci_get_drvdata(pdev); in beiscsi_eeh_resume()
5516 ret = beiscsi_enable_port(phba); in beiscsi_eeh_resume()
5518 __beiscsi_log(phba, KERN_ERR, in beiscsi_eeh_resume()
5527 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()
5637 phba->shost->host_no); in beiscsi_dev_probe()
5638 phba->wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, wq_name); in beiscsi_dev_probe()
5639 if (!phba->wq) { in beiscsi_dev_probe()
5640 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5647 INIT_DELAYED_WORK(&phba->eqd_update, beiscsi_eqd_update_work); in beiscsi_dev_probe()
5649 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_dev_probe()
5652 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_dev_probe()
5657 i = (phba->pcidev->msix_enabled) ? i : 0; in beiscsi_dev_probe()
5662 ret = beiscsi_init_irqs(phba); in beiscsi_dev_probe()
5664 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5669 hwi_enable_intr(phba); in beiscsi_dev_probe()
5671 ret = iscsi_host_add(phba->shost, &phba->pcidev->dev); in beiscsi_dev_probe()
5676 set_bit(BEISCSI_HBA_ONLINE, &phba->state); in beiscsi_dev_probe()
5677 __beiscsi_log(phba, KERN_INFO, in beiscsi_dev_probe()
5678 "BM_%d : port online: 0x%lx\n", phba->state); in beiscsi_dev_probe()
5680 INIT_WORK(&phba->boot_work, beiscsi_boot_work); in beiscsi_dev_probe()
5681 ret = beiscsi_boot_get_shandle(phba, &s_handle); in beiscsi_dev_probe()
5683 beiscsi_start_boot_work(phba, s_handle); in beiscsi_dev_probe()
5689 set_bit(BEISCSI_HBA_BOOT_FOUND, &phba->state); in beiscsi_dev_probe()
5692 beiscsi_iface_create_default(phba); in beiscsi_dev_probe()
5693 schedule_delayed_work(&phba->eqd_update, in beiscsi_dev_probe()
5696 INIT_WORK(&phba->sess_work, beiscsi_sess_work); in beiscsi_dev_probe()
5697 INIT_DELAYED_WORK(&phba->recover_port, beiscsi_recover_port); in beiscsi_dev_probe()
5702 timer_setup(&phba->hw_check, beiscsi_hw_health_check, 0); in beiscsi_dev_probe()
5703 mod_timer(&phba->hw_check, in beiscsi_dev_probe()
5705 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5710 hwi_disable_intr(phba); in beiscsi_dev_probe()
5711 beiscsi_free_irqs(phba); in beiscsi_dev_probe()
5713 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_dev_probe()
5717 destroy_workqueue(phba->wq); in beiscsi_dev_probe()
5719 hwi_cleanup_port(phba); in beiscsi_dev_probe()
5720 beiscsi_cleanup_port(phba); in beiscsi_dev_probe()
5721 beiscsi_free_mem(phba); in beiscsi_dev_probe()
5723 dma_free_coherent(&phba->pcidev->dev, in beiscsi_dev_probe()
5724 phba->ctrl.mbox_mem_alloced.size, in beiscsi_dev_probe()
5725 phba->ctrl.mbox_mem_alloced.va, in beiscsi_dev_probe()
5726 phba->ctrl.mbox_mem_alloced.dma); in beiscsi_dev_probe()
5727 beiscsi_unmap_pci_function(phba); in beiscsi_dev_probe()
5729 pci_disable_msix(phba->pcidev); in beiscsi_dev_probe()
5730 pci_dev_put(phba->pcidev); in beiscsi_dev_probe()
5731 iscsi_host_free(phba->shost); in beiscsi_dev_probe()
5741 struct beiscsi_hba *phba = NULL; in beiscsi_remove() local
5743 phba = pci_get_drvdata(pcidev); in beiscsi_remove()
5744 if (!phba) { in beiscsi_remove()
5750 del_timer_sync(&phba->hw_check); in beiscsi_remove()
5751 cancel_delayed_work_sync(&phba->recover_port); in beiscsi_remove()
5752 cancel_work_sync(&phba->sess_work); in beiscsi_remove()
5754 beiscsi_iface_destroy_default(phba); in beiscsi_remove()
5755 iscsi_host_remove(phba->shost, false); in beiscsi_remove()
5756 beiscsi_disable_port(phba, 1); in beiscsi_remove()
5759 iscsi_boot_destroy_kset(phba->boot_struct.boot_kset); in beiscsi_remove()
5762 destroy_workqueue(phba->wq); in beiscsi_remove()
5763 beiscsi_free_mem(phba); in beiscsi_remove()
5766 beiscsi_unmap_pci_function(phba); in beiscsi_remove()
5767 dma_free_coherent(&phba->pcidev->dev, in beiscsi_remove()
5768 phba->ctrl.mbox_mem_alloced.size, in beiscsi_remove()
5769 phba->ctrl.mbox_mem_alloced.va, in beiscsi_remove()
5770 phba->ctrl.mbox_mem_alloced.dma); in beiscsi_remove()
5772 pci_dev_put(phba->pcidev); in beiscsi_remove()
5773 iscsi_host_free(phba->shost); in beiscsi_remove()