• Home
  • Raw
  • Download

Lines Matching +full:cpu +full:- +full:centric

4  * Copyright (C) 2017-2020 Broadcom. All Rights Reserved. The term *
6 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
9 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
17 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
26 #include <linux/dma-mapping.h>
43 #include <linux/cpu.h>
69 /* Used when mapping IRQ vectors in a driver centric manner */
103 * lpfc_config_port_prep - Perform lpfc initialization prior to config port
112 * 0 - success.
113 * -ERESTART - requests the SLI layer to reset the HBA and try again.
114 * Any other value - indicates an error.
119 lpfc_vpd_t *vp = &phba->vpd; in lpfc_config_port_prep()
129 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_prep()
131 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_prep()
132 return -ENOMEM; in lpfc_config_port_prep()
135 mb = &pmb->u.mb; in lpfc_config_port_prep()
136 phba->link_state = LPFC_INIT_MBX_CMDS; in lpfc_config_port_prep()
138 if (lpfc_is_LC_HBA(phba->pcidev->device)) { in lpfc_config_port_prep()
148 memset((char*)mb->un.varRDnvp.rsvd3, 0, in lpfc_config_port_prep()
149 sizeof (mb->un.varRDnvp.rsvd3)); in lpfc_config_port_prep()
150 memcpy((char*)mb->un.varRDnvp.rsvd3, licensed, in lpfc_config_port_prep()
160 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_prep()
161 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
162 return -ERESTART; in lpfc_config_port_prep()
164 memcpy(phba->wwnn, (char *)mb->un.varRDnvp.nodename, in lpfc_config_port_prep()
165 sizeof(phba->wwnn)); in lpfc_config_port_prep()
166 memcpy(phba->wwpn, (char *)mb->un.varRDnvp.portname, in lpfc_config_port_prep()
167 sizeof(phba->wwpn)); in lpfc_config_port_prep()
174 phba->sli3_options &= (uint32_t)LPFC_SLI3_BG_ENABLED; in lpfc_config_port_prep()
183 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_prep()
184 mempool_free( pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
185 return -ERESTART; in lpfc_config_port_prep()
193 if (mb->un.varRdRev.rr == 0) { in lpfc_config_port_prep()
194 vp->rev.rBit = 0; in lpfc_config_port_prep()
198 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
199 return -ERESTART; in lpfc_config_port_prep()
202 if (phba->sli_rev == 3 && !mb->un.varRdRev.v3rsp) { in lpfc_config_port_prep()
203 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
204 return -EINVAL; in lpfc_config_port_prep()
208 vp->rev.rBit = 1; in lpfc_config_port_prep()
209 memcpy(&vp->sli3Feat, &mb->un.varRdRev.sli3Feat, sizeof(uint32_t)); in lpfc_config_port_prep()
210 vp->rev.sli1FwRev = mb->un.varRdRev.sli1FwRev; in lpfc_config_port_prep()
211 memcpy(vp->rev.sli1FwName, (char*) mb->un.varRdRev.sli1FwName, 16); in lpfc_config_port_prep()
212 vp->rev.sli2FwRev = mb->un.varRdRev.sli2FwRev; in lpfc_config_port_prep()
213 memcpy(vp->rev.sli2FwName, (char *) mb->un.varRdRev.sli2FwName, 16); in lpfc_config_port_prep()
214 vp->rev.biuRev = mb->un.varRdRev.biuRev; in lpfc_config_port_prep()
215 vp->rev.smRev = mb->un.varRdRev.smRev; in lpfc_config_port_prep()
216 vp->rev.smFwRev = mb->un.varRdRev.un.smFwRev; in lpfc_config_port_prep()
217 vp->rev.endecRev = mb->un.varRdRev.endecRev; in lpfc_config_port_prep()
218 vp->rev.fcphHigh = mb->un.varRdRev.fcphHigh; in lpfc_config_port_prep()
219 vp->rev.fcphLow = mb->un.varRdRev.fcphLow; in lpfc_config_port_prep()
220 vp->rev.feaLevelHigh = mb->un.varRdRev.feaLevelHigh; in lpfc_config_port_prep()
221 vp->rev.feaLevelLow = mb->un.varRdRev.feaLevelLow; in lpfc_config_port_prep()
222 vp->rev.postKernRev = mb->un.varRdRev.postKernRev; in lpfc_config_port_prep()
223 vp->rev.opFwRev = mb->un.varRdRev.opFwRev; in lpfc_config_port_prep()
229 if (vp->rev.feaLevelHigh < 9) in lpfc_config_port_prep()
230 phba->sli3_options |= LPFC_SLI3_VPORT_TEARDOWN; in lpfc_config_port_prep()
232 if (lpfc_is_LC_HBA(phba->pcidev->device)) in lpfc_config_port_prep()
233 memcpy(phba->RandomData, (char *)&mb->un.varWords[24], in lpfc_config_port_prep()
234 sizeof (phba->RandomData)); in lpfc_config_port_prep()
248 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_prep()
249 mb->un.varDmp.word_cnt = 0; in lpfc_config_port_prep()
254 if (mb->un.varDmp.word_cnt == 0) in lpfc_config_port_prep()
257 i = mb->un.varDmp.word_cnt * sizeof(uint32_t); in lpfc_config_port_prep()
259 i = DMP_VPD_SIZE - offset; in lpfc_config_port_prep()
269 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
274 * lpfc_config_async_cmpl - Completion handler for config async event mbox cmd
286 if (pmboxq->u.mb.mbxStatus == MBX_SUCCESS) in lpfc_config_async_cmpl()
287 phba->temp_sensor_support = 1; in lpfc_config_async_cmpl()
289 phba->temp_sensor_support = 0; in lpfc_config_async_cmpl()
290 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_config_async_cmpl()
295 * lpfc_dump_wakeup_param_cmpl - dump memory mailbox command completion handler
313 if (pmboxq->u.mb.mbxStatus != MBX_SUCCESS) { in lpfc_dump_wakeup_param_cmpl()
314 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_dump_wakeup_param_cmpl()
321 prog_id_word = pmboxq->u.mb.un.varWords[7]; in lpfc_dump_wakeup_param_cmpl()
324 if (prg->dist < 4) in lpfc_dump_wakeup_param_cmpl()
325 dist = dist_char[prg->dist]; in lpfc_dump_wakeup_param_cmpl()
327 if ((prg->dist == 3) && (prg->num == 0)) in lpfc_dump_wakeup_param_cmpl()
328 snprintf(phba->OptionROMVersion, 32, "%d.%d%d", in lpfc_dump_wakeup_param_cmpl()
329 prg->ver, prg->rev, prg->lev); in lpfc_dump_wakeup_param_cmpl()
331 snprintf(phba->OptionROMVersion, 32, "%d.%d%d%c%d", in lpfc_dump_wakeup_param_cmpl()
332 prg->ver, prg->rev, prg->lev, in lpfc_dump_wakeup_param_cmpl()
333 dist, prg->num); in lpfc_dump_wakeup_param_cmpl()
334 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_dump_wakeup_param_cmpl()
339 * lpfc_update_vport_wwn - Updates the fc_nodename, fc_portname,
350 uint8_t vvvl = vport->fc_sparam.cmn.valid_vendor_ver_level; in lpfc_update_vport_wwn()
351 u32 *fawwpn_key = (u32 *)&vport->fc_sparam.un.vendorVersion[0]; in lpfc_update_vport_wwn()
354 if (vport->phba->cfg_soft_wwnn) in lpfc_update_vport_wwn()
355 u64_to_wwn(vport->phba->cfg_soft_wwnn, in lpfc_update_vport_wwn()
356 vport->fc_sparam.nodeName.u.wwn); in lpfc_update_vport_wwn()
357 if (vport->phba->cfg_soft_wwpn) in lpfc_update_vport_wwn()
358 u64_to_wwn(vport->phba->cfg_soft_wwpn, in lpfc_update_vport_wwn()
359 vport->fc_sparam.portName.u.wwn); in lpfc_update_vport_wwn()
365 if (vport->fc_nodename.u.wwn[0] == 0 || vport->phba->cfg_soft_wwnn) in lpfc_update_vport_wwn()
366 memcpy(&vport->fc_nodename, &vport->fc_sparam.nodeName, in lpfc_update_vport_wwn()
369 memcpy(&vport->fc_sparam.nodeName, &vport->fc_nodename, in lpfc_update_vport_wwn()
376 if (vport->fc_portname.u.wwn[0] != 0 && in lpfc_update_vport_wwn()
377 memcmp(&vport->fc_portname, &vport->fc_sparam.portName, in lpfc_update_vport_wwn()
379 vport->vport_flag |= FAWWPN_PARAM_CHG; in lpfc_update_vport_wwn()
381 if (vport->fc_portname.u.wwn[0] == 0 || in lpfc_update_vport_wwn()
382 vport->phba->cfg_soft_wwpn || in lpfc_update_vport_wwn()
384 vport->vport_flag & FAWWPN_SET) { in lpfc_update_vport_wwn()
385 memcpy(&vport->fc_portname, &vport->fc_sparam.portName, in lpfc_update_vport_wwn()
387 vport->vport_flag &= ~FAWWPN_SET; in lpfc_update_vport_wwn()
389 vport->vport_flag |= FAWWPN_SET; in lpfc_update_vport_wwn()
392 memcpy(&vport->fc_sparam.portName, &vport->fc_portname, in lpfc_update_vport_wwn()
397 * lpfc_config_port_post - Perform lpfc initialization after config port
406 * 0 - success.
407 * Any other value - error.
412 struct lpfc_vport *vport = phba->pport; in lpfc_config_port_post()
417 struct lpfc_sli *psli = &phba->sli; in lpfc_config_port_post()
422 spin_lock_irq(&phba->hbalock); in lpfc_config_port_post()
427 if (phba->over_temp_state == HBA_OVER_TEMP) in lpfc_config_port_post()
428 phba->over_temp_state = HBA_NORMAL_TEMP; in lpfc_config_port_post()
429 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
431 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
433 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
434 return -ENOMEM; in lpfc_config_port_post()
436 mb = &pmb->u.mb; in lpfc_config_port_post()
441 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
442 return -ENOMEM; in lpfc_config_port_post()
445 pmb->vport = vport; in lpfc_config_port_post()
450 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_post()
451 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
452 mp = (struct lpfc_dmabuf *)pmb->ctx_buf; in lpfc_config_port_post()
453 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
454 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_config_port_post()
456 return -EIO; in lpfc_config_port_post()
459 mp = (struct lpfc_dmabuf *)pmb->ctx_buf; in lpfc_config_port_post()
461 memcpy(&vport->fc_sparam, mp->virt, sizeof (struct serv_parm)); in lpfc_config_port_post()
462 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_config_port_post()
464 pmb->ctx_buf = NULL; in lpfc_config_port_post()
468 fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); in lpfc_config_port_post()
469 fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); in lpfc_config_port_post()
470 fc_host_max_npiv_vports(shost) = phba->max_vpi; in lpfc_config_port_post()
473 /* This should be consolidated into parse_vpd ? - mr */ in lpfc_config_port_post()
474 if (phba->SerialNumber[0] == 0) { in lpfc_config_port_post()
477 outptr = &vport->fc_nodename.u.s.IEEE[0]; in lpfc_config_port_post()
482 phba->SerialNumber[i] = in lpfc_config_port_post()
485 phba->SerialNumber[i] = in lpfc_config_port_post()
486 (char)((uint8_t) 0x61 + (uint8_t) (j - 10)); in lpfc_config_port_post()
490 phba->SerialNumber[i] = in lpfc_config_port_post()
493 phba->SerialNumber[i] = in lpfc_config_port_post()
494 (char)((uint8_t) 0x61 + (uint8_t) (j - 10)); in lpfc_config_port_post()
499 pmb->vport = vport; in lpfc_config_port_post()
504 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_post()
505 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
506 mempool_free( pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
507 return -EIO; in lpfc_config_port_post()
514 if (phba->cfg_hba_queue_depth > mb->un.varRdConfig.max_xri) { in lpfc_config_port_post()
517 phba->cfg_hba_queue_depth, in lpfc_config_port_post()
518 mb->un.varRdConfig.max_xri); in lpfc_config_port_post()
519 phba->cfg_hba_queue_depth = mb->un.varRdConfig.max_xri; in lpfc_config_port_post()
522 phba->lmt = mb->un.varRdConfig.lmt; in lpfc_config_port_post()
525 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_config_port_post()
527 phba->link_state = LPFC_LINK_DOWN; in lpfc_config_port_post()
530 if (psli->sli3_ring[LPFC_EXTRA_RING].sli.sli3.cmdringaddr) in lpfc_config_port_post()
531 psli->sli3_ring[LPFC_EXTRA_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_config_port_post()
532 if (psli->sli3_ring[LPFC_FCP_RING].sli.sli3.cmdringaddr) in lpfc_config_port_post()
533 psli->sli3_ring[LPFC_FCP_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_config_port_post()
536 if (phba->sli_rev != 3) in lpfc_config_port_post()
540 * Configure HBA MSI-X attention conditions to messages if MSI-X mode in lpfc_config_port_post()
542 if (phba->intr_type == MSIX) { in lpfc_config_port_post()
545 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
546 return -EIO; in lpfc_config_port_post()
553 pmb->u.mb.mbxCommand, in lpfc_config_port_post()
554 pmb->u.mb.mbxStatus); in lpfc_config_port_post()
555 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
556 return -EIO; in lpfc_config_port_post()
560 spin_lock_irq(&phba->hbalock); in lpfc_config_port_post()
562 phba->hba_flag &= ~HBA_ERATT_HANDLED; in lpfc_config_port_post()
565 if (lpfc_readl(phba->HCregaddr, &status)) { in lpfc_config_port_post()
566 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
567 return -EIO; in lpfc_config_port_post()
570 if (psli->num_rings > 0) in lpfc_config_port_post()
572 if (psli->num_rings > 1) in lpfc_config_port_post()
574 if (psli->num_rings > 2) in lpfc_config_port_post()
576 if (psli->num_rings > 3) in lpfc_config_port_post()
579 if ((phba->cfg_poll & ENABLE_FCP_RING_POLLING) && in lpfc_config_port_post()
580 (phba->cfg_poll & DISABLE_FCP_RING_INT)) in lpfc_config_port_post()
583 writel(status, phba->HCregaddr); in lpfc_config_port_post()
584 readl(phba->HCregaddr); /* flush */ in lpfc_config_port_post()
585 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
587 /* Set up ring-0 (ELS) timer */ in lpfc_config_port_post()
588 timeout = phba->fc_ratov * 2; in lpfc_config_port_post()
589 mod_timer(&vport->els_tmofunc, in lpfc_config_port_post()
592 mod_timer(&phba->hb_tmofunc, in lpfc_config_port_post()
594 phba->hb_outstanding = 0; in lpfc_config_port_post()
595 phba->last_completion_time = jiffies; in lpfc_config_port_post()
597 mod_timer(&phba->eratt_poll, in lpfc_config_port_post()
598 jiffies + msecs_to_jiffies(1000 * phba->eratt_poll_interval)); in lpfc_config_port_post()
600 if (phba->hba_flag & LINK_DISABLED) { in lpfc_config_port_post()
604 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_config_port_post()
611 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
612 return -EIO; in lpfc_config_port_post()
614 } else if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) { in lpfc_config_port_post()
615 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
616 rc = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); in lpfc_config_port_post()
621 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
623 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
624 return -ENOMEM; in lpfc_config_port_post()
628 pmb->mbox_cmpl = lpfc_config_async_cmpl; in lpfc_config_port_post()
629 pmb->vport = phba->pport; in lpfc_config_port_post()
637 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
641 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
643 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
644 return -ENOMEM; in lpfc_config_port_post()
648 pmb->mbox_cmpl = lpfc_dump_wakeup_param_cmpl; in lpfc_config_port_post()
649 pmb->vport = phba->pport; in lpfc_config_port_post()
656 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
663 * lpfc_hba_init_link - Initialize the FC link
665 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
673 * 0 - success
674 * Any other value - error
679 return lpfc_hba_init_link_fc_topology(phba, phba->cfg_topology, flag); in lpfc_hba_init_link()
683 * lpfc_hba_init_link_fc_topology - Initialize FC link with desired topology
686 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
694 * 0 - success
695 * Any other value - error
701 struct lpfc_vport *vport = phba->pport; in lpfc_hba_init_link_fc_topology()
706 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_hba_init_link_fc_topology()
708 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_init_link_fc_topology()
709 return -ENOMEM; in lpfc_hba_init_link_fc_topology()
711 mb = &pmb->u.mb; in lpfc_hba_init_link_fc_topology()
712 pmb->vport = vport; in lpfc_hba_init_link_fc_topology()
714 if ((phba->cfg_link_speed > LPFC_USER_LINK_SPEED_MAX) || in lpfc_hba_init_link_fc_topology()
715 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_1G) && in lpfc_hba_init_link_fc_topology()
716 !(phba->lmt & LMT_1Gb)) || in lpfc_hba_init_link_fc_topology()
717 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_2G) && in lpfc_hba_init_link_fc_topology()
718 !(phba->lmt & LMT_2Gb)) || in lpfc_hba_init_link_fc_topology()
719 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_4G) && in lpfc_hba_init_link_fc_topology()
720 !(phba->lmt & LMT_4Gb)) || in lpfc_hba_init_link_fc_topology()
721 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_8G) && in lpfc_hba_init_link_fc_topology()
722 !(phba->lmt & LMT_8Gb)) || in lpfc_hba_init_link_fc_topology()
723 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_10G) && in lpfc_hba_init_link_fc_topology()
724 !(phba->lmt & LMT_10Gb)) || in lpfc_hba_init_link_fc_topology()
725 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G) && in lpfc_hba_init_link_fc_topology()
726 !(phba->lmt & LMT_16Gb)) || in lpfc_hba_init_link_fc_topology()
727 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_32G) && in lpfc_hba_init_link_fc_topology()
728 !(phba->lmt & LMT_32Gb)) || in lpfc_hba_init_link_fc_topology()
729 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_64G) && in lpfc_hba_init_link_fc_topology()
730 !(phba->lmt & LMT_64Gb))) { in lpfc_hba_init_link_fc_topology()
735 phba->cfg_link_speed); in lpfc_hba_init_link_fc_topology()
736 phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; in lpfc_hba_init_link_fc_topology()
738 lpfc_init_link(phba, pmb, fc_topology, phba->cfg_link_speed); in lpfc_hba_init_link_fc_topology()
739 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_hba_init_link_fc_topology()
740 if (phba->sli_rev < LPFC_SLI_REV4) in lpfc_hba_init_link_fc_topology()
747 mb->mbxCommand, mb->mbxStatus); in lpfc_hba_init_link_fc_topology()
748 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_hba_init_link_fc_topology()
750 writel(0, phba->HCregaddr); in lpfc_hba_init_link_fc_topology()
751 readl(phba->HCregaddr); /* flush */ in lpfc_hba_init_link_fc_topology()
753 writel(0xffffffff, phba->HAregaddr); in lpfc_hba_init_link_fc_topology()
754 readl(phba->HAregaddr); /* flush */ in lpfc_hba_init_link_fc_topology()
756 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_init_link_fc_topology()
758 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_init_link_fc_topology()
759 return -EIO; in lpfc_hba_init_link_fc_topology()
761 phba->cfg_suppress_link_up = LPFC_INITIALIZE_LINK; in lpfc_hba_init_link_fc_topology()
763 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_init_link_fc_topology()
769 * lpfc_hba_down_link - this routine downs the FC link
771 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
778 * 0 - success
779 * Any other value - error
787 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_hba_down_link()
789 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_down_link()
790 return -ENOMEM; in lpfc_hba_down_link()
796 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_hba_down_link()
803 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_down_link()
804 return -EIO; in lpfc_hba_down_link()
807 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_down_link()
813 * lpfc_hba_down_prep - Perform lpfc uninitialization prior to HBA reset
820 * 0 - success.
821 * Any other value - error.
829 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_hba_down_prep()
831 writel(0, phba->HCregaddr); in lpfc_hba_down_prep()
832 readl(phba->HCregaddr); /* flush */ in lpfc_hba_down_prep()
835 if (phba->pport->load_flag & FC_UNLOADING) in lpfc_hba_down_prep()
836 lpfc_cleanup_discovery_resources(phba->pport); in lpfc_hba_down_prep()
840 for (i = 0; i <= phba->max_vports && in lpfc_hba_down_prep()
849 * lpfc_sli4_free_sp_events - Cleanup sp_queue_events to free
868 spin_lock_irq(&phba->hbalock); in lpfc_sli4_free_sp_events()
869 phba->hba_flag &= ~HBA_SP_QUEUE_EVT; in lpfc_sli4_free_sp_events()
870 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_free_sp_events()
872 while (!list_empty(&phba->sli4_hba.sp_queue_event)) { in lpfc_sli4_free_sp_events()
874 spin_lock_irq(&phba->hbalock); in lpfc_sli4_free_sp_events()
875 list_remove_head(&phba->sli4_hba.sp_queue_event, in lpfc_sli4_free_sp_events()
877 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_free_sp_events()
879 switch (bf_get(lpfc_wcqe_c_code, &cq_event->cqe.wcqe_cmpl)) { in lpfc_sli4_free_sp_events()
889 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_free_sp_events()
895 * lpfc_hba_free_post_buf - Perform lpfc uninitialization after HBA reset
908 struct lpfc_sli *psli = &phba->sli; in lpfc_hba_free_post_buf()
914 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) in lpfc_hba_free_post_buf()
918 pring = &psli->sli3_ring[LPFC_ELS_RING]; in lpfc_hba_free_post_buf()
919 spin_lock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
920 list_splice_init(&pring->postbufq, &buflist); in lpfc_hba_free_post_buf()
921 spin_unlock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
925 list_del(&mp->list); in lpfc_hba_free_post_buf()
927 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_hba_free_post_buf()
931 spin_lock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
932 pring->postbufq_cnt -= count; in lpfc_hba_free_post_buf()
933 spin_unlock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
938 * lpfc_hba_clean_txcmplq - Perform lpfc uninitialization after HBA reset
950 struct lpfc_sli *psli = &phba->sli; in lpfc_hba_clean_txcmplq()
957 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_hba_clean_txcmplq()
958 for (i = 0; i < psli->num_rings; i++) { in lpfc_hba_clean_txcmplq()
959 pring = &psli->sli3_ring[i]; in lpfc_hba_clean_txcmplq()
960 spin_lock_irq(&phba->hbalock); in lpfc_hba_clean_txcmplq()
965 list_splice_init(&pring->txcmplq, &completions); in lpfc_hba_clean_txcmplq()
966 pring->txcmplq_cnt = 0; in lpfc_hba_clean_txcmplq()
967 spin_unlock_irq(&phba->hbalock); in lpfc_hba_clean_txcmplq()
976 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_hba_clean_txcmplq()
977 pring = qp->pring; in lpfc_hba_clean_txcmplq()
980 spin_lock_irq(&pring->ring_lock); in lpfc_hba_clean_txcmplq()
982 &pring->txcmplq, list) in lpfc_hba_clean_txcmplq()
983 piocb->iocb_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_hba_clean_txcmplq()
984 list_splice_init(&pring->txcmplq, &completions); in lpfc_hba_clean_txcmplq()
985 pring->txcmplq_cnt = 0; in lpfc_hba_clean_txcmplq()
986 spin_unlock_irq(&pring->ring_lock); in lpfc_hba_clean_txcmplq()
995 * lpfc_hba_down_post_s3 - Perform lpfc uninitialization after HBA reset
1002 * 0 - success.
1003 * Any other value - error.
1014 * lpfc_hba_down_post_s4 - Perform lpfc uninitialization after HBA reset
1021 * 0 - success.
1022 * Any other value - error.
1046 spin_lock_irq(&phba->hbalock); /* required for lpfc_els_sgl_list and */ in lpfc_hba_down_post_s4()
1051 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_hba_down_post_s4()
1053 &phba->sli4_hba.lpfc_abts_els_sgl_list, list) in lpfc_hba_down_post_s4()
1054 sglq_entry->state = SGL_FREED; in lpfc_hba_down_post_s4()
1056 list_splice_init(&phba->sli4_hba.lpfc_abts_els_sgl_list, in lpfc_hba_down_post_s4()
1057 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_hba_down_post_s4()
1060 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_hba_down_post_s4()
1066 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_hba_down_post_s4()
1067 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_hba_down_post_s4()
1069 spin_lock(&qp->abts_io_buf_list_lock); in lpfc_hba_down_post_s4()
1070 list_splice_init(&qp->lpfc_abts_io_buf_list, in lpfc_hba_down_post_s4()
1074 psb->pCmd = NULL; in lpfc_hba_down_post_s4()
1075 psb->status = IOSTAT_SUCCESS; in lpfc_hba_down_post_s4()
1078 spin_lock(&qp->io_buf_list_put_lock); in lpfc_hba_down_post_s4()
1079 list_splice_init(&aborts, &qp->lpfc_io_buf_list_put); in lpfc_hba_down_post_s4()
1080 qp->put_io_bufs += qp->abts_scsi_io_bufs; in lpfc_hba_down_post_s4()
1081 qp->put_io_bufs += qp->abts_nvme_io_bufs; in lpfc_hba_down_post_s4()
1082 qp->abts_scsi_io_bufs = 0; in lpfc_hba_down_post_s4()
1083 qp->abts_nvme_io_bufs = 0; in lpfc_hba_down_post_s4()
1084 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_hba_down_post_s4()
1085 spin_unlock(&qp->abts_io_buf_list_lock); in lpfc_hba_down_post_s4()
1087 spin_unlock_irq(&phba->hbalock); in lpfc_hba_down_post_s4()
1089 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_hba_down_post_s4()
1090 spin_lock_irq(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_hba_down_post_s4()
1091 list_splice_init(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list, in lpfc_hba_down_post_s4()
1093 spin_unlock_irq(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_hba_down_post_s4()
1095 ctxp->flag &= ~(LPFC_NVME_XBUSY | LPFC_NVME_ABORT_OP); in lpfc_hba_down_post_s4()
1096 lpfc_nvmet_ctxbuf_post(phba, ctxp->ctxbuf); in lpfc_hba_down_post_s4()
1105 * lpfc_hba_down_post - Wrapper func for hba down post routine
1112 * 0 - success.
1113 * Any other value - error.
1118 return (*phba->lpfc_hba_down_post)(phba); in lpfc_hba_down_post()
1122 * lpfc_hb_timeout - The HBA-timer timeout handler
1125 * This is the HBA-timer timeout handler registered to the lpfc driver. When
1127 * work-port-events bitmap and the worker thread is notified. This timeout
1143 spin_lock_irqsave(&phba->pport->work_port_lock, iflag); in lpfc_hb_timeout()
1144 tmo_posted = phba->pport->work_port_events & WORKER_HB_TMO; in lpfc_hb_timeout()
1146 phba->pport->work_port_events |= WORKER_HB_TMO; in lpfc_hb_timeout()
1147 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); in lpfc_hb_timeout()
1156 * lpfc_rrq_timeout - The RRQ-timer timeout handler
1159 * This is the RRQ-timer timeout handler registered to the lpfc driver. When
1161 * work-port-events bitmap and the worker thread is notified. This timeout
1174 spin_lock_irqsave(&phba->pport->work_port_lock, iflag); in lpfc_rrq_timeout()
1175 if (!(phba->pport->load_flag & FC_UNLOADING)) in lpfc_rrq_timeout()
1176 phba->hba_flag |= HBA_RRQ_ACTIVE; in lpfc_rrq_timeout()
1178 phba->hba_flag &= ~HBA_RRQ_ACTIVE; in lpfc_rrq_timeout()
1179 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); in lpfc_rrq_timeout()
1181 if (!(phba->pport->load_flag & FC_UNLOADING)) in lpfc_rrq_timeout()
1186 * lpfc_hb_mbox_cmpl - The lpfc heart-beat mailbox command callback function
1190 * This is the callback function to the lpfc heart-beat mailbox command.
1191 * If configured, the lpfc driver issues the heart-beat mailbox command to
1193 * heart-beat mailbox command is issued, the driver shall set up heart-beat
1195 * heart-beat outstanding state. Once the mailbox command comes back and
1196 * no error conditions detected, the heart-beat mailbox command timer is
1197 * reset to LPFC_HB_MBOX_INTERVAL seconds and the heart-beat outstanding
1198 * state is cleared for the next heart-beat. If the timer expired with the
1199 * heart-beat outstanding state set, the driver will put the HBA offline.
1206 spin_lock_irqsave(&phba->hbalock, drvr_flag); in lpfc_hb_mbox_cmpl()
1207 phba->hb_outstanding = 0; in lpfc_hb_mbox_cmpl()
1208 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_hb_mbox_cmpl()
1210 /* Check and reset heart-beat timer is necessary */ in lpfc_hb_mbox_cmpl()
1211 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_hb_mbox_cmpl()
1212 if (!(phba->pport->fc_flag & FC_OFFLINE_MODE) && in lpfc_hb_mbox_cmpl()
1213 !(phba->link_state == LPFC_HBA_ERROR) && in lpfc_hb_mbox_cmpl()
1214 !(phba->pport->load_flag & FC_UNLOADING)) in lpfc_hb_mbox_cmpl()
1215 mod_timer(&phba->hb_tmofunc, in lpfc_hb_mbox_cmpl()
1222 * lpfc_idle_stat_delay_work - idle_stat tracking
1224 * This routine tracks per-cq idle_stat and determines polling decisions.
1241 if (phba->pport->load_flag & FC_UNLOADING) in lpfc_idle_stat_delay_work()
1244 if (phba->link_state == LPFC_HBA_ERROR || in lpfc_idle_stat_delay_work()
1245 phba->pport->fc_flag & FC_OFFLINE_MODE) in lpfc_idle_stat_delay_work()
1249 hdwq = &phba->sli4_hba.hdwq[phba->sli4_hba.cpu_map[i].hdwq]; in lpfc_idle_stat_delay_work()
1250 cq = hdwq->io_cq; in lpfc_idle_stat_delay_work()
1252 /* Skip if we've already handled this cq's primary CPU */ in lpfc_idle_stat_delay_work()
1253 if (cq->chann != i) in lpfc_idle_stat_delay_work()
1256 idle_stat = &phba->sli4_hba.idle_stat[i]; in lpfc_idle_stat_delay_work()
1262 * percentage of 100 - the sum of the other consumption times. in lpfc_idle_stat_delay_work()
1265 diff_idle = wall_idle - idle_stat->prev_idle; in lpfc_idle_stat_delay_work()
1266 diff_wall = wall - idle_stat->prev_wall; in lpfc_idle_stat_delay_work()
1271 busy_time = diff_wall - diff_idle; in lpfc_idle_stat_delay_work()
1274 idle_percent = 100 - idle_percent; in lpfc_idle_stat_delay_work()
1277 cq->poll_mode = LPFC_QUEUE_WORK; in lpfc_idle_stat_delay_work()
1279 cq->poll_mode = LPFC_IRQ_POLL; in lpfc_idle_stat_delay_work()
1281 idle_stat->prev_idle = wall_idle; in lpfc_idle_stat_delay_work()
1282 idle_stat->prev_wall = wall; in lpfc_idle_stat_delay_work()
1286 schedule_delayed_work(&phba->idle_stat_delay_work, in lpfc_idle_stat_delay_work()
1301 if (!phba->cfg_auto_imax || phba->pport->load_flag & FC_UNLOADING) in lpfc_hb_eq_delay_work()
1304 if (phba->link_state == LPFC_HBA_ERROR || in lpfc_hb_eq_delay_work()
1305 phba->pport->fc_flag & FC_OFFLINE_MODE) in lpfc_hb_eq_delay_work()
1308 ena_delay = kcalloc(phba->sli4_hba.num_possible_cpu, sizeof(*ena_delay), in lpfc_hb_eq_delay_work()
1313 for (i = 0; i < phba->cfg_irq_chann; i++) { in lpfc_hb_eq_delay_work()
1315 eq = phba->sli4_hba.hba_eq_hdl[i].eq; in lpfc_hb_eq_delay_work()
1318 if (eq->q_mode || eq->q_flag & HBA_EQ_DELAY_CHK) { in lpfc_hb_eq_delay_work()
1319 eq->q_flag &= ~HBA_EQ_DELAY_CHK; in lpfc_hb_eq_delay_work()
1320 ena_delay[eq->last_cpu] = 1; in lpfc_hb_eq_delay_work()
1325 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, i); in lpfc_hb_eq_delay_work()
1327 usdelay = (eqi->icnt >> 10) * LPFC_EQ_DELAY_STEP; in lpfc_hb_eq_delay_work()
1334 eqi->icnt = 0; in lpfc_hb_eq_delay_work()
1336 list_for_each_entry_safe(eq, eq_next, &eqi->list, cpu_list) { in lpfc_hb_eq_delay_work()
1337 if (unlikely(eq->last_cpu != i)) { in lpfc_hb_eq_delay_work()
1338 eqi_new = per_cpu_ptr(phba->sli4_hba.eq_info, in lpfc_hb_eq_delay_work()
1339 eq->last_cpu); in lpfc_hb_eq_delay_work()
1340 list_move_tail(&eq->cpu_list, &eqi_new->list); in lpfc_hb_eq_delay_work()
1343 if (usdelay != eq->q_mode) in lpfc_hb_eq_delay_work()
1344 lpfc_modify_hba_eq_delay(phba, eq->hdwq, 1, in lpfc_hb_eq_delay_work()
1352 queue_delayed_work(phba->wq, &phba->eq_delay_work, in lpfc_hb_eq_delay_work()
1357 * lpfc_hb_mxp_handler - Multi-XRI pools handler to adjust XRI distribution
1368 hwq_count = phba->cfg_hdw_queue; in lpfc_hb_mxp_handler()
1384 * lpfc_hb_timeout_handler - The HBA-timer timeout handler
1387 * This is the actual HBA-timer timeout handler to be invoked by the worker
1388 * thread whenever the HBA timer fired and HBA-timeout event posted. This
1391 * or by processing slow-ring or fast-ring events within the HBA-timer
1393 * the timer for the next timeout period. If lpfc heart-beat mailbox command
1394 * is configured and there is no heart-beat mailbox command outstanding, a
1395 * heart-beat mailbox is issued and timer set properly. Otherwise, if there
1396 * has been a heart-beat mailbox command outstanding, the HBA shall be put
1406 struct lpfc_sli *psli = &phba->sli; in lpfc_hb_timeout_handler()
1409 if (phba->cfg_xri_rebalancing) { in lpfc_hb_timeout_handler()
1410 /* Multi-XRI pools handler */ in lpfc_hb_timeout_handler()
1416 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_hb_timeout_handler()
1422 if ((phba->link_state == LPFC_HBA_ERROR) || in lpfc_hb_timeout_handler()
1423 (phba->pport->load_flag & FC_UNLOADING) || in lpfc_hb_timeout_handler()
1424 (phba->pport->fc_flag & FC_OFFLINE_MODE)) in lpfc_hb_timeout_handler()
1427 spin_lock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1429 if (time_after(phba->last_completion_time + in lpfc_hb_timeout_handler()
1432 spin_unlock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1433 if (!phba->hb_outstanding) in lpfc_hb_timeout_handler()
1434 mod_timer(&phba->hb_tmofunc, in lpfc_hb_timeout_handler()
1438 mod_timer(&phba->hb_tmofunc, in lpfc_hb_timeout_handler()
1443 spin_unlock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1445 if (phba->elsbuf_cnt && in lpfc_hb_timeout_handler()
1446 (phba->elsbuf_cnt == phba->elsbuf_prev_cnt)) { in lpfc_hb_timeout_handler()
1447 spin_lock_irq(&phba->hbalock); in lpfc_hb_timeout_handler()
1448 list_splice_init(&phba->elsbuf, &completions); in lpfc_hb_timeout_handler()
1449 phba->elsbuf_cnt = 0; in lpfc_hb_timeout_handler()
1450 phba->elsbuf_prev_cnt = 0; in lpfc_hb_timeout_handler()
1451 spin_unlock_irq(&phba->hbalock); in lpfc_hb_timeout_handler()
1456 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); in lpfc_hb_timeout_handler()
1460 phba->elsbuf_prev_cnt = phba->elsbuf_cnt; in lpfc_hb_timeout_handler()
1463 if (phba->cfg_enable_hba_heartbeat) { in lpfc_hb_timeout_handler()
1464 if (!phba->hb_outstanding) { in lpfc_hb_timeout_handler()
1465 if ((!(psli->sli_flag & LPFC_SLI_MBOX_ACTIVE)) && in lpfc_hb_timeout_handler()
1466 (list_empty(&psli->mboxq))) { in lpfc_hb_timeout_handler()
1467 pmboxq = mempool_alloc(phba->mbox_mem_pool, in lpfc_hb_timeout_handler()
1470 mod_timer(&phba->hb_tmofunc, in lpfc_hb_timeout_handler()
1478 pmboxq->mbox_cmpl = lpfc_hb_mbox_cmpl; in lpfc_hb_timeout_handler()
1479 pmboxq->vport = phba->pport; in lpfc_hb_timeout_handler()
1486 phba->mbox_mem_pool); in lpfc_hb_timeout_handler()
1487 mod_timer(&phba->hb_tmofunc, in lpfc_hb_timeout_handler()
1493 phba->skipped_hb = 0; in lpfc_hb_timeout_handler()
1494 phba->hb_outstanding = 1; in lpfc_hb_timeout_handler()
1495 } else if (time_before_eq(phba->last_completion_time, in lpfc_hb_timeout_handler()
1496 phba->skipped_hb)) { in lpfc_hb_timeout_handler()
1501 - phba->last_completion_time)); in lpfc_hb_timeout_handler()
1503 phba->skipped_hb = jiffies; in lpfc_hb_timeout_handler()
1505 mod_timer(&phba->hb_tmofunc, in lpfc_hb_timeout_handler()
1519 - phba->last_completion_time)); in lpfc_hb_timeout_handler()
1520 mod_timer(&phba->hb_tmofunc, in lpfc_hb_timeout_handler()
1525 mod_timer(&phba->hb_tmofunc, in lpfc_hb_timeout_handler()
1532 * lpfc_offline_eratt - Bring lpfc offline on hardware error attention
1541 struct lpfc_sli *psli = &phba->sli; in lpfc_offline_eratt()
1543 spin_lock_irq(&phba->hbalock); in lpfc_offline_eratt()
1544 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_offline_eratt()
1545 spin_unlock_irq(&phba->hbalock); in lpfc_offline_eratt()
1550 spin_lock_irq(&phba->hbalock); in lpfc_offline_eratt()
1552 spin_unlock_irq(&phba->hbalock); in lpfc_offline_eratt()
1556 phba->link_state = LPFC_HBA_ERROR; in lpfc_offline_eratt()
1561 * lpfc_sli4_offline_eratt - Bring lpfc offline on SLI4 hardware error attention
1570 spin_lock_irq(&phba->hbalock); in lpfc_sli4_offline_eratt()
1571 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli4_offline_eratt()
1572 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_offline_eratt()
1582 * lpfc_handle_deferred_eratt - The HBA hardware deferred error handler
1593 uint32_t old_host_status = phba->work_hs; in lpfc_handle_deferred_eratt()
1594 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_deferred_eratt()
1599 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_deferred_eratt()
1600 spin_lock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1601 phba->hba_flag &= ~DEFER_ERATT; in lpfc_handle_deferred_eratt()
1602 spin_unlock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1609 phba->work_hs, phba->work_status[0], in lpfc_handle_deferred_eratt()
1610 phba->work_status[1]); in lpfc_handle_deferred_eratt()
1612 spin_lock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1613 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_handle_deferred_eratt()
1614 spin_unlock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1620 * SCSI layer retry it after re-establishing link. in lpfc_handle_deferred_eratt()
1632 while (phba->work_hs & HS_FFER1) { in lpfc_handle_deferred_eratt()
1634 if (lpfc_readl(phba->HSregaddr, &phba->work_hs)) { in lpfc_handle_deferred_eratt()
1635 phba->work_hs = UNPLUG_ERR ; in lpfc_handle_deferred_eratt()
1639 if (phba->pport->load_flag & FC_UNLOADING) { in lpfc_handle_deferred_eratt()
1640 phba->work_hs = 0; in lpfc_handle_deferred_eratt()
1650 if ((!phba->work_hs) && (!(phba->pport->load_flag & FC_UNLOADING))) in lpfc_handle_deferred_eratt()
1651 phba->work_hs = old_host_status & ~HS_FFER1; in lpfc_handle_deferred_eratt()
1653 spin_lock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1654 phba->hba_flag &= ~DEFER_ERATT; in lpfc_handle_deferred_eratt()
1655 spin_unlock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1656 phba->work_status[0] = readl(phba->MBslimaddr + 0xa8); in lpfc_handle_deferred_eratt()
1657 phba->work_status[1] = readl(phba->MBslimaddr + 0xac); in lpfc_handle_deferred_eratt()
1668 shost = lpfc_shost_from_vport(phba->pport); in lpfc_board_errevt_to_mgmt()
1676 * lpfc_handle_eratt_s3 - The SLI3 HBA hardware error handler
1681 * 1 - HBA error attention interrupt
1682 * 2 - DMA ring index out of range
1683 * 3 - Mailbox command came back as unknown
1688 struct lpfc_vport *vport = phba->pport; in lpfc_handle_eratt_s3()
1689 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_eratt_s3()
1698 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_eratt_s3()
1699 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1700 phba->hba_flag &= ~DEFER_ERATT; in lpfc_handle_eratt_s3()
1701 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1706 if (!phba->cfg_enable_hba_reset) in lpfc_handle_eratt_s3()
1712 if (phba->hba_flag & DEFER_ERATT) in lpfc_handle_eratt_s3()
1715 if ((phba->work_hs & HS_FFER6) || (phba->work_hs & HS_FFER8)) { in lpfc_handle_eratt_s3()
1716 if (phba->work_hs & HS_FFER6) in lpfc_handle_eratt_s3()
1717 /* Re-establishing Link */ in lpfc_handle_eratt_s3()
1719 "1301 Re-establishing Link " in lpfc_handle_eratt_s3()
1721 phba->work_hs, phba->work_status[0], in lpfc_handle_eratt_s3()
1722 phba->work_status[1]); in lpfc_handle_eratt_s3()
1723 if (phba->work_hs & HS_FFER8) in lpfc_handle_eratt_s3()
1728 phba->work_hs, phba->work_status[0], in lpfc_handle_eratt_s3()
1729 phba->work_status[1]); in lpfc_handle_eratt_s3()
1731 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1732 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_handle_eratt_s3()
1733 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1739 * retry it after re-establishing link. in lpfc_handle_eratt_s3()
1755 } else if (phba->work_hs & HS_CRIT_TEMP) { in lpfc_handle_eratt_s3()
1756 temperature = readl(phba->MBslimaddr + TEMPERATURE_OFFSET); in lpfc_handle_eratt_s3()
1765 temperature, phba->work_hs, in lpfc_handle_eratt_s3()
1766 phba->work_status[0], phba->work_status[1]); in lpfc_handle_eratt_s3()
1768 shost = lpfc_shost_from_vport(phba->pport); in lpfc_handle_eratt_s3()
1775 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1776 phba->over_temp_state = HBA_OVER_TEMP; in lpfc_handle_eratt_s3()
1777 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1788 phba->work_hs, in lpfc_handle_eratt_s3()
1789 phba->work_status[0], phba->work_status[1]); in lpfc_handle_eratt_s3()
1803 * lpfc_sli4_port_sta_fn_reset - The SLI4 function reset due to port status reg
1820 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_port_sta_fn_reset()
1848 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_sli4_port_sta_fn_reset()
1852 return -EIO; in lpfc_sli4_port_sta_fn_reset()
1854 phba->intr_mode = intr_mode; in lpfc_sli4_port_sta_fn_reset()
1863 * lpfc_handle_eratt_s4 - The SLI4 HBA hardware error handler
1872 struct lpfc_vport *vport = phba->pport; in lpfc_handle_eratt_s4()
1888 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_eratt_s4()
1896 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_handle_eratt_s4()
1900 phba->sli4_hba.u.if_type0.UERRLOregaddr, in lpfc_handle_eratt_s4()
1903 phba->sli4_hba.u.if_type0.UEMASKLOregaddr, in lpfc_handle_eratt_s4()
1906 if (pci_rd_rc1 == -EIO && pci_rd_rc2 == -EIO) in lpfc_handle_eratt_s4()
1908 if (!(phba->hba_flag & HBA_RECOVERABLE_UE)) { in lpfc_handle_eratt_s4()
1915 for (i = 0; i < phba->sli4_hba.ue_to_sr / 1000; i++) { in lpfc_handle_eratt_s4()
1916 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_handle_eratt_s4()
1938 if (!lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_handle_eratt_s4()
1957 phba->link_state = LPFC_HBA_ERROR; in lpfc_handle_eratt_s4()
1963 phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_handle_eratt_s4()
1966 if (pci_rd_rc1 == -EIO) { in lpfc_handle_eratt_s4()
1969 readl(phba->sli4_hba.u.if_type2.STATUSregaddr)); in lpfc_handle_eratt_s4()
1973 reg_err1 = readl(phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_handle_eratt_s4()
1974 reg_err2 = readl(phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_handle_eratt_s4()
1981 phba->sfp_alarm |= LPFC_TRANSGRESSION_HIGH_TEMPERATURE; in lpfc_handle_eratt_s4()
1986 shost = lpfc_shost_from_vport(phba->pport); in lpfc_handle_eratt_s4()
1993 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s4()
1994 phba->over_temp_state = HBA_OVER_TEMP; in lpfc_handle_eratt_s4()
1995 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s4()
2015 if (!phba->cfg_enable_hba_reset) in lpfc_handle_eratt_s4()
2032 phba->link_state = LPFC_HBA_ERROR; in lpfc_handle_eratt_s4()
2051 * lpfc_handle_eratt - Wrapper func for handling hba error attention
2058 * 0 - success.
2059 * Any other value - error.
2064 (*phba->lpfc_handle_eratt)(phba); in lpfc_handle_eratt()
2068 * lpfc_handle_latt - The HBA link event handler
2077 struct lpfc_vport *vport = phba->pport; in lpfc_handle_latt()
2078 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_latt()
2084 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_handle_latt()
2096 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); in lpfc_handle_latt()
2097 if (!mp->virt) { in lpfc_handle_latt()
2105 psli->slistat.link_event++; in lpfc_handle_latt()
2107 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_handle_latt()
2108 pmb->vport = vport; in lpfc_handle_latt()
2110 phba->sli.sli3_ring[LPFC_ELS_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_handle_latt()
2118 spin_lock_irq(&phba->hbalock); in lpfc_handle_latt()
2119 writel(HA_LATT, phba->HAregaddr); in lpfc_handle_latt()
2120 readl(phba->HAregaddr); /* flush */ in lpfc_handle_latt()
2121 spin_unlock_irq(&phba->hbalock); in lpfc_handle_latt()
2126 phba->sli.sli3_ring[LPFC_ELS_RING].flag &= ~LPFC_STOP_IOCB_EVENT; in lpfc_handle_latt()
2127 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_handle_latt()
2131 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_handle_latt()
2134 spin_lock_irq(&phba->hbalock); in lpfc_handle_latt()
2135 psli->sli_flag |= LPFC_PROCESS_LA; in lpfc_handle_latt()
2136 control = readl(phba->HCregaddr); in lpfc_handle_latt()
2138 writel(control, phba->HCregaddr); in lpfc_handle_latt()
2139 readl(phba->HCregaddr); /* flush */ in lpfc_handle_latt()
2142 writel(HA_LATT, phba->HAregaddr); in lpfc_handle_latt()
2143 readl(phba->HAregaddr); /* flush */ in lpfc_handle_latt()
2144 spin_unlock_irq(&phba->hbalock); in lpfc_handle_latt()
2146 phba->link_state = LPFC_HBA_ERROR; in lpfc_handle_latt()
2155 * lpfc_parse_vpd - Parse VPD (Vital Product Data)
2165 * 0 - pointer to the VPD passed in is NULL
2166 * 1 - success
2185 while (!finished && (index < (len - 4))) { in lpfc_parse_vpd()
2204 if (Length > len - index) in lpfc_parse_vpd()
2205 Length = len - index; in lpfc_parse_vpd()
2213 Length -= (3+i); in lpfc_parse_vpd()
2214 while(i--) { in lpfc_parse_vpd()
2215 phba->SerialNumber[j++] = vpd[index++]; in lpfc_parse_vpd()
2219 phba->SerialNumber[j] = 0; in lpfc_parse_vpd()
2223 phba->vpd_flag |= VPD_MODEL_DESC; in lpfc_parse_vpd()
2228 Length -= (3+i); in lpfc_parse_vpd()
2229 while(i--) { in lpfc_parse_vpd()
2230 phba->ModelDesc[j++] = vpd[index++]; in lpfc_parse_vpd()
2234 phba->ModelDesc[j] = 0; in lpfc_parse_vpd()
2238 phba->vpd_flag |= VPD_MODEL_NAME; in lpfc_parse_vpd()
2243 Length -= (3+i); in lpfc_parse_vpd()
2244 while(i--) { in lpfc_parse_vpd()
2245 phba->ModelName[j++] = vpd[index++]; in lpfc_parse_vpd()
2249 phba->ModelName[j] = 0; in lpfc_parse_vpd()
2253 phba->vpd_flag |= VPD_PROGRAM_TYPE; in lpfc_parse_vpd()
2258 Length -= (3+i); in lpfc_parse_vpd()
2259 while(i--) { in lpfc_parse_vpd()
2260 phba->ProgramType[j++] = vpd[index++]; in lpfc_parse_vpd()
2264 phba->ProgramType[j] = 0; in lpfc_parse_vpd()
2268 phba->vpd_flag |= VPD_PORT; in lpfc_parse_vpd()
2273 Length -= (3+i); in lpfc_parse_vpd()
2274 while(i--) { in lpfc_parse_vpd()
2275 if ((phba->sli_rev == LPFC_SLI_REV4) && in lpfc_parse_vpd()
2276 (phba->sli4_hba.pport_name_sta == in lpfc_parse_vpd()
2281 phba->Port[j++] = vpd[index++]; in lpfc_parse_vpd()
2285 if ((phba->sli_rev != LPFC_SLI_REV4) || in lpfc_parse_vpd()
2286 (phba->sli4_hba.pport_name_sta == in lpfc_parse_vpd()
2288 phba->Port[j] = 0; in lpfc_parse_vpd()
2296 Length -= (3 + i); in lpfc_parse_vpd()
2314 * lpfc_get_hba_model_desc - Retrieve HBA device model name and description
2329 uint16_t dev_id = phba->pcidev->device; in lpfc_get_hba_model_desc()
2343 if (phba->lmt & LMT_64Gb) in lpfc_get_hba_model_desc()
2345 else if (phba->lmt & LMT_32Gb) in lpfc_get_hba_model_desc()
2347 else if (phba->lmt & LMT_16Gb) in lpfc_get_hba_model_desc()
2349 else if (phba->lmt & LMT_10Gb) in lpfc_get_hba_model_desc()
2351 else if (phba->lmt & LMT_8Gb) in lpfc_get_hba_model_desc()
2353 else if (phba->lmt & LMT_4Gb) in lpfc_get_hba_model_desc()
2355 else if (phba->lmt & LMT_2Gb) in lpfc_get_hba_model_desc()
2357 else if (phba->lmt & LMT_1Gb) in lpfc_get_hba_model_desc()
2362 vp = &phba->vpd; in lpfc_get_hba_model_desc()
2370 if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3) in lpfc_get_hba_model_desc()
2381 if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID) in lpfc_get_hba_model_desc()
2392 m = (typeof(m)){"LP9802", "PCI-X", in lpfc_get_hba_model_desc()
2396 m = (typeof(m)){"LP10000", "PCI-X", in lpfc_get_hba_model_desc()
2400 m = (typeof(m)){"LPX1000", "PCI-X", in lpfc_get_hba_model_desc()
2404 m = (typeof(m)){"LP982", "PCI-X", in lpfc_get_hba_model_desc()
2408 m = (typeof(m)){"LP1050", "PCI-X", in lpfc_get_hba_model_desc()
2412 m = (typeof(m)){"LP11000", "PCI-X2", in lpfc_get_hba_model_desc()
2416 m = (typeof(m)){"LP11000-SP", "PCI-X2", in lpfc_get_hba_model_desc()
2420 m = (typeof(m)){"LP11002-SP", "PCI-X2", in lpfc_get_hba_model_desc()
2428 m = (typeof(m)){"LPe1000-SP", "PCIe", in lpfc_get_hba_model_desc()
2432 m = (typeof(m)){"LPe1002-SP", "PCIe", in lpfc_get_hba_model_desc()
2436 m = (typeof(m)){"LP1150", "PCI-X2", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2439 m = (typeof(m)){"LP111", "PCI-X2", in lpfc_get_hba_model_desc()
2459 m = (typeof(m)){"LP101", "PCI-X", in lpfc_get_hba_model_desc()
2463 m = (typeof(m)){"LP10000-S", "PCI", in lpfc_get_hba_model_desc()
2467 m = (typeof(m)){"LP11000-S", "PCI-X2", in lpfc_get_hba_model_desc()
2471 m = (typeof(m)){"LPe11000-S", "PCIe", in lpfc_get_hba_model_desc()
2484 m = (typeof(m)){"LPe12002-SP", "PCIe", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2487 m = (typeof(m)){"LPe12000-SP", "PCIe", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2490 m = (typeof(m)){"LPe12000-S", "PCIe", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2506 m = (typeof(m)){"LPemv12002-S", "PCIe IOV", in lpfc_get_hba_model_desc()
2518 m = (typeof(m)){"LPSe12002-ML1-E", "PCIe", in lpfc_get_hba_model_desc()
2568 phba->Port); in lpfc_get_hba_model_desc()
2582 * lpfc_post_buffer - Post IOCB(s) with DMA buffer descriptor(s) to a IOCB ring
2600 cnt += pring->missbufcnt; in lpfc_post_buffer()
2607 pring->missbufcnt = cnt; in lpfc_post_buffer()
2610 icmd = &iocb->iocb; in lpfc_post_buffer()
2616 mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &mp1->phys); in lpfc_post_buffer()
2617 if (!mp1 || !mp1->virt) { in lpfc_post_buffer()
2620 pring->missbufcnt = cnt; in lpfc_post_buffer()
2624 INIT_LIST_HEAD(&mp1->list); in lpfc_post_buffer()
2629 mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI, in lpfc_post_buffer()
2630 &mp2->phys); in lpfc_post_buffer()
2631 if (!mp2 || !mp2->virt) { in lpfc_post_buffer()
2633 lpfc_mbuf_free(phba, mp1->virt, mp1->phys); in lpfc_post_buffer()
2636 pring->missbufcnt = cnt; in lpfc_post_buffer()
2640 INIT_LIST_HEAD(&mp2->list); in lpfc_post_buffer()
2645 icmd->un.cont64[0].addrHigh = putPaddrHigh(mp1->phys); in lpfc_post_buffer()
2646 icmd->un.cont64[0].addrLow = putPaddrLow(mp1->phys); in lpfc_post_buffer()
2647 icmd->un.cont64[0].tus.f.bdeSize = FCELSSIZE; in lpfc_post_buffer()
2648 icmd->ulpBdeCount = 1; in lpfc_post_buffer()
2649 cnt--; in lpfc_post_buffer()
2651 icmd->un.cont64[1].addrHigh = putPaddrHigh(mp2->phys); in lpfc_post_buffer()
2652 icmd->un.cont64[1].addrLow = putPaddrLow(mp2->phys); in lpfc_post_buffer()
2653 icmd->un.cont64[1].tus.f.bdeSize = FCELSSIZE; in lpfc_post_buffer()
2654 cnt--; in lpfc_post_buffer()
2655 icmd->ulpBdeCount = 2; in lpfc_post_buffer()
2658 icmd->ulpCommand = CMD_QUE_RING_BUF64_CN; in lpfc_post_buffer()
2659 icmd->ulpLe = 1; in lpfc_post_buffer()
2661 if (lpfc_sli_issue_iocb(phba, pring->ringno, iocb, 0) == in lpfc_post_buffer()
2663 lpfc_mbuf_free(phba, mp1->virt, mp1->phys); in lpfc_post_buffer()
2667 lpfc_mbuf_free(phba, mp2->virt, mp2->phys); in lpfc_post_buffer()
2672 pring->missbufcnt = cnt; in lpfc_post_buffer()
2679 pring->missbufcnt = 0; in lpfc_post_buffer()
2684 * lpfc_post_rcv_buf - Post the initial receive IOCB buffers to ELS ring
2692 * 0 - success (currently always success)
2697 struct lpfc_sli *psli = &phba->sli; in lpfc_post_rcv_buf()
2700 lpfc_post_buffer(phba, &psli->sli3_ring[LPFC_ELS_RING], LPFC_BUF_RING0); in lpfc_post_rcv_buf()
2701 /* Ring 2 - FCP no buffers needed */ in lpfc_post_rcv_buf()
2706 #define S(N,V) (((V)<<(N))|((V)>>(32-(N))))
2709 * lpfc_sha_init - Set up initial array of hash table entries
2726 * lpfc_sha_iterate - Iterate initial hash table with the working hash table
2745 HashWorkingPointer[t - 3] ^ HashWorkingPointer[t - in lpfc_sha_iterate()
2747 HashWorkingPointer[t - 14] ^ HashWorkingPointer[t - 16]); in lpfc_sha_iterate()
2783 * lpfc_challenge_key - Create challenge key based on WWPN of the HBA
2799 * lpfc_hba_init - Perform special handling for LC HBA initialization
2801 * @hbainit: pointer to an array of unsigned 32-bit integers.
2810 uint32_t *pwwnn = (uint32_t *) phba->wwnn; in lpfc_hba_init()
2820 lpfc_challenge_key(phba->RandomData + t, HashWorking + t); in lpfc_hba_init()
2828 * lpfc_cleanup - Performs vport cleanups before deleting a vport
2839 struct lpfc_hba *phba = vport->phba; in lpfc_cleanup()
2843 if (phba->link_state > LPFC_LINK_DOWN) in lpfc_cleanup()
2846 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { in lpfc_cleanup()
2852 spin_lock_irq(&phba->ndlp_lock); in lpfc_cleanup()
2854 spin_unlock_irq(&phba->ndlp_lock); in lpfc_cleanup()
2859 spin_lock_irq(&phba->ndlp_lock); in lpfc_cleanup()
2862 spin_unlock_irq(&phba->ndlp_lock); in lpfc_cleanup()
2867 spin_unlock_irq(&phba->ndlp_lock); in lpfc_cleanup()
2869 if (vport->port_type != LPFC_PHYSICAL_PORT && in lpfc_cleanup()
2870 ndlp->nlp_DID == Fabric_DID) { in lpfc_cleanup()
2879 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) { in lpfc_cleanup()
2884 if (ndlp->nlp_type & NLP_FABRIC) in lpfc_cleanup()
2896 while (!list_empty(&vport->fc_nodes)) { in lpfc_cleanup()
2902 &vport->fc_nodes, nlp_listp) { in lpfc_cleanup()
2903 lpfc_printf_vlog(ndlp->vport, KERN_ERR, in lpfc_cleanup()
2907 ndlp->nlp_DID, (void *)ndlp, in lpfc_cleanup()
2908 ndlp->nlp_usg_map, in lpfc_cleanup()
2909 kref_read(&ndlp->kref)); in lpfc_cleanup()
2921 * lpfc_stop_vport_timers - Stop all the timers associated with a vport
2931 del_timer_sync(&vport->els_tmofunc); in lpfc_stop_vport_timers()
2932 del_timer_sync(&vport->delayed_disc_tmo); in lpfc_stop_vport_timers()
2938 * __lpfc_sli4_stop_fcf_redisc_wait_timer - Stop FCF rediscovery wait timer
2948 phba->fcf.fcf_flag &= ~FCF_REDISC_PEND; in __lpfc_sli4_stop_fcf_redisc_wait_timer()
2951 del_timer(&phba->fcf.redisc_wait); in __lpfc_sli4_stop_fcf_redisc_wait_timer()
2955 * lpfc_sli4_stop_fcf_redisc_wait_timer - Stop FCF rediscovery wait timer
2966 spin_lock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
2967 if (!(phba->fcf.fcf_flag & FCF_REDISC_PEND)) { in lpfc_sli4_stop_fcf_redisc_wait_timer()
2969 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
2974 phba->fcf.fcf_flag &= ~(FCF_DEAD_DISC | FCF_ACVL_DISC); in lpfc_sli4_stop_fcf_redisc_wait_timer()
2975 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
2979 * lpfc_stop_hba_timers - Stop all the timers associated with an HBA
2988 if (phba->pport) in lpfc_stop_hba_timers()
2989 lpfc_stop_vport_timers(phba->pport); in lpfc_stop_hba_timers()
2990 cancel_delayed_work_sync(&phba->eq_delay_work); in lpfc_stop_hba_timers()
2991 cancel_delayed_work_sync(&phba->idle_stat_delay_work); in lpfc_stop_hba_timers()
2992 del_timer_sync(&phba->sli.mbox_tmo); in lpfc_stop_hba_timers()
2993 del_timer_sync(&phba->fabric_block_timer); in lpfc_stop_hba_timers()
2994 del_timer_sync(&phba->eratt_poll); in lpfc_stop_hba_timers()
2995 del_timer_sync(&phba->hb_tmofunc); in lpfc_stop_hba_timers()
2996 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_stop_hba_timers()
2997 del_timer_sync(&phba->rrq_tmr); in lpfc_stop_hba_timers()
2998 phba->hba_flag &= ~HBA_RRQ_ACTIVE; in lpfc_stop_hba_timers()
3000 phba->hb_outstanding = 0; in lpfc_stop_hba_timers()
3002 switch (phba->pci_dev_grp) { in lpfc_stop_hba_timers()
3005 del_timer_sync(&phba->fcp_poll_timer); in lpfc_stop_hba_timers()
3014 phba->pci_dev_grp); in lpfc_stop_hba_timers()
3021 * lpfc_block_mgmt_io - Mark a HBA's management interface as blocked
3038 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3039 phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO; in lpfc_block_mgmt_io()
3040 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3044 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3045 if (phba->sli.mbox_active) { in lpfc_block_mgmt_io()
3046 actcmd = phba->sli.mbox_active->u.mb.mbxCommand; in lpfc_block_mgmt_io()
3051 phba->sli.mbox_active) * 1000) + jiffies; in lpfc_block_mgmt_io()
3053 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3056 while (phba->sli.mbox_active) { in lpfc_block_mgmt_io()
3062 "- mbox cmd %x still active\n", in lpfc_block_mgmt_io()
3063 phba->sli.sli_flag, actcmd); in lpfc_block_mgmt_io()
3070 * lpfc_sli4_node_prep - Assign RPIs for active nodes.
3085 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_sli4_node_prep()
3092 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_sli4_node_prep()
3093 if (vports[i]->load_flag & FC_UNLOADING) in lpfc_sli4_node_prep()
3097 &vports[i]->fc_nodes, in lpfc_sli4_node_prep()
3103 spin_lock_irqsave(&phba->ndlp_lock, flags); in lpfc_sli4_node_prep()
3105 spin_unlock_irqrestore(&phba->ndlp_lock, flags); in lpfc_sli4_node_prep()
3108 ndlp->nlp_rpi = rpi; in lpfc_sli4_node_prep()
3109 lpfc_printf_vlog(ndlp->vport, KERN_INFO, in lpfc_sli4_node_prep()
3113 ndlp->nlp_rpi, ndlp, ndlp->nlp_DID, in lpfc_sli4_node_prep()
3114 ndlp->nlp_flag, ndlp->nlp_usg_map); in lpfc_sli4_node_prep()
3121 * lpfc_create_expedite_pool - create expedite pool
3135 epd_pool = &phba->epd_pool; in lpfc_create_expedite_pool()
3136 qp = &phba->sli4_hba.hdwq[0]; in lpfc_create_expedite_pool()
3138 spin_lock_init(&epd_pool->lock); in lpfc_create_expedite_pool()
3139 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_create_expedite_pool()
3140 spin_lock(&epd_pool->lock); in lpfc_create_expedite_pool()
3141 INIT_LIST_HEAD(&epd_pool->list); in lpfc_create_expedite_pool()
3143 &qp->lpfc_io_buf_list_put, list) { in lpfc_create_expedite_pool()
3144 list_move_tail(&lpfc_ncmd->list, &epd_pool->list); in lpfc_create_expedite_pool()
3145 lpfc_ncmd->expedite = true; in lpfc_create_expedite_pool()
3146 qp->put_io_bufs--; in lpfc_create_expedite_pool()
3147 epd_pool->count++; in lpfc_create_expedite_pool()
3148 if (epd_pool->count >= XRI_BATCH) in lpfc_create_expedite_pool()
3151 spin_unlock(&epd_pool->lock); in lpfc_create_expedite_pool()
3152 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_create_expedite_pool()
3156 * lpfc_destroy_expedite_pool - destroy expedite pool
3170 epd_pool = &phba->epd_pool; in lpfc_destroy_expedite_pool()
3171 qp = &phba->sli4_hba.hdwq[0]; in lpfc_destroy_expedite_pool()
3173 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_expedite_pool()
3174 spin_lock(&epd_pool->lock); in lpfc_destroy_expedite_pool()
3176 &epd_pool->list, list) { in lpfc_destroy_expedite_pool()
3177 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_expedite_pool()
3178 &qp->lpfc_io_buf_list_put); in lpfc_destroy_expedite_pool()
3179 lpfc_ncmd->flags = false; in lpfc_destroy_expedite_pool()
3180 qp->put_io_bufs++; in lpfc_destroy_expedite_pool()
3181 epd_pool->count--; in lpfc_destroy_expedite_pool()
3183 spin_unlock(&epd_pool->lock); in lpfc_destroy_expedite_pool()
3184 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_expedite_pool()
3188 * lpfc_create_multixri_pools - create multi-XRI pools
3210 phba->cfg_hdw_queue, phba->sli4_hba.num_present_cpu, in lpfc_create_multixri_pools()
3211 phba->sli4_hba.io_xri_cnt); in lpfc_create_multixri_pools()
3213 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_create_multixri_pools()
3216 hwq_count = phba->cfg_hdw_queue; in lpfc_create_multixri_pools()
3217 count_per_hwq = phba->sli4_hba.io_xri_cnt / hwq_count; in lpfc_create_multixri_pools()
3227 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_create_multixri_pools()
3232 qp = &phba->sli4_hba.hdwq[j]; in lpfc_create_multixri_pools()
3233 kfree(qp->p_multixri_pool); in lpfc_create_multixri_pools()
3236 phba->cfg_xri_rebalancing = 0; in lpfc_create_multixri_pools()
3240 qp = &phba->sli4_hba.hdwq[i]; in lpfc_create_multixri_pools()
3241 qp->p_multixri_pool = multixri_pool; in lpfc_create_multixri_pools()
3243 multixri_pool->xri_limit = count_per_hwq; in lpfc_create_multixri_pools()
3244 multixri_pool->rrb_next_hwqid = i; in lpfc_create_multixri_pools()
3247 pbl_pool = &multixri_pool->pbl_pool; in lpfc_create_multixri_pools()
3248 spin_lock_init(&pbl_pool->lock); in lpfc_create_multixri_pools()
3249 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_create_multixri_pools()
3250 spin_lock(&pbl_pool->lock); in lpfc_create_multixri_pools()
3251 INIT_LIST_HEAD(&pbl_pool->list); in lpfc_create_multixri_pools()
3253 &qp->lpfc_io_buf_list_put, list) { in lpfc_create_multixri_pools()
3254 list_move_tail(&lpfc_ncmd->list, &pbl_pool->list); in lpfc_create_multixri_pools()
3255 qp->put_io_bufs--; in lpfc_create_multixri_pools()
3256 pbl_pool->count++; in lpfc_create_multixri_pools()
3260 pbl_pool->count, i); in lpfc_create_multixri_pools()
3261 spin_unlock(&pbl_pool->lock); in lpfc_create_multixri_pools()
3262 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_create_multixri_pools()
3265 pvt_pool = &multixri_pool->pvt_pool; in lpfc_create_multixri_pools()
3266 pvt_pool->high_watermark = multixri_pool->xri_limit / 2; in lpfc_create_multixri_pools()
3267 pvt_pool->low_watermark = XRI_BATCH; in lpfc_create_multixri_pools()
3268 spin_lock_init(&pvt_pool->lock); in lpfc_create_multixri_pools()
3269 spin_lock_irqsave(&pvt_pool->lock, iflag); in lpfc_create_multixri_pools()
3270 INIT_LIST_HEAD(&pvt_pool->list); in lpfc_create_multixri_pools()
3271 pvt_pool->count = 0; in lpfc_create_multixri_pools()
3272 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_create_multixri_pools()
3277 * lpfc_destroy_multixri_pools - destroy multi-XRI pools
3294 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_destroy_multixri_pools()
3297 if (!(phba->pport->load_flag & FC_UNLOADING)) in lpfc_destroy_multixri_pools()
3300 hwq_count = phba->cfg_hdw_queue; in lpfc_destroy_multixri_pools()
3303 qp = &phba->sli4_hba.hdwq[i]; in lpfc_destroy_multixri_pools()
3304 multixri_pool = qp->p_multixri_pool; in lpfc_destroy_multixri_pools()
3308 qp->p_multixri_pool = NULL; in lpfc_destroy_multixri_pools()
3310 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_multixri_pools()
3313 pbl_pool = &multixri_pool->pbl_pool; in lpfc_destroy_multixri_pools()
3314 spin_lock(&pbl_pool->lock); in lpfc_destroy_multixri_pools()
3318 pbl_pool->count, i); in lpfc_destroy_multixri_pools()
3321 &pbl_pool->list, list) { in lpfc_destroy_multixri_pools()
3322 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_multixri_pools()
3323 &qp->lpfc_io_buf_list_put); in lpfc_destroy_multixri_pools()
3324 qp->put_io_bufs++; in lpfc_destroy_multixri_pools()
3325 pbl_pool->count--; in lpfc_destroy_multixri_pools()
3328 INIT_LIST_HEAD(&pbl_pool->list); in lpfc_destroy_multixri_pools()
3329 pbl_pool->count = 0; in lpfc_destroy_multixri_pools()
3331 spin_unlock(&pbl_pool->lock); in lpfc_destroy_multixri_pools()
3334 pvt_pool = &multixri_pool->pvt_pool; in lpfc_destroy_multixri_pools()
3335 spin_lock(&pvt_pool->lock); in lpfc_destroy_multixri_pools()
3339 pvt_pool->count, i); in lpfc_destroy_multixri_pools()
3342 &pvt_pool->list, list) { in lpfc_destroy_multixri_pools()
3343 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_multixri_pools()
3344 &qp->lpfc_io_buf_list_put); in lpfc_destroy_multixri_pools()
3345 qp->put_io_bufs++; in lpfc_destroy_multixri_pools()
3346 pvt_pool->count--; in lpfc_destroy_multixri_pools()
3349 INIT_LIST_HEAD(&pvt_pool->list); in lpfc_destroy_multixri_pools()
3350 pvt_pool->count = 0; in lpfc_destroy_multixri_pools()
3352 spin_unlock(&pvt_pool->lock); in lpfc_destroy_multixri_pools()
3353 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_multixri_pools()
3360 * lpfc_online - Initialize and bring a HBA online
3368 * 0 - successful
3369 * 1 - failed
3381 vport = phba->pport; in lpfc_online()
3383 if (!(vport->fc_flag & FC_OFFLINE_MODE)) in lpfc_online()
3391 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_online()
3396 spin_lock_irq(&phba->hbalock); in lpfc_online()
3397 if (!phba->sli4_hba.max_cfg_param.vpi_used) in lpfc_online()
3399 spin_unlock_irq(&phba->hbalock); in lpfc_online()
3404 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME && in lpfc_online()
3405 !phba->nvmet_support) { in lpfc_online()
3406 error = lpfc_nvme_create_localport(phba->pport); in lpfc_online()
3422 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_online()
3425 spin_lock_irq(shost->host_lock); in lpfc_online()
3426 vports[i]->fc_flag &= ~FC_OFFLINE_MODE; in lpfc_online()
3427 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) in lpfc_online()
3428 vports[i]->fc_flag |= FC_VPORT_NEEDS_REG_VPI; in lpfc_online()
3429 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_online()
3430 vports[i]->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; in lpfc_online()
3432 (vports[i]->port_type != in lpfc_online()
3434 vports[i]->vpi = 0; in lpfc_online()
3436 spin_unlock_irq(shost->host_lock); in lpfc_online()
3441 if (phba->cfg_xri_rebalancing) in lpfc_online()
3451 * lpfc_unblock_mgmt_io - Mark a HBA's management interface to be not blocked
3466 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_unblock_mgmt_io()
3467 phba->sli.sli_flag &= ~LPFC_BLOCK_MGMT_IO; in lpfc_unblock_mgmt_io()
3468 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_unblock_mgmt_io()
3472 * lpfc_offline_prep - Prepare a HBA to be brought offline
3483 struct lpfc_vport *vport = phba->pport; in lpfc_offline_prep()
3489 if (vport->fc_flag & FC_OFFLINE_MODE) in lpfc_offline_prep()
3499 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_offline_prep()
3500 if (vports[i]->load_flag & FC_UNLOADING) in lpfc_offline_prep()
3503 spin_lock_irq(shost->host_lock); in lpfc_offline_prep()
3504 vports[i]->vpi_state &= ~LPFC_VPI_REGISTERED; in lpfc_offline_prep()
3505 vports[i]->fc_flag |= FC_VPORT_NEEDS_REG_VPI; in lpfc_offline_prep()
3506 vports[i]->fc_flag &= ~FC_VFI_REGISTERED; in lpfc_offline_prep()
3507 spin_unlock_irq(shost->host_lock); in lpfc_offline_prep()
3511 &vports[i]->fc_nodes, in lpfc_offline_prep()
3514 ndlp->nlp_state == NLP_STE_UNUSED_NODE) { in lpfc_offline_prep()
3518 ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR; in lpfc_offline_prep()
3522 if (ndlp->nlp_type & NLP_FABRIC) { in lpfc_offline_prep()
3528 spin_lock_irq(shost->host_lock); in lpfc_offline_prep()
3529 ndlp->nlp_flag &= ~NLP_NPR_ADISC; in lpfc_offline_prep()
3530 spin_unlock_irq(shost->host_lock); in lpfc_offline_prep()
3536 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_offline_prep()
3537 lpfc_printf_vlog(ndlp->vport, KERN_INFO, in lpfc_offline_prep()
3542 ndlp->nlp_rpi, ndlp, in lpfc_offline_prep()
3543 ndlp->nlp_DID, in lpfc_offline_prep()
3544 ndlp->nlp_usg_map); in lpfc_offline_prep()
3545 lpfc_sli4_free_rpi(phba, ndlp->nlp_rpi); in lpfc_offline_prep()
3546 ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR; in lpfc_offline_prep()
3556 if (phba->wq) in lpfc_offline_prep()
3557 flush_workqueue(phba->wq); in lpfc_offline_prep()
3561 * lpfc_offline - Bring a HBA offline
3575 if (phba->pport->fc_flag & FC_OFFLINE_MODE) in lpfc_offline()
3585 lpfc_nvme_destroy_localport(phba->pport); in lpfc_offline()
3589 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) in lpfc_offline()
3597 spin_lock_irq(&phba->hbalock); in lpfc_offline()
3598 phba->work_ha = 0; in lpfc_offline()
3599 spin_unlock_irq(&phba->hbalock); in lpfc_offline()
3602 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_offline()
3604 spin_lock_irq(shost->host_lock); in lpfc_offline()
3605 vports[i]->work_port_events = 0; in lpfc_offline()
3606 vports[i]->fc_flag |= FC_OFFLINE_MODE; in lpfc_offline()
3607 spin_unlock_irq(shost->host_lock); in lpfc_offline()
3612 if (phba->cfg_xri_rebalancing) in lpfc_offline()
3617 * lpfc_scsi_free - Free all the SCSI buffers and IOCBs from driver lists
3629 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_scsi_free()
3632 spin_lock_irq(&phba->hbalock); in lpfc_scsi_free()
3636 spin_lock(&phba->scsi_buf_list_put_lock); in lpfc_scsi_free()
3637 list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list_put, in lpfc_scsi_free()
3639 list_del(&sb->list); in lpfc_scsi_free()
3640 dma_pool_free(phba->lpfc_sg_dma_buf_pool, sb->data, in lpfc_scsi_free()
3641 sb->dma_handle); in lpfc_scsi_free()
3643 phba->total_scsi_bufs--; in lpfc_scsi_free()
3645 spin_unlock(&phba->scsi_buf_list_put_lock); in lpfc_scsi_free()
3647 spin_lock(&phba->scsi_buf_list_get_lock); in lpfc_scsi_free()
3648 list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list_get, in lpfc_scsi_free()
3650 list_del(&sb->list); in lpfc_scsi_free()
3651 dma_pool_free(phba->lpfc_sg_dma_buf_pool, sb->data, in lpfc_scsi_free()
3652 sb->dma_handle); in lpfc_scsi_free()
3654 phba->total_scsi_bufs--; in lpfc_scsi_free()
3656 spin_unlock(&phba->scsi_buf_list_get_lock); in lpfc_scsi_free()
3657 spin_unlock_irq(&phba->hbalock); in lpfc_scsi_free()
3661 * lpfc_io_free - Free all the IO buffers and IOCBs from driver lists
3675 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_free()
3676 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_free()
3678 spin_lock(&qp->io_buf_list_put_lock); in lpfc_io_free()
3680 &qp->lpfc_io_buf_list_put, in lpfc_io_free()
3682 list_del(&lpfc_ncmd->list); in lpfc_io_free()
3683 qp->put_io_bufs--; in lpfc_io_free()
3684 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_io_free()
3685 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_io_free()
3686 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_io_free()
3690 qp->total_io_bufs--; in lpfc_io_free()
3692 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_io_free()
3694 spin_lock(&qp->io_buf_list_get_lock); in lpfc_io_free()
3696 &qp->lpfc_io_buf_list_get, in lpfc_io_free()
3698 list_del(&lpfc_ncmd->list); in lpfc_io_free()
3699 qp->get_io_bufs--; in lpfc_io_free()
3700 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_io_free()
3701 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_io_free()
3702 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_io_free()
3706 qp->total_io_bufs--; in lpfc_io_free()
3708 spin_unlock(&qp->io_buf_list_get_lock); in lpfc_io_free()
3713 * lpfc_sli4_els_sgl_update - update ELS xri-sgl sizing and mapping
3722 * 0 - successful (for now, it always returns 0)
3733 * update on pci function's els xri-sgl list in lpfc_sli4_els_sgl_update()
3737 if (els_xri_cnt > phba->sli4_hba.els_xri_cnt) { in lpfc_sli4_els_sgl_update()
3738 /* els xri-sgl expanded */ in lpfc_sli4_els_sgl_update()
3739 xri_cnt = els_xri_cnt - phba->sli4_hba.els_xri_cnt; in lpfc_sli4_els_sgl_update()
3741 "3157 ELS xri-sgl count increased from " in lpfc_sli4_els_sgl_update()
3742 "%d to %d\n", phba->sli4_hba.els_xri_cnt, in lpfc_sli4_els_sgl_update()
3753 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
3756 sglq_entry->buff_type = GEN_BUFF_TYPE; in lpfc_sli4_els_sgl_update()
3757 sglq_entry->virt = lpfc_mbuf_alloc(phba, 0, in lpfc_sli4_els_sgl_update()
3758 &sglq_entry->phys); in lpfc_sli4_els_sgl_update()
3759 if (sglq_entry->virt == NULL) { in lpfc_sli4_els_sgl_update()
3765 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
3768 sglq_entry->sgl = sglq_entry->virt; in lpfc_sli4_els_sgl_update()
3769 memset(sglq_entry->sgl, 0, LPFC_BPL_SIZE); in lpfc_sli4_els_sgl_update()
3770 sglq_entry->state = SGL_FREED; in lpfc_sli4_els_sgl_update()
3771 list_add_tail(&sglq_entry->list, &els_sgl_list); in lpfc_sli4_els_sgl_update()
3773 spin_lock_irq(&phba->hbalock); in lpfc_sli4_els_sgl_update()
3774 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
3776 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_sli4_els_sgl_update()
3777 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
3778 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_els_sgl_update()
3779 } else if (els_xri_cnt < phba->sli4_hba.els_xri_cnt) { in lpfc_sli4_els_sgl_update()
3780 /* els xri-sgl shrinked */ in lpfc_sli4_els_sgl_update()
3781 xri_cnt = phba->sli4_hba.els_xri_cnt - els_xri_cnt; in lpfc_sli4_els_sgl_update()
3783 "3158 ELS xri-sgl count decreased from " in lpfc_sli4_els_sgl_update()
3784 "%d to %d\n", phba->sli4_hba.els_xri_cnt, in lpfc_sli4_els_sgl_update()
3786 spin_lock_irq(&phba->hbalock); in lpfc_sli4_els_sgl_update()
3787 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
3788 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, in lpfc_sli4_els_sgl_update()
3795 __lpfc_mbuf_free(phba, sglq_entry->virt, in lpfc_sli4_els_sgl_update()
3796 sglq_entry->phys); in lpfc_sli4_els_sgl_update()
3801 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_sli4_els_sgl_update()
3802 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
3803 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_els_sgl_update()
3806 "3163 ELS xri-sgl count unchanged: %d\n", in lpfc_sli4_els_sgl_update()
3808 phba->sli4_hba.els_xri_cnt = els_xri_cnt; in lpfc_sli4_els_sgl_update()
3814 &phba->sli4_hba.lpfc_els_sgl_list, list) { in lpfc_sli4_els_sgl_update()
3821 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
3824 sglq_entry->sli4_lxritag = lxri; in lpfc_sli4_els_sgl_update()
3825 sglq_entry->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_els_sgl_update()
3835 * lpfc_sli4_nvmet_sgl_update - update xri-sgl sizing and mapping
3844 * 0 - successful (for now, it always returns 0)
3856 * update on pci function's nvmet xri-sgl list in lpfc_sli4_nvmet_sgl_update()
3861 nvmet_xri_cnt = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
3862 if (nvmet_xri_cnt > phba->sli4_hba.nvmet_xri_cnt) { in lpfc_sli4_nvmet_sgl_update()
3863 /* els xri-sgl expanded */ in lpfc_sli4_nvmet_sgl_update()
3864 xri_cnt = nvmet_xri_cnt - phba->sli4_hba.nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
3866 "6302 NVMET xri-sgl cnt grew from %d to %d\n", in lpfc_sli4_nvmet_sgl_update()
3867 phba->sli4_hba.nvmet_xri_cnt, nvmet_xri_cnt); in lpfc_sli4_nvmet_sgl_update()
3877 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
3880 sglq_entry->buff_type = NVMET_BUFF_TYPE; in lpfc_sli4_nvmet_sgl_update()
3881 sglq_entry->virt = lpfc_nvmet_buf_alloc(phba, 0, in lpfc_sli4_nvmet_sgl_update()
3882 &sglq_entry->phys); in lpfc_sli4_nvmet_sgl_update()
3883 if (sglq_entry->virt == NULL) { in lpfc_sli4_nvmet_sgl_update()
3889 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
3892 sglq_entry->sgl = sglq_entry->virt; in lpfc_sli4_nvmet_sgl_update()
3893 memset(sglq_entry->sgl, 0, in lpfc_sli4_nvmet_sgl_update()
3894 phba->cfg_sg_dma_buf_size); in lpfc_sli4_nvmet_sgl_update()
3895 sglq_entry->state = SGL_FREED; in lpfc_sli4_nvmet_sgl_update()
3896 list_add_tail(&sglq_entry->list, &nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
3898 spin_lock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
3899 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
3901 &phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
3902 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
3903 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
3904 } else if (nvmet_xri_cnt < phba->sli4_hba.nvmet_xri_cnt) { in lpfc_sli4_nvmet_sgl_update()
3905 /* nvmet xri-sgl shrunk */ in lpfc_sli4_nvmet_sgl_update()
3906 xri_cnt = phba->sli4_hba.nvmet_xri_cnt - nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
3908 "6305 NVMET xri-sgl count decreased from " in lpfc_sli4_nvmet_sgl_update()
3909 "%d to %d\n", phba->sli4_hba.nvmet_xri_cnt, in lpfc_sli4_nvmet_sgl_update()
3911 spin_lock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
3912 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
3913 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, in lpfc_sli4_nvmet_sgl_update()
3920 lpfc_nvmet_buf_free(phba, sglq_entry->virt, in lpfc_sli4_nvmet_sgl_update()
3921 sglq_entry->phys); in lpfc_sli4_nvmet_sgl_update()
3926 &phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
3927 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
3928 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
3931 "6306 NVMET xri-sgl count unchanged: %d\n", in lpfc_sli4_nvmet_sgl_update()
3933 phba->sli4_hba.nvmet_xri_cnt = nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
3939 &phba->sli4_hba.lpfc_nvmet_sgl_list, list) { in lpfc_sli4_nvmet_sgl_update()
3946 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
3949 sglq_entry->sli4_lxritag = lxri; in lpfc_sli4_nvmet_sgl_update()
3950 sglq_entry->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_nvmet_sgl_update()
3969 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_buf_flush()
3970 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf_flush()
3971 spin_lock_irq(&qp->io_buf_list_get_lock); in lpfc_io_buf_flush()
3972 spin_lock(&qp->io_buf_list_put_lock); in lpfc_io_buf_flush()
3975 list_splice_init(&qp->lpfc_io_buf_list_get, &blist); in lpfc_io_buf_flush()
3976 list_splice(&qp->lpfc_io_buf_list_put, &blist); in lpfc_io_buf_flush()
3977 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_io_buf_flush()
3978 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_io_buf_flush()
3979 cnt += qp->get_io_bufs + qp->put_io_bufs; in lpfc_io_buf_flush()
3980 qp->get_io_bufs = 0; in lpfc_io_buf_flush()
3981 qp->put_io_bufs = 0; in lpfc_io_buf_flush()
3982 qp->total_io_bufs = 0; in lpfc_io_buf_flush()
3983 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_io_buf_flush()
3984 spin_unlock_irq(&qp->io_buf_list_get_lock); in lpfc_io_buf_flush()
3997 list_add_tail(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4000 xri = lpfc_cmd->cur_iocbq.sli4_xritag; in lpfc_io_buf_flush()
4004 if (xri < iobufp->cur_iocbq.sli4_xritag) { in lpfc_io_buf_flush()
4006 list_add(&lpfc_cmd->list, in lpfc_io_buf_flush()
4007 &prev_iobufp->list); in lpfc_io_buf_flush()
4009 list_add(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4016 list_add_tail(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4028 qp = phba->sli4_hba.hdwq; in lpfc_io_buf_replenish()
4031 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_buf_replenish()
4037 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf_replenish()
4038 lpfc_cmd->hdwq_no = idx; in lpfc_io_buf_replenish()
4039 lpfc_cmd->hdwq = qp; in lpfc_io_buf_replenish()
4040 lpfc_cmd->cur_iocbq.wqe_cmpl = NULL; in lpfc_io_buf_replenish()
4041 lpfc_cmd->cur_iocbq.iocb_cmpl = NULL; in lpfc_io_buf_replenish()
4042 spin_lock(&qp->io_buf_list_put_lock); in lpfc_io_buf_replenish()
4043 list_add_tail(&lpfc_cmd->list, in lpfc_io_buf_replenish()
4044 &qp->lpfc_io_buf_list_put); in lpfc_io_buf_replenish()
4045 qp->put_io_bufs++; in lpfc_io_buf_replenish()
4046 qp->total_io_bufs++; in lpfc_io_buf_replenish()
4047 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_io_buf_replenish()
4054 * lpfc_sli4_io_sgl_update - update xri-sgl sizing and mapping
4063 * 0 - successful (for now, it always returns 0)
4075 * update on pci function's allocated nvme xri-sgl list in lpfc_sli4_io_sgl_update()
4080 io_xri_max = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt; in lpfc_sli4_io_sgl_update()
4081 phba->sli4_hba.io_xri_max = io_xri_max; in lpfc_sli4_io_sgl_update()
4086 phba->sli4_hba.io_xri_cnt, in lpfc_sli4_io_sgl_update()
4087 phba->sli4_hba.io_xri_max); in lpfc_sli4_io_sgl_update()
4091 if (phba->sli4_hba.io_xri_cnt > phba->sli4_hba.io_xri_max) { in lpfc_sli4_io_sgl_update()
4093 io_xri_cnt = phba->sli4_hba.io_xri_cnt - in lpfc_sli4_io_sgl_update()
4094 phba->sli4_hba.io_xri_max; in lpfc_sli4_io_sgl_update()
4100 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_sli4_io_sgl_update()
4101 lpfc_ncmd->data, in lpfc_sli4_io_sgl_update()
4102 lpfc_ncmd->dma_handle); in lpfc_sli4_io_sgl_update()
4106 phba->sli4_hba.io_xri_cnt -= io_xri_cnt; in lpfc_sli4_io_sgl_update()
4112 phba->sli4_hba.io_xri_cnt = cnt; in lpfc_sli4_io_sgl_update()
4121 rc = -ENOMEM; in lpfc_sli4_io_sgl_update()
4124 lpfc_ncmd->cur_iocbq.sli4_lxritag = lxri; in lpfc_sli4_io_sgl_update()
4125 lpfc_ncmd->cur_iocbq.sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_io_sgl_update()
4136 * lpfc_new_io_buf - IO buffer allocator for HBA with SLI4 IF spec
4140 * This routine allocates nvme buffers for device with SLI-4 interface spec,
4146 * int - number of IO buffers that were allocated and posted.
4160 phba->sli4_hba.io_xri_cnt = 0; in lpfc_new_io_buf()
4170 lpfc_ncmd->data = dma_pool_zalloc(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4172 &lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4173 if (!lpfc_ncmd->data) { in lpfc_new_io_buf()
4178 if (phba->cfg_xpsgl && !phba->nvmet_support) { in lpfc_new_io_buf()
4179 INIT_LIST_HEAD(&lpfc_ncmd->dma_sgl_xtra_list); in lpfc_new_io_buf()
4185 if ((phba->sli3_options & LPFC_SLI3_BG_ENABLED) && in lpfc_new_io_buf()
4186 (((unsigned long)(lpfc_ncmd->data) & in lpfc_new_io_buf()
4187 (unsigned long)(SLI4_PAGE_SIZE - 1)) != 0)) { in lpfc_new_io_buf()
4192 (unsigned long)lpfc_ncmd->data); in lpfc_new_io_buf()
4193 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4194 lpfc_ncmd->data, in lpfc_new_io_buf()
4195 lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4201 INIT_LIST_HEAD(&lpfc_ncmd->dma_cmd_rsp_list); in lpfc_new_io_buf()
4205 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4206 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4210 pwqeq = &lpfc_ncmd->cur_iocbq; in lpfc_new_io_buf()
4212 /* Allocate iotag for lpfc_ncmd->cur_iocbq. */ in lpfc_new_io_buf()
4215 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4216 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4224 pwqeq->sli4_lxritag = lxri; in lpfc_new_io_buf()
4225 pwqeq->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_new_io_buf()
4226 pwqeq->context1 = lpfc_ncmd; in lpfc_new_io_buf()
4228 /* Initialize local short-hand pointers. */ in lpfc_new_io_buf()
4229 lpfc_ncmd->dma_sgl = lpfc_ncmd->data; in lpfc_new_io_buf()
4230 lpfc_ncmd->dma_phys_sgl = lpfc_ncmd->dma_handle; in lpfc_new_io_buf()
4231 lpfc_ncmd->cur_iocbq.context1 = lpfc_ncmd; in lpfc_new_io_buf()
4232 spin_lock_init(&lpfc_ncmd->buf_lock); in lpfc_new_io_buf()
4235 list_add_tail(&lpfc_ncmd->list, &post_nblist); in lpfc_new_io_buf()
4236 phba->sli4_hba.io_xri_cnt++; in lpfc_new_io_buf()
4260 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_get_wwpn()
4263 return (uint64_t)-1; in lpfc_get_wwpn()
4272 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_get_wwpn()
4273 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_get_wwpn()
4274 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_get_wwpn()
4275 return (uint64_t) -1; in lpfc_get_wwpn()
4277 mb = &mboxq->u.mb; in lpfc_get_wwpn()
4278 memcpy(&wwn, (char *)mb->un.varRDnvp.portname, sizeof(uint64_t)); in lpfc_get_wwpn()
4280 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_get_wwpn()
4281 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_get_wwpn()
4288 * lpfc_create_port - Create an FC port
4300 * @vport - pointer to the virtual N_Port data structure.
4301 * NULL - port create failed.
4316 if (phba->sli_rev < LPFC_SLI_REV4 && in lpfc_create_port()
4317 dev == &phba->pcidev->dev) { in lpfc_create_port()
4339 if (dev == &phba->pcidev->dev) { in lpfc_create_port()
4340 template = &phba->port_template; in lpfc_create_port()
4342 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { in lpfc_create_port()
4348 template->max_sectors = 0xffff; in lpfc_create_port()
4349 template->eh_host_reset_handler = NULL; in lpfc_create_port()
4353 memcpy(&phba->vport_template, &lpfc_template, in lpfc_create_port()
4355 phba->vport_template.max_sectors = 0xffff; in lpfc_create_port()
4356 phba->vport_template.shost_attrs = lpfc_vport_attrs; in lpfc_create_port()
4357 phba->vport_template.eh_bus_reset_handler = NULL; in lpfc_create_port()
4358 phba->vport_template.eh_host_reset_handler = NULL; in lpfc_create_port()
4359 phba->vport_template.vendor_id = 0; in lpfc_create_port()
4362 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_create_port()
4363 template->sg_tablesize = phba->cfg_scsi_seg_cnt; in lpfc_create_port()
4364 phba->vport_template.sg_tablesize = in lpfc_create_port()
4365 phba->cfg_scsi_seg_cnt; in lpfc_create_port()
4367 template->sg_tablesize = phba->cfg_sg_seg_cnt; in lpfc_create_port()
4368 phba->vport_template.sg_tablesize = in lpfc_create_port()
4369 phba->cfg_sg_seg_cnt; in lpfc_create_port()
4378 template = &phba->vport_template; in lpfc_create_port()
4385 vport = (struct lpfc_vport *) shost->hostdata; in lpfc_create_port()
4386 vport->phba = phba; in lpfc_create_port()
4387 vport->load_flag |= FC_LOADING; in lpfc_create_port()
4388 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; in lpfc_create_port()
4389 vport->fc_rscn_flush = 0; in lpfc_create_port()
4393 vport->cfg_enable_fc4_type = phba->cfg_enable_fc4_type; in lpfc_create_port()
4395 shost->unique_id = instance; in lpfc_create_port()
4396 shost->max_id = LPFC_MAX_TARGET; in lpfc_create_port()
4397 shost->max_lun = vport->cfg_max_luns; in lpfc_create_port()
4398 shost->this_id = -1; in lpfc_create_port()
4399 shost->max_cmd_len = 16; in lpfc_create_port()
4401 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_create_port()
4402 if (!phba->cfg_fcp_mq_threshold || in lpfc_create_port()
4403 phba->cfg_fcp_mq_threshold > phba->cfg_hdw_queue) in lpfc_create_port()
4404 phba->cfg_fcp_mq_threshold = phba->cfg_hdw_queue; in lpfc_create_port()
4406 shost->nr_hw_queues = min_t(int, 2 * num_possible_nodes(), in lpfc_create_port()
4407 phba->cfg_fcp_mq_threshold); in lpfc_create_port()
4409 shost->dma_boundary = in lpfc_create_port()
4410 phba->sli4_hba.pc_sli4_params.sge_supp_len-1; in lpfc_create_port()
4412 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_create_port()
4413 shost->sg_tablesize = LPFC_MAX_SG_TABLESIZE; in lpfc_create_port()
4415 shost->sg_tablesize = phba->cfg_scsi_seg_cnt; in lpfc_create_port()
4417 /* SLI-3 has a limited number of hardware queues (3), in lpfc_create_port()
4420 shost->nr_hw_queues = 1; in lpfc_create_port()
4427 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_create_port()
4428 if (dev != &phba->pcidev->dev) { in lpfc_create_port()
4429 shost->transportt = lpfc_vport_transport_template; in lpfc_create_port()
4430 vport->port_type = LPFC_NPIV_PORT; in lpfc_create_port()
4432 shost->transportt = lpfc_transport_template; in lpfc_create_port()
4433 vport->port_type = LPFC_PHYSICAL_PORT; in lpfc_create_port()
4439 vport->port_type, shost->sg_tablesize, in lpfc_create_port()
4440 phba->cfg_scsi_seg_cnt, phba->cfg_sg_seg_cnt); in lpfc_create_port()
4443 INIT_LIST_HEAD(&vport->fc_nodes); in lpfc_create_port()
4444 INIT_LIST_HEAD(&vport->rcv_buffer_list); in lpfc_create_port()
4445 spin_lock_init(&vport->work_port_lock); in lpfc_create_port()
4447 timer_setup(&vport->fc_disctmo, lpfc_disc_timeout, 0); in lpfc_create_port()
4449 timer_setup(&vport->els_tmofunc, lpfc_els_timeout, 0); in lpfc_create_port()
4451 timer_setup(&vport->delayed_disc_tmo, lpfc_delayed_disc_tmo, 0); in lpfc_create_port()
4453 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) in lpfc_create_port()
4456 error = scsi_add_host_with_dma(shost, dev, &phba->pcidev->dev); in lpfc_create_port()
4460 spin_lock_irq(&phba->port_list_lock); in lpfc_create_port()
4461 list_add_tail(&vport->listentry, &phba->port_list); in lpfc_create_port()
4462 spin_unlock_irq(&phba->port_list_lock); in lpfc_create_port()
4472 * destroy_port - destroy an FC port
4482 struct lpfc_hba *phba = vport->phba; in destroy_port()
4488 spin_lock_irq(&phba->port_list_lock); in destroy_port()
4489 list_del_init(&vport->listentry); in destroy_port()
4490 spin_unlock_irq(&phba->port_list_lock); in destroy_port()
4497 * lpfc_get_instance - Get a unique integer ID
4503 * instance - a unique integer ID allocated as the new instance.
4504 * -1 - lpfc get instance failed.
4512 return ret < 0 ? -1 : ret; in lpfc_get_instance()
4516 * lpfc_scan_finished - method for SCSI layer to detect whether scan is done
4527 * 0 - SCSI host scan is not over yet.
4528 * 1 - SCSI host scan is over.
4532 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_scan_finished()
4533 struct lpfc_hba *phba = vport->phba; in lpfc_scan_finished()
4536 spin_lock_irq(shost->host_lock); in lpfc_scan_finished()
4538 if (vport->load_flag & FC_UNLOADING) { in lpfc_scan_finished()
4550 phba->link_state <= LPFC_LINK_DOWN) { in lpfc_scan_finished()
4558 if (vport->port_state != LPFC_VPORT_READY) in lpfc_scan_finished()
4560 if (vport->num_disc_nodes || vport->fc_prli_sent) in lpfc_scan_finished()
4562 if (vport->fc_map_cnt == 0 && time < msecs_to_jiffies(2 * 1000)) in lpfc_scan_finished()
4564 if ((phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) != 0) in lpfc_scan_finished()
4570 spin_unlock_irq(shost->host_lock); in lpfc_scan_finished()
4576 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; in lpfc_host_supported_speeds_set()
4577 struct lpfc_hba *phba = vport->phba; in lpfc_host_supported_speeds_set()
4584 if (phba->hba_flag & HBA_FCOE_MODE) in lpfc_host_supported_speeds_set()
4587 if (phba->lmt & LMT_128Gb) in lpfc_host_supported_speeds_set()
4589 if (phba->lmt & LMT_64Gb) in lpfc_host_supported_speeds_set()
4591 if (phba->lmt & LMT_32Gb) in lpfc_host_supported_speeds_set()
4593 if (phba->lmt & LMT_16Gb) in lpfc_host_supported_speeds_set()
4595 if (phba->lmt & LMT_10Gb) in lpfc_host_supported_speeds_set()
4597 if (phba->lmt & LMT_8Gb) in lpfc_host_supported_speeds_set()
4599 if (phba->lmt & LMT_4Gb) in lpfc_host_supported_speeds_set()
4601 if (phba->lmt & LMT_2Gb) in lpfc_host_supported_speeds_set()
4603 if (phba->lmt & LMT_1Gb) in lpfc_host_supported_speeds_set()
4608 * lpfc_host_attrib_init - Initialize SCSI host attributes on a FC port
4616 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_host_attrib_init()
4617 struct lpfc_hba *phba = vport->phba; in lpfc_host_attrib_init()
4622 fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); in lpfc_host_attrib_init()
4623 fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); in lpfc_host_attrib_init()
4637 (((uint32_t) vport->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) | in lpfc_host_attrib_init()
4638 (uint32_t) vport->fc_sparam.cmn.bbRcvSizeLsb; in lpfc_host_attrib_init()
4640 fc_host_dev_loss_tmo(shost) = vport->cfg_devloss_tmo; in lpfc_host_attrib_init()
4648 fc_host_max_npiv_vports(shost) = phba->max_vpi; in lpfc_host_attrib_init()
4649 spin_lock_irq(shost->host_lock); in lpfc_host_attrib_init()
4650 vport->load_flag &= ~FC_LOADING; in lpfc_host_attrib_init()
4651 spin_unlock_irq(shost->host_lock); in lpfc_host_attrib_init()
4655 * lpfc_stop_port_s3 - Stop SLI3 device port
4666 writel(0, phba->HCregaddr); in lpfc_stop_port_s3()
4667 readl(phba->HCregaddr); /* flush */ in lpfc_stop_port_s3()
4669 writel(0xffffffff, phba->HAregaddr); in lpfc_stop_port_s3()
4670 readl(phba->HAregaddr); /* flush */ in lpfc_stop_port_s3()
4674 phba->pport->work_port_events = 0; in lpfc_stop_port_s3()
4678 * lpfc_stop_port_s4 - Stop SLI4 device port
4690 if (phba->pport) in lpfc_stop_port_s4()
4691 phba->pport->work_port_events = 0; in lpfc_stop_port_s4()
4692 phba->sli4_hba.intr_enable = 0; in lpfc_stop_port_s4()
4696 * lpfc_stop_port - Wrapper function for stopping hba port
4705 phba->lpfc_stop_port(phba); in lpfc_stop_port()
4707 if (phba->wq) in lpfc_stop_port()
4708 flush_workqueue(phba->wq); in lpfc_stop_port()
4712 * lpfc_fcf_redisc_wait_start_timer - Start fcf rediscover wait timer
4723 mod_timer(&phba->fcf.redisc_wait, fcf_redisc_wait_tmo); in lpfc_fcf_redisc_wait_start_timer()
4724 spin_lock_irq(&phba->hbalock); in lpfc_fcf_redisc_wait_start_timer()
4726 phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_SCAN_DONE); in lpfc_fcf_redisc_wait_start_timer()
4728 phba->fcf.fcf_flag |= FCF_REDISC_PEND; in lpfc_fcf_redisc_wait_start_timer()
4729 spin_unlock_irq(&phba->hbalock); in lpfc_fcf_redisc_wait_start_timer()
4733 * lpfc_sli4_fcf_redisc_wait_tmo - FCF table rediscover wait timeout
4748 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
4749 if (!(phba->fcf.fcf_flag & FCF_REDISC_PEND)) { in lpfc_sli4_fcf_redisc_wait_tmo()
4750 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
4754 phba->fcf.fcf_flag &= ~FCF_REDISC_PEND; in lpfc_sli4_fcf_redisc_wait_tmo()
4756 phba->fcf.fcf_flag |= FCF_REDISC_EVT; in lpfc_sli4_fcf_redisc_wait_tmo()
4757 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
4765 * lpfc_sli4_parse_latt_fault - Parse sli4 link-attention link fault code
4769 * This routine is to parse the SLI4 link-attention link fault code.
4790 * lpfc_sli4_parse_latt_type - Parse sli4 link attention type
4811 /* Ignore physical link up events - wait for logical link up */ in lpfc_sli4_parse_latt_type()
4828 * lpfc_sli_port_speed_get - Get sli3 link speed code to link speed
4843 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_sli_port_speed_get()
4844 switch (phba->fc_linkspeed) { in lpfc_sli_port_speed_get()
4867 if (phba->sli4_hba.link_state.logical_speed) in lpfc_sli_port_speed_get()
4869 phba->sli4_hba.link_state.logical_speed; in lpfc_sli_port_speed_get()
4871 link_speed = phba->sli4_hba.link_state.speed; in lpfc_sli_port_speed_get()
4877 * lpfc_sli4_port_speed_parse - Parse async evt link speed code to link speed
4970 * lpfc_sli4_async_link_evt - Process the asynchronous FCoE link event
4990 phba->fcoe_eventtag = acqe_link->event_tag; in lpfc_sli4_async_link_evt()
4991 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_async_link_evt()
5003 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); in lpfc_sli4_async_link_evt()
5004 if (!mp->virt) { in lpfc_sli4_async_link_evt()
5014 phba->sli4_hba.els_wq->pring->flag |= LPFC_STOP_IOCB_EVENT; in lpfc_sli4_async_link_evt()
5017 phba->sli.slistat.link_event++; in lpfc_sli4_async_link_evt()
5021 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_sli4_async_link_evt()
5022 pmb->vport = phba->pport; in lpfc_sli4_async_link_evt()
5025 phba->sli4_hba.link_state.speed = in lpfc_sli4_async_link_evt()
5028 phba->sli4_hba.link_state.duplex = in lpfc_sli4_async_link_evt()
5030 phba->sli4_hba.link_state.status = in lpfc_sli4_async_link_evt()
5032 phba->sli4_hba.link_state.type = in lpfc_sli4_async_link_evt()
5034 phba->sli4_hba.link_state.number = in lpfc_sli4_async_link_evt()
5036 phba->sli4_hba.link_state.fault = in lpfc_sli4_async_link_evt()
5038 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_link_evt()
5042 "2900 Async FC/FCoE Link event - Speed:%dGBit " in lpfc_sli4_async_link_evt()
5045 phba->sli4_hba.link_state.speed, in lpfc_sli4_async_link_evt()
5046 phba->sli4_hba.link_state.topology, in lpfc_sli4_async_link_evt()
5047 phba->sli4_hba.link_state.status, in lpfc_sli4_async_link_evt()
5048 phba->sli4_hba.link_state.type, in lpfc_sli4_async_link_evt()
5049 phba->sli4_hba.link_state.number, in lpfc_sli4_async_link_evt()
5050 phba->sli4_hba.link_state.logical_speed, in lpfc_sli4_async_link_evt()
5051 phba->sli4_hba.link_state.fault); in lpfc_sli4_async_link_evt()
5054 * topology info. Note: Optional for non FC-AL ports. in lpfc_sli4_async_link_evt()
5056 if (!(phba->hba_flag & HBA_FCOE_MODE)) { in lpfc_sli4_async_link_evt()
5068 mb = &pmb->u.mb; in lpfc_sli4_async_link_evt()
5069 mb->mbxStatus = MBX_SUCCESS; in lpfc_sli4_async_link_evt()
5075 la = (struct lpfc_mbx_read_top *) &pmb->u.mb.un.varReadTop; in lpfc_sli4_async_link_evt()
5076 la->eventTag = acqe_link->event_tag; in lpfc_sli4_async_link_evt()
5097 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_async_link_evt()
5101 * lpfc_async_link_speed_to_read_top - Parse async evt link speed code to read
5154 ((phba->trunk_link.link##__idx.state == LPFC_LINK_UP) ?\
5168 phba->sli4_hba.link_state.speed = in lpfc_update_trunk_link_status()
5172 phba->sli4_hba.link_state.logical_speed = in lpfc_update_trunk_link_status()
5175 phba->fc_linkspeed = in lpfc_update_trunk_link_status()
5181 phba->trunk_link.link0.state = in lpfc_update_trunk_link_status()
5184 phba->trunk_link.link0.fault = port_fault & 0x1 ? err : 0; in lpfc_update_trunk_link_status()
5187 phba->trunk_link.link1.state = in lpfc_update_trunk_link_status()
5190 phba->trunk_link.link1.fault = port_fault & 0x2 ? err : 0; in lpfc_update_trunk_link_status()
5193 phba->trunk_link.link2.state = in lpfc_update_trunk_link_status()
5196 phba->trunk_link.link2.fault = port_fault & 0x4 ? err : 0; in lpfc_update_trunk_link_status()
5199 phba->trunk_link.link3.state = in lpfc_update_trunk_link_status()
5202 phba->trunk_link.link3.fault = port_fault & 0x8 ? err : 0; in lpfc_update_trunk_link_status()
5206 "2910 Async FC Trunking Event - Speed:%d\n" in lpfc_update_trunk_link_status()
5209 phba->sli4_hba.link_state.speed, in lpfc_update_trunk_link_status()
5210 phba->sli4_hba.link_state.logical_speed, in lpfc_update_trunk_link_status()
5218 * SLI-4: We have only 0xA error codes in lpfc_update_trunk_link_status()
5230 * lpfc_sli4_async_fc_evt - Process the asynchronous FC link event
5262 phba->sli4_hba.link_state.speed = in lpfc_sli4_async_fc_evt()
5265 phba->sli4_hba.link_state.duplex = LPFC_ASYNC_LINK_DUPLEX_FULL; in lpfc_sli4_async_fc_evt()
5266 phba->sli4_hba.link_state.topology = in lpfc_sli4_async_fc_evt()
5268 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
5270 phba->sli4_hba.link_state.type = in lpfc_sli4_async_fc_evt()
5272 phba->sli4_hba.link_state.number = in lpfc_sli4_async_fc_evt()
5274 phba->sli4_hba.link_state.fault = in lpfc_sli4_async_fc_evt()
5279 phba->sli4_hba.link_state.logical_speed = 0; in lpfc_sli4_async_fc_evt()
5280 else if (!phba->sli4_hba.conf_trunk) in lpfc_sli4_async_fc_evt()
5281 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_fc_evt()
5285 "2896 Async FC event - Speed:%dGBaud Topology:x%x " in lpfc_sli4_async_fc_evt()
5288 phba->sli4_hba.link_state.speed, in lpfc_sli4_async_fc_evt()
5289 phba->sli4_hba.link_state.topology, in lpfc_sli4_async_fc_evt()
5290 phba->sli4_hba.link_state.status, in lpfc_sli4_async_fc_evt()
5291 phba->sli4_hba.link_state.type, in lpfc_sli4_async_fc_evt()
5292 phba->sli4_hba.link_state.number, in lpfc_sli4_async_fc_evt()
5293 phba->sli4_hba.link_state.logical_speed, in lpfc_sli4_async_fc_evt()
5294 phba->sli4_hba.link_state.fault); in lpfc_sli4_async_fc_evt()
5295 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_async_fc_evt()
5307 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); in lpfc_sli4_async_fc_evt()
5308 if (!mp->virt) { in lpfc_sli4_async_fc_evt()
5318 phba->sli4_hba.els_wq->pring->flag |= LPFC_STOP_IOCB_EVENT; in lpfc_sli4_async_fc_evt()
5321 phba->sli.slistat.link_event++; in lpfc_sli4_async_fc_evt()
5325 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_sli4_async_fc_evt()
5326 pmb->vport = phba->pport; in lpfc_sli4_async_fc_evt()
5328 if (phba->sli4_hba.link_state.status != LPFC_FC_LA_TYPE_LINK_UP) { in lpfc_sli4_async_fc_evt()
5329 phba->link_flag &= ~(LS_MDS_LINK_DOWN | LS_MDS_LOOPBACK); in lpfc_sli4_async_fc_evt()
5331 switch (phba->sli4_hba.link_state.status) { in lpfc_sli4_async_fc_evt()
5333 phba->link_flag |= LS_MDS_LINK_DOWN; in lpfc_sli4_async_fc_evt()
5336 phba->link_flag |= LS_MDS_LOOPBACK; in lpfc_sli4_async_fc_evt()
5343 mb = &pmb->u.mb; in lpfc_sli4_async_fc_evt()
5344 mb->mbxStatus = MBX_SUCCESS; in lpfc_sli4_async_fc_evt()
5350 la = (struct lpfc_mbx_read_top *)&pmb->u.mb.un.varReadTop; in lpfc_sli4_async_fc_evt()
5351 la->eventTag = acqe_fc->event_tag; in lpfc_sli4_async_fc_evt()
5353 if (phba->sli4_hba.link_state.status == in lpfc_sli4_async_fc_evt()
5375 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_async_fc_evt()
5379 * lpfc_sli4_async_sli_evt - Process the asynchronous SLI link event
5402 "2901 Async SLI event - Type:%d, Event Data: x%08x " in lpfc_sli4_async_sli_evt()
5404 acqe_sli->event_data1, acqe_sli->event_data2, in lpfc_sli4_async_sli_evt()
5405 acqe_sli->reserved, acqe_sli->trailer); in lpfc_sli4_async_sli_evt()
5407 port_name = phba->Port[0]; in lpfc_sli4_async_sli_evt()
5415 temp_event_data.data = (uint32_t)acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
5418 "3190 Over Temperature:%d Celsius- Port Name %c\n", in lpfc_sli4_async_sli_evt()
5419 acqe_sli->event_data1, port_name); in lpfc_sli4_async_sli_evt()
5421 phba->sfp_warning |= LPFC_TRANSGRESSION_HIGH_TEMPERATURE; in lpfc_sli4_async_sli_evt()
5422 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli4_async_sli_evt()
5432 temp_event_data.data = (uint32_t)acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
5435 "3191 Normal Temperature:%d Celsius - Port Name %c\n", in lpfc_sli4_async_sli_evt()
5436 acqe_sli->event_data1, port_name); in lpfc_sli4_async_sli_evt()
5438 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli4_async_sli_evt()
5447 &acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
5450 switch (phba->sli4_hba.lnk_info.lnk_no) { in lpfc_sli4_async_sli_evt()
5453 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
5455 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
5459 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
5461 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
5465 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
5467 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
5471 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
5473 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
5480 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_async_sli_evt()
5485 if (phba->sli4_hba.lnk_info.optic_state == status) in lpfc_sli4_async_sli_evt()
5494 "installed/not installed - Reseat optics, " in lpfc_sli4_async_sli_evt()
5499 "Optics of two types installed - Remove one " in lpfc_sli4_async_sli_evt()
5503 sprintf(message, "Incompatible optics - Replace with " in lpfc_sli4_async_sli_evt()
5507 sprintf(message, "Unqualified optics - Replace with " in lpfc_sli4_async_sli_evt()
5509 "Support - Link is%s operational", in lpfc_sli4_async_sli_evt()
5513 sprintf(message, "Uncertified optics - Replace with " in lpfc_sli4_async_sli_evt()
5514 "Avago-certified optics to enable link " in lpfc_sli4_async_sli_evt()
5515 "operation - Link is%s operational", in lpfc_sli4_async_sli_evt()
5527 phba->lmt = 0; in lpfc_sli4_async_sli_evt()
5535 for (i = 0; i <= phba->max_vports && vports[i] != NULL; in lpfc_sli4_async_sli_evt()
5543 phba->sli4_hba.lnk_info.optic_state = status; in lpfc_sli4_async_sli_evt()
5549 "3192 Remote DPort Test Initiated - " in lpfc_sli4_async_sli_evt()
5551 acqe_sli->event_data1, acqe_sli->event_data2); in lpfc_sli4_async_sli_evt()
5555 * to use FA-WWN, but the attached device doesn’t support it. in lpfc_sli4_async_sli_evt()
5557 * Event Data1 - N.A, Event Data2 - N.A in lpfc_sli4_async_sli_evt()
5560 "2699 Misconfigured FA-WWN - Attached device does " in lpfc_sli4_async_sli_evt()
5561 "not support FA-WWN\n"); in lpfc_sli4_async_sli_evt()
5566 "2518 EEPROM failure - " in lpfc_sli4_async_sli_evt()
5568 acqe_sli->event_data1, acqe_sli->event_data2); in lpfc_sli4_async_sli_evt()
5579 * lpfc_sli4_perform_vport_cvl - Perform clear virtual link on a vport
5597 phba = vport->phba; in lpfc_sli4_perform_vport_cvl()
5607 ndlp->nlp_type |= NLP_FABRIC; in lpfc_sli4_perform_vport_cvl()
5611 /* re-setup ndlp without removing from node list */ in lpfc_sli4_perform_vport_cvl()
5616 if ((phba->pport->port_state < LPFC_FLOGI) && in lpfc_sli4_perform_vport_cvl()
5617 (phba->pport->port_state != LPFC_VPORT_FAILED)) in lpfc_sli4_perform_vport_cvl()
5620 if ((vport != phba->pport) && (vport->port_state < LPFC_FDISC) in lpfc_sli4_perform_vport_cvl()
5621 && (vport->port_state != LPFC_VPORT_FAILED)) in lpfc_sli4_perform_vport_cvl()
5628 spin_lock_irq(shost->host_lock); in lpfc_sli4_perform_vport_cvl()
5629 vport->fc_flag |= FC_VPORT_CVL_RCVD; in lpfc_sli4_perform_vport_cvl()
5630 spin_unlock_irq(shost->host_lock); in lpfc_sli4_perform_vport_cvl()
5636 * lpfc_sli4_perform_all_vport_cvl - Perform clear virtual link on all vports
5650 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) in lpfc_sli4_perform_all_vport_cvl()
5656 * lpfc_sli4_async_fip_evt - Process the asynchronous FCoE FIP event
5675 phba->fc_eventTag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
5676 phba->fcoe_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
5684 acqe_fip->event_tag, in lpfc_sli4_async_fip_evt()
5685 acqe_fip->index); in lpfc_sli4_async_fip_evt()
5691 acqe_fip->event_tag, in lpfc_sli4_async_fip_evt()
5692 acqe_fip->index); in lpfc_sli4_async_fip_evt()
5693 if (phba->fcf.fcf_flag & FCF_DISCOVERY) { in lpfc_sli4_async_fip_evt()
5703 acqe_fip->index); in lpfc_sli4_async_fip_evt()
5704 rc = lpfc_sli4_read_fcf_rec(phba, acqe_fip->index); in lpfc_sli4_async_fip_evt()
5708 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5709 if (phba->hba_flag & FCF_TS_INPROG) { in lpfc_sli4_async_fip_evt()
5710 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5714 if (phba->fcf.fcf_flag & (FCF_REDISC_EVT | FCF_REDISC_PEND)) { in lpfc_sli4_async_fip_evt()
5715 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5720 if (phba->fcf.fcf_flag & FCF_SCAN_DONE) { in lpfc_sli4_async_fip_evt()
5721 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5724 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5726 /* Otherwise, scan the entire FCF table and re-discover SAN */ in lpfc_sli4_async_fip_evt()
5730 acqe_fip->event_tag, acqe_fip->index); in lpfc_sli4_async_fip_evt()
5743 acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
5747 phba->fcoe_cvl_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
5750 "tag:x%x\n", acqe_fip->index, in lpfc_sli4_async_fip_evt()
5751 acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
5756 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5757 if ((phba->fcf.fcf_flag & FCF_DISCOVERY) && in lpfc_sli4_async_fip_evt()
5758 (phba->fcf.current_rec.fcf_indx != acqe_fip->index)) { in lpfc_sli4_async_fip_evt()
5759 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5761 lpfc_sli4_fcf_rr_index_clear(phba, acqe_fip->index); in lpfc_sli4_async_fip_evt()
5764 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5767 if (phba->fcf.current_rec.fcf_indx != acqe_fip->index) in lpfc_sli4_async_fip_evt()
5776 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5778 phba->fcf.fcf_flag |= FCF_DEAD_DISC; in lpfc_sli4_async_fip_evt()
5779 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5784 "\n", acqe_fip->event_tag, acqe_fip->index); in lpfc_sli4_async_fip_evt()
5792 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5793 phba->fcf.fcf_flag &= ~FCF_DEAD_DISC; in lpfc_sli4_async_fip_evt()
5794 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5811 phba->fcoe_cvl_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
5815 " tag 0x%x\n", acqe_fip->index, acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
5818 acqe_fip->index); in lpfc_sli4_async_fip_evt()
5826 for (i = 0; i <= phba->max_vports && vports[i] != NULL; in lpfc_sli4_async_fip_evt()
5828 if ((!(vports[i]->fc_flag & in lpfc_sli4_async_fip_evt()
5830 (vports[i]->port_state > LPFC_FDISC)) { in lpfc_sli4_async_fip_evt()
5839 * Don't re-instantiate if vport is marked for deletion. in lpfc_sli4_async_fip_evt()
5843 if (!(vport->load_flag & FC_UNLOADING) && in lpfc_sli4_async_fip_evt()
5847 * re-instantiate the Vlink using FDISC. in lpfc_sli4_async_fip_evt()
5849 mod_timer(&ndlp->nlp_delayfunc, in lpfc_sli4_async_fip_evt()
5852 spin_lock_irq(shost->host_lock); in lpfc_sli4_async_fip_evt()
5853 ndlp->nlp_flag |= NLP_DELAY_TMO; in lpfc_sli4_async_fip_evt()
5854 spin_unlock_irq(shost->host_lock); in lpfc_sli4_async_fip_evt()
5855 ndlp->nlp_last_elscmd = ELS_CMD_FDISC; in lpfc_sli4_async_fip_evt()
5856 vport->port_state = LPFC_FDISC; in lpfc_sli4_async_fip_evt()
5865 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5866 if (phba->fcf.fcf_flag & FCF_DISCOVERY) { in lpfc_sli4_async_fip_evt()
5867 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5871 phba->fcf.fcf_flag |= FCF_ACVL_DISC; in lpfc_sli4_async_fip_evt()
5872 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5876 "evt_tag:x%x\n", acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
5884 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5885 phba->fcf.fcf_flag &= ~FCF_ACVL_DISC; in lpfc_sli4_async_fip_evt()
5886 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5888 * Last resort will be re-try on the in lpfc_sli4_async_fip_evt()
5903 "0x%x\n", event_type, acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
5909 * lpfc_sli4_async_dcbx_evt - Process the asynchronous dcbx event
5919 phba->fc_eventTag = acqe_dcbx->event_tag; in lpfc_sli4_async_dcbx_evt()
5926 * lpfc_sli4_async_grp5_evt - Process the asynchronous group5 event
5940 phba->fc_eventTag = acqe_grp5->event_tag; in lpfc_sli4_async_grp5_evt()
5941 phba->fcoe_eventtag = acqe_grp5->event_tag; in lpfc_sli4_async_grp5_evt()
5942 prev_ll_spd = phba->sli4_hba.link_state.logical_speed; in lpfc_sli4_async_grp5_evt()
5943 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_grp5_evt()
5948 phba->sli4_hba.link_state.logical_speed); in lpfc_sli4_async_grp5_evt()
5952 * lpfc_sli4_async_event_proc - Process all the pending asynchronous event
5964 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_async_event_proc()
5965 phba->hba_flag &= ~ASYNC_EVENT; in lpfc_sli4_async_event_proc()
5966 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_async_event_proc()
5969 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
5970 while (!list_empty(&phba->sli4_hba.sp_asynce_work_queue)) { in lpfc_sli4_async_event_proc()
5971 list_remove_head(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_async_event_proc()
5973 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, in lpfc_sli4_async_event_proc()
5977 switch (bf_get(lpfc_trailer_code, &cq_event->cqe.mcqe_cmpl)) { in lpfc_sli4_async_event_proc()
5980 &cq_event->cqe.acqe_link); in lpfc_sli4_async_event_proc()
5983 lpfc_sli4_async_fip_evt(phba, &cq_event->cqe.acqe_fip); in lpfc_sli4_async_event_proc()
5987 &cq_event->cqe.acqe_dcbx); in lpfc_sli4_async_event_proc()
5991 &cq_event->cqe.acqe_grp5); in lpfc_sli4_async_event_proc()
5994 lpfc_sli4_async_fc_evt(phba, &cq_event->cqe.acqe_fc); in lpfc_sli4_async_event_proc()
5997 lpfc_sli4_async_sli_evt(phba, &cq_event->cqe.acqe_sli); in lpfc_sli4_async_event_proc()
6004 &cq_event->cqe.mcqe_cmpl)); in lpfc_sli4_async_event_proc()
6010 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
6012 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
6016 * lpfc_sli4_fcf_redisc_event_proc - Process fcf table rediscovery event
6026 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_event_proc()
6028 phba->fcf.fcf_flag &= ~FCF_REDISC_EVT; in lpfc_sli4_fcf_redisc_event_proc()
6030 phba->fcf.failover_rec.flag = 0; in lpfc_sli4_fcf_redisc_event_proc()
6032 phba->fcf.fcf_flag |= FCF_REDISC_FOV; in lpfc_sli4_fcf_redisc_event_proc()
6033 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_event_proc()
6035 /* Scan FCF table from the first entry to re-discover SAN */ in lpfc_sli4_fcf_redisc_event_proc()
6037 "2777 Start post-quiescent FCF table scan\n"); in lpfc_sli4_fcf_redisc_event_proc()
6046 * lpfc_api_table_setup - Set up per hba pci-device group func api jump table
6048 * @dev_grp: The HBA PCI-Device group number.
6050 * This routine is invoked to set up the per HBA PCI-Device group function
6053 * Return: 0 if success, otherwise -ENODEV
6060 /* Set up lpfc PCI-device group */ in lpfc_api_table_setup()
6061 phba->pci_dev_grp = dev_grp; in lpfc_api_table_setup()
6065 phba->sli_rev = LPFC_SLI_REV4; in lpfc_api_table_setup()
6070 return -ENODEV; in lpfc_api_table_setup()
6074 return -ENODEV; in lpfc_api_table_setup()
6078 return -ENODEV; in lpfc_api_table_setup()
6082 return -ENODEV; in lpfc_api_table_setup()
6088 * lpfc_log_intr_mode - Log the active interrupt mode
6108 "0480 Enabled MSI-X interrupt mode.\n"); in lpfc_log_intr_mode()
6119 * lpfc_enable_pci_dev - Enable a generic PCI device.
6126 * 0 - successful
6127 * other values - error
6135 if (!phba->pcidev) in lpfc_enable_pci_dev()
6138 pdev = phba->pcidev; in lpfc_enable_pci_dev()
6152 pdev->needs_freset = 1; in lpfc_enable_pci_dev()
6161 return -ENODEV; in lpfc_enable_pci_dev()
6165 * lpfc_disable_pci_dev - Disable a generic PCI device.
6177 if (!phba->pcidev) in lpfc_disable_pci_dev()
6180 pdev = phba->pcidev; in lpfc_disable_pci_dev()
6189 * lpfc_reset_hba - Reset a hba
6201 if (!phba->cfg_enable_hba_reset) { in lpfc_reset_hba()
6202 phba->link_state = LPFC_HBA_ERROR; in lpfc_reset_hba()
6205 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE) in lpfc_reset_hba()
6216 * lpfc_sli_sriov_nr_virtfn_get - Get the number of sr-iov virtual functions
6219 * This function enables the PCI SR-IOV virtual functions to a physical
6220 * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
6222 * not all devices support SR-IOV, the return code from the pci_enable_sriov()
6228 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_sriov_nr_virtfn_get()
6241 * lpfc_sli_probe_sriov_nr_virtfn - Enable a number of sr-iov virtual functions
6245 * This function enables the PCI SR-IOV virtual functions to a physical
6246 * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
6248 * not all devices support SR-IOV, the return code from the pci_enable_sriov()
6254 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_probe_sriov_nr_virtfn()
6263 return -EINVAL; in lpfc_sli_probe_sriov_nr_virtfn()
6280 * lpfc_setup_driver_resource_phase1 - Phase1 etup driver internal resources.
6287 * 0 - successful
6288 * other values - error
6293 struct lpfc_sli *psli = &phba->sli; in lpfc_setup_driver_resource_phase1()
6298 atomic_set(&phba->fast_event_count, 0); in lpfc_setup_driver_resource_phase1()
6299 atomic_set(&phba->dbg_log_idx, 0); in lpfc_setup_driver_resource_phase1()
6300 atomic_set(&phba->dbg_log_cnt, 0); in lpfc_setup_driver_resource_phase1()
6301 atomic_set(&phba->dbg_log_dmping, 0); in lpfc_setup_driver_resource_phase1()
6302 spin_lock_init(&phba->hbalock); in lpfc_setup_driver_resource_phase1()
6305 spin_lock_init(&phba->ndlp_lock); in lpfc_setup_driver_resource_phase1()
6308 spin_lock_init(&phba->port_list_lock); in lpfc_setup_driver_resource_phase1()
6309 INIT_LIST_HEAD(&phba->port_list); in lpfc_setup_driver_resource_phase1()
6311 INIT_LIST_HEAD(&phba->work_list); in lpfc_setup_driver_resource_phase1()
6312 init_waitqueue_head(&phba->wait_4_mlo_m_q); in lpfc_setup_driver_resource_phase1()
6315 init_waitqueue_head(&phba->work_waitq); in lpfc_setup_driver_resource_phase1()
6319 ((phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ? in lpfc_setup_driver_resource_phase1()
6321 ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) ? in lpfc_setup_driver_resource_phase1()
6323 (phba->nvmet_support ? "NVMET" : " ")); in lpfc_setup_driver_resource_phase1()
6326 spin_lock_init(&phba->scsi_buf_list_get_lock); in lpfc_setup_driver_resource_phase1()
6327 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_get); in lpfc_setup_driver_resource_phase1()
6328 spin_lock_init(&phba->scsi_buf_list_put_lock); in lpfc_setup_driver_resource_phase1()
6329 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_put); in lpfc_setup_driver_resource_phase1()
6332 INIT_LIST_HEAD(&phba->fabric_iocb_list); in lpfc_setup_driver_resource_phase1()
6335 INIT_LIST_HEAD(&phba->elsbuf); in lpfc_setup_driver_resource_phase1()
6338 INIT_LIST_HEAD(&phba->fcf_conn_rec_list); in lpfc_setup_driver_resource_phase1()
6341 spin_lock_init(&phba->devicelock); in lpfc_setup_driver_resource_phase1()
6342 INIT_LIST_HEAD(&phba->luns); in lpfc_setup_driver_resource_phase1()
6345 timer_setup(&psli->mbox_tmo, lpfc_mbox_timeout, 0); in lpfc_setup_driver_resource_phase1()
6347 timer_setup(&phba->fabric_block_timer, lpfc_fabric_block_timeout, 0); in lpfc_setup_driver_resource_phase1()
6349 timer_setup(&phba->eratt_poll, lpfc_poll_eratt, 0); in lpfc_setup_driver_resource_phase1()
6351 timer_setup(&phba->hb_tmofunc, lpfc_hb_timeout, 0); in lpfc_setup_driver_resource_phase1()
6353 INIT_DELAYED_WORK(&phba->eq_delay_work, lpfc_hb_eq_delay_work); in lpfc_setup_driver_resource_phase1()
6355 INIT_DELAYED_WORK(&phba->idle_stat_delay_work, in lpfc_setup_driver_resource_phase1()
6362 * lpfc_sli_driver_resource_setup - Setup driver internal resources for SLI3 dev
6366 * support the SLI-3 HBA device it attached to.
6369 * 0 - successful
6370 * other values - error
6382 timer_setup(&phba->fcp_poll_timer, lpfc_poll_timeout, 0); in lpfc_sli_driver_resource_setup()
6385 phba->work_ha_mask = (HA_ERATT | HA_MBATT | HA_LATT); in lpfc_sli_driver_resource_setup()
6386 phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING * 4)); in lpfc_sli_driver_resource_setup()
6390 /* Set up phase-1 common device driver resources */ in lpfc_sli_driver_resource_setup()
6394 return -ENODEV; in lpfc_sli_driver_resource_setup()
6396 if (phba->pcidev->device == PCI_DEVICE_ID_HORNET) { in lpfc_sli_driver_resource_setup()
6397 phba->menlo_flag |= HBA_MENLO_SUPPORT; in lpfc_sli_driver_resource_setup()
6399 if (phba->cfg_sg_seg_cnt < LPFC_DEFAULT_MENLO_SG_SEG_CNT) in lpfc_sli_driver_resource_setup()
6400 phba->cfg_sg_seg_cnt = LPFC_DEFAULT_MENLO_SG_SEG_CNT; in lpfc_sli_driver_resource_setup()
6403 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
6404 phba->sli.sli3_ring = kcalloc(LPFC_SLI3_MAX_RING, in lpfc_sli_driver_resource_setup()
6407 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
6408 return -ENOMEM; in lpfc_sli_driver_resource_setup()
6415 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_driver_resource_setup()
6421 if (phba->cfg_enable_bg) { in lpfc_sli_driver_resource_setup()
6423 * The scsi_buf for a T10-DIF I/O will hold the FCP cmnd, in lpfc_sli_driver_resource_setup()
6431 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
6435 if (phba->cfg_sg_seg_cnt > LPFC_MAX_SG_SEG_CNT_DIF) in lpfc_sli_driver_resource_setup()
6436 phba->cfg_sg_seg_cnt = LPFC_MAX_SG_SEG_CNT_DIF; in lpfc_sli_driver_resource_setup()
6439 phba->cfg_total_seg_cnt = LPFC_MAX_SG_SEG_CNT; in lpfc_sli_driver_resource_setup()
6446 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
6448 ((phba->cfg_sg_seg_cnt + 2) * entry_sz); in lpfc_sli_driver_resource_setup()
6451 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + 2; in lpfc_sli_driver_resource_setup()
6456 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
6457 phba->cfg_total_seg_cnt); in lpfc_sli_driver_resource_setup()
6459 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli_driver_resource_setup()
6461 phba->max_vports = 0; in lpfc_sli_driver_resource_setup()
6471 return -ENOMEM; in lpfc_sli_driver_resource_setup()
6473 phba->lpfc_sg_dma_buf_pool = in lpfc_sli_driver_resource_setup()
6475 &phba->pcidev->dev, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
6478 if (!phba->lpfc_sg_dma_buf_pool) in lpfc_sli_driver_resource_setup()
6481 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli_driver_resource_setup()
6483 &phba->pcidev->dev, in lpfc_sli_driver_resource_setup()
6488 if (!phba->lpfc_cmd_rsp_buf_pool) in lpfc_sli_driver_resource_setup()
6492 * Enable sr-iov virtual functions if supported and configured in lpfc_sli_driver_resource_setup()
6495 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli_driver_resource_setup()
6497 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
6500 "2808 Requested number of SR-IOV " in lpfc_sli_driver_resource_setup()
6503 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
6504 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli_driver_resource_setup()
6511 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli_driver_resource_setup()
6512 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli_driver_resource_setup()
6515 return -ENOMEM; in lpfc_sli_driver_resource_setup()
6519 * lpfc_sli_driver_resource_unset - Unset drvr internal resources for SLI3 dev
6523 * specific for supporting the SLI-3 HBA device it attached to.
6535 * lpfc_sli4_driver_resource_setup - Setup drvr internal resources for SLI4 dev
6539 * support the SLI-4 HBA device it attached to.
6542 * 0 - successful
6543 * other values - error
6557 phba->sli4_hba.num_present_cpu = lpfc_present_cpu; in lpfc_sli4_driver_resource_setup()
6558 phba->sli4_hba.num_possible_cpu = cpumask_last(cpu_possible_mask) + 1; in lpfc_sli4_driver_resource_setup()
6559 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_setup()
6564 /* Set up phase-1 common device driver resources */ in lpfc_sli4_driver_resource_setup()
6567 return -ENODEV; in lpfc_sli4_driver_resource_setup()
6572 return -ENODEV; in lpfc_sli4_driver_resource_setup()
6577 phba->wq = alloc_workqueue("lpfc_wq", WQ_MEM_RECLAIM, 0); in lpfc_sli4_driver_resource_setup()
6583 timer_setup(&phba->rrq_tmr, lpfc_rrq_timeout, 0); in lpfc_sli4_driver_resource_setup()
6586 timer_setup(&phba->fcf.redisc_wait, lpfc_sli4_fcf_redisc_wait_tmo, 0); in lpfc_sli4_driver_resource_setup()
6589 * Control structure for handling external multi-buffer mailbox in lpfc_sli4_driver_resource_setup()
6590 * command pass-through. in lpfc_sli4_driver_resource_setup()
6592 memset((uint8_t *)&phba->mbox_ext_buf_ctx, 0, in lpfc_sli4_driver_resource_setup()
6594 INIT_LIST_HEAD(&phba->mbox_ext_buf_ctx.ext_dmabuf_list); in lpfc_sli4_driver_resource_setup()
6596 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli4_driver_resource_setup()
6599 phba->max_vports = 0; in lpfc_sli4_driver_resource_setup()
6602 phba->valid_vlan = 0; in lpfc_sli4_driver_resource_setup()
6603 phba->fc_map[0] = LPFC_FCOE_FCF_MAP0; in lpfc_sli4_driver_resource_setup()
6604 phba->fc_map[1] = LPFC_FCOE_FCF_MAP1; in lpfc_sli4_driver_resource_setup()
6605 phba->fc_map[2] = LPFC_FCOE_FCF_MAP2; in lpfc_sli4_driver_resource_setup()
6614 INIT_LIST_HEAD(&phba->hbqs[LPFC_ELS_HBQ].hbq_buffer_list); in lpfc_sli4_driver_resource_setup()
6615 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_sli4_rb_alloc; in lpfc_sli4_driver_resource_setup()
6616 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_sli4_rb_free; in lpfc_sli4_driver_resource_setup()
6622 spin_lock_init(&phba->sli4_hba.abts_io_buf_list_lock); in lpfc_sli4_driver_resource_setup()
6623 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_io_buf_list); in lpfc_sli4_driver_resource_setup()
6625 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
6627 spin_lock_init(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_sli4_driver_resource_setup()
6628 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_driver_resource_setup()
6629 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_io_wait_list); in lpfc_sli4_driver_resource_setup()
6630 spin_lock_init(&phba->sli4_hba.t_active_list_lock); in lpfc_sli4_driver_resource_setup()
6631 INIT_LIST_HEAD(&phba->sli4_hba.t_active_ctx_list); in lpfc_sli4_driver_resource_setup()
6635 spin_lock_init(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_driver_resource_setup()
6636 spin_lock_init(&phba->sli4_hba.nvmet_io_wait_lock); in lpfc_sli4_driver_resource_setup()
6637 spin_lock_init(&phba->sli4_hba.asynce_list_lock); in lpfc_sli4_driver_resource_setup()
6638 spin_lock_init(&phba->sli4_hba.els_xri_abrt_list_lock); in lpfc_sli4_driver_resource_setup()
6641 * Initialize driver internal slow-path work queues in lpfc_sli4_driver_resource_setup()
6644 /* Driver internel slow-path CQ Event pool */ in lpfc_sli4_driver_resource_setup()
6645 INIT_LIST_HEAD(&phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_driver_resource_setup()
6647 INIT_LIST_HEAD(&phba->sli4_hba.sp_queue_event); in lpfc_sli4_driver_resource_setup()
6649 INIT_LIST_HEAD(&phba->sli4_hba.sp_asynce_work_queue); in lpfc_sli4_driver_resource_setup()
6650 /* Slow-path XRI aborted CQ Event work queue list */ in lpfc_sli4_driver_resource_setup()
6651 INIT_LIST_HEAD(&phba->sli4_hba.sp_els_xri_aborted_work_queue); in lpfc_sli4_driver_resource_setup()
6653 INIT_LIST_HEAD(&phba->sli4_hba.sp_unsol_work_queue); in lpfc_sli4_driver_resource_setup()
6656 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_blk_list); in lpfc_sli4_driver_resource_setup()
6657 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_xri_blk_list); in lpfc_sli4_driver_resource_setup()
6658 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_vfi_blk_list); in lpfc_sli4_driver_resource_setup()
6659 INIT_LIST_HEAD(&phba->lpfc_vpi_blk_list); in lpfc_sli4_driver_resource_setup()
6664 INIT_LIST_HEAD(&phba->sli.mboxq); in lpfc_sli4_driver_resource_setup()
6665 INIT_LIST_HEAD(&phba->sli.mboxq_cmpl); in lpfc_sli4_driver_resource_setup()
6668 phba->sli4_hba.lnk_info.optic_state = 0xff; in lpfc_sli4_driver_resource_setup()
6673 return -ENOMEM; in lpfc_sli4_driver_resource_setup()
6676 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_driver_resource_setup()
6680 rc = -ENODEV; in lpfc_sli4_driver_resource_setup()
6683 phba->temp_sensor_support = 1; in lpfc_sli4_driver_resource_setup()
6705 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_driver_resource_setup()
6712 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_sli4_driver_resource_setup()
6715 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
6720 phba->nvmet_support = 0; in lpfc_sli4_driver_resource_setup()
6731 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_driver_resource_setup()
6732 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_driver_resource_setup()
6733 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
6734 rc = -EIO; in lpfc_sli4_driver_resource_setup()
6737 mb = &mboxq->u.mb; in lpfc_sli4_driver_resource_setup()
6738 memcpy(&wwn, (char *)mb->un.varRDnvp.nodename, in lpfc_sli4_driver_resource_setup()
6741 phba->sli4_hba.wwnn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
6742 memcpy(&wwn, (char *)mb->un.varRDnvp.portname, in lpfc_sli4_driver_resource_setup()
6746 phba->sli4_hba.wwpn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
6755 phba->nvmet_support = 1; /* a match */ in lpfc_sli4_driver_resource_setup()
6769 phba->cfg_xri_rebalancing = 0; in lpfc_sli4_driver_resource_setup()
6770 if (phba->irq_chann_mode == NHT_MODE) { in lpfc_sli4_driver_resource_setup()
6771 phba->cfg_irq_chann = in lpfc_sli4_driver_resource_setup()
6772 phba->sli4_hba.num_present_cpu; in lpfc_sli4_driver_resource_setup()
6773 phba->cfg_hdw_queue = in lpfc_sli4_driver_resource_setup()
6774 phba->sli4_hba.num_present_cpu; in lpfc_sli4_driver_resource_setup()
6775 phba->irq_chann_mode = NORMAL_MODE; in lpfc_sli4_driver_resource_setup()
6792 &phba->sli4_hba.sli_intf); in lpfc_sli4_driver_resource_setup()
6794 &phba->sli4_hba.sli_intf); in lpfc_sli4_driver_resource_setup()
6795 if (phba->sli4_hba.extents_in_use && in lpfc_sli4_driver_resource_setup()
6796 phba->sli4_hba.rpi_hdrs_in_use) { in lpfc_sli4_driver_resource_setup()
6802 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
6803 rc = -EIO; in lpfc_sli4_driver_resource_setup()
6809 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
6810 rc = -EIO; in lpfc_sli4_driver_resource_setup()
6820 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_driver_resource_setup()
6834 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) { in lpfc_sli4_driver_resource_setup()
6838 * The scsi_buf for a T10-DIF I/O holds the FCP cmnd, in lpfc_sli4_driver_resource_setup()
6846 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli4_driver_resource_setup()
6850 phba->cfg_total_seg_cnt = LPFC_MAX_SGL_SEG_CNT; in lpfc_sli4_driver_resource_setup()
6856 if (phba->cfg_enable_bg && in lpfc_sli4_driver_resource_setup()
6857 phba->cfg_sg_seg_cnt > LPFC_MAX_BG_SLI4_SEG_CNT_DIF) in lpfc_sli4_driver_resource_setup()
6858 phba->cfg_scsi_seg_cnt = LPFC_MAX_BG_SLI4_SEG_CNT_DIF; in lpfc_sli4_driver_resource_setup()
6860 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
6868 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli4_driver_resource_setup()
6870 ((phba->cfg_sg_seg_cnt + extra) * in lpfc_sli4_driver_resource_setup()
6874 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + extra; in lpfc_sli4_driver_resource_setup()
6875 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
6878 * NOTE: if (phba->cfg_sg_seg_cnt + extra) <= 256 we only in lpfc_sli4_driver_resource_setup()
6883 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_driver_resource_setup()
6884 phba->cfg_sg_dma_buf_size = LPFC_DEFAULT_XPSGL_SIZE; in lpfc_sli4_driver_resource_setup()
6885 else if (phba->cfg_sg_dma_buf_size <= LPFC_MIN_SG_SLI4_BUF_SZ) in lpfc_sli4_driver_resource_setup()
6886 phba->cfg_sg_dma_buf_size = LPFC_MIN_SG_SLI4_BUF_SZ; in lpfc_sli4_driver_resource_setup()
6888 phba->cfg_sg_dma_buf_size = in lpfc_sli4_driver_resource_setup()
6889 SLI4_PAGE_ALIGN(phba->cfg_sg_dma_buf_size); in lpfc_sli4_driver_resource_setup()
6891 phba->border_sge_num = phba->cfg_sg_dma_buf_size / in lpfc_sli4_driver_resource_setup()
6895 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
6896 if (phba->cfg_sg_seg_cnt > LPFC_MAX_NVME_SEG_CNT) { in lpfc_sli4_driver_resource_setup()
6901 phba->cfg_nvme_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_sli4_driver_resource_setup()
6903 phba->cfg_nvme_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
6909 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
6910 phba->cfg_total_seg_cnt, phba->cfg_scsi_seg_cnt, in lpfc_sli4_driver_resource_setup()
6911 phba->cfg_nvme_seg_cnt); in lpfc_sli4_driver_resource_setup()
6913 if (phba->cfg_sg_dma_buf_size < SLI4_PAGE_SIZE) in lpfc_sli4_driver_resource_setup()
6914 i = phba->cfg_sg_dma_buf_size; in lpfc_sli4_driver_resource_setup()
6918 phba->lpfc_sg_dma_buf_pool = in lpfc_sli4_driver_resource_setup()
6920 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
6921 phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
6923 if (!phba->lpfc_sg_dma_buf_pool) in lpfc_sli4_driver_resource_setup()
6926 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli4_driver_resource_setup()
6928 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
6932 if (!phba->lpfc_cmd_rsp_buf_pool) in lpfc_sli4_driver_resource_setup()
6935 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
6971 longs = (LPFC_SLI4_FCF_TBL_INDX_MAX + BITS_PER_LONG - 1)/BITS_PER_LONG; in lpfc_sli4_driver_resource_setup()
6972 phba->fcf.fcf_rr_bmask = kcalloc(longs, sizeof(unsigned long), in lpfc_sli4_driver_resource_setup()
6974 if (!phba->fcf.fcf_rr_bmask) { in lpfc_sli4_driver_resource_setup()
6978 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
6982 phba->sli4_hba.hba_eq_hdl = kcalloc(phba->cfg_irq_chann, in lpfc_sli4_driver_resource_setup()
6985 if (!phba->sli4_hba.hba_eq_hdl) { in lpfc_sli4_driver_resource_setup()
6988 "fast-path per-EQ handle array\n"); in lpfc_sli4_driver_resource_setup()
6989 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
6993 phba->sli4_hba.cpu_map = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
6996 if (!phba->sli4_hba.cpu_map) { in lpfc_sli4_driver_resource_setup()
6998 "3327 Failed allocate memory for msi-x " in lpfc_sli4_driver_resource_setup()
7000 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
7004 phba->sli4_hba.eq_info = alloc_percpu(struct lpfc_eq_intr_info); in lpfc_sli4_driver_resource_setup()
7005 if (!phba->sli4_hba.eq_info) { in lpfc_sli4_driver_resource_setup()
7008 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
7012 phba->sli4_hba.idle_stat = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
7013 sizeof(*phba->sli4_hba.idle_stat), in lpfc_sli4_driver_resource_setup()
7015 if (!phba->sli4_hba.idle_stat) { in lpfc_sli4_driver_resource_setup()
7018 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
7023 phba->sli4_hba.c_stat = alloc_percpu(struct lpfc_hdwq_stat); in lpfc_sli4_driver_resource_setup()
7024 if (!phba->sli4_hba.c_stat) { in lpfc_sli4_driver_resource_setup()
7026 "3332 Failed allocating per cpu hdwq stats\n"); in lpfc_sli4_driver_resource_setup()
7027 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
7033 * Enable sr-iov virtual functions if supported and configured in lpfc_sli4_driver_resource_setup()
7036 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli4_driver_resource_setup()
7038 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
7041 "3020 Requested number of SR-IOV " in lpfc_sli4_driver_resource_setup()
7044 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
7045 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli4_driver_resource_setup()
7053 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_setup()
7056 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_setup()
7058 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_setup()
7060 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_setup()
7062 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_setup()
7070 dma_pool_destroy(phba->lpfc_cmd_rsp_buf_pool); in lpfc_sli4_driver_resource_setup()
7071 phba->lpfc_cmd_rsp_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
7073 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli4_driver_resource_setup()
7074 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
7083 * lpfc_sli4_driver_resource_unset - Unset drvr internal resources for SLI4 dev
7087 * specific for supporting the SLI-4 HBA device it attached to.
7094 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_unset()
7096 free_percpu(phba->sli4_hba.c_stat); in lpfc_sli4_driver_resource_unset()
7098 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_unset()
7100 /* Free memory allocated for msi-x interrupt vector to CPU mapping */ in lpfc_sli4_driver_resource_unset()
7101 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_unset()
7102 phba->sli4_hba.num_possible_cpu = 0; in lpfc_sli4_driver_resource_unset()
7103 phba->sli4_hba.num_present_cpu = 0; in lpfc_sli4_driver_resource_unset()
7104 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_unset()
7105 cpumask_clear(&phba->sli4_hba.irq_aff_mask); in lpfc_sli4_driver_resource_unset()
7107 /* Free memory allocated for fast-path work queue handles */ in lpfc_sli4_driver_resource_unset()
7108 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_unset()
7115 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_unset()
7137 &phba->fcf_conn_rec_list, list) { in lpfc_sli4_driver_resource_unset()
7138 list_del_init(&conn_entry->list); in lpfc_sli4_driver_resource_unset()
7146 * lpfc_init_api_table_setup - Set up init api function jump table
7148 * @dev_grp: The HBA PCI-Device group number.
7153 * Returns: 0 - success, -ENODEV - failure.
7158 phba->lpfc_hba_init_link = lpfc_hba_init_link; in lpfc_init_api_table_setup()
7159 phba->lpfc_hba_down_link = lpfc_hba_down_link; in lpfc_init_api_table_setup()
7160 phba->lpfc_selective_reset = lpfc_selective_reset; in lpfc_init_api_table_setup()
7163 phba->lpfc_hba_down_post = lpfc_hba_down_post_s3; in lpfc_init_api_table_setup()
7164 phba->lpfc_handle_eratt = lpfc_handle_eratt_s3; in lpfc_init_api_table_setup()
7165 phba->lpfc_stop_port = lpfc_stop_port_s3; in lpfc_init_api_table_setup()
7168 phba->lpfc_hba_down_post = lpfc_hba_down_post_s4; in lpfc_init_api_table_setup()
7169 phba->lpfc_handle_eratt = lpfc_handle_eratt_s4; in lpfc_init_api_table_setup()
7170 phba->lpfc_stop_port = lpfc_stop_port_s4; in lpfc_init_api_table_setup()
7174 "1431 Invalid HBA PCI-device group: 0x%x\n", in lpfc_init_api_table_setup()
7176 return -ENODEV; in lpfc_init_api_table_setup()
7183 * lpfc_setup_driver_resource_phase2 - Phase2 setup driver internal resources.
7190 * 0 - successful
7191 * other values - error
7199 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_setup_driver_resource_phase2()
7200 "lpfc_worker_%d", phba->brd_no); in lpfc_setup_driver_resource_phase2()
7201 if (IS_ERR(phba->worker_thread)) { in lpfc_setup_driver_resource_phase2()
7202 error = PTR_ERR(phba->worker_thread); in lpfc_setup_driver_resource_phase2()
7210 * lpfc_unset_driver_resource_phase2 - Phase2 unset driver internal resources.
7220 if (phba->wq) { in lpfc_unset_driver_resource_phase2()
7221 flush_workqueue(phba->wq); in lpfc_unset_driver_resource_phase2()
7222 destroy_workqueue(phba->wq); in lpfc_unset_driver_resource_phase2()
7223 phba->wq = NULL; in lpfc_unset_driver_resource_phase2()
7227 if (phba->worker_thread) in lpfc_unset_driver_resource_phase2()
7228 kthread_stop(phba->worker_thread); in lpfc_unset_driver_resource_phase2()
7232 * lpfc_free_iocb_list - Free iocb list.
7242 spin_lock_irq(&phba->hbalock); in lpfc_free_iocb_list()
7244 &phba->lpfc_iocb_list, list) { in lpfc_free_iocb_list()
7245 list_del(&iocbq_entry->list); in lpfc_free_iocb_list()
7247 phba->total_iocbq_bufs--; in lpfc_free_iocb_list()
7249 spin_unlock_irq(&phba->hbalock); in lpfc_free_iocb_list()
7255 * lpfc_init_iocb_list - Allocate and initialize iocb list.
7263 * 0 - successful
7264 * other values - error
7274 INIT_LIST_HEAD(&phba->lpfc_iocb_list); in lpfc_init_iocb_list()
7291 iocbq_entry->sli4_lxritag = NO_XRI; in lpfc_init_iocb_list()
7292 iocbq_entry->sli4_xritag = NO_XRI; in lpfc_init_iocb_list()
7294 spin_lock_irq(&phba->hbalock); in lpfc_init_iocb_list()
7295 list_add(&iocbq_entry->list, &phba->lpfc_iocb_list); in lpfc_init_iocb_list()
7296 phba->total_iocbq_bufs++; in lpfc_init_iocb_list()
7297 spin_unlock_irq(&phba->hbalock); in lpfc_init_iocb_list()
7305 return -ENOMEM; in lpfc_init_iocb_list()
7309 * lpfc_free_sgl_list - Free a given sgl list.
7321 list_del(&sglq_entry->list); in lpfc_free_sgl_list()
7322 lpfc_mbuf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_sgl_list()
7328 * lpfc_free_els_sgl_list - Free els sgl list.
7339 spin_lock_irq(&phba->hbalock); in lpfc_free_els_sgl_list()
7340 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
7341 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, &sglq_list); in lpfc_free_els_sgl_list()
7342 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
7343 spin_unlock_irq(&phba->hbalock); in lpfc_free_els_sgl_list()
7350 * lpfc_free_nvmet_sgl_list - Free nvmet sgl list.
7362 spin_lock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
7363 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
7364 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, &sglq_list); in lpfc_free_nvmet_sgl_list()
7365 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
7366 spin_unlock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
7370 list_del(&sglq_entry->list); in lpfc_free_nvmet_sgl_list()
7371 lpfc_nvmet_buf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_nvmet_sgl_list()
7379 phba->sli4_hba.nvmet_xri_cnt = 0; in lpfc_free_nvmet_sgl_list()
7383 * lpfc_init_active_sgl_array - Allocate the buf to track active ELS XRIs.
7394 size *= phba->sli4_hba.max_cfg_param.max_xri; in lpfc_init_active_sgl_array()
7396 phba->sli4_hba.lpfc_sglq_active_list = in lpfc_init_active_sgl_array()
7398 if (!phba->sli4_hba.lpfc_sglq_active_list) in lpfc_init_active_sgl_array()
7399 return -ENOMEM; in lpfc_init_active_sgl_array()
7404 * lpfc_free_active_sgl - Free the buf that tracks active ELS XRIs.
7414 kfree(phba->sli4_hba.lpfc_sglq_active_list); in lpfc_free_active_sgl()
7418 * lpfc_init_sgl_list - Allocate and initialize sgl list.
7429 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_els_sgl_list); in lpfc_init_sgl_list()
7430 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_init_sgl_list()
7431 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_init_sgl_list()
7432 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_init_sgl_list()
7434 /* els xri-sgl book keeping */ in lpfc_init_sgl_list()
7435 phba->sli4_hba.els_xri_cnt = 0; in lpfc_init_sgl_list()
7437 /* nvme xri-buffer book keeping */ in lpfc_init_sgl_list()
7438 phba->sli4_hba.io_xri_cnt = 0; in lpfc_init_sgl_list()
7442 * lpfc_sli4_init_rpi_hdrs - Post the rpi header memory region to the port
7452 * 0 - successful
7453 * -ERROR - otherwise.
7461 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_init_rpi_hdrs()
7462 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_init_rpi_hdrs()
7464 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_init_rpi_hdrs()
7465 return -EIO; in lpfc_sli4_init_rpi_hdrs()
7472 rc = -ENODEV; in lpfc_sli4_init_rpi_hdrs()
7479 * lpfc_sli4_create_rpi_hdr - Allocate an rpi header memory region
7503 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_create_rpi_hdr()
7505 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_create_rpi_hdr()
7509 rpi_limit = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_create_rpi_hdr()
7511 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
7517 curr_rpi_range = phba->sli4_hba.next_rpi; in lpfc_sli4_create_rpi_hdr()
7518 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
7526 * port expects a 4KB DMA-mapped memory region that is 4K aligned. in lpfc_sli4_create_rpi_hdr()
7532 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_create_rpi_hdr()
7534 &dmabuf->phys, GFP_KERNEL); in lpfc_sli4_create_rpi_hdr()
7535 if (!dmabuf->virt) { in lpfc_sli4_create_rpi_hdr()
7540 if (!IS_ALIGNED(dmabuf->phys, LPFC_HDR_TEMPLATE_SIZE)) { in lpfc_sli4_create_rpi_hdr()
7550 rpi_hdr->dmabuf = dmabuf; in lpfc_sli4_create_rpi_hdr()
7551 rpi_hdr->len = LPFC_HDR_TEMPLATE_SIZE; in lpfc_sli4_create_rpi_hdr()
7552 rpi_hdr->page_count = 1; in lpfc_sli4_create_rpi_hdr()
7553 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
7556 rpi_hdr->start_rpi = curr_rpi_range; in lpfc_sli4_create_rpi_hdr()
7557 rpi_hdr->next_rpi = phba->sli4_hba.next_rpi + LPFC_RPI_HDR_COUNT; in lpfc_sli4_create_rpi_hdr()
7558 list_add_tail(&rpi_hdr->list, &phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_create_rpi_hdr()
7560 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
7564 dma_free_coherent(&phba->pcidev->dev, LPFC_HDR_TEMPLATE_SIZE, in lpfc_sli4_create_rpi_hdr()
7565 dmabuf->virt, dmabuf->phys); in lpfc_sli4_create_rpi_hdr()
7572 * lpfc_sli4_remove_rpi_hdrs - Remove all rpi header memory regions
7585 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_remove_rpi_hdrs()
7589 &phba->sli4_hba.lpfc_rpi_hdr_list, list) { in lpfc_sli4_remove_rpi_hdrs()
7590 list_del(&rpi_hdr->list); in lpfc_sli4_remove_rpi_hdrs()
7591 dma_free_coherent(&phba->pcidev->dev, rpi_hdr->len, in lpfc_sli4_remove_rpi_hdrs()
7592 rpi_hdr->dmabuf->virt, rpi_hdr->dmabuf->phys); in lpfc_sli4_remove_rpi_hdrs()
7593 kfree(rpi_hdr->dmabuf); in lpfc_sli4_remove_rpi_hdrs()
7598 phba->sli4_hba.next_rpi = 0; in lpfc_sli4_remove_rpi_hdrs()
7602 * lpfc_hba_alloc - Allocate driver hba data structure for a device.
7610 * pointer to @phba - successful
7611 * NULL - error
7621 dev_err(&pdev->dev, "failed to allocate hba struct\n"); in lpfc_hba_alloc()
7626 phba->pcidev = pdev; in lpfc_hba_alloc()
7629 phba->brd_no = lpfc_get_instance(); in lpfc_hba_alloc()
7630 if (phba->brd_no < 0) { in lpfc_hba_alloc()
7634 phba->eratt_poll_interval = LPFC_ERATT_POLL_INTERVAL; in lpfc_hba_alloc()
7636 spin_lock_init(&phba->ct_ev_lock); in lpfc_hba_alloc()
7637 INIT_LIST_HEAD(&phba->ct_ev_waiters); in lpfc_hba_alloc()
7643 * lpfc_hba_free - Free driver hba data structure with a device.
7652 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_hba_free()
7653 kfree(phba->sli4_hba.hdwq); in lpfc_hba_free()
7656 idr_remove(&lpfc_hba_index, phba->brd_no); in lpfc_hba_free()
7659 kfree(phba->sli.sli3_ring); in lpfc_hba_free()
7660 phba->sli.sli3_ring = NULL; in lpfc_hba_free()
7667 * lpfc_create_shost - Create hba physical port with associated scsi host.
7674 * 0 - successful
7675 * other values - error
7684 phba->fc_edtov = FF_DEF_EDTOV; in lpfc_create_shost()
7685 phba->fc_ratov = FF_DEF_RATOV; in lpfc_create_shost()
7686 phba->fc_altov = FF_DEF_ALTOV; in lpfc_create_shost()
7687 phba->fc_arbtov = FF_DEF_ARBTOV; in lpfc_create_shost()
7689 atomic_set(&phba->sdev_cnt, 0); in lpfc_create_shost()
7690 vport = lpfc_create_port(phba, phba->brd_no, &phba->pcidev->dev); in lpfc_create_shost()
7692 return -ENODEV; in lpfc_create_shost()
7695 phba->pport = vport; in lpfc_create_shost()
7697 if (phba->nvmet_support) { in lpfc_create_shost()
7699 phba->targetport = NULL; in lpfc_create_shost()
7700 phba->cfg_enable_fc4_type = LPFC_ENABLE_NVME; in lpfc_create_shost()
7707 pci_set_drvdata(phba->pcidev, shost); in lpfc_create_shost()
7713 vport->load_flag |= FC_ALLOW_FDMI; in lpfc_create_shost()
7714 if (phba->cfg_enable_SmartSAN || in lpfc_create_shost()
7715 (phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT)) { in lpfc_create_shost()
7718 vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR; in lpfc_create_shost()
7719 if (phba->cfg_enable_SmartSAN) in lpfc_create_shost()
7720 vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR; in lpfc_create_shost()
7722 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR; in lpfc_create_shost()
7728 * lpfc_destroy_shost - Destroy hba physical port with associated scsi host.
7737 struct lpfc_vport *vport = phba->pport; in lpfc_destroy_shost()
7746 * lpfc_setup_bg - Setup Block guard structures and debug areas.
7759 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
7764 old_mask = phba->cfg_prot_mask; in lpfc_setup_bg()
7765 old_guard = phba->cfg_prot_guard; in lpfc_setup_bg()
7768 phba->cfg_prot_mask &= (SHOST_DIF_TYPE1_PROTECTION | in lpfc_setup_bg()
7771 phba->cfg_prot_guard &= (SHOST_DIX_GUARD_IP | in lpfc_setup_bg()
7775 if (phba->cfg_prot_mask == SHOST_DIX_TYPE1_PROTECTION) in lpfc_setup_bg()
7776 phba->cfg_prot_mask |= SHOST_DIF_TYPE1_PROTECTION; in lpfc_setup_bg()
7778 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
7779 if ((old_mask != phba->cfg_prot_mask) || in lpfc_setup_bg()
7780 (old_guard != phba->cfg_prot_guard)) in lpfc_setup_bg()
7784 phba->cfg_prot_mask, in lpfc_setup_bg()
7785 phba->cfg_prot_guard); in lpfc_setup_bg()
7787 scsi_host_set_prot(shost, phba->cfg_prot_mask); in lpfc_setup_bg()
7788 scsi_host_set_guard(shost, phba->cfg_prot_guard); in lpfc_setup_bg()
7798 * lpfc_post_init_setup - Perform necessary device post initialization setup.
7811 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_post_init_setup()
7817 shost = pci_get_drvdata(phba->pcidev); in lpfc_post_init_setup()
7818 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_post_init_setup()
7822 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_post_init_setup()
7823 spin_lock_irq(shost->host_lock); in lpfc_post_init_setup()
7825 spin_unlock_irq(shost->host_lock); in lpfc_post_init_setup()
7841 * lpfc_sli_pci_mem_setup - Setup SLI3 HBA PCI memory space.
7845 * with SLI-3 interface spec.
7848 * 0 - successful
7849 * other values - error
7854 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_pci_mem_setup()
7861 return -ENODEV; in lpfc_sli_pci_mem_setup()
7864 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli_pci_mem_setup()
7866 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli_pci_mem_setup()
7869 error = -ENODEV; in lpfc_sli_pci_mem_setup()
7874 phba->pci_bar0_map = pci_resource_start(pdev, 0); in lpfc_sli_pci_mem_setup()
7877 phba->pci_bar2_map = pci_resource_start(pdev, 2); in lpfc_sli_pci_mem_setup()
7881 phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli_pci_mem_setup()
7882 if (!phba->slim_memmap_p) { in lpfc_sli_pci_mem_setup()
7883 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
7889 phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli_pci_mem_setup()
7890 if (!phba->ctrl_regs_memmap_p) { in lpfc_sli_pci_mem_setup()
7891 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
7896 /* Allocate memory for SLI-2 structures */ in lpfc_sli_pci_mem_setup()
7897 phba->slim2p.virt = dma_alloc_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
7898 &phba->slim2p.phys, GFP_KERNEL); in lpfc_sli_pci_mem_setup()
7899 if (!phba->slim2p.virt) in lpfc_sli_pci_mem_setup()
7902 phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx); in lpfc_sli_pci_mem_setup()
7903 phba->mbox_ext = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
7905 phba->pcb = (phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, pcb)); in lpfc_sli_pci_mem_setup()
7906 phba->IOCBs = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
7909 phba->hbqslimp.virt = dma_alloc_coherent(&pdev->dev, in lpfc_sli_pci_mem_setup()
7911 &phba->hbqslimp.phys, in lpfc_sli_pci_mem_setup()
7913 if (!phba->hbqslimp.virt) in lpfc_sli_pci_mem_setup()
7917 ptr = phba->hbqslimp.virt; in lpfc_sli_pci_mem_setup()
7919 phba->hbqs[i].hbq_virt = ptr; in lpfc_sli_pci_mem_setup()
7920 INIT_LIST_HEAD(&phba->hbqs[i].hbq_buffer_list); in lpfc_sli_pci_mem_setup()
7921 ptr += (lpfc_hbq_defs[i]->entry_count * in lpfc_sli_pci_mem_setup()
7924 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_els_hbq_alloc; in lpfc_sli_pci_mem_setup()
7925 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_els_hbq_free; in lpfc_sli_pci_mem_setup()
7927 memset(phba->hbqslimp.virt, 0, lpfc_sli_hbq_size()); in lpfc_sli_pci_mem_setup()
7929 phba->MBslimaddr = phba->slim_memmap_p; in lpfc_sli_pci_mem_setup()
7930 phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
7931 phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
7932 phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; in lpfc_sli_pci_mem_setup()
7933 phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; in lpfc_sli_pci_mem_setup()
7938 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
7939 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_setup()
7941 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_setup()
7943 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_setup()
7949 * lpfc_sli_pci_mem_unset - Unset SLI3 HBA PCI memory space.
7953 * with SLI-3 interface spec.
7961 if (!phba->pcidev) in lpfc_sli_pci_mem_unset()
7964 pdev = phba->pcidev; in lpfc_sli_pci_mem_unset()
7967 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_sli_pci_mem_unset()
7968 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_sli_pci_mem_unset()
7969 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_unset()
7970 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_unset()
7973 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_unset()
7974 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_unset()
7980 * lpfc_sli4_post_status_check - Wait for SLI4 POST done and check status
7986 * Return 0 if successful, otherwise -ENODEV.
7998 if (!phba->sli4_hba.PSMPHRregaddr) in lpfc_sli4_post_status_check()
7999 return -ENODEV; in lpfc_sli4_post_status_check()
8003 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_sli4_post_status_check()
8007 port_error = -ENODEV; in lpfc_sli4_post_status_check()
8022 "1408 Port Failed POST - portsmphr=0x%x, " in lpfc_sli4_post_status_check()
8040 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
8042 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
8044 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
8046 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
8048 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
8050 &phba->sli4_hba.sli_intf)); in lpfc_sli4_post_status_check()
8057 &phba->sli4_hba.sli_intf); in lpfc_sli4_post_status_check()
8060 phba->sli4_hba.ue_mask_lo = in lpfc_sli4_post_status_check()
8061 readl(phba->sli4_hba.u.if_type0.UEMASKLOregaddr); in lpfc_sli4_post_status_check()
8062 phba->sli4_hba.ue_mask_hi = in lpfc_sli4_post_status_check()
8063 readl(phba->sli4_hba.u.if_type0.UEMASKHIregaddr); in lpfc_sli4_post_status_check()
8065 readl(phba->sli4_hba.u.if_type0.UERRLOregaddr); in lpfc_sli4_post_status_check()
8067 readl(phba->sli4_hba.u.if_type0.UERRHIregaddr); in lpfc_sli4_post_status_check()
8068 if ((~phba->sli4_hba.ue_mask_lo & uerrlo_reg.word0) || in lpfc_sli4_post_status_check()
8069 (~phba->sli4_hba.ue_mask_hi & uerrhi_reg.word0)) { in lpfc_sli4_post_status_check()
8080 phba->sli4_hba.ue_mask_lo, in lpfc_sli4_post_status_check()
8081 phba->sli4_hba.ue_mask_hi); in lpfc_sli4_post_status_check()
8082 port_error = -ENODEV; in lpfc_sli4_post_status_check()
8088 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_post_status_check()
8092 phba->work_status[0] = in lpfc_sli4_post_status_check()
8093 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
8095 phba->work_status[1] = in lpfc_sli4_post_status_check()
8096 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
8105 phba->work_status[0], in lpfc_sli4_post_status_check()
8106 phba->work_status[1]); in lpfc_sli4_post_status_check()
8107 port_error = -ENODEV; in lpfc_sli4_post_status_check()
8119 * lpfc_sli4_bar0_register_memmap - Set up SLI4 BAR0 register memory map.
8131 phba->sli4_hba.u.if_type0.UERRLOregaddr = in lpfc_sli4_bar0_register_memmap()
8132 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_LO; in lpfc_sli4_bar0_register_memmap()
8133 phba->sli4_hba.u.if_type0.UERRHIregaddr = in lpfc_sli4_bar0_register_memmap()
8134 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_HI; in lpfc_sli4_bar0_register_memmap()
8135 phba->sli4_hba.u.if_type0.UEMASKLOregaddr = in lpfc_sli4_bar0_register_memmap()
8136 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_LO; in lpfc_sli4_bar0_register_memmap()
8137 phba->sli4_hba.u.if_type0.UEMASKHIregaddr = in lpfc_sli4_bar0_register_memmap()
8138 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_HI; in lpfc_sli4_bar0_register_memmap()
8139 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
8140 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
8143 phba->sli4_hba.u.if_type2.EQDregaddr = in lpfc_sli4_bar0_register_memmap()
8144 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8146 phba->sli4_hba.u.if_type2.ERR1regaddr = in lpfc_sli4_bar0_register_memmap()
8147 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8149 phba->sli4_hba.u.if_type2.ERR2regaddr = in lpfc_sli4_bar0_register_memmap()
8150 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8152 phba->sli4_hba.u.if_type2.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
8153 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8155 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
8156 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8158 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
8159 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
8160 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
8161 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8163 phba->sli4_hba.RQDBregaddr = in lpfc_sli4_bar0_register_memmap()
8164 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8166 phba->sli4_hba.WQDBregaddr = in lpfc_sli4_bar0_register_memmap()
8167 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8169 phba->sli4_hba.CQDBregaddr = in lpfc_sli4_bar0_register_memmap()
8170 phba->sli4_hba.conf_regs_memmap_p + LPFC_EQCQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
8171 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar0_register_memmap()
8172 phba->sli4_hba.MQDBregaddr = in lpfc_sli4_bar0_register_memmap()
8173 phba->sli4_hba.conf_regs_memmap_p + LPFC_MQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
8174 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
8175 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
8178 phba->sli4_hba.u.if_type2.EQDregaddr = in lpfc_sli4_bar0_register_memmap()
8179 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8181 phba->sli4_hba.u.if_type2.ERR1regaddr = in lpfc_sli4_bar0_register_memmap()
8182 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8184 phba->sli4_hba.u.if_type2.ERR2regaddr = in lpfc_sli4_bar0_register_memmap()
8185 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8187 phba->sli4_hba.u.if_type2.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
8188 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8190 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
8191 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8193 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
8194 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8196 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
8197 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
8201 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_bar0_register_memmap()
8202 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar0_register_memmap()
8209 * lpfc_sli4_bar1_register_memmap - Set up SLI4 BAR1 register memory map.
8220 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar1_register_memmap()
8221 phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8223 phba->sli4_hba.ISRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8225 phba->sli4_hba.IMRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8227 phba->sli4_hba.ISCRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8231 phba->sli4_hba.RQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8233 phba->sli4_hba.WQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8235 phba->sli4_hba.CQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8237 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8239 phba->sli4_hba.MQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8245 dev_err(&phba->pcidev->dev, in lpfc_sli4_bar1_register_memmap()
8246 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar1_register_memmap()
8253 * lpfc_sli4_bar2_register_memmap - Set up SLI4 BAR2 register memory map.
8260 * Return 0 if successful, otherwise -ENODEV.
8266 return -ENODEV; in lpfc_sli4_bar2_register_memmap()
8268 phba->sli4_hba.RQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8271 phba->sli4_hba.WQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8274 phba->sli4_hba.CQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8277 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar2_register_memmap()
8278 phba->sli4_hba.MQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8280 phba->sli4_hba.BMBXregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8286 * lpfc_create_bootstrap_mbox - Create the bootstrap mailbox
8290 * region consistent with the SLI-4 interface spec. This
8297 * 0 - successful
8298 * -ENOMEM - could not allocated memory.
8311 return -ENOMEM; in lpfc_create_bootstrap_mbox()
8317 bmbx_size = sizeof(struct lpfc_bmbx_create) + (LPFC_ALIGN_16_BYTE - 1); in lpfc_create_bootstrap_mbox()
8318 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, bmbx_size, in lpfc_create_bootstrap_mbox()
8319 &dmabuf->phys, GFP_KERNEL); in lpfc_create_bootstrap_mbox()
8320 if (!dmabuf->virt) { in lpfc_create_bootstrap_mbox()
8322 return -ENOMEM; in lpfc_create_bootstrap_mbox()
8328 * to be 16-byte aligned. Also align the virtual memory as each in lpfc_create_bootstrap_mbox()
8332 phba->sli4_hba.bmbx.dmabuf = dmabuf; in lpfc_create_bootstrap_mbox()
8333 phba->sli4_hba.bmbx.bmbx_size = bmbx_size; in lpfc_create_bootstrap_mbox()
8335 phba->sli4_hba.bmbx.avirt = PTR_ALIGN(dmabuf->virt, in lpfc_create_bootstrap_mbox()
8337 phba->sli4_hba.bmbx.aphys = ALIGN(dmabuf->phys, in lpfc_create_bootstrap_mbox()
8343 * as two 30-bit addresses. The other data is a bit marking whether in lpfc_create_bootstrap_mbox()
8344 * the 30-bit address is the high or low address. in lpfc_create_bootstrap_mbox()
8348 dma_address = &phba->sli4_hba.bmbx.dma_address; in lpfc_create_bootstrap_mbox()
8349 phys_addr = (uint64_t)phba->sli4_hba.bmbx.aphys; in lpfc_create_bootstrap_mbox()
8351 dma_address->addr_hi = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
8354 pa_addr = (uint32_t) ((phba->sli4_hba.bmbx.aphys >> 4) & 0x3fffffff); in lpfc_create_bootstrap_mbox()
8355 dma_address->addr_lo = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
8361 * lpfc_destroy_bootstrap_mbox - Destroy all bootstrap mailbox resources
8374 dma_free_coherent(&phba->pcidev->dev, in lpfc_destroy_bootstrap_mbox()
8375 phba->sli4_hba.bmbx.bmbx_size, in lpfc_destroy_bootstrap_mbox()
8376 phba->sli4_hba.bmbx.dmabuf->virt, in lpfc_destroy_bootstrap_mbox()
8377 phba->sli4_hba.bmbx.dmabuf->phys); in lpfc_destroy_bootstrap_mbox()
8379 kfree(phba->sli4_hba.bmbx.dmabuf); in lpfc_destroy_bootstrap_mbox()
8380 memset(&phba->sli4_hba.bmbx, 0, sizeof(struct lpfc_bmbx)); in lpfc_destroy_bootstrap_mbox()
8397 * lpfc_map_topology - Map the topology read from READ_CONFIG
8422 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
8425 /* FW supports persistent topology - override module parameter value */ in lpfc_map_topology()
8426 phba->hba_flag |= HBA_PERSISTENT_TOPO; in lpfc_map_topology()
8427 switch (phba->pcidev->device) { in lpfc_map_topology()
8431 phba->cfg_topology = ((pt == LINK_FLAGS_LOOP) in lpfc_map_topology()
8435 phba->hba_flag &= ~HBA_PERSISTENT_TOPO; in lpfc_map_topology()
8440 /* If topology failover set - pt is '0' or '1' */ in lpfc_map_topology()
8441 phba->cfg_topology = (pt ? FLAGS_TOPOLOGY_MODE_PT_LOOP : in lpfc_map_topology()
8444 phba->cfg_topology = ((pt == LINK_FLAGS_P2P) in lpfc_map_topology()
8450 if (phba->hba_flag & HBA_PERSISTENT_TOPO) { in lpfc_map_topology()
8453 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
8458 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
8463 * lpfc_sli4_read_config - Get the config parameters.
8472 * 0 - successful
8473 * -ENOMEM - No available memory
8474 * -EIO - The mailbox failed to complete successfully.
8490 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_read_config()
8495 return -ENOMEM; in lpfc_sli4_read_config()
8505 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
8506 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
8507 rc = -EIO; in lpfc_sli4_read_config()
8509 rd_config = &pmb->u.mqe.un.rd_config; in lpfc_sli4_read_config()
8511 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_VAL; in lpfc_sli4_read_config()
8512 phba->sli4_hba.lnk_info.lnk_tp = in lpfc_sli4_read_config()
8514 phba->sli4_hba.lnk_info.lnk_no = in lpfc_sli4_read_config()
8518 phba->sli4_hba.lnk_info.lnk_tp, in lpfc_sli4_read_config()
8519 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_read_config()
8523 bf_get(lpfc_mqe_command, &pmb->u.mqe)); in lpfc_sli4_read_config()
8525 phba->bbcredit_support = 1; in lpfc_sli4_read_config()
8526 phba->sli4_hba.bbscn_params.word0 = rd_config->word8; in lpfc_sli4_read_config()
8529 phba->sli4_hba.conf_trunk = in lpfc_sli4_read_config()
8531 phba->sli4_hba.extents_in_use = in lpfc_sli4_read_config()
8533 phba->sli4_hba.max_cfg_param.max_xri = in lpfc_sli4_read_config()
8537 phba->sli4_hba.max_cfg_param.max_xri > 512) in lpfc_sli4_read_config()
8538 phba->sli4_hba.max_cfg_param.max_xri = 512; in lpfc_sli4_read_config()
8539 phba->sli4_hba.max_cfg_param.xri_base = in lpfc_sli4_read_config()
8541 phba->sli4_hba.max_cfg_param.max_vpi = in lpfc_sli4_read_config()
8544 if (phba->sli4_hba.max_cfg_param.max_vpi > LPFC_MAX_VPORTS) in lpfc_sli4_read_config()
8545 phba->sli4_hba.max_cfg_param.max_vpi = LPFC_MAX_VPORTS; in lpfc_sli4_read_config()
8546 phba->sli4_hba.max_cfg_param.vpi_base = in lpfc_sli4_read_config()
8548 phba->sli4_hba.max_cfg_param.max_rpi = in lpfc_sli4_read_config()
8550 phba->sli4_hba.max_cfg_param.rpi_base = in lpfc_sli4_read_config()
8552 phba->sli4_hba.max_cfg_param.max_vfi = in lpfc_sli4_read_config()
8554 phba->sli4_hba.max_cfg_param.vfi_base = in lpfc_sli4_read_config()
8556 phba->sli4_hba.max_cfg_param.max_fcfi = in lpfc_sli4_read_config()
8558 phba->sli4_hba.max_cfg_param.max_eq = in lpfc_sli4_read_config()
8560 phba->sli4_hba.max_cfg_param.max_rq = in lpfc_sli4_read_config()
8562 phba->sli4_hba.max_cfg_param.max_wq = in lpfc_sli4_read_config()
8564 phba->sli4_hba.max_cfg_param.max_cq = in lpfc_sli4_read_config()
8566 phba->lmt = bf_get(lpfc_mbx_rd_conf_lmt, rd_config); in lpfc_sli4_read_config()
8567 phba->sli4_hba.next_xri = phba->sli4_hba.max_cfg_param.xri_base; in lpfc_sli4_read_config()
8568 phba->vpi_base = phba->sli4_hba.max_cfg_param.vpi_base; in lpfc_sli4_read_config()
8569 phba->vfi_base = phba->sli4_hba.max_cfg_param.vfi_base; in lpfc_sli4_read_config()
8570 phba->max_vpi = (phba->sli4_hba.max_cfg_param.max_vpi > 0) ? in lpfc_sli4_read_config()
8571 (phba->sli4_hba.max_cfg_param.max_vpi - 1) : 0; in lpfc_sli4_read_config()
8572 phba->max_vports = phba->max_vpi; in lpfc_sli4_read_config()
8581 phba->sli4_hba.extents_in_use, in lpfc_sli4_read_config()
8582 phba->sli4_hba.max_cfg_param.xri_base, in lpfc_sli4_read_config()
8583 phba->sli4_hba.max_cfg_param.max_xri, in lpfc_sli4_read_config()
8584 phba->sli4_hba.max_cfg_param.vpi_base, in lpfc_sli4_read_config()
8585 phba->sli4_hba.max_cfg_param.max_vpi, in lpfc_sli4_read_config()
8586 phba->sli4_hba.max_cfg_param.vfi_base, in lpfc_sli4_read_config()
8587 phba->sli4_hba.max_cfg_param.max_vfi, in lpfc_sli4_read_config()
8588 phba->sli4_hba.max_cfg_param.rpi_base, in lpfc_sli4_read_config()
8589 phba->sli4_hba.max_cfg_param.max_rpi, in lpfc_sli4_read_config()
8590 phba->sli4_hba.max_cfg_param.max_fcfi, in lpfc_sli4_read_config()
8591 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
8592 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
8593 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
8594 phba->sli4_hba.max_cfg_param.max_rq, in lpfc_sli4_read_config()
8595 phba->lmt); in lpfc_sli4_read_config()
8601 qmin = phba->sli4_hba.max_cfg_param.max_wq; in lpfc_sli4_read_config()
8602 if (phba->sli4_hba.max_cfg_param.max_cq < qmin) in lpfc_sli4_read_config()
8603 qmin = phba->sli4_hba.max_cfg_param.max_cq; in lpfc_sli4_read_config()
8604 if (phba->sli4_hba.max_cfg_param.max_eq < qmin) in lpfc_sli4_read_config()
8605 qmin = phba->sli4_hba.max_cfg_param.max_eq; in lpfc_sli4_read_config()
8612 qmin -= 4; in lpfc_sli4_read_config()
8615 if ((phba->cfg_irq_chann > qmin) || in lpfc_sli4_read_config()
8616 (phba->cfg_hdw_queue > qmin)) { in lpfc_sli4_read_config()
8618 "2005 Reducing Queues - " in lpfc_sli4_read_config()
8622 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
8623 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
8624 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
8625 qmin, phba->cfg_irq_chann, in lpfc_sli4_read_config()
8626 phba->cfg_hdw_queue); in lpfc_sli4_read_config()
8628 if (phba->cfg_irq_chann > qmin) in lpfc_sli4_read_config()
8629 phba->cfg_irq_chann = qmin; in lpfc_sli4_read_config()
8630 if (phba->cfg_hdw_queue > qmin) in lpfc_sli4_read_config()
8631 phba->cfg_hdw_queue = qmin; in lpfc_sli4_read_config()
8639 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_read_config()
8644 phba->hba_flag |= HBA_FORCED_LINK_SPEED; in lpfc_sli4_read_config()
8648 phba->cfg_link_speed = in lpfc_sli4_read_config()
8652 phba->cfg_link_speed = in lpfc_sli4_read_config()
8656 phba->cfg_link_speed = in lpfc_sli4_read_config()
8660 phba->cfg_link_speed = in lpfc_sli4_read_config()
8664 phba->cfg_link_speed = in lpfc_sli4_read_config()
8668 phba->cfg_link_speed = in lpfc_sli4_read_config()
8672 phba->cfg_link_speed = in lpfc_sli4_read_config()
8676 phba->cfg_link_speed = in lpfc_sli4_read_config()
8680 phba->cfg_link_speed = in lpfc_sli4_read_config()
8689 phba->cfg_link_speed = in lpfc_sli4_read_config()
8696 length = phba->sli4_hba.max_cfg_param.max_xri - in lpfc_sli4_read_config()
8698 if (phba->cfg_hba_queue_depth > length) { in lpfc_sli4_read_config()
8701 phba->cfg_hba_queue_depth, length); in lpfc_sli4_read_config()
8702 phba->cfg_hba_queue_depth = length; in lpfc_sli4_read_config()
8705 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_read_config()
8710 length = (sizeof(struct lpfc_mbx_get_func_cfg) - in lpfc_sli4_read_config()
8718 &pmb->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_read_config()
8719 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_read_config()
8720 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_read_config()
8725 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
8726 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
8731 get_func_cfg = &pmb->u.mqe.un.get_func_cfg; in lpfc_sli4_read_config()
8733 pdesc_0 = (char *)&get_func_cfg->func_cfg.desc[0]; in lpfc_sli4_read_config()
8745 phba->sli4_hba.iov.pf_number = in lpfc_sli4_read_config()
8747 phba->sli4_hba.iov.vf_number = in lpfc_sli4_read_config()
8756 "vf_number:%d\n", phba->sli4_hba.iov.pf_number, in lpfc_sli4_read_config()
8757 phba->sli4_hba.iov.vf_number); in lpfc_sli4_read_config()
8765 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_read_config()
8770 * lpfc_setup_endian_order - Write endian order to an SLI4 if_type 0 port.
8773 * This routine is invoked to setup the port-side endian order when
8778 * 0 - successful
8779 * -ENOMEM - No available memory
8780 * -EIO - The mailbox failed to complete successfully.
8790 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_setup_endian_order()
8793 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_setup_endian_order()
8800 return -ENOMEM; in lpfc_setup_endian_order()
8808 memcpy(&mboxq->u.mqe, &endian_mb_data, sizeof(endian_mb_data)); in lpfc_setup_endian_order()
8815 rc = -EIO; in lpfc_setup_endian_order()
8817 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_setup_endian_order()
8829 * lpfc_sli4_queue_verify - Verify and update EQ counts
8838 * 0 - successful
8839 * -ENOMEM - No available memory
8845 * Sanity check for configured queue parameters against the run-time in lpfc_sli4_queue_verify()
8849 if (phba->nvmet_support) { in lpfc_sli4_queue_verify()
8850 if (phba->cfg_hdw_queue < phba->cfg_nvmet_mrq) in lpfc_sli4_queue_verify()
8851 phba->cfg_nvmet_mrq = phba->cfg_hdw_queue; in lpfc_sli4_queue_verify()
8852 if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX) in lpfc_sli4_queue_verify()
8853 phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX; in lpfc_sli4_queue_verify()
8858 phba->cfg_hdw_queue, phba->cfg_irq_chann, in lpfc_sli4_queue_verify()
8859 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_verify()
8862 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_verify()
8863 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_verify()
8866 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_verify()
8867 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_verify()
8876 int cpu; in lpfc_alloc_io_wq_cq() local
8878 cpu = lpfc_find_cpu_handle(phba, idx, LPFC_FIND_BY_HDWQ); in lpfc_alloc_io_wq_cq()
8880 if (phba->enab_exp_wqcq_pages) in lpfc_alloc_io_wq_cq()
8883 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
8884 LPFC_CQE_EXP_COUNT, cpu); in lpfc_alloc_io_wq_cq()
8888 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
8889 phba->sli4_hba.cq_ecount, cpu); in lpfc_alloc_io_wq_cq()
8892 "0499 Failed allocate fast-path IO CQ (%d)\n", in lpfc_alloc_io_wq_cq()
8896 qdesc->qe_valid = 1; in lpfc_alloc_io_wq_cq()
8897 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
8898 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
8899 phba->sli4_hba.hdwq[idx].io_cq = qdesc; in lpfc_alloc_io_wq_cq()
8902 if (phba->enab_exp_wqcq_pages) { in lpfc_alloc_io_wq_cq()
8904 wqesize = (phba->fcp_embed_io) ? in lpfc_alloc_io_wq_cq()
8905 LPFC_WQE128_SIZE : phba->sli4_hba.wq_esize; in lpfc_alloc_io_wq_cq()
8908 LPFC_WQE_EXP_COUNT, cpu); in lpfc_alloc_io_wq_cq()
8911 phba->sli4_hba.wq_esize, in lpfc_alloc_io_wq_cq()
8912 phba->sli4_hba.wq_ecount, cpu); in lpfc_alloc_io_wq_cq()
8916 "0503 Failed allocate fast-path IO WQ (%d)\n", in lpfc_alloc_io_wq_cq()
8920 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
8921 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
8922 phba->sli4_hba.hdwq[idx].io_wq = qdesc; in lpfc_alloc_io_wq_cq()
8923 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_alloc_io_wq_cq()
8928 * lpfc_sli4_queue_create - Create all the SLI4 queues
8937 * 0 - successful
8938 * -ENOMEM - No availble memory
8939 * -EIO - The mailbox failed to complete successfully.
8945 int idx, cpu, eqcpu; in lpfc_sli4_queue_create() local
8955 phba->sli4_hba.mq_esize = LPFC_MQE_SIZE; in lpfc_sli4_queue_create()
8956 phba->sli4_hba.mq_ecount = LPFC_MQE_DEF_COUNT; in lpfc_sli4_queue_create()
8957 phba->sli4_hba.wq_esize = LPFC_WQE_SIZE; in lpfc_sli4_queue_create()
8958 phba->sli4_hba.wq_ecount = LPFC_WQE_DEF_COUNT; in lpfc_sli4_queue_create()
8959 phba->sli4_hba.rq_esize = LPFC_RQE_SIZE; in lpfc_sli4_queue_create()
8960 phba->sli4_hba.rq_ecount = LPFC_RQE_DEF_COUNT; in lpfc_sli4_queue_create()
8961 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_create()
8962 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_create()
8963 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_create()
8964 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_create()
8966 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
8967 phba->sli4_hba.hdwq = kcalloc( in lpfc_sli4_queue_create()
8968 phba->cfg_hdw_queue, sizeof(struct lpfc_sli4_hdw_queue), in lpfc_sli4_queue_create()
8970 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
8973 "fast-path Hardware Queue array\n"); in lpfc_sli4_queue_create()
8977 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
8978 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_queue_create()
8979 spin_lock_init(&qp->io_buf_list_get_lock); in lpfc_sli4_queue_create()
8980 spin_lock_init(&qp->io_buf_list_put_lock); in lpfc_sli4_queue_create()
8981 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_sli4_queue_create()
8982 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_sli4_queue_create()
8983 qp->get_io_bufs = 0; in lpfc_sli4_queue_create()
8984 qp->put_io_bufs = 0; in lpfc_sli4_queue_create()
8985 qp->total_io_bufs = 0; in lpfc_sli4_queue_create()
8986 spin_lock_init(&qp->abts_io_buf_list_lock); in lpfc_sli4_queue_create()
8987 INIT_LIST_HEAD(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_queue_create()
8988 qp->abts_scsi_io_bufs = 0; in lpfc_sli4_queue_create()
8989 qp->abts_nvme_io_bufs = 0; in lpfc_sli4_queue_create()
8990 INIT_LIST_HEAD(&qp->sgl_list); in lpfc_sli4_queue_create()
8991 INIT_LIST_HEAD(&qp->cmd_rsp_buf_list); in lpfc_sli4_queue_create()
8992 spin_lock_init(&qp->hdwq_lock); in lpfc_sli4_queue_create()
8996 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
8997 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
8998 phba->sli4_hba.nvmet_cqset = kcalloc( in lpfc_sli4_queue_create()
8999 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
9002 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_create()
9005 "fast-path CQ set array\n"); in lpfc_sli4_queue_create()
9008 phba->sli4_hba.nvmet_mrq_hdr = kcalloc( in lpfc_sli4_queue_create()
9009 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
9012 if (!phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_create()
9015 "fast-path RQ set hdr array\n"); in lpfc_sli4_queue_create()
9018 phba->sli4_hba.nvmet_mrq_data = kcalloc( in lpfc_sli4_queue_create()
9019 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
9022 if (!phba->sli4_hba.nvmet_mrq_data) { in lpfc_sli4_queue_create()
9025 "fast-path RQ set data array\n"); in lpfc_sli4_queue_create()
9031 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
9034 for_each_present_cpu(cpu) { in lpfc_sli4_queue_create()
9039 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
9040 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_create()
9043 /* Get a ptr to the Hardware Queue associated with this CPU */ in lpfc_sli4_queue_create()
9044 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
9048 phba->sli4_hba.eq_esize, in lpfc_sli4_queue_create()
9049 phba->sli4_hba.eq_ecount, cpu); in lpfc_sli4_queue_create()
9053 cpup->hdwq); in lpfc_sli4_queue_create()
9056 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
9057 qdesc->hdwq = cpup->hdwq; in lpfc_sli4_queue_create()
9058 qdesc->chann = cpu; /* First CPU this EQ is affinitized to */ in lpfc_sli4_queue_create()
9059 qdesc->last_cpu = qdesc->chann; in lpfc_sli4_queue_create()
9062 qp->hba_eq = qdesc; in lpfc_sli4_queue_create()
9064 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, qdesc->last_cpu); in lpfc_sli4_queue_create()
9065 list_add(&qdesc->cpu_list, &eqi->list); in lpfc_sli4_queue_create()
9071 for_each_present_cpu(cpu) { in lpfc_sli4_queue_create()
9072 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
9075 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_sli4_queue_create()
9079 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
9080 if (qp->hba_eq) in lpfc_sli4_queue_create()
9084 eqcpu = lpfc_find_cpu_handle(phba, cpup->eq, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
9085 eqcpup = &phba->sli4_hba.cpu_map[eqcpu]; in lpfc_sli4_queue_create()
9086 qp->hba_eq = phba->sli4_hba.hdwq[eqcpup->hdwq].hba_eq; in lpfc_sli4_queue_create()
9090 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
9095 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
9096 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
9097 cpu = lpfc_find_cpu_handle(phba, idx, in lpfc_sli4_queue_create()
9101 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
9102 phba->sli4_hba.cq_ecount, in lpfc_sli4_queue_create()
9103 cpu); in lpfc_sli4_queue_create()
9110 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
9111 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
9112 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9113 phba->sli4_hba.nvmet_cqset[idx] = qdesc; in lpfc_sli4_queue_create()
9121 cpu = lpfc_find_cpu_handle(phba, 0, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
9122 /* Create slow-path Mailbox Command Complete Queue */ in lpfc_sli4_queue_create()
9124 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
9125 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
9128 "0500 Failed allocate slow-path mailbox CQ\n"); in lpfc_sli4_queue_create()
9131 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
9132 phba->sli4_hba.mbx_cq = qdesc; in lpfc_sli4_queue_create()
9134 /* Create slow-path ELS Complete Queue */ in lpfc_sli4_queue_create()
9136 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
9137 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
9140 "0501 Failed allocate slow-path ELS CQ\n"); in lpfc_sli4_queue_create()
9143 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
9144 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9145 phba->sli4_hba.els_cq = qdesc; in lpfc_sli4_queue_create()
9155 phba->sli4_hba.mq_esize, in lpfc_sli4_queue_create()
9156 phba->sli4_hba.mq_ecount, cpu); in lpfc_sli4_queue_create()
9159 "0505 Failed allocate slow-path MQ\n"); in lpfc_sli4_queue_create()
9162 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9163 phba->sli4_hba.mbx_wq = qdesc; in lpfc_sli4_queue_create()
9169 /* Create slow-path ELS Work Queue */ in lpfc_sli4_queue_create()
9171 phba->sli4_hba.wq_esize, in lpfc_sli4_queue_create()
9172 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
9175 "0504 Failed allocate slow-path ELS WQ\n"); in lpfc_sli4_queue_create()
9178 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9179 phba->sli4_hba.els_wq = qdesc; in lpfc_sli4_queue_create()
9180 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
9182 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
9185 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
9186 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
9192 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9193 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
9194 phba->sli4_hba.nvmels_cq = qdesc; in lpfc_sli4_queue_create()
9198 phba->sli4_hba.wq_esize, in lpfc_sli4_queue_create()
9199 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
9205 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9206 phba->sli4_hba.nvmels_wq = qdesc; in lpfc_sli4_queue_create()
9207 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
9216 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
9217 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
9223 phba->sli4_hba.hdr_rq = qdesc; in lpfc_sli4_queue_create()
9227 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
9228 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
9234 phba->sli4_hba.dat_rq = qdesc; in lpfc_sli4_queue_create()
9236 if ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) && in lpfc_sli4_queue_create()
9237 phba->nvmet_support) { in lpfc_sli4_queue_create()
9238 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
9239 cpu = lpfc_find_cpu_handle(phba, idx, in lpfc_sli4_queue_create()
9244 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
9246 cpu); in lpfc_sli4_queue_create()
9253 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
9254 phba->sli4_hba.nvmet_mrq_hdr[idx] = qdesc; in lpfc_sli4_queue_create()
9257 qdesc->rqbp = kzalloc_node(sizeof(*qdesc->rqbp), in lpfc_sli4_queue_create()
9259 cpu_to_node(cpu)); in lpfc_sli4_queue_create()
9260 if (qdesc->rqbp == NULL) { in lpfc_sli4_queue_create()
9268 INIT_LIST_HEAD(&qdesc->rqbp->rqb_buffer_list); in lpfc_sli4_queue_create()
9273 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
9275 cpu); in lpfc_sli4_queue_create()
9282 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
9283 phba->sli4_hba.nvmet_mrq_data[idx] = qdesc; in lpfc_sli4_queue_create()
9288 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
9289 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
9290 memset(&phba->sli4_hba.hdwq[idx].nvme_cstat, 0, in lpfc_sli4_queue_create()
9291 sizeof(phba->sli4_hba.hdwq[idx].nvme_cstat)); in lpfc_sli4_queue_create()
9296 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { in lpfc_sli4_queue_create()
9297 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
9298 memset(&phba->sli4_hba.hdwq[idx].scsi_cstat, 0, in lpfc_sli4_queue_create()
9299 sizeof(phba->sli4_hba.hdwq[idx].scsi_cstat)); in lpfc_sli4_queue_create()
9307 return -ENOMEM; in lpfc_sli4_queue_create()
9341 hdwq = phba->sli4_hba.hdwq; in lpfc_sli4_release_hdwq()
9344 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_release_hdwq()
9351 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_release_hdwq()
9356 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_release_hdwq()
9358 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_sli4_release_hdwq()
9360 phba->sli4_hba.hba_eq_hdl[idx].eq = NULL; in lpfc_sli4_release_hdwq()
9365 * lpfc_sli4_queue_destroy - Destroy all the SLI4 queues
9372 * 0 - successful
9373 * -ENOMEM - No available memory
9374 * -EIO - The mailbox failed to complete successfully.
9384 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9385 phba->sli.sli_flag |= LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
9386 while (phba->sli.sli_flag & LPFC_QUEUE_FREE_WAIT) { in lpfc_sli4_queue_destroy()
9387 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9389 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9391 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9396 if (phba->sli4_hba.hdwq) in lpfc_sli4_queue_destroy()
9399 if (phba->nvmet_support) { in lpfc_sli4_queue_destroy()
9400 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_destroy()
9401 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
9403 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_destroy()
9404 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
9405 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_destroy()
9406 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
9410 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_destroy()
9413 __lpfc_sli4_release_queue(&phba->sli4_hba.els_wq); in lpfc_sli4_queue_destroy()
9416 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_destroy()
9419 __lpfc_sli4_release_queue(&phba->sli4_hba.hdr_rq); in lpfc_sli4_queue_destroy()
9420 __lpfc_sli4_release_queue(&phba->sli4_hba.dat_rq); in lpfc_sli4_queue_destroy()
9423 __lpfc_sli4_release_queue(&phba->sli4_hba.els_cq); in lpfc_sli4_queue_destroy()
9426 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_destroy()
9429 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_destroy()
9432 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_destroy()
9435 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9436 phba->sli.sli_flag &= ~LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
9437 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9447 rqbp = rq->rqbp; in lpfc_free_rq_buffer()
9448 while (!list_empty(&rqbp->rqb_buffer_list)) { in lpfc_free_rq_buffer()
9449 list_remove_head(&rqbp->rqb_buffer_list, h_buf, in lpfc_free_rq_buffer()
9453 (rqbp->rqb_free_buffer)(phba, rqb_buffer); in lpfc_free_rq_buffer()
9454 rqbp->buffer_count--; in lpfc_free_rq_buffer()
9469 "6085 Fast-path %s (%d) not allocated\n", in lpfc_create_wq_cq()
9471 return -ENOMEM; in lpfc_create_wq_cq()
9487 *cq_map = cq->queue_id; in lpfc_create_wq_cq()
9490 "6087 CQ setup: cq[%d]-id=%d, parent eq[%d]-id=%d\n", in lpfc_create_wq_cq()
9491 qidx, cq->queue_id, qidx, eq->queue_id); in lpfc_create_wq_cq()
9499 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
9504 pring = wq->pring; in lpfc_create_wq_cq()
9505 pring->sli.sli4.wqp = (void *)wq; in lpfc_create_wq_cq()
9506 cq->pring = pring; in lpfc_create_wq_cq()
9509 "2593 WQ setup: wq[%d]-id=%d assoc=%d, cq[%d]-id=%d\n", in lpfc_create_wq_cq()
9510 qidx, wq->queue_id, wq->assoc_qid, qidx, cq->queue_id); in lpfc_create_wq_cq()
9515 "0539 Failed setup of slow-path MQ: " in lpfc_create_wq_cq()
9517 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
9522 "2589 MBX MQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_create_wq_cq()
9523 phba->sli4_hba.mbx_wq->queue_id, in lpfc_create_wq_cq()
9524 phba->sli4_hba.mbx_cq->queue_id); in lpfc_create_wq_cq()
9531 * lpfc_setup_cq_lookup - Setup the CQ lookup table
9543 memset(phba->sli4_hba.cq_lookup, 0, in lpfc_setup_cq_lookup()
9544 (sizeof(struct lpfc_queue *) * (phba->sli4_hba.cq_max + 1))); in lpfc_setup_cq_lookup()
9546 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_setup_cq_lookup()
9548 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_setup_cq_lookup()
9552 list_for_each_entry(childq, &eq->child_list, list) { in lpfc_setup_cq_lookup()
9553 if (childq->queue_id > phba->sli4_hba.cq_max) in lpfc_setup_cq_lookup()
9555 if (childq->subtype == LPFC_IO) in lpfc_setup_cq_lookup()
9556 phba->sli4_hba.cq_lookup[childq->queue_id] = in lpfc_setup_cq_lookup()
9563 * lpfc_sli4_queue_setup - Set up all the SLI4 queues
9570 * 0 - successful
9571 * -ENOMEM - No available memory
9572 * -EIO - The mailbox failed to complete successfully.
9582 int qidx, cpu; in lpfc_sli4_queue_setup() local
9584 int rc = -ENOMEM; in lpfc_sli4_queue_setup()
9586 /* Check for dual-ULP support */ in lpfc_sli4_queue_setup()
9587 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_queue_setup()
9592 return -ENOMEM; in lpfc_sli4_queue_setup()
9594 length = (sizeof(struct lpfc_mbx_query_fw_config) - in lpfc_sli4_queue_setup()
9603 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_queue_setup()
9604 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_queue_setup()
9605 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_queue_setup()
9611 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
9612 rc = -ENXIO; in lpfc_sli4_queue_setup()
9616 phba->sli4_hba.fw_func_mode = in lpfc_sli4_queue_setup()
9617 mboxq->u.mqe.un.query_fw_cfg.rsp.function_mode; in lpfc_sli4_queue_setup()
9618 phba->sli4_hba.ulp0_mode = mboxq->u.mqe.un.query_fw_cfg.rsp.ulp0_mode; in lpfc_sli4_queue_setup()
9619 phba->sli4_hba.ulp1_mode = mboxq->u.mqe.un.query_fw_cfg.rsp.ulp1_mode; in lpfc_sli4_queue_setup()
9620 phba->sli4_hba.physical_port = in lpfc_sli4_queue_setup()
9621 mboxq->u.mqe.un.query_fw_cfg.rsp.physical_port; in lpfc_sli4_queue_setup()
9624 "ulp1_mode:x%x\n", phba->sli4_hba.fw_func_mode, in lpfc_sli4_queue_setup()
9625 phba->sli4_hba.ulp0_mode, phba->sli4_hba.ulp1_mode); in lpfc_sli4_queue_setup()
9627 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
9632 qp = phba->sli4_hba.hdwq; in lpfc_sli4_queue_setup()
9637 "3147 Fast-path EQs not allocated\n"); in lpfc_sli4_queue_setup()
9638 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9643 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_setup()
9645 for_each_present_cpu(cpu) { in lpfc_sli4_queue_setup()
9646 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
9648 /* Look for the CPU thats using that vector with in lpfc_sli4_queue_setup()
9651 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_setup()
9653 if (qidx != cpup->eq) in lpfc_sli4_queue_setup()
9657 rc = lpfc_eq_create(phba, qp[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
9658 phba->cfg_fcp_imax); in lpfc_sli4_queue_setup()
9661 "0523 Failed setup of fast-path" in lpfc_sli4_queue_setup()
9663 cpup->eq, (uint32_t)rc); in lpfc_sli4_queue_setup()
9668 phba->sli4_hba.hba_eq_hdl[cpup->eq].eq = in lpfc_sli4_queue_setup()
9669 qp[cpup->hdwq].hba_eq; in lpfc_sli4_queue_setup()
9672 "2584 HBA EQ setup: queue[%d]-id=%d\n", in lpfc_sli4_queue_setup()
9673 cpup->eq, in lpfc_sli4_queue_setup()
9674 qp[cpup->hdwq].hba_eq->queue_id); in lpfc_sli4_queue_setup()
9679 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_setup()
9680 cpu = lpfc_find_cpu_handle(phba, qidx, LPFC_FIND_BY_HDWQ); in lpfc_sli4_queue_setup()
9681 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
9685 phba->sli4_hba.hdwq[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
9688 &phba->sli4_hba.hdwq[qidx].io_cq_map, in lpfc_sli4_queue_setup()
9704 /* Set up slow-path MBOX CQ/MQ */ in lpfc_sli4_queue_setup()
9706 if (!phba->sli4_hba.mbx_cq || !phba->sli4_hba.mbx_wq) { in lpfc_sli4_queue_setup()
9709 phba->sli4_hba.mbx_cq ? in lpfc_sli4_queue_setup()
9711 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9716 phba->sli4_hba.mbx_cq, in lpfc_sli4_queue_setup()
9717 phba->sli4_hba.mbx_wq, in lpfc_sli4_queue_setup()
9725 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
9726 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_setup()
9728 "3165 Fast-path NVME CQ Set " in lpfc_sli4_queue_setup()
9730 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9733 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
9735 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
9747 rc = lpfc_cq_create(phba, phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
9756 phba->sli4_hba.nvmet_cqset[0]->chann = 0; in lpfc_sli4_queue_setup()
9759 "6090 NVMET CQ setup: cq-id=%d, " in lpfc_sli4_queue_setup()
9760 "parent eq-id=%d\n", in lpfc_sli4_queue_setup()
9761 phba->sli4_hba.nvmet_cqset[0]->queue_id, in lpfc_sli4_queue_setup()
9762 qp[0].hba_eq->queue_id); in lpfc_sli4_queue_setup()
9766 /* Set up slow-path ELS WQ/CQ */ in lpfc_sli4_queue_setup()
9767 if (!phba->sli4_hba.els_cq || !phba->sli4_hba.els_wq) { in lpfc_sli4_queue_setup()
9770 phba->sli4_hba.els_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
9771 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9775 phba->sli4_hba.els_cq, in lpfc_sli4_queue_setup()
9776 phba->sli4_hba.els_wq, in lpfc_sli4_queue_setup()
9785 "2590 ELS WQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_sli4_queue_setup()
9786 phba->sli4_hba.els_wq->queue_id, in lpfc_sli4_queue_setup()
9787 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
9789 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_setup()
9791 if (!phba->sli4_hba.nvmels_cq || !phba->sli4_hba.nvmels_wq) { in lpfc_sli4_queue_setup()
9794 phba->sli4_hba.nvmels_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
9795 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9799 phba->sli4_hba.nvmels_cq, in lpfc_sli4_queue_setup()
9800 phba->sli4_hba.nvmels_wq, in lpfc_sli4_queue_setup()
9810 "6096 ELS WQ setup: wq-id=%d, " in lpfc_sli4_queue_setup()
9811 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
9812 phba->sli4_hba.nvmels_wq->queue_id, in lpfc_sli4_queue_setup()
9813 phba->sli4_hba.nvmels_cq->queue_id); in lpfc_sli4_queue_setup()
9819 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
9820 if ((!phba->sli4_hba.nvmet_cqset) || in lpfc_sli4_queue_setup()
9821 (!phba->sli4_hba.nvmet_mrq_hdr) || in lpfc_sli4_queue_setup()
9822 (!phba->sli4_hba.nvmet_mrq_data)) { in lpfc_sli4_queue_setup()
9826 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9829 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
9831 phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_setup()
9832 phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_setup()
9833 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
9845 phba->sli4_hba.nvmet_mrq_hdr[0], in lpfc_sli4_queue_setup()
9846 phba->sli4_hba.nvmet_mrq_data[0], in lpfc_sli4_queue_setup()
9847 phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
9859 "6099 NVMET RQ setup: hdr-rq-id=%d, " in lpfc_sli4_queue_setup()
9860 "dat-rq-id=%d parent cq-id=%d\n", in lpfc_sli4_queue_setup()
9861 phba->sli4_hba.nvmet_mrq_hdr[0]->queue_id, in lpfc_sli4_queue_setup()
9862 phba->sli4_hba.nvmet_mrq_data[0]->queue_id, in lpfc_sli4_queue_setup()
9863 phba->sli4_hba.nvmet_cqset[0]->queue_id); in lpfc_sli4_queue_setup()
9868 if (!phba->sli4_hba.hdr_rq || !phba->sli4_hba.dat_rq) { in lpfc_sli4_queue_setup()
9871 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9875 rc = lpfc_rq_create(phba, phba->sli4_hba.hdr_rq, phba->sli4_hba.dat_rq, in lpfc_sli4_queue_setup()
9876 phba->sli4_hba.els_cq, LPFC_USOL); in lpfc_sli4_queue_setup()
9885 "2592 USL RQ setup: hdr-rq-id=%d, dat-rq-id=%d " in lpfc_sli4_queue_setup()
9886 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
9887 phba->sli4_hba.hdr_rq->queue_id, in lpfc_sli4_queue_setup()
9888 phba->sli4_hba.dat_rq->queue_id, in lpfc_sli4_queue_setup()
9889 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
9891 if (phba->cfg_fcp_imax) in lpfc_sli4_queue_setup()
9892 usdelay = LPFC_SEC_TO_USEC / phba->cfg_fcp_imax; in lpfc_sli4_queue_setup()
9896 for (qidx = 0; qidx < phba->cfg_irq_chann; in lpfc_sli4_queue_setup()
9901 if (phba->sli4_hba.cq_max) { in lpfc_sli4_queue_setup()
9902 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_setup()
9903 phba->sli4_hba.cq_lookup = kcalloc((phba->sli4_hba.cq_max + 1), in lpfc_sli4_queue_setup()
9905 if (!phba->sli4_hba.cq_lookup) { in lpfc_sli4_queue_setup()
9908 "size 0x%x\n", phba->sli4_hba.cq_max); in lpfc_sli4_queue_setup()
9909 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9923 * lpfc_sli4_queue_unset - Unset all the SLI4 queues
9930 * 0 - successful
9931 * -ENOMEM - No available memory
9932 * -EIO - The mailbox failed to complete successfully.
9942 if (phba->sli4_hba.mbx_wq) in lpfc_sli4_queue_unset()
9943 lpfc_mq_destroy(phba, phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_unset()
9946 if (phba->sli4_hba.nvmels_wq) in lpfc_sli4_queue_unset()
9947 lpfc_wq_destroy(phba, phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_unset()
9950 if (phba->sli4_hba.els_wq) in lpfc_sli4_queue_unset()
9951 lpfc_wq_destroy(phba, phba->sli4_hba.els_wq); in lpfc_sli4_queue_unset()
9954 if (phba->sli4_hba.hdr_rq) in lpfc_sli4_queue_unset()
9955 lpfc_rq_destroy(phba, phba->sli4_hba.hdr_rq, in lpfc_sli4_queue_unset()
9956 phba->sli4_hba.dat_rq); in lpfc_sli4_queue_unset()
9959 if (phba->sli4_hba.mbx_cq) in lpfc_sli4_queue_unset()
9960 lpfc_cq_destroy(phba, phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_unset()
9963 if (phba->sli4_hba.els_cq) in lpfc_sli4_queue_unset()
9964 lpfc_cq_destroy(phba, phba->sli4_hba.els_cq); in lpfc_sli4_queue_unset()
9967 if (phba->sli4_hba.nvmels_cq) in lpfc_sli4_queue_unset()
9968 lpfc_cq_destroy(phba, phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_unset()
9970 if (phba->nvmet_support) { in lpfc_sli4_queue_unset()
9972 if (phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_unset()
9973 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
9976 phba->sli4_hba.nvmet_mrq_hdr[qidx], in lpfc_sli4_queue_unset()
9977 phba->sli4_hba.nvmet_mrq_data[qidx]); in lpfc_sli4_queue_unset()
9981 if (phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_unset()
9982 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
9984 phba, phba->sli4_hba.nvmet_cqset[qidx]); in lpfc_sli4_queue_unset()
9988 /* Unset fast-path SLI4 queues */ in lpfc_sli4_queue_unset()
9989 if (phba->sli4_hba.hdwq) { in lpfc_sli4_queue_unset()
9991 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_unset()
9993 qp = &phba->sli4_hba.hdwq[qidx]; in lpfc_sli4_queue_unset()
9994 lpfc_wq_destroy(phba, qp->io_wq); in lpfc_sli4_queue_unset()
9995 lpfc_cq_destroy(phba, qp->io_cq); in lpfc_sli4_queue_unset()
9998 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_unset()
10000 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_sli4_queue_unset()
10005 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_unset()
10006 phba->sli4_hba.cq_lookup = NULL; in lpfc_sli4_queue_unset()
10007 phba->sli4_hba.cq_max = 0; in lpfc_sli4_queue_unset()
10011 * lpfc_sli4_cq_event_pool_create - Create completion-queue event free pool
10018 * - Mailbox asynchronous events
10019 * - Receive queue completion unsolicited events
10020 * Later, this can be used for all the slow-path events.
10023 * 0 - successful
10024 * -ENOMEM - No available memory
10032 for (i = 0; i < (4 * phba->sli4_hba.cq_ecount); i++) { in lpfc_sli4_cq_event_pool_create()
10036 list_add_tail(&cq_event->list, in lpfc_sli4_cq_event_pool_create()
10037 &phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_cq_event_pool_create()
10043 return -ENOMEM; in lpfc_sli4_cq_event_pool_create()
10047 * lpfc_sli4_cq_event_pool_destroy - Free completion-queue event free pool
10052 * cleanup routine to free all the outstanding completion-queue events
10062 &phba->sli4_hba.sp_cqe_event_pool, list) { in lpfc_sli4_cq_event_pool_destroy()
10063 list_del(&cq_event->list); in lpfc_sli4_cq_event_pool_destroy()
10069 * __lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
10073 * completion-queue event from the free pool.
10075 * Return: Pointer to the newly allocated completion-queue event if successful
10083 list_remove_head(&phba->sli4_hba.sp_cqe_event_pool, cq_event, in __lpfc_sli4_cq_event_alloc()
10089 * lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
10093 * completion-queue event from the free pool.
10095 * Return: Pointer to the newly allocated completion-queue event if successful
10104 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
10106 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
10111 * __lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
10116 * completion-queue event back into the free pool.
10122 list_add_tail(&cq_event->list, &phba->sli4_hba.sp_cqe_event_pool); in __lpfc_sli4_cq_event_release()
10126 * lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
10131 * completion-queue event back into the free pool.
10138 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
10140 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
10144 * lpfc_sli4_cq_event_release_all - Release all cq events to the free pool
10147 * This routine is to free all the pending completion-queue events to the
10160 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
10161 list_splice_init(&phba->sli4_hba.sp_els_xri_aborted_work_queue, in lpfc_sli4_cq_event_release_all()
10163 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
10166 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
10167 list_splice_init(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_cq_event_release_all()
10169 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
10179 * lpfc_pci_function_reset - Reset pci function.
10186 * 0 - successful
10187 * -ENOMEM - No available memory
10188 * -EIO - The mailbox failed to complete successfully.
10202 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_pci_function_reset()
10205 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_pci_function_reset()
10212 return -ENOMEM; in lpfc_pci_function_reset()
10215 /* Setup PCI function reset mailbox-ioctl command */ in lpfc_pci_function_reset()
10221 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_pci_function_reset()
10222 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_pci_function_reset()
10224 &shdr->response); in lpfc_pci_function_reset()
10225 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_pci_function_reset()
10232 rc = -ENXIO; in lpfc_pci_function_reset()
10244 if (lpfc_readl(phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
10246 rc = -ENODEV; in lpfc_pci_function_reset()
10255 phba->work_status[0] = readl( in lpfc_pci_function_reset()
10256 phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_pci_function_reset()
10257 phba->work_status[1] = readl( in lpfc_pci_function_reset()
10258 phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_pci_function_reset()
10263 phba->work_status[0], in lpfc_pci_function_reset()
10264 phba->work_status[1]); in lpfc_pci_function_reset()
10265 rc = -ENODEV; in lpfc_pci_function_reset()
10278 writel(reg_data.word0, phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
10281 pci_read_config_word(phba->pcidev, in lpfc_pci_function_reset()
10288 rc = -ENODEV; in lpfc_pci_function_reset()
10299 /* Catch the not-ready port failure after a port reset. */ in lpfc_pci_function_reset()
10304 rc = -ENODEV; in lpfc_pci_function_reset()
10311 * lpfc_sli4_pci_mem_setup - Setup SLI4 HBA PCI memory space.
10315 * with SLI-4 interface spec.
10318 * 0 - successful
10319 * other values - error
10324 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_pci_mem_setup()
10330 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10333 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli4_pci_mem_setup()
10335 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli4_pci_mem_setup()
10344 &phba->sli4_hba.sli_intf.word0)) { in lpfc_sli4_pci_mem_setup()
10345 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10349 if (bf_get(lpfc_sli_intf_valid, &phba->sli4_hba.sli_intf) != in lpfc_sli4_pci_mem_setup()
10354 phba->sli4_hba.sli_intf.word0); in lpfc_sli4_pci_mem_setup()
10355 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10358 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_setup()
10366 phba->pci_bar0_map = pci_resource_start(pdev, PCI_64BIT_BAR0); in lpfc_sli4_pci_mem_setup()
10373 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10374 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
10375 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10376 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
10379 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10381 phba->pci_bar0_memmap_p = phba->sli4_hba.conf_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10385 phba->pci_bar0_map = pci_resource_start(pdev, 1); in lpfc_sli4_pci_mem_setup()
10388 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
10389 "FATAL - No BAR0 mapping for SLI4, if_type 2\n"); in lpfc_sli4_pci_mem_setup()
10390 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10392 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10393 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
10394 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10395 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
10398 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10409 phba->pci_bar1_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
10412 phba->sli4_hba.ctrl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10413 ioremap(phba->pci_bar1_map, in lpfc_sli4_pci_mem_setup()
10415 if (!phba->sli4_hba.ctrl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10416 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
10419 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10422 phba->pci_bar2_memmap_p = in lpfc_sli4_pci_mem_setup()
10423 phba->sli4_hba.ctrl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10426 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10437 phba->pci_bar1_map = pci_resource_start(pdev, PCI_64BIT_BAR2); in lpfc_sli4_pci_mem_setup()
10439 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10440 ioremap(phba->pci_bar1_map, bar1map_len); in lpfc_sli4_pci_mem_setup()
10441 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10442 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
10444 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10447 phba->pci_bar2_memmap_p = phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10457 phba->pci_bar2_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
10460 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10461 ioremap(phba->pci_bar2_map, in lpfc_sli4_pci_mem_setup()
10463 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10464 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
10467 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10470 phba->pci_bar4_memmap_p = in lpfc_sli4_pci_mem_setup()
10471 phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10476 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10487 phba->pci_bar2_map = pci_resource_start(pdev, PCI_64BIT_BAR4); in lpfc_sli4_pci_mem_setup()
10489 phba->sli4_hba.dpp_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10490 ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli4_pci_mem_setup()
10491 if (!phba->sli4_hba.dpp_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10492 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
10494 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10497 phba->pci_bar4_memmap_p = phba->sli4_hba.dpp_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10504 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
10505 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_write_eq_db; in lpfc_sli4_pci_mem_setup()
10506 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_write_cq_db; in lpfc_sli4_pci_mem_setup()
10509 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_if6_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
10510 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_if6_write_eq_db; in lpfc_sli4_pci_mem_setup()
10511 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_if6_write_cq_db; in lpfc_sli4_pci_mem_setup()
10520 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
10522 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
10524 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
10530 * lpfc_sli4_pci_mem_unset - Unset SLI4 HBA PCI memory space.
10534 * with SLI-4 interface spec.
10540 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_unset()
10544 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10545 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10546 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10549 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10552 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10553 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10554 if (phba->sli4_hba.dpp_regs_memmap_p) in lpfc_sli4_pci_mem_unset()
10555 iounmap(phba->sli4_hba.dpp_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10559 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_pci_mem_unset()
10560 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_pci_mem_unset()
10567 * lpfc_sli_enable_msix - Enable MSI-X interrupt mode on SLI-3 device
10570 * This routine is invoked to enable the MSI-X interrupt vectors to device
10571 * with SLI-3 interface specs.
10574 * 0 - successful
10575 * other values - error
10583 /* Set up MSI-X multi-message vectors */ in lpfc_sli_enable_msix()
10584 rc = pci_alloc_irq_vectors(phba->pcidev, in lpfc_sli_enable_msix()
10588 "0420 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli_enable_msix()
10593 * Assign MSI-X vectors to interrupt handlers in lpfc_sli_enable_msix()
10596 /* vector-0 is associated to slow-path handler */ in lpfc_sli_enable_msix()
10597 rc = request_irq(pci_irq_vector(phba->pcidev, 0), in lpfc_sli_enable_msix()
10602 "0421 MSI-X slow-path request_irq failed " in lpfc_sli_enable_msix()
10607 /* vector-1 is associated to fast-path handler */ in lpfc_sli_enable_msix()
10608 rc = request_irq(pci_irq_vector(phba->pcidev, 1), in lpfc_sli_enable_msix()
10614 "0429 MSI-X fast-path request_irq failed " in lpfc_sli_enable_msix()
10620 * Configure HBA MSI-X attention conditions to messages in lpfc_sli_enable_msix()
10622 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_enable_msix()
10625 rc = -ENOMEM; in lpfc_sli_enable_msix()
10639 pmb->u.mb.mbxCommand, pmb->u.mb.mbxStatus); in lpfc_sli_enable_msix()
10644 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
10649 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
10653 free_irq(pci_irq_vector(phba->pcidev, 1), phba); in lpfc_sli_enable_msix()
10657 free_irq(pci_irq_vector(phba->pcidev, 0), phba); in lpfc_sli_enable_msix()
10660 /* Unconfigure MSI-X capability structure */ in lpfc_sli_enable_msix()
10661 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_enable_msix()
10668 * lpfc_sli_enable_msi - Enable MSI interrupt mode on SLI-3 device.
10672 * SLI-3 interface spec. The kernel function pci_enable_msi() is called to
10678 * 0 - successful
10679 * other values - error
10686 rc = pci_enable_msi(phba->pcidev); in lpfc_sli_enable_msi()
10696 rc = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_msi()
10699 pci_disable_msi(phba->pcidev); in lpfc_sli_enable_msi()
10707 * lpfc_sli_enable_intr - Enable device interrupt to SLI-3 device.
10709 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
10712 * interrupt handler(s) to interrupt vector(s) to device with SLI-3 interface
10717 * MSI-X -> MSI -> IRQ.
10720 * 0 - successful
10721 * other values - error
10733 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli_enable_intr()
10736 /* Indicate initialization to MSI-X mode */ in lpfc_sli_enable_intr()
10737 phba->intr_type = MSIX; in lpfc_sli_enable_intr()
10743 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli_enable_intr()
10744 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli_enable_intr()
10748 phba->intr_type = MSI; in lpfc_sli_enable_intr()
10753 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli_enable_intr()
10754 if (phba->intr_type == NONE) { in lpfc_sli_enable_intr()
10755 retval = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_intr()
10759 phba->intr_type = INTx; in lpfc_sli_enable_intr()
10767 * lpfc_sli_disable_intr - Disable device interrupt to SLI-3 device.
10772 * SLI-3 interface spec. Depending on the interrupt mode, the driver will
10780 if (phba->intr_type == MSIX) in lpfc_sli_disable_intr()
10786 free_irq(pci_irq_vector(phba->pcidev, i), phba); in lpfc_sli_disable_intr()
10787 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_disable_intr()
10790 phba->intr_type = NONE; in lpfc_sli_disable_intr()
10791 phba->sli.slistat.sli_intr = 0; in lpfc_sli_disable_intr()
10795 * lpfc_find_cpu_handle - Find the CPU that corresponds to the specified Queue
10800 * Return the CPU that matches the selection criteria
10806 int cpu; in lpfc_find_cpu_handle() local
10809 for_each_present_cpu(cpu) { in lpfc_find_cpu_handle()
10810 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_find_cpu_handle()
10817 (cpup->flag & LPFC_CPU_FIRST_IRQ) && in lpfc_find_cpu_handle()
10818 (cpup->eq == id)) in lpfc_find_cpu_handle()
10819 return cpu; in lpfc_find_cpu_handle()
10821 /* If matching by HDWQ, select the first CPU that matches */ in lpfc_find_cpu_handle()
10822 if ((match == LPFC_FIND_BY_HDWQ) && (cpup->hdwq == id)) in lpfc_find_cpu_handle()
10823 return cpu; in lpfc_find_cpu_handle()
10830 * lpfc_find_hyper - Determine if the CPU map entry is hyper-threaded
10832 * @cpu: CPU map index
10833 * @phys_id: CPU package physical id
10834 * @core_id: CPU core id
10837 lpfc_find_hyper(struct lpfc_hba *phba, int cpu, in lpfc_find_hyper() argument
10844 cpup = &phba->sli4_hba.cpu_map[idx]; in lpfc_find_hyper()
10846 if ((cpup->phys_id == phys_id) && in lpfc_find_hyper()
10847 (cpup->core_id == core_id) && in lpfc_find_hyper()
10848 (cpu != idx)) in lpfc_find_hyper()
10856 * lpfc_assign_eq_map_info - Assigns eq for vector_map structure
10860 * @cpu: cpu used to index vector_map structure
10866 unsigned int cpu) in lpfc_assign_eq_map_info() argument
10868 struct lpfc_vector_map_info *cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_assign_eq_map_info()
10871 cpup->eq = eqidx; in lpfc_assign_eq_map_info()
10872 cpup->flag |= flag; in lpfc_assign_eq_map_info()
10875 "3336 Set Affinity: CPU %d irq %d eq %d flag x%x\n", in lpfc_assign_eq_map_info()
10876 cpu, eqhdl->irq, cpup->eq, cpup->flag); in lpfc_assign_eq_map_info()
10880 * lpfc_cpu_map_array_init - Initialize cpu_map structure
10890 int cpu; in lpfc_cpu_map_array_init() local
10892 for_each_possible_cpu(cpu) { in lpfc_cpu_map_array_init()
10893 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_map_array_init()
10894 cpup->phys_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
10895 cpup->core_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
10896 cpup->hdwq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
10897 cpup->eq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
10898 cpup->flag = 0; in lpfc_cpu_map_array_init()
10899 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, cpu); in lpfc_cpu_map_array_init()
10900 INIT_LIST_HEAD(&eqi->list); in lpfc_cpu_map_array_init()
10901 eqi->icnt = 0; in lpfc_cpu_map_array_init()
10906 * lpfc_hba_eq_hdl_array_init - Initialize hba_eq_hdl structure
10917 for (i = 0; i < phba->cfg_irq_chann; i++) { in lpfc_hba_eq_hdl_array_init()
10919 eqhdl->irq = LPFC_VECTOR_MAP_EMPTY; in lpfc_hba_eq_hdl_array_init()
10920 eqhdl->phba = phba; in lpfc_hba_eq_hdl_array_init()
10925 * lpfc_cpu_affinity_check - Check vector CPU affinity mappings
10929 * The routine will figure out the CPU affinity assignment for every
10930 * MSI-X vector allocated for the HBA.
10931 * In addition, the CPU to IO channel mapping will be calculated
10932 * and the phba->sli4_hba.cpu_map array will reflect this.
10937 int i, cpu, idx, next_idx, new_cpu, start_cpu, first_cpu; in lpfc_cpu_affinity_check() local
10954 /* Update CPU map with physical id and core id of each CPU */ in lpfc_cpu_affinity_check()
10955 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
10956 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
10958 cpuinfo = &cpu_data(cpu); in lpfc_cpu_affinity_check()
10959 cpup->phys_id = cpuinfo->phys_proc_id; in lpfc_cpu_affinity_check()
10960 cpup->core_id = cpuinfo->cpu_core_id; in lpfc_cpu_affinity_check()
10961 if (lpfc_find_hyper(phba, cpu, cpup->phys_id, cpup->core_id)) in lpfc_cpu_affinity_check()
10962 cpup->flag |= LPFC_CPU_MAP_HYPER; in lpfc_cpu_affinity_check()
10965 cpup->phys_id = 0; in lpfc_cpu_affinity_check()
10966 cpup->core_id = cpu; in lpfc_cpu_affinity_check()
10970 "3328 CPU %d physid %d coreid %d flag x%x\n", in lpfc_cpu_affinity_check()
10971 cpu, cpup->phys_id, cpup->core_id, cpup->flag); in lpfc_cpu_affinity_check()
10973 if (cpup->phys_id > max_phys_id) in lpfc_cpu_affinity_check()
10974 max_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
10975 if (cpup->phys_id < min_phys_id) in lpfc_cpu_affinity_check()
10976 min_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
10978 if (cpup->core_id > max_core_id) in lpfc_cpu_affinity_check()
10979 max_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
10980 if (cpup->core_id < min_core_id) in lpfc_cpu_affinity_check()
10981 min_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
10986 * Next we will set any unassigned (unaffinitized) cpu map in lpfc_cpu_affinity_check()
10992 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
10993 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
10995 /* Is this CPU entry unassigned */ in lpfc_cpu_affinity_check()
10996 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
10997 /* Mark CPU as IRQ not assigned by the kernel */ in lpfc_cpu_affinity_check()
10998 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
11006 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
11007 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
11008 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
11009 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY) && in lpfc_cpu_affinity_check()
11010 (new_cpup->phys_id == cpup->phys_id)) in lpfc_cpu_affinity_check()
11017 /* At this point, we leave the CPU as unassigned */ in lpfc_cpu_affinity_check()
11021 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
11024 * chance of having multiple unassigned CPU entries in lpfc_cpu_affinity_check()
11032 "3337 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
11033 "eq %d from peer cpu %d same " in lpfc_cpu_affinity_check()
11035 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
11036 cpup->phys_id); in lpfc_cpu_affinity_check()
11040 /* Set any unassigned cpu map entries to a IRQ on any phys_id */ in lpfc_cpu_affinity_check()
11043 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
11044 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
11047 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
11049 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
11057 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
11058 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
11059 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
11060 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY)) in lpfc_cpu_affinity_check()
11069 "3339 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
11071 cpup->hdwq, cpup->eq); in lpfc_cpu_affinity_check()
11075 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
11078 * chance of having multiple unassigned CPU entries in lpfc_cpu_affinity_check()
11086 "3338 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
11087 "eq %d from peer cpu %d (%d/%d)\n", in lpfc_cpu_affinity_check()
11088 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
11089 new_cpup->phys_id, new_cpup->core_id); in lpfc_cpu_affinity_check()
11097 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
11098 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
11101 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_cpu_affinity_check()
11105 cpup->hdwq = idx; in lpfc_cpu_affinity_check()
11108 "3333 Set Affinity: CPU %d (phys %d core %d): " in lpfc_cpu_affinity_check()
11110 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
11111 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
11114 * This will be 1 to 1 - hdwq to cpu, unless there are less in lpfc_cpu_affinity_check()
11115 * hardware queues then CPUs. For that case we will just round-robin in lpfc_cpu_affinity_check()
11118 * for irq_chann < hdwq. The idx is used for round-robin assignments in lpfc_cpu_affinity_check()
11124 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
11125 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
11128 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_cpu_affinity_check()
11135 if (next_idx < phba->cfg_hdw_queue) { in lpfc_cpu_affinity_check()
11136 cpup->hdwq = next_idx; in lpfc_cpu_affinity_check()
11141 /* Not a First CPU and all hdw_queues are used. Reuse a in lpfc_cpu_affinity_check()
11142 * Hardware Queue for another CPU, so be smart about it in lpfc_cpu_affinity_check()
11144 * (CPU package) and core_id. in lpfc_cpu_affinity_check()
11147 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
11148 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
11149 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
11150 new_cpup->phys_id == cpup->phys_id && in lpfc_cpu_affinity_check()
11151 new_cpup->core_id == cpup->core_id) { in lpfc_cpu_affinity_check()
11163 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
11164 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
11165 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
11166 new_cpup->phys_id == cpup->phys_id) in lpfc_cpu_affinity_check()
11175 cpup->hdwq = idx % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
11183 cpup->hdwq = new_cpup->hdwq; in lpfc_cpu_affinity_check()
11186 "3335 Set Affinity: CPU %d (phys %d core %d): " in lpfc_cpu_affinity_check()
11188 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
11189 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
11193 * Initialize the cpu_map slots for not-present cpus in case in lpfc_cpu_affinity_check()
11194 * a cpu is hot-added. Perform a simple hdwq round robin assignment. in lpfc_cpu_affinity_check()
11197 for_each_possible_cpu(cpu) { in lpfc_cpu_affinity_check()
11198 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
11200 c_stat = per_cpu_ptr(phba->sli4_hba.c_stat, cpu); in lpfc_cpu_affinity_check()
11201 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
11203 if (cpup->hdwq != LPFC_VECTOR_MAP_EMPTY) in lpfc_cpu_affinity_check()
11206 cpup->hdwq = idx++ % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
11208 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
11212 "CPU %d hdwq %d\n", in lpfc_cpu_affinity_check()
11213 cpu, cpup->hdwq); in lpfc_cpu_affinity_check()
11226 * @cpu: cpu going offline
11230 lpfc_cpuhp_get_eq(struct lpfc_hba *phba, unsigned int cpu, in lpfc_cpuhp_get_eq() argument
11240 return -ENOMEM; in lpfc_cpuhp_get_eq()
11242 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_cpuhp_get_eq()
11243 maskp = pci_irq_get_affinity(phba->pcidev, idx); in lpfc_cpuhp_get_eq()
11247 * if irq is not affinitized to the cpu going in lpfc_cpuhp_get_eq()
11251 if (!cpumask_and(tmp, maskp, cpumask_of(cpu))) in lpfc_cpuhp_get_eq()
11253 /* get the cpus that are online and are affini- in lpfc_cpuhp_get_eq()
11255 * more than 1 then cpuhp is not going to shut- in lpfc_cpuhp_get_eq()
11256 * down this vector. Since this cpu has not in lpfc_cpuhp_get_eq()
11268 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_cpuhp_get_eq()
11269 list_add(&eq->_poll_list, eqlist); in lpfc_cpuhp_get_eq()
11277 if (phba->sli_rev != LPFC_SLI_REV4) in __lpfc_cpuhp_remove()
11281 &phba->cpuhp); in __lpfc_cpuhp_remove()
11287 del_timer_sync(&phba->cpuhp_poll_timer); in __lpfc_cpuhp_remove()
11292 if (phba->pport->fc_flag & FC_OFFLINE_MODE) in lpfc_cpuhp_remove()
11300 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_cpuhp_add()
11305 if (!list_empty(&phba->poll_list)) in lpfc_cpuhp_add()
11306 mod_timer(&phba->cpuhp_poll_timer, in lpfc_cpuhp_add()
11312 &phba->cpuhp); in lpfc_cpuhp_add()
11317 if (phba->pport->load_flag & FC_UNLOADING) { in __lpfc_cpuhp_checks()
11318 *retval = -EAGAIN; in __lpfc_cpuhp_checks()
11322 if (phba->sli_rev != LPFC_SLI_REV4) { in __lpfc_cpuhp_checks()
11332 * lpfc_irq_set_aff - set IRQ affinity
11334 * @cpu: cpu to set affinity
11338 lpfc_irq_set_aff(struct lpfc_hba_eq_hdl *eqhdl, unsigned int cpu) in lpfc_irq_set_aff() argument
11340 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_set_aff()
11341 cpumask_set_cpu(cpu, &eqhdl->aff_mask); in lpfc_irq_set_aff()
11342 irq_set_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_set_aff()
11343 irq_set_affinity_hint(eqhdl->irq, &eqhdl->aff_mask); in lpfc_irq_set_aff()
11347 * lpfc_irq_clear_aff - clear IRQ affinity
11354 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_clear_aff()
11355 irq_clear_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_clear_aff()
11359 * lpfc_irq_rebalance - rebalances IRQ affinity according to cpuhp event
11361 * @cpu: cpu going offline/online
11362 * @offline: true, cpu is going offline. false, cpu is coming online.
11364 * If cpu is going offline, we'll try our best effort to find the next
11365 * online cpu on the phba's original_mask and migrate all offlining IRQ
11368 * If cpu is coming online, reaffinitize the IRQ back to the onlining cpu.
11371 * PCI_IRQ_AFFINITY to auto-manage IRQ affinity.
11375 lpfc_irq_rebalance(struct lpfc_hba *phba, unsigned int cpu, bool offline) in lpfc_irq_rebalance() argument
11382 if (phba->irq_chann_mode == NORMAL_MODE) in lpfc_irq_rebalance()
11385 orig_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_irq_rebalance()
11387 if (!cpumask_test_cpu(cpu, orig_mask)) in lpfc_irq_rebalance()
11390 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_irq_rebalance()
11392 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_irq_rebalance()
11396 /* Find next online CPU on original mask */ in lpfc_irq_rebalance()
11397 cpu_next = cpumask_next_wrap(cpu, orig_mask, cpu, true); in lpfc_irq_rebalance()
11400 /* Found a valid CPU */ in lpfc_irq_rebalance()
11401 if ((cpu_select < nr_cpu_ids) && (cpu_select != cpu)) { in lpfc_irq_rebalance()
11403 * cpu aff_mask is migrated in lpfc_irq_rebalance()
11405 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_irq_rebalance()
11409 if (cpumask_test_cpu(cpu, aff_mask)) in lpfc_irq_rebalance()
11415 for (idx = 0; idx < phba->cfg_irq_chann; idx++) in lpfc_irq_rebalance()
11419 /* Migrate affinity back to this CPU */ in lpfc_irq_rebalance()
11420 lpfc_irq_set_aff(lpfc_get_eq_hdl(cpup->eq), cpu); in lpfc_irq_rebalance()
11424 static int lpfc_cpu_offline(unsigned int cpu, struct hlist_node *node) in lpfc_cpu_offline() argument
11432 WARN_ONCE(!phba, "cpu: %u. phba:NULL", raw_smp_processor_id()); in lpfc_cpu_offline()
11439 lpfc_irq_rebalance(phba, cpu, true); in lpfc_cpu_offline()
11441 retval = lpfc_cpuhp_get_eq(phba, cpu, &eqlist); in lpfc_cpu_offline()
11447 list_del_init(&eq->_poll_list); in lpfc_cpu_offline()
11454 static int lpfc_cpu_online(unsigned int cpu, struct hlist_node *node) in lpfc_cpu_online() argument
11462 WARN_ONCE(!phba, "cpu: %u. phba:NULL", raw_smp_processor_id()); in lpfc_cpu_online()
11469 lpfc_irq_rebalance(phba, cpu, false); in lpfc_cpu_online()
11471 list_for_each_entry_safe(eq, next, &phba->poll_list, _poll_list) { in lpfc_cpu_online()
11472 n = lpfc_find_cpu_handle(phba, eq->hdwq, LPFC_FIND_BY_HDWQ); in lpfc_cpu_online()
11473 if (n == cpu) in lpfc_cpu_online()
11481 * lpfc_sli4_enable_msix - Enable MSI-X interrupt mode to SLI-4 device
11484 * This routine is invoked to enable the MSI-X interrupt vectors to device
11485 * with SLI-4 interface spec. It also allocates MSI-X vectors and maps them
11491 * allocated and assigned to each online and offline cpu. If the cpu is
11492 * online, then affinity will be set to that cpu. If the cpu is offline, then
11493 * affinity will be set to the nearest peer cpu within the numa node that is
11495 * assigned and the OS may do as it pleases. Note: cpu vector affinity mapping
11496 * is consistent with the way cpu online/offline is handled when cfg_irq_numa is
11501 * cpu affinity. The driver will then use that affinity mapping to setup its
11502 * cpu mapping table.
11505 * 0 - successful
11506 * other values - error
11514 unsigned int cpu = 0, cpu_cnt = 0, cpu_select = nr_cpu_ids; in lpfc_sli4_enable_msix() local
11520 /* Set up MSI-X multi-message vectors */ in lpfc_sli4_enable_msix()
11521 vectors = phba->cfg_irq_chann; in lpfc_sli4_enable_msix()
11523 if (phba->irq_chann_mode != NORMAL_MODE) in lpfc_sli4_enable_msix()
11524 aff_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_sli4_enable_msix()
11528 vectors = min(phba->cfg_irq_chann, cpu_cnt); in lpfc_sli4_enable_msix()
11530 /* cpu: iterates over aff_mask including offline or online in lpfc_sli4_enable_msix()
11533 cpu = cpumask_first(aff_mask); in lpfc_sli4_enable_msix()
11534 cpu_select = lpfc_next_online_cpu(aff_mask, cpu); in lpfc_sli4_enable_msix()
11539 rc = pci_alloc_irq_vectors(phba->pcidev, 1, vectors, flags); in lpfc_sli4_enable_msix()
11542 "0484 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli4_enable_msix()
11547 /* Assign MSI-X vectors to interrupt handlers */ in lpfc_sli4_enable_msix()
11550 name = eqhdl->handler_name; in lpfc_sli4_enable_msix()
11555 eqhdl->idx = index; in lpfc_sli4_enable_msix()
11556 rc = request_irq(pci_irq_vector(phba->pcidev, index), in lpfc_sli4_enable_msix()
11561 "0486 MSI-X fast-path (%d) " in lpfc_sli4_enable_msix()
11566 eqhdl->irq = pci_irq_vector(phba->pcidev, index); in lpfc_sli4_enable_msix()
11569 /* If found a neighboring online cpu, set affinity */ in lpfc_sli4_enable_msix()
11576 cpu); in lpfc_sli4_enable_msix()
11578 /* Iterate to next offline or online cpu in aff_mask */ in lpfc_sli4_enable_msix()
11579 cpu = cpumask_next(cpu, aff_mask); in lpfc_sli4_enable_msix()
11581 /* Find next online cpu in aff_mask to set affinity */ in lpfc_sli4_enable_msix()
11582 cpu_select = lpfc_next_online_cpu(aff_mask, cpu); in lpfc_sli4_enable_msix()
11584 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_msix()
11586 cpu); in lpfc_sli4_enable_msix()
11588 maskp = pci_irq_get_affinity(phba->pcidev, index); in lpfc_sli4_enable_msix()
11591 for_each_cpu_and(cpu, maskp, cpu_present_mask) { in lpfc_sli4_enable_msix()
11592 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_enable_msix()
11594 /* If this is the first CPU thats assigned to in lpfc_sli4_enable_msix()
11598 * vectors are affinitized to all the cpu's. in lpfc_sli4_enable_msix()
11606 if (cpup->eq != LPFC_VECTOR_MAP_EMPTY) in lpfc_sli4_enable_msix()
11610 cpu); in lpfc_sli4_enable_msix()
11616 if (vectors != phba->cfg_irq_chann) { in lpfc_sli4_enable_msix()
11619 "MSI-X vectors, requested %d got %d\n", in lpfc_sli4_enable_msix()
11620 phba->cfg_irq_chann, vectors); in lpfc_sli4_enable_msix()
11621 if (phba->cfg_irq_chann > vectors) in lpfc_sli4_enable_msix()
11622 phba->cfg_irq_chann = vectors; in lpfc_sli4_enable_msix()
11629 for (--index; index >= 0; index--) { in lpfc_sli4_enable_msix()
11632 irq_set_affinity_hint(eqhdl->irq, NULL); in lpfc_sli4_enable_msix()
11633 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_enable_msix()
11636 /* Unconfigure MSI-X capability structure */ in lpfc_sli4_enable_msix()
11637 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msix()
11644 * lpfc_sli4_enable_msi - Enable MSI interrupt mode to SLI-4 device
11648 * SLI-4 interface spec. The kernel function pci_alloc_irq_vectors() is
11654 * 0 - successful
11655 * other values - error
11661 unsigned int cpu; in lpfc_sli4_enable_msi() local
11664 rc = pci_alloc_irq_vectors(phba->pcidev, 1, 1, in lpfc_sli4_enable_msi()
11672 return rc ? rc : -1; in lpfc_sli4_enable_msi()
11675 rc = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_msi()
11678 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msi()
11685 eqhdl->irq = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_msi()
11687 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_msi()
11688 lpfc_assign_eq_map_info(phba, 0, LPFC_CPU_FIRST_IRQ, cpu); in lpfc_sli4_enable_msi()
11690 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_enable_msi()
11692 eqhdl->idx = index; in lpfc_sli4_enable_msi()
11699 * lpfc_sli4_enable_intr - Enable device interrupt to SLI-4 device
11701 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
11704 * interrupt handler(s) to interrupt vector(s) to device with SLI-4
11709 * MSI-X -> MSI -> IRQ.
11712 * 0 - successful
11713 * other values - error
11725 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli4_enable_intr()
11728 /* Indicate initialization to MSI-X mode */ in lpfc_sli4_enable_intr()
11729 phba->intr_type = MSIX; in lpfc_sli4_enable_intr()
11735 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli4_enable_intr()
11736 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
11740 phba->intr_type = MSI; in lpfc_sli4_enable_intr()
11745 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli4_enable_intr()
11746 if (phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
11747 retval = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_intr()
11751 unsigned int cpu; in lpfc_sli4_enable_intr() local
11754 phba->intr_type = INTx; in lpfc_sli4_enable_intr()
11758 eqhdl->irq = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_intr()
11760 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_intr()
11762 cpu); in lpfc_sli4_enable_intr()
11763 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_enable_intr()
11765 eqhdl->idx = idx; in lpfc_sli4_enable_intr()
11773 * lpfc_sli4_disable_intr - Disable device interrupt to SLI-4 device
11778 * with SLI-4 interface spec. Depending on the interrupt mode, the driver
11785 if (phba->intr_type == MSIX) { in lpfc_sli4_disable_intr()
11789 /* Free up MSI-X multi-message vectors */ in lpfc_sli4_disable_intr()
11790 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_disable_intr()
11793 irq_set_affinity_hint(eqhdl->irq, NULL); in lpfc_sli4_disable_intr()
11794 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_disable_intr()
11797 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_disable_intr()
11800 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_disable_intr()
11803 phba->intr_type = NONE; in lpfc_sli4_disable_intr()
11804 phba->sli.slistat.sli_intr = 0; in lpfc_sli4_disable_intr()
11808 * lpfc_unset_hba - Unset SLI3 hba device initialization
11812 * a device with SLI-3 interface spec.
11817 struct lpfc_vport *vport = phba->pport; in lpfc_unset_hba()
11820 spin_lock_irq(shost->host_lock); in lpfc_unset_hba()
11821 vport->load_flag |= FC_UNLOADING; in lpfc_unset_hba()
11822 spin_unlock_irq(shost->host_lock); in lpfc_unset_hba()
11824 kfree(phba->vpi_bmask); in lpfc_unset_hba()
11825 kfree(phba->vpi_ids); in lpfc_unset_hba()
11829 phba->pport->work_port_events = 0; in lpfc_unset_hba()
11841 * lpfc_sli4_xri_exchange_busy_wait - Wait for device XRI exchange busy
11861 int els_xri_cmpl = list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
11870 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_xri_exchange_busy_wait()
11874 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
11875 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
11876 io_xri_cmpl = list_empty(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
11883 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
11885 list_empty(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
11913 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
11914 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
11916 &qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
11923 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
11925 &phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
11928 list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
11934 * lpfc_sli4_hba_unset - Unset the fcoe hba
11948 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_hba_unset()
11951 if (phba->pport) in lpfc_sli4_hba_unset()
11952 phba->sli4_hba.intr_enable = 0; in lpfc_sli4_hba_unset()
11960 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
11961 phba->sli.sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_hba_unset()
11962 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
11964 while (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
11970 if (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
11971 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
11972 mboxq = phba->sli.mbox_active; in lpfc_sli4_hba_unset()
11973 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_hba_unset()
11975 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_hba_unset()
11976 phba->sli.mbox_active = NULL; in lpfc_sli4_hba_unset()
11977 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
11986 /* per-phba callback de-registration for hotplug event */ in lpfc_sli4_hba_unset()
11987 if (phba->pport) in lpfc_sli4_hba_unset()
11993 /* Disable SR-IOV if enabled */ in lpfc_sli4_hba_unset()
11994 if (phba->cfg_sriov_nr_virtfn) in lpfc_sli4_hba_unset()
11998 kthread_stop(phba->worker_thread); in lpfc_sli4_hba_unset()
12013 if (phba->ras_fwlog.ras_enabled) in lpfc_sli4_hba_unset()
12017 if (phba->pport) in lpfc_sli4_hba_unset()
12018 phba->pport->work_port_events = 0; in lpfc_sli4_hba_unset()
12022 * lpfc_get_sli4_parameters - Get the SLI4 Config PARAMETERS.
12029 * This function may be be called from any context that can block-wait
12037 struct lpfc_mqe *mqe = &mboxq->u.mqe; in lpfc_get_sli4_parameters()
12049 phba->sli4_hba.rpi_hdrs_in_use = 1; in lpfc_get_sli4_parameters()
12052 length = (sizeof(struct lpfc_mbx_get_sli4_parameters) - in lpfc_get_sli4_parameters()
12057 if (!phba->sli4_hba.intr_enable) in lpfc_get_sli4_parameters()
12065 sli4_params = &phba->sli4_hba.pc_sli4_params; in lpfc_get_sli4_parameters()
12066 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters; in lpfc_get_sli4_parameters()
12067 sli4_params->if_type = bf_get(cfg_if_type, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12068 sli4_params->sli_rev = bf_get(cfg_sli_rev, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12069 sli4_params->sli_family = bf_get(cfg_sli_family, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12070 sli4_params->featurelevel_1 = bf_get(cfg_sli_hint_1, in lpfc_get_sli4_parameters()
12072 sli4_params->featurelevel_2 = bf_get(cfg_sli_hint_2, in lpfc_get_sli4_parameters()
12075 phba->sli3_options |= LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
12077 phba->sli3_options &= ~LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
12078 sli4_params->sge_supp_len = mbx_sli4_parameters->sge_supp_len; in lpfc_get_sli4_parameters()
12079 sli4_params->loopbk_scope = bf_get(cfg_loopbk_scope, in lpfc_get_sli4_parameters()
12081 sli4_params->oas_supported = bf_get(cfg_oas, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12082 sli4_params->cqv = bf_get(cfg_cqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12083 sli4_params->mqv = bf_get(cfg_mqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12084 sli4_params->wqv = bf_get(cfg_wqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12085 sli4_params->rqv = bf_get(cfg_rqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12086 sli4_params->eqav = bf_get(cfg_eqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12087 sli4_params->cqav = bf_get(cfg_cqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12088 sli4_params->wqsize = bf_get(cfg_wqsize, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12089 sli4_params->bv1s = bf_get(cfg_bv1s, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12090 sli4_params->pls = bf_get(cfg_pvl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12091 sli4_params->sgl_pages_max = bf_get(cfg_sgl_page_cnt, in lpfc_get_sli4_parameters()
12093 sli4_params->wqpcnt = bf_get(cfg_wqpcnt, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12094 sli4_params->sgl_pp_align = bf_get(cfg_sgl_pp_align, in lpfc_get_sli4_parameters()
12096 phba->sli4_hba.extents_in_use = bf_get(cfg_ext, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12097 phba->sli4_hba.rpi_hdrs_in_use = bf_get(cfg_hdrr, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12099 /* Check for Extended Pre-Registered SGL support */ in lpfc_get_sli4_parameters()
12100 phba->cfg_xpsgl = bf_get(cfg_xpsgl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12108 sli4_params->nvme = 1; in lpfc_get_sli4_parameters()
12111 if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP) { in lpfc_get_sli4_parameters()
12115 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
12120 sli4_params->nvme = 0; in lpfc_get_sli4_parameters()
12121 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_get_sli4_parameters()
12127 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
12129 phba->nvme_support = 0; in lpfc_get_sli4_parameters()
12130 phba->nvmet_support = 0; in lpfc_get_sli4_parameters()
12131 phba->cfg_nvmet_mrq = 0; in lpfc_get_sli4_parameters()
12132 phba->cfg_nvme_seg_cnt = 0; in lpfc_get_sli4_parameters()
12135 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_get_sli4_parameters()
12136 return -ENODEV; in lpfc_get_sli4_parameters()
12137 phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; in lpfc_get_sli4_parameters()
12144 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_get_sli4_parameters()
12145 phba->cfg_sg_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_get_sli4_parameters()
12148 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) != in lpfc_get_sli4_parameters()
12150 phba->cfg_enable_pbde = 0; in lpfc_get_sli4_parameters()
12155 * In SLI4-Parameters Descriptor: in lpfc_get_sli4_parameters()
12160 if (phba->cfg_suppress_rsp && bf_get(cfg_xib, mbx_sli4_parameters) && in lpfc_get_sli4_parameters()
12162 phba->sli.sli_flag |= LPFC_SLI_SUPPRESS_RSP; in lpfc_get_sli4_parameters()
12164 phba->cfg_suppress_rsp = 0; in lpfc_get_sli4_parameters()
12167 phba->sli.sli_flag |= LPFC_SLI_USE_EQDR; in lpfc_get_sli4_parameters()
12170 if (sli4_params->sge_supp_len > LPFC_MAX_SGE_SIZE) in lpfc_get_sli4_parameters()
12171 sli4_params->sge_supp_len = LPFC_MAX_SGE_SIZE; in lpfc_get_sli4_parameters()
12176 * to use this option, 128-byte WQEs must be used. in lpfc_get_sli4_parameters()
12179 phba->fcp_embed_io = 1; in lpfc_get_sli4_parameters()
12181 phba->fcp_embed_io = 0; in lpfc_get_sli4_parameters()
12186 phba->cfg_enable_pbde, in lpfc_get_sli4_parameters()
12187 phba->fcp_embed_io, phba->nvme_support, in lpfc_get_sli4_parameters()
12188 phba->cfg_nvme_embed_cmd, phba->cfg_suppress_rsp); in lpfc_get_sli4_parameters()
12190 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
12192 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
12199 (sli4_params->wqsize & LPFC_WQ_SZ128_SUPPORT)) in lpfc_get_sli4_parameters()
12200 phba->enab_exp_wqcq_pages = 1; in lpfc_get_sli4_parameters()
12202 phba->enab_exp_wqcq_pages = 0; in lpfc_get_sli4_parameters()
12207 phba->mds_diags_support = 1; in lpfc_get_sli4_parameters()
12209 phba->mds_diags_support = 0; in lpfc_get_sli4_parameters()
12215 phba->nsler = 1; in lpfc_get_sli4_parameters()
12217 phba->nsler = 0; in lpfc_get_sli4_parameters()
12223 * lpfc_pci_probe_one_s3 - PCI probe func to reg SLI-3 device to PCI subsystem.
12227 * This routine is to be called to attach a device with SLI-3 interface spec
12228 * to the PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
12229 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
12236 * 0 - driver can claim the device
12237 * negative value - driver can not claim the device
12251 return -ENOMEM; in lpfc_pci_probe_one_s3()
12258 /* Set up SLI API function jump table for PCI-device group-0 HBAs */ in lpfc_pci_probe_one_s3()
12263 /* Set up SLI-3 specific device PCI memory space */ in lpfc_pci_probe_one_s3()
12271 /* Set up SLI-3 specific device driver resources */ in lpfc_pci_probe_one_s3()
12297 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s3()
12308 vport = phba->pport; in lpfc_pci_probe_one_s3()
12318 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s3()
12327 error = -ENODEV; in lpfc_pci_probe_one_s3()
12330 /* SLI-3 HBA setup */ in lpfc_pci_probe_one_s3()
12334 error = -ENODEV; in lpfc_pci_probe_one_s3()
12342 phba->sli.slistat.sli_intr > LPFC_MSIX_VECTORS) { in lpfc_pci_probe_one_s3()
12344 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s3()
12355 cfg_mode = --intr_mode; in lpfc_pci_probe_one_s3()
12391 * lpfc_pci_remove_one_s3 - PCI func to unreg SLI-3 device from PCI subsystem.
12394 * This routine is to be called to disattach a device with SLI-3 interface
12395 * spec from PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
12403 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s3()
12405 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s3()
12408 spin_lock_irq(&phba->hbalock); in lpfc_pci_remove_one_s3()
12409 vport->load_flag |= FC_UNLOADING; in lpfc_pci_remove_one_s3()
12410 spin_unlock_irq(&phba->hbalock); in lpfc_pci_remove_one_s3()
12417 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s3()
12418 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s3()
12420 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s3()
12439 kthread_stop(phba->worker_thread); in lpfc_pci_remove_one_s3()
12443 kfree(phba->vpi_bmask); in lpfc_pci_remove_one_s3()
12444 kfree(phba->vpi_ids); in lpfc_pci_remove_one_s3()
12447 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
12448 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s3()
12449 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
12453 /* Disable SR-IOV if enabled */ in lpfc_pci_remove_one_s3()
12454 if (phba->cfg_sriov_nr_virtfn) in lpfc_pci_remove_one_s3()
12471 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_pci_remove_one_s3()
12472 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_pci_remove_one_s3()
12475 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_pci_remove_one_s3()
12476 phba->slim2p.virt, phba->slim2p.phys); in lpfc_pci_remove_one_s3()
12479 iounmap(phba->ctrl_regs_memmap_p); in lpfc_pci_remove_one_s3()
12480 iounmap(phba->slim_memmap_p); in lpfc_pci_remove_one_s3()
12489 * lpfc_pci_suspend_one_s3 - PCI func to suspend SLI-3 device for power mgmnt
12494 * system Power Management (PM) to device with SLI-3 interface spec. When
12498 * minimum PM requirements to a power-aware driver's PM support for the
12499 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
12506 * 0 - driver suspended the device
12513 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s3()
12521 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s3()
12534 * lpfc_pci_resume_one_s3 - PCI func to resume SLI-3 device for power mgmnt
12538 * system Power Management (PM) to device with SLI-3 interface spec. When PM
12541 * driver implements the minimum PM requirements to a power-aware driver's
12542 * PM for suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE,
12549 * 0 - driver suspended the device
12556 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s3()
12573 if (pdev->is_busmaster) in lpfc_pci_resume_one_s3()
12577 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s3()
12578 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s3()
12579 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s3()
12580 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s3()
12588 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
12592 return -EIO; in lpfc_pci_resume_one_s3()
12594 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s3()
12601 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
12607 * lpfc_sli_prep_dev_for_recover - Prepare SLI3 device for pci slot recover
12621 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli_prep_dev_for_recover()
12627 * lpfc_sli_prep_dev_for_reset - Prepare SLI3 device for pci slot reset
12654 pci_disable_device(phba->pcidev); in lpfc_sli_prep_dev_for_reset()
12658 * lpfc_sli_prep_dev_for_perm_failure - Prepare SLI3 dev for pci slot disable
12681 * lpfc_io_error_detected_s3 - Method for handling SLI-3 device PCI I/O error
12686 * device with SLI-3 interface spec. This function is called by the PCI
12694 * PCI_ERS_RESULT_CAN_RECOVER - can be recovered with reset_link
12695 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
12696 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
12702 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s3()
12706 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s3()
12727 * lpfc_io_slot_reset_s3 - Method for restarting PCI SLI-3 device from scratch.
12731 * device with SLI-3 interface spec. This is called after PCI bus has been
12732 * reset to restart the PCI card from scratch, as if from a cold-boot.
12741 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
12742 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
12748 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s3()
12749 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s3()
12752 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s3()
12754 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s3()
12767 if (pdev->is_busmaster) in lpfc_io_slot_reset_s3()
12770 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
12771 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s3()
12772 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
12775 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
12778 "0427 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s3()
12782 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s3()
12790 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
12796 * lpfc_io_resume_s3 - Method for resuming PCI I/O operation on SLI-3 device.
12800 * with SLI-3 interface spec. It is called when kernel error recovery tells
12809 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s3()
12811 /* Bring device online, it will be no-op for non-fatal error resume */ in lpfc_io_resume_s3()
12816 * lpfc_sli4_get_els_iocb_cnt - Calculate the # of ELS IOCBs to reserve
12824 int max_xri = phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_get_els_iocb_cnt()
12826 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli4_get_els_iocb_cnt()
12846 * lpfc_sli4_get_iocb_cnt - Calculate the # of total IOCBs to reserve
12856 if (phba->nvmet_support) in lpfc_sli4_get_iocb_cnt()
12876 (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G6_FC && in lpfc_log_write_firmware_error()
12878 (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G7_FC && in lpfc_log_write_firmware_error()
12884 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
12885 fsize, fw->size); in lpfc_log_write_firmware_error()
12886 rc = -EINVAL; in lpfc_log_write_firmware_error()
12893 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
12894 fsize, fw->size); in lpfc_log_write_firmware_error()
12895 rc = -EACCES; in lpfc_log_write_firmware_error()
12901 offset, phba->pcidev->device, magic_number, in lpfc_log_write_firmware_error()
12902 ftype, fid, fsize, fw->size); in lpfc_log_write_firmware_error()
12903 rc = -EIO; in lpfc_log_write_firmware_error()
12909 * lpfc_write_firmware - attempt to write a firmware image to the port
12926 /* It can be null in no-wait mode, sanity check */ in lpfc_write_firmware()
12928 rc = -ENXIO; in lpfc_write_firmware()
12931 image = (struct lpfc_grp_hdr *)fw->data; in lpfc_write_firmware()
12933 magic_number = be32_to_cpu(image->magic_number); in lpfc_write_firmware()
12936 fsize = be32_to_cpu(image->size); in lpfc_write_firmware()
12940 if (strncmp(fwrev, image->revision, strnlen(image->revision, 16))) { in lpfc_write_firmware()
12944 fwrev, image->revision); in lpfc_write_firmware()
12949 rc = -ENOMEM; in lpfc_write_firmware()
12952 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_write_firmware()
12954 &dmabuf->phys, in lpfc_write_firmware()
12956 if (!dmabuf->virt) { in lpfc_write_firmware()
12958 rc = -ENOMEM; in lpfc_write_firmware()
12961 list_add_tail(&dmabuf->list, &dma_buffer_list); in lpfc_write_firmware()
12963 while (offset < fw->size) { in lpfc_write_firmware()
12966 if (temp_offset + SLI4_PAGE_SIZE > fw->size) { in lpfc_write_firmware()
12967 memcpy(dmabuf->virt, in lpfc_write_firmware()
12968 fw->data + temp_offset, in lpfc_write_firmware()
12969 fw->size - temp_offset); in lpfc_write_firmware()
12970 temp_offset = fw->size; in lpfc_write_firmware()
12973 memcpy(dmabuf->virt, fw->data + temp_offset, in lpfc_write_firmware()
12978 (fw->size - offset), &offset); in lpfc_write_firmware()
12994 fwrev, image->revision); in lpfc_write_firmware()
12998 list_del(&dmabuf->list); in lpfc_write_firmware()
12999 dma_free_coherent(&phba->pcidev->dev, SLI4_PAGE_SIZE, in lpfc_write_firmware()
13000 dmabuf->virt, dmabuf->phys); in lpfc_write_firmware()
13014 * lpfc_sli4_request_firmware_update - Request linux generic firmware upgrade
13029 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_request_firmware_update()
13031 return -EPERM; in lpfc_sli4_request_firmware_update()
13033 snprintf(file_name, ELX_MODEL_NAME_SIZE, "%s.grp", phba->ModelName); in lpfc_sli4_request_firmware_update()
13037 file_name, &phba->pcidev->dev, in lpfc_sli4_request_firmware_update()
13041 ret = request_firmware(&fw, file_name, &phba->pcidev->dev); in lpfc_sli4_request_firmware_update()
13045 ret = -EINVAL; in lpfc_sli4_request_firmware_update()
13052 * lpfc_pci_probe_one_s4 - PCI probe func to reg SLI-4 device to PCI subsys
13057 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
13058 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
13066 * 0 - driver can claim the device
13067 * negative value - driver can not claim the device
13081 return -ENOMEM; in lpfc_pci_probe_one_s4()
13083 INIT_LIST_HEAD(&phba->poll_list); in lpfc_pci_probe_one_s4()
13090 /* Set up SLI API function jump table for PCI-device group-1 HBAs */ in lpfc_pci_probe_one_s4()
13095 /* Set up SLI-4 specific device PCI memory space */ in lpfc_pci_probe_one_s4()
13103 /* Set up SLI-4 Specific device driver resources */ in lpfc_pci_probe_one_s4()
13111 INIT_LIST_HEAD(&phba->active_rrq_list); in lpfc_pci_probe_one_s4()
13112 INIT_LIST_HEAD(&phba->fcf.fcf_pri_list); in lpfc_pci_probe_one_s4()
13123 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s4()
13126 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s4()
13129 phba->pport = NULL; in lpfc_pci_probe_one_s4()
13143 error = -ENODEV; in lpfc_pci_probe_one_s4()
13146 /* Default to single EQ for non-MSI-X */ in lpfc_pci_probe_one_s4()
13147 if (phba->intr_type != MSIX) { in lpfc_pci_probe_one_s4()
13148 phba->cfg_irq_chann = 1; in lpfc_pci_probe_one_s4()
13149 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
13150 if (phba->nvmet_support) in lpfc_pci_probe_one_s4()
13151 phba->cfg_nvmet_mrq = 1; in lpfc_pci_probe_one_s4()
13154 lpfc_cpu_affinity_check(phba, phba->cfg_irq_chann); in lpfc_pci_probe_one_s4()
13163 vport = phba->pport; in lpfc_pci_probe_one_s4()
13174 /* Set up SLI-4 HBA */ in lpfc_pci_probe_one_s4()
13178 error = -ENODEV; in lpfc_pci_probe_one_s4()
13183 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s4()
13192 if (phba->nvmet_support == 0) { in lpfc_pci_probe_one_s4()
13193 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
13210 if (phba->cfg_request_firmware_upgrade) in lpfc_pci_probe_one_s4()
13219 timer_setup(&phba->cpuhp_poll_timer, lpfc_sli4_poll_hbtimer, 0); in lpfc_pci_probe_one_s4()
13220 cpuhp_state_add_instance_nocalls(lpfc_cpuhp_state, &phba->cpuhp); in lpfc_pci_probe_one_s4()
13246 * lpfc_pci_remove_one_s4 - PCI func to unreg SLI-4 device from PCI subsystem
13250 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
13258 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s4()
13260 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s4()
13264 spin_lock_irq(&phba->hbalock); in lpfc_pci_remove_one_s4()
13265 vport->load_flag |= FC_UNLOADING; in lpfc_pci_remove_one_s4()
13266 spin_unlock_irq(&phba->hbalock); in lpfc_pci_remove_one_s4()
13274 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s4()
13275 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s4()
13277 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s4()
13292 /* De-allocate multi-XRI pools */ in lpfc_pci_remove_one_s4()
13293 if (phba->cfg_xri_rebalancing) in lpfc_pci_remove_one_s4()
13304 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
13305 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s4()
13306 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
13332 * lpfc_pci_suspend_one_s4 - PCI func to suspend SLI-4 device for power mgmnt
13337 * Power Management (PM) to device with SLI-4 interface spec. When PM invokes
13341 * requirements to a power-aware driver's PM support for suspend/resume -- all
13349 * 0 - driver suspended the device
13356 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s4()
13364 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s4()
13378 * lpfc_pci_resume_one_s4 - PCI func to resume SLI-4 device for power mgmnt
13382 * Power Management (PM) to device with SLI-4 interface spac. When PM invokes
13385 * implements the minimum PM requirements to a power-aware driver's PM for
13386 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
13393 * 0 - driver suspended the device
13400 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s4()
13417 if (pdev->is_busmaster) in lpfc_pci_resume_one_s4()
13421 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s4()
13422 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s4()
13423 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s4()
13424 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s4()
13432 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
13436 return -EIO; in lpfc_pci_resume_one_s4()
13438 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s4()
13445 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
13451 * lpfc_sli4_prep_dev_for_recover - Prepare SLI4 device for pci slot recover
13464 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli4_prep_dev_for_recover()
13470 * lpfc_sli4_prep_dev_for_reset - Prepare SLI4 device for pci slot reset
13498 pci_disable_device(phba->pcidev); in lpfc_sli4_prep_dev_for_reset()
13502 * lpfc_sli4_prep_dev_for_perm_failure - Prepare SLI4 dev for pci slot disable
13526 * lpfc_io_error_detected_s4 - Method for handling PCI I/O error to SLI-4 device
13531 * with SLI-4 interface spec. This function is called by the PCI subsystem
13538 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
13539 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
13545 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s4()
13549 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s4()
13570 * lpfc_io_slot_reset_s4 - Method for restart PCI SLI-4 device from scratch
13574 * with SLI-4 interface spec. It is called after PCI bus has been reset to
13575 * restart the PCI card from scratch, as if from a cold-boot. During the
13584 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
13585 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
13591 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s4()
13592 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s4()
13595 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s4()
13597 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s4()
13610 if (pdev->is_busmaster) in lpfc_io_slot_reset_s4()
13613 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
13614 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s4()
13615 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
13618 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
13621 "2824 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s4()
13625 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s4()
13628 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
13634 * lpfc_io_resume_s4 - Method for resuming PCI I/O operation to SLI-4 device
13638 * with SLI-4 interface spec. It is called when kernel error recovery tells
13647 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s4()
13655 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) { in lpfc_io_resume_s4()
13666 * lpfc_pci_probe_one - lpfc PCI probe func to reg dev to PCI subsystem
13672 * at PCI device-specific information of the device and driver to see if the
13675 * the action to the proper SLI-3 or SLI-4 device probing routine, which will
13680 * 0 - driver can claim the device
13681 * negative value - driver can not claim the device
13690 return -ENODEV; in lpfc_pci_probe_one()
13702 * lpfc_pci_remove_one - lpfc PCI func to unreg dev from PCI subsystem
13707 * This routine dispatches the action to the proper SLI-3 or SLI-4 device
13715 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_remove_one()
13717 switch (phba->pci_dev_grp) { in lpfc_pci_remove_one()
13727 phba->pci_dev_grp); in lpfc_pci_remove_one()
13734 * lpfc_pci_suspend_one - lpfc PCI func to suspend dev for power management
13740 * the action to the proper SLI-3 or SLI-4 device suspend routine, which will
13744 * 0 - driver suspended the device
13751 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one()
13752 int rc = -ENODEV; in lpfc_pci_suspend_one()
13754 switch (phba->pci_dev_grp) { in lpfc_pci_suspend_one()
13764 phba->pci_dev_grp); in lpfc_pci_suspend_one()
13771 * lpfc_pci_resume_one - lpfc PCI func to resume dev for power management
13776 * the action to the proper SLI-3 or SLI-4 device resume routine, which will
13780 * 0 - driver suspended the device
13787 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one()
13788 int rc = -ENODEV; in lpfc_pci_resume_one()
13790 switch (phba->pci_dev_grp) { in lpfc_pci_resume_one()
13800 phba->pci_dev_grp); in lpfc_pci_resume_one()
13807 * lpfc_io_error_detected - lpfc method for handling PCI I/O error
13814 * the action to the proper SLI-3 or SLI-4 device error detected handling
13818 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
13819 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
13825 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected()
13828 switch (phba->pci_dev_grp) { in lpfc_io_error_detected()
13838 phba->pci_dev_grp); in lpfc_io_error_detected()
13845 * lpfc_io_slot_reset - lpfc method for restart PCI dev from scratch
13850 * from scratch, as if from a cold-boot. When this routine is invoked, it
13851 * dispatches the action to the proper SLI-3 or SLI-4 device reset handling
13855 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
13856 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
13862 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset()
13865 switch (phba->pci_dev_grp) { in lpfc_io_slot_reset()
13875 phba->pci_dev_grp); in lpfc_io_slot_reset()
13882 * lpfc_io_resume - lpfc method for resuming PCI I/O operation
13888 * this routine is invoked, it dispatches the action to the proper SLI-3
13889 * or SLI-4 device io_resume routine, which will resume the device operation.
13895 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume()
13897 switch (phba->pci_dev_grp) { in lpfc_io_resume()
13907 phba->pci_dev_grp); in lpfc_io_resume()
13914 * lpfc_sli4_oas_verify - Verify OAS is supported by this adapter
13927 if (!phba->cfg_EnableXLane) in lpfc_sli4_oas_verify()
13930 if (phba->sli4_hba.pc_sli4_params.oas_supported) { in lpfc_sli4_oas_verify()
13931 phba->cfg_fof = 1; in lpfc_sli4_oas_verify()
13933 phba->cfg_fof = 0; in lpfc_sli4_oas_verify()
13934 mempool_destroy(phba->device_data_mem_pool); in lpfc_sli4_oas_verify()
13935 phba->device_data_mem_pool = NULL; in lpfc_sli4_oas_verify()
13942 * lpfc_sli4_ras_init - Verify RAS-FW log is supported by this adapter
13951 switch (phba->pcidev->device) { in lpfc_sli4_ras_init()
13954 phba->ras_fwlog.ras_hwsupport = true; in lpfc_sli4_ras_init()
13955 if (phba->cfg_ras_fwlog_func == PCI_FUNC(phba->pcidev->devfn) && in lpfc_sli4_ras_init()
13956 phba->cfg_ras_fwlog_buffsize) in lpfc_sli4_ras_init()
13957 phba->ras_fwlog.ras_enabled = true; in lpfc_sli4_ras_init()
13959 phba->ras_fwlog.ras_enabled = false; in lpfc_sli4_ras_init()
13962 phba->ras_fwlog.ras_hwsupport = false; in lpfc_sli4_ras_init()
13997 * lpfc_init - lpfc module initialization routine
14004 * 0 - successful
14005 * -ENOMEM - FC attach transport failed
14006 * all others - failed
14021 error = -ENOMEM; in lpfc_init()
14073 if (phba->cfg_log_verbose) in lpfc_dmp_dbg()
14076 if (atomic_cmpxchg(&phba->dbg_log_dmping, 0, 1) != 0) in lpfc_dmp_dbg()
14079 start_idx = (unsigned int)atomic_read(&phba->dbg_log_idx) % DBG_LOG_SZ; in lpfc_dmp_dbg()
14080 dbg_cnt = (unsigned int)atomic_read(&phba->dbg_log_cnt); in lpfc_dmp_dbg()
14084 temp_idx -= 1; in lpfc_dmp_dbg()
14086 if ((start_idx + dbg_cnt) > (DBG_LOG_SZ - 1)) { in lpfc_dmp_dbg()
14090 start_idx = DBG_LOG_SZ - (dbg_cnt - start_idx); in lpfc_dmp_dbg()
14092 start_idx -= dbg_cnt; in lpfc_dmp_dbg()
14095 dev_info(&phba->pcidev->dev, "start %d end %d cnt %d\n", in lpfc_dmp_dbg()
14103 rem_nsec = do_div(phba->dbg_log[temp_idx].t_ns, NSEC_PER_SEC); in lpfc_dmp_dbg()
14104 dev_info(&phba->pcidev->dev, "%d: [%5lu.%06lu] %s", in lpfc_dmp_dbg()
14106 (unsigned long)phba->dbg_log[temp_idx].t_ns, in lpfc_dmp_dbg()
14108 phba->dbg_log[temp_idx].log); in lpfc_dmp_dbg()
14110 atomic_set(&phba->dbg_log_cnt, 0); in lpfc_dmp_dbg()
14111 atomic_set(&phba->dbg_log_dmping, 0); in lpfc_dmp_dbg()
14119 int dbg_dmping = atomic_read(&phba->dbg_log_dmping); in lpfc_dbg_print()
14127 dev_info(&phba->pcidev->dev, "%pV", &vaf); in lpfc_dbg_print()
14131 idx = (unsigned int)atomic_fetch_add(1, &phba->dbg_log_idx) % in lpfc_dbg_print()
14134 atomic_inc(&phba->dbg_log_cnt); in lpfc_dbg_print()
14136 vscnprintf(phba->dbg_log[idx].log, in lpfc_dbg_print()
14137 sizeof(phba->dbg_log[idx].log), fmt, args); in lpfc_dbg_print()
14140 phba->dbg_log[idx].t_ns = local_clock(); in lpfc_dbg_print()
14144 * lpfc_exit - lpfc module removal routine