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
5963 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_event_proc()
5964 phba->hba_flag &= ~ASYNC_EVENT; in lpfc_sli4_async_event_proc()
5965 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_event_proc()
5967 while (!list_empty(&phba->sli4_hba.sp_asynce_work_queue)) { in lpfc_sli4_async_event_proc()
5969 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_event_proc()
5970 list_remove_head(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_async_event_proc()
5972 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_event_proc()
5974 switch (bf_get(lpfc_trailer_code, &cq_event->cqe.mcqe_cmpl)) { in lpfc_sli4_async_event_proc()
5977 &cq_event->cqe.acqe_link); in lpfc_sli4_async_event_proc()
5980 lpfc_sli4_async_fip_evt(phba, &cq_event->cqe.acqe_fip); in lpfc_sli4_async_event_proc()
5984 &cq_event->cqe.acqe_dcbx); in lpfc_sli4_async_event_proc()
5988 &cq_event->cqe.acqe_grp5); in lpfc_sli4_async_event_proc()
5991 lpfc_sli4_async_fc_evt(phba, &cq_event->cqe.acqe_fc); in lpfc_sli4_async_event_proc()
5994 lpfc_sli4_async_sli_evt(phba, &cq_event->cqe.acqe_sli); in lpfc_sli4_async_event_proc()
6001 &cq_event->cqe.mcqe_cmpl)); in lpfc_sli4_async_event_proc()
6010 * lpfc_sli4_fcf_redisc_event_proc - Process fcf table rediscovery event
6020 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_event_proc()
6022 phba->fcf.fcf_flag &= ~FCF_REDISC_EVT; in lpfc_sli4_fcf_redisc_event_proc()
6024 phba->fcf.failover_rec.flag = 0; in lpfc_sli4_fcf_redisc_event_proc()
6026 phba->fcf.fcf_flag |= FCF_REDISC_FOV; in lpfc_sli4_fcf_redisc_event_proc()
6027 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_event_proc()
6029 /* Scan FCF table from the first entry to re-discover SAN */ in lpfc_sli4_fcf_redisc_event_proc()
6031 "2777 Start post-quiescent FCF table scan\n"); in lpfc_sli4_fcf_redisc_event_proc()
6040 * lpfc_api_table_setup - Set up per hba pci-device group func api jump table
6042 * @dev_grp: The HBA PCI-Device group number.
6044 * This routine is invoked to set up the per HBA PCI-Device group function
6047 * Return: 0 if success, otherwise -ENODEV
6054 /* Set up lpfc PCI-device group */ in lpfc_api_table_setup()
6055 phba->pci_dev_grp = dev_grp; in lpfc_api_table_setup()
6059 phba->sli_rev = LPFC_SLI_REV4; in lpfc_api_table_setup()
6064 return -ENODEV; in lpfc_api_table_setup()
6068 return -ENODEV; in lpfc_api_table_setup()
6072 return -ENODEV; in lpfc_api_table_setup()
6076 return -ENODEV; in lpfc_api_table_setup()
6082 * lpfc_log_intr_mode - Log the active interrupt mode
6102 "0480 Enabled MSI-X interrupt mode.\n"); in lpfc_log_intr_mode()
6113 * lpfc_enable_pci_dev - Enable a generic PCI device.
6120 * 0 - successful
6121 * other values - error
6129 if (!phba->pcidev) in lpfc_enable_pci_dev()
6132 pdev = phba->pcidev; in lpfc_enable_pci_dev()
6146 pdev->needs_freset = 1; in lpfc_enable_pci_dev()
6155 return -ENODEV; in lpfc_enable_pci_dev()
6159 * lpfc_disable_pci_dev - Disable a generic PCI device.
6171 if (!phba->pcidev) in lpfc_disable_pci_dev()
6174 pdev = phba->pcidev; in lpfc_disable_pci_dev()
6183 * lpfc_reset_hba - Reset a hba
6195 if (!phba->cfg_enable_hba_reset) { in lpfc_reset_hba()
6196 phba->link_state = LPFC_HBA_ERROR; in lpfc_reset_hba()
6199 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE) in lpfc_reset_hba()
6210 * lpfc_sli_sriov_nr_virtfn_get - Get the number of sr-iov virtual functions
6213 * This function enables the PCI SR-IOV virtual functions to a physical
6214 * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
6216 * not all devices support SR-IOV, the return code from the pci_enable_sriov()
6222 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_sriov_nr_virtfn_get()
6235 * lpfc_sli_probe_sriov_nr_virtfn - Enable a number of sr-iov virtual functions
6239 * This function enables the PCI SR-IOV virtual functions to a physical
6240 * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
6242 * not all devices support SR-IOV, the return code from the pci_enable_sriov()
6248 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_probe_sriov_nr_virtfn()
6257 return -EINVAL; in lpfc_sli_probe_sriov_nr_virtfn()
6274 * lpfc_setup_driver_resource_phase1 - Phase1 etup driver internal resources.
6281 * 0 - successful
6282 * other values - error
6287 struct lpfc_sli *psli = &phba->sli; in lpfc_setup_driver_resource_phase1()
6292 atomic_set(&phba->fast_event_count, 0); in lpfc_setup_driver_resource_phase1()
6293 atomic_set(&phba->dbg_log_idx, 0); in lpfc_setup_driver_resource_phase1()
6294 atomic_set(&phba->dbg_log_cnt, 0); in lpfc_setup_driver_resource_phase1()
6295 atomic_set(&phba->dbg_log_dmping, 0); in lpfc_setup_driver_resource_phase1()
6296 spin_lock_init(&phba->hbalock); in lpfc_setup_driver_resource_phase1()
6299 spin_lock_init(&phba->ndlp_lock); in lpfc_setup_driver_resource_phase1()
6302 spin_lock_init(&phba->port_list_lock); in lpfc_setup_driver_resource_phase1()
6303 INIT_LIST_HEAD(&phba->port_list); in lpfc_setup_driver_resource_phase1()
6305 INIT_LIST_HEAD(&phba->work_list); in lpfc_setup_driver_resource_phase1()
6306 init_waitqueue_head(&phba->wait_4_mlo_m_q); in lpfc_setup_driver_resource_phase1()
6309 init_waitqueue_head(&phba->work_waitq); in lpfc_setup_driver_resource_phase1()
6313 ((phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ? in lpfc_setup_driver_resource_phase1()
6315 ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) ? in lpfc_setup_driver_resource_phase1()
6317 (phba->nvmet_support ? "NVMET" : " ")); in lpfc_setup_driver_resource_phase1()
6320 spin_lock_init(&phba->scsi_buf_list_get_lock); in lpfc_setup_driver_resource_phase1()
6321 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_get); in lpfc_setup_driver_resource_phase1()
6322 spin_lock_init(&phba->scsi_buf_list_put_lock); in lpfc_setup_driver_resource_phase1()
6323 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_put); in lpfc_setup_driver_resource_phase1()
6326 INIT_LIST_HEAD(&phba->fabric_iocb_list); in lpfc_setup_driver_resource_phase1()
6329 INIT_LIST_HEAD(&phba->elsbuf); in lpfc_setup_driver_resource_phase1()
6332 INIT_LIST_HEAD(&phba->fcf_conn_rec_list); in lpfc_setup_driver_resource_phase1()
6335 spin_lock_init(&phba->devicelock); in lpfc_setup_driver_resource_phase1()
6336 INIT_LIST_HEAD(&phba->luns); in lpfc_setup_driver_resource_phase1()
6339 timer_setup(&psli->mbox_tmo, lpfc_mbox_timeout, 0); in lpfc_setup_driver_resource_phase1()
6341 timer_setup(&phba->fabric_block_timer, lpfc_fabric_block_timeout, 0); in lpfc_setup_driver_resource_phase1()
6343 timer_setup(&phba->eratt_poll, lpfc_poll_eratt, 0); in lpfc_setup_driver_resource_phase1()
6345 timer_setup(&phba->hb_tmofunc, lpfc_hb_timeout, 0); in lpfc_setup_driver_resource_phase1()
6347 INIT_DELAYED_WORK(&phba->eq_delay_work, lpfc_hb_eq_delay_work); in lpfc_setup_driver_resource_phase1()
6349 INIT_DELAYED_WORK(&phba->idle_stat_delay_work, in lpfc_setup_driver_resource_phase1()
6356 * lpfc_sli_driver_resource_setup - Setup driver internal resources for SLI3 dev
6360 * support the SLI-3 HBA device it attached to.
6363 * 0 - successful
6364 * other values - error
6376 timer_setup(&phba->fcp_poll_timer, lpfc_poll_timeout, 0); in lpfc_sli_driver_resource_setup()
6379 phba->work_ha_mask = (HA_ERATT | HA_MBATT | HA_LATT); in lpfc_sli_driver_resource_setup()
6380 phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING * 4)); in lpfc_sli_driver_resource_setup()
6384 /* Set up phase-1 common device driver resources */ in lpfc_sli_driver_resource_setup()
6388 return -ENODEV; in lpfc_sli_driver_resource_setup()
6390 if (phba->pcidev->device == PCI_DEVICE_ID_HORNET) { in lpfc_sli_driver_resource_setup()
6391 phba->menlo_flag |= HBA_MENLO_SUPPORT; in lpfc_sli_driver_resource_setup()
6393 if (phba->cfg_sg_seg_cnt < LPFC_DEFAULT_MENLO_SG_SEG_CNT) in lpfc_sli_driver_resource_setup()
6394 phba->cfg_sg_seg_cnt = LPFC_DEFAULT_MENLO_SG_SEG_CNT; in lpfc_sli_driver_resource_setup()
6397 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
6398 phba->sli.sli3_ring = kcalloc(LPFC_SLI3_MAX_RING, in lpfc_sli_driver_resource_setup()
6401 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
6402 return -ENOMEM; in lpfc_sli_driver_resource_setup()
6409 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_driver_resource_setup()
6415 if (phba->cfg_enable_bg) { in lpfc_sli_driver_resource_setup()
6417 * The scsi_buf for a T10-DIF I/O will hold the FCP cmnd, in lpfc_sli_driver_resource_setup()
6425 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
6429 if (phba->cfg_sg_seg_cnt > LPFC_MAX_SG_SEG_CNT_DIF) in lpfc_sli_driver_resource_setup()
6430 phba->cfg_sg_seg_cnt = LPFC_MAX_SG_SEG_CNT_DIF; in lpfc_sli_driver_resource_setup()
6433 phba->cfg_total_seg_cnt = LPFC_MAX_SG_SEG_CNT; in lpfc_sli_driver_resource_setup()
6440 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
6442 ((phba->cfg_sg_seg_cnt + 2) * entry_sz); in lpfc_sli_driver_resource_setup()
6445 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + 2; in lpfc_sli_driver_resource_setup()
6450 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
6451 phba->cfg_total_seg_cnt); in lpfc_sli_driver_resource_setup()
6453 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli_driver_resource_setup()
6455 phba->max_vports = 0; in lpfc_sli_driver_resource_setup()
6465 return -ENOMEM; in lpfc_sli_driver_resource_setup()
6467 phba->lpfc_sg_dma_buf_pool = in lpfc_sli_driver_resource_setup()
6469 &phba->pcidev->dev, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
6472 if (!phba->lpfc_sg_dma_buf_pool) in lpfc_sli_driver_resource_setup()
6475 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli_driver_resource_setup()
6477 &phba->pcidev->dev, in lpfc_sli_driver_resource_setup()
6482 if (!phba->lpfc_cmd_rsp_buf_pool) in lpfc_sli_driver_resource_setup()
6486 * Enable sr-iov virtual functions if supported and configured in lpfc_sli_driver_resource_setup()
6489 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli_driver_resource_setup()
6491 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
6494 "2808 Requested number of SR-IOV " in lpfc_sli_driver_resource_setup()
6497 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
6498 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli_driver_resource_setup()
6505 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli_driver_resource_setup()
6506 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli_driver_resource_setup()
6509 return -ENOMEM; in lpfc_sli_driver_resource_setup()
6513 * lpfc_sli_driver_resource_unset - Unset drvr internal resources for SLI3 dev
6517 * specific for supporting the SLI-3 HBA device it attached to.
6529 * lpfc_sli4_driver_resource_setup - Setup drvr internal resources for SLI4 dev
6533 * support the SLI-4 HBA device it attached to.
6536 * 0 - successful
6537 * other values - error
6553 phba->sli4_hba.num_present_cpu = lpfc_present_cpu; in lpfc_sli4_driver_resource_setup()
6554 phba->sli4_hba.num_possible_cpu = cpumask_last(cpu_possible_mask) + 1; in lpfc_sli4_driver_resource_setup()
6555 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_setup()
6560 /* Set up phase-1 common device driver resources */ in lpfc_sli4_driver_resource_setup()
6563 return -ENODEV; in lpfc_sli4_driver_resource_setup()
6568 return -ENODEV; in lpfc_sli4_driver_resource_setup()
6573 phba->wq = alloc_workqueue("lpfc_wq", WQ_MEM_RECLAIM, 0); in lpfc_sli4_driver_resource_setup()
6579 timer_setup(&phba->rrq_tmr, lpfc_rrq_timeout, 0); in lpfc_sli4_driver_resource_setup()
6582 timer_setup(&phba->fcf.redisc_wait, lpfc_sli4_fcf_redisc_wait_tmo, 0); in lpfc_sli4_driver_resource_setup()
6585 * Control structure for handling external multi-buffer mailbox in lpfc_sli4_driver_resource_setup()
6586 * command pass-through. in lpfc_sli4_driver_resource_setup()
6588 memset((uint8_t *)&phba->mbox_ext_buf_ctx, 0, in lpfc_sli4_driver_resource_setup()
6590 INIT_LIST_HEAD(&phba->mbox_ext_buf_ctx.ext_dmabuf_list); in lpfc_sli4_driver_resource_setup()
6592 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli4_driver_resource_setup()
6595 phba->max_vports = 0; in lpfc_sli4_driver_resource_setup()
6598 phba->valid_vlan = 0; in lpfc_sli4_driver_resource_setup()
6599 phba->fc_map[0] = LPFC_FCOE_FCF_MAP0; in lpfc_sli4_driver_resource_setup()
6600 phba->fc_map[1] = LPFC_FCOE_FCF_MAP1; in lpfc_sli4_driver_resource_setup()
6601 phba->fc_map[2] = LPFC_FCOE_FCF_MAP2; in lpfc_sli4_driver_resource_setup()
6610 INIT_LIST_HEAD(&phba->hbqs[LPFC_ELS_HBQ].hbq_buffer_list); in lpfc_sli4_driver_resource_setup()
6611 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_sli4_rb_alloc; in lpfc_sli4_driver_resource_setup()
6612 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_sli4_rb_free; in lpfc_sli4_driver_resource_setup()
6618 spin_lock_init(&phba->sli4_hba.abts_io_buf_list_lock); in lpfc_sli4_driver_resource_setup()
6619 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_io_buf_list); in lpfc_sli4_driver_resource_setup()
6621 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
6623 spin_lock_init(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_sli4_driver_resource_setup()
6624 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_driver_resource_setup()
6625 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_io_wait_list); in lpfc_sli4_driver_resource_setup()
6626 spin_lock_init(&phba->sli4_hba.t_active_list_lock); in lpfc_sli4_driver_resource_setup()
6627 INIT_LIST_HEAD(&phba->sli4_hba.t_active_ctx_list); in lpfc_sli4_driver_resource_setup()
6631 spin_lock_init(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_driver_resource_setup()
6632 spin_lock_init(&phba->sli4_hba.nvmet_io_wait_lock); in lpfc_sli4_driver_resource_setup()
6635 * Initialize driver internal slow-path work queues in lpfc_sli4_driver_resource_setup()
6638 /* Driver internel slow-path CQ Event pool */ in lpfc_sli4_driver_resource_setup()
6639 INIT_LIST_HEAD(&phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_driver_resource_setup()
6641 INIT_LIST_HEAD(&phba->sli4_hba.sp_queue_event); in lpfc_sli4_driver_resource_setup()
6643 INIT_LIST_HEAD(&phba->sli4_hba.sp_asynce_work_queue); in lpfc_sli4_driver_resource_setup()
6644 /* Fast-path XRI aborted CQ Event work queue list */ in lpfc_sli4_driver_resource_setup()
6645 INIT_LIST_HEAD(&phba->sli4_hba.sp_fcp_xri_aborted_work_queue); in lpfc_sli4_driver_resource_setup()
6646 /* Slow-path XRI aborted CQ Event work queue list */ in lpfc_sli4_driver_resource_setup()
6647 INIT_LIST_HEAD(&phba->sli4_hba.sp_els_xri_aborted_work_queue); in lpfc_sli4_driver_resource_setup()
6649 INIT_LIST_HEAD(&phba->sli4_hba.sp_unsol_work_queue); in lpfc_sli4_driver_resource_setup()
6652 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_blk_list); in lpfc_sli4_driver_resource_setup()
6653 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_xri_blk_list); in lpfc_sli4_driver_resource_setup()
6654 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_vfi_blk_list); in lpfc_sli4_driver_resource_setup()
6655 INIT_LIST_HEAD(&phba->lpfc_vpi_blk_list); in lpfc_sli4_driver_resource_setup()
6660 INIT_LIST_HEAD(&phba->sli.mboxq); in lpfc_sli4_driver_resource_setup()
6661 INIT_LIST_HEAD(&phba->sli.mboxq_cmpl); in lpfc_sli4_driver_resource_setup()
6664 phba->sli4_hba.lnk_info.optic_state = 0xff; in lpfc_sli4_driver_resource_setup()
6669 return -ENOMEM; in lpfc_sli4_driver_resource_setup()
6672 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_driver_resource_setup()
6676 rc = -ENODEV; in lpfc_sli4_driver_resource_setup()
6679 phba->temp_sensor_support = 1; in lpfc_sli4_driver_resource_setup()
6701 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_driver_resource_setup()
6708 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_sli4_driver_resource_setup()
6711 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
6716 phba->nvmet_support = 0; in lpfc_sli4_driver_resource_setup()
6727 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_driver_resource_setup()
6728 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_driver_resource_setup()
6729 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
6730 rc = -EIO; in lpfc_sli4_driver_resource_setup()
6733 mb = &mboxq->u.mb; in lpfc_sli4_driver_resource_setup()
6734 memcpy(&wwn, (char *)mb->un.varRDnvp.nodename, in lpfc_sli4_driver_resource_setup()
6737 phba->sli4_hba.wwnn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
6738 memcpy(&wwn, (char *)mb->un.varRDnvp.portname, in lpfc_sli4_driver_resource_setup()
6742 phba->sli4_hba.wwpn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
6751 phba->nvmet_support = 1; /* a match */ in lpfc_sli4_driver_resource_setup()
6765 phba->cfg_xri_rebalancing = 0; in lpfc_sli4_driver_resource_setup()
6766 if (phba->irq_chann_mode == NHT_MODE) { in lpfc_sli4_driver_resource_setup()
6767 phba->cfg_irq_chann = in lpfc_sli4_driver_resource_setup()
6768 phba->sli4_hba.num_present_cpu; in lpfc_sli4_driver_resource_setup()
6769 phba->cfg_hdw_queue = in lpfc_sli4_driver_resource_setup()
6770 phba->sli4_hba.num_present_cpu; in lpfc_sli4_driver_resource_setup()
6771 phba->irq_chann_mode = NORMAL_MODE; in lpfc_sli4_driver_resource_setup()
6784 mqe = &mboxq->u.mqe; in lpfc_sli4_driver_resource_setup()
6785 memcpy(&pn_page[0], ((uint8_t *)&mqe->un.supp_pages.word3), in lpfc_sli4_driver_resource_setup()
6790 phba->sli4_hba.pc_sli4_params.supported = 1; in lpfc_sli4_driver_resource_setup()
6797 if (phba->sli4_hba.pc_sli4_params.supported) in lpfc_sli4_driver_resource_setup()
6800 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
6801 rc = -EIO; in lpfc_sli4_driver_resource_setup()
6814 &phba->sli4_hba.sli_intf); in lpfc_sli4_driver_resource_setup()
6816 &phba->sli4_hba.sli_intf); in lpfc_sli4_driver_resource_setup()
6817 if (phba->sli4_hba.extents_in_use && in lpfc_sli4_driver_resource_setup()
6818 phba->sli4_hba.rpi_hdrs_in_use) { in lpfc_sli4_driver_resource_setup()
6824 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
6825 rc = -EIO; in lpfc_sli4_driver_resource_setup()
6831 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
6832 rc = -EIO; in lpfc_sli4_driver_resource_setup()
6842 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_driver_resource_setup()
6856 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) { in lpfc_sli4_driver_resource_setup()
6860 * The scsi_buf for a T10-DIF I/O holds the FCP cmnd, in lpfc_sli4_driver_resource_setup()
6868 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli4_driver_resource_setup()
6872 phba->cfg_total_seg_cnt = LPFC_MAX_SGL_SEG_CNT; in lpfc_sli4_driver_resource_setup()
6878 if (phba->cfg_enable_bg && in lpfc_sli4_driver_resource_setup()
6879 phba->cfg_sg_seg_cnt > LPFC_MAX_BG_SLI4_SEG_CNT_DIF) in lpfc_sli4_driver_resource_setup()
6880 phba->cfg_scsi_seg_cnt = LPFC_MAX_BG_SLI4_SEG_CNT_DIF; in lpfc_sli4_driver_resource_setup()
6882 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
6890 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli4_driver_resource_setup()
6892 ((phba->cfg_sg_seg_cnt + extra) * in lpfc_sli4_driver_resource_setup()
6896 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + extra; in lpfc_sli4_driver_resource_setup()
6897 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
6900 * NOTE: if (phba->cfg_sg_seg_cnt + extra) <= 256 we only in lpfc_sli4_driver_resource_setup()
6905 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_driver_resource_setup()
6906 phba->cfg_sg_dma_buf_size = LPFC_DEFAULT_XPSGL_SIZE; in lpfc_sli4_driver_resource_setup()
6907 else if (phba->cfg_sg_dma_buf_size <= LPFC_MIN_SG_SLI4_BUF_SZ) in lpfc_sli4_driver_resource_setup()
6908 phba->cfg_sg_dma_buf_size = LPFC_MIN_SG_SLI4_BUF_SZ; in lpfc_sli4_driver_resource_setup()
6910 phba->cfg_sg_dma_buf_size = in lpfc_sli4_driver_resource_setup()
6911 SLI4_PAGE_ALIGN(phba->cfg_sg_dma_buf_size); in lpfc_sli4_driver_resource_setup()
6913 phba->border_sge_num = phba->cfg_sg_dma_buf_size / in lpfc_sli4_driver_resource_setup()
6917 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
6918 if (phba->cfg_sg_seg_cnt > LPFC_MAX_NVME_SEG_CNT) { in lpfc_sli4_driver_resource_setup()
6923 phba->cfg_nvme_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_sli4_driver_resource_setup()
6925 phba->cfg_nvme_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
6931 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
6932 phba->cfg_total_seg_cnt, phba->cfg_scsi_seg_cnt, in lpfc_sli4_driver_resource_setup()
6933 phba->cfg_nvme_seg_cnt); in lpfc_sli4_driver_resource_setup()
6935 if (phba->cfg_sg_dma_buf_size < SLI4_PAGE_SIZE) in lpfc_sli4_driver_resource_setup()
6936 i = phba->cfg_sg_dma_buf_size; in lpfc_sli4_driver_resource_setup()
6940 phba->lpfc_sg_dma_buf_pool = in lpfc_sli4_driver_resource_setup()
6942 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
6943 phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
6945 if (!phba->lpfc_sg_dma_buf_pool) in lpfc_sli4_driver_resource_setup()
6948 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli4_driver_resource_setup()
6950 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
6954 if (!phba->lpfc_cmd_rsp_buf_pool) in lpfc_sli4_driver_resource_setup()
6957 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
6993 longs = (LPFC_SLI4_FCF_TBL_INDX_MAX + BITS_PER_LONG - 1)/BITS_PER_LONG; in lpfc_sli4_driver_resource_setup()
6994 phba->fcf.fcf_rr_bmask = kcalloc(longs, sizeof(unsigned long), in lpfc_sli4_driver_resource_setup()
6996 if (!phba->fcf.fcf_rr_bmask) { in lpfc_sli4_driver_resource_setup()
7000 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
7004 phba->sli4_hba.hba_eq_hdl = kcalloc(phba->cfg_irq_chann, in lpfc_sli4_driver_resource_setup()
7007 if (!phba->sli4_hba.hba_eq_hdl) { in lpfc_sli4_driver_resource_setup()
7010 "fast-path per-EQ handle array\n"); in lpfc_sli4_driver_resource_setup()
7011 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
7015 phba->sli4_hba.cpu_map = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
7018 if (!phba->sli4_hba.cpu_map) { in lpfc_sli4_driver_resource_setup()
7020 "3327 Failed allocate memory for msi-x " in lpfc_sli4_driver_resource_setup()
7022 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
7026 phba->sli4_hba.eq_info = alloc_percpu(struct lpfc_eq_intr_info); in lpfc_sli4_driver_resource_setup()
7027 if (!phba->sli4_hba.eq_info) { in lpfc_sli4_driver_resource_setup()
7030 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
7034 phba->sli4_hba.idle_stat = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
7035 sizeof(*phba->sli4_hba.idle_stat), in lpfc_sli4_driver_resource_setup()
7037 if (!phba->sli4_hba.idle_stat) { in lpfc_sli4_driver_resource_setup()
7040 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
7045 phba->sli4_hba.c_stat = alloc_percpu(struct lpfc_hdwq_stat); in lpfc_sli4_driver_resource_setup()
7046 if (!phba->sli4_hba.c_stat) { in lpfc_sli4_driver_resource_setup()
7048 "3332 Failed allocating per cpu hdwq stats\n"); in lpfc_sli4_driver_resource_setup()
7049 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
7055 * Enable sr-iov virtual functions if supported and configured in lpfc_sli4_driver_resource_setup()
7058 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli4_driver_resource_setup()
7060 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
7063 "3020 Requested number of SR-IOV " in lpfc_sli4_driver_resource_setup()
7066 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
7067 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli4_driver_resource_setup()
7075 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_setup()
7078 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_setup()
7080 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_setup()
7082 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_setup()
7084 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_setup()
7092 dma_pool_destroy(phba->lpfc_cmd_rsp_buf_pool); in lpfc_sli4_driver_resource_setup()
7093 phba->lpfc_cmd_rsp_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
7095 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli4_driver_resource_setup()
7096 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
7105 * lpfc_sli4_driver_resource_unset - Unset drvr internal resources for SLI4 dev
7109 * specific for supporting the SLI-4 HBA device it attached to.
7116 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_unset()
7118 free_percpu(phba->sli4_hba.c_stat); in lpfc_sli4_driver_resource_unset()
7120 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_unset()
7122 /* Free memory allocated for msi-x interrupt vector to CPU mapping */ in lpfc_sli4_driver_resource_unset()
7123 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_unset()
7124 phba->sli4_hba.num_possible_cpu = 0; in lpfc_sli4_driver_resource_unset()
7125 phba->sli4_hba.num_present_cpu = 0; in lpfc_sli4_driver_resource_unset()
7126 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_unset()
7127 cpumask_clear(&phba->sli4_hba.irq_aff_mask); in lpfc_sli4_driver_resource_unset()
7129 /* Free memory allocated for fast-path work queue handles */ in lpfc_sli4_driver_resource_unset()
7130 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_unset()
7137 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_unset()
7159 &phba->fcf_conn_rec_list, list) { in lpfc_sli4_driver_resource_unset()
7160 list_del_init(&conn_entry->list); in lpfc_sli4_driver_resource_unset()
7168 * lpfc_init_api_table_setup - Set up init api function jump table
7170 * @dev_grp: The HBA PCI-Device group number.
7175 * Returns: 0 - success, -ENODEV - failure.
7180 phba->lpfc_hba_init_link = lpfc_hba_init_link; in lpfc_init_api_table_setup()
7181 phba->lpfc_hba_down_link = lpfc_hba_down_link; in lpfc_init_api_table_setup()
7182 phba->lpfc_selective_reset = lpfc_selective_reset; in lpfc_init_api_table_setup()
7185 phba->lpfc_hba_down_post = lpfc_hba_down_post_s3; in lpfc_init_api_table_setup()
7186 phba->lpfc_handle_eratt = lpfc_handle_eratt_s3; in lpfc_init_api_table_setup()
7187 phba->lpfc_stop_port = lpfc_stop_port_s3; in lpfc_init_api_table_setup()
7190 phba->lpfc_hba_down_post = lpfc_hba_down_post_s4; in lpfc_init_api_table_setup()
7191 phba->lpfc_handle_eratt = lpfc_handle_eratt_s4; in lpfc_init_api_table_setup()
7192 phba->lpfc_stop_port = lpfc_stop_port_s4; in lpfc_init_api_table_setup()
7196 "1431 Invalid HBA PCI-device group: 0x%x\n", in lpfc_init_api_table_setup()
7198 return -ENODEV; in lpfc_init_api_table_setup()
7205 * lpfc_setup_driver_resource_phase2 - Phase2 setup driver internal resources.
7212 * 0 - successful
7213 * other values - error
7221 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_setup_driver_resource_phase2()
7222 "lpfc_worker_%d", phba->brd_no); in lpfc_setup_driver_resource_phase2()
7223 if (IS_ERR(phba->worker_thread)) { in lpfc_setup_driver_resource_phase2()
7224 error = PTR_ERR(phba->worker_thread); in lpfc_setup_driver_resource_phase2()
7232 * lpfc_unset_driver_resource_phase2 - Phase2 unset driver internal resources.
7242 if (phba->wq) { in lpfc_unset_driver_resource_phase2()
7243 flush_workqueue(phba->wq); in lpfc_unset_driver_resource_phase2()
7244 destroy_workqueue(phba->wq); in lpfc_unset_driver_resource_phase2()
7245 phba->wq = NULL; in lpfc_unset_driver_resource_phase2()
7249 if (phba->worker_thread) in lpfc_unset_driver_resource_phase2()
7250 kthread_stop(phba->worker_thread); in lpfc_unset_driver_resource_phase2()
7254 * lpfc_free_iocb_list - Free iocb list.
7264 spin_lock_irq(&phba->hbalock); in lpfc_free_iocb_list()
7266 &phba->lpfc_iocb_list, list) { in lpfc_free_iocb_list()
7267 list_del(&iocbq_entry->list); in lpfc_free_iocb_list()
7269 phba->total_iocbq_bufs--; in lpfc_free_iocb_list()
7271 spin_unlock_irq(&phba->hbalock); in lpfc_free_iocb_list()
7277 * lpfc_init_iocb_list - Allocate and initialize iocb list.
7285 * 0 - successful
7286 * other values - error
7296 INIT_LIST_HEAD(&phba->lpfc_iocb_list); in lpfc_init_iocb_list()
7313 iocbq_entry->sli4_lxritag = NO_XRI; in lpfc_init_iocb_list()
7314 iocbq_entry->sli4_xritag = NO_XRI; in lpfc_init_iocb_list()
7316 spin_lock_irq(&phba->hbalock); in lpfc_init_iocb_list()
7317 list_add(&iocbq_entry->list, &phba->lpfc_iocb_list); in lpfc_init_iocb_list()
7318 phba->total_iocbq_bufs++; in lpfc_init_iocb_list()
7319 spin_unlock_irq(&phba->hbalock); in lpfc_init_iocb_list()
7327 return -ENOMEM; in lpfc_init_iocb_list()
7331 * lpfc_free_sgl_list - Free a given sgl list.
7343 list_del(&sglq_entry->list); in lpfc_free_sgl_list()
7344 lpfc_mbuf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_sgl_list()
7350 * lpfc_free_els_sgl_list - Free els sgl list.
7361 spin_lock_irq(&phba->hbalock); in lpfc_free_els_sgl_list()
7362 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
7363 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, &sglq_list); in lpfc_free_els_sgl_list()
7364 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
7365 spin_unlock_irq(&phba->hbalock); in lpfc_free_els_sgl_list()
7372 * lpfc_free_nvmet_sgl_list - Free nvmet sgl list.
7384 spin_lock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
7385 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
7386 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, &sglq_list); in lpfc_free_nvmet_sgl_list()
7387 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
7388 spin_unlock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
7392 list_del(&sglq_entry->list); in lpfc_free_nvmet_sgl_list()
7393 lpfc_nvmet_buf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_nvmet_sgl_list()
7401 phba->sli4_hba.nvmet_xri_cnt = 0; in lpfc_free_nvmet_sgl_list()
7405 * lpfc_init_active_sgl_array - Allocate the buf to track active ELS XRIs.
7416 size *= phba->sli4_hba.max_cfg_param.max_xri; in lpfc_init_active_sgl_array()
7418 phba->sli4_hba.lpfc_sglq_active_list = in lpfc_init_active_sgl_array()
7420 if (!phba->sli4_hba.lpfc_sglq_active_list) in lpfc_init_active_sgl_array()
7421 return -ENOMEM; in lpfc_init_active_sgl_array()
7426 * lpfc_free_active_sgl - Free the buf that tracks active ELS XRIs.
7436 kfree(phba->sli4_hba.lpfc_sglq_active_list); in lpfc_free_active_sgl()
7440 * lpfc_init_sgl_list - Allocate and initialize sgl list.
7451 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_els_sgl_list); in lpfc_init_sgl_list()
7452 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_init_sgl_list()
7453 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_init_sgl_list()
7454 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_init_sgl_list()
7456 /* els xri-sgl book keeping */ in lpfc_init_sgl_list()
7457 phba->sli4_hba.els_xri_cnt = 0; in lpfc_init_sgl_list()
7459 /* nvme xri-buffer book keeping */ in lpfc_init_sgl_list()
7460 phba->sli4_hba.io_xri_cnt = 0; in lpfc_init_sgl_list()
7464 * lpfc_sli4_init_rpi_hdrs - Post the rpi header memory region to the port
7474 * 0 - successful
7475 * -ERROR - otherwise.
7483 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_init_rpi_hdrs()
7484 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_init_rpi_hdrs()
7486 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_init_rpi_hdrs()
7487 return -EIO; in lpfc_sli4_init_rpi_hdrs()
7494 rc = -ENODEV; in lpfc_sli4_init_rpi_hdrs()
7501 * lpfc_sli4_create_rpi_hdr - Allocate an rpi header memory region
7525 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_create_rpi_hdr()
7527 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_create_rpi_hdr()
7531 rpi_limit = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_create_rpi_hdr()
7533 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
7539 curr_rpi_range = phba->sli4_hba.next_rpi; in lpfc_sli4_create_rpi_hdr()
7540 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
7548 * port expects a 4KB DMA-mapped memory region that is 4K aligned. in lpfc_sli4_create_rpi_hdr()
7554 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_create_rpi_hdr()
7556 &dmabuf->phys, GFP_KERNEL); in lpfc_sli4_create_rpi_hdr()
7557 if (!dmabuf->virt) { in lpfc_sli4_create_rpi_hdr()
7562 if (!IS_ALIGNED(dmabuf->phys, LPFC_HDR_TEMPLATE_SIZE)) { in lpfc_sli4_create_rpi_hdr()
7572 rpi_hdr->dmabuf = dmabuf; in lpfc_sli4_create_rpi_hdr()
7573 rpi_hdr->len = LPFC_HDR_TEMPLATE_SIZE; in lpfc_sli4_create_rpi_hdr()
7574 rpi_hdr->page_count = 1; in lpfc_sli4_create_rpi_hdr()
7575 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
7578 rpi_hdr->start_rpi = curr_rpi_range; in lpfc_sli4_create_rpi_hdr()
7579 rpi_hdr->next_rpi = phba->sli4_hba.next_rpi + LPFC_RPI_HDR_COUNT; in lpfc_sli4_create_rpi_hdr()
7580 list_add_tail(&rpi_hdr->list, &phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_create_rpi_hdr()
7582 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
7586 dma_free_coherent(&phba->pcidev->dev, LPFC_HDR_TEMPLATE_SIZE, in lpfc_sli4_create_rpi_hdr()
7587 dmabuf->virt, dmabuf->phys); in lpfc_sli4_create_rpi_hdr()
7594 * lpfc_sli4_remove_rpi_hdrs - Remove all rpi header memory regions
7607 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_remove_rpi_hdrs()
7611 &phba->sli4_hba.lpfc_rpi_hdr_list, list) { in lpfc_sli4_remove_rpi_hdrs()
7612 list_del(&rpi_hdr->list); in lpfc_sli4_remove_rpi_hdrs()
7613 dma_free_coherent(&phba->pcidev->dev, rpi_hdr->len, in lpfc_sli4_remove_rpi_hdrs()
7614 rpi_hdr->dmabuf->virt, rpi_hdr->dmabuf->phys); in lpfc_sli4_remove_rpi_hdrs()
7615 kfree(rpi_hdr->dmabuf); in lpfc_sli4_remove_rpi_hdrs()
7620 phba->sli4_hba.next_rpi = 0; in lpfc_sli4_remove_rpi_hdrs()
7624 * lpfc_hba_alloc - Allocate driver hba data structure for a device.
7632 * pointer to @phba - successful
7633 * NULL - error
7643 dev_err(&pdev->dev, "failed to allocate hba struct\n"); in lpfc_hba_alloc()
7648 phba->pcidev = pdev; in lpfc_hba_alloc()
7651 phba->brd_no = lpfc_get_instance(); in lpfc_hba_alloc()
7652 if (phba->brd_no < 0) { in lpfc_hba_alloc()
7656 phba->eratt_poll_interval = LPFC_ERATT_POLL_INTERVAL; in lpfc_hba_alloc()
7658 spin_lock_init(&phba->ct_ev_lock); in lpfc_hba_alloc()
7659 INIT_LIST_HEAD(&phba->ct_ev_waiters); in lpfc_hba_alloc()
7665 * lpfc_hba_free - Free driver hba data structure with a device.
7674 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_hba_free()
7675 kfree(phba->sli4_hba.hdwq); in lpfc_hba_free()
7678 idr_remove(&lpfc_hba_index, phba->brd_no); in lpfc_hba_free()
7681 kfree(phba->sli.sli3_ring); in lpfc_hba_free()
7682 phba->sli.sli3_ring = NULL; in lpfc_hba_free()
7689 * lpfc_create_shost - Create hba physical port with associated scsi host.
7696 * 0 - successful
7697 * other values - error
7706 phba->fc_edtov = FF_DEF_EDTOV; in lpfc_create_shost()
7707 phba->fc_ratov = FF_DEF_RATOV; in lpfc_create_shost()
7708 phba->fc_altov = FF_DEF_ALTOV; in lpfc_create_shost()
7709 phba->fc_arbtov = FF_DEF_ARBTOV; in lpfc_create_shost()
7711 atomic_set(&phba->sdev_cnt, 0); in lpfc_create_shost()
7712 vport = lpfc_create_port(phba, phba->brd_no, &phba->pcidev->dev); in lpfc_create_shost()
7714 return -ENODEV; in lpfc_create_shost()
7717 phba->pport = vport; in lpfc_create_shost()
7719 if (phba->nvmet_support) { in lpfc_create_shost()
7721 phba->targetport = NULL; in lpfc_create_shost()
7722 phba->cfg_enable_fc4_type = LPFC_ENABLE_NVME; in lpfc_create_shost()
7729 pci_set_drvdata(phba->pcidev, shost); in lpfc_create_shost()
7735 vport->load_flag |= FC_ALLOW_FDMI; in lpfc_create_shost()
7736 if (phba->cfg_enable_SmartSAN || in lpfc_create_shost()
7737 (phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT)) { in lpfc_create_shost()
7740 vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR; in lpfc_create_shost()
7741 if (phba->cfg_enable_SmartSAN) in lpfc_create_shost()
7742 vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR; in lpfc_create_shost()
7744 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR; in lpfc_create_shost()
7750 * lpfc_destroy_shost - Destroy hba physical port with associated scsi host.
7759 struct lpfc_vport *vport = phba->pport; in lpfc_destroy_shost()
7768 * lpfc_setup_bg - Setup Block guard structures and debug areas.
7781 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
7786 old_mask = phba->cfg_prot_mask; in lpfc_setup_bg()
7787 old_guard = phba->cfg_prot_guard; in lpfc_setup_bg()
7790 phba->cfg_prot_mask &= (SHOST_DIF_TYPE1_PROTECTION | in lpfc_setup_bg()
7793 phba->cfg_prot_guard &= (SHOST_DIX_GUARD_IP | in lpfc_setup_bg()
7797 if (phba->cfg_prot_mask == SHOST_DIX_TYPE1_PROTECTION) in lpfc_setup_bg()
7798 phba->cfg_prot_mask |= SHOST_DIF_TYPE1_PROTECTION; in lpfc_setup_bg()
7800 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
7801 if ((old_mask != phba->cfg_prot_mask) || in lpfc_setup_bg()
7802 (old_guard != phba->cfg_prot_guard)) in lpfc_setup_bg()
7806 phba->cfg_prot_mask, in lpfc_setup_bg()
7807 phba->cfg_prot_guard); in lpfc_setup_bg()
7809 scsi_host_set_prot(shost, phba->cfg_prot_mask); in lpfc_setup_bg()
7810 scsi_host_set_guard(shost, phba->cfg_prot_guard); in lpfc_setup_bg()
7820 * lpfc_post_init_setup - Perform necessary device post initialization setup.
7833 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_post_init_setup()
7839 shost = pci_get_drvdata(phba->pcidev); in lpfc_post_init_setup()
7840 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_post_init_setup()
7844 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_post_init_setup()
7845 spin_lock_irq(shost->host_lock); in lpfc_post_init_setup()
7847 spin_unlock_irq(shost->host_lock); in lpfc_post_init_setup()
7863 * lpfc_sli_pci_mem_setup - Setup SLI3 HBA PCI memory space.
7867 * with SLI-3 interface spec.
7870 * 0 - successful
7871 * other values - error
7876 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_pci_mem_setup()
7883 return -ENODEV; in lpfc_sli_pci_mem_setup()
7886 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli_pci_mem_setup()
7888 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli_pci_mem_setup()
7891 error = -ENODEV; in lpfc_sli_pci_mem_setup()
7896 phba->pci_bar0_map = pci_resource_start(pdev, 0); in lpfc_sli_pci_mem_setup()
7899 phba->pci_bar2_map = pci_resource_start(pdev, 2); in lpfc_sli_pci_mem_setup()
7903 phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli_pci_mem_setup()
7904 if (!phba->slim_memmap_p) { in lpfc_sli_pci_mem_setup()
7905 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
7911 phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli_pci_mem_setup()
7912 if (!phba->ctrl_regs_memmap_p) { in lpfc_sli_pci_mem_setup()
7913 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
7918 /* Allocate memory for SLI-2 structures */ in lpfc_sli_pci_mem_setup()
7919 phba->slim2p.virt = dma_alloc_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
7920 &phba->slim2p.phys, GFP_KERNEL); in lpfc_sli_pci_mem_setup()
7921 if (!phba->slim2p.virt) in lpfc_sli_pci_mem_setup()
7924 phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx); in lpfc_sli_pci_mem_setup()
7925 phba->mbox_ext = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
7927 phba->pcb = (phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, pcb)); in lpfc_sli_pci_mem_setup()
7928 phba->IOCBs = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
7931 phba->hbqslimp.virt = dma_alloc_coherent(&pdev->dev, in lpfc_sli_pci_mem_setup()
7933 &phba->hbqslimp.phys, in lpfc_sli_pci_mem_setup()
7935 if (!phba->hbqslimp.virt) in lpfc_sli_pci_mem_setup()
7939 ptr = phba->hbqslimp.virt; in lpfc_sli_pci_mem_setup()
7941 phba->hbqs[i].hbq_virt = ptr; in lpfc_sli_pci_mem_setup()
7942 INIT_LIST_HEAD(&phba->hbqs[i].hbq_buffer_list); in lpfc_sli_pci_mem_setup()
7943 ptr += (lpfc_hbq_defs[i]->entry_count * in lpfc_sli_pci_mem_setup()
7946 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_els_hbq_alloc; in lpfc_sli_pci_mem_setup()
7947 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_els_hbq_free; in lpfc_sli_pci_mem_setup()
7949 memset(phba->hbqslimp.virt, 0, lpfc_sli_hbq_size()); in lpfc_sli_pci_mem_setup()
7951 phba->MBslimaddr = phba->slim_memmap_p; in lpfc_sli_pci_mem_setup()
7952 phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
7953 phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
7954 phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; in lpfc_sli_pci_mem_setup()
7955 phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; in lpfc_sli_pci_mem_setup()
7960 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
7961 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_setup()
7963 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_setup()
7965 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_setup()
7971 * lpfc_sli_pci_mem_unset - Unset SLI3 HBA PCI memory space.
7975 * with SLI-3 interface spec.
7983 if (!phba->pcidev) in lpfc_sli_pci_mem_unset()
7986 pdev = phba->pcidev; in lpfc_sli_pci_mem_unset()
7989 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_sli_pci_mem_unset()
7990 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_sli_pci_mem_unset()
7991 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_unset()
7992 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_unset()
7995 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_unset()
7996 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_unset()
8002 * lpfc_sli4_post_status_check - Wait for SLI4 POST done and check status
8008 * Return 0 if successful, otherwise -ENODEV.
8020 if (!phba->sli4_hba.PSMPHRregaddr) in lpfc_sli4_post_status_check()
8021 return -ENODEV; in lpfc_sli4_post_status_check()
8025 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_sli4_post_status_check()
8029 port_error = -ENODEV; in lpfc_sli4_post_status_check()
8044 "1408 Port Failed POST - portsmphr=0x%x, " in lpfc_sli4_post_status_check()
8062 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
8064 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
8066 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
8068 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
8070 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
8072 &phba->sli4_hba.sli_intf)); in lpfc_sli4_post_status_check()
8079 &phba->sli4_hba.sli_intf); in lpfc_sli4_post_status_check()
8082 phba->sli4_hba.ue_mask_lo = in lpfc_sli4_post_status_check()
8083 readl(phba->sli4_hba.u.if_type0.UEMASKLOregaddr); in lpfc_sli4_post_status_check()
8084 phba->sli4_hba.ue_mask_hi = in lpfc_sli4_post_status_check()
8085 readl(phba->sli4_hba.u.if_type0.UEMASKHIregaddr); in lpfc_sli4_post_status_check()
8087 readl(phba->sli4_hba.u.if_type0.UERRLOregaddr); in lpfc_sli4_post_status_check()
8089 readl(phba->sli4_hba.u.if_type0.UERRHIregaddr); in lpfc_sli4_post_status_check()
8090 if ((~phba->sli4_hba.ue_mask_lo & uerrlo_reg.word0) || in lpfc_sli4_post_status_check()
8091 (~phba->sli4_hba.ue_mask_hi & uerrhi_reg.word0)) { in lpfc_sli4_post_status_check()
8102 phba->sli4_hba.ue_mask_lo, in lpfc_sli4_post_status_check()
8103 phba->sli4_hba.ue_mask_hi); in lpfc_sli4_post_status_check()
8104 port_error = -ENODEV; in lpfc_sli4_post_status_check()
8110 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_post_status_check()
8114 phba->work_status[0] = in lpfc_sli4_post_status_check()
8115 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
8117 phba->work_status[1] = in lpfc_sli4_post_status_check()
8118 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
8127 phba->work_status[0], in lpfc_sli4_post_status_check()
8128 phba->work_status[1]); in lpfc_sli4_post_status_check()
8129 port_error = -ENODEV; in lpfc_sli4_post_status_check()
8141 * lpfc_sli4_bar0_register_memmap - Set up SLI4 BAR0 register memory map.
8153 phba->sli4_hba.u.if_type0.UERRLOregaddr = in lpfc_sli4_bar0_register_memmap()
8154 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_LO; in lpfc_sli4_bar0_register_memmap()
8155 phba->sli4_hba.u.if_type0.UERRHIregaddr = in lpfc_sli4_bar0_register_memmap()
8156 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_HI; in lpfc_sli4_bar0_register_memmap()
8157 phba->sli4_hba.u.if_type0.UEMASKLOregaddr = in lpfc_sli4_bar0_register_memmap()
8158 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_LO; in lpfc_sli4_bar0_register_memmap()
8159 phba->sli4_hba.u.if_type0.UEMASKHIregaddr = in lpfc_sli4_bar0_register_memmap()
8160 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_HI; 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()
8165 phba->sli4_hba.u.if_type2.EQDregaddr = in lpfc_sli4_bar0_register_memmap()
8166 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8168 phba->sli4_hba.u.if_type2.ERR1regaddr = in lpfc_sli4_bar0_register_memmap()
8169 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8171 phba->sli4_hba.u.if_type2.ERR2regaddr = in lpfc_sli4_bar0_register_memmap()
8172 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8174 phba->sli4_hba.u.if_type2.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
8175 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8177 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
8178 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8180 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
8181 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
8182 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
8183 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8185 phba->sli4_hba.RQDBregaddr = in lpfc_sli4_bar0_register_memmap()
8186 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8188 phba->sli4_hba.WQDBregaddr = in lpfc_sli4_bar0_register_memmap()
8189 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8191 phba->sli4_hba.CQDBregaddr = in lpfc_sli4_bar0_register_memmap()
8192 phba->sli4_hba.conf_regs_memmap_p + LPFC_EQCQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
8193 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar0_register_memmap()
8194 phba->sli4_hba.MQDBregaddr = in lpfc_sli4_bar0_register_memmap()
8195 phba->sli4_hba.conf_regs_memmap_p + LPFC_MQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
8196 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
8197 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
8200 phba->sli4_hba.u.if_type2.EQDregaddr = in lpfc_sli4_bar0_register_memmap()
8201 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8203 phba->sli4_hba.u.if_type2.ERR1regaddr = in lpfc_sli4_bar0_register_memmap()
8204 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8206 phba->sli4_hba.u.if_type2.ERR2regaddr = in lpfc_sli4_bar0_register_memmap()
8207 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8209 phba->sli4_hba.u.if_type2.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
8210 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8212 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
8213 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8215 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
8216 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8218 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
8219 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
8223 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_bar0_register_memmap()
8224 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar0_register_memmap()
8231 * lpfc_sli4_bar1_register_memmap - Set up SLI4 BAR1 register memory map.
8242 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar1_register_memmap()
8243 phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8245 phba->sli4_hba.ISRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8247 phba->sli4_hba.IMRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8249 phba->sli4_hba.ISCRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8253 phba->sli4_hba.RQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8255 phba->sli4_hba.WQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8257 phba->sli4_hba.CQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8259 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8261 phba->sli4_hba.MQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8267 dev_err(&phba->pcidev->dev, in lpfc_sli4_bar1_register_memmap()
8268 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar1_register_memmap()
8275 * lpfc_sli4_bar2_register_memmap - Set up SLI4 BAR2 register memory map.
8282 * Return 0 if successful, otherwise -ENODEV.
8288 return -ENODEV; in lpfc_sli4_bar2_register_memmap()
8290 phba->sli4_hba.RQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8293 phba->sli4_hba.WQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8296 phba->sli4_hba.CQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8299 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar2_register_memmap()
8300 phba->sli4_hba.MQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8302 phba->sli4_hba.BMBXregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8308 * lpfc_create_bootstrap_mbox - Create the bootstrap mailbox
8312 * region consistent with the SLI-4 interface spec. This
8319 * 0 - successful
8320 * -ENOMEM - could not allocated memory.
8333 return -ENOMEM; in lpfc_create_bootstrap_mbox()
8339 bmbx_size = sizeof(struct lpfc_bmbx_create) + (LPFC_ALIGN_16_BYTE - 1); in lpfc_create_bootstrap_mbox()
8340 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, bmbx_size, in lpfc_create_bootstrap_mbox()
8341 &dmabuf->phys, GFP_KERNEL); in lpfc_create_bootstrap_mbox()
8342 if (!dmabuf->virt) { in lpfc_create_bootstrap_mbox()
8344 return -ENOMEM; in lpfc_create_bootstrap_mbox()
8350 * to be 16-byte aligned. Also align the virtual memory as each in lpfc_create_bootstrap_mbox()
8354 phba->sli4_hba.bmbx.dmabuf = dmabuf; in lpfc_create_bootstrap_mbox()
8355 phba->sli4_hba.bmbx.bmbx_size = bmbx_size; in lpfc_create_bootstrap_mbox()
8357 phba->sli4_hba.bmbx.avirt = PTR_ALIGN(dmabuf->virt, in lpfc_create_bootstrap_mbox()
8359 phba->sli4_hba.bmbx.aphys = ALIGN(dmabuf->phys, in lpfc_create_bootstrap_mbox()
8365 * as two 30-bit addresses. The other data is a bit marking whether in lpfc_create_bootstrap_mbox()
8366 * the 30-bit address is the high or low address. in lpfc_create_bootstrap_mbox()
8370 dma_address = &phba->sli4_hba.bmbx.dma_address; in lpfc_create_bootstrap_mbox()
8371 phys_addr = (uint64_t)phba->sli4_hba.bmbx.aphys; in lpfc_create_bootstrap_mbox()
8373 dma_address->addr_hi = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
8376 pa_addr = (uint32_t) ((phba->sli4_hba.bmbx.aphys >> 4) & 0x3fffffff); in lpfc_create_bootstrap_mbox()
8377 dma_address->addr_lo = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
8383 * lpfc_destroy_bootstrap_mbox - Destroy all bootstrap mailbox resources
8396 dma_free_coherent(&phba->pcidev->dev, in lpfc_destroy_bootstrap_mbox()
8397 phba->sli4_hba.bmbx.bmbx_size, in lpfc_destroy_bootstrap_mbox()
8398 phba->sli4_hba.bmbx.dmabuf->virt, in lpfc_destroy_bootstrap_mbox()
8399 phba->sli4_hba.bmbx.dmabuf->phys); in lpfc_destroy_bootstrap_mbox()
8401 kfree(phba->sli4_hba.bmbx.dmabuf); in lpfc_destroy_bootstrap_mbox()
8402 memset(&phba->sli4_hba.bmbx, 0, sizeof(struct lpfc_bmbx)); in lpfc_destroy_bootstrap_mbox()
8419 * lpfc_map_topology - Map the topology read from READ_CONFIG
8444 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
8447 /* FW supports persistent topology - override module parameter value */ in lpfc_map_topology()
8448 phba->hba_flag |= HBA_PERSISTENT_TOPO; in lpfc_map_topology()
8449 switch (phba->pcidev->device) { in lpfc_map_topology()
8453 phba->cfg_topology = ((pt == LINK_FLAGS_LOOP) in lpfc_map_topology()
8457 phba->hba_flag &= ~HBA_PERSISTENT_TOPO; in lpfc_map_topology()
8462 /* If topology failover set - pt is '0' or '1' */ in lpfc_map_topology()
8463 phba->cfg_topology = (pt ? FLAGS_TOPOLOGY_MODE_PT_LOOP : in lpfc_map_topology()
8466 phba->cfg_topology = ((pt == LINK_FLAGS_P2P) in lpfc_map_topology()
8472 if (phba->hba_flag & HBA_PERSISTENT_TOPO) { in lpfc_map_topology()
8475 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
8480 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
8485 * lpfc_sli4_read_config - Get the config parameters.
8494 * 0 - successful
8495 * -ENOMEM - No available memory
8496 * -EIO - The mailbox failed to complete successfully.
8512 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_read_config()
8517 return -ENOMEM; in lpfc_sli4_read_config()
8527 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
8528 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
8529 rc = -EIO; in lpfc_sli4_read_config()
8531 rd_config = &pmb->u.mqe.un.rd_config; in lpfc_sli4_read_config()
8533 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_VAL; in lpfc_sli4_read_config()
8534 phba->sli4_hba.lnk_info.lnk_tp = in lpfc_sli4_read_config()
8536 phba->sli4_hba.lnk_info.lnk_no = in lpfc_sli4_read_config()
8540 phba->sli4_hba.lnk_info.lnk_tp, in lpfc_sli4_read_config()
8541 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_read_config()
8545 bf_get(lpfc_mqe_command, &pmb->u.mqe)); in lpfc_sli4_read_config()
8547 phba->bbcredit_support = 1; in lpfc_sli4_read_config()
8548 phba->sli4_hba.bbscn_params.word0 = rd_config->word8; in lpfc_sli4_read_config()
8551 phba->sli4_hba.conf_trunk = in lpfc_sli4_read_config()
8553 phba->sli4_hba.extents_in_use = in lpfc_sli4_read_config()
8555 phba->sli4_hba.max_cfg_param.max_xri = in lpfc_sli4_read_config()
8559 phba->sli4_hba.max_cfg_param.max_xri > 512) in lpfc_sli4_read_config()
8560 phba->sli4_hba.max_cfg_param.max_xri = 512; in lpfc_sli4_read_config()
8561 phba->sli4_hba.max_cfg_param.xri_base = in lpfc_sli4_read_config()
8563 phba->sli4_hba.max_cfg_param.max_vpi = in lpfc_sli4_read_config()
8566 if (phba->sli4_hba.max_cfg_param.max_vpi > LPFC_MAX_VPORTS) in lpfc_sli4_read_config()
8567 phba->sli4_hba.max_cfg_param.max_vpi = LPFC_MAX_VPORTS; in lpfc_sli4_read_config()
8568 phba->sli4_hba.max_cfg_param.vpi_base = in lpfc_sli4_read_config()
8570 phba->sli4_hba.max_cfg_param.max_rpi = in lpfc_sli4_read_config()
8572 phba->sli4_hba.max_cfg_param.rpi_base = in lpfc_sli4_read_config()
8574 phba->sli4_hba.max_cfg_param.max_vfi = in lpfc_sli4_read_config()
8576 phba->sli4_hba.max_cfg_param.vfi_base = in lpfc_sli4_read_config()
8578 phba->sli4_hba.max_cfg_param.max_fcfi = in lpfc_sli4_read_config()
8580 phba->sli4_hba.max_cfg_param.max_eq = in lpfc_sli4_read_config()
8582 phba->sli4_hba.max_cfg_param.max_rq = in lpfc_sli4_read_config()
8584 phba->sli4_hba.max_cfg_param.max_wq = in lpfc_sli4_read_config()
8586 phba->sli4_hba.max_cfg_param.max_cq = in lpfc_sli4_read_config()
8588 phba->lmt = bf_get(lpfc_mbx_rd_conf_lmt, rd_config); in lpfc_sli4_read_config()
8589 phba->sli4_hba.next_xri = phba->sli4_hba.max_cfg_param.xri_base; in lpfc_sli4_read_config()
8590 phba->vpi_base = phba->sli4_hba.max_cfg_param.vpi_base; in lpfc_sli4_read_config()
8591 phba->vfi_base = phba->sli4_hba.max_cfg_param.vfi_base; in lpfc_sli4_read_config()
8592 phba->max_vpi = (phba->sli4_hba.max_cfg_param.max_vpi > 0) ? in lpfc_sli4_read_config()
8593 (phba->sli4_hba.max_cfg_param.max_vpi - 1) : 0; in lpfc_sli4_read_config()
8594 phba->max_vports = phba->max_vpi; in lpfc_sli4_read_config()
8603 phba->sli4_hba.extents_in_use, in lpfc_sli4_read_config()
8604 phba->sli4_hba.max_cfg_param.xri_base, in lpfc_sli4_read_config()
8605 phba->sli4_hba.max_cfg_param.max_xri, in lpfc_sli4_read_config()
8606 phba->sli4_hba.max_cfg_param.vpi_base, in lpfc_sli4_read_config()
8607 phba->sli4_hba.max_cfg_param.max_vpi, in lpfc_sli4_read_config()
8608 phba->sli4_hba.max_cfg_param.vfi_base, in lpfc_sli4_read_config()
8609 phba->sli4_hba.max_cfg_param.max_vfi, in lpfc_sli4_read_config()
8610 phba->sli4_hba.max_cfg_param.rpi_base, in lpfc_sli4_read_config()
8611 phba->sli4_hba.max_cfg_param.max_rpi, in lpfc_sli4_read_config()
8612 phba->sli4_hba.max_cfg_param.max_fcfi, in lpfc_sli4_read_config()
8613 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
8614 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
8615 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
8616 phba->sli4_hba.max_cfg_param.max_rq, in lpfc_sli4_read_config()
8617 phba->lmt); in lpfc_sli4_read_config()
8623 qmin = phba->sli4_hba.max_cfg_param.max_wq; in lpfc_sli4_read_config()
8624 if (phba->sli4_hba.max_cfg_param.max_cq < qmin) in lpfc_sli4_read_config()
8625 qmin = phba->sli4_hba.max_cfg_param.max_cq; in lpfc_sli4_read_config()
8626 if (phba->sli4_hba.max_cfg_param.max_eq < qmin) in lpfc_sli4_read_config()
8627 qmin = phba->sli4_hba.max_cfg_param.max_eq; in lpfc_sli4_read_config()
8634 qmin -= 4; in lpfc_sli4_read_config()
8637 if ((phba->cfg_irq_chann > qmin) || in lpfc_sli4_read_config()
8638 (phba->cfg_hdw_queue > qmin)) { in lpfc_sli4_read_config()
8640 "2005 Reducing Queues - " in lpfc_sli4_read_config()
8644 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
8645 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
8646 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
8647 qmin, phba->cfg_irq_chann, in lpfc_sli4_read_config()
8648 phba->cfg_hdw_queue); in lpfc_sli4_read_config()
8650 if (phba->cfg_irq_chann > qmin) in lpfc_sli4_read_config()
8651 phba->cfg_irq_chann = qmin; in lpfc_sli4_read_config()
8652 if (phba->cfg_hdw_queue > qmin) in lpfc_sli4_read_config()
8653 phba->cfg_hdw_queue = qmin; in lpfc_sli4_read_config()
8661 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_read_config()
8666 phba->hba_flag |= HBA_FORCED_LINK_SPEED; in lpfc_sli4_read_config()
8670 phba->cfg_link_speed = in lpfc_sli4_read_config()
8674 phba->cfg_link_speed = in lpfc_sli4_read_config()
8678 phba->cfg_link_speed = in lpfc_sli4_read_config()
8682 phba->cfg_link_speed = in lpfc_sli4_read_config()
8686 phba->cfg_link_speed = in lpfc_sli4_read_config()
8690 phba->cfg_link_speed = in lpfc_sli4_read_config()
8694 phba->cfg_link_speed = in lpfc_sli4_read_config()
8698 phba->cfg_link_speed = in lpfc_sli4_read_config()
8702 phba->cfg_link_speed = in lpfc_sli4_read_config()
8711 phba->cfg_link_speed = in lpfc_sli4_read_config()
8718 length = phba->sli4_hba.max_cfg_param.max_xri - in lpfc_sli4_read_config()
8720 if (phba->cfg_hba_queue_depth > length) { in lpfc_sli4_read_config()
8723 phba->cfg_hba_queue_depth, length); in lpfc_sli4_read_config()
8724 phba->cfg_hba_queue_depth = length; in lpfc_sli4_read_config()
8727 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_read_config()
8732 length = (sizeof(struct lpfc_mbx_get_func_cfg) - in lpfc_sli4_read_config()
8740 &pmb->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_read_config()
8741 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_read_config()
8742 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_read_config()
8747 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
8748 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
8753 get_func_cfg = &pmb->u.mqe.un.get_func_cfg; in lpfc_sli4_read_config()
8755 pdesc_0 = (char *)&get_func_cfg->func_cfg.desc[0]; in lpfc_sli4_read_config()
8767 phba->sli4_hba.iov.pf_number = in lpfc_sli4_read_config()
8769 phba->sli4_hba.iov.vf_number = in lpfc_sli4_read_config()
8778 "vf_number:%d\n", phba->sli4_hba.iov.pf_number, in lpfc_sli4_read_config()
8779 phba->sli4_hba.iov.vf_number); in lpfc_sli4_read_config()
8787 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_read_config()
8792 * lpfc_setup_endian_order - Write endian order to an SLI4 if_type 0 port.
8795 * This routine is invoked to setup the port-side endian order when
8800 * 0 - successful
8801 * -ENOMEM - No available memory
8802 * -EIO - The mailbox failed to complete successfully.
8812 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_setup_endian_order()
8815 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_setup_endian_order()
8822 return -ENOMEM; in lpfc_setup_endian_order()
8830 memcpy(&mboxq->u.mqe, &endian_mb_data, sizeof(endian_mb_data)); in lpfc_setup_endian_order()
8837 rc = -EIO; in lpfc_setup_endian_order()
8839 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_setup_endian_order()
8851 * lpfc_sli4_queue_verify - Verify and update EQ counts
8860 * 0 - successful
8861 * -ENOMEM - No available memory
8867 * Sanity check for configured queue parameters against the run-time in lpfc_sli4_queue_verify()
8871 if (phba->nvmet_support) { in lpfc_sli4_queue_verify()
8872 if (phba->cfg_hdw_queue < phba->cfg_nvmet_mrq) in lpfc_sli4_queue_verify()
8873 phba->cfg_nvmet_mrq = phba->cfg_hdw_queue; in lpfc_sli4_queue_verify()
8874 if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX) in lpfc_sli4_queue_verify()
8875 phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX; in lpfc_sli4_queue_verify()
8880 phba->cfg_hdw_queue, phba->cfg_irq_chann, in lpfc_sli4_queue_verify()
8881 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_verify()
8884 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_verify()
8885 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_verify()
8888 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_verify()
8889 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_verify()
8898 int cpu; in lpfc_alloc_io_wq_cq() local
8900 cpu = lpfc_find_cpu_handle(phba, idx, LPFC_FIND_BY_HDWQ); in lpfc_alloc_io_wq_cq()
8902 if (phba->enab_exp_wqcq_pages) in lpfc_alloc_io_wq_cq()
8905 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
8906 LPFC_CQE_EXP_COUNT, cpu); in lpfc_alloc_io_wq_cq()
8910 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
8911 phba->sli4_hba.cq_ecount, cpu); in lpfc_alloc_io_wq_cq()
8914 "0499 Failed allocate fast-path IO CQ (%d)\n", in lpfc_alloc_io_wq_cq()
8918 qdesc->qe_valid = 1; in lpfc_alloc_io_wq_cq()
8919 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
8920 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
8921 phba->sli4_hba.hdwq[idx].io_cq = qdesc; in lpfc_alloc_io_wq_cq()
8924 if (phba->enab_exp_wqcq_pages) { in lpfc_alloc_io_wq_cq()
8926 wqesize = (phba->fcp_embed_io) ? in lpfc_alloc_io_wq_cq()
8927 LPFC_WQE128_SIZE : phba->sli4_hba.wq_esize; in lpfc_alloc_io_wq_cq()
8930 LPFC_WQE_EXP_COUNT, cpu); in lpfc_alloc_io_wq_cq()
8933 phba->sli4_hba.wq_esize, in lpfc_alloc_io_wq_cq()
8934 phba->sli4_hba.wq_ecount, cpu); in lpfc_alloc_io_wq_cq()
8938 "0503 Failed allocate fast-path IO WQ (%d)\n", in lpfc_alloc_io_wq_cq()
8942 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
8943 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
8944 phba->sli4_hba.hdwq[idx].io_wq = qdesc; in lpfc_alloc_io_wq_cq()
8945 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_alloc_io_wq_cq()
8950 * lpfc_sli4_queue_create - Create all the SLI4 queues
8959 * 0 - successful
8960 * -ENOMEM - No availble memory
8961 * -EIO - The mailbox failed to complete successfully.
8967 int idx, cpu, eqcpu; in lpfc_sli4_queue_create() local
8977 phba->sli4_hba.mq_esize = LPFC_MQE_SIZE; in lpfc_sli4_queue_create()
8978 phba->sli4_hba.mq_ecount = LPFC_MQE_DEF_COUNT; in lpfc_sli4_queue_create()
8979 phba->sli4_hba.wq_esize = LPFC_WQE_SIZE; in lpfc_sli4_queue_create()
8980 phba->sli4_hba.wq_ecount = LPFC_WQE_DEF_COUNT; in lpfc_sli4_queue_create()
8981 phba->sli4_hba.rq_esize = LPFC_RQE_SIZE; in lpfc_sli4_queue_create()
8982 phba->sli4_hba.rq_ecount = LPFC_RQE_DEF_COUNT; in lpfc_sli4_queue_create()
8983 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_create()
8984 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_create()
8985 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_create()
8986 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_create()
8988 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
8989 phba->sli4_hba.hdwq = kcalloc( in lpfc_sli4_queue_create()
8990 phba->cfg_hdw_queue, sizeof(struct lpfc_sli4_hdw_queue), in lpfc_sli4_queue_create()
8992 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
8995 "fast-path Hardware Queue array\n"); in lpfc_sli4_queue_create()
8999 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
9000 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_queue_create()
9001 spin_lock_init(&qp->io_buf_list_get_lock); in lpfc_sli4_queue_create()
9002 spin_lock_init(&qp->io_buf_list_put_lock); in lpfc_sli4_queue_create()
9003 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_sli4_queue_create()
9004 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_sli4_queue_create()
9005 qp->get_io_bufs = 0; in lpfc_sli4_queue_create()
9006 qp->put_io_bufs = 0; in lpfc_sli4_queue_create()
9007 qp->total_io_bufs = 0; in lpfc_sli4_queue_create()
9008 spin_lock_init(&qp->abts_io_buf_list_lock); in lpfc_sli4_queue_create()
9009 INIT_LIST_HEAD(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_queue_create()
9010 qp->abts_scsi_io_bufs = 0; in lpfc_sli4_queue_create()
9011 qp->abts_nvme_io_bufs = 0; in lpfc_sli4_queue_create()
9012 INIT_LIST_HEAD(&qp->sgl_list); in lpfc_sli4_queue_create()
9013 INIT_LIST_HEAD(&qp->cmd_rsp_buf_list); in lpfc_sli4_queue_create()
9014 spin_lock_init(&qp->hdwq_lock); in lpfc_sli4_queue_create()
9018 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
9019 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
9020 phba->sli4_hba.nvmet_cqset = kcalloc( in lpfc_sli4_queue_create()
9021 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
9024 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_create()
9027 "fast-path CQ set array\n"); in lpfc_sli4_queue_create()
9030 phba->sli4_hba.nvmet_mrq_hdr = kcalloc( in lpfc_sli4_queue_create()
9031 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
9034 if (!phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_create()
9037 "fast-path RQ set hdr array\n"); in lpfc_sli4_queue_create()
9040 phba->sli4_hba.nvmet_mrq_data = kcalloc( in lpfc_sli4_queue_create()
9041 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
9044 if (!phba->sli4_hba.nvmet_mrq_data) { in lpfc_sli4_queue_create()
9047 "fast-path RQ set data array\n"); in lpfc_sli4_queue_create()
9053 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
9056 for_each_present_cpu(cpu) { in lpfc_sli4_queue_create()
9061 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
9062 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_create()
9065 /* Get a ptr to the Hardware Queue associated with this CPU */ in lpfc_sli4_queue_create()
9066 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
9070 phba->sli4_hba.eq_esize, in lpfc_sli4_queue_create()
9071 phba->sli4_hba.eq_ecount, cpu); in lpfc_sli4_queue_create()
9075 cpup->hdwq); in lpfc_sli4_queue_create()
9078 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
9079 qdesc->hdwq = cpup->hdwq; in lpfc_sli4_queue_create()
9080 qdesc->chann = cpu; /* First CPU this EQ is affinitized to */ in lpfc_sli4_queue_create()
9081 qdesc->last_cpu = qdesc->chann; in lpfc_sli4_queue_create()
9084 qp->hba_eq = qdesc; in lpfc_sli4_queue_create()
9086 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, qdesc->last_cpu); in lpfc_sli4_queue_create()
9087 list_add(&qdesc->cpu_list, &eqi->list); in lpfc_sli4_queue_create()
9093 for_each_present_cpu(cpu) { in lpfc_sli4_queue_create()
9094 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
9097 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_sli4_queue_create()
9101 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
9102 if (qp->hba_eq) in lpfc_sli4_queue_create()
9106 eqcpu = lpfc_find_cpu_handle(phba, cpup->eq, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
9107 eqcpup = &phba->sli4_hba.cpu_map[eqcpu]; in lpfc_sli4_queue_create()
9108 qp->hba_eq = phba->sli4_hba.hdwq[eqcpup->hdwq].hba_eq; in lpfc_sli4_queue_create()
9112 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
9117 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
9118 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
9119 cpu = lpfc_find_cpu_handle(phba, idx, in lpfc_sli4_queue_create()
9123 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
9124 phba->sli4_hba.cq_ecount, in lpfc_sli4_queue_create()
9125 cpu); in lpfc_sli4_queue_create()
9132 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
9133 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
9134 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9135 phba->sli4_hba.nvmet_cqset[idx] = qdesc; in lpfc_sli4_queue_create()
9143 cpu = lpfc_find_cpu_handle(phba, 0, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
9144 /* Create slow-path Mailbox Command Complete Queue */ in lpfc_sli4_queue_create()
9146 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
9147 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
9150 "0500 Failed allocate slow-path mailbox CQ\n"); in lpfc_sli4_queue_create()
9153 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
9154 phba->sli4_hba.mbx_cq = qdesc; in lpfc_sli4_queue_create()
9156 /* Create slow-path ELS Complete Queue */ in lpfc_sli4_queue_create()
9158 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
9159 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
9162 "0501 Failed allocate slow-path ELS CQ\n"); in lpfc_sli4_queue_create()
9165 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
9166 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9167 phba->sli4_hba.els_cq = qdesc; in lpfc_sli4_queue_create()
9177 phba->sli4_hba.mq_esize, in lpfc_sli4_queue_create()
9178 phba->sli4_hba.mq_ecount, cpu); in lpfc_sli4_queue_create()
9181 "0505 Failed allocate slow-path MQ\n"); in lpfc_sli4_queue_create()
9184 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9185 phba->sli4_hba.mbx_wq = qdesc; in lpfc_sli4_queue_create()
9191 /* Create slow-path ELS Work Queue */ in lpfc_sli4_queue_create()
9193 phba->sli4_hba.wq_esize, in lpfc_sli4_queue_create()
9194 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
9197 "0504 Failed allocate slow-path ELS WQ\n"); in lpfc_sli4_queue_create()
9200 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9201 phba->sli4_hba.els_wq = qdesc; in lpfc_sli4_queue_create()
9202 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
9204 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
9207 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
9208 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
9214 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9215 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
9216 phba->sli4_hba.nvmels_cq = qdesc; in lpfc_sli4_queue_create()
9220 phba->sli4_hba.wq_esize, in lpfc_sli4_queue_create()
9221 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
9227 qdesc->chann = cpu; in lpfc_sli4_queue_create()
9228 phba->sli4_hba.nvmels_wq = qdesc; in lpfc_sli4_queue_create()
9229 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
9238 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
9239 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
9245 phba->sli4_hba.hdr_rq = qdesc; in lpfc_sli4_queue_create()
9249 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
9250 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
9256 phba->sli4_hba.dat_rq = qdesc; in lpfc_sli4_queue_create()
9258 if ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) && in lpfc_sli4_queue_create()
9259 phba->nvmet_support) { in lpfc_sli4_queue_create()
9260 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
9261 cpu = lpfc_find_cpu_handle(phba, idx, in lpfc_sli4_queue_create()
9266 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
9268 cpu); in lpfc_sli4_queue_create()
9275 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
9276 phba->sli4_hba.nvmet_mrq_hdr[idx] = qdesc; in lpfc_sli4_queue_create()
9279 qdesc->rqbp = kzalloc_node(sizeof(*qdesc->rqbp), in lpfc_sli4_queue_create()
9281 cpu_to_node(cpu)); in lpfc_sli4_queue_create()
9282 if (qdesc->rqbp == NULL) { in lpfc_sli4_queue_create()
9290 INIT_LIST_HEAD(&qdesc->rqbp->rqb_buffer_list); in lpfc_sli4_queue_create()
9295 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
9297 cpu); in lpfc_sli4_queue_create()
9304 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
9305 phba->sli4_hba.nvmet_mrq_data[idx] = qdesc; in lpfc_sli4_queue_create()
9310 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
9311 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
9312 memset(&phba->sli4_hba.hdwq[idx].nvme_cstat, 0, in lpfc_sli4_queue_create()
9313 sizeof(phba->sli4_hba.hdwq[idx].nvme_cstat)); in lpfc_sli4_queue_create()
9318 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { in lpfc_sli4_queue_create()
9319 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
9320 memset(&phba->sli4_hba.hdwq[idx].scsi_cstat, 0, in lpfc_sli4_queue_create()
9321 sizeof(phba->sli4_hba.hdwq[idx].scsi_cstat)); in lpfc_sli4_queue_create()
9329 return -ENOMEM; in lpfc_sli4_queue_create()
9363 hdwq = phba->sli4_hba.hdwq; in lpfc_sli4_release_hdwq()
9366 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_release_hdwq()
9373 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_release_hdwq()
9378 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_release_hdwq()
9380 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_sli4_release_hdwq()
9382 phba->sli4_hba.hba_eq_hdl[idx].eq = NULL; in lpfc_sli4_release_hdwq()
9387 * lpfc_sli4_queue_destroy - Destroy all the SLI4 queues
9394 * 0 - successful
9395 * -ENOMEM - No available memory
9396 * -EIO - The mailbox failed to complete successfully.
9406 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9407 phba->sli.sli_flag |= LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
9408 while (phba->sli.sli_flag & LPFC_QUEUE_FREE_WAIT) { in lpfc_sli4_queue_destroy()
9409 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9411 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9413 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9418 if (phba->sli4_hba.hdwq) in lpfc_sli4_queue_destroy()
9421 if (phba->nvmet_support) { in lpfc_sli4_queue_destroy()
9422 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_destroy()
9423 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
9425 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_destroy()
9426 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
9427 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_destroy()
9428 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
9432 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_destroy()
9435 __lpfc_sli4_release_queue(&phba->sli4_hba.els_wq); in lpfc_sli4_queue_destroy()
9438 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_destroy()
9441 __lpfc_sli4_release_queue(&phba->sli4_hba.hdr_rq); in lpfc_sli4_queue_destroy()
9442 __lpfc_sli4_release_queue(&phba->sli4_hba.dat_rq); in lpfc_sli4_queue_destroy()
9445 __lpfc_sli4_release_queue(&phba->sli4_hba.els_cq); in lpfc_sli4_queue_destroy()
9448 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_destroy()
9451 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_destroy()
9454 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_destroy()
9457 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9458 phba->sli.sli_flag &= ~LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
9459 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9469 rqbp = rq->rqbp; in lpfc_free_rq_buffer()
9470 while (!list_empty(&rqbp->rqb_buffer_list)) { in lpfc_free_rq_buffer()
9471 list_remove_head(&rqbp->rqb_buffer_list, h_buf, in lpfc_free_rq_buffer()
9475 (rqbp->rqb_free_buffer)(phba, rqb_buffer); in lpfc_free_rq_buffer()
9476 rqbp->buffer_count--; in lpfc_free_rq_buffer()
9491 "6085 Fast-path %s (%d) not allocated\n", in lpfc_create_wq_cq()
9493 return -ENOMEM; in lpfc_create_wq_cq()
9509 *cq_map = cq->queue_id; in lpfc_create_wq_cq()
9512 "6087 CQ setup: cq[%d]-id=%d, parent eq[%d]-id=%d\n", in lpfc_create_wq_cq()
9513 qidx, cq->queue_id, qidx, eq->queue_id); in lpfc_create_wq_cq()
9521 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
9526 pring = wq->pring; in lpfc_create_wq_cq()
9527 pring->sli.sli4.wqp = (void *)wq; in lpfc_create_wq_cq()
9528 cq->pring = pring; in lpfc_create_wq_cq()
9531 "2593 WQ setup: wq[%d]-id=%d assoc=%d, cq[%d]-id=%d\n", in lpfc_create_wq_cq()
9532 qidx, wq->queue_id, wq->assoc_qid, qidx, cq->queue_id); in lpfc_create_wq_cq()
9537 "0539 Failed setup of slow-path MQ: " in lpfc_create_wq_cq()
9539 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
9544 "2589 MBX MQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_create_wq_cq()
9545 phba->sli4_hba.mbx_wq->queue_id, in lpfc_create_wq_cq()
9546 phba->sli4_hba.mbx_cq->queue_id); in lpfc_create_wq_cq()
9553 * lpfc_setup_cq_lookup - Setup the CQ lookup table
9565 memset(phba->sli4_hba.cq_lookup, 0, in lpfc_setup_cq_lookup()
9566 (sizeof(struct lpfc_queue *) * (phba->sli4_hba.cq_max + 1))); in lpfc_setup_cq_lookup()
9568 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_setup_cq_lookup()
9570 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_setup_cq_lookup()
9574 list_for_each_entry(childq, &eq->child_list, list) { in lpfc_setup_cq_lookup()
9575 if (childq->queue_id > phba->sli4_hba.cq_max) in lpfc_setup_cq_lookup()
9577 if (childq->subtype == LPFC_IO) in lpfc_setup_cq_lookup()
9578 phba->sli4_hba.cq_lookup[childq->queue_id] = in lpfc_setup_cq_lookup()
9585 * lpfc_sli4_queue_setup - Set up all the SLI4 queues
9592 * 0 - successful
9593 * -ENOMEM - No available memory
9594 * -EIO - The mailbox failed to complete successfully.
9604 int qidx, cpu; in lpfc_sli4_queue_setup() local
9606 int rc = -ENOMEM; in lpfc_sli4_queue_setup()
9608 /* Check for dual-ULP support */ in lpfc_sli4_queue_setup()
9609 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_queue_setup()
9614 return -ENOMEM; in lpfc_sli4_queue_setup()
9616 length = (sizeof(struct lpfc_mbx_query_fw_config) - in lpfc_sli4_queue_setup()
9625 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_queue_setup()
9626 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_queue_setup()
9627 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_queue_setup()
9634 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
9635 rc = -ENXIO; in lpfc_sli4_queue_setup()
9639 phba->sli4_hba.fw_func_mode = in lpfc_sli4_queue_setup()
9640 mboxq->u.mqe.un.query_fw_cfg.rsp.function_mode; in lpfc_sli4_queue_setup()
9641 phba->sli4_hba.ulp0_mode = mboxq->u.mqe.un.query_fw_cfg.rsp.ulp0_mode; in lpfc_sli4_queue_setup()
9642 phba->sli4_hba.ulp1_mode = mboxq->u.mqe.un.query_fw_cfg.rsp.ulp1_mode; in lpfc_sli4_queue_setup()
9643 phba->sli4_hba.physical_port = in lpfc_sli4_queue_setup()
9644 mboxq->u.mqe.un.query_fw_cfg.rsp.physical_port; in lpfc_sli4_queue_setup()
9647 "ulp1_mode:x%x\n", phba->sli4_hba.fw_func_mode, in lpfc_sli4_queue_setup()
9648 phba->sli4_hba.ulp0_mode, phba->sli4_hba.ulp1_mode); in lpfc_sli4_queue_setup()
9651 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
9656 qp = phba->sli4_hba.hdwq; in lpfc_sli4_queue_setup()
9661 "3147 Fast-path EQs not allocated\n"); in lpfc_sli4_queue_setup()
9662 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9667 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_setup()
9669 for_each_present_cpu(cpu) { in lpfc_sli4_queue_setup()
9670 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
9672 /* Look for the CPU thats using that vector with in lpfc_sli4_queue_setup()
9675 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_setup()
9677 if (qidx != cpup->eq) in lpfc_sli4_queue_setup()
9681 rc = lpfc_eq_create(phba, qp[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
9682 phba->cfg_fcp_imax); in lpfc_sli4_queue_setup()
9685 "0523 Failed setup of fast-path" in lpfc_sli4_queue_setup()
9687 cpup->eq, (uint32_t)rc); in lpfc_sli4_queue_setup()
9692 phba->sli4_hba.hba_eq_hdl[cpup->eq].eq = in lpfc_sli4_queue_setup()
9693 qp[cpup->hdwq].hba_eq; in lpfc_sli4_queue_setup()
9696 "2584 HBA EQ setup: queue[%d]-id=%d\n", in lpfc_sli4_queue_setup()
9697 cpup->eq, in lpfc_sli4_queue_setup()
9698 qp[cpup->hdwq].hba_eq->queue_id); in lpfc_sli4_queue_setup()
9703 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_setup()
9704 cpu = lpfc_find_cpu_handle(phba, qidx, LPFC_FIND_BY_HDWQ); in lpfc_sli4_queue_setup()
9705 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
9709 phba->sli4_hba.hdwq[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
9712 &phba->sli4_hba.hdwq[qidx].io_cq_map, in lpfc_sli4_queue_setup()
9728 /* Set up slow-path MBOX CQ/MQ */ in lpfc_sli4_queue_setup()
9730 if (!phba->sli4_hba.mbx_cq || !phba->sli4_hba.mbx_wq) { in lpfc_sli4_queue_setup()
9733 phba->sli4_hba.mbx_cq ? in lpfc_sli4_queue_setup()
9735 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9740 phba->sli4_hba.mbx_cq, in lpfc_sli4_queue_setup()
9741 phba->sli4_hba.mbx_wq, in lpfc_sli4_queue_setup()
9749 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
9750 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_setup()
9752 "3165 Fast-path NVME CQ Set " in lpfc_sli4_queue_setup()
9754 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9757 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
9759 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
9771 rc = lpfc_cq_create(phba, phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
9780 phba->sli4_hba.nvmet_cqset[0]->chann = 0; in lpfc_sli4_queue_setup()
9783 "6090 NVMET CQ setup: cq-id=%d, " in lpfc_sli4_queue_setup()
9784 "parent eq-id=%d\n", in lpfc_sli4_queue_setup()
9785 phba->sli4_hba.nvmet_cqset[0]->queue_id, in lpfc_sli4_queue_setup()
9786 qp[0].hba_eq->queue_id); in lpfc_sli4_queue_setup()
9790 /* Set up slow-path ELS WQ/CQ */ in lpfc_sli4_queue_setup()
9791 if (!phba->sli4_hba.els_cq || !phba->sli4_hba.els_wq) { in lpfc_sli4_queue_setup()
9794 phba->sli4_hba.els_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
9795 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9799 phba->sli4_hba.els_cq, in lpfc_sli4_queue_setup()
9800 phba->sli4_hba.els_wq, in lpfc_sli4_queue_setup()
9809 "2590 ELS WQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_sli4_queue_setup()
9810 phba->sli4_hba.els_wq->queue_id, in lpfc_sli4_queue_setup()
9811 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
9813 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_setup()
9815 if (!phba->sli4_hba.nvmels_cq || !phba->sli4_hba.nvmels_wq) { in lpfc_sli4_queue_setup()
9818 phba->sli4_hba.nvmels_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
9819 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9823 phba->sli4_hba.nvmels_cq, in lpfc_sli4_queue_setup()
9824 phba->sli4_hba.nvmels_wq, in lpfc_sli4_queue_setup()
9834 "6096 ELS WQ setup: wq-id=%d, " in lpfc_sli4_queue_setup()
9835 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
9836 phba->sli4_hba.nvmels_wq->queue_id, in lpfc_sli4_queue_setup()
9837 phba->sli4_hba.nvmels_cq->queue_id); in lpfc_sli4_queue_setup()
9843 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
9844 if ((!phba->sli4_hba.nvmet_cqset) || in lpfc_sli4_queue_setup()
9845 (!phba->sli4_hba.nvmet_mrq_hdr) || in lpfc_sli4_queue_setup()
9846 (!phba->sli4_hba.nvmet_mrq_data)) { in lpfc_sli4_queue_setup()
9850 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9853 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
9855 phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_setup()
9856 phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_setup()
9857 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
9869 phba->sli4_hba.nvmet_mrq_hdr[0], in lpfc_sli4_queue_setup()
9870 phba->sli4_hba.nvmet_mrq_data[0], in lpfc_sli4_queue_setup()
9871 phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
9883 "6099 NVMET RQ setup: hdr-rq-id=%d, " in lpfc_sli4_queue_setup()
9884 "dat-rq-id=%d parent cq-id=%d\n", in lpfc_sli4_queue_setup()
9885 phba->sli4_hba.nvmet_mrq_hdr[0]->queue_id, in lpfc_sli4_queue_setup()
9886 phba->sli4_hba.nvmet_mrq_data[0]->queue_id, in lpfc_sli4_queue_setup()
9887 phba->sli4_hba.nvmet_cqset[0]->queue_id); in lpfc_sli4_queue_setup()
9892 if (!phba->sli4_hba.hdr_rq || !phba->sli4_hba.dat_rq) { in lpfc_sli4_queue_setup()
9895 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9899 rc = lpfc_rq_create(phba, phba->sli4_hba.hdr_rq, phba->sli4_hba.dat_rq, in lpfc_sli4_queue_setup()
9900 phba->sli4_hba.els_cq, LPFC_USOL); in lpfc_sli4_queue_setup()
9909 "2592 USL RQ setup: hdr-rq-id=%d, dat-rq-id=%d " in lpfc_sli4_queue_setup()
9910 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
9911 phba->sli4_hba.hdr_rq->queue_id, in lpfc_sli4_queue_setup()
9912 phba->sli4_hba.dat_rq->queue_id, in lpfc_sli4_queue_setup()
9913 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
9915 if (phba->cfg_fcp_imax) in lpfc_sli4_queue_setup()
9916 usdelay = LPFC_SEC_TO_USEC / phba->cfg_fcp_imax; in lpfc_sli4_queue_setup()
9920 for (qidx = 0; qidx < phba->cfg_irq_chann; in lpfc_sli4_queue_setup()
9925 if (phba->sli4_hba.cq_max) { in lpfc_sli4_queue_setup()
9926 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_setup()
9927 phba->sli4_hba.cq_lookup = kcalloc((phba->sli4_hba.cq_max + 1), in lpfc_sli4_queue_setup()
9929 if (!phba->sli4_hba.cq_lookup) { in lpfc_sli4_queue_setup()
9932 "size 0x%x\n", phba->sli4_hba.cq_max); in lpfc_sli4_queue_setup()
9933 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9947 * lpfc_sli4_queue_unset - Unset all the SLI4 queues
9954 * 0 - successful
9955 * -ENOMEM - No available memory
9956 * -EIO - The mailbox failed to complete successfully.
9966 if (phba->sli4_hba.mbx_wq) in lpfc_sli4_queue_unset()
9967 lpfc_mq_destroy(phba, phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_unset()
9970 if (phba->sli4_hba.nvmels_wq) in lpfc_sli4_queue_unset()
9971 lpfc_wq_destroy(phba, phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_unset()
9974 if (phba->sli4_hba.els_wq) in lpfc_sli4_queue_unset()
9975 lpfc_wq_destroy(phba, phba->sli4_hba.els_wq); in lpfc_sli4_queue_unset()
9978 if (phba->sli4_hba.hdr_rq) in lpfc_sli4_queue_unset()
9979 lpfc_rq_destroy(phba, phba->sli4_hba.hdr_rq, in lpfc_sli4_queue_unset()
9980 phba->sli4_hba.dat_rq); in lpfc_sli4_queue_unset()
9983 if (phba->sli4_hba.mbx_cq) in lpfc_sli4_queue_unset()
9984 lpfc_cq_destroy(phba, phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_unset()
9987 if (phba->sli4_hba.els_cq) in lpfc_sli4_queue_unset()
9988 lpfc_cq_destroy(phba, phba->sli4_hba.els_cq); in lpfc_sli4_queue_unset()
9991 if (phba->sli4_hba.nvmels_cq) in lpfc_sli4_queue_unset()
9992 lpfc_cq_destroy(phba, phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_unset()
9994 if (phba->nvmet_support) { in lpfc_sli4_queue_unset()
9996 if (phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_unset()
9997 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
10000 phba->sli4_hba.nvmet_mrq_hdr[qidx], in lpfc_sli4_queue_unset()
10001 phba->sli4_hba.nvmet_mrq_data[qidx]); in lpfc_sli4_queue_unset()
10005 if (phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_unset()
10006 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
10008 phba, phba->sli4_hba.nvmet_cqset[qidx]); in lpfc_sli4_queue_unset()
10012 /* Unset fast-path SLI4 queues */ in lpfc_sli4_queue_unset()
10013 if (phba->sli4_hba.hdwq) { in lpfc_sli4_queue_unset()
10015 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_unset()
10017 qp = &phba->sli4_hba.hdwq[qidx]; in lpfc_sli4_queue_unset()
10018 lpfc_wq_destroy(phba, qp->io_wq); in lpfc_sli4_queue_unset()
10019 lpfc_cq_destroy(phba, qp->io_cq); in lpfc_sli4_queue_unset()
10022 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_unset()
10024 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_sli4_queue_unset()
10029 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_unset()
10030 phba->sli4_hba.cq_lookup = NULL; in lpfc_sli4_queue_unset()
10031 phba->sli4_hba.cq_max = 0; in lpfc_sli4_queue_unset()
10035 * lpfc_sli4_cq_event_pool_create - Create completion-queue event free pool
10042 * - Mailbox asynchronous events
10043 * - Receive queue completion unsolicited events
10044 * Later, this can be used for all the slow-path events.
10047 * 0 - successful
10048 * -ENOMEM - No available memory
10056 for (i = 0; i < (4 * phba->sli4_hba.cq_ecount); i++) { in lpfc_sli4_cq_event_pool_create()
10060 list_add_tail(&cq_event->list, in lpfc_sli4_cq_event_pool_create()
10061 &phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_cq_event_pool_create()
10067 return -ENOMEM; in lpfc_sli4_cq_event_pool_create()
10071 * lpfc_sli4_cq_event_pool_destroy - Free completion-queue event free pool
10076 * cleanup routine to free all the outstanding completion-queue events
10086 &phba->sli4_hba.sp_cqe_event_pool, list) { in lpfc_sli4_cq_event_pool_destroy()
10087 list_del(&cq_event->list); in lpfc_sli4_cq_event_pool_destroy()
10093 * __lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
10097 * completion-queue event from the free pool.
10099 * Return: Pointer to the newly allocated completion-queue event if successful
10107 list_remove_head(&phba->sli4_hba.sp_cqe_event_pool, cq_event, in __lpfc_sli4_cq_event_alloc()
10113 * lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
10117 * completion-queue event from the free pool.
10119 * Return: Pointer to the newly allocated completion-queue event if successful
10128 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
10130 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
10135 * __lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
10140 * completion-queue event back into the free pool.
10146 list_add_tail(&cq_event->list, &phba->sli4_hba.sp_cqe_event_pool); in __lpfc_sli4_cq_event_release()
10150 * lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
10155 * completion-queue event back into the free pool.
10162 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
10164 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
10168 * lpfc_sli4_cq_event_release_all - Release all cq events to the free pool
10171 * This routine is to free all the pending completion-queue events to the
10182 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release_all()
10184 list_splice_init(&phba->sli4_hba.sp_fcp_xri_aborted_work_queue, in lpfc_sli4_cq_event_release_all()
10187 list_splice_init(&phba->sli4_hba.sp_els_xri_aborted_work_queue, in lpfc_sli4_cq_event_release_all()
10190 list_splice_init(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_cq_event_release_all()
10192 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release_all()
10201 * lpfc_pci_function_reset - Reset pci function.
10208 * 0 - successful
10209 * -ENOMEM - No available memory
10210 * -EIO - The mailbox failed to complete successfully.
10224 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_pci_function_reset()
10227 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_pci_function_reset()
10234 return -ENOMEM; in lpfc_pci_function_reset()
10237 /* Setup PCI function reset mailbox-ioctl command */ in lpfc_pci_function_reset()
10243 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_pci_function_reset()
10244 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_pci_function_reset()
10246 &shdr->response); in lpfc_pci_function_reset()
10248 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_pci_function_reset()
10255 rc = -ENXIO; in lpfc_pci_function_reset()
10267 if (lpfc_readl(phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
10269 rc = -ENODEV; in lpfc_pci_function_reset()
10278 phba->work_status[0] = readl( in lpfc_pci_function_reset()
10279 phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_pci_function_reset()
10280 phba->work_status[1] = readl( in lpfc_pci_function_reset()
10281 phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_pci_function_reset()
10286 phba->work_status[0], in lpfc_pci_function_reset()
10287 phba->work_status[1]); in lpfc_pci_function_reset()
10288 rc = -ENODEV; in lpfc_pci_function_reset()
10301 writel(reg_data.word0, phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
10304 pci_read_config_word(phba->pcidev, in lpfc_pci_function_reset()
10311 rc = -ENODEV; in lpfc_pci_function_reset()
10322 /* Catch the not-ready port failure after a port reset. */ in lpfc_pci_function_reset()
10327 rc = -ENODEV; in lpfc_pci_function_reset()
10334 * lpfc_sli4_pci_mem_setup - Setup SLI4 HBA PCI memory space.
10338 * with SLI-4 interface spec.
10341 * 0 - successful
10342 * other values - error
10347 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_pci_mem_setup()
10353 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10356 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli4_pci_mem_setup()
10358 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli4_pci_mem_setup()
10367 &phba->sli4_hba.sli_intf.word0)) { in lpfc_sli4_pci_mem_setup()
10368 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10372 if (bf_get(lpfc_sli_intf_valid, &phba->sli4_hba.sli_intf) != in lpfc_sli4_pci_mem_setup()
10377 phba->sli4_hba.sli_intf.word0); in lpfc_sli4_pci_mem_setup()
10378 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10381 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_setup()
10389 phba->pci_bar0_map = pci_resource_start(pdev, PCI_64BIT_BAR0); in lpfc_sli4_pci_mem_setup()
10396 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10397 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
10398 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10399 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
10402 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10404 phba->pci_bar0_memmap_p = phba->sli4_hba.conf_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10408 phba->pci_bar0_map = pci_resource_start(pdev, 1); in lpfc_sli4_pci_mem_setup()
10411 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
10412 "FATAL - No BAR0 mapping for SLI4, if_type 2\n"); in lpfc_sli4_pci_mem_setup()
10413 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10415 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10416 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
10417 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10418 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
10421 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10432 phba->pci_bar1_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
10435 phba->sli4_hba.ctrl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10436 ioremap(phba->pci_bar1_map, in lpfc_sli4_pci_mem_setup()
10438 if (!phba->sli4_hba.ctrl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10439 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
10442 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10445 phba->pci_bar2_memmap_p = in lpfc_sli4_pci_mem_setup()
10446 phba->sli4_hba.ctrl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10449 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10460 phba->pci_bar1_map = pci_resource_start(pdev, PCI_64BIT_BAR2); in lpfc_sli4_pci_mem_setup()
10462 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10463 ioremap(phba->pci_bar1_map, bar1map_len); in lpfc_sli4_pci_mem_setup()
10464 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10465 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
10467 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10470 phba->pci_bar2_memmap_p = phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10480 phba->pci_bar2_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
10483 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10484 ioremap(phba->pci_bar2_map, in lpfc_sli4_pci_mem_setup()
10486 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10487 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
10490 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10493 phba->pci_bar4_memmap_p = in lpfc_sli4_pci_mem_setup()
10494 phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10499 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10510 phba->pci_bar2_map = pci_resource_start(pdev, PCI_64BIT_BAR4); in lpfc_sli4_pci_mem_setup()
10512 phba->sli4_hba.dpp_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10513 ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli4_pci_mem_setup()
10514 if (!phba->sli4_hba.dpp_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10515 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
10517 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10520 phba->pci_bar4_memmap_p = phba->sli4_hba.dpp_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10527 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
10528 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_write_eq_db; in lpfc_sli4_pci_mem_setup()
10529 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_write_cq_db; in lpfc_sli4_pci_mem_setup()
10532 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_if6_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
10533 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_if6_write_eq_db; in lpfc_sli4_pci_mem_setup()
10534 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_if6_write_cq_db; in lpfc_sli4_pci_mem_setup()
10543 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
10545 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
10547 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
10553 * lpfc_sli4_pci_mem_unset - Unset SLI4 HBA PCI memory space.
10557 * with SLI-4 interface spec.
10563 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_unset()
10567 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10568 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10569 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10572 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10575 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10576 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10577 if (phba->sli4_hba.dpp_regs_memmap_p) in lpfc_sli4_pci_mem_unset()
10578 iounmap(phba->sli4_hba.dpp_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10582 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_pci_mem_unset()
10583 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_pci_mem_unset()
10590 * lpfc_sli_enable_msix - Enable MSI-X interrupt mode on SLI-3 device
10593 * This routine is invoked to enable the MSI-X interrupt vectors to device
10594 * with SLI-3 interface specs.
10597 * 0 - successful
10598 * other values - error
10606 /* Set up MSI-X multi-message vectors */ in lpfc_sli_enable_msix()
10607 rc = pci_alloc_irq_vectors(phba->pcidev, in lpfc_sli_enable_msix()
10611 "0420 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli_enable_msix()
10616 * Assign MSI-X vectors to interrupt handlers in lpfc_sli_enable_msix()
10619 /* vector-0 is associated to slow-path handler */ in lpfc_sli_enable_msix()
10620 rc = request_irq(pci_irq_vector(phba->pcidev, 0), in lpfc_sli_enable_msix()
10625 "0421 MSI-X slow-path request_irq failed " in lpfc_sli_enable_msix()
10630 /* vector-1 is associated to fast-path handler */ in lpfc_sli_enable_msix()
10631 rc = request_irq(pci_irq_vector(phba->pcidev, 1), in lpfc_sli_enable_msix()
10637 "0429 MSI-X fast-path request_irq failed " in lpfc_sli_enable_msix()
10643 * Configure HBA MSI-X attention conditions to messages in lpfc_sli_enable_msix()
10645 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_enable_msix()
10648 rc = -ENOMEM; in lpfc_sli_enable_msix()
10662 pmb->u.mb.mbxCommand, pmb->u.mb.mbxStatus); in lpfc_sli_enable_msix()
10667 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
10672 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
10676 free_irq(pci_irq_vector(phba->pcidev, 1), phba); in lpfc_sli_enable_msix()
10680 free_irq(pci_irq_vector(phba->pcidev, 0), phba); in lpfc_sli_enable_msix()
10683 /* Unconfigure MSI-X capability structure */ in lpfc_sli_enable_msix()
10684 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_enable_msix()
10691 * lpfc_sli_enable_msi - Enable MSI interrupt mode on SLI-3 device.
10695 * SLI-3 interface spec. The kernel function pci_enable_msi() is called to
10701 * 0 - successful
10702 * other values - error
10709 rc = pci_enable_msi(phba->pcidev); in lpfc_sli_enable_msi()
10719 rc = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_msi()
10722 pci_disable_msi(phba->pcidev); in lpfc_sli_enable_msi()
10730 * lpfc_sli_enable_intr - Enable device interrupt to SLI-3 device.
10732 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
10735 * interrupt handler(s) to interrupt vector(s) to device with SLI-3 interface
10740 * MSI-X -> MSI -> IRQ.
10743 * 0 - successful
10744 * other values - error
10756 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli_enable_intr()
10759 /* Indicate initialization to MSI-X mode */ in lpfc_sli_enable_intr()
10760 phba->intr_type = MSIX; in lpfc_sli_enable_intr()
10766 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli_enable_intr()
10767 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli_enable_intr()
10771 phba->intr_type = MSI; in lpfc_sli_enable_intr()
10776 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli_enable_intr()
10777 if (phba->intr_type == NONE) { in lpfc_sli_enable_intr()
10778 retval = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_intr()
10782 phba->intr_type = INTx; in lpfc_sli_enable_intr()
10790 * lpfc_sli_disable_intr - Disable device interrupt to SLI-3 device.
10795 * SLI-3 interface spec. Depending on the interrupt mode, the driver will
10803 if (phba->intr_type == MSIX) in lpfc_sli_disable_intr()
10809 free_irq(pci_irq_vector(phba->pcidev, i), phba); in lpfc_sli_disable_intr()
10810 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_disable_intr()
10813 phba->intr_type = NONE; in lpfc_sli_disable_intr()
10814 phba->sli.slistat.sli_intr = 0; in lpfc_sli_disable_intr()
10818 * lpfc_find_cpu_handle - Find the CPU that corresponds to the specified Queue
10823 * Return the CPU that matches the selection criteria
10829 int cpu; in lpfc_find_cpu_handle() local
10832 for_each_present_cpu(cpu) { in lpfc_find_cpu_handle()
10833 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_find_cpu_handle()
10840 (cpup->flag & LPFC_CPU_FIRST_IRQ) && in lpfc_find_cpu_handle()
10841 (cpup->eq == id)) in lpfc_find_cpu_handle()
10842 return cpu; in lpfc_find_cpu_handle()
10844 /* If matching by HDWQ, select the first CPU that matches */ in lpfc_find_cpu_handle()
10845 if ((match == LPFC_FIND_BY_HDWQ) && (cpup->hdwq == id)) in lpfc_find_cpu_handle()
10846 return cpu; in lpfc_find_cpu_handle()
10853 * lpfc_find_hyper - Determine if the CPU map entry is hyper-threaded
10855 * @cpu: CPU map index
10856 * @phys_id: CPU package physical id
10857 * @core_id: CPU core id
10860 lpfc_find_hyper(struct lpfc_hba *phba, int cpu, in lpfc_find_hyper() argument
10867 cpup = &phba->sli4_hba.cpu_map[idx]; in lpfc_find_hyper()
10869 if ((cpup->phys_id == phys_id) && in lpfc_find_hyper()
10870 (cpup->core_id == core_id) && in lpfc_find_hyper()
10871 (cpu != idx)) in lpfc_find_hyper()
10879 * lpfc_assign_eq_map_info - Assigns eq for vector_map structure
10883 * @cpu: cpu used to index vector_map structure
10889 unsigned int cpu) in lpfc_assign_eq_map_info() argument
10891 struct lpfc_vector_map_info *cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_assign_eq_map_info()
10894 cpup->eq = eqidx; in lpfc_assign_eq_map_info()
10895 cpup->flag |= flag; in lpfc_assign_eq_map_info()
10898 "3336 Set Affinity: CPU %d irq %d eq %d flag x%x\n", in lpfc_assign_eq_map_info()
10899 cpu, eqhdl->irq, cpup->eq, cpup->flag); in lpfc_assign_eq_map_info()
10903 * lpfc_cpu_map_array_init - Initialize cpu_map structure
10913 int cpu; in lpfc_cpu_map_array_init() local
10915 for_each_possible_cpu(cpu) { in lpfc_cpu_map_array_init()
10916 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_map_array_init()
10917 cpup->phys_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
10918 cpup->core_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
10919 cpup->hdwq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
10920 cpup->eq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
10921 cpup->flag = 0; in lpfc_cpu_map_array_init()
10922 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, cpu); in lpfc_cpu_map_array_init()
10923 INIT_LIST_HEAD(&eqi->list); in lpfc_cpu_map_array_init()
10924 eqi->icnt = 0; in lpfc_cpu_map_array_init()
10929 * lpfc_hba_eq_hdl_array_init - Initialize hba_eq_hdl structure
10940 for (i = 0; i < phba->cfg_irq_chann; i++) { in lpfc_hba_eq_hdl_array_init()
10942 eqhdl->irq = LPFC_VECTOR_MAP_EMPTY; in lpfc_hba_eq_hdl_array_init()
10943 eqhdl->phba = phba; in lpfc_hba_eq_hdl_array_init()
10948 * lpfc_cpu_affinity_check - Check vector CPU affinity mappings
10952 * The routine will figure out the CPU affinity assignment for every
10953 * MSI-X vector allocated for the HBA.
10954 * In addition, the CPU to IO channel mapping will be calculated
10955 * and the phba->sli4_hba.cpu_map array will reflect this.
10960 int i, cpu, idx, next_idx, new_cpu, start_cpu, first_cpu; in lpfc_cpu_affinity_check() local
10977 /* Update CPU map with physical id and core id of each CPU */ in lpfc_cpu_affinity_check()
10978 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
10979 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
10981 cpuinfo = &cpu_data(cpu); in lpfc_cpu_affinity_check()
10982 cpup->phys_id = cpuinfo->phys_proc_id; in lpfc_cpu_affinity_check()
10983 cpup->core_id = cpuinfo->cpu_core_id; in lpfc_cpu_affinity_check()
10984 if (lpfc_find_hyper(phba, cpu, cpup->phys_id, cpup->core_id)) in lpfc_cpu_affinity_check()
10985 cpup->flag |= LPFC_CPU_MAP_HYPER; in lpfc_cpu_affinity_check()
10988 cpup->phys_id = 0; in lpfc_cpu_affinity_check()
10989 cpup->core_id = cpu; in lpfc_cpu_affinity_check()
10993 "3328 CPU %d physid %d coreid %d flag x%x\n", in lpfc_cpu_affinity_check()
10994 cpu, cpup->phys_id, cpup->core_id, cpup->flag); in lpfc_cpu_affinity_check()
10996 if (cpup->phys_id > max_phys_id) in lpfc_cpu_affinity_check()
10997 max_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
10998 if (cpup->phys_id < min_phys_id) in lpfc_cpu_affinity_check()
10999 min_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
11001 if (cpup->core_id > max_core_id) in lpfc_cpu_affinity_check()
11002 max_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
11003 if (cpup->core_id < min_core_id) in lpfc_cpu_affinity_check()
11004 min_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
11009 * Next we will set any unassigned (unaffinitized) cpu map in lpfc_cpu_affinity_check()
11015 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
11016 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
11018 /* Is this CPU entry unassigned */ in lpfc_cpu_affinity_check()
11019 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
11020 /* Mark CPU as IRQ not assigned by the kernel */ in lpfc_cpu_affinity_check()
11021 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
11029 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
11030 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
11031 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
11032 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY) && in lpfc_cpu_affinity_check()
11033 (new_cpup->phys_id == cpup->phys_id)) in lpfc_cpu_affinity_check()
11040 /* At this point, we leave the CPU as unassigned */ in lpfc_cpu_affinity_check()
11044 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
11047 * chance of having multiple unassigned CPU entries in lpfc_cpu_affinity_check()
11055 "3337 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
11056 "eq %d from peer cpu %d same " in lpfc_cpu_affinity_check()
11058 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
11059 cpup->phys_id); in lpfc_cpu_affinity_check()
11063 /* Set any unassigned cpu map entries to a IRQ on any phys_id */ in lpfc_cpu_affinity_check()
11066 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
11067 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
11070 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
11072 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
11080 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
11081 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
11082 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
11083 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY)) in lpfc_cpu_affinity_check()
11092 "3339 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
11094 cpup->hdwq, cpup->eq); in lpfc_cpu_affinity_check()
11098 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
11101 * chance of having multiple unassigned CPU entries in lpfc_cpu_affinity_check()
11109 "3338 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
11110 "eq %d from peer cpu %d (%d/%d)\n", in lpfc_cpu_affinity_check()
11111 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
11112 new_cpup->phys_id, new_cpup->core_id); in lpfc_cpu_affinity_check()
11120 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
11121 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
11124 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_cpu_affinity_check()
11128 cpup->hdwq = idx; in lpfc_cpu_affinity_check()
11131 "3333 Set Affinity: CPU %d (phys %d core %d): " in lpfc_cpu_affinity_check()
11133 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
11134 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
11137 * This will be 1 to 1 - hdwq to cpu, unless there are less in lpfc_cpu_affinity_check()
11138 * hardware queues then CPUs. For that case we will just round-robin in lpfc_cpu_affinity_check()
11141 * for irq_chann < hdwq. The idx is used for round-robin assignments in lpfc_cpu_affinity_check()
11147 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
11148 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
11151 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_cpu_affinity_check()
11158 if (next_idx < phba->cfg_hdw_queue) { in lpfc_cpu_affinity_check()
11159 cpup->hdwq = next_idx; in lpfc_cpu_affinity_check()
11164 /* Not a First CPU and all hdw_queues are used. Reuse a in lpfc_cpu_affinity_check()
11165 * Hardware Queue for another CPU, so be smart about it in lpfc_cpu_affinity_check()
11167 * (CPU package) and core_id. in lpfc_cpu_affinity_check()
11170 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
11171 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
11172 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
11173 new_cpup->phys_id == cpup->phys_id && in lpfc_cpu_affinity_check()
11174 new_cpup->core_id == cpup->core_id) { in lpfc_cpu_affinity_check()
11186 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
11187 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
11188 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
11189 new_cpup->phys_id == cpup->phys_id) in lpfc_cpu_affinity_check()
11198 cpup->hdwq = idx % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
11206 cpup->hdwq = new_cpup->hdwq; in lpfc_cpu_affinity_check()
11209 "3335 Set Affinity: CPU %d (phys %d core %d): " in lpfc_cpu_affinity_check()
11211 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
11212 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
11216 * Initialize the cpu_map slots for not-present cpus in case in lpfc_cpu_affinity_check()
11217 * a cpu is hot-added. Perform a simple hdwq round robin assignment. in lpfc_cpu_affinity_check()
11220 for_each_possible_cpu(cpu) { in lpfc_cpu_affinity_check()
11221 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
11223 c_stat = per_cpu_ptr(phba->sli4_hba.c_stat, cpu); in lpfc_cpu_affinity_check()
11224 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
11226 if (cpup->hdwq != LPFC_VECTOR_MAP_EMPTY) in lpfc_cpu_affinity_check()
11229 cpup->hdwq = idx++ % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
11231 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
11235 "CPU %d hdwq %d\n", in lpfc_cpu_affinity_check()
11236 cpu, cpup->hdwq); in lpfc_cpu_affinity_check()
11249 * @cpu: cpu going offline
11253 lpfc_cpuhp_get_eq(struct lpfc_hba *phba, unsigned int cpu, in lpfc_cpuhp_get_eq() argument
11263 return -ENOMEM; in lpfc_cpuhp_get_eq()
11265 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_cpuhp_get_eq()
11266 maskp = pci_irq_get_affinity(phba->pcidev, idx); in lpfc_cpuhp_get_eq()
11270 * if irq is not affinitized to the cpu going in lpfc_cpuhp_get_eq()
11274 if (!cpumask_and(tmp, maskp, cpumask_of(cpu))) in lpfc_cpuhp_get_eq()
11276 /* get the cpus that are online and are affini- in lpfc_cpuhp_get_eq()
11278 * more than 1 then cpuhp is not going to shut- in lpfc_cpuhp_get_eq()
11279 * down this vector. Since this cpu has not in lpfc_cpuhp_get_eq()
11291 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_cpuhp_get_eq()
11292 list_add(&eq->_poll_list, eqlist); in lpfc_cpuhp_get_eq()
11300 if (phba->sli_rev != LPFC_SLI_REV4) in __lpfc_cpuhp_remove()
11304 &phba->cpuhp); in __lpfc_cpuhp_remove()
11310 del_timer_sync(&phba->cpuhp_poll_timer); in __lpfc_cpuhp_remove()
11315 if (phba->pport->fc_flag & FC_OFFLINE_MODE) in lpfc_cpuhp_remove()
11323 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_cpuhp_add()
11328 if (!list_empty(&phba->poll_list)) in lpfc_cpuhp_add()
11329 mod_timer(&phba->cpuhp_poll_timer, in lpfc_cpuhp_add()
11335 &phba->cpuhp); in lpfc_cpuhp_add()
11340 if (phba->pport->load_flag & FC_UNLOADING) { in __lpfc_cpuhp_checks()
11341 *retval = -EAGAIN; in __lpfc_cpuhp_checks()
11345 if (phba->sli_rev != LPFC_SLI_REV4) { in __lpfc_cpuhp_checks()
11355 * lpfc_irq_set_aff - set IRQ affinity
11357 * @cpu: cpu to set affinity
11361 lpfc_irq_set_aff(struct lpfc_hba_eq_hdl *eqhdl, unsigned int cpu) in lpfc_irq_set_aff() argument
11363 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_set_aff()
11364 cpumask_set_cpu(cpu, &eqhdl->aff_mask); in lpfc_irq_set_aff()
11365 irq_set_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_set_aff()
11366 irq_set_affinity_hint(eqhdl->irq, &eqhdl->aff_mask); in lpfc_irq_set_aff()
11370 * lpfc_irq_clear_aff - clear IRQ affinity
11377 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_clear_aff()
11378 irq_clear_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_clear_aff()
11382 * lpfc_irq_rebalance - rebalances IRQ affinity according to cpuhp event
11384 * @cpu: cpu going offline/online
11385 * @offline: true, cpu is going offline. false, cpu is coming online.
11387 * If cpu is going offline, we'll try our best effort to find the next
11388 * online cpu on the phba's original_mask and migrate all offlining IRQ
11391 * If cpu is coming online, reaffinitize the IRQ back to the onlining cpu.
11394 * PCI_IRQ_AFFINITY to auto-manage IRQ affinity.
11398 lpfc_irq_rebalance(struct lpfc_hba *phba, unsigned int cpu, bool offline) in lpfc_irq_rebalance() argument
11405 if (phba->irq_chann_mode == NORMAL_MODE) in lpfc_irq_rebalance()
11408 orig_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_irq_rebalance()
11410 if (!cpumask_test_cpu(cpu, orig_mask)) in lpfc_irq_rebalance()
11413 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_irq_rebalance()
11415 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_irq_rebalance()
11419 /* Find next online CPU on original mask */ in lpfc_irq_rebalance()
11420 cpu_next = cpumask_next_wrap(cpu, orig_mask, cpu, true); in lpfc_irq_rebalance()
11423 /* Found a valid CPU */ in lpfc_irq_rebalance()
11424 if ((cpu_select < nr_cpu_ids) && (cpu_select != cpu)) { in lpfc_irq_rebalance()
11426 * cpu aff_mask is migrated in lpfc_irq_rebalance()
11428 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_irq_rebalance()
11432 if (cpumask_test_cpu(cpu, aff_mask)) in lpfc_irq_rebalance()
11438 for (idx = 0; idx < phba->cfg_irq_chann; idx++) in lpfc_irq_rebalance()
11442 /* Migrate affinity back to this CPU */ in lpfc_irq_rebalance()
11443 lpfc_irq_set_aff(lpfc_get_eq_hdl(cpup->eq), cpu); in lpfc_irq_rebalance()
11447 static int lpfc_cpu_offline(unsigned int cpu, struct hlist_node *node) in lpfc_cpu_offline() argument
11455 WARN_ONCE(!phba, "cpu: %u. phba:NULL", raw_smp_processor_id()); in lpfc_cpu_offline()
11462 lpfc_irq_rebalance(phba, cpu, true); in lpfc_cpu_offline()
11464 retval = lpfc_cpuhp_get_eq(phba, cpu, &eqlist); in lpfc_cpu_offline()
11470 list_del_init(&eq->_poll_list); in lpfc_cpu_offline()
11477 static int lpfc_cpu_online(unsigned int cpu, struct hlist_node *node) in lpfc_cpu_online() argument
11485 WARN_ONCE(!phba, "cpu: %u. phba:NULL", raw_smp_processor_id()); in lpfc_cpu_online()
11492 lpfc_irq_rebalance(phba, cpu, false); in lpfc_cpu_online()
11494 list_for_each_entry_safe(eq, next, &phba->poll_list, _poll_list) { in lpfc_cpu_online()
11495 n = lpfc_find_cpu_handle(phba, eq->hdwq, LPFC_FIND_BY_HDWQ); in lpfc_cpu_online()
11496 if (n == cpu) in lpfc_cpu_online()
11504 * lpfc_sli4_enable_msix - Enable MSI-X interrupt mode to SLI-4 device
11507 * This routine is invoked to enable the MSI-X interrupt vectors to device
11508 * with SLI-4 interface spec. It also allocates MSI-X vectors and maps them
11514 * allocated and assigned to each online and offline cpu. If the cpu is
11515 * online, then affinity will be set to that cpu. If the cpu is offline, then
11516 * affinity will be set to the nearest peer cpu within the numa node that is
11518 * assigned and the OS may do as it pleases. Note: cpu vector affinity mapping
11519 * is consistent with the way cpu online/offline is handled when cfg_irq_numa is
11524 * cpu affinity. The driver will then use that affinity mapping to setup its
11525 * cpu mapping table.
11528 * 0 - successful
11529 * other values - error
11537 unsigned int cpu = 0, cpu_cnt = 0, cpu_select = nr_cpu_ids; in lpfc_sli4_enable_msix() local
11543 /* Set up MSI-X multi-message vectors */ in lpfc_sli4_enable_msix()
11544 vectors = phba->cfg_irq_chann; in lpfc_sli4_enable_msix()
11546 if (phba->irq_chann_mode != NORMAL_MODE) in lpfc_sli4_enable_msix()
11547 aff_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_sli4_enable_msix()
11551 vectors = min(phba->cfg_irq_chann, cpu_cnt); in lpfc_sli4_enable_msix()
11553 /* cpu: iterates over aff_mask including offline or online in lpfc_sli4_enable_msix()
11556 cpu = cpumask_first(aff_mask); in lpfc_sli4_enable_msix()
11557 cpu_select = lpfc_next_online_cpu(aff_mask, cpu); in lpfc_sli4_enable_msix()
11562 rc = pci_alloc_irq_vectors(phba->pcidev, 1, vectors, flags); in lpfc_sli4_enable_msix()
11565 "0484 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli4_enable_msix()
11570 /* Assign MSI-X vectors to interrupt handlers */ in lpfc_sli4_enable_msix()
11573 name = eqhdl->handler_name; in lpfc_sli4_enable_msix()
11578 eqhdl->idx = index; in lpfc_sli4_enable_msix()
11579 rc = request_irq(pci_irq_vector(phba->pcidev, index), in lpfc_sli4_enable_msix()
11584 "0486 MSI-X fast-path (%d) " in lpfc_sli4_enable_msix()
11589 eqhdl->irq = pci_irq_vector(phba->pcidev, index); in lpfc_sli4_enable_msix()
11592 /* If found a neighboring online cpu, set affinity */ in lpfc_sli4_enable_msix()
11599 cpu); in lpfc_sli4_enable_msix()
11601 /* Iterate to next offline or online cpu in aff_mask */ in lpfc_sli4_enable_msix()
11602 cpu = cpumask_next(cpu, aff_mask); in lpfc_sli4_enable_msix()
11604 /* Find next online cpu in aff_mask to set affinity */ in lpfc_sli4_enable_msix()
11605 cpu_select = lpfc_next_online_cpu(aff_mask, cpu); in lpfc_sli4_enable_msix()
11607 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_msix()
11609 cpu); in lpfc_sli4_enable_msix()
11611 maskp = pci_irq_get_affinity(phba->pcidev, index); in lpfc_sli4_enable_msix()
11614 for_each_cpu_and(cpu, maskp, cpu_present_mask) { in lpfc_sli4_enable_msix()
11615 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_enable_msix()
11617 /* If this is the first CPU thats assigned to in lpfc_sli4_enable_msix()
11621 * vectors are affinitized to all the cpu's. in lpfc_sli4_enable_msix()
11629 if (cpup->eq != LPFC_VECTOR_MAP_EMPTY) in lpfc_sli4_enable_msix()
11633 cpu); in lpfc_sli4_enable_msix()
11639 if (vectors != phba->cfg_irq_chann) { in lpfc_sli4_enable_msix()
11642 "MSI-X vectors, requested %d got %d\n", in lpfc_sli4_enable_msix()
11643 phba->cfg_irq_chann, vectors); in lpfc_sli4_enable_msix()
11644 if (phba->cfg_irq_chann > vectors) in lpfc_sli4_enable_msix()
11645 phba->cfg_irq_chann = vectors; in lpfc_sli4_enable_msix()
11652 for (--index; index >= 0; index--) { in lpfc_sli4_enable_msix()
11655 irq_set_affinity_hint(eqhdl->irq, NULL); in lpfc_sli4_enable_msix()
11656 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_enable_msix()
11659 /* Unconfigure MSI-X capability structure */ in lpfc_sli4_enable_msix()
11660 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msix()
11667 * lpfc_sli4_enable_msi - Enable MSI interrupt mode to SLI-4 device
11671 * SLI-4 interface spec. The kernel function pci_alloc_irq_vectors() is
11677 * 0 - successful
11678 * other values - error
11684 unsigned int cpu; in lpfc_sli4_enable_msi() local
11687 rc = pci_alloc_irq_vectors(phba->pcidev, 1, 1, in lpfc_sli4_enable_msi()
11695 return rc ? rc : -1; in lpfc_sli4_enable_msi()
11698 rc = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_msi()
11701 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msi()
11708 eqhdl->irq = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_msi()
11710 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_msi()
11711 lpfc_assign_eq_map_info(phba, 0, LPFC_CPU_FIRST_IRQ, cpu); in lpfc_sli4_enable_msi()
11713 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_enable_msi()
11715 eqhdl->idx = index; in lpfc_sli4_enable_msi()
11722 * lpfc_sli4_enable_intr - Enable device interrupt to SLI-4 device
11724 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
11727 * interrupt handler(s) to interrupt vector(s) to device with SLI-4
11732 * MSI-X -> MSI -> IRQ.
11735 * 0 - successful
11736 * other values - error
11748 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli4_enable_intr()
11751 /* Indicate initialization to MSI-X mode */ in lpfc_sli4_enable_intr()
11752 phba->intr_type = MSIX; in lpfc_sli4_enable_intr()
11758 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli4_enable_intr()
11759 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
11763 phba->intr_type = MSI; in lpfc_sli4_enable_intr()
11768 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli4_enable_intr()
11769 if (phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
11770 retval = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_intr()
11774 unsigned int cpu; in lpfc_sli4_enable_intr() local
11777 phba->intr_type = INTx; in lpfc_sli4_enable_intr()
11781 eqhdl->irq = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_intr()
11783 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_intr()
11785 cpu); in lpfc_sli4_enable_intr()
11786 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_enable_intr()
11788 eqhdl->idx = idx; in lpfc_sli4_enable_intr()
11796 * lpfc_sli4_disable_intr - Disable device interrupt to SLI-4 device
11801 * with SLI-4 interface spec. Depending on the interrupt mode, the driver
11808 if (phba->intr_type == MSIX) { in lpfc_sli4_disable_intr()
11812 /* Free up MSI-X multi-message vectors */ in lpfc_sli4_disable_intr()
11813 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_disable_intr()
11816 irq_set_affinity_hint(eqhdl->irq, NULL); in lpfc_sli4_disable_intr()
11817 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_disable_intr()
11820 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_disable_intr()
11823 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_disable_intr()
11826 phba->intr_type = NONE; in lpfc_sli4_disable_intr()
11827 phba->sli.slistat.sli_intr = 0; in lpfc_sli4_disable_intr()
11831 * lpfc_unset_hba - Unset SLI3 hba device initialization
11835 * a device with SLI-3 interface spec.
11840 struct lpfc_vport *vport = phba->pport; in lpfc_unset_hba()
11843 spin_lock_irq(shost->host_lock); in lpfc_unset_hba()
11844 vport->load_flag |= FC_UNLOADING; in lpfc_unset_hba()
11845 spin_unlock_irq(shost->host_lock); in lpfc_unset_hba()
11847 kfree(phba->vpi_bmask); in lpfc_unset_hba()
11848 kfree(phba->vpi_ids); in lpfc_unset_hba()
11852 phba->pport->work_port_events = 0; in lpfc_unset_hba()
11864 * lpfc_sli4_xri_exchange_busy_wait - Wait for device XRI exchange busy
11884 int els_xri_cmpl = list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
11893 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_xri_exchange_busy_wait()
11897 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
11898 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
11899 io_xri_cmpl = list_empty(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
11906 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
11908 list_empty(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
11936 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
11937 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
11939 &qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
11946 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
11948 &phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
11951 list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
11957 * lpfc_sli4_hba_unset - Unset the fcoe hba
11971 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_hba_unset()
11974 if (phba->pport) in lpfc_sli4_hba_unset()
11975 phba->sli4_hba.intr_enable = 0; in lpfc_sli4_hba_unset()
11983 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
11984 phba->sli.sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_hba_unset()
11985 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
11987 while (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
11993 if (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
11994 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
11995 mboxq = phba->sli.mbox_active; in lpfc_sli4_hba_unset()
11996 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_hba_unset()
11998 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_hba_unset()
11999 phba->sli.mbox_active = NULL; in lpfc_sli4_hba_unset()
12000 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
12009 /* per-phba callback de-registration for hotplug event */ in lpfc_sli4_hba_unset()
12010 if (phba->pport) in lpfc_sli4_hba_unset()
12016 /* Disable SR-IOV if enabled */ in lpfc_sli4_hba_unset()
12017 if (phba->cfg_sriov_nr_virtfn) in lpfc_sli4_hba_unset()
12021 kthread_stop(phba->worker_thread); in lpfc_sli4_hba_unset()
12036 if (phba->ras_fwlog.ras_enabled) in lpfc_sli4_hba_unset()
12040 if (phba->pport) in lpfc_sli4_hba_unset()
12041 phba->pport->work_port_events = 0; in lpfc_sli4_hba_unset()
12045 * lpfc_pc_sli4_params_get - Get the SLI4_PARAMS port capabilities.
12052 * This function may be be called from any context that can block-wait
12065 mqe = &mboxq->u.mqe; in lpfc_pc_sli4_params_get()
12069 if (!phba->sli4_hba.intr_enable) in lpfc_pc_sli4_params_get()
12079 sli4_params = &phba->sli4_hba.pc_sli4_params; in lpfc_pc_sli4_params_get()
12080 sli4_params->if_type = bf_get(if_type, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12081 sli4_params->sli_rev = bf_get(sli_rev, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12082 sli4_params->sli_family = bf_get(sli_family, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12083 sli4_params->featurelevel_1 = bf_get(featurelevel_1, in lpfc_pc_sli4_params_get()
12084 &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12085 sli4_params->featurelevel_2 = bf_get(featurelevel_2, in lpfc_pc_sli4_params_get()
12086 &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12087 sli4_params->proto_types = mqe->un.sli4_params.word3; in lpfc_pc_sli4_params_get()
12088 sli4_params->sge_supp_len = mqe->un.sli4_params.sge_supp_len; in lpfc_pc_sli4_params_get()
12089 sli4_params->if_page_sz = bf_get(if_page_sz, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12090 sli4_params->rq_db_window = bf_get(rq_db_window, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12091 sli4_params->loopbk_scope = bf_get(loopbk_scope, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12092 sli4_params->eq_pages_max = bf_get(eq_pages, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12093 sli4_params->eqe_size = bf_get(eqe_size, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12094 sli4_params->cq_pages_max = bf_get(cq_pages, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12095 sli4_params->cqe_size = bf_get(cqe_size, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12096 sli4_params->mq_pages_max = bf_get(mq_pages, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12097 sli4_params->mqe_size = bf_get(mqe_size, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12098 sli4_params->mq_elem_cnt = bf_get(mq_elem_cnt, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12099 sli4_params->wq_pages_max = bf_get(wq_pages, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12100 sli4_params->wqe_size = bf_get(wqe_size, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12101 sli4_params->rq_pages_max = bf_get(rq_pages, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12102 sli4_params->rqe_size = bf_get(rqe_size, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12103 sli4_params->hdr_pages_max = bf_get(hdr_pages, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12104 sli4_params->hdr_size = bf_get(hdr_size, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12105 sli4_params->hdr_pp_align = bf_get(hdr_pp_align, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12106 sli4_params->sgl_pages_max = bf_get(sgl_pages, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12107 sli4_params->sgl_pp_align = bf_get(sgl_pp_align, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
12110 if (sli4_params->sge_supp_len > LPFC_MAX_SGE_SIZE) in lpfc_pc_sli4_params_get()
12111 sli4_params->sge_supp_len = LPFC_MAX_SGE_SIZE; in lpfc_pc_sli4_params_get()
12117 * lpfc_get_sli4_parameters - Get the SLI4 Config PARAMETERS.
12124 * This function may be be called from any context that can block-wait
12132 struct lpfc_mqe *mqe = &mboxq->u.mqe; in lpfc_get_sli4_parameters()
12144 phba->sli4_hba.rpi_hdrs_in_use = 1; in lpfc_get_sli4_parameters()
12147 length = (sizeof(struct lpfc_mbx_get_sli4_parameters) - in lpfc_get_sli4_parameters()
12152 if (!phba->sli4_hba.intr_enable) in lpfc_get_sli4_parameters()
12160 sli4_params = &phba->sli4_hba.pc_sli4_params; in lpfc_get_sli4_parameters()
12161 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters; in lpfc_get_sli4_parameters()
12162 sli4_params->if_type = bf_get(cfg_if_type, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12163 sli4_params->sli_rev = bf_get(cfg_sli_rev, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12164 sli4_params->sli_family = bf_get(cfg_sli_family, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12165 sli4_params->featurelevel_1 = bf_get(cfg_sli_hint_1, in lpfc_get_sli4_parameters()
12167 sli4_params->featurelevel_2 = bf_get(cfg_sli_hint_2, in lpfc_get_sli4_parameters()
12170 phba->sli3_options |= LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
12172 phba->sli3_options &= ~LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
12173 sli4_params->sge_supp_len = mbx_sli4_parameters->sge_supp_len; in lpfc_get_sli4_parameters()
12174 sli4_params->loopbk_scope = bf_get(loopbk_scope, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12175 sli4_params->oas_supported = bf_get(cfg_oas, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12176 sli4_params->cqv = bf_get(cfg_cqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12177 sli4_params->mqv = bf_get(cfg_mqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12178 sli4_params->wqv = bf_get(cfg_wqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12179 sli4_params->rqv = bf_get(cfg_rqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12180 sli4_params->eqav = bf_get(cfg_eqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12181 sli4_params->cqav = bf_get(cfg_cqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12182 sli4_params->wqsize = bf_get(cfg_wqsize, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12183 sli4_params->bv1s = bf_get(cfg_bv1s, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12184 sli4_params->pls = bf_get(cfg_pvl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12185 sli4_params->sgl_pages_max = bf_get(cfg_sgl_page_cnt, in lpfc_get_sli4_parameters()
12187 sli4_params->wqpcnt = bf_get(cfg_wqpcnt, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12188 sli4_params->sgl_pp_align = bf_get(cfg_sgl_pp_align, in lpfc_get_sli4_parameters()
12190 phba->sli4_hba.extents_in_use = bf_get(cfg_ext, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12191 phba->sli4_hba.rpi_hdrs_in_use = bf_get(cfg_hdrr, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12193 /* Check for Extended Pre-Registered SGL support */ in lpfc_get_sli4_parameters()
12194 phba->cfg_xpsgl = bf_get(cfg_xpsgl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
12202 sli4_params->nvme = 1; in lpfc_get_sli4_parameters()
12205 if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP) { in lpfc_get_sli4_parameters()
12209 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
12214 sli4_params->nvme = 0; in lpfc_get_sli4_parameters()
12215 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_get_sli4_parameters()
12221 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
12223 phba->nvme_support = 0; in lpfc_get_sli4_parameters()
12224 phba->nvmet_support = 0; in lpfc_get_sli4_parameters()
12225 phba->cfg_nvmet_mrq = 0; in lpfc_get_sli4_parameters()
12226 phba->cfg_nvme_seg_cnt = 0; in lpfc_get_sli4_parameters()
12229 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_get_sli4_parameters()
12230 return -ENODEV; in lpfc_get_sli4_parameters()
12231 phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; in lpfc_get_sli4_parameters()
12238 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_get_sli4_parameters()
12239 phba->cfg_sg_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_get_sli4_parameters()
12242 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) != in lpfc_get_sli4_parameters()
12244 phba->cfg_enable_pbde = 0; in lpfc_get_sli4_parameters()
12249 * In SLI4-Parameters Descriptor: in lpfc_get_sli4_parameters()
12254 if (phba->cfg_suppress_rsp && bf_get(cfg_xib, mbx_sli4_parameters) && in lpfc_get_sli4_parameters()
12256 phba->sli.sli_flag |= LPFC_SLI_SUPPRESS_RSP; in lpfc_get_sli4_parameters()
12258 phba->cfg_suppress_rsp = 0; in lpfc_get_sli4_parameters()
12261 phba->sli.sli_flag |= LPFC_SLI_USE_EQDR; in lpfc_get_sli4_parameters()
12264 if (sli4_params->sge_supp_len > LPFC_MAX_SGE_SIZE) in lpfc_get_sli4_parameters()
12265 sli4_params->sge_supp_len = LPFC_MAX_SGE_SIZE; in lpfc_get_sli4_parameters()
12270 * to use this option, 128-byte WQEs must be used. in lpfc_get_sli4_parameters()
12273 phba->fcp_embed_io = 1; in lpfc_get_sli4_parameters()
12275 phba->fcp_embed_io = 0; in lpfc_get_sli4_parameters()
12280 phba->cfg_enable_pbde, in lpfc_get_sli4_parameters()
12281 phba->fcp_embed_io, phba->nvme_support, in lpfc_get_sli4_parameters()
12282 phba->cfg_nvme_embed_cmd, phba->cfg_suppress_rsp); in lpfc_get_sli4_parameters()
12284 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
12286 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
12293 (sli4_params->wqsize & LPFC_WQ_SZ128_SUPPORT)) in lpfc_get_sli4_parameters()
12294 phba->enab_exp_wqcq_pages = 1; in lpfc_get_sli4_parameters()
12296 phba->enab_exp_wqcq_pages = 0; in lpfc_get_sli4_parameters()
12301 phba->mds_diags_support = 1; in lpfc_get_sli4_parameters()
12303 phba->mds_diags_support = 0; in lpfc_get_sli4_parameters()
12309 phba->nsler = 1; in lpfc_get_sli4_parameters()
12311 phba->nsler = 0; in lpfc_get_sli4_parameters()
12317 * lpfc_pci_probe_one_s3 - PCI probe func to reg SLI-3 device to PCI subsystem.
12321 * This routine is to be called to attach a device with SLI-3 interface spec
12322 * to the PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
12323 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
12330 * 0 - driver can claim the device
12331 * negative value - driver can not claim the device
12345 return -ENOMEM; in lpfc_pci_probe_one_s3()
12352 /* Set up SLI API function jump table for PCI-device group-0 HBAs */ in lpfc_pci_probe_one_s3()
12357 /* Set up SLI-3 specific device PCI memory space */ in lpfc_pci_probe_one_s3()
12365 /* Set up SLI-3 specific device driver resources */ in lpfc_pci_probe_one_s3()
12391 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s3()
12402 vport = phba->pport; in lpfc_pci_probe_one_s3()
12412 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s3()
12421 error = -ENODEV; in lpfc_pci_probe_one_s3()
12424 /* SLI-3 HBA setup */ in lpfc_pci_probe_one_s3()
12428 error = -ENODEV; in lpfc_pci_probe_one_s3()
12436 phba->sli.slistat.sli_intr > LPFC_MSIX_VECTORS) { in lpfc_pci_probe_one_s3()
12438 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s3()
12449 cfg_mode = --intr_mode; in lpfc_pci_probe_one_s3()
12485 * lpfc_pci_remove_one_s3 - PCI func to unreg SLI-3 device from PCI subsystem.
12488 * This routine is to be called to disattach a device with SLI-3 interface
12489 * spec from PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
12497 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s3()
12499 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s3()
12502 spin_lock_irq(&phba->hbalock); in lpfc_pci_remove_one_s3()
12503 vport->load_flag |= FC_UNLOADING; in lpfc_pci_remove_one_s3()
12504 spin_unlock_irq(&phba->hbalock); in lpfc_pci_remove_one_s3()
12511 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s3()
12512 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s3()
12514 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s3()
12533 kthread_stop(phba->worker_thread); in lpfc_pci_remove_one_s3()
12537 kfree(phba->vpi_bmask); in lpfc_pci_remove_one_s3()
12538 kfree(phba->vpi_ids); in lpfc_pci_remove_one_s3()
12541 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
12542 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s3()
12543 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
12547 /* Disable SR-IOV if enabled */ in lpfc_pci_remove_one_s3()
12548 if (phba->cfg_sriov_nr_virtfn) in lpfc_pci_remove_one_s3()
12565 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_pci_remove_one_s3()
12566 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_pci_remove_one_s3()
12569 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_pci_remove_one_s3()
12570 phba->slim2p.virt, phba->slim2p.phys); in lpfc_pci_remove_one_s3()
12573 iounmap(phba->ctrl_regs_memmap_p); in lpfc_pci_remove_one_s3()
12574 iounmap(phba->slim_memmap_p); in lpfc_pci_remove_one_s3()
12583 * lpfc_pci_suspend_one_s3 - PCI func to suspend SLI-3 device for power mgmnt
12588 * system Power Management (PM) to device with SLI-3 interface spec. When
12592 * minimum PM requirements to a power-aware driver's PM support for the
12593 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
12600 * 0 - driver suspended the device
12607 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s3()
12615 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s3()
12628 * lpfc_pci_resume_one_s3 - PCI func to resume SLI-3 device for power mgmnt
12632 * system Power Management (PM) to device with SLI-3 interface spec. When PM
12635 * driver implements the minimum PM requirements to a power-aware driver's
12636 * PM for suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE,
12643 * 0 - driver suspended the device
12650 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s3()
12667 if (pdev->is_busmaster) in lpfc_pci_resume_one_s3()
12671 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s3()
12672 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s3()
12673 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s3()
12674 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s3()
12682 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
12686 return -EIO; in lpfc_pci_resume_one_s3()
12688 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s3()
12695 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
12701 * lpfc_sli_prep_dev_for_recover - Prepare SLI3 device for pci slot recover
12715 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli_prep_dev_for_recover()
12721 * lpfc_sli_prep_dev_for_reset - Prepare SLI3 device for pci slot reset
12748 pci_disable_device(phba->pcidev); in lpfc_sli_prep_dev_for_reset()
12752 * lpfc_sli_prep_dev_for_perm_failure - Prepare SLI3 dev for pci slot disable
12775 * lpfc_io_error_detected_s3 - Method for handling SLI-3 device PCI I/O error
12780 * device with SLI-3 interface spec. This function is called by the PCI
12788 * PCI_ERS_RESULT_CAN_RECOVER - can be recovered with reset_link
12789 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
12790 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
12796 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s3()
12800 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s3()
12821 * lpfc_io_slot_reset_s3 - Method for restarting PCI SLI-3 device from scratch.
12825 * device with SLI-3 interface spec. This is called after PCI bus has been
12826 * reset to restart the PCI card from scratch, as if from a cold-boot.
12835 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
12836 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
12842 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s3()
12843 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s3()
12846 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s3()
12848 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s3()
12861 if (pdev->is_busmaster) in lpfc_io_slot_reset_s3()
12864 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
12865 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s3()
12866 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
12869 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
12872 "0427 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s3()
12876 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s3()
12884 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
12890 * lpfc_io_resume_s3 - Method for resuming PCI I/O operation on SLI-3 device.
12894 * with SLI-3 interface spec. It is called when kernel error recovery tells
12903 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s3()
12905 /* Bring device online, it will be no-op for non-fatal error resume */ in lpfc_io_resume_s3()
12910 * lpfc_sli4_get_els_iocb_cnt - Calculate the # of ELS IOCBs to reserve
12918 int max_xri = phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_get_els_iocb_cnt()
12920 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli4_get_els_iocb_cnt()
12940 * lpfc_sli4_get_iocb_cnt - Calculate the # of total IOCBs to reserve
12950 if (phba->nvmet_support) in lpfc_sli4_get_iocb_cnt()
12970 (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G6_FC && in lpfc_log_write_firmware_error()
12972 (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G7_FC && in lpfc_log_write_firmware_error()
12978 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
12979 fsize, fw->size); in lpfc_log_write_firmware_error()
12980 rc = -EINVAL; in lpfc_log_write_firmware_error()
12987 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
12988 fsize, fw->size); in lpfc_log_write_firmware_error()
12989 rc = -EACCES; in lpfc_log_write_firmware_error()
12995 offset, phba->pcidev->device, magic_number, in lpfc_log_write_firmware_error()
12996 ftype, fid, fsize, fw->size); in lpfc_log_write_firmware_error()
12997 rc = -EIO; in lpfc_log_write_firmware_error()
13003 * lpfc_write_firmware - attempt to write a firmware image to the port
13020 /* It can be null in no-wait mode, sanity check */ in lpfc_write_firmware()
13022 rc = -ENXIO; in lpfc_write_firmware()
13025 image = (struct lpfc_grp_hdr *)fw->data; in lpfc_write_firmware()
13027 magic_number = be32_to_cpu(image->magic_number); in lpfc_write_firmware()
13030 fsize = be32_to_cpu(image->size); in lpfc_write_firmware()
13034 if (strncmp(fwrev, image->revision, strnlen(image->revision, 16))) { in lpfc_write_firmware()
13038 fwrev, image->revision); in lpfc_write_firmware()
13043 rc = -ENOMEM; in lpfc_write_firmware()
13046 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_write_firmware()
13048 &dmabuf->phys, in lpfc_write_firmware()
13050 if (!dmabuf->virt) { in lpfc_write_firmware()
13052 rc = -ENOMEM; in lpfc_write_firmware()
13055 list_add_tail(&dmabuf->list, &dma_buffer_list); in lpfc_write_firmware()
13057 while (offset < fw->size) { in lpfc_write_firmware()
13060 if (temp_offset + SLI4_PAGE_SIZE > fw->size) { in lpfc_write_firmware()
13061 memcpy(dmabuf->virt, in lpfc_write_firmware()
13062 fw->data + temp_offset, in lpfc_write_firmware()
13063 fw->size - temp_offset); in lpfc_write_firmware()
13064 temp_offset = fw->size; in lpfc_write_firmware()
13067 memcpy(dmabuf->virt, fw->data + temp_offset, in lpfc_write_firmware()
13072 (fw->size - offset), &offset); in lpfc_write_firmware()
13088 fwrev, image->revision); in lpfc_write_firmware()
13092 list_del(&dmabuf->list); in lpfc_write_firmware()
13093 dma_free_coherent(&phba->pcidev->dev, SLI4_PAGE_SIZE, in lpfc_write_firmware()
13094 dmabuf->virt, dmabuf->phys); in lpfc_write_firmware()
13108 * lpfc_sli4_request_firmware_update - Request linux generic firmware upgrade
13123 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_request_firmware_update()
13125 return -EPERM; in lpfc_sli4_request_firmware_update()
13127 snprintf(file_name, ELX_MODEL_NAME_SIZE, "%s.grp", phba->ModelName); in lpfc_sli4_request_firmware_update()
13131 file_name, &phba->pcidev->dev, in lpfc_sli4_request_firmware_update()
13135 ret = request_firmware(&fw, file_name, &phba->pcidev->dev); in lpfc_sli4_request_firmware_update()
13139 ret = -EINVAL; in lpfc_sli4_request_firmware_update()
13146 * lpfc_pci_probe_one_s4 - PCI probe func to reg SLI-4 device to PCI subsys
13151 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
13152 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
13160 * 0 - driver can claim the device
13161 * negative value - driver can not claim the device
13175 return -ENOMEM; in lpfc_pci_probe_one_s4()
13182 /* Set up SLI API function jump table for PCI-device group-1 HBAs */ in lpfc_pci_probe_one_s4()
13187 /* Set up SLI-4 specific device PCI memory space */ in lpfc_pci_probe_one_s4()
13195 /* Set up SLI-4 Specific device driver resources */ in lpfc_pci_probe_one_s4()
13203 INIT_LIST_HEAD(&phba->active_rrq_list); in lpfc_pci_probe_one_s4()
13204 INIT_LIST_HEAD(&phba->fcf.fcf_pri_list); in lpfc_pci_probe_one_s4()
13215 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s4()
13218 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s4()
13221 phba->pport = NULL; in lpfc_pci_probe_one_s4()
13235 error = -ENODEV; in lpfc_pci_probe_one_s4()
13238 /* Default to single EQ for non-MSI-X */ in lpfc_pci_probe_one_s4()
13239 if (phba->intr_type != MSIX) { in lpfc_pci_probe_one_s4()
13240 phba->cfg_irq_chann = 1; in lpfc_pci_probe_one_s4()
13241 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
13242 if (phba->nvmet_support) in lpfc_pci_probe_one_s4()
13243 phba->cfg_nvmet_mrq = 1; in lpfc_pci_probe_one_s4()
13246 lpfc_cpu_affinity_check(phba, phba->cfg_irq_chann); in lpfc_pci_probe_one_s4()
13255 vport = phba->pport; in lpfc_pci_probe_one_s4()
13266 /* Set up SLI-4 HBA */ in lpfc_pci_probe_one_s4()
13270 error = -ENODEV; in lpfc_pci_probe_one_s4()
13275 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s4()
13284 if (phba->nvmet_support == 0) { in lpfc_pci_probe_one_s4()
13285 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
13302 if (phba->cfg_request_firmware_upgrade) in lpfc_pci_probe_one_s4()
13311 INIT_LIST_HEAD(&phba->poll_list); in lpfc_pci_probe_one_s4()
13312 timer_setup(&phba->cpuhp_poll_timer, lpfc_sli4_poll_hbtimer, 0); in lpfc_pci_probe_one_s4()
13313 cpuhp_state_add_instance_nocalls(lpfc_cpuhp_state, &phba->cpuhp); in lpfc_pci_probe_one_s4()
13339 * lpfc_pci_remove_one_s4 - PCI func to unreg SLI-4 device from PCI subsystem
13343 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
13351 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s4()
13353 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s4()
13357 spin_lock_irq(&phba->hbalock); in lpfc_pci_remove_one_s4()
13358 vport->load_flag |= FC_UNLOADING; in lpfc_pci_remove_one_s4()
13359 spin_unlock_irq(&phba->hbalock); in lpfc_pci_remove_one_s4()
13367 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s4()
13368 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s4()
13370 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s4()
13385 /* De-allocate multi-XRI pools */ in lpfc_pci_remove_one_s4()
13386 if (phba->cfg_xri_rebalancing) in lpfc_pci_remove_one_s4()
13397 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
13398 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s4()
13399 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
13425 * lpfc_pci_suspend_one_s4 - PCI func to suspend SLI-4 device for power mgmnt
13430 * Power Management (PM) to device with SLI-4 interface spec. When PM invokes
13434 * requirements to a power-aware driver's PM support for suspend/resume -- all
13442 * 0 - driver suspended the device
13449 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s4()
13457 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s4()
13471 * lpfc_pci_resume_one_s4 - PCI func to resume SLI-4 device for power mgmnt
13475 * Power Management (PM) to device with SLI-4 interface spac. When PM invokes
13478 * implements the minimum PM requirements to a power-aware driver's PM for
13479 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
13486 * 0 - driver suspended the device
13493 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s4()
13510 if (pdev->is_busmaster) in lpfc_pci_resume_one_s4()
13514 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s4()
13515 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s4()
13516 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s4()
13517 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s4()
13525 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
13529 return -EIO; in lpfc_pci_resume_one_s4()
13531 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s4()
13538 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
13544 * lpfc_sli4_prep_dev_for_recover - Prepare SLI4 device for pci slot recover
13557 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli4_prep_dev_for_recover()
13563 * lpfc_sli4_prep_dev_for_reset - Prepare SLI4 device for pci slot reset
13591 pci_disable_device(phba->pcidev); in lpfc_sli4_prep_dev_for_reset()
13595 * lpfc_sli4_prep_dev_for_perm_failure - Prepare SLI4 dev for pci slot disable
13619 * lpfc_io_error_detected_s4 - Method for handling PCI I/O error to SLI-4 device
13624 * with SLI-4 interface spec. This function is called by the PCI subsystem
13631 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
13632 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
13638 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s4()
13642 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s4()
13663 * lpfc_io_slot_reset_s4 - Method for restart PCI SLI-4 device from scratch
13667 * with SLI-4 interface spec. It is called after PCI bus has been reset to
13668 * restart the PCI card from scratch, as if from a cold-boot. During the
13677 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
13678 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
13684 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s4()
13685 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s4()
13688 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s4()
13690 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s4()
13703 if (pdev->is_busmaster) in lpfc_io_slot_reset_s4()
13706 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
13707 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s4()
13708 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
13711 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
13714 "2824 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s4()
13718 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s4()
13721 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
13727 * lpfc_io_resume_s4 - Method for resuming PCI I/O operation to SLI-4 device
13731 * with SLI-4 interface spec. It is called when kernel error recovery tells
13740 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s4()
13748 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) { in lpfc_io_resume_s4()
13759 * lpfc_pci_probe_one - lpfc PCI probe func to reg dev to PCI subsystem
13765 * at PCI device-specific information of the device and driver to see if the
13768 * the action to the proper SLI-3 or SLI-4 device probing routine, which will
13773 * 0 - driver can claim the device
13774 * negative value - driver can not claim the device
13783 return -ENODEV; in lpfc_pci_probe_one()
13795 * lpfc_pci_remove_one - lpfc PCI func to unreg dev from PCI subsystem
13800 * This routine dispatches the action to the proper SLI-3 or SLI-4 device
13808 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_remove_one()
13810 switch (phba->pci_dev_grp) { in lpfc_pci_remove_one()
13820 phba->pci_dev_grp); in lpfc_pci_remove_one()
13827 * lpfc_pci_suspend_one - lpfc PCI func to suspend dev for power management
13833 * the action to the proper SLI-3 or SLI-4 device suspend routine, which will
13837 * 0 - driver suspended the device
13844 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one()
13845 int rc = -ENODEV; in lpfc_pci_suspend_one()
13847 switch (phba->pci_dev_grp) { in lpfc_pci_suspend_one()
13857 phba->pci_dev_grp); in lpfc_pci_suspend_one()
13864 * lpfc_pci_resume_one - lpfc PCI func to resume dev for power management
13869 * the action to the proper SLI-3 or SLI-4 device resume routine, which will
13873 * 0 - driver suspended the device
13880 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one()
13881 int rc = -ENODEV; in lpfc_pci_resume_one()
13883 switch (phba->pci_dev_grp) { in lpfc_pci_resume_one()
13893 phba->pci_dev_grp); in lpfc_pci_resume_one()
13900 * lpfc_io_error_detected - lpfc method for handling PCI I/O error
13907 * the action to the proper SLI-3 or SLI-4 device error detected handling
13911 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
13912 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
13918 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected()
13921 switch (phba->pci_dev_grp) { in lpfc_io_error_detected()
13931 phba->pci_dev_grp); in lpfc_io_error_detected()
13938 * lpfc_io_slot_reset - lpfc method for restart PCI dev from scratch
13943 * from scratch, as if from a cold-boot. When this routine is invoked, it
13944 * dispatches the action to the proper SLI-3 or SLI-4 device reset handling
13948 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
13949 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
13955 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset()
13958 switch (phba->pci_dev_grp) { in lpfc_io_slot_reset()
13968 phba->pci_dev_grp); in lpfc_io_slot_reset()
13975 * lpfc_io_resume - lpfc method for resuming PCI I/O operation
13981 * this routine is invoked, it dispatches the action to the proper SLI-3
13982 * or SLI-4 device io_resume routine, which will resume the device operation.
13988 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume()
13990 switch (phba->pci_dev_grp) { in lpfc_io_resume()
14000 phba->pci_dev_grp); in lpfc_io_resume()
14007 * lpfc_sli4_oas_verify - Verify OAS is supported by this adapter
14020 if (!phba->cfg_EnableXLane) in lpfc_sli4_oas_verify()
14023 if (phba->sli4_hba.pc_sli4_params.oas_supported) { in lpfc_sli4_oas_verify()
14024 phba->cfg_fof = 1; in lpfc_sli4_oas_verify()
14026 phba->cfg_fof = 0; in lpfc_sli4_oas_verify()
14027 mempool_destroy(phba->device_data_mem_pool); in lpfc_sli4_oas_verify()
14028 phba->device_data_mem_pool = NULL; in lpfc_sli4_oas_verify()
14035 * lpfc_sli4_ras_init - Verify RAS-FW log is supported by this adapter
14044 switch (phba->pcidev->device) { in lpfc_sli4_ras_init()
14047 phba->ras_fwlog.ras_hwsupport = true; in lpfc_sli4_ras_init()
14048 if (phba->cfg_ras_fwlog_func == PCI_FUNC(phba->pcidev->devfn) && in lpfc_sli4_ras_init()
14049 phba->cfg_ras_fwlog_buffsize) in lpfc_sli4_ras_init()
14050 phba->ras_fwlog.ras_enabled = true; in lpfc_sli4_ras_init()
14052 phba->ras_fwlog.ras_enabled = false; in lpfc_sli4_ras_init()
14055 phba->ras_fwlog.ras_hwsupport = false; in lpfc_sli4_ras_init()
14090 * lpfc_init - lpfc module initialization routine
14097 * 0 - successful
14098 * -ENOMEM - FC attach transport failed
14099 * all others - failed
14114 error = -ENOMEM; in lpfc_init()
14166 if (phba->cfg_log_verbose) in lpfc_dmp_dbg()
14169 if (atomic_cmpxchg(&phba->dbg_log_dmping, 0, 1) != 0) in lpfc_dmp_dbg()
14172 start_idx = (unsigned int)atomic_read(&phba->dbg_log_idx) % DBG_LOG_SZ; in lpfc_dmp_dbg()
14173 dbg_cnt = (unsigned int)atomic_read(&phba->dbg_log_cnt); in lpfc_dmp_dbg()
14177 temp_idx -= 1; in lpfc_dmp_dbg()
14179 if ((start_idx + dbg_cnt) > (DBG_LOG_SZ - 1)) { in lpfc_dmp_dbg()
14183 start_idx = DBG_LOG_SZ - (dbg_cnt - start_idx); in lpfc_dmp_dbg()
14185 start_idx -= dbg_cnt; in lpfc_dmp_dbg()
14188 dev_info(&phba->pcidev->dev, "start %d end %d cnt %d\n", in lpfc_dmp_dbg()
14196 rem_nsec = do_div(phba->dbg_log[temp_idx].t_ns, NSEC_PER_SEC); in lpfc_dmp_dbg()
14197 dev_info(&phba->pcidev->dev, "%d: [%5lu.%06lu] %s", in lpfc_dmp_dbg()
14199 (unsigned long)phba->dbg_log[temp_idx].t_ns, in lpfc_dmp_dbg()
14201 phba->dbg_log[temp_idx].log); in lpfc_dmp_dbg()
14203 atomic_set(&phba->dbg_log_cnt, 0); in lpfc_dmp_dbg()
14204 atomic_set(&phba->dbg_log_dmping, 0); in lpfc_dmp_dbg()
14212 int dbg_dmping = atomic_read(&phba->dbg_log_dmping); in lpfc_dbg_print()
14220 dev_info(&phba->pcidev->dev, "%pV", &vaf); in lpfc_dbg_print()
14224 idx = (unsigned int)atomic_fetch_add(1, &phba->dbg_log_idx) % in lpfc_dbg_print()
14227 atomic_inc(&phba->dbg_log_cnt); in lpfc_dbg_print()
14229 vscnprintf(phba->dbg_log[idx].log, in lpfc_dbg_print()
14230 sizeof(phba->dbg_log[idx].log), fmt, args); in lpfc_dbg_print()
14233 phba->dbg_log[idx].t_ns = local_clock(); in lpfc_dbg_print()
14237 * lpfc_exit - lpfc module removal routine