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->ras_fwlog_lock); in lpfc_setup_driver_resource_phase1()
7705 spin_lock_init(&phba->scsi_buf_list_get_lock); in lpfc_setup_driver_resource_phase1()
7706 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_get); in lpfc_setup_driver_resource_phase1()
7707 spin_lock_init(&phba->scsi_buf_list_put_lock); in lpfc_setup_driver_resource_phase1()
7708 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_put); in lpfc_setup_driver_resource_phase1()
7711 INIT_LIST_HEAD(&phba->fabric_iocb_list); in lpfc_setup_driver_resource_phase1()
7714 INIT_LIST_HEAD(&phba->elsbuf); in lpfc_setup_driver_resource_phase1()
7717 INIT_LIST_HEAD(&phba->fcf_conn_rec_list); in lpfc_setup_driver_resource_phase1()
7720 spin_lock_init(&phba->devicelock); in lpfc_setup_driver_resource_phase1()
7721 INIT_LIST_HEAD(&phba->luns); in lpfc_setup_driver_resource_phase1()
7724 timer_setup(&psli->mbox_tmo, lpfc_mbox_timeout, 0); in lpfc_setup_driver_resource_phase1()
7726 timer_setup(&phba->fabric_block_timer, lpfc_fabric_block_timeout, 0); in lpfc_setup_driver_resource_phase1()
7728 timer_setup(&phba->eratt_poll, lpfc_poll_eratt, 0); in lpfc_setup_driver_resource_phase1()
7730 timer_setup(&phba->hb_tmofunc, lpfc_hb_timeout, 0); in lpfc_setup_driver_resource_phase1()
7732 INIT_DELAYED_WORK(&phba->eq_delay_work, lpfc_hb_eq_delay_work); in lpfc_setup_driver_resource_phase1()
7734 INIT_DELAYED_WORK(&phba->idle_stat_delay_work, in lpfc_setup_driver_resource_phase1()
7736 INIT_WORK(&phba->unblock_request_work, lpfc_unblock_requests_work); in lpfc_setup_driver_resource_phase1()
7741 * lpfc_sli_driver_resource_setup - Setup driver internal resources for SLI3 dev
7745 * support the SLI-3 HBA device it attached to.
7748 * 0 - successful
7749 * other values - error
7761 timer_setup(&phba->fcp_poll_timer, lpfc_poll_timeout, 0); in lpfc_sli_driver_resource_setup()
7764 phba->work_ha_mask = (HA_ERATT | HA_MBATT | HA_LATT); in lpfc_sli_driver_resource_setup()
7765 phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING * 4)); in lpfc_sli_driver_resource_setup()
7769 /* Set up phase-1 common device driver resources */ in lpfc_sli_driver_resource_setup()
7773 return -ENODEV; in lpfc_sli_driver_resource_setup()
7775 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
7776 phba->sli.sli3_ring = kcalloc(LPFC_SLI3_MAX_RING, in lpfc_sli_driver_resource_setup()
7779 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
7780 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7787 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_driver_resource_setup()
7793 if (phba->cfg_enable_bg) { in lpfc_sli_driver_resource_setup()
7795 * The scsi_buf for a T10-DIF I/O will hold the FCP cmnd, in lpfc_sli_driver_resource_setup()
7803 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
7807 if (phba->cfg_sg_seg_cnt > LPFC_MAX_SG_SEG_CNT_DIF) in lpfc_sli_driver_resource_setup()
7808 phba->cfg_sg_seg_cnt = LPFC_MAX_SG_SEG_CNT_DIF; in lpfc_sli_driver_resource_setup()
7811 phba->cfg_total_seg_cnt = LPFC_MAX_SG_SEG_CNT; in lpfc_sli_driver_resource_setup()
7818 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
7820 ((phba->cfg_sg_seg_cnt + 2) * entry_sz); in lpfc_sli_driver_resource_setup()
7823 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + 2; in lpfc_sli_driver_resource_setup()
7828 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
7829 phba->cfg_total_seg_cnt); in lpfc_sli_driver_resource_setup()
7831 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli_driver_resource_setup()
7833 phba->max_vports = 0; in lpfc_sli_driver_resource_setup()
7843 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7845 phba->lpfc_sg_dma_buf_pool = in lpfc_sli_driver_resource_setup()
7847 &phba->pcidev->dev, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
7850 if (!phba->lpfc_sg_dma_buf_pool) in lpfc_sli_driver_resource_setup()
7853 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli_driver_resource_setup()
7855 &phba->pcidev->dev, in lpfc_sli_driver_resource_setup()
7860 if (!phba->lpfc_cmd_rsp_buf_pool) in lpfc_sli_driver_resource_setup()
7864 * Enable sr-iov virtual functions if supported and configured in lpfc_sli_driver_resource_setup()
7867 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli_driver_resource_setup()
7869 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
7872 "2808 Requested number of SR-IOV " in lpfc_sli_driver_resource_setup()
7875 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
7876 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli_driver_resource_setup()
7883 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli_driver_resource_setup()
7884 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli_driver_resource_setup()
7887 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7891 * lpfc_sli_driver_resource_unset - Unset drvr internal resources for SLI3 dev
7895 * specific for supporting the SLI-3 HBA device it attached to.
7907 * lpfc_sli4_driver_resource_setup - Setup drvr internal resources for SLI4 dev
7911 * support the SLI-4 HBA device it attached to.
7914 * 0 - successful
7915 * other values - error
7929 phba->sli4_hba.num_present_cpu = lpfc_present_cpu; in lpfc_sli4_driver_resource_setup()
7930 phba->sli4_hba.num_possible_cpu = cpumask_last(cpu_possible_mask) + 1; in lpfc_sli4_driver_resource_setup()
7931 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_setup()
7936 /* Set up phase-1 common device driver resources */ in lpfc_sli4_driver_resource_setup()
7939 return -ENODEV; in lpfc_sli4_driver_resource_setup()
7944 return -ENODEV; in lpfc_sli4_driver_resource_setup()
7949 phba->wq = alloc_workqueue("lpfc_wq", WQ_MEM_RECLAIM, 0); in lpfc_sli4_driver_resource_setup()
7950 if (!phba->wq) in lpfc_sli4_driver_resource_setup()
7951 return -ENOMEM; in lpfc_sli4_driver_resource_setup()
7957 timer_setup(&phba->rrq_tmr, lpfc_rrq_timeout, 0); in lpfc_sli4_driver_resource_setup()
7960 timer_setup(&phba->fcf.redisc_wait, lpfc_sli4_fcf_redisc_wait_tmo, 0); in lpfc_sli4_driver_resource_setup()
7963 hrtimer_init(&phba->cmf_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in lpfc_sli4_driver_resource_setup()
7964 phba->cmf_timer.function = lpfc_cmf_timer; in lpfc_sli4_driver_resource_setup()
7966 hrtimer_init(&phba->cmf_stats_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in lpfc_sli4_driver_resource_setup()
7967 phba->cmf_stats_timer.function = lpfc_cmf_stats_timer; in lpfc_sli4_driver_resource_setup()
7970 * Control structure for handling external multi-buffer mailbox in lpfc_sli4_driver_resource_setup()
7971 * command pass-through. in lpfc_sli4_driver_resource_setup()
7973 memset((uint8_t *)&phba->mbox_ext_buf_ctx, 0, in lpfc_sli4_driver_resource_setup()
7975 INIT_LIST_HEAD(&phba->mbox_ext_buf_ctx.ext_dmabuf_list); in lpfc_sli4_driver_resource_setup()
7977 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli4_driver_resource_setup()
7980 phba->max_vports = 0; in lpfc_sli4_driver_resource_setup()
7983 phba->valid_vlan = 0; in lpfc_sli4_driver_resource_setup()
7984 phba->fc_map[0] = LPFC_FCOE_FCF_MAP0; in lpfc_sli4_driver_resource_setup()
7985 phba->fc_map[1] = LPFC_FCOE_FCF_MAP1; in lpfc_sli4_driver_resource_setup()
7986 phba->fc_map[2] = LPFC_FCOE_FCF_MAP2; in lpfc_sli4_driver_resource_setup()
7995 INIT_LIST_HEAD(&phba->hbqs[LPFC_ELS_HBQ].hbq_buffer_list); in lpfc_sli4_driver_resource_setup()
7996 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_sli4_rb_alloc; in lpfc_sli4_driver_resource_setup()
7997 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_sli4_rb_free; in lpfc_sli4_driver_resource_setup()
8001 timer_setup(&phba->inactive_vmid_poll, lpfc_vmid_poll, 0); in lpfc_sli4_driver_resource_setup()
8007 spin_lock_init(&phba->sli4_hba.abts_io_buf_list_lock); in lpfc_sli4_driver_resource_setup()
8008 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_io_buf_list); in lpfc_sli4_driver_resource_setup()
8010 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
8012 spin_lock_init(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_sli4_driver_resource_setup()
8013 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_driver_resource_setup()
8014 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_io_wait_list); in lpfc_sli4_driver_resource_setup()
8015 spin_lock_init(&phba->sli4_hba.t_active_list_lock); in lpfc_sli4_driver_resource_setup()
8016 INIT_LIST_HEAD(&phba->sli4_hba.t_active_ctx_list); in lpfc_sli4_driver_resource_setup()
8020 spin_lock_init(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_driver_resource_setup()
8021 spin_lock_init(&phba->sli4_hba.nvmet_io_wait_lock); in lpfc_sli4_driver_resource_setup()
8022 spin_lock_init(&phba->sli4_hba.asynce_list_lock); in lpfc_sli4_driver_resource_setup()
8023 spin_lock_init(&phba->sli4_hba.els_xri_abrt_list_lock); in lpfc_sli4_driver_resource_setup()
8026 * Initialize driver internal slow-path work queues in lpfc_sli4_driver_resource_setup()
8029 /* Driver internel slow-path CQ Event pool */ in lpfc_sli4_driver_resource_setup()
8030 INIT_LIST_HEAD(&phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_driver_resource_setup()
8032 INIT_LIST_HEAD(&phba->sli4_hba.sp_queue_event); in lpfc_sli4_driver_resource_setup()
8034 INIT_LIST_HEAD(&phba->sli4_hba.sp_asynce_work_queue); in lpfc_sli4_driver_resource_setup()
8035 /* Slow-path XRI aborted CQ Event work queue list */ in lpfc_sli4_driver_resource_setup()
8036 INIT_LIST_HEAD(&phba->sli4_hba.sp_els_xri_aborted_work_queue); in lpfc_sli4_driver_resource_setup()
8038 INIT_LIST_HEAD(&phba->sli4_hba.sp_unsol_work_queue); in lpfc_sli4_driver_resource_setup()
8041 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_blk_list); in lpfc_sli4_driver_resource_setup()
8042 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_xri_blk_list); in lpfc_sli4_driver_resource_setup()
8043 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_vfi_blk_list); in lpfc_sli4_driver_resource_setup()
8044 INIT_LIST_HEAD(&phba->lpfc_vpi_blk_list); in lpfc_sli4_driver_resource_setup()
8049 INIT_LIST_HEAD(&phba->sli.mboxq); in lpfc_sli4_driver_resource_setup()
8050 INIT_LIST_HEAD(&phba->sli.mboxq_cmpl); in lpfc_sli4_driver_resource_setup()
8053 phba->sli4_hba.lnk_info.optic_state = 0xff; in lpfc_sli4_driver_resource_setup()
8061 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_driver_resource_setup()
8065 rc = -ENODEV; in lpfc_sli4_driver_resource_setup()
8068 phba->temp_sensor_support = 1; in lpfc_sli4_driver_resource_setup()
8086 if (phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_CONFIG) { in lpfc_sli4_driver_resource_setup()
8087 /* Right now the link is down, if FA-PWWN is configured the in lpfc_sli4_driver_resource_setup()
8094 phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_FABRIC; in lpfc_sli4_driver_resource_setup()
8102 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_driver_resource_setup()
8109 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_sli4_driver_resource_setup()
8112 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8117 phba->nvmet_support = 0; in lpfc_sli4_driver_resource_setup()
8128 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_driver_resource_setup()
8129 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_driver_resource_setup()
8130 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8131 rc = -EIO; in lpfc_sli4_driver_resource_setup()
8134 mb = &mboxq->u.mb; in lpfc_sli4_driver_resource_setup()
8135 memcpy(&wwn, (char *)mb->un.varRDnvp.nodename, in lpfc_sli4_driver_resource_setup()
8138 phba->sli4_hba.wwnn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
8139 memcpy(&wwn, (char *)mb->un.varRDnvp.portname, in lpfc_sli4_driver_resource_setup()
8143 phba->sli4_hba.wwpn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
8152 phba->nvmet_support = 1; /* a match */ in lpfc_sli4_driver_resource_setup()
8166 phba->cfg_xri_rebalancing = 0; in lpfc_sli4_driver_resource_setup()
8167 if (phba->irq_chann_mode == NHT_MODE) { in lpfc_sli4_driver_resource_setup()
8168 phba->cfg_irq_chann = in lpfc_sli4_driver_resource_setup()
8169 phba->sli4_hba.num_present_cpu; in lpfc_sli4_driver_resource_setup()
8170 phba->cfg_hdw_queue = in lpfc_sli4_driver_resource_setup()
8171 phba->sli4_hba.num_present_cpu; in lpfc_sli4_driver_resource_setup()
8172 phba->irq_chann_mode = NORMAL_MODE; in lpfc_sli4_driver_resource_setup()
8189 &phba->sli4_hba.sli_intf); in lpfc_sli4_driver_resource_setup()
8191 &phba->sli4_hba.sli_intf); in lpfc_sli4_driver_resource_setup()
8192 if (phba->sli4_hba.extents_in_use && in lpfc_sli4_driver_resource_setup()
8193 phba->sli4_hba.rpi_hdrs_in_use) { in lpfc_sli4_driver_resource_setup()
8199 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8200 rc = -EIO; in lpfc_sli4_driver_resource_setup()
8206 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8207 rc = -EIO; in lpfc_sli4_driver_resource_setup()
8217 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_driver_resource_setup()
8231 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) { in lpfc_sli4_driver_resource_setup()
8235 * The scsi_buf for a T10-DIF I/O holds the FCP cmnd, in lpfc_sli4_driver_resource_setup()
8243 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli4_driver_resource_setup()
8247 phba->cfg_total_seg_cnt = LPFC_MAX_SGL_SEG_CNT; in lpfc_sli4_driver_resource_setup()
8253 if (phba->cfg_enable_bg && in lpfc_sli4_driver_resource_setup()
8254 phba->cfg_sg_seg_cnt > LPFC_MAX_BG_SLI4_SEG_CNT_DIF) in lpfc_sli4_driver_resource_setup()
8255 phba->cfg_scsi_seg_cnt = LPFC_MAX_BG_SLI4_SEG_CNT_DIF; in lpfc_sli4_driver_resource_setup()
8257 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8265 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli4_driver_resource_setup()
8267 ((phba->cfg_sg_seg_cnt + extra) * in lpfc_sli4_driver_resource_setup()
8271 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + extra; in lpfc_sli4_driver_resource_setup()
8272 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8275 * NOTE: if (phba->cfg_sg_seg_cnt + extra) <= 256 we only in lpfc_sli4_driver_resource_setup()
8280 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_driver_resource_setup()
8281 phba->cfg_sg_dma_buf_size = LPFC_DEFAULT_XPSGL_SIZE; in lpfc_sli4_driver_resource_setup()
8282 else if (phba->cfg_sg_dma_buf_size <= LPFC_MIN_SG_SLI4_BUF_SZ) in lpfc_sli4_driver_resource_setup()
8283 phba->cfg_sg_dma_buf_size = LPFC_MIN_SG_SLI4_BUF_SZ; in lpfc_sli4_driver_resource_setup()
8285 phba->cfg_sg_dma_buf_size = in lpfc_sli4_driver_resource_setup()
8286 SLI4_PAGE_ALIGN(phba->cfg_sg_dma_buf_size); in lpfc_sli4_driver_resource_setup()
8288 phba->border_sge_num = phba->cfg_sg_dma_buf_size / in lpfc_sli4_driver_resource_setup()
8292 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
8293 if (phba->cfg_sg_seg_cnt > LPFC_MAX_NVME_SEG_CNT) { in lpfc_sli4_driver_resource_setup()
8298 phba->cfg_nvme_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_sli4_driver_resource_setup()
8300 phba->cfg_nvme_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8306 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
8307 phba->cfg_total_seg_cnt, phba->cfg_scsi_seg_cnt, in lpfc_sli4_driver_resource_setup()
8308 phba->cfg_nvme_seg_cnt); in lpfc_sli4_driver_resource_setup()
8310 if (phba->cfg_sg_dma_buf_size < SLI4_PAGE_SIZE) in lpfc_sli4_driver_resource_setup()
8311 i = phba->cfg_sg_dma_buf_size; in lpfc_sli4_driver_resource_setup()
8315 phba->lpfc_sg_dma_buf_pool = in lpfc_sli4_driver_resource_setup()
8317 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
8318 phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
8320 if (!phba->lpfc_sg_dma_buf_pool) { in lpfc_sli4_driver_resource_setup()
8321 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8325 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli4_driver_resource_setup()
8327 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
8331 if (!phba->lpfc_cmd_rsp_buf_pool) { in lpfc_sli4_driver_resource_setup()
8332 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8336 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8372 longs = (LPFC_SLI4_FCF_TBL_INDX_MAX + BITS_PER_LONG - 1)/BITS_PER_LONG; in lpfc_sli4_driver_resource_setup()
8373 phba->fcf.fcf_rr_bmask = kcalloc(longs, sizeof(unsigned long), in lpfc_sli4_driver_resource_setup()
8375 if (!phba->fcf.fcf_rr_bmask) { in lpfc_sli4_driver_resource_setup()
8379 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8383 phba->sli4_hba.hba_eq_hdl = kcalloc(phba->cfg_irq_chann, in lpfc_sli4_driver_resource_setup()
8386 if (!phba->sli4_hba.hba_eq_hdl) { in lpfc_sli4_driver_resource_setup()
8389 "fast-path per-EQ handle array\n"); in lpfc_sli4_driver_resource_setup()
8390 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8394 phba->sli4_hba.cpu_map = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
8397 if (!phba->sli4_hba.cpu_map) { in lpfc_sli4_driver_resource_setup()
8399 "3327 Failed allocate memory for msi-x " in lpfc_sli4_driver_resource_setup()
8401 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8405 phba->sli4_hba.eq_info = alloc_percpu(struct lpfc_eq_intr_info); in lpfc_sli4_driver_resource_setup()
8406 if (!phba->sli4_hba.eq_info) { in lpfc_sli4_driver_resource_setup()
8409 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8413 phba->sli4_hba.idle_stat = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
8414 sizeof(*phba->sli4_hba.idle_stat), in lpfc_sli4_driver_resource_setup()
8416 if (!phba->sli4_hba.idle_stat) { in lpfc_sli4_driver_resource_setup()
8419 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8424 phba->sli4_hba.c_stat = alloc_percpu(struct lpfc_hdwq_stat); in lpfc_sli4_driver_resource_setup()
8425 if (!phba->sli4_hba.c_stat) { in lpfc_sli4_driver_resource_setup()
8427 "3332 Failed allocating per cpu hdwq stats\n"); in lpfc_sli4_driver_resource_setup()
8428 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8433 phba->cmf_stat = alloc_percpu(struct lpfc_cgn_stat); in lpfc_sli4_driver_resource_setup()
8434 if (!phba->cmf_stat) { in lpfc_sli4_driver_resource_setup()
8436 "3331 Failed allocating per cpu cgn stats\n"); in lpfc_sli4_driver_resource_setup()
8437 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8442 * Enable sr-iov virtual functions if supported and configured in lpfc_sli4_driver_resource_setup()
8445 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli4_driver_resource_setup()
8447 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
8450 "3020 Requested number of SR-IOV " in lpfc_sli4_driver_resource_setup()
8453 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
8454 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli4_driver_resource_setup()
8462 free_percpu(phba->sli4_hba.c_stat); in lpfc_sli4_driver_resource_setup()
8465 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_setup()
8467 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_setup()
8469 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_setup()
8471 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_setup()
8473 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_setup()
8481 dma_pool_destroy(phba->lpfc_cmd_rsp_buf_pool); in lpfc_sli4_driver_resource_setup()
8482 phba->lpfc_cmd_rsp_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
8484 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli4_driver_resource_setup()
8485 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
8491 destroy_workqueue(phba->wq); in lpfc_sli4_driver_resource_setup()
8492 phba->wq = NULL; in lpfc_sli4_driver_resource_setup()
8497 * lpfc_sli4_driver_resource_unset - Unset drvr internal resources for SLI4 dev
8501 * specific for supporting the SLI-4 HBA device it attached to.
8508 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_unset()
8510 free_percpu(phba->sli4_hba.c_stat); in lpfc_sli4_driver_resource_unset()
8512 free_percpu(phba->cmf_stat); in lpfc_sli4_driver_resource_unset()
8513 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_unset()
8515 /* Free memory allocated for msi-x interrupt vector to CPU mapping */ in lpfc_sli4_driver_resource_unset()
8516 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_unset()
8517 phba->sli4_hba.num_possible_cpu = 0; in lpfc_sli4_driver_resource_unset()
8518 phba->sli4_hba.num_present_cpu = 0; in lpfc_sli4_driver_resource_unset()
8519 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_unset()
8520 cpumask_clear(&phba->sli4_hba.irq_aff_mask); in lpfc_sli4_driver_resource_unset()
8522 /* Free memory allocated for fast-path work queue handles */ in lpfc_sli4_driver_resource_unset()
8523 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_unset()
8530 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_unset()
8552 &phba->fcf_conn_rec_list, list) { in lpfc_sli4_driver_resource_unset()
8553 list_del_init(&conn_entry->list); in lpfc_sli4_driver_resource_unset()
8561 * lpfc_init_api_table_setup - Set up init api function jump table
8563 * @dev_grp: The HBA PCI-Device group number.
8568 * Returns: 0 - success, -ENODEV - failure.
8573 phba->lpfc_hba_init_link = lpfc_hba_init_link; in lpfc_init_api_table_setup()
8574 phba->lpfc_hba_down_link = lpfc_hba_down_link; in lpfc_init_api_table_setup()
8575 phba->lpfc_selective_reset = lpfc_selective_reset; in lpfc_init_api_table_setup()
8578 phba->lpfc_hba_down_post = lpfc_hba_down_post_s3; in lpfc_init_api_table_setup()
8579 phba->lpfc_handle_eratt = lpfc_handle_eratt_s3; in lpfc_init_api_table_setup()
8580 phba->lpfc_stop_port = lpfc_stop_port_s3; in lpfc_init_api_table_setup()
8583 phba->lpfc_hba_down_post = lpfc_hba_down_post_s4; in lpfc_init_api_table_setup()
8584 phba->lpfc_handle_eratt = lpfc_handle_eratt_s4; in lpfc_init_api_table_setup()
8585 phba->lpfc_stop_port = lpfc_stop_port_s4; in lpfc_init_api_table_setup()
8589 "1431 Invalid HBA PCI-device group: 0x%x\n", in lpfc_init_api_table_setup()
8591 return -ENODEV; in lpfc_init_api_table_setup()
8597 * lpfc_setup_driver_resource_phase2 - Phase2 setup driver internal resources.
8604 * 0 - successful
8605 * other values - error
8613 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_setup_driver_resource_phase2()
8614 "lpfc_worker_%d", phba->brd_no); in lpfc_setup_driver_resource_phase2()
8615 if (IS_ERR(phba->worker_thread)) { in lpfc_setup_driver_resource_phase2()
8616 error = PTR_ERR(phba->worker_thread); in lpfc_setup_driver_resource_phase2()
8624 * lpfc_unset_driver_resource_phase2 - Phase2 unset driver internal resources.
8634 if (phba->wq) { in lpfc_unset_driver_resource_phase2()
8635 destroy_workqueue(phba->wq); in lpfc_unset_driver_resource_phase2()
8636 phba->wq = NULL; in lpfc_unset_driver_resource_phase2()
8640 if (phba->worker_thread) in lpfc_unset_driver_resource_phase2()
8641 kthread_stop(phba->worker_thread); in lpfc_unset_driver_resource_phase2()
8645 * lpfc_free_iocb_list - Free iocb list.
8655 spin_lock_irq(&phba->hbalock); in lpfc_free_iocb_list()
8657 &phba->lpfc_iocb_list, list) { in lpfc_free_iocb_list()
8658 list_del(&iocbq_entry->list); in lpfc_free_iocb_list()
8660 phba->total_iocbq_bufs--; in lpfc_free_iocb_list()
8662 spin_unlock_irq(&phba->hbalock); in lpfc_free_iocb_list()
8668 * lpfc_init_iocb_list - Allocate and initialize iocb list.
8676 * 0 - successful
8677 * other values - error
8687 INIT_LIST_HEAD(&phba->lpfc_iocb_list); in lpfc_init_iocb_list()
8704 iocbq_entry->sli4_lxritag = NO_XRI; in lpfc_init_iocb_list()
8705 iocbq_entry->sli4_xritag = NO_XRI; in lpfc_init_iocb_list()
8707 spin_lock_irq(&phba->hbalock); in lpfc_init_iocb_list()
8708 list_add(&iocbq_entry->list, &phba->lpfc_iocb_list); in lpfc_init_iocb_list()
8709 phba->total_iocbq_bufs++; in lpfc_init_iocb_list()
8710 spin_unlock_irq(&phba->hbalock); in lpfc_init_iocb_list()
8718 return -ENOMEM; in lpfc_init_iocb_list()
8722 * lpfc_free_sgl_list - Free a given sgl list.
8734 list_del(&sglq_entry->list); in lpfc_free_sgl_list()
8735 lpfc_mbuf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_sgl_list()
8741 * lpfc_free_els_sgl_list - Free els sgl list.
8752 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
8753 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, &sglq_list); in lpfc_free_els_sgl_list()
8754 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
8761 * lpfc_free_nvmet_sgl_list - Free nvmet sgl list.
8773 spin_lock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
8774 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
8775 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, &sglq_list); in lpfc_free_nvmet_sgl_list()
8776 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
8777 spin_unlock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
8781 list_del(&sglq_entry->list); in lpfc_free_nvmet_sgl_list()
8782 lpfc_nvmet_buf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_nvmet_sgl_list()
8790 phba->sli4_hba.nvmet_xri_cnt = 0; in lpfc_free_nvmet_sgl_list()
8794 * lpfc_init_active_sgl_array - Allocate the buf to track active ELS XRIs.
8805 size *= phba->sli4_hba.max_cfg_param.max_xri; in lpfc_init_active_sgl_array()
8807 phba->sli4_hba.lpfc_sglq_active_list = in lpfc_init_active_sgl_array()
8809 if (!phba->sli4_hba.lpfc_sglq_active_list) in lpfc_init_active_sgl_array()
8810 return -ENOMEM; in lpfc_init_active_sgl_array()
8815 * lpfc_free_active_sgl - Free the buf that tracks active ELS XRIs.
8825 kfree(phba->sli4_hba.lpfc_sglq_active_list); in lpfc_free_active_sgl()
8829 * lpfc_init_sgl_list - Allocate and initialize sgl list.
8840 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_els_sgl_list); in lpfc_init_sgl_list()
8841 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_init_sgl_list()
8842 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_init_sgl_list()
8843 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_init_sgl_list()
8845 /* els xri-sgl book keeping */ in lpfc_init_sgl_list()
8846 phba->sli4_hba.els_xri_cnt = 0; in lpfc_init_sgl_list()
8848 /* nvme xri-buffer book keeping */ in lpfc_init_sgl_list()
8849 phba->sli4_hba.io_xri_cnt = 0; in lpfc_init_sgl_list()
8853 * lpfc_sli4_init_rpi_hdrs - Post the rpi header memory region to the port
8863 * 0 - successful
8864 * -ERROR - otherwise.
8872 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_init_rpi_hdrs()
8873 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_init_rpi_hdrs()
8875 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_init_rpi_hdrs()
8876 return -EIO; in lpfc_sli4_init_rpi_hdrs()
8883 rc = -ENODEV; in lpfc_sli4_init_rpi_hdrs()
8890 * lpfc_sli4_create_rpi_hdr - Allocate an rpi header memory region
8914 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_create_rpi_hdr()
8916 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_create_rpi_hdr()
8920 rpi_limit = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_create_rpi_hdr()
8922 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8928 curr_rpi_range = phba->sli4_hba.next_rpi; in lpfc_sli4_create_rpi_hdr()
8929 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8937 * port expects a 4KB DMA-mapped memory region that is 4K aligned. in lpfc_sli4_create_rpi_hdr()
8943 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_create_rpi_hdr()
8945 &dmabuf->phys, GFP_KERNEL); in lpfc_sli4_create_rpi_hdr()
8946 if (!dmabuf->virt) { in lpfc_sli4_create_rpi_hdr()
8951 if (!IS_ALIGNED(dmabuf->phys, LPFC_HDR_TEMPLATE_SIZE)) { in lpfc_sli4_create_rpi_hdr()
8961 rpi_hdr->dmabuf = dmabuf; in lpfc_sli4_create_rpi_hdr()
8962 rpi_hdr->len = LPFC_HDR_TEMPLATE_SIZE; in lpfc_sli4_create_rpi_hdr()
8963 rpi_hdr->page_count = 1; in lpfc_sli4_create_rpi_hdr()
8964 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8967 rpi_hdr->start_rpi = curr_rpi_range; in lpfc_sli4_create_rpi_hdr()
8968 rpi_hdr->next_rpi = phba->sli4_hba.next_rpi + LPFC_RPI_HDR_COUNT; in lpfc_sli4_create_rpi_hdr()
8969 list_add_tail(&rpi_hdr->list, &phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_create_rpi_hdr()
8971 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8975 dma_free_coherent(&phba->pcidev->dev, LPFC_HDR_TEMPLATE_SIZE, in lpfc_sli4_create_rpi_hdr()
8976 dmabuf->virt, dmabuf->phys); in lpfc_sli4_create_rpi_hdr()
8983 * lpfc_sli4_remove_rpi_hdrs - Remove all rpi header memory regions
8996 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_remove_rpi_hdrs()
9000 &phba->sli4_hba.lpfc_rpi_hdr_list, list) { in lpfc_sli4_remove_rpi_hdrs()
9001 list_del(&rpi_hdr->list); in lpfc_sli4_remove_rpi_hdrs()
9002 dma_free_coherent(&phba->pcidev->dev, rpi_hdr->len, in lpfc_sli4_remove_rpi_hdrs()
9003 rpi_hdr->dmabuf->virt, rpi_hdr->dmabuf->phys); in lpfc_sli4_remove_rpi_hdrs()
9004 kfree(rpi_hdr->dmabuf); in lpfc_sli4_remove_rpi_hdrs()
9009 phba->sli4_hba.next_rpi = 0; in lpfc_sli4_remove_rpi_hdrs()
9013 * lpfc_hba_alloc - Allocate driver hba data structure for a device.
9021 * pointer to @phba - successful
9022 * NULL - error
9032 dev_err(&pdev->dev, "failed to allocate hba struct\n"); in lpfc_hba_alloc()
9037 phba->pcidev = pdev; in lpfc_hba_alloc()
9040 phba->brd_no = lpfc_get_instance(); in lpfc_hba_alloc()
9041 if (phba->brd_no < 0) { in lpfc_hba_alloc()
9045 phba->eratt_poll_interval = LPFC_ERATT_POLL_INTERVAL; in lpfc_hba_alloc()
9047 spin_lock_init(&phba->ct_ev_lock); in lpfc_hba_alloc()
9048 INIT_LIST_HEAD(&phba->ct_ev_waiters); in lpfc_hba_alloc()
9054 * lpfc_hba_free - Free driver hba data structure with a device.
9063 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_hba_free()
9064 kfree(phba->sli4_hba.hdwq); in lpfc_hba_free()
9067 idr_remove(&lpfc_hba_index, phba->brd_no); in lpfc_hba_free()
9070 kfree(phba->sli.sli3_ring); in lpfc_hba_free()
9071 phba->sli.sli3_ring = NULL; in lpfc_hba_free()
9078 * lpfc_setup_fdmi_mask - Setup initial FDMI mask for HBA and Port attributes
9084 * fallback hierarchy is SmartSAN -> FDMI2 -> FMDI1
9089 struct lpfc_hba *phba = vport->phba; in lpfc_setup_fdmi_mask()
9091 vport->load_flag |= FC_ALLOW_FDMI; in lpfc_setup_fdmi_mask()
9092 if (phba->cfg_enable_SmartSAN || in lpfc_setup_fdmi_mask()
9093 phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT) { in lpfc_setup_fdmi_mask()
9095 vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR; in lpfc_setup_fdmi_mask()
9096 if (phba->cfg_enable_SmartSAN) in lpfc_setup_fdmi_mask()
9097 vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR; in lpfc_setup_fdmi_mask()
9099 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR; in lpfc_setup_fdmi_mask()
9104 vport->fdmi_hba_mask, vport->fdmi_port_mask); in lpfc_setup_fdmi_mask()
9108 * lpfc_create_shost - Create hba physical port with associated scsi host.
9115 * 0 - successful
9116 * other values - error
9125 phba->fc_edtov = FF_DEF_EDTOV; in lpfc_create_shost()
9126 phba->fc_ratov = FF_DEF_RATOV; in lpfc_create_shost()
9127 phba->fc_altov = FF_DEF_ALTOV; in lpfc_create_shost()
9128 phba->fc_arbtov = FF_DEF_ARBTOV; in lpfc_create_shost()
9130 atomic_set(&phba->sdev_cnt, 0); in lpfc_create_shost()
9131 vport = lpfc_create_port(phba, phba->brd_no, &phba->pcidev->dev); in lpfc_create_shost()
9133 return -ENODEV; in lpfc_create_shost()
9136 phba->pport = vport; in lpfc_create_shost()
9138 if (phba->nvmet_support) { in lpfc_create_shost()
9140 phba->targetport = NULL; in lpfc_create_shost()
9141 phba->cfg_enable_fc4_type = LPFC_ENABLE_NVME; in lpfc_create_shost()
9148 pci_set_drvdata(phba->pcidev, shost); in lpfc_create_shost()
9160 * lpfc_destroy_shost - Destroy hba physical port with associated scsi host.
9169 struct lpfc_vport *vport = phba->pport; in lpfc_destroy_shost()
9178 * lpfc_setup_bg - Setup Block guard structures and debug areas.
9191 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
9196 old_mask = phba->cfg_prot_mask; in lpfc_setup_bg()
9197 old_guard = phba->cfg_prot_guard; in lpfc_setup_bg()
9200 phba->cfg_prot_mask &= (SHOST_DIF_TYPE1_PROTECTION | in lpfc_setup_bg()
9203 phba->cfg_prot_guard &= (SHOST_DIX_GUARD_IP | in lpfc_setup_bg()
9207 if (phba->cfg_prot_mask == SHOST_DIX_TYPE1_PROTECTION) in lpfc_setup_bg()
9208 phba->cfg_prot_mask |= SHOST_DIF_TYPE1_PROTECTION; in lpfc_setup_bg()
9210 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
9211 if ((old_mask != phba->cfg_prot_mask) || in lpfc_setup_bg()
9212 (old_guard != phba->cfg_prot_guard)) in lpfc_setup_bg()
9216 phba->cfg_prot_mask, in lpfc_setup_bg()
9217 phba->cfg_prot_guard); in lpfc_setup_bg()
9219 scsi_host_set_prot(shost, phba->cfg_prot_mask); in lpfc_setup_bg()
9220 scsi_host_set_guard(shost, phba->cfg_prot_guard); in lpfc_setup_bg()
9230 * lpfc_post_init_setup - Perform necessary device post initialization setup.
9243 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_post_init_setup()
9249 shost = pci_get_drvdata(phba->pcidev); in lpfc_post_init_setup()
9250 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_post_init_setup()
9254 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_post_init_setup()
9255 spin_lock_irq(shost->host_lock); in lpfc_post_init_setup()
9257 spin_unlock_irq(shost->host_lock); in lpfc_post_init_setup()
9273 * lpfc_sli_pci_mem_setup - Setup SLI3 HBA PCI memory space.
9277 * with SLI-3 interface spec.
9280 * 0 - successful
9281 * other values - error
9286 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_pci_mem_setup()
9293 return -ENODEV; in lpfc_sli_pci_mem_setup()
9296 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli_pci_mem_setup()
9298 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli_pci_mem_setup()
9301 error = -ENODEV; in lpfc_sli_pci_mem_setup()
9306 phba->pci_bar0_map = pci_resource_start(pdev, 0); in lpfc_sli_pci_mem_setup()
9309 phba->pci_bar2_map = pci_resource_start(pdev, 2); in lpfc_sli_pci_mem_setup()
9313 phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli_pci_mem_setup()
9314 if (!phba->slim_memmap_p) { in lpfc_sli_pci_mem_setup()
9315 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
9321 phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli_pci_mem_setup()
9322 if (!phba->ctrl_regs_memmap_p) { in lpfc_sli_pci_mem_setup()
9323 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
9328 /* Allocate memory for SLI-2 structures */ in lpfc_sli_pci_mem_setup()
9329 phba->slim2p.virt = dma_alloc_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
9330 &phba->slim2p.phys, GFP_KERNEL); in lpfc_sli_pci_mem_setup()
9331 if (!phba->slim2p.virt) in lpfc_sli_pci_mem_setup()
9334 phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx); in lpfc_sli_pci_mem_setup()
9335 phba->mbox_ext = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
9337 phba->pcb = (phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, pcb)); in lpfc_sli_pci_mem_setup()
9338 phba->IOCBs = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
9341 phba->hbqslimp.virt = dma_alloc_coherent(&pdev->dev, in lpfc_sli_pci_mem_setup()
9343 &phba->hbqslimp.phys, in lpfc_sli_pci_mem_setup()
9345 if (!phba->hbqslimp.virt) in lpfc_sli_pci_mem_setup()
9349 ptr = phba->hbqslimp.virt; in lpfc_sli_pci_mem_setup()
9351 phba->hbqs[i].hbq_virt = ptr; in lpfc_sli_pci_mem_setup()
9352 INIT_LIST_HEAD(&phba->hbqs[i].hbq_buffer_list); in lpfc_sli_pci_mem_setup()
9353 ptr += (lpfc_hbq_defs[i]->entry_count * in lpfc_sli_pci_mem_setup()
9356 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_els_hbq_alloc; in lpfc_sli_pci_mem_setup()
9357 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_els_hbq_free; in lpfc_sli_pci_mem_setup()
9359 memset(phba->hbqslimp.virt, 0, lpfc_sli_hbq_size()); in lpfc_sli_pci_mem_setup()
9361 phba->MBslimaddr = phba->slim_memmap_p; in lpfc_sli_pci_mem_setup()
9362 phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9363 phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9364 phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9365 phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9370 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
9371 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_setup()
9373 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_setup()
9375 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_setup()
9381 * lpfc_sli_pci_mem_unset - Unset SLI3 HBA PCI memory space.
9385 * with SLI-3 interface spec.
9393 if (!phba->pcidev) in lpfc_sli_pci_mem_unset()
9396 pdev = phba->pcidev; in lpfc_sli_pci_mem_unset()
9399 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_sli_pci_mem_unset()
9400 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_sli_pci_mem_unset()
9401 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_unset()
9402 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_unset()
9405 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_unset()
9406 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_unset()
9412 * lpfc_sli4_post_status_check - Wait for SLI4 POST done and check status
9418 * Return 0 if successful, otherwise -ENODEV.
9430 if (!phba->sli4_hba.PSMPHRregaddr) in lpfc_sli4_post_status_check()
9431 return -ENODEV; in lpfc_sli4_post_status_check()
9435 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_sli4_post_status_check()
9439 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9454 "1408 Port Failed POST - portsmphr=0x%x, " in lpfc_sli4_post_status_check()
9472 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9474 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9476 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9478 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9480 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9482 &phba->sli4_hba.sli_intf)); in lpfc_sli4_post_status_check()
9489 &phba->sli4_hba.sli_intf); in lpfc_sli4_post_status_check()
9492 phba->sli4_hba.ue_mask_lo = in lpfc_sli4_post_status_check()
9493 readl(phba->sli4_hba.u.if_type0.UEMASKLOregaddr); in lpfc_sli4_post_status_check()
9494 phba->sli4_hba.ue_mask_hi = in lpfc_sli4_post_status_check()
9495 readl(phba->sli4_hba.u.if_type0.UEMASKHIregaddr); in lpfc_sli4_post_status_check()
9497 readl(phba->sli4_hba.u.if_type0.UERRLOregaddr); in lpfc_sli4_post_status_check()
9499 readl(phba->sli4_hba.u.if_type0.UERRHIregaddr); in lpfc_sli4_post_status_check()
9500 if ((~phba->sli4_hba.ue_mask_lo & uerrlo_reg.word0) || in lpfc_sli4_post_status_check()
9501 (~phba->sli4_hba.ue_mask_hi & uerrhi_reg.word0)) { in lpfc_sli4_post_status_check()
9512 phba->sli4_hba.ue_mask_lo, in lpfc_sli4_post_status_check()
9513 phba->sli4_hba.ue_mask_hi); in lpfc_sli4_post_status_check()
9514 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9520 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_post_status_check()
9523 phba->work_status[0] = in lpfc_sli4_post_status_check()
9524 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
9526 phba->work_status[1] = in lpfc_sli4_post_status_check()
9527 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
9536 phba->work_status[0], in lpfc_sli4_post_status_check()
9537 phba->work_status[1]); in lpfc_sli4_post_status_check()
9538 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9544 &phba->sli4_hba.sli_intf) == in lpfc_sli4_post_status_check()
9546 pci_write_config_byte(phba->pcidev, in lpfc_sli4_post_status_check()
9558 * lpfc_sli4_bar0_register_memmap - Set up SLI4 BAR0 register memory map.
9570 phba->sli4_hba.u.if_type0.UERRLOregaddr = in lpfc_sli4_bar0_register_memmap()
9571 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_LO; in lpfc_sli4_bar0_register_memmap()
9572 phba->sli4_hba.u.if_type0.UERRHIregaddr = in lpfc_sli4_bar0_register_memmap()
9573 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_HI; in lpfc_sli4_bar0_register_memmap()
9574 phba->sli4_hba.u.if_type0.UEMASKLOregaddr = in lpfc_sli4_bar0_register_memmap()
9575 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_LO; in lpfc_sli4_bar0_register_memmap()
9576 phba->sli4_hba.u.if_type0.UEMASKHIregaddr = in lpfc_sli4_bar0_register_memmap()
9577 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_HI; in lpfc_sli4_bar0_register_memmap()
9578 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
9579 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
9582 phba->sli4_hba.u.if_type2.EQDregaddr = 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.ERR1regaddr = 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.ERR2regaddr = 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.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
9592 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9594 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
9595 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9597 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
9598 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
9599 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
9600 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9602 phba->sli4_hba.RQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9603 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9605 phba->sli4_hba.WQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9606 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9608 phba->sli4_hba.CQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9609 phba->sli4_hba.conf_regs_memmap_p + LPFC_EQCQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
9610 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar0_register_memmap()
9611 phba->sli4_hba.MQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9612 phba->sli4_hba.conf_regs_memmap_p + LPFC_MQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
9613 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
9614 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
9617 phba->sli4_hba.u.if_type2.EQDregaddr = 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.ERR1regaddr = 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.ERR2regaddr = 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.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
9627 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9629 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
9630 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9632 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
9633 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9635 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
9636 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
9640 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_bar0_register_memmap()
9641 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar0_register_memmap()
9648 * lpfc_sli4_bar1_register_memmap - Set up SLI4 BAR1 register memory map.
9659 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar1_register_memmap()
9660 phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9662 phba->sli4_hba.ISRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9664 phba->sli4_hba.IMRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9666 phba->sli4_hba.ISCRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9670 phba->sli4_hba.RQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9672 phba->sli4_hba.WQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9674 phba->sli4_hba.CQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9676 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9678 phba->sli4_hba.MQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9684 dev_err(&phba->pcidev->dev, in lpfc_sli4_bar1_register_memmap()
9685 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar1_register_memmap()
9692 * lpfc_sli4_bar2_register_memmap - Set up SLI4 BAR2 register memory map.
9699 * Return 0 if successful, otherwise -ENODEV.
9705 return -ENODEV; in lpfc_sli4_bar2_register_memmap()
9707 phba->sli4_hba.RQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9710 phba->sli4_hba.WQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9713 phba->sli4_hba.CQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9716 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar2_register_memmap()
9717 phba->sli4_hba.MQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9719 phba->sli4_hba.BMBXregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9725 * lpfc_create_bootstrap_mbox - Create the bootstrap mailbox
9729 * region consistent with the SLI-4 interface spec. This
9736 * 0 - successful
9737 * -ENOMEM - could not allocated memory.
9750 return -ENOMEM; in lpfc_create_bootstrap_mbox()
9756 bmbx_size = sizeof(struct lpfc_bmbx_create) + (LPFC_ALIGN_16_BYTE - 1); in lpfc_create_bootstrap_mbox()
9757 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, bmbx_size, in lpfc_create_bootstrap_mbox()
9758 &dmabuf->phys, GFP_KERNEL); in lpfc_create_bootstrap_mbox()
9759 if (!dmabuf->virt) { in lpfc_create_bootstrap_mbox()
9761 return -ENOMEM; in lpfc_create_bootstrap_mbox()
9767 * to be 16-byte aligned. Also align the virtual memory as each in lpfc_create_bootstrap_mbox()
9771 phba->sli4_hba.bmbx.dmabuf = dmabuf; in lpfc_create_bootstrap_mbox()
9772 phba->sli4_hba.bmbx.bmbx_size = bmbx_size; in lpfc_create_bootstrap_mbox()
9774 phba->sli4_hba.bmbx.avirt = PTR_ALIGN(dmabuf->virt, in lpfc_create_bootstrap_mbox()
9776 phba->sli4_hba.bmbx.aphys = ALIGN(dmabuf->phys, in lpfc_create_bootstrap_mbox()
9782 * as two 30-bit addresses. The other data is a bit marking whether in lpfc_create_bootstrap_mbox()
9783 * the 30-bit address is the high or low address. in lpfc_create_bootstrap_mbox()
9787 dma_address = &phba->sli4_hba.bmbx.dma_address; in lpfc_create_bootstrap_mbox()
9788 phys_addr = (uint64_t)phba->sli4_hba.bmbx.aphys; in lpfc_create_bootstrap_mbox()
9790 dma_address->addr_hi = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
9793 pa_addr = (uint32_t) ((phba->sli4_hba.bmbx.aphys >> 4) & 0x3fffffff); in lpfc_create_bootstrap_mbox()
9794 dma_address->addr_lo = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
9800 * lpfc_destroy_bootstrap_mbox - Destroy all bootstrap mailbox resources
9813 dma_free_coherent(&phba->pcidev->dev, in lpfc_destroy_bootstrap_mbox()
9814 phba->sli4_hba.bmbx.bmbx_size, in lpfc_destroy_bootstrap_mbox()
9815 phba->sli4_hba.bmbx.dmabuf->virt, in lpfc_destroy_bootstrap_mbox()
9816 phba->sli4_hba.bmbx.dmabuf->phys); in lpfc_destroy_bootstrap_mbox()
9818 kfree(phba->sli4_hba.bmbx.dmabuf); in lpfc_destroy_bootstrap_mbox()
9819 memset(&phba->sli4_hba.bmbx, 0, sizeof(struct lpfc_bmbx)); in lpfc_destroy_bootstrap_mbox()
9836 * lpfc_map_topology - Map the topology read from READ_CONFIG
9861 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9864 /* FW supports persistent topology - override module parameter value */ in lpfc_map_topology()
9865 phba->hba_flag |= HBA_PERSISTENT_TOPO; in lpfc_map_topology()
9868 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_map_topology()
9870 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_map_topology()
9873 phba->cfg_topology = ((pt == LINK_FLAGS_LOOP) in lpfc_map_topology()
9877 phba->hba_flag &= ~HBA_PERSISTENT_TOPO; in lpfc_map_topology()
9881 /* If topology failover set - pt is '0' or '1' */ in lpfc_map_topology()
9882 phba->cfg_topology = (pt ? FLAGS_TOPOLOGY_MODE_PT_LOOP : in lpfc_map_topology()
9885 phba->cfg_topology = ((pt == LINK_FLAGS_P2P) in lpfc_map_topology()
9890 if (phba->hba_flag & HBA_PERSISTENT_TOPO) { in lpfc_map_topology()
9893 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9898 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9903 * lpfc_sli4_read_config - Get the config parameters.
9912 * 0 - successful
9913 * -ENOMEM - No available memory
9914 * -EIO - The mailbox failed to complete successfully.
9930 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_read_config()
9935 return -ENOMEM; in lpfc_sli4_read_config()
9945 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
9946 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
9947 rc = -EIO; in lpfc_sli4_read_config()
9949 rd_config = &pmb->u.mqe.un.rd_config; in lpfc_sli4_read_config()
9951 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_VAL; in lpfc_sli4_read_config()
9952 phba->sli4_hba.lnk_info.lnk_tp = in lpfc_sli4_read_config()
9954 phba->sli4_hba.lnk_info.lnk_no = in lpfc_sli4_read_config()
9958 phba->sli4_hba.lnk_info.lnk_tp, in lpfc_sli4_read_config()
9959 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_read_config()
9963 bf_get(lpfc_mqe_command, &pmb->u.mqe)); in lpfc_sli4_read_config()
9965 phba->bbcredit_support = 1; in lpfc_sli4_read_config()
9966 phba->sli4_hba.bbscn_params.word0 = rd_config->word8; in lpfc_sli4_read_config()
9974 "2702 READ_CONFIG: FA-PWWN is " in lpfc_sli4_read_config()
9976 phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_CONFIG; in lpfc_sli4_read_config()
9979 phba->sli4_hba.fawwpn_flag &= ~LPFC_FAWWPN_CONFIG; in lpfc_sli4_read_config()
9982 phba->sli4_hba.conf_trunk = in lpfc_sli4_read_config()
9984 phba->sli4_hba.extents_in_use = in lpfc_sli4_read_config()
9987 phba->sli4_hba.max_cfg_param.max_xri = in lpfc_sli4_read_config()
9991 phba->sli4_hba.max_cfg_param.max_xri > 512) in lpfc_sli4_read_config()
9992 phba->sli4_hba.max_cfg_param.max_xri = 512; in lpfc_sli4_read_config()
9993 phba->sli4_hba.max_cfg_param.xri_base = in lpfc_sli4_read_config()
9995 phba->sli4_hba.max_cfg_param.max_vpi = in lpfc_sli4_read_config()
9998 if (phba->sli4_hba.max_cfg_param.max_vpi > LPFC_MAX_VPORTS) in lpfc_sli4_read_config()
9999 phba->sli4_hba.max_cfg_param.max_vpi = LPFC_MAX_VPORTS; in lpfc_sli4_read_config()
10000 phba->sli4_hba.max_cfg_param.vpi_base = in lpfc_sli4_read_config()
10002 phba->sli4_hba.max_cfg_param.max_rpi = in lpfc_sli4_read_config()
10004 phba->sli4_hba.max_cfg_param.rpi_base = in lpfc_sli4_read_config()
10006 phba->sli4_hba.max_cfg_param.max_vfi = in lpfc_sli4_read_config()
10008 phba->sli4_hba.max_cfg_param.vfi_base = in lpfc_sli4_read_config()
10010 phba->sli4_hba.max_cfg_param.max_fcfi = in lpfc_sli4_read_config()
10012 phba->sli4_hba.max_cfg_param.max_eq = in lpfc_sli4_read_config()
10014 phba->sli4_hba.max_cfg_param.max_rq = in lpfc_sli4_read_config()
10016 phba->sli4_hba.max_cfg_param.max_wq = in lpfc_sli4_read_config()
10018 phba->sli4_hba.max_cfg_param.max_cq = in lpfc_sli4_read_config()
10020 phba->lmt = bf_get(lpfc_mbx_rd_conf_lmt, rd_config); in lpfc_sli4_read_config()
10021 phba->sli4_hba.next_xri = phba->sli4_hba.max_cfg_param.xri_base; in lpfc_sli4_read_config()
10022 phba->vpi_base = phba->sli4_hba.max_cfg_param.vpi_base; in lpfc_sli4_read_config()
10023 phba->vfi_base = phba->sli4_hba.max_cfg_param.vfi_base; in lpfc_sli4_read_config()
10024 phba->max_vpi = (phba->sli4_hba.max_cfg_param.max_vpi > 0) ? in lpfc_sli4_read_config()
10025 (phba->sli4_hba.max_cfg_param.max_vpi - 1) : 0; in lpfc_sli4_read_config()
10026 phba->max_vports = phba->max_vpi; in lpfc_sli4_read_config()
10037 phba->cgn_reg_fpin = LPFC_CGN_FPIN_BOTH; in lpfc_sli4_read_config()
10038 phba->cgn_reg_signal = EDC_CG_SIG_NOTSUPPORTED; in lpfc_sli4_read_config()
10039 phba->cgn_sig_freq = lpfc_fabric_cgn_frequency; in lpfc_sli4_read_config()
10043 phba->cgn_reg_signal = EDC_CG_SIG_WARN_ONLY; in lpfc_sli4_read_config()
10044 phba->cgn_reg_fpin &= ~LPFC_CGN_FPIN_WARN; in lpfc_sli4_read_config()
10050 if (phba->cgn_reg_signal != in lpfc_sli4_read_config()
10053 phba->cgn_reg_fpin = LPFC_CGN_FPIN_BOTH; in lpfc_sli4_read_config()
10054 phba->cgn_reg_signal = in lpfc_sli4_read_config()
10057 phba->cgn_reg_signal = in lpfc_sli4_read_config()
10059 phba->cgn_reg_fpin = in lpfc_sli4_read_config()
10066 phba->cgn_init_reg_fpin = phba->cgn_reg_fpin; in lpfc_sli4_read_config()
10067 phba->cgn_init_reg_signal = phba->cgn_reg_signal; in lpfc_sli4_read_config()
10071 phba->cgn_reg_signal, phba->cgn_reg_fpin); in lpfc_sli4_read_config()
10081 phba->sli4_hba.extents_in_use, in lpfc_sli4_read_config()
10082 phba->sli4_hba.max_cfg_param.xri_base, in lpfc_sli4_read_config()
10083 phba->sli4_hba.max_cfg_param.max_xri, in lpfc_sli4_read_config()
10084 phba->sli4_hba.max_cfg_param.vpi_base, in lpfc_sli4_read_config()
10085 phba->sli4_hba.max_cfg_param.max_vpi, in lpfc_sli4_read_config()
10086 phba->sli4_hba.max_cfg_param.vfi_base, in lpfc_sli4_read_config()
10087 phba->sli4_hba.max_cfg_param.max_vfi, in lpfc_sli4_read_config()
10088 phba->sli4_hba.max_cfg_param.rpi_base, in lpfc_sli4_read_config()
10089 phba->sli4_hba.max_cfg_param.max_rpi, in lpfc_sli4_read_config()
10090 phba->sli4_hba.max_cfg_param.max_fcfi, in lpfc_sli4_read_config()
10091 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
10092 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
10093 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
10094 phba->sli4_hba.max_cfg_param.max_rq, in lpfc_sli4_read_config()
10095 phba->lmt); in lpfc_sli4_read_config()
10101 qmin = phba->sli4_hba.max_cfg_param.max_wq; in lpfc_sli4_read_config()
10102 if (phba->sli4_hba.max_cfg_param.max_cq < qmin) in lpfc_sli4_read_config()
10103 qmin = phba->sli4_hba.max_cfg_param.max_cq; in lpfc_sli4_read_config()
10108 qmin -= 4; in lpfc_sli4_read_config()
10109 if (phba->sli4_hba.max_cfg_param.max_eq < qmin) in lpfc_sli4_read_config()
10110 qmin = phba->sli4_hba.max_cfg_param.max_eq; in lpfc_sli4_read_config()
10113 if ((phba->cfg_irq_chann > qmin) || in lpfc_sli4_read_config()
10114 (phba->cfg_hdw_queue > qmin)) { in lpfc_sli4_read_config()
10116 "2005 Reducing Queues - " in lpfc_sli4_read_config()
10120 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
10121 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
10122 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
10123 qmin, phba->cfg_irq_chann, in lpfc_sli4_read_config()
10124 phba->cfg_hdw_queue); in lpfc_sli4_read_config()
10126 if (phba->cfg_irq_chann > qmin) in lpfc_sli4_read_config()
10127 phba->cfg_irq_chann = qmin; in lpfc_sli4_read_config()
10128 if (phba->cfg_hdw_queue > qmin) in lpfc_sli4_read_config()
10129 phba->cfg_hdw_queue = qmin; in lpfc_sli4_read_config()
10137 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_read_config()
10142 phba->hba_flag |= HBA_FORCED_LINK_SPEED; in lpfc_sli4_read_config()
10146 phba->cfg_link_speed = in lpfc_sli4_read_config()
10150 phba->cfg_link_speed = in lpfc_sli4_read_config()
10154 phba->cfg_link_speed = in lpfc_sli4_read_config()
10158 phba->cfg_link_speed = in lpfc_sli4_read_config()
10162 phba->cfg_link_speed = in lpfc_sli4_read_config()
10166 phba->cfg_link_speed = in lpfc_sli4_read_config()
10170 phba->cfg_link_speed = in lpfc_sli4_read_config()
10174 phba->cfg_link_speed = in lpfc_sli4_read_config()
10178 phba->cfg_link_speed = in lpfc_sli4_read_config()
10187 phba->cfg_link_speed = in lpfc_sli4_read_config()
10194 length = phba->sli4_hba.max_cfg_param.max_xri - in lpfc_sli4_read_config()
10196 if (phba->cfg_hba_queue_depth > length) { in lpfc_sli4_read_config()
10199 phba->cfg_hba_queue_depth, length); in lpfc_sli4_read_config()
10200 phba->cfg_hba_queue_depth = length; in lpfc_sli4_read_config()
10203 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_read_config()
10208 length = (sizeof(struct lpfc_mbx_get_func_cfg) - in lpfc_sli4_read_config()
10216 &pmb->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_read_config()
10217 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_read_config()
10218 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_read_config()
10223 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
10224 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
10229 get_func_cfg = &pmb->u.mqe.un.get_func_cfg; in lpfc_sli4_read_config()
10231 pdesc_0 = (char *)&get_func_cfg->func_cfg.desc[0]; in lpfc_sli4_read_config()
10243 phba->sli4_hba.iov.pf_number = in lpfc_sli4_read_config()
10245 phba->sli4_hba.iov.vf_number = in lpfc_sli4_read_config()
10254 "vf_number:%d\n", phba->sli4_hba.iov.pf_number, in lpfc_sli4_read_config()
10255 phba->sli4_hba.iov.vf_number); in lpfc_sli4_read_config()
10263 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_read_config()
10268 * lpfc_setup_endian_order - Write endian order to an SLI4 if_type 0 port.
10271 * This routine is invoked to setup the port-side endian order when
10276 * 0 - successful
10277 * -ENOMEM - No available memory
10278 * -EIO - The mailbox failed to complete successfully.
10288 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_setup_endian_order()
10291 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_setup_endian_order()
10298 return -ENOMEM; in lpfc_setup_endian_order()
10306 memcpy(&mboxq->u.mqe, &endian_mb_data, sizeof(endian_mb_data)); in lpfc_setup_endian_order()
10313 rc = -EIO; in lpfc_setup_endian_order()
10315 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_setup_endian_order()
10327 * lpfc_sli4_queue_verify - Verify and update EQ counts
10336 * 0 - successful
10337 * -ENOMEM - No available memory
10343 * Sanity check for configured queue parameters against the run-time in lpfc_sli4_queue_verify()
10347 if (phba->nvmet_support) { in lpfc_sli4_queue_verify()
10348 if (phba->cfg_hdw_queue < phba->cfg_nvmet_mrq) in lpfc_sli4_queue_verify()
10349 phba->cfg_nvmet_mrq = phba->cfg_hdw_queue; in lpfc_sli4_queue_verify()
10350 if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX) in lpfc_sli4_queue_verify()
10351 phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX; in lpfc_sli4_queue_verify()
10356 phba->cfg_hdw_queue, phba->cfg_irq_chann, in lpfc_sli4_queue_verify()
10357 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_verify()
10360 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_verify()
10361 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_verify()
10364 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_verify()
10365 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_verify()
10374 int cpu; in lpfc_alloc_io_wq_cq() local
10376 cpu = lpfc_find_cpu_handle(phba, idx, LPFC_FIND_BY_HDWQ); in lpfc_alloc_io_wq_cq()
10378 if (phba->enab_exp_wqcq_pages) in lpfc_alloc_io_wq_cq()
10381 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
10382 LPFC_CQE_EXP_COUNT, cpu); in lpfc_alloc_io_wq_cq()
10386 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
10387 phba->sli4_hba.cq_ecount, cpu); in lpfc_alloc_io_wq_cq()
10390 "0499 Failed allocate fast-path IO CQ (%d)\n", in lpfc_alloc_io_wq_cq()
10394 qdesc->qe_valid = 1; in lpfc_alloc_io_wq_cq()
10395 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
10396 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
10397 phba->sli4_hba.hdwq[idx].io_cq = qdesc; in lpfc_alloc_io_wq_cq()
10400 if (phba->enab_exp_wqcq_pages) { in lpfc_alloc_io_wq_cq()
10402 wqesize = (phba->fcp_embed_io) ? in lpfc_alloc_io_wq_cq()
10403 LPFC_WQE128_SIZE : phba->sli4_hba.wq_esize; in lpfc_alloc_io_wq_cq()
10406 LPFC_WQE_EXP_COUNT, cpu); in lpfc_alloc_io_wq_cq()
10409 phba->sli4_hba.wq_esize, in lpfc_alloc_io_wq_cq()
10410 phba->sli4_hba.wq_ecount, cpu); in lpfc_alloc_io_wq_cq()
10414 "0503 Failed allocate fast-path IO WQ (%d)\n", in lpfc_alloc_io_wq_cq()
10418 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
10419 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
10420 phba->sli4_hba.hdwq[idx].io_wq = qdesc; in lpfc_alloc_io_wq_cq()
10421 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_alloc_io_wq_cq()
10426 * lpfc_sli4_queue_create - Create all the SLI4 queues
10435 * 0 - successful
10436 * -ENOMEM - No availble memory
10437 * -EIO - The mailbox failed to complete successfully.
10443 int idx, cpu, eqcpu; in lpfc_sli4_queue_create() local
10453 phba->sli4_hba.mq_esize = LPFC_MQE_SIZE; in lpfc_sli4_queue_create()
10454 phba->sli4_hba.mq_ecount = LPFC_MQE_DEF_COUNT; in lpfc_sli4_queue_create()
10455 phba->sli4_hba.wq_esize = LPFC_WQE_SIZE; in lpfc_sli4_queue_create()
10456 phba->sli4_hba.wq_ecount = LPFC_WQE_DEF_COUNT; in lpfc_sli4_queue_create()
10457 phba->sli4_hba.rq_esize = LPFC_RQE_SIZE; in lpfc_sli4_queue_create()
10458 phba->sli4_hba.rq_ecount = LPFC_RQE_DEF_COUNT; in lpfc_sli4_queue_create()
10459 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_create()
10460 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_create()
10461 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_create()
10462 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_create()
10464 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
10465 phba->sli4_hba.hdwq = kcalloc( in lpfc_sli4_queue_create()
10466 phba->cfg_hdw_queue, sizeof(struct lpfc_sli4_hdw_queue), in lpfc_sli4_queue_create()
10468 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
10471 "fast-path Hardware Queue array\n"); in lpfc_sli4_queue_create()
10475 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10476 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_queue_create()
10477 spin_lock_init(&qp->io_buf_list_get_lock); in lpfc_sli4_queue_create()
10478 spin_lock_init(&qp->io_buf_list_put_lock); in lpfc_sli4_queue_create()
10479 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_sli4_queue_create()
10480 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_sli4_queue_create()
10481 qp->get_io_bufs = 0; in lpfc_sli4_queue_create()
10482 qp->put_io_bufs = 0; in lpfc_sli4_queue_create()
10483 qp->total_io_bufs = 0; in lpfc_sli4_queue_create()
10484 spin_lock_init(&qp->abts_io_buf_list_lock); in lpfc_sli4_queue_create()
10485 INIT_LIST_HEAD(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_queue_create()
10486 qp->abts_scsi_io_bufs = 0; in lpfc_sli4_queue_create()
10487 qp->abts_nvme_io_bufs = 0; in lpfc_sli4_queue_create()
10488 INIT_LIST_HEAD(&qp->sgl_list); in lpfc_sli4_queue_create()
10489 INIT_LIST_HEAD(&qp->cmd_rsp_buf_list); in lpfc_sli4_queue_create()
10490 spin_lock_init(&qp->hdwq_lock); in lpfc_sli4_queue_create()
10494 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10495 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
10496 phba->sli4_hba.nvmet_cqset = kcalloc( in lpfc_sli4_queue_create()
10497 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10500 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_create()
10503 "fast-path CQ set array\n"); in lpfc_sli4_queue_create()
10506 phba->sli4_hba.nvmet_mrq_hdr = kcalloc( in lpfc_sli4_queue_create()
10507 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10510 if (!phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_create()
10513 "fast-path RQ set hdr array\n"); in lpfc_sli4_queue_create()
10516 phba->sli4_hba.nvmet_mrq_data = kcalloc( in lpfc_sli4_queue_create()
10517 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10520 if (!phba->sli4_hba.nvmet_mrq_data) { in lpfc_sli4_queue_create()
10523 "fast-path RQ set data array\n"); in lpfc_sli4_queue_create()
10529 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10532 for_each_present_cpu(cpu) { in lpfc_sli4_queue_create()
10537 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
10538 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_create()
10541 /* Get a ptr to the Hardware Queue associated with this CPU */ in lpfc_sli4_queue_create()
10542 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
10546 phba->sli4_hba.eq_esize, in lpfc_sli4_queue_create()
10547 phba->sli4_hba.eq_ecount, cpu); in lpfc_sli4_queue_create()
10551 cpup->hdwq); in lpfc_sli4_queue_create()
10554 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10555 qdesc->hdwq = cpup->hdwq; in lpfc_sli4_queue_create()
10556 qdesc->chann = cpu; /* First CPU this EQ is affinitized to */ in lpfc_sli4_queue_create()
10557 qdesc->last_cpu = qdesc->chann; in lpfc_sli4_queue_create()
10560 qp->hba_eq = qdesc; in lpfc_sli4_queue_create()
10562 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, qdesc->last_cpu); in lpfc_sli4_queue_create()
10563 list_add(&qdesc->cpu_list, &eqi->list); in lpfc_sli4_queue_create()
10569 for_each_present_cpu(cpu) { in lpfc_sli4_queue_create()
10570 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
10573 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_sli4_queue_create()
10577 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
10578 if (qp->hba_eq) in lpfc_sli4_queue_create()
10582 eqcpu = lpfc_find_cpu_handle(phba, cpup->eq, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
10583 eqcpup = &phba->sli4_hba.cpu_map[eqcpu]; in lpfc_sli4_queue_create()
10584 qp->hba_eq = phba->sli4_hba.hdwq[eqcpup->hdwq].hba_eq; in lpfc_sli4_queue_create()
10588 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10593 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
10594 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
10595 cpu = lpfc_find_cpu_handle(phba, idx, in lpfc_sli4_queue_create()
10599 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10600 phba->sli4_hba.cq_ecount, in lpfc_sli4_queue_create()
10601 cpu); in lpfc_sli4_queue_create()
10608 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10609 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10610 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10611 phba->sli4_hba.nvmet_cqset[idx] = qdesc; in lpfc_sli4_queue_create()
10619 cpu = lpfc_find_cpu_handle(phba, 0, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
10620 /* Create slow-path Mailbox Command Complete Queue */ in lpfc_sli4_queue_create()
10622 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10623 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10626 "0500 Failed allocate slow-path mailbox CQ\n"); in lpfc_sli4_queue_create()
10629 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10630 phba->sli4_hba.mbx_cq = qdesc; in lpfc_sli4_queue_create()
10632 /* Create slow-path ELS Complete Queue */ in lpfc_sli4_queue_create()
10634 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10635 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10638 "0501 Failed allocate slow-path ELS CQ\n"); in lpfc_sli4_queue_create()
10641 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10642 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10643 phba->sli4_hba.els_cq = qdesc; in lpfc_sli4_queue_create()
10653 phba->sli4_hba.mq_esize, in lpfc_sli4_queue_create()
10654 phba->sli4_hba.mq_ecount, cpu); in lpfc_sli4_queue_create()
10657 "0505 Failed allocate slow-path MQ\n"); in lpfc_sli4_queue_create()
10660 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10661 phba->sli4_hba.mbx_wq = qdesc; in lpfc_sli4_queue_create()
10667 /* Create slow-path ELS Work Queue */ in lpfc_sli4_queue_create()
10669 phba->sli4_hba.wq_esize, in lpfc_sli4_queue_create()
10670 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
10673 "0504 Failed allocate slow-path ELS WQ\n"); in lpfc_sli4_queue_create()
10676 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10677 phba->sli4_hba.els_wq = qdesc; in lpfc_sli4_queue_create()
10678 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10680 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10683 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10684 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10690 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10691 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10692 phba->sli4_hba.nvmels_cq = qdesc; in lpfc_sli4_queue_create()
10696 phba->sli4_hba.wq_esize, in lpfc_sli4_queue_create()
10697 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
10703 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10704 phba->sli4_hba.nvmels_wq = qdesc; in lpfc_sli4_queue_create()
10705 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10714 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10715 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
10721 phba->sli4_hba.hdr_rq = qdesc; in lpfc_sli4_queue_create()
10725 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10726 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
10732 phba->sli4_hba.dat_rq = qdesc; in lpfc_sli4_queue_create()
10734 if ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) && in lpfc_sli4_queue_create()
10735 phba->nvmet_support) { in lpfc_sli4_queue_create()
10736 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
10737 cpu = lpfc_find_cpu_handle(phba, idx, in lpfc_sli4_queue_create()
10742 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10744 cpu); in lpfc_sli4_queue_create()
10751 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10752 phba->sli4_hba.nvmet_mrq_hdr[idx] = qdesc; in lpfc_sli4_queue_create()
10755 qdesc->rqbp = kzalloc_node(sizeof(*qdesc->rqbp), in lpfc_sli4_queue_create()
10757 cpu_to_node(cpu)); in lpfc_sli4_queue_create()
10758 if (qdesc->rqbp == NULL) { in lpfc_sli4_queue_create()
10766 INIT_LIST_HEAD(&qdesc->rqbp->rqb_buffer_list); in lpfc_sli4_queue_create()
10771 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10773 cpu); in lpfc_sli4_queue_create()
10780 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10781 phba->sli4_hba.nvmet_mrq_data[idx] = qdesc; in lpfc_sli4_queue_create()
10786 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10787 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10788 memset(&phba->sli4_hba.hdwq[idx].nvme_cstat, 0, in lpfc_sli4_queue_create()
10789 sizeof(phba->sli4_hba.hdwq[idx].nvme_cstat)); in lpfc_sli4_queue_create()
10794 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { in lpfc_sli4_queue_create()
10795 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10796 memset(&phba->sli4_hba.hdwq[idx].scsi_cstat, 0, in lpfc_sli4_queue_create()
10797 sizeof(phba->sli4_hba.hdwq[idx].scsi_cstat)); in lpfc_sli4_queue_create()
10805 return -ENOMEM; in lpfc_sli4_queue_create()
10839 hdwq = phba->sli4_hba.hdwq; in lpfc_sli4_release_hdwq()
10842 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_release_hdwq()
10849 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_release_hdwq()
10854 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_release_hdwq()
10856 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_sli4_release_hdwq()
10858 phba->sli4_hba.hba_eq_hdl[idx].eq = NULL; in lpfc_sli4_release_hdwq()
10863 * lpfc_sli4_queue_destroy - Destroy all the SLI4 queues
10870 * 0 - successful
10871 * -ENOMEM - No available memory
10872 * -EIO - The mailbox failed to complete successfully.
10882 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10883 phba->sli.sli_flag |= LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
10884 while (phba->sli.sli_flag & LPFC_QUEUE_FREE_WAIT) { in lpfc_sli4_queue_destroy()
10885 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10887 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10889 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10894 if (phba->sli4_hba.hdwq) in lpfc_sli4_queue_destroy()
10897 if (phba->nvmet_support) { in lpfc_sli4_queue_destroy()
10898 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_destroy()
10899 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10901 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_destroy()
10902 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10903 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_destroy()
10904 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10908 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_destroy()
10911 __lpfc_sli4_release_queue(&phba->sli4_hba.els_wq); in lpfc_sli4_queue_destroy()
10914 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_destroy()
10917 __lpfc_sli4_release_queue(&phba->sli4_hba.hdr_rq); in lpfc_sli4_queue_destroy()
10918 __lpfc_sli4_release_queue(&phba->sli4_hba.dat_rq); in lpfc_sli4_queue_destroy()
10921 __lpfc_sli4_release_queue(&phba->sli4_hba.els_cq); in lpfc_sli4_queue_destroy()
10924 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_destroy()
10927 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_destroy()
10930 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_destroy()
10933 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10934 phba->sli.sli_flag &= ~LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
10935 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10945 rqbp = rq->rqbp; in lpfc_free_rq_buffer()
10946 while (!list_empty(&rqbp->rqb_buffer_list)) { in lpfc_free_rq_buffer()
10947 list_remove_head(&rqbp->rqb_buffer_list, h_buf, in lpfc_free_rq_buffer()
10951 (rqbp->rqb_free_buffer)(phba, rqb_buffer); in lpfc_free_rq_buffer()
10952 rqbp->buffer_count--; in lpfc_free_rq_buffer()
10967 "6085 Fast-path %s (%d) not allocated\n", in lpfc_create_wq_cq()
10969 return -ENOMEM; in lpfc_create_wq_cq()
10985 *cq_map = cq->queue_id; in lpfc_create_wq_cq()
10988 "6087 CQ setup: cq[%d]-id=%d, parent eq[%d]-id=%d\n", in lpfc_create_wq_cq()
10989 qidx, cq->queue_id, qidx, eq->queue_id); in lpfc_create_wq_cq()
10997 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
11002 pring = wq->pring; in lpfc_create_wq_cq()
11003 pring->sli.sli4.wqp = (void *)wq; in lpfc_create_wq_cq()
11004 cq->pring = pring; in lpfc_create_wq_cq()
11007 "2593 WQ setup: wq[%d]-id=%d assoc=%d, cq[%d]-id=%d\n", in lpfc_create_wq_cq()
11008 qidx, wq->queue_id, wq->assoc_qid, qidx, cq->queue_id); in lpfc_create_wq_cq()
11013 "0539 Failed setup of slow-path MQ: " in lpfc_create_wq_cq()
11015 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
11020 "2589 MBX MQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_create_wq_cq()
11021 phba->sli4_hba.mbx_wq->queue_id, in lpfc_create_wq_cq()
11022 phba->sli4_hba.mbx_cq->queue_id); in lpfc_create_wq_cq()
11029 * lpfc_setup_cq_lookup - Setup the CQ lookup table
11041 memset(phba->sli4_hba.cq_lookup, 0, in lpfc_setup_cq_lookup()
11042 (sizeof(struct lpfc_queue *) * (phba->sli4_hba.cq_max + 1))); in lpfc_setup_cq_lookup()
11044 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_setup_cq_lookup()
11046 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_setup_cq_lookup()
11050 list_for_each_entry(childq, &eq->child_list, list) { in lpfc_setup_cq_lookup()
11051 if (childq->queue_id > phba->sli4_hba.cq_max) in lpfc_setup_cq_lookup()
11053 if (childq->subtype == LPFC_IO) in lpfc_setup_cq_lookup()
11054 phba->sli4_hba.cq_lookup[childq->queue_id] = in lpfc_setup_cq_lookup()
11061 * lpfc_sli4_queue_setup - Set up all the SLI4 queues
11068 * 0 - successful
11069 * -ENOMEM - No available memory
11070 * -EIO - The mailbox failed to complete successfully.
11080 int qidx, cpu; in lpfc_sli4_queue_setup() local
11082 int rc = -ENOMEM; in lpfc_sli4_queue_setup()
11084 /* Check for dual-ULP support */ in lpfc_sli4_queue_setup()
11085 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_queue_setup()
11090 return -ENOMEM; in lpfc_sli4_queue_setup()
11092 length = (sizeof(struct lpfc_mbx_query_fw_config) - in lpfc_sli4_queue_setup()
11101 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_queue_setup()
11102 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_queue_setup()
11103 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_queue_setup()
11109 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
11110 rc = -ENXIO; in lpfc_sli4_queue_setup()
11114 phba->sli4_hba.fw_func_mode = in lpfc_sli4_queue_setup()
11115 mboxq->u.mqe.un.query_fw_cfg.rsp.function_mode; in lpfc_sli4_queue_setup()
11116 phba->sli4_hba.ulp0_mode = mboxq->u.mqe.un.query_fw_cfg.rsp.ulp0_mode; in lpfc_sli4_queue_setup()
11117 phba->sli4_hba.ulp1_mode = mboxq->u.mqe.un.query_fw_cfg.rsp.ulp1_mode; in lpfc_sli4_queue_setup()
11118 phba->sli4_hba.physical_port = in lpfc_sli4_queue_setup()
11119 mboxq->u.mqe.un.query_fw_cfg.rsp.physical_port; in lpfc_sli4_queue_setup()
11122 "ulp1_mode:x%x\n", phba->sli4_hba.fw_func_mode, in lpfc_sli4_queue_setup()
11123 phba->sli4_hba.ulp0_mode, phba->sli4_hba.ulp1_mode); in lpfc_sli4_queue_setup()
11125 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
11130 qp = phba->sli4_hba.hdwq; in lpfc_sli4_queue_setup()
11135 "3147 Fast-path EQs not allocated\n"); in lpfc_sli4_queue_setup()
11136 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11141 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_setup()
11143 for_each_present_cpu(cpu) { in lpfc_sli4_queue_setup()
11144 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
11146 /* Look for the CPU thats using that vector with in lpfc_sli4_queue_setup()
11149 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_setup()
11151 if (qidx != cpup->eq) in lpfc_sli4_queue_setup()
11155 rc = lpfc_eq_create(phba, qp[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
11156 phba->cfg_fcp_imax); in lpfc_sli4_queue_setup()
11159 "0523 Failed setup of fast-path" in lpfc_sli4_queue_setup()
11161 cpup->eq, (uint32_t)rc); in lpfc_sli4_queue_setup()
11166 phba->sli4_hba.hba_eq_hdl[cpup->eq].eq = in lpfc_sli4_queue_setup()
11167 qp[cpup->hdwq].hba_eq; in lpfc_sli4_queue_setup()
11170 "2584 HBA EQ setup: queue[%d]-id=%d\n", in lpfc_sli4_queue_setup()
11171 cpup->eq, in lpfc_sli4_queue_setup()
11172 qp[cpup->hdwq].hba_eq->queue_id); in lpfc_sli4_queue_setup()
11177 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_setup()
11178 cpu = lpfc_find_cpu_handle(phba, qidx, LPFC_FIND_BY_HDWQ); in lpfc_sli4_queue_setup()
11179 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
11183 phba->sli4_hba.hdwq[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
11186 &phba->sli4_hba.hdwq[qidx].io_cq_map, in lpfc_sli4_queue_setup()
11202 /* Set up slow-path MBOX CQ/MQ */ in lpfc_sli4_queue_setup()
11204 if (!phba->sli4_hba.mbx_cq || !phba->sli4_hba.mbx_wq) { in lpfc_sli4_queue_setup()
11207 phba->sli4_hba.mbx_cq ? in lpfc_sli4_queue_setup()
11209 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11214 phba->sli4_hba.mbx_cq, in lpfc_sli4_queue_setup()
11215 phba->sli4_hba.mbx_wq, in lpfc_sli4_queue_setup()
11223 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
11224 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_setup()
11226 "3165 Fast-path NVME CQ Set " in lpfc_sli4_queue_setup()
11228 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11231 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
11233 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
11245 rc = lpfc_cq_create(phba, phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
11254 phba->sli4_hba.nvmet_cqset[0]->chann = 0; in lpfc_sli4_queue_setup()
11257 "6090 NVMET CQ setup: cq-id=%d, " in lpfc_sli4_queue_setup()
11258 "parent eq-id=%d\n", in lpfc_sli4_queue_setup()
11259 phba->sli4_hba.nvmet_cqset[0]->queue_id, in lpfc_sli4_queue_setup()
11260 qp[0].hba_eq->queue_id); in lpfc_sli4_queue_setup()
11264 /* Set up slow-path ELS WQ/CQ */ in lpfc_sli4_queue_setup()
11265 if (!phba->sli4_hba.els_cq || !phba->sli4_hba.els_wq) { in lpfc_sli4_queue_setup()
11268 phba->sli4_hba.els_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
11269 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11273 phba->sli4_hba.els_cq, in lpfc_sli4_queue_setup()
11274 phba->sli4_hba.els_wq, in lpfc_sli4_queue_setup()
11283 "2590 ELS WQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11284 phba->sli4_hba.els_wq->queue_id, in lpfc_sli4_queue_setup()
11285 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
11287 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_setup()
11289 if (!phba->sli4_hba.nvmels_cq || !phba->sli4_hba.nvmels_wq) { in lpfc_sli4_queue_setup()
11292 phba->sli4_hba.nvmels_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
11293 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11297 phba->sli4_hba.nvmels_cq, in lpfc_sli4_queue_setup()
11298 phba->sli4_hba.nvmels_wq, in lpfc_sli4_queue_setup()
11308 "6096 ELS WQ setup: wq-id=%d, " in lpfc_sli4_queue_setup()
11309 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11310 phba->sli4_hba.nvmels_wq->queue_id, in lpfc_sli4_queue_setup()
11311 phba->sli4_hba.nvmels_cq->queue_id); in lpfc_sli4_queue_setup()
11317 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
11318 if ((!phba->sli4_hba.nvmet_cqset) || in lpfc_sli4_queue_setup()
11319 (!phba->sli4_hba.nvmet_mrq_hdr) || in lpfc_sli4_queue_setup()
11320 (!phba->sli4_hba.nvmet_mrq_data)) { in lpfc_sli4_queue_setup()
11324 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11327 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
11329 phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_setup()
11330 phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_setup()
11331 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
11343 phba->sli4_hba.nvmet_mrq_hdr[0], in lpfc_sli4_queue_setup()
11344 phba->sli4_hba.nvmet_mrq_data[0], in lpfc_sli4_queue_setup()
11345 phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
11357 "6099 NVMET RQ setup: hdr-rq-id=%d, " in lpfc_sli4_queue_setup()
11358 "dat-rq-id=%d parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11359 phba->sli4_hba.nvmet_mrq_hdr[0]->queue_id, in lpfc_sli4_queue_setup()
11360 phba->sli4_hba.nvmet_mrq_data[0]->queue_id, in lpfc_sli4_queue_setup()
11361 phba->sli4_hba.nvmet_cqset[0]->queue_id); in lpfc_sli4_queue_setup()
11366 if (!phba->sli4_hba.hdr_rq || !phba->sli4_hba.dat_rq) { in lpfc_sli4_queue_setup()
11369 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11373 rc = lpfc_rq_create(phba, phba->sli4_hba.hdr_rq, phba->sli4_hba.dat_rq, in lpfc_sli4_queue_setup()
11374 phba->sli4_hba.els_cq, LPFC_USOL); in lpfc_sli4_queue_setup()
11383 "2592 USL RQ setup: hdr-rq-id=%d, dat-rq-id=%d " in lpfc_sli4_queue_setup()
11384 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11385 phba->sli4_hba.hdr_rq->queue_id, in lpfc_sli4_queue_setup()
11386 phba->sli4_hba.dat_rq->queue_id, in lpfc_sli4_queue_setup()
11387 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
11389 if (phba->cfg_fcp_imax) in lpfc_sli4_queue_setup()
11390 usdelay = LPFC_SEC_TO_USEC / phba->cfg_fcp_imax; in lpfc_sli4_queue_setup()
11394 for (qidx = 0; qidx < phba->cfg_irq_chann; in lpfc_sli4_queue_setup()
11399 if (phba->sli4_hba.cq_max) { in lpfc_sli4_queue_setup()
11400 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_setup()
11401 phba->sli4_hba.cq_lookup = kcalloc((phba->sli4_hba.cq_max + 1), in lpfc_sli4_queue_setup()
11403 if (!phba->sli4_hba.cq_lookup) { in lpfc_sli4_queue_setup()
11406 "size 0x%x\n", phba->sli4_hba.cq_max); in lpfc_sli4_queue_setup()
11407 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11421 * lpfc_sli4_queue_unset - Unset all the SLI4 queues
11428 * 0 - successful
11429 * -ENOMEM - No available memory
11430 * -EIO - The mailbox failed to complete successfully.
11440 if (phba->sli4_hba.mbx_wq) in lpfc_sli4_queue_unset()
11441 lpfc_mq_destroy(phba, phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_unset()
11444 if (phba->sli4_hba.nvmels_wq) in lpfc_sli4_queue_unset()
11445 lpfc_wq_destroy(phba, phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_unset()
11448 if (phba->sli4_hba.els_wq) in lpfc_sli4_queue_unset()
11449 lpfc_wq_destroy(phba, phba->sli4_hba.els_wq); in lpfc_sli4_queue_unset()
11452 if (phba->sli4_hba.hdr_rq) in lpfc_sli4_queue_unset()
11453 lpfc_rq_destroy(phba, phba->sli4_hba.hdr_rq, in lpfc_sli4_queue_unset()
11454 phba->sli4_hba.dat_rq); in lpfc_sli4_queue_unset()
11457 if (phba->sli4_hba.mbx_cq) in lpfc_sli4_queue_unset()
11458 lpfc_cq_destroy(phba, phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_unset()
11461 if (phba->sli4_hba.els_cq) in lpfc_sli4_queue_unset()
11462 lpfc_cq_destroy(phba, phba->sli4_hba.els_cq); in lpfc_sli4_queue_unset()
11465 if (phba->sli4_hba.nvmels_cq) in lpfc_sli4_queue_unset()
11466 lpfc_cq_destroy(phba, phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_unset()
11468 if (phba->nvmet_support) { in lpfc_sli4_queue_unset()
11470 if (phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_unset()
11471 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
11474 phba->sli4_hba.nvmet_mrq_hdr[qidx], in lpfc_sli4_queue_unset()
11475 phba->sli4_hba.nvmet_mrq_data[qidx]); in lpfc_sli4_queue_unset()
11479 if (phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_unset()
11480 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
11482 phba, phba->sli4_hba.nvmet_cqset[qidx]); in lpfc_sli4_queue_unset()
11486 /* Unset fast-path SLI4 queues */ in lpfc_sli4_queue_unset()
11487 if (phba->sli4_hba.hdwq) { in lpfc_sli4_queue_unset()
11489 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_unset()
11491 qp = &phba->sli4_hba.hdwq[qidx]; in lpfc_sli4_queue_unset()
11492 lpfc_wq_destroy(phba, qp->io_wq); in lpfc_sli4_queue_unset()
11493 lpfc_cq_destroy(phba, qp->io_cq); in lpfc_sli4_queue_unset()
11496 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_unset()
11498 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_sli4_queue_unset()
11503 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_unset()
11504 phba->sli4_hba.cq_lookup = NULL; in lpfc_sli4_queue_unset()
11505 phba->sli4_hba.cq_max = 0; in lpfc_sli4_queue_unset()
11509 * lpfc_sli4_cq_event_pool_create - Create completion-queue event free pool
11516 * - Mailbox asynchronous events
11517 * - Receive queue completion unsolicited events
11518 * Later, this can be used for all the slow-path events.
11521 * 0 - successful
11522 * -ENOMEM - No available memory
11530 for (i = 0; i < (4 * phba->sli4_hba.cq_ecount); i++) { in lpfc_sli4_cq_event_pool_create()
11534 list_add_tail(&cq_event->list, in lpfc_sli4_cq_event_pool_create()
11535 &phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_cq_event_pool_create()
11541 return -ENOMEM; in lpfc_sli4_cq_event_pool_create()
11545 * lpfc_sli4_cq_event_pool_destroy - Free completion-queue event free pool
11550 * cleanup routine to free all the outstanding completion-queue events
11560 &phba->sli4_hba.sp_cqe_event_pool, list) { in lpfc_sli4_cq_event_pool_destroy()
11561 list_del(&cq_event->list); in lpfc_sli4_cq_event_pool_destroy()
11567 * __lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
11571 * completion-queue event from the free pool.
11573 * Return: Pointer to the newly allocated completion-queue event if successful
11581 list_remove_head(&phba->sli4_hba.sp_cqe_event_pool, cq_event, in __lpfc_sli4_cq_event_alloc()
11587 * lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
11591 * completion-queue event from the free pool.
11593 * Return: Pointer to the newly allocated completion-queue event if successful
11602 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
11604 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
11609 * __lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
11614 * completion-queue event back into the free pool.
11620 list_add_tail(&cq_event->list, &phba->sli4_hba.sp_cqe_event_pool); in __lpfc_sli4_cq_event_release()
11624 * lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
11629 * completion-queue event back into the free pool.
11636 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
11638 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
11642 * lpfc_sli4_cq_event_release_all - Release all cq events to the free pool
11645 * This routine is to free all the pending completion-queue events to the
11658 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11659 list_splice_init(&phba->sli4_hba.sp_els_xri_aborted_work_queue, in lpfc_sli4_cq_event_release_all()
11661 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11664 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11665 list_splice_init(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_cq_event_release_all()
11667 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11677 * lpfc_pci_function_reset - Reset pci function.
11684 * 0 - successful
11685 * -ENOMEM - No available memory
11686 * -EIO - The mailbox failed to complete successfully.
11700 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_pci_function_reset()
11703 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_pci_function_reset()
11710 return -ENOMEM; in lpfc_pci_function_reset()
11713 /* Setup PCI function reset mailbox-ioctl command */ in lpfc_pci_function_reset()
11719 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_pci_function_reset()
11720 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_pci_function_reset()
11722 &shdr->response); in lpfc_pci_function_reset()
11723 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_pci_function_reset()
11730 rc = -ENXIO; in lpfc_pci_function_reset()
11742 if (lpfc_readl(phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
11744 rc = -ENODEV; in lpfc_pci_function_reset()
11753 phba->work_status[0] = readl( in lpfc_pci_function_reset()
11754 phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_pci_function_reset()
11755 phba->work_status[1] = readl( in lpfc_pci_function_reset()
11756 phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_pci_function_reset()
11761 phba->work_status[0], in lpfc_pci_function_reset()
11762 phba->work_status[1]); in lpfc_pci_function_reset()
11763 rc = -ENODEV; in lpfc_pci_function_reset()
11779 writel(reg_data.word0, phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
11782 pci_read_config_word(phba->pcidev, in lpfc_pci_function_reset()
11789 rc = -ENODEV; in lpfc_pci_function_reset()
11800 /* Catch the not-ready port failure after a port reset. */ in lpfc_pci_function_reset()
11805 rc = -ENODEV; in lpfc_pci_function_reset()
11812 * lpfc_sli4_pci_mem_setup - Setup SLI4 HBA PCI memory space.
11816 * with SLI-4 interface spec.
11819 * 0 - successful
11820 * other values - error
11825 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_pci_mem_setup()
11831 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11834 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli4_pci_mem_setup()
11836 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli4_pci_mem_setup()
11845 &phba->sli4_hba.sli_intf.word0)) { in lpfc_sli4_pci_mem_setup()
11846 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11850 if (bf_get(lpfc_sli_intf_valid, &phba->sli4_hba.sli_intf) != in lpfc_sli4_pci_mem_setup()
11855 phba->sli4_hba.sli_intf.word0); in lpfc_sli4_pci_mem_setup()
11856 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11859 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_setup()
11867 phba->pci_bar0_map = pci_resource_start(pdev, PCI_64BIT_BAR0); in lpfc_sli4_pci_mem_setup()
11874 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11875 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
11876 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11877 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11880 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11882 phba->pci_bar0_memmap_p = phba->sli4_hba.conf_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11886 phba->pci_bar0_map = pci_resource_start(pdev, 1); in lpfc_sli4_pci_mem_setup()
11889 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11890 "FATAL - No BAR0 mapping for SLI4, if_type 2\n"); in lpfc_sli4_pci_mem_setup()
11891 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11893 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11894 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
11895 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11896 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11899 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11910 phba->pci_bar1_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
11913 phba->sli4_hba.ctrl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11914 ioremap(phba->pci_bar1_map, in lpfc_sli4_pci_mem_setup()
11916 if (!phba->sli4_hba.ctrl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11917 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11920 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11923 phba->pci_bar2_memmap_p = in lpfc_sli4_pci_mem_setup()
11924 phba->sli4_hba.ctrl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11927 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11938 phba->pci_bar1_map = pci_resource_start(pdev, PCI_64BIT_BAR2); in lpfc_sli4_pci_mem_setup()
11940 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11941 ioremap(phba->pci_bar1_map, bar1map_len); in lpfc_sli4_pci_mem_setup()
11942 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11943 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11945 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11948 phba->pci_bar2_memmap_p = phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11958 phba->pci_bar2_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
11961 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11962 ioremap(phba->pci_bar2_map, in lpfc_sli4_pci_mem_setup()
11964 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11965 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11968 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11971 phba->pci_bar4_memmap_p = in lpfc_sli4_pci_mem_setup()
11972 phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11977 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11988 phba->pci_bar2_map = pci_resource_start(pdev, PCI_64BIT_BAR4); in lpfc_sli4_pci_mem_setup()
11990 phba->sli4_hba.dpp_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11991 ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli4_pci_mem_setup()
11992 if (!phba->sli4_hba.dpp_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11993 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11995 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11998 phba->pci_bar4_memmap_p = phba->sli4_hba.dpp_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
12005 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
12006 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_write_eq_db; in lpfc_sli4_pci_mem_setup()
12007 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_write_cq_db; in lpfc_sli4_pci_mem_setup()
12010 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_if6_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
12011 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_if6_write_eq_db; in lpfc_sli4_pci_mem_setup()
12012 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_if6_write_cq_db; in lpfc_sli4_pci_mem_setup()
12021 if (phba->sli4_hba.drbl_regs_memmap_p) in lpfc_sli4_pci_mem_setup()
12022 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12024 if (phba->sli4_hba.ctrl_regs_memmap_p) in lpfc_sli4_pci_mem_setup()
12025 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12027 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12033 * lpfc_sli4_pci_mem_unset - Unset SLI4 HBA PCI memory space.
12037 * with SLI-4 interface spec.
12043 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_unset()
12047 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12048 iounmap(phba->sli4_hba.ctrl_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.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12055 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12056 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12057 if (phba->sli4_hba.dpp_regs_memmap_p) in lpfc_sli4_pci_mem_unset()
12058 iounmap(phba->sli4_hba.dpp_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12063 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_pci_mem_unset()
12064 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_pci_mem_unset()
12071 * lpfc_sli_enable_msix - Enable MSI-X interrupt mode on SLI-3 device
12074 * This routine is invoked to enable the MSI-X interrupt vectors to device
12075 * with SLI-3 interface specs.
12078 * 0 - successful
12079 * other values - error
12087 /* Set up MSI-X multi-message vectors */ in lpfc_sli_enable_msix()
12088 rc = pci_alloc_irq_vectors(phba->pcidev, in lpfc_sli_enable_msix()
12092 "0420 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli_enable_msix()
12097 * Assign MSI-X vectors to interrupt handlers in lpfc_sli_enable_msix()
12100 /* vector-0 is associated to slow-path handler */ in lpfc_sli_enable_msix()
12101 rc = request_irq(pci_irq_vector(phba->pcidev, 0), in lpfc_sli_enable_msix()
12106 "0421 MSI-X slow-path request_irq failed " in lpfc_sli_enable_msix()
12111 /* vector-1 is associated to fast-path handler */ in lpfc_sli_enable_msix()
12112 rc = request_irq(pci_irq_vector(phba->pcidev, 1), in lpfc_sli_enable_msix()
12118 "0429 MSI-X fast-path request_irq failed " in lpfc_sli_enable_msix()
12124 * Configure HBA MSI-X attention conditions to messages in lpfc_sli_enable_msix()
12126 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_enable_msix()
12129 rc = -ENOMEM; in lpfc_sli_enable_msix()
12143 pmb->u.mb.mbxCommand, pmb->u.mb.mbxStatus); in lpfc_sli_enable_msix()
12148 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
12153 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
12157 free_irq(pci_irq_vector(phba->pcidev, 1), phba); in lpfc_sli_enable_msix()
12161 free_irq(pci_irq_vector(phba->pcidev, 0), phba); in lpfc_sli_enable_msix()
12164 /* Unconfigure MSI-X capability structure */ in lpfc_sli_enable_msix()
12165 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_enable_msix()
12172 * lpfc_sli_enable_msi - Enable MSI interrupt mode on SLI-3 device.
12176 * SLI-3 interface spec. The kernel function pci_enable_msi() is called to
12182 * 0 - successful
12183 * other values - error
12190 rc = pci_enable_msi(phba->pcidev); in lpfc_sli_enable_msi()
12200 rc = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_msi()
12203 pci_disable_msi(phba->pcidev); in lpfc_sli_enable_msi()
12211 * lpfc_sli_enable_intr - Enable device interrupt to SLI-3 device.
12213 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
12216 * interrupt handler(s) to interrupt vector(s) to device with SLI-3 interface
12221 * MSI-X -> MSI -> IRQ.
12224 * 0 - successful
12225 * other values - error
12237 phba->hba_flag &= ~HBA_NEEDS_CFG_PORT; in lpfc_sli_enable_intr()
12240 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli_enable_intr()
12243 /* Indicate initialization to MSI-X mode */ in lpfc_sli_enable_intr()
12244 phba->intr_type = MSIX; in lpfc_sli_enable_intr()
12249 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli_enable_intr()
12250 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli_enable_intr()
12254 phba->intr_type = MSI; in lpfc_sli_enable_intr()
12259 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli_enable_intr()
12260 if (phba->intr_type == NONE) { in lpfc_sli_enable_intr()
12261 retval = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_intr()
12265 phba->intr_type = INTx; in lpfc_sli_enable_intr()
12273 * lpfc_sli_disable_intr - Disable device interrupt to SLI-3 device.
12278 * SLI-3 interface spec. Depending on the interrupt mode, the driver will
12286 if (phba->intr_type == MSIX) in lpfc_sli_disable_intr()
12292 free_irq(pci_irq_vector(phba->pcidev, i), phba); in lpfc_sli_disable_intr()
12293 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_disable_intr()
12296 phba->intr_type = NONE; in lpfc_sli_disable_intr()
12297 phba->sli.slistat.sli_intr = 0; in lpfc_sli_disable_intr()
12301 * lpfc_find_cpu_handle - Find the CPU that corresponds to the specified Queue
12306 * Return the CPU that matches the selection criteria
12312 int cpu; in lpfc_find_cpu_handle() local
12315 for_each_present_cpu(cpu) { in lpfc_find_cpu_handle()
12316 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_find_cpu_handle()
12323 (cpup->flag & LPFC_CPU_FIRST_IRQ) && in lpfc_find_cpu_handle()
12324 (cpup->eq == id)) in lpfc_find_cpu_handle()
12325 return cpu; in lpfc_find_cpu_handle()
12327 /* If matching by HDWQ, select the first CPU that matches */ in lpfc_find_cpu_handle()
12328 if ((match == LPFC_FIND_BY_HDWQ) && (cpup->hdwq == id)) in lpfc_find_cpu_handle()
12329 return cpu; in lpfc_find_cpu_handle()
12336 * lpfc_find_hyper - Determine if the CPU map entry is hyper-threaded
12338 * @cpu: CPU map index
12339 * @phys_id: CPU package physical id
12340 * @core_id: CPU core id
12343 lpfc_find_hyper(struct lpfc_hba *phba, int cpu, in lpfc_find_hyper() argument
12350 cpup = &phba->sli4_hba.cpu_map[idx]; in lpfc_find_hyper()
12352 if ((cpup->phys_id == phys_id) && in lpfc_find_hyper()
12353 (cpup->core_id == core_id) && in lpfc_find_hyper()
12354 (cpu != idx)) in lpfc_find_hyper()
12362 * lpfc_assign_eq_map_info - Assigns eq for vector_map structure
12366 * @cpu: cpu used to index vector_map structure
12372 unsigned int cpu) in lpfc_assign_eq_map_info() argument
12374 struct lpfc_vector_map_info *cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_assign_eq_map_info()
12377 cpup->eq = eqidx; in lpfc_assign_eq_map_info()
12378 cpup->flag |= flag; in lpfc_assign_eq_map_info()
12381 "3336 Set Affinity: CPU %d irq %d eq %d flag x%x\n", in lpfc_assign_eq_map_info()
12382 cpu, eqhdl->irq, cpup->eq, cpup->flag); in lpfc_assign_eq_map_info()
12386 * lpfc_cpu_map_array_init - Initialize cpu_map structure
12396 int cpu; in lpfc_cpu_map_array_init() local
12398 for_each_possible_cpu(cpu) { in lpfc_cpu_map_array_init()
12399 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_map_array_init()
12400 cpup->phys_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12401 cpup->core_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12402 cpup->hdwq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12403 cpup->eq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12404 cpup->flag = 0; in lpfc_cpu_map_array_init()
12405 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, cpu); in lpfc_cpu_map_array_init()
12406 INIT_LIST_HEAD(&eqi->list); in lpfc_cpu_map_array_init()
12407 eqi->icnt = 0; in lpfc_cpu_map_array_init()
12412 * lpfc_hba_eq_hdl_array_init - Initialize hba_eq_hdl structure
12423 for (i = 0; i < phba->cfg_irq_chann; i++) { in lpfc_hba_eq_hdl_array_init()
12425 eqhdl->irq = LPFC_IRQ_EMPTY; in lpfc_hba_eq_hdl_array_init()
12426 eqhdl->phba = phba; in lpfc_hba_eq_hdl_array_init()
12431 * lpfc_cpu_affinity_check - Check vector CPU affinity mappings
12435 * The routine will figure out the CPU affinity assignment for every
12436 * MSI-X vector allocated for the HBA.
12437 * In addition, the CPU to IO channel mapping will be calculated
12438 * and the phba->sli4_hba.cpu_map array will reflect this.
12443 int i, cpu, idx, next_idx, new_cpu, start_cpu, first_cpu; in lpfc_cpu_affinity_check() local
12460 /* Update CPU map with physical id and core id of each CPU */ in lpfc_cpu_affinity_check()
12461 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
12462 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12464 cpuinfo = &cpu_data(cpu); in lpfc_cpu_affinity_check()
12465 cpup->phys_id = cpuinfo->phys_proc_id; in lpfc_cpu_affinity_check()
12466 cpup->core_id = cpuinfo->cpu_core_id; in lpfc_cpu_affinity_check()
12467 if (lpfc_find_hyper(phba, cpu, cpup->phys_id, cpup->core_id)) in lpfc_cpu_affinity_check()
12468 cpup->flag |= LPFC_CPU_MAP_HYPER; in lpfc_cpu_affinity_check()
12471 cpup->phys_id = 0; in lpfc_cpu_affinity_check()
12472 cpup->core_id = cpu; in lpfc_cpu_affinity_check()
12476 "3328 CPU %d physid %d coreid %d flag x%x\n", in lpfc_cpu_affinity_check()
12477 cpu, cpup->phys_id, cpup->core_id, cpup->flag); in lpfc_cpu_affinity_check()
12479 if (cpup->phys_id > max_phys_id) in lpfc_cpu_affinity_check()
12480 max_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
12481 if (cpup->phys_id < min_phys_id) in lpfc_cpu_affinity_check()
12482 min_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
12484 if (cpup->core_id > max_core_id) in lpfc_cpu_affinity_check()
12485 max_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
12486 if (cpup->core_id < min_core_id) in lpfc_cpu_affinity_check()
12487 min_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
12492 * Next we will set any unassigned (unaffinitized) cpu map in lpfc_cpu_affinity_check()
12498 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
12499 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12501 /* Is this CPU entry unassigned */ in lpfc_cpu_affinity_check()
12502 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
12503 /* Mark CPU as IRQ not assigned by the kernel */ in lpfc_cpu_affinity_check()
12504 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
12512 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12513 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12514 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
12515 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY) && in lpfc_cpu_affinity_check()
12516 (new_cpup->phys_id == cpup->phys_id)) in lpfc_cpu_affinity_check()
12520 /* At this point, we leave the CPU as unassigned */ in lpfc_cpu_affinity_check()
12524 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
12527 * chance of having multiple unassigned CPU entries in lpfc_cpu_affinity_check()
12533 "3337 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
12534 "eq %d from peer cpu %d same " in lpfc_cpu_affinity_check()
12536 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
12537 cpup->phys_id); in lpfc_cpu_affinity_check()
12541 /* Set any unassigned cpu map entries to a IRQ on any phys_id */ in lpfc_cpu_affinity_check()
12544 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
12545 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12548 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
12550 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
12558 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12559 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12560 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
12561 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY)) in lpfc_cpu_affinity_check()
12567 "3339 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
12569 cpup->hdwq, cpup->eq); in lpfc_cpu_affinity_check()
12573 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
12576 * chance of having multiple unassigned CPU entries in lpfc_cpu_affinity_check()
12582 "3338 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
12583 "eq %d from peer cpu %d (%d/%d)\n", in lpfc_cpu_affinity_check()
12584 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
12585 new_cpup->phys_id, new_cpup->core_id); in lpfc_cpu_affinity_check()
12593 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
12594 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12597 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_cpu_affinity_check()
12601 cpup->hdwq = idx; in lpfc_cpu_affinity_check()
12604 "3333 Set Affinity: CPU %d (phys %d core %d): " in lpfc_cpu_affinity_check()
12606 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
12607 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
12610 * This will be 1 to 1 - hdwq to cpu, unless there are less in lpfc_cpu_affinity_check()
12611 * hardware queues then CPUs. For that case we will just round-robin in lpfc_cpu_affinity_check()
12614 * for irq_chann < hdwq. The idx is used for round-robin assignments in lpfc_cpu_affinity_check()
12620 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
12621 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12624 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_cpu_affinity_check()
12631 if (next_idx < phba->cfg_hdw_queue) { in lpfc_cpu_affinity_check()
12632 cpup->hdwq = next_idx; in lpfc_cpu_affinity_check()
12637 /* Not a First CPU and all hdw_queues are used. Reuse a in lpfc_cpu_affinity_check()
12638 * Hardware Queue for another CPU, so be smart about it in lpfc_cpu_affinity_check()
12640 * (CPU package) and core_id. in lpfc_cpu_affinity_check()
12643 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12644 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12645 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
12646 new_cpup->phys_id == cpup->phys_id && in lpfc_cpu_affinity_check()
12647 new_cpup->core_id == cpup->core_id) { in lpfc_cpu_affinity_check()
12657 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12658 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12659 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
12660 new_cpup->phys_id == cpup->phys_id) in lpfc_cpu_affinity_check()
12666 cpup->hdwq = idx % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
12672 cpup->hdwq = new_cpup->hdwq; in lpfc_cpu_affinity_check()
12675 "3335 Set Affinity: CPU %d (phys %d core %d): " in lpfc_cpu_affinity_check()
12677 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
12678 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
12682 * Initialize the cpu_map slots for not-present cpus in case in lpfc_cpu_affinity_check()
12683 * a cpu is hot-added. Perform a simple hdwq round robin assignment. in lpfc_cpu_affinity_check()
12686 for_each_possible_cpu(cpu) { in lpfc_cpu_affinity_check()
12687 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12689 c_stat = per_cpu_ptr(phba->sli4_hba.c_stat, cpu); in lpfc_cpu_affinity_check()
12690 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
12692 if (cpup->hdwq != LPFC_VECTOR_MAP_EMPTY) in lpfc_cpu_affinity_check()
12695 cpup->hdwq = idx++ % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
12697 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
12701 "CPU %d hdwq %d\n", in lpfc_cpu_affinity_check()
12702 cpu, cpup->hdwq); in lpfc_cpu_affinity_check()
12715 * @cpu: cpu going offline
12719 lpfc_cpuhp_get_eq(struct lpfc_hba *phba, unsigned int cpu, in lpfc_cpuhp_get_eq() argument
12729 return -ENOMEM; in lpfc_cpuhp_get_eq()
12731 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_cpuhp_get_eq()
12732 maskp = pci_irq_get_affinity(phba->pcidev, idx); in lpfc_cpuhp_get_eq()
12736 * if irq is not affinitized to the cpu going in lpfc_cpuhp_get_eq()
12740 if (!cpumask_and(tmp, maskp, cpumask_of(cpu))) in lpfc_cpuhp_get_eq()
12742 /* get the cpus that are online and are affini- in lpfc_cpuhp_get_eq()
12744 * more than 1 then cpuhp is not going to shut- in lpfc_cpuhp_get_eq()
12745 * down this vector. Since this cpu has not in lpfc_cpuhp_get_eq()
12757 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_cpuhp_get_eq()
12758 list_add(&eq->_poll_list, eqlist); in lpfc_cpuhp_get_eq()
12766 if (phba->sli_rev != LPFC_SLI_REV4) in __lpfc_cpuhp_remove()
12770 &phba->cpuhp); in __lpfc_cpuhp_remove()
12776 del_timer_sync(&phba->cpuhp_poll_timer); in __lpfc_cpuhp_remove()
12781 if (phba->pport && (phba->pport->fc_flag & FC_OFFLINE_MODE)) in lpfc_cpuhp_remove()
12789 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_cpuhp_add()
12794 if (!list_empty(&phba->poll_list)) in lpfc_cpuhp_add()
12795 mod_timer(&phba->cpuhp_poll_timer, in lpfc_cpuhp_add()
12801 &phba->cpuhp); in lpfc_cpuhp_add()
12806 if (phba->pport->load_flag & FC_UNLOADING) { in __lpfc_cpuhp_checks()
12807 *retval = -EAGAIN; in __lpfc_cpuhp_checks()
12811 if (phba->sli_rev != LPFC_SLI_REV4) { in __lpfc_cpuhp_checks()
12821 * lpfc_irq_set_aff - set IRQ affinity
12823 * @cpu: cpu to set affinity
12827 lpfc_irq_set_aff(struct lpfc_hba_eq_hdl *eqhdl, unsigned int cpu) in lpfc_irq_set_aff() argument
12829 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_set_aff()
12830 cpumask_set_cpu(cpu, &eqhdl->aff_mask); in lpfc_irq_set_aff()
12831 irq_set_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_set_aff()
12832 irq_set_affinity(eqhdl->irq, &eqhdl->aff_mask); in lpfc_irq_set_aff()
12836 * lpfc_irq_clear_aff - clear IRQ affinity
12843 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_clear_aff()
12844 irq_clear_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_clear_aff()
12848 * lpfc_irq_rebalance - rebalances IRQ affinity according to cpuhp event
12850 * @cpu: cpu going offline/online
12851 * @offline: true, cpu is going offline. false, cpu is coming online.
12853 * If cpu is going offline, we'll try our best effort to find the next
12854 * online cpu on the phba's original_mask and migrate all offlining IRQ
12857 * If cpu is coming online, reaffinitize the IRQ back to the onlining cpu.
12860 * PCI_IRQ_AFFINITY to auto-manage IRQ affinity.
12864 lpfc_irq_rebalance(struct lpfc_hba *phba, unsigned int cpu, bool offline) in lpfc_irq_rebalance() argument
12871 if (phba->irq_chann_mode == NORMAL_MODE) in lpfc_irq_rebalance()
12874 orig_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_irq_rebalance()
12876 if (!cpumask_test_cpu(cpu, orig_mask)) in lpfc_irq_rebalance()
12879 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_irq_rebalance()
12881 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_irq_rebalance()
12885 /* Find next online CPU on original mask */ in lpfc_irq_rebalance()
12886 cpu_next = cpumask_next_wrap(cpu, orig_mask, cpu, true); in lpfc_irq_rebalance()
12889 /* Found a valid CPU */ in lpfc_irq_rebalance()
12890 if ((cpu_select < nr_cpu_ids) && (cpu_select != cpu)) { in lpfc_irq_rebalance()
12892 * cpu aff_mask is migrated in lpfc_irq_rebalance()
12894 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_irq_rebalance()
12898 if (cpumask_test_cpu(cpu, aff_mask)) in lpfc_irq_rebalance()
12904 for (idx = 0; idx < phba->cfg_irq_chann; idx++) in lpfc_irq_rebalance()
12908 /* Migrate affinity back to this CPU */ in lpfc_irq_rebalance()
12909 lpfc_irq_set_aff(lpfc_get_eq_hdl(cpup->eq), cpu); in lpfc_irq_rebalance()
12913 static int lpfc_cpu_offline(unsigned int cpu, struct hlist_node *node) in lpfc_cpu_offline() argument
12921 WARN_ONCE(!phba, "cpu: %u. phba:NULL", raw_smp_processor_id()); in lpfc_cpu_offline()
12928 lpfc_irq_rebalance(phba, cpu, true); in lpfc_cpu_offline()
12930 retval = lpfc_cpuhp_get_eq(phba, cpu, &eqlist); in lpfc_cpu_offline()
12936 list_del_init(&eq->_poll_list); in lpfc_cpu_offline()
12943 static int lpfc_cpu_online(unsigned int cpu, struct hlist_node *node) in lpfc_cpu_online() argument
12951 WARN_ONCE(!phba, "cpu: %u. phba:NULL", raw_smp_processor_id()); in lpfc_cpu_online()
12958 lpfc_irq_rebalance(phba, cpu, false); in lpfc_cpu_online()
12960 list_for_each_entry_safe(eq, next, &phba->poll_list, _poll_list) { in lpfc_cpu_online()
12961 n = lpfc_find_cpu_handle(phba, eq->hdwq, LPFC_FIND_BY_HDWQ); in lpfc_cpu_online()
12962 if (n == cpu) in lpfc_cpu_online()
12970 * lpfc_sli4_enable_msix - Enable MSI-X interrupt mode to SLI-4 device
12973 * This routine is invoked to enable the MSI-X interrupt vectors to device
12974 * with SLI-4 interface spec. It also allocates MSI-X vectors and maps them
12980 * allocated and assigned to each online and offline cpu. If the cpu is
12981 * online, then affinity will be set to that cpu. If the cpu is offline, then
12982 * affinity will be set to the nearest peer cpu within the numa node that is
12984 * assigned and the OS may do as it pleases. Note: cpu vector affinity mapping
12985 * is consistent with the way cpu online/offline is handled when cfg_irq_numa is
12990 * cpu affinity. The driver will then use that affinity mapping to setup its
12991 * cpu mapping table.
12994 * 0 - successful
12995 * other values - error
13003 unsigned int cpu = 0, cpu_cnt = 0, cpu_select = nr_cpu_ids; in lpfc_sli4_enable_msix() local
13009 /* Set up MSI-X multi-message vectors */ in lpfc_sli4_enable_msix()
13010 vectors = phba->cfg_irq_chann; in lpfc_sli4_enable_msix()
13012 if (phba->irq_chann_mode != NORMAL_MODE) in lpfc_sli4_enable_msix()
13013 aff_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_sli4_enable_msix()
13017 vectors = min(phba->cfg_irq_chann, cpu_cnt); in lpfc_sli4_enable_msix()
13019 /* cpu: iterates over aff_mask including offline or online in lpfc_sli4_enable_msix()
13022 cpu = cpumask_first(aff_mask); in lpfc_sli4_enable_msix()
13023 cpu_select = lpfc_next_online_cpu(aff_mask, cpu); in lpfc_sli4_enable_msix()
13028 rc = pci_alloc_irq_vectors(phba->pcidev, 1, vectors, flags); in lpfc_sli4_enable_msix()
13031 "0484 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli4_enable_msix()
13036 /* Assign MSI-X vectors to interrupt handlers */ in lpfc_sli4_enable_msix()
13039 name = eqhdl->handler_name; in lpfc_sli4_enable_msix()
13044 eqhdl->idx = index; in lpfc_sli4_enable_msix()
13045 rc = pci_irq_vector(phba->pcidev, index); in lpfc_sli4_enable_msix()
13048 "0489 MSI-X fast-path (%d) " in lpfc_sli4_enable_msix()
13052 eqhdl->irq = rc; in lpfc_sli4_enable_msix()
13054 rc = request_threaded_irq(eqhdl->irq, in lpfc_sli4_enable_msix()
13060 "0486 MSI-X fast-path (%d) " in lpfc_sli4_enable_msix()
13066 /* If found a neighboring online cpu, set affinity */ in lpfc_sli4_enable_msix()
13073 cpu); in lpfc_sli4_enable_msix()
13075 /* Iterate to next offline or online cpu in aff_mask */ in lpfc_sli4_enable_msix()
13076 cpu = cpumask_next(cpu, aff_mask); in lpfc_sli4_enable_msix()
13078 /* Find next online cpu in aff_mask to set affinity */ in lpfc_sli4_enable_msix()
13079 cpu_select = lpfc_next_online_cpu(aff_mask, cpu); in lpfc_sli4_enable_msix()
13081 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_msix()
13083 cpu); in lpfc_sli4_enable_msix()
13085 maskp = pci_irq_get_affinity(phba->pcidev, index); in lpfc_sli4_enable_msix()
13088 for_each_cpu_and(cpu, maskp, cpu_present_mask) { in lpfc_sli4_enable_msix()
13089 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_enable_msix()
13091 /* If this is the first CPU thats assigned to in lpfc_sli4_enable_msix()
13095 * vectors are affinitized to all the cpu's. in lpfc_sli4_enable_msix()
13103 if (cpup->eq != LPFC_VECTOR_MAP_EMPTY) in lpfc_sli4_enable_msix()
13107 cpu); in lpfc_sli4_enable_msix()
13113 if (vectors != phba->cfg_irq_chann) { in lpfc_sli4_enable_msix()
13116 "MSI-X vectors, requested %d got %d\n", in lpfc_sli4_enable_msix()
13117 phba->cfg_irq_chann, vectors); in lpfc_sli4_enable_msix()
13118 if (phba->cfg_irq_chann > vectors) in lpfc_sli4_enable_msix()
13119 phba->cfg_irq_chann = vectors; in lpfc_sli4_enable_msix()
13126 for (--index; index >= 0; index--) { in lpfc_sli4_enable_msix()
13129 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_enable_msix()
13132 /* Unconfigure MSI-X capability structure */ in lpfc_sli4_enable_msix()
13133 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msix()
13140 * lpfc_sli4_enable_msi - Enable MSI interrupt mode to SLI-4 device
13144 * SLI-4 interface spec. The kernel function pci_alloc_irq_vectors() is
13150 * 0 - successful
13151 * other values - error
13157 unsigned int cpu; in lpfc_sli4_enable_msi() local
13160 rc = pci_alloc_irq_vectors(phba->pcidev, 1, 1, in lpfc_sli4_enable_msi()
13168 return rc ? rc : -1; in lpfc_sli4_enable_msi()
13171 rc = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_msi()
13174 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msi()
13181 rc = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_msi()
13183 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_enable_msi()
13184 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msi()
13189 eqhdl->irq = rc; in lpfc_sli4_enable_msi()
13191 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_msi()
13192 lpfc_assign_eq_map_info(phba, 0, LPFC_CPU_FIRST_IRQ, cpu); in lpfc_sli4_enable_msi()
13194 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_enable_msi()
13196 eqhdl->idx = index; in lpfc_sli4_enable_msi()
13203 * lpfc_sli4_enable_intr - Enable device interrupt to SLI-4 device
13205 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
13208 * interrupt handler(s) to interrupt vector(s) to device with SLI-4
13213 * MSI-X -> MSI -> IRQ.
13216 * Interrupt mode (2, 1, 0) - successful
13217 * LPFC_INTR_ERROR - error
13229 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli4_enable_intr()
13232 /* Indicate initialization to MSI-X mode */ in lpfc_sli4_enable_intr()
13233 phba->intr_type = MSIX; in lpfc_sli4_enable_intr()
13239 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli4_enable_intr()
13240 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
13244 phba->intr_type = MSI; in lpfc_sli4_enable_intr()
13249 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli4_enable_intr()
13250 if (phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
13251 retval = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_intr()
13255 unsigned int cpu; in lpfc_sli4_enable_intr() local
13258 phba->intr_type = INTx; in lpfc_sli4_enable_intr()
13262 retval = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_intr()
13264 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_enable_intr()
13270 eqhdl->irq = retval; in lpfc_sli4_enable_intr()
13272 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_intr()
13274 cpu); in lpfc_sli4_enable_intr()
13275 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_enable_intr()
13277 eqhdl->idx = idx; in lpfc_sli4_enable_intr()
13285 * lpfc_sli4_disable_intr - Disable device interrupt to SLI-4 device
13290 * with SLI-4 interface spec. Depending on the interrupt mode, the driver
13297 if (phba->intr_type == MSIX) { in lpfc_sli4_disable_intr()
13301 /* Free up MSI-X multi-message vectors */ in lpfc_sli4_disable_intr()
13302 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_disable_intr()
13305 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_disable_intr()
13308 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_disable_intr()
13311 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_disable_intr()
13314 phba->intr_type = NONE; in lpfc_sli4_disable_intr()
13315 phba->sli.slistat.sli_intr = 0; in lpfc_sli4_disable_intr()
13319 * lpfc_unset_hba - Unset SLI3 hba device initialization
13323 * a device with SLI-3 interface spec.
13328 struct lpfc_vport *vport = phba->pport; in lpfc_unset_hba()
13331 spin_lock_irq(shost->host_lock); in lpfc_unset_hba()
13332 vport->load_flag |= FC_UNLOADING; in lpfc_unset_hba()
13333 spin_unlock_irq(shost->host_lock); in lpfc_unset_hba()
13335 kfree(phba->vpi_bmask); in lpfc_unset_hba()
13336 kfree(phba->vpi_ids); in lpfc_unset_hba()
13340 phba->pport->work_port_events = 0; in lpfc_unset_hba()
13352 * lpfc_sli4_xri_exchange_busy_wait - Wait for device XRI exchange busy
13372 int els_xri_cmpl = list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
13381 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_xri_exchange_busy_wait()
13385 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
13386 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
13387 io_xri_cmpl = list_empty(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
13394 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
13396 list_empty(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
13424 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
13425 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
13427 &qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
13434 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
13436 &phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
13439 list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
13445 * lpfc_sli4_hba_unset - Unset the fcoe hba
13459 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_hba_unset()
13462 hrtimer_cancel(&phba->cmf_stats_timer); in lpfc_sli4_hba_unset()
13463 hrtimer_cancel(&phba->cmf_timer); in lpfc_sli4_hba_unset()
13465 if (phba->pport) in lpfc_sli4_hba_unset()
13466 phba->sli4_hba.intr_enable = 0; in lpfc_sli4_hba_unset()
13474 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13475 phba->sli.sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_hba_unset()
13476 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13478 while (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
13484 if (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
13485 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13486 mboxq = phba->sli.mbox_active; in lpfc_sli4_hba_unset()
13487 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_hba_unset()
13489 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_hba_unset()
13490 phba->sli.mbox_active = NULL; in lpfc_sli4_hba_unset()
13491 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13497 if (!pci_channel_offline(phba->pcidev)) in lpfc_sli4_hba_unset()
13501 /* per-phba callback de-registration for hotplug event */ in lpfc_sli4_hba_unset()
13502 if (phba->pport) in lpfc_sli4_hba_unset()
13508 /* Disable SR-IOV if enabled */ in lpfc_sli4_hba_unset()
13509 if (phba->cfg_sriov_nr_virtfn) in lpfc_sli4_hba_unset()
13513 kthread_stop(phba->worker_thread); in lpfc_sli4_hba_unset()
13527 if (phba->ras_fwlog.ras_enabled) in lpfc_sli4_hba_unset()
13531 if (phba->pport) in lpfc_sli4_hba_unset()
13532 phba->pport->work_port_events = 0; in lpfc_sli4_hba_unset()
13593 "6235 INIT Congestion Buffer %p\n", phba->cgn_i); in lpfc_init_congestion_buf()
13595 if (!phba->cgn_i) in lpfc_init_congestion_buf()
13597 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_init_congestion_buf()
13599 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_init_congestion_buf()
13600 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_init_congestion_buf()
13601 atomic_set(&phba->cgn_sync_alarm_cnt, 0); in lpfc_init_congestion_buf()
13602 atomic_set(&phba->cgn_sync_warn_cnt, 0); in lpfc_init_congestion_buf()
13604 atomic_set(&phba->cgn_driver_evt_cnt, 0); in lpfc_init_congestion_buf()
13605 atomic_set(&phba->cgn_latency_evt_cnt, 0); in lpfc_init_congestion_buf()
13606 atomic64_set(&phba->cgn_latency_evt, 0); in lpfc_init_congestion_buf()
13607 phba->cgn_evt_minute = 0; in lpfc_init_congestion_buf()
13610 cp->cgn_info_size = cpu_to_le16(LPFC_CGN_INFO_SZ); in lpfc_init_congestion_buf()
13611 cp->cgn_info_version = LPFC_CGN_INFO_V4; in lpfc_init_congestion_buf()
13614 cp->cgn_info_mode = phba->cgn_p.cgn_param_mode; in lpfc_init_congestion_buf()
13615 cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0; in lpfc_init_congestion_buf()
13616 cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1; in lpfc_init_congestion_buf()
13617 cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2; in lpfc_init_congestion_buf()
13619 lpfc_cgn_update_tstamp(phba, &cp->base_time); in lpfc_init_congestion_buf()
13622 if (phba->pport) { in lpfc_init_congestion_buf()
13623 size = (uint16_t)(phba->pport->cfg_lun_queue_depth); in lpfc_init_congestion_buf()
13624 cp->cgn_lunq = cpu_to_le16(size); in lpfc_init_congestion_buf()
13629 cp->cgn_warn_freq = cpu_to_le16(LPFC_FPIN_INIT_FREQ); in lpfc_init_congestion_buf()
13630 cp->cgn_alarm_freq = cpu_to_le16(LPFC_FPIN_INIT_FREQ); in lpfc_init_congestion_buf()
13632 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_init_congestion_buf()
13634 phba->cgn_evt_timestamp = jiffies + in lpfc_init_congestion_buf()
13645 "6236 INIT Congestion Stat %p\n", phba->cgn_i); in lpfc_init_congestion_stat()
13647 if (!phba->cgn_i) in lpfc_init_congestion_stat()
13650 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_init_congestion_stat()
13651 memset(&cp->cgn_stat, 0, sizeof(cp->cgn_stat)); in lpfc_init_congestion_stat()
13653 lpfc_cgn_update_tstamp(phba, &cp->stat_start); in lpfc_init_congestion_stat()
13655 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_init_congestion_stat()
13659 * __lpfc_reg_congestion_buf - register congestion info buffer with HBA
13672 if (!phba->cgn_i) in __lpfc_reg_congestion_buf()
13673 return -ENXIO; in __lpfc_reg_congestion_buf()
13675 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in __lpfc_reg_congestion_buf()
13680 phba->pport->port_state, reg); in __lpfc_reg_congestion_buf()
13681 return -ENOMEM; in __lpfc_reg_congestion_buf()
13684 length = (sizeof(struct lpfc_mbx_reg_congestion_buf) - in __lpfc_reg_congestion_buf()
13689 reg_congestion_buf = &mboxq->u.mqe.un.reg_congestion_buf; in __lpfc_reg_congestion_buf()
13695 reg_congestion_buf->length = sizeof(struct lpfc_cgn_info); in __lpfc_reg_congestion_buf()
13696 reg_congestion_buf->addr_lo = in __lpfc_reg_congestion_buf()
13697 putPaddrLow(phba->cgn_i->phys); in __lpfc_reg_congestion_buf()
13698 reg_congestion_buf->addr_hi = in __lpfc_reg_congestion_buf()
13699 putPaddrHigh(phba->cgn_i->phys); in __lpfc_reg_congestion_buf()
13703 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in __lpfc_reg_congestion_buf()
13704 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in __lpfc_reg_congestion_buf()
13706 &shdr->response); in __lpfc_reg_congestion_buf()
13707 mempool_free(mboxq, phba->mbox_mem_pool); in __lpfc_reg_congestion_buf()
13714 return -ENXIO; in __lpfc_reg_congestion_buf()
13733 * lpfc_get_sli4_parameters - Get the SLI4 Config PARAMETERS.
13740 * This function may be be called from any context that can block-wait
13748 struct lpfc_mqe *mqe = &mboxq->u.mqe; in lpfc_get_sli4_parameters()
13760 phba->sli4_hba.rpi_hdrs_in_use = 1; in lpfc_get_sli4_parameters()
13763 length = (sizeof(struct lpfc_mbx_get_sli4_parameters) - in lpfc_get_sli4_parameters()
13768 if (!phba->sli4_hba.intr_enable) in lpfc_get_sli4_parameters()
13776 sli4_params = &phba->sli4_hba.pc_sli4_params; in lpfc_get_sli4_parameters()
13777 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters; in lpfc_get_sli4_parameters()
13778 sli4_params->if_type = bf_get(cfg_if_type, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13779 sli4_params->sli_rev = bf_get(cfg_sli_rev, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13780 sli4_params->sli_family = bf_get(cfg_sli_family, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13781 sli4_params->featurelevel_1 = bf_get(cfg_sli_hint_1, in lpfc_get_sli4_parameters()
13783 sli4_params->featurelevel_2 = bf_get(cfg_sli_hint_2, in lpfc_get_sli4_parameters()
13786 phba->sli3_options |= LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
13788 phba->sli3_options &= ~LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
13789 sli4_params->sge_supp_len = mbx_sli4_parameters->sge_supp_len; in lpfc_get_sli4_parameters()
13790 sli4_params->loopbk_scope = bf_get(cfg_loopbk_scope, in lpfc_get_sli4_parameters()
13792 sli4_params->oas_supported = bf_get(cfg_oas, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13793 sli4_params->cqv = bf_get(cfg_cqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13794 sli4_params->mqv = bf_get(cfg_mqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13795 sli4_params->wqv = bf_get(cfg_wqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13796 sli4_params->rqv = bf_get(cfg_rqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13797 sli4_params->eqav = bf_get(cfg_eqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13798 sli4_params->cqav = bf_get(cfg_cqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13799 sli4_params->wqsize = bf_get(cfg_wqsize, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13800 sli4_params->bv1s = bf_get(cfg_bv1s, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13801 sli4_params->pls = bf_get(cfg_pvl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13802 sli4_params->sgl_pages_max = bf_get(cfg_sgl_page_cnt, in lpfc_get_sli4_parameters()
13804 sli4_params->wqpcnt = bf_get(cfg_wqpcnt, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13805 sli4_params->sgl_pp_align = bf_get(cfg_sgl_pp_align, in lpfc_get_sli4_parameters()
13807 phba->sli4_hba.extents_in_use = bf_get(cfg_ext, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13808 phba->sli4_hba.rpi_hdrs_in_use = bf_get(cfg_hdrr, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13809 sli4_params->mi_cap = bf_get(cfg_mi_ver, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13811 /* Check for Extended Pre-Registered SGL support */ in lpfc_get_sli4_parameters()
13812 phba->cfg_xpsgl = bf_get(cfg_xpsgl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13820 sli4_params->nvme = 1; in lpfc_get_sli4_parameters()
13823 if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP) { in lpfc_get_sli4_parameters()
13827 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
13832 sli4_params->nvme = 0; in lpfc_get_sli4_parameters()
13833 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_get_sli4_parameters()
13839 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
13841 phba->nvmet_support = 0; in lpfc_get_sli4_parameters()
13842 phba->cfg_nvmet_mrq = 0; in lpfc_get_sli4_parameters()
13843 phba->cfg_nvme_seg_cnt = 0; in lpfc_get_sli4_parameters()
13846 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_get_sli4_parameters()
13847 return -ENODEV; in lpfc_get_sli4_parameters()
13848 phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; in lpfc_get_sli4_parameters()
13855 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_get_sli4_parameters()
13856 phba->cfg_sg_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_get_sli4_parameters()
13860 phba->cfg_enable_pbde = 1; in lpfc_get_sli4_parameters()
13862 phba->cfg_enable_pbde = 0; in lpfc_get_sli4_parameters()
13867 * In SLI4-Parameters Descriptor: in lpfc_get_sli4_parameters()
13872 if (phba->cfg_suppress_rsp && bf_get(cfg_xib, mbx_sli4_parameters) && in lpfc_get_sli4_parameters()
13874 phba->sli.sli_flag |= LPFC_SLI_SUPPRESS_RSP; in lpfc_get_sli4_parameters()
13876 phba->cfg_suppress_rsp = 0; in lpfc_get_sli4_parameters()
13879 phba->sli.sli_flag |= LPFC_SLI_USE_EQDR; in lpfc_get_sli4_parameters()
13882 if (sli4_params->sge_supp_len > LPFC_MAX_SGE_SIZE) in lpfc_get_sli4_parameters()
13883 sli4_params->sge_supp_len = LPFC_MAX_SGE_SIZE; in lpfc_get_sli4_parameters()
13885 rc = dma_set_max_seg_size(&phba->pcidev->dev, sli4_params->sge_supp_len); in lpfc_get_sli4_parameters()
13895 * to use this option, 128-byte WQEs must be used. in lpfc_get_sli4_parameters()
13898 phba->fcp_embed_io = 1; in lpfc_get_sli4_parameters()
13900 phba->fcp_embed_io = 0; in lpfc_get_sli4_parameters()
13905 phba->cfg_enable_pbde, in lpfc_get_sli4_parameters()
13906 phba->fcp_embed_io, sli4_params->nvme, in lpfc_get_sli4_parameters()
13907 phba->cfg_nvme_embed_cmd, phba->cfg_suppress_rsp); in lpfc_get_sli4_parameters()
13909 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
13911 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
13918 (sli4_params->wqsize & LPFC_WQ_SZ128_SUPPORT)) in lpfc_get_sli4_parameters()
13919 phba->enab_exp_wqcq_pages = 1; in lpfc_get_sli4_parameters()
13921 phba->enab_exp_wqcq_pages = 0; in lpfc_get_sli4_parameters()
13926 phba->mds_diags_support = 1; in lpfc_get_sli4_parameters()
13928 phba->mds_diags_support = 0; in lpfc_get_sli4_parameters()
13934 phba->nsler = 1; in lpfc_get_sli4_parameters()
13936 phba->nsler = 0; in lpfc_get_sli4_parameters()
13942 * lpfc_pci_probe_one_s3 - PCI probe func to reg SLI-3 device to PCI subsystem.
13946 * This routine is to be called to attach a device with SLI-3 interface spec
13947 * to the PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
13948 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
13955 * 0 - driver can claim the device
13956 * negative value - driver can not claim the device
13970 return -ENOMEM; in lpfc_pci_probe_one_s3()
13977 /* Set up SLI API function jump table for PCI-device group-0 HBAs */ in lpfc_pci_probe_one_s3()
13982 /* Set up SLI-3 specific device PCI memory space */ in lpfc_pci_probe_one_s3()
13990 /* Set up SLI-3 specific device driver resources */ in lpfc_pci_probe_one_s3()
14016 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s3()
14027 vport = phba->pport; in lpfc_pci_probe_one_s3()
14037 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s3()
14046 error = -ENODEV; in lpfc_pci_probe_one_s3()
14049 /* SLI-3 HBA setup */ in lpfc_pci_probe_one_s3()
14053 error = -ENODEV; in lpfc_pci_probe_one_s3()
14061 phba->sli.slistat.sli_intr > LPFC_MSIX_VECTORS) { in lpfc_pci_probe_one_s3()
14063 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s3()
14074 cfg_mode = --intr_mode; in lpfc_pci_probe_one_s3()
14110 * lpfc_pci_remove_one_s3 - PCI func to unreg SLI-3 device from PCI subsystem.
14113 * This routine is to be called to disattach a device with SLI-3 interface
14114 * spec from PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
14122 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s3()
14124 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s3()
14127 spin_lock_irq(&phba->hbalock); in lpfc_pci_remove_one_s3()
14128 vport->load_flag |= FC_UNLOADING; in lpfc_pci_remove_one_s3()
14129 spin_unlock_irq(&phba->hbalock); in lpfc_pci_remove_one_s3()
14136 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s3()
14137 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s3()
14139 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s3()
14159 kthread_stop(phba->worker_thread); in lpfc_pci_remove_one_s3()
14163 kfree(phba->vpi_bmask); in lpfc_pci_remove_one_s3()
14164 kfree(phba->vpi_ids); in lpfc_pci_remove_one_s3()
14167 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
14168 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s3()
14169 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
14173 /* Disable SR-IOV if enabled */ in lpfc_pci_remove_one_s3()
14174 if (phba->cfg_sriov_nr_virtfn) in lpfc_pci_remove_one_s3()
14191 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_pci_remove_one_s3()
14192 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_pci_remove_one_s3()
14195 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_pci_remove_one_s3()
14196 phba->slim2p.virt, phba->slim2p.phys); in lpfc_pci_remove_one_s3()
14199 iounmap(phba->ctrl_regs_memmap_p); in lpfc_pci_remove_one_s3()
14200 iounmap(phba->slim_memmap_p); in lpfc_pci_remove_one_s3()
14209 * lpfc_pci_suspend_one_s3 - PCI func to suspend SLI-3 device for power mgmnt
14213 * system Power Management (PM) to device with SLI-3 interface spec. When
14217 * minimum PM requirements to a power-aware driver's PM support for the
14218 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
14225 * 0 - driver suspended the device
14232 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s3()
14240 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s3()
14249 * lpfc_pci_resume_one_s3 - PCI func to resume SLI-3 device for power mgmnt
14253 * system Power Management (PM) to device with SLI-3 interface spec. When PM
14256 * driver implements the minimum PM requirements to a power-aware driver's
14257 * PM for suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE,
14264 * 0 - driver suspended the device
14271 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s3()
14279 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s3()
14280 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s3()
14281 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s3()
14282 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s3()
14294 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
14298 return -EIO; in lpfc_pci_resume_one_s3()
14300 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s3()
14307 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
14313 * lpfc_sli_prep_dev_for_recover - Prepare SLI3 device for pci slot recover
14327 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli_prep_dev_for_recover()
14333 * lpfc_sli_prep_dev_for_reset - Prepare SLI3 device for pci slot reset
14360 pci_disable_device(phba->pcidev); in lpfc_sli_prep_dev_for_reset()
14364 * lpfc_sli_prep_dev_for_perm_failure - Prepare SLI3 dev for pci slot disable
14388 * lpfc_io_error_detected_s3 - Method for handling SLI-3 device PCI I/O error
14393 * device with SLI-3 interface spec. This function is called by the PCI
14401 * PCI_ERS_RESULT_CAN_RECOVER - can be recovered with reset_link
14402 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
14403 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
14409 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s3()
14413 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s3()
14434 * lpfc_io_slot_reset_s3 - Method for restarting PCI SLI-3 device from scratch.
14438 * device with SLI-3 interface spec. This is called after PCI bus has been
14439 * reset to restart the PCI card from scratch, as if from a cold-boot.
14448 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
14449 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
14455 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s3()
14456 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s3()
14459 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s3()
14461 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s3()
14474 if (pdev->is_busmaster) in lpfc_io_slot_reset_s3()
14477 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
14478 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s3()
14479 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
14482 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
14485 "0427 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s3()
14489 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s3()
14497 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
14503 * lpfc_io_resume_s3 - Method for resuming PCI I/O operation on SLI-3 device.
14507 * with SLI-3 interface spec. It is called when kernel error recovery tells
14516 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s3()
14518 /* Bring device online, it will be no-op for non-fatal error resume */ in lpfc_io_resume_s3()
14523 * lpfc_sli4_get_els_iocb_cnt - Calculate the # of ELS IOCBs to reserve
14531 int max_xri = phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_get_els_iocb_cnt()
14533 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli4_get_els_iocb_cnt()
14553 * lpfc_sli4_get_iocb_cnt - Calculate the # of total IOCBs to reserve
14563 if (phba->nvmet_support) in lpfc_sli4_get_iocb_cnt()
14577 sli_family = bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf); in lpfc_log_write_firmware_error()
14595 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
14596 fsize, fw->size); in lpfc_log_write_firmware_error()
14597 rc = -EINVAL; in lpfc_log_write_firmware_error()
14604 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
14605 fsize, fw->size); in lpfc_log_write_firmware_error()
14606 rc = -EACCES; in lpfc_log_write_firmware_error()
14612 offset, phba->pcidev->device, magic_number, in lpfc_log_write_firmware_error()
14613 ftype, fid, fsize, fw->size); in lpfc_log_write_firmware_error()
14614 rc = -EIO; in lpfc_log_write_firmware_error()
14620 * lpfc_write_firmware - attempt to write a firmware image to the port
14637 /* It can be null in no-wait mode, sanity check */ in lpfc_write_firmware()
14639 rc = -ENXIO; in lpfc_write_firmware()
14642 image = (struct lpfc_grp_hdr *)fw->data; in lpfc_write_firmware()
14644 magic_number = be32_to_cpu(image->magic_number); in lpfc_write_firmware()
14647 fsize = be32_to_cpu(image->size); in lpfc_write_firmware()
14651 if (strncmp(fwrev, image->revision, strnlen(image->revision, 16))) { in lpfc_write_firmware()
14655 fwrev, image->revision); in lpfc_write_firmware()
14660 rc = -ENOMEM; in lpfc_write_firmware()
14663 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_write_firmware()
14665 &dmabuf->phys, in lpfc_write_firmware()
14667 if (!dmabuf->virt) { in lpfc_write_firmware()
14669 rc = -ENOMEM; in lpfc_write_firmware()
14672 list_add_tail(&dmabuf->list, &dma_buffer_list); in lpfc_write_firmware()
14674 while (offset < fw->size) { in lpfc_write_firmware()
14677 if (temp_offset + SLI4_PAGE_SIZE > fw->size) { in lpfc_write_firmware()
14678 memcpy(dmabuf->virt, in lpfc_write_firmware()
14679 fw->data + temp_offset, in lpfc_write_firmware()
14680 fw->size - temp_offset); in lpfc_write_firmware()
14681 temp_offset = fw->size; in lpfc_write_firmware()
14684 memcpy(dmabuf->virt, fw->data + temp_offset, in lpfc_write_firmware()
14689 (fw->size - offset), &offset); in lpfc_write_firmware()
14705 fwrev, image->revision); in lpfc_write_firmware()
14709 list_del(&dmabuf->list); in lpfc_write_firmware()
14710 dma_free_coherent(&phba->pcidev->dev, SLI4_PAGE_SIZE, in lpfc_write_firmware()
14711 dmabuf->virt, dmabuf->phys); in lpfc_write_firmware()
14725 * lpfc_sli4_request_firmware_update - Request linux generic firmware upgrade
14740 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_request_firmware_update()
14742 return -EPERM; in lpfc_sli4_request_firmware_update()
14744 scnprintf(file_name, sizeof(file_name), "%s.grp", phba->ModelName); in lpfc_sli4_request_firmware_update()
14748 file_name, &phba->pcidev->dev, in lpfc_sli4_request_firmware_update()
14752 ret = request_firmware(&fw, file_name, &phba->pcidev->dev); in lpfc_sli4_request_firmware_update()
14756 ret = -EINVAL; in lpfc_sli4_request_firmware_update()
14763 * lpfc_pci_probe_one_s4 - PCI probe func to reg SLI-4 device to PCI subsys
14768 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
14769 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
14777 * 0 - driver can claim the device
14778 * negative value - driver can not claim the device
14792 return -ENOMEM; in lpfc_pci_probe_one_s4()
14794 INIT_LIST_HEAD(&phba->poll_list); in lpfc_pci_probe_one_s4()
14801 /* Set up SLI API function jump table for PCI-device group-1 HBAs */ in lpfc_pci_probe_one_s4()
14806 /* Set up SLI-4 specific device PCI memory space */ in lpfc_pci_probe_one_s4()
14814 /* Set up SLI-4 Specific device driver resources */ in lpfc_pci_probe_one_s4()
14822 INIT_LIST_HEAD(&phba->active_rrq_list); in lpfc_pci_probe_one_s4()
14823 INIT_LIST_HEAD(&phba->fcf.fcf_pri_list); in lpfc_pci_probe_one_s4()
14834 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s4()
14837 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s4()
14840 phba->pport = NULL; in lpfc_pci_probe_one_s4()
14854 error = -ENODEV; in lpfc_pci_probe_one_s4()
14857 /* Default to single EQ for non-MSI-X */ in lpfc_pci_probe_one_s4()
14858 if (phba->intr_type != MSIX) { in lpfc_pci_probe_one_s4()
14859 phba->cfg_irq_chann = 1; in lpfc_pci_probe_one_s4()
14860 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
14861 if (phba->nvmet_support) in lpfc_pci_probe_one_s4()
14862 phba->cfg_nvmet_mrq = 1; in lpfc_pci_probe_one_s4()
14865 lpfc_cpu_affinity_check(phba, phba->cfg_irq_chann); in lpfc_pci_probe_one_s4()
14874 vport = phba->pport; in lpfc_pci_probe_one_s4()
14885 /* Set up SLI-4 HBA */ in lpfc_pci_probe_one_s4()
14889 error = -ENODEV; in lpfc_pci_probe_one_s4()
14894 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s4()
14903 if (phba->nvmet_support == 0) { in lpfc_pci_probe_one_s4()
14904 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
14921 if (phba->cfg_request_firmware_upgrade) in lpfc_pci_probe_one_s4()
14927 timer_setup(&phba->cpuhp_poll_timer, lpfc_sli4_poll_hbtimer, 0); in lpfc_pci_probe_one_s4()
14928 cpuhp_state_add_instance_nocalls(lpfc_cpuhp_state, &phba->cpuhp); in lpfc_pci_probe_one_s4()
14954 * lpfc_pci_remove_one_s4 - PCI func to unreg SLI-4 device from PCI subsystem
14958 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
14966 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s4()
14968 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s4()
14972 spin_lock_irq(&phba->hbalock); in lpfc_pci_remove_one_s4()
14973 vport->load_flag |= FC_UNLOADING; in lpfc_pci_remove_one_s4()
14974 spin_unlock_irq(&phba->hbalock); in lpfc_pci_remove_one_s4()
14975 if (phba->cgn_i) in lpfc_pci_remove_one_s4()
14983 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s4()
14984 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s4()
14986 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s4()
15001 /* De-allocate multi-XRI pools */ in lpfc_pci_remove_one_s4()
15002 if (phba->cfg_xri_rebalancing) in lpfc_pci_remove_one_s4()
15013 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
15014 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s4()
15015 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
15041 * lpfc_pci_suspend_one_s4 - PCI func to suspend SLI-4 device for power mgmnt
15045 * Power Management (PM) to device with SLI-4 interface spec. When PM invokes
15049 * requirements to a power-aware driver's PM support for suspend/resume -- all
15057 * 0 - driver suspended the device
15064 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s4()
15072 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s4()
15082 * lpfc_pci_resume_one_s4 - PCI func to resume SLI-4 device for power mgmnt
15086 * Power Management (PM) to device with SLI-4 interface spac. When PM invokes
15089 * implements the minimum PM requirements to a power-aware driver's PM for
15090 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
15097 * 0 - driver suspended the device
15104 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s4()
15112 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s4()
15113 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s4()
15114 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s4()
15115 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s4()
15123 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
15127 return -EIO; in lpfc_pci_resume_one_s4()
15129 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s4()
15136 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
15142 * lpfc_sli4_prep_dev_for_recover - Prepare SLI4 device for pci slot recover
15155 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli4_prep_dev_for_recover()
15161 * lpfc_sli4_prep_dev_for_reset - Prepare SLI4 device for pci slot reset
15171 int offline = pci_channel_offline(phba->pcidev); in lpfc_sli4_prep_dev_for_reset()
15193 pci_disable_device(phba->pcidev); in lpfc_sli4_prep_dev_for_reset()
15197 * lpfc_sli4_prep_dev_for_perm_failure - Prepare SLI4 dev for pci slot disable
15221 * lpfc_io_error_detected_s4 - Method for handling PCI I/O error to SLI-4 device
15226 * with SLI-4 interface spec. This function is called by the PCI subsystem
15233 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
15234 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15240 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s4()
15245 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s4()
15249 hba_pci_err = test_and_set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15259 set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15264 hba_pci_err = test_and_set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15276 * lpfc_io_slot_reset_s4 - Method for restart PCI SLI-4 device from scratch
15280 * with SLI-4 interface spec. It is called after PCI bus has been reset to
15281 * restart the PCI card from scratch, as if from a cold-boot. During the
15290 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
15291 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15297 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s4()
15298 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s4()
15302 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s4()
15304 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s4()
15311 hba_pci_err = test_and_clear_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_slot_reset_s4()
15313 dev_info(&pdev->dev, in lpfc_io_slot_reset_s4()
15321 if (pdev->is_busmaster) in lpfc_io_slot_reset_s4()
15324 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
15325 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s4()
15326 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
15331 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
15334 "2824 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s4()
15338 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s4()
15339 lpfc_cpu_affinity_check(phba, phba->cfg_irq_chann); in lpfc_io_slot_reset_s4()
15342 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
15348 * lpfc_io_resume_s4 - Method for resuming PCI I/O operation to SLI-4 device
15352 * with SLI-4 interface spec. It is called when kernel error recovery tells
15361 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s4()
15369 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) { in lpfc_io_resume_s4()
15378 * lpfc_pci_probe_one - lpfc PCI probe func to reg dev to PCI subsystem
15384 * at PCI device-specific information of the device and driver to see if the
15387 * the action to the proper SLI-3 or SLI-4 device probing routine, which will
15392 * 0 - driver can claim the device
15393 * negative value - driver can not claim the device
15402 return -ENODEV; in lpfc_pci_probe_one()
15414 * lpfc_pci_remove_one - lpfc PCI func to unreg dev from PCI subsystem
15419 * This routine dispatches the action to the proper SLI-3 or SLI-4 device
15427 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_remove_one()
15429 switch (phba->pci_dev_grp) { in lpfc_pci_remove_one()
15439 phba->pci_dev_grp); in lpfc_pci_remove_one()
15446 * lpfc_pci_suspend_one - lpfc PCI func to suspend dev for power management
15451 * the action to the proper SLI-3 or SLI-4 device suspend routine, which will
15455 * 0 - driver suspended the device
15462 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one()
15463 int rc = -ENODEV; in lpfc_pci_suspend_one()
15465 switch (phba->pci_dev_grp) { in lpfc_pci_suspend_one()
15475 phba->pci_dev_grp); in lpfc_pci_suspend_one()
15482 * lpfc_pci_resume_one - lpfc PCI func to resume dev for power management
15487 * the action to the proper SLI-3 or SLI-4 device resume routine, which will
15491 * 0 - driver suspended the device
15498 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one()
15499 int rc = -ENODEV; in lpfc_pci_resume_one()
15501 switch (phba->pci_dev_grp) { in lpfc_pci_resume_one()
15511 phba->pci_dev_grp); in lpfc_pci_resume_one()
15518 * lpfc_io_error_detected - lpfc method for handling PCI I/O error
15525 * the action to the proper SLI-3 or SLI-4 device error detected handling
15529 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
15530 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15536 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected()
15539 if (phba->link_state == LPFC_HBA_ERROR && in lpfc_io_error_detected()
15540 phba->hba_flag & HBA_IOQ_FLUSH) in lpfc_io_error_detected()
15543 switch (phba->pci_dev_grp) { in lpfc_io_error_detected()
15553 phba->pci_dev_grp); in lpfc_io_error_detected()
15560 * lpfc_io_slot_reset - lpfc method for restart PCI dev from scratch
15565 * from scratch, as if from a cold-boot. When this routine is invoked, it
15566 * dispatches the action to the proper SLI-3 or SLI-4 device reset handling
15570 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
15571 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15577 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset()
15580 switch (phba->pci_dev_grp) { in lpfc_io_slot_reset()
15590 phba->pci_dev_grp); in lpfc_io_slot_reset()
15597 * lpfc_io_resume - lpfc method for resuming PCI I/O operation
15603 * this routine is invoked, it dispatches the action to the proper SLI-3
15604 * or SLI-4 device io_resume routine, which will resume the device operation.
15610 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume()
15612 switch (phba->pci_dev_grp) { in lpfc_io_resume()
15622 phba->pci_dev_grp); in lpfc_io_resume()
15629 * lpfc_sli4_oas_verify - Verify OAS is supported by this adapter
15642 if (!phba->cfg_EnableXLane) in lpfc_sli4_oas_verify()
15645 if (phba->sli4_hba.pc_sli4_params.oas_supported) { in lpfc_sli4_oas_verify()
15646 phba->cfg_fof = 1; in lpfc_sli4_oas_verify()
15648 phba->cfg_fof = 0; in lpfc_sli4_oas_verify()
15649 mempool_destroy(phba->device_data_mem_pool); in lpfc_sli4_oas_verify()
15650 phba->device_data_mem_pool = NULL; in lpfc_sli4_oas_verify()
15657 * lpfc_sli4_ras_init - Verify RAS-FW log is supported by this adapter
15667 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_ras_init()
15669 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_sli4_ras_init()
15671 phba->ras_fwlog.ras_hwsupport = true; in lpfc_sli4_ras_init()
15672 if (phba->cfg_ras_fwlog_func == PCI_FUNC(phba->pcidev->devfn) && in lpfc_sli4_ras_init()
15673 phba->cfg_ras_fwlog_buffsize) in lpfc_sli4_ras_init()
15674 phba->ras_fwlog.ras_enabled = true; in lpfc_sli4_ras_init()
15676 phba->ras_fwlog.ras_enabled = false; in lpfc_sli4_ras_init()
15678 phba->ras_fwlog.ras_hwsupport = false; in lpfc_sli4_ras_init()
15716 * lpfc_init - lpfc module initialization routine
15723 * 0 - successful
15724 * -ENOMEM - FC attach transport failed
15725 * all others - failed
15740 error = -ENOMEM; in lpfc_init()
15794 if (atomic_cmpxchg(&phba->dbg_log_dmping, 0, 1) != 0) in lpfc_dmp_dbg()
15797 start_idx = (unsigned int)atomic_read(&phba->dbg_log_idx) % DBG_LOG_SZ; in lpfc_dmp_dbg()
15798 dbg_cnt = (unsigned int)atomic_read(&phba->dbg_log_cnt); in lpfc_dmp_dbg()
15804 temp_idx -= 1; in lpfc_dmp_dbg()
15806 if ((start_idx + dbg_cnt) > (DBG_LOG_SZ - 1)) { in lpfc_dmp_dbg()
15810 start_idx = DBG_LOG_SZ - (dbg_cnt - start_idx); in lpfc_dmp_dbg()
15812 start_idx -= dbg_cnt; in lpfc_dmp_dbg()
15815 dev_info(&phba->pcidev->dev, "start %d end %d cnt %d\n", in lpfc_dmp_dbg()
15823 rem_nsec = do_div(phba->dbg_log[temp_idx].t_ns, NSEC_PER_SEC); in lpfc_dmp_dbg()
15824 dev_info(&phba->pcidev->dev, "%d: [%5lu.%06lu] %s", in lpfc_dmp_dbg()
15826 (unsigned long)phba->dbg_log[temp_idx].t_ns, in lpfc_dmp_dbg()
15828 phba->dbg_log[temp_idx].log); in lpfc_dmp_dbg()
15831 atomic_set(&phba->dbg_log_cnt, 0); in lpfc_dmp_dbg()
15832 atomic_set(&phba->dbg_log_dmping, 0); in lpfc_dmp_dbg()
15840 int dbg_dmping = atomic_read(&phba->dbg_log_dmping); in lpfc_dbg_print()
15848 dev_info(&phba->pcidev->dev, "%pV", &vaf); in lpfc_dbg_print()
15852 idx = (unsigned int)atomic_fetch_add(1, &phba->dbg_log_idx) % in lpfc_dbg_print()
15855 atomic_inc(&phba->dbg_log_cnt); in lpfc_dbg_print()
15857 vscnprintf(phba->dbg_log[idx].log, in lpfc_dbg_print()
15858 sizeof(phba->dbg_log[idx].log), fmt, args); in lpfc_dbg_print()
15861 phba->dbg_log[idx].t_ns = local_clock(); in lpfc_dbg_print()
15865 * lpfc_exit - lpfc module removal routine