Lines Matching +full:cpu +full:- +full:centric
4 * Copyright (C) 2017-2023 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>
42 #include <linux/cpu.h>
68 /* Used when mapping IRQ vectors in a driver centric manner */
107 * lpfc_config_port_prep - Perform lpfc initialization prior to config port
116 * 0 - success.
117 * -ERESTART - requests the SLI layer to reset the HBA and try again.
118 * Any other value - indicates an error.
123 lpfc_vpd_t *vp = &phba->vpd; in lpfc_config_port_prep()
133 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_prep()
135 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_prep()
136 return -ENOMEM; in lpfc_config_port_prep()
139 mb = &pmb->u.mb; in lpfc_config_port_prep()
140 phba->link_state = LPFC_INIT_MBX_CMDS; in lpfc_config_port_prep()
142 if (lpfc_is_LC_HBA(phba->pcidev->device)) { in lpfc_config_port_prep()
152 memset((char*)mb->un.varRDnvp.rsvd3, 0, in lpfc_config_port_prep()
153 sizeof (mb->un.varRDnvp.rsvd3)); in lpfc_config_port_prep()
154 memcpy((char*)mb->un.varRDnvp.rsvd3, licensed, in lpfc_config_port_prep()
164 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_prep()
165 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
166 return -ERESTART; in lpfc_config_port_prep()
168 memcpy(phba->wwnn, (char *)mb->un.varRDnvp.nodename, in lpfc_config_port_prep()
169 sizeof(phba->wwnn)); in lpfc_config_port_prep()
170 memcpy(phba->wwpn, (char *)mb->un.varRDnvp.portname, in lpfc_config_port_prep()
171 sizeof(phba->wwpn)); in lpfc_config_port_prep()
178 phba->sli3_options &= (uint32_t)LPFC_SLI3_BG_ENABLED; in lpfc_config_port_prep()
187 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_prep()
188 mempool_free( pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
189 return -ERESTART; in lpfc_config_port_prep()
197 if (mb->un.varRdRev.rr == 0) { in lpfc_config_port_prep()
198 vp->rev.rBit = 0; in lpfc_config_port_prep()
202 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
203 return -ERESTART; in lpfc_config_port_prep()
206 if (phba->sli_rev == 3 && !mb->un.varRdRev.v3rsp) { in lpfc_config_port_prep()
207 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
208 return -EINVAL; in lpfc_config_port_prep()
212 vp->rev.rBit = 1; in lpfc_config_port_prep()
213 memcpy(&vp->sli3Feat, &mb->un.varRdRev.sli3Feat, sizeof(uint32_t)); in lpfc_config_port_prep()
214 vp->rev.sli1FwRev = mb->un.varRdRev.sli1FwRev; in lpfc_config_port_prep()
215 memcpy(vp->rev.sli1FwName, (char*) mb->un.varRdRev.sli1FwName, 16); in lpfc_config_port_prep()
216 vp->rev.sli2FwRev = mb->un.varRdRev.sli2FwRev; in lpfc_config_port_prep()
217 memcpy(vp->rev.sli2FwName, (char *) mb->un.varRdRev.sli2FwName, 16); in lpfc_config_port_prep()
218 vp->rev.biuRev = mb->un.varRdRev.biuRev; in lpfc_config_port_prep()
219 vp->rev.smRev = mb->un.varRdRev.smRev; in lpfc_config_port_prep()
220 vp->rev.smFwRev = mb->un.varRdRev.un.smFwRev; in lpfc_config_port_prep()
221 vp->rev.endecRev = mb->un.varRdRev.endecRev; in lpfc_config_port_prep()
222 vp->rev.fcphHigh = mb->un.varRdRev.fcphHigh; in lpfc_config_port_prep()
223 vp->rev.fcphLow = mb->un.varRdRev.fcphLow; in lpfc_config_port_prep()
224 vp->rev.feaLevelHigh = mb->un.varRdRev.feaLevelHigh; in lpfc_config_port_prep()
225 vp->rev.feaLevelLow = mb->un.varRdRev.feaLevelLow; in lpfc_config_port_prep()
226 vp->rev.postKernRev = mb->un.varRdRev.postKernRev; in lpfc_config_port_prep()
227 vp->rev.opFwRev = mb->un.varRdRev.opFwRev; in lpfc_config_port_prep()
233 if (vp->rev.feaLevelHigh < 9) in lpfc_config_port_prep()
234 phba->sli3_options |= LPFC_SLI3_VPORT_TEARDOWN; in lpfc_config_port_prep()
236 if (lpfc_is_LC_HBA(phba->pcidev->device)) in lpfc_config_port_prep()
237 memcpy(phba->RandomData, (char *)&mb->un.varWords[24], in lpfc_config_port_prep()
238 sizeof (phba->RandomData)); in lpfc_config_port_prep()
252 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_prep()
253 mb->un.varDmp.word_cnt = 0; in lpfc_config_port_prep()
258 if (mb->un.varDmp.word_cnt == 0) in lpfc_config_port_prep()
261 if (mb->un.varDmp.word_cnt > DMP_VPD_SIZE - offset) in lpfc_config_port_prep()
262 mb->un.varDmp.word_cnt = DMP_VPD_SIZE - offset; in lpfc_config_port_prep()
265 mb->un.varDmp.word_cnt); in lpfc_config_port_prep()
266 offset += mb->un.varDmp.word_cnt; in lpfc_config_port_prep()
267 } while (mb->un.varDmp.word_cnt && offset < DMP_VPD_SIZE); in lpfc_config_port_prep()
273 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
278 * lpfc_config_async_cmpl - Completion handler for config async event mbox cmd
290 if (pmboxq->u.mb.mbxStatus == MBX_SUCCESS) in lpfc_config_async_cmpl()
291 phba->temp_sensor_support = 1; in lpfc_config_async_cmpl()
293 phba->temp_sensor_support = 0; in lpfc_config_async_cmpl()
294 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_config_async_cmpl()
299 * lpfc_dump_wakeup_param_cmpl - dump memory mailbox command completion handler
317 if (pmboxq->u.mb.mbxStatus != MBX_SUCCESS) { in lpfc_dump_wakeup_param_cmpl()
318 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_dump_wakeup_param_cmpl()
325 prog_id_word = pmboxq->u.mb.un.varWords[7]; in lpfc_dump_wakeup_param_cmpl()
328 dist = dist_char[prg->dist]; in lpfc_dump_wakeup_param_cmpl()
330 if ((prg->dist == 3) && (prg->num == 0)) in lpfc_dump_wakeup_param_cmpl()
331 snprintf(phba->OptionROMVersion, 32, "%d.%d%d", in lpfc_dump_wakeup_param_cmpl()
332 prg->ver, prg->rev, prg->lev); in lpfc_dump_wakeup_param_cmpl()
334 snprintf(phba->OptionROMVersion, 32, "%d.%d%d%c%d", in lpfc_dump_wakeup_param_cmpl()
335 prg->ver, prg->rev, prg->lev, in lpfc_dump_wakeup_param_cmpl()
336 dist, prg->num); in lpfc_dump_wakeup_param_cmpl()
337 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_dump_wakeup_param_cmpl()
342 * lpfc_update_vport_wwn - Updates the fc_nodename, fc_portname,
352 struct lpfc_hba *phba = vport->phba; in lpfc_update_vport_wwn()
358 if (vport->fc_nodename.u.wwn[0] == 0) in lpfc_update_vport_wwn()
359 memcpy(&vport->fc_nodename, &vport->fc_sparam.nodeName, in lpfc_update_vport_wwn()
362 memcpy(&vport->fc_sparam.nodeName, &vport->fc_nodename, in lpfc_update_vport_wwn()
369 if (vport->fc_portname.u.wwn[0] != 0 && in lpfc_update_vport_wwn()
370 memcmp(&vport->fc_portname, &vport->fc_sparam.portName, in lpfc_update_vport_wwn()
372 vport->vport_flag |= FAWWPN_PARAM_CHG; in lpfc_update_vport_wwn()
374 if (phba->sli_rev == LPFC_SLI_REV4 && in lpfc_update_vport_wwn()
375 vport->port_type == LPFC_PHYSICAL_PORT && in lpfc_update_vport_wwn()
376 phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_FABRIC) { in lpfc_update_vport_wwn()
377 if (!(phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_CONFIG)) in lpfc_update_vport_wwn()
378 phba->sli4_hba.fawwpn_flag &= in lpfc_update_vport_wwn()
382 "2701 FA-PWWN change WWPN from %llx to " in lpfc_update_vport_wwn()
384 wwn_to_u64(vport->fc_portname.u.wwn), in lpfc_update_vport_wwn()
386 (vport->fc_sparam.portName.u.wwn), in lpfc_update_vport_wwn()
387 vport->vport_flag, in lpfc_update_vport_wwn()
388 phba->sli4_hba.fawwpn_flag); in lpfc_update_vport_wwn()
389 memcpy(&vport->fc_portname, &vport->fc_sparam.portName, in lpfc_update_vport_wwn()
394 if (vport->fc_portname.u.wwn[0] == 0) in lpfc_update_vport_wwn()
395 memcpy(&vport->fc_portname, &vport->fc_sparam.portName, in lpfc_update_vport_wwn()
398 memcpy(&vport->fc_sparam.portName, &vport->fc_portname, in lpfc_update_vport_wwn()
403 * lpfc_config_port_post - Perform lpfc initialization after config port
412 * 0 - success.
413 * Any other value - error.
418 struct lpfc_vport *vport = phba->pport; in lpfc_config_port_post()
423 struct lpfc_sli *psli = &phba->sli; in lpfc_config_port_post()
428 spin_lock_irq(&phba->hbalock); in lpfc_config_port_post()
433 if (phba->over_temp_state == HBA_OVER_TEMP) in lpfc_config_port_post()
434 phba->over_temp_state = HBA_NORMAL_TEMP; in lpfc_config_port_post()
435 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
437 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
439 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
440 return -ENOMEM; in lpfc_config_port_post()
442 mb = &pmb->u.mb; in lpfc_config_port_post()
447 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
448 return -ENOMEM; in lpfc_config_port_post()
451 pmb->vport = vport; in lpfc_config_port_post()
456 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_post()
457 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
459 return -EIO; in lpfc_config_port_post()
462 mp = (struct lpfc_dmabuf *)pmb->ctx_buf; in lpfc_config_port_post()
468 memcpy(&vport->fc_sparam, mp->virt, sizeof (struct serv_parm)); in lpfc_config_port_post()
469 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_config_port_post()
471 pmb->ctx_buf = NULL; in lpfc_config_port_post()
475 fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); in lpfc_config_port_post()
476 fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); in lpfc_config_port_post()
477 fc_host_max_npiv_vports(shost) = phba->max_vpi; in lpfc_config_port_post()
480 /* This should be consolidated into parse_vpd ? - mr */ in lpfc_config_port_post()
481 if (phba->SerialNumber[0] == 0) { in lpfc_config_port_post()
484 outptr = &vport->fc_nodename.u.s.IEEE[0]; in lpfc_config_port_post()
489 phba->SerialNumber[i] = in lpfc_config_port_post()
492 phba->SerialNumber[i] = in lpfc_config_port_post()
493 (char)((uint8_t) 0x61 + (uint8_t) (j - 10)); in lpfc_config_port_post()
497 phba->SerialNumber[i] = in lpfc_config_port_post()
500 phba->SerialNumber[i] = in lpfc_config_port_post()
501 (char)((uint8_t) 0x61 + (uint8_t) (j - 10)); in lpfc_config_port_post()
506 pmb->vport = vport; in lpfc_config_port_post()
511 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_post()
512 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
513 mempool_free( pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
514 return -EIO; in lpfc_config_port_post()
521 if (phba->cfg_hba_queue_depth > mb->un.varRdConfig.max_xri) { in lpfc_config_port_post()
524 phba->cfg_hba_queue_depth, in lpfc_config_port_post()
525 mb->un.varRdConfig.max_xri); in lpfc_config_port_post()
526 phba->cfg_hba_queue_depth = mb->un.varRdConfig.max_xri; in lpfc_config_port_post()
529 phba->lmt = mb->un.varRdConfig.lmt; in lpfc_config_port_post()
532 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_config_port_post()
534 phba->link_state = LPFC_LINK_DOWN; in lpfc_config_port_post()
537 if (psli->sli3_ring[LPFC_EXTRA_RING].sli.sli3.cmdringaddr) in lpfc_config_port_post()
538 psli->sli3_ring[LPFC_EXTRA_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_config_port_post()
539 if (psli->sli3_ring[LPFC_FCP_RING].sli.sli3.cmdringaddr) in lpfc_config_port_post()
540 psli->sli3_ring[LPFC_FCP_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_config_port_post()
543 if (phba->sli_rev != 3) in lpfc_config_port_post()
547 * Configure HBA MSI-X attention conditions to messages if MSI-X mode in lpfc_config_port_post()
549 if (phba->intr_type == MSIX) { in lpfc_config_port_post()
552 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
553 return -EIO; in lpfc_config_port_post()
560 pmb->u.mb.mbxCommand, in lpfc_config_port_post()
561 pmb->u.mb.mbxStatus); in lpfc_config_port_post()
562 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
563 return -EIO; in lpfc_config_port_post()
567 spin_lock_irq(&phba->hbalock); in lpfc_config_port_post()
569 phba->hba_flag &= ~HBA_ERATT_HANDLED; in lpfc_config_port_post()
572 if (lpfc_readl(phba->HCregaddr, &status)) { in lpfc_config_port_post()
573 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
574 return -EIO; in lpfc_config_port_post()
577 if (psli->num_rings > 0) in lpfc_config_port_post()
579 if (psli->num_rings > 1) in lpfc_config_port_post()
581 if (psli->num_rings > 2) in lpfc_config_port_post()
583 if (psli->num_rings > 3) in lpfc_config_port_post()
586 if ((phba->cfg_poll & ENABLE_FCP_RING_POLLING) && in lpfc_config_port_post()
587 (phba->cfg_poll & DISABLE_FCP_RING_INT)) in lpfc_config_port_post()
590 writel(status, phba->HCregaddr); in lpfc_config_port_post()
591 readl(phba->HCregaddr); /* flush */ in lpfc_config_port_post()
592 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
594 /* Set up ring-0 (ELS) timer */ in lpfc_config_port_post()
595 timeout = phba->fc_ratov * 2; in lpfc_config_port_post()
596 mod_timer(&vport->els_tmofunc, in lpfc_config_port_post()
599 mod_timer(&phba->hb_tmofunc, in lpfc_config_port_post()
601 phba->hba_flag &= ~(HBA_HBEAT_INP | HBA_HBEAT_TMO); in lpfc_config_port_post()
602 phba->last_completion_time = jiffies; in lpfc_config_port_post()
604 mod_timer(&phba->eratt_poll, in lpfc_config_port_post()
605 jiffies + msecs_to_jiffies(1000 * phba->eratt_poll_interval)); in lpfc_config_port_post()
607 if (phba->hba_flag & LINK_DISABLED) { in lpfc_config_port_post()
611 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_config_port_post()
618 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
619 return -EIO; in lpfc_config_port_post()
621 } else if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) { in lpfc_config_port_post()
622 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
623 rc = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); in lpfc_config_port_post()
628 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
630 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
631 return -ENOMEM; in lpfc_config_port_post()
635 pmb->mbox_cmpl = lpfc_config_async_cmpl; in lpfc_config_port_post()
636 pmb->vport = phba->pport; in lpfc_config_port_post()
644 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
648 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
650 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
651 return -ENOMEM; in lpfc_config_port_post()
655 pmb->mbox_cmpl = lpfc_dump_wakeup_param_cmpl; in lpfc_config_port_post()
656 pmb->vport = phba->pport; in lpfc_config_port_post()
663 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
670 * lpfc_sli4_refresh_params - update driver copy of params.
684 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_refresh_params()
686 return -ENOMEM; in lpfc_sli4_refresh_params()
688 mqe = &mboxq->u.mqe; in lpfc_sli4_refresh_params()
690 length = (sizeof(struct lpfc_mbx_get_sli4_parameters) - in lpfc_sli4_refresh_params()
698 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_refresh_params()
701 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters; in lpfc_sli4_refresh_params()
702 phba->sli4_hba.pc_sli4_params.mi_cap = in lpfc_sli4_refresh_params()
706 if (phba->cfg_enable_mi) in lpfc_sli4_refresh_params()
707 phba->sli4_hba.pc_sli4_params.mi_ver = in lpfc_sli4_refresh_params()
710 phba->sli4_hba.pc_sli4_params.mi_ver = 0; in lpfc_sli4_refresh_params()
712 phba->sli4_hba.pc_sli4_params.cmf = in lpfc_sli4_refresh_params()
714 phba->sli4_hba.pc_sli4_params.pls = in lpfc_sli4_refresh_params()
717 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_refresh_params()
722 * lpfc_hba_init_link - Initialize the FC link
724 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
732 * 0 - success
733 * Any other value - error
738 return lpfc_hba_init_link_fc_topology(phba, phba->cfg_topology, flag); in lpfc_hba_init_link()
742 * lpfc_hba_init_link_fc_topology - Initialize FC link with desired topology
745 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
753 * 0 - success
754 * Any other value - error
760 struct lpfc_vport *vport = phba->pport; in lpfc_hba_init_link_fc_topology()
765 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_hba_init_link_fc_topology()
767 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_init_link_fc_topology()
768 return -ENOMEM; in lpfc_hba_init_link_fc_topology()
770 mb = &pmb->u.mb; in lpfc_hba_init_link_fc_topology()
771 pmb->vport = vport; in lpfc_hba_init_link_fc_topology()
773 if ((phba->cfg_link_speed > LPFC_USER_LINK_SPEED_MAX) || in lpfc_hba_init_link_fc_topology()
774 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_1G) && in lpfc_hba_init_link_fc_topology()
775 !(phba->lmt & LMT_1Gb)) || in lpfc_hba_init_link_fc_topology()
776 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_2G) && in lpfc_hba_init_link_fc_topology()
777 !(phba->lmt & LMT_2Gb)) || in lpfc_hba_init_link_fc_topology()
778 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_4G) && in lpfc_hba_init_link_fc_topology()
779 !(phba->lmt & LMT_4Gb)) || in lpfc_hba_init_link_fc_topology()
780 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_8G) && in lpfc_hba_init_link_fc_topology()
781 !(phba->lmt & LMT_8Gb)) || in lpfc_hba_init_link_fc_topology()
782 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_10G) && in lpfc_hba_init_link_fc_topology()
783 !(phba->lmt & LMT_10Gb)) || in lpfc_hba_init_link_fc_topology()
784 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G) && in lpfc_hba_init_link_fc_topology()
785 !(phba->lmt & LMT_16Gb)) || in lpfc_hba_init_link_fc_topology()
786 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_32G) && in lpfc_hba_init_link_fc_topology()
787 !(phba->lmt & LMT_32Gb)) || in lpfc_hba_init_link_fc_topology()
788 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_64G) && in lpfc_hba_init_link_fc_topology()
789 !(phba->lmt & LMT_64Gb))) { in lpfc_hba_init_link_fc_topology()
794 phba->cfg_link_speed); in lpfc_hba_init_link_fc_topology()
795 phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; in lpfc_hba_init_link_fc_topology()
797 lpfc_init_link(phba, pmb, fc_topology, phba->cfg_link_speed); in lpfc_hba_init_link_fc_topology()
798 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_hba_init_link_fc_topology()
799 if (phba->sli_rev < LPFC_SLI_REV4) in lpfc_hba_init_link_fc_topology()
806 mb->mbxCommand, mb->mbxStatus); in lpfc_hba_init_link_fc_topology()
807 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_hba_init_link_fc_topology()
809 writel(0, phba->HCregaddr); in lpfc_hba_init_link_fc_topology()
810 readl(phba->HCregaddr); /* flush */ in lpfc_hba_init_link_fc_topology()
812 writel(0xffffffff, phba->HAregaddr); in lpfc_hba_init_link_fc_topology()
813 readl(phba->HAregaddr); /* flush */ in lpfc_hba_init_link_fc_topology()
815 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_init_link_fc_topology()
817 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_init_link_fc_topology()
818 return -EIO; in lpfc_hba_init_link_fc_topology()
820 phba->cfg_suppress_link_up = LPFC_INITIALIZE_LINK; in lpfc_hba_init_link_fc_topology()
822 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_init_link_fc_topology()
828 * lpfc_hba_down_link - this routine downs the FC link
830 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
837 * 0 - success
838 * Any other value - error
846 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_hba_down_link()
848 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_down_link()
849 return -ENOMEM; in lpfc_hba_down_link()
855 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_hba_down_link()
862 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_down_link()
863 return -EIO; in lpfc_hba_down_link()
866 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_down_link()
872 * lpfc_hba_down_prep - Perform lpfc uninitialization prior to HBA reset
879 * 0 - success.
880 * Any other value - error.
888 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_hba_down_prep()
890 writel(0, phba->HCregaddr); in lpfc_hba_down_prep()
891 readl(phba->HCregaddr); /* flush */ in lpfc_hba_down_prep()
894 if (phba->pport->load_flag & FC_UNLOADING) in lpfc_hba_down_prep()
895 lpfc_cleanup_discovery_resources(phba->pport); in lpfc_hba_down_prep()
899 for (i = 0; i <= phba->max_vports && in lpfc_hba_down_prep()
908 * lpfc_sli4_free_sp_events - Cleanup sp_queue_events to free
927 spin_lock_irq(&phba->hbalock); in lpfc_sli4_free_sp_events()
928 phba->hba_flag &= ~HBA_SP_QUEUE_EVT; in lpfc_sli4_free_sp_events()
929 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_free_sp_events()
931 while (!list_empty(&phba->sli4_hba.sp_queue_event)) { in lpfc_sli4_free_sp_events()
933 spin_lock_irq(&phba->hbalock); in lpfc_sli4_free_sp_events()
934 list_remove_head(&phba->sli4_hba.sp_queue_event, in lpfc_sli4_free_sp_events()
936 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_free_sp_events()
938 switch (bf_get(lpfc_wcqe_c_code, &cq_event->cqe.wcqe_cmpl)) { in lpfc_sli4_free_sp_events()
948 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_free_sp_events()
954 * lpfc_hba_free_post_buf - Perform lpfc uninitialization after HBA reset
967 struct lpfc_sli *psli = &phba->sli; in lpfc_hba_free_post_buf()
973 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) in lpfc_hba_free_post_buf()
977 pring = &psli->sli3_ring[LPFC_ELS_RING]; in lpfc_hba_free_post_buf()
978 spin_lock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
979 list_splice_init(&pring->postbufq, &buflist); in lpfc_hba_free_post_buf()
980 spin_unlock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
984 list_del(&mp->list); in lpfc_hba_free_post_buf()
986 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_hba_free_post_buf()
990 spin_lock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
991 pring->postbufq_cnt -= count; in lpfc_hba_free_post_buf()
992 spin_unlock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
997 * lpfc_hba_clean_txcmplq - Perform lpfc uninitialization after HBA reset
1009 struct lpfc_sli *psli = &phba->sli; in lpfc_hba_clean_txcmplq()
1016 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_hba_clean_txcmplq()
1017 for (i = 0; i < psli->num_rings; i++) { in lpfc_hba_clean_txcmplq()
1018 pring = &psli->sli3_ring[i]; in lpfc_hba_clean_txcmplq()
1019 spin_lock_irq(&phba->hbalock); in lpfc_hba_clean_txcmplq()
1024 list_splice_init(&pring->txcmplq, &completions); in lpfc_hba_clean_txcmplq()
1025 pring->txcmplq_cnt = 0; in lpfc_hba_clean_txcmplq()
1026 spin_unlock_irq(&phba->hbalock); in lpfc_hba_clean_txcmplq()
1035 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_hba_clean_txcmplq()
1036 pring = qp->pring; in lpfc_hba_clean_txcmplq()
1039 spin_lock_irq(&pring->ring_lock); in lpfc_hba_clean_txcmplq()
1041 &pring->txcmplq, list) in lpfc_hba_clean_txcmplq()
1042 piocb->cmd_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_hba_clean_txcmplq()
1043 list_splice_init(&pring->txcmplq, &completions); in lpfc_hba_clean_txcmplq()
1044 pring->txcmplq_cnt = 0; in lpfc_hba_clean_txcmplq()
1045 spin_unlock_irq(&pring->ring_lock); in lpfc_hba_clean_txcmplq()
1054 * lpfc_hba_down_post_s3 - Perform lpfc uninitialization after HBA reset
1061 * 0 - success.
1062 * Any other value - error.
1073 * lpfc_hba_down_post_s4 - Perform lpfc uninitialization after HBA reset
1080 * 0 - success.
1081 * Any other value - error.
1109 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_hba_down_post_s4()
1111 &phba->sli4_hba.lpfc_abts_els_sgl_list, list) in lpfc_hba_down_post_s4()
1112 sglq_entry->state = SGL_FREED; in lpfc_hba_down_post_s4()
1114 list_splice_init(&phba->sli4_hba.lpfc_abts_els_sgl_list, in lpfc_hba_down_post_s4()
1115 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_hba_down_post_s4()
1118 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_hba_down_post_s4()
1123 spin_lock_irq(&phba->hbalock); in lpfc_hba_down_post_s4()
1125 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_hba_down_post_s4()
1126 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_hba_down_post_s4()
1128 spin_lock(&qp->abts_io_buf_list_lock); in lpfc_hba_down_post_s4()
1129 list_splice_init(&qp->lpfc_abts_io_buf_list, in lpfc_hba_down_post_s4()
1133 psb->pCmd = NULL; in lpfc_hba_down_post_s4()
1134 psb->status = IOSTAT_SUCCESS; in lpfc_hba_down_post_s4()
1137 spin_lock(&qp->io_buf_list_put_lock); in lpfc_hba_down_post_s4()
1138 list_splice_init(&aborts, &qp->lpfc_io_buf_list_put); in lpfc_hba_down_post_s4()
1139 qp->put_io_bufs += qp->abts_scsi_io_bufs; in lpfc_hba_down_post_s4()
1140 qp->put_io_bufs += qp->abts_nvme_io_bufs; in lpfc_hba_down_post_s4()
1141 qp->abts_scsi_io_bufs = 0; in lpfc_hba_down_post_s4()
1142 qp->abts_nvme_io_bufs = 0; in lpfc_hba_down_post_s4()
1143 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_hba_down_post_s4()
1144 spin_unlock(&qp->abts_io_buf_list_lock); in lpfc_hba_down_post_s4()
1146 spin_unlock_irq(&phba->hbalock); in lpfc_hba_down_post_s4()
1148 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_hba_down_post_s4()
1149 spin_lock_irq(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_hba_down_post_s4()
1150 list_splice_init(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list, in lpfc_hba_down_post_s4()
1152 spin_unlock_irq(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_hba_down_post_s4()
1154 ctxp->flag &= ~(LPFC_NVME_XBUSY | LPFC_NVME_ABORT_OP); in lpfc_hba_down_post_s4()
1155 lpfc_nvmet_ctxbuf_post(phba, ctxp->ctxbuf); in lpfc_hba_down_post_s4()
1164 * lpfc_hba_down_post - Wrapper func for hba down post routine
1171 * 0 - success.
1172 * Any other value - error.
1177 return (*phba->lpfc_hba_down_post)(phba); in lpfc_hba_down_post()
1181 * lpfc_hb_timeout - The HBA-timer timeout handler
1184 * This is the HBA-timer timeout handler registered to the lpfc driver. When
1186 * work-port-events bitmap and the worker thread is notified. This timeout
1202 spin_lock_irqsave(&phba->pport->work_port_lock, iflag); in lpfc_hb_timeout()
1203 tmo_posted = phba->pport->work_port_events & WORKER_HB_TMO; in lpfc_hb_timeout()
1205 phba->pport->work_port_events |= WORKER_HB_TMO; in lpfc_hb_timeout()
1206 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); in lpfc_hb_timeout()
1215 * lpfc_rrq_timeout - The RRQ-timer timeout handler
1218 * This is the RRQ-timer timeout handler registered to the lpfc driver. When
1220 * work-port-events bitmap and the worker thread is notified. This timeout
1233 spin_lock_irqsave(&phba->pport->work_port_lock, iflag); in lpfc_rrq_timeout()
1234 if (!(phba->pport->load_flag & FC_UNLOADING)) in lpfc_rrq_timeout()
1235 phba->hba_flag |= HBA_RRQ_ACTIVE; in lpfc_rrq_timeout()
1237 phba->hba_flag &= ~HBA_RRQ_ACTIVE; in lpfc_rrq_timeout()
1238 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); in lpfc_rrq_timeout()
1240 if (!(phba->pport->load_flag & FC_UNLOADING)) in lpfc_rrq_timeout()
1245 * lpfc_hb_mbox_cmpl - The lpfc heart-beat mailbox command callback function
1249 * This is the callback function to the lpfc heart-beat mailbox command.
1250 * If configured, the lpfc driver issues the heart-beat mailbox command to
1252 * heart-beat mailbox command is issued, the driver shall set up heart-beat
1254 * heart-beat outstanding state. Once the mailbox command comes back and
1255 * no error conditions detected, the heart-beat mailbox command timer is
1256 * reset to LPFC_HB_MBOX_INTERVAL seconds and the heart-beat outstanding
1257 * state is cleared for the next heart-beat. If the timer expired with the
1258 * heart-beat outstanding state set, the driver will put the HBA offline.
1265 spin_lock_irqsave(&phba->hbalock, drvr_flag); in lpfc_hb_mbox_cmpl()
1266 phba->hba_flag &= ~(HBA_HBEAT_INP | HBA_HBEAT_TMO); in lpfc_hb_mbox_cmpl()
1267 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_hb_mbox_cmpl()
1269 /* Check and reset heart-beat timer if necessary */ in lpfc_hb_mbox_cmpl()
1270 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_hb_mbox_cmpl()
1271 if (!(phba->pport->fc_flag & FC_OFFLINE_MODE) && in lpfc_hb_mbox_cmpl()
1272 !(phba->link_state == LPFC_HBA_ERROR) && in lpfc_hb_mbox_cmpl()
1273 !(phba->pport->load_flag & FC_UNLOADING)) in lpfc_hb_mbox_cmpl()
1274 mod_timer(&phba->hb_tmofunc, in lpfc_hb_mbox_cmpl()
1281 * lpfc_idle_stat_delay_work - idle_stat tracking
1283 * This routine tracks per-eq idle_stat and determines polling decisions.
1300 if (phba->pport->load_flag & FC_UNLOADING) in lpfc_idle_stat_delay_work()
1303 if (phba->link_state == LPFC_HBA_ERROR || in lpfc_idle_stat_delay_work()
1304 phba->pport->fc_flag & FC_OFFLINE_MODE || in lpfc_idle_stat_delay_work()
1305 phba->cmf_active_mode != LPFC_CFG_OFF) in lpfc_idle_stat_delay_work()
1309 hdwq = &phba->sli4_hba.hdwq[phba->sli4_hba.cpu_map[i].hdwq]; in lpfc_idle_stat_delay_work()
1310 eq = hdwq->hba_eq; in lpfc_idle_stat_delay_work()
1312 /* Skip if we've already handled this eq's primary CPU */ in lpfc_idle_stat_delay_work()
1313 if (eq->chann != i) in lpfc_idle_stat_delay_work()
1316 idle_stat = &phba->sli4_hba.idle_stat[i]; in lpfc_idle_stat_delay_work()
1322 * percentage of 100 - the sum of the other consumption times. in lpfc_idle_stat_delay_work()
1325 diff_idle = wall_idle - idle_stat->prev_idle; in lpfc_idle_stat_delay_work()
1326 diff_wall = wall - idle_stat->prev_wall; in lpfc_idle_stat_delay_work()
1331 busy_time = diff_wall - diff_idle; in lpfc_idle_stat_delay_work()
1334 idle_percent = 100 - idle_percent; in lpfc_idle_stat_delay_work()
1337 eq->poll_mode = LPFC_QUEUE_WORK; in lpfc_idle_stat_delay_work()
1339 eq->poll_mode = LPFC_THREADED_IRQ; in lpfc_idle_stat_delay_work()
1341 idle_stat->prev_idle = wall_idle; in lpfc_idle_stat_delay_work()
1342 idle_stat->prev_wall = wall; in lpfc_idle_stat_delay_work()
1346 schedule_delayed_work(&phba->idle_stat_delay_work, in lpfc_idle_stat_delay_work()
1361 if (!phba->cfg_auto_imax || phba->pport->load_flag & FC_UNLOADING) in lpfc_hb_eq_delay_work()
1364 if (phba->link_state == LPFC_HBA_ERROR || in lpfc_hb_eq_delay_work()
1365 phba->pport->fc_flag & FC_OFFLINE_MODE) in lpfc_hb_eq_delay_work()
1368 ena_delay = kcalloc(phba->sli4_hba.num_possible_cpu, sizeof(*ena_delay), in lpfc_hb_eq_delay_work()
1373 for (i = 0; i < phba->cfg_irq_chann; i++) { in lpfc_hb_eq_delay_work()
1375 eq = phba->sli4_hba.hba_eq_hdl[i].eq; in lpfc_hb_eq_delay_work()
1378 if (eq->q_mode || eq->q_flag & HBA_EQ_DELAY_CHK) { in lpfc_hb_eq_delay_work()
1379 eq->q_flag &= ~HBA_EQ_DELAY_CHK; in lpfc_hb_eq_delay_work()
1380 ena_delay[eq->last_cpu] = 1; in lpfc_hb_eq_delay_work()
1385 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, i); in lpfc_hb_eq_delay_work()
1387 usdelay = (eqi->icnt >> 10) * LPFC_EQ_DELAY_STEP; in lpfc_hb_eq_delay_work()
1394 eqi->icnt = 0; in lpfc_hb_eq_delay_work()
1396 list_for_each_entry_safe(eq, eq_next, &eqi->list, cpu_list) { in lpfc_hb_eq_delay_work()
1397 if (unlikely(eq->last_cpu != i)) { in lpfc_hb_eq_delay_work()
1398 eqi_new = per_cpu_ptr(phba->sli4_hba.eq_info, in lpfc_hb_eq_delay_work()
1399 eq->last_cpu); in lpfc_hb_eq_delay_work()
1400 list_move_tail(&eq->cpu_list, &eqi_new->list); in lpfc_hb_eq_delay_work()
1403 if (usdelay != eq->q_mode) in lpfc_hb_eq_delay_work()
1404 lpfc_modify_hba_eq_delay(phba, eq->hdwq, 1, in lpfc_hb_eq_delay_work()
1412 queue_delayed_work(phba->wq, &phba->eq_delay_work, in lpfc_hb_eq_delay_work()
1417 * lpfc_hb_mxp_handler - Multi-XRI pools handler to adjust XRI distribution
1428 hwq_count = phba->cfg_hdw_queue; in lpfc_hb_mxp_handler()
1444 * lpfc_issue_hb_mbox - Issues heart-beat mailbox command
1458 if (phba->hba_flag & HBA_HBEAT_INP) in lpfc_issue_hb_mbox()
1461 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_issue_hb_mbox()
1463 return -ENOMEM; in lpfc_issue_hb_mbox()
1466 pmboxq->mbox_cmpl = lpfc_hb_mbox_cmpl; in lpfc_issue_hb_mbox()
1467 pmboxq->vport = phba->pport; in lpfc_issue_hb_mbox()
1471 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_issue_hb_mbox()
1472 return -ENXIO; in lpfc_issue_hb_mbox()
1474 phba->hba_flag |= HBA_HBEAT_INP; in lpfc_issue_hb_mbox()
1480 * lpfc_issue_hb_tmo - Signals heartbeat timer to issue mbox command
1492 if (phba->cfg_enable_hba_heartbeat) in lpfc_issue_hb_tmo()
1494 phba->hba_flag |= HBA_HBEAT_TMO; in lpfc_issue_hb_tmo()
1498 * lpfc_hb_timeout_handler - The HBA-timer timeout handler
1501 * This is the actual HBA-timer timeout handler to be invoked by the worker
1502 * thread whenever the HBA timer fired and HBA-timeout event posted. This
1505 * or by processing slow-ring or fast-ring events within the HBA-timer
1507 * the timer for the next timeout period. If lpfc heart-beat mailbox command
1508 * is configured and there is no heart-beat mailbox command outstanding, a
1509 * heart-beat mailbox is issued and timer set properly. Otherwise, if there
1510 * has been a heart-beat mailbox command outstanding, the HBA shall be put
1520 struct lpfc_sli *psli = &phba->sli; in lpfc_hb_timeout_handler()
1523 if (phba->cfg_xri_rebalancing) { in lpfc_hb_timeout_handler()
1524 /* Multi-XRI pools handler */ in lpfc_hb_timeout_handler()
1530 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_hb_timeout_handler()
1536 if ((phba->link_state == LPFC_HBA_ERROR) || in lpfc_hb_timeout_handler()
1537 (phba->pport->load_flag & FC_UNLOADING) || in lpfc_hb_timeout_handler()
1538 (phba->pport->fc_flag & FC_OFFLINE_MODE)) in lpfc_hb_timeout_handler()
1541 if (phba->elsbuf_cnt && in lpfc_hb_timeout_handler()
1542 (phba->elsbuf_cnt == phba->elsbuf_prev_cnt)) { in lpfc_hb_timeout_handler()
1543 spin_lock_irq(&phba->hbalock); in lpfc_hb_timeout_handler()
1544 list_splice_init(&phba->elsbuf, &completions); in lpfc_hb_timeout_handler()
1545 phba->elsbuf_cnt = 0; in lpfc_hb_timeout_handler()
1546 phba->elsbuf_prev_cnt = 0; in lpfc_hb_timeout_handler()
1547 spin_unlock_irq(&phba->hbalock); in lpfc_hb_timeout_handler()
1552 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); in lpfc_hb_timeout_handler()
1556 phba->elsbuf_prev_cnt = phba->elsbuf_cnt; in lpfc_hb_timeout_handler()
1559 if (phba->cfg_enable_hba_heartbeat) { in lpfc_hb_timeout_handler()
1561 spin_lock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1562 if (time_after(phba->last_completion_time + in lpfc_hb_timeout_handler()
1565 spin_unlock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1566 if (phba->hba_flag & HBA_HBEAT_INP) in lpfc_hb_timeout_handler()
1572 spin_unlock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1575 if (phba->hba_flag & HBA_HBEAT_INP) { in lpfc_hb_timeout_handler()
1585 - phba->last_completion_time)); in lpfc_hb_timeout_handler()
1588 if ((!(psli->sli_flag & LPFC_SLI_MBOX_ACTIVE)) && in lpfc_hb_timeout_handler()
1589 (list_empty(&psli->mboxq))) { in lpfc_hb_timeout_handler()
1596 phba->skipped_hb = 0; in lpfc_hb_timeout_handler()
1597 } else if (time_before_eq(phba->last_completion_time, in lpfc_hb_timeout_handler()
1598 phba->skipped_hb)) { in lpfc_hb_timeout_handler()
1603 - phba->last_completion_time)); in lpfc_hb_timeout_handler()
1605 phba->skipped_hb = jiffies; in lpfc_hb_timeout_handler()
1612 if (phba->hba_flag & HBA_HBEAT_TMO) { in lpfc_hb_timeout_handler()
1623 mod_timer(&phba->hb_tmofunc, jiffies + msecs_to_jiffies(tmo)); in lpfc_hb_timeout_handler()
1627 * lpfc_offline_eratt - Bring lpfc offline on hardware error attention
1636 struct lpfc_sli *psli = &phba->sli; in lpfc_offline_eratt()
1638 spin_lock_irq(&phba->hbalock); in lpfc_offline_eratt()
1639 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_offline_eratt()
1640 spin_unlock_irq(&phba->hbalock); in lpfc_offline_eratt()
1645 spin_lock_irq(&phba->hbalock); in lpfc_offline_eratt()
1647 spin_unlock_irq(&phba->hbalock); in lpfc_offline_eratt()
1651 phba->link_state = LPFC_HBA_ERROR; in lpfc_offline_eratt()
1656 * lpfc_sli4_offline_eratt - Bring lpfc offline on SLI4 hardware error attention
1665 spin_lock_irq(&phba->hbalock); in lpfc_sli4_offline_eratt()
1666 if (phba->link_state == LPFC_HBA_ERROR && in lpfc_sli4_offline_eratt()
1667 test_bit(HBA_PCI_ERR, &phba->bit_flags)) { in lpfc_sli4_offline_eratt()
1668 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_offline_eratt()
1671 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli4_offline_eratt()
1672 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_offline_eratt()
1682 * lpfc_handle_deferred_eratt - The HBA hardware deferred error handler
1693 uint32_t old_host_status = phba->work_hs; in lpfc_handle_deferred_eratt()
1694 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_deferred_eratt()
1699 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_deferred_eratt()
1700 spin_lock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1701 phba->hba_flag &= ~DEFER_ERATT; in lpfc_handle_deferred_eratt()
1702 spin_unlock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1709 phba->work_hs, phba->work_status[0], in lpfc_handle_deferred_eratt()
1710 phba->work_status[1]); in lpfc_handle_deferred_eratt()
1712 spin_lock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1713 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_handle_deferred_eratt()
1714 spin_unlock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1720 * SCSI layer retry it after re-establishing link. in lpfc_handle_deferred_eratt()
1732 while (phba->work_hs & HS_FFER1) { in lpfc_handle_deferred_eratt()
1734 if (lpfc_readl(phba->HSregaddr, &phba->work_hs)) { in lpfc_handle_deferred_eratt()
1735 phba->work_hs = UNPLUG_ERR ; in lpfc_handle_deferred_eratt()
1739 if (phba->pport->load_flag & FC_UNLOADING) { in lpfc_handle_deferred_eratt()
1740 phba->work_hs = 0; in lpfc_handle_deferred_eratt()
1750 if ((!phba->work_hs) && (!(phba->pport->load_flag & FC_UNLOADING))) in lpfc_handle_deferred_eratt()
1751 phba->work_hs = old_host_status & ~HS_FFER1; in lpfc_handle_deferred_eratt()
1753 spin_lock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1754 phba->hba_flag &= ~DEFER_ERATT; in lpfc_handle_deferred_eratt()
1755 spin_unlock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1756 phba->work_status[0] = readl(phba->MBslimaddr + 0xa8); in lpfc_handle_deferred_eratt()
1757 phba->work_status[1] = readl(phba->MBslimaddr + 0xac); in lpfc_handle_deferred_eratt()
1768 shost = lpfc_shost_from_vport(phba->pport); in lpfc_board_errevt_to_mgmt()
1776 * lpfc_handle_eratt_s3 - The SLI3 HBA hardware error handler
1781 * 1 - HBA error attention interrupt
1782 * 2 - DMA ring index out of range
1783 * 3 - Mailbox command came back as unknown
1788 struct lpfc_vport *vport = phba->pport; in lpfc_handle_eratt_s3()
1789 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_eratt_s3()
1798 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_eratt_s3()
1799 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1800 phba->hba_flag &= ~DEFER_ERATT; in lpfc_handle_eratt_s3()
1801 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1806 if (!phba->cfg_enable_hba_reset) in lpfc_handle_eratt_s3()
1812 if (phba->hba_flag & DEFER_ERATT) in lpfc_handle_eratt_s3()
1815 if ((phba->work_hs & HS_FFER6) || (phba->work_hs & HS_FFER8)) { in lpfc_handle_eratt_s3()
1816 if (phba->work_hs & HS_FFER6) in lpfc_handle_eratt_s3()
1817 /* Re-establishing Link */ in lpfc_handle_eratt_s3()
1819 "1301 Re-establishing Link " in lpfc_handle_eratt_s3()
1821 phba->work_hs, phba->work_status[0], in lpfc_handle_eratt_s3()
1822 phba->work_status[1]); in lpfc_handle_eratt_s3()
1823 if (phba->work_hs & HS_FFER8) in lpfc_handle_eratt_s3()
1828 phba->work_hs, phba->work_status[0], in lpfc_handle_eratt_s3()
1829 phba->work_status[1]); in lpfc_handle_eratt_s3()
1831 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1832 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_handle_eratt_s3()
1833 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1839 * retry it after re-establishing link. in lpfc_handle_eratt_s3()
1855 } else if (phba->work_hs & HS_CRIT_TEMP) { in lpfc_handle_eratt_s3()
1856 temperature = readl(phba->MBslimaddr + TEMPERATURE_OFFSET); in lpfc_handle_eratt_s3()
1865 temperature, phba->work_hs, in lpfc_handle_eratt_s3()
1866 phba->work_status[0], phba->work_status[1]); in lpfc_handle_eratt_s3()
1868 shost = lpfc_shost_from_vport(phba->pport); in lpfc_handle_eratt_s3()
1875 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1876 phba->over_temp_state = HBA_OVER_TEMP; in lpfc_handle_eratt_s3()
1877 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1888 phba->work_hs, in lpfc_handle_eratt_s3()
1889 phba->work_status[0], phba->work_status[1]); in lpfc_handle_eratt_s3()
1903 * lpfc_sli4_port_sta_fn_reset - The SLI4 function reset due to port status reg
1921 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_port_sta_fn_reset()
1943 spin_lock_irq(&phba->hbalock); in lpfc_sli4_port_sta_fn_reset()
1944 phba->sli.sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_sli4_port_sta_fn_reset()
1945 if (phba->sli.mbox_active) { in lpfc_sli4_port_sta_fn_reset()
1946 mboxq = phba->sli.mbox_active; in lpfc_sli4_port_sta_fn_reset()
1947 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_port_sta_fn_reset()
1949 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_port_sta_fn_reset()
1950 phba->sli.mbox_active = NULL; in lpfc_sli4_port_sta_fn_reset()
1952 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_port_sta_fn_reset()
1967 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_sli4_port_sta_fn_reset()
1971 return -EIO; in lpfc_sli4_port_sta_fn_reset()
1973 phba->intr_mode = intr_mode; in lpfc_sli4_port_sta_fn_reset()
1982 * lpfc_handle_eratt_s4 - The SLI4 HBA hardware error handler
1991 struct lpfc_vport *vport = phba->pport; in lpfc_handle_eratt_s4()
2007 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_eratt_s4()
2015 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_handle_eratt_s4()
2019 phba->sli4_hba.u.if_type0.UERRLOregaddr, in lpfc_handle_eratt_s4()
2022 phba->sli4_hba.u.if_type0.UEMASKLOregaddr, in lpfc_handle_eratt_s4()
2025 if (pci_rd_rc1 == -EIO && pci_rd_rc2 == -EIO) in lpfc_handle_eratt_s4()
2027 if (!(phba->hba_flag & HBA_RECOVERABLE_UE)) { in lpfc_handle_eratt_s4()
2034 for (i = 0; i < phba->sli4_hba.ue_to_sr / 1000; i++) { in lpfc_handle_eratt_s4()
2035 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_handle_eratt_s4()
2057 if (!lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_handle_eratt_s4()
2076 phba->link_state = LPFC_HBA_ERROR; in lpfc_handle_eratt_s4()
2082 phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_handle_eratt_s4()
2085 if (pci_rd_rc1 == -EIO) { in lpfc_handle_eratt_s4()
2088 readl(phba->sli4_hba.u.if_type2.STATUSregaddr)); in lpfc_handle_eratt_s4()
2092 reg_err1 = readl(phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_handle_eratt_s4()
2093 reg_err2 = readl(phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_handle_eratt_s4()
2100 phba->sfp_alarm |= LPFC_TRANSGRESSION_HIGH_TEMPERATURE; in lpfc_handle_eratt_s4()
2105 shost = lpfc_shost_from_vport(phba->pport); in lpfc_handle_eratt_s4()
2112 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s4()
2113 phba->over_temp_state = HBA_OVER_TEMP; in lpfc_handle_eratt_s4()
2114 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s4()
2134 if (!phba->cfg_enable_hba_reset) in lpfc_handle_eratt_s4()
2170 * lpfc_handle_eratt - Wrapper func for handling hba error attention
2177 * 0 - success.
2178 * Any other value - error.
2183 (*phba->lpfc_handle_eratt)(phba); in lpfc_handle_eratt()
2187 * lpfc_handle_latt - The HBA link event handler
2196 struct lpfc_vport *vport = phba->pport; in lpfc_handle_latt()
2197 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_latt()
2202 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_handle_latt()
2211 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_handle_latt()
2217 psli->slistat.link_event++; in lpfc_handle_latt()
2218 lpfc_read_topology(phba, pmb, (struct lpfc_dmabuf *)pmb->ctx_buf); in lpfc_handle_latt()
2219 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_handle_latt()
2220 pmb->vport = vport; in lpfc_handle_latt()
2222 phba->sli.sli3_ring[LPFC_ELS_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_handle_latt()
2230 spin_lock_irq(&phba->hbalock); in lpfc_handle_latt()
2231 writel(HA_LATT, phba->HAregaddr); in lpfc_handle_latt()
2232 readl(phba->HAregaddr); /* flush */ in lpfc_handle_latt()
2233 spin_unlock_irq(&phba->hbalock); in lpfc_handle_latt()
2238 phba->sli.sli3_ring[LPFC_ELS_RING].flag &= ~LPFC_STOP_IOCB_EVENT; in lpfc_handle_latt()
2242 spin_lock_irq(&phba->hbalock); in lpfc_handle_latt()
2243 psli->sli_flag |= LPFC_PROCESS_LA; in lpfc_handle_latt()
2244 control = readl(phba->HCregaddr); in lpfc_handle_latt()
2246 writel(control, phba->HCregaddr); in lpfc_handle_latt()
2247 readl(phba->HCregaddr); /* flush */ in lpfc_handle_latt()
2250 writel(HA_LATT, phba->HAregaddr); in lpfc_handle_latt()
2251 readl(phba->HAregaddr); /* flush */ in lpfc_handle_latt()
2252 spin_unlock_irq(&phba->hbalock); in lpfc_handle_latt()
2254 phba->link_state = LPFC_HBA_ERROR; in lpfc_handle_latt()
2274 length -= (3+i); in lpfc_fill_vpd()
2275 while (i--) { in lpfc_fill_vpd()
2276 phba->SerialNumber[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2280 phba->SerialNumber[j] = 0; in lpfc_fill_vpd()
2283 phba->vpd_flag |= VPD_MODEL_DESC; in lpfc_fill_vpd()
2288 length -= (3+i); in lpfc_fill_vpd()
2289 while (i--) { in lpfc_fill_vpd()
2290 phba->ModelDesc[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2294 phba->ModelDesc[j] = 0; in lpfc_fill_vpd()
2297 phba->vpd_flag |= VPD_MODEL_NAME; in lpfc_fill_vpd()
2302 length -= (3+i); in lpfc_fill_vpd()
2303 while (i--) { in lpfc_fill_vpd()
2304 phba->ModelName[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2308 phba->ModelName[j] = 0; in lpfc_fill_vpd()
2311 phba->vpd_flag |= VPD_PROGRAM_TYPE; in lpfc_fill_vpd()
2316 length -= (3+i); in lpfc_fill_vpd()
2317 while (i--) { in lpfc_fill_vpd()
2318 phba->ProgramType[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2322 phba->ProgramType[j] = 0; in lpfc_fill_vpd()
2325 phba->vpd_flag |= VPD_PORT; in lpfc_fill_vpd()
2330 length -= (3 + i); in lpfc_fill_vpd()
2331 while (i--) { in lpfc_fill_vpd()
2332 if ((phba->sli_rev == LPFC_SLI_REV4) && in lpfc_fill_vpd()
2333 (phba->sli4_hba.pport_name_sta == in lpfc_fill_vpd()
2338 phba->Port[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2342 if ((phba->sli_rev != LPFC_SLI_REV4) || in lpfc_fill_vpd()
2343 (phba->sli4_hba.pport_name_sta == in lpfc_fill_vpd()
2345 phba->Port[j] = 0; in lpfc_fill_vpd()
2352 length -= (3 + i); in lpfc_fill_vpd()
2358 * lpfc_parse_vpd - Parse VPD (Vital Product Data)
2368 * 0 - pointer to the VPD passed in is NULL
2369 * 1 - success
2388 while (!finished && (index < (len - 4))) { in lpfc_parse_vpd()
2407 if (Length > len - index) in lpfc_parse_vpd()
2408 Length = len - index; in lpfc_parse_vpd()
2426 * lpfc_get_atto_model_desc - Retrieve ATTO HBA device model name and description
2440 uint16_t sub_dev_id = phba->pcidev->subsystem_device; in lpfc_get_atto_model_desc()
2504 (tbolt) ? "ThunderLink FC " : "Celerity FC-", in lpfc_get_atto_model_desc()
2506 phba->Port); in lpfc_get_atto_model_desc()
2510 * lpfc_get_hba_model_desc - Retrieve HBA device model name and description
2525 uint16_t dev_id = phba->pcidev->device; in lpfc_get_hba_model_desc()
2539 if (phba->pcidev->vendor == PCI_VENDOR_ID_ATTO) { in lpfc_get_hba_model_desc()
2544 if (phba->lmt & LMT_64Gb) in lpfc_get_hba_model_desc()
2546 else if (phba->lmt & LMT_32Gb) in lpfc_get_hba_model_desc()
2548 else if (phba->lmt & LMT_16Gb) in lpfc_get_hba_model_desc()
2550 else if (phba->lmt & LMT_10Gb) in lpfc_get_hba_model_desc()
2552 else if (phba->lmt & LMT_8Gb) in lpfc_get_hba_model_desc()
2554 else if (phba->lmt & LMT_4Gb) in lpfc_get_hba_model_desc()
2556 else if (phba->lmt & LMT_2Gb) in lpfc_get_hba_model_desc()
2558 else if (phba->lmt & LMT_1Gb) in lpfc_get_hba_model_desc()
2563 vp = &phba->vpd; in lpfc_get_hba_model_desc()
2571 if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3) in lpfc_get_hba_model_desc()
2582 if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID) in lpfc_get_hba_model_desc()
2593 m = (typeof(m)){"LP9802", "PCI-X", in lpfc_get_hba_model_desc()
2597 m = (typeof(m)){"LP10000", "PCI-X", in lpfc_get_hba_model_desc()
2601 m = (typeof(m)){"LPX1000", "PCI-X", in lpfc_get_hba_model_desc()
2605 m = (typeof(m)){"LP982", "PCI-X", in lpfc_get_hba_model_desc()
2609 m = (typeof(m)){"LP1050", "PCI-X", in lpfc_get_hba_model_desc()
2613 m = (typeof(m)){"LP11000", "PCI-X2", in lpfc_get_hba_model_desc()
2617 m = (typeof(m)){"LP11000-SP", "PCI-X2", in lpfc_get_hba_model_desc()
2621 m = (typeof(m)){"LP11002-SP", "PCI-X2", in lpfc_get_hba_model_desc()
2629 m = (typeof(m)){"LPe1000-SP", "PCIe", in lpfc_get_hba_model_desc()
2633 m = (typeof(m)){"LPe1002-SP", "PCIe", in lpfc_get_hba_model_desc()
2637 m = (typeof(m)){"LP1150", "PCI-X2", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2640 m = (typeof(m)){"LP111", "PCI-X2", in lpfc_get_hba_model_desc()
2660 m = (typeof(m)){"LP101", "PCI-X", in lpfc_get_hba_model_desc()
2664 m = (typeof(m)){"LP10000-S", "PCI", in lpfc_get_hba_model_desc()
2668 m = (typeof(m)){"LP11000-S", "PCI-X2", in lpfc_get_hba_model_desc()
2672 m = (typeof(m)){"LPe11000-S", "PCIe", in lpfc_get_hba_model_desc()
2685 m = (typeof(m)){"LPe12002-SP", "PCIe", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2688 m = (typeof(m)){"LPe12000-SP", "PCIe", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2691 m = (typeof(m)){"LPe12000-S", "PCIe", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2702 m = (typeof(m)){"LPemv12002-S", "PCIe IOV", in lpfc_get_hba_model_desc()
2714 m = (typeof(m)){"LPSe12002-ML1-E", "PCIe", in lpfc_get_hba_model_desc()
2767 phba->Port); in lpfc_get_hba_model_desc()
2781 * lpfc_sli3_post_buffer - Post IOCB(s) with DMA buffer descriptor(s) to a IOCB ring
2799 cnt += pring->missbufcnt; in lpfc_sli3_post_buffer()
2806 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2809 icmd = &iocb->iocb; in lpfc_sli3_post_buffer()
2815 mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &mp1->phys); in lpfc_sli3_post_buffer()
2816 if (!mp1 || !mp1->virt) { in lpfc_sli3_post_buffer()
2819 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2823 INIT_LIST_HEAD(&mp1->list); in lpfc_sli3_post_buffer()
2828 mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI, in lpfc_sli3_post_buffer()
2829 &mp2->phys); in lpfc_sli3_post_buffer()
2830 if (!mp2 || !mp2->virt) { in lpfc_sli3_post_buffer()
2832 lpfc_mbuf_free(phba, mp1->virt, mp1->phys); in lpfc_sli3_post_buffer()
2835 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2839 INIT_LIST_HEAD(&mp2->list); in lpfc_sli3_post_buffer()
2844 icmd->un.cont64[0].addrHigh = putPaddrHigh(mp1->phys); in lpfc_sli3_post_buffer()
2845 icmd->un.cont64[0].addrLow = putPaddrLow(mp1->phys); in lpfc_sli3_post_buffer()
2846 icmd->un.cont64[0].tus.f.bdeSize = FCELSSIZE; in lpfc_sli3_post_buffer()
2847 icmd->ulpBdeCount = 1; in lpfc_sli3_post_buffer()
2848 cnt--; in lpfc_sli3_post_buffer()
2850 icmd->un.cont64[1].addrHigh = putPaddrHigh(mp2->phys); in lpfc_sli3_post_buffer()
2851 icmd->un.cont64[1].addrLow = putPaddrLow(mp2->phys); in lpfc_sli3_post_buffer()
2852 icmd->un.cont64[1].tus.f.bdeSize = FCELSSIZE; in lpfc_sli3_post_buffer()
2853 cnt--; in lpfc_sli3_post_buffer()
2854 icmd->ulpBdeCount = 2; in lpfc_sli3_post_buffer()
2857 icmd->ulpCommand = CMD_QUE_RING_BUF64_CN; in lpfc_sli3_post_buffer()
2858 icmd->ulpLe = 1; in lpfc_sli3_post_buffer()
2860 if (lpfc_sli_issue_iocb(phba, pring->ringno, iocb, 0) == in lpfc_sli3_post_buffer()
2862 lpfc_mbuf_free(phba, mp1->virt, mp1->phys); in lpfc_sli3_post_buffer()
2866 lpfc_mbuf_free(phba, mp2->virt, mp2->phys); in lpfc_sli3_post_buffer()
2871 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2878 pring->missbufcnt = 0; in lpfc_sli3_post_buffer()
2883 * lpfc_post_rcv_buf - Post the initial receive IOCB buffers to ELS ring
2891 * 0 - success (currently always success)
2896 struct lpfc_sli *psli = &phba->sli; in lpfc_post_rcv_buf()
2899 lpfc_sli3_post_buffer(phba, &psli->sli3_ring[LPFC_ELS_RING], LPFC_BUF_RING0); in lpfc_post_rcv_buf()
2900 /* Ring 2 - FCP no buffers needed */ in lpfc_post_rcv_buf()
2905 #define S(N,V) (((V)<<(N))|((V)>>(32-(N))))
2908 * lpfc_sha_init - Set up initial array of hash table entries
2925 * lpfc_sha_iterate - Iterate initial hash table with the working hash table
2944 HashWorkingPointer[t - 3] ^ HashWorkingPointer[t - in lpfc_sha_iterate()
2946 HashWorkingPointer[t - 14] ^ HashWorkingPointer[t - 16]); in lpfc_sha_iterate()
2982 * lpfc_challenge_key - Create challenge key based on WWPN of the HBA
2998 * lpfc_hba_init - Perform special handling for LC HBA initialization
3000 * @hbainit: pointer to an array of unsigned 32-bit integers.
3009 uint32_t *pwwnn = (uint32_t *) phba->wwnn; in lpfc_hba_init()
3019 lpfc_challenge_key(phba->RandomData + t, HashWorking + t); in lpfc_hba_init()
3027 * lpfc_cleanup - Performs vport cleanups before deleting a vport
3038 struct lpfc_hba *phba = vport->phba; in lpfc_cleanup()
3042 if (phba->link_state > LPFC_LINK_DOWN) in lpfc_cleanup()
3049 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { in lpfc_cleanup()
3050 if (vport->port_type != LPFC_PHYSICAL_PORT && in lpfc_cleanup()
3051 ndlp->nlp_DID == Fabric_DID) { in lpfc_cleanup()
3057 if (ndlp->nlp_DID == Fabric_Cntl_DID && in lpfc_cleanup()
3058 ndlp->nlp_state == NLP_STE_UNUSED_NODE) { in lpfc_cleanup()
3066 if (ndlp->nlp_type & NLP_FABRIC && in lpfc_cleanup()
3067 ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) in lpfc_cleanup()
3071 if (!(ndlp->fc4_xpt_flags & (NVME_XPT_REGD|SCSI_XPT_REGD))) in lpfc_cleanup()
3088 if (vport->load_flag & FC_UNLOADING && in lpfc_cleanup()
3089 pci_channel_offline(phba->pcidev)) in lpfc_cleanup()
3090 lpfc_sli_flush_io_rings(vport->phba); in lpfc_cleanup()
3096 while (!list_empty(&vport->fc_nodes)) { in lpfc_cleanup()
3102 &vport->fc_nodes, nlp_listp) { in lpfc_cleanup()
3103 lpfc_printf_vlog(ndlp->vport, KERN_ERR, in lpfc_cleanup()
3107 ndlp->nlp_DID, (void *)ndlp, in lpfc_cleanup()
3108 kref_read(&ndlp->kref), in lpfc_cleanup()
3109 ndlp->fc4_xpt_flags, in lpfc_cleanup()
3110 ndlp->nlp_flag); in lpfc_cleanup()
3122 * lpfc_stop_vport_timers - Stop all the timers associated with a vport
3132 del_timer_sync(&vport->els_tmofunc); in lpfc_stop_vport_timers()
3133 del_timer_sync(&vport->delayed_disc_tmo); in lpfc_stop_vport_timers()
3139 * __lpfc_sli4_stop_fcf_redisc_wait_timer - Stop FCF rediscovery wait timer
3149 phba->fcf.fcf_flag &= ~FCF_REDISC_PEND; in __lpfc_sli4_stop_fcf_redisc_wait_timer()
3152 del_timer(&phba->fcf.redisc_wait); in __lpfc_sli4_stop_fcf_redisc_wait_timer()
3156 * lpfc_sli4_stop_fcf_redisc_wait_timer - Stop FCF rediscovery wait timer
3167 spin_lock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3168 if (!(phba->fcf.fcf_flag & FCF_REDISC_PEND)) { in lpfc_sli4_stop_fcf_redisc_wait_timer()
3170 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3175 phba->fcf.fcf_flag &= ~(FCF_DEAD_DISC | FCF_ACVL_DISC); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3176 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3180 * lpfc_cmf_stop - Stop CMF processing
3190 int cpu; in lpfc_cmf_stop() local
3194 if (!phba->sli4_hba.pc_sli4_params.cmf) in lpfc_cmf_stop()
3201 hrtimer_cancel(&phba->cmf_stats_timer); in lpfc_cmf_stop()
3202 hrtimer_cancel(&phba->cmf_timer); in lpfc_cmf_stop()
3205 atomic_set(&phba->cmf_busy, 0); in lpfc_cmf_stop()
3206 for_each_present_cpu(cpu) { in lpfc_cmf_stop()
3207 cgs = per_cpu_ptr(phba->cmf_stat, cpu); in lpfc_cmf_stop()
3208 atomic64_set(&cgs->total_bytes, 0); in lpfc_cmf_stop()
3209 atomic64_set(&cgs->rcv_bytes, 0); in lpfc_cmf_stop()
3210 atomic_set(&cgs->rx_io_cnt, 0); in lpfc_cmf_stop()
3211 atomic64_set(&cgs->rx_latency, 0); in lpfc_cmf_stop()
3213 atomic_set(&phba->cmf_bw_wait, 0); in lpfc_cmf_stop()
3215 /* Resume any blocked IO - Queue unblock on workqueue */ in lpfc_cmf_stop()
3216 queue_work(phba->wq, &phba->unblock_request_work); in lpfc_cmf_stop()
3234 phba->cmf_interval_rate = LPFC_CMF_INTERVAL; in lpfc_cmf_signal_init()
3235 phba->cmf_max_line_rate = lpfc_get_max_line_rate(phba); in lpfc_cmf_signal_init()
3236 phba->cmf_link_byte_count = div_u64(phba->cmf_max_line_rate * in lpfc_cmf_signal_init()
3237 phba->cmf_interval_rate, 1000); in lpfc_cmf_signal_init()
3238 phba->cmf_max_bytes_per_interval = phba->cmf_link_byte_count; in lpfc_cmf_signal_init()
3245 * lpfc_cmf_start - Start CMF processing
3255 int cpu; in lpfc_cmf_start() local
3258 if (!phba->sli4_hba.pc_sli4_params.cmf || in lpfc_cmf_start()
3259 phba->cmf_active_mode == LPFC_CFG_OFF) in lpfc_cmf_start()
3265 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_cmf_start()
3266 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_cmf_start()
3267 atomic_set(&phba->cgn_sync_alarm_cnt, 0); in lpfc_cmf_start()
3268 atomic_set(&phba->cgn_sync_warn_cnt, 0); in lpfc_cmf_start()
3270 atomic_set(&phba->cmf_busy, 0); in lpfc_cmf_start()
3271 for_each_present_cpu(cpu) { in lpfc_cmf_start()
3272 cgs = per_cpu_ptr(phba->cmf_stat, cpu); in lpfc_cmf_start()
3273 atomic64_set(&cgs->total_bytes, 0); in lpfc_cmf_start()
3274 atomic64_set(&cgs->rcv_bytes, 0); in lpfc_cmf_start()
3275 atomic_set(&cgs->rx_io_cnt, 0); in lpfc_cmf_start()
3276 atomic64_set(&cgs->rx_latency, 0); in lpfc_cmf_start()
3278 phba->cmf_latency.tv_sec = 0; in lpfc_cmf_start()
3279 phba->cmf_latency.tv_nsec = 0; in lpfc_cmf_start()
3286 phba->cmf_timer_cnt = 0; in lpfc_cmf_start()
3287 hrtimer_start(&phba->cmf_timer, in lpfc_cmf_start()
3290 hrtimer_start(&phba->cmf_stats_timer, in lpfc_cmf_start()
3294 ktime_get_real_ts64(&phba->cmf_latency); in lpfc_cmf_start()
3296 atomic_set(&phba->cmf_bw_wait, 0); in lpfc_cmf_start()
3297 atomic_set(&phba->cmf_stop_io, 0); in lpfc_cmf_start()
3301 * lpfc_stop_hba_timers - Stop all the timers associated with an HBA
3310 if (phba->pport) in lpfc_stop_hba_timers()
3311 lpfc_stop_vport_timers(phba->pport); in lpfc_stop_hba_timers()
3312 cancel_delayed_work_sync(&phba->eq_delay_work); in lpfc_stop_hba_timers()
3313 cancel_delayed_work_sync(&phba->idle_stat_delay_work); in lpfc_stop_hba_timers()
3314 del_timer_sync(&phba->sli.mbox_tmo); in lpfc_stop_hba_timers()
3315 del_timer_sync(&phba->fabric_block_timer); in lpfc_stop_hba_timers()
3316 del_timer_sync(&phba->eratt_poll); in lpfc_stop_hba_timers()
3317 del_timer_sync(&phba->hb_tmofunc); in lpfc_stop_hba_timers()
3318 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_stop_hba_timers()
3319 del_timer_sync(&phba->rrq_tmr); in lpfc_stop_hba_timers()
3320 phba->hba_flag &= ~HBA_RRQ_ACTIVE; in lpfc_stop_hba_timers()
3322 phba->hba_flag &= ~(HBA_HBEAT_INP | HBA_HBEAT_TMO); in lpfc_stop_hba_timers()
3324 switch (phba->pci_dev_grp) { in lpfc_stop_hba_timers()
3327 del_timer_sync(&phba->fcp_poll_timer); in lpfc_stop_hba_timers()
3336 phba->pci_dev_grp); in lpfc_stop_hba_timers()
3343 * lpfc_block_mgmt_io - Mark a HBA's management interface as blocked
3360 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3361 phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO; in lpfc_block_mgmt_io()
3362 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3366 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3367 if (phba->sli.mbox_active) { in lpfc_block_mgmt_io()
3368 actcmd = phba->sli.mbox_active->u.mb.mbxCommand; in lpfc_block_mgmt_io()
3373 phba->sli.mbox_active) * 1000) + jiffies; in lpfc_block_mgmt_io()
3375 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3378 while (phba->sli.mbox_active) { in lpfc_block_mgmt_io()
3384 "- mbox cmd %x still active\n", in lpfc_block_mgmt_io()
3385 phba->sli.sli_flag, actcmd); in lpfc_block_mgmt_io()
3392 * lpfc_sli4_node_prep - Assign RPIs for active nodes.
3406 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_sli4_node_prep()
3413 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_sli4_node_prep()
3414 if (vports[i]->load_flag & FC_UNLOADING) in lpfc_sli4_node_prep()
3418 &vports[i]->fc_nodes, in lpfc_sli4_node_prep()
3425 ndlp->nlp_rpi = rpi; in lpfc_sli4_node_prep()
3426 lpfc_printf_vlog(ndlp->vport, KERN_INFO, in lpfc_sli4_node_prep()
3430 ndlp->nlp_rpi, ndlp, ndlp->nlp_DID, in lpfc_sli4_node_prep()
3431 ndlp->nlp_flag); in lpfc_sli4_node_prep()
3438 * lpfc_create_expedite_pool - create expedite pool
3452 epd_pool = &phba->epd_pool; in lpfc_create_expedite_pool()
3453 qp = &phba->sli4_hba.hdwq[0]; in lpfc_create_expedite_pool()
3455 spin_lock_init(&epd_pool->lock); in lpfc_create_expedite_pool()
3456 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_create_expedite_pool()
3457 spin_lock(&epd_pool->lock); in lpfc_create_expedite_pool()
3458 INIT_LIST_HEAD(&epd_pool->list); in lpfc_create_expedite_pool()
3460 &qp->lpfc_io_buf_list_put, list) { in lpfc_create_expedite_pool()
3461 list_move_tail(&lpfc_ncmd->list, &epd_pool->list); in lpfc_create_expedite_pool()
3462 lpfc_ncmd->expedite = true; in lpfc_create_expedite_pool()
3463 qp->put_io_bufs--; in lpfc_create_expedite_pool()
3464 epd_pool->count++; in lpfc_create_expedite_pool()
3465 if (epd_pool->count >= XRI_BATCH) in lpfc_create_expedite_pool()
3468 spin_unlock(&epd_pool->lock); in lpfc_create_expedite_pool()
3469 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_create_expedite_pool()
3473 * lpfc_destroy_expedite_pool - destroy expedite pool
3487 epd_pool = &phba->epd_pool; in lpfc_destroy_expedite_pool()
3488 qp = &phba->sli4_hba.hdwq[0]; in lpfc_destroy_expedite_pool()
3490 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_expedite_pool()
3491 spin_lock(&epd_pool->lock); in lpfc_destroy_expedite_pool()
3493 &epd_pool->list, list) { in lpfc_destroy_expedite_pool()
3494 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_expedite_pool()
3495 &qp->lpfc_io_buf_list_put); in lpfc_destroy_expedite_pool()
3496 lpfc_ncmd->flags = false; in lpfc_destroy_expedite_pool()
3497 qp->put_io_bufs++; in lpfc_destroy_expedite_pool()
3498 epd_pool->count--; in lpfc_destroy_expedite_pool()
3500 spin_unlock(&epd_pool->lock); in lpfc_destroy_expedite_pool()
3501 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_expedite_pool()
3505 * lpfc_create_multixri_pools - create multi-XRI pools
3527 phba->cfg_hdw_queue, phba->sli4_hba.num_present_cpu, in lpfc_create_multixri_pools()
3528 phba->sli4_hba.io_xri_cnt); in lpfc_create_multixri_pools()
3530 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_create_multixri_pools()
3533 hwq_count = phba->cfg_hdw_queue; in lpfc_create_multixri_pools()
3534 count_per_hwq = phba->sli4_hba.io_xri_cnt / hwq_count; in lpfc_create_multixri_pools()
3544 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_create_multixri_pools()
3549 qp = &phba->sli4_hba.hdwq[j]; in lpfc_create_multixri_pools()
3550 kfree(qp->p_multixri_pool); in lpfc_create_multixri_pools()
3553 phba->cfg_xri_rebalancing = 0; in lpfc_create_multixri_pools()
3557 qp = &phba->sli4_hba.hdwq[i]; in lpfc_create_multixri_pools()
3558 qp->p_multixri_pool = multixri_pool; in lpfc_create_multixri_pools()
3560 multixri_pool->xri_limit = count_per_hwq; in lpfc_create_multixri_pools()
3561 multixri_pool->rrb_next_hwqid = i; in lpfc_create_multixri_pools()
3564 pbl_pool = &multixri_pool->pbl_pool; in lpfc_create_multixri_pools()
3565 spin_lock_init(&pbl_pool->lock); in lpfc_create_multixri_pools()
3566 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_create_multixri_pools()
3567 spin_lock(&pbl_pool->lock); in lpfc_create_multixri_pools()
3568 INIT_LIST_HEAD(&pbl_pool->list); in lpfc_create_multixri_pools()
3570 &qp->lpfc_io_buf_list_put, list) { in lpfc_create_multixri_pools()
3571 list_move_tail(&lpfc_ncmd->list, &pbl_pool->list); in lpfc_create_multixri_pools()
3572 qp->put_io_bufs--; in lpfc_create_multixri_pools()
3573 pbl_pool->count++; in lpfc_create_multixri_pools()
3577 pbl_pool->count, i); in lpfc_create_multixri_pools()
3578 spin_unlock(&pbl_pool->lock); in lpfc_create_multixri_pools()
3579 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_create_multixri_pools()
3582 pvt_pool = &multixri_pool->pvt_pool; in lpfc_create_multixri_pools()
3583 pvt_pool->high_watermark = multixri_pool->xri_limit / 2; in lpfc_create_multixri_pools()
3584 pvt_pool->low_watermark = XRI_BATCH; in lpfc_create_multixri_pools()
3585 spin_lock_init(&pvt_pool->lock); in lpfc_create_multixri_pools()
3586 spin_lock_irqsave(&pvt_pool->lock, iflag); in lpfc_create_multixri_pools()
3587 INIT_LIST_HEAD(&pvt_pool->list); in lpfc_create_multixri_pools()
3588 pvt_pool->count = 0; in lpfc_create_multixri_pools()
3589 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_create_multixri_pools()
3594 * lpfc_destroy_multixri_pools - destroy multi-XRI pools
3611 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_destroy_multixri_pools()
3614 if (!(phba->pport->load_flag & FC_UNLOADING)) in lpfc_destroy_multixri_pools()
3617 hwq_count = phba->cfg_hdw_queue; in lpfc_destroy_multixri_pools()
3620 qp = &phba->sli4_hba.hdwq[i]; in lpfc_destroy_multixri_pools()
3621 multixri_pool = qp->p_multixri_pool; in lpfc_destroy_multixri_pools()
3625 qp->p_multixri_pool = NULL; in lpfc_destroy_multixri_pools()
3627 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_multixri_pools()
3630 pbl_pool = &multixri_pool->pbl_pool; in lpfc_destroy_multixri_pools()
3631 spin_lock(&pbl_pool->lock); in lpfc_destroy_multixri_pools()
3635 pbl_pool->count, i); in lpfc_destroy_multixri_pools()
3638 &pbl_pool->list, list) { in lpfc_destroy_multixri_pools()
3639 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_multixri_pools()
3640 &qp->lpfc_io_buf_list_put); in lpfc_destroy_multixri_pools()
3641 qp->put_io_bufs++; in lpfc_destroy_multixri_pools()
3642 pbl_pool->count--; in lpfc_destroy_multixri_pools()
3645 INIT_LIST_HEAD(&pbl_pool->list); in lpfc_destroy_multixri_pools()
3646 pbl_pool->count = 0; in lpfc_destroy_multixri_pools()
3648 spin_unlock(&pbl_pool->lock); in lpfc_destroy_multixri_pools()
3651 pvt_pool = &multixri_pool->pvt_pool; in lpfc_destroy_multixri_pools()
3652 spin_lock(&pvt_pool->lock); in lpfc_destroy_multixri_pools()
3656 pvt_pool->count, i); in lpfc_destroy_multixri_pools()
3659 &pvt_pool->list, list) { in lpfc_destroy_multixri_pools()
3660 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_multixri_pools()
3661 &qp->lpfc_io_buf_list_put); in lpfc_destroy_multixri_pools()
3662 qp->put_io_bufs++; in lpfc_destroy_multixri_pools()
3663 pvt_pool->count--; in lpfc_destroy_multixri_pools()
3666 INIT_LIST_HEAD(&pvt_pool->list); in lpfc_destroy_multixri_pools()
3667 pvt_pool->count = 0; in lpfc_destroy_multixri_pools()
3669 spin_unlock(&pvt_pool->lock); in lpfc_destroy_multixri_pools()
3670 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_multixri_pools()
3677 * lpfc_online - Initialize and bring a HBA online
3685 * 0 - successful
3686 * 1 - failed
3698 vport = phba->pport; in lpfc_online()
3700 if (!(vport->fc_flag & FC_OFFLINE_MODE)) in lpfc_online()
3708 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_online()
3713 spin_lock_irq(&phba->hbalock); in lpfc_online()
3714 if (!phba->sli4_hba.max_cfg_param.vpi_used) in lpfc_online()
3716 spin_unlock_irq(&phba->hbalock); in lpfc_online()
3721 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME && in lpfc_online()
3722 !phba->nvmet_support) { in lpfc_online()
3723 error = lpfc_nvme_create_localport(phba->pport); in lpfc_online()
3739 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_online()
3742 spin_lock_irq(shost->host_lock); in lpfc_online()
3743 vports[i]->fc_flag &= ~FC_OFFLINE_MODE; in lpfc_online()
3744 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) in lpfc_online()
3745 vports[i]->fc_flag |= FC_VPORT_NEEDS_REG_VPI; in lpfc_online()
3746 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_online()
3747 vports[i]->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; in lpfc_online()
3749 (vports[i]->port_type != in lpfc_online()
3751 vports[i]->vpi = 0; in lpfc_online()
3753 spin_unlock_irq(shost->host_lock); in lpfc_online()
3758 if (phba->cfg_xri_rebalancing) in lpfc_online()
3768 * lpfc_unblock_mgmt_io - Mark a HBA's management interface to be not blocked
3783 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_unblock_mgmt_io()
3784 phba->sli.sli_flag &= ~LPFC_BLOCK_MGMT_IO; in lpfc_unblock_mgmt_io()
3785 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_unblock_mgmt_io()
3789 * lpfc_offline_prep - Prepare a HBA to be brought offline
3800 struct lpfc_vport *vport = phba->pport; in lpfc_offline_prep()
3808 if (vport->fc_flag & FC_OFFLINE_MODE) in lpfc_offline_prep()
3815 offline = pci_channel_offline(phba->pcidev); in lpfc_offline_prep()
3816 hba_pci_err = test_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_offline_prep()
3821 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_offline_prep()
3822 if (vports[i]->load_flag & FC_UNLOADING) in lpfc_offline_prep()
3825 spin_lock_irq(shost->host_lock); in lpfc_offline_prep()
3826 vports[i]->vpi_state &= ~LPFC_VPI_REGISTERED; in lpfc_offline_prep()
3827 vports[i]->fc_flag |= FC_VPORT_NEEDS_REG_VPI; in lpfc_offline_prep()
3828 vports[i]->fc_flag &= ~FC_VFI_REGISTERED; in lpfc_offline_prep()
3829 spin_unlock_irq(shost->host_lock); in lpfc_offline_prep()
3833 &vports[i]->fc_nodes, in lpfc_offline_prep()
3836 spin_lock_irq(&ndlp->lock); in lpfc_offline_prep()
3837 ndlp->nlp_flag &= ~NLP_NPR_ADISC; in lpfc_offline_prep()
3838 spin_unlock_irq(&ndlp->lock); in lpfc_offline_prep()
3841 spin_lock_irq(&ndlp->lock); in lpfc_offline_prep()
3842 ndlp->nlp_flag &= ~(NLP_UNREG_INP | in lpfc_offline_prep()
3844 spin_unlock_irq(&ndlp->lock); in lpfc_offline_prep()
3845 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_offline_prep()
3856 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_offline_prep()
3861 ndlp->nlp_rpi, ndlp, in lpfc_offline_prep()
3862 ndlp->nlp_DID); in lpfc_offline_prep()
3863 lpfc_sli4_free_rpi(phba, ndlp->nlp_rpi); in lpfc_offline_prep()
3864 ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR; in lpfc_offline_prep()
3867 if (ndlp->nlp_type & NLP_FABRIC) { in lpfc_offline_prep()
3878 if (!(ndlp->save_flags & in lpfc_offline_prep()
3880 !(ndlp->fc4_xpt_flags & in lpfc_offline_prep()
3894 if (phba->wq) in lpfc_offline_prep()
3895 flush_workqueue(phba->wq); in lpfc_offline_prep()
3899 * lpfc_offline - Bring a HBA offline
3913 if (phba->pport->fc_flag & FC_OFFLINE_MODE) in lpfc_offline()
3923 lpfc_nvme_destroy_localport(phba->pport); in lpfc_offline()
3927 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) in lpfc_offline()
3935 spin_lock_irq(&phba->hbalock); in lpfc_offline()
3936 phba->work_ha = 0; in lpfc_offline()
3937 spin_unlock_irq(&phba->hbalock); in lpfc_offline()
3940 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_offline()
3942 spin_lock_irq(shost->host_lock); in lpfc_offline()
3943 vports[i]->work_port_events = 0; in lpfc_offline()
3944 vports[i]->fc_flag |= FC_OFFLINE_MODE; in lpfc_offline()
3945 spin_unlock_irq(shost->host_lock); in lpfc_offline()
3951 if (phba->pport->fc_flag & FC_OFFLINE_MODE) in lpfc_offline()
3954 if (phba->cfg_xri_rebalancing) in lpfc_offline()
3959 * lpfc_scsi_free - Free all the SCSI buffers and IOCBs from driver lists
3971 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_scsi_free()
3974 spin_lock_irq(&phba->hbalock); in lpfc_scsi_free()
3978 spin_lock(&phba->scsi_buf_list_put_lock); in lpfc_scsi_free()
3979 list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list_put, in lpfc_scsi_free()
3981 list_del(&sb->list); in lpfc_scsi_free()
3982 dma_pool_free(phba->lpfc_sg_dma_buf_pool, sb->data, in lpfc_scsi_free()
3983 sb->dma_handle); in lpfc_scsi_free()
3985 phba->total_scsi_bufs--; in lpfc_scsi_free()
3987 spin_unlock(&phba->scsi_buf_list_put_lock); in lpfc_scsi_free()
3989 spin_lock(&phba->scsi_buf_list_get_lock); in lpfc_scsi_free()
3990 list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list_get, in lpfc_scsi_free()
3992 list_del(&sb->list); in lpfc_scsi_free()
3993 dma_pool_free(phba->lpfc_sg_dma_buf_pool, sb->data, in lpfc_scsi_free()
3994 sb->dma_handle); in lpfc_scsi_free()
3996 phba->total_scsi_bufs--; in lpfc_scsi_free()
3998 spin_unlock(&phba->scsi_buf_list_get_lock); in lpfc_scsi_free()
3999 spin_unlock_irq(&phba->hbalock); in lpfc_scsi_free()
4003 * lpfc_io_free - Free all the IO buffers and IOCBs from driver lists
4017 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_free()
4018 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_free()
4020 spin_lock(&qp->io_buf_list_put_lock); in lpfc_io_free()
4022 &qp->lpfc_io_buf_list_put, in lpfc_io_free()
4024 list_del(&lpfc_ncmd->list); in lpfc_io_free()
4025 qp->put_io_bufs--; in lpfc_io_free()
4026 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_io_free()
4027 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_io_free()
4028 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_io_free()
4032 qp->total_io_bufs--; in lpfc_io_free()
4034 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_io_free()
4036 spin_lock(&qp->io_buf_list_get_lock); in lpfc_io_free()
4038 &qp->lpfc_io_buf_list_get, in lpfc_io_free()
4040 list_del(&lpfc_ncmd->list); in lpfc_io_free()
4041 qp->get_io_bufs--; in lpfc_io_free()
4042 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_io_free()
4043 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_io_free()
4044 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_io_free()
4048 qp->total_io_bufs--; in lpfc_io_free()
4050 spin_unlock(&qp->io_buf_list_get_lock); in lpfc_io_free()
4055 * lpfc_sli4_els_sgl_update - update ELS xri-sgl sizing and mapping
4064 * 0 - successful (for now, it always returns 0)
4075 * update on pci function's els xri-sgl list in lpfc_sli4_els_sgl_update()
4079 if (els_xri_cnt > phba->sli4_hba.els_xri_cnt) { in lpfc_sli4_els_sgl_update()
4080 /* els xri-sgl expanded */ in lpfc_sli4_els_sgl_update()
4081 xri_cnt = els_xri_cnt - phba->sli4_hba.els_xri_cnt; in lpfc_sli4_els_sgl_update()
4083 "3157 ELS xri-sgl count increased from " in lpfc_sli4_els_sgl_update()
4084 "%d to %d\n", phba->sli4_hba.els_xri_cnt, in lpfc_sli4_els_sgl_update()
4095 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
4098 sglq_entry->buff_type = GEN_BUFF_TYPE; in lpfc_sli4_els_sgl_update()
4099 sglq_entry->virt = lpfc_mbuf_alloc(phba, 0, in lpfc_sli4_els_sgl_update()
4100 &sglq_entry->phys); in lpfc_sli4_els_sgl_update()
4101 if (sglq_entry->virt == NULL) { in lpfc_sli4_els_sgl_update()
4107 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
4110 sglq_entry->sgl = sglq_entry->virt; in lpfc_sli4_els_sgl_update()
4111 memset(sglq_entry->sgl, 0, LPFC_BPL_SIZE); in lpfc_sli4_els_sgl_update()
4112 sglq_entry->state = SGL_FREED; in lpfc_sli4_els_sgl_update()
4113 list_add_tail(&sglq_entry->list, &els_sgl_list); in lpfc_sli4_els_sgl_update()
4115 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4117 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_sli4_els_sgl_update()
4118 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4119 } else if (els_xri_cnt < phba->sli4_hba.els_xri_cnt) { in lpfc_sli4_els_sgl_update()
4120 /* els xri-sgl shrinked */ in lpfc_sli4_els_sgl_update()
4121 xri_cnt = phba->sli4_hba.els_xri_cnt - els_xri_cnt; in lpfc_sli4_els_sgl_update()
4123 "3158 ELS xri-sgl count decreased from " in lpfc_sli4_els_sgl_update()
4124 "%d to %d\n", phba->sli4_hba.els_xri_cnt, in lpfc_sli4_els_sgl_update()
4126 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4127 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, in lpfc_sli4_els_sgl_update()
4134 __lpfc_mbuf_free(phba, sglq_entry->virt, in lpfc_sli4_els_sgl_update()
4135 sglq_entry->phys); in lpfc_sli4_els_sgl_update()
4140 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_sli4_els_sgl_update()
4141 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4144 "3163 ELS xri-sgl count unchanged: %d\n", in lpfc_sli4_els_sgl_update()
4146 phba->sli4_hba.els_xri_cnt = els_xri_cnt; in lpfc_sli4_els_sgl_update()
4152 &phba->sli4_hba.lpfc_els_sgl_list, list) { in lpfc_sli4_els_sgl_update()
4159 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
4162 sglq_entry->sli4_lxritag = lxri; in lpfc_sli4_els_sgl_update()
4163 sglq_entry->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_els_sgl_update()
4173 * lpfc_sli4_nvmet_sgl_update - update xri-sgl sizing and mapping
4182 * 0 - successful (for now, it always returns 0)
4194 * update on pci function's nvmet xri-sgl list in lpfc_sli4_nvmet_sgl_update()
4199 nvmet_xri_cnt = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4200 if (nvmet_xri_cnt > phba->sli4_hba.nvmet_xri_cnt) { in lpfc_sli4_nvmet_sgl_update()
4201 /* els xri-sgl expanded */ in lpfc_sli4_nvmet_sgl_update()
4202 xri_cnt = nvmet_xri_cnt - phba->sli4_hba.nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4204 "6302 NVMET xri-sgl cnt grew from %d to %d\n", in lpfc_sli4_nvmet_sgl_update()
4205 phba->sli4_hba.nvmet_xri_cnt, nvmet_xri_cnt); in lpfc_sli4_nvmet_sgl_update()
4215 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
4218 sglq_entry->buff_type = NVMET_BUFF_TYPE; in lpfc_sli4_nvmet_sgl_update()
4219 sglq_entry->virt = lpfc_nvmet_buf_alloc(phba, 0, in lpfc_sli4_nvmet_sgl_update()
4220 &sglq_entry->phys); in lpfc_sli4_nvmet_sgl_update()
4221 if (sglq_entry->virt == NULL) { in lpfc_sli4_nvmet_sgl_update()
4227 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
4230 sglq_entry->sgl = sglq_entry->virt; in lpfc_sli4_nvmet_sgl_update()
4231 memset(sglq_entry->sgl, 0, in lpfc_sli4_nvmet_sgl_update()
4232 phba->cfg_sg_dma_buf_size); in lpfc_sli4_nvmet_sgl_update()
4233 sglq_entry->state = SGL_FREED; in lpfc_sli4_nvmet_sgl_update()
4234 list_add_tail(&sglq_entry->list, &nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
4236 spin_lock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4237 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4239 &phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
4240 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4241 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4242 } else if (nvmet_xri_cnt < phba->sli4_hba.nvmet_xri_cnt) { in lpfc_sli4_nvmet_sgl_update()
4243 /* nvmet xri-sgl shrunk */ in lpfc_sli4_nvmet_sgl_update()
4244 xri_cnt = phba->sli4_hba.nvmet_xri_cnt - nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4246 "6305 NVMET xri-sgl count decreased from " in lpfc_sli4_nvmet_sgl_update()
4247 "%d to %d\n", phba->sli4_hba.nvmet_xri_cnt, in lpfc_sli4_nvmet_sgl_update()
4249 spin_lock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4250 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4251 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, in lpfc_sli4_nvmet_sgl_update()
4258 lpfc_nvmet_buf_free(phba, sglq_entry->virt, in lpfc_sli4_nvmet_sgl_update()
4259 sglq_entry->phys); in lpfc_sli4_nvmet_sgl_update()
4264 &phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
4265 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4266 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4269 "6306 NVMET xri-sgl count unchanged: %d\n", in lpfc_sli4_nvmet_sgl_update()
4271 phba->sli4_hba.nvmet_xri_cnt = nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4277 &phba->sli4_hba.lpfc_nvmet_sgl_list, list) { in lpfc_sli4_nvmet_sgl_update()
4284 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
4287 sglq_entry->sli4_lxritag = lxri; in lpfc_sli4_nvmet_sgl_update()
4288 sglq_entry->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_nvmet_sgl_update()
4307 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_buf_flush()
4308 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf_flush()
4309 spin_lock_irq(&qp->io_buf_list_get_lock); in lpfc_io_buf_flush()
4310 spin_lock(&qp->io_buf_list_put_lock); in lpfc_io_buf_flush()
4313 list_splice_init(&qp->lpfc_io_buf_list_get, &blist); in lpfc_io_buf_flush()
4314 list_splice(&qp->lpfc_io_buf_list_put, &blist); in lpfc_io_buf_flush()
4315 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_io_buf_flush()
4316 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_io_buf_flush()
4317 cnt += qp->get_io_bufs + qp->put_io_bufs; in lpfc_io_buf_flush()
4318 qp->get_io_bufs = 0; in lpfc_io_buf_flush()
4319 qp->put_io_bufs = 0; in lpfc_io_buf_flush()
4320 qp->total_io_bufs = 0; in lpfc_io_buf_flush()
4321 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_io_buf_flush()
4322 spin_unlock_irq(&qp->io_buf_list_get_lock); in lpfc_io_buf_flush()
4335 list_add_tail(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4338 xri = lpfc_cmd->cur_iocbq.sli4_xritag; in lpfc_io_buf_flush()
4342 if (xri < iobufp->cur_iocbq.sli4_xritag) { in lpfc_io_buf_flush()
4344 list_add(&lpfc_cmd->list, in lpfc_io_buf_flush()
4345 &prev_iobufp->list); in lpfc_io_buf_flush()
4347 list_add(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4354 list_add_tail(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4367 qp = phba->sli4_hba.hdwq; in lpfc_io_buf_replenish()
4370 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_buf_replenish()
4376 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf_replenish()
4377 lpfc_cmd->hdwq_no = idx; in lpfc_io_buf_replenish()
4378 lpfc_cmd->hdwq = qp; in lpfc_io_buf_replenish()
4379 lpfc_cmd->cur_iocbq.cmd_cmpl = NULL; in lpfc_io_buf_replenish()
4380 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflags); in lpfc_io_buf_replenish()
4381 list_add_tail(&lpfc_cmd->list, in lpfc_io_buf_replenish()
4382 &qp->lpfc_io_buf_list_put); in lpfc_io_buf_replenish()
4383 qp->put_io_bufs++; in lpfc_io_buf_replenish()
4384 qp->total_io_bufs++; in lpfc_io_buf_replenish()
4385 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, in lpfc_io_buf_replenish()
4393 * lpfc_sli4_io_sgl_update - update xri-sgl sizing and mapping
4402 * 0 - successful (for now, it always returns 0)
4414 * update on pci function's allocated nvme xri-sgl list in lpfc_sli4_io_sgl_update()
4419 io_xri_max = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt; in lpfc_sli4_io_sgl_update()
4420 phba->sli4_hba.io_xri_max = io_xri_max; in lpfc_sli4_io_sgl_update()
4425 phba->sli4_hba.io_xri_cnt, in lpfc_sli4_io_sgl_update()
4426 phba->sli4_hba.io_xri_max, in lpfc_sli4_io_sgl_update()
4431 if (phba->sli4_hba.io_xri_cnt > phba->sli4_hba.io_xri_max) { in lpfc_sli4_io_sgl_update()
4433 io_xri_cnt = phba->sli4_hba.io_xri_cnt - in lpfc_sli4_io_sgl_update()
4434 phba->sli4_hba.io_xri_max; in lpfc_sli4_io_sgl_update()
4440 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_sli4_io_sgl_update()
4441 lpfc_ncmd->data, in lpfc_sli4_io_sgl_update()
4442 lpfc_ncmd->dma_handle); in lpfc_sli4_io_sgl_update()
4446 phba->sli4_hba.io_xri_cnt -= io_xri_cnt; in lpfc_sli4_io_sgl_update()
4452 phba->sli4_hba.io_xri_cnt = cnt; in lpfc_sli4_io_sgl_update()
4461 rc = -ENOMEM; in lpfc_sli4_io_sgl_update()
4464 lpfc_ncmd->cur_iocbq.sli4_lxritag = lxri; in lpfc_sli4_io_sgl_update()
4465 lpfc_ncmd->cur_iocbq.sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_io_sgl_update()
4476 * lpfc_new_io_buf - IO buffer allocator for HBA with SLI4 IF spec
4480 * This routine allocates nvme buffers for device with SLI-4 interface spec,
4486 * int - number of IO buffers that were allocated and posted.
4500 phba->sli4_hba.io_xri_cnt = 0; in lpfc_new_io_buf()
4510 lpfc_ncmd->data = dma_pool_zalloc(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4512 &lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4513 if (!lpfc_ncmd->data) { in lpfc_new_io_buf()
4518 if (phba->cfg_xpsgl && !phba->nvmet_support) { in lpfc_new_io_buf()
4519 INIT_LIST_HEAD(&lpfc_ncmd->dma_sgl_xtra_list); in lpfc_new_io_buf()
4525 if ((phba->sli3_options & LPFC_SLI3_BG_ENABLED) && in lpfc_new_io_buf()
4526 (((unsigned long)(lpfc_ncmd->data) & in lpfc_new_io_buf()
4527 (unsigned long)(SLI4_PAGE_SIZE - 1)) != 0)) { in lpfc_new_io_buf()
4532 (unsigned long)lpfc_ncmd->data); in lpfc_new_io_buf()
4533 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4534 lpfc_ncmd->data, in lpfc_new_io_buf()
4535 lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4541 INIT_LIST_HEAD(&lpfc_ncmd->dma_cmd_rsp_list); in lpfc_new_io_buf()
4545 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4546 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4550 pwqeq = &lpfc_ncmd->cur_iocbq; in lpfc_new_io_buf()
4552 /* Allocate iotag for lpfc_ncmd->cur_iocbq. */ in lpfc_new_io_buf()
4555 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4556 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4564 pwqeq->sli4_lxritag = lxri; in lpfc_new_io_buf()
4565 pwqeq->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_new_io_buf()
4567 /* Initialize local short-hand pointers. */ in lpfc_new_io_buf()
4568 lpfc_ncmd->dma_sgl = lpfc_ncmd->data; in lpfc_new_io_buf()
4569 lpfc_ncmd->dma_phys_sgl = lpfc_ncmd->dma_handle; in lpfc_new_io_buf()
4570 lpfc_ncmd->cur_iocbq.io_buf = lpfc_ncmd; in lpfc_new_io_buf()
4571 spin_lock_init(&lpfc_ncmd->buf_lock); in lpfc_new_io_buf()
4574 list_add_tail(&lpfc_ncmd->list, &post_nblist); in lpfc_new_io_buf()
4575 phba->sli4_hba.io_xri_cnt++; in lpfc_new_io_buf()
4601 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_get_wwpn()
4604 return (uint64_t)-1; in lpfc_get_wwpn()
4613 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_get_wwpn()
4614 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_get_wwpn()
4615 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_get_wwpn()
4616 return (uint64_t) -1; in lpfc_get_wwpn()
4618 mb = &mboxq->u.mb; in lpfc_get_wwpn()
4619 memcpy(&wwn, (char *)mb->un.varRDnvp.portname, sizeof(uint64_t)); in lpfc_get_wwpn()
4621 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_get_wwpn()
4622 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_get_wwpn()
4630 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_get_sg_tablesize()
4631 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_get_sg_tablesize()
4634 return phba->cfg_scsi_seg_cnt; in lpfc_get_sg_tablesize()
4636 return phba->cfg_sg_seg_cnt; in lpfc_get_sg_tablesize()
4640 * lpfc_vmid_res_alloc - Allocates resources for VMID
4648 * Non-0 on Failure
4654 if (phba->sli_rev == LPFC_SLI_REV3) { in lpfc_vmid_res_alloc()
4655 phba->cfg_vmid_app_header = 0; in lpfc_vmid_res_alloc()
4656 phba->cfg_vmid_priority_tagging = 0; in lpfc_vmid_res_alloc()
4660 vport->vmid = in lpfc_vmid_res_alloc()
4661 kcalloc(phba->cfg_max_vmid, sizeof(struct lpfc_vmid), in lpfc_vmid_res_alloc()
4663 if (!vport->vmid) in lpfc_vmid_res_alloc()
4664 return -ENOMEM; in lpfc_vmid_res_alloc()
4666 rwlock_init(&vport->vmid_lock); in lpfc_vmid_res_alloc()
4669 vport->vmid_priority_tagging = phba->cfg_vmid_priority_tagging; in lpfc_vmid_res_alloc()
4670 vport->vmid_inactivity_timeout = in lpfc_vmid_res_alloc()
4671 phba->cfg_vmid_inactivity_timeout; in lpfc_vmid_res_alloc()
4672 vport->max_vmid = phba->cfg_max_vmid; in lpfc_vmid_res_alloc()
4673 vport->cur_vmid_cnt = 0; in lpfc_vmid_res_alloc()
4675 vport->vmid_priority_range = bitmap_zalloc in lpfc_vmid_res_alloc()
4678 if (!vport->vmid_priority_range) { in lpfc_vmid_res_alloc()
4679 kfree(vport->vmid); in lpfc_vmid_res_alloc()
4680 return -ENOMEM; in lpfc_vmid_res_alloc()
4683 hash_init(vport->hash_table); in lpfc_vmid_res_alloc()
4689 * lpfc_create_port - Create an FC port
4701 * @vport - pointer to the virtual N_Port data structure.
4702 * NULL - port create failed.
4717 if (phba->sli_rev < LPFC_SLI_REV4 && in lpfc_create_port()
4718 dev == &phba->pcidev->dev) { in lpfc_create_port()
4740 if (dev == &phba->pcidev->dev) { in lpfc_create_port()
4741 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { in lpfc_create_port()
4747 template->eh_host_reset_handler = NULL; in lpfc_create_port()
4750 template->sg_tablesize = lpfc_get_sg_tablesize(phba); in lpfc_create_port()
4760 template->sg_tablesize = lpfc_get_sg_tablesize(phba); in lpfc_create_port()
4767 vport = (struct lpfc_vport *) shost->hostdata; in lpfc_create_port()
4768 vport->phba = phba; in lpfc_create_port()
4769 vport->load_flag |= FC_LOADING; in lpfc_create_port()
4770 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; in lpfc_create_port()
4771 vport->fc_rscn_flush = 0; in lpfc_create_port()
4775 vport->cfg_enable_fc4_type = phba->cfg_enable_fc4_type; in lpfc_create_port()
4777 shost->unique_id = instance; in lpfc_create_port()
4778 shost->max_id = LPFC_MAX_TARGET; in lpfc_create_port()
4779 shost->max_lun = vport->cfg_max_luns; in lpfc_create_port()
4780 shost->this_id = -1; in lpfc_create_port()
4781 shost->max_cmd_len = 16; in lpfc_create_port()
4783 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_create_port()
4784 if (!phba->cfg_fcp_mq_threshold || in lpfc_create_port()
4785 phba->cfg_fcp_mq_threshold > phba->cfg_hdw_queue) in lpfc_create_port()
4786 phba->cfg_fcp_mq_threshold = phba->cfg_hdw_queue; in lpfc_create_port()
4788 shost->nr_hw_queues = min_t(int, 2 * num_possible_nodes(), in lpfc_create_port()
4789 phba->cfg_fcp_mq_threshold); in lpfc_create_port()
4791 shost->dma_boundary = in lpfc_create_port()
4792 phba->sli4_hba.pc_sli4_params.sge_supp_len-1; in lpfc_create_port()
4794 /* SLI-3 has a limited number of hardware queues (3), in lpfc_create_port()
4797 shost->nr_hw_queues = 1; in lpfc_create_port()
4804 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_create_port()
4805 if (dev != &phba->pcidev->dev) { in lpfc_create_port()
4806 shost->transportt = lpfc_vport_transport_template; in lpfc_create_port()
4807 vport->port_type = LPFC_NPIV_PORT; in lpfc_create_port()
4809 shost->transportt = lpfc_transport_template; in lpfc_create_port()
4810 vport->port_type = LPFC_PHYSICAL_PORT; in lpfc_create_port()
4816 vport->port_type, shost->sg_tablesize, in lpfc_create_port()
4817 phba->cfg_scsi_seg_cnt, phba->cfg_sg_seg_cnt); in lpfc_create_port()
4826 INIT_LIST_HEAD(&vport->fc_nodes); in lpfc_create_port()
4827 INIT_LIST_HEAD(&vport->rcv_buffer_list); in lpfc_create_port()
4828 spin_lock_init(&vport->work_port_lock); in lpfc_create_port()
4830 timer_setup(&vport->fc_disctmo, lpfc_disc_timeout, 0); in lpfc_create_port()
4832 timer_setup(&vport->els_tmofunc, lpfc_els_timeout, 0); in lpfc_create_port()
4834 timer_setup(&vport->delayed_disc_tmo, lpfc_delayed_disc_tmo, 0); in lpfc_create_port()
4836 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) in lpfc_create_port()
4839 error = scsi_add_host_with_dma(shost, dev, &phba->pcidev->dev); in lpfc_create_port()
4843 spin_lock_irq(&phba->port_list_lock); in lpfc_create_port()
4844 list_add_tail(&vport->listentry, &phba->port_list); in lpfc_create_port()
4845 spin_unlock_irq(&phba->port_list_lock); in lpfc_create_port()
4849 kfree(vport->vmid); in lpfc_create_port()
4850 bitmap_free(vport->vmid_priority_range); in lpfc_create_port()
4858 * destroy_port - destroy an FC port
4868 struct lpfc_hba *phba = vport->phba; in destroy_port()
4874 spin_lock_irq(&phba->port_list_lock); in destroy_port()
4875 list_del_init(&vport->listentry); in destroy_port()
4876 spin_unlock_irq(&phba->port_list_lock); in destroy_port()
4883 * lpfc_get_instance - Get a unique integer ID
4889 * instance - a unique integer ID allocated as the new instance.
4890 * -1 - lpfc get instance failed.
4898 return ret < 0 ? -1 : ret; in lpfc_get_instance()
4902 * lpfc_scan_finished - method for SCSI layer to detect whether scan is done
4913 * 0 - SCSI host scan is not over yet.
4914 * 1 - SCSI host scan is over.
4918 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_scan_finished()
4919 struct lpfc_hba *phba = vport->phba; in lpfc_scan_finished()
4922 spin_lock_irq(shost->host_lock); in lpfc_scan_finished()
4924 if (vport->load_flag & FC_UNLOADING) { in lpfc_scan_finished()
4936 phba->link_state <= LPFC_LINK_DOWN) { in lpfc_scan_finished()
4944 if (vport->port_state != LPFC_VPORT_READY) in lpfc_scan_finished()
4946 if (vport->num_disc_nodes || vport->fc_prli_sent) in lpfc_scan_finished()
4948 if (vport->fc_map_cnt == 0 && time < msecs_to_jiffies(2 * 1000)) in lpfc_scan_finished()
4950 if ((phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) != 0) in lpfc_scan_finished()
4956 spin_unlock_irq(shost->host_lock); in lpfc_scan_finished()
4962 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; in lpfc_host_supported_speeds_set()
4963 struct lpfc_hba *phba = vport->phba; in lpfc_host_supported_speeds_set()
4970 if (phba->hba_flag & HBA_FCOE_MODE) in lpfc_host_supported_speeds_set()
4973 if (phba->lmt & LMT_256Gb) in lpfc_host_supported_speeds_set()
4975 if (phba->lmt & LMT_128Gb) in lpfc_host_supported_speeds_set()
4977 if (phba->lmt & LMT_64Gb) in lpfc_host_supported_speeds_set()
4979 if (phba->lmt & LMT_32Gb) in lpfc_host_supported_speeds_set()
4981 if (phba->lmt & LMT_16Gb) in lpfc_host_supported_speeds_set()
4983 if (phba->lmt & LMT_10Gb) in lpfc_host_supported_speeds_set()
4985 if (phba->lmt & LMT_8Gb) in lpfc_host_supported_speeds_set()
4987 if (phba->lmt & LMT_4Gb) in lpfc_host_supported_speeds_set()
4989 if (phba->lmt & LMT_2Gb) in lpfc_host_supported_speeds_set()
4991 if (phba->lmt & LMT_1Gb) in lpfc_host_supported_speeds_set()
4996 * lpfc_host_attrib_init - Initialize SCSI host attributes on a FC port
5004 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_host_attrib_init()
5005 struct lpfc_hba *phba = vport->phba; in lpfc_host_attrib_init()
5010 fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); in lpfc_host_attrib_init()
5011 fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); in lpfc_host_attrib_init()
5025 (((uint32_t) vport->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) | in lpfc_host_attrib_init()
5026 (uint32_t) vport->fc_sparam.cmn.bbRcvSizeLsb; in lpfc_host_attrib_init()
5028 fc_host_dev_loss_tmo(shost) = vport->cfg_devloss_tmo; in lpfc_host_attrib_init()
5036 fc_host_max_npiv_vports(shost) = phba->max_vpi; in lpfc_host_attrib_init()
5037 spin_lock_irq(shost->host_lock); in lpfc_host_attrib_init()
5038 vport->load_flag &= ~FC_LOADING; in lpfc_host_attrib_init()
5039 spin_unlock_irq(shost->host_lock); in lpfc_host_attrib_init()
5043 * lpfc_stop_port_s3 - Stop SLI3 device port
5054 writel(0, phba->HCregaddr); in lpfc_stop_port_s3()
5055 readl(phba->HCregaddr); /* flush */ in lpfc_stop_port_s3()
5057 writel(0xffffffff, phba->HAregaddr); in lpfc_stop_port_s3()
5058 readl(phba->HAregaddr); /* flush */ in lpfc_stop_port_s3()
5062 phba->pport->work_port_events = 0; in lpfc_stop_port_s3()
5066 * lpfc_stop_port_s4 - Stop SLI4 device port
5078 if (phba->pport) in lpfc_stop_port_s4()
5079 phba->pport->work_port_events = 0; in lpfc_stop_port_s4()
5080 phba->sli4_hba.intr_enable = 0; in lpfc_stop_port_s4()
5084 * lpfc_stop_port - Wrapper function for stopping hba port
5093 phba->lpfc_stop_port(phba); in lpfc_stop_port()
5095 if (phba->wq) in lpfc_stop_port()
5096 flush_workqueue(phba->wq); in lpfc_stop_port()
5100 * lpfc_fcf_redisc_wait_start_timer - Start fcf rediscover wait timer
5111 mod_timer(&phba->fcf.redisc_wait, fcf_redisc_wait_tmo); in lpfc_fcf_redisc_wait_start_timer()
5112 spin_lock_irq(&phba->hbalock); in lpfc_fcf_redisc_wait_start_timer()
5114 phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_SCAN_DONE); in lpfc_fcf_redisc_wait_start_timer()
5116 phba->fcf.fcf_flag |= FCF_REDISC_PEND; in lpfc_fcf_redisc_wait_start_timer()
5117 spin_unlock_irq(&phba->hbalock); in lpfc_fcf_redisc_wait_start_timer()
5121 * lpfc_sli4_fcf_redisc_wait_tmo - FCF table rediscover wait timeout
5136 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
5137 if (!(phba->fcf.fcf_flag & FCF_REDISC_PEND)) { in lpfc_sli4_fcf_redisc_wait_tmo()
5138 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
5142 phba->fcf.fcf_flag &= ~FCF_REDISC_PEND; in lpfc_sli4_fcf_redisc_wait_tmo()
5144 phba->fcf.fcf_flag |= FCF_REDISC_EVT; in lpfc_sli4_fcf_redisc_wait_tmo()
5145 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
5153 * lpfc_vmid_poll - VMID timeout detection
5168 if (phba->pport->vmid_priority_tagging) { in lpfc_vmid_poll()
5170 phba->pport->work_port_events |= WORKER_CHECK_VMID_ISSUE_QFPA; in lpfc_vmid_poll()
5174 if (phba->pport->vmid_inactivity_timeout || in lpfc_vmid_poll()
5175 phba->pport->load_flag & FC_DEREGISTER_ALL_APP_ID) { in lpfc_vmid_poll()
5177 phba->pport->work_port_events |= WORKER_CHECK_INACTIVE_VMID; in lpfc_vmid_poll()
5184 mod_timer(&phba->inactive_vmid_poll, jiffies + msecs_to_jiffies(1000 * in lpfc_vmid_poll()
5189 * lpfc_sli4_parse_latt_fault - Parse sli4 link-attention link fault code
5193 * This routine is to parse the SLI4 link-attention link fault code.
5223 * lpfc_sli4_parse_latt_type - Parse sli4 link attention type
5244 /* Ignore physical link up events - wait for logical link up */ in lpfc_sli4_parse_latt_type()
5261 * lpfc_sli_port_speed_get - Get sli3 link speed code to link speed
5276 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_sli_port_speed_get()
5277 switch (phba->fc_linkspeed) { in lpfc_sli_port_speed_get()
5300 if (phba->sli4_hba.link_state.logical_speed) in lpfc_sli_port_speed_get()
5302 phba->sli4_hba.link_state.logical_speed; in lpfc_sli_port_speed_get()
5304 link_speed = phba->sli4_hba.link_state.speed; in lpfc_sli_port_speed_get()
5310 * lpfc_sli4_port_speed_parse - Parse async evt link speed code to link speed
5406 * lpfc_sli4_async_link_evt - Process the asynchronous FCoE link event
5425 phba->fcoe_eventtag = acqe_link->event_tag; in lpfc_sli4_async_link_evt()
5426 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_async_link_evt()
5444 phba->sli4_hba.els_wq->pring->flag |= LPFC_STOP_IOCB_EVENT; in lpfc_sli4_async_link_evt()
5447 phba->sli.slistat.link_event++; in lpfc_sli4_async_link_evt()
5450 lpfc_read_topology(phba, pmb, (struct lpfc_dmabuf *)pmb->ctx_buf); in lpfc_sli4_async_link_evt()
5451 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_sli4_async_link_evt()
5452 pmb->vport = phba->pport; in lpfc_sli4_async_link_evt()
5455 phba->sli4_hba.link_state.speed = in lpfc_sli4_async_link_evt()
5458 phba->sli4_hba.link_state.duplex = in lpfc_sli4_async_link_evt()
5460 phba->sli4_hba.link_state.status = in lpfc_sli4_async_link_evt()
5462 phba->sli4_hba.link_state.type = in lpfc_sli4_async_link_evt()
5464 phba->sli4_hba.link_state.number = in lpfc_sli4_async_link_evt()
5466 phba->sli4_hba.link_state.fault = in lpfc_sli4_async_link_evt()
5468 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_link_evt()
5472 "2900 Async FC/FCoE Link event - Speed:%dGBit " in lpfc_sli4_async_link_evt()
5475 phba->sli4_hba.link_state.speed, in lpfc_sli4_async_link_evt()
5476 phba->sli4_hba.link_state.topology, in lpfc_sli4_async_link_evt()
5477 phba->sli4_hba.link_state.status, in lpfc_sli4_async_link_evt()
5478 phba->sli4_hba.link_state.type, in lpfc_sli4_async_link_evt()
5479 phba->sli4_hba.link_state.number, in lpfc_sli4_async_link_evt()
5480 phba->sli4_hba.link_state.logical_speed, in lpfc_sli4_async_link_evt()
5481 phba->sli4_hba.link_state.fault); in lpfc_sli4_async_link_evt()
5484 * topology info. Note: Optional for non FC-AL ports. in lpfc_sli4_async_link_evt()
5486 if (!(phba->hba_flag & HBA_FCOE_MODE)) { in lpfc_sli4_async_link_evt()
5498 mb = &pmb->u.mb; in lpfc_sli4_async_link_evt()
5499 mb->mbxStatus = MBX_SUCCESS; in lpfc_sli4_async_link_evt()
5505 la = (struct lpfc_mbx_read_top *) &pmb->u.mb.un.varReadTop; in lpfc_sli4_async_link_evt()
5506 la->eventTag = acqe_link->event_tag; in lpfc_sli4_async_link_evt()
5529 * lpfc_async_link_speed_to_read_top - Parse async evt link speed code to read
5583 if (!phba->rx_monitor) { in lpfc_cgn_dump_rxmonitor()
5587 lpfc_rx_monitor_report(phba, phba->rx_monitor, NULL, 0, in lpfc_cgn_dump_rxmonitor()
5593 * lpfc_cgn_update_stat - Save data into congestion stats buffer
5606 if (!phba->cgn_i) in lpfc_cgn_update_stat()
5608 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_cgn_update_stat()
5613 le32_add_cpu(&cp->link_integ_notification, 1); in lpfc_cgn_update_stat()
5614 lpfc_cgn_update_tstamp(phba, &cp->stat_lnk); in lpfc_cgn_update_stat()
5617 le32_add_cpu(&cp->delivery_notification, 1); in lpfc_cgn_update_stat()
5618 lpfc_cgn_update_tstamp(phba, &cp->stat_delivery); in lpfc_cgn_update_stat()
5621 le32_add_cpu(&cp->cgn_peer_notification, 1); in lpfc_cgn_update_stat()
5622 lpfc_cgn_update_tstamp(phba, &cp->stat_peer); in lpfc_cgn_update_stat()
5625 le32_add_cpu(&cp->cgn_notification, 1); in lpfc_cgn_update_stat()
5626 lpfc_cgn_update_tstamp(phba, &cp->stat_fpin); in lpfc_cgn_update_stat()
5628 if (phba->cgn_fpin_frequency && in lpfc_cgn_update_stat()
5629 phba->cgn_fpin_frequency != LPFC_FPIN_INIT_FREQ) { in lpfc_cgn_update_stat()
5630 value = LPFC_CGN_TIMER_TO_MIN / phba->cgn_fpin_frequency; in lpfc_cgn_update_stat()
5631 cp->cgn_stat_npm = value; in lpfc_cgn_update_stat()
5636 cp->cgn_info_crc = cpu_to_le32(value); in lpfc_cgn_update_stat()
5640 * lpfc_cgn_update_tstamp - Update cmf timestamp
5653 ts->month = tm_val.tm_mon + 1; in lpfc_cgn_update_tstamp()
5654 ts->day = tm_val.tm_mday; in lpfc_cgn_update_tstamp()
5655 ts->year = tm_val.tm_year - 100; in lpfc_cgn_update_tstamp()
5656 ts->hour = tm_val.tm_hour; in lpfc_cgn_update_tstamp()
5657 ts->minute = tm_val.tm_min; in lpfc_cgn_update_tstamp()
5658 ts->second = tm_val.tm_sec; in lpfc_cgn_update_tstamp()
5663 ts->day, ts->month, in lpfc_cgn_update_tstamp()
5664 ts->year, ts->hour, in lpfc_cgn_update_tstamp()
5665 ts->minute, ts->second); in lpfc_cgn_update_tstamp()
5669 * lpfc_cmf_stats_timer - Save data into registered congestion buffer
5695 if (!phba->cgn_i) in lpfc_cmf_stats_timer()
5697 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_cmf_stats_timer()
5699 phba->cgn_evt_timestamp = jiffies + in lpfc_cmf_stats_timer()
5701 phba->cgn_evt_minute++; in lpfc_cmf_stats_timer()
5704 lpfc_cgn_update_tstamp(phba, &cp->base_time); in lpfc_cmf_stats_timer()
5706 if (phba->cgn_fpin_frequency && in lpfc_cmf_stats_timer()
5707 phba->cgn_fpin_frequency != LPFC_FPIN_INIT_FREQ) { in lpfc_cmf_stats_timer()
5708 value = LPFC_CGN_TIMER_TO_MIN / phba->cgn_fpin_frequency; in lpfc_cmf_stats_timer()
5709 cp->cgn_stat_npm = value; in lpfc_cmf_stats_timer()
5713 lvalue = atomic_read(&phba->cgn_latency_evt_cnt); in lpfc_cmf_stats_timer()
5714 latsum = atomic64_read(&phba->cgn_latency_evt); in lpfc_cmf_stats_timer()
5715 atomic_set(&phba->cgn_latency_evt_cnt, 0); in lpfc_cmf_stats_timer()
5716 atomic64_set(&phba->cgn_latency_evt, 0); in lpfc_cmf_stats_timer()
5722 bps = div_u64(phba->rx_block_cnt, LPFC_SEC_MIN) * 512; in lpfc_cmf_stats_timer()
5723 phba->rx_block_cnt = 0; in lpfc_cmf_stats_timer()
5728 cp->cgn_info_mode = phba->cgn_p.cgn_param_mode; in lpfc_cmf_stats_timer()
5729 cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0; in lpfc_cmf_stats_timer()
5730 cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1; in lpfc_cmf_stats_timer()
5731 cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2; in lpfc_cmf_stats_timer()
5734 value = (uint16_t)(phba->pport->cfg_lun_queue_depth); in lpfc_cmf_stats_timer()
5735 cp->cgn_lunq = cpu_to_le16(value); in lpfc_cmf_stats_timer()
5737 /* Record congestion buffer info - every minute in lpfc_cmf_stats_timer()
5743 index = ++cp->cgn_index_minute; in lpfc_cmf_stats_timer()
5744 if (cp->cgn_index_minute == LPFC_MIN_HOUR) { in lpfc_cmf_stats_timer()
5745 cp->cgn_index_minute = 0; in lpfc_cmf_stats_timer()
5750 dvalue = atomic_read(&phba->cgn_driver_evt_cnt); in lpfc_cmf_stats_timer()
5751 atomic_set(&phba->cgn_driver_evt_cnt, 0); in lpfc_cmf_stats_timer()
5753 /* Get the number of warning events - FPIN and Signal for this minute */ in lpfc_cmf_stats_timer()
5755 if ((phba->cgn_reg_fpin & LPFC_CGN_FPIN_WARN) || in lpfc_cmf_stats_timer()
5756 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY || in lpfc_cmf_stats_timer()
5757 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) in lpfc_cmf_stats_timer()
5758 wvalue = atomic_read(&phba->cgn_fabric_warn_cnt); in lpfc_cmf_stats_timer()
5759 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_cmf_stats_timer()
5761 /* Get the number of alarm events - FPIN and Signal for this minute */ in lpfc_cmf_stats_timer()
5763 if ((phba->cgn_reg_fpin & LPFC_CGN_FPIN_ALARM) || in lpfc_cmf_stats_timer()
5764 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) in lpfc_cmf_stats_timer()
5765 avalue = atomic_read(&phba->cgn_fabric_alarm_cnt); in lpfc_cmf_stats_timer()
5766 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_cmf_stats_timer()
5771 ptr = &cp->cgn_drvr_min[index]; in lpfc_cmf_stats_timer()
5775 ptr = &cp->cgn_warn_min[index]; in lpfc_cmf_stats_timer()
5779 ptr = &cp->cgn_alarm_min[index]; in lpfc_cmf_stats_timer()
5783 lptr = &cp->cgn_latency_min[index]; in lpfc_cmf_stats_timer()
5792 mptr = &cp->cgn_bw_min[index]; in lpfc_cmf_stats_timer()
5796 "2418 Congestion Info - minute (%d): %d %d %d %d %d\n", in lpfc_cmf_stats_timer()
5800 if ((phba->cgn_evt_minute % LPFC_MIN_HOUR) == 0) { in lpfc_cmf_stats_timer()
5801 /* Record congestion buffer info - every hour in lpfc_cmf_stats_timer()
5804 index = ++cp->cgn_index_hour; in lpfc_cmf_stats_timer()
5805 if (cp->cgn_index_hour == LPFC_HOUR_DAY) { in lpfc_cmf_stats_timer()
5806 cp->cgn_index_hour = 0; in lpfc_cmf_stats_timer()
5817 dvalue += le16_to_cpu(cp->cgn_drvr_min[i]); in lpfc_cmf_stats_timer()
5818 wvalue += le16_to_cpu(cp->cgn_warn_min[i]); in lpfc_cmf_stats_timer()
5819 lvalue += le32_to_cpu(cp->cgn_latency_min[i]); in lpfc_cmf_stats_timer()
5820 mbps += le16_to_cpu(cp->cgn_bw_min[i]); in lpfc_cmf_stats_timer()
5821 avalue += le16_to_cpu(cp->cgn_alarm_min[i]); in lpfc_cmf_stats_timer()
5828 lptr = &cp->cgn_drvr_hr[index]; in lpfc_cmf_stats_timer()
5830 lptr = &cp->cgn_warn_hr[index]; in lpfc_cmf_stats_timer()
5832 lptr = &cp->cgn_latency_hr[index]; in lpfc_cmf_stats_timer()
5834 mptr = &cp->cgn_bw_hr[index]; in lpfc_cmf_stats_timer()
5836 lptr = &cp->cgn_alarm_hr[index]; in lpfc_cmf_stats_timer()
5840 "2419 Congestion Info - hour " in lpfc_cmf_stats_timer()
5846 if ((phba->cgn_evt_minute % LPFC_MIN_DAY) == 0) { in lpfc_cmf_stats_timer()
5847 /* Record congestion buffer info - every hour in lpfc_cmf_stats_timer()
5851 index = ++cp->cgn_index_day; in lpfc_cmf_stats_timer()
5852 if (cp->cgn_index_day == LPFC_MAX_CGN_DAYS) { in lpfc_cmf_stats_timer()
5853 cp->cgn_index_day = 0; in lpfc_cmf_stats_timer()
5864 dvalue += le32_to_cpu(cp->cgn_drvr_hr[i]); in lpfc_cmf_stats_timer()
5865 wvalue += le32_to_cpu(cp->cgn_warn_hr[i]); in lpfc_cmf_stats_timer()
5866 lvalue += le32_to_cpu(cp->cgn_latency_hr[i]); in lpfc_cmf_stats_timer()
5867 mbps += le16_to_cpu(cp->cgn_bw_hr[i]); in lpfc_cmf_stats_timer()
5868 avalue += le32_to_cpu(cp->cgn_alarm_hr[i]); in lpfc_cmf_stats_timer()
5875 lptr = &cp->cgn_drvr_day[index]; in lpfc_cmf_stats_timer()
5877 lptr = &cp->cgn_warn_day[index]; in lpfc_cmf_stats_timer()
5879 lptr = &cp->cgn_latency_day[index]; in lpfc_cmf_stats_timer()
5881 mptr = &cp->cgn_bw_day[index]; in lpfc_cmf_stats_timer()
5883 lptr = &cp->cgn_alarm_day[index]; in lpfc_cmf_stats_timer()
5887 "2420 Congestion Info - daily (%d): " in lpfc_cmf_stats_timer()
5893 value = phba->cgn_fpin_frequency; in lpfc_cmf_stats_timer()
5894 cp->cgn_warn_freq = cpu_to_le16(value); in lpfc_cmf_stats_timer()
5895 cp->cgn_alarm_freq = cpu_to_le16(value); in lpfc_cmf_stats_timer()
5899 cp->cgn_info_crc = cpu_to_le32(lvalue); in lpfc_cmf_stats_timer()
5907 * lpfc_calc_cmf_latency - latency from start of rxate timer interval
5925 if (cmpl_time.tv_sec == phba->cmf_latency.tv_sec) { in lpfc_calc_cmf_latency()
5926 msec = (cmpl_time.tv_nsec - phba->cmf_latency.tv_nsec) / in lpfc_calc_cmf_latency()
5929 if (cmpl_time.tv_nsec >= phba->cmf_latency.tv_nsec) { in lpfc_calc_cmf_latency()
5930 msec = (cmpl_time.tv_sec - in lpfc_calc_cmf_latency()
5931 phba->cmf_latency.tv_sec) * MSEC_PER_SEC; in lpfc_calc_cmf_latency()
5932 msec += ((cmpl_time.tv_nsec - in lpfc_calc_cmf_latency()
5933 phba->cmf_latency.tv_nsec) / NSEC_PER_MSEC); in lpfc_calc_cmf_latency()
5935 msec = (cmpl_time.tv_sec - phba->cmf_latency.tv_sec - in lpfc_calc_cmf_latency()
5937 msec += (((NSEC_PER_SEC - phba->cmf_latency.tv_nsec) + in lpfc_calc_cmf_latency()
5945 * lpfc_cmf_timer - This is the timer function for one congestion
5961 int cpu; in lpfc_cmf_timer() local
5964 if (phba->cmf_active_mode == LPFC_CFG_OFF || in lpfc_cmf_timer()
5965 !phba->cmf_latency.tv_sec) { in lpfc_cmf_timer()
5968 phba->cmf_active_mode, in lpfc_cmf_timer()
5969 (uint64_t)phba->cmf_latency.tv_sec); in lpfc_cmf_timer()
5976 if (!phba->pport) in lpfc_cmf_timer()
5982 atomic_set(&phba->cmf_stop_io, 1); in lpfc_cmf_timer()
5996 ktime_get_real_ts64(&phba->cmf_latency); in lpfc_cmf_timer()
5998 phba->cmf_link_byte_count = in lpfc_cmf_timer()
5999 div_u64(phba->cmf_max_line_rate * LPFC_CMF_INTERVAL, 1000); in lpfc_cmf_timer()
6006 for_each_present_cpu(cpu) { in lpfc_cmf_timer()
6007 cgs = per_cpu_ptr(phba->cmf_stat, cpu); in lpfc_cmf_timer()
6008 total += atomic64_xchg(&cgs->total_bytes, 0); in lpfc_cmf_timer()
6009 io_cnt += atomic_xchg(&cgs->rx_io_cnt, 0); in lpfc_cmf_timer()
6010 lat += atomic64_xchg(&cgs->rx_latency, 0); in lpfc_cmf_timer()
6011 rcv += atomic64_xchg(&cgs->rcv_bytes, 0); in lpfc_cmf_timer()
6019 if (phba->cmf_active_mode == LPFC_CFG_MANAGED && in lpfc_cmf_timer()
6020 phba->link_state != LPFC_LINK_DOWN && in lpfc_cmf_timer()
6021 phba->hba_flag & HBA_SETUP) { in lpfc_cmf_timer()
6022 mbpi = phba->cmf_last_sync_bw; in lpfc_cmf_timer()
6023 phba->cmf_last_sync_bw = 0; in lpfc_cmf_timer()
6034 extra = cnt - total; in lpfc_cmf_timer()
6041 mbpi = phba->cmf_link_byte_count; in lpfc_cmf_timer()
6044 phba->cmf_timer_cnt++; in lpfc_cmf_timer()
6048 atomic_add(io_cnt, &phba->cgn_latency_evt_cnt); in lpfc_cmf_timer()
6049 atomic64_add(lat, &phba->cgn_latency_evt); in lpfc_cmf_timer()
6051 busy = atomic_xchg(&phba->cmf_busy, 0); in lpfc_cmf_timer()
6052 max_read = atomic_xchg(&phba->rx_max_read_cnt, 0); in lpfc_cmf_timer()
6056 if (mbpi > phba->cmf_link_byte_count || in lpfc_cmf_timer()
6057 phba->cmf_active_mode == LPFC_CFG_MONITOR) in lpfc_cmf_timer()
6058 mbpi = phba->cmf_link_byte_count; in lpfc_cmf_timer()
6063 if (mbpi != phba->cmf_max_bytes_per_interval) in lpfc_cmf_timer()
6064 phba->cmf_max_bytes_per_interval = mbpi; in lpfc_cmf_timer()
6068 if (phba->rx_monitor) { in lpfc_cmf_timer()
6073 entry.cmf_info = phba->cmf_active_info; in lpfc_cmf_timer()
6084 if (phba->cmf_active_mode == LPFC_CFG_MANAGED) in lpfc_cmf_timer()
6085 entry.timer_utilization = phba->cmf_last_ts; in lpfc_cmf_timer()
6089 phba->cmf_last_ts = 0; in lpfc_cmf_timer()
6091 lpfc_rx_monitor_record(phba->rx_monitor, &entry); in lpfc_cmf_timer()
6094 if (phba->cmf_active_mode == LPFC_CFG_MONITOR) { in lpfc_cmf_timer()
6099 atomic_inc(&phba->cgn_driver_evt_cnt); in lpfc_cmf_timer()
6101 phba->rx_block_cnt += div_u64(rcv, 512); /* save 512 byte block cnt */ in lpfc_cmf_timer()
6106 if (atomic_xchg(&phba->cmf_bw_wait, 0)) in lpfc_cmf_timer()
6107 queue_work(phba->wq, &phba->unblock_request_work); in lpfc_cmf_timer()
6110 atomic_set(&phba->cmf_stop_io, 0); in lpfc_cmf_timer()
6120 ((phba->trunk_link.link##__idx.state == LPFC_LINK_UP) ?\
6135 phba->sli4_hba.link_state.speed = in lpfc_update_trunk_link_status()
6139 phba->sli4_hba.link_state.logical_speed = in lpfc_update_trunk_link_status()
6142 phba->fc_linkspeed = in lpfc_update_trunk_link_status()
6148 phba->trunk_link.link0.state = in lpfc_update_trunk_link_status()
6151 phba->trunk_link.link0.fault = port_fault & 0x1 ? err : 0; in lpfc_update_trunk_link_status()
6155 phba->trunk_link.link1.state = in lpfc_update_trunk_link_status()
6158 phba->trunk_link.link1.fault = port_fault & 0x2 ? err : 0; in lpfc_update_trunk_link_status()
6162 phba->trunk_link.link2.state = in lpfc_update_trunk_link_status()
6165 phba->trunk_link.link2.fault = port_fault & 0x4 ? err : 0; in lpfc_update_trunk_link_status()
6169 phba->trunk_link.link3.state = in lpfc_update_trunk_link_status()
6172 phba->trunk_link.link3.fault = port_fault & 0x8 ? err : 0; in lpfc_update_trunk_link_status()
6177 phba->trunk_link.phy_lnk_speed = in lpfc_update_trunk_link_status()
6178 phba->sli4_hba.link_state.logical_speed / (cnt * 1000); in lpfc_update_trunk_link_status()
6180 phba->trunk_link.phy_lnk_speed = LPFC_LINK_SPEED_UNKNOWN; in lpfc_update_trunk_link_status()
6183 "2910 Async FC Trunking Event - Speed:%d\n" in lpfc_update_trunk_link_status()
6186 phba->sli4_hba.link_state.speed, in lpfc_update_trunk_link_status()
6187 phba->sli4_hba.link_state.logical_speed, in lpfc_update_trunk_link_status()
6191 if (phba->cmf_active_mode != LPFC_CFG_OFF) in lpfc_update_trunk_link_status()
6198 * SLI-4: We have only 0xA error codes in lpfc_update_trunk_link_status()
6210 * lpfc_sli4_async_fc_evt - Process the asynchronous FC link event
6242 phba->sli4_hba.link_state.speed = in lpfc_sli4_async_fc_evt()
6245 phba->sli4_hba.link_state.duplex = LPFC_ASYNC_LINK_DUPLEX_FULL; in lpfc_sli4_async_fc_evt()
6246 phba->sli4_hba.link_state.topology = in lpfc_sli4_async_fc_evt()
6248 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
6250 phba->sli4_hba.link_state.type = in lpfc_sli4_async_fc_evt()
6252 phba->sli4_hba.link_state.number = in lpfc_sli4_async_fc_evt()
6254 phba->sli4_hba.link_state.fault = in lpfc_sli4_async_fc_evt()
6256 phba->sli4_hba.link_state.link_status = in lpfc_sli4_async_fc_evt()
6263 if (phba->sli4_hba.link_state.status >= LPFC_FC_LA_TYPE_LINK_UP && in lpfc_sli4_async_fc_evt()
6264 phba->sli4_hba.link_state.status < LPFC_FC_LA_TYPE_ACTIVATE_FAIL) { in lpfc_sli4_async_fc_evt()
6267 phba->sli4_hba.link_state.logical_speed = 0; in lpfc_sli4_async_fc_evt()
6268 else if (!phba->sli4_hba.conf_trunk) in lpfc_sli4_async_fc_evt()
6269 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_fc_evt()
6274 "2896 Async FC event - Speed:%dGBaud Topology:x%x " in lpfc_sli4_async_fc_evt()
6277 phba->sli4_hba.link_state.speed, in lpfc_sli4_async_fc_evt()
6278 phba->sli4_hba.link_state.topology, in lpfc_sli4_async_fc_evt()
6279 phba->sli4_hba.link_state.status, in lpfc_sli4_async_fc_evt()
6280 phba->sli4_hba.link_state.type, in lpfc_sli4_async_fc_evt()
6281 phba->sli4_hba.link_state.number, in lpfc_sli4_async_fc_evt()
6282 phba->sli4_hba.link_state.logical_speed, in lpfc_sli4_async_fc_evt()
6283 phba->sli4_hba.link_state.fault, in lpfc_sli4_async_fc_evt()
6284 phba->sli4_hba.link_state.link_status); in lpfc_sli4_async_fc_evt()
6291 if (phba->sli4_hba.link_state.status >= LPFC_FC_LA_TYPE_ACTIVATE_FAIL) { in lpfc_sli4_async_fc_evt()
6292 switch (phba->sli4_hba.link_state.status) { in lpfc_sli4_async_fc_evt()
6295 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
6306 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
6314 "2992 Async FC event - Informational Link " in lpfc_sli4_async_fc_evt()
6320 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_async_fc_evt()
6337 phba->sli4_hba.els_wq->pring->flag |= LPFC_STOP_IOCB_EVENT; in lpfc_sli4_async_fc_evt()
6340 phba->sli.slistat.link_event++; in lpfc_sli4_async_fc_evt()
6343 lpfc_read_topology(phba, pmb, (struct lpfc_dmabuf *)pmb->ctx_buf); in lpfc_sli4_async_fc_evt()
6344 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_sli4_async_fc_evt()
6345 pmb->vport = phba->pport; in lpfc_sli4_async_fc_evt()
6347 if (phba->sli4_hba.link_state.status != LPFC_FC_LA_TYPE_LINK_UP) { in lpfc_sli4_async_fc_evt()
6348 phba->link_flag &= ~(LS_MDS_LINK_DOWN | LS_MDS_LOOPBACK); in lpfc_sli4_async_fc_evt()
6350 switch (phba->sli4_hba.link_state.status) { in lpfc_sli4_async_fc_evt()
6352 phba->link_flag |= LS_MDS_LINK_DOWN; in lpfc_sli4_async_fc_evt()
6355 phba->link_flag |= LS_MDS_LOOPBACK; in lpfc_sli4_async_fc_evt()
6362 mb = &pmb->u.mb; in lpfc_sli4_async_fc_evt()
6363 mb->mbxStatus = MBX_SUCCESS; in lpfc_sli4_async_fc_evt()
6369 la = (struct lpfc_mbx_read_top *)&pmb->u.mb.un.varReadTop; in lpfc_sli4_async_fc_evt()
6370 la->eventTag = acqe_fc->event_tag; in lpfc_sli4_async_fc_evt()
6372 if (phba->sli4_hba.link_state.status == in lpfc_sli4_async_fc_evt()
6396 * lpfc_sli4_async_sli_evt - Process the asynchronous SLI link event
6420 "2901 Async SLI event - Type:%d, Event Data: x%08x " in lpfc_sli4_async_sli_evt()
6422 acqe_sli->event_data1, acqe_sli->event_data2, in lpfc_sli4_async_sli_evt()
6423 acqe_sli->event_data3, acqe_sli->trailer); in lpfc_sli4_async_sli_evt()
6425 port_name = phba->Port[0]; in lpfc_sli4_async_sli_evt()
6433 temp_event_data.data = (uint32_t)acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6436 "3190 Over Temperature:%d Celsius- Port Name %c\n", in lpfc_sli4_async_sli_evt()
6437 acqe_sli->event_data1, port_name); in lpfc_sli4_async_sli_evt()
6439 phba->sfp_warning |= LPFC_TRANSGRESSION_HIGH_TEMPERATURE; in lpfc_sli4_async_sli_evt()
6440 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli4_async_sli_evt()
6450 temp_event_data.data = (uint32_t)acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6453 "3191 Normal Temperature:%d Celsius - Port Name %c\n", in lpfc_sli4_async_sli_evt()
6454 acqe_sli->event_data1, port_name); in lpfc_sli4_async_sli_evt()
6456 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli4_async_sli_evt()
6465 &acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6468 switch (phba->sli4_hba.lnk_info.lnk_no) { in lpfc_sli4_async_sli_evt()
6471 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6473 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6477 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6479 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6483 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6485 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6489 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6491 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6498 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_async_sli_evt()
6503 if (phba->sli4_hba.lnk_info.optic_state == status) in lpfc_sli4_async_sli_evt()
6512 "installed/not installed - Reseat optics, " in lpfc_sli4_async_sli_evt()
6517 "Optics of two types installed - Remove one " in lpfc_sli4_async_sli_evt()
6521 sprintf(message, "Incompatible optics - Replace with " in lpfc_sli4_async_sli_evt()
6525 sprintf(message, "Unqualified optics - Replace with " in lpfc_sli4_async_sli_evt()
6527 "Support - Link is%s operational", in lpfc_sli4_async_sli_evt()
6531 sprintf(message, "Uncertified optics - Replace with " in lpfc_sli4_async_sli_evt()
6532 "Avago-certified optics to enable link " in lpfc_sli4_async_sli_evt()
6533 "operation - Link is%s operational", in lpfc_sli4_async_sli_evt()
6545 phba->lmt = 0; in lpfc_sli4_async_sli_evt()
6559 for (i = 0; i <= phba->max_vports && vports[i] != NULL; in lpfc_sli4_async_sli_evt()
6567 phba->sli4_hba.lnk_info.optic_state = status; in lpfc_sli4_async_sli_evt()
6573 "3192 Remote DPort Test Initiated - " in lpfc_sli4_async_sli_evt()
6575 acqe_sli->event_data1, acqe_sli->event_data2); in lpfc_sli4_async_sli_evt()
6583 * to use FA-WWN, but the attached device doesn’t support it. in lpfc_sli4_async_sli_evt()
6584 * Event Data1 - N.A, Event Data2 - N.A in lpfc_sli4_async_sli_evt()
6588 "2699 Misconfigured FA-PWWN - Attached device " in lpfc_sli4_async_sli_evt()
6589 "does not support FA-PWWN\n"); in lpfc_sli4_async_sli_evt()
6590 phba->sli4_hba.fawwpn_flag &= ~LPFC_FAWWPN_FABRIC; in lpfc_sli4_async_sli_evt()
6591 memset(phba->pport->fc_portname.u.wwn, 0, in lpfc_sli4_async_sli_evt()
6597 "2518 EEPROM failure - " in lpfc_sli4_async_sli_evt()
6599 acqe_sli->event_data1, acqe_sli->event_data2); in lpfc_sli4_async_sli_evt()
6602 if (phba->cmf_active_mode == LPFC_CFG_OFF) in lpfc_sli4_async_sli_evt()
6605 &acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6606 phba->cgn_acqe_cnt++; in lpfc_sli4_async_sli_evt()
6609 atomic64_add(cnt, &phba->cgn_acqe_stat.warn); in lpfc_sli4_async_sli_evt()
6610 atomic64_add(cgn_signal->alarm_cnt, &phba->cgn_acqe_stat.alarm); in lpfc_sli4_async_sli_evt()
6615 if (cgn_signal->alarm_cnt) { in lpfc_sli4_async_sli_evt()
6616 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { in lpfc_sli4_async_sli_evt()
6618 atomic_add(cgn_signal->alarm_cnt, in lpfc_sli4_async_sli_evt()
6619 &phba->cgn_sync_alarm_cnt); in lpfc_sli4_async_sli_evt()
6623 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY || in lpfc_sli4_async_sli_evt()
6624 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { in lpfc_sli4_async_sli_evt()
6626 atomic_add(cnt, &phba->cgn_sync_warn_cnt); in lpfc_sli4_async_sli_evt()
6636 acqe_sli->event_data1, acqe_sli->event_data2, in lpfc_sli4_async_sli_evt()
6637 acqe_sli->event_data3); in lpfc_sli4_async_sli_evt()
6648 * lpfc_sli4_perform_vport_cvl - Perform clear virtual link on a vport
6666 phba = vport->phba; in lpfc_sli4_perform_vport_cvl()
6676 ndlp->nlp_type |= NLP_FABRIC; in lpfc_sli4_perform_vport_cvl()
6680 if ((phba->pport->port_state < LPFC_FLOGI) && in lpfc_sli4_perform_vport_cvl()
6681 (phba->pport->port_state != LPFC_VPORT_FAILED)) in lpfc_sli4_perform_vport_cvl()
6684 if ((vport != phba->pport) && (vport->port_state < LPFC_FDISC) in lpfc_sli4_perform_vport_cvl()
6685 && (vport->port_state != LPFC_VPORT_FAILED)) in lpfc_sli4_perform_vport_cvl()
6692 spin_lock_irq(shost->host_lock); in lpfc_sli4_perform_vport_cvl()
6693 vport->fc_flag |= FC_VPORT_CVL_RCVD; in lpfc_sli4_perform_vport_cvl()
6694 spin_unlock_irq(shost->host_lock); in lpfc_sli4_perform_vport_cvl()
6700 * lpfc_sli4_perform_all_vport_cvl - Perform clear virtual link on all vports
6714 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) in lpfc_sli4_perform_all_vport_cvl()
6720 * lpfc_sli4_async_fip_evt - Process the asynchronous FCoE FIP event
6738 phba->fc_eventTag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6739 phba->fcoe_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6747 acqe_fip->event_tag, in lpfc_sli4_async_fip_evt()
6748 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6754 acqe_fip->event_tag, in lpfc_sli4_async_fip_evt()
6755 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6756 if (phba->fcf.fcf_flag & FCF_DISCOVERY) { in lpfc_sli4_async_fip_evt()
6766 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6767 rc = lpfc_sli4_read_fcf_rec(phba, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6771 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6772 if (phba->hba_flag & FCF_TS_INPROG) { in lpfc_sli4_async_fip_evt()
6773 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6777 if (phba->fcf.fcf_flag & (FCF_REDISC_EVT | FCF_REDISC_PEND)) { in lpfc_sli4_async_fip_evt()
6778 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6783 if (phba->fcf.fcf_flag & FCF_SCAN_DONE) { in lpfc_sli4_async_fip_evt()
6784 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6787 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6789 /* Otherwise, scan the entire FCF table and re-discover SAN */ in lpfc_sli4_async_fip_evt()
6793 acqe_fip->event_tag, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6806 acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6810 phba->fcoe_cvl_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6813 "tag:x%x\n", acqe_fip->index, in lpfc_sli4_async_fip_evt()
6814 acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6819 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6820 if ((phba->fcf.fcf_flag & FCF_DISCOVERY) && in lpfc_sli4_async_fip_evt()
6821 (phba->fcf.current_rec.fcf_indx != acqe_fip->index)) { in lpfc_sli4_async_fip_evt()
6822 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6824 lpfc_sli4_fcf_rr_index_clear(phba, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6827 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6830 if (phba->fcf.current_rec.fcf_indx != acqe_fip->index) in lpfc_sli4_async_fip_evt()
6839 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6841 phba->fcf.fcf_flag |= FCF_DEAD_DISC; in lpfc_sli4_async_fip_evt()
6842 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6847 "\n", acqe_fip->event_tag, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6855 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6856 phba->fcf.fcf_flag &= ~FCF_DEAD_DISC; in lpfc_sli4_async_fip_evt()
6857 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6874 phba->fcoe_cvl_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6878 " tag 0x%x\n", acqe_fip->index, acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6881 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6889 for (i = 0; i <= phba->max_vports && vports[i] != NULL; in lpfc_sli4_async_fip_evt()
6891 if ((!(vports[i]->fc_flag & in lpfc_sli4_async_fip_evt()
6893 (vports[i]->port_state > LPFC_FDISC)) { in lpfc_sli4_async_fip_evt()
6902 * Don't re-instantiate if vport is marked for deletion. in lpfc_sli4_async_fip_evt()
6906 if (!(vport->load_flag & FC_UNLOADING) && in lpfc_sli4_async_fip_evt()
6910 * re-instantiate the Vlink using FDISC. in lpfc_sli4_async_fip_evt()
6912 mod_timer(&ndlp->nlp_delayfunc, in lpfc_sli4_async_fip_evt()
6914 spin_lock_irq(&ndlp->lock); in lpfc_sli4_async_fip_evt()
6915 ndlp->nlp_flag |= NLP_DELAY_TMO; in lpfc_sli4_async_fip_evt()
6916 spin_unlock_irq(&ndlp->lock); in lpfc_sli4_async_fip_evt()
6917 ndlp->nlp_last_elscmd = ELS_CMD_FDISC; in lpfc_sli4_async_fip_evt()
6918 vport->port_state = LPFC_FDISC; in lpfc_sli4_async_fip_evt()
6927 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6928 if (phba->fcf.fcf_flag & FCF_DISCOVERY) { in lpfc_sli4_async_fip_evt()
6929 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6933 phba->fcf.fcf_flag |= FCF_ACVL_DISC; in lpfc_sli4_async_fip_evt()
6934 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6938 "evt_tag:x%x\n", acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6946 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6947 phba->fcf.fcf_flag &= ~FCF_ACVL_DISC; in lpfc_sli4_async_fip_evt()
6948 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6950 * Last resort will be re-try on the in lpfc_sli4_async_fip_evt()
6965 "0x%x\n", event_type, acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6971 * lpfc_sli4_async_dcbx_evt - Process the asynchronous dcbx event
6981 phba->fc_eventTag = acqe_dcbx->event_tag; in lpfc_sli4_async_dcbx_evt()
6988 * lpfc_sli4_async_grp5_evt - Process the asynchronous group5 event
7002 phba->fc_eventTag = acqe_grp5->event_tag; in lpfc_sli4_async_grp5_evt()
7003 phba->fcoe_eventtag = acqe_grp5->event_tag; in lpfc_sli4_async_grp5_evt()
7004 prev_ll_spd = phba->sli4_hba.link_state.logical_speed; in lpfc_sli4_async_grp5_evt()
7005 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_grp5_evt()
7010 phba->sli4_hba.link_state.logical_speed); in lpfc_sli4_async_grp5_evt()
7014 * lpfc_sli4_async_cmstat_evt - Process the asynchronous cmstat event
7023 if (!phba->cgn_i) in lpfc_sli4_async_cmstat_evt()
7029 * lpfc_cgn_params_val - Validate FW congestion parameters.
7039 spin_lock_irq(&phba->hbalock); in lpfc_cgn_params_val()
7041 if (!lpfc_rangecheck(p_cfg_param->cgn_param_mode, LPFC_CFG_OFF, in lpfc_cgn_params_val()
7045 p_cfg_param->cgn_param_mode); in lpfc_cgn_params_val()
7046 p_cfg_param->cgn_param_mode = LPFC_CFG_OFF; in lpfc_cgn_params_val()
7049 spin_unlock_irq(&phba->hbalock); in lpfc_cgn_params_val()
7059 * lpfc_cgn_params_parse - Process a FW cong parm change event
7066 * valid, in-range values. If the signature magic is correct and
7082 if (p_cgn_param->cgn_param_magic == LPFC_CFG_PARAM_MAGIC_NUM) { in lpfc_cgn_params_parse()
7090 p_cgn_param->cgn_param_magic, in lpfc_cgn_params_parse()
7091 p_cgn_param->cgn_param_version, in lpfc_cgn_params_parse()
7092 p_cgn_param->cgn_param_mode, in lpfc_cgn_params_parse()
7093 p_cgn_param->cgn_param_level0, in lpfc_cgn_params_parse()
7094 p_cgn_param->cgn_param_level1, in lpfc_cgn_params_parse()
7095 p_cgn_param->cgn_param_level2, in lpfc_cgn_params_parse()
7096 p_cgn_param->byte13, in lpfc_cgn_params_parse()
7097 p_cgn_param->byte14, in lpfc_cgn_params_parse()
7098 p_cgn_param->byte15, in lpfc_cgn_params_parse()
7099 p_cgn_param->byte11, in lpfc_cgn_params_parse()
7100 p_cgn_param->byte12, in lpfc_cgn_params_parse()
7101 phba->cmf_active_mode); in lpfc_cgn_params_parse()
7103 oldmode = phba->cmf_active_mode; in lpfc_cgn_params_parse()
7111 spin_lock_irq(&phba->hbalock); in lpfc_cgn_params_parse()
7112 memcpy(&phba->cgn_p, p_cgn_param, in lpfc_cgn_params_parse()
7116 if (phba->cgn_i) { in lpfc_cgn_params_parse()
7117 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_cgn_params_parse()
7118 cp->cgn_info_mode = phba->cgn_p.cgn_param_mode; in lpfc_cgn_params_parse()
7119 cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0; in lpfc_cgn_params_parse()
7120 cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1; in lpfc_cgn_params_parse()
7121 cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2; in lpfc_cgn_params_parse()
7124 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_cgn_params_parse()
7126 spin_unlock_irq(&phba->hbalock); in lpfc_cgn_params_parse()
7128 phba->cmf_active_mode = phba->cgn_p.cgn_param_mode; in lpfc_cgn_params_parse()
7132 if (phba->cgn_p.cgn_param_mode != LPFC_CFG_OFF) { in lpfc_cgn_params_parse()
7136 if (phba->link_state >= LPFC_LINK_UP) { in lpfc_cgn_params_parse()
7137 phba->cgn_reg_fpin = in lpfc_cgn_params_parse()
7138 phba->cgn_init_reg_fpin; in lpfc_cgn_params_parse()
7139 phba->cgn_reg_signal = in lpfc_cgn_params_parse()
7140 phba->cgn_init_reg_signal; in lpfc_cgn_params_parse()
7141 lpfc_issue_els_edc(phba->pport, 0); in lpfc_cgn_params_parse()
7146 switch (phba->cgn_p.cgn_param_mode) { in lpfc_cgn_params_parse()
7150 if (phba->link_state >= LPFC_LINK_UP) in lpfc_cgn_params_parse()
7151 lpfc_issue_els_edc(phba->pport, 0); in lpfc_cgn_params_parse()
7154 phba->cmf_max_bytes_per_interval = in lpfc_cgn_params_parse()
7155 phba->cmf_link_byte_count; in lpfc_cgn_params_parse()
7157 /* Resume blocked IO - unblock on workqueue */ in lpfc_cgn_params_parse()
7158 queue_work(phba->wq, in lpfc_cgn_params_parse()
7159 &phba->unblock_request_work); in lpfc_cgn_params_parse()
7164 switch (phba->cgn_p.cgn_param_mode) { in lpfc_cgn_params_parse()
7168 if (phba->link_state >= LPFC_LINK_UP) in lpfc_cgn_params_parse()
7169 lpfc_issue_els_edc(phba->pport, 0); in lpfc_cgn_params_parse()
7178 oldmode != phba->cgn_p.cgn_param_mode) { in lpfc_cgn_params_parse()
7179 if (phba->cgn_p.cgn_param_mode == LPFC_CFG_MANAGED) in lpfc_cgn_params_parse()
7181 phba->cgn_p.cgn_param_level0); in lpfc_cgn_params_parse()
7185 dev_info(&phba->pcidev->dev, "%d: " in lpfc_cgn_params_parse()
7187 phba->brd_no, in lpfc_cgn_params_parse()
7189 [phba->cgn_p.cgn_param_mode], in lpfc_cgn_params_parse()
7195 "version %d\n", p_cgn_param->cgn_param_magic, in lpfc_cgn_params_parse()
7196 p_cgn_param->cgn_param_version); in lpfc_cgn_params_parse()
7201 * lpfc_sli4_cgn_params_read - Read and Validate FW congestion parameters.
7210 * -Eval if an error was encountered
7225 return -ENOMEM; in lpfc_sli4_cgn_params_read()
7257 * lpfc_sli4_cgn_parm_chg_evt - Process a FW congestion param change event
7279 if (!phba->sli4_hba.pc_sli4_params.cmf) { in lpfc_sli4_cgn_parm_chg_evt()
7282 return -EACCES; in lpfc_sli4_cgn_parm_chg_evt()
7302 * lpfc_sli4_async_event_proc - Process all the pending asynchronous event
7314 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_async_event_proc()
7315 phba->hba_flag &= ~ASYNC_EVENT; in lpfc_sli4_async_event_proc()
7316 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_async_event_proc()
7319 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
7320 while (!list_empty(&phba->sli4_hba.sp_asynce_work_queue)) { in lpfc_sli4_async_event_proc()
7321 list_remove_head(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_async_event_proc()
7323 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, in lpfc_sli4_async_event_proc()
7327 switch (bf_get(lpfc_trailer_code, &cq_event->cqe.mcqe_cmpl)) { in lpfc_sli4_async_event_proc()
7330 &cq_event->cqe.acqe_link); in lpfc_sli4_async_event_proc()
7333 lpfc_sli4_async_fip_evt(phba, &cq_event->cqe.acqe_fip); in lpfc_sli4_async_event_proc()
7337 &cq_event->cqe.acqe_dcbx); in lpfc_sli4_async_event_proc()
7341 &cq_event->cqe.acqe_grp5); in lpfc_sli4_async_event_proc()
7344 lpfc_sli4_async_fc_evt(phba, &cq_event->cqe.acqe_fc); in lpfc_sli4_async_event_proc()
7347 lpfc_sli4_async_sli_evt(phba, &cq_event->cqe.acqe_sli); in lpfc_sli4_async_event_proc()
7357 &cq_event->cqe.mcqe_cmpl)); in lpfc_sli4_async_event_proc()
7363 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
7365 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
7369 * lpfc_sli4_fcf_redisc_event_proc - Process fcf table rediscovery event
7379 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_event_proc()
7381 phba->fcf.fcf_flag &= ~FCF_REDISC_EVT; in lpfc_sli4_fcf_redisc_event_proc()
7383 phba->fcf.failover_rec.flag = 0; in lpfc_sli4_fcf_redisc_event_proc()
7385 phba->fcf.fcf_flag |= FCF_REDISC_FOV; in lpfc_sli4_fcf_redisc_event_proc()
7386 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_event_proc()
7388 /* Scan FCF table from the first entry to re-discover SAN */ in lpfc_sli4_fcf_redisc_event_proc()
7390 "2777 Start post-quiescent FCF table scan\n"); in lpfc_sli4_fcf_redisc_event_proc()
7399 * lpfc_api_table_setup - Set up per hba pci-device group func api jump table
7401 * @dev_grp: The HBA PCI-Device group number.
7403 * This routine is invoked to set up the per HBA PCI-Device group function
7406 * Return: 0 if success, otherwise -ENODEV
7413 /* Set up lpfc PCI-device group */ in lpfc_api_table_setup()
7414 phba->pci_dev_grp = dev_grp; in lpfc_api_table_setup()
7418 phba->sli_rev = LPFC_SLI_REV4; in lpfc_api_table_setup()
7423 return -ENODEV; in lpfc_api_table_setup()
7427 return -ENODEV; in lpfc_api_table_setup()
7431 return -ENODEV; in lpfc_api_table_setup()
7435 return -ENODEV; in lpfc_api_table_setup()
7441 * lpfc_log_intr_mode - Log the active interrupt mode
7461 "0480 Enabled MSI-X interrupt mode.\n"); in lpfc_log_intr_mode()
7472 * lpfc_enable_pci_dev - Enable a generic PCI device.
7479 * 0 - successful
7480 * other values - error
7488 if (!phba->pcidev) in lpfc_enable_pci_dev()
7491 pdev = phba->pcidev; in lpfc_enable_pci_dev()
7505 pdev->needs_freset = 1; in lpfc_enable_pci_dev()
7514 return -ENODEV; in lpfc_enable_pci_dev()
7518 * lpfc_disable_pci_dev - Disable a generic PCI device.
7530 if (!phba->pcidev) in lpfc_disable_pci_dev()
7533 pdev = phba->pcidev; in lpfc_disable_pci_dev()
7542 * lpfc_reset_hba - Reset a hba
7556 if (!phba->cfg_enable_hba_reset) { in lpfc_reset_hba()
7557 phba->link_state = LPFC_HBA_ERROR; in lpfc_reset_hba()
7562 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE) { in lpfc_reset_hba()
7565 if (test_bit(MBX_TMO_ERR, &phba->bit_flags)) { in lpfc_reset_hba()
7574 clear_bit(MBX_TMO_ERR, &phba->bit_flags); in lpfc_reset_hba()
7587 * lpfc_sli_sriov_nr_virtfn_get - Get the number of sr-iov virtual functions
7590 * This function enables the PCI SR-IOV virtual functions to a physical
7591 * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
7593 * not all devices support SR-IOV, the return code from the pci_enable_sriov()
7599 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_sriov_nr_virtfn_get()
7612 * lpfc_sli_probe_sriov_nr_virtfn - Enable a number of sr-iov virtual functions
7616 * This function enables the PCI SR-IOV virtual functions to a physical
7617 * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
7619 * not all devices support SR-IOV, the return code from the pci_enable_sriov()
7625 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_probe_sriov_nr_virtfn()
7634 return -EINVAL; in lpfc_sli_probe_sriov_nr_virtfn()
7660 * lpfc_setup_driver_resource_phase1 - Phase1 etup driver internal resources.
7667 * 0 - successful
7668 * other values - error
7673 struct lpfc_sli *psli = &phba->sli; in lpfc_setup_driver_resource_phase1()
7678 atomic_set(&phba->fast_event_count, 0); in lpfc_setup_driver_resource_phase1()
7679 atomic_set(&phba->dbg_log_idx, 0); in lpfc_setup_driver_resource_phase1()
7680 atomic_set(&phba->dbg_log_cnt, 0); in lpfc_setup_driver_resource_phase1()
7681 atomic_set(&phba->dbg_log_dmping, 0); in lpfc_setup_driver_resource_phase1()
7682 spin_lock_init(&phba->hbalock); in lpfc_setup_driver_resource_phase1()
7685 spin_lock_init(&phba->port_list_lock); in lpfc_setup_driver_resource_phase1()
7686 INIT_LIST_HEAD(&phba->port_list); in lpfc_setup_driver_resource_phase1()
7688 INIT_LIST_HEAD(&phba->work_list); in lpfc_setup_driver_resource_phase1()
7691 init_waitqueue_head(&phba->work_waitq); in lpfc_setup_driver_resource_phase1()
7695 ((phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ? in lpfc_setup_driver_resource_phase1()
7697 ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) ? in lpfc_setup_driver_resource_phase1()
7699 (phba->nvmet_support ? "NVMET" : " ")); in lpfc_setup_driver_resource_phase1()
7702 spin_lock_init(&phba->scsi_buf_list_get_lock); in lpfc_setup_driver_resource_phase1()
7703 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_get); in lpfc_setup_driver_resource_phase1()
7704 spin_lock_init(&phba->scsi_buf_list_put_lock); in lpfc_setup_driver_resource_phase1()
7705 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_put); in lpfc_setup_driver_resource_phase1()
7708 INIT_LIST_HEAD(&phba->fabric_iocb_list); in lpfc_setup_driver_resource_phase1()
7711 INIT_LIST_HEAD(&phba->elsbuf); in lpfc_setup_driver_resource_phase1()
7714 INIT_LIST_HEAD(&phba->fcf_conn_rec_list); in lpfc_setup_driver_resource_phase1()
7717 spin_lock_init(&phba->devicelock); in lpfc_setup_driver_resource_phase1()
7718 INIT_LIST_HEAD(&phba->luns); in lpfc_setup_driver_resource_phase1()
7721 timer_setup(&psli->mbox_tmo, lpfc_mbox_timeout, 0); in lpfc_setup_driver_resource_phase1()
7723 timer_setup(&phba->fabric_block_timer, lpfc_fabric_block_timeout, 0); in lpfc_setup_driver_resource_phase1()
7725 timer_setup(&phba->eratt_poll, lpfc_poll_eratt, 0); in lpfc_setup_driver_resource_phase1()
7727 timer_setup(&phba->hb_tmofunc, lpfc_hb_timeout, 0); in lpfc_setup_driver_resource_phase1()
7729 INIT_DELAYED_WORK(&phba->eq_delay_work, lpfc_hb_eq_delay_work); in lpfc_setup_driver_resource_phase1()
7731 INIT_DELAYED_WORK(&phba->idle_stat_delay_work, in lpfc_setup_driver_resource_phase1()
7733 INIT_WORK(&phba->unblock_request_work, lpfc_unblock_requests_work); in lpfc_setup_driver_resource_phase1()
7738 * lpfc_sli_driver_resource_setup - Setup driver internal resources for SLI3 dev
7742 * support the SLI-3 HBA device it attached to.
7745 * 0 - successful
7746 * other values - error
7758 timer_setup(&phba->fcp_poll_timer, lpfc_poll_timeout, 0); in lpfc_sli_driver_resource_setup()
7761 phba->work_ha_mask = (HA_ERATT | HA_MBATT | HA_LATT); in lpfc_sli_driver_resource_setup()
7762 phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING * 4)); in lpfc_sli_driver_resource_setup()
7766 /* Set up phase-1 common device driver resources */ in lpfc_sli_driver_resource_setup()
7770 return -ENODEV; in lpfc_sli_driver_resource_setup()
7772 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
7773 phba->sli.sli3_ring = kcalloc(LPFC_SLI3_MAX_RING, in lpfc_sli_driver_resource_setup()
7776 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
7777 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7784 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_driver_resource_setup()
7790 if (phba->cfg_enable_bg) { in lpfc_sli_driver_resource_setup()
7792 * The scsi_buf for a T10-DIF I/O will hold the FCP cmnd, in lpfc_sli_driver_resource_setup()
7800 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
7804 if (phba->cfg_sg_seg_cnt > LPFC_MAX_SG_SEG_CNT_DIF) in lpfc_sli_driver_resource_setup()
7805 phba->cfg_sg_seg_cnt = LPFC_MAX_SG_SEG_CNT_DIF; in lpfc_sli_driver_resource_setup()
7808 phba->cfg_total_seg_cnt = LPFC_MAX_SG_SEG_CNT; in lpfc_sli_driver_resource_setup()
7815 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
7817 ((phba->cfg_sg_seg_cnt + 2) * entry_sz); in lpfc_sli_driver_resource_setup()
7820 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + 2; in lpfc_sli_driver_resource_setup()
7825 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
7826 phba->cfg_total_seg_cnt); in lpfc_sli_driver_resource_setup()
7828 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli_driver_resource_setup()
7830 phba->max_vports = 0; in lpfc_sli_driver_resource_setup()
7840 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7842 phba->lpfc_sg_dma_buf_pool = in lpfc_sli_driver_resource_setup()
7844 &phba->pcidev->dev, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
7847 if (!phba->lpfc_sg_dma_buf_pool) in lpfc_sli_driver_resource_setup()
7850 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli_driver_resource_setup()
7852 &phba->pcidev->dev, in lpfc_sli_driver_resource_setup()
7857 if (!phba->lpfc_cmd_rsp_buf_pool) in lpfc_sli_driver_resource_setup()
7861 * Enable sr-iov virtual functions if supported and configured in lpfc_sli_driver_resource_setup()
7864 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli_driver_resource_setup()
7866 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
7869 "2808 Requested number of SR-IOV " in lpfc_sli_driver_resource_setup()
7872 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
7873 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli_driver_resource_setup()
7880 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli_driver_resource_setup()
7881 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli_driver_resource_setup()
7884 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7888 * lpfc_sli_driver_resource_unset - Unset drvr internal resources for SLI3 dev
7892 * specific for supporting the SLI-3 HBA device it attached to.
7904 * lpfc_sli4_driver_resource_setup - Setup drvr internal resources for SLI4 dev
7908 * support the SLI-4 HBA device it attached to.
7911 * 0 - successful
7912 * other values - error
7926 phba->sli4_hba.num_present_cpu = lpfc_present_cpu; in lpfc_sli4_driver_resource_setup()
7927 phba->sli4_hba.num_possible_cpu = cpumask_last(cpu_possible_mask) + 1; in lpfc_sli4_driver_resource_setup()
7928 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_setup()
7933 /* Set up phase-1 common device driver resources */ in lpfc_sli4_driver_resource_setup()
7936 return -ENODEV; in lpfc_sli4_driver_resource_setup()
7941 return -ENODEV; in lpfc_sli4_driver_resource_setup()
7946 phba->wq = alloc_workqueue("lpfc_wq", WQ_MEM_RECLAIM, 0); in lpfc_sli4_driver_resource_setup()
7947 if (!phba->wq) in lpfc_sli4_driver_resource_setup()
7948 return -ENOMEM; in lpfc_sli4_driver_resource_setup()
7954 timer_setup(&phba->rrq_tmr, lpfc_rrq_timeout, 0); in lpfc_sli4_driver_resource_setup()
7957 timer_setup(&phba->fcf.redisc_wait, lpfc_sli4_fcf_redisc_wait_tmo, 0); in lpfc_sli4_driver_resource_setup()
7960 hrtimer_init(&phba->cmf_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in lpfc_sli4_driver_resource_setup()
7961 phba->cmf_timer.function = lpfc_cmf_timer; in lpfc_sli4_driver_resource_setup()
7963 hrtimer_init(&phba->cmf_stats_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in lpfc_sli4_driver_resource_setup()
7964 phba->cmf_stats_timer.function = lpfc_cmf_stats_timer; in lpfc_sli4_driver_resource_setup()
7967 * Control structure for handling external multi-buffer mailbox in lpfc_sli4_driver_resource_setup()
7968 * command pass-through. in lpfc_sli4_driver_resource_setup()
7970 memset((uint8_t *)&phba->mbox_ext_buf_ctx, 0, in lpfc_sli4_driver_resource_setup()
7972 INIT_LIST_HEAD(&phba->mbox_ext_buf_ctx.ext_dmabuf_list); in lpfc_sli4_driver_resource_setup()
7974 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli4_driver_resource_setup()
7977 phba->max_vports = 0; in lpfc_sli4_driver_resource_setup()
7980 phba->valid_vlan = 0; in lpfc_sli4_driver_resource_setup()
7981 phba->fc_map[0] = LPFC_FCOE_FCF_MAP0; in lpfc_sli4_driver_resource_setup()
7982 phba->fc_map[1] = LPFC_FCOE_FCF_MAP1; in lpfc_sli4_driver_resource_setup()
7983 phba->fc_map[2] = LPFC_FCOE_FCF_MAP2; in lpfc_sli4_driver_resource_setup()
7992 INIT_LIST_HEAD(&phba->hbqs[LPFC_ELS_HBQ].hbq_buffer_list); in lpfc_sli4_driver_resource_setup()
7993 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_sli4_rb_alloc; in lpfc_sli4_driver_resource_setup()
7994 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_sli4_rb_free; in lpfc_sli4_driver_resource_setup()
7998 timer_setup(&phba->inactive_vmid_poll, lpfc_vmid_poll, 0); in lpfc_sli4_driver_resource_setup()
8004 spin_lock_init(&phba->sli4_hba.abts_io_buf_list_lock); in lpfc_sli4_driver_resource_setup()
8005 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_io_buf_list); in lpfc_sli4_driver_resource_setup()
8007 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
8009 spin_lock_init(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_sli4_driver_resource_setup()
8010 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_driver_resource_setup()
8011 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_io_wait_list); in lpfc_sli4_driver_resource_setup()
8012 spin_lock_init(&phba->sli4_hba.t_active_list_lock); in lpfc_sli4_driver_resource_setup()
8013 INIT_LIST_HEAD(&phba->sli4_hba.t_active_ctx_list); in lpfc_sli4_driver_resource_setup()
8017 spin_lock_init(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_driver_resource_setup()
8018 spin_lock_init(&phba->sli4_hba.nvmet_io_wait_lock); in lpfc_sli4_driver_resource_setup()
8019 spin_lock_init(&phba->sli4_hba.asynce_list_lock); in lpfc_sli4_driver_resource_setup()
8020 spin_lock_init(&phba->sli4_hba.els_xri_abrt_list_lock); in lpfc_sli4_driver_resource_setup()
8023 * Initialize driver internal slow-path work queues in lpfc_sli4_driver_resource_setup()
8026 /* Driver internel slow-path CQ Event pool */ in lpfc_sli4_driver_resource_setup()
8027 INIT_LIST_HEAD(&phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_driver_resource_setup()
8029 INIT_LIST_HEAD(&phba->sli4_hba.sp_queue_event); in lpfc_sli4_driver_resource_setup()
8031 INIT_LIST_HEAD(&phba->sli4_hba.sp_asynce_work_queue); in lpfc_sli4_driver_resource_setup()
8032 /* Slow-path XRI aborted CQ Event work queue list */ in lpfc_sli4_driver_resource_setup()
8033 INIT_LIST_HEAD(&phba->sli4_hba.sp_els_xri_aborted_work_queue); in lpfc_sli4_driver_resource_setup()
8035 INIT_LIST_HEAD(&phba->sli4_hba.sp_unsol_work_queue); in lpfc_sli4_driver_resource_setup()
8038 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_blk_list); in lpfc_sli4_driver_resource_setup()
8039 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_xri_blk_list); in lpfc_sli4_driver_resource_setup()
8040 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_vfi_blk_list); in lpfc_sli4_driver_resource_setup()
8041 INIT_LIST_HEAD(&phba->lpfc_vpi_blk_list); in lpfc_sli4_driver_resource_setup()
8046 INIT_LIST_HEAD(&phba->sli.mboxq); in lpfc_sli4_driver_resource_setup()
8047 INIT_LIST_HEAD(&phba->sli.mboxq_cmpl); in lpfc_sli4_driver_resource_setup()
8050 phba->sli4_hba.lnk_info.optic_state = 0xff; in lpfc_sli4_driver_resource_setup()
8058 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_driver_resource_setup()
8062 rc = -ENODEV; in lpfc_sli4_driver_resource_setup()
8065 phba->temp_sensor_support = 1; in lpfc_sli4_driver_resource_setup()
8083 if (phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_CONFIG) { in lpfc_sli4_driver_resource_setup()
8084 /* Right now the link is down, if FA-PWWN is configured the in lpfc_sli4_driver_resource_setup()
8091 phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_FABRIC; in lpfc_sli4_driver_resource_setup()
8099 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_driver_resource_setup()
8106 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_sli4_driver_resource_setup()
8109 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8114 phba->nvmet_support = 0; in lpfc_sli4_driver_resource_setup()
8125 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_driver_resource_setup()
8126 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_driver_resource_setup()
8127 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8128 rc = -EIO; in lpfc_sli4_driver_resource_setup()
8131 mb = &mboxq->u.mb; in lpfc_sli4_driver_resource_setup()
8132 memcpy(&wwn, (char *)mb->un.varRDnvp.nodename, in lpfc_sli4_driver_resource_setup()
8135 phba->sli4_hba.wwnn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
8136 memcpy(&wwn, (char *)mb->un.varRDnvp.portname, in lpfc_sli4_driver_resource_setup()
8140 phba->sli4_hba.wwpn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
8149 phba->nvmet_support = 1; /* a match */ in lpfc_sli4_driver_resource_setup()
8163 phba->cfg_xri_rebalancing = 0; in lpfc_sli4_driver_resource_setup()
8164 if (phba->irq_chann_mode == NHT_MODE) { in lpfc_sli4_driver_resource_setup()
8165 phba->cfg_irq_chann = in lpfc_sli4_driver_resource_setup()
8166 phba->sli4_hba.num_present_cpu; in lpfc_sli4_driver_resource_setup()
8167 phba->cfg_hdw_queue = in lpfc_sli4_driver_resource_setup()
8168 phba->sli4_hba.num_present_cpu; in lpfc_sli4_driver_resource_setup()
8169 phba->irq_chann_mode = NORMAL_MODE; in lpfc_sli4_driver_resource_setup()
8186 &phba->sli4_hba.sli_intf); in lpfc_sli4_driver_resource_setup()
8188 &phba->sli4_hba.sli_intf); in lpfc_sli4_driver_resource_setup()
8189 if (phba->sli4_hba.extents_in_use && in lpfc_sli4_driver_resource_setup()
8190 phba->sli4_hba.rpi_hdrs_in_use) { in lpfc_sli4_driver_resource_setup()
8196 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8197 rc = -EIO; in lpfc_sli4_driver_resource_setup()
8203 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8204 rc = -EIO; in lpfc_sli4_driver_resource_setup()
8214 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_driver_resource_setup()
8228 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) { in lpfc_sli4_driver_resource_setup()
8232 * The scsi_buf for a T10-DIF I/O holds the FCP cmnd, in lpfc_sli4_driver_resource_setup()
8240 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli4_driver_resource_setup()
8244 phba->cfg_total_seg_cnt = LPFC_MAX_SGL_SEG_CNT; in lpfc_sli4_driver_resource_setup()
8250 if (phba->cfg_enable_bg && in lpfc_sli4_driver_resource_setup()
8251 phba->cfg_sg_seg_cnt > LPFC_MAX_BG_SLI4_SEG_CNT_DIF) in lpfc_sli4_driver_resource_setup()
8252 phba->cfg_scsi_seg_cnt = LPFC_MAX_BG_SLI4_SEG_CNT_DIF; in lpfc_sli4_driver_resource_setup()
8254 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8262 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli4_driver_resource_setup()
8264 ((phba->cfg_sg_seg_cnt + extra) * in lpfc_sli4_driver_resource_setup()
8268 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + extra; in lpfc_sli4_driver_resource_setup()
8269 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8272 * NOTE: if (phba->cfg_sg_seg_cnt + extra) <= 256 we only in lpfc_sli4_driver_resource_setup()
8277 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_driver_resource_setup()
8278 phba->cfg_sg_dma_buf_size = LPFC_DEFAULT_XPSGL_SIZE; in lpfc_sli4_driver_resource_setup()
8279 else if (phba->cfg_sg_dma_buf_size <= LPFC_MIN_SG_SLI4_BUF_SZ) in lpfc_sli4_driver_resource_setup()
8280 phba->cfg_sg_dma_buf_size = LPFC_MIN_SG_SLI4_BUF_SZ; in lpfc_sli4_driver_resource_setup()
8282 phba->cfg_sg_dma_buf_size = in lpfc_sli4_driver_resource_setup()
8283 SLI4_PAGE_ALIGN(phba->cfg_sg_dma_buf_size); in lpfc_sli4_driver_resource_setup()
8285 phba->border_sge_num = phba->cfg_sg_dma_buf_size / in lpfc_sli4_driver_resource_setup()
8289 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
8290 if (phba->cfg_sg_seg_cnt > LPFC_MAX_NVME_SEG_CNT) { in lpfc_sli4_driver_resource_setup()
8295 phba->cfg_nvme_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_sli4_driver_resource_setup()
8297 phba->cfg_nvme_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8303 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
8304 phba->cfg_total_seg_cnt, phba->cfg_scsi_seg_cnt, in lpfc_sli4_driver_resource_setup()
8305 phba->cfg_nvme_seg_cnt); in lpfc_sli4_driver_resource_setup()
8307 if (phba->cfg_sg_dma_buf_size < SLI4_PAGE_SIZE) in lpfc_sli4_driver_resource_setup()
8308 i = phba->cfg_sg_dma_buf_size; in lpfc_sli4_driver_resource_setup()
8312 phba->lpfc_sg_dma_buf_pool = in lpfc_sli4_driver_resource_setup()
8314 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
8315 phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
8317 if (!phba->lpfc_sg_dma_buf_pool) { in lpfc_sli4_driver_resource_setup()
8318 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8322 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli4_driver_resource_setup()
8324 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
8328 if (!phba->lpfc_cmd_rsp_buf_pool) { in lpfc_sli4_driver_resource_setup()
8329 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8333 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8369 longs = (LPFC_SLI4_FCF_TBL_INDX_MAX + BITS_PER_LONG - 1)/BITS_PER_LONG; in lpfc_sli4_driver_resource_setup()
8370 phba->fcf.fcf_rr_bmask = kcalloc(longs, sizeof(unsigned long), in lpfc_sli4_driver_resource_setup()
8372 if (!phba->fcf.fcf_rr_bmask) { in lpfc_sli4_driver_resource_setup()
8376 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8380 phba->sli4_hba.hba_eq_hdl = kcalloc(phba->cfg_irq_chann, in lpfc_sli4_driver_resource_setup()
8383 if (!phba->sli4_hba.hba_eq_hdl) { in lpfc_sli4_driver_resource_setup()
8386 "fast-path per-EQ handle array\n"); in lpfc_sli4_driver_resource_setup()
8387 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8391 phba->sli4_hba.cpu_map = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
8394 if (!phba->sli4_hba.cpu_map) { in lpfc_sli4_driver_resource_setup()
8396 "3327 Failed allocate memory for msi-x " in lpfc_sli4_driver_resource_setup()
8398 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8402 phba->sli4_hba.eq_info = alloc_percpu(struct lpfc_eq_intr_info); in lpfc_sli4_driver_resource_setup()
8403 if (!phba->sli4_hba.eq_info) { in lpfc_sli4_driver_resource_setup()
8406 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8410 phba->sli4_hba.idle_stat = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
8411 sizeof(*phba->sli4_hba.idle_stat), in lpfc_sli4_driver_resource_setup()
8413 if (!phba->sli4_hba.idle_stat) { in lpfc_sli4_driver_resource_setup()
8416 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8421 phba->sli4_hba.c_stat = alloc_percpu(struct lpfc_hdwq_stat); in lpfc_sli4_driver_resource_setup()
8422 if (!phba->sli4_hba.c_stat) { in lpfc_sli4_driver_resource_setup()
8424 "3332 Failed allocating per cpu hdwq stats\n"); in lpfc_sli4_driver_resource_setup()
8425 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8430 phba->cmf_stat = alloc_percpu(struct lpfc_cgn_stat); in lpfc_sli4_driver_resource_setup()
8431 if (!phba->cmf_stat) { in lpfc_sli4_driver_resource_setup()
8433 "3331 Failed allocating per cpu cgn stats\n"); in lpfc_sli4_driver_resource_setup()
8434 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8439 * Enable sr-iov virtual functions if supported and configured in lpfc_sli4_driver_resource_setup()
8442 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli4_driver_resource_setup()
8444 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
8447 "3020 Requested number of SR-IOV " in lpfc_sli4_driver_resource_setup()
8450 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
8451 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli4_driver_resource_setup()
8459 free_percpu(phba->sli4_hba.c_stat); in lpfc_sli4_driver_resource_setup()
8462 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_setup()
8464 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_setup()
8466 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_setup()
8468 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_setup()
8470 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_setup()
8478 dma_pool_destroy(phba->lpfc_cmd_rsp_buf_pool); in lpfc_sli4_driver_resource_setup()
8479 phba->lpfc_cmd_rsp_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
8481 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli4_driver_resource_setup()
8482 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
8488 destroy_workqueue(phba->wq); in lpfc_sli4_driver_resource_setup()
8489 phba->wq = NULL; in lpfc_sli4_driver_resource_setup()
8494 * lpfc_sli4_driver_resource_unset - Unset drvr internal resources for SLI4 dev
8498 * specific for supporting the SLI-4 HBA device it attached to.
8505 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_unset()
8507 free_percpu(phba->sli4_hba.c_stat); in lpfc_sli4_driver_resource_unset()
8509 free_percpu(phba->cmf_stat); in lpfc_sli4_driver_resource_unset()
8510 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_unset()
8512 /* Free memory allocated for msi-x interrupt vector to CPU mapping */ in lpfc_sli4_driver_resource_unset()
8513 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_unset()
8514 phba->sli4_hba.num_possible_cpu = 0; in lpfc_sli4_driver_resource_unset()
8515 phba->sli4_hba.num_present_cpu = 0; in lpfc_sli4_driver_resource_unset()
8516 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_unset()
8517 cpumask_clear(&phba->sli4_hba.irq_aff_mask); in lpfc_sli4_driver_resource_unset()
8519 /* Free memory allocated for fast-path work queue handles */ in lpfc_sli4_driver_resource_unset()
8520 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_unset()
8527 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_unset()
8549 &phba->fcf_conn_rec_list, list) { in lpfc_sli4_driver_resource_unset()
8550 list_del_init(&conn_entry->list); in lpfc_sli4_driver_resource_unset()
8558 * lpfc_init_api_table_setup - Set up init api function jump table
8560 * @dev_grp: The HBA PCI-Device group number.
8565 * Returns: 0 - success, -ENODEV - failure.
8570 phba->lpfc_hba_init_link = lpfc_hba_init_link; in lpfc_init_api_table_setup()
8571 phba->lpfc_hba_down_link = lpfc_hba_down_link; in lpfc_init_api_table_setup()
8572 phba->lpfc_selective_reset = lpfc_selective_reset; in lpfc_init_api_table_setup()
8575 phba->lpfc_hba_down_post = lpfc_hba_down_post_s3; in lpfc_init_api_table_setup()
8576 phba->lpfc_handle_eratt = lpfc_handle_eratt_s3; in lpfc_init_api_table_setup()
8577 phba->lpfc_stop_port = lpfc_stop_port_s3; in lpfc_init_api_table_setup()
8580 phba->lpfc_hba_down_post = lpfc_hba_down_post_s4; in lpfc_init_api_table_setup()
8581 phba->lpfc_handle_eratt = lpfc_handle_eratt_s4; in lpfc_init_api_table_setup()
8582 phba->lpfc_stop_port = lpfc_stop_port_s4; in lpfc_init_api_table_setup()
8586 "1431 Invalid HBA PCI-device group: 0x%x\n", in lpfc_init_api_table_setup()
8588 return -ENODEV; in lpfc_init_api_table_setup()
8594 * lpfc_setup_driver_resource_phase2 - Phase2 setup driver internal resources.
8601 * 0 - successful
8602 * other values - error
8610 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_setup_driver_resource_phase2()
8611 "lpfc_worker_%d", phba->brd_no); in lpfc_setup_driver_resource_phase2()
8612 if (IS_ERR(phba->worker_thread)) { in lpfc_setup_driver_resource_phase2()
8613 error = PTR_ERR(phba->worker_thread); in lpfc_setup_driver_resource_phase2()
8621 * lpfc_unset_driver_resource_phase2 - Phase2 unset driver internal resources.
8631 if (phba->wq) { in lpfc_unset_driver_resource_phase2()
8632 destroy_workqueue(phba->wq); in lpfc_unset_driver_resource_phase2()
8633 phba->wq = NULL; in lpfc_unset_driver_resource_phase2()
8637 if (phba->worker_thread) in lpfc_unset_driver_resource_phase2()
8638 kthread_stop(phba->worker_thread); in lpfc_unset_driver_resource_phase2()
8642 * lpfc_free_iocb_list - Free iocb list.
8652 spin_lock_irq(&phba->hbalock); in lpfc_free_iocb_list()
8654 &phba->lpfc_iocb_list, list) { in lpfc_free_iocb_list()
8655 list_del(&iocbq_entry->list); in lpfc_free_iocb_list()
8657 phba->total_iocbq_bufs--; in lpfc_free_iocb_list()
8659 spin_unlock_irq(&phba->hbalock); in lpfc_free_iocb_list()
8665 * lpfc_init_iocb_list - Allocate and initialize iocb list.
8673 * 0 - successful
8674 * other values - error
8684 INIT_LIST_HEAD(&phba->lpfc_iocb_list); in lpfc_init_iocb_list()
8701 iocbq_entry->sli4_lxritag = NO_XRI; in lpfc_init_iocb_list()
8702 iocbq_entry->sli4_xritag = NO_XRI; in lpfc_init_iocb_list()
8704 spin_lock_irq(&phba->hbalock); in lpfc_init_iocb_list()
8705 list_add(&iocbq_entry->list, &phba->lpfc_iocb_list); in lpfc_init_iocb_list()
8706 phba->total_iocbq_bufs++; in lpfc_init_iocb_list()
8707 spin_unlock_irq(&phba->hbalock); in lpfc_init_iocb_list()
8715 return -ENOMEM; in lpfc_init_iocb_list()
8719 * lpfc_free_sgl_list - Free a given sgl list.
8731 list_del(&sglq_entry->list); in lpfc_free_sgl_list()
8732 lpfc_mbuf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_sgl_list()
8738 * lpfc_free_els_sgl_list - Free els sgl list.
8749 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
8750 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, &sglq_list); in lpfc_free_els_sgl_list()
8751 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
8758 * lpfc_free_nvmet_sgl_list - Free nvmet sgl list.
8770 spin_lock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
8771 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
8772 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, &sglq_list); in lpfc_free_nvmet_sgl_list()
8773 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
8774 spin_unlock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
8778 list_del(&sglq_entry->list); in lpfc_free_nvmet_sgl_list()
8779 lpfc_nvmet_buf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_nvmet_sgl_list()
8787 phba->sli4_hba.nvmet_xri_cnt = 0; in lpfc_free_nvmet_sgl_list()
8791 * lpfc_init_active_sgl_array - Allocate the buf to track active ELS XRIs.
8802 size *= phba->sli4_hba.max_cfg_param.max_xri; in lpfc_init_active_sgl_array()
8804 phba->sli4_hba.lpfc_sglq_active_list = in lpfc_init_active_sgl_array()
8806 if (!phba->sli4_hba.lpfc_sglq_active_list) in lpfc_init_active_sgl_array()
8807 return -ENOMEM; in lpfc_init_active_sgl_array()
8812 * lpfc_free_active_sgl - Free the buf that tracks active ELS XRIs.
8822 kfree(phba->sli4_hba.lpfc_sglq_active_list); in lpfc_free_active_sgl()
8826 * lpfc_init_sgl_list - Allocate and initialize sgl list.
8837 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_els_sgl_list); in lpfc_init_sgl_list()
8838 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_init_sgl_list()
8839 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_init_sgl_list()
8840 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_init_sgl_list()
8842 /* els xri-sgl book keeping */ in lpfc_init_sgl_list()
8843 phba->sli4_hba.els_xri_cnt = 0; in lpfc_init_sgl_list()
8845 /* nvme xri-buffer book keeping */ in lpfc_init_sgl_list()
8846 phba->sli4_hba.io_xri_cnt = 0; in lpfc_init_sgl_list()
8850 * lpfc_sli4_init_rpi_hdrs - Post the rpi header memory region to the port
8860 * 0 - successful
8861 * -ERROR - otherwise.
8869 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_init_rpi_hdrs()
8870 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_init_rpi_hdrs()
8872 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_init_rpi_hdrs()
8873 return -EIO; in lpfc_sli4_init_rpi_hdrs()
8880 rc = -ENODEV; in lpfc_sli4_init_rpi_hdrs()
8887 * lpfc_sli4_create_rpi_hdr - Allocate an rpi header memory region
8911 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_create_rpi_hdr()
8913 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_create_rpi_hdr()
8917 rpi_limit = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_create_rpi_hdr()
8919 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8925 curr_rpi_range = phba->sli4_hba.next_rpi; in lpfc_sli4_create_rpi_hdr()
8926 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8934 * port expects a 4KB DMA-mapped memory region that is 4K aligned. in lpfc_sli4_create_rpi_hdr()
8940 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_create_rpi_hdr()
8942 &dmabuf->phys, GFP_KERNEL); in lpfc_sli4_create_rpi_hdr()
8943 if (!dmabuf->virt) { in lpfc_sli4_create_rpi_hdr()
8948 if (!IS_ALIGNED(dmabuf->phys, LPFC_HDR_TEMPLATE_SIZE)) { in lpfc_sli4_create_rpi_hdr()
8958 rpi_hdr->dmabuf = dmabuf; in lpfc_sli4_create_rpi_hdr()
8959 rpi_hdr->len = LPFC_HDR_TEMPLATE_SIZE; in lpfc_sli4_create_rpi_hdr()
8960 rpi_hdr->page_count = 1; in lpfc_sli4_create_rpi_hdr()
8961 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8964 rpi_hdr->start_rpi = curr_rpi_range; in lpfc_sli4_create_rpi_hdr()
8965 rpi_hdr->next_rpi = phba->sli4_hba.next_rpi + LPFC_RPI_HDR_COUNT; in lpfc_sli4_create_rpi_hdr()
8966 list_add_tail(&rpi_hdr->list, &phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_create_rpi_hdr()
8968 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8972 dma_free_coherent(&phba->pcidev->dev, LPFC_HDR_TEMPLATE_SIZE, in lpfc_sli4_create_rpi_hdr()
8973 dmabuf->virt, dmabuf->phys); in lpfc_sli4_create_rpi_hdr()
8980 * lpfc_sli4_remove_rpi_hdrs - Remove all rpi header memory regions
8993 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_remove_rpi_hdrs()
8997 &phba->sli4_hba.lpfc_rpi_hdr_list, list) { in lpfc_sli4_remove_rpi_hdrs()
8998 list_del(&rpi_hdr->list); in lpfc_sli4_remove_rpi_hdrs()
8999 dma_free_coherent(&phba->pcidev->dev, rpi_hdr->len, in lpfc_sli4_remove_rpi_hdrs()
9000 rpi_hdr->dmabuf->virt, rpi_hdr->dmabuf->phys); in lpfc_sli4_remove_rpi_hdrs()
9001 kfree(rpi_hdr->dmabuf); in lpfc_sli4_remove_rpi_hdrs()
9006 phba->sli4_hba.next_rpi = 0; in lpfc_sli4_remove_rpi_hdrs()
9010 * lpfc_hba_alloc - Allocate driver hba data structure for a device.
9018 * pointer to @phba - successful
9019 * NULL - error
9029 dev_err(&pdev->dev, "failed to allocate hba struct\n"); in lpfc_hba_alloc()
9034 phba->pcidev = pdev; in lpfc_hba_alloc()
9037 phba->brd_no = lpfc_get_instance(); in lpfc_hba_alloc()
9038 if (phba->brd_no < 0) { in lpfc_hba_alloc()
9042 phba->eratt_poll_interval = LPFC_ERATT_POLL_INTERVAL; in lpfc_hba_alloc()
9044 spin_lock_init(&phba->ct_ev_lock); in lpfc_hba_alloc()
9045 INIT_LIST_HEAD(&phba->ct_ev_waiters); in lpfc_hba_alloc()
9051 * lpfc_hba_free - Free driver hba data structure with a device.
9060 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_hba_free()
9061 kfree(phba->sli4_hba.hdwq); in lpfc_hba_free()
9064 idr_remove(&lpfc_hba_index, phba->brd_no); in lpfc_hba_free()
9067 kfree(phba->sli.sli3_ring); in lpfc_hba_free()
9068 phba->sli.sli3_ring = NULL; in lpfc_hba_free()
9075 * lpfc_setup_fdmi_mask - Setup initial FDMI mask for HBA and Port attributes
9081 * fallback hierarchy is SmartSAN -> FDMI2 -> FMDI1
9086 struct lpfc_hba *phba = vport->phba; in lpfc_setup_fdmi_mask()
9088 vport->load_flag |= FC_ALLOW_FDMI; in lpfc_setup_fdmi_mask()
9089 if (phba->cfg_enable_SmartSAN || in lpfc_setup_fdmi_mask()
9090 phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT) { in lpfc_setup_fdmi_mask()
9092 vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR; in lpfc_setup_fdmi_mask()
9093 if (phba->cfg_enable_SmartSAN) in lpfc_setup_fdmi_mask()
9094 vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR; in lpfc_setup_fdmi_mask()
9096 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR; in lpfc_setup_fdmi_mask()
9101 vport->fdmi_hba_mask, vport->fdmi_port_mask); in lpfc_setup_fdmi_mask()
9105 * lpfc_create_shost - Create hba physical port with associated scsi host.
9112 * 0 - successful
9113 * other values - error
9122 phba->fc_edtov = FF_DEF_EDTOV; in lpfc_create_shost()
9123 phba->fc_ratov = FF_DEF_RATOV; in lpfc_create_shost()
9124 phba->fc_altov = FF_DEF_ALTOV; in lpfc_create_shost()
9125 phba->fc_arbtov = FF_DEF_ARBTOV; in lpfc_create_shost()
9127 atomic_set(&phba->sdev_cnt, 0); in lpfc_create_shost()
9128 vport = lpfc_create_port(phba, phba->brd_no, &phba->pcidev->dev); in lpfc_create_shost()
9130 return -ENODEV; in lpfc_create_shost()
9133 phba->pport = vport; in lpfc_create_shost()
9135 if (phba->nvmet_support) { in lpfc_create_shost()
9137 phba->targetport = NULL; in lpfc_create_shost()
9138 phba->cfg_enable_fc4_type = LPFC_ENABLE_NVME; in lpfc_create_shost()
9145 pci_set_drvdata(phba->pcidev, shost); in lpfc_create_shost()
9157 * lpfc_destroy_shost - Destroy hba physical port with associated scsi host.
9166 struct lpfc_vport *vport = phba->pport; in lpfc_destroy_shost()
9175 * lpfc_setup_bg - Setup Block guard structures and debug areas.
9188 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
9193 old_mask = phba->cfg_prot_mask; in lpfc_setup_bg()
9194 old_guard = phba->cfg_prot_guard; in lpfc_setup_bg()
9197 phba->cfg_prot_mask &= (SHOST_DIF_TYPE1_PROTECTION | in lpfc_setup_bg()
9200 phba->cfg_prot_guard &= (SHOST_DIX_GUARD_IP | in lpfc_setup_bg()
9204 if (phba->cfg_prot_mask == SHOST_DIX_TYPE1_PROTECTION) in lpfc_setup_bg()
9205 phba->cfg_prot_mask |= SHOST_DIF_TYPE1_PROTECTION; in lpfc_setup_bg()
9207 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
9208 if ((old_mask != phba->cfg_prot_mask) || in lpfc_setup_bg()
9209 (old_guard != phba->cfg_prot_guard)) in lpfc_setup_bg()
9213 phba->cfg_prot_mask, in lpfc_setup_bg()
9214 phba->cfg_prot_guard); in lpfc_setup_bg()
9216 scsi_host_set_prot(shost, phba->cfg_prot_mask); in lpfc_setup_bg()
9217 scsi_host_set_guard(shost, phba->cfg_prot_guard); in lpfc_setup_bg()
9227 * lpfc_post_init_setup - Perform necessary device post initialization setup.
9240 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_post_init_setup()
9246 shost = pci_get_drvdata(phba->pcidev); in lpfc_post_init_setup()
9247 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_post_init_setup()
9251 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_post_init_setup()
9252 spin_lock_irq(shost->host_lock); in lpfc_post_init_setup()
9254 spin_unlock_irq(shost->host_lock); in lpfc_post_init_setup()
9270 * lpfc_sli_pci_mem_setup - Setup SLI3 HBA PCI memory space.
9274 * with SLI-3 interface spec.
9277 * 0 - successful
9278 * other values - error
9283 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_pci_mem_setup()
9290 return -ENODEV; in lpfc_sli_pci_mem_setup()
9293 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli_pci_mem_setup()
9295 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli_pci_mem_setup()
9298 error = -ENODEV; in lpfc_sli_pci_mem_setup()
9303 phba->pci_bar0_map = pci_resource_start(pdev, 0); in lpfc_sli_pci_mem_setup()
9306 phba->pci_bar2_map = pci_resource_start(pdev, 2); in lpfc_sli_pci_mem_setup()
9310 phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli_pci_mem_setup()
9311 if (!phba->slim_memmap_p) { in lpfc_sli_pci_mem_setup()
9312 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
9318 phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli_pci_mem_setup()
9319 if (!phba->ctrl_regs_memmap_p) { in lpfc_sli_pci_mem_setup()
9320 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
9325 /* Allocate memory for SLI-2 structures */ in lpfc_sli_pci_mem_setup()
9326 phba->slim2p.virt = dma_alloc_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
9327 &phba->slim2p.phys, GFP_KERNEL); in lpfc_sli_pci_mem_setup()
9328 if (!phba->slim2p.virt) in lpfc_sli_pci_mem_setup()
9331 phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx); in lpfc_sli_pci_mem_setup()
9332 phba->mbox_ext = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
9334 phba->pcb = (phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, pcb)); in lpfc_sli_pci_mem_setup()
9335 phba->IOCBs = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
9338 phba->hbqslimp.virt = dma_alloc_coherent(&pdev->dev, in lpfc_sli_pci_mem_setup()
9340 &phba->hbqslimp.phys, in lpfc_sli_pci_mem_setup()
9342 if (!phba->hbqslimp.virt) in lpfc_sli_pci_mem_setup()
9346 ptr = phba->hbqslimp.virt; in lpfc_sli_pci_mem_setup()
9348 phba->hbqs[i].hbq_virt = ptr; in lpfc_sli_pci_mem_setup()
9349 INIT_LIST_HEAD(&phba->hbqs[i].hbq_buffer_list); in lpfc_sli_pci_mem_setup()
9350 ptr += (lpfc_hbq_defs[i]->entry_count * in lpfc_sli_pci_mem_setup()
9353 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_els_hbq_alloc; in lpfc_sli_pci_mem_setup()
9354 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_els_hbq_free; in lpfc_sli_pci_mem_setup()
9356 memset(phba->hbqslimp.virt, 0, lpfc_sli_hbq_size()); in lpfc_sli_pci_mem_setup()
9358 phba->MBslimaddr = phba->slim_memmap_p; in lpfc_sli_pci_mem_setup()
9359 phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9360 phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9361 phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9362 phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9367 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
9368 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_setup()
9370 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_setup()
9372 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_setup()
9378 * lpfc_sli_pci_mem_unset - Unset SLI3 HBA PCI memory space.
9382 * with SLI-3 interface spec.
9390 if (!phba->pcidev) in lpfc_sli_pci_mem_unset()
9393 pdev = phba->pcidev; in lpfc_sli_pci_mem_unset()
9396 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_sli_pci_mem_unset()
9397 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_sli_pci_mem_unset()
9398 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_unset()
9399 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_unset()
9402 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_unset()
9403 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_unset()
9409 * lpfc_sli4_post_status_check - Wait for SLI4 POST done and check status
9415 * Return 0 if successful, otherwise -ENODEV.
9427 if (!phba->sli4_hba.PSMPHRregaddr) in lpfc_sli4_post_status_check()
9428 return -ENODEV; in lpfc_sli4_post_status_check()
9432 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_sli4_post_status_check()
9436 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9451 "1408 Port Failed POST - portsmphr=0x%x, " in lpfc_sli4_post_status_check()
9469 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9471 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9473 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9475 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9477 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9479 &phba->sli4_hba.sli_intf)); in lpfc_sli4_post_status_check()
9486 &phba->sli4_hba.sli_intf); in lpfc_sli4_post_status_check()
9489 phba->sli4_hba.ue_mask_lo = in lpfc_sli4_post_status_check()
9490 readl(phba->sli4_hba.u.if_type0.UEMASKLOregaddr); in lpfc_sli4_post_status_check()
9491 phba->sli4_hba.ue_mask_hi = in lpfc_sli4_post_status_check()
9492 readl(phba->sli4_hba.u.if_type0.UEMASKHIregaddr); in lpfc_sli4_post_status_check()
9494 readl(phba->sli4_hba.u.if_type0.UERRLOregaddr); in lpfc_sli4_post_status_check()
9496 readl(phba->sli4_hba.u.if_type0.UERRHIregaddr); in lpfc_sli4_post_status_check()
9497 if ((~phba->sli4_hba.ue_mask_lo & uerrlo_reg.word0) || in lpfc_sli4_post_status_check()
9498 (~phba->sli4_hba.ue_mask_hi & uerrhi_reg.word0)) { in lpfc_sli4_post_status_check()
9509 phba->sli4_hba.ue_mask_lo, in lpfc_sli4_post_status_check()
9510 phba->sli4_hba.ue_mask_hi); in lpfc_sli4_post_status_check()
9511 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9517 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_post_status_check()
9520 phba->work_status[0] = in lpfc_sli4_post_status_check()
9521 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
9523 phba->work_status[1] = in lpfc_sli4_post_status_check()
9524 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
9533 phba->work_status[0], in lpfc_sli4_post_status_check()
9534 phba->work_status[1]); in lpfc_sli4_post_status_check()
9535 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9541 &phba->sli4_hba.sli_intf) == in lpfc_sli4_post_status_check()
9543 pci_write_config_byte(phba->pcidev, in lpfc_sli4_post_status_check()
9555 * lpfc_sli4_bar0_register_memmap - Set up SLI4 BAR0 register memory map.
9567 phba->sli4_hba.u.if_type0.UERRLOregaddr = in lpfc_sli4_bar0_register_memmap()
9568 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_LO; in lpfc_sli4_bar0_register_memmap()
9569 phba->sli4_hba.u.if_type0.UERRHIregaddr = in lpfc_sli4_bar0_register_memmap()
9570 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_HI; in lpfc_sli4_bar0_register_memmap()
9571 phba->sli4_hba.u.if_type0.UEMASKLOregaddr = in lpfc_sli4_bar0_register_memmap()
9572 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_LO; in lpfc_sli4_bar0_register_memmap()
9573 phba->sli4_hba.u.if_type0.UEMASKHIregaddr = in lpfc_sli4_bar0_register_memmap()
9574 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_HI; in lpfc_sli4_bar0_register_memmap()
9575 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
9576 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
9579 phba->sli4_hba.u.if_type2.EQDregaddr = in lpfc_sli4_bar0_register_memmap()
9580 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9582 phba->sli4_hba.u.if_type2.ERR1regaddr = in lpfc_sli4_bar0_register_memmap()
9583 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9585 phba->sli4_hba.u.if_type2.ERR2regaddr = in lpfc_sli4_bar0_register_memmap()
9586 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9588 phba->sli4_hba.u.if_type2.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
9589 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9591 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
9592 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9594 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
9595 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
9596 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
9597 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9599 phba->sli4_hba.RQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9600 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9602 phba->sli4_hba.WQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9603 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9605 phba->sli4_hba.CQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9606 phba->sli4_hba.conf_regs_memmap_p + LPFC_EQCQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
9607 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar0_register_memmap()
9608 phba->sli4_hba.MQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9609 phba->sli4_hba.conf_regs_memmap_p + LPFC_MQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
9610 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
9611 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
9614 phba->sli4_hba.u.if_type2.EQDregaddr = in lpfc_sli4_bar0_register_memmap()
9615 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9617 phba->sli4_hba.u.if_type2.ERR1regaddr = in lpfc_sli4_bar0_register_memmap()
9618 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9620 phba->sli4_hba.u.if_type2.ERR2regaddr = in lpfc_sli4_bar0_register_memmap()
9621 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9623 phba->sli4_hba.u.if_type2.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
9624 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9626 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
9627 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9629 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
9630 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9632 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
9633 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
9637 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_bar0_register_memmap()
9638 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar0_register_memmap()
9645 * lpfc_sli4_bar1_register_memmap - Set up SLI4 BAR1 register memory map.
9656 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar1_register_memmap()
9657 phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9659 phba->sli4_hba.ISRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9661 phba->sli4_hba.IMRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9663 phba->sli4_hba.ISCRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9667 phba->sli4_hba.RQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9669 phba->sli4_hba.WQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9671 phba->sli4_hba.CQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9673 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9675 phba->sli4_hba.MQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9681 dev_err(&phba->pcidev->dev, in lpfc_sli4_bar1_register_memmap()
9682 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar1_register_memmap()
9689 * lpfc_sli4_bar2_register_memmap - Set up SLI4 BAR2 register memory map.
9696 * Return 0 if successful, otherwise -ENODEV.
9702 return -ENODEV; in lpfc_sli4_bar2_register_memmap()
9704 phba->sli4_hba.RQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9707 phba->sli4_hba.WQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9710 phba->sli4_hba.CQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9713 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar2_register_memmap()
9714 phba->sli4_hba.MQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9716 phba->sli4_hba.BMBXregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9722 * lpfc_create_bootstrap_mbox - Create the bootstrap mailbox
9726 * region consistent with the SLI-4 interface spec. This
9733 * 0 - successful
9734 * -ENOMEM - could not allocated memory.
9747 return -ENOMEM; in lpfc_create_bootstrap_mbox()
9753 bmbx_size = sizeof(struct lpfc_bmbx_create) + (LPFC_ALIGN_16_BYTE - 1); in lpfc_create_bootstrap_mbox()
9754 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, bmbx_size, in lpfc_create_bootstrap_mbox()
9755 &dmabuf->phys, GFP_KERNEL); in lpfc_create_bootstrap_mbox()
9756 if (!dmabuf->virt) { in lpfc_create_bootstrap_mbox()
9758 return -ENOMEM; in lpfc_create_bootstrap_mbox()
9764 * to be 16-byte aligned. Also align the virtual memory as each in lpfc_create_bootstrap_mbox()
9768 phba->sli4_hba.bmbx.dmabuf = dmabuf; in lpfc_create_bootstrap_mbox()
9769 phba->sli4_hba.bmbx.bmbx_size = bmbx_size; in lpfc_create_bootstrap_mbox()
9771 phba->sli4_hba.bmbx.avirt = PTR_ALIGN(dmabuf->virt, in lpfc_create_bootstrap_mbox()
9773 phba->sli4_hba.bmbx.aphys = ALIGN(dmabuf->phys, in lpfc_create_bootstrap_mbox()
9779 * as two 30-bit addresses. The other data is a bit marking whether in lpfc_create_bootstrap_mbox()
9780 * the 30-bit address is the high or low address. in lpfc_create_bootstrap_mbox()
9784 dma_address = &phba->sli4_hba.bmbx.dma_address; in lpfc_create_bootstrap_mbox()
9785 phys_addr = (uint64_t)phba->sli4_hba.bmbx.aphys; in lpfc_create_bootstrap_mbox()
9787 dma_address->addr_hi = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
9790 pa_addr = (uint32_t) ((phba->sli4_hba.bmbx.aphys >> 4) & 0x3fffffff); in lpfc_create_bootstrap_mbox()
9791 dma_address->addr_lo = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
9797 * lpfc_destroy_bootstrap_mbox - Destroy all bootstrap mailbox resources
9810 dma_free_coherent(&phba->pcidev->dev, in lpfc_destroy_bootstrap_mbox()
9811 phba->sli4_hba.bmbx.bmbx_size, in lpfc_destroy_bootstrap_mbox()
9812 phba->sli4_hba.bmbx.dmabuf->virt, in lpfc_destroy_bootstrap_mbox()
9813 phba->sli4_hba.bmbx.dmabuf->phys); in lpfc_destroy_bootstrap_mbox()
9815 kfree(phba->sli4_hba.bmbx.dmabuf); in lpfc_destroy_bootstrap_mbox()
9816 memset(&phba->sli4_hba.bmbx, 0, sizeof(struct lpfc_bmbx)); in lpfc_destroy_bootstrap_mbox()
9833 * lpfc_map_topology - Map the topology read from READ_CONFIG
9858 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9861 /* FW supports persistent topology - override module parameter value */ in lpfc_map_topology()
9862 phba->hba_flag |= HBA_PERSISTENT_TOPO; in lpfc_map_topology()
9865 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_map_topology()
9867 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_map_topology()
9870 phba->cfg_topology = ((pt == LINK_FLAGS_LOOP) in lpfc_map_topology()
9874 phba->hba_flag &= ~HBA_PERSISTENT_TOPO; in lpfc_map_topology()
9878 /* If topology failover set - pt is '0' or '1' */ in lpfc_map_topology()
9879 phba->cfg_topology = (pt ? FLAGS_TOPOLOGY_MODE_PT_LOOP : in lpfc_map_topology()
9882 phba->cfg_topology = ((pt == LINK_FLAGS_P2P) in lpfc_map_topology()
9887 if (phba->hba_flag & HBA_PERSISTENT_TOPO) { in lpfc_map_topology()
9890 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9895 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9900 * lpfc_sli4_read_config - Get the config parameters.
9909 * 0 - successful
9910 * -ENOMEM - No available memory
9911 * -EIO - The mailbox failed to complete successfully.
9927 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_read_config()
9932 return -ENOMEM; in lpfc_sli4_read_config()
9942 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
9943 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
9944 rc = -EIO; in lpfc_sli4_read_config()
9946 rd_config = &pmb->u.mqe.un.rd_config; in lpfc_sli4_read_config()
9948 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_VAL; in lpfc_sli4_read_config()
9949 phba->sli4_hba.lnk_info.lnk_tp = in lpfc_sli4_read_config()
9951 phba->sli4_hba.lnk_info.lnk_no = in lpfc_sli4_read_config()
9955 phba->sli4_hba.lnk_info.lnk_tp, in lpfc_sli4_read_config()
9956 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_read_config()
9960 bf_get(lpfc_mqe_command, &pmb->u.mqe)); in lpfc_sli4_read_config()
9962 phba->bbcredit_support = 1; in lpfc_sli4_read_config()
9963 phba->sli4_hba.bbscn_params.word0 = rd_config->word8; in lpfc_sli4_read_config()
9971 "2702 READ_CONFIG: FA-PWWN is " in lpfc_sli4_read_config()
9973 phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_CONFIG; in lpfc_sli4_read_config()
9976 phba->sli4_hba.fawwpn_flag &= ~LPFC_FAWWPN_CONFIG; in lpfc_sli4_read_config()
9979 phba->sli4_hba.conf_trunk = in lpfc_sli4_read_config()
9981 phba->sli4_hba.extents_in_use = in lpfc_sli4_read_config()
9984 phba->sli4_hba.max_cfg_param.max_xri = in lpfc_sli4_read_config()
9988 phba->sli4_hba.max_cfg_param.max_xri > 512) in lpfc_sli4_read_config()
9989 phba->sli4_hba.max_cfg_param.max_xri = 512; in lpfc_sli4_read_config()
9990 phba->sli4_hba.max_cfg_param.xri_base = in lpfc_sli4_read_config()
9992 phba->sli4_hba.max_cfg_param.max_vpi = in lpfc_sli4_read_config()
9995 if (phba->sli4_hba.max_cfg_param.max_vpi > LPFC_MAX_VPORTS) in lpfc_sli4_read_config()
9996 phba->sli4_hba.max_cfg_param.max_vpi = LPFC_MAX_VPORTS; in lpfc_sli4_read_config()
9997 phba->sli4_hba.max_cfg_param.vpi_base = in lpfc_sli4_read_config()
9999 phba->sli4_hba.max_cfg_param.max_rpi = in lpfc_sli4_read_config()
10001 phba->sli4_hba.max_cfg_param.rpi_base = in lpfc_sli4_read_config()
10003 phba->sli4_hba.max_cfg_param.max_vfi = in lpfc_sli4_read_config()
10005 phba->sli4_hba.max_cfg_param.vfi_base = in lpfc_sli4_read_config()
10007 phba->sli4_hba.max_cfg_param.max_fcfi = in lpfc_sli4_read_config()
10009 phba->sli4_hba.max_cfg_param.max_eq = in lpfc_sli4_read_config()
10011 phba->sli4_hba.max_cfg_param.max_rq = in lpfc_sli4_read_config()
10013 phba->sli4_hba.max_cfg_param.max_wq = in lpfc_sli4_read_config()
10015 phba->sli4_hba.max_cfg_param.max_cq = in lpfc_sli4_read_config()
10017 phba->lmt = bf_get(lpfc_mbx_rd_conf_lmt, rd_config); in lpfc_sli4_read_config()
10018 phba->sli4_hba.next_xri = phba->sli4_hba.max_cfg_param.xri_base; in lpfc_sli4_read_config()
10019 phba->vpi_base = phba->sli4_hba.max_cfg_param.vpi_base; in lpfc_sli4_read_config()
10020 phba->vfi_base = phba->sli4_hba.max_cfg_param.vfi_base; in lpfc_sli4_read_config()
10021 phba->max_vpi = (phba->sli4_hba.max_cfg_param.max_vpi > 0) ? in lpfc_sli4_read_config()
10022 (phba->sli4_hba.max_cfg_param.max_vpi - 1) : 0; in lpfc_sli4_read_config()
10023 phba->max_vports = phba->max_vpi; in lpfc_sli4_read_config()
10034 phba->cgn_reg_fpin = LPFC_CGN_FPIN_BOTH; in lpfc_sli4_read_config()
10035 phba->cgn_reg_signal = EDC_CG_SIG_NOTSUPPORTED; in lpfc_sli4_read_config()
10036 phba->cgn_sig_freq = lpfc_fabric_cgn_frequency; in lpfc_sli4_read_config()
10040 phba->cgn_reg_signal = EDC_CG_SIG_WARN_ONLY; in lpfc_sli4_read_config()
10041 phba->cgn_reg_fpin &= ~LPFC_CGN_FPIN_WARN; in lpfc_sli4_read_config()
10047 if (phba->cgn_reg_signal != in lpfc_sli4_read_config()
10050 phba->cgn_reg_fpin = LPFC_CGN_FPIN_BOTH; in lpfc_sli4_read_config()
10051 phba->cgn_reg_signal = in lpfc_sli4_read_config()
10054 phba->cgn_reg_signal = in lpfc_sli4_read_config()
10056 phba->cgn_reg_fpin = in lpfc_sli4_read_config()
10063 phba->cgn_init_reg_fpin = phba->cgn_reg_fpin; in lpfc_sli4_read_config()
10064 phba->cgn_init_reg_signal = phba->cgn_reg_signal; in lpfc_sli4_read_config()
10068 phba->cgn_reg_signal, phba->cgn_reg_fpin); in lpfc_sli4_read_config()
10078 phba->sli4_hba.extents_in_use, in lpfc_sli4_read_config()
10079 phba->sli4_hba.max_cfg_param.xri_base, in lpfc_sli4_read_config()
10080 phba->sli4_hba.max_cfg_param.max_xri, in lpfc_sli4_read_config()
10081 phba->sli4_hba.max_cfg_param.vpi_base, in lpfc_sli4_read_config()
10082 phba->sli4_hba.max_cfg_param.max_vpi, in lpfc_sli4_read_config()
10083 phba->sli4_hba.max_cfg_param.vfi_base, in lpfc_sli4_read_config()
10084 phba->sli4_hba.max_cfg_param.max_vfi, in lpfc_sli4_read_config()
10085 phba->sli4_hba.max_cfg_param.rpi_base, in lpfc_sli4_read_config()
10086 phba->sli4_hba.max_cfg_param.max_rpi, in lpfc_sli4_read_config()
10087 phba->sli4_hba.max_cfg_param.max_fcfi, in lpfc_sli4_read_config()
10088 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
10089 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
10090 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
10091 phba->sli4_hba.max_cfg_param.max_rq, in lpfc_sli4_read_config()
10092 phba->lmt); in lpfc_sli4_read_config()
10098 qmin = phba->sli4_hba.max_cfg_param.max_wq; in lpfc_sli4_read_config()
10099 if (phba->sli4_hba.max_cfg_param.max_cq < qmin) in lpfc_sli4_read_config()
10100 qmin = phba->sli4_hba.max_cfg_param.max_cq; in lpfc_sli4_read_config()
10105 qmin -= 4; in lpfc_sli4_read_config()
10106 if (phba->sli4_hba.max_cfg_param.max_eq < qmin) in lpfc_sli4_read_config()
10107 qmin = phba->sli4_hba.max_cfg_param.max_eq; in lpfc_sli4_read_config()
10110 if ((phba->cfg_irq_chann > qmin) || in lpfc_sli4_read_config()
10111 (phba->cfg_hdw_queue > qmin)) { in lpfc_sli4_read_config()
10113 "2005 Reducing Queues - " in lpfc_sli4_read_config()
10117 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
10118 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
10119 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
10120 qmin, phba->cfg_irq_chann, in lpfc_sli4_read_config()
10121 phba->cfg_hdw_queue); in lpfc_sli4_read_config()
10123 if (phba->cfg_irq_chann > qmin) in lpfc_sli4_read_config()
10124 phba->cfg_irq_chann = qmin; in lpfc_sli4_read_config()
10125 if (phba->cfg_hdw_queue > qmin) in lpfc_sli4_read_config()
10126 phba->cfg_hdw_queue = qmin; in lpfc_sli4_read_config()
10134 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_read_config()
10139 phba->hba_flag |= HBA_FORCED_LINK_SPEED; in lpfc_sli4_read_config()
10143 phba->cfg_link_speed = in lpfc_sli4_read_config()
10147 phba->cfg_link_speed = in lpfc_sli4_read_config()
10151 phba->cfg_link_speed = in lpfc_sli4_read_config()
10155 phba->cfg_link_speed = in lpfc_sli4_read_config()
10159 phba->cfg_link_speed = in lpfc_sli4_read_config()
10163 phba->cfg_link_speed = in lpfc_sli4_read_config()
10167 phba->cfg_link_speed = in lpfc_sli4_read_config()
10171 phba->cfg_link_speed = in lpfc_sli4_read_config()
10175 phba->cfg_link_speed = in lpfc_sli4_read_config()
10184 phba->cfg_link_speed = in lpfc_sli4_read_config()
10191 length = phba->sli4_hba.max_cfg_param.max_xri - in lpfc_sli4_read_config()
10193 if (phba->cfg_hba_queue_depth > length) { in lpfc_sli4_read_config()
10196 phba->cfg_hba_queue_depth, length); in lpfc_sli4_read_config()
10197 phba->cfg_hba_queue_depth = length; in lpfc_sli4_read_config()
10200 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_read_config()
10205 length = (sizeof(struct lpfc_mbx_get_func_cfg) - in lpfc_sli4_read_config()
10213 &pmb->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_read_config()
10214 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_read_config()
10215 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_read_config()
10220 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
10221 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
10226 get_func_cfg = &pmb->u.mqe.un.get_func_cfg; in lpfc_sli4_read_config()
10228 pdesc_0 = (char *)&get_func_cfg->func_cfg.desc[0]; in lpfc_sli4_read_config()
10240 phba->sli4_hba.iov.pf_number = in lpfc_sli4_read_config()
10242 phba->sli4_hba.iov.vf_number = in lpfc_sli4_read_config()
10251 "vf_number:%d\n", phba->sli4_hba.iov.pf_number, in lpfc_sli4_read_config()
10252 phba->sli4_hba.iov.vf_number); in lpfc_sli4_read_config()
10260 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_read_config()
10265 * lpfc_setup_endian_order - Write endian order to an SLI4 if_type 0 port.
10268 * This routine is invoked to setup the port-side endian order when
10273 * 0 - successful
10274 * -ENOMEM - No available memory
10275 * -EIO - The mailbox failed to complete successfully.
10285 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_setup_endian_order()
10288 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_setup_endian_order()
10295 return -ENOMEM; in lpfc_setup_endian_order()
10303 memcpy(&mboxq->u.mqe, &endian_mb_data, sizeof(endian_mb_data)); in lpfc_setup_endian_order()
10310 rc = -EIO; in lpfc_setup_endian_order()
10312 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_setup_endian_order()
10324 * lpfc_sli4_queue_verify - Verify and update EQ counts
10333 * 0 - successful
10334 * -ENOMEM - No available memory
10340 * Sanity check for configured queue parameters against the run-time in lpfc_sli4_queue_verify()
10344 if (phba->nvmet_support) { in lpfc_sli4_queue_verify()
10345 if (phba->cfg_hdw_queue < phba->cfg_nvmet_mrq) in lpfc_sli4_queue_verify()
10346 phba->cfg_nvmet_mrq = phba->cfg_hdw_queue; in lpfc_sli4_queue_verify()
10347 if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX) in lpfc_sli4_queue_verify()
10348 phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX; in lpfc_sli4_queue_verify()
10353 phba->cfg_hdw_queue, phba->cfg_irq_chann, in lpfc_sli4_queue_verify()
10354 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_verify()
10357 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_verify()
10358 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_verify()
10361 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_verify()
10362 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_verify()
10371 int cpu; in lpfc_alloc_io_wq_cq() local
10373 cpu = lpfc_find_cpu_handle(phba, idx, LPFC_FIND_BY_HDWQ); in lpfc_alloc_io_wq_cq()
10375 if (phba->enab_exp_wqcq_pages) in lpfc_alloc_io_wq_cq()
10378 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
10379 LPFC_CQE_EXP_COUNT, cpu); in lpfc_alloc_io_wq_cq()
10383 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
10384 phba->sli4_hba.cq_ecount, cpu); in lpfc_alloc_io_wq_cq()
10387 "0499 Failed allocate fast-path IO CQ (%d)\n", in lpfc_alloc_io_wq_cq()
10391 qdesc->qe_valid = 1; in lpfc_alloc_io_wq_cq()
10392 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
10393 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
10394 phba->sli4_hba.hdwq[idx].io_cq = qdesc; in lpfc_alloc_io_wq_cq()
10397 if (phba->enab_exp_wqcq_pages) { in lpfc_alloc_io_wq_cq()
10399 wqesize = (phba->fcp_embed_io) ? in lpfc_alloc_io_wq_cq()
10400 LPFC_WQE128_SIZE : phba->sli4_hba.wq_esize; in lpfc_alloc_io_wq_cq()
10403 LPFC_WQE_EXP_COUNT, cpu); in lpfc_alloc_io_wq_cq()
10406 phba->sli4_hba.wq_esize, in lpfc_alloc_io_wq_cq()
10407 phba->sli4_hba.wq_ecount, cpu); in lpfc_alloc_io_wq_cq()
10411 "0503 Failed allocate fast-path IO WQ (%d)\n", in lpfc_alloc_io_wq_cq()
10415 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
10416 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
10417 phba->sli4_hba.hdwq[idx].io_wq = qdesc; in lpfc_alloc_io_wq_cq()
10418 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_alloc_io_wq_cq()
10423 * lpfc_sli4_queue_create - Create all the SLI4 queues
10432 * 0 - successful
10433 * -ENOMEM - No availble memory
10434 * -EIO - The mailbox failed to complete successfully.
10440 int idx, cpu, eqcpu; in lpfc_sli4_queue_create() local
10450 phba->sli4_hba.mq_esize = LPFC_MQE_SIZE; in lpfc_sli4_queue_create()
10451 phba->sli4_hba.mq_ecount = LPFC_MQE_DEF_COUNT; in lpfc_sli4_queue_create()
10452 phba->sli4_hba.wq_esize = LPFC_WQE_SIZE; in lpfc_sli4_queue_create()
10453 phba->sli4_hba.wq_ecount = LPFC_WQE_DEF_COUNT; in lpfc_sli4_queue_create()
10454 phba->sli4_hba.rq_esize = LPFC_RQE_SIZE; in lpfc_sli4_queue_create()
10455 phba->sli4_hba.rq_ecount = LPFC_RQE_DEF_COUNT; in lpfc_sli4_queue_create()
10456 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_create()
10457 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_create()
10458 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_create()
10459 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_create()
10461 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
10462 phba->sli4_hba.hdwq = kcalloc( in lpfc_sli4_queue_create()
10463 phba->cfg_hdw_queue, sizeof(struct lpfc_sli4_hdw_queue), in lpfc_sli4_queue_create()
10465 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
10468 "fast-path Hardware Queue array\n"); in lpfc_sli4_queue_create()
10472 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10473 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_queue_create()
10474 spin_lock_init(&qp->io_buf_list_get_lock); in lpfc_sli4_queue_create()
10475 spin_lock_init(&qp->io_buf_list_put_lock); in lpfc_sli4_queue_create()
10476 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_sli4_queue_create()
10477 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_sli4_queue_create()
10478 qp->get_io_bufs = 0; in lpfc_sli4_queue_create()
10479 qp->put_io_bufs = 0; in lpfc_sli4_queue_create()
10480 qp->total_io_bufs = 0; in lpfc_sli4_queue_create()
10481 spin_lock_init(&qp->abts_io_buf_list_lock); in lpfc_sli4_queue_create()
10482 INIT_LIST_HEAD(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_queue_create()
10483 qp->abts_scsi_io_bufs = 0; in lpfc_sli4_queue_create()
10484 qp->abts_nvme_io_bufs = 0; in lpfc_sli4_queue_create()
10485 INIT_LIST_HEAD(&qp->sgl_list); in lpfc_sli4_queue_create()
10486 INIT_LIST_HEAD(&qp->cmd_rsp_buf_list); in lpfc_sli4_queue_create()
10487 spin_lock_init(&qp->hdwq_lock); in lpfc_sli4_queue_create()
10491 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10492 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
10493 phba->sli4_hba.nvmet_cqset = kcalloc( in lpfc_sli4_queue_create()
10494 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10497 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_create()
10500 "fast-path CQ set array\n"); in lpfc_sli4_queue_create()
10503 phba->sli4_hba.nvmet_mrq_hdr = kcalloc( in lpfc_sli4_queue_create()
10504 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10507 if (!phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_create()
10510 "fast-path RQ set hdr array\n"); in lpfc_sli4_queue_create()
10513 phba->sli4_hba.nvmet_mrq_data = kcalloc( in lpfc_sli4_queue_create()
10514 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10517 if (!phba->sli4_hba.nvmet_mrq_data) { in lpfc_sli4_queue_create()
10520 "fast-path RQ set data array\n"); in lpfc_sli4_queue_create()
10526 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10529 for_each_present_cpu(cpu) { in lpfc_sli4_queue_create()
10534 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
10535 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_create()
10538 /* Get a ptr to the Hardware Queue associated with this CPU */ in lpfc_sli4_queue_create()
10539 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
10543 phba->sli4_hba.eq_esize, in lpfc_sli4_queue_create()
10544 phba->sli4_hba.eq_ecount, cpu); in lpfc_sli4_queue_create()
10548 cpup->hdwq); in lpfc_sli4_queue_create()
10551 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10552 qdesc->hdwq = cpup->hdwq; in lpfc_sli4_queue_create()
10553 qdesc->chann = cpu; /* First CPU this EQ is affinitized to */ in lpfc_sli4_queue_create()
10554 qdesc->last_cpu = qdesc->chann; in lpfc_sli4_queue_create()
10557 qp->hba_eq = qdesc; in lpfc_sli4_queue_create()
10559 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, qdesc->last_cpu); in lpfc_sli4_queue_create()
10560 list_add(&qdesc->cpu_list, &eqi->list); in lpfc_sli4_queue_create()
10566 for_each_present_cpu(cpu) { in lpfc_sli4_queue_create()
10567 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
10570 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_sli4_queue_create()
10574 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
10575 if (qp->hba_eq) in lpfc_sli4_queue_create()
10579 eqcpu = lpfc_find_cpu_handle(phba, cpup->eq, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
10580 eqcpup = &phba->sli4_hba.cpu_map[eqcpu]; in lpfc_sli4_queue_create()
10581 qp->hba_eq = phba->sli4_hba.hdwq[eqcpup->hdwq].hba_eq; in lpfc_sli4_queue_create()
10585 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10590 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
10591 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
10592 cpu = lpfc_find_cpu_handle(phba, idx, in lpfc_sli4_queue_create()
10596 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10597 phba->sli4_hba.cq_ecount, in lpfc_sli4_queue_create()
10598 cpu); in lpfc_sli4_queue_create()
10605 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10606 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10607 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10608 phba->sli4_hba.nvmet_cqset[idx] = qdesc; in lpfc_sli4_queue_create()
10616 cpu = lpfc_find_cpu_handle(phba, 0, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
10617 /* Create slow-path Mailbox Command Complete Queue */ in lpfc_sli4_queue_create()
10619 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10620 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10623 "0500 Failed allocate slow-path mailbox CQ\n"); in lpfc_sli4_queue_create()
10626 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10627 phba->sli4_hba.mbx_cq = qdesc; in lpfc_sli4_queue_create()
10629 /* Create slow-path ELS Complete Queue */ in lpfc_sli4_queue_create()
10631 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10632 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10635 "0501 Failed allocate slow-path ELS CQ\n"); in lpfc_sli4_queue_create()
10638 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10639 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10640 phba->sli4_hba.els_cq = qdesc; in lpfc_sli4_queue_create()
10650 phba->sli4_hba.mq_esize, in lpfc_sli4_queue_create()
10651 phba->sli4_hba.mq_ecount, cpu); in lpfc_sli4_queue_create()
10654 "0505 Failed allocate slow-path MQ\n"); in lpfc_sli4_queue_create()
10657 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10658 phba->sli4_hba.mbx_wq = qdesc; in lpfc_sli4_queue_create()
10664 /* Create slow-path ELS Work Queue */ in lpfc_sli4_queue_create()
10666 phba->sli4_hba.wq_esize, in lpfc_sli4_queue_create()
10667 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
10670 "0504 Failed allocate slow-path ELS WQ\n"); in lpfc_sli4_queue_create()
10673 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10674 phba->sli4_hba.els_wq = qdesc; in lpfc_sli4_queue_create()
10675 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10677 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10680 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10681 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10687 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10688 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10689 phba->sli4_hba.nvmels_cq = qdesc; in lpfc_sli4_queue_create()
10693 phba->sli4_hba.wq_esize, in lpfc_sli4_queue_create()
10694 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
10700 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10701 phba->sli4_hba.nvmels_wq = qdesc; in lpfc_sli4_queue_create()
10702 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10711 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10712 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
10718 phba->sli4_hba.hdr_rq = qdesc; in lpfc_sli4_queue_create()
10722 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10723 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
10729 phba->sli4_hba.dat_rq = qdesc; in lpfc_sli4_queue_create()
10731 if ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) && in lpfc_sli4_queue_create()
10732 phba->nvmet_support) { in lpfc_sli4_queue_create()
10733 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
10734 cpu = lpfc_find_cpu_handle(phba, idx, in lpfc_sli4_queue_create()
10739 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10741 cpu); in lpfc_sli4_queue_create()
10748 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10749 phba->sli4_hba.nvmet_mrq_hdr[idx] = qdesc; in lpfc_sli4_queue_create()
10752 qdesc->rqbp = kzalloc_node(sizeof(*qdesc->rqbp), in lpfc_sli4_queue_create()
10754 cpu_to_node(cpu)); in lpfc_sli4_queue_create()
10755 if (qdesc->rqbp == NULL) { in lpfc_sli4_queue_create()
10763 INIT_LIST_HEAD(&qdesc->rqbp->rqb_buffer_list); in lpfc_sli4_queue_create()
10768 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10770 cpu); in lpfc_sli4_queue_create()
10777 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10778 phba->sli4_hba.nvmet_mrq_data[idx] = qdesc; in lpfc_sli4_queue_create()
10783 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10784 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10785 memset(&phba->sli4_hba.hdwq[idx].nvme_cstat, 0, in lpfc_sli4_queue_create()
10786 sizeof(phba->sli4_hba.hdwq[idx].nvme_cstat)); in lpfc_sli4_queue_create()
10791 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { in lpfc_sli4_queue_create()
10792 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10793 memset(&phba->sli4_hba.hdwq[idx].scsi_cstat, 0, in lpfc_sli4_queue_create()
10794 sizeof(phba->sli4_hba.hdwq[idx].scsi_cstat)); in lpfc_sli4_queue_create()
10802 return -ENOMEM; in lpfc_sli4_queue_create()
10836 hdwq = phba->sli4_hba.hdwq; in lpfc_sli4_release_hdwq()
10839 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_release_hdwq()
10846 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_release_hdwq()
10851 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_release_hdwq()
10853 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_sli4_release_hdwq()
10855 phba->sli4_hba.hba_eq_hdl[idx].eq = NULL; in lpfc_sli4_release_hdwq()
10860 * lpfc_sli4_queue_destroy - Destroy all the SLI4 queues
10867 * 0 - successful
10868 * -ENOMEM - No available memory
10869 * -EIO - The mailbox failed to complete successfully.
10879 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10880 phba->sli.sli_flag |= LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
10881 while (phba->sli.sli_flag & LPFC_QUEUE_FREE_WAIT) { in lpfc_sli4_queue_destroy()
10882 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10884 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10886 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10891 if (phba->sli4_hba.hdwq) in lpfc_sli4_queue_destroy()
10894 if (phba->nvmet_support) { in lpfc_sli4_queue_destroy()
10895 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_destroy()
10896 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10898 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_destroy()
10899 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10900 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_destroy()
10901 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10905 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_destroy()
10908 __lpfc_sli4_release_queue(&phba->sli4_hba.els_wq); in lpfc_sli4_queue_destroy()
10911 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_destroy()
10914 __lpfc_sli4_release_queue(&phba->sli4_hba.hdr_rq); in lpfc_sli4_queue_destroy()
10915 __lpfc_sli4_release_queue(&phba->sli4_hba.dat_rq); in lpfc_sli4_queue_destroy()
10918 __lpfc_sli4_release_queue(&phba->sli4_hba.els_cq); in lpfc_sli4_queue_destroy()
10921 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_destroy()
10924 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_destroy()
10927 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_destroy()
10930 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10931 phba->sli.sli_flag &= ~LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
10932 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10942 rqbp = rq->rqbp; in lpfc_free_rq_buffer()
10943 while (!list_empty(&rqbp->rqb_buffer_list)) { in lpfc_free_rq_buffer()
10944 list_remove_head(&rqbp->rqb_buffer_list, h_buf, in lpfc_free_rq_buffer()
10948 (rqbp->rqb_free_buffer)(phba, rqb_buffer); in lpfc_free_rq_buffer()
10949 rqbp->buffer_count--; in lpfc_free_rq_buffer()
10964 "6085 Fast-path %s (%d) not allocated\n", in lpfc_create_wq_cq()
10966 return -ENOMEM; in lpfc_create_wq_cq()
10982 *cq_map = cq->queue_id; in lpfc_create_wq_cq()
10985 "6087 CQ setup: cq[%d]-id=%d, parent eq[%d]-id=%d\n", in lpfc_create_wq_cq()
10986 qidx, cq->queue_id, qidx, eq->queue_id); in lpfc_create_wq_cq()
10994 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
10999 pring = wq->pring; in lpfc_create_wq_cq()
11000 pring->sli.sli4.wqp = (void *)wq; in lpfc_create_wq_cq()
11001 cq->pring = pring; in lpfc_create_wq_cq()
11004 "2593 WQ setup: wq[%d]-id=%d assoc=%d, cq[%d]-id=%d\n", in lpfc_create_wq_cq()
11005 qidx, wq->queue_id, wq->assoc_qid, qidx, cq->queue_id); in lpfc_create_wq_cq()
11010 "0539 Failed setup of slow-path MQ: " in lpfc_create_wq_cq()
11012 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
11017 "2589 MBX MQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_create_wq_cq()
11018 phba->sli4_hba.mbx_wq->queue_id, in lpfc_create_wq_cq()
11019 phba->sli4_hba.mbx_cq->queue_id); in lpfc_create_wq_cq()
11026 * lpfc_setup_cq_lookup - Setup the CQ lookup table
11038 memset(phba->sli4_hba.cq_lookup, 0, in lpfc_setup_cq_lookup()
11039 (sizeof(struct lpfc_queue *) * (phba->sli4_hba.cq_max + 1))); in lpfc_setup_cq_lookup()
11041 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_setup_cq_lookup()
11043 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_setup_cq_lookup()
11047 list_for_each_entry(childq, &eq->child_list, list) { in lpfc_setup_cq_lookup()
11048 if (childq->queue_id > phba->sli4_hba.cq_max) in lpfc_setup_cq_lookup()
11050 if (childq->subtype == LPFC_IO) in lpfc_setup_cq_lookup()
11051 phba->sli4_hba.cq_lookup[childq->queue_id] = in lpfc_setup_cq_lookup()
11058 * lpfc_sli4_queue_setup - Set up all the SLI4 queues
11065 * 0 - successful
11066 * -ENOMEM - No available memory
11067 * -EIO - The mailbox failed to complete successfully.
11077 int qidx, cpu; in lpfc_sli4_queue_setup() local
11079 int rc = -ENOMEM; in lpfc_sli4_queue_setup()
11081 /* Check for dual-ULP support */ in lpfc_sli4_queue_setup()
11082 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_queue_setup()
11087 return -ENOMEM; in lpfc_sli4_queue_setup()
11089 length = (sizeof(struct lpfc_mbx_query_fw_config) - in lpfc_sli4_queue_setup()
11098 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_queue_setup()
11099 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_queue_setup()
11100 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_queue_setup()
11106 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
11107 rc = -ENXIO; in lpfc_sli4_queue_setup()
11111 phba->sli4_hba.fw_func_mode = in lpfc_sli4_queue_setup()
11112 mboxq->u.mqe.un.query_fw_cfg.rsp.function_mode; in lpfc_sli4_queue_setup()
11113 phba->sli4_hba.ulp0_mode = mboxq->u.mqe.un.query_fw_cfg.rsp.ulp0_mode; in lpfc_sli4_queue_setup()
11114 phba->sli4_hba.ulp1_mode = mboxq->u.mqe.un.query_fw_cfg.rsp.ulp1_mode; in lpfc_sli4_queue_setup()
11115 phba->sli4_hba.physical_port = in lpfc_sli4_queue_setup()
11116 mboxq->u.mqe.un.query_fw_cfg.rsp.physical_port; in lpfc_sli4_queue_setup()
11119 "ulp1_mode:x%x\n", phba->sli4_hba.fw_func_mode, in lpfc_sli4_queue_setup()
11120 phba->sli4_hba.ulp0_mode, phba->sli4_hba.ulp1_mode); in lpfc_sli4_queue_setup()
11122 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
11127 qp = phba->sli4_hba.hdwq; in lpfc_sli4_queue_setup()
11132 "3147 Fast-path EQs not allocated\n"); in lpfc_sli4_queue_setup()
11133 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11138 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_setup()
11140 for_each_present_cpu(cpu) { in lpfc_sli4_queue_setup()
11141 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
11143 /* Look for the CPU thats using that vector with in lpfc_sli4_queue_setup()
11146 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_setup()
11148 if (qidx != cpup->eq) in lpfc_sli4_queue_setup()
11152 rc = lpfc_eq_create(phba, qp[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
11153 phba->cfg_fcp_imax); in lpfc_sli4_queue_setup()
11156 "0523 Failed setup of fast-path" in lpfc_sli4_queue_setup()
11158 cpup->eq, (uint32_t)rc); in lpfc_sli4_queue_setup()
11163 phba->sli4_hba.hba_eq_hdl[cpup->eq].eq = in lpfc_sli4_queue_setup()
11164 qp[cpup->hdwq].hba_eq; in lpfc_sli4_queue_setup()
11167 "2584 HBA EQ setup: queue[%d]-id=%d\n", in lpfc_sli4_queue_setup()
11168 cpup->eq, in lpfc_sli4_queue_setup()
11169 qp[cpup->hdwq].hba_eq->queue_id); in lpfc_sli4_queue_setup()
11174 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_setup()
11175 cpu = lpfc_find_cpu_handle(phba, qidx, LPFC_FIND_BY_HDWQ); in lpfc_sli4_queue_setup()
11176 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
11180 phba->sli4_hba.hdwq[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
11183 &phba->sli4_hba.hdwq[qidx].io_cq_map, in lpfc_sli4_queue_setup()
11199 /* Set up slow-path MBOX CQ/MQ */ in lpfc_sli4_queue_setup()
11201 if (!phba->sli4_hba.mbx_cq || !phba->sli4_hba.mbx_wq) { in lpfc_sli4_queue_setup()
11204 phba->sli4_hba.mbx_cq ? in lpfc_sli4_queue_setup()
11206 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11211 phba->sli4_hba.mbx_cq, in lpfc_sli4_queue_setup()
11212 phba->sli4_hba.mbx_wq, in lpfc_sli4_queue_setup()
11220 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
11221 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_setup()
11223 "3165 Fast-path NVME CQ Set " in lpfc_sli4_queue_setup()
11225 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11228 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
11230 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
11242 rc = lpfc_cq_create(phba, phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
11251 phba->sli4_hba.nvmet_cqset[0]->chann = 0; in lpfc_sli4_queue_setup()
11254 "6090 NVMET CQ setup: cq-id=%d, " in lpfc_sli4_queue_setup()
11255 "parent eq-id=%d\n", in lpfc_sli4_queue_setup()
11256 phba->sli4_hba.nvmet_cqset[0]->queue_id, in lpfc_sli4_queue_setup()
11257 qp[0].hba_eq->queue_id); in lpfc_sli4_queue_setup()
11261 /* Set up slow-path ELS WQ/CQ */ in lpfc_sli4_queue_setup()
11262 if (!phba->sli4_hba.els_cq || !phba->sli4_hba.els_wq) { in lpfc_sli4_queue_setup()
11265 phba->sli4_hba.els_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
11266 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11270 phba->sli4_hba.els_cq, in lpfc_sli4_queue_setup()
11271 phba->sli4_hba.els_wq, in lpfc_sli4_queue_setup()
11280 "2590 ELS WQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11281 phba->sli4_hba.els_wq->queue_id, in lpfc_sli4_queue_setup()
11282 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
11284 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_setup()
11286 if (!phba->sli4_hba.nvmels_cq || !phba->sli4_hba.nvmels_wq) { in lpfc_sli4_queue_setup()
11289 phba->sli4_hba.nvmels_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
11290 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11294 phba->sli4_hba.nvmels_cq, in lpfc_sli4_queue_setup()
11295 phba->sli4_hba.nvmels_wq, in lpfc_sli4_queue_setup()
11305 "6096 ELS WQ setup: wq-id=%d, " in lpfc_sli4_queue_setup()
11306 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11307 phba->sli4_hba.nvmels_wq->queue_id, in lpfc_sli4_queue_setup()
11308 phba->sli4_hba.nvmels_cq->queue_id); in lpfc_sli4_queue_setup()
11314 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
11315 if ((!phba->sli4_hba.nvmet_cqset) || in lpfc_sli4_queue_setup()
11316 (!phba->sli4_hba.nvmet_mrq_hdr) || in lpfc_sli4_queue_setup()
11317 (!phba->sli4_hba.nvmet_mrq_data)) { in lpfc_sli4_queue_setup()
11321 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11324 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
11326 phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_setup()
11327 phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_setup()
11328 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
11340 phba->sli4_hba.nvmet_mrq_hdr[0], in lpfc_sli4_queue_setup()
11341 phba->sli4_hba.nvmet_mrq_data[0], in lpfc_sli4_queue_setup()
11342 phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
11354 "6099 NVMET RQ setup: hdr-rq-id=%d, " in lpfc_sli4_queue_setup()
11355 "dat-rq-id=%d parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11356 phba->sli4_hba.nvmet_mrq_hdr[0]->queue_id, in lpfc_sli4_queue_setup()
11357 phba->sli4_hba.nvmet_mrq_data[0]->queue_id, in lpfc_sli4_queue_setup()
11358 phba->sli4_hba.nvmet_cqset[0]->queue_id); in lpfc_sli4_queue_setup()
11363 if (!phba->sli4_hba.hdr_rq || !phba->sli4_hba.dat_rq) { in lpfc_sli4_queue_setup()
11366 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11370 rc = lpfc_rq_create(phba, phba->sli4_hba.hdr_rq, phba->sli4_hba.dat_rq, in lpfc_sli4_queue_setup()
11371 phba->sli4_hba.els_cq, LPFC_USOL); in lpfc_sli4_queue_setup()
11380 "2592 USL RQ setup: hdr-rq-id=%d, dat-rq-id=%d " in lpfc_sli4_queue_setup()
11381 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11382 phba->sli4_hba.hdr_rq->queue_id, in lpfc_sli4_queue_setup()
11383 phba->sli4_hba.dat_rq->queue_id, in lpfc_sli4_queue_setup()
11384 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
11386 if (phba->cfg_fcp_imax) in lpfc_sli4_queue_setup()
11387 usdelay = LPFC_SEC_TO_USEC / phba->cfg_fcp_imax; in lpfc_sli4_queue_setup()
11391 for (qidx = 0; qidx < phba->cfg_irq_chann; in lpfc_sli4_queue_setup()
11396 if (phba->sli4_hba.cq_max) { in lpfc_sli4_queue_setup()
11397 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_setup()
11398 phba->sli4_hba.cq_lookup = kcalloc((phba->sli4_hba.cq_max + 1), in lpfc_sli4_queue_setup()
11400 if (!phba->sli4_hba.cq_lookup) { in lpfc_sli4_queue_setup()
11403 "size 0x%x\n", phba->sli4_hba.cq_max); in lpfc_sli4_queue_setup()
11404 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11418 * lpfc_sli4_queue_unset - Unset all the SLI4 queues
11425 * 0 - successful
11426 * -ENOMEM - No available memory
11427 * -EIO - The mailbox failed to complete successfully.
11437 if (phba->sli4_hba.mbx_wq) in lpfc_sli4_queue_unset()
11438 lpfc_mq_destroy(phba, phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_unset()
11441 if (phba->sli4_hba.nvmels_wq) in lpfc_sli4_queue_unset()
11442 lpfc_wq_destroy(phba, phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_unset()
11445 if (phba->sli4_hba.els_wq) in lpfc_sli4_queue_unset()
11446 lpfc_wq_destroy(phba, phba->sli4_hba.els_wq); in lpfc_sli4_queue_unset()
11449 if (phba->sli4_hba.hdr_rq) in lpfc_sli4_queue_unset()
11450 lpfc_rq_destroy(phba, phba->sli4_hba.hdr_rq, in lpfc_sli4_queue_unset()
11451 phba->sli4_hba.dat_rq); in lpfc_sli4_queue_unset()
11454 if (phba->sli4_hba.mbx_cq) in lpfc_sli4_queue_unset()
11455 lpfc_cq_destroy(phba, phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_unset()
11458 if (phba->sli4_hba.els_cq) in lpfc_sli4_queue_unset()
11459 lpfc_cq_destroy(phba, phba->sli4_hba.els_cq); in lpfc_sli4_queue_unset()
11462 if (phba->sli4_hba.nvmels_cq) in lpfc_sli4_queue_unset()
11463 lpfc_cq_destroy(phba, phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_unset()
11465 if (phba->nvmet_support) { in lpfc_sli4_queue_unset()
11467 if (phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_unset()
11468 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
11471 phba->sli4_hba.nvmet_mrq_hdr[qidx], in lpfc_sli4_queue_unset()
11472 phba->sli4_hba.nvmet_mrq_data[qidx]); in lpfc_sli4_queue_unset()
11476 if (phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_unset()
11477 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
11479 phba, phba->sli4_hba.nvmet_cqset[qidx]); in lpfc_sli4_queue_unset()
11483 /* Unset fast-path SLI4 queues */ in lpfc_sli4_queue_unset()
11484 if (phba->sli4_hba.hdwq) { in lpfc_sli4_queue_unset()
11486 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_unset()
11488 qp = &phba->sli4_hba.hdwq[qidx]; in lpfc_sli4_queue_unset()
11489 lpfc_wq_destroy(phba, qp->io_wq); in lpfc_sli4_queue_unset()
11490 lpfc_cq_destroy(phba, qp->io_cq); in lpfc_sli4_queue_unset()
11493 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_unset()
11495 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_sli4_queue_unset()
11500 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_unset()
11501 phba->sli4_hba.cq_lookup = NULL; in lpfc_sli4_queue_unset()
11502 phba->sli4_hba.cq_max = 0; in lpfc_sli4_queue_unset()
11506 * lpfc_sli4_cq_event_pool_create - Create completion-queue event free pool
11513 * - Mailbox asynchronous events
11514 * - Receive queue completion unsolicited events
11515 * Later, this can be used for all the slow-path events.
11518 * 0 - successful
11519 * -ENOMEM - No available memory
11527 for (i = 0; i < (4 * phba->sli4_hba.cq_ecount); i++) { in lpfc_sli4_cq_event_pool_create()
11531 list_add_tail(&cq_event->list, in lpfc_sli4_cq_event_pool_create()
11532 &phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_cq_event_pool_create()
11538 return -ENOMEM; in lpfc_sli4_cq_event_pool_create()
11542 * lpfc_sli4_cq_event_pool_destroy - Free completion-queue event free pool
11547 * cleanup routine to free all the outstanding completion-queue events
11557 &phba->sli4_hba.sp_cqe_event_pool, list) { in lpfc_sli4_cq_event_pool_destroy()
11558 list_del(&cq_event->list); in lpfc_sli4_cq_event_pool_destroy()
11564 * __lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
11568 * completion-queue event from the free pool.
11570 * Return: Pointer to the newly allocated completion-queue event if successful
11578 list_remove_head(&phba->sli4_hba.sp_cqe_event_pool, cq_event, in __lpfc_sli4_cq_event_alloc()
11584 * lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
11588 * completion-queue event from the free pool.
11590 * Return: Pointer to the newly allocated completion-queue event if successful
11599 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
11601 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
11606 * __lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
11611 * completion-queue event back into the free pool.
11617 list_add_tail(&cq_event->list, &phba->sli4_hba.sp_cqe_event_pool); in __lpfc_sli4_cq_event_release()
11621 * lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
11626 * completion-queue event back into the free pool.
11633 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
11635 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
11639 * lpfc_sli4_cq_event_release_all - Release all cq events to the free pool
11642 * This routine is to free all the pending completion-queue events to the
11655 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11656 list_splice_init(&phba->sli4_hba.sp_els_xri_aborted_work_queue, in lpfc_sli4_cq_event_release_all()
11658 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11661 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11662 list_splice_init(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_cq_event_release_all()
11664 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11674 * lpfc_pci_function_reset - Reset pci function.
11681 * 0 - successful
11682 * -ENOMEM - No available memory
11683 * -EIO - The mailbox failed to complete successfully.
11697 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_pci_function_reset()
11700 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_pci_function_reset()
11707 return -ENOMEM; in lpfc_pci_function_reset()
11710 /* Setup PCI function reset mailbox-ioctl command */ in lpfc_pci_function_reset()
11716 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_pci_function_reset()
11717 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_pci_function_reset()
11719 &shdr->response); in lpfc_pci_function_reset()
11720 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_pci_function_reset()
11727 rc = -ENXIO; in lpfc_pci_function_reset()
11739 if (lpfc_readl(phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
11741 rc = -ENODEV; in lpfc_pci_function_reset()
11750 phba->work_status[0] = readl( in lpfc_pci_function_reset()
11751 phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_pci_function_reset()
11752 phba->work_status[1] = readl( in lpfc_pci_function_reset()
11753 phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_pci_function_reset()
11758 phba->work_status[0], in lpfc_pci_function_reset()
11759 phba->work_status[1]); in lpfc_pci_function_reset()
11760 rc = -ENODEV; in lpfc_pci_function_reset()
11776 writel(reg_data.word0, phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
11779 pci_read_config_word(phba->pcidev, in lpfc_pci_function_reset()
11786 rc = -ENODEV; in lpfc_pci_function_reset()
11797 /* Catch the not-ready port failure after a port reset. */ in lpfc_pci_function_reset()
11802 rc = -ENODEV; in lpfc_pci_function_reset()
11809 * lpfc_sli4_pci_mem_setup - Setup SLI4 HBA PCI memory space.
11813 * with SLI-4 interface spec.
11816 * 0 - successful
11817 * other values - error
11822 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_pci_mem_setup()
11828 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11831 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli4_pci_mem_setup()
11833 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli4_pci_mem_setup()
11842 &phba->sli4_hba.sli_intf.word0)) { in lpfc_sli4_pci_mem_setup()
11843 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11847 if (bf_get(lpfc_sli_intf_valid, &phba->sli4_hba.sli_intf) != in lpfc_sli4_pci_mem_setup()
11852 phba->sli4_hba.sli_intf.word0); in lpfc_sli4_pci_mem_setup()
11853 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11856 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_setup()
11864 phba->pci_bar0_map = pci_resource_start(pdev, PCI_64BIT_BAR0); in lpfc_sli4_pci_mem_setup()
11871 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11872 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
11873 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11874 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11877 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11879 phba->pci_bar0_memmap_p = phba->sli4_hba.conf_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11883 phba->pci_bar0_map = pci_resource_start(pdev, 1); in lpfc_sli4_pci_mem_setup()
11886 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11887 "FATAL - No BAR0 mapping for SLI4, if_type 2\n"); in lpfc_sli4_pci_mem_setup()
11888 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11890 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11891 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
11892 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11893 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11896 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11907 phba->pci_bar1_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
11910 phba->sli4_hba.ctrl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11911 ioremap(phba->pci_bar1_map, in lpfc_sli4_pci_mem_setup()
11913 if (!phba->sli4_hba.ctrl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11914 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11917 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11920 phba->pci_bar2_memmap_p = in lpfc_sli4_pci_mem_setup()
11921 phba->sli4_hba.ctrl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11924 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11935 phba->pci_bar1_map = pci_resource_start(pdev, PCI_64BIT_BAR2); in lpfc_sli4_pci_mem_setup()
11937 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11938 ioremap(phba->pci_bar1_map, bar1map_len); in lpfc_sli4_pci_mem_setup()
11939 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11940 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11942 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11945 phba->pci_bar2_memmap_p = phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11955 phba->pci_bar2_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
11958 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11959 ioremap(phba->pci_bar2_map, in lpfc_sli4_pci_mem_setup()
11961 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11962 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11965 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11968 phba->pci_bar4_memmap_p = in lpfc_sli4_pci_mem_setup()
11969 phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11974 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11985 phba->pci_bar2_map = pci_resource_start(pdev, PCI_64BIT_BAR4); in lpfc_sli4_pci_mem_setup()
11987 phba->sli4_hba.dpp_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11988 ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli4_pci_mem_setup()
11989 if (!phba->sli4_hba.dpp_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11990 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11992 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11995 phba->pci_bar4_memmap_p = phba->sli4_hba.dpp_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
12002 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
12003 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_write_eq_db; in lpfc_sli4_pci_mem_setup()
12004 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_write_cq_db; in lpfc_sli4_pci_mem_setup()
12007 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_if6_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
12008 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_if6_write_eq_db; in lpfc_sli4_pci_mem_setup()
12009 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_if6_write_cq_db; in lpfc_sli4_pci_mem_setup()
12018 if (phba->sli4_hba.drbl_regs_memmap_p) in lpfc_sli4_pci_mem_setup()
12019 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12021 if (phba->sli4_hba.ctrl_regs_memmap_p) in lpfc_sli4_pci_mem_setup()
12022 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12024 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12030 * lpfc_sli4_pci_mem_unset - Unset SLI4 HBA PCI memory space.
12034 * with SLI-4 interface spec.
12040 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_unset()
12044 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12045 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12046 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12049 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12052 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12053 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12054 if (phba->sli4_hba.dpp_regs_memmap_p) in lpfc_sli4_pci_mem_unset()
12055 iounmap(phba->sli4_hba.dpp_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12060 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_pci_mem_unset()
12061 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_pci_mem_unset()
12068 * lpfc_sli_enable_msix - Enable MSI-X interrupt mode on SLI-3 device
12071 * This routine is invoked to enable the MSI-X interrupt vectors to device
12072 * with SLI-3 interface specs.
12075 * 0 - successful
12076 * other values - error
12084 /* Set up MSI-X multi-message vectors */ in lpfc_sli_enable_msix()
12085 rc = pci_alloc_irq_vectors(phba->pcidev, in lpfc_sli_enable_msix()
12089 "0420 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli_enable_msix()
12094 * Assign MSI-X vectors to interrupt handlers in lpfc_sli_enable_msix()
12097 /* vector-0 is associated to slow-path handler */ in lpfc_sli_enable_msix()
12098 rc = request_irq(pci_irq_vector(phba->pcidev, 0), in lpfc_sli_enable_msix()
12103 "0421 MSI-X slow-path request_irq failed " in lpfc_sli_enable_msix()
12108 /* vector-1 is associated to fast-path handler */ in lpfc_sli_enable_msix()
12109 rc = request_irq(pci_irq_vector(phba->pcidev, 1), in lpfc_sli_enable_msix()
12115 "0429 MSI-X fast-path request_irq failed " in lpfc_sli_enable_msix()
12121 * Configure HBA MSI-X attention conditions to messages in lpfc_sli_enable_msix()
12123 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_enable_msix()
12126 rc = -ENOMEM; in lpfc_sli_enable_msix()
12140 pmb->u.mb.mbxCommand, pmb->u.mb.mbxStatus); in lpfc_sli_enable_msix()
12145 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
12150 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
12154 free_irq(pci_irq_vector(phba->pcidev, 1), phba); in lpfc_sli_enable_msix()
12158 free_irq(pci_irq_vector(phba->pcidev, 0), phba); in lpfc_sli_enable_msix()
12161 /* Unconfigure MSI-X capability structure */ in lpfc_sli_enable_msix()
12162 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_enable_msix()
12169 * lpfc_sli_enable_msi - Enable MSI interrupt mode on SLI-3 device.
12173 * SLI-3 interface spec. The kernel function pci_enable_msi() is called to
12179 * 0 - successful
12180 * other values - error
12187 rc = pci_enable_msi(phba->pcidev); in lpfc_sli_enable_msi()
12197 rc = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_msi()
12200 pci_disable_msi(phba->pcidev); in lpfc_sli_enable_msi()
12208 * lpfc_sli_enable_intr - Enable device interrupt to SLI-3 device.
12210 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
12213 * interrupt handler(s) to interrupt vector(s) to device with SLI-3 interface
12218 * MSI-X -> MSI -> IRQ.
12221 * 0 - successful
12222 * other values - error
12234 phba->hba_flag &= ~HBA_NEEDS_CFG_PORT; in lpfc_sli_enable_intr()
12237 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli_enable_intr()
12240 /* Indicate initialization to MSI-X mode */ in lpfc_sli_enable_intr()
12241 phba->intr_type = MSIX; in lpfc_sli_enable_intr()
12246 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli_enable_intr()
12247 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli_enable_intr()
12251 phba->intr_type = MSI; in lpfc_sli_enable_intr()
12256 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli_enable_intr()
12257 if (phba->intr_type == NONE) { in lpfc_sli_enable_intr()
12258 retval = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_intr()
12262 phba->intr_type = INTx; in lpfc_sli_enable_intr()
12270 * lpfc_sli_disable_intr - Disable device interrupt to SLI-3 device.
12275 * SLI-3 interface spec. Depending on the interrupt mode, the driver will
12283 if (phba->intr_type == MSIX) in lpfc_sli_disable_intr()
12289 free_irq(pci_irq_vector(phba->pcidev, i), phba); in lpfc_sli_disable_intr()
12290 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_disable_intr()
12293 phba->intr_type = NONE; in lpfc_sli_disable_intr()
12294 phba->sli.slistat.sli_intr = 0; in lpfc_sli_disable_intr()
12298 * lpfc_find_cpu_handle - Find the CPU that corresponds to the specified Queue
12303 * Return the CPU that matches the selection criteria
12309 int cpu; in lpfc_find_cpu_handle() local
12312 for_each_present_cpu(cpu) { in lpfc_find_cpu_handle()
12313 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_find_cpu_handle()
12320 (cpup->flag & LPFC_CPU_FIRST_IRQ) && in lpfc_find_cpu_handle()
12321 (cpup->eq == id)) in lpfc_find_cpu_handle()
12322 return cpu; in lpfc_find_cpu_handle()
12324 /* If matching by HDWQ, select the first CPU that matches */ in lpfc_find_cpu_handle()
12325 if ((match == LPFC_FIND_BY_HDWQ) && (cpup->hdwq == id)) in lpfc_find_cpu_handle()
12326 return cpu; in lpfc_find_cpu_handle()
12333 * lpfc_find_hyper - Determine if the CPU map entry is hyper-threaded
12335 * @cpu: CPU map index
12336 * @phys_id: CPU package physical id
12337 * @core_id: CPU core id
12340 lpfc_find_hyper(struct lpfc_hba *phba, int cpu, in lpfc_find_hyper() argument
12347 cpup = &phba->sli4_hba.cpu_map[idx]; in lpfc_find_hyper()
12349 if ((cpup->phys_id == phys_id) && in lpfc_find_hyper()
12350 (cpup->core_id == core_id) && in lpfc_find_hyper()
12351 (cpu != idx)) in lpfc_find_hyper()
12359 * lpfc_assign_eq_map_info - Assigns eq for vector_map structure
12363 * @cpu: cpu used to index vector_map structure
12369 unsigned int cpu) in lpfc_assign_eq_map_info() argument
12371 struct lpfc_vector_map_info *cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_assign_eq_map_info()
12374 cpup->eq = eqidx; in lpfc_assign_eq_map_info()
12375 cpup->flag |= flag; in lpfc_assign_eq_map_info()
12378 "3336 Set Affinity: CPU %d irq %d eq %d flag x%x\n", in lpfc_assign_eq_map_info()
12379 cpu, eqhdl->irq, cpup->eq, cpup->flag); in lpfc_assign_eq_map_info()
12383 * lpfc_cpu_map_array_init - Initialize cpu_map structure
12393 int cpu; in lpfc_cpu_map_array_init() local
12395 for_each_possible_cpu(cpu) { in lpfc_cpu_map_array_init()
12396 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_map_array_init()
12397 cpup->phys_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12398 cpup->core_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12399 cpup->hdwq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12400 cpup->eq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12401 cpup->flag = 0; in lpfc_cpu_map_array_init()
12402 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, cpu); in lpfc_cpu_map_array_init()
12403 INIT_LIST_HEAD(&eqi->list); in lpfc_cpu_map_array_init()
12404 eqi->icnt = 0; in lpfc_cpu_map_array_init()
12409 * lpfc_hba_eq_hdl_array_init - Initialize hba_eq_hdl structure
12420 for (i = 0; i < phba->cfg_irq_chann; i++) { in lpfc_hba_eq_hdl_array_init()
12422 eqhdl->irq = LPFC_IRQ_EMPTY; in lpfc_hba_eq_hdl_array_init()
12423 eqhdl->phba = phba; in lpfc_hba_eq_hdl_array_init()
12428 * lpfc_cpu_affinity_check - Check vector CPU affinity mappings
12432 * The routine will figure out the CPU affinity assignment for every
12433 * MSI-X vector allocated for the HBA.
12434 * In addition, the CPU to IO channel mapping will be calculated
12435 * and the phba->sli4_hba.cpu_map array will reflect this.
12440 int i, cpu, idx, next_idx, new_cpu, start_cpu, first_cpu; in lpfc_cpu_affinity_check() local
12454 /* Update CPU map with physical id and core id of each CPU */ in lpfc_cpu_affinity_check()
12455 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
12456 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12458 cpup->phys_id = topology_physical_package_id(cpu); in lpfc_cpu_affinity_check()
12459 cpup->core_id = topology_core_id(cpu); in lpfc_cpu_affinity_check()
12460 if (lpfc_find_hyper(phba, cpu, cpup->phys_id, cpup->core_id)) in lpfc_cpu_affinity_check()
12461 cpup->flag |= LPFC_CPU_MAP_HYPER; in lpfc_cpu_affinity_check()
12464 cpup->phys_id = 0; in lpfc_cpu_affinity_check()
12465 cpup->core_id = cpu; in lpfc_cpu_affinity_check()
12469 "3328 CPU %d physid %d coreid %d flag x%x\n", in lpfc_cpu_affinity_check()
12470 cpu, cpup->phys_id, cpup->core_id, cpup->flag); in lpfc_cpu_affinity_check()
12472 if (cpup->phys_id > max_phys_id) in lpfc_cpu_affinity_check()
12473 max_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
12474 if (cpup->phys_id < min_phys_id) in lpfc_cpu_affinity_check()
12475 min_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
12477 if (cpup->core_id > max_core_id) in lpfc_cpu_affinity_check()
12478 max_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
12479 if (cpup->core_id < min_core_id) in lpfc_cpu_affinity_check()
12480 min_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
12485 * Next we will set any unassigned (unaffinitized) cpu map in lpfc_cpu_affinity_check()
12491 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
12492 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12494 /* Is this CPU entry unassigned */ in lpfc_cpu_affinity_check()
12495 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
12496 /* Mark CPU as IRQ not assigned by the kernel */ in lpfc_cpu_affinity_check()
12497 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
12505 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12506 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12507 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
12508 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY) && in lpfc_cpu_affinity_check()
12509 (new_cpup->phys_id == cpup->phys_id)) in lpfc_cpu_affinity_check()
12513 /* At this point, we leave the CPU as unassigned */ in lpfc_cpu_affinity_check()
12517 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
12520 * chance of having multiple unassigned CPU entries in lpfc_cpu_affinity_check()
12526 "3337 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
12527 "eq %d from peer cpu %d same " in lpfc_cpu_affinity_check()
12529 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
12530 cpup->phys_id); in lpfc_cpu_affinity_check()
12534 /* Set any unassigned cpu map entries to a IRQ on any phys_id */ in lpfc_cpu_affinity_check()
12537 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
12538 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12541 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
12543 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
12551 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12552 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12553 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
12554 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY)) in lpfc_cpu_affinity_check()
12560 "3339 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
12562 cpup->hdwq, cpup->eq); in lpfc_cpu_affinity_check()
12566 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
12569 * chance of having multiple unassigned CPU entries in lpfc_cpu_affinity_check()
12575 "3338 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
12576 "eq %d from peer cpu %d (%d/%d)\n", in lpfc_cpu_affinity_check()
12577 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
12578 new_cpup->phys_id, new_cpup->core_id); in lpfc_cpu_affinity_check()
12586 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
12587 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12590 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_cpu_affinity_check()
12594 cpup->hdwq = idx; in lpfc_cpu_affinity_check()
12597 "3333 Set Affinity: CPU %d (phys %d core %d): " in lpfc_cpu_affinity_check()
12599 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
12600 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
12603 * This will be 1 to 1 - hdwq to cpu, unless there are less in lpfc_cpu_affinity_check()
12604 * hardware queues then CPUs. For that case we will just round-robin in lpfc_cpu_affinity_check()
12607 * for irq_chann < hdwq. The idx is used for round-robin assignments in lpfc_cpu_affinity_check()
12613 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
12614 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12617 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_cpu_affinity_check()
12624 if (next_idx < phba->cfg_hdw_queue) { in lpfc_cpu_affinity_check()
12625 cpup->hdwq = next_idx; in lpfc_cpu_affinity_check()
12630 /* Not a First CPU and all hdw_queues are used. Reuse a in lpfc_cpu_affinity_check()
12631 * Hardware Queue for another CPU, so be smart about it in lpfc_cpu_affinity_check()
12633 * (CPU package) and core_id. in lpfc_cpu_affinity_check()
12636 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12637 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12638 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
12639 new_cpup->phys_id == cpup->phys_id && in lpfc_cpu_affinity_check()
12640 new_cpup->core_id == cpup->core_id) { in lpfc_cpu_affinity_check()
12650 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12651 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12652 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
12653 new_cpup->phys_id == cpup->phys_id) in lpfc_cpu_affinity_check()
12659 cpup->hdwq = idx % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
12665 cpup->hdwq = new_cpup->hdwq; in lpfc_cpu_affinity_check()
12668 "3335 Set Affinity: CPU %d (phys %d core %d): " in lpfc_cpu_affinity_check()
12670 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
12671 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
12675 * Initialize the cpu_map slots for not-present cpus in case in lpfc_cpu_affinity_check()
12676 * a cpu is hot-added. Perform a simple hdwq round robin assignment. in lpfc_cpu_affinity_check()
12679 for_each_possible_cpu(cpu) { in lpfc_cpu_affinity_check()
12680 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12682 c_stat = per_cpu_ptr(phba->sli4_hba.c_stat, cpu); in lpfc_cpu_affinity_check()
12683 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
12685 if (cpup->hdwq != LPFC_VECTOR_MAP_EMPTY) in lpfc_cpu_affinity_check()
12688 cpup->hdwq = idx++ % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
12690 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
12694 "CPU %d hdwq %d\n", in lpfc_cpu_affinity_check()
12695 cpu, cpup->hdwq); in lpfc_cpu_affinity_check()
12708 * @cpu: cpu going offline
12712 lpfc_cpuhp_get_eq(struct lpfc_hba *phba, unsigned int cpu, in lpfc_cpuhp_get_eq() argument
12722 return -ENOMEM; in lpfc_cpuhp_get_eq()
12724 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_cpuhp_get_eq()
12725 maskp = pci_irq_get_affinity(phba->pcidev, idx); in lpfc_cpuhp_get_eq()
12729 * if irq is not affinitized to the cpu going in lpfc_cpuhp_get_eq()
12733 if (!cpumask_and(tmp, maskp, cpumask_of(cpu))) in lpfc_cpuhp_get_eq()
12735 /* get the cpus that are online and are affini- in lpfc_cpuhp_get_eq()
12737 * more than 1 then cpuhp is not going to shut- in lpfc_cpuhp_get_eq()
12738 * down this vector. Since this cpu has not in lpfc_cpuhp_get_eq()
12750 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_cpuhp_get_eq()
12751 list_add(&eq->_poll_list, eqlist); in lpfc_cpuhp_get_eq()
12759 if (phba->sli_rev != LPFC_SLI_REV4) in __lpfc_cpuhp_remove()
12763 &phba->cpuhp); in __lpfc_cpuhp_remove()
12769 del_timer_sync(&phba->cpuhp_poll_timer); in __lpfc_cpuhp_remove()
12774 if (phba->pport && (phba->pport->fc_flag & FC_OFFLINE_MODE)) in lpfc_cpuhp_remove()
12782 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_cpuhp_add()
12787 if (!list_empty(&phba->poll_list)) in lpfc_cpuhp_add()
12788 mod_timer(&phba->cpuhp_poll_timer, in lpfc_cpuhp_add()
12794 &phba->cpuhp); in lpfc_cpuhp_add()
12799 if (phba->pport->load_flag & FC_UNLOADING) { in __lpfc_cpuhp_checks()
12800 *retval = -EAGAIN; in __lpfc_cpuhp_checks()
12804 if (phba->sli_rev != LPFC_SLI_REV4) { in __lpfc_cpuhp_checks()
12814 * lpfc_irq_set_aff - set IRQ affinity
12816 * @cpu: cpu to set affinity
12820 lpfc_irq_set_aff(struct lpfc_hba_eq_hdl *eqhdl, unsigned int cpu) in lpfc_irq_set_aff() argument
12822 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_set_aff()
12823 cpumask_set_cpu(cpu, &eqhdl->aff_mask); in lpfc_irq_set_aff()
12824 irq_set_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_set_aff()
12825 irq_set_affinity(eqhdl->irq, &eqhdl->aff_mask); in lpfc_irq_set_aff()
12829 * lpfc_irq_clear_aff - clear IRQ affinity
12836 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_clear_aff()
12837 irq_clear_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_clear_aff()
12841 * lpfc_irq_rebalance - rebalances IRQ affinity according to cpuhp event
12843 * @cpu: cpu going offline/online
12844 * @offline: true, cpu is going offline. false, cpu is coming online.
12846 * If cpu is going offline, we'll try our best effort to find the next
12847 * online cpu on the phba's original_mask and migrate all offlining IRQ
12850 * If cpu is coming online, reaffinitize the IRQ back to the onlining cpu.
12853 * PCI_IRQ_AFFINITY to auto-manage IRQ affinity.
12857 lpfc_irq_rebalance(struct lpfc_hba *phba, unsigned int cpu, bool offline) in lpfc_irq_rebalance() argument
12864 if (phba->irq_chann_mode == NORMAL_MODE) in lpfc_irq_rebalance()
12867 orig_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_irq_rebalance()
12869 if (!cpumask_test_cpu(cpu, orig_mask)) in lpfc_irq_rebalance()
12872 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_irq_rebalance()
12874 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_irq_rebalance()
12878 /* Find next online CPU on original mask */ in lpfc_irq_rebalance()
12879 cpu_next = cpumask_next_wrap(cpu, orig_mask, cpu, true); in lpfc_irq_rebalance()
12882 /* Found a valid CPU */ in lpfc_irq_rebalance()
12883 if ((cpu_select < nr_cpu_ids) && (cpu_select != cpu)) { in lpfc_irq_rebalance()
12885 * cpu aff_mask is migrated in lpfc_irq_rebalance()
12887 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_irq_rebalance()
12891 if (cpumask_test_cpu(cpu, aff_mask)) in lpfc_irq_rebalance()
12897 for (idx = 0; idx < phba->cfg_irq_chann; idx++) in lpfc_irq_rebalance()
12901 /* Migrate affinity back to this CPU */ in lpfc_irq_rebalance()
12902 lpfc_irq_set_aff(lpfc_get_eq_hdl(cpup->eq), cpu); in lpfc_irq_rebalance()
12906 static int lpfc_cpu_offline(unsigned int cpu, struct hlist_node *node) in lpfc_cpu_offline() argument
12914 WARN_ONCE(!phba, "cpu: %u. phba:NULL", raw_smp_processor_id()); in lpfc_cpu_offline()
12921 lpfc_irq_rebalance(phba, cpu, true); in lpfc_cpu_offline()
12923 retval = lpfc_cpuhp_get_eq(phba, cpu, &eqlist); in lpfc_cpu_offline()
12929 list_del_init(&eq->_poll_list); in lpfc_cpu_offline()
12936 static int lpfc_cpu_online(unsigned int cpu, struct hlist_node *node) in lpfc_cpu_online() argument
12944 WARN_ONCE(!phba, "cpu: %u. phba:NULL", raw_smp_processor_id()); in lpfc_cpu_online()
12951 lpfc_irq_rebalance(phba, cpu, false); in lpfc_cpu_online()
12953 list_for_each_entry_safe(eq, next, &phba->poll_list, _poll_list) { in lpfc_cpu_online()
12954 n = lpfc_find_cpu_handle(phba, eq->hdwq, LPFC_FIND_BY_HDWQ); in lpfc_cpu_online()
12955 if (n == cpu) in lpfc_cpu_online()
12963 * lpfc_sli4_enable_msix - Enable MSI-X interrupt mode to SLI-4 device
12966 * This routine is invoked to enable the MSI-X interrupt vectors to device
12967 * with SLI-4 interface spec. It also allocates MSI-X vectors and maps them
12973 * allocated and assigned to each online and offline cpu. If the cpu is
12974 * online, then affinity will be set to that cpu. If the cpu is offline, then
12975 * affinity will be set to the nearest peer cpu within the numa node that is
12977 * assigned and the OS may do as it pleases. Note: cpu vector affinity mapping
12978 * is consistent with the way cpu online/offline is handled when cfg_irq_numa is
12983 * cpu affinity. The driver will then use that affinity mapping to setup its
12984 * cpu mapping table.
12987 * 0 - successful
12988 * other values - error
12996 unsigned int cpu = 0, cpu_cnt = 0, cpu_select = nr_cpu_ids; in lpfc_sli4_enable_msix() local
13002 /* Set up MSI-X multi-message vectors */ in lpfc_sli4_enable_msix()
13003 vectors = phba->cfg_irq_chann; in lpfc_sli4_enable_msix()
13005 if (phba->irq_chann_mode != NORMAL_MODE) in lpfc_sli4_enable_msix()
13006 aff_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_sli4_enable_msix()
13010 vectors = min(phba->cfg_irq_chann, cpu_cnt); in lpfc_sli4_enable_msix()
13012 /* cpu: iterates over aff_mask including offline or online in lpfc_sli4_enable_msix()
13015 cpu = cpumask_first(aff_mask); in lpfc_sli4_enable_msix()
13016 cpu_select = lpfc_next_online_cpu(aff_mask, cpu); in lpfc_sli4_enable_msix()
13021 rc = pci_alloc_irq_vectors(phba->pcidev, 1, vectors, flags); in lpfc_sli4_enable_msix()
13024 "0484 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli4_enable_msix()
13029 /* Assign MSI-X vectors to interrupt handlers */ in lpfc_sli4_enable_msix()
13032 name = eqhdl->handler_name; in lpfc_sli4_enable_msix()
13037 eqhdl->idx = index; in lpfc_sli4_enable_msix()
13038 rc = pci_irq_vector(phba->pcidev, index); in lpfc_sli4_enable_msix()
13041 "0489 MSI-X fast-path (%d) " in lpfc_sli4_enable_msix()
13045 eqhdl->irq = rc; in lpfc_sli4_enable_msix()
13047 rc = request_threaded_irq(eqhdl->irq, in lpfc_sli4_enable_msix()
13053 "0486 MSI-X fast-path (%d) " in lpfc_sli4_enable_msix()
13059 /* If found a neighboring online cpu, set affinity */ in lpfc_sli4_enable_msix()
13066 cpu); in lpfc_sli4_enable_msix()
13068 /* Iterate to next offline or online cpu in aff_mask */ in lpfc_sli4_enable_msix()
13069 cpu = cpumask_next(cpu, aff_mask); in lpfc_sli4_enable_msix()
13071 /* Find next online cpu in aff_mask to set affinity */ in lpfc_sli4_enable_msix()
13072 cpu_select = lpfc_next_online_cpu(aff_mask, cpu); in lpfc_sli4_enable_msix()
13074 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_msix()
13076 cpu); in lpfc_sli4_enable_msix()
13078 maskp = pci_irq_get_affinity(phba->pcidev, index); in lpfc_sli4_enable_msix()
13081 for_each_cpu_and(cpu, maskp, cpu_present_mask) { in lpfc_sli4_enable_msix()
13082 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_enable_msix()
13084 /* If this is the first CPU thats assigned to in lpfc_sli4_enable_msix()
13088 * vectors are affinitized to all the cpu's. in lpfc_sli4_enable_msix()
13096 if (cpup->eq != LPFC_VECTOR_MAP_EMPTY) in lpfc_sli4_enable_msix()
13100 cpu); in lpfc_sli4_enable_msix()
13106 if (vectors != phba->cfg_irq_chann) { in lpfc_sli4_enable_msix()
13109 "MSI-X vectors, requested %d got %d\n", in lpfc_sli4_enable_msix()
13110 phba->cfg_irq_chann, vectors); in lpfc_sli4_enable_msix()
13111 if (phba->cfg_irq_chann > vectors) in lpfc_sli4_enable_msix()
13112 phba->cfg_irq_chann = vectors; in lpfc_sli4_enable_msix()
13119 for (--index; index >= 0; index--) { in lpfc_sli4_enable_msix()
13122 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_enable_msix()
13125 /* Unconfigure MSI-X capability structure */ in lpfc_sli4_enable_msix()
13126 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msix()
13133 * lpfc_sli4_enable_msi - Enable MSI interrupt mode to SLI-4 device
13137 * SLI-4 interface spec. The kernel function pci_alloc_irq_vectors() is
13143 * 0 - successful
13144 * other values - error
13150 unsigned int cpu; in lpfc_sli4_enable_msi() local
13153 rc = pci_alloc_irq_vectors(phba->pcidev, 1, 1, in lpfc_sli4_enable_msi()
13161 return rc ? rc : -1; in lpfc_sli4_enable_msi()
13164 rc = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_msi()
13167 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msi()
13174 rc = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_msi()
13176 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msi()
13181 eqhdl->irq = rc; in lpfc_sli4_enable_msi()
13183 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_msi()
13184 lpfc_assign_eq_map_info(phba, 0, LPFC_CPU_FIRST_IRQ, cpu); in lpfc_sli4_enable_msi()
13186 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_enable_msi()
13188 eqhdl->idx = index; in lpfc_sli4_enable_msi()
13195 * lpfc_sli4_enable_intr - Enable device interrupt to SLI-4 device
13197 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
13200 * interrupt handler(s) to interrupt vector(s) to device with SLI-4
13205 * MSI-X -> MSI -> IRQ.
13208 * Interrupt mode (2, 1, 0) - successful
13209 * LPFC_INTR_ERROR - error
13221 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli4_enable_intr()
13224 /* Indicate initialization to MSI-X mode */ in lpfc_sli4_enable_intr()
13225 phba->intr_type = MSIX; in lpfc_sli4_enable_intr()
13231 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli4_enable_intr()
13232 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
13236 phba->intr_type = MSI; in lpfc_sli4_enable_intr()
13241 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli4_enable_intr()
13242 if (phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
13243 retval = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_intr()
13247 unsigned int cpu; in lpfc_sli4_enable_intr() local
13250 phba->intr_type = INTx; in lpfc_sli4_enable_intr()
13254 retval = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_intr()
13261 eqhdl->irq = retval; in lpfc_sli4_enable_intr()
13263 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_intr()
13265 cpu); in lpfc_sli4_enable_intr()
13266 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_enable_intr()
13268 eqhdl->idx = idx; in lpfc_sli4_enable_intr()
13276 * lpfc_sli4_disable_intr - Disable device interrupt to SLI-4 device
13281 * with SLI-4 interface spec. Depending on the interrupt mode, the driver
13288 if (phba->intr_type == MSIX) { in lpfc_sli4_disable_intr()
13292 /* Free up MSI-X multi-message vectors */ in lpfc_sli4_disable_intr()
13293 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_disable_intr()
13296 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_disable_intr()
13299 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_disable_intr()
13302 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_disable_intr()
13305 phba->intr_type = NONE; in lpfc_sli4_disable_intr()
13306 phba->sli.slistat.sli_intr = 0; in lpfc_sli4_disable_intr()
13310 * lpfc_unset_hba - Unset SLI3 hba device initialization
13314 * a device with SLI-3 interface spec.
13319 struct lpfc_vport *vport = phba->pport; in lpfc_unset_hba()
13322 spin_lock_irq(shost->host_lock); in lpfc_unset_hba()
13323 vport->load_flag |= FC_UNLOADING; in lpfc_unset_hba()
13324 spin_unlock_irq(shost->host_lock); in lpfc_unset_hba()
13326 kfree(phba->vpi_bmask); in lpfc_unset_hba()
13327 kfree(phba->vpi_ids); in lpfc_unset_hba()
13331 phba->pport->work_port_events = 0; in lpfc_unset_hba()
13343 * lpfc_sli4_xri_exchange_busy_wait - Wait for device XRI exchange busy
13363 int els_xri_cmpl = list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
13372 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_xri_exchange_busy_wait()
13376 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
13377 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
13378 io_xri_cmpl = list_empty(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
13385 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
13387 list_empty(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
13415 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
13416 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
13418 &qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
13425 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
13427 &phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
13430 list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
13436 * lpfc_sli4_hba_unset - Unset the fcoe hba
13450 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_hba_unset()
13453 hrtimer_cancel(&phba->cmf_stats_timer); in lpfc_sli4_hba_unset()
13454 hrtimer_cancel(&phba->cmf_timer); in lpfc_sli4_hba_unset()
13456 if (phba->pport) in lpfc_sli4_hba_unset()
13457 phba->sli4_hba.intr_enable = 0; in lpfc_sli4_hba_unset()
13465 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13466 phba->sli.sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_hba_unset()
13467 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13469 while (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
13475 if (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
13476 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13477 mboxq = phba->sli.mbox_active; in lpfc_sli4_hba_unset()
13478 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_hba_unset()
13480 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_hba_unset()
13481 phba->sli.mbox_active = NULL; in lpfc_sli4_hba_unset()
13482 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13488 if (!pci_channel_offline(phba->pcidev)) in lpfc_sli4_hba_unset()
13492 /* per-phba callback de-registration for hotplug event */ in lpfc_sli4_hba_unset()
13493 if (phba->pport) in lpfc_sli4_hba_unset()
13499 /* Disable SR-IOV if enabled */ in lpfc_sli4_hba_unset()
13500 if (phba->cfg_sriov_nr_virtfn) in lpfc_sli4_hba_unset()
13504 kthread_stop(phba->worker_thread); in lpfc_sli4_hba_unset()
13516 if (phba->ras_fwlog.ras_enabled) in lpfc_sli4_hba_unset()
13520 if (phba->pport) in lpfc_sli4_hba_unset()
13521 phba->pport->work_port_events = 0; in lpfc_sli4_hba_unset()
13582 "6235 INIT Congestion Buffer %p\n", phba->cgn_i); in lpfc_init_congestion_buf()
13584 if (!phba->cgn_i) in lpfc_init_congestion_buf()
13586 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_init_congestion_buf()
13588 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_init_congestion_buf()
13589 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_init_congestion_buf()
13590 atomic_set(&phba->cgn_sync_alarm_cnt, 0); in lpfc_init_congestion_buf()
13591 atomic_set(&phba->cgn_sync_warn_cnt, 0); in lpfc_init_congestion_buf()
13593 atomic_set(&phba->cgn_driver_evt_cnt, 0); in lpfc_init_congestion_buf()
13594 atomic_set(&phba->cgn_latency_evt_cnt, 0); in lpfc_init_congestion_buf()
13595 atomic64_set(&phba->cgn_latency_evt, 0); in lpfc_init_congestion_buf()
13596 phba->cgn_evt_minute = 0; in lpfc_init_congestion_buf()
13599 cp->cgn_info_size = cpu_to_le16(LPFC_CGN_INFO_SZ); in lpfc_init_congestion_buf()
13600 cp->cgn_info_version = LPFC_CGN_INFO_V4; in lpfc_init_congestion_buf()
13603 cp->cgn_info_mode = phba->cgn_p.cgn_param_mode; in lpfc_init_congestion_buf()
13604 cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0; in lpfc_init_congestion_buf()
13605 cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1; in lpfc_init_congestion_buf()
13606 cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2; in lpfc_init_congestion_buf()
13608 lpfc_cgn_update_tstamp(phba, &cp->base_time); in lpfc_init_congestion_buf()
13611 if (phba->pport) { in lpfc_init_congestion_buf()
13612 size = (uint16_t)(phba->pport->cfg_lun_queue_depth); in lpfc_init_congestion_buf()
13613 cp->cgn_lunq = cpu_to_le16(size); in lpfc_init_congestion_buf()
13618 cp->cgn_warn_freq = cpu_to_le16(LPFC_FPIN_INIT_FREQ); in lpfc_init_congestion_buf()
13619 cp->cgn_alarm_freq = cpu_to_le16(LPFC_FPIN_INIT_FREQ); in lpfc_init_congestion_buf()
13621 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_init_congestion_buf()
13623 phba->cgn_evt_timestamp = jiffies + in lpfc_init_congestion_buf()
13634 "6236 INIT Congestion Stat %p\n", phba->cgn_i); in lpfc_init_congestion_stat()
13636 if (!phba->cgn_i) in lpfc_init_congestion_stat()
13639 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_init_congestion_stat()
13640 memset(&cp->cgn_stat, 0, sizeof(cp->cgn_stat)); in lpfc_init_congestion_stat()
13642 lpfc_cgn_update_tstamp(phba, &cp->stat_start); in lpfc_init_congestion_stat()
13644 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_init_congestion_stat()
13648 * __lpfc_reg_congestion_buf - register congestion info buffer with HBA
13661 if (!phba->cgn_i) in __lpfc_reg_congestion_buf()
13662 return -ENXIO; in __lpfc_reg_congestion_buf()
13664 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in __lpfc_reg_congestion_buf()
13669 phba->pport->port_state, reg); in __lpfc_reg_congestion_buf()
13670 return -ENOMEM; in __lpfc_reg_congestion_buf()
13673 length = (sizeof(struct lpfc_mbx_reg_congestion_buf) - in __lpfc_reg_congestion_buf()
13678 reg_congestion_buf = &mboxq->u.mqe.un.reg_congestion_buf; in __lpfc_reg_congestion_buf()
13684 reg_congestion_buf->length = sizeof(struct lpfc_cgn_info); in __lpfc_reg_congestion_buf()
13685 reg_congestion_buf->addr_lo = in __lpfc_reg_congestion_buf()
13686 putPaddrLow(phba->cgn_i->phys); in __lpfc_reg_congestion_buf()
13687 reg_congestion_buf->addr_hi = in __lpfc_reg_congestion_buf()
13688 putPaddrHigh(phba->cgn_i->phys); in __lpfc_reg_congestion_buf()
13692 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in __lpfc_reg_congestion_buf()
13693 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in __lpfc_reg_congestion_buf()
13695 &shdr->response); in __lpfc_reg_congestion_buf()
13696 mempool_free(mboxq, phba->mbox_mem_pool); in __lpfc_reg_congestion_buf()
13703 return -ENXIO; in __lpfc_reg_congestion_buf()
13722 * lpfc_get_sli4_parameters - Get the SLI4 Config PARAMETERS.
13729 * This function may be be called from any context that can block-wait
13737 struct lpfc_mqe *mqe = &mboxq->u.mqe; in lpfc_get_sli4_parameters()
13749 phba->sli4_hba.rpi_hdrs_in_use = 1; in lpfc_get_sli4_parameters()
13752 length = (sizeof(struct lpfc_mbx_get_sli4_parameters) - in lpfc_get_sli4_parameters()
13757 if (!phba->sli4_hba.intr_enable) in lpfc_get_sli4_parameters()
13765 sli4_params = &phba->sli4_hba.pc_sli4_params; in lpfc_get_sli4_parameters()
13766 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters; in lpfc_get_sli4_parameters()
13767 sli4_params->if_type = bf_get(cfg_if_type, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13768 sli4_params->sli_rev = bf_get(cfg_sli_rev, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13769 sli4_params->sli_family = bf_get(cfg_sli_family, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13770 sli4_params->featurelevel_1 = bf_get(cfg_sli_hint_1, in lpfc_get_sli4_parameters()
13772 sli4_params->featurelevel_2 = bf_get(cfg_sli_hint_2, in lpfc_get_sli4_parameters()
13775 phba->sli3_options |= LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
13777 phba->sli3_options &= ~LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
13778 sli4_params->sge_supp_len = mbx_sli4_parameters->sge_supp_len; in lpfc_get_sli4_parameters()
13779 sli4_params->loopbk_scope = bf_get(cfg_loopbk_scope, in lpfc_get_sli4_parameters()
13781 sli4_params->oas_supported = bf_get(cfg_oas, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13782 sli4_params->cqv = bf_get(cfg_cqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13783 sli4_params->mqv = bf_get(cfg_mqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13784 sli4_params->wqv = bf_get(cfg_wqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13785 sli4_params->rqv = bf_get(cfg_rqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13786 sli4_params->eqav = bf_get(cfg_eqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13787 sli4_params->cqav = bf_get(cfg_cqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13788 sli4_params->wqsize = bf_get(cfg_wqsize, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13789 sli4_params->bv1s = bf_get(cfg_bv1s, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13790 sli4_params->pls = bf_get(cfg_pvl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13791 sli4_params->sgl_pages_max = bf_get(cfg_sgl_page_cnt, in lpfc_get_sli4_parameters()
13793 sli4_params->wqpcnt = bf_get(cfg_wqpcnt, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13794 sli4_params->sgl_pp_align = bf_get(cfg_sgl_pp_align, in lpfc_get_sli4_parameters()
13796 phba->sli4_hba.extents_in_use = bf_get(cfg_ext, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13797 phba->sli4_hba.rpi_hdrs_in_use = bf_get(cfg_hdrr, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13798 sli4_params->mi_cap = bf_get(cfg_mi_ver, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13800 /* Check for Extended Pre-Registered SGL support */ in lpfc_get_sli4_parameters()
13801 phba->cfg_xpsgl = bf_get(cfg_xpsgl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13809 sli4_params->nvme = 1; in lpfc_get_sli4_parameters()
13812 if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP) { in lpfc_get_sli4_parameters()
13816 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
13821 sli4_params->nvme = 0; in lpfc_get_sli4_parameters()
13822 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_get_sli4_parameters()
13828 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
13830 phba->nvmet_support = 0; in lpfc_get_sli4_parameters()
13831 phba->cfg_nvmet_mrq = 0; in lpfc_get_sli4_parameters()
13832 phba->cfg_nvme_seg_cnt = 0; in lpfc_get_sli4_parameters()
13835 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_get_sli4_parameters()
13836 return -ENODEV; in lpfc_get_sli4_parameters()
13837 phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; in lpfc_get_sli4_parameters()
13844 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_get_sli4_parameters()
13845 phba->cfg_sg_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_get_sli4_parameters()
13849 phba->cfg_enable_pbde = 1; in lpfc_get_sli4_parameters()
13851 phba->cfg_enable_pbde = 0; in lpfc_get_sli4_parameters()
13856 * In SLI4-Parameters Descriptor: in lpfc_get_sli4_parameters()
13861 if (phba->cfg_suppress_rsp && bf_get(cfg_xib, mbx_sli4_parameters) && in lpfc_get_sli4_parameters()
13863 phba->sli.sli_flag |= LPFC_SLI_SUPPRESS_RSP; in lpfc_get_sli4_parameters()
13865 phba->cfg_suppress_rsp = 0; in lpfc_get_sli4_parameters()
13868 phba->sli.sli_flag |= LPFC_SLI_USE_EQDR; in lpfc_get_sli4_parameters()
13871 if (sli4_params->sge_supp_len > LPFC_MAX_SGE_SIZE) in lpfc_get_sli4_parameters()
13872 sli4_params->sge_supp_len = LPFC_MAX_SGE_SIZE; in lpfc_get_sli4_parameters()
13874 rc = dma_set_max_seg_size(&phba->pcidev->dev, sli4_params->sge_supp_len); in lpfc_get_sli4_parameters()
13884 * to use this option, 128-byte WQEs must be used. in lpfc_get_sli4_parameters()
13887 phba->fcp_embed_io = 1; in lpfc_get_sli4_parameters()
13889 phba->fcp_embed_io = 0; in lpfc_get_sli4_parameters()
13894 phba->cfg_enable_pbde, in lpfc_get_sli4_parameters()
13895 phba->fcp_embed_io, sli4_params->nvme, in lpfc_get_sli4_parameters()
13896 phba->cfg_nvme_embed_cmd, phba->cfg_suppress_rsp); in lpfc_get_sli4_parameters()
13898 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
13900 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
13907 (sli4_params->wqsize & LPFC_WQ_SZ128_SUPPORT)) in lpfc_get_sli4_parameters()
13908 phba->enab_exp_wqcq_pages = 1; in lpfc_get_sli4_parameters()
13910 phba->enab_exp_wqcq_pages = 0; in lpfc_get_sli4_parameters()
13915 phba->mds_diags_support = 1; in lpfc_get_sli4_parameters()
13917 phba->mds_diags_support = 0; in lpfc_get_sli4_parameters()
13923 phba->nsler = 1; in lpfc_get_sli4_parameters()
13925 phba->nsler = 0; in lpfc_get_sli4_parameters()
13931 * lpfc_pci_probe_one_s3 - PCI probe func to reg SLI-3 device to PCI subsystem.
13935 * This routine is to be called to attach a device with SLI-3 interface spec
13936 * to the PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
13937 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
13944 * 0 - driver can claim the device
13945 * negative value - driver can not claim the device
13959 return -ENOMEM; in lpfc_pci_probe_one_s3()
13966 /* Set up SLI API function jump table for PCI-device group-0 HBAs */ in lpfc_pci_probe_one_s3()
13971 /* Set up SLI-3 specific device PCI memory space */ in lpfc_pci_probe_one_s3()
13979 /* Set up SLI-3 specific device driver resources */ in lpfc_pci_probe_one_s3()
14005 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s3()
14016 vport = phba->pport; in lpfc_pci_probe_one_s3()
14026 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s3()
14035 error = -ENODEV; in lpfc_pci_probe_one_s3()
14038 /* SLI-3 HBA setup */ in lpfc_pci_probe_one_s3()
14042 error = -ENODEV; in lpfc_pci_probe_one_s3()
14050 phba->sli.slistat.sli_intr > LPFC_MSIX_VECTORS) { in lpfc_pci_probe_one_s3()
14052 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s3()
14063 cfg_mode = --intr_mode; in lpfc_pci_probe_one_s3()
14099 * lpfc_pci_remove_one_s3 - PCI func to unreg SLI-3 device from PCI subsystem.
14102 * This routine is to be called to disattach a device with SLI-3 interface
14103 * spec from PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
14111 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s3()
14113 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s3()
14116 spin_lock_irq(&phba->hbalock); in lpfc_pci_remove_one_s3()
14117 vport->load_flag |= FC_UNLOADING; in lpfc_pci_remove_one_s3()
14118 spin_unlock_irq(&phba->hbalock); in lpfc_pci_remove_one_s3()
14125 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s3()
14126 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s3()
14128 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s3()
14148 kthread_stop(phba->worker_thread); in lpfc_pci_remove_one_s3()
14152 kfree(phba->vpi_bmask); in lpfc_pci_remove_one_s3()
14153 kfree(phba->vpi_ids); in lpfc_pci_remove_one_s3()
14156 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
14157 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s3()
14158 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
14162 /* Disable SR-IOV if enabled */ in lpfc_pci_remove_one_s3()
14163 if (phba->cfg_sriov_nr_virtfn) in lpfc_pci_remove_one_s3()
14180 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_pci_remove_one_s3()
14181 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_pci_remove_one_s3()
14184 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_pci_remove_one_s3()
14185 phba->slim2p.virt, phba->slim2p.phys); in lpfc_pci_remove_one_s3()
14188 iounmap(phba->ctrl_regs_memmap_p); in lpfc_pci_remove_one_s3()
14189 iounmap(phba->slim_memmap_p); in lpfc_pci_remove_one_s3()
14198 * lpfc_pci_suspend_one_s3 - PCI func to suspend SLI-3 device for power mgmnt
14202 * system Power Management (PM) to device with SLI-3 interface spec. When
14206 * minimum PM requirements to a power-aware driver's PM support for the
14207 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
14214 * 0 - driver suspended the device
14221 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s3()
14229 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s3()
14238 * lpfc_pci_resume_one_s3 - PCI func to resume SLI-3 device for power mgmnt
14242 * system Power Management (PM) to device with SLI-3 interface spec. When PM
14245 * driver implements the minimum PM requirements to a power-aware driver's
14246 * PM for suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE,
14253 * 0 - driver suspended the device
14260 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s3()
14268 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s3()
14269 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s3()
14270 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s3()
14271 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s3()
14283 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
14287 return -EIO; in lpfc_pci_resume_one_s3()
14289 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s3()
14296 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
14302 * lpfc_sli_prep_dev_for_recover - Prepare SLI3 device for pci slot recover
14316 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli_prep_dev_for_recover()
14322 * lpfc_sli_prep_dev_for_reset - Prepare SLI3 device for pci slot reset
14349 pci_disable_device(phba->pcidev); in lpfc_sli_prep_dev_for_reset()
14353 * lpfc_sli_prep_dev_for_perm_failure - Prepare SLI3 dev for pci slot disable
14377 * lpfc_io_error_detected_s3 - Method for handling SLI-3 device PCI I/O error
14382 * device with SLI-3 interface spec. This function is called by the PCI
14390 * PCI_ERS_RESULT_CAN_RECOVER - can be recovered with reset_link
14391 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
14392 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
14398 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s3()
14402 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s3()
14423 * lpfc_io_slot_reset_s3 - Method for restarting PCI SLI-3 device from scratch.
14427 * device with SLI-3 interface spec. This is called after PCI bus has been
14428 * reset to restart the PCI card from scratch, as if from a cold-boot.
14437 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
14438 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
14444 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s3()
14445 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s3()
14448 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s3()
14450 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s3()
14463 if (pdev->is_busmaster) in lpfc_io_slot_reset_s3()
14466 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
14467 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s3()
14468 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
14471 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
14474 "0427 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s3()
14478 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s3()
14486 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
14492 * lpfc_io_resume_s3 - Method for resuming PCI I/O operation on SLI-3 device.
14496 * with SLI-3 interface spec. It is called when kernel error recovery tells
14505 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s3()
14507 /* Bring device online, it will be no-op for non-fatal error resume */ in lpfc_io_resume_s3()
14512 * lpfc_sli4_get_els_iocb_cnt - Calculate the # of ELS IOCBs to reserve
14520 int max_xri = phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_get_els_iocb_cnt()
14522 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli4_get_els_iocb_cnt()
14542 * lpfc_sli4_get_iocb_cnt - Calculate the # of total IOCBs to reserve
14552 if (phba->nvmet_support) in lpfc_sli4_get_iocb_cnt()
14566 sli_family = bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf); in lpfc_log_write_firmware_error()
14584 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
14585 fsize, fw->size); in lpfc_log_write_firmware_error()
14586 rc = -EINVAL; in lpfc_log_write_firmware_error()
14593 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
14594 fsize, fw->size); in lpfc_log_write_firmware_error()
14595 rc = -EACCES; in lpfc_log_write_firmware_error()
14601 offset, phba->pcidev->device, magic_number, in lpfc_log_write_firmware_error()
14602 ftype, fid, fsize, fw->size); in lpfc_log_write_firmware_error()
14603 rc = -EIO; in lpfc_log_write_firmware_error()
14609 * lpfc_write_firmware - attempt to write a firmware image to the port
14626 /* It can be null in no-wait mode, sanity check */ in lpfc_write_firmware()
14628 rc = -ENXIO; in lpfc_write_firmware()
14631 image = (struct lpfc_grp_hdr *)fw->data; in lpfc_write_firmware()
14633 magic_number = be32_to_cpu(image->magic_number); in lpfc_write_firmware()
14636 fsize = be32_to_cpu(image->size); in lpfc_write_firmware()
14640 if (strncmp(fwrev, image->revision, strnlen(image->revision, 16))) { in lpfc_write_firmware()
14644 fwrev, image->revision); in lpfc_write_firmware()
14649 rc = -ENOMEM; in lpfc_write_firmware()
14652 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_write_firmware()
14654 &dmabuf->phys, in lpfc_write_firmware()
14656 if (!dmabuf->virt) { in lpfc_write_firmware()
14658 rc = -ENOMEM; in lpfc_write_firmware()
14661 list_add_tail(&dmabuf->list, &dma_buffer_list); in lpfc_write_firmware()
14663 while (offset < fw->size) { in lpfc_write_firmware()
14666 if (temp_offset + SLI4_PAGE_SIZE > fw->size) { in lpfc_write_firmware()
14667 memcpy(dmabuf->virt, in lpfc_write_firmware()
14668 fw->data + temp_offset, in lpfc_write_firmware()
14669 fw->size - temp_offset); in lpfc_write_firmware()
14670 temp_offset = fw->size; in lpfc_write_firmware()
14673 memcpy(dmabuf->virt, fw->data + temp_offset, in lpfc_write_firmware()
14678 (fw->size - offset), &offset); in lpfc_write_firmware()
14694 fwrev, image->revision); in lpfc_write_firmware()
14698 list_del(&dmabuf->list); in lpfc_write_firmware()
14699 dma_free_coherent(&phba->pcidev->dev, SLI4_PAGE_SIZE, in lpfc_write_firmware()
14700 dmabuf->virt, dmabuf->phys); in lpfc_write_firmware()
14714 * lpfc_sli4_request_firmware_update - Request linux generic firmware upgrade
14729 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_request_firmware_update()
14731 return -EPERM; in lpfc_sli4_request_firmware_update()
14733 scnprintf(file_name, sizeof(file_name), "%s.grp", phba->ModelName); in lpfc_sli4_request_firmware_update()
14737 file_name, &phba->pcidev->dev, in lpfc_sli4_request_firmware_update()
14741 ret = request_firmware(&fw, file_name, &phba->pcidev->dev); in lpfc_sli4_request_firmware_update()
14745 ret = -EINVAL; in lpfc_sli4_request_firmware_update()
14752 * lpfc_pci_probe_one_s4 - PCI probe func to reg SLI-4 device to PCI subsys
14757 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
14758 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
14766 * 0 - driver can claim the device
14767 * negative value - driver can not claim the device
14781 return -ENOMEM; in lpfc_pci_probe_one_s4()
14783 INIT_LIST_HEAD(&phba->poll_list); in lpfc_pci_probe_one_s4()
14790 /* Set up SLI API function jump table for PCI-device group-1 HBAs */ in lpfc_pci_probe_one_s4()
14795 /* Set up SLI-4 specific device PCI memory space */ in lpfc_pci_probe_one_s4()
14803 /* Set up SLI-4 Specific device driver resources */ in lpfc_pci_probe_one_s4()
14811 INIT_LIST_HEAD(&phba->active_rrq_list); in lpfc_pci_probe_one_s4()
14812 INIT_LIST_HEAD(&phba->fcf.fcf_pri_list); in lpfc_pci_probe_one_s4()
14823 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s4()
14826 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s4()
14829 phba->pport = NULL; in lpfc_pci_probe_one_s4()
14843 error = -ENODEV; in lpfc_pci_probe_one_s4()
14846 /* Default to single EQ for non-MSI-X */ in lpfc_pci_probe_one_s4()
14847 if (phba->intr_type != MSIX) { in lpfc_pci_probe_one_s4()
14848 phba->cfg_irq_chann = 1; in lpfc_pci_probe_one_s4()
14849 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
14850 if (phba->nvmet_support) in lpfc_pci_probe_one_s4()
14851 phba->cfg_nvmet_mrq = 1; in lpfc_pci_probe_one_s4()
14854 lpfc_cpu_affinity_check(phba, phba->cfg_irq_chann); in lpfc_pci_probe_one_s4()
14863 vport = phba->pport; in lpfc_pci_probe_one_s4()
14874 /* Set up SLI-4 HBA */ in lpfc_pci_probe_one_s4()
14878 error = -ENODEV; in lpfc_pci_probe_one_s4()
14883 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s4()
14892 if (phba->nvmet_support == 0) { in lpfc_pci_probe_one_s4()
14893 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
14910 if (phba->cfg_request_firmware_upgrade) in lpfc_pci_probe_one_s4()
14916 timer_setup(&phba->cpuhp_poll_timer, lpfc_sli4_poll_hbtimer, 0); in lpfc_pci_probe_one_s4()
14917 cpuhp_state_add_instance_nocalls(lpfc_cpuhp_state, &phba->cpuhp); in lpfc_pci_probe_one_s4()
14943 * lpfc_pci_remove_one_s4 - PCI func to unreg SLI-4 device from PCI subsystem
14947 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
14955 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s4()
14957 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s4()
14961 spin_lock_irq(&phba->hbalock); in lpfc_pci_remove_one_s4()
14962 vport->load_flag |= FC_UNLOADING; in lpfc_pci_remove_one_s4()
14963 spin_unlock_irq(&phba->hbalock); in lpfc_pci_remove_one_s4()
14964 if (phba->cgn_i) in lpfc_pci_remove_one_s4()
14972 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s4()
14973 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s4()
14975 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s4()
14990 /* De-allocate multi-XRI pools */ in lpfc_pci_remove_one_s4()
14991 if (phba->cfg_xri_rebalancing) in lpfc_pci_remove_one_s4()
15002 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
15003 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s4()
15004 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
15030 * lpfc_pci_suspend_one_s4 - PCI func to suspend SLI-4 device for power mgmnt
15034 * Power Management (PM) to device with SLI-4 interface spec. When PM invokes
15038 * requirements to a power-aware driver's PM support for suspend/resume -- all
15046 * 0 - driver suspended the device
15053 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s4()
15061 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s4()
15071 * lpfc_pci_resume_one_s4 - PCI func to resume SLI-4 device for power mgmnt
15075 * Power Management (PM) to device with SLI-4 interface spac. When PM invokes
15078 * implements the minimum PM requirements to a power-aware driver's PM for
15079 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
15086 * 0 - driver suspended the device
15093 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s4()
15101 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s4()
15102 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s4()
15103 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s4()
15104 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s4()
15112 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
15116 return -EIO; in lpfc_pci_resume_one_s4()
15118 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s4()
15125 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
15131 * lpfc_sli4_prep_dev_for_recover - Prepare SLI4 device for pci slot recover
15144 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli4_prep_dev_for_recover()
15150 * lpfc_sli4_prep_dev_for_reset - Prepare SLI4 device for pci slot reset
15160 int offline = pci_channel_offline(phba->pcidev); in lpfc_sli4_prep_dev_for_reset()
15182 pci_disable_device(phba->pcidev); in lpfc_sli4_prep_dev_for_reset()
15186 * lpfc_sli4_prep_dev_for_perm_failure - Prepare SLI4 dev for pci slot disable
15210 * lpfc_io_error_detected_s4 - Method for handling PCI I/O error to SLI-4 device
15215 * with SLI-4 interface spec. This function is called by the PCI subsystem
15222 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
15223 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15229 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s4()
15234 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s4()
15238 hba_pci_err = test_and_set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15248 set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15253 hba_pci_err = test_and_set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15265 * lpfc_io_slot_reset_s4 - Method for restart PCI SLI-4 device from scratch
15269 * with SLI-4 interface spec. It is called after PCI bus has been reset to
15270 * restart the PCI card from scratch, as if from a cold-boot. During the
15279 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
15280 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15286 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s4()
15287 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s4()
15291 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s4()
15293 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s4()
15300 hba_pci_err = test_and_clear_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_slot_reset_s4()
15302 dev_info(&pdev->dev, in lpfc_io_slot_reset_s4()
15310 if (pdev->is_busmaster) in lpfc_io_slot_reset_s4()
15313 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
15314 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s4()
15315 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
15320 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
15323 "2824 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s4()
15327 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s4()
15328 lpfc_cpu_affinity_check(phba, phba->cfg_irq_chann); in lpfc_io_slot_reset_s4()
15331 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
15337 * lpfc_io_resume_s4 - Method for resuming PCI I/O operation to SLI-4 device
15341 * with SLI-4 interface spec. It is called when kernel error recovery tells
15350 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s4()
15358 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) { in lpfc_io_resume_s4()
15367 * lpfc_pci_probe_one - lpfc PCI probe func to reg dev to PCI subsystem
15373 * at PCI device-specific information of the device and driver to see if the
15376 * the action to the proper SLI-3 or SLI-4 device probing routine, which will
15381 * 0 - driver can claim the device
15382 * negative value - driver can not claim the device
15391 return -ENODEV; in lpfc_pci_probe_one()
15403 * lpfc_pci_remove_one - lpfc PCI func to unreg dev from PCI subsystem
15408 * This routine dispatches the action to the proper SLI-3 or SLI-4 device
15416 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_remove_one()
15418 switch (phba->pci_dev_grp) { in lpfc_pci_remove_one()
15428 phba->pci_dev_grp); in lpfc_pci_remove_one()
15435 * lpfc_pci_suspend_one - lpfc PCI func to suspend dev for power management
15440 * the action to the proper SLI-3 or SLI-4 device suspend routine, which will
15444 * 0 - driver suspended the device
15451 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one()
15452 int rc = -ENODEV; in lpfc_pci_suspend_one()
15454 switch (phba->pci_dev_grp) { in lpfc_pci_suspend_one()
15464 phba->pci_dev_grp); in lpfc_pci_suspend_one()
15471 * lpfc_pci_resume_one - lpfc PCI func to resume dev for power management
15476 * the action to the proper SLI-3 or SLI-4 device resume routine, which will
15480 * 0 - driver suspended the device
15487 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one()
15488 int rc = -ENODEV; in lpfc_pci_resume_one()
15490 switch (phba->pci_dev_grp) { in lpfc_pci_resume_one()
15500 phba->pci_dev_grp); in lpfc_pci_resume_one()
15507 * lpfc_io_error_detected - lpfc method for handling PCI I/O error
15514 * the action to the proper SLI-3 or SLI-4 device error detected handling
15518 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
15519 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15525 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected()
15528 if (phba->link_state == LPFC_HBA_ERROR && in lpfc_io_error_detected()
15529 phba->hba_flag & HBA_IOQ_FLUSH) in lpfc_io_error_detected()
15532 switch (phba->pci_dev_grp) { in lpfc_io_error_detected()
15542 phba->pci_dev_grp); in lpfc_io_error_detected()
15549 * lpfc_io_slot_reset - lpfc method for restart PCI dev from scratch
15554 * from scratch, as if from a cold-boot. When this routine is invoked, it
15555 * dispatches the action to the proper SLI-3 or SLI-4 device reset handling
15559 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
15560 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15566 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset()
15569 switch (phba->pci_dev_grp) { in lpfc_io_slot_reset()
15579 phba->pci_dev_grp); in lpfc_io_slot_reset()
15586 * lpfc_io_resume - lpfc method for resuming PCI I/O operation
15592 * this routine is invoked, it dispatches the action to the proper SLI-3
15593 * or SLI-4 device io_resume routine, which will resume the device operation.
15599 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume()
15601 switch (phba->pci_dev_grp) { in lpfc_io_resume()
15611 phba->pci_dev_grp); in lpfc_io_resume()
15618 * lpfc_sli4_oas_verify - Verify OAS is supported by this adapter
15631 if (!phba->cfg_EnableXLane) in lpfc_sli4_oas_verify()
15634 if (phba->sli4_hba.pc_sli4_params.oas_supported) { in lpfc_sli4_oas_verify()
15635 phba->cfg_fof = 1; in lpfc_sli4_oas_verify()
15637 phba->cfg_fof = 0; in lpfc_sli4_oas_verify()
15638 mempool_destroy(phba->device_data_mem_pool); in lpfc_sli4_oas_verify()
15639 phba->device_data_mem_pool = NULL; in lpfc_sli4_oas_verify()
15646 * lpfc_sli4_ras_init - Verify RAS-FW log is supported by this adapter
15656 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_ras_init()
15658 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_sli4_ras_init()
15660 phba->ras_fwlog.ras_hwsupport = true; in lpfc_sli4_ras_init()
15661 if (phba->cfg_ras_fwlog_func == PCI_FUNC(phba->pcidev->devfn) && in lpfc_sli4_ras_init()
15662 phba->cfg_ras_fwlog_buffsize) in lpfc_sli4_ras_init()
15663 phba->ras_fwlog.ras_enabled = true; in lpfc_sli4_ras_init()
15665 phba->ras_fwlog.ras_enabled = false; in lpfc_sli4_ras_init()
15667 phba->ras_fwlog.ras_hwsupport = false; in lpfc_sli4_ras_init()
15705 * lpfc_init - lpfc module initialization routine
15712 * 0 - successful
15713 * -ENOMEM - FC attach transport failed
15714 * all others - failed
15729 error = -ENOMEM; in lpfc_init()
15783 if (atomic_cmpxchg(&phba->dbg_log_dmping, 0, 1) != 0) in lpfc_dmp_dbg()
15786 start_idx = (unsigned int)atomic_read(&phba->dbg_log_idx) % DBG_LOG_SZ; in lpfc_dmp_dbg()
15787 dbg_cnt = (unsigned int)atomic_read(&phba->dbg_log_cnt); in lpfc_dmp_dbg()
15793 temp_idx -= 1; in lpfc_dmp_dbg()
15795 if ((start_idx + dbg_cnt) > (DBG_LOG_SZ - 1)) { in lpfc_dmp_dbg()
15799 start_idx = DBG_LOG_SZ - (dbg_cnt - start_idx); in lpfc_dmp_dbg()
15801 start_idx -= dbg_cnt; in lpfc_dmp_dbg()
15804 dev_info(&phba->pcidev->dev, "start %d end %d cnt %d\n", in lpfc_dmp_dbg()
15812 rem_nsec = do_div(phba->dbg_log[temp_idx].t_ns, NSEC_PER_SEC); in lpfc_dmp_dbg()
15813 dev_info(&phba->pcidev->dev, "%d: [%5lu.%06lu] %s", in lpfc_dmp_dbg()
15815 (unsigned long)phba->dbg_log[temp_idx].t_ns, in lpfc_dmp_dbg()
15817 phba->dbg_log[temp_idx].log); in lpfc_dmp_dbg()
15820 atomic_set(&phba->dbg_log_cnt, 0); in lpfc_dmp_dbg()
15821 atomic_set(&phba->dbg_log_dmping, 0); in lpfc_dmp_dbg()
15829 int dbg_dmping = atomic_read(&phba->dbg_log_dmping); in lpfc_dbg_print()
15837 dev_info(&phba->pcidev->dev, "%pV", &vaf); in lpfc_dbg_print()
15841 idx = (unsigned int)atomic_fetch_add(1, &phba->dbg_log_idx) % in lpfc_dbg_print()
15844 atomic_inc(&phba->dbg_log_cnt); in lpfc_dbg_print()
15846 vscnprintf(phba->dbg_log[idx].log, in lpfc_dbg_print()
15847 sizeof(phba->dbg_log[idx].log), fmt, args); in lpfc_dbg_print()
15850 phba->dbg_log[idx].t_ns = local_clock(); in lpfc_dbg_print()
15854 * lpfc_exit - lpfc module removal routine