Lines Matching +full:region +full:- +full:freeze +full:- +full:timeout +full:- +full:us
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>
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()
425 uint32_t status, timeout; in lpfc_config_port_post() local
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()
598 jiffies + secs_to_jiffies(timeout)); 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
1185 * this timer fires, a HBA timeout event shall be posted to the lpfc driver
1186 * work-port-events bitmap and the worker thread is notified. This timeout
1187 * event will be used by the worker thread to invoke the actual timeout
1189 * be performed in the timeout handler and the HBA timeout event bit shall
1201 /* Check for heart beat timeout conditions */ in lpfc_hb_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
1219 * this timer fires, a RRQ timeout event shall be posted to the lpfc driver
1220 * work-port-events bitmap and the worker thread is notified. This timeout
1221 * event will be used by the worker thread to invoke the actual timeout
1223 * be performed in the timeout handler and the RRQ timeout event bit shall
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
1250 * timeout timer to LPFC_HB_MBOX_TIMEOUT (current 30) seconds and marks
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()
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
1481 * If lpfc_enable_hba_heartbeat is set, the timeout routine will always
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
1501 * timeout window (LPFC_HB_MBOX_INTERVAL), this handler just simply resets
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()
1572 * If heart beat timeout called with HBA_HBEAT_INP set 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
1913 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_port_sta_fn_reset()
1935 spin_lock_irq(&phba->hbalock); in lpfc_sli4_port_sta_fn_reset()
1936 phba->sli.sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_sli4_port_sta_fn_reset()
1937 if (phba->sli.mbox_active) { in lpfc_sli4_port_sta_fn_reset()
1938 mboxq = phba->sli.mbox_active; in lpfc_sli4_port_sta_fn_reset()
1939 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_port_sta_fn_reset()
1941 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_port_sta_fn_reset()
1942 phba->sli.mbox_active = NULL; in lpfc_sli4_port_sta_fn_reset()
1944 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_port_sta_fn_reset()
1960 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_sli4_port_sta_fn_reset()
1964 return -EIO; in lpfc_sli4_port_sta_fn_reset()
1966 phba->intr_mode = intr_mode; in lpfc_sli4_port_sta_fn_reset()
1975 * lpfc_handle_eratt_s4 - The SLI4 HBA hardware error handler
1984 struct lpfc_vport *vport = phba->pport; in lpfc_handle_eratt_s4()
2000 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_eratt_s4()
2008 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_handle_eratt_s4()
2012 phba->sli4_hba.u.if_type0.UERRLOregaddr, in lpfc_handle_eratt_s4()
2015 phba->sli4_hba.u.if_type0.UEMASKLOregaddr, in lpfc_handle_eratt_s4()
2018 if (pci_rd_rc1 == -EIO && pci_rd_rc2 == -EIO) in lpfc_handle_eratt_s4()
2020 if (!test_bit(HBA_RECOVERABLE_UE, &phba->hba_flag)) { in lpfc_handle_eratt_s4()
2027 for (i = 0; i < phba->sli4_hba.ue_to_sr / 1000; i++) { in lpfc_handle_eratt_s4()
2028 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_handle_eratt_s4()
2050 if (!lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_handle_eratt_s4()
2069 phba->link_state = LPFC_HBA_ERROR; in lpfc_handle_eratt_s4()
2075 phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_handle_eratt_s4()
2078 if (pci_rd_rc1 == -EIO) { in lpfc_handle_eratt_s4()
2081 readl(phba->sli4_hba.u.if_type2.STATUSregaddr)); in lpfc_handle_eratt_s4()
2085 reg_err1 = readl(phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_handle_eratt_s4()
2086 reg_err2 = readl(phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_handle_eratt_s4()
2093 phba->sfp_alarm |= LPFC_TRANSGRESSION_HIGH_TEMPERATURE; in lpfc_handle_eratt_s4()
2098 shost = lpfc_shost_from_vport(phba->pport); in lpfc_handle_eratt_s4()
2105 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s4()
2106 phba->over_temp_state = HBA_OVER_TEMP; in lpfc_handle_eratt_s4()
2107 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s4()
2127 if (!phba->cfg_enable_hba_reset) in lpfc_handle_eratt_s4()
2163 * lpfc_handle_eratt - Wrapper func for handling hba error attention
2170 * 0 - success.
2171 * Any other value - error.
2176 (*phba->lpfc_handle_eratt)(phba); in lpfc_handle_eratt()
2180 * lpfc_handle_latt - The HBA link event handler
2189 struct lpfc_vport *vport = phba->pport; in lpfc_handle_latt()
2190 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_latt()
2195 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_handle_latt()
2204 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_handle_latt()
2210 psli->slistat.link_event++; in lpfc_handle_latt()
2211 lpfc_read_topology(phba, pmb, pmb->ctx_buf); in lpfc_handle_latt()
2212 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_handle_latt()
2213 pmb->vport = vport; in lpfc_handle_latt()
2215 phba->sli.sli3_ring[LPFC_ELS_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_handle_latt()
2223 spin_lock_irq(&phba->hbalock); in lpfc_handle_latt()
2224 writel(HA_LATT, phba->HAregaddr); in lpfc_handle_latt()
2225 readl(phba->HAregaddr); /* flush */ in lpfc_handle_latt()
2226 spin_unlock_irq(&phba->hbalock); in lpfc_handle_latt()
2231 phba->sli.sli3_ring[LPFC_ELS_RING].flag &= ~LPFC_STOP_IOCB_EVENT; in lpfc_handle_latt()
2235 spin_lock_irq(&phba->hbalock); in lpfc_handle_latt()
2236 psli->sli_flag |= LPFC_PROCESS_LA; in lpfc_handle_latt()
2237 control = readl(phba->HCregaddr); in lpfc_handle_latt()
2239 writel(control, phba->HCregaddr); in lpfc_handle_latt()
2240 readl(phba->HCregaddr); /* flush */ in lpfc_handle_latt()
2243 writel(HA_LATT, phba->HAregaddr); in lpfc_handle_latt()
2244 readl(phba->HAregaddr); /* flush */ in lpfc_handle_latt()
2245 spin_unlock_irq(&phba->hbalock); in lpfc_handle_latt()
2247 phba->link_state = LPFC_HBA_ERROR; in lpfc_handle_latt()
2267 length -= (3+i); in lpfc_fill_vpd()
2268 while (i--) { in lpfc_fill_vpd()
2269 phba->SerialNumber[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2273 phba->SerialNumber[j] = 0; in lpfc_fill_vpd()
2276 phba->vpd_flag |= VPD_MODEL_DESC; in lpfc_fill_vpd()
2281 length -= (3+i); in lpfc_fill_vpd()
2282 while (i--) { in lpfc_fill_vpd()
2283 phba->ModelDesc[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2287 phba->ModelDesc[j] = 0; in lpfc_fill_vpd()
2290 phba->vpd_flag |= VPD_MODEL_NAME; in lpfc_fill_vpd()
2295 length -= (3+i); in lpfc_fill_vpd()
2296 while (i--) { in lpfc_fill_vpd()
2297 phba->ModelName[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2301 phba->ModelName[j] = 0; in lpfc_fill_vpd()
2304 phba->vpd_flag |= VPD_PROGRAM_TYPE; in lpfc_fill_vpd()
2309 length -= (3+i); in lpfc_fill_vpd()
2310 while (i--) { in lpfc_fill_vpd()
2311 phba->ProgramType[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2315 phba->ProgramType[j] = 0; in lpfc_fill_vpd()
2318 phba->vpd_flag |= VPD_PORT; in lpfc_fill_vpd()
2323 length -= (3 + i); in lpfc_fill_vpd()
2324 while (i--) { in lpfc_fill_vpd()
2325 if ((phba->sli_rev == LPFC_SLI_REV4) && in lpfc_fill_vpd()
2326 (phba->sli4_hba.pport_name_sta == in lpfc_fill_vpd()
2331 phba->Port[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2335 if ((phba->sli_rev != LPFC_SLI_REV4) || in lpfc_fill_vpd()
2336 (phba->sli4_hba.pport_name_sta == in lpfc_fill_vpd()
2338 phba->Port[j] = 0; in lpfc_fill_vpd()
2345 length -= (3 + i); in lpfc_fill_vpd()
2351 * lpfc_parse_vpd - Parse VPD (Vital Product Data)
2361 * 0 - pointer to the VPD passed in is NULL
2362 * 1 - success
2381 while (!finished && (index < (len - 4))) { in lpfc_parse_vpd()
2400 if (Length > len - index) in lpfc_parse_vpd()
2401 Length = len - index; in lpfc_parse_vpd()
2419 * lpfc_get_atto_model_desc - Retrieve ATTO HBA device model name and description
2433 uint16_t sub_dev_id = phba->pcidev->subsystem_device; in lpfc_get_atto_model_desc()
2497 (tbolt) ? "ThunderLink FC " : "Celerity FC-", in lpfc_get_atto_model_desc()
2499 phba->Port); in lpfc_get_atto_model_desc()
2503 * lpfc_get_hba_model_desc - Retrieve HBA device model name and description
2518 uint16_t dev_id = phba->pcidev->device; in lpfc_get_hba_model_desc()
2532 if (phba->pcidev->vendor == PCI_VENDOR_ID_ATTO) { in lpfc_get_hba_model_desc()
2537 if (phba->lmt & LMT_64Gb) in lpfc_get_hba_model_desc()
2539 else if (phba->lmt & LMT_32Gb) in lpfc_get_hba_model_desc()
2541 else if (phba->lmt & LMT_16Gb) in lpfc_get_hba_model_desc()
2543 else if (phba->lmt & LMT_10Gb) in lpfc_get_hba_model_desc()
2545 else if (phba->lmt & LMT_8Gb) in lpfc_get_hba_model_desc()
2547 else if (phba->lmt & LMT_4Gb) in lpfc_get_hba_model_desc()
2549 else if (phba->lmt & LMT_2Gb) in lpfc_get_hba_model_desc()
2551 else if (phba->lmt & LMT_1Gb) in lpfc_get_hba_model_desc()
2556 vp = &phba->vpd; in lpfc_get_hba_model_desc()
2564 if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3) in lpfc_get_hba_model_desc()
2575 if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID) in lpfc_get_hba_model_desc()
2586 m = (typeof(m)){"LP9802", "PCI-X", in lpfc_get_hba_model_desc()
2590 m = (typeof(m)){"LP10000", "PCI-X", in lpfc_get_hba_model_desc()
2594 m = (typeof(m)){"LPX1000", "PCI-X", in lpfc_get_hba_model_desc()
2598 m = (typeof(m)){"LP982", "PCI-X", in lpfc_get_hba_model_desc()
2602 m = (typeof(m)){"LP1050", "PCI-X", in lpfc_get_hba_model_desc()
2606 m = (typeof(m)){"LP11000", "PCI-X2", in lpfc_get_hba_model_desc()
2610 m = (typeof(m)){"LP11000-SP", "PCI-X2", in lpfc_get_hba_model_desc()
2614 m = (typeof(m)){"LP11002-SP", "PCI-X2", in lpfc_get_hba_model_desc()
2622 m = (typeof(m)){"LPe1000-SP", "PCIe", in lpfc_get_hba_model_desc()
2626 m = (typeof(m)){"LPe1002-SP", "PCIe", in lpfc_get_hba_model_desc()
2630 m = (typeof(m)){"LP1150", "PCI-X2", in lpfc_get_hba_model_desc()
2634 m = (typeof(m)){"LP111", "PCI-X2", in lpfc_get_hba_model_desc()
2659 m = (typeof(m)){"LP101", "PCI-X", in lpfc_get_hba_model_desc()
2663 m = (typeof(m)){"LP10000-S", "PCI", in lpfc_get_hba_model_desc()
2667 m = (typeof(m)){"LP11000-S", "PCI-X2", in lpfc_get_hba_model_desc()
2671 m = (typeof(m)){"LPe11000-S", "PCIe", in lpfc_get_hba_model_desc()
2687 m = (typeof(m)){"LPe12002-SP", "PCIe", in lpfc_get_hba_model_desc()
2691 m = (typeof(m)){"LPe12000-SP", "PCIe", in lpfc_get_hba_model_desc()
2695 m = (typeof(m)){"LPe12000-S", "PCIe", in lpfc_get_hba_model_desc()
2707 m = (typeof(m)){"LPemv12002-S", "PCIe IOV", in lpfc_get_hba_model_desc()
2721 m = (typeof(m)){"LPSe12002-ML1-E", "PCIe", in lpfc_get_hba_model_desc()
2777 phba->Port); in lpfc_get_hba_model_desc()
2791 * lpfc_sli3_post_buffer - Post IOCB(s) with DMA buffer descriptor(s) to a IOCB ring
2809 cnt += pring->missbufcnt; in lpfc_sli3_post_buffer()
2816 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2819 icmd = &iocb->iocb; in lpfc_sli3_post_buffer()
2825 mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &mp1->phys); in lpfc_sli3_post_buffer()
2826 if (!mp1 || !mp1->virt) { in lpfc_sli3_post_buffer()
2829 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2833 INIT_LIST_HEAD(&mp1->list); in lpfc_sli3_post_buffer()
2838 mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI, in lpfc_sli3_post_buffer()
2839 &mp2->phys); in lpfc_sli3_post_buffer()
2840 if (!mp2 || !mp2->virt) { in lpfc_sli3_post_buffer()
2842 lpfc_mbuf_free(phba, mp1->virt, mp1->phys); in lpfc_sli3_post_buffer()
2845 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2849 INIT_LIST_HEAD(&mp2->list); in lpfc_sli3_post_buffer()
2854 icmd->un.cont64[0].addrHigh = putPaddrHigh(mp1->phys); in lpfc_sli3_post_buffer()
2855 icmd->un.cont64[0].addrLow = putPaddrLow(mp1->phys); in lpfc_sli3_post_buffer()
2856 icmd->un.cont64[0].tus.f.bdeSize = FCELSSIZE; in lpfc_sli3_post_buffer()
2857 icmd->ulpBdeCount = 1; in lpfc_sli3_post_buffer()
2858 cnt--; in lpfc_sli3_post_buffer()
2860 icmd->un.cont64[1].addrHigh = putPaddrHigh(mp2->phys); in lpfc_sli3_post_buffer()
2861 icmd->un.cont64[1].addrLow = putPaddrLow(mp2->phys); in lpfc_sli3_post_buffer()
2862 icmd->un.cont64[1].tus.f.bdeSize = FCELSSIZE; in lpfc_sli3_post_buffer()
2863 cnt--; in lpfc_sli3_post_buffer()
2864 icmd->ulpBdeCount = 2; in lpfc_sli3_post_buffer()
2867 icmd->ulpCommand = CMD_QUE_RING_BUF64_CN; in lpfc_sli3_post_buffer()
2868 icmd->ulpLe = 1; in lpfc_sli3_post_buffer()
2870 if (lpfc_sli_issue_iocb(phba, pring->ringno, iocb, 0) == in lpfc_sli3_post_buffer()
2872 lpfc_mbuf_free(phba, mp1->virt, mp1->phys); in lpfc_sli3_post_buffer()
2876 lpfc_mbuf_free(phba, mp2->virt, mp2->phys); in lpfc_sli3_post_buffer()
2881 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2888 pring->missbufcnt = 0; in lpfc_sli3_post_buffer()
2893 * lpfc_post_rcv_buf - Post the initial receive IOCB buffers to ELS ring
2901 * 0 - success (currently always success)
2906 struct lpfc_sli *psli = &phba->sli; in lpfc_post_rcv_buf()
2909 lpfc_sli3_post_buffer(phba, &psli->sli3_ring[LPFC_ELS_RING], LPFC_BUF_RING0); in lpfc_post_rcv_buf()
2910 /* Ring 2 - FCP no buffers needed */ in lpfc_post_rcv_buf()
2915 #define S(N,V) (((V)<<(N))|((V)>>(32-(N))))
2918 * lpfc_sha_init - Set up initial array of hash table entries
2935 * lpfc_sha_iterate - Iterate initial hash table with the working hash table
2954 HashWorkingPointer[t - 3] ^ HashWorkingPointer[t - in lpfc_sha_iterate()
2956 HashWorkingPointer[t - 14] ^ HashWorkingPointer[t - 16]); in lpfc_sha_iterate()
2992 * lpfc_challenge_key - Create challenge key based on WWPN of the HBA
3008 * lpfc_hba_init - Perform special handling for LC HBA initialization
3010 * @hbainit: pointer to an array of unsigned 32-bit integers.
3019 uint32_t *pwwnn = (uint32_t *) phba->wwnn; in lpfc_hba_init()
3029 lpfc_challenge_key(phba->RandomData + t, HashWorking + t); in lpfc_hba_init()
3037 * lpfc_cleanup - Performs vport cleanups before deleting a vport
3048 struct lpfc_hba *phba = vport->phba; in lpfc_cleanup()
3052 if (phba->link_state > LPFC_LINK_DOWN) in lpfc_cleanup()
3059 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { in lpfc_cleanup()
3060 if (ndlp->nlp_DID == Fabric_Cntl_DID && in lpfc_cleanup()
3061 ndlp->nlp_state == NLP_STE_UNUSED_NODE) { in lpfc_cleanup()
3069 if (ndlp->nlp_type & NLP_FABRIC && in lpfc_cleanup()
3070 ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) in lpfc_cleanup()
3074 if (!(ndlp->fc4_xpt_flags & (NVME_XPT_REGD|SCSI_XPT_REGD))) in lpfc_cleanup()
3091 if (test_bit(FC_UNLOADING, &vport->load_flag) && in lpfc_cleanup()
3092 pci_channel_offline(phba->pcidev)) in lpfc_cleanup()
3093 lpfc_sli_flush_io_rings(vport->phba); in lpfc_cleanup()
3099 while (!list_empty(&vport->fc_nodes)) { in lpfc_cleanup()
3105 &vport->fc_nodes, nlp_listp) { in lpfc_cleanup()
3106 lpfc_printf_vlog(ndlp->vport, KERN_ERR, in lpfc_cleanup()
3111 ndlp->nlp_DID, (void *)ndlp, in lpfc_cleanup()
3112 kref_read(&ndlp->kref), in lpfc_cleanup()
3113 ndlp->fc4_xpt_flags, in lpfc_cleanup()
3114 ndlp->nlp_flag); in lpfc_cleanup()
3126 * lpfc_stop_vport_timers - Stop all the timers associated with a vport
3136 timer_delete_sync(&vport->els_tmofunc); in lpfc_stop_vport_timers()
3137 timer_delete_sync(&vport->delayed_disc_tmo); in lpfc_stop_vport_timers()
3143 * __lpfc_sli4_stop_fcf_redisc_wait_timer - Stop FCF rediscovery wait timer
3153 phba->fcf.fcf_flag &= ~FCF_REDISC_PEND; in __lpfc_sli4_stop_fcf_redisc_wait_timer()
3156 timer_delete(&phba->fcf.redisc_wait); in __lpfc_sli4_stop_fcf_redisc_wait_timer()
3160 * lpfc_sli4_stop_fcf_redisc_wait_timer - Stop FCF rediscovery wait timer
3171 spin_lock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3172 if (!(phba->fcf.fcf_flag & FCF_REDISC_PEND)) { in lpfc_sli4_stop_fcf_redisc_wait_timer()
3174 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3179 phba->fcf.fcf_flag &= ~(FCF_DEAD_DISC | FCF_ACVL_DISC); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3180 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3184 * lpfc_cmf_stop - Stop CMF processing
3198 if (!phba->sli4_hba.pc_sli4_params.cmf) in lpfc_cmf_stop()
3205 hrtimer_cancel(&phba->cmf_stats_timer); in lpfc_cmf_stop()
3206 hrtimer_cancel(&phba->cmf_timer); in lpfc_cmf_stop()
3209 atomic_set(&phba->cmf_busy, 0); in lpfc_cmf_stop()
3211 cgs = per_cpu_ptr(phba->cmf_stat, cpu); in lpfc_cmf_stop()
3212 atomic64_set(&cgs->total_bytes, 0); in lpfc_cmf_stop()
3213 atomic64_set(&cgs->rcv_bytes, 0); in lpfc_cmf_stop()
3214 atomic_set(&cgs->rx_io_cnt, 0); in lpfc_cmf_stop()
3215 atomic64_set(&cgs->rx_latency, 0); in lpfc_cmf_stop()
3217 atomic_set(&phba->cmf_bw_wait, 0); in lpfc_cmf_stop()
3219 /* Resume any blocked IO - Queue unblock on workqueue */ in lpfc_cmf_stop()
3220 queue_work(phba->wq, &phba->unblock_request_work); in lpfc_cmf_stop()
3238 phba->cmf_interval_rate = LPFC_CMF_INTERVAL; in lpfc_cmf_signal_init()
3239 phba->cmf_max_line_rate = lpfc_get_max_line_rate(phba); in lpfc_cmf_signal_init()
3240 phba->cmf_link_byte_count = div_u64(phba->cmf_max_line_rate * in lpfc_cmf_signal_init()
3241 phba->cmf_interval_rate, 1000); in lpfc_cmf_signal_init()
3242 phba->cmf_max_bytes_per_interval = phba->cmf_link_byte_count; in lpfc_cmf_signal_init()
3249 * lpfc_cmf_start - Start CMF processing
3262 if (!phba->sli4_hba.pc_sli4_params.cmf || in lpfc_cmf_start()
3263 phba->cmf_active_mode == LPFC_CFG_OFF) in lpfc_cmf_start()
3269 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_cmf_start()
3270 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_cmf_start()
3271 atomic_set(&phba->cgn_sync_alarm_cnt, 0); in lpfc_cmf_start()
3272 atomic_set(&phba->cgn_sync_warn_cnt, 0); in lpfc_cmf_start()
3274 atomic_set(&phba->cmf_busy, 0); in lpfc_cmf_start()
3276 cgs = per_cpu_ptr(phba->cmf_stat, cpu); in lpfc_cmf_start()
3277 atomic64_set(&cgs->total_bytes, 0); in lpfc_cmf_start()
3278 atomic64_set(&cgs->rcv_bytes, 0); in lpfc_cmf_start()
3279 atomic_set(&cgs->rx_io_cnt, 0); in lpfc_cmf_start()
3280 atomic64_set(&cgs->rx_latency, 0); in lpfc_cmf_start()
3282 phba->cmf_latency.tv_sec = 0; in lpfc_cmf_start()
3283 phba->cmf_latency.tv_nsec = 0; in lpfc_cmf_start()
3290 phba->cmf_timer_cnt = 0; in lpfc_cmf_start()
3291 hrtimer_start(&phba->cmf_timer, in lpfc_cmf_start()
3294 hrtimer_start(&phba->cmf_stats_timer, in lpfc_cmf_start()
3298 ktime_get_real_ts64(&phba->cmf_latency); in lpfc_cmf_start()
3300 atomic_set(&phba->cmf_bw_wait, 0); in lpfc_cmf_start()
3301 atomic_set(&phba->cmf_stop_io, 0); in lpfc_cmf_start()
3305 * lpfc_stop_hba_timers - Stop all the timers associated with an HBA
3314 if (phba->pport) in lpfc_stop_hba_timers()
3315 lpfc_stop_vport_timers(phba->pport); in lpfc_stop_hba_timers()
3316 cancel_delayed_work_sync(&phba->eq_delay_work); in lpfc_stop_hba_timers()
3317 cancel_delayed_work_sync(&phba->idle_stat_delay_work); in lpfc_stop_hba_timers()
3318 timer_delete_sync(&phba->sli.mbox_tmo); in lpfc_stop_hba_timers()
3319 timer_delete_sync(&phba->fabric_block_timer); in lpfc_stop_hba_timers()
3320 timer_delete_sync(&phba->eratt_poll); in lpfc_stop_hba_timers()
3321 timer_delete_sync(&phba->hb_tmofunc); in lpfc_stop_hba_timers()
3322 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_stop_hba_timers()
3323 timer_delete_sync(&phba->rrq_tmr); in lpfc_stop_hba_timers()
3324 clear_bit(HBA_RRQ_ACTIVE, &phba->hba_flag); in lpfc_stop_hba_timers()
3326 clear_bit(HBA_HBEAT_INP, &phba->hba_flag); in lpfc_stop_hba_timers()
3327 clear_bit(HBA_HBEAT_TMO, &phba->hba_flag); in lpfc_stop_hba_timers()
3329 switch (phba->pci_dev_grp) { in lpfc_stop_hba_timers()
3332 timer_delete_sync(&phba->fcp_poll_timer); in lpfc_stop_hba_timers()
3341 phba->pci_dev_grp); in lpfc_stop_hba_timers()
3348 * lpfc_block_mgmt_io - Mark a HBA's management interface as blocked
3363 unsigned long timeout; in lpfc_block_mgmt_io() local
3365 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3366 phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO; in lpfc_block_mgmt_io()
3367 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3370 timeout = secs_to_jiffies(LPFC_MBOX_TMO) + jiffies; in lpfc_block_mgmt_io()
3371 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3372 if (phba->sli.mbox_active) { in lpfc_block_mgmt_io()
3373 actcmd = phba->sli.mbox_active->u.mb.mbxCommand; in lpfc_block_mgmt_io()
3377 timeout = secs_to_jiffies(lpfc_mbox_tmo_val(phba, in lpfc_block_mgmt_io()
3378 phba->sli.mbox_active)) + jiffies; in lpfc_block_mgmt_io()
3380 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3383 while (phba->sli.mbox_active) { in lpfc_block_mgmt_io()
3386 if (time_after(jiffies, timeout)) { in lpfc_block_mgmt_io()
3389 "- mbox cmd %x still active\n", in lpfc_block_mgmt_io()
3390 phba->sli.sli_flag, actcmd); in lpfc_block_mgmt_io()
3397 * lpfc_sli4_node_rpi_restore - Recover assigned RPIs for active nodes.
3411 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_sli4_node_rpi_restore()
3418 for (i = 0; i <= phba->max_vports && vports[i]; i++) { in lpfc_sli4_node_rpi_restore()
3419 if (test_bit(FC_UNLOADING, &vports[i]->load_flag)) in lpfc_sli4_node_rpi_restore()
3423 &vports[i]->fc_nodes, in lpfc_sli4_node_rpi_restore()
3427 lpfc_printf_vlog(ndlp->vport, KERN_INFO, in lpfc_sli4_node_rpi_restore()
3432 ndlp, ndlp->nlp_DID, in lpfc_sli4_node_rpi_restore()
3433 ndlp->nlp_flag); in lpfc_sli4_node_rpi_restore()
3436 ndlp->nlp_rpi = rpi; in lpfc_sli4_node_rpi_restore()
3437 lpfc_printf_vlog(ndlp->vport, KERN_INFO, in lpfc_sli4_node_rpi_restore()
3441 ndlp->nlp_rpi, ndlp, ndlp->nlp_DID, in lpfc_sli4_node_rpi_restore()
3442 ndlp->nlp_flag); in lpfc_sli4_node_rpi_restore()
3449 * lpfc_create_expedite_pool - create expedite pool
3463 epd_pool = &phba->epd_pool; in lpfc_create_expedite_pool()
3464 qp = &phba->sli4_hba.hdwq[0]; in lpfc_create_expedite_pool()
3466 spin_lock_init(&epd_pool->lock); in lpfc_create_expedite_pool()
3467 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_create_expedite_pool()
3468 spin_lock(&epd_pool->lock); in lpfc_create_expedite_pool()
3469 INIT_LIST_HEAD(&epd_pool->list); in lpfc_create_expedite_pool()
3471 &qp->lpfc_io_buf_list_put, list) { in lpfc_create_expedite_pool()
3472 list_move_tail(&lpfc_ncmd->list, &epd_pool->list); in lpfc_create_expedite_pool()
3473 lpfc_ncmd->expedite = true; in lpfc_create_expedite_pool()
3474 qp->put_io_bufs--; in lpfc_create_expedite_pool()
3475 epd_pool->count++; in lpfc_create_expedite_pool()
3476 if (epd_pool->count >= XRI_BATCH) in lpfc_create_expedite_pool()
3479 spin_unlock(&epd_pool->lock); in lpfc_create_expedite_pool()
3480 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_create_expedite_pool()
3484 * lpfc_destroy_expedite_pool - destroy expedite pool
3498 epd_pool = &phba->epd_pool; in lpfc_destroy_expedite_pool()
3499 qp = &phba->sli4_hba.hdwq[0]; in lpfc_destroy_expedite_pool()
3501 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_expedite_pool()
3502 spin_lock(&epd_pool->lock); in lpfc_destroy_expedite_pool()
3504 &epd_pool->list, list) { in lpfc_destroy_expedite_pool()
3505 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_expedite_pool()
3506 &qp->lpfc_io_buf_list_put); in lpfc_destroy_expedite_pool()
3507 lpfc_ncmd->flags = false; in lpfc_destroy_expedite_pool()
3508 qp->put_io_bufs++; in lpfc_destroy_expedite_pool()
3509 epd_pool->count--; in lpfc_destroy_expedite_pool()
3511 spin_unlock(&epd_pool->lock); in lpfc_destroy_expedite_pool()
3512 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_expedite_pool()
3516 * lpfc_create_multixri_pools - create multi-XRI pools
3538 phba->cfg_hdw_queue, phba->sli4_hba.num_present_cpu, in lpfc_create_multixri_pools()
3539 phba->sli4_hba.io_xri_cnt); in lpfc_create_multixri_pools()
3541 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_create_multixri_pools()
3544 hwq_count = phba->cfg_hdw_queue; in lpfc_create_multixri_pools()
3545 count_per_hwq = phba->sli4_hba.io_xri_cnt / hwq_count; in lpfc_create_multixri_pools()
3555 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_create_multixri_pools()
3560 qp = &phba->sli4_hba.hdwq[j]; in lpfc_create_multixri_pools()
3561 kfree(qp->p_multixri_pool); in lpfc_create_multixri_pools()
3564 phba->cfg_xri_rebalancing = 0; in lpfc_create_multixri_pools()
3568 qp = &phba->sli4_hba.hdwq[i]; in lpfc_create_multixri_pools()
3569 qp->p_multixri_pool = multixri_pool; in lpfc_create_multixri_pools()
3571 multixri_pool->xri_limit = count_per_hwq; in lpfc_create_multixri_pools()
3572 multixri_pool->rrb_next_hwqid = i; in lpfc_create_multixri_pools()
3575 pbl_pool = &multixri_pool->pbl_pool; in lpfc_create_multixri_pools()
3576 spin_lock_init(&pbl_pool->lock); in lpfc_create_multixri_pools()
3577 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_create_multixri_pools()
3578 spin_lock(&pbl_pool->lock); in lpfc_create_multixri_pools()
3579 INIT_LIST_HEAD(&pbl_pool->list); in lpfc_create_multixri_pools()
3581 &qp->lpfc_io_buf_list_put, list) { in lpfc_create_multixri_pools()
3582 list_move_tail(&lpfc_ncmd->list, &pbl_pool->list); in lpfc_create_multixri_pools()
3583 qp->put_io_bufs--; in lpfc_create_multixri_pools()
3584 pbl_pool->count++; in lpfc_create_multixri_pools()
3588 pbl_pool->count, i); in lpfc_create_multixri_pools()
3589 spin_unlock(&pbl_pool->lock); in lpfc_create_multixri_pools()
3590 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_create_multixri_pools()
3593 pvt_pool = &multixri_pool->pvt_pool; in lpfc_create_multixri_pools()
3594 pvt_pool->high_watermark = multixri_pool->xri_limit / 2; in lpfc_create_multixri_pools()
3595 pvt_pool->low_watermark = XRI_BATCH; in lpfc_create_multixri_pools()
3596 spin_lock_init(&pvt_pool->lock); in lpfc_create_multixri_pools()
3597 spin_lock_irqsave(&pvt_pool->lock, iflag); in lpfc_create_multixri_pools()
3598 INIT_LIST_HEAD(&pvt_pool->list); in lpfc_create_multixri_pools()
3599 pvt_pool->count = 0; in lpfc_create_multixri_pools()
3600 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_create_multixri_pools()
3605 * lpfc_destroy_multixri_pools - destroy multi-XRI pools
3622 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_destroy_multixri_pools()
3625 if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_destroy_multixri_pools()
3628 hwq_count = phba->cfg_hdw_queue; in lpfc_destroy_multixri_pools()
3631 qp = &phba->sli4_hba.hdwq[i]; in lpfc_destroy_multixri_pools()
3632 multixri_pool = qp->p_multixri_pool; in lpfc_destroy_multixri_pools()
3636 qp->p_multixri_pool = NULL; in lpfc_destroy_multixri_pools()
3638 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_multixri_pools()
3641 pbl_pool = &multixri_pool->pbl_pool; in lpfc_destroy_multixri_pools()
3642 spin_lock(&pbl_pool->lock); in lpfc_destroy_multixri_pools()
3646 pbl_pool->count, i); in lpfc_destroy_multixri_pools()
3649 &pbl_pool->list, list) { in lpfc_destroy_multixri_pools()
3650 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_multixri_pools()
3651 &qp->lpfc_io_buf_list_put); in lpfc_destroy_multixri_pools()
3652 qp->put_io_bufs++; in lpfc_destroy_multixri_pools()
3653 pbl_pool->count--; in lpfc_destroy_multixri_pools()
3656 INIT_LIST_HEAD(&pbl_pool->list); in lpfc_destroy_multixri_pools()
3657 pbl_pool->count = 0; in lpfc_destroy_multixri_pools()
3659 spin_unlock(&pbl_pool->lock); in lpfc_destroy_multixri_pools()
3662 pvt_pool = &multixri_pool->pvt_pool; in lpfc_destroy_multixri_pools()
3663 spin_lock(&pvt_pool->lock); in lpfc_destroy_multixri_pools()
3667 pvt_pool->count, i); in lpfc_destroy_multixri_pools()
3670 &pvt_pool->list, list) { in lpfc_destroy_multixri_pools()
3671 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_multixri_pools()
3672 &qp->lpfc_io_buf_list_put); in lpfc_destroy_multixri_pools()
3673 qp->put_io_bufs++; in lpfc_destroy_multixri_pools()
3674 pvt_pool->count--; in lpfc_destroy_multixri_pools()
3677 INIT_LIST_HEAD(&pvt_pool->list); in lpfc_destroy_multixri_pools()
3678 pvt_pool->count = 0; in lpfc_destroy_multixri_pools()
3680 spin_unlock(&pvt_pool->lock); in lpfc_destroy_multixri_pools()
3681 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_multixri_pools()
3688 * lpfc_online - Initialize and bring a HBA online
3696 * 0 - successful
3697 * 1 - failed
3709 vport = phba->pport; in lpfc_online()
3711 if (!test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) in lpfc_online()
3719 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_online()
3724 spin_lock_irq(&phba->hbalock); in lpfc_online()
3725 if (!phba->sli4_hba.max_cfg_param.vpi_used) in lpfc_online()
3727 spin_unlock_irq(&phba->hbalock); in lpfc_online()
3732 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME && in lpfc_online()
3733 !phba->nvmet_support) { in lpfc_online()
3734 error = lpfc_nvme_create_localport(phba->pport); in lpfc_online()
3750 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_online()
3751 clear_bit(FC_OFFLINE_MODE, &vports[i]->fc_flag); in lpfc_online()
3752 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) in lpfc_online()
3754 &vports[i]->fc_flag); in lpfc_online()
3755 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_online()
3757 &vports[i]->fc_flag); in lpfc_online()
3759 (vports[i]->port_type != in lpfc_online()
3761 vports[i]->vpi = 0; in lpfc_online()
3767 if (phba->cfg_xri_rebalancing) in lpfc_online()
3777 * lpfc_unblock_mgmt_io - Mark a HBA's management interface to be not blocked
3792 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_unblock_mgmt_io()
3793 phba->sli.sli_flag &= ~LPFC_BLOCK_MGMT_IO; in lpfc_unblock_mgmt_io()
3794 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_unblock_mgmt_io()
3798 * lpfc_offline_prep - Prepare a HBA to be brought offline
3809 struct lpfc_vport *vport = phba->pport; in lpfc_offline_prep()
3817 if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) in lpfc_offline_prep()
3824 offline = pci_channel_offline(phba->pcidev); in lpfc_offline_prep()
3825 hba_pci_err = test_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_offline_prep()
3830 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_offline_prep()
3831 if (test_bit(FC_UNLOADING, &vports[i]->load_flag)) in lpfc_offline_prep()
3834 spin_lock_irq(shost->host_lock); in lpfc_offline_prep()
3835 vports[i]->vpi_state &= ~LPFC_VPI_REGISTERED; in lpfc_offline_prep()
3836 spin_unlock_irq(shost->host_lock); in lpfc_offline_prep()
3837 set_bit(FC_VPORT_NEEDS_REG_VPI, &vports[i]->fc_flag); in lpfc_offline_prep()
3838 clear_bit(FC_VFI_REGISTERED, &vports[i]->fc_flag); in lpfc_offline_prep()
3841 &vports[i]->fc_nodes, in lpfc_offline_prep()
3844 clear_bit(NLP_NPR_ADISC, &ndlp->nlp_flag); in lpfc_offline_prep()
3847 &ndlp->nlp_flag); in lpfc_offline_prep()
3849 &ndlp->nlp_flag); in lpfc_offline_prep()
3852 if (ndlp->nlp_type & NLP_FABRIC) { in lpfc_offline_prep()
3864 &ndlp->save_flags) && in lpfc_offline_prep()
3865 !(ndlp->fc4_xpt_flags & in lpfc_offline_prep()
3879 if (phba->wq) in lpfc_offline_prep()
3880 flush_workqueue(phba->wq); in lpfc_offline_prep()
3884 * lpfc_offline - Bring a HBA offline
3898 if (test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_offline()
3908 lpfc_nvme_destroy_localport(phba->pport); in lpfc_offline()
3912 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) in lpfc_offline()
3920 spin_lock_irq(&phba->hbalock); in lpfc_offline()
3921 phba->work_ha = 0; in lpfc_offline()
3922 spin_unlock_irq(&phba->hbalock); in lpfc_offline()
3925 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_offline()
3927 spin_lock_irq(shost->host_lock); in lpfc_offline()
3928 vports[i]->work_port_events = 0; in lpfc_offline()
3929 spin_unlock_irq(shost->host_lock); in lpfc_offline()
3930 set_bit(FC_OFFLINE_MODE, &vports[i]->fc_flag); in lpfc_offline()
3936 if (test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_offline()
3939 if (phba->cfg_xri_rebalancing) in lpfc_offline()
3944 * lpfc_scsi_free - Free all the SCSI buffers and IOCBs from driver lists
3956 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_scsi_free()
3959 spin_lock_irq(&phba->hbalock); in lpfc_scsi_free()
3963 spin_lock(&phba->scsi_buf_list_put_lock); in lpfc_scsi_free()
3964 list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list_put, in lpfc_scsi_free()
3966 list_del(&sb->list); in lpfc_scsi_free()
3967 dma_pool_free(phba->lpfc_sg_dma_buf_pool, sb->data, in lpfc_scsi_free()
3968 sb->dma_handle); in lpfc_scsi_free()
3970 phba->total_scsi_bufs--; in lpfc_scsi_free()
3972 spin_unlock(&phba->scsi_buf_list_put_lock); in lpfc_scsi_free()
3974 spin_lock(&phba->scsi_buf_list_get_lock); in lpfc_scsi_free()
3975 list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list_get, in lpfc_scsi_free()
3977 list_del(&sb->list); in lpfc_scsi_free()
3978 dma_pool_free(phba->lpfc_sg_dma_buf_pool, sb->data, in lpfc_scsi_free()
3979 sb->dma_handle); in lpfc_scsi_free()
3981 phba->total_scsi_bufs--; in lpfc_scsi_free()
3983 spin_unlock(&phba->scsi_buf_list_get_lock); in lpfc_scsi_free()
3984 spin_unlock_irq(&phba->hbalock); in lpfc_scsi_free()
3988 * lpfc_io_free - Free all the IO buffers and IOCBs from driver lists
4002 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_free()
4003 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_free()
4005 spin_lock(&qp->io_buf_list_put_lock); in lpfc_io_free()
4007 &qp->lpfc_io_buf_list_put, in lpfc_io_free()
4009 list_del(&lpfc_ncmd->list); in lpfc_io_free()
4010 qp->put_io_bufs--; in lpfc_io_free()
4011 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_io_free()
4012 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_io_free()
4013 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_io_free()
4017 qp->total_io_bufs--; in lpfc_io_free()
4019 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_io_free()
4021 spin_lock(&qp->io_buf_list_get_lock); in lpfc_io_free()
4023 &qp->lpfc_io_buf_list_get, in lpfc_io_free()
4025 list_del(&lpfc_ncmd->list); in lpfc_io_free()
4026 qp->get_io_bufs--; in lpfc_io_free()
4027 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_io_free()
4028 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_io_free()
4029 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_io_free()
4033 qp->total_io_bufs--; in lpfc_io_free()
4035 spin_unlock(&qp->io_buf_list_get_lock); in lpfc_io_free()
4040 * lpfc_sli4_els_sgl_update - update ELS xri-sgl sizing and mapping
4049 * 0 - successful (for now, it always returns 0)
4060 * update on pci function's els xri-sgl list in lpfc_sli4_els_sgl_update()
4064 if (els_xri_cnt > phba->sli4_hba.els_xri_cnt) { in lpfc_sli4_els_sgl_update()
4065 /* els xri-sgl expanded */ in lpfc_sli4_els_sgl_update()
4066 xri_cnt = els_xri_cnt - phba->sli4_hba.els_xri_cnt; in lpfc_sli4_els_sgl_update()
4068 "3157 ELS xri-sgl count increased from " in lpfc_sli4_els_sgl_update()
4069 "%d to %d\n", phba->sli4_hba.els_xri_cnt, in lpfc_sli4_els_sgl_update()
4080 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
4083 sglq_entry->buff_type = GEN_BUFF_TYPE; in lpfc_sli4_els_sgl_update()
4084 sglq_entry->virt = lpfc_mbuf_alloc(phba, 0, in lpfc_sli4_els_sgl_update()
4085 &sglq_entry->phys); in lpfc_sli4_els_sgl_update()
4086 if (sglq_entry->virt == NULL) { in lpfc_sli4_els_sgl_update()
4092 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
4095 sglq_entry->sgl = sglq_entry->virt; in lpfc_sli4_els_sgl_update()
4096 memset(sglq_entry->sgl, 0, LPFC_BPL_SIZE); in lpfc_sli4_els_sgl_update()
4097 sglq_entry->state = SGL_FREED; in lpfc_sli4_els_sgl_update()
4098 list_add_tail(&sglq_entry->list, &els_sgl_list); in lpfc_sli4_els_sgl_update()
4100 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4102 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_sli4_els_sgl_update()
4103 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4104 } else if (els_xri_cnt < phba->sli4_hba.els_xri_cnt) { in lpfc_sli4_els_sgl_update()
4105 /* els xri-sgl shrinked */ in lpfc_sli4_els_sgl_update()
4106 xri_cnt = phba->sli4_hba.els_xri_cnt - els_xri_cnt; in lpfc_sli4_els_sgl_update()
4108 "3158 ELS xri-sgl count decreased from " in lpfc_sli4_els_sgl_update()
4109 "%d to %d\n", phba->sli4_hba.els_xri_cnt, in lpfc_sli4_els_sgl_update()
4111 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4112 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, in lpfc_sli4_els_sgl_update()
4119 __lpfc_mbuf_free(phba, sglq_entry->virt, in lpfc_sli4_els_sgl_update()
4120 sglq_entry->phys); in lpfc_sli4_els_sgl_update()
4125 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_sli4_els_sgl_update()
4126 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4129 "3163 ELS xri-sgl count unchanged: %d\n", in lpfc_sli4_els_sgl_update()
4131 phba->sli4_hba.els_xri_cnt = els_xri_cnt; in lpfc_sli4_els_sgl_update()
4137 &phba->sli4_hba.lpfc_els_sgl_list, list) { in lpfc_sli4_els_sgl_update()
4144 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
4147 sglq_entry->sli4_lxritag = lxri; in lpfc_sli4_els_sgl_update()
4148 sglq_entry->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_els_sgl_update()
4158 * lpfc_sli4_nvmet_sgl_update - update xri-sgl sizing and mapping
4167 * 0 - successful (for now, it always returns 0)
4179 * update on pci function's nvmet xri-sgl list in lpfc_sli4_nvmet_sgl_update()
4184 nvmet_xri_cnt = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4185 if (nvmet_xri_cnt > phba->sli4_hba.nvmet_xri_cnt) { in lpfc_sli4_nvmet_sgl_update()
4186 /* els xri-sgl expanded */ in lpfc_sli4_nvmet_sgl_update()
4187 xri_cnt = nvmet_xri_cnt - phba->sli4_hba.nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4189 "6302 NVMET xri-sgl cnt grew from %d to %d\n", in lpfc_sli4_nvmet_sgl_update()
4190 phba->sli4_hba.nvmet_xri_cnt, nvmet_xri_cnt); in lpfc_sli4_nvmet_sgl_update()
4200 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
4203 sglq_entry->buff_type = NVMET_BUFF_TYPE; in lpfc_sli4_nvmet_sgl_update()
4204 sglq_entry->virt = lpfc_nvmet_buf_alloc(phba, 0, in lpfc_sli4_nvmet_sgl_update()
4205 &sglq_entry->phys); in lpfc_sli4_nvmet_sgl_update()
4206 if (sglq_entry->virt == NULL) { in lpfc_sli4_nvmet_sgl_update()
4212 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
4215 sglq_entry->sgl = sglq_entry->virt; in lpfc_sli4_nvmet_sgl_update()
4216 memset(sglq_entry->sgl, 0, in lpfc_sli4_nvmet_sgl_update()
4217 phba->cfg_sg_dma_buf_size); in lpfc_sli4_nvmet_sgl_update()
4218 sglq_entry->state = SGL_FREED; in lpfc_sli4_nvmet_sgl_update()
4219 list_add_tail(&sglq_entry->list, &nvmet_sgl_list); 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()
4224 &phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
4225 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4226 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4227 } else if (nvmet_xri_cnt < phba->sli4_hba.nvmet_xri_cnt) { in lpfc_sli4_nvmet_sgl_update()
4228 /* nvmet xri-sgl shrunk */ in lpfc_sli4_nvmet_sgl_update()
4229 xri_cnt = phba->sli4_hba.nvmet_xri_cnt - nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4231 "6305 NVMET xri-sgl count decreased from " in lpfc_sli4_nvmet_sgl_update()
4232 "%d to %d\n", phba->sli4_hba.nvmet_xri_cnt, in lpfc_sli4_nvmet_sgl_update()
4234 spin_lock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4235 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4236 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, in lpfc_sli4_nvmet_sgl_update()
4243 lpfc_nvmet_buf_free(phba, sglq_entry->virt, in lpfc_sli4_nvmet_sgl_update()
4244 sglq_entry->phys); in lpfc_sli4_nvmet_sgl_update()
4249 &phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
4250 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4251 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4254 "6306 NVMET xri-sgl count unchanged: %d\n", in lpfc_sli4_nvmet_sgl_update()
4256 phba->sli4_hba.nvmet_xri_cnt = nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4262 &phba->sli4_hba.lpfc_nvmet_sgl_list, list) { in lpfc_sli4_nvmet_sgl_update()
4269 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
4272 sglq_entry->sli4_lxritag = lxri; in lpfc_sli4_nvmet_sgl_update()
4273 sglq_entry->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_nvmet_sgl_update()
4292 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_buf_flush()
4293 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf_flush()
4294 spin_lock_irq(&qp->io_buf_list_get_lock); in lpfc_io_buf_flush()
4295 spin_lock(&qp->io_buf_list_put_lock); in lpfc_io_buf_flush()
4298 list_splice_init(&qp->lpfc_io_buf_list_get, &blist); in lpfc_io_buf_flush()
4299 list_splice(&qp->lpfc_io_buf_list_put, &blist); in lpfc_io_buf_flush()
4300 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_io_buf_flush()
4301 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_io_buf_flush()
4302 cnt += qp->get_io_bufs + qp->put_io_bufs; in lpfc_io_buf_flush()
4303 qp->get_io_bufs = 0; in lpfc_io_buf_flush()
4304 qp->put_io_bufs = 0; in lpfc_io_buf_flush()
4305 qp->total_io_bufs = 0; in lpfc_io_buf_flush()
4306 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_io_buf_flush()
4307 spin_unlock_irq(&qp->io_buf_list_get_lock); in lpfc_io_buf_flush()
4320 list_add_tail(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4323 xri = lpfc_cmd->cur_iocbq.sli4_xritag; in lpfc_io_buf_flush()
4327 if (xri < iobufp->cur_iocbq.sli4_xritag) { in lpfc_io_buf_flush()
4329 list_add(&lpfc_cmd->list, in lpfc_io_buf_flush()
4330 &prev_iobufp->list); in lpfc_io_buf_flush()
4332 list_add(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4339 list_add_tail(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4352 qp = phba->sli4_hba.hdwq; in lpfc_io_buf_replenish()
4355 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_buf_replenish()
4361 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf_replenish()
4362 lpfc_cmd->hdwq_no = idx; in lpfc_io_buf_replenish()
4363 lpfc_cmd->hdwq = qp; in lpfc_io_buf_replenish()
4364 lpfc_cmd->cur_iocbq.cmd_cmpl = NULL; in lpfc_io_buf_replenish()
4365 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflags); in lpfc_io_buf_replenish()
4366 list_add_tail(&lpfc_cmd->list, in lpfc_io_buf_replenish()
4367 &qp->lpfc_io_buf_list_put); in lpfc_io_buf_replenish()
4368 qp->put_io_bufs++; in lpfc_io_buf_replenish()
4369 qp->total_io_bufs++; in lpfc_io_buf_replenish()
4370 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, in lpfc_io_buf_replenish()
4378 * lpfc_sli4_io_sgl_update - update xri-sgl sizing and mapping
4387 * 0 - successful (for now, it always returns 0)
4399 * update on pci function's allocated nvme xri-sgl list in lpfc_sli4_io_sgl_update()
4404 io_xri_max = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt; in lpfc_sli4_io_sgl_update()
4405 phba->sli4_hba.io_xri_max = io_xri_max; in lpfc_sli4_io_sgl_update()
4410 phba->sli4_hba.io_xri_cnt, in lpfc_sli4_io_sgl_update()
4411 phba->sli4_hba.io_xri_max, in lpfc_sli4_io_sgl_update()
4416 if (phba->sli4_hba.io_xri_cnt > phba->sli4_hba.io_xri_max) { in lpfc_sli4_io_sgl_update()
4418 io_xri_cnt = phba->sli4_hba.io_xri_cnt - in lpfc_sli4_io_sgl_update()
4419 phba->sli4_hba.io_xri_max; in lpfc_sli4_io_sgl_update()
4425 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_sli4_io_sgl_update()
4426 lpfc_ncmd->data, in lpfc_sli4_io_sgl_update()
4427 lpfc_ncmd->dma_handle); in lpfc_sli4_io_sgl_update()
4431 phba->sli4_hba.io_xri_cnt -= io_xri_cnt; in lpfc_sli4_io_sgl_update()
4437 phba->sli4_hba.io_xri_cnt = cnt; in lpfc_sli4_io_sgl_update()
4446 rc = -ENOMEM; in lpfc_sli4_io_sgl_update()
4449 lpfc_ncmd->cur_iocbq.sli4_lxritag = lxri; in lpfc_sli4_io_sgl_update()
4450 lpfc_ncmd->cur_iocbq.sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_io_sgl_update()
4461 * lpfc_new_io_buf - IO buffer allocator for HBA with SLI4 IF spec
4465 * This routine allocates nvme buffers for device with SLI-4 interface spec,
4471 * int - number of IO buffers that were allocated and posted.
4485 phba->sli4_hba.io_xri_cnt = 0; in lpfc_new_io_buf()
4495 lpfc_ncmd->data = dma_pool_zalloc(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4497 &lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4498 if (!lpfc_ncmd->data) { in lpfc_new_io_buf()
4503 if (phba->cfg_xpsgl && !phba->nvmet_support) { in lpfc_new_io_buf()
4504 INIT_LIST_HEAD(&lpfc_ncmd->dma_sgl_xtra_list); in lpfc_new_io_buf()
4510 if ((phba->sli3_options & LPFC_SLI3_BG_ENABLED) && in lpfc_new_io_buf()
4511 (((unsigned long)(lpfc_ncmd->data) & in lpfc_new_io_buf()
4512 (unsigned long)(SLI4_PAGE_SIZE - 1)) != 0)) { in lpfc_new_io_buf()
4517 (unsigned long)lpfc_ncmd->data); in lpfc_new_io_buf()
4518 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4519 lpfc_ncmd->data, in lpfc_new_io_buf()
4520 lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4526 INIT_LIST_HEAD(&lpfc_ncmd->dma_cmd_rsp_list); in lpfc_new_io_buf()
4530 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4531 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4535 pwqeq = &lpfc_ncmd->cur_iocbq; in lpfc_new_io_buf()
4537 /* Allocate iotag for lpfc_ncmd->cur_iocbq. */ in lpfc_new_io_buf()
4540 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4541 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4549 pwqeq->sli4_lxritag = lxri; in lpfc_new_io_buf()
4550 pwqeq->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_new_io_buf()
4552 /* Initialize local short-hand pointers. */ in lpfc_new_io_buf()
4553 lpfc_ncmd->dma_sgl = lpfc_ncmd->data; in lpfc_new_io_buf()
4554 lpfc_ncmd->dma_phys_sgl = lpfc_ncmd->dma_handle; in lpfc_new_io_buf()
4555 lpfc_ncmd->cur_iocbq.io_buf = lpfc_ncmd; in lpfc_new_io_buf()
4556 spin_lock_init(&lpfc_ncmd->buf_lock); in lpfc_new_io_buf()
4559 list_add_tail(&lpfc_ncmd->list, &post_nblist); in lpfc_new_io_buf()
4560 phba->sli4_hba.io_xri_cnt++; in lpfc_new_io_buf()
4586 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_get_wwpn()
4589 return (uint64_t)-1; in lpfc_get_wwpn()
4598 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_get_wwpn()
4599 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_get_wwpn()
4600 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_get_wwpn()
4601 return (uint64_t) -1; in lpfc_get_wwpn()
4603 mb = &mboxq->u.mb; in lpfc_get_wwpn()
4604 memcpy(&wwn, (char *)mb->un.varRDnvp.portname, sizeof(uint64_t)); in lpfc_get_wwpn()
4606 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_get_wwpn()
4607 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_get_wwpn()
4615 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_get_sg_tablesize()
4616 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_get_sg_tablesize()
4619 return phba->cfg_scsi_seg_cnt; in lpfc_get_sg_tablesize()
4621 return phba->cfg_sg_seg_cnt; in lpfc_get_sg_tablesize()
4625 * lpfc_vmid_res_alloc - Allocates resources for VMID
4633 * Non-0 on Failure
4639 if (phba->sli_rev == LPFC_SLI_REV3) { in lpfc_vmid_res_alloc()
4640 phba->cfg_vmid_app_header = 0; in lpfc_vmid_res_alloc()
4641 phba->cfg_vmid_priority_tagging = 0; in lpfc_vmid_res_alloc()
4645 vport->vmid = in lpfc_vmid_res_alloc()
4646 kcalloc(phba->cfg_max_vmid, sizeof(struct lpfc_vmid), in lpfc_vmid_res_alloc()
4648 if (!vport->vmid) in lpfc_vmid_res_alloc()
4649 return -ENOMEM; in lpfc_vmid_res_alloc()
4651 rwlock_init(&vport->vmid_lock); in lpfc_vmid_res_alloc()
4654 vport->vmid_priority_tagging = phba->cfg_vmid_priority_tagging; in lpfc_vmid_res_alloc()
4655 vport->vmid_inactivity_timeout = in lpfc_vmid_res_alloc()
4656 phba->cfg_vmid_inactivity_timeout; in lpfc_vmid_res_alloc()
4657 vport->max_vmid = phba->cfg_max_vmid; in lpfc_vmid_res_alloc()
4658 vport->cur_vmid_cnt = 0; in lpfc_vmid_res_alloc()
4660 vport->vmid_priority_range = bitmap_zalloc in lpfc_vmid_res_alloc()
4663 if (!vport->vmid_priority_range) { in lpfc_vmid_res_alloc()
4664 kfree(vport->vmid); in lpfc_vmid_res_alloc()
4665 return -ENOMEM; in lpfc_vmid_res_alloc()
4668 hash_init(vport->hash_table); in lpfc_vmid_res_alloc()
4674 * lpfc_create_port - Create an FC port
4686 * @vport - pointer to the virtual N_Port data structure.
4687 * NULL - port create failed.
4703 if (phba->sli_rev < LPFC_SLI_REV4 && in lpfc_create_port()
4704 dev == &phba->pcidev->dev) { in lpfc_create_port()
4726 if (dev == &phba->pcidev->dev) { in lpfc_create_port()
4727 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { in lpfc_create_port()
4733 template->eh_host_reset_handler = NULL; in lpfc_create_port()
4736 template->sg_tablesize = lpfc_get_sg_tablesize(phba); in lpfc_create_port()
4746 template->sg_tablesize = lpfc_get_sg_tablesize(phba); in lpfc_create_port()
4753 vport = (struct lpfc_vport *) shost->hostdata; in lpfc_create_port()
4754 vport->phba = phba; in lpfc_create_port()
4755 set_bit(FC_LOADING, &vport->load_flag); in lpfc_create_port()
4756 set_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); in lpfc_create_port()
4757 vport->fc_rscn_flush = 0; in lpfc_create_port()
4758 atomic_set(&vport->fc_plogi_cnt, 0); in lpfc_create_port()
4759 atomic_set(&vport->fc_adisc_cnt, 0); in lpfc_create_port()
4760 atomic_set(&vport->fc_reglogin_cnt, 0); in lpfc_create_port()
4761 atomic_set(&vport->fc_prli_cnt, 0); in lpfc_create_port()
4762 atomic_set(&vport->fc_unmap_cnt, 0); in lpfc_create_port()
4763 atomic_set(&vport->fc_map_cnt, 0); in lpfc_create_port()
4764 atomic_set(&vport->fc_npr_cnt, 0); in lpfc_create_port()
4765 atomic_set(&vport->fc_unused_cnt, 0); in lpfc_create_port()
4769 vport->cfg_enable_fc4_type = phba->cfg_enable_fc4_type; in lpfc_create_port()
4771 shost->unique_id = instance; in lpfc_create_port()
4772 shost->max_id = LPFC_MAX_TARGET; in lpfc_create_port()
4773 shost->max_lun = vport->cfg_max_luns; in lpfc_create_port()
4774 shost->this_id = -1; in lpfc_create_port()
4777 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_create_port()
4779 &phba->sli4_hba.sli_intf); in lpfc_create_port()
4784 shost->max_cmd_len = LPFC_FCP_CDB_LEN_32; in lpfc_create_port()
4787 shost->max_cmd_len = LPFC_FCP_CDB_LEN; in lpfc_create_port()
4791 shost->max_cmd_len = LPFC_FCP_CDB_LEN; in lpfc_create_port()
4794 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_create_port()
4795 if (!phba->cfg_fcp_mq_threshold || in lpfc_create_port()
4796 phba->cfg_fcp_mq_threshold > phba->cfg_hdw_queue) in lpfc_create_port()
4797 phba->cfg_fcp_mq_threshold = phba->cfg_hdw_queue; in lpfc_create_port()
4799 shost->nr_hw_queues = min_t(int, 2 * num_possible_nodes(), in lpfc_create_port()
4800 phba->cfg_fcp_mq_threshold); in lpfc_create_port()
4802 shost->dma_boundary = in lpfc_create_port()
4803 phba->sli4_hba.pc_sli4_params.sge_supp_len-1; in lpfc_create_port()
4805 /* SLI-3 has a limited number of hardware queues (3), in lpfc_create_port()
4808 shost->nr_hw_queues = 1; in lpfc_create_port()
4815 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_create_port()
4816 if (dev != &phba->pcidev->dev) { in lpfc_create_port()
4817 shost->transportt = lpfc_vport_transport_template; in lpfc_create_port()
4818 vport->port_type = LPFC_NPIV_PORT; in lpfc_create_port()
4820 shost->transportt = lpfc_transport_template; in lpfc_create_port()
4821 vport->port_type = LPFC_PHYSICAL_PORT; in lpfc_create_port()
4827 vport->port_type, shost->sg_tablesize, in lpfc_create_port()
4828 phba->cfg_scsi_seg_cnt, phba->cfg_sg_seg_cnt); in lpfc_create_port()
4837 INIT_LIST_HEAD(&vport->fc_nodes); in lpfc_create_port()
4838 spin_lock_init(&vport->fc_nodes_list_lock); in lpfc_create_port()
4839 INIT_LIST_HEAD(&vport->rcv_buffer_list); in lpfc_create_port()
4840 spin_lock_init(&vport->work_port_lock); in lpfc_create_port()
4842 timer_setup(&vport->fc_disctmo, lpfc_disc_timeout, 0); in lpfc_create_port()
4844 timer_setup(&vport->els_tmofunc, lpfc_els_timeout, 0); in lpfc_create_port()
4846 timer_setup(&vport->delayed_disc_tmo, lpfc_delayed_disc_tmo, 0); in lpfc_create_port()
4848 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) in lpfc_create_port()
4851 error = scsi_add_host_with_dma(shost, dev, &phba->pcidev->dev); in lpfc_create_port()
4855 spin_lock_irq(&phba->port_list_lock); in lpfc_create_port()
4856 list_add_tail(&vport->listentry, &phba->port_list); in lpfc_create_port()
4857 spin_unlock_irq(&phba->port_list_lock); in lpfc_create_port()
4861 kfree(vport->vmid); in lpfc_create_port()
4862 bitmap_free(vport->vmid_priority_range); in lpfc_create_port()
4870 * destroy_port - destroy an FC port
4880 struct lpfc_hba *phba = vport->phba; in destroy_port()
4886 spin_lock_irq(&phba->port_list_lock); in destroy_port()
4887 list_del_init(&vport->listentry); in destroy_port()
4888 spin_unlock_irq(&phba->port_list_lock); in destroy_port()
4895 * lpfc_get_instance - Get a unique integer ID
4901 * instance - a unique integer ID allocated as the new instance.
4902 * -1 - lpfc get instance failed.
4910 return ret < 0 ? -1 : ret; in lpfc_get_instance()
4914 * lpfc_scan_finished - method for SCSI layer to detect whether scan is done
4925 * 0 - SCSI host scan is not over yet.
4926 * 1 - SCSI host scan is over.
4930 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_scan_finished()
4931 struct lpfc_hba *phba = vport->phba; in lpfc_scan_finished()
4934 spin_lock_irq(shost->host_lock); in lpfc_scan_finished()
4936 if (test_bit(FC_UNLOADING, &vport->load_flag)) { in lpfc_scan_finished()
4948 phba->link_state <= LPFC_LINK_DOWN) { in lpfc_scan_finished()
4956 if (vport->port_state != LPFC_VPORT_READY) in lpfc_scan_finished()
4958 if (vport->num_disc_nodes || vport->fc_prli_sent) in lpfc_scan_finished()
4960 if (!atomic_read(&vport->fc_map_cnt) && in lpfc_scan_finished()
4963 if ((phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) != 0) in lpfc_scan_finished()
4969 spin_unlock_irq(shost->host_lock); in lpfc_scan_finished()
4975 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; in lpfc_host_supported_speeds_set()
4976 struct lpfc_hba *phba = vport->phba; in lpfc_host_supported_speeds_set()
4983 if (test_bit(HBA_FCOE_MODE, &phba->hba_flag)) in lpfc_host_supported_speeds_set()
4986 if (phba->lmt & LMT_256Gb) in lpfc_host_supported_speeds_set()
4988 if (phba->lmt & LMT_128Gb) in lpfc_host_supported_speeds_set()
4990 if (phba->lmt & LMT_64Gb) in lpfc_host_supported_speeds_set()
4992 if (phba->lmt & LMT_32Gb) in lpfc_host_supported_speeds_set()
4994 if (phba->lmt & LMT_16Gb) in lpfc_host_supported_speeds_set()
4996 if (phba->lmt & LMT_10Gb) in lpfc_host_supported_speeds_set()
4998 if (phba->lmt & LMT_8Gb) in lpfc_host_supported_speeds_set()
5000 if (phba->lmt & LMT_4Gb) in lpfc_host_supported_speeds_set()
5002 if (phba->lmt & LMT_2Gb) in lpfc_host_supported_speeds_set()
5004 if (phba->lmt & LMT_1Gb) in lpfc_host_supported_speeds_set()
5009 * lpfc_host_attrib_init - Initialize SCSI host attributes on a FC port
5017 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_host_attrib_init()
5018 struct lpfc_hba *phba = vport->phba; in lpfc_host_attrib_init()
5023 fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); in lpfc_host_attrib_init()
5024 fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); in lpfc_host_attrib_init()
5038 (((uint32_t) vport->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) | in lpfc_host_attrib_init()
5039 (uint32_t) vport->fc_sparam.cmn.bbRcvSizeLsb; in lpfc_host_attrib_init()
5041 fc_host_dev_loss_tmo(shost) = vport->cfg_devloss_tmo; in lpfc_host_attrib_init()
5049 fc_host_max_npiv_vports(shost) = phba->max_vpi; in lpfc_host_attrib_init()
5050 clear_bit(FC_LOADING, &vport->load_flag); in lpfc_host_attrib_init()
5054 * lpfc_stop_port_s3 - Stop SLI3 device port
5065 writel(0, phba->HCregaddr); in lpfc_stop_port_s3()
5066 readl(phba->HCregaddr); /* flush */ in lpfc_stop_port_s3()
5068 writel(0xffffffff, phba->HAregaddr); in lpfc_stop_port_s3()
5069 readl(phba->HAregaddr); /* flush */ in lpfc_stop_port_s3()
5073 phba->pport->work_port_events = 0; in lpfc_stop_port_s3()
5077 * lpfc_stop_port_s4 - Stop SLI4 device port
5089 if (phba->pport) in lpfc_stop_port_s4()
5090 phba->pport->work_port_events = 0; in lpfc_stop_port_s4()
5091 phba->sli4_hba.intr_enable = 0; in lpfc_stop_port_s4()
5095 * lpfc_stop_port - Wrapper function for stopping hba port
5104 phba->lpfc_stop_port(phba); in lpfc_stop_port()
5106 if (phba->wq) in lpfc_stop_port()
5107 flush_workqueue(phba->wq); in lpfc_stop_port()
5111 * lpfc_fcf_redisc_wait_start_timer - Start fcf rediscover wait timer
5122 mod_timer(&phba->fcf.redisc_wait, fcf_redisc_wait_tmo); in lpfc_fcf_redisc_wait_start_timer()
5123 spin_lock_irq(&phba->hbalock); in lpfc_fcf_redisc_wait_start_timer()
5125 phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_SCAN_DONE); in lpfc_fcf_redisc_wait_start_timer()
5127 phba->fcf.fcf_flag |= FCF_REDISC_PEND; in lpfc_fcf_redisc_wait_start_timer()
5128 spin_unlock_irq(&phba->hbalock); in lpfc_fcf_redisc_wait_start_timer()
5132 * lpfc_sli4_fcf_redisc_wait_tmo - FCF table rediscover wait timeout
5147 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
5148 if (!(phba->fcf.fcf_flag & FCF_REDISC_PEND)) { in lpfc_sli4_fcf_redisc_wait_tmo()
5149 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
5153 phba->fcf.fcf_flag &= ~FCF_REDISC_PEND; in lpfc_sli4_fcf_redisc_wait_tmo()
5155 phba->fcf.fcf_flag |= FCF_REDISC_EVT; in lpfc_sli4_fcf_redisc_wait_tmo()
5156 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
5164 * lpfc_vmid_poll - VMID timeout detection
5180 if (phba->pport->vmid_priority_tagging) { in lpfc_vmid_poll()
5182 phba->pport->work_port_events |= WORKER_CHECK_VMID_ISSUE_QFPA; in lpfc_vmid_poll()
5186 if (phba->pport->vmid_inactivity_timeout || in lpfc_vmid_poll()
5187 test_bit(FC_DEREGISTER_ALL_APP_ID, &phba->pport->load_flag)) { in lpfc_vmid_poll()
5189 phba->pport->work_port_events |= WORKER_CHECK_INACTIVE_VMID; in lpfc_vmid_poll()
5196 mod_timer(&phba->inactive_vmid_poll, in lpfc_vmid_poll()
5201 * lpfc_sli4_parse_latt_fault - Parse sli4 link-attention link fault code
5205 * This routine is to parse the SLI4 link-attention link fault code.
5235 * lpfc_sli4_parse_latt_type - Parse sli4 link attention type
5256 /* Ignore physical link up events - wait for logical link up */ in lpfc_sli4_parse_latt_type()
5273 * lpfc_sli_port_speed_get - Get sli3 link speed code to link speed
5288 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_sli_port_speed_get()
5289 switch (phba->fc_linkspeed) { in lpfc_sli_port_speed_get()
5312 if (phba->sli4_hba.link_state.logical_speed) in lpfc_sli_port_speed_get()
5314 phba->sli4_hba.link_state.logical_speed; in lpfc_sli_port_speed_get()
5316 link_speed = phba->sli4_hba.link_state.speed; in lpfc_sli_port_speed_get()
5322 * lpfc_sli4_port_speed_parse - Parse async evt link speed code to link speed
5418 * lpfc_sli4_async_link_evt - Process the asynchronous FCoE link event
5437 phba->fcoe_eventtag = acqe_link->event_tag; in lpfc_sli4_async_link_evt()
5438 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_async_link_evt()
5456 phba->sli4_hba.els_wq->pring->flag |= LPFC_STOP_IOCB_EVENT; in lpfc_sli4_async_link_evt()
5459 phba->sli.slistat.link_event++; in lpfc_sli4_async_link_evt()
5462 lpfc_read_topology(phba, pmb, pmb->ctx_buf); in lpfc_sli4_async_link_evt()
5463 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_sli4_async_link_evt()
5464 pmb->vport = phba->pport; in lpfc_sli4_async_link_evt()
5467 phba->sli4_hba.link_state.speed = in lpfc_sli4_async_link_evt()
5470 phba->sli4_hba.link_state.duplex = in lpfc_sli4_async_link_evt()
5472 phba->sli4_hba.link_state.status = in lpfc_sli4_async_link_evt()
5474 phba->sli4_hba.link_state.type = in lpfc_sli4_async_link_evt()
5476 phba->sli4_hba.link_state.number = in lpfc_sli4_async_link_evt()
5478 phba->sli4_hba.link_state.fault = in lpfc_sli4_async_link_evt()
5480 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_link_evt()
5484 "2900 Async FC/FCoE Link event - Speed:%dGBit " in lpfc_sli4_async_link_evt()
5487 phba->sli4_hba.link_state.speed, in lpfc_sli4_async_link_evt()
5488 phba->sli4_hba.link_state.topology, in lpfc_sli4_async_link_evt()
5489 phba->sli4_hba.link_state.status, in lpfc_sli4_async_link_evt()
5490 phba->sli4_hba.link_state.type, in lpfc_sli4_async_link_evt()
5491 phba->sli4_hba.link_state.number, in lpfc_sli4_async_link_evt()
5492 phba->sli4_hba.link_state.logical_speed, in lpfc_sli4_async_link_evt()
5493 phba->sli4_hba.link_state.fault); in lpfc_sli4_async_link_evt()
5496 * topology info. Note: Optional for non FC-AL ports. in lpfc_sli4_async_link_evt()
5498 if (!test_bit(HBA_FCOE_MODE, &phba->hba_flag)) { in lpfc_sli4_async_link_evt()
5510 mb = &pmb->u.mb; in lpfc_sli4_async_link_evt()
5511 mb->mbxStatus = MBX_SUCCESS; in lpfc_sli4_async_link_evt()
5517 la = (struct lpfc_mbx_read_top *) &pmb->u.mb.un.varReadTop; in lpfc_sli4_async_link_evt()
5518 la->eventTag = acqe_link->event_tag; in lpfc_sli4_async_link_evt()
5541 * lpfc_async_link_speed_to_read_top - Parse async evt link speed code to read
5595 if (!phba->rx_monitor) { in lpfc_cgn_dump_rxmonitor()
5599 lpfc_rx_monitor_report(phba, phba->rx_monitor, NULL, 0, in lpfc_cgn_dump_rxmonitor()
5605 * lpfc_cgn_update_stat - Save data into congestion stats buffer
5618 if (!phba->cgn_i) in lpfc_cgn_update_stat()
5620 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_cgn_update_stat()
5625 le32_add_cpu(&cp->link_integ_notification, 1); in lpfc_cgn_update_stat()
5626 lpfc_cgn_update_tstamp(phba, &cp->stat_lnk); in lpfc_cgn_update_stat()
5629 le32_add_cpu(&cp->delivery_notification, 1); in lpfc_cgn_update_stat()
5630 lpfc_cgn_update_tstamp(phba, &cp->stat_delivery); in lpfc_cgn_update_stat()
5633 le32_add_cpu(&cp->cgn_peer_notification, 1); in lpfc_cgn_update_stat()
5634 lpfc_cgn_update_tstamp(phba, &cp->stat_peer); in lpfc_cgn_update_stat()
5637 le32_add_cpu(&cp->cgn_notification, 1); in lpfc_cgn_update_stat()
5638 lpfc_cgn_update_tstamp(phba, &cp->stat_fpin); in lpfc_cgn_update_stat()
5640 if (phba->cgn_fpin_frequency && in lpfc_cgn_update_stat()
5641 phba->cgn_fpin_frequency != LPFC_FPIN_INIT_FREQ) { in lpfc_cgn_update_stat()
5642 value = LPFC_CGN_TIMER_TO_MIN / phba->cgn_fpin_frequency; in lpfc_cgn_update_stat()
5643 cp->cgn_stat_npm = value; in lpfc_cgn_update_stat()
5648 cp->cgn_info_crc = cpu_to_le32(value); in lpfc_cgn_update_stat()
5652 * lpfc_cgn_update_tstamp - Update cmf timestamp
5665 ts->month = tm_val.tm_mon + 1; in lpfc_cgn_update_tstamp()
5666 ts->day = tm_val.tm_mday; in lpfc_cgn_update_tstamp()
5667 ts->year = tm_val.tm_year - 100; in lpfc_cgn_update_tstamp()
5668 ts->hour = tm_val.tm_hour; in lpfc_cgn_update_tstamp()
5669 ts->minute = tm_val.tm_min; in lpfc_cgn_update_tstamp()
5670 ts->second = tm_val.tm_sec; in lpfc_cgn_update_tstamp()
5675 ts->day, ts->month, in lpfc_cgn_update_tstamp()
5676 ts->year, ts->hour, in lpfc_cgn_update_tstamp()
5677 ts->minute, ts->second); in lpfc_cgn_update_tstamp()
5681 * lpfc_cmf_stats_timer - Save data into registered congestion buffer
5707 if (!phba->cgn_i) in lpfc_cmf_stats_timer()
5709 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_cmf_stats_timer()
5711 phba->cgn_evt_timestamp = jiffies + in lpfc_cmf_stats_timer()
5713 phba->cgn_evt_minute++; in lpfc_cmf_stats_timer()
5716 lpfc_cgn_update_tstamp(phba, &cp->base_time); in lpfc_cmf_stats_timer()
5718 if (phba->cgn_fpin_frequency && in lpfc_cmf_stats_timer()
5719 phba->cgn_fpin_frequency != LPFC_FPIN_INIT_FREQ) { in lpfc_cmf_stats_timer()
5720 value = LPFC_CGN_TIMER_TO_MIN / phba->cgn_fpin_frequency; in lpfc_cmf_stats_timer()
5721 cp->cgn_stat_npm = value; in lpfc_cmf_stats_timer()
5725 lvalue = atomic_read(&phba->cgn_latency_evt_cnt); in lpfc_cmf_stats_timer()
5726 latsum = atomic64_read(&phba->cgn_latency_evt); in lpfc_cmf_stats_timer()
5727 atomic_set(&phba->cgn_latency_evt_cnt, 0); in lpfc_cmf_stats_timer()
5728 atomic64_set(&phba->cgn_latency_evt, 0); in lpfc_cmf_stats_timer()
5734 bps = div_u64(phba->rx_block_cnt, LPFC_SEC_MIN) * 512; in lpfc_cmf_stats_timer()
5735 phba->rx_block_cnt = 0; in lpfc_cmf_stats_timer()
5740 cp->cgn_info_mode = phba->cgn_p.cgn_param_mode; in lpfc_cmf_stats_timer()
5741 cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0; in lpfc_cmf_stats_timer()
5742 cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1; in lpfc_cmf_stats_timer()
5743 cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2; in lpfc_cmf_stats_timer()
5746 value = (uint16_t)(phba->pport->cfg_lun_queue_depth); in lpfc_cmf_stats_timer()
5747 cp->cgn_lunq = cpu_to_le16(value); in lpfc_cmf_stats_timer()
5749 /* Record congestion buffer info - every minute in lpfc_cmf_stats_timer()
5755 index = ++cp->cgn_index_minute; in lpfc_cmf_stats_timer()
5756 if (cp->cgn_index_minute == LPFC_MIN_HOUR) { in lpfc_cmf_stats_timer()
5757 cp->cgn_index_minute = 0; in lpfc_cmf_stats_timer()
5762 dvalue = atomic_read(&phba->cgn_driver_evt_cnt); in lpfc_cmf_stats_timer()
5763 atomic_set(&phba->cgn_driver_evt_cnt, 0); in lpfc_cmf_stats_timer()
5765 /* Get the number of warning events - FPIN and Signal for this minute */ in lpfc_cmf_stats_timer()
5767 if ((phba->cgn_reg_fpin & LPFC_CGN_FPIN_WARN) || in lpfc_cmf_stats_timer()
5768 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY || in lpfc_cmf_stats_timer()
5769 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) in lpfc_cmf_stats_timer()
5770 wvalue = atomic_read(&phba->cgn_fabric_warn_cnt); in lpfc_cmf_stats_timer()
5771 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_cmf_stats_timer()
5773 /* Get the number of alarm events - FPIN and Signal for this minute */ in lpfc_cmf_stats_timer()
5775 if ((phba->cgn_reg_fpin & LPFC_CGN_FPIN_ALARM) || in lpfc_cmf_stats_timer()
5776 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) in lpfc_cmf_stats_timer()
5777 avalue = atomic_read(&phba->cgn_fabric_alarm_cnt); in lpfc_cmf_stats_timer()
5778 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_cmf_stats_timer()
5783 ptr = &cp->cgn_drvr_min[index]; in lpfc_cmf_stats_timer()
5787 ptr = &cp->cgn_warn_min[index]; in lpfc_cmf_stats_timer()
5791 ptr = &cp->cgn_alarm_min[index]; in lpfc_cmf_stats_timer()
5795 lptr = &cp->cgn_latency_min[index]; in lpfc_cmf_stats_timer()
5804 mptr = &cp->cgn_bw_min[index]; in lpfc_cmf_stats_timer()
5808 "2418 Congestion Info - minute (%d): %d %d %d %d %d\n", in lpfc_cmf_stats_timer()
5812 if ((phba->cgn_evt_minute % LPFC_MIN_HOUR) == 0) { in lpfc_cmf_stats_timer()
5813 /* Record congestion buffer info - every hour in lpfc_cmf_stats_timer()
5816 index = ++cp->cgn_index_hour; in lpfc_cmf_stats_timer()
5817 if (cp->cgn_index_hour == LPFC_HOUR_DAY) { in lpfc_cmf_stats_timer()
5818 cp->cgn_index_hour = 0; in lpfc_cmf_stats_timer()
5829 dvalue += le16_to_cpu(cp->cgn_drvr_min[i]); in lpfc_cmf_stats_timer()
5830 wvalue += le16_to_cpu(cp->cgn_warn_min[i]); in lpfc_cmf_stats_timer()
5831 lvalue += le32_to_cpu(cp->cgn_latency_min[i]); in lpfc_cmf_stats_timer()
5832 mbps += le16_to_cpu(cp->cgn_bw_min[i]); in lpfc_cmf_stats_timer()
5833 avalue += le16_to_cpu(cp->cgn_alarm_min[i]); in lpfc_cmf_stats_timer()
5840 lptr = &cp->cgn_drvr_hr[index]; in lpfc_cmf_stats_timer()
5842 lptr = &cp->cgn_warn_hr[index]; in lpfc_cmf_stats_timer()
5844 lptr = &cp->cgn_latency_hr[index]; in lpfc_cmf_stats_timer()
5846 mptr = &cp->cgn_bw_hr[index]; in lpfc_cmf_stats_timer()
5848 lptr = &cp->cgn_alarm_hr[index]; in lpfc_cmf_stats_timer()
5852 "2419 Congestion Info - hour " in lpfc_cmf_stats_timer()
5858 if ((phba->cgn_evt_minute % LPFC_MIN_DAY) == 0) { in lpfc_cmf_stats_timer()
5859 /* Record congestion buffer info - every hour in lpfc_cmf_stats_timer()
5863 index = ++cp->cgn_index_day; in lpfc_cmf_stats_timer()
5864 if (cp->cgn_index_day == LPFC_MAX_CGN_DAYS) { in lpfc_cmf_stats_timer()
5865 cp->cgn_index_day = 0; in lpfc_cmf_stats_timer()
5876 dvalue += le32_to_cpu(cp->cgn_drvr_hr[i]); in lpfc_cmf_stats_timer()
5877 wvalue += le32_to_cpu(cp->cgn_warn_hr[i]); in lpfc_cmf_stats_timer()
5878 lvalue += le32_to_cpu(cp->cgn_latency_hr[i]); in lpfc_cmf_stats_timer()
5879 mbps += le16_to_cpu(cp->cgn_bw_hr[i]); in lpfc_cmf_stats_timer()
5880 avalue += le32_to_cpu(cp->cgn_alarm_hr[i]); in lpfc_cmf_stats_timer()
5887 lptr = &cp->cgn_drvr_day[index]; in lpfc_cmf_stats_timer()
5889 lptr = &cp->cgn_warn_day[index]; in lpfc_cmf_stats_timer()
5891 lptr = &cp->cgn_latency_day[index]; in lpfc_cmf_stats_timer()
5893 mptr = &cp->cgn_bw_day[index]; in lpfc_cmf_stats_timer()
5895 lptr = &cp->cgn_alarm_day[index]; in lpfc_cmf_stats_timer()
5899 "2420 Congestion Info - daily (%d): " in lpfc_cmf_stats_timer()
5905 value = phba->cgn_fpin_frequency; in lpfc_cmf_stats_timer()
5906 cp->cgn_warn_freq = cpu_to_le16(value); in lpfc_cmf_stats_timer()
5907 cp->cgn_alarm_freq = cpu_to_le16(value); in lpfc_cmf_stats_timer()
5911 cp->cgn_info_crc = cpu_to_le32(lvalue); in lpfc_cmf_stats_timer()
5919 * lpfc_calc_cmf_latency - latency from start of rxate timer interval
5937 if (cmpl_time.tv_sec == phba->cmf_latency.tv_sec) { in lpfc_calc_cmf_latency()
5938 msec = (cmpl_time.tv_nsec - phba->cmf_latency.tv_nsec) / in lpfc_calc_cmf_latency()
5941 if (cmpl_time.tv_nsec >= phba->cmf_latency.tv_nsec) { in lpfc_calc_cmf_latency()
5942 msec = (cmpl_time.tv_sec - in lpfc_calc_cmf_latency()
5943 phba->cmf_latency.tv_sec) * MSEC_PER_SEC; in lpfc_calc_cmf_latency()
5944 msec += ((cmpl_time.tv_nsec - in lpfc_calc_cmf_latency()
5945 phba->cmf_latency.tv_nsec) / NSEC_PER_MSEC); in lpfc_calc_cmf_latency()
5947 msec = (cmpl_time.tv_sec - phba->cmf_latency.tv_sec - in lpfc_calc_cmf_latency()
5949 msec += (((NSEC_PER_SEC - phba->cmf_latency.tv_nsec) + in lpfc_calc_cmf_latency()
5957 * lpfc_cmf_timer - This is the timer function for one congestion
5976 if (phba->cmf_active_mode == LPFC_CFG_OFF || in lpfc_cmf_timer()
5977 !phba->cmf_latency.tv_sec) { in lpfc_cmf_timer()
5980 phba->cmf_active_mode, in lpfc_cmf_timer()
5981 (uint64_t)phba->cmf_latency.tv_sec); in lpfc_cmf_timer()
5988 if (!phba->pport) in lpfc_cmf_timer()
5994 atomic_set(&phba->cmf_stop_io, 1); in lpfc_cmf_timer()
6008 ktime_get_real_ts64(&phba->cmf_latency); in lpfc_cmf_timer()
6010 phba->cmf_link_byte_count = in lpfc_cmf_timer()
6011 div_u64(phba->cmf_max_line_rate * LPFC_CMF_INTERVAL, 1000); in lpfc_cmf_timer()
6019 cgs = per_cpu_ptr(phba->cmf_stat, cpu); in lpfc_cmf_timer()
6020 total += atomic64_xchg(&cgs->total_bytes, 0); in lpfc_cmf_timer()
6021 io_cnt += atomic_xchg(&cgs->rx_io_cnt, 0); in lpfc_cmf_timer()
6022 lat += atomic64_xchg(&cgs->rx_latency, 0); in lpfc_cmf_timer()
6023 rcv += atomic64_xchg(&cgs->rcv_bytes, 0); in lpfc_cmf_timer()
6031 if (phba->cmf_active_mode == LPFC_CFG_MANAGED && in lpfc_cmf_timer()
6032 phba->link_state != LPFC_LINK_DOWN && in lpfc_cmf_timer()
6033 test_bit(HBA_SETUP, &phba->hba_flag)) { in lpfc_cmf_timer()
6034 mbpi = phba->cmf_last_sync_bw; in lpfc_cmf_timer()
6035 phba->cmf_last_sync_bw = 0; in lpfc_cmf_timer()
6046 extra = cnt - total; in lpfc_cmf_timer()
6053 mbpi = phba->cmf_link_byte_count; in lpfc_cmf_timer()
6056 phba->cmf_timer_cnt++; in lpfc_cmf_timer()
6059 /* Update congestion info buffer latency in us */ in lpfc_cmf_timer()
6060 atomic_add(io_cnt, &phba->cgn_latency_evt_cnt); in lpfc_cmf_timer()
6061 atomic64_add(lat, &phba->cgn_latency_evt); in lpfc_cmf_timer()
6063 busy = atomic_xchg(&phba->cmf_busy, 0); in lpfc_cmf_timer()
6064 max_read = atomic_xchg(&phba->rx_max_read_cnt, 0); in lpfc_cmf_timer()
6068 if (mbpi > phba->cmf_link_byte_count || in lpfc_cmf_timer()
6069 phba->cmf_active_mode == LPFC_CFG_MONITOR) in lpfc_cmf_timer()
6070 mbpi = phba->cmf_link_byte_count; in lpfc_cmf_timer()
6075 if (mbpi != phba->cmf_max_bytes_per_interval) in lpfc_cmf_timer()
6076 phba->cmf_max_bytes_per_interval = mbpi; in lpfc_cmf_timer()
6080 if (phba->rx_monitor) { in lpfc_cmf_timer()
6085 entry.cmf_info = phba->cmf_active_info; in lpfc_cmf_timer()
6096 if (phba->cmf_active_mode == LPFC_CFG_MANAGED) in lpfc_cmf_timer()
6097 entry.timer_utilization = phba->cmf_last_ts; in lpfc_cmf_timer()
6101 phba->cmf_last_ts = 0; in lpfc_cmf_timer()
6103 lpfc_rx_monitor_record(phba->rx_monitor, &entry); in lpfc_cmf_timer()
6106 if (phba->cmf_active_mode == LPFC_CFG_MONITOR) { in lpfc_cmf_timer()
6111 atomic_inc(&phba->cgn_driver_evt_cnt); in lpfc_cmf_timer()
6113 phba->rx_block_cnt += div_u64(rcv, 512); /* save 512 byte block cnt */ in lpfc_cmf_timer()
6118 if (atomic_xchg(&phba->cmf_bw_wait, 0)) in lpfc_cmf_timer()
6119 queue_work(phba->wq, &phba->unblock_request_work); in lpfc_cmf_timer()
6122 atomic_set(&phba->cmf_stop_io, 0); in lpfc_cmf_timer()
6132 ((phba->trunk_link.link##__idx.state == LPFC_LINK_UP) ?\
6147 phba->sli4_hba.link_state.speed = in lpfc_update_trunk_link_status()
6151 phba->sli4_hba.link_state.logical_speed = in lpfc_update_trunk_link_status()
6154 phba->fc_linkspeed = in lpfc_update_trunk_link_status()
6160 phba->trunk_link.link0.state = in lpfc_update_trunk_link_status()
6163 phba->trunk_link.link0.fault = port_fault & 0x1 ? err : 0; in lpfc_update_trunk_link_status()
6167 phba->trunk_link.link1.state = in lpfc_update_trunk_link_status()
6170 phba->trunk_link.link1.fault = port_fault & 0x2 ? err : 0; in lpfc_update_trunk_link_status()
6174 phba->trunk_link.link2.state = in lpfc_update_trunk_link_status()
6177 phba->trunk_link.link2.fault = port_fault & 0x4 ? err : 0; in lpfc_update_trunk_link_status()
6181 phba->trunk_link.link3.state = in lpfc_update_trunk_link_status()
6184 phba->trunk_link.link3.fault = port_fault & 0x8 ? err : 0; in lpfc_update_trunk_link_status()
6189 phba->trunk_link.phy_lnk_speed = in lpfc_update_trunk_link_status()
6190 phba->sli4_hba.link_state.logical_speed / (cnt * 1000); in lpfc_update_trunk_link_status()
6192 phba->trunk_link.phy_lnk_speed = LPFC_LINK_SPEED_UNKNOWN; in lpfc_update_trunk_link_status()
6195 "2910 Async FC Trunking Event - Speed:%d\n" in lpfc_update_trunk_link_status()
6198 phba->sli4_hba.link_state.speed, in lpfc_update_trunk_link_status()
6199 phba->sli4_hba.link_state.logical_speed, in lpfc_update_trunk_link_status()
6203 if (phba->cmf_active_mode != LPFC_CFG_OFF) in lpfc_update_trunk_link_status()
6210 * SLI-4: We have only 0xA error codes in lpfc_update_trunk_link_status()
6222 * lpfc_sli4_async_fc_evt - Process the asynchronous FC link event
6254 phba->sli4_hba.link_state.speed = in lpfc_sli4_async_fc_evt()
6257 phba->sli4_hba.link_state.duplex = LPFC_ASYNC_LINK_DUPLEX_FULL; in lpfc_sli4_async_fc_evt()
6258 phba->sli4_hba.link_state.topology = in lpfc_sli4_async_fc_evt()
6260 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
6262 phba->sli4_hba.link_state.type = in lpfc_sli4_async_fc_evt()
6264 phba->sli4_hba.link_state.number = in lpfc_sli4_async_fc_evt()
6266 phba->sli4_hba.link_state.fault = in lpfc_sli4_async_fc_evt()
6268 phba->sli4_hba.link_state.link_status = in lpfc_sli4_async_fc_evt()
6275 if (phba->sli4_hba.link_state.status >= LPFC_FC_LA_TYPE_LINK_UP && in lpfc_sli4_async_fc_evt()
6276 phba->sli4_hba.link_state.status < LPFC_FC_LA_TYPE_ACTIVATE_FAIL) { in lpfc_sli4_async_fc_evt()
6279 phba->sli4_hba.link_state.logical_speed = 0; in lpfc_sli4_async_fc_evt()
6280 else if (!phba->sli4_hba.conf_trunk) in lpfc_sli4_async_fc_evt()
6281 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_fc_evt()
6286 "2896 Async FC event - Speed:%dGBaud Topology:x%x " in lpfc_sli4_async_fc_evt()
6289 phba->sli4_hba.link_state.speed, in lpfc_sli4_async_fc_evt()
6290 phba->sli4_hba.link_state.topology, in lpfc_sli4_async_fc_evt()
6291 phba->sli4_hba.link_state.status, in lpfc_sli4_async_fc_evt()
6292 phba->sli4_hba.link_state.type, in lpfc_sli4_async_fc_evt()
6293 phba->sli4_hba.link_state.number, in lpfc_sli4_async_fc_evt()
6294 phba->sli4_hba.link_state.logical_speed, in lpfc_sli4_async_fc_evt()
6295 phba->sli4_hba.link_state.fault, in lpfc_sli4_async_fc_evt()
6296 phba->sli4_hba.link_state.link_status); in lpfc_sli4_async_fc_evt()
6303 if (phba->sli4_hba.link_state.status >= LPFC_FC_LA_TYPE_ACTIVATE_FAIL) { in lpfc_sli4_async_fc_evt()
6304 switch (phba->sli4_hba.link_state.status) { in lpfc_sli4_async_fc_evt()
6307 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
6318 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
6326 "2992 Async FC event - Informational Link " in lpfc_sli4_async_fc_evt()
6332 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_async_fc_evt()
6349 phba->sli4_hba.els_wq->pring->flag |= LPFC_STOP_IOCB_EVENT; in lpfc_sli4_async_fc_evt()
6352 phba->sli.slistat.link_event++; in lpfc_sli4_async_fc_evt()
6355 lpfc_read_topology(phba, pmb, pmb->ctx_buf); in lpfc_sli4_async_fc_evt()
6356 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_sli4_async_fc_evt()
6357 pmb->vport = phba->pport; in lpfc_sli4_async_fc_evt()
6359 if (phba->sli4_hba.link_state.status != LPFC_FC_LA_TYPE_LINK_UP) { in lpfc_sli4_async_fc_evt()
6360 phba->link_flag &= ~(LS_MDS_LINK_DOWN | LS_MDS_LOOPBACK); in lpfc_sli4_async_fc_evt()
6362 switch (phba->sli4_hba.link_state.status) { in lpfc_sli4_async_fc_evt()
6364 phba->link_flag |= LS_MDS_LINK_DOWN; in lpfc_sli4_async_fc_evt()
6367 phba->link_flag |= LS_MDS_LOOPBACK; in lpfc_sli4_async_fc_evt()
6374 mb = &pmb->u.mb; in lpfc_sli4_async_fc_evt()
6375 mb->mbxStatus = MBX_SUCCESS; in lpfc_sli4_async_fc_evt()
6381 la = (struct lpfc_mbx_read_top *)&pmb->u.mb.un.varReadTop; in lpfc_sli4_async_fc_evt()
6382 la->eventTag = acqe_fc->event_tag; in lpfc_sli4_async_fc_evt()
6384 if (phba->sli4_hba.link_state.status == in lpfc_sli4_async_fc_evt()
6408 * lpfc_sli4_async_sli_evt - Process the asynchronous SLI link event
6432 "2901 Async SLI event - Type:%d, Event Data: x%08x " in lpfc_sli4_async_sli_evt()
6434 acqe_sli->event_data1, acqe_sli->event_data2, in lpfc_sli4_async_sli_evt()
6435 acqe_sli->event_data3, acqe_sli->trailer); in lpfc_sli4_async_sli_evt()
6437 port_name = phba->Port[0]; in lpfc_sli4_async_sli_evt()
6445 temp_event_data.data = (uint32_t)acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6448 "3190 Over Temperature:%d Celsius- Port Name %c\n", in lpfc_sli4_async_sli_evt()
6449 acqe_sli->event_data1, port_name); in lpfc_sli4_async_sli_evt()
6451 phba->sfp_warning |= LPFC_TRANSGRESSION_HIGH_TEMPERATURE; in lpfc_sli4_async_sli_evt()
6452 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli4_async_sli_evt()
6462 temp_event_data.data = (uint32_t)acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6465 "3191 Normal Temperature:%d Celsius - Port Name %c\n", in lpfc_sli4_async_sli_evt()
6466 acqe_sli->event_data1, port_name); in lpfc_sli4_async_sli_evt()
6468 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli4_async_sli_evt()
6477 &acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6480 switch (phba->sli4_hba.lnk_info.lnk_no) { in lpfc_sli4_async_sli_evt()
6483 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6485 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6489 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6491 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6495 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6497 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6501 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6503 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6510 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_async_sli_evt()
6515 if (phba->sli4_hba.lnk_info.optic_state == status) in lpfc_sli4_async_sli_evt()
6524 "installed/not installed - Reseat optics, " in lpfc_sli4_async_sli_evt()
6529 "Optics of two types installed - Remove one " in lpfc_sli4_async_sli_evt()
6533 sprintf(message, "Incompatible optics - Replace with " in lpfc_sli4_async_sli_evt()
6537 sprintf(message, "Unqualified optics - Replace with " in lpfc_sli4_async_sli_evt()
6539 "Support - Link is%s operational", in lpfc_sli4_async_sli_evt()
6543 sprintf(message, "Uncertified optics - Replace with " in lpfc_sli4_async_sli_evt()
6544 "Avago-certified optics to enable link " in lpfc_sli4_async_sli_evt()
6545 "operation - Link is%s operational", in lpfc_sli4_async_sli_evt()
6557 phba->lmt = 0; in lpfc_sli4_async_sli_evt()
6571 for (i = 0; i <= phba->max_vports && vports[i] != NULL; in lpfc_sli4_async_sli_evt()
6579 phba->sli4_hba.lnk_info.optic_state = status; in lpfc_sli4_async_sli_evt()
6585 "3192 Remote DPort Test Initiated - " in lpfc_sli4_async_sli_evt()
6587 acqe_sli->event_data1, acqe_sli->event_data2); in lpfc_sli4_async_sli_evt()
6595 * to use FA-WWN, but the attached device doesn’t support it. in lpfc_sli4_async_sli_evt()
6596 * Event Data1 - N.A, Event Data2 - N.A in lpfc_sli4_async_sli_evt()
6600 "2699 Misconfigured FA-PWWN - Attached device " in lpfc_sli4_async_sli_evt()
6601 "does not support FA-PWWN\n"); in lpfc_sli4_async_sli_evt()
6602 phba->sli4_hba.fawwpn_flag &= ~LPFC_FAWWPN_FABRIC; in lpfc_sli4_async_sli_evt()
6603 memset(phba->pport->fc_portname.u.wwn, 0, in lpfc_sli4_async_sli_evt()
6609 "2518 EEPROM failure - " in lpfc_sli4_async_sli_evt()
6611 acqe_sli->event_data1, acqe_sli->event_data2); in lpfc_sli4_async_sli_evt()
6614 if (phba->cmf_active_mode == LPFC_CFG_OFF) in lpfc_sli4_async_sli_evt()
6617 &acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6618 phba->cgn_acqe_cnt++; in lpfc_sli4_async_sli_evt()
6621 atomic64_add(cnt, &phba->cgn_acqe_stat.warn); in lpfc_sli4_async_sli_evt()
6622 atomic64_add(cgn_signal->alarm_cnt, &phba->cgn_acqe_stat.alarm); in lpfc_sli4_async_sli_evt()
6627 if (cgn_signal->alarm_cnt) { in lpfc_sli4_async_sli_evt()
6628 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { in lpfc_sli4_async_sli_evt()
6630 atomic_add(cgn_signal->alarm_cnt, in lpfc_sli4_async_sli_evt()
6631 &phba->cgn_sync_alarm_cnt); in lpfc_sli4_async_sli_evt()
6635 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY || in lpfc_sli4_async_sli_evt()
6636 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { in lpfc_sli4_async_sli_evt()
6638 atomic_add(cnt, &phba->cgn_sync_warn_cnt); in lpfc_sli4_async_sli_evt()
6648 acqe_sli->event_data1, acqe_sli->event_data2, in lpfc_sli4_async_sli_evt()
6649 acqe_sli->event_data3); in lpfc_sli4_async_sli_evt()
6665 * lpfc_sli4_perform_vport_cvl - Perform clear virtual link on a vport
6683 phba = vport->phba; in lpfc_sli4_perform_vport_cvl()
6693 ndlp->nlp_type |= NLP_FABRIC; in lpfc_sli4_perform_vport_cvl()
6697 if ((phba->pport->port_state < LPFC_FLOGI) && in lpfc_sli4_perform_vport_cvl()
6698 (phba->pport->port_state != LPFC_VPORT_FAILED)) in lpfc_sli4_perform_vport_cvl()
6701 if ((vport != phba->pport) && (vport->port_state < LPFC_FDISC) in lpfc_sli4_perform_vport_cvl()
6702 && (vport->port_state != LPFC_VPORT_FAILED)) in lpfc_sli4_perform_vport_cvl()
6709 set_bit(FC_VPORT_CVL_RCVD, &vport->fc_flag); in lpfc_sli4_perform_vport_cvl()
6715 * lpfc_sli4_perform_all_vport_cvl - Perform clear virtual link on all vports
6729 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) in lpfc_sli4_perform_all_vport_cvl()
6735 * lpfc_sli4_async_fip_evt - Process the asynchronous FCoE FIP event
6753 phba->fc_eventTag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6754 phba->fcoe_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6762 acqe_fip->event_tag, in lpfc_sli4_async_fip_evt()
6763 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6769 acqe_fip->event_tag, in lpfc_sli4_async_fip_evt()
6770 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6771 if (phba->fcf.fcf_flag & FCF_DISCOVERY) { in lpfc_sli4_async_fip_evt()
6781 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6782 rc = lpfc_sli4_read_fcf_rec(phba, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6786 if (test_bit(FCF_TS_INPROG, &phba->hba_flag)) in lpfc_sli4_async_fip_evt()
6788 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6790 if (phba->fcf.fcf_flag & (FCF_REDISC_EVT | FCF_REDISC_PEND)) { in lpfc_sli4_async_fip_evt()
6791 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6796 if (phba->fcf.fcf_flag & FCF_SCAN_DONE) { in lpfc_sli4_async_fip_evt()
6797 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6800 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6802 /* Otherwise, scan the entire FCF table and re-discover SAN */ in lpfc_sli4_async_fip_evt()
6806 acqe_fip->event_tag, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6819 acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6823 phba->fcoe_cvl_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6826 "tag:x%x\n", acqe_fip->index, in lpfc_sli4_async_fip_evt()
6827 acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6832 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6833 if ((phba->fcf.fcf_flag & FCF_DISCOVERY) && in lpfc_sli4_async_fip_evt()
6834 (phba->fcf.current_rec.fcf_indx != acqe_fip->index)) { in lpfc_sli4_async_fip_evt()
6835 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6837 lpfc_sli4_fcf_rr_index_clear(phba, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6840 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6843 if (phba->fcf.current_rec.fcf_indx != acqe_fip->index) in lpfc_sli4_async_fip_evt()
6852 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6854 phba->fcf.fcf_flag |= FCF_DEAD_DISC; in lpfc_sli4_async_fip_evt()
6855 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6860 "\n", acqe_fip->event_tag, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6868 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6869 phba->fcf.fcf_flag &= ~FCF_DEAD_DISC; in lpfc_sli4_async_fip_evt()
6870 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6887 phba->fcoe_cvl_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6891 " tag 0x%x\n", acqe_fip->index, acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6894 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6902 for (i = 0; i <= phba->max_vports && vports[i] != NULL; in lpfc_sli4_async_fip_evt()
6905 &vports[i]->fc_flag) && in lpfc_sli4_async_fip_evt()
6906 vports[i]->port_state > LPFC_FDISC) { in lpfc_sli4_async_fip_evt()
6915 * Don't re-instantiate if vport is marked for deletion. in lpfc_sli4_async_fip_evt()
6919 if (!test_bit(FC_UNLOADING, &vport->load_flag) && in lpfc_sli4_async_fip_evt()
6923 * re-instantiate the Vlink using FDISC. in lpfc_sli4_async_fip_evt()
6925 mod_timer(&ndlp->nlp_delayfunc, in lpfc_sli4_async_fip_evt()
6927 set_bit(NLP_DELAY_TMO, &ndlp->nlp_flag); in lpfc_sli4_async_fip_evt()
6928 ndlp->nlp_last_elscmd = ELS_CMD_FDISC; in lpfc_sli4_async_fip_evt()
6929 vport->port_state = LPFC_FDISC; in lpfc_sli4_async_fip_evt()
6938 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6939 if (phba->fcf.fcf_flag & FCF_DISCOVERY) { in lpfc_sli4_async_fip_evt()
6940 spin_unlock_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()
6949 "evt_tag:x%x\n", acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6957 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6958 phba->fcf.fcf_flag &= ~FCF_ACVL_DISC; in lpfc_sli4_async_fip_evt()
6959 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6961 * Last resort will be re-try on the in lpfc_sli4_async_fip_evt()
6976 "0x%x\n", event_type, acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6982 * lpfc_sli4_async_dcbx_evt - Process the asynchronous dcbx event
6992 phba->fc_eventTag = acqe_dcbx->event_tag; in lpfc_sli4_async_dcbx_evt()
6999 * lpfc_sli4_async_grp5_evt - Process the asynchronous group5 event
7013 phba->fc_eventTag = acqe_grp5->event_tag; in lpfc_sli4_async_grp5_evt()
7014 phba->fcoe_eventtag = acqe_grp5->event_tag; in lpfc_sli4_async_grp5_evt()
7015 prev_ll_spd = phba->sli4_hba.link_state.logical_speed; in lpfc_sli4_async_grp5_evt()
7016 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_grp5_evt()
7021 phba->sli4_hba.link_state.logical_speed); in lpfc_sli4_async_grp5_evt()
7025 * lpfc_sli4_async_cmstat_evt - Process the asynchronous cmstat event
7034 if (!phba->cgn_i) in lpfc_sli4_async_cmstat_evt()
7040 * lpfc_cgn_params_val - Validate FW congestion parameters.
7050 spin_lock_irq(&phba->hbalock); in lpfc_cgn_params_val()
7052 if (!lpfc_rangecheck(p_cfg_param->cgn_param_mode, LPFC_CFG_OFF, in lpfc_cgn_params_val()
7056 p_cfg_param->cgn_param_mode); in lpfc_cgn_params_val()
7057 p_cfg_param->cgn_param_mode = LPFC_CFG_OFF; in lpfc_cgn_params_val()
7060 spin_unlock_irq(&phba->hbalock); in lpfc_cgn_params_val()
7070 * lpfc_cgn_params_parse - Process a FW cong parm change event
7077 * valid, in-range values. If the signature magic is correct and
7093 if (p_cgn_param->cgn_param_magic == LPFC_CFG_PARAM_MAGIC_NUM) { in lpfc_cgn_params_parse()
7101 p_cgn_param->cgn_param_magic, in lpfc_cgn_params_parse()
7102 p_cgn_param->cgn_param_version, in lpfc_cgn_params_parse()
7103 p_cgn_param->cgn_param_mode, in lpfc_cgn_params_parse()
7104 p_cgn_param->cgn_param_level0, in lpfc_cgn_params_parse()
7105 p_cgn_param->cgn_param_level1, in lpfc_cgn_params_parse()
7106 p_cgn_param->cgn_param_level2, in lpfc_cgn_params_parse()
7107 p_cgn_param->byte13, in lpfc_cgn_params_parse()
7108 p_cgn_param->byte14, in lpfc_cgn_params_parse()
7109 p_cgn_param->byte15, in lpfc_cgn_params_parse()
7110 p_cgn_param->byte11, in lpfc_cgn_params_parse()
7111 p_cgn_param->byte12, in lpfc_cgn_params_parse()
7112 phba->cmf_active_mode); in lpfc_cgn_params_parse()
7114 oldmode = phba->cmf_active_mode; in lpfc_cgn_params_parse()
7122 spin_lock_irq(&phba->hbalock); in lpfc_cgn_params_parse()
7123 memcpy(&phba->cgn_p, p_cgn_param, in lpfc_cgn_params_parse()
7127 if (phba->cgn_i) { in lpfc_cgn_params_parse()
7128 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_cgn_params_parse()
7129 cp->cgn_info_mode = phba->cgn_p.cgn_param_mode; in lpfc_cgn_params_parse()
7130 cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0; in lpfc_cgn_params_parse()
7131 cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1; in lpfc_cgn_params_parse()
7132 cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2; in lpfc_cgn_params_parse()
7135 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_cgn_params_parse()
7137 spin_unlock_irq(&phba->hbalock); in lpfc_cgn_params_parse()
7139 phba->cmf_active_mode = phba->cgn_p.cgn_param_mode; in lpfc_cgn_params_parse()
7143 if (phba->cgn_p.cgn_param_mode != LPFC_CFG_OFF) { in lpfc_cgn_params_parse()
7147 if (phba->link_state >= LPFC_LINK_UP) { in lpfc_cgn_params_parse()
7148 phba->cgn_reg_fpin = in lpfc_cgn_params_parse()
7149 phba->cgn_init_reg_fpin; in lpfc_cgn_params_parse()
7150 phba->cgn_reg_signal = in lpfc_cgn_params_parse()
7151 phba->cgn_init_reg_signal; in lpfc_cgn_params_parse()
7152 lpfc_issue_els_edc(phba->pport, 0); in lpfc_cgn_params_parse()
7157 switch (phba->cgn_p.cgn_param_mode) { in lpfc_cgn_params_parse()
7161 if (phba->link_state >= LPFC_LINK_UP) in lpfc_cgn_params_parse()
7162 lpfc_issue_els_edc(phba->pport, 0); in lpfc_cgn_params_parse()
7165 phba->cmf_max_bytes_per_interval = in lpfc_cgn_params_parse()
7166 phba->cmf_link_byte_count; in lpfc_cgn_params_parse()
7168 /* Resume blocked IO - unblock on workqueue */ in lpfc_cgn_params_parse()
7169 queue_work(phba->wq, in lpfc_cgn_params_parse()
7170 &phba->unblock_request_work); in lpfc_cgn_params_parse()
7175 switch (phba->cgn_p.cgn_param_mode) { in lpfc_cgn_params_parse()
7179 if (phba->link_state >= LPFC_LINK_UP) in lpfc_cgn_params_parse()
7180 lpfc_issue_els_edc(phba->pport, 0); in lpfc_cgn_params_parse()
7189 oldmode != phba->cgn_p.cgn_param_mode) { in lpfc_cgn_params_parse()
7190 if (phba->cgn_p.cgn_param_mode == LPFC_CFG_MANAGED) in lpfc_cgn_params_parse()
7192 phba->cgn_p.cgn_param_level0); in lpfc_cgn_params_parse()
7196 dev_info(&phba->pcidev->dev, "%d: " in lpfc_cgn_params_parse()
7198 phba->brd_no, in lpfc_cgn_params_parse()
7200 [phba->cgn_p.cgn_param_mode], in lpfc_cgn_params_parse()
7206 "version %d\n", p_cgn_param->cgn_param_magic, in lpfc_cgn_params_parse()
7207 p_cgn_param->cgn_param_version); in lpfc_cgn_params_parse()
7212 * lpfc_sli4_cgn_params_read - Read and Validate FW congestion parameters.
7221 * -Eval if an error was encountered
7236 return -ENOMEM; in lpfc_sli4_cgn_params_read()
7268 * lpfc_sli4_cgn_parm_chg_evt - Process a FW congestion param change event
7290 if (!phba->sli4_hba.pc_sli4_params.cmf) { in lpfc_sli4_cgn_parm_chg_evt()
7293 return -EACCES; in lpfc_sli4_cgn_parm_chg_evt()
7313 * lpfc_sli4_async_event_proc - Process all the pending asynchronous event
7325 clear_bit(ASYNC_EVENT, &phba->hba_flag); in lpfc_sli4_async_event_proc()
7328 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
7329 while (!list_empty(&phba->sli4_hba.sp_asynce_work_queue)) { in lpfc_sli4_async_event_proc()
7330 list_remove_head(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_async_event_proc()
7332 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, in lpfc_sli4_async_event_proc()
7336 switch (bf_get(lpfc_trailer_code, &cq_event->cqe.mcqe_cmpl)) { in lpfc_sli4_async_event_proc()
7339 &cq_event->cqe.acqe_link); in lpfc_sli4_async_event_proc()
7342 lpfc_sli4_async_fip_evt(phba, &cq_event->cqe.acqe_fip); in lpfc_sli4_async_event_proc()
7346 &cq_event->cqe.acqe_dcbx); in lpfc_sli4_async_event_proc()
7350 &cq_event->cqe.acqe_grp5); in lpfc_sli4_async_event_proc()
7353 lpfc_sli4_async_fc_evt(phba, &cq_event->cqe.acqe_fc); in lpfc_sli4_async_event_proc()
7356 lpfc_sli4_async_sli_evt(phba, &cq_event->cqe.acqe_sli); in lpfc_sli4_async_event_proc()
7363 &cq_event->cqe.mcqe_cmpl)); in lpfc_sli4_async_event_proc()
7369 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
7371 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
7375 * lpfc_sli4_fcf_redisc_event_proc - Process fcf table rediscovery event
7385 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_event_proc()
7386 /* Clear FCF rediscovery timeout event */ in lpfc_sli4_fcf_redisc_event_proc()
7387 phba->fcf.fcf_flag &= ~FCF_REDISC_EVT; in lpfc_sli4_fcf_redisc_event_proc()
7389 phba->fcf.failover_rec.flag = 0; in lpfc_sli4_fcf_redisc_event_proc()
7391 phba->fcf.fcf_flag |= FCF_REDISC_FOV; in lpfc_sli4_fcf_redisc_event_proc()
7392 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_event_proc()
7394 /* Scan FCF table from the first entry to re-discover SAN */ in lpfc_sli4_fcf_redisc_event_proc()
7396 "2777 Start post-quiescent FCF table scan\n"); in lpfc_sli4_fcf_redisc_event_proc()
7405 * lpfc_api_table_setup - Set up per hba pci-device group func api jump table
7407 * @dev_grp: The HBA PCI-Device group number.
7409 * This routine is invoked to set up the per HBA PCI-Device group function
7412 * Return: 0 if success, otherwise -ENODEV
7419 /* Set up lpfc PCI-device group */ in lpfc_api_table_setup()
7420 phba->pci_dev_grp = dev_grp; in lpfc_api_table_setup()
7424 phba->sli_rev = LPFC_SLI_REV4; in lpfc_api_table_setup()
7429 return -ENODEV; in lpfc_api_table_setup()
7433 return -ENODEV; in lpfc_api_table_setup()
7437 return -ENODEV; in lpfc_api_table_setup()
7441 return -ENODEV; in lpfc_api_table_setup()
7447 * lpfc_log_intr_mode - Log the active interrupt mode
7467 "0480 Enabled MSI-X interrupt mode.\n"); in lpfc_log_intr_mode()
7478 * lpfc_enable_pci_dev - Enable a generic PCI device.
7485 * 0 - successful
7486 * other values - error
7494 if (!phba->pcidev) in lpfc_enable_pci_dev()
7497 pdev = phba->pcidev; in lpfc_enable_pci_dev()
7511 pdev->needs_freset = 1; in lpfc_enable_pci_dev()
7520 return -ENODEV; in lpfc_enable_pci_dev()
7524 * lpfc_disable_pci_dev - Disable a generic PCI device.
7536 if (!phba->pcidev) in lpfc_disable_pci_dev()
7539 pdev = phba->pcidev; in lpfc_disable_pci_dev()
7548 * lpfc_reset_hba - Reset a hba
7562 if (!phba->cfg_enable_hba_reset) { in lpfc_reset_hba()
7563 phba->link_state = LPFC_HBA_ERROR; in lpfc_reset_hba()
7568 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE) { in lpfc_reset_hba()
7571 if (test_bit(MBX_TMO_ERR, &phba->bit_flags)) { in lpfc_reset_hba()
7580 clear_bit(MBX_TMO_ERR, &phba->bit_flags); in lpfc_reset_hba()
7593 * lpfc_sli_sriov_nr_virtfn_get - Get the number of sr-iov virtual functions
7596 * This function enables the PCI SR-IOV virtual functions to a physical
7597 * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
7599 * not all devices support SR-IOV, the return code from the pci_enable_sriov()
7605 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_sriov_nr_virtfn_get()
7618 * lpfc_sli_probe_sriov_nr_virtfn - Enable a number of sr-iov virtual functions
7622 * This function enables the PCI SR-IOV virtual functions to a physical
7623 * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
7625 * not all devices support SR-IOV, the return code from the pci_enable_sriov()
7631 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_probe_sriov_nr_virtfn()
7640 return -EINVAL; in lpfc_sli_probe_sriov_nr_virtfn()
7666 * lpfc_setup_driver_resource_phase1 - Phase1 etup driver internal resources.
7673 * 0 - successful
7674 * other values - error
7679 struct lpfc_sli *psli = &phba->sli; in lpfc_setup_driver_resource_phase1()
7684 atomic_set(&phba->fast_event_count, 0); in lpfc_setup_driver_resource_phase1()
7685 atomic_set(&phba->dbg_log_idx, 0); in lpfc_setup_driver_resource_phase1()
7686 atomic_set(&phba->dbg_log_cnt, 0); in lpfc_setup_driver_resource_phase1()
7687 atomic_set(&phba->dbg_log_dmping, 0); in lpfc_setup_driver_resource_phase1()
7688 spin_lock_init(&phba->hbalock); in lpfc_setup_driver_resource_phase1()
7691 spin_lock_init(&phba->port_list_lock); in lpfc_setup_driver_resource_phase1()
7692 INIT_LIST_HEAD(&phba->port_list); in lpfc_setup_driver_resource_phase1()
7694 INIT_LIST_HEAD(&phba->work_list); in lpfc_setup_driver_resource_phase1()
7697 init_waitqueue_head(&phba->work_waitq); in lpfc_setup_driver_resource_phase1()
7701 ((phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ? in lpfc_setup_driver_resource_phase1()
7703 ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) ? in lpfc_setup_driver_resource_phase1()
7705 (phba->nvmet_support ? "NVMET" : " ")); in lpfc_setup_driver_resource_phase1()
7708 spin_lock_init(&phba->ras_fwlog_lock); in lpfc_setup_driver_resource_phase1()
7711 spin_lock_init(&phba->scsi_buf_list_get_lock); in lpfc_setup_driver_resource_phase1()
7712 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_get); in lpfc_setup_driver_resource_phase1()
7713 spin_lock_init(&phba->scsi_buf_list_put_lock); in lpfc_setup_driver_resource_phase1()
7714 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_put); in lpfc_setup_driver_resource_phase1()
7717 INIT_LIST_HEAD(&phba->fabric_iocb_list); in lpfc_setup_driver_resource_phase1()
7720 INIT_LIST_HEAD(&phba->elsbuf); in lpfc_setup_driver_resource_phase1()
7723 INIT_LIST_HEAD(&phba->fcf_conn_rec_list); in lpfc_setup_driver_resource_phase1()
7726 spin_lock_init(&phba->devicelock); in lpfc_setup_driver_resource_phase1()
7727 INIT_LIST_HEAD(&phba->luns); in lpfc_setup_driver_resource_phase1()
7730 timer_setup(&psli->mbox_tmo, lpfc_mbox_timeout, 0); in lpfc_setup_driver_resource_phase1()
7732 timer_setup(&phba->fabric_block_timer, lpfc_fabric_block_timeout, 0); in lpfc_setup_driver_resource_phase1()
7734 timer_setup(&phba->eratt_poll, lpfc_poll_eratt, 0); in lpfc_setup_driver_resource_phase1()
7736 timer_setup(&phba->hb_tmofunc, lpfc_hb_timeout, 0); in lpfc_setup_driver_resource_phase1()
7738 INIT_DELAYED_WORK(&phba->eq_delay_work, lpfc_hb_eq_delay_work); in lpfc_setup_driver_resource_phase1()
7740 INIT_DELAYED_WORK(&phba->idle_stat_delay_work, in lpfc_setup_driver_resource_phase1()
7742 INIT_WORK(&phba->unblock_request_work, lpfc_unblock_requests_work); in lpfc_setup_driver_resource_phase1()
7747 * lpfc_sli_driver_resource_setup - Setup driver internal resources for SLI3 dev
7751 * support the SLI-3 HBA device it attached to.
7754 * 0 - successful
7755 * other values - error
7767 timer_setup(&phba->fcp_poll_timer, lpfc_poll_timeout, 0); in lpfc_sli_driver_resource_setup()
7770 phba->work_ha_mask = (HA_ERATT | HA_MBATT | HA_LATT); in lpfc_sli_driver_resource_setup()
7771 phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING * 4)); in lpfc_sli_driver_resource_setup()
7775 /* Set up phase-1 common device driver resources */ in lpfc_sli_driver_resource_setup()
7779 return -ENODEV; in lpfc_sli_driver_resource_setup()
7781 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
7782 phba->sli.sli3_ring = kcalloc(LPFC_SLI3_MAX_RING, in lpfc_sli_driver_resource_setup()
7785 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
7786 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7793 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_driver_resource_setup()
7799 if (phba->cfg_enable_bg) { in lpfc_sli_driver_resource_setup()
7801 * The scsi_buf for a T10-DIF I/O will hold the FCP cmnd, in lpfc_sli_driver_resource_setup()
7804 * will hand us (ie: there could be one for every block in lpfc_sli_driver_resource_setup()
7809 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
7813 if (phba->cfg_sg_seg_cnt > LPFC_MAX_SG_SEG_CNT_DIF) in lpfc_sli_driver_resource_setup()
7814 phba->cfg_sg_seg_cnt = LPFC_MAX_SG_SEG_CNT_DIF; in lpfc_sli_driver_resource_setup()
7817 phba->cfg_total_seg_cnt = LPFC_MAX_SG_SEG_CNT; in lpfc_sli_driver_resource_setup()
7824 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
7826 ((phba->cfg_sg_seg_cnt + 2) * entry_sz); in lpfc_sli_driver_resource_setup()
7829 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + 2; in lpfc_sli_driver_resource_setup()
7834 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
7835 phba->cfg_total_seg_cnt); in lpfc_sli_driver_resource_setup()
7837 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli_driver_resource_setup()
7839 phba->max_vports = 0; in lpfc_sli_driver_resource_setup()
7849 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7851 phba->lpfc_sg_dma_buf_pool = in lpfc_sli_driver_resource_setup()
7853 &phba->pcidev->dev, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
7856 if (!phba->lpfc_sg_dma_buf_pool) in lpfc_sli_driver_resource_setup()
7859 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli_driver_resource_setup()
7861 &phba->pcidev->dev, in lpfc_sli_driver_resource_setup()
7866 if (!phba->lpfc_cmd_rsp_buf_pool) in lpfc_sli_driver_resource_setup()
7870 * Enable sr-iov virtual functions if supported and configured in lpfc_sli_driver_resource_setup()
7873 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli_driver_resource_setup()
7875 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
7878 "2808 Requested number of SR-IOV " in lpfc_sli_driver_resource_setup()
7881 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
7882 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli_driver_resource_setup()
7889 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli_driver_resource_setup()
7890 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli_driver_resource_setup()
7893 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7897 * lpfc_sli_driver_resource_unset - Unset drvr internal resources for SLI3 dev
7901 * specific for supporting the SLI-3 HBA device it attached to.
7913 * lpfc_sli4_driver_resource_setup - Setup drvr internal resources for SLI4 dev
7917 * support the SLI-4 HBA device it attached to.
7920 * 0 - successful
7921 * other values - error
7933 phba->sli4_hba.num_present_cpu = lpfc_present_cpu; in lpfc_sli4_driver_resource_setup()
7934 phba->sli4_hba.num_possible_cpu = cpumask_last(cpu_possible_mask) + 1; in lpfc_sli4_driver_resource_setup()
7935 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_setup()
7940 /* Set up phase-1 common device driver resources */ in lpfc_sli4_driver_resource_setup()
7943 return -ENODEV; in lpfc_sli4_driver_resource_setup()
7948 return -ENODEV; in lpfc_sli4_driver_resource_setup()
7953 phba->wq = alloc_workqueue("lpfc_wq", WQ_MEM_RECLAIM, 0); in lpfc_sli4_driver_resource_setup()
7954 if (!phba->wq) in lpfc_sli4_driver_resource_setup()
7955 return -ENOMEM; in lpfc_sli4_driver_resource_setup()
7961 timer_setup(&phba->rrq_tmr, lpfc_rrq_timeout, 0); in lpfc_sli4_driver_resource_setup()
7964 timer_setup(&phba->fcf.redisc_wait, lpfc_sli4_fcf_redisc_wait_tmo, 0); in lpfc_sli4_driver_resource_setup()
7967 hrtimer_setup(&phba->cmf_timer, lpfc_cmf_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in lpfc_sli4_driver_resource_setup()
7969 hrtimer_setup(&phba->cmf_stats_timer, lpfc_cmf_stats_timer, CLOCK_MONOTONIC, in lpfc_sli4_driver_resource_setup()
7973 * Control structure for handling external multi-buffer mailbox in lpfc_sli4_driver_resource_setup()
7974 * command pass-through. in lpfc_sli4_driver_resource_setup()
7976 memset((uint8_t *)&phba->mbox_ext_buf_ctx, 0, in lpfc_sli4_driver_resource_setup()
7978 INIT_LIST_HEAD(&phba->mbox_ext_buf_ctx.ext_dmabuf_list); in lpfc_sli4_driver_resource_setup()
7980 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli4_driver_resource_setup()
7983 phba->max_vports = 0; in lpfc_sli4_driver_resource_setup()
7986 phba->valid_vlan = 0; in lpfc_sli4_driver_resource_setup()
7987 phba->fc_map[0] = LPFC_FCOE_FCF_MAP0; in lpfc_sli4_driver_resource_setup()
7988 phba->fc_map[1] = LPFC_FCOE_FCF_MAP1; in lpfc_sli4_driver_resource_setup()
7989 phba->fc_map[2] = LPFC_FCOE_FCF_MAP2; in lpfc_sli4_driver_resource_setup()
7998 INIT_LIST_HEAD(&phba->hbqs[LPFC_ELS_HBQ].hbq_buffer_list); in lpfc_sli4_driver_resource_setup()
7999 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_sli4_rb_alloc; in lpfc_sli4_driver_resource_setup()
8000 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_sli4_rb_free; in lpfc_sli4_driver_resource_setup()
8002 /* for VMID idle timeout if VMID is enabled */ in lpfc_sli4_driver_resource_setup()
8004 timer_setup(&phba->inactive_vmid_poll, lpfc_vmid_poll, 0); in lpfc_sli4_driver_resource_setup()
8010 spin_lock_init(&phba->sli4_hba.abts_io_buf_list_lock); in lpfc_sli4_driver_resource_setup()
8011 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_io_buf_list); in lpfc_sli4_driver_resource_setup()
8013 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
8015 spin_lock_init(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_sli4_driver_resource_setup()
8016 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_driver_resource_setup()
8017 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_io_wait_list); in lpfc_sli4_driver_resource_setup()
8018 spin_lock_init(&phba->sli4_hba.t_active_list_lock); in lpfc_sli4_driver_resource_setup()
8019 INIT_LIST_HEAD(&phba->sli4_hba.t_active_ctx_list); in lpfc_sli4_driver_resource_setup()
8023 spin_lock_init(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_driver_resource_setup()
8024 spin_lock_init(&phba->sli4_hba.nvmet_io_wait_lock); in lpfc_sli4_driver_resource_setup()
8025 spin_lock_init(&phba->sli4_hba.asynce_list_lock); in lpfc_sli4_driver_resource_setup()
8026 spin_lock_init(&phba->sli4_hba.els_xri_abrt_list_lock); in lpfc_sli4_driver_resource_setup()
8029 * Initialize driver internal slow-path work queues in lpfc_sli4_driver_resource_setup()
8032 /* Driver internel slow-path CQ Event pool */ in lpfc_sli4_driver_resource_setup()
8033 INIT_LIST_HEAD(&phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_driver_resource_setup()
8035 INIT_LIST_HEAD(&phba->sli4_hba.sp_queue_event); in lpfc_sli4_driver_resource_setup()
8037 INIT_LIST_HEAD(&phba->sli4_hba.sp_asynce_work_queue); in lpfc_sli4_driver_resource_setup()
8038 /* Slow-path XRI aborted CQ Event work queue list */ in lpfc_sli4_driver_resource_setup()
8039 INIT_LIST_HEAD(&phba->sli4_hba.sp_els_xri_aborted_work_queue); in lpfc_sli4_driver_resource_setup()
8041 INIT_LIST_HEAD(&phba->sli4_hba.sp_unsol_work_queue); in lpfc_sli4_driver_resource_setup()
8044 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_blk_list); in lpfc_sli4_driver_resource_setup()
8045 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_xri_blk_list); in lpfc_sli4_driver_resource_setup()
8046 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_vfi_blk_list); in lpfc_sli4_driver_resource_setup()
8047 INIT_LIST_HEAD(&phba->lpfc_vpi_blk_list); in lpfc_sli4_driver_resource_setup()
8052 INIT_LIST_HEAD(&phba->sli.mboxq); in lpfc_sli4_driver_resource_setup()
8053 INIT_LIST_HEAD(&phba->sli.mboxq_cmpl); in lpfc_sli4_driver_resource_setup()
8056 phba->sli4_hba.lnk_info.optic_state = 0xff; in lpfc_sli4_driver_resource_setup()
8064 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_driver_resource_setup()
8068 rc = -ENODEV; in lpfc_sli4_driver_resource_setup()
8071 phba->temp_sensor_support = 1; in lpfc_sli4_driver_resource_setup()
8089 if (phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_CONFIG) { in lpfc_sli4_driver_resource_setup()
8090 /* Right now the link is down, if FA-PWWN is configured the in lpfc_sli4_driver_resource_setup()
8097 phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_FABRIC; in lpfc_sli4_driver_resource_setup()
8105 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_driver_resource_setup()
8112 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_sli4_driver_resource_setup()
8115 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8120 phba->nvmet_support = 0; in lpfc_sli4_driver_resource_setup()
8131 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_driver_resource_setup()
8132 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_driver_resource_setup()
8133 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8134 rc = -EIO; in lpfc_sli4_driver_resource_setup()
8137 mb = &mboxq->u.mb; in lpfc_sli4_driver_resource_setup()
8138 memcpy(&wwn, (char *)mb->un.varRDnvp.nodename, in lpfc_sli4_driver_resource_setup()
8141 phba->sli4_hba.wwnn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
8142 memcpy(&wwn, (char *)mb->un.varRDnvp.portname, in lpfc_sli4_driver_resource_setup()
8146 phba->sli4_hba.wwpn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
8155 phba->nvmet_support = 1; /* a match */ in lpfc_sli4_driver_resource_setup()
8169 phba->cfg_xri_rebalancing = 0; in lpfc_sli4_driver_resource_setup()
8170 if (phba->irq_chann_mode == NHT_MODE) { in lpfc_sli4_driver_resource_setup()
8171 phba->cfg_irq_chann = in lpfc_sli4_driver_resource_setup()
8172 phba->sli4_hba.num_present_cpu; in lpfc_sli4_driver_resource_setup()
8173 phba->cfg_hdw_queue = in lpfc_sli4_driver_resource_setup()
8174 phba->sli4_hba.num_present_cpu; in lpfc_sli4_driver_resource_setup()
8175 phba->irq_chann_mode = NORMAL_MODE; in lpfc_sli4_driver_resource_setup()
8193 rc = -EIO; in lpfc_sli4_driver_resource_setup()
8194 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8203 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_driver_resource_setup()
8217 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) { in lpfc_sli4_driver_resource_setup()
8221 * The scsi_buf for a T10-DIF I/O holds the FCP cmnd, in lpfc_sli4_driver_resource_setup()
8224 * will hand us (ie: there could be one for every block in lpfc_sli4_driver_resource_setup()
8229 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd32) + in lpfc_sli4_driver_resource_setup()
8233 phba->cfg_total_seg_cnt = LPFC_MAX_SGL_SEG_CNT; in lpfc_sli4_driver_resource_setup()
8239 if (phba->cfg_enable_bg && in lpfc_sli4_driver_resource_setup()
8240 phba->cfg_sg_seg_cnt > LPFC_MAX_BG_SLI4_SEG_CNT_DIF) in lpfc_sli4_driver_resource_setup()
8241 phba->cfg_scsi_seg_cnt = LPFC_MAX_BG_SLI4_SEG_CNT_DIF; in lpfc_sli4_driver_resource_setup()
8243 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8251 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd32) + in lpfc_sli4_driver_resource_setup()
8253 ((phba->cfg_sg_seg_cnt + extra) * in lpfc_sli4_driver_resource_setup()
8257 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + extra; in lpfc_sli4_driver_resource_setup()
8258 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8261 * NOTE: if (phba->cfg_sg_seg_cnt + extra) <= 256 we only in lpfc_sli4_driver_resource_setup()
8266 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_driver_resource_setup()
8267 phba->cfg_sg_dma_buf_size = LPFC_DEFAULT_XPSGL_SIZE; in lpfc_sli4_driver_resource_setup()
8268 else if (phba->cfg_sg_dma_buf_size <= LPFC_MIN_SG_SLI4_BUF_SZ) in lpfc_sli4_driver_resource_setup()
8269 phba->cfg_sg_dma_buf_size = LPFC_MIN_SG_SLI4_BUF_SZ; in lpfc_sli4_driver_resource_setup()
8271 phba->cfg_sg_dma_buf_size = in lpfc_sli4_driver_resource_setup()
8272 SLI4_PAGE_ALIGN(phba->cfg_sg_dma_buf_size); in lpfc_sli4_driver_resource_setup()
8274 phba->border_sge_num = phba->cfg_sg_dma_buf_size / in lpfc_sli4_driver_resource_setup()
8278 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
8279 if (phba->cfg_sg_seg_cnt > LPFC_MAX_NVME_SEG_CNT) { in lpfc_sli4_driver_resource_setup()
8284 phba->cfg_nvme_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_sli4_driver_resource_setup()
8286 phba->cfg_nvme_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8292 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
8293 phba->cfg_total_seg_cnt, phba->cfg_scsi_seg_cnt, in lpfc_sli4_driver_resource_setup()
8294 phba->cfg_nvme_seg_cnt); in lpfc_sli4_driver_resource_setup()
8296 i = min(phba->cfg_sg_dma_buf_size, SLI4_PAGE_SIZE); in lpfc_sli4_driver_resource_setup()
8298 phba->lpfc_sg_dma_buf_pool = in lpfc_sli4_driver_resource_setup()
8300 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
8301 phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
8303 if (!phba->lpfc_sg_dma_buf_pool) { in lpfc_sli4_driver_resource_setup()
8304 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8308 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli4_driver_resource_setup()
8310 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
8314 if (!phba->lpfc_cmd_rsp_buf_pool) { in lpfc_sli4_driver_resource_setup()
8315 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8319 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8355 longs = (LPFC_SLI4_FCF_TBL_INDX_MAX + BITS_PER_LONG - 1)/BITS_PER_LONG; in lpfc_sli4_driver_resource_setup()
8356 phba->fcf.fcf_rr_bmask = kcalloc(longs, sizeof(unsigned long), in lpfc_sli4_driver_resource_setup()
8358 if (!phba->fcf.fcf_rr_bmask) { in lpfc_sli4_driver_resource_setup()
8362 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8366 phba->sli4_hba.hba_eq_hdl = kcalloc(phba->cfg_irq_chann, in lpfc_sli4_driver_resource_setup()
8369 if (!phba->sli4_hba.hba_eq_hdl) { in lpfc_sli4_driver_resource_setup()
8372 "fast-path per-EQ handle array\n"); in lpfc_sli4_driver_resource_setup()
8373 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8377 phba->sli4_hba.cpu_map = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
8380 if (!phba->sli4_hba.cpu_map) { in lpfc_sli4_driver_resource_setup()
8382 "3327 Failed allocate memory for msi-x " in lpfc_sli4_driver_resource_setup()
8384 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8388 phba->sli4_hba.eq_info = alloc_percpu(struct lpfc_eq_intr_info); in lpfc_sli4_driver_resource_setup()
8389 if (!phba->sli4_hba.eq_info) { in lpfc_sli4_driver_resource_setup()
8392 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8396 phba->sli4_hba.idle_stat = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
8397 sizeof(*phba->sli4_hba.idle_stat), in lpfc_sli4_driver_resource_setup()
8399 if (!phba->sli4_hba.idle_stat) { in lpfc_sli4_driver_resource_setup()
8402 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8407 phba->sli4_hba.c_stat = alloc_percpu(struct lpfc_hdwq_stat); in lpfc_sli4_driver_resource_setup()
8408 if (!phba->sli4_hba.c_stat) { in lpfc_sli4_driver_resource_setup()
8411 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8416 phba->cmf_stat = alloc_percpu(struct lpfc_cgn_stat); in lpfc_sli4_driver_resource_setup()
8417 if (!phba->cmf_stat) { in lpfc_sli4_driver_resource_setup()
8420 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8425 * Enable sr-iov virtual functions if supported and configured in lpfc_sli4_driver_resource_setup()
8428 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli4_driver_resource_setup()
8430 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
8433 "3020 Requested number of SR-IOV " in lpfc_sli4_driver_resource_setup()
8436 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
8437 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli4_driver_resource_setup()
8445 free_percpu(phba->sli4_hba.c_stat); in lpfc_sli4_driver_resource_setup()
8448 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_setup()
8450 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_setup()
8452 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_setup()
8454 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_setup()
8456 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_setup()
8464 dma_pool_destroy(phba->lpfc_cmd_rsp_buf_pool); in lpfc_sli4_driver_resource_setup()
8465 phba->lpfc_cmd_rsp_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
8467 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli4_driver_resource_setup()
8468 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
8474 destroy_workqueue(phba->wq); in lpfc_sli4_driver_resource_setup()
8475 phba->wq = NULL; in lpfc_sli4_driver_resource_setup()
8480 * lpfc_sli4_driver_resource_unset - Unset drvr internal resources for SLI4 dev
8484 * specific for supporting the SLI-4 HBA device it attached to.
8491 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_unset()
8493 free_percpu(phba->sli4_hba.c_stat); in lpfc_sli4_driver_resource_unset()
8495 free_percpu(phba->cmf_stat); in lpfc_sli4_driver_resource_unset()
8496 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_unset()
8498 /* Free memory allocated for msi-x interrupt vector to CPU mapping */ in lpfc_sli4_driver_resource_unset()
8499 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_unset()
8500 phba->sli4_hba.num_possible_cpu = 0; in lpfc_sli4_driver_resource_unset()
8501 phba->sli4_hba.num_present_cpu = 0; in lpfc_sli4_driver_resource_unset()
8502 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_unset()
8503 cpumask_clear(&phba->sli4_hba.irq_aff_mask); in lpfc_sli4_driver_resource_unset()
8505 /* Free memory allocated for fast-path work queue handles */ in lpfc_sli4_driver_resource_unset()
8506 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_unset()
8513 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_unset()
8527 /* Free the bsmbx region. */ in lpfc_sli4_driver_resource_unset()
8535 &phba->fcf_conn_rec_list, list) { in lpfc_sli4_driver_resource_unset()
8536 list_del_init(&conn_entry->list); in lpfc_sli4_driver_resource_unset()
8544 * lpfc_init_api_table_setup - Set up init api function jump table
8546 * @dev_grp: The HBA PCI-Device group number.
8551 * Returns: 0 - success, -ENODEV - failure.
8556 phba->lpfc_hba_init_link = lpfc_hba_init_link; in lpfc_init_api_table_setup()
8557 phba->lpfc_hba_down_link = lpfc_hba_down_link; in lpfc_init_api_table_setup()
8558 phba->lpfc_selective_reset = lpfc_selective_reset; in lpfc_init_api_table_setup()
8561 phba->lpfc_hba_down_post = lpfc_hba_down_post_s3; in lpfc_init_api_table_setup()
8562 phba->lpfc_handle_eratt = lpfc_handle_eratt_s3; in lpfc_init_api_table_setup()
8563 phba->lpfc_stop_port = lpfc_stop_port_s3; in lpfc_init_api_table_setup()
8566 phba->lpfc_hba_down_post = lpfc_hba_down_post_s4; in lpfc_init_api_table_setup()
8567 phba->lpfc_handle_eratt = lpfc_handle_eratt_s4; in lpfc_init_api_table_setup()
8568 phba->lpfc_stop_port = lpfc_stop_port_s4; in lpfc_init_api_table_setup()
8572 "1431 Invalid HBA PCI-device group: 0x%x\n", in lpfc_init_api_table_setup()
8574 return -ENODEV; in lpfc_init_api_table_setup()
8580 * lpfc_setup_driver_resource_phase2 - Phase2 setup driver internal resources.
8587 * 0 - successful
8588 * other values - error
8596 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_setup_driver_resource_phase2()
8597 "lpfc_worker_%d", phba->brd_no); in lpfc_setup_driver_resource_phase2()
8598 if (IS_ERR(phba->worker_thread)) { in lpfc_setup_driver_resource_phase2()
8599 error = PTR_ERR(phba->worker_thread); in lpfc_setup_driver_resource_phase2()
8607 * lpfc_unset_driver_resource_phase2 - Phase2 unset driver internal resources.
8617 if (phba->wq) { in lpfc_unset_driver_resource_phase2()
8618 destroy_workqueue(phba->wq); in lpfc_unset_driver_resource_phase2()
8619 phba->wq = NULL; in lpfc_unset_driver_resource_phase2()
8623 if (phba->worker_thread) in lpfc_unset_driver_resource_phase2()
8624 kthread_stop(phba->worker_thread); in lpfc_unset_driver_resource_phase2()
8628 * lpfc_free_iocb_list - Free iocb list.
8638 spin_lock_irq(&phba->hbalock); in lpfc_free_iocb_list()
8640 &phba->lpfc_iocb_list, list) { in lpfc_free_iocb_list()
8641 list_del(&iocbq_entry->list); in lpfc_free_iocb_list()
8643 phba->total_iocbq_bufs--; in lpfc_free_iocb_list()
8645 spin_unlock_irq(&phba->hbalock); in lpfc_free_iocb_list()
8651 * lpfc_init_iocb_list - Allocate and initialize iocb list.
8659 * 0 - successful
8660 * other values - error
8670 INIT_LIST_HEAD(&phba->lpfc_iocb_list); in lpfc_init_iocb_list()
8687 iocbq_entry->sli4_lxritag = NO_XRI; in lpfc_init_iocb_list()
8688 iocbq_entry->sli4_xritag = NO_XRI; in lpfc_init_iocb_list()
8690 spin_lock_irq(&phba->hbalock); in lpfc_init_iocb_list()
8691 list_add(&iocbq_entry->list, &phba->lpfc_iocb_list); in lpfc_init_iocb_list()
8692 phba->total_iocbq_bufs++; in lpfc_init_iocb_list()
8693 spin_unlock_irq(&phba->hbalock); in lpfc_init_iocb_list()
8701 return -ENOMEM; in lpfc_init_iocb_list()
8705 * lpfc_free_sgl_list - Free a given sgl list.
8717 list_del(&sglq_entry->list); in lpfc_free_sgl_list()
8718 lpfc_mbuf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_sgl_list()
8724 * lpfc_free_els_sgl_list - Free els sgl list.
8735 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
8736 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, &sglq_list); in lpfc_free_els_sgl_list()
8737 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
8744 * lpfc_free_nvmet_sgl_list - Free nvmet sgl list.
8756 spin_lock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
8757 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
8758 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, &sglq_list); in lpfc_free_nvmet_sgl_list()
8759 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
8760 spin_unlock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
8764 list_del(&sglq_entry->list); in lpfc_free_nvmet_sgl_list()
8765 lpfc_nvmet_buf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_nvmet_sgl_list()
8773 phba->sli4_hba.nvmet_xri_cnt = 0; in lpfc_free_nvmet_sgl_list()
8777 * lpfc_init_active_sgl_array - Allocate the buf to track active ELS XRIs.
8788 size *= phba->sli4_hba.max_cfg_param.max_xri; in lpfc_init_active_sgl_array()
8790 phba->sli4_hba.lpfc_sglq_active_list = in lpfc_init_active_sgl_array()
8792 if (!phba->sli4_hba.lpfc_sglq_active_list) in lpfc_init_active_sgl_array()
8793 return -ENOMEM; in lpfc_init_active_sgl_array()
8798 * lpfc_free_active_sgl - Free the buf that tracks active ELS XRIs.
8808 kfree(phba->sli4_hba.lpfc_sglq_active_list); in lpfc_free_active_sgl()
8812 * lpfc_init_sgl_list - Allocate and initialize sgl list.
8823 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_els_sgl_list); in lpfc_init_sgl_list()
8824 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_init_sgl_list()
8825 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_init_sgl_list()
8826 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_init_sgl_list()
8828 /* els xri-sgl book keeping */ in lpfc_init_sgl_list()
8829 phba->sli4_hba.els_xri_cnt = 0; in lpfc_init_sgl_list()
8831 /* nvme xri-buffer book keeping */ in lpfc_init_sgl_list()
8832 phba->sli4_hba.io_xri_cnt = 0; in lpfc_init_sgl_list()
8836 * lpfc_sli4_init_rpi_hdrs - Post the rpi header memory region to the port
8841 * posts a PAGE_SIZE memory region to the port to hold up to
8846 * 0 - successful
8847 * -ERROR - otherwise.
8855 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_init_rpi_hdrs()
8856 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_init_rpi_hdrs()
8858 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_init_rpi_hdrs()
8859 return -EIO; in lpfc_sli4_init_rpi_hdrs()
8866 rc = -ENODEV; in lpfc_sli4_init_rpi_hdrs()
8873 * lpfc_sli4_create_rpi_hdr - Allocate an rpi header memory region
8876 * This routine is invoked to allocate a single 4KB memory region to
8877 * support rpis and stores them in the phba. This single region
8878 * provides support for up to 64 rpis. The region is used globally
8897 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_create_rpi_hdr()
8899 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_create_rpi_hdr()
8903 rpi_limit = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_create_rpi_hdr()
8905 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8911 curr_rpi_range = phba->sli4_hba.next_rpi; in lpfc_sli4_create_rpi_hdr()
8912 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8919 * First allocate the protocol header region for the port. The in lpfc_sli4_create_rpi_hdr()
8920 * port expects a 4KB DMA-mapped memory region that is 4K aligned. in lpfc_sli4_create_rpi_hdr()
8926 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_create_rpi_hdr()
8928 &dmabuf->phys, GFP_KERNEL); in lpfc_sli4_create_rpi_hdr()
8929 if (!dmabuf->virt) { in lpfc_sli4_create_rpi_hdr()
8934 if (!IS_ALIGNED(dmabuf->phys, LPFC_HDR_TEMPLATE_SIZE)) { in lpfc_sli4_create_rpi_hdr()
8944 rpi_hdr->dmabuf = dmabuf; in lpfc_sli4_create_rpi_hdr()
8945 rpi_hdr->len = LPFC_HDR_TEMPLATE_SIZE; in lpfc_sli4_create_rpi_hdr()
8946 rpi_hdr->page_count = 1; in lpfc_sli4_create_rpi_hdr()
8947 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8950 rpi_hdr->start_rpi = curr_rpi_range; in lpfc_sli4_create_rpi_hdr()
8951 rpi_hdr->next_rpi = phba->sli4_hba.next_rpi + LPFC_RPI_HDR_COUNT; in lpfc_sli4_create_rpi_hdr()
8952 list_add_tail(&rpi_hdr->list, &phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_create_rpi_hdr()
8954 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8958 dma_free_coherent(&phba->pcidev->dev, LPFC_HDR_TEMPLATE_SIZE, in lpfc_sli4_create_rpi_hdr()
8959 dmabuf->virt, dmabuf->phys); in lpfc_sli4_create_rpi_hdr()
8966 * lpfc_sli4_remove_rpi_hdrs - Remove all rpi header memory regions
8979 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_remove_rpi_hdrs()
8983 &phba->sli4_hba.lpfc_rpi_hdr_list, list) { in lpfc_sli4_remove_rpi_hdrs()
8984 list_del(&rpi_hdr->list); in lpfc_sli4_remove_rpi_hdrs()
8985 dma_free_coherent(&phba->pcidev->dev, rpi_hdr->len, in lpfc_sli4_remove_rpi_hdrs()
8986 rpi_hdr->dmabuf->virt, rpi_hdr->dmabuf->phys); in lpfc_sli4_remove_rpi_hdrs()
8987 kfree(rpi_hdr->dmabuf); in lpfc_sli4_remove_rpi_hdrs()
8992 phba->sli4_hba.next_rpi = 0; in lpfc_sli4_remove_rpi_hdrs()
8996 * lpfc_hba_alloc - Allocate driver hba data structure for a device.
9004 * pointer to @phba - successful
9005 * NULL - error
9015 dev_err(&pdev->dev, "failed to allocate hba struct\n"); in lpfc_hba_alloc()
9020 phba->pcidev = pdev; in lpfc_hba_alloc()
9023 phba->brd_no = lpfc_get_instance(); in lpfc_hba_alloc()
9024 if (phba->brd_no < 0) { in lpfc_hba_alloc()
9028 phba->eratt_poll_interval = LPFC_ERATT_POLL_INTERVAL; in lpfc_hba_alloc()
9030 spin_lock_init(&phba->ct_ev_lock); in lpfc_hba_alloc()
9031 INIT_LIST_HEAD(&phba->ct_ev_waiters); in lpfc_hba_alloc()
9037 * lpfc_hba_free - Free driver hba data structure with a device.
9046 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_hba_free()
9047 kfree(phba->sli4_hba.hdwq); in lpfc_hba_free()
9050 idr_remove(&lpfc_hba_index, phba->brd_no); in lpfc_hba_free()
9053 kfree(phba->sli.sli3_ring); in lpfc_hba_free()
9054 phba->sli.sli3_ring = NULL; in lpfc_hba_free()
9061 * lpfc_setup_fdmi_mask - Setup initial FDMI mask for HBA and Port attributes
9067 * fallback hierarchy is SmartSAN -> FDMI2 -> FMDI1
9072 struct lpfc_hba *phba = vport->phba; in lpfc_setup_fdmi_mask()
9074 set_bit(FC_ALLOW_FDMI, &vport->load_flag); in lpfc_setup_fdmi_mask()
9075 if (phba->cfg_enable_SmartSAN || in lpfc_setup_fdmi_mask()
9076 phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT) { in lpfc_setup_fdmi_mask()
9078 vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR; in lpfc_setup_fdmi_mask()
9079 if (phba->cfg_enable_SmartSAN) in lpfc_setup_fdmi_mask()
9080 vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR; in lpfc_setup_fdmi_mask()
9082 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR; in lpfc_setup_fdmi_mask()
9087 vport->fdmi_hba_mask, vport->fdmi_port_mask); in lpfc_setup_fdmi_mask()
9091 * lpfc_create_shost - Create hba physical port with associated scsi host.
9098 * 0 - successful
9099 * other values - error
9108 phba->fc_edtov = FF_DEF_EDTOV; in lpfc_create_shost()
9109 phba->fc_ratov = FF_DEF_RATOV; in lpfc_create_shost()
9110 phba->fc_altov = FF_DEF_ALTOV; in lpfc_create_shost()
9111 phba->fc_arbtov = FF_DEF_ARBTOV; in lpfc_create_shost()
9113 atomic_set(&phba->sdev_cnt, 0); in lpfc_create_shost()
9114 vport = lpfc_create_port(phba, phba->brd_no, &phba->pcidev->dev); in lpfc_create_shost()
9116 return -ENODEV; in lpfc_create_shost()
9119 phba->pport = vport; in lpfc_create_shost()
9121 if (phba->nvmet_support) { in lpfc_create_shost()
9123 phba->targetport = NULL; in lpfc_create_shost()
9124 phba->cfg_enable_fc4_type = LPFC_ENABLE_NVME; in lpfc_create_shost()
9131 pci_set_drvdata(phba->pcidev, shost); in lpfc_create_shost()
9143 * lpfc_destroy_shost - Destroy hba physical port with associated scsi host.
9152 struct lpfc_vport *vport = phba->pport; in lpfc_destroy_shost()
9161 * lpfc_setup_bg - Setup Block guard structures and debug areas.
9174 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
9179 old_mask = phba->cfg_prot_mask; in lpfc_setup_bg()
9180 old_guard = phba->cfg_prot_guard; in lpfc_setup_bg()
9183 phba->cfg_prot_mask &= (SHOST_DIF_TYPE1_PROTECTION | in lpfc_setup_bg()
9186 phba->cfg_prot_guard &= (SHOST_DIX_GUARD_IP | in lpfc_setup_bg()
9190 if (phba->cfg_prot_mask == SHOST_DIX_TYPE1_PROTECTION) in lpfc_setup_bg()
9191 phba->cfg_prot_mask |= SHOST_DIF_TYPE1_PROTECTION; in lpfc_setup_bg()
9193 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
9194 if ((old_mask != phba->cfg_prot_mask) || in lpfc_setup_bg()
9195 (old_guard != phba->cfg_prot_guard)) in lpfc_setup_bg()
9199 phba->cfg_prot_mask, in lpfc_setup_bg()
9200 phba->cfg_prot_guard); in lpfc_setup_bg()
9202 scsi_host_set_prot(shost, phba->cfg_prot_mask); in lpfc_setup_bg()
9203 scsi_host_set_guard(shost, phba->cfg_prot_guard); in lpfc_setup_bg()
9213 * lpfc_post_init_setup - Perform necessary device post initialization setup.
9226 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_post_init_setup()
9232 shost = pci_get_drvdata(phba->pcidev); in lpfc_post_init_setup()
9233 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_post_init_setup()
9237 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_post_init_setup()
9238 spin_lock_irq(shost->host_lock); in lpfc_post_init_setup()
9240 spin_unlock_irq(shost->host_lock); in lpfc_post_init_setup()
9256 * lpfc_sli_pci_mem_setup - Setup SLI3 HBA PCI memory space.
9260 * with SLI-3 interface spec.
9263 * 0 - successful
9264 * other values - error
9269 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_pci_mem_setup()
9276 return -ENODEV; in lpfc_sli_pci_mem_setup()
9279 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli_pci_mem_setup()
9281 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli_pci_mem_setup()
9284 error = -ENODEV; in lpfc_sli_pci_mem_setup()
9289 phba->pci_bar0_map = pci_resource_start(pdev, 0); in lpfc_sli_pci_mem_setup()
9292 phba->pci_bar2_map = pci_resource_start(pdev, 2); in lpfc_sli_pci_mem_setup()
9296 phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli_pci_mem_setup()
9297 if (!phba->slim_memmap_p) { in lpfc_sli_pci_mem_setup()
9298 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
9304 phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli_pci_mem_setup()
9305 if (!phba->ctrl_regs_memmap_p) { in lpfc_sli_pci_mem_setup()
9306 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
9311 /* Allocate memory for SLI-2 structures */ in lpfc_sli_pci_mem_setup()
9312 phba->slim2p.virt = dma_alloc_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
9313 &phba->slim2p.phys, GFP_KERNEL); in lpfc_sli_pci_mem_setup()
9314 if (!phba->slim2p.virt) in lpfc_sli_pci_mem_setup()
9317 phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx); in lpfc_sli_pci_mem_setup()
9318 phba->mbox_ext = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
9320 phba->pcb = (phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, pcb)); in lpfc_sli_pci_mem_setup()
9321 phba->IOCBs = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
9324 phba->hbqslimp.virt = dma_alloc_coherent(&pdev->dev, in lpfc_sli_pci_mem_setup()
9326 &phba->hbqslimp.phys, in lpfc_sli_pci_mem_setup()
9328 if (!phba->hbqslimp.virt) in lpfc_sli_pci_mem_setup()
9332 ptr = phba->hbqslimp.virt; in lpfc_sli_pci_mem_setup()
9334 phba->hbqs[i].hbq_virt = ptr; in lpfc_sli_pci_mem_setup()
9335 INIT_LIST_HEAD(&phba->hbqs[i].hbq_buffer_list); in lpfc_sli_pci_mem_setup()
9336 ptr += (lpfc_hbq_defs[i]->entry_count * in lpfc_sli_pci_mem_setup()
9339 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_els_hbq_alloc; in lpfc_sli_pci_mem_setup()
9340 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_els_hbq_free; in lpfc_sli_pci_mem_setup()
9342 memset(phba->hbqslimp.virt, 0, lpfc_sli_hbq_size()); in lpfc_sli_pci_mem_setup()
9344 phba->MBslimaddr = phba->slim_memmap_p; in lpfc_sli_pci_mem_setup()
9345 phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9346 phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9347 phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9348 phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9353 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
9354 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_setup()
9356 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_setup()
9358 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_setup()
9364 * lpfc_sli_pci_mem_unset - Unset SLI3 HBA PCI memory space.
9368 * with SLI-3 interface spec.
9376 if (!phba->pcidev) in lpfc_sli_pci_mem_unset()
9379 pdev = phba->pcidev; in lpfc_sli_pci_mem_unset()
9382 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_sli_pci_mem_unset()
9383 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_sli_pci_mem_unset()
9384 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_unset()
9385 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_unset()
9388 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_unset()
9389 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_unset()
9395 * lpfc_sli4_post_status_check - Wait for SLI4 POST done and check status
9401 * Return 0 if successful, otherwise -ENODEV.
9413 if (!phba->sli4_hba.PSMPHRregaddr) in lpfc_sli4_post_status_check()
9414 return -ENODEV; in lpfc_sli4_post_status_check()
9418 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_sli4_post_status_check()
9422 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9437 "1408 Port Failed POST - portsmphr=0x%x, " in lpfc_sli4_post_status_check()
9455 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9457 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9459 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9461 &phba->sli4_hba.sli_intf), 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()
9472 &phba->sli4_hba.sli_intf); in lpfc_sli4_post_status_check()
9475 phba->sli4_hba.ue_mask_lo = in lpfc_sli4_post_status_check()
9476 readl(phba->sli4_hba.u.if_type0.UEMASKLOregaddr); in lpfc_sli4_post_status_check()
9477 phba->sli4_hba.ue_mask_hi = in lpfc_sli4_post_status_check()
9478 readl(phba->sli4_hba.u.if_type0.UEMASKHIregaddr); in lpfc_sli4_post_status_check()
9480 readl(phba->sli4_hba.u.if_type0.UERRLOregaddr); in lpfc_sli4_post_status_check()
9482 readl(phba->sli4_hba.u.if_type0.UERRHIregaddr); in lpfc_sli4_post_status_check()
9483 if ((~phba->sli4_hba.ue_mask_lo & uerrlo_reg.word0) || in lpfc_sli4_post_status_check()
9484 (~phba->sli4_hba.ue_mask_hi & uerrhi_reg.word0)) { in lpfc_sli4_post_status_check()
9495 phba->sli4_hba.ue_mask_lo, in lpfc_sli4_post_status_check()
9496 phba->sli4_hba.ue_mask_hi); in lpfc_sli4_post_status_check()
9497 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9503 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_post_status_check()
9506 phba->work_status[0] = in lpfc_sli4_post_status_check()
9507 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
9509 phba->work_status[1] = in lpfc_sli4_post_status_check()
9510 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
9519 phba->work_status[0], in lpfc_sli4_post_status_check()
9520 phba->work_status[1]); in lpfc_sli4_post_status_check()
9521 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9527 &phba->sli4_hba.sli_intf) == in lpfc_sli4_post_status_check()
9529 pci_write_config_byte(phba->pcidev, in lpfc_sli4_post_status_check()
9541 * lpfc_sli4_bar0_register_memmap - Set up SLI4 BAR0 register memory map.
9553 phba->sli4_hba.u.if_type0.UERRLOregaddr = in lpfc_sli4_bar0_register_memmap()
9554 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_LO; in lpfc_sli4_bar0_register_memmap()
9555 phba->sli4_hba.u.if_type0.UERRHIregaddr = in lpfc_sli4_bar0_register_memmap()
9556 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_HI; in lpfc_sli4_bar0_register_memmap()
9557 phba->sli4_hba.u.if_type0.UEMASKLOregaddr = in lpfc_sli4_bar0_register_memmap()
9558 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_LO; in lpfc_sli4_bar0_register_memmap()
9559 phba->sli4_hba.u.if_type0.UEMASKHIregaddr = in lpfc_sli4_bar0_register_memmap()
9560 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_HI; in lpfc_sli4_bar0_register_memmap()
9561 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
9562 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
9565 phba->sli4_hba.u.if_type2.EQDregaddr = in lpfc_sli4_bar0_register_memmap()
9566 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9568 phba->sli4_hba.u.if_type2.ERR1regaddr = in lpfc_sli4_bar0_register_memmap()
9569 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9571 phba->sli4_hba.u.if_type2.ERR2regaddr = in lpfc_sli4_bar0_register_memmap()
9572 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9574 phba->sli4_hba.u.if_type2.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
9575 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9577 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
9578 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9580 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
9581 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
9582 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
9583 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9585 phba->sli4_hba.RQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9586 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9588 phba->sli4_hba.WQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9589 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9591 phba->sli4_hba.CQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9592 phba->sli4_hba.conf_regs_memmap_p + LPFC_EQCQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
9593 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar0_register_memmap()
9594 phba->sli4_hba.MQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9595 phba->sli4_hba.conf_regs_memmap_p + LPFC_MQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
9596 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
9597 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
9600 phba->sli4_hba.u.if_type2.EQDregaddr = in lpfc_sli4_bar0_register_memmap()
9601 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9603 phba->sli4_hba.u.if_type2.ERR1regaddr = in lpfc_sli4_bar0_register_memmap()
9604 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9606 phba->sli4_hba.u.if_type2.ERR2regaddr = in lpfc_sli4_bar0_register_memmap()
9607 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9609 phba->sli4_hba.u.if_type2.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
9610 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9612 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
9613 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9615 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
9616 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9618 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
9619 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
9623 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_bar0_register_memmap()
9624 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar0_register_memmap()
9631 * lpfc_sli4_bar1_register_memmap - Set up SLI4 BAR1 register memory map.
9642 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar1_register_memmap()
9643 phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9645 phba->sli4_hba.ISRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9647 phba->sli4_hba.IMRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9649 phba->sli4_hba.ISCRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9653 phba->sli4_hba.RQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9655 phba->sli4_hba.WQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9657 phba->sli4_hba.CQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9659 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9661 phba->sli4_hba.MQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9667 dev_err(&phba->pcidev->dev, in lpfc_sli4_bar1_register_memmap()
9668 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar1_register_memmap()
9675 * lpfc_sli4_bar2_register_memmap - Set up SLI4 BAR2 register memory map.
9682 * Return 0 if successful, otherwise -ENODEV.
9688 return -ENODEV; in lpfc_sli4_bar2_register_memmap()
9690 phba->sli4_hba.RQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9693 phba->sli4_hba.WQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9696 phba->sli4_hba.CQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9699 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar2_register_memmap()
9700 phba->sli4_hba.MQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9702 phba->sli4_hba.BMBXregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9708 * lpfc_create_bootstrap_mbox - Create the bootstrap mailbox
9712 * region consistent with the SLI-4 interface spec. This
9719 * 0 - successful
9720 * -ENOMEM - could not allocated memory.
9733 return -ENOMEM; in lpfc_create_bootstrap_mbox()
9736 * The bootstrap mailbox region is comprised of 2 parts in lpfc_create_bootstrap_mbox()
9739 bmbx_size = sizeof(struct lpfc_bmbx_create) + (LPFC_ALIGN_16_BYTE - 1); in lpfc_create_bootstrap_mbox()
9740 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, bmbx_size, in lpfc_create_bootstrap_mbox()
9741 &dmabuf->phys, GFP_KERNEL); in lpfc_create_bootstrap_mbox()
9742 if (!dmabuf->virt) { in lpfc_create_bootstrap_mbox()
9744 return -ENOMEM; in lpfc_create_bootstrap_mbox()
9750 * to be 16-byte aligned. Also align the virtual memory as each in lpfc_create_bootstrap_mbox()
9751 * maibox is copied into the bmbx mailbox region before issuing the in lpfc_create_bootstrap_mbox()
9754 phba->sli4_hba.bmbx.dmabuf = dmabuf; in lpfc_create_bootstrap_mbox()
9755 phba->sli4_hba.bmbx.bmbx_size = bmbx_size; in lpfc_create_bootstrap_mbox()
9757 phba->sli4_hba.bmbx.avirt = PTR_ALIGN(dmabuf->virt, in lpfc_create_bootstrap_mbox()
9759 phba->sli4_hba.bmbx.aphys = ALIGN(dmabuf->phys, in lpfc_create_bootstrap_mbox()
9765 * as two 30-bit addresses. The other data is a bit marking whether in lpfc_create_bootstrap_mbox()
9766 * the 30-bit address is the high or low address. in lpfc_create_bootstrap_mbox()
9770 dma_address = &phba->sli4_hba.bmbx.dma_address; in lpfc_create_bootstrap_mbox()
9771 phys_addr = (uint64_t)phba->sli4_hba.bmbx.aphys; in lpfc_create_bootstrap_mbox()
9773 dma_address->addr_hi = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
9776 pa_addr = (uint32_t) ((phba->sli4_hba.bmbx.aphys >> 4) & 0x3fffffff); in lpfc_create_bootstrap_mbox()
9777 dma_address->addr_lo = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
9783 * lpfc_destroy_bootstrap_mbox - Destroy all bootstrap mailbox resources
9787 * region and release all host resources. This routine requires
9796 dma_free_coherent(&phba->pcidev->dev, in lpfc_destroy_bootstrap_mbox()
9797 phba->sli4_hba.bmbx.bmbx_size, in lpfc_destroy_bootstrap_mbox()
9798 phba->sli4_hba.bmbx.dmabuf->virt, in lpfc_destroy_bootstrap_mbox()
9799 phba->sli4_hba.bmbx.dmabuf->phys); in lpfc_destroy_bootstrap_mbox()
9801 kfree(phba->sli4_hba.bmbx.dmabuf); in lpfc_destroy_bootstrap_mbox()
9802 memset(&phba->sli4_hba.bmbx, 0, sizeof(struct lpfc_bmbx)); in lpfc_destroy_bootstrap_mbox()
9819 * lpfc_map_topology - Map the topology read from READ_CONFIG
9844 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9847 /* FW supports persistent topology - override module parameter value */ in lpfc_map_topology()
9848 set_bit(HBA_PERSISTENT_TOPO, &phba->hba_flag); in lpfc_map_topology()
9851 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_map_topology()
9853 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_map_topology()
9856 phba->cfg_topology = ((pt == LINK_FLAGS_LOOP) in lpfc_map_topology()
9860 clear_bit(HBA_PERSISTENT_TOPO, &phba->hba_flag); in lpfc_map_topology()
9863 /* If topology failover set - pt is '0' or '1' */ in lpfc_map_topology()
9864 phba->cfg_topology = (pt ? FLAGS_TOPOLOGY_MODE_PT_LOOP : in lpfc_map_topology()
9867 phba->cfg_topology = ((pt == LINK_FLAGS_P2P) in lpfc_map_topology()
9871 if (test_bit(HBA_PERSISTENT_TOPO, &phba->hba_flag)) in lpfc_map_topology()
9874 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9879 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9883 * lpfc_sli4_read_config - Get the config parameters.
9892 * 0 - successful
9893 * -ENOMEM - No available memory
9894 * -EIO - The mailbox failed to complete successfully.
9910 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_read_config()
9915 return -ENOMEM; in lpfc_sli4_read_config()
9925 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
9926 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
9927 rc = -EIO; in lpfc_sli4_read_config()
9929 rd_config = &pmb->u.mqe.un.rd_config; in lpfc_sli4_read_config()
9931 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_VAL; in lpfc_sli4_read_config()
9932 phba->sli4_hba.lnk_info.lnk_tp = in lpfc_sli4_read_config()
9934 phba->sli4_hba.lnk_info.lnk_no = in lpfc_sli4_read_config()
9938 phba->sli4_hba.lnk_info.lnk_tp, in lpfc_sli4_read_config()
9939 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_read_config()
9943 bf_get(lpfc_mqe_command, &pmb->u.mqe)); in lpfc_sli4_read_config()
9945 phba->bbcredit_support = 1; in lpfc_sli4_read_config()
9946 phba->sli4_hba.bbscn_params.word0 = rd_config->word8; in lpfc_sli4_read_config()
9954 "2702 READ_CONFIG: FA-PWWN is " in lpfc_sli4_read_config()
9956 phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_CONFIG; in lpfc_sli4_read_config()
9959 phba->sli4_hba.fawwpn_flag &= ~LPFC_FAWWPN_CONFIG; in lpfc_sli4_read_config()
9962 phba->sli4_hba.conf_trunk = in lpfc_sli4_read_config()
9964 phba->sli4_hba.extents_in_use = in lpfc_sli4_read_config()
9967 phba->sli4_hba.max_cfg_param.max_xri = in lpfc_sli4_read_config()
9971 phba->sli4_hba.max_cfg_param.max_xri > 512) in lpfc_sli4_read_config()
9972 phba->sli4_hba.max_cfg_param.max_xri = 512; in lpfc_sli4_read_config()
9973 phba->sli4_hba.max_cfg_param.xri_base = in lpfc_sli4_read_config()
9975 phba->sli4_hba.max_cfg_param.max_vpi = in lpfc_sli4_read_config()
9978 if (phba->sli4_hba.max_cfg_param.max_vpi > LPFC_MAX_VPORTS) in lpfc_sli4_read_config()
9979 phba->sli4_hba.max_cfg_param.max_vpi = LPFC_MAX_VPORTS; in lpfc_sli4_read_config()
9980 phba->sli4_hba.max_cfg_param.vpi_base = in lpfc_sli4_read_config()
9982 phba->sli4_hba.max_cfg_param.max_rpi = in lpfc_sli4_read_config()
9984 phba->sli4_hba.max_cfg_param.rpi_base = in lpfc_sli4_read_config()
9986 phba->sli4_hba.max_cfg_param.max_vfi = in lpfc_sli4_read_config()
9988 phba->sli4_hba.max_cfg_param.vfi_base = in lpfc_sli4_read_config()
9990 phba->sli4_hba.max_cfg_param.max_fcfi = in lpfc_sli4_read_config()
9992 phba->sli4_hba.max_cfg_param.max_eq = in lpfc_sli4_read_config()
9994 phba->sli4_hba.max_cfg_param.max_rq = in lpfc_sli4_read_config()
9996 phba->sli4_hba.max_cfg_param.max_wq = in lpfc_sli4_read_config()
9998 phba->sli4_hba.max_cfg_param.max_cq = in lpfc_sli4_read_config()
10000 phba->lmt = bf_get(lpfc_mbx_rd_conf_lmt, rd_config); in lpfc_sli4_read_config()
10001 phba->sli4_hba.next_xri = phba->sli4_hba.max_cfg_param.xri_base; in lpfc_sli4_read_config()
10002 phba->vpi_base = phba->sli4_hba.max_cfg_param.vpi_base; in lpfc_sli4_read_config()
10003 phba->vfi_base = phba->sli4_hba.max_cfg_param.vfi_base; in lpfc_sli4_read_config()
10004 phba->max_vpi = (phba->sli4_hba.max_cfg_param.max_vpi > 0) ? in lpfc_sli4_read_config()
10005 (phba->sli4_hba.max_cfg_param.max_vpi - 1) : 0; in lpfc_sli4_read_config()
10006 phba->max_vports = phba->max_vpi; in lpfc_sli4_read_config()
10017 phba->cgn_reg_fpin = LPFC_CGN_FPIN_BOTH; in lpfc_sli4_read_config()
10018 phba->cgn_reg_signal = EDC_CG_SIG_NOTSUPPORTED; in lpfc_sli4_read_config()
10019 phba->cgn_sig_freq = lpfc_fabric_cgn_frequency; in lpfc_sli4_read_config()
10023 phba->cgn_reg_signal = EDC_CG_SIG_WARN_ONLY; in lpfc_sli4_read_config()
10024 phba->cgn_reg_fpin &= ~LPFC_CGN_FPIN_WARN; in lpfc_sli4_read_config()
10030 if (phba->cgn_reg_signal != in lpfc_sli4_read_config()
10033 phba->cgn_reg_fpin = LPFC_CGN_FPIN_BOTH; in lpfc_sli4_read_config()
10034 phba->cgn_reg_signal = in lpfc_sli4_read_config()
10037 phba->cgn_reg_signal = in lpfc_sli4_read_config()
10039 phba->cgn_reg_fpin = in lpfc_sli4_read_config()
10046 phba->cgn_init_reg_fpin = phba->cgn_reg_fpin; in lpfc_sli4_read_config()
10047 phba->cgn_init_reg_signal = phba->cgn_reg_signal; in lpfc_sli4_read_config()
10051 phba->cgn_reg_signal, phba->cgn_reg_fpin); in lpfc_sli4_read_config()
10061 phba->sli4_hba.extents_in_use, in lpfc_sli4_read_config()
10062 phba->sli4_hba.max_cfg_param.xri_base, in lpfc_sli4_read_config()
10063 phba->sli4_hba.max_cfg_param.max_xri, in lpfc_sli4_read_config()
10064 phba->sli4_hba.max_cfg_param.vpi_base, in lpfc_sli4_read_config()
10065 phba->sli4_hba.max_cfg_param.max_vpi, in lpfc_sli4_read_config()
10066 phba->sli4_hba.max_cfg_param.vfi_base, in lpfc_sli4_read_config()
10067 phba->sli4_hba.max_cfg_param.max_vfi, in lpfc_sli4_read_config()
10068 phba->sli4_hba.max_cfg_param.rpi_base, in lpfc_sli4_read_config()
10069 phba->sli4_hba.max_cfg_param.max_rpi, in lpfc_sli4_read_config()
10070 phba->sli4_hba.max_cfg_param.max_fcfi, in lpfc_sli4_read_config()
10071 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
10072 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
10073 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
10074 phba->sli4_hba.max_cfg_param.max_rq, in lpfc_sli4_read_config()
10075 phba->lmt); in lpfc_sli4_read_config()
10081 qmin = phba->sli4_hba.max_cfg_param.max_wq; in lpfc_sli4_read_config()
10082 if (phba->sli4_hba.max_cfg_param.max_cq < qmin) in lpfc_sli4_read_config()
10083 qmin = phba->sli4_hba.max_cfg_param.max_cq; in lpfc_sli4_read_config()
10088 qmin -= 4; in lpfc_sli4_read_config()
10089 if (phba->sli4_hba.max_cfg_param.max_eq < qmin) in lpfc_sli4_read_config()
10090 qmin = phba->sli4_hba.max_cfg_param.max_eq; in lpfc_sli4_read_config()
10093 if ((phba->cfg_irq_chann > qmin) || in lpfc_sli4_read_config()
10094 (phba->cfg_hdw_queue > qmin)) { in lpfc_sli4_read_config()
10096 "2005 Reducing Queues - " in lpfc_sli4_read_config()
10100 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
10101 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
10102 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
10103 qmin, phba->cfg_irq_chann, in lpfc_sli4_read_config()
10104 phba->cfg_hdw_queue); in lpfc_sli4_read_config()
10106 if (phba->cfg_irq_chann > qmin) in lpfc_sli4_read_config()
10107 phba->cfg_irq_chann = qmin; in lpfc_sli4_read_config()
10108 if (phba->cfg_hdw_queue > qmin) in lpfc_sli4_read_config()
10109 phba->cfg_hdw_queue = qmin; in lpfc_sli4_read_config()
10117 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_read_config()
10122 set_bit(HBA_FORCED_LINK_SPEED, &phba->hba_flag); in lpfc_sli4_read_config()
10126 phba->cfg_link_speed = in lpfc_sli4_read_config()
10130 phba->cfg_link_speed = 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()
10167 phba->cfg_link_speed = in lpfc_sli4_read_config()
10174 length = phba->sli4_hba.max_cfg_param.max_xri - in lpfc_sli4_read_config()
10176 if (phba->cfg_hba_queue_depth > length) { in lpfc_sli4_read_config()
10179 phba->cfg_hba_queue_depth, length); in lpfc_sli4_read_config()
10180 phba->cfg_hba_queue_depth = length; in lpfc_sli4_read_config()
10183 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_read_config()
10188 length = (sizeof(struct lpfc_mbx_get_func_cfg) - in lpfc_sli4_read_config()
10196 &pmb->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_read_config()
10197 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_read_config()
10198 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_read_config()
10203 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
10204 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
10209 get_func_cfg = &pmb->u.mqe.un.get_func_cfg; in lpfc_sli4_read_config()
10211 pdesc_0 = (char *)&get_func_cfg->func_cfg.desc[0]; in lpfc_sli4_read_config()
10223 phba->sli4_hba.iov.pf_number = in lpfc_sli4_read_config()
10225 phba->sli4_hba.iov.vf_number = in lpfc_sli4_read_config()
10234 "vf_number:%d\n", phba->sli4_hba.iov.pf_number, in lpfc_sli4_read_config()
10235 phba->sli4_hba.iov.vf_number); in lpfc_sli4_read_config()
10243 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_read_config()
10248 * lpfc_setup_endian_order - Write endian order to an SLI4 if_type 0 port.
10251 * This routine is invoked to setup the port-side endian order when
10256 * 0 - successful
10257 * -ENOMEM - No available memory
10258 * -EIO - The mailbox failed to complete successfully.
10268 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_setup_endian_order()
10271 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_setup_endian_order()
10278 return -ENOMEM; in lpfc_setup_endian_order()
10286 memcpy(&mboxq->u.mqe, &endian_mb_data, sizeof(endian_mb_data)); in lpfc_setup_endian_order()
10293 rc = -EIO; in lpfc_setup_endian_order()
10295 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_setup_endian_order()
10307 * lpfc_sli4_queue_verify - Verify and update EQ counts
10316 * 0 - successful
10317 * -ENOMEM - No available memory
10323 * Sanity check for configured queue parameters against the run-time in lpfc_sli4_queue_verify()
10327 if (phba->nvmet_support) { in lpfc_sli4_queue_verify()
10328 if (phba->cfg_hdw_queue < phba->cfg_nvmet_mrq) in lpfc_sli4_queue_verify()
10329 phba->cfg_nvmet_mrq = phba->cfg_hdw_queue; in lpfc_sli4_queue_verify()
10330 if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX) in lpfc_sli4_queue_verify()
10331 phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX; in lpfc_sli4_queue_verify()
10336 phba->cfg_hdw_queue, phba->cfg_irq_chann, in lpfc_sli4_queue_verify()
10337 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_verify()
10340 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_verify()
10341 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_verify()
10344 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_verify()
10345 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_verify()
10358 if (phba->enab_exp_wqcq_pages) in lpfc_alloc_io_wq_cq()
10361 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
10366 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
10367 phba->sli4_hba.cq_ecount, cpu); in lpfc_alloc_io_wq_cq()
10370 "0499 Failed allocate fast-path IO CQ (%d)\n", in lpfc_alloc_io_wq_cq()
10374 qdesc->qe_valid = 1; in lpfc_alloc_io_wq_cq()
10375 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
10376 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
10377 phba->sli4_hba.hdwq[idx].io_cq = qdesc; in lpfc_alloc_io_wq_cq()
10380 if (phba->enab_exp_wqcq_pages) { in lpfc_alloc_io_wq_cq()
10382 wqesize = (phba->fcp_embed_io) ? in lpfc_alloc_io_wq_cq()
10383 LPFC_WQE128_SIZE : phba->sli4_hba.wq_esize; in lpfc_alloc_io_wq_cq()
10389 phba->sli4_hba.wq_esize, in lpfc_alloc_io_wq_cq()
10390 phba->sli4_hba.wq_ecount, cpu); in lpfc_alloc_io_wq_cq()
10394 "0503 Failed allocate fast-path IO WQ (%d)\n", in lpfc_alloc_io_wq_cq()
10398 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
10399 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
10400 phba->sli4_hba.hdwq[idx].io_wq = qdesc; in lpfc_alloc_io_wq_cq()
10401 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_alloc_io_wq_cq()
10406 * lpfc_sli4_queue_create - Create all the SLI4 queues
10415 * 0 - successful
10416 * -ENOMEM - No availble memory
10417 * -EIO - The mailbox failed to complete successfully.
10434 phba->sli4_hba.mq_esize = LPFC_MQE_SIZE; in lpfc_sli4_queue_create()
10435 phba->sli4_hba.mq_ecount = LPFC_MQE_DEF_COUNT; in lpfc_sli4_queue_create()
10436 phba->sli4_hba.wq_esize = LPFC_WQE_SIZE; in lpfc_sli4_queue_create()
10437 phba->sli4_hba.wq_ecount = LPFC_WQE_DEF_COUNT; in lpfc_sli4_queue_create()
10438 phba->sli4_hba.rq_esize = LPFC_RQE_SIZE; in lpfc_sli4_queue_create()
10439 phba->sli4_hba.rq_ecount = LPFC_RQE_DEF_COUNT; in lpfc_sli4_queue_create()
10440 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_create()
10441 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_create()
10442 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_create()
10443 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_create()
10445 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
10446 phba->sli4_hba.hdwq = kcalloc( in lpfc_sli4_queue_create()
10447 phba->cfg_hdw_queue, sizeof(struct lpfc_sli4_hdw_queue), in lpfc_sli4_queue_create()
10449 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
10452 "fast-path Hardware Queue array\n"); in lpfc_sli4_queue_create()
10456 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10457 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_queue_create()
10458 spin_lock_init(&qp->io_buf_list_get_lock); in lpfc_sli4_queue_create()
10459 spin_lock_init(&qp->io_buf_list_put_lock); in lpfc_sli4_queue_create()
10460 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_sli4_queue_create()
10461 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_sli4_queue_create()
10462 qp->get_io_bufs = 0; in lpfc_sli4_queue_create()
10463 qp->put_io_bufs = 0; in lpfc_sli4_queue_create()
10464 qp->total_io_bufs = 0; in lpfc_sli4_queue_create()
10465 spin_lock_init(&qp->abts_io_buf_list_lock); in lpfc_sli4_queue_create()
10466 INIT_LIST_HEAD(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_queue_create()
10467 qp->abts_scsi_io_bufs = 0; in lpfc_sli4_queue_create()
10468 qp->abts_nvme_io_bufs = 0; in lpfc_sli4_queue_create()
10469 INIT_LIST_HEAD(&qp->sgl_list); in lpfc_sli4_queue_create()
10470 INIT_LIST_HEAD(&qp->cmd_rsp_buf_list); in lpfc_sli4_queue_create()
10471 spin_lock_init(&qp->hdwq_lock); in lpfc_sli4_queue_create()
10475 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10476 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
10477 phba->sli4_hba.nvmet_cqset = kcalloc( in lpfc_sli4_queue_create()
10478 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10481 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_create()
10484 "fast-path CQ set array\n"); in lpfc_sli4_queue_create()
10487 phba->sli4_hba.nvmet_mrq_hdr = kcalloc( in lpfc_sli4_queue_create()
10488 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10491 if (!phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_create()
10494 "fast-path RQ set hdr array\n"); in lpfc_sli4_queue_create()
10497 phba->sli4_hba.nvmet_mrq_data = kcalloc( in lpfc_sli4_queue_create()
10498 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10501 if (!phba->sli4_hba.nvmet_mrq_data) { in lpfc_sli4_queue_create()
10504 "fast-path RQ set data array\n"); in lpfc_sli4_queue_create()
10510 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10518 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
10519 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_create()
10523 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
10527 phba->sli4_hba.eq_esize, in lpfc_sli4_queue_create()
10528 phba->sli4_hba.eq_ecount, cpu); in lpfc_sli4_queue_create()
10532 cpup->hdwq); in lpfc_sli4_queue_create()
10535 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10536 qdesc->hdwq = cpup->hdwq; in lpfc_sli4_queue_create()
10537 qdesc->chann = cpu; /* First CPU this EQ is affinitized to */ in lpfc_sli4_queue_create()
10538 qdesc->last_cpu = qdesc->chann; in lpfc_sli4_queue_create()
10541 qp->hba_eq = qdesc; in lpfc_sli4_queue_create()
10543 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, qdesc->last_cpu); in lpfc_sli4_queue_create()
10544 list_add(&qdesc->cpu_list, &eqi->list); in lpfc_sli4_queue_create()
10551 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
10554 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_sli4_queue_create()
10558 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
10559 if (qp->hba_eq) in lpfc_sli4_queue_create()
10563 eqcpu = lpfc_find_cpu_handle(phba, cpup->eq, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
10564 eqcpup = &phba->sli4_hba.cpu_map[eqcpu]; in lpfc_sli4_queue_create()
10565 qp->hba_eq = phba->sli4_hba.hdwq[eqcpup->hdwq].hba_eq; in lpfc_sli4_queue_create()
10569 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10574 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
10575 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
10580 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10581 phba->sli4_hba.cq_ecount, in lpfc_sli4_queue_create()
10589 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10590 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10591 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10592 phba->sli4_hba.nvmet_cqset[idx] = qdesc; in lpfc_sli4_queue_create()
10601 /* Create slow-path Mailbox Command Complete Queue */ in lpfc_sli4_queue_create()
10603 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10604 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10607 "0500 Failed allocate slow-path mailbox CQ\n"); in lpfc_sli4_queue_create()
10610 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10611 phba->sli4_hba.mbx_cq = qdesc; in lpfc_sli4_queue_create()
10613 /* Create slow-path ELS Complete Queue */ in lpfc_sli4_queue_create()
10615 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10616 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10619 "0501 Failed allocate slow-path ELS CQ\n"); in lpfc_sli4_queue_create()
10622 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10623 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10624 phba->sli4_hba.els_cq = qdesc; in lpfc_sli4_queue_create()
10634 phba->sli4_hba.mq_esize, in lpfc_sli4_queue_create()
10635 phba->sli4_hba.mq_ecount, cpu); in lpfc_sli4_queue_create()
10638 "0505 Failed allocate slow-path MQ\n"); in lpfc_sli4_queue_create()
10641 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10642 phba->sli4_hba.mbx_wq = qdesc; in lpfc_sli4_queue_create()
10649 * Create slow-path ELS Work Queue. in lpfc_sli4_queue_create()
10652 wqesize = (phba->fcp_embed_io) ? in lpfc_sli4_queue_create()
10653 LPFC_WQE128_SIZE : phba->sli4_hba.wq_esize; in lpfc_sli4_queue_create()
10657 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
10660 "0504 Failed allocate slow-path ELS WQ\n"); in lpfc_sli4_queue_create()
10663 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10664 phba->sli4_hba.els_wq = qdesc; in lpfc_sli4_queue_create()
10665 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10667 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10670 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10671 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10677 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10678 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10679 phba->sli4_hba.nvmels_cq = qdesc; in lpfc_sli4_queue_create()
10683 phba->sli4_hba.wq_esize, in lpfc_sli4_queue_create()
10684 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
10690 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10691 phba->sli4_hba.nvmels_wq = qdesc; in lpfc_sli4_queue_create()
10692 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10701 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10702 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
10708 phba->sli4_hba.hdr_rq = qdesc; in lpfc_sli4_queue_create()
10712 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10713 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
10719 phba->sli4_hba.dat_rq = qdesc; in lpfc_sli4_queue_create()
10721 if ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) && in lpfc_sli4_queue_create()
10722 phba->nvmet_support) { in lpfc_sli4_queue_create()
10723 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
10729 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10738 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10739 phba->sli4_hba.nvmet_mrq_hdr[idx] = qdesc; in lpfc_sli4_queue_create()
10742 qdesc->rqbp = kzalloc_node(sizeof(*qdesc->rqbp), in lpfc_sli4_queue_create()
10745 if (qdesc->rqbp == NULL) { in lpfc_sli4_queue_create()
10753 INIT_LIST_HEAD(&qdesc->rqbp->rqb_buffer_list); in lpfc_sli4_queue_create()
10758 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10767 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10768 phba->sli4_hba.nvmet_mrq_data[idx] = qdesc; in lpfc_sli4_queue_create()
10773 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10774 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10775 memset(&phba->sli4_hba.hdwq[idx].nvme_cstat, 0, in lpfc_sli4_queue_create()
10776 sizeof(phba->sli4_hba.hdwq[idx].nvme_cstat)); in lpfc_sli4_queue_create()
10781 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { 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].scsi_cstat, 0, in lpfc_sli4_queue_create()
10784 sizeof(phba->sli4_hba.hdwq[idx].scsi_cstat)); in lpfc_sli4_queue_create()
10792 return -ENOMEM; in lpfc_sli4_queue_create()
10826 hdwq = phba->sli4_hba.hdwq; in lpfc_sli4_release_hdwq()
10829 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_release_hdwq()
10836 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_release_hdwq()
10841 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_release_hdwq()
10843 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_sli4_release_hdwq()
10845 phba->sli4_hba.hba_eq_hdl[idx].eq = NULL; in lpfc_sli4_release_hdwq()
10850 * lpfc_sli4_queue_destroy - Destroy all the SLI4 queues
10857 * 0 - successful
10858 * -ENOMEM - No available memory
10859 * -EIO - The mailbox failed to complete successfully.
10869 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10870 phba->sli.sli_flag |= LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
10871 while (phba->sli.sli_flag & LPFC_QUEUE_FREE_WAIT) { in lpfc_sli4_queue_destroy()
10872 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10874 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10876 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10881 if (phba->sli4_hba.hdwq) in lpfc_sli4_queue_destroy()
10884 if (phba->nvmet_support) { in lpfc_sli4_queue_destroy()
10885 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_destroy()
10886 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10888 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_destroy()
10889 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10890 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_destroy()
10891 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10895 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_destroy()
10898 __lpfc_sli4_release_queue(&phba->sli4_hba.els_wq); in lpfc_sli4_queue_destroy()
10901 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_destroy()
10904 __lpfc_sli4_release_queue(&phba->sli4_hba.hdr_rq); in lpfc_sli4_queue_destroy()
10905 __lpfc_sli4_release_queue(&phba->sli4_hba.dat_rq); in lpfc_sli4_queue_destroy()
10908 __lpfc_sli4_release_queue(&phba->sli4_hba.els_cq); in lpfc_sli4_queue_destroy()
10911 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_destroy()
10914 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_destroy()
10917 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_destroy()
10920 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10921 phba->sli.sli_flag &= ~LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
10922 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10932 rqbp = rq->rqbp; in lpfc_free_rq_buffer()
10933 while (!list_empty(&rqbp->rqb_buffer_list)) { in lpfc_free_rq_buffer()
10934 list_remove_head(&rqbp->rqb_buffer_list, h_buf, in lpfc_free_rq_buffer()
10938 (rqbp->rqb_free_buffer)(phba, rqb_buffer); in lpfc_free_rq_buffer()
10939 rqbp->buffer_count--; in lpfc_free_rq_buffer()
10954 "6085 Fast-path %s (%d) not allocated\n", in lpfc_create_wq_cq()
10956 return -ENOMEM; in lpfc_create_wq_cq()
10972 *cq_map = cq->queue_id; in lpfc_create_wq_cq()
10975 "6087 CQ setup: cq[%d]-id=%d, parent eq[%d]-id=%d\n", in lpfc_create_wq_cq()
10976 qidx, cq->queue_id, qidx, eq->queue_id); in lpfc_create_wq_cq()
10984 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
10989 pring = wq->pring; in lpfc_create_wq_cq()
10990 pring->sli.sli4.wqp = (void *)wq; in lpfc_create_wq_cq()
10991 cq->pring = pring; in lpfc_create_wq_cq()
10994 "2593 WQ setup: wq[%d]-id=%d assoc=%d, cq[%d]-id=%d\n", in lpfc_create_wq_cq()
10995 qidx, wq->queue_id, wq->assoc_qid, qidx, cq->queue_id); in lpfc_create_wq_cq()
11000 "0539 Failed setup of slow-path MQ: " in lpfc_create_wq_cq()
11002 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
11007 "2589 MBX MQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_create_wq_cq()
11008 phba->sli4_hba.mbx_wq->queue_id, in lpfc_create_wq_cq()
11009 phba->sli4_hba.mbx_cq->queue_id); in lpfc_create_wq_cq()
11016 * lpfc_setup_cq_lookup - Setup the CQ lookup table
11028 memset(phba->sli4_hba.cq_lookup, 0, in lpfc_setup_cq_lookup()
11029 (sizeof(struct lpfc_queue *) * (phba->sli4_hba.cq_max + 1))); in lpfc_setup_cq_lookup()
11031 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_setup_cq_lookup()
11033 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_setup_cq_lookup()
11037 list_for_each_entry(childq, &eq->child_list, list) { in lpfc_setup_cq_lookup()
11038 if (childq->queue_id > phba->sli4_hba.cq_max) in lpfc_setup_cq_lookup()
11040 if (childq->subtype == LPFC_IO) in lpfc_setup_cq_lookup()
11041 phba->sli4_hba.cq_lookup[childq->queue_id] = in lpfc_setup_cq_lookup()
11048 * lpfc_sli4_queue_setup - Set up all the SLI4 queues
11055 * 0 - successful
11056 * -ENOMEM - No available memory
11057 * -EIO - The mailbox failed to complete successfully.
11069 int rc = -ENOMEM; in lpfc_sli4_queue_setup()
11071 /* Check for dual-ULP support */ in lpfc_sli4_queue_setup()
11072 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_queue_setup()
11077 return -ENOMEM; in lpfc_sli4_queue_setup()
11079 length = (sizeof(struct lpfc_mbx_query_fw_config) - in lpfc_sli4_queue_setup()
11088 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_queue_setup()
11089 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_queue_setup()
11090 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_queue_setup()
11096 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
11097 rc = -ENXIO; in lpfc_sli4_queue_setup()
11101 phba->sli4_hba.fw_func_mode = in lpfc_sli4_queue_setup()
11102 mboxq->u.mqe.un.query_fw_cfg.rsp.function_mode; in lpfc_sli4_queue_setup()
11103 phba->sli4_hba.physical_port = in lpfc_sli4_queue_setup()
11104 mboxq->u.mqe.un.query_fw_cfg.rsp.physical_port; in lpfc_sli4_queue_setup()
11107 phba->sli4_hba.fw_func_mode); in lpfc_sli4_queue_setup()
11109 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
11114 qp = phba->sli4_hba.hdwq; in lpfc_sli4_queue_setup()
11119 "3147 Fast-path EQs not allocated\n"); in lpfc_sli4_queue_setup()
11120 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11125 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_setup()
11128 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
11133 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_setup()
11135 if (qidx != cpup->eq) in lpfc_sli4_queue_setup()
11139 rc = lpfc_eq_create(phba, qp[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
11140 phba->cfg_fcp_imax); in lpfc_sli4_queue_setup()
11143 "0523 Failed setup of fast-path" in lpfc_sli4_queue_setup()
11145 cpup->eq, (uint32_t)rc); in lpfc_sli4_queue_setup()
11150 phba->sli4_hba.hba_eq_hdl[cpup->eq].eq = in lpfc_sli4_queue_setup()
11151 qp[cpup->hdwq].hba_eq; in lpfc_sli4_queue_setup()
11154 "2584 HBA EQ setup: queue[%d]-id=%d\n", in lpfc_sli4_queue_setup()
11155 cpup->eq, in lpfc_sli4_queue_setup()
11156 qp[cpup->hdwq].hba_eq->queue_id); in lpfc_sli4_queue_setup()
11161 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_setup()
11163 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
11167 phba->sli4_hba.hdwq[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
11170 &phba->sli4_hba.hdwq[qidx].io_cq_map, in lpfc_sli4_queue_setup()
11186 /* Set up slow-path MBOX CQ/MQ */ in lpfc_sli4_queue_setup()
11188 if (!phba->sli4_hba.mbx_cq || !phba->sli4_hba.mbx_wq) { in lpfc_sli4_queue_setup()
11191 phba->sli4_hba.mbx_cq ? in lpfc_sli4_queue_setup()
11193 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11198 phba->sli4_hba.mbx_cq, in lpfc_sli4_queue_setup()
11199 phba->sli4_hba.mbx_wq, in lpfc_sli4_queue_setup()
11207 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
11208 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_setup()
11210 "3165 Fast-path NVME CQ Set " in lpfc_sli4_queue_setup()
11212 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11215 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
11217 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
11229 rc = lpfc_cq_create(phba, phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
11238 phba->sli4_hba.nvmet_cqset[0]->chann = 0; in lpfc_sli4_queue_setup()
11241 "6090 NVMET CQ setup: cq-id=%d, " in lpfc_sli4_queue_setup()
11242 "parent eq-id=%d\n", in lpfc_sli4_queue_setup()
11243 phba->sli4_hba.nvmet_cqset[0]->queue_id, in lpfc_sli4_queue_setup()
11244 qp[0].hba_eq->queue_id); in lpfc_sli4_queue_setup()
11248 /* Set up slow-path ELS WQ/CQ */ in lpfc_sli4_queue_setup()
11249 if (!phba->sli4_hba.els_cq || !phba->sli4_hba.els_wq) { in lpfc_sli4_queue_setup()
11252 phba->sli4_hba.els_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
11253 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11257 phba->sli4_hba.els_cq, in lpfc_sli4_queue_setup()
11258 phba->sli4_hba.els_wq, in lpfc_sli4_queue_setup()
11267 "2590 ELS WQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11268 phba->sli4_hba.els_wq->queue_id, in lpfc_sli4_queue_setup()
11269 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
11271 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_setup()
11273 if (!phba->sli4_hba.nvmels_cq || !phba->sli4_hba.nvmels_wq) { in lpfc_sli4_queue_setup()
11276 phba->sli4_hba.nvmels_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
11277 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11281 phba->sli4_hba.nvmels_cq, in lpfc_sli4_queue_setup()
11282 phba->sli4_hba.nvmels_wq, in lpfc_sli4_queue_setup()
11292 "6096 ELS WQ setup: wq-id=%d, " in lpfc_sli4_queue_setup()
11293 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11294 phba->sli4_hba.nvmels_wq->queue_id, in lpfc_sli4_queue_setup()
11295 phba->sli4_hba.nvmels_cq->queue_id); in lpfc_sli4_queue_setup()
11301 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
11302 if ((!phba->sli4_hba.nvmet_cqset) || in lpfc_sli4_queue_setup()
11303 (!phba->sli4_hba.nvmet_mrq_hdr) || in lpfc_sli4_queue_setup()
11304 (!phba->sli4_hba.nvmet_mrq_data)) { in lpfc_sli4_queue_setup()
11308 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11311 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
11313 phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_setup()
11314 phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_setup()
11315 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
11327 phba->sli4_hba.nvmet_mrq_hdr[0], in lpfc_sli4_queue_setup()
11328 phba->sli4_hba.nvmet_mrq_data[0], in lpfc_sli4_queue_setup()
11329 phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
11341 "6099 NVMET RQ setup: hdr-rq-id=%d, " in lpfc_sli4_queue_setup()
11342 "dat-rq-id=%d parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11343 phba->sli4_hba.nvmet_mrq_hdr[0]->queue_id, in lpfc_sli4_queue_setup()
11344 phba->sli4_hba.nvmet_mrq_data[0]->queue_id, in lpfc_sli4_queue_setup()
11345 phba->sli4_hba.nvmet_cqset[0]->queue_id); in lpfc_sli4_queue_setup()
11350 if (!phba->sli4_hba.hdr_rq || !phba->sli4_hba.dat_rq) { in lpfc_sli4_queue_setup()
11353 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11357 rc = lpfc_rq_create(phba, phba->sli4_hba.hdr_rq, phba->sli4_hba.dat_rq, in lpfc_sli4_queue_setup()
11358 phba->sli4_hba.els_cq, LPFC_USOL); in lpfc_sli4_queue_setup()
11367 "2592 USL RQ setup: hdr-rq-id=%d, dat-rq-id=%d " in lpfc_sli4_queue_setup()
11368 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11369 phba->sli4_hba.hdr_rq->queue_id, in lpfc_sli4_queue_setup()
11370 phba->sli4_hba.dat_rq->queue_id, in lpfc_sli4_queue_setup()
11371 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
11373 if (phba->cfg_fcp_imax) in lpfc_sli4_queue_setup()
11374 usdelay = LPFC_SEC_TO_USEC / phba->cfg_fcp_imax; in lpfc_sli4_queue_setup()
11378 for (qidx = 0; qidx < phba->cfg_irq_chann; in lpfc_sli4_queue_setup()
11383 if (phba->sli4_hba.cq_max) { in lpfc_sli4_queue_setup()
11384 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_setup()
11385 phba->sli4_hba.cq_lookup = kcalloc((phba->sli4_hba.cq_max + 1), in lpfc_sli4_queue_setup()
11387 if (!phba->sli4_hba.cq_lookup) { in lpfc_sli4_queue_setup()
11390 "size 0x%x\n", phba->sli4_hba.cq_max); in lpfc_sli4_queue_setup()
11391 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11405 * lpfc_sli4_queue_unset - Unset all the SLI4 queues
11412 * 0 - successful
11413 * -ENOMEM - No available memory
11414 * -EIO - The mailbox failed to complete successfully.
11424 if (phba->sli4_hba.mbx_wq) in lpfc_sli4_queue_unset()
11425 lpfc_mq_destroy(phba, phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_unset()
11428 if (phba->sli4_hba.nvmels_wq) in lpfc_sli4_queue_unset()
11429 lpfc_wq_destroy(phba, phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_unset()
11432 if (phba->sli4_hba.els_wq) in lpfc_sli4_queue_unset()
11433 lpfc_wq_destroy(phba, phba->sli4_hba.els_wq); in lpfc_sli4_queue_unset()
11436 if (phba->sli4_hba.hdr_rq) in lpfc_sli4_queue_unset()
11437 lpfc_rq_destroy(phba, phba->sli4_hba.hdr_rq, in lpfc_sli4_queue_unset()
11438 phba->sli4_hba.dat_rq); in lpfc_sli4_queue_unset()
11441 if (phba->sli4_hba.mbx_cq) in lpfc_sli4_queue_unset()
11442 lpfc_cq_destroy(phba, phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_unset()
11445 if (phba->sli4_hba.els_cq) in lpfc_sli4_queue_unset()
11446 lpfc_cq_destroy(phba, phba->sli4_hba.els_cq); in lpfc_sli4_queue_unset()
11449 if (phba->sli4_hba.nvmels_cq) in lpfc_sli4_queue_unset()
11450 lpfc_cq_destroy(phba, phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_unset()
11452 if (phba->nvmet_support) { in lpfc_sli4_queue_unset()
11454 if (phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_unset()
11455 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
11458 phba->sli4_hba.nvmet_mrq_hdr[qidx], in lpfc_sli4_queue_unset()
11459 phba->sli4_hba.nvmet_mrq_data[qidx]); in lpfc_sli4_queue_unset()
11463 if (phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_unset()
11464 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
11466 phba, phba->sli4_hba.nvmet_cqset[qidx]); in lpfc_sli4_queue_unset()
11470 /* Unset fast-path SLI4 queues */ in lpfc_sli4_queue_unset()
11471 if (phba->sli4_hba.hdwq) { in lpfc_sli4_queue_unset()
11473 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_unset()
11475 qp = &phba->sli4_hba.hdwq[qidx]; in lpfc_sli4_queue_unset()
11476 lpfc_wq_destroy(phba, qp->io_wq); in lpfc_sli4_queue_unset()
11477 lpfc_cq_destroy(phba, qp->io_cq); in lpfc_sli4_queue_unset()
11480 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_unset()
11482 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_sli4_queue_unset()
11487 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_unset()
11488 phba->sli4_hba.cq_lookup = NULL; in lpfc_sli4_queue_unset()
11489 phba->sli4_hba.cq_max = 0; in lpfc_sli4_queue_unset()
11493 * lpfc_sli4_cq_event_pool_create - Create completion-queue event free pool
11500 * - Mailbox asynchronous events
11501 * - Receive queue completion unsolicited events
11502 * Later, this can be used for all the slow-path events.
11505 * 0 - successful
11506 * -ENOMEM - No available memory
11514 for (i = 0; i < (4 * phba->sli4_hba.cq_ecount); i++) { in lpfc_sli4_cq_event_pool_create()
11518 list_add_tail(&cq_event->list, in lpfc_sli4_cq_event_pool_create()
11519 &phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_cq_event_pool_create()
11525 return -ENOMEM; in lpfc_sli4_cq_event_pool_create()
11529 * lpfc_sli4_cq_event_pool_destroy - Free completion-queue event free pool
11534 * cleanup routine to free all the outstanding completion-queue events
11544 &phba->sli4_hba.sp_cqe_event_pool, list) { in lpfc_sli4_cq_event_pool_destroy()
11545 list_del(&cq_event->list); in lpfc_sli4_cq_event_pool_destroy()
11551 * __lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
11555 * completion-queue event from the free pool.
11557 * Return: Pointer to the newly allocated completion-queue event if successful
11565 list_remove_head(&phba->sli4_hba.sp_cqe_event_pool, cq_event, in __lpfc_sli4_cq_event_alloc()
11571 * lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
11575 * completion-queue event from the free pool.
11577 * Return: Pointer to the newly allocated completion-queue event if successful
11586 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
11588 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
11593 * __lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
11598 * completion-queue event back into the free pool.
11604 list_add_tail(&cq_event->list, &phba->sli4_hba.sp_cqe_event_pool); in __lpfc_sli4_cq_event_release()
11608 * lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
11613 * completion-queue event back into the free pool.
11620 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
11622 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
11626 * lpfc_sli4_cq_event_release_all - Release all cq events to the free pool
11629 * This routine is to free all the pending completion-queue events to the
11642 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11643 list_splice_init(&phba->sli4_hba.sp_els_xri_aborted_work_queue, in lpfc_sli4_cq_event_release_all()
11645 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11648 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11649 list_splice_init(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_cq_event_release_all()
11651 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11661 * lpfc_pci_function_reset - Reset pci function.
11668 * 0 - successful
11669 * -ENOMEM - No available memory
11670 * -EIO - The mailbox failed to complete successfully.
11684 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_pci_function_reset()
11687 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_pci_function_reset()
11694 return -ENOMEM; in lpfc_pci_function_reset()
11697 /* Setup PCI function reset mailbox-ioctl command */ in lpfc_pci_function_reset()
11703 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_pci_function_reset()
11704 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_pci_function_reset()
11706 &shdr->response); in lpfc_pci_function_reset()
11707 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_pci_function_reset()
11714 rc = -ENXIO; in lpfc_pci_function_reset()
11726 if (lpfc_readl(phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
11728 rc = -ENODEV; in lpfc_pci_function_reset()
11737 phba->work_status[0] = readl( in lpfc_pci_function_reset()
11738 phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_pci_function_reset()
11739 phba->work_status[1] = readl( in lpfc_pci_function_reset()
11740 phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_pci_function_reset()
11745 phba->work_status[0], in lpfc_pci_function_reset()
11746 phba->work_status[1]); in lpfc_pci_function_reset()
11747 rc = -ENODEV; in lpfc_pci_function_reset()
11763 writel(reg_data.word0, phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
11766 pci_read_config_word(phba->pcidev, in lpfc_pci_function_reset()
11773 rc = -ENODEV; in lpfc_pci_function_reset()
11784 /* Catch the not-ready port failure after a port reset. */ in lpfc_pci_function_reset()
11789 rc = -ENODEV; in lpfc_pci_function_reset()
11796 * lpfc_sli4_pci_mem_setup - Setup SLI4 HBA PCI memory space.
11800 * with SLI-4 interface spec.
11803 * 0 - successful
11804 * other values - error
11809 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_pci_mem_setup()
11815 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11818 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli4_pci_mem_setup()
11820 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli4_pci_mem_setup()
11829 &phba->sli4_hba.sli_intf.word0)) { in lpfc_sli4_pci_mem_setup()
11830 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11834 if (bf_get(lpfc_sli_intf_valid, &phba->sli4_hba.sli_intf) != in lpfc_sli4_pci_mem_setup()
11839 phba->sli4_hba.sli_intf.word0); in lpfc_sli4_pci_mem_setup()
11840 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11843 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_setup()
11851 phba->pci_bar0_map = pci_resource_start(pdev, PCI_64BIT_BAR0); in lpfc_sli4_pci_mem_setup()
11858 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11859 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
11860 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11861 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11864 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11866 phba->pci_bar0_memmap_p = phba->sli4_hba.conf_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11870 phba->pci_bar0_map = pci_resource_start(pdev, 1); in lpfc_sli4_pci_mem_setup()
11873 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11874 "FATAL - No BAR0 mapping for SLI4, if_type 2\n"); in lpfc_sli4_pci_mem_setup()
11875 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11877 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11878 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
11879 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11880 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11883 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11894 phba->pci_bar1_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
11897 phba->sli4_hba.ctrl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11898 ioremap(phba->pci_bar1_map, in lpfc_sli4_pci_mem_setup()
11900 if (!phba->sli4_hba.ctrl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11901 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11904 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11907 phba->pci_bar2_memmap_p = in lpfc_sli4_pci_mem_setup()
11908 phba->sli4_hba.ctrl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11911 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11922 phba->pci_bar1_map = pci_resource_start(pdev, PCI_64BIT_BAR2); in lpfc_sli4_pci_mem_setup()
11924 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11925 ioremap(phba->pci_bar1_map, bar1map_len); in lpfc_sli4_pci_mem_setup()
11926 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11927 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11929 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11932 phba->pci_bar2_memmap_p = phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11942 phba->pci_bar2_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
11945 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11946 ioremap(phba->pci_bar2_map, in lpfc_sli4_pci_mem_setup()
11948 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11949 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11952 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11955 phba->pci_bar4_memmap_p = in lpfc_sli4_pci_mem_setup()
11956 phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11961 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11972 phba->pci_bar2_map = pci_resource_start(pdev, PCI_64BIT_BAR4); in lpfc_sli4_pci_mem_setup()
11974 phba->sli4_hba.dpp_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11975 ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli4_pci_mem_setup()
11976 if (!phba->sli4_hba.dpp_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11977 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11979 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11982 phba->pci_bar4_memmap_p = phba->sli4_hba.dpp_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11989 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
11990 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_write_eq_db; in lpfc_sli4_pci_mem_setup()
11991 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_write_cq_db; in lpfc_sli4_pci_mem_setup()
11994 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_if6_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
11995 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_if6_write_eq_db; in lpfc_sli4_pci_mem_setup()
11996 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_if6_write_cq_db; in lpfc_sli4_pci_mem_setup()
12005 if (phba->sli4_hba.drbl_regs_memmap_p) in lpfc_sli4_pci_mem_setup()
12006 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12008 if (phba->sli4_hba.ctrl_regs_memmap_p) in lpfc_sli4_pci_mem_setup()
12009 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12011 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12017 * lpfc_sli4_pci_mem_unset - Unset SLI4 HBA PCI memory space.
12021 * with SLI-4 interface spec.
12027 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_unset()
12031 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12032 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12033 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12036 iounmap(phba->sli4_hba.conf_regs_memmap_p); 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.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12041 if (phba->sli4_hba.dpp_regs_memmap_p) in lpfc_sli4_pci_mem_unset()
12042 iounmap(phba->sli4_hba.dpp_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12047 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_pci_mem_unset()
12048 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_pci_mem_unset()
12055 * lpfc_sli_enable_msix - Enable MSI-X interrupt mode on SLI-3 device
12058 * This routine is invoked to enable the MSI-X interrupt vectors to device
12059 * with SLI-3 interface specs.
12062 * 0 - successful
12063 * other values - error
12071 /* Set up MSI-X multi-message vectors */ in lpfc_sli_enable_msix()
12072 rc = pci_alloc_irq_vectors(phba->pcidev, in lpfc_sli_enable_msix()
12076 "0420 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli_enable_msix()
12081 * Assign MSI-X vectors to interrupt handlers in lpfc_sli_enable_msix()
12084 /* vector-0 is associated to slow-path handler */ in lpfc_sli_enable_msix()
12085 rc = request_irq(pci_irq_vector(phba->pcidev, 0), in lpfc_sli_enable_msix()
12090 "0421 MSI-X slow-path request_irq failed " in lpfc_sli_enable_msix()
12095 /* vector-1 is associated to fast-path handler */ in lpfc_sli_enable_msix()
12096 rc = request_irq(pci_irq_vector(phba->pcidev, 1), in lpfc_sli_enable_msix()
12102 "0429 MSI-X fast-path request_irq failed " in lpfc_sli_enable_msix()
12108 * Configure HBA MSI-X attention conditions to messages in lpfc_sli_enable_msix()
12110 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_enable_msix()
12113 rc = -ENOMEM; in lpfc_sli_enable_msix()
12127 pmb->u.mb.mbxCommand, pmb->u.mb.mbxStatus); in lpfc_sli_enable_msix()
12132 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
12137 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
12141 free_irq(pci_irq_vector(phba->pcidev, 1), phba); in lpfc_sli_enable_msix()
12145 free_irq(pci_irq_vector(phba->pcidev, 0), phba); in lpfc_sli_enable_msix()
12148 /* Unconfigure MSI-X capability structure */ in lpfc_sli_enable_msix()
12149 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_enable_msix()
12156 * lpfc_sli_enable_msi - Enable MSI interrupt mode on SLI-3 device.
12160 * SLI-3 interface spec. The kernel function pci_enable_msi() is called to
12166 * 0 - successful
12167 * other values - error
12174 rc = pci_enable_msi(phba->pcidev); in lpfc_sli_enable_msi()
12184 rc = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_msi()
12187 pci_disable_msi(phba->pcidev); in lpfc_sli_enable_msi()
12195 * lpfc_sli_enable_intr - Enable device interrupt to SLI-3 device.
12197 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
12200 * interrupt handler(s) to interrupt vector(s) to device with SLI-3 interface
12205 * MSI-X -> MSI -> IRQ.
12208 * 0 - successful
12209 * other values - error
12221 clear_bit(HBA_NEEDS_CFG_PORT, &phba->hba_flag); in lpfc_sli_enable_intr()
12224 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli_enable_intr()
12227 /* Indicate initialization to MSI-X mode */ in lpfc_sli_enable_intr()
12228 phba->intr_type = MSIX; in lpfc_sli_enable_intr()
12233 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli_enable_intr()
12234 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli_enable_intr()
12238 phba->intr_type = MSI; in lpfc_sli_enable_intr()
12243 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli_enable_intr()
12244 if (phba->intr_type == NONE) { in lpfc_sli_enable_intr()
12245 retval = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_intr()
12249 phba->intr_type = INTx; in lpfc_sli_enable_intr()
12257 * lpfc_sli_disable_intr - Disable device interrupt to SLI-3 device.
12262 * SLI-3 interface spec. Depending on the interrupt mode, the driver will
12270 if (phba->intr_type == MSIX) in lpfc_sli_disable_intr()
12276 free_irq(pci_irq_vector(phba->pcidev, i), phba); in lpfc_sli_disable_intr()
12277 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_disable_intr()
12280 phba->intr_type = NONE; in lpfc_sli_disable_intr()
12281 phba->sli.slistat.sli_intr = 0; in lpfc_sli_disable_intr()
12285 * lpfc_find_cpu_handle - Find the CPU that corresponds to the specified Queue
12300 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_find_cpu_handle()
12307 (cpup->flag & LPFC_CPU_FIRST_IRQ) && in lpfc_find_cpu_handle()
12308 (cpup->eq == id)) in lpfc_find_cpu_handle()
12312 if ((match == LPFC_FIND_BY_HDWQ) && (cpup->hdwq == id)) in lpfc_find_cpu_handle()
12320 * lpfc_find_hyper - Determine if the CPU map entry is hyper-threaded
12334 cpup = &phba->sli4_hba.cpu_map[idx]; in lpfc_find_hyper()
12336 if ((cpup->phys_id == phys_id) && in lpfc_find_hyper()
12337 (cpup->core_id == core_id) && in lpfc_find_hyper()
12346 * lpfc_assign_eq_map_info - Assigns eq for vector_map structure
12358 struct lpfc_vector_map_info *cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_assign_eq_map_info()
12361 cpup->eq = eqidx; in lpfc_assign_eq_map_info()
12362 cpup->flag |= flag; in lpfc_assign_eq_map_info()
12366 cpu, eqhdl->irq, cpup->eq, cpup->flag); in lpfc_assign_eq_map_info()
12370 * lpfc_cpu_map_array_init - Initialize cpu_map structure
12383 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_map_array_init()
12384 cpup->phys_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12385 cpup->core_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12386 cpup->hdwq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12387 cpup->eq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12388 cpup->flag = 0; in lpfc_cpu_map_array_init()
12389 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, cpu); in lpfc_cpu_map_array_init()
12390 INIT_LIST_HEAD(&eqi->list); in lpfc_cpu_map_array_init()
12391 eqi->icnt = 0; in lpfc_cpu_map_array_init()
12396 * lpfc_hba_eq_hdl_array_init - Initialize hba_eq_hdl structure
12407 for (i = 0; i < phba->cfg_irq_chann; i++) { in lpfc_hba_eq_hdl_array_init()
12409 eqhdl->irq = LPFC_IRQ_EMPTY; in lpfc_hba_eq_hdl_array_init()
12410 eqhdl->phba = phba; in lpfc_hba_eq_hdl_array_init()
12415 * lpfc_cpu_affinity_check - Check vector CPU affinity mappings
12420 * MSI-X vector allocated for the HBA.
12422 * and the phba->sli4_hba.cpu_map array will reflect this.
12443 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12445 cpup->phys_id = topology_physical_package_id(cpu); in lpfc_cpu_affinity_check()
12446 cpup->core_id = topology_core_id(cpu); in lpfc_cpu_affinity_check()
12447 if (lpfc_find_hyper(phba, cpu, cpup->phys_id, cpup->core_id)) in lpfc_cpu_affinity_check()
12448 cpup->flag |= LPFC_CPU_MAP_HYPER; in lpfc_cpu_affinity_check()
12451 cpup->phys_id = 0; in lpfc_cpu_affinity_check()
12452 cpup->core_id = cpu; in lpfc_cpu_affinity_check()
12457 cpu, cpup->phys_id, cpup->core_id, cpup->flag); in lpfc_cpu_affinity_check()
12459 if (cpup->phys_id > max_phys_id) in lpfc_cpu_affinity_check()
12460 max_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
12461 if (cpup->phys_id < min_phys_id) in lpfc_cpu_affinity_check()
12462 min_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
12464 if (cpup->core_id > max_core_id) in lpfc_cpu_affinity_check()
12465 max_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
12466 if (cpup->core_id < min_core_id) in lpfc_cpu_affinity_check()
12467 min_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
12479 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12482 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
12484 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
12492 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12493 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12494 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
12495 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY) && in lpfc_cpu_affinity_check()
12496 (new_cpup->phys_id == cpup->phys_id)) in lpfc_cpu_affinity_check()
12504 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
12516 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
12517 cpup->phys_id); in lpfc_cpu_affinity_check()
12525 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12528 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
12530 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
12538 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12539 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12540 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
12541 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY)) in lpfc_cpu_affinity_check()
12549 cpup->hdwq, cpup->eq); in lpfc_cpu_affinity_check()
12553 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
12564 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
12565 new_cpup->phys_id, new_cpup->core_id); in lpfc_cpu_affinity_check()
12574 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12577 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_cpu_affinity_check()
12581 cpup->hdwq = idx; in lpfc_cpu_affinity_check()
12586 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
12587 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
12590 * This will be 1 to 1 - hdwq to cpu, unless there are less in lpfc_cpu_affinity_check()
12591 * hardware queues then CPUs. For that case we will just round-robin in lpfc_cpu_affinity_check()
12594 * for irq_chann < hdwq. The idx is used for round-robin assignments in lpfc_cpu_affinity_check()
12601 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12604 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_cpu_affinity_check()
12611 if (next_idx < phba->cfg_hdw_queue) { in lpfc_cpu_affinity_check()
12612 cpup->hdwq = next_idx; in lpfc_cpu_affinity_check()
12623 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12624 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12625 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
12626 new_cpup->phys_id == cpup->phys_id && in lpfc_cpu_affinity_check()
12627 new_cpup->core_id == cpup->core_id) { in lpfc_cpu_affinity_check()
12637 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12638 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12639 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
12640 new_cpup->phys_id == cpup->phys_id) in lpfc_cpu_affinity_check()
12646 cpup->hdwq = idx % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
12652 cpup->hdwq = new_cpup->hdwq; in lpfc_cpu_affinity_check()
12657 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
12658 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
12662 * Initialize the cpu_map slots for not-present cpus in case in lpfc_cpu_affinity_check()
12663 * a cpu is hot-added. Perform a simple hdwq round robin assignment. in lpfc_cpu_affinity_check()
12667 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12669 c_stat = per_cpu_ptr(phba->sli4_hba.c_stat, cpu); in lpfc_cpu_affinity_check()
12670 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
12672 if (cpup->hdwq != LPFC_VECTOR_MAP_EMPTY) in lpfc_cpu_affinity_check()
12675 cpup->hdwq = idx++ % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
12677 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
12682 cpu, cpup->hdwq); in lpfc_cpu_affinity_check()
12709 return -ENOMEM; in lpfc_cpuhp_get_eq()
12711 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_cpuhp_get_eq()
12712 maskp = pci_irq_get_affinity(phba->pcidev, idx); in lpfc_cpuhp_get_eq()
12722 /* get the cpus that are online and are affini- in lpfc_cpuhp_get_eq()
12724 * more than 1 then cpuhp is not going to shut- in lpfc_cpuhp_get_eq()
12737 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_cpuhp_get_eq()
12738 list_add(&eq->_poll_list, eqlist); in lpfc_cpuhp_get_eq()
12746 if (phba->sli_rev != LPFC_SLI_REV4) in __lpfc_cpuhp_remove()
12750 &phba->cpuhp); in __lpfc_cpuhp_remove()
12756 timer_delete_sync(&phba->cpuhp_poll_timer); in __lpfc_cpuhp_remove()
12761 if (phba->pport && in lpfc_cpuhp_remove()
12762 test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_cpuhp_remove()
12770 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_cpuhp_add()
12775 if (!list_empty(&phba->poll_list)) in lpfc_cpuhp_add()
12776 mod_timer(&phba->cpuhp_poll_timer, in lpfc_cpuhp_add()
12782 &phba->cpuhp); in lpfc_cpuhp_add()
12787 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { in __lpfc_cpuhp_checks()
12788 *retval = -EAGAIN; in __lpfc_cpuhp_checks()
12792 if (phba->sli_rev != LPFC_SLI_REV4) { in __lpfc_cpuhp_checks()
12802 * lpfc_irq_set_aff - set IRQ affinity
12810 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_set_aff()
12811 cpumask_set_cpu(cpu, &eqhdl->aff_mask); in lpfc_irq_set_aff()
12812 irq_set_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_set_aff()
12813 irq_set_affinity(eqhdl->irq, &eqhdl->aff_mask); in lpfc_irq_set_aff()
12817 * lpfc_irq_clear_aff - clear IRQ affinity
12824 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_clear_aff()
12825 irq_clear_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_clear_aff()
12829 * lpfc_irq_rebalance - rebalances IRQ affinity according to cpuhp event
12841 * PCI_IRQ_AFFINITY to auto-manage IRQ affinity.
12852 if (phba->irq_chann_mode == NORMAL_MODE) in lpfc_irq_rebalance()
12855 orig_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_irq_rebalance()
12860 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_irq_rebalance()
12862 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_irq_rebalance()
12875 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_irq_rebalance()
12885 for (idx = 0; idx < phba->cfg_irq_chann; idx++) in lpfc_irq_rebalance()
12890 lpfc_irq_set_aff(lpfc_get_eq_hdl(cpup->eq), cpu); in lpfc_irq_rebalance()
12917 list_del_init(&eq->_poll_list); in lpfc_cpu_offline()
12941 list_for_each_entry_safe(eq, next, &phba->poll_list, _poll_list) { in lpfc_cpu_online()
12942 n = lpfc_find_cpu_handle(phba, eq->hdwq, LPFC_FIND_BY_HDWQ); in lpfc_cpu_online()
12951 * lpfc_sli4_enable_msix - Enable MSI-X interrupt mode to SLI-4 device
12954 * This routine is invoked to enable the MSI-X interrupt vectors to device
12955 * with SLI-4 interface spec. It also allocates MSI-X vectors and maps them
12975 * 0 - successful
12976 * other values - error
12990 /* Set up MSI-X multi-message vectors */ in lpfc_sli4_enable_msix()
12991 vectors = phba->cfg_irq_chann; in lpfc_sli4_enable_msix()
12993 if (phba->irq_chann_mode != NORMAL_MODE) in lpfc_sli4_enable_msix()
12994 aff_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_sli4_enable_msix()
12998 vectors = min(phba->cfg_irq_chann, cpu_cnt); in lpfc_sli4_enable_msix()
13009 rc = pci_alloc_irq_vectors(phba->pcidev, 1, vectors, flags); in lpfc_sli4_enable_msix()
13012 "0484 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli4_enable_msix()
13017 /* Assign MSI-X vectors to interrupt handlers */ in lpfc_sli4_enable_msix()
13020 name = eqhdl->handler_name; in lpfc_sli4_enable_msix()
13025 eqhdl->idx = index; in lpfc_sli4_enable_msix()
13026 rc = pci_irq_vector(phba->pcidev, index); in lpfc_sli4_enable_msix()
13029 "0489 MSI-X fast-path (%d) " in lpfc_sli4_enable_msix()
13033 eqhdl->irq = rc; in lpfc_sli4_enable_msix()
13035 rc = request_threaded_irq(eqhdl->irq, in lpfc_sli4_enable_msix()
13041 "0486 MSI-X fast-path (%d) " in lpfc_sli4_enable_msix()
13066 maskp = pci_irq_get_affinity(phba->pcidev, index); in lpfc_sli4_enable_msix()
13070 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_enable_msix()
13084 if (cpup->eq != LPFC_VECTOR_MAP_EMPTY) in lpfc_sli4_enable_msix()
13094 if (vectors != phba->cfg_irq_chann) { in lpfc_sli4_enable_msix()
13097 "MSI-X vectors, requested %d got %d\n", in lpfc_sli4_enable_msix()
13098 phba->cfg_irq_chann, vectors); in lpfc_sli4_enable_msix()
13099 if (phba->cfg_irq_chann > vectors) in lpfc_sli4_enable_msix()
13100 phba->cfg_irq_chann = vectors; in lpfc_sli4_enable_msix()
13107 for (--index; index >= 0; index--) { in lpfc_sli4_enable_msix()
13110 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_enable_msix()
13113 /* Unconfigure MSI-X capability structure */ in lpfc_sli4_enable_msix()
13114 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msix()
13121 * lpfc_sli4_enable_msi - Enable MSI interrupt mode to SLI-4 device
13125 * SLI-4 interface spec. The kernel function pci_alloc_irq_vectors() is
13131 * 0 - successful
13132 * other values - error
13141 rc = pci_alloc_irq_vectors(phba->pcidev, 1, 1, in lpfc_sli4_enable_msi()
13149 return rc ? rc : -1; in lpfc_sli4_enable_msi()
13152 rc = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_msi()
13155 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msi()
13162 rc = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_msi()
13164 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_enable_msi()
13165 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msi()
13170 eqhdl->irq = rc; in lpfc_sli4_enable_msi()
13175 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_enable_msi()
13177 eqhdl->idx = index; in lpfc_sli4_enable_msi()
13184 * lpfc_sli4_enable_intr - Enable device interrupt to SLI-4 device
13186 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
13189 * interrupt handler(s) to interrupt vector(s) to device with SLI-4
13194 * MSI-X -> MSI -> IRQ.
13197 * Interrupt mode (2, 1, 0) - successful
13198 * LPFC_INTR_ERROR - error
13210 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli4_enable_intr()
13213 /* Indicate initialization to MSI-X mode */ in lpfc_sli4_enable_intr()
13214 phba->intr_type = MSIX; in lpfc_sli4_enable_intr()
13220 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli4_enable_intr()
13221 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
13225 phba->intr_type = MSI; in lpfc_sli4_enable_intr()
13230 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli4_enable_intr()
13231 if (phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
13232 retval = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_intr()
13239 phba->intr_type = INTx; in lpfc_sli4_enable_intr()
13243 retval = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_intr()
13245 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_enable_intr()
13251 eqhdl->irq = retval; in lpfc_sli4_enable_intr()
13256 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_enable_intr()
13258 eqhdl->idx = idx; in lpfc_sli4_enable_intr()
13266 * lpfc_sli4_disable_intr - Disable device interrupt to SLI-4 device
13271 * with SLI-4 interface spec. Depending on the interrupt mode, the driver
13278 if (phba->intr_type == MSIX) { in lpfc_sli4_disable_intr()
13282 /* Free up MSI-X multi-message vectors */ in lpfc_sli4_disable_intr()
13283 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_disable_intr()
13286 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_disable_intr()
13289 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_disable_intr()
13292 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_disable_intr()
13295 phba->intr_type = NONE; in lpfc_sli4_disable_intr()
13296 phba->sli.slistat.sli_intr = 0; in lpfc_sli4_disable_intr()
13300 * lpfc_unset_hba - Unset SLI3 hba device initialization
13304 * a device with SLI-3 interface spec.
13309 set_bit(FC_UNLOADING, &phba->pport->load_flag); in lpfc_unset_hba()
13311 kfree(phba->vpi_bmask); in lpfc_unset_hba()
13312 kfree(phba->vpi_ids); in lpfc_unset_hba()
13316 phba->pport->work_port_events = 0; in lpfc_unset_hba()
13328 * lpfc_sli4_xri_exchange_busy_wait - Wait for device XRI exchange busy
13348 int els_xri_cmpl = list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
13357 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_xri_exchange_busy_wait()
13361 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
13362 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
13363 io_xri_cmpl = list_empty(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
13370 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
13372 list_empty(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
13400 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
13401 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
13403 &qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
13410 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
13412 &phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
13415 list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
13421 * lpfc_sli4_hba_unset - Unset the fcoe hba
13435 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_hba_unset()
13438 hrtimer_cancel(&phba->cmf_stats_timer); in lpfc_sli4_hba_unset()
13439 hrtimer_cancel(&phba->cmf_timer); in lpfc_sli4_hba_unset()
13441 if (phba->pport) in lpfc_sli4_hba_unset()
13442 phba->sli4_hba.intr_enable = 0; in lpfc_sli4_hba_unset()
13450 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13451 phba->sli.sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_hba_unset()
13452 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13454 while (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
13460 if (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
13461 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13462 mboxq = phba->sli.mbox_active; in lpfc_sli4_hba_unset()
13463 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_hba_unset()
13465 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_hba_unset()
13466 phba->sli.mbox_active = NULL; in lpfc_sli4_hba_unset()
13467 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13473 if (!pci_channel_offline(phba->pcidev)) in lpfc_sli4_hba_unset()
13477 /* per-phba callback de-registration for hotplug event */ in lpfc_sli4_hba_unset()
13478 if (phba->pport) in lpfc_sli4_hba_unset()
13484 /* Disable SR-IOV if enabled */ in lpfc_sli4_hba_unset()
13485 if (phba->cfg_sriov_nr_virtfn) in lpfc_sli4_hba_unset()
13489 kthread_stop(phba->worker_thread); in lpfc_sli4_hba_unset()
13503 if (phba->ras_fwlog.ras_enabled) in lpfc_sli4_hba_unset()
13507 if (phba->pport) in lpfc_sli4_hba_unset()
13508 phba->pport->work_port_events = 0; in lpfc_sli4_hba_unset()
13569 "6235 INIT Congestion Buffer %p\n", phba->cgn_i); in lpfc_init_congestion_buf()
13571 if (!phba->cgn_i) in lpfc_init_congestion_buf()
13573 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_init_congestion_buf()
13575 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_init_congestion_buf()
13576 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_init_congestion_buf()
13577 atomic_set(&phba->cgn_sync_alarm_cnt, 0); in lpfc_init_congestion_buf()
13578 atomic_set(&phba->cgn_sync_warn_cnt, 0); in lpfc_init_congestion_buf()
13580 atomic_set(&phba->cgn_driver_evt_cnt, 0); in lpfc_init_congestion_buf()
13581 atomic_set(&phba->cgn_latency_evt_cnt, 0); in lpfc_init_congestion_buf()
13582 atomic64_set(&phba->cgn_latency_evt, 0); in lpfc_init_congestion_buf()
13583 phba->cgn_evt_minute = 0; in lpfc_init_congestion_buf()
13586 cp->cgn_info_size = cpu_to_le16(LPFC_CGN_INFO_SZ); in lpfc_init_congestion_buf()
13587 cp->cgn_info_version = LPFC_CGN_INFO_V4; in lpfc_init_congestion_buf()
13590 cp->cgn_info_mode = phba->cgn_p.cgn_param_mode; in lpfc_init_congestion_buf()
13591 cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0; in lpfc_init_congestion_buf()
13592 cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1; in lpfc_init_congestion_buf()
13593 cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2; in lpfc_init_congestion_buf()
13595 lpfc_cgn_update_tstamp(phba, &cp->base_time); in lpfc_init_congestion_buf()
13598 if (phba->pport) { in lpfc_init_congestion_buf()
13599 size = (uint16_t)(phba->pport->cfg_lun_queue_depth); in lpfc_init_congestion_buf()
13600 cp->cgn_lunq = cpu_to_le16(size); in lpfc_init_congestion_buf()
13605 cp->cgn_warn_freq = cpu_to_le16(LPFC_FPIN_INIT_FREQ); in lpfc_init_congestion_buf()
13606 cp->cgn_alarm_freq = cpu_to_le16(LPFC_FPIN_INIT_FREQ); in lpfc_init_congestion_buf()
13608 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_init_congestion_buf()
13610 phba->cgn_evt_timestamp = jiffies + in lpfc_init_congestion_buf()
13621 "6236 INIT Congestion Stat %p\n", phba->cgn_i); in lpfc_init_congestion_stat()
13623 if (!phba->cgn_i) in lpfc_init_congestion_stat()
13626 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_init_congestion_stat()
13627 memset(&cp->cgn_stat, 0, sizeof(cp->cgn_stat)); in lpfc_init_congestion_stat()
13629 lpfc_cgn_update_tstamp(phba, &cp->stat_start); in lpfc_init_congestion_stat()
13631 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_init_congestion_stat()
13635 * __lpfc_reg_congestion_buf - register congestion info buffer with HBA
13648 if (!phba->cgn_i) in __lpfc_reg_congestion_buf()
13649 return -ENXIO; in __lpfc_reg_congestion_buf()
13651 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in __lpfc_reg_congestion_buf()
13656 phba->pport->port_state, reg); in __lpfc_reg_congestion_buf()
13657 return -ENOMEM; in __lpfc_reg_congestion_buf()
13660 length = (sizeof(struct lpfc_mbx_reg_congestion_buf) - in __lpfc_reg_congestion_buf()
13665 reg_congestion_buf = &mboxq->u.mqe.un.reg_congestion_buf; in __lpfc_reg_congestion_buf()
13671 reg_congestion_buf->length = sizeof(struct lpfc_cgn_info); in __lpfc_reg_congestion_buf()
13672 reg_congestion_buf->addr_lo = in __lpfc_reg_congestion_buf()
13673 putPaddrLow(phba->cgn_i->phys); in __lpfc_reg_congestion_buf()
13674 reg_congestion_buf->addr_hi = in __lpfc_reg_congestion_buf()
13675 putPaddrHigh(phba->cgn_i->phys); in __lpfc_reg_congestion_buf()
13679 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in __lpfc_reg_congestion_buf()
13680 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in __lpfc_reg_congestion_buf()
13682 &shdr->response); in __lpfc_reg_congestion_buf()
13683 mempool_free(mboxq, phba->mbox_mem_pool); in __lpfc_reg_congestion_buf()
13690 return -ENXIO; in __lpfc_reg_congestion_buf()
13709 * lpfc_get_sli4_parameters - Get the SLI4 Config PARAMETERS.
13716 * This function may be be called from any context that can block-wait
13724 struct lpfc_mqe *mqe = &mboxq->u.mqe; in lpfc_get_sli4_parameters()
13736 phba->sli4_hba.rpi_hdrs_in_use = 1; in lpfc_get_sli4_parameters()
13739 length = (sizeof(struct lpfc_mbx_get_sli4_parameters) - in lpfc_get_sli4_parameters()
13744 if (!phba->sli4_hba.intr_enable) in lpfc_get_sli4_parameters()
13752 sli4_params = &phba->sli4_hba.pc_sli4_params; in lpfc_get_sli4_parameters()
13753 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters; in lpfc_get_sli4_parameters()
13754 sli4_params->if_type = bf_get(cfg_if_type, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13755 sli4_params->sli_rev = bf_get(cfg_sli_rev, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13756 sli4_params->sli_family = bf_get(cfg_sli_family, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13757 sli4_params->featurelevel_1 = bf_get(cfg_sli_hint_1, in lpfc_get_sli4_parameters()
13759 sli4_params->featurelevel_2 = bf_get(cfg_sli_hint_2, in lpfc_get_sli4_parameters()
13762 phba->sli3_options |= LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
13764 phba->sli3_options &= ~LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
13765 sli4_params->sge_supp_len = mbx_sli4_parameters->sge_supp_len; in lpfc_get_sli4_parameters()
13766 sli4_params->loopbk_scope = bf_get(cfg_loopbk_scope, in lpfc_get_sli4_parameters()
13768 sli4_params->oas_supported = bf_get(cfg_oas, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13769 sli4_params->cqv = bf_get(cfg_cqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13770 sli4_params->mqv = bf_get(cfg_mqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13771 sli4_params->wqv = bf_get(cfg_wqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13772 sli4_params->rqv = bf_get(cfg_rqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13773 sli4_params->eqav = bf_get(cfg_eqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13774 sli4_params->cqav = bf_get(cfg_cqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13775 sli4_params->wqsize = bf_get(cfg_wqsize, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13776 sli4_params->bv1s = bf_get(cfg_bv1s, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13777 sli4_params->pls = bf_get(cfg_pvl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13778 sli4_params->sgl_pages_max = bf_get(cfg_sgl_page_cnt, in lpfc_get_sli4_parameters()
13780 sli4_params->wqpcnt = bf_get(cfg_wqpcnt, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13781 sli4_params->sgl_pp_align = bf_get(cfg_sgl_pp_align, in lpfc_get_sli4_parameters()
13783 phba->sli4_hba.extents_in_use = bf_get(cfg_ext, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13784 phba->sli4_hba.rpi_hdrs_in_use = bf_get(cfg_hdrr, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13785 sli4_params->mi_cap = bf_get(cfg_mi_ver, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13787 /* Check for Extended Pre-Registered SGL support */ in lpfc_get_sli4_parameters()
13788 phba->cfg_xpsgl = bf_get(cfg_xpsgl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13796 sli4_params->nvme = 1; in lpfc_get_sli4_parameters()
13799 if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP) { in lpfc_get_sli4_parameters()
13803 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
13808 sli4_params->nvme = 0; in lpfc_get_sli4_parameters()
13809 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_get_sli4_parameters()
13815 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
13817 phba->nvmet_support = 0; in lpfc_get_sli4_parameters()
13818 phba->cfg_nvmet_mrq = 0; in lpfc_get_sli4_parameters()
13819 phba->cfg_nvme_seg_cnt = 0; in lpfc_get_sli4_parameters()
13822 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_get_sli4_parameters()
13823 return -ENODEV; in lpfc_get_sli4_parameters()
13824 phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; in lpfc_get_sli4_parameters()
13831 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_get_sli4_parameters()
13832 phba->cfg_sg_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_get_sli4_parameters()
13836 phba->cfg_enable_pbde = 1; in lpfc_get_sli4_parameters()
13838 phba->cfg_enable_pbde = 0; in lpfc_get_sli4_parameters()
13843 * In SLI4-Parameters Descriptor: in lpfc_get_sli4_parameters()
13848 if (phba->cfg_suppress_rsp && bf_get(cfg_xib, mbx_sli4_parameters) && in lpfc_get_sli4_parameters()
13850 phba->sli.sli_flag |= LPFC_SLI_SUPPRESS_RSP; in lpfc_get_sli4_parameters()
13852 phba->cfg_suppress_rsp = 0; in lpfc_get_sli4_parameters()
13855 phba->sli.sli_flag |= LPFC_SLI_USE_EQDR; in lpfc_get_sli4_parameters()
13858 if (sli4_params->sge_supp_len > LPFC_MAX_SGE_SIZE) in lpfc_get_sli4_parameters()
13859 sli4_params->sge_supp_len = LPFC_MAX_SGE_SIZE; in lpfc_get_sli4_parameters()
13861 dma_set_max_seg_size(&phba->pcidev->dev, sli4_params->sge_supp_len); in lpfc_get_sli4_parameters()
13866 * to use this option, 128-byte WQEs must be used. in lpfc_get_sli4_parameters()
13869 phba->fcp_embed_io = 1; in lpfc_get_sli4_parameters()
13871 phba->fcp_embed_io = 0; in lpfc_get_sli4_parameters()
13876 phba->cfg_enable_pbde, in lpfc_get_sli4_parameters()
13877 phba->fcp_embed_io, sli4_params->nvme, in lpfc_get_sli4_parameters()
13878 phba->cfg_nvme_embed_cmd, phba->cfg_suppress_rsp); in lpfc_get_sli4_parameters()
13880 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
13882 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
13889 (sli4_params->wqsize & LPFC_WQ_SZ128_SUPPORT)) in lpfc_get_sli4_parameters()
13890 phba->enab_exp_wqcq_pages = 1; in lpfc_get_sli4_parameters()
13892 phba->enab_exp_wqcq_pages = 0; in lpfc_get_sli4_parameters()
13897 phba->mds_diags_support = 1; in lpfc_get_sli4_parameters()
13899 phba->mds_diags_support = 0; in lpfc_get_sli4_parameters()
13905 phba->nsler = 1; in lpfc_get_sli4_parameters()
13907 phba->nsler = 0; in lpfc_get_sli4_parameters()
13913 * lpfc_pci_probe_one_s3 - PCI probe func to reg SLI-3 device to PCI subsystem.
13917 * This routine is to be called to attach a device with SLI-3 interface spec
13918 * to the PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
13919 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
13926 * 0 - driver can claim the device
13927 * negative value - driver can not claim the device
13941 return -ENOMEM; in lpfc_pci_probe_one_s3()
13948 /* Set up SLI API function jump table for PCI-device group-0 HBAs */ in lpfc_pci_probe_one_s3()
13953 /* Set up SLI-3 specific device PCI memory space */ in lpfc_pci_probe_one_s3()
13961 /* Set up SLI-3 specific device driver resources */ in lpfc_pci_probe_one_s3()
13987 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s3()
13998 vport = phba->pport; in lpfc_pci_probe_one_s3()
14008 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s3()
14017 error = -ENODEV; in lpfc_pci_probe_one_s3()
14020 /* SLI-3 HBA setup */ in lpfc_pci_probe_one_s3()
14024 error = -ENODEV; in lpfc_pci_probe_one_s3()
14032 phba->sli.slistat.sli_intr > LPFC_MSIX_VECTORS) { in lpfc_pci_probe_one_s3()
14034 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s3()
14045 cfg_mode = --intr_mode; in lpfc_pci_probe_one_s3()
14081 * lpfc_pci_remove_one_s3 - PCI func to unreg SLI-3 device from PCI subsystem.
14084 * This routine is to be called to disattach a device with SLI-3 interface
14085 * spec from PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
14093 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s3()
14095 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s3()
14098 set_bit(FC_UNLOADING, &vport->load_flag); in lpfc_pci_remove_one_s3()
14105 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s3()
14106 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s3()
14108 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s3()
14128 kthread_stop(phba->worker_thread); in lpfc_pci_remove_one_s3()
14132 kfree(phba->vpi_bmask); in lpfc_pci_remove_one_s3()
14133 kfree(phba->vpi_ids); in lpfc_pci_remove_one_s3()
14136 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
14137 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s3()
14138 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
14142 /* Disable SR-IOV if enabled */ in lpfc_pci_remove_one_s3()
14143 if (phba->cfg_sriov_nr_virtfn) in lpfc_pci_remove_one_s3()
14160 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_pci_remove_one_s3()
14161 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_pci_remove_one_s3()
14164 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_pci_remove_one_s3()
14165 phba->slim2p.virt, phba->slim2p.phys); in lpfc_pci_remove_one_s3()
14168 iounmap(phba->ctrl_regs_memmap_p); in lpfc_pci_remove_one_s3()
14169 iounmap(phba->slim_memmap_p); in lpfc_pci_remove_one_s3()
14178 * lpfc_pci_suspend_one_s3 - PCI func to suspend SLI-3 device for power mgmnt
14182 * system Power Management (PM) to device with SLI-3 interface spec. When
14186 * minimum PM requirements to a power-aware driver's PM support for the
14187 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
14194 * 0 - driver suspended the device
14201 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s3()
14209 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s3()
14218 * lpfc_pci_resume_one_s3 - PCI func to resume SLI-3 device for power mgmnt
14222 * system Power Management (PM) to device with SLI-3 interface spec. When PM
14225 * driver implements the minimum PM requirements to a power-aware driver's
14226 * PM for suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE,
14227 * FREEZE) to the suspend() method call will be treated as SUSPEND and the
14233 * 0 - driver suspended the device
14240 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s3()
14248 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s3()
14249 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s3()
14250 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s3()
14251 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s3()
14263 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
14267 return -EIO; in lpfc_pci_resume_one_s3()
14269 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s3()
14276 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
14282 * lpfc_sli_prep_dev_for_recover - Prepare SLI3 device for pci slot recover
14296 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli_prep_dev_for_recover()
14302 * lpfc_sli_prep_dev_for_reset - Prepare SLI3 device for pci slot reset
14329 pci_disable_device(phba->pcidev); in lpfc_sli_prep_dev_for_reset()
14333 * lpfc_sli_prep_dev_for_perm_failure - Prepare SLI3 dev for pci slot disable
14357 * lpfc_io_error_detected_s3 - Method for handling SLI-3 device PCI I/O error
14362 * device with SLI-3 interface spec. This function is called by the PCI
14370 * PCI_ERS_RESULT_CAN_RECOVER - can be recovered without reset
14371 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
14372 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
14378 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s3()
14382 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s3()
14403 * lpfc_io_slot_reset_s3 - Method for restarting PCI SLI-3 device from scratch.
14407 * device with SLI-3 interface spec. This is called after PCI bus has been
14408 * reset to restart the PCI card from scratch, as if from a cold-boot.
14417 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
14418 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
14424 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s3()
14425 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s3()
14428 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s3()
14430 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s3()
14443 if (pdev->is_busmaster) in lpfc_io_slot_reset_s3()
14446 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
14447 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s3()
14448 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
14451 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
14454 "0427 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s3()
14458 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s3()
14466 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
14472 * lpfc_io_resume_s3 - Method for resuming PCI I/O operation on SLI-3 device.
14476 * with SLI-3 interface spec. It is called when kernel error recovery tells
14485 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s3()
14487 /* Bring device online, it will be no-op for non-fatal error resume */ in lpfc_io_resume_s3()
14492 * lpfc_sli4_get_els_iocb_cnt - Calculate the # of ELS IOCBs to reserve
14500 int max_xri = phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_get_els_iocb_cnt()
14502 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli4_get_els_iocb_cnt()
14522 * lpfc_sli4_get_iocb_cnt - Calculate the # of total IOCBs to reserve
14532 if (phba->nvmet_support) in lpfc_sli4_get_iocb_cnt()
14546 sli_family = bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf); in lpfc_log_write_firmware_error()
14564 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
14565 fsize, fw->size); in lpfc_log_write_firmware_error()
14566 rc = -EINVAL; in lpfc_log_write_firmware_error()
14573 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
14574 fsize, fw->size); in lpfc_log_write_firmware_error()
14575 rc = -EACCES; in lpfc_log_write_firmware_error()
14581 offset, phba->pcidev->device, magic_number, in lpfc_log_write_firmware_error()
14582 ftype, fid, fsize, fw->size); in lpfc_log_write_firmware_error()
14583 rc = -EIO; in lpfc_log_write_firmware_error()
14589 * lpfc_write_firmware - attempt to write a firmware image to the port
14606 /* It can be null in no-wait mode, sanity check */ in lpfc_write_firmware()
14608 rc = -ENXIO; in lpfc_write_firmware()
14611 image = (struct lpfc_grp_hdr *)fw->data; in lpfc_write_firmware()
14613 magic_number = be32_to_cpu(image->magic_number); in lpfc_write_firmware()
14616 fsize = be32_to_cpu(image->size); in lpfc_write_firmware()
14620 if (strncmp(fwrev, image->revision, strnlen(image->revision, 16))) { in lpfc_write_firmware()
14624 fwrev, image->revision); in lpfc_write_firmware()
14629 rc = -ENOMEM; in lpfc_write_firmware()
14632 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_write_firmware()
14634 &dmabuf->phys, in lpfc_write_firmware()
14636 if (!dmabuf->virt) { in lpfc_write_firmware()
14638 rc = -ENOMEM; in lpfc_write_firmware()
14641 list_add_tail(&dmabuf->list, &dma_buffer_list); in lpfc_write_firmware()
14643 while (offset < fw->size) { in lpfc_write_firmware()
14646 if (temp_offset + SLI4_PAGE_SIZE > fw->size) { in lpfc_write_firmware()
14647 memcpy(dmabuf->virt, in lpfc_write_firmware()
14648 fw->data + temp_offset, in lpfc_write_firmware()
14649 fw->size - temp_offset); in lpfc_write_firmware()
14650 temp_offset = fw->size; in lpfc_write_firmware()
14653 memcpy(dmabuf->virt, fw->data + temp_offset, in lpfc_write_firmware()
14658 (fw->size - offset), &offset); in lpfc_write_firmware()
14674 fwrev, image->revision); in lpfc_write_firmware()
14678 list_del(&dmabuf->list); in lpfc_write_firmware()
14679 dma_free_coherent(&phba->pcidev->dev, SLI4_PAGE_SIZE, in lpfc_write_firmware()
14680 dmabuf->virt, dmabuf->phys); in lpfc_write_firmware()
14694 * lpfc_sli4_request_firmware_update - Request linux generic firmware upgrade
14709 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_request_firmware_update()
14711 return -EPERM; in lpfc_sli4_request_firmware_update()
14713 scnprintf(file_name, sizeof(file_name), "%s.grp", phba->ModelName); in lpfc_sli4_request_firmware_update()
14717 file_name, &phba->pcidev->dev, in lpfc_sli4_request_firmware_update()
14721 ret = request_firmware(&fw, file_name, &phba->pcidev->dev); in lpfc_sli4_request_firmware_update()
14725 ret = -EINVAL; in lpfc_sli4_request_firmware_update()
14732 * lpfc_pci_probe_one_s4 - PCI probe func to reg SLI-4 device to PCI subsys
14737 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
14738 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
14746 * 0 - driver can claim the device
14747 * negative value - driver can not claim the device
14761 return -ENOMEM; in lpfc_pci_probe_one_s4()
14763 INIT_LIST_HEAD(&phba->poll_list); in lpfc_pci_probe_one_s4()
14770 /* Set up SLI API function jump table for PCI-device group-1 HBAs */ in lpfc_pci_probe_one_s4()
14775 /* Set up SLI-4 specific device PCI memory space */ in lpfc_pci_probe_one_s4()
14783 /* Set up SLI-4 Specific device driver resources */ in lpfc_pci_probe_one_s4()
14791 spin_lock_init(&phba->rrq_list_lock); in lpfc_pci_probe_one_s4()
14792 INIT_LIST_HEAD(&phba->active_rrq_list); in lpfc_pci_probe_one_s4()
14793 INIT_LIST_HEAD(&phba->fcf.fcf_pri_list); in lpfc_pci_probe_one_s4()
14804 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s4()
14807 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s4()
14810 phba->pport = NULL; in lpfc_pci_probe_one_s4()
14824 error = -ENODEV; in lpfc_pci_probe_one_s4()
14827 /* Default to single EQ for non-MSI-X */ in lpfc_pci_probe_one_s4()
14828 if (phba->intr_type != MSIX) { in lpfc_pci_probe_one_s4()
14829 phba->cfg_irq_chann = 1; in lpfc_pci_probe_one_s4()
14830 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
14831 if (phba->nvmet_support) in lpfc_pci_probe_one_s4()
14832 phba->cfg_nvmet_mrq = 1; in lpfc_pci_probe_one_s4()
14835 lpfc_cpu_affinity_check(phba, phba->cfg_irq_chann); in lpfc_pci_probe_one_s4()
14844 vport = phba->pport; in lpfc_pci_probe_one_s4()
14855 /* Set up SLI-4 HBA */ in lpfc_pci_probe_one_s4()
14859 error = -ENODEV; in lpfc_pci_probe_one_s4()
14864 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s4()
14873 if (phba->nvmet_support == 0) { in lpfc_pci_probe_one_s4()
14874 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
14891 if (phba->cfg_request_firmware_upgrade) in lpfc_pci_probe_one_s4()
14897 timer_setup(&phba->cpuhp_poll_timer, lpfc_sli4_poll_hbtimer, 0); in lpfc_pci_probe_one_s4()
14898 cpuhp_state_add_instance_nocalls(lpfc_cpuhp_state, &phba->cpuhp); in lpfc_pci_probe_one_s4()
14924 * lpfc_pci_remove_one_s4 - PCI func to unreg SLI-4 device from PCI subsystem
14928 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
14936 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s4()
14938 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s4()
14942 set_bit(FC_UNLOADING, &vport->load_flag); in lpfc_pci_remove_one_s4()
14943 if (phba->cgn_i) in lpfc_pci_remove_one_s4()
14951 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s4()
14952 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s4()
14954 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s4()
14969 /* De-allocate multi-XRI pools */ in lpfc_pci_remove_one_s4()
14970 if (phba->cfg_xri_rebalancing) in lpfc_pci_remove_one_s4()
14981 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
14982 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s4()
14983 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
15009 * lpfc_pci_suspend_one_s4 - PCI func to suspend SLI-4 device for power mgmnt
15013 * Power Management (PM) to device with SLI-4 interface spec. When PM invokes
15017 * requirements to a power-aware driver's PM support for suspend/resume -- all
15018 * the possible PM messages (SUSPEND, HIBERNATE, FREEZE) to the suspend()
15025 * 0 - driver suspended the device
15032 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s4()
15040 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s4()
15050 * lpfc_pci_resume_one_s4 - PCI func to resume SLI-4 device for power mgmnt
15054 * Power Management (PM) to device with SLI-4 interface spac. When PM invokes
15057 * implements the minimum PM requirements to a power-aware driver's PM for
15058 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
15065 * 0 - driver suspended the device
15072 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s4()
15080 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s4()
15081 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s4()
15082 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s4()
15083 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s4()
15091 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
15095 return -EIO; in lpfc_pci_resume_one_s4()
15097 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s4()
15104 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
15110 * lpfc_sli4_prep_dev_for_recover - Prepare SLI4 device for pci slot recover
15123 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli4_prep_dev_for_recover()
15129 * lpfc_sli4_prep_dev_for_reset - Prepare SLI4 device for pci slot reset
15139 int offline = pci_channel_offline(phba->pcidev); in lpfc_sli4_prep_dev_for_reset()
15161 pci_disable_device(phba->pcidev); in lpfc_sli4_prep_dev_for_reset()
15165 * lpfc_sli4_prep_dev_for_perm_failure - Prepare SLI4 dev for pci slot disable
15189 * lpfc_io_error_detected_s4 - Method for handling PCI I/O error to SLI-4 device
15194 * with SLI-4 interface spec. This function is called by the PCI subsystem
15201 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
15202 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15208 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s4()
15213 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s4()
15217 hba_pci_err = test_and_set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15227 set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15232 hba_pci_err = test_and_set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15244 * lpfc_io_slot_reset_s4 - Method for restart PCI SLI-4 device from scratch
15248 * with SLI-4 interface spec. It is called after PCI bus has been reset to
15249 * restart the PCI card from scratch, as if from a cold-boot. During the
15258 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
15259 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15265 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s4()
15266 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s4()
15270 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s4()
15272 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s4()
15279 hba_pci_err = test_and_clear_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_slot_reset_s4()
15281 dev_info(&pdev->dev, in lpfc_io_slot_reset_s4()
15289 if (pdev->is_busmaster) in lpfc_io_slot_reset_s4()
15292 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
15293 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s4()
15294 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
15299 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
15302 "2824 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s4()
15306 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s4()
15307 lpfc_cpu_affinity_check(phba, phba->cfg_irq_chann); in lpfc_io_slot_reset_s4()
15310 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
15316 * lpfc_io_resume_s4 - Method for resuming PCI I/O operation to SLI-4 device
15320 * with SLI-4 interface spec. It is called when kernel error recovery tells
15329 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s4()
15337 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) { in lpfc_io_resume_s4()
15346 * lpfc_pci_probe_one - lpfc PCI probe func to reg dev to PCI subsystem
15352 * at PCI device-specific information of the device and driver to see if the
15355 * the action to the proper SLI-3 or SLI-4 device probing routine, which will
15360 * 0 - driver can claim the device
15361 * negative value - driver can not claim the device
15370 return -ENODEV; in lpfc_pci_probe_one()
15382 * lpfc_pci_remove_one - lpfc PCI func to unreg dev from PCI subsystem
15387 * This routine dispatches the action to the proper SLI-3 or SLI-4 device
15395 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_remove_one()
15397 switch (phba->pci_dev_grp) { in lpfc_pci_remove_one()
15407 phba->pci_dev_grp); in lpfc_pci_remove_one()
15414 * lpfc_pci_suspend_one - lpfc PCI func to suspend dev for power management
15419 * the action to the proper SLI-3 or SLI-4 device suspend routine, which will
15423 * 0 - driver suspended the device
15430 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one()
15431 int rc = -ENODEV; in lpfc_pci_suspend_one()
15433 switch (phba->pci_dev_grp) { in lpfc_pci_suspend_one()
15443 phba->pci_dev_grp); in lpfc_pci_suspend_one()
15450 * lpfc_pci_resume_one - lpfc PCI func to resume dev for power management
15455 * the action to the proper SLI-3 or SLI-4 device resume routine, which will
15459 * 0 - driver suspended the device
15466 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one()
15467 int rc = -ENODEV; in lpfc_pci_resume_one()
15469 switch (phba->pci_dev_grp) { in lpfc_pci_resume_one()
15479 phba->pci_dev_grp); in lpfc_pci_resume_one()
15486 * lpfc_io_error_detected - lpfc method for handling PCI I/O error
15493 * the action to the proper SLI-3 or SLI-4 device error detected handling
15497 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
15498 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15504 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected()
15507 if (phba->link_state == LPFC_HBA_ERROR && in lpfc_io_error_detected()
15508 test_bit(HBA_IOQ_FLUSH, &phba->hba_flag)) in lpfc_io_error_detected()
15511 switch (phba->pci_dev_grp) { in lpfc_io_error_detected()
15521 phba->pci_dev_grp); in lpfc_io_error_detected()
15528 * lpfc_io_slot_reset - lpfc method for restart PCI dev from scratch
15533 * from scratch, as if from a cold-boot. When this routine is invoked, it
15534 * dispatches the action to the proper SLI-3 or SLI-4 device reset handling
15538 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
15539 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15545 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset()
15548 switch (phba->pci_dev_grp) { in lpfc_io_slot_reset()
15558 phba->pci_dev_grp); in lpfc_io_slot_reset()
15565 * lpfc_io_resume - lpfc method for resuming PCI I/O operation
15571 * this routine is invoked, it dispatches the action to the proper SLI-3
15572 * or SLI-4 device io_resume routine, which will resume the device operation.
15578 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume()
15580 switch (phba->pci_dev_grp) { in lpfc_io_resume()
15590 phba->pci_dev_grp); in lpfc_io_resume()
15597 * lpfc_sli4_oas_verify - Verify OAS is supported by this adapter
15610 if (!phba->cfg_EnableXLane) in lpfc_sli4_oas_verify()
15613 if (phba->sli4_hba.pc_sli4_params.oas_supported) { in lpfc_sli4_oas_verify()
15614 phba->cfg_fof = 1; in lpfc_sli4_oas_verify()
15616 phba->cfg_fof = 0; in lpfc_sli4_oas_verify()
15617 mempool_destroy(phba->device_data_mem_pool); in lpfc_sli4_oas_verify()
15618 phba->device_data_mem_pool = NULL; in lpfc_sli4_oas_verify()
15625 * lpfc_sli4_ras_init - Verify RAS-FW log is supported by this adapter
15635 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_ras_init()
15637 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_sli4_ras_init()
15639 phba->ras_fwlog.ras_hwsupport = true; in lpfc_sli4_ras_init()
15640 if (phba->cfg_ras_fwlog_func == PCI_FUNC(phba->pcidev->devfn) && in lpfc_sli4_ras_init()
15641 phba->cfg_ras_fwlog_buffsize) in lpfc_sli4_ras_init()
15642 phba->ras_fwlog.ras_enabled = true; in lpfc_sli4_ras_init()
15644 phba->ras_fwlog.ras_enabled = false; in lpfc_sli4_ras_init()
15646 phba->ras_fwlog.ras_hwsupport = false; in lpfc_sli4_ras_init()
15684 * lpfc_init - lpfc module initialization routine
15691 * 0 - successful
15692 * -ENOMEM - FC attach transport failed
15693 * all others - failed
15708 error = -ENOMEM; in lpfc_init()
15762 if (atomic_cmpxchg(&phba->dbg_log_dmping, 0, 1) != 0) in lpfc_dmp_dbg()
15765 start_idx = (unsigned int)atomic_read(&phba->dbg_log_idx) % DBG_LOG_SZ; in lpfc_dmp_dbg()
15766 dbg_cnt = (unsigned int)atomic_read(&phba->dbg_log_cnt); in lpfc_dmp_dbg()
15772 temp_idx -= 1; in lpfc_dmp_dbg()
15774 if ((start_idx + dbg_cnt) > (DBG_LOG_SZ - 1)) { in lpfc_dmp_dbg()
15778 start_idx = DBG_LOG_SZ - (dbg_cnt - start_idx); in lpfc_dmp_dbg()
15780 start_idx -= dbg_cnt; in lpfc_dmp_dbg()
15783 dev_info(&phba->pcidev->dev, "start %d end %d cnt %d\n", in lpfc_dmp_dbg()
15791 rem_nsec = do_div(phba->dbg_log[temp_idx].t_ns, NSEC_PER_SEC); in lpfc_dmp_dbg()
15792 dev_info(&phba->pcidev->dev, "%d: [%5lu.%06lu] %s", in lpfc_dmp_dbg()
15794 (unsigned long)phba->dbg_log[temp_idx].t_ns, in lpfc_dmp_dbg()
15796 phba->dbg_log[temp_idx].log); in lpfc_dmp_dbg()
15799 atomic_set(&phba->dbg_log_cnt, 0); in lpfc_dmp_dbg()
15800 atomic_set(&phba->dbg_log_dmping, 0); in lpfc_dmp_dbg()
15808 int dbg_dmping = atomic_read(&phba->dbg_log_dmping); in lpfc_dbg_print()
15816 dev_info(&phba->pcidev->dev, "%pV", &vaf); in lpfc_dbg_print()
15820 idx = (unsigned int)atomic_fetch_add(1, &phba->dbg_log_idx) % in lpfc_dbg_print()
15823 atomic_inc(&phba->dbg_log_cnt); in lpfc_dbg_print()
15825 vscnprintf(phba->dbg_log[idx].log, in lpfc_dbg_print()
15826 sizeof(phba->dbg_log[idx].log), fmt, args); in lpfc_dbg_print()
15829 phba->dbg_log[idx].t_ns = local_clock(); in lpfc_dbg_print()
15833 * lpfc_exit - lpfc module removal routine