Lines Matching +full:no +full:- +full:pbl +full:- +full:x8
4 * Copyright (C) 2017-2024 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()
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()
465 /* This dmabuf was allocated by lpfc_read_sparam. The dmabuf is no 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()
480 /* If no serial number in VPD data, use low 6 bytes of WWNN */ in lpfc_config_port_post()
481 /* This should be consolidated into parse_vpd ? - mr */ in lpfc_config_port_post()
482 if (phba->SerialNumber[0] == 0) { in lpfc_config_port_post()
485 outptr = &vport->fc_nodename.u.s.IEEE[0]; in lpfc_config_port_post()
490 phba->SerialNumber[i] = in lpfc_config_port_post()
493 phba->SerialNumber[i] = in lpfc_config_port_post()
494 (char)((uint8_t) 0x61 + (uint8_t) (j - 10)); in lpfc_config_port_post()
498 phba->SerialNumber[i] = in lpfc_config_port_post()
501 phba->SerialNumber[i] = in lpfc_config_port_post()
502 (char)((uint8_t) 0x61 + (uint8_t) (j - 10)); in lpfc_config_port_post()
507 pmb->vport = vport; in lpfc_config_port_post()
512 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_post()
513 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
514 mempool_free( pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
515 return -EIO; in lpfc_config_port_post()
522 if (phba->cfg_hba_queue_depth > mb->un.varRdConfig.max_xri) { in lpfc_config_port_post()
525 phba->cfg_hba_queue_depth, in lpfc_config_port_post()
526 mb->un.varRdConfig.max_xri); in lpfc_config_port_post()
527 phba->cfg_hba_queue_depth = mb->un.varRdConfig.max_xri; in lpfc_config_port_post()
530 phba->lmt = mb->un.varRdConfig.lmt; in lpfc_config_port_post()
533 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_config_port_post()
535 phba->link_state = LPFC_LINK_DOWN; in lpfc_config_port_post()
538 if (psli->sli3_ring[LPFC_EXTRA_RING].sli.sli3.cmdringaddr) in lpfc_config_port_post()
539 psli->sli3_ring[LPFC_EXTRA_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_config_port_post()
540 if (psli->sli3_ring[LPFC_FCP_RING].sli.sli3.cmdringaddr) in lpfc_config_port_post()
541 psli->sli3_ring[LPFC_FCP_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_config_port_post()
544 if (phba->sli_rev != 3) in lpfc_config_port_post()
548 * Configure HBA MSI-X attention conditions to messages if MSI-X mode in lpfc_config_port_post()
550 if (phba->intr_type == MSIX) { in lpfc_config_port_post()
553 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
554 return -EIO; in lpfc_config_port_post()
561 pmb->u.mb.mbxCommand, in lpfc_config_port_post()
562 pmb->u.mb.mbxStatus); in lpfc_config_port_post()
563 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
564 return -EIO; in lpfc_config_port_post()
568 spin_lock_irq(&phba->hbalock); in lpfc_config_port_post()
570 clear_bit(HBA_ERATT_HANDLED, &phba->hba_flag); in lpfc_config_port_post()
573 if (lpfc_readl(phba->HCregaddr, &status)) { in lpfc_config_port_post()
574 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
575 return -EIO; in lpfc_config_port_post()
578 if (psli->num_rings > 0) in lpfc_config_port_post()
580 if (psli->num_rings > 1) in lpfc_config_port_post()
582 if (psli->num_rings > 2) in lpfc_config_port_post()
584 if (psli->num_rings > 3) in lpfc_config_port_post()
587 if ((phba->cfg_poll & ENABLE_FCP_RING_POLLING) && in lpfc_config_port_post()
588 (phba->cfg_poll & DISABLE_FCP_RING_INT)) in lpfc_config_port_post()
591 writel(status, phba->HCregaddr); in lpfc_config_port_post()
592 readl(phba->HCregaddr); /* flush */ in lpfc_config_port_post()
593 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
595 /* Set up ring-0 (ELS) timer */ in lpfc_config_port_post()
596 timeout = phba->fc_ratov * 2; in lpfc_config_port_post()
597 mod_timer(&vport->els_tmofunc, in lpfc_config_port_post()
600 mod_timer(&phba->hb_tmofunc, in lpfc_config_port_post()
602 clear_bit(HBA_HBEAT_INP, &phba->hba_flag); in lpfc_config_port_post()
603 clear_bit(HBA_HBEAT_TMO, &phba->hba_flag); in lpfc_config_port_post()
604 phba->last_completion_time = jiffies; in lpfc_config_port_post()
606 mod_timer(&phba->eratt_poll, in lpfc_config_port_post()
607 jiffies + msecs_to_jiffies(1000 * phba->eratt_poll_interval)); in lpfc_config_port_post()
609 if (test_bit(LINK_DISABLED, &phba->hba_flag)) { in lpfc_config_port_post()
613 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_config_port_post()
620 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
621 return -EIO; in lpfc_config_port_post()
623 } else if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) { in lpfc_config_port_post()
624 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
625 rc = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); in lpfc_config_port_post()
630 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
632 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
633 return -ENOMEM; in lpfc_config_port_post()
637 pmb->mbox_cmpl = lpfc_config_async_cmpl; in lpfc_config_port_post()
638 pmb->vport = phba->pport; in lpfc_config_port_post()
646 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
650 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
652 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
653 return -ENOMEM; in lpfc_config_port_post()
657 pmb->mbox_cmpl = lpfc_dump_wakeup_param_cmpl; in lpfc_config_port_post()
658 pmb->vport = phba->pport; in lpfc_config_port_post()
665 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
672 * lpfc_sli4_refresh_params - update driver copy of params.
686 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_refresh_params()
688 return -ENOMEM; in lpfc_sli4_refresh_params()
690 mqe = &mboxq->u.mqe; in lpfc_sli4_refresh_params()
692 length = (sizeof(struct lpfc_mbx_get_sli4_parameters) - in lpfc_sli4_refresh_params()
700 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_refresh_params()
703 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters; in lpfc_sli4_refresh_params()
704 phba->sli4_hba.pc_sli4_params.mi_cap = in lpfc_sli4_refresh_params()
708 if (phba->cfg_enable_mi) in lpfc_sli4_refresh_params()
709 phba->sli4_hba.pc_sli4_params.mi_ver = in lpfc_sli4_refresh_params()
712 phba->sli4_hba.pc_sli4_params.mi_ver = 0; in lpfc_sli4_refresh_params()
714 phba->sli4_hba.pc_sli4_params.cmf = in lpfc_sli4_refresh_params()
716 phba->sli4_hba.pc_sli4_params.pls = in lpfc_sli4_refresh_params()
719 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_refresh_params()
724 * lpfc_hba_init_link - Initialize the FC link
726 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
734 * 0 - success
735 * Any other value - error
740 return lpfc_hba_init_link_fc_topology(phba, phba->cfg_topology, flag); in lpfc_hba_init_link()
744 * lpfc_hba_init_link_fc_topology - Initialize FC link with desired topology
747 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
755 * 0 - success
756 * Any other value - error
762 struct lpfc_vport *vport = phba->pport; in lpfc_hba_init_link_fc_topology()
767 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_hba_init_link_fc_topology()
769 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_init_link_fc_topology()
770 return -ENOMEM; in lpfc_hba_init_link_fc_topology()
772 mb = &pmb->u.mb; in lpfc_hba_init_link_fc_topology()
773 pmb->vport = vport; in lpfc_hba_init_link_fc_topology()
775 if ((phba->cfg_link_speed > LPFC_USER_LINK_SPEED_MAX) || in lpfc_hba_init_link_fc_topology()
776 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_1G) && in lpfc_hba_init_link_fc_topology()
777 !(phba->lmt & LMT_1Gb)) || in lpfc_hba_init_link_fc_topology()
778 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_2G) && in lpfc_hba_init_link_fc_topology()
779 !(phba->lmt & LMT_2Gb)) || in lpfc_hba_init_link_fc_topology()
780 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_4G) && in lpfc_hba_init_link_fc_topology()
781 !(phba->lmt & LMT_4Gb)) || in lpfc_hba_init_link_fc_topology()
782 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_8G) && in lpfc_hba_init_link_fc_topology()
783 !(phba->lmt & LMT_8Gb)) || in lpfc_hba_init_link_fc_topology()
784 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_10G) && in lpfc_hba_init_link_fc_topology()
785 !(phba->lmt & LMT_10Gb)) || in lpfc_hba_init_link_fc_topology()
786 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G) && in lpfc_hba_init_link_fc_topology()
787 !(phba->lmt & LMT_16Gb)) || in lpfc_hba_init_link_fc_topology()
788 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_32G) && in lpfc_hba_init_link_fc_topology()
789 !(phba->lmt & LMT_32Gb)) || in lpfc_hba_init_link_fc_topology()
790 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_64G) && in lpfc_hba_init_link_fc_topology()
791 !(phba->lmt & LMT_64Gb))) { in lpfc_hba_init_link_fc_topology()
796 phba->cfg_link_speed); in lpfc_hba_init_link_fc_topology()
797 phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; in lpfc_hba_init_link_fc_topology()
799 lpfc_init_link(phba, pmb, fc_topology, phba->cfg_link_speed); in lpfc_hba_init_link_fc_topology()
800 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_hba_init_link_fc_topology()
801 if (phba->sli_rev < LPFC_SLI_REV4) in lpfc_hba_init_link_fc_topology()
808 mb->mbxCommand, mb->mbxStatus); in lpfc_hba_init_link_fc_topology()
809 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_hba_init_link_fc_topology()
811 writel(0, phba->HCregaddr); in lpfc_hba_init_link_fc_topology()
812 readl(phba->HCregaddr); /* flush */ in lpfc_hba_init_link_fc_topology()
814 writel(0xffffffff, phba->HAregaddr); in lpfc_hba_init_link_fc_topology()
815 readl(phba->HAregaddr); /* flush */ in lpfc_hba_init_link_fc_topology()
817 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_init_link_fc_topology()
819 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_init_link_fc_topology()
820 return -EIO; in lpfc_hba_init_link_fc_topology()
822 phba->cfg_suppress_link_up = LPFC_INITIALIZE_LINK; in lpfc_hba_init_link_fc_topology()
824 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_init_link_fc_topology()
830 * lpfc_hba_down_link - this routine downs the FC link
832 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
839 * 0 - success
840 * Any other value - error
848 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_hba_down_link()
850 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_down_link()
851 return -ENOMEM; in lpfc_hba_down_link()
857 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_hba_down_link()
864 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_down_link()
865 return -EIO; in lpfc_hba_down_link()
868 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_down_link()
874 * lpfc_hba_down_prep - Perform lpfc uninitialization prior to HBA reset
881 * 0 - success.
882 * Any other value - error.
890 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_hba_down_prep()
892 writel(0, phba->HCregaddr); in lpfc_hba_down_prep()
893 readl(phba->HCregaddr); /* flush */ in lpfc_hba_down_prep()
896 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_hba_down_prep()
897 lpfc_cleanup_discovery_resources(phba->pport); in lpfc_hba_down_prep()
901 for (i = 0; i <= phba->max_vports && in lpfc_hba_down_prep()
910 * lpfc_sli4_free_sp_events - Cleanup sp_queue_events to free
929 clear_bit(HBA_SP_QUEUE_EVT, &phba->hba_flag); in lpfc_sli4_free_sp_events()
931 while (!list_empty(&phba->sli4_hba.sp_queue_event)) { in lpfc_sli4_free_sp_events()
933 spin_lock_irq(&phba->hbalock); in lpfc_sli4_free_sp_events()
934 list_remove_head(&phba->sli4_hba.sp_queue_event, in lpfc_sli4_free_sp_events()
936 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_free_sp_events()
938 switch (bf_get(lpfc_wcqe_c_code, &cq_event->cqe.wcqe_cmpl)) { in lpfc_sli4_free_sp_events()
948 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_free_sp_events()
954 * lpfc_hba_free_post_buf - Perform lpfc uninitialization after HBA reset
967 struct lpfc_sli *psli = &phba->sli; in lpfc_hba_free_post_buf()
973 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) in lpfc_hba_free_post_buf()
977 pring = &psli->sli3_ring[LPFC_ELS_RING]; in lpfc_hba_free_post_buf()
978 spin_lock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
979 list_splice_init(&pring->postbufq, &buflist); in lpfc_hba_free_post_buf()
980 spin_unlock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
984 list_del(&mp->list); in lpfc_hba_free_post_buf()
986 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_hba_free_post_buf()
990 spin_lock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
991 pring->postbufq_cnt -= count; in lpfc_hba_free_post_buf()
992 spin_unlock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
997 * lpfc_hba_clean_txcmplq - Perform lpfc uninitialization after HBA reset
1009 struct lpfc_sli *psli = &phba->sli; in lpfc_hba_clean_txcmplq()
1016 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_hba_clean_txcmplq()
1017 for (i = 0; i < psli->num_rings; i++) { in lpfc_hba_clean_txcmplq()
1018 pring = &psli->sli3_ring[i]; in lpfc_hba_clean_txcmplq()
1019 spin_lock_irq(&phba->hbalock); in lpfc_hba_clean_txcmplq()
1024 list_splice_init(&pring->txcmplq, &completions); in lpfc_hba_clean_txcmplq()
1025 pring->txcmplq_cnt = 0; in lpfc_hba_clean_txcmplq()
1026 spin_unlock_irq(&phba->hbalock); in lpfc_hba_clean_txcmplq()
1035 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_hba_clean_txcmplq()
1036 pring = qp->pring; in lpfc_hba_clean_txcmplq()
1039 spin_lock_irq(&pring->ring_lock); in lpfc_hba_clean_txcmplq()
1041 &pring->txcmplq, list) in lpfc_hba_clean_txcmplq()
1042 piocb->cmd_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_hba_clean_txcmplq()
1043 list_splice_init(&pring->txcmplq, &completions); in lpfc_hba_clean_txcmplq()
1044 pring->txcmplq_cnt = 0; in lpfc_hba_clean_txcmplq()
1045 spin_unlock_irq(&pring->ring_lock); in lpfc_hba_clean_txcmplq()
1054 * lpfc_hba_down_post_s3 - Perform lpfc uninitialization after HBA reset
1061 * 0 - success.
1062 * Any other value - error.
1073 * lpfc_hba_down_post_s4 - Perform lpfc uninitialization after HBA reset
1080 * 0 - success.
1081 * Any other value - error.
1109 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_hba_down_post_s4()
1111 &phba->sli4_hba.lpfc_abts_els_sgl_list, list) in lpfc_hba_down_post_s4()
1112 sglq_entry->state = SGL_FREED; in lpfc_hba_down_post_s4()
1114 list_splice_init(&phba->sli4_hba.lpfc_abts_els_sgl_list, in lpfc_hba_down_post_s4()
1115 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_hba_down_post_s4()
1118 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_hba_down_post_s4()
1123 spin_lock_irq(&phba->hbalock); in lpfc_hba_down_post_s4()
1125 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_hba_down_post_s4()
1126 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_hba_down_post_s4()
1128 spin_lock(&qp->abts_io_buf_list_lock); in lpfc_hba_down_post_s4()
1129 list_splice_init(&qp->lpfc_abts_io_buf_list, in lpfc_hba_down_post_s4()
1133 psb->pCmd = NULL; in lpfc_hba_down_post_s4()
1134 psb->status = IOSTAT_SUCCESS; in lpfc_hba_down_post_s4()
1137 spin_lock(&qp->io_buf_list_put_lock); in lpfc_hba_down_post_s4()
1138 list_splice_init(&aborts, &qp->lpfc_io_buf_list_put); in lpfc_hba_down_post_s4()
1139 qp->put_io_bufs += qp->abts_scsi_io_bufs; in lpfc_hba_down_post_s4()
1140 qp->put_io_bufs += qp->abts_nvme_io_bufs; in lpfc_hba_down_post_s4()
1141 qp->abts_scsi_io_bufs = 0; in lpfc_hba_down_post_s4()
1142 qp->abts_nvme_io_bufs = 0; in lpfc_hba_down_post_s4()
1143 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_hba_down_post_s4()
1144 spin_unlock(&qp->abts_io_buf_list_lock); in lpfc_hba_down_post_s4()
1146 spin_unlock_irq(&phba->hbalock); in lpfc_hba_down_post_s4()
1148 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_hba_down_post_s4()
1149 spin_lock_irq(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_hba_down_post_s4()
1150 list_splice_init(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list, in lpfc_hba_down_post_s4()
1152 spin_unlock_irq(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_hba_down_post_s4()
1154 ctxp->flag &= ~(LPFC_NVME_XBUSY | LPFC_NVME_ABORT_OP); in lpfc_hba_down_post_s4()
1155 lpfc_nvmet_ctxbuf_post(phba, ctxp->ctxbuf); in lpfc_hba_down_post_s4()
1164 * lpfc_hba_down_post - Wrapper func for hba down post routine
1171 * 0 - success.
1172 * Any other value - error.
1177 return (*phba->lpfc_hba_down_post)(phba); in lpfc_hba_down_post()
1181 * lpfc_hb_timeout - The HBA-timer timeout handler
1184 * This is the HBA-timer timeout handler registered to the lpfc driver. When
1186 * work-port-events bitmap and the worker thread is notified. This timeout
1202 spin_lock_irqsave(&phba->pport->work_port_lock, iflag); in lpfc_hb_timeout()
1203 tmo_posted = phba->pport->work_port_events & WORKER_HB_TMO; in lpfc_hb_timeout()
1205 phba->pport->work_port_events |= WORKER_HB_TMO; in lpfc_hb_timeout()
1206 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); in lpfc_hb_timeout()
1215 * lpfc_rrq_timeout - The RRQ-timer timeout handler
1218 * This is the RRQ-timer timeout handler registered to the lpfc driver. When
1220 * work-port-events bitmap and the worker thread is notified. This timeout
1232 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { in lpfc_rrq_timeout()
1233 clear_bit(HBA_RRQ_ACTIVE, &phba->hba_flag); in lpfc_rrq_timeout()
1237 set_bit(HBA_RRQ_ACTIVE, &phba->hba_flag); in lpfc_rrq_timeout()
1242 * lpfc_hb_mbox_cmpl - The lpfc heart-beat mailbox command callback function
1246 * This is the callback function to the lpfc heart-beat mailbox command.
1247 * If configured, the lpfc driver issues the heart-beat mailbox command to
1249 * heart-beat mailbox command is issued, the driver shall set up heart-beat
1251 * heart-beat outstanding state. Once the mailbox command comes back and
1252 * no error conditions detected, the heart-beat mailbox command timer is
1253 * reset to LPFC_HB_MBOX_INTERVAL seconds and the heart-beat outstanding
1254 * state is cleared for the next heart-beat. If the timer expired with the
1255 * heart-beat outstanding state set, the driver will put the HBA offline.
1260 clear_bit(HBA_HBEAT_INP, &phba->hba_flag); in lpfc_hb_mbox_cmpl()
1261 clear_bit(HBA_HBEAT_TMO, &phba->hba_flag); in lpfc_hb_mbox_cmpl()
1263 /* Check and reset heart-beat timer if necessary */ in lpfc_hb_mbox_cmpl()
1264 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_hb_mbox_cmpl()
1265 if (!test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag) && in lpfc_hb_mbox_cmpl()
1266 !(phba->link_state == LPFC_HBA_ERROR) && in lpfc_hb_mbox_cmpl()
1267 !test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_hb_mbox_cmpl()
1268 mod_timer(&phba->hb_tmofunc, in lpfc_hb_mbox_cmpl()
1275 * lpfc_idle_stat_delay_work - idle_stat tracking
1277 * This routine tracks per-eq idle_stat and determines polling decisions.
1294 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_idle_stat_delay_work()
1297 if (phba->link_state == LPFC_HBA_ERROR || in lpfc_idle_stat_delay_work()
1298 test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag) || in lpfc_idle_stat_delay_work()
1299 phba->cmf_active_mode != LPFC_CFG_OFF) in lpfc_idle_stat_delay_work()
1303 hdwq = &phba->sli4_hba.hdwq[phba->sli4_hba.cpu_map[i].hdwq]; in lpfc_idle_stat_delay_work()
1304 eq = hdwq->hba_eq; in lpfc_idle_stat_delay_work()
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()
1432 /* Snapshot pbl, pvt and busy count */ in lpfc_hb_mxp_handler()
1439 * lpfc_issue_hb_mbox - Issues heart-beat mailbox command
1453 if (test_bit(HBA_HBEAT_INP, &phba->hba_flag)) in lpfc_issue_hb_mbox()
1456 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_issue_hb_mbox()
1458 return -ENOMEM; in lpfc_issue_hb_mbox()
1461 pmboxq->mbox_cmpl = lpfc_hb_mbox_cmpl; in lpfc_issue_hb_mbox()
1462 pmboxq->vport = phba->pport; in lpfc_issue_hb_mbox()
1466 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_issue_hb_mbox()
1467 return -ENXIO; in lpfc_issue_hb_mbox()
1469 set_bit(HBA_HBEAT_INP, &phba->hba_flag); in lpfc_issue_hb_mbox()
1475 * lpfc_issue_hb_tmo - Signals heartbeat timer to issue mbox command
1487 if (phba->cfg_enable_hba_heartbeat) in lpfc_issue_hb_tmo()
1489 set_bit(HBA_HBEAT_TMO, &phba->hba_flag); in lpfc_issue_hb_tmo()
1493 * lpfc_hb_timeout_handler - The HBA-timer timeout handler
1496 * This is the actual HBA-timer timeout handler to be invoked by the worker
1497 * thread whenever the HBA timer fired and HBA-timeout event posted. This
1500 * or by processing slow-ring or fast-ring events within the HBA-timer
1502 * the timer for the next timeout period. If lpfc heart-beat mailbox command
1503 * is configured and there is no heart-beat mailbox command outstanding, a
1504 * heart-beat mailbox is issued and timer set properly. Otherwise, if there
1505 * has been a heart-beat mailbox command outstanding, the HBA shall be put
1515 struct lpfc_sli *psli = &phba->sli; in lpfc_hb_timeout_handler()
1518 if (phba->cfg_xri_rebalancing) { in lpfc_hb_timeout_handler()
1519 /* Multi-XRI pools handler */ in lpfc_hb_timeout_handler()
1525 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_hb_timeout_handler()
1531 if (phba->link_state == LPFC_HBA_ERROR || in lpfc_hb_timeout_handler()
1532 test_bit(FC_UNLOADING, &phba->pport->load_flag) || in lpfc_hb_timeout_handler()
1533 test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_hb_timeout_handler()
1536 if (phba->elsbuf_cnt && in lpfc_hb_timeout_handler()
1537 (phba->elsbuf_cnt == phba->elsbuf_prev_cnt)) { in lpfc_hb_timeout_handler()
1538 spin_lock_irq(&phba->hbalock); in lpfc_hb_timeout_handler()
1539 list_splice_init(&phba->elsbuf, &completions); in lpfc_hb_timeout_handler()
1540 phba->elsbuf_cnt = 0; in lpfc_hb_timeout_handler()
1541 phba->elsbuf_prev_cnt = 0; in lpfc_hb_timeout_handler()
1542 spin_unlock_irq(&phba->hbalock); in lpfc_hb_timeout_handler()
1547 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); in lpfc_hb_timeout_handler()
1551 phba->elsbuf_prev_cnt = phba->elsbuf_cnt; in lpfc_hb_timeout_handler()
1553 /* If there is no heart beat outstanding, issue a heartbeat command */ in lpfc_hb_timeout_handler()
1554 if (phba->cfg_enable_hba_heartbeat) { in lpfc_hb_timeout_handler()
1555 /* If IOs are completing, no need to issue a MBX_HEARTBEAT */ in lpfc_hb_timeout_handler()
1556 spin_lock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1557 if (time_after(phba->last_completion_time + in lpfc_hb_timeout_handler()
1560 spin_unlock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1561 if (test_bit(HBA_HBEAT_INP, &phba->hba_flag)) in lpfc_hb_timeout_handler()
1567 spin_unlock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1570 if (test_bit(HBA_HBEAT_INP, &phba->hba_flag)) { in lpfc_hb_timeout_handler()
1580 - phba->last_completion_time)); in lpfc_hb_timeout_handler()
1583 if ((!(psli->sli_flag & LPFC_SLI_MBOX_ACTIVE)) && in lpfc_hb_timeout_handler()
1584 (list_empty(&psli->mboxq))) { in lpfc_hb_timeout_handler()
1591 phba->skipped_hb = 0; in lpfc_hb_timeout_handler()
1592 } else if (time_before_eq(phba->last_completion_time, in lpfc_hb_timeout_handler()
1593 phba->skipped_hb)) { in lpfc_hb_timeout_handler()
1598 - phba->last_completion_time)); in lpfc_hb_timeout_handler()
1600 phba->skipped_hb = jiffies; in lpfc_hb_timeout_handler()
1607 if (test_bit(HBA_HBEAT_TMO, &phba->hba_flag)) { in lpfc_hb_timeout_handler()
1618 mod_timer(&phba->hb_tmofunc, jiffies + msecs_to_jiffies(tmo)); in lpfc_hb_timeout_handler()
1622 * lpfc_offline_eratt - Bring lpfc offline on hardware error attention
1631 struct lpfc_sli *psli = &phba->sli; in lpfc_offline_eratt()
1633 spin_lock_irq(&phba->hbalock); in lpfc_offline_eratt()
1634 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_offline_eratt()
1635 spin_unlock_irq(&phba->hbalock); in lpfc_offline_eratt()
1640 spin_lock_irq(&phba->hbalock); in lpfc_offline_eratt()
1642 spin_unlock_irq(&phba->hbalock); in lpfc_offline_eratt()
1646 phba->link_state = LPFC_HBA_ERROR; in lpfc_offline_eratt()
1651 * lpfc_sli4_offline_eratt - Bring lpfc offline on SLI4 hardware error attention
1660 spin_lock_irq(&phba->hbalock); in lpfc_sli4_offline_eratt()
1661 if (phba->link_state == LPFC_HBA_ERROR && in lpfc_sli4_offline_eratt()
1662 test_bit(HBA_PCI_ERR, &phba->bit_flags)) { in lpfc_sli4_offline_eratt()
1663 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_offline_eratt()
1666 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli4_offline_eratt()
1667 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_offline_eratt()
1677 * lpfc_handle_deferred_eratt - The HBA hardware deferred error handler
1688 uint32_t old_host_status = phba->work_hs; in lpfc_handle_deferred_eratt()
1689 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_deferred_eratt()
1694 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_deferred_eratt()
1695 clear_bit(DEFER_ERATT, &phba->hba_flag); in lpfc_handle_deferred_eratt()
1702 phba->work_hs, phba->work_status[0], in lpfc_handle_deferred_eratt()
1703 phba->work_status[1]); in lpfc_handle_deferred_eratt()
1705 spin_lock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1706 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_handle_deferred_eratt()
1707 spin_unlock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1713 * SCSI layer retry it after re-establishing link. in lpfc_handle_deferred_eratt()
1725 while (phba->work_hs & HS_FFER1) { in lpfc_handle_deferred_eratt()
1727 if (lpfc_readl(phba->HSregaddr, &phba->work_hs)) { in lpfc_handle_deferred_eratt()
1728 phba->work_hs = UNPLUG_ERR ; in lpfc_handle_deferred_eratt()
1732 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { in lpfc_handle_deferred_eratt()
1733 phba->work_hs = 0; in lpfc_handle_deferred_eratt()
1743 if (!phba->work_hs && !test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_handle_deferred_eratt()
1744 phba->work_hs = old_host_status & ~HS_FFER1; in lpfc_handle_deferred_eratt()
1746 clear_bit(DEFER_ERATT, &phba->hba_flag); in lpfc_handle_deferred_eratt()
1747 phba->work_status[0] = readl(phba->MBslimaddr + 0xa8); in lpfc_handle_deferred_eratt()
1748 phba->work_status[1] = readl(phba->MBslimaddr + 0xac); in lpfc_handle_deferred_eratt()
1759 shost = lpfc_shost_from_vport(phba->pport); in lpfc_board_errevt_to_mgmt()
1767 * lpfc_handle_eratt_s3 - The SLI3 HBA hardware error handler
1772 * 1 - HBA error attention interrupt
1773 * 2 - DMA ring index out of range
1774 * 3 - Mailbox command came back as unknown
1779 struct lpfc_vport *vport = phba->pport; in lpfc_handle_eratt_s3()
1780 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_eratt_s3()
1789 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_eratt_s3()
1790 clear_bit(DEFER_ERATT, &phba->hba_flag); in lpfc_handle_eratt_s3()
1795 if (!phba->cfg_enable_hba_reset) in lpfc_handle_eratt_s3()
1801 if (test_bit(DEFER_ERATT, &phba->hba_flag)) in lpfc_handle_eratt_s3()
1804 if ((phba->work_hs & HS_FFER6) || (phba->work_hs & HS_FFER8)) { in lpfc_handle_eratt_s3()
1805 if (phba->work_hs & HS_FFER6) in lpfc_handle_eratt_s3()
1806 /* Re-establishing Link */ in lpfc_handle_eratt_s3()
1808 "1301 Re-establishing Link " in lpfc_handle_eratt_s3()
1810 phba->work_hs, phba->work_status[0], in lpfc_handle_eratt_s3()
1811 phba->work_status[1]); in lpfc_handle_eratt_s3()
1812 if (phba->work_hs & HS_FFER8) in lpfc_handle_eratt_s3()
1817 phba->work_hs, phba->work_status[0], in lpfc_handle_eratt_s3()
1818 phba->work_status[1]); in lpfc_handle_eratt_s3()
1820 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1821 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_handle_eratt_s3()
1822 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1828 * retry it after re-establishing link. in lpfc_handle_eratt_s3()
1844 } else if (phba->work_hs & HS_CRIT_TEMP) { in lpfc_handle_eratt_s3()
1845 temperature = readl(phba->MBslimaddr + TEMPERATURE_OFFSET); in lpfc_handle_eratt_s3()
1854 temperature, phba->work_hs, in lpfc_handle_eratt_s3()
1855 phba->work_status[0], phba->work_status[1]); in lpfc_handle_eratt_s3()
1857 shost = lpfc_shost_from_vport(phba->pport); in lpfc_handle_eratt_s3()
1864 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1865 phba->over_temp_state = HBA_OVER_TEMP; in lpfc_handle_eratt_s3()
1866 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1877 phba->work_hs, in lpfc_handle_eratt_s3()
1878 phba->work_status[0], phba->work_status[1]); in lpfc_handle_eratt_s3()
1892 * lpfc_sli4_port_sta_fn_reset - The SLI4 function reset due to port status reg
1910 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_port_sta_fn_reset()
1927 /* If we are no wait, the HBA has been reset and is not in lpfc_sli4_port_sta_fn_reset()
1932 spin_lock_irq(&phba->hbalock); in lpfc_sli4_port_sta_fn_reset()
1933 phba->sli.sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_sli4_port_sta_fn_reset()
1934 if (phba->sli.mbox_active) { in lpfc_sli4_port_sta_fn_reset()
1935 mboxq = phba->sli.mbox_active; in lpfc_sli4_port_sta_fn_reset()
1936 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_port_sta_fn_reset()
1938 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_port_sta_fn_reset()
1939 phba->sli.mbox_active = NULL; in lpfc_sli4_port_sta_fn_reset()
1941 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_port_sta_fn_reset()
1956 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_sli4_port_sta_fn_reset()
1960 return -EIO; in lpfc_sli4_port_sta_fn_reset()
1962 phba->intr_mode = intr_mode; in lpfc_sli4_port_sta_fn_reset()
1971 * lpfc_handle_eratt_s4 - The SLI4 HBA hardware error handler
1980 struct lpfc_vport *vport = phba->pport; in lpfc_handle_eratt_s4()
1996 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_eratt_s4()
2004 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_handle_eratt_s4()
2008 phba->sli4_hba.u.if_type0.UERRLOregaddr, in lpfc_handle_eratt_s4()
2011 phba->sli4_hba.u.if_type0.UEMASKLOregaddr, in lpfc_handle_eratt_s4()
2014 if (pci_rd_rc1 == -EIO && pci_rd_rc2 == -EIO) in lpfc_handle_eratt_s4()
2016 if (!test_bit(HBA_RECOVERABLE_UE, &phba->hba_flag)) { in lpfc_handle_eratt_s4()
2023 for (i = 0; i < phba->sli4_hba.ue_to_sr / 1000; i++) { in lpfc_handle_eratt_s4()
2024 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_handle_eratt_s4()
2046 if (!lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_handle_eratt_s4()
2065 phba->link_state = LPFC_HBA_ERROR; in lpfc_handle_eratt_s4()
2071 phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_handle_eratt_s4()
2074 if (pci_rd_rc1 == -EIO) { in lpfc_handle_eratt_s4()
2077 readl(phba->sli4_hba.u.if_type2.STATUSregaddr)); in lpfc_handle_eratt_s4()
2081 reg_err1 = readl(phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_handle_eratt_s4()
2082 reg_err2 = readl(phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_handle_eratt_s4()
2089 phba->sfp_alarm |= LPFC_TRANSGRESSION_HIGH_TEMPERATURE; in lpfc_handle_eratt_s4()
2094 shost = lpfc_shost_from_vport(phba->pport); in lpfc_handle_eratt_s4()
2101 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s4()
2102 phba->over_temp_state = HBA_OVER_TEMP; in lpfc_handle_eratt_s4()
2103 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s4()
2123 if (!phba->cfg_enable_hba_reset) in lpfc_handle_eratt_s4()
2159 * lpfc_handle_eratt - Wrapper func for handling hba error attention
2166 * 0 - success.
2167 * Any other value - error.
2172 (*phba->lpfc_handle_eratt)(phba); in lpfc_handle_eratt()
2176 * lpfc_handle_latt - The HBA link event handler
2185 struct lpfc_vport *vport = phba->pport; in lpfc_handle_latt()
2186 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_latt()
2191 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_handle_latt()
2200 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_handle_latt()
2206 psli->slistat.link_event++; in lpfc_handle_latt()
2207 lpfc_read_topology(phba, pmb, pmb->ctx_buf); in lpfc_handle_latt()
2208 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_handle_latt()
2209 pmb->vport = vport; in lpfc_handle_latt()
2211 phba->sli.sli3_ring[LPFC_ELS_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_handle_latt()
2219 spin_lock_irq(&phba->hbalock); in lpfc_handle_latt()
2220 writel(HA_LATT, phba->HAregaddr); in lpfc_handle_latt()
2221 readl(phba->HAregaddr); /* flush */ in lpfc_handle_latt()
2222 spin_unlock_irq(&phba->hbalock); in lpfc_handle_latt()
2227 phba->sli.sli3_ring[LPFC_ELS_RING].flag &= ~LPFC_STOP_IOCB_EVENT; in lpfc_handle_latt()
2231 spin_lock_irq(&phba->hbalock); in lpfc_handle_latt()
2232 psli->sli_flag |= LPFC_PROCESS_LA; in lpfc_handle_latt()
2233 control = readl(phba->HCregaddr); in lpfc_handle_latt()
2235 writel(control, phba->HCregaddr); in lpfc_handle_latt()
2236 readl(phba->HCregaddr); /* flush */ in lpfc_handle_latt()
2239 writel(HA_LATT, phba->HAregaddr); in lpfc_handle_latt()
2240 readl(phba->HAregaddr); /* flush */ in lpfc_handle_latt()
2241 spin_unlock_irq(&phba->hbalock); in lpfc_handle_latt()
2243 phba->link_state = LPFC_HBA_ERROR; in lpfc_handle_latt()
2263 length -= (3+i); in lpfc_fill_vpd()
2264 while (i--) { in lpfc_fill_vpd()
2265 phba->SerialNumber[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2269 phba->SerialNumber[j] = 0; in lpfc_fill_vpd()
2272 phba->vpd_flag |= VPD_MODEL_DESC; in lpfc_fill_vpd()
2277 length -= (3+i); in lpfc_fill_vpd()
2278 while (i--) { in lpfc_fill_vpd()
2279 phba->ModelDesc[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2283 phba->ModelDesc[j] = 0; in lpfc_fill_vpd()
2286 phba->vpd_flag |= VPD_MODEL_NAME; in lpfc_fill_vpd()
2291 length -= (3+i); in lpfc_fill_vpd()
2292 while (i--) { in lpfc_fill_vpd()
2293 phba->ModelName[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2297 phba->ModelName[j] = 0; in lpfc_fill_vpd()
2300 phba->vpd_flag |= VPD_PROGRAM_TYPE; in lpfc_fill_vpd()
2305 length -= (3+i); in lpfc_fill_vpd()
2306 while (i--) { in lpfc_fill_vpd()
2307 phba->ProgramType[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2311 phba->ProgramType[j] = 0; in lpfc_fill_vpd()
2314 phba->vpd_flag |= VPD_PORT; in lpfc_fill_vpd()
2319 length -= (3 + i); in lpfc_fill_vpd()
2320 while (i--) { in lpfc_fill_vpd()
2321 if ((phba->sli_rev == LPFC_SLI_REV4) && in lpfc_fill_vpd()
2322 (phba->sli4_hba.pport_name_sta == in lpfc_fill_vpd()
2327 phba->Port[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2331 if ((phba->sli_rev != LPFC_SLI_REV4) || in lpfc_fill_vpd()
2332 (phba->sli4_hba.pport_name_sta == in lpfc_fill_vpd()
2334 phba->Port[j] = 0; in lpfc_fill_vpd()
2341 length -= (3 + i); in lpfc_fill_vpd()
2347 * lpfc_parse_vpd - Parse VPD (Vital Product Data)
2357 * 0 - pointer to the VPD passed in is NULL
2358 * 1 - success
2377 while (!finished && (index < (len - 4))) { in lpfc_parse_vpd()
2396 if (Length > len - index) in lpfc_parse_vpd()
2397 Length = len - index; in lpfc_parse_vpd()
2415 * lpfc_get_atto_model_desc - Retrieve ATTO HBA device model name and description
2429 uint16_t sub_dev_id = phba->pcidev->subsystem_device; in lpfc_get_atto_model_desc()
2493 (tbolt) ? "ThunderLink FC " : "Celerity FC-", in lpfc_get_atto_model_desc()
2495 phba->Port); in lpfc_get_atto_model_desc()
2499 * lpfc_get_hba_model_desc - Retrieve HBA device model name and description
2514 uint16_t dev_id = phba->pcidev->device; in lpfc_get_hba_model_desc()
2528 if (phba->pcidev->vendor == PCI_VENDOR_ID_ATTO) { in lpfc_get_hba_model_desc()
2533 if (phba->lmt & LMT_64Gb) in lpfc_get_hba_model_desc()
2535 else if (phba->lmt & LMT_32Gb) in lpfc_get_hba_model_desc()
2537 else if (phba->lmt & LMT_16Gb) in lpfc_get_hba_model_desc()
2539 else if (phba->lmt & LMT_10Gb) in lpfc_get_hba_model_desc()
2541 else if (phba->lmt & LMT_8Gb) in lpfc_get_hba_model_desc()
2543 else if (phba->lmt & LMT_4Gb) in lpfc_get_hba_model_desc()
2545 else if (phba->lmt & LMT_2Gb) in lpfc_get_hba_model_desc()
2547 else if (phba->lmt & LMT_1Gb) in lpfc_get_hba_model_desc()
2552 vp = &phba->vpd; in lpfc_get_hba_model_desc()
2560 if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3) in lpfc_get_hba_model_desc()
2571 if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID) in lpfc_get_hba_model_desc()
2582 m = (typeof(m)){"LP9802", "PCI-X", in lpfc_get_hba_model_desc()
2586 m = (typeof(m)){"LP10000", "PCI-X", in lpfc_get_hba_model_desc()
2590 m = (typeof(m)){"LPX1000", "PCI-X", in lpfc_get_hba_model_desc()
2594 m = (typeof(m)){"LP982", "PCI-X", in lpfc_get_hba_model_desc()
2598 m = (typeof(m)){"LP1050", "PCI-X", in lpfc_get_hba_model_desc()
2602 m = (typeof(m)){"LP11000", "PCI-X2", in lpfc_get_hba_model_desc()
2606 m = (typeof(m)){"LP11000-SP", "PCI-X2", in lpfc_get_hba_model_desc()
2610 m = (typeof(m)){"LP11002-SP", "PCI-X2", in lpfc_get_hba_model_desc()
2618 m = (typeof(m)){"LPe1000-SP", "PCIe", in lpfc_get_hba_model_desc()
2622 m = (typeof(m)){"LPe1002-SP", "PCIe", in lpfc_get_hba_model_desc()
2626 m = (typeof(m)){"LP1150", "PCI-X2", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2629 m = (typeof(m)){"LP111", "PCI-X2", in lpfc_get_hba_model_desc()
2649 m = (typeof(m)){"LP101", "PCI-X", in lpfc_get_hba_model_desc()
2653 m = (typeof(m)){"LP10000-S", "PCI", in lpfc_get_hba_model_desc()
2657 m = (typeof(m)){"LP11000-S", "PCI-X2", in lpfc_get_hba_model_desc()
2661 m = (typeof(m)){"LPe11000-S", "PCIe", in lpfc_get_hba_model_desc()
2674 m = (typeof(m)){"LPe12002-SP", "PCIe", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2677 m = (typeof(m)){"LPe12000-SP", "PCIe", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2680 m = (typeof(m)){"LPe12000-S", "PCIe", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2691 m = (typeof(m)){"LPemv12002-S", "PCIe IOV", in lpfc_get_hba_model_desc()
2703 m = (typeof(m)){"LPSe12002-ML1-E", "PCIe", in lpfc_get_hba_model_desc()
2756 phba->Port); in lpfc_get_hba_model_desc()
2770 * lpfc_sli3_post_buffer - Post IOCB(s) with DMA buffer descriptor(s) to a IOCB ring
2788 cnt += pring->missbufcnt; in lpfc_sli3_post_buffer()
2795 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2798 icmd = &iocb->iocb; in lpfc_sli3_post_buffer()
2804 mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &mp1->phys); in lpfc_sli3_post_buffer()
2805 if (!mp1 || !mp1->virt) { in lpfc_sli3_post_buffer()
2808 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2812 INIT_LIST_HEAD(&mp1->list); in lpfc_sli3_post_buffer()
2817 mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI, in lpfc_sli3_post_buffer()
2818 &mp2->phys); in lpfc_sli3_post_buffer()
2819 if (!mp2 || !mp2->virt) { in lpfc_sli3_post_buffer()
2821 lpfc_mbuf_free(phba, mp1->virt, mp1->phys); in lpfc_sli3_post_buffer()
2824 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2828 INIT_LIST_HEAD(&mp2->list); in lpfc_sli3_post_buffer()
2833 icmd->un.cont64[0].addrHigh = putPaddrHigh(mp1->phys); in lpfc_sli3_post_buffer()
2834 icmd->un.cont64[0].addrLow = putPaddrLow(mp1->phys); in lpfc_sli3_post_buffer()
2835 icmd->un.cont64[0].tus.f.bdeSize = FCELSSIZE; in lpfc_sli3_post_buffer()
2836 icmd->ulpBdeCount = 1; in lpfc_sli3_post_buffer()
2837 cnt--; in lpfc_sli3_post_buffer()
2839 icmd->un.cont64[1].addrHigh = putPaddrHigh(mp2->phys); in lpfc_sli3_post_buffer()
2840 icmd->un.cont64[1].addrLow = putPaddrLow(mp2->phys); in lpfc_sli3_post_buffer()
2841 icmd->un.cont64[1].tus.f.bdeSize = FCELSSIZE; in lpfc_sli3_post_buffer()
2842 cnt--; in lpfc_sli3_post_buffer()
2843 icmd->ulpBdeCount = 2; in lpfc_sli3_post_buffer()
2846 icmd->ulpCommand = CMD_QUE_RING_BUF64_CN; in lpfc_sli3_post_buffer()
2847 icmd->ulpLe = 1; in lpfc_sli3_post_buffer()
2849 if (lpfc_sli_issue_iocb(phba, pring->ringno, iocb, 0) == in lpfc_sli3_post_buffer()
2851 lpfc_mbuf_free(phba, mp1->virt, mp1->phys); in lpfc_sli3_post_buffer()
2855 lpfc_mbuf_free(phba, mp2->virt, mp2->phys); in lpfc_sli3_post_buffer()
2860 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2867 pring->missbufcnt = 0; in lpfc_sli3_post_buffer()
2872 * lpfc_post_rcv_buf - Post the initial receive IOCB buffers to ELS ring
2880 * 0 - success (currently always success)
2885 struct lpfc_sli *psli = &phba->sli; in lpfc_post_rcv_buf()
2888 lpfc_sli3_post_buffer(phba, &psli->sli3_ring[LPFC_ELS_RING], LPFC_BUF_RING0); in lpfc_post_rcv_buf()
2889 /* Ring 2 - FCP no buffers needed */ in lpfc_post_rcv_buf()
2894 #define S(N,V) (((V)<<(N))|((V)>>(32-(N))))
2897 * lpfc_sha_init - Set up initial array of hash table entries
2914 * lpfc_sha_iterate - Iterate initial hash table with the working hash table
2933 HashWorkingPointer[t - 3] ^ HashWorkingPointer[t - in lpfc_sha_iterate()
2935 HashWorkingPointer[t - 14] ^ HashWorkingPointer[t - 16]); in lpfc_sha_iterate()
2971 * lpfc_challenge_key - Create challenge key based on WWPN of the HBA
2987 * lpfc_hba_init - Perform special handling for LC HBA initialization
2989 * @hbainit: pointer to an array of unsigned 32-bit integers.
2998 uint32_t *pwwnn = (uint32_t *) phba->wwnn; in lpfc_hba_init()
3008 lpfc_challenge_key(phba->RandomData + t, HashWorking + t); in lpfc_hba_init()
3016 * lpfc_cleanup - Performs vport cleanups before deleting a vport
3027 struct lpfc_hba *phba = vport->phba; in lpfc_cleanup()
3031 if (phba->link_state > LPFC_LINK_DOWN) in lpfc_cleanup()
3038 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { in lpfc_cleanup()
3039 if (vport->port_type != LPFC_PHYSICAL_PORT && in lpfc_cleanup()
3040 ndlp->nlp_DID == Fabric_DID) { in lpfc_cleanup()
3046 if (ndlp->nlp_DID == Fabric_Cntl_DID && in lpfc_cleanup()
3047 ndlp->nlp_state == NLP_STE_UNUSED_NODE) { in lpfc_cleanup()
3055 if (ndlp->nlp_type & NLP_FABRIC && in lpfc_cleanup()
3056 ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) in lpfc_cleanup()
3060 if (!(ndlp->fc4_xpt_flags & (NVME_XPT_REGD|SCSI_XPT_REGD))) in lpfc_cleanup()
3077 if (test_bit(FC_UNLOADING, &vport->load_flag) && in lpfc_cleanup()
3078 pci_channel_offline(phba->pcidev)) in lpfc_cleanup()
3079 lpfc_sli_flush_io_rings(vport->phba); in lpfc_cleanup()
3085 while (!list_empty(&vport->fc_nodes)) { in lpfc_cleanup()
3091 &vport->fc_nodes, nlp_listp) { in lpfc_cleanup()
3092 lpfc_printf_vlog(ndlp->vport, KERN_ERR, in lpfc_cleanup()
3096 ndlp->nlp_DID, (void *)ndlp, in lpfc_cleanup()
3097 kref_read(&ndlp->kref), in lpfc_cleanup()
3098 ndlp->fc4_xpt_flags, in lpfc_cleanup()
3099 ndlp->nlp_flag); in lpfc_cleanup()
3111 * lpfc_stop_vport_timers - Stop all the timers associated with a vport
3121 del_timer_sync(&vport->els_tmofunc); in lpfc_stop_vport_timers()
3122 del_timer_sync(&vport->delayed_disc_tmo); in lpfc_stop_vport_timers()
3128 * __lpfc_sli4_stop_fcf_redisc_wait_timer - Stop FCF rediscovery wait timer
3138 phba->fcf.fcf_flag &= ~FCF_REDISC_PEND; in __lpfc_sli4_stop_fcf_redisc_wait_timer()
3141 del_timer(&phba->fcf.redisc_wait); in __lpfc_sli4_stop_fcf_redisc_wait_timer()
3145 * lpfc_sli4_stop_fcf_redisc_wait_timer - Stop FCF rediscovery wait timer
3156 spin_lock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3157 if (!(phba->fcf.fcf_flag & FCF_REDISC_PEND)) { in lpfc_sli4_stop_fcf_redisc_wait_timer()
3159 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3164 phba->fcf.fcf_flag &= ~(FCF_DEAD_DISC | FCF_ACVL_DISC); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3165 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3169 * lpfc_cmf_stop - Stop CMF processing
3183 if (!phba->sli4_hba.pc_sli4_params.cmf) in lpfc_cmf_stop()
3190 hrtimer_cancel(&phba->cmf_stats_timer); in lpfc_cmf_stop()
3191 hrtimer_cancel(&phba->cmf_timer); in lpfc_cmf_stop()
3194 atomic_set(&phba->cmf_busy, 0); in lpfc_cmf_stop()
3196 cgs = per_cpu_ptr(phba->cmf_stat, cpu); in lpfc_cmf_stop()
3197 atomic64_set(&cgs->total_bytes, 0); in lpfc_cmf_stop()
3198 atomic64_set(&cgs->rcv_bytes, 0); in lpfc_cmf_stop()
3199 atomic_set(&cgs->rx_io_cnt, 0); in lpfc_cmf_stop()
3200 atomic64_set(&cgs->rx_latency, 0); in lpfc_cmf_stop()
3202 atomic_set(&phba->cmf_bw_wait, 0); in lpfc_cmf_stop()
3204 /* Resume any blocked IO - Queue unblock on workqueue */ in lpfc_cmf_stop()
3205 queue_work(phba->wq, &phba->unblock_request_work); in lpfc_cmf_stop()
3223 phba->cmf_interval_rate = LPFC_CMF_INTERVAL; in lpfc_cmf_signal_init()
3224 phba->cmf_max_line_rate = lpfc_get_max_line_rate(phba); in lpfc_cmf_signal_init()
3225 phba->cmf_link_byte_count = div_u64(phba->cmf_max_line_rate * in lpfc_cmf_signal_init()
3226 phba->cmf_interval_rate, 1000); in lpfc_cmf_signal_init()
3227 phba->cmf_max_bytes_per_interval = phba->cmf_link_byte_count; in lpfc_cmf_signal_init()
3234 * lpfc_cmf_start - Start CMF processing
3247 if (!phba->sli4_hba.pc_sli4_params.cmf || in lpfc_cmf_start()
3248 phba->cmf_active_mode == LPFC_CFG_OFF) in lpfc_cmf_start()
3254 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_cmf_start()
3255 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_cmf_start()
3256 atomic_set(&phba->cgn_sync_alarm_cnt, 0); in lpfc_cmf_start()
3257 atomic_set(&phba->cgn_sync_warn_cnt, 0); in lpfc_cmf_start()
3259 atomic_set(&phba->cmf_busy, 0); in lpfc_cmf_start()
3261 cgs = per_cpu_ptr(phba->cmf_stat, cpu); in lpfc_cmf_start()
3262 atomic64_set(&cgs->total_bytes, 0); in lpfc_cmf_start()
3263 atomic64_set(&cgs->rcv_bytes, 0); in lpfc_cmf_start()
3264 atomic_set(&cgs->rx_io_cnt, 0); in lpfc_cmf_start()
3265 atomic64_set(&cgs->rx_latency, 0); in lpfc_cmf_start()
3267 phba->cmf_latency.tv_sec = 0; in lpfc_cmf_start()
3268 phba->cmf_latency.tv_nsec = 0; in lpfc_cmf_start()
3275 phba->cmf_timer_cnt = 0; in lpfc_cmf_start()
3276 hrtimer_start(&phba->cmf_timer, in lpfc_cmf_start()
3279 hrtimer_start(&phba->cmf_stats_timer, in lpfc_cmf_start()
3283 ktime_get_real_ts64(&phba->cmf_latency); in lpfc_cmf_start()
3285 atomic_set(&phba->cmf_bw_wait, 0); in lpfc_cmf_start()
3286 atomic_set(&phba->cmf_stop_io, 0); in lpfc_cmf_start()
3290 * lpfc_stop_hba_timers - Stop all the timers associated with an HBA
3299 if (phba->pport) in lpfc_stop_hba_timers()
3300 lpfc_stop_vport_timers(phba->pport); in lpfc_stop_hba_timers()
3301 cancel_delayed_work_sync(&phba->eq_delay_work); in lpfc_stop_hba_timers()
3302 cancel_delayed_work_sync(&phba->idle_stat_delay_work); in lpfc_stop_hba_timers()
3303 del_timer_sync(&phba->sli.mbox_tmo); in lpfc_stop_hba_timers()
3304 del_timer_sync(&phba->fabric_block_timer); in lpfc_stop_hba_timers()
3305 del_timer_sync(&phba->eratt_poll); in lpfc_stop_hba_timers()
3306 del_timer_sync(&phba->hb_tmofunc); in lpfc_stop_hba_timers()
3307 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_stop_hba_timers()
3308 del_timer_sync(&phba->rrq_tmr); in lpfc_stop_hba_timers()
3309 clear_bit(HBA_RRQ_ACTIVE, &phba->hba_flag); in lpfc_stop_hba_timers()
3311 clear_bit(HBA_HBEAT_INP, &phba->hba_flag); in lpfc_stop_hba_timers()
3312 clear_bit(HBA_HBEAT_TMO, &phba->hba_flag); in lpfc_stop_hba_timers()
3314 switch (phba->pci_dev_grp) { in lpfc_stop_hba_timers()
3317 del_timer_sync(&phba->fcp_poll_timer); in lpfc_stop_hba_timers()
3326 phba->pci_dev_grp); in lpfc_stop_hba_timers()
3333 * lpfc_block_mgmt_io - Mark a HBA's management interface as blocked
3335 * @mbx_action: flag for mailbox no wait action.
3350 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3351 phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO; in lpfc_block_mgmt_io()
3352 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3356 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3357 if (phba->sli.mbox_active) { in lpfc_block_mgmt_io()
3358 actcmd = phba->sli.mbox_active->u.mb.mbxCommand; in lpfc_block_mgmt_io()
3363 phba->sli.mbox_active) * 1000) + jiffies; in lpfc_block_mgmt_io()
3365 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3368 while (phba->sli.mbox_active) { in lpfc_block_mgmt_io()
3374 "- mbox cmd %x still active\n", in lpfc_block_mgmt_io()
3375 phba->sli.sli_flag, actcmd); in lpfc_block_mgmt_io()
3382 * lpfc_sli4_node_prep - Assign RPIs for active nodes.
3396 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_sli4_node_prep()
3403 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_sli4_node_prep()
3404 if (test_bit(FC_UNLOADING, &vports[i]->load_flag)) in lpfc_sli4_node_prep()
3408 &vports[i]->fc_nodes, in lpfc_sli4_node_prep()
3415 ndlp->nlp_rpi = rpi; in lpfc_sli4_node_prep()
3416 lpfc_printf_vlog(ndlp->vport, KERN_INFO, in lpfc_sli4_node_prep()
3420 ndlp->nlp_rpi, ndlp, ndlp->nlp_DID, in lpfc_sli4_node_prep()
3421 ndlp->nlp_flag); in lpfc_sli4_node_prep()
3428 * lpfc_create_expedite_pool - create expedite pool
3442 epd_pool = &phba->epd_pool; in lpfc_create_expedite_pool()
3443 qp = &phba->sli4_hba.hdwq[0]; in lpfc_create_expedite_pool()
3445 spin_lock_init(&epd_pool->lock); in lpfc_create_expedite_pool()
3446 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_create_expedite_pool()
3447 spin_lock(&epd_pool->lock); in lpfc_create_expedite_pool()
3448 INIT_LIST_HEAD(&epd_pool->list); in lpfc_create_expedite_pool()
3450 &qp->lpfc_io_buf_list_put, list) { in lpfc_create_expedite_pool()
3451 list_move_tail(&lpfc_ncmd->list, &epd_pool->list); in lpfc_create_expedite_pool()
3452 lpfc_ncmd->expedite = true; in lpfc_create_expedite_pool()
3453 qp->put_io_bufs--; in lpfc_create_expedite_pool()
3454 epd_pool->count++; in lpfc_create_expedite_pool()
3455 if (epd_pool->count >= XRI_BATCH) in lpfc_create_expedite_pool()
3458 spin_unlock(&epd_pool->lock); in lpfc_create_expedite_pool()
3459 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_create_expedite_pool()
3463 * lpfc_destroy_expedite_pool - destroy expedite pool
3477 epd_pool = &phba->epd_pool; in lpfc_destroy_expedite_pool()
3478 qp = &phba->sli4_hba.hdwq[0]; in lpfc_destroy_expedite_pool()
3480 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_expedite_pool()
3481 spin_lock(&epd_pool->lock); in lpfc_destroy_expedite_pool()
3483 &epd_pool->list, list) { in lpfc_destroy_expedite_pool()
3484 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_expedite_pool()
3485 &qp->lpfc_io_buf_list_put); in lpfc_destroy_expedite_pool()
3486 lpfc_ncmd->flags = false; in lpfc_destroy_expedite_pool()
3487 qp->put_io_bufs++; in lpfc_destroy_expedite_pool()
3488 epd_pool->count--; in lpfc_destroy_expedite_pool()
3490 spin_unlock(&epd_pool->lock); in lpfc_destroy_expedite_pool()
3491 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_expedite_pool()
3495 * lpfc_create_multixri_pools - create multi-XRI pools
3517 phba->cfg_hdw_queue, phba->sli4_hba.num_present_cpu, in lpfc_create_multixri_pools()
3518 phba->sli4_hba.io_xri_cnt); in lpfc_create_multixri_pools()
3520 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_create_multixri_pools()
3523 hwq_count = phba->cfg_hdw_queue; in lpfc_create_multixri_pools()
3524 count_per_hwq = phba->sli4_hba.io_xri_cnt / hwq_count; in lpfc_create_multixri_pools()
3534 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_create_multixri_pools()
3539 qp = &phba->sli4_hba.hdwq[j]; in lpfc_create_multixri_pools()
3540 kfree(qp->p_multixri_pool); in lpfc_create_multixri_pools()
3543 phba->cfg_xri_rebalancing = 0; in lpfc_create_multixri_pools()
3547 qp = &phba->sli4_hba.hdwq[i]; in lpfc_create_multixri_pools()
3548 qp->p_multixri_pool = multixri_pool; in lpfc_create_multixri_pools()
3550 multixri_pool->xri_limit = count_per_hwq; in lpfc_create_multixri_pools()
3551 multixri_pool->rrb_next_hwqid = i; in lpfc_create_multixri_pools()
3554 pbl_pool = &multixri_pool->pbl_pool; in lpfc_create_multixri_pools()
3555 spin_lock_init(&pbl_pool->lock); in lpfc_create_multixri_pools()
3556 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_create_multixri_pools()
3557 spin_lock(&pbl_pool->lock); in lpfc_create_multixri_pools()
3558 INIT_LIST_HEAD(&pbl_pool->list); in lpfc_create_multixri_pools()
3560 &qp->lpfc_io_buf_list_put, list) { in lpfc_create_multixri_pools()
3561 list_move_tail(&lpfc_ncmd->list, &pbl_pool->list); in lpfc_create_multixri_pools()
3562 qp->put_io_bufs--; in lpfc_create_multixri_pools()
3563 pbl_pool->count++; in lpfc_create_multixri_pools()
3567 pbl_pool->count, i); in lpfc_create_multixri_pools()
3568 spin_unlock(&pbl_pool->lock); in lpfc_create_multixri_pools()
3569 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_create_multixri_pools()
3572 pvt_pool = &multixri_pool->pvt_pool; in lpfc_create_multixri_pools()
3573 pvt_pool->high_watermark = multixri_pool->xri_limit / 2; in lpfc_create_multixri_pools()
3574 pvt_pool->low_watermark = XRI_BATCH; in lpfc_create_multixri_pools()
3575 spin_lock_init(&pvt_pool->lock); in lpfc_create_multixri_pools()
3576 spin_lock_irqsave(&pvt_pool->lock, iflag); in lpfc_create_multixri_pools()
3577 INIT_LIST_HEAD(&pvt_pool->list); in lpfc_create_multixri_pools()
3578 pvt_pool->count = 0; in lpfc_create_multixri_pools()
3579 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_create_multixri_pools()
3584 * lpfc_destroy_multixri_pools - destroy multi-XRI pools
3601 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_destroy_multixri_pools()
3604 if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_destroy_multixri_pools()
3607 hwq_count = phba->cfg_hdw_queue; in lpfc_destroy_multixri_pools()
3610 qp = &phba->sli4_hba.hdwq[i]; in lpfc_destroy_multixri_pools()
3611 multixri_pool = qp->p_multixri_pool; in lpfc_destroy_multixri_pools()
3615 qp->p_multixri_pool = NULL; in lpfc_destroy_multixri_pools()
3617 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_multixri_pools()
3620 pbl_pool = &multixri_pool->pbl_pool; in lpfc_destroy_multixri_pools()
3621 spin_lock(&pbl_pool->lock); in lpfc_destroy_multixri_pools()
3625 pbl_pool->count, i); in lpfc_destroy_multixri_pools()
3628 &pbl_pool->list, list) { in lpfc_destroy_multixri_pools()
3629 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_multixri_pools()
3630 &qp->lpfc_io_buf_list_put); in lpfc_destroy_multixri_pools()
3631 qp->put_io_bufs++; in lpfc_destroy_multixri_pools()
3632 pbl_pool->count--; in lpfc_destroy_multixri_pools()
3635 INIT_LIST_HEAD(&pbl_pool->list); in lpfc_destroy_multixri_pools()
3636 pbl_pool->count = 0; in lpfc_destroy_multixri_pools()
3638 spin_unlock(&pbl_pool->lock); in lpfc_destroy_multixri_pools()
3641 pvt_pool = &multixri_pool->pvt_pool; in lpfc_destroy_multixri_pools()
3642 spin_lock(&pvt_pool->lock); in lpfc_destroy_multixri_pools()
3646 pvt_pool->count, i); in lpfc_destroy_multixri_pools()
3649 &pvt_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 pvt_pool->count--; in lpfc_destroy_multixri_pools()
3656 INIT_LIST_HEAD(&pvt_pool->list); in lpfc_destroy_multixri_pools()
3657 pvt_pool->count = 0; in lpfc_destroy_multixri_pools()
3659 spin_unlock(&pvt_pool->lock); in lpfc_destroy_multixri_pools()
3660 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_multixri_pools()
3667 * lpfc_online - Initialize and bring a HBA online
3675 * 0 - successful
3676 * 1 - failed
3688 vport = phba->pport; in lpfc_online()
3690 if (!test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) in lpfc_online()
3698 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_online()
3703 spin_lock_irq(&phba->hbalock); in lpfc_online()
3704 if (!phba->sli4_hba.max_cfg_param.vpi_used) in lpfc_online()
3706 spin_unlock_irq(&phba->hbalock); in lpfc_online()
3711 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME && in lpfc_online()
3712 !phba->nvmet_support) { in lpfc_online()
3713 error = lpfc_nvme_create_localport(phba->pport); in lpfc_online()
3729 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_online()
3730 clear_bit(FC_OFFLINE_MODE, &vports[i]->fc_flag); in lpfc_online()
3731 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) in lpfc_online()
3733 &vports[i]->fc_flag); in lpfc_online()
3734 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_online()
3736 &vports[i]->fc_flag); in lpfc_online()
3738 (vports[i]->port_type != in lpfc_online()
3740 vports[i]->vpi = 0; in lpfc_online()
3746 if (phba->cfg_xri_rebalancing) in lpfc_online()
3756 * lpfc_unblock_mgmt_io - Mark a HBA's management interface to be not blocked
3771 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_unblock_mgmt_io()
3772 phba->sli.sli_flag &= ~LPFC_BLOCK_MGMT_IO; in lpfc_unblock_mgmt_io()
3773 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_unblock_mgmt_io()
3777 * lpfc_offline_prep - Prepare a HBA to be brought offline
3788 struct lpfc_vport *vport = phba->pport; in lpfc_offline_prep()
3796 if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) in lpfc_offline_prep()
3803 offline = pci_channel_offline(phba->pcidev); in lpfc_offline_prep()
3804 hba_pci_err = test_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_offline_prep()
3809 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_offline_prep()
3810 if (test_bit(FC_UNLOADING, &vports[i]->load_flag)) in lpfc_offline_prep()
3813 spin_lock_irq(shost->host_lock); in lpfc_offline_prep()
3814 vports[i]->vpi_state &= ~LPFC_VPI_REGISTERED; in lpfc_offline_prep()
3815 spin_unlock_irq(shost->host_lock); in lpfc_offline_prep()
3816 set_bit(FC_VPORT_NEEDS_REG_VPI, &vports[i]->fc_flag); in lpfc_offline_prep()
3817 clear_bit(FC_VFI_REGISTERED, &vports[i]->fc_flag); in lpfc_offline_prep()
3820 &vports[i]->fc_nodes, in lpfc_offline_prep()
3823 spin_lock_irq(&ndlp->lock); in lpfc_offline_prep()
3824 ndlp->nlp_flag &= ~NLP_NPR_ADISC; in lpfc_offline_prep()
3825 spin_unlock_irq(&ndlp->lock); in lpfc_offline_prep()
3828 spin_lock_irq(&ndlp->lock); in lpfc_offline_prep()
3829 ndlp->nlp_flag &= ~(NLP_UNREG_INP | in lpfc_offline_prep()
3831 spin_unlock_irq(&ndlp->lock); in lpfc_offline_prep()
3832 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_offline_prep()
3843 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_offline_prep()
3848 ndlp->nlp_rpi, ndlp, in lpfc_offline_prep()
3849 ndlp->nlp_DID); in lpfc_offline_prep()
3850 lpfc_sli4_free_rpi(phba, ndlp->nlp_rpi); in lpfc_offline_prep()
3851 ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR; in lpfc_offline_prep()
3854 if (ndlp->nlp_type & NLP_FABRIC) { in lpfc_offline_prep()
3865 if (!(ndlp->save_flags & in lpfc_offline_prep()
3867 !(ndlp->fc4_xpt_flags & in lpfc_offline_prep()
3881 if (phba->wq) in lpfc_offline_prep()
3882 flush_workqueue(phba->wq); in lpfc_offline_prep()
3886 * lpfc_offline - Bring a HBA offline
3900 if (test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_offline()
3910 lpfc_nvme_destroy_localport(phba->pport); in lpfc_offline()
3914 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) in lpfc_offline()
3922 spin_lock_irq(&phba->hbalock); in lpfc_offline()
3923 phba->work_ha = 0; in lpfc_offline()
3924 spin_unlock_irq(&phba->hbalock); in lpfc_offline()
3927 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_offline()
3929 spin_lock_irq(shost->host_lock); in lpfc_offline()
3930 vports[i]->work_port_events = 0; in lpfc_offline()
3931 spin_unlock_irq(shost->host_lock); in lpfc_offline()
3932 set_bit(FC_OFFLINE_MODE, &vports[i]->fc_flag); in lpfc_offline()
3938 if (test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_offline()
3941 if (phba->cfg_xri_rebalancing) in lpfc_offline()
3946 * lpfc_scsi_free - Free all the SCSI buffers and IOCBs from driver lists
3958 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_scsi_free()
3961 spin_lock_irq(&phba->hbalock); in lpfc_scsi_free()
3965 spin_lock(&phba->scsi_buf_list_put_lock); in lpfc_scsi_free()
3966 list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list_put, in lpfc_scsi_free()
3968 list_del(&sb->list); in lpfc_scsi_free()
3969 dma_pool_free(phba->lpfc_sg_dma_buf_pool, sb->data, in lpfc_scsi_free()
3970 sb->dma_handle); in lpfc_scsi_free()
3972 phba->total_scsi_bufs--; in lpfc_scsi_free()
3974 spin_unlock(&phba->scsi_buf_list_put_lock); in lpfc_scsi_free()
3976 spin_lock(&phba->scsi_buf_list_get_lock); in lpfc_scsi_free()
3977 list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list_get, in lpfc_scsi_free()
3979 list_del(&sb->list); in lpfc_scsi_free()
3980 dma_pool_free(phba->lpfc_sg_dma_buf_pool, sb->data, in lpfc_scsi_free()
3981 sb->dma_handle); in lpfc_scsi_free()
3983 phba->total_scsi_bufs--; in lpfc_scsi_free()
3985 spin_unlock(&phba->scsi_buf_list_get_lock); in lpfc_scsi_free()
3986 spin_unlock_irq(&phba->hbalock); in lpfc_scsi_free()
3990 * lpfc_io_free - Free all the IO buffers and IOCBs from driver lists
4004 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_free()
4005 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_free()
4007 spin_lock(&qp->io_buf_list_put_lock); in lpfc_io_free()
4009 &qp->lpfc_io_buf_list_put, in lpfc_io_free()
4011 list_del(&lpfc_ncmd->list); in lpfc_io_free()
4012 qp->put_io_bufs--; in lpfc_io_free()
4013 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_io_free()
4014 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_io_free()
4015 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_io_free()
4019 qp->total_io_bufs--; in lpfc_io_free()
4021 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_io_free()
4023 spin_lock(&qp->io_buf_list_get_lock); in lpfc_io_free()
4025 &qp->lpfc_io_buf_list_get, in lpfc_io_free()
4027 list_del(&lpfc_ncmd->list); in lpfc_io_free()
4028 qp->get_io_bufs--; in lpfc_io_free()
4029 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_io_free()
4030 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_io_free()
4031 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_io_free()
4035 qp->total_io_bufs--; in lpfc_io_free()
4037 spin_unlock(&qp->io_buf_list_get_lock); in lpfc_io_free()
4042 * lpfc_sli4_els_sgl_update - update ELS xri-sgl sizing and mapping
4051 * 0 - successful (for now, it always returns 0)
4062 * update on pci function's els xri-sgl list in lpfc_sli4_els_sgl_update()
4066 if (els_xri_cnt > phba->sli4_hba.els_xri_cnt) { in lpfc_sli4_els_sgl_update()
4067 /* els xri-sgl expanded */ in lpfc_sli4_els_sgl_update()
4068 xri_cnt = els_xri_cnt - phba->sli4_hba.els_xri_cnt; in lpfc_sli4_els_sgl_update()
4070 "3157 ELS xri-sgl count increased from " in lpfc_sli4_els_sgl_update()
4071 "%d to %d\n", phba->sli4_hba.els_xri_cnt, in lpfc_sli4_els_sgl_update()
4082 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
4085 sglq_entry->buff_type = GEN_BUFF_TYPE; in lpfc_sli4_els_sgl_update()
4086 sglq_entry->virt = lpfc_mbuf_alloc(phba, 0, in lpfc_sli4_els_sgl_update()
4087 &sglq_entry->phys); in lpfc_sli4_els_sgl_update()
4088 if (sglq_entry->virt == NULL) { in lpfc_sli4_els_sgl_update()
4094 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
4097 sglq_entry->sgl = sglq_entry->virt; in lpfc_sli4_els_sgl_update()
4098 memset(sglq_entry->sgl, 0, LPFC_BPL_SIZE); in lpfc_sli4_els_sgl_update()
4099 sglq_entry->state = SGL_FREED; in lpfc_sli4_els_sgl_update()
4100 list_add_tail(&sglq_entry->list, &els_sgl_list); in lpfc_sli4_els_sgl_update()
4102 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4104 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_sli4_els_sgl_update()
4105 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4106 } else if (els_xri_cnt < phba->sli4_hba.els_xri_cnt) { in lpfc_sli4_els_sgl_update()
4107 /* els xri-sgl shrinked */ in lpfc_sli4_els_sgl_update()
4108 xri_cnt = phba->sli4_hba.els_xri_cnt - els_xri_cnt; in lpfc_sli4_els_sgl_update()
4110 "3158 ELS xri-sgl count decreased from " in lpfc_sli4_els_sgl_update()
4111 "%d to %d\n", phba->sli4_hba.els_xri_cnt, in lpfc_sli4_els_sgl_update()
4113 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4114 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, in lpfc_sli4_els_sgl_update()
4121 __lpfc_mbuf_free(phba, sglq_entry->virt, in lpfc_sli4_els_sgl_update()
4122 sglq_entry->phys); in lpfc_sli4_els_sgl_update()
4127 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_sli4_els_sgl_update()
4128 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4131 "3163 ELS xri-sgl count unchanged: %d\n", in lpfc_sli4_els_sgl_update()
4133 phba->sli4_hba.els_xri_cnt = els_xri_cnt; in lpfc_sli4_els_sgl_update()
4139 &phba->sli4_hba.lpfc_els_sgl_list, list) { in lpfc_sli4_els_sgl_update()
4146 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
4149 sglq_entry->sli4_lxritag = lxri; in lpfc_sli4_els_sgl_update()
4150 sglq_entry->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_els_sgl_update()
4160 * lpfc_sli4_nvmet_sgl_update - update xri-sgl sizing and mapping
4169 * 0 - successful (for now, it always returns 0)
4181 * update on pci function's nvmet xri-sgl list in lpfc_sli4_nvmet_sgl_update()
4186 nvmet_xri_cnt = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4187 if (nvmet_xri_cnt > phba->sli4_hba.nvmet_xri_cnt) { in lpfc_sli4_nvmet_sgl_update()
4188 /* els xri-sgl expanded */ in lpfc_sli4_nvmet_sgl_update()
4189 xri_cnt = nvmet_xri_cnt - phba->sli4_hba.nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4191 "6302 NVMET xri-sgl cnt grew from %d to %d\n", in lpfc_sli4_nvmet_sgl_update()
4192 phba->sli4_hba.nvmet_xri_cnt, nvmet_xri_cnt); in lpfc_sli4_nvmet_sgl_update()
4202 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
4205 sglq_entry->buff_type = NVMET_BUFF_TYPE; in lpfc_sli4_nvmet_sgl_update()
4206 sglq_entry->virt = lpfc_nvmet_buf_alloc(phba, 0, in lpfc_sli4_nvmet_sgl_update()
4207 &sglq_entry->phys); in lpfc_sli4_nvmet_sgl_update()
4208 if (sglq_entry->virt == NULL) { in lpfc_sli4_nvmet_sgl_update()
4214 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
4217 sglq_entry->sgl = sglq_entry->virt; in lpfc_sli4_nvmet_sgl_update()
4218 memset(sglq_entry->sgl, 0, in lpfc_sli4_nvmet_sgl_update()
4219 phba->cfg_sg_dma_buf_size); in lpfc_sli4_nvmet_sgl_update()
4220 sglq_entry->state = SGL_FREED; in lpfc_sli4_nvmet_sgl_update()
4221 list_add_tail(&sglq_entry->list, &nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
4223 spin_lock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4224 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4226 &phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
4227 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4228 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4229 } else if (nvmet_xri_cnt < phba->sli4_hba.nvmet_xri_cnt) { in lpfc_sli4_nvmet_sgl_update()
4230 /* nvmet xri-sgl shrunk */ in lpfc_sli4_nvmet_sgl_update()
4231 xri_cnt = phba->sli4_hba.nvmet_xri_cnt - nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4233 "6305 NVMET xri-sgl count decreased from " in lpfc_sli4_nvmet_sgl_update()
4234 "%d to %d\n", phba->sli4_hba.nvmet_xri_cnt, in lpfc_sli4_nvmet_sgl_update()
4236 spin_lock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4237 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4238 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, in lpfc_sli4_nvmet_sgl_update()
4245 lpfc_nvmet_buf_free(phba, sglq_entry->virt, in lpfc_sli4_nvmet_sgl_update()
4246 sglq_entry->phys); in lpfc_sli4_nvmet_sgl_update()
4251 &phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
4252 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4253 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4256 "6306 NVMET xri-sgl count unchanged: %d\n", in lpfc_sli4_nvmet_sgl_update()
4258 phba->sli4_hba.nvmet_xri_cnt = nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4264 &phba->sli4_hba.lpfc_nvmet_sgl_list, list) { in lpfc_sli4_nvmet_sgl_update()
4271 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
4274 sglq_entry->sli4_lxritag = lxri; in lpfc_sli4_nvmet_sgl_update()
4275 sglq_entry->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_nvmet_sgl_update()
4294 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_buf_flush()
4295 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf_flush()
4296 spin_lock_irq(&qp->io_buf_list_get_lock); in lpfc_io_buf_flush()
4297 spin_lock(&qp->io_buf_list_put_lock); in lpfc_io_buf_flush()
4300 list_splice_init(&qp->lpfc_io_buf_list_get, &blist); in lpfc_io_buf_flush()
4301 list_splice(&qp->lpfc_io_buf_list_put, &blist); in lpfc_io_buf_flush()
4302 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_io_buf_flush()
4303 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_io_buf_flush()
4304 cnt += qp->get_io_bufs + qp->put_io_bufs; in lpfc_io_buf_flush()
4305 qp->get_io_bufs = 0; in lpfc_io_buf_flush()
4306 qp->put_io_bufs = 0; in lpfc_io_buf_flush()
4307 qp->total_io_bufs = 0; in lpfc_io_buf_flush()
4308 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_io_buf_flush()
4309 spin_unlock_irq(&qp->io_buf_list_get_lock); in lpfc_io_buf_flush()
4322 list_add_tail(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4325 xri = lpfc_cmd->cur_iocbq.sli4_xritag; in lpfc_io_buf_flush()
4329 if (xri < iobufp->cur_iocbq.sli4_xritag) { in lpfc_io_buf_flush()
4331 list_add(&lpfc_cmd->list, in lpfc_io_buf_flush()
4332 &prev_iobufp->list); in lpfc_io_buf_flush()
4334 list_add(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4341 list_add_tail(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4354 qp = phba->sli4_hba.hdwq; in lpfc_io_buf_replenish()
4357 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_buf_replenish()
4363 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf_replenish()
4364 lpfc_cmd->hdwq_no = idx; in lpfc_io_buf_replenish()
4365 lpfc_cmd->hdwq = qp; in lpfc_io_buf_replenish()
4366 lpfc_cmd->cur_iocbq.cmd_cmpl = NULL; in lpfc_io_buf_replenish()
4367 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflags); in lpfc_io_buf_replenish()
4368 list_add_tail(&lpfc_cmd->list, in lpfc_io_buf_replenish()
4369 &qp->lpfc_io_buf_list_put); in lpfc_io_buf_replenish()
4370 qp->put_io_bufs++; in lpfc_io_buf_replenish()
4371 qp->total_io_bufs++; in lpfc_io_buf_replenish()
4372 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, in lpfc_io_buf_replenish()
4380 * lpfc_sli4_io_sgl_update - update xri-sgl sizing and mapping
4389 * 0 - successful (for now, it always returns 0)
4401 * update on pci function's allocated nvme xri-sgl list in lpfc_sli4_io_sgl_update()
4406 io_xri_max = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt; in lpfc_sli4_io_sgl_update()
4407 phba->sli4_hba.io_xri_max = io_xri_max; in lpfc_sli4_io_sgl_update()
4412 phba->sli4_hba.io_xri_cnt, in lpfc_sli4_io_sgl_update()
4413 phba->sli4_hba.io_xri_max, in lpfc_sli4_io_sgl_update()
4418 if (phba->sli4_hba.io_xri_cnt > phba->sli4_hba.io_xri_max) { in lpfc_sli4_io_sgl_update()
4420 io_xri_cnt = phba->sli4_hba.io_xri_cnt - in lpfc_sli4_io_sgl_update()
4421 phba->sli4_hba.io_xri_max; in lpfc_sli4_io_sgl_update()
4427 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_sli4_io_sgl_update()
4428 lpfc_ncmd->data, in lpfc_sli4_io_sgl_update()
4429 lpfc_ncmd->dma_handle); in lpfc_sli4_io_sgl_update()
4433 phba->sli4_hba.io_xri_cnt -= io_xri_cnt; in lpfc_sli4_io_sgl_update()
4439 phba->sli4_hba.io_xri_cnt = cnt; in lpfc_sli4_io_sgl_update()
4448 rc = -ENOMEM; in lpfc_sli4_io_sgl_update()
4451 lpfc_ncmd->cur_iocbq.sli4_lxritag = lxri; in lpfc_sli4_io_sgl_update()
4452 lpfc_ncmd->cur_iocbq.sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_io_sgl_update()
4463 * lpfc_new_io_buf - IO buffer allocator for HBA with SLI4 IF spec
4467 * This routine allocates nvme buffers for device with SLI-4 interface spec,
4473 * int - number of IO buffers that were allocated and posted.
4487 phba->sli4_hba.io_xri_cnt = 0; in lpfc_new_io_buf()
4497 lpfc_ncmd->data = dma_pool_zalloc(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4499 &lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4500 if (!lpfc_ncmd->data) { in lpfc_new_io_buf()
4505 if (phba->cfg_xpsgl && !phba->nvmet_support) { in lpfc_new_io_buf()
4506 INIT_LIST_HEAD(&lpfc_ncmd->dma_sgl_xtra_list); in lpfc_new_io_buf()
4512 if ((phba->sli3_options & LPFC_SLI3_BG_ENABLED) && in lpfc_new_io_buf()
4513 (((unsigned long)(lpfc_ncmd->data) & in lpfc_new_io_buf()
4514 (unsigned long)(SLI4_PAGE_SIZE - 1)) != 0)) { in lpfc_new_io_buf()
4519 (unsigned long)lpfc_ncmd->data); in lpfc_new_io_buf()
4520 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4521 lpfc_ncmd->data, in lpfc_new_io_buf()
4522 lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4528 INIT_LIST_HEAD(&lpfc_ncmd->dma_cmd_rsp_list); in lpfc_new_io_buf()
4532 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4533 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4537 pwqeq = &lpfc_ncmd->cur_iocbq; in lpfc_new_io_buf()
4539 /* Allocate iotag for lpfc_ncmd->cur_iocbq. */ in lpfc_new_io_buf()
4542 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4543 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4551 pwqeq->sli4_lxritag = lxri; in lpfc_new_io_buf()
4552 pwqeq->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_new_io_buf()
4554 /* Initialize local short-hand pointers. */ in lpfc_new_io_buf()
4555 lpfc_ncmd->dma_sgl = lpfc_ncmd->data; in lpfc_new_io_buf()
4556 lpfc_ncmd->dma_phys_sgl = lpfc_ncmd->dma_handle; in lpfc_new_io_buf()
4557 lpfc_ncmd->cur_iocbq.io_buf = lpfc_ncmd; in lpfc_new_io_buf()
4558 spin_lock_init(&lpfc_ncmd->buf_lock); in lpfc_new_io_buf()
4561 list_add_tail(&lpfc_ncmd->list, &post_nblist); in lpfc_new_io_buf()
4562 phba->sli4_hba.io_xri_cnt++; in lpfc_new_io_buf()
4588 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_get_wwpn()
4591 return (uint64_t)-1; in lpfc_get_wwpn()
4600 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_get_wwpn()
4601 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_get_wwpn()
4602 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_get_wwpn()
4603 return (uint64_t) -1; in lpfc_get_wwpn()
4605 mb = &mboxq->u.mb; in lpfc_get_wwpn()
4606 memcpy(&wwn, (char *)mb->un.varRDnvp.portname, sizeof(uint64_t)); in lpfc_get_wwpn()
4608 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_get_wwpn()
4609 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_get_wwpn()
4617 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_get_sg_tablesize()
4618 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_get_sg_tablesize()
4621 return phba->cfg_scsi_seg_cnt; in lpfc_get_sg_tablesize()
4623 return phba->cfg_sg_seg_cnt; in lpfc_get_sg_tablesize()
4627 * lpfc_vmid_res_alloc - Allocates resources for VMID
4635 * Non-0 on Failure
4641 if (phba->sli_rev == LPFC_SLI_REV3) { in lpfc_vmid_res_alloc()
4642 phba->cfg_vmid_app_header = 0; in lpfc_vmid_res_alloc()
4643 phba->cfg_vmid_priority_tagging = 0; in lpfc_vmid_res_alloc()
4647 vport->vmid = in lpfc_vmid_res_alloc()
4648 kcalloc(phba->cfg_max_vmid, sizeof(struct lpfc_vmid), in lpfc_vmid_res_alloc()
4650 if (!vport->vmid) in lpfc_vmid_res_alloc()
4651 return -ENOMEM; in lpfc_vmid_res_alloc()
4653 rwlock_init(&vport->vmid_lock); in lpfc_vmid_res_alloc()
4656 vport->vmid_priority_tagging = phba->cfg_vmid_priority_tagging; in lpfc_vmid_res_alloc()
4657 vport->vmid_inactivity_timeout = in lpfc_vmid_res_alloc()
4658 phba->cfg_vmid_inactivity_timeout; in lpfc_vmid_res_alloc()
4659 vport->max_vmid = phba->cfg_max_vmid; in lpfc_vmid_res_alloc()
4660 vport->cur_vmid_cnt = 0; in lpfc_vmid_res_alloc()
4662 vport->vmid_priority_range = bitmap_zalloc in lpfc_vmid_res_alloc()
4665 if (!vport->vmid_priority_range) { in lpfc_vmid_res_alloc()
4666 kfree(vport->vmid); in lpfc_vmid_res_alloc()
4667 return -ENOMEM; in lpfc_vmid_res_alloc()
4670 hash_init(vport->hash_table); in lpfc_vmid_res_alloc()
4676 * lpfc_create_port - Create an FC port
4688 * @vport - pointer to the virtual N_Port data structure.
4689 * NULL - port create failed.
4705 if (phba->sli_rev < LPFC_SLI_REV4 && in lpfc_create_port()
4706 dev == &phba->pcidev->dev) { in lpfc_create_port()
4728 if (dev == &phba->pcidev->dev) { in lpfc_create_port()
4729 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { in lpfc_create_port()
4734 /* template is for a no reset SCSI Host */ in lpfc_create_port()
4735 template->eh_host_reset_handler = NULL; in lpfc_create_port()
4738 template->sg_tablesize = lpfc_get_sg_tablesize(phba); in lpfc_create_port()
4748 template->sg_tablesize = lpfc_get_sg_tablesize(phba); in lpfc_create_port()
4755 vport = (struct lpfc_vport *) shost->hostdata; in lpfc_create_port()
4756 vport->phba = phba; in lpfc_create_port()
4757 set_bit(FC_LOADING, &vport->load_flag); in lpfc_create_port()
4758 set_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); in lpfc_create_port()
4759 vport->fc_rscn_flush = 0; in lpfc_create_port()
4760 atomic_set(&vport->fc_plogi_cnt, 0); in lpfc_create_port()
4761 atomic_set(&vport->fc_adisc_cnt, 0); in lpfc_create_port()
4762 atomic_set(&vport->fc_reglogin_cnt, 0); in lpfc_create_port()
4763 atomic_set(&vport->fc_prli_cnt, 0); in lpfc_create_port()
4764 atomic_set(&vport->fc_unmap_cnt, 0); in lpfc_create_port()
4765 atomic_set(&vport->fc_map_cnt, 0); in lpfc_create_port()
4766 atomic_set(&vport->fc_npr_cnt, 0); in lpfc_create_port()
4767 atomic_set(&vport->fc_unused_cnt, 0); in lpfc_create_port()
4771 vport->cfg_enable_fc4_type = phba->cfg_enable_fc4_type; in lpfc_create_port()
4773 shost->unique_id = instance; in lpfc_create_port()
4774 shost->max_id = LPFC_MAX_TARGET; in lpfc_create_port()
4775 shost->max_lun = vport->cfg_max_luns; in lpfc_create_port()
4776 shost->this_id = -1; in lpfc_create_port()
4779 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_create_port()
4781 &phba->sli4_hba.sli_intf); in lpfc_create_port()
4786 shost->max_cmd_len = LPFC_FCP_CDB_LEN_32; in lpfc_create_port()
4789 shost->max_cmd_len = LPFC_FCP_CDB_LEN; in lpfc_create_port()
4793 shost->max_cmd_len = LPFC_FCP_CDB_LEN; in lpfc_create_port()
4796 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_create_port()
4797 if (!phba->cfg_fcp_mq_threshold || in lpfc_create_port()
4798 phba->cfg_fcp_mq_threshold > phba->cfg_hdw_queue) in lpfc_create_port()
4799 phba->cfg_fcp_mq_threshold = phba->cfg_hdw_queue; in lpfc_create_port()
4801 shost->nr_hw_queues = min_t(int, 2 * num_possible_nodes(), in lpfc_create_port()
4802 phba->cfg_fcp_mq_threshold); in lpfc_create_port()
4804 shost->dma_boundary = in lpfc_create_port()
4805 phba->sli4_hba.pc_sli4_params.sge_supp_len-1; in lpfc_create_port()
4807 /* SLI-3 has a limited number of hardware queues (3), in lpfc_create_port()
4810 shost->nr_hw_queues = 1; in lpfc_create_port()
4813 * Set initial can_queue value since 0 is no longer supported and in lpfc_create_port()
4817 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_create_port()
4818 if (dev != &phba->pcidev->dev) { in lpfc_create_port()
4819 shost->transportt = lpfc_vport_transport_template; in lpfc_create_port()
4820 vport->port_type = LPFC_NPIV_PORT; in lpfc_create_port()
4822 shost->transportt = lpfc_transport_template; in lpfc_create_port()
4823 vport->port_type = LPFC_PHYSICAL_PORT; in lpfc_create_port()
4829 vport->port_type, shost->sg_tablesize, in lpfc_create_port()
4830 phba->cfg_scsi_seg_cnt, phba->cfg_sg_seg_cnt); in lpfc_create_port()
4839 INIT_LIST_HEAD(&vport->fc_nodes); in lpfc_create_port()
4840 spin_lock_init(&vport->fc_nodes_list_lock); in lpfc_create_port()
4841 INIT_LIST_HEAD(&vport->rcv_buffer_list); in lpfc_create_port()
4842 spin_lock_init(&vport->work_port_lock); in lpfc_create_port()
4844 timer_setup(&vport->fc_disctmo, lpfc_disc_timeout, 0); in lpfc_create_port()
4846 timer_setup(&vport->els_tmofunc, lpfc_els_timeout, 0); in lpfc_create_port()
4848 timer_setup(&vport->delayed_disc_tmo, lpfc_delayed_disc_tmo, 0); in lpfc_create_port()
4850 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) in lpfc_create_port()
4853 error = scsi_add_host_with_dma(shost, dev, &phba->pcidev->dev); in lpfc_create_port()
4857 spin_lock_irq(&phba->port_list_lock); in lpfc_create_port()
4858 list_add_tail(&vport->listentry, &phba->port_list); in lpfc_create_port()
4859 spin_unlock_irq(&phba->port_list_lock); in lpfc_create_port()
4863 kfree(vport->vmid); in lpfc_create_port()
4864 bitmap_free(vport->vmid_priority_range); in lpfc_create_port()
4872 * destroy_port - destroy an FC port
4882 struct lpfc_hba *phba = vport->phba; in destroy_port()
4888 spin_lock_irq(&phba->port_list_lock); in destroy_port()
4889 list_del_init(&vport->listentry); in destroy_port()
4890 spin_unlock_irq(&phba->port_list_lock); in destroy_port()
4897 * lpfc_get_instance - Get a unique integer ID
4903 * instance - a unique integer ID allocated as the new instance.
4904 * -1 - lpfc get instance failed.
4912 return ret < 0 ? -1 : ret; in lpfc_get_instance()
4916 * lpfc_scan_finished - method for SCSI layer to detect whether scan is done
4923 * Note: there is no scan_start function as adapter initialization will have
4927 * 0 - SCSI host scan is not over yet.
4928 * 1 - SCSI host scan is over.
4932 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_scan_finished()
4933 struct lpfc_hba *phba = vport->phba; in lpfc_scan_finished()
4936 spin_lock_irq(shost->host_lock); in lpfc_scan_finished()
4938 if (test_bit(FC_UNLOADING, &vport->load_flag)) { in lpfc_scan_finished()
4950 phba->link_state <= LPFC_LINK_DOWN) { in lpfc_scan_finished()
4958 if (vport->port_state != LPFC_VPORT_READY) in lpfc_scan_finished()
4960 if (vport->num_disc_nodes || vport->fc_prli_sent) in lpfc_scan_finished()
4962 if (!atomic_read(&vport->fc_map_cnt) && in lpfc_scan_finished()
4965 if ((phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) != 0) in lpfc_scan_finished()
4971 spin_unlock_irq(shost->host_lock); in lpfc_scan_finished()
4977 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; in lpfc_host_supported_speeds_set()
4978 struct lpfc_hba *phba = vport->phba; in lpfc_host_supported_speeds_set()
4985 if (test_bit(HBA_FCOE_MODE, &phba->hba_flag)) in lpfc_host_supported_speeds_set()
4988 if (phba->lmt & LMT_256Gb) in lpfc_host_supported_speeds_set()
4990 if (phba->lmt & LMT_128Gb) in lpfc_host_supported_speeds_set()
4992 if (phba->lmt & LMT_64Gb) in lpfc_host_supported_speeds_set()
4994 if (phba->lmt & LMT_32Gb) in lpfc_host_supported_speeds_set()
4996 if (phba->lmt & LMT_16Gb) in lpfc_host_supported_speeds_set()
4998 if (phba->lmt & LMT_10Gb) in lpfc_host_supported_speeds_set()
5000 if (phba->lmt & LMT_8Gb) in lpfc_host_supported_speeds_set()
5002 if (phba->lmt & LMT_4Gb) in lpfc_host_supported_speeds_set()
5004 if (phba->lmt & LMT_2Gb) in lpfc_host_supported_speeds_set()
5006 if (phba->lmt & LMT_1Gb) in lpfc_host_supported_speeds_set()
5011 * lpfc_host_attrib_init - Initialize SCSI host attributes on a FC port
5019 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_host_attrib_init()
5020 struct lpfc_hba *phba = vport->phba; in lpfc_host_attrib_init()
5025 fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); in lpfc_host_attrib_init()
5026 fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); in lpfc_host_attrib_init()
5040 (((uint32_t) vport->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) | in lpfc_host_attrib_init()
5041 (uint32_t) vport->fc_sparam.cmn.bbRcvSizeLsb; in lpfc_host_attrib_init()
5043 fc_host_dev_loss_tmo(shost) = vport->cfg_devloss_tmo; in lpfc_host_attrib_init()
5051 fc_host_max_npiv_vports(shost) = phba->max_vpi; in lpfc_host_attrib_init()
5052 clear_bit(FC_LOADING, &vport->load_flag); in lpfc_host_attrib_init()
5056 * lpfc_stop_port_s3 - Stop SLI3 device port
5067 writel(0, phba->HCregaddr); in lpfc_stop_port_s3()
5068 readl(phba->HCregaddr); /* flush */ in lpfc_stop_port_s3()
5070 writel(0xffffffff, phba->HAregaddr); in lpfc_stop_port_s3()
5071 readl(phba->HAregaddr); /* flush */ in lpfc_stop_port_s3()
5075 phba->pport->work_port_events = 0; in lpfc_stop_port_s3()
5079 * lpfc_stop_port_s4 - Stop SLI4 device port
5091 if (phba->pport) in lpfc_stop_port_s4()
5092 phba->pport->work_port_events = 0; in lpfc_stop_port_s4()
5093 phba->sli4_hba.intr_enable = 0; in lpfc_stop_port_s4()
5097 * lpfc_stop_port - Wrapper function for stopping hba port
5106 phba->lpfc_stop_port(phba); in lpfc_stop_port()
5108 if (phba->wq) in lpfc_stop_port()
5109 flush_workqueue(phba->wq); in lpfc_stop_port()
5113 * lpfc_fcf_redisc_wait_start_timer - Start fcf rediscover wait timer
5124 mod_timer(&phba->fcf.redisc_wait, fcf_redisc_wait_tmo); in lpfc_fcf_redisc_wait_start_timer()
5125 spin_lock_irq(&phba->hbalock); in lpfc_fcf_redisc_wait_start_timer()
5127 phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_SCAN_DONE); in lpfc_fcf_redisc_wait_start_timer()
5129 phba->fcf.fcf_flag |= FCF_REDISC_PEND; in lpfc_fcf_redisc_wait_start_timer()
5130 spin_unlock_irq(&phba->hbalock); in lpfc_fcf_redisc_wait_start_timer()
5134 * lpfc_sli4_fcf_redisc_wait_tmo - FCF table rediscover wait timeout
5149 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
5150 if (!(phba->fcf.fcf_flag & FCF_REDISC_PEND)) { in lpfc_sli4_fcf_redisc_wait_tmo()
5151 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
5155 phba->fcf.fcf_flag &= ~FCF_REDISC_PEND; in lpfc_sli4_fcf_redisc_wait_tmo()
5157 phba->fcf.fcf_flag |= FCF_REDISC_EVT; in lpfc_sli4_fcf_redisc_wait_tmo()
5158 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
5166 * lpfc_vmid_poll - VMID timeout detection
5169 * This routine is invoked when there is no I/O on by a VM for the specified
5181 if (phba->pport->vmid_priority_tagging) { in lpfc_vmid_poll()
5183 phba->pport->work_port_events |= WORKER_CHECK_VMID_ISSUE_QFPA; in lpfc_vmid_poll()
5187 if (phba->pport->vmid_inactivity_timeout || in lpfc_vmid_poll()
5188 test_bit(FC_DEREGISTER_ALL_APP_ID, &phba->pport->load_flag)) { in lpfc_vmid_poll()
5190 phba->pport->work_port_events |= WORKER_CHECK_INACTIVE_VMID; in lpfc_vmid_poll()
5197 mod_timer(&phba->inactive_vmid_poll, jiffies + msecs_to_jiffies(1000 * in lpfc_vmid_poll()
5202 * lpfc_sli4_parse_latt_fault - Parse sli4 link-attention link fault code
5206 * This routine is to parse the SLI4 link-attention link fault code.
5236 * lpfc_sli4_parse_latt_type - Parse sli4 link attention type
5257 /* Ignore physical link up events - wait for logical link up */ in lpfc_sli4_parse_latt_type()
5274 * lpfc_sli_port_speed_get - Get sli3 link speed code to link speed
5289 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_sli_port_speed_get()
5290 switch (phba->fc_linkspeed) { in lpfc_sli_port_speed_get()
5313 if (phba->sli4_hba.link_state.logical_speed) in lpfc_sli_port_speed_get()
5315 phba->sli4_hba.link_state.logical_speed; in lpfc_sli_port_speed_get()
5317 link_speed = phba->sli4_hba.link_state.speed; in lpfc_sli_port_speed_get()
5323 * lpfc_sli4_port_speed_parse - Parse async evt link speed code to link speed
5419 * lpfc_sli4_async_link_evt - Process the asynchronous FCoE link event
5438 phba->fcoe_eventtag = acqe_link->event_tag; in lpfc_sli4_async_link_evt()
5439 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_async_link_evt()
5457 phba->sli4_hba.els_wq->pring->flag |= LPFC_STOP_IOCB_EVENT; in lpfc_sli4_async_link_evt()
5460 phba->sli.slistat.link_event++; in lpfc_sli4_async_link_evt()
5463 lpfc_read_topology(phba, pmb, pmb->ctx_buf); in lpfc_sli4_async_link_evt()
5464 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_sli4_async_link_evt()
5465 pmb->vport = phba->pport; in lpfc_sli4_async_link_evt()
5468 phba->sli4_hba.link_state.speed = in lpfc_sli4_async_link_evt()
5471 phba->sli4_hba.link_state.duplex = in lpfc_sli4_async_link_evt()
5473 phba->sli4_hba.link_state.status = in lpfc_sli4_async_link_evt()
5475 phba->sli4_hba.link_state.type = in lpfc_sli4_async_link_evt()
5477 phba->sli4_hba.link_state.number = in lpfc_sli4_async_link_evt()
5479 phba->sli4_hba.link_state.fault = in lpfc_sli4_async_link_evt()
5481 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_link_evt()
5485 "2900 Async FC/FCoE Link event - Speed:%dGBit " in lpfc_sli4_async_link_evt()
5488 phba->sli4_hba.link_state.speed, in lpfc_sli4_async_link_evt()
5489 phba->sli4_hba.link_state.topology, in lpfc_sli4_async_link_evt()
5490 phba->sli4_hba.link_state.status, in lpfc_sli4_async_link_evt()
5491 phba->sli4_hba.link_state.type, in lpfc_sli4_async_link_evt()
5492 phba->sli4_hba.link_state.number, in lpfc_sli4_async_link_evt()
5493 phba->sli4_hba.link_state.logical_speed, in lpfc_sli4_async_link_evt()
5494 phba->sli4_hba.link_state.fault); in lpfc_sli4_async_link_evt()
5497 * topology info. Note: Optional for non FC-AL ports. in lpfc_sli4_async_link_evt()
5499 if (!test_bit(HBA_FCOE_MODE, &phba->hba_flag)) { in lpfc_sli4_async_link_evt()
5511 mb = &pmb->u.mb; in lpfc_sli4_async_link_evt()
5512 mb->mbxStatus = MBX_SUCCESS; in lpfc_sli4_async_link_evt()
5518 la = (struct lpfc_mbx_read_top *) &pmb->u.mb.un.varReadTop; in lpfc_sli4_async_link_evt()
5519 la->eventTag = acqe_link->event_tag; in lpfc_sli4_async_link_evt()
5542 * lpfc_async_link_speed_to_read_top - Parse async evt link speed code to read
5596 if (!phba->rx_monitor) { in lpfc_cgn_dump_rxmonitor()
5600 lpfc_rx_monitor_report(phba, phba->rx_monitor, NULL, 0, in lpfc_cgn_dump_rxmonitor()
5606 * lpfc_cgn_update_stat - Save data into congestion stats buffer
5619 if (!phba->cgn_i) in lpfc_cgn_update_stat()
5621 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_cgn_update_stat()
5626 le32_add_cpu(&cp->link_integ_notification, 1); in lpfc_cgn_update_stat()
5627 lpfc_cgn_update_tstamp(phba, &cp->stat_lnk); in lpfc_cgn_update_stat()
5630 le32_add_cpu(&cp->delivery_notification, 1); in lpfc_cgn_update_stat()
5631 lpfc_cgn_update_tstamp(phba, &cp->stat_delivery); in lpfc_cgn_update_stat()
5634 le32_add_cpu(&cp->cgn_peer_notification, 1); in lpfc_cgn_update_stat()
5635 lpfc_cgn_update_tstamp(phba, &cp->stat_peer); in lpfc_cgn_update_stat()
5638 le32_add_cpu(&cp->cgn_notification, 1); in lpfc_cgn_update_stat()
5639 lpfc_cgn_update_tstamp(phba, &cp->stat_fpin); in lpfc_cgn_update_stat()
5641 if (phba->cgn_fpin_frequency && in lpfc_cgn_update_stat()
5642 phba->cgn_fpin_frequency != LPFC_FPIN_INIT_FREQ) { in lpfc_cgn_update_stat()
5643 value = LPFC_CGN_TIMER_TO_MIN / phba->cgn_fpin_frequency; in lpfc_cgn_update_stat()
5644 cp->cgn_stat_npm = value; in lpfc_cgn_update_stat()
5649 cp->cgn_info_crc = cpu_to_le32(value); in lpfc_cgn_update_stat()
5653 * lpfc_cgn_update_tstamp - Update cmf timestamp
5666 ts->month = tm_val.tm_mon + 1; in lpfc_cgn_update_tstamp()
5667 ts->day = tm_val.tm_mday; in lpfc_cgn_update_tstamp()
5668 ts->year = tm_val.tm_year - 100; in lpfc_cgn_update_tstamp()
5669 ts->hour = tm_val.tm_hour; in lpfc_cgn_update_tstamp()
5670 ts->minute = tm_val.tm_min; in lpfc_cgn_update_tstamp()
5671 ts->second = tm_val.tm_sec; in lpfc_cgn_update_tstamp()
5676 ts->day, ts->month, in lpfc_cgn_update_tstamp()
5677 ts->year, ts->hour, in lpfc_cgn_update_tstamp()
5678 ts->minute, ts->second); in lpfc_cgn_update_tstamp()
5682 * lpfc_cmf_stats_timer - Save data into registered congestion buffer
5708 if (!phba->cgn_i) in lpfc_cmf_stats_timer()
5710 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_cmf_stats_timer()
5712 phba->cgn_evt_timestamp = jiffies + in lpfc_cmf_stats_timer()
5714 phba->cgn_evt_minute++; in lpfc_cmf_stats_timer()
5717 lpfc_cgn_update_tstamp(phba, &cp->base_time); in lpfc_cmf_stats_timer()
5719 if (phba->cgn_fpin_frequency && in lpfc_cmf_stats_timer()
5720 phba->cgn_fpin_frequency != LPFC_FPIN_INIT_FREQ) { in lpfc_cmf_stats_timer()
5721 value = LPFC_CGN_TIMER_TO_MIN / phba->cgn_fpin_frequency; in lpfc_cmf_stats_timer()
5722 cp->cgn_stat_npm = value; in lpfc_cmf_stats_timer()
5726 lvalue = atomic_read(&phba->cgn_latency_evt_cnt); in lpfc_cmf_stats_timer()
5727 latsum = atomic64_read(&phba->cgn_latency_evt); in lpfc_cmf_stats_timer()
5728 atomic_set(&phba->cgn_latency_evt_cnt, 0); in lpfc_cmf_stats_timer()
5729 atomic64_set(&phba->cgn_latency_evt, 0); in lpfc_cmf_stats_timer()
5735 bps = div_u64(phba->rx_block_cnt, LPFC_SEC_MIN) * 512; in lpfc_cmf_stats_timer()
5736 phba->rx_block_cnt = 0; in lpfc_cmf_stats_timer()
5741 cp->cgn_info_mode = phba->cgn_p.cgn_param_mode; in lpfc_cmf_stats_timer()
5742 cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0; in lpfc_cmf_stats_timer()
5743 cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1; in lpfc_cmf_stats_timer()
5744 cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2; in lpfc_cmf_stats_timer()
5747 value = (uint16_t)(phba->pport->cfg_lun_queue_depth); in lpfc_cmf_stats_timer()
5748 cp->cgn_lunq = cpu_to_le16(value); in lpfc_cmf_stats_timer()
5750 /* Record congestion buffer info - every minute in lpfc_cmf_stats_timer()
5756 index = ++cp->cgn_index_minute; in lpfc_cmf_stats_timer()
5757 if (cp->cgn_index_minute == LPFC_MIN_HOUR) { in lpfc_cmf_stats_timer()
5758 cp->cgn_index_minute = 0; in lpfc_cmf_stats_timer()
5763 dvalue = atomic_read(&phba->cgn_driver_evt_cnt); in lpfc_cmf_stats_timer()
5764 atomic_set(&phba->cgn_driver_evt_cnt, 0); in lpfc_cmf_stats_timer()
5766 /* Get the number of warning events - FPIN and Signal for this minute */ in lpfc_cmf_stats_timer()
5768 if ((phba->cgn_reg_fpin & LPFC_CGN_FPIN_WARN) || in lpfc_cmf_stats_timer()
5769 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY || in lpfc_cmf_stats_timer()
5770 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) in lpfc_cmf_stats_timer()
5771 wvalue = atomic_read(&phba->cgn_fabric_warn_cnt); in lpfc_cmf_stats_timer()
5772 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_cmf_stats_timer()
5774 /* Get the number of alarm events - FPIN and Signal for this minute */ in lpfc_cmf_stats_timer()
5776 if ((phba->cgn_reg_fpin & LPFC_CGN_FPIN_ALARM) || in lpfc_cmf_stats_timer()
5777 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) in lpfc_cmf_stats_timer()
5778 avalue = atomic_read(&phba->cgn_fabric_alarm_cnt); in lpfc_cmf_stats_timer()
5779 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_cmf_stats_timer()
5784 ptr = &cp->cgn_drvr_min[index]; in lpfc_cmf_stats_timer()
5788 ptr = &cp->cgn_warn_min[index]; in lpfc_cmf_stats_timer()
5792 ptr = &cp->cgn_alarm_min[index]; in lpfc_cmf_stats_timer()
5796 lptr = &cp->cgn_latency_min[index]; in lpfc_cmf_stats_timer()
5805 mptr = &cp->cgn_bw_min[index]; in lpfc_cmf_stats_timer()
5809 "2418 Congestion Info - minute (%d): %d %d %d %d %d\n", in lpfc_cmf_stats_timer()
5813 if ((phba->cgn_evt_minute % LPFC_MIN_HOUR) == 0) { in lpfc_cmf_stats_timer()
5814 /* Record congestion buffer info - every hour in lpfc_cmf_stats_timer()
5817 index = ++cp->cgn_index_hour; in lpfc_cmf_stats_timer()
5818 if (cp->cgn_index_hour == LPFC_HOUR_DAY) { in lpfc_cmf_stats_timer()
5819 cp->cgn_index_hour = 0; in lpfc_cmf_stats_timer()
5830 dvalue += le16_to_cpu(cp->cgn_drvr_min[i]); in lpfc_cmf_stats_timer()
5831 wvalue += le16_to_cpu(cp->cgn_warn_min[i]); in lpfc_cmf_stats_timer()
5832 lvalue += le32_to_cpu(cp->cgn_latency_min[i]); in lpfc_cmf_stats_timer()
5833 mbps += le16_to_cpu(cp->cgn_bw_min[i]); in lpfc_cmf_stats_timer()
5834 avalue += le16_to_cpu(cp->cgn_alarm_min[i]); in lpfc_cmf_stats_timer()
5841 lptr = &cp->cgn_drvr_hr[index]; in lpfc_cmf_stats_timer()
5843 lptr = &cp->cgn_warn_hr[index]; in lpfc_cmf_stats_timer()
5845 lptr = &cp->cgn_latency_hr[index]; in lpfc_cmf_stats_timer()
5847 mptr = &cp->cgn_bw_hr[index]; in lpfc_cmf_stats_timer()
5849 lptr = &cp->cgn_alarm_hr[index]; in lpfc_cmf_stats_timer()
5853 "2419 Congestion Info - hour " in lpfc_cmf_stats_timer()
5859 if ((phba->cgn_evt_minute % LPFC_MIN_DAY) == 0) { in lpfc_cmf_stats_timer()
5860 /* Record congestion buffer info - every hour in lpfc_cmf_stats_timer()
5864 index = ++cp->cgn_index_day; in lpfc_cmf_stats_timer()
5865 if (cp->cgn_index_day == LPFC_MAX_CGN_DAYS) { in lpfc_cmf_stats_timer()
5866 cp->cgn_index_day = 0; in lpfc_cmf_stats_timer()
5877 dvalue += le32_to_cpu(cp->cgn_drvr_hr[i]); in lpfc_cmf_stats_timer()
5878 wvalue += le32_to_cpu(cp->cgn_warn_hr[i]); in lpfc_cmf_stats_timer()
5879 lvalue += le32_to_cpu(cp->cgn_latency_hr[i]); in lpfc_cmf_stats_timer()
5880 mbps += le16_to_cpu(cp->cgn_bw_hr[i]); in lpfc_cmf_stats_timer()
5881 avalue += le32_to_cpu(cp->cgn_alarm_hr[i]); in lpfc_cmf_stats_timer()
5888 lptr = &cp->cgn_drvr_day[index]; in lpfc_cmf_stats_timer()
5890 lptr = &cp->cgn_warn_day[index]; in lpfc_cmf_stats_timer()
5892 lptr = &cp->cgn_latency_day[index]; in lpfc_cmf_stats_timer()
5894 mptr = &cp->cgn_bw_day[index]; in lpfc_cmf_stats_timer()
5896 lptr = &cp->cgn_alarm_day[index]; in lpfc_cmf_stats_timer()
5900 "2420 Congestion Info - daily (%d): " in lpfc_cmf_stats_timer()
5906 value = phba->cgn_fpin_frequency; in lpfc_cmf_stats_timer()
5907 cp->cgn_warn_freq = cpu_to_le16(value); in lpfc_cmf_stats_timer()
5908 cp->cgn_alarm_freq = cpu_to_le16(value); in lpfc_cmf_stats_timer()
5912 cp->cgn_info_crc = cpu_to_le32(lvalue); in lpfc_cmf_stats_timer()
5920 * lpfc_calc_cmf_latency - latency from start of rxate timer interval
5938 if (cmpl_time.tv_sec == phba->cmf_latency.tv_sec) { in lpfc_calc_cmf_latency()
5939 msec = (cmpl_time.tv_nsec - phba->cmf_latency.tv_nsec) / in lpfc_calc_cmf_latency()
5942 if (cmpl_time.tv_nsec >= phba->cmf_latency.tv_nsec) { in lpfc_calc_cmf_latency()
5943 msec = (cmpl_time.tv_sec - in lpfc_calc_cmf_latency()
5944 phba->cmf_latency.tv_sec) * MSEC_PER_SEC; in lpfc_calc_cmf_latency()
5945 msec += ((cmpl_time.tv_nsec - in lpfc_calc_cmf_latency()
5946 phba->cmf_latency.tv_nsec) / NSEC_PER_MSEC); in lpfc_calc_cmf_latency()
5948 msec = (cmpl_time.tv_sec - phba->cmf_latency.tv_sec - in lpfc_calc_cmf_latency()
5950 msec += (((NSEC_PER_SEC - phba->cmf_latency.tv_nsec) + in lpfc_calc_cmf_latency()
5958 * lpfc_cmf_timer - This is the timer function for one congestion
5977 if (phba->cmf_active_mode == LPFC_CFG_OFF || in lpfc_cmf_timer()
5978 !phba->cmf_latency.tv_sec) { in lpfc_cmf_timer()
5981 phba->cmf_active_mode, in lpfc_cmf_timer()
5982 (uint64_t)phba->cmf_latency.tv_sec); in lpfc_cmf_timer()
5989 if (!phba->pport) in lpfc_cmf_timer()
5995 atomic_set(&phba->cmf_stop_io, 1); in lpfc_cmf_timer()
6009 ktime_get_real_ts64(&phba->cmf_latency); in lpfc_cmf_timer()
6011 phba->cmf_link_byte_count = in lpfc_cmf_timer()
6012 div_u64(phba->cmf_max_line_rate * LPFC_CMF_INTERVAL, 1000); in lpfc_cmf_timer()
6020 cgs = per_cpu_ptr(phba->cmf_stat, cpu); in lpfc_cmf_timer()
6021 total += atomic64_xchg(&cgs->total_bytes, 0); in lpfc_cmf_timer()
6022 io_cnt += atomic_xchg(&cgs->rx_io_cnt, 0); in lpfc_cmf_timer()
6023 lat += atomic64_xchg(&cgs->rx_latency, 0); in lpfc_cmf_timer()
6024 rcv += atomic64_xchg(&cgs->rcv_bytes, 0); in lpfc_cmf_timer()
6032 if (phba->cmf_active_mode == LPFC_CFG_MANAGED && in lpfc_cmf_timer()
6033 phba->link_state != LPFC_LINK_DOWN && in lpfc_cmf_timer()
6034 test_bit(HBA_SETUP, &phba->hba_flag)) { in lpfc_cmf_timer()
6035 mbpi = phba->cmf_last_sync_bw; in lpfc_cmf_timer()
6036 phba->cmf_last_sync_bw = 0; in lpfc_cmf_timer()
6047 extra = cnt - total; in lpfc_cmf_timer()
6054 mbpi = phba->cmf_link_byte_count; in lpfc_cmf_timer()
6057 phba->cmf_timer_cnt++; in lpfc_cmf_timer()
6061 atomic_add(io_cnt, &phba->cgn_latency_evt_cnt); in lpfc_cmf_timer()
6062 atomic64_add(lat, &phba->cgn_latency_evt); in lpfc_cmf_timer()
6064 busy = atomic_xchg(&phba->cmf_busy, 0); in lpfc_cmf_timer()
6065 max_read = atomic_xchg(&phba->rx_max_read_cnt, 0); in lpfc_cmf_timer()
6069 if (mbpi > phba->cmf_link_byte_count || in lpfc_cmf_timer()
6070 phba->cmf_active_mode == LPFC_CFG_MONITOR) in lpfc_cmf_timer()
6071 mbpi = phba->cmf_link_byte_count; in lpfc_cmf_timer()
6076 if (mbpi != phba->cmf_max_bytes_per_interval) in lpfc_cmf_timer()
6077 phba->cmf_max_bytes_per_interval = mbpi; in lpfc_cmf_timer()
6081 if (phba->rx_monitor) { in lpfc_cmf_timer()
6086 entry.cmf_info = phba->cmf_active_info; in lpfc_cmf_timer()
6097 if (phba->cmf_active_mode == LPFC_CFG_MANAGED) in lpfc_cmf_timer()
6098 entry.timer_utilization = phba->cmf_last_ts; in lpfc_cmf_timer()
6102 phba->cmf_last_ts = 0; in lpfc_cmf_timer()
6104 lpfc_rx_monitor_record(phba->rx_monitor, &entry); in lpfc_cmf_timer()
6107 if (phba->cmf_active_mode == LPFC_CFG_MONITOR) { in lpfc_cmf_timer()
6112 atomic_inc(&phba->cgn_driver_evt_cnt); in lpfc_cmf_timer()
6114 phba->rx_block_cnt += div_u64(rcv, 512); /* save 512 byte block cnt */ in lpfc_cmf_timer()
6119 if (atomic_xchg(&phba->cmf_bw_wait, 0)) in lpfc_cmf_timer()
6120 queue_work(phba->wq, &phba->unblock_request_work); in lpfc_cmf_timer()
6123 atomic_set(&phba->cmf_stop_io, 0); in lpfc_cmf_timer()
6133 ((phba->trunk_link.link##__idx.state == LPFC_LINK_UP) ?\
6138 (port_fault & (1 << __idx) ? "YES" : "NO") : "NA"
6148 phba->sli4_hba.link_state.speed = in lpfc_update_trunk_link_status()
6152 phba->sli4_hba.link_state.logical_speed = in lpfc_update_trunk_link_status()
6155 phba->fc_linkspeed = in lpfc_update_trunk_link_status()
6161 phba->trunk_link.link0.state = in lpfc_update_trunk_link_status()
6164 phba->trunk_link.link0.fault = port_fault & 0x1 ? err : 0; in lpfc_update_trunk_link_status()
6168 phba->trunk_link.link1.state = in lpfc_update_trunk_link_status()
6171 phba->trunk_link.link1.fault = port_fault & 0x2 ? err : 0; in lpfc_update_trunk_link_status()
6175 phba->trunk_link.link2.state = in lpfc_update_trunk_link_status()
6178 phba->trunk_link.link2.fault = port_fault & 0x4 ? err : 0; in lpfc_update_trunk_link_status()
6182 phba->trunk_link.link3.state = in lpfc_update_trunk_link_status()
6185 phba->trunk_link.link3.fault = port_fault & 0x8 ? err : 0; in lpfc_update_trunk_link_status()
6190 phba->trunk_link.phy_lnk_speed = in lpfc_update_trunk_link_status()
6191 phba->sli4_hba.link_state.logical_speed / (cnt * 1000); in lpfc_update_trunk_link_status()
6193 phba->trunk_link.phy_lnk_speed = LPFC_LINK_SPEED_UNKNOWN; in lpfc_update_trunk_link_status()
6196 "2910 Async FC Trunking Event - Speed:%d\n" in lpfc_update_trunk_link_status()
6199 phba->sli4_hba.link_state.speed, in lpfc_update_trunk_link_status()
6200 phba->sli4_hba.link_state.logical_speed, in lpfc_update_trunk_link_status()
6204 if (phba->cmf_active_mode != LPFC_CFG_OFF) in lpfc_update_trunk_link_status()
6211 * SLI-4: We have only 0xA error codes in lpfc_update_trunk_link_status()
6223 * lpfc_sli4_async_fc_evt - Process the asynchronous FC link event
6255 phba->sli4_hba.link_state.speed = in lpfc_sli4_async_fc_evt()
6258 phba->sli4_hba.link_state.duplex = LPFC_ASYNC_LINK_DUPLEX_FULL; in lpfc_sli4_async_fc_evt()
6259 phba->sli4_hba.link_state.topology = in lpfc_sli4_async_fc_evt()
6261 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
6263 phba->sli4_hba.link_state.type = in lpfc_sli4_async_fc_evt()
6265 phba->sli4_hba.link_state.number = in lpfc_sli4_async_fc_evt()
6267 phba->sli4_hba.link_state.fault = in lpfc_sli4_async_fc_evt()
6269 phba->sli4_hba.link_state.link_status = in lpfc_sli4_async_fc_evt()
6276 if (phba->sli4_hba.link_state.status >= LPFC_FC_LA_TYPE_LINK_UP && in lpfc_sli4_async_fc_evt()
6277 phba->sli4_hba.link_state.status < LPFC_FC_LA_TYPE_ACTIVATE_FAIL) { in lpfc_sli4_async_fc_evt()
6280 phba->sli4_hba.link_state.logical_speed = 0; in lpfc_sli4_async_fc_evt()
6281 else if (!phba->sli4_hba.conf_trunk) in lpfc_sli4_async_fc_evt()
6282 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_fc_evt()
6287 "2896 Async FC event - Speed:%dGBaud Topology:x%x " in lpfc_sli4_async_fc_evt()
6290 phba->sli4_hba.link_state.speed, in lpfc_sli4_async_fc_evt()
6291 phba->sli4_hba.link_state.topology, in lpfc_sli4_async_fc_evt()
6292 phba->sli4_hba.link_state.status, in lpfc_sli4_async_fc_evt()
6293 phba->sli4_hba.link_state.type, in lpfc_sli4_async_fc_evt()
6294 phba->sli4_hba.link_state.number, in lpfc_sli4_async_fc_evt()
6295 phba->sli4_hba.link_state.logical_speed, in lpfc_sli4_async_fc_evt()
6296 phba->sli4_hba.link_state.fault, in lpfc_sli4_async_fc_evt()
6297 phba->sli4_hba.link_state.link_status); in lpfc_sli4_async_fc_evt()
6302 * link_state.status appropriately. No further action is required. in lpfc_sli4_async_fc_evt()
6304 if (phba->sli4_hba.link_state.status >= LPFC_FC_LA_TYPE_ACTIVATE_FAIL) { in lpfc_sli4_async_fc_evt()
6305 switch (phba->sli4_hba.link_state.status) { in lpfc_sli4_async_fc_evt()
6308 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
6319 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
6327 "2992 Async FC event - Informational Link " in lpfc_sli4_async_fc_evt()
6333 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_async_fc_evt()
6350 phba->sli4_hba.els_wq->pring->flag |= LPFC_STOP_IOCB_EVENT; in lpfc_sli4_async_fc_evt()
6353 phba->sli.slistat.link_event++; in lpfc_sli4_async_fc_evt()
6356 lpfc_read_topology(phba, pmb, pmb->ctx_buf); in lpfc_sli4_async_fc_evt()
6357 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_sli4_async_fc_evt()
6358 pmb->vport = phba->pport; in lpfc_sli4_async_fc_evt()
6360 if (phba->sli4_hba.link_state.status != LPFC_FC_LA_TYPE_LINK_UP) { in lpfc_sli4_async_fc_evt()
6361 phba->link_flag &= ~(LS_MDS_LINK_DOWN | LS_MDS_LOOPBACK); in lpfc_sli4_async_fc_evt()
6363 switch (phba->sli4_hba.link_state.status) { in lpfc_sli4_async_fc_evt()
6365 phba->link_flag |= LS_MDS_LINK_DOWN; in lpfc_sli4_async_fc_evt()
6368 phba->link_flag |= LS_MDS_LOOPBACK; in lpfc_sli4_async_fc_evt()
6375 mb = &pmb->u.mb; in lpfc_sli4_async_fc_evt()
6376 mb->mbxStatus = MBX_SUCCESS; in lpfc_sli4_async_fc_evt()
6382 la = (struct lpfc_mbx_read_top *)&pmb->u.mb.un.varReadTop; in lpfc_sli4_async_fc_evt()
6383 la->eventTag = acqe_fc->event_tag; in lpfc_sli4_async_fc_evt()
6385 if (phba->sli4_hba.link_state.status == in lpfc_sli4_async_fc_evt()
6409 * lpfc_sli4_async_sli_evt - Process the asynchronous SLI link event
6433 "2901 Async SLI event - Type:%d, Event Data: x%08x " in lpfc_sli4_async_sli_evt()
6435 acqe_sli->event_data1, acqe_sli->event_data2, in lpfc_sli4_async_sli_evt()
6436 acqe_sli->event_data3, acqe_sli->trailer); in lpfc_sli4_async_sli_evt()
6438 port_name = phba->Port[0]; in lpfc_sli4_async_sli_evt()
6446 temp_event_data.data = (uint32_t)acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6449 "3190 Over Temperature:%d Celsius- Port Name %c\n", in lpfc_sli4_async_sli_evt()
6450 acqe_sli->event_data1, port_name); in lpfc_sli4_async_sli_evt()
6452 phba->sfp_warning |= LPFC_TRANSGRESSION_HIGH_TEMPERATURE; in lpfc_sli4_async_sli_evt()
6453 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli4_async_sli_evt()
6463 temp_event_data.data = (uint32_t)acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6466 "3191 Normal Temperature:%d Celsius - Port Name %c\n", in lpfc_sli4_async_sli_evt()
6467 acqe_sli->event_data1, port_name); in lpfc_sli4_async_sli_evt()
6469 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli4_async_sli_evt()
6478 &acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6481 switch (phba->sli4_hba.lnk_info.lnk_no) { in lpfc_sli4_async_sli_evt()
6484 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6486 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6490 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6492 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6496 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6498 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6502 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6504 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6511 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_async_sli_evt()
6516 if (phba->sli4_hba.lnk_info.optic_state == status) in lpfc_sli4_async_sli_evt()
6525 "installed/not installed - Reseat optics, " in lpfc_sli4_async_sli_evt()
6530 "Optics of two types installed - Remove one " in lpfc_sli4_async_sli_evt()
6534 sprintf(message, "Incompatible optics - Replace with " in lpfc_sli4_async_sli_evt()
6538 sprintf(message, "Unqualified optics - Replace with " in lpfc_sli4_async_sli_evt()
6540 "Support - Link is%s operational", in lpfc_sli4_async_sli_evt()
6544 sprintf(message, "Uncertified optics - Replace with " in lpfc_sli4_async_sli_evt()
6545 "Avago-certified optics to enable link " in lpfc_sli4_async_sli_evt()
6546 "operation - Link is%s operational", in lpfc_sli4_async_sli_evt()
6558 phba->lmt = 0; in lpfc_sli4_async_sli_evt()
6572 for (i = 0; i <= phba->max_vports && vports[i] != NULL; in lpfc_sli4_async_sli_evt()
6580 phba->sli4_hba.lnk_info.optic_state = status; in lpfc_sli4_async_sli_evt()
6586 "3192 Remote DPort Test Initiated - " in lpfc_sli4_async_sli_evt()
6588 acqe_sli->event_data1, acqe_sli->event_data2); in lpfc_sli4_async_sli_evt()
6596 * to use FA-WWN, but the attached device doesn’t support it. in lpfc_sli4_async_sli_evt()
6597 * Event Data1 - N.A, Event Data2 - N.A in lpfc_sli4_async_sli_evt()
6601 "2699 Misconfigured FA-PWWN - Attached device " in lpfc_sli4_async_sli_evt()
6602 "does not support FA-PWWN\n"); in lpfc_sli4_async_sli_evt()
6603 phba->sli4_hba.fawwpn_flag &= ~LPFC_FAWWPN_FABRIC; in lpfc_sli4_async_sli_evt()
6604 memset(phba->pport->fc_portname.u.wwn, 0, in lpfc_sli4_async_sli_evt()
6608 /* EEPROM failure. No driver action is required */ in lpfc_sli4_async_sli_evt()
6610 "2518 EEPROM failure - " in lpfc_sli4_async_sli_evt()
6612 acqe_sli->event_data1, acqe_sli->event_data2); in lpfc_sli4_async_sli_evt()
6615 if (phba->cmf_active_mode == LPFC_CFG_OFF) in lpfc_sli4_async_sli_evt()
6618 &acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6619 phba->cgn_acqe_cnt++; in lpfc_sli4_async_sli_evt()
6622 atomic64_add(cnt, &phba->cgn_acqe_stat.warn); in lpfc_sli4_async_sli_evt()
6623 atomic64_add(cgn_signal->alarm_cnt, &phba->cgn_acqe_stat.alarm); in lpfc_sli4_async_sli_evt()
6625 /* no threshold for CMF, even 1 signal will trigger an event */ in lpfc_sli4_async_sli_evt()
6628 if (cgn_signal->alarm_cnt) { in lpfc_sli4_async_sli_evt()
6629 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { in lpfc_sli4_async_sli_evt()
6631 atomic_add(cgn_signal->alarm_cnt, in lpfc_sli4_async_sli_evt()
6632 &phba->cgn_sync_alarm_cnt); in lpfc_sli4_async_sli_evt()
6636 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY || in lpfc_sli4_async_sli_evt()
6637 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { in lpfc_sli4_async_sli_evt()
6639 atomic_add(cnt, &phba->cgn_sync_warn_cnt); in lpfc_sli4_async_sli_evt()
6649 acqe_sli->event_data1, acqe_sli->event_data2, in lpfc_sli4_async_sli_evt()
6650 acqe_sli->event_data3); in lpfc_sli4_async_sli_evt()
6666 * lpfc_sli4_perform_vport_cvl - Perform clear virtual link on a vport
6684 phba = vport->phba; in lpfc_sli4_perform_vport_cvl()
6694 ndlp->nlp_type |= NLP_FABRIC; in lpfc_sli4_perform_vport_cvl()
6698 if ((phba->pport->port_state < LPFC_FLOGI) && in lpfc_sli4_perform_vport_cvl()
6699 (phba->pport->port_state != LPFC_VPORT_FAILED)) in lpfc_sli4_perform_vport_cvl()
6702 if ((vport != phba->pport) && (vport->port_state < LPFC_FDISC) in lpfc_sli4_perform_vport_cvl()
6703 && (vport->port_state != LPFC_VPORT_FAILED)) in lpfc_sli4_perform_vport_cvl()
6710 set_bit(FC_VPORT_CVL_RCVD, &vport->fc_flag); in lpfc_sli4_perform_vport_cvl()
6716 * lpfc_sli4_perform_all_vport_cvl - Perform clear virtual link on all vports
6730 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) in lpfc_sli4_perform_all_vport_cvl()
6736 * lpfc_sli4_async_fip_evt - Process the asynchronous FCoE FIP event
6754 phba->fc_eventTag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6755 phba->fcoe_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6763 acqe_fip->event_tag, in lpfc_sli4_async_fip_evt()
6764 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6770 acqe_fip->event_tag, in lpfc_sli4_async_fip_evt()
6771 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6772 if (phba->fcf.fcf_flag & FCF_DISCOVERY) { in lpfc_sli4_async_fip_evt()
6782 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6783 rc = lpfc_sli4_read_fcf_rec(phba, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6787 if (test_bit(FCF_TS_INPROG, &phba->hba_flag)) in lpfc_sli4_async_fip_evt()
6789 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6791 if (phba->fcf.fcf_flag & (FCF_REDISC_EVT | FCF_REDISC_PEND)) { in lpfc_sli4_async_fip_evt()
6792 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6797 if (phba->fcf.fcf_flag & FCF_SCAN_DONE) { in lpfc_sli4_async_fip_evt()
6798 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6801 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6803 /* Otherwise, scan the entire FCF table and re-discover SAN */ in lpfc_sli4_async_fip_evt()
6807 acqe_fip->event_tag, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6820 acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6824 phba->fcoe_cvl_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6827 "tag:x%x\n", acqe_fip->index, in lpfc_sli4_async_fip_evt()
6828 acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6833 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6834 if ((phba->fcf.fcf_flag & FCF_DISCOVERY) && in lpfc_sli4_async_fip_evt()
6835 (phba->fcf.current_rec.fcf_indx != acqe_fip->index)) { in lpfc_sli4_async_fip_evt()
6836 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6838 lpfc_sli4_fcf_rr_index_clear(phba, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6841 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6844 if (phba->fcf.current_rec.fcf_indx != acqe_fip->index) in lpfc_sli4_async_fip_evt()
6850 * is no longer valid as we are not in the middle of FCF in lpfc_sli4_async_fip_evt()
6853 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6855 phba->fcf.fcf_flag |= FCF_DEAD_DISC; in lpfc_sli4_async_fip_evt()
6856 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6861 "\n", acqe_fip->event_tag, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6869 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6870 phba->fcf.fcf_flag &= ~FCF_DEAD_DISC; in lpfc_sli4_async_fip_evt()
6871 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6888 phba->fcoe_cvl_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6892 " tag 0x%x\n", acqe_fip->index, acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6895 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6903 for (i = 0; i <= phba->max_vports && vports[i] != NULL; in lpfc_sli4_async_fip_evt()
6906 &vports[i]->fc_flag) && in lpfc_sli4_async_fip_evt()
6907 vports[i]->port_state > LPFC_FDISC) { in lpfc_sli4_async_fip_evt()
6916 * Don't re-instantiate if vport is marked for deletion. in lpfc_sli4_async_fip_evt()
6920 if (!test_bit(FC_UNLOADING, &vport->load_flag) && in lpfc_sli4_async_fip_evt()
6924 * re-instantiate the Vlink using FDISC. in lpfc_sli4_async_fip_evt()
6926 mod_timer(&ndlp->nlp_delayfunc, in lpfc_sli4_async_fip_evt()
6928 spin_lock_irq(&ndlp->lock); in lpfc_sli4_async_fip_evt()
6929 ndlp->nlp_flag |= NLP_DELAY_TMO; in lpfc_sli4_async_fip_evt()
6930 spin_unlock_irq(&ndlp->lock); in lpfc_sli4_async_fip_evt()
6931 ndlp->nlp_last_elscmd = ELS_CMD_FDISC; in lpfc_sli4_async_fip_evt()
6932 vport->port_state = LPFC_FDISC; in lpfc_sli4_async_fip_evt()
6938 * is no longer valid if we are not already in lpfc_sli4_async_fip_evt()
6941 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6942 if (phba->fcf.fcf_flag & FCF_DISCOVERY) { in lpfc_sli4_async_fip_evt()
6943 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6947 phba->fcf.fcf_flag |= FCF_ACVL_DISC; in lpfc_sli4_async_fip_evt()
6948 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6952 "evt_tag:x%x\n", acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6960 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6961 phba->fcf.fcf_flag &= ~FCF_ACVL_DISC; in lpfc_sli4_async_fip_evt()
6962 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6964 * Last resort will be re-try on the in lpfc_sli4_async_fip_evt()
6979 "0x%x\n", event_type, acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6985 * lpfc_sli4_async_dcbx_evt - Process the asynchronous dcbx event
6995 phba->fc_eventTag = acqe_dcbx->event_tag; in lpfc_sli4_async_dcbx_evt()
7002 * lpfc_sli4_async_grp5_evt - Process the asynchronous group5 event
7016 phba->fc_eventTag = acqe_grp5->event_tag; in lpfc_sli4_async_grp5_evt()
7017 phba->fcoe_eventtag = acqe_grp5->event_tag; in lpfc_sli4_async_grp5_evt()
7018 prev_ll_spd = phba->sli4_hba.link_state.logical_speed; in lpfc_sli4_async_grp5_evt()
7019 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_grp5_evt()
7024 phba->sli4_hba.link_state.logical_speed); in lpfc_sli4_async_grp5_evt()
7028 * lpfc_sli4_async_cmstat_evt - Process the asynchronous cmstat event
7037 if (!phba->cgn_i) in lpfc_sli4_async_cmstat_evt()
7043 * lpfc_cgn_params_val - Validate FW congestion parameters.
7053 spin_lock_irq(&phba->hbalock); in lpfc_cgn_params_val()
7055 if (!lpfc_rangecheck(p_cfg_param->cgn_param_mode, LPFC_CFG_OFF, in lpfc_cgn_params_val()
7059 p_cfg_param->cgn_param_mode); in lpfc_cgn_params_val()
7060 p_cfg_param->cgn_param_mode = LPFC_CFG_OFF; in lpfc_cgn_params_val()
7063 spin_unlock_irq(&phba->hbalock); in lpfc_cgn_params_val()
7073 * lpfc_cgn_params_parse - Process a FW cong parm change event
7080 * valid, in-range values. If the signature magic is correct and
7096 if (p_cgn_param->cgn_param_magic == LPFC_CFG_PARAM_MAGIC_NUM) { in lpfc_cgn_params_parse()
7104 p_cgn_param->cgn_param_magic, in lpfc_cgn_params_parse()
7105 p_cgn_param->cgn_param_version, in lpfc_cgn_params_parse()
7106 p_cgn_param->cgn_param_mode, in lpfc_cgn_params_parse()
7107 p_cgn_param->cgn_param_level0, in lpfc_cgn_params_parse()
7108 p_cgn_param->cgn_param_level1, in lpfc_cgn_params_parse()
7109 p_cgn_param->cgn_param_level2, in lpfc_cgn_params_parse()
7110 p_cgn_param->byte13, in lpfc_cgn_params_parse()
7111 p_cgn_param->byte14, in lpfc_cgn_params_parse()
7112 p_cgn_param->byte15, in lpfc_cgn_params_parse()
7113 p_cgn_param->byte11, in lpfc_cgn_params_parse()
7114 p_cgn_param->byte12, in lpfc_cgn_params_parse()
7115 phba->cmf_active_mode); in lpfc_cgn_params_parse()
7117 oldmode = phba->cmf_active_mode; in lpfc_cgn_params_parse()
7120 * by this routine. No need to fail. in lpfc_cgn_params_parse()
7125 spin_lock_irq(&phba->hbalock); in lpfc_cgn_params_parse()
7126 memcpy(&phba->cgn_p, p_cgn_param, in lpfc_cgn_params_parse()
7130 if (phba->cgn_i) { in lpfc_cgn_params_parse()
7131 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_cgn_params_parse()
7132 cp->cgn_info_mode = phba->cgn_p.cgn_param_mode; in lpfc_cgn_params_parse()
7133 cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0; in lpfc_cgn_params_parse()
7134 cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1; in lpfc_cgn_params_parse()
7135 cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2; in lpfc_cgn_params_parse()
7138 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_cgn_params_parse()
7140 spin_unlock_irq(&phba->hbalock); in lpfc_cgn_params_parse()
7142 phba->cmf_active_mode = phba->cgn_p.cgn_param_mode; in lpfc_cgn_params_parse()
7146 if (phba->cgn_p.cgn_param_mode != LPFC_CFG_OFF) { in lpfc_cgn_params_parse()
7150 if (phba->link_state >= LPFC_LINK_UP) { in lpfc_cgn_params_parse()
7151 phba->cgn_reg_fpin = in lpfc_cgn_params_parse()
7152 phba->cgn_init_reg_fpin; in lpfc_cgn_params_parse()
7153 phba->cgn_reg_signal = in lpfc_cgn_params_parse()
7154 phba->cgn_init_reg_signal; in lpfc_cgn_params_parse()
7155 lpfc_issue_els_edc(phba->pport, 0); in lpfc_cgn_params_parse()
7160 switch (phba->cgn_p.cgn_param_mode) { in lpfc_cgn_params_parse()
7164 if (phba->link_state >= LPFC_LINK_UP) in lpfc_cgn_params_parse()
7165 lpfc_issue_els_edc(phba->pport, 0); in lpfc_cgn_params_parse()
7168 phba->cmf_max_bytes_per_interval = in lpfc_cgn_params_parse()
7169 phba->cmf_link_byte_count; in lpfc_cgn_params_parse()
7171 /* Resume blocked IO - unblock on workqueue */ in lpfc_cgn_params_parse()
7172 queue_work(phba->wq, in lpfc_cgn_params_parse()
7173 &phba->unblock_request_work); in lpfc_cgn_params_parse()
7178 switch (phba->cgn_p.cgn_param_mode) { in lpfc_cgn_params_parse()
7182 if (phba->link_state >= LPFC_LINK_UP) in lpfc_cgn_params_parse()
7183 lpfc_issue_els_edc(phba->pport, 0); in lpfc_cgn_params_parse()
7192 oldmode != phba->cgn_p.cgn_param_mode) { in lpfc_cgn_params_parse()
7193 if (phba->cgn_p.cgn_param_mode == LPFC_CFG_MANAGED) in lpfc_cgn_params_parse()
7195 phba->cgn_p.cgn_param_level0); in lpfc_cgn_params_parse()
7199 dev_info(&phba->pcidev->dev, "%d: " in lpfc_cgn_params_parse()
7201 phba->brd_no, in lpfc_cgn_params_parse()
7203 [phba->cgn_p.cgn_param_mode], in lpfc_cgn_params_parse()
7209 "version %d\n", p_cgn_param->cgn_param_magic, in lpfc_cgn_params_parse()
7210 p_cgn_param->cgn_param_version); in lpfc_cgn_params_parse()
7215 * lpfc_sli4_cgn_params_read - Read and Validate FW congestion parameters.
7224 * -Eval if an error was encountered
7239 return -ENOMEM; in lpfc_sli4_cgn_params_read()
7243 /* 0 means no data. A negative means error. A positive means in lpfc_sli4_cgn_params_read()
7248 "4670 CGN RD OBJ returns no data\n"); in lpfc_sli4_cgn_params_read()
7260 * may have been altered in FW, but take no action here. in lpfc_sli4_cgn_params_read()
7271 * lpfc_sli4_cgn_parm_chg_evt - Process a FW congestion param change event
7282 * The acqe event is not passed because there is no further data
7293 if (!phba->sli4_hba.pc_sli4_params.cmf) { in lpfc_sli4_cgn_parm_chg_evt()
7296 return -EACCES; in lpfc_sli4_cgn_parm_chg_evt()
7316 * lpfc_sli4_async_event_proc - Process all the pending asynchronous event
7328 clear_bit(ASYNC_EVENT, &phba->hba_flag); in lpfc_sli4_async_event_proc()
7331 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
7332 while (!list_empty(&phba->sli4_hba.sp_asynce_work_queue)) { in lpfc_sli4_async_event_proc()
7333 list_remove_head(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_async_event_proc()
7335 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, in lpfc_sli4_async_event_proc()
7339 switch (bf_get(lpfc_trailer_code, &cq_event->cqe.mcqe_cmpl)) { in lpfc_sli4_async_event_proc()
7342 &cq_event->cqe.acqe_link); in lpfc_sli4_async_event_proc()
7345 lpfc_sli4_async_fip_evt(phba, &cq_event->cqe.acqe_fip); in lpfc_sli4_async_event_proc()
7349 &cq_event->cqe.acqe_dcbx); in lpfc_sli4_async_event_proc()
7353 &cq_event->cqe.acqe_grp5); in lpfc_sli4_async_event_proc()
7356 lpfc_sli4_async_fc_evt(phba, &cq_event->cqe.acqe_fc); in lpfc_sli4_async_event_proc()
7359 lpfc_sli4_async_sli_evt(phba, &cq_event->cqe.acqe_sli); in lpfc_sli4_async_event_proc()
7366 &cq_event->cqe.mcqe_cmpl)); in lpfc_sli4_async_event_proc()
7372 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
7374 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
7378 * lpfc_sli4_fcf_redisc_event_proc - Process fcf table rediscovery event
7388 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_event_proc()
7390 phba->fcf.fcf_flag &= ~FCF_REDISC_EVT; in lpfc_sli4_fcf_redisc_event_proc()
7392 phba->fcf.failover_rec.flag = 0; in lpfc_sli4_fcf_redisc_event_proc()
7394 phba->fcf.fcf_flag |= FCF_REDISC_FOV; in lpfc_sli4_fcf_redisc_event_proc()
7395 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_event_proc()
7397 /* Scan FCF table from the first entry to re-discover SAN */ in lpfc_sli4_fcf_redisc_event_proc()
7399 "2777 Start post-quiescent FCF table scan\n"); in lpfc_sli4_fcf_redisc_event_proc()
7408 * lpfc_api_table_setup - Set up per hba pci-device group func api jump table
7410 * @dev_grp: The HBA PCI-Device group number.
7412 * This routine is invoked to set up the per HBA PCI-Device group function
7415 * Return: 0 if success, otherwise -ENODEV
7422 /* Set up lpfc PCI-device group */ in lpfc_api_table_setup()
7423 phba->pci_dev_grp = dev_grp; in lpfc_api_table_setup()
7427 phba->sli_rev = LPFC_SLI_REV4; in lpfc_api_table_setup()
7432 return -ENODEV; in lpfc_api_table_setup()
7436 return -ENODEV; in lpfc_api_table_setup()
7440 return -ENODEV; in lpfc_api_table_setup()
7444 return -ENODEV; in lpfc_api_table_setup()
7450 * lpfc_log_intr_mode - Log the active interrupt mode
7470 "0480 Enabled MSI-X interrupt mode.\n"); in lpfc_log_intr_mode()
7481 * lpfc_enable_pci_dev - Enable a generic PCI device.
7488 * 0 - successful
7489 * other values - error
7497 if (!phba->pcidev) in lpfc_enable_pci_dev()
7500 pdev = phba->pcidev; in lpfc_enable_pci_dev()
7514 pdev->needs_freset = 1; in lpfc_enable_pci_dev()
7523 return -ENODEV; in lpfc_enable_pci_dev()
7527 * lpfc_disable_pci_dev - Disable a generic PCI device.
7539 if (!phba->pcidev) in lpfc_disable_pci_dev()
7542 pdev = phba->pcidev; in lpfc_disable_pci_dev()
7551 * lpfc_reset_hba - Reset a hba
7565 if (!phba->cfg_enable_hba_reset) { in lpfc_reset_hba()
7566 phba->link_state = LPFC_HBA_ERROR; in lpfc_reset_hba()
7571 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE) { in lpfc_reset_hba()
7574 if (test_bit(MBX_TMO_ERR, &phba->bit_flags)) { in lpfc_reset_hba()
7583 clear_bit(MBX_TMO_ERR, &phba->bit_flags); in lpfc_reset_hba()
7596 * lpfc_sli_sriov_nr_virtfn_get - Get the number of sr-iov virtual functions
7599 * This function enables the PCI SR-IOV virtual functions to a physical
7600 * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
7602 * not all devices support SR-IOV, the return code from the pci_enable_sriov()
7608 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_sriov_nr_virtfn_get()
7621 * lpfc_sli_probe_sriov_nr_virtfn - Enable a number of sr-iov virtual functions
7625 * This function enables the PCI SR-IOV virtual functions to a physical
7626 * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
7628 * not all devices support SR-IOV, the return code from the pci_enable_sriov()
7634 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_probe_sriov_nr_virtfn()
7643 return -EINVAL; in lpfc_sli_probe_sriov_nr_virtfn()
7669 * lpfc_setup_driver_resource_phase1 - Phase1 etup driver internal resources.
7676 * 0 - successful
7677 * other values - error
7682 struct lpfc_sli *psli = &phba->sli; in lpfc_setup_driver_resource_phase1()
7687 atomic_set(&phba->fast_event_count, 0); in lpfc_setup_driver_resource_phase1()
7688 atomic_set(&phba->dbg_log_idx, 0); in lpfc_setup_driver_resource_phase1()
7689 atomic_set(&phba->dbg_log_cnt, 0); in lpfc_setup_driver_resource_phase1()
7690 atomic_set(&phba->dbg_log_dmping, 0); in lpfc_setup_driver_resource_phase1()
7691 spin_lock_init(&phba->hbalock); in lpfc_setup_driver_resource_phase1()
7694 spin_lock_init(&phba->port_list_lock); in lpfc_setup_driver_resource_phase1()
7695 INIT_LIST_HEAD(&phba->port_list); in lpfc_setup_driver_resource_phase1()
7697 INIT_LIST_HEAD(&phba->work_list); in lpfc_setup_driver_resource_phase1()
7700 init_waitqueue_head(&phba->work_waitq); in lpfc_setup_driver_resource_phase1()
7704 ((phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ? in lpfc_setup_driver_resource_phase1()
7706 ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) ? in lpfc_setup_driver_resource_phase1()
7708 (phba->nvmet_support ? "NVMET" : " ")); in lpfc_setup_driver_resource_phase1()
7711 spin_lock_init(&phba->ras_fwlog_lock); in lpfc_setup_driver_resource_phase1()
7714 spin_lock_init(&phba->scsi_buf_list_get_lock); in lpfc_setup_driver_resource_phase1()
7715 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_get); in lpfc_setup_driver_resource_phase1()
7716 spin_lock_init(&phba->scsi_buf_list_put_lock); in lpfc_setup_driver_resource_phase1()
7717 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_put); in lpfc_setup_driver_resource_phase1()
7720 INIT_LIST_HEAD(&phba->fabric_iocb_list); in lpfc_setup_driver_resource_phase1()
7723 INIT_LIST_HEAD(&phba->elsbuf); in lpfc_setup_driver_resource_phase1()
7726 INIT_LIST_HEAD(&phba->fcf_conn_rec_list); in lpfc_setup_driver_resource_phase1()
7729 spin_lock_init(&phba->devicelock); in lpfc_setup_driver_resource_phase1()
7730 INIT_LIST_HEAD(&phba->luns); in lpfc_setup_driver_resource_phase1()
7733 timer_setup(&psli->mbox_tmo, lpfc_mbox_timeout, 0); in lpfc_setup_driver_resource_phase1()
7735 timer_setup(&phba->fabric_block_timer, lpfc_fabric_block_timeout, 0); in lpfc_setup_driver_resource_phase1()
7737 timer_setup(&phba->eratt_poll, lpfc_poll_eratt, 0); in lpfc_setup_driver_resource_phase1()
7739 timer_setup(&phba->hb_tmofunc, lpfc_hb_timeout, 0); in lpfc_setup_driver_resource_phase1()
7741 INIT_DELAYED_WORK(&phba->eq_delay_work, lpfc_hb_eq_delay_work); in lpfc_setup_driver_resource_phase1()
7743 INIT_DELAYED_WORK(&phba->idle_stat_delay_work, in lpfc_setup_driver_resource_phase1()
7745 INIT_WORK(&phba->unblock_request_work, lpfc_unblock_requests_work); in lpfc_setup_driver_resource_phase1()
7750 * lpfc_sli_driver_resource_setup - Setup driver internal resources for SLI3 dev
7754 * support the SLI-3 HBA device it attached to.
7757 * 0 - successful
7758 * other values - error
7770 timer_setup(&phba->fcp_poll_timer, lpfc_poll_timeout, 0); in lpfc_sli_driver_resource_setup()
7773 phba->work_ha_mask = (HA_ERATT | HA_MBATT | HA_LATT); in lpfc_sli_driver_resource_setup()
7774 phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING * 4)); in lpfc_sli_driver_resource_setup()
7778 /* Set up phase-1 common device driver resources */ in lpfc_sli_driver_resource_setup()
7782 return -ENODEV; in lpfc_sli_driver_resource_setup()
7784 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
7785 phba->sli.sli3_ring = kcalloc(LPFC_SLI3_MAX_RING, in lpfc_sli_driver_resource_setup()
7788 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
7789 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7796 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_driver_resource_setup()
7802 if (phba->cfg_enable_bg) { in lpfc_sli_driver_resource_setup()
7804 * The scsi_buf for a T10-DIF I/O will hold the FCP cmnd, in lpfc_sli_driver_resource_setup()
7805 * the FCP rsp, and a BDE for each. Sice we have no control in lpfc_sli_driver_resource_setup()
7812 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
7816 if (phba->cfg_sg_seg_cnt > LPFC_MAX_SG_SEG_CNT_DIF) in lpfc_sli_driver_resource_setup()
7817 phba->cfg_sg_seg_cnt = LPFC_MAX_SG_SEG_CNT_DIF; in lpfc_sli_driver_resource_setup()
7820 phba->cfg_total_seg_cnt = LPFC_MAX_SG_SEG_CNT; in lpfc_sli_driver_resource_setup()
7827 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
7829 ((phba->cfg_sg_seg_cnt + 2) * entry_sz); in lpfc_sli_driver_resource_setup()
7832 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + 2; in lpfc_sli_driver_resource_setup()
7837 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
7838 phba->cfg_total_seg_cnt); in lpfc_sli_driver_resource_setup()
7840 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli_driver_resource_setup()
7842 phba->max_vports = 0; in lpfc_sli_driver_resource_setup()
7852 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7854 phba->lpfc_sg_dma_buf_pool = in lpfc_sli_driver_resource_setup()
7856 &phba->pcidev->dev, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
7859 if (!phba->lpfc_sg_dma_buf_pool) in lpfc_sli_driver_resource_setup()
7862 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli_driver_resource_setup()
7864 &phba->pcidev->dev, in lpfc_sli_driver_resource_setup()
7869 if (!phba->lpfc_cmd_rsp_buf_pool) in lpfc_sli_driver_resource_setup()
7873 * Enable sr-iov virtual functions if supported and configured in lpfc_sli_driver_resource_setup()
7876 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli_driver_resource_setup()
7878 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
7881 "2808 Requested number of SR-IOV " in lpfc_sli_driver_resource_setup()
7884 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
7885 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli_driver_resource_setup()
7892 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli_driver_resource_setup()
7893 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli_driver_resource_setup()
7896 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7900 * lpfc_sli_driver_resource_unset - Unset drvr internal resources for SLI3 dev
7904 * specific for supporting the SLI-3 HBA device it attached to.
7916 * lpfc_sli4_driver_resource_setup - Setup drvr internal resources for SLI4 dev
7920 * support the SLI-4 HBA device it attached to.
7923 * 0 - successful
7924 * other values - error
7938 phba->sli4_hba.num_present_cpu = lpfc_present_cpu; in lpfc_sli4_driver_resource_setup()
7939 phba->sli4_hba.num_possible_cpu = cpumask_last(cpu_possible_mask) + 1; in lpfc_sli4_driver_resource_setup()
7940 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_setup()
7945 /* Set up phase-1 common device driver resources */ in lpfc_sli4_driver_resource_setup()
7948 return -ENODEV; in lpfc_sli4_driver_resource_setup()
7953 return -ENODEV; in lpfc_sli4_driver_resource_setup()
7958 phba->wq = alloc_workqueue("lpfc_wq", WQ_MEM_RECLAIM, 0); in lpfc_sli4_driver_resource_setup()
7959 if (!phba->wq) in lpfc_sli4_driver_resource_setup()
7960 return -ENOMEM; in lpfc_sli4_driver_resource_setup()
7966 timer_setup(&phba->rrq_tmr, lpfc_rrq_timeout, 0); in lpfc_sli4_driver_resource_setup()
7969 timer_setup(&phba->fcf.redisc_wait, lpfc_sli4_fcf_redisc_wait_tmo, 0); in lpfc_sli4_driver_resource_setup()
7972 hrtimer_init(&phba->cmf_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in lpfc_sli4_driver_resource_setup()
7973 phba->cmf_timer.function = lpfc_cmf_timer; in lpfc_sli4_driver_resource_setup()
7975 hrtimer_init(&phba->cmf_stats_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in lpfc_sli4_driver_resource_setup()
7976 phba->cmf_stats_timer.function = lpfc_cmf_stats_timer; in lpfc_sli4_driver_resource_setup()
7979 * Control structure for handling external multi-buffer mailbox in lpfc_sli4_driver_resource_setup()
7980 * command pass-through. in lpfc_sli4_driver_resource_setup()
7982 memset((uint8_t *)&phba->mbox_ext_buf_ctx, 0, in lpfc_sli4_driver_resource_setup()
7984 INIT_LIST_HEAD(&phba->mbox_ext_buf_ctx.ext_dmabuf_list); in lpfc_sli4_driver_resource_setup()
7986 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli4_driver_resource_setup()
7989 phba->max_vports = 0; in lpfc_sli4_driver_resource_setup()
7992 phba->valid_vlan = 0; in lpfc_sli4_driver_resource_setup()
7993 phba->fc_map[0] = LPFC_FCOE_FCF_MAP0; in lpfc_sli4_driver_resource_setup()
7994 phba->fc_map[1] = LPFC_FCOE_FCF_MAP1; in lpfc_sli4_driver_resource_setup()
7995 phba->fc_map[2] = LPFC_FCOE_FCF_MAP2; in lpfc_sli4_driver_resource_setup()
8004 INIT_LIST_HEAD(&phba->hbqs[LPFC_ELS_HBQ].hbq_buffer_list); in lpfc_sli4_driver_resource_setup()
8005 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_sli4_rb_alloc; in lpfc_sli4_driver_resource_setup()
8006 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_sli4_rb_free; in lpfc_sli4_driver_resource_setup()
8010 timer_setup(&phba->inactive_vmid_poll, lpfc_vmid_poll, 0); in lpfc_sli4_driver_resource_setup()
8016 spin_lock_init(&phba->sli4_hba.abts_io_buf_list_lock); in lpfc_sli4_driver_resource_setup()
8017 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_io_buf_list); in lpfc_sli4_driver_resource_setup()
8019 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
8021 spin_lock_init(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_sli4_driver_resource_setup()
8022 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_driver_resource_setup()
8023 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_io_wait_list); in lpfc_sli4_driver_resource_setup()
8024 spin_lock_init(&phba->sli4_hba.t_active_list_lock); in lpfc_sli4_driver_resource_setup()
8025 INIT_LIST_HEAD(&phba->sli4_hba.t_active_ctx_list); in lpfc_sli4_driver_resource_setup()
8029 spin_lock_init(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_driver_resource_setup()
8030 spin_lock_init(&phba->sli4_hba.nvmet_io_wait_lock); in lpfc_sli4_driver_resource_setup()
8031 spin_lock_init(&phba->sli4_hba.asynce_list_lock); in lpfc_sli4_driver_resource_setup()
8032 spin_lock_init(&phba->sli4_hba.els_xri_abrt_list_lock); in lpfc_sli4_driver_resource_setup()
8035 * Initialize driver internal slow-path work queues in lpfc_sli4_driver_resource_setup()
8038 /* Driver internel slow-path CQ Event pool */ in lpfc_sli4_driver_resource_setup()
8039 INIT_LIST_HEAD(&phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_driver_resource_setup()
8041 INIT_LIST_HEAD(&phba->sli4_hba.sp_queue_event); in lpfc_sli4_driver_resource_setup()
8043 INIT_LIST_HEAD(&phba->sli4_hba.sp_asynce_work_queue); in lpfc_sli4_driver_resource_setup()
8044 /* Slow-path XRI aborted CQ Event work queue list */ in lpfc_sli4_driver_resource_setup()
8045 INIT_LIST_HEAD(&phba->sli4_hba.sp_els_xri_aborted_work_queue); in lpfc_sli4_driver_resource_setup()
8047 INIT_LIST_HEAD(&phba->sli4_hba.sp_unsol_work_queue); in lpfc_sli4_driver_resource_setup()
8050 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_blk_list); in lpfc_sli4_driver_resource_setup()
8051 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_xri_blk_list); in lpfc_sli4_driver_resource_setup()
8052 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_vfi_blk_list); in lpfc_sli4_driver_resource_setup()
8053 INIT_LIST_HEAD(&phba->lpfc_vpi_blk_list); in lpfc_sli4_driver_resource_setup()
8058 INIT_LIST_HEAD(&phba->sli.mboxq); in lpfc_sli4_driver_resource_setup()
8059 INIT_LIST_HEAD(&phba->sli.mboxq_cmpl); in lpfc_sli4_driver_resource_setup()
8062 phba->sli4_hba.lnk_info.optic_state = 0xff; in lpfc_sli4_driver_resource_setup()
8070 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_driver_resource_setup()
8074 rc = -ENODEV; in lpfc_sli4_driver_resource_setup()
8077 phba->temp_sensor_support = 1; in lpfc_sli4_driver_resource_setup()
8095 if (phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_CONFIG) { in lpfc_sli4_driver_resource_setup()
8096 /* Right now the link is down, if FA-PWWN is configured the in lpfc_sli4_driver_resource_setup()
8100 * the driver gets is if it fails, if it succeeds there is no in lpfc_sli4_driver_resource_setup()
8103 phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_FABRIC; in lpfc_sli4_driver_resource_setup()
8111 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_driver_resource_setup()
8118 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_sli4_driver_resource_setup()
8121 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8126 phba->nvmet_support = 0; in lpfc_sli4_driver_resource_setup()
8137 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_driver_resource_setup()
8138 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_driver_resource_setup()
8139 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8140 rc = -EIO; in lpfc_sli4_driver_resource_setup()
8143 mb = &mboxq->u.mb; in lpfc_sli4_driver_resource_setup()
8144 memcpy(&wwn, (char *)mb->un.varRDnvp.nodename, in lpfc_sli4_driver_resource_setup()
8147 phba->sli4_hba.wwnn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
8148 memcpy(&wwn, (char *)mb->un.varRDnvp.portname, in lpfc_sli4_driver_resource_setup()
8152 phba->sli4_hba.wwpn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
8161 phba->nvmet_support = 1; /* a match */ in lpfc_sli4_driver_resource_setup()
8175 phba->cfg_xri_rebalancing = 0; in lpfc_sli4_driver_resource_setup()
8176 if (phba->irq_chann_mode == NHT_MODE) { in lpfc_sli4_driver_resource_setup()
8177 phba->cfg_irq_chann = in lpfc_sli4_driver_resource_setup()
8178 phba->sli4_hba.num_present_cpu; in lpfc_sli4_driver_resource_setup()
8179 phba->cfg_hdw_queue = in lpfc_sli4_driver_resource_setup()
8180 phba->sli4_hba.num_present_cpu; in lpfc_sli4_driver_resource_setup()
8181 phba->irq_chann_mode = NORMAL_MODE; in lpfc_sli4_driver_resource_setup()
8198 &phba->sli4_hba.sli_intf); in lpfc_sli4_driver_resource_setup()
8200 &phba->sli4_hba.sli_intf); in lpfc_sli4_driver_resource_setup()
8201 if (phba->sli4_hba.extents_in_use && in lpfc_sli4_driver_resource_setup()
8202 phba->sli4_hba.rpi_hdrs_in_use) { in lpfc_sli4_driver_resource_setup()
8208 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8209 rc = -EIO; in lpfc_sli4_driver_resource_setup()
8215 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8216 rc = -EIO; in lpfc_sli4_driver_resource_setup()
8226 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_driver_resource_setup()
8240 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) { in lpfc_sli4_driver_resource_setup()
8244 * The scsi_buf for a T10-DIF I/O holds the FCP cmnd, in lpfc_sli4_driver_resource_setup()
8245 * the FCP rsp, and a SGE. Sice we have no control in lpfc_sli4_driver_resource_setup()
8252 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd32) + in lpfc_sli4_driver_resource_setup()
8256 phba->cfg_total_seg_cnt = LPFC_MAX_SGL_SEG_CNT; in lpfc_sli4_driver_resource_setup()
8262 if (phba->cfg_enable_bg && in lpfc_sli4_driver_resource_setup()
8263 phba->cfg_sg_seg_cnt > LPFC_MAX_BG_SLI4_SEG_CNT_DIF) in lpfc_sli4_driver_resource_setup()
8264 phba->cfg_scsi_seg_cnt = LPFC_MAX_BG_SLI4_SEG_CNT_DIF; in lpfc_sli4_driver_resource_setup()
8266 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8274 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd32) + in lpfc_sli4_driver_resource_setup()
8276 ((phba->cfg_sg_seg_cnt + extra) * in lpfc_sli4_driver_resource_setup()
8280 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + extra; in lpfc_sli4_driver_resource_setup()
8281 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8284 * NOTE: if (phba->cfg_sg_seg_cnt + extra) <= 256 we only in lpfc_sli4_driver_resource_setup()
8289 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_driver_resource_setup()
8290 phba->cfg_sg_dma_buf_size = LPFC_DEFAULT_XPSGL_SIZE; in lpfc_sli4_driver_resource_setup()
8291 else if (phba->cfg_sg_dma_buf_size <= LPFC_MIN_SG_SLI4_BUF_SZ) in lpfc_sli4_driver_resource_setup()
8292 phba->cfg_sg_dma_buf_size = LPFC_MIN_SG_SLI4_BUF_SZ; in lpfc_sli4_driver_resource_setup()
8294 phba->cfg_sg_dma_buf_size = in lpfc_sli4_driver_resource_setup()
8295 SLI4_PAGE_ALIGN(phba->cfg_sg_dma_buf_size); in lpfc_sli4_driver_resource_setup()
8297 phba->border_sge_num = phba->cfg_sg_dma_buf_size / in lpfc_sli4_driver_resource_setup()
8301 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
8302 if (phba->cfg_sg_seg_cnt > LPFC_MAX_NVME_SEG_CNT) { in lpfc_sli4_driver_resource_setup()
8307 phba->cfg_nvme_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_sli4_driver_resource_setup()
8309 phba->cfg_nvme_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8315 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
8316 phba->cfg_total_seg_cnt, phba->cfg_scsi_seg_cnt, in lpfc_sli4_driver_resource_setup()
8317 phba->cfg_nvme_seg_cnt); in lpfc_sli4_driver_resource_setup()
8319 if (phba->cfg_sg_dma_buf_size < SLI4_PAGE_SIZE) in lpfc_sli4_driver_resource_setup()
8320 i = phba->cfg_sg_dma_buf_size; in lpfc_sli4_driver_resource_setup()
8324 phba->lpfc_sg_dma_buf_pool = in lpfc_sli4_driver_resource_setup()
8326 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
8327 phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
8329 if (!phba->lpfc_sg_dma_buf_pool) { in lpfc_sli4_driver_resource_setup()
8330 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8334 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli4_driver_resource_setup()
8336 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
8340 if (!phba->lpfc_cmd_rsp_buf_pool) { in lpfc_sli4_driver_resource_setup()
8341 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8345 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8381 longs = (LPFC_SLI4_FCF_TBL_INDX_MAX + BITS_PER_LONG - 1)/BITS_PER_LONG; in lpfc_sli4_driver_resource_setup()
8382 phba->fcf.fcf_rr_bmask = kcalloc(longs, sizeof(unsigned long), in lpfc_sli4_driver_resource_setup()
8384 if (!phba->fcf.fcf_rr_bmask) { in lpfc_sli4_driver_resource_setup()
8388 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8392 phba->sli4_hba.hba_eq_hdl = kcalloc(phba->cfg_irq_chann, in lpfc_sli4_driver_resource_setup()
8395 if (!phba->sli4_hba.hba_eq_hdl) { in lpfc_sli4_driver_resource_setup()
8398 "fast-path per-EQ handle array\n"); in lpfc_sli4_driver_resource_setup()
8399 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8403 phba->sli4_hba.cpu_map = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
8406 if (!phba->sli4_hba.cpu_map) { in lpfc_sli4_driver_resource_setup()
8408 "3327 Failed allocate memory for msi-x " in lpfc_sli4_driver_resource_setup()
8410 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8414 phba->sli4_hba.eq_info = alloc_percpu(struct lpfc_eq_intr_info); in lpfc_sli4_driver_resource_setup()
8415 if (!phba->sli4_hba.eq_info) { in lpfc_sli4_driver_resource_setup()
8418 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8422 phba->sli4_hba.idle_stat = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
8423 sizeof(*phba->sli4_hba.idle_stat), in lpfc_sli4_driver_resource_setup()
8425 if (!phba->sli4_hba.idle_stat) { in lpfc_sli4_driver_resource_setup()
8428 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8433 phba->sli4_hba.c_stat = alloc_percpu(struct lpfc_hdwq_stat); in lpfc_sli4_driver_resource_setup()
8434 if (!phba->sli4_hba.c_stat) { in lpfc_sli4_driver_resource_setup()
8437 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8442 phba->cmf_stat = alloc_percpu(struct lpfc_cgn_stat); in lpfc_sli4_driver_resource_setup()
8443 if (!phba->cmf_stat) { in lpfc_sli4_driver_resource_setup()
8446 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8451 * Enable sr-iov virtual functions if supported and configured in lpfc_sli4_driver_resource_setup()
8454 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli4_driver_resource_setup()
8456 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
8459 "3020 Requested number of SR-IOV " in lpfc_sli4_driver_resource_setup()
8462 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
8463 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli4_driver_resource_setup()
8471 free_percpu(phba->sli4_hba.c_stat); in lpfc_sli4_driver_resource_setup()
8474 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_setup()
8476 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_setup()
8478 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_setup()
8480 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_setup()
8482 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_setup()
8490 dma_pool_destroy(phba->lpfc_cmd_rsp_buf_pool); in lpfc_sli4_driver_resource_setup()
8491 phba->lpfc_cmd_rsp_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
8493 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli4_driver_resource_setup()
8494 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
8500 destroy_workqueue(phba->wq); in lpfc_sli4_driver_resource_setup()
8501 phba->wq = NULL; in lpfc_sli4_driver_resource_setup()
8506 * lpfc_sli4_driver_resource_unset - Unset drvr internal resources for SLI4 dev
8510 * specific for supporting the SLI-4 HBA device it attached to.
8517 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_unset()
8519 free_percpu(phba->sli4_hba.c_stat); in lpfc_sli4_driver_resource_unset()
8521 free_percpu(phba->cmf_stat); in lpfc_sli4_driver_resource_unset()
8522 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_unset()
8524 /* Free memory allocated for msi-x interrupt vector to CPU mapping */ in lpfc_sli4_driver_resource_unset()
8525 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_unset()
8526 phba->sli4_hba.num_possible_cpu = 0; in lpfc_sli4_driver_resource_unset()
8527 phba->sli4_hba.num_present_cpu = 0; in lpfc_sli4_driver_resource_unset()
8528 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_unset()
8529 cpumask_clear(&phba->sli4_hba.irq_aff_mask); in lpfc_sli4_driver_resource_unset()
8531 /* Free memory allocated for fast-path work queue handles */ in lpfc_sli4_driver_resource_unset()
8532 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_unset()
8539 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_unset()
8561 &phba->fcf_conn_rec_list, list) { in lpfc_sli4_driver_resource_unset()
8562 list_del_init(&conn_entry->list); in lpfc_sli4_driver_resource_unset()
8570 * lpfc_init_api_table_setup - Set up init api function jump table
8572 * @dev_grp: The HBA PCI-Device group number.
8577 * Returns: 0 - success, -ENODEV - failure.
8582 phba->lpfc_hba_init_link = lpfc_hba_init_link; in lpfc_init_api_table_setup()
8583 phba->lpfc_hba_down_link = lpfc_hba_down_link; in lpfc_init_api_table_setup()
8584 phba->lpfc_selective_reset = lpfc_selective_reset; in lpfc_init_api_table_setup()
8587 phba->lpfc_hba_down_post = lpfc_hba_down_post_s3; in lpfc_init_api_table_setup()
8588 phba->lpfc_handle_eratt = lpfc_handle_eratt_s3; in lpfc_init_api_table_setup()
8589 phba->lpfc_stop_port = lpfc_stop_port_s3; in lpfc_init_api_table_setup()
8592 phba->lpfc_hba_down_post = lpfc_hba_down_post_s4; in lpfc_init_api_table_setup()
8593 phba->lpfc_handle_eratt = lpfc_handle_eratt_s4; in lpfc_init_api_table_setup()
8594 phba->lpfc_stop_port = lpfc_stop_port_s4; in lpfc_init_api_table_setup()
8598 "1431 Invalid HBA PCI-device group: 0x%x\n", in lpfc_init_api_table_setup()
8600 return -ENODEV; in lpfc_init_api_table_setup()
8606 * lpfc_setup_driver_resource_phase2 - Phase2 setup driver internal resources.
8613 * 0 - successful
8614 * other values - error
8622 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_setup_driver_resource_phase2()
8623 "lpfc_worker_%d", phba->brd_no); in lpfc_setup_driver_resource_phase2()
8624 if (IS_ERR(phba->worker_thread)) { in lpfc_setup_driver_resource_phase2()
8625 error = PTR_ERR(phba->worker_thread); in lpfc_setup_driver_resource_phase2()
8633 * lpfc_unset_driver_resource_phase2 - Phase2 unset driver internal resources.
8643 if (phba->wq) { in lpfc_unset_driver_resource_phase2()
8644 destroy_workqueue(phba->wq); in lpfc_unset_driver_resource_phase2()
8645 phba->wq = NULL; in lpfc_unset_driver_resource_phase2()
8649 if (phba->worker_thread) in lpfc_unset_driver_resource_phase2()
8650 kthread_stop(phba->worker_thread); in lpfc_unset_driver_resource_phase2()
8654 * lpfc_free_iocb_list - Free iocb list.
8664 spin_lock_irq(&phba->hbalock); in lpfc_free_iocb_list()
8666 &phba->lpfc_iocb_list, list) { in lpfc_free_iocb_list()
8667 list_del(&iocbq_entry->list); in lpfc_free_iocb_list()
8669 phba->total_iocbq_bufs--; in lpfc_free_iocb_list()
8671 spin_unlock_irq(&phba->hbalock); in lpfc_free_iocb_list()
8677 * lpfc_init_iocb_list - Allocate and initialize iocb list.
8685 * 0 - successful
8686 * other values - error
8696 INIT_LIST_HEAD(&phba->lpfc_iocb_list); in lpfc_init_iocb_list()
8713 iocbq_entry->sli4_lxritag = NO_XRI; in lpfc_init_iocb_list()
8714 iocbq_entry->sli4_xritag = NO_XRI; in lpfc_init_iocb_list()
8716 spin_lock_irq(&phba->hbalock); in lpfc_init_iocb_list()
8717 list_add(&iocbq_entry->list, &phba->lpfc_iocb_list); in lpfc_init_iocb_list()
8718 phba->total_iocbq_bufs++; in lpfc_init_iocb_list()
8719 spin_unlock_irq(&phba->hbalock); in lpfc_init_iocb_list()
8727 return -ENOMEM; in lpfc_init_iocb_list()
8731 * lpfc_free_sgl_list - Free a given sgl list.
8743 list_del(&sglq_entry->list); in lpfc_free_sgl_list()
8744 lpfc_mbuf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_sgl_list()
8750 * lpfc_free_els_sgl_list - Free els sgl list.
8761 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
8762 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, &sglq_list); in lpfc_free_els_sgl_list()
8763 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
8770 * lpfc_free_nvmet_sgl_list - Free nvmet sgl list.
8782 spin_lock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
8783 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
8784 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, &sglq_list); in lpfc_free_nvmet_sgl_list()
8785 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
8786 spin_unlock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
8790 list_del(&sglq_entry->list); in lpfc_free_nvmet_sgl_list()
8791 lpfc_nvmet_buf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_nvmet_sgl_list()
8795 /* Update the nvmet_xri_cnt to reflect no current sgls. in lpfc_free_nvmet_sgl_list()
8799 phba->sli4_hba.nvmet_xri_cnt = 0; in lpfc_free_nvmet_sgl_list()
8803 * lpfc_init_active_sgl_array - Allocate the buf to track active ELS XRIs.
8814 size *= phba->sli4_hba.max_cfg_param.max_xri; in lpfc_init_active_sgl_array()
8816 phba->sli4_hba.lpfc_sglq_active_list = in lpfc_init_active_sgl_array()
8818 if (!phba->sli4_hba.lpfc_sglq_active_list) in lpfc_init_active_sgl_array()
8819 return -ENOMEM; in lpfc_init_active_sgl_array()
8824 * lpfc_free_active_sgl - Free the buf that tracks active ELS XRIs.
8834 kfree(phba->sli4_hba.lpfc_sglq_active_list); in lpfc_free_active_sgl()
8838 * lpfc_init_sgl_list - Allocate and initialize sgl list.
8849 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_els_sgl_list); in lpfc_init_sgl_list()
8850 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_init_sgl_list()
8851 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_init_sgl_list()
8852 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_init_sgl_list()
8854 /* els xri-sgl book keeping */ in lpfc_init_sgl_list()
8855 phba->sli4_hba.els_xri_cnt = 0; in lpfc_init_sgl_list()
8857 /* nvme xri-buffer book keeping */ in lpfc_init_sgl_list()
8858 phba->sli4_hba.io_xri_cnt = 0; in lpfc_init_sgl_list()
8862 * lpfc_sli4_init_rpi_hdrs - Post the rpi header memory region to the port
8872 * 0 - successful
8873 * -ERROR - otherwise.
8881 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_init_rpi_hdrs()
8882 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_init_rpi_hdrs()
8884 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_init_rpi_hdrs()
8885 return -EIO; in lpfc_sli4_init_rpi_hdrs()
8892 rc = -ENODEV; in lpfc_sli4_init_rpi_hdrs()
8899 * lpfc_sli4_create_rpi_hdr - Allocate an rpi header memory region
8923 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_create_rpi_hdr()
8925 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_create_rpi_hdr()
8929 rpi_limit = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_create_rpi_hdr()
8931 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8937 curr_rpi_range = phba->sli4_hba.next_rpi; in lpfc_sli4_create_rpi_hdr()
8938 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8946 * port expects a 4KB DMA-mapped memory region that is 4K aligned. in lpfc_sli4_create_rpi_hdr()
8952 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_create_rpi_hdr()
8954 &dmabuf->phys, GFP_KERNEL); in lpfc_sli4_create_rpi_hdr()
8955 if (!dmabuf->virt) { in lpfc_sli4_create_rpi_hdr()
8960 if (!IS_ALIGNED(dmabuf->phys, LPFC_HDR_TEMPLATE_SIZE)) { in lpfc_sli4_create_rpi_hdr()
8970 rpi_hdr->dmabuf = dmabuf; in lpfc_sli4_create_rpi_hdr()
8971 rpi_hdr->len = LPFC_HDR_TEMPLATE_SIZE; in lpfc_sli4_create_rpi_hdr()
8972 rpi_hdr->page_count = 1; in lpfc_sli4_create_rpi_hdr()
8973 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8976 rpi_hdr->start_rpi = curr_rpi_range; in lpfc_sli4_create_rpi_hdr()
8977 rpi_hdr->next_rpi = phba->sli4_hba.next_rpi + LPFC_RPI_HDR_COUNT; in lpfc_sli4_create_rpi_hdr()
8978 list_add_tail(&rpi_hdr->list, &phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_create_rpi_hdr()
8980 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8984 dma_free_coherent(&phba->pcidev->dev, LPFC_HDR_TEMPLATE_SIZE, in lpfc_sli4_create_rpi_hdr()
8985 dmabuf->virt, dmabuf->phys); in lpfc_sli4_create_rpi_hdr()
8992 * lpfc_sli4_remove_rpi_hdrs - Remove all rpi header memory regions
9005 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_remove_rpi_hdrs()
9009 &phba->sli4_hba.lpfc_rpi_hdr_list, list) { in lpfc_sli4_remove_rpi_hdrs()
9010 list_del(&rpi_hdr->list); in lpfc_sli4_remove_rpi_hdrs()
9011 dma_free_coherent(&phba->pcidev->dev, rpi_hdr->len, in lpfc_sli4_remove_rpi_hdrs()
9012 rpi_hdr->dmabuf->virt, rpi_hdr->dmabuf->phys); in lpfc_sli4_remove_rpi_hdrs()
9013 kfree(rpi_hdr->dmabuf); in lpfc_sli4_remove_rpi_hdrs()
9017 /* There are no rpis available to the port now. */ in lpfc_sli4_remove_rpi_hdrs()
9018 phba->sli4_hba.next_rpi = 0; in lpfc_sli4_remove_rpi_hdrs()
9022 * lpfc_hba_alloc - Allocate driver hba data structure for a device.
9030 * pointer to @phba - successful
9031 * NULL - error
9041 dev_err(&pdev->dev, "failed to allocate hba struct\n"); in lpfc_hba_alloc()
9046 phba->pcidev = pdev; in lpfc_hba_alloc()
9049 phba->brd_no = lpfc_get_instance(); in lpfc_hba_alloc()
9050 if (phba->brd_no < 0) { in lpfc_hba_alloc()
9054 phba->eratt_poll_interval = LPFC_ERATT_POLL_INTERVAL; in lpfc_hba_alloc()
9056 spin_lock_init(&phba->ct_ev_lock); in lpfc_hba_alloc()
9057 INIT_LIST_HEAD(&phba->ct_ev_waiters); in lpfc_hba_alloc()
9063 * lpfc_hba_free - Free driver hba data structure with a device.
9072 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_hba_free()
9073 kfree(phba->sli4_hba.hdwq); in lpfc_hba_free()
9076 idr_remove(&lpfc_hba_index, phba->brd_no); in lpfc_hba_free()
9079 kfree(phba->sli.sli3_ring); in lpfc_hba_free()
9080 phba->sli.sli3_ring = NULL; in lpfc_hba_free()
9087 * lpfc_setup_fdmi_mask - Setup initial FDMI mask for HBA and Port attributes
9093 * fallback hierarchy is SmartSAN -> FDMI2 -> FMDI1
9098 struct lpfc_hba *phba = vport->phba; in lpfc_setup_fdmi_mask()
9100 set_bit(FC_ALLOW_FDMI, &vport->load_flag); in lpfc_setup_fdmi_mask()
9101 if (phba->cfg_enable_SmartSAN || in lpfc_setup_fdmi_mask()
9102 phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT) { in lpfc_setup_fdmi_mask()
9104 vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR; in lpfc_setup_fdmi_mask()
9105 if (phba->cfg_enable_SmartSAN) in lpfc_setup_fdmi_mask()
9106 vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR; in lpfc_setup_fdmi_mask()
9108 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR; in lpfc_setup_fdmi_mask()
9113 vport->fdmi_hba_mask, vport->fdmi_port_mask); in lpfc_setup_fdmi_mask()
9117 * lpfc_create_shost - Create hba physical port with associated scsi host.
9124 * 0 - successful
9125 * other values - error
9134 phba->fc_edtov = FF_DEF_EDTOV; in lpfc_create_shost()
9135 phba->fc_ratov = FF_DEF_RATOV; in lpfc_create_shost()
9136 phba->fc_altov = FF_DEF_ALTOV; in lpfc_create_shost()
9137 phba->fc_arbtov = FF_DEF_ARBTOV; in lpfc_create_shost()
9139 atomic_set(&phba->sdev_cnt, 0); in lpfc_create_shost()
9140 vport = lpfc_create_port(phba, phba->brd_no, &phba->pcidev->dev); in lpfc_create_shost()
9142 return -ENODEV; in lpfc_create_shost()
9145 phba->pport = vport; in lpfc_create_shost()
9147 if (phba->nvmet_support) { in lpfc_create_shost()
9149 phba->targetport = NULL; in lpfc_create_shost()
9150 phba->cfg_enable_fc4_type = LPFC_ENABLE_NVME; in lpfc_create_shost()
9157 pci_set_drvdata(phba->pcidev, shost); in lpfc_create_shost()
9169 * lpfc_destroy_shost - Destroy hba physical port with associated scsi host.
9178 struct lpfc_vport *vport = phba->pport; in lpfc_destroy_shost()
9187 * lpfc_setup_bg - Setup Block guard structures and debug areas.
9200 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
9205 old_mask = phba->cfg_prot_mask; in lpfc_setup_bg()
9206 old_guard = phba->cfg_prot_guard; in lpfc_setup_bg()
9209 phba->cfg_prot_mask &= (SHOST_DIF_TYPE1_PROTECTION | in lpfc_setup_bg()
9212 phba->cfg_prot_guard &= (SHOST_DIX_GUARD_IP | in lpfc_setup_bg()
9216 if (phba->cfg_prot_mask == SHOST_DIX_TYPE1_PROTECTION) in lpfc_setup_bg()
9217 phba->cfg_prot_mask |= SHOST_DIF_TYPE1_PROTECTION; in lpfc_setup_bg()
9219 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
9220 if ((old_mask != phba->cfg_prot_mask) || in lpfc_setup_bg()
9221 (old_guard != phba->cfg_prot_guard)) in lpfc_setup_bg()
9225 phba->cfg_prot_mask, in lpfc_setup_bg()
9226 phba->cfg_prot_guard); in lpfc_setup_bg()
9228 scsi_host_set_prot(shost, phba->cfg_prot_mask); in lpfc_setup_bg()
9229 scsi_host_set_guard(shost, phba->cfg_prot_guard); in lpfc_setup_bg()
9239 * lpfc_post_init_setup - Perform necessary device post initialization setup.
9252 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_post_init_setup()
9258 shost = pci_get_drvdata(phba->pcidev); in lpfc_post_init_setup()
9259 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_post_init_setup()
9263 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_post_init_setup()
9264 spin_lock_irq(shost->host_lock); in lpfc_post_init_setup()
9266 spin_unlock_irq(shost->host_lock); in lpfc_post_init_setup()
9282 * lpfc_sli_pci_mem_setup - Setup SLI3 HBA PCI memory space.
9286 * with SLI-3 interface spec.
9289 * 0 - successful
9290 * other values - error
9295 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_pci_mem_setup()
9302 return -ENODEV; in lpfc_sli_pci_mem_setup()
9305 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli_pci_mem_setup()
9307 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli_pci_mem_setup()
9310 error = -ENODEV; in lpfc_sli_pci_mem_setup()
9315 phba->pci_bar0_map = pci_resource_start(pdev, 0); in lpfc_sli_pci_mem_setup()
9318 phba->pci_bar2_map = pci_resource_start(pdev, 2); in lpfc_sli_pci_mem_setup()
9322 phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli_pci_mem_setup()
9323 if (!phba->slim_memmap_p) { in lpfc_sli_pci_mem_setup()
9324 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
9330 phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli_pci_mem_setup()
9331 if (!phba->ctrl_regs_memmap_p) { in lpfc_sli_pci_mem_setup()
9332 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
9337 /* Allocate memory for SLI-2 structures */ in lpfc_sli_pci_mem_setup()
9338 phba->slim2p.virt = dma_alloc_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
9339 &phba->slim2p.phys, GFP_KERNEL); in lpfc_sli_pci_mem_setup()
9340 if (!phba->slim2p.virt) in lpfc_sli_pci_mem_setup()
9343 phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx); in lpfc_sli_pci_mem_setup()
9344 phba->mbox_ext = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
9346 phba->pcb = (phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, pcb)); in lpfc_sli_pci_mem_setup()
9347 phba->IOCBs = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
9350 phba->hbqslimp.virt = dma_alloc_coherent(&pdev->dev, in lpfc_sli_pci_mem_setup()
9352 &phba->hbqslimp.phys, in lpfc_sli_pci_mem_setup()
9354 if (!phba->hbqslimp.virt) in lpfc_sli_pci_mem_setup()
9358 ptr = phba->hbqslimp.virt; in lpfc_sli_pci_mem_setup()
9360 phba->hbqs[i].hbq_virt = ptr; in lpfc_sli_pci_mem_setup()
9361 INIT_LIST_HEAD(&phba->hbqs[i].hbq_buffer_list); in lpfc_sli_pci_mem_setup()
9362 ptr += (lpfc_hbq_defs[i]->entry_count * in lpfc_sli_pci_mem_setup()
9365 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_els_hbq_alloc; in lpfc_sli_pci_mem_setup()
9366 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_els_hbq_free; in lpfc_sli_pci_mem_setup()
9368 memset(phba->hbqslimp.virt, 0, lpfc_sli_hbq_size()); in lpfc_sli_pci_mem_setup()
9370 phba->MBslimaddr = phba->slim_memmap_p; in lpfc_sli_pci_mem_setup()
9371 phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9372 phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9373 phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9374 phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9379 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
9380 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_setup()
9382 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_setup()
9384 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_setup()
9390 * lpfc_sli_pci_mem_unset - Unset SLI3 HBA PCI memory space.
9394 * with SLI-3 interface spec.
9402 if (!phba->pcidev) in lpfc_sli_pci_mem_unset()
9405 pdev = phba->pcidev; in lpfc_sli_pci_mem_unset()
9408 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_sli_pci_mem_unset()
9409 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_sli_pci_mem_unset()
9410 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_unset()
9411 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_unset()
9414 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_unset()
9415 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_unset()
9421 * lpfc_sli4_post_status_check - Wait for SLI4 POST done and check status
9427 * Return 0 if successful, otherwise -ENODEV.
9439 if (!phba->sli4_hba.PSMPHRregaddr) in lpfc_sli4_post_status_check()
9440 return -ENODEV; in lpfc_sli4_post_status_check()
9444 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_sli4_post_status_check()
9448 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9463 "1408 Port Failed POST - portsmphr=0x%x, " in lpfc_sli4_post_status_check()
9481 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9483 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9485 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9487 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9489 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9491 &phba->sli4_hba.sli_intf)); in lpfc_sli4_post_status_check()
9498 &phba->sli4_hba.sli_intf); in lpfc_sli4_post_status_check()
9501 phba->sli4_hba.ue_mask_lo = in lpfc_sli4_post_status_check()
9502 readl(phba->sli4_hba.u.if_type0.UEMASKLOregaddr); in lpfc_sli4_post_status_check()
9503 phba->sli4_hba.ue_mask_hi = in lpfc_sli4_post_status_check()
9504 readl(phba->sli4_hba.u.if_type0.UEMASKHIregaddr); in lpfc_sli4_post_status_check()
9506 readl(phba->sli4_hba.u.if_type0.UERRLOregaddr); in lpfc_sli4_post_status_check()
9508 readl(phba->sli4_hba.u.if_type0.UERRHIregaddr); in lpfc_sli4_post_status_check()
9509 if ((~phba->sli4_hba.ue_mask_lo & uerrlo_reg.word0) || in lpfc_sli4_post_status_check()
9510 (~phba->sli4_hba.ue_mask_hi & uerrhi_reg.word0)) { in lpfc_sli4_post_status_check()
9521 phba->sli4_hba.ue_mask_lo, in lpfc_sli4_post_status_check()
9522 phba->sli4_hba.ue_mask_hi); in lpfc_sli4_post_status_check()
9523 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9529 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_post_status_check()
9532 phba->work_status[0] = in lpfc_sli4_post_status_check()
9533 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
9535 phba->work_status[1] = in lpfc_sli4_post_status_check()
9536 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
9545 phba->work_status[0], in lpfc_sli4_post_status_check()
9546 phba->work_status[1]); in lpfc_sli4_post_status_check()
9547 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9553 &phba->sli4_hba.sli_intf) == in lpfc_sli4_post_status_check()
9555 pci_write_config_byte(phba->pcidev, in lpfc_sli4_post_status_check()
9567 * lpfc_sli4_bar0_register_memmap - Set up SLI4 BAR0 register memory map.
9579 phba->sli4_hba.u.if_type0.UERRLOregaddr = in lpfc_sli4_bar0_register_memmap()
9580 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_LO; in lpfc_sli4_bar0_register_memmap()
9581 phba->sli4_hba.u.if_type0.UERRHIregaddr = in lpfc_sli4_bar0_register_memmap()
9582 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_HI; in lpfc_sli4_bar0_register_memmap()
9583 phba->sli4_hba.u.if_type0.UEMASKLOregaddr = in lpfc_sli4_bar0_register_memmap()
9584 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_LO; in lpfc_sli4_bar0_register_memmap()
9585 phba->sli4_hba.u.if_type0.UEMASKHIregaddr = in lpfc_sli4_bar0_register_memmap()
9586 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_HI; in lpfc_sli4_bar0_register_memmap()
9587 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
9588 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
9591 phba->sli4_hba.u.if_type2.EQDregaddr = in lpfc_sli4_bar0_register_memmap()
9592 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9594 phba->sli4_hba.u.if_type2.ERR1regaddr = in lpfc_sli4_bar0_register_memmap()
9595 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9597 phba->sli4_hba.u.if_type2.ERR2regaddr = in lpfc_sli4_bar0_register_memmap()
9598 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9600 phba->sli4_hba.u.if_type2.CTRLregaddr = 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.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
9604 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9606 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
9607 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
9608 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
9609 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9611 phba->sli4_hba.RQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9612 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9614 phba->sli4_hba.WQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9615 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9617 phba->sli4_hba.CQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9618 phba->sli4_hba.conf_regs_memmap_p + LPFC_EQCQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
9619 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar0_register_memmap()
9620 phba->sli4_hba.MQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9621 phba->sli4_hba.conf_regs_memmap_p + LPFC_MQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
9622 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
9623 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
9626 phba->sli4_hba.u.if_type2.EQDregaddr = in lpfc_sli4_bar0_register_memmap()
9627 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9629 phba->sli4_hba.u.if_type2.ERR1regaddr = in lpfc_sli4_bar0_register_memmap()
9630 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9632 phba->sli4_hba.u.if_type2.ERR2regaddr = in lpfc_sli4_bar0_register_memmap()
9633 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9635 phba->sli4_hba.u.if_type2.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
9636 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9638 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
9639 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9641 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
9642 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9644 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
9645 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
9649 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_bar0_register_memmap()
9650 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar0_register_memmap()
9657 * lpfc_sli4_bar1_register_memmap - Set up SLI4 BAR1 register memory map.
9668 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar1_register_memmap()
9669 phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9671 phba->sli4_hba.ISRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9673 phba->sli4_hba.IMRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9675 phba->sli4_hba.ISCRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9679 phba->sli4_hba.RQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9681 phba->sli4_hba.WQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9683 phba->sli4_hba.CQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9685 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9687 phba->sli4_hba.MQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9693 dev_err(&phba->pcidev->dev, in lpfc_sli4_bar1_register_memmap()
9694 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar1_register_memmap()
9701 * lpfc_sli4_bar2_register_memmap - Set up SLI4 BAR2 register memory map.
9708 * Return 0 if successful, otherwise -ENODEV.
9714 return -ENODEV; in lpfc_sli4_bar2_register_memmap()
9716 phba->sli4_hba.RQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9719 phba->sli4_hba.WQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9722 phba->sli4_hba.CQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9725 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar2_register_memmap()
9726 phba->sli4_hba.MQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9728 phba->sli4_hba.BMBXregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9734 * lpfc_create_bootstrap_mbox - Create the bootstrap mailbox
9738 * region consistent with the SLI-4 interface spec. This
9741 * needs. No locks are expected to be held when calling
9745 * 0 - successful
9746 * -ENOMEM - could not allocated memory.
9759 return -ENOMEM; in lpfc_create_bootstrap_mbox()
9765 bmbx_size = sizeof(struct lpfc_bmbx_create) + (LPFC_ALIGN_16_BYTE - 1); in lpfc_create_bootstrap_mbox()
9766 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, bmbx_size, in lpfc_create_bootstrap_mbox()
9767 &dmabuf->phys, GFP_KERNEL); in lpfc_create_bootstrap_mbox()
9768 if (!dmabuf->virt) { in lpfc_create_bootstrap_mbox()
9770 return -ENOMEM; in lpfc_create_bootstrap_mbox()
9776 * to be 16-byte aligned. Also align the virtual memory as each in lpfc_create_bootstrap_mbox()
9780 phba->sli4_hba.bmbx.dmabuf = dmabuf; in lpfc_create_bootstrap_mbox()
9781 phba->sli4_hba.bmbx.bmbx_size = bmbx_size; in lpfc_create_bootstrap_mbox()
9783 phba->sli4_hba.bmbx.avirt = PTR_ALIGN(dmabuf->virt, in lpfc_create_bootstrap_mbox()
9785 phba->sli4_hba.bmbx.aphys = ALIGN(dmabuf->phys, in lpfc_create_bootstrap_mbox()
9791 * as two 30-bit addresses. The other data is a bit marking whether in lpfc_create_bootstrap_mbox()
9792 * the 30-bit address is the high or low address. in lpfc_create_bootstrap_mbox()
9796 dma_address = &phba->sli4_hba.bmbx.dma_address; in lpfc_create_bootstrap_mbox()
9797 phys_addr = (uint64_t)phba->sli4_hba.bmbx.aphys; in lpfc_create_bootstrap_mbox()
9799 dma_address->addr_hi = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
9802 pa_addr = (uint32_t) ((phba->sli4_hba.bmbx.aphys >> 4) & 0x3fffffff); in lpfc_create_bootstrap_mbox()
9803 dma_address->addr_lo = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
9809 * lpfc_destroy_bootstrap_mbox - Destroy all bootstrap mailbox resources
9814 * the caller to ensure all mailbox commands recovered, no
9822 dma_free_coherent(&phba->pcidev->dev, in lpfc_destroy_bootstrap_mbox()
9823 phba->sli4_hba.bmbx.bmbx_size, in lpfc_destroy_bootstrap_mbox()
9824 phba->sli4_hba.bmbx.dmabuf->virt, in lpfc_destroy_bootstrap_mbox()
9825 phba->sli4_hba.bmbx.dmabuf->phys); in lpfc_destroy_bootstrap_mbox()
9827 kfree(phba->sli4_hba.bmbx.dmabuf); in lpfc_destroy_bootstrap_mbox()
9828 memset(&phba->sli4_hba.bmbx, 0, sizeof(struct lpfc_bmbx)); in lpfc_destroy_bootstrap_mbox()
9845 * lpfc_map_topology - Map the topology read from READ_CONFIG
9870 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9873 /* FW supports persistent topology - override module parameter value */ in lpfc_map_topology()
9874 set_bit(HBA_PERSISTENT_TOPO, &phba->hba_flag); in lpfc_map_topology()
9877 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_map_topology()
9879 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_map_topology()
9882 phba->cfg_topology = ((pt == LINK_FLAGS_LOOP) in lpfc_map_topology()
9886 clear_bit(HBA_PERSISTENT_TOPO, &phba->hba_flag); in lpfc_map_topology()
9889 /* If topology failover set - pt is '0' or '1' */ in lpfc_map_topology()
9890 phba->cfg_topology = (pt ? FLAGS_TOPOLOGY_MODE_PT_LOOP : in lpfc_map_topology()
9893 phba->cfg_topology = ((pt == LINK_FLAGS_P2P) in lpfc_map_topology()
9897 if (test_bit(HBA_PERSISTENT_TOPO, &phba->hba_flag)) in lpfc_map_topology()
9900 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9905 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9909 * lpfc_sli4_read_config - Get the config parameters.
9918 * 0 - successful
9919 * -ENOMEM - No available memory
9920 * -EIO - The mailbox failed to complete successfully.
9936 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_read_config()
9941 return -ENOMEM; in lpfc_sli4_read_config()
9951 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
9952 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
9953 rc = -EIO; in lpfc_sli4_read_config()
9955 rd_config = &pmb->u.mqe.un.rd_config; in lpfc_sli4_read_config()
9957 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_VAL; in lpfc_sli4_read_config()
9958 phba->sli4_hba.lnk_info.lnk_tp = in lpfc_sli4_read_config()
9960 phba->sli4_hba.lnk_info.lnk_no = in lpfc_sli4_read_config()
9964 phba->sli4_hba.lnk_info.lnk_tp, in lpfc_sli4_read_config()
9965 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_read_config()
9969 bf_get(lpfc_mqe_command, &pmb->u.mqe)); in lpfc_sli4_read_config()
9971 phba->bbcredit_support = 1; in lpfc_sli4_read_config()
9972 phba->sli4_hba.bbscn_params.word0 = rd_config->word8; in lpfc_sli4_read_config()
9980 "2702 READ_CONFIG: FA-PWWN is " in lpfc_sli4_read_config()
9982 phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_CONFIG; in lpfc_sli4_read_config()
9985 phba->sli4_hba.fawwpn_flag &= ~LPFC_FAWWPN_CONFIG; in lpfc_sli4_read_config()
9988 phba->sli4_hba.conf_trunk = in lpfc_sli4_read_config()
9990 phba->sli4_hba.extents_in_use = in lpfc_sli4_read_config()
9993 phba->sli4_hba.max_cfg_param.max_xri = in lpfc_sli4_read_config()
9997 phba->sli4_hba.max_cfg_param.max_xri > 512) in lpfc_sli4_read_config()
9998 phba->sli4_hba.max_cfg_param.max_xri = 512; in lpfc_sli4_read_config()
9999 phba->sli4_hba.max_cfg_param.xri_base = in lpfc_sli4_read_config()
10001 phba->sli4_hba.max_cfg_param.max_vpi = in lpfc_sli4_read_config()
10004 if (phba->sli4_hba.max_cfg_param.max_vpi > LPFC_MAX_VPORTS) in lpfc_sli4_read_config()
10005 phba->sli4_hba.max_cfg_param.max_vpi = LPFC_MAX_VPORTS; in lpfc_sli4_read_config()
10006 phba->sli4_hba.max_cfg_param.vpi_base = in lpfc_sli4_read_config()
10008 phba->sli4_hba.max_cfg_param.max_rpi = in lpfc_sli4_read_config()
10010 phba->sli4_hba.max_cfg_param.rpi_base = in lpfc_sli4_read_config()
10012 phba->sli4_hba.max_cfg_param.max_vfi = in lpfc_sli4_read_config()
10014 phba->sli4_hba.max_cfg_param.vfi_base = in lpfc_sli4_read_config()
10016 phba->sli4_hba.max_cfg_param.max_fcfi = in lpfc_sli4_read_config()
10018 phba->sli4_hba.max_cfg_param.max_eq = in lpfc_sli4_read_config()
10020 phba->sli4_hba.max_cfg_param.max_rq = in lpfc_sli4_read_config()
10022 phba->sli4_hba.max_cfg_param.max_wq = in lpfc_sli4_read_config()
10024 phba->sli4_hba.max_cfg_param.max_cq = in lpfc_sli4_read_config()
10026 phba->lmt = bf_get(lpfc_mbx_rd_conf_lmt, rd_config); in lpfc_sli4_read_config()
10027 phba->sli4_hba.next_xri = phba->sli4_hba.max_cfg_param.xri_base; in lpfc_sli4_read_config()
10028 phba->vpi_base = phba->sli4_hba.max_cfg_param.vpi_base; in lpfc_sli4_read_config()
10029 phba->vfi_base = phba->sli4_hba.max_cfg_param.vfi_base; in lpfc_sli4_read_config()
10030 phba->max_vpi = (phba->sli4_hba.max_cfg_param.max_vpi > 0) ? in lpfc_sli4_read_config()
10031 (phba->sli4_hba.max_cfg_param.max_vpi - 1) : 0; in lpfc_sli4_read_config()
10032 phba->max_vports = phba->max_vpi; in lpfc_sli4_read_config()
10043 phba->cgn_reg_fpin = LPFC_CGN_FPIN_BOTH; in lpfc_sli4_read_config()
10044 phba->cgn_reg_signal = EDC_CG_SIG_NOTSUPPORTED; in lpfc_sli4_read_config()
10045 phba->cgn_sig_freq = lpfc_fabric_cgn_frequency; in lpfc_sli4_read_config()
10049 phba->cgn_reg_signal = EDC_CG_SIG_WARN_ONLY; in lpfc_sli4_read_config()
10050 phba->cgn_reg_fpin &= ~LPFC_CGN_FPIN_WARN; in lpfc_sli4_read_config()
10056 if (phba->cgn_reg_signal != in lpfc_sli4_read_config()
10059 phba->cgn_reg_fpin = LPFC_CGN_FPIN_BOTH; in lpfc_sli4_read_config()
10060 phba->cgn_reg_signal = in lpfc_sli4_read_config()
10063 phba->cgn_reg_signal = in lpfc_sli4_read_config()
10065 phba->cgn_reg_fpin = in lpfc_sli4_read_config()
10072 phba->cgn_init_reg_fpin = phba->cgn_reg_fpin; in lpfc_sli4_read_config()
10073 phba->cgn_init_reg_signal = phba->cgn_reg_signal; in lpfc_sli4_read_config()
10077 phba->cgn_reg_signal, phba->cgn_reg_fpin); in lpfc_sli4_read_config()
10087 phba->sli4_hba.extents_in_use, in lpfc_sli4_read_config()
10088 phba->sli4_hba.max_cfg_param.xri_base, in lpfc_sli4_read_config()
10089 phba->sli4_hba.max_cfg_param.max_xri, in lpfc_sli4_read_config()
10090 phba->sli4_hba.max_cfg_param.vpi_base, in lpfc_sli4_read_config()
10091 phba->sli4_hba.max_cfg_param.max_vpi, in lpfc_sli4_read_config()
10092 phba->sli4_hba.max_cfg_param.vfi_base, in lpfc_sli4_read_config()
10093 phba->sli4_hba.max_cfg_param.max_vfi, in lpfc_sli4_read_config()
10094 phba->sli4_hba.max_cfg_param.rpi_base, in lpfc_sli4_read_config()
10095 phba->sli4_hba.max_cfg_param.max_rpi, in lpfc_sli4_read_config()
10096 phba->sli4_hba.max_cfg_param.max_fcfi, in lpfc_sli4_read_config()
10097 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
10098 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
10099 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
10100 phba->sli4_hba.max_cfg_param.max_rq, in lpfc_sli4_read_config()
10101 phba->lmt); in lpfc_sli4_read_config()
10107 qmin = phba->sli4_hba.max_cfg_param.max_wq; in lpfc_sli4_read_config()
10108 if (phba->sli4_hba.max_cfg_param.max_cq < qmin) in lpfc_sli4_read_config()
10109 qmin = phba->sli4_hba.max_cfg_param.max_cq; in lpfc_sli4_read_config()
10114 qmin -= 4; in lpfc_sli4_read_config()
10115 if (phba->sli4_hba.max_cfg_param.max_eq < qmin) in lpfc_sli4_read_config()
10116 qmin = phba->sli4_hba.max_cfg_param.max_eq; in lpfc_sli4_read_config()
10119 if ((phba->cfg_irq_chann > qmin) || in lpfc_sli4_read_config()
10120 (phba->cfg_hdw_queue > qmin)) { in lpfc_sli4_read_config()
10122 "2005 Reducing Queues - " in lpfc_sli4_read_config()
10126 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
10127 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
10128 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
10129 qmin, phba->cfg_irq_chann, in lpfc_sli4_read_config()
10130 phba->cfg_hdw_queue); in lpfc_sli4_read_config()
10132 if (phba->cfg_irq_chann > qmin) in lpfc_sli4_read_config()
10133 phba->cfg_irq_chann = qmin; in lpfc_sli4_read_config()
10134 if (phba->cfg_hdw_queue > qmin) in lpfc_sli4_read_config()
10135 phba->cfg_hdw_queue = qmin; in lpfc_sli4_read_config()
10143 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_read_config()
10148 set_bit(HBA_FORCED_LINK_SPEED, &phba->hba_flag); in lpfc_sli4_read_config()
10152 phba->cfg_link_speed = in lpfc_sli4_read_config()
10156 phba->cfg_link_speed = in lpfc_sli4_read_config()
10160 phba->cfg_link_speed = in lpfc_sli4_read_config()
10164 phba->cfg_link_speed = in lpfc_sli4_read_config()
10168 phba->cfg_link_speed = in lpfc_sli4_read_config()
10172 phba->cfg_link_speed = in lpfc_sli4_read_config()
10176 phba->cfg_link_speed = in lpfc_sli4_read_config()
10180 phba->cfg_link_speed = in lpfc_sli4_read_config()
10184 phba->cfg_link_speed = in lpfc_sli4_read_config()
10193 phba->cfg_link_speed = in lpfc_sli4_read_config()
10200 length = phba->sli4_hba.max_cfg_param.max_xri - in lpfc_sli4_read_config()
10202 if (phba->cfg_hba_queue_depth > length) { in lpfc_sli4_read_config()
10205 phba->cfg_hba_queue_depth, length); in lpfc_sli4_read_config()
10206 phba->cfg_hba_queue_depth = length; in lpfc_sli4_read_config()
10209 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_read_config()
10214 length = (sizeof(struct lpfc_mbx_get_func_cfg) - in lpfc_sli4_read_config()
10222 &pmb->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_read_config()
10223 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_read_config()
10224 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_read_config()
10229 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
10230 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
10235 get_func_cfg = &pmb->u.mqe.un.get_func_cfg; in lpfc_sli4_read_config()
10237 pdesc_0 = (char *)&get_func_cfg->func_cfg.desc[0]; in lpfc_sli4_read_config()
10249 phba->sli4_hba.iov.pf_number = in lpfc_sli4_read_config()
10251 phba->sli4_hba.iov.vf_number = in lpfc_sli4_read_config()
10260 "vf_number:%d\n", phba->sli4_hba.iov.pf_number, in lpfc_sli4_read_config()
10261 phba->sli4_hba.iov.vf_number); in lpfc_sli4_read_config()
10269 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_read_config()
10274 * lpfc_setup_endian_order - Write endian order to an SLI4 if_type 0 port.
10277 * This routine is invoked to setup the port-side endian order when
10278 * the port if_type is 0. This routine has no function for other
10282 * 0 - successful
10283 * -ENOMEM - No available memory
10284 * -EIO - The mailbox failed to complete successfully.
10294 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_setup_endian_order()
10297 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_setup_endian_order()
10304 return -ENOMEM; in lpfc_setup_endian_order()
10309 * two words to contain special data values and no other data. in lpfc_setup_endian_order()
10312 memcpy(&mboxq->u.mqe, &endian_mb_data, sizeof(endian_mb_data)); in lpfc_setup_endian_order()
10319 rc = -EIO; in lpfc_setup_endian_order()
10321 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_setup_endian_order()
10333 * lpfc_sli4_queue_verify - Verify and update EQ counts
10342 * 0 - successful
10343 * -ENOMEM - No available memory
10349 * Sanity check for configured queue parameters against the run-time in lpfc_sli4_queue_verify()
10353 if (phba->nvmet_support) { in lpfc_sli4_queue_verify()
10354 if (phba->cfg_hdw_queue < phba->cfg_nvmet_mrq) in lpfc_sli4_queue_verify()
10355 phba->cfg_nvmet_mrq = phba->cfg_hdw_queue; in lpfc_sli4_queue_verify()
10356 if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX) in lpfc_sli4_queue_verify()
10357 phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX; in lpfc_sli4_queue_verify()
10362 phba->cfg_hdw_queue, phba->cfg_irq_chann, in lpfc_sli4_queue_verify()
10363 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_verify()
10366 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_verify()
10367 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_verify()
10370 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_verify()
10371 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_verify()
10384 if (phba->enab_exp_wqcq_pages) in lpfc_alloc_io_wq_cq()
10387 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
10392 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
10393 phba->sli4_hba.cq_ecount, cpu); in lpfc_alloc_io_wq_cq()
10396 "0499 Failed allocate fast-path IO CQ (%d)\n", in lpfc_alloc_io_wq_cq()
10400 qdesc->qe_valid = 1; in lpfc_alloc_io_wq_cq()
10401 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
10402 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
10403 phba->sli4_hba.hdwq[idx].io_cq = qdesc; in lpfc_alloc_io_wq_cq()
10406 if (phba->enab_exp_wqcq_pages) { in lpfc_alloc_io_wq_cq()
10408 wqesize = (phba->fcp_embed_io) ? in lpfc_alloc_io_wq_cq()
10409 LPFC_WQE128_SIZE : phba->sli4_hba.wq_esize; in lpfc_alloc_io_wq_cq()
10415 phba->sli4_hba.wq_esize, in lpfc_alloc_io_wq_cq()
10416 phba->sli4_hba.wq_ecount, cpu); in lpfc_alloc_io_wq_cq()
10420 "0503 Failed allocate fast-path IO WQ (%d)\n", in lpfc_alloc_io_wq_cq()
10424 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
10425 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
10426 phba->sli4_hba.hdwq[idx].io_wq = qdesc; in lpfc_alloc_io_wq_cq()
10427 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_alloc_io_wq_cq()
10432 * lpfc_sli4_queue_create - Create all the SLI4 queues
10441 * 0 - successful
10442 * -ENOMEM - No availble memory
10443 * -EIO - The mailbox failed to complete successfully.
10460 phba->sli4_hba.mq_esize = LPFC_MQE_SIZE; in lpfc_sli4_queue_create()
10461 phba->sli4_hba.mq_ecount = LPFC_MQE_DEF_COUNT; in lpfc_sli4_queue_create()
10462 phba->sli4_hba.wq_esize = LPFC_WQE_SIZE; in lpfc_sli4_queue_create()
10463 phba->sli4_hba.wq_ecount = LPFC_WQE_DEF_COUNT; in lpfc_sli4_queue_create()
10464 phba->sli4_hba.rq_esize = LPFC_RQE_SIZE; in lpfc_sli4_queue_create()
10465 phba->sli4_hba.rq_ecount = LPFC_RQE_DEF_COUNT; in lpfc_sli4_queue_create()
10466 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_create()
10467 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_create()
10468 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_create()
10469 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_create()
10471 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
10472 phba->sli4_hba.hdwq = kcalloc( in lpfc_sli4_queue_create()
10473 phba->cfg_hdw_queue, sizeof(struct lpfc_sli4_hdw_queue), in lpfc_sli4_queue_create()
10475 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
10478 "fast-path Hardware Queue array\n"); in lpfc_sli4_queue_create()
10482 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10483 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_queue_create()
10484 spin_lock_init(&qp->io_buf_list_get_lock); in lpfc_sli4_queue_create()
10485 spin_lock_init(&qp->io_buf_list_put_lock); in lpfc_sli4_queue_create()
10486 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_sli4_queue_create()
10487 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_sli4_queue_create()
10488 qp->get_io_bufs = 0; in lpfc_sli4_queue_create()
10489 qp->put_io_bufs = 0; in lpfc_sli4_queue_create()
10490 qp->total_io_bufs = 0; in lpfc_sli4_queue_create()
10491 spin_lock_init(&qp->abts_io_buf_list_lock); in lpfc_sli4_queue_create()
10492 INIT_LIST_HEAD(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_queue_create()
10493 qp->abts_scsi_io_bufs = 0; in lpfc_sli4_queue_create()
10494 qp->abts_nvme_io_bufs = 0; in lpfc_sli4_queue_create()
10495 INIT_LIST_HEAD(&qp->sgl_list); in lpfc_sli4_queue_create()
10496 INIT_LIST_HEAD(&qp->cmd_rsp_buf_list); in lpfc_sli4_queue_create()
10497 spin_lock_init(&qp->hdwq_lock); in lpfc_sli4_queue_create()
10501 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10502 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
10503 phba->sli4_hba.nvmet_cqset = kcalloc( in lpfc_sli4_queue_create()
10504 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10507 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_create()
10510 "fast-path CQ set array\n"); in lpfc_sli4_queue_create()
10513 phba->sli4_hba.nvmet_mrq_hdr = kcalloc( in lpfc_sli4_queue_create()
10514 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10517 if (!phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_create()
10520 "fast-path RQ set hdr array\n"); in lpfc_sli4_queue_create()
10523 phba->sli4_hba.nvmet_mrq_data = kcalloc( in lpfc_sli4_queue_create()
10524 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10527 if (!phba->sli4_hba.nvmet_mrq_data) { in lpfc_sli4_queue_create()
10530 "fast-path RQ set data array\n"); in lpfc_sli4_queue_create()
10536 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10544 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
10545 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_create()
10549 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
10553 phba->sli4_hba.eq_esize, in lpfc_sli4_queue_create()
10554 phba->sli4_hba.eq_ecount, cpu); in lpfc_sli4_queue_create()
10558 cpup->hdwq); in lpfc_sli4_queue_create()
10561 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10562 qdesc->hdwq = cpup->hdwq; in lpfc_sli4_queue_create()
10563 qdesc->chann = cpu; /* First CPU this EQ is affinitized to */ in lpfc_sli4_queue_create()
10564 qdesc->last_cpu = qdesc->chann; in lpfc_sli4_queue_create()
10567 qp->hba_eq = qdesc; in lpfc_sli4_queue_create()
10569 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, qdesc->last_cpu); in lpfc_sli4_queue_create()
10570 list_add(&qdesc->cpu_list, &eqi->list); in lpfc_sli4_queue_create()
10577 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
10580 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_sli4_queue_create()
10584 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
10585 if (qp->hba_eq) in lpfc_sli4_queue_create()
10589 eqcpu = lpfc_find_cpu_handle(phba, cpup->eq, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
10590 eqcpup = &phba->sli4_hba.cpu_map[eqcpu]; in lpfc_sli4_queue_create()
10591 qp->hba_eq = phba->sli4_hba.hdwq[eqcpup->hdwq].hba_eq; in lpfc_sli4_queue_create()
10595 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10600 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
10601 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
10606 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10607 phba->sli4_hba.cq_ecount, in lpfc_sli4_queue_create()
10615 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10616 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10617 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10618 phba->sli4_hba.nvmet_cqset[idx] = qdesc; in lpfc_sli4_queue_create()
10627 /* Create slow-path Mailbox Command Complete Queue */ in lpfc_sli4_queue_create()
10629 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10630 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10633 "0500 Failed allocate slow-path mailbox CQ\n"); in lpfc_sli4_queue_create()
10636 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10637 phba->sli4_hba.mbx_cq = qdesc; in lpfc_sli4_queue_create()
10639 /* Create slow-path ELS Complete Queue */ in lpfc_sli4_queue_create()
10641 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10642 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10645 "0501 Failed allocate slow-path ELS CQ\n"); in lpfc_sli4_queue_create()
10648 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10649 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10650 phba->sli4_hba.els_cq = qdesc; in lpfc_sli4_queue_create()
10660 phba->sli4_hba.mq_esize, in lpfc_sli4_queue_create()
10661 phba->sli4_hba.mq_ecount, cpu); in lpfc_sli4_queue_create()
10664 "0505 Failed allocate slow-path MQ\n"); in lpfc_sli4_queue_create()
10667 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10668 phba->sli4_hba.mbx_wq = qdesc; in lpfc_sli4_queue_create()
10675 * Create slow-path ELS Work Queue. in lpfc_sli4_queue_create()
10678 wqesize = (phba->fcp_embed_io) ? in lpfc_sli4_queue_create()
10679 LPFC_WQE128_SIZE : phba->sli4_hba.wq_esize; in lpfc_sli4_queue_create()
10683 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
10686 "0504 Failed allocate slow-path ELS WQ\n"); in lpfc_sli4_queue_create()
10689 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10690 phba->sli4_hba.els_wq = qdesc; in lpfc_sli4_queue_create()
10691 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10693 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10696 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10697 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10703 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10704 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10705 phba->sli4_hba.nvmels_cq = qdesc; in lpfc_sli4_queue_create()
10709 phba->sli4_hba.wq_esize, in lpfc_sli4_queue_create()
10710 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
10716 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10717 phba->sli4_hba.nvmels_wq = qdesc; in lpfc_sli4_queue_create()
10718 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10727 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10728 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
10734 phba->sli4_hba.hdr_rq = qdesc; in lpfc_sli4_queue_create()
10738 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10739 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
10745 phba->sli4_hba.dat_rq = qdesc; in lpfc_sli4_queue_create()
10747 if ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) && in lpfc_sli4_queue_create()
10748 phba->nvmet_support) { in lpfc_sli4_queue_create()
10749 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
10755 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10764 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10765 phba->sli4_hba.nvmet_mrq_hdr[idx] = qdesc; in lpfc_sli4_queue_create()
10768 qdesc->rqbp = kzalloc_node(sizeof(*qdesc->rqbp), in lpfc_sli4_queue_create()
10771 if (qdesc->rqbp == NULL) { in lpfc_sli4_queue_create()
10779 INIT_LIST_HEAD(&qdesc->rqbp->rqb_buffer_list); in lpfc_sli4_queue_create()
10784 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10793 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10794 phba->sli4_hba.nvmet_mrq_data[idx] = qdesc; in lpfc_sli4_queue_create()
10799 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10800 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10801 memset(&phba->sli4_hba.hdwq[idx].nvme_cstat, 0, in lpfc_sli4_queue_create()
10802 sizeof(phba->sli4_hba.hdwq[idx].nvme_cstat)); in lpfc_sli4_queue_create()
10807 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { in lpfc_sli4_queue_create()
10808 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10809 memset(&phba->sli4_hba.hdwq[idx].scsi_cstat, 0, in lpfc_sli4_queue_create()
10810 sizeof(phba->sli4_hba.hdwq[idx].scsi_cstat)); in lpfc_sli4_queue_create()
10818 return -ENOMEM; in lpfc_sli4_queue_create()
10852 hdwq = phba->sli4_hba.hdwq; in lpfc_sli4_release_hdwq()
10855 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_release_hdwq()
10862 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_release_hdwq()
10867 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_release_hdwq()
10869 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_sli4_release_hdwq()
10871 phba->sli4_hba.hba_eq_hdl[idx].eq = NULL; in lpfc_sli4_release_hdwq()
10876 * lpfc_sli4_queue_destroy - Destroy all the SLI4 queues
10883 * 0 - successful
10884 * -ENOMEM - No available memory
10885 * -EIO - The mailbox failed to complete successfully.
10895 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10896 phba->sli.sli_flag |= LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
10897 while (phba->sli.sli_flag & LPFC_QUEUE_FREE_WAIT) { in lpfc_sli4_queue_destroy()
10898 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10900 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10902 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10907 if (phba->sli4_hba.hdwq) in lpfc_sli4_queue_destroy()
10910 if (phba->nvmet_support) { in lpfc_sli4_queue_destroy()
10911 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_destroy()
10912 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10914 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_destroy()
10915 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10916 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_destroy()
10917 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10921 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_destroy()
10924 __lpfc_sli4_release_queue(&phba->sli4_hba.els_wq); in lpfc_sli4_queue_destroy()
10927 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_destroy()
10930 __lpfc_sli4_release_queue(&phba->sli4_hba.hdr_rq); in lpfc_sli4_queue_destroy()
10931 __lpfc_sli4_release_queue(&phba->sli4_hba.dat_rq); in lpfc_sli4_queue_destroy()
10934 __lpfc_sli4_release_queue(&phba->sli4_hba.els_cq); in lpfc_sli4_queue_destroy()
10937 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_destroy()
10940 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_destroy()
10943 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_destroy()
10946 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10947 phba->sli.sli_flag &= ~LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
10948 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10958 rqbp = rq->rqbp; in lpfc_free_rq_buffer()
10959 while (!list_empty(&rqbp->rqb_buffer_list)) { in lpfc_free_rq_buffer()
10960 list_remove_head(&rqbp->rqb_buffer_list, h_buf, in lpfc_free_rq_buffer()
10964 (rqbp->rqb_free_buffer)(phba, rqb_buffer); in lpfc_free_rq_buffer()
10965 rqbp->buffer_count--; in lpfc_free_rq_buffer()
10980 "6085 Fast-path %s (%d) not allocated\n", in lpfc_create_wq_cq()
10982 return -ENOMEM; in lpfc_create_wq_cq()
10998 *cq_map = cq->queue_id; in lpfc_create_wq_cq()
11001 "6087 CQ setup: cq[%d]-id=%d, parent eq[%d]-id=%d\n", in lpfc_create_wq_cq()
11002 qidx, cq->queue_id, qidx, eq->queue_id); in lpfc_create_wq_cq()
11010 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
11015 pring = wq->pring; in lpfc_create_wq_cq()
11016 pring->sli.sli4.wqp = (void *)wq; in lpfc_create_wq_cq()
11017 cq->pring = pring; in lpfc_create_wq_cq()
11020 "2593 WQ setup: wq[%d]-id=%d assoc=%d, cq[%d]-id=%d\n", in lpfc_create_wq_cq()
11021 qidx, wq->queue_id, wq->assoc_qid, qidx, cq->queue_id); in lpfc_create_wq_cq()
11026 "0539 Failed setup of slow-path MQ: " in lpfc_create_wq_cq()
11028 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
11033 "2589 MBX MQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_create_wq_cq()
11034 phba->sli4_hba.mbx_wq->queue_id, in lpfc_create_wq_cq()
11035 phba->sli4_hba.mbx_cq->queue_id); in lpfc_create_wq_cq()
11042 * lpfc_setup_cq_lookup - Setup the CQ lookup table
11054 memset(phba->sli4_hba.cq_lookup, 0, in lpfc_setup_cq_lookup()
11055 (sizeof(struct lpfc_queue *) * (phba->sli4_hba.cq_max + 1))); in lpfc_setup_cq_lookup()
11057 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_setup_cq_lookup()
11059 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_setup_cq_lookup()
11063 list_for_each_entry(childq, &eq->child_list, list) { in lpfc_setup_cq_lookup()
11064 if (childq->queue_id > phba->sli4_hba.cq_max) in lpfc_setup_cq_lookup()
11066 if (childq->subtype == LPFC_IO) in lpfc_setup_cq_lookup()
11067 phba->sli4_hba.cq_lookup[childq->queue_id] = in lpfc_setup_cq_lookup()
11074 * lpfc_sli4_queue_setup - Set up all the SLI4 queues
11081 * 0 - successful
11082 * -ENOMEM - No available memory
11083 * -EIO - The mailbox failed to complete successfully.
11095 int rc = -ENOMEM; in lpfc_sli4_queue_setup()
11097 /* Check for dual-ULP support */ in lpfc_sli4_queue_setup()
11098 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_queue_setup()
11103 return -ENOMEM; in lpfc_sli4_queue_setup()
11105 length = (sizeof(struct lpfc_mbx_query_fw_config) - in lpfc_sli4_queue_setup()
11114 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_queue_setup()
11115 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_queue_setup()
11116 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_queue_setup()
11122 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
11123 rc = -ENXIO; in lpfc_sli4_queue_setup()
11127 phba->sli4_hba.fw_func_mode = in lpfc_sli4_queue_setup()
11128 mboxq->u.mqe.un.query_fw_cfg.rsp.function_mode; in lpfc_sli4_queue_setup()
11129 phba->sli4_hba.ulp0_mode = mboxq->u.mqe.un.query_fw_cfg.rsp.ulp0_mode; in lpfc_sli4_queue_setup()
11130 phba->sli4_hba.ulp1_mode = mboxq->u.mqe.un.query_fw_cfg.rsp.ulp1_mode; in lpfc_sli4_queue_setup()
11131 phba->sli4_hba.physical_port = in lpfc_sli4_queue_setup()
11132 mboxq->u.mqe.un.query_fw_cfg.rsp.physical_port; in lpfc_sli4_queue_setup()
11135 "ulp1_mode:x%x\n", phba->sli4_hba.fw_func_mode, in lpfc_sli4_queue_setup()
11136 phba->sli4_hba.ulp0_mode, phba->sli4_hba.ulp1_mode); in lpfc_sli4_queue_setup()
11138 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
11143 qp = phba->sli4_hba.hdwq; in lpfc_sli4_queue_setup()
11148 "3147 Fast-path EQs not allocated\n"); in lpfc_sli4_queue_setup()
11149 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11154 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_setup()
11157 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
11162 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_setup()
11164 if (qidx != cpup->eq) in lpfc_sli4_queue_setup()
11168 rc = lpfc_eq_create(phba, qp[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
11169 phba->cfg_fcp_imax); in lpfc_sli4_queue_setup()
11172 "0523 Failed setup of fast-path" in lpfc_sli4_queue_setup()
11174 cpup->eq, (uint32_t)rc); in lpfc_sli4_queue_setup()
11179 phba->sli4_hba.hba_eq_hdl[cpup->eq].eq = in lpfc_sli4_queue_setup()
11180 qp[cpup->hdwq].hba_eq; in lpfc_sli4_queue_setup()
11183 "2584 HBA EQ setup: queue[%d]-id=%d\n", in lpfc_sli4_queue_setup()
11184 cpup->eq, in lpfc_sli4_queue_setup()
11185 qp[cpup->hdwq].hba_eq->queue_id); in lpfc_sli4_queue_setup()
11190 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_setup()
11192 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
11196 phba->sli4_hba.hdwq[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
11199 &phba->sli4_hba.hdwq[qidx].io_cq_map, in lpfc_sli4_queue_setup()
11215 /* Set up slow-path MBOX CQ/MQ */ in lpfc_sli4_queue_setup()
11217 if (!phba->sli4_hba.mbx_cq || !phba->sli4_hba.mbx_wq) { in lpfc_sli4_queue_setup()
11220 phba->sli4_hba.mbx_cq ? in lpfc_sli4_queue_setup()
11222 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11227 phba->sli4_hba.mbx_cq, in lpfc_sli4_queue_setup()
11228 phba->sli4_hba.mbx_wq, in lpfc_sli4_queue_setup()
11236 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
11237 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_setup()
11239 "3165 Fast-path NVME CQ Set " in lpfc_sli4_queue_setup()
11241 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11244 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
11246 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
11258 rc = lpfc_cq_create(phba, phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
11267 phba->sli4_hba.nvmet_cqset[0]->chann = 0; in lpfc_sli4_queue_setup()
11270 "6090 NVMET CQ setup: cq-id=%d, " in lpfc_sli4_queue_setup()
11271 "parent eq-id=%d\n", in lpfc_sli4_queue_setup()
11272 phba->sli4_hba.nvmet_cqset[0]->queue_id, in lpfc_sli4_queue_setup()
11273 qp[0].hba_eq->queue_id); in lpfc_sli4_queue_setup()
11277 /* Set up slow-path ELS WQ/CQ */ in lpfc_sli4_queue_setup()
11278 if (!phba->sli4_hba.els_cq || !phba->sli4_hba.els_wq) { in lpfc_sli4_queue_setup()
11281 phba->sli4_hba.els_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
11282 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11286 phba->sli4_hba.els_cq, in lpfc_sli4_queue_setup()
11287 phba->sli4_hba.els_wq, in lpfc_sli4_queue_setup()
11296 "2590 ELS WQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11297 phba->sli4_hba.els_wq->queue_id, in lpfc_sli4_queue_setup()
11298 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
11300 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_setup()
11302 if (!phba->sli4_hba.nvmels_cq || !phba->sli4_hba.nvmels_wq) { in lpfc_sli4_queue_setup()
11305 phba->sli4_hba.nvmels_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
11306 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11310 phba->sli4_hba.nvmels_cq, in lpfc_sli4_queue_setup()
11311 phba->sli4_hba.nvmels_wq, in lpfc_sli4_queue_setup()
11321 "6096 ELS WQ setup: wq-id=%d, " in lpfc_sli4_queue_setup()
11322 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11323 phba->sli4_hba.nvmels_wq->queue_id, in lpfc_sli4_queue_setup()
11324 phba->sli4_hba.nvmels_cq->queue_id); in lpfc_sli4_queue_setup()
11330 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
11331 if ((!phba->sli4_hba.nvmet_cqset) || in lpfc_sli4_queue_setup()
11332 (!phba->sli4_hba.nvmet_mrq_hdr) || in lpfc_sli4_queue_setup()
11333 (!phba->sli4_hba.nvmet_mrq_data)) { in lpfc_sli4_queue_setup()
11337 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11340 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
11342 phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_setup()
11343 phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_setup()
11344 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
11356 phba->sli4_hba.nvmet_mrq_hdr[0], in lpfc_sli4_queue_setup()
11357 phba->sli4_hba.nvmet_mrq_data[0], in lpfc_sli4_queue_setup()
11358 phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
11370 "6099 NVMET RQ setup: hdr-rq-id=%d, " in lpfc_sli4_queue_setup()
11371 "dat-rq-id=%d parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11372 phba->sli4_hba.nvmet_mrq_hdr[0]->queue_id, in lpfc_sli4_queue_setup()
11373 phba->sli4_hba.nvmet_mrq_data[0]->queue_id, in lpfc_sli4_queue_setup()
11374 phba->sli4_hba.nvmet_cqset[0]->queue_id); in lpfc_sli4_queue_setup()
11379 if (!phba->sli4_hba.hdr_rq || !phba->sli4_hba.dat_rq) { in lpfc_sli4_queue_setup()
11382 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11386 rc = lpfc_rq_create(phba, phba->sli4_hba.hdr_rq, phba->sli4_hba.dat_rq, in lpfc_sli4_queue_setup()
11387 phba->sli4_hba.els_cq, LPFC_USOL); in lpfc_sli4_queue_setup()
11396 "2592 USL RQ setup: hdr-rq-id=%d, dat-rq-id=%d " in lpfc_sli4_queue_setup()
11397 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11398 phba->sli4_hba.hdr_rq->queue_id, in lpfc_sli4_queue_setup()
11399 phba->sli4_hba.dat_rq->queue_id, in lpfc_sli4_queue_setup()
11400 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
11402 if (phba->cfg_fcp_imax) in lpfc_sli4_queue_setup()
11403 usdelay = LPFC_SEC_TO_USEC / phba->cfg_fcp_imax; in lpfc_sli4_queue_setup()
11407 for (qidx = 0; qidx < phba->cfg_irq_chann; in lpfc_sli4_queue_setup()
11412 if (phba->sli4_hba.cq_max) { in lpfc_sli4_queue_setup()
11413 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_setup()
11414 phba->sli4_hba.cq_lookup = kcalloc((phba->sli4_hba.cq_max + 1), in lpfc_sli4_queue_setup()
11416 if (!phba->sli4_hba.cq_lookup) { in lpfc_sli4_queue_setup()
11419 "size 0x%x\n", phba->sli4_hba.cq_max); in lpfc_sli4_queue_setup()
11420 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11434 * lpfc_sli4_queue_unset - Unset all the SLI4 queues
11441 * 0 - successful
11442 * -ENOMEM - No available memory
11443 * -EIO - The mailbox failed to complete successfully.
11453 if (phba->sli4_hba.mbx_wq) in lpfc_sli4_queue_unset()
11454 lpfc_mq_destroy(phba, phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_unset()
11457 if (phba->sli4_hba.nvmels_wq) in lpfc_sli4_queue_unset()
11458 lpfc_wq_destroy(phba, phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_unset()
11461 if (phba->sli4_hba.els_wq) in lpfc_sli4_queue_unset()
11462 lpfc_wq_destroy(phba, phba->sli4_hba.els_wq); in lpfc_sli4_queue_unset()
11465 if (phba->sli4_hba.hdr_rq) in lpfc_sli4_queue_unset()
11466 lpfc_rq_destroy(phba, phba->sli4_hba.hdr_rq, in lpfc_sli4_queue_unset()
11467 phba->sli4_hba.dat_rq); in lpfc_sli4_queue_unset()
11470 if (phba->sli4_hba.mbx_cq) in lpfc_sli4_queue_unset()
11471 lpfc_cq_destroy(phba, phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_unset()
11474 if (phba->sli4_hba.els_cq) in lpfc_sli4_queue_unset()
11475 lpfc_cq_destroy(phba, phba->sli4_hba.els_cq); in lpfc_sli4_queue_unset()
11478 if (phba->sli4_hba.nvmels_cq) in lpfc_sli4_queue_unset()
11479 lpfc_cq_destroy(phba, phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_unset()
11481 if (phba->nvmet_support) { in lpfc_sli4_queue_unset()
11483 if (phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_unset()
11484 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
11487 phba->sli4_hba.nvmet_mrq_hdr[qidx], in lpfc_sli4_queue_unset()
11488 phba->sli4_hba.nvmet_mrq_data[qidx]); in lpfc_sli4_queue_unset()
11492 if (phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_unset()
11493 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
11495 phba, phba->sli4_hba.nvmet_cqset[qidx]); in lpfc_sli4_queue_unset()
11499 /* Unset fast-path SLI4 queues */ in lpfc_sli4_queue_unset()
11500 if (phba->sli4_hba.hdwq) { in lpfc_sli4_queue_unset()
11502 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_unset()
11504 qp = &phba->sli4_hba.hdwq[qidx]; in lpfc_sli4_queue_unset()
11505 lpfc_wq_destroy(phba, qp->io_wq); in lpfc_sli4_queue_unset()
11506 lpfc_cq_destroy(phba, qp->io_cq); in lpfc_sli4_queue_unset()
11509 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_unset()
11511 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_sli4_queue_unset()
11516 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_unset()
11517 phba->sli4_hba.cq_lookup = NULL; in lpfc_sli4_queue_unset()
11518 phba->sli4_hba.cq_max = 0; in lpfc_sli4_queue_unset()
11522 * lpfc_sli4_cq_event_pool_create - Create completion-queue event free pool
11529 * - Mailbox asynchronous events
11530 * - Receive queue completion unsolicited events
11531 * Later, this can be used for all the slow-path events.
11534 * 0 - successful
11535 * -ENOMEM - No available memory
11543 for (i = 0; i < (4 * phba->sli4_hba.cq_ecount); i++) { in lpfc_sli4_cq_event_pool_create()
11547 list_add_tail(&cq_event->list, in lpfc_sli4_cq_event_pool_create()
11548 &phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_cq_event_pool_create()
11554 return -ENOMEM; in lpfc_sli4_cq_event_pool_create()
11558 * lpfc_sli4_cq_event_pool_destroy - Free completion-queue event free pool
11563 * cleanup routine to free all the outstanding completion-queue events
11573 &phba->sli4_hba.sp_cqe_event_pool, list) { in lpfc_sli4_cq_event_pool_destroy()
11574 list_del(&cq_event->list); in lpfc_sli4_cq_event_pool_destroy()
11580 * __lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
11584 * completion-queue event from the free pool.
11586 * Return: Pointer to the newly allocated completion-queue event if successful
11594 list_remove_head(&phba->sli4_hba.sp_cqe_event_pool, cq_event, in __lpfc_sli4_cq_event_alloc()
11600 * lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
11604 * completion-queue event from the free pool.
11606 * Return: Pointer to the newly allocated completion-queue event if successful
11615 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
11617 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
11622 * __lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
11627 * completion-queue event back into the free pool.
11633 list_add_tail(&cq_event->list, &phba->sli4_hba.sp_cqe_event_pool); in __lpfc_sli4_cq_event_release()
11637 * lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
11642 * completion-queue event back into the free pool.
11649 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
11651 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
11655 * lpfc_sli4_cq_event_release_all - Release all cq events to the free pool
11658 * This routine is to free all the pending completion-queue events to the
11671 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11672 list_splice_init(&phba->sli4_hba.sp_els_xri_aborted_work_queue, in lpfc_sli4_cq_event_release_all()
11674 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11677 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11678 list_splice_init(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_cq_event_release_all()
11680 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11690 * lpfc_pci_function_reset - Reset pci function.
11697 * 0 - successful
11698 * -ENOMEM - No available memory
11699 * -EIO - The mailbox failed to complete successfully.
11713 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_pci_function_reset()
11716 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_pci_function_reset()
11723 return -ENOMEM; in lpfc_pci_function_reset()
11726 /* Setup PCI function reset mailbox-ioctl command */ in lpfc_pci_function_reset()
11732 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_pci_function_reset()
11733 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_pci_function_reset()
11735 &shdr->response); in lpfc_pci_function_reset()
11736 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_pci_function_reset()
11743 rc = -ENXIO; in lpfc_pci_function_reset()
11755 if (lpfc_readl(phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
11757 rc = -ENODEV; in lpfc_pci_function_reset()
11766 phba->work_status[0] = readl( in lpfc_pci_function_reset()
11767 phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_pci_function_reset()
11768 phba->work_status[1] = readl( in lpfc_pci_function_reset()
11769 phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_pci_function_reset()
11774 phba->work_status[0], in lpfc_pci_function_reset()
11775 phba->work_status[1]); in lpfc_pci_function_reset()
11776 rc = -ENODEV; in lpfc_pci_function_reset()
11792 writel(reg_data.word0, phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
11795 pci_read_config_word(phba->pcidev, in lpfc_pci_function_reset()
11802 rc = -ENODEV; in lpfc_pci_function_reset()
11813 /* Catch the not-ready port failure after a port reset. */ in lpfc_pci_function_reset()
11818 rc = -ENODEV; in lpfc_pci_function_reset()
11825 * lpfc_sli4_pci_mem_setup - Setup SLI4 HBA PCI memory space.
11829 * with SLI-4 interface spec.
11832 * 0 - successful
11833 * other values - error
11838 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_pci_mem_setup()
11844 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11847 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli4_pci_mem_setup()
11849 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli4_pci_mem_setup()
11858 &phba->sli4_hba.sli_intf.word0)) { in lpfc_sli4_pci_mem_setup()
11859 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11862 /* There is no SLI3 failback for SLI4 devices. */ in lpfc_sli4_pci_mem_setup()
11863 if (bf_get(lpfc_sli_intf_valid, &phba->sli4_hba.sli_intf) != in lpfc_sli4_pci_mem_setup()
11868 phba->sli4_hba.sli_intf.word0); in lpfc_sli4_pci_mem_setup()
11869 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11872 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_setup()
11880 phba->pci_bar0_map = pci_resource_start(pdev, PCI_64BIT_BAR0); in lpfc_sli4_pci_mem_setup()
11887 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11888 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
11889 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11890 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11893 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11895 phba->pci_bar0_memmap_p = phba->sli4_hba.conf_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11899 phba->pci_bar0_map = pci_resource_start(pdev, 1); in lpfc_sli4_pci_mem_setup()
11902 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11903 "FATAL - No BAR0 mapping for SLI4, if_type 2\n"); in lpfc_sli4_pci_mem_setup()
11904 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11906 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11907 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
11908 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11909 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11912 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11923 phba->pci_bar1_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
11926 phba->sli4_hba.ctrl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11927 ioremap(phba->pci_bar1_map, in lpfc_sli4_pci_mem_setup()
11929 if (!phba->sli4_hba.ctrl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11930 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11933 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11936 phba->pci_bar2_memmap_p = in lpfc_sli4_pci_mem_setup()
11937 phba->sli4_hba.ctrl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11940 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11951 phba->pci_bar1_map = pci_resource_start(pdev, PCI_64BIT_BAR2); in lpfc_sli4_pci_mem_setup()
11953 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11954 ioremap(phba->pci_bar1_map, bar1map_len); in lpfc_sli4_pci_mem_setup()
11955 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11956 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11958 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11961 phba->pci_bar2_memmap_p = phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11971 phba->pci_bar2_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
11974 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11975 ioremap(phba->pci_bar2_map, in lpfc_sli4_pci_mem_setup()
11977 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11978 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11981 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11984 phba->pci_bar4_memmap_p = in lpfc_sli4_pci_mem_setup()
11985 phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11990 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
12001 phba->pci_bar2_map = pci_resource_start(pdev, PCI_64BIT_BAR4); in lpfc_sli4_pci_mem_setup()
12003 phba->sli4_hba.dpp_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
12004 ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli4_pci_mem_setup()
12005 if (!phba->sli4_hba.dpp_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
12006 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
12008 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
12011 phba->pci_bar4_memmap_p = phba->sli4_hba.dpp_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
12018 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
12019 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_write_eq_db; in lpfc_sli4_pci_mem_setup()
12020 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_write_cq_db; in lpfc_sli4_pci_mem_setup()
12023 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_if6_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
12024 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_if6_write_eq_db; in lpfc_sli4_pci_mem_setup()
12025 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_if6_write_cq_db; in lpfc_sli4_pci_mem_setup()
12034 if (phba->sli4_hba.drbl_regs_memmap_p) in lpfc_sli4_pci_mem_setup()
12035 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12037 if (phba->sli4_hba.ctrl_regs_memmap_p) in lpfc_sli4_pci_mem_setup()
12038 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12040 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12046 * lpfc_sli4_pci_mem_unset - Unset SLI4 HBA PCI memory space.
12050 * with SLI-4 interface spec.
12056 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_unset()
12060 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12061 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12062 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12065 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12068 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12069 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12070 if (phba->sli4_hba.dpp_regs_memmap_p) in lpfc_sli4_pci_mem_unset()
12071 iounmap(phba->sli4_hba.dpp_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12076 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_pci_mem_unset()
12077 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_pci_mem_unset()
12084 * lpfc_sli_enable_msix - Enable MSI-X interrupt mode on SLI-3 device
12087 * This routine is invoked to enable the MSI-X interrupt vectors to device
12088 * with SLI-3 interface specs.
12091 * 0 - successful
12092 * other values - error
12100 /* Set up MSI-X multi-message vectors */ in lpfc_sli_enable_msix()
12101 rc = pci_alloc_irq_vectors(phba->pcidev, in lpfc_sli_enable_msix()
12105 "0420 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli_enable_msix()
12110 * Assign MSI-X vectors to interrupt handlers in lpfc_sli_enable_msix()
12113 /* vector-0 is associated to slow-path handler */ in lpfc_sli_enable_msix()
12114 rc = request_irq(pci_irq_vector(phba->pcidev, 0), in lpfc_sli_enable_msix()
12119 "0421 MSI-X slow-path request_irq failed " in lpfc_sli_enable_msix()
12124 /* vector-1 is associated to fast-path handler */ in lpfc_sli_enable_msix()
12125 rc = request_irq(pci_irq_vector(phba->pcidev, 1), in lpfc_sli_enable_msix()
12131 "0429 MSI-X fast-path request_irq failed " in lpfc_sli_enable_msix()
12137 * Configure HBA MSI-X attention conditions to messages in lpfc_sli_enable_msix()
12139 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_enable_msix()
12142 rc = -ENOMEM; in lpfc_sli_enable_msix()
12156 pmb->u.mb.mbxCommand, pmb->u.mb.mbxStatus); in lpfc_sli_enable_msix()
12161 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
12166 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
12170 free_irq(pci_irq_vector(phba->pcidev, 1), phba); in lpfc_sli_enable_msix()
12174 free_irq(pci_irq_vector(phba->pcidev, 0), phba); in lpfc_sli_enable_msix()
12177 /* Unconfigure MSI-X capability structure */ in lpfc_sli_enable_msix()
12178 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_enable_msix()
12185 * lpfc_sli_enable_msi - Enable MSI interrupt mode on SLI-3 device.
12189 * SLI-3 interface spec. The kernel function pci_enable_msi() is called to
12195 * 0 - successful
12196 * other values - error
12203 rc = pci_enable_msi(phba->pcidev); in lpfc_sli_enable_msi()
12213 rc = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_msi()
12216 pci_disable_msi(phba->pcidev); in lpfc_sli_enable_msi()
12224 * lpfc_sli_enable_intr - Enable device interrupt to SLI-3 device.
12226 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
12229 * interrupt handler(s) to interrupt vector(s) to device with SLI-3 interface
12234 * MSI-X -> MSI -> IRQ.
12237 * 0 - successful
12238 * other values - error
12250 clear_bit(HBA_NEEDS_CFG_PORT, &phba->hba_flag); in lpfc_sli_enable_intr()
12253 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli_enable_intr()
12256 /* Indicate initialization to MSI-X mode */ in lpfc_sli_enable_intr()
12257 phba->intr_type = MSIX; in lpfc_sli_enable_intr()
12262 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli_enable_intr()
12263 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli_enable_intr()
12267 phba->intr_type = MSI; in lpfc_sli_enable_intr()
12272 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli_enable_intr()
12273 if (phba->intr_type == NONE) { in lpfc_sli_enable_intr()
12274 retval = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_intr()
12278 phba->intr_type = INTx; in lpfc_sli_enable_intr()
12286 * lpfc_sli_disable_intr - Disable device interrupt to SLI-3 device.
12291 * SLI-3 interface spec. Depending on the interrupt mode, the driver will
12299 if (phba->intr_type == MSIX) in lpfc_sli_disable_intr()
12305 free_irq(pci_irq_vector(phba->pcidev, i), phba); in lpfc_sli_disable_intr()
12306 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_disable_intr()
12309 phba->intr_type = NONE; in lpfc_sli_disable_intr()
12310 phba->sli.slistat.sli_intr = 0; in lpfc_sli_disable_intr()
12314 * lpfc_find_cpu_handle - Find the CPU that corresponds to the specified Queue
12329 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_find_cpu_handle()
12336 (cpup->flag & LPFC_CPU_FIRST_IRQ) && in lpfc_find_cpu_handle()
12337 (cpup->eq == id)) in lpfc_find_cpu_handle()
12341 if ((match == LPFC_FIND_BY_HDWQ) && (cpup->hdwq == id)) in lpfc_find_cpu_handle()
12349 * lpfc_find_hyper - Determine if the CPU map entry is hyper-threaded
12363 cpup = &phba->sli4_hba.cpu_map[idx]; in lpfc_find_hyper()
12365 if ((cpup->phys_id == phys_id) && in lpfc_find_hyper()
12366 (cpup->core_id == core_id) && in lpfc_find_hyper()
12375 * lpfc_assign_eq_map_info - Assigns eq for vector_map structure
12387 struct lpfc_vector_map_info *cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_assign_eq_map_info()
12390 cpup->eq = eqidx; in lpfc_assign_eq_map_info()
12391 cpup->flag |= flag; in lpfc_assign_eq_map_info()
12395 cpu, eqhdl->irq, cpup->eq, cpup->flag); in lpfc_assign_eq_map_info()
12399 * lpfc_cpu_map_array_init - Initialize cpu_map structure
12412 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_map_array_init()
12413 cpup->phys_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12414 cpup->core_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12415 cpup->hdwq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12416 cpup->eq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12417 cpup->flag = 0; in lpfc_cpu_map_array_init()
12418 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, cpu); in lpfc_cpu_map_array_init()
12419 INIT_LIST_HEAD(&eqi->list); in lpfc_cpu_map_array_init()
12420 eqi->icnt = 0; in lpfc_cpu_map_array_init()
12425 * lpfc_hba_eq_hdl_array_init - Initialize hba_eq_hdl structure
12436 for (i = 0; i < phba->cfg_irq_chann; i++) { in lpfc_hba_eq_hdl_array_init()
12438 eqhdl->irq = LPFC_IRQ_EMPTY; in lpfc_hba_eq_hdl_array_init()
12439 eqhdl->phba = phba; in lpfc_hba_eq_hdl_array_init()
12444 * lpfc_cpu_affinity_check - Check vector CPU affinity mappings
12449 * MSI-X vector allocated for the HBA.
12451 * and the phba->sli4_hba.cpu_map array will reflect this.
12472 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12474 cpup->phys_id = topology_physical_package_id(cpu); in lpfc_cpu_affinity_check()
12475 cpup->core_id = topology_core_id(cpu); in lpfc_cpu_affinity_check()
12476 if (lpfc_find_hyper(phba, cpu, cpup->phys_id, cpup->core_id)) in lpfc_cpu_affinity_check()
12477 cpup->flag |= LPFC_CPU_MAP_HYPER; in lpfc_cpu_affinity_check()
12479 /* No distinction between CPUs for other platforms */ in lpfc_cpu_affinity_check()
12480 cpup->phys_id = 0; in lpfc_cpu_affinity_check()
12481 cpup->core_id = cpu; in lpfc_cpu_affinity_check()
12486 cpu, cpup->phys_id, cpup->core_id, cpup->flag); in lpfc_cpu_affinity_check()
12488 if (cpup->phys_id > max_phys_id) in lpfc_cpu_affinity_check()
12489 max_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
12490 if (cpup->phys_id < min_phys_id) in lpfc_cpu_affinity_check()
12491 min_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
12493 if (cpup->core_id > max_core_id) in lpfc_cpu_affinity_check()
12494 max_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
12495 if (cpup->core_id < min_core_id) in lpfc_cpu_affinity_check()
12496 min_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
12508 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12511 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
12513 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
12521 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12522 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12523 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
12524 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY) && in lpfc_cpu_affinity_check()
12525 (new_cpup->phys_id == cpup->phys_id)) in lpfc_cpu_affinity_check()
12533 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
12545 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
12546 cpup->phys_id); in lpfc_cpu_affinity_check()
12554 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12557 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
12559 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
12567 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12568 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12569 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
12570 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY)) in lpfc_cpu_affinity_check()
12578 cpup->hdwq, cpup->eq); in lpfc_cpu_affinity_check()
12582 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
12593 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
12594 new_cpup->phys_id, new_cpup->core_id); in lpfc_cpu_affinity_check()
12603 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12606 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_cpu_affinity_check()
12610 cpup->hdwq = idx; in lpfc_cpu_affinity_check()
12615 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
12616 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
12619 * This will be 1 to 1 - hdwq to cpu, unless there are less in lpfc_cpu_affinity_check()
12620 * hardware queues then CPUs. For that case we will just round-robin in lpfc_cpu_affinity_check()
12623 * for irq_chann < hdwq. The idx is used for round-robin assignments in lpfc_cpu_affinity_check()
12630 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12633 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_cpu_affinity_check()
12640 if (next_idx < phba->cfg_hdw_queue) { in lpfc_cpu_affinity_check()
12641 cpup->hdwq = next_idx; in lpfc_cpu_affinity_check()
12652 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12653 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12654 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
12655 new_cpup->phys_id == cpup->phys_id && in lpfc_cpu_affinity_check()
12656 new_cpup->core_id == cpup->core_id) { in lpfc_cpu_affinity_check()
12666 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12667 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12668 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
12669 new_cpup->phys_id == cpup->phys_id) in lpfc_cpu_affinity_check()
12675 cpup->hdwq = idx % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
12681 cpup->hdwq = new_cpup->hdwq; in lpfc_cpu_affinity_check()
12686 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
12687 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
12691 * Initialize the cpu_map slots for not-present cpus in case in lpfc_cpu_affinity_check()
12692 * a cpu is hot-added. Perform a simple hdwq round robin assignment. in lpfc_cpu_affinity_check()
12696 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12698 c_stat = per_cpu_ptr(phba->sli4_hba.c_stat, cpu); in lpfc_cpu_affinity_check()
12699 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
12701 if (cpup->hdwq != LPFC_VECTOR_MAP_EMPTY) in lpfc_cpu_affinity_check()
12704 cpup->hdwq = idx++ % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
12706 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
12711 cpu, cpup->hdwq); in lpfc_cpu_affinity_check()
12738 return -ENOMEM; in lpfc_cpuhp_get_eq()
12740 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_cpuhp_get_eq()
12741 maskp = pci_irq_get_affinity(phba->pcidev, idx); in lpfc_cpuhp_get_eq()
12751 /* get the cpus that are online and are affini- in lpfc_cpuhp_get_eq()
12753 * more than 1 then cpuhp is not going to shut- in lpfc_cpuhp_get_eq()
12766 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_cpuhp_get_eq()
12767 list_add(&eq->_poll_list, eqlist); in lpfc_cpuhp_get_eq()
12775 if (phba->sli_rev != LPFC_SLI_REV4) in __lpfc_cpuhp_remove()
12779 &phba->cpuhp); in __lpfc_cpuhp_remove()
12785 del_timer_sync(&phba->cpuhp_poll_timer); in __lpfc_cpuhp_remove()
12790 if (phba->pport && in lpfc_cpuhp_remove()
12791 test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_cpuhp_remove()
12799 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_cpuhp_add()
12804 if (!list_empty(&phba->poll_list)) in lpfc_cpuhp_add()
12805 mod_timer(&phba->cpuhp_poll_timer, in lpfc_cpuhp_add()
12811 &phba->cpuhp); in lpfc_cpuhp_add()
12816 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { in __lpfc_cpuhp_checks()
12817 *retval = -EAGAIN; in __lpfc_cpuhp_checks()
12821 if (phba->sli_rev != LPFC_SLI_REV4) { in __lpfc_cpuhp_checks()
12831 * lpfc_irq_set_aff - set IRQ affinity
12839 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_set_aff()
12840 cpumask_set_cpu(cpu, &eqhdl->aff_mask); in lpfc_irq_set_aff()
12841 irq_set_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_set_aff()
12842 irq_set_affinity(eqhdl->irq, &eqhdl->aff_mask); in lpfc_irq_set_aff()
12846 * lpfc_irq_clear_aff - clear IRQ affinity
12853 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_clear_aff()
12854 irq_clear_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_clear_aff()
12858 * lpfc_irq_rebalance - rebalances IRQ affinity according to cpuhp event
12870 * PCI_IRQ_AFFINITY to auto-manage IRQ affinity.
12881 if (phba->irq_chann_mode == NORMAL_MODE) in lpfc_irq_rebalance()
12884 orig_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_irq_rebalance()
12889 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_irq_rebalance()
12891 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_irq_rebalance()
12904 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_irq_rebalance()
12913 /* Rely on irqbalance if no online CPUs left on NUMA */ in lpfc_irq_rebalance()
12914 for (idx = 0; idx < phba->cfg_irq_chann; idx++) in lpfc_irq_rebalance()
12919 lpfc_irq_set_aff(lpfc_get_eq_hdl(cpup->eq), cpu); in lpfc_irq_rebalance()
12946 list_del_init(&eq->_poll_list); in lpfc_cpu_offline()
12970 list_for_each_entry_safe(eq, next, &phba->poll_list, _poll_list) { in lpfc_cpu_online()
12971 n = lpfc_find_cpu_handle(phba, eq->hdwq, LPFC_FIND_BY_HDWQ); in lpfc_cpu_online()
12980 * lpfc_sli4_enable_msix - Enable MSI-X interrupt mode to SLI-4 device
12983 * This routine is invoked to enable the MSI-X interrupt vectors to device
12984 * with SLI-4 interface spec. It also allocates MSI-X vectors and maps them
12993 * online. If there are no online cpus within the numa node, affinity is not
13004 * 0 - successful
13005 * other values - error
13019 /* Set up MSI-X multi-message vectors */ in lpfc_sli4_enable_msix()
13020 vectors = phba->cfg_irq_chann; in lpfc_sli4_enable_msix()
13022 if (phba->irq_chann_mode != NORMAL_MODE) in lpfc_sli4_enable_msix()
13023 aff_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_sli4_enable_msix()
13027 vectors = min(phba->cfg_irq_chann, cpu_cnt); in lpfc_sli4_enable_msix()
13038 rc = pci_alloc_irq_vectors(phba->pcidev, 1, vectors, flags); in lpfc_sli4_enable_msix()
13041 "0484 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli4_enable_msix()
13046 /* Assign MSI-X vectors to interrupt handlers */ in lpfc_sli4_enable_msix()
13049 name = eqhdl->handler_name; in lpfc_sli4_enable_msix()
13054 eqhdl->idx = index; in lpfc_sli4_enable_msix()
13055 rc = pci_irq_vector(phba->pcidev, index); in lpfc_sli4_enable_msix()
13058 "0489 MSI-X fast-path (%d) " in lpfc_sli4_enable_msix()
13062 eqhdl->irq = rc; in lpfc_sli4_enable_msix()
13064 rc = request_threaded_irq(eqhdl->irq, in lpfc_sli4_enable_msix()
13070 "0486 MSI-X fast-path (%d) " in lpfc_sli4_enable_msix()
13095 maskp = pci_irq_get_affinity(phba->pcidev, index); in lpfc_sli4_enable_msix()
13099 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_enable_msix()
13113 if (cpup->eq != LPFC_VECTOR_MAP_EMPTY) in lpfc_sli4_enable_msix()
13123 if (vectors != phba->cfg_irq_chann) { in lpfc_sli4_enable_msix()
13126 "MSI-X vectors, requested %d got %d\n", in lpfc_sli4_enable_msix()
13127 phba->cfg_irq_chann, vectors); in lpfc_sli4_enable_msix()
13128 if (phba->cfg_irq_chann > vectors) in lpfc_sli4_enable_msix()
13129 phba->cfg_irq_chann = vectors; in lpfc_sli4_enable_msix()
13136 for (--index; index >= 0; index--) { in lpfc_sli4_enable_msix()
13139 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_enable_msix()
13142 /* Unconfigure MSI-X capability structure */ in lpfc_sli4_enable_msix()
13143 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msix()
13150 * lpfc_sli4_enable_msi - Enable MSI interrupt mode to SLI-4 device
13154 * SLI-4 interface spec. The kernel function pci_alloc_irq_vectors() is
13160 * 0 - successful
13161 * other values - error
13170 rc = pci_alloc_irq_vectors(phba->pcidev, 1, 1, in lpfc_sli4_enable_msi()
13178 return rc ? rc : -1; in lpfc_sli4_enable_msi()
13181 rc = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_msi()
13184 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msi()
13191 rc = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_msi()
13193 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msi()
13198 eqhdl->irq = rc; in lpfc_sli4_enable_msi()
13203 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_enable_msi()
13205 eqhdl->idx = index; in lpfc_sli4_enable_msi()
13212 * lpfc_sli4_enable_intr - Enable device interrupt to SLI-4 device
13214 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
13217 * interrupt handler(s) to interrupt vector(s) to device with SLI-4
13222 * MSI-X -> MSI -> IRQ.
13225 * Interrupt mode (2, 1, 0) - successful
13226 * LPFC_INTR_ERROR - error
13238 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli4_enable_intr()
13241 /* Indicate initialization to MSI-X mode */ in lpfc_sli4_enable_intr()
13242 phba->intr_type = MSIX; in lpfc_sli4_enable_intr()
13248 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli4_enable_intr()
13249 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
13253 phba->intr_type = MSI; in lpfc_sli4_enable_intr()
13258 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli4_enable_intr()
13259 if (phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
13260 retval = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_intr()
13267 phba->intr_type = INTx; in lpfc_sli4_enable_intr()
13271 retval = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_intr()
13278 eqhdl->irq = retval; in lpfc_sli4_enable_intr()
13283 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_enable_intr()
13285 eqhdl->idx = idx; in lpfc_sli4_enable_intr()
13293 * lpfc_sli4_disable_intr - Disable device interrupt to SLI-4 device
13298 * with SLI-4 interface spec. Depending on the interrupt mode, the driver
13305 if (phba->intr_type == MSIX) { in lpfc_sli4_disable_intr()
13309 /* Free up MSI-X multi-message vectors */ in lpfc_sli4_disable_intr()
13310 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_disable_intr()
13313 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_disable_intr()
13316 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_disable_intr()
13319 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_disable_intr()
13322 phba->intr_type = NONE; in lpfc_sli4_disable_intr()
13323 phba->sli.slistat.sli_intr = 0; in lpfc_sli4_disable_intr()
13327 * lpfc_unset_hba - Unset SLI3 hba device initialization
13331 * a device with SLI-3 interface spec.
13336 set_bit(FC_UNLOADING, &phba->pport->load_flag); in lpfc_unset_hba()
13338 kfree(phba->vpi_bmask); in lpfc_unset_hba()
13339 kfree(phba->vpi_ids); in lpfc_unset_hba()
13343 phba->pport->work_port_events = 0; in lpfc_unset_hba()
13355 * lpfc_sli4_xri_exchange_busy_wait - Wait for device XRI exchange busy
13375 int els_xri_cmpl = list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
13384 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_xri_exchange_busy_wait()
13388 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
13389 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
13390 io_xri_cmpl = list_empty(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
13397 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
13399 list_empty(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
13427 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
13428 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
13430 &qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
13437 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
13439 &phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
13442 list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
13448 * lpfc_sli4_hba_unset - Unset the fcoe hba
13462 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_hba_unset()
13465 hrtimer_cancel(&phba->cmf_stats_timer); in lpfc_sli4_hba_unset()
13466 hrtimer_cancel(&phba->cmf_timer); in lpfc_sli4_hba_unset()
13468 if (phba->pport) in lpfc_sli4_hba_unset()
13469 phba->sli4_hba.intr_enable = 0; in lpfc_sli4_hba_unset()
13477 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13478 phba->sli.sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_hba_unset()
13479 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13481 while (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
13487 if (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
13488 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13489 mboxq = phba->sli.mbox_active; in lpfc_sli4_hba_unset()
13490 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_hba_unset()
13492 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_hba_unset()
13493 phba->sli.mbox_active = NULL; in lpfc_sli4_hba_unset()
13494 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13500 if (!pci_channel_offline(phba->pcidev)) in lpfc_sli4_hba_unset()
13504 /* per-phba callback de-registration for hotplug event */ in lpfc_sli4_hba_unset()
13505 if (phba->pport) in lpfc_sli4_hba_unset()
13511 /* Disable SR-IOV if enabled */ in lpfc_sli4_hba_unset()
13512 if (phba->cfg_sriov_nr_virtfn) in lpfc_sli4_hba_unset()
13516 kthread_stop(phba->worker_thread); in lpfc_sli4_hba_unset()
13528 if (phba->ras_fwlog.ras_enabled) in lpfc_sli4_hba_unset()
13532 if (phba->pport) in lpfc_sli4_hba_unset()
13533 phba->pport->work_port_events = 0; in lpfc_sli4_hba_unset()
13594 "6235 INIT Congestion Buffer %p\n", phba->cgn_i); in lpfc_init_congestion_buf()
13596 if (!phba->cgn_i) in lpfc_init_congestion_buf()
13598 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_init_congestion_buf()
13600 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_init_congestion_buf()
13601 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_init_congestion_buf()
13602 atomic_set(&phba->cgn_sync_alarm_cnt, 0); in lpfc_init_congestion_buf()
13603 atomic_set(&phba->cgn_sync_warn_cnt, 0); in lpfc_init_congestion_buf()
13605 atomic_set(&phba->cgn_driver_evt_cnt, 0); in lpfc_init_congestion_buf()
13606 atomic_set(&phba->cgn_latency_evt_cnt, 0); in lpfc_init_congestion_buf()
13607 atomic64_set(&phba->cgn_latency_evt, 0); in lpfc_init_congestion_buf()
13608 phba->cgn_evt_minute = 0; in lpfc_init_congestion_buf()
13611 cp->cgn_info_size = cpu_to_le16(LPFC_CGN_INFO_SZ); in lpfc_init_congestion_buf()
13612 cp->cgn_info_version = LPFC_CGN_INFO_V4; in lpfc_init_congestion_buf()
13615 cp->cgn_info_mode = phba->cgn_p.cgn_param_mode; in lpfc_init_congestion_buf()
13616 cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0; in lpfc_init_congestion_buf()
13617 cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1; in lpfc_init_congestion_buf()
13618 cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2; in lpfc_init_congestion_buf()
13620 lpfc_cgn_update_tstamp(phba, &cp->base_time); in lpfc_init_congestion_buf()
13623 if (phba->pport) { in lpfc_init_congestion_buf()
13624 size = (uint16_t)(phba->pport->cfg_lun_queue_depth); in lpfc_init_congestion_buf()
13625 cp->cgn_lunq = cpu_to_le16(size); in lpfc_init_congestion_buf()
13630 cp->cgn_warn_freq = cpu_to_le16(LPFC_FPIN_INIT_FREQ); in lpfc_init_congestion_buf()
13631 cp->cgn_alarm_freq = cpu_to_le16(LPFC_FPIN_INIT_FREQ); in lpfc_init_congestion_buf()
13633 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_init_congestion_buf()
13635 phba->cgn_evt_timestamp = jiffies + in lpfc_init_congestion_buf()
13646 "6236 INIT Congestion Stat %p\n", phba->cgn_i); in lpfc_init_congestion_stat()
13648 if (!phba->cgn_i) in lpfc_init_congestion_stat()
13651 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_init_congestion_stat()
13652 memset(&cp->cgn_stat, 0, sizeof(cp->cgn_stat)); in lpfc_init_congestion_stat()
13654 lpfc_cgn_update_tstamp(phba, &cp->stat_start); in lpfc_init_congestion_stat()
13656 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_init_congestion_stat()
13660 * __lpfc_reg_congestion_buf - register congestion info buffer with HBA
13673 if (!phba->cgn_i) in __lpfc_reg_congestion_buf()
13674 return -ENXIO; in __lpfc_reg_congestion_buf()
13676 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in __lpfc_reg_congestion_buf()
13681 phba->pport->port_state, reg); in __lpfc_reg_congestion_buf()
13682 return -ENOMEM; in __lpfc_reg_congestion_buf()
13685 length = (sizeof(struct lpfc_mbx_reg_congestion_buf) - in __lpfc_reg_congestion_buf()
13690 reg_congestion_buf = &mboxq->u.mqe.un.reg_congestion_buf; in __lpfc_reg_congestion_buf()
13696 reg_congestion_buf->length = sizeof(struct lpfc_cgn_info); in __lpfc_reg_congestion_buf()
13697 reg_congestion_buf->addr_lo = in __lpfc_reg_congestion_buf()
13698 putPaddrLow(phba->cgn_i->phys); in __lpfc_reg_congestion_buf()
13699 reg_congestion_buf->addr_hi = in __lpfc_reg_congestion_buf()
13700 putPaddrHigh(phba->cgn_i->phys); in __lpfc_reg_congestion_buf()
13704 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in __lpfc_reg_congestion_buf()
13705 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in __lpfc_reg_congestion_buf()
13707 &shdr->response); in __lpfc_reg_congestion_buf()
13708 mempool_free(mboxq, phba->mbox_mem_pool); in __lpfc_reg_congestion_buf()
13715 return -ENXIO; in __lpfc_reg_congestion_buf()
13734 * lpfc_get_sli4_parameters - Get the SLI4 Config PARAMETERS.
13741 * This function may be be called from any context that can block-wait
13749 struct lpfc_mqe *mqe = &mboxq->u.mqe; in lpfc_get_sli4_parameters()
13761 phba->sli4_hba.rpi_hdrs_in_use = 1; in lpfc_get_sli4_parameters()
13764 length = (sizeof(struct lpfc_mbx_get_sli4_parameters) - in lpfc_get_sli4_parameters()
13769 if (!phba->sli4_hba.intr_enable) in lpfc_get_sli4_parameters()
13777 sli4_params = &phba->sli4_hba.pc_sli4_params; in lpfc_get_sli4_parameters()
13778 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters; in lpfc_get_sli4_parameters()
13779 sli4_params->if_type = bf_get(cfg_if_type, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13780 sli4_params->sli_rev = bf_get(cfg_sli_rev, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13781 sli4_params->sli_family = bf_get(cfg_sli_family, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13782 sli4_params->featurelevel_1 = bf_get(cfg_sli_hint_1, in lpfc_get_sli4_parameters()
13784 sli4_params->featurelevel_2 = bf_get(cfg_sli_hint_2, in lpfc_get_sli4_parameters()
13787 phba->sli3_options |= LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
13789 phba->sli3_options &= ~LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
13790 sli4_params->sge_supp_len = mbx_sli4_parameters->sge_supp_len; in lpfc_get_sli4_parameters()
13791 sli4_params->loopbk_scope = bf_get(cfg_loopbk_scope, in lpfc_get_sli4_parameters()
13793 sli4_params->oas_supported = bf_get(cfg_oas, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13794 sli4_params->cqv = bf_get(cfg_cqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13795 sli4_params->mqv = bf_get(cfg_mqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13796 sli4_params->wqv = bf_get(cfg_wqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13797 sli4_params->rqv = bf_get(cfg_rqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13798 sli4_params->eqav = bf_get(cfg_eqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13799 sli4_params->cqav = bf_get(cfg_cqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13800 sli4_params->wqsize = bf_get(cfg_wqsize, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13801 sli4_params->bv1s = bf_get(cfg_bv1s, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13802 sli4_params->pls = bf_get(cfg_pvl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13803 sli4_params->sgl_pages_max = bf_get(cfg_sgl_page_cnt, in lpfc_get_sli4_parameters()
13805 sli4_params->wqpcnt = bf_get(cfg_wqpcnt, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13806 sli4_params->sgl_pp_align = bf_get(cfg_sgl_pp_align, in lpfc_get_sli4_parameters()
13808 phba->sli4_hba.extents_in_use = bf_get(cfg_ext, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13809 phba->sli4_hba.rpi_hdrs_in_use = bf_get(cfg_hdrr, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13810 sli4_params->mi_cap = bf_get(cfg_mi_ver, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13812 /* Check for Extended Pre-Registered SGL support */ in lpfc_get_sli4_parameters()
13813 phba->cfg_xpsgl = bf_get(cfg_xpsgl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13821 sli4_params->nvme = 1; in lpfc_get_sli4_parameters()
13824 if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP) { in lpfc_get_sli4_parameters()
13828 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
13832 /* No firmware NVME support, check driver FC4 NVME support */ in lpfc_get_sli4_parameters()
13833 sli4_params->nvme = 0; in lpfc_get_sli4_parameters()
13834 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_get_sli4_parameters()
13840 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
13842 phba->nvmet_support = 0; in lpfc_get_sli4_parameters()
13843 phba->cfg_nvmet_mrq = 0; in lpfc_get_sli4_parameters()
13844 phba->cfg_nvme_seg_cnt = 0; in lpfc_get_sli4_parameters()
13846 /* If no FC4 type support, move to just SCSI support */ in lpfc_get_sli4_parameters()
13847 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_get_sli4_parameters()
13848 return -ENODEV; in lpfc_get_sli4_parameters()
13849 phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; in lpfc_get_sli4_parameters()
13856 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_get_sli4_parameters()
13857 phba->cfg_sg_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_get_sli4_parameters()
13861 phba->cfg_enable_pbde = 1; in lpfc_get_sli4_parameters()
13863 phba->cfg_enable_pbde = 0; in lpfc_get_sli4_parameters()
13868 * In SLI4-Parameters Descriptor: in lpfc_get_sli4_parameters()
13873 if (phba->cfg_suppress_rsp && bf_get(cfg_xib, mbx_sli4_parameters) && in lpfc_get_sli4_parameters()
13875 phba->sli.sli_flag |= LPFC_SLI_SUPPRESS_RSP; in lpfc_get_sli4_parameters()
13877 phba->cfg_suppress_rsp = 0; in lpfc_get_sli4_parameters()
13880 phba->sli.sli_flag |= LPFC_SLI_USE_EQDR; in lpfc_get_sli4_parameters()
13883 if (sli4_params->sge_supp_len > LPFC_MAX_SGE_SIZE) in lpfc_get_sli4_parameters()
13884 sli4_params->sge_supp_len = LPFC_MAX_SGE_SIZE; in lpfc_get_sli4_parameters()
13886 dma_set_max_seg_size(&phba->pcidev->dev, sli4_params->sge_supp_len); in lpfc_get_sli4_parameters()
13891 * to use this option, 128-byte WQEs must be used. in lpfc_get_sli4_parameters()
13894 phba->fcp_embed_io = 1; in lpfc_get_sli4_parameters()
13896 phba->fcp_embed_io = 0; in lpfc_get_sli4_parameters()
13901 phba->cfg_enable_pbde, in lpfc_get_sli4_parameters()
13902 phba->fcp_embed_io, sli4_params->nvme, in lpfc_get_sli4_parameters()
13903 phba->cfg_nvme_embed_cmd, phba->cfg_suppress_rsp); in lpfc_get_sli4_parameters()
13905 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
13907 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
13914 (sli4_params->wqsize & LPFC_WQ_SZ128_SUPPORT)) in lpfc_get_sli4_parameters()
13915 phba->enab_exp_wqcq_pages = 1; in lpfc_get_sli4_parameters()
13917 phba->enab_exp_wqcq_pages = 0; in lpfc_get_sli4_parameters()
13922 phba->mds_diags_support = 1; in lpfc_get_sli4_parameters()
13924 phba->mds_diags_support = 0; in lpfc_get_sli4_parameters()
13930 phba->nsler = 1; in lpfc_get_sli4_parameters()
13932 phba->nsler = 0; in lpfc_get_sli4_parameters()
13938 * lpfc_pci_probe_one_s3 - PCI probe func to reg SLI-3 device to PCI subsystem.
13942 * This routine is to be called to attach a device with SLI-3 interface spec
13943 * to the PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
13944 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
13951 * 0 - driver can claim the device
13952 * negative value - driver can not claim the device
13966 return -ENOMEM; in lpfc_pci_probe_one_s3()
13973 /* Set up SLI API function jump table for PCI-device group-0 HBAs */ in lpfc_pci_probe_one_s3()
13978 /* Set up SLI-3 specific device PCI memory space */ in lpfc_pci_probe_one_s3()
13986 /* Set up SLI-3 specific device driver resources */ in lpfc_pci_probe_one_s3()
14012 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s3()
14023 vport = phba->pport; in lpfc_pci_probe_one_s3()
14033 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s3()
14042 error = -ENODEV; in lpfc_pci_probe_one_s3()
14045 /* SLI-3 HBA setup */ in lpfc_pci_probe_one_s3()
14049 error = -ENODEV; in lpfc_pci_probe_one_s3()
14057 phba->sli.slistat.sli_intr > LPFC_MSIX_VECTORS) { in lpfc_pci_probe_one_s3()
14059 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s3()
14070 cfg_mode = --intr_mode; in lpfc_pci_probe_one_s3()
14106 * lpfc_pci_remove_one_s3 - PCI func to unreg SLI-3 device from PCI subsystem.
14109 * This routine is to be called to disattach a device with SLI-3 interface
14110 * spec from PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
14118 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s3()
14120 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s3()
14123 set_bit(FC_UNLOADING, &vport->load_flag); in lpfc_pci_remove_one_s3()
14130 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s3()
14131 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s3()
14133 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s3()
14153 kthread_stop(phba->worker_thread); in lpfc_pci_remove_one_s3()
14157 kfree(phba->vpi_bmask); in lpfc_pci_remove_one_s3()
14158 kfree(phba->vpi_ids); in lpfc_pci_remove_one_s3()
14161 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
14162 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s3()
14163 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
14167 /* Disable SR-IOV if enabled */ in lpfc_pci_remove_one_s3()
14168 if (phba->cfg_sriov_nr_virtfn) in lpfc_pci_remove_one_s3()
14185 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_pci_remove_one_s3()
14186 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_pci_remove_one_s3()
14189 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_pci_remove_one_s3()
14190 phba->slim2p.virt, phba->slim2p.phys); in lpfc_pci_remove_one_s3()
14193 iounmap(phba->ctrl_regs_memmap_p); in lpfc_pci_remove_one_s3()
14194 iounmap(phba->slim_memmap_p); in lpfc_pci_remove_one_s3()
14203 * lpfc_pci_suspend_one_s3 - PCI func to suspend SLI-3 device for power mgmnt
14207 * system Power Management (PM) to device with SLI-3 interface spec. When
14211 * minimum PM requirements to a power-aware driver's PM support for the
14212 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
14219 * 0 - driver suspended the device
14226 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s3()
14234 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s3()
14243 * lpfc_pci_resume_one_s3 - PCI func to resume SLI-3 device for power mgmnt
14247 * system Power Management (PM) to device with SLI-3 interface spec. When PM
14250 * driver implements the minimum PM requirements to a power-aware driver's
14251 * PM for suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE,
14258 * 0 - driver suspended the device
14265 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s3()
14273 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s3()
14274 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s3()
14275 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s3()
14276 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s3()
14288 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
14292 return -EIO; in lpfc_pci_resume_one_s3()
14294 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s3()
14301 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
14307 * lpfc_sli_prep_dev_for_recover - Prepare SLI3 device for pci slot recover
14321 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli_prep_dev_for_recover()
14327 * lpfc_sli_prep_dev_for_reset - Prepare SLI3 device for pci slot reset
14354 pci_disable_device(phba->pcidev); in lpfc_sli_prep_dev_for_reset()
14358 * lpfc_sli_prep_dev_for_perm_failure - Prepare SLI3 dev for pci slot disable
14382 * lpfc_io_error_detected_s3 - Method for handling SLI-3 device PCI I/O error
14387 * device with SLI-3 interface spec. This function is called by the PCI
14395 * PCI_ERS_RESULT_CAN_RECOVER - can be recovered with reset_link
14396 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
14397 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
14403 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s3()
14407 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s3()
14428 * lpfc_io_slot_reset_s3 - Method for restarting PCI SLI-3 device from scratch.
14432 * device with SLI-3 interface spec. This is called after PCI bus has been
14433 * reset to restart the PCI card from scratch, as if from a cold-boot.
14442 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
14443 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
14449 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s3()
14450 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s3()
14453 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s3()
14455 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s3()
14468 if (pdev->is_busmaster) in lpfc_io_slot_reset_s3()
14471 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
14472 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s3()
14473 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
14476 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
14479 "0427 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s3()
14483 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s3()
14491 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
14497 * lpfc_io_resume_s3 - Method for resuming PCI I/O operation on SLI-3 device.
14501 * with SLI-3 interface spec. It is called when kernel error recovery tells
14510 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s3()
14512 /* Bring device online, it will be no-op for non-fatal error resume */ in lpfc_io_resume_s3()
14517 * lpfc_sli4_get_els_iocb_cnt - Calculate the # of ELS IOCBs to reserve
14525 int max_xri = phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_get_els_iocb_cnt()
14527 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli4_get_els_iocb_cnt()
14547 * lpfc_sli4_get_iocb_cnt - Calculate the # of total IOCBs to reserve
14557 if (phba->nvmet_support) in lpfc_sli4_get_iocb_cnt()
14571 sli_family = bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf); in lpfc_log_write_firmware_error()
14589 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
14590 fsize, fw->size); in lpfc_log_write_firmware_error()
14591 rc = -EINVAL; in lpfc_log_write_firmware_error()
14598 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
14599 fsize, fw->size); in lpfc_log_write_firmware_error()
14600 rc = -EACCES; in lpfc_log_write_firmware_error()
14606 offset, phba->pcidev->device, magic_number, in lpfc_log_write_firmware_error()
14607 ftype, fid, fsize, fw->size); in lpfc_log_write_firmware_error()
14608 rc = -EIO; in lpfc_log_write_firmware_error()
14614 * lpfc_write_firmware - attempt to write a firmware image to the port
14631 /* It can be null in no-wait mode, sanity check */ in lpfc_write_firmware()
14633 rc = -ENXIO; in lpfc_write_firmware()
14636 image = (struct lpfc_grp_hdr *)fw->data; in lpfc_write_firmware()
14638 magic_number = be32_to_cpu(image->magic_number); in lpfc_write_firmware()
14641 fsize = be32_to_cpu(image->size); in lpfc_write_firmware()
14645 if (strncmp(fwrev, image->revision, strnlen(image->revision, 16))) { in lpfc_write_firmware()
14649 fwrev, image->revision); in lpfc_write_firmware()
14654 rc = -ENOMEM; in lpfc_write_firmware()
14657 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_write_firmware()
14659 &dmabuf->phys, in lpfc_write_firmware()
14661 if (!dmabuf->virt) { in lpfc_write_firmware()
14663 rc = -ENOMEM; in lpfc_write_firmware()
14666 list_add_tail(&dmabuf->list, &dma_buffer_list); in lpfc_write_firmware()
14668 while (offset < fw->size) { in lpfc_write_firmware()
14671 if (temp_offset + SLI4_PAGE_SIZE > fw->size) { in lpfc_write_firmware()
14672 memcpy(dmabuf->virt, in lpfc_write_firmware()
14673 fw->data + temp_offset, in lpfc_write_firmware()
14674 fw->size - temp_offset); in lpfc_write_firmware()
14675 temp_offset = fw->size; in lpfc_write_firmware()
14678 memcpy(dmabuf->virt, fw->data + temp_offset, in lpfc_write_firmware()
14683 (fw->size - offset), &offset); in lpfc_write_firmware()
14699 fwrev, image->revision); in lpfc_write_firmware()
14703 list_del(&dmabuf->list); in lpfc_write_firmware()
14704 dma_free_coherent(&phba->pcidev->dev, SLI4_PAGE_SIZE, in lpfc_write_firmware()
14705 dmabuf->virt, dmabuf->phys); in lpfc_write_firmware()
14719 * lpfc_sli4_request_firmware_update - Request linux generic firmware upgrade
14734 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_request_firmware_update()
14736 return -EPERM; in lpfc_sli4_request_firmware_update()
14738 scnprintf(file_name, sizeof(file_name), "%s.grp", phba->ModelName); in lpfc_sli4_request_firmware_update()
14742 file_name, &phba->pcidev->dev, in lpfc_sli4_request_firmware_update()
14746 ret = request_firmware(&fw, file_name, &phba->pcidev->dev); in lpfc_sli4_request_firmware_update()
14750 ret = -EINVAL; in lpfc_sli4_request_firmware_update()
14757 * lpfc_pci_probe_one_s4 - PCI probe func to reg SLI-4 device to PCI subsys
14762 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
14763 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
14771 * 0 - driver can claim the device
14772 * negative value - driver can not claim the device
14786 return -ENOMEM; in lpfc_pci_probe_one_s4()
14788 INIT_LIST_HEAD(&phba->poll_list); in lpfc_pci_probe_one_s4()
14795 /* Set up SLI API function jump table for PCI-device group-1 HBAs */ in lpfc_pci_probe_one_s4()
14800 /* Set up SLI-4 specific device PCI memory space */ in lpfc_pci_probe_one_s4()
14808 /* Set up SLI-4 Specific device driver resources */ in lpfc_pci_probe_one_s4()
14816 spin_lock_init(&phba->rrq_list_lock); in lpfc_pci_probe_one_s4()
14817 INIT_LIST_HEAD(&phba->active_rrq_list); in lpfc_pci_probe_one_s4()
14818 INIT_LIST_HEAD(&phba->fcf.fcf_pri_list); in lpfc_pci_probe_one_s4()
14829 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s4()
14832 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s4()
14835 phba->pport = NULL; in lpfc_pci_probe_one_s4()
14849 error = -ENODEV; in lpfc_pci_probe_one_s4()
14852 /* Default to single EQ for non-MSI-X */ in lpfc_pci_probe_one_s4()
14853 if (phba->intr_type != MSIX) { in lpfc_pci_probe_one_s4()
14854 phba->cfg_irq_chann = 1; in lpfc_pci_probe_one_s4()
14855 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
14856 if (phba->nvmet_support) in lpfc_pci_probe_one_s4()
14857 phba->cfg_nvmet_mrq = 1; in lpfc_pci_probe_one_s4()
14860 lpfc_cpu_affinity_check(phba, phba->cfg_irq_chann); in lpfc_pci_probe_one_s4()
14869 vport = phba->pport; in lpfc_pci_probe_one_s4()
14880 /* Set up SLI-4 HBA */ in lpfc_pci_probe_one_s4()
14884 error = -ENODEV; in lpfc_pci_probe_one_s4()
14889 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s4()
14898 if (phba->nvmet_support == 0) { in lpfc_pci_probe_one_s4()
14899 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
14916 if (phba->cfg_request_firmware_upgrade) in lpfc_pci_probe_one_s4()
14922 timer_setup(&phba->cpuhp_poll_timer, lpfc_sli4_poll_hbtimer, 0); in lpfc_pci_probe_one_s4()
14923 cpuhp_state_add_instance_nocalls(lpfc_cpuhp_state, &phba->cpuhp); in lpfc_pci_probe_one_s4()
14949 * lpfc_pci_remove_one_s4 - PCI func to unreg SLI-4 device from PCI subsystem
14953 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
14961 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s4()
14963 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s4()
14967 set_bit(FC_UNLOADING, &vport->load_flag); in lpfc_pci_remove_one_s4()
14968 if (phba->cgn_i) in lpfc_pci_remove_one_s4()
14976 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s4()
14977 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s4()
14979 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s4()
14994 /* De-allocate multi-XRI pools */ in lpfc_pci_remove_one_s4()
14995 if (phba->cfg_xri_rebalancing) in lpfc_pci_remove_one_s4()
15006 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
15007 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s4()
15008 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
15034 * lpfc_pci_suspend_one_s4 - PCI func to suspend SLI-4 device for power mgmnt
15038 * Power Management (PM) to device with SLI-4 interface spec. When PM invokes
15042 * requirements to a power-aware driver's PM support for suspend/resume -- all
15050 * 0 - driver suspended the device
15057 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s4()
15065 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s4()
15075 * lpfc_pci_resume_one_s4 - PCI func to resume SLI-4 device for power mgmnt
15079 * Power Management (PM) to device with SLI-4 interface spac. When PM invokes
15082 * implements the minimum PM requirements to a power-aware driver's PM for
15083 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
15090 * 0 - driver suspended the device
15097 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s4()
15105 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s4()
15106 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s4()
15107 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s4()
15108 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s4()
15116 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
15120 return -EIO; in lpfc_pci_resume_one_s4()
15122 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s4()
15129 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
15135 * lpfc_sli4_prep_dev_for_recover - Prepare SLI4 device for pci slot recover
15148 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli4_prep_dev_for_recover()
15154 * lpfc_sli4_prep_dev_for_reset - Prepare SLI4 device for pci slot reset
15164 int offline = pci_channel_offline(phba->pcidev); in lpfc_sli4_prep_dev_for_reset()
15186 pci_disable_device(phba->pcidev); in lpfc_sli4_prep_dev_for_reset()
15190 * lpfc_sli4_prep_dev_for_perm_failure - Prepare SLI4 dev for pci slot disable
15214 * lpfc_io_error_detected_s4 - Method for handling PCI I/O error to SLI-4 device
15219 * with SLI-4 interface spec. This function is called by the PCI subsystem
15226 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
15227 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15233 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s4()
15238 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s4()
15242 hba_pci_err = test_and_set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15252 set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15257 hba_pci_err = test_and_set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15269 * lpfc_io_slot_reset_s4 - Method for restart PCI SLI-4 device from scratch
15273 * with SLI-4 interface spec. It is called after PCI bus has been reset to
15274 * restart the PCI card from scratch, as if from a cold-boot. During the
15283 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
15284 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15290 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s4()
15291 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s4()
15295 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s4()
15297 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s4()
15304 hba_pci_err = test_and_clear_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_slot_reset_s4()
15306 dev_info(&pdev->dev, in lpfc_io_slot_reset_s4()
15314 if (pdev->is_busmaster) in lpfc_io_slot_reset_s4()
15317 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
15318 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s4()
15319 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
15324 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
15327 "2824 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s4()
15331 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s4()
15332 lpfc_cpu_affinity_check(phba, phba->cfg_irq_chann); in lpfc_io_slot_reset_s4()
15335 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
15341 * lpfc_io_resume_s4 - Method for resuming PCI I/O operation to SLI-4 device
15345 * with SLI-4 interface spec. It is called when kernel error recovery tells
15354 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s4()
15362 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) { in lpfc_io_resume_s4()
15371 * lpfc_pci_probe_one - lpfc PCI probe func to reg dev to PCI subsystem
15377 * at PCI device-specific information of the device and driver to see if the
15380 * the action to the proper SLI-3 or SLI-4 device probing routine, which will
15385 * 0 - driver can claim the device
15386 * negative value - driver can not claim the device
15395 return -ENODEV; in lpfc_pci_probe_one()
15407 * lpfc_pci_remove_one - lpfc PCI func to unreg dev from PCI subsystem
15412 * This routine dispatches the action to the proper SLI-3 or SLI-4 device
15420 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_remove_one()
15422 switch (phba->pci_dev_grp) { in lpfc_pci_remove_one()
15432 phba->pci_dev_grp); in lpfc_pci_remove_one()
15439 * lpfc_pci_suspend_one - lpfc PCI func to suspend dev for power management
15444 * the action to the proper SLI-3 or SLI-4 device suspend routine, which will
15448 * 0 - driver suspended the device
15455 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one()
15456 int rc = -ENODEV; in lpfc_pci_suspend_one()
15458 switch (phba->pci_dev_grp) { in lpfc_pci_suspend_one()
15468 phba->pci_dev_grp); in lpfc_pci_suspend_one()
15475 * lpfc_pci_resume_one - lpfc PCI func to resume dev for power management
15480 * the action to the proper SLI-3 or SLI-4 device resume routine, which will
15484 * 0 - driver suspended the device
15491 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one()
15492 int rc = -ENODEV; in lpfc_pci_resume_one()
15494 switch (phba->pci_dev_grp) { in lpfc_pci_resume_one()
15504 phba->pci_dev_grp); in lpfc_pci_resume_one()
15511 * lpfc_io_error_detected - lpfc method for handling PCI I/O error
15518 * the action to the proper SLI-3 or SLI-4 device error detected handling
15522 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
15523 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15529 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected()
15532 if (phba->link_state == LPFC_HBA_ERROR && in lpfc_io_error_detected()
15533 test_bit(HBA_IOQ_FLUSH, &phba->hba_flag)) in lpfc_io_error_detected()
15536 switch (phba->pci_dev_grp) { in lpfc_io_error_detected()
15546 phba->pci_dev_grp); in lpfc_io_error_detected()
15553 * lpfc_io_slot_reset - lpfc method for restart PCI dev from scratch
15558 * from scratch, as if from a cold-boot. When this routine is invoked, it
15559 * dispatches the action to the proper SLI-3 or SLI-4 device reset handling
15563 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
15564 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15570 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset()
15573 switch (phba->pci_dev_grp) { in lpfc_io_slot_reset()
15583 phba->pci_dev_grp); in lpfc_io_slot_reset()
15590 * lpfc_io_resume - lpfc method for resuming PCI I/O operation
15596 * this routine is invoked, it dispatches the action to the proper SLI-3
15597 * or SLI-4 device io_resume routine, which will resume the device operation.
15603 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume()
15605 switch (phba->pci_dev_grp) { in lpfc_io_resume()
15615 phba->pci_dev_grp); in lpfc_io_resume()
15622 * lpfc_sli4_oas_verify - Verify OAS is supported by this adapter
15635 if (!phba->cfg_EnableXLane) in lpfc_sli4_oas_verify()
15638 if (phba->sli4_hba.pc_sli4_params.oas_supported) { in lpfc_sli4_oas_verify()
15639 phba->cfg_fof = 1; in lpfc_sli4_oas_verify()
15641 phba->cfg_fof = 0; in lpfc_sli4_oas_verify()
15642 mempool_destroy(phba->device_data_mem_pool); in lpfc_sli4_oas_verify()
15643 phba->device_data_mem_pool = NULL; in lpfc_sli4_oas_verify()
15650 * lpfc_sli4_ras_init - Verify RAS-FW log is supported by this adapter
15660 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_ras_init()
15662 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_sli4_ras_init()
15664 phba->ras_fwlog.ras_hwsupport = true; in lpfc_sli4_ras_init()
15665 if (phba->cfg_ras_fwlog_func == PCI_FUNC(phba->pcidev->devfn) && in lpfc_sli4_ras_init()
15666 phba->cfg_ras_fwlog_buffsize) in lpfc_sli4_ras_init()
15667 phba->ras_fwlog.ras_enabled = true; in lpfc_sli4_ras_init()
15669 phba->ras_fwlog.ras_enabled = false; in lpfc_sli4_ras_init()
15671 phba->ras_fwlog.ras_hwsupport = false; in lpfc_sli4_ras_init()
15709 * lpfc_init - lpfc module initialization routine
15716 * 0 - successful
15717 * -ENOMEM - FC attach transport failed
15718 * all others - failed
15733 error = -ENOMEM; in lpfc_init()
15787 if (atomic_cmpxchg(&phba->dbg_log_dmping, 0, 1) != 0) in lpfc_dmp_dbg()
15790 start_idx = (unsigned int)atomic_read(&phba->dbg_log_idx) % DBG_LOG_SZ; in lpfc_dmp_dbg()
15791 dbg_cnt = (unsigned int)atomic_read(&phba->dbg_log_cnt); in lpfc_dmp_dbg()
15797 temp_idx -= 1; in lpfc_dmp_dbg()
15799 if ((start_idx + dbg_cnt) > (DBG_LOG_SZ - 1)) { in lpfc_dmp_dbg()
15803 start_idx = DBG_LOG_SZ - (dbg_cnt - start_idx); in lpfc_dmp_dbg()
15805 start_idx -= dbg_cnt; in lpfc_dmp_dbg()
15808 dev_info(&phba->pcidev->dev, "start %d end %d cnt %d\n", in lpfc_dmp_dbg()
15816 rem_nsec = do_div(phba->dbg_log[temp_idx].t_ns, NSEC_PER_SEC); in lpfc_dmp_dbg()
15817 dev_info(&phba->pcidev->dev, "%d: [%5lu.%06lu] %s", in lpfc_dmp_dbg()
15819 (unsigned long)phba->dbg_log[temp_idx].t_ns, in lpfc_dmp_dbg()
15821 phba->dbg_log[temp_idx].log); in lpfc_dmp_dbg()
15824 atomic_set(&phba->dbg_log_cnt, 0); in lpfc_dmp_dbg()
15825 atomic_set(&phba->dbg_log_dmping, 0); in lpfc_dmp_dbg()
15833 int dbg_dmping = atomic_read(&phba->dbg_log_dmping); in lpfc_dbg_print()
15841 dev_info(&phba->pcidev->dev, "%pV", &vaf); in lpfc_dbg_print()
15845 idx = (unsigned int)atomic_fetch_add(1, &phba->dbg_log_idx) % in lpfc_dbg_print()
15848 atomic_inc(&phba->dbg_log_cnt); in lpfc_dbg_print()
15850 vscnprintf(phba->dbg_log[idx].log, in lpfc_dbg_print()
15851 sizeof(phba->dbg_log[idx].log), fmt, args); in lpfc_dbg_print()
15854 phba->dbg_log[idx].t_ns = local_clock(); in lpfc_dbg_print()
15858 * lpfc_exit - lpfc module removal routine