Lines Matching +full:temperature +full:- +full:tracking

4  * Copyright (C) 2017-2025 Broadcom. All Rights Reserved. The term *
6 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
9 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
17 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
26 #include <linux/dma-mapping.h>
108 * lpfc_config_port_prep - Perform lpfc initialization prior to config port
117 * 0 - success.
118 * -ERESTART - requests the SLI layer to reset the HBA and try again.
119 * Any other value - indicates an error.
124 lpfc_vpd_t *vp = &phba->vpd; in lpfc_config_port_prep()
134 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_prep()
136 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_prep()
137 return -ENOMEM; in lpfc_config_port_prep()
140 mb = &pmb->u.mb; in lpfc_config_port_prep()
141 phba->link_state = LPFC_INIT_MBX_CMDS; in lpfc_config_port_prep()
143 if (lpfc_is_LC_HBA(phba->pcidev->device)) { in lpfc_config_port_prep()
153 memset((char*)mb->un.varRDnvp.rsvd3, 0, in lpfc_config_port_prep()
154 sizeof (mb->un.varRDnvp.rsvd3)); in lpfc_config_port_prep()
155 memcpy((char*)mb->un.varRDnvp.rsvd3, licensed, in lpfc_config_port_prep()
165 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_prep()
166 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
167 return -ERESTART; in lpfc_config_port_prep()
169 memcpy(phba->wwnn, (char *)mb->un.varRDnvp.nodename, in lpfc_config_port_prep()
170 sizeof(phba->wwnn)); in lpfc_config_port_prep()
171 memcpy(phba->wwpn, (char *)mb->un.varRDnvp.portname, in lpfc_config_port_prep()
172 sizeof(phba->wwpn)); in lpfc_config_port_prep()
179 phba->sli3_options &= (uint32_t)LPFC_SLI3_BG_ENABLED; in lpfc_config_port_prep()
188 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_prep()
189 mempool_free( pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
190 return -ERESTART; in lpfc_config_port_prep()
198 if (mb->un.varRdRev.rr == 0) { in lpfc_config_port_prep()
199 vp->rev.rBit = 0; in lpfc_config_port_prep()
203 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
204 return -ERESTART; in lpfc_config_port_prep()
207 if (phba->sli_rev == 3 && !mb->un.varRdRev.v3rsp) { in lpfc_config_port_prep()
208 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
209 return -EINVAL; in lpfc_config_port_prep()
213 vp->rev.rBit = 1; in lpfc_config_port_prep()
214 memcpy(&vp->sli3Feat, &mb->un.varRdRev.sli3Feat, sizeof(uint32_t)); in lpfc_config_port_prep()
215 vp->rev.sli1FwRev = mb->un.varRdRev.sli1FwRev; in lpfc_config_port_prep()
216 memcpy(vp->rev.sli1FwName, (char*) mb->un.varRdRev.sli1FwName, 16); in lpfc_config_port_prep()
217 vp->rev.sli2FwRev = mb->un.varRdRev.sli2FwRev; in lpfc_config_port_prep()
218 memcpy(vp->rev.sli2FwName, (char *) mb->un.varRdRev.sli2FwName, 16); in lpfc_config_port_prep()
219 vp->rev.biuRev = mb->un.varRdRev.biuRev; in lpfc_config_port_prep()
220 vp->rev.smRev = mb->un.varRdRev.smRev; in lpfc_config_port_prep()
221 vp->rev.smFwRev = mb->un.varRdRev.un.smFwRev; in lpfc_config_port_prep()
222 vp->rev.endecRev = mb->un.varRdRev.endecRev; in lpfc_config_port_prep()
223 vp->rev.fcphHigh = mb->un.varRdRev.fcphHigh; in lpfc_config_port_prep()
224 vp->rev.fcphLow = mb->un.varRdRev.fcphLow; in lpfc_config_port_prep()
225 vp->rev.feaLevelHigh = mb->un.varRdRev.feaLevelHigh; in lpfc_config_port_prep()
226 vp->rev.feaLevelLow = mb->un.varRdRev.feaLevelLow; in lpfc_config_port_prep()
227 vp->rev.postKernRev = mb->un.varRdRev.postKernRev; in lpfc_config_port_prep()
228 vp->rev.opFwRev = mb->un.varRdRev.opFwRev; in lpfc_config_port_prep()
234 if (vp->rev.feaLevelHigh < 9) in lpfc_config_port_prep()
235 phba->sli3_options |= LPFC_SLI3_VPORT_TEARDOWN; in lpfc_config_port_prep()
237 if (lpfc_is_LC_HBA(phba->pcidev->device)) in lpfc_config_port_prep()
238 memcpy(phba->RandomData, (char *)&mb->un.varWords[24], in lpfc_config_port_prep()
239 sizeof (phba->RandomData)); in lpfc_config_port_prep()
253 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_prep()
254 mb->un.varDmp.word_cnt = 0; in lpfc_config_port_prep()
259 if (mb->un.varDmp.word_cnt == 0) in lpfc_config_port_prep()
262 if (mb->un.varDmp.word_cnt > DMP_VPD_SIZE - offset) in lpfc_config_port_prep()
263 mb->un.varDmp.word_cnt = DMP_VPD_SIZE - offset; in lpfc_config_port_prep()
266 mb->un.varDmp.word_cnt); in lpfc_config_port_prep()
267 offset += mb->un.varDmp.word_cnt; in lpfc_config_port_prep()
268 } while (mb->un.varDmp.word_cnt && offset < DMP_VPD_SIZE); in lpfc_config_port_prep()
274 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
279 * lpfc_config_async_cmpl - Completion handler for config async event mbox cmd
291 if (pmboxq->u.mb.mbxStatus == MBX_SUCCESS) in lpfc_config_async_cmpl()
292 phba->temp_sensor_support = 1; in lpfc_config_async_cmpl()
294 phba->temp_sensor_support = 0; in lpfc_config_async_cmpl()
295 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_config_async_cmpl()
300 * lpfc_dump_wakeup_param_cmpl - dump memory mailbox command completion handler
318 if (pmboxq->u.mb.mbxStatus != MBX_SUCCESS) { in lpfc_dump_wakeup_param_cmpl()
319 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_dump_wakeup_param_cmpl()
326 prog_id_word = pmboxq->u.mb.un.varWords[7]; in lpfc_dump_wakeup_param_cmpl()
329 dist = dist_char[prg->dist]; in lpfc_dump_wakeup_param_cmpl()
331 if ((prg->dist == 3) && (prg->num == 0)) in lpfc_dump_wakeup_param_cmpl()
332 snprintf(phba->OptionROMVersion, 32, "%d.%d%d", in lpfc_dump_wakeup_param_cmpl()
333 prg->ver, prg->rev, prg->lev); in lpfc_dump_wakeup_param_cmpl()
335 snprintf(phba->OptionROMVersion, 32, "%d.%d%d%c%d", in lpfc_dump_wakeup_param_cmpl()
336 prg->ver, prg->rev, prg->lev, in lpfc_dump_wakeup_param_cmpl()
337 dist, prg->num); in lpfc_dump_wakeup_param_cmpl()
338 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_dump_wakeup_param_cmpl()
343 * lpfc_update_vport_wwn - Updates the fc_nodename, fc_portname,
353 struct lpfc_hba *phba = vport->phba; in lpfc_update_vport_wwn()
359 if (vport->fc_nodename.u.wwn[0] == 0) in lpfc_update_vport_wwn()
360 memcpy(&vport->fc_nodename, &vport->fc_sparam.nodeName, in lpfc_update_vport_wwn()
363 memcpy(&vport->fc_sparam.nodeName, &vport->fc_nodename, in lpfc_update_vport_wwn()
370 if (vport->fc_portname.u.wwn[0] != 0 && in lpfc_update_vport_wwn()
371 memcmp(&vport->fc_portname, &vport->fc_sparam.portName, in lpfc_update_vport_wwn()
373 vport->vport_flag |= FAWWPN_PARAM_CHG; in lpfc_update_vport_wwn()
375 if (phba->sli_rev == LPFC_SLI_REV4 && in lpfc_update_vport_wwn()
376 vport->port_type == LPFC_PHYSICAL_PORT && in lpfc_update_vport_wwn()
377 phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_FABRIC) { in lpfc_update_vport_wwn()
378 if (!(phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_CONFIG)) in lpfc_update_vport_wwn()
379 phba->sli4_hba.fawwpn_flag &= in lpfc_update_vport_wwn()
383 "2701 FA-PWWN change WWPN from %llx to " in lpfc_update_vport_wwn()
385 wwn_to_u64(vport->fc_portname.u.wwn), in lpfc_update_vport_wwn()
387 (vport->fc_sparam.portName.u.wwn), in lpfc_update_vport_wwn()
388 vport->vport_flag, in lpfc_update_vport_wwn()
389 phba->sli4_hba.fawwpn_flag); in lpfc_update_vport_wwn()
390 memcpy(&vport->fc_portname, &vport->fc_sparam.portName, in lpfc_update_vport_wwn()
395 if (vport->fc_portname.u.wwn[0] == 0) in lpfc_update_vport_wwn()
396 memcpy(&vport->fc_portname, &vport->fc_sparam.portName, in lpfc_update_vport_wwn()
399 memcpy(&vport->fc_sparam.portName, &vport->fc_portname, in lpfc_update_vport_wwn()
404 * lpfc_config_port_post - Perform lpfc initialization after config port
413 * 0 - success.
414 * Any other value - error.
419 struct lpfc_vport *vport = phba->pport; in lpfc_config_port_post()
424 struct lpfc_sli *psli = &phba->sli; in lpfc_config_port_post()
429 spin_lock_irq(&phba->hbalock); in lpfc_config_port_post()
434 if (phba->over_temp_state == HBA_OVER_TEMP) in lpfc_config_port_post()
435 phba->over_temp_state = HBA_NORMAL_TEMP; in lpfc_config_port_post()
436 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
438 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
440 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
441 return -ENOMEM; in lpfc_config_port_post()
443 mb = &pmb->u.mb; in lpfc_config_port_post()
448 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
449 return -ENOMEM; in lpfc_config_port_post()
452 pmb->vport = vport; in lpfc_config_port_post()
457 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_post()
458 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
460 return -EIO; in lpfc_config_port_post()
463 mp = pmb->ctx_buf; in lpfc_config_port_post()
469 memcpy(&vport->fc_sparam, mp->virt, sizeof (struct serv_parm)); in lpfc_config_port_post()
470 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_config_port_post()
472 pmb->ctx_buf = NULL; in lpfc_config_port_post()
476 fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); in lpfc_config_port_post()
477 fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); in lpfc_config_port_post()
478 fc_host_max_npiv_vports(shost) = phba->max_vpi; in lpfc_config_port_post()
481 /* This should be consolidated into parse_vpd ? - mr */ in lpfc_config_port_post()
482 if (phba->SerialNumber[0] == 0) { in lpfc_config_port_post()
485 outptr = &vport->fc_nodename.u.s.IEEE[0]; in lpfc_config_port_post()
490 phba->SerialNumber[i] = in lpfc_config_port_post()
493 phba->SerialNumber[i] = in lpfc_config_port_post()
494 (char)((uint8_t) 0x61 + (uint8_t) (j - 10)); in lpfc_config_port_post()
498 phba->SerialNumber[i] = in lpfc_config_port_post()
501 phba->SerialNumber[i] = in lpfc_config_port_post()
502 (char)((uint8_t) 0x61 + (uint8_t) (j - 10)); in lpfc_config_port_post()
507 pmb->vport = vport; in lpfc_config_port_post()
512 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_post()
513 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
514 mempool_free( pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
515 return -EIO; in lpfc_config_port_post()
522 if (phba->cfg_hba_queue_depth > mb->un.varRdConfig.max_xri) { in lpfc_config_port_post()
525 phba->cfg_hba_queue_depth, in lpfc_config_port_post()
526 mb->un.varRdConfig.max_xri); in lpfc_config_port_post()
527 phba->cfg_hba_queue_depth = mb->un.varRdConfig.max_xri; in lpfc_config_port_post()
530 phba->lmt = mb->un.varRdConfig.lmt; in lpfc_config_port_post()
533 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_config_port_post()
535 phba->link_state = LPFC_LINK_DOWN; in lpfc_config_port_post()
538 if (psli->sli3_ring[LPFC_EXTRA_RING].sli.sli3.cmdringaddr) in lpfc_config_port_post()
539 psli->sli3_ring[LPFC_EXTRA_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_config_port_post()
540 if (psli->sli3_ring[LPFC_FCP_RING].sli.sli3.cmdringaddr) in lpfc_config_port_post()
541 psli->sli3_ring[LPFC_FCP_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_config_port_post()
544 if (phba->sli_rev != 3) in lpfc_config_port_post()
548 * Configure HBA MSI-X attention conditions to messages if MSI-X mode in lpfc_config_port_post()
550 if (phba->intr_type == MSIX) { in lpfc_config_port_post()
553 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
554 return -EIO; in lpfc_config_port_post()
561 pmb->u.mb.mbxCommand, in lpfc_config_port_post()
562 pmb->u.mb.mbxStatus); in lpfc_config_port_post()
563 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
564 return -EIO; in lpfc_config_port_post()
568 spin_lock_irq(&phba->hbalock); in lpfc_config_port_post()
570 clear_bit(HBA_ERATT_HANDLED, &phba->hba_flag); in lpfc_config_port_post()
573 if (lpfc_readl(phba->HCregaddr, &status)) { in lpfc_config_port_post()
574 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
575 return -EIO; in lpfc_config_port_post()
578 if (psli->num_rings > 0) in lpfc_config_port_post()
580 if (psli->num_rings > 1) in lpfc_config_port_post()
582 if (psli->num_rings > 2) in lpfc_config_port_post()
584 if (psli->num_rings > 3) in lpfc_config_port_post()
587 if ((phba->cfg_poll & ENABLE_FCP_RING_POLLING) && in lpfc_config_port_post()
588 (phba->cfg_poll & DISABLE_FCP_RING_INT)) in lpfc_config_port_post()
591 writel(status, phba->HCregaddr); in lpfc_config_port_post()
592 readl(phba->HCregaddr); /* flush */ in lpfc_config_port_post()
593 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
595 /* Set up ring-0 (ELS) timer */ in lpfc_config_port_post()
596 timeout = phba->fc_ratov * 2; in lpfc_config_port_post()
597 mod_timer(&vport->els_tmofunc, in lpfc_config_port_post()
600 mod_timer(&phba->hb_tmofunc, in lpfc_config_port_post()
602 clear_bit(HBA_HBEAT_INP, &phba->hba_flag); in lpfc_config_port_post()
603 clear_bit(HBA_HBEAT_TMO, &phba->hba_flag); in lpfc_config_port_post()
604 phba->last_completion_time = jiffies; in lpfc_config_port_post()
606 mod_timer(&phba->eratt_poll, in lpfc_config_port_post()
607 jiffies + secs_to_jiffies(phba->eratt_poll_interval)); in lpfc_config_port_post()
609 if (test_bit(LINK_DISABLED, &phba->hba_flag)) { in lpfc_config_port_post()
613 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_config_port_post()
620 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
621 return -EIO; in lpfc_config_port_post()
623 } else if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) { in lpfc_config_port_post()
624 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
625 rc = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); in lpfc_config_port_post()
630 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
632 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
633 return -ENOMEM; in lpfc_config_port_post()
637 pmb->mbox_cmpl = lpfc_config_async_cmpl; in lpfc_config_port_post()
638 pmb->vport = phba->pport; in lpfc_config_port_post()
646 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
650 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
652 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
653 return -ENOMEM; in lpfc_config_port_post()
657 pmb->mbox_cmpl = lpfc_dump_wakeup_param_cmpl; in lpfc_config_port_post()
658 pmb->vport = phba->pport; in lpfc_config_port_post()
665 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
672 * lpfc_sli4_refresh_params - update driver copy of params.
686 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_refresh_params()
688 return -ENOMEM; in lpfc_sli4_refresh_params()
690 mqe = &mboxq->u.mqe; in lpfc_sli4_refresh_params()
692 length = (sizeof(struct lpfc_mbx_get_sli4_parameters) - in lpfc_sli4_refresh_params()
700 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_refresh_params()
703 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters; in lpfc_sli4_refresh_params()
704 phba->sli4_hba.pc_sli4_params.mi_cap = in lpfc_sli4_refresh_params()
708 if (phba->cfg_enable_mi) in lpfc_sli4_refresh_params()
709 phba->sli4_hba.pc_sli4_params.mi_ver = in lpfc_sli4_refresh_params()
712 phba->sli4_hba.pc_sli4_params.mi_ver = 0; in lpfc_sli4_refresh_params()
714 phba->sli4_hba.pc_sli4_params.cmf = in lpfc_sli4_refresh_params()
716 phba->sli4_hba.pc_sli4_params.pls = in lpfc_sli4_refresh_params()
719 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_refresh_params()
724 * lpfc_hba_init_link - Initialize the FC link
726 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
734 * 0 - success
735 * Any other value - error
740 return lpfc_hba_init_link_fc_topology(phba, phba->cfg_topology, flag); in lpfc_hba_init_link()
744 * lpfc_hba_init_link_fc_topology - Initialize FC link with desired topology
747 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
755 * 0 - success
756 * Any other value - error
762 struct lpfc_vport *vport = phba->pport; in lpfc_hba_init_link_fc_topology()
767 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_hba_init_link_fc_topology()
769 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_init_link_fc_topology()
770 return -ENOMEM; in lpfc_hba_init_link_fc_topology()
772 mb = &pmb->u.mb; in lpfc_hba_init_link_fc_topology()
773 pmb->vport = vport; in lpfc_hba_init_link_fc_topology()
775 if ((phba->cfg_link_speed > LPFC_USER_LINK_SPEED_MAX) || in lpfc_hba_init_link_fc_topology()
776 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_1G) && in lpfc_hba_init_link_fc_topology()
777 !(phba->lmt & LMT_1Gb)) || in lpfc_hba_init_link_fc_topology()
778 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_2G) && in lpfc_hba_init_link_fc_topology()
779 !(phba->lmt & LMT_2Gb)) || in lpfc_hba_init_link_fc_topology()
780 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_4G) && in lpfc_hba_init_link_fc_topology()
781 !(phba->lmt & LMT_4Gb)) || in lpfc_hba_init_link_fc_topology()
782 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_8G) && in lpfc_hba_init_link_fc_topology()
783 !(phba->lmt & LMT_8Gb)) || in lpfc_hba_init_link_fc_topology()
784 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_10G) && in lpfc_hba_init_link_fc_topology()
785 !(phba->lmt & LMT_10Gb)) || in lpfc_hba_init_link_fc_topology()
786 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G) && in lpfc_hba_init_link_fc_topology()
787 !(phba->lmt & LMT_16Gb)) || in lpfc_hba_init_link_fc_topology()
788 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_32G) && in lpfc_hba_init_link_fc_topology()
789 !(phba->lmt & LMT_32Gb)) || in lpfc_hba_init_link_fc_topology()
790 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_64G) && in lpfc_hba_init_link_fc_topology()
791 !(phba->lmt & LMT_64Gb))) { in lpfc_hba_init_link_fc_topology()
796 phba->cfg_link_speed); in lpfc_hba_init_link_fc_topology()
797 phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; in lpfc_hba_init_link_fc_topology()
799 lpfc_init_link(phba, pmb, fc_topology, phba->cfg_link_speed); in lpfc_hba_init_link_fc_topology()
800 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_hba_init_link_fc_topology()
801 if (phba->sli_rev < LPFC_SLI_REV4) in lpfc_hba_init_link_fc_topology()
808 mb->mbxCommand, mb->mbxStatus); in lpfc_hba_init_link_fc_topology()
809 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_hba_init_link_fc_topology()
811 writel(0, phba->HCregaddr); in lpfc_hba_init_link_fc_topology()
812 readl(phba->HCregaddr); /* flush */ in lpfc_hba_init_link_fc_topology()
814 writel(0xffffffff, phba->HAregaddr); in lpfc_hba_init_link_fc_topology()
815 readl(phba->HAregaddr); /* flush */ in lpfc_hba_init_link_fc_topology()
817 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_init_link_fc_topology()
819 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_init_link_fc_topology()
820 return -EIO; in lpfc_hba_init_link_fc_topology()
822 phba->cfg_suppress_link_up = LPFC_INITIALIZE_LINK; in lpfc_hba_init_link_fc_topology()
824 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_init_link_fc_topology()
830 * lpfc_hba_down_link - this routine downs the FC link
832 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
839 * 0 - success
840 * Any other value - error
848 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_hba_down_link()
850 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_down_link()
851 return -ENOMEM; in lpfc_hba_down_link()
857 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_hba_down_link()
864 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_down_link()
865 return -EIO; in lpfc_hba_down_link()
868 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_down_link()
874 * lpfc_hba_down_prep - Perform lpfc uninitialization prior to HBA reset
881 * 0 - success.
882 * Any other value - error.
890 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_hba_down_prep()
892 writel(0, phba->HCregaddr); in lpfc_hba_down_prep()
893 readl(phba->HCregaddr); /* flush */ in lpfc_hba_down_prep()
896 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_hba_down_prep()
897 lpfc_cleanup_discovery_resources(phba->pport); in lpfc_hba_down_prep()
901 for (i = 0; i <= phba->max_vports && in lpfc_hba_down_prep()
910 * lpfc_sli4_free_sp_events - Cleanup sp_queue_events to free
929 clear_bit(HBA_SP_QUEUE_EVT, &phba->hba_flag); in lpfc_sli4_free_sp_events()
931 while (!list_empty(&phba->sli4_hba.sp_queue_event)) { in lpfc_sli4_free_sp_events()
933 spin_lock_irq(&phba->hbalock); in lpfc_sli4_free_sp_events()
934 list_remove_head(&phba->sli4_hba.sp_queue_event, in lpfc_sli4_free_sp_events()
936 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_free_sp_events()
938 switch (bf_get(lpfc_wcqe_c_code, &cq_event->cqe.wcqe_cmpl)) { in lpfc_sli4_free_sp_events()
948 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_free_sp_events()
954 * lpfc_hba_free_post_buf - Perform lpfc uninitialization after HBA reset
967 struct lpfc_sli *psli = &phba->sli; in lpfc_hba_free_post_buf()
973 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) in lpfc_hba_free_post_buf()
977 pring = &psli->sli3_ring[LPFC_ELS_RING]; in lpfc_hba_free_post_buf()
978 spin_lock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
979 list_splice_init(&pring->postbufq, &buflist); in lpfc_hba_free_post_buf()
980 spin_unlock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
984 list_del(&mp->list); in lpfc_hba_free_post_buf()
986 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_hba_free_post_buf()
990 spin_lock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
991 pring->postbufq_cnt -= count; in lpfc_hba_free_post_buf()
992 spin_unlock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
997 * lpfc_hba_clean_txcmplq - Perform lpfc uninitialization after HBA reset
1009 struct lpfc_sli *psli = &phba->sli; in lpfc_hba_clean_txcmplq()
1016 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_hba_clean_txcmplq()
1017 for (i = 0; i < psli->num_rings; i++) { in lpfc_hba_clean_txcmplq()
1018 pring = &psli->sli3_ring[i]; in lpfc_hba_clean_txcmplq()
1019 spin_lock_irq(&phba->hbalock); in lpfc_hba_clean_txcmplq()
1024 list_splice_init(&pring->txcmplq, &completions); in lpfc_hba_clean_txcmplq()
1025 pring->txcmplq_cnt = 0; in lpfc_hba_clean_txcmplq()
1026 spin_unlock_irq(&phba->hbalock); in lpfc_hba_clean_txcmplq()
1035 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_hba_clean_txcmplq()
1036 pring = qp->pring; in lpfc_hba_clean_txcmplq()
1039 spin_lock_irq(&pring->ring_lock); in lpfc_hba_clean_txcmplq()
1041 &pring->txcmplq, list) in lpfc_hba_clean_txcmplq()
1042 piocb->cmd_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_hba_clean_txcmplq()
1043 list_splice_init(&pring->txcmplq, &completions); in lpfc_hba_clean_txcmplq()
1044 pring->txcmplq_cnt = 0; in lpfc_hba_clean_txcmplq()
1045 spin_unlock_irq(&pring->ring_lock); in lpfc_hba_clean_txcmplq()
1054 * lpfc_hba_down_post_s3 - Perform lpfc uninitialization after HBA reset
1061 * 0 - success.
1062 * Any other value - error.
1073 * lpfc_hba_down_post_s4 - Perform lpfc uninitialization after HBA reset
1080 * 0 - success.
1081 * Any other value - error.
1109 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_hba_down_post_s4()
1111 &phba->sli4_hba.lpfc_abts_els_sgl_list, list) in lpfc_hba_down_post_s4()
1112 sglq_entry->state = SGL_FREED; in lpfc_hba_down_post_s4()
1114 list_splice_init(&phba->sli4_hba.lpfc_abts_els_sgl_list, in lpfc_hba_down_post_s4()
1115 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_hba_down_post_s4()
1118 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_hba_down_post_s4()
1123 spin_lock_irq(&phba->hbalock); in lpfc_hba_down_post_s4()
1125 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_hba_down_post_s4()
1126 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_hba_down_post_s4()
1128 spin_lock(&qp->abts_io_buf_list_lock); in lpfc_hba_down_post_s4()
1129 list_splice_init(&qp->lpfc_abts_io_buf_list, in lpfc_hba_down_post_s4()
1133 psb->pCmd = NULL; in lpfc_hba_down_post_s4()
1134 psb->status = IOSTAT_SUCCESS; in lpfc_hba_down_post_s4()
1137 spin_lock(&qp->io_buf_list_put_lock); in lpfc_hba_down_post_s4()
1138 list_splice_init(&aborts, &qp->lpfc_io_buf_list_put); in lpfc_hba_down_post_s4()
1139 qp->put_io_bufs += qp->abts_scsi_io_bufs; in lpfc_hba_down_post_s4()
1140 qp->put_io_bufs += qp->abts_nvme_io_bufs; in lpfc_hba_down_post_s4()
1141 qp->abts_scsi_io_bufs = 0; in lpfc_hba_down_post_s4()
1142 qp->abts_nvme_io_bufs = 0; in lpfc_hba_down_post_s4()
1143 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_hba_down_post_s4()
1144 spin_unlock(&qp->abts_io_buf_list_lock); in lpfc_hba_down_post_s4()
1146 spin_unlock_irq(&phba->hbalock); in lpfc_hba_down_post_s4()
1148 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_hba_down_post_s4()
1149 spin_lock_irq(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_hba_down_post_s4()
1150 list_splice_init(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list, in lpfc_hba_down_post_s4()
1152 spin_unlock_irq(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_hba_down_post_s4()
1154 ctxp->flag &= ~(LPFC_NVME_XBUSY | LPFC_NVME_ABORT_OP); in lpfc_hba_down_post_s4()
1155 lpfc_nvmet_ctxbuf_post(phba, ctxp->ctxbuf); in lpfc_hba_down_post_s4()
1164 * lpfc_hba_down_post - Wrapper func for hba down post routine
1171 * 0 - success.
1172 * Any other value - error.
1177 return (*phba->lpfc_hba_down_post)(phba); in lpfc_hba_down_post()
1181 * lpfc_hb_timeout - The HBA-timer timeout handler
1184 * This is the HBA-timer timeout handler registered to the lpfc driver. When
1186 * work-port-events bitmap and the worker thread is notified. This timeout
1202 spin_lock_irqsave(&phba->pport->work_port_lock, iflag); in lpfc_hb_timeout()
1203 tmo_posted = phba->pport->work_port_events & WORKER_HB_TMO; in lpfc_hb_timeout()
1205 phba->pport->work_port_events |= WORKER_HB_TMO; in lpfc_hb_timeout()
1206 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); in lpfc_hb_timeout()
1215 * lpfc_rrq_timeout - The RRQ-timer timeout handler
1218 * This is the RRQ-timer timeout handler registered to the lpfc driver. When
1220 * work-port-events bitmap and the worker thread is notified. This timeout
1232 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { in lpfc_rrq_timeout()
1233 clear_bit(HBA_RRQ_ACTIVE, &phba->hba_flag); in lpfc_rrq_timeout()
1237 set_bit(HBA_RRQ_ACTIVE, &phba->hba_flag); in lpfc_rrq_timeout()
1242 * lpfc_hb_mbox_cmpl - The lpfc heart-beat mailbox command callback function
1246 * This is the callback function to the lpfc heart-beat mailbox command.
1247 * If configured, the lpfc driver issues the heart-beat mailbox command to
1249 * heart-beat mailbox command is issued, the driver shall set up heart-beat
1251 * heart-beat outstanding state. Once the mailbox command comes back and
1252 * no error conditions detected, the heart-beat mailbox command timer is
1253 * reset to LPFC_HB_MBOX_INTERVAL seconds and the heart-beat outstanding
1254 * state is cleared for the next heart-beat. If the timer expired with the
1255 * heart-beat outstanding state set, the driver will put the HBA offline.
1260 clear_bit(HBA_HBEAT_INP, &phba->hba_flag); in lpfc_hb_mbox_cmpl()
1261 clear_bit(HBA_HBEAT_TMO, &phba->hba_flag); in lpfc_hb_mbox_cmpl()
1263 /* Check and reset heart-beat timer if necessary */ in lpfc_hb_mbox_cmpl()
1264 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_hb_mbox_cmpl()
1265 if (!test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag) && in lpfc_hb_mbox_cmpl()
1266 !(phba->link_state == LPFC_HBA_ERROR) && in lpfc_hb_mbox_cmpl()
1267 !test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_hb_mbox_cmpl()
1268 mod_timer(&phba->hb_tmofunc, in lpfc_hb_mbox_cmpl()
1275 * lpfc_idle_stat_delay_work - idle_stat tracking
1277 * This routine tracks per-eq idle_stat and determines polling decisions.
1294 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_idle_stat_delay_work()
1297 if (phba->link_state == LPFC_HBA_ERROR || in lpfc_idle_stat_delay_work()
1298 test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag) || in lpfc_idle_stat_delay_work()
1299 phba->cmf_active_mode != LPFC_CFG_OFF) in lpfc_idle_stat_delay_work()
1303 hdwq = &phba->sli4_hba.hdwq[phba->sli4_hba.cpu_map[i].hdwq]; in lpfc_idle_stat_delay_work()
1304 eq = hdwq->hba_eq; in lpfc_idle_stat_delay_work()
1307 if (eq->chann != i) in lpfc_idle_stat_delay_work()
1310 idle_stat = &phba->sli4_hba.idle_stat[i]; in lpfc_idle_stat_delay_work()
1316 * percentage of 100 - the sum of the other consumption times. in lpfc_idle_stat_delay_work()
1319 diff_idle = wall_idle - idle_stat->prev_idle; in lpfc_idle_stat_delay_work()
1320 diff_wall = wall - idle_stat->prev_wall; in lpfc_idle_stat_delay_work()
1325 busy_time = diff_wall - diff_idle; in lpfc_idle_stat_delay_work()
1328 idle_percent = 100 - idle_percent; in lpfc_idle_stat_delay_work()
1331 eq->poll_mode = LPFC_QUEUE_WORK; in lpfc_idle_stat_delay_work()
1333 eq->poll_mode = LPFC_THREADED_IRQ; in lpfc_idle_stat_delay_work()
1335 idle_stat->prev_idle = wall_idle; in lpfc_idle_stat_delay_work()
1336 idle_stat->prev_wall = wall; in lpfc_idle_stat_delay_work()
1340 schedule_delayed_work(&phba->idle_stat_delay_work, in lpfc_idle_stat_delay_work()
1355 if (!phba->cfg_auto_imax || in lpfc_hb_eq_delay_work()
1356 test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_hb_eq_delay_work()
1359 if (phba->link_state == LPFC_HBA_ERROR || in lpfc_hb_eq_delay_work()
1360 test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_hb_eq_delay_work()
1363 ena_delay = kcalloc(phba->sli4_hba.num_possible_cpu, sizeof(*ena_delay), in lpfc_hb_eq_delay_work()
1368 for (i = 0; i < phba->cfg_irq_chann; i++) { in lpfc_hb_eq_delay_work()
1370 eq = phba->sli4_hba.hba_eq_hdl[i].eq; in lpfc_hb_eq_delay_work()
1373 if (eq->q_mode || eq->q_flag & HBA_EQ_DELAY_CHK) { in lpfc_hb_eq_delay_work()
1374 eq->q_flag &= ~HBA_EQ_DELAY_CHK; in lpfc_hb_eq_delay_work()
1375 ena_delay[eq->last_cpu] = 1; in lpfc_hb_eq_delay_work()
1380 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, i); in lpfc_hb_eq_delay_work()
1382 usdelay = (eqi->icnt >> 10) * LPFC_EQ_DELAY_STEP; in lpfc_hb_eq_delay_work()
1389 eqi->icnt = 0; in lpfc_hb_eq_delay_work()
1391 list_for_each_entry_safe(eq, eq_next, &eqi->list, cpu_list) { in lpfc_hb_eq_delay_work()
1392 if (unlikely(eq->last_cpu != i)) { in lpfc_hb_eq_delay_work()
1393 eqi_new = per_cpu_ptr(phba->sli4_hba.eq_info, in lpfc_hb_eq_delay_work()
1394 eq->last_cpu); in lpfc_hb_eq_delay_work()
1395 list_move_tail(&eq->cpu_list, &eqi_new->list); in lpfc_hb_eq_delay_work()
1398 if (usdelay != eq->q_mode) in lpfc_hb_eq_delay_work()
1399 lpfc_modify_hba_eq_delay(phba, eq->hdwq, 1, in lpfc_hb_eq_delay_work()
1407 queue_delayed_work(phba->wq, &phba->eq_delay_work, in lpfc_hb_eq_delay_work()
1412 * lpfc_hb_mxp_handler - Multi-XRI pools handler to adjust XRI distribution
1423 hwq_count = phba->cfg_hdw_queue; in lpfc_hb_mxp_handler()
1439 * lpfc_issue_hb_mbox - Issues heart-beat mailbox command
1453 if (test_bit(HBA_HBEAT_INP, &phba->hba_flag)) in lpfc_issue_hb_mbox()
1456 pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_issue_hb_mbox()
1458 return -ENOMEM; in lpfc_issue_hb_mbox()
1461 pmboxq->mbox_cmpl = lpfc_hb_mbox_cmpl; in lpfc_issue_hb_mbox()
1462 pmboxq->vport = phba->pport; in lpfc_issue_hb_mbox()
1466 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_issue_hb_mbox()
1467 return -ENXIO; in lpfc_issue_hb_mbox()
1469 set_bit(HBA_HBEAT_INP, &phba->hba_flag); in lpfc_issue_hb_mbox()
1475 * lpfc_issue_hb_tmo - Signals heartbeat timer to issue mbox command
1487 if (phba->cfg_enable_hba_heartbeat) in lpfc_issue_hb_tmo()
1489 set_bit(HBA_HBEAT_TMO, &phba->hba_flag); in lpfc_issue_hb_tmo()
1493 * lpfc_hb_timeout_handler - The HBA-timer timeout handler
1496 * This is the actual HBA-timer timeout handler to be invoked by the worker
1497 * thread whenever the HBA timer fired and HBA-timeout event posted. This
1500 * or by processing slow-ring or fast-ring events within the HBA-timer
1502 * the timer for the next timeout period. If lpfc heart-beat mailbox command
1503 * is configured and there is no heart-beat mailbox command outstanding, a
1504 * heart-beat mailbox is issued and timer set properly. Otherwise, if there
1505 * has been a heart-beat mailbox command outstanding, the HBA shall be put
1515 struct lpfc_sli *psli = &phba->sli; in lpfc_hb_timeout_handler()
1518 if (phba->cfg_xri_rebalancing) { in lpfc_hb_timeout_handler()
1519 /* Multi-XRI pools handler */ in lpfc_hb_timeout_handler()
1525 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_hb_timeout_handler()
1531 if (phba->link_state == LPFC_HBA_ERROR || in lpfc_hb_timeout_handler()
1532 test_bit(FC_UNLOADING, &phba->pport->load_flag) || in lpfc_hb_timeout_handler()
1533 test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_hb_timeout_handler()
1536 if (phba->elsbuf_cnt && in lpfc_hb_timeout_handler()
1537 (phba->elsbuf_cnt == phba->elsbuf_prev_cnt)) { in lpfc_hb_timeout_handler()
1538 spin_lock_irq(&phba->hbalock); in lpfc_hb_timeout_handler()
1539 list_splice_init(&phba->elsbuf, &completions); in lpfc_hb_timeout_handler()
1540 phba->elsbuf_cnt = 0; in lpfc_hb_timeout_handler()
1541 phba->elsbuf_prev_cnt = 0; in lpfc_hb_timeout_handler()
1542 spin_unlock_irq(&phba->hbalock); in lpfc_hb_timeout_handler()
1547 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); in lpfc_hb_timeout_handler()
1551 phba->elsbuf_prev_cnt = phba->elsbuf_cnt; in lpfc_hb_timeout_handler()
1554 if (phba->cfg_enable_hba_heartbeat) { in lpfc_hb_timeout_handler()
1556 spin_lock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1557 if (time_after(phba->last_completion_time + in lpfc_hb_timeout_handler()
1560 spin_unlock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1561 if (test_bit(HBA_HBEAT_INP, &phba->hba_flag)) in lpfc_hb_timeout_handler()
1567 spin_unlock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1570 if (test_bit(HBA_HBEAT_INP, &phba->hba_flag)) { in lpfc_hb_timeout_handler()
1580 - phba->last_completion_time)); in lpfc_hb_timeout_handler()
1583 if ((!(psli->sli_flag & LPFC_SLI_MBOX_ACTIVE)) && in lpfc_hb_timeout_handler()
1584 (list_empty(&psli->mboxq))) { in lpfc_hb_timeout_handler()
1591 phba->skipped_hb = 0; in lpfc_hb_timeout_handler()
1592 } else if (time_before_eq(phba->last_completion_time, in lpfc_hb_timeout_handler()
1593 phba->skipped_hb)) { in lpfc_hb_timeout_handler()
1598 - phba->last_completion_time)); in lpfc_hb_timeout_handler()
1600 phba->skipped_hb = jiffies; in lpfc_hb_timeout_handler()
1607 if (test_bit(HBA_HBEAT_TMO, &phba->hba_flag)) { in lpfc_hb_timeout_handler()
1618 mod_timer(&phba->hb_tmofunc, jiffies + msecs_to_jiffies(tmo)); in lpfc_hb_timeout_handler()
1622 * lpfc_offline_eratt - Bring lpfc offline on hardware error attention
1631 struct lpfc_sli *psli = &phba->sli; in lpfc_offline_eratt()
1633 spin_lock_irq(&phba->hbalock); in lpfc_offline_eratt()
1634 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_offline_eratt()
1635 spin_unlock_irq(&phba->hbalock); in lpfc_offline_eratt()
1640 spin_lock_irq(&phba->hbalock); in lpfc_offline_eratt()
1642 spin_unlock_irq(&phba->hbalock); in lpfc_offline_eratt()
1646 phba->link_state = LPFC_HBA_ERROR; in lpfc_offline_eratt()
1651 * lpfc_sli4_offline_eratt - Bring lpfc offline on SLI4 hardware error attention
1660 spin_lock_irq(&phba->hbalock); in lpfc_sli4_offline_eratt()
1661 if (phba->link_state == LPFC_HBA_ERROR && in lpfc_sli4_offline_eratt()
1662 test_bit(HBA_PCI_ERR, &phba->bit_flags)) { in lpfc_sli4_offline_eratt()
1663 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_offline_eratt()
1666 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli4_offline_eratt()
1667 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_offline_eratt()
1677 * lpfc_handle_deferred_eratt - The HBA hardware deferred error handler
1688 uint32_t old_host_status = phba->work_hs; in lpfc_handle_deferred_eratt()
1689 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_deferred_eratt()
1694 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_deferred_eratt()
1695 clear_bit(DEFER_ERATT, &phba->hba_flag); in lpfc_handle_deferred_eratt()
1702 phba->work_hs, phba->work_status[0], in lpfc_handle_deferred_eratt()
1703 phba->work_status[1]); in lpfc_handle_deferred_eratt()
1705 spin_lock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1706 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_handle_deferred_eratt()
1707 spin_unlock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1713 * SCSI layer retry it after re-establishing link. in lpfc_handle_deferred_eratt()
1725 while (phba->work_hs & HS_FFER1) { in lpfc_handle_deferred_eratt()
1727 if (lpfc_readl(phba->HSregaddr, &phba->work_hs)) { in lpfc_handle_deferred_eratt()
1728 phba->work_hs = UNPLUG_ERR ; in lpfc_handle_deferred_eratt()
1732 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { in lpfc_handle_deferred_eratt()
1733 phba->work_hs = 0; in lpfc_handle_deferred_eratt()
1743 if (!phba->work_hs && !test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_handle_deferred_eratt()
1744 phba->work_hs = old_host_status & ~HS_FFER1; in lpfc_handle_deferred_eratt()
1746 clear_bit(DEFER_ERATT, &phba->hba_flag); in lpfc_handle_deferred_eratt()
1747 phba->work_status[0] = readl(phba->MBslimaddr + 0xa8); in lpfc_handle_deferred_eratt()
1748 phba->work_status[1] = readl(phba->MBslimaddr + 0xac); in lpfc_handle_deferred_eratt()
1759 shost = lpfc_shost_from_vport(phba->pport); in lpfc_board_errevt_to_mgmt()
1767 * lpfc_handle_eratt_s3 - The SLI3 HBA hardware error handler
1772 * 1 - HBA error attention interrupt
1773 * 2 - DMA ring index out of range
1774 * 3 - Mailbox command came back as unknown
1779 struct lpfc_vport *vport = phba->pport; in lpfc_handle_eratt_s3()
1780 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_eratt_s3()
1782 unsigned long temperature; in lpfc_handle_eratt_s3() local
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()
1848 temp_event_data.data = (uint32_t)temperature; in lpfc_handle_eratt_s3()
1851 "0406 Adapter maximum temperature exceeded " in lpfc_handle_eratt_s3()
1854 temperature, phba->work_hs, in lpfc_handle_eratt_s3()
1855 phba->work_status[0], phba->work_status[1]); in lpfc_handle_eratt_s3()
1857 shost = lpfc_shost_from_vport(phba->pport); in lpfc_handle_eratt_s3()
1864 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1865 phba->over_temp_state = HBA_OVER_TEMP; in lpfc_handle_eratt_s3()
1866 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1877 phba->work_hs, in lpfc_handle_eratt_s3()
1878 phba->work_status[0], phba->work_status[1]); in lpfc_handle_eratt_s3()
1892 * lpfc_sli4_port_sta_fn_reset - The SLI4 function reset due to port status reg
1913 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_port_sta_fn_reset()
1935 spin_lock_irq(&phba->hbalock); in lpfc_sli4_port_sta_fn_reset()
1936 phba->sli.sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_sli4_port_sta_fn_reset()
1937 if (phba->sli.mbox_active) { in lpfc_sli4_port_sta_fn_reset()
1938 mboxq = phba->sli.mbox_active; in lpfc_sli4_port_sta_fn_reset()
1939 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_port_sta_fn_reset()
1941 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_port_sta_fn_reset()
1942 phba->sli.mbox_active = NULL; in lpfc_sli4_port_sta_fn_reset()
1944 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_port_sta_fn_reset()
1960 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_sli4_port_sta_fn_reset()
1964 return -EIO; in lpfc_sli4_port_sta_fn_reset()
1966 phba->intr_mode = intr_mode; in lpfc_sli4_port_sta_fn_reset()
1975 * lpfc_handle_eratt_s4 - The SLI4 HBA hardware error handler
1984 struct lpfc_vport *vport = phba->pport; in lpfc_handle_eratt_s4()
2000 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_eratt_s4()
2008 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_handle_eratt_s4()
2012 phba->sli4_hba.u.if_type0.UERRLOregaddr, in lpfc_handle_eratt_s4()
2015 phba->sli4_hba.u.if_type0.UEMASKLOregaddr, in lpfc_handle_eratt_s4()
2018 if (pci_rd_rc1 == -EIO && pci_rd_rc2 == -EIO) in lpfc_handle_eratt_s4()
2020 if (!test_bit(HBA_RECOVERABLE_UE, &phba->hba_flag)) { in lpfc_handle_eratt_s4()
2027 for (i = 0; i < phba->sli4_hba.ue_to_sr / 1000; i++) { in lpfc_handle_eratt_s4()
2028 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_handle_eratt_s4()
2050 if (!lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_handle_eratt_s4()
2069 phba->link_state = LPFC_HBA_ERROR; in lpfc_handle_eratt_s4()
2075 phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_handle_eratt_s4()
2078 if (pci_rd_rc1 == -EIO) { in lpfc_handle_eratt_s4()
2081 readl(phba->sli4_hba.u.if_type2.STATUSregaddr)); in lpfc_handle_eratt_s4()
2085 reg_err1 = readl(phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_handle_eratt_s4()
2086 reg_err2 = readl(phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_handle_eratt_s4()
2093 phba->sfp_alarm |= LPFC_TRANSGRESSION_HIGH_TEMPERATURE; in lpfc_handle_eratt_s4()
2098 shost = lpfc_shost_from_vport(phba->pport); in lpfc_handle_eratt_s4()
2105 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s4()
2106 phba->over_temp_state = HBA_OVER_TEMP; in lpfc_handle_eratt_s4()
2107 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s4()
2127 if (!phba->cfg_enable_hba_reset) in lpfc_handle_eratt_s4()
2163 * lpfc_handle_eratt - Wrapper func for handling hba error attention
2170 * 0 - success.
2171 * Any other value - error.
2176 (*phba->lpfc_handle_eratt)(phba); in lpfc_handle_eratt()
2180 * lpfc_handle_latt - The HBA link event handler
2189 struct lpfc_vport *vport = phba->pport; in lpfc_handle_latt()
2190 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_latt()
2195 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_handle_latt()
2204 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_handle_latt()
2210 psli->slistat.link_event++; in lpfc_handle_latt()
2211 lpfc_read_topology(phba, pmb, pmb->ctx_buf); in lpfc_handle_latt()
2212 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_handle_latt()
2213 pmb->vport = vport; in lpfc_handle_latt()
2215 phba->sli.sli3_ring[LPFC_ELS_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_handle_latt()
2223 spin_lock_irq(&phba->hbalock); in lpfc_handle_latt()
2224 writel(HA_LATT, phba->HAregaddr); in lpfc_handle_latt()
2225 readl(phba->HAregaddr); /* flush */ in lpfc_handle_latt()
2226 spin_unlock_irq(&phba->hbalock); in lpfc_handle_latt()
2231 phba->sli.sli3_ring[LPFC_ELS_RING].flag &= ~LPFC_STOP_IOCB_EVENT; in lpfc_handle_latt()
2235 spin_lock_irq(&phba->hbalock); in lpfc_handle_latt()
2236 psli->sli_flag |= LPFC_PROCESS_LA; in lpfc_handle_latt()
2237 control = readl(phba->HCregaddr); in lpfc_handle_latt()
2239 writel(control, phba->HCregaddr); in lpfc_handle_latt()
2240 readl(phba->HCregaddr); /* flush */ in lpfc_handle_latt()
2243 writel(HA_LATT, phba->HAregaddr); in lpfc_handle_latt()
2244 readl(phba->HAregaddr); /* flush */ in lpfc_handle_latt()
2245 spin_unlock_irq(&phba->hbalock); in lpfc_handle_latt()
2247 phba->link_state = LPFC_HBA_ERROR; in lpfc_handle_latt()
2267 length -= (3+i); in lpfc_fill_vpd()
2268 while (i--) { in lpfc_fill_vpd()
2269 phba->SerialNumber[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2273 phba->SerialNumber[j] = 0; in lpfc_fill_vpd()
2276 phba->vpd_flag |= VPD_MODEL_DESC; in lpfc_fill_vpd()
2281 length -= (3+i); in lpfc_fill_vpd()
2282 while (i--) { in lpfc_fill_vpd()
2283 phba->ModelDesc[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2287 phba->ModelDesc[j] = 0; in lpfc_fill_vpd()
2290 phba->vpd_flag |= VPD_MODEL_NAME; in lpfc_fill_vpd()
2295 length -= (3+i); in lpfc_fill_vpd()
2296 while (i--) { in lpfc_fill_vpd()
2297 phba->ModelName[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2301 phba->ModelName[j] = 0; in lpfc_fill_vpd()
2304 phba->vpd_flag |= VPD_PROGRAM_TYPE; in lpfc_fill_vpd()
2309 length -= (3+i); in lpfc_fill_vpd()
2310 while (i--) { in lpfc_fill_vpd()
2311 phba->ProgramType[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2315 phba->ProgramType[j] = 0; in lpfc_fill_vpd()
2318 phba->vpd_flag |= VPD_PORT; in lpfc_fill_vpd()
2323 length -= (3 + i); in lpfc_fill_vpd()
2324 while (i--) { in lpfc_fill_vpd()
2325 if ((phba->sli_rev == LPFC_SLI_REV4) && in lpfc_fill_vpd()
2326 (phba->sli4_hba.pport_name_sta == in lpfc_fill_vpd()
2331 phba->Port[j++] = vpd[(*pindex)++]; in lpfc_fill_vpd()
2335 if ((phba->sli_rev != LPFC_SLI_REV4) || in lpfc_fill_vpd()
2336 (phba->sli4_hba.pport_name_sta == in lpfc_fill_vpd()
2338 phba->Port[j] = 0; in lpfc_fill_vpd()
2345 length -= (3 + i); in lpfc_fill_vpd()
2351 * lpfc_parse_vpd - Parse VPD (Vital Product Data)
2361 * 0 - pointer to the VPD passed in is NULL
2362 * 1 - success
2381 while (!finished && (index < (len - 4))) { in lpfc_parse_vpd()
2400 if (Length > len - index) in lpfc_parse_vpd()
2401 Length = len - index; in lpfc_parse_vpd()
2419 * lpfc_get_atto_model_desc - Retrieve ATTO HBA device model name and description
2433 uint16_t sub_dev_id = phba->pcidev->subsystem_device; in lpfc_get_atto_model_desc()
2497 (tbolt) ? "ThunderLink FC " : "Celerity FC-", in lpfc_get_atto_model_desc()
2499 phba->Port); in lpfc_get_atto_model_desc()
2503 * lpfc_get_hba_model_desc - Retrieve HBA device model name and description
2518 uint16_t dev_id = phba->pcidev->device; in lpfc_get_hba_model_desc()
2532 if (phba->pcidev->vendor == PCI_VENDOR_ID_ATTO) { in lpfc_get_hba_model_desc()
2537 if (phba->lmt & LMT_64Gb) in lpfc_get_hba_model_desc()
2539 else if (phba->lmt & LMT_32Gb) in lpfc_get_hba_model_desc()
2541 else if (phba->lmt & LMT_16Gb) in lpfc_get_hba_model_desc()
2543 else if (phba->lmt & LMT_10Gb) in lpfc_get_hba_model_desc()
2545 else if (phba->lmt & LMT_8Gb) in lpfc_get_hba_model_desc()
2547 else if (phba->lmt & LMT_4Gb) in lpfc_get_hba_model_desc()
2549 else if (phba->lmt & LMT_2Gb) in lpfc_get_hba_model_desc()
2551 else if (phba->lmt & LMT_1Gb) in lpfc_get_hba_model_desc()
2556 vp = &phba->vpd; in lpfc_get_hba_model_desc()
2564 if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3) in lpfc_get_hba_model_desc()
2575 if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID) in lpfc_get_hba_model_desc()
2586 m = (typeof(m)){"LP9802", "PCI-X", in lpfc_get_hba_model_desc()
2590 m = (typeof(m)){"LP10000", "PCI-X", in lpfc_get_hba_model_desc()
2594 m = (typeof(m)){"LPX1000", "PCI-X", in lpfc_get_hba_model_desc()
2598 m = (typeof(m)){"LP982", "PCI-X", in lpfc_get_hba_model_desc()
2602 m = (typeof(m)){"LP1050", "PCI-X", in lpfc_get_hba_model_desc()
2606 m = (typeof(m)){"LP11000", "PCI-X2", in lpfc_get_hba_model_desc()
2610 m = (typeof(m)){"LP11000-SP", "PCI-X2", in lpfc_get_hba_model_desc()
2614 m = (typeof(m)){"LP11002-SP", "PCI-X2", in lpfc_get_hba_model_desc()
2622 m = (typeof(m)){"LPe1000-SP", "PCIe", in lpfc_get_hba_model_desc()
2626 m = (typeof(m)){"LPe1002-SP", "PCIe", in lpfc_get_hba_model_desc()
2630 m = (typeof(m)){"LP1150", "PCI-X2", in lpfc_get_hba_model_desc()
2634 m = (typeof(m)){"LP111", "PCI-X2", in lpfc_get_hba_model_desc()
2659 m = (typeof(m)){"LP101", "PCI-X", in lpfc_get_hba_model_desc()
2663 m = (typeof(m)){"LP10000-S", "PCI", in lpfc_get_hba_model_desc()
2667 m = (typeof(m)){"LP11000-S", "PCI-X2", in lpfc_get_hba_model_desc()
2671 m = (typeof(m)){"LPe11000-S", "PCIe", in lpfc_get_hba_model_desc()
2687 m = (typeof(m)){"LPe12002-SP", "PCIe", in lpfc_get_hba_model_desc()
2691 m = (typeof(m)){"LPe12000-SP", "PCIe", in lpfc_get_hba_model_desc()
2695 m = (typeof(m)){"LPe12000-S", "PCIe", in lpfc_get_hba_model_desc()
2707 m = (typeof(m)){"LPemv12002-S", "PCIe IOV", in lpfc_get_hba_model_desc()
2721 m = (typeof(m)){"LPSe12002-ML1-E", "PCIe", in lpfc_get_hba_model_desc()
2777 phba->Port); in lpfc_get_hba_model_desc()
2791 * lpfc_sli3_post_buffer - Post IOCB(s) with DMA buffer descriptor(s) to a IOCB ring
2809 cnt += pring->missbufcnt; in lpfc_sli3_post_buffer()
2816 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2819 icmd = &iocb->iocb; in lpfc_sli3_post_buffer()
2825 mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &mp1->phys); in lpfc_sli3_post_buffer()
2826 if (!mp1 || !mp1->virt) { in lpfc_sli3_post_buffer()
2829 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2833 INIT_LIST_HEAD(&mp1->list); in lpfc_sli3_post_buffer()
2838 mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI, in lpfc_sli3_post_buffer()
2839 &mp2->phys); in lpfc_sli3_post_buffer()
2840 if (!mp2 || !mp2->virt) { in lpfc_sli3_post_buffer()
2842 lpfc_mbuf_free(phba, mp1->virt, mp1->phys); in lpfc_sli3_post_buffer()
2845 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2849 INIT_LIST_HEAD(&mp2->list); in lpfc_sli3_post_buffer()
2854 icmd->un.cont64[0].addrHigh = putPaddrHigh(mp1->phys); in lpfc_sli3_post_buffer()
2855 icmd->un.cont64[0].addrLow = putPaddrLow(mp1->phys); in lpfc_sli3_post_buffer()
2856 icmd->un.cont64[0].tus.f.bdeSize = FCELSSIZE; in lpfc_sli3_post_buffer()
2857 icmd->ulpBdeCount = 1; in lpfc_sli3_post_buffer()
2858 cnt--; in lpfc_sli3_post_buffer()
2860 icmd->un.cont64[1].addrHigh = putPaddrHigh(mp2->phys); in lpfc_sli3_post_buffer()
2861 icmd->un.cont64[1].addrLow = putPaddrLow(mp2->phys); in lpfc_sli3_post_buffer()
2862 icmd->un.cont64[1].tus.f.bdeSize = FCELSSIZE; in lpfc_sli3_post_buffer()
2863 cnt--; in lpfc_sli3_post_buffer()
2864 icmd->ulpBdeCount = 2; in lpfc_sli3_post_buffer()
2867 icmd->ulpCommand = CMD_QUE_RING_BUF64_CN; in lpfc_sli3_post_buffer()
2868 icmd->ulpLe = 1; in lpfc_sli3_post_buffer()
2870 if (lpfc_sli_issue_iocb(phba, pring->ringno, iocb, 0) == in lpfc_sli3_post_buffer()
2872 lpfc_mbuf_free(phba, mp1->virt, mp1->phys); in lpfc_sli3_post_buffer()
2876 lpfc_mbuf_free(phba, mp2->virt, mp2->phys); in lpfc_sli3_post_buffer()
2881 pring->missbufcnt = cnt; in lpfc_sli3_post_buffer()
2888 pring->missbufcnt = 0; in lpfc_sli3_post_buffer()
2893 * lpfc_post_rcv_buf - Post the initial receive IOCB buffers to ELS ring
2901 * 0 - success (currently always success)
2906 struct lpfc_sli *psli = &phba->sli; in lpfc_post_rcv_buf()
2909 lpfc_sli3_post_buffer(phba, &psli->sli3_ring[LPFC_ELS_RING], LPFC_BUF_RING0); in lpfc_post_rcv_buf()
2910 /* Ring 2 - FCP no buffers needed */ in lpfc_post_rcv_buf()
2915 #define S(N,V) (((V)<<(N))|((V)>>(32-(N))))
2918 * lpfc_sha_init - Set up initial array of hash table entries
2935 * lpfc_sha_iterate - Iterate initial hash table with the working hash table
2954 HashWorkingPointer[t - 3] ^ HashWorkingPointer[t - in lpfc_sha_iterate()
2956 HashWorkingPointer[t - 14] ^ HashWorkingPointer[t - 16]); in lpfc_sha_iterate()
2992 * lpfc_challenge_key - Create challenge key based on WWPN of the HBA
3008 * lpfc_hba_init - Perform special handling for LC HBA initialization
3010 * @hbainit: pointer to an array of unsigned 32-bit integers.
3019 uint32_t *pwwnn = (uint32_t *) phba->wwnn; in lpfc_hba_init()
3029 lpfc_challenge_key(phba->RandomData + t, HashWorking + t); in lpfc_hba_init()
3037 * lpfc_cleanup - Performs vport cleanups before deleting a vport
3048 struct lpfc_hba *phba = vport->phba; in lpfc_cleanup()
3052 if (phba->link_state > LPFC_LINK_DOWN) in lpfc_cleanup()
3059 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { in lpfc_cleanup()
3063 if (ndlp->nlp_type & NLP_FABRIC && in lpfc_cleanup()
3064 ndlp->nlp_state == NLP_STE_UNMAPPED_NODE) in lpfc_cleanup()
3068 if (!(ndlp->fc4_xpt_flags & (NVME_XPT_REGD|SCSI_XPT_REGD))) in lpfc_cleanup()
3085 if (test_bit(FC_UNLOADING, &vport->load_flag) && in lpfc_cleanup()
3086 pci_channel_offline(phba->pcidev)) in lpfc_cleanup()
3087 lpfc_sli_flush_io_rings(vport->phba); in lpfc_cleanup()
3093 while (!list_empty(&vport->fc_nodes)) { in lpfc_cleanup()
3099 &vport->fc_nodes, nlp_listp) { in lpfc_cleanup()
3100 lpfc_printf_vlog(ndlp->vport, KERN_ERR, in lpfc_cleanup()
3105 ndlp->nlp_DID, (void *)ndlp, in lpfc_cleanup()
3106 kref_read(&ndlp->kref), in lpfc_cleanup()
3107 ndlp->fc4_xpt_flags, in lpfc_cleanup()
3108 ndlp->nlp_flag); in lpfc_cleanup()
3120 * lpfc_stop_vport_timers - Stop all the timers associated with a vport
3130 timer_delete_sync(&vport->els_tmofunc); in lpfc_stop_vport_timers()
3131 timer_delete_sync(&vport->delayed_disc_tmo); in lpfc_stop_vport_timers()
3137 * __lpfc_sli4_stop_fcf_redisc_wait_timer - Stop FCF rediscovery wait timer
3147 phba->fcf.fcf_flag &= ~FCF_REDISC_PEND; in __lpfc_sli4_stop_fcf_redisc_wait_timer()
3150 timer_delete(&phba->fcf.redisc_wait); in __lpfc_sli4_stop_fcf_redisc_wait_timer()
3154 * lpfc_sli4_stop_fcf_redisc_wait_timer - Stop FCF rediscovery wait timer
3165 spin_lock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3166 if (!(phba->fcf.fcf_flag & FCF_REDISC_PEND)) { in lpfc_sli4_stop_fcf_redisc_wait_timer()
3168 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3173 phba->fcf.fcf_flag &= ~(FCF_DEAD_DISC | FCF_ACVL_DISC); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3174 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
3178 * lpfc_cmf_stop - Stop CMF processing
3192 if (!phba->sli4_hba.pc_sli4_params.cmf) in lpfc_cmf_stop()
3199 hrtimer_cancel(&phba->cmf_stats_timer); in lpfc_cmf_stop()
3200 hrtimer_cancel(&phba->cmf_timer); in lpfc_cmf_stop()
3203 atomic_set(&phba->cmf_busy, 0); in lpfc_cmf_stop()
3205 cgs = per_cpu_ptr(phba->cmf_stat, cpu); in lpfc_cmf_stop()
3206 atomic64_set(&cgs->total_bytes, 0); in lpfc_cmf_stop()
3207 atomic64_set(&cgs->rcv_bytes, 0); in lpfc_cmf_stop()
3208 atomic_set(&cgs->rx_io_cnt, 0); in lpfc_cmf_stop()
3209 atomic64_set(&cgs->rx_latency, 0); in lpfc_cmf_stop()
3211 atomic_set(&phba->cmf_bw_wait, 0); in lpfc_cmf_stop()
3213 /* Resume any blocked IO - Queue unblock on workqueue */ in lpfc_cmf_stop()
3214 queue_work(phba->wq, &phba->unblock_request_work); in lpfc_cmf_stop()
3232 phba->cmf_interval_rate = LPFC_CMF_INTERVAL; in lpfc_cmf_signal_init()
3233 phba->cmf_max_line_rate = lpfc_get_max_line_rate(phba); in lpfc_cmf_signal_init()
3234 phba->cmf_link_byte_count = div_u64(phba->cmf_max_line_rate * in lpfc_cmf_signal_init()
3235 phba->cmf_interval_rate, 1000); in lpfc_cmf_signal_init()
3236 phba->cmf_max_bytes_per_interval = phba->cmf_link_byte_count; in lpfc_cmf_signal_init()
3243 * lpfc_cmf_start - Start CMF processing
3256 if (!phba->sli4_hba.pc_sli4_params.cmf || in lpfc_cmf_start()
3257 phba->cmf_active_mode == LPFC_CFG_OFF) in lpfc_cmf_start()
3263 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_cmf_start()
3264 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_cmf_start()
3265 atomic_set(&phba->cgn_sync_alarm_cnt, 0); in lpfc_cmf_start()
3266 atomic_set(&phba->cgn_sync_warn_cnt, 0); in lpfc_cmf_start()
3268 atomic_set(&phba->cmf_busy, 0); in lpfc_cmf_start()
3270 cgs = per_cpu_ptr(phba->cmf_stat, cpu); in lpfc_cmf_start()
3271 atomic64_set(&cgs->total_bytes, 0); in lpfc_cmf_start()
3272 atomic64_set(&cgs->rcv_bytes, 0); in lpfc_cmf_start()
3273 atomic_set(&cgs->rx_io_cnt, 0); in lpfc_cmf_start()
3274 atomic64_set(&cgs->rx_latency, 0); in lpfc_cmf_start()
3276 phba->cmf_latency.tv_sec = 0; in lpfc_cmf_start()
3277 phba->cmf_latency.tv_nsec = 0; in lpfc_cmf_start()
3284 phba->cmf_timer_cnt = 0; in lpfc_cmf_start()
3285 hrtimer_start(&phba->cmf_timer, in lpfc_cmf_start()
3288 hrtimer_start(&phba->cmf_stats_timer, in lpfc_cmf_start()
3292 ktime_get_real_ts64(&phba->cmf_latency); in lpfc_cmf_start()
3294 atomic_set(&phba->cmf_bw_wait, 0); in lpfc_cmf_start()
3295 atomic_set(&phba->cmf_stop_io, 0); in lpfc_cmf_start()
3299 * lpfc_stop_hba_timers - Stop all the timers associated with an HBA
3308 if (phba->pport) in lpfc_stop_hba_timers()
3309 lpfc_stop_vport_timers(phba->pport); in lpfc_stop_hba_timers()
3310 cancel_delayed_work_sync(&phba->eq_delay_work); in lpfc_stop_hba_timers()
3311 cancel_delayed_work_sync(&phba->idle_stat_delay_work); in lpfc_stop_hba_timers()
3312 timer_delete_sync(&phba->sli.mbox_tmo); in lpfc_stop_hba_timers()
3313 timer_delete_sync(&phba->fabric_block_timer); in lpfc_stop_hba_timers()
3314 timer_delete_sync(&phba->eratt_poll); in lpfc_stop_hba_timers()
3315 timer_delete_sync(&phba->hb_tmofunc); in lpfc_stop_hba_timers()
3316 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_stop_hba_timers()
3317 timer_delete_sync(&phba->rrq_tmr); in lpfc_stop_hba_timers()
3318 clear_bit(HBA_RRQ_ACTIVE, &phba->hba_flag); in lpfc_stop_hba_timers()
3320 clear_bit(HBA_HBEAT_INP, &phba->hba_flag); in lpfc_stop_hba_timers()
3321 clear_bit(HBA_HBEAT_TMO, &phba->hba_flag); in lpfc_stop_hba_timers()
3323 switch (phba->pci_dev_grp) { in lpfc_stop_hba_timers()
3326 timer_delete_sync(&phba->fcp_poll_timer); in lpfc_stop_hba_timers()
3335 phba->pci_dev_grp); in lpfc_stop_hba_timers()
3342 * lpfc_block_mgmt_io - Mark a HBA's management interface as blocked
3359 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3360 phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO; in lpfc_block_mgmt_io()
3361 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3365 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3366 if (phba->sli.mbox_active) { in lpfc_block_mgmt_io()
3367 actcmd = phba->sli.mbox_active->u.mb.mbxCommand; in lpfc_block_mgmt_io()
3372 phba->sli.mbox_active)) + jiffies; in lpfc_block_mgmt_io()
3374 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3377 while (phba->sli.mbox_active) { in lpfc_block_mgmt_io()
3383 "- mbox cmd %x still active\n", in lpfc_block_mgmt_io()
3384 phba->sli.sli_flag, actcmd); in lpfc_block_mgmt_io()
3391 * lpfc_sli4_node_rpi_restore - Recover assigned RPIs for active nodes.
3405 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_sli4_node_rpi_restore()
3412 for (i = 0; i <= phba->max_vports && vports[i]; i++) { in lpfc_sli4_node_rpi_restore()
3413 if (test_bit(FC_UNLOADING, &vports[i]->load_flag)) in lpfc_sli4_node_rpi_restore()
3417 &vports[i]->fc_nodes, in lpfc_sli4_node_rpi_restore()
3421 lpfc_printf_vlog(ndlp->vport, KERN_INFO, in lpfc_sli4_node_rpi_restore()
3426 ndlp, ndlp->nlp_DID, in lpfc_sli4_node_rpi_restore()
3427 ndlp->nlp_flag); in lpfc_sli4_node_rpi_restore()
3430 ndlp->nlp_rpi = rpi; in lpfc_sli4_node_rpi_restore()
3431 lpfc_printf_vlog(ndlp->vport, KERN_INFO, in lpfc_sli4_node_rpi_restore()
3435 ndlp->nlp_rpi, ndlp, ndlp->nlp_DID, in lpfc_sli4_node_rpi_restore()
3436 ndlp->nlp_flag); in lpfc_sli4_node_rpi_restore()
3443 * lpfc_create_expedite_pool - create expedite pool
3457 epd_pool = &phba->epd_pool; in lpfc_create_expedite_pool()
3458 qp = &phba->sli4_hba.hdwq[0]; in lpfc_create_expedite_pool()
3460 spin_lock_init(&epd_pool->lock); in lpfc_create_expedite_pool()
3461 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_create_expedite_pool()
3462 spin_lock(&epd_pool->lock); in lpfc_create_expedite_pool()
3463 INIT_LIST_HEAD(&epd_pool->list); in lpfc_create_expedite_pool()
3465 &qp->lpfc_io_buf_list_put, list) { in lpfc_create_expedite_pool()
3466 list_move_tail(&lpfc_ncmd->list, &epd_pool->list); in lpfc_create_expedite_pool()
3467 lpfc_ncmd->expedite = true; in lpfc_create_expedite_pool()
3468 qp->put_io_bufs--; in lpfc_create_expedite_pool()
3469 epd_pool->count++; in lpfc_create_expedite_pool()
3470 if (epd_pool->count >= XRI_BATCH) in lpfc_create_expedite_pool()
3473 spin_unlock(&epd_pool->lock); in lpfc_create_expedite_pool()
3474 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_create_expedite_pool()
3478 * lpfc_destroy_expedite_pool - destroy expedite pool
3492 epd_pool = &phba->epd_pool; in lpfc_destroy_expedite_pool()
3493 qp = &phba->sli4_hba.hdwq[0]; in lpfc_destroy_expedite_pool()
3495 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_expedite_pool()
3496 spin_lock(&epd_pool->lock); in lpfc_destroy_expedite_pool()
3498 &epd_pool->list, list) { in lpfc_destroy_expedite_pool()
3499 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_expedite_pool()
3500 &qp->lpfc_io_buf_list_put); in lpfc_destroy_expedite_pool()
3501 lpfc_ncmd->flags = false; in lpfc_destroy_expedite_pool()
3502 qp->put_io_bufs++; in lpfc_destroy_expedite_pool()
3503 epd_pool->count--; in lpfc_destroy_expedite_pool()
3505 spin_unlock(&epd_pool->lock); in lpfc_destroy_expedite_pool()
3506 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_expedite_pool()
3510 * lpfc_create_multixri_pools - create multi-XRI pools
3532 phba->cfg_hdw_queue, phba->sli4_hba.num_present_cpu, in lpfc_create_multixri_pools()
3533 phba->sli4_hba.io_xri_cnt); in lpfc_create_multixri_pools()
3535 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_create_multixri_pools()
3538 hwq_count = phba->cfg_hdw_queue; in lpfc_create_multixri_pools()
3539 count_per_hwq = phba->sli4_hba.io_xri_cnt / hwq_count; in lpfc_create_multixri_pools()
3549 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_create_multixri_pools()
3554 qp = &phba->sli4_hba.hdwq[j]; in lpfc_create_multixri_pools()
3555 kfree(qp->p_multixri_pool); in lpfc_create_multixri_pools()
3558 phba->cfg_xri_rebalancing = 0; in lpfc_create_multixri_pools()
3562 qp = &phba->sli4_hba.hdwq[i]; in lpfc_create_multixri_pools()
3563 qp->p_multixri_pool = multixri_pool; in lpfc_create_multixri_pools()
3565 multixri_pool->xri_limit = count_per_hwq; in lpfc_create_multixri_pools()
3566 multixri_pool->rrb_next_hwqid = i; in lpfc_create_multixri_pools()
3569 pbl_pool = &multixri_pool->pbl_pool; in lpfc_create_multixri_pools()
3570 spin_lock_init(&pbl_pool->lock); in lpfc_create_multixri_pools()
3571 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_create_multixri_pools()
3572 spin_lock(&pbl_pool->lock); in lpfc_create_multixri_pools()
3573 INIT_LIST_HEAD(&pbl_pool->list); in lpfc_create_multixri_pools()
3575 &qp->lpfc_io_buf_list_put, list) { in lpfc_create_multixri_pools()
3576 list_move_tail(&lpfc_ncmd->list, &pbl_pool->list); in lpfc_create_multixri_pools()
3577 qp->put_io_bufs--; in lpfc_create_multixri_pools()
3578 pbl_pool->count++; in lpfc_create_multixri_pools()
3582 pbl_pool->count, i); in lpfc_create_multixri_pools()
3583 spin_unlock(&pbl_pool->lock); in lpfc_create_multixri_pools()
3584 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_create_multixri_pools()
3587 pvt_pool = &multixri_pool->pvt_pool; in lpfc_create_multixri_pools()
3588 pvt_pool->high_watermark = multixri_pool->xri_limit / 2; in lpfc_create_multixri_pools()
3589 pvt_pool->low_watermark = XRI_BATCH; in lpfc_create_multixri_pools()
3590 spin_lock_init(&pvt_pool->lock); in lpfc_create_multixri_pools()
3591 spin_lock_irqsave(&pvt_pool->lock, iflag); in lpfc_create_multixri_pools()
3592 INIT_LIST_HEAD(&pvt_pool->list); in lpfc_create_multixri_pools()
3593 pvt_pool->count = 0; in lpfc_create_multixri_pools()
3594 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_create_multixri_pools()
3599 * lpfc_destroy_multixri_pools - destroy multi-XRI pools
3616 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_destroy_multixri_pools()
3619 if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_destroy_multixri_pools()
3622 hwq_count = phba->cfg_hdw_queue; in lpfc_destroy_multixri_pools()
3625 qp = &phba->sli4_hba.hdwq[i]; in lpfc_destroy_multixri_pools()
3626 multixri_pool = qp->p_multixri_pool; in lpfc_destroy_multixri_pools()
3630 qp->p_multixri_pool = NULL; in lpfc_destroy_multixri_pools()
3632 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_multixri_pools()
3635 pbl_pool = &multixri_pool->pbl_pool; in lpfc_destroy_multixri_pools()
3636 spin_lock(&pbl_pool->lock); in lpfc_destroy_multixri_pools()
3640 pbl_pool->count, i); in lpfc_destroy_multixri_pools()
3643 &pbl_pool->list, list) { in lpfc_destroy_multixri_pools()
3644 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_multixri_pools()
3645 &qp->lpfc_io_buf_list_put); in lpfc_destroy_multixri_pools()
3646 qp->put_io_bufs++; in lpfc_destroy_multixri_pools()
3647 pbl_pool->count--; in lpfc_destroy_multixri_pools()
3650 INIT_LIST_HEAD(&pbl_pool->list); in lpfc_destroy_multixri_pools()
3651 pbl_pool->count = 0; in lpfc_destroy_multixri_pools()
3653 spin_unlock(&pbl_pool->lock); in lpfc_destroy_multixri_pools()
3656 pvt_pool = &multixri_pool->pvt_pool; in lpfc_destroy_multixri_pools()
3657 spin_lock(&pvt_pool->lock); in lpfc_destroy_multixri_pools()
3661 pvt_pool->count, i); in lpfc_destroy_multixri_pools()
3664 &pvt_pool->list, list) { in lpfc_destroy_multixri_pools()
3665 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_multixri_pools()
3666 &qp->lpfc_io_buf_list_put); in lpfc_destroy_multixri_pools()
3667 qp->put_io_bufs++; in lpfc_destroy_multixri_pools()
3668 pvt_pool->count--; in lpfc_destroy_multixri_pools()
3671 INIT_LIST_HEAD(&pvt_pool->list); in lpfc_destroy_multixri_pools()
3672 pvt_pool->count = 0; in lpfc_destroy_multixri_pools()
3674 spin_unlock(&pvt_pool->lock); in lpfc_destroy_multixri_pools()
3675 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_multixri_pools()
3682 * lpfc_online - Initialize and bring a HBA online
3690 * 0 - successful
3691 * 1 - failed
3703 vport = phba->pport; in lpfc_online()
3705 if (!test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) in lpfc_online()
3713 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_online()
3718 spin_lock_irq(&phba->hbalock); in lpfc_online()
3719 if (!phba->sli4_hba.max_cfg_param.vpi_used) in lpfc_online()
3721 spin_unlock_irq(&phba->hbalock); in lpfc_online()
3726 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME && in lpfc_online()
3727 !phba->nvmet_support) { in lpfc_online()
3728 error = lpfc_nvme_create_localport(phba->pport); in lpfc_online()
3744 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_online()
3745 clear_bit(FC_OFFLINE_MODE, &vports[i]->fc_flag); in lpfc_online()
3746 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) in lpfc_online()
3748 &vports[i]->fc_flag); in lpfc_online()
3749 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_online()
3751 &vports[i]->fc_flag); in lpfc_online()
3753 (vports[i]->port_type != in lpfc_online()
3755 vports[i]->vpi = 0; in lpfc_online()
3761 if (phba->cfg_xri_rebalancing) in lpfc_online()
3771 * lpfc_unblock_mgmt_io - Mark a HBA's management interface to be not blocked
3786 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_unblock_mgmt_io()
3787 phba->sli.sli_flag &= ~LPFC_BLOCK_MGMT_IO; in lpfc_unblock_mgmt_io()
3788 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_unblock_mgmt_io()
3792 * lpfc_offline_prep - Prepare a HBA to be brought offline
3803 struct lpfc_vport *vport = phba->pport; in lpfc_offline_prep()
3811 if (test_bit(FC_OFFLINE_MODE, &vport->fc_flag)) in lpfc_offline_prep()
3818 offline = pci_channel_offline(phba->pcidev); in lpfc_offline_prep()
3819 hba_pci_err = test_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_offline_prep()
3824 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_offline_prep()
3825 if (test_bit(FC_UNLOADING, &vports[i]->load_flag)) in lpfc_offline_prep()
3828 spin_lock_irq(shost->host_lock); in lpfc_offline_prep()
3829 vports[i]->vpi_state &= ~LPFC_VPI_REGISTERED; in lpfc_offline_prep()
3830 spin_unlock_irq(shost->host_lock); in lpfc_offline_prep()
3831 set_bit(FC_VPORT_NEEDS_REG_VPI, &vports[i]->fc_flag); in lpfc_offline_prep()
3832 clear_bit(FC_VFI_REGISTERED, &vports[i]->fc_flag); in lpfc_offline_prep()
3835 &vports[i]->fc_nodes, in lpfc_offline_prep()
3838 clear_bit(NLP_NPR_ADISC, &ndlp->nlp_flag); in lpfc_offline_prep()
3841 &ndlp->nlp_flag); in lpfc_offline_prep()
3843 &ndlp->nlp_flag); in lpfc_offline_prep()
3846 if (ndlp->nlp_type & NLP_FABRIC) { in lpfc_offline_prep()
3858 &ndlp->save_flags) && in lpfc_offline_prep()
3859 !(ndlp->fc4_xpt_flags & in lpfc_offline_prep()
3873 if (phba->wq) in lpfc_offline_prep()
3874 flush_workqueue(phba->wq); in lpfc_offline_prep()
3878 * lpfc_offline - Bring a HBA offline
3892 if (test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_offline()
3902 lpfc_nvme_destroy_localport(phba->pport); in lpfc_offline()
3906 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) in lpfc_offline()
3914 spin_lock_irq(&phba->hbalock); in lpfc_offline()
3915 phba->work_ha = 0; in lpfc_offline()
3916 spin_unlock_irq(&phba->hbalock); in lpfc_offline()
3919 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_offline()
3921 spin_lock_irq(shost->host_lock); in lpfc_offline()
3922 vports[i]->work_port_events = 0; in lpfc_offline()
3923 spin_unlock_irq(shost->host_lock); in lpfc_offline()
3924 set_bit(FC_OFFLINE_MODE, &vports[i]->fc_flag); in lpfc_offline()
3930 if (test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_offline()
3933 if (phba->cfg_xri_rebalancing) in lpfc_offline()
3938 * lpfc_scsi_free - Free all the SCSI buffers and IOCBs from driver lists
3950 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_scsi_free()
3953 spin_lock_irq(&phba->hbalock); in lpfc_scsi_free()
3957 spin_lock(&phba->scsi_buf_list_put_lock); in lpfc_scsi_free()
3958 list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list_put, in lpfc_scsi_free()
3960 list_del(&sb->list); in lpfc_scsi_free()
3961 dma_pool_free(phba->lpfc_sg_dma_buf_pool, sb->data, in lpfc_scsi_free()
3962 sb->dma_handle); in lpfc_scsi_free()
3964 phba->total_scsi_bufs--; in lpfc_scsi_free()
3966 spin_unlock(&phba->scsi_buf_list_put_lock); in lpfc_scsi_free()
3968 spin_lock(&phba->scsi_buf_list_get_lock); in lpfc_scsi_free()
3969 list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list_get, in lpfc_scsi_free()
3971 list_del(&sb->list); in lpfc_scsi_free()
3972 dma_pool_free(phba->lpfc_sg_dma_buf_pool, sb->data, in lpfc_scsi_free()
3973 sb->dma_handle); in lpfc_scsi_free()
3975 phba->total_scsi_bufs--; in lpfc_scsi_free()
3977 spin_unlock(&phba->scsi_buf_list_get_lock); in lpfc_scsi_free()
3978 spin_unlock_irq(&phba->hbalock); in lpfc_scsi_free()
3982 * lpfc_io_free - Free all the IO buffers and IOCBs from driver lists
3996 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_free()
3997 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_free()
3999 spin_lock(&qp->io_buf_list_put_lock); in lpfc_io_free()
4001 &qp->lpfc_io_buf_list_put, in lpfc_io_free()
4003 list_del(&lpfc_ncmd->list); in lpfc_io_free()
4004 qp->put_io_bufs--; in lpfc_io_free()
4005 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_io_free()
4006 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_io_free()
4007 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_io_free()
4011 qp->total_io_bufs--; in lpfc_io_free()
4013 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_io_free()
4015 spin_lock(&qp->io_buf_list_get_lock); in lpfc_io_free()
4017 &qp->lpfc_io_buf_list_get, in lpfc_io_free()
4019 list_del(&lpfc_ncmd->list); in lpfc_io_free()
4020 qp->get_io_bufs--; in lpfc_io_free()
4021 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_io_free()
4022 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_io_free()
4023 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_io_free()
4027 qp->total_io_bufs--; in lpfc_io_free()
4029 spin_unlock(&qp->io_buf_list_get_lock); in lpfc_io_free()
4034 * lpfc_sli4_els_sgl_update - update ELS xri-sgl sizing and mapping
4043 * 0 - successful (for now, it always returns 0)
4054 * update on pci function's els xri-sgl list in lpfc_sli4_els_sgl_update()
4058 if (els_xri_cnt > phba->sli4_hba.els_xri_cnt) { in lpfc_sli4_els_sgl_update()
4059 /* els xri-sgl expanded */ in lpfc_sli4_els_sgl_update()
4060 xri_cnt = els_xri_cnt - phba->sli4_hba.els_xri_cnt; in lpfc_sli4_els_sgl_update()
4062 "3157 ELS xri-sgl count increased from " in lpfc_sli4_els_sgl_update()
4063 "%d to %d\n", phba->sli4_hba.els_xri_cnt, in lpfc_sli4_els_sgl_update()
4074 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
4077 sglq_entry->buff_type = GEN_BUFF_TYPE; in lpfc_sli4_els_sgl_update()
4078 sglq_entry->virt = lpfc_mbuf_alloc(phba, 0, in lpfc_sli4_els_sgl_update()
4079 &sglq_entry->phys); in lpfc_sli4_els_sgl_update()
4080 if (sglq_entry->virt == NULL) { in lpfc_sli4_els_sgl_update()
4086 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
4089 sglq_entry->sgl = sglq_entry->virt; in lpfc_sli4_els_sgl_update()
4090 memset(sglq_entry->sgl, 0, LPFC_BPL_SIZE); in lpfc_sli4_els_sgl_update()
4091 sglq_entry->state = SGL_FREED; in lpfc_sli4_els_sgl_update()
4092 list_add_tail(&sglq_entry->list, &els_sgl_list); in lpfc_sli4_els_sgl_update()
4094 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4096 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_sli4_els_sgl_update()
4097 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4098 } else if (els_xri_cnt < phba->sli4_hba.els_xri_cnt) { in lpfc_sli4_els_sgl_update()
4099 /* els xri-sgl shrinked */ in lpfc_sli4_els_sgl_update()
4100 xri_cnt = phba->sli4_hba.els_xri_cnt - els_xri_cnt; in lpfc_sli4_els_sgl_update()
4102 "3158 ELS xri-sgl count decreased from " in lpfc_sli4_els_sgl_update()
4103 "%d to %d\n", phba->sli4_hba.els_xri_cnt, in lpfc_sli4_els_sgl_update()
4105 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4106 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, in lpfc_sli4_els_sgl_update()
4113 __lpfc_mbuf_free(phba, sglq_entry->virt, in lpfc_sli4_els_sgl_update()
4114 sglq_entry->phys); in lpfc_sli4_els_sgl_update()
4119 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_sli4_els_sgl_update()
4120 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
4123 "3163 ELS xri-sgl count unchanged: %d\n", in lpfc_sli4_els_sgl_update()
4125 phba->sli4_hba.els_xri_cnt = els_xri_cnt; in lpfc_sli4_els_sgl_update()
4131 &phba->sli4_hba.lpfc_els_sgl_list, list) { in lpfc_sli4_els_sgl_update()
4138 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
4141 sglq_entry->sli4_lxritag = lxri; in lpfc_sli4_els_sgl_update()
4142 sglq_entry->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_els_sgl_update()
4152 * lpfc_sli4_nvmet_sgl_update - update xri-sgl sizing and mapping
4161 * 0 - successful (for now, it always returns 0)
4173 * update on pci function's nvmet xri-sgl list in lpfc_sli4_nvmet_sgl_update()
4178 nvmet_xri_cnt = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4179 if (nvmet_xri_cnt > phba->sli4_hba.nvmet_xri_cnt) { in lpfc_sli4_nvmet_sgl_update()
4180 /* els xri-sgl expanded */ in lpfc_sli4_nvmet_sgl_update()
4181 xri_cnt = nvmet_xri_cnt - phba->sli4_hba.nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4183 "6302 NVMET xri-sgl cnt grew from %d to %d\n", in lpfc_sli4_nvmet_sgl_update()
4184 phba->sli4_hba.nvmet_xri_cnt, nvmet_xri_cnt); in lpfc_sli4_nvmet_sgl_update()
4194 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
4197 sglq_entry->buff_type = NVMET_BUFF_TYPE; in lpfc_sli4_nvmet_sgl_update()
4198 sglq_entry->virt = lpfc_nvmet_buf_alloc(phba, 0, in lpfc_sli4_nvmet_sgl_update()
4199 &sglq_entry->phys); in lpfc_sli4_nvmet_sgl_update()
4200 if (sglq_entry->virt == NULL) { in lpfc_sli4_nvmet_sgl_update()
4206 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
4209 sglq_entry->sgl = sglq_entry->virt; in lpfc_sli4_nvmet_sgl_update()
4210 memset(sglq_entry->sgl, 0, in lpfc_sli4_nvmet_sgl_update()
4211 phba->cfg_sg_dma_buf_size); in lpfc_sli4_nvmet_sgl_update()
4212 sglq_entry->state = SGL_FREED; in lpfc_sli4_nvmet_sgl_update()
4213 list_add_tail(&sglq_entry->list, &nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
4215 spin_lock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4216 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4218 &phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
4219 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4220 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4221 } else if (nvmet_xri_cnt < phba->sli4_hba.nvmet_xri_cnt) { in lpfc_sli4_nvmet_sgl_update()
4222 /* nvmet xri-sgl shrunk */ in lpfc_sli4_nvmet_sgl_update()
4223 xri_cnt = phba->sli4_hba.nvmet_xri_cnt - nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4225 "6305 NVMET xri-sgl count decreased from " in lpfc_sli4_nvmet_sgl_update()
4226 "%d to %d\n", phba->sli4_hba.nvmet_xri_cnt, in lpfc_sli4_nvmet_sgl_update()
4228 spin_lock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4229 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4230 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, in lpfc_sli4_nvmet_sgl_update()
4237 lpfc_nvmet_buf_free(phba, sglq_entry->virt, in lpfc_sli4_nvmet_sgl_update()
4238 sglq_entry->phys); in lpfc_sli4_nvmet_sgl_update()
4243 &phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
4244 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
4245 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
4248 "6306 NVMET xri-sgl count unchanged: %d\n", in lpfc_sli4_nvmet_sgl_update()
4250 phba->sli4_hba.nvmet_xri_cnt = nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
4256 &phba->sli4_hba.lpfc_nvmet_sgl_list, list) { in lpfc_sli4_nvmet_sgl_update()
4263 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
4266 sglq_entry->sli4_lxritag = lxri; in lpfc_sli4_nvmet_sgl_update()
4267 sglq_entry->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_nvmet_sgl_update()
4286 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_buf_flush()
4287 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf_flush()
4288 spin_lock_irq(&qp->io_buf_list_get_lock); in lpfc_io_buf_flush()
4289 spin_lock(&qp->io_buf_list_put_lock); in lpfc_io_buf_flush()
4292 list_splice_init(&qp->lpfc_io_buf_list_get, &blist); in lpfc_io_buf_flush()
4293 list_splice(&qp->lpfc_io_buf_list_put, &blist); in lpfc_io_buf_flush()
4294 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_io_buf_flush()
4295 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_io_buf_flush()
4296 cnt += qp->get_io_bufs + qp->put_io_bufs; in lpfc_io_buf_flush()
4297 qp->get_io_bufs = 0; in lpfc_io_buf_flush()
4298 qp->put_io_bufs = 0; in lpfc_io_buf_flush()
4299 qp->total_io_bufs = 0; in lpfc_io_buf_flush()
4300 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_io_buf_flush()
4301 spin_unlock_irq(&qp->io_buf_list_get_lock); in lpfc_io_buf_flush()
4314 list_add_tail(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4317 xri = lpfc_cmd->cur_iocbq.sli4_xritag; in lpfc_io_buf_flush()
4321 if (xri < iobufp->cur_iocbq.sli4_xritag) { in lpfc_io_buf_flush()
4323 list_add(&lpfc_cmd->list, in lpfc_io_buf_flush()
4324 &prev_iobufp->list); in lpfc_io_buf_flush()
4326 list_add(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4333 list_add_tail(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
4346 qp = phba->sli4_hba.hdwq; in lpfc_io_buf_replenish()
4349 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_buf_replenish()
4355 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf_replenish()
4356 lpfc_cmd->hdwq_no = idx; in lpfc_io_buf_replenish()
4357 lpfc_cmd->hdwq = qp; in lpfc_io_buf_replenish()
4358 lpfc_cmd->cur_iocbq.cmd_cmpl = NULL; in lpfc_io_buf_replenish()
4359 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflags); in lpfc_io_buf_replenish()
4360 list_add_tail(&lpfc_cmd->list, in lpfc_io_buf_replenish()
4361 &qp->lpfc_io_buf_list_put); in lpfc_io_buf_replenish()
4362 qp->put_io_bufs++; in lpfc_io_buf_replenish()
4363 qp->total_io_bufs++; in lpfc_io_buf_replenish()
4364 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, in lpfc_io_buf_replenish()
4372 * lpfc_sli4_io_sgl_update - update xri-sgl sizing and mapping
4381 * 0 - successful (for now, it always returns 0)
4393 * update on pci function's allocated nvme xri-sgl list in lpfc_sli4_io_sgl_update()
4398 io_xri_max = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt; in lpfc_sli4_io_sgl_update()
4399 phba->sli4_hba.io_xri_max = io_xri_max; in lpfc_sli4_io_sgl_update()
4404 phba->sli4_hba.io_xri_cnt, in lpfc_sli4_io_sgl_update()
4405 phba->sli4_hba.io_xri_max, in lpfc_sli4_io_sgl_update()
4410 if (phba->sli4_hba.io_xri_cnt > phba->sli4_hba.io_xri_max) { in lpfc_sli4_io_sgl_update()
4412 io_xri_cnt = 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()
4419 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_sli4_io_sgl_update()
4420 lpfc_ncmd->data, in lpfc_sli4_io_sgl_update()
4421 lpfc_ncmd->dma_handle); in lpfc_sli4_io_sgl_update()
4425 phba->sli4_hba.io_xri_cnt -= io_xri_cnt; in lpfc_sli4_io_sgl_update()
4431 phba->sli4_hba.io_xri_cnt = cnt; in lpfc_sli4_io_sgl_update()
4440 rc = -ENOMEM; in lpfc_sli4_io_sgl_update()
4443 lpfc_ncmd->cur_iocbq.sli4_lxritag = lxri; in lpfc_sli4_io_sgl_update()
4444 lpfc_ncmd->cur_iocbq.sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_io_sgl_update()
4455 * lpfc_new_io_buf - IO buffer allocator for HBA with SLI4 IF spec
4459 * This routine allocates nvme buffers for device with SLI-4 interface spec,
4465 * int - number of IO buffers that were allocated and posted.
4479 phba->sli4_hba.io_xri_cnt = 0; in lpfc_new_io_buf()
4489 lpfc_ncmd->data = dma_pool_zalloc(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4491 &lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4492 if (!lpfc_ncmd->data) { in lpfc_new_io_buf()
4497 if (phba->cfg_xpsgl && !phba->nvmet_support) { in lpfc_new_io_buf()
4498 INIT_LIST_HEAD(&lpfc_ncmd->dma_sgl_xtra_list); in lpfc_new_io_buf()
4504 if ((phba->sli3_options & LPFC_SLI3_BG_ENABLED) && in lpfc_new_io_buf()
4505 (((unsigned long)(lpfc_ncmd->data) & in lpfc_new_io_buf()
4506 (unsigned long)(SLI4_PAGE_SIZE - 1)) != 0)) { in lpfc_new_io_buf()
4511 (unsigned long)lpfc_ncmd->data); in lpfc_new_io_buf()
4512 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4513 lpfc_ncmd->data, in lpfc_new_io_buf()
4514 lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4520 INIT_LIST_HEAD(&lpfc_ncmd->dma_cmd_rsp_list); in lpfc_new_io_buf()
4524 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4525 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4529 pwqeq = &lpfc_ncmd->cur_iocbq; in lpfc_new_io_buf()
4531 /* Allocate iotag for lpfc_ncmd->cur_iocbq. */ in lpfc_new_io_buf()
4534 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4535 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4543 pwqeq->sli4_lxritag = lxri; in lpfc_new_io_buf()
4544 pwqeq->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_new_io_buf()
4546 /* Initialize local short-hand pointers. */ in lpfc_new_io_buf()
4547 lpfc_ncmd->dma_sgl = lpfc_ncmd->data; in lpfc_new_io_buf()
4548 lpfc_ncmd->dma_phys_sgl = lpfc_ncmd->dma_handle; in lpfc_new_io_buf()
4549 lpfc_ncmd->cur_iocbq.io_buf = lpfc_ncmd; in lpfc_new_io_buf()
4550 spin_lock_init(&lpfc_ncmd->buf_lock); in lpfc_new_io_buf()
4553 list_add_tail(&lpfc_ncmd->list, &post_nblist); in lpfc_new_io_buf()
4554 phba->sli4_hba.io_xri_cnt++; in lpfc_new_io_buf()
4580 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_get_wwpn()
4583 return (uint64_t)-1; in lpfc_get_wwpn()
4592 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_get_wwpn()
4593 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_get_wwpn()
4594 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_get_wwpn()
4595 return (uint64_t) -1; in lpfc_get_wwpn()
4597 mb = &mboxq->u.mb; in lpfc_get_wwpn()
4598 memcpy(&wwn, (char *)mb->un.varRDnvp.portname, sizeof(uint64_t)); in lpfc_get_wwpn()
4600 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_get_wwpn()
4601 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_get_wwpn()
4609 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_get_sg_tablesize()
4610 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_get_sg_tablesize()
4613 return phba->cfg_scsi_seg_cnt; in lpfc_get_sg_tablesize()
4615 return phba->cfg_sg_seg_cnt; in lpfc_get_sg_tablesize()
4619 * lpfc_vmid_res_alloc - Allocates resources for VMID
4627 * Non-0 on Failure
4633 if (phba->sli_rev == LPFC_SLI_REV3) { in lpfc_vmid_res_alloc()
4634 phba->cfg_vmid_app_header = 0; in lpfc_vmid_res_alloc()
4635 phba->cfg_vmid_priority_tagging = 0; in lpfc_vmid_res_alloc()
4639 vport->vmid = in lpfc_vmid_res_alloc()
4640 kcalloc(phba->cfg_max_vmid, sizeof(struct lpfc_vmid), in lpfc_vmid_res_alloc()
4642 if (!vport->vmid) in lpfc_vmid_res_alloc()
4643 return -ENOMEM; in lpfc_vmid_res_alloc()
4645 rwlock_init(&vport->vmid_lock); in lpfc_vmid_res_alloc()
4648 vport->vmid_priority_tagging = phba->cfg_vmid_priority_tagging; in lpfc_vmid_res_alloc()
4649 vport->vmid_inactivity_timeout = in lpfc_vmid_res_alloc()
4650 phba->cfg_vmid_inactivity_timeout; in lpfc_vmid_res_alloc()
4651 vport->max_vmid = phba->cfg_max_vmid; in lpfc_vmid_res_alloc()
4652 vport->cur_vmid_cnt = 0; in lpfc_vmid_res_alloc()
4654 vport->vmid_priority_range = bitmap_zalloc in lpfc_vmid_res_alloc()
4657 if (!vport->vmid_priority_range) { in lpfc_vmid_res_alloc()
4658 kfree(vport->vmid); in lpfc_vmid_res_alloc()
4659 return -ENOMEM; in lpfc_vmid_res_alloc()
4662 hash_init(vport->hash_table); in lpfc_vmid_res_alloc()
4668 * lpfc_create_port - Create an FC port
4680 * @vport - pointer to the virtual N_Port data structure.
4681 * NULL - port create failed.
4697 if (phba->sli_rev < LPFC_SLI_REV4 && in lpfc_create_port()
4698 dev == &phba->pcidev->dev) { in lpfc_create_port()
4720 if (dev == &phba->pcidev->dev) { in lpfc_create_port()
4721 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { in lpfc_create_port()
4727 template->eh_host_reset_handler = NULL; in lpfc_create_port()
4730 template->sg_tablesize = lpfc_get_sg_tablesize(phba); in lpfc_create_port()
4740 template->sg_tablesize = lpfc_get_sg_tablesize(phba); in lpfc_create_port()
4747 vport = (struct lpfc_vport *) shost->hostdata; in lpfc_create_port()
4748 vport->phba = phba; in lpfc_create_port()
4749 set_bit(FC_LOADING, &vport->load_flag); in lpfc_create_port()
4750 set_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); in lpfc_create_port()
4751 vport->fc_rscn_flush = 0; in lpfc_create_port()
4752 atomic_set(&vport->fc_plogi_cnt, 0); in lpfc_create_port()
4753 atomic_set(&vport->fc_adisc_cnt, 0); in lpfc_create_port()
4754 atomic_set(&vport->fc_reglogin_cnt, 0); in lpfc_create_port()
4755 atomic_set(&vport->fc_prli_cnt, 0); in lpfc_create_port()
4756 atomic_set(&vport->fc_unmap_cnt, 0); in lpfc_create_port()
4757 atomic_set(&vport->fc_map_cnt, 0); in lpfc_create_port()
4758 atomic_set(&vport->fc_npr_cnt, 0); in lpfc_create_port()
4759 atomic_set(&vport->fc_unused_cnt, 0); in lpfc_create_port()
4763 vport->cfg_enable_fc4_type = phba->cfg_enable_fc4_type; in lpfc_create_port()
4765 shost->unique_id = instance; in lpfc_create_port()
4766 shost->max_id = LPFC_MAX_TARGET; in lpfc_create_port()
4767 shost->max_lun = vport->cfg_max_luns; in lpfc_create_port()
4768 shost->this_id = -1; in lpfc_create_port()
4771 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_create_port()
4773 &phba->sli4_hba.sli_intf); in lpfc_create_port()
4778 shost->max_cmd_len = LPFC_FCP_CDB_LEN_32; in lpfc_create_port()
4781 shost->max_cmd_len = LPFC_FCP_CDB_LEN; in lpfc_create_port()
4785 shost->max_cmd_len = LPFC_FCP_CDB_LEN; in lpfc_create_port()
4788 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_create_port()
4789 if (!phba->cfg_fcp_mq_threshold || in lpfc_create_port()
4790 phba->cfg_fcp_mq_threshold > phba->cfg_hdw_queue) in lpfc_create_port()
4791 phba->cfg_fcp_mq_threshold = phba->cfg_hdw_queue; in lpfc_create_port()
4793 shost->nr_hw_queues = min_t(int, 2 * num_possible_nodes(), in lpfc_create_port()
4794 phba->cfg_fcp_mq_threshold); in lpfc_create_port()
4796 shost->dma_boundary = in lpfc_create_port()
4797 phba->sli4_hba.pc_sli4_params.sge_supp_len-1; in lpfc_create_port()
4799 /* SLI-3 has a limited number of hardware queues (3), in lpfc_create_port()
4802 shost->nr_hw_queues = 1; in lpfc_create_port()
4809 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_create_port()
4810 if (dev != &phba->pcidev->dev) { in lpfc_create_port()
4811 shost->transportt = lpfc_vport_transport_template; in lpfc_create_port()
4812 vport->port_type = LPFC_NPIV_PORT; in lpfc_create_port()
4814 shost->transportt = lpfc_transport_template; in lpfc_create_port()
4815 vport->port_type = LPFC_PHYSICAL_PORT; in lpfc_create_port()
4821 vport->port_type, shost->sg_tablesize, in lpfc_create_port()
4822 phba->cfg_scsi_seg_cnt, phba->cfg_sg_seg_cnt); in lpfc_create_port()
4831 INIT_LIST_HEAD(&vport->fc_nodes); in lpfc_create_port()
4832 spin_lock_init(&vport->fc_nodes_list_lock); in lpfc_create_port()
4833 INIT_LIST_HEAD(&vport->rcv_buffer_list); in lpfc_create_port()
4834 spin_lock_init(&vport->work_port_lock); in lpfc_create_port()
4836 timer_setup(&vport->fc_disctmo, lpfc_disc_timeout, 0); in lpfc_create_port()
4838 timer_setup(&vport->els_tmofunc, lpfc_els_timeout, 0); in lpfc_create_port()
4840 timer_setup(&vport->delayed_disc_tmo, lpfc_delayed_disc_tmo, 0); in lpfc_create_port()
4842 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) in lpfc_create_port()
4845 error = scsi_add_host_with_dma(shost, dev, &phba->pcidev->dev); in lpfc_create_port()
4849 spin_lock_irq(&phba->port_list_lock); in lpfc_create_port()
4850 list_add_tail(&vport->listentry, &phba->port_list); in lpfc_create_port()
4851 spin_unlock_irq(&phba->port_list_lock); in lpfc_create_port()
4855 kfree(vport->vmid); in lpfc_create_port()
4856 bitmap_free(vport->vmid_priority_range); in lpfc_create_port()
4864 * destroy_port - destroy an FC port
4874 struct lpfc_hba *phba = vport->phba; in destroy_port()
4880 spin_lock_irq(&phba->port_list_lock); in destroy_port()
4881 list_del_init(&vport->listentry); in destroy_port()
4882 spin_unlock_irq(&phba->port_list_lock); in destroy_port()
4889 * lpfc_get_instance - Get a unique integer ID
4895 * instance - a unique integer ID allocated as the new instance.
4896 * -1 - lpfc get instance failed.
4904 return ret < 0 ? -1 : ret; in lpfc_get_instance()
4908 * lpfc_scan_finished - method for SCSI layer to detect whether scan is done
4919 * 0 - SCSI host scan is not over yet.
4920 * 1 - SCSI host scan is over.
4924 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_scan_finished()
4925 struct lpfc_hba *phba = vport->phba; in lpfc_scan_finished()
4928 spin_lock_irq(shost->host_lock); in lpfc_scan_finished()
4930 if (test_bit(FC_UNLOADING, &vport->load_flag)) { in lpfc_scan_finished()
4942 phba->link_state <= LPFC_LINK_DOWN) { in lpfc_scan_finished()
4950 if (vport->port_state != LPFC_VPORT_READY) in lpfc_scan_finished()
4952 if (vport->num_disc_nodes || vport->fc_prli_sent) in lpfc_scan_finished()
4954 if (!atomic_read(&vport->fc_map_cnt) && in lpfc_scan_finished()
4957 if ((phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) != 0) in lpfc_scan_finished()
4963 spin_unlock_irq(shost->host_lock); in lpfc_scan_finished()
4969 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; in lpfc_host_supported_speeds_set()
4970 struct lpfc_hba *phba = vport->phba; in lpfc_host_supported_speeds_set()
4977 if (test_bit(HBA_FCOE_MODE, &phba->hba_flag)) in lpfc_host_supported_speeds_set()
4980 if (phba->lmt & LMT_256Gb) in lpfc_host_supported_speeds_set()
4982 if (phba->lmt & LMT_128Gb) in lpfc_host_supported_speeds_set()
4984 if (phba->lmt & LMT_64Gb) in lpfc_host_supported_speeds_set()
4986 if (phba->lmt & LMT_32Gb) in lpfc_host_supported_speeds_set()
4988 if (phba->lmt & LMT_16Gb) in lpfc_host_supported_speeds_set()
4990 if (phba->lmt & LMT_10Gb) in lpfc_host_supported_speeds_set()
4992 if (phba->lmt & LMT_8Gb) in lpfc_host_supported_speeds_set()
4994 if (phba->lmt & LMT_4Gb) in lpfc_host_supported_speeds_set()
4996 if (phba->lmt & LMT_2Gb) in lpfc_host_supported_speeds_set()
4998 if (phba->lmt & LMT_1Gb) in lpfc_host_supported_speeds_set()
5003 * lpfc_host_attrib_init - Initialize SCSI host attributes on a FC port
5011 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_host_attrib_init()
5012 struct lpfc_hba *phba = vport->phba; in lpfc_host_attrib_init()
5017 fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); in lpfc_host_attrib_init()
5018 fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); in lpfc_host_attrib_init()
5032 (((uint32_t) vport->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) | in lpfc_host_attrib_init()
5033 (uint32_t) vport->fc_sparam.cmn.bbRcvSizeLsb; in lpfc_host_attrib_init()
5035 fc_host_dev_loss_tmo(shost) = vport->cfg_devloss_tmo; in lpfc_host_attrib_init()
5043 fc_host_max_npiv_vports(shost) = phba->max_vpi; in lpfc_host_attrib_init()
5044 clear_bit(FC_LOADING, &vport->load_flag); in lpfc_host_attrib_init()
5048 * lpfc_stop_port_s3 - Stop SLI3 device port
5059 writel(0, phba->HCregaddr); in lpfc_stop_port_s3()
5060 readl(phba->HCregaddr); /* flush */ in lpfc_stop_port_s3()
5062 writel(0xffffffff, phba->HAregaddr); in lpfc_stop_port_s3()
5063 readl(phba->HAregaddr); /* flush */ in lpfc_stop_port_s3()
5067 phba->pport->work_port_events = 0; in lpfc_stop_port_s3()
5071 * lpfc_stop_port_s4 - Stop SLI4 device port
5083 if (phba->pport) in lpfc_stop_port_s4()
5084 phba->pport->work_port_events = 0; in lpfc_stop_port_s4()
5085 phba->sli4_hba.intr_enable = 0; in lpfc_stop_port_s4()
5089 * lpfc_stop_port - Wrapper function for stopping hba port
5098 phba->lpfc_stop_port(phba); in lpfc_stop_port()
5100 if (phba->wq) in lpfc_stop_port()
5101 flush_workqueue(phba->wq); in lpfc_stop_port()
5105 * lpfc_fcf_redisc_wait_start_timer - Start fcf rediscover wait timer
5116 mod_timer(&phba->fcf.redisc_wait, fcf_redisc_wait_tmo); in lpfc_fcf_redisc_wait_start_timer()
5117 spin_lock_irq(&phba->hbalock); in lpfc_fcf_redisc_wait_start_timer()
5119 phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_SCAN_DONE); in lpfc_fcf_redisc_wait_start_timer()
5121 phba->fcf.fcf_flag |= FCF_REDISC_PEND; in lpfc_fcf_redisc_wait_start_timer()
5122 spin_unlock_irq(&phba->hbalock); in lpfc_fcf_redisc_wait_start_timer()
5126 * lpfc_sli4_fcf_redisc_wait_tmo - FCF table rediscover wait timeout
5141 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
5142 if (!(phba->fcf.fcf_flag & FCF_REDISC_PEND)) { in lpfc_sli4_fcf_redisc_wait_tmo()
5143 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
5147 phba->fcf.fcf_flag &= ~FCF_REDISC_PEND; in lpfc_sli4_fcf_redisc_wait_tmo()
5149 phba->fcf.fcf_flag |= FCF_REDISC_EVT; in lpfc_sli4_fcf_redisc_wait_tmo()
5150 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
5158 * lpfc_vmid_poll - VMID timeout detection
5174 if (phba->pport->vmid_priority_tagging) { in lpfc_vmid_poll()
5176 phba->pport->work_port_events |= WORKER_CHECK_VMID_ISSUE_QFPA; in lpfc_vmid_poll()
5180 if (phba->pport->vmid_inactivity_timeout || in lpfc_vmid_poll()
5181 test_bit(FC_DEREGISTER_ALL_APP_ID, &phba->pport->load_flag)) { in lpfc_vmid_poll()
5183 phba->pport->work_port_events |= WORKER_CHECK_INACTIVE_VMID; in lpfc_vmid_poll()
5190 mod_timer(&phba->inactive_vmid_poll, in lpfc_vmid_poll()
5195 * lpfc_sli4_parse_latt_fault - Parse sli4 link-attention link fault code
5199 * This routine is to parse the SLI4 link-attention link fault code.
5229 * lpfc_sli4_parse_latt_type - Parse sli4 link attention type
5250 /* Ignore physical link up events - wait for logical link up */ in lpfc_sli4_parse_latt_type()
5267 * lpfc_sli_port_speed_get - Get sli3 link speed code to link speed
5282 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_sli_port_speed_get()
5283 switch (phba->fc_linkspeed) { in lpfc_sli_port_speed_get()
5306 if (phba->sli4_hba.link_state.logical_speed) in lpfc_sli_port_speed_get()
5308 phba->sli4_hba.link_state.logical_speed; in lpfc_sli_port_speed_get()
5310 link_speed = phba->sli4_hba.link_state.speed; in lpfc_sli_port_speed_get()
5316 * lpfc_sli4_port_speed_parse - Parse async evt link speed code to link speed
5412 * lpfc_sli4_async_link_evt - Process the asynchronous FCoE link event
5431 phba->fcoe_eventtag = acqe_link->event_tag; in lpfc_sli4_async_link_evt()
5432 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_async_link_evt()
5450 phba->sli4_hba.els_wq->pring->flag |= LPFC_STOP_IOCB_EVENT; in lpfc_sli4_async_link_evt()
5453 phba->sli.slistat.link_event++; in lpfc_sli4_async_link_evt()
5456 lpfc_read_topology(phba, pmb, pmb->ctx_buf); in lpfc_sli4_async_link_evt()
5457 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_sli4_async_link_evt()
5458 pmb->vport = phba->pport; in lpfc_sli4_async_link_evt()
5461 phba->sli4_hba.link_state.speed = in lpfc_sli4_async_link_evt()
5464 phba->sli4_hba.link_state.duplex = in lpfc_sli4_async_link_evt()
5466 phba->sli4_hba.link_state.status = in lpfc_sli4_async_link_evt()
5468 phba->sli4_hba.link_state.type = in lpfc_sli4_async_link_evt()
5470 phba->sli4_hba.link_state.number = in lpfc_sli4_async_link_evt()
5472 phba->sli4_hba.link_state.fault = in lpfc_sli4_async_link_evt()
5474 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_link_evt()
5478 "2900 Async FC/FCoE Link event - Speed:%dGBit " in lpfc_sli4_async_link_evt()
5481 phba->sli4_hba.link_state.speed, in lpfc_sli4_async_link_evt()
5482 phba->sli4_hba.link_state.topology, in lpfc_sli4_async_link_evt()
5483 phba->sli4_hba.link_state.status, in lpfc_sli4_async_link_evt()
5484 phba->sli4_hba.link_state.type, in lpfc_sli4_async_link_evt()
5485 phba->sli4_hba.link_state.number, in lpfc_sli4_async_link_evt()
5486 phba->sli4_hba.link_state.logical_speed, in lpfc_sli4_async_link_evt()
5487 phba->sli4_hba.link_state.fault); in lpfc_sli4_async_link_evt()
5490 * topology info. Note: Optional for non FC-AL ports. in lpfc_sli4_async_link_evt()
5492 if (!test_bit(HBA_FCOE_MODE, &phba->hba_flag)) { in lpfc_sli4_async_link_evt()
5504 mb = &pmb->u.mb; in lpfc_sli4_async_link_evt()
5505 mb->mbxStatus = MBX_SUCCESS; in lpfc_sli4_async_link_evt()
5511 la = (struct lpfc_mbx_read_top *) &pmb->u.mb.un.varReadTop; in lpfc_sli4_async_link_evt()
5512 la->eventTag = acqe_link->event_tag; in lpfc_sli4_async_link_evt()
5535 * lpfc_async_link_speed_to_read_top - Parse async evt link speed code to read
5589 if (!phba->rx_monitor) { in lpfc_cgn_dump_rxmonitor()
5593 lpfc_rx_monitor_report(phba, phba->rx_monitor, NULL, 0, in lpfc_cgn_dump_rxmonitor()
5599 * lpfc_cgn_update_stat - Save data into congestion stats buffer
5612 if (!phba->cgn_i) in lpfc_cgn_update_stat()
5614 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_cgn_update_stat()
5619 le32_add_cpu(&cp->link_integ_notification, 1); in lpfc_cgn_update_stat()
5620 lpfc_cgn_update_tstamp(phba, &cp->stat_lnk); in lpfc_cgn_update_stat()
5623 le32_add_cpu(&cp->delivery_notification, 1); in lpfc_cgn_update_stat()
5624 lpfc_cgn_update_tstamp(phba, &cp->stat_delivery); in lpfc_cgn_update_stat()
5627 le32_add_cpu(&cp->cgn_peer_notification, 1); in lpfc_cgn_update_stat()
5628 lpfc_cgn_update_tstamp(phba, &cp->stat_peer); in lpfc_cgn_update_stat()
5631 le32_add_cpu(&cp->cgn_notification, 1); in lpfc_cgn_update_stat()
5632 lpfc_cgn_update_tstamp(phba, &cp->stat_fpin); in lpfc_cgn_update_stat()
5634 if (phba->cgn_fpin_frequency && in lpfc_cgn_update_stat()
5635 phba->cgn_fpin_frequency != LPFC_FPIN_INIT_FREQ) { in lpfc_cgn_update_stat()
5636 value = LPFC_CGN_TIMER_TO_MIN / phba->cgn_fpin_frequency; in lpfc_cgn_update_stat()
5637 cp->cgn_stat_npm = value; in lpfc_cgn_update_stat()
5642 cp->cgn_info_crc = cpu_to_le32(value); in lpfc_cgn_update_stat()
5646 * lpfc_cgn_update_tstamp - Update cmf timestamp
5659 ts->month = tm_val.tm_mon + 1; in lpfc_cgn_update_tstamp()
5660 ts->day = tm_val.tm_mday; in lpfc_cgn_update_tstamp()
5661 ts->year = tm_val.tm_year - 100; in lpfc_cgn_update_tstamp()
5662 ts->hour = tm_val.tm_hour; in lpfc_cgn_update_tstamp()
5663 ts->minute = tm_val.tm_min; in lpfc_cgn_update_tstamp()
5664 ts->second = tm_val.tm_sec; in lpfc_cgn_update_tstamp()
5669 ts->day, ts->month, in lpfc_cgn_update_tstamp()
5670 ts->year, ts->hour, in lpfc_cgn_update_tstamp()
5671 ts->minute, ts->second); in lpfc_cgn_update_tstamp()
5675 * lpfc_cmf_stats_timer - Save data into registered congestion buffer
5701 if (!phba->cgn_i) in lpfc_cmf_stats_timer()
5703 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_cmf_stats_timer()
5705 phba->cgn_evt_timestamp = jiffies + in lpfc_cmf_stats_timer()
5707 phba->cgn_evt_minute++; in lpfc_cmf_stats_timer()
5710 lpfc_cgn_update_tstamp(phba, &cp->base_time); in lpfc_cmf_stats_timer()
5712 if (phba->cgn_fpin_frequency && in lpfc_cmf_stats_timer()
5713 phba->cgn_fpin_frequency != LPFC_FPIN_INIT_FREQ) { in lpfc_cmf_stats_timer()
5714 value = LPFC_CGN_TIMER_TO_MIN / phba->cgn_fpin_frequency; in lpfc_cmf_stats_timer()
5715 cp->cgn_stat_npm = value; in lpfc_cmf_stats_timer()
5719 lvalue = atomic_read(&phba->cgn_latency_evt_cnt); in lpfc_cmf_stats_timer()
5720 latsum = atomic64_read(&phba->cgn_latency_evt); in lpfc_cmf_stats_timer()
5721 atomic_set(&phba->cgn_latency_evt_cnt, 0); in lpfc_cmf_stats_timer()
5722 atomic64_set(&phba->cgn_latency_evt, 0); in lpfc_cmf_stats_timer()
5728 bps = div_u64(phba->rx_block_cnt, LPFC_SEC_MIN) * 512; in lpfc_cmf_stats_timer()
5729 phba->rx_block_cnt = 0; in lpfc_cmf_stats_timer()
5734 cp->cgn_info_mode = phba->cgn_p.cgn_param_mode; in lpfc_cmf_stats_timer()
5735 cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0; in lpfc_cmf_stats_timer()
5736 cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1; in lpfc_cmf_stats_timer()
5737 cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2; in lpfc_cmf_stats_timer()
5740 value = (uint16_t)(phba->pport->cfg_lun_queue_depth); in lpfc_cmf_stats_timer()
5741 cp->cgn_lunq = cpu_to_le16(value); in lpfc_cmf_stats_timer()
5743 /* Record congestion buffer info - every minute in lpfc_cmf_stats_timer()
5749 index = ++cp->cgn_index_minute; in lpfc_cmf_stats_timer()
5750 if (cp->cgn_index_minute == LPFC_MIN_HOUR) { in lpfc_cmf_stats_timer()
5751 cp->cgn_index_minute = 0; in lpfc_cmf_stats_timer()
5756 dvalue = atomic_read(&phba->cgn_driver_evt_cnt); in lpfc_cmf_stats_timer()
5757 atomic_set(&phba->cgn_driver_evt_cnt, 0); in lpfc_cmf_stats_timer()
5759 /* Get the number of warning events - FPIN and Signal for this minute */ in lpfc_cmf_stats_timer()
5761 if ((phba->cgn_reg_fpin & LPFC_CGN_FPIN_WARN) || in lpfc_cmf_stats_timer()
5762 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY || in lpfc_cmf_stats_timer()
5763 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) in lpfc_cmf_stats_timer()
5764 wvalue = atomic_read(&phba->cgn_fabric_warn_cnt); in lpfc_cmf_stats_timer()
5765 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_cmf_stats_timer()
5767 /* Get the number of alarm events - FPIN and Signal for this minute */ in lpfc_cmf_stats_timer()
5769 if ((phba->cgn_reg_fpin & LPFC_CGN_FPIN_ALARM) || in lpfc_cmf_stats_timer()
5770 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) in lpfc_cmf_stats_timer()
5771 avalue = atomic_read(&phba->cgn_fabric_alarm_cnt); in lpfc_cmf_stats_timer()
5772 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_cmf_stats_timer()
5777 ptr = &cp->cgn_drvr_min[index]; in lpfc_cmf_stats_timer()
5781 ptr = &cp->cgn_warn_min[index]; in lpfc_cmf_stats_timer()
5785 ptr = &cp->cgn_alarm_min[index]; in lpfc_cmf_stats_timer()
5789 lptr = &cp->cgn_latency_min[index]; in lpfc_cmf_stats_timer()
5798 mptr = &cp->cgn_bw_min[index]; in lpfc_cmf_stats_timer()
5802 "2418 Congestion Info - minute (%d): %d %d %d %d %d\n", in lpfc_cmf_stats_timer()
5806 if ((phba->cgn_evt_minute % LPFC_MIN_HOUR) == 0) { in lpfc_cmf_stats_timer()
5807 /* Record congestion buffer info - every hour in lpfc_cmf_stats_timer()
5810 index = ++cp->cgn_index_hour; in lpfc_cmf_stats_timer()
5811 if (cp->cgn_index_hour == LPFC_HOUR_DAY) { in lpfc_cmf_stats_timer()
5812 cp->cgn_index_hour = 0; in lpfc_cmf_stats_timer()
5823 dvalue += le16_to_cpu(cp->cgn_drvr_min[i]); in lpfc_cmf_stats_timer()
5824 wvalue += le16_to_cpu(cp->cgn_warn_min[i]); in lpfc_cmf_stats_timer()
5825 lvalue += le32_to_cpu(cp->cgn_latency_min[i]); in lpfc_cmf_stats_timer()
5826 mbps += le16_to_cpu(cp->cgn_bw_min[i]); in lpfc_cmf_stats_timer()
5827 avalue += le16_to_cpu(cp->cgn_alarm_min[i]); in lpfc_cmf_stats_timer()
5834 lptr = &cp->cgn_drvr_hr[index]; in lpfc_cmf_stats_timer()
5836 lptr = &cp->cgn_warn_hr[index]; in lpfc_cmf_stats_timer()
5838 lptr = &cp->cgn_latency_hr[index]; in lpfc_cmf_stats_timer()
5840 mptr = &cp->cgn_bw_hr[index]; in lpfc_cmf_stats_timer()
5842 lptr = &cp->cgn_alarm_hr[index]; in lpfc_cmf_stats_timer()
5846 "2419 Congestion Info - hour " in lpfc_cmf_stats_timer()
5852 if ((phba->cgn_evt_minute % LPFC_MIN_DAY) == 0) { in lpfc_cmf_stats_timer()
5853 /* Record congestion buffer info - every hour in lpfc_cmf_stats_timer()
5857 index = ++cp->cgn_index_day; in lpfc_cmf_stats_timer()
5858 if (cp->cgn_index_day == LPFC_MAX_CGN_DAYS) { in lpfc_cmf_stats_timer()
5859 cp->cgn_index_day = 0; in lpfc_cmf_stats_timer()
5870 dvalue += le32_to_cpu(cp->cgn_drvr_hr[i]); in lpfc_cmf_stats_timer()
5871 wvalue += le32_to_cpu(cp->cgn_warn_hr[i]); in lpfc_cmf_stats_timer()
5872 lvalue += le32_to_cpu(cp->cgn_latency_hr[i]); in lpfc_cmf_stats_timer()
5873 mbps += le16_to_cpu(cp->cgn_bw_hr[i]); in lpfc_cmf_stats_timer()
5874 avalue += le32_to_cpu(cp->cgn_alarm_hr[i]); in lpfc_cmf_stats_timer()
5881 lptr = &cp->cgn_drvr_day[index]; in lpfc_cmf_stats_timer()
5883 lptr = &cp->cgn_warn_day[index]; in lpfc_cmf_stats_timer()
5885 lptr = &cp->cgn_latency_day[index]; in lpfc_cmf_stats_timer()
5887 mptr = &cp->cgn_bw_day[index]; in lpfc_cmf_stats_timer()
5889 lptr = &cp->cgn_alarm_day[index]; in lpfc_cmf_stats_timer()
5893 "2420 Congestion Info - daily (%d): " in lpfc_cmf_stats_timer()
5899 value = phba->cgn_fpin_frequency; in lpfc_cmf_stats_timer()
5900 cp->cgn_warn_freq = cpu_to_le16(value); in lpfc_cmf_stats_timer()
5901 cp->cgn_alarm_freq = cpu_to_le16(value); in lpfc_cmf_stats_timer()
5905 cp->cgn_info_crc = cpu_to_le32(lvalue); in lpfc_cmf_stats_timer()
5913 * lpfc_calc_cmf_latency - latency from start of rxate timer interval
5931 if (cmpl_time.tv_sec == phba->cmf_latency.tv_sec) { in lpfc_calc_cmf_latency()
5932 msec = (cmpl_time.tv_nsec - phba->cmf_latency.tv_nsec) / in lpfc_calc_cmf_latency()
5935 if (cmpl_time.tv_nsec >= phba->cmf_latency.tv_nsec) { in lpfc_calc_cmf_latency()
5936 msec = (cmpl_time.tv_sec - in lpfc_calc_cmf_latency()
5937 phba->cmf_latency.tv_sec) * MSEC_PER_SEC; in lpfc_calc_cmf_latency()
5938 msec += ((cmpl_time.tv_nsec - in lpfc_calc_cmf_latency()
5939 phba->cmf_latency.tv_nsec) / NSEC_PER_MSEC); in lpfc_calc_cmf_latency()
5941 msec = (cmpl_time.tv_sec - phba->cmf_latency.tv_sec - in lpfc_calc_cmf_latency()
5943 msec += (((NSEC_PER_SEC - phba->cmf_latency.tv_nsec) + in lpfc_calc_cmf_latency()
5951 * lpfc_cmf_timer - This is the timer function for one congestion
5970 if (phba->cmf_active_mode == LPFC_CFG_OFF || in lpfc_cmf_timer()
5971 !phba->cmf_latency.tv_sec) { in lpfc_cmf_timer()
5974 phba->cmf_active_mode, in lpfc_cmf_timer()
5975 (uint64_t)phba->cmf_latency.tv_sec); in lpfc_cmf_timer()
5982 if (!phba->pport) in lpfc_cmf_timer()
5988 atomic_set(&phba->cmf_stop_io, 1); in lpfc_cmf_timer()
6002 ktime_get_real_ts64(&phba->cmf_latency); in lpfc_cmf_timer()
6004 phba->cmf_link_byte_count = in lpfc_cmf_timer()
6005 div_u64(phba->cmf_max_line_rate * LPFC_CMF_INTERVAL, 1000); in lpfc_cmf_timer()
6013 cgs = per_cpu_ptr(phba->cmf_stat, cpu); in lpfc_cmf_timer()
6014 total += atomic64_xchg(&cgs->total_bytes, 0); in lpfc_cmf_timer()
6015 io_cnt += atomic_xchg(&cgs->rx_io_cnt, 0); in lpfc_cmf_timer()
6016 lat += atomic64_xchg(&cgs->rx_latency, 0); in lpfc_cmf_timer()
6017 rcv += atomic64_xchg(&cgs->rcv_bytes, 0); in lpfc_cmf_timer()
6025 if (phba->cmf_active_mode == LPFC_CFG_MANAGED && in lpfc_cmf_timer()
6026 phba->link_state != LPFC_LINK_DOWN && in lpfc_cmf_timer()
6027 test_bit(HBA_SETUP, &phba->hba_flag)) { in lpfc_cmf_timer()
6028 mbpi = phba->cmf_last_sync_bw; in lpfc_cmf_timer()
6029 phba->cmf_last_sync_bw = 0; in lpfc_cmf_timer()
6040 extra = cnt - total; in lpfc_cmf_timer()
6047 mbpi = phba->cmf_link_byte_count; in lpfc_cmf_timer()
6050 phba->cmf_timer_cnt++; in lpfc_cmf_timer()
6054 atomic_add(io_cnt, &phba->cgn_latency_evt_cnt); in lpfc_cmf_timer()
6055 atomic64_add(lat, &phba->cgn_latency_evt); in lpfc_cmf_timer()
6057 busy = atomic_xchg(&phba->cmf_busy, 0); in lpfc_cmf_timer()
6058 max_read = atomic_xchg(&phba->rx_max_read_cnt, 0); in lpfc_cmf_timer()
6062 if (mbpi > phba->cmf_link_byte_count || in lpfc_cmf_timer()
6063 phba->cmf_active_mode == LPFC_CFG_MONITOR) in lpfc_cmf_timer()
6064 mbpi = phba->cmf_link_byte_count; in lpfc_cmf_timer()
6069 if (mbpi != phba->cmf_max_bytes_per_interval) in lpfc_cmf_timer()
6070 phba->cmf_max_bytes_per_interval = mbpi; in lpfc_cmf_timer()
6074 if (phba->rx_monitor) { in lpfc_cmf_timer()
6079 entry.cmf_info = phba->cmf_active_info; in lpfc_cmf_timer()
6090 if (phba->cmf_active_mode == LPFC_CFG_MANAGED) in lpfc_cmf_timer()
6091 entry.timer_utilization = phba->cmf_last_ts; in lpfc_cmf_timer()
6095 phba->cmf_last_ts = 0; in lpfc_cmf_timer()
6097 lpfc_rx_monitor_record(phba->rx_monitor, &entry); in lpfc_cmf_timer()
6100 if (phba->cmf_active_mode == LPFC_CFG_MONITOR) { in lpfc_cmf_timer()
6105 atomic_inc(&phba->cgn_driver_evt_cnt); in lpfc_cmf_timer()
6107 phba->rx_block_cnt += div_u64(rcv, 512); /* save 512 byte block cnt */ in lpfc_cmf_timer()
6112 if (atomic_xchg(&phba->cmf_bw_wait, 0)) in lpfc_cmf_timer()
6113 queue_work(phba->wq, &phba->unblock_request_work); in lpfc_cmf_timer()
6116 atomic_set(&phba->cmf_stop_io, 0); in lpfc_cmf_timer()
6126 ((phba->trunk_link.link##__idx.state == LPFC_LINK_UP) ?\
6141 phba->sli4_hba.link_state.speed = in lpfc_update_trunk_link_status()
6145 phba->sli4_hba.link_state.logical_speed = in lpfc_update_trunk_link_status()
6148 phba->fc_linkspeed = in lpfc_update_trunk_link_status()
6154 phba->trunk_link.link0.state = in lpfc_update_trunk_link_status()
6157 phba->trunk_link.link0.fault = port_fault & 0x1 ? err : 0; in lpfc_update_trunk_link_status()
6161 phba->trunk_link.link1.state = in lpfc_update_trunk_link_status()
6164 phba->trunk_link.link1.fault = port_fault & 0x2 ? err : 0; in lpfc_update_trunk_link_status()
6168 phba->trunk_link.link2.state = in lpfc_update_trunk_link_status()
6171 phba->trunk_link.link2.fault = port_fault & 0x4 ? err : 0; in lpfc_update_trunk_link_status()
6175 phba->trunk_link.link3.state = in lpfc_update_trunk_link_status()
6178 phba->trunk_link.link3.fault = port_fault & 0x8 ? err : 0; in lpfc_update_trunk_link_status()
6183 phba->trunk_link.phy_lnk_speed = in lpfc_update_trunk_link_status()
6184 phba->sli4_hba.link_state.logical_speed / (cnt * 1000); in lpfc_update_trunk_link_status()
6186 phba->trunk_link.phy_lnk_speed = LPFC_LINK_SPEED_UNKNOWN; in lpfc_update_trunk_link_status()
6189 "2910 Async FC Trunking Event - Speed:%d\n" in lpfc_update_trunk_link_status()
6192 phba->sli4_hba.link_state.speed, in lpfc_update_trunk_link_status()
6193 phba->sli4_hba.link_state.logical_speed, in lpfc_update_trunk_link_status()
6197 if (phba->cmf_active_mode != LPFC_CFG_OFF) in lpfc_update_trunk_link_status()
6204 * SLI-4: We have only 0xA error codes in lpfc_update_trunk_link_status()
6216 * lpfc_sli4_async_fc_evt - Process the asynchronous FC link event
6248 phba->sli4_hba.link_state.speed = in lpfc_sli4_async_fc_evt()
6251 phba->sli4_hba.link_state.duplex = LPFC_ASYNC_LINK_DUPLEX_FULL; in lpfc_sli4_async_fc_evt()
6252 phba->sli4_hba.link_state.topology = in lpfc_sli4_async_fc_evt()
6254 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
6256 phba->sli4_hba.link_state.type = in lpfc_sli4_async_fc_evt()
6258 phba->sli4_hba.link_state.number = in lpfc_sli4_async_fc_evt()
6260 phba->sli4_hba.link_state.fault = in lpfc_sli4_async_fc_evt()
6262 phba->sli4_hba.link_state.link_status = in lpfc_sli4_async_fc_evt()
6269 if (phba->sli4_hba.link_state.status >= LPFC_FC_LA_TYPE_LINK_UP && in lpfc_sli4_async_fc_evt()
6270 phba->sli4_hba.link_state.status < LPFC_FC_LA_TYPE_ACTIVATE_FAIL) { in lpfc_sli4_async_fc_evt()
6273 phba->sli4_hba.link_state.logical_speed = 0; in lpfc_sli4_async_fc_evt()
6274 else if (!phba->sli4_hba.conf_trunk) in lpfc_sli4_async_fc_evt()
6275 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_fc_evt()
6280 "2896 Async FC event - Speed:%dGBaud Topology:x%x " in lpfc_sli4_async_fc_evt()
6283 phba->sli4_hba.link_state.speed, in lpfc_sli4_async_fc_evt()
6284 phba->sli4_hba.link_state.topology, in lpfc_sli4_async_fc_evt()
6285 phba->sli4_hba.link_state.status, in lpfc_sli4_async_fc_evt()
6286 phba->sli4_hba.link_state.type, in lpfc_sli4_async_fc_evt()
6287 phba->sli4_hba.link_state.number, in lpfc_sli4_async_fc_evt()
6288 phba->sli4_hba.link_state.logical_speed, in lpfc_sli4_async_fc_evt()
6289 phba->sli4_hba.link_state.fault, in lpfc_sli4_async_fc_evt()
6290 phba->sli4_hba.link_state.link_status); in lpfc_sli4_async_fc_evt()
6297 if (phba->sli4_hba.link_state.status >= LPFC_FC_LA_TYPE_ACTIVATE_FAIL) { in lpfc_sli4_async_fc_evt()
6298 switch (phba->sli4_hba.link_state.status) { in lpfc_sli4_async_fc_evt()
6301 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
6312 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
6320 "2992 Async FC event - Informational Link " in lpfc_sli4_async_fc_evt()
6326 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_async_fc_evt()
6343 phba->sli4_hba.els_wq->pring->flag |= LPFC_STOP_IOCB_EVENT; in lpfc_sli4_async_fc_evt()
6346 phba->sli.slistat.link_event++; in lpfc_sli4_async_fc_evt()
6349 lpfc_read_topology(phba, pmb, pmb->ctx_buf); in lpfc_sli4_async_fc_evt()
6350 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_sli4_async_fc_evt()
6351 pmb->vport = phba->pport; in lpfc_sli4_async_fc_evt()
6353 if (phba->sli4_hba.link_state.status != LPFC_FC_LA_TYPE_LINK_UP) { in lpfc_sli4_async_fc_evt()
6354 phba->link_flag &= ~(LS_MDS_LINK_DOWN | LS_MDS_LOOPBACK); in lpfc_sli4_async_fc_evt()
6356 switch (phba->sli4_hba.link_state.status) { in lpfc_sli4_async_fc_evt()
6358 phba->link_flag |= LS_MDS_LINK_DOWN; in lpfc_sli4_async_fc_evt()
6361 phba->link_flag |= LS_MDS_LOOPBACK; in lpfc_sli4_async_fc_evt()
6368 mb = &pmb->u.mb; in lpfc_sli4_async_fc_evt()
6369 mb->mbxStatus = MBX_SUCCESS; in lpfc_sli4_async_fc_evt()
6375 la = (struct lpfc_mbx_read_top *)&pmb->u.mb.un.varReadTop; in lpfc_sli4_async_fc_evt()
6376 la->eventTag = acqe_fc->event_tag; in lpfc_sli4_async_fc_evt()
6378 if (phba->sli4_hba.link_state.status == in lpfc_sli4_async_fc_evt()
6402 * lpfc_sli4_async_sli_evt - Process the asynchronous SLI link event
6426 "2901 Async SLI event - Type:%d, Event Data: x%08x " in lpfc_sli4_async_sli_evt()
6428 acqe_sli->event_data1, acqe_sli->event_data2, in lpfc_sli4_async_sli_evt()
6429 acqe_sli->event_data3, acqe_sli->trailer); in lpfc_sli4_async_sli_evt()
6431 port_name = phba->Port[0]; in lpfc_sli4_async_sli_evt()
6439 temp_event_data.data = (uint32_t)acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6442 "3190 Over Temperature:%d Celsius- Port Name %c\n", in lpfc_sli4_async_sli_evt()
6443 acqe_sli->event_data1, port_name); in lpfc_sli4_async_sli_evt()
6445 phba->sfp_warning |= LPFC_TRANSGRESSION_HIGH_TEMPERATURE; in lpfc_sli4_async_sli_evt()
6446 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli4_async_sli_evt()
6456 temp_event_data.data = (uint32_t)acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6459 "3191 Normal Temperature:%d Celsius - Port Name %c\n", in lpfc_sli4_async_sli_evt()
6460 acqe_sli->event_data1, port_name); in lpfc_sli4_async_sli_evt()
6462 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli4_async_sli_evt()
6471 &acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6474 switch (phba->sli4_hba.lnk_info.lnk_no) { in lpfc_sli4_async_sli_evt()
6477 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6479 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6483 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6485 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6489 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6491 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6495 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6497 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
6504 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_async_sli_evt()
6509 if (phba->sli4_hba.lnk_info.optic_state == status) in lpfc_sli4_async_sli_evt()
6518 "installed/not installed - Reseat optics, " in lpfc_sli4_async_sli_evt()
6523 "Optics of two types installed - Remove one " in lpfc_sli4_async_sli_evt()
6527 sprintf(message, "Incompatible optics - Replace with " in lpfc_sli4_async_sli_evt()
6531 sprintf(message, "Unqualified optics - Replace with " in lpfc_sli4_async_sli_evt()
6533 "Support - Link is%s operational", in lpfc_sli4_async_sli_evt()
6537 sprintf(message, "Uncertified optics - Replace with " in lpfc_sli4_async_sli_evt()
6538 "Avago-certified optics to enable link " in lpfc_sli4_async_sli_evt()
6539 "operation - Link is%s operational", in lpfc_sli4_async_sli_evt()
6551 phba->lmt = 0; in lpfc_sli4_async_sli_evt()
6565 for (i = 0; i <= phba->max_vports && vports[i] != NULL; in lpfc_sli4_async_sli_evt()
6573 phba->sli4_hba.lnk_info.optic_state = status; in lpfc_sli4_async_sli_evt()
6579 "3192 Remote DPort Test Initiated - " in lpfc_sli4_async_sli_evt()
6581 acqe_sli->event_data1, acqe_sli->event_data2); in lpfc_sli4_async_sli_evt()
6589 * to use FA-WWN, but the attached device doesn’t support it. in lpfc_sli4_async_sli_evt()
6590 * Event Data1 - N.A, Event Data2 - N.A in lpfc_sli4_async_sli_evt()
6594 "2699 Misconfigured FA-PWWN - Attached device " in lpfc_sli4_async_sli_evt()
6595 "does not support FA-PWWN\n"); in lpfc_sli4_async_sli_evt()
6596 phba->sli4_hba.fawwpn_flag &= ~LPFC_FAWWPN_FABRIC; in lpfc_sli4_async_sli_evt()
6597 memset(phba->pport->fc_portname.u.wwn, 0, in lpfc_sli4_async_sli_evt()
6603 "2518 EEPROM failure - " in lpfc_sli4_async_sli_evt()
6605 acqe_sli->event_data1, acqe_sli->event_data2); in lpfc_sli4_async_sli_evt()
6608 if (phba->cmf_active_mode == LPFC_CFG_OFF) in lpfc_sli4_async_sli_evt()
6611 &acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
6612 phba->cgn_acqe_cnt++; in lpfc_sli4_async_sli_evt()
6615 atomic64_add(cnt, &phba->cgn_acqe_stat.warn); in lpfc_sli4_async_sli_evt()
6616 atomic64_add(cgn_signal->alarm_cnt, &phba->cgn_acqe_stat.alarm); in lpfc_sli4_async_sli_evt()
6621 if (cgn_signal->alarm_cnt) { in lpfc_sli4_async_sli_evt()
6622 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { in lpfc_sli4_async_sli_evt()
6624 atomic_add(cgn_signal->alarm_cnt, in lpfc_sli4_async_sli_evt()
6625 &phba->cgn_sync_alarm_cnt); in lpfc_sli4_async_sli_evt()
6629 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY || in lpfc_sli4_async_sli_evt()
6630 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { in lpfc_sli4_async_sli_evt()
6632 atomic_add(cnt, &phba->cgn_sync_warn_cnt); in lpfc_sli4_async_sli_evt()
6637 /* May be accompanied by a temperature event */ in lpfc_sli4_async_sli_evt()
6642 acqe_sli->event_data1, acqe_sli->event_data2, in lpfc_sli4_async_sli_evt()
6643 acqe_sli->event_data3); in lpfc_sli4_async_sli_evt()
6659 * lpfc_sli4_perform_vport_cvl - Perform clear virtual link on a vport
6677 phba = vport->phba; in lpfc_sli4_perform_vport_cvl()
6687 ndlp->nlp_type |= NLP_FABRIC; in lpfc_sli4_perform_vport_cvl()
6691 if ((phba->pport->port_state < LPFC_FLOGI) && in lpfc_sli4_perform_vport_cvl()
6692 (phba->pport->port_state != LPFC_VPORT_FAILED)) in lpfc_sli4_perform_vport_cvl()
6695 if ((vport != phba->pport) && (vport->port_state < LPFC_FDISC) in lpfc_sli4_perform_vport_cvl()
6696 && (vport->port_state != LPFC_VPORT_FAILED)) in lpfc_sli4_perform_vport_cvl()
6703 set_bit(FC_VPORT_CVL_RCVD, &vport->fc_flag); in lpfc_sli4_perform_vport_cvl()
6709 * lpfc_sli4_perform_all_vport_cvl - Perform clear virtual link on all vports
6723 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) in lpfc_sli4_perform_all_vport_cvl()
6729 * lpfc_sli4_async_fip_evt - Process the asynchronous FCoE FIP event
6747 phba->fc_eventTag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6748 phba->fcoe_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6756 acqe_fip->event_tag, in lpfc_sli4_async_fip_evt()
6757 acqe_fip->index); 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()
6765 if (phba->fcf.fcf_flag & FCF_DISCOVERY) { in lpfc_sli4_async_fip_evt()
6775 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6776 rc = lpfc_sli4_read_fcf_rec(phba, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6780 if (test_bit(FCF_TS_INPROG, &phba->hba_flag)) in lpfc_sli4_async_fip_evt()
6782 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6784 if (phba->fcf.fcf_flag & (FCF_REDISC_EVT | FCF_REDISC_PEND)) { in lpfc_sli4_async_fip_evt()
6785 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6790 if (phba->fcf.fcf_flag & FCF_SCAN_DONE) { in lpfc_sli4_async_fip_evt()
6791 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6794 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6796 /* Otherwise, scan the entire FCF table and re-discover SAN */ in lpfc_sli4_async_fip_evt()
6800 acqe_fip->event_tag, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6813 acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6817 phba->fcoe_cvl_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6820 "tag:x%x\n", acqe_fip->index, in lpfc_sli4_async_fip_evt()
6821 acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6826 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6827 if ((phba->fcf.fcf_flag & FCF_DISCOVERY) && in lpfc_sli4_async_fip_evt()
6828 (phba->fcf.current_rec.fcf_indx != acqe_fip->index)) { in lpfc_sli4_async_fip_evt()
6829 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6831 lpfc_sli4_fcf_rr_index_clear(phba, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6834 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6837 if (phba->fcf.current_rec.fcf_indx != acqe_fip->index) in lpfc_sli4_async_fip_evt()
6846 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6848 phba->fcf.fcf_flag |= FCF_DEAD_DISC; in lpfc_sli4_async_fip_evt()
6849 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6854 "\n", acqe_fip->event_tag, acqe_fip->index); in lpfc_sli4_async_fip_evt()
6862 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6863 phba->fcf.fcf_flag &= ~FCF_DEAD_DISC; in lpfc_sli4_async_fip_evt()
6864 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6881 phba->fcoe_cvl_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
6885 " tag 0x%x\n", acqe_fip->index, acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6888 acqe_fip->index); in lpfc_sli4_async_fip_evt()
6896 for (i = 0; i <= phba->max_vports && vports[i] != NULL; in lpfc_sli4_async_fip_evt()
6899 &vports[i]->fc_flag) && in lpfc_sli4_async_fip_evt()
6900 vports[i]->port_state > LPFC_FDISC) { in lpfc_sli4_async_fip_evt()
6909 * Don't re-instantiate if vport is marked for deletion. in lpfc_sli4_async_fip_evt()
6913 if (!test_bit(FC_UNLOADING, &vport->load_flag) && in lpfc_sli4_async_fip_evt()
6917 * re-instantiate the Vlink using FDISC. in lpfc_sli4_async_fip_evt()
6919 mod_timer(&ndlp->nlp_delayfunc, in lpfc_sli4_async_fip_evt()
6921 set_bit(NLP_DELAY_TMO, &ndlp->nlp_flag); in lpfc_sli4_async_fip_evt()
6922 ndlp->nlp_last_elscmd = ELS_CMD_FDISC; in lpfc_sli4_async_fip_evt()
6923 vport->port_state = LPFC_FDISC; in lpfc_sli4_async_fip_evt()
6932 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6933 if (phba->fcf.fcf_flag & FCF_DISCOVERY) { in lpfc_sli4_async_fip_evt()
6934 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6938 phba->fcf.fcf_flag |= FCF_ACVL_DISC; in lpfc_sli4_async_fip_evt()
6939 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6943 "evt_tag:x%x\n", acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6951 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6952 phba->fcf.fcf_flag &= ~FCF_ACVL_DISC; in lpfc_sli4_async_fip_evt()
6953 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
6955 * Last resort will be re-try on the in lpfc_sli4_async_fip_evt()
6970 "0x%x\n", event_type, acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
6976 * lpfc_sli4_async_dcbx_evt - Process the asynchronous dcbx event
6986 phba->fc_eventTag = acqe_dcbx->event_tag; in lpfc_sli4_async_dcbx_evt()
6993 * lpfc_sli4_async_grp5_evt - Process the asynchronous group5 event
7007 phba->fc_eventTag = acqe_grp5->event_tag; in lpfc_sli4_async_grp5_evt()
7008 phba->fcoe_eventtag = acqe_grp5->event_tag; in lpfc_sli4_async_grp5_evt()
7009 prev_ll_spd = phba->sli4_hba.link_state.logical_speed; in lpfc_sli4_async_grp5_evt()
7010 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_grp5_evt()
7015 phba->sli4_hba.link_state.logical_speed); in lpfc_sli4_async_grp5_evt()
7019 * lpfc_sli4_async_cmstat_evt - Process the asynchronous cmstat event
7028 if (!phba->cgn_i) in lpfc_sli4_async_cmstat_evt()
7034 * lpfc_cgn_params_val - Validate FW congestion parameters.
7044 spin_lock_irq(&phba->hbalock); in lpfc_cgn_params_val()
7046 if (!lpfc_rangecheck(p_cfg_param->cgn_param_mode, LPFC_CFG_OFF, in lpfc_cgn_params_val()
7050 p_cfg_param->cgn_param_mode); in lpfc_cgn_params_val()
7051 p_cfg_param->cgn_param_mode = LPFC_CFG_OFF; in lpfc_cgn_params_val()
7054 spin_unlock_irq(&phba->hbalock); in lpfc_cgn_params_val()
7064 * lpfc_cgn_params_parse - Process a FW cong parm change event
7071 * valid, in-range values. If the signature magic is correct and
7087 if (p_cgn_param->cgn_param_magic == LPFC_CFG_PARAM_MAGIC_NUM) { in lpfc_cgn_params_parse()
7095 p_cgn_param->cgn_param_magic, in lpfc_cgn_params_parse()
7096 p_cgn_param->cgn_param_version, in lpfc_cgn_params_parse()
7097 p_cgn_param->cgn_param_mode, in lpfc_cgn_params_parse()
7098 p_cgn_param->cgn_param_level0, in lpfc_cgn_params_parse()
7099 p_cgn_param->cgn_param_level1, in lpfc_cgn_params_parse()
7100 p_cgn_param->cgn_param_level2, in lpfc_cgn_params_parse()
7101 p_cgn_param->byte13, in lpfc_cgn_params_parse()
7102 p_cgn_param->byte14, in lpfc_cgn_params_parse()
7103 p_cgn_param->byte15, in lpfc_cgn_params_parse()
7104 p_cgn_param->byte11, in lpfc_cgn_params_parse()
7105 p_cgn_param->byte12, in lpfc_cgn_params_parse()
7106 phba->cmf_active_mode); in lpfc_cgn_params_parse()
7108 oldmode = phba->cmf_active_mode; in lpfc_cgn_params_parse()
7116 spin_lock_irq(&phba->hbalock); in lpfc_cgn_params_parse()
7117 memcpy(&phba->cgn_p, p_cgn_param, in lpfc_cgn_params_parse()
7121 if (phba->cgn_i) { in lpfc_cgn_params_parse()
7122 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_cgn_params_parse()
7123 cp->cgn_info_mode = phba->cgn_p.cgn_param_mode; in lpfc_cgn_params_parse()
7124 cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0; in lpfc_cgn_params_parse()
7125 cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1; in lpfc_cgn_params_parse()
7126 cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2; in lpfc_cgn_params_parse()
7129 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_cgn_params_parse()
7131 spin_unlock_irq(&phba->hbalock); in lpfc_cgn_params_parse()
7133 phba->cmf_active_mode = phba->cgn_p.cgn_param_mode; in lpfc_cgn_params_parse()
7137 if (phba->cgn_p.cgn_param_mode != LPFC_CFG_OFF) { in lpfc_cgn_params_parse()
7141 if (phba->link_state >= LPFC_LINK_UP) { in lpfc_cgn_params_parse()
7142 phba->cgn_reg_fpin = in lpfc_cgn_params_parse()
7143 phba->cgn_init_reg_fpin; in lpfc_cgn_params_parse()
7144 phba->cgn_reg_signal = in lpfc_cgn_params_parse()
7145 phba->cgn_init_reg_signal; in lpfc_cgn_params_parse()
7146 lpfc_issue_els_edc(phba->pport, 0); in lpfc_cgn_params_parse()
7151 switch (phba->cgn_p.cgn_param_mode) { in lpfc_cgn_params_parse()
7155 if (phba->link_state >= LPFC_LINK_UP) in lpfc_cgn_params_parse()
7156 lpfc_issue_els_edc(phba->pport, 0); in lpfc_cgn_params_parse()
7159 phba->cmf_max_bytes_per_interval = in lpfc_cgn_params_parse()
7160 phba->cmf_link_byte_count; in lpfc_cgn_params_parse()
7162 /* Resume blocked IO - unblock on workqueue */ in lpfc_cgn_params_parse()
7163 queue_work(phba->wq, in lpfc_cgn_params_parse()
7164 &phba->unblock_request_work); in lpfc_cgn_params_parse()
7169 switch (phba->cgn_p.cgn_param_mode) { in lpfc_cgn_params_parse()
7173 if (phba->link_state >= LPFC_LINK_UP) in lpfc_cgn_params_parse()
7174 lpfc_issue_els_edc(phba->pport, 0); in lpfc_cgn_params_parse()
7183 oldmode != phba->cgn_p.cgn_param_mode) { in lpfc_cgn_params_parse()
7184 if (phba->cgn_p.cgn_param_mode == LPFC_CFG_MANAGED) in lpfc_cgn_params_parse()
7186 phba->cgn_p.cgn_param_level0); in lpfc_cgn_params_parse()
7190 dev_info(&phba->pcidev->dev, "%d: " in lpfc_cgn_params_parse()
7192 phba->brd_no, in lpfc_cgn_params_parse()
7194 [phba->cgn_p.cgn_param_mode], in lpfc_cgn_params_parse()
7200 "version %d\n", p_cgn_param->cgn_param_magic, in lpfc_cgn_params_parse()
7201 p_cgn_param->cgn_param_version); in lpfc_cgn_params_parse()
7206 * lpfc_sli4_cgn_params_read - Read and Validate FW congestion parameters.
7215 * -Eval if an error was encountered
7230 return -ENOMEM; in lpfc_sli4_cgn_params_read()
7262 * lpfc_sli4_cgn_parm_chg_evt - Process a FW congestion param change event
7284 if (!phba->sli4_hba.pc_sli4_params.cmf) { in lpfc_sli4_cgn_parm_chg_evt()
7287 return -EACCES; in lpfc_sli4_cgn_parm_chg_evt()
7307 * lpfc_sli4_async_event_proc - Process all the pending asynchronous event
7319 clear_bit(ASYNC_EVENT, &phba->hba_flag); in lpfc_sli4_async_event_proc()
7322 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
7323 while (!list_empty(&phba->sli4_hba.sp_asynce_work_queue)) { in lpfc_sli4_async_event_proc()
7324 list_remove_head(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_async_event_proc()
7326 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, in lpfc_sli4_async_event_proc()
7330 switch (bf_get(lpfc_trailer_code, &cq_event->cqe.mcqe_cmpl)) { in lpfc_sli4_async_event_proc()
7333 &cq_event->cqe.acqe_link); in lpfc_sli4_async_event_proc()
7336 lpfc_sli4_async_fip_evt(phba, &cq_event->cqe.acqe_fip); in lpfc_sli4_async_event_proc()
7340 &cq_event->cqe.acqe_dcbx); in lpfc_sli4_async_event_proc()
7344 &cq_event->cqe.acqe_grp5); in lpfc_sli4_async_event_proc()
7347 lpfc_sli4_async_fc_evt(phba, &cq_event->cqe.acqe_fc); in lpfc_sli4_async_event_proc()
7350 lpfc_sli4_async_sli_evt(phba, &cq_event->cqe.acqe_sli); in lpfc_sli4_async_event_proc()
7357 &cq_event->cqe.mcqe_cmpl)); in lpfc_sli4_async_event_proc()
7363 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
7365 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_async_event_proc()
7369 * lpfc_sli4_fcf_redisc_event_proc - Process fcf table rediscovery event
7379 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_event_proc()
7381 phba->fcf.fcf_flag &= ~FCF_REDISC_EVT; in lpfc_sli4_fcf_redisc_event_proc()
7383 phba->fcf.failover_rec.flag = 0; in lpfc_sli4_fcf_redisc_event_proc()
7385 phba->fcf.fcf_flag |= FCF_REDISC_FOV; in lpfc_sli4_fcf_redisc_event_proc()
7386 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_event_proc()
7388 /* Scan FCF table from the first entry to re-discover SAN */ in lpfc_sli4_fcf_redisc_event_proc()
7390 "2777 Start post-quiescent FCF table scan\n"); in lpfc_sli4_fcf_redisc_event_proc()
7399 * lpfc_api_table_setup - Set up per hba pci-device group func api jump table
7401 * @dev_grp: The HBA PCI-Device group number.
7403 * This routine is invoked to set up the per HBA PCI-Device group function
7406 * Return: 0 if success, otherwise -ENODEV
7413 /* Set up lpfc PCI-device group */ in lpfc_api_table_setup()
7414 phba->pci_dev_grp = dev_grp; in lpfc_api_table_setup()
7418 phba->sli_rev = LPFC_SLI_REV4; in lpfc_api_table_setup()
7423 return -ENODEV; in lpfc_api_table_setup()
7427 return -ENODEV; in lpfc_api_table_setup()
7431 return -ENODEV; in lpfc_api_table_setup()
7435 return -ENODEV; in lpfc_api_table_setup()
7441 * lpfc_log_intr_mode - Log the active interrupt mode
7461 "0480 Enabled MSI-X interrupt mode.\n"); in lpfc_log_intr_mode()
7472 * lpfc_enable_pci_dev - Enable a generic PCI device.
7479 * 0 - successful
7480 * other values - error
7488 if (!phba->pcidev) in lpfc_enable_pci_dev()
7491 pdev = phba->pcidev; in lpfc_enable_pci_dev()
7505 pdev->needs_freset = 1; in lpfc_enable_pci_dev()
7514 return -ENODEV; in lpfc_enable_pci_dev()
7518 * lpfc_disable_pci_dev - Disable a generic PCI device.
7530 if (!phba->pcidev) in lpfc_disable_pci_dev()
7533 pdev = phba->pcidev; in lpfc_disable_pci_dev()
7542 * lpfc_reset_hba - Reset a hba
7556 if (!phba->cfg_enable_hba_reset) { in lpfc_reset_hba()
7557 phba->link_state = LPFC_HBA_ERROR; in lpfc_reset_hba()
7562 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE) { in lpfc_reset_hba()
7565 if (test_bit(MBX_TMO_ERR, &phba->bit_flags)) { in lpfc_reset_hba()
7574 clear_bit(MBX_TMO_ERR, &phba->bit_flags); in lpfc_reset_hba()
7587 * lpfc_sli_sriov_nr_virtfn_get - Get the number of sr-iov virtual functions
7590 * This function enables the PCI SR-IOV virtual functions to a physical
7591 * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
7593 * not all devices support SR-IOV, the return code from the pci_enable_sriov()
7599 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_sriov_nr_virtfn_get()
7612 * lpfc_sli_probe_sriov_nr_virtfn - Enable a number of sr-iov virtual functions
7616 * This function enables the PCI SR-IOV virtual functions to a physical
7617 * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
7619 * not all devices support SR-IOV, the return code from the pci_enable_sriov()
7625 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_probe_sriov_nr_virtfn()
7634 return -EINVAL; in lpfc_sli_probe_sriov_nr_virtfn()
7660 * lpfc_setup_driver_resource_phase1 - Phase1 etup driver internal resources.
7667 * 0 - successful
7668 * other values - error
7673 struct lpfc_sli *psli = &phba->sli; in lpfc_setup_driver_resource_phase1()
7678 atomic_set(&phba->fast_event_count, 0); in lpfc_setup_driver_resource_phase1()
7679 atomic_set(&phba->dbg_log_idx, 0); in lpfc_setup_driver_resource_phase1()
7680 atomic_set(&phba->dbg_log_cnt, 0); in lpfc_setup_driver_resource_phase1()
7681 atomic_set(&phba->dbg_log_dmping, 0); in lpfc_setup_driver_resource_phase1()
7682 spin_lock_init(&phba->hbalock); in lpfc_setup_driver_resource_phase1()
7685 spin_lock_init(&phba->port_list_lock); in lpfc_setup_driver_resource_phase1()
7686 INIT_LIST_HEAD(&phba->port_list); in lpfc_setup_driver_resource_phase1()
7688 INIT_LIST_HEAD(&phba->work_list); in lpfc_setup_driver_resource_phase1()
7691 init_waitqueue_head(&phba->work_waitq); in lpfc_setup_driver_resource_phase1()
7695 ((phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ? in lpfc_setup_driver_resource_phase1()
7697 ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) ? in lpfc_setup_driver_resource_phase1()
7699 (phba->nvmet_support ? "NVMET" : " ")); in lpfc_setup_driver_resource_phase1()
7702 spin_lock_init(&phba->ras_fwlog_lock); in lpfc_setup_driver_resource_phase1()
7705 spin_lock_init(&phba->scsi_buf_list_get_lock); in lpfc_setup_driver_resource_phase1()
7706 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_get); in lpfc_setup_driver_resource_phase1()
7707 spin_lock_init(&phba->scsi_buf_list_put_lock); in lpfc_setup_driver_resource_phase1()
7708 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_put); in lpfc_setup_driver_resource_phase1()
7711 INIT_LIST_HEAD(&phba->fabric_iocb_list); in lpfc_setup_driver_resource_phase1()
7714 INIT_LIST_HEAD(&phba->elsbuf); in lpfc_setup_driver_resource_phase1()
7717 INIT_LIST_HEAD(&phba->fcf_conn_rec_list); in lpfc_setup_driver_resource_phase1()
7720 spin_lock_init(&phba->devicelock); in lpfc_setup_driver_resource_phase1()
7721 INIT_LIST_HEAD(&phba->luns); in lpfc_setup_driver_resource_phase1()
7724 timer_setup(&psli->mbox_tmo, lpfc_mbox_timeout, 0); in lpfc_setup_driver_resource_phase1()
7726 timer_setup(&phba->fabric_block_timer, lpfc_fabric_block_timeout, 0); in lpfc_setup_driver_resource_phase1()
7728 timer_setup(&phba->eratt_poll, lpfc_poll_eratt, 0); in lpfc_setup_driver_resource_phase1()
7730 timer_setup(&phba->hb_tmofunc, lpfc_hb_timeout, 0); in lpfc_setup_driver_resource_phase1()
7732 INIT_DELAYED_WORK(&phba->eq_delay_work, lpfc_hb_eq_delay_work); in lpfc_setup_driver_resource_phase1()
7734 INIT_DELAYED_WORK(&phba->idle_stat_delay_work, in lpfc_setup_driver_resource_phase1()
7736 INIT_WORK(&phba->unblock_request_work, lpfc_unblock_requests_work); in lpfc_setup_driver_resource_phase1()
7741 * lpfc_sli_driver_resource_setup - Setup driver internal resources for SLI3 dev
7745 * support the SLI-3 HBA device it attached to.
7748 * 0 - successful
7749 * other values - error
7761 timer_setup(&phba->fcp_poll_timer, lpfc_poll_timeout, 0); in lpfc_sli_driver_resource_setup()
7764 phba->work_ha_mask = (HA_ERATT | HA_MBATT | HA_LATT); in lpfc_sli_driver_resource_setup()
7765 phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING * 4)); in lpfc_sli_driver_resource_setup()
7769 /* Set up phase-1 common device driver resources */ in lpfc_sli_driver_resource_setup()
7773 return -ENODEV; in lpfc_sli_driver_resource_setup()
7775 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
7776 phba->sli.sli3_ring = kcalloc(LPFC_SLI3_MAX_RING, in lpfc_sli_driver_resource_setup()
7779 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
7780 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7787 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_driver_resource_setup()
7793 if (phba->cfg_enable_bg) { in lpfc_sli_driver_resource_setup()
7795 * The scsi_buf for a T10-DIF I/O will hold the FCP cmnd, in lpfc_sli_driver_resource_setup()
7803 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
7807 if (phba->cfg_sg_seg_cnt > LPFC_MAX_SG_SEG_CNT_DIF) in lpfc_sli_driver_resource_setup()
7808 phba->cfg_sg_seg_cnt = LPFC_MAX_SG_SEG_CNT_DIF; in lpfc_sli_driver_resource_setup()
7811 phba->cfg_total_seg_cnt = LPFC_MAX_SG_SEG_CNT; in lpfc_sli_driver_resource_setup()
7818 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
7820 ((phba->cfg_sg_seg_cnt + 2) * entry_sz); in lpfc_sli_driver_resource_setup()
7823 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + 2; in lpfc_sli_driver_resource_setup()
7828 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
7829 phba->cfg_total_seg_cnt); in lpfc_sli_driver_resource_setup()
7831 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli_driver_resource_setup()
7833 phba->max_vports = 0; in lpfc_sli_driver_resource_setup()
7843 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7845 phba->lpfc_sg_dma_buf_pool = in lpfc_sli_driver_resource_setup()
7847 &phba->pcidev->dev, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
7850 if (!phba->lpfc_sg_dma_buf_pool) in lpfc_sli_driver_resource_setup()
7853 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli_driver_resource_setup()
7855 &phba->pcidev->dev, in lpfc_sli_driver_resource_setup()
7860 if (!phba->lpfc_cmd_rsp_buf_pool) in lpfc_sli_driver_resource_setup()
7864 * Enable sr-iov virtual functions if supported and configured in lpfc_sli_driver_resource_setup()
7867 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli_driver_resource_setup()
7869 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
7872 "2808 Requested number of SR-IOV " in lpfc_sli_driver_resource_setup()
7875 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
7876 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli_driver_resource_setup()
7883 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli_driver_resource_setup()
7884 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli_driver_resource_setup()
7887 return -ENOMEM; in lpfc_sli_driver_resource_setup()
7891 * lpfc_sli_driver_resource_unset - Unset drvr internal resources for SLI3 dev
7895 * specific for supporting the SLI-3 HBA device it attached to.
7907 * lpfc_sli4_driver_resource_setup - Setup drvr internal resources for SLI4 dev
7911 * support the SLI-4 HBA device it attached to.
7914 * 0 - successful
7915 * other values - error
7927 phba->sli4_hba.num_present_cpu = lpfc_present_cpu; in lpfc_sli4_driver_resource_setup()
7928 phba->sli4_hba.num_possible_cpu = cpumask_last(cpu_possible_mask) + 1; in lpfc_sli4_driver_resource_setup()
7929 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_setup()
7934 /* Set up phase-1 common device driver resources */ in lpfc_sli4_driver_resource_setup()
7937 return -ENODEV; in lpfc_sli4_driver_resource_setup()
7942 return -ENODEV; in lpfc_sli4_driver_resource_setup()
7947 phba->wq = alloc_workqueue("lpfc_wq", WQ_MEM_RECLAIM | WQ_PERCPU, 0); in lpfc_sli4_driver_resource_setup()
7948 if (!phba->wq) in lpfc_sli4_driver_resource_setup()
7949 return -ENOMEM; in lpfc_sli4_driver_resource_setup()
7955 timer_setup(&phba->rrq_tmr, lpfc_rrq_timeout, 0); in lpfc_sli4_driver_resource_setup()
7958 timer_setup(&phba->fcf.redisc_wait, lpfc_sli4_fcf_redisc_wait_tmo, 0); in lpfc_sli4_driver_resource_setup()
7961 hrtimer_setup(&phba->cmf_timer, lpfc_cmf_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in lpfc_sli4_driver_resource_setup()
7963 hrtimer_setup(&phba->cmf_stats_timer, lpfc_cmf_stats_timer, CLOCK_MONOTONIC, in lpfc_sli4_driver_resource_setup()
7967 * Control structure for handling external multi-buffer mailbox in lpfc_sli4_driver_resource_setup()
7968 * command pass-through. in lpfc_sli4_driver_resource_setup()
7970 memset((uint8_t *)&phba->mbox_ext_buf_ctx, 0, in lpfc_sli4_driver_resource_setup()
7972 INIT_LIST_HEAD(&phba->mbox_ext_buf_ctx.ext_dmabuf_list); in lpfc_sli4_driver_resource_setup()
7974 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli4_driver_resource_setup()
7977 phba->max_vports = 0; in lpfc_sli4_driver_resource_setup()
7980 phba->valid_vlan = 0; in lpfc_sli4_driver_resource_setup()
7981 phba->fc_map[0] = LPFC_FCOE_FCF_MAP0; in lpfc_sli4_driver_resource_setup()
7982 phba->fc_map[1] = LPFC_FCOE_FCF_MAP1; in lpfc_sli4_driver_resource_setup()
7983 phba->fc_map[2] = LPFC_FCOE_FCF_MAP2; in lpfc_sli4_driver_resource_setup()
7992 INIT_LIST_HEAD(&phba->hbqs[LPFC_ELS_HBQ].hbq_buffer_list); in lpfc_sli4_driver_resource_setup()
7993 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_sli4_rb_alloc; in lpfc_sli4_driver_resource_setup()
7994 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_sli4_rb_free; in lpfc_sli4_driver_resource_setup()
7998 timer_setup(&phba->inactive_vmid_poll, lpfc_vmid_poll, 0); in lpfc_sli4_driver_resource_setup()
8004 spin_lock_init(&phba->sli4_hba.abts_io_buf_list_lock); in lpfc_sli4_driver_resource_setup()
8005 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_io_buf_list); in lpfc_sli4_driver_resource_setup()
8007 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
8009 spin_lock_init(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_sli4_driver_resource_setup()
8010 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_driver_resource_setup()
8011 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_io_wait_list); in lpfc_sli4_driver_resource_setup()
8012 spin_lock_init(&phba->sli4_hba.t_active_list_lock); in lpfc_sli4_driver_resource_setup()
8013 INIT_LIST_HEAD(&phba->sli4_hba.t_active_ctx_list); in lpfc_sli4_driver_resource_setup()
8017 spin_lock_init(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_driver_resource_setup()
8018 spin_lock_init(&phba->sli4_hba.nvmet_io_wait_lock); in lpfc_sli4_driver_resource_setup()
8019 spin_lock_init(&phba->sli4_hba.asynce_list_lock); in lpfc_sli4_driver_resource_setup()
8020 spin_lock_init(&phba->sli4_hba.els_xri_abrt_list_lock); in lpfc_sli4_driver_resource_setup()
8023 * Initialize driver internal slow-path work queues in lpfc_sli4_driver_resource_setup()
8026 /* Driver internel slow-path CQ Event pool */ in lpfc_sli4_driver_resource_setup()
8027 INIT_LIST_HEAD(&phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_driver_resource_setup()
8029 INIT_LIST_HEAD(&phba->sli4_hba.sp_queue_event); in lpfc_sli4_driver_resource_setup()
8031 INIT_LIST_HEAD(&phba->sli4_hba.sp_asynce_work_queue); in lpfc_sli4_driver_resource_setup()
8032 /* Slow-path XRI aborted CQ Event work queue list */ in lpfc_sli4_driver_resource_setup()
8033 INIT_LIST_HEAD(&phba->sli4_hba.sp_els_xri_aborted_work_queue); in lpfc_sli4_driver_resource_setup()
8035 INIT_LIST_HEAD(&phba->sli4_hba.sp_unsol_work_queue); in lpfc_sli4_driver_resource_setup()
8038 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_blk_list); in lpfc_sli4_driver_resource_setup()
8039 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_xri_blk_list); in lpfc_sli4_driver_resource_setup()
8040 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_vfi_blk_list); in lpfc_sli4_driver_resource_setup()
8041 INIT_LIST_HEAD(&phba->lpfc_vpi_blk_list); in lpfc_sli4_driver_resource_setup()
8046 INIT_LIST_HEAD(&phba->sli.mboxq); in lpfc_sli4_driver_resource_setup()
8047 INIT_LIST_HEAD(&phba->sli.mboxq_cmpl); in lpfc_sli4_driver_resource_setup()
8050 phba->sli4_hba.lnk_info.optic_state = 0xff; in lpfc_sli4_driver_resource_setup()
8058 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_driver_resource_setup()
8062 rc = -ENODEV; in lpfc_sli4_driver_resource_setup()
8065 phba->temp_sensor_support = 1; in lpfc_sli4_driver_resource_setup()
8083 if (phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_CONFIG) { in lpfc_sli4_driver_resource_setup()
8084 /* Right now the link is down, if FA-PWWN is configured the in lpfc_sli4_driver_resource_setup()
8091 phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_FABRIC; in lpfc_sli4_driver_resource_setup()
8099 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_driver_resource_setup()
8106 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_sli4_driver_resource_setup()
8109 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8114 phba->nvmet_support = 0; in lpfc_sli4_driver_resource_setup()
8125 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_driver_resource_setup()
8126 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_driver_resource_setup()
8127 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8128 rc = -EIO; in lpfc_sli4_driver_resource_setup()
8131 mb = &mboxq->u.mb; in lpfc_sli4_driver_resource_setup()
8132 memcpy(&wwn, (char *)mb->un.varRDnvp.nodename, in lpfc_sli4_driver_resource_setup()
8135 phba->sli4_hba.wwnn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
8136 memcpy(&wwn, (char *)mb->un.varRDnvp.portname, in lpfc_sli4_driver_resource_setup()
8140 phba->sli4_hba.wwpn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
8149 phba->nvmet_support = 1; /* a match */ in lpfc_sli4_driver_resource_setup()
8163 phba->cfg_xri_rebalancing = 0; in lpfc_sli4_driver_resource_setup()
8164 if (phba->irq_chann_mode == NHT_MODE) { in lpfc_sli4_driver_resource_setup()
8165 phba->cfg_irq_chann = in lpfc_sli4_driver_resource_setup()
8166 phba->sli4_hba.num_present_cpu; in lpfc_sli4_driver_resource_setup()
8167 phba->cfg_hdw_queue = in lpfc_sli4_driver_resource_setup()
8168 phba->sli4_hba.num_present_cpu; in lpfc_sli4_driver_resource_setup()
8169 phba->irq_chann_mode = NORMAL_MODE; in lpfc_sli4_driver_resource_setup()
8187 rc = -EIO; in lpfc_sli4_driver_resource_setup()
8188 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8197 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_driver_resource_setup()
8211 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) { in lpfc_sli4_driver_resource_setup()
8215 * The scsi_buf for a T10-DIF I/O holds the FCP cmnd, in lpfc_sli4_driver_resource_setup()
8223 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd32) + in lpfc_sli4_driver_resource_setup()
8227 phba->cfg_total_seg_cnt = LPFC_MAX_SGL_SEG_CNT; in lpfc_sli4_driver_resource_setup()
8233 if (phba->cfg_enable_bg && in lpfc_sli4_driver_resource_setup()
8234 phba->cfg_sg_seg_cnt > LPFC_MAX_BG_SLI4_SEG_CNT_DIF) in lpfc_sli4_driver_resource_setup()
8235 phba->cfg_scsi_seg_cnt = LPFC_MAX_BG_SLI4_SEG_CNT_DIF; in lpfc_sli4_driver_resource_setup()
8237 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8245 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd32) + in lpfc_sli4_driver_resource_setup()
8247 ((phba->cfg_sg_seg_cnt + extra) * in lpfc_sli4_driver_resource_setup()
8251 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + extra; in lpfc_sli4_driver_resource_setup()
8252 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8255 * NOTE: if (phba->cfg_sg_seg_cnt + extra) <= 256 we only in lpfc_sli4_driver_resource_setup()
8260 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_driver_resource_setup()
8261 phba->cfg_sg_dma_buf_size = LPFC_DEFAULT_XPSGL_SIZE; in lpfc_sli4_driver_resource_setup()
8262 else if (phba->cfg_sg_dma_buf_size <= LPFC_MIN_SG_SLI4_BUF_SZ) in lpfc_sli4_driver_resource_setup()
8263 phba->cfg_sg_dma_buf_size = LPFC_MIN_SG_SLI4_BUF_SZ; in lpfc_sli4_driver_resource_setup()
8265 phba->cfg_sg_dma_buf_size = in lpfc_sli4_driver_resource_setup()
8266 SLI4_PAGE_ALIGN(phba->cfg_sg_dma_buf_size); in lpfc_sli4_driver_resource_setup()
8268 phba->border_sge_num = phba->cfg_sg_dma_buf_size / in lpfc_sli4_driver_resource_setup()
8272 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
8273 if (phba->cfg_sg_seg_cnt > LPFC_MAX_NVME_SEG_CNT) { in lpfc_sli4_driver_resource_setup()
8278 phba->cfg_nvme_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_sli4_driver_resource_setup()
8280 phba->cfg_nvme_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
8286 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
8287 phba->cfg_total_seg_cnt, phba->cfg_scsi_seg_cnt, in lpfc_sli4_driver_resource_setup()
8288 phba->cfg_nvme_seg_cnt); in lpfc_sli4_driver_resource_setup()
8290 i = min(phba->cfg_sg_dma_buf_size, SLI4_PAGE_SIZE); in lpfc_sli4_driver_resource_setup()
8292 phba->lpfc_sg_dma_buf_pool = in lpfc_sli4_driver_resource_setup()
8294 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
8295 phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
8297 if (!phba->lpfc_sg_dma_buf_pool) { in lpfc_sli4_driver_resource_setup()
8298 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8302 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli4_driver_resource_setup()
8304 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
8308 if (!phba->lpfc_cmd_rsp_buf_pool) { in lpfc_sli4_driver_resource_setup()
8309 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8313 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
8349 longs = (LPFC_SLI4_FCF_TBL_INDX_MAX + BITS_PER_LONG - 1)/BITS_PER_LONG; in lpfc_sli4_driver_resource_setup()
8350 phba->fcf.fcf_rr_bmask = kcalloc(longs, sizeof(unsigned long), in lpfc_sli4_driver_resource_setup()
8352 if (!phba->fcf.fcf_rr_bmask) { in lpfc_sli4_driver_resource_setup()
8356 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8360 phba->sli4_hba.hba_eq_hdl = kcalloc(phba->cfg_irq_chann, in lpfc_sli4_driver_resource_setup()
8363 if (!phba->sli4_hba.hba_eq_hdl) { in lpfc_sli4_driver_resource_setup()
8366 "fast-path per-EQ handle array\n"); in lpfc_sli4_driver_resource_setup()
8367 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8371 phba->sli4_hba.cpu_map = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
8374 if (!phba->sli4_hba.cpu_map) { in lpfc_sli4_driver_resource_setup()
8376 "3327 Failed allocate memory for msi-x " in lpfc_sli4_driver_resource_setup()
8378 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8382 phba->sli4_hba.eq_info = alloc_percpu(struct lpfc_eq_intr_info); in lpfc_sli4_driver_resource_setup()
8383 if (!phba->sli4_hba.eq_info) { in lpfc_sli4_driver_resource_setup()
8386 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8390 phba->sli4_hba.idle_stat = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
8391 sizeof(*phba->sli4_hba.idle_stat), in lpfc_sli4_driver_resource_setup()
8393 if (!phba->sli4_hba.idle_stat) { in lpfc_sli4_driver_resource_setup()
8396 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8401 phba->sli4_hba.c_stat = alloc_percpu(struct lpfc_hdwq_stat); in lpfc_sli4_driver_resource_setup()
8402 if (!phba->sli4_hba.c_stat) { in lpfc_sli4_driver_resource_setup()
8405 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8410 phba->cmf_stat = alloc_percpu(struct lpfc_cgn_stat); in lpfc_sli4_driver_resource_setup()
8411 if (!phba->cmf_stat) { in lpfc_sli4_driver_resource_setup()
8414 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
8419 * Enable sr-iov virtual functions if supported and configured in lpfc_sli4_driver_resource_setup()
8422 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli4_driver_resource_setup()
8424 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
8427 "3020 Requested number of SR-IOV " in lpfc_sli4_driver_resource_setup()
8430 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
8431 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli4_driver_resource_setup()
8439 free_percpu(phba->sli4_hba.c_stat); in lpfc_sli4_driver_resource_setup()
8442 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_setup()
8444 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_setup()
8446 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_setup()
8448 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_setup()
8450 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_setup()
8458 dma_pool_destroy(phba->lpfc_cmd_rsp_buf_pool); in lpfc_sli4_driver_resource_setup()
8459 phba->lpfc_cmd_rsp_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
8461 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli4_driver_resource_setup()
8462 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
8468 destroy_workqueue(phba->wq); in lpfc_sli4_driver_resource_setup()
8469 phba->wq = NULL; in lpfc_sli4_driver_resource_setup()
8474 * lpfc_sli4_driver_resource_unset - Unset drvr internal resources for SLI4 dev
8478 * specific for supporting the SLI-4 HBA device it attached to.
8485 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_unset()
8487 free_percpu(phba->sli4_hba.c_stat); in lpfc_sli4_driver_resource_unset()
8489 free_percpu(phba->cmf_stat); in lpfc_sli4_driver_resource_unset()
8490 kfree(phba->sli4_hba.idle_stat); in lpfc_sli4_driver_resource_unset()
8492 /* Free memory allocated for msi-x interrupt vector to CPU mapping */ in lpfc_sli4_driver_resource_unset()
8493 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_unset()
8494 phba->sli4_hba.num_possible_cpu = 0; in lpfc_sli4_driver_resource_unset()
8495 phba->sli4_hba.num_present_cpu = 0; in lpfc_sli4_driver_resource_unset()
8496 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_unset()
8497 cpumask_clear(&phba->sli4_hba.irq_aff_mask); in lpfc_sli4_driver_resource_unset()
8499 /* Free memory allocated for fast-path work queue handles */ in lpfc_sli4_driver_resource_unset()
8500 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_unset()
8507 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_unset()
8529 &phba->fcf_conn_rec_list, list) { in lpfc_sli4_driver_resource_unset()
8530 list_del_init(&conn_entry->list); in lpfc_sli4_driver_resource_unset()
8538 * lpfc_init_api_table_setup - Set up init api function jump table
8540 * @dev_grp: The HBA PCI-Device group number.
8545 * Returns: 0 - success, -ENODEV - failure.
8550 phba->lpfc_hba_init_link = lpfc_hba_init_link; in lpfc_init_api_table_setup()
8551 phba->lpfc_hba_down_link = lpfc_hba_down_link; in lpfc_init_api_table_setup()
8552 phba->lpfc_selective_reset = lpfc_selective_reset; in lpfc_init_api_table_setup()
8555 phba->lpfc_hba_down_post = lpfc_hba_down_post_s3; in lpfc_init_api_table_setup()
8556 phba->lpfc_handle_eratt = lpfc_handle_eratt_s3; in lpfc_init_api_table_setup()
8557 phba->lpfc_stop_port = lpfc_stop_port_s3; in lpfc_init_api_table_setup()
8560 phba->lpfc_hba_down_post = lpfc_hba_down_post_s4; in lpfc_init_api_table_setup()
8561 phba->lpfc_handle_eratt = lpfc_handle_eratt_s4; in lpfc_init_api_table_setup()
8562 phba->lpfc_stop_port = lpfc_stop_port_s4; in lpfc_init_api_table_setup()
8566 "1431 Invalid HBA PCI-device group: 0x%x\n", in lpfc_init_api_table_setup()
8568 return -ENODEV; in lpfc_init_api_table_setup()
8574 * lpfc_setup_driver_resource_phase2 - Phase2 setup driver internal resources.
8581 * 0 - successful
8582 * other values - error
8590 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_setup_driver_resource_phase2()
8591 "lpfc_worker_%d", phba->brd_no); in lpfc_setup_driver_resource_phase2()
8592 if (IS_ERR(phba->worker_thread)) { in lpfc_setup_driver_resource_phase2()
8593 error = PTR_ERR(phba->worker_thread); in lpfc_setup_driver_resource_phase2()
8601 * lpfc_unset_driver_resource_phase2 - Phase2 unset driver internal resources.
8611 if (phba->wq) { in lpfc_unset_driver_resource_phase2()
8612 destroy_workqueue(phba->wq); in lpfc_unset_driver_resource_phase2()
8613 phba->wq = NULL; in lpfc_unset_driver_resource_phase2()
8617 if (phba->worker_thread) in lpfc_unset_driver_resource_phase2()
8618 kthread_stop(phba->worker_thread); in lpfc_unset_driver_resource_phase2()
8622 * lpfc_free_iocb_list - Free iocb list.
8632 spin_lock_irq(&phba->hbalock); in lpfc_free_iocb_list()
8634 &phba->lpfc_iocb_list, list) { in lpfc_free_iocb_list()
8635 list_del(&iocbq_entry->list); in lpfc_free_iocb_list()
8637 phba->total_iocbq_bufs--; in lpfc_free_iocb_list()
8639 spin_unlock_irq(&phba->hbalock); in lpfc_free_iocb_list()
8645 * lpfc_init_iocb_list - Allocate and initialize iocb list.
8653 * 0 - successful
8654 * other values - error
8664 INIT_LIST_HEAD(&phba->lpfc_iocb_list); in lpfc_init_iocb_list()
8681 iocbq_entry->sli4_lxritag = NO_XRI; in lpfc_init_iocb_list()
8682 iocbq_entry->sli4_xritag = NO_XRI; in lpfc_init_iocb_list()
8684 spin_lock_irq(&phba->hbalock); in lpfc_init_iocb_list()
8685 list_add(&iocbq_entry->list, &phba->lpfc_iocb_list); in lpfc_init_iocb_list()
8686 phba->total_iocbq_bufs++; in lpfc_init_iocb_list()
8687 spin_unlock_irq(&phba->hbalock); in lpfc_init_iocb_list()
8695 return -ENOMEM; in lpfc_init_iocb_list()
8699 * lpfc_free_sgl_list - Free a given sgl list.
8711 list_del(&sglq_entry->list); in lpfc_free_sgl_list()
8712 lpfc_mbuf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_sgl_list()
8718 * lpfc_free_els_sgl_list - Free els sgl list.
8729 spin_lock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
8730 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, &sglq_list); in lpfc_free_els_sgl_list()
8731 spin_unlock_irq(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
8738 * lpfc_free_nvmet_sgl_list - Free nvmet sgl list.
8750 spin_lock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
8751 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
8752 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, &sglq_list); in lpfc_free_nvmet_sgl_list()
8753 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
8754 spin_unlock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
8758 list_del(&sglq_entry->list); in lpfc_free_nvmet_sgl_list()
8759 lpfc_nvmet_buf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_nvmet_sgl_list()
8767 phba->sli4_hba.nvmet_xri_cnt = 0; in lpfc_free_nvmet_sgl_list()
8771 * lpfc_init_active_sgl_array - Allocate the buf to track active ELS XRIs.
8782 size *= phba->sli4_hba.max_cfg_param.max_xri; in lpfc_init_active_sgl_array()
8784 phba->sli4_hba.lpfc_sglq_active_list = in lpfc_init_active_sgl_array()
8786 if (!phba->sli4_hba.lpfc_sglq_active_list) in lpfc_init_active_sgl_array()
8787 return -ENOMEM; in lpfc_init_active_sgl_array()
8792 * lpfc_free_active_sgl - Free the buf that tracks active ELS XRIs.
8802 kfree(phba->sli4_hba.lpfc_sglq_active_list); in lpfc_free_active_sgl()
8806 * lpfc_init_sgl_list - Allocate and initialize sgl list.
8817 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_els_sgl_list); in lpfc_init_sgl_list()
8818 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_init_sgl_list()
8819 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_init_sgl_list()
8820 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_init_sgl_list()
8822 /* els xri-sgl book keeping */ in lpfc_init_sgl_list()
8823 phba->sli4_hba.els_xri_cnt = 0; in lpfc_init_sgl_list()
8825 /* nvme xri-buffer book keeping */ in lpfc_init_sgl_list()
8826 phba->sli4_hba.io_xri_cnt = 0; in lpfc_init_sgl_list()
8830 * lpfc_sli4_init_rpi_hdrs - Post the rpi header memory region to the port
8840 * 0 - successful
8841 * -ERROR - otherwise.
8849 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_init_rpi_hdrs()
8850 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_init_rpi_hdrs()
8852 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_init_rpi_hdrs()
8853 return -EIO; in lpfc_sli4_init_rpi_hdrs()
8860 rc = -ENODEV; in lpfc_sli4_init_rpi_hdrs()
8867 * lpfc_sli4_create_rpi_hdr - Allocate an rpi header memory region
8891 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_create_rpi_hdr()
8893 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_create_rpi_hdr()
8897 rpi_limit = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_create_rpi_hdr()
8899 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8905 curr_rpi_range = phba->sli4_hba.next_rpi; in lpfc_sli4_create_rpi_hdr()
8906 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8914 * port expects a 4KB DMA-mapped memory region that is 4K aligned. in lpfc_sli4_create_rpi_hdr()
8920 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_create_rpi_hdr()
8922 &dmabuf->phys, GFP_KERNEL); in lpfc_sli4_create_rpi_hdr()
8923 if (!dmabuf->virt) { in lpfc_sli4_create_rpi_hdr()
8928 if (!IS_ALIGNED(dmabuf->phys, LPFC_HDR_TEMPLATE_SIZE)) { in lpfc_sli4_create_rpi_hdr()
8938 rpi_hdr->dmabuf = dmabuf; in lpfc_sli4_create_rpi_hdr()
8939 rpi_hdr->len = LPFC_HDR_TEMPLATE_SIZE; in lpfc_sli4_create_rpi_hdr()
8940 rpi_hdr->page_count = 1; in lpfc_sli4_create_rpi_hdr()
8941 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8944 rpi_hdr->start_rpi = curr_rpi_range; in lpfc_sli4_create_rpi_hdr()
8945 rpi_hdr->next_rpi = phba->sli4_hba.next_rpi + LPFC_RPI_HDR_COUNT; in lpfc_sli4_create_rpi_hdr()
8946 list_add_tail(&rpi_hdr->list, &phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_create_rpi_hdr()
8948 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
8952 dma_free_coherent(&phba->pcidev->dev, LPFC_HDR_TEMPLATE_SIZE, in lpfc_sli4_create_rpi_hdr()
8953 dmabuf->virt, dmabuf->phys); in lpfc_sli4_create_rpi_hdr()
8960 * lpfc_sli4_remove_rpi_hdrs - Remove all rpi header memory regions
8973 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_remove_rpi_hdrs()
8977 &phba->sli4_hba.lpfc_rpi_hdr_list, list) { in lpfc_sli4_remove_rpi_hdrs()
8978 list_del(&rpi_hdr->list); in lpfc_sli4_remove_rpi_hdrs()
8979 dma_free_coherent(&phba->pcidev->dev, rpi_hdr->len, in lpfc_sli4_remove_rpi_hdrs()
8980 rpi_hdr->dmabuf->virt, rpi_hdr->dmabuf->phys); in lpfc_sli4_remove_rpi_hdrs()
8981 kfree(rpi_hdr->dmabuf); in lpfc_sli4_remove_rpi_hdrs()
8986 phba->sli4_hba.next_rpi = 0; in lpfc_sli4_remove_rpi_hdrs()
8990 * lpfc_hba_alloc - Allocate driver hba data structure for a device.
8998 * pointer to @phba - successful
8999 * NULL - error
9009 dev_err(&pdev->dev, "failed to allocate hba struct\n"); in lpfc_hba_alloc()
9014 phba->pcidev = pdev; in lpfc_hba_alloc()
9017 phba->brd_no = lpfc_get_instance(); in lpfc_hba_alloc()
9018 if (phba->brd_no < 0) { in lpfc_hba_alloc()
9022 phba->eratt_poll_interval = LPFC_ERATT_POLL_INTERVAL; in lpfc_hba_alloc()
9024 spin_lock_init(&phba->ct_ev_lock); in lpfc_hba_alloc()
9025 INIT_LIST_HEAD(&phba->ct_ev_waiters); in lpfc_hba_alloc()
9031 * lpfc_hba_free - Free driver hba data structure with a device.
9040 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_hba_free()
9041 kfree(phba->sli4_hba.hdwq); in lpfc_hba_free()
9044 idr_remove(&lpfc_hba_index, phba->brd_no); in lpfc_hba_free()
9047 kfree(phba->sli.sli3_ring); in lpfc_hba_free()
9048 phba->sli.sli3_ring = NULL; in lpfc_hba_free()
9055 * lpfc_setup_fdmi_mask - Setup initial FDMI mask for HBA and Port attributes
9061 * fallback hierarchy is SmartSAN -> FDMI2 -> FMDI1
9066 struct lpfc_hba *phba = vport->phba; in lpfc_setup_fdmi_mask()
9068 set_bit(FC_ALLOW_FDMI, &vport->load_flag); in lpfc_setup_fdmi_mask()
9069 if (phba->cfg_enable_SmartSAN || in lpfc_setup_fdmi_mask()
9070 phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT) { in lpfc_setup_fdmi_mask()
9072 vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR; in lpfc_setup_fdmi_mask()
9073 if (phba->cfg_enable_SmartSAN) in lpfc_setup_fdmi_mask()
9074 vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR; in lpfc_setup_fdmi_mask()
9076 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR; in lpfc_setup_fdmi_mask()
9081 vport->fdmi_hba_mask, vport->fdmi_port_mask); in lpfc_setup_fdmi_mask()
9085 * lpfc_create_shost - Create hba physical port with associated scsi host.
9092 * 0 - successful
9093 * other values - error
9102 phba->fc_edtov = FF_DEF_EDTOV; in lpfc_create_shost()
9103 phba->fc_ratov = FF_DEF_RATOV; in lpfc_create_shost()
9104 phba->fc_altov = FF_DEF_ALTOV; in lpfc_create_shost()
9105 phba->fc_arbtov = FF_DEF_ARBTOV; in lpfc_create_shost()
9107 atomic_set(&phba->sdev_cnt, 0); in lpfc_create_shost()
9108 vport = lpfc_create_port(phba, phba->brd_no, &phba->pcidev->dev); in lpfc_create_shost()
9110 return -ENODEV; in lpfc_create_shost()
9113 phba->pport = vport; in lpfc_create_shost()
9115 if (phba->nvmet_support) { in lpfc_create_shost()
9117 phba->targetport = NULL; in lpfc_create_shost()
9118 phba->cfg_enable_fc4_type = LPFC_ENABLE_NVME; in lpfc_create_shost()
9125 pci_set_drvdata(phba->pcidev, shost); in lpfc_create_shost()
9137 * lpfc_destroy_shost - Destroy hba physical port with associated scsi host.
9146 struct lpfc_vport *vport = phba->pport; in lpfc_destroy_shost()
9155 * lpfc_setup_bg - Setup Block guard structures and debug areas.
9168 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
9173 old_mask = phba->cfg_prot_mask; in lpfc_setup_bg()
9174 old_guard = phba->cfg_prot_guard; in lpfc_setup_bg()
9177 phba->cfg_prot_mask &= (SHOST_DIF_TYPE1_PROTECTION | in lpfc_setup_bg()
9180 phba->cfg_prot_guard &= (SHOST_DIX_GUARD_IP | in lpfc_setup_bg()
9184 if (phba->cfg_prot_mask == SHOST_DIX_TYPE1_PROTECTION) in lpfc_setup_bg()
9185 phba->cfg_prot_mask |= SHOST_DIF_TYPE1_PROTECTION; in lpfc_setup_bg()
9187 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
9188 if ((old_mask != phba->cfg_prot_mask) || in lpfc_setup_bg()
9189 (old_guard != phba->cfg_prot_guard)) in lpfc_setup_bg()
9193 phba->cfg_prot_mask, in lpfc_setup_bg()
9194 phba->cfg_prot_guard); in lpfc_setup_bg()
9196 scsi_host_set_prot(shost, phba->cfg_prot_mask); in lpfc_setup_bg()
9197 scsi_host_set_guard(shost, phba->cfg_prot_guard); in lpfc_setup_bg()
9207 * lpfc_post_init_setup - Perform necessary device post initialization setup.
9220 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_post_init_setup()
9226 shost = pci_get_drvdata(phba->pcidev); in lpfc_post_init_setup()
9227 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_post_init_setup()
9231 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_post_init_setup()
9232 spin_lock_irq(shost->host_lock); in lpfc_post_init_setup()
9234 spin_unlock_irq(shost->host_lock); in lpfc_post_init_setup()
9250 * lpfc_sli_pci_mem_setup - Setup SLI3 HBA PCI memory space.
9254 * with SLI-3 interface spec.
9257 * 0 - successful
9258 * other values - error
9263 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_pci_mem_setup()
9270 return -ENODEV; in lpfc_sli_pci_mem_setup()
9273 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli_pci_mem_setup()
9275 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli_pci_mem_setup()
9278 error = -ENODEV; in lpfc_sli_pci_mem_setup()
9283 phba->pci_bar0_map = pci_resource_start(pdev, 0); in lpfc_sli_pci_mem_setup()
9286 phba->pci_bar2_map = pci_resource_start(pdev, 2); in lpfc_sli_pci_mem_setup()
9290 phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli_pci_mem_setup()
9291 if (!phba->slim_memmap_p) { in lpfc_sli_pci_mem_setup()
9292 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
9298 phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli_pci_mem_setup()
9299 if (!phba->ctrl_regs_memmap_p) { in lpfc_sli_pci_mem_setup()
9300 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
9305 /* Allocate memory for SLI-2 structures */ in lpfc_sli_pci_mem_setup()
9306 phba->slim2p.virt = dma_alloc_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
9307 &phba->slim2p.phys, GFP_KERNEL); in lpfc_sli_pci_mem_setup()
9308 if (!phba->slim2p.virt) in lpfc_sli_pci_mem_setup()
9311 phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx); in lpfc_sli_pci_mem_setup()
9312 phba->mbox_ext = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
9314 phba->pcb = (phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, pcb)); in lpfc_sli_pci_mem_setup()
9315 phba->IOCBs = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
9318 phba->hbqslimp.virt = dma_alloc_coherent(&pdev->dev, in lpfc_sli_pci_mem_setup()
9320 &phba->hbqslimp.phys, in lpfc_sli_pci_mem_setup()
9322 if (!phba->hbqslimp.virt) in lpfc_sli_pci_mem_setup()
9326 ptr = phba->hbqslimp.virt; in lpfc_sli_pci_mem_setup()
9328 phba->hbqs[i].hbq_virt = ptr; in lpfc_sli_pci_mem_setup()
9329 INIT_LIST_HEAD(&phba->hbqs[i].hbq_buffer_list); in lpfc_sli_pci_mem_setup()
9330 ptr += (lpfc_hbq_defs[i]->entry_count * in lpfc_sli_pci_mem_setup()
9333 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_els_hbq_alloc; in lpfc_sli_pci_mem_setup()
9334 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_els_hbq_free; in lpfc_sli_pci_mem_setup()
9336 memset(phba->hbqslimp.virt, 0, lpfc_sli_hbq_size()); in lpfc_sli_pci_mem_setup()
9338 phba->MBslimaddr = phba->slim_memmap_p; in lpfc_sli_pci_mem_setup()
9339 phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9340 phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9341 phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9342 phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; in lpfc_sli_pci_mem_setup()
9347 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
9348 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_setup()
9350 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_setup()
9352 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_setup()
9358 * lpfc_sli_pci_mem_unset - Unset SLI3 HBA PCI memory space.
9362 * with SLI-3 interface spec.
9370 if (!phba->pcidev) in lpfc_sli_pci_mem_unset()
9373 pdev = phba->pcidev; in lpfc_sli_pci_mem_unset()
9376 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_sli_pci_mem_unset()
9377 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_sli_pci_mem_unset()
9378 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_unset()
9379 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_unset()
9382 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_unset()
9383 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_unset()
9389 * lpfc_sli4_post_status_check - Wait for SLI4 POST done and check status
9395 * Return 0 if successful, otherwise -ENODEV.
9407 if (!phba->sli4_hba.PSMPHRregaddr) in lpfc_sli4_post_status_check()
9408 return -ENODEV; in lpfc_sli4_post_status_check()
9412 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_sli4_post_status_check()
9416 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9431 "1408 Port Failed POST - portsmphr=0x%x, " in lpfc_sli4_post_status_check()
9449 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9451 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9453 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9455 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9457 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
9459 &phba->sli4_hba.sli_intf)); in lpfc_sli4_post_status_check()
9466 &phba->sli4_hba.sli_intf); in lpfc_sli4_post_status_check()
9469 phba->sli4_hba.ue_mask_lo = in lpfc_sli4_post_status_check()
9470 readl(phba->sli4_hba.u.if_type0.UEMASKLOregaddr); in lpfc_sli4_post_status_check()
9471 phba->sli4_hba.ue_mask_hi = in lpfc_sli4_post_status_check()
9472 readl(phba->sli4_hba.u.if_type0.UEMASKHIregaddr); in lpfc_sli4_post_status_check()
9474 readl(phba->sli4_hba.u.if_type0.UERRLOregaddr); in lpfc_sli4_post_status_check()
9476 readl(phba->sli4_hba.u.if_type0.UERRHIregaddr); in lpfc_sli4_post_status_check()
9477 if ((~phba->sli4_hba.ue_mask_lo & uerrlo_reg.word0) || in lpfc_sli4_post_status_check()
9478 (~phba->sli4_hba.ue_mask_hi & uerrhi_reg.word0)) { in lpfc_sli4_post_status_check()
9489 phba->sli4_hba.ue_mask_lo, in lpfc_sli4_post_status_check()
9490 phba->sli4_hba.ue_mask_hi); in lpfc_sli4_post_status_check()
9491 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9497 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_post_status_check()
9500 phba->work_status[0] = in lpfc_sli4_post_status_check()
9501 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
9503 phba->work_status[1] = in lpfc_sli4_post_status_check()
9504 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
9513 phba->work_status[0], in lpfc_sli4_post_status_check()
9514 phba->work_status[1]); in lpfc_sli4_post_status_check()
9515 port_error = -ENODEV; in lpfc_sli4_post_status_check()
9521 &phba->sli4_hba.sli_intf) == in lpfc_sli4_post_status_check()
9523 pci_write_config_byte(phba->pcidev, in lpfc_sli4_post_status_check()
9535 * lpfc_sli4_bar0_register_memmap - Set up SLI4 BAR0 register memory map.
9547 phba->sli4_hba.u.if_type0.UERRLOregaddr = in lpfc_sli4_bar0_register_memmap()
9548 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_LO; in lpfc_sli4_bar0_register_memmap()
9549 phba->sli4_hba.u.if_type0.UERRHIregaddr = in lpfc_sli4_bar0_register_memmap()
9550 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_HI; in lpfc_sli4_bar0_register_memmap()
9551 phba->sli4_hba.u.if_type0.UEMASKLOregaddr = in lpfc_sli4_bar0_register_memmap()
9552 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_LO; in lpfc_sli4_bar0_register_memmap()
9553 phba->sli4_hba.u.if_type0.UEMASKHIregaddr = in lpfc_sli4_bar0_register_memmap()
9554 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_HI; in lpfc_sli4_bar0_register_memmap()
9555 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
9556 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
9559 phba->sli4_hba.u.if_type2.EQDregaddr = in lpfc_sli4_bar0_register_memmap()
9560 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9562 phba->sli4_hba.u.if_type2.ERR1regaddr = in lpfc_sli4_bar0_register_memmap()
9563 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9565 phba->sli4_hba.u.if_type2.ERR2regaddr = in lpfc_sli4_bar0_register_memmap()
9566 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9568 phba->sli4_hba.u.if_type2.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
9569 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9571 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
9572 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9574 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
9575 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
9576 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
9577 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9579 phba->sli4_hba.RQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9580 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9582 phba->sli4_hba.WQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9583 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9585 phba->sli4_hba.CQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9586 phba->sli4_hba.conf_regs_memmap_p + LPFC_EQCQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
9587 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar0_register_memmap()
9588 phba->sli4_hba.MQDBregaddr = in lpfc_sli4_bar0_register_memmap()
9589 phba->sli4_hba.conf_regs_memmap_p + LPFC_MQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
9590 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
9591 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
9594 phba->sli4_hba.u.if_type2.EQDregaddr = 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.ERR1regaddr = 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.ERR2regaddr = 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.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
9604 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9606 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
9607 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9609 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
9610 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
9612 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
9613 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
9617 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_bar0_register_memmap()
9618 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar0_register_memmap()
9625 * lpfc_sli4_bar1_register_memmap - Set up SLI4 BAR1 register memory map.
9636 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar1_register_memmap()
9637 phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9639 phba->sli4_hba.ISRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9641 phba->sli4_hba.IMRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9643 phba->sli4_hba.ISCRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9647 phba->sli4_hba.RQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9649 phba->sli4_hba.WQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9651 phba->sli4_hba.CQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9653 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9655 phba->sli4_hba.MQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
9661 dev_err(&phba->pcidev->dev, in lpfc_sli4_bar1_register_memmap()
9662 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar1_register_memmap()
9669 * lpfc_sli4_bar2_register_memmap - Set up SLI4 BAR2 register memory map.
9676 * Return 0 if successful, otherwise -ENODEV.
9682 return -ENODEV; in lpfc_sli4_bar2_register_memmap()
9684 phba->sli4_hba.RQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9687 phba->sli4_hba.WQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9690 phba->sli4_hba.CQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9693 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar2_register_memmap()
9694 phba->sli4_hba.MQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9696 phba->sli4_hba.BMBXregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
9702 * lpfc_create_bootstrap_mbox - Create the bootstrap mailbox
9706 * region consistent with the SLI-4 interface spec. This
9713 * 0 - successful
9714 * -ENOMEM - could not allocated memory.
9727 return -ENOMEM; in lpfc_create_bootstrap_mbox()
9733 bmbx_size = sizeof(struct lpfc_bmbx_create) + (LPFC_ALIGN_16_BYTE - 1); in lpfc_create_bootstrap_mbox()
9734 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, bmbx_size, in lpfc_create_bootstrap_mbox()
9735 &dmabuf->phys, GFP_KERNEL); in lpfc_create_bootstrap_mbox()
9736 if (!dmabuf->virt) { in lpfc_create_bootstrap_mbox()
9738 return -ENOMEM; in lpfc_create_bootstrap_mbox()
9744 * to be 16-byte aligned. Also align the virtual memory as each in lpfc_create_bootstrap_mbox()
9748 phba->sli4_hba.bmbx.dmabuf = dmabuf; in lpfc_create_bootstrap_mbox()
9749 phba->sli4_hba.bmbx.bmbx_size = bmbx_size; in lpfc_create_bootstrap_mbox()
9751 phba->sli4_hba.bmbx.avirt = PTR_ALIGN(dmabuf->virt, in lpfc_create_bootstrap_mbox()
9753 phba->sli4_hba.bmbx.aphys = ALIGN(dmabuf->phys, in lpfc_create_bootstrap_mbox()
9759 * as two 30-bit addresses. The other data is a bit marking whether in lpfc_create_bootstrap_mbox()
9760 * the 30-bit address is the high or low address. in lpfc_create_bootstrap_mbox()
9764 dma_address = &phba->sli4_hba.bmbx.dma_address; in lpfc_create_bootstrap_mbox()
9765 phys_addr = (uint64_t)phba->sli4_hba.bmbx.aphys; in lpfc_create_bootstrap_mbox()
9767 dma_address->addr_hi = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
9770 pa_addr = (uint32_t) ((phba->sli4_hba.bmbx.aphys >> 4) & 0x3fffffff); in lpfc_create_bootstrap_mbox()
9771 dma_address->addr_lo = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
9777 * lpfc_destroy_bootstrap_mbox - Destroy all bootstrap mailbox resources
9790 dma_free_coherent(&phba->pcidev->dev, in lpfc_destroy_bootstrap_mbox()
9791 phba->sli4_hba.bmbx.bmbx_size, in lpfc_destroy_bootstrap_mbox()
9792 phba->sli4_hba.bmbx.dmabuf->virt, in lpfc_destroy_bootstrap_mbox()
9793 phba->sli4_hba.bmbx.dmabuf->phys); in lpfc_destroy_bootstrap_mbox()
9795 kfree(phba->sli4_hba.bmbx.dmabuf); in lpfc_destroy_bootstrap_mbox()
9796 memset(&phba->sli4_hba.bmbx, 0, sizeof(struct lpfc_bmbx)); in lpfc_destroy_bootstrap_mbox()
9813 * lpfc_map_topology - Map the topology read from READ_CONFIG
9838 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9841 /* FW supports persistent topology - override module parameter value */ in lpfc_map_topology()
9842 set_bit(HBA_PERSISTENT_TOPO, &phba->hba_flag); in lpfc_map_topology()
9845 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_map_topology()
9847 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_map_topology()
9850 phba->cfg_topology = ((pt == LINK_FLAGS_LOOP) in lpfc_map_topology()
9854 clear_bit(HBA_PERSISTENT_TOPO, &phba->hba_flag); in lpfc_map_topology()
9857 /* If topology failover set - pt is '0' or '1' */ in lpfc_map_topology()
9858 phba->cfg_topology = (pt ? FLAGS_TOPOLOGY_MODE_PT_LOOP : in lpfc_map_topology()
9861 phba->cfg_topology = ((pt == LINK_FLAGS_P2P) in lpfc_map_topology()
9865 if (test_bit(HBA_PERSISTENT_TOPO, &phba->hba_flag)) in lpfc_map_topology()
9868 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9873 lpfc_topo_to_str[phba->cfg_topology]); in lpfc_map_topology()
9877 * lpfc_sli4_read_config - Get the config parameters.
9886 * 0 - successful
9887 * -ENOMEM - No available memory
9888 * -EIO - The mailbox failed to complete successfully.
9904 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_read_config()
9909 return -ENOMEM; in lpfc_sli4_read_config()
9919 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
9920 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
9921 rc = -EIO; in lpfc_sli4_read_config()
9923 rd_config = &pmb->u.mqe.un.rd_config; in lpfc_sli4_read_config()
9925 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_VAL; in lpfc_sli4_read_config()
9926 phba->sli4_hba.lnk_info.lnk_tp = in lpfc_sli4_read_config()
9928 phba->sli4_hba.lnk_info.lnk_no = in lpfc_sli4_read_config()
9932 phba->sli4_hba.lnk_info.lnk_tp, in lpfc_sli4_read_config()
9933 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_read_config()
9937 bf_get(lpfc_mqe_command, &pmb->u.mqe)); in lpfc_sli4_read_config()
9939 phba->bbcredit_support = 1; in lpfc_sli4_read_config()
9940 phba->sli4_hba.bbscn_params.word0 = rd_config->word8; in lpfc_sli4_read_config()
9948 "2702 READ_CONFIG: FA-PWWN is " in lpfc_sli4_read_config()
9950 phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_CONFIG; in lpfc_sli4_read_config()
9953 phba->sli4_hba.fawwpn_flag &= ~LPFC_FAWWPN_CONFIG; in lpfc_sli4_read_config()
9956 phba->sli4_hba.conf_trunk = in lpfc_sli4_read_config()
9958 phba->sli4_hba.extents_in_use = in lpfc_sli4_read_config()
9961 phba->sli4_hba.max_cfg_param.max_xri = in lpfc_sli4_read_config()
9965 phba->sli4_hba.max_cfg_param.max_xri > 512) in lpfc_sli4_read_config()
9966 phba->sli4_hba.max_cfg_param.max_xri = 512; in lpfc_sli4_read_config()
9967 phba->sli4_hba.max_cfg_param.xri_base = in lpfc_sli4_read_config()
9969 phba->sli4_hba.max_cfg_param.max_vpi = in lpfc_sli4_read_config()
9972 if (phba->sli4_hba.max_cfg_param.max_vpi > LPFC_MAX_VPORTS) in lpfc_sli4_read_config()
9973 phba->sli4_hba.max_cfg_param.max_vpi = LPFC_MAX_VPORTS; in lpfc_sli4_read_config()
9974 phba->sli4_hba.max_cfg_param.vpi_base = in lpfc_sli4_read_config()
9976 phba->sli4_hba.max_cfg_param.max_rpi = in lpfc_sli4_read_config()
9978 phba->sli4_hba.max_cfg_param.rpi_base = in lpfc_sli4_read_config()
9980 phba->sli4_hba.max_cfg_param.max_vfi = in lpfc_sli4_read_config()
9982 phba->sli4_hba.max_cfg_param.vfi_base = in lpfc_sli4_read_config()
9984 phba->sli4_hba.max_cfg_param.max_fcfi = in lpfc_sli4_read_config()
9986 phba->sli4_hba.max_cfg_param.max_eq = in lpfc_sli4_read_config()
9988 phba->sli4_hba.max_cfg_param.max_rq = in lpfc_sli4_read_config()
9990 phba->sli4_hba.max_cfg_param.max_wq = in lpfc_sli4_read_config()
9992 phba->sli4_hba.max_cfg_param.max_cq = in lpfc_sli4_read_config()
9994 phba->lmt = bf_get(lpfc_mbx_rd_conf_lmt, rd_config); in lpfc_sli4_read_config()
9995 phba->sli4_hba.next_xri = phba->sli4_hba.max_cfg_param.xri_base; in lpfc_sli4_read_config()
9996 phba->vpi_base = phba->sli4_hba.max_cfg_param.vpi_base; in lpfc_sli4_read_config()
9997 phba->vfi_base = phba->sli4_hba.max_cfg_param.vfi_base; in lpfc_sli4_read_config()
9998 phba->max_vpi = (phba->sli4_hba.max_cfg_param.max_vpi > 0) ? in lpfc_sli4_read_config()
9999 (phba->sli4_hba.max_cfg_param.max_vpi - 1) : 0; in lpfc_sli4_read_config()
10000 phba->max_vports = phba->max_vpi; in lpfc_sli4_read_config()
10011 phba->cgn_reg_fpin = LPFC_CGN_FPIN_BOTH; in lpfc_sli4_read_config()
10012 phba->cgn_reg_signal = EDC_CG_SIG_NOTSUPPORTED; in lpfc_sli4_read_config()
10013 phba->cgn_sig_freq = lpfc_fabric_cgn_frequency; in lpfc_sli4_read_config()
10017 phba->cgn_reg_signal = EDC_CG_SIG_WARN_ONLY; in lpfc_sli4_read_config()
10018 phba->cgn_reg_fpin &= ~LPFC_CGN_FPIN_WARN; in lpfc_sli4_read_config()
10024 if (phba->cgn_reg_signal != in lpfc_sli4_read_config()
10027 phba->cgn_reg_fpin = LPFC_CGN_FPIN_BOTH; in lpfc_sli4_read_config()
10028 phba->cgn_reg_signal = in lpfc_sli4_read_config()
10031 phba->cgn_reg_signal = in lpfc_sli4_read_config()
10033 phba->cgn_reg_fpin = in lpfc_sli4_read_config()
10040 phba->cgn_init_reg_fpin = phba->cgn_reg_fpin; in lpfc_sli4_read_config()
10041 phba->cgn_init_reg_signal = phba->cgn_reg_signal; in lpfc_sli4_read_config()
10045 phba->cgn_reg_signal, phba->cgn_reg_fpin); in lpfc_sli4_read_config()
10055 phba->sli4_hba.extents_in_use, in lpfc_sli4_read_config()
10056 phba->sli4_hba.max_cfg_param.xri_base, in lpfc_sli4_read_config()
10057 phba->sli4_hba.max_cfg_param.max_xri, in lpfc_sli4_read_config()
10058 phba->sli4_hba.max_cfg_param.vpi_base, in lpfc_sli4_read_config()
10059 phba->sli4_hba.max_cfg_param.max_vpi, in lpfc_sli4_read_config()
10060 phba->sli4_hba.max_cfg_param.vfi_base, in lpfc_sli4_read_config()
10061 phba->sli4_hba.max_cfg_param.max_vfi, in lpfc_sli4_read_config()
10062 phba->sli4_hba.max_cfg_param.rpi_base, in lpfc_sli4_read_config()
10063 phba->sli4_hba.max_cfg_param.max_rpi, in lpfc_sli4_read_config()
10064 phba->sli4_hba.max_cfg_param.max_fcfi, in lpfc_sli4_read_config()
10065 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
10066 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
10067 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
10068 phba->sli4_hba.max_cfg_param.max_rq, in lpfc_sli4_read_config()
10069 phba->lmt); in lpfc_sli4_read_config()
10075 qmin = phba->sli4_hba.max_cfg_param.max_wq; in lpfc_sli4_read_config()
10076 if (phba->sli4_hba.max_cfg_param.max_cq < qmin) in lpfc_sli4_read_config()
10077 qmin = phba->sli4_hba.max_cfg_param.max_cq; in lpfc_sli4_read_config()
10082 qmin -= 4; in lpfc_sli4_read_config()
10083 if (phba->sli4_hba.max_cfg_param.max_eq < qmin) in lpfc_sli4_read_config()
10084 qmin = phba->sli4_hba.max_cfg_param.max_eq; in lpfc_sli4_read_config()
10087 if ((phba->cfg_irq_chann > qmin) || in lpfc_sli4_read_config()
10088 (phba->cfg_hdw_queue > qmin)) { in lpfc_sli4_read_config()
10090 "2005 Reducing Queues - " in lpfc_sli4_read_config()
10094 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
10095 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
10096 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
10097 qmin, phba->cfg_irq_chann, in lpfc_sli4_read_config()
10098 phba->cfg_hdw_queue); in lpfc_sli4_read_config()
10100 if (phba->cfg_irq_chann > qmin) in lpfc_sli4_read_config()
10101 phba->cfg_irq_chann = qmin; in lpfc_sli4_read_config()
10102 if (phba->cfg_hdw_queue > qmin) in lpfc_sli4_read_config()
10103 phba->cfg_hdw_queue = qmin; in lpfc_sli4_read_config()
10111 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_read_config()
10116 set_bit(HBA_FORCED_LINK_SPEED, &phba->hba_flag); in lpfc_sli4_read_config()
10120 phba->cfg_link_speed = in lpfc_sli4_read_config()
10124 phba->cfg_link_speed = in lpfc_sli4_read_config()
10128 phba->cfg_link_speed = in lpfc_sli4_read_config()
10132 phba->cfg_link_speed = in lpfc_sli4_read_config()
10136 phba->cfg_link_speed = in lpfc_sli4_read_config()
10140 phba->cfg_link_speed = in lpfc_sli4_read_config()
10144 phba->cfg_link_speed = in lpfc_sli4_read_config()
10148 phba->cfg_link_speed = in lpfc_sli4_read_config()
10152 phba->cfg_link_speed = in lpfc_sli4_read_config()
10161 phba->cfg_link_speed = in lpfc_sli4_read_config()
10168 length = phba->sli4_hba.max_cfg_param.max_xri - in lpfc_sli4_read_config()
10170 if (phba->cfg_hba_queue_depth > length) { in lpfc_sli4_read_config()
10173 phba->cfg_hba_queue_depth, length); in lpfc_sli4_read_config()
10174 phba->cfg_hba_queue_depth = length; in lpfc_sli4_read_config()
10177 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_read_config()
10182 length = (sizeof(struct lpfc_mbx_get_func_cfg) - in lpfc_sli4_read_config()
10190 &pmb->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_read_config()
10191 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_read_config()
10192 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_read_config()
10197 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
10198 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
10203 get_func_cfg = &pmb->u.mqe.un.get_func_cfg; in lpfc_sli4_read_config()
10205 pdesc_0 = (char *)&get_func_cfg->func_cfg.desc[0]; in lpfc_sli4_read_config()
10217 phba->sli4_hba.iov.pf_number = in lpfc_sli4_read_config()
10219 phba->sli4_hba.iov.vf_number = in lpfc_sli4_read_config()
10228 "vf_number:%d\n", phba->sli4_hba.iov.pf_number, in lpfc_sli4_read_config()
10229 phba->sli4_hba.iov.vf_number); in lpfc_sli4_read_config()
10237 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_read_config()
10242 * lpfc_setup_endian_order - Write endian order to an SLI4 if_type 0 port.
10245 * This routine is invoked to setup the port-side endian order when
10250 * 0 - successful
10251 * -ENOMEM - No available memory
10252 * -EIO - The mailbox failed to complete successfully.
10262 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_setup_endian_order()
10265 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_setup_endian_order()
10272 return -ENOMEM; in lpfc_setup_endian_order()
10280 memcpy(&mboxq->u.mqe, &endian_mb_data, sizeof(endian_mb_data)); in lpfc_setup_endian_order()
10287 rc = -EIO; in lpfc_setup_endian_order()
10289 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_setup_endian_order()
10301 * lpfc_sli4_queue_verify - Verify and update EQ counts
10310 * 0 - successful
10311 * -ENOMEM - No available memory
10317 * Sanity check for configured queue parameters against the run-time in lpfc_sli4_queue_verify()
10321 if (phba->nvmet_support) { in lpfc_sli4_queue_verify()
10322 if (phba->cfg_hdw_queue < phba->cfg_nvmet_mrq) in lpfc_sli4_queue_verify()
10323 phba->cfg_nvmet_mrq = phba->cfg_hdw_queue; in lpfc_sli4_queue_verify()
10324 if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX) in lpfc_sli4_queue_verify()
10325 phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX; in lpfc_sli4_queue_verify()
10330 phba->cfg_hdw_queue, phba->cfg_irq_chann, in lpfc_sli4_queue_verify()
10331 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_verify()
10334 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_verify()
10335 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_verify()
10338 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_verify()
10339 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_verify()
10352 if (phba->enab_exp_wqcq_pages) in lpfc_alloc_io_wq_cq()
10355 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
10360 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
10361 phba->sli4_hba.cq_ecount, cpu); in lpfc_alloc_io_wq_cq()
10364 "0499 Failed allocate fast-path IO CQ (%d)\n", in lpfc_alloc_io_wq_cq()
10368 qdesc->qe_valid = 1; in lpfc_alloc_io_wq_cq()
10369 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
10370 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
10371 phba->sli4_hba.hdwq[idx].io_cq = qdesc; in lpfc_alloc_io_wq_cq()
10374 if (phba->enab_exp_wqcq_pages) { in lpfc_alloc_io_wq_cq()
10376 wqesize = (phba->fcp_embed_io) ? in lpfc_alloc_io_wq_cq()
10377 LPFC_WQE128_SIZE : phba->sli4_hba.wq_esize; in lpfc_alloc_io_wq_cq()
10383 phba->sli4_hba.wq_esize, in lpfc_alloc_io_wq_cq()
10384 phba->sli4_hba.wq_ecount, cpu); in lpfc_alloc_io_wq_cq()
10388 "0503 Failed allocate fast-path IO WQ (%d)\n", in lpfc_alloc_io_wq_cq()
10392 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
10393 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
10394 phba->sli4_hba.hdwq[idx].io_wq = qdesc; in lpfc_alloc_io_wq_cq()
10395 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_alloc_io_wq_cq()
10400 * lpfc_sli4_queue_create - Create all the SLI4 queues
10409 * 0 - successful
10410 * -ENOMEM - No availble memory
10411 * -EIO - The mailbox failed to complete successfully.
10428 phba->sli4_hba.mq_esize = LPFC_MQE_SIZE; in lpfc_sli4_queue_create()
10429 phba->sli4_hba.mq_ecount = LPFC_MQE_DEF_COUNT; in lpfc_sli4_queue_create()
10430 phba->sli4_hba.wq_esize = LPFC_WQE_SIZE; in lpfc_sli4_queue_create()
10431 phba->sli4_hba.wq_ecount = LPFC_WQE_DEF_COUNT; in lpfc_sli4_queue_create()
10432 phba->sli4_hba.rq_esize = LPFC_RQE_SIZE; in lpfc_sli4_queue_create()
10433 phba->sli4_hba.rq_ecount = LPFC_RQE_DEF_COUNT; in lpfc_sli4_queue_create()
10434 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_create()
10435 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_create()
10436 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_create()
10437 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_create()
10439 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
10440 phba->sli4_hba.hdwq = kcalloc( in lpfc_sli4_queue_create()
10441 phba->cfg_hdw_queue, sizeof(struct lpfc_sli4_hdw_queue), in lpfc_sli4_queue_create()
10443 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
10446 "fast-path Hardware Queue array\n"); in lpfc_sli4_queue_create()
10450 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10451 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_queue_create()
10452 spin_lock_init(&qp->io_buf_list_get_lock); in lpfc_sli4_queue_create()
10453 spin_lock_init(&qp->io_buf_list_put_lock); in lpfc_sli4_queue_create()
10454 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_sli4_queue_create()
10455 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_sli4_queue_create()
10456 qp->get_io_bufs = 0; in lpfc_sli4_queue_create()
10457 qp->put_io_bufs = 0; in lpfc_sli4_queue_create()
10458 qp->total_io_bufs = 0; in lpfc_sli4_queue_create()
10459 spin_lock_init(&qp->abts_io_buf_list_lock); in lpfc_sli4_queue_create()
10460 INIT_LIST_HEAD(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_queue_create()
10461 qp->abts_scsi_io_bufs = 0; in lpfc_sli4_queue_create()
10462 qp->abts_nvme_io_bufs = 0; in lpfc_sli4_queue_create()
10463 INIT_LIST_HEAD(&qp->sgl_list); in lpfc_sli4_queue_create()
10464 INIT_LIST_HEAD(&qp->cmd_rsp_buf_list); in lpfc_sli4_queue_create()
10465 spin_lock_init(&qp->hdwq_lock); in lpfc_sli4_queue_create()
10469 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10470 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
10471 phba->sli4_hba.nvmet_cqset = kcalloc( in lpfc_sli4_queue_create()
10472 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10475 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_create()
10478 "fast-path CQ set array\n"); in lpfc_sli4_queue_create()
10481 phba->sli4_hba.nvmet_mrq_hdr = kcalloc( in lpfc_sli4_queue_create()
10482 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10485 if (!phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_create()
10488 "fast-path RQ set hdr array\n"); in lpfc_sli4_queue_create()
10491 phba->sli4_hba.nvmet_mrq_data = kcalloc( in lpfc_sli4_queue_create()
10492 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
10495 if (!phba->sli4_hba.nvmet_mrq_data) { in lpfc_sli4_queue_create()
10498 "fast-path RQ set data array\n"); in lpfc_sli4_queue_create()
10504 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10512 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
10513 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_create()
10517 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
10521 phba->sli4_hba.eq_esize, in lpfc_sli4_queue_create()
10522 phba->sli4_hba.eq_ecount, cpu); in lpfc_sli4_queue_create()
10526 cpup->hdwq); in lpfc_sli4_queue_create()
10529 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10530 qdesc->hdwq = cpup->hdwq; in lpfc_sli4_queue_create()
10531 qdesc->chann = cpu; /* First CPU this EQ is affinitized to */ in lpfc_sli4_queue_create()
10532 qdesc->last_cpu = qdesc->chann; in lpfc_sli4_queue_create()
10535 qp->hba_eq = qdesc; in lpfc_sli4_queue_create()
10537 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, qdesc->last_cpu); in lpfc_sli4_queue_create()
10538 list_add(&qdesc->cpu_list, &eqi->list); in lpfc_sli4_queue_create()
10545 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
10548 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_sli4_queue_create()
10552 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
10553 if (qp->hba_eq) in lpfc_sli4_queue_create()
10557 eqcpu = lpfc_find_cpu_handle(phba, cpup->eq, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
10558 eqcpup = &phba->sli4_hba.cpu_map[eqcpu]; in lpfc_sli4_queue_create()
10559 qp->hba_eq = phba->sli4_hba.hdwq[eqcpup->hdwq].hba_eq; in lpfc_sli4_queue_create()
10563 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10568 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
10569 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
10574 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10575 phba->sli4_hba.cq_ecount, in lpfc_sli4_queue_create()
10583 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10584 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10585 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10586 phba->sli4_hba.nvmet_cqset[idx] = qdesc; in lpfc_sli4_queue_create()
10595 /* Create slow-path Mailbox Command Complete Queue */ in lpfc_sli4_queue_create()
10597 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10598 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10601 "0500 Failed allocate slow-path mailbox CQ\n"); in lpfc_sli4_queue_create()
10604 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10605 phba->sli4_hba.mbx_cq = qdesc; in lpfc_sli4_queue_create()
10607 /* Create slow-path ELS Complete Queue */ in lpfc_sli4_queue_create()
10609 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10610 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10613 "0501 Failed allocate slow-path ELS CQ\n"); in lpfc_sli4_queue_create()
10616 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10617 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10618 phba->sli4_hba.els_cq = qdesc; in lpfc_sli4_queue_create()
10628 phba->sli4_hba.mq_esize, in lpfc_sli4_queue_create()
10629 phba->sli4_hba.mq_ecount, cpu); in lpfc_sli4_queue_create()
10632 "0505 Failed allocate slow-path MQ\n"); in lpfc_sli4_queue_create()
10635 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10636 phba->sli4_hba.mbx_wq = qdesc; in lpfc_sli4_queue_create()
10643 * Create slow-path ELS Work Queue. in lpfc_sli4_queue_create()
10646 wqesize = (phba->fcp_embed_io) ? in lpfc_sli4_queue_create()
10647 LPFC_WQE128_SIZE : phba->sli4_hba.wq_esize; in lpfc_sli4_queue_create()
10651 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
10654 "0504 Failed allocate slow-path ELS WQ\n"); in lpfc_sli4_queue_create()
10657 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10658 phba->sli4_hba.els_wq = qdesc; in lpfc_sli4_queue_create()
10659 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10661 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10664 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
10665 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
10671 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10672 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
10673 phba->sli4_hba.nvmels_cq = qdesc; in lpfc_sli4_queue_create()
10677 phba->sli4_hba.wq_esize, in lpfc_sli4_queue_create()
10678 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
10684 qdesc->chann = cpu; in lpfc_sli4_queue_create()
10685 phba->sli4_hba.nvmels_wq = qdesc; in lpfc_sli4_queue_create()
10686 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
10695 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10696 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
10702 phba->sli4_hba.hdr_rq = qdesc; in lpfc_sli4_queue_create()
10706 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10707 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
10713 phba->sli4_hba.dat_rq = qdesc; in lpfc_sli4_queue_create()
10715 if ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) && in lpfc_sli4_queue_create()
10716 phba->nvmet_support) { in lpfc_sli4_queue_create()
10717 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
10723 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10732 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10733 phba->sli4_hba.nvmet_mrq_hdr[idx] = qdesc; in lpfc_sli4_queue_create()
10736 qdesc->rqbp = kzalloc_node(sizeof(*qdesc->rqbp), in lpfc_sli4_queue_create()
10739 if (qdesc->rqbp == NULL) { in lpfc_sli4_queue_create()
10747 INIT_LIST_HEAD(&qdesc->rqbp->rqb_buffer_list); in lpfc_sli4_queue_create()
10752 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
10761 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
10762 phba->sli4_hba.nvmet_mrq_data[idx] = qdesc; in lpfc_sli4_queue_create()
10767 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
10768 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10769 memset(&phba->sli4_hba.hdwq[idx].nvme_cstat, 0, in lpfc_sli4_queue_create()
10770 sizeof(phba->sli4_hba.hdwq[idx].nvme_cstat)); in lpfc_sli4_queue_create()
10775 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { in lpfc_sli4_queue_create()
10776 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
10777 memset(&phba->sli4_hba.hdwq[idx].scsi_cstat, 0, in lpfc_sli4_queue_create()
10778 sizeof(phba->sli4_hba.hdwq[idx].scsi_cstat)); in lpfc_sli4_queue_create()
10786 return -ENOMEM; in lpfc_sli4_queue_create()
10820 hdwq = phba->sli4_hba.hdwq; in lpfc_sli4_release_hdwq()
10823 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_release_hdwq()
10830 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_release_hdwq()
10835 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_release_hdwq()
10837 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_sli4_release_hdwq()
10839 phba->sli4_hba.hba_eq_hdl[idx].eq = NULL; in lpfc_sli4_release_hdwq()
10844 * lpfc_sli4_queue_destroy - Destroy all the SLI4 queues
10851 * 0 - successful
10852 * -ENOMEM - No available memory
10853 * -EIO - The mailbox failed to complete successfully.
10863 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10864 phba->sli.sli_flag |= LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
10865 while (phba->sli.sli_flag & LPFC_QUEUE_FREE_WAIT) { in lpfc_sli4_queue_destroy()
10866 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10868 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10870 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10875 if (phba->sli4_hba.hdwq) in lpfc_sli4_queue_destroy()
10878 if (phba->nvmet_support) { in lpfc_sli4_queue_destroy()
10879 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_destroy()
10880 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10882 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_destroy()
10883 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10884 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_destroy()
10885 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
10889 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_destroy()
10892 __lpfc_sli4_release_queue(&phba->sli4_hba.els_wq); in lpfc_sli4_queue_destroy()
10895 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_destroy()
10898 __lpfc_sli4_release_queue(&phba->sli4_hba.hdr_rq); in lpfc_sli4_queue_destroy()
10899 __lpfc_sli4_release_queue(&phba->sli4_hba.dat_rq); in lpfc_sli4_queue_destroy()
10902 __lpfc_sli4_release_queue(&phba->sli4_hba.els_cq); in lpfc_sli4_queue_destroy()
10905 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_destroy()
10908 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_destroy()
10911 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_destroy()
10914 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10915 phba->sli.sli_flag &= ~LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
10916 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
10926 rqbp = rq->rqbp; in lpfc_free_rq_buffer()
10927 while (!list_empty(&rqbp->rqb_buffer_list)) { in lpfc_free_rq_buffer()
10928 list_remove_head(&rqbp->rqb_buffer_list, h_buf, in lpfc_free_rq_buffer()
10932 (rqbp->rqb_free_buffer)(phba, rqb_buffer); in lpfc_free_rq_buffer()
10933 rqbp->buffer_count--; in lpfc_free_rq_buffer()
10948 "6085 Fast-path %s (%d) not allocated\n", in lpfc_create_wq_cq()
10950 return -ENOMEM; in lpfc_create_wq_cq()
10966 *cq_map = cq->queue_id; in lpfc_create_wq_cq()
10969 "6087 CQ setup: cq[%d]-id=%d, parent eq[%d]-id=%d\n", in lpfc_create_wq_cq()
10970 qidx, cq->queue_id, qidx, eq->queue_id); in lpfc_create_wq_cq()
10978 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
10983 pring = wq->pring; in lpfc_create_wq_cq()
10984 pring->sli.sli4.wqp = (void *)wq; in lpfc_create_wq_cq()
10985 cq->pring = pring; in lpfc_create_wq_cq()
10988 "2593 WQ setup: wq[%d]-id=%d assoc=%d, cq[%d]-id=%d\n", in lpfc_create_wq_cq()
10989 qidx, wq->queue_id, wq->assoc_qid, qidx, cq->queue_id); in lpfc_create_wq_cq()
10994 "0539 Failed setup of slow-path MQ: " in lpfc_create_wq_cq()
10996 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
11001 "2589 MBX MQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_create_wq_cq()
11002 phba->sli4_hba.mbx_wq->queue_id, in lpfc_create_wq_cq()
11003 phba->sli4_hba.mbx_cq->queue_id); in lpfc_create_wq_cq()
11010 * lpfc_setup_cq_lookup - Setup the CQ lookup table
11022 memset(phba->sli4_hba.cq_lookup, 0, in lpfc_setup_cq_lookup()
11023 (sizeof(struct lpfc_queue *) * (phba->sli4_hba.cq_max + 1))); in lpfc_setup_cq_lookup()
11025 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_setup_cq_lookup()
11027 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_setup_cq_lookup()
11031 list_for_each_entry(childq, &eq->child_list, list) { in lpfc_setup_cq_lookup()
11032 if (childq->queue_id > phba->sli4_hba.cq_max) in lpfc_setup_cq_lookup()
11034 if (childq->subtype == LPFC_IO) in lpfc_setup_cq_lookup()
11035 phba->sli4_hba.cq_lookup[childq->queue_id] = in lpfc_setup_cq_lookup()
11042 * lpfc_sli4_queue_setup - Set up all the SLI4 queues
11049 * 0 - successful
11050 * -ENOMEM - No available memory
11051 * -EIO - The mailbox failed to complete successfully.
11063 int rc = -ENOMEM; in lpfc_sli4_queue_setup()
11065 /* Check for dual-ULP support */ in lpfc_sli4_queue_setup()
11066 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_queue_setup()
11071 return -ENOMEM; in lpfc_sli4_queue_setup()
11073 length = (sizeof(struct lpfc_mbx_query_fw_config) - in lpfc_sli4_queue_setup()
11082 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_queue_setup()
11083 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_queue_setup()
11084 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_queue_setup()
11090 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
11091 rc = -ENXIO; in lpfc_sli4_queue_setup()
11095 phba->sli4_hba.fw_func_mode = in lpfc_sli4_queue_setup()
11096 mboxq->u.mqe.un.query_fw_cfg.rsp.function_mode; in lpfc_sli4_queue_setup()
11097 phba->sli4_hba.physical_port = in lpfc_sli4_queue_setup()
11098 mboxq->u.mqe.un.query_fw_cfg.rsp.physical_port; in lpfc_sli4_queue_setup()
11101 phba->sli4_hba.fw_func_mode); in lpfc_sli4_queue_setup()
11103 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
11108 qp = phba->sli4_hba.hdwq; in lpfc_sli4_queue_setup()
11113 "3147 Fast-path EQs not allocated\n"); in lpfc_sli4_queue_setup()
11114 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11119 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_setup()
11122 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
11127 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_setup()
11129 if (qidx != cpup->eq) in lpfc_sli4_queue_setup()
11133 rc = lpfc_eq_create(phba, qp[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
11134 phba->cfg_fcp_imax); in lpfc_sli4_queue_setup()
11137 "0523 Failed setup of fast-path" in lpfc_sli4_queue_setup()
11139 cpup->eq, (uint32_t)rc); in lpfc_sli4_queue_setup()
11144 phba->sli4_hba.hba_eq_hdl[cpup->eq].eq = in lpfc_sli4_queue_setup()
11145 qp[cpup->hdwq].hba_eq; in lpfc_sli4_queue_setup()
11148 "2584 HBA EQ setup: queue[%d]-id=%d\n", in lpfc_sli4_queue_setup()
11149 cpup->eq, in lpfc_sli4_queue_setup()
11150 qp[cpup->hdwq].hba_eq->queue_id); in lpfc_sli4_queue_setup()
11155 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_setup()
11157 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
11161 phba->sli4_hba.hdwq[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
11164 &phba->sli4_hba.hdwq[qidx].io_cq_map, in lpfc_sli4_queue_setup()
11180 /* Set up slow-path MBOX CQ/MQ */ in lpfc_sli4_queue_setup()
11182 if (!phba->sli4_hba.mbx_cq || !phba->sli4_hba.mbx_wq) { in lpfc_sli4_queue_setup()
11185 phba->sli4_hba.mbx_cq ? in lpfc_sli4_queue_setup()
11187 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11192 phba->sli4_hba.mbx_cq, in lpfc_sli4_queue_setup()
11193 phba->sli4_hba.mbx_wq, in lpfc_sli4_queue_setup()
11201 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
11202 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_setup()
11204 "3165 Fast-path NVME CQ Set " in lpfc_sli4_queue_setup()
11206 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11209 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
11211 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
11223 rc = lpfc_cq_create(phba, phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
11232 phba->sli4_hba.nvmet_cqset[0]->chann = 0; in lpfc_sli4_queue_setup()
11235 "6090 NVMET CQ setup: cq-id=%d, " in lpfc_sli4_queue_setup()
11236 "parent eq-id=%d\n", in lpfc_sli4_queue_setup()
11237 phba->sli4_hba.nvmet_cqset[0]->queue_id, in lpfc_sli4_queue_setup()
11238 qp[0].hba_eq->queue_id); in lpfc_sli4_queue_setup()
11242 /* Set up slow-path ELS WQ/CQ */ in lpfc_sli4_queue_setup()
11243 if (!phba->sli4_hba.els_cq || !phba->sli4_hba.els_wq) { in lpfc_sli4_queue_setup()
11246 phba->sli4_hba.els_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
11247 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11251 phba->sli4_hba.els_cq, in lpfc_sli4_queue_setup()
11252 phba->sli4_hba.els_wq, in lpfc_sli4_queue_setup()
11261 "2590 ELS WQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11262 phba->sli4_hba.els_wq->queue_id, in lpfc_sli4_queue_setup()
11263 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
11265 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_setup()
11267 if (!phba->sli4_hba.nvmels_cq || !phba->sli4_hba.nvmels_wq) { in lpfc_sli4_queue_setup()
11270 phba->sli4_hba.nvmels_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
11271 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11275 phba->sli4_hba.nvmels_cq, in lpfc_sli4_queue_setup()
11276 phba->sli4_hba.nvmels_wq, in lpfc_sli4_queue_setup()
11286 "6096 ELS WQ setup: wq-id=%d, " in lpfc_sli4_queue_setup()
11287 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11288 phba->sli4_hba.nvmels_wq->queue_id, in lpfc_sli4_queue_setup()
11289 phba->sli4_hba.nvmels_cq->queue_id); in lpfc_sli4_queue_setup()
11295 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
11296 if ((!phba->sli4_hba.nvmet_cqset) || in lpfc_sli4_queue_setup()
11297 (!phba->sli4_hba.nvmet_mrq_hdr) || in lpfc_sli4_queue_setup()
11298 (!phba->sli4_hba.nvmet_mrq_data)) { in lpfc_sli4_queue_setup()
11302 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11305 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
11307 phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_setup()
11308 phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_setup()
11309 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
11321 phba->sli4_hba.nvmet_mrq_hdr[0], in lpfc_sli4_queue_setup()
11322 phba->sli4_hba.nvmet_mrq_data[0], in lpfc_sli4_queue_setup()
11323 phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
11335 "6099 NVMET RQ setup: hdr-rq-id=%d, " in lpfc_sli4_queue_setup()
11336 "dat-rq-id=%d parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11337 phba->sli4_hba.nvmet_mrq_hdr[0]->queue_id, in lpfc_sli4_queue_setup()
11338 phba->sli4_hba.nvmet_mrq_data[0]->queue_id, in lpfc_sli4_queue_setup()
11339 phba->sli4_hba.nvmet_cqset[0]->queue_id); in lpfc_sli4_queue_setup()
11344 if (!phba->sli4_hba.hdr_rq || !phba->sli4_hba.dat_rq) { in lpfc_sli4_queue_setup()
11347 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11351 rc = lpfc_rq_create(phba, phba->sli4_hba.hdr_rq, phba->sli4_hba.dat_rq, in lpfc_sli4_queue_setup()
11352 phba->sli4_hba.els_cq, LPFC_USOL); in lpfc_sli4_queue_setup()
11361 "2592 USL RQ setup: hdr-rq-id=%d, dat-rq-id=%d " in lpfc_sli4_queue_setup()
11362 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
11363 phba->sli4_hba.hdr_rq->queue_id, in lpfc_sli4_queue_setup()
11364 phba->sli4_hba.dat_rq->queue_id, in lpfc_sli4_queue_setup()
11365 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
11367 if (phba->cfg_fcp_imax) in lpfc_sli4_queue_setup()
11368 usdelay = LPFC_SEC_TO_USEC / phba->cfg_fcp_imax; in lpfc_sli4_queue_setup()
11372 for (qidx = 0; qidx < phba->cfg_irq_chann; in lpfc_sli4_queue_setup()
11377 if (phba->sli4_hba.cq_max) { in lpfc_sli4_queue_setup()
11378 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_setup()
11379 phba->sli4_hba.cq_lookup = kcalloc((phba->sli4_hba.cq_max + 1), in lpfc_sli4_queue_setup()
11381 if (!phba->sli4_hba.cq_lookup) { in lpfc_sli4_queue_setup()
11384 "size 0x%x\n", phba->sli4_hba.cq_max); in lpfc_sli4_queue_setup()
11385 rc = -ENOMEM; in lpfc_sli4_queue_setup()
11399 * lpfc_sli4_queue_unset - Unset all the SLI4 queues
11406 * 0 - successful
11407 * -ENOMEM - No available memory
11408 * -EIO - The mailbox failed to complete successfully.
11418 if (phba->sli4_hba.mbx_wq) in lpfc_sli4_queue_unset()
11419 lpfc_mq_destroy(phba, phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_unset()
11422 if (phba->sli4_hba.nvmels_wq) in lpfc_sli4_queue_unset()
11423 lpfc_wq_destroy(phba, phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_unset()
11426 if (phba->sli4_hba.els_wq) in lpfc_sli4_queue_unset()
11427 lpfc_wq_destroy(phba, phba->sli4_hba.els_wq); in lpfc_sli4_queue_unset()
11430 if (phba->sli4_hba.hdr_rq) in lpfc_sli4_queue_unset()
11431 lpfc_rq_destroy(phba, phba->sli4_hba.hdr_rq, in lpfc_sli4_queue_unset()
11432 phba->sli4_hba.dat_rq); in lpfc_sli4_queue_unset()
11435 if (phba->sli4_hba.mbx_cq) in lpfc_sli4_queue_unset()
11436 lpfc_cq_destroy(phba, phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_unset()
11439 if (phba->sli4_hba.els_cq) in lpfc_sli4_queue_unset()
11440 lpfc_cq_destroy(phba, phba->sli4_hba.els_cq); in lpfc_sli4_queue_unset()
11443 if (phba->sli4_hba.nvmels_cq) in lpfc_sli4_queue_unset()
11444 lpfc_cq_destroy(phba, phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_unset()
11446 if (phba->nvmet_support) { in lpfc_sli4_queue_unset()
11448 if (phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_unset()
11449 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
11452 phba->sli4_hba.nvmet_mrq_hdr[qidx], in lpfc_sli4_queue_unset()
11453 phba->sli4_hba.nvmet_mrq_data[qidx]); in lpfc_sli4_queue_unset()
11457 if (phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_unset()
11458 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
11460 phba, phba->sli4_hba.nvmet_cqset[qidx]); in lpfc_sli4_queue_unset()
11464 /* Unset fast-path SLI4 queues */ in lpfc_sli4_queue_unset()
11465 if (phba->sli4_hba.hdwq) { in lpfc_sli4_queue_unset()
11467 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_unset()
11469 qp = &phba->sli4_hba.hdwq[qidx]; in lpfc_sli4_queue_unset()
11470 lpfc_wq_destroy(phba, qp->io_wq); in lpfc_sli4_queue_unset()
11471 lpfc_cq_destroy(phba, qp->io_cq); in lpfc_sli4_queue_unset()
11474 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_unset()
11476 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_sli4_queue_unset()
11481 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_unset()
11482 phba->sli4_hba.cq_lookup = NULL; in lpfc_sli4_queue_unset()
11483 phba->sli4_hba.cq_max = 0; in lpfc_sli4_queue_unset()
11487 * lpfc_sli4_cq_event_pool_create - Create completion-queue event free pool
11494 * - Mailbox asynchronous events
11495 * - Receive queue completion unsolicited events
11496 * Later, this can be used for all the slow-path events.
11499 * 0 - successful
11500 * -ENOMEM - No available memory
11508 for (i = 0; i < (4 * phba->sli4_hba.cq_ecount); i++) { in lpfc_sli4_cq_event_pool_create()
11512 list_add_tail(&cq_event->list, in lpfc_sli4_cq_event_pool_create()
11513 &phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_cq_event_pool_create()
11519 return -ENOMEM; in lpfc_sli4_cq_event_pool_create()
11523 * lpfc_sli4_cq_event_pool_destroy - Free completion-queue event free pool
11528 * cleanup routine to free all the outstanding completion-queue events
11538 &phba->sli4_hba.sp_cqe_event_pool, list) { in lpfc_sli4_cq_event_pool_destroy()
11539 list_del(&cq_event->list); in lpfc_sli4_cq_event_pool_destroy()
11545 * __lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
11549 * completion-queue event from the free pool.
11551 * Return: Pointer to the newly allocated completion-queue event if successful
11559 list_remove_head(&phba->sli4_hba.sp_cqe_event_pool, cq_event, in __lpfc_sli4_cq_event_alloc()
11565 * lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
11569 * completion-queue event from the free pool.
11571 * Return: Pointer to the newly allocated completion-queue event if successful
11580 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
11582 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
11587 * __lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
11592 * completion-queue event back into the free pool.
11598 list_add_tail(&cq_event->list, &phba->sli4_hba.sp_cqe_event_pool); in __lpfc_sli4_cq_event_release()
11602 * lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
11607 * completion-queue event back into the free pool.
11614 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
11616 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
11620 * lpfc_sli4_cq_event_release_all - Release all cq events to the free pool
11623 * This routine is to free all the pending completion-queue events to the
11636 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11637 list_splice_init(&phba->sli4_hba.sp_els_xri_aborted_work_queue, in lpfc_sli4_cq_event_release_all()
11639 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11642 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11643 list_splice_init(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_cq_event_release_all()
11645 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_cq_event_release_all()
11655 * lpfc_pci_function_reset - Reset pci function.
11662 * 0 - successful
11663 * -ENOMEM - No available memory
11664 * -EIO - The mailbox failed to complete successfully.
11678 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_pci_function_reset()
11681 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_pci_function_reset()
11688 return -ENOMEM; in lpfc_pci_function_reset()
11691 /* Setup PCI function reset mailbox-ioctl command */ in lpfc_pci_function_reset()
11697 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_pci_function_reset()
11698 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_pci_function_reset()
11700 &shdr->response); in lpfc_pci_function_reset()
11701 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_pci_function_reset()
11708 rc = -ENXIO; in lpfc_pci_function_reset()
11720 if (lpfc_readl(phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
11722 rc = -ENODEV; in lpfc_pci_function_reset()
11731 phba->work_status[0] = readl( in lpfc_pci_function_reset()
11732 phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_pci_function_reset()
11733 phba->work_status[1] = readl( in lpfc_pci_function_reset()
11734 phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_pci_function_reset()
11739 phba->work_status[0], in lpfc_pci_function_reset()
11740 phba->work_status[1]); in lpfc_pci_function_reset()
11741 rc = -ENODEV; in lpfc_pci_function_reset()
11757 writel(reg_data.word0, phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
11760 pci_read_config_word(phba->pcidev, in lpfc_pci_function_reset()
11767 rc = -ENODEV; in lpfc_pci_function_reset()
11778 /* Catch the not-ready port failure after a port reset. */ in lpfc_pci_function_reset()
11783 rc = -ENODEV; in lpfc_pci_function_reset()
11790 * lpfc_sli4_pci_mem_setup - Setup SLI4 HBA PCI memory space.
11794 * with SLI-4 interface spec.
11797 * 0 - successful
11798 * other values - error
11803 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_pci_mem_setup()
11809 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11812 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli4_pci_mem_setup()
11814 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli4_pci_mem_setup()
11823 &phba->sli4_hba.sli_intf.word0)) { in lpfc_sli4_pci_mem_setup()
11824 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11828 if (bf_get(lpfc_sli_intf_valid, &phba->sli4_hba.sli_intf) != in lpfc_sli4_pci_mem_setup()
11833 phba->sli4_hba.sli_intf.word0); in lpfc_sli4_pci_mem_setup()
11834 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11837 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_setup()
11845 phba->pci_bar0_map = pci_resource_start(pdev, PCI_64BIT_BAR0); in lpfc_sli4_pci_mem_setup()
11852 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11853 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
11854 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11855 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11858 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11860 phba->pci_bar0_memmap_p = phba->sli4_hba.conf_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11864 phba->pci_bar0_map = pci_resource_start(pdev, 1); in lpfc_sli4_pci_mem_setup()
11867 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11868 "FATAL - No BAR0 mapping for SLI4, if_type 2\n"); in lpfc_sli4_pci_mem_setup()
11869 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11871 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11872 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
11873 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11874 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
11877 return -ENODEV; in lpfc_sli4_pci_mem_setup()
11888 phba->pci_bar1_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
11891 phba->sli4_hba.ctrl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11892 ioremap(phba->pci_bar1_map, in lpfc_sli4_pci_mem_setup()
11894 if (!phba->sli4_hba.ctrl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11895 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11898 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11901 phba->pci_bar2_memmap_p = in lpfc_sli4_pci_mem_setup()
11902 phba->sli4_hba.ctrl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11905 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11916 phba->pci_bar1_map = pci_resource_start(pdev, PCI_64BIT_BAR2); in lpfc_sli4_pci_mem_setup()
11918 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11919 ioremap(phba->pci_bar1_map, bar1map_len); in lpfc_sli4_pci_mem_setup()
11920 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11921 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11923 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11926 phba->pci_bar2_memmap_p = phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11936 phba->pci_bar2_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
11939 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11940 ioremap(phba->pci_bar2_map, in lpfc_sli4_pci_mem_setup()
11942 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11943 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11946 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11949 phba->pci_bar4_memmap_p = in lpfc_sli4_pci_mem_setup()
11950 phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11955 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11966 phba->pci_bar2_map = pci_resource_start(pdev, PCI_64BIT_BAR4); in lpfc_sli4_pci_mem_setup()
11968 phba->sli4_hba.dpp_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
11969 ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli4_pci_mem_setup()
11970 if (!phba->sli4_hba.dpp_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
11971 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
11973 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
11976 phba->pci_bar4_memmap_p = phba->sli4_hba.dpp_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
11983 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
11984 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_write_eq_db; in lpfc_sli4_pci_mem_setup()
11985 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_write_cq_db; in lpfc_sli4_pci_mem_setup()
11988 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_if6_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
11989 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_if6_write_eq_db; in lpfc_sli4_pci_mem_setup()
11990 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_if6_write_cq_db; in lpfc_sli4_pci_mem_setup()
11999 if (phba->sli4_hba.drbl_regs_memmap_p) in lpfc_sli4_pci_mem_setup()
12000 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12002 if (phba->sli4_hba.ctrl_regs_memmap_p) in lpfc_sli4_pci_mem_setup()
12003 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12005 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
12011 * lpfc_sli4_pci_mem_unset - Unset SLI4 HBA PCI memory space.
12015 * with SLI-4 interface spec.
12021 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_unset()
12025 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12026 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12027 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12030 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12033 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12034 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12035 if (phba->sli4_hba.dpp_regs_memmap_p) in lpfc_sli4_pci_mem_unset()
12036 iounmap(phba->sli4_hba.dpp_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
12041 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_pci_mem_unset()
12042 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_pci_mem_unset()
12049 * lpfc_sli_enable_msix - Enable MSI-X interrupt mode on SLI-3 device
12052 * This routine is invoked to enable the MSI-X interrupt vectors to device
12053 * with SLI-3 interface specs.
12056 * 0 - successful
12057 * other values - error
12065 /* Set up MSI-X multi-message vectors */ in lpfc_sli_enable_msix()
12066 rc = pci_alloc_irq_vectors(phba->pcidev, in lpfc_sli_enable_msix()
12070 "0420 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli_enable_msix()
12075 * Assign MSI-X vectors to interrupt handlers in lpfc_sli_enable_msix()
12078 /* vector-0 is associated to slow-path handler */ in lpfc_sli_enable_msix()
12079 rc = request_irq(pci_irq_vector(phba->pcidev, 0), in lpfc_sli_enable_msix()
12084 "0421 MSI-X slow-path request_irq failed " in lpfc_sli_enable_msix()
12089 /* vector-1 is associated to fast-path handler */ in lpfc_sli_enable_msix()
12090 rc = request_irq(pci_irq_vector(phba->pcidev, 1), in lpfc_sli_enable_msix()
12096 "0429 MSI-X fast-path request_irq failed " in lpfc_sli_enable_msix()
12102 * Configure HBA MSI-X attention conditions to messages in lpfc_sli_enable_msix()
12104 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_enable_msix()
12107 rc = -ENOMEM; in lpfc_sli_enable_msix()
12121 pmb->u.mb.mbxCommand, pmb->u.mb.mbxStatus); in lpfc_sli_enable_msix()
12126 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
12131 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
12135 free_irq(pci_irq_vector(phba->pcidev, 1), phba); in lpfc_sli_enable_msix()
12139 free_irq(pci_irq_vector(phba->pcidev, 0), phba); in lpfc_sli_enable_msix()
12142 /* Unconfigure MSI-X capability structure */ in lpfc_sli_enable_msix()
12143 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_enable_msix()
12150 * lpfc_sli_enable_msi - Enable MSI interrupt mode on SLI-3 device.
12154 * SLI-3 interface spec. The kernel function pci_enable_msi() is called to
12160 * 0 - successful
12161 * other values - error
12168 rc = pci_enable_msi(phba->pcidev); in lpfc_sli_enable_msi()
12178 rc = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_msi()
12181 pci_disable_msi(phba->pcidev); in lpfc_sli_enable_msi()
12189 * lpfc_sli_enable_intr - Enable device interrupt to SLI-3 device.
12191 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
12194 * interrupt handler(s) to interrupt vector(s) to device with SLI-3 interface
12199 * MSI-X -> MSI -> IRQ.
12202 * 0 - successful
12203 * other values - error
12215 clear_bit(HBA_NEEDS_CFG_PORT, &phba->hba_flag); in lpfc_sli_enable_intr()
12218 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli_enable_intr()
12221 /* Indicate initialization to MSI-X mode */ in lpfc_sli_enable_intr()
12222 phba->intr_type = MSIX; in lpfc_sli_enable_intr()
12227 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli_enable_intr()
12228 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli_enable_intr()
12232 phba->intr_type = MSI; in lpfc_sli_enable_intr()
12237 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli_enable_intr()
12238 if (phba->intr_type == NONE) { in lpfc_sli_enable_intr()
12239 retval = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_intr()
12243 phba->intr_type = INTx; in lpfc_sli_enable_intr()
12251 * lpfc_sli_disable_intr - Disable device interrupt to SLI-3 device.
12256 * SLI-3 interface spec. Depending on the interrupt mode, the driver will
12264 if (phba->intr_type == MSIX) in lpfc_sli_disable_intr()
12270 free_irq(pci_irq_vector(phba->pcidev, i), phba); in lpfc_sli_disable_intr()
12271 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_disable_intr()
12274 phba->intr_type = NONE; in lpfc_sli_disable_intr()
12275 phba->sli.slistat.sli_intr = 0; in lpfc_sli_disable_intr()
12279 * lpfc_find_cpu_handle - Find the CPU that corresponds to the specified Queue
12294 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_find_cpu_handle()
12301 (cpup->flag & LPFC_CPU_FIRST_IRQ) && in lpfc_find_cpu_handle()
12302 (cpup->eq == id)) in lpfc_find_cpu_handle()
12306 if ((match == LPFC_FIND_BY_HDWQ) && (cpup->hdwq == id)) in lpfc_find_cpu_handle()
12314 * lpfc_find_hyper - Determine if the CPU map entry is hyper-threaded
12328 cpup = &phba->sli4_hba.cpu_map[idx]; in lpfc_find_hyper()
12330 if ((cpup->phys_id == phys_id) && in lpfc_find_hyper()
12331 (cpup->core_id == core_id) && in lpfc_find_hyper()
12340 * lpfc_assign_eq_map_info - Assigns eq for vector_map structure
12352 struct lpfc_vector_map_info *cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_assign_eq_map_info()
12355 cpup->eq = eqidx; in lpfc_assign_eq_map_info()
12356 cpup->flag |= flag; in lpfc_assign_eq_map_info()
12360 cpu, eqhdl->irq, cpup->eq, cpup->flag); in lpfc_assign_eq_map_info()
12364 * lpfc_cpu_map_array_init - Initialize cpu_map structure
12377 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_map_array_init()
12378 cpup->phys_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12379 cpup->core_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12380 cpup->hdwq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12381 cpup->eq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_map_array_init()
12382 cpup->flag = 0; in lpfc_cpu_map_array_init()
12383 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, cpu); in lpfc_cpu_map_array_init()
12384 INIT_LIST_HEAD(&eqi->list); in lpfc_cpu_map_array_init()
12385 eqi->icnt = 0; in lpfc_cpu_map_array_init()
12390 * lpfc_hba_eq_hdl_array_init - Initialize hba_eq_hdl structure
12401 for (i = 0; i < phba->cfg_irq_chann; i++) { in lpfc_hba_eq_hdl_array_init()
12403 eqhdl->irq = LPFC_IRQ_EMPTY; in lpfc_hba_eq_hdl_array_init()
12404 eqhdl->phba = phba; in lpfc_hba_eq_hdl_array_init()
12409 * lpfc_cpu_affinity_check - Check vector CPU affinity mappings
12414 * MSI-X vector allocated for the HBA.
12416 * and the phba->sli4_hba.cpu_map array will reflect this.
12437 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12439 cpup->phys_id = topology_physical_package_id(cpu); in lpfc_cpu_affinity_check()
12440 cpup->core_id = topology_core_id(cpu); in lpfc_cpu_affinity_check()
12441 if (lpfc_find_hyper(phba, cpu, cpup->phys_id, cpup->core_id)) in lpfc_cpu_affinity_check()
12442 cpup->flag |= LPFC_CPU_MAP_HYPER; in lpfc_cpu_affinity_check()
12445 cpup->phys_id = 0; in lpfc_cpu_affinity_check()
12446 cpup->core_id = cpu; in lpfc_cpu_affinity_check()
12451 cpu, cpup->phys_id, cpup->core_id, cpup->flag); in lpfc_cpu_affinity_check()
12453 if (cpup->phys_id > max_phys_id) in lpfc_cpu_affinity_check()
12454 max_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
12455 if (cpup->phys_id < min_phys_id) in lpfc_cpu_affinity_check()
12456 min_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
12458 if (cpup->core_id > max_core_id) in lpfc_cpu_affinity_check()
12459 max_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
12460 if (cpup->core_id < min_core_id) in lpfc_cpu_affinity_check()
12461 min_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
12473 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12476 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
12478 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
12486 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12487 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12488 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
12489 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY) && in lpfc_cpu_affinity_check()
12490 (new_cpup->phys_id == cpup->phys_id)) in lpfc_cpu_affinity_check()
12498 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
12510 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
12511 cpup->phys_id); in lpfc_cpu_affinity_check()
12519 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12522 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
12524 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
12532 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12533 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12534 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
12535 (new_cpup->eq != LPFC_VECTOR_MAP_EMPTY)) in lpfc_cpu_affinity_check()
12543 cpup->hdwq, cpup->eq); in lpfc_cpu_affinity_check()
12547 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
12558 cpu, cpup->eq, new_cpu, in lpfc_cpu_affinity_check()
12559 new_cpup->phys_id, new_cpup->core_id); in lpfc_cpu_affinity_check()
12568 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12571 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_cpu_affinity_check()
12575 cpup->hdwq = idx; in lpfc_cpu_affinity_check()
12580 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
12581 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
12584 * This will be 1 to 1 - hdwq to cpu, unless there are less in lpfc_cpu_affinity_check()
12585 * hardware queues then CPUs. For that case we will just round-robin in lpfc_cpu_affinity_check()
12588 * for irq_chann < hdwq. The idx is used for round-robin assignments in lpfc_cpu_affinity_check()
12595 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12598 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_cpu_affinity_check()
12605 if (next_idx < phba->cfg_hdw_queue) { in lpfc_cpu_affinity_check()
12606 cpup->hdwq = next_idx; in lpfc_cpu_affinity_check()
12617 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12618 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12619 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
12620 new_cpup->phys_id == cpup->phys_id && in lpfc_cpu_affinity_check()
12621 new_cpup->core_id == cpup->core_id) { in lpfc_cpu_affinity_check()
12631 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
12632 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
12633 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
12634 new_cpup->phys_id == cpup->phys_id) in lpfc_cpu_affinity_check()
12640 cpup->hdwq = idx % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
12646 cpup->hdwq = new_cpup->hdwq; in lpfc_cpu_affinity_check()
12651 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
12652 cpup->hdwq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
12656 * Initialize the cpu_map slots for not-present cpus in case in lpfc_cpu_affinity_check()
12657 * a cpu is hot-added. Perform a simple hdwq round robin assignment. in lpfc_cpu_affinity_check()
12661 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
12663 c_stat = per_cpu_ptr(phba->sli4_hba.c_stat, cpu); in lpfc_cpu_affinity_check()
12664 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
12666 if (cpup->hdwq != LPFC_VECTOR_MAP_EMPTY) in lpfc_cpu_affinity_check()
12669 cpup->hdwq = idx++ % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
12671 c_stat->hdwq_no = cpup->hdwq; in lpfc_cpu_affinity_check()
12676 cpu, cpup->hdwq); in lpfc_cpu_affinity_check()
12703 return -ENOMEM; in lpfc_cpuhp_get_eq()
12705 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_cpuhp_get_eq()
12706 maskp = pci_irq_get_affinity(phba->pcidev, idx); in lpfc_cpuhp_get_eq()
12716 /* get the cpus that are online and are affini- in lpfc_cpuhp_get_eq()
12718 * more than 1 then cpuhp is not going to shut- in lpfc_cpuhp_get_eq()
12731 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_cpuhp_get_eq()
12732 list_add(&eq->_poll_list, eqlist); in lpfc_cpuhp_get_eq()
12740 if (phba->sli_rev != LPFC_SLI_REV4) in __lpfc_cpuhp_remove()
12744 &phba->cpuhp); in __lpfc_cpuhp_remove()
12750 timer_delete_sync(&phba->cpuhp_poll_timer); in __lpfc_cpuhp_remove()
12755 if (phba->pport && in lpfc_cpuhp_remove()
12756 test_bit(FC_OFFLINE_MODE, &phba->pport->fc_flag)) in lpfc_cpuhp_remove()
12764 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_cpuhp_add()
12769 if (!list_empty(&phba->poll_list)) in lpfc_cpuhp_add()
12770 mod_timer(&phba->cpuhp_poll_timer, in lpfc_cpuhp_add()
12776 &phba->cpuhp); in lpfc_cpuhp_add()
12781 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { in __lpfc_cpuhp_checks()
12782 *retval = -EAGAIN; in __lpfc_cpuhp_checks()
12786 if (phba->sli_rev != LPFC_SLI_REV4) { in __lpfc_cpuhp_checks()
12796 * lpfc_irq_set_aff - set IRQ affinity
12804 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_set_aff()
12805 cpumask_set_cpu(cpu, &eqhdl->aff_mask); in lpfc_irq_set_aff()
12806 irq_set_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_set_aff()
12807 irq_set_affinity(eqhdl->irq, &eqhdl->aff_mask); in lpfc_irq_set_aff()
12811 * lpfc_irq_clear_aff - clear IRQ affinity
12818 cpumask_clear(&eqhdl->aff_mask); in lpfc_irq_clear_aff()
12819 irq_clear_status_flags(eqhdl->irq, IRQ_NO_BALANCING); in lpfc_irq_clear_aff()
12823 * lpfc_irq_rebalance - rebalances IRQ affinity according to cpuhp event
12835 * PCI_IRQ_AFFINITY to auto-manage IRQ affinity.
12846 if (phba->irq_chann_mode == NORMAL_MODE) in lpfc_irq_rebalance()
12849 orig_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_irq_rebalance()
12854 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_irq_rebalance()
12856 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_irq_rebalance()
12869 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_irq_rebalance()
12879 for (idx = 0; idx < phba->cfg_irq_chann; idx++) in lpfc_irq_rebalance()
12884 lpfc_irq_set_aff(lpfc_get_eq_hdl(cpup->eq), cpu); in lpfc_irq_rebalance()
12911 list_del_init(&eq->_poll_list); in lpfc_cpu_offline()
12935 list_for_each_entry_safe(eq, next, &phba->poll_list, _poll_list) { in lpfc_cpu_online()
12936 n = lpfc_find_cpu_handle(phba, eq->hdwq, LPFC_FIND_BY_HDWQ); in lpfc_cpu_online()
12945 * lpfc_sli4_enable_msix - Enable MSI-X interrupt mode to SLI-4 device
12948 * This routine is invoked to enable the MSI-X interrupt vectors to device
12949 * with SLI-4 interface spec. It also allocates MSI-X vectors and maps them
12969 * 0 - successful
12970 * other values - error
12984 /* Set up MSI-X multi-message vectors */ in lpfc_sli4_enable_msix()
12985 vectors = phba->cfg_irq_chann; in lpfc_sli4_enable_msix()
12987 if (phba->irq_chann_mode != NORMAL_MODE) in lpfc_sli4_enable_msix()
12988 aff_mask = &phba->sli4_hba.irq_aff_mask; in lpfc_sli4_enable_msix()
12992 vectors = min(phba->cfg_irq_chann, cpu_cnt); in lpfc_sli4_enable_msix()
13003 rc = pci_alloc_irq_vectors(phba->pcidev, 1, vectors, flags); in lpfc_sli4_enable_msix()
13006 "0484 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli4_enable_msix()
13011 /* Assign MSI-X vectors to interrupt handlers */ in lpfc_sli4_enable_msix()
13014 name = eqhdl->handler_name; in lpfc_sli4_enable_msix()
13019 eqhdl->idx = index; in lpfc_sli4_enable_msix()
13020 rc = pci_irq_vector(phba->pcidev, index); in lpfc_sli4_enable_msix()
13023 "0489 MSI-X fast-path (%d) " in lpfc_sli4_enable_msix()
13027 eqhdl->irq = rc; in lpfc_sli4_enable_msix()
13029 rc = request_threaded_irq(eqhdl->irq, in lpfc_sli4_enable_msix()
13035 "0486 MSI-X fast-path (%d) " in lpfc_sli4_enable_msix()
13060 maskp = pci_irq_get_affinity(phba->pcidev, index); in lpfc_sli4_enable_msix()
13064 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_enable_msix()
13078 if (cpup->eq != LPFC_VECTOR_MAP_EMPTY) in lpfc_sli4_enable_msix()
13088 if (vectors != phba->cfg_irq_chann) { in lpfc_sli4_enable_msix()
13091 "MSI-X vectors, requested %d got %d\n", in lpfc_sli4_enable_msix()
13092 phba->cfg_irq_chann, vectors); in lpfc_sli4_enable_msix()
13093 if (phba->cfg_irq_chann > vectors) in lpfc_sli4_enable_msix()
13094 phba->cfg_irq_chann = vectors; in lpfc_sli4_enable_msix()
13101 for (--index; index >= 0; index--) { in lpfc_sli4_enable_msix()
13104 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_enable_msix()
13107 /* Unconfigure MSI-X capability structure */ in lpfc_sli4_enable_msix()
13108 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msix()
13115 * lpfc_sli4_enable_msi - Enable MSI interrupt mode to SLI-4 device
13119 * SLI-4 interface spec. The kernel function pci_alloc_irq_vectors() is
13125 * 0 - successful
13126 * other values - error
13135 rc = pci_alloc_irq_vectors(phba->pcidev, 1, 1, in lpfc_sli4_enable_msi()
13143 return rc ? rc : -1; in lpfc_sli4_enable_msi()
13146 rc = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_msi()
13149 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msi()
13156 rc = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_msi()
13158 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_enable_msi()
13159 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msi()
13164 eqhdl->irq = rc; in lpfc_sli4_enable_msi()
13169 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_enable_msi()
13171 eqhdl->idx = index; in lpfc_sli4_enable_msi()
13178 * lpfc_sli4_enable_intr - Enable device interrupt to SLI-4 device
13180 * @cfg_mode: Interrupt configuration mode (INTx, MSI or MSI-X).
13183 * interrupt handler(s) to interrupt vector(s) to device with SLI-4
13188 * MSI-X -> MSI -> IRQ.
13191 * Interrupt mode (2, 1, 0) - successful
13192 * LPFC_INTR_ERROR - error
13204 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli4_enable_intr()
13207 /* Indicate initialization to MSI-X mode */ in lpfc_sli4_enable_intr()
13208 phba->intr_type = MSIX; in lpfc_sli4_enable_intr()
13214 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli4_enable_intr()
13215 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
13219 phba->intr_type = MSI; in lpfc_sli4_enable_intr()
13224 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli4_enable_intr()
13225 if (phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
13226 retval = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_intr()
13233 phba->intr_type = INTx; in lpfc_sli4_enable_intr()
13237 retval = pci_irq_vector(phba->pcidev, 0); in lpfc_sli4_enable_intr()
13239 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_enable_intr()
13245 eqhdl->irq = retval; in lpfc_sli4_enable_intr()
13250 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_enable_intr()
13252 eqhdl->idx = idx; in lpfc_sli4_enable_intr()
13260 * lpfc_sli4_disable_intr - Disable device interrupt to SLI-4 device
13265 * with SLI-4 interface spec. Depending on the interrupt mode, the driver
13272 if (phba->intr_type == MSIX) { in lpfc_sli4_disable_intr()
13276 /* Free up MSI-X multi-message vectors */ in lpfc_sli4_disable_intr()
13277 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_disable_intr()
13280 free_irq(eqhdl->irq, eqhdl); in lpfc_sli4_disable_intr()
13283 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_disable_intr()
13286 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_disable_intr()
13289 phba->intr_type = NONE; in lpfc_sli4_disable_intr()
13290 phba->sli.slistat.sli_intr = 0; in lpfc_sli4_disable_intr()
13294 * lpfc_unset_hba - Unset SLI3 hba device initialization
13298 * a device with SLI-3 interface spec.
13303 set_bit(FC_UNLOADING, &phba->pport->load_flag); in lpfc_unset_hba()
13305 kfree(phba->vpi_bmask); in lpfc_unset_hba()
13306 kfree(phba->vpi_ids); in lpfc_unset_hba()
13310 phba->pport->work_port_events = 0; in lpfc_unset_hba()
13322 * lpfc_sli4_xri_exchange_busy_wait - Wait for device XRI exchange busy
13342 int els_xri_cmpl = list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
13351 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_xri_exchange_busy_wait()
13355 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
13356 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
13357 io_xri_cmpl = list_empty(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
13364 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
13366 list_empty(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
13394 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
13395 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
13397 &qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
13404 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
13406 &phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
13409 list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
13415 * lpfc_sli4_hba_unset - Unset the fcoe hba
13429 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_hba_unset()
13432 hrtimer_cancel(&phba->cmf_stats_timer); in lpfc_sli4_hba_unset()
13433 hrtimer_cancel(&phba->cmf_timer); in lpfc_sli4_hba_unset()
13435 if (phba->pport) in lpfc_sli4_hba_unset()
13436 phba->sli4_hba.intr_enable = 0; in lpfc_sli4_hba_unset()
13444 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13445 phba->sli.sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_hba_unset()
13446 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13448 while (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
13454 if (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
13455 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13456 mboxq = phba->sli.mbox_active; in lpfc_sli4_hba_unset()
13457 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_hba_unset()
13459 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_hba_unset()
13460 phba->sli.mbox_active = NULL; in lpfc_sli4_hba_unset()
13461 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
13467 if (!pci_channel_offline(phba->pcidev)) in lpfc_sli4_hba_unset()
13471 /* per-phba callback de-registration for hotplug event */ in lpfc_sli4_hba_unset()
13472 if (phba->pport) in lpfc_sli4_hba_unset()
13478 /* Disable SR-IOV if enabled */ in lpfc_sli4_hba_unset()
13479 if (phba->cfg_sriov_nr_virtfn) in lpfc_sli4_hba_unset()
13483 kthread_stop(phba->worker_thread); in lpfc_sli4_hba_unset()
13497 if (phba->ras_fwlog.ras_enabled) in lpfc_sli4_hba_unset()
13501 if (phba->pport) in lpfc_sli4_hba_unset()
13502 phba->pport->work_port_events = 0; in lpfc_sli4_hba_unset()
13563 "6235 INIT Congestion Buffer %p\n", phba->cgn_i); in lpfc_init_congestion_buf()
13565 if (!phba->cgn_i) in lpfc_init_congestion_buf()
13567 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_init_congestion_buf()
13569 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_init_congestion_buf()
13570 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_init_congestion_buf()
13571 atomic_set(&phba->cgn_sync_alarm_cnt, 0); in lpfc_init_congestion_buf()
13572 atomic_set(&phba->cgn_sync_warn_cnt, 0); in lpfc_init_congestion_buf()
13574 atomic_set(&phba->cgn_driver_evt_cnt, 0); in lpfc_init_congestion_buf()
13575 atomic_set(&phba->cgn_latency_evt_cnt, 0); in lpfc_init_congestion_buf()
13576 atomic64_set(&phba->cgn_latency_evt, 0); in lpfc_init_congestion_buf()
13577 phba->cgn_evt_minute = 0; in lpfc_init_congestion_buf()
13580 cp->cgn_info_size = cpu_to_le16(LPFC_CGN_INFO_SZ); in lpfc_init_congestion_buf()
13581 cp->cgn_info_version = LPFC_CGN_INFO_V4; in lpfc_init_congestion_buf()
13584 cp->cgn_info_mode = phba->cgn_p.cgn_param_mode; in lpfc_init_congestion_buf()
13585 cp->cgn_info_level0 = phba->cgn_p.cgn_param_level0; in lpfc_init_congestion_buf()
13586 cp->cgn_info_level1 = phba->cgn_p.cgn_param_level1; in lpfc_init_congestion_buf()
13587 cp->cgn_info_level2 = phba->cgn_p.cgn_param_level2; in lpfc_init_congestion_buf()
13589 lpfc_cgn_update_tstamp(phba, &cp->base_time); in lpfc_init_congestion_buf()
13592 if (phba->pport) { in lpfc_init_congestion_buf()
13593 size = (uint16_t)(phba->pport->cfg_lun_queue_depth); in lpfc_init_congestion_buf()
13594 cp->cgn_lunq = cpu_to_le16(size); in lpfc_init_congestion_buf()
13599 cp->cgn_warn_freq = cpu_to_le16(LPFC_FPIN_INIT_FREQ); in lpfc_init_congestion_buf()
13600 cp->cgn_alarm_freq = cpu_to_le16(LPFC_FPIN_INIT_FREQ); in lpfc_init_congestion_buf()
13602 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_init_congestion_buf()
13604 phba->cgn_evt_timestamp = jiffies + in lpfc_init_congestion_buf()
13615 "6236 INIT Congestion Stat %p\n", phba->cgn_i); in lpfc_init_congestion_stat()
13617 if (!phba->cgn_i) in lpfc_init_congestion_stat()
13620 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; in lpfc_init_congestion_stat()
13621 memset(&cp->cgn_stat, 0, sizeof(cp->cgn_stat)); in lpfc_init_congestion_stat()
13623 lpfc_cgn_update_tstamp(phba, &cp->stat_start); in lpfc_init_congestion_stat()
13625 cp->cgn_info_crc = cpu_to_le32(crc); in lpfc_init_congestion_stat()
13629 * __lpfc_reg_congestion_buf - register congestion info buffer with HBA
13642 if (!phba->cgn_i) in __lpfc_reg_congestion_buf()
13643 return -ENXIO; in __lpfc_reg_congestion_buf()
13645 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in __lpfc_reg_congestion_buf()
13650 phba->pport->port_state, reg); in __lpfc_reg_congestion_buf()
13651 return -ENOMEM; in __lpfc_reg_congestion_buf()
13654 length = (sizeof(struct lpfc_mbx_reg_congestion_buf) - in __lpfc_reg_congestion_buf()
13659 reg_congestion_buf = &mboxq->u.mqe.un.reg_congestion_buf; in __lpfc_reg_congestion_buf()
13665 reg_congestion_buf->length = sizeof(struct lpfc_cgn_info); in __lpfc_reg_congestion_buf()
13666 reg_congestion_buf->addr_lo = in __lpfc_reg_congestion_buf()
13667 putPaddrLow(phba->cgn_i->phys); in __lpfc_reg_congestion_buf()
13668 reg_congestion_buf->addr_hi = in __lpfc_reg_congestion_buf()
13669 putPaddrHigh(phba->cgn_i->phys); in __lpfc_reg_congestion_buf()
13673 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in __lpfc_reg_congestion_buf()
13674 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in __lpfc_reg_congestion_buf()
13676 &shdr->response); in __lpfc_reg_congestion_buf()
13677 mempool_free(mboxq, phba->mbox_mem_pool); in __lpfc_reg_congestion_buf()
13684 return -ENXIO; in __lpfc_reg_congestion_buf()
13703 * lpfc_get_sli4_parameters - Get the SLI4 Config PARAMETERS.
13710 * This function may be be called from any context that can block-wait
13718 struct lpfc_mqe *mqe = &mboxq->u.mqe; in lpfc_get_sli4_parameters()
13730 phba->sli4_hba.rpi_hdrs_in_use = 1; in lpfc_get_sli4_parameters()
13733 length = (sizeof(struct lpfc_mbx_get_sli4_parameters) - in lpfc_get_sli4_parameters()
13738 if (!phba->sli4_hba.intr_enable) in lpfc_get_sli4_parameters()
13746 sli4_params = &phba->sli4_hba.pc_sli4_params; in lpfc_get_sli4_parameters()
13747 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters; in lpfc_get_sli4_parameters()
13748 sli4_params->if_type = bf_get(cfg_if_type, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13749 sli4_params->sli_rev = bf_get(cfg_sli_rev, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13750 sli4_params->sli_family = bf_get(cfg_sli_family, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13751 sli4_params->featurelevel_1 = bf_get(cfg_sli_hint_1, in lpfc_get_sli4_parameters()
13753 sli4_params->featurelevel_2 = bf_get(cfg_sli_hint_2, in lpfc_get_sli4_parameters()
13756 phba->sli3_options |= LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
13758 phba->sli3_options &= ~LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
13759 sli4_params->sge_supp_len = mbx_sli4_parameters->sge_supp_len; in lpfc_get_sli4_parameters()
13760 sli4_params->loopbk_scope = bf_get(cfg_loopbk_scope, in lpfc_get_sli4_parameters()
13762 sli4_params->oas_supported = bf_get(cfg_oas, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13763 sli4_params->cqv = bf_get(cfg_cqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13764 sli4_params->mqv = bf_get(cfg_mqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13765 sli4_params->wqv = bf_get(cfg_wqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13766 sli4_params->rqv = bf_get(cfg_rqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13767 sli4_params->eqav = bf_get(cfg_eqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13768 sli4_params->cqav = bf_get(cfg_cqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13769 sli4_params->wqsize = bf_get(cfg_wqsize, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13770 sli4_params->bv1s = bf_get(cfg_bv1s, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13771 sli4_params->pls = bf_get(cfg_pvl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13772 sli4_params->sgl_pages_max = bf_get(cfg_sgl_page_cnt, in lpfc_get_sli4_parameters()
13774 sli4_params->wqpcnt = bf_get(cfg_wqpcnt, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13775 sli4_params->sgl_pp_align = bf_get(cfg_sgl_pp_align, in lpfc_get_sli4_parameters()
13777 phba->sli4_hba.extents_in_use = bf_get(cfg_ext, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13778 phba->sli4_hba.rpi_hdrs_in_use = bf_get(cfg_hdrr, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13779 sli4_params->mi_cap = bf_get(cfg_mi_ver, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13781 /* Check for Extended Pre-Registered SGL support */ in lpfc_get_sli4_parameters()
13782 phba->cfg_xpsgl = bf_get(cfg_xpsgl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
13790 sli4_params->nvme = 1; in lpfc_get_sli4_parameters()
13793 if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP) { in lpfc_get_sli4_parameters()
13797 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
13802 sli4_params->nvme = 0; in lpfc_get_sli4_parameters()
13803 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_get_sli4_parameters()
13809 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
13811 phba->nvmet_support = 0; in lpfc_get_sli4_parameters()
13812 phba->cfg_nvmet_mrq = 0; in lpfc_get_sli4_parameters()
13813 phba->cfg_nvme_seg_cnt = 0; in lpfc_get_sli4_parameters()
13816 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_get_sli4_parameters()
13817 return -ENODEV; in lpfc_get_sli4_parameters()
13818 phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; in lpfc_get_sli4_parameters()
13825 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_get_sli4_parameters()
13826 phba->cfg_sg_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_get_sli4_parameters()
13830 phba->cfg_enable_pbde = 1; in lpfc_get_sli4_parameters()
13832 phba->cfg_enable_pbde = 0; in lpfc_get_sli4_parameters()
13837 * In SLI4-Parameters Descriptor: in lpfc_get_sli4_parameters()
13842 if (phba->cfg_suppress_rsp && bf_get(cfg_xib, mbx_sli4_parameters) && in lpfc_get_sli4_parameters()
13844 phba->sli.sli_flag |= LPFC_SLI_SUPPRESS_RSP; in lpfc_get_sli4_parameters()
13846 phba->cfg_suppress_rsp = 0; in lpfc_get_sli4_parameters()
13849 phba->sli.sli_flag |= LPFC_SLI_USE_EQDR; in lpfc_get_sli4_parameters()
13852 if (sli4_params->sge_supp_len > LPFC_MAX_SGE_SIZE) in lpfc_get_sli4_parameters()
13853 sli4_params->sge_supp_len = LPFC_MAX_SGE_SIZE; in lpfc_get_sli4_parameters()
13855 dma_set_max_seg_size(&phba->pcidev->dev, sli4_params->sge_supp_len); in lpfc_get_sli4_parameters()
13860 * to use this option, 128-byte WQEs must be used. in lpfc_get_sli4_parameters()
13863 phba->fcp_embed_io = 1; in lpfc_get_sli4_parameters()
13865 phba->fcp_embed_io = 0; in lpfc_get_sli4_parameters()
13870 phba->cfg_enable_pbde, in lpfc_get_sli4_parameters()
13871 phba->fcp_embed_io, sli4_params->nvme, in lpfc_get_sli4_parameters()
13872 phba->cfg_nvme_embed_cmd, phba->cfg_suppress_rsp); in lpfc_get_sli4_parameters()
13874 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
13876 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
13883 (sli4_params->wqsize & LPFC_WQ_SZ128_SUPPORT)) in lpfc_get_sli4_parameters()
13884 phba->enab_exp_wqcq_pages = 1; in lpfc_get_sli4_parameters()
13886 phba->enab_exp_wqcq_pages = 0; in lpfc_get_sli4_parameters()
13891 phba->mds_diags_support = 1; in lpfc_get_sli4_parameters()
13893 phba->mds_diags_support = 0; in lpfc_get_sli4_parameters()
13899 phba->nsler = 1; in lpfc_get_sli4_parameters()
13901 phba->nsler = 0; in lpfc_get_sli4_parameters()
13907 * lpfc_pci_probe_one_s3 - PCI probe func to reg SLI-3 device to PCI subsystem.
13911 * This routine is to be called to attach a device with SLI-3 interface spec
13912 * to the PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
13913 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
13920 * 0 - driver can claim the device
13921 * negative value - driver can not claim the device
13935 return -ENOMEM; in lpfc_pci_probe_one_s3()
13942 /* Set up SLI API function jump table for PCI-device group-0 HBAs */ in lpfc_pci_probe_one_s3()
13947 /* Set up SLI-3 specific device PCI memory space */ in lpfc_pci_probe_one_s3()
13955 /* Set up SLI-3 specific device driver resources */ in lpfc_pci_probe_one_s3()
13981 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s3()
13992 vport = phba->pport; in lpfc_pci_probe_one_s3()
14002 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s3()
14011 error = -ENODEV; in lpfc_pci_probe_one_s3()
14014 /* SLI-3 HBA setup */ in lpfc_pci_probe_one_s3()
14018 error = -ENODEV; in lpfc_pci_probe_one_s3()
14026 phba->sli.slistat.sli_intr > LPFC_MSIX_VECTORS) { in lpfc_pci_probe_one_s3()
14028 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s3()
14039 cfg_mode = --intr_mode; in lpfc_pci_probe_one_s3()
14075 * lpfc_pci_remove_one_s3 - PCI func to unreg SLI-3 device from PCI subsystem.
14078 * This routine is to be called to disattach a device with SLI-3 interface
14079 * spec from PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
14087 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s3()
14089 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s3()
14092 set_bit(FC_UNLOADING, &vport->load_flag); in lpfc_pci_remove_one_s3()
14099 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s3()
14100 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s3()
14102 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s3()
14122 kthread_stop(phba->worker_thread); in lpfc_pci_remove_one_s3()
14126 kfree(phba->vpi_bmask); in lpfc_pci_remove_one_s3()
14127 kfree(phba->vpi_ids); in lpfc_pci_remove_one_s3()
14130 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
14131 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s3()
14132 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
14136 /* Disable SR-IOV if enabled */ in lpfc_pci_remove_one_s3()
14137 if (phba->cfg_sriov_nr_virtfn) in lpfc_pci_remove_one_s3()
14154 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_pci_remove_one_s3()
14155 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_pci_remove_one_s3()
14158 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_pci_remove_one_s3()
14159 phba->slim2p.virt, phba->slim2p.phys); in lpfc_pci_remove_one_s3()
14162 iounmap(phba->ctrl_regs_memmap_p); in lpfc_pci_remove_one_s3()
14163 iounmap(phba->slim_memmap_p); in lpfc_pci_remove_one_s3()
14172 * lpfc_pci_suspend_one_s3 - PCI func to suspend SLI-3 device for power mgmnt
14176 * system Power Management (PM) to device with SLI-3 interface spec. When
14180 * minimum PM requirements to a power-aware driver's PM support for the
14181 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
14188 * 0 - driver suspended the device
14195 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s3()
14203 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s3()
14212 * lpfc_pci_resume_one_s3 - PCI func to resume SLI-3 device for power mgmnt
14216 * system Power Management (PM) to device with SLI-3 interface spec. When PM
14219 * driver implements the minimum PM requirements to a power-aware driver's
14220 * PM for suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE,
14227 * 0 - driver suspended the device
14234 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s3()
14242 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s3()
14243 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s3()
14244 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s3()
14245 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s3()
14257 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
14261 return -EIO; in lpfc_pci_resume_one_s3()
14263 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s3()
14270 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
14276 * lpfc_sli_prep_dev_for_recover - Prepare SLI3 device for pci slot recover
14290 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli_prep_dev_for_recover()
14296 * lpfc_sli_prep_dev_for_reset - Prepare SLI3 device for pci slot reset
14323 pci_disable_device(phba->pcidev); in lpfc_sli_prep_dev_for_reset()
14327 * lpfc_sli_prep_dev_for_perm_failure - Prepare SLI3 dev for pci slot disable
14351 * lpfc_io_error_detected_s3 - Method for handling SLI-3 device PCI I/O error
14356 * device with SLI-3 interface spec. This function is called by the PCI
14364 * PCI_ERS_RESULT_CAN_RECOVER - can be recovered without reset
14365 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
14366 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
14372 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s3()
14376 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s3()
14397 * lpfc_io_slot_reset_s3 - Method for restarting PCI SLI-3 device from scratch.
14401 * device with SLI-3 interface spec. This is called after PCI bus has been
14402 * reset to restart the PCI card from scratch, as if from a cold-boot.
14411 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
14412 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
14418 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s3()
14419 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s3()
14422 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s3()
14424 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s3()
14431 if (pdev->is_busmaster) in lpfc_io_slot_reset_s3()
14434 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
14435 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s3()
14436 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
14439 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
14442 "0427 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s3()
14446 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s3()
14454 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
14460 * lpfc_io_resume_s3 - Method for resuming PCI I/O operation on SLI-3 device.
14464 * with SLI-3 interface spec. It is called when kernel error recovery tells
14473 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s3()
14475 /* Bring device online, it will be no-op for non-fatal error resume */ in lpfc_io_resume_s3()
14480 * lpfc_sli4_get_els_iocb_cnt - Calculate the # of ELS IOCBs to reserve
14488 int max_xri = phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_get_els_iocb_cnt()
14490 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli4_get_els_iocb_cnt()
14510 * lpfc_sli4_get_iocb_cnt - Calculate the # of total IOCBs to reserve
14520 if (phba->nvmet_support) in lpfc_sli4_get_iocb_cnt()
14534 sli_family = bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf); in lpfc_log_write_firmware_error()
14552 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
14553 fsize, fw->size); in lpfc_log_write_firmware_error()
14554 rc = -EINVAL; in lpfc_log_write_firmware_error()
14561 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
14562 fsize, fw->size); in lpfc_log_write_firmware_error()
14563 rc = -EACCES; in lpfc_log_write_firmware_error()
14569 offset, phba->pcidev->device, magic_number, in lpfc_log_write_firmware_error()
14570 ftype, fid, fsize, fw->size); in lpfc_log_write_firmware_error()
14571 rc = -EIO; in lpfc_log_write_firmware_error()
14577 * lpfc_write_firmware - attempt to write a firmware image to the port
14594 /* It can be null in no-wait mode, sanity check */ in lpfc_write_firmware()
14596 rc = -ENXIO; in lpfc_write_firmware()
14599 image = (struct lpfc_grp_hdr *)fw->data; in lpfc_write_firmware()
14601 magic_number = be32_to_cpu(image->magic_number); in lpfc_write_firmware()
14604 fsize = be32_to_cpu(image->size); in lpfc_write_firmware()
14608 if (strncmp(fwrev, image->revision, strnlen(image->revision, 16))) { in lpfc_write_firmware()
14612 fwrev, image->revision); in lpfc_write_firmware()
14617 rc = -ENOMEM; in lpfc_write_firmware()
14620 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_write_firmware()
14622 &dmabuf->phys, in lpfc_write_firmware()
14624 if (!dmabuf->virt) { in lpfc_write_firmware()
14626 rc = -ENOMEM; in lpfc_write_firmware()
14629 list_add_tail(&dmabuf->list, &dma_buffer_list); in lpfc_write_firmware()
14631 while (offset < fw->size) { in lpfc_write_firmware()
14634 if (temp_offset + SLI4_PAGE_SIZE > fw->size) { in lpfc_write_firmware()
14635 memcpy(dmabuf->virt, in lpfc_write_firmware()
14636 fw->data + temp_offset, in lpfc_write_firmware()
14637 fw->size - temp_offset); in lpfc_write_firmware()
14638 temp_offset = fw->size; in lpfc_write_firmware()
14641 memcpy(dmabuf->virt, fw->data + temp_offset, in lpfc_write_firmware()
14646 (fw->size - offset), &offset); in lpfc_write_firmware()
14662 fwrev, image->revision); in lpfc_write_firmware()
14666 list_del(&dmabuf->list); in lpfc_write_firmware()
14667 dma_free_coherent(&phba->pcidev->dev, SLI4_PAGE_SIZE, in lpfc_write_firmware()
14668 dmabuf->virt, dmabuf->phys); in lpfc_write_firmware()
14682 * lpfc_sli4_request_firmware_update - Request linux generic firmware upgrade
14697 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_request_firmware_update()
14699 return -EPERM; in lpfc_sli4_request_firmware_update()
14701 scnprintf(file_name, sizeof(file_name), "%s.grp", phba->ModelName); in lpfc_sli4_request_firmware_update()
14705 file_name, &phba->pcidev->dev, in lpfc_sli4_request_firmware_update()
14709 ret = request_firmware(&fw, file_name, &phba->pcidev->dev); in lpfc_sli4_request_firmware_update()
14713 ret = -EINVAL; in lpfc_sli4_request_firmware_update()
14720 * lpfc_pci_probe_one_s4 - PCI probe func to reg SLI-4 device to PCI subsys
14725 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
14726 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
14734 * 0 - driver can claim the device
14735 * negative value - driver can not claim the device
14749 return -ENOMEM; in lpfc_pci_probe_one_s4()
14751 INIT_LIST_HEAD(&phba->poll_list); in lpfc_pci_probe_one_s4()
14758 /* Set up SLI API function jump table for PCI-device group-1 HBAs */ in lpfc_pci_probe_one_s4()
14763 /* Set up SLI-4 specific device PCI memory space */ in lpfc_pci_probe_one_s4()
14771 /* Set up SLI-4 Specific device driver resources */ in lpfc_pci_probe_one_s4()
14779 spin_lock_init(&phba->rrq_list_lock); in lpfc_pci_probe_one_s4()
14780 INIT_LIST_HEAD(&phba->active_rrq_list); in lpfc_pci_probe_one_s4()
14781 INIT_LIST_HEAD(&phba->fcf.fcf_pri_list); in lpfc_pci_probe_one_s4()
14792 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s4()
14795 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s4()
14798 phba->pport = NULL; in lpfc_pci_probe_one_s4()
14812 error = -ENODEV; in lpfc_pci_probe_one_s4()
14815 /* Default to single EQ for non-MSI-X */ in lpfc_pci_probe_one_s4()
14816 if (phba->intr_type != MSIX) { in lpfc_pci_probe_one_s4()
14817 phba->cfg_irq_chann = 1; in lpfc_pci_probe_one_s4()
14818 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
14819 if (phba->nvmet_support) in lpfc_pci_probe_one_s4()
14820 phba->cfg_nvmet_mrq = 1; in lpfc_pci_probe_one_s4()
14823 lpfc_cpu_affinity_check(phba, phba->cfg_irq_chann); in lpfc_pci_probe_one_s4()
14832 vport = phba->pport; in lpfc_pci_probe_one_s4()
14843 /* Set up SLI-4 HBA */ in lpfc_pci_probe_one_s4()
14847 error = -ENODEV; in lpfc_pci_probe_one_s4()
14852 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s4()
14861 if (phba->nvmet_support == 0) { in lpfc_pci_probe_one_s4()
14862 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
14879 if (phba->cfg_request_firmware_upgrade) in lpfc_pci_probe_one_s4()
14885 timer_setup(&phba->cpuhp_poll_timer, lpfc_sli4_poll_hbtimer, 0); in lpfc_pci_probe_one_s4()
14886 cpuhp_state_add_instance_nocalls(lpfc_cpuhp_state, &phba->cpuhp); in lpfc_pci_probe_one_s4()
14912 * lpfc_pci_remove_one_s4 - PCI func to unreg SLI-4 device from PCI subsystem
14916 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
14924 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s4()
14926 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s4()
14930 set_bit(FC_UNLOADING, &vport->load_flag); in lpfc_pci_remove_one_s4()
14931 if (phba->cgn_i) in lpfc_pci_remove_one_s4()
14939 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s4()
14940 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s4()
14942 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s4()
14957 /* De-allocate multi-XRI pools */ in lpfc_pci_remove_one_s4()
14958 if (phba->cfg_xri_rebalancing) in lpfc_pci_remove_one_s4()
14969 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
14970 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s4()
14971 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
14997 * lpfc_pci_suspend_one_s4 - PCI func to suspend SLI-4 device for power mgmnt
15001 * Power Management (PM) to device with SLI-4 interface spec. When PM invokes
15005 * requirements to a power-aware driver's PM support for suspend/resume -- all
15013 * 0 - driver suspended the device
15020 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s4()
15028 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s4()
15038 * lpfc_pci_resume_one_s4 - PCI func to resume SLI-4 device for power mgmnt
15042 * Power Management (PM) to device with SLI-4 interface spac. When PM invokes
15045 * implements the minimum PM requirements to a power-aware driver's PM for
15046 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
15053 * 0 - driver suspended the device
15060 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s4()
15068 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s4()
15069 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s4()
15070 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s4()
15071 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s4()
15079 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
15083 return -EIO; in lpfc_pci_resume_one_s4()
15085 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s4()
15092 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
15098 * lpfc_sli4_prep_dev_for_recover - Prepare SLI4 device for pci slot recover
15111 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli4_prep_dev_for_recover()
15117 * lpfc_sli4_prep_dev_for_reset - Prepare SLI4 device for pci slot reset
15127 int offline = pci_channel_offline(phba->pcidev); in lpfc_sli4_prep_dev_for_reset()
15149 pci_disable_device(phba->pcidev); in lpfc_sli4_prep_dev_for_reset()
15153 * lpfc_sli4_prep_dev_for_perm_failure - Prepare SLI4 dev for pci slot disable
15177 * lpfc_io_error_detected_s4 - Method for handling PCI I/O error to SLI-4 device
15182 * with SLI-4 interface spec. This function is called by the PCI subsystem
15189 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
15190 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15196 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s4()
15201 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s4()
15205 hba_pci_err = test_and_set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15215 set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15220 hba_pci_err = test_and_set_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_error_detected_s4()
15232 * lpfc_io_slot_reset_s4 - Method for restart PCI SLI-4 device from scratch
15236 * with SLI-4 interface spec. It is called after PCI bus has been reset to
15237 * restart the PCI card from scratch, as if from a cold-boot. During the
15246 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
15247 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15253 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s4()
15254 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s4()
15258 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s4()
15260 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s4()
15267 hba_pci_err = test_and_clear_bit(HBA_PCI_ERR, &phba->bit_flags); in lpfc_io_slot_reset_s4()
15269 dev_info(&pdev->dev, in lpfc_io_slot_reset_s4()
15277 if (pdev->is_busmaster) in lpfc_io_slot_reset_s4()
15280 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
15281 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s4()
15282 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
15287 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
15290 "2824 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s4()
15294 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s4()
15295 lpfc_cpu_affinity_check(phba, phba->cfg_irq_chann); in lpfc_io_slot_reset_s4()
15298 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
15304 * lpfc_io_resume_s4 - Method for resuming PCI I/O operation to SLI-4 device
15308 * with SLI-4 interface spec. It is called when kernel error recovery tells
15317 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s4()
15325 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) { in lpfc_io_resume_s4()
15334 * lpfc_pci_probe_one - lpfc PCI probe func to reg dev to PCI subsystem
15340 * at PCI device-specific information of the device and driver to see if the
15343 * the action to the proper SLI-3 or SLI-4 device probing routine, which will
15348 * 0 - driver can claim the device
15349 * negative value - driver can not claim the device
15358 return -ENODEV; in lpfc_pci_probe_one()
15370 * lpfc_pci_remove_one - lpfc PCI func to unreg dev from PCI subsystem
15375 * This routine dispatches the action to the proper SLI-3 or SLI-4 device
15383 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_remove_one()
15385 switch (phba->pci_dev_grp) { in lpfc_pci_remove_one()
15395 phba->pci_dev_grp); in lpfc_pci_remove_one()
15402 * lpfc_pci_suspend_one - lpfc PCI func to suspend dev for power management
15407 * the action to the proper SLI-3 or SLI-4 device suspend routine, which will
15411 * 0 - driver suspended the device
15418 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one()
15419 int rc = -ENODEV; in lpfc_pci_suspend_one()
15421 switch (phba->pci_dev_grp) { in lpfc_pci_suspend_one()
15431 phba->pci_dev_grp); in lpfc_pci_suspend_one()
15438 * lpfc_pci_resume_one - lpfc PCI func to resume dev for power management
15443 * the action to the proper SLI-3 or SLI-4 device resume routine, which will
15447 * 0 - driver suspended the device
15454 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one()
15455 int rc = -ENODEV; in lpfc_pci_resume_one()
15457 switch (phba->pci_dev_grp) { in lpfc_pci_resume_one()
15467 phba->pci_dev_grp); in lpfc_pci_resume_one()
15474 * lpfc_io_error_detected - lpfc method for handling PCI I/O error
15481 * the action to the proper SLI-3 or SLI-4 device error detected handling
15485 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
15486 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15492 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected()
15495 if (phba->link_state == LPFC_HBA_ERROR && in lpfc_io_error_detected()
15496 test_bit(HBA_IOQ_FLUSH, &phba->hba_flag)) in lpfc_io_error_detected()
15499 switch (phba->pci_dev_grp) { in lpfc_io_error_detected()
15509 phba->pci_dev_grp); in lpfc_io_error_detected()
15516 * lpfc_io_slot_reset - lpfc method for restart PCI dev from scratch
15521 * from scratch, as if from a cold-boot. When this routine is invoked, it
15522 * dispatches the action to the proper SLI-3 or SLI-4 device reset handling
15526 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
15527 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
15533 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset()
15536 switch (phba->pci_dev_grp) { in lpfc_io_slot_reset()
15546 phba->pci_dev_grp); in lpfc_io_slot_reset()
15553 * lpfc_io_resume - lpfc method for resuming PCI I/O operation
15559 * this routine is invoked, it dispatches the action to the proper SLI-3
15560 * or SLI-4 device io_resume routine, which will resume the device operation.
15566 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume()
15568 switch (phba->pci_dev_grp) { in lpfc_io_resume()
15578 phba->pci_dev_grp); in lpfc_io_resume()
15585 * lpfc_sli4_oas_verify - Verify OAS is supported by this adapter
15598 if (!phba->cfg_EnableXLane) in lpfc_sli4_oas_verify()
15601 if (phba->sli4_hba.pc_sli4_params.oas_supported) { in lpfc_sli4_oas_verify()
15602 phba->cfg_fof = 1; in lpfc_sli4_oas_verify()
15604 phba->cfg_fof = 0; in lpfc_sli4_oas_verify()
15605 mempool_destroy(phba->device_data_mem_pool); in lpfc_sli4_oas_verify()
15606 phba->device_data_mem_pool = NULL; in lpfc_sli4_oas_verify()
15613 * lpfc_sli4_ras_init - Verify RAS-FW log is supported by this adapter
15623 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_ras_init()
15625 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_sli4_ras_init()
15627 phba->ras_fwlog.ras_hwsupport = true; in lpfc_sli4_ras_init()
15628 if (phba->cfg_ras_fwlog_func == PCI_FUNC(phba->pcidev->devfn) && in lpfc_sli4_ras_init()
15629 phba->cfg_ras_fwlog_buffsize) in lpfc_sli4_ras_init()
15630 phba->ras_fwlog.ras_enabled = true; in lpfc_sli4_ras_init()
15632 phba->ras_fwlog.ras_enabled = false; in lpfc_sli4_ras_init()
15634 phba->ras_fwlog.ras_hwsupport = false; in lpfc_sli4_ras_init()
15672 * lpfc_init - lpfc module initialization routine
15679 * 0 - successful
15680 * -ENOMEM - FC attach transport failed
15681 * all others - failed
15696 error = -ENOMEM; in lpfc_init()
15750 if (atomic_cmpxchg(&phba->dbg_log_dmping, 0, 1) != 0) in lpfc_dmp_dbg()
15753 start_idx = (unsigned int)atomic_read(&phba->dbg_log_idx) % DBG_LOG_SZ; in lpfc_dmp_dbg()
15754 dbg_cnt = (unsigned int)atomic_read(&phba->dbg_log_cnt); in lpfc_dmp_dbg()
15760 temp_idx -= 1; in lpfc_dmp_dbg()
15762 if ((start_idx + dbg_cnt) > (DBG_LOG_SZ - 1)) { in lpfc_dmp_dbg()
15766 start_idx = DBG_LOG_SZ - (dbg_cnt - start_idx); in lpfc_dmp_dbg()
15768 start_idx -= dbg_cnt; in lpfc_dmp_dbg()
15771 dev_info(&phba->pcidev->dev, "start %d end %d cnt %d\n", in lpfc_dmp_dbg()
15779 rem_nsec = do_div(phba->dbg_log[temp_idx].t_ns, NSEC_PER_SEC); in lpfc_dmp_dbg()
15780 dev_info(&phba->pcidev->dev, "%d: [%5lu.%06lu] %s", in lpfc_dmp_dbg()
15782 (unsigned long)phba->dbg_log[temp_idx].t_ns, in lpfc_dmp_dbg()
15784 phba->dbg_log[temp_idx].log); in lpfc_dmp_dbg()
15787 atomic_set(&phba->dbg_log_cnt, 0); in lpfc_dmp_dbg()
15788 atomic_set(&phba->dbg_log_dmping, 0); in lpfc_dmp_dbg()
15796 int dbg_dmping = atomic_read(&phba->dbg_log_dmping); in lpfc_dbg_print()
15804 dev_info(&phba->pcidev->dev, "%pV", &vaf); in lpfc_dbg_print()
15808 idx = (unsigned int)atomic_fetch_add(1, &phba->dbg_log_idx) % in lpfc_dbg_print()
15811 atomic_inc(&phba->dbg_log_cnt); in lpfc_dbg_print()
15813 vscnprintf(phba->dbg_log[idx].log, in lpfc_dbg_print()
15814 sizeof(phba->dbg_log[idx].log), fmt, args); in lpfc_dbg_print()
15817 phba->dbg_log[idx].t_ns = local_clock(); in lpfc_dbg_print()
15821 * lpfc_exit - lpfc module removal routine