Lines Matching +full:comp +full:- +full:disable

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
4 * Copyright (c) 2014- QLogic Corporation.
8 * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
47 int bfa_linkup_delay = -1;
59 #define BFAD_FW_FILE_CB "cbfw-3.2.5.1.bin"
60 #define BFAD_FW_FILE_CT "ctfw-3.2.5.1.bin"
61 #define BFAD_FW_FILE_CT2 "ct2fw-3.2.5.1.bin"
126 MODULE_PARM_DESC(msix_disable_cb, "Disable Message Signaled Interrupts for QLogic-415/425/815/825 c…
128 MODULE_PARM_DESC(msix_disable_ct, "Disable Message Signaled Interrupts if possible for QLogic-1010/…
170 bfad->bfad_tsk = kthread_create(bfad_worker, (void *) bfad, in bfad_sm_uninit()
172 if (IS_ERR(bfad->bfad_tsk)) { in bfad_sm_uninit()
174 "creation failed!\n", bfad->inst_no); in bfad_sm_uninit()
204 init_completion(&bfad->comp); in bfad_sm_created()
209 bfad->inst_no); in bfad_sm_created()
214 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_sm_created()
215 bfa_iocfc_init(&bfad->bfa); in bfad_sm_created()
216 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_sm_created()
219 if ((bfad->bfad_flags & BFAD_MSIX_ON) && in bfad_sm_created()
222 __func__, bfad->inst_no); in bfad_sm_created()
227 wait_for_completion(&bfad->comp); in bfad_sm_created()
229 if ((bfad->bfad_flags & BFAD_HAL_INIT_DONE)) { in bfad_sm_created()
234 bfad->pci_name); in bfad_sm_created()
235 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_sm_created()
236 bfa_fcs_init(&bfad->bfa_fcs); in bfad_sm_created()
237 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_sm_created()
241 init_completion(&bfad->comp); in bfad_sm_created()
243 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_sm_created()
244 bfad->pport.flags |= BFAD_PORT_DELETE; in bfad_sm_created()
245 bfa_fcs_exit(&bfad->bfa_fcs); in bfad_sm_created()
246 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_sm_created()
248 wait_for_completion(&bfad->comp); in bfad_sm_created()
253 bfad->bfad_flags |= BFAD_HAL_INIT_FAIL; in bfad_sm_created()
278 kthread_stop(bfad->bfad_tsk); in bfad_sm_initializing()
279 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_sm_initializing()
280 bfad->bfad_tsk = NULL; in bfad_sm_initializing()
281 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_sm_initializing()
293 kthread_stop(bfad->bfad_tsk); in bfad_sm_initializing()
294 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_sm_initializing()
295 bfad->bfad_tsk = NULL; in bfad_sm_initializing()
296 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_sm_initializing()
330 del_timer_sync(&bfad->hal_tmo); in bfad_sm_failed()
379 del_timer_sync(&bfad->hal_tmo); in bfad_sm_stopping()
381 bfad->bfad_flags &= ~BFAD_FC4_PROBE_DONE; in bfad_sm_stopping()
399 fcomp->status = status; in bfad_hcb_comp()
400 complete(&fcomp->comp); in bfad_hcb_comp()
412 bfad->bfad_flags |= BFAD_HAL_INIT_DONE; in bfa_cb_init()
419 if ((bfad->bfad_flags & BFAD_HAL_INIT_FAIL)) { in bfa_cb_init()
420 bfad->bfad_flags &= ~BFAD_HAL_INIT_FAIL; in bfa_cb_init()
421 wake_up_process(bfad->bfad_tsk); in bfa_cb_init()
425 complete(&bfad->comp); in bfa_cb_init()
440 port_drv = &bfad->pport; in bfa_fcb_lport_new()
441 port_drv->pvb_type = BFAD_PORT_PHYS_BASE; in bfa_fcb_lport_new()
443 port_drv = &vf_drv->base_port; in bfa_fcb_lport_new()
444 port_drv->pvb_type = BFAD_PORT_VF_BASE; in bfa_fcb_lport_new()
446 port_drv = &vp_drv->drv_port; in bfa_fcb_lport_new()
447 port_drv->pvb_type = BFAD_PORT_PHYS_VPORT; in bfa_fcb_lport_new()
449 port_drv = &vp_drv->drv_port; in bfa_fcb_lport_new()
450 port_drv->pvb_type = BFAD_PORT_VF_VPORT; in bfa_fcb_lport_new()
453 port_drv->fcs_port = port; in bfa_fcb_lport_new()
454 port_drv->roles = roles; in bfa_fcb_lport_new()
482 *rport = &(*rport_drv)->fcs_rport; in bfa_fcb_rport_alloc()
505 vport->drv_port.bfad = bfad; in bfa_fcb_pbc_vport_create()
511 rc = bfa_fcs_pbc_vport_create(&vport->fcs_vport, &bfad->bfa_fcs, 0, in bfa_fcb_pbc_vport_create()
519 list_add_tail(&vport->list_entry, &bfad->pbc_vport_list); in bfa_fcb_pbc_vport_create()
525 struct bfa_meminfo_s *hal_meminfo = &bfad->meminfo; in bfad_hal_mem_release()
530 dma_info = &hal_meminfo->dma_info; in bfad_hal_mem_release()
531 kva_info = &hal_meminfo->kva_info; in bfad_hal_mem_release()
534 list_for_each(km_qe, &kva_info->qe) { in bfad_hal_mem_release()
536 vfree(kva_elem->kva); in bfad_hal_mem_release()
540 list_for_each(dm_qe, &dma_info->qe) { in bfad_hal_mem_release()
542 dma_free_coherent(&bfad->pcidev->dev, in bfad_hal_mem_release()
543 dma_elem->mem_len, dma_elem->kva, in bfad_hal_mem_release()
544 (dma_addr_t) dma_elem->dma); in bfad_hal_mem_release()
554 bfa_cfg->fwcfg.num_rports = num_rports; in bfad_update_hal_cfg()
556 bfa_cfg->fwcfg.num_ioim_reqs = num_ios; in bfad_update_hal_cfg()
558 bfa_cfg->fwcfg.num_tskim_reqs = num_tms; in bfad_update_hal_cfg()
560 bfa_cfg->fwcfg.num_fcxp_reqs = num_fcxps; in bfad_update_hal_cfg()
562 bfa_cfg->fwcfg.num_uf_bufs = num_ufbufs; in bfad_update_hal_cfg()
564 bfa_cfg->drvcfg.num_reqq_elems = reqq_size; in bfad_update_hal_cfg()
566 bfa_cfg->drvcfg.num_rspq_elems = rspq_size; in bfad_update_hal_cfg()
568 bfa_cfg->drvcfg.num_sgpgs = num_sgpgs; in bfad_update_hal_cfg()
574 num_rports = bfa_cfg->fwcfg.num_rports; in bfad_update_hal_cfg()
575 num_ios = bfa_cfg->fwcfg.num_ioim_reqs; in bfad_update_hal_cfg()
576 num_tms = bfa_cfg->fwcfg.num_tskim_reqs; in bfad_update_hal_cfg()
577 num_fcxps = bfa_cfg->fwcfg.num_fcxp_reqs; in bfad_update_hal_cfg()
578 num_ufbufs = bfa_cfg->fwcfg.num_uf_bufs; in bfad_update_hal_cfg()
579 reqq_size = bfa_cfg->drvcfg.num_reqq_elems; in bfad_update_hal_cfg()
580 rspq_size = bfa_cfg->drvcfg.num_rspq_elems; in bfad_update_hal_cfg()
581 num_sgpgs = bfa_cfg->drvcfg.num_sgpgs; in bfad_update_hal_cfg()
587 struct bfa_meminfo_s *hal_meminfo = &bfad->meminfo; in bfad_hal_mem_alloc()
594 bfa_cfg_get_default(&bfad->ioc_cfg); in bfad_hal_mem_alloc()
595 bfad_update_hal_cfg(&bfad->ioc_cfg); in bfad_hal_mem_alloc()
596 bfad->cfg_data.ioc_queue_depth = bfad->ioc_cfg.fwcfg.num_ioim_reqs; in bfad_hal_mem_alloc()
597 bfa_cfg_get_meminfo(&bfad->ioc_cfg, hal_meminfo, &bfad->bfa); in bfad_hal_mem_alloc()
599 dma_info = &hal_meminfo->dma_info; in bfad_hal_mem_alloc()
600 kva_info = &hal_meminfo->kva_info; in bfad_hal_mem_alloc()
603 list_for_each(km_qe, &kva_info->qe) { in bfad_hal_mem_alloc()
605 kva_elem->kva = vzalloc(kva_elem->mem_len); in bfad_hal_mem_alloc()
606 if (kva_elem->kva == NULL) { in bfad_hal_mem_alloc()
614 list_for_each(dm_qe, &dma_info->qe) { in bfad_hal_mem_alloc()
616 dma_elem->kva = dma_alloc_coherent(&bfad->pcidev->dev, in bfad_hal_mem_alloc()
617 dma_elem->mem_len, in bfad_hal_mem_alloc()
619 if (dma_elem->kva == NULL) { in bfad_hal_mem_alloc()
624 dma_elem->dma = phys_addr; in bfad_hal_mem_alloc()
625 memset(dma_elem->kva, 0, dma_elem->mem_len); in bfad_hal_mem_alloc()
649 vport->drv_port.bfad = bfad; in bfad_vport_create()
650 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_vport_create()
651 rc = bfa_fcs_vport_create(&vport->fcs_vport, &bfad->bfa_fcs, vf_id, in bfad_vport_create()
653 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_vport_create()
658 if (port_cfg->roles & BFA_LPORT_ROLE_FCP_IM) { in bfad_vport_create()
659 rc = bfad_im_scsi_host_alloc(bfad, vport->drv_port.im_port, in bfad_vport_create()
665 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_vport_create()
666 bfa_fcs_vport_start(&vport->fcs_vport); in bfad_vport_create()
667 list_add_tail(&vport->list_entry, &bfad->vport_list); in bfad_vport_create()
668 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_vport_create()
673 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_vport_create()
674 vport->comp_del = &fcomp; in bfad_vport_create()
675 init_completion(vport->comp_del); in bfad_vport_create()
676 bfa_fcs_vport_delete(&vport->fcs_vport); in bfad_vport_create()
677 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_vport_create()
678 wait_for_completion(vport->comp_del); in bfad_vport_create()
692 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_bfa_tmo()
694 bfa_timer_beat(&bfad->bfa.timer_mod); in bfad_bfa_tmo()
696 bfa_comp_deq(&bfad->bfa, &doneq); in bfad_bfa_tmo()
697 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_bfa_tmo()
700 bfa_comp_process(&bfad->bfa, &doneq); in bfad_bfa_tmo()
701 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_bfa_tmo()
702 bfa_comp_free(&bfad->bfa, &doneq); in bfad_bfa_tmo()
703 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_bfa_tmo()
706 mod_timer(&bfad->hal_tmo, in bfad_bfa_tmo()
713 timer_setup(&bfad->hal_tmo, bfad_bfa_tmo, 0); in bfad_init_timer()
715 mod_timer(&bfad->hal_tmo, in bfad_init_timer()
722 int rc = -ENODEV; in bfad_pci_init()
734 rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in bfad_pci_init()
736 rc = -ENODEV; in bfad_pci_init()
741 bfad->pci_bar0_kva = pci_iomap(pdev, 0, pci_resource_len(pdev, 0)); in bfad_pci_init()
742 bfad->pci_bar2_kva = pci_iomap(pdev, 2, pci_resource_len(pdev, 2)); in bfad_pci_init()
744 if (bfad->pci_bar0_kva == NULL) { in bfad_pci_init()
746 rc = -ENODEV; in bfad_pci_init()
750 bfad->hal_pcidev.pci_slot = PCI_SLOT(pdev->devfn); in bfad_pci_init()
751 bfad->hal_pcidev.pci_func = PCI_FUNC(pdev->devfn); in bfad_pci_init()
752 bfad->hal_pcidev.pci_bar_kva = bfad->pci_bar0_kva; in bfad_pci_init()
753 bfad->hal_pcidev.device_id = pdev->device; in bfad_pci_init()
754 bfad->hal_pcidev.ssid = pdev->subsystem_device; in bfad_pci_init()
755 bfad->pci_name = pci_name(pdev); in bfad_pci_init()
757 bfad->pci_attr.vendor_id = pdev->vendor; in bfad_pci_init()
758 bfad->pci_attr.device_id = pdev->device; in bfad_pci_init()
759 bfad->pci_attr.ssid = pdev->subsystem_device; in bfad_pci_init()
760 bfad->pci_attr.ssvid = pdev->subsystem_vendor; in bfad_pci_init()
761 bfad->pci_attr.pcifn = PCI_FUNC(pdev->devfn); in bfad_pci_init()
763 bfad->pcidev = pdev; in bfad_pci_init()
773 "reset to %d\n", bfad->pci_name, max_rq, in bfad_pci_init()
779 bfad->pci_name, pcie_max_read_reqsz); in bfad_pci_init()
798 pci_iounmap(pdev, bfad->pci_bar0_kva); in bfad_pci_uninit()
799 pci_iounmap(pdev, bfad->pci_bar2_kva); in bfad_pci_uninit()
810 bfad->cfg_data.rport_del_timeout = rport_del_timeout; in bfad_drv_init()
811 bfad->cfg_data.lun_queue_depth = bfa_lun_queue_depth; in bfad_drv_init()
812 bfad->cfg_data.io_max_sge = bfa_io_max_sge; in bfad_drv_init()
813 bfad->cfg_data.binding_method = FCP_PWWN_BINDING; in bfad_drv_init()
818 bfad->inst_no); in bfad_drv_init()
820 "Not enough memory to attach all QLogic BR-series HBA ports. System may need more memory.\n"); in bfad_drv_init()
824 bfad->bfa.trcmod = bfad->trcmod; in bfad_drv_init()
825 bfad->bfa.plog = &bfad->plog_buf; in bfad_drv_init()
826 bfa_plog_init(&bfad->plog_buf); in bfad_drv_init()
827 bfa_plog_str(&bfad->plog_buf, BFA_PL_MID_DRVR, BFA_PL_EID_DRIVER_START, in bfad_drv_init()
830 bfa_attach(&bfad->bfa, bfad, &bfad->ioc_cfg, &bfad->meminfo, in bfad_drv_init()
831 &bfad->hal_pcidev); in bfad_drv_init()
834 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_drv_init()
835 bfad->bfa_fcs.trcmod = bfad->trcmod; in bfad_drv_init()
836 bfa_fcs_attach(&bfad->bfa_fcs, &bfad->bfa, bfad, BFA_FALSE); in bfad_drv_init()
837 bfad->bfa_fcs.fdmi_enabled = fdmi_enable; in bfad_drv_init()
838 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_drv_init()
840 bfad->bfad_flags |= BFAD_DRV_INIT_DONE; in bfad_drv_init()
850 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_drv_uninit()
851 init_completion(&bfad->comp); in bfad_drv_uninit()
852 bfa_iocfc_stop(&bfad->bfa); in bfad_drv_uninit()
853 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_drv_uninit()
854 wait_for_completion(&bfad->comp); in bfad_drv_uninit()
856 del_timer_sync(&bfad->hal_tmo); in bfad_drv_uninit()
857 bfa_isr_disable(&bfad->bfa); in bfad_drv_uninit()
858 bfa_detach(&bfad->bfa); in bfad_drv_uninit()
862 bfad->bfad_flags &= ~BFAD_DRV_INIT_DONE; in bfad_drv_uninit()
870 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_drv_start()
871 bfa_iocfc_start(&bfad->bfa); in bfad_drv_start()
872 bfa_fcs_pbc_vport_init(&bfad->bfa_fcs); in bfad_drv_start()
873 bfa_fcs_fabric_modstart(&bfad->bfa_fcs); in bfad_drv_start()
874 bfad->bfad_flags |= BFAD_HAL_START_DONE; in bfad_drv_start()
875 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_drv_start()
877 if (bfad->im) in bfad_drv_start()
878 flush_workqueue(bfad->im->drv_workq); in bfad_drv_start()
886 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_fcs_stop()
887 init_completion(&bfad->comp); in bfad_fcs_stop()
888 bfad->pport.flags |= BFAD_PORT_DELETE; in bfad_fcs_stop()
889 bfa_fcs_exit(&bfad->bfa_fcs); in bfad_fcs_stop()
890 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_fcs_stop()
891 wait_for_completion(&bfad->comp); in bfad_fcs_stop()
901 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_stop()
902 init_completion(&bfad->comp); in bfad_stop()
903 bfa_iocfc_stop(&bfad->bfa); in bfad_stop()
904 bfad->bfad_flags &= ~BFAD_HAL_START_DONE; in bfad_stop()
905 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_stop()
906 wait_for_completion(&bfad->comp); in bfad_stop()
919 if (bfad->pport.im_port == NULL) { in bfad_cfg_pport()
924 rc = bfad_im_scsi_host_alloc(bfad, bfad->pport.im_port, in bfad_cfg_pport()
925 &bfad->pcidev->dev); in bfad_cfg_pport()
929 bfad->pport.roles |= BFA_LPORT_ROLE_FCP_IM; in bfad_cfg_pport()
932 bfad->bfad_flags |= BFAD_CFG_PPORT_DONE; in bfad_cfg_pport()
942 (bfad->pport.roles & BFA_LPORT_ROLE_FCP_IM)) { in bfad_uncfg_pport()
943 bfad_im_scsi_host_free(bfad, bfad->pport.im_port); in bfad_uncfg_pport()
944 bfad_im_port_clean(bfad->pport.im_port); in bfad_uncfg_pport()
945 kfree(bfad->pport.im_port); in bfad_uncfg_pport()
946 bfad->pport.roles &= ~BFA_LPORT_ROLE_FCP_IM; in bfad_uncfg_pport()
949 bfad->bfad_flags &= ~BFAD_CFG_PPORT_DONE; in bfad_uncfg_pport()
960 /* Limit min/max. xfer size to [64k-32MB] */ in bfad_start_ops()
980 strscpy(driver_info.os_device_name, bfad->pci_name, in bfad_start_ops()
984 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_start_ops()
985 bfa_fcs_driver_info_init(&bfad->bfa_fcs, &driver_info); in bfad_start_ops()
987 if (bfad->bfad_flags & BFAD_CFG_PPORT_DONE) in bfad_start_ops()
988 bfa_fcs_update_cfg(&bfad->bfa_fcs); in bfad_start_ops()
990 bfa_fcs_init(&bfad->bfa_fcs); in bfad_start_ops()
992 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_start_ops()
994 if (!(bfad->bfad_flags & BFAD_CFG_PPORT_DONE)) { in bfad_start_ops()
1001 bfad_fc_host_init(bfad->pport.im_port); in bfad_start_ops()
1011 bfad->bfad_flags |= BFAD_FC4_PROBE_DONE; in bfad_start_ops()
1016 list_for_each_entry_safe(vport, vport_new, &bfad->pbc_vport_list, in bfad_start_ops()
1025 vid.disable = false; in bfad_start_ops()
1027 (&((vport->fcs_vport).lport.port_cfg.nwwn))); in bfad_start_ops()
1029 (&((vport->fcs_vport).lport.port_cfg.pwwn))); in bfad_start_ops()
1030 fc_vport = fc_vport_create(bfad->pport.im_port->shost, 0, &vid); in bfad_start_ops()
1034 " %s\n", bfad->inst_no, pwwn_buf); in bfad_start_ops()
1036 list_del(&vport->list_entry); in bfad_start_ops()
1041 * If bfa_linkup_delay is set to -1 default; try to retrive the in bfad_start_ops()
1048 bfa_linkup_delay = -1; in bfad_start_ops()
1069 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_worker()
1070 bfad->bfad_tsk = NULL; in bfad_worker()
1071 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_worker()
1087 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_intx()
1088 rc = bfa_intx(&bfad->bfa); in bfad_intx()
1090 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_intx()
1094 bfa_comp_deq(&bfad->bfa, &doneq); in bfad_intx()
1095 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_intx()
1098 bfa_comp_process(&bfad->bfa, &doneq); in bfad_intx()
1100 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_intx()
1101 bfa_comp_free(&bfad->bfa, &doneq); in bfad_intx()
1102 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_intx()
1113 struct bfad_s *bfad = vec->bfad; in bfad_msix()
1117 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_msix()
1119 bfa_msix(&bfad->bfa, vec->msix.entry); in bfad_msix()
1120 bfa_comp_deq(&bfad->bfa, &doneq); in bfad_msix()
1121 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_msix()
1124 bfa_comp_process(&bfad->bfa, &doneq); in bfad_msix()
1126 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_msix()
1127 bfa_comp_free(&bfad->bfa, &doneq); in bfad_msix()
1128 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_msix()
1144 for (i = 0, bfad->nvec = 0; i < MAX_MSIX_ENTRY; i++) { in bfad_init_msix_entry()
1146 bfad->msix_tab[bfad->nvec].msix.entry = i; in bfad_init_msix_entry()
1147 bfad->msix_tab[bfad->nvec].bfad = bfad; in bfad_init_msix_entry()
1148 msix_entries[bfad->nvec].entry = i; in bfad_init_msix_entry()
1149 bfad->nvec++; in bfad_init_msix_entry()
1162 for (i = 0; i < bfad->nvec; i++) { in bfad_install_msix_handler()
1163 sprintf(bfad->msix_tab[i].name, "bfa-%s-%s", in bfad_install_msix_handler()
1164 bfad->pci_name, in bfad_install_msix_handler()
1165 ((bfa_asic_id_cb(bfad->hal_pcidev.device_id)) ? in bfad_install_msix_handler()
1168 error = request_irq(bfad->msix_tab[i].msix.vector, in bfad_install_msix_handler()
1170 bfad->msix_tab[i].name, &bfad->msix_tab[i]); in bfad_install_msix_handler()
1172 bfa_trc(bfad, bfad->msix_tab[i].msix.vector); in bfad_install_msix_handler()
1177 free_irq(bfad->msix_tab[j].msix.vector, in bfad_install_msix_handler()
1178 &bfad->msix_tab[j]); in bfad_install_msix_handler()
1180 bfad->bfad_flags &= ~BFAD_MSIX_ON; in bfad_install_msix_handler()
1181 pci_disable_msix(bfad->pcidev); in bfad_install_msix_handler()
1199 struct pci_dev *pdev = bfad->pcidev; in bfad_setup_intr()
1203 bfa_msix_getvecs(&bfad->bfa, &mask, &num_bit, &max_bit); in bfad_setup_intr()
1208 if ((bfa_asic_id_ctc(pdev->device) && !msix_disable_ct) || in bfad_setup_intr()
1209 (bfa_asic_id_cb(pdev->device) && !msix_disable_cb)) { in bfad_setup_intr()
1211 error = pci_enable_msix_exact(bfad->pcidev, in bfad_setup_intr()
1212 msix_entries, bfad->nvec); in bfad_setup_intr()
1214 if (error == -ENOSPC && bfa_asic_id_ctc(pdev->device)) { in bfad_setup_intr()
1217 bfad->pci_name, bfad->nvec, error); in bfad_setup_intr()
1218 bfad->nvec = 1; in bfad_setup_intr()
1219 error = pci_enable_msix_exact(bfad->pcidev, in bfad_setup_intr()
1227 bfad->inst_no, error); in bfad_setup_intr()
1231 /* Disable INTX in MSI-X mode */ in bfad_setup_intr()
1239 for (i = 0; i < bfad->nvec; i++) { in bfad_setup_intr()
1241 bfad->msix_tab[i].msix.vector = msix_entries[i].vector; in bfad_setup_intr()
1244 bfa_msix_init(&bfad->bfa, bfad->nvec); in bfad_setup_intr()
1246 bfad->bfad_flags |= BFAD_MSIX_ON; in bfad_setup_intr()
1252 error = request_irq(bfad->pcidev->irq, (irq_handler_t)bfad_intx, in bfad_setup_intr()
1257 bfad->bfad_flags |= BFAD_INTX_ON; in bfad_setup_intr()
1267 if (bfad->bfad_flags & BFAD_MSIX_ON) { in bfad_remove_intr()
1268 for (i = 0; i < bfad->nvec; i++) in bfad_remove_intr()
1269 free_irq(bfad->msix_tab[i].msix.vector, in bfad_remove_intr()
1270 &bfad->msix_tab[i]); in bfad_remove_intr()
1272 pci_disable_msix(bfad->pcidev); in bfad_remove_intr()
1273 bfad->bfad_flags &= ~BFAD_MSIX_ON; in bfad_remove_intr()
1274 } else if (bfad->bfad_flags & BFAD_INTX_ON) { in bfad_remove_intr()
1275 free_irq(bfad->pcidev->irq, bfad); in bfad_remove_intr()
1286 int error = -ENODEV, retval, i; in bfad_pci_probe()
1288 /* For single port cards - only claim function 0 */ in bfad_pci_probe()
1289 if ((pdev->device == BFA_PCI_DEVICE_ID_FC_8G1P) && in bfad_pci_probe()
1290 (PCI_FUNC(pdev->devfn) != 0)) in bfad_pci_probe()
1291 return -ENODEV; in bfad_pci_probe()
1295 error = -ENOMEM; in bfad_pci_probe()
1299 bfad->trcmod = kzalloc(sizeof(struct bfa_trc_mod_s), GFP_KERNEL); in bfad_pci_probe()
1300 if (!bfad->trcmod) { in bfad_pci_probe()
1302 error = -ENOMEM; in bfad_pci_probe()
1307 bfa_trc_init(bfad->trcmod); in bfad_pci_probe()
1311 INIT_LIST_HEAD(&bfad->free_aen_q); in bfad_pci_probe()
1312 INIT_LIST_HEAD(&bfad->active_aen_q); in bfad_pci_probe()
1314 list_add_tail(&bfad->aen_list[i].qe, &bfad->free_aen_q); in bfad_pci_probe()
1317 kfree(bfad->trcmod); in bfad_pci_probe()
1329 bfad->inst_no = bfad_inst++; in bfad_pci_probe()
1330 list_add_tail(&bfad->list_entry, &bfad_list); in bfad_pci_probe()
1336 spin_lock_init(&bfad->bfad_lock); in bfad_pci_probe()
1337 spin_lock_init(&bfad->bfad_aen_spinlock); in bfad_pci_probe()
1341 bfad->ref_count = 0; in bfad_pci_probe()
1342 bfad->pport.bfad = bfad; in bfad_pci_probe()
1343 INIT_LIST_HEAD(&bfad->pbc_vport_list); in bfad_pci_probe()
1344 INIT_LIST_HEAD(&bfad->vport_list); in bfad_pci_probe()
1348 bfad_debugfs_init(&bfad->pport); in bfad_pci_probe()
1365 kfree(bfad->regdata); in bfad_pci_probe()
1366 bfad_debugfs_exit(&bfad->pport); in bfad_pci_probe()
1368 bfad_inst--; in bfad_pci_probe()
1369 list_del(&bfad->list_entry); in bfad_pci_probe()
1373 kfree(bfad->trcmod); in bfad_pci_probe()
1389 bfa_trc(bfad, bfad->inst_no); in bfad_pci_remove()
1391 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_pci_remove()
1392 if (bfad->bfad_tsk != NULL) { in bfad_pci_remove()
1393 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_pci_remove()
1394 kthread_stop(bfad->bfad_tsk); in bfad_pci_remove()
1396 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_pci_remove()
1403 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_pci_remove()
1404 bfa_detach(&bfad->bfa); in bfad_pci_remove()
1405 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_pci_remove()
1409 kfree(bfad->regdata); in bfad_pci_remove()
1410 bfad_debugfs_exit(&bfad->pport); in bfad_pci_remove()
1414 bfad_inst--; in bfad_pci_remove()
1415 list_del(&bfad->list_entry); in bfad_pci_remove()
1419 kfree(bfad->trcmod); in bfad_pci_remove()
1433 dev_printk(KERN_ERR, &pdev->dev, in bfad_pci_error_detected()
1434 "error detected state: %d - flags: 0x%x\n", in bfad_pci_error_detected()
1435 state, bfad->bfad_flags); in bfad_pci_error_detected()
1438 case pci_channel_io_normal: /* non-fatal error */ in bfad_pci_error_detected()
1439 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_pci_error_detected()
1440 bfad->bfad_flags &= ~BFAD_EEH_BUSY; in bfad_pci_error_detected()
1442 bfa_ioc_suspend(&bfad->bfa.ioc); in bfad_pci_error_detected()
1443 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_pci_error_detected()
1444 del_timer_sync(&bfad->hal_tmo); in bfad_pci_error_detected()
1448 init_completion(&bfad->comp); in bfad_pci_error_detected()
1449 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_pci_error_detected()
1450 bfad->bfad_flags |= BFAD_EEH_BUSY; in bfad_pci_error_detected()
1452 bfa_ioc_suspend(&bfad->bfa.ioc); in bfad_pci_error_detected()
1453 bfa_fcs_stop(&bfad->bfa_fcs); in bfad_pci_error_detected()
1454 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_pci_error_detected()
1455 wait_for_completion(&bfad->comp); in bfad_pci_error_detected()
1458 del_timer_sync(&bfad->hal_tmo); in bfad_pci_error_detected()
1463 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_pci_error_detected()
1464 bfad->bfad_flags |= BFAD_EEH_BUSY | in bfad_pci_error_detected()
1466 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_pci_error_detected()
1469 * pci_channel_io_perm_failure - it will subsequently call in bfad_pci_error_detected()
1471 * system - So defer the cleanup to pci_remove(); cleaning up in bfad_pci_error_detected()
1486 struct pci_dev *pdev = bfad->pcidev; in restart_bfa()
1488 bfa_attach(&bfad->bfa, bfad, &bfad->ioc_cfg, in restart_bfa()
1489 &bfad->meminfo, &bfad->hal_pcidev); in restart_bfa()
1493 dev_printk(KERN_WARNING, &pdev->dev, in restart_bfa()
1494 "%s: bfad_setup_intr failed\n", bfad->pci_name); in restart_bfa()
1496 return -1; in restart_bfa()
1499 init_completion(&bfad->comp); in restart_bfa()
1500 spin_lock_irqsave(&bfad->bfad_lock, flags); in restart_bfa()
1501 bfa_iocfc_init(&bfad->bfa); in restart_bfa()
1502 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in restart_bfa()
1505 if ((bfad->bfad_flags & BFAD_MSIX_ON) && in restart_bfa()
1507 dev_printk(KERN_WARNING, &pdev->dev, in restart_bfa()
1508 "%s: install_msix failed.\n", bfad->pci_name); in restart_bfa()
1511 wait_for_completion(&bfad->comp); in restart_bfa()
1518 * PCI Error Recovery entry, re-initialize the chip.
1527 dev_printk(KERN_ERR, &pdev->dev, in bfad_pci_slot_reset()
1528 "bfad_pci_slot_reset flags: 0x%x\n", bfad->bfad_flags); in bfad_pci_slot_reset()
1531 dev_printk(KERN_ERR, &pdev->dev, "Cannot re-enable " in bfad_pci_slot_reset()
1540 * be 0xff any time) to make sure - we did not hit another PCI error in bfad_pci_slot_reset()
1545 dev_printk(KERN_ERR, &pdev->dev, in bfad_pci_slot_reset()
1553 rc = dma_set_mask_and_coherent(&bfad->pcidev->dev, DMA_BIT_MASK(64)); in bfad_pci_slot_reset()
1557 if (restart_bfa(bfad) == -1) in bfad_pci_slot_reset()
1560 dev_printk(KERN_WARNING, &pdev->dev, in bfad_pci_slot_reset()
1561 "slot_reset completed flags: 0x%x!\n", bfad->bfad_flags); in bfad_pci_slot_reset()
1576 dev_printk(KERN_INFO, &pdev->dev, "mmio_enabled\n"); in bfad_pci_mmio_enabled()
1579 bfa_ioc_debug_save_ftrc(&bfad->bfa.ioc); in bfad_pci_mmio_enabled()
1582 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_pci_mmio_enabled()
1583 init_completion(&bfad->comp); in bfad_pci_mmio_enabled()
1584 bfa_fcs_stop(&bfad->bfa_fcs); in bfad_pci_mmio_enabled()
1585 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_pci_mmio_enabled()
1586 wait_for_completion(&bfad->comp); in bfad_pci_mmio_enabled()
1589 del_timer_sync(&bfad->hal_tmo); in bfad_pci_mmio_enabled()
1601 dev_printk(KERN_WARNING, &pdev->dev, "resume\n"); in bfad_pci_resume()
1606 spin_lock_irqsave(&bfad->bfad_lock, flags); in bfad_pci_resume()
1607 bfad->bfad_flags &= ~BFAD_EEH_BUSY; in bfad_pci_resume()
1608 spin_unlock_irqrestore(&bfad->bfad_lock, flags); in bfad_pci_resume()
1688 pr_info("QLogic BR-series BFA FC/FCOE SCSI driver - version: %s\n", in bfad_init()
1696 error = -ENOMEM; in bfad_init()
1739 if (request_firmware(&fw, fw_name, &pdev->dev)) { in bfad_read_firmware()
1745 *bfi_image = vmalloc(fw->size); in bfad_read_firmware()
1748 "size=%x!\n", (u32) fw->size); in bfad_read_firmware()
1752 memcpy(*bfi_image, fw->data, fw->size); in bfad_read_firmware()
1753 *bfi_image_size = fw->size/sizeof(u32); in bfad_read_firmware()
1761 if (bfa_asic_id_ct2(pdev->device)) { in bfad_load_fwimg()
1766 } else if (bfa_asic_id_ct(pdev->device)) { in bfad_load_fwimg()
1771 } else if (bfa_asic_id_cb(pdev->device)) { in bfad_load_fwimg()
1795 MODULE_DESCRIPTION("QLogic BR-series Fibre Channel HBA Driver" BFAD_PROTO_NAME);