Lines Matching +full:cpu +full:- +full:centric
4 * Copyright (C) 2017-2025 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 */
108 * lpfc_config_port_prep - Perform lpfc initialization prior to config port
117 * 0 - success.
118 * -ERESTART - requests the SLI layer to reset the HBA and try again.
119 * Any other value - indicates an error.
124 lpfc_vpd_t *vp = &phba->vpd; in lpfc_config_port_prep()
134 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_prep()
136 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_prep()
137 return -ENOMEM; in lpfc_config_port_prep()
140 mb = &pmb->u.mb; in lpfc_config_port_prep()
141 phba->link_state = LPFC_INIT_MBX_CMDS; in lpfc_config_port_prep()
143 if (lpfc_is_LC_HBA(phba->pcidev->device)) { in lpfc_config_port_prep()
153 memset((char*)mb->un.varRDnvp.rsvd3, 0, in lpfc_config_port_prep()
154 sizeof (mb->un.varRDnvp.rsvd3)); in lpfc_config_port_prep()
155 memcpy((char*)mb->un.varRDnvp.rsvd3, licensed, in lpfc_config_port_prep()
165 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_prep()
166 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
167 return -ERESTART; in lpfc_config_port_prep()
169 memcpy(phba->wwnn, (char *)mb->un.varRDnvp.nodename, in lpfc_config_port_prep()
170 sizeof(phba->wwnn)); in lpfc_config_port_prep()
171 memcpy(phba->wwpn, (char *)mb->un.varRDnvp.portname, in lpfc_config_port_prep()
172 sizeof(phba->wwpn)); in lpfc_config_port_prep()
179 phba->sli3_options &= (uint32_t)LPFC_SLI3_BG_ENABLED; in lpfc_config_port_prep()
188 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_prep()
189 mempool_free( pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
190 return -ERESTART; in lpfc_config_port_prep()
198 if (mb->un.varRdRev.rr == 0) { in lpfc_config_port_prep()
199 vp->rev.rBit = 0; in lpfc_config_port_prep()
203 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
204 return -ERESTART; in lpfc_config_port_prep()
207 if (phba->sli_rev == 3 && !mb->un.varRdRev.v3rsp) { in lpfc_config_port_prep()
208 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
209 return -EINVAL; in lpfc_config_port_prep()
213 vp->rev.rBit = 1; in lpfc_config_port_prep()
214 memcpy(&vp->sli3Feat, &mb->un.varRdRev.sli3Feat, sizeof(uint32_t)); in lpfc_config_port_prep()
215 vp->rev.sli1FwRev = mb->un.varRdRev.sli1FwRev; in lpfc_config_port_prep()
216 memcpy(vp->rev.sli1FwName, (char*) mb->un.varRdRev.sli1FwName, 16); in lpfc_config_port_prep()
217 vp->rev.sli2FwRev = mb->un.varRdRev.sli2FwRev; in lpfc_config_port_prep()
218 memcpy(vp->rev.sli2FwName, (char *) mb->un.varRdRev.sli2FwName, 16); in lpfc_config_port_prep()
219 vp->rev.biuRev = mb->un.varRdRev.biuRev; in lpfc_config_port_prep()
220 vp->rev.smRev = mb->un.varRdRev.smRev; in lpfc_config_port_prep()
221 vp->rev.smFwRev = mb->un.varRdRev.un.smFwRev; in lpfc_config_port_prep()
222 vp->rev.endecRev = mb->un.varRdRev.endecRev; in lpfc_config_port_prep()
223 vp->rev.fcphHigh = mb->un.varRdRev.fcphHigh; in lpfc_config_port_prep()
224 vp->rev.fcphLow = mb->un.varRdRev.fcphLow; in lpfc_config_port_prep()
225 vp->rev.feaLevelHigh = mb->un.varRdRev.feaLevelHigh; in lpfc_config_port_prep()
226 vp->rev.feaLevelLow = mb->un.varRdRev.feaLevelLow; in lpfc_config_port_prep()
227 vp->rev.postKernRev = mb->un.varRdRev.postKernRev; in lpfc_config_port_prep()
228 vp->rev.opFwRev = mb->un.varRdRev.opFwRev; in lpfc_config_port_prep()
234 if (vp->rev.feaLevelHigh < 9) in lpfc_config_port_prep()
235 phba->sli3_options |= LPFC_SLI3_VPORT_TEARDOWN; in lpfc_config_port_prep()
237 if (lpfc_is_LC_HBA(phba->pcidev->device)) in lpfc_config_port_prep()
238 memcpy(phba->RandomData, (char *)&mb->un.varWords[24], in lpfc_config_port_prep()
239 sizeof (phba->RandomData)); in lpfc_config_port_prep()
253 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_prep()
254 mb->un.varDmp.word_cnt = 0; in lpfc_config_port_prep()
259 if (mb->un.varDmp.word_cnt == 0) in lpfc_config_port_prep()
262 if (mb->un.varDmp.word_cnt > DMP_VPD_SIZE - offset) in lpfc_config_port_prep()
263 mb->un.varDmp.word_cnt = DMP_VPD_SIZE - offset; in lpfc_config_port_prep()
266 mb->un.varDmp.word_cnt); in lpfc_config_port_prep()
267 offset += mb->un.varDmp.word_cnt; in lpfc_config_port_prep()
268 } while (mb->un.varDmp.word_cnt && offset < DMP_VPD_SIZE); in lpfc_config_port_prep()
274 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
279 * lpfc_config_async_cmpl - Completion handler for config async event mbox cmd
291 if (pmboxq->u.mb.mbxStatus == MBX_SUCCESS) in lpfc_config_async_cmpl()
292 phba->temp_sensor_support = 1; in lpfc_config_async_cmpl()
294 phba->temp_sensor_support = 0; in lpfc_config_async_cmpl()
295 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_config_async_cmpl()
300 * lpfc_dump_wakeup_param_cmpl - dump memory mailbox command completion handler
318 if (pmboxq->u.mb.mbxStatus != MBX_SUCCESS) { in lpfc_dump_wakeup_param_cmpl()
319 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_dump_wakeup_param_cmpl()
326 prog_id_word = pmboxq->u.mb.un.varWords[7]; in lpfc_dump_wakeup_param_cmpl()
329 dist = dist_char[prg->dist]; in lpfc_dump_wakeup_param_cmpl()
331 if ((prg->dist == 3) && (prg->num == 0)) in lpfc_dump_wakeup_param_cmpl()
332 snprintf(phba->OptionROMVersion, 32, "%d.%d%d", in lpfc_dump_wakeup_param_cmpl()
333 prg->ver, prg->rev, prg->lev); in lpfc_dump_wakeup_param_cmpl()
335 snprintf(phba->OptionROMVersion, 32, "%d.%d%d%c%d", in lpfc_dump_wakeup_param_cmpl()
336 prg->ver, prg->rev, prg->lev, in lpfc_dump_wakeup_param_cmpl()
337 dist, prg->num); in lpfc_dump_wakeup_param_cmpl()
338 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_dump_wakeup_param_cmpl()
343 * lpfc_update_vport_wwn - Updates the fc_nodename, fc_portname,
353 struct lpfc_hba *phba = vport->phba; in lpfc_update_vport_wwn()
359 if (vport->fc_nodename.u.wwn[0] == 0) in lpfc_update_vport_wwn()
360 memcpy(&vport->fc_nodename, &vport->fc_sparam.nodeName, in lpfc_update_vport_wwn()
363 memcpy(&vport->fc_sparam.nodeName, &vport->fc_nodename, in lpfc_update_vport_wwn()
370 if (vport->fc_portname.u.wwn[0] != 0 && in lpfc_update_vport_wwn()
371 memcmp(&vport->fc_portname, &vport->fc_sparam.portName, in lpfc_update_vport_wwn()
373 vport->vport_flag |= FAWWPN_PARAM_CHG; in lpfc_update_vport_wwn()
375 if (phba->sli_rev == LPFC_SLI_REV4 && in lpfc_update_vport_wwn()
376 vport->port_type == LPFC_PHYSICAL_PORT && in lpfc_update_vport_wwn()
377 phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_FABRIC) { in lpfc_update_vport_wwn()
378 if (!(phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_CONFIG)) in lpfc_update_vport_wwn()
379 phba->sli4_hba.fawwpn_flag &= in lpfc_update_vport_wwn()
383 "2701 FA-PWWN change WWPN from %llx to " in lpfc_update_vport_wwn()
385 wwn_to_u64(vport->fc_portname.u.wwn), in lpfc_update_vport_wwn()
387 (vport->fc_sparam.portName.u.wwn), in lpfc_update_vport_wwn()
388 vport->vport_flag, in lpfc_update_vport_wwn()
389 phba->sli4_hba.fawwpn_flag); in lpfc_update_vport_wwn()
390 memcpy(&vport->fc_portname, &vport->fc_sparam.portName, in lpfc_update_vport_wwn()
395 if (vport->fc_portname.u.wwn[0] == 0) in lpfc_update_vport_wwn()
396 memcpy(&vport->fc_portname, &vport->fc_sparam.portName, in lpfc_update_vport_wwn()
399 memcpy(&vport->fc_sparam.portName, &vport->fc_portname, in lpfc_update_vport_wwn()
404 * lpfc_config_port_post - Perform lpfc initialization after config port
413 * 0 - success.
414 * Any other value - error.
419 struct lpfc_vport *vport = phba->pport; in lpfc_config_port_post()
424 struct lpfc_sli *psli = &phba->sli; in lpfc_config_port_post()
429 spin_lock_irq(&phba->hbalock); in lpfc_config_port_post()
434 if (phba->over_temp_state == HBA_OVER_TEMP) in lpfc_config_port_post()
435 phba->over_temp_state = HBA_NORMAL_TEMP; in lpfc_config_port_post()
436 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
438 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
440 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
441 return -ENOMEM; in lpfc_config_port_post()
443 mb = &pmb->u.mb; in lpfc_config_port_post()
448 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
449 return -ENOMEM; in lpfc_config_port_post()
452 pmb->vport = vport; in lpfc_config_port_post()
457 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_post()
458 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
460 return -EIO; in lpfc_config_port_post()
463 mp = pmb->ctx_buf; in lpfc_config_port_post()
469 memcpy(&vport->fc_sparam, mp->virt, sizeof (struct serv_parm)); in lpfc_config_port_post()
470 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_config_port_post()
472 pmb->ctx_buf = NULL; in lpfc_config_port_post()
476 fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); in lpfc_config_port_post()
477 fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); in lpfc_config_port_post()
478 fc_host_max_npiv_vports(shost) = phba->max_vpi; in lpfc_config_port_post()
481 /* This should be consolidated into parse_vpd ? - mr */ in lpfc_config_port_post()
482 if (phba->SerialNumber[0] == 0) { in lpfc_config_port_post()
485 outptr = &vport->fc_nodename.u.s.IEEE[0]; in lpfc_config_port_post()
490 phba->SerialNumber[i] = in lpfc_config_port_post()
493 phba->SerialNumber[i] = in lpfc_config_port_post()
494 (char)((uint8_t) 0x61 + (uint8_t) (j - 10)); in lpfc_config_port_post()
498 phba->SerialNumber[i] = in lpfc_config_port_post()
501 phba->SerialNumber[i] = in lpfc_config_port_post()
502 (char)((uint8_t) 0x61 + (uint8_t) (j - 10)); in lpfc_config_port_post()
507 pmb->vport = vport; in lpfc_config_port_post()
512 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_post()
513 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
514 mempool_free( pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
515 return -EIO; in lpfc_config_port_post()
522 if (phba->cfg_hba_queue_depth > mb->un.varRdConfig.max_xri) { in lpfc_config_port_post()
525 phba->cfg_hba_queue_depth, in lpfc_config_port_post()
526 mb->un.varRdConfig.max_xri); in lpfc_config_port_post()
527 phba->cfg_hba_queue_depth = mb->un.varRdConfig.max_xri; in lpfc_config_port_post()
530 phba->lmt = mb->un.varRdConfig.lmt; in lpfc_config_port_post()
533 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_config_port_post()
535 phba->link_state = LPFC_LINK_DOWN; in lpfc_config_port_post()
538 if (psli->sli3_ring[LPFC_EXTRA_RING].sli.sli3.cmdringaddr) in lpfc_config_port_post()
539 psli->sli3_ring[LPFC_EXTRA_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_config_port_post()
540 if (psli->sli3_ring[LPFC_FCP_RING].sli.sli3.cmdringaddr) in lpfc_config_port_post()
541 psli->sli3_ring[LPFC_FCP_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_config_port_post()
544 if (phba->sli_rev != 3) in lpfc_config_port_post()
548 * Configure HBA MSI-X attention conditions to messages if MSI-X mode in lpfc_config_port_post()
550 if (phba->intr_type == MSIX) { in lpfc_config_port_post()
553 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
554 return -EIO; in lpfc_config_port_post()
561 pmb->u.mb.mbxCommand, in lpfc_config_port_post()
562 pmb->u.mb.mbxStatus); in lpfc_config_port_post()
563 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
564 return -EIO; in lpfc_config_port_post()
568 spin_lock_irq(&phba->hbalock); in lpfc_config_port_post()
570 clear_bit(HBA_ERATT_HANDLED, &phba->hba_flag); in lpfc_config_port_post()
573 if (lpfc_readl(phba->HCregaddr, &status)) { in lpfc_config_port_post()
574 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
575 return -EIO; in lpfc_config_port_post()
578 if (psli->num_rings > 0) in lpfc_config_port_post()
580 if (psli->num_rings > 1) in lpfc_config_port_post()
582 if (psli->num_rings > 2) in lpfc_config_port_post()
584 if (psli->num_rings > 3) in lpfc_config_port_post()
587 if ((phba->cfg_poll & ENABLE_FCP_RING_POLLING) && in lpfc_config_port_post()
588 (phba->cfg_poll & DISABLE_FCP_RING_INT)) in lpfc_config_port_post()
591 writel(status, phba->HCregaddr); in lpfc_config_port_post()
592 readl(phba->HCregaddr); /* flush */ in lpfc_config_port_post()
593 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
595 /* Set up ring-0 (ELS) timer */ in lpfc_config_port_post()
596 timeout = phba->fc_ratov * 2; in lpfc_config_port_post()
597 mod_timer(&vport->els_tmofunc, in lpfc_config_port_post()
600 mod_timer(&phba->hb_tmofunc, in lpfc_config_port_post()
602 clear_bit(HBA_HBEAT_INP, &phba->hba_flag); in lpfc_config_port_post()
603 clear_bit(HBA_HBEAT_TMO, &phba->hba_flag); in lpfc_config_port_post()
604 phba->last_completion_time = jiffies; in lpfc_config_port_post()
606 mod_timer(&phba->eratt_poll, in lpfc_config_port_post()
607 jiffies + secs_to_jiffies(phba->eratt_poll_interval)); in lpfc_config_port_post()
609 if (test_bit(LINK_DISABLED, &phba->hba_flag)) { in lpfc_config_port_post()
613 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_config_port_post()
620 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
621 return -EIO; in lpfc_config_port_post()
623 } else if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) { in lpfc_config_port_post()
624 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
625 rc = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); in lpfc_config_port_post()
630 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
632 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
633 return -ENOMEM; in lpfc_config_port_post()
637 pmb->mbox_cmpl = lpfc_config_async_cmpl; in lpfc_config_port_post()
638 pmb->vport = phba->pport; in lpfc_config_port_post()
646 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
650 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
652 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
653 return -ENOMEM; in lpfc_config_port_post()
657 pmb->mbox_cmpl = lpfc_dump_wakeup_param_cmpl; in lpfc_config_port_post()
658 pmb->vport = phba->pport; in lpfc_config_port_post()
665 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
672 * lpfc_sli4_refresh_params - update driver copy of params.
686 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_refresh_params()
688 return -ENOMEM; in lpfc_sli4_refresh_params()
690 mqe = &mboxq->u.mqe; in lpfc_sli4_refresh_params()
692 length = (sizeof(struct lpfc_mbx_get_sli4_parameters) - in lpfc_sli4_refresh_params()
700 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_refresh_params()
703 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters; in lpfc_sli4_refresh_params()
704 phba->sli4_hba.pc_sli4_params.mi_cap = in lpfc_sli4_refresh_params()
708 if (phba->cfg_enable_mi) in lpfc_sli4_refresh_params()
709 phba->sli4_hba.pc_sli4_params.mi_ver = in lpfc_sli4_refresh_params()
712 phba->sli4_hba.pc_sli4_params.mi_ver = 0; in lpfc_sli4_refresh_params()
714 phba->sli4_hba.pc_sli4_params.cmf = in lpfc_sli4_refresh_params()
716 phba->sli4_hba.pc_sli4_params.pls = in lpfc_sli4_refresh_params()
719 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_refresh_params()
724 * lpfc_hba_init_link - Initialize the FC link
726 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
734 * 0 - success
735 * Any other value - error
740 return lpfc_hba_init_link_fc_topology(phba, phba->cfg_topology, flag); in lpfc_hba_init_link()
744 * lpfc_hba_init_link_fc_topology - Initialize FC link with desired topology
747 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
755 * 0 - success
756 * Any other value - error
762 struct lpfc_vport *vport = phba->pport; in lpfc_hba_init_link_fc_topology()
767 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_hba_init_link_fc_topology()
769 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_init_link_fc_topology()
770 return -ENOMEM; in lpfc_hba_init_link_fc_topology()
772 mb = &pmb->u.mb; in lpfc_hba_init_link_fc_topology()
773 pmb->vport = vport; in lpfc_hba_init_link_fc_topology()
775 if ((phba->cfg_link_speed > LPFC_USER_LINK_SPEED_MAX) || in lpfc_hba_init_link_fc_topology()
776 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_1G) && in lpfc_hba_init_link_fc_topology()
777 !(phba->lmt & LMT_1Gb)) || in lpfc_hba_init_link_fc_topology()
778 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_2G) && in lpfc_hba_init_link_fc_topology()
779 !(phba->lmt & LMT_2Gb)) || in lpfc_hba_init_link_fc_topology()
780 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_4G) && in lpfc_hba_init_link_fc_topology()
781 !(phba->lmt & LMT_4Gb)) || in lpfc_hba_init_link_fc_topology()
782 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_8G) && in lpfc_hba_init_link_fc_topology()
783 !(phba->lmt & LMT_8Gb)) || in lpfc_hba_init_link_fc_topology()
784 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_10G) && in lpfc_hba_init_link_fc_topology()
785 !(phba->lmt & LMT_10Gb)) || in lpfc_hba_init_link_fc_topology()
786 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G) && in lpfc_hba_init_link_fc_topology()
787 !(phba->lmt & LMT_16Gb)) || in lpfc_hba_init_link_fc_topology()
788 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_32G) && in lpfc_hba_init_link_fc_topology()
789 !(phba->lmt & LMT_32Gb)) || in lpfc_hba_init_link_fc_topology()
790 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_64G) && in lpfc_hba_init_link_fc_topology()
791 !(phba->lmt & LMT_64Gb))) { in lpfc_hba_init_link_fc_topology()
796 phba->cfg_link_speed); in lpfc_hba_init_link_fc_topology()
797 phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; in lpfc_hba_init_link_fc_topology()
799 lpfc_init_link(phba, pmb, fc_topology, phba->cfg_link_speed); in lpfc_hba_init_link_fc_topology()
800 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_hba_init_link_fc_topology()
801 if (phba->sli_rev < LPFC_SLI_REV4) in lpfc_hba_init_link_fc_topology()
808 mb->mbxCommand, mb->mbxStatus); in lpfc_hba_init_link_fc_topology()
809 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_hba_init_link_fc_topology()
811 writel(0, phba->HCregaddr); in lpfc_hba_init_link_fc_topology()
812 readl(phba->HCregaddr); /* flush */ in lpfc_hba_init_link_fc_topology()
814 writel(0xffffffff, phba->HAregaddr); in lpfc_hba_init_link_fc_topology()
815 readl(phba->HAregaddr); /* flush */ in lpfc_hba_init_link_fc_topology()
817 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_init_link_fc_topology()
819 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_init_link_fc_topology()
820 return -EIO; in lpfc_hba_init_link_fc_topology()
822 phba->cfg_suppress_link_up = LPFC_INITIALIZE_LINK; in lpfc_hba_init_link_fc_topology()
824 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_init_link_fc_topology()
830 * lpfc_hba_down_link - this routine downs the FC link
832 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
839 * 0 - success
840 * Any other value - error
848 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_hba_down_link()
850 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_down_link()
851 return -ENOMEM; in lpfc_hba_down_link()
857 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_hba_down_link()
864 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_down_link()
865 return -EIO; in lpfc_hba_down_link()
868 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_down_link()
874 * lpfc_hba_down_prep - Perform lpfc uninitialization prior to HBA reset
881 * 0 - success.
882 * Any other value - error.
890 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_hba_down_prep()
892 writel(0, phba->HCregaddr); in lpfc_hba_down_prep()
893 readl(phba->HCregaddr); /* flush */ in lpfc_hba_down_prep()
896 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_hba_down_prep()
897 lpfc_cleanup_discovery_resources(phba->pport); in lpfc_hba_down_prep()
901 for (i = 0; i <= phba->max_vports && in lpfc_hba_down_prep()
910 * lpfc_sli4_free_sp_events - Cleanup sp_queue_events to free
929 clear_bit(HBA_SP_QUEUE_EVT, &phba->hba_flag); 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
1232 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { in lpfc_rrq_timeout()
1233 clear_bit(HBA_RRQ_ACTIVE, &phba->hba_flag); in lpfc_rrq_timeout()
1237 set_bit(HBA_RRQ_ACTIVE, &phba->hba_flag); in lpfc_rrq_timeout()
1242 * lpfc_hb_mbox_cmpl - The lpfc heart-beat mailbox command callback function
1246 * This is the callback function to the lpfc heart-beat mailbox command.
1247 * If configured, the lpfc driver issues the heart-beat mailbox command to
1249 * heart-beat mailbox command is issued, the driver shall set up heart-beat
1251 * heart-beat outstanding state. Once the mailbox command comes back and
1252 * no error conditions detected, the heart-beat mailbox command timer is
1253 * reset to LPFC_HB_MBOX_INTERVAL seconds and the heart-beat outstanding
1254 * state is cleared for the next heart-beat. If the timer expired with the
1255 * heart-beat outstanding state set, the driver will put the HBA offline.
1260 clear_bit(HBA_HBEAT_INP, &phba->hba_flag); in lpfc_hb_mbox_cmpl()
1261 clear_bit(HBA_HBEAT_TMO, &phba->hba_flag); in lpfc_hb_mbox_cmpl()
1263 /* Check and reset heart-beat timer if necessary */ in lpfc_hb_mbox_cmpl()
1264 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_hb_mbox_cmpl()
1265 if (!test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag) && in lpfc_hb_mbox_cmpl()
1266 !(phba->link_state == LPFC_HBA_ERROR) && in lpfc_hb_mbox_cmpl()
1267 !test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_hb_mbox_cmpl()
1268 mod_timer(&phba->hb_tmofunc, in lpfc_hb_mbox_cmpl()
1275 * lpfc_idle_stat_delay_work - idle_stat tracking
1277 * This routine tracks per-eq idle_stat and determines polling decisions.
1294 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_idle_stat_delay_work()
1297 if (phba->link_state == LPFC_HBA_ERROR || in lpfc_idle_stat_delay_work()
1298 test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag) || in lpfc_idle_stat_delay_work()
1299 phba->cmf_active_mode != LPFC_CFG_OFF) in lpfc_idle_stat_delay_work()
1303 hdwq = &phba->sli4_hba.hdwq[phba->sli4_hba.cpu_map[i].hdwq]; in lpfc_idle_stat_delay_work()
1304 eq = hdwq->hba_eq; in lpfc_idle_stat_delay_work()
1306 /* Skip if we've already handled this eq's primary CPU */ in lpfc_idle_stat_delay_work()
1307 if (eq->chann != i) in lpfc_idle_stat_delay_work()
1310 idle_stat = &phba->sli4_hba.idle_stat[i]; in lpfc_idle_stat_delay_work()
1316 * percentage of 100 - the sum of the other consumption times. in lpfc_idle_stat_delay_work()
1319 diff_idle = wall_idle - idle_stat->prev_idle; in lpfc_idle_stat_delay_work()
1320 diff_wall = wall - idle_stat->prev_wall; in lpfc_idle_stat_delay_work()
1325 busy_time = diff_wall - diff_idle; in lpfc_idle_stat_delay_work()
1328 idle_percent = 100 - idle_percent; in lpfc_idle_stat_delay_work()
1331 eq->poll_mode = LPFC_QUEUE_WORK; in lpfc_idle_stat_delay_work()
1333 eq->poll_mode = LPFC_THREADED_IRQ; in lpfc_idle_stat_delay_work()
1335 idle_stat->prev_idle = wall_idle; in lpfc_idle_stat_delay_work()
1336 idle_stat->prev_wall = wall; in lpfc_idle_stat_delay_work()
1340 schedule_delayed_work(&phba->idle_stat_delay_work, in lpfc_idle_stat_delay_work()
1355 if (!phba->cfg_auto_imax || in lpfc_hb_eq_delay_work()
1356 test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_hb_eq_delay_work()
1359 if (phba->link_state == LPFC_HBA_ERROR || in lpfc_hb_eq_delay_work()
1360 test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_hb_eq_delay_work()
1363 ena_delay = kcalloc(phba->sli4_hba.num_possible_cpu, sizeof(*ena_delay), in lpfc_hb_eq_delay_work()
1368 for (i = 0; i < phba->cfg_irq_chann; i++) { in lpfc_hb_eq_delay_work()
1370 eq = phba->sli4_hba.hba_eq_hdl[i].eq; in lpfc_hb_eq_delay_work()
1373 if (eq->q_mode || eq->q_flag & HBA_EQ_DELAY_CHK) { in lpfc_hb_eq_delay_work()
1374 eq->q_flag &= ~HBA_EQ_DELAY_CHK; in lpfc_hb_eq_delay_work()
1375 ena_delay[eq->last_cpu] = 1; in lpfc_hb_eq_delay_work()
1380 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, i); in lpfc_hb_eq_delay_work()
1382 usdelay = (eqi->icnt >> 10) * LPFC_EQ_DELAY_STEP; in lpfc_hb_eq_delay_work()
1389 eqi->icnt = 0; in lpfc_hb_eq_delay_work()
1391 list_for_each_entry_safe(eq, eq_next, &eqi->list, cpu_list) { in lpfc_hb_eq_delay_work()
1392 if (unlikely(eq->last_cpu != i)) { in lpfc_hb_eq_delay_work()
1393 eqi_new = per_cpu_ptr(phba->sli4_hba.eq_info, in lpfc_hb_eq_delay_work()
1394 eq->last_cpu); in lpfc_hb_eq_delay_work()
1395 list_move_tail(&eq->cpu_list, &eqi_new->list); in lpfc_hb_eq_delay_work()
1398 if (usdelay != eq->q_mode) in lpfc_hb_eq_delay_work()
1399 lpfc_modify_hba_eq_delay(phba, eq->hdwq, 1, in lpfc_hb_eq_delay_work()
1407 queue_delayed_work(phba->wq, &phba->eq_delay_work, in lpfc_hb_eq_delay_work()
1412 * lpfc_hb_mxp_handler - Multi-XRI pools handler to adjust XRI distribution
1423 hwq_count = phba->cfg_hdw_queue; in lpfc_hb_mxp_handler()
1439 * lpfc_issue_hb_mbox - Issues heart-beat mailbox command
1453 if (test_bit(HBA_HBEAT_INP, &phba->hba_flag)) in lpfc_issue_hb_mbox()
1456 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_issue_hb_mbox()
1458 return -ENOMEM; in lpfc_issue_hb_mbox()
1461 pmboxq->mbox_cmpl = lpfc_hb_mbox_cmpl; in lpfc_issue_hb_mbox()
1462 pmboxq->vport = phba->pport; in lpfc_issue_hb_mbox()
1466 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_issue_hb_mbox()
1467 return -ENXIO; in lpfc_issue_hb_mbox()
1469 set_bit(HBA_HBEAT_INP, &phba->hba_flag); in lpfc_issue_hb_mbox()
1475 * lpfc_issue_hb_tmo - Signals heartbeat timer to issue mbox command
1487 if (phba->cfg_enable_hba_heartbeat) in lpfc_issue_hb_tmo()
1489 set_bit(HBA_HBEAT_TMO, &phba->hba_flag); in lpfc_issue_hb_tmo()
1493 * lpfc_hb_timeout_handler - The HBA-timer timeout handler
1496 * This is the actual HBA-timer timeout handler to be invoked by the worker
1497 * thread whenever the HBA timer fired and HBA-timeout event posted. This
1500 * or by processing slow-ring or fast-ring events within the HBA-timer
1502 * the timer for the next timeout period. If lpfc heart-beat mailbox command
1503 * is configured and there is no heart-beat mailbox command outstanding, a
1504 * heart-beat mailbox is issued and timer set properly. Otherwise, if there
1505 * has been a heart-beat mailbox command outstanding, the HBA shall be put
1515 struct lpfc_sli *psli = &phba->sli; in lpfc_hb_timeout_handler()
1518 if (phba->cfg_xri_rebalancing) { in lpfc_hb_timeout_handler()
1519 /* Multi-XRI pools handler */ in lpfc_hb_timeout_handler()
1525 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_hb_timeout_handler()
1531 if (phba->link_state == LPFC_HBA_ERROR || in lpfc_hb_timeout_handler()
1532 test_bit(FC_UNLOADING, &phba->pport->load_flag) || in lpfc_hb_timeout_handler()
1533 test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_hb_timeout_handler()
1536 if (phba->elsbuf_cnt && in lpfc_hb_timeout_handler()
1537 (phba->elsbuf_cnt == phba->elsbuf_prev_cnt)) { in lpfc_hb_timeout_handler()
1538 spin_lock_irq(&phba->hbalock); in lpfc_hb_timeout_handler()
1539 list_splice_init(&phba->elsbuf, &completions); in lpfc_hb_timeout_handler()
1540 phba->elsbuf_cnt = 0; in lpfc_hb_timeout_handler()
1541 phba->elsbuf_prev_cnt = 0; in lpfc_hb_timeout_handler()
1542 spin_unlock_irq(&phba->hbalock); in lpfc_hb_timeout_handler()
1547 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); in lpfc_hb_timeout_handler()
1551 phba->elsbuf_prev_cnt = phba->elsbuf_cnt; in lpfc_hb_timeout_handler()
1554 if (phba->cfg_enable_hba_heartbeat) { in lpfc_hb_timeout_handler()
1556 spin_lock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1557 if (time_after(phba->last_completion_time + in lpfc_hb_timeout_handler()
1560 spin_unlock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1561 if (test_bit(HBA_HBEAT_INP, &phba->hba_flag)) in lpfc_hb_timeout_handler()
1567 spin_unlock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1570 if (test_bit(HBA_HBEAT_INP, &phba->hba_flag)) { in lpfc_hb_timeout_handler()
1580 - phba->last_completion_time)); in lpfc_hb_timeout_handler()
1583 if ((!(psli->sli_flag & LPFC_SLI_MBOX_ACTIVE)) && in lpfc_hb_timeout_handler()
1584 (list_empty(&psli->mboxq))) { in lpfc_hb_timeout_handler()
1591 phba->skipped_hb = 0; in lpfc_hb_timeout_handler()
1592 } else if (time_before_eq(phba->last_completion_time, in lpfc_hb_timeout_handler()
1593 phba->skipped_hb)) { in lpfc_hb_timeout_handler()
1598 - phba->last_completion_time)); in lpfc_hb_timeout_handler()
1600 phba->skipped_hb = jiffies; in lpfc_hb_timeout_handler()
1607 if (test_bit(HBA_HBEAT_TMO, &phba->hba_flag)) { in lpfc_hb_timeout_handler()
1618 mod_timer(&phba->hb_tmofunc, jiffies + msecs_to_jiffies(tmo)); in lpfc_hb_timeout_handler()
1622 * lpfc_offline_eratt - Bring lpfc offline on hardware error attention
1631 struct lpfc_sli *psli = &phba->sli; in lpfc_offline_eratt()
1633 spin_lock_irq(&phba->hbalock); in lpfc_offline_eratt()
1634 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_offline_eratt()
1635 spin_unlock_irq(&phba->hbalock); in lpfc_offline_eratt()
1640 spin_lock_irq(&phba->hbalock); in lpfc_offline_eratt()
1642 spin_unlock_irq(&phba->hbalock); in lpfc_offline_eratt()
1646 phba->link_state = LPFC_HBA_ERROR; in lpfc_offline_eratt()
1651 * lpfc_sli4_offline_eratt - Bring lpfc offline on SLI4 hardware error attention
1660 spin_lock_irq(&phba->hbalock); in lpfc_sli4_offline_eratt()
1661 if (phba->link_state == LPFC_HBA_ERROR && in lpfc_sli4_offline_eratt()
1662 test_bit(HBA_PCI_ERR, &phba->bit_flags)) { in lpfc_sli4_offline_eratt()
1663 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_offline_eratt()
1666 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli4_offline_eratt()
1667 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_offline_eratt()
1677 * lpfc_handle_deferred_eratt - The HBA hardware deferred error handler
1688 uint32_t old_host_status = phba->work_hs; in lpfc_handle_deferred_eratt()
1689 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_deferred_eratt()
1694 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_deferred_eratt()
1695 clear_bit(DEFER_ERATT, &phba->hba_flag); in lpfc_handle_deferred_eratt()
1702 phba->work_hs, phba->work_status[0], in lpfc_handle_deferred_eratt()
1703 phba->work_status[1]); in lpfc_handle_deferred_eratt()
1705 spin_lock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1706 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_handle_deferred_eratt()
1707 spin_unlock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1713 * SCSI layer retry it after re-establishing link. in lpfc_handle_deferred_eratt()
1725 while (phba->work_hs & HS_FFER1) { in lpfc_handle_deferred_eratt()
1727 if (lpfc_readl(phba->HSregaddr, &phba->work_hs)) { in lpfc_handle_deferred_eratt()
1728 phba->work_hs = UNPLUG_ERR ; in lpfc_handle_deferred_eratt()
1732 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { in lpfc_handle_deferred_eratt()
1733 phba->work_hs = 0; in lpfc_handle_deferred_eratt()
1743 if (!phba->work_hs && !test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_handle_deferred_eratt()
1744 phba->work_hs = old_host_status & ~HS_FFER1; in lpfc_handle_deferred_eratt()
1746 clear_bit(DEFER_ERATT, &phba->hba_flag); in lpfc_handle_deferred_eratt()
1747 phba->work_status[0] = readl(phba->MBslimaddr + 0xa8); in lpfc_handle_deferred_eratt()
1748 phba->work_status[1] = readl(phba->MBslimaddr + 0xac); in lpfc_handle_deferred_eratt()
1759 shost = lpfc_shost_from_vport(phba->pport); in lpfc_board_errevt_to_mgmt()
1767 * lpfc_handle_eratt_s3 - The SLI3 HBA hardware error handler
1772 * 1 - HBA error attention interrupt
1773 * 2 - DMA ring index out of range
1774 * 3 - Mailbox command came back as unknown
1779 struct lpfc_vport *vport = phba->pport; in lpfc_handle_eratt_s3()
1780 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_eratt_s3()
1789 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_eratt_s3()
1790 clear_bit(DEFER_ERATT, &phba->hba_flag); in lpfc_handle_eratt_s3()
1795 if (!phba->cfg_enable_hba_reset) in lpfc_handle_eratt_s3()
1801 if (test_bit(DEFER_ERATT, &phba->hba_flag)) in lpfc_handle_eratt_s3()
1804 if ((phba->work_hs & HS_FFER6) || (phba->work_hs & HS_FFER8)) { in lpfc_handle_eratt_s3()
1805 if (phba->work_hs & HS_FFER6) in lpfc_handle_eratt_s3()
1806 /* Re-establishing Link */ in lpfc_handle_eratt_s3()
1808 "1301 Re-establishing Link " in lpfc_handle_eratt_s3()
1810 phba->work_hs, phba->work_status[0], in lpfc_handle_eratt_s3()
1811 phba->work_status[1]); in lpfc_handle_eratt_s3()
1812 if (phba->work_hs & HS_FFER8) in lpfc_handle_eratt_s3()
1817 phba->work_hs, phba->work_status[0], in lpfc_handle_eratt_s3()
1818 phba->work_status[1]); in lpfc_handle_eratt_s3()
1820 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1821 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_handle_eratt_s3()
1822 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1828 * retry it after re-establishing link. in lpfc_handle_eratt_s3()
1844 } else if (phba->work_hs & HS_CRIT_TEMP) { in lpfc_handle_eratt_s3()
1845 temperature = readl(phba->MBslimaddr + TEMPERATURE_OFFSET); in lpfc_handle_eratt_s3()
1854 temperature, phba->work_hs, in lpfc_handle_eratt_s3()
1855 phba->work_status[0], phba->work_status[1]); in lpfc_handle_eratt_s3()
1857 shost = lpfc_shost_from_vport(phba->pport); in lpfc_handle_eratt_s3()
1864 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1865 phba->over_temp_state = HBA_OVER_TEMP; in lpfc_handle_eratt_s3()
1866 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1877 phba->work_hs, in lpfc_handle_eratt_s3()
1878 phba->work_status[0], phba->work_status[1]); in lpfc_handle_eratt_s3()
1892 * lpfc_sli4_port_sta_fn_reset - The SLI4 function reset due to port status reg
1910 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_port_sta_fn_reset()
1932 spin_lock_irq(&phba->hbalock); in lpfc_sli4_port_sta_fn_reset()
1933 phba->sli.sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_sli4_port_sta_fn_reset()
1934 if (phba->sli.mbox_active) { in lpfc_sli4_port_sta_fn_reset()
1935 mboxq = phba->sli.mbox_active; in lpfc_sli4_port_sta_fn_reset()
1936 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_port_sta_fn_reset()
1938 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_port_sta_fn_reset()
1939 phba->sli.mbox_active = NULL; in lpfc_sli4_port_sta_fn_reset()
1941 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_port_sta_fn_reset()
1957 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_sli4_port_sta_fn_reset()
1961 return -EIO; in lpfc_sli4_port_sta_fn_reset()
1963 phba->intr_mode = intr_mode; in lpfc_sli4_port_sta_fn_reset()
1972 * lpfc_handle_eratt_s4 - The SLI4 HBA hardware error handler
1981 struct lpfc_vport *vport = phba->pport; in lpfc_handle_eratt_s4()
1997 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_eratt_s4()
2005 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_handle_eratt_s4()
2009 phba->sli4_hba.u.if_type0.UERRLOregaddr, in lpfc_handle_eratt_s4()
2012 phba->sli4_hba.u.if_type0.UEMASKLOregaddr, in lpfc_handle_eratt_s4()
2015 if (pci_rd_rc1 == -EIO && pci_rd_rc2 == -EIO) in lpfc_handle_eratt_s4()
2017 if (!test_bit(HBA_RECOVERABLE_UE, &phba->hba_flag)) { in lpfc_handle_eratt_s4()
2024 for (i = 0; i < phba->sli4_hba.ue_to_sr / 1000; i++) { in lpfc_handle_eratt_s4()
2025 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_handle_eratt_s4()
2047 if (!lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_handle_eratt_s4()
2066 phba->link_state = LPFC_HBA_ERROR; in lpfc_handle_eratt_s4()
2072 phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_handle_eratt_s4()
2075 if (pci_rd_rc1 == -EIO) { in lpfc_handle_eratt_s4()
2078 readl(phba->sli4_hba.u.if_type2.STATUSregaddr)); in lpfc_handle_eratt_s4()
2082 reg_err1 = readl(phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_handle_eratt_s4()
2083 reg_err2 = readl(phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_handle_eratt_s4()
2090 phba->sfp_alarm |= LPFC_TRANSGRESSION_HIGH_TEMPERATURE; in lpfc_handle_eratt_s4()
2095 shost = lpfc_shost_from_vport(phba->pport); in lpfc_handle_eratt_s4()
2102 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s4()
2103 phba->over_temp_state = HBA_OVER_TEMP; in lpfc_handle_eratt_s4()
2104 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s4()
2124 if (!phba->cfg_enable_hba_reset) in lpfc_handle_eratt_s4()
2160 * lpfc_handle_eratt - Wrapper func for handling hba error attention
2167 * 0 - success.
2168 * Any other value - error.
2173 (*phba->lpfc_handle_eratt)(phba); in lpfc_handle_eratt()
2177 * lpfc_handle_latt - The HBA link event handler
2186 struct lpfc_vport *vport = phba->pport; in lpfc_handle_latt()
2187 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_latt()
2192 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_handle_latt()
2201 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_handle_latt()
2207 psli->slistat.link_event++; in lpfc_handle_latt()
2208 lpfc_read_topology(phba, pmb, pmb->ctx_buf); in lpfc_handle_latt()
2209 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_handle_latt()
2210 pmb->vport = vport; in lpfc_handle_latt()
2212 phba->sli.sli3_ring[LPFC_ELS_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_handle_latt()
2220 spin_lock_irq(&phba->hbalock); in lpfc_handle_latt()
2221 writel(HA_LATT, phba->HAregaddr); in lpfc_handle_latt()
2222 readl(phba->HAregaddr); /* flush */ in lpfc_handle_latt()
2223 spin_unlock_irq(&phba->hbalock); in lpfc_handle_latt()
2228 phba->sli.sli3_ring[LPFC_ELS_RING].flag &= ~LPFC_STOP_IOCB_EVENT; in lpfc_handle_latt()
2232 spin_lock_irq(&phba->hbalock); in lpfc_handle_latt()
2233 psli->sli_flag |= LPFC_PROCESS_LA; in lpfc_handle_latt()
2234 control = readl(phba->HCregaddr); in lpfc_handle_latt()
2236 writel(control, phba->HCregaddr); in lpfc_handle_latt()
2237 readl(phba->HCregaddr); /* flush */ in lpfc_handle_latt()
2240 writel(HA_LATT, phba->HAregaddr); in lpfc_handle_latt()
2241 readl(phba->HAregaddr); /* flush */ in lpfc_handle_latt()
2242 spin_unlock_irq(&phba->hbalock); in lpfc_handle_latt()
2244 phba->link_state = LPFC_HBA_ERROR; in lpfc_handle_latt()
2264 length -= (3+i); in lpfc_fill_vpd()
2265 while (i--) { in lpfc_fill_vpd()
2266 phba->SerialNumber[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2270 phba->SerialNumber[j] = 0; in lpfc_fill_vpd()
2273 phba->vpd_flag |= VPD_MODEL_DESC; in lpfc_fill_vpd()
2278 length -= (3+i); in lpfc_fill_vpd()
2279 while (i--) { in lpfc_fill_vpd()
2280 phba->ModelDesc[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2284 phba->ModelDesc[j] = 0; in lpfc_fill_vpd()
2287 phba->vpd_flag |= VPD_MODEL_NAME; in lpfc_fill_vpd()
2292 length -= (3+i); in lpfc_fill_vpd()
2293 while (i--) { in lpfc_fill_vpd()
2294 phba->ModelName[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2298 phba->ModelName[j] = 0; in lpfc_fill_vpd()
2301 phba->vpd_flag |= VPD_PROGRAM_TYPE; in lpfc_fill_vpd()
2306 length -= (3+i); in lpfc_fill_vpd()
2307 while (i--) { in lpfc_fill_vpd()
2308 phba->ProgramType[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2312 phba->ProgramType[j] = 0; in lpfc_fill_vpd()
2315 phba->vpd_flag |= VPD_PORT; in lpfc_fill_vpd()
2320 length -= (3 + i); in lpfc_fill_vpd()
2321 while (i--) { in lpfc_fill_vpd()
2322 if ((phba->sli_rev == LPFC_SLI_REV4) && in lpfc_fill_vpd()
2323 (phba->sli4_hba.pport_name_sta == in lpfc_fill_vpd()
2328 phba->Port[j++] = vpd[(*pindex)++]; 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()
2335 phba->Port[j] = 0; in lpfc_fill_vpd()
2342 length -= (3 + i); in lpfc_fill_vpd()
2348 * lpfc_parse_vpd - Parse VPD (Vital Product Data)
2358 * 0 - pointer to the VPD passed in is NULL
2359 * 1 - success
2378 while (!finished && (index < (len - 4))) { in lpfc_parse_vpd()
2397 if (Length > len - index) in lpfc_parse_vpd()
2398 Length = len - index; in lpfc_parse_vpd()
2416 * lpfc_get_atto_model_desc - Retrieve ATTO HBA device model name and description
2430 uint16_t sub_dev_id = phba->pcidev->subsystem_device; in lpfc_get_atto_model_desc()
2494 (tbolt) ? "ThunderLink FC " : "Celerity FC-", in lpfc_get_atto_model_desc()
2496 phba->Port); in lpfc_get_atto_model_desc()
2500 * lpfc_get_hba_model_desc - Retrieve HBA device model name and description
2515 uint16_t dev_id = phba->pcidev->device; in lpfc_get_hba_model_desc()
2529 if (phba->pcidev->vendor == PCI_VENDOR_ID_ATTO) { in lpfc_get_hba_model_desc()
2534 if (phba->lmt & LMT_64Gb) in lpfc_get_hba_model_desc()
2536 else if (phba->lmt & LMT_32Gb) in lpfc_get_hba_model_desc()
2538 else if (phba->lmt & LMT_16Gb) in lpfc_get_hba_model_desc()
2540 else if (phba->lmt & LMT_10Gb) in lpfc_get_hba_model_desc()
2542 else if (phba->lmt & LMT_8Gb) in lpfc_get_hba_model_desc()
2544 else if (phba->lmt & LMT_4Gb) in lpfc_get_hba_model_desc()
2546 else if (phba->lmt & LMT_2Gb) in lpfc_get_hba_model_desc()
2548 else if (phba->lmt & LMT_1Gb) in lpfc_get_hba_model_desc()
2553 vp = &phba->vpd; in lpfc_get_hba_model_desc()
2561 if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3) in lpfc_get_hba_model_desc()
2572 if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID) in lpfc_get_hba_model_desc()
2583 m = (typeof(m)){"LP9802", "PCI-X", in lpfc_get_hba_model_desc()
2587 m = (typeof(m)){"LP10000", "PCI-X", in lpfc_get_hba_model_desc()
2591 m = (typeof(m)){"LPX1000", "PCI-X", in lpfc_get_hba_model_desc()
2595 m = (typeof(m)){"LP982", "PCI-X", in lpfc_get_hba_model_desc()
2599 m = (typeof(m)){"LP1050", "PCI-X", in lpfc_get_hba_model_desc()
2603 m = (typeof(m)){"LP11000", "PCI-X2", in lpfc_get_hba_model_desc()
2607 m = (typeof(m)){"LP11000-SP", "PCI-X2", in lpfc_get_hba_model_desc()
2611 m = (typeof(m)){"LP11002-SP", "PCI-X2", in lpfc_get_hba_model_desc()
2619 m = (typeof(m)){"LPe1000-SP", "PCIe", in lpfc_get_hba_model_desc()
2623 m = (typeof(m)){"LPe1002-SP", "PCIe", in lpfc_get_hba_model_desc()
2627 m = (typeof(m)){"LP1150", "PCI-X2", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2630 m = (typeof(m)){"LP111", "PCI-X2", in lpfc_get_hba_model_desc()
2650 m = (typeof(m)){"LP101", "PCI-X", in lpfc_get_hba_model_desc()
2654 m = (typeof(m)){"LP10000-S", "PCI", in lpfc_get_hba_model_desc()
2658 m = (typeof(m)){"LP11000-S", "PCI-X2", in lpfc_get_hba_model_desc()
2662 m = (typeof(m)){"LPe11000-S", "PCIe", in lpfc_get_hba_model_desc()
2675 m = (typeof(m)){"LPe12002-SP", "PCIe", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2678 m = (typeof(m)){"LPe12000-SP", "PCIe", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2681 m = (typeof(m)){"LPe12000-S", "PCIe", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2692 m = (typeof(m)){"LPemv12002-S", "PCIe IOV", in lpfc_get_hba_model_desc()
2704 m = (typeof(m)){"LPSe12002-ML1-E", "PCIe", in lpfc_get_hba_model_desc()
2757 phba->Port); in lpfc_get_hba_model_desc()
2771 * lpfc_sli3_post_buffer - Post IOCB(s) with DMA buffer descriptor(s) to a IOCB ring
2789 cnt += pring->missbufcnt; in lpfc_sli3_post_buffer()
2796 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2799 icmd = &iocb->iocb; in lpfc_sli3_post_buffer()
2805 mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &mp1->phys); in lpfc_sli3_post_buffer()
2806 if (!mp1 || !mp1->virt) { in lpfc_sli3_post_buffer()
2809 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2813 INIT_LIST_HEAD(&mp1->list); in lpfc_sli3_post_buffer()
2818 mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI, in lpfc_sli3_post_buffer()
2819 &mp2->phys); in lpfc_sli3_post_buffer()
2820 if (!mp2 || !mp2->virt) { in lpfc_sli3_post_buffer()
2822 lpfc_mbuf_free(phba, mp1->virt, mp1->phys); in lpfc_sli3_post_buffer()
2825 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2829 INIT_LIST_HEAD(&mp2->list); in lpfc_sli3_post_buffer()
2834 icmd->un.cont64[0].addrHigh = putPaddrHigh(mp1->phys); in lpfc_sli3_post_buffer()
2835 icmd->un.cont64[0].addrLow = putPaddrLow(mp1->phys); in lpfc_sli3_post_buffer()
2836 icmd->un.cont64[0].tus.f.bdeSize = FCELSSIZE; in lpfc_sli3_post_buffer()
2837 icmd->ulpBdeCount = 1; in lpfc_sli3_post_buffer()
2838 cnt--; in lpfc_sli3_post_buffer()
2840 icmd->un.cont64[1].addrHigh = putPaddrHigh(mp2->phys); in lpfc_sli3_post_buffer()
2841 icmd->un.cont64[1].addrLow = putPaddrLow(mp2->phys); in lpfc_sli3_post_buffer()
2842 icmd->un.cont64[1].tus.f.bdeSize = FCELSSIZE; in lpfc_sli3_post_buffer()
2843 cnt--; in lpfc_sli3_post_buffer()
2844 icmd->ulpBdeCount = 2; in lpfc_sli3_post_buffer()
2847 icmd->ulpCommand = CMD_QUE_RING_BUF64_CN; in lpfc_sli3_post_buffer()
2848 icmd->ulpLe = 1; in lpfc_sli3_post_buffer()
2850 if (lpfc_sli_issue_iocb(phba, pring->ringno, iocb, 0) == in lpfc_sli3_post_buffer()
2852 lpfc_mbuf_free(phba, mp1->virt, mp1->phys); in lpfc_sli3_post_buffer()
2856 lpfc_mbuf_free(phba, mp2->virt, mp2->phys); in lpfc_sli3_post_buffer()
2861 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2868 pring->missbufcnt = 0; in lpfc_sli3_post_buffer()
2873 * lpfc_post_rcv_buf - Post the initial receive IOCB buffers to ELS ring
2881 * 0 - success (currently always success)
2886 struct lpfc_sli *psli = &phba->sli; in lpfc_post_rcv_buf()
2889 lpfc_sli3_post_buffer(phba, &psli->sli3_ring[LPFC_ELS_RING], LPFC_BUF_RING0); in lpfc_post_rcv_buf()
2890 /* Ring 2 - FCP no buffers needed */ in lpfc_post_rcv_buf()
2895 #define S(N,V) (((V)<<(N))|((V)>>(32-(N))))
2898 * lpfc_sha_init - Set up initial array of hash table entries
2915 * lpfc_sha_iterate - Iterate initial hash table with the working hash table
2934 HashWorkingPointer[t - 3] ^ HashWorkingPointer[t - in lpfc_sha_iterate()
2936 HashWorkingPointer[t - 14] ^ HashWorkingPointer[t - 16]); in lpfc_sha_iterate()
2972 * lpfc_challenge_key - Create challenge key based on WWPN of the HBA
2988 * lpfc_hba_init - Perform special handling for LC HBA initialization
2990 * @hbainit: pointer to an array of unsigned 32-bit integers.
2999 uint32_t *pwwnn = (uint32_t *) phba->wwnn; in lpfc_hba_init()
3009 lpfc_challenge_key(phba->RandomData + t, HashWorking + t); in lpfc_hba_init()
3017 * lpfc_cleanup - Performs vport cleanups before deleting a vport
3028 struct lpfc_hba *phba = vport->phba; in lpfc_cleanup()
3032 if (phba->link_state > LPFC_LINK_DOWN) in lpfc_cleanup()
3039 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { in lpfc_cleanup()
3040 if (vport->port_type != LPFC_PHYSICAL_PORT && in lpfc_cleanup()
3041 ndlp->nlp_DID == Fabric_DID) { in lpfc_cleanup()
3047 if (ndlp->nlp_DID == Fabric_Cntl_DID && in lpfc_cleanup()
3048 ndlp->nlp_state == NLP_STE_UNUSED_NODE) { in lpfc_cleanup()
3056 if (ndlp->nlp_type & NLP_FABRIC && in lpfc_cleanup()
3057 ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) in lpfc_cleanup()
3061 if (!(ndlp->fc4_xpt_flags & (NVME_XPT_REGD|SCSI_XPT_REGD))) in lpfc_cleanup()
3078 if (test_bit(FC_UNLOADING, &vport->load_flag) && in lpfc_cleanup()
3079 pci_channel_offline(phba->pcidev)) in lpfc_cleanup()
3080 lpfc_sli_flush_io_rings(vport->phba); in lpfc_cleanup()
3086 while (!list_empty(&vport->fc_nodes)) { in lpfc_cleanup()
3092 &vport->fc_nodes, nlp_listp) { in lpfc_cleanup()
3093 lpfc_printf_vlog(ndlp->vport, KERN_ERR, in lpfc_cleanup()
3098 ndlp->nlp_DID, (void *)ndlp, in lpfc_cleanup()
3099 kref_read(&ndlp->kref), in lpfc_cleanup()
3100 ndlp->fc4_xpt_flags, in lpfc_cleanup()
3101 ndlp->nlp_flag); in lpfc_cleanup()
3113 * lpfc_stop_vport_timers - Stop all the timers associated with a vport
3123 timer_delete_sync(&vport->els_tmofunc); in lpfc_stop_vport_timers()
3124 timer_delete_sync(&vport->delayed_disc_tmo); in lpfc_stop_vport_timers()
3130 * __lpfc_sli4_stop_fcf_redisc_wait_timer - Stop FCF rediscovery wait timer
3140 phba->fcf.fcf_flag &= ~FCF_REDISC_PEND; in __lpfc_sli4_stop_fcf_redisc_wait_timer()
3143 timer_delete(&phba->fcf.redisc_wait); in __lpfc_sli4_stop_fcf_redisc_wait_timer()
3147 * lpfc_sli4_stop_fcf_redisc_wait_timer - Stop FCF rediscovery wait timer
3158 spin_lock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3159 if (!(phba->fcf.fcf_flag & FCF_REDISC_PEND)) { in lpfc_sli4_stop_fcf_redisc_wait_timer()
3161 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3166 phba->fcf.fcf_flag &= ~(FCF_DEAD_DISC | FCF_ACVL_DISC); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3167 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3171 * lpfc_cmf_stop - Stop CMF processing
3181 int cpu; in lpfc_cmf_stop() local
3185 if (!phba->sli4_hba.pc_sli4_params.cmf) in lpfc_cmf_stop()
3192 hrtimer_cancel(&phba->cmf_stats_timer); in lpfc_cmf_stop()
3193 hrtimer_cancel(&phba->cmf_timer); in lpfc_cmf_stop()
3196 atomic_set(&phba->cmf_busy, 0); in lpfc_cmf_stop()
3197 for_each_present_cpu(cpu) { in lpfc_cmf_stop()
3198 cgs = per_cpu_ptr(phba->cmf_stat, cpu); in lpfc_cmf_stop()
3199 atomic64_set(&cgs->total_bytes, 0); in lpfc_cmf_stop()
3200 atomic64_set(&cgs->rcv_bytes, 0); in lpfc_cmf_stop()
3201 atomic_set(&cgs->rx_io_cnt, 0); in lpfc_cmf_stop()
3202 atomic64_set(&cgs->rx_latency, 0); in lpfc_cmf_stop()
3204 atomic_set(&phba->cmf_bw_wait, 0); in lpfc_cmf_stop()
3206 /* Resume any blocked IO - Queue unblock on workqueue */ in lpfc_cmf_stop()
3207 queue_work(phba->wq, &phba->unblock_request_work); in lpfc_cmf_stop()
3225 phba->cmf_interval_rate = LPFC_CMF_INTERVAL; in lpfc_cmf_signal_init()
3226 phba->cmf_max_line_rate = lpfc_get_max_line_rate(phba); in lpfc_cmf_signal_init()
3227 phba->cmf_link_byte_count = div_u64(phba->cmf_max_line_rate * in lpfc_cmf_signal_init()
3228 phba->cmf_interval_rate, 1000); in lpfc_cmf_signal_init()
3229 phba->cmf_max_bytes_per_interval = phba->cmf_link_byte_count; in lpfc_cmf_signal_init()
3236 * lpfc_cmf_start - Start CMF processing
3246 int cpu; in lpfc_cmf_start() local
3249 if (!phba->sli4_hba.pc_sli4_params.cmf || in lpfc_cmf_start()
3250 phba->cmf_active_mode == LPFC_CFG_OFF) in lpfc_cmf_start()
3256 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_cmf_start()
3257 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_cmf_start()
3258 atomic_set(&phba->cgn_sync_alarm_cnt, 0); in lpfc_cmf_start()
3259 atomic_set(&phba->cgn_sync_warn_cnt, 0); in lpfc_cmf_start()
3261 atomic_set(&phba->cmf_busy, 0); in lpfc_cmf_start()
3262 for_each_present_cpu(cpu) { in lpfc_cmf_start()
3263 cgs = per_cpu_ptr(phba->cmf_stat, cpu); in lpfc_cmf_start()
3264 atomic64_set(&cgs->total_bytes, 0); in lpfc_cmf_start()
3265 atomic64_set(&cgs->rcv_bytes, 0); in lpfc_cmf_start()
3266 atomic_set(&cgs->rx_io_cnt, 0); in lpfc_cmf_start()
3267 atomic64_set(&cgs->rx_latency, 0); in lpfc_cmf_start()
3269 phba->cmf_latency.tv_sec = 0; in lpfc_cmf_start()
3270 phba->cmf_latency.tv_nsec = 0; in lpfc_cmf_start()
3277 phba->cmf_timer_cnt = 0; in lpfc_cmf_start()
3278 hrtimer_start(&phba->cmf_timer, in lpfc_cmf_start()
3281 hrtimer_start(&phba->cmf_stats_timer, in lpfc_cmf_start()
3285 ktime_get_real_ts64(&phba->cmf_latency); in lpfc_cmf_start()
3287 atomic_set(&phba->cmf_bw_wait, 0); in lpfc_cmf_start()
3288 atomic_set(&phba->cmf_stop_io, 0); in lpfc_cmf_start()
3292 * lpfc_stop_hba_timers - Stop all the timers associated with an HBA
3301 if (phba->pport) in lpfc_stop_hba_timers()
3302 lpfc_stop_vport_timers(phba->pport); in lpfc_stop_hba_timers()
3303 cancel_delayed_work_sync(&phba->eq_delay_work); in lpfc_stop_hba_timers()
3304 cancel_delayed_work_sync(&phba->idle_stat_delay_work); in lpfc_stop_hba_timers()
3305 timer_delete_sync(&phba->sli.mbox_tmo); in lpfc_stop_hba_timers()
3306 timer_delete_sync(&phba->fabric_block_timer); in lpfc_stop_hba_timers()
3307 timer_delete_sync(&phba->eratt_poll); in lpfc_stop_hba_timers()
3308 timer_delete_sync(&phba->hb_tmofunc); in lpfc_stop_hba_timers()
3309 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_stop_hba_timers()
3310 timer_delete_sync(&phba->rrq_tmr); in lpfc_stop_hba_timers()
3311 clear_bit(HBA_RRQ_ACTIVE, &phba->hba_flag); in lpfc_stop_hba_timers()
3313 clear_bit(HBA_HBEAT_INP, &phba->hba_flag); in lpfc_stop_hba_timers()
3314 clear_bit(HBA_HBEAT_TMO, &phba->hba_flag); in lpfc_stop_hba_timers()
3316 switch (phba->pci_dev_grp) { in lpfc_stop_hba_timers()
3319 timer_delete_sync(&phba->fcp_poll_timer); in lpfc_stop_hba_timers()
3328 phba->pci_dev_grp); in lpfc_stop_hba_timers()
3335 * lpfc_block_mgmt_io - Mark a HBA's management interface as blocked
3352 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3353 phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO; in lpfc_block_mgmt_io()
3354 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3358 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3359 if (phba->sli.mbox_active) { in lpfc_block_mgmt_io()
3360 actcmd = phba->sli.mbox_active->u.mb.mbxCommand; in lpfc_block_mgmt_io()
3365 phba->sli.mbox_active)) + jiffies; in lpfc_block_mgmt_io()
3367 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3370 while (phba->sli.mbox_active) { in lpfc_block_mgmt_io()
3376 "- mbox cmd %x still active\n", in lpfc_block_mgmt_io()
3377 phba->sli.sli_flag, actcmd); in lpfc_block_mgmt_io()
3384 * lpfc_sli4_node_rpi_restore - Recover assigned RPIs for active nodes.
3398 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_sli4_node_rpi_restore()
3405 for (i = 0; i <= phba->max_vports && vports[i]; i++) { in lpfc_sli4_node_rpi_restore()
3406 if (test_bit(FC_UNLOADING, &vports[i]->load_flag)) in lpfc_sli4_node_rpi_restore()
3410 &vports[i]->fc_nodes, in lpfc_sli4_node_rpi_restore()
3414 lpfc_printf_vlog(ndlp->vport, KERN_INFO, in lpfc_sli4_node_rpi_restore()
3419 ndlp, ndlp->nlp_DID, in lpfc_sli4_node_rpi_restore()
3420 ndlp->nlp_flag); in lpfc_sli4_node_rpi_restore()
3423 ndlp->nlp_rpi = rpi; in lpfc_sli4_node_rpi_restore()
3424 lpfc_printf_vlog(ndlp->vport, KERN_INFO, in lpfc_sli4_node_rpi_restore()
3428 ndlp->nlp_rpi, ndlp, ndlp->nlp_DID, in lpfc_sli4_node_rpi_restore()
3429 ndlp->nlp_flag); in lpfc_sli4_node_rpi_restore()
3436 * lpfc_create_expedite_pool - create expedite pool
3450 epd_pool = &phba->epd_pool; in lpfc_create_expedite_pool()
3451 qp = &phba->sli4_hba.hdwq[0]; in lpfc_create_expedite_pool()
3453 spin_lock_init(&epd_pool->lock); in lpfc_create_expedite_pool()
3454 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_create_expedite_pool()
3455 spin_lock(&epd_pool->lock); in lpfc_create_expedite_pool()
3456 INIT_LIST_HEAD(&epd_pool->list); in lpfc_create_expedite_pool()
3458 &qp->lpfc_io_buf_list_put, list) { in lpfc_create_expedite_pool()
3459 list_move_tail(&lpfc_ncmd->list, &epd_pool->list); in lpfc_create_expedite_pool()
3460 lpfc_ncmd->expedite = true; in lpfc_create_expedite_pool()
3461 qp->put_io_bufs--; in lpfc_create_expedite_pool()
3462 epd_pool->count++; in lpfc_create_expedite_pool()
3463 if (epd_pool->count >= XRI_BATCH) in lpfc_create_expedite_pool()
3466 spin_unlock(&epd_pool->lock); in lpfc_create_expedite_pool()
3467 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_create_expedite_pool()
3471 * lpfc_destroy_expedite_pool - destroy expedite pool
3485 epd_pool = &phba->epd_pool; in lpfc_destroy_expedite_pool()
3486 qp = &phba->sli4_hba.hdwq[0]; in lpfc_destroy_expedite_pool()
3488 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_expedite_pool()
3489 spin_lock(&epd_pool->lock); in lpfc_destroy_expedite_pool()
3491 &epd_pool->list, list) { in lpfc_destroy_expedite_pool()
3492 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_expedite_pool()
3493 &qp->lpfc_io_buf_list_put); in lpfc_destroy_expedite_pool()
3494 lpfc_ncmd->flags = false; in lpfc_destroy_expedite_pool()
3495 qp->put_io_bufs++; in lpfc_destroy_expedite_pool()
3496 epd_pool->count--; in lpfc_destroy_expedite_pool()
3498 spin_unlock(&epd_pool->lock); in lpfc_destroy_expedite_pool()
3499 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_expedite_pool()
3503 * lpfc_create_multixri_pools - create multi-XRI pools
3525 phba->cfg_hdw_queue, phba->sli4_hba.num_present_cpu, in lpfc_create_multixri_pools()
3526 phba->sli4_hba.io_xri_cnt); in lpfc_create_multixri_pools()
3528 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_create_multixri_pools()
3531 hwq_count = phba->cfg_hdw_queue; in lpfc_create_multixri_pools()
3532 count_per_hwq = phba->sli4_hba.io_xri_cnt / hwq_count; in lpfc_create_multixri_pools()
3542 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_create_multixri_pools()
3547 qp = &phba->sli4_hba.hdwq[j]; in lpfc_create_multixri_pools()
3548 kfree(qp->p_multixri_pool); in lpfc_create_multixri_pools()
3551 phba->cfg_xri_rebalancing = 0; in lpfc_create_multixri_pools()
3555 qp = &phba->sli4_hba.hdwq[i]; in lpfc_create_multixri_pools()
3556 qp->p_multixri_pool = multixri_pool; in lpfc_create_multixri_pools()
3558 multixri_pool->xri_limit = count_per_hwq; in lpfc_create_multixri_pools()
3559 multixri_pool->rrb_next_hwqid = i; in lpfc_create_multixri_pools()
3562 pbl_pool = &multixri_pool->pbl_pool; in lpfc_create_multixri_pools()
3563 spin_lock_init(&pbl_pool->lock); in lpfc_create_multixri_pools()
3564 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_create_multixri_pools()
3565 spin_lock(&pbl_pool->lock); in lpfc_create_multixri_pools()
3566 INIT_LIST_HEAD(&pbl_pool->list); in lpfc_create_multixri_pools()
3568 &qp->lpfc_io_buf_list_put, list) { in lpfc_create_multixri_pools()
3569 list_move_tail(&lpfc_ncmd->list, &pbl_pool->list); in lpfc_create_multixri_pools()
3570 qp->put_io_bufs--; in lpfc_create_multixri_pools()
3571 pbl_pool->count++; in lpfc_create_multixri_pools()
3575 pbl_pool->count, i); in lpfc_create_multixri_pools()
3576 spin_unlock(&pbl_pool->lock); in lpfc_create_multixri_pools()
3577 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_create_multixri_pools()
3580 pvt_pool = &multixri_pool->pvt_pool; in lpfc_create_multixri_pools()
3581 pvt_pool->high_watermark = multixri_pool->xri_limit / 2; in lpfc_create_multixri_pools()
3582 pvt_pool->low_watermark = XRI_BATCH; in lpfc_create_multixri_pools()
3583 spin_lock_init(&pvt_pool->lock); in lpfc_create_multixri_pools()
3584 spin_lock_irqsave(&pvt_pool->lock, iflag); in lpfc_create_multixri_pools()
3585 INIT_LIST_HEAD(&pvt_pool->list); in lpfc_create_multixri_pools()
3586 pvt_pool->count = 0; in lpfc_create_multixri_pools()
3587 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_create_multixri_pools()
3592 * lpfc_destroy_multixri_pools - destroy multi-XRI pools
3609 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_destroy_multixri_pools()
3612 if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_destroy_multixri_pools()
3615 hwq_count = phba->cfg_hdw_queue; in lpfc_destroy_multixri_pools()
3618 qp = &phba->sli4_hba.hdwq[i]; in lpfc_destroy_multixri_pools()
3619 multixri_pool = qp->p_multixri_pool; in lpfc_destroy_multixri_pools()
3623 qp->p_multixri_pool = NULL; in lpfc_destroy_multixri_pools()
3625 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_multixri_pools()
3628 pbl_pool = &multixri_pool->pbl_pool; in lpfc_destroy_multixri_pools()
3629 spin_lock(&pbl_pool->lock); in lpfc_destroy_multixri_pools()
3633 pbl_pool->count, i); in lpfc_destroy_multixri_pools()
3636 &pbl_pool->list, list) { in lpfc_destroy_multixri_pools()
3637 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_multixri_pools()
3638 &qp->lpfc_io_buf_list_put); in lpfc_destroy_multixri_pools()
3639 qp->put_io_bufs++; in lpfc_destroy_multixri_pools()
3640 pbl_pool->count--; in lpfc_destroy_multixri_pools()
3643 INIT_LIST_HEAD(&pbl_pool->list); in lpfc_destroy_multixri_pools()
3644 pbl_pool->count = 0; in lpfc_destroy_multixri_pools()
3646 spin_unlock(&pbl_pool->lock); in lpfc_destroy_multixri_pools()
3649 pvt_pool = &multixri_pool->pvt_pool; in lpfc_destroy_multixri_pools()
3650 spin_lock(&pvt_pool->lock); in lpfc_destroy_multixri_pools()
3654 pvt_pool->count, i); in lpfc_destroy_multixri_pools()
3657 &pvt_pool->list, list) { in lpfc_destroy_multixri_pools()
3658 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_multixri_pools()
3659 &qp->lpfc_io_buf_list_put); in lpfc_destroy_multixri_pools()
3660 qp->put_io_bufs++; in lpfc_destroy_multixri_pools()
3661 pvt_pool->count--; in lpfc_destroy_multixri_pools()
3664 INIT_LIST_HEAD(&pvt_pool->list); in lpfc_destroy_multixri_pools()
3665 pvt_pool->count = 0; in lpfc_destroy_multixri_pools()
3667 spin_unlock(&pvt_pool->lock); in lpfc_destroy_multixri_pools()
3668 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_multixri_pools()
3675 * lpfc_online - Initialize and bring a HBA online
3683 * 0 - successful
3684 * 1 - failed
3696 vport = phba->pport; in lpfc_online()
3698 if (!test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) in lpfc_online()
3706 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_online()
3711 spin_lock_irq(&phba->hbalock); in lpfc_online()
3712 if (!phba->sli4_hba.max_cfg_param.vpi_used) in lpfc_online()
3714 spin_unlock_irq(&phba->hbalock); in lpfc_online()
3719 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME && in lpfc_online()
3720 !phba->nvmet_support) { in lpfc_online()
3721 error = lpfc_nvme_create_localport(phba->pport); in lpfc_online()
3737 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_online()
3738 clear_bit(FC_OFFLINE_MODE, &vports[i]->fc_flag); in lpfc_online()
3739 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) in lpfc_online()
3741 &vports[i]->fc_flag); in lpfc_online()
3742 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_online()
3744 &vports[i]->fc_flag); in lpfc_online()
3746 (vports[i]->port_type != in lpfc_online()
3748 vports[i]->vpi = 0; in lpfc_online()
3754 if (phba->cfg_xri_rebalancing) in lpfc_online()
3764 * lpfc_unblock_mgmt_io - Mark a HBA's management interface to be not blocked
3779 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_unblock_mgmt_io()
3780 phba->sli.sli_flag &= ~LPFC_BLOCK_MGMT_IO; in lpfc_unblock_mgmt_io()
3781 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_unblock_mgmt_io()
3785 * lpfc_offline_prep - Prepare a HBA to be brought offline
3796 struct lpfc_vport *vport = phba->pport; in lpfc_offline_prep()
3804 if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) in lpfc_offline_prep()
3811 offline = pci_channel_offline(phba->pcidev); in lpfc_offline_prep()
3812 hba_pci_err = test_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_offline_prep()
3817 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_offline_prep()
3818 if (test_bit(FC_UNLOADING, &vports[i]->load_flag)) in lpfc_offline_prep()
3821 spin_lock_irq(shost->host_lock); in lpfc_offline_prep()
3822 vports[i]->vpi_state &= ~LPFC_VPI_REGISTERED; in lpfc_offline_prep()
3823 spin_unlock_irq(shost->host_lock); in lpfc_offline_prep()
3824 set_bit(FC_VPORT_NEEDS_REG_VPI, &vports[i]->fc_flag); in lpfc_offline_prep()
3825 clear_bit(FC_VFI_REGISTERED, &vports[i]->fc_flag); in lpfc_offline_prep()
3828 &vports[i]->fc_nodes, in lpfc_offline_prep()
3831 clear_bit(NLP_NPR_ADISC, &ndlp->nlp_flag); in lpfc_offline_prep()
3834 &ndlp->nlp_flag); in lpfc_offline_prep()
3836 &ndlp->nlp_flag); in lpfc_offline_prep()
3839 if (ndlp->nlp_type & NLP_FABRIC) { in lpfc_offline_prep()
3851 &ndlp->save_flags) && in lpfc_offline_prep()
3852 !(ndlp->fc4_xpt_flags & in lpfc_offline_prep()
3866 if (phba->wq) in lpfc_offline_prep()
3867 flush_workqueue(phba->wq); in lpfc_offline_prep()
3871 * lpfc_offline - Bring a HBA offline
3885 if (test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_offline()
3895 lpfc_nvme_destroy_localport(phba->pport); in lpfc_offline()
3899 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) in lpfc_offline()
3907 spin_lock_irq(&phba->hbalock); in lpfc_offline()
3908 phba->work_ha = 0; in lpfc_offline()
3909 spin_unlock_irq(&phba->hbalock); in lpfc_offline()
3912 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_offline()
3914 spin_lock_irq(shost->host_lock); in lpfc_offline()
3915 vports[i]->work_port_events = 0; in lpfc_offline()
3916 spin_unlock_irq(shost->host_lock); in lpfc_offline()
3917 set_bit(FC_OFFLINE_MODE, &vports[i]->fc_flag); in lpfc_offline()
3923 if (test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_offline()
3926 if (phba->cfg_xri_rebalancing) in lpfc_offline()
3931 * lpfc_scsi_free - Free all the SCSI buffers and IOCBs from driver lists
3943 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_scsi_free()
3946 spin_lock_irq(&phba->hbalock); in lpfc_scsi_free()
3950 spin_lock(&phba->scsi_buf_list_put_lock); in lpfc_scsi_free()
3951 list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list_put, in lpfc_scsi_free()
3953 list_del(&sb->list); in lpfc_scsi_free()
3954 dma_pool_free(phba->lpfc_sg_dma_buf_pool, sb->data, in lpfc_scsi_free()
3955 sb->dma_handle); in lpfc_scsi_free()
3957 phba->total_scsi_bufs--; in lpfc_scsi_free()
3959 spin_unlock(&phba->scsi_buf_list_put_lock); in lpfc_scsi_free()
3961 spin_lock(&phba->scsi_buf_list_get_lock); in lpfc_scsi_free()
3962 list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list_get, in lpfc_scsi_free()
3964 list_del(&sb->list); in lpfc_scsi_free()
3965 dma_pool_free(phba->lpfc_sg_dma_buf_pool, sb->data, in lpfc_scsi_free()
3966 sb->dma_handle); in lpfc_scsi_free()
3968 phba->total_scsi_bufs--; in lpfc_scsi_free()
3970 spin_unlock(&phba->scsi_buf_list_get_lock); in lpfc_scsi_free()
3971 spin_unlock_irq(&phba->hbalock); in lpfc_scsi_free()
3975 * lpfc_io_free - Free all the IO buffers and IOCBs from driver lists
3989 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_free()
3990 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_free()
3992 spin_lock(&qp->io_buf_list_put_lock); in lpfc_io_free()
3994 &qp->lpfc_io_buf_list_put, in lpfc_io_free()
3996 list_del(&lpfc_ncmd->list); in lpfc_io_free()
3997 qp->put_io_bufs--; in lpfc_io_free()
3998 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_io_free()
3999 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_io_free()
4000 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_io_free()
4004 qp->total_io_bufs--; in lpfc_io_free()
4006 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_io_free()
4008 spin_lock(&qp->io_buf_list_get_lock); in lpfc_io_free()
4010 &qp->lpfc_io_buf_list_get, in lpfc_io_free()
4012 list_del(&lpfc_ncmd->list); in lpfc_io_free()
4013 qp->get_io_bufs--; in lpfc_io_free()
4014 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_io_free()
4015 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_io_free()
4016 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_io_free()
4020 qp->total_io_bufs--; in lpfc_io_free()
4022 spin_unlock(&qp->io_buf_list_get_lock); in lpfc_io_free()
4027 * lpfc_sli4_els_sgl_update - update ELS xri-sgl sizing and mapping
4036 * 0 - successful (for now, it always returns 0)
4047 * update on pci function's els xri-sgl list in lpfc_sli4_els_sgl_update()
4051 if (els_xri_cnt > phba->sli4_hba.els_xri_cnt) { in lpfc_sli4_els_sgl_update()
4052 /* els xri-sgl expanded */ in lpfc_sli4_els_sgl_update()
4053 xri_cnt = els_xri_cnt - phba->sli4_hba.els_xri_cnt; in lpfc_sli4_els_sgl_update()
4055 "3157 ELS xri-sgl count increased from " in lpfc_sli4_els_sgl_update()
4056 "%d to %d\n", phba->sli4_hba.els_xri_cnt, in lpfc_sli4_els_sgl_update()
4067 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
4070 sglq_entry->buff_type = GEN_BUFF_TYPE; in lpfc_sli4_els_sgl_update()
4071 sglq_entry->virt = lpfc_mbuf_alloc(phba, 0, in lpfc_sli4_els_sgl_update()
4072 &sglq_entry->phys); in lpfc_sli4_els_sgl_update()
4073 if (sglq_entry->virt == NULL) { in lpfc_sli4_els_sgl_update()
4079 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
4082 sglq_entry->sgl = sglq_entry->virt; in lpfc_sli4_els_sgl_update()
4083 memset(sglq_entry->sgl, 0, LPFC_BPL_SIZE); in lpfc_sli4_els_sgl_update()
4084 sglq_entry->state = SGL_FREED; in lpfc_sli4_els_sgl_update()
4085 list_add_tail(&sglq_entry->list, &els_sgl_list); in lpfc_sli4_els_sgl_update()
4087 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4089 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_sli4_els_sgl_update()
4090 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4091 } else if (els_xri_cnt < phba->sli4_hba.els_xri_cnt) { in lpfc_sli4_els_sgl_update()
4092 /* els xri-sgl shrinked */ in lpfc_sli4_els_sgl_update()
4093 xri_cnt = phba->sli4_hba.els_xri_cnt - els_xri_cnt; in lpfc_sli4_els_sgl_update()
4095 "3158 ELS xri-sgl count decreased from " in lpfc_sli4_els_sgl_update()
4096 "%d to %d\n", phba->sli4_hba.els_xri_cnt, in lpfc_sli4_els_sgl_update()
4098 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4099 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, in lpfc_sli4_els_sgl_update()
4106 __lpfc_mbuf_free(phba, sglq_entry->virt, in lpfc_sli4_els_sgl_update()
4107 sglq_entry->phys); in lpfc_sli4_els_sgl_update()
4112 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_sli4_els_sgl_update()
4113 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4116 "3163 ELS xri-sgl count unchanged: %d\n", in lpfc_sli4_els_sgl_update()
4118 phba->sli4_hba.els_xri_cnt = els_xri_cnt; in lpfc_sli4_els_sgl_update()
4124 &phba->sli4_hba.lpfc_els_sgl_list, list) { in lpfc_sli4_els_sgl_update()
4131 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
4134 sglq_entry->sli4_lxritag = lxri; in lpfc_sli4_els_sgl_update()
4135 sglq_entry->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_els_sgl_update()
4145 * lpfc_sli4_nvmet_sgl_update - update xri-sgl sizing and mapping
4154 * 0 - successful (for now, it always returns 0)
4166 * update on pci function's nvmet xri-sgl list in lpfc_sli4_nvmet_sgl_update()
4171 nvmet_xri_cnt = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4172 if (nvmet_xri_cnt > phba->sli4_hba.nvmet_xri_cnt) { in lpfc_sli4_nvmet_sgl_update()
4173 /* els xri-sgl expanded */ in lpfc_sli4_nvmet_sgl_update()
4174 xri_cnt = nvmet_xri_cnt - phba->sli4_hba.nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4176 "6302 NVMET xri-sgl cnt grew from %d to %d\n", in lpfc_sli4_nvmet_sgl_update()
4177 phba->sli4_hba.nvmet_xri_cnt, nvmet_xri_cnt); in lpfc_sli4_nvmet_sgl_update()
4187 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
4190 sglq_entry->buff_type = NVMET_BUFF_TYPE; in lpfc_sli4_nvmet_sgl_update()
4191 sglq_entry->virt = lpfc_nvmet_buf_alloc(phba, 0, in lpfc_sli4_nvmet_sgl_update()
4192 &sglq_entry->phys); in lpfc_sli4_nvmet_sgl_update()
4193 if (sglq_entry->virt == NULL) { in lpfc_sli4_nvmet_sgl_update()
4199 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
4202 sglq_entry->sgl = sglq_entry->virt; in lpfc_sli4_nvmet_sgl_update()
4203 memset(sglq_entry->sgl, 0, in lpfc_sli4_nvmet_sgl_update()
4204 phba->cfg_sg_dma_buf_size); in lpfc_sli4_nvmet_sgl_update()
4205 sglq_entry->state = SGL_FREED; in lpfc_sli4_nvmet_sgl_update()
4206 list_add_tail(&sglq_entry->list, &nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
4208 spin_lock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4209 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4211 &phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
4212 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4213 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4214 } else if (nvmet_xri_cnt < phba->sli4_hba.nvmet_xri_cnt) { in lpfc_sli4_nvmet_sgl_update()
4215 /* nvmet xri-sgl shrunk */ in lpfc_sli4_nvmet_sgl_update()
4216 xri_cnt = phba->sli4_hba.nvmet_xri_cnt - nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4218 "6305 NVMET xri-sgl count decreased from " in lpfc_sli4_nvmet_sgl_update()
4219 "%d to %d\n", phba->sli4_hba.nvmet_xri_cnt, in lpfc_sli4_nvmet_sgl_update()
4221 spin_lock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4222 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4223 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, in lpfc_sli4_nvmet_sgl_update()
4230 lpfc_nvmet_buf_free(phba, sglq_entry->virt, in lpfc_sli4_nvmet_sgl_update()
4231 sglq_entry->phys); in lpfc_sli4_nvmet_sgl_update()
4236 &phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
4237 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4238 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4241 "6306 NVMET xri-sgl count unchanged: %d\n", in lpfc_sli4_nvmet_sgl_update()
4243 phba->sli4_hba.nvmet_xri_cnt = nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4249 &phba->sli4_hba.lpfc_nvmet_sgl_list, list) { in lpfc_sli4_nvmet_sgl_update()
4256 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
4259 sglq_entry->sli4_lxritag = lxri; in lpfc_sli4_nvmet_sgl_update()
4260 sglq_entry->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_nvmet_sgl_update()
4279 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_buf_flush()
4280 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf_flush()
4281 spin_lock_irq(&qp->io_buf_list_get_lock); in lpfc_io_buf_flush()
4282 spin_lock(&qp->io_buf_list_put_lock); in lpfc_io_buf_flush()
4285 list_splice_init(&qp->lpfc_io_buf_list_get, &blist); in lpfc_io_buf_flush()
4286 list_splice(&qp->lpfc_io_buf_list_put, &blist); in lpfc_io_buf_flush()
4287 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_io_buf_flush()
4288 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_io_buf_flush()
4289 cnt += qp->get_io_bufs + qp->put_io_bufs; in lpfc_io_buf_flush()
4290 qp->get_io_bufs = 0; in lpfc_io_buf_flush()
4291 qp->put_io_bufs = 0; in lpfc_io_buf_flush()
4292 qp->total_io_bufs = 0; in lpfc_io_buf_flush()
4293 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_io_buf_flush()
4294 spin_unlock_irq(&qp->io_buf_list_get_lock); in lpfc_io_buf_flush()
4307 list_add_tail(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4310 xri = lpfc_cmd->cur_iocbq.sli4_xritag; in lpfc_io_buf_flush()
4314 if (xri < iobufp->cur_iocbq.sli4_xritag) { in lpfc_io_buf_flush()
4316 list_add(&lpfc_cmd->list, in lpfc_io_buf_flush()
4317 &prev_iobufp->list); in lpfc_io_buf_flush()
4319 list_add(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4326 list_add_tail(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4339 qp = phba->sli4_hba.hdwq; in lpfc_io_buf_replenish()
4342 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_buf_replenish()
4348 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf_replenish()
4349 lpfc_cmd->hdwq_no = idx; in lpfc_io_buf_replenish()
4350 lpfc_cmd->hdwq = qp; in lpfc_io_buf_replenish()
4351 lpfc_cmd->cur_iocbq.cmd_cmpl = NULL; in lpfc_io_buf_replenish()
4352 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflags); in lpfc_io_buf_replenish()
4353 list_add_tail(&lpfc_cmd->list, in lpfc_io_buf_replenish()
4354 &qp->lpfc_io_buf_list_put); in lpfc_io_buf_replenish()
4355 qp->put_io_bufs++; in lpfc_io_buf_replenish()
4356 qp->total_io_bufs++; in lpfc_io_buf_replenish()
4357 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, in lpfc_io_buf_replenish()
4365 * lpfc_sli4_io_sgl_update - update xri-sgl sizing and mapping
4374 * 0 - successful (for now, it always returns 0)
4386 * update on pci function's allocated nvme xri-sgl list in lpfc_sli4_io_sgl_update()
4391 io_xri_max = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt; in lpfc_sli4_io_sgl_update()
4392 phba->sli4_hba.io_xri_max = io_xri_max; in lpfc_sli4_io_sgl_update()
4397 phba->sli4_hba.io_xri_cnt, in lpfc_sli4_io_sgl_update()
4398 phba->sli4_hba.io_xri_max, in lpfc_sli4_io_sgl_update()
4403 if (phba->sli4_hba.io_xri_cnt > phba->sli4_hba.io_xri_max) { in lpfc_sli4_io_sgl_update()
4405 io_xri_cnt = phba->sli4_hba.io_xri_cnt - in lpfc_sli4_io_sgl_update()
4406 phba->sli4_hba.io_xri_max; in lpfc_sli4_io_sgl_update()
4412 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_sli4_io_sgl_update()
4413 lpfc_ncmd->data, in lpfc_sli4_io_sgl_update()
4414 lpfc_ncmd->dma_handle); in lpfc_sli4_io_sgl_update()
4418 phba->sli4_hba.io_xri_cnt -= io_xri_cnt; in lpfc_sli4_io_sgl_update()
4424 phba->sli4_hba.io_xri_cnt = cnt; in lpfc_sli4_io_sgl_update()
4433 rc = -ENOMEM; in lpfc_sli4_io_sgl_update()
4436 lpfc_ncmd->cur_iocbq.sli4_lxritag = lxri; in lpfc_sli4_io_sgl_update()
4437 lpfc_ncmd->cur_iocbq.sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_io_sgl_update()
4448 * lpfc_new_io_buf - IO buffer allocator for HBA with SLI4 IF spec
4452 * This routine allocates nvme buffers for device with SLI-4 interface spec,
4458 * int - number of IO buffers that were allocated and posted.
4472 phba->sli4_hba.io_xri_cnt = 0; in lpfc_new_io_buf()
4482 lpfc_ncmd->data = dma_pool_zalloc(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4484 &lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4485 if (!lpfc_ncmd->data) { in lpfc_new_io_buf()
4490 if (phba->cfg_xpsgl && !phba->nvmet_support) { in lpfc_new_io_buf()
4491 INIT_LIST_HEAD(&lpfc_ncmd->dma_sgl_xtra_list); in lpfc_new_io_buf()
4497 if ((phba->sli3_options & LPFC_SLI3_BG_ENABLED) && in lpfc_new_io_buf()
4498 (((unsigned long)(lpfc_ncmd->data) & in lpfc_new_io_buf()
4499 (unsigned long)(SLI4_PAGE_SIZE - 1)) != 0)) { in lpfc_new_io_buf()
4504 (unsigned long)lpfc_ncmd->data); in lpfc_new_io_buf()
4505 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4506 lpfc_ncmd->data, in lpfc_new_io_buf()
4507 lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4513 INIT_LIST_HEAD(&lpfc_ncmd->dma_cmd_rsp_list); in lpfc_new_io_buf()
4517 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4518 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4522 pwqeq = &lpfc_ncmd->cur_iocbq; in lpfc_new_io_buf()
4524 /* Allocate iotag for lpfc_ncmd->cur_iocbq. */ in lpfc_new_io_buf()
4527 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4528 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4536 pwqeq->sli4_lxritag = lxri; in lpfc_new_io_buf()
4537 pwqeq->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_new_io_buf()
4539 /* Initialize local short-hand pointers. */ in lpfc_new_io_buf()
4540 lpfc_ncmd->dma_sgl = lpfc_ncmd->data; in lpfc_new_io_buf()
4541 lpfc_ncmd->dma_phys_sgl = lpfc_ncmd->dma_handle; in lpfc_new_io_buf()
4542 lpfc_ncmd->cur_iocbq.io_buf = lpfc_ncmd; in lpfc_new_io_buf()
4543 spin_lock_init(&lpfc_ncmd->buf_lock); in lpfc_new_io_buf()
4546 list_add_tail(&lpfc_ncmd->list, &post_nblist); in lpfc_new_io_buf()
4547 phba->sli4_hba.io_xri_cnt++; in lpfc_new_io_buf()
4573 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_get_wwpn()
4576 return (uint64_t)-1; in lpfc_get_wwpn()
4585 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_get_wwpn()
4586 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_get_wwpn()
4587 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_get_wwpn()
4588 return (uint64_t) -1; in lpfc_get_wwpn()
4590 mb = &mboxq->u.mb; in lpfc_get_wwpn()
4591 memcpy(&wwn, (char *)mb->un.varRDnvp.portname, sizeof(uint64_t)); in lpfc_get_wwpn()
4593 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_get_wwpn()
4594 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_get_wwpn()
4602 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_get_sg_tablesize()
4603 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_get_sg_tablesize()
4606 return phba->cfg_scsi_seg_cnt; in lpfc_get_sg_tablesize()
4608 return phba->cfg_sg_seg_cnt; in lpfc_get_sg_tablesize()
4612 * lpfc_vmid_res_alloc - Allocates resources for VMID
4620 * Non-0 on Failure
4626 if (phba->sli_rev == LPFC_SLI_REV3) { in lpfc_vmid_res_alloc()
4627 phba->cfg_vmid_app_header = 0; in lpfc_vmid_res_alloc()
4628 phba->cfg_vmid_priority_tagging = 0; in lpfc_vmid_res_alloc()
4632 vport->vmid = in lpfc_vmid_res_alloc()
4633 kcalloc(phba->cfg_max_vmid, sizeof(struct lpfc_vmid), in lpfc_vmid_res_alloc()
4635 if (!vport->vmid) in lpfc_vmid_res_alloc()
4636 return -ENOMEM; in lpfc_vmid_res_alloc()
4638 rwlock_init(&vport->vmid_lock); in lpfc_vmid_res_alloc()
4641 vport->vmid_priority_tagging = phba->cfg_vmid_priority_tagging; in lpfc_vmid_res_alloc()
4642 vport->vmid_inactivity_timeout = in lpfc_vmid_res_alloc()
4643 phba->cfg_vmid_inactivity_timeout; in lpfc_vmid_res_alloc()
4644 vport->max_vmid = phba->cfg_max_vmid; in lpfc_vmid_res_alloc()
4645 vport->cur_vmid_cnt = 0; in lpfc_vmid_res_alloc()
4647 vport->vmid_priority_range = bitmap_zalloc in lpfc_vmid_res_alloc()
4650 if (!vport->vmid_priority_range) { in lpfc_vmid_res_alloc()
4651 kfree(vport->vmid); in lpfc_vmid_res_alloc()
4652 return -ENOMEM; in lpfc_vmid_res_alloc()
4655 hash_init(vport->hash_table); in lpfc_vmid_res_alloc()
4661 * lpfc_create_port - Create an FC port
4673 * @vport - pointer to the virtual N_Port data structure.
4674 * NULL - port create failed.
4690 if (phba->sli_rev < LPFC_SLI_REV4 && in lpfc_create_port()
4691 dev == &phba->pcidev->dev) { in lpfc_create_port()
4713 if (dev == &phba->pcidev->dev) { in lpfc_create_port()
4714 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { in lpfc_create_port()
4720 template->eh_host_reset_handler = NULL; in lpfc_create_port()
4723 template->sg_tablesize = lpfc_get_sg_tablesize(phba); in lpfc_create_port()
4733 template->sg_tablesize = lpfc_get_sg_tablesize(phba); in lpfc_create_port()
4740 vport = (struct lpfc_vport *) shost->hostdata; in lpfc_create_port()
4741 vport->phba = phba; in lpfc_create_port()
4742 set_bit(FC_LOADING, &vport->load_flag); in lpfc_create_port()
4743 set_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); in lpfc_create_port()
4744 vport->fc_rscn_flush = 0; in lpfc_create_port()
4745 atomic_set(&vport->fc_plogi_cnt, 0); in lpfc_create_port()
4746 atomic_set(&vport->fc_adisc_cnt, 0); in lpfc_create_port()
4747 atomic_set(&vport->fc_reglogin_cnt, 0); in lpfc_create_port()
4748 atomic_set(&vport->fc_prli_cnt, 0); in lpfc_create_port()
4749 atomic_set(&vport->fc_unmap_cnt, 0); in lpfc_create_port()
4750 atomic_set(&vport->fc_map_cnt, 0); in lpfc_create_port()
4751 atomic_set(&vport->fc_npr_cnt, 0); in lpfc_create_port()
4752 atomic_set(&vport->fc_unused_cnt, 0); in lpfc_create_port()
4756 vport->cfg_enable_fc4_type = phba->cfg_enable_fc4_type; in lpfc_create_port()
4758 shost->unique_id = instance; in lpfc_create_port()
4759 shost->max_id = LPFC_MAX_TARGET; in lpfc_create_port()
4760 shost->max_lun = vport->cfg_max_luns; in lpfc_create_port()
4761 shost->this_id = -1; in lpfc_create_port()
4764 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_create_port()
4766 &phba->sli4_hba.sli_intf); in lpfc_create_port()
4771 shost->max_cmd_len = LPFC_FCP_CDB_LEN_32; in lpfc_create_port()
4774 shost->max_cmd_len = LPFC_FCP_CDB_LEN; in lpfc_create_port()
4778 shost->max_cmd_len = LPFC_FCP_CDB_LEN; in lpfc_create_port()
4781 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_create_port()
4782 if (!phba->cfg_fcp_mq_threshold || in lpfc_create_port()
4783 phba->cfg_fcp_mq_threshold > phba->cfg_hdw_queue) in lpfc_create_port()
4784 phba->cfg_fcp_mq_threshold = phba->cfg_hdw_queue; in lpfc_create_port()
4786 shost->nr_hw_queues = min_t(int, 2 * num_possible_nodes(), in lpfc_create_port()
4787 phba->cfg_fcp_mq_threshold); in lpfc_create_port()
4789 shost->dma_boundary = in lpfc_create_port()
4790 phba->sli4_hba.pc_sli4_params.sge_supp_len-1; in lpfc_create_port()
4792 /* SLI-3 has a limited number of hardware queues (3), in lpfc_create_port()
4795 shost->nr_hw_queues = 1; in lpfc_create_port()
4802 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_create_port()
4803 if (dev != &phba->pcidev->dev) { in lpfc_create_port()
4804 shost->transportt = lpfc_vport_transport_template; in lpfc_create_port()
4805 vport->port_type = LPFC_NPIV_PORT; in lpfc_create_port()
4807 shost->transportt = lpfc_transport_template; in lpfc_create_port()
4808 vport->port_type = LPFC_PHYSICAL_PORT; in lpfc_create_port()
4814 vport->port_type, shost->sg_tablesize, in lpfc_create_port()
4815 phba->cfg_scsi_seg_cnt, phba->cfg_sg_seg_cnt); in lpfc_create_port()
4824 INIT_LIST_HEAD(&vport->fc_nodes); in lpfc_create_port()
4825 spin_lock_init(&vport->fc_nodes_list_lock); in lpfc_create_port()
4826 INIT_LIST_HEAD(&vport->rcv_buffer_list); in lpfc_create_port()
4827 spin_lock_init(&vport->work_port_lock); in lpfc_create_port()
4829 timer_setup(&vport->fc_disctmo, lpfc_disc_timeout, 0); in lpfc_create_port()
4831 timer_setup(&vport->els_tmofunc, lpfc_els_timeout, 0); in lpfc_create_port()
4833 timer_setup(&vport->delayed_disc_tmo, lpfc_delayed_disc_tmo, 0); in lpfc_create_port()
4835 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) in lpfc_create_port()
4838 error = scsi_add_host_with_dma(shost, dev, &phba->pcidev->dev); in lpfc_create_port()
4842 spin_lock_irq(&phba->port_list_lock); in lpfc_create_port()
4843 list_add_tail(&vport->listentry, &phba->port_list); in lpfc_create_port()
4844 spin_unlock_irq(&phba->port_list_lock); in lpfc_create_port()
4848 kfree(vport->vmid); in lpfc_create_port()
4849 bitmap_free(vport->vmid_priority_range); in lpfc_create_port()
4857 * destroy_port - destroy an FC port
4867 struct lpfc_hba *phba = vport->phba; in destroy_port()
4873 spin_lock_irq(&phba->port_list_lock); in destroy_port()
4874 list_del_init(&vport->listentry); in destroy_port()
4875 spin_unlock_irq(&phba->port_list_lock); in destroy_port()
4882 * lpfc_get_instance - Get a unique integer ID
4888 * instance - a unique integer ID allocated as the new instance.
4889 * -1 - lpfc get instance failed.
4897 return ret < 0 ? -1 : ret; in lpfc_get_instance()
4901 * lpfc_scan_finished - method for SCSI layer to detect whether scan is done
4912 * 0 - SCSI host scan is not over yet.
4913 * 1 - SCSI host scan is over.
4917 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_scan_finished()
4918 struct lpfc_hba *phba = vport->phba; in lpfc_scan_finished()
4921 spin_lock_irq(shost->host_lock); in lpfc_scan_finished()
4923 if (test_bit(FC_UNLOADING, &vport->load_flag)) { in lpfc_scan_finished()
4935 phba->link_state <= LPFC_LINK_DOWN) { in lpfc_scan_finished()
4943 if (vport->port_state != LPFC_VPORT_READY) in lpfc_scan_finished()
4945 if (vport->num_disc_nodes || vport->fc_prli_sent) in lpfc_scan_finished()
4947 if (!atomic_read(&vport->fc_map_cnt) && 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 (test_bit(HBA_FCOE_MODE, &phba->hba_flag)) 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 clear_bit(FC_LOADING, &vport->load_flag); in lpfc_host_attrib_init()
5041 * lpfc_stop_port_s3 - Stop SLI3 device port
5052 writel(0, phba->HCregaddr); in lpfc_stop_port_s3()
5053 readl(phba->HCregaddr); /* flush */ in lpfc_stop_port_s3()
5055 writel(0xffffffff, phba->HAregaddr); in lpfc_stop_port_s3()
5056 readl(phba->HAregaddr); /* flush */ in lpfc_stop_port_s3()
5060 phba->pport->work_port_events = 0; in lpfc_stop_port_s3()
5064 * lpfc_stop_port_s4 - Stop SLI4 device port
5076 if (phba->pport) in lpfc_stop_port_s4()
5077 phba->pport->work_port_events = 0; in lpfc_stop_port_s4()
5078 phba->sli4_hba.intr_enable = 0; in lpfc_stop_port_s4()
5082 * lpfc_stop_port - Wrapper function for stopping hba port
5091 phba->lpfc_stop_port(phba); in lpfc_stop_port()
5093 if (phba->wq) in lpfc_stop_port()
5094 flush_workqueue(phba->wq); in lpfc_stop_port()
5098 * lpfc_fcf_redisc_wait_start_timer - Start fcf rediscover wait timer
5109 mod_timer(&phba->fcf.redisc_wait, fcf_redisc_wait_tmo); in lpfc_fcf_redisc_wait_start_timer()
5110 spin_lock_irq(&phba->hbalock); in lpfc_fcf_redisc_wait_start_timer()
5112 phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_SCAN_DONE); in lpfc_fcf_redisc_wait_start_timer()
5114 phba->fcf.fcf_flag |= FCF_REDISC_PEND; in lpfc_fcf_redisc_wait_start_timer()
5115 spin_unlock_irq(&phba->hbalock); in lpfc_fcf_redisc_wait_start_timer()
5119 * lpfc_sli4_fcf_redisc_wait_tmo - FCF table rediscover wait timeout
5134 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
5135 if (!(phba->fcf.fcf_flag & FCF_REDISC_PEND)) { in lpfc_sli4_fcf_redisc_wait_tmo()
5136 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
5140 phba->fcf.fcf_flag &= ~FCF_REDISC_PEND; in lpfc_sli4_fcf_redisc_wait_tmo()
5142 phba->fcf.fcf_flag |= FCF_REDISC_EVT; in lpfc_sli4_fcf_redisc_wait_tmo()
5143 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
5151 * lpfc_vmid_poll - VMID timeout detection
5166 if (phba->pport->vmid_priority_tagging) { in lpfc_vmid_poll()
5168 phba->pport->work_port_events |= WORKER_CHECK_VMID_ISSUE_QFPA; in lpfc_vmid_poll()
5172 if (phba->pport->vmid_inactivity_timeout || in lpfc_vmid_poll()
5173 test_bit(FC_DEREGISTER_ALL_APP_ID, &phba->pport->load_flag)) { in lpfc_vmid_poll()
5175 phba->pport->work_port_events |= WORKER_CHECK_INACTIVE_VMID; in lpfc_vmid_poll()
5182 mod_timer(&phba->inactive_vmid_poll, in lpfc_vmid_poll()
5187 * lpfc_sli4_parse_latt_fault - Parse sli4 link-attention link fault code
5191 * This routine is to parse the SLI4 link-attention link fault code.
5221 * lpfc_sli4_parse_latt_type - Parse sli4 link attention type
5242 /* Ignore physical link up events - wait for logical link up */ in lpfc_sli4_parse_latt_type()
5259 * lpfc_sli_port_speed_get - Get sli3 link speed code to link speed
5274 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_sli_port_speed_get()
5275 switch (phba->fc_linkspeed) { in lpfc_sli_port_speed_get()
5298 if (phba->sli4_hba.link_state.logical_speed) in lpfc_sli_port_speed_get()
5300 phba->sli4_hba.link_state.logical_speed; in lpfc_sli_port_speed_get()
5302 link_speed = phba->sli4_hba.link_state.speed; in lpfc_sli_port_speed_get()
5308 * lpfc_sli4_port_speed_parse - Parse async evt link speed code to link speed
5404 * lpfc_sli4_async_link_evt - Process the asynchronous FCoE link event
5423 phba->fcoe_eventtag = acqe_link->event_tag; in lpfc_sli4_async_link_evt()
5424 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_async_link_evt()
5442 phba->sli4_hba.els_wq->pring->flag |= LPFC_STOP_IOCB_EVENT; in lpfc_sli4_async_link_evt()
5445 phba->sli.slistat.link_event++; in lpfc_sli4_async_link_evt()
5448 lpfc_read_topology(phba, pmb, pmb->ctx_buf); in lpfc_sli4_async_link_evt()
5449 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_sli4_async_link_evt()
5450 pmb->vport = phba->pport; in lpfc_sli4_async_link_evt()
5453 phba->sli4_hba.link_state.speed = in lpfc_sli4_async_link_evt()
5456 phba->sli4_hba.link_state.duplex = in lpfc_sli4_async_link_evt()
5458 phba->sli4_hba.link_state.status = in lpfc_sli4_async_link_evt()
5460 phba->sli4_hba.link_state.type = in lpfc_sli4_async_link_evt()
5462 phba->sli4_hba.link_state.number = in lpfc_sli4_async_link_evt()
5464 phba->sli4_hba.link_state.fault = in lpfc_sli4_async_link_evt()
5466 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_link_evt()
5470 "2900 Async FC/FCoE Link event - Speed:%dGBit " in lpfc_sli4_async_link_evt()
5473 phba->sli4_hba.link_state.speed, in lpfc_sli4_async_link_evt()
5474 phba->sli4_hba.link_state.topology, in lpfc_sli4_async_link_evt()
5475 phba->sli4_hba.link_state.status, in lpfc_sli4_async_link_evt()
5476 phba->sli4_hba.link_state.type, in lpfc_sli4_async_link_evt()
5477 phba->sli4_hba.link_state.number, in lpfc_sli4_async_link_evt()
5478 phba->sli4_hba.link_state.logical_speed, in lpfc_sli4_async_link_evt()
5479 phba->sli4_hba.link_state.fault); in lpfc_sli4_async_link_evt()
5482 * topology info. Note: Optional for non FC-AL ports. in lpfc_sli4_async_link_evt()
5484 if (!test_bit(HBA_FCOE_MODE, &phba->hba_flag)) { in lpfc_sli4_async_link_evt()
5496 mb = &pmb->u.mb; in lpfc_sli4_async_link_evt()
5497 mb->mbxStatus = MBX_SUCCESS; in lpfc_sli4_async_link_evt()
5503 la = (struct lpfc_mbx_read_top *) &pmb->u.mb.un.varReadTop; in lpfc_sli4_async_link_evt()
5504 la->eventTag = acqe_link->event_tag; in lpfc_sli4_async_link_evt()
5527 * lpfc_async_link_speed_to_read_top - Parse async evt link speed code to read
5581 if (!phba->rx_monitor) { in lpfc_cgn_dump_rxmonitor()
5585 lpfc_rx_monitor_report(phba, phba->rx_monitor, NULL, 0, in lpfc_cgn_dump_rxmonitor()
5591 * lpfc_cgn_update_stat - Save data into congestion stats buffer
5604 if (!phba->cgn_i) in lpfc_cgn_update_stat()
5606 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_cgn_update_stat()
5611 le32_add_cpu(&cp->link_integ_notification, 1); in lpfc_cgn_update_stat()
5612 lpfc_cgn_update_tstamp(phba, &cp->stat_lnk); in lpfc_cgn_update_stat()
5615 le32_add_cpu(&cp->delivery_notification, 1); in lpfc_cgn_update_stat()
5616 lpfc_cgn_update_tstamp(phba, &cp->stat_delivery); in lpfc_cgn_update_stat()
5619 le32_add_cpu(&cp->cgn_peer_notification, 1); in lpfc_cgn_update_stat()
5620 lpfc_cgn_update_tstamp(phba, &cp->stat_peer); in lpfc_cgn_update_stat()
5623 le32_add_cpu(&cp->cgn_notification, 1); in lpfc_cgn_update_stat()
5624 lpfc_cgn_update_tstamp(phba, &cp->stat_fpin); in lpfc_cgn_update_stat()
5626 if (phba->cgn_fpin_frequency && in lpfc_cgn_update_stat()
5627 phba->cgn_fpin_frequency != LPFC_FPIN_INIT_FREQ) { in lpfc_cgn_update_stat()
5628 value = LPFC_CGN_TIMER_TO_MIN / phba->cgn_fpin_frequency; in lpfc_cgn_update_stat()
5629 cp->cgn_stat_npm = value; in lpfc_cgn_update_stat()
5634 cp->cgn_info_crc = cpu_to_le32(value); in lpfc_cgn_update_stat()
5638 * lpfc_cgn_update_tstamp - Update cmf timestamp
5651 ts->month = tm_val.tm_mon + 1; in lpfc_cgn_update_tstamp()
5652 ts->day = tm_val.tm_mday; in lpfc_cgn_update_tstamp()
5653 ts->year = tm_val.tm_year - 100; in lpfc_cgn_update_tstamp()
5654 ts->hour = tm_val.tm_hour; in lpfc_cgn_update_tstamp()
5655 ts->minute = tm_val.tm_min; in lpfc_cgn_update_tstamp()
5656 ts->second = tm_val.tm_sec; in lpfc_cgn_update_tstamp()
5661 ts->day, ts->month, in lpfc_cgn_update_tstamp()
5662 ts->year, ts->hour, in lpfc_cgn_update_tstamp()
5663 ts->minute, ts->second); in lpfc_cgn_update_tstamp()
5667 * lpfc_cmf_stats_timer - Save data into registered congestion buffer
5693 if (!phba->cgn_i) in lpfc_cmf_stats_timer()
5695 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_cmf_stats_timer()
5697 phba->cgn_evt_timestamp = jiffies + in lpfc_cmf_stats_timer()
5699 phba->cgn_evt_minute++; in lpfc_cmf_stats_timer()
5702 lpfc_cgn_update_tstamp(phba, &cp->base_time); in lpfc_cmf_stats_timer()
5704 if (phba->cgn_fpin_frequency && in lpfc_cmf_stats_timer()
5705 phba->cgn_fpin_frequency != LPFC_FPIN_INIT_FREQ) { in lpfc_cmf_stats_timer()
5706 value = LPFC_CGN_TIMER_TO_MIN / phba->cgn_fpin_frequency; in lpfc_cmf_stats_timer()
5707 cp->cgn_stat_npm = value; in lpfc_cmf_stats_timer()
5711 lvalue = atomic_read(&phba->cgn_latency_evt_cnt); in lpfc_cmf_stats_timer()
5712 latsum = atomic64_read(&phba->cgn_latency_evt); in lpfc_cmf_stats_timer()
5713 atomic_set(&phba->cgn_latency_evt_cnt, 0); in lpfc_cmf_stats_timer()
5714 atomic64_set(&phba->cgn_latency_evt, 0); in lpfc_cmf_stats_timer()
5720 bps = div_u64(phba->rx_block_cnt, LPFC_SEC_MIN) * 512; in lpfc_cmf_stats_timer()
5721 phba->rx_block_cnt = 0; in lpfc_cmf_stats_timer()
5726 cp->cgn_info_mode = phba->cgn_p.cgn_param_mode; in lpfc_cmf_stats_timer()
5727 cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0; in lpfc_cmf_stats_timer()
5728 cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1; in lpfc_cmf_stats_timer()
5729 cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2; in lpfc_cmf_stats_timer()
5732 value = (uint16_t)(phba->pport->cfg_lun_queue_depth); in lpfc_cmf_stats_timer()
5733 cp->cgn_lunq = cpu_to_le16(value); in lpfc_cmf_stats_timer()
5735 /* Record congestion buffer info - every minute in lpfc_cmf_stats_timer()
5741 index = ++cp->cgn_index_minute; in lpfc_cmf_stats_timer()
5742 if (cp->cgn_index_minute == LPFC_MIN_HOUR) { in lpfc_cmf_stats_timer()
5743 cp->cgn_index_minute = 0; in lpfc_cmf_stats_timer()
5748 dvalue = atomic_read(&phba->cgn_driver_evt_cnt); in lpfc_cmf_stats_timer()
5749 atomic_set(&phba->cgn_driver_evt_cnt, 0); in lpfc_cmf_stats_timer()
5751 /* Get the number of warning events - FPIN and Signal for this minute */ in lpfc_cmf_stats_timer()
5753 if ((phba->cgn_reg_fpin & LPFC_CGN_FPIN_WARN) || in lpfc_cmf_stats_timer()
5754 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY || in lpfc_cmf_stats_timer()
5755 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) in lpfc_cmf_stats_timer()
5756 wvalue = atomic_read(&phba->cgn_fabric_warn_cnt); in lpfc_cmf_stats_timer()
5757 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_cmf_stats_timer()
5759 /* Get the number of alarm events - FPIN and Signal for this minute */ in lpfc_cmf_stats_timer()
5761 if ((phba->cgn_reg_fpin & LPFC_CGN_FPIN_ALARM) || in lpfc_cmf_stats_timer()
5762 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) in lpfc_cmf_stats_timer()
5763 avalue = atomic_read(&phba->cgn_fabric_alarm_cnt); in lpfc_cmf_stats_timer()
5764 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_cmf_stats_timer()
5769 ptr = &cp->cgn_drvr_min[index]; in lpfc_cmf_stats_timer()
5773 ptr = &cp->cgn_warn_min[index]; in lpfc_cmf_stats_timer()
5777 ptr = &cp->cgn_alarm_min[index]; in lpfc_cmf_stats_timer()
5781 lptr = &cp->cgn_latency_min[index]; in lpfc_cmf_stats_timer()
5790 mptr = &cp->cgn_bw_min[index]; in lpfc_cmf_stats_timer()
5794 "2418 Congestion Info - minute (%d): %d %d %d %d %d\n", in lpfc_cmf_stats_timer()
5798 if ((phba->cgn_evt_minute % LPFC_MIN_HOUR) == 0) { in lpfc_cmf_stats_timer()
5799 /* Record congestion buffer info - every hour in lpfc_cmf_stats_timer()
5802 index = ++cp->cgn_index_hour; in lpfc_cmf_stats_timer()
5803 if (cp->cgn_index_hour == LPFC_HOUR_DAY) { in lpfc_cmf_stats_timer()
5804 cp->cgn_index_hour = 0; in lpfc_cmf_stats_timer()
5815 dvalue += le16_to_cpu(cp->cgn_drvr_min[i]); in lpfc_cmf_stats_timer()
5816 wvalue += le16_to_cpu(cp->cgn_warn_min[i]); in lpfc_cmf_stats_timer()
5817 lvalue += le32_to_cpu(cp->cgn_latency_min[i]); in lpfc_cmf_stats_timer()
5818 mbps += le16_to_cpu(cp->cgn_bw_min[i]); in lpfc_cmf_stats_timer()
5819 avalue += le16_to_cpu(cp->cgn_alarm_min[i]); in lpfc_cmf_stats_timer()
5826 lptr = &cp->cgn_drvr_hr[index]; in lpfc_cmf_stats_timer()
5828 lptr = &cp->cgn_warn_hr[index]; in lpfc_cmf_stats_timer()
5830 lptr = &cp->cgn_latency_hr[index]; in lpfc_cmf_stats_timer()
5832 mptr = &cp->cgn_bw_hr[index]; in lpfc_cmf_stats_timer()
5834 lptr = &cp->cgn_alarm_hr[index]; in lpfc_cmf_stats_timer()
5838 "2419 Congestion Info - hour " in lpfc_cmf_stats_timer()
5844 if ((phba->cgn_evt_minute % LPFC_MIN_DAY) == 0) { in lpfc_cmf_stats_timer()
5845 /* Record congestion buffer info - every hour in lpfc_cmf_stats_timer()
5849 index = ++cp->cgn_index_day; in lpfc_cmf_stats_timer()
5850 if (cp->cgn_index_day == LPFC_MAX_CGN_DAYS) { in lpfc_cmf_stats_timer()
5851 cp->cgn_index_day = 0; in lpfc_cmf_stats_timer()
5862 dvalue += le32_to_cpu(cp->cgn_drvr_hr[i]); in lpfc_cmf_stats_timer()
5863 wvalue += le32_to_cpu(cp->cgn_warn_hr[i]); in lpfc_cmf_stats_timer()
5864 lvalue += le32_to_cpu(cp->cgn_latency_hr[i]); in lpfc_cmf_stats_timer()
5865 mbps += le16_to_cpu(cp->cgn_bw_hr[i]); in lpfc_cmf_stats_timer()
5866 avalue += le32_to_cpu(cp->cgn_alarm_hr[i]); in lpfc_cmf_stats_timer()
5873 lptr = &cp->cgn_drvr_day[index]; in lpfc_cmf_stats_timer()
5875 lptr = &cp->cgn_warn_day[index]; in lpfc_cmf_stats_timer()
5877 lptr = &cp->cgn_latency_day[index]; in lpfc_cmf_stats_timer()
5879 mptr = &cp->cgn_bw_day[index]; in lpfc_cmf_stats_timer()
5881 lptr = &cp->cgn_alarm_day[index]; in lpfc_cmf_stats_timer()
5885 "2420 Congestion Info - daily (%d): " in lpfc_cmf_stats_timer()
5891 value = phba->cgn_fpin_frequency; in lpfc_cmf_stats_timer()
5892 cp->cgn_warn_freq = cpu_to_le16(value); in lpfc_cmf_stats_timer()
5893 cp->cgn_alarm_freq = cpu_to_le16(value); in lpfc_cmf_stats_timer()
5897 cp->cgn_info_crc = cpu_to_le32(lvalue); in lpfc_cmf_stats_timer()
5905 * lpfc_calc_cmf_latency - latency from start of rxate timer interval
5923 if (cmpl_time.tv_sec == phba->cmf_latency.tv_sec) { in lpfc_calc_cmf_latency()
5924 msec = (cmpl_time.tv_nsec - phba->cmf_latency.tv_nsec) / in lpfc_calc_cmf_latency()
5927 if (cmpl_time.tv_nsec >= phba->cmf_latency.tv_nsec) { in lpfc_calc_cmf_latency()
5928 msec = (cmpl_time.tv_sec - in lpfc_calc_cmf_latency()
5929 phba->cmf_latency.tv_sec) * MSEC_PER_SEC; in lpfc_calc_cmf_latency()
5930 msec += ((cmpl_time.tv_nsec - in lpfc_calc_cmf_latency()
5931 phba->cmf_latency.tv_nsec) / NSEC_PER_MSEC); in lpfc_calc_cmf_latency()
5933 msec = (cmpl_time.tv_sec - phba->cmf_latency.tv_sec - in lpfc_calc_cmf_latency()
5935 msec += (((NSEC_PER_SEC - phba->cmf_latency.tv_nsec) + in lpfc_calc_cmf_latency()
5943 * lpfc_cmf_timer - This is the timer function for one congestion
5959 int cpu; in lpfc_cmf_timer() local
5962 if (phba->cmf_active_mode == LPFC_CFG_OFF || in lpfc_cmf_timer()
5963 !phba->cmf_latency.tv_sec) { in lpfc_cmf_timer()
5966 phba->cmf_active_mode, in lpfc_cmf_timer()
5967 (uint64_t)phba->cmf_latency.tv_sec); in lpfc_cmf_timer()
5974 if (!phba->pport) in lpfc_cmf_timer()
5980 atomic_set(&phba->cmf_stop_io, 1); in lpfc_cmf_timer()
5994 ktime_get_real_ts64(&phba->cmf_latency); in lpfc_cmf_timer()
5996 phba->cmf_link_byte_count = in lpfc_cmf_timer()
5997 div_u64(phba->cmf_max_line_rate * LPFC_CMF_INTERVAL, 1000); in lpfc_cmf_timer()
6004 for_each_present_cpu(cpu) { in lpfc_cmf_timer()
6005 cgs = per_cpu_ptr(phba->cmf_stat, cpu); in lpfc_cmf_timer()
6006 total += atomic64_xchg(&cgs->total_bytes, 0); in lpfc_cmf_timer()
6007 io_cnt += atomic_xchg(&cgs->rx_io_cnt, 0); in lpfc_cmf_timer()
6008 lat += atomic64_xchg(&cgs->rx_latency, 0); in lpfc_cmf_timer()
6009 rcv += atomic64_xchg(&cgs->rcv_bytes, 0); in lpfc_cmf_timer()
6017 if (phba->cmf_active_mode == LPFC_CFG_MANAGED && in lpfc_cmf_timer()
6018 phba->link_state != LPFC_LINK_DOWN && in lpfc_cmf_timer()
6019 test_bit(HBA_SETUP, &phba->hba_flag)) { in lpfc_cmf_timer()
6020 mbpi = phba->cmf_last_sync_bw; in lpfc_cmf_timer()
6021 phba->cmf_last_sync_bw = 0; in lpfc_cmf_timer()
6032 extra = cnt - total; in lpfc_cmf_timer()
6039 mbpi = phba->cmf_link_byte_count; in lpfc_cmf_timer()
6042 phba->cmf_timer_cnt++; in lpfc_cmf_timer()
6046 atomic_add(io_cnt, &phba->cgn_latency_evt_cnt); in lpfc_cmf_timer()
6047 atomic64_add(lat, &phba->cgn_latency_evt); in lpfc_cmf_timer()
6049 busy = atomic_xchg(&phba->cmf_busy, 0); in lpfc_cmf_timer()
6050 max_read = atomic_xchg(&phba->rx_max_read_cnt, 0); in lpfc_cmf_timer()
6054 if (mbpi > phba->cmf_link_byte_count || in lpfc_cmf_timer()
6055 phba->cmf_active_mode == LPFC_CFG_MONITOR) in lpfc_cmf_timer()
6056 mbpi = phba->cmf_link_byte_count; in lpfc_cmf_timer()
6061 if (mbpi != phba->cmf_max_bytes_per_interval) in lpfc_cmf_timer()
6062 phba->cmf_max_bytes_per_interval = mbpi; in lpfc_cmf_timer()
6066 if (phba->rx_monitor) { in lpfc_cmf_timer()
6071 entry.cmf_info = phba->cmf_active_info; in lpfc_cmf_timer()
6082 if (phba->cmf_active_mode == LPFC_CFG_MANAGED) in lpfc_cmf_timer()
6083 entry.timer_utilization = phba->cmf_last_ts; in lpfc_cmf_timer()
6087 phba->cmf_last_ts = 0; in lpfc_cmf_timer()
6089 lpfc_rx_monitor_record(phba->rx_monitor, &entry); in lpfc_cmf_timer()
6092 if (phba->cmf_active_mode == LPFC_CFG_MONITOR) { in lpfc_cmf_timer()
6097 atomic_inc(&phba->cgn_driver_evt_cnt); in lpfc_cmf_timer()
6099 phba->rx_block_cnt += div_u64(rcv, 512); /* save 512 byte block cnt */ in lpfc_cmf_timer()
6104 if (atomic_xchg(&phba->cmf_bw_wait, 0)) in lpfc_cmf_timer()
6105 queue_work(phba->wq, &phba->unblock_request_work); in lpfc_cmf_timer()
6108 atomic_set(&phba->cmf_stop_io, 0); in lpfc_cmf_timer()
6118 ((phba->trunk_link.link##__idx.state == LPFC_LINK_UP) ?\
6133 phba->sli4_hba.link_state.speed = in lpfc_update_trunk_link_status()
6137 phba->sli4_hba.link_state.logical_speed = in lpfc_update_trunk_link_status()
6140 phba->fc_linkspeed = in lpfc_update_trunk_link_status()
6146 phba->trunk_link.link0.state = in lpfc_update_trunk_link_status()
6149 phba->trunk_link.link0.fault = port_fault & 0x1 ? err : 0; in lpfc_update_trunk_link_status()
6153 phba->trunk_link.link1.state = in lpfc_update_trunk_link_status()
6156 phba->trunk_link.link1.fault = port_fault & 0x2 ? err : 0; in lpfc_update_trunk_link_status()
6160 phba->trunk_link.link2.state = in lpfc_update_trunk_link_status()
6163 phba->trunk_link.link2.fault = port_fault & 0x4 ? err : 0; in lpfc_update_trunk_link_status()
6167 phba->trunk_link.link3.state = in lpfc_update_trunk_link_status()
6170 phba->trunk_link.link3.fault = port_fault & 0x8 ? err : 0; in lpfc_update_trunk_link_status()
6175 phba->trunk_link.phy_lnk_speed = in lpfc_update_trunk_link_status()
6176 phba->sli4_hba.link_state.logical_speed / (cnt * 1000); in lpfc_update_trunk_link_status()
6178 phba->trunk_link.phy_lnk_speed = LPFC_LINK_SPEED_UNKNOWN; in lpfc_update_trunk_link_status()
6181 "2910 Async FC Trunking Event - Speed:%d\n" in lpfc_update_trunk_link_status()
6184 phba->sli4_hba.link_state.speed, in lpfc_update_trunk_link_status()
6185 phba->sli4_hba.link_state.logical_speed, in lpfc_update_trunk_link_status()
6189 if (phba->cmf_active_mode != LPFC_CFG_OFF) in lpfc_update_trunk_link_status()
6196 * SLI-4: We have only 0xA error codes in lpfc_update_trunk_link_status()
6208 * lpfc_sli4_async_fc_evt - Process the asynchronous FC link event
6240 phba->sli4_hba.link_state.speed = in lpfc_sli4_async_fc_evt()
6243 phba->sli4_hba.link_state.duplex = LPFC_ASYNC_LINK_DUPLEX_FULL; in lpfc_sli4_async_fc_evt()
6244 phba->sli4_hba.link_state.topology = in lpfc_sli4_async_fc_evt()
6246 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
6248 phba->sli4_hba.link_state.type = in lpfc_sli4_async_fc_evt()
6250 phba->sli4_hba.link_state.number = in lpfc_sli4_async_fc_evt()
6252 phba->sli4_hba.link_state.fault = in lpfc_sli4_async_fc_evt()
6254 phba->sli4_hba.link_state.link_status = in lpfc_sli4_async_fc_evt()
6261 if (phba->sli4_hba.link_state.status >= LPFC_FC_LA_TYPE_LINK_UP && in lpfc_sli4_async_fc_evt()
6262 phba->sli4_hba.link_state.status < LPFC_FC_LA_TYPE_ACTIVATE_FAIL) { in lpfc_sli4_async_fc_evt()
6265 phba->sli4_hba.link_state.logical_speed = 0; in lpfc_sli4_async_fc_evt()
6266 else if (!phba->sli4_hba.conf_trunk) in lpfc_sli4_async_fc_evt()
6267 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_fc_evt()
6272 "2896 Async FC event - Speed:%dGBaud Topology:x%x " in lpfc_sli4_async_fc_evt()
6275 phba->sli4_hba.link_state.speed, in lpfc_sli4_async_fc_evt()
6276 phba->sli4_hba.link_state.topology, in lpfc_sli4_async_fc_evt()
6277 phba->sli4_hba.link_state.status, in lpfc_sli4_async_fc_evt()
6278 phba->sli4_hba.link_state.type, in lpfc_sli4_async_fc_evt()
6279 phba->sli4_hba.link_state.number, in lpfc_sli4_async_fc_evt()
6280 phba->sli4_hba.link_state.logical_speed, in lpfc_sli4_async_fc_evt()
6281 phba->sli4_hba.link_state.fault, in lpfc_sli4_async_fc_evt()
6282 phba->sli4_hba.link_state.link_status); in lpfc_sli4_async_fc_evt()
6289 if (phba->sli4_hba.link_state.status >= LPFC_FC_LA_TYPE_ACTIVATE_FAIL) { in lpfc_sli4_async_fc_evt()
6290 switch (phba->sli4_hba.link_state.status) { in lpfc_sli4_async_fc_evt()
6293 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
6304 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
6312 "2992 Async FC event - Informational Link " in lpfc_sli4_async_fc_evt()
6318 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_async_fc_evt()
6335 phba->sli4_hba.els_wq->pring->flag |= LPFC_STOP_IOCB_EVENT; in lpfc_sli4_async_fc_evt()
6338 phba->sli.slistat.link_event++; in lpfc_sli4_async_fc_evt()
6341 lpfc_read_topology(phba, pmb, pmb->ctx_buf); in lpfc_sli4_async_fc_evt()
6342 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_sli4_async_fc_evt()
6343 pmb->vport = phba->pport; in lpfc_sli4_async_fc_evt()
6345 if (phba->sli4_hba.link_state.status != LPFC_FC_LA_TYPE_LINK_UP) { in lpfc_sli4_async_fc_evt()
6346 phba->link_flag &= ~(LS_MDS_LINK_DOWN | LS_MDS_LOOPBACK); in lpfc_sli4_async_fc_evt()
6348 switch (phba->sli4_hba.link_state.status) { in lpfc_sli4_async_fc_evt()
6350 phba->link_flag |= LS_MDS_LINK_DOWN; in lpfc_sli4_async_fc_evt()
6353 phba->link_flag |= LS_MDS_LOOPBACK; in lpfc_sli4_async_fc_evt()
6360 mb = &pmb->u.mb; in lpfc_sli4_async_fc_evt()
6361 mb->mbxStatus = MBX_SUCCESS; in lpfc_sli4_async_fc_evt()
6367 la = (struct lpfc_mbx_read_top *)&pmb->u.mb.un.varReadTop; in lpfc_sli4_async_fc_evt()
6368 la->eventTag = acqe_fc->event_tag; in lpfc_sli4_async_fc_evt()
6370 if (phba->sli4_hba.link_state.status == in lpfc_sli4_async_fc_evt()
6394 * lpfc_sli4_async_sli_evt - Process the asynchronous SLI link event
6418 "2901 Async SLI event - Type:%d, Event Data: x%08x " in lpfc_sli4_async_sli_evt()
6420 acqe_sli->event_data1, acqe_sli->event_data2, in lpfc_sli4_async_sli_evt()
6421 acqe_sli->event_data3, acqe_sli->trailer); in lpfc_sli4_async_sli_evt()
6423 port_name = phba->Port[0]; in lpfc_sli4_async_sli_evt()
6431 temp_event_data.data = (uint32_t)acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6434 "3190 Over Temperature:%d Celsius- Port Name %c\n", in lpfc_sli4_async_sli_evt()
6435 acqe_sli->event_data1, port_name); in lpfc_sli4_async_sli_evt()
6437 phba->sfp_warning |= LPFC_TRANSGRESSION_HIGH_TEMPERATURE; in lpfc_sli4_async_sli_evt()
6438 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli4_async_sli_evt()
6448 temp_event_data.data = (uint32_t)acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6451 "3191 Normal Temperature:%d Celsius - Port Name %c\n", in lpfc_sli4_async_sli_evt()
6452 acqe_sli->event_data1, port_name); in lpfc_sli4_async_sli_evt()
6454 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli4_async_sli_evt()
6463 &acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6466 switch (phba->sli4_hba.lnk_info.lnk_no) { in lpfc_sli4_async_sli_evt()
6469 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6471 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6475 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6477 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6481 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6483 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6487 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6489 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6496 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_async_sli_evt()
6501 if (phba->sli4_hba.lnk_info.optic_state == status) in lpfc_sli4_async_sli_evt()
6510 "installed/not installed - Reseat optics, " in lpfc_sli4_async_sli_evt()
6515 "Optics of two types installed - Remove one " in lpfc_sli4_async_sli_evt()
6519 sprintf(message, "Incompatible optics - Replace with " in lpfc_sli4_async_sli_evt()
6523 sprintf(message, "Unqualified optics - Replace with " in lpfc_sli4_async_sli_evt()
6525 "Support - Link is%s operational", in lpfc_sli4_async_sli_evt()
6529 sprintf(message, "Uncertified optics - Replace with " in lpfc_sli4_async_sli_evt()
6530 "Avago-certified optics to enable link " in lpfc_sli4_async_sli_evt()
6531 "operation - Link is%s operational", in lpfc_sli4_async_sli_evt()
6543 phba->lmt = 0; in lpfc_sli4_async_sli_evt()
6557 for (i = 0; i <= phba->max_vports && vports[i] != NULL; in lpfc_sli4_async_sli_evt()
6565 phba->sli4_hba.lnk_info.optic_state = status; in lpfc_sli4_async_sli_evt()
6571 "3192 Remote DPort Test Initiated - " in lpfc_sli4_async_sli_evt()
6573 acqe_sli->event_data1, acqe_sli->event_data2); in lpfc_sli4_async_sli_evt()
6581 * to use FA-WWN, but the attached device doesn’t support it. in lpfc_sli4_async_sli_evt()
6582 * Event Data1 - N.A, Event Data2 - N.A in lpfc_sli4_async_sli_evt()
6586 "2699 Misconfigured FA-PWWN - Attached device " in lpfc_sli4_async_sli_evt()
6587 "does not support FA-PWWN\n"); in lpfc_sli4_async_sli_evt()
6588 phba->sli4_hba.fawwpn_flag &= ~LPFC_FAWWPN_FABRIC; in lpfc_sli4_async_sli_evt()
6589 memset(phba->pport->fc_portname.u.wwn, 0, in lpfc_sli4_async_sli_evt()
6595 "2518 EEPROM failure - " in lpfc_sli4_async_sli_evt()
6597 acqe_sli->event_data1, acqe_sli->event_data2); in lpfc_sli4_async_sli_evt()
6600 if (phba->cmf_active_mode == LPFC_CFG_OFF) in lpfc_sli4_async_sli_evt()
6603 &acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6604 phba->cgn_acqe_cnt++; in lpfc_sli4_async_sli_evt()
6607 atomic64_add(cnt, &phba->cgn_acqe_stat.warn); in lpfc_sli4_async_sli_evt()
6608 atomic64_add(cgn_signal->alarm_cnt, &phba->cgn_acqe_stat.alarm); in lpfc_sli4_async_sli_evt()
6613 if (cgn_signal->alarm_cnt) { in lpfc_sli4_async_sli_evt()
6614 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { in lpfc_sli4_async_sli_evt()
6616 atomic_add(cgn_signal->alarm_cnt, in lpfc_sli4_async_sli_evt()
6617 &phba->cgn_sync_alarm_cnt); in lpfc_sli4_async_sli_evt()
6621 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY || in lpfc_sli4_async_sli_evt()
6622 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { in lpfc_sli4_async_sli_evt()
6624 atomic_add(cnt, &phba->cgn_sync_warn_cnt); in lpfc_sli4_async_sli_evt()
6634 acqe_sli->event_data1, acqe_sli->event_data2, in lpfc_sli4_async_sli_evt()
6635 acqe_sli->event_data3); in lpfc_sli4_async_sli_evt()
6651 * lpfc_sli4_perform_vport_cvl - Perform clear virtual link on a vport
6669 phba = vport->phba; in lpfc_sli4_perform_vport_cvl()
6679 ndlp->nlp_type |= NLP_FABRIC; in lpfc_sli4_perform_vport_cvl()
6683 if ((phba->pport->port_state < LPFC_FLOGI) && in lpfc_sli4_perform_vport_cvl()
6684 (phba->pport->port_state != LPFC_VPORT_FAILED)) in lpfc_sli4_perform_vport_cvl()
6687 if ((vport != phba->pport) && (vport->port_state < LPFC_FDISC) in lpfc_sli4_perform_vport_cvl()
6688 && (vport->port_state != LPFC_VPORT_FAILED)) in lpfc_sli4_perform_vport_cvl()
6695 set_bit(FC_VPORT_CVL_RCVD, &vport->fc_flag); in lpfc_sli4_perform_vport_cvl()
6701 * lpfc_sli4_perform_all_vport_cvl - Perform clear virtual link on all vports
6715 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) in lpfc_sli4_perform_all_vport_cvl()
6721 * lpfc_sli4_async_fip_evt - Process the asynchronous FCoE FIP event
6739 phba->fc_eventTag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6740 phba->fcoe_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6748 acqe_fip->event_tag, in lpfc_sli4_async_fip_evt()
6749 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6755 acqe_fip->event_tag, in lpfc_sli4_async_fip_evt()
6756 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6757 if (phba->fcf.fcf_flag & FCF_DISCOVERY) { in lpfc_sli4_async_fip_evt()
6767 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6768 rc = lpfc_sli4_read_fcf_rec(phba, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6772 if (test_bit(FCF_TS_INPROG, &phba->hba_flag)) in lpfc_sli4_async_fip_evt()
6774 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6776 if (phba->fcf.fcf_flag & (FCF_REDISC_EVT | FCF_REDISC_PEND)) { in lpfc_sli4_async_fip_evt()
6777 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6782 if (phba->fcf.fcf_flag & FCF_SCAN_DONE) { in lpfc_sli4_async_fip_evt()
6783 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6786 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6788 /* Otherwise, scan the entire FCF table and re-discover SAN */ in lpfc_sli4_async_fip_evt()
6792 acqe_fip->event_tag, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6805 acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6809 phba->fcoe_cvl_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6812 "tag:x%x\n", acqe_fip->index, in lpfc_sli4_async_fip_evt()
6813 acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6818 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6819 if ((phba->fcf.fcf_flag & FCF_DISCOVERY) && in lpfc_sli4_async_fip_evt()
6820 (phba->fcf.current_rec.fcf_indx != acqe_fip->index)) { in lpfc_sli4_async_fip_evt()
6821 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6823 lpfc_sli4_fcf_rr_index_clear(phba, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6826 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6829 if (phba->fcf.current_rec.fcf_indx != acqe_fip->index) in lpfc_sli4_async_fip_evt()
6838 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6840 phba->fcf.fcf_flag |= FCF_DEAD_DISC; in lpfc_sli4_async_fip_evt()
6841 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6846 "\n", acqe_fip->event_tag, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6854 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6855 phba->fcf.fcf_flag &= ~FCF_DEAD_DISC; in lpfc_sli4_async_fip_evt()
6856 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6873 phba->fcoe_cvl_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6877 " tag 0x%x\n", acqe_fip->index, acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6880 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6888 for (i = 0; i <= phba->max_vports && vports[i] != NULL; in lpfc_sli4_async_fip_evt()
6891 &vports[i]->fc_flag) && in lpfc_sli4_async_fip_evt()
6892 vports[i]->port_state > LPFC_FDISC) { in lpfc_sli4_async_fip_evt()
6901 * Don't re-instantiate if vport is marked for deletion. in lpfc_sli4_async_fip_evt()
6905 if (!test_bit(FC_UNLOADING, &vport->load_flag) && in lpfc_sli4_async_fip_evt()
6909 * re-instantiate the Vlink using FDISC. in lpfc_sli4_async_fip_evt()
6911 mod_timer(&ndlp->nlp_delayfunc, in lpfc_sli4_async_fip_evt()
6913 set_bit(NLP_DELAY_TMO, &ndlp->nlp_flag); in lpfc_sli4_async_fip_evt()
6914 ndlp->nlp_last_elscmd = ELS_CMD_FDISC; in lpfc_sli4_async_fip_evt()
6915 vport->port_state = LPFC_FDISC; in lpfc_sli4_async_fip_evt()
6924 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6925 if (phba->fcf.fcf_flag & FCF_DISCOVERY) { in lpfc_sli4_async_fip_evt()
6926 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6930 phba->fcf.fcf_flag |= FCF_ACVL_DISC; in lpfc_sli4_async_fip_evt()
6931 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6935 "evt_tag:x%x\n", acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6943 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6944 phba->fcf.fcf_flag &= ~FCF_ACVL_DISC; in lpfc_sli4_async_fip_evt()
6945 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6947 * Last resort will be re-try on the in lpfc_sli4_async_fip_evt()
6962 "0x%x\n", event_type, acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6968 * lpfc_sli4_async_dcbx_evt - Process the asynchronous dcbx event
6978 phba->fc_eventTag = acqe_dcbx->event_tag; in lpfc_sli4_async_dcbx_evt()
6985 * lpfc_sli4_async_grp5_evt - Process the asynchronous group5 event
6999 phba->fc_eventTag = acqe_grp5->event_tag; in lpfc_sli4_async_grp5_evt()
7000 phba->fcoe_eventtag = acqe_grp5->event_tag; in lpfc_sli4_async_grp5_evt()
7001 prev_ll_spd = phba->sli4_hba.link_state.logical_speed; in lpfc_sli4_async_grp5_evt()
7002 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_grp5_evt()
7007 phba->sli4_hba.link_state.logical_speed); in lpfc_sli4_async_grp5_evt()
7011 * lpfc_sli4_async_cmstat_evt - Process the asynchronous cmstat event
7020 if (!phba->cgn_i) in lpfc_sli4_async_cmstat_evt()
7026 * lpfc_cgn_params_val - Validate FW congestion parameters.
7036 spin_lock_irq(&phba->hbalock); in lpfc_cgn_params_val()
7038 if (!lpfc_rangecheck(p_cfg_param->cgn_param_mode, LPFC_CFG_OFF, in lpfc_cgn_params_val()
7042 p_cfg_param->cgn_param_mode); in lpfc_cgn_params_val()
7043 p_cfg_param->cgn_param_mode = LPFC_CFG_OFF; in lpfc_cgn_params_val()
7046 spin_unlock_irq(&phba->hbalock); in lpfc_cgn_params_val()
7056 * lpfc_cgn_params_parse - Process a FW cong parm change event
7063 * valid, in-range values. If the signature magic is correct and
7079 if (p_cgn_param->cgn_param_magic == LPFC_CFG_PARAM_MAGIC_NUM) { in lpfc_cgn_params_parse()
7087 p_cgn_param->cgn_param_magic, in lpfc_cgn_params_parse()
7088 p_cgn_param->cgn_param_version, in lpfc_cgn_params_parse()
7089 p_cgn_param->cgn_param_mode, in lpfc_cgn_params_parse()
7090 p_cgn_param->cgn_param_level0, in lpfc_cgn_params_parse()
7091 p_cgn_param->cgn_param_level1, in lpfc_cgn_params_parse()
7092 p_cgn_param->cgn_param_level2, in lpfc_cgn_params_parse()
7093 p_cgn_param->byte13, in lpfc_cgn_params_parse()
7094 p_cgn_param->byte14, in lpfc_cgn_params_parse()
7095 p_cgn_param->byte15, in lpfc_cgn_params_parse()
7096 p_cgn_param->byte11, in lpfc_cgn_params_parse()
7097 p_cgn_param->byte12, in lpfc_cgn_params_parse()
7098 phba->cmf_active_mode); in lpfc_cgn_params_parse()
7100 oldmode = phba->cmf_active_mode; in lpfc_cgn_params_parse()
7108 spin_lock_irq(&phba->hbalock); in lpfc_cgn_params_parse()
7109 memcpy(&phba->cgn_p, p_cgn_param, in lpfc_cgn_params_parse()
7113 if (phba->cgn_i) { in lpfc_cgn_params_parse()
7114 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_cgn_params_parse()
7115 cp->cgn_info_mode = phba->cgn_p.cgn_param_mode; in lpfc_cgn_params_parse()
7116 cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0; in lpfc_cgn_params_parse()
7117 cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1; in lpfc_cgn_params_parse()
7118 cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2; in lpfc_cgn_params_parse()
7121 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_cgn_params_parse()
7123 spin_unlock_irq(&phba->hbalock); in lpfc_cgn_params_parse()
7125 phba->cmf_active_mode = phba->cgn_p.cgn_param_mode; in lpfc_cgn_params_parse()
7129 if (phba->cgn_p.cgn_param_mode != LPFC_CFG_OFF) { in lpfc_cgn_params_parse()
7133 if (phba->link_state >= LPFC_LINK_UP) { in lpfc_cgn_params_parse()
7134 phba->cgn_reg_fpin = in lpfc_cgn_params_parse()
7135 phba->cgn_init_reg_fpin; in lpfc_cgn_params_parse()
7136 phba->cgn_reg_signal = in lpfc_cgn_params_parse()
7137 phba->cgn_init_reg_signal; in lpfc_cgn_params_parse()
7138 lpfc_issue_els_edc(phba->pport, 0); in lpfc_cgn_params_parse()
7143 switch (phba->cgn_p.cgn_param_mode) { in lpfc_cgn_params_parse()
7147 if (phba->link_state >= LPFC_LINK_UP) in lpfc_cgn_params_parse()
7148 lpfc_issue_els_edc(phba->pport, 0); in lpfc_cgn_params_parse()
7151 phba->cmf_max_bytes_per_interval = in lpfc_cgn_params_parse()
7152 phba->cmf_link_byte_count; in lpfc_cgn_params_parse()
7154 /* Resume blocked IO - unblock on workqueue */ in lpfc_cgn_params_parse()
7155 queue_work(phba->wq, in lpfc_cgn_params_parse()
7156 &phba->unblock_request_work); in lpfc_cgn_params_parse()
7161 switch (phba->cgn_p.cgn_param_mode) { in lpfc_cgn_params_parse()
7165 if (phba->link_state >= LPFC_LINK_UP) in lpfc_cgn_params_parse()
7166 lpfc_issue_els_edc(phba->pport, 0); in lpfc_cgn_params_parse()
7175 oldmode != phba->cgn_p.cgn_param_mode) { in lpfc_cgn_params_parse()
7176 if (phba->cgn_p.cgn_param_mode == LPFC_CFG_MANAGED) in lpfc_cgn_params_parse()
7178 phba->cgn_p.cgn_param_level0); in lpfc_cgn_params_parse()
7182 dev_info(&phba->pcidev->dev, "%d: " in lpfc_cgn_params_parse()
7184 phba->brd_no, in lpfc_cgn_params_parse()
7186 [phba->cgn_p.cgn_param_mode], in lpfc_cgn_params_parse()
7192 "version %d\n", p_cgn_param->cgn_param_magic, in lpfc_cgn_params_parse()
7193 p_cgn_param->cgn_param_version); in lpfc_cgn_params_parse()
7198 * lpfc_sli4_cgn_params_read - Read and Validate FW congestion parameters.
7207 * -Eval if an error was encountered
7222 return -ENOMEM; in lpfc_sli4_cgn_params_read()
7254 * lpfc_sli4_cgn_parm_chg_evt - Process a FW congestion param change event
7276 if (!phba->sli4_hba.pc_sli4_params.cmf) { in lpfc_sli4_cgn_parm_chg_evt()
7279 return -EACCES; in lpfc_sli4_cgn_parm_chg_evt()
7299 * lpfc_sli4_async_event_proc - Process all the pending asynchronous event
7311 clear_bit(ASYNC_EVENT, &phba->hba_flag); in lpfc_sli4_async_event_proc()
7314 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
7315 while (!list_empty(&phba->sli4_hba.sp_asynce_work_queue)) { in lpfc_sli4_async_event_proc()
7316 list_remove_head(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_async_event_proc()
7318 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, in lpfc_sli4_async_event_proc()
7322 switch (bf_get(lpfc_trailer_code, &cq_event->cqe.mcqe_cmpl)) { in lpfc_sli4_async_event_proc()
7325 &cq_event->cqe.acqe_link); in lpfc_sli4_async_event_proc()
7328 lpfc_sli4_async_fip_evt(phba, &cq_event->cqe.acqe_fip); in lpfc_sli4_async_event_proc()
7332 &cq_event->cqe.acqe_dcbx); in lpfc_sli4_async_event_proc()
7336 &cq_event->cqe.acqe_grp5); in lpfc_sli4_async_event_proc()
7339 lpfc_sli4_async_fc_evt(phba, &cq_event->cqe.acqe_fc); in lpfc_sli4_async_event_proc()
7342 lpfc_sli4_async_sli_evt(phba, &cq_event->cqe.acqe_sli); in lpfc_sli4_async_event_proc()
7349 &cq_event->cqe.mcqe_cmpl)); in lpfc_sli4_async_event_proc()
7355 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
7357 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
7361 * lpfc_sli4_fcf_redisc_event_proc - Process fcf table rediscovery event
7371 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_event_proc()
7373 phba->fcf.fcf_flag &= ~FCF_REDISC_EVT; in lpfc_sli4_fcf_redisc_event_proc()
7375 phba->fcf.failover_rec.flag = 0; in lpfc_sli4_fcf_redisc_event_proc()
7377 phba->fcf.fcf_flag |= FCF_REDISC_FOV; in lpfc_sli4_fcf_redisc_event_proc()
7378 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_event_proc()
7380 /* Scan FCF table from the first entry to re-discover SAN */ in lpfc_sli4_fcf_redisc_event_proc()
7382 "2777 Start post-quiescent FCF table scan\n"); in lpfc_sli4_fcf_redisc_event_proc()
7391 * lpfc_api_table_setup - Set up per hba pci-device group func api jump table
7393 * @dev_grp: The HBA PCI-Device group number.
7395 * This routine is invoked to set up the per HBA PCI-Device group function
7398 * Return: 0 if success, otherwise -ENODEV
7405 /* Set up lpfc PCI-device group */ in lpfc_api_table_setup()
7406 phba->pci_dev_grp = dev_grp; in lpfc_api_table_setup()
7410 phba->sli_rev = LPFC_SLI_REV4; in lpfc_api_table_setup()
7415 return -ENODEV; in lpfc_api_table_setup()
7419 return -ENODEV; in lpfc_api_table_setup()
7423 return -ENODEV; in lpfc_api_table_setup()
7427 return -ENODEV; in lpfc_api_table_setup()
7433 * lpfc_log_intr_mode - Log the active interrupt mode
7453 "0480 Enabled MSI-X interrupt mode.\n"); in lpfc_log_intr_mode()
7464 * lpfc_enable_pci_dev - Enable a generic PCI device.
7471 * 0 - successful
7472 * other values - error
7480 if (!phba->pcidev) in lpfc_enable_pci_dev()
7483 pdev = phba->pcidev; in lpfc_enable_pci_dev()
7497 pdev->needs_freset = 1; in lpfc_enable_pci_dev()
7506 return -ENODEV; in lpfc_enable_pci_dev()
7510 * lpfc_disable_pci_dev - Disable a generic PCI device.
7522 if (!phba->pcidev) in lpfc_disable_pci_dev()
7525 pdev = phba->pcidev; in lpfc_disable_pci_dev()
7534 * lpfc_reset_hba - Reset a hba
7548 if (!phba->cfg_enable_hba_reset) { in lpfc_reset_hba()
7549 phba->link_state = LPFC_HBA_ERROR; in lpfc_reset_hba()
7554 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE) { in lpfc_reset_hba()
7557 if (test_bit(MBX_TMO_ERR, &phba->bit_flags)) { in lpfc_reset_hba()
7566 clear_bit(MBX_TMO_ERR, &phba->bit_flags); in lpfc_reset_hba()
7579 * lpfc_sli_sriov_nr_virtfn_get - Get the number of sr-iov virtual functions
7582 * This function enables the PCI SR-IOV virtual functions to a physical
7583 * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
7585 * not all devices support SR-IOV, the return code from the pci_enable_sriov()
7591 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_sriov_nr_virtfn_get()
7604 * lpfc_sli_probe_sriov_nr_virtfn - Enable a number of sr-iov virtual functions
7608 * This function enables the PCI SR-IOV virtual functions to a physical
7609 * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
7611 * not all devices support SR-IOV, the return code from the pci_enable_sriov()
7617 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_probe_sriov_nr_virtfn()
7626 return -EINVAL; in lpfc_sli_probe_sriov_nr_virtfn()
7652 * lpfc_setup_driver_resource_phase1 - Phase1 etup driver internal resources.
7659 * 0 - successful
7660 * other values - error
7665 struct lpfc_sli *psli = &phba->sli; in lpfc_setup_driver_resource_phase1()
7670 atomic_set(&phba->fast_event_count, 0); in lpfc_setup_driver_resource_phase1()
7671 atomic_set(&phba->dbg_log_idx, 0); in lpfc_setup_driver_resource_phase1()
7672 atomic_set(&phba->dbg_log_cnt, 0); in lpfc_setup_driver_resource_phase1()
7673 atomic_set(&phba->dbg_log_dmping, 0); in lpfc_setup_driver_resource_phase1()
7674 spin_lock_init(&phba->hbalock); in lpfc_setup_driver_resource_phase1()
7677 spin_lock_init(&phba->port_list_lock); in lpfc_setup_driver_resource_phase1()
7678 INIT_LIST_HEAD(&phba->port_list); in lpfc_setup_driver_resource_phase1()
7680 INIT_LIST_HEAD(&phba->work_list); in lpfc_setup_driver_resource_phase1()
7683 init_waitqueue_head(&phba->work_waitq); in lpfc_setup_driver_resource_phase1()
7687 ((phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ? in lpfc_setup_driver_resource_phase1()
7689 ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) ? in lpfc_setup_driver_resource_phase1()
7691 (phba->nvmet_support ? "NVMET" : " ")); in lpfc_setup_driver_resource_phase1()
7694 spin_lock_init(&phba->ras_fwlog_lock); in lpfc_setup_driver_resource_phase1()
7697 spin_lock_init(&phba->scsi_buf_list_get_lock); in lpfc_setup_driver_resource_phase1()
7698 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_get); in lpfc_setup_driver_resource_phase1()
7699 spin_lock_init(&phba->scsi_buf_list_put_lock); in lpfc_setup_driver_resource_phase1()
7700 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_put); in lpfc_setup_driver_resource_phase1()
7703 INIT_LIST_HEAD(&phba->fabric_iocb_list); in lpfc_setup_driver_resource_phase1()
7706 INIT_LIST_HEAD(&phba->elsbuf); in lpfc_setup_driver_resource_phase1()
7709 INIT_LIST_HEAD(&phba->fcf_conn_rec_list); in lpfc_setup_driver_resource_phase1()
7712 spin_lock_init(&phba->devicelock); in lpfc_setup_driver_resource_phase1()
7713 INIT_LIST_HEAD(&phba->luns); in lpfc_setup_driver_resource_phase1()
7716 timer_setup(&psli->mbox_tmo, lpfc_mbox_timeout, 0); in lpfc_setup_driver_resource_phase1()
7718 timer_setup(&phba->fabric_block_timer, lpfc_fabric_block_timeout, 0); in lpfc_setup_driver_resource_phase1()
7720 timer_setup(&phba->eratt_poll, lpfc_poll_eratt, 0); in lpfc_setup_driver_resource_phase1()
7722 timer_setup(&phba->hb_tmofunc, lpfc_hb_timeout, 0); in lpfc_setup_driver_resource_phase1()
7724 INIT_DELAYED_WORK(&phba->eq_delay_work, lpfc_hb_eq_delay_work); in lpfc_setup_driver_resource_phase1()
7726 INIT_DELAYED_WORK(&phba->idle_stat_delay_work, in lpfc_setup_driver_resource_phase1()
7728 INIT_WORK(&phba->unblock_request_work, lpfc_unblock_requests_work); in lpfc_setup_driver_resource_phase1()
7733 * lpfc_sli_driver_resource_setup - Setup driver internal resources for SLI3 dev
7737 * support the SLI-3 HBA device it attached to.
7740 * 0 - successful
7741 * other values - error
7753 timer_setup(&phba->fcp_poll_timer, lpfc_poll_timeout, 0); in lpfc_sli_driver_resource_setup()
7756 phba->work_ha_mask = (HA_ERATT | HA_MBATT | HA_LATT); in lpfc_sli_driver_resource_setup()
7757 phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING * 4)); in lpfc_sli_driver_resource_setup()
7761 /* Set up phase-1 common device driver resources */ in lpfc_sli_driver_resource_setup()
7765 return -ENODEV; in lpfc_sli_driver_resource_setup()
7767 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
7768 phba->sli.sli3_ring = kcalloc(LPFC_SLI3_MAX_RING, in lpfc_sli_driver_resource_setup()
7771 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
7772 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7779 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_driver_resource_setup()
7785 if (phba->cfg_enable_bg) { in lpfc_sli_driver_resource_setup()
7787 * The scsi_buf for a T10-DIF I/O will hold the FCP cmnd, in lpfc_sli_driver_resource_setup()
7795 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
7799 if (phba->cfg_sg_seg_cnt > LPFC_MAX_SG_SEG_CNT_DIF) in lpfc_sli_driver_resource_setup()
7800 phba->cfg_sg_seg_cnt = LPFC_MAX_SG_SEG_CNT_DIF; in lpfc_sli_driver_resource_setup()
7803 phba->cfg_total_seg_cnt = LPFC_MAX_SG_SEG_CNT; in lpfc_sli_driver_resource_setup()
7810 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
7812 ((phba->cfg_sg_seg_cnt + 2) * entry_sz); in lpfc_sli_driver_resource_setup()
7815 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + 2; in lpfc_sli_driver_resource_setup()
7820 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
7821 phba->cfg_total_seg_cnt); in lpfc_sli_driver_resource_setup()
7823 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli_driver_resource_setup()
7825 phba->max_vports = 0; in lpfc_sli_driver_resource_setup()
7835 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7837 phba->lpfc_sg_dma_buf_pool = in lpfc_sli_driver_resource_setup()
7839 &phba->pcidev->dev, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
7842 if (!phba->lpfc_sg_dma_buf_pool) in lpfc_sli_driver_resource_setup()
7845 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli_driver_resource_setup()
7847 &phba->pcidev->dev, in lpfc_sli_driver_resource_setup()
7852 if (!phba->lpfc_cmd_rsp_buf_pool) in lpfc_sli_driver_resource_setup()
7856 * Enable sr-iov virtual functions if supported and configured in lpfc_sli_driver_resource_setup()
7859 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli_driver_resource_setup()
7861 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
7864 "2808 Requested number of SR-IOV " in lpfc_sli_driver_resource_setup()
7867 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
7868 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli_driver_resource_setup()
7875 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli_driver_resource_setup()
7876 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli_driver_resource_setup()
7879 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7883 * lpfc_sli_driver_resource_unset - Unset drvr internal resources for SLI3 dev
7887 * specific for supporting the SLI-3 HBA device it attached to.
7899 * lpfc_sli4_driver_resource_setup - Setup drvr internal resources for SLI4 dev
7903 * support the SLI-4 HBA device it attached to.
7906 * 0 - successful
7907 * other values - error
7921 phba->sli4_hba.num_present_cpu = lpfc_present_cpu; in lpfc_sli4_driver_resource_setup()
7922 phba->sli4_hba.num_possible_cpu = cpumask_last(cpu_possible_mask) + 1; in lpfc_sli4_driver_resource_setup()
7923 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_setup()
7928 /* Set up phase-1 common device driver resources */ in lpfc_sli4_driver_resource_setup()
7931 return -ENODEV; in lpfc_sli4_driver_resource_setup()
7936 return -ENODEV; in lpfc_sli4_driver_resource_setup()
7941 phba->wq = alloc_workqueue("lpfc_wq", WQ_MEM_RECLAIM, 0); in lpfc_sli4_driver_resource_setup()
7942 if (!phba->wq) in lpfc_sli4_driver_resource_setup()
7943 return -ENOMEM; in lpfc_sli4_driver_resource_setup()
7949 timer_setup(&phba->rrq_tmr, lpfc_rrq_timeout, 0); in lpfc_sli4_driver_resource_setup()
7952 timer_setup(&phba->fcf.redisc_wait, lpfc_sli4_fcf_redisc_wait_tmo, 0); in lpfc_sli4_driver_resource_setup()
7955 hrtimer_setup(&phba->cmf_timer, lpfc_cmf_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in lpfc_sli4_driver_resource_setup()
7957 hrtimer_setup(&phba->cmf_stats_timer, lpfc_cmf_stats_timer, CLOCK_MONOTONIC, in lpfc_sli4_driver_resource_setup()
7961 * Control structure for handling external multi-buffer mailbox in lpfc_sli4_driver_resource_setup()
7962 * command pass-through. in lpfc_sli4_driver_resource_setup()
7964 memset((uint8_t *)&phba->mbox_ext_buf_ctx, 0, in lpfc_sli4_driver_resource_setup()
7966 INIT_LIST_HEAD(&phba->mbox_ext_buf_ctx.ext_dmabuf_list); in lpfc_sli4_driver_resource_setup()
7968 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli4_driver_resource_setup()
7971 phba->max_vports = 0; in lpfc_sli4_driver_resource_setup()
7974 phba->valid_vlan = 0; in lpfc_sli4_driver_resource_setup()
7975 phba->fc_map[0] = LPFC_FCOE_FCF_MAP0; in lpfc_sli4_driver_resource_setup()
7976 phba->fc_map[1] = LPFC_FCOE_FCF_MAP1; in lpfc_sli4_driver_resource_setup()
7977 phba->fc_map[2] = LPFC_FCOE_FCF_MAP2; in lpfc_sli4_driver_resource_setup()
7986 INIT_LIST_HEAD(&phba->hbqs[LPFC_ELS_HBQ].hbq_buffer_list); in lpfc_sli4_driver_resource_setup()
7987 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_sli4_rb_alloc; in lpfc_sli4_driver_resource_setup()
7988 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_sli4_rb_free; in lpfc_sli4_driver_resource_setup()
7992 timer_setup(&phba->inactive_vmid_poll, lpfc_vmid_poll, 0); in lpfc_sli4_driver_resource_setup()
7998 spin_lock_init(&phba->sli4_hba.abts_io_buf_list_lock); in lpfc_sli4_driver_resource_setup()
7999 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_io_buf_list); in lpfc_sli4_driver_resource_setup()
8001 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
8003 spin_lock_init(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_sli4_driver_resource_setup()
8004 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_driver_resource_setup()
8005 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_io_wait_list); in lpfc_sli4_driver_resource_setup()
8006 spin_lock_init(&phba->sli4_hba.t_active_list_lock); in lpfc_sli4_driver_resource_setup()
8007 INIT_LIST_HEAD(&phba->sli4_hba.t_active_ctx_list); in lpfc_sli4_driver_resource_setup()
8011 spin_lock_init(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_driver_resource_setup()
8012 spin_lock_init(&phba->sli4_hba.nvmet_io_wait_lock); in lpfc_sli4_driver_resource_setup()
8013 spin_lock_init(&phba->sli4_hba.asynce_list_lock); in lpfc_sli4_driver_resource_setup()
8014 spin_lock_init(&phba->sli4_hba.els_xri_abrt_list_lock); in lpfc_sli4_driver_resource_setup()
8017 * Initialize driver internal slow-path work queues in lpfc_sli4_driver_resource_setup()
8020 /* Driver internel slow-path CQ Event pool */ in lpfc_sli4_driver_resource_setup()
8021 INIT_LIST_HEAD(&phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_driver_resource_setup()
8023 INIT_LIST_HEAD(&phba->sli4_hba.sp_queue_event); in lpfc_sli4_driver_resource_setup()
8025 INIT_LIST_HEAD(&phba->sli4_hba.sp_asynce_work_queue); in lpfc_sli4_driver_resource_setup()
8026 /* Slow-path XRI aborted CQ Event work queue list */ in lpfc_sli4_driver_resource_setup()
8027 INIT_LIST_HEAD(&phba->sli4_hba.sp_els_xri_aborted_work_queue); in lpfc_sli4_driver_resource_setup()
8029 INIT_LIST_HEAD(&phba->sli4_hba.sp_unsol_work_queue); in lpfc_sli4_driver_resource_setup()
8032 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_blk_list); in lpfc_sli4_driver_resource_setup()
8033 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_xri_blk_list); in lpfc_sli4_driver_resource_setup()
8034 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_vfi_blk_list); in lpfc_sli4_driver_resource_setup()
8035 INIT_LIST_HEAD(&phba->lpfc_vpi_blk_list); in lpfc_sli4_driver_resource_setup()
8040 INIT_LIST_HEAD(&phba->sli.mboxq); in lpfc_sli4_driver_resource_setup()
8041 INIT_LIST_HEAD(&phba->sli.mboxq_cmpl); in lpfc_sli4_driver_resource_setup()
8044 phba->sli4_hba.lnk_info.optic_state = 0xff; in lpfc_sli4_driver_resource_setup()
8052 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_driver_resource_setup()
8056 rc = -ENODEV; in lpfc_sli4_driver_resource_setup()
8059 phba->temp_sensor_support = 1; in lpfc_sli4_driver_resource_setup()
8077 if (phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_CONFIG) { in lpfc_sli4_driver_resource_setup()
8078 /* Right now the link is down, if FA-PWWN is configured the in lpfc_sli4_driver_resource_setup()
8085 phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_FABRIC; in lpfc_sli4_driver_resource_setup()
8093 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_driver_resource_setup()
8100 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_sli4_driver_resource_setup()
8103 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8108 phba->nvmet_support = 0; in lpfc_sli4_driver_resource_setup()
8119 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_driver_resource_setup()
8120 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_driver_resource_setup()
8121 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8122 rc = -EIO; in lpfc_sli4_driver_resource_setup()
8125 mb = &mboxq->u.mb; in lpfc_sli4_driver_resource_setup()
8126 memcpy(&wwn, (char *)mb->un.varRDnvp.nodename, in lpfc_sli4_driver_resource_setup()
8129 phba->sli4_hba.wwnn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
8130 memcpy(&wwn, (char *)mb->un.varRDnvp.portname, in lpfc_sli4_driver_resource_setup()
8134 phba->sli4_hba.wwpn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
8143 phba->nvmet_support = 1; /* a match */ in lpfc_sli4_driver_resource_setup()
8157 phba->cfg_xri_rebalancing = 0; in lpfc_sli4_driver_resource_setup()
8158 if (phba->irq_chann_mode == NHT_MODE) { in lpfc_sli4_driver_resource_setup()
8159 phba->cfg_irq_chann = in lpfc_sli4_driver_resource_setup()
8160 phba->sli4_hba.num_present_cpu; in lpfc_sli4_driver_resource_setup()
8161 phba->cfg_hdw_queue = in lpfc_sli4_driver_resource_setup()
8162 phba->sli4_hba.num_present_cpu; in lpfc_sli4_driver_resource_setup()
8163 phba->irq_chann_mode = NORMAL_MODE; in lpfc_sli4_driver_resource_setup()
8180 &phba->sli4_hba.sli_intf); in lpfc_sli4_driver_resource_setup()
8182 &phba->sli4_hba.sli_intf); in lpfc_sli4_driver_resource_setup()
8183 if (phba->sli4_hba.extents_in_use && in lpfc_sli4_driver_resource_setup()
8184 phba->sli4_hba.rpi_hdrs_in_use) { in lpfc_sli4_driver_resource_setup()
8190 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8191 rc = -EIO; in lpfc_sli4_driver_resource_setup()
8197 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8198 rc = -EIO; in lpfc_sli4_driver_resource_setup()
8208 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_driver_resource_setup()
8222 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) { in lpfc_sli4_driver_resource_setup()
8226 * The scsi_buf for a T10-DIF I/O holds the FCP cmnd, in lpfc_sli4_driver_resource_setup()
8234 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd32) + in lpfc_sli4_driver_resource_setup()
8238 phba->cfg_total_seg_cnt = LPFC_MAX_SGL_SEG_CNT; in lpfc_sli4_driver_resource_setup()
8244 if (phba->cfg_enable_bg && in lpfc_sli4_driver_resource_setup()
8245 phba->cfg_sg_seg_cnt > LPFC_MAX_BG_SLI4_SEG_CNT_DIF) in lpfc_sli4_driver_resource_setup()
8246 phba->cfg_scsi_seg_cnt = LPFC_MAX_BG_SLI4_SEG_CNT_DIF; in lpfc_sli4_driver_resource_setup()
8248 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8256 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd32) + in lpfc_sli4_driver_resource_setup()
8258 ((phba->cfg_sg_seg_cnt + extra) * in lpfc_sli4_driver_resource_setup()
8262 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + extra; in lpfc_sli4_driver_resource_setup()
8263 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8266 * NOTE: if (phba->cfg_sg_seg_cnt + extra) <= 256 we only in lpfc_sli4_driver_resource_setup()
8271 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_driver_resource_setup()
8272 phba->cfg_sg_dma_buf_size = LPFC_DEFAULT_XPSGL_SIZE; in lpfc_sli4_driver_resource_setup()
8273 else if (phba->cfg_sg_dma_buf_size <= LPFC_MIN_SG_SLI4_BUF_SZ) in lpfc_sli4_driver_resource_setup()
8274 phba->cfg_sg_dma_buf_size = LPFC_MIN_SG_SLI4_BUF_SZ; in lpfc_sli4_driver_resource_setup()
8276 phba->cfg_sg_dma_buf_size = in lpfc_sli4_driver_resource_setup()
8277 SLI4_PAGE_ALIGN(phba->cfg_sg_dma_buf_size); in lpfc_sli4_driver_resource_setup()
8279 phba->border_sge_num = phba->cfg_sg_dma_buf_size / in lpfc_sli4_driver_resource_setup()
8283 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
8284 if (phba->cfg_sg_seg_cnt > LPFC_MAX_NVME_SEG_CNT) { in lpfc_sli4_driver_resource_setup()
8289 phba->cfg_nvme_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_sli4_driver_resource_setup()
8291 phba->cfg_nvme_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8297 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
8298 phba->cfg_total_seg_cnt, phba->cfg_scsi_seg_cnt, in lpfc_sli4_driver_resource_setup()
8299 phba->cfg_nvme_seg_cnt); in lpfc_sli4_driver_resource_setup()
8301 if (phba->cfg_sg_dma_buf_size < SLI4_PAGE_SIZE) in lpfc_sli4_driver_resource_setup()
8302 i = phba->cfg_sg_dma_buf_size; in lpfc_sli4_driver_resource_setup()
8306 phba->lpfc_sg_dma_buf_pool = in lpfc_sli4_driver_resource_setup()
8308 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
8309 phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
8311 if (!phba->lpfc_sg_dma_buf_pool) { in lpfc_sli4_driver_resource_setup()
8312 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8316 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli4_driver_resource_setup()
8318 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
8322 if (!phba->lpfc_cmd_rsp_buf_pool) { in lpfc_sli4_driver_resource_setup()
8323 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8327 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8363 longs = (LPFC_SLI4_FCF_TBL_INDX_MAX + BITS_PER_LONG - 1)/BITS_PER_LONG; in lpfc_sli4_driver_resource_setup()
8364 phba->fcf.fcf_rr_bmask = kcalloc(longs, sizeof(unsigned long), in lpfc_sli4_driver_resource_setup()
8366 if (!phba->fcf.fcf_rr_bmask) { in lpfc_sli4_driver_resource_setup()
8370 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8374 phba->sli4_hba.hba_eq_hdl = kcalloc(phba->cfg_irq_chann, in lpfc_sli4_driver_resource_setup()
8377 if (!phba->sli4_hba.hba_eq_hdl) { in lpfc_sli4_driver_resource_setup()
8380 "fast-path per-EQ handle array\n"); in lpfc_sli4_driver_resource_setup()
8381 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8385 phba->sli4_hba.cpu_map = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
8388 if (!phba->sli4_hba.cpu_map) { in lpfc_sli4_driver_resource_setup()
8390 "3327 Failed allocate memory for msi-x " in lpfc_sli4_driver_resource_setup()
8392 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8396 phba->sli4_hba.eq_info = alloc_percpu(struct lpfc_eq_intr_info); in lpfc_sli4_driver_resource_setup()
8397 if (!phba->sli4_hba.eq_info) { in lpfc_sli4_driver_resource_setup()
8400 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8404 phba->sli4_hba.idle_stat = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
8405 sizeof(*phba->sli4_hba.idle_stat), in lpfc_sli4_driver_resource_setup()
8407 if (!phba->sli4_hba.idle_stat) { in lpfc_sli4_driver_resource_setup()
8410 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8415 phba->sli4_hba.c_stat = alloc_percpu(struct lpfc_hdwq_stat); in lpfc_sli4_driver_resource_setup()
8416 if (!phba->sli4_hba.c_stat) { in lpfc_sli4_driver_resource_setup()
8418 "3332 Failed allocating per cpu hdwq stats\n"); in lpfc_sli4_driver_resource_setup()
8419 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8424 phba->cmf_stat = alloc_percpu(struct lpfc_cgn_stat); in lpfc_sli4_driver_resource_setup()
8425 if (!phba->cmf_stat) { in lpfc_sli4_driver_resource_setup()
8427 "3331 Failed allocating per cpu cgn stats\n"); in lpfc_sli4_driver_resource_setup()
8428 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8433 * Enable sr-iov virtual functions if supported and configured in lpfc_sli4_driver_resource_setup()
8436 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli4_driver_resource_setup()
8438 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
8441 "3020 Requested number of SR-IOV " in lpfc_sli4_driver_resource_setup()
8444 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
8445 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli4_driver_resource_setup()
8453 free_percpu(phba->sli4_hba.c_stat); in lpfc_sli4_driver_resource_setup()
8456 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_setup()
8458 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_setup()
8460 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_setup()
8462 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_setup()
8464 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_setup()
8472 dma_pool_destroy(phba->lpfc_cmd_rsp_buf_pool); in lpfc_sli4_driver_resource_setup()
8473 phba->lpfc_cmd_rsp_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
8475 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli4_driver_resource_setup()
8476 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
8482 destroy_workqueue(phba->wq); in lpfc_sli4_driver_resource_setup()
8483 phba->wq = NULL; in lpfc_sli4_driver_resource_setup()
8488 * lpfc_sli4_driver_resource_unset - Unset drvr internal resources for SLI4 dev
8492 * specific for supporting the SLI-4 HBA device it attached to.
8499 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_unset()
8501 free_percpu(phba->sli4_hba.c_stat); in lpfc_sli4_driver_resource_unset()
8503 free_percpu(phba->cmf_stat); in lpfc_sli4_driver_resource_unset()
8504 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_unset()
8506 /* Free memory allocated for msi-x interrupt vector to CPU mapping */ in lpfc_sli4_driver_resource_unset()
8507 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_unset()
8508 phba->sli4_hba.num_possible_cpu = 0; in lpfc_sli4_driver_resource_unset()
8509 phba->sli4_hba.num_present_cpu = 0; in lpfc_sli4_driver_resource_unset()
8510 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_unset()
8511 cpumask_clear(&phba->sli4_hba.irq_aff_mask); in lpfc_sli4_driver_resource_unset()
8513 /* Free memory allocated for fast-path work queue handles */ in lpfc_sli4_driver_resource_unset()
8514 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_unset()
8521 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_unset()
8543 &phba->fcf_conn_rec_list, list) { in lpfc_sli4_driver_resource_unset()
8544 list_del_init(&conn_entry->list); in lpfc_sli4_driver_resource_unset()
8552 * lpfc_init_api_table_setup - Set up init api function jump table
8554 * @dev_grp: The HBA PCI-Device group number.
8559 * Returns: 0 - success, -ENODEV - failure.
8564 phba->lpfc_hba_init_link = lpfc_hba_init_link; in lpfc_init_api_table_setup()
8565 phba->lpfc_hba_down_link = lpfc_hba_down_link; in lpfc_init_api_table_setup()
8566 phba->lpfc_selective_reset = lpfc_selective_reset; in lpfc_init_api_table_setup()
8569 phba->lpfc_hba_down_post = lpfc_hba_down_post_s3; in lpfc_init_api_table_setup()
8570 phba->lpfc_handle_eratt = lpfc_handle_eratt_s3; in lpfc_init_api_table_setup()
8571 phba->lpfc_stop_port = lpfc_stop_port_s3; in lpfc_init_api_table_setup()
8574 phba->lpfc_hba_down_post = lpfc_hba_down_post_s4; in lpfc_init_api_table_setup()
8575 phba->lpfc_handle_eratt = lpfc_handle_eratt_s4; in lpfc_init_api_table_setup()
8576 phba->lpfc_stop_port = lpfc_stop_port_s4; in lpfc_init_api_table_setup()
8580 "1431 Invalid HBA PCI-device group: 0x%x\n", in lpfc_init_api_table_setup()
8582 return -ENODEV; in lpfc_init_api_table_setup()
8588 * lpfc_setup_driver_resource_phase2 - Phase2 setup driver internal resources.
8595 * 0 - successful
8596 * other values - error
8604 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_setup_driver_resource_phase2()
8605 "lpfc_worker_%d", phba->brd_no); in lpfc_setup_driver_resource_phase2()
8606 if (IS_ERR(phba->worker_thread)) { in lpfc_setup_driver_resource_phase2()
8607 error = PTR_ERR(phba->worker_thread); in lpfc_setup_driver_resource_phase2()
8615 * lpfc_unset_driver_resource_phase2 - Phase2 unset driver internal resources.
8625 if (phba->wq) { in lpfc_unset_driver_resource_phase2()
8626 destroy_workqueue(phba->wq); in lpfc_unset_driver_resource_phase2()
8627 phba->wq = NULL; in lpfc_unset_driver_resource_phase2()
8631 if (phba->worker_thread) in lpfc_unset_driver_resource_phase2()
8632 kthread_stop(phba->worker_thread); in lpfc_unset_driver_resource_phase2()
8636 * lpfc_free_iocb_list - Free iocb list.
8646 spin_lock_irq(&phba->hbalock); in lpfc_free_iocb_list()
8648 &phba->lpfc_iocb_list, list) { in lpfc_free_iocb_list()
8649 list_del(&iocbq_entry->list); in lpfc_free_iocb_list()
8651 phba->total_iocbq_bufs--; in lpfc_free_iocb_list()
8653 spin_unlock_irq(&phba->hbalock); in lpfc_free_iocb_list()
8659 * lpfc_init_iocb_list - Allocate and initialize iocb list.
8667 * 0 - successful
8668 * other values - error
8678 INIT_LIST_HEAD(&phba->lpfc_iocb_list); in lpfc_init_iocb_list()
8695 iocbq_entry->sli4_lxritag = NO_XRI; in lpfc_init_iocb_list()
8696 iocbq_entry->sli4_xritag = NO_XRI; in lpfc_init_iocb_list()
8698 spin_lock_irq(&phba->hbalock); in lpfc_init_iocb_list()
8699 list_add(&iocbq_entry->list, &phba->lpfc_iocb_list); in lpfc_init_iocb_list()
8700 phba->total_iocbq_bufs++; in lpfc_init_iocb_list()
8701 spin_unlock_irq(&phba->hbalock); in lpfc_init_iocb_list()
8709 return -ENOMEM; in lpfc_init_iocb_list()
8713 * lpfc_free_sgl_list - Free a given sgl list.
8725 list_del(&sglq_entry->list); in lpfc_free_sgl_list()
8726 lpfc_mbuf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_sgl_list()
8732 * lpfc_free_els_sgl_list - Free els sgl list.
8743 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
8744 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, &sglq_list); in lpfc_free_els_sgl_list()
8745 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
8752 * lpfc_free_nvmet_sgl_list - Free nvmet sgl list.
8764 spin_lock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
8765 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
8766 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, &sglq_list); in lpfc_free_nvmet_sgl_list()
8767 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
8768 spin_unlock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
8772 list_del(&sglq_entry->list); in lpfc_free_nvmet_sgl_list()
8773 lpfc_nvmet_buf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_nvmet_sgl_list()
8781 phba->sli4_hba.nvmet_xri_cnt = 0; in lpfc_free_nvmet_sgl_list()
8785 * lpfc_init_active_sgl_array - Allocate the buf to track active ELS XRIs.
8796 size *= phba->sli4_hba.max_cfg_param.max_xri; in lpfc_init_active_sgl_array()
8798 phba->sli4_hba.lpfc_sglq_active_list = in lpfc_init_active_sgl_array()
8800 if (!phba->sli4_hba.lpfc_sglq_active_list) in lpfc_init_active_sgl_array()
8801 return -ENOMEM; in lpfc_init_active_sgl_array()
8806 * lpfc_free_active_sgl - Free the buf that tracks active ELS XRIs.
8816 kfree(phba->sli4_hba.lpfc_sglq_active_list); in lpfc_free_active_sgl()
8820 * lpfc_init_sgl_list - Allocate and initialize sgl list.
8831 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_els_sgl_list); in lpfc_init_sgl_list()
8832 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_init_sgl_list()
8833 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_init_sgl_list()
8834 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_init_sgl_list()
8836 /* els xri-sgl book keeping */ in lpfc_init_sgl_list()
8837 phba->sli4_hba.els_xri_cnt = 0; in lpfc_init_sgl_list()
8839 /* nvme xri-buffer book keeping */ in lpfc_init_sgl_list()
8840 phba->sli4_hba.io_xri_cnt = 0; in lpfc_init_sgl_list()
8844 * lpfc_sli4_init_rpi_hdrs - Post the rpi header memory region to the port
8854 * 0 - successful
8855 * -ERROR - otherwise.
8863 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_init_rpi_hdrs()
8864 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_init_rpi_hdrs()
8866 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_init_rpi_hdrs()
8867 return -EIO; in lpfc_sli4_init_rpi_hdrs()
8874 rc = -ENODEV; in lpfc_sli4_init_rpi_hdrs()
8881 * lpfc_sli4_create_rpi_hdr - Allocate an rpi header memory region
8905 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_create_rpi_hdr()
8907 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_create_rpi_hdr()
8911 rpi_limit = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_create_rpi_hdr()
8913 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8919 curr_rpi_range = phba->sli4_hba.next_rpi; in lpfc_sli4_create_rpi_hdr()
8920 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8928 * port expects a 4KB DMA-mapped memory region that is 4K aligned. in lpfc_sli4_create_rpi_hdr()
8934 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_create_rpi_hdr()
8936 &dmabuf->phys, GFP_KERNEL); in lpfc_sli4_create_rpi_hdr()
8937 if (!dmabuf->virt) { in lpfc_sli4_create_rpi_hdr()
8942 if (!IS_ALIGNED(dmabuf->phys, LPFC_HDR_TEMPLATE_SIZE)) { in lpfc_sli4_create_rpi_hdr()
8952 rpi_hdr->dmabuf = dmabuf; in lpfc_sli4_create_rpi_hdr()
8953 rpi_hdr->len = LPFC_HDR_TEMPLATE_SIZE; in lpfc_sli4_create_rpi_hdr()
8954 rpi_hdr->page_count = 1; in lpfc_sli4_create_rpi_hdr()
8955 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8958 rpi_hdr->start_rpi = curr_rpi_range; in lpfc_sli4_create_rpi_hdr()
8959 rpi_hdr->next_rpi = phba->sli4_hba.next_rpi + LPFC_RPI_HDR_COUNT; in lpfc_sli4_create_rpi_hdr()
8960 list_add_tail(&rpi_hdr->list, &phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_create_rpi_hdr()
8962 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8966 dma_free_coherent(&phba->pcidev->dev, LPFC_HDR_TEMPLATE_SIZE, in lpfc_sli4_create_rpi_hdr()
8967 dmabuf->virt, dmabuf->phys); in lpfc_sli4_create_rpi_hdr()
8974 * lpfc_sli4_remove_rpi_hdrs - Remove all rpi header memory regions
8987 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_remove_rpi_hdrs()
8991 &phba->sli4_hba.lpfc_rpi_hdr_list, list) { in lpfc_sli4_remove_rpi_hdrs()
8992 list_del(&rpi_hdr->list); in lpfc_sli4_remove_rpi_hdrs()
8993 dma_free_coherent(&phba->pcidev->dev, rpi_hdr->len, in lpfc_sli4_remove_rpi_hdrs()
8994 rpi_hdr->dmabuf->virt, rpi_hdr->dmabuf->phys); in lpfc_sli4_remove_rpi_hdrs()
8995 kfree(rpi_hdr->dmabuf); in lpfc_sli4_remove_rpi_hdrs()
9000 phba->sli4_hba.next_rpi = 0; in lpfc_sli4_remove_rpi_hdrs()
9004 * lpfc_hba_alloc - Allocate driver hba data structure for a device.
9012 * pointer to @phba - successful
9013 * NULL - error
9023 dev_err(&pdev->dev, "failed to allocate hba struct\n"); in lpfc_hba_alloc()
9028 phba->pcidev = pdev; in lpfc_hba_alloc()
9031 phba->brd_no = lpfc_get_instance(); in lpfc_hba_alloc()
9032 if (phba->brd_no < 0) { in lpfc_hba_alloc()
9036 phba->eratt_poll_interval = LPFC_ERATT_POLL_INTERVAL; in lpfc_hba_alloc()
9038 spin_lock_init(&phba->ct_ev_lock); in lpfc_hba_alloc()
9039 INIT_LIST_HEAD(&phba->ct_ev_waiters); in lpfc_hba_alloc()
9045 * lpfc_hba_free - Free driver hba data structure with a device.
9054 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_hba_free()
9055 kfree(phba->sli4_hba.hdwq); in lpfc_hba_free()
9058 idr_remove(&lpfc_hba_index, phba->brd_no); in lpfc_hba_free()
9061 kfree(phba->sli.sli3_ring); in lpfc_hba_free()
9062 phba->sli.sli3_ring = NULL; in lpfc_hba_free()
9069 * lpfc_setup_fdmi_mask - Setup initial FDMI mask for HBA and Port attributes
9075 * fallback hierarchy is SmartSAN -> FDMI2 -> FMDI1
9080 struct lpfc_hba *phba = vport->phba; in lpfc_setup_fdmi_mask()
9082 set_bit(FC_ALLOW_FDMI, &vport->load_flag); in lpfc_setup_fdmi_mask()
9083 if (phba->cfg_enable_SmartSAN || in lpfc_setup_fdmi_mask()
9084 phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT) { in lpfc_setup_fdmi_mask()
9086 vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR; in lpfc_setup_fdmi_mask()
9087 if (phba->cfg_enable_SmartSAN) in lpfc_setup_fdmi_mask()
9088 vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR; in lpfc_setup_fdmi_mask()
9090 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR; in lpfc_setup_fdmi_mask()
9095 vport->fdmi_hba_mask, vport->fdmi_port_mask); in lpfc_setup_fdmi_mask()
9099 * lpfc_create_shost - Create hba physical port with associated scsi host.
9106 * 0 - successful
9107 * other values - error
9116 phba->fc_edtov = FF_DEF_EDTOV; in lpfc_create_shost()
9117 phba->fc_ratov = FF_DEF_RATOV; in lpfc_create_shost()
9118 phba->fc_altov = FF_DEF_ALTOV; in lpfc_create_shost()
9119 phba->fc_arbtov = FF_DEF_ARBTOV; in lpfc_create_shost()
9121 atomic_set(&phba->sdev_cnt, 0); in lpfc_create_shost()
9122 vport = lpfc_create_port(phba, phba->brd_no, &phba->pcidev->dev); in lpfc_create_shost()
9124 return -ENODEV; in lpfc_create_shost()
9127 phba->pport = vport; in lpfc_create_shost()
9129 if (phba->nvmet_support) { in lpfc_create_shost()
9131 phba->targetport = NULL; in lpfc_create_shost()
9132 phba->cfg_enable_fc4_type = LPFC_ENABLE_NVME; in lpfc_create_shost()
9139 pci_set_drvdata(phba->pcidev, shost); in lpfc_create_shost()
9151 * lpfc_destroy_shost - Destroy hba physical port with associated scsi host.
9160 struct lpfc_vport *vport = phba->pport; in lpfc_destroy_shost()
9169 * lpfc_setup_bg - Setup Block guard structures and debug areas.
9182 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
9187 old_mask = phba->cfg_prot_mask; in lpfc_setup_bg()
9188 old_guard = phba->cfg_prot_guard; in lpfc_setup_bg()
9191 phba->cfg_prot_mask &= (SHOST_DIF_TYPE1_PROTECTION | in lpfc_setup_bg()
9194 phba->cfg_prot_guard &= (SHOST_DIX_GUARD_IP | in lpfc_setup_bg()
9198 if (phba->cfg_prot_mask == SHOST_DIX_TYPE1_PROTECTION) in lpfc_setup_bg()
9199 phba->cfg_prot_mask |= SHOST_DIF_TYPE1_PROTECTION; in lpfc_setup_bg()
9201 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
9202 if ((old_mask != phba->cfg_prot_mask) || in lpfc_setup_bg()
9203 (old_guard != phba->cfg_prot_guard)) in lpfc_setup_bg()
9207 phba->cfg_prot_mask, in lpfc_setup_bg()
9208 phba->cfg_prot_guard); in lpfc_setup_bg()
9210 scsi_host_set_prot(shost, phba->cfg_prot_mask); in lpfc_setup_bg()
9211 scsi_host_set_guard(shost, phba->cfg_prot_guard); in lpfc_setup_bg()
9221 * lpfc_post_init_setup - Perform necessary device post initialization setup.
9234 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_post_init_setup()
9240 shost = pci_get_drvdata(phba->pcidev); in lpfc_post_init_setup()
9241 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_post_init_setup()
9245 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_post_init_setup()
9246 spin_lock_irq(shost->host_lock); in lpfc_post_init_setup()
9248 spin_unlock_irq(shost->host_lock); in lpfc_post_init_setup()
9264 * lpfc_sli_pci_mem_setup - Setup SLI3 HBA PCI memory space.
9268 * with SLI-3 interface spec.
9271 * 0 - successful
9272 * other values - error
9277 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_pci_mem_setup()
9284 return -ENODEV; in lpfc_sli_pci_mem_setup()
9287 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli_pci_mem_setup()
9289 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli_pci_mem_setup()
9292 error = -ENODEV; in lpfc_sli_pci_mem_setup()
9297 phba->pci_bar0_map = pci_resource_start(pdev, 0); in lpfc_sli_pci_mem_setup()
9300 phba->pci_bar2_map = pci_resource_start(pdev, 2); in lpfc_sli_pci_mem_setup()
9304 phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli_pci_mem_setup()
9305 if (!phba->slim_memmap_p) { in lpfc_sli_pci_mem_setup()
9306 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
9312 phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli_pci_mem_setup()
9313 if (!phba->ctrl_regs_memmap_p) { in lpfc_sli_pci_mem_setup()
9314 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
9319 /* Allocate memory for SLI-2 structures */ in lpfc_sli_pci_mem_setup()
9320 phba->slim2p.virt = dma_alloc_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
9321 &phba->slim2p.phys, GFP_KERNEL); in lpfc_sli_pci_mem_setup()
9322 if (!phba->slim2p.virt) in lpfc_sli_pci_mem_setup()
9325 phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx); in lpfc_sli_pci_mem_setup()
9326 phba->mbox_ext = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
9328 phba->pcb = (phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, pcb)); in lpfc_sli_pci_mem_setup()
9329 phba->IOCBs = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
9332 phba->hbqslimp.virt = dma_alloc_coherent(&pdev->dev, in lpfc_sli_pci_mem_setup()
9334 &phba->hbqslimp.phys, in lpfc_sli_pci_mem_setup()
9336 if (!phba->hbqslimp.virt) in lpfc_sli_pci_mem_setup()
9340 ptr = phba->hbqslimp.virt; in lpfc_sli_pci_mem_setup()
9342 phba->hbqs[i].hbq_virt = ptr; in lpfc_sli_pci_mem_setup()
9343 INIT_LIST_HEAD(&phba->hbqs[i].hbq_buffer_list); in lpfc_sli_pci_mem_setup()
9344 ptr += (lpfc_hbq_defs[i]->entry_count * in lpfc_sli_pci_mem_setup()
9347 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_els_hbq_alloc; in lpfc_sli_pci_mem_setup()
9348 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_els_hbq_free; in lpfc_sli_pci_mem_setup()
9350 memset(phba->hbqslimp.virt, 0, lpfc_sli_hbq_size()); in lpfc_sli_pci_mem_setup()
9352 phba->MBslimaddr = phba->slim_memmap_p; in lpfc_sli_pci_mem_setup()
9353 phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9354 phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9355 phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9356 phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9361 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
9362 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_setup()
9364 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_setup()
9366 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_setup()
9372 * lpfc_sli_pci_mem_unset - Unset SLI3 HBA PCI memory space.
9376 * with SLI-3 interface spec.
9384 if (!phba->pcidev) in lpfc_sli_pci_mem_unset()
9387 pdev = phba->pcidev; in lpfc_sli_pci_mem_unset()
9390 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_sli_pci_mem_unset()
9391 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_sli_pci_mem_unset()
9392 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_unset()
9393 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_unset()
9396 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_unset()
9397 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_unset()
9403 * lpfc_sli4_post_status_check - Wait for SLI4 POST done and check status
9409 * Return 0 if successful, otherwise -ENODEV.
9421 if (!phba->sli4_hba.PSMPHRregaddr) in lpfc_sli4_post_status_check()
9422 return -ENODEV; in lpfc_sli4_post_status_check()
9426 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_sli4_post_status_check()
9430 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9445 "1408 Port Failed POST - portsmphr=0x%x, " in lpfc_sli4_post_status_check()
9463 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9465 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9467 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9469 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9471 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9473 &phba->sli4_hba.sli_intf)); in lpfc_sli4_post_status_check()
9480 &phba->sli4_hba.sli_intf); in lpfc_sli4_post_status_check()
9483 phba->sli4_hba.ue_mask_lo = in lpfc_sli4_post_status_check()
9484 readl(phba->sli4_hba.u.if_type0.UEMASKLOregaddr); in lpfc_sli4_post_status_check()
9485 phba->sli4_hba.ue_mask_hi = in lpfc_sli4_post_status_check()
9486 readl(phba->sli4_hba.u.if_type0.UEMASKHIregaddr); in lpfc_sli4_post_status_check()
9488 readl(phba->sli4_hba.u.if_type0.UERRLOregaddr); in lpfc_sli4_post_status_check()
9490 readl(phba->sli4_hba.u.if_type0.UERRHIregaddr); in lpfc_sli4_post_status_check()
9491 if ((~phba->sli4_hba.ue_mask_lo & uerrlo_reg.word0) || in lpfc_sli4_post_status_check()
9492 (~phba->sli4_hba.ue_mask_hi & uerrhi_reg.word0)) { in lpfc_sli4_post_status_check()
9503 phba->sli4_hba.ue_mask_lo, in lpfc_sli4_post_status_check()
9504 phba->sli4_hba.ue_mask_hi); in lpfc_sli4_post_status_check()
9505 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9511 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_post_status_check()
9514 phba->work_status[0] = in lpfc_sli4_post_status_check()
9515 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
9517 phba->work_status[1] = in lpfc_sli4_post_status_check()
9518 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
9527 phba->work_status[0], in lpfc_sli4_post_status_check()
9528 phba->work_status[1]); in lpfc_sli4_post_status_check()
9529 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9535 &phba->sli4_hba.sli_intf) == in lpfc_sli4_post_status_check()
9537 pci_write_config_byte(phba->pcidev, in lpfc_sli4_post_status_check()
9549 * lpfc_sli4_bar0_register_memmap - Set up SLI4 BAR0 register memory map.
9561 phba->sli4_hba.u.if_type0.UERRLOregaddr = in lpfc_sli4_bar0_register_memmap()
9562 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_LO; in lpfc_sli4_bar0_register_memmap()
9563 phba->sli4_hba.u.if_type0.UERRHIregaddr = in lpfc_sli4_bar0_register_memmap()
9564 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_HI; in lpfc_sli4_bar0_register_memmap()
9565 phba->sli4_hba.u.if_type0.UEMASKLOregaddr = in lpfc_sli4_bar0_register_memmap()
9566 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_LO; in lpfc_sli4_bar0_register_memmap()
9567 phba->sli4_hba.u.if_type0.UEMASKHIregaddr = in lpfc_sli4_bar0_register_memmap()
9568 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_HI; in lpfc_sli4_bar0_register_memmap()
9569 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
9570 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
9573 phba->sli4_hba.u.if_type2.EQDregaddr = in lpfc_sli4_bar0_register_memmap()
9574 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9576 phba->sli4_hba.u.if_type2.ERR1regaddr = in lpfc_sli4_bar0_register_memmap()
9577 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9579 phba->sli4_hba.u.if_type2.ERR2regaddr = in lpfc_sli4_bar0_register_memmap()
9580 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9582 phba->sli4_hba.u.if_type2.CTRLregaddr = 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.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
9586 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9588 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
9589 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
9590 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
9591 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9593 phba->sli4_hba.RQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9594 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9596 phba->sli4_hba.WQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9597 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9599 phba->sli4_hba.CQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9600 phba->sli4_hba.conf_regs_memmap_p + LPFC_EQCQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
9601 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar0_register_memmap()
9602 phba->sli4_hba.MQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9603 phba->sli4_hba.conf_regs_memmap_p + LPFC_MQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
9604 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
9605 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
9608 phba->sli4_hba.u.if_type2.EQDregaddr = in lpfc_sli4_bar0_register_memmap()
9609 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9611 phba->sli4_hba.u.if_type2.ERR1regaddr = in lpfc_sli4_bar0_register_memmap()
9612 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9614 phba->sli4_hba.u.if_type2.ERR2regaddr = in lpfc_sli4_bar0_register_memmap()
9615 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9617 phba->sli4_hba.u.if_type2.CTRLregaddr = 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.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
9621 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9623 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
9624 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9626 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
9627 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
9631 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_bar0_register_memmap()
9632 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar0_register_memmap()
9639 * lpfc_sli4_bar1_register_memmap - Set up SLI4 BAR1 register memory map.
9650 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar1_register_memmap()
9651 phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9653 phba->sli4_hba.ISRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9655 phba->sli4_hba.IMRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9657 phba->sli4_hba.ISCRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9661 phba->sli4_hba.RQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9663 phba->sli4_hba.WQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9665 phba->sli4_hba.CQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9667 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9669 phba->sli4_hba.MQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9675 dev_err(&phba->pcidev->dev, in lpfc_sli4_bar1_register_memmap()
9676 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar1_register_memmap()
9683 * lpfc_sli4_bar2_register_memmap - Set up SLI4 BAR2 register memory map.
9690 * Return 0 if successful, otherwise -ENODEV.
9696 return -ENODEV; in lpfc_sli4_bar2_register_memmap()
9698 phba->sli4_hba.RQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9701 phba->sli4_hba.WQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9704 phba->sli4_hba.CQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9707 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar2_register_memmap()
9708 phba->sli4_hba.MQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9710 phba->sli4_hba.BMBXregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9716 * lpfc_create_bootstrap_mbox - Create the bootstrap mailbox
9720 * region consistent with the SLI-4 interface spec. This
9727 * 0 - successful
9728 * -ENOMEM - could not allocated memory.
9741 return -ENOMEM; in lpfc_create_bootstrap_mbox()
9747 bmbx_size = sizeof(struct lpfc_bmbx_create) + (LPFC_ALIGN_16_BYTE - 1); in lpfc_create_bootstrap_mbox()
9748 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, bmbx_size, in lpfc_create_bootstrap_mbox()
9749 &dmabuf->phys, GFP_KERNEL); in lpfc_create_bootstrap_mbox()
9750 if (!dmabuf->virt) { in lpfc_create_bootstrap_mbox()
9752 return -ENOMEM; in lpfc_create_bootstrap_mbox()
9758 * to be 16-byte aligned. Also align the virtual memory as each in lpfc_create_bootstrap_mbox()
9762 phba->sli4_hba.bmbx.dmabuf = dmabuf; in lpfc_create_bootstrap_mbox()
9763 phba->sli4_hba.bmbx.bmbx_size = bmbx_size; in lpfc_create_bootstrap_mbox()
9765 phba->sli4_hba.bmbx.avirt = PTR_ALIGN(dmabuf->virt, in lpfc_create_bootstrap_mbox()
9767 phba->sli4_hba.bmbx.aphys = ALIGN(dmabuf->phys, in lpfc_create_bootstrap_mbox()
9773 * as two 30-bit addresses. The other data is a bit marking whether in lpfc_create_bootstrap_mbox()
9774 * the 30-bit address is the high or low address. in lpfc_create_bootstrap_mbox()
9778 dma_address = &phba->sli4_hba.bmbx.dma_address; in lpfc_create_bootstrap_mbox()
9779 phys_addr = (uint64_t)phba->sli4_hba.bmbx.aphys; in lpfc_create_bootstrap_mbox()
9781 dma_address->addr_hi = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
9784 pa_addr = (uint32_t) ((phba->sli4_hba.bmbx.aphys >> 4) & 0x3fffffff); in lpfc_create_bootstrap_mbox()
9785 dma_address->addr_lo = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
9791 * lpfc_destroy_bootstrap_mbox - Destroy all bootstrap mailbox resources
9804 dma_free_coherent(&phba->pcidev->dev, in lpfc_destroy_bootstrap_mbox()
9805 phba->sli4_hba.bmbx.bmbx_size, in lpfc_destroy_bootstrap_mbox()
9806 phba->sli4_hba.bmbx.dmabuf->virt, in lpfc_destroy_bootstrap_mbox()
9807 phba->sli4_hba.bmbx.dmabuf->phys); in lpfc_destroy_bootstrap_mbox()
9809 kfree(phba->sli4_hba.bmbx.dmabuf); in lpfc_destroy_bootstrap_mbox()
9810 memset(&phba->sli4_hba.bmbx, 0, sizeof(struct lpfc_bmbx)); in lpfc_destroy_bootstrap_mbox()
9827 * lpfc_map_topology - Map the topology read from READ_CONFIG
9852 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9855 /* FW supports persistent topology - override module parameter value */ in lpfc_map_topology()
9856 set_bit(HBA_PERSISTENT_TOPO, &phba->hba_flag); in lpfc_map_topology()
9859 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_map_topology()
9861 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_map_topology()
9864 phba->cfg_topology = ((pt == LINK_FLAGS_LOOP) in lpfc_map_topology()
9868 clear_bit(HBA_PERSISTENT_TOPO, &phba->hba_flag); in lpfc_map_topology()
9871 /* If topology failover set - pt is '0' or '1' */ in lpfc_map_topology()
9872 phba->cfg_topology = (pt ? FLAGS_TOPOLOGY_MODE_PT_LOOP : in lpfc_map_topology()
9875 phba->cfg_topology = ((pt == LINK_FLAGS_P2P) in lpfc_map_topology()
9879 if (test_bit(HBA_PERSISTENT_TOPO, &phba->hba_flag)) in lpfc_map_topology()
9882 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9887 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9891 * lpfc_sli4_read_config - Get the config parameters.
9900 * 0 - successful
9901 * -ENOMEM - No available memory
9902 * -EIO - The mailbox failed to complete successfully.
9918 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_read_config()
9923 return -ENOMEM; in lpfc_sli4_read_config()
9933 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
9934 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
9935 rc = -EIO; in lpfc_sli4_read_config()
9937 rd_config = &pmb->u.mqe.un.rd_config; in lpfc_sli4_read_config()
9939 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_VAL; in lpfc_sli4_read_config()
9940 phba->sli4_hba.lnk_info.lnk_tp = in lpfc_sli4_read_config()
9942 phba->sli4_hba.lnk_info.lnk_no = in lpfc_sli4_read_config()
9946 phba->sli4_hba.lnk_info.lnk_tp, in lpfc_sli4_read_config()
9947 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_read_config()
9951 bf_get(lpfc_mqe_command, &pmb->u.mqe)); in lpfc_sli4_read_config()
9953 phba->bbcredit_support = 1; in lpfc_sli4_read_config()
9954 phba->sli4_hba.bbscn_params.word0 = rd_config->word8; in lpfc_sli4_read_config()
9962 "2702 READ_CONFIG: FA-PWWN is " in lpfc_sli4_read_config()
9964 phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_CONFIG; in lpfc_sli4_read_config()
9967 phba->sli4_hba.fawwpn_flag &= ~LPFC_FAWWPN_CONFIG; in lpfc_sli4_read_config()
9970 phba->sli4_hba.conf_trunk = in lpfc_sli4_read_config()
9972 phba->sli4_hba.extents_in_use = in lpfc_sli4_read_config()
9975 phba->sli4_hba.max_cfg_param.max_xri = in lpfc_sli4_read_config()
9979 phba->sli4_hba.max_cfg_param.max_xri > 512) in lpfc_sli4_read_config()
9980 phba->sli4_hba.max_cfg_param.max_xri = 512; in lpfc_sli4_read_config()
9981 phba->sli4_hba.max_cfg_param.xri_base = in lpfc_sli4_read_config()
9983 phba->sli4_hba.max_cfg_param.max_vpi = in lpfc_sli4_read_config()
9986 if (phba->sli4_hba.max_cfg_param.max_vpi > LPFC_MAX_VPORTS) in lpfc_sli4_read_config()
9987 phba->sli4_hba.max_cfg_param.max_vpi = LPFC_MAX_VPORTS; in lpfc_sli4_read_config()
9988 phba->sli4_hba.max_cfg_param.vpi_base = in lpfc_sli4_read_config()
9990 phba->sli4_hba.max_cfg_param.max_rpi = in lpfc_sli4_read_config()
9992 phba->sli4_hba.max_cfg_param.rpi_base = in lpfc_sli4_read_config()
9994 phba->sli4_hba.max_cfg_param.max_vfi = in lpfc_sli4_read_config()
9996 phba->sli4_hba.max_cfg_param.vfi_base = in lpfc_sli4_read_config()
9998 phba->sli4_hba.max_cfg_param.max_fcfi = in lpfc_sli4_read_config()
10000 phba->sli4_hba.max_cfg_param.max_eq = in lpfc_sli4_read_config()
10002 phba->sli4_hba.max_cfg_param.max_rq = in lpfc_sli4_read_config()
10004 phba->sli4_hba.max_cfg_param.max_wq = in lpfc_sli4_read_config()
10006 phba->sli4_hba.max_cfg_param.max_cq = in lpfc_sli4_read_config()
10008 phba->lmt = bf_get(lpfc_mbx_rd_conf_lmt, rd_config); in lpfc_sli4_read_config()
10009 phba->sli4_hba.next_xri = phba->sli4_hba.max_cfg_param.xri_base; in lpfc_sli4_read_config()
10010 phba->vpi_base = phba->sli4_hba.max_cfg_param.vpi_base; in lpfc_sli4_read_config()
10011 phba->vfi_base = phba->sli4_hba.max_cfg_param.vfi_base; in lpfc_sli4_read_config()
10012 phba->max_vpi = (phba->sli4_hba.max_cfg_param.max_vpi > 0) ? in lpfc_sli4_read_config()
10013 (phba->sli4_hba.max_cfg_param.max_vpi - 1) : 0; in lpfc_sli4_read_config()
10014 phba->max_vports = phba->max_vpi; in lpfc_sli4_read_config()
10025 phba->cgn_reg_fpin = LPFC_CGN_FPIN_BOTH; in lpfc_sli4_read_config()
10026 phba->cgn_reg_signal = EDC_CG_SIG_NOTSUPPORTED; in lpfc_sli4_read_config()
10027 phba->cgn_sig_freq = lpfc_fabric_cgn_frequency; in lpfc_sli4_read_config()
10031 phba->cgn_reg_signal = EDC_CG_SIG_WARN_ONLY; in lpfc_sli4_read_config()
10032 phba->cgn_reg_fpin &= ~LPFC_CGN_FPIN_WARN; in lpfc_sli4_read_config()
10038 if (phba->cgn_reg_signal != in lpfc_sli4_read_config()
10041 phba->cgn_reg_fpin = LPFC_CGN_FPIN_BOTH; in lpfc_sli4_read_config()
10042 phba->cgn_reg_signal = in lpfc_sli4_read_config()
10045 phba->cgn_reg_signal = in lpfc_sli4_read_config()
10047 phba->cgn_reg_fpin = in lpfc_sli4_read_config()
10054 phba->cgn_init_reg_fpin = phba->cgn_reg_fpin; in lpfc_sli4_read_config()
10055 phba->cgn_init_reg_signal = phba->cgn_reg_signal; in lpfc_sli4_read_config()
10059 phba->cgn_reg_signal, phba->cgn_reg_fpin); in lpfc_sli4_read_config()
10069 phba->sli4_hba.extents_in_use, in lpfc_sli4_read_config()
10070 phba->sli4_hba.max_cfg_param.xri_base, in lpfc_sli4_read_config()
10071 phba->sli4_hba.max_cfg_param.max_xri, in lpfc_sli4_read_config()
10072 phba->sli4_hba.max_cfg_param.vpi_base, in lpfc_sli4_read_config()
10073 phba->sli4_hba.max_cfg_param.max_vpi, in lpfc_sli4_read_config()
10074 phba->sli4_hba.max_cfg_param.vfi_base, in lpfc_sli4_read_config()
10075 phba->sli4_hba.max_cfg_param.max_vfi, in lpfc_sli4_read_config()
10076 phba->sli4_hba.max_cfg_param.rpi_base, in lpfc_sli4_read_config()
10077 phba->sli4_hba.max_cfg_param.max_rpi, in lpfc_sli4_read_config()
10078 phba->sli4_hba.max_cfg_param.max_fcfi, in lpfc_sli4_read_config()
10079 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
10080 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
10081 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
10082 phba->sli4_hba.max_cfg_param.max_rq, in lpfc_sli4_read_config()
10083 phba->lmt); in lpfc_sli4_read_config()
10089 qmin = phba->sli4_hba.max_cfg_param.max_wq; in lpfc_sli4_read_config()
10090 if (phba->sli4_hba.max_cfg_param.max_cq < qmin) in lpfc_sli4_read_config()
10091 qmin = phba->sli4_hba.max_cfg_param.max_cq; in lpfc_sli4_read_config()
10096 qmin -= 4; in lpfc_sli4_read_config()
10097 if (phba->sli4_hba.max_cfg_param.max_eq < qmin) in lpfc_sli4_read_config()
10098 qmin = phba->sli4_hba.max_cfg_param.max_eq; in lpfc_sli4_read_config()
10101 if ((phba->cfg_irq_chann > qmin) || in lpfc_sli4_read_config()
10102 (phba->cfg_hdw_queue > qmin)) { in lpfc_sli4_read_config()
10104 "2005 Reducing Queues - " in lpfc_sli4_read_config()
10108 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
10109 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
10110 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
10111 qmin, phba->cfg_irq_chann, in lpfc_sli4_read_config()
10112 phba->cfg_hdw_queue); in lpfc_sli4_read_config()
10114 if (phba->cfg_irq_chann > qmin) in lpfc_sli4_read_config()
10115 phba->cfg_irq_chann = qmin; in lpfc_sli4_read_config()
10116 if (phba->cfg_hdw_queue > qmin) in lpfc_sli4_read_config()
10117 phba->cfg_hdw_queue = qmin; in lpfc_sli4_read_config()
10125 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_read_config()
10130 set_bit(HBA_FORCED_LINK_SPEED, &phba->hba_flag); in lpfc_sli4_read_config()
10134 phba->cfg_link_speed = in lpfc_sli4_read_config()
10138 phba->cfg_link_speed = in lpfc_sli4_read_config()
10142 phba->cfg_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()
10175 phba->cfg_link_speed = in lpfc_sli4_read_config()
10182 length = phba->sli4_hba.max_cfg_param.max_xri - in lpfc_sli4_read_config()
10184 if (phba->cfg_hba_queue_depth > length) { in lpfc_sli4_read_config()
10187 phba->cfg_hba_queue_depth, length); in lpfc_sli4_read_config()
10188 phba->cfg_hba_queue_depth = length; in lpfc_sli4_read_config()
10191 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_read_config()
10196 length = (sizeof(struct lpfc_mbx_get_func_cfg) - in lpfc_sli4_read_config()
10204 &pmb->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_read_config()
10205 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_read_config()
10206 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_read_config()
10211 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
10212 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
10217 get_func_cfg = &pmb->u.mqe.un.get_func_cfg; in lpfc_sli4_read_config()
10219 pdesc_0 = (char *)&get_func_cfg->func_cfg.desc[0]; in lpfc_sli4_read_config()
10231 phba->sli4_hba.iov.pf_number = in lpfc_sli4_read_config()
10233 phba->sli4_hba.iov.vf_number = in lpfc_sli4_read_config()
10242 "vf_number:%d\n", phba->sli4_hba.iov.pf_number, in lpfc_sli4_read_config()
10243 phba->sli4_hba.iov.vf_number); in lpfc_sli4_read_config()
10251 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_read_config()
10256 * lpfc_setup_endian_order - Write endian order to an SLI4 if_type 0 port.
10259 * This routine is invoked to setup the port-side endian order when
10264 * 0 - successful
10265 * -ENOMEM - No available memory
10266 * -EIO - The mailbox failed to complete successfully.
10276 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_setup_endian_order()
10279 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_setup_endian_order()
10286 return -ENOMEM; in lpfc_setup_endian_order()
10294 memcpy(&mboxq->u.mqe, &endian_mb_data, sizeof(endian_mb_data)); in lpfc_setup_endian_order()
10301 rc = -EIO; in lpfc_setup_endian_order()
10303 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_setup_endian_order()
10315 * lpfc_sli4_queue_verify - Verify and update EQ counts
10324 * 0 - successful
10325 * -ENOMEM - No available memory
10331 * Sanity check for configured queue parameters against the run-time in lpfc_sli4_queue_verify()
10335 if (phba->nvmet_support) { in lpfc_sli4_queue_verify()
10336 if (phba->cfg_hdw_queue < phba->cfg_nvmet_mrq) in lpfc_sli4_queue_verify()
10337 phba->cfg_nvmet_mrq = phba->cfg_hdw_queue; in lpfc_sli4_queue_verify()
10338 if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX) in lpfc_sli4_queue_verify()
10339 phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX; in lpfc_sli4_queue_verify()
10344 phba->cfg_hdw_queue, phba->cfg_irq_chann, in lpfc_sli4_queue_verify()
10345 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_verify()
10348 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_verify()
10349 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_verify()
10352 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_verify()
10353 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_verify()
10362 int cpu; in lpfc_alloc_io_wq_cq() local
10364 cpu = lpfc_find_cpu_handle(phba, idx, LPFC_FIND_BY_HDWQ); in lpfc_alloc_io_wq_cq()
10366 if (phba->enab_exp_wqcq_pages) in lpfc_alloc_io_wq_cq()
10369 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
10370 LPFC_CQE_EXP_COUNT, cpu); in lpfc_alloc_io_wq_cq()
10374 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
10375 phba->sli4_hba.cq_ecount, cpu); in lpfc_alloc_io_wq_cq()
10378 "0499 Failed allocate fast-path IO CQ (%d)\n", in lpfc_alloc_io_wq_cq()
10382 qdesc->qe_valid = 1; in lpfc_alloc_io_wq_cq()
10383 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
10384 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
10385 phba->sli4_hba.hdwq[idx].io_cq = qdesc; in lpfc_alloc_io_wq_cq()
10388 if (phba->enab_exp_wqcq_pages) { in lpfc_alloc_io_wq_cq()
10390 wqesize = (phba->fcp_embed_io) ? in lpfc_alloc_io_wq_cq()
10391 LPFC_WQE128_SIZE : phba->sli4_hba.wq_esize; in lpfc_alloc_io_wq_cq()
10394 LPFC_WQE_EXP_COUNT, cpu); in lpfc_alloc_io_wq_cq()
10397 phba->sli4_hba.wq_esize, in lpfc_alloc_io_wq_cq()
10398 phba->sli4_hba.wq_ecount, cpu); in lpfc_alloc_io_wq_cq()
10402 "0503 Failed allocate fast-path IO WQ (%d)\n", in lpfc_alloc_io_wq_cq()
10406 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
10407 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
10408 phba->sli4_hba.hdwq[idx].io_wq = qdesc; in lpfc_alloc_io_wq_cq()
10409 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_alloc_io_wq_cq()
10414 * lpfc_sli4_queue_create - Create all the SLI4 queues
10423 * 0 - successful
10424 * -ENOMEM - No availble memory
10425 * -EIO - The mailbox failed to complete successfully.
10431 int idx, cpu, eqcpu; in lpfc_sli4_queue_create() local
10442 phba->sli4_hba.mq_esize = LPFC_MQE_SIZE; in lpfc_sli4_queue_create()
10443 phba->sli4_hba.mq_ecount = LPFC_MQE_DEF_COUNT; in lpfc_sli4_queue_create()
10444 phba->sli4_hba.wq_esize = LPFC_WQE_SIZE; in lpfc_sli4_queue_create()
10445 phba->sli4_hba.wq_ecount = LPFC_WQE_DEF_COUNT; in lpfc_sli4_queue_create()
10446 phba->sli4_hba.rq_esize = LPFC_RQE_SIZE; in lpfc_sli4_queue_create()
10447 phba->sli4_hba.rq_ecount = LPFC_RQE_DEF_COUNT; in lpfc_sli4_queue_create()
10448 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_create()
10449 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_create()
10450 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_create()
10451 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_create()
10453 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
10454 phba->sli4_hba.hdwq = kcalloc( in lpfc_sli4_queue_create()
10455 phba->cfg_hdw_queue, sizeof(struct lpfc_sli4_hdw_queue), in lpfc_sli4_queue_create()
10457 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
10460 "fast-path Hardware Queue array\n"); in lpfc_sli4_queue_create()
10464 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10465 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_queue_create()
10466 spin_lock_init(&qp->io_buf_list_get_lock); in lpfc_sli4_queue_create()
10467 spin_lock_init(&qp->io_buf_list_put_lock); in lpfc_sli4_queue_create()
10468 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_sli4_queue_create()
10469 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_sli4_queue_create()
10470 qp->get_io_bufs = 0; in lpfc_sli4_queue_create()
10471 qp->put_io_bufs = 0; in lpfc_sli4_queue_create()
10472 qp->total_io_bufs = 0; in lpfc_sli4_queue_create()
10473 spin_lock_init(&qp->abts_io_buf_list_lock); in lpfc_sli4_queue_create()
10474 INIT_LIST_HEAD(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_queue_create()
10475 qp->abts_scsi_io_bufs = 0; in lpfc_sli4_queue_create()
10476 qp->abts_nvme_io_bufs = 0; in lpfc_sli4_queue_create()
10477 INIT_LIST_HEAD(&qp->sgl_list); in lpfc_sli4_queue_create()
10478 INIT_LIST_HEAD(&qp->cmd_rsp_buf_list); in lpfc_sli4_queue_create()
10479 spin_lock_init(&qp->hdwq_lock); in lpfc_sli4_queue_create()
10483 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10484 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
10485 phba->sli4_hba.nvmet_cqset = kcalloc( in lpfc_sli4_queue_create()
10486 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10489 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_create()
10492 "fast-path CQ set array\n"); in lpfc_sli4_queue_create()
10495 phba->sli4_hba.nvmet_mrq_hdr = kcalloc( in lpfc_sli4_queue_create()
10496 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10499 if (!phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_create()
10502 "fast-path RQ set hdr array\n"); in lpfc_sli4_queue_create()
10505 phba->sli4_hba.nvmet_mrq_data = kcalloc( in lpfc_sli4_queue_create()
10506 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10509 if (!phba->sli4_hba.nvmet_mrq_data) { in lpfc_sli4_queue_create()
10512 "fast-path RQ set data array\n"); in lpfc_sli4_queue_create()
10518 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10521 for_each_present_cpu(cpu) { in lpfc_sli4_queue_create()
10526 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
10527 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_create()
10530 /* Get a ptr to the Hardware Queue associated with this CPU */ in lpfc_sli4_queue_create()
10531 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
10535 phba->sli4_hba.eq_esize, in lpfc_sli4_queue_create()
10536 phba->sli4_hba.eq_ecount, cpu); in lpfc_sli4_queue_create()
10540 cpup->hdwq); in lpfc_sli4_queue_create()
10543 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10544 qdesc->hdwq = cpup->hdwq; in lpfc_sli4_queue_create()
10545 qdesc->chann = cpu; /* First CPU this EQ is affinitized to */ in lpfc_sli4_queue_create()
10546 qdesc->last_cpu = qdesc->chann; in lpfc_sli4_queue_create()
10549 qp->hba_eq = qdesc; in lpfc_sli4_queue_create()
10551 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, qdesc->last_cpu); in lpfc_sli4_queue_create()
10552 list_add(&qdesc->cpu_list, &eqi->list); in lpfc_sli4_queue_create()
10558 for_each_present_cpu(cpu) { in lpfc_sli4_queue_create()
10559 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
10562 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_sli4_queue_create()
10566 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
10567 if (qp->hba_eq) in lpfc_sli4_queue_create()
10571 eqcpu = lpfc_find_cpu_handle(phba, cpup->eq, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
10572 eqcpup = &phba->sli4_hba.cpu_map[eqcpu]; in lpfc_sli4_queue_create()
10573 qp->hba_eq = phba->sli4_hba.hdwq[eqcpup->hdwq].hba_eq; in lpfc_sli4_queue_create()
10577 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10582 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
10583 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
10584 cpu = lpfc_find_cpu_handle(phba, idx, in lpfc_sli4_queue_create()
10588 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10589 phba->sli4_hba.cq_ecount, in lpfc_sli4_queue_create()
10590 cpu); in lpfc_sli4_queue_create()
10597 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10598 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10599 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10600 phba->sli4_hba.nvmet_cqset[idx] = qdesc; in lpfc_sli4_queue_create()
10608 cpu = lpfc_find_cpu_handle(phba, 0, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
10609 /* Create slow-path Mailbox Command Complete Queue */ in lpfc_sli4_queue_create()
10611 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10612 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10615 "0500 Failed allocate slow-path mailbox CQ\n"); in lpfc_sli4_queue_create()
10618 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10619 phba->sli4_hba.mbx_cq = qdesc; in lpfc_sli4_queue_create()
10621 /* Create slow-path ELS Complete Queue */ in lpfc_sli4_queue_create()
10623 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10624 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10627 "0501 Failed allocate slow-path ELS CQ\n"); in lpfc_sli4_queue_create()
10630 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10631 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10632 phba->sli4_hba.els_cq = qdesc; in lpfc_sli4_queue_create()
10642 phba->sli4_hba.mq_esize, in lpfc_sli4_queue_create()
10643 phba->sli4_hba.mq_ecount, cpu); in lpfc_sli4_queue_create()
10646 "0505 Failed allocate slow-path MQ\n"); in lpfc_sli4_queue_create()
10649 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10650 phba->sli4_hba.mbx_wq = qdesc; in lpfc_sli4_queue_create()
10657 * Create slow-path ELS Work Queue. in lpfc_sli4_queue_create()
10660 wqesize = (phba->fcp_embed_io) ? in lpfc_sli4_queue_create()
10661 LPFC_WQE128_SIZE : phba->sli4_hba.wq_esize; in lpfc_sli4_queue_create()
10665 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
10668 "0504 Failed allocate slow-path ELS WQ\n"); in lpfc_sli4_queue_create()
10671 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10672 phba->sli4_hba.els_wq = qdesc; in lpfc_sli4_queue_create()
10673 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10675 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10678 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10679 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10685 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10686 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10687 phba->sli4_hba.nvmels_cq = qdesc; in lpfc_sli4_queue_create()
10691 phba->sli4_hba.wq_esize, in lpfc_sli4_queue_create()
10692 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
10698 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10699 phba->sli4_hba.nvmels_wq = qdesc; in lpfc_sli4_queue_create()
10700 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10709 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10710 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
10716 phba->sli4_hba.hdr_rq = qdesc; in lpfc_sli4_queue_create()
10720 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10721 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
10727 phba->sli4_hba.dat_rq = qdesc; in lpfc_sli4_queue_create()
10729 if ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) && in lpfc_sli4_queue_create()
10730 phba->nvmet_support) { in lpfc_sli4_queue_create()
10731 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
10732 cpu = lpfc_find_cpu_handle(phba, idx, in lpfc_sli4_queue_create()
10737 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10739 cpu); in lpfc_sli4_queue_create()
10746 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10747 phba->sli4_hba.nvmet_mrq_hdr[idx] = qdesc; in lpfc_sli4_queue_create()
10750 qdesc->rqbp = kzalloc_node(sizeof(*qdesc->rqbp), in lpfc_sli4_queue_create()
10752 cpu_to_node(cpu)); in lpfc_sli4_queue_create()
10753 if (qdesc->rqbp == NULL) { in lpfc_sli4_queue_create()
10761 INIT_LIST_HEAD(&qdesc->rqbp->rqb_buffer_list); in lpfc_sli4_queue_create()
10766 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10768 cpu); in lpfc_sli4_queue_create()
10775 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10776 phba->sli4_hba.nvmet_mrq_data[idx] = qdesc; in lpfc_sli4_queue_create()
10781 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10782 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10783 memset(&phba->sli4_hba.hdwq[idx].nvme_cstat, 0, in lpfc_sli4_queue_create()
10784 sizeof(phba->sli4_hba.hdwq[idx].nvme_cstat)); in lpfc_sli4_queue_create()
10789 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { in lpfc_sli4_queue_create()
10790 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10791 memset(&phba->sli4_hba.hdwq[idx].scsi_cstat, 0, in lpfc_sli4_queue_create()
10792 sizeof(phba->sli4_hba.hdwq[idx].scsi_cstat)); in lpfc_sli4_queue_create()
10800 return -ENOMEM; in lpfc_sli4_queue_create()
10834 hdwq = phba->sli4_hba.hdwq; in lpfc_sli4_release_hdwq()
10837 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_release_hdwq()
10844 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_release_hdwq()
10849 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_release_hdwq()
10851 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_sli4_release_hdwq()
10853 phba->sli4_hba.hba_eq_hdl[idx].eq = NULL; in lpfc_sli4_release_hdwq()
10858 * lpfc_sli4_queue_destroy - Destroy all the SLI4 queues
10865 * 0 - successful
10866 * -ENOMEM - No available memory
10867 * -EIO - The mailbox failed to complete successfully.
10877 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10878 phba->sli.sli_flag |= LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
10879 while (phba->sli.sli_flag & LPFC_QUEUE_FREE_WAIT) { in lpfc_sli4_queue_destroy()
10880 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10882 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10884 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10889 if (phba->sli4_hba.hdwq) in lpfc_sli4_queue_destroy()
10892 if (phba->nvmet_support) { in lpfc_sli4_queue_destroy()
10893 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_destroy()
10894 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10896 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_destroy()
10897 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10898 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_destroy()
10899 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10903 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_destroy()
10906 __lpfc_sli4_release_queue(&phba->sli4_hba.els_wq); in lpfc_sli4_queue_destroy()
10909 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_destroy()
10912 __lpfc_sli4_release_queue(&phba->sli4_hba.hdr_rq); in lpfc_sli4_queue_destroy()
10913 __lpfc_sli4_release_queue(&phba->sli4_hba.dat_rq); in lpfc_sli4_queue_destroy()
10916 __lpfc_sli4_release_queue(&phba->sli4_hba.els_cq); in lpfc_sli4_queue_destroy()
10919 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_destroy()
10922 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_destroy()
10925 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_destroy()
10928 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10929 phba->sli.sli_flag &= ~LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
10930 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10940 rqbp = rq->rqbp; in lpfc_free_rq_buffer()
10941 while (!list_empty(&rqbp->rqb_buffer_list)) { in lpfc_free_rq_buffer()
10942 list_remove_head(&rqbp->rqb_buffer_list, h_buf, in lpfc_free_rq_buffer()
10946 (rqbp->rqb_free_buffer)(phba, rqb_buffer); in lpfc_free_rq_buffer()
10947 rqbp->buffer_count--; in lpfc_free_rq_buffer()
10962 "6085 Fast-path %s (%d) not allocated\n", in lpfc_create_wq_cq()
10964 return -ENOMEM; in lpfc_create_wq_cq()
10980 *cq_map = cq->queue_id; in lpfc_create_wq_cq()
10983 "6087 CQ setup: cq[%d]-id=%d, parent eq[%d]-id=%d\n", in lpfc_create_wq_cq()
10984 qidx, cq->queue_id, qidx, eq->queue_id); in lpfc_create_wq_cq()
10992 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
10997 pring = wq->pring; in lpfc_create_wq_cq()
10998 pring->sli.sli4.wqp = (void *)wq; in lpfc_create_wq_cq()
10999 cq->pring = pring; in lpfc_create_wq_cq()
11002 "2593 WQ setup: wq[%d]-id=%d assoc=%d, cq[%d]-id=%d\n", in lpfc_create_wq_cq()
11003 qidx, wq->queue_id, wq->assoc_qid, qidx, cq->queue_id); in lpfc_create_wq_cq()
11008 "0539 Failed setup of slow-path MQ: " in lpfc_create_wq_cq()
11010 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
11015 "2589 MBX MQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_create_wq_cq()
11016 phba->sli4_hba.mbx_wq->queue_id, in lpfc_create_wq_cq()
11017 phba->sli4_hba.mbx_cq->queue_id); in lpfc_create_wq_cq()
11024 * lpfc_setup_cq_lookup - Setup the CQ lookup table
11036 memset(phba->sli4_hba.cq_lookup, 0, in lpfc_setup_cq_lookup()
11037 (sizeof(struct lpfc_queue *) * (phba->sli4_hba.cq_max + 1))); in lpfc_setup_cq_lookup()
11039 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_setup_cq_lookup()
11041 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_setup_cq_lookup()
11045 list_for_each_entry(childq, &eq->child_list, list) { in lpfc_setup_cq_lookup()
11046 if (childq->queue_id > phba->sli4_hba.cq_max) in lpfc_setup_cq_lookup()
11048 if (childq->subtype == LPFC_IO) in lpfc_setup_cq_lookup()
11049 phba->sli4_hba.cq_lookup[childq->queue_id] = in lpfc_setup_cq_lookup()
11056 * lpfc_sli4_queue_setup - Set up all the SLI4 queues
11063 * 0 - successful
11064 * -ENOMEM - No available memory
11065 * -EIO - The mailbox failed to complete successfully.
11075 int qidx, cpu; in lpfc_sli4_queue_setup() local
11077 int rc = -ENOMEM; in lpfc_sli4_queue_setup()
11079 /* Check for dual-ULP support */ in lpfc_sli4_queue_setup()
11080 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_queue_setup()
11085 return -ENOMEM; in lpfc_sli4_queue_setup()
11087 length = (sizeof(struct lpfc_mbx_query_fw_config) - in lpfc_sli4_queue_setup()
11096 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_queue_setup()
11097 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_queue_setup()
11098 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_queue_setup()
11104 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
11105 rc = -ENXIO; in lpfc_sli4_queue_setup()
11109 phba->sli4_hba.fw_func_mode = in lpfc_sli4_queue_setup()
11110 mboxq->u.mqe.un.query_fw_cfg.rsp.function_mode; in lpfc_sli4_queue_setup()
11111 phba->sli4_hba.physical_port = in lpfc_sli4_queue_setup()
11112 mboxq->u.mqe.un.query_fw_cfg.rsp.physical_port; in lpfc_sli4_queue_setup()
11115 phba->sli4_hba.fw_func_mode); in lpfc_sli4_queue_setup()
11117 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
11122 qp = phba->sli4_hba.hdwq; in lpfc_sli4_queue_setup()
11127 "3147 Fast-path EQs not allocated\n"); in lpfc_sli4_queue_setup()
11128 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11133 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_setup()
11135 for_each_present_cpu(cpu) { in lpfc_sli4_queue_setup()
11136 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
11138 /* Look for the CPU thats using that vector with in lpfc_sli4_queue_setup()
11141 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_setup()
11143 if (qidx != cpup->eq) in lpfc_sli4_queue_setup()
11147 rc = lpfc_eq_create(phba, qp[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
11148 phba->cfg_fcp_imax); in lpfc_sli4_queue_setup()
11151 "0523 Failed setup of fast-path" in lpfc_sli4_queue_setup()
11153 cpup->eq, (uint32_t)rc); in lpfc_sli4_queue_setup()
11158 phba->sli4_hba.hba_eq_hdl[cpup->eq].eq = in lpfc_sli4_queue_setup()
11159 qp[cpup->hdwq].hba_eq; in lpfc_sli4_queue_setup()
11162 "2584 HBA EQ setup: queue[%d]-id=%d\n", in lpfc_sli4_queue_setup()
11163 cpup->eq, in lpfc_sli4_queue_setup()
11164 qp[cpup->hdwq].hba_eq->queue_id); in lpfc_sli4_queue_setup()
11169 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_setup()
11170 cpu = lpfc_find_cpu_handle(phba, qidx, LPFC_FIND_BY_HDWQ); in lpfc_sli4_queue_setup()
11171 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
11175 phba->sli4_hba.hdwq[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
11178 &phba->sli4_hba.hdwq[qidx].io_cq_map, in lpfc_sli4_queue_setup()
11194 /* Set up slow-path MBOX CQ/MQ */ in lpfc_sli4_queue_setup()
11196 if (!phba->sli4_hba.mbx_cq || !phba->sli4_hba.mbx_wq) { in lpfc_sli4_queue_setup()
11199 phba->sli4_hba.mbx_cq ? in lpfc_sli4_queue_setup()
11201 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11206 phba->sli4_hba.mbx_cq, in lpfc_sli4_queue_setup()
11207 phba->sli4_hba.mbx_wq, in lpfc_sli4_queue_setup()
11215 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
11216 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_setup()
11218 "3165 Fast-path NVME CQ Set " in lpfc_sli4_queue_setup()
11220 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11223 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
11225 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
11237 rc = lpfc_cq_create(phba, phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
11246 phba->sli4_hba.nvmet_cqset[0]->chann = 0; in lpfc_sli4_queue_setup()
11249 "6090 NVMET CQ setup: cq-id=%d, " in lpfc_sli4_queue_setup()
11250 "parent eq-id=%d\n", in lpfc_sli4_queue_setup()
11251 phba->sli4_hba.nvmet_cqset[0]->queue_id, in lpfc_sli4_queue_setup()
11252 qp[0].hba_eq->queue_id); in lpfc_sli4_queue_setup()
11256 /* Set up slow-path ELS WQ/CQ */ in lpfc_sli4_queue_setup()
11257 if (!phba->sli4_hba.els_cq || !phba->sli4_hba.els_wq) { in lpfc_sli4_queue_setup()
11260 phba->sli4_hba.els_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
11261 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11265 phba->sli4_hba.els_cq, in lpfc_sli4_queue_setup()
11266 phba->sli4_hba.els_wq, in lpfc_sli4_queue_setup()
11275 "2590 ELS WQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11276 phba->sli4_hba.els_wq->queue_id, in lpfc_sli4_queue_setup()
11277 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
11279 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_setup()
11281 if (!phba->sli4_hba.nvmels_cq || !phba->sli4_hba.nvmels_wq) { in lpfc_sli4_queue_setup()
11284 phba->sli4_hba.nvmels_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
11285 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11289 phba->sli4_hba.nvmels_cq, in lpfc_sli4_queue_setup()
11290 phba->sli4_hba.nvmels_wq, in lpfc_sli4_queue_setup()
11300 "6096 ELS WQ setup: wq-id=%d, " in lpfc_sli4_queue_setup()
11301 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11302 phba->sli4_hba.nvmels_wq->queue_id, in lpfc_sli4_queue_setup()
11303 phba->sli4_hba.nvmels_cq->queue_id); in lpfc_sli4_queue_setup()
11309 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
11310 if ((!phba->sli4_hba.nvmet_cqset) || in lpfc_sli4_queue_setup()
11311 (!phba->sli4_hba.nvmet_mrq_hdr) || in lpfc_sli4_queue_setup()
11312 (!phba->sli4_hba.nvmet_mrq_data)) { in lpfc_sli4_queue_setup()
11316 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11319 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
11321 phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_setup()
11322 phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_setup()
11323 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
11335 phba->sli4_hba.nvmet_mrq_hdr[0], in lpfc_sli4_queue_setup()
11336 phba->sli4_hba.nvmet_mrq_data[0], in lpfc_sli4_queue_setup()
11337 phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
11349 "6099 NVMET RQ setup: hdr-rq-id=%d, " in lpfc_sli4_queue_setup()
11350 "dat-rq-id=%d parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11351 phba->sli4_hba.nvmet_mrq_hdr[0]->queue_id, in lpfc_sli4_queue_setup()
11352 phba->sli4_hba.nvmet_mrq_data[0]->queue_id, in lpfc_sli4_queue_setup()
11353 phba->sli4_hba.nvmet_cqset[0]->queue_id); in lpfc_sli4_queue_setup()
11358 if (!phba->sli4_hba.hdr_rq || !phba->sli4_hba.dat_rq) { in lpfc_sli4_queue_setup()
11361 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11365 rc = lpfc_rq_create(phba, phba->sli4_hba.hdr_rq, phba->sli4_hba.dat_rq, in lpfc_sli4_queue_setup()
11366 phba->sli4_hba.els_cq, LPFC_USOL); in lpfc_sli4_queue_setup()
11375 "2592 USL RQ setup: hdr-rq-id=%d, dat-rq-id=%d " in lpfc_sli4_queue_setup()
11376 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11377 phba->sli4_hba.hdr_rq->queue_id, in lpfc_sli4_queue_setup()
11378 phba->sli4_hba.dat_rq->queue_id, in lpfc_sli4_queue_setup()
11379 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
11381 if (phba->cfg_fcp_imax) in lpfc_sli4_queue_setup()
11382 usdelay = LPFC_SEC_TO_USEC / phba->cfg_fcp_imax; in lpfc_sli4_queue_setup()
11386 for (qidx = 0; qidx < phba->cfg_irq_chann; in lpfc_sli4_queue_setup()
11391 if (phba->sli4_hba.cq_max) { in lpfc_sli4_queue_setup()
11392 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_setup()
11393 phba->sli4_hba.cq_lookup = kcalloc((phba->sli4_hba.cq_max + 1), in lpfc_sli4_queue_setup()
11395 if (!phba->sli4_hba.cq_lookup) { in lpfc_sli4_queue_setup()
11398 "size 0x%x\n", phba->sli4_hba.cq_max); in lpfc_sli4_queue_setup()
11399 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11413 * lpfc_sli4_queue_unset - Unset all the SLI4 queues
11420 * 0 - successful
11421 * -ENOMEM - No available memory
11422 * -EIO - The mailbox failed to complete successfully.
11432 if (phba->sli4_hba.mbx_wq) in lpfc_sli4_queue_unset()
11433 lpfc_mq_destroy(phba, phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_unset()
11436 if (phba->sli4_hba.nvmels_wq) in lpfc_sli4_queue_unset()
11437 lpfc_wq_destroy(phba, phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_unset()
11440 if (phba->sli4_hba.els_wq) in lpfc_sli4_queue_unset()
11441 lpfc_wq_destroy(phba, phba->sli4_hba.els_wq); in lpfc_sli4_queue_unset()
11444 if (phba->sli4_hba.hdr_rq) in lpfc_sli4_queue_unset()
11445 lpfc_rq_destroy(phba, phba->sli4_hba.hdr_rq, in lpfc_sli4_queue_unset()
11446 phba->sli4_hba.dat_rq); in lpfc_sli4_queue_unset()
11449 if (phba->sli4_hba.mbx_cq) in lpfc_sli4_queue_unset()
11450 lpfc_cq_destroy(phba, phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_unset()
11453 if (phba->sli4_hba.els_cq) in lpfc_sli4_queue_unset()
11454 lpfc_cq_destroy(phba, phba->sli4_hba.els_cq); in lpfc_sli4_queue_unset()
11457 if (phba->sli4_hba.nvmels_cq) in lpfc_sli4_queue_unset()
11458 lpfc_cq_destroy(phba, phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_unset()
11460 if (phba->nvmet_support) { in lpfc_sli4_queue_unset()
11462 if (phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_unset()
11463 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
11466 phba->sli4_hba.nvmet_mrq_hdr[qidx], in lpfc_sli4_queue_unset()
11467 phba->sli4_hba.nvmet_mrq_data[qidx]); in lpfc_sli4_queue_unset()
11471 if (phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_unset()
11472 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
11474 phba, phba->sli4_hba.nvmet_cqset[qidx]); in lpfc_sli4_queue_unset()
11478 /* Unset fast-path SLI4 queues */ in lpfc_sli4_queue_unset()
11479 if (phba->sli4_hba.hdwq) { in lpfc_sli4_queue_unset()
11481 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_unset()
11483 qp = &phba->sli4_hba.hdwq[qidx]; in lpfc_sli4_queue_unset()
11484 lpfc_wq_destroy(phba, qp->io_wq); in lpfc_sli4_queue_unset()
11485 lpfc_cq_destroy(phba, qp->io_cq); in lpfc_sli4_queue_unset()
11488 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_unset()
11490 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_sli4_queue_unset()
11495 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_unset()
11496 phba->sli4_hba.cq_lookup = NULL; in lpfc_sli4_queue_unset()
11497 phba->sli4_hba.cq_max = 0; in lpfc_sli4_queue_unset()
11501 * lpfc_sli4_cq_event_pool_create - Create completion-queue event free pool
11508 * - Mailbox asynchronous events
11509 * - Receive queue completion unsolicited events
11510 * Later, this can be used for all the slow-path events.
11513 * 0 - successful
11514 * -ENOMEM - No available memory
11522 for (i = 0; i < (4 * phba->sli4_hba.cq_ecount); i++) { in lpfc_sli4_cq_event_pool_create()
11526 list_add_tail(&cq_event->list, in lpfc_sli4_cq_event_pool_create()
11527 &phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_cq_event_pool_create()
11533 return -ENOMEM; in lpfc_sli4_cq_event_pool_create()
11537 * lpfc_sli4_cq_event_pool_destroy - Free completion-queue event free pool
11542 * cleanup routine to free all the outstanding completion-queue events
11552 &phba->sli4_hba.sp_cqe_event_pool, list) { in lpfc_sli4_cq_event_pool_destroy()
11553 list_del(&cq_event->list); in lpfc_sli4_cq_event_pool_destroy()
11559 * __lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
11563 * completion-queue event from the free pool.
11565 * Return: Pointer to the newly allocated completion-queue event if successful
11573 list_remove_head(&phba->sli4_hba.sp_cqe_event_pool, cq_event, in __lpfc_sli4_cq_event_alloc()
11579 * lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
11583 * completion-queue event from the free pool.
11585 * Return: Pointer to the newly allocated completion-queue event if successful
11594 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
11596 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
11601 * __lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
11606 * completion-queue event back into the free pool.
11612 list_add_tail(&cq_event->list, &phba->sli4_hba.sp_cqe_event_pool); in __lpfc_sli4_cq_event_release()
11616 * lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
11621 * completion-queue event back into the free pool.
11628 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
11630 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
11634 * lpfc_sli4_cq_event_release_all - Release all cq events to the free pool
11637 * This routine is to free all the pending completion-queue events to the
11650 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11651 list_splice_init(&phba->sli4_hba.sp_els_xri_aborted_work_queue, in lpfc_sli4_cq_event_release_all()
11653 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11656 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11657 list_splice_init(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_cq_event_release_all()
11659 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11669 * lpfc_pci_function_reset - Reset pci function.
11676 * 0 - successful
11677 * -ENOMEM - No available memory
11678 * -EIO - The mailbox failed to complete successfully.
11692 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_pci_function_reset()
11695 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_pci_function_reset()
11702 return -ENOMEM; in lpfc_pci_function_reset()
11705 /* Setup PCI function reset mailbox-ioctl command */ in lpfc_pci_function_reset()
11711 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_pci_function_reset()
11712 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_pci_function_reset()
11714 &shdr->response); in lpfc_pci_function_reset()
11715 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_pci_function_reset()
11722 rc = -ENXIO; in lpfc_pci_function_reset()
11734 if (lpfc_readl(phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
11736 rc = -ENODEV; in lpfc_pci_function_reset()
11745 phba->work_status[0] = readl( in lpfc_pci_function_reset()
11746 phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_pci_function_reset()
11747 phba->work_status[1] = readl( in lpfc_pci_function_reset()
11748 phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_pci_function_reset()
11753 phba->work_status[0], in lpfc_pci_function_reset()
11754 phba->work_status[1]); in lpfc_pci_function_reset()
11755 rc = -ENODEV; in lpfc_pci_function_reset()
11771 writel(reg_data.word0, phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
11774 pci_read_config_word(phba->pcidev, in lpfc_pci_function_reset()
11781 rc = -ENODEV; in lpfc_pci_function_reset()
11792 /* Catch the not-ready port failure after a port reset. */ in lpfc_pci_function_reset()
11797 rc = -ENODEV; in lpfc_pci_function_reset()
11804 * lpfc_sli4_pci_mem_setup - Setup SLI4 HBA PCI memory space.
11808 * with SLI-4 interface spec.
11811 * 0 - successful
11812 * other values - error
11817 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_pci_mem_setup()
11823 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11826 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli4_pci_mem_setup()
11828 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli4_pci_mem_setup()
11837 &phba->sli4_hba.sli_intf.word0)) { in lpfc_sli4_pci_mem_setup()
11838 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11842 if (bf_get(lpfc_sli_intf_valid, &phba->sli4_hba.sli_intf) != in lpfc_sli4_pci_mem_setup()
11847 phba->sli4_hba.sli_intf.word0); in lpfc_sli4_pci_mem_setup()
11848 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11851 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_setup()
11859 phba->pci_bar0_map = pci_resource_start(pdev, PCI_64BIT_BAR0); in lpfc_sli4_pci_mem_setup()
11866 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11867 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
11868 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11869 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11872 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11874 phba->pci_bar0_memmap_p = phba->sli4_hba.conf_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11878 phba->pci_bar0_map = pci_resource_start(pdev, 1); in lpfc_sli4_pci_mem_setup()
11881 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11882 "FATAL - No BAR0 mapping for SLI4, if_type 2\n"); in lpfc_sli4_pci_mem_setup()
11883 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11885 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11886 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
11887 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11888 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11891 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11902 phba->pci_bar1_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
11905 phba->sli4_hba.ctrl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11906 ioremap(phba->pci_bar1_map, in lpfc_sli4_pci_mem_setup()
11908 if (!phba->sli4_hba.ctrl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11909 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11912 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11915 phba->pci_bar2_memmap_p = in lpfc_sli4_pci_mem_setup()
11916 phba->sli4_hba.ctrl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11919 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11930 phba->pci_bar1_map = pci_resource_start(pdev, PCI_64BIT_BAR2); in lpfc_sli4_pci_mem_setup()
11932 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11933 ioremap(phba->pci_bar1_map, bar1map_len); in lpfc_sli4_pci_mem_setup()
11934 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11935 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11937 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11940 phba->pci_bar2_memmap_p = phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11950 phba->pci_bar2_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
11953 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11954 ioremap(phba->pci_bar2_map, in lpfc_sli4_pci_mem_setup()
11956 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11957 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11960 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11963 phba->pci_bar4_memmap_p = in lpfc_sli4_pci_mem_setup()
11964 phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11969 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11980 phba->pci_bar2_map = pci_resource_start(pdev, PCI_64BIT_BAR4); in lpfc_sli4_pci_mem_setup()
11982 phba->sli4_hba.dpp_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11983 ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli4_pci_mem_setup()
11984 if (!phba->sli4_hba.dpp_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11985 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11987 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11990 phba->pci_bar4_memmap_p = phba->sli4_hba.dpp_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11997 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
11998 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_write_eq_db; in lpfc_sli4_pci_mem_setup()
11999 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_write_cq_db; in lpfc_sli4_pci_mem_setup()
12002 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_if6_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
12003 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_if6_write_eq_db; in lpfc_sli4_pci_mem_setup()
12004 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_if6_write_cq_db; in lpfc_sli4_pci_mem_setup()
12013 if (phba->sli4_hba.drbl_regs_memmap_p) in lpfc_sli4_pci_mem_setup()
12014 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12016 if (phba->sli4_hba.ctrl_regs_memmap_p) in lpfc_sli4_pci_mem_setup()
12017 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12019 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12025 * lpfc_sli4_pci_mem_unset - Unset SLI4 HBA PCI memory space.
12029 * with SLI-4 interface spec.
12035 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_unset()
12039 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12040 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12041 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12044 iounmap(phba->sli4_hba.conf_regs_memmap_p); 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.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12049 if (phba->sli4_hba.dpp_regs_memmap_p) in lpfc_sli4_pci_mem_unset()
12050 iounmap(phba->sli4_hba.dpp_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12055 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_pci_mem_unset()
12056 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_pci_mem_unset()
12063 * lpfc_sli_enable_msix - Enable MSI-X interrupt mode on SLI-3 device
12066 * This routine is invoked to enable the MSI-X interrupt vectors to device
12067 * with SLI-3 interface specs.
12070 * 0 - successful
12071 * other values - error
12079 /* Set up MSI-X multi-message vectors */ in lpfc_sli_enable_msix()
12080 rc = pci_alloc_irq_vectors(phba->pcidev, in lpfc_sli_enable_msix()
12084 "0420 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli_enable_msix()
12089 * Assign MSI-X vectors to interrupt handlers in lpfc_sli_enable_msix()
12092 /* vector-0 is associated to slow-path handler */ in lpfc_sli_enable_msix()
12093 rc = request_irq(pci_irq_vector(phba->pcidev, 0), in lpfc_sli_enable_msix()
12098 "0421 MSI-X slow-path request_irq failed " in lpfc_sli_enable_msix()
12103 /* vector-1 is associated to fast-path handler */ in lpfc_sli_enable_msix()
12104 rc = request_irq(pci_irq_vector(phba->pcidev, 1), in lpfc_sli_enable_msix()
12110 "0429 MSI-X fast-path request_irq failed " in lpfc_sli_enable_msix()
12116 * Configure HBA MSI-X attention conditions to messages in lpfc_sli_enable_msix()
12118 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_enable_msix()
12121 rc = -ENOMEM; in lpfc_sli_enable_msix()
12135 pmb->u.mb.mbxCommand, pmb->u.mb.mbxStatus); in lpfc_sli_enable_msix()
12140 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
12145 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
12149 free_irq(pci_irq_vector(phba->pcidev, 1), phba); in lpfc_sli_enable_msix()
12153 free_irq(pci_irq_vector(phba->pcidev, 0), phba); in lpfc_sli_enable_msix()
12156 /* Unconfigure MSI-X capability structure */ in lpfc_sli_enable_msix()
12157 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_enable_msix()
12164 * lpfc_sli_enable_msi - Enable MSI interrupt mode on SLI-3 device.
12168 * SLI-3 interface spec. The kernel function pci_enable_msi() is called to
12174 * 0 - successful
12175 * other values - error
12182 rc = pci_enable_msi(phba->pcidev); in lpfc_sli_enable_msi()
12192 rc = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_msi()
12195 pci_disable_msi(phba->pcidev); in lpfc_sli_enable_msi()
12203 * lpfc_sli_enable_intr - Enable device interrupt to SLI-3 device.
12205 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
12208 * interrupt handler(s) to interrupt vector(s) to device with SLI-3 interface
12213 * MSI-X -> MSI -> IRQ.
12216 * 0 - successful
12217 * other values - error
12229 clear_bit(HBA_NEEDS_CFG_PORT, &phba->hba_flag); in lpfc_sli_enable_intr()
12232 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli_enable_intr()
12235 /* Indicate initialization to MSI-X mode */ in lpfc_sli_enable_intr()
12236 phba->intr_type = MSIX; in lpfc_sli_enable_intr()
12241 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli_enable_intr()
12242 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli_enable_intr()
12246 phba->intr_type = MSI; in lpfc_sli_enable_intr()
12251 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli_enable_intr()
12252 if (phba->intr_type == NONE) { in lpfc_sli_enable_intr()
12253 retval = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_intr()
12257 phba->intr_type = INTx; in lpfc_sli_enable_intr()
12265 * lpfc_sli_disable_intr - Disable device interrupt to SLI-3 device.
12270 * SLI-3 interface spec. Depending on the interrupt mode, the driver will
12278 if (phba->intr_type == MSIX) in lpfc_sli_disable_intr()
12284 free_irq(pci_irq_vector(phba->pcidev, i), phba); in lpfc_sli_disable_intr()
12285 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_disable_intr()
12288 phba->intr_type = NONE; in lpfc_sli_disable_intr()
12289 phba->sli.slistat.sli_intr = 0; in lpfc_sli_disable_intr()
12293 * lpfc_find_cpu_handle - Find the CPU that corresponds to the specified Queue
12298 * Return the CPU that matches the selection criteria
12304 int cpu; in lpfc_find_cpu_handle() local
12307 for_each_present_cpu(cpu) { in lpfc_find_cpu_handle()
12308 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_find_cpu_handle()
12315 (cpup->flag & LPFC_CPU_FIRST_IRQ) && in lpfc_find_cpu_handle()
12316 (cpup->eq == id)) in lpfc_find_cpu_handle()
12317 return cpu; in lpfc_find_cpu_handle()
12319 /* If matching by HDWQ, select the first CPU that matches */ in lpfc_find_cpu_handle()
12320 if ((match == LPFC_FIND_BY_HDWQ) && (cpup->hdwq == id)) in lpfc_find_cpu_handle()
12321 return cpu; in lpfc_find_cpu_handle()
12328 * lpfc_find_hyper - Determine if the CPU map entry is hyper-threaded
12330 * @cpu: CPU map index
12331 * @phys_id: CPU package physical id
12332 * @core_id: CPU core id
12335 lpfc_find_hyper(struct lpfc_hba *phba, int cpu, in lpfc_find_hyper() argument
12342 cpup = &phba->sli4_hba.cpu_map[idx]; in lpfc_find_hyper()
12344 if ((cpup->phys_id == phys_id) && in lpfc_find_hyper()
12345 (cpup->core_id == core_id) && in lpfc_find_hyper()
12346 (cpu != idx)) in lpfc_find_hyper()
12354 * lpfc_assign_eq_map_info - Assigns eq for vector_map structure
12358 * @cpu: cpu used to index vector_map structure
12364 unsigned int cpu) in lpfc_assign_eq_map_info() argument
12366 struct lpfc_vector_map_info *cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_assign_eq_map_info()
12369 cpup->eq = eqidx; in lpfc_assign_eq_map_info()
12370 cpup->flag |= flag; in lpfc_assign_eq_map_info()
12373 "3336 Set Affinity: CPU %d irq %d eq %d flag x%x\n", in lpfc_assign_eq_map_info()
12374 cpu, eqhdl->irq, cpup->eq, cpup->flag); in lpfc_assign_eq_map_info()
12378 * lpfc_cpu_map_array_init - Initialize cpu_map structure
12388 int cpu; in lpfc_cpu_map_array_init() local
12390 for_each_possible_cpu(cpu) { in lpfc_cpu_map_array_init()
12391 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_map_array_init()
12392 cpup->phys_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12393 cpup->core_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12394 cpup->hdwq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12395 cpup->eq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12396 cpup->flag = 0; in lpfc_cpu_map_array_init()
12397 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, cpu); in lpfc_cpu_map_array_init()
12398 INIT_LIST_HEAD(&eqi->list); in lpfc_cpu_map_array_init()
12399 eqi->icnt = 0; in lpfc_cpu_map_array_init()
12404 * lpfc_hba_eq_hdl_array_init - Initialize hba_eq_hdl structure
12415 for (i = 0; i < phba->cfg_irq_chann; i++) { in lpfc_hba_eq_hdl_array_init()
12417 eqhdl->irq = LPFC_IRQ_EMPTY; in lpfc_hba_eq_hdl_array_init()
12418 eqhdl->phba = phba; in lpfc_hba_eq_hdl_array_init()
12423 * lpfc_cpu_affinity_check - Check vector CPU affinity mappings
12427 * The routine will figure out the CPU affinity assignment for every
12428 * MSI-X vector allocated for the HBA.
12429 * In addition, the CPU to IO channel mapping will be calculated
12430 * and the phba->sli4_hba.cpu_map array will reflect this.
12435 int i, cpu, idx, next_idx, new_cpu, start_cpu, first_cpu; in lpfc_cpu_affinity_check() local
12449 /* Update CPU map with physical id and core id of each CPU */ in lpfc_cpu_affinity_check()
12450 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
12451 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12453 cpup->phys_id = topology_physical_package_id(cpu); in lpfc_cpu_affinity_check()
12454 cpup->core_id = topology_core_id(cpu); in lpfc_cpu_affinity_check()
12455 if (lpfc_find_hyper(phba, cpu, cpup->phys_id, cpup->core_id)) in lpfc_cpu_affinity_check()
12456 cpup->flag |= LPFC_CPU_MAP_HYPER; in lpfc_cpu_affinity_check()
12459 cpup->phys_id = 0; in lpfc_cpu_affinity_check()
12460 cpup->core_id = cpu; in lpfc_cpu_affinity_check()
12464 "3328 CPU %d physid %d coreid %d flag x%x\n", in lpfc_cpu_affinity_check()
12465 cpu, cpup->phys_id, cpup->core_id, cpup->flag); in lpfc_cpu_affinity_check()
12467 if (cpup->phys_id > max_phys_id) in lpfc_cpu_affinity_check()
12468 max_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
12469 if (cpup->phys_id < min_phys_id) in lpfc_cpu_affinity_check()
12470 min_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
12472 if (cpup->core_id > max_core_id) in lpfc_cpu_affinity_check()
12473 max_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
12474 if (cpup->core_id < min_core_id) in lpfc_cpu_affinity_check()
12475 min_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
12480 * Next we will set any unassigned (unaffinitized) cpu map in lpfc_cpu_affinity_check()
12486 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
12487 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12489 /* Is this CPU entry unassigned */ in lpfc_cpu_affinity_check()
12490 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
12491 /* Mark CPU as IRQ not assigned by the kernel */ in lpfc_cpu_affinity_check()
12492 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
12500 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12501 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12502 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
12503 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY) && in lpfc_cpu_affinity_check()
12504 (new_cpup->phys_id == cpup->phys_id)) in lpfc_cpu_affinity_check()
12508 /* At this point, we leave the CPU as unassigned */ in lpfc_cpu_affinity_check()
12512 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
12515 * chance of having multiple unassigned CPU entries in lpfc_cpu_affinity_check()
12521 "3337 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
12522 "eq %d from peer cpu %d same " in lpfc_cpu_affinity_check()
12524 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
12525 cpup->phys_id); in lpfc_cpu_affinity_check()
12529 /* Set any unassigned cpu map entries to a IRQ on any phys_id */ in lpfc_cpu_affinity_check()
12532 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
12533 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12536 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
12538 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
12546 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12547 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12548 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
12549 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY)) in lpfc_cpu_affinity_check()
12555 "3339 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
12557 cpup->hdwq, cpup->eq); in lpfc_cpu_affinity_check()
12561 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
12564 * chance of having multiple unassigned CPU entries in lpfc_cpu_affinity_check()
12570 "3338 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
12571 "eq %d from peer cpu %d (%d/%d)\n", in lpfc_cpu_affinity_check()
12572 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
12573 new_cpup->phys_id, new_cpup->core_id); in lpfc_cpu_affinity_check()
12581 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
12582 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12585 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_cpu_affinity_check()
12589 cpup->hdwq = idx; in lpfc_cpu_affinity_check()
12592 "3333 Set Affinity: CPU %d (phys %d core %d): " in lpfc_cpu_affinity_check()
12594 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
12595 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
12598 * This will be 1 to 1 - hdwq to cpu, unless there are less in lpfc_cpu_affinity_check()
12599 * hardware queues then CPUs. For that case we will just round-robin in lpfc_cpu_affinity_check()
12602 * for irq_chann < hdwq. The idx is used for round-robin assignments in lpfc_cpu_affinity_check()
12608 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
12609 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12612 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_cpu_affinity_check()
12619 if (next_idx < phba->cfg_hdw_queue) { in lpfc_cpu_affinity_check()
12620 cpup->hdwq = next_idx; in lpfc_cpu_affinity_check()
12625 /* Not a First CPU and all hdw_queues are used. Reuse a in lpfc_cpu_affinity_check()
12626 * Hardware Queue for another CPU, so be smart about it in lpfc_cpu_affinity_check()
12628 * (CPU package) and core_id. in lpfc_cpu_affinity_check()
12631 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12632 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12633 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
12634 new_cpup->phys_id == cpup->phys_id && in lpfc_cpu_affinity_check()
12635 new_cpup->core_id == cpup->core_id) { in lpfc_cpu_affinity_check()
12645 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12646 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12647 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
12648 new_cpup->phys_id == cpup->phys_id) in lpfc_cpu_affinity_check()
12654 cpup->hdwq = idx % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
12660 cpup->hdwq = new_cpup->hdwq; in lpfc_cpu_affinity_check()
12663 "3335 Set Affinity: CPU %d (phys %d core %d): " in lpfc_cpu_affinity_check()
12665 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
12666 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
12670 * Initialize the cpu_map slots for not-present cpus in case in lpfc_cpu_affinity_check()
12671 * a cpu is hot-added. Perform a simple hdwq round robin assignment. in lpfc_cpu_affinity_check()
12674 for_each_possible_cpu(cpu) { in lpfc_cpu_affinity_check()
12675 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12677 c_stat = per_cpu_ptr(phba->sli4_hba.c_stat, cpu); in lpfc_cpu_affinity_check()
12678 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
12680 if (cpup->hdwq != LPFC_VECTOR_MAP_EMPTY) in lpfc_cpu_affinity_check()
12683 cpup->hdwq = idx++ % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
12685 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
12689 "CPU %d hdwq %d\n", in lpfc_cpu_affinity_check()
12690 cpu, cpup->hdwq); in lpfc_cpu_affinity_check()
12703 * @cpu: cpu going offline
12707 lpfc_cpuhp_get_eq(struct lpfc_hba *phba, unsigned int cpu, in lpfc_cpuhp_get_eq() argument
12717 return -ENOMEM; in lpfc_cpuhp_get_eq()
12719 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_cpuhp_get_eq()
12720 maskp = pci_irq_get_affinity(phba->pcidev, idx); in lpfc_cpuhp_get_eq()
12724 * if irq is not affinitized to the cpu going in lpfc_cpuhp_get_eq()
12728 if (!cpumask_and(tmp, maskp, cpumask_of(cpu))) in lpfc_cpuhp_get_eq()
12730 /* get the cpus that are online and are affini- in lpfc_cpuhp_get_eq()
12732 * more than 1 then cpuhp is not going to shut- in lpfc_cpuhp_get_eq()
12733 * down this vector. Since this cpu has not in lpfc_cpuhp_get_eq()
12745 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_cpuhp_get_eq()
12746 list_add(&eq->_poll_list, eqlist); in lpfc_cpuhp_get_eq()
12754 if (phba->sli_rev != LPFC_SLI_REV4) in __lpfc_cpuhp_remove()
12758 &phba->cpuhp); in __lpfc_cpuhp_remove()
12764 timer_delete_sync(&phba->cpuhp_poll_timer); in __lpfc_cpuhp_remove()
12769 if (phba->pport && in lpfc_cpuhp_remove()
12770 test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_cpuhp_remove()
12778 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_cpuhp_add()
12783 if (!list_empty(&phba->poll_list)) in lpfc_cpuhp_add()
12784 mod_timer(&phba->cpuhp_poll_timer, in lpfc_cpuhp_add()
12790 &phba->cpuhp); in lpfc_cpuhp_add()
12795 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { in __lpfc_cpuhp_checks()
12796 *retval = -EAGAIN; in __lpfc_cpuhp_checks()
12800 if (phba->sli_rev != LPFC_SLI_REV4) { in __lpfc_cpuhp_checks()
12810 * lpfc_irq_set_aff - set IRQ affinity
12812 * @cpu: cpu to set affinity
12816 lpfc_irq_set_aff(struct lpfc_hba_eq_hdl *eqhdl, unsigned int cpu) in lpfc_irq_set_aff() argument
12818 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_set_aff()
12819 cpumask_set_cpu(cpu, &eqhdl->aff_mask); in lpfc_irq_set_aff()
12820 irq_set_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_set_aff()
12821 irq_set_affinity(eqhdl->irq, &eqhdl->aff_mask); in lpfc_irq_set_aff()
12825 * lpfc_irq_clear_aff - clear IRQ affinity
12832 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_clear_aff()
12833 irq_clear_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_clear_aff()
12837 * lpfc_irq_rebalance - rebalances IRQ affinity according to cpuhp event
12839 * @cpu: cpu going offline/online
12840 * @offline: true, cpu is going offline. false, cpu is coming online.
12842 * If cpu is going offline, we'll try our best effort to find the next
12843 * online cpu on the phba's original_mask and migrate all offlining IRQ
12846 * If cpu is coming online, reaffinitize the IRQ back to the onlining cpu.
12849 * PCI_IRQ_AFFINITY to auto-manage IRQ affinity.
12853 lpfc_irq_rebalance(struct lpfc_hba *phba, unsigned int cpu, bool offline) in lpfc_irq_rebalance() argument
12860 if (phba->irq_chann_mode == NORMAL_MODE) in lpfc_irq_rebalance()
12863 orig_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_irq_rebalance()
12865 if (!cpumask_test_cpu(cpu, orig_mask)) in lpfc_irq_rebalance()
12868 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_irq_rebalance()
12870 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_irq_rebalance()
12874 /* Find next online CPU on original mask */ in lpfc_irq_rebalance()
12875 cpu_next = cpumask_next_wrap(cpu, orig_mask); in lpfc_irq_rebalance()
12878 /* Found a valid CPU */ in lpfc_irq_rebalance()
12879 if ((cpu_select < nr_cpu_ids) && (cpu_select != cpu)) { in lpfc_irq_rebalance()
12881 * cpu aff_mask is migrated in lpfc_irq_rebalance()
12883 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_irq_rebalance()
12887 if (cpumask_test_cpu(cpu, aff_mask)) in lpfc_irq_rebalance()
12893 for (idx = 0; idx < phba->cfg_irq_chann; idx++) in lpfc_irq_rebalance()
12897 /* Migrate affinity back to this CPU */ in lpfc_irq_rebalance()
12898 lpfc_irq_set_aff(lpfc_get_eq_hdl(cpup->eq), cpu); in lpfc_irq_rebalance()
12902 static int lpfc_cpu_offline(unsigned int cpu, struct hlist_node *node) in lpfc_cpu_offline() argument
12910 WARN_ONCE(!phba, "cpu: %u. phba:NULL", raw_smp_processor_id()); in lpfc_cpu_offline()
12917 lpfc_irq_rebalance(phba, cpu, true); in lpfc_cpu_offline()
12919 retval = lpfc_cpuhp_get_eq(phba, cpu, &eqlist); in lpfc_cpu_offline()
12925 list_del_init(&eq->_poll_list); in lpfc_cpu_offline()
12932 static int lpfc_cpu_online(unsigned int cpu, struct hlist_node *node) in lpfc_cpu_online() argument
12940 WARN_ONCE(!phba, "cpu: %u. phba:NULL", raw_smp_processor_id()); in lpfc_cpu_online()
12947 lpfc_irq_rebalance(phba, cpu, false); in lpfc_cpu_online()
12949 list_for_each_entry_safe(eq, next, &phba->poll_list, _poll_list) { in lpfc_cpu_online()
12950 n = lpfc_find_cpu_handle(phba, eq->hdwq, LPFC_FIND_BY_HDWQ); in lpfc_cpu_online()
12951 if (n == cpu) in lpfc_cpu_online()
12959 * lpfc_sli4_enable_msix - Enable MSI-X interrupt mode to SLI-4 device
12962 * This routine is invoked to enable the MSI-X interrupt vectors to device
12963 * with SLI-4 interface spec. It also allocates MSI-X vectors and maps them
12969 * allocated and assigned to each online and offline cpu. If the cpu is
12970 * online, then affinity will be set to that cpu. If the cpu is offline, then
12971 * affinity will be set to the nearest peer cpu within the numa node that is
12973 * assigned and the OS may do as it pleases. Note: cpu vector affinity mapping
12974 * is consistent with the way cpu online/offline is handled when cfg_irq_numa is
12979 * cpu affinity. The driver will then use that affinity mapping to setup its
12980 * cpu mapping table.
12983 * 0 - successful
12984 * other values - error
12992 unsigned int cpu = 0, cpu_cnt = 0, cpu_select = nr_cpu_ids; in lpfc_sli4_enable_msix() local
12998 /* Set up MSI-X multi-message vectors */ in lpfc_sli4_enable_msix()
12999 vectors = phba->cfg_irq_chann; in lpfc_sli4_enable_msix()
13001 if (phba->irq_chann_mode != NORMAL_MODE) in lpfc_sli4_enable_msix()
13002 aff_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_sli4_enable_msix()
13006 vectors = min(phba->cfg_irq_chann, cpu_cnt); in lpfc_sli4_enable_msix()
13008 /* cpu: iterates over aff_mask including offline or online in lpfc_sli4_enable_msix()
13011 cpu = cpumask_first(aff_mask); in lpfc_sli4_enable_msix()
13012 cpu_select = lpfc_next_online_cpu(aff_mask, cpu); in lpfc_sli4_enable_msix()
13017 rc = pci_alloc_irq_vectors(phba->pcidev, 1, vectors, flags); in lpfc_sli4_enable_msix()
13020 "0484 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli4_enable_msix()
13025 /* Assign MSI-X vectors to interrupt handlers */ in lpfc_sli4_enable_msix()
13028 name = eqhdl->handler_name; in lpfc_sli4_enable_msix()
13033 eqhdl->idx = index; in lpfc_sli4_enable_msix()
13034 rc = pci_irq_vector(phba->pcidev, index); in lpfc_sli4_enable_msix()
13037 "0489 MSI-X fast-path (%d) " in lpfc_sli4_enable_msix()
13041 eqhdl->irq = rc; in lpfc_sli4_enable_msix()
13043 rc = request_threaded_irq(eqhdl->irq, in lpfc_sli4_enable_msix()
13049 "0486 MSI-X fast-path (%d) " in lpfc_sli4_enable_msix()
13055 /* If found a neighboring online cpu, set affinity */ in lpfc_sli4_enable_msix()
13062 cpu); in lpfc_sli4_enable_msix()
13064 /* Iterate to next offline or online cpu in aff_mask */ in lpfc_sli4_enable_msix()
13065 cpu = cpumask_next(cpu, aff_mask); in lpfc_sli4_enable_msix()
13067 /* Find next online cpu in aff_mask to set affinity */ in lpfc_sli4_enable_msix()
13068 cpu_select = lpfc_next_online_cpu(aff_mask, cpu); in lpfc_sli4_enable_msix()
13070 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_msix()
13072 cpu); in lpfc_sli4_enable_msix()
13074 maskp = pci_irq_get_affinity(phba->pcidev, index); in lpfc_sli4_enable_msix()
13077 for_each_cpu_and(cpu, maskp, cpu_present_mask) { in lpfc_sli4_enable_msix()
13078 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_enable_msix()
13080 /* If this is the first CPU thats assigned to in lpfc_sli4_enable_msix()
13084 * vectors are affinitized to all the cpu's. in lpfc_sli4_enable_msix()
13092 if (cpup->eq != LPFC_VECTOR_MAP_EMPTY) in lpfc_sli4_enable_msix()
13096 cpu); in lpfc_sli4_enable_msix()
13102 if (vectors != phba->cfg_irq_chann) { in lpfc_sli4_enable_msix()
13105 "MSI-X vectors, requested %d got %d\n", in lpfc_sli4_enable_msix()
13106 phba->cfg_irq_chann, vectors); in lpfc_sli4_enable_msix()
13107 if (phba->cfg_irq_chann > vectors) in lpfc_sli4_enable_msix()
13108 phba->cfg_irq_chann = vectors; in lpfc_sli4_enable_msix()
13115 for (--index; index >= 0; index--) { in lpfc_sli4_enable_msix()
13118 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_enable_msix()
13121 /* Unconfigure MSI-X capability structure */ in lpfc_sli4_enable_msix()
13122 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msix()
13129 * lpfc_sli4_enable_msi - Enable MSI interrupt mode to SLI-4 device
13133 * SLI-4 interface spec. The kernel function pci_alloc_irq_vectors() is
13139 * 0 - successful
13140 * other values - error
13146 unsigned int cpu; in lpfc_sli4_enable_msi() local
13149 rc = pci_alloc_irq_vectors(phba->pcidev, 1, 1, in lpfc_sli4_enable_msi()
13157 return rc ? rc : -1; in lpfc_sli4_enable_msi()
13160 rc = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_msi()
13163 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msi()
13170 rc = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_msi()
13172 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_enable_msi()
13173 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msi()
13178 eqhdl->irq = rc; in lpfc_sli4_enable_msi()
13180 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_msi()
13181 lpfc_assign_eq_map_info(phba, 0, LPFC_CPU_FIRST_IRQ, cpu); in lpfc_sli4_enable_msi()
13183 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_enable_msi()
13185 eqhdl->idx = index; in lpfc_sli4_enable_msi()
13192 * lpfc_sli4_enable_intr - Enable device interrupt to SLI-4 device
13194 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
13197 * interrupt handler(s) to interrupt vector(s) to device with SLI-4
13202 * MSI-X -> MSI -> IRQ.
13205 * Interrupt mode (2, 1, 0) - successful
13206 * LPFC_INTR_ERROR - error
13218 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli4_enable_intr()
13221 /* Indicate initialization to MSI-X mode */ in lpfc_sli4_enable_intr()
13222 phba->intr_type = MSIX; in lpfc_sli4_enable_intr()
13228 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli4_enable_intr()
13229 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
13233 phba->intr_type = MSI; in lpfc_sli4_enable_intr()
13238 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli4_enable_intr()
13239 if (phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
13240 retval = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_intr()
13244 unsigned int cpu; in lpfc_sli4_enable_intr() local
13247 phba->intr_type = INTx; in lpfc_sli4_enable_intr()
13251 retval = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_intr()
13253 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_enable_intr()
13259 eqhdl->irq = retval; in lpfc_sli4_enable_intr()
13261 cpu = cpumask_first(cpu_present_mask); in lpfc_sli4_enable_intr()
13263 cpu); in lpfc_sli4_enable_intr()
13264 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_enable_intr()
13266 eqhdl->idx = idx; in lpfc_sli4_enable_intr()
13274 * lpfc_sli4_disable_intr - Disable device interrupt to SLI-4 device
13279 * with SLI-4 interface spec. Depending on the interrupt mode, the driver
13286 if (phba->intr_type == MSIX) { in lpfc_sli4_disable_intr()
13290 /* Free up MSI-X multi-message vectors */ in lpfc_sli4_disable_intr()
13291 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_disable_intr()
13294 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_disable_intr()
13297 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_disable_intr()
13300 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_disable_intr()
13303 phba->intr_type = NONE; in lpfc_sli4_disable_intr()
13304 phba->sli.slistat.sli_intr = 0; in lpfc_sli4_disable_intr()
13308 * lpfc_unset_hba - Unset SLI3 hba device initialization
13312 * a device with SLI-3 interface spec.
13317 set_bit(FC_UNLOADING, &phba->pport->load_flag); in lpfc_unset_hba()
13319 kfree(phba->vpi_bmask); in lpfc_unset_hba()
13320 kfree(phba->vpi_ids); in lpfc_unset_hba()
13324 phba->pport->work_port_events = 0; in lpfc_unset_hba()
13336 * lpfc_sli4_xri_exchange_busy_wait - Wait for device XRI exchange busy
13356 int els_xri_cmpl = list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
13365 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_xri_exchange_busy_wait()
13369 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
13370 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
13371 io_xri_cmpl = list_empty(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
13378 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
13380 list_empty(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
13408 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
13409 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
13411 &qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
13418 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
13420 &phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
13423 list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
13429 * lpfc_sli4_hba_unset - Unset the fcoe hba
13443 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_hba_unset()
13446 hrtimer_cancel(&phba->cmf_stats_timer); in lpfc_sli4_hba_unset()
13447 hrtimer_cancel(&phba->cmf_timer); in lpfc_sli4_hba_unset()
13449 if (phba->pport) in lpfc_sli4_hba_unset()
13450 phba->sli4_hba.intr_enable = 0; in lpfc_sli4_hba_unset()
13458 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13459 phba->sli.sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_hba_unset()
13460 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13462 while (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
13468 if (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
13469 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13470 mboxq = phba->sli.mbox_active; in lpfc_sli4_hba_unset()
13471 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_hba_unset()
13473 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_hba_unset()
13474 phba->sli.mbox_active = NULL; in lpfc_sli4_hba_unset()
13475 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13481 if (!pci_channel_offline(phba->pcidev)) in lpfc_sli4_hba_unset()
13485 /* per-phba callback de-registration for hotplug event */ in lpfc_sli4_hba_unset()
13486 if (phba->pport) in lpfc_sli4_hba_unset()
13492 /* Disable SR-IOV if enabled */ in lpfc_sli4_hba_unset()
13493 if (phba->cfg_sriov_nr_virtfn) in lpfc_sli4_hba_unset()
13497 kthread_stop(phba->worker_thread); in lpfc_sli4_hba_unset()
13511 if (phba->ras_fwlog.ras_enabled) in lpfc_sli4_hba_unset()
13515 if (phba->pport) in lpfc_sli4_hba_unset()
13516 phba->pport->work_port_events = 0; in lpfc_sli4_hba_unset()
13577 "6235 INIT Congestion Buffer %p\n", phba->cgn_i); in lpfc_init_congestion_buf()
13579 if (!phba->cgn_i) in lpfc_init_congestion_buf()
13581 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_init_congestion_buf()
13583 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_init_congestion_buf()
13584 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_init_congestion_buf()
13585 atomic_set(&phba->cgn_sync_alarm_cnt, 0); in lpfc_init_congestion_buf()
13586 atomic_set(&phba->cgn_sync_warn_cnt, 0); in lpfc_init_congestion_buf()
13588 atomic_set(&phba->cgn_driver_evt_cnt, 0); in lpfc_init_congestion_buf()
13589 atomic_set(&phba->cgn_latency_evt_cnt, 0); in lpfc_init_congestion_buf()
13590 atomic64_set(&phba->cgn_latency_evt, 0); in lpfc_init_congestion_buf()
13591 phba->cgn_evt_minute = 0; in lpfc_init_congestion_buf()
13594 cp->cgn_info_size = cpu_to_le16(LPFC_CGN_INFO_SZ); in lpfc_init_congestion_buf()
13595 cp->cgn_info_version = LPFC_CGN_INFO_V4; in lpfc_init_congestion_buf()
13598 cp->cgn_info_mode = phba->cgn_p.cgn_param_mode; in lpfc_init_congestion_buf()
13599 cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0; in lpfc_init_congestion_buf()
13600 cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1; in lpfc_init_congestion_buf()
13601 cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2; in lpfc_init_congestion_buf()
13603 lpfc_cgn_update_tstamp(phba, &cp->base_time); in lpfc_init_congestion_buf()
13606 if (phba->pport) { in lpfc_init_congestion_buf()
13607 size = (uint16_t)(phba->pport->cfg_lun_queue_depth); in lpfc_init_congestion_buf()
13608 cp->cgn_lunq = cpu_to_le16(size); in lpfc_init_congestion_buf()
13613 cp->cgn_warn_freq = cpu_to_le16(LPFC_FPIN_INIT_FREQ); in lpfc_init_congestion_buf()
13614 cp->cgn_alarm_freq = cpu_to_le16(LPFC_FPIN_INIT_FREQ); in lpfc_init_congestion_buf()
13616 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_init_congestion_buf()
13618 phba->cgn_evt_timestamp = jiffies + in lpfc_init_congestion_buf()
13629 "6236 INIT Congestion Stat %p\n", phba->cgn_i); in lpfc_init_congestion_stat()
13631 if (!phba->cgn_i) in lpfc_init_congestion_stat()
13634 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_init_congestion_stat()
13635 memset(&cp->cgn_stat, 0, sizeof(cp->cgn_stat)); in lpfc_init_congestion_stat()
13637 lpfc_cgn_update_tstamp(phba, &cp->stat_start); in lpfc_init_congestion_stat()
13639 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_init_congestion_stat()
13643 * __lpfc_reg_congestion_buf - register congestion info buffer with HBA
13656 if (!phba->cgn_i) in __lpfc_reg_congestion_buf()
13657 return -ENXIO; in __lpfc_reg_congestion_buf()
13659 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in __lpfc_reg_congestion_buf()
13664 phba->pport->port_state, reg); in __lpfc_reg_congestion_buf()
13665 return -ENOMEM; in __lpfc_reg_congestion_buf()
13668 length = (sizeof(struct lpfc_mbx_reg_congestion_buf) - in __lpfc_reg_congestion_buf()
13673 reg_congestion_buf = &mboxq->u.mqe.un.reg_congestion_buf; in __lpfc_reg_congestion_buf()
13679 reg_congestion_buf->length = sizeof(struct lpfc_cgn_info); in __lpfc_reg_congestion_buf()
13680 reg_congestion_buf->addr_lo = in __lpfc_reg_congestion_buf()
13681 putPaddrLow(phba->cgn_i->phys); in __lpfc_reg_congestion_buf()
13682 reg_congestion_buf->addr_hi = in __lpfc_reg_congestion_buf()
13683 putPaddrHigh(phba->cgn_i->phys); in __lpfc_reg_congestion_buf()
13687 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in __lpfc_reg_congestion_buf()
13688 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in __lpfc_reg_congestion_buf()
13690 &shdr->response); in __lpfc_reg_congestion_buf()
13691 mempool_free(mboxq, phba->mbox_mem_pool); in __lpfc_reg_congestion_buf()
13698 return -ENXIO; in __lpfc_reg_congestion_buf()
13717 * lpfc_get_sli4_parameters - Get the SLI4 Config PARAMETERS.
13724 * This function may be be called from any context that can block-wait
13732 struct lpfc_mqe *mqe = &mboxq->u.mqe; in lpfc_get_sli4_parameters()
13744 phba->sli4_hba.rpi_hdrs_in_use = 1; in lpfc_get_sli4_parameters()
13747 length = (sizeof(struct lpfc_mbx_get_sli4_parameters) - in lpfc_get_sli4_parameters()
13752 if (!phba->sli4_hba.intr_enable) in lpfc_get_sli4_parameters()
13760 sli4_params = &phba->sli4_hba.pc_sli4_params; in lpfc_get_sli4_parameters()
13761 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters; in lpfc_get_sli4_parameters()
13762 sli4_params->if_type = bf_get(cfg_if_type, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13763 sli4_params->sli_rev = bf_get(cfg_sli_rev, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13764 sli4_params->sli_family = bf_get(cfg_sli_family, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13765 sli4_params->featurelevel_1 = bf_get(cfg_sli_hint_1, in lpfc_get_sli4_parameters()
13767 sli4_params->featurelevel_2 = bf_get(cfg_sli_hint_2, in lpfc_get_sli4_parameters()
13770 phba->sli3_options |= LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
13772 phba->sli3_options &= ~LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
13773 sli4_params->sge_supp_len = mbx_sli4_parameters->sge_supp_len; in lpfc_get_sli4_parameters()
13774 sli4_params->loopbk_scope = bf_get(cfg_loopbk_scope, in lpfc_get_sli4_parameters()
13776 sli4_params->oas_supported = bf_get(cfg_oas, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13777 sli4_params->cqv = bf_get(cfg_cqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13778 sli4_params->mqv = bf_get(cfg_mqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13779 sli4_params->wqv = bf_get(cfg_wqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13780 sli4_params->rqv = bf_get(cfg_rqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13781 sli4_params->eqav = bf_get(cfg_eqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13782 sli4_params->cqav = bf_get(cfg_cqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13783 sli4_params->wqsize = bf_get(cfg_wqsize, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13784 sli4_params->bv1s = bf_get(cfg_bv1s, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13785 sli4_params->pls = bf_get(cfg_pvl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13786 sli4_params->sgl_pages_max = bf_get(cfg_sgl_page_cnt, in lpfc_get_sli4_parameters()
13788 sli4_params->wqpcnt = bf_get(cfg_wqpcnt, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13789 sli4_params->sgl_pp_align = bf_get(cfg_sgl_pp_align, in lpfc_get_sli4_parameters()
13791 phba->sli4_hba.extents_in_use = bf_get(cfg_ext, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13792 phba->sli4_hba.rpi_hdrs_in_use = bf_get(cfg_hdrr, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13793 sli4_params->mi_cap = bf_get(cfg_mi_ver, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13795 /* Check for Extended Pre-Registered SGL support */ in lpfc_get_sli4_parameters()
13796 phba->cfg_xpsgl = bf_get(cfg_xpsgl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13804 sli4_params->nvme = 1; in lpfc_get_sli4_parameters()
13807 if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP) { in lpfc_get_sli4_parameters()
13811 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
13816 sli4_params->nvme = 0; in lpfc_get_sli4_parameters()
13817 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_get_sli4_parameters()
13823 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
13825 phba->nvmet_support = 0; in lpfc_get_sli4_parameters()
13826 phba->cfg_nvmet_mrq = 0; in lpfc_get_sli4_parameters()
13827 phba->cfg_nvme_seg_cnt = 0; in lpfc_get_sli4_parameters()
13830 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_get_sli4_parameters()
13831 return -ENODEV; in lpfc_get_sli4_parameters()
13832 phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; in lpfc_get_sli4_parameters()
13839 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_get_sli4_parameters()
13840 phba->cfg_sg_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_get_sli4_parameters()
13844 phba->cfg_enable_pbde = 1; in lpfc_get_sli4_parameters()
13846 phba->cfg_enable_pbde = 0; in lpfc_get_sli4_parameters()
13851 * In SLI4-Parameters Descriptor: in lpfc_get_sli4_parameters()
13856 if (phba->cfg_suppress_rsp && bf_get(cfg_xib, mbx_sli4_parameters) && in lpfc_get_sli4_parameters()
13858 phba->sli.sli_flag |= LPFC_SLI_SUPPRESS_RSP; in lpfc_get_sli4_parameters()
13860 phba->cfg_suppress_rsp = 0; in lpfc_get_sli4_parameters()
13863 phba->sli.sli_flag |= LPFC_SLI_USE_EQDR; in lpfc_get_sli4_parameters()
13866 if (sli4_params->sge_supp_len > LPFC_MAX_SGE_SIZE) in lpfc_get_sli4_parameters()
13867 sli4_params->sge_supp_len = LPFC_MAX_SGE_SIZE; in lpfc_get_sli4_parameters()
13869 dma_set_max_seg_size(&phba->pcidev->dev, sli4_params->sge_supp_len); in lpfc_get_sli4_parameters()
13874 * to use this option, 128-byte WQEs must be used. in lpfc_get_sli4_parameters()
13877 phba->fcp_embed_io = 1; in lpfc_get_sli4_parameters()
13879 phba->fcp_embed_io = 0; in lpfc_get_sli4_parameters()
13884 phba->cfg_enable_pbde, in lpfc_get_sli4_parameters()
13885 phba->fcp_embed_io, sli4_params->nvme, in lpfc_get_sli4_parameters()
13886 phba->cfg_nvme_embed_cmd, phba->cfg_suppress_rsp); in lpfc_get_sli4_parameters()
13888 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
13890 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
13897 (sli4_params->wqsize & LPFC_WQ_SZ128_SUPPORT)) in lpfc_get_sli4_parameters()
13898 phba->enab_exp_wqcq_pages = 1; in lpfc_get_sli4_parameters()
13900 phba->enab_exp_wqcq_pages = 0; in lpfc_get_sli4_parameters()
13905 phba->mds_diags_support = 1; in lpfc_get_sli4_parameters()
13907 phba->mds_diags_support = 0; in lpfc_get_sli4_parameters()
13913 phba->nsler = 1; in lpfc_get_sli4_parameters()
13915 phba->nsler = 0; in lpfc_get_sli4_parameters()
13921 * lpfc_pci_probe_one_s3 - PCI probe func to reg SLI-3 device to PCI subsystem.
13925 * This routine is to be called to attach a device with SLI-3 interface spec
13926 * to the PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
13927 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
13934 * 0 - driver can claim the device
13935 * negative value - driver can not claim the device
13949 return -ENOMEM; in lpfc_pci_probe_one_s3()
13956 /* Set up SLI API function jump table for PCI-device group-0 HBAs */ in lpfc_pci_probe_one_s3()
13961 /* Set up SLI-3 specific device PCI memory space */ in lpfc_pci_probe_one_s3()
13969 /* Set up SLI-3 specific device driver resources */ in lpfc_pci_probe_one_s3()
13995 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s3()
14006 vport = phba->pport; in lpfc_pci_probe_one_s3()
14016 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s3()
14025 error = -ENODEV; in lpfc_pci_probe_one_s3()
14028 /* SLI-3 HBA setup */ in lpfc_pci_probe_one_s3()
14032 error = -ENODEV; in lpfc_pci_probe_one_s3()
14040 phba->sli.slistat.sli_intr > LPFC_MSIX_VECTORS) { in lpfc_pci_probe_one_s3()
14042 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s3()
14053 cfg_mode = --intr_mode; in lpfc_pci_probe_one_s3()
14089 * lpfc_pci_remove_one_s3 - PCI func to unreg SLI-3 device from PCI subsystem.
14092 * This routine is to be called to disattach a device with SLI-3 interface
14093 * spec from PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
14101 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s3()
14103 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s3()
14106 set_bit(FC_UNLOADING, &vport->load_flag); in lpfc_pci_remove_one_s3()
14113 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s3()
14114 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s3()
14116 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s3()
14136 kthread_stop(phba->worker_thread); in lpfc_pci_remove_one_s3()
14140 kfree(phba->vpi_bmask); in lpfc_pci_remove_one_s3()
14141 kfree(phba->vpi_ids); in lpfc_pci_remove_one_s3()
14144 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
14145 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s3()
14146 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
14150 /* Disable SR-IOV if enabled */ in lpfc_pci_remove_one_s3()
14151 if (phba->cfg_sriov_nr_virtfn) in lpfc_pci_remove_one_s3()
14168 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_pci_remove_one_s3()
14169 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_pci_remove_one_s3()
14172 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_pci_remove_one_s3()
14173 phba->slim2p.virt, phba->slim2p.phys); in lpfc_pci_remove_one_s3()
14176 iounmap(phba->ctrl_regs_memmap_p); in lpfc_pci_remove_one_s3()
14177 iounmap(phba->slim_memmap_p); in lpfc_pci_remove_one_s3()
14186 * lpfc_pci_suspend_one_s3 - PCI func to suspend SLI-3 device for power mgmnt
14190 * system Power Management (PM) to device with SLI-3 interface spec. When
14194 * minimum PM requirements to a power-aware driver's PM support for the
14195 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
14202 * 0 - driver suspended the device
14209 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s3()
14217 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s3()
14226 * lpfc_pci_resume_one_s3 - PCI func to resume SLI-3 device for power mgmnt
14230 * system Power Management (PM) to device with SLI-3 interface spec. When PM
14233 * driver implements the minimum PM requirements to a power-aware driver's
14234 * PM for suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE,
14241 * 0 - driver suspended the device
14248 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s3()
14256 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s3()
14257 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s3()
14258 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s3()
14259 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s3()
14271 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
14275 return -EIO; in lpfc_pci_resume_one_s3()
14277 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s3()
14284 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
14290 * lpfc_sli_prep_dev_for_recover - Prepare SLI3 device for pci slot recover
14304 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli_prep_dev_for_recover()
14310 * lpfc_sli_prep_dev_for_reset - Prepare SLI3 device for pci slot reset
14337 pci_disable_device(phba->pcidev); in lpfc_sli_prep_dev_for_reset()
14341 * lpfc_sli_prep_dev_for_perm_failure - Prepare SLI3 dev for pci slot disable
14365 * lpfc_io_error_detected_s3 - Method for handling SLI-3 device PCI I/O error
14370 * device with SLI-3 interface spec. This function is called by the PCI
14378 * PCI_ERS_RESULT_CAN_RECOVER - can be recovered with reset_link
14379 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
14380 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
14386 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s3()
14390 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s3()
14411 * lpfc_io_slot_reset_s3 - Method for restarting PCI SLI-3 device from scratch.
14415 * device with SLI-3 interface spec. This is called after PCI bus has been
14416 * reset to restart the PCI card from scratch, as if from a cold-boot.
14425 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
14426 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
14432 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s3()
14433 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s3()
14436 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s3()
14438 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s3()
14451 if (pdev->is_busmaster) in lpfc_io_slot_reset_s3()
14454 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
14455 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s3()
14456 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
14459 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
14462 "0427 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s3()
14466 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s3()
14474 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
14480 * lpfc_io_resume_s3 - Method for resuming PCI I/O operation on SLI-3 device.
14484 * with SLI-3 interface spec. It is called when kernel error recovery tells
14493 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s3()
14495 /* Bring device online, it will be no-op for non-fatal error resume */ in lpfc_io_resume_s3()
14500 * lpfc_sli4_get_els_iocb_cnt - Calculate the # of ELS IOCBs to reserve
14508 int max_xri = phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_get_els_iocb_cnt()
14510 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli4_get_els_iocb_cnt()
14530 * lpfc_sli4_get_iocb_cnt - Calculate the # of total IOCBs to reserve
14540 if (phba->nvmet_support) in lpfc_sli4_get_iocb_cnt()
14554 sli_family = bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf); in lpfc_log_write_firmware_error()
14572 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
14573 fsize, fw->size); in lpfc_log_write_firmware_error()
14574 rc = -EINVAL; in lpfc_log_write_firmware_error()
14581 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
14582 fsize, fw->size); in lpfc_log_write_firmware_error()
14583 rc = -EACCES; in lpfc_log_write_firmware_error()
14589 offset, phba->pcidev->device, magic_number, in lpfc_log_write_firmware_error()
14590 ftype, fid, fsize, fw->size); in lpfc_log_write_firmware_error()
14591 rc = -EIO; in lpfc_log_write_firmware_error()
14597 * lpfc_write_firmware - attempt to write a firmware image to the port
14614 /* It can be null in no-wait mode, sanity check */ in lpfc_write_firmware()
14616 rc = -ENXIO; in lpfc_write_firmware()
14619 image = (struct lpfc_grp_hdr *)fw->data; in lpfc_write_firmware()
14621 magic_number = be32_to_cpu(image->magic_number); in lpfc_write_firmware()
14624 fsize = be32_to_cpu(image->size); in lpfc_write_firmware()
14628 if (strncmp(fwrev, image->revision, strnlen(image->revision, 16))) { in lpfc_write_firmware()
14632 fwrev, image->revision); in lpfc_write_firmware()
14637 rc = -ENOMEM; in lpfc_write_firmware()
14640 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_write_firmware()
14642 &dmabuf->phys, in lpfc_write_firmware()
14644 if (!dmabuf->virt) { in lpfc_write_firmware()
14646 rc = -ENOMEM; in lpfc_write_firmware()
14649 list_add_tail(&dmabuf->list, &dma_buffer_list); in lpfc_write_firmware()
14651 while (offset < fw->size) { in lpfc_write_firmware()
14654 if (temp_offset + SLI4_PAGE_SIZE > fw->size) { in lpfc_write_firmware()
14655 memcpy(dmabuf->virt, in lpfc_write_firmware()
14656 fw->data + temp_offset, in lpfc_write_firmware()
14657 fw->size - temp_offset); in lpfc_write_firmware()
14658 temp_offset = fw->size; in lpfc_write_firmware()
14661 memcpy(dmabuf->virt, fw->data + temp_offset, in lpfc_write_firmware()
14666 (fw->size - offset), &offset); in lpfc_write_firmware()
14682 fwrev, image->revision); in lpfc_write_firmware()
14686 list_del(&dmabuf->list); in lpfc_write_firmware()
14687 dma_free_coherent(&phba->pcidev->dev, SLI4_PAGE_SIZE, in lpfc_write_firmware()
14688 dmabuf->virt, dmabuf->phys); in lpfc_write_firmware()
14702 * lpfc_sli4_request_firmware_update - Request linux generic firmware upgrade
14717 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_request_firmware_update()
14719 return -EPERM; in lpfc_sli4_request_firmware_update()
14721 scnprintf(file_name, sizeof(file_name), "%s.grp", phba->ModelName); in lpfc_sli4_request_firmware_update()
14725 file_name, &phba->pcidev->dev, in lpfc_sli4_request_firmware_update()
14729 ret = request_firmware(&fw, file_name, &phba->pcidev->dev); in lpfc_sli4_request_firmware_update()
14733 ret = -EINVAL; in lpfc_sli4_request_firmware_update()
14740 * lpfc_pci_probe_one_s4 - PCI probe func to reg SLI-4 device to PCI subsys
14745 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
14746 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
14754 * 0 - driver can claim the device
14755 * negative value - driver can not claim the device
14769 return -ENOMEM; in lpfc_pci_probe_one_s4()
14771 INIT_LIST_HEAD(&phba->poll_list); in lpfc_pci_probe_one_s4()
14778 /* Set up SLI API function jump table for PCI-device group-1 HBAs */ in lpfc_pci_probe_one_s4()
14783 /* Set up SLI-4 specific device PCI memory space */ in lpfc_pci_probe_one_s4()
14791 /* Set up SLI-4 Specific device driver resources */ in lpfc_pci_probe_one_s4()
14799 spin_lock_init(&phba->rrq_list_lock); in lpfc_pci_probe_one_s4()
14800 INIT_LIST_HEAD(&phba->active_rrq_list); in lpfc_pci_probe_one_s4()
14801 INIT_LIST_HEAD(&phba->fcf.fcf_pri_list); in lpfc_pci_probe_one_s4()
14812 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s4()
14815 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s4()
14818 phba->pport = NULL; in lpfc_pci_probe_one_s4()
14832 error = -ENODEV; in lpfc_pci_probe_one_s4()
14835 /* Default to single EQ for non-MSI-X */ in lpfc_pci_probe_one_s4()
14836 if (phba->intr_type != MSIX) { in lpfc_pci_probe_one_s4()
14837 phba->cfg_irq_chann = 1; in lpfc_pci_probe_one_s4()
14838 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
14839 if (phba->nvmet_support) in lpfc_pci_probe_one_s4()
14840 phba->cfg_nvmet_mrq = 1; in lpfc_pci_probe_one_s4()
14843 lpfc_cpu_affinity_check(phba, phba->cfg_irq_chann); in lpfc_pci_probe_one_s4()
14852 vport = phba->pport; in lpfc_pci_probe_one_s4()
14863 /* Set up SLI-4 HBA */ in lpfc_pci_probe_one_s4()
14867 error = -ENODEV; in lpfc_pci_probe_one_s4()
14872 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s4()
14881 if (phba->nvmet_support == 0) { in lpfc_pci_probe_one_s4()
14882 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
14899 if (phba->cfg_request_firmware_upgrade) in lpfc_pci_probe_one_s4()
14905 timer_setup(&phba->cpuhp_poll_timer, lpfc_sli4_poll_hbtimer, 0); in lpfc_pci_probe_one_s4()
14906 cpuhp_state_add_instance_nocalls(lpfc_cpuhp_state, &phba->cpuhp); in lpfc_pci_probe_one_s4()
14932 * lpfc_pci_remove_one_s4 - PCI func to unreg SLI-4 device from PCI subsystem
14936 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
14944 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s4()
14946 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s4()
14950 set_bit(FC_UNLOADING, &vport->load_flag); in lpfc_pci_remove_one_s4()
14951 if (phba->cgn_i) in lpfc_pci_remove_one_s4()
14959 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s4()
14960 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s4()
14962 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s4()
14977 /* De-allocate multi-XRI pools */ in lpfc_pci_remove_one_s4()
14978 if (phba->cfg_xri_rebalancing) in lpfc_pci_remove_one_s4()
14989 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
14990 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s4()
14991 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
15017 * lpfc_pci_suspend_one_s4 - PCI func to suspend SLI-4 device for power mgmnt
15021 * Power Management (PM) to device with SLI-4 interface spec. When PM invokes
15025 * requirements to a power-aware driver's PM support for suspend/resume -- all
15033 * 0 - driver suspended the device
15040 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s4()
15048 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s4()
15058 * lpfc_pci_resume_one_s4 - PCI func to resume SLI-4 device for power mgmnt
15062 * Power Management (PM) to device with SLI-4 interface spac. When PM invokes
15065 * implements the minimum PM requirements to a power-aware driver's PM for
15066 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
15073 * 0 - driver suspended the device
15080 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s4()
15088 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s4()
15089 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s4()
15090 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s4()
15091 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s4()
15099 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
15103 return -EIO; in lpfc_pci_resume_one_s4()
15105 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s4()
15112 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
15118 * lpfc_sli4_prep_dev_for_recover - Prepare SLI4 device for pci slot recover
15131 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli4_prep_dev_for_recover()
15137 * lpfc_sli4_prep_dev_for_reset - Prepare SLI4 device for pci slot reset
15147 int offline = pci_channel_offline(phba->pcidev); in lpfc_sli4_prep_dev_for_reset()
15169 pci_disable_device(phba->pcidev); in lpfc_sli4_prep_dev_for_reset()
15173 * lpfc_sli4_prep_dev_for_perm_failure - Prepare SLI4 dev for pci slot disable
15197 * lpfc_io_error_detected_s4 - Method for handling PCI I/O error to SLI-4 device
15202 * with SLI-4 interface spec. This function is called by the PCI subsystem
15209 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
15210 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15216 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s4()
15221 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s4()
15225 hba_pci_err = test_and_set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15235 set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15240 hba_pci_err = test_and_set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15252 * lpfc_io_slot_reset_s4 - Method for restart PCI SLI-4 device from scratch
15256 * with SLI-4 interface spec. It is called after PCI bus has been reset to
15257 * restart the PCI card from scratch, as if from a cold-boot. During the
15266 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
15267 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15273 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s4()
15274 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s4()
15278 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s4()
15280 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s4()
15287 hba_pci_err = test_and_clear_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_slot_reset_s4()
15289 dev_info(&pdev->dev, in lpfc_io_slot_reset_s4()
15297 if (pdev->is_busmaster) in lpfc_io_slot_reset_s4()
15300 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
15301 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s4()
15302 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
15307 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
15310 "2824 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s4()
15314 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s4()
15315 lpfc_cpu_affinity_check(phba, phba->cfg_irq_chann); in lpfc_io_slot_reset_s4()
15318 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
15324 * lpfc_io_resume_s4 - Method for resuming PCI I/O operation to SLI-4 device
15328 * with SLI-4 interface spec. It is called when kernel error recovery tells
15337 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s4()
15345 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) { in lpfc_io_resume_s4()
15354 * lpfc_pci_probe_one - lpfc PCI probe func to reg dev to PCI subsystem
15360 * at PCI device-specific information of the device and driver to see if the
15363 * the action to the proper SLI-3 or SLI-4 device probing routine, which will
15368 * 0 - driver can claim the device
15369 * negative value - driver can not claim the device
15378 return -ENODEV; in lpfc_pci_probe_one()
15390 * lpfc_pci_remove_one - lpfc PCI func to unreg dev from PCI subsystem
15395 * This routine dispatches the action to the proper SLI-3 or SLI-4 device
15403 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_remove_one()
15405 switch (phba->pci_dev_grp) { in lpfc_pci_remove_one()
15415 phba->pci_dev_grp); in lpfc_pci_remove_one()
15422 * lpfc_pci_suspend_one - lpfc PCI func to suspend dev for power management
15427 * the action to the proper SLI-3 or SLI-4 device suspend routine, which will
15431 * 0 - driver suspended the device
15438 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one()
15439 int rc = -ENODEV; in lpfc_pci_suspend_one()
15441 switch (phba->pci_dev_grp) { in lpfc_pci_suspend_one()
15451 phba->pci_dev_grp); in lpfc_pci_suspend_one()
15458 * lpfc_pci_resume_one - lpfc PCI func to resume dev for power management
15463 * the action to the proper SLI-3 or SLI-4 device resume routine, which will
15467 * 0 - driver suspended the device
15474 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one()
15475 int rc = -ENODEV; in lpfc_pci_resume_one()
15477 switch (phba->pci_dev_grp) { in lpfc_pci_resume_one()
15487 phba->pci_dev_grp); in lpfc_pci_resume_one()
15494 * lpfc_io_error_detected - lpfc method for handling PCI I/O error
15501 * the action to the proper SLI-3 or SLI-4 device error detected handling
15505 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
15506 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15512 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected()
15515 if (phba->link_state == LPFC_HBA_ERROR && in lpfc_io_error_detected()
15516 test_bit(HBA_IOQ_FLUSH, &phba->hba_flag)) in lpfc_io_error_detected()
15519 switch (phba->pci_dev_grp) { in lpfc_io_error_detected()
15529 phba->pci_dev_grp); in lpfc_io_error_detected()
15536 * lpfc_io_slot_reset - lpfc method for restart PCI dev from scratch
15541 * from scratch, as if from a cold-boot. When this routine is invoked, it
15542 * dispatches the action to the proper SLI-3 or SLI-4 device reset handling
15546 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
15547 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15553 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset()
15556 switch (phba->pci_dev_grp) { in lpfc_io_slot_reset()
15566 phba->pci_dev_grp); in lpfc_io_slot_reset()
15573 * lpfc_io_resume - lpfc method for resuming PCI I/O operation
15579 * this routine is invoked, it dispatches the action to the proper SLI-3
15580 * or SLI-4 device io_resume routine, which will resume the device operation.
15586 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume()
15588 switch (phba->pci_dev_grp) { in lpfc_io_resume()
15598 phba->pci_dev_grp); in lpfc_io_resume()
15605 * lpfc_sli4_oas_verify - Verify OAS is supported by this adapter
15618 if (!phba->cfg_EnableXLane) in lpfc_sli4_oas_verify()
15621 if (phba->sli4_hba.pc_sli4_params.oas_supported) { in lpfc_sli4_oas_verify()
15622 phba->cfg_fof = 1; in lpfc_sli4_oas_verify()
15624 phba->cfg_fof = 0; in lpfc_sli4_oas_verify()
15625 mempool_destroy(phba->device_data_mem_pool); in lpfc_sli4_oas_verify()
15626 phba->device_data_mem_pool = NULL; in lpfc_sli4_oas_verify()
15633 * lpfc_sli4_ras_init - Verify RAS-FW log is supported by this adapter
15643 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_ras_init()
15645 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_sli4_ras_init()
15647 phba->ras_fwlog.ras_hwsupport = true; in lpfc_sli4_ras_init()
15648 if (phba->cfg_ras_fwlog_func == PCI_FUNC(phba->pcidev->devfn) && in lpfc_sli4_ras_init()
15649 phba->cfg_ras_fwlog_buffsize) in lpfc_sli4_ras_init()
15650 phba->ras_fwlog.ras_enabled = true; in lpfc_sli4_ras_init()
15652 phba->ras_fwlog.ras_enabled = false; in lpfc_sli4_ras_init()
15654 phba->ras_fwlog.ras_hwsupport = false; in lpfc_sli4_ras_init()
15692 * lpfc_init - lpfc module initialization routine
15699 * 0 - successful
15700 * -ENOMEM - FC attach transport failed
15701 * all others - failed
15716 error = -ENOMEM; in lpfc_init()
15770 if (atomic_cmpxchg(&phba->dbg_log_dmping, 0, 1) != 0) in lpfc_dmp_dbg()
15773 start_idx = (unsigned int)atomic_read(&phba->dbg_log_idx) % DBG_LOG_SZ; in lpfc_dmp_dbg()
15774 dbg_cnt = (unsigned int)atomic_read(&phba->dbg_log_cnt); in lpfc_dmp_dbg()
15780 temp_idx -= 1; in lpfc_dmp_dbg()
15782 if ((start_idx + dbg_cnt) > (DBG_LOG_SZ - 1)) { in lpfc_dmp_dbg()
15786 start_idx = DBG_LOG_SZ - (dbg_cnt - start_idx); in lpfc_dmp_dbg()
15788 start_idx -= dbg_cnt; in lpfc_dmp_dbg()
15791 dev_info(&phba->pcidev->dev, "start %d end %d cnt %d\n", in lpfc_dmp_dbg()
15799 rem_nsec = do_div(phba->dbg_log[temp_idx].t_ns, NSEC_PER_SEC); in lpfc_dmp_dbg()
15800 dev_info(&phba->pcidev->dev, "%d: [%5lu.%06lu] %s", in lpfc_dmp_dbg()
15802 (unsigned long)phba->dbg_log[temp_idx].t_ns, in lpfc_dmp_dbg()
15804 phba->dbg_log[temp_idx].log); in lpfc_dmp_dbg()
15807 atomic_set(&phba->dbg_log_cnt, 0); in lpfc_dmp_dbg()
15808 atomic_set(&phba->dbg_log_dmping, 0); in lpfc_dmp_dbg()
15816 int dbg_dmping = atomic_read(&phba->dbg_log_dmping); in lpfc_dbg_print()
15824 dev_info(&phba->pcidev->dev, "%pV", &vaf); in lpfc_dbg_print()
15828 idx = (unsigned int)atomic_fetch_add(1, &phba->dbg_log_idx) % in lpfc_dbg_print()
15831 atomic_inc(&phba->dbg_log_cnt); in lpfc_dbg_print()
15833 vscnprintf(phba->dbg_log[idx].log, in lpfc_dbg_print()
15834 sizeof(phba->dbg_log[idx].log), fmt, args); in lpfc_dbg_print()
15837 phba->dbg_log[idx].t_ns = local_clock(); in lpfc_dbg_print()
15841 * lpfc_exit - lpfc module removal routine