• 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()
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()
7080 destroy_workqueue(phba->wq); in lpfc_sli4_driver_resource_setup()
7081 phba->wq = NULL; in lpfc_sli4_driver_resource_setup()
7086 * lpfc_sli4_driver_resource_unset - Unset drvr internal resources for SLI4 dev
7090 * specific for supporting the SLI-4 HBA device it attached to.
7097 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_unset()
7099 free_percpu(phba->sli4_hba.c_stat); in lpfc_sli4_driver_resource_unset()
7101 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_unset()
7103 /* Free memory allocated for msi-x interrupt vector to CPU mapping */ in lpfc_sli4_driver_resource_unset()
7104 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_unset()
7105 phba->sli4_hba.num_possible_cpu = 0; in lpfc_sli4_driver_resource_unset()
7106 phba->sli4_hba.num_present_cpu = 0; in lpfc_sli4_driver_resource_unset()
7107 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_unset()
7108 cpumask_clear(&phba->sli4_hba.irq_aff_mask); in lpfc_sli4_driver_resource_unset()
7110 /* Free memory allocated for fast-path work queue handles */ in lpfc_sli4_driver_resource_unset()
7111 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_unset()
7118 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_unset()
7140 &phba->fcf_conn_rec_list, list) { in lpfc_sli4_driver_resource_unset()
7141 list_del_init(&conn_entry->list); in lpfc_sli4_driver_resource_unset()
7149 * lpfc_init_api_table_setup - Set up init api function jump table
7151 * @dev_grp: The HBA PCI-Device group number.
7156 * Returns: 0 - success, -ENODEV - failure.
7161 phba->lpfc_hba_init_link = lpfc_hba_init_link; in lpfc_init_api_table_setup()
7162 phba->lpfc_hba_down_link = lpfc_hba_down_link; in lpfc_init_api_table_setup()
7163 phba->lpfc_selective_reset = lpfc_selective_reset; in lpfc_init_api_table_setup()
7166 phba->lpfc_hba_down_post = lpfc_hba_down_post_s3; in lpfc_init_api_table_setup()
7167 phba->lpfc_handle_eratt = lpfc_handle_eratt_s3; in lpfc_init_api_table_setup()
7168 phba->lpfc_stop_port = lpfc_stop_port_s3; in lpfc_init_api_table_setup()
7171 phba->lpfc_hba_down_post = lpfc_hba_down_post_s4; in lpfc_init_api_table_setup()
7172 phba->lpfc_handle_eratt = lpfc_handle_eratt_s4; in lpfc_init_api_table_setup()
7173 phba->lpfc_stop_port = lpfc_stop_port_s4; in lpfc_init_api_table_setup()
7177 "1431 Invalid HBA PCI-device group: 0x%x\n", in lpfc_init_api_table_setup()
7179 return -ENODEV; in lpfc_init_api_table_setup()
7186 * lpfc_setup_driver_resource_phase2 - Phase2 setup driver internal resources.
7193 * 0 - successful
7194 * other values - error
7202 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_setup_driver_resource_phase2()
7203 "lpfc_worker_%d", phba->brd_no); in lpfc_setup_driver_resource_phase2()
7204 if (IS_ERR(phba->worker_thread)) { in lpfc_setup_driver_resource_phase2()
7205 error = PTR_ERR(phba->worker_thread); in lpfc_setup_driver_resource_phase2()
7213 * lpfc_unset_driver_resource_phase2 - Phase2 unset driver internal resources.
7223 if (phba->wq) { in lpfc_unset_driver_resource_phase2()
7224 flush_workqueue(phba->wq); in lpfc_unset_driver_resource_phase2()
7225 destroy_workqueue(phba->wq); in lpfc_unset_driver_resource_phase2()
7226 phba->wq = NULL; in lpfc_unset_driver_resource_phase2()
7230 if (phba->worker_thread) in lpfc_unset_driver_resource_phase2()
7231 kthread_stop(phba->worker_thread); in lpfc_unset_driver_resource_phase2()
7235 * lpfc_free_iocb_list - Free iocb list.
7245 spin_lock_irq(&phba->hbalock); in lpfc_free_iocb_list()
7247 &phba->lpfc_iocb_list, list) { in lpfc_free_iocb_list()
7248 list_del(&iocbq_entry->list); in lpfc_free_iocb_list()
7250 phba->total_iocbq_bufs--; in lpfc_free_iocb_list()
7252 spin_unlock_irq(&phba->hbalock); in lpfc_free_iocb_list()
7258 * lpfc_init_iocb_list - Allocate and initialize iocb list.
7266 * 0 - successful
7267 * other values - error
7277 INIT_LIST_HEAD(&phba->lpfc_iocb_list); in lpfc_init_iocb_list()
7294 iocbq_entry->sli4_lxritag = NO_XRI; in lpfc_init_iocb_list()
7295 iocbq_entry->sli4_xritag = NO_XRI; in lpfc_init_iocb_list()
7297 spin_lock_irq(&phba->hbalock); in lpfc_init_iocb_list()
7298 list_add(&iocbq_entry->list, &phba->lpfc_iocb_list); in lpfc_init_iocb_list()
7299 phba->total_iocbq_bufs++; in lpfc_init_iocb_list()
7300 spin_unlock_irq(&phba->hbalock); in lpfc_init_iocb_list()
7308 return -ENOMEM; in lpfc_init_iocb_list()
7312 * lpfc_free_sgl_list - Free a given sgl list.
7324 list_del(&sglq_entry->list); in lpfc_free_sgl_list()
7325 lpfc_mbuf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_sgl_list()
7331 * lpfc_free_els_sgl_list - Free els sgl list.
7342 spin_lock_irq(&phba->hbalock); in lpfc_free_els_sgl_list()
7343 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
7344 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, &sglq_list); in lpfc_free_els_sgl_list()
7345 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
7346 spin_unlock_irq(&phba->hbalock); in lpfc_free_els_sgl_list()
7353 * lpfc_free_nvmet_sgl_list - Free nvmet sgl list.
7365 spin_lock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
7366 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
7367 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, &sglq_list); in lpfc_free_nvmet_sgl_list()
7368 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
7369 spin_unlock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
7373 list_del(&sglq_entry->list); in lpfc_free_nvmet_sgl_list()
7374 lpfc_nvmet_buf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_nvmet_sgl_list()
7382 phba->sli4_hba.nvmet_xri_cnt = 0; in lpfc_free_nvmet_sgl_list()
7386 * lpfc_init_active_sgl_array - Allocate the buf to track active ELS XRIs.
7397 size *= phba->sli4_hba.max_cfg_param.max_xri; in lpfc_init_active_sgl_array()
7399 phba->sli4_hba.lpfc_sglq_active_list = in lpfc_init_active_sgl_array()
7401 if (!phba->sli4_hba.lpfc_sglq_active_list) in lpfc_init_active_sgl_array()
7402 return -ENOMEM; in lpfc_init_active_sgl_array()
7407 * lpfc_free_active_sgl - Free the buf that tracks active ELS XRIs.
7417 kfree(phba->sli4_hba.lpfc_sglq_active_list); in lpfc_free_active_sgl()
7421 * lpfc_init_sgl_list - Allocate and initialize sgl list.
7432 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_els_sgl_list); in lpfc_init_sgl_list()
7433 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_init_sgl_list()
7434 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_init_sgl_list()
7435 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_init_sgl_list()
7437 /* els xri-sgl book keeping */ in lpfc_init_sgl_list()
7438 phba->sli4_hba.els_xri_cnt = 0; in lpfc_init_sgl_list()
7440 /* nvme xri-buffer book keeping */ in lpfc_init_sgl_list()
7441 phba->sli4_hba.io_xri_cnt = 0; in lpfc_init_sgl_list()
7445 * lpfc_sli4_init_rpi_hdrs - Post the rpi header memory region to the port
7455 * 0 - successful
7456 * -ERROR - otherwise.
7464 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_init_rpi_hdrs()
7465 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_init_rpi_hdrs()
7467 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_init_rpi_hdrs()
7468 return -EIO; in lpfc_sli4_init_rpi_hdrs()
7475 rc = -ENODEV; in lpfc_sli4_init_rpi_hdrs()
7482 * lpfc_sli4_create_rpi_hdr - Allocate an rpi header memory region
7506 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_create_rpi_hdr()
7508 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_create_rpi_hdr()
7512 rpi_limit = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_create_rpi_hdr()
7514 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
7520 curr_rpi_range = phba->sli4_hba.next_rpi; in lpfc_sli4_create_rpi_hdr()
7521 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
7529 * port expects a 4KB DMA-mapped memory region that is 4K aligned. in lpfc_sli4_create_rpi_hdr()
7535 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_create_rpi_hdr()
7537 &dmabuf->phys, GFP_KERNEL); in lpfc_sli4_create_rpi_hdr()
7538 if (!dmabuf->virt) { in lpfc_sli4_create_rpi_hdr()
7543 if (!IS_ALIGNED(dmabuf->phys, LPFC_HDR_TEMPLATE_SIZE)) { in lpfc_sli4_create_rpi_hdr()
7553 rpi_hdr->dmabuf = dmabuf; in lpfc_sli4_create_rpi_hdr()
7554 rpi_hdr->len = LPFC_HDR_TEMPLATE_SIZE; in lpfc_sli4_create_rpi_hdr()
7555 rpi_hdr->page_count = 1; in lpfc_sli4_create_rpi_hdr()
7556 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
7559 rpi_hdr->start_rpi = curr_rpi_range; in lpfc_sli4_create_rpi_hdr()
7560 rpi_hdr->next_rpi = phba->sli4_hba.next_rpi + LPFC_RPI_HDR_COUNT; in lpfc_sli4_create_rpi_hdr()
7561 list_add_tail(&rpi_hdr->list, &phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_create_rpi_hdr()
7563 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
7567 dma_free_coherent(&phba->pcidev->dev, LPFC_HDR_TEMPLATE_SIZE, in lpfc_sli4_create_rpi_hdr()
7568 dmabuf->virt, dmabuf->phys); in lpfc_sli4_create_rpi_hdr()
7575 * lpfc_sli4_remove_rpi_hdrs - Remove all rpi header memory regions
7588 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_remove_rpi_hdrs()
7592 &phba->sli4_hba.lpfc_rpi_hdr_list, list) { in lpfc_sli4_remove_rpi_hdrs()
7593 list_del(&rpi_hdr->list); in lpfc_sli4_remove_rpi_hdrs()
7594 dma_free_coherent(&phba->pcidev->dev, rpi_hdr->len, in lpfc_sli4_remove_rpi_hdrs()
7595 rpi_hdr->dmabuf->virt, rpi_hdr->dmabuf->phys); in lpfc_sli4_remove_rpi_hdrs()
7596 kfree(rpi_hdr->dmabuf); in lpfc_sli4_remove_rpi_hdrs()
7601 phba->sli4_hba.next_rpi = 0; in lpfc_sli4_remove_rpi_hdrs()
7605 * lpfc_hba_alloc - Allocate driver hba data structure for a device.
7613 * pointer to @phba - successful
7614 * NULL - error
7624 dev_err(&pdev->dev, "failed to allocate hba struct\n"); in lpfc_hba_alloc()
7629 phba->pcidev = pdev; in lpfc_hba_alloc()
7632 phba->brd_no = lpfc_get_instance(); in lpfc_hba_alloc()
7633 if (phba->brd_no < 0) { in lpfc_hba_alloc()
7637 phba->eratt_poll_interval = LPFC_ERATT_POLL_INTERVAL; in lpfc_hba_alloc()
7639 spin_lock_init(&phba->ct_ev_lock); in lpfc_hba_alloc()
7640 INIT_LIST_HEAD(&phba->ct_ev_waiters); in lpfc_hba_alloc()
7646 * lpfc_hba_free - Free driver hba data structure with a device.
7655 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_hba_free()
7656 kfree(phba->sli4_hba.hdwq); in lpfc_hba_free()
7659 idr_remove(&lpfc_hba_index, phba->brd_no); in lpfc_hba_free()
7662 kfree(phba->sli.sli3_ring); in lpfc_hba_free()
7663 phba->sli.sli3_ring = NULL; in lpfc_hba_free()
7670 * lpfc_create_shost - Create hba physical port with associated scsi host.
7677 * 0 - successful
7678 * other values - error
7687 phba->fc_edtov = FF_DEF_EDTOV; in lpfc_create_shost()
7688 phba->fc_ratov = FF_DEF_RATOV; in lpfc_create_shost()
7689 phba->fc_altov = FF_DEF_ALTOV; in lpfc_create_shost()
7690 phba->fc_arbtov = FF_DEF_ARBTOV; in lpfc_create_shost()
7692 atomic_set(&phba->sdev_cnt, 0); in lpfc_create_shost()
7693 vport = lpfc_create_port(phba, phba->brd_no, &phba->pcidev->dev); in lpfc_create_shost()
7695 return -ENODEV; in lpfc_create_shost()
7698 phba->pport = vport; in lpfc_create_shost()
7700 if (phba->nvmet_support) { in lpfc_create_shost()
7702 phba->targetport = NULL; in lpfc_create_shost()
7703 phba->cfg_enable_fc4_type = LPFC_ENABLE_NVME; in lpfc_create_shost()
7710 pci_set_drvdata(phba->pcidev, shost); in lpfc_create_shost()
7716 vport->load_flag |= FC_ALLOW_FDMI; in lpfc_create_shost()
7717 if (phba->cfg_enable_SmartSAN || in lpfc_create_shost()
7718 (phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT)) { in lpfc_create_shost()
7721 vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR; in lpfc_create_shost()
7722 if (phba->cfg_enable_SmartSAN) in lpfc_create_shost()
7723 vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR; in lpfc_create_shost()
7725 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR; in lpfc_create_shost()
7731 * lpfc_destroy_shost - Destroy hba physical port with associated scsi host.
7740 struct lpfc_vport *vport = phba->pport; in lpfc_destroy_shost()
7749 * lpfc_setup_bg - Setup Block guard structures and debug areas.
7762 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
7767 old_mask = phba->cfg_prot_mask; in lpfc_setup_bg()
7768 old_guard = phba->cfg_prot_guard; in lpfc_setup_bg()
7771 phba->cfg_prot_mask &= (SHOST_DIF_TYPE1_PROTECTION | in lpfc_setup_bg()
7774 phba->cfg_prot_guard &= (SHOST_DIX_GUARD_IP | in lpfc_setup_bg()
7778 if (phba->cfg_prot_mask == SHOST_DIX_TYPE1_PROTECTION) in lpfc_setup_bg()
7779 phba->cfg_prot_mask |= SHOST_DIF_TYPE1_PROTECTION; in lpfc_setup_bg()
7781 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
7782 if ((old_mask != phba->cfg_prot_mask) || in lpfc_setup_bg()
7783 (old_guard != phba->cfg_prot_guard)) in lpfc_setup_bg()
7787 phba->cfg_prot_mask, in lpfc_setup_bg()
7788 phba->cfg_prot_guard); in lpfc_setup_bg()
7790 scsi_host_set_prot(shost, phba->cfg_prot_mask); in lpfc_setup_bg()
7791 scsi_host_set_guard(shost, phba->cfg_prot_guard); in lpfc_setup_bg()
7801 * lpfc_post_init_setup - Perform necessary device post initialization setup.
7814 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_post_init_setup()
7820 shost = pci_get_drvdata(phba->pcidev); in lpfc_post_init_setup()
7821 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_post_init_setup()
7825 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_post_init_setup()
7826 spin_lock_irq(shost->host_lock); in lpfc_post_init_setup()
7828 spin_unlock_irq(shost->host_lock); in lpfc_post_init_setup()
7844 * lpfc_sli_pci_mem_setup - Setup SLI3 HBA PCI memory space.
7848 * with SLI-3 interface spec.
7851 * 0 - successful
7852 * other values - error
7857 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_pci_mem_setup()
7864 return -ENODEV; in lpfc_sli_pci_mem_setup()
7867 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli_pci_mem_setup()
7869 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli_pci_mem_setup()
7872 error = -ENODEV; in lpfc_sli_pci_mem_setup()
7877 phba->pci_bar0_map = pci_resource_start(pdev, 0); in lpfc_sli_pci_mem_setup()
7880 phba->pci_bar2_map = pci_resource_start(pdev, 2); in lpfc_sli_pci_mem_setup()
7884 phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli_pci_mem_setup()
7885 if (!phba->slim_memmap_p) { in lpfc_sli_pci_mem_setup()
7886 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
7892 phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli_pci_mem_setup()
7893 if (!phba->ctrl_regs_memmap_p) { in lpfc_sli_pci_mem_setup()
7894 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
7899 /* Allocate memory for SLI-2 structures */ in lpfc_sli_pci_mem_setup()
7900 phba->slim2p.virt = dma_alloc_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
7901 &phba->slim2p.phys, GFP_KERNEL); in lpfc_sli_pci_mem_setup()
7902 if (!phba->slim2p.virt) in lpfc_sli_pci_mem_setup()
7905 phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx); in lpfc_sli_pci_mem_setup()
7906 phba->mbox_ext = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
7908 phba->pcb = (phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, pcb)); in lpfc_sli_pci_mem_setup()
7909 phba->IOCBs = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
7912 phba->hbqslimp.virt = dma_alloc_coherent(&pdev->dev, in lpfc_sli_pci_mem_setup()
7914 &phba->hbqslimp.phys, in lpfc_sli_pci_mem_setup()
7916 if (!phba->hbqslimp.virt) in lpfc_sli_pci_mem_setup()
7920 ptr = phba->hbqslimp.virt; in lpfc_sli_pci_mem_setup()
7922 phba->hbqs[i].hbq_virt = ptr; in lpfc_sli_pci_mem_setup()
7923 INIT_LIST_HEAD(&phba->hbqs[i].hbq_buffer_list); in lpfc_sli_pci_mem_setup()
7924 ptr += (lpfc_hbq_defs[i]->entry_count * in lpfc_sli_pci_mem_setup()
7927 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_els_hbq_alloc; in lpfc_sli_pci_mem_setup()
7928 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_els_hbq_free; in lpfc_sli_pci_mem_setup()
7930 memset(phba->hbqslimp.virt, 0, lpfc_sli_hbq_size()); in lpfc_sli_pci_mem_setup()
7932 phba->MBslimaddr = phba->slim_memmap_p; in lpfc_sli_pci_mem_setup()
7933 phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
7934 phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
7935 phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; in lpfc_sli_pci_mem_setup()
7936 phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; in lpfc_sli_pci_mem_setup()
7941 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
7942 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_setup()
7944 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_setup()
7946 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_setup()
7952 * lpfc_sli_pci_mem_unset - Unset SLI3 HBA PCI memory space.
7956 * with SLI-3 interface spec.
7964 if (!phba->pcidev) in lpfc_sli_pci_mem_unset()
7967 pdev = phba->pcidev; in lpfc_sli_pci_mem_unset()
7970 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_sli_pci_mem_unset()
7971 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_sli_pci_mem_unset()
7972 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_unset()
7973 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_unset()
7976 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_unset()
7977 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_unset()
7983 * lpfc_sli4_post_status_check - Wait for SLI4 POST done and check status
7989 * Return 0 if successful, otherwise -ENODEV.
8001 if (!phba->sli4_hba.PSMPHRregaddr) in lpfc_sli4_post_status_check()
8002 return -ENODEV; in lpfc_sli4_post_status_check()
8006 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_sli4_post_status_check()
8010 port_error = -ENODEV; in lpfc_sli4_post_status_check()
8025 "1408 Port Failed POST - portsmphr=0x%x, " in lpfc_sli4_post_status_check()
8043 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
8045 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
8047 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
8049 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
8051 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
8053 &phba->sli4_hba.sli_intf)); in lpfc_sli4_post_status_check()
8060 &phba->sli4_hba.sli_intf); in lpfc_sli4_post_status_check()
8063 phba->sli4_hba.ue_mask_lo = in lpfc_sli4_post_status_check()
8064 readl(phba->sli4_hba.u.if_type0.UEMASKLOregaddr); in lpfc_sli4_post_status_check()
8065 phba->sli4_hba.ue_mask_hi = in lpfc_sli4_post_status_check()
8066 readl(phba->sli4_hba.u.if_type0.UEMASKHIregaddr); in lpfc_sli4_post_status_check()
8068 readl(phba->sli4_hba.u.if_type0.UERRLOregaddr); in lpfc_sli4_post_status_check()
8070 readl(phba->sli4_hba.u.if_type0.UERRHIregaddr); in lpfc_sli4_post_status_check()
8071 if ((~phba->sli4_hba.ue_mask_lo & uerrlo_reg.word0) || in lpfc_sli4_post_status_check()
8072 (~phba->sli4_hba.ue_mask_hi & uerrhi_reg.word0)) { in lpfc_sli4_post_status_check()
8083 phba->sli4_hba.ue_mask_lo, in lpfc_sli4_post_status_check()
8084 phba->sli4_hba.ue_mask_hi); in lpfc_sli4_post_status_check()
8085 port_error = -ENODEV; in lpfc_sli4_post_status_check()
8091 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_post_status_check()
8095 phba->work_status[0] = in lpfc_sli4_post_status_check()
8096 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
8098 phba->work_status[1] = in lpfc_sli4_post_status_check()
8099 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
8108 phba->work_status[0], in lpfc_sli4_post_status_check()
8109 phba->work_status[1]); in lpfc_sli4_post_status_check()
8110 port_error = -ENODEV; in lpfc_sli4_post_status_check()
8122 * lpfc_sli4_bar0_register_memmap - Set up SLI4 BAR0 register memory map.
8134 phba->sli4_hba.u.if_type0.UERRLOregaddr = in lpfc_sli4_bar0_register_memmap()
8135 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_LO; in lpfc_sli4_bar0_register_memmap()
8136 phba->sli4_hba.u.if_type0.UERRHIregaddr = in lpfc_sli4_bar0_register_memmap()
8137 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_HI; in lpfc_sli4_bar0_register_memmap()
8138 phba->sli4_hba.u.if_type0.UEMASKLOregaddr = in lpfc_sli4_bar0_register_memmap()
8139 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_LO; in lpfc_sli4_bar0_register_memmap()
8140 phba->sli4_hba.u.if_type0.UEMASKHIregaddr = in lpfc_sli4_bar0_register_memmap()
8141 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_HI; in lpfc_sli4_bar0_register_memmap()
8142 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
8143 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
8146 phba->sli4_hba.u.if_type2.EQDregaddr = 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.ERR1regaddr = 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.ERR2regaddr = 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.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
8156 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8158 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
8159 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8161 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
8162 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
8163 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
8164 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8166 phba->sli4_hba.RQDBregaddr = in lpfc_sli4_bar0_register_memmap()
8167 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8169 phba->sli4_hba.WQDBregaddr = in lpfc_sli4_bar0_register_memmap()
8170 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8172 phba->sli4_hba.CQDBregaddr = in lpfc_sli4_bar0_register_memmap()
8173 phba->sli4_hba.conf_regs_memmap_p + LPFC_EQCQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
8174 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar0_register_memmap()
8175 phba->sli4_hba.MQDBregaddr = in lpfc_sli4_bar0_register_memmap()
8176 phba->sli4_hba.conf_regs_memmap_p + LPFC_MQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
8177 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
8178 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
8181 phba->sli4_hba.u.if_type2.EQDregaddr = 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.ERR1regaddr = 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.ERR2regaddr = 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.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
8191 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8193 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
8194 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8196 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
8197 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8199 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
8200 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
8204 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_bar0_register_memmap()
8205 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar0_register_memmap()
8212 * lpfc_sli4_bar1_register_memmap - Set up SLI4 BAR1 register memory map.
8223 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar1_register_memmap()
8224 phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8226 phba->sli4_hba.ISRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8228 phba->sli4_hba.IMRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8230 phba->sli4_hba.ISCRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8234 phba->sli4_hba.RQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8236 phba->sli4_hba.WQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8238 phba->sli4_hba.CQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8240 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8242 phba->sli4_hba.MQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8248 dev_err(&phba->pcidev->dev, in lpfc_sli4_bar1_register_memmap()
8249 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar1_register_memmap()
8256 * lpfc_sli4_bar2_register_memmap - Set up SLI4 BAR2 register memory map.
8263 * Return 0 if successful, otherwise -ENODEV.
8269 return -ENODEV; in lpfc_sli4_bar2_register_memmap()
8271 phba->sli4_hba.RQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8274 phba->sli4_hba.WQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8277 phba->sli4_hba.CQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8280 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar2_register_memmap()
8281 phba->sli4_hba.MQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8283 phba->sli4_hba.BMBXregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8289 * lpfc_create_bootstrap_mbox - Create the bootstrap mailbox
8293 * region consistent with the SLI-4 interface spec. This
8300 * 0 - successful
8301 * -ENOMEM - could not allocated memory.
8314 return -ENOMEM; in lpfc_create_bootstrap_mbox()
8320 bmbx_size = sizeof(struct lpfc_bmbx_create) + (LPFC_ALIGN_16_BYTE - 1); in lpfc_create_bootstrap_mbox()
8321 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, bmbx_size, in lpfc_create_bootstrap_mbox()
8322 &dmabuf->phys, GFP_KERNEL); in lpfc_create_bootstrap_mbox()
8323 if (!dmabuf->virt) { in lpfc_create_bootstrap_mbox()
8325 return -ENOMEM; in lpfc_create_bootstrap_mbox()
8331 * to be 16-byte aligned. Also align the virtual memory as each in lpfc_create_bootstrap_mbox()
8335 phba->sli4_hba.bmbx.dmabuf = dmabuf; in lpfc_create_bootstrap_mbox()
8336 phba->sli4_hba.bmbx.bmbx_size = bmbx_size; in lpfc_create_bootstrap_mbox()
8338 phba->sli4_hba.bmbx.avirt = PTR_ALIGN(dmabuf->virt, in lpfc_create_bootstrap_mbox()
8340 phba->sli4_hba.bmbx.aphys = ALIGN(dmabuf->phys, in lpfc_create_bootstrap_mbox()
8346 * as two 30-bit addresses. The other data is a bit marking whether in lpfc_create_bootstrap_mbox()
8347 * the 30-bit address is the high or low address. in lpfc_create_bootstrap_mbox()
8351 dma_address = &phba->sli4_hba.bmbx.dma_address; in lpfc_create_bootstrap_mbox()
8352 phys_addr = (uint64_t)phba->sli4_hba.bmbx.aphys; in lpfc_create_bootstrap_mbox()
8354 dma_address->addr_hi = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
8357 pa_addr = (uint32_t) ((phba->sli4_hba.bmbx.aphys >> 4) & 0x3fffffff); in lpfc_create_bootstrap_mbox()
8358 dma_address->addr_lo = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
8364 * lpfc_destroy_bootstrap_mbox - Destroy all bootstrap mailbox resources
8377 dma_free_coherent(&phba->pcidev->dev, in lpfc_destroy_bootstrap_mbox()
8378 phba->sli4_hba.bmbx.bmbx_size, in lpfc_destroy_bootstrap_mbox()
8379 phba->sli4_hba.bmbx.dmabuf->virt, in lpfc_destroy_bootstrap_mbox()
8380 phba->sli4_hba.bmbx.dmabuf->phys); in lpfc_destroy_bootstrap_mbox()
8382 kfree(phba->sli4_hba.bmbx.dmabuf); in lpfc_destroy_bootstrap_mbox()
8383 memset(&phba->sli4_hba.bmbx, 0, sizeof(struct lpfc_bmbx)); in lpfc_destroy_bootstrap_mbox()
8400 * lpfc_map_topology - Map the topology read from READ_CONFIG
8425 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
8428 /* FW supports persistent topology - override module parameter value */ in lpfc_map_topology()
8429 phba->hba_flag |= HBA_PERSISTENT_TOPO; in lpfc_map_topology()
8430 switch (phba->pcidev->device) { in lpfc_map_topology()
8434 phba->cfg_topology = ((pt == LINK_FLAGS_LOOP) in lpfc_map_topology()
8438 phba->hba_flag &= ~HBA_PERSISTENT_TOPO; in lpfc_map_topology()
8443 /* If topology failover set - pt is '0' or '1' */ in lpfc_map_topology()
8444 phba->cfg_topology = (pt ? FLAGS_TOPOLOGY_MODE_PT_LOOP : in lpfc_map_topology()
8447 phba->cfg_topology = ((pt == LINK_FLAGS_P2P) in lpfc_map_topology()
8453 if (phba->hba_flag & HBA_PERSISTENT_TOPO) { in lpfc_map_topology()
8456 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
8461 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
8466 * lpfc_sli4_read_config - Get the config parameters.
8475 * 0 - successful
8476 * -ENOMEM - No available memory
8477 * -EIO - The mailbox failed to complete successfully.
8493 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_read_config()
8498 return -ENOMEM; in lpfc_sli4_read_config()
8508 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
8509 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
8510 rc = -EIO; in lpfc_sli4_read_config()
8512 rd_config = &pmb->u.mqe.un.rd_config; in lpfc_sli4_read_config()
8514 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_VAL; in lpfc_sli4_read_config()
8515 phba->sli4_hba.lnk_info.lnk_tp = in lpfc_sli4_read_config()
8517 phba->sli4_hba.lnk_info.lnk_no = in lpfc_sli4_read_config()
8521 phba->sli4_hba.lnk_info.lnk_tp, in lpfc_sli4_read_config()
8522 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_read_config()
8526 bf_get(lpfc_mqe_command, &pmb->u.mqe)); in lpfc_sli4_read_config()
8528 phba->bbcredit_support = 1; in lpfc_sli4_read_config()
8529 phba->sli4_hba.bbscn_params.word0 = rd_config->word8; in lpfc_sli4_read_config()
8532 phba->sli4_hba.conf_trunk = in lpfc_sli4_read_config()
8534 phba->sli4_hba.extents_in_use = in lpfc_sli4_read_config()
8536 phba->sli4_hba.max_cfg_param.max_xri = in lpfc_sli4_read_config()
8540 phba->sli4_hba.max_cfg_param.max_xri > 512) in lpfc_sli4_read_config()
8541 phba->sli4_hba.max_cfg_param.max_xri = 512; in lpfc_sli4_read_config()
8542 phba->sli4_hba.max_cfg_param.xri_base = in lpfc_sli4_read_config()
8544 phba->sli4_hba.max_cfg_param.max_vpi = in lpfc_sli4_read_config()
8547 if (phba->sli4_hba.max_cfg_param.max_vpi > LPFC_MAX_VPORTS) in lpfc_sli4_read_config()
8548 phba->sli4_hba.max_cfg_param.max_vpi = LPFC_MAX_VPORTS; in lpfc_sli4_read_config()
8549 phba->sli4_hba.max_cfg_param.vpi_base = in lpfc_sli4_read_config()
8551 phba->sli4_hba.max_cfg_param.max_rpi = in lpfc_sli4_read_config()
8553 phba->sli4_hba.max_cfg_param.rpi_base = in lpfc_sli4_read_config()
8555 phba->sli4_hba.max_cfg_param.max_vfi = in lpfc_sli4_read_config()
8557 phba->sli4_hba.max_cfg_param.vfi_base = in lpfc_sli4_read_config()
8559 phba->sli4_hba.max_cfg_param.max_fcfi = in lpfc_sli4_read_config()
8561 phba->sli4_hba.max_cfg_param.max_eq = in lpfc_sli4_read_config()
8563 phba->sli4_hba.max_cfg_param.max_rq = in lpfc_sli4_read_config()
8565 phba->sli4_hba.max_cfg_param.max_wq = in lpfc_sli4_read_config()
8567 phba->sli4_hba.max_cfg_param.max_cq = in lpfc_sli4_read_config()
8569 phba->lmt = bf_get(lpfc_mbx_rd_conf_lmt, rd_config); in lpfc_sli4_read_config()
8570 phba->sli4_hba.next_xri = phba->sli4_hba.max_cfg_param.xri_base; in lpfc_sli4_read_config()
8571 phba->vpi_base = phba->sli4_hba.max_cfg_param.vpi_base; in lpfc_sli4_read_config()
8572 phba->vfi_base = phba->sli4_hba.max_cfg_param.vfi_base; in lpfc_sli4_read_config()
8573 phba->max_vpi = (phba->sli4_hba.max_cfg_param.max_vpi > 0) ? in lpfc_sli4_read_config()
8574 (phba->sli4_hba.max_cfg_param.max_vpi - 1) : 0; in lpfc_sli4_read_config()
8575 phba->max_vports = phba->max_vpi; in lpfc_sli4_read_config()
8584 phba->sli4_hba.extents_in_use, in lpfc_sli4_read_config()
8585 phba->sli4_hba.max_cfg_param.xri_base, in lpfc_sli4_read_config()
8586 phba->sli4_hba.max_cfg_param.max_xri, in lpfc_sli4_read_config()
8587 phba->sli4_hba.max_cfg_param.vpi_base, in lpfc_sli4_read_config()
8588 phba->sli4_hba.max_cfg_param.max_vpi, in lpfc_sli4_read_config()
8589 phba->sli4_hba.max_cfg_param.vfi_base, in lpfc_sli4_read_config()
8590 phba->sli4_hba.max_cfg_param.max_vfi, in lpfc_sli4_read_config()
8591 phba->sli4_hba.max_cfg_param.rpi_base, in lpfc_sli4_read_config()
8592 phba->sli4_hba.max_cfg_param.max_rpi, in lpfc_sli4_read_config()
8593 phba->sli4_hba.max_cfg_param.max_fcfi, in lpfc_sli4_read_config()
8594 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
8595 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
8596 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
8597 phba->sli4_hba.max_cfg_param.max_rq, in lpfc_sli4_read_config()
8598 phba->lmt); in lpfc_sli4_read_config()
8604 qmin = phba->sli4_hba.max_cfg_param.max_wq; in lpfc_sli4_read_config()
8605 if (phba->sli4_hba.max_cfg_param.max_cq < qmin) in lpfc_sli4_read_config()
8606 qmin = phba->sli4_hba.max_cfg_param.max_cq; in lpfc_sli4_read_config()
8607 if (phba->sli4_hba.max_cfg_param.max_eq < qmin) in lpfc_sli4_read_config()
8608 qmin = phba->sli4_hba.max_cfg_param.max_eq; in lpfc_sli4_read_config()
8615 qmin -= 4; in lpfc_sli4_read_config()
8618 if ((phba->cfg_irq_chann > qmin) || in lpfc_sli4_read_config()
8619 (phba->cfg_hdw_queue > qmin)) { in lpfc_sli4_read_config()
8621 "2005 Reducing Queues - " in lpfc_sli4_read_config()
8625 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
8626 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
8627 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
8628 qmin, phba->cfg_irq_chann, in lpfc_sli4_read_config()
8629 phba->cfg_hdw_queue); in lpfc_sli4_read_config()
8631 if (phba->cfg_irq_chann > qmin) in lpfc_sli4_read_config()
8632 phba->cfg_irq_chann = qmin; in lpfc_sli4_read_config()
8633 if (phba->cfg_hdw_queue > qmin) in lpfc_sli4_read_config()
8634 phba->cfg_hdw_queue = qmin; in lpfc_sli4_read_config()
8642 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_read_config()
8647 phba->hba_flag |= HBA_FORCED_LINK_SPEED; in lpfc_sli4_read_config()
8651 phba->cfg_link_speed = in lpfc_sli4_read_config()
8655 phba->cfg_link_speed = in lpfc_sli4_read_config()
8659 phba->cfg_link_speed = in lpfc_sli4_read_config()
8663 phba->cfg_link_speed = in lpfc_sli4_read_config()
8667 phba->cfg_link_speed = in lpfc_sli4_read_config()
8671 phba->cfg_link_speed = in lpfc_sli4_read_config()
8675 phba->cfg_link_speed = in lpfc_sli4_read_config()
8679 phba->cfg_link_speed = in lpfc_sli4_read_config()
8683 phba->cfg_link_speed = in lpfc_sli4_read_config()
8692 phba->cfg_link_speed = in lpfc_sli4_read_config()
8699 length = phba->sli4_hba.max_cfg_param.max_xri - in lpfc_sli4_read_config()
8701 if (phba->cfg_hba_queue_depth > length) { in lpfc_sli4_read_config()
8704 phba->cfg_hba_queue_depth, length); in lpfc_sli4_read_config()
8705 phba->cfg_hba_queue_depth = length; in lpfc_sli4_read_config()
8708 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_read_config()
8713 length = (sizeof(struct lpfc_mbx_get_func_cfg) - in lpfc_sli4_read_config()
8721 &pmb->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_read_config()
8722 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_read_config()
8723 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_read_config()
8728 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
8729 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
8734 get_func_cfg = &pmb->u.mqe.un.get_func_cfg; in lpfc_sli4_read_config()
8736 pdesc_0 = (char *)&get_func_cfg->func_cfg.desc[0]; in lpfc_sli4_read_config()
8748 phba->sli4_hba.iov.pf_number = in lpfc_sli4_read_config()
8750 phba->sli4_hba.iov.vf_number = in lpfc_sli4_read_config()
8759 "vf_number:%d\n", phba->sli4_hba.iov.pf_number, in lpfc_sli4_read_config()
8760 phba->sli4_hba.iov.vf_number); in lpfc_sli4_read_config()
8768 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_read_config()
8773 * lpfc_setup_endian_order - Write endian order to an SLI4 if_type 0 port.
8776 * This routine is invoked to setup the port-side endian order when
8781 * 0 - successful
8782 * -ENOMEM - No available memory
8783 * -EIO - The mailbox failed to complete successfully.
8793 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_setup_endian_order()
8796 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_setup_endian_order()
8803 return -ENOMEM; in lpfc_setup_endian_order()
8811 memcpy(&mboxq->u.mqe, &endian_mb_data, sizeof(endian_mb_data)); in lpfc_setup_endian_order()
8818 rc = -EIO; in lpfc_setup_endian_order()
8820 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_setup_endian_order()
8832 * lpfc_sli4_queue_verify - Verify and update EQ counts
8841 * 0 - successful
8842 * -ENOMEM - No available memory
8848 * Sanity check for configured queue parameters against the run-time in lpfc_sli4_queue_verify()
8852 if (phba->nvmet_support) { in lpfc_sli4_queue_verify()
8853 if (phba->cfg_hdw_queue < phba->cfg_nvmet_mrq) in lpfc_sli4_queue_verify()
8854 phba->cfg_nvmet_mrq = phba->cfg_hdw_queue; in lpfc_sli4_queue_verify()
8855 if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX) in lpfc_sli4_queue_verify()
8856 phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX; in lpfc_sli4_queue_verify()
8861 phba->cfg_hdw_queue, phba->cfg_irq_chann, in lpfc_sli4_queue_verify()
8862 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_verify()
8865 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_verify()
8866 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_verify()
8869 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_verify()
8870 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_verify()
8879 int cpu; in lpfc_alloc_io_wq_cq() local
8881 cpu = lpfc_find_cpu_handle(phba, idx, LPFC_FIND_BY_HDWQ); in lpfc_alloc_io_wq_cq()
8883 if (phba->enab_exp_wqcq_pages) in lpfc_alloc_io_wq_cq()
8886 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
8887 LPFC_CQE_EXP_COUNT, cpu); in lpfc_alloc_io_wq_cq()
8891 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
8892 phba->sli4_hba.cq_ecount, cpu); in lpfc_alloc_io_wq_cq()
8895 "0499 Failed allocate fast-path IO CQ (%d)\n", in lpfc_alloc_io_wq_cq()
8899 qdesc->qe_valid = 1; in lpfc_alloc_io_wq_cq()
8900 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
8901 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
8902 phba->sli4_hba.hdwq[idx].io_cq = qdesc; in lpfc_alloc_io_wq_cq()
8905 if (phba->enab_exp_wqcq_pages) { in lpfc_alloc_io_wq_cq()
8907 wqesize = (phba->fcp_embed_io) ? in lpfc_alloc_io_wq_cq()
8908 LPFC_WQE128_SIZE : phba->sli4_hba.wq_esize; in lpfc_alloc_io_wq_cq()
8911 LPFC_WQE_EXP_COUNT, cpu); in lpfc_alloc_io_wq_cq()
8914 phba->sli4_hba.wq_esize, in lpfc_alloc_io_wq_cq()
8915 phba->sli4_hba.wq_ecount, cpu); in lpfc_alloc_io_wq_cq()
8919 "0503 Failed allocate fast-path IO WQ (%d)\n", in lpfc_alloc_io_wq_cq()
8923 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
8924 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
8925 phba->sli4_hba.hdwq[idx].io_wq = qdesc; in lpfc_alloc_io_wq_cq()
8926 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_alloc_io_wq_cq()
8931 * lpfc_sli4_queue_create - Create all the SLI4 queues
8940 * 0 - successful
8941 * -ENOMEM - No availble memory
8942 * -EIO - The mailbox failed to complete successfully.
8948 int idx, cpu, eqcpu; in lpfc_sli4_queue_create() local
8958 phba->sli4_hba.mq_esize = LPFC_MQE_SIZE; in lpfc_sli4_queue_create()
8959 phba->sli4_hba.mq_ecount = LPFC_MQE_DEF_COUNT; in lpfc_sli4_queue_create()
8960 phba->sli4_hba.wq_esize = LPFC_WQE_SIZE; in lpfc_sli4_queue_create()
8961 phba->sli4_hba.wq_ecount = LPFC_WQE_DEF_COUNT; in lpfc_sli4_queue_create()
8962 phba->sli4_hba.rq_esize = LPFC_RQE_SIZE; in lpfc_sli4_queue_create()
8963 phba->sli4_hba.rq_ecount = LPFC_RQE_DEF_COUNT; in lpfc_sli4_queue_create()
8964 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_create()
8965 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_create()
8966 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_create()
8967 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_create()
8969 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
8970 phba->sli4_hba.hdwq = kcalloc( in lpfc_sli4_queue_create()
8971 phba->cfg_hdw_queue, sizeof(struct lpfc_sli4_hdw_queue), in lpfc_sli4_queue_create()
8973 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
8976 "fast-path Hardware Queue array\n"); in lpfc_sli4_queue_create()
8980 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
8981 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_queue_create()
8982 spin_lock_init(&qp->io_buf_list_get_lock); in lpfc_sli4_queue_create()
8983 spin_lock_init(&qp->io_buf_list_put_lock); in lpfc_sli4_queue_create()
8984 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_sli4_queue_create()
8985 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_sli4_queue_create()
8986 qp->get_io_bufs = 0; in lpfc_sli4_queue_create()
8987 qp->put_io_bufs = 0; in lpfc_sli4_queue_create()
8988 qp->total_io_bufs = 0; in lpfc_sli4_queue_create()
8989 spin_lock_init(&qp->abts_io_buf_list_lock); in lpfc_sli4_queue_create()
8990 INIT_LIST_HEAD(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_queue_create()
8991 qp->abts_scsi_io_bufs = 0; in lpfc_sli4_queue_create()
8992 qp->abts_nvme_io_bufs = 0; in lpfc_sli4_queue_create()
8993 INIT_LIST_HEAD(&qp->sgl_list); in lpfc_sli4_queue_create()
8994 INIT_LIST_HEAD(&qp->cmd_rsp_buf_list); in lpfc_sli4_queue_create()
8995 spin_lock_init(&qp->hdwq_lock); in lpfc_sli4_queue_create()
8999 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
9000 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
9001 phba->sli4_hba.nvmet_cqset = kcalloc( in lpfc_sli4_queue_create()
9002 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
9005 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_create()
9008 "fast-path CQ set array\n"); in lpfc_sli4_queue_create()
9011 phba->sli4_hba.nvmet_mrq_hdr = kcalloc( in lpfc_sli4_queue_create()
9012 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
9015 if (!phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_create()
9018 "fast-path RQ set hdr array\n"); in lpfc_sli4_queue_create()
9021 phba->sli4_hba.nvmet_mrq_data = kcalloc( in lpfc_sli4_queue_create()
9022 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
9025 if (!phba->sli4_hba.nvmet_mrq_data) { in lpfc_sli4_queue_create()
9028 "fast-path RQ set data array\n"); in lpfc_sli4_queue_create()
9034 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
9037 for_each_present_cpu(cpu) { in lpfc_sli4_queue_create()
9042 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
9043 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_create()
9046 /* Get a ptr to the Hardware Queue associated with this CPU */ in lpfc_sli4_queue_create()
9047 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
9051 phba->sli4_hba.eq_esize, in lpfc_sli4_queue_create()
9052 phba->sli4_hba.eq_ecount, cpu); in lpfc_sli4_queue_create()
9056 cpup->hdwq); in lpfc_sli4_queue_create()
9059 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
9060 qdesc->hdwq = cpup->hdwq; in lpfc_sli4_queue_create()
9061 qdesc->chann = cpu; /* First CPU this EQ is affinitized to */ in lpfc_sli4_queue_create()
9062 qdesc->last_cpu = qdesc->chann; in lpfc_sli4_queue_create()
9065 qp->hba_eq = qdesc; in lpfc_sli4_queue_create()
9067 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, qdesc->last_cpu); in lpfc_sli4_queue_create()
9068 list_add(&qdesc->cpu_list, &eqi->list); in lpfc_sli4_queue_create()
9074 for_each_present_cpu(cpu) { in lpfc_sli4_queue_create()
9075 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
9078 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_sli4_queue_create()
9082 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
9083 if (qp->hba_eq) in lpfc_sli4_queue_create()
9087 eqcpu = lpfc_find_cpu_handle(phba, cpup->eq, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
9088 eqcpup = &phba->sli4_hba.cpu_map[eqcpu]; in lpfc_sli4_queue_create()
9089 qp->hba_eq = phba->sli4_hba.hdwq[eqcpup->hdwq].hba_eq; in lpfc_sli4_queue_create()
9093 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
9098 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
9099 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
9100 cpu = lpfc_find_cpu_handle(phba, idx, in lpfc_sli4_queue_create()
9104 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
9105 phba->sli4_hba.cq_ecount, in lpfc_sli4_queue_create()
9106 cpu); in lpfc_sli4_queue_create()
9113 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
9114 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
9115 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9116 phba->sli4_hba.nvmet_cqset[idx] = qdesc; in lpfc_sli4_queue_create()
9124 cpu = lpfc_find_cpu_handle(phba, 0, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
9125 /* Create slow-path Mailbox Command Complete Queue */ in lpfc_sli4_queue_create()
9127 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
9128 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
9131 "0500 Failed allocate slow-path mailbox CQ\n"); in lpfc_sli4_queue_create()
9134 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
9135 phba->sli4_hba.mbx_cq = qdesc; in lpfc_sli4_queue_create()
9137 /* Create slow-path ELS Complete Queue */ in lpfc_sli4_queue_create()
9139 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
9140 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
9143 "0501 Failed allocate slow-path ELS CQ\n"); in lpfc_sli4_queue_create()
9146 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
9147 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9148 phba->sli4_hba.els_cq = qdesc; in lpfc_sli4_queue_create()
9158 phba->sli4_hba.mq_esize, in lpfc_sli4_queue_create()
9159 phba->sli4_hba.mq_ecount, cpu); in lpfc_sli4_queue_create()
9162 "0505 Failed allocate slow-path MQ\n"); in lpfc_sli4_queue_create()
9165 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9166 phba->sli4_hba.mbx_wq = qdesc; in lpfc_sli4_queue_create()
9172 /* Create slow-path ELS Work Queue */ in lpfc_sli4_queue_create()
9174 phba->sli4_hba.wq_esize, in lpfc_sli4_queue_create()
9175 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
9178 "0504 Failed allocate slow-path ELS WQ\n"); in lpfc_sli4_queue_create()
9181 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9182 phba->sli4_hba.els_wq = qdesc; in lpfc_sli4_queue_create()
9183 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
9185 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
9188 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
9189 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
9195 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9196 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
9197 phba->sli4_hba.nvmels_cq = qdesc; in lpfc_sli4_queue_create()
9201 phba->sli4_hba.wq_esize, in lpfc_sli4_queue_create()
9202 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
9208 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9209 phba->sli4_hba.nvmels_wq = qdesc; in lpfc_sli4_queue_create()
9210 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
9219 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
9220 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
9226 phba->sli4_hba.hdr_rq = qdesc; in lpfc_sli4_queue_create()
9230 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
9231 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
9237 phba->sli4_hba.dat_rq = qdesc; in lpfc_sli4_queue_create()
9239 if ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) && in lpfc_sli4_queue_create()
9240 phba->nvmet_support) { in lpfc_sli4_queue_create()
9241 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
9242 cpu = lpfc_find_cpu_handle(phba, idx, in lpfc_sli4_queue_create()
9247 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
9249 cpu); in lpfc_sli4_queue_create()
9256 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
9257 phba->sli4_hba.nvmet_mrq_hdr[idx] = qdesc; in lpfc_sli4_queue_create()
9260 qdesc->rqbp = kzalloc_node(sizeof(*qdesc->rqbp), in lpfc_sli4_queue_create()
9262 cpu_to_node(cpu)); in lpfc_sli4_queue_create()
9263 if (qdesc->rqbp == NULL) { in lpfc_sli4_queue_create()
9271 INIT_LIST_HEAD(&qdesc->rqbp->rqb_buffer_list); in lpfc_sli4_queue_create()
9276 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
9278 cpu); in lpfc_sli4_queue_create()
9285 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
9286 phba->sli4_hba.nvmet_mrq_data[idx] = qdesc; in lpfc_sli4_queue_create()
9291 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
9292 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
9293 memset(&phba->sli4_hba.hdwq[idx].nvme_cstat, 0, in lpfc_sli4_queue_create()
9294 sizeof(phba->sli4_hba.hdwq[idx].nvme_cstat)); in lpfc_sli4_queue_create()
9299 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { in lpfc_sli4_queue_create()
9300 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
9301 memset(&phba->sli4_hba.hdwq[idx].scsi_cstat, 0, in lpfc_sli4_queue_create()
9302 sizeof(phba->sli4_hba.hdwq[idx].scsi_cstat)); in lpfc_sli4_queue_create()
9310 return -ENOMEM; in lpfc_sli4_queue_create()
9344 hdwq = phba->sli4_hba.hdwq; in lpfc_sli4_release_hdwq()
9347 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_release_hdwq()
9354 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_release_hdwq()
9359 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_release_hdwq()
9361 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_sli4_release_hdwq()
9363 phba->sli4_hba.hba_eq_hdl[idx].eq = NULL; in lpfc_sli4_release_hdwq()
9368 * lpfc_sli4_queue_destroy - Destroy all the SLI4 queues
9375 * 0 - successful
9376 * -ENOMEM - No available memory
9377 * -EIO - The mailbox failed to complete successfully.
9387 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9388 phba->sli.sli_flag |= LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
9389 while (phba->sli.sli_flag & LPFC_QUEUE_FREE_WAIT) { in lpfc_sli4_queue_destroy()
9390 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9392 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9394 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9399 if (phba->sli4_hba.hdwq) in lpfc_sli4_queue_destroy()
9402 if (phba->nvmet_support) { in lpfc_sli4_queue_destroy()
9403 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_destroy()
9404 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
9406 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_destroy()
9407 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
9408 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_destroy()
9409 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
9413 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_destroy()
9416 __lpfc_sli4_release_queue(&phba->sli4_hba.els_wq); in lpfc_sli4_queue_destroy()
9419 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_destroy()
9422 __lpfc_sli4_release_queue(&phba->sli4_hba.hdr_rq); in lpfc_sli4_queue_destroy()
9423 __lpfc_sli4_release_queue(&phba->sli4_hba.dat_rq); in lpfc_sli4_queue_destroy()
9426 __lpfc_sli4_release_queue(&phba->sli4_hba.els_cq); in lpfc_sli4_queue_destroy()
9429 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_destroy()
9432 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_destroy()
9435 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_destroy()
9438 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9439 phba->sli.sli_flag &= ~LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
9440 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9450 rqbp = rq->rqbp; in lpfc_free_rq_buffer()
9451 while (!list_empty(&rqbp->rqb_buffer_list)) { in lpfc_free_rq_buffer()
9452 list_remove_head(&rqbp->rqb_buffer_list, h_buf, in lpfc_free_rq_buffer()
9456 (rqbp->rqb_free_buffer)(phba, rqb_buffer); in lpfc_free_rq_buffer()
9457 rqbp->buffer_count--; in lpfc_free_rq_buffer()
9472 "6085 Fast-path %s (%d) not allocated\n", in lpfc_create_wq_cq()
9474 return -ENOMEM; in lpfc_create_wq_cq()
9490 *cq_map = cq->queue_id; in lpfc_create_wq_cq()
9493 "6087 CQ setup: cq[%d]-id=%d, parent eq[%d]-id=%d\n", in lpfc_create_wq_cq()
9494 qidx, cq->queue_id, qidx, eq->queue_id); in lpfc_create_wq_cq()
9502 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
9507 pring = wq->pring; in lpfc_create_wq_cq()
9508 pring->sli.sli4.wqp = (void *)wq; in lpfc_create_wq_cq()
9509 cq->pring = pring; in lpfc_create_wq_cq()
9512 "2593 WQ setup: wq[%d]-id=%d assoc=%d, cq[%d]-id=%d\n", in lpfc_create_wq_cq()
9513 qidx, wq->queue_id, wq->assoc_qid, qidx, cq->queue_id); in lpfc_create_wq_cq()
9518 "0539 Failed setup of slow-path MQ: " in lpfc_create_wq_cq()
9520 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
9525 "2589 MBX MQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_create_wq_cq()
9526 phba->sli4_hba.mbx_wq->queue_id, in lpfc_create_wq_cq()
9527 phba->sli4_hba.mbx_cq->queue_id); in lpfc_create_wq_cq()
9534 * lpfc_setup_cq_lookup - Setup the CQ lookup table
9546 memset(phba->sli4_hba.cq_lookup, 0, in lpfc_setup_cq_lookup()
9547 (sizeof(struct lpfc_queue *) * (phba->sli4_hba.cq_max + 1))); in lpfc_setup_cq_lookup()
9549 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_setup_cq_lookup()
9551 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_setup_cq_lookup()
9555 list_for_each_entry(childq, &eq->child_list, list) { in lpfc_setup_cq_lookup()
9556 if (childq->queue_id > phba->sli4_hba.cq_max) in lpfc_setup_cq_lookup()
9558 if (childq->subtype == LPFC_IO) in lpfc_setup_cq_lookup()
9559 phba->sli4_hba.cq_lookup[childq->queue_id] = in lpfc_setup_cq_lookup()
9566 * lpfc_sli4_queue_setup - Set up all the SLI4 queues
9573 * 0 - successful
9574 * -ENOMEM - No available memory
9575 * -EIO - The mailbox failed to complete successfully.
9585 int qidx, cpu; in lpfc_sli4_queue_setup() local
9587 int rc = -ENOMEM; in lpfc_sli4_queue_setup()
9589 /* Check for dual-ULP support */ in lpfc_sli4_queue_setup()
9590 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_queue_setup()
9595 return -ENOMEM; in lpfc_sli4_queue_setup()
9597 length = (sizeof(struct lpfc_mbx_query_fw_config) - in lpfc_sli4_queue_setup()
9606 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_queue_setup()
9607 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_queue_setup()
9608 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_queue_setup()
9614 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
9615 rc = -ENXIO; in lpfc_sli4_queue_setup()
9619 phba->sli4_hba.fw_func_mode = in lpfc_sli4_queue_setup()
9620 mboxq->u.mqe.un.query_fw_cfg.rsp.function_mode; in lpfc_sli4_queue_setup()
9621 phba->sli4_hba.ulp0_mode = mboxq->u.mqe.un.query_fw_cfg.rsp.ulp0_mode; in lpfc_sli4_queue_setup()
9622 phba->sli4_hba.ulp1_mode = mboxq->u.mqe.un.query_fw_cfg.rsp.ulp1_mode; in lpfc_sli4_queue_setup()
9623 phba->sli4_hba.physical_port = in lpfc_sli4_queue_setup()
9624 mboxq->u.mqe.un.query_fw_cfg.rsp.physical_port; in lpfc_sli4_queue_setup()
9627 "ulp1_mode:x%x\n", phba->sli4_hba.fw_func_mode, in lpfc_sli4_queue_setup()
9628 phba->sli4_hba.ulp0_mode, phba->sli4_hba.ulp1_mode); in lpfc_sli4_queue_setup()
9630 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
9635 qp = phba->sli4_hba.hdwq; in lpfc_sli4_queue_setup()
9640 "3147 Fast-path EQs not allocated\n"); in lpfc_sli4_queue_setup()
9641 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9646 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_setup()
9648 for_each_present_cpu(cpu) { in lpfc_sli4_queue_setup()
9649 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
9651 /* Look for the CPU thats using that vector with in lpfc_sli4_queue_setup()
9654 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_setup()
9656 if (qidx != cpup->eq) in lpfc_sli4_queue_setup()
9660 rc = lpfc_eq_create(phba, qp[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
9661 phba->cfg_fcp_imax); in lpfc_sli4_queue_setup()
9664 "0523 Failed setup of fast-path" in lpfc_sli4_queue_setup()
9666 cpup->eq, (uint32_t)rc); in lpfc_sli4_queue_setup()
9671 phba->sli4_hba.hba_eq_hdl[cpup->eq].eq = in lpfc_sli4_queue_setup()
9672 qp[cpup->hdwq].hba_eq; in lpfc_sli4_queue_setup()
9675 "2584 HBA EQ setup: queue[%d]-id=%d\n", in lpfc_sli4_queue_setup()
9676 cpup->eq, in lpfc_sli4_queue_setup()
9677 qp[cpup->hdwq].hba_eq->queue_id); in lpfc_sli4_queue_setup()
9682 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_setup()
9683 cpu = lpfc_find_cpu_handle(phba, qidx, LPFC_FIND_BY_HDWQ); in lpfc_sli4_queue_setup()
9684 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
9688 phba->sli4_hba.hdwq[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
9691 &phba->sli4_hba.hdwq[qidx].io_cq_map, in lpfc_sli4_queue_setup()
9707 /* Set up slow-path MBOX CQ/MQ */ in lpfc_sli4_queue_setup()
9709 if (!phba->sli4_hba.mbx_cq || !phba->sli4_hba.mbx_wq) { in lpfc_sli4_queue_setup()
9712 phba->sli4_hba.mbx_cq ? in lpfc_sli4_queue_setup()
9714 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9719 phba->sli4_hba.mbx_cq, in lpfc_sli4_queue_setup()
9720 phba->sli4_hba.mbx_wq, in lpfc_sli4_queue_setup()
9728 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
9729 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_setup()
9731 "3165 Fast-path NVME CQ Set " in lpfc_sli4_queue_setup()
9733 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9736 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
9738 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
9750 rc = lpfc_cq_create(phba, phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
9759 phba->sli4_hba.nvmet_cqset[0]->chann = 0; in lpfc_sli4_queue_setup()
9762 "6090 NVMET CQ setup: cq-id=%d, " in lpfc_sli4_queue_setup()
9763 "parent eq-id=%d\n", in lpfc_sli4_queue_setup()
9764 phba->sli4_hba.nvmet_cqset[0]->queue_id, in lpfc_sli4_queue_setup()
9765 qp[0].hba_eq->queue_id); in lpfc_sli4_queue_setup()
9769 /* Set up slow-path ELS WQ/CQ */ in lpfc_sli4_queue_setup()
9770 if (!phba->sli4_hba.els_cq || !phba->sli4_hba.els_wq) { in lpfc_sli4_queue_setup()
9773 phba->sli4_hba.els_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
9774 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9778 phba->sli4_hba.els_cq, in lpfc_sli4_queue_setup()
9779 phba->sli4_hba.els_wq, in lpfc_sli4_queue_setup()
9788 "2590 ELS WQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_sli4_queue_setup()
9789 phba->sli4_hba.els_wq->queue_id, in lpfc_sli4_queue_setup()
9790 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
9792 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_setup()
9794 if (!phba->sli4_hba.nvmels_cq || !phba->sli4_hba.nvmels_wq) { in lpfc_sli4_queue_setup()
9797 phba->sli4_hba.nvmels_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
9798 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9802 phba->sli4_hba.nvmels_cq, in lpfc_sli4_queue_setup()
9803 phba->sli4_hba.nvmels_wq, in lpfc_sli4_queue_setup()
9813 "6096 ELS WQ setup: wq-id=%d, " in lpfc_sli4_queue_setup()
9814 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
9815 phba->sli4_hba.nvmels_wq->queue_id, in lpfc_sli4_queue_setup()
9816 phba->sli4_hba.nvmels_cq->queue_id); in lpfc_sli4_queue_setup()
9822 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
9823 if ((!phba->sli4_hba.nvmet_cqset) || in lpfc_sli4_queue_setup()
9824 (!phba->sli4_hba.nvmet_mrq_hdr) || in lpfc_sli4_queue_setup()
9825 (!phba->sli4_hba.nvmet_mrq_data)) { in lpfc_sli4_queue_setup()
9829 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9832 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
9834 phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_setup()
9835 phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_setup()
9836 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
9848 phba->sli4_hba.nvmet_mrq_hdr[0], in lpfc_sli4_queue_setup()
9849 phba->sli4_hba.nvmet_mrq_data[0], in lpfc_sli4_queue_setup()
9850 phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
9862 "6099 NVMET RQ setup: hdr-rq-id=%d, " in lpfc_sli4_queue_setup()
9863 "dat-rq-id=%d parent cq-id=%d\n", in lpfc_sli4_queue_setup()
9864 phba->sli4_hba.nvmet_mrq_hdr[0]->queue_id, in lpfc_sli4_queue_setup()
9865 phba->sli4_hba.nvmet_mrq_data[0]->queue_id, in lpfc_sli4_queue_setup()
9866 phba->sli4_hba.nvmet_cqset[0]->queue_id); in lpfc_sli4_queue_setup()
9871 if (!phba->sli4_hba.hdr_rq || !phba->sli4_hba.dat_rq) { in lpfc_sli4_queue_setup()
9874 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9878 rc = lpfc_rq_create(phba, phba->sli4_hba.hdr_rq, phba->sli4_hba.dat_rq, in lpfc_sli4_queue_setup()
9879 phba->sli4_hba.els_cq, LPFC_USOL); in lpfc_sli4_queue_setup()
9888 "2592 USL RQ setup: hdr-rq-id=%d, dat-rq-id=%d " in lpfc_sli4_queue_setup()
9889 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
9890 phba->sli4_hba.hdr_rq->queue_id, in lpfc_sli4_queue_setup()
9891 phba->sli4_hba.dat_rq->queue_id, in lpfc_sli4_queue_setup()
9892 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
9894 if (phba->cfg_fcp_imax) in lpfc_sli4_queue_setup()
9895 usdelay = LPFC_SEC_TO_USEC / phba->cfg_fcp_imax; in lpfc_sli4_queue_setup()
9899 for (qidx = 0; qidx < phba->cfg_irq_chann; in lpfc_sli4_queue_setup()
9904 if (phba->sli4_hba.cq_max) { in lpfc_sli4_queue_setup()
9905 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_setup()
9906 phba->sli4_hba.cq_lookup = kcalloc((phba->sli4_hba.cq_max + 1), in lpfc_sli4_queue_setup()
9908 if (!phba->sli4_hba.cq_lookup) { in lpfc_sli4_queue_setup()
9911 "size 0x%x\n", phba->sli4_hba.cq_max); in lpfc_sli4_queue_setup()
9912 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9926 * lpfc_sli4_queue_unset - Unset all the SLI4 queues
9933 * 0 - successful
9934 * -ENOMEM - No available memory
9935 * -EIO - The mailbox failed to complete successfully.
9945 if (phba->sli4_hba.mbx_wq) in lpfc_sli4_queue_unset()
9946 lpfc_mq_destroy(phba, phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_unset()
9949 if (phba->sli4_hba.nvmels_wq) in lpfc_sli4_queue_unset()
9950 lpfc_wq_destroy(phba, phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_unset()
9953 if (phba->sli4_hba.els_wq) in lpfc_sli4_queue_unset()
9954 lpfc_wq_destroy(phba, phba->sli4_hba.els_wq); in lpfc_sli4_queue_unset()
9957 if (phba->sli4_hba.hdr_rq) in lpfc_sli4_queue_unset()
9958 lpfc_rq_destroy(phba, phba->sli4_hba.hdr_rq, in lpfc_sli4_queue_unset()
9959 phba->sli4_hba.dat_rq); in lpfc_sli4_queue_unset()
9962 if (phba->sli4_hba.mbx_cq) in lpfc_sli4_queue_unset()
9963 lpfc_cq_destroy(phba, phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_unset()
9966 if (phba->sli4_hba.els_cq) in lpfc_sli4_queue_unset()
9967 lpfc_cq_destroy(phba, phba->sli4_hba.els_cq); in lpfc_sli4_queue_unset()
9970 if (phba->sli4_hba.nvmels_cq) in lpfc_sli4_queue_unset()
9971 lpfc_cq_destroy(phba, phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_unset()
9973 if (phba->nvmet_support) { in lpfc_sli4_queue_unset()
9975 if (phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_unset()
9976 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
9979 phba->sli4_hba.nvmet_mrq_hdr[qidx], in lpfc_sli4_queue_unset()
9980 phba->sli4_hba.nvmet_mrq_data[qidx]); in lpfc_sli4_queue_unset()
9984 if (phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_unset()
9985 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
9987 phba, phba->sli4_hba.nvmet_cqset[qidx]); in lpfc_sli4_queue_unset()
9991 /* Unset fast-path SLI4 queues */ in lpfc_sli4_queue_unset()
9992 if (phba->sli4_hba.hdwq) { in lpfc_sli4_queue_unset()
9994 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_unset()
9996 qp = &phba->sli4_hba.hdwq[qidx]; in lpfc_sli4_queue_unset()
9997 lpfc_wq_destroy(phba, qp->io_wq); in lpfc_sli4_queue_unset()
9998 lpfc_cq_destroy(phba, qp->io_cq); in lpfc_sli4_queue_unset()
10001 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_unset()
10003 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_sli4_queue_unset()
10008 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_unset()
10009 phba->sli4_hba.cq_lookup = NULL; in lpfc_sli4_queue_unset()
10010 phba->sli4_hba.cq_max = 0; in lpfc_sli4_queue_unset()
10014 * lpfc_sli4_cq_event_pool_create - Create completion-queue event free pool
10021 * - Mailbox asynchronous events
10022 * - Receive queue completion unsolicited events
10023 * Later, this can be used for all the slow-path events.
10026 * 0 - successful
10027 * -ENOMEM - No available memory
10035 for (i = 0; i < (4 * phba->sli4_hba.cq_ecount); i++) { in lpfc_sli4_cq_event_pool_create()
10039 list_add_tail(&cq_event->list, in lpfc_sli4_cq_event_pool_create()
10040 &phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_cq_event_pool_create()
10046 return -ENOMEM; in lpfc_sli4_cq_event_pool_create()
10050 * lpfc_sli4_cq_event_pool_destroy - Free completion-queue event free pool
10055 * cleanup routine to free all the outstanding completion-queue events
10065 &phba->sli4_hba.sp_cqe_event_pool, list) { in lpfc_sli4_cq_event_pool_destroy()
10066 list_del(&cq_event->list); in lpfc_sli4_cq_event_pool_destroy()
10072 * __lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
10076 * completion-queue event from the free pool.
10078 * Return: Pointer to the newly allocated completion-queue event if successful
10086 list_remove_head(&phba->sli4_hba.sp_cqe_event_pool, cq_event, in __lpfc_sli4_cq_event_alloc()
10092 * lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
10096 * completion-queue event from the free pool.
10098 * Return: Pointer to the newly allocated completion-queue event if successful
10107 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
10109 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
10114 * __lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
10119 * completion-queue event back into the free pool.
10125 list_add_tail(&cq_event->list, &phba->sli4_hba.sp_cqe_event_pool); in __lpfc_sli4_cq_event_release()
10129 * lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
10134 * completion-queue event back into the free pool.
10141 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
10143 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
10147 * lpfc_sli4_cq_event_release_all - Release all cq events to the free pool
10150 * This routine is to free all the pending completion-queue events to the
10163 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
10164 list_splice_init(&phba->sli4_hba.sp_els_xri_aborted_work_queue, in lpfc_sli4_cq_event_release_all()
10166 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
10169 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
10170 list_splice_init(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_cq_event_release_all()
10172 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
10182 * lpfc_pci_function_reset - Reset pci function.
10189 * 0 - successful
10190 * -ENOMEM - No available memory
10191 * -EIO - The mailbox failed to complete successfully.
10205 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_pci_function_reset()
10208 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_pci_function_reset()
10215 return -ENOMEM; in lpfc_pci_function_reset()
10218 /* Setup PCI function reset mailbox-ioctl command */ in lpfc_pci_function_reset()
10224 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_pci_function_reset()
10225 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_pci_function_reset()
10227 &shdr->response); in lpfc_pci_function_reset()
10228 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_pci_function_reset()
10235 rc = -ENXIO; in lpfc_pci_function_reset()
10247 if (lpfc_readl(phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
10249 rc = -ENODEV; in lpfc_pci_function_reset()
10258 phba->work_status[0] = readl( in lpfc_pci_function_reset()
10259 phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_pci_function_reset()
10260 phba->work_status[1] = readl( in lpfc_pci_function_reset()
10261 phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_pci_function_reset()
10266 phba->work_status[0], in lpfc_pci_function_reset()
10267 phba->work_status[1]); in lpfc_pci_function_reset()
10268 rc = -ENODEV; in lpfc_pci_function_reset()
10281 writel(reg_data.word0, phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
10284 pci_read_config_word(phba->pcidev, in lpfc_pci_function_reset()
10291 rc = -ENODEV; in lpfc_pci_function_reset()
10302 /* Catch the not-ready port failure after a port reset. */ in lpfc_pci_function_reset()
10307 rc = -ENODEV; in lpfc_pci_function_reset()
10314 * lpfc_sli4_pci_mem_setup - Setup SLI4 HBA PCI memory space.
10318 * with SLI-4 interface spec.
10321 * 0 - successful
10322 * other values - error
10327 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_pci_mem_setup()
10333 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10336 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli4_pci_mem_setup()
10338 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli4_pci_mem_setup()
10347 &phba->sli4_hba.sli_intf.word0)) { in lpfc_sli4_pci_mem_setup()
10348 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10352 if (bf_get(lpfc_sli_intf_valid, &phba->sli4_hba.sli_intf) != in lpfc_sli4_pci_mem_setup()
10357 phba->sli4_hba.sli_intf.word0); in lpfc_sli4_pci_mem_setup()
10358 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10361 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_setup()
10369 phba->pci_bar0_map = pci_resource_start(pdev, PCI_64BIT_BAR0); in lpfc_sli4_pci_mem_setup()
10376 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10377 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
10378 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10379 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
10382 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10384 phba->pci_bar0_memmap_p = phba->sli4_hba.conf_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10388 phba->pci_bar0_map = pci_resource_start(pdev, 1); in lpfc_sli4_pci_mem_setup()
10391 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
10392 "FATAL - No BAR0 mapping for SLI4, if_type 2\n"); in lpfc_sli4_pci_mem_setup()
10393 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10395 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10396 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
10397 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10398 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
10401 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10412 phba->pci_bar1_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
10415 phba->sli4_hba.ctrl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10416 ioremap(phba->pci_bar1_map, in lpfc_sli4_pci_mem_setup()
10418 if (!phba->sli4_hba.ctrl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10419 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
10422 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10425 phba->pci_bar2_memmap_p = in lpfc_sli4_pci_mem_setup()
10426 phba->sli4_hba.ctrl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10429 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10440 phba->pci_bar1_map = pci_resource_start(pdev, PCI_64BIT_BAR2); in lpfc_sli4_pci_mem_setup()
10442 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10443 ioremap(phba->pci_bar1_map, bar1map_len); in lpfc_sli4_pci_mem_setup()
10444 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10445 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
10447 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10450 phba->pci_bar2_memmap_p = phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10460 phba->pci_bar2_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
10463 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10464 ioremap(phba->pci_bar2_map, in lpfc_sli4_pci_mem_setup()
10466 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10467 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
10470 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10473 phba->pci_bar4_memmap_p = in lpfc_sli4_pci_mem_setup()
10474 phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10479 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10490 phba->pci_bar2_map = pci_resource_start(pdev, PCI_64BIT_BAR4); in lpfc_sli4_pci_mem_setup()
10492 phba->sli4_hba.dpp_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10493 ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli4_pci_mem_setup()
10494 if (!phba->sli4_hba.dpp_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10495 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
10497 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10500 phba->pci_bar4_memmap_p = phba->sli4_hba.dpp_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10507 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
10508 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_write_eq_db; in lpfc_sli4_pci_mem_setup()
10509 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_write_cq_db; in lpfc_sli4_pci_mem_setup()
10512 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_if6_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
10513 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_if6_write_eq_db; in lpfc_sli4_pci_mem_setup()
10514 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_if6_write_cq_db; in lpfc_sli4_pci_mem_setup()
10523 if (phba->sli4_hba.drbl_regs_memmap_p) in lpfc_sli4_pci_mem_setup()
10524 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
10526 if (phba->sli4_hba.ctrl_regs_memmap_p) in lpfc_sli4_pci_mem_setup()
10527 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
10529 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
10535 * lpfc_sli4_pci_mem_unset - Unset SLI4 HBA PCI memory space.
10539 * with SLI-4 interface spec.
10545 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_unset()
10549 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10550 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10551 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10554 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10557 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10558 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10559 if (phba->sli4_hba.dpp_regs_memmap_p) in lpfc_sli4_pci_mem_unset()
10560 iounmap(phba->sli4_hba.dpp_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10564 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_pci_mem_unset()
10565 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_pci_mem_unset()
10572 * lpfc_sli_enable_msix - Enable MSI-X interrupt mode on SLI-3 device
10575 * This routine is invoked to enable the MSI-X interrupt vectors to device
10576 * with SLI-3 interface specs.
10579 * 0 - successful
10580 * other values - error
10588 /* Set up MSI-X multi-message vectors */ in lpfc_sli_enable_msix()
10589 rc = pci_alloc_irq_vectors(phba->pcidev, in lpfc_sli_enable_msix()
10593 "0420 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli_enable_msix()
10598 * Assign MSI-X vectors to interrupt handlers in lpfc_sli_enable_msix()
10601 /* vector-0 is associated to slow-path handler */ in lpfc_sli_enable_msix()
10602 rc = request_irq(pci_irq_vector(phba->pcidev, 0), in lpfc_sli_enable_msix()
10607 "0421 MSI-X slow-path request_irq failed " in lpfc_sli_enable_msix()
10612 /* vector-1 is associated to fast-path handler */ in lpfc_sli_enable_msix()
10613 rc = request_irq(pci_irq_vector(phba->pcidev, 1), in lpfc_sli_enable_msix()
10619 "0429 MSI-X fast-path request_irq failed " in lpfc_sli_enable_msix()
10625 * Configure HBA MSI-X attention conditions to messages in lpfc_sli_enable_msix()
10627 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_enable_msix()
10630 rc = -ENOMEM; in lpfc_sli_enable_msix()
10644 pmb->u.mb.mbxCommand, pmb->u.mb.mbxStatus); in lpfc_sli_enable_msix()
10649 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
10654 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
10658 free_irq(pci_irq_vector(phba->pcidev, 1), phba); in lpfc_sli_enable_msix()
10662 free_irq(pci_irq_vector(phba->pcidev, 0), phba); in lpfc_sli_enable_msix()
10665 /* Unconfigure MSI-X capability structure */ in lpfc_sli_enable_msix()
10666 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_enable_msix()
10673 * lpfc_sli_enable_msi - Enable MSI interrupt mode on SLI-3 device.
10677 * SLI-3 interface spec. The kernel function pci_enable_msi() is called to
10683 * 0 - successful
10684 * other values - error
10691 rc = pci_enable_msi(phba->pcidev); in lpfc_sli_enable_msi()
10701 rc = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_msi()
10704 pci_disable_msi(phba->pcidev); in lpfc_sli_enable_msi()
10712 * lpfc_sli_enable_intr - Enable device interrupt to SLI-3 device.
10714 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
10717 * interrupt handler(s) to interrupt vector(s) to device with SLI-3 interface
10722 * MSI-X -> MSI -> IRQ.
10725 * 0 - successful
10726 * other values - error
10738 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli_enable_intr()
10741 /* Indicate initialization to MSI-X mode */ in lpfc_sli_enable_intr()
10742 phba->intr_type = MSIX; in lpfc_sli_enable_intr()
10748 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli_enable_intr()
10749 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli_enable_intr()
10753 phba->intr_type = MSI; in lpfc_sli_enable_intr()
10758 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli_enable_intr()
10759 if (phba->intr_type == NONE) { in lpfc_sli_enable_intr()
10760 retval = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_intr()
10764 phba->intr_type = INTx; in lpfc_sli_enable_intr()
10772 * lpfc_sli_disable_intr - Disable device interrupt to SLI-3 device.
10777 * SLI-3 interface spec. Depending on the interrupt mode, the driver will
10785 if (phba->intr_type == MSIX) in lpfc_sli_disable_intr()
10791 free_irq(pci_irq_vector(phba->pcidev, i), phba); in lpfc_sli_disable_intr()
10792 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_disable_intr()
10795 phba->intr_type = NONE; in lpfc_sli_disable_intr()
10796 phba->sli.slistat.sli_intr = 0; in lpfc_sli_disable_intr()
10800 * lpfc_find_cpu_handle - Find the CPU that corresponds to the specified Queue
10805 * Return the CPU that matches the selection criteria
10811 int cpu; in lpfc_find_cpu_handle() local
10814 for_each_present_cpu(cpu) { in lpfc_find_cpu_handle()
10815 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_find_cpu_handle()
10822 (cpup->flag & LPFC_CPU_FIRST_IRQ) && in lpfc_find_cpu_handle()
10823 (cpup->eq == id)) in lpfc_find_cpu_handle()
10824 return cpu; in lpfc_find_cpu_handle()
10826 /* If matching by HDWQ, select the first CPU that matches */ in lpfc_find_cpu_handle()
10827 if ((match == LPFC_FIND_BY_HDWQ) && (cpup->hdwq == id)) in lpfc_find_cpu_handle()
10828 return cpu; in lpfc_find_cpu_handle()
10835 * lpfc_find_hyper - Determine if the CPU map entry is hyper-threaded
10837 * @cpu: CPU map index
10838 * @phys_id: CPU package physical id
10839 * @core_id: CPU core id
10842 lpfc_find_hyper(struct lpfc_hba *phba, int cpu, in lpfc_find_hyper() argument
10849 cpup = &phba->sli4_hba.cpu_map[idx]; in lpfc_find_hyper()
10851 if ((cpup->phys_id == phys_id) && in lpfc_find_hyper()
10852 (cpup->core_id == core_id) && in lpfc_find_hyper()
10853 (cpu != idx)) in lpfc_find_hyper()
10861 * lpfc_assign_eq_map_info - Assigns eq for vector_map structure
10865 * @cpu: cpu used to index vector_map structure
10871 unsigned int cpu) in lpfc_assign_eq_map_info() argument
10873 struct lpfc_vector_map_info *cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_assign_eq_map_info()
10876 cpup->eq = eqidx; in lpfc_assign_eq_map_info()
10877 cpup->flag |= flag; in lpfc_assign_eq_map_info()
10880 "3336 Set Affinity: CPU %d irq %d eq %d flag x%x\n", in lpfc_assign_eq_map_info()
10881 cpu, eqhdl->irq, cpup->eq, cpup->flag); in lpfc_assign_eq_map_info()
10885 * lpfc_cpu_map_array_init - Initialize cpu_map structure
10895 int cpu; in lpfc_cpu_map_array_init() local
10897 for_each_possible_cpu(cpu) { in lpfc_cpu_map_array_init()
10898 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_map_array_init()
10899 cpup->phys_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
10900 cpup->core_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
10901 cpup->hdwq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
10902 cpup->eq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
10903 cpup->flag = 0; in lpfc_cpu_map_array_init()
10904 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, cpu); in lpfc_cpu_map_array_init()
10905 INIT_LIST_HEAD(&eqi->list); in lpfc_cpu_map_array_init()
10906 eqi->icnt = 0; in lpfc_cpu_map_array_init()
10911 * lpfc_hba_eq_hdl_array_init - Initialize hba_eq_hdl structure
10922 for (i = 0; i < phba->cfg_irq_chann; i++) { in lpfc_hba_eq_hdl_array_init()
10924 eqhdl->irq = LPFC_VECTOR_MAP_EMPTY; in lpfc_hba_eq_hdl_array_init()
10925 eqhdl->phba = phba; in lpfc_hba_eq_hdl_array_init()
10930 * lpfc_cpu_affinity_check - Check vector CPU affinity mappings
10934 * The routine will figure out the CPU affinity assignment for every
10935 * MSI-X vector allocated for the HBA.
10936 * In addition, the CPU to IO channel mapping will be calculated
10937 * and the phba->sli4_hba.cpu_map array will reflect this.
10942 int i, cpu, idx, next_idx, new_cpu, start_cpu, first_cpu; in lpfc_cpu_affinity_check() local
10959 /* Update CPU map with physical id and core id of each CPU */ in lpfc_cpu_affinity_check()
10960 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
10961 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
10963 cpuinfo = &cpu_data(cpu); in lpfc_cpu_affinity_check()
10964 cpup->phys_id = cpuinfo->phys_proc_id; in lpfc_cpu_affinity_check()
10965 cpup->core_id = cpuinfo->cpu_core_id; in lpfc_cpu_affinity_check()
10966 if (lpfc_find_hyper(phba, cpu, cpup->phys_id, cpup->core_id)) in lpfc_cpu_affinity_check()
10967 cpup->flag |= LPFC_CPU_MAP_HYPER; in lpfc_cpu_affinity_check()
10970 cpup->phys_id = 0; in lpfc_cpu_affinity_check()
10971 cpup->core_id = cpu; in lpfc_cpu_affinity_check()
10975 "3328 CPU %d physid %d coreid %d flag x%x\n", in lpfc_cpu_affinity_check()
10976 cpu, cpup->phys_id, cpup->core_id, cpup->flag); in lpfc_cpu_affinity_check()
10978 if (cpup->phys_id > max_phys_id) in lpfc_cpu_affinity_check()
10979 max_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
10980 if (cpup->phys_id < min_phys_id) in lpfc_cpu_affinity_check()
10981 min_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
10983 if (cpup->core_id > max_core_id) in lpfc_cpu_affinity_check()
10984 max_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
10985 if (cpup->core_id < min_core_id) in lpfc_cpu_affinity_check()
10986 min_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
10991 * Next we will set any unassigned (unaffinitized) cpu map in lpfc_cpu_affinity_check()
10997 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
10998 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
11000 /* Is this CPU entry unassigned */ in lpfc_cpu_affinity_check()
11001 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
11002 /* Mark CPU as IRQ not assigned by the kernel */ in lpfc_cpu_affinity_check()
11003 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
11011 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
11012 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
11013 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
11014 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY) && in lpfc_cpu_affinity_check()
11015 (new_cpup->phys_id == cpup->phys_id)) in lpfc_cpu_affinity_check()
11022 /* At this point, we leave the CPU as unassigned */ in lpfc_cpu_affinity_check()
11026 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
11029 * chance of having multiple unassigned CPU entries in lpfc_cpu_affinity_check()
11037 "3337 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
11038 "eq %d from peer cpu %d same " in lpfc_cpu_affinity_check()
11040 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
11041 cpup->phys_id); in lpfc_cpu_affinity_check()
11045 /* Set any unassigned cpu map entries to a IRQ on any phys_id */ in lpfc_cpu_affinity_check()
11048 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
11049 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
11052 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
11054 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
11062 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
11063 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
11064 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
11065 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY)) in lpfc_cpu_affinity_check()
11074 "3339 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
11076 cpup->hdwq, cpup->eq); in lpfc_cpu_affinity_check()
11080 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
11083 * chance of having multiple unassigned CPU entries in lpfc_cpu_affinity_check()
11091 "3338 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
11092 "eq %d from peer cpu %d (%d/%d)\n", in lpfc_cpu_affinity_check()
11093 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
11094 new_cpup->phys_id, new_cpup->core_id); in lpfc_cpu_affinity_check()
11102 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
11103 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
11106 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_cpu_affinity_check()
11110 cpup->hdwq = idx; in lpfc_cpu_affinity_check()
11113 "3333 Set Affinity: CPU %d (phys %d core %d): " in lpfc_cpu_affinity_check()
11115 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
11116 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
11119 * This will be 1 to 1 - hdwq to cpu, unless there are less in lpfc_cpu_affinity_check()
11120 * hardware queues then CPUs. For that case we will just round-robin in lpfc_cpu_affinity_check()
11123 * for irq_chann < hdwq. The idx is used for round-robin assignments in lpfc_cpu_affinity_check()
11129 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
11130 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
11133 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_cpu_affinity_check()
11140 if (next_idx < phba->cfg_hdw_queue) { in lpfc_cpu_affinity_check()
11141 cpup->hdwq = next_idx; in lpfc_cpu_affinity_check()
11146 /* Not a First CPU and all hdw_queues are used. Reuse a in lpfc_cpu_affinity_check()
11147 * Hardware Queue for another CPU, so be smart about it in lpfc_cpu_affinity_check()
11149 * (CPU package) and core_id. in lpfc_cpu_affinity_check()
11152 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
11153 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
11154 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
11155 new_cpup->phys_id == cpup->phys_id && in lpfc_cpu_affinity_check()
11156 new_cpup->core_id == cpup->core_id) { in lpfc_cpu_affinity_check()
11168 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
11169 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
11170 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
11171 new_cpup->phys_id == cpup->phys_id) in lpfc_cpu_affinity_check()
11180 cpup->hdwq = idx % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
11188 cpup->hdwq = new_cpup->hdwq; in lpfc_cpu_affinity_check()
11191 "3335 Set Affinity: CPU %d (phys %d core %d): " in lpfc_cpu_affinity_check()
11193 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
11194 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
11198 * Initialize the cpu_map slots for not-present cpus in case in lpfc_cpu_affinity_check()
11199 * a cpu is hot-added. Perform a simple hdwq round robin assignment. in lpfc_cpu_affinity_check()
11202 for_each_possible_cpu(cpu) { in lpfc_cpu_affinity_check()
11203 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
11205 c_stat = per_cpu_ptr(phba->sli4_hba.c_stat, cpu); in lpfc_cpu_affinity_check()
11206 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
11208 if (cpup->hdwq != LPFC_VECTOR_MAP_EMPTY) in lpfc_cpu_affinity_check()
11211 cpup->hdwq = idx++ % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
11213 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
11217 "CPU %d hdwq %d\n", in lpfc_cpu_affinity_check()
11218 cpu, cpup->hdwq); in lpfc_cpu_affinity_check()
11231 * @cpu: cpu going offline
11235 lpfc_cpuhp_get_eq(struct lpfc_hba *phba, unsigned int cpu, in lpfc_cpuhp_get_eq() argument
11245 return -ENOMEM; in lpfc_cpuhp_get_eq()
11247 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_cpuhp_get_eq()
11248 maskp = pci_irq_get_affinity(phba->pcidev, idx); in lpfc_cpuhp_get_eq()
11252 * if irq is not affinitized to the cpu going in lpfc_cpuhp_get_eq()
11256 if (!cpumask_and(tmp, maskp, cpumask_of(cpu))) in lpfc_cpuhp_get_eq()
11258 /* get the cpus that are online and are affini- in lpfc_cpuhp_get_eq()
11260 * more than 1 then cpuhp is not going to shut- in lpfc_cpuhp_get_eq()
11261 * down this vector. Since this cpu has not in lpfc_cpuhp_get_eq()
11273 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_cpuhp_get_eq()
11274 list_add(&eq->_poll_list, eqlist); in lpfc_cpuhp_get_eq()
11282 if (phba->sli_rev != LPFC_SLI_REV4) in __lpfc_cpuhp_remove()
11286 &phba->cpuhp); in __lpfc_cpuhp_remove()
11292 del_timer_sync(&phba->cpuhp_poll_timer); in __lpfc_cpuhp_remove()
11297 if (phba->pport->fc_flag & FC_OFFLINE_MODE) in lpfc_cpuhp_remove()
11305 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_cpuhp_add()
11310 if (!list_empty(&phba->poll_list)) in lpfc_cpuhp_add()
11311 mod_timer(&phba->cpuhp_poll_timer, in lpfc_cpuhp_add()
11317 &phba->cpuhp); in lpfc_cpuhp_add()
11322 if (phba->pport->load_flag & FC_UNLOADING) { in __lpfc_cpuhp_checks()
11323 *retval = -EAGAIN; in __lpfc_cpuhp_checks()
11327 if (phba->sli_rev != LPFC_SLI_REV4) { in __lpfc_cpuhp_checks()
11337 * lpfc_irq_set_aff - set IRQ affinity
11339 * @cpu: cpu to set affinity
11343 lpfc_irq_set_aff(struct lpfc_hba_eq_hdl *eqhdl, unsigned int cpu) in lpfc_irq_set_aff() argument
11345 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_set_aff()
11346 cpumask_set_cpu(cpu, &eqhdl->aff_mask); in lpfc_irq_set_aff()
11347 irq_set_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_set_aff()
11348 irq_set_affinity_hint(eqhdl->irq, &eqhdl->aff_mask); in lpfc_irq_set_aff()
11352 * lpfc_irq_clear_aff - clear IRQ affinity
11359 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_clear_aff()
11360 irq_clear_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_clear_aff()
11364 * lpfc_irq_rebalance - rebalances IRQ affinity according to cpuhp event
11366 * @cpu: cpu going offline/online
11367 * @offline: true, cpu is going offline. false, cpu is coming online.
11369 * If cpu is going offline, we'll try our best effort to find the next
11370 * online cpu on the phba's original_mask and migrate all offlining IRQ
11373 * If cpu is coming online, reaffinitize the IRQ back to the onlining cpu.
11376 * PCI_IRQ_AFFINITY to auto-manage IRQ affinity.
11380 lpfc_irq_rebalance(struct lpfc_hba *phba, unsigned int cpu, bool offline) in lpfc_irq_rebalance() argument
11387 if (phba->irq_chann_mode == NORMAL_MODE) in lpfc_irq_rebalance()
11390 orig_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_irq_rebalance()
11392 if (!cpumask_test_cpu(cpu, orig_mask)) in lpfc_irq_rebalance()
11395 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_irq_rebalance()
11397 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_irq_rebalance()
11401 /* Find next online CPU on original mask */ in lpfc_irq_rebalance()
11402 cpu_next = cpumask_next_wrap(cpu, orig_mask, cpu, true); in lpfc_irq_rebalance()
11405 /* Found a valid CPU */ in lpfc_irq_rebalance()
11406 if ((cpu_select < nr_cpu_ids) && (cpu_select != cpu)) { in lpfc_irq_rebalance()
11408 * cpu aff_mask is migrated in lpfc_irq_rebalance()
11410 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_irq_rebalance()
11414 if (cpumask_test_cpu(cpu, aff_mask)) in lpfc_irq_rebalance()
11420 for (idx = 0; idx < phba->cfg_irq_chann; idx++) in lpfc_irq_rebalance()
11424 /* Migrate affinity back to this CPU */ in lpfc_irq_rebalance()
11425 lpfc_irq_set_aff(lpfc_get_eq_hdl(cpup->eq), cpu); in lpfc_irq_rebalance()
11429 static int lpfc_cpu_offline(unsigned int cpu, struct hlist_node *node) in lpfc_cpu_offline() argument
11437 WARN_ONCE(!phba, "cpu: %u. phba:NULL", raw_smp_processor_id()); in lpfc_cpu_offline()
11444 lpfc_irq_rebalance(phba, cpu, true); in lpfc_cpu_offline()
11446 retval = lpfc_cpuhp_get_eq(phba, cpu, &eqlist); in lpfc_cpu_offline()
11452 list_del_init(&eq->_poll_list); in lpfc_cpu_offline()
11459 static int lpfc_cpu_online(unsigned int cpu, struct hlist_node *node) in lpfc_cpu_online() argument
11467 WARN_ONCE(!phba, "cpu: %u. phba:NULL", raw_smp_processor_id()); in lpfc_cpu_online()
11474 lpfc_irq_rebalance(phba, cpu, false); in lpfc_cpu_online()
11476 list_for_each_entry_safe(eq, next, &phba->poll_list, _poll_list) { in lpfc_cpu_online()
11477 n = lpfc_find_cpu_handle(phba, eq->hdwq, LPFC_FIND_BY_HDWQ); in lpfc_cpu_online()
11478 if (n == cpu) in lpfc_cpu_online()
11486 * lpfc_sli4_enable_msix - Enable MSI-X interrupt mode to SLI-4 device
11489 * This routine is invoked to enable the MSI-X interrupt vectors to device
11490 * with SLI-4 interface spec. It also allocates MSI-X vectors and maps them
11496 * allocated and assigned to each online and offline cpu. If the cpu is
11497 * online, then affinity will be set to that cpu. If the cpu is offline, then
11498 * affinity will be set to the nearest peer cpu within the numa node that is
11500 * assigned and the OS may do as it pleases. Note: cpu vector affinity mapping
11501 * is consistent with the way cpu online/offline is handled when cfg_irq_numa is
11506 * cpu affinity. The driver will then use that affinity mapping to setup its
11507 * cpu mapping table.
11510 * 0 - successful
11511 * other values - error
11519 unsigned int cpu = 0, cpu_cnt = 0, cpu_select = nr_cpu_ids; in lpfc_sli4_enable_msix() local
11525 /* Set up MSI-X multi-message vectors */ in lpfc_sli4_enable_msix()
11526 vectors = phba->cfg_irq_chann; in lpfc_sli4_enable_msix()
11528 if (phba->irq_chann_mode != NORMAL_MODE) in lpfc_sli4_enable_msix()
11529 aff_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_sli4_enable_msix()
11533 vectors = min(phba->cfg_irq_chann, cpu_cnt); in lpfc_sli4_enable_msix()
11535 /* cpu: iterates over aff_mask including offline or online in lpfc_sli4_enable_msix()
11538 cpu = cpumask_first(aff_mask); in lpfc_sli4_enable_msix()
11539 cpu_select = lpfc_next_online_cpu(aff_mask, cpu); in lpfc_sli4_enable_msix()
11544 rc = pci_alloc_irq_vectors(phba->pcidev, 1, vectors, flags); in lpfc_sli4_enable_msix()
11547 "0484 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli4_enable_msix()
11552 /* Assign MSI-X vectors to interrupt handlers */ in lpfc_sli4_enable_msix()
11555 name = eqhdl->handler_name; in lpfc_sli4_enable_msix()
11560 eqhdl->idx = index; in lpfc_sli4_enable_msix()
11561 rc = request_irq(pci_irq_vector(phba->pcidev, index), in lpfc_sli4_enable_msix()
11566 "0486 MSI-X fast-path (%d) " in lpfc_sli4_enable_msix()
11571 eqhdl->irq = pci_irq_vector(phba->pcidev, index); in lpfc_sli4_enable_msix()
11574 /* If found a neighboring online cpu, set affinity */ in lpfc_sli4_enable_msix()
11581 cpu); in lpfc_sli4_enable_msix()
11583 /* Iterate to next offline or online cpu in aff_mask */ in lpfc_sli4_enable_msix()
11584 cpu = cpumask_next(cpu, aff_mask); in lpfc_sli4_enable_msix()
11586 /* Find next online cpu in aff_mask to set affinity */ in lpfc_sli4_enable_msix()
11587 cpu_select = lpfc_next_online_cpu(aff_mask, cpu); in lpfc_sli4_enable_msix()
11589 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_msix()
11591 cpu); in lpfc_sli4_enable_msix()
11593 maskp = pci_irq_get_affinity(phba->pcidev, index); in lpfc_sli4_enable_msix()
11596 for_each_cpu_and(cpu, maskp, cpu_present_mask) { in lpfc_sli4_enable_msix()
11597 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_enable_msix()
11599 /* If this is the first CPU thats assigned to in lpfc_sli4_enable_msix()
11603 * vectors are affinitized to all the cpu's. in lpfc_sli4_enable_msix()
11611 if (cpup->eq != LPFC_VECTOR_MAP_EMPTY) in lpfc_sli4_enable_msix()
11615 cpu); in lpfc_sli4_enable_msix()
11621 if (vectors != phba->cfg_irq_chann) { in lpfc_sli4_enable_msix()
11624 "MSI-X vectors, requested %d got %d\n", in lpfc_sli4_enable_msix()
11625 phba->cfg_irq_chann, vectors); in lpfc_sli4_enable_msix()
11626 if (phba->cfg_irq_chann > vectors) in lpfc_sli4_enable_msix()
11627 phba->cfg_irq_chann = vectors; in lpfc_sli4_enable_msix()
11634 for (--index; index >= 0; index--) { in lpfc_sli4_enable_msix()
11637 irq_set_affinity_hint(eqhdl->irq, NULL); in lpfc_sli4_enable_msix()
11638 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_enable_msix()
11641 /* Unconfigure MSI-X capability structure */ in lpfc_sli4_enable_msix()
11642 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msix()
11649 * lpfc_sli4_enable_msi - Enable MSI interrupt mode to SLI-4 device
11653 * SLI-4 interface spec. The kernel function pci_alloc_irq_vectors() is
11659 * 0 - successful
11660 * other values - error
11666 unsigned int cpu; in lpfc_sli4_enable_msi() local
11669 rc = pci_alloc_irq_vectors(phba->pcidev, 1, 1, in lpfc_sli4_enable_msi()
11677 return rc ? rc : -1; in lpfc_sli4_enable_msi()
11680 rc = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_msi()
11683 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msi()
11690 eqhdl->irq = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_msi()
11692 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_msi()
11693 lpfc_assign_eq_map_info(phba, 0, LPFC_CPU_FIRST_IRQ, cpu); in lpfc_sli4_enable_msi()
11695 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_enable_msi()
11697 eqhdl->idx = index; in lpfc_sli4_enable_msi()
11704 * lpfc_sli4_enable_intr - Enable device interrupt to SLI-4 device
11706 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
11709 * interrupt handler(s) to interrupt vector(s) to device with SLI-4
11714 * MSI-X -> MSI -> IRQ.
11717 * 0 - successful
11718 * other values - error
11730 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli4_enable_intr()
11733 /* Indicate initialization to MSI-X mode */ in lpfc_sli4_enable_intr()
11734 phba->intr_type = MSIX; in lpfc_sli4_enable_intr()
11740 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli4_enable_intr()
11741 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
11745 phba->intr_type = MSI; in lpfc_sli4_enable_intr()
11750 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli4_enable_intr()
11751 if (phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
11752 retval = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_intr()
11756 unsigned int cpu; in lpfc_sli4_enable_intr() local
11759 phba->intr_type = INTx; in lpfc_sli4_enable_intr()
11763 eqhdl->irq = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_intr()
11765 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_intr()
11767 cpu); in lpfc_sli4_enable_intr()
11768 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_enable_intr()
11770 eqhdl->idx = idx; in lpfc_sli4_enable_intr()
11778 * lpfc_sli4_disable_intr - Disable device interrupt to SLI-4 device
11783 * with SLI-4 interface spec. Depending on the interrupt mode, the driver
11790 if (phba->intr_type == MSIX) { in lpfc_sli4_disable_intr()
11794 /* Free up MSI-X multi-message vectors */ in lpfc_sli4_disable_intr()
11795 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_disable_intr()
11798 irq_set_affinity_hint(eqhdl->irq, NULL); in lpfc_sli4_disable_intr()
11799 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_disable_intr()
11802 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_disable_intr()
11805 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_disable_intr()
11808 phba->intr_type = NONE; in lpfc_sli4_disable_intr()
11809 phba->sli.slistat.sli_intr = 0; in lpfc_sli4_disable_intr()
11813 * lpfc_unset_hba - Unset SLI3 hba device initialization
11817 * a device with SLI-3 interface spec.
11822 struct lpfc_vport *vport = phba->pport; in lpfc_unset_hba()
11825 spin_lock_irq(shost->host_lock); in lpfc_unset_hba()
11826 vport->load_flag |= FC_UNLOADING; in lpfc_unset_hba()
11827 spin_unlock_irq(shost->host_lock); in lpfc_unset_hba()
11829 kfree(phba->vpi_bmask); in lpfc_unset_hba()
11830 kfree(phba->vpi_ids); in lpfc_unset_hba()
11834 phba->pport->work_port_events = 0; in lpfc_unset_hba()
11846 * lpfc_sli4_xri_exchange_busy_wait - Wait for device XRI exchange busy
11866 int els_xri_cmpl = list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
11875 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_xri_exchange_busy_wait()
11879 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
11880 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
11881 io_xri_cmpl = list_empty(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
11888 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
11890 list_empty(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
11918 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
11919 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
11921 &qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
11928 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
11930 &phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
11933 list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
11939 * lpfc_sli4_hba_unset - Unset the fcoe hba
11953 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_hba_unset()
11956 if (phba->pport) in lpfc_sli4_hba_unset()
11957 phba->sli4_hba.intr_enable = 0; in lpfc_sli4_hba_unset()
11965 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
11966 phba->sli.sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_hba_unset()
11967 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
11969 while (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
11975 if (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
11976 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
11977 mboxq = phba->sli.mbox_active; in lpfc_sli4_hba_unset()
11978 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_hba_unset()
11980 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_hba_unset()
11981 phba->sli.mbox_active = NULL; in lpfc_sli4_hba_unset()
11982 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
11991 /* per-phba callback de-registration for hotplug event */ in lpfc_sli4_hba_unset()
11992 if (phba->pport) in lpfc_sli4_hba_unset()
11998 /* Disable SR-IOV if enabled */ in lpfc_sli4_hba_unset()
11999 if (phba->cfg_sriov_nr_virtfn) in lpfc_sli4_hba_unset()
12003 kthread_stop(phba->worker_thread); in lpfc_sli4_hba_unset()
12018 if (phba->ras_fwlog.ras_enabled) in lpfc_sli4_hba_unset()
12022 if (phba->pport) in lpfc_sli4_hba_unset()
12023 phba->pport->work_port_events = 0; in lpfc_sli4_hba_unset()
12027 * lpfc_get_sli4_parameters - Get the SLI4 Config PARAMETERS.
12034 * This function may be be called from any context that can block-wait
12042 struct lpfc_mqe *mqe = &mboxq->u.mqe; in lpfc_get_sli4_parameters()
12054 phba->sli4_hba.rpi_hdrs_in_use = 1; in lpfc_get_sli4_parameters()
12057 length = (sizeof(struct lpfc_mbx_get_sli4_parameters) - in lpfc_get_sli4_parameters()
12062 if (!phba->sli4_hba.intr_enable) in lpfc_get_sli4_parameters()
12070 sli4_params = &phba->sli4_hba.pc_sli4_params; in lpfc_get_sli4_parameters()
12071 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters; in lpfc_get_sli4_parameters()
12072 sli4_params->if_type = bf_get(cfg_if_type, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12073 sli4_params->sli_rev = bf_get(cfg_sli_rev, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12074 sli4_params->sli_family = bf_get(cfg_sli_family, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12075 sli4_params->featurelevel_1 = bf_get(cfg_sli_hint_1, in lpfc_get_sli4_parameters()
12077 sli4_params->featurelevel_2 = bf_get(cfg_sli_hint_2, in lpfc_get_sli4_parameters()
12080 phba->sli3_options |= LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
12082 phba->sli3_options &= ~LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
12083 sli4_params->sge_supp_len = mbx_sli4_parameters->sge_supp_len; in lpfc_get_sli4_parameters()
12084 sli4_params->loopbk_scope = bf_get(cfg_loopbk_scope, in lpfc_get_sli4_parameters()
12086 sli4_params->oas_supported = bf_get(cfg_oas, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12087 sli4_params->cqv = bf_get(cfg_cqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12088 sli4_params->mqv = bf_get(cfg_mqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12089 sli4_params->wqv = bf_get(cfg_wqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12090 sli4_params->rqv = bf_get(cfg_rqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12091 sli4_params->eqav = bf_get(cfg_eqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12092 sli4_params->cqav = bf_get(cfg_cqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12093 sli4_params->wqsize = bf_get(cfg_wqsize, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12094 sli4_params->bv1s = bf_get(cfg_bv1s, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12095 sli4_params->pls = bf_get(cfg_pvl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12096 sli4_params->sgl_pages_max = bf_get(cfg_sgl_page_cnt, in lpfc_get_sli4_parameters()
12098 sli4_params->wqpcnt = bf_get(cfg_wqpcnt, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12099 sli4_params->sgl_pp_align = bf_get(cfg_sgl_pp_align, in lpfc_get_sli4_parameters()
12101 phba->sli4_hba.extents_in_use = bf_get(cfg_ext, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12102 phba->sli4_hba.rpi_hdrs_in_use = bf_get(cfg_hdrr, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12104 /* Check for Extended Pre-Registered SGL support */ in lpfc_get_sli4_parameters()
12105 phba->cfg_xpsgl = bf_get(cfg_xpsgl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12113 sli4_params->nvme = 1; in lpfc_get_sli4_parameters()
12116 if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP) { in lpfc_get_sli4_parameters()
12120 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
12125 sli4_params->nvme = 0; in lpfc_get_sli4_parameters()
12126 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_get_sli4_parameters()
12132 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
12134 phba->nvme_support = 0; in lpfc_get_sli4_parameters()
12135 phba->nvmet_support = 0; in lpfc_get_sli4_parameters()
12136 phba->cfg_nvmet_mrq = 0; in lpfc_get_sli4_parameters()
12137 phba->cfg_nvme_seg_cnt = 0; in lpfc_get_sli4_parameters()
12140 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_get_sli4_parameters()
12141 return -ENODEV; in lpfc_get_sli4_parameters()
12142 phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; in lpfc_get_sli4_parameters()
12149 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_get_sli4_parameters()
12150 phba->cfg_sg_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_get_sli4_parameters()
12153 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) != in lpfc_get_sli4_parameters()
12155 phba->cfg_enable_pbde = 0; in lpfc_get_sli4_parameters()
12160 * In SLI4-Parameters Descriptor: in lpfc_get_sli4_parameters()
12165 if (phba->cfg_suppress_rsp && bf_get(cfg_xib, mbx_sli4_parameters) && in lpfc_get_sli4_parameters()
12167 phba->sli.sli_flag |= LPFC_SLI_SUPPRESS_RSP; in lpfc_get_sli4_parameters()
12169 phba->cfg_suppress_rsp = 0; in lpfc_get_sli4_parameters()
12172 phba->sli.sli_flag |= LPFC_SLI_USE_EQDR; in lpfc_get_sli4_parameters()
12175 if (sli4_params->sge_supp_len > LPFC_MAX_SGE_SIZE) in lpfc_get_sli4_parameters()
12176 sli4_params->sge_supp_len = LPFC_MAX_SGE_SIZE; in lpfc_get_sli4_parameters()
12181 * to use this option, 128-byte WQEs must be used. in lpfc_get_sli4_parameters()
12184 phba->fcp_embed_io = 1; in lpfc_get_sli4_parameters()
12186 phba->fcp_embed_io = 0; in lpfc_get_sli4_parameters()
12191 phba->cfg_enable_pbde, in lpfc_get_sli4_parameters()
12192 phba->fcp_embed_io, phba->nvme_support, in lpfc_get_sli4_parameters()
12193 phba->cfg_nvme_embed_cmd, phba->cfg_suppress_rsp); in lpfc_get_sli4_parameters()
12195 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
12197 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
12204 (sli4_params->wqsize & LPFC_WQ_SZ128_SUPPORT)) in lpfc_get_sli4_parameters()
12205 phba->enab_exp_wqcq_pages = 1; in lpfc_get_sli4_parameters()
12207 phba->enab_exp_wqcq_pages = 0; in lpfc_get_sli4_parameters()
12212 phba->mds_diags_support = 1; in lpfc_get_sli4_parameters()
12214 phba->mds_diags_support = 0; in lpfc_get_sli4_parameters()
12220 phba->nsler = 1; in lpfc_get_sli4_parameters()
12222 phba->nsler = 0; in lpfc_get_sli4_parameters()
12228 * lpfc_pci_probe_one_s3 - PCI probe func to reg SLI-3 device to PCI subsystem.
12232 * This routine is to be called to attach a device with SLI-3 interface spec
12233 * to the PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
12234 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
12241 * 0 - driver can claim the device
12242 * negative value - driver can not claim the device
12256 return -ENOMEM; in lpfc_pci_probe_one_s3()
12263 /* Set up SLI API function jump table for PCI-device group-0 HBAs */ in lpfc_pci_probe_one_s3()
12268 /* Set up SLI-3 specific device PCI memory space */ in lpfc_pci_probe_one_s3()
12276 /* Set up SLI-3 specific device driver resources */ in lpfc_pci_probe_one_s3()
12302 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s3()
12313 vport = phba->pport; in lpfc_pci_probe_one_s3()
12323 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s3()
12332 error = -ENODEV; in lpfc_pci_probe_one_s3()
12335 /* SLI-3 HBA setup */ in lpfc_pci_probe_one_s3()
12339 error = -ENODEV; in lpfc_pci_probe_one_s3()
12347 phba->sli.slistat.sli_intr > LPFC_MSIX_VECTORS) { in lpfc_pci_probe_one_s3()
12349 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s3()
12360 cfg_mode = --intr_mode; in lpfc_pci_probe_one_s3()
12396 * lpfc_pci_remove_one_s3 - PCI func to unreg SLI-3 device from PCI subsystem.
12399 * This routine is to be called to disattach a device with SLI-3 interface
12400 * spec from PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
12408 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s3()
12410 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s3()
12413 spin_lock_irq(&phba->hbalock); in lpfc_pci_remove_one_s3()
12414 vport->load_flag |= FC_UNLOADING; in lpfc_pci_remove_one_s3()
12415 spin_unlock_irq(&phba->hbalock); in lpfc_pci_remove_one_s3()
12422 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s3()
12423 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s3()
12425 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s3()
12444 kthread_stop(phba->worker_thread); in lpfc_pci_remove_one_s3()
12448 kfree(phba->vpi_bmask); in lpfc_pci_remove_one_s3()
12449 kfree(phba->vpi_ids); in lpfc_pci_remove_one_s3()
12452 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
12453 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s3()
12454 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
12458 /* Disable SR-IOV if enabled */ in lpfc_pci_remove_one_s3()
12459 if (phba->cfg_sriov_nr_virtfn) in lpfc_pci_remove_one_s3()
12476 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_pci_remove_one_s3()
12477 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_pci_remove_one_s3()
12480 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_pci_remove_one_s3()
12481 phba->slim2p.virt, phba->slim2p.phys); in lpfc_pci_remove_one_s3()
12484 iounmap(phba->ctrl_regs_memmap_p); in lpfc_pci_remove_one_s3()
12485 iounmap(phba->slim_memmap_p); in lpfc_pci_remove_one_s3()
12494 * lpfc_pci_suspend_one_s3 - PCI func to suspend SLI-3 device for power mgmnt
12499 * system Power Management (PM) to device with SLI-3 interface spec. When
12503 * minimum PM requirements to a power-aware driver's PM support for the
12504 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
12511 * 0 - driver suspended the device
12518 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s3()
12526 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s3()
12539 * lpfc_pci_resume_one_s3 - PCI func to resume SLI-3 device for power mgmnt
12543 * system Power Management (PM) to device with SLI-3 interface spec. When PM
12546 * driver implements the minimum PM requirements to a power-aware driver's
12547 * PM for suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE,
12554 * 0 - driver suspended the device
12561 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s3()
12578 if (pdev->is_busmaster) in lpfc_pci_resume_one_s3()
12582 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s3()
12583 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s3()
12584 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s3()
12585 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s3()
12593 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
12597 return -EIO; in lpfc_pci_resume_one_s3()
12599 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s3()
12606 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
12612 * lpfc_sli_prep_dev_for_recover - Prepare SLI3 device for pci slot recover
12626 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli_prep_dev_for_recover()
12632 * lpfc_sli_prep_dev_for_reset - Prepare SLI3 device for pci slot reset
12659 pci_disable_device(phba->pcidev); in lpfc_sli_prep_dev_for_reset()
12663 * lpfc_sli_prep_dev_for_perm_failure - Prepare SLI3 dev for pci slot disable
12686 * lpfc_io_error_detected_s3 - Method for handling SLI-3 device PCI I/O error
12691 * device with SLI-3 interface spec. This function is called by the PCI
12699 * PCI_ERS_RESULT_CAN_RECOVER - can be recovered with reset_link
12700 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
12701 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
12707 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s3()
12711 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s3()
12732 * lpfc_io_slot_reset_s3 - Method for restarting PCI SLI-3 device from scratch.
12736 * device with SLI-3 interface spec. This is called after PCI bus has been
12737 * reset to restart the PCI card from scratch, as if from a cold-boot.
12746 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
12747 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
12753 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s3()
12754 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s3()
12757 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s3()
12759 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s3()
12772 if (pdev->is_busmaster) in lpfc_io_slot_reset_s3()
12775 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
12776 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s3()
12777 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
12780 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
12783 "0427 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s3()
12787 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s3()
12795 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
12801 * lpfc_io_resume_s3 - Method for resuming PCI I/O operation on SLI-3 device.
12805 * with SLI-3 interface spec. It is called when kernel error recovery tells
12814 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s3()
12816 /* Bring device online, it will be no-op for non-fatal error resume */ in lpfc_io_resume_s3()
12821 * lpfc_sli4_get_els_iocb_cnt - Calculate the # of ELS IOCBs to reserve
12829 int max_xri = phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_get_els_iocb_cnt()
12831 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli4_get_els_iocb_cnt()
12851 * lpfc_sli4_get_iocb_cnt - Calculate the # of total IOCBs to reserve
12861 if (phba->nvmet_support) in lpfc_sli4_get_iocb_cnt()
12881 (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G6_FC && in lpfc_log_write_firmware_error()
12883 (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G7_FC && in lpfc_log_write_firmware_error()
12889 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
12890 fsize, fw->size); in lpfc_log_write_firmware_error()
12891 rc = -EINVAL; in lpfc_log_write_firmware_error()
12898 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
12899 fsize, fw->size); in lpfc_log_write_firmware_error()
12900 rc = -EACCES; in lpfc_log_write_firmware_error()
12906 offset, phba->pcidev->device, magic_number, in lpfc_log_write_firmware_error()
12907 ftype, fid, fsize, fw->size); in lpfc_log_write_firmware_error()
12908 rc = -EIO; in lpfc_log_write_firmware_error()
12914 * lpfc_write_firmware - attempt to write a firmware image to the port
12931 /* It can be null in no-wait mode, sanity check */ in lpfc_write_firmware()
12933 rc = -ENXIO; in lpfc_write_firmware()
12936 image = (struct lpfc_grp_hdr *)fw->data; in lpfc_write_firmware()
12938 magic_number = be32_to_cpu(image->magic_number); in lpfc_write_firmware()
12941 fsize = be32_to_cpu(image->size); in lpfc_write_firmware()
12945 if (strncmp(fwrev, image->revision, strnlen(image->revision, 16))) { in lpfc_write_firmware()
12949 fwrev, image->revision); in lpfc_write_firmware()
12954 rc = -ENOMEM; in lpfc_write_firmware()
12957 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_write_firmware()
12959 &dmabuf->phys, in lpfc_write_firmware()
12961 if (!dmabuf->virt) { in lpfc_write_firmware()
12963 rc = -ENOMEM; in lpfc_write_firmware()
12966 list_add_tail(&dmabuf->list, &dma_buffer_list); in lpfc_write_firmware()
12968 while (offset < fw->size) { in lpfc_write_firmware()
12971 if (temp_offset + SLI4_PAGE_SIZE > fw->size) { in lpfc_write_firmware()
12972 memcpy(dmabuf->virt, in lpfc_write_firmware()
12973 fw->data + temp_offset, in lpfc_write_firmware()
12974 fw->size - temp_offset); in lpfc_write_firmware()
12975 temp_offset = fw->size; in lpfc_write_firmware()
12978 memcpy(dmabuf->virt, fw->data + temp_offset, in lpfc_write_firmware()
12983 (fw->size - offset), &offset); in lpfc_write_firmware()
12999 fwrev, image->revision); in lpfc_write_firmware()
13003 list_del(&dmabuf->list); in lpfc_write_firmware()
13004 dma_free_coherent(&phba->pcidev->dev, SLI4_PAGE_SIZE, in lpfc_write_firmware()
13005 dmabuf->virt, dmabuf->phys); in lpfc_write_firmware()
13019 * lpfc_sli4_request_firmware_update - Request linux generic firmware upgrade
13034 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_request_firmware_update()
13036 return -EPERM; in lpfc_sli4_request_firmware_update()
13038 scnprintf(file_name, sizeof(file_name), "%s.grp", phba->ModelName); in lpfc_sli4_request_firmware_update()
13042 file_name, &phba->pcidev->dev, in lpfc_sli4_request_firmware_update()
13046 ret = request_firmware(&fw, file_name, &phba->pcidev->dev); in lpfc_sli4_request_firmware_update()
13050 ret = -EINVAL; in lpfc_sli4_request_firmware_update()
13057 * lpfc_pci_probe_one_s4 - PCI probe func to reg SLI-4 device to PCI subsys
13062 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
13063 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
13071 * 0 - driver can claim the device
13072 * negative value - driver can not claim the device
13086 return -ENOMEM; in lpfc_pci_probe_one_s4()
13088 INIT_LIST_HEAD(&phba->poll_list); in lpfc_pci_probe_one_s4()
13095 /* Set up SLI API function jump table for PCI-device group-1 HBAs */ in lpfc_pci_probe_one_s4()
13100 /* Set up SLI-4 specific device PCI memory space */ in lpfc_pci_probe_one_s4()
13108 /* Set up SLI-4 Specific device driver resources */ in lpfc_pci_probe_one_s4()
13116 INIT_LIST_HEAD(&phba->active_rrq_list); in lpfc_pci_probe_one_s4()
13117 INIT_LIST_HEAD(&phba->fcf.fcf_pri_list); in lpfc_pci_probe_one_s4()
13128 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s4()
13131 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s4()
13134 phba->pport = NULL; in lpfc_pci_probe_one_s4()
13148 error = -ENODEV; in lpfc_pci_probe_one_s4()
13151 /* Default to single EQ for non-MSI-X */ in lpfc_pci_probe_one_s4()
13152 if (phba->intr_type != MSIX) { in lpfc_pci_probe_one_s4()
13153 phba->cfg_irq_chann = 1; in lpfc_pci_probe_one_s4()
13154 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
13155 if (phba->nvmet_support) in lpfc_pci_probe_one_s4()
13156 phba->cfg_nvmet_mrq = 1; in lpfc_pci_probe_one_s4()
13159 lpfc_cpu_affinity_check(phba, phba->cfg_irq_chann); in lpfc_pci_probe_one_s4()
13168 vport = phba->pport; in lpfc_pci_probe_one_s4()
13179 /* Set up SLI-4 HBA */ in lpfc_pci_probe_one_s4()
13183 error = -ENODEV; in lpfc_pci_probe_one_s4()
13188 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s4()
13197 if (phba->nvmet_support == 0) { in lpfc_pci_probe_one_s4()
13198 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
13215 if (phba->cfg_request_firmware_upgrade) in lpfc_pci_probe_one_s4()
13224 timer_setup(&phba->cpuhp_poll_timer, lpfc_sli4_poll_hbtimer, 0); in lpfc_pci_probe_one_s4()
13225 cpuhp_state_add_instance_nocalls(lpfc_cpuhp_state, &phba->cpuhp); in lpfc_pci_probe_one_s4()
13251 * lpfc_pci_remove_one_s4 - PCI func to unreg SLI-4 device from PCI subsystem
13255 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
13263 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s4()
13265 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s4()
13269 spin_lock_irq(&phba->hbalock); in lpfc_pci_remove_one_s4()
13270 vport->load_flag |= FC_UNLOADING; in lpfc_pci_remove_one_s4()
13271 spin_unlock_irq(&phba->hbalock); in lpfc_pci_remove_one_s4()
13279 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s4()
13280 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s4()
13282 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s4()
13297 /* De-allocate multi-XRI pools */ in lpfc_pci_remove_one_s4()
13298 if (phba->cfg_xri_rebalancing) in lpfc_pci_remove_one_s4()
13309 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
13310 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s4()
13311 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
13337 * lpfc_pci_suspend_one_s4 - PCI func to suspend SLI-4 device for power mgmnt
13342 * Power Management (PM) to device with SLI-4 interface spec. When PM invokes
13346 * requirements to a power-aware driver's PM support for suspend/resume -- all
13354 * 0 - driver suspended the device
13361 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s4()
13369 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s4()
13383 * lpfc_pci_resume_one_s4 - PCI func to resume SLI-4 device for power mgmnt
13387 * Power Management (PM) to device with SLI-4 interface spac. When PM invokes
13390 * implements the minimum PM requirements to a power-aware driver's PM for
13391 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
13398 * 0 - driver suspended the device
13405 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s4()
13422 if (pdev->is_busmaster) in lpfc_pci_resume_one_s4()
13426 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s4()
13427 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s4()
13428 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s4()
13429 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s4()
13437 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
13441 return -EIO; in lpfc_pci_resume_one_s4()
13443 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s4()
13450 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
13456 * lpfc_sli4_prep_dev_for_recover - Prepare SLI4 device for pci slot recover
13469 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli4_prep_dev_for_recover()
13475 * lpfc_sli4_prep_dev_for_reset - Prepare SLI4 device for pci slot reset
13503 pci_disable_device(phba->pcidev); in lpfc_sli4_prep_dev_for_reset()
13507 * lpfc_sli4_prep_dev_for_perm_failure - Prepare SLI4 dev for pci slot disable
13531 * lpfc_io_error_detected_s4 - Method for handling PCI I/O error to SLI-4 device
13536 * with SLI-4 interface spec. This function is called by the PCI subsystem
13543 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
13544 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
13550 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s4()
13554 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s4()
13575 * lpfc_io_slot_reset_s4 - Method for restart PCI SLI-4 device from scratch
13579 * with SLI-4 interface spec. It is called after PCI bus has been reset to
13580 * restart the PCI card from scratch, as if from a cold-boot. During the
13589 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
13590 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
13596 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s4()
13597 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s4()
13600 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s4()
13602 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s4()
13615 if (pdev->is_busmaster) in lpfc_io_slot_reset_s4()
13618 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
13619 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s4()
13620 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
13625 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
13628 "2824 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s4()
13632 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s4()
13635 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
13641 * lpfc_io_resume_s4 - Method for resuming PCI I/O operation to SLI-4 device
13645 * with SLI-4 interface spec. It is called when kernel error recovery tells
13654 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s4()
13662 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) { in lpfc_io_resume_s4()
13673 * lpfc_pci_probe_one - lpfc PCI probe func to reg dev to PCI subsystem
13679 * at PCI device-specific information of the device and driver to see if the
13682 * the action to the proper SLI-3 or SLI-4 device probing routine, which will
13687 * 0 - driver can claim the device
13688 * negative value - driver can not claim the device
13697 return -ENODEV; in lpfc_pci_probe_one()
13709 * lpfc_pci_remove_one - lpfc PCI func to unreg dev from PCI subsystem
13714 * This routine dispatches the action to the proper SLI-3 or SLI-4 device
13722 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_remove_one()
13724 switch (phba->pci_dev_grp) { in lpfc_pci_remove_one()
13734 phba->pci_dev_grp); in lpfc_pci_remove_one()
13741 * lpfc_pci_suspend_one - lpfc PCI func to suspend dev for power management
13747 * the action to the proper SLI-3 or SLI-4 device suspend routine, which will
13751 * 0 - driver suspended the device
13758 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one()
13759 int rc = -ENODEV; in lpfc_pci_suspend_one()
13761 switch (phba->pci_dev_grp) { in lpfc_pci_suspend_one()
13771 phba->pci_dev_grp); in lpfc_pci_suspend_one()
13778 * lpfc_pci_resume_one - lpfc PCI func to resume dev for power management
13783 * the action to the proper SLI-3 or SLI-4 device resume routine, which will
13787 * 0 - driver suspended the device
13794 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one()
13795 int rc = -ENODEV; in lpfc_pci_resume_one()
13797 switch (phba->pci_dev_grp) { in lpfc_pci_resume_one()
13807 phba->pci_dev_grp); in lpfc_pci_resume_one()
13814 * lpfc_io_error_detected - lpfc method for handling PCI I/O error
13821 * the action to the proper SLI-3 or SLI-4 device error detected handling
13825 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
13826 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
13832 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected()
13835 switch (phba->pci_dev_grp) { in lpfc_io_error_detected()
13845 phba->pci_dev_grp); in lpfc_io_error_detected()
13852 * lpfc_io_slot_reset - lpfc method for restart PCI dev from scratch
13857 * from scratch, as if from a cold-boot. When this routine is invoked, it
13858 * dispatches the action to the proper SLI-3 or SLI-4 device reset handling
13862 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
13863 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
13869 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset()
13872 switch (phba->pci_dev_grp) { in lpfc_io_slot_reset()
13882 phba->pci_dev_grp); in lpfc_io_slot_reset()
13889 * lpfc_io_resume - lpfc method for resuming PCI I/O operation
13895 * this routine is invoked, it dispatches the action to the proper SLI-3
13896 * or SLI-4 device io_resume routine, which will resume the device operation.
13902 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume()
13904 switch (phba->pci_dev_grp) { in lpfc_io_resume()
13914 phba->pci_dev_grp); in lpfc_io_resume()
13921 * lpfc_sli4_oas_verify - Verify OAS is supported by this adapter
13934 if (!phba->cfg_EnableXLane) in lpfc_sli4_oas_verify()
13937 if (phba->sli4_hba.pc_sli4_params.oas_supported) { in lpfc_sli4_oas_verify()
13938 phba->cfg_fof = 1; in lpfc_sli4_oas_verify()
13940 phba->cfg_fof = 0; in lpfc_sli4_oas_verify()
13941 mempool_destroy(phba->device_data_mem_pool); in lpfc_sli4_oas_verify()
13942 phba->device_data_mem_pool = NULL; in lpfc_sli4_oas_verify()
13949 * lpfc_sli4_ras_init - Verify RAS-FW log is supported by this adapter
13958 switch (phba->pcidev->device) { in lpfc_sli4_ras_init()
13961 phba->ras_fwlog.ras_hwsupport = true; in lpfc_sli4_ras_init()
13962 if (phba->cfg_ras_fwlog_func == PCI_FUNC(phba->pcidev->devfn) && in lpfc_sli4_ras_init()
13963 phba->cfg_ras_fwlog_buffsize) in lpfc_sli4_ras_init()
13964 phba->ras_fwlog.ras_enabled = true; in lpfc_sli4_ras_init()
13966 phba->ras_fwlog.ras_enabled = false; in lpfc_sli4_ras_init()
13969 phba->ras_fwlog.ras_hwsupport = false; in lpfc_sli4_ras_init()
14004 * lpfc_init - lpfc module initialization routine
14011 * 0 - successful
14012 * -ENOMEM - FC attach transport failed
14013 * all others - failed
14028 error = -ENOMEM; in lpfc_init()
14080 if (phba->cfg_log_verbose) in lpfc_dmp_dbg()
14083 if (atomic_cmpxchg(&phba->dbg_log_dmping, 0, 1) != 0) in lpfc_dmp_dbg()
14086 start_idx = (unsigned int)atomic_read(&phba->dbg_log_idx) % DBG_LOG_SZ; in lpfc_dmp_dbg()
14087 dbg_cnt = (unsigned int)atomic_read(&phba->dbg_log_cnt); in lpfc_dmp_dbg()
14091 temp_idx -= 1; in lpfc_dmp_dbg()
14093 if ((start_idx + dbg_cnt) > (DBG_LOG_SZ - 1)) { in lpfc_dmp_dbg()
14097 start_idx = DBG_LOG_SZ - (dbg_cnt - start_idx); in lpfc_dmp_dbg()
14099 start_idx -= dbg_cnt; in lpfc_dmp_dbg()
14102 dev_info(&phba->pcidev->dev, "start %d end %d cnt %d\n", in lpfc_dmp_dbg()
14110 rem_nsec = do_div(phba->dbg_log[temp_idx].t_ns, NSEC_PER_SEC); in lpfc_dmp_dbg()
14111 dev_info(&phba->pcidev->dev, "%d: [%5lu.%06lu] %s", in lpfc_dmp_dbg()
14113 (unsigned long)phba->dbg_log[temp_idx].t_ns, in lpfc_dmp_dbg()
14115 phba->dbg_log[temp_idx].log); in lpfc_dmp_dbg()
14117 atomic_set(&phba->dbg_log_cnt, 0); in lpfc_dmp_dbg()
14118 atomic_set(&phba->dbg_log_dmping, 0); in lpfc_dmp_dbg()
14126 int dbg_dmping = atomic_read(&phba->dbg_log_dmping); in lpfc_dbg_print()
14134 dev_info(&phba->pcidev->dev, "%pV", &vaf); in lpfc_dbg_print()
14138 idx = (unsigned int)atomic_fetch_add(1, &phba->dbg_log_idx) % in lpfc_dbg_print()
14141 atomic_inc(&phba->dbg_log_cnt); in lpfc_dbg_print()
14143 vscnprintf(phba->dbg_log[idx].log, in lpfc_dbg_print()
14144 sizeof(phba->dbg_log[idx].log), fmt, args); in lpfc_dbg_print()
14147 phba->dbg_log[idx].t_ns = local_clock(); in lpfc_dbg_print()
14151 * lpfc_exit - lpfc module removal routine