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;\
225 struct beiscsi_hba *phba; in beiscsi_eh_abort() local
243 phba = beiscsi_conn->phba; in beiscsi_eh_abort()
245 if (is_chip_be2_be3r(phba)) { in beiscsi_eh_abort()
256 rc = beiscsi_mgmt_invalidate_icds(phba, &inv_tbl, 1); in beiscsi_eh_abort()
259 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH, in beiscsi_eh_abort()
278 struct beiscsi_hba *phba; in beiscsi_eh_device_reset() local
295 phba = beiscsi_conn->phba; in beiscsi_eh_device_reset()
300 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH, in beiscsi_eh_device_reset()
327 if (is_chip_be2_be3r(phba)) { in beiscsi_eh_device_reset()
348 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_EH, in beiscsi_eh_device_reset()
354 if (beiscsi_mgmt_invalidate_icds(phba, &inv_tbl->tbl[0], nents)) { in beiscsi_eh_device_reset()
355 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_EH, in beiscsi_eh_device_reset()
410 struct beiscsi_hba *phba; in beiscsi_hba_alloc() local
413 shost = iscsi_host_alloc(&beiscsi_sht, sizeof(*phba), 0); in beiscsi_hba_alloc()
424 phba = iscsi_host_priv(shost); in beiscsi_hba_alloc()
425 memset(phba, 0, sizeof(*phba)); in beiscsi_hba_alloc()
426 phba->shost = shost; in beiscsi_hba_alloc()
427 phba->pcidev = pci_dev_get(pcidev); in beiscsi_hba_alloc()
428 pci_set_drvdata(pcidev, phba); in beiscsi_hba_alloc()
429 phba->interface_handle = 0xFFFFFFFF; in beiscsi_hba_alloc()
431 return phba; in beiscsi_hba_alloc()
434 static void beiscsi_unmap_pci_function(struct beiscsi_hba *phba) in beiscsi_unmap_pci_function() argument
436 if (phba->csr_va) { in beiscsi_unmap_pci_function()
437 iounmap(phba->csr_va); in beiscsi_unmap_pci_function()
438 phba->csr_va = NULL; in beiscsi_unmap_pci_function()
440 if (phba->db_va) { in beiscsi_unmap_pci_function()
441 iounmap(phba->db_va); in beiscsi_unmap_pci_function()
442 phba->db_va = NULL; in beiscsi_unmap_pci_function()
444 if (phba->pci_va) { in beiscsi_unmap_pci_function()
445 iounmap(phba->pci_va); in beiscsi_unmap_pci_function()
446 phba->pci_va = NULL; in beiscsi_unmap_pci_function()
450 static int beiscsi_map_pci_bars(struct beiscsi_hba *phba, in beiscsi_map_pci_bars() argument
460 phba->ctrl.csr = addr; in beiscsi_map_pci_bars()
461 phba->csr_va = addr; in beiscsi_map_pci_bars()
466 phba->ctrl.db = addr; in beiscsi_map_pci_bars()
467 phba->db_va = addr; in beiscsi_map_pci_bars()
469 if (phba->generation == BE_GEN2) in beiscsi_map_pci_bars()
479 phba->ctrl.pcicfg = addr; in beiscsi_map_pci_bars()
480 phba->pci_va = addr; in beiscsi_map_pci_bars()
484 beiscsi_unmap_pci_function(phba); in beiscsi_map_pci_bars()
525 static int be_ctrl_init(struct beiscsi_hba *phba, struct pci_dev *pdev) in be_ctrl_init() argument
527 struct be_ctrl_info *ctrl = &phba->ctrl; in be_ctrl_init()
533 status = beiscsi_map_pci_bars(phba, pdev); in be_ctrl_init()
540 beiscsi_unmap_pci_function(phba); in be_ctrl_init()
549 spin_lock_init(&phba->ctrl.mcc_lock); in be_ctrl_init()
558 static void beiscsi_get_params(struct beiscsi_hba *phba) in beiscsi_get_params() argument
564 total_cid_count = BEISCSI_GET_CID_COUNT(phba, BEISCSI_ULP0) + in beiscsi_get_params()
565 BEISCSI_GET_CID_COUNT(phba, BEISCSI_ULP1); in beiscsi_get_params()
574 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in beiscsi_get_params()
575 icd_start = phba->fw_config.iscsi_icd_start[ulp_num]; in beiscsi_get_params()
576 icd_count = phba->fw_config.iscsi_icd_count[ulp_num]; in beiscsi_get_params()
588 phba->fw_config. in beiscsi_get_params()
603 phba->fw_config.iscsi_icd_count[ulp_num] = (icd_count - in beiscsi_get_params()
606 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_get_params()
611 phba->fw_config. in beiscsi_get_params()
613 phba->fw_config. in beiscsi_get_params()
620 total_icd_count = phba->fw_config.iscsi_icd_count[ulp_num]; in beiscsi_get_params()
621 phba->params.ios_per_ctrl = (total_icd_count - in beiscsi_get_params()
624 phba->params.cxns_per_ctrl = total_cid_count; in beiscsi_get_params()
625 phba->params.icds_per_ctrl = total_icd_count; in beiscsi_get_params()
626 phba->params.num_sge_per_io = BE2_SGE; in beiscsi_get_params()
627 phba->params.defpdu_hdr_sz = BE2_DEFPDU_HDR_SZ; in beiscsi_get_params()
628 phba->params.defpdu_data_sz = BE2_DEFPDU_DATA_SZ; in beiscsi_get_params()
629 phba->params.num_eq_entries = 1024; in beiscsi_get_params()
630 phba->params.num_cq_entries = 1024; in beiscsi_get_params()
631 phba->params.wrbs_per_cxn = 256; in beiscsi_get_params()
634 static void hwi_ring_eq_db(struct beiscsi_hba *phba, in hwi_ring_eq_db() argument
657 iowrite32(val, phba->db_va + DB_EQ_OFFSET); in hwi_ring_eq_db()
667 struct beiscsi_hba *phba; in be_isr_mcc() local
676 phba = pbe_eq->phba; in be_isr_mcc()
677 mcc = &phba->ctrl.mcc_obj.cq; in be_isr_mcc()
694 queue_work(phba->wq, &pbe_eq->mcc_work); in be_isr_mcc()
695 hwi_ring_eq_db(phba, eq->id, 1, mcc_events, 1, 1); in be_isr_mcc()
707 struct beiscsi_hba *phba; in be_isr_msix() local
714 phba = pbe_eq->phba; in be_isr_msix()
716 hwi_ring_eq_db(phba, eq->id, 1, 0, 0, 1); in be_isr_msix()
729 struct beiscsi_hba *phba; in be_isr() local
740 phba = dev_id; in be_isr()
741 ctrl = &phba->ctrl; in be_isr()
747 phwi_ctrlr = phba->phwi_ctrlr; in be_isr()
752 mcc = &phba->ctrl.mcc_obj.cq; in be_isr()
774 queue_work(phba->wq, &pbe_eq->mcc_work); in be_isr()
780 hwi_ring_eq_db(phba, eq->id, 0, (io_events + mcc_events), rearm, 1); in be_isr()
784 static void beiscsi_free_irqs(struct beiscsi_hba *phba) in beiscsi_free_irqs() argument
789 if (!phba->pcidev->msix_enabled) { in beiscsi_free_irqs()
790 if (phba->pcidev->irq) in beiscsi_free_irqs()
791 free_irq(phba->pcidev->irq, phba); in beiscsi_free_irqs()
795 phwi_context = phba->phwi_ctrlr->phwi_ctxt; in beiscsi_free_irqs()
796 for (i = 0; i <= phba->num_cpus; i++) { in beiscsi_free_irqs()
797 free_irq(pci_irq_vector(phba->pcidev, i), in beiscsi_free_irqs()
799 kfree(phba->msi_name[i]); in beiscsi_free_irqs()
803 static int beiscsi_init_irqs(struct beiscsi_hba *phba) in beiscsi_init_irqs() argument
805 struct pci_dev *pcidev = phba->pcidev; in beiscsi_init_irqs()
810 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_init_irqs()
814 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_init_irqs()
815 phba->msi_name[i] = kasprintf(GFP_KERNEL, in beiscsi_init_irqs()
817 phba->shost->host_no, i); in beiscsi_init_irqs()
818 if (!phba->msi_name[i]) { in beiscsi_init_irqs()
824 be_isr_msix, 0, phba->msi_name[i], in beiscsi_init_irqs()
827 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_irqs()
831 kfree(phba->msi_name[i]); in beiscsi_init_irqs()
835 phba->msi_name[i] = kasprintf(GFP_KERNEL, "beiscsi_mcc_%02x", in beiscsi_init_irqs()
836 phba->shost->host_no); in beiscsi_init_irqs()
837 if (!phba->msi_name[i]) { in beiscsi_init_irqs()
842 phba->msi_name[i], &phwi_context->be_eq[i]); in beiscsi_init_irqs()
844 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT , in beiscsi_init_irqs()
847 kfree(phba->msi_name[i]); in beiscsi_init_irqs()
853 "beiscsi", phba); in beiscsi_init_irqs()
855 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_irqs()
865 kfree(phba->msi_name[j]); in beiscsi_init_irqs()
870 void hwi_ring_cq_db(struct beiscsi_hba *phba, in hwi_ring_cq_db() argument
889 iowrite32(val, phba->db_va + DB_CQ_OFFSET); in hwi_ring_cq_db()
892 static struct sgl_handle *alloc_io_sgl_handle(struct beiscsi_hba *phba) in alloc_io_sgl_handle() argument
897 spin_lock_irqsave(&phba->io_sgl_lock, flags); in alloc_io_sgl_handle()
898 if (phba->io_sgl_hndl_avbl) { in alloc_io_sgl_handle()
899 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, in alloc_io_sgl_handle()
902 phba->io_sgl_alloc_index); in alloc_io_sgl_handle()
904 psgl_handle = phba->io_sgl_hndl_base[phba-> in alloc_io_sgl_handle()
906 phba->io_sgl_hndl_base[phba->io_sgl_alloc_index] = NULL; in alloc_io_sgl_handle()
907 phba->io_sgl_hndl_avbl--; in alloc_io_sgl_handle()
908 if (phba->io_sgl_alloc_index == (phba->params. in alloc_io_sgl_handle()
910 phba->io_sgl_alloc_index = 0; in alloc_io_sgl_handle()
912 phba->io_sgl_alloc_index++; in alloc_io_sgl_handle()
915 spin_unlock_irqrestore(&phba->io_sgl_lock, flags); in alloc_io_sgl_handle()
920 free_io_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) in free_io_sgl_handle() argument
924 spin_lock_irqsave(&phba->io_sgl_lock, flags); in free_io_sgl_handle()
925 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, in free_io_sgl_handle()
927 phba->io_sgl_free_index); in free_io_sgl_handle()
929 if (phba->io_sgl_hndl_base[phba->io_sgl_free_index]) { in free_io_sgl_handle()
934 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_IO, in free_io_sgl_handle()
936 phba->io_sgl_free_index, in free_io_sgl_handle()
937 phba->io_sgl_hndl_base[phba->io_sgl_free_index]); in free_io_sgl_handle()
938 spin_unlock_irqrestore(&phba->io_sgl_lock, flags); in free_io_sgl_handle()
941 phba->io_sgl_hndl_base[phba->io_sgl_free_index] = psgl_handle; in free_io_sgl_handle()
942 phba->io_sgl_hndl_avbl++; in free_io_sgl_handle()
943 if (phba->io_sgl_free_index == (phba->params.ios_per_ctrl - 1)) in free_io_sgl_handle()
944 phba->io_sgl_free_index = 0; in free_io_sgl_handle()
946 phba->io_sgl_free_index++; in free_io_sgl_handle()
947 spin_unlock_irqrestore(&phba->io_sgl_lock, flags); in free_io_sgl_handle()
984 struct wrb_handle *alloc_wrb_handle(struct beiscsi_hba *phba, unsigned int cid, in alloc_wrb_handle() argument
991 phwi_ctrlr = phba->phwi_ctrlr; in alloc_wrb_handle()
995 return beiscsi_get_wrb_handle(pwrb_context, phba->params.wrbs_per_cxn); in alloc_wrb_handle()
1025 free_wrb_handle(struct beiscsi_hba *phba, struct hwi_wrb_context *pwrb_context, in free_wrb_handle() argument
1030 phba->params.wrbs_per_cxn); in free_wrb_handle()
1031 beiscsi_log(phba, KERN_INFO, in free_wrb_handle()
1039 static struct sgl_handle *alloc_mgmt_sgl_handle(struct beiscsi_hba *phba) in alloc_mgmt_sgl_handle() argument
1044 spin_lock_irqsave(&phba->mgmt_sgl_lock, flags); in alloc_mgmt_sgl_handle()
1045 if (phba->eh_sgl_hndl_avbl) { in alloc_mgmt_sgl_handle()
1046 psgl_handle = phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index]; in alloc_mgmt_sgl_handle()
1047 phba->eh_sgl_hndl_base[phba->eh_sgl_alloc_index] = NULL; in alloc_mgmt_sgl_handle()
1048 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, in alloc_mgmt_sgl_handle()
1050 phba->eh_sgl_alloc_index, in alloc_mgmt_sgl_handle()
1051 phba->eh_sgl_alloc_index); in alloc_mgmt_sgl_handle()
1053 phba->eh_sgl_hndl_avbl--; in alloc_mgmt_sgl_handle()
1054 if (phba->eh_sgl_alloc_index == in alloc_mgmt_sgl_handle()
1055 (phba->params.icds_per_ctrl - phba->params.ios_per_ctrl - in alloc_mgmt_sgl_handle()
1057 phba->eh_sgl_alloc_index = 0; in alloc_mgmt_sgl_handle()
1059 phba->eh_sgl_alloc_index++; in alloc_mgmt_sgl_handle()
1062 spin_unlock_irqrestore(&phba->mgmt_sgl_lock, flags); in alloc_mgmt_sgl_handle()
1067 free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle) in free_mgmt_sgl_handle() argument
1071 spin_lock_irqsave(&phba->mgmt_sgl_lock, flags); in free_mgmt_sgl_handle()
1072 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, in free_mgmt_sgl_handle()
1075 phba->eh_sgl_free_index); in free_mgmt_sgl_handle()
1077 if (phba->eh_sgl_hndl_base[phba->eh_sgl_free_index]) { in free_mgmt_sgl_handle()
1082 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_CONFIG, in free_mgmt_sgl_handle()
1085 phba->eh_sgl_free_index); in free_mgmt_sgl_handle()
1086 spin_unlock_irqrestore(&phba->mgmt_sgl_lock, flags); in free_mgmt_sgl_handle()
1089 phba->eh_sgl_hndl_base[phba->eh_sgl_free_index] = psgl_handle; in free_mgmt_sgl_handle()
1090 phba->eh_sgl_hndl_avbl++; in free_mgmt_sgl_handle()
1091 if (phba->eh_sgl_free_index == in free_mgmt_sgl_handle()
1092 (phba->params.icds_per_ctrl - phba->params.ios_per_ctrl - 1)) in free_mgmt_sgl_handle()
1093 phba->eh_sgl_free_index = 0; in free_mgmt_sgl_handle()
1095 phba->eh_sgl_free_index++; in free_mgmt_sgl_handle()
1096 spin_unlock_irqrestore(&phba->mgmt_sgl_lock, flags); in free_mgmt_sgl_handle()
1217 struct beiscsi_hba *phba, struct sol_cqe *psol) in hwi_complete_drvr_msgs() argument
1226 phwi_ctrlr = phba->phwi_ctrlr; in hwi_complete_drvr_msgs()
1227 if (is_chip_be2_be3r(phba)) { in hwi_complete_drvr_msgs()
1270 static void adapter_get_sol_cqe(struct beiscsi_hba *phba, in adapter_get_sol_cqe() argument
1274 if (is_chip_be2_be3r(phba)) { in adapter_get_sol_cqe()
1325 struct beiscsi_hba *phba, struct sol_cqe *psol) in hwi_complete_cmd() argument
1337 phwi_ctrlr = phba->phwi_ctrlr; in hwi_complete_cmd()
1340 adapter_get_sol_cqe(phba, psol, &csol_cqe); in hwi_complete_cmd()
1374 beiscsi_log(phba, KERN_ERR, in hwi_complete_cmd()
1385 beiscsi_log(phba, KERN_WARNING, in hwi_complete_cmd()
1410 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_complete_pdu() local
1428 beiscsi_log(phba, KERN_ERR, in beiscsi_complete_pdu()
1440 beiscsi_log(phba, KERN_WARNING, in beiscsi_complete_pdu()
1461 beiscsi_hdl_purge_handles(struct beiscsi_hba *phba, in beiscsi_hdl_purge_handles() argument
1484 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_hdl_get_handle() local
1501 if (is_chip_be2_be3r(phba)) { in beiscsi_hdl_get_handle()
1548 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI, in beiscsi_hdl_get_handle()
1567 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI, in beiscsi_hdl_get_handle()
1570 beiscsi_hdl_purge_handles(phba, pasync_ctx, cri); in beiscsi_hdl_get_handle()
1593 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_hdl_fwd_pdu() local
1624 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI, in beiscsi_hdl_fwd_pdu()
1635 beiscsi_hdl_purge_handles(phba, pasync_ctx, cri); in beiscsi_hdl_fwd_pdu()
1647 struct beiscsi_hba *phba; in beiscsi_hdl_gather_pdu() local
1651 phba = beiscsi_conn->phba; in beiscsi_hdl_gather_pdu()
1692 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_ISCSI, in beiscsi_hdl_gather_pdu()
1701 beiscsi_hdl_purge_handles(phba, pasync_ctx, cri); in beiscsi_hdl_gather_pdu()
1707 beiscsi_hdq_post_handles(struct beiscsi_hba *phba, in beiscsi_hdq_post_handles() argument
1718 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_hdq_post_handles()
1760 iowrite32(doorbell, phba->db_va + doorbell_offset); in beiscsi_hdq_post_handles()
1767 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_hdq_process_compl() local
1774 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_hdq_process_compl()
1780 if (is_chip_be2_be3r(phba)) in beiscsi_hdq_process_compl()
1790 beiscsi_hdq_post_handles(phba, header, ulp_num, 8 * consumed); in beiscsi_hdq_process_compl()
1793 void beiscsi_process_mcc_cq(struct beiscsi_hba *phba) in beiscsi_process_mcc_cq() argument
1799 mcc_cq = &phba->ctrl.mcc_obj.cq; in beiscsi_process_mcc_cq()
1803 if (beiscsi_hba_in_error(phba)) in beiscsi_process_mcc_cq()
1807 hwi_ring_cq_db(phba, mcc_cq->id, in beiscsi_process_mcc_cq()
1812 beiscsi_process_async_event(phba, mcc_compl); in beiscsi_process_mcc_cq()
1814 beiscsi_process_mcc_compl(&phba->ctrl, mcc_compl); in beiscsi_process_mcc_cq()
1825 hwi_ring_cq_db(phba, mcc_cq->id, num_processed, 1); in beiscsi_process_mcc_cq()
1831 struct beiscsi_hba *phba; in beiscsi_mcc_work() local
1834 phba = pbe_eq->phba; in beiscsi_mcc_work()
1835 beiscsi_process_mcc_cq(phba); in beiscsi_mcc_work()
1837 if (!beiscsi_hba_in_error(phba)) in beiscsi_mcc_work()
1838 hwi_ring_eq_db(phba, pbe_eq->q.id, 0, 0, 1, 1); in beiscsi_mcc_work()
1860 struct beiscsi_hba *phba; in beiscsi_process_cq() local
1864 phba = pbe_eq->phba; in beiscsi_process_cq()
1868 if (beiscsi_hba_in_error(phba)) in beiscsi_process_cq()
1877 if (is_chip_be2_be3r(phba)) { in beiscsi_process_cq()
1892 ep = phba->ep_array[cri_index]; in beiscsi_process_cq()
1898 beiscsi_log(phba, KERN_WARNING, in beiscsi_process_cq()
1910 hwi_ring_cq_db(phba, cq->id, 32, 0); in beiscsi_process_cq()
1917 hwi_complete_cmd(beiscsi_conn, phba, sol); in beiscsi_process_cq()
1920 beiscsi_log(phba, KERN_INFO, in beiscsi_process_cq()
1925 hwi_complete_drvr_msgs(beiscsi_conn, phba, sol); in beiscsi_process_cq()
1928 beiscsi_log(phba, KERN_INFO, in beiscsi_process_cq()
1933 spin_lock_bh(&phba->async_pdu_lock); in beiscsi_process_cq()
1936 spin_unlock_bh(&phba->async_pdu_lock); in beiscsi_process_cq()
1939 beiscsi_log(phba, KERN_INFO, in beiscsi_process_cq()
1944 spin_lock_bh(&phba->async_pdu_lock); in beiscsi_process_cq()
1947 spin_unlock_bh(&phba->async_pdu_lock); in beiscsi_process_cq()
1952 beiscsi_log(phba, KERN_ERR, in beiscsi_process_cq()
1959 beiscsi_log(phba, KERN_ERR, in beiscsi_process_cq()
1971 beiscsi_log(phba, KERN_ERR, in beiscsi_process_cq()
1977 beiscsi_log(phba, KERN_ERR, in beiscsi_process_cq()
1981 spin_lock_bh(&phba->async_pdu_lock); in beiscsi_process_cq()
1985 spin_unlock_bh(&phba->async_pdu_lock); in beiscsi_process_cq()
2002 beiscsi_log(phba, KERN_ERR, in beiscsi_process_cq()
2011 beiscsi_log(phba, KERN_ERR, in beiscsi_process_cq()
2028 hwi_ring_cq_db(phba, cq->id, num_processed, 1); in beiscsi_process_cq()
2035 struct beiscsi_hba *phba; in be_iopoll() local
2041 phba = pbe_eq->phba; in be_iopoll()
2042 if (beiscsi_hba_in_error(phba)) { in be_iopoll()
2057 hwi_ring_eq_db(phba, eq->id, 1, io_events, 0, 1); in be_iopoll()
2063 beiscsi_log(phba, KERN_INFO, in be_iopoll()
2067 if (!beiscsi_hba_in_error(phba)) in be_iopoll()
2068 hwi_ring_eq_db(phba, pbe_eq->q.id, 0, 0, 1, 1); in be_iopoll()
2266 struct beiscsi_hba *phba = beiscsi_conn->phba; in hwi_write_buffer() local
2280 if (is_chip_be2_be3r(phba)) in hwi_write_buffer()
2289 io_task->mtask_addr = dma_map_single(&phba->pcidev->dev, in hwi_write_buffer()
2293 if (dma_mapping_error(&phba->pcidev->dev, in hwi_write_buffer()
2347 static void beiscsi_find_mem_req(struct beiscsi_hba *phba) in beiscsi_find_mem_req() argument
2354 phba->params.hwi_ws_sz = sizeof(struct hwi_controller); in beiscsi_find_mem_req()
2356 phba->mem_req[ISCSI_MEM_GLOBAL_HEADER] = 2 * in beiscsi_find_mem_req()
2358 phba->mem_req[HWI_MEM_ADDN_CONTEXT] = in beiscsi_find_mem_req()
2362 phba->mem_req[HWI_MEM_WRB] = sizeof(struct iscsi_wrb) in beiscsi_find_mem_req()
2363 * (phba->params.wrbs_per_cxn) in beiscsi_find_mem_req()
2364 * phba->params.cxns_per_ctrl; in beiscsi_find_mem_req()
2366 (phba->params.wrbs_per_cxn); in beiscsi_find_mem_req()
2367 phba->mem_req[HWI_MEM_WRBH] = roundup_pow_of_two((wrb_sz_per_cxn) * in beiscsi_find_mem_req()
2368 phba->params.cxns_per_ctrl); in beiscsi_find_mem_req()
2370 phba->mem_req[HWI_MEM_SGLH] = sizeof(struct sgl_handle) * in beiscsi_find_mem_req()
2371 phba->params.icds_per_ctrl; in beiscsi_find_mem_req()
2372 phba->mem_req[HWI_MEM_SGE] = sizeof(struct iscsi_sge) * in beiscsi_find_mem_req()
2373 phba->params.num_sge_per_io * phba->params.icds_per_ctrl; in beiscsi_find_mem_req()
2375 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in beiscsi_find_mem_req()
2379 phba, ulp_num) * in beiscsi_find_mem_req()
2384 phba, ulp_num) * in beiscsi_find_mem_req()
2385 phba->params.defpdu_hdr_sz); in beiscsi_find_mem_req()
2389 phba, ulp_num) * in beiscsi_find_mem_req()
2390 phba->params.defpdu_data_sz); in beiscsi_find_mem_req()
2394 phba, ulp_num) * in beiscsi_find_mem_req()
2399 phba->mem_req[mem_descr_index] = in beiscsi_find_mem_req()
2400 BEISCSI_GET_CID_COUNT(phba, ulp_num) * in beiscsi_find_mem_req()
2405 phba->mem_req[mem_descr_index] = in beiscsi_find_mem_req()
2411 phba->mem_req[mem_descr_index] = in beiscsi_find_mem_req()
2417 phba->mem_req[mem_descr_index] = in beiscsi_find_mem_req()
2423 phba->mem_req[mem_descr_index] = in beiscsi_find_mem_req()
2429 phba->mem_req[mem_descr_index] = in beiscsi_find_mem_req()
2430 BEISCSI_ASYNC_HDQ_SIZE(phba, ulp_num) * in beiscsi_find_mem_req()
2435 phba->mem_req[mem_descr_index] = in beiscsi_find_mem_req()
2436 BEISCSI_ASYNC_HDQ_SIZE(phba, ulp_num) * in beiscsi_find_mem_req()
2441 phba->mem_req[mem_descr_index] = in beiscsi_find_mem_req()
2443 (BEISCSI_ASYNC_HDQ_SIZE(phba, ulp_num) * in beiscsi_find_mem_req()
2449 static int beiscsi_alloc_mem(struct beiscsi_hba *phba) in beiscsi_alloc_mem() argument
2457 phba->phwi_ctrlr = kzalloc(phba->params.hwi_ws_sz, GFP_KERNEL); in beiscsi_alloc_mem()
2458 if (!phba->phwi_ctrlr) in beiscsi_alloc_mem()
2462 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_alloc_mem()
2463 phwi_ctrlr->wrb_context = kcalloc(phba->params.cxns_per_ctrl, in beiscsi_alloc_mem()
2467 kfree(phba->phwi_ctrlr); in beiscsi_alloc_mem()
2471 phba->init_mem = kcalloc(SE_MEM_MAX, sizeof(*mem_descr), in beiscsi_alloc_mem()
2473 if (!phba->init_mem) { in beiscsi_alloc_mem()
2475 kfree(phba->phwi_ctrlr); in beiscsi_alloc_mem()
2483 kfree(phba->init_mem); in beiscsi_alloc_mem()
2485 kfree(phba->phwi_ctrlr); in beiscsi_alloc_mem()
2489 mem_descr = phba->init_mem; in beiscsi_alloc_mem()
2491 if (!phba->mem_req[i]) { in beiscsi_alloc_mem()
2499 alloc_size = phba->mem_req[i]; in beiscsi_alloc_mem()
2505 dma_alloc_coherent(&phba->pcidev->dev, in beiscsi_alloc_mem()
2528 mem_descr->size_in_bytes = phba->mem_req[i]; in beiscsi_alloc_mem()
2544 dma_free_coherent(&phba->pcidev->dev, in beiscsi_alloc_mem()
2559 kfree(phba->init_mem); in beiscsi_alloc_mem()
2560 kfree(phba->phwi_ctrlr->wrb_context); in beiscsi_alloc_mem()
2561 kfree(phba->phwi_ctrlr); in beiscsi_alloc_mem()
2565 static int beiscsi_get_memory(struct beiscsi_hba *phba) in beiscsi_get_memory() argument
2567 beiscsi_find_mem_req(phba); in beiscsi_get_memory()
2568 return beiscsi_alloc_mem(phba); in beiscsi_get_memory()
2571 static void iscsi_init_global_templates(struct beiscsi_hba *phba) in iscsi_init_global_templates() argument
2577 mem_descr = phba->init_mem; in iscsi_init_global_templates()
2596 static int beiscsi_init_wrb_handle(struct beiscsi_hba *phba) in beiscsi_init_wrb_handle() argument
2607 mem_descr_wrbh = phba->init_mem; in beiscsi_init_wrb_handle()
2610 mem_descr_wrb = phba->init_mem; in beiscsi_init_wrb_handle()
2612 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_init_wrb_handle()
2616 phwi_ctxt->be_wrbq = kcalloc(phba->params.cxns_per_ctrl, in beiscsi_init_wrb_handle()
2620 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_wrb_handle()
2625 for (index = 0; index < phba->params.cxns_per_ctrl; index++) { in beiscsi_init_wrb_handle()
2628 kcalloc(phba->params.wrbs_per_cxn, in beiscsi_init_wrb_handle()
2632 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_wrb_handle()
2637 kcalloc(phba->params.wrbs_per_cxn, in beiscsi_init_wrb_handle()
2641 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_wrb_handle()
2650 phba->params.wrbs_per_cxn)); in beiscsi_init_wrb_handle()
2658 for (j = 0; j < phba->params.wrbs_per_cxn; j++) { in beiscsi_init_wrb_handle()
2671 for (index = 0; index < phba->params.cxns_per_ctrl; index++) { in beiscsi_init_wrb_handle()
2677 phba->params.wrbs_per_cxn)); in beiscsi_init_wrb_handle()
2682 for (j = 0; j < phba->params.wrbs_per_cxn; j++) { in beiscsi_init_wrb_handle()
2700 static int hwi_init_async_pdu_ctx(struct beiscsi_hba *phba) in hwi_init_async_pdu_ctx() argument
2704 struct hba_parameters *p = &phba->params; in hwi_init_async_pdu_ctx()
2711 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in hwi_init_async_pdu_ctx()
2713 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2717 phwi_ctrlr = phba->phwi_ctrlr; in hwi_init_async_pdu_ctx()
2730 pasync_ctx->num_entries = BEISCSI_ASYNC_HDQ_SIZE(phba, in hwi_init_async_pdu_ctx()
2733 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2737 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_async_pdu_ctx()
2744 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2759 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2763 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_async_pdu_ctx()
2770 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2779 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2783 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_async_pdu_ctx()
2790 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2799 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2803 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_async_pdu_ctx()
2810 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2819 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2823 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2839 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in hwi_init_async_pdu_ctx()
2843 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_async_pdu_ctx()
2850 beiscsi_log(phba, KERN_WARNING, in hwi_init_async_pdu_ctx()
2865 phba->params.defpdu_data_sz); in hwi_init_async_pdu_ctx()
2869 (phba, ulp_num); index++) { in hwi_init_async_pdu_ctx()
2908 phba->params.defpdu_data_sz); in hwi_init_async_pdu_ctx()
2955 hwi_build_be_sgl_arr(struct beiscsi_hba *phba, in hwi_build_be_sgl_arr() argument
2967 hwi_build_be_sgl_by_offset(struct beiscsi_hba *phba, in hwi_build_be_sgl_by_offset() argument
2994 static int beiscsi_create_eqs(struct beiscsi_hba *phba, in beiscsi_create_eqs() argument
3004 num_eq_pages = PAGES_REQUIRED(phba->params.num_eq_entries * \ in beiscsi_create_eqs()
3007 if (phba->pcidev->msix_enabled) in beiscsi_create_eqs()
3011 for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) { in beiscsi_create_eqs()
3014 phwi_context->be_eq[i].phba = phba; in beiscsi_create_eqs()
3015 eq_vaddress = dma_alloc_coherent(&phba->pcidev->dev, in beiscsi_create_eqs()
3024 ret = be_fill_queue(eq, phba->params.num_eq_entries, in beiscsi_create_eqs()
3027 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_eqs()
3033 ret = beiscsi_cmd_eq_create(&phba->ctrl, eq, in beiscsi_create_eqs()
3036 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_eqs()
3042 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_create_eqs()
3049 for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) { in beiscsi_create_eqs()
3053 dma_free_coherent(&phba->pcidev->dev, num_eq_pages in beiscsi_create_eqs()
3060 static int beiscsi_create_cqs(struct beiscsi_hba *phba, in beiscsi_create_cqs() argument
3071 num_cq_pages = PAGES_REQUIRED(phba->params.num_cq_entries * \ in beiscsi_create_cqs()
3074 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_create_cqs()
3079 pbe_eq->phba = phba; in beiscsi_create_cqs()
3081 cq_vaddress = dma_alloc_coherent(&phba->pcidev->dev, in beiscsi_create_cqs()
3089 ret = be_fill_queue(cq, phba->params.num_cq_entries, in beiscsi_create_cqs()
3092 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_cqs()
3099 ret = beiscsi_cmd_cq_create(&phba->ctrl, cq, eq, false, in beiscsi_create_cqs()
3102 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_cqs()
3107 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_create_cqs()
3114 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_create_cqs()
3118 dma_free_coherent(&phba->pcidev->dev, num_cq_pages in beiscsi_create_cqs()
3126 beiscsi_create_def_hdr(struct beiscsi_hba *phba, in beiscsi_create_def_hdr() argument
3142 mem_descr = phba->init_mem; in beiscsi_create_def_hdr()
3150 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_def_hdr()
3158 ret = be_cmd_create_default_pdu_queue(&phba->ctrl, cq, dq, in beiscsi_create_def_hdr()
3160 phba->params.defpdu_hdr_sz, in beiscsi_create_def_hdr()
3163 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_def_hdr()
3170 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_create_def_hdr()
3178 beiscsi_create_def_data(struct beiscsi_hba *phba, in beiscsi_create_def_data() argument
3194 mem_descr = phba->init_mem; in beiscsi_create_def_data()
3202 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_def_data()
3211 ret = be_cmd_create_default_pdu_queue(&phba->ctrl, cq, dataq, in beiscsi_create_def_data()
3213 phba->params.defpdu_data_sz, in beiscsi_create_def_data()
3216 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_def_data()
3223 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_create_def_data()
3228 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_create_def_data()
3236 beiscsi_post_template_hdr(struct beiscsi_hba *phba) in beiscsi_post_template_hdr() argument
3244 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in beiscsi_post_template_hdr()
3245 mem_descr = (struct be_mem_descriptor *)phba->init_mem; in beiscsi_post_template_hdr()
3250 hwi_build_be_sgl_arr(phba, pm_arr, &sgl); in beiscsi_post_template_hdr()
3252 &phba->ctrl, &sgl); in beiscsi_post_template_hdr()
3255 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_post_template_hdr()
3261 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_post_template_hdr()
3270 beiscsi_post_pages(struct beiscsi_hba *phba) in beiscsi_post_pages() argument
3278 mem_descr = phba->init_mem; in beiscsi_post_pages()
3283 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) in beiscsi_post_pages()
3286 page_offset = (sizeof(struct iscsi_sge) * phba->params.num_sge_per_io * in beiscsi_post_pages()
3287 phba->fw_config.iscsi_icd_start[ulp_num]) / PAGE_SIZE; in beiscsi_post_pages()
3289 hwi_build_be_sgl_arr(phba, pm_arr, &sgl); in beiscsi_post_pages()
3290 status = be_cmd_iscsi_post_sgl_pages(&phba->ctrl, &sgl, in beiscsi_post_pages()
3295 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_post_pages()
3301 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_post_pages()
3306 static void be_queue_free(struct beiscsi_hba *phba, struct be_queue_info *q) in be_queue_free() argument
3310 dma_free_coherent(&phba->pcidev->dev, mem->size, in be_queue_free()
3316 static int be_queue_alloc(struct beiscsi_hba *phba, struct be_queue_info *q, in be_queue_alloc() argument
3325 mem->va = dma_alloc_coherent(&phba->pcidev->dev, mem->size, &mem->dma, in be_queue_alloc()
3333 beiscsi_create_wrb_rings(struct beiscsi_hba *phba, in beiscsi_create_wrb_rings() argument
3350 mem_descr = phba->init_mem; in beiscsi_create_wrb_rings()
3352 pwrb_arr = kmalloc_array(phba->params.cxns_per_ctrl, in beiscsi_create_wrb_rings()
3356 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_wrb_rings()
3363 (phba->params.wrbs_per_cxn * sizeof(struct iscsi_wrb)); in beiscsi_create_wrb_rings()
3365 for (num = 0; num < phba->params.cxns_per_ctrl; num++) { in beiscsi_create_wrb_rings()
3369 pwrb_arr[num].size = phba->params.wrbs_per_cxn * in beiscsi_create_wrb_rings()
3380 (phba->params.wrbs_per_cxn * in beiscsi_create_wrb_rings()
3385 pwrb_arr[num].size = phba->params.wrbs_per_cxn * in beiscsi_create_wrb_rings()
3395 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in beiscsi_create_wrb_rings()
3399 BEISCSI_GET_CID_COUNT(phba, ulp_num); in beiscsi_create_wrb_rings()
3402 for (i = 0; i < phba->params.cxns_per_ctrl; i++) { in beiscsi_create_wrb_rings()
3414 hwi_build_be_sgl_by_offset(phba, &pwrb_arr[i], &sgl); in beiscsi_create_wrb_rings()
3415 status = be_cmd_wrbq_create(&phba->ctrl, &sgl, in beiscsi_create_wrb_rings()
3420 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_create_wrb_rings()
3432 static void free_wrb_handles(struct beiscsi_hba *phba) in free_wrb_handles() argument
3438 phwi_ctrlr = phba->phwi_ctrlr; in free_wrb_handles()
3439 for (index = 0; index < phba->params.cxns_per_ctrl; index++) { in free_wrb_handles()
3446 static void be_mcc_queues_destroy(struct beiscsi_hba *phba) in be_mcc_queues_destroy() argument
3448 struct be_ctrl_info *ctrl = &phba->ctrl; in be_mcc_queues_destroy()
3453 q = &phba->ctrl.mcc_obj.q; in be_mcc_queues_destroy()
3497 be_queue_free(phba, q); in be_mcc_queues_destroy()
3500 q = &phba->ctrl.mcc_obj.cq; in be_mcc_queues_destroy()
3503 be_queue_free(phba, q); in be_mcc_queues_destroy()
3507 static int be_mcc_queues_create(struct beiscsi_hba *phba, in be_mcc_queues_create() argument
3511 struct be_ctrl_info *ctrl = &phba->ctrl; in be_mcc_queues_create()
3514 cq = &phba->ctrl.mcc_obj.cq; in be_mcc_queues_create()
3515 if (be_queue_alloc(phba, cq, MCC_CQ_LEN, in be_mcc_queues_create()
3519 if (phba->pcidev->msix_enabled) { in be_mcc_queues_create()
3521 &phwi_context->be_eq[phba->num_cpus].q, in be_mcc_queues_create()
3531 q = &phba->ctrl.mcc_obj.q; in be_mcc_queues_create()
3532 if (be_queue_alloc(phba, q, MCC_Q_LEN, sizeof(struct be_mcc_wrb))) in be_mcc_queues_create()
3536 if (beiscsi_cmd_mccq_create(phba, q, cq)) in be_mcc_queues_create()
3542 be_queue_free(phba, q); in be_mcc_queues_create()
3546 be_queue_free(phba, cq); in be_mcc_queues_create()
3551 static void be2iscsi_enable_msix(struct beiscsi_hba *phba) in be2iscsi_enable_msix() argument
3555 switch (phba->generation) { in be2iscsi_enable_msix()
3561 nvec = phba->fw_config.eqid_count; in be2iscsi_enable_msix()
3572 if (pci_alloc_irq_vectors_affinity(phba->pcidev, 2, nvec, in be2iscsi_enable_msix()
3574 phba->num_cpus = nvec - 1; in be2iscsi_enable_msix()
3579 phba->num_cpus = 1; in be2iscsi_enable_msix()
3582 static void hwi_purge_eq(struct beiscsi_hba *phba) in hwi_purge_eq() argument
3591 if (beiscsi_hba_in_error(phba)) in hwi_purge_eq()
3594 phwi_ctrlr = phba->phwi_ctrlr; in hwi_purge_eq()
3596 if (phba->pcidev->msix_enabled) in hwi_purge_eq()
3601 for (i = 0; i < (phba->num_cpus + eq_msix); i++) { in hwi_purge_eq()
3614 hwi_ring_eq_db(phba, eq->id, 1, num_processed, 1, 1); in hwi_purge_eq()
3618 static void hwi_cleanup_port(struct beiscsi_hba *phba) in hwi_cleanup_port() argument
3621 struct be_ctrl_info *ctrl = &phba->ctrl; in hwi_cleanup_port()
3627 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) in hwi_cleanup_port()
3628 beiscsi_cmd_iscsi_cleanup(phba, ulp_num); in hwi_cleanup_port()
3635 hwi_purge_eq(phba); in hwi_cleanup_port()
3637 phwi_ctrlr = phba->phwi_ctrlr; in hwi_cleanup_port()
3642 for (i = 0; i < phba->params.cxns_per_ctrl; i++) { in hwi_cleanup_port()
3648 free_wrb_handles(phba); in hwi_cleanup_port()
3651 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in hwi_cleanup_port()
3665 for (i = 0; i < (phba->num_cpus); i++) { in hwi_cleanup_port()
3668 be_queue_free(phba, q); in hwi_cleanup_port()
3673 be_mcc_queues_destroy(phba); in hwi_cleanup_port()
3674 if (phba->pcidev->msix_enabled) in hwi_cleanup_port()
3678 for (i = 0; i < (phba->num_cpus + eq_for_mcc); i++) { in hwi_cleanup_port()
3681 be_queue_free(phba, q); in hwi_cleanup_port()
3686 beiscsi_cmd_function_reset(phba); in hwi_cleanup_port()
3688 beiscsi_cmd_special_wrb(&phba->ctrl, 0); in hwi_cleanup_port()
3691 static int hwi_init_port(struct beiscsi_hba *phba) in hwi_init_port() argument
3696 struct be_ctrl_info *ctrl = &phba->ctrl; in hwi_init_port()
3700 phwi_ctrlr = phba->phwi_ctrlr; in hwi_init_port()
3703 phba->optic_state = 0xff; in hwi_init_port()
3705 status = beiscsi_create_eqs(phba, phwi_context); in hwi_init_port()
3707 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3712 status = be_mcc_queues_create(phba, phwi_context); in hwi_init_port()
3716 status = beiscsi_check_supported_fw(ctrl, phba); in hwi_init_port()
3718 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3723 status = beiscsi_create_cqs(phba, phwi_context); in hwi_init_port()
3725 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3731 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in hwi_init_port()
3735 status = beiscsi_create_def_hdr(phba, phwi_context, in hwi_init_port()
3740 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3746 status = beiscsi_create_def_data(phba, phwi_context, in hwi_init_port()
3751 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3760 beiscsi_hdq_post_handles(phba, BEISCSI_DEFQ_HDR, in hwi_init_port()
3762 beiscsi_hdq_post_handles(phba, BEISCSI_DEFQ_DATA, in hwi_init_port()
3767 status = beiscsi_post_pages(phba); in hwi_init_port()
3769 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3774 status = beiscsi_post_template_hdr(phba); in hwi_init_port()
3776 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3780 status = beiscsi_create_wrb_rings(phba, phwi_context, phwi_ctrlr); in hwi_init_port()
3782 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3790 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) { in hwi_init_port()
3797 phba->params.cxns_per_ctrl; cri++) { in hwi_init_port()
3807 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_port()
3812 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_port()
3814 hwi_cleanup_port(phba); in hwi_init_port()
3818 static int hwi_init_controller(struct beiscsi_hba *phba) in hwi_init_controller() argument
3822 phwi_ctrlr = phba->phwi_ctrlr; in hwi_init_controller()
3823 if (1 == phba->init_mem[HWI_MEM_ADDN_CONTEXT].num_elements) { in hwi_init_controller()
3824 phwi_ctrlr->phwi_ctxt = (struct hwi_context_memory *)phba-> in hwi_init_controller()
3826 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_init_controller()
3830 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_controller()
3836 iscsi_init_global_templates(phba); in hwi_init_controller()
3837 if (beiscsi_init_wrb_handle(phba)) in hwi_init_controller()
3840 if (hwi_init_async_pdu_ctx(phba)) { in hwi_init_controller()
3841 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_controller()
3846 if (hwi_init_port(phba) != 0) { in hwi_init_controller()
3847 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hwi_init_controller()
3855 static void beiscsi_free_mem(struct beiscsi_hba *phba) in beiscsi_free_mem() argument
3860 mem_descr = phba->init_mem; in beiscsi_free_mem()
3865 dma_free_coherent(&phba->pcidev->dev, in beiscsi_free_mem()
3875 kfree(phba->init_mem); in beiscsi_free_mem()
3876 kfree(phba->phwi_ctrlr->wrb_context); in beiscsi_free_mem()
3877 kfree(phba->phwi_ctrlr); in beiscsi_free_mem()
3880 static int beiscsi_init_sgl_handle(struct beiscsi_hba *phba) in beiscsi_init_sgl_handle() argument
3888 phba->io_sgl_hndl_avbl = 0; in beiscsi_init_sgl_handle()
3889 phba->eh_sgl_hndl_avbl = 0; in beiscsi_init_sgl_handle()
3891 mem_descr_sglh = phba->init_mem; in beiscsi_init_sgl_handle()
3894 phba->io_sgl_hndl_base = kcalloc(phba->params.ios_per_ctrl, in beiscsi_init_sgl_handle()
3897 if (!phba->io_sgl_hndl_base) { in beiscsi_init_sgl_handle()
3898 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_sgl_handle()
3902 phba->eh_sgl_hndl_base = in beiscsi_init_sgl_handle()
3903 kcalloc(phba->params.icds_per_ctrl - in beiscsi_init_sgl_handle()
3904 phba->params.ios_per_ctrl, in beiscsi_init_sgl_handle()
3906 if (!phba->eh_sgl_hndl_base) { in beiscsi_init_sgl_handle()
3907 kfree(phba->io_sgl_hndl_base); in beiscsi_init_sgl_handle()
3908 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_sgl_handle()
3913 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_sgl_handle()
3926 if (arr_index < phba->params.ios_per_ctrl) { in beiscsi_init_sgl_handle()
3927 phba->io_sgl_hndl_base[arr_index] = psgl_handle; in beiscsi_init_sgl_handle()
3928 phba->io_sgl_hndl_avbl++; in beiscsi_init_sgl_handle()
3931 phba->eh_sgl_hndl_base[arr_index - in beiscsi_init_sgl_handle()
3932 phba->params.ios_per_ctrl] = in beiscsi_init_sgl_handle()
3935 phba->eh_sgl_hndl_avbl++; in beiscsi_init_sgl_handle()
3941 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_init_sgl_handle()
3944 phba->io_sgl_hndl_avbl, in beiscsi_init_sgl_handle()
3945 phba->eh_sgl_hndl_avbl); in beiscsi_init_sgl_handle()
3947 mem_descr_sg = phba->init_mem; in beiscsi_init_sgl_handle()
3949 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_init_sgl_handle()
3954 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) in beiscsi_init_sgl_handle()
3957 ulp_icd_start = phba->fw_config.iscsi_icd_start[ulp_num]; in beiscsi_init_sgl_handle()
3966 (sizeof(struct iscsi_sge) * phba->params.num_sge_per_io); in beiscsi_init_sgl_handle()
3968 if (arr_index < phba->params.ios_per_ctrl) in beiscsi_init_sgl_handle()
3969 psgl_handle = phba->io_sgl_hndl_base[arr_index]; in beiscsi_init_sgl_handle()
3971 psgl_handle = phba->eh_sgl_hndl_base[arr_index - in beiscsi_init_sgl_handle()
3972 phba->params.ios_per_ctrl]; in beiscsi_init_sgl_handle()
3976 pfrag += phba->params.num_sge_per_io; in beiscsi_init_sgl_handle()
3981 phba->io_sgl_free_index = 0; in beiscsi_init_sgl_handle()
3982 phba->io_sgl_alloc_index = 0; in beiscsi_init_sgl_handle()
3983 phba->eh_sgl_free_index = 0; in beiscsi_init_sgl_handle()
3984 phba->eh_sgl_alloc_index = 0; in beiscsi_init_sgl_handle()
3988 static int hba_setup_cid_tbls(struct beiscsi_hba *phba) in hba_setup_cid_tbls() argument
3995 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { in hba_setup_cid_tbls()
4000 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hba_setup_cid_tbls()
4011 kcalloc(BEISCSI_GET_CID_COUNT(phba, ulp_num), in hba_setup_cid_tbls()
4015 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hba_setup_cid_tbls()
4026 phba, ulp_num); in hba_setup_cid_tbls()
4029 phba->cid_array_info[ulp_num] = ptr_cid_info; in hba_setup_cid_tbls()
4032 phba->ep_array = kcalloc(phba->params.cxns_per_ctrl, in hba_setup_cid_tbls()
4035 if (!phba->ep_array) { in hba_setup_cid_tbls()
4036 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hba_setup_cid_tbls()
4044 phba->conn_table = kcalloc(phba->params.cxns_per_ctrl, in hba_setup_cid_tbls()
4047 if (!phba->conn_table) { in hba_setup_cid_tbls()
4048 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in hba_setup_cid_tbls()
4052 kfree(phba->ep_array); in hba_setup_cid_tbls()
4053 phba->ep_array = NULL; in hba_setup_cid_tbls()
4059 for (i = 0; i < phba->params.cxns_per_ctrl; i++) { in hba_setup_cid_tbls()
4060 ulp_num = phba->phwi_ctrlr->wrb_context[i].ulp_num; in hba_setup_cid_tbls()
4062 ptr_cid_info = phba->cid_array_info[ulp_num]; in hba_setup_cid_tbls()
4064 phba->phwi_ctrlr->wrb_context[i].cid; in hba_setup_cid_tbls()
4069 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { in hba_setup_cid_tbls()
4070 ptr_cid_info = phba->cid_array_info[ulp_num]; in hba_setup_cid_tbls()
4080 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { in hba_setup_cid_tbls()
4081 ptr_cid_info = phba->cid_array_info[ulp_num]; in hba_setup_cid_tbls()
4086 phba->cid_array_info[ulp_num] = NULL; in hba_setup_cid_tbls()
4094 static void hwi_enable_intr(struct beiscsi_hba *phba) in hwi_enable_intr() argument
4096 struct be_ctrl_info *ctrl = &phba->ctrl; in hwi_enable_intr()
4104 phwi_ctrlr = phba->phwi_ctrlr; in hwi_enable_intr()
4114 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_enable_intr()
4119 if (!phba->pcidev->msix_enabled) { in hwi_enable_intr()
4121 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()
4126 for (i = 0; i <= phba->num_cpus; i++) { in hwi_enable_intr()
4128 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in hwi_enable_intr()
4130 hwi_ring_eq_db(phba, eq->id, 0, 0, 1, 1); in hwi_enable_intr()
4135 static void hwi_disable_intr(struct beiscsi_hba *phba) in hwi_disable_intr() argument
4137 struct be_ctrl_info *ctrl = &phba->ctrl; in hwi_disable_intr()
4147 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, in hwi_disable_intr()
4151 static int beiscsi_init_port(struct beiscsi_hba *phba) in beiscsi_init_port() argument
4155 ret = hwi_init_controller(phba); in beiscsi_init_port()
4157 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_port()
4161 ret = beiscsi_init_sgl_handle(phba); in beiscsi_init_port()
4163 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_port()
4168 ret = hba_setup_cid_tbls(phba); in beiscsi_init_port()
4170 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_init_port()
4172 kfree(phba->io_sgl_hndl_base); in beiscsi_init_port()
4173 kfree(phba->eh_sgl_hndl_base); in beiscsi_init_port()
4179 hwi_cleanup_port(phba); in beiscsi_init_port()
4183 static void beiscsi_cleanup_port(struct beiscsi_hba *phba) in beiscsi_cleanup_port() argument
4188 kfree(phba->io_sgl_hndl_base); in beiscsi_cleanup_port()
4189 kfree(phba->eh_sgl_hndl_base); in beiscsi_cleanup_port()
4190 kfree(phba->ep_array); in beiscsi_cleanup_port()
4191 kfree(phba->conn_table); in beiscsi_cleanup_port()
4194 if (test_bit(ulp_num, (void *)&phba->fw_config.ulp_supported)) { in beiscsi_cleanup_port()
4195 ptr_cid_info = phba->cid_array_info[ulp_num]; in beiscsi_cleanup_port()
4200 phba->cid_array_info[ulp_num] = NULL; in beiscsi_cleanup_port()
4218 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_free_mgmt_task_handles() local
4224 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_free_mgmt_task_handles()
4230 free_wrb_handle(phba, pwrb_context, io_task->pwrb_handle); in beiscsi_free_mgmt_task_handles()
4235 free_mgmt_sgl_handle(phba, io_task->psgl_handle); in beiscsi_free_mgmt_task_handles()
4240 dma_unmap_single(&phba->pcidev->dev, in beiscsi_free_mgmt_task_handles()
4258 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_cleanup_task() local
4265 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_cleanup_task()
4277 free_wrb_handle(phba, pwrb_context, in beiscsi_cleanup_task()
4283 free_io_sgl_handle(phba, io_task->psgl_handle); in beiscsi_cleanup_task()
4304 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_offload_connection() local
4318 pwrb_handle = alloc_wrb_handle(phba, beiscsi_conn->beiscsi_conn_cid, in beiscsi_offload_connection()
4322 if (is_chip_be2_be3r(phba)) in beiscsi_offload_connection()
4324 phba->init_mem, in beiscsi_offload_connection()
4337 iowrite32(doorbell, phba->db_va + in beiscsi_offload_connection()
4347 phba->params.wrbs_per_cxn); in beiscsi_offload_connection()
4348 beiscsi_log(phba, KERN_INFO, in beiscsi_offload_connection()
4378 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_alloc_pdu() local
4400 io_task->psgl_handle = alloc_io_sgl_handle(phba); in beiscsi_alloc_pdu()
4402 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4409 io_task->pwrb_handle = alloc_wrb_handle(phba, in beiscsi_alloc_pdu()
4413 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4426 alloc_mgmt_sgl_handle(phba); in beiscsi_alloc_pdu()
4428 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4442 alloc_wrb_handle(phba, in beiscsi_alloc_pdu()
4446 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4465 io_task->psgl_handle = alloc_mgmt_sgl_handle(phba); in beiscsi_alloc_pdu()
4467 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4477 alloc_wrb_handle(phba, in beiscsi_alloc_pdu()
4481 beiscsi_log(phba, KERN_ERR, in beiscsi_alloc_pdu()
4500 free_io_sgl_handle(phba, io_task->psgl_handle); in beiscsi_alloc_pdu()
4503 free_mgmt_sgl_handle(phba, io_task->psgl_handle); in beiscsi_alloc_pdu()
4506 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_alloc_pdu()
4511 free_wrb_handle(phba, pwrb_context, io_task->pwrb_handle); in beiscsi_alloc_pdu()
4526 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_iotask_v2() local
4574 iowrite32(doorbell, phba->db_va + in beiscsi_iotask_v2()
4587 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_iotask() local
4635 iowrite32(doorbell, phba->db_va + in beiscsi_iotask()
4645 struct beiscsi_hba *phba = beiscsi_conn->phba; in beiscsi_mtask() local
4655 if (is_chip_be2_be3r(phba)) { in beiscsi_mtask()
4703 if (is_chip_be2_be3r(phba)) in beiscsi_mtask()
4711 if (is_chip_be2_be3r(phba)) in beiscsi_mtask()
4734 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, in beiscsi_mtask()
4745 io_task->wrb_type = (is_chip_be2_be3r(phba)) ? in beiscsi_mtask()
4753 iowrite32(doorbell, phba->db_va + in beiscsi_mtask()
4762 struct beiscsi_hba *phba; in beiscsi_task_xmit() local
4767 phba = io_task->conn->phba; in beiscsi_task_xmit()
4773 if (!beiscsi_hba_is_online(phba)) in beiscsi_task_xmit()
4786 beiscsi_log(phba, KERN_ERR, in beiscsi_task_xmit()
4807 return phba->iotask_fn(task, sg, num_sg, xferlen, writedir); in beiscsi_task_xmit()
4817 struct beiscsi_hba *phba; in beiscsi_bsg_request() local
4827 phba = iscsi_host_priv(shost); in beiscsi_bsg_request()
4829 if (!beiscsi_hba_is_online(phba)) { in beiscsi_bsg_request()
4830 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG, in beiscsi_bsg_request()
4831 "BM_%d : HBA in error 0x%lx\n", phba->state); in beiscsi_bsg_request()
4837 nonemb_cmd.va = dma_alloc_coherent(&phba->ctrl.pdev->dev, in beiscsi_bsg_request()
4841 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, in beiscsi_bsg_request()
4846 tag = mgmt_vendor_specific_fw_cmd(&phba->ctrl, phba, job, in beiscsi_bsg_request()
4849 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, in beiscsi_bsg_request()
4852 dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size, in beiscsi_bsg_request()
4858 phba->ctrl.mcc_wait[tag], in beiscsi_bsg_request()
4859 phba->ctrl.mcc_tag_status[tag], in beiscsi_bsg_request()
4863 if (!test_bit(BEISCSI_HBA_ONLINE, &phba->state)) { in beiscsi_bsg_request()
4865 &phba->ctrl.ptag_state[tag].tag_state); in beiscsi_bsg_request()
4866 dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size, in beiscsi_bsg_request()
4870 extd_status = (phba->ctrl.mcc_tag_status[tag] & in beiscsi_bsg_request()
4872 status = phba->ctrl.mcc_tag_status[tag] & CQE_STATUS_MASK; in beiscsi_bsg_request()
4873 free_mcc_wrb(&phba->ctrl, tag); in beiscsi_bsg_request()
4883 dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size, in beiscsi_bsg_request()
4886 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, in beiscsi_bsg_request()
4898 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG, in beiscsi_bsg_request()
4907 static void beiscsi_hba_attrs_init(struct beiscsi_hba *phba) in beiscsi_hba_attrs_init() argument
4910 beiscsi_log_enable_init(phba, beiscsi_log_enable); in beiscsi_hba_attrs_init()
4913 void beiscsi_start_boot_work(struct beiscsi_hba *phba, unsigned int s_handle) in beiscsi_start_boot_work() argument
4915 if (phba->boot_struct.boot_kset) in beiscsi_start_boot_work()
4919 if (test_and_set_bit(BEISCSI_HBA_BOOT_WORK, &phba->state)) in beiscsi_start_boot_work()
4922 phba->boot_struct.retry = 3; in beiscsi_start_boot_work()
4923 phba->boot_struct.tag = 0; in beiscsi_start_boot_work()
4924 phba->boot_struct.s_handle = s_handle; in beiscsi_start_boot_work()
4925 phba->boot_struct.action = BEISCSI_BOOT_GET_SHANDLE; in beiscsi_start_boot_work()
4926 schedule_work(&phba->boot_work); in beiscsi_start_boot_work()
4938 struct beiscsi_hba *phba = data; in beiscsi_show_boot_tgt_info() local
4939 struct mgmt_session_info *boot_sess = &phba->boot_struct.boot_sess; in beiscsi_show_boot_tgt_info()
5002 struct beiscsi_hba *phba = data; in beiscsi_show_boot_ini_info() local
5009 phba->boot_struct.boot_sess.initiator_iscsiname); in beiscsi_show_boot_ini_info()
5017 struct beiscsi_hba *phba = data; in beiscsi_show_boot_eth_info() local
5029 rc = beiscsi_get_macaddr(str, phba); in beiscsi_show_boot_eth_info()
5083 struct beiscsi_hba *phba = data; in beiscsi_boot_kobj_release() local
5085 scsi_host_put(phba->shost); in beiscsi_boot_kobj_release()
5088 static int beiscsi_boot_create_kset(struct beiscsi_hba *phba) in beiscsi_boot_create_kset() argument
5090 struct boot_struct *bs = &phba->boot_struct; in beiscsi_boot_create_kset()
5094 __beiscsi_log(phba, KERN_ERR, in beiscsi_boot_create_kset()
5099 bs->boot_kset = iscsi_boot_create_host_kset(phba->shost->host_no); in beiscsi_boot_create_kset()
5101 __beiscsi_log(phba, KERN_ERR, in beiscsi_boot_create_kset()
5107 if (!scsi_host_get(phba->shost)) in beiscsi_boot_create_kset()
5110 boot_kobj = iscsi_boot_create_target(bs->boot_kset, 0, phba, in beiscsi_boot_create_kset()
5117 if (!scsi_host_get(phba->shost)) in beiscsi_boot_create_kset()
5120 boot_kobj = iscsi_boot_create_initiator(bs->boot_kset, 0, phba, in beiscsi_boot_create_kset()
5127 if (!scsi_host_get(phba->shost)) in beiscsi_boot_create_kset()
5130 boot_kobj = iscsi_boot_create_ethernet(bs->boot_kset, 0, phba, in beiscsi_boot_create_kset()
5140 scsi_host_put(phba->shost); in beiscsi_boot_create_kset()
5149 struct beiscsi_hba *phba = in beiscsi_boot_work() local
5151 struct boot_struct *bs = &phba->boot_struct; in beiscsi_boot_work()
5154 if (!beiscsi_hba_is_online(phba)) in beiscsi_boot_work()
5157 beiscsi_log(phba, KERN_INFO, in beiscsi_boot_work()
5160 __func__, phba->boot_struct.action); in beiscsi_boot_work()
5162 switch (phba->boot_struct.action) { in beiscsi_boot_work()
5164 tag = beiscsi_boot_reopen_sess(phba); in beiscsi_boot_work()
5167 tag = __beiscsi_boot_get_shandle(phba, 1); in beiscsi_boot_work()
5170 tag = beiscsi_boot_get_sinfo(phba); in beiscsi_boot_work()
5173 tag = beiscsi_boot_logout_sess(phba); in beiscsi_boot_work()
5176 beiscsi_boot_create_kset(phba); in beiscsi_boot_work()
5182 clear_bit(BEISCSI_HBA_BOOT_WORK, &phba->state); in beiscsi_boot_work()
5187 schedule_work(&phba->boot_work); in beiscsi_boot_work()
5189 clear_bit(BEISCSI_HBA_BOOT_WORK, &phba->state); in beiscsi_boot_work()
5199 struct beiscsi_hba *phba; in beiscsi_eqd_update_work() local
5205 phba = container_of(work, struct beiscsi_hba, eqd_update.work); in beiscsi_eqd_update_work()
5206 if (!beiscsi_hba_is_online(phba)) in beiscsi_eqd_update_work()
5209 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_eqd_update_work()
5212 for (i = 0; i <= phba->num_cpus; i++) { in beiscsi_eqd_update_work()
5213 aic = &phba->aic_obj[i]; in beiscsi_eqd_update_work()
5243 beiscsi_modify_eq_delay(phba, set_eqd, num); in beiscsi_eqd_update_work()
5245 schedule_delayed_work(&phba->eqd_update, in beiscsi_eqd_update_work()
5251 struct beiscsi_hba *phba = from_timer(phba, t, hw_check); in beiscsi_hw_tpe_check() local
5255 if (!beiscsi_detect_tpe(phba)) in beiscsi_hw_tpe_check()
5260 if (phba->ue2rp > BEISCSI_UE_DETECT_INTERVAL) in beiscsi_hw_tpe_check()
5261 wait = phba->ue2rp - BEISCSI_UE_DETECT_INTERVAL; in beiscsi_hw_tpe_check()
5262 queue_delayed_work(phba->wq, &phba->recover_port, in beiscsi_hw_tpe_check()
5268 struct beiscsi_hba *phba = from_timer(phba, t, hw_check); in beiscsi_hw_health_check() local
5270 beiscsi_detect_ue(phba); in beiscsi_hw_health_check()
5271 if (beiscsi_detect_ue(phba)) { in beiscsi_hw_health_check()
5272 __beiscsi_log(phba, KERN_ERR, in beiscsi_hw_health_check()
5273 "BM_%d : port in error: %lx\n", phba->state); in beiscsi_hw_health_check()
5275 queue_work(phba->wq, &phba->sess_work); in beiscsi_hw_health_check()
5278 if (!test_bit(BEISCSI_HBA_UER_SUPP, &phba->state)) in beiscsi_hw_health_check()
5281 phba->hw_check.function = beiscsi_hw_tpe_check; in beiscsi_hw_health_check()
5284 mod_timer(&phba->hw_check, in beiscsi_hw_health_check()
5296 static int beiscsi_enable_port(struct beiscsi_hba *phba) in beiscsi_enable_port() argument
5303 if (test_bit(BEISCSI_HBA_ONLINE, &phba->state)) { in beiscsi_enable_port()
5304 __beiscsi_log(phba, KERN_ERR, in beiscsi_enable_port()
5306 __func__, phba->state); in beiscsi_enable_port()
5310 ret = beiscsi_init_sliport(phba); in beiscsi_enable_port()
5314 be2iscsi_enable_msix(phba); in beiscsi_enable_port()
5316 beiscsi_get_params(phba); in beiscsi_enable_port()
5317 beiscsi_set_host_data(phba); in beiscsi_enable_port()
5319 beiscsi_set_uer_feature(phba); in beiscsi_enable_port()
5321 phba->shost->max_id = phba->params.cxns_per_ctrl - 1; in beiscsi_enable_port()
5322 phba->shost->can_queue = phba->params.ios_per_ctrl; in beiscsi_enable_port()
5323 ret = beiscsi_init_port(phba); in beiscsi_enable_port()
5325 __beiscsi_log(phba, KERN_ERR, in beiscsi_enable_port()
5331 init_waitqueue_head(&phba->ctrl.mcc_wait[i + 1]); in beiscsi_enable_port()
5332 phba->ctrl.mcc_tag[i] = i + 1; in beiscsi_enable_port()
5333 phba->ctrl.mcc_tag_status[i + 1] = 0; in beiscsi_enable_port()
5334 phba->ctrl.mcc_tag_available++; in beiscsi_enable_port()
5337 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_enable_port()
5339 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_enable_port()
5344 i = (phba->pcidev->msix_enabled) ? i : 0; in beiscsi_enable_port()
5349 ret = beiscsi_init_irqs(phba); in beiscsi_enable_port()
5351 __beiscsi_log(phba, KERN_ERR, in beiscsi_enable_port()
5355 hwi_enable_intr(phba); in beiscsi_enable_port()
5357 set_bit(BEISCSI_HBA_ONLINE, &phba->state); in beiscsi_enable_port()
5358 __beiscsi_log(phba, KERN_INFO, in beiscsi_enable_port()
5359 "BM_%d : port online: 0x%lx\n", phba->state); in beiscsi_enable_port()
5362 schedule_delayed_work(&phba->eqd_update, in beiscsi_enable_port()
5369 phba->hw_check.function = beiscsi_hw_health_check; in beiscsi_enable_port()
5370 mod_timer(&phba->hw_check, in beiscsi_enable_port()
5375 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_enable_port()
5379 hwi_cleanup_port(phba); in beiscsi_enable_port()
5382 pci_free_irq_vectors(phba->pcidev); in beiscsi_enable_port()
5394 static void beiscsi_disable_port(struct beiscsi_hba *phba, int unload) in beiscsi_disable_port() argument
5401 if (!test_and_clear_bit(BEISCSI_HBA_ONLINE, &phba->state)) in beiscsi_disable_port()
5404 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_disable_port()
5406 hwi_disable_intr(phba); in beiscsi_disable_port()
5407 beiscsi_free_irqs(phba); in beiscsi_disable_port()
5408 pci_free_irq_vectors(phba->pcidev); in beiscsi_disable_port()
5410 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_disable_port()
5414 cancel_delayed_work_sync(&phba->eqd_update); in beiscsi_disable_port()
5415 cancel_work_sync(&phba->boot_work); in beiscsi_disable_port()
5417 if (!unload && beiscsi_hba_in_error(phba)) { in beiscsi_disable_port()
5421 hwi_cleanup_port(phba); in beiscsi_disable_port()
5422 beiscsi_cleanup_port(phba); in beiscsi_disable_port()
5427 struct beiscsi_hba *phba; in beiscsi_sess_work() local
5429 phba = container_of(work, struct beiscsi_hba, sess_work); in beiscsi_sess_work()
5435 iscsi_host_for_each_session(phba->shost, beiscsi_session_fail); in beiscsi_sess_work()
5440 struct beiscsi_hba *phba; in beiscsi_recover_port() local
5442 phba = container_of(work, struct beiscsi_hba, recover_port.work); in beiscsi_recover_port()
5443 beiscsi_disable_port(phba, 0); in beiscsi_recover_port()
5444 beiscsi_enable_port(phba); in beiscsi_recover_port()
5450 struct beiscsi_hba *phba = NULL; in beiscsi_eeh_err_detected() local
5452 phba = (struct beiscsi_hba *)pci_get_drvdata(pdev); in beiscsi_eeh_err_detected()
5453 set_bit(BEISCSI_HBA_PCI_ERR, &phba->state); in beiscsi_eeh_err_detected()
5455 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_eeh_err_detected()
5459 del_timer_sync(&phba->hw_check); in beiscsi_eeh_err_detected()
5460 cancel_delayed_work_sync(&phba->recover_port); in beiscsi_eeh_err_detected()
5463 iscsi_host_for_each_session(phba->shost, beiscsi_session_fail); in beiscsi_eeh_err_detected()
5464 beiscsi_disable_port(phba, 0); in beiscsi_eeh_err_detected()
5467 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_eeh_err_detected()
5488 struct beiscsi_hba *phba = NULL; in beiscsi_eeh_reset() local
5491 phba = (struct beiscsi_hba *)pci_get_drvdata(pdev); in beiscsi_eeh_reset()
5493 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_eeh_reset()
5504 status = beiscsi_check_fw_rdy(phba); in beiscsi_eeh_reset()
5506 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, in beiscsi_eeh_reset()
5509 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, in beiscsi_eeh_reset()
5519 struct beiscsi_hba *phba; in beiscsi_eeh_resume() local
5522 phba = (struct beiscsi_hba *)pci_get_drvdata(pdev); in beiscsi_eeh_resume()
5525 ret = beiscsi_enable_port(phba); in beiscsi_eeh_resume()
5527 __beiscsi_log(phba, KERN_ERR, in beiscsi_eeh_resume()
5536 struct beiscsi_hba *phba = NULL; in beiscsi_dev_probe() local
5549 phba = beiscsi_hba_alloc(pcidev); in beiscsi_dev_probe()
5550 if (!phba) { in beiscsi_dev_probe()
5560 beiscsi_log(phba, KERN_WARNING, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5567 beiscsi_hba_attrs_init(phba); in beiscsi_dev_probe()
5569 phba->mac_addr_set = false; in beiscsi_dev_probe()
5575 phba->generation = BE_GEN2; in beiscsi_dev_probe()
5576 phba->iotask_fn = beiscsi_iotask; in beiscsi_dev_probe()
5582 phba->generation = BE_GEN3; in beiscsi_dev_probe()
5583 phba->iotask_fn = beiscsi_iotask; in beiscsi_dev_probe()
5586 phba->generation = BE_GEN4; in beiscsi_dev_probe()
5587 phba->iotask_fn = beiscsi_iotask_v2; in beiscsi_dev_probe()
5590 phba->generation = 0; in beiscsi_dev_probe()
5593 ret = be_ctrl_init(phba, pcidev); in beiscsi_dev_probe()
5595 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5600 ret = beiscsi_init_sliport(phba); in beiscsi_dev_probe()
5604 spin_lock_init(&phba->io_sgl_lock); in beiscsi_dev_probe()
5605 spin_lock_init(&phba->mgmt_sgl_lock); in beiscsi_dev_probe()
5606 spin_lock_init(&phba->async_pdu_lock); in beiscsi_dev_probe()
5607 ret = beiscsi_get_fw_config(&phba->ctrl, phba); in beiscsi_dev_probe()
5609 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5613 beiscsi_get_port_name(&phba->ctrl, phba); in beiscsi_dev_probe()
5614 beiscsi_get_params(phba); in beiscsi_dev_probe()
5615 beiscsi_set_host_data(phba); in beiscsi_dev_probe()
5616 beiscsi_set_uer_feature(phba); in beiscsi_dev_probe()
5618 be2iscsi_enable_msix(phba); in beiscsi_dev_probe()
5620 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5622 phba->num_cpus); in beiscsi_dev_probe()
5624 phba->shost->max_id = phba->params.cxns_per_ctrl; in beiscsi_dev_probe()
5625 phba->shost->can_queue = phba->params.ios_per_ctrl; in beiscsi_dev_probe()
5626 ret = beiscsi_get_memory(phba); in beiscsi_dev_probe()
5628 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5633 ret = beiscsi_init_port(phba); in beiscsi_dev_probe()
5635 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5637 beiscsi_free_mem(phba); in beiscsi_dev_probe()
5642 init_waitqueue_head(&phba->ctrl.mcc_wait[i + 1]); in beiscsi_dev_probe()
5643 phba->ctrl.mcc_tag[i] = i + 1; in beiscsi_dev_probe()
5644 phba->ctrl.mcc_tag_status[i + 1] = 0; in beiscsi_dev_probe()
5645 phba->ctrl.mcc_tag_available++; in beiscsi_dev_probe()
5646 memset(&phba->ctrl.ptag_state[i].tag_mem_state, 0, in beiscsi_dev_probe()
5650 phba->ctrl.mcc_alloc_index = phba->ctrl.mcc_free_index = 0; in beiscsi_dev_probe()
5653 phba->shost->host_no); in beiscsi_dev_probe()
5654 phba->wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, wq_name); in beiscsi_dev_probe()
5655 if (!phba->wq) { in beiscsi_dev_probe()
5656 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5663 INIT_DELAYED_WORK(&phba->eqd_update, beiscsi_eqd_update_work); in beiscsi_dev_probe()
5665 phwi_ctrlr = phba->phwi_ctrlr; in beiscsi_dev_probe()
5668 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_dev_probe()
5673 i = (phba->pcidev->msix_enabled) ? i : 0; in beiscsi_dev_probe()
5678 ret = beiscsi_init_irqs(phba); in beiscsi_dev_probe()
5680 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5685 hwi_enable_intr(phba); in beiscsi_dev_probe()
5687 ret = iscsi_host_add(phba->shost, &phba->pcidev->dev); in beiscsi_dev_probe()
5692 set_bit(BEISCSI_HBA_ONLINE, &phba->state); in beiscsi_dev_probe()
5693 __beiscsi_log(phba, KERN_INFO, in beiscsi_dev_probe()
5694 "BM_%d : port online: 0x%lx\n", phba->state); in beiscsi_dev_probe()
5696 INIT_WORK(&phba->boot_work, beiscsi_boot_work); in beiscsi_dev_probe()
5697 ret = beiscsi_boot_get_shandle(phba, &s_handle); in beiscsi_dev_probe()
5699 beiscsi_start_boot_work(phba, s_handle); in beiscsi_dev_probe()
5705 set_bit(BEISCSI_HBA_BOOT_FOUND, &phba->state); in beiscsi_dev_probe()
5708 beiscsi_iface_create_default(phba); in beiscsi_dev_probe()
5709 schedule_delayed_work(&phba->eqd_update, in beiscsi_dev_probe()
5712 INIT_WORK(&phba->sess_work, beiscsi_sess_work); in beiscsi_dev_probe()
5713 INIT_DELAYED_WORK(&phba->recover_port, beiscsi_recover_port); in beiscsi_dev_probe()
5718 timer_setup(&phba->hw_check, beiscsi_hw_health_check, 0); in beiscsi_dev_probe()
5719 mod_timer(&phba->hw_check, in beiscsi_dev_probe()
5721 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT, in beiscsi_dev_probe()
5726 hwi_disable_intr(phba); in beiscsi_dev_probe()
5727 beiscsi_free_irqs(phba); in beiscsi_dev_probe()
5729 for (i = 0; i < phba->num_cpus; i++) { in beiscsi_dev_probe()
5733 destroy_workqueue(phba->wq); in beiscsi_dev_probe()
5735 hwi_cleanup_port(phba); in beiscsi_dev_probe()
5736 beiscsi_cleanup_port(phba); in beiscsi_dev_probe()
5737 beiscsi_free_mem(phba); in beiscsi_dev_probe()
5739 dma_free_coherent(&phba->pcidev->dev, in beiscsi_dev_probe()
5740 phba->ctrl.mbox_mem_alloced.size, in beiscsi_dev_probe()
5741 phba->ctrl.mbox_mem_alloced.va, in beiscsi_dev_probe()
5742 phba->ctrl.mbox_mem_alloced.dma); in beiscsi_dev_probe()
5743 beiscsi_unmap_pci_function(phba); in beiscsi_dev_probe()
5745 pci_disable_msix(phba->pcidev); in beiscsi_dev_probe()
5746 pci_dev_put(phba->pcidev); in beiscsi_dev_probe()
5747 iscsi_host_free(phba->shost); in beiscsi_dev_probe()
5758 struct beiscsi_hba *phba = NULL; in beiscsi_remove() local
5760 phba = pci_get_drvdata(pcidev); in beiscsi_remove()
5761 if (!phba) { in beiscsi_remove()
5767 del_timer_sync(&phba->hw_check); in beiscsi_remove()
5768 cancel_delayed_work_sync(&phba->recover_port); in beiscsi_remove()
5769 cancel_work_sync(&phba->sess_work); in beiscsi_remove()
5771 beiscsi_iface_destroy_default(phba); in beiscsi_remove()
5772 iscsi_host_remove(phba->shost); in beiscsi_remove()
5773 beiscsi_disable_port(phba, 1); in beiscsi_remove()
5776 iscsi_boot_destroy_kset(phba->boot_struct.boot_kset); in beiscsi_remove()
5779 destroy_workqueue(phba->wq); in beiscsi_remove()
5780 beiscsi_free_mem(phba); in beiscsi_remove()
5783 beiscsi_unmap_pci_function(phba); in beiscsi_remove()
5784 dma_free_coherent(&phba->pcidev->dev, in beiscsi_remove()
5785 phba->ctrl.mbox_mem_alloced.size, in beiscsi_remove()
5786 phba->ctrl.mbox_mem_alloced.va, in beiscsi_remove()
5787 phba->ctrl.mbox_mem_alloced.dma); in beiscsi_remove()
5789 pci_dev_put(phba->pcidev); in beiscsi_remove()
5790 iscsi_host_free(phba->shost); in beiscsi_remove()