Lines Matching +full:cpu +full:- +full:centric
4 * Copyright (C) 2017-2019 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>
51 #include <linux/nvme-fc-driver.h>
69 /* Used when mapping IRQ vectors in a driver centric manner */
100 * lpfc_config_port_prep - Perform lpfc initialization prior to config port
109 * 0 - success.
110 * -ERESTART - requests the SLI layer to reset the HBA and try again.
111 * Any other value - indicates an error.
116 lpfc_vpd_t *vp = &phba->vpd; in lpfc_config_port_prep()
126 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_prep()
128 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_prep()
129 return -ENOMEM; in lpfc_config_port_prep()
132 mb = &pmb->u.mb; in lpfc_config_port_prep()
133 phba->link_state = LPFC_INIT_MBX_CMDS; in lpfc_config_port_prep()
135 if (lpfc_is_LC_HBA(phba->pcidev->device)) { in lpfc_config_port_prep()
145 memset((char*)mb->un.varRDnvp.rsvd3, 0, in lpfc_config_port_prep()
146 sizeof (mb->un.varRDnvp.rsvd3)); in lpfc_config_port_prep()
147 memcpy((char*)mb->un.varRDnvp.rsvd3, licensed, in lpfc_config_port_prep()
157 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_prep()
158 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
159 return -ERESTART; in lpfc_config_port_prep()
161 memcpy(phba->wwnn, (char *)mb->un.varRDnvp.nodename, in lpfc_config_port_prep()
162 sizeof(phba->wwnn)); in lpfc_config_port_prep()
163 memcpy(phba->wwpn, (char *)mb->un.varRDnvp.portname, in lpfc_config_port_prep()
164 sizeof(phba->wwpn)); in lpfc_config_port_prep()
171 phba->sli3_options &= (uint32_t)LPFC_SLI3_BG_ENABLED; in lpfc_config_port_prep()
180 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_prep()
181 mempool_free( pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
182 return -ERESTART; in lpfc_config_port_prep()
190 if (mb->un.varRdRev.rr == 0) { in lpfc_config_port_prep()
191 vp->rev.rBit = 0; in lpfc_config_port_prep()
195 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
196 return -ERESTART; in lpfc_config_port_prep()
199 if (phba->sli_rev == 3 && !mb->un.varRdRev.v3rsp) { in lpfc_config_port_prep()
200 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
201 return -EINVAL; in lpfc_config_port_prep()
205 vp->rev.rBit = 1; in lpfc_config_port_prep()
206 memcpy(&vp->sli3Feat, &mb->un.varRdRev.sli3Feat, sizeof(uint32_t)); in lpfc_config_port_prep()
207 vp->rev.sli1FwRev = mb->un.varRdRev.sli1FwRev; in lpfc_config_port_prep()
208 memcpy(vp->rev.sli1FwName, (char*) mb->un.varRdRev.sli1FwName, 16); in lpfc_config_port_prep()
209 vp->rev.sli2FwRev = mb->un.varRdRev.sli2FwRev; in lpfc_config_port_prep()
210 memcpy(vp->rev.sli2FwName, (char *) mb->un.varRdRev.sli2FwName, 16); in lpfc_config_port_prep()
211 vp->rev.biuRev = mb->un.varRdRev.biuRev; in lpfc_config_port_prep()
212 vp->rev.smRev = mb->un.varRdRev.smRev; in lpfc_config_port_prep()
213 vp->rev.smFwRev = mb->un.varRdRev.un.smFwRev; in lpfc_config_port_prep()
214 vp->rev.endecRev = mb->un.varRdRev.endecRev; in lpfc_config_port_prep()
215 vp->rev.fcphHigh = mb->un.varRdRev.fcphHigh; in lpfc_config_port_prep()
216 vp->rev.fcphLow = mb->un.varRdRev.fcphLow; in lpfc_config_port_prep()
217 vp->rev.feaLevelHigh = mb->un.varRdRev.feaLevelHigh; in lpfc_config_port_prep()
218 vp->rev.feaLevelLow = mb->un.varRdRev.feaLevelLow; in lpfc_config_port_prep()
219 vp->rev.postKernRev = mb->un.varRdRev.postKernRev; in lpfc_config_port_prep()
220 vp->rev.opFwRev = mb->un.varRdRev.opFwRev; in lpfc_config_port_prep()
226 if (vp->rev.feaLevelHigh < 9) in lpfc_config_port_prep()
227 phba->sli3_options |= LPFC_SLI3_VPORT_TEARDOWN; in lpfc_config_port_prep()
229 if (lpfc_is_LC_HBA(phba->pcidev->device)) in lpfc_config_port_prep()
230 memcpy(phba->RandomData, (char *)&mb->un.varWords[24], in lpfc_config_port_prep()
231 sizeof (phba->RandomData)); in lpfc_config_port_prep()
245 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_prep()
246 mb->un.varDmp.word_cnt = 0; in lpfc_config_port_prep()
251 if (mb->un.varDmp.word_cnt == 0) in lpfc_config_port_prep()
253 if (mb->un.varDmp.word_cnt > DMP_VPD_SIZE - offset) in lpfc_config_port_prep()
254 mb->un.varDmp.word_cnt = DMP_VPD_SIZE - offset; in lpfc_config_port_prep()
257 mb->un.varDmp.word_cnt); in lpfc_config_port_prep()
258 offset += mb->un.varDmp.word_cnt; in lpfc_config_port_prep()
259 } while (mb->un.varDmp.word_cnt && offset < DMP_VPD_SIZE); in lpfc_config_port_prep()
264 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_prep()
269 * lpfc_config_async_cmpl - Completion handler for config async event mbox cmd
281 if (pmboxq->u.mb.mbxStatus == MBX_SUCCESS) in lpfc_config_async_cmpl()
282 phba->temp_sensor_support = 1; in lpfc_config_async_cmpl()
284 phba->temp_sensor_support = 0; in lpfc_config_async_cmpl()
285 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_config_async_cmpl()
290 * lpfc_dump_wakeup_param_cmpl - dump memory mailbox command completion handler
308 if (pmboxq->u.mb.mbxStatus != MBX_SUCCESS) { in lpfc_dump_wakeup_param_cmpl()
309 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_dump_wakeup_param_cmpl()
316 prog_id_word = pmboxq->u.mb.un.varWords[7]; in lpfc_dump_wakeup_param_cmpl()
319 if (prg->dist < 4) in lpfc_dump_wakeup_param_cmpl()
320 dist = dist_char[prg->dist]; in lpfc_dump_wakeup_param_cmpl()
322 if ((prg->dist == 3) && (prg->num == 0)) in lpfc_dump_wakeup_param_cmpl()
323 snprintf(phba->OptionROMVersion, 32, "%d.%d%d", in lpfc_dump_wakeup_param_cmpl()
324 prg->ver, prg->rev, prg->lev); in lpfc_dump_wakeup_param_cmpl()
326 snprintf(phba->OptionROMVersion, 32, "%d.%d%d%c%d", in lpfc_dump_wakeup_param_cmpl()
327 prg->ver, prg->rev, prg->lev, in lpfc_dump_wakeup_param_cmpl()
328 dist, prg->num); in lpfc_dump_wakeup_param_cmpl()
329 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_dump_wakeup_param_cmpl()
334 * lpfc_update_vport_wwn - Updates the fc_nodename, fc_portname,
345 uint8_t vvvl = vport->fc_sparam.cmn.valid_vendor_ver_level; in lpfc_update_vport_wwn()
346 u32 *fawwpn_key = (u32 *)&vport->fc_sparam.un.vendorVersion[0]; in lpfc_update_vport_wwn()
349 if (vport->phba->cfg_soft_wwnn) in lpfc_update_vport_wwn()
350 u64_to_wwn(vport->phba->cfg_soft_wwnn, in lpfc_update_vport_wwn()
351 vport->fc_sparam.nodeName.u.wwn); in lpfc_update_vport_wwn()
352 if (vport->phba->cfg_soft_wwpn) in lpfc_update_vport_wwn()
353 u64_to_wwn(vport->phba->cfg_soft_wwpn, in lpfc_update_vport_wwn()
354 vport->fc_sparam.portName.u.wwn); in lpfc_update_vport_wwn()
360 if (vport->fc_nodename.u.wwn[0] == 0 || vport->phba->cfg_soft_wwnn) in lpfc_update_vport_wwn()
361 memcpy(&vport->fc_nodename, &vport->fc_sparam.nodeName, in lpfc_update_vport_wwn()
364 memcpy(&vport->fc_sparam.nodeName, &vport->fc_nodename, in lpfc_update_vport_wwn()
371 if (vport->fc_portname.u.wwn[0] != 0 && in lpfc_update_vport_wwn()
372 memcmp(&vport->fc_portname, &vport->fc_sparam.portName, in lpfc_update_vport_wwn()
374 vport->vport_flag |= FAWWPN_PARAM_CHG; in lpfc_update_vport_wwn()
376 if (vport->fc_portname.u.wwn[0] == 0 || in lpfc_update_vport_wwn()
377 vport->phba->cfg_soft_wwpn || in lpfc_update_vport_wwn()
379 vport->vport_flag & FAWWPN_SET) { in lpfc_update_vport_wwn()
380 memcpy(&vport->fc_portname, &vport->fc_sparam.portName, in lpfc_update_vport_wwn()
382 vport->vport_flag &= ~FAWWPN_SET; in lpfc_update_vport_wwn()
384 vport->vport_flag |= FAWWPN_SET; in lpfc_update_vport_wwn()
387 memcpy(&vport->fc_sparam.portName, &vport->fc_portname, in lpfc_update_vport_wwn()
392 * lpfc_config_port_post - Perform lpfc initialization after config port
401 * 0 - success.
402 * Any other value - error.
407 struct lpfc_vport *vport = phba->pport; in lpfc_config_port_post()
412 struct lpfc_sli *psli = &phba->sli; in lpfc_config_port_post()
417 spin_lock_irq(&phba->hbalock); in lpfc_config_port_post()
422 if (phba->over_temp_state == HBA_OVER_TEMP) in lpfc_config_port_post()
423 phba->over_temp_state = HBA_NORMAL_TEMP; in lpfc_config_port_post()
424 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
426 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
428 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
429 return -ENOMEM; in lpfc_config_port_post()
431 mb = &pmb->u.mb; in lpfc_config_port_post()
436 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
437 return -ENOMEM; in lpfc_config_port_post()
440 pmb->vport = vport; in lpfc_config_port_post()
445 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_post()
446 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
447 mp = (struct lpfc_dmabuf *)pmb->ctx_buf; in lpfc_config_port_post()
448 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
449 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_config_port_post()
451 return -EIO; in lpfc_config_port_post()
454 mp = (struct lpfc_dmabuf *)pmb->ctx_buf; in lpfc_config_port_post()
456 memcpy(&vport->fc_sparam, mp->virt, sizeof (struct serv_parm)); in lpfc_config_port_post()
457 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_config_port_post()
459 pmb->ctx_buf = NULL; in lpfc_config_port_post()
463 fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); in lpfc_config_port_post()
464 fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); in lpfc_config_port_post()
465 fc_host_max_npiv_vports(shost) = phba->max_vpi; in lpfc_config_port_post()
468 /* This should be consolidated into parse_vpd ? - mr */ in lpfc_config_port_post()
469 if (phba->SerialNumber[0] == 0) { in lpfc_config_port_post()
472 outptr = &vport->fc_nodename.u.s.IEEE[0]; in lpfc_config_port_post()
477 phba->SerialNumber[i] = in lpfc_config_port_post()
480 phba->SerialNumber[i] = in lpfc_config_port_post()
481 (char)((uint8_t) 0x61 + (uint8_t) (j - 10)); in lpfc_config_port_post()
485 phba->SerialNumber[i] = in lpfc_config_port_post()
488 phba->SerialNumber[i] = in lpfc_config_port_post()
489 (char)((uint8_t) 0x61 + (uint8_t) (j - 10)); in lpfc_config_port_post()
494 pmb->vport = vport; in lpfc_config_port_post()
499 mb->mbxCommand, mb->mbxStatus); in lpfc_config_port_post()
500 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
501 mempool_free( pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
502 return -EIO; in lpfc_config_port_post()
509 i = (mb->un.varRdConfig.max_xri + 1); in lpfc_config_port_post()
510 if (phba->cfg_hba_queue_depth > i) { in lpfc_config_port_post()
513 phba->cfg_hba_queue_depth, i); in lpfc_config_port_post()
514 phba->cfg_hba_queue_depth = i; in lpfc_config_port_post()
518 i = (mb->un.varRdConfig.max_xri >> 3); in lpfc_config_port_post()
519 if (phba->pport->cfg_lun_queue_depth > i) { in lpfc_config_port_post()
522 phba->pport->cfg_lun_queue_depth, i); in lpfc_config_port_post()
523 phba->pport->cfg_lun_queue_depth = i; in lpfc_config_port_post()
526 phba->lmt = mb->un.varRdConfig.lmt; in lpfc_config_port_post()
529 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_config_port_post()
531 phba->link_state = LPFC_LINK_DOWN; in lpfc_config_port_post()
534 if (psli->sli3_ring[LPFC_EXTRA_RING].sli.sli3.cmdringaddr) in lpfc_config_port_post()
535 psli->sli3_ring[LPFC_EXTRA_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_config_port_post()
536 if (psli->sli3_ring[LPFC_FCP_RING].sli.sli3.cmdringaddr) in lpfc_config_port_post()
537 psli->sli3_ring[LPFC_FCP_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_config_port_post()
540 if (phba->sli_rev != 3) in lpfc_config_port_post()
544 * Configure HBA MSI-X attention conditions to messages if MSI-X mode in lpfc_config_port_post()
546 if (phba->intr_type == MSIX) { in lpfc_config_port_post()
549 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
550 return -EIO; in lpfc_config_port_post()
557 pmb->u.mb.mbxCommand, in lpfc_config_port_post()
558 pmb->u.mb.mbxStatus); in lpfc_config_port_post()
559 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
560 return -EIO; in lpfc_config_port_post()
564 spin_lock_irq(&phba->hbalock); in lpfc_config_port_post()
566 phba->hba_flag &= ~HBA_ERATT_HANDLED; in lpfc_config_port_post()
569 if (lpfc_readl(phba->HCregaddr, &status)) { in lpfc_config_port_post()
570 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
571 return -EIO; in lpfc_config_port_post()
574 if (psli->num_rings > 0) in lpfc_config_port_post()
576 if (psli->num_rings > 1) in lpfc_config_port_post()
578 if (psli->num_rings > 2) in lpfc_config_port_post()
580 if (psli->num_rings > 3) in lpfc_config_port_post()
583 if ((phba->cfg_poll & ENABLE_FCP_RING_POLLING) && in lpfc_config_port_post()
584 (phba->cfg_poll & DISABLE_FCP_RING_INT)) in lpfc_config_port_post()
587 writel(status, phba->HCregaddr); in lpfc_config_port_post()
588 readl(phba->HCregaddr); /* flush */ in lpfc_config_port_post()
589 spin_unlock_irq(&phba->hbalock); in lpfc_config_port_post()
591 /* Set up ring-0 (ELS) timer */ in lpfc_config_port_post()
592 timeout = phba->fc_ratov * 2; in lpfc_config_port_post()
593 mod_timer(&vport->els_tmofunc, in lpfc_config_port_post()
596 mod_timer(&phba->hb_tmofunc, in lpfc_config_port_post()
598 phba->hb_outstanding = 0; in lpfc_config_port_post()
599 phba->last_completion_time = jiffies; in lpfc_config_port_post()
601 mod_timer(&phba->eratt_poll, in lpfc_config_port_post()
602 jiffies + msecs_to_jiffies(1000 * phba->eratt_poll_interval)); in lpfc_config_port_post()
604 if (phba->hba_flag & LINK_DISABLED) { in lpfc_config_port_post()
609 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_config_port_post()
617 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
618 return -EIO; in lpfc_config_port_post()
620 } else if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) { in lpfc_config_port_post()
621 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
622 rc = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); in lpfc_config_port_post()
627 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
629 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
630 return -ENOMEM; in lpfc_config_port_post()
634 pmb->mbox_cmpl = lpfc_config_async_cmpl; in lpfc_config_port_post()
635 pmb->vport = phba->pport; in lpfc_config_port_post()
645 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
649 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_port_post()
651 phba->link_state = LPFC_HBA_ERROR; in lpfc_config_port_post()
652 return -ENOMEM; in lpfc_config_port_post()
656 pmb->mbox_cmpl = lpfc_dump_wakeup_param_cmpl; in lpfc_config_port_post()
657 pmb->vport = phba->pport; in lpfc_config_port_post()
663 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_config_port_post()
670 * lpfc_hba_init_link - Initialize the FC link
672 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
680 * 0 - success
681 * Any other value - error
686 return lpfc_hba_init_link_fc_topology(phba, phba->cfg_topology, flag); in lpfc_hba_init_link()
690 * lpfc_hba_init_link_fc_topology - Initialize FC link with desired topology
693 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
701 * 0 - success
702 * Any other value - error
708 struct lpfc_vport *vport = phba->pport; in lpfc_hba_init_link_fc_topology()
713 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_hba_init_link_fc_topology()
715 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_init_link_fc_topology()
716 return -ENOMEM; in lpfc_hba_init_link_fc_topology()
718 mb = &pmb->u.mb; in lpfc_hba_init_link_fc_topology()
719 pmb->vport = vport; in lpfc_hba_init_link_fc_topology()
721 if ((phba->cfg_link_speed > LPFC_USER_LINK_SPEED_MAX) || in lpfc_hba_init_link_fc_topology()
722 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_1G) && in lpfc_hba_init_link_fc_topology()
723 !(phba->lmt & LMT_1Gb)) || in lpfc_hba_init_link_fc_topology()
724 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_2G) && in lpfc_hba_init_link_fc_topology()
725 !(phba->lmt & LMT_2Gb)) || in lpfc_hba_init_link_fc_topology()
726 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_4G) && in lpfc_hba_init_link_fc_topology()
727 !(phba->lmt & LMT_4Gb)) || in lpfc_hba_init_link_fc_topology()
728 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_8G) && in lpfc_hba_init_link_fc_topology()
729 !(phba->lmt & LMT_8Gb)) || in lpfc_hba_init_link_fc_topology()
730 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_10G) && in lpfc_hba_init_link_fc_topology()
731 !(phba->lmt & LMT_10Gb)) || in lpfc_hba_init_link_fc_topology()
732 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_16G) && in lpfc_hba_init_link_fc_topology()
733 !(phba->lmt & LMT_16Gb)) || in lpfc_hba_init_link_fc_topology()
734 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_32G) && in lpfc_hba_init_link_fc_topology()
735 !(phba->lmt & LMT_32Gb)) || in lpfc_hba_init_link_fc_topology()
736 ((phba->cfg_link_speed == LPFC_USER_LINK_SPEED_64G) && in lpfc_hba_init_link_fc_topology()
737 !(phba->lmt & LMT_64Gb))) { in lpfc_hba_init_link_fc_topology()
742 phba->cfg_link_speed); in lpfc_hba_init_link_fc_topology()
743 phba->cfg_link_speed = LPFC_USER_LINK_SPEED_AUTO; in lpfc_hba_init_link_fc_topology()
745 lpfc_init_link(phba, pmb, fc_topology, phba->cfg_link_speed); in lpfc_hba_init_link_fc_topology()
746 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_hba_init_link_fc_topology()
747 if (phba->sli_rev < LPFC_SLI_REV4) in lpfc_hba_init_link_fc_topology()
754 mb->mbxCommand, mb->mbxStatus); in lpfc_hba_init_link_fc_topology()
755 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_hba_init_link_fc_topology()
757 writel(0, phba->HCregaddr); in lpfc_hba_init_link_fc_topology()
758 readl(phba->HCregaddr); /* flush */ in lpfc_hba_init_link_fc_topology()
760 writel(0xffffffff, phba->HAregaddr); in lpfc_hba_init_link_fc_topology()
761 readl(phba->HAregaddr); /* flush */ in lpfc_hba_init_link_fc_topology()
763 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_init_link_fc_topology()
765 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_init_link_fc_topology()
766 return -EIO; in lpfc_hba_init_link_fc_topology()
768 phba->cfg_suppress_link_up = LPFC_INITIALIZE_LINK; in lpfc_hba_init_link_fc_topology()
770 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_init_link_fc_topology()
776 * lpfc_hba_down_link - this routine downs the FC link
778 * @flag: mailbox command issue mode - either MBX_POLL or MBX_NOWAIT
785 * 0 - success
786 * Any other value - error
794 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_hba_down_link()
796 phba->link_state = LPFC_HBA_ERROR; in lpfc_hba_down_link()
797 return -ENOMEM; in lpfc_hba_down_link()
804 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_hba_down_link()
812 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_down_link()
813 return -EIO; in lpfc_hba_down_link()
816 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_hba_down_link()
822 * lpfc_hba_down_prep - Perform lpfc uninitialization prior to HBA reset
829 * 0 - success.
830 * Any other value - error.
838 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_hba_down_prep()
840 writel(0, phba->HCregaddr); in lpfc_hba_down_prep()
841 readl(phba->HCregaddr); /* flush */ in lpfc_hba_down_prep()
844 if (phba->pport->load_flag & FC_UNLOADING) in lpfc_hba_down_prep()
845 lpfc_cleanup_discovery_resources(phba->pport); in lpfc_hba_down_prep()
849 for (i = 0; i <= phba->max_vports && in lpfc_hba_down_prep()
858 * lpfc_sli4_free_sp_events - Cleanup sp_queue_events to free
877 spin_lock_irq(&phba->hbalock); in lpfc_sli4_free_sp_events()
878 phba->hba_flag &= ~HBA_SP_QUEUE_EVT; in lpfc_sli4_free_sp_events()
879 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_free_sp_events()
881 while (!list_empty(&phba->sli4_hba.sp_queue_event)) { in lpfc_sli4_free_sp_events()
883 spin_lock_irq(&phba->hbalock); in lpfc_sli4_free_sp_events()
884 list_remove_head(&phba->sli4_hba.sp_queue_event, in lpfc_sli4_free_sp_events()
886 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_free_sp_events()
888 switch (bf_get(lpfc_wcqe_c_code, &cq_event->cqe.wcqe_cmpl)) { in lpfc_sli4_free_sp_events()
898 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_free_sp_events()
904 * lpfc_hba_free_post_buf - Perform lpfc uninitialization after HBA reset
917 struct lpfc_sli *psli = &phba->sli; in lpfc_hba_free_post_buf()
923 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) in lpfc_hba_free_post_buf()
927 pring = &psli->sli3_ring[LPFC_ELS_RING]; in lpfc_hba_free_post_buf()
928 spin_lock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
929 list_splice_init(&pring->postbufq, &buflist); in lpfc_hba_free_post_buf()
930 spin_unlock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
934 list_del(&mp->list); in lpfc_hba_free_post_buf()
936 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_hba_free_post_buf()
940 spin_lock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
941 pring->postbufq_cnt -= count; in lpfc_hba_free_post_buf()
942 spin_unlock_irq(&phba->hbalock); in lpfc_hba_free_post_buf()
947 * lpfc_hba_clean_txcmplq - Perform lpfc uninitialization after HBA reset
959 struct lpfc_sli *psli = &phba->sli; in lpfc_hba_clean_txcmplq()
966 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_hba_clean_txcmplq()
967 for (i = 0; i < psli->num_rings; i++) { in lpfc_hba_clean_txcmplq()
968 pring = &psli->sli3_ring[i]; in lpfc_hba_clean_txcmplq()
969 spin_lock_irq(&phba->hbalock); in lpfc_hba_clean_txcmplq()
974 list_splice_init(&pring->txcmplq, &completions); in lpfc_hba_clean_txcmplq()
975 pring->txcmplq_cnt = 0; in lpfc_hba_clean_txcmplq()
976 spin_unlock_irq(&phba->hbalock); in lpfc_hba_clean_txcmplq()
985 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_hba_clean_txcmplq()
986 pring = qp->pring; in lpfc_hba_clean_txcmplq()
989 spin_lock_irq(&pring->ring_lock); in lpfc_hba_clean_txcmplq()
991 &pring->txcmplq, list) in lpfc_hba_clean_txcmplq()
992 piocb->iocb_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_hba_clean_txcmplq()
993 list_splice_init(&pring->txcmplq, &completions); in lpfc_hba_clean_txcmplq()
994 pring->txcmplq_cnt = 0; in lpfc_hba_clean_txcmplq()
995 spin_unlock_irq(&pring->ring_lock); in lpfc_hba_clean_txcmplq()
1004 * lpfc_hba_down_post_s3 - Perform lpfc uninitialization after HBA reset
1012 * 0 - success.
1013 * Any other value - error.
1024 * lpfc_hba_down_post_s4 - Perform lpfc uninitialization after HBA reset
1031 * 0 - success.
1032 * Any other value - error.
1056 spin_lock_irq(&phba->hbalock); /* required for lpfc_els_sgl_list and */ in lpfc_hba_down_post_s4()
1061 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_hba_down_post_s4()
1063 &phba->sli4_hba.lpfc_abts_els_sgl_list, list) in lpfc_hba_down_post_s4()
1064 sglq_entry->state = SGL_FREED; in lpfc_hba_down_post_s4()
1066 list_splice_init(&phba->sli4_hba.lpfc_abts_els_sgl_list, in lpfc_hba_down_post_s4()
1067 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_hba_down_post_s4()
1070 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_hba_down_post_s4()
1076 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_hba_down_post_s4()
1077 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_hba_down_post_s4()
1079 spin_lock(&qp->abts_io_buf_list_lock); in lpfc_hba_down_post_s4()
1080 list_splice_init(&qp->lpfc_abts_io_buf_list, in lpfc_hba_down_post_s4()
1084 psb->pCmd = NULL; in lpfc_hba_down_post_s4()
1085 psb->status = IOSTAT_SUCCESS; in lpfc_hba_down_post_s4()
1088 spin_lock(&qp->io_buf_list_put_lock); in lpfc_hba_down_post_s4()
1089 list_splice_init(&aborts, &qp->lpfc_io_buf_list_put); in lpfc_hba_down_post_s4()
1090 qp->put_io_bufs += qp->abts_scsi_io_bufs; in lpfc_hba_down_post_s4()
1091 qp->put_io_bufs += qp->abts_nvme_io_bufs; in lpfc_hba_down_post_s4()
1092 qp->abts_scsi_io_bufs = 0; in lpfc_hba_down_post_s4()
1093 qp->abts_nvme_io_bufs = 0; in lpfc_hba_down_post_s4()
1094 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_hba_down_post_s4()
1095 spin_unlock(&qp->abts_io_buf_list_lock); in lpfc_hba_down_post_s4()
1097 spin_unlock_irq(&phba->hbalock); in lpfc_hba_down_post_s4()
1099 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_hba_down_post_s4()
1100 spin_lock_irq(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_hba_down_post_s4()
1101 list_splice_init(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list, in lpfc_hba_down_post_s4()
1103 spin_unlock_irq(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_hba_down_post_s4()
1105 ctxp->flag &= ~(LPFC_NVMET_XBUSY | LPFC_NVMET_ABORT_OP); in lpfc_hba_down_post_s4()
1106 lpfc_nvmet_ctxbuf_post(phba, ctxp->ctxbuf); in lpfc_hba_down_post_s4()
1115 * lpfc_hba_down_post - Wrapper func for hba down post routine
1122 * 0 - success.
1123 * Any other value - error.
1128 return (*phba->lpfc_hba_down_post)(phba); in lpfc_hba_down_post()
1132 * lpfc_hb_timeout - The HBA-timer timeout handler
1135 * This is the HBA-timer timeout handler registered to the lpfc driver. When
1137 * work-port-events bitmap and the worker thread is notified. This timeout
1153 spin_lock_irqsave(&phba->pport->work_port_lock, iflag); in lpfc_hb_timeout()
1154 tmo_posted = phba->pport->work_port_events & WORKER_HB_TMO; in lpfc_hb_timeout()
1156 phba->pport->work_port_events |= WORKER_HB_TMO; in lpfc_hb_timeout()
1157 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); in lpfc_hb_timeout()
1166 * lpfc_rrq_timeout - The RRQ-timer timeout handler
1169 * This is the RRQ-timer timeout handler registered to the lpfc driver. When
1171 * work-port-events bitmap and the worker thread is notified. This timeout
1184 spin_lock_irqsave(&phba->pport->work_port_lock, iflag); in lpfc_rrq_timeout()
1185 if (!(phba->pport->load_flag & FC_UNLOADING)) in lpfc_rrq_timeout()
1186 phba->hba_flag |= HBA_RRQ_ACTIVE; in lpfc_rrq_timeout()
1188 phba->hba_flag &= ~HBA_RRQ_ACTIVE; in lpfc_rrq_timeout()
1189 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); in lpfc_rrq_timeout()
1191 if (!(phba->pport->load_flag & FC_UNLOADING)) in lpfc_rrq_timeout()
1196 * lpfc_hb_mbox_cmpl - The lpfc heart-beat mailbox command callback function
1200 * This is the callback function to the lpfc heart-beat mailbox command.
1201 * If configured, the lpfc driver issues the heart-beat mailbox command to
1203 * heart-beat mailbox command is issued, the driver shall set up heart-beat
1205 * heart-beat outstanding state. Once the mailbox command comes back and
1206 * no error conditions detected, the heart-beat mailbox command timer is
1207 * reset to LPFC_HB_MBOX_INTERVAL seconds and the heart-beat outstanding
1208 * state is cleared for the next heart-beat. If the timer expired with the
1209 * heart-beat outstanding state set, the driver will put the HBA offline.
1216 spin_lock_irqsave(&phba->hbalock, drvr_flag); in lpfc_hb_mbox_cmpl()
1217 phba->hb_outstanding = 0; in lpfc_hb_mbox_cmpl()
1218 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_hb_mbox_cmpl()
1220 /* Check and reset heart-beat timer is necessary */ in lpfc_hb_mbox_cmpl()
1221 mempool_free(pmboxq, phba->mbox_mem_pool); in lpfc_hb_mbox_cmpl()
1222 if (!(phba->pport->fc_flag & FC_OFFLINE_MODE) && in lpfc_hb_mbox_cmpl()
1223 !(phba->link_state == LPFC_HBA_ERROR) && in lpfc_hb_mbox_cmpl()
1224 !(phba->pport->load_flag & FC_UNLOADING)) in lpfc_hb_mbox_cmpl()
1225 mod_timer(&phba->hb_tmofunc, in lpfc_hb_mbox_cmpl()
1243 if (!phba->cfg_auto_imax || phba->pport->load_flag & FC_UNLOADING) in lpfc_hb_eq_delay_work()
1246 if (phba->link_state == LPFC_HBA_ERROR || in lpfc_hb_eq_delay_work()
1247 phba->pport->fc_flag & FC_OFFLINE_MODE) in lpfc_hb_eq_delay_work()
1255 if (phba->cfg_irq_chann > 1) { in lpfc_hb_eq_delay_work()
1257 for (i = 0; i < phba->cfg_irq_chann; i++) { in lpfc_hb_eq_delay_work()
1259 eq = phba->sli4_hba.hba_eq_hdl[i].eq; in lpfc_hb_eq_delay_work()
1262 if (eq->q_mode) { in lpfc_hb_eq_delay_work()
1266 if (eqcnt[eq->last_cpu] < 2) in lpfc_hb_eq_delay_work()
1267 eqcnt[eq->last_cpu]++; in lpfc_hb_eq_delay_work()
1273 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, i); in lpfc_hb_eq_delay_work()
1275 eqi->icnt = 0; in lpfc_hb_eq_delay_work()
1279 usdelay = (eqi->icnt / LPFC_IMAX_THRESHOLD) * in lpfc_hb_eq_delay_work()
1284 eqi->icnt = 0; in lpfc_hb_eq_delay_work()
1286 list_for_each_entry_safe(eq, eq_next, &eqi->list, cpu_list) { in lpfc_hb_eq_delay_work()
1287 if (eq->last_cpu != i) { in lpfc_hb_eq_delay_work()
1288 eqi_new = per_cpu_ptr(phba->sli4_hba.eq_info, in lpfc_hb_eq_delay_work()
1289 eq->last_cpu); in lpfc_hb_eq_delay_work()
1290 list_move_tail(&eq->cpu_list, &eqi_new->list); in lpfc_hb_eq_delay_work()
1293 if (usdelay != eq->q_mode) in lpfc_hb_eq_delay_work()
1294 lpfc_modify_hba_eq_delay(phba, eq->hdwq, 1, in lpfc_hb_eq_delay_work()
1302 queue_delayed_work(phba->wq, &phba->eq_delay_work, in lpfc_hb_eq_delay_work()
1307 * lpfc_hb_mxp_handler - Multi-XRI pools handler to adjust XRI distribution
1318 hwq_count = phba->cfg_hdw_queue; in lpfc_hb_mxp_handler()
1334 * lpfc_hb_timeout_handler - The HBA-timer timeout handler
1337 * This is the actual HBA-timer timeout handler to be invoked by the worker
1338 * thread whenever the HBA timer fired and HBA-timeout event posted. This
1341 * or by processing slow-ring or fast-ring events within the HBA-timer
1343 * the timer for the next timeout period. If lpfc heart-beat mailbox command
1344 * is configured and there is no heart-beat mailbox command outstanding, a
1345 * heart-beat mailbox is issued and timer set properly. Otherwise, if there
1346 * has been a heart-beat mailbox command outstanding, the HBA shall be put
1356 struct lpfc_sli *psli = &phba->sli; in lpfc_hb_timeout_handler()
1359 if (phba->cfg_xri_rebalancing) { in lpfc_hb_timeout_handler()
1360 /* Multi-XRI pools handler */ in lpfc_hb_timeout_handler()
1366 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_hb_timeout_handler()
1372 if ((phba->link_state == LPFC_HBA_ERROR) || in lpfc_hb_timeout_handler()
1373 (phba->pport->load_flag & FC_UNLOADING) || in lpfc_hb_timeout_handler()
1374 (phba->pport->fc_flag & FC_OFFLINE_MODE)) in lpfc_hb_timeout_handler()
1377 spin_lock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1379 if (time_after(phba->last_completion_time + in lpfc_hb_timeout_handler()
1382 spin_unlock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1383 if (!phba->hb_outstanding) in lpfc_hb_timeout_handler()
1384 mod_timer(&phba->hb_tmofunc, in lpfc_hb_timeout_handler()
1388 mod_timer(&phba->hb_tmofunc, in lpfc_hb_timeout_handler()
1393 spin_unlock_irq(&phba->pport->work_port_lock); in lpfc_hb_timeout_handler()
1395 if (phba->elsbuf_cnt && in lpfc_hb_timeout_handler()
1396 (phba->elsbuf_cnt == phba->elsbuf_prev_cnt)) { in lpfc_hb_timeout_handler()
1397 spin_lock_irq(&phba->hbalock); in lpfc_hb_timeout_handler()
1398 list_splice_init(&phba->elsbuf, &completions); in lpfc_hb_timeout_handler()
1399 phba->elsbuf_cnt = 0; in lpfc_hb_timeout_handler()
1400 phba->elsbuf_prev_cnt = 0; in lpfc_hb_timeout_handler()
1401 spin_unlock_irq(&phba->hbalock); in lpfc_hb_timeout_handler()
1406 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); in lpfc_hb_timeout_handler()
1410 phba->elsbuf_prev_cnt = phba->elsbuf_cnt; in lpfc_hb_timeout_handler()
1413 if (phba->cfg_enable_hba_heartbeat) { in lpfc_hb_timeout_handler()
1414 if (!phba->hb_outstanding) { in lpfc_hb_timeout_handler()
1415 if ((!(psli->sli_flag & LPFC_SLI_MBOX_ACTIVE)) && in lpfc_hb_timeout_handler()
1416 (list_empty(&psli->mboxq))) { in lpfc_hb_timeout_handler()
1417 pmboxq = mempool_alloc(phba->mbox_mem_pool, in lpfc_hb_timeout_handler()
1420 mod_timer(&phba->hb_tmofunc, in lpfc_hb_timeout_handler()
1428 pmboxq->mbox_cmpl = lpfc_hb_mbox_cmpl; in lpfc_hb_timeout_handler()
1429 pmboxq->vport = phba->pport; in lpfc_hb_timeout_handler()
1436 phba->mbox_mem_pool); in lpfc_hb_timeout_handler()
1437 mod_timer(&phba->hb_tmofunc, in lpfc_hb_timeout_handler()
1443 phba->skipped_hb = 0; in lpfc_hb_timeout_handler()
1444 phba->hb_outstanding = 1; in lpfc_hb_timeout_handler()
1445 } else if (time_before_eq(phba->last_completion_time, in lpfc_hb_timeout_handler()
1446 phba->skipped_hb)) { in lpfc_hb_timeout_handler()
1451 - phba->last_completion_time)); in lpfc_hb_timeout_handler()
1453 phba->skipped_hb = jiffies; in lpfc_hb_timeout_handler()
1455 mod_timer(&phba->hb_tmofunc, in lpfc_hb_timeout_handler()
1469 - phba->last_completion_time)); in lpfc_hb_timeout_handler()
1470 mod_timer(&phba->hb_tmofunc, in lpfc_hb_timeout_handler()
1475 mod_timer(&phba->hb_tmofunc, in lpfc_hb_timeout_handler()
1482 * lpfc_offline_eratt - Bring lpfc offline on hardware error attention
1491 struct lpfc_sli *psli = &phba->sli; in lpfc_offline_eratt()
1493 spin_lock_irq(&phba->hbalock); in lpfc_offline_eratt()
1494 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_offline_eratt()
1495 spin_unlock_irq(&phba->hbalock); in lpfc_offline_eratt()
1500 spin_lock_irq(&phba->hbalock); in lpfc_offline_eratt()
1502 spin_unlock_irq(&phba->hbalock); in lpfc_offline_eratt()
1506 phba->link_state = LPFC_HBA_ERROR; in lpfc_offline_eratt()
1511 * lpfc_sli4_offline_eratt - Bring lpfc offline on SLI4 hardware error attention
1520 spin_lock_irq(&phba->hbalock); in lpfc_sli4_offline_eratt()
1521 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli4_offline_eratt()
1522 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_offline_eratt()
1532 * lpfc_handle_deferred_eratt - The HBA hardware deferred error handler
1543 uint32_t old_host_status = phba->work_hs; in lpfc_handle_deferred_eratt()
1544 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_deferred_eratt()
1549 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_deferred_eratt()
1550 spin_lock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1551 phba->hba_flag &= ~DEFER_ERATT; in lpfc_handle_deferred_eratt()
1552 spin_unlock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1559 phba->work_hs, in lpfc_handle_deferred_eratt()
1560 phba->work_status[0], phba->work_status[1]); in lpfc_handle_deferred_eratt()
1562 spin_lock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1563 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_handle_deferred_eratt()
1564 spin_unlock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1570 * SCSI layer retry it after re-establishing link. in lpfc_handle_deferred_eratt()
1582 while (phba->work_hs & HS_FFER1) { in lpfc_handle_deferred_eratt()
1584 if (lpfc_readl(phba->HSregaddr, &phba->work_hs)) { in lpfc_handle_deferred_eratt()
1585 phba->work_hs = UNPLUG_ERR ; in lpfc_handle_deferred_eratt()
1589 if (phba->pport->load_flag & FC_UNLOADING) { in lpfc_handle_deferred_eratt()
1590 phba->work_hs = 0; in lpfc_handle_deferred_eratt()
1600 if ((!phba->work_hs) && (!(phba->pport->load_flag & FC_UNLOADING))) in lpfc_handle_deferred_eratt()
1601 phba->work_hs = old_host_status & ~HS_FFER1; in lpfc_handle_deferred_eratt()
1603 spin_lock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1604 phba->hba_flag &= ~DEFER_ERATT; in lpfc_handle_deferred_eratt()
1605 spin_unlock_irq(&phba->hbalock); in lpfc_handle_deferred_eratt()
1606 phba->work_status[0] = readl(phba->MBslimaddr + 0xa8); in lpfc_handle_deferred_eratt()
1607 phba->work_status[1] = readl(phba->MBslimaddr + 0xac); in lpfc_handle_deferred_eratt()
1618 shost = lpfc_shost_from_vport(phba->pport); in lpfc_board_errevt_to_mgmt()
1626 * lpfc_handle_eratt_s3 - The SLI3 HBA hardware error handler
1631 * 1 - HBA error attention interrupt
1632 * 2 - DMA ring index out of range
1633 * 3 - Mailbox command came back as unknown
1638 struct lpfc_vport *vport = phba->pport; in lpfc_handle_eratt_s3()
1639 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_eratt_s3()
1648 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_eratt_s3()
1649 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1650 phba->hba_flag &= ~DEFER_ERATT; in lpfc_handle_eratt_s3()
1651 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1656 if (!phba->cfg_enable_hba_reset) in lpfc_handle_eratt_s3()
1662 if (phba->hba_flag & DEFER_ERATT) in lpfc_handle_eratt_s3()
1665 if ((phba->work_hs & HS_FFER6) || (phba->work_hs & HS_FFER8)) { in lpfc_handle_eratt_s3()
1666 if (phba->work_hs & HS_FFER6) in lpfc_handle_eratt_s3()
1667 /* Re-establishing Link */ in lpfc_handle_eratt_s3()
1669 "1301 Re-establishing Link " in lpfc_handle_eratt_s3()
1671 phba->work_hs, phba->work_status[0], in lpfc_handle_eratt_s3()
1672 phba->work_status[1]); in lpfc_handle_eratt_s3()
1673 if (phba->work_hs & HS_FFER8) in lpfc_handle_eratt_s3()
1678 phba->work_hs, phba->work_status[0], in lpfc_handle_eratt_s3()
1679 phba->work_status[1]); in lpfc_handle_eratt_s3()
1681 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1682 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_handle_eratt_s3()
1683 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1689 * retry it after re-establishing link. in lpfc_handle_eratt_s3()
1705 } else if (phba->work_hs & HS_CRIT_TEMP) { in lpfc_handle_eratt_s3()
1706 temperature = readl(phba->MBslimaddr + TEMPERATURE_OFFSET); in lpfc_handle_eratt_s3()
1715 temperature, phba->work_hs, in lpfc_handle_eratt_s3()
1716 phba->work_status[0], phba->work_status[1]); in lpfc_handle_eratt_s3()
1718 shost = lpfc_shost_from_vport(phba->pport); in lpfc_handle_eratt_s3()
1725 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1726 phba->over_temp_state = HBA_OVER_TEMP; in lpfc_handle_eratt_s3()
1727 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s3()
1738 phba->work_hs, in lpfc_handle_eratt_s3()
1739 phba->work_status[0], phba->work_status[1]); in lpfc_handle_eratt_s3()
1753 * lpfc_sli4_port_sta_fn_reset - The SLI4 function reset due to port status reg
1770 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_port_sta_fn_reset()
1798 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_sli4_port_sta_fn_reset()
1802 return -EIO; in lpfc_sli4_port_sta_fn_reset()
1804 phba->intr_mode = intr_mode; in lpfc_sli4_port_sta_fn_reset()
1813 * lpfc_handle_eratt_s4 - The SLI4 HBA hardware error handler
1822 struct lpfc_vport *vport = phba->pport; in lpfc_handle_eratt_s4()
1838 if (pci_channel_offline(phba->pcidev)) { in lpfc_handle_eratt_s4()
1846 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_handle_eratt_s4()
1850 phba->sli4_hba.u.if_type0.UERRLOregaddr, in lpfc_handle_eratt_s4()
1853 phba->sli4_hba.u.if_type0.UEMASKLOregaddr, in lpfc_handle_eratt_s4()
1856 if (pci_rd_rc1 == -EIO && pci_rd_rc2 == -EIO) in lpfc_handle_eratt_s4()
1858 if (!(phba->hba_flag & HBA_RECOVERABLE_UE)) { in lpfc_handle_eratt_s4()
1865 for (i = 0; i < phba->sli4_hba.ue_to_sr / 1000; i++) { in lpfc_handle_eratt_s4()
1866 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_handle_eratt_s4()
1888 if (!lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_handle_eratt_s4()
1907 phba->link_state = LPFC_HBA_ERROR; in lpfc_handle_eratt_s4()
1913 phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_handle_eratt_s4()
1916 if (pci_rd_rc1 == -EIO) { in lpfc_handle_eratt_s4()
1919 readl(phba->sli4_hba.u.if_type2.STATUSregaddr)); in lpfc_handle_eratt_s4()
1923 reg_err1 = readl(phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_handle_eratt_s4()
1924 reg_err2 = readl(phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_handle_eratt_s4()
1931 phba->sfp_alarm |= LPFC_TRANSGRESSION_HIGH_TEMPERATURE; in lpfc_handle_eratt_s4()
1936 shost = lpfc_shost_from_vport(phba->pport); in lpfc_handle_eratt_s4()
1943 spin_lock_irq(&phba->hbalock); in lpfc_handle_eratt_s4()
1944 phba->over_temp_state = HBA_OVER_TEMP; in lpfc_handle_eratt_s4()
1945 spin_unlock_irq(&phba->hbalock); in lpfc_handle_eratt_s4()
1965 if (!phba->cfg_enable_hba_reset) in lpfc_handle_eratt_s4()
1982 phba->link_state = LPFC_HBA_ERROR; in lpfc_handle_eratt_s4()
2001 * lpfc_handle_eratt - Wrapper func for handling hba error attention
2008 * 0 - success.
2009 * Any other value - error.
2014 (*phba->lpfc_handle_eratt)(phba); in lpfc_handle_eratt()
2018 * lpfc_handle_latt - The HBA link event handler
2027 struct lpfc_vport *vport = phba->pport; in lpfc_handle_latt()
2028 struct lpfc_sli *psli = &phba->sli; in lpfc_handle_latt()
2034 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_handle_latt()
2046 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); in lpfc_handle_latt()
2047 if (!mp->virt) { in lpfc_handle_latt()
2055 psli->slistat.link_event++; in lpfc_handle_latt()
2057 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_handle_latt()
2058 pmb->vport = vport; in lpfc_handle_latt()
2060 phba->sli.sli3_ring[LPFC_ELS_RING].flag |= LPFC_STOP_IOCB_EVENT; in lpfc_handle_latt()
2068 spin_lock_irq(&phba->hbalock); in lpfc_handle_latt()
2069 writel(HA_LATT, phba->HAregaddr); in lpfc_handle_latt()
2070 readl(phba->HAregaddr); /* flush */ in lpfc_handle_latt()
2071 spin_unlock_irq(&phba->hbalock); in lpfc_handle_latt()
2076 phba->sli.sli3_ring[LPFC_ELS_RING].flag &= ~LPFC_STOP_IOCB_EVENT; in lpfc_handle_latt()
2077 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_handle_latt()
2081 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_handle_latt()
2084 spin_lock_irq(&phba->hbalock); in lpfc_handle_latt()
2085 psli->sli_flag |= LPFC_PROCESS_LA; in lpfc_handle_latt()
2086 control = readl(phba->HCregaddr); in lpfc_handle_latt()
2088 writel(control, phba->HCregaddr); in lpfc_handle_latt()
2089 readl(phba->HCregaddr); /* flush */ in lpfc_handle_latt()
2092 writel(HA_LATT, phba->HAregaddr); in lpfc_handle_latt()
2093 readl(phba->HAregaddr); /* flush */ in lpfc_handle_latt()
2094 spin_unlock_irq(&phba->hbalock); in lpfc_handle_latt()
2096 phba->link_state = LPFC_HBA_ERROR; in lpfc_handle_latt()
2105 * lpfc_parse_vpd - Parse VPD (Vital Product Data)
2115 * 0 - pointer to the VPD passed in is NULL
2116 * 1 - success
2135 while (!finished && (index < (len - 4))) { in lpfc_parse_vpd()
2154 if (Length > len - index) in lpfc_parse_vpd()
2155 Length = len - index; in lpfc_parse_vpd()
2163 Length -= (3+i); in lpfc_parse_vpd()
2164 while(i--) { in lpfc_parse_vpd()
2165 phba->SerialNumber[j++] = vpd[index++]; in lpfc_parse_vpd()
2169 phba->SerialNumber[j] = 0; in lpfc_parse_vpd()
2173 phba->vpd_flag |= VPD_MODEL_DESC; in lpfc_parse_vpd()
2178 Length -= (3+i); in lpfc_parse_vpd()
2179 while(i--) { in lpfc_parse_vpd()
2180 phba->ModelDesc[j++] = vpd[index++]; in lpfc_parse_vpd()
2184 phba->ModelDesc[j] = 0; in lpfc_parse_vpd()
2188 phba->vpd_flag |= VPD_MODEL_NAME; in lpfc_parse_vpd()
2193 Length -= (3+i); in lpfc_parse_vpd()
2194 while(i--) { in lpfc_parse_vpd()
2195 phba->ModelName[j++] = vpd[index++]; in lpfc_parse_vpd()
2199 phba->ModelName[j] = 0; in lpfc_parse_vpd()
2203 phba->vpd_flag |= VPD_PROGRAM_TYPE; in lpfc_parse_vpd()
2208 Length -= (3+i); in lpfc_parse_vpd()
2209 while(i--) { in lpfc_parse_vpd()
2210 phba->ProgramType[j++] = vpd[index++]; in lpfc_parse_vpd()
2214 phba->ProgramType[j] = 0; in lpfc_parse_vpd()
2218 phba->vpd_flag |= VPD_PORT; in lpfc_parse_vpd()
2223 Length -= (3+i); in lpfc_parse_vpd()
2224 while(i--) { in lpfc_parse_vpd()
2225 if ((phba->sli_rev == LPFC_SLI_REV4) && in lpfc_parse_vpd()
2226 (phba->sli4_hba.pport_name_sta == in lpfc_parse_vpd()
2231 phba->Port[j++] = vpd[index++]; in lpfc_parse_vpd()
2235 if ((phba->sli_rev != LPFC_SLI_REV4) || in lpfc_parse_vpd()
2236 (phba->sli4_hba.pport_name_sta == in lpfc_parse_vpd()
2238 phba->Port[j] = 0; in lpfc_parse_vpd()
2246 Length -= (3 + i); in lpfc_parse_vpd()
2264 * lpfc_get_hba_model_desc - Retrieve HBA device model name and description
2279 uint16_t dev_id = phba->pcidev->device; in lpfc_get_hba_model_desc()
2293 if (phba->lmt & LMT_64Gb) in lpfc_get_hba_model_desc()
2295 else if (phba->lmt & LMT_32Gb) in lpfc_get_hba_model_desc()
2297 else if (phba->lmt & LMT_16Gb) in lpfc_get_hba_model_desc()
2299 else if (phba->lmt & LMT_10Gb) in lpfc_get_hba_model_desc()
2301 else if (phba->lmt & LMT_8Gb) in lpfc_get_hba_model_desc()
2303 else if (phba->lmt & LMT_4Gb) in lpfc_get_hba_model_desc()
2305 else if (phba->lmt & LMT_2Gb) in lpfc_get_hba_model_desc()
2307 else if (phba->lmt & LMT_1Gb) in lpfc_get_hba_model_desc()
2312 vp = &phba->vpd; in lpfc_get_hba_model_desc()
2320 if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3) in lpfc_get_hba_model_desc()
2331 if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID) in lpfc_get_hba_model_desc()
2342 m = (typeof(m)){"LP9802", "PCI-X", in lpfc_get_hba_model_desc()
2346 m = (typeof(m)){"LP10000", "PCI-X", in lpfc_get_hba_model_desc()
2350 m = (typeof(m)){"LPX1000", "PCI-X", in lpfc_get_hba_model_desc()
2354 m = (typeof(m)){"LP982", "PCI-X", in lpfc_get_hba_model_desc()
2358 m = (typeof(m)){"LP1050", "PCI-X", in lpfc_get_hba_model_desc()
2362 m = (typeof(m)){"LP11000", "PCI-X2", in lpfc_get_hba_model_desc()
2366 m = (typeof(m)){"LP11000-SP", "PCI-X2", in lpfc_get_hba_model_desc()
2370 m = (typeof(m)){"LP11002-SP", "PCI-X2", in lpfc_get_hba_model_desc()
2378 m = (typeof(m)){"LPe1000-SP", "PCIe", in lpfc_get_hba_model_desc()
2382 m = (typeof(m)){"LPe1002-SP", "PCIe", in lpfc_get_hba_model_desc()
2386 m = (typeof(m)){"LP1150", "PCI-X2", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2389 m = (typeof(m)){"LP111", "PCI-X2", in lpfc_get_hba_model_desc()
2409 m = (typeof(m)){"LP101", "PCI-X", in lpfc_get_hba_model_desc()
2413 m = (typeof(m)){"LP10000-S", "PCI", in lpfc_get_hba_model_desc()
2417 m = (typeof(m)){"LP11000-S", "PCI-X2", in lpfc_get_hba_model_desc()
2421 m = (typeof(m)){"LPe11000-S", "PCIe", in lpfc_get_hba_model_desc()
2434 m = (typeof(m)){"LPe12002-SP", "PCIe", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2437 m = (typeof(m)){"LPe12000-SP", "PCIe", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2440 m = (typeof(m)){"LPe12000-S", "PCIe", "Fibre Channel Adapter"}; in lpfc_get_hba_model_desc()
2456 m = (typeof(m)){"LPemv12002-S", "PCIe IOV", in lpfc_get_hba_model_desc()
2468 m = (typeof(m)){"LPSe12002-ML1-E", "PCIe", in lpfc_get_hba_model_desc()
2518 phba->Port); in lpfc_get_hba_model_desc()
2532 * lpfc_post_buffer - Post IOCB(s) with DMA buffer descriptor(s) to a IOCB ring
2550 cnt += pring->missbufcnt; in lpfc_post_buffer()
2557 pring->missbufcnt = cnt; in lpfc_post_buffer()
2560 icmd = &iocb->iocb; in lpfc_post_buffer()
2566 mp1->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &mp1->phys); in lpfc_post_buffer()
2567 if (!mp1 || !mp1->virt) { in lpfc_post_buffer()
2570 pring->missbufcnt = cnt; in lpfc_post_buffer()
2574 INIT_LIST_HEAD(&mp1->list); in lpfc_post_buffer()
2579 mp2->virt = lpfc_mbuf_alloc(phba, MEM_PRI, in lpfc_post_buffer()
2580 &mp2->phys); in lpfc_post_buffer()
2581 if (!mp2 || !mp2->virt) { in lpfc_post_buffer()
2583 lpfc_mbuf_free(phba, mp1->virt, mp1->phys); in lpfc_post_buffer()
2586 pring->missbufcnt = cnt; in lpfc_post_buffer()
2590 INIT_LIST_HEAD(&mp2->list); in lpfc_post_buffer()
2595 icmd->un.cont64[0].addrHigh = putPaddrHigh(mp1->phys); in lpfc_post_buffer()
2596 icmd->un.cont64[0].addrLow = putPaddrLow(mp1->phys); in lpfc_post_buffer()
2597 icmd->un.cont64[0].tus.f.bdeSize = FCELSSIZE; in lpfc_post_buffer()
2598 icmd->ulpBdeCount = 1; in lpfc_post_buffer()
2599 cnt--; in lpfc_post_buffer()
2601 icmd->un.cont64[1].addrHigh = putPaddrHigh(mp2->phys); in lpfc_post_buffer()
2602 icmd->un.cont64[1].addrLow = putPaddrLow(mp2->phys); in lpfc_post_buffer()
2603 icmd->un.cont64[1].tus.f.bdeSize = FCELSSIZE; in lpfc_post_buffer()
2604 cnt--; in lpfc_post_buffer()
2605 icmd->ulpBdeCount = 2; in lpfc_post_buffer()
2608 icmd->ulpCommand = CMD_QUE_RING_BUF64_CN; in lpfc_post_buffer()
2609 icmd->ulpLe = 1; in lpfc_post_buffer()
2611 if (lpfc_sli_issue_iocb(phba, pring->ringno, iocb, 0) == in lpfc_post_buffer()
2613 lpfc_mbuf_free(phba, mp1->virt, mp1->phys); in lpfc_post_buffer()
2617 lpfc_mbuf_free(phba, mp2->virt, mp2->phys); in lpfc_post_buffer()
2622 pring->missbufcnt = cnt; in lpfc_post_buffer()
2629 pring->missbufcnt = 0; in lpfc_post_buffer()
2634 * lpfc_post_rcv_buf - Post the initial receive IOCB buffers to ELS ring
2642 * 0 - success (currently always success)
2647 struct lpfc_sli *psli = &phba->sli; in lpfc_post_rcv_buf()
2650 lpfc_post_buffer(phba, &psli->sli3_ring[LPFC_ELS_RING], LPFC_BUF_RING0); in lpfc_post_rcv_buf()
2651 /* Ring 2 - FCP no buffers needed */ in lpfc_post_rcv_buf()
2656 #define S(N,V) (((V)<<(N))|((V)>>(32-(N))))
2659 * lpfc_sha_init - Set up initial array of hash table entries
2676 * lpfc_sha_iterate - Iterate initial hash table with the working hash table
2695 HashWorkingPointer[t - 3] ^ HashWorkingPointer[t - in lpfc_sha_iterate()
2697 HashWorkingPointer[t - 14] ^ HashWorkingPointer[t - 16]); in lpfc_sha_iterate()
2733 * lpfc_challenge_key - Create challenge key based on WWPN of the HBA
2749 * lpfc_hba_init - Perform special handling for LC HBA initialization
2751 * @hbainit: pointer to an array of unsigned 32-bit integers.
2760 uint32_t *pwwnn = (uint32_t *) phba->wwnn; in lpfc_hba_init()
2770 lpfc_challenge_key(phba->RandomData + t, HashWorking + t); in lpfc_hba_init()
2778 * lpfc_cleanup - Performs vport cleanups before deleting a vport
2789 struct lpfc_hba *phba = vport->phba; in lpfc_cleanup()
2793 if (phba->link_state > LPFC_LINK_DOWN) in lpfc_cleanup()
2796 list_for_each_entry_safe(ndlp, next_ndlp, &vport->fc_nodes, nlp_listp) { in lpfc_cleanup()
2802 spin_lock_irq(&phba->ndlp_lock); in lpfc_cleanup()
2804 spin_unlock_irq(&phba->ndlp_lock); in lpfc_cleanup()
2809 spin_lock_irq(&phba->ndlp_lock); in lpfc_cleanup()
2812 spin_unlock_irq(&phba->ndlp_lock); in lpfc_cleanup()
2817 spin_unlock_irq(&phba->ndlp_lock); in lpfc_cleanup()
2819 if (vport->port_type != LPFC_PHYSICAL_PORT && in lpfc_cleanup()
2820 ndlp->nlp_DID == Fabric_DID) { in lpfc_cleanup()
2829 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) { in lpfc_cleanup()
2834 if (ndlp->nlp_type & NLP_FABRIC) in lpfc_cleanup()
2846 while (!list_empty(&vport->fc_nodes)) { in lpfc_cleanup()
2851 &vport->fc_nodes, nlp_listp) { in lpfc_cleanup()
2852 lpfc_printf_vlog(ndlp->vport, KERN_ERR, in lpfc_cleanup()
2856 ndlp->nlp_DID, (void *)ndlp, in lpfc_cleanup()
2857 ndlp->nlp_usg_map, in lpfc_cleanup()
2858 kref_read(&ndlp->kref)); in lpfc_cleanup()
2870 * lpfc_stop_vport_timers - Stop all the timers associated with a vport
2880 del_timer_sync(&vport->els_tmofunc); in lpfc_stop_vport_timers()
2881 del_timer_sync(&vport->delayed_disc_tmo); in lpfc_stop_vport_timers()
2887 * __lpfc_sli4_stop_fcf_redisc_wait_timer - Stop FCF rediscovery wait timer
2897 phba->fcf.fcf_flag &= ~FCF_REDISC_PEND; in __lpfc_sli4_stop_fcf_redisc_wait_timer()
2900 del_timer(&phba->fcf.redisc_wait); in __lpfc_sli4_stop_fcf_redisc_wait_timer()
2904 * lpfc_sli4_stop_fcf_redisc_wait_timer - Stop FCF rediscovery wait timer
2915 spin_lock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
2916 if (!(phba->fcf.fcf_flag & FCF_REDISC_PEND)) { in lpfc_sli4_stop_fcf_redisc_wait_timer()
2918 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
2923 phba->fcf.fcf_flag &= ~(FCF_DEAD_DISC | FCF_ACVL_DISC); in lpfc_sli4_stop_fcf_redisc_wait_timer()
2924 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_stop_fcf_redisc_wait_timer()
2928 * lpfc_stop_hba_timers - Stop all the timers associated with an HBA
2937 if (phba->pport) in lpfc_stop_hba_timers()
2938 lpfc_stop_vport_timers(phba->pport); in lpfc_stop_hba_timers()
2939 cancel_delayed_work_sync(&phba->eq_delay_work); in lpfc_stop_hba_timers()
2940 del_timer_sync(&phba->sli.mbox_tmo); in lpfc_stop_hba_timers()
2941 del_timer_sync(&phba->fabric_block_timer); in lpfc_stop_hba_timers()
2942 del_timer_sync(&phba->eratt_poll); in lpfc_stop_hba_timers()
2943 del_timer_sync(&phba->hb_tmofunc); in lpfc_stop_hba_timers()
2944 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_stop_hba_timers()
2945 del_timer_sync(&phba->rrq_tmr); in lpfc_stop_hba_timers()
2946 phba->hba_flag &= ~HBA_RRQ_ACTIVE; in lpfc_stop_hba_timers()
2948 phba->hb_outstanding = 0; in lpfc_stop_hba_timers()
2950 switch (phba->pci_dev_grp) { in lpfc_stop_hba_timers()
2953 del_timer_sync(&phba->fcp_poll_timer); in lpfc_stop_hba_timers()
2962 phba->pci_dev_grp); in lpfc_stop_hba_timers()
2969 * lpfc_block_mgmt_io - Mark a HBA's management interface as blocked
2985 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
2986 phba->sli.sli_flag |= LPFC_BLOCK_MGMT_IO; in lpfc_block_mgmt_io()
2987 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
2991 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
2992 if (phba->sli.mbox_active) { in lpfc_block_mgmt_io()
2993 actcmd = phba->sli.mbox_active->u.mb.mbxCommand; in lpfc_block_mgmt_io()
2998 phba->sli.mbox_active) * 1000) + jiffies; in lpfc_block_mgmt_io()
3000 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_block_mgmt_io()
3003 while (phba->sli.mbox_active) { in lpfc_block_mgmt_io()
3009 "- mbox cmd %x still active\n", in lpfc_block_mgmt_io()
3010 phba->sli.sli_flag, actcmd); in lpfc_block_mgmt_io()
3017 * lpfc_sli4_node_prep - Assign RPIs for active nodes.
3032 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_sli4_node_prep()
3039 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_sli4_node_prep()
3040 if (vports[i]->load_flag & FC_UNLOADING) in lpfc_sli4_node_prep()
3044 &vports[i]->fc_nodes, in lpfc_sli4_node_prep()
3050 spin_lock_irqsave(&phba->ndlp_lock, flags); in lpfc_sli4_node_prep()
3052 spin_unlock_irqrestore(&phba->ndlp_lock, flags); in lpfc_sli4_node_prep()
3055 ndlp->nlp_rpi = rpi; in lpfc_sli4_node_prep()
3056 lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NODE, in lpfc_sli4_node_prep()
3058 "flg:%x map:%x x%px\n", ndlp->nlp_rpi, in lpfc_sli4_node_prep()
3059 ndlp->nlp_DID, ndlp->nlp_flag, in lpfc_sli4_node_prep()
3060 ndlp->nlp_usg_map, ndlp); in lpfc_sli4_node_prep()
3067 * lpfc_create_expedite_pool - create expedite pool
3081 epd_pool = &phba->epd_pool; in lpfc_create_expedite_pool()
3082 qp = &phba->sli4_hba.hdwq[0]; in lpfc_create_expedite_pool()
3084 spin_lock_init(&epd_pool->lock); in lpfc_create_expedite_pool()
3085 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_create_expedite_pool()
3086 spin_lock(&epd_pool->lock); in lpfc_create_expedite_pool()
3087 INIT_LIST_HEAD(&epd_pool->list); in lpfc_create_expedite_pool()
3089 &qp->lpfc_io_buf_list_put, list) { in lpfc_create_expedite_pool()
3090 list_move_tail(&lpfc_ncmd->list, &epd_pool->list); in lpfc_create_expedite_pool()
3091 lpfc_ncmd->expedite = true; in lpfc_create_expedite_pool()
3092 qp->put_io_bufs--; in lpfc_create_expedite_pool()
3093 epd_pool->count++; in lpfc_create_expedite_pool()
3094 if (epd_pool->count >= XRI_BATCH) in lpfc_create_expedite_pool()
3097 spin_unlock(&epd_pool->lock); in lpfc_create_expedite_pool()
3098 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_create_expedite_pool()
3102 * lpfc_destroy_expedite_pool - destroy expedite pool
3116 epd_pool = &phba->epd_pool; in lpfc_destroy_expedite_pool()
3117 qp = &phba->sli4_hba.hdwq[0]; in lpfc_destroy_expedite_pool()
3119 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_expedite_pool()
3120 spin_lock(&epd_pool->lock); in lpfc_destroy_expedite_pool()
3122 &epd_pool->list, list) { in lpfc_destroy_expedite_pool()
3123 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_expedite_pool()
3124 &qp->lpfc_io_buf_list_put); in lpfc_destroy_expedite_pool()
3125 lpfc_ncmd->flags = false; in lpfc_destroy_expedite_pool()
3126 qp->put_io_bufs++; in lpfc_destroy_expedite_pool()
3127 epd_pool->count--; in lpfc_destroy_expedite_pool()
3129 spin_unlock(&epd_pool->lock); in lpfc_destroy_expedite_pool()
3130 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_expedite_pool()
3134 * lpfc_create_multixri_pools - create multi-XRI pools
3156 phba->cfg_hdw_queue, phba->sli4_hba.num_present_cpu, in lpfc_create_multixri_pools()
3157 phba->sli4_hba.io_xri_cnt); in lpfc_create_multixri_pools()
3159 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_create_multixri_pools()
3162 hwq_count = phba->cfg_hdw_queue; in lpfc_create_multixri_pools()
3163 count_per_hwq = phba->sli4_hba.io_xri_cnt / hwq_count; in lpfc_create_multixri_pools()
3173 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_create_multixri_pools()
3178 qp = &phba->sli4_hba.hdwq[j]; in lpfc_create_multixri_pools()
3179 kfree(qp->p_multixri_pool); in lpfc_create_multixri_pools()
3182 phba->cfg_xri_rebalancing = 0; in lpfc_create_multixri_pools()
3186 qp = &phba->sli4_hba.hdwq[i]; in lpfc_create_multixri_pools()
3187 qp->p_multixri_pool = multixri_pool; in lpfc_create_multixri_pools()
3189 multixri_pool->xri_limit = count_per_hwq; in lpfc_create_multixri_pools()
3190 multixri_pool->rrb_next_hwqid = i; in lpfc_create_multixri_pools()
3193 pbl_pool = &multixri_pool->pbl_pool; in lpfc_create_multixri_pools()
3194 spin_lock_init(&pbl_pool->lock); in lpfc_create_multixri_pools()
3195 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_create_multixri_pools()
3196 spin_lock(&pbl_pool->lock); in lpfc_create_multixri_pools()
3197 INIT_LIST_HEAD(&pbl_pool->list); in lpfc_create_multixri_pools()
3199 &qp->lpfc_io_buf_list_put, list) { in lpfc_create_multixri_pools()
3200 list_move_tail(&lpfc_ncmd->list, &pbl_pool->list); in lpfc_create_multixri_pools()
3201 qp->put_io_bufs--; in lpfc_create_multixri_pools()
3202 pbl_pool->count++; in lpfc_create_multixri_pools()
3206 pbl_pool->count, i); in lpfc_create_multixri_pools()
3207 spin_unlock(&pbl_pool->lock); in lpfc_create_multixri_pools()
3208 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_create_multixri_pools()
3211 pvt_pool = &multixri_pool->pvt_pool; in lpfc_create_multixri_pools()
3212 pvt_pool->high_watermark = multixri_pool->xri_limit / 2; in lpfc_create_multixri_pools()
3213 pvt_pool->low_watermark = XRI_BATCH; in lpfc_create_multixri_pools()
3214 spin_lock_init(&pvt_pool->lock); in lpfc_create_multixri_pools()
3215 spin_lock_irqsave(&pvt_pool->lock, iflag); in lpfc_create_multixri_pools()
3216 INIT_LIST_HEAD(&pvt_pool->list); in lpfc_create_multixri_pools()
3217 pvt_pool->count = 0; in lpfc_create_multixri_pools()
3218 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_create_multixri_pools()
3223 * lpfc_destroy_multixri_pools - destroy multi-XRI pools
3240 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_destroy_multixri_pools()
3243 if (!(phba->pport->load_flag & FC_UNLOADING)) in lpfc_destroy_multixri_pools()
3246 hwq_count = phba->cfg_hdw_queue; in lpfc_destroy_multixri_pools()
3249 qp = &phba->sli4_hba.hdwq[i]; in lpfc_destroy_multixri_pools()
3250 multixri_pool = qp->p_multixri_pool; in lpfc_destroy_multixri_pools()
3254 qp->p_multixri_pool = NULL; in lpfc_destroy_multixri_pools()
3256 spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_multixri_pools()
3259 pbl_pool = &multixri_pool->pbl_pool; in lpfc_destroy_multixri_pools()
3260 spin_lock(&pbl_pool->lock); in lpfc_destroy_multixri_pools()
3264 pbl_pool->count, i); in lpfc_destroy_multixri_pools()
3267 &pbl_pool->list, list) { in lpfc_destroy_multixri_pools()
3268 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_multixri_pools()
3269 &qp->lpfc_io_buf_list_put); in lpfc_destroy_multixri_pools()
3270 qp->put_io_bufs++; in lpfc_destroy_multixri_pools()
3271 pbl_pool->count--; in lpfc_destroy_multixri_pools()
3274 INIT_LIST_HEAD(&pbl_pool->list); in lpfc_destroy_multixri_pools()
3275 pbl_pool->count = 0; in lpfc_destroy_multixri_pools()
3277 spin_unlock(&pbl_pool->lock); in lpfc_destroy_multixri_pools()
3280 pvt_pool = &multixri_pool->pvt_pool; in lpfc_destroy_multixri_pools()
3281 spin_lock(&pvt_pool->lock); in lpfc_destroy_multixri_pools()
3285 pvt_pool->count, i); in lpfc_destroy_multixri_pools()
3288 &pvt_pool->list, list) { in lpfc_destroy_multixri_pools()
3289 list_move_tail(&lpfc_ncmd->list, in lpfc_destroy_multixri_pools()
3290 &qp->lpfc_io_buf_list_put); in lpfc_destroy_multixri_pools()
3291 qp->put_io_bufs++; in lpfc_destroy_multixri_pools()
3292 pvt_pool->count--; in lpfc_destroy_multixri_pools()
3295 INIT_LIST_HEAD(&pvt_pool->list); in lpfc_destroy_multixri_pools()
3296 pvt_pool->count = 0; in lpfc_destroy_multixri_pools()
3298 spin_unlock(&pvt_pool->lock); in lpfc_destroy_multixri_pools()
3299 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, iflag); in lpfc_destroy_multixri_pools()
3306 * lpfc_online - Initialize and bring a HBA online
3314 * 0 - successful
3315 * 1 - failed
3327 vport = phba->pport; in lpfc_online()
3329 if (!(vport->fc_flag & FC_OFFLINE_MODE)) in lpfc_online()
3337 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_online()
3342 spin_lock_irq(&phba->hbalock); in lpfc_online()
3343 if (!phba->sli4_hba.max_cfg_param.vpi_used) in lpfc_online()
3345 spin_unlock_irq(&phba->hbalock); in lpfc_online()
3350 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME && in lpfc_online()
3351 !phba->nvmet_support) { in lpfc_online()
3352 error = lpfc_nvme_create_localport(phba->pport); in lpfc_online()
3368 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_online()
3371 spin_lock_irq(shost->host_lock); in lpfc_online()
3372 vports[i]->fc_flag &= ~FC_OFFLINE_MODE; in lpfc_online()
3373 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) in lpfc_online()
3374 vports[i]->fc_flag |= FC_VPORT_NEEDS_REG_VPI; in lpfc_online()
3375 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_online()
3376 vports[i]->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; in lpfc_online()
3378 (vports[i]->port_type != in lpfc_online()
3380 vports[i]->vpi = 0; in lpfc_online()
3382 spin_unlock_irq(shost->host_lock); in lpfc_online()
3387 if (phba->cfg_xri_rebalancing) in lpfc_online()
3395 * lpfc_unblock_mgmt_io - Mark a HBA's management interface to be not blocked
3410 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_unblock_mgmt_io()
3411 phba->sli.sli_flag &= ~LPFC_BLOCK_MGMT_IO; in lpfc_unblock_mgmt_io()
3412 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_unblock_mgmt_io()
3416 * lpfc_offline_prep - Prepare a HBA to be brought offline
3426 struct lpfc_vport *vport = phba->pport; in lpfc_offline_prep()
3432 if (vport->fc_flag & FC_OFFLINE_MODE) in lpfc_offline_prep()
3442 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_offline_prep()
3443 if (vports[i]->load_flag & FC_UNLOADING) in lpfc_offline_prep()
3446 spin_lock_irq(shost->host_lock); in lpfc_offline_prep()
3447 vports[i]->vpi_state &= ~LPFC_VPI_REGISTERED; in lpfc_offline_prep()
3448 vports[i]->fc_flag |= FC_VPORT_NEEDS_REG_VPI; in lpfc_offline_prep()
3449 vports[i]->fc_flag &= ~FC_VFI_REGISTERED; in lpfc_offline_prep()
3450 spin_unlock_irq(shost->host_lock); in lpfc_offline_prep()
3454 &vports[i]->fc_nodes, in lpfc_offline_prep()
3458 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE) in lpfc_offline_prep()
3460 if (ndlp->nlp_type & NLP_FABRIC) { in lpfc_offline_prep()
3466 spin_lock_irq(shost->host_lock); in lpfc_offline_prep()
3467 ndlp->nlp_flag &= ~NLP_NPR_ADISC; in lpfc_offline_prep()
3468 spin_unlock_irq(shost->host_lock); in lpfc_offline_prep()
3474 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_offline_prep()
3475 lpfc_printf_vlog(ndlp->vport, in lpfc_offline_prep()
3480 ndlp, ndlp->nlp_DID, in lpfc_offline_prep()
3481 ndlp->nlp_usg_map, in lpfc_offline_prep()
3482 ndlp->nlp_rpi); in lpfc_offline_prep()
3484 lpfc_sli4_free_rpi(phba, ndlp->nlp_rpi); in lpfc_offline_prep()
3494 if (phba->wq) in lpfc_offline_prep()
3495 flush_workqueue(phba->wq); in lpfc_offline_prep()
3499 * lpfc_offline - Bring a HBA offline
3513 if (phba->pport->fc_flag & FC_OFFLINE_MODE) in lpfc_offline()
3523 lpfc_nvme_destroy_localport(phba->pport); in lpfc_offline()
3527 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) in lpfc_offline()
3535 spin_lock_irq(&phba->hbalock); in lpfc_offline()
3536 phba->work_ha = 0; in lpfc_offline()
3537 spin_unlock_irq(&phba->hbalock); in lpfc_offline()
3540 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_offline()
3542 spin_lock_irq(shost->host_lock); in lpfc_offline()
3543 vports[i]->work_port_events = 0; in lpfc_offline()
3544 vports[i]->fc_flag |= FC_OFFLINE_MODE; in lpfc_offline()
3545 spin_unlock_irq(shost->host_lock); in lpfc_offline()
3549 if (phba->cfg_xri_rebalancing) in lpfc_offline()
3554 * lpfc_scsi_free - Free all the SCSI buffers and IOCBs from driver lists
3566 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_scsi_free()
3569 spin_lock_irq(&phba->hbalock); in lpfc_scsi_free()
3573 spin_lock(&phba->scsi_buf_list_put_lock); in lpfc_scsi_free()
3574 list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list_put, in lpfc_scsi_free()
3576 list_del(&sb->list); in lpfc_scsi_free()
3577 dma_pool_free(phba->lpfc_sg_dma_buf_pool, sb->data, in lpfc_scsi_free()
3578 sb->dma_handle); in lpfc_scsi_free()
3580 phba->total_scsi_bufs--; in lpfc_scsi_free()
3582 spin_unlock(&phba->scsi_buf_list_put_lock); in lpfc_scsi_free()
3584 spin_lock(&phba->scsi_buf_list_get_lock); in lpfc_scsi_free()
3585 list_for_each_entry_safe(sb, sb_next, &phba->lpfc_scsi_buf_list_get, in lpfc_scsi_free()
3587 list_del(&sb->list); in lpfc_scsi_free()
3588 dma_pool_free(phba->lpfc_sg_dma_buf_pool, sb->data, in lpfc_scsi_free()
3589 sb->dma_handle); in lpfc_scsi_free()
3591 phba->total_scsi_bufs--; in lpfc_scsi_free()
3593 spin_unlock(&phba->scsi_buf_list_get_lock); in lpfc_scsi_free()
3594 spin_unlock_irq(&phba->hbalock); in lpfc_scsi_free()
3598 * lpfc_io_free - Free all the IO buffers and IOCBs from driver lists
3612 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_free()
3613 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_free()
3615 spin_lock(&qp->io_buf_list_put_lock); in lpfc_io_free()
3617 &qp->lpfc_io_buf_list_put, in lpfc_io_free()
3619 list_del(&lpfc_ncmd->list); in lpfc_io_free()
3620 qp->put_io_bufs--; in lpfc_io_free()
3621 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_io_free()
3622 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_io_free()
3623 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_io_free()
3627 qp->total_io_bufs--; in lpfc_io_free()
3629 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_io_free()
3631 spin_lock(&qp->io_buf_list_get_lock); in lpfc_io_free()
3633 &qp->lpfc_io_buf_list_get, in lpfc_io_free()
3635 list_del(&lpfc_ncmd->list); in lpfc_io_free()
3636 qp->get_io_bufs--; in lpfc_io_free()
3637 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_io_free()
3638 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_io_free()
3639 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_io_free()
3643 qp->total_io_bufs--; in lpfc_io_free()
3645 spin_unlock(&qp->io_buf_list_get_lock); in lpfc_io_free()
3650 * lpfc_sli4_els_sgl_update - update ELS xri-sgl sizing and mapping
3659 * 0 - successful (for now, it always returns 0)
3670 * update on pci function's els xri-sgl list in lpfc_sli4_els_sgl_update()
3674 if (els_xri_cnt > phba->sli4_hba.els_xri_cnt) { in lpfc_sli4_els_sgl_update()
3675 /* els xri-sgl expanded */ in lpfc_sli4_els_sgl_update()
3676 xri_cnt = els_xri_cnt - phba->sli4_hba.els_xri_cnt; in lpfc_sli4_els_sgl_update()
3678 "3157 ELS xri-sgl count increased from " in lpfc_sli4_els_sgl_update()
3679 "%d to %d\n", phba->sli4_hba.els_xri_cnt, in lpfc_sli4_els_sgl_update()
3689 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
3692 sglq_entry->buff_type = GEN_BUFF_TYPE; in lpfc_sli4_els_sgl_update()
3693 sglq_entry->virt = lpfc_mbuf_alloc(phba, 0, in lpfc_sli4_els_sgl_update()
3694 &sglq_entry->phys); in lpfc_sli4_els_sgl_update()
3695 if (sglq_entry->virt == NULL) { in lpfc_sli4_els_sgl_update()
3700 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
3703 sglq_entry->sgl = sglq_entry->virt; in lpfc_sli4_els_sgl_update()
3704 memset(sglq_entry->sgl, 0, LPFC_BPL_SIZE); in lpfc_sli4_els_sgl_update()
3705 sglq_entry->state = SGL_FREED; in lpfc_sli4_els_sgl_update()
3706 list_add_tail(&sglq_entry->list, &els_sgl_list); in lpfc_sli4_els_sgl_update()
3708 spin_lock_irq(&phba->hbalock); in lpfc_sli4_els_sgl_update()
3709 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
3711 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_sli4_els_sgl_update()
3712 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
3713 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_els_sgl_update()
3714 } else if (els_xri_cnt < phba->sli4_hba.els_xri_cnt) { in lpfc_sli4_els_sgl_update()
3715 /* els xri-sgl shrinked */ in lpfc_sli4_els_sgl_update()
3716 xri_cnt = phba->sli4_hba.els_xri_cnt - els_xri_cnt; in lpfc_sli4_els_sgl_update()
3718 "3158 ELS xri-sgl count decreased from " in lpfc_sli4_els_sgl_update()
3719 "%d to %d\n", phba->sli4_hba.els_xri_cnt, in lpfc_sli4_els_sgl_update()
3721 spin_lock_irq(&phba->hbalock); in lpfc_sli4_els_sgl_update()
3722 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
3723 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, in lpfc_sli4_els_sgl_update()
3730 __lpfc_mbuf_free(phba, sglq_entry->virt, in lpfc_sli4_els_sgl_update()
3731 sglq_entry->phys); in lpfc_sli4_els_sgl_update()
3736 &phba->sli4_hba.lpfc_els_sgl_list); in lpfc_sli4_els_sgl_update()
3737 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_els_sgl_update()
3738 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_els_sgl_update()
3741 "3163 ELS xri-sgl count unchanged: %d\n", in lpfc_sli4_els_sgl_update()
3743 phba->sli4_hba.els_xri_cnt = els_xri_cnt; in lpfc_sli4_els_sgl_update()
3749 &phba->sli4_hba.lpfc_els_sgl_list, list) { in lpfc_sli4_els_sgl_update()
3755 rc = -ENOMEM; in lpfc_sli4_els_sgl_update()
3758 sglq_entry->sli4_lxritag = lxri; in lpfc_sli4_els_sgl_update()
3759 sglq_entry->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_els_sgl_update()
3769 * lpfc_sli4_nvmet_sgl_update - update xri-sgl sizing and mapping
3778 * 0 - successful (for now, it always returns 0)
3790 * update on pci function's nvmet xri-sgl list in lpfc_sli4_nvmet_sgl_update()
3795 nvmet_xri_cnt = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
3796 if (nvmet_xri_cnt > phba->sli4_hba.nvmet_xri_cnt) { in lpfc_sli4_nvmet_sgl_update()
3797 /* els xri-sgl expanded */ in lpfc_sli4_nvmet_sgl_update()
3798 xri_cnt = nvmet_xri_cnt - phba->sli4_hba.nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
3800 "6302 NVMET xri-sgl cnt grew from %d to %d\n", in lpfc_sli4_nvmet_sgl_update()
3801 phba->sli4_hba.nvmet_xri_cnt, nvmet_xri_cnt); in lpfc_sli4_nvmet_sgl_update()
3810 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
3813 sglq_entry->buff_type = NVMET_BUFF_TYPE; in lpfc_sli4_nvmet_sgl_update()
3814 sglq_entry->virt = lpfc_nvmet_buf_alloc(phba, 0, in lpfc_sli4_nvmet_sgl_update()
3815 &sglq_entry->phys); in lpfc_sli4_nvmet_sgl_update()
3816 if (sglq_entry->virt == NULL) { in lpfc_sli4_nvmet_sgl_update()
3821 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
3824 sglq_entry->sgl = sglq_entry->virt; in lpfc_sli4_nvmet_sgl_update()
3825 memset(sglq_entry->sgl, 0, in lpfc_sli4_nvmet_sgl_update()
3826 phba->cfg_sg_dma_buf_size); in lpfc_sli4_nvmet_sgl_update()
3827 sglq_entry->state = SGL_FREED; in lpfc_sli4_nvmet_sgl_update()
3828 list_add_tail(&sglq_entry->list, &nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
3830 spin_lock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
3831 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
3833 &phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
3834 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
3835 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
3836 } else if (nvmet_xri_cnt < phba->sli4_hba.nvmet_xri_cnt) { in lpfc_sli4_nvmet_sgl_update()
3837 /* nvmet xri-sgl shrunk */ in lpfc_sli4_nvmet_sgl_update()
3838 xri_cnt = phba->sli4_hba.nvmet_xri_cnt - nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
3840 "6305 NVMET xri-sgl count decreased from " in lpfc_sli4_nvmet_sgl_update()
3841 "%d to %d\n", phba->sli4_hba.nvmet_xri_cnt, in lpfc_sli4_nvmet_sgl_update()
3843 spin_lock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
3844 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
3845 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, in lpfc_sli4_nvmet_sgl_update()
3852 lpfc_nvmet_buf_free(phba, sglq_entry->virt, in lpfc_sli4_nvmet_sgl_update()
3853 sglq_entry->phys); in lpfc_sli4_nvmet_sgl_update()
3858 &phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_sli4_nvmet_sgl_update()
3859 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_nvmet_sgl_update()
3860 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_nvmet_sgl_update()
3863 "6306 NVMET xri-sgl count unchanged: %d\n", in lpfc_sli4_nvmet_sgl_update()
3865 phba->sli4_hba.nvmet_xri_cnt = nvmet_xri_cnt; in lpfc_sli4_nvmet_sgl_update()
3871 &phba->sli4_hba.lpfc_nvmet_sgl_list, list) { in lpfc_sli4_nvmet_sgl_update()
3877 rc = -ENOMEM; in lpfc_sli4_nvmet_sgl_update()
3880 sglq_entry->sli4_lxritag = lxri; in lpfc_sli4_nvmet_sgl_update()
3881 sglq_entry->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_nvmet_sgl_update()
3900 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_buf_flush()
3901 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf_flush()
3902 spin_lock_irq(&qp->io_buf_list_get_lock); in lpfc_io_buf_flush()
3903 spin_lock(&qp->io_buf_list_put_lock); in lpfc_io_buf_flush()
3906 list_splice_init(&qp->lpfc_io_buf_list_get, &blist); in lpfc_io_buf_flush()
3907 list_splice(&qp->lpfc_io_buf_list_put, &blist); in lpfc_io_buf_flush()
3908 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_io_buf_flush()
3909 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_io_buf_flush()
3910 cnt += qp->get_io_bufs + qp->put_io_bufs; in lpfc_io_buf_flush()
3911 qp->get_io_bufs = 0; in lpfc_io_buf_flush()
3912 qp->put_io_bufs = 0; in lpfc_io_buf_flush()
3913 qp->total_io_bufs = 0; in lpfc_io_buf_flush()
3914 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_io_buf_flush()
3915 spin_unlock_irq(&qp->io_buf_list_get_lock); in lpfc_io_buf_flush()
3928 list_add_tail(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
3931 xri = lpfc_cmd->cur_iocbq.sli4_xritag; in lpfc_io_buf_flush()
3935 if (xri < iobufp->cur_iocbq.sli4_xritag) { in lpfc_io_buf_flush()
3937 list_add(&lpfc_cmd->list, in lpfc_io_buf_flush()
3938 &prev_iobufp->list); in lpfc_io_buf_flush()
3940 list_add(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
3947 list_add_tail(&lpfc_cmd->list, cbuf); in lpfc_io_buf_flush()
3959 qp = phba->sli4_hba.hdwq; in lpfc_io_buf_replenish()
3962 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_io_buf_replenish()
3968 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf_replenish()
3969 lpfc_cmd->hdwq_no = idx; in lpfc_io_buf_replenish()
3970 lpfc_cmd->hdwq = qp; in lpfc_io_buf_replenish()
3971 lpfc_cmd->cur_iocbq.wqe_cmpl = NULL; in lpfc_io_buf_replenish()
3972 lpfc_cmd->cur_iocbq.iocb_cmpl = NULL; in lpfc_io_buf_replenish()
3973 spin_lock(&qp->io_buf_list_put_lock); in lpfc_io_buf_replenish()
3974 list_add_tail(&lpfc_cmd->list, in lpfc_io_buf_replenish()
3975 &qp->lpfc_io_buf_list_put); in lpfc_io_buf_replenish()
3976 qp->put_io_bufs++; in lpfc_io_buf_replenish()
3977 qp->total_io_bufs++; in lpfc_io_buf_replenish()
3978 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_io_buf_replenish()
3985 * lpfc_sli4_io_sgl_update - update xri-sgl sizing and mapping
3994 * 0 - successful (for now, it always returns 0)
4006 * update on pci function's allocated nvme xri-sgl list in lpfc_sli4_io_sgl_update()
4011 io_xri_max = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt; in lpfc_sli4_io_sgl_update()
4012 phba->sli4_hba.io_xri_max = io_xri_max; in lpfc_sli4_io_sgl_update()
4017 phba->sli4_hba.io_xri_cnt, in lpfc_sli4_io_sgl_update()
4018 phba->sli4_hba.io_xri_max); in lpfc_sli4_io_sgl_update()
4022 if (phba->sli4_hba.io_xri_cnt > phba->sli4_hba.io_xri_max) { in lpfc_sli4_io_sgl_update()
4024 io_xri_cnt = phba->sli4_hba.io_xri_cnt - in lpfc_sli4_io_sgl_update()
4025 phba->sli4_hba.io_xri_max; in lpfc_sli4_io_sgl_update()
4031 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_sli4_io_sgl_update()
4032 lpfc_ncmd->data, in lpfc_sli4_io_sgl_update()
4033 lpfc_ncmd->dma_handle); in lpfc_sli4_io_sgl_update()
4037 phba->sli4_hba.io_xri_cnt -= io_xri_cnt; in lpfc_sli4_io_sgl_update()
4043 phba->sli4_hba.io_xri_cnt = cnt; in lpfc_sli4_io_sgl_update()
4051 rc = -ENOMEM; in lpfc_sli4_io_sgl_update()
4054 lpfc_ncmd->cur_iocbq.sli4_lxritag = lxri; in lpfc_sli4_io_sgl_update()
4055 lpfc_ncmd->cur_iocbq.sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_sli4_io_sgl_update()
4066 * lpfc_new_io_buf - IO buffer allocator for HBA with SLI4 IF spec
4070 * This routine allocates nvme buffers for device with SLI-4 interface spec,
4076 * int - number of IO buffers that were allocated and posted.
4090 phba->sli4_hba.io_xri_cnt = 0; in lpfc_new_io_buf()
4100 lpfc_ncmd->data = dma_pool_zalloc(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4102 &lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4103 if (!lpfc_ncmd->data) { in lpfc_new_io_buf()
4108 if (phba->cfg_xpsgl && !phba->nvmet_support) { in lpfc_new_io_buf()
4109 INIT_LIST_HEAD(&lpfc_ncmd->dma_sgl_xtra_list); in lpfc_new_io_buf()
4115 if ((phba->sli3_options & LPFC_SLI3_BG_ENABLED) && in lpfc_new_io_buf()
4116 (((unsigned long)(lpfc_ncmd->data) & in lpfc_new_io_buf()
4117 (unsigned long)(SLI4_PAGE_SIZE - 1)) != 0)) { in lpfc_new_io_buf()
4121 (unsigned long)lpfc_ncmd->data); in lpfc_new_io_buf()
4122 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4123 lpfc_ncmd->data, in lpfc_new_io_buf()
4124 lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4130 INIT_LIST_HEAD(&lpfc_ncmd->dma_cmd_rsp_list); in lpfc_new_io_buf()
4134 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4135 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4139 pwqeq = &lpfc_ncmd->cur_iocbq; in lpfc_new_io_buf()
4141 /* Allocate iotag for lpfc_ncmd->cur_iocbq. */ in lpfc_new_io_buf()
4144 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_new_io_buf()
4145 lpfc_ncmd->data, lpfc_ncmd->dma_handle); in lpfc_new_io_buf()
4153 pwqeq->sli4_lxritag = lxri; in lpfc_new_io_buf()
4154 pwqeq->sli4_xritag = phba->sli4_hba.xri_ids[lxri]; in lpfc_new_io_buf()
4155 pwqeq->context1 = lpfc_ncmd; in lpfc_new_io_buf()
4157 /* Initialize local short-hand pointers. */ in lpfc_new_io_buf()
4158 lpfc_ncmd->dma_sgl = lpfc_ncmd->data; in lpfc_new_io_buf()
4159 lpfc_ncmd->dma_phys_sgl = lpfc_ncmd->dma_handle; in lpfc_new_io_buf()
4160 lpfc_ncmd->cur_iocbq.context1 = lpfc_ncmd; in lpfc_new_io_buf()
4161 spin_lock_init(&lpfc_ncmd->buf_lock); in lpfc_new_io_buf()
4164 list_add_tail(&lpfc_ncmd->list, &post_nblist); in lpfc_new_io_buf()
4165 phba->sli4_hba.io_xri_cnt++; in lpfc_new_io_buf()
4189 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_get_wwpn()
4192 return (uint64_t)-1; in lpfc_get_wwpn()
4201 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_get_wwpn()
4202 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_get_wwpn()
4203 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_get_wwpn()
4204 return (uint64_t) -1; in lpfc_get_wwpn()
4206 mb = &mboxq->u.mb; in lpfc_get_wwpn()
4207 memcpy(&wwn, (char *)mb->un.varRDnvp.portname, sizeof(uint64_t)); in lpfc_get_wwpn()
4209 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_get_wwpn()
4210 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_get_wwpn()
4217 * lpfc_create_port - Create an FC port
4229 * @vport - pointer to the virtual N_Port data structure.
4230 * NULL - port create failed.
4244 if (phba->sli_rev < LPFC_SLI_REV4 && in lpfc_create_port()
4245 dev == &phba->pcidev->dev) { in lpfc_create_port()
4265 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { in lpfc_create_port()
4266 if (dev != &phba->pcidev->dev) { in lpfc_create_port()
4277 } else if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_create_port()
4284 vport = (struct lpfc_vport *) shost->hostdata; in lpfc_create_port()
4285 vport->phba = phba; in lpfc_create_port()
4286 vport->load_flag |= FC_LOADING; in lpfc_create_port()
4287 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; in lpfc_create_port()
4288 vport->fc_rscn_flush = 0; in lpfc_create_port()
4292 vport->cfg_enable_fc4_type = phba->cfg_enable_fc4_type; in lpfc_create_port()
4294 shost->unique_id = instance; in lpfc_create_port()
4295 shost->max_id = LPFC_MAX_TARGET; in lpfc_create_port()
4296 shost->max_lun = vport->cfg_max_luns; in lpfc_create_port()
4297 shost->this_id = -1; in lpfc_create_port()
4298 shost->max_cmd_len = 16; in lpfc_create_port()
4300 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_create_port()
4301 if (!phba->cfg_fcp_mq_threshold || in lpfc_create_port()
4302 phba->cfg_fcp_mq_threshold > phba->cfg_hdw_queue) in lpfc_create_port()
4303 phba->cfg_fcp_mq_threshold = phba->cfg_hdw_queue; in lpfc_create_port()
4305 shost->nr_hw_queues = min_t(int, 2 * num_possible_nodes(), in lpfc_create_port()
4306 phba->cfg_fcp_mq_threshold); in lpfc_create_port()
4308 shost->dma_boundary = in lpfc_create_port()
4309 phba->sli4_hba.pc_sli4_params.sge_supp_len-1; in lpfc_create_port()
4311 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_create_port()
4312 shost->sg_tablesize = LPFC_MAX_SG_TABLESIZE; in lpfc_create_port()
4314 shost->sg_tablesize = phba->cfg_scsi_seg_cnt; in lpfc_create_port()
4316 /* SLI-3 has a limited number of hardware queues (3), in lpfc_create_port()
4319 shost->nr_hw_queues = 1; in lpfc_create_port()
4326 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_create_port()
4327 if (dev != &phba->pcidev->dev) { in lpfc_create_port()
4328 shost->transportt = lpfc_vport_transport_template; in lpfc_create_port()
4329 vport->port_type = LPFC_NPIV_PORT; in lpfc_create_port()
4331 shost->transportt = lpfc_transport_template; in lpfc_create_port()
4332 vport->port_type = LPFC_PHYSICAL_PORT; in lpfc_create_port()
4336 INIT_LIST_HEAD(&vport->fc_nodes); in lpfc_create_port()
4337 INIT_LIST_HEAD(&vport->rcv_buffer_list); in lpfc_create_port()
4338 spin_lock_init(&vport->work_port_lock); in lpfc_create_port()
4340 timer_setup(&vport->fc_disctmo, lpfc_disc_timeout, 0); in lpfc_create_port()
4342 timer_setup(&vport->els_tmofunc, lpfc_els_timeout, 0); in lpfc_create_port()
4344 timer_setup(&vport->delayed_disc_tmo, lpfc_delayed_disc_tmo, 0); in lpfc_create_port()
4346 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) in lpfc_create_port()
4349 error = scsi_add_host_with_dma(shost, dev, &phba->pcidev->dev); in lpfc_create_port()
4353 spin_lock_irq(&phba->port_list_lock); in lpfc_create_port()
4354 list_add_tail(&vport->listentry, &phba->port_list); in lpfc_create_port()
4355 spin_unlock_irq(&phba->port_list_lock); in lpfc_create_port()
4365 * destroy_port - destroy an FC port
4375 struct lpfc_hba *phba = vport->phba; in destroy_port()
4381 spin_lock_irq(&phba->port_list_lock); in destroy_port()
4382 list_del_init(&vport->listentry); in destroy_port()
4383 spin_unlock_irq(&phba->port_list_lock); in destroy_port()
4390 * lpfc_get_instance - Get a unique integer ID
4396 * instance - a unique integer ID allocated as the new instance.
4397 * -1 - lpfc get instance failed.
4405 return ret < 0 ? -1 : ret; in lpfc_get_instance()
4409 * lpfc_scan_finished - method for SCSI layer to detect whether scan is done
4420 * 0 - SCSI host scan is not over yet.
4421 * 1 - SCSI host scan is over.
4425 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_scan_finished()
4426 struct lpfc_hba *phba = vport->phba; in lpfc_scan_finished()
4429 spin_lock_irq(shost->host_lock); in lpfc_scan_finished()
4431 if (vport->load_flag & FC_UNLOADING) { in lpfc_scan_finished()
4443 phba->link_state <= LPFC_LINK_DOWN) { in lpfc_scan_finished()
4451 if (vport->port_state != LPFC_VPORT_READY) in lpfc_scan_finished()
4453 if (vport->num_disc_nodes || vport->fc_prli_sent) in lpfc_scan_finished()
4455 if (vport->fc_map_cnt == 0 && time < msecs_to_jiffies(2 * 1000)) in lpfc_scan_finished()
4457 if ((phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) != 0) in lpfc_scan_finished()
4463 spin_unlock_irq(shost->host_lock); in lpfc_scan_finished()
4469 struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata; in lpfc_host_supported_speeds_set()
4470 struct lpfc_hba *phba = vport->phba; in lpfc_host_supported_speeds_set()
4473 if (phba->lmt & LMT_128Gb) in lpfc_host_supported_speeds_set()
4475 if (phba->lmt & LMT_64Gb) in lpfc_host_supported_speeds_set()
4477 if (phba->lmt & LMT_32Gb) in lpfc_host_supported_speeds_set()
4479 if (phba->lmt & LMT_16Gb) in lpfc_host_supported_speeds_set()
4481 if (phba->lmt & LMT_10Gb) in lpfc_host_supported_speeds_set()
4483 if (phba->lmt & LMT_8Gb) in lpfc_host_supported_speeds_set()
4485 if (phba->lmt & LMT_4Gb) in lpfc_host_supported_speeds_set()
4487 if (phba->lmt & LMT_2Gb) in lpfc_host_supported_speeds_set()
4489 if (phba->lmt & LMT_1Gb) in lpfc_host_supported_speeds_set()
4494 * lpfc_host_attrib_init - Initialize SCSI host attributes on a FC port
4502 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_host_attrib_init()
4503 struct lpfc_hba *phba = vport->phba; in lpfc_host_attrib_init()
4508 fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); in lpfc_host_attrib_init()
4509 fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); in lpfc_host_attrib_init()
4523 (((uint32_t) vport->fc_sparam.cmn.bbRcvSizeMsb & 0x0F) << 8) | in lpfc_host_attrib_init()
4524 (uint32_t) vport->fc_sparam.cmn.bbRcvSizeLsb; in lpfc_host_attrib_init()
4526 fc_host_dev_loss_tmo(shost) = vport->cfg_devloss_tmo; in lpfc_host_attrib_init()
4534 fc_host_max_npiv_vports(shost) = phba->max_vpi; in lpfc_host_attrib_init()
4535 spin_lock_irq(shost->host_lock); in lpfc_host_attrib_init()
4536 vport->load_flag &= ~FC_LOADING; in lpfc_host_attrib_init()
4537 spin_unlock_irq(shost->host_lock); in lpfc_host_attrib_init()
4541 * lpfc_stop_port_s3 - Stop SLI3 device port
4552 writel(0, phba->HCregaddr); in lpfc_stop_port_s3()
4553 readl(phba->HCregaddr); /* flush */ in lpfc_stop_port_s3()
4555 writel(0xffffffff, phba->HAregaddr); in lpfc_stop_port_s3()
4556 readl(phba->HAregaddr); /* flush */ in lpfc_stop_port_s3()
4560 phba->pport->work_port_events = 0; in lpfc_stop_port_s3()
4564 * lpfc_stop_port_s4 - Stop SLI4 device port
4576 if (phba->pport) in lpfc_stop_port_s4()
4577 phba->pport->work_port_events = 0; in lpfc_stop_port_s4()
4578 phba->sli4_hba.intr_enable = 0; in lpfc_stop_port_s4()
4582 * lpfc_stop_port - Wrapper function for stopping hba port
4591 phba->lpfc_stop_port(phba); in lpfc_stop_port()
4593 if (phba->wq) in lpfc_stop_port()
4594 flush_workqueue(phba->wq); in lpfc_stop_port()
4598 * lpfc_fcf_redisc_wait_start_timer - Start fcf rediscover wait timer
4609 mod_timer(&phba->fcf.redisc_wait, fcf_redisc_wait_tmo); in lpfc_fcf_redisc_wait_start_timer()
4610 spin_lock_irq(&phba->hbalock); in lpfc_fcf_redisc_wait_start_timer()
4612 phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_SCAN_DONE); in lpfc_fcf_redisc_wait_start_timer()
4614 phba->fcf.fcf_flag |= FCF_REDISC_PEND; in lpfc_fcf_redisc_wait_start_timer()
4615 spin_unlock_irq(&phba->hbalock); in lpfc_fcf_redisc_wait_start_timer()
4619 * lpfc_sli4_fcf_redisc_wait_tmo - FCF table rediscover wait timeout
4634 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
4635 if (!(phba->fcf.fcf_flag & FCF_REDISC_PEND)) { in lpfc_sli4_fcf_redisc_wait_tmo()
4636 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
4640 phba->fcf.fcf_flag &= ~FCF_REDISC_PEND; in lpfc_sli4_fcf_redisc_wait_tmo()
4642 phba->fcf.fcf_flag |= FCF_REDISC_EVT; in lpfc_sli4_fcf_redisc_wait_tmo()
4643 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_wait_tmo()
4651 * lpfc_sli4_parse_latt_fault - Parse sli4 link-attention link fault code
4655 * This routine is to parse the SLI4 link-attention link fault code.
4676 * lpfc_sli4_parse_latt_type - Parse sli4 link attention type
4697 /* Ignore physical link up events - wait for logical link up */ in lpfc_sli4_parse_latt_type()
4714 * lpfc_sli_port_speed_get - Get sli3 link speed code to link speed
4729 if (phba->sli_rev <= LPFC_SLI_REV3) { in lpfc_sli_port_speed_get()
4730 switch (phba->fc_linkspeed) { in lpfc_sli_port_speed_get()
4753 if (phba->sli4_hba.link_state.logical_speed) in lpfc_sli_port_speed_get()
4755 phba->sli4_hba.link_state.logical_speed; in lpfc_sli_port_speed_get()
4757 link_speed = phba->sli4_hba.link_state.speed; in lpfc_sli_port_speed_get()
4763 * lpfc_sli4_port_speed_parse - Parse async evt link speed code to link speed
4853 * lpfc_sli4_async_link_evt - Process the asynchronous FCoE link event
4873 phba->fcoe_eventtag = acqe_link->event_tag; in lpfc_sli4_async_link_evt()
4874 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_async_link_evt()
4886 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); in lpfc_sli4_async_link_evt()
4887 if (!mp->virt) { in lpfc_sli4_async_link_evt()
4897 phba->sli4_hba.els_wq->pring->flag |= LPFC_STOP_IOCB_EVENT; in lpfc_sli4_async_link_evt()
4900 phba->sli.slistat.link_event++; in lpfc_sli4_async_link_evt()
4904 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_sli4_async_link_evt()
4905 pmb->vport = phba->pport; in lpfc_sli4_async_link_evt()
4908 phba->sli4_hba.link_state.speed = in lpfc_sli4_async_link_evt()
4911 phba->sli4_hba.link_state.duplex = in lpfc_sli4_async_link_evt()
4913 phba->sli4_hba.link_state.status = in lpfc_sli4_async_link_evt()
4915 phba->sli4_hba.link_state.type = in lpfc_sli4_async_link_evt()
4917 phba->sli4_hba.link_state.number = in lpfc_sli4_async_link_evt()
4919 phba->sli4_hba.link_state.fault = in lpfc_sli4_async_link_evt()
4921 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_link_evt()
4925 "2900 Async FC/FCoE Link event - Speed:%dGBit " in lpfc_sli4_async_link_evt()
4928 phba->sli4_hba.link_state.speed, in lpfc_sli4_async_link_evt()
4929 phba->sli4_hba.link_state.topology, in lpfc_sli4_async_link_evt()
4930 phba->sli4_hba.link_state.status, in lpfc_sli4_async_link_evt()
4931 phba->sli4_hba.link_state.type, in lpfc_sli4_async_link_evt()
4932 phba->sli4_hba.link_state.number, in lpfc_sli4_async_link_evt()
4933 phba->sli4_hba.link_state.logical_speed, in lpfc_sli4_async_link_evt()
4934 phba->sli4_hba.link_state.fault); in lpfc_sli4_async_link_evt()
4937 * topology info. Note: Optional for non FC-AL ports. in lpfc_sli4_async_link_evt()
4939 if (!(phba->hba_flag & HBA_FCOE_MODE)) { in lpfc_sli4_async_link_evt()
4951 mb = &pmb->u.mb; in lpfc_sli4_async_link_evt()
4952 mb->mbxStatus = MBX_SUCCESS; in lpfc_sli4_async_link_evt()
4958 la = (struct lpfc_mbx_read_top *) &pmb->u.mb.un.varReadTop; in lpfc_sli4_async_link_evt()
4959 la->eventTag = acqe_link->event_tag; in lpfc_sli4_async_link_evt()
4980 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_async_link_evt()
4984 * lpfc_async_link_speed_to_read_top - Parse async evt link speed code to read
5038 ((phba->trunk_link.link##__idx.state == LPFC_LINK_UP) ?\
5052 phba->sli4_hba.link_state.speed = in lpfc_update_trunk_link_status()
5056 phba->sli4_hba.link_state.logical_speed = in lpfc_update_trunk_link_status()
5059 phba->fc_linkspeed = in lpfc_update_trunk_link_status()
5065 phba->trunk_link.link0.state = in lpfc_update_trunk_link_status()
5068 phba->trunk_link.link0.fault = port_fault & 0x1 ? err : 0; in lpfc_update_trunk_link_status()
5071 phba->trunk_link.link1.state = in lpfc_update_trunk_link_status()
5074 phba->trunk_link.link1.fault = port_fault & 0x2 ? err : 0; in lpfc_update_trunk_link_status()
5077 phba->trunk_link.link2.state = in lpfc_update_trunk_link_status()
5080 phba->trunk_link.link2.fault = port_fault & 0x4 ? err : 0; in lpfc_update_trunk_link_status()
5083 phba->trunk_link.link3.state = in lpfc_update_trunk_link_status()
5086 phba->trunk_link.link3.fault = port_fault & 0x8 ? err : 0; in lpfc_update_trunk_link_status()
5090 "2910 Async FC Trunking Event - Speed:%d\n" in lpfc_update_trunk_link_status()
5093 phba->sli4_hba.link_state.speed, in lpfc_update_trunk_link_status()
5094 phba->sli4_hba.link_state.logical_speed, in lpfc_update_trunk_link_status()
5102 * SLI-4: We have only 0xA error codes in lpfc_update_trunk_link_status()
5114 * lpfc_sli4_async_fc_evt - Process the asynchronous FC link event
5146 phba->sli4_hba.link_state.speed = in lpfc_sli4_async_fc_evt()
5149 phba->sli4_hba.link_state.duplex = LPFC_ASYNC_LINK_DUPLEX_FULL; in lpfc_sli4_async_fc_evt()
5150 phba->sli4_hba.link_state.topology = in lpfc_sli4_async_fc_evt()
5152 phba->sli4_hba.link_state.status = in lpfc_sli4_async_fc_evt()
5154 phba->sli4_hba.link_state.type = in lpfc_sli4_async_fc_evt()
5156 phba->sli4_hba.link_state.number = in lpfc_sli4_async_fc_evt()
5158 phba->sli4_hba.link_state.fault = in lpfc_sli4_async_fc_evt()
5163 phba->sli4_hba.link_state.logical_speed = 0; in lpfc_sli4_async_fc_evt()
5164 else if (!phba->sli4_hba.conf_trunk) in lpfc_sli4_async_fc_evt()
5165 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_fc_evt()
5169 "2896 Async FC event - Speed:%dGBaud Topology:x%x " in lpfc_sli4_async_fc_evt()
5172 phba->sli4_hba.link_state.speed, in lpfc_sli4_async_fc_evt()
5173 phba->sli4_hba.link_state.topology, in lpfc_sli4_async_fc_evt()
5174 phba->sli4_hba.link_state.status, in lpfc_sli4_async_fc_evt()
5175 phba->sli4_hba.link_state.type, in lpfc_sli4_async_fc_evt()
5176 phba->sli4_hba.link_state.number, in lpfc_sli4_async_fc_evt()
5177 phba->sli4_hba.link_state.logical_speed, in lpfc_sli4_async_fc_evt()
5178 phba->sli4_hba.link_state.fault); in lpfc_sli4_async_fc_evt()
5179 pmb = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_async_fc_evt()
5191 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); in lpfc_sli4_async_fc_evt()
5192 if (!mp->virt) { in lpfc_sli4_async_fc_evt()
5202 phba->sli4_hba.els_wq->pring->flag |= LPFC_STOP_IOCB_EVENT; in lpfc_sli4_async_fc_evt()
5205 phba->sli.slistat.link_event++; in lpfc_sli4_async_fc_evt()
5209 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_topology; in lpfc_sli4_async_fc_evt()
5210 pmb->vport = phba->pport; in lpfc_sli4_async_fc_evt()
5212 if (phba->sli4_hba.link_state.status != LPFC_FC_LA_TYPE_LINK_UP) { in lpfc_sli4_async_fc_evt()
5213 phba->link_flag &= ~(LS_MDS_LINK_DOWN | LS_MDS_LOOPBACK); in lpfc_sli4_async_fc_evt()
5215 switch (phba->sli4_hba.link_state.status) { in lpfc_sli4_async_fc_evt()
5217 phba->link_flag |= LS_MDS_LINK_DOWN; in lpfc_sli4_async_fc_evt()
5220 phba->link_flag |= LS_MDS_LOOPBACK; in lpfc_sli4_async_fc_evt()
5227 mb = &pmb->u.mb; in lpfc_sli4_async_fc_evt()
5228 mb->mbxStatus = MBX_SUCCESS; in lpfc_sli4_async_fc_evt()
5234 la = (struct lpfc_mbx_read_top *)&pmb->u.mb.un.varReadTop; in lpfc_sli4_async_fc_evt()
5235 la->eventTag = acqe_fc->event_tag; in lpfc_sli4_async_fc_evt()
5237 if (phba->sli4_hba.link_state.status == in lpfc_sli4_async_fc_evt()
5259 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_async_fc_evt()
5263 * lpfc_sli4_async_sli_evt - Process the asynchronous SLI link event
5286 "2901 Async SLI event - Event Data1:x%08x Event Data2:" in lpfc_sli4_async_sli_evt()
5288 acqe_sli->event_data1, acqe_sli->event_data2, in lpfc_sli4_async_sli_evt()
5291 port_name = phba->Port[0]; in lpfc_sli4_async_sli_evt()
5299 temp_event_data.data = (uint32_t)acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
5302 "3190 Over Temperature:%d Celsius- Port Name %c\n", in lpfc_sli4_async_sli_evt()
5303 acqe_sli->event_data1, port_name); in lpfc_sli4_async_sli_evt()
5305 phba->sfp_warning |= LPFC_TRANSGRESSION_HIGH_TEMPERATURE; in lpfc_sli4_async_sli_evt()
5306 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli4_async_sli_evt()
5316 temp_event_data.data = (uint32_t)acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
5319 "3191 Normal Temperature:%d Celsius - Port Name %c\n", in lpfc_sli4_async_sli_evt()
5320 acqe_sli->event_data1, port_name); in lpfc_sli4_async_sli_evt()
5322 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli4_async_sli_evt()
5331 &acqe_sli->event_data1; in lpfc_sli4_async_sli_evt()
5334 switch (phba->sli4_hba.lnk_info.lnk_no) { in lpfc_sli4_async_sli_evt()
5337 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
5339 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
5343 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
5345 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
5349 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
5351 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
5355 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
5357 &misconfigured->theEvent); in lpfc_sli4_async_sli_evt()
5364 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_async_sli_evt()
5369 if (phba->sli4_hba.lnk_info.optic_state == status) in lpfc_sli4_async_sli_evt()
5378 "installed/not installed - Reseat optics, " in lpfc_sli4_async_sli_evt()
5383 "Optics of two types installed - Remove one " in lpfc_sli4_async_sli_evt()
5387 sprintf(message, "Incompatible optics - Replace with " in lpfc_sli4_async_sli_evt()
5391 sprintf(message, "Unqualified optics - Replace with " in lpfc_sli4_async_sli_evt()
5393 "Support - Link is%s operational", in lpfc_sli4_async_sli_evt()
5397 sprintf(message, "Uncertified optics - Replace with " in lpfc_sli4_async_sli_evt()
5398 "Avago-certified optics to enable link " in lpfc_sli4_async_sli_evt()
5399 "operation - Link is%s operational", in lpfc_sli4_async_sli_evt()
5411 phba->lmt = 0; in lpfc_sli4_async_sli_evt()
5418 for (i = 0; i <= phba->max_vports && vports[i] != NULL; in lpfc_sli4_async_sli_evt()
5426 phba->sli4_hba.lnk_info.optic_state = status; in lpfc_sli4_async_sli_evt()
5432 "3192 Remote DPort Test Initiated - " in lpfc_sli4_async_sli_evt()
5434 acqe_sli->event_data1, acqe_sli->event_data2); in lpfc_sli4_async_sli_evt()
5438 "3193 Async SLI event - Event Data1:x%08x Event Data2:" in lpfc_sli4_async_sli_evt()
5440 acqe_sli->event_data1, acqe_sli->event_data2, in lpfc_sli4_async_sli_evt()
5447 * lpfc_sli4_perform_vport_cvl - Perform clear virtual link on a vport
5465 phba = vport->phba; in lpfc_sli4_perform_vport_cvl()
5475 ndlp->nlp_type |= NLP_FABRIC; in lpfc_sli4_perform_vport_cvl()
5479 /* re-setup ndlp without removing from node list */ in lpfc_sli4_perform_vport_cvl()
5484 if ((phba->pport->port_state < LPFC_FLOGI) && in lpfc_sli4_perform_vport_cvl()
5485 (phba->pport->port_state != LPFC_VPORT_FAILED)) in lpfc_sli4_perform_vport_cvl()
5488 if ((vport != phba->pport) && (vport->port_state < LPFC_FDISC) in lpfc_sli4_perform_vport_cvl()
5489 && (vport->port_state != LPFC_VPORT_FAILED)) in lpfc_sli4_perform_vport_cvl()
5496 spin_lock_irq(shost->host_lock); in lpfc_sli4_perform_vport_cvl()
5497 vport->fc_flag |= FC_VPORT_CVL_RCVD; in lpfc_sli4_perform_vport_cvl()
5498 spin_unlock_irq(shost->host_lock); in lpfc_sli4_perform_vport_cvl()
5504 * lpfc_sli4_perform_all_vport_cvl - Perform clear virtual link on all vports
5518 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) in lpfc_sli4_perform_all_vport_cvl()
5524 * lpfc_sli4_async_fip_evt - Process the asynchronous FCoE FIP event
5543 phba->fc_eventTag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
5544 phba->fcoe_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
5553 acqe_fip->event_tag, in lpfc_sli4_async_fip_evt()
5554 acqe_fip->index); in lpfc_sli4_async_fip_evt()
5560 acqe_fip->event_tag, in lpfc_sli4_async_fip_evt()
5561 acqe_fip->index); in lpfc_sli4_async_fip_evt()
5562 if (phba->fcf.fcf_flag & FCF_DISCOVERY) { in lpfc_sli4_async_fip_evt()
5572 acqe_fip->index); in lpfc_sli4_async_fip_evt()
5573 rc = lpfc_sli4_read_fcf_rec(phba, acqe_fip->index); in lpfc_sli4_async_fip_evt()
5577 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5578 if (phba->hba_flag & FCF_TS_INPROG) { in lpfc_sli4_async_fip_evt()
5579 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5583 if (phba->fcf.fcf_flag & (FCF_REDISC_EVT | FCF_REDISC_PEND)) { in lpfc_sli4_async_fip_evt()
5584 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5589 if (phba->fcf.fcf_flag & FCF_SCAN_DONE) { in lpfc_sli4_async_fip_evt()
5590 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5593 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5595 /* Otherwise, scan the entire FCF table and re-discover SAN */ in lpfc_sli4_async_fip_evt()
5599 acqe_fip->event_tag, acqe_fip->index); in lpfc_sli4_async_fip_evt()
5612 acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
5616 phba->fcoe_cvl_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
5619 "tag:x%x\n", acqe_fip->index, acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
5624 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5625 if ((phba->fcf.fcf_flag & FCF_DISCOVERY) && in lpfc_sli4_async_fip_evt()
5626 (phba->fcf.current_rec.fcf_indx != acqe_fip->index)) { in lpfc_sli4_async_fip_evt()
5627 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5629 lpfc_sli4_fcf_rr_index_clear(phba, acqe_fip->index); in lpfc_sli4_async_fip_evt()
5632 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5635 if (phba->fcf.current_rec.fcf_indx != acqe_fip->index) in lpfc_sli4_async_fip_evt()
5644 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5646 phba->fcf.fcf_flag |= FCF_DEAD_DISC; in lpfc_sli4_async_fip_evt()
5647 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5652 "\n", acqe_fip->event_tag, acqe_fip->index); in lpfc_sli4_async_fip_evt()
5660 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5661 phba->fcf.fcf_flag &= ~FCF_DEAD_DISC; in lpfc_sli4_async_fip_evt()
5662 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5679 phba->fcoe_cvl_eventtag = acqe_fip->event_tag; in lpfc_sli4_async_fip_evt()
5682 " tag 0x%x\n", acqe_fip->index, acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
5685 acqe_fip->index); in lpfc_sli4_async_fip_evt()
5693 for (i = 0; i <= phba->max_vports && vports[i] != NULL; in lpfc_sli4_async_fip_evt()
5695 if ((!(vports[i]->fc_flag & in lpfc_sli4_async_fip_evt()
5697 (vports[i]->port_state > LPFC_FDISC)) { in lpfc_sli4_async_fip_evt()
5706 * Don't re-instantiate if vport is marked for deletion. in lpfc_sli4_async_fip_evt()
5710 if (!(vport->load_flag & FC_UNLOADING) && in lpfc_sli4_async_fip_evt()
5714 * re-instantiate the Vlink using FDISC. in lpfc_sli4_async_fip_evt()
5716 mod_timer(&ndlp->nlp_delayfunc, in lpfc_sli4_async_fip_evt()
5719 spin_lock_irq(shost->host_lock); in lpfc_sli4_async_fip_evt()
5720 ndlp->nlp_flag |= NLP_DELAY_TMO; in lpfc_sli4_async_fip_evt()
5721 spin_unlock_irq(shost->host_lock); in lpfc_sli4_async_fip_evt()
5722 ndlp->nlp_last_elscmd = ELS_CMD_FDISC; in lpfc_sli4_async_fip_evt()
5723 vport->port_state = LPFC_FDISC; in lpfc_sli4_async_fip_evt()
5732 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5733 if (phba->fcf.fcf_flag & FCF_DISCOVERY) { in lpfc_sli4_async_fip_evt()
5734 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5738 phba->fcf.fcf_flag |= FCF_ACVL_DISC; in lpfc_sli4_async_fip_evt()
5739 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5743 "evt_tag:x%x\n", acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
5751 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5752 phba->fcf.fcf_flag &= ~FCF_ACVL_DISC; in lpfc_sli4_async_fip_evt()
5753 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_fip_evt()
5755 * Last resort will be re-try on the in lpfc_sli4_async_fip_evt()
5770 "0x%x\n", event_type, acqe_fip->event_tag); in lpfc_sli4_async_fip_evt()
5776 * lpfc_sli4_async_dcbx_evt - Process the asynchronous dcbx event
5786 phba->fc_eventTag = acqe_dcbx->event_tag; in lpfc_sli4_async_dcbx_evt()
5793 * lpfc_sli4_async_grp5_evt - Process the asynchronous group5 event
5807 phba->fc_eventTag = acqe_grp5->event_tag; in lpfc_sli4_async_grp5_evt()
5808 phba->fcoe_eventtag = acqe_grp5->event_tag; in lpfc_sli4_async_grp5_evt()
5809 prev_ll_spd = phba->sli4_hba.link_state.logical_speed; in lpfc_sli4_async_grp5_evt()
5810 phba->sli4_hba.link_state.logical_speed = in lpfc_sli4_async_grp5_evt()
5815 phba->sli4_hba.link_state.logical_speed); in lpfc_sli4_async_grp5_evt()
5819 * lpfc_sli4_async_event_proc - Process all the pending asynchronous event
5830 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_event_proc()
5831 phba->hba_flag &= ~ASYNC_EVENT; in lpfc_sli4_async_event_proc()
5832 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_event_proc()
5834 while (!list_empty(&phba->sli4_hba.sp_asynce_work_queue)) { in lpfc_sli4_async_event_proc()
5836 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_event_proc()
5837 list_remove_head(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_async_event_proc()
5839 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_event_proc()
5841 switch (bf_get(lpfc_trailer_code, &cq_event->cqe.mcqe_cmpl)) { in lpfc_sli4_async_event_proc()
5844 &cq_event->cqe.acqe_link); in lpfc_sli4_async_event_proc()
5847 lpfc_sli4_async_fip_evt(phba, &cq_event->cqe.acqe_fip); in lpfc_sli4_async_event_proc()
5851 &cq_event->cqe.acqe_dcbx); in lpfc_sli4_async_event_proc()
5855 &cq_event->cqe.acqe_grp5); in lpfc_sli4_async_event_proc()
5858 lpfc_sli4_async_fc_evt(phba, &cq_event->cqe.acqe_fc); in lpfc_sli4_async_event_proc()
5861 lpfc_sli4_async_sli_evt(phba, &cq_event->cqe.acqe_sli); in lpfc_sli4_async_event_proc()
5867 &cq_event->cqe.mcqe_cmpl)); in lpfc_sli4_async_event_proc()
5876 * lpfc_sli4_fcf_redisc_event_proc - Process fcf table rediscovery event
5886 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_event_proc()
5888 phba->fcf.fcf_flag &= ~FCF_REDISC_EVT; in lpfc_sli4_fcf_redisc_event_proc()
5890 phba->fcf.failover_rec.flag = 0; in lpfc_sli4_fcf_redisc_event_proc()
5892 phba->fcf.fcf_flag |= FCF_REDISC_FOV; in lpfc_sli4_fcf_redisc_event_proc()
5893 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_redisc_event_proc()
5895 /* Scan FCF table from the first entry to re-discover SAN */ in lpfc_sli4_fcf_redisc_event_proc()
5897 "2777 Start post-quiescent FCF table scan\n"); in lpfc_sli4_fcf_redisc_event_proc()
5906 * lpfc_api_table_setup - Set up per hba pci-device group func api jump table
5908 * @dev_grp: The HBA PCI-Device group number.
5910 * This routine is invoked to set up the per HBA PCI-Device group function
5913 * Return: 0 if success, otherwise -ENODEV
5920 /* Set up lpfc PCI-device group */ in lpfc_api_table_setup()
5921 phba->pci_dev_grp = dev_grp; in lpfc_api_table_setup()
5925 phba->sli_rev = LPFC_SLI_REV4; in lpfc_api_table_setup()
5930 return -ENODEV; in lpfc_api_table_setup()
5934 return -ENODEV; in lpfc_api_table_setup()
5938 return -ENODEV; in lpfc_api_table_setup()
5942 return -ENODEV; in lpfc_api_table_setup()
5948 * lpfc_log_intr_mode - Log the active interrupt mode
5968 "0480 Enabled MSI-X interrupt mode.\n"); in lpfc_log_intr_mode()
5979 * lpfc_enable_pci_dev - Enable a generic PCI device.
5986 * 0 - successful
5987 * other values - error
5995 if (!phba->pcidev) in lpfc_enable_pci_dev()
5998 pdev = phba->pcidev; in lpfc_enable_pci_dev()
6012 pdev->needs_freset = 1; in lpfc_enable_pci_dev()
6021 return -ENODEV; in lpfc_enable_pci_dev()
6025 * lpfc_disable_pci_dev - Disable a generic PCI device.
6037 if (!phba->pcidev) in lpfc_disable_pci_dev()
6040 pdev = phba->pcidev; in lpfc_disable_pci_dev()
6049 * lpfc_reset_hba - Reset a hba
6061 if (!phba->cfg_enable_hba_reset) { in lpfc_reset_hba()
6062 phba->link_state = LPFC_HBA_ERROR; in lpfc_reset_hba()
6065 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE) in lpfc_reset_hba()
6076 * lpfc_sli_sriov_nr_virtfn_get - Get the number of sr-iov virtual functions
6079 * This function enables the PCI SR-IOV virtual functions to a physical
6080 * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
6082 * not all devices support SR-IOV, the return code from the pci_enable_sriov()
6088 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_sriov_nr_virtfn_get()
6101 * lpfc_sli_probe_sriov_nr_virtfn - Enable a number of sr-iov virtual functions
6105 * This function enables the PCI SR-IOV virtual functions to a physical
6106 * function. It invokes the PCI SR-IOV api with the @nr_vfn provided to
6108 * not all devices support SR-IOV, the return code from the pci_enable_sriov()
6114 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_probe_sriov_nr_virtfn()
6123 return -EINVAL; in lpfc_sli_probe_sriov_nr_virtfn()
6140 * lpfc_setup_driver_resource_phase1 - Phase1 etup driver internal resources.
6147 * 0 - successful
6148 * other values - error
6153 struct lpfc_sli *psli = &phba->sli; in lpfc_setup_driver_resource_phase1()
6158 atomic_set(&phba->fast_event_count, 0); in lpfc_setup_driver_resource_phase1()
6159 spin_lock_init(&phba->hbalock); in lpfc_setup_driver_resource_phase1()
6162 spin_lock_init(&phba->ndlp_lock); in lpfc_setup_driver_resource_phase1()
6165 spin_lock_init(&phba->port_list_lock); in lpfc_setup_driver_resource_phase1()
6166 INIT_LIST_HEAD(&phba->port_list); in lpfc_setup_driver_resource_phase1()
6168 INIT_LIST_HEAD(&phba->work_list); in lpfc_setup_driver_resource_phase1()
6169 init_waitqueue_head(&phba->wait_4_mlo_m_q); in lpfc_setup_driver_resource_phase1()
6172 init_waitqueue_head(&phba->work_waitq); in lpfc_setup_driver_resource_phase1()
6176 ((phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) ? in lpfc_setup_driver_resource_phase1()
6178 ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) ? in lpfc_setup_driver_resource_phase1()
6180 (phba->nvmet_support ? "NVMET" : " ")); in lpfc_setup_driver_resource_phase1()
6183 spin_lock_init(&phba->scsi_buf_list_get_lock); in lpfc_setup_driver_resource_phase1()
6184 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_get); in lpfc_setup_driver_resource_phase1()
6185 spin_lock_init(&phba->scsi_buf_list_put_lock); in lpfc_setup_driver_resource_phase1()
6186 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list_put); in lpfc_setup_driver_resource_phase1()
6189 INIT_LIST_HEAD(&phba->fabric_iocb_list); in lpfc_setup_driver_resource_phase1()
6192 INIT_LIST_HEAD(&phba->elsbuf); in lpfc_setup_driver_resource_phase1()
6195 INIT_LIST_HEAD(&phba->fcf_conn_rec_list); in lpfc_setup_driver_resource_phase1()
6198 spin_lock_init(&phba->devicelock); in lpfc_setup_driver_resource_phase1()
6199 INIT_LIST_HEAD(&phba->luns); in lpfc_setup_driver_resource_phase1()
6202 timer_setup(&psli->mbox_tmo, lpfc_mbox_timeout, 0); in lpfc_setup_driver_resource_phase1()
6204 timer_setup(&phba->fabric_block_timer, lpfc_fabric_block_timeout, 0); in lpfc_setup_driver_resource_phase1()
6206 timer_setup(&phba->eratt_poll, lpfc_poll_eratt, 0); in lpfc_setup_driver_resource_phase1()
6208 timer_setup(&phba->hb_tmofunc, lpfc_hb_timeout, 0); in lpfc_setup_driver_resource_phase1()
6210 INIT_DELAYED_WORK(&phba->eq_delay_work, lpfc_hb_eq_delay_work); in lpfc_setup_driver_resource_phase1()
6216 * lpfc_sli_driver_resource_setup - Setup driver internal resources for SLI3 dev
6220 * support the SLI-3 HBA device it attached to.
6223 * 0 - successful
6224 * other values - error
6236 timer_setup(&phba->fcp_poll_timer, lpfc_poll_timeout, 0); in lpfc_sli_driver_resource_setup()
6239 phba->work_ha_mask = (HA_ERATT | HA_MBATT | HA_LATT); in lpfc_sli_driver_resource_setup()
6240 phba->work_ha_mask |= (HA_RXMASK << (LPFC_ELS_RING * 4)); in lpfc_sli_driver_resource_setup()
6244 /* Set up phase-1 common device driver resources */ in lpfc_sli_driver_resource_setup()
6248 return -ENODEV; in lpfc_sli_driver_resource_setup()
6250 if (phba->pcidev->device == PCI_DEVICE_ID_HORNET) { in lpfc_sli_driver_resource_setup()
6251 phba->menlo_flag |= HBA_MENLO_SUPPORT; in lpfc_sli_driver_resource_setup()
6253 if (phba->cfg_sg_seg_cnt < LPFC_DEFAULT_MENLO_SG_SEG_CNT) in lpfc_sli_driver_resource_setup()
6254 phba->cfg_sg_seg_cnt = LPFC_DEFAULT_MENLO_SG_SEG_CNT; in lpfc_sli_driver_resource_setup()
6257 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
6258 phba->sli.sli3_ring = kcalloc(LPFC_SLI3_MAX_RING, in lpfc_sli_driver_resource_setup()
6261 if (!phba->sli.sli3_ring) in lpfc_sli_driver_resource_setup()
6262 return -ENOMEM; in lpfc_sli_driver_resource_setup()
6270 lpfc_vport_template.sg_tablesize = phba->cfg_sg_seg_cnt; in lpfc_sli_driver_resource_setup()
6271 lpfc_template_no_hr.sg_tablesize = phba->cfg_sg_seg_cnt; in lpfc_sli_driver_resource_setup()
6272 lpfc_template.sg_tablesize = phba->cfg_sg_seg_cnt; in lpfc_sli_driver_resource_setup()
6274 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_driver_resource_setup()
6280 if (phba->cfg_enable_bg) { in lpfc_sli_driver_resource_setup()
6282 * The scsi_buf for a T10-DIF I/O will hold the FCP cmnd, in lpfc_sli_driver_resource_setup()
6290 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
6294 if (phba->cfg_sg_seg_cnt > LPFC_MAX_SG_SEG_CNT_DIF) in lpfc_sli_driver_resource_setup()
6295 phba->cfg_sg_seg_cnt = LPFC_MAX_SG_SEG_CNT_DIF; in lpfc_sli_driver_resource_setup()
6298 phba->cfg_total_seg_cnt = LPFC_MAX_SG_SEG_CNT; in lpfc_sli_driver_resource_setup()
6305 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli_driver_resource_setup()
6307 ((phba->cfg_sg_seg_cnt + 2) * entry_sz); in lpfc_sli_driver_resource_setup()
6310 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + 2; in lpfc_sli_driver_resource_setup()
6315 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
6316 phba->cfg_total_seg_cnt); in lpfc_sli_driver_resource_setup()
6318 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli_driver_resource_setup()
6320 phba->max_vports = 0; in lpfc_sli_driver_resource_setup()
6330 return -ENOMEM; in lpfc_sli_driver_resource_setup()
6332 phba->lpfc_sg_dma_buf_pool = in lpfc_sli_driver_resource_setup()
6334 &phba->pcidev->dev, phba->cfg_sg_dma_buf_size, in lpfc_sli_driver_resource_setup()
6337 if (!phba->lpfc_sg_dma_buf_pool) in lpfc_sli_driver_resource_setup()
6340 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli_driver_resource_setup()
6342 &phba->pcidev->dev, in lpfc_sli_driver_resource_setup()
6347 if (!phba->lpfc_cmd_rsp_buf_pool) in lpfc_sli_driver_resource_setup()
6351 * Enable sr-iov virtual functions if supported and configured in lpfc_sli_driver_resource_setup()
6354 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli_driver_resource_setup()
6356 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
6359 "2808 Requested number of SR-IOV " in lpfc_sli_driver_resource_setup()
6362 phba->cfg_sriov_nr_virtfn); in lpfc_sli_driver_resource_setup()
6363 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli_driver_resource_setup()
6370 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli_driver_resource_setup()
6371 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli_driver_resource_setup()
6374 return -ENOMEM; in lpfc_sli_driver_resource_setup()
6378 * lpfc_sli_driver_resource_unset - Unset drvr internal resources for SLI3 dev
6382 * specific for supporting the SLI-3 HBA device it attached to.
6394 * lpfc_sli4_driver_resource_setup - Setup drvr internal resources for SLI4 dev
6398 * support the SLI-4 HBA device it attached to.
6401 * 0 - successful
6402 * other values - error
6418 phba->sli4_hba.num_present_cpu = lpfc_present_cpu; in lpfc_sli4_driver_resource_setup()
6419 phba->sli4_hba.num_possible_cpu = num_possible_cpus(); in lpfc_sli4_driver_resource_setup()
6420 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_setup()
6425 /* Set up phase-1 common device driver resources */ in lpfc_sli4_driver_resource_setup()
6428 return -ENODEV; in lpfc_sli4_driver_resource_setup()
6433 return -ENODEV; in lpfc_sli4_driver_resource_setup()
6438 phba->wq = alloc_workqueue("lpfc_wq", WQ_MEM_RECLAIM, 0); in lpfc_sli4_driver_resource_setup()
6444 timer_setup(&phba->rrq_tmr, lpfc_rrq_timeout, 0); in lpfc_sli4_driver_resource_setup()
6447 timer_setup(&phba->fcf.redisc_wait, lpfc_sli4_fcf_redisc_wait_tmo, 0); in lpfc_sli4_driver_resource_setup()
6450 * Control structure for handling external multi-buffer mailbox in lpfc_sli4_driver_resource_setup()
6451 * command pass-through. in lpfc_sli4_driver_resource_setup()
6453 memset((uint8_t *)&phba->mbox_ext_buf_ctx, 0, in lpfc_sli4_driver_resource_setup()
6455 INIT_LIST_HEAD(&phba->mbox_ext_buf_ctx.ext_dmabuf_list); in lpfc_sli4_driver_resource_setup()
6457 phba->max_vpi = LPFC_MAX_VPI; in lpfc_sli4_driver_resource_setup()
6460 phba->max_vports = 0; in lpfc_sli4_driver_resource_setup()
6463 phba->valid_vlan = 0; in lpfc_sli4_driver_resource_setup()
6464 phba->fc_map[0] = LPFC_FCOE_FCF_MAP0; in lpfc_sli4_driver_resource_setup()
6465 phba->fc_map[1] = LPFC_FCOE_FCF_MAP1; in lpfc_sli4_driver_resource_setup()
6466 phba->fc_map[2] = LPFC_FCOE_FCF_MAP2; in lpfc_sli4_driver_resource_setup()
6475 INIT_LIST_HEAD(&phba->hbqs[LPFC_ELS_HBQ].hbq_buffer_list); in lpfc_sli4_driver_resource_setup()
6476 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_sli4_rb_alloc; in lpfc_sli4_driver_resource_setup()
6477 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_sli4_rb_free; in lpfc_sli4_driver_resource_setup()
6483 spin_lock_init(&phba->sli4_hba.abts_io_buf_list_lock); in lpfc_sli4_driver_resource_setup()
6484 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_io_buf_list); in lpfc_sli4_driver_resource_setup()
6486 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
6488 spin_lock_init(&phba->sli4_hba.abts_nvmet_buf_list_lock); in lpfc_sli4_driver_resource_setup()
6489 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_driver_resource_setup()
6490 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_io_wait_list); in lpfc_sli4_driver_resource_setup()
6491 spin_lock_init(&phba->sli4_hba.t_active_list_lock); in lpfc_sli4_driver_resource_setup()
6492 INIT_LIST_HEAD(&phba->sli4_hba.t_active_ctx_list); in lpfc_sli4_driver_resource_setup()
6496 spin_lock_init(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_driver_resource_setup()
6497 spin_lock_init(&phba->sli4_hba.nvmet_io_wait_lock); in lpfc_sli4_driver_resource_setup()
6500 * Initialize driver internal slow-path work queues in lpfc_sli4_driver_resource_setup()
6503 /* Driver internel slow-path CQ Event pool */ in lpfc_sli4_driver_resource_setup()
6504 INIT_LIST_HEAD(&phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_driver_resource_setup()
6506 INIT_LIST_HEAD(&phba->sli4_hba.sp_queue_event); in lpfc_sli4_driver_resource_setup()
6508 INIT_LIST_HEAD(&phba->sli4_hba.sp_asynce_work_queue); in lpfc_sli4_driver_resource_setup()
6509 /* Fast-path XRI aborted CQ Event work queue list */ in lpfc_sli4_driver_resource_setup()
6510 INIT_LIST_HEAD(&phba->sli4_hba.sp_fcp_xri_aborted_work_queue); in lpfc_sli4_driver_resource_setup()
6511 /* Slow-path XRI aborted CQ Event work queue list */ in lpfc_sli4_driver_resource_setup()
6512 INIT_LIST_HEAD(&phba->sli4_hba.sp_els_xri_aborted_work_queue); in lpfc_sli4_driver_resource_setup()
6514 INIT_LIST_HEAD(&phba->sli4_hba.sp_unsol_work_queue); in lpfc_sli4_driver_resource_setup()
6517 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_blk_list); in lpfc_sli4_driver_resource_setup()
6518 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_xri_blk_list); in lpfc_sli4_driver_resource_setup()
6519 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_vfi_blk_list); in lpfc_sli4_driver_resource_setup()
6520 INIT_LIST_HEAD(&phba->lpfc_vpi_blk_list); in lpfc_sli4_driver_resource_setup()
6525 INIT_LIST_HEAD(&phba->sli.mboxq); in lpfc_sli4_driver_resource_setup()
6526 INIT_LIST_HEAD(&phba->sli.mboxq_cmpl); in lpfc_sli4_driver_resource_setup()
6529 phba->sli4_hba.lnk_info.optic_state = 0xff; in lpfc_sli4_driver_resource_setup()
6534 return -ENOMEM; in lpfc_sli4_driver_resource_setup()
6537 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_driver_resource_setup()
6541 rc = -ENODEV; in lpfc_sli4_driver_resource_setup()
6544 phba->temp_sensor_support = 1; in lpfc_sli4_driver_resource_setup()
6566 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_driver_resource_setup()
6573 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_sli4_driver_resource_setup()
6576 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
6581 phba->nvmet_support = 0; in lpfc_sli4_driver_resource_setup()
6591 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_driver_resource_setup()
6592 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_driver_resource_setup()
6593 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
6594 rc = -EIO; in lpfc_sli4_driver_resource_setup()
6597 mb = &mboxq->u.mb; in lpfc_sli4_driver_resource_setup()
6598 memcpy(&wwn, (char *)mb->un.varRDnvp.nodename, in lpfc_sli4_driver_resource_setup()
6601 phba->sli4_hba.wwnn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
6602 memcpy(&wwn, (char *)mb->un.varRDnvp.portname, in lpfc_sli4_driver_resource_setup()
6606 phba->sli4_hba.wwpn.u.name = wwn; in lpfc_sli4_driver_resource_setup()
6615 phba->nvmet_support = 1; /* a match */ in lpfc_sli4_driver_resource_setup()
6627 phba->cfg_xri_rebalancing = 0; in lpfc_sli4_driver_resource_setup()
6639 mqe = &mboxq->u.mqe; in lpfc_sli4_driver_resource_setup()
6640 memcpy(&pn_page[0], ((uint8_t *)&mqe->un.supp_pages.word3), in lpfc_sli4_driver_resource_setup()
6645 phba->sli4_hba.pc_sli4_params.supported = 1; in lpfc_sli4_driver_resource_setup()
6652 if (phba->sli4_hba.pc_sli4_params.supported) in lpfc_sli4_driver_resource_setup()
6655 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
6656 rc = -EIO; in lpfc_sli4_driver_resource_setup()
6669 &phba->sli4_hba.sli_intf); in lpfc_sli4_driver_resource_setup()
6671 &phba->sli4_hba.sli_intf); in lpfc_sli4_driver_resource_setup()
6672 if (phba->sli4_hba.extents_in_use && in lpfc_sli4_driver_resource_setup()
6673 phba->sli4_hba.rpi_hdrs_in_use) { in lpfc_sli4_driver_resource_setup()
6679 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
6680 rc = -EIO; in lpfc_sli4_driver_resource_setup()
6686 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
6687 rc = -EIO; in lpfc_sli4_driver_resource_setup()
6697 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_driver_resource_setup()
6711 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) { in lpfc_sli4_driver_resource_setup()
6715 * The scsi_buf for a T10-DIF I/O holds the FCP cmnd, in lpfc_sli4_driver_resource_setup()
6723 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli4_driver_resource_setup()
6727 phba->cfg_total_seg_cnt = LPFC_MAX_SGL_SEG_CNT; in lpfc_sli4_driver_resource_setup()
6733 if (phba->cfg_enable_bg && in lpfc_sli4_driver_resource_setup()
6734 phba->cfg_sg_seg_cnt > LPFC_MAX_BG_SLI4_SEG_CNT_DIF) in lpfc_sli4_driver_resource_setup()
6735 phba->cfg_scsi_seg_cnt = LPFC_MAX_BG_SLI4_SEG_CNT_DIF; in lpfc_sli4_driver_resource_setup()
6737 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
6745 phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) + in lpfc_sli4_driver_resource_setup()
6747 ((phba->cfg_sg_seg_cnt + extra) * in lpfc_sli4_driver_resource_setup()
6751 phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + extra; in lpfc_sli4_driver_resource_setup()
6752 phba->cfg_scsi_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
6755 * NOTE: if (phba->cfg_sg_seg_cnt + extra) <= 256 we only in lpfc_sli4_driver_resource_setup()
6760 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_driver_resource_setup()
6761 phba->cfg_sg_dma_buf_size = LPFC_DEFAULT_XPSGL_SIZE; in lpfc_sli4_driver_resource_setup()
6762 else if (phba->cfg_sg_dma_buf_size <= LPFC_MIN_SG_SLI4_BUF_SZ) in lpfc_sli4_driver_resource_setup()
6763 phba->cfg_sg_dma_buf_size = LPFC_MIN_SG_SLI4_BUF_SZ; in lpfc_sli4_driver_resource_setup()
6765 phba->cfg_sg_dma_buf_size = in lpfc_sli4_driver_resource_setup()
6766 SLI4_PAGE_ALIGN(phba->cfg_sg_dma_buf_size); in lpfc_sli4_driver_resource_setup()
6768 phba->border_sge_num = phba->cfg_sg_dma_buf_size / in lpfc_sli4_driver_resource_setup()
6772 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_driver_resource_setup()
6773 if (phba->cfg_sg_seg_cnt > LPFC_MAX_NVME_SEG_CNT) { in lpfc_sli4_driver_resource_setup()
6778 phba->cfg_nvme_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_sli4_driver_resource_setup()
6780 phba->cfg_nvme_seg_cnt = phba->cfg_sg_seg_cnt; in lpfc_sli4_driver_resource_setup()
6784 lpfc_vport_template.sg_tablesize = phba->cfg_scsi_seg_cnt; in lpfc_sli4_driver_resource_setup()
6785 lpfc_template.sg_tablesize = phba->cfg_scsi_seg_cnt; in lpfc_sli4_driver_resource_setup()
6786 lpfc_template_no_hr.sg_tablesize = phba->cfg_scsi_seg_cnt; in lpfc_sli4_driver_resource_setup()
6791 phba->cfg_sg_seg_cnt, phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
6792 phba->cfg_total_seg_cnt, phba->cfg_scsi_seg_cnt, in lpfc_sli4_driver_resource_setup()
6793 phba->cfg_nvme_seg_cnt); in lpfc_sli4_driver_resource_setup()
6795 if (phba->cfg_sg_dma_buf_size < SLI4_PAGE_SIZE) in lpfc_sli4_driver_resource_setup()
6796 i = phba->cfg_sg_dma_buf_size; in lpfc_sli4_driver_resource_setup()
6800 phba->lpfc_sg_dma_buf_pool = in lpfc_sli4_driver_resource_setup()
6802 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
6803 phba->cfg_sg_dma_buf_size, in lpfc_sli4_driver_resource_setup()
6805 if (!phba->lpfc_sg_dma_buf_pool) in lpfc_sli4_driver_resource_setup()
6808 phba->lpfc_cmd_rsp_buf_pool = in lpfc_sli4_driver_resource_setup()
6810 &phba->pcidev->dev, in lpfc_sli4_driver_resource_setup()
6814 if (!phba->lpfc_cmd_rsp_buf_pool) in lpfc_sli4_driver_resource_setup()
6817 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_driver_resource_setup()
6853 longs = (LPFC_SLI4_FCF_TBL_INDX_MAX + BITS_PER_LONG - 1)/BITS_PER_LONG; in lpfc_sli4_driver_resource_setup()
6854 phba->fcf.fcf_rr_bmask = kcalloc(longs, sizeof(unsigned long), in lpfc_sli4_driver_resource_setup()
6856 if (!phba->fcf.fcf_rr_bmask) { in lpfc_sli4_driver_resource_setup()
6860 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
6864 phba->sli4_hba.hba_eq_hdl = kcalloc(phba->cfg_irq_chann, in lpfc_sli4_driver_resource_setup()
6867 if (!phba->sli4_hba.hba_eq_hdl) { in lpfc_sli4_driver_resource_setup()
6870 "fast-path per-EQ handle array\n"); in lpfc_sli4_driver_resource_setup()
6871 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
6875 phba->sli4_hba.cpu_map = kcalloc(phba->sli4_hba.num_possible_cpu, in lpfc_sli4_driver_resource_setup()
6878 if (!phba->sli4_hba.cpu_map) { in lpfc_sli4_driver_resource_setup()
6880 "3327 Failed allocate memory for msi-x " in lpfc_sli4_driver_resource_setup()
6882 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
6886 phba->sli4_hba.eq_info = alloc_percpu(struct lpfc_eq_intr_info); in lpfc_sli4_driver_resource_setup()
6887 if (!phba->sli4_hba.eq_info) { in lpfc_sli4_driver_resource_setup()
6890 rc = -ENOMEM; in lpfc_sli4_driver_resource_setup()
6894 * Enable sr-iov virtual functions if supported and configured in lpfc_sli4_driver_resource_setup()
6897 if (phba->cfg_sriov_nr_virtfn > 0) { in lpfc_sli4_driver_resource_setup()
6899 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
6902 "3020 Requested number of SR-IOV " in lpfc_sli4_driver_resource_setup()
6905 phba->cfg_sriov_nr_virtfn); in lpfc_sli4_driver_resource_setup()
6906 phba->cfg_sriov_nr_virtfn = 0; in lpfc_sli4_driver_resource_setup()
6913 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_setup()
6915 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_setup()
6917 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_setup()
6925 dma_pool_destroy(phba->lpfc_cmd_rsp_buf_pool); in lpfc_sli4_driver_resource_setup()
6926 phba->lpfc_cmd_rsp_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
6928 dma_pool_destroy(phba->lpfc_sg_dma_buf_pool); in lpfc_sli4_driver_resource_setup()
6929 phba->lpfc_sg_dma_buf_pool = NULL; in lpfc_sli4_driver_resource_setup()
6938 * lpfc_sli4_driver_resource_unset - Unset drvr internal resources for SLI4 dev
6942 * specific for supporting the SLI-4 HBA device it attached to.
6949 free_percpu(phba->sli4_hba.eq_info); in lpfc_sli4_driver_resource_unset()
6951 /* Free memory allocated for msi-x interrupt vector to CPU mapping */ in lpfc_sli4_driver_resource_unset()
6952 kfree(phba->sli4_hba.cpu_map); in lpfc_sli4_driver_resource_unset()
6953 phba->sli4_hba.num_possible_cpu = 0; in lpfc_sli4_driver_resource_unset()
6954 phba->sli4_hba.num_present_cpu = 0; in lpfc_sli4_driver_resource_unset()
6955 phba->sli4_hba.curr_disp_cpu = 0; in lpfc_sli4_driver_resource_unset()
6957 /* Free memory allocated for fast-path work queue handles */ in lpfc_sli4_driver_resource_unset()
6958 kfree(phba->sli4_hba.hba_eq_hdl); in lpfc_sli4_driver_resource_unset()
6965 kfree(phba->fcf.fcf_rr_bmask); in lpfc_sli4_driver_resource_unset()
6987 &phba->fcf_conn_rec_list, list) { in lpfc_sli4_driver_resource_unset()
6988 list_del_init(&conn_entry->list); in lpfc_sli4_driver_resource_unset()
6996 * lpfc_init_api_table_setup - Set up init api function jump table
6998 * @dev_grp: The HBA PCI-Device group number.
7003 * Returns: 0 - success, -ENODEV - failure.
7008 phba->lpfc_hba_init_link = lpfc_hba_init_link; in lpfc_init_api_table_setup()
7009 phba->lpfc_hba_down_link = lpfc_hba_down_link; in lpfc_init_api_table_setup()
7010 phba->lpfc_selective_reset = lpfc_selective_reset; in lpfc_init_api_table_setup()
7013 phba->lpfc_hba_down_post = lpfc_hba_down_post_s3; in lpfc_init_api_table_setup()
7014 phba->lpfc_handle_eratt = lpfc_handle_eratt_s3; in lpfc_init_api_table_setup()
7015 phba->lpfc_stop_port = lpfc_stop_port_s3; in lpfc_init_api_table_setup()
7018 phba->lpfc_hba_down_post = lpfc_hba_down_post_s4; in lpfc_init_api_table_setup()
7019 phba->lpfc_handle_eratt = lpfc_handle_eratt_s4; in lpfc_init_api_table_setup()
7020 phba->lpfc_stop_port = lpfc_stop_port_s4; in lpfc_init_api_table_setup()
7024 "1431 Invalid HBA PCI-device group: 0x%x\n", in lpfc_init_api_table_setup()
7026 return -ENODEV; in lpfc_init_api_table_setup()
7033 * lpfc_setup_driver_resource_phase2 - Phase2 setup driver internal resources.
7040 * 0 - successful
7041 * other values - error
7049 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_setup_driver_resource_phase2()
7050 "lpfc_worker_%d", phba->brd_no); in lpfc_setup_driver_resource_phase2()
7051 if (IS_ERR(phba->worker_thread)) { in lpfc_setup_driver_resource_phase2()
7052 error = PTR_ERR(phba->worker_thread); in lpfc_setup_driver_resource_phase2()
7060 * lpfc_unset_driver_resource_phase2 - Phase2 unset driver internal resources.
7070 if (phba->wq) { in lpfc_unset_driver_resource_phase2()
7071 flush_workqueue(phba->wq); in lpfc_unset_driver_resource_phase2()
7072 destroy_workqueue(phba->wq); in lpfc_unset_driver_resource_phase2()
7073 phba->wq = NULL; in lpfc_unset_driver_resource_phase2()
7077 if (phba->worker_thread) in lpfc_unset_driver_resource_phase2()
7078 kthread_stop(phba->worker_thread); in lpfc_unset_driver_resource_phase2()
7082 * lpfc_free_iocb_list - Free iocb list.
7092 spin_lock_irq(&phba->hbalock); in lpfc_free_iocb_list()
7094 &phba->lpfc_iocb_list, list) { in lpfc_free_iocb_list()
7095 list_del(&iocbq_entry->list); in lpfc_free_iocb_list()
7097 phba->total_iocbq_bufs--; in lpfc_free_iocb_list()
7099 spin_unlock_irq(&phba->hbalock); in lpfc_free_iocb_list()
7105 * lpfc_init_iocb_list - Allocate and initialize iocb list.
7112 * 0 - successful
7113 * other values - error
7123 INIT_LIST_HEAD(&phba->lpfc_iocb_list); in lpfc_init_iocb_list()
7140 iocbq_entry->sli4_lxritag = NO_XRI; in lpfc_init_iocb_list()
7141 iocbq_entry->sli4_xritag = NO_XRI; in lpfc_init_iocb_list()
7143 spin_lock_irq(&phba->hbalock); in lpfc_init_iocb_list()
7144 list_add(&iocbq_entry->list, &phba->lpfc_iocb_list); in lpfc_init_iocb_list()
7145 phba->total_iocbq_bufs++; in lpfc_init_iocb_list()
7146 spin_unlock_irq(&phba->hbalock); in lpfc_init_iocb_list()
7154 return -ENOMEM; in lpfc_init_iocb_list()
7158 * lpfc_free_sgl_list - Free a given sgl list.
7170 list_del(&sglq_entry->list); in lpfc_free_sgl_list()
7171 lpfc_mbuf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_sgl_list()
7177 * lpfc_free_els_sgl_list - Free els sgl list.
7188 spin_lock_irq(&phba->hbalock); in lpfc_free_els_sgl_list()
7189 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
7190 list_splice_init(&phba->sli4_hba.lpfc_els_sgl_list, &sglq_list); in lpfc_free_els_sgl_list()
7191 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_els_sgl_list()
7192 spin_unlock_irq(&phba->hbalock); in lpfc_free_els_sgl_list()
7199 * lpfc_free_nvmet_sgl_list - Free nvmet sgl list.
7211 spin_lock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
7212 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
7213 list_splice_init(&phba->sli4_hba.lpfc_nvmet_sgl_list, &sglq_list); in lpfc_free_nvmet_sgl_list()
7214 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_free_nvmet_sgl_list()
7215 spin_unlock_irq(&phba->hbalock); in lpfc_free_nvmet_sgl_list()
7219 list_del(&sglq_entry->list); in lpfc_free_nvmet_sgl_list()
7220 lpfc_nvmet_buf_free(phba, sglq_entry->virt, sglq_entry->phys); in lpfc_free_nvmet_sgl_list()
7228 phba->sli4_hba.nvmet_xri_cnt = 0; in lpfc_free_nvmet_sgl_list()
7232 * lpfc_init_active_sgl_array - Allocate the buf to track active ELS XRIs.
7243 size *= phba->sli4_hba.max_cfg_param.max_xri; in lpfc_init_active_sgl_array()
7245 phba->sli4_hba.lpfc_sglq_active_list = in lpfc_init_active_sgl_array()
7247 if (!phba->sli4_hba.lpfc_sglq_active_list) in lpfc_init_active_sgl_array()
7248 return -ENOMEM; in lpfc_init_active_sgl_array()
7253 * lpfc_free_active_sgl - Free the buf that tracks active ELS XRIs.
7263 kfree(phba->sli4_hba.lpfc_sglq_active_list); in lpfc_free_active_sgl()
7267 * lpfc_init_sgl_list - Allocate and initialize sgl list.
7278 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_els_sgl_list); in lpfc_init_sgl_list()
7279 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_init_sgl_list()
7280 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_nvmet_sgl_list); in lpfc_init_sgl_list()
7281 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_init_sgl_list()
7283 /* els xri-sgl book keeping */ in lpfc_init_sgl_list()
7284 phba->sli4_hba.els_xri_cnt = 0; in lpfc_init_sgl_list()
7286 /* nvme xri-buffer book keeping */ in lpfc_init_sgl_list()
7287 phba->sli4_hba.io_xri_cnt = 0; in lpfc_init_sgl_list()
7291 * lpfc_sli4_init_rpi_hdrs - Post the rpi header memory region to the port
7301 * 0 - successful
7302 * -ERROR - otherwise.
7310 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_init_rpi_hdrs()
7311 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_init_rpi_hdrs()
7313 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_init_rpi_hdrs()
7314 return -EIO; in lpfc_sli4_init_rpi_hdrs()
7321 rc = -ENODEV; in lpfc_sli4_init_rpi_hdrs()
7328 * lpfc_sli4_create_rpi_hdr - Allocate an rpi header memory region
7352 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_create_rpi_hdr()
7354 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_create_rpi_hdr()
7358 rpi_limit = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_create_rpi_hdr()
7360 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
7366 curr_rpi_range = phba->sli4_hba.next_rpi; in lpfc_sli4_create_rpi_hdr()
7367 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
7375 * port expects a 4KB DMA-mapped memory region that is 4K aligned. in lpfc_sli4_create_rpi_hdr()
7381 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_create_rpi_hdr()
7383 &dmabuf->phys, GFP_KERNEL); in lpfc_sli4_create_rpi_hdr()
7384 if (!dmabuf->virt) { in lpfc_sli4_create_rpi_hdr()
7389 if (!IS_ALIGNED(dmabuf->phys, LPFC_HDR_TEMPLATE_SIZE)) { in lpfc_sli4_create_rpi_hdr()
7399 rpi_hdr->dmabuf = dmabuf; in lpfc_sli4_create_rpi_hdr()
7400 rpi_hdr->len = LPFC_HDR_TEMPLATE_SIZE; in lpfc_sli4_create_rpi_hdr()
7401 rpi_hdr->page_count = 1; in lpfc_sli4_create_rpi_hdr()
7402 spin_lock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
7405 rpi_hdr->start_rpi = curr_rpi_range; in lpfc_sli4_create_rpi_hdr()
7406 rpi_hdr->next_rpi = phba->sli4_hba.next_rpi + LPFC_RPI_HDR_COUNT; in lpfc_sli4_create_rpi_hdr()
7407 list_add_tail(&rpi_hdr->list, &phba->sli4_hba.lpfc_rpi_hdr_list); in lpfc_sli4_create_rpi_hdr()
7409 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_create_rpi_hdr()
7413 dma_free_coherent(&phba->pcidev->dev, LPFC_HDR_TEMPLATE_SIZE, in lpfc_sli4_create_rpi_hdr()
7414 dmabuf->virt, dmabuf->phys); in lpfc_sli4_create_rpi_hdr()
7421 * lpfc_sli4_remove_rpi_hdrs - Remove all rpi header memory regions
7434 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_remove_rpi_hdrs()
7438 &phba->sli4_hba.lpfc_rpi_hdr_list, list) { in lpfc_sli4_remove_rpi_hdrs()
7439 list_del(&rpi_hdr->list); in lpfc_sli4_remove_rpi_hdrs()
7440 dma_free_coherent(&phba->pcidev->dev, rpi_hdr->len, in lpfc_sli4_remove_rpi_hdrs()
7441 rpi_hdr->dmabuf->virt, rpi_hdr->dmabuf->phys); in lpfc_sli4_remove_rpi_hdrs()
7442 kfree(rpi_hdr->dmabuf); in lpfc_sli4_remove_rpi_hdrs()
7447 phba->sli4_hba.next_rpi = 0; in lpfc_sli4_remove_rpi_hdrs()
7451 * lpfc_hba_alloc - Allocate driver hba data structure for a device.
7459 * pointer to @phba - successful
7460 * NULL - error
7470 dev_err(&pdev->dev, "failed to allocate hba struct\n"); in lpfc_hba_alloc()
7475 phba->pcidev = pdev; in lpfc_hba_alloc()
7478 phba->brd_no = lpfc_get_instance(); in lpfc_hba_alloc()
7479 if (phba->brd_no < 0) { in lpfc_hba_alloc()
7483 phba->eratt_poll_interval = LPFC_ERATT_POLL_INTERVAL; in lpfc_hba_alloc()
7485 spin_lock_init(&phba->ct_ev_lock); in lpfc_hba_alloc()
7486 INIT_LIST_HEAD(&phba->ct_ev_waiters); in lpfc_hba_alloc()
7492 * lpfc_hba_free - Free driver hba data structure with a device.
7501 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_hba_free()
7502 kfree(phba->sli4_hba.hdwq); in lpfc_hba_free()
7505 idr_remove(&lpfc_hba_index, phba->brd_no); in lpfc_hba_free()
7508 kfree(phba->sli.sli3_ring); in lpfc_hba_free()
7509 phba->sli.sli3_ring = NULL; in lpfc_hba_free()
7516 * lpfc_create_shost - Create hba physical port with associated scsi host.
7523 * 0 - successful
7524 * other values - error
7533 phba->fc_edtov = FF_DEF_EDTOV; in lpfc_create_shost()
7534 phba->fc_ratov = FF_DEF_RATOV; in lpfc_create_shost()
7535 phba->fc_altov = FF_DEF_ALTOV; in lpfc_create_shost()
7536 phba->fc_arbtov = FF_DEF_ARBTOV; in lpfc_create_shost()
7538 atomic_set(&phba->sdev_cnt, 0); in lpfc_create_shost()
7539 vport = lpfc_create_port(phba, phba->brd_no, &phba->pcidev->dev); in lpfc_create_shost()
7541 return -ENODEV; in lpfc_create_shost()
7544 phba->pport = vport; in lpfc_create_shost()
7546 if (phba->nvmet_support) { in lpfc_create_shost()
7548 if (phba->txrdy_payload_pool == NULL) { in lpfc_create_shost()
7549 phba->txrdy_payload_pool = dma_pool_create( in lpfc_create_shost()
7550 "txrdy_pool", &phba->pcidev->dev, in lpfc_create_shost()
7552 if (phba->txrdy_payload_pool) { in lpfc_create_shost()
7553 phba->targetport = NULL; in lpfc_create_shost()
7554 phba->cfg_enable_fc4_type = LPFC_ENABLE_NVME; in lpfc_create_shost()
7564 pci_set_drvdata(phba->pcidev, shost); in lpfc_create_shost()
7570 vport->load_flag |= FC_ALLOW_FDMI; in lpfc_create_shost()
7571 if (phba->cfg_enable_SmartSAN || in lpfc_create_shost()
7572 (phba->cfg_fdmi_on == LPFC_FDMI_SUPPORT)) { in lpfc_create_shost()
7575 vport->fdmi_hba_mask = LPFC_FDMI2_HBA_ATTR; in lpfc_create_shost()
7576 if (phba->cfg_enable_SmartSAN) in lpfc_create_shost()
7577 vport->fdmi_port_mask = LPFC_FDMI2_SMART_ATTR; in lpfc_create_shost()
7579 vport->fdmi_port_mask = LPFC_FDMI2_PORT_ATTR; in lpfc_create_shost()
7585 * lpfc_destroy_shost - Destroy hba physical port with associated scsi host.
7594 struct lpfc_vport *vport = phba->pport; in lpfc_destroy_shost()
7603 * lpfc_setup_bg - Setup Block guard structures and debug areas.
7616 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
7621 old_mask = phba->cfg_prot_mask; in lpfc_setup_bg()
7622 old_guard = phba->cfg_prot_guard; in lpfc_setup_bg()
7625 phba->cfg_prot_mask &= (SHOST_DIF_TYPE1_PROTECTION | in lpfc_setup_bg()
7628 phba->cfg_prot_guard &= (SHOST_DIX_GUARD_IP | in lpfc_setup_bg()
7632 if (phba->cfg_prot_mask == SHOST_DIX_TYPE1_PROTECTION) in lpfc_setup_bg()
7633 phba->cfg_prot_mask |= SHOST_DIF_TYPE1_PROTECTION; in lpfc_setup_bg()
7635 if (phba->cfg_prot_mask && phba->cfg_prot_guard) { in lpfc_setup_bg()
7636 if ((old_mask != phba->cfg_prot_mask) || in lpfc_setup_bg()
7637 (old_guard != phba->cfg_prot_guard)) in lpfc_setup_bg()
7641 phba->cfg_prot_mask, in lpfc_setup_bg()
7642 phba->cfg_prot_guard); in lpfc_setup_bg()
7644 scsi_host_set_prot(shost, phba->cfg_prot_mask); in lpfc_setup_bg()
7645 scsi_host_set_guard(shost, phba->cfg_prot_guard); in lpfc_setup_bg()
7655 * lpfc_post_init_setup - Perform necessary device post initialization setup.
7668 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_post_init_setup()
7674 shost = pci_get_drvdata(phba->pcidev); in lpfc_post_init_setup()
7675 shost->can_queue = phba->cfg_hba_queue_depth - 10; in lpfc_post_init_setup()
7679 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_post_init_setup()
7680 spin_lock_irq(shost->host_lock); in lpfc_post_init_setup()
7682 spin_unlock_irq(shost->host_lock); in lpfc_post_init_setup()
7698 * lpfc_sli_pci_mem_setup - Setup SLI3 HBA PCI memory space.
7702 * with SLI-3 interface spec.
7705 * 0 - successful
7706 * other values - error
7711 struct pci_dev *pdev = phba->pcidev; in lpfc_sli_pci_mem_setup()
7718 return -ENODEV; in lpfc_sli_pci_mem_setup()
7721 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli_pci_mem_setup()
7723 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli_pci_mem_setup()
7726 error = -ENODEV; in lpfc_sli_pci_mem_setup()
7731 phba->pci_bar0_map = pci_resource_start(pdev, 0); in lpfc_sli_pci_mem_setup()
7734 phba->pci_bar2_map = pci_resource_start(pdev, 2); in lpfc_sli_pci_mem_setup()
7738 phba->slim_memmap_p = ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli_pci_mem_setup()
7739 if (!phba->slim_memmap_p) { in lpfc_sli_pci_mem_setup()
7740 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
7746 phba->ctrl_regs_memmap_p = ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli_pci_mem_setup()
7747 if (!phba->ctrl_regs_memmap_p) { in lpfc_sli_pci_mem_setup()
7748 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli_pci_mem_setup()
7753 /* Allocate memory for SLI-2 structures */ in lpfc_sli_pci_mem_setup()
7754 phba->slim2p.virt = dma_alloc_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
7755 &phba->slim2p.phys, GFP_KERNEL); in lpfc_sli_pci_mem_setup()
7756 if (!phba->slim2p.virt) in lpfc_sli_pci_mem_setup()
7759 phba->mbox = phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, mbx); in lpfc_sli_pci_mem_setup()
7760 phba->mbox_ext = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
7762 phba->pcb = (phba->slim2p.virt + offsetof(struct lpfc_sli2_slim, pcb)); in lpfc_sli_pci_mem_setup()
7763 phba->IOCBs = (phba->slim2p.virt + in lpfc_sli_pci_mem_setup()
7766 phba->hbqslimp.virt = dma_alloc_coherent(&pdev->dev, in lpfc_sli_pci_mem_setup()
7768 &phba->hbqslimp.phys, in lpfc_sli_pci_mem_setup()
7770 if (!phba->hbqslimp.virt) in lpfc_sli_pci_mem_setup()
7774 ptr = phba->hbqslimp.virt; in lpfc_sli_pci_mem_setup()
7776 phba->hbqs[i].hbq_virt = ptr; in lpfc_sli_pci_mem_setup()
7777 INIT_LIST_HEAD(&phba->hbqs[i].hbq_buffer_list); in lpfc_sli_pci_mem_setup()
7778 ptr += (lpfc_hbq_defs[i]->entry_count * in lpfc_sli_pci_mem_setup()
7781 phba->hbqs[LPFC_ELS_HBQ].hbq_alloc_buffer = lpfc_els_hbq_alloc; in lpfc_sli_pci_mem_setup()
7782 phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer = lpfc_els_hbq_free; in lpfc_sli_pci_mem_setup()
7784 memset(phba->hbqslimp.virt, 0, lpfc_sli_hbq_size()); in lpfc_sli_pci_mem_setup()
7786 phba->MBslimaddr = phba->slim_memmap_p; in lpfc_sli_pci_mem_setup()
7787 phba->HAregaddr = phba->ctrl_regs_memmap_p + HA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
7788 phba->CAregaddr = phba->ctrl_regs_memmap_p + CA_REG_OFFSET; in lpfc_sli_pci_mem_setup()
7789 phba->HSregaddr = phba->ctrl_regs_memmap_p + HS_REG_OFFSET; in lpfc_sli_pci_mem_setup()
7790 phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; in lpfc_sli_pci_mem_setup()
7795 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_setup()
7796 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_setup()
7798 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_setup()
7800 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_setup()
7806 * lpfc_sli_pci_mem_unset - Unset SLI3 HBA PCI memory space.
7810 * with SLI-3 interface spec.
7818 if (!phba->pcidev) in lpfc_sli_pci_mem_unset()
7821 pdev = phba->pcidev; in lpfc_sli_pci_mem_unset()
7824 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_sli_pci_mem_unset()
7825 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_sli_pci_mem_unset()
7826 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_sli_pci_mem_unset()
7827 phba->slim2p.virt, phba->slim2p.phys); in lpfc_sli_pci_mem_unset()
7830 iounmap(phba->ctrl_regs_memmap_p); in lpfc_sli_pci_mem_unset()
7831 iounmap(phba->slim_memmap_p); in lpfc_sli_pci_mem_unset()
7837 * lpfc_sli4_post_status_check - Wait for SLI4 POST done and check status
7843 * Return 0 if successful, otherwise -ENODEV.
7855 if (!phba->sli4_hba.PSMPHRregaddr) in lpfc_sli4_post_status_check()
7856 return -ENODEV; in lpfc_sli4_post_status_check()
7860 if (lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_sli4_post_status_check()
7864 port_error = -ENODEV; in lpfc_sli4_post_status_check()
7879 "1408 Port Failed POST - portsmphr=0x%x, " in lpfc_sli4_post_status_check()
7897 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
7899 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
7901 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
7903 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
7905 &phba->sli4_hba.sli_intf), in lpfc_sli4_post_status_check()
7907 &phba->sli4_hba.sli_intf)); in lpfc_sli4_post_status_check()
7914 &phba->sli4_hba.sli_intf); in lpfc_sli4_post_status_check()
7917 phba->sli4_hba.ue_mask_lo = in lpfc_sli4_post_status_check()
7918 readl(phba->sli4_hba.u.if_type0.UEMASKLOregaddr); in lpfc_sli4_post_status_check()
7919 phba->sli4_hba.ue_mask_hi = in lpfc_sli4_post_status_check()
7920 readl(phba->sli4_hba.u.if_type0.UEMASKHIregaddr); in lpfc_sli4_post_status_check()
7922 readl(phba->sli4_hba.u.if_type0.UERRLOregaddr); in lpfc_sli4_post_status_check()
7924 readl(phba->sli4_hba.u.if_type0.UERRHIregaddr); in lpfc_sli4_post_status_check()
7925 if ((~phba->sli4_hba.ue_mask_lo & uerrlo_reg.word0) || in lpfc_sli4_post_status_check()
7926 (~phba->sli4_hba.ue_mask_hi & uerrhi_reg.word0)) { in lpfc_sli4_post_status_check()
7936 phba->sli4_hba.ue_mask_lo, in lpfc_sli4_post_status_check()
7937 phba->sli4_hba.ue_mask_hi); in lpfc_sli4_post_status_check()
7938 port_error = -ENODEV; in lpfc_sli4_post_status_check()
7944 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_post_status_check()
7948 phba->work_status[0] = in lpfc_sli4_post_status_check()
7949 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
7951 phba->work_status[1] = in lpfc_sli4_post_status_check()
7952 readl(phba->sli4_hba.u.if_type2. in lpfc_sli4_post_status_check()
7961 phba->work_status[0], in lpfc_sli4_post_status_check()
7962 phba->work_status[1]); in lpfc_sli4_post_status_check()
7963 port_error = -ENODEV; in lpfc_sli4_post_status_check()
7975 * lpfc_sli4_bar0_register_memmap - Set up SLI4 BAR0 register memory map.
7987 phba->sli4_hba.u.if_type0.UERRLOregaddr = in lpfc_sli4_bar0_register_memmap()
7988 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_LO; in lpfc_sli4_bar0_register_memmap()
7989 phba->sli4_hba.u.if_type0.UERRHIregaddr = in lpfc_sli4_bar0_register_memmap()
7990 phba->sli4_hba.conf_regs_memmap_p + LPFC_UERR_STATUS_HI; in lpfc_sli4_bar0_register_memmap()
7991 phba->sli4_hba.u.if_type0.UEMASKLOregaddr = in lpfc_sli4_bar0_register_memmap()
7992 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_LO; in lpfc_sli4_bar0_register_memmap()
7993 phba->sli4_hba.u.if_type0.UEMASKHIregaddr = in lpfc_sli4_bar0_register_memmap()
7994 phba->sli4_hba.conf_regs_memmap_p + LPFC_UE_MASK_HI; in lpfc_sli4_bar0_register_memmap()
7995 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
7996 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
7999 phba->sli4_hba.u.if_type2.EQDregaddr = in lpfc_sli4_bar0_register_memmap()
8000 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8002 phba->sli4_hba.u.if_type2.ERR1regaddr = in lpfc_sli4_bar0_register_memmap()
8003 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8005 phba->sli4_hba.u.if_type2.ERR2regaddr = in lpfc_sli4_bar0_register_memmap()
8006 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8008 phba->sli4_hba.u.if_type2.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
8009 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8011 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
8012 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8014 phba->sli4_hba.SLIINTFregaddr = in lpfc_sli4_bar0_register_memmap()
8015 phba->sli4_hba.conf_regs_memmap_p + LPFC_SLI_INTF; in lpfc_sli4_bar0_register_memmap()
8016 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
8017 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8019 phba->sli4_hba.RQDBregaddr = in lpfc_sli4_bar0_register_memmap()
8020 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8022 phba->sli4_hba.WQDBregaddr = in lpfc_sli4_bar0_register_memmap()
8023 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8025 phba->sli4_hba.CQDBregaddr = in lpfc_sli4_bar0_register_memmap()
8026 phba->sli4_hba.conf_regs_memmap_p + LPFC_EQCQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
8027 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar0_register_memmap()
8028 phba->sli4_hba.MQDBregaddr = in lpfc_sli4_bar0_register_memmap()
8029 phba->sli4_hba.conf_regs_memmap_p + LPFC_MQ_DOORBELL; in lpfc_sli4_bar0_register_memmap()
8030 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
8031 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
8034 phba->sli4_hba.u.if_type2.EQDregaddr = in lpfc_sli4_bar0_register_memmap()
8035 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8037 phba->sli4_hba.u.if_type2.ERR1regaddr = in lpfc_sli4_bar0_register_memmap()
8038 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8040 phba->sli4_hba.u.if_type2.ERR2regaddr = in lpfc_sli4_bar0_register_memmap()
8041 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8043 phba->sli4_hba.u.if_type2.CTRLregaddr = in lpfc_sli4_bar0_register_memmap()
8044 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8046 phba->sli4_hba.u.if_type2.STATUSregaddr = in lpfc_sli4_bar0_register_memmap()
8047 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8049 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar0_register_memmap()
8050 phba->sli4_hba.conf_regs_memmap_p + in lpfc_sli4_bar0_register_memmap()
8052 phba->sli4_hba.BMBXregaddr = in lpfc_sli4_bar0_register_memmap()
8053 phba->sli4_hba.conf_regs_memmap_p + LPFC_BMBX; in lpfc_sli4_bar0_register_memmap()
8057 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_bar0_register_memmap()
8058 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar0_register_memmap()
8065 * lpfc_sli4_bar1_register_memmap - Set up SLI4 BAR1 register memory map.
8075 phba->sli4_hba.PSMPHRregaddr = in lpfc_sli4_bar1_register_memmap()
8076 phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8078 phba->sli4_hba.ISRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8080 phba->sli4_hba.IMRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8082 phba->sli4_hba.ISCRregaddr = phba->sli4_hba.ctrl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8086 phba->sli4_hba.RQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8088 phba->sli4_hba.WQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8090 phba->sli4_hba.CQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8092 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8094 phba->sli4_hba.MQDBregaddr = phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar1_register_memmap()
8100 dev_err(&phba->pcidev->dev, in lpfc_sli4_bar1_register_memmap()
8101 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_bar1_register_memmap()
8108 * lpfc_sli4_bar2_register_memmap - Set up SLI4 BAR2 register memory map.
8115 * Return 0 if successful, otherwise -ENODEV.
8121 return -ENODEV; in lpfc_sli4_bar2_register_memmap()
8123 phba->sli4_hba.RQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8126 phba->sli4_hba.WQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8129 phba->sli4_hba.CQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8132 phba->sli4_hba.EQDBregaddr = phba->sli4_hba.CQDBregaddr; in lpfc_sli4_bar2_register_memmap()
8133 phba->sli4_hba.MQDBregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8135 phba->sli4_hba.BMBXregaddr = (phba->sli4_hba.drbl_regs_memmap_p + in lpfc_sli4_bar2_register_memmap()
8141 * lpfc_create_bootstrap_mbox - Create the bootstrap mailbox
8145 * region consistent with the SLI-4 interface spec. This
8152 * 0 - successful
8153 * -ENOMEM - could not allocated memory.
8166 return -ENOMEM; in lpfc_create_bootstrap_mbox()
8172 bmbx_size = sizeof(struct lpfc_bmbx_create) + (LPFC_ALIGN_16_BYTE - 1); in lpfc_create_bootstrap_mbox()
8173 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, bmbx_size, in lpfc_create_bootstrap_mbox()
8174 &dmabuf->phys, GFP_KERNEL); in lpfc_create_bootstrap_mbox()
8175 if (!dmabuf->virt) { in lpfc_create_bootstrap_mbox()
8177 return -ENOMEM; in lpfc_create_bootstrap_mbox()
8183 * to be 16-byte aligned. Also align the virtual memory as each in lpfc_create_bootstrap_mbox()
8187 phba->sli4_hba.bmbx.dmabuf = dmabuf; in lpfc_create_bootstrap_mbox()
8188 phba->sli4_hba.bmbx.bmbx_size = bmbx_size; in lpfc_create_bootstrap_mbox()
8190 phba->sli4_hba.bmbx.avirt = PTR_ALIGN(dmabuf->virt, in lpfc_create_bootstrap_mbox()
8192 phba->sli4_hba.bmbx.aphys = ALIGN(dmabuf->phys, in lpfc_create_bootstrap_mbox()
8198 * as two 30-bit addresses. The other data is a bit marking whether in lpfc_create_bootstrap_mbox()
8199 * the 30-bit address is the high or low address. in lpfc_create_bootstrap_mbox()
8203 dma_address = &phba->sli4_hba.bmbx.dma_address; in lpfc_create_bootstrap_mbox()
8204 phys_addr = (uint64_t)phba->sli4_hba.bmbx.aphys; in lpfc_create_bootstrap_mbox()
8206 dma_address->addr_hi = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
8209 pa_addr = (uint32_t) ((phba->sli4_hba.bmbx.aphys >> 4) & 0x3fffffff); in lpfc_create_bootstrap_mbox()
8210 dma_address->addr_lo = (uint32_t) ((pa_addr << 2) | in lpfc_create_bootstrap_mbox()
8216 * lpfc_destroy_bootstrap_mbox - Destroy all bootstrap mailbox resources
8229 dma_free_coherent(&phba->pcidev->dev, in lpfc_destroy_bootstrap_mbox()
8230 phba->sli4_hba.bmbx.bmbx_size, in lpfc_destroy_bootstrap_mbox()
8231 phba->sli4_hba.bmbx.dmabuf->virt, in lpfc_destroy_bootstrap_mbox()
8232 phba->sli4_hba.bmbx.dmabuf->phys); in lpfc_destroy_bootstrap_mbox()
8234 kfree(phba->sli4_hba.bmbx.dmabuf); in lpfc_destroy_bootstrap_mbox()
8235 memset(&phba->sli4_hba.bmbx, 0, sizeof(struct lpfc_bmbx)); in lpfc_destroy_bootstrap_mbox()
8239 * lpfc_sli4_read_config - Get the config parameters.
8248 * 0 - successful
8249 * -ENOMEM - No available memory
8250 * -EIO - The mailbox failed to complete successfully.
8266 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_read_config()
8271 return -ENOMEM; in lpfc_sli4_read_config()
8281 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
8282 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
8283 rc = -EIO; in lpfc_sli4_read_config()
8285 rd_config = &pmb->u.mqe.un.rd_config; in lpfc_sli4_read_config()
8287 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_VAL; in lpfc_sli4_read_config()
8288 phba->sli4_hba.lnk_info.lnk_tp = in lpfc_sli4_read_config()
8290 phba->sli4_hba.lnk_info.lnk_no = in lpfc_sli4_read_config()
8294 phba->sli4_hba.lnk_info.lnk_tp, in lpfc_sli4_read_config()
8295 phba->sli4_hba.lnk_info.lnk_no); in lpfc_sli4_read_config()
8299 bf_get(lpfc_mqe_command, &pmb->u.mqe)); in lpfc_sli4_read_config()
8301 phba->bbcredit_support = 1; in lpfc_sli4_read_config()
8302 phba->sli4_hba.bbscn_params.word0 = rd_config->word8; in lpfc_sli4_read_config()
8305 phba->sli4_hba.conf_trunk = in lpfc_sli4_read_config()
8307 phba->sli4_hba.extents_in_use = in lpfc_sli4_read_config()
8309 phba->sli4_hba.max_cfg_param.max_xri = in lpfc_sli4_read_config()
8313 phba->sli4_hba.max_cfg_param.max_xri > 512) in lpfc_sli4_read_config()
8314 phba->sli4_hba.max_cfg_param.max_xri = 512; in lpfc_sli4_read_config()
8315 phba->sli4_hba.max_cfg_param.xri_base = in lpfc_sli4_read_config()
8317 phba->sli4_hba.max_cfg_param.max_vpi = in lpfc_sli4_read_config()
8320 if (phba->sli4_hba.max_cfg_param.max_vpi > LPFC_MAX_VPORTS) in lpfc_sli4_read_config()
8321 phba->sli4_hba.max_cfg_param.max_vpi = LPFC_MAX_VPORTS; in lpfc_sli4_read_config()
8322 phba->sli4_hba.max_cfg_param.vpi_base = in lpfc_sli4_read_config()
8324 phba->sli4_hba.max_cfg_param.max_rpi = in lpfc_sli4_read_config()
8326 phba->sli4_hba.max_cfg_param.rpi_base = in lpfc_sli4_read_config()
8328 phba->sli4_hba.max_cfg_param.max_vfi = in lpfc_sli4_read_config()
8330 phba->sli4_hba.max_cfg_param.vfi_base = in lpfc_sli4_read_config()
8332 phba->sli4_hba.max_cfg_param.max_fcfi = in lpfc_sli4_read_config()
8334 phba->sli4_hba.max_cfg_param.max_eq = in lpfc_sli4_read_config()
8336 phba->sli4_hba.max_cfg_param.max_rq = in lpfc_sli4_read_config()
8338 phba->sli4_hba.max_cfg_param.max_wq = in lpfc_sli4_read_config()
8340 phba->sli4_hba.max_cfg_param.max_cq = in lpfc_sli4_read_config()
8342 phba->lmt = bf_get(lpfc_mbx_rd_conf_lmt, rd_config); in lpfc_sli4_read_config()
8343 phba->sli4_hba.next_xri = phba->sli4_hba.max_cfg_param.xri_base; in lpfc_sli4_read_config()
8344 phba->vpi_base = phba->sli4_hba.max_cfg_param.vpi_base; in lpfc_sli4_read_config()
8345 phba->vfi_base = phba->sli4_hba.max_cfg_param.vfi_base; in lpfc_sli4_read_config()
8346 phba->max_vpi = (phba->sli4_hba.max_cfg_param.max_vpi > 0) ? in lpfc_sli4_read_config()
8347 (phba->sli4_hba.max_cfg_param.max_vpi - 1) : 0; in lpfc_sli4_read_config()
8348 phba->max_vports = phba->max_vpi; in lpfc_sli4_read_config()
8356 phba->sli4_hba.extents_in_use, in lpfc_sli4_read_config()
8357 phba->sli4_hba.max_cfg_param.xri_base, in lpfc_sli4_read_config()
8358 phba->sli4_hba.max_cfg_param.max_xri, in lpfc_sli4_read_config()
8359 phba->sli4_hba.max_cfg_param.vpi_base, in lpfc_sli4_read_config()
8360 phba->sli4_hba.max_cfg_param.max_vpi, in lpfc_sli4_read_config()
8361 phba->sli4_hba.max_cfg_param.vfi_base, in lpfc_sli4_read_config()
8362 phba->sli4_hba.max_cfg_param.max_vfi, in lpfc_sli4_read_config()
8363 phba->sli4_hba.max_cfg_param.rpi_base, in lpfc_sli4_read_config()
8364 phba->sli4_hba.max_cfg_param.max_rpi, in lpfc_sli4_read_config()
8365 phba->sli4_hba.max_cfg_param.max_fcfi, in lpfc_sli4_read_config()
8366 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
8367 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
8368 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
8369 phba->sli4_hba.max_cfg_param.max_rq); in lpfc_sli4_read_config()
8375 qmin = phba->sli4_hba.max_cfg_param.max_wq; in lpfc_sli4_read_config()
8376 if (phba->sli4_hba.max_cfg_param.max_cq < qmin) in lpfc_sli4_read_config()
8377 qmin = phba->sli4_hba.max_cfg_param.max_cq; in lpfc_sli4_read_config()
8378 if (phba->sli4_hba.max_cfg_param.max_eq < qmin) in lpfc_sli4_read_config()
8379 qmin = phba->sli4_hba.max_cfg_param.max_eq; in lpfc_sli4_read_config()
8386 qmin -= 4; in lpfc_sli4_read_config()
8389 if ((phba->cfg_irq_chann > qmin) || in lpfc_sli4_read_config()
8390 (phba->cfg_hdw_queue > qmin)) { in lpfc_sli4_read_config()
8395 phba->sli4_hba.max_cfg_param.max_wq, in lpfc_sli4_read_config()
8396 phba->sli4_hba.max_cfg_param.max_cq, in lpfc_sli4_read_config()
8397 phba->sli4_hba.max_cfg_param.max_eq, in lpfc_sli4_read_config()
8398 qmin, phba->cfg_irq_chann, in lpfc_sli4_read_config()
8399 phba->cfg_hdw_queue); in lpfc_sli4_read_config()
8401 if (phba->cfg_irq_chann > qmin) in lpfc_sli4_read_config()
8402 phba->cfg_irq_chann = qmin; in lpfc_sli4_read_config()
8403 if (phba->cfg_hdw_queue > qmin) in lpfc_sli4_read_config()
8404 phba->cfg_hdw_queue = qmin; in lpfc_sli4_read_config()
8412 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_read_config()
8417 phba->hba_flag |= HBA_FORCED_LINK_SPEED; in lpfc_sli4_read_config()
8421 phba->cfg_link_speed = in lpfc_sli4_read_config()
8425 phba->cfg_link_speed = in lpfc_sli4_read_config()
8429 phba->cfg_link_speed = in lpfc_sli4_read_config()
8433 phba->cfg_link_speed = in lpfc_sli4_read_config()
8437 phba->cfg_link_speed = in lpfc_sli4_read_config()
8441 phba->cfg_link_speed = in lpfc_sli4_read_config()
8445 phba->cfg_link_speed = in lpfc_sli4_read_config()
8449 phba->cfg_link_speed = in lpfc_sli4_read_config()
8453 phba->cfg_link_speed = in lpfc_sli4_read_config()
8461 phba->cfg_link_speed = in lpfc_sli4_read_config()
8468 length = phba->sli4_hba.max_cfg_param.max_xri - in lpfc_sli4_read_config()
8470 if (phba->cfg_hba_queue_depth > length) { in lpfc_sli4_read_config()
8473 phba->cfg_hba_queue_depth, length); in lpfc_sli4_read_config()
8474 phba->cfg_hba_queue_depth = length; in lpfc_sli4_read_config()
8477 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_read_config()
8482 length = (sizeof(struct lpfc_mbx_get_func_cfg) - in lpfc_sli4_read_config()
8490 &pmb->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_read_config()
8491 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_read_config()
8492 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_read_config()
8497 bf_get(lpfc_mqe_command, &pmb->u.mqe), in lpfc_sli4_read_config()
8498 bf_get(lpfc_mqe_status, &pmb->u.mqe)); in lpfc_sli4_read_config()
8503 get_func_cfg = &pmb->u.mqe.un.get_func_cfg; in lpfc_sli4_read_config()
8505 pdesc_0 = (char *)&get_func_cfg->func_cfg.desc[0]; in lpfc_sli4_read_config()
8517 phba->sli4_hba.iov.pf_number = in lpfc_sli4_read_config()
8519 phba->sli4_hba.iov.vf_number = in lpfc_sli4_read_config()
8528 "vf_number:%d\n", phba->sli4_hba.iov.pf_number, in lpfc_sli4_read_config()
8529 phba->sli4_hba.iov.vf_number); in lpfc_sli4_read_config()
8537 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_read_config()
8542 * lpfc_setup_endian_order - Write endian order to an SLI4 if_type 0 port.
8545 * This routine is invoked to setup the port-side endian order when
8550 * 0 - successful
8551 * -ENOMEM - No available memory
8552 * -EIO - The mailbox failed to complete successfully.
8562 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_setup_endian_order()
8565 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_setup_endian_order()
8572 return -ENOMEM; in lpfc_setup_endian_order()
8580 memcpy(&mboxq->u.mqe, &endian_mb_data, sizeof(endian_mb_data)); in lpfc_setup_endian_order()
8587 rc = -EIO; in lpfc_setup_endian_order()
8589 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_setup_endian_order()
8601 * lpfc_sli4_queue_verify - Verify and update EQ counts
8610 * 0 - successful
8611 * -ENOMEM - No available memory
8617 * Sanity check for configured queue parameters against the run-time in lpfc_sli4_queue_verify()
8621 if (phba->nvmet_support) { in lpfc_sli4_queue_verify()
8622 if (phba->cfg_irq_chann < phba->cfg_nvmet_mrq) in lpfc_sli4_queue_verify()
8623 phba->cfg_nvmet_mrq = phba->cfg_irq_chann; in lpfc_sli4_queue_verify()
8624 if (phba->cfg_nvmet_mrq > LPFC_NVMET_MRQ_MAX) in lpfc_sli4_queue_verify()
8625 phba->cfg_nvmet_mrq = LPFC_NVMET_MRQ_MAX; in lpfc_sli4_queue_verify()
8630 phba->cfg_hdw_queue, phba->cfg_irq_chann, in lpfc_sli4_queue_verify()
8631 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_verify()
8634 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_verify()
8635 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_verify()
8638 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_verify()
8639 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_verify()
8648 int cpu; in lpfc_alloc_io_wq_cq() local
8650 cpu = lpfc_find_cpu_handle(phba, idx, LPFC_FIND_BY_HDWQ); in lpfc_alloc_io_wq_cq()
8652 if (phba->enab_exp_wqcq_pages) in lpfc_alloc_io_wq_cq()
8655 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
8656 LPFC_CQE_EXP_COUNT, cpu); in lpfc_alloc_io_wq_cq()
8660 phba->sli4_hba.cq_esize, in lpfc_alloc_io_wq_cq()
8661 phba->sli4_hba.cq_ecount, cpu); in lpfc_alloc_io_wq_cq()
8664 "0499 Failed allocate fast-path IO CQ (%d)\n", idx); in lpfc_alloc_io_wq_cq()
8667 qdesc->qe_valid = 1; in lpfc_alloc_io_wq_cq()
8668 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
8669 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
8670 phba->sli4_hba.hdwq[idx].io_cq = qdesc; in lpfc_alloc_io_wq_cq()
8673 if (phba->enab_exp_wqcq_pages) { in lpfc_alloc_io_wq_cq()
8675 wqesize = (phba->fcp_embed_io) ? in lpfc_alloc_io_wq_cq()
8676 LPFC_WQE128_SIZE : phba->sli4_hba.wq_esize; in lpfc_alloc_io_wq_cq()
8679 LPFC_WQE_EXP_COUNT, cpu); in lpfc_alloc_io_wq_cq()
8682 phba->sli4_hba.wq_esize, in lpfc_alloc_io_wq_cq()
8683 phba->sli4_hba.wq_ecount, cpu); in lpfc_alloc_io_wq_cq()
8687 "0503 Failed allocate fast-path IO WQ (%d)\n", in lpfc_alloc_io_wq_cq()
8691 qdesc->hdwq = idx; in lpfc_alloc_io_wq_cq()
8692 qdesc->chann = cpu; in lpfc_alloc_io_wq_cq()
8693 phba->sli4_hba.hdwq[idx].io_wq = qdesc; in lpfc_alloc_io_wq_cq()
8694 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_alloc_io_wq_cq()
8699 * lpfc_sli4_queue_create - Create all the SLI4 queues
8708 * 0 - successful
8709 * -ENOMEM - No availble memory
8710 * -EIO - The mailbox failed to complete successfully.
8716 int idx, cpu, eqcpu; in lpfc_sli4_queue_create() local
8726 phba->sli4_hba.mq_esize = LPFC_MQE_SIZE; in lpfc_sli4_queue_create()
8727 phba->sli4_hba.mq_ecount = LPFC_MQE_DEF_COUNT; in lpfc_sli4_queue_create()
8728 phba->sli4_hba.wq_esize = LPFC_WQE_SIZE; in lpfc_sli4_queue_create()
8729 phba->sli4_hba.wq_ecount = LPFC_WQE_DEF_COUNT; in lpfc_sli4_queue_create()
8730 phba->sli4_hba.rq_esize = LPFC_RQE_SIZE; in lpfc_sli4_queue_create()
8731 phba->sli4_hba.rq_ecount = LPFC_RQE_DEF_COUNT; in lpfc_sli4_queue_create()
8732 phba->sli4_hba.eq_esize = LPFC_EQE_SIZE_4B; in lpfc_sli4_queue_create()
8733 phba->sli4_hba.eq_ecount = LPFC_EQE_DEF_COUNT; in lpfc_sli4_queue_create()
8734 phba->sli4_hba.cq_esize = LPFC_CQE_SIZE; in lpfc_sli4_queue_create()
8735 phba->sli4_hba.cq_ecount = LPFC_CQE_DEF_COUNT; in lpfc_sli4_queue_create()
8737 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
8738 phba->sli4_hba.hdwq = kcalloc( in lpfc_sli4_queue_create()
8739 phba->cfg_hdw_queue, sizeof(struct lpfc_sli4_hdw_queue), in lpfc_sli4_queue_create()
8741 if (!phba->sli4_hba.hdwq) { in lpfc_sli4_queue_create()
8744 "fast-path Hardware Queue array\n"); in lpfc_sli4_queue_create()
8748 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
8749 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_queue_create()
8750 spin_lock_init(&qp->io_buf_list_get_lock); in lpfc_sli4_queue_create()
8751 spin_lock_init(&qp->io_buf_list_put_lock); in lpfc_sli4_queue_create()
8752 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_get); in lpfc_sli4_queue_create()
8753 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_sli4_queue_create()
8754 qp->get_io_bufs = 0; in lpfc_sli4_queue_create()
8755 qp->put_io_bufs = 0; in lpfc_sli4_queue_create()
8756 qp->total_io_bufs = 0; in lpfc_sli4_queue_create()
8757 spin_lock_init(&qp->abts_io_buf_list_lock); in lpfc_sli4_queue_create()
8758 INIT_LIST_HEAD(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_queue_create()
8759 qp->abts_scsi_io_bufs = 0; in lpfc_sli4_queue_create()
8760 qp->abts_nvme_io_bufs = 0; in lpfc_sli4_queue_create()
8761 INIT_LIST_HEAD(&qp->sgl_list); in lpfc_sli4_queue_create()
8762 INIT_LIST_HEAD(&qp->cmd_rsp_buf_list); in lpfc_sli4_queue_create()
8763 spin_lock_init(&qp->hdwq_lock); in lpfc_sli4_queue_create()
8767 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
8768 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
8769 phba->sli4_hba.nvmet_cqset = kcalloc( in lpfc_sli4_queue_create()
8770 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
8773 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_create()
8776 "fast-path CQ set array\n"); in lpfc_sli4_queue_create()
8779 phba->sli4_hba.nvmet_mrq_hdr = kcalloc( in lpfc_sli4_queue_create()
8780 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
8783 if (!phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_create()
8786 "fast-path RQ set hdr array\n"); in lpfc_sli4_queue_create()
8789 phba->sli4_hba.nvmet_mrq_data = kcalloc( in lpfc_sli4_queue_create()
8790 phba->cfg_nvmet_mrq, in lpfc_sli4_queue_create()
8793 if (!phba->sli4_hba.nvmet_mrq_data) { in lpfc_sli4_queue_create()
8796 "fast-path RQ set data array\n"); in lpfc_sli4_queue_create()
8802 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
8805 for_each_present_cpu(cpu) { in lpfc_sli4_queue_create()
8810 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
8811 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_create()
8814 /* Get a ptr to the Hardware Queue associated with this CPU */ in lpfc_sli4_queue_create()
8815 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
8819 phba->sli4_hba.eq_esize, in lpfc_sli4_queue_create()
8820 phba->sli4_hba.eq_ecount, cpu); in lpfc_sli4_queue_create()
8824 cpup->hdwq); in lpfc_sli4_queue_create()
8827 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
8828 qdesc->hdwq = cpup->hdwq; in lpfc_sli4_queue_create()
8829 qdesc->chann = cpu; /* First CPU this EQ is affinitized to */ in lpfc_sli4_queue_create()
8830 qdesc->last_cpu = qdesc->chann; in lpfc_sli4_queue_create()
8833 qp->hba_eq = qdesc; in lpfc_sli4_queue_create()
8835 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, qdesc->last_cpu); in lpfc_sli4_queue_create()
8836 list_add(&qdesc->cpu_list, &eqi->list); in lpfc_sli4_queue_create()
8842 for_each_present_cpu(cpu) { in lpfc_sli4_queue_create()
8843 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_create()
8846 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_sli4_queue_create()
8850 qp = &phba->sli4_hba.hdwq[cpup->hdwq]; in lpfc_sli4_queue_create()
8851 if (qp->hba_eq) in lpfc_sli4_queue_create()
8855 eqcpu = lpfc_find_cpu_handle(phba, cpup->eq, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
8856 eqcpup = &phba->sli4_hba.cpu_map[eqcpu]; in lpfc_sli4_queue_create()
8857 qp->hba_eq = phba->sli4_hba.hdwq[eqcpup->hdwq].hba_eq; in lpfc_sli4_queue_create()
8861 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
8866 if (phba->nvmet_support) { in lpfc_sli4_queue_create()
8867 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
8868 cpu = lpfc_find_cpu_handle(phba, idx, in lpfc_sli4_queue_create()
8872 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
8873 phba->sli4_hba.cq_ecount, in lpfc_sli4_queue_create()
8874 cpu); in lpfc_sli4_queue_create()
8881 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
8882 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
8883 qdesc->chann = cpu; in lpfc_sli4_queue_create()
8884 phba->sli4_hba.nvmet_cqset[idx] = qdesc; in lpfc_sli4_queue_create()
8892 cpu = lpfc_find_cpu_handle(phba, 0, LPFC_FIND_BY_EQ); in lpfc_sli4_queue_create()
8893 /* Create slow-path Mailbox Command Complete Queue */ in lpfc_sli4_queue_create()
8895 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
8896 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
8899 "0500 Failed allocate slow-path mailbox CQ\n"); in lpfc_sli4_queue_create()
8902 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
8903 phba->sli4_hba.mbx_cq = qdesc; in lpfc_sli4_queue_create()
8905 /* Create slow-path ELS Complete Queue */ in lpfc_sli4_queue_create()
8907 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
8908 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
8911 "0501 Failed allocate slow-path ELS CQ\n"); in lpfc_sli4_queue_create()
8914 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
8915 qdesc->chann = cpu; in lpfc_sli4_queue_create()
8916 phba->sli4_hba.els_cq = qdesc; in lpfc_sli4_queue_create()
8926 phba->sli4_hba.mq_esize, in lpfc_sli4_queue_create()
8927 phba->sli4_hba.mq_ecount, cpu); in lpfc_sli4_queue_create()
8930 "0505 Failed allocate slow-path MQ\n"); in lpfc_sli4_queue_create()
8933 qdesc->chann = cpu; in lpfc_sli4_queue_create()
8934 phba->sli4_hba.mbx_wq = qdesc; in lpfc_sli4_queue_create()
8940 /* Create slow-path ELS Work Queue */ in lpfc_sli4_queue_create()
8942 phba->sli4_hba.wq_esize, in lpfc_sli4_queue_create()
8943 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
8946 "0504 Failed allocate slow-path ELS WQ\n"); in lpfc_sli4_queue_create()
8949 qdesc->chann = cpu; in lpfc_sli4_queue_create()
8950 phba->sli4_hba.els_wq = qdesc; in lpfc_sli4_queue_create()
8951 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
8953 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
8956 phba->sli4_hba.cq_esize, in lpfc_sli4_queue_create()
8957 phba->sli4_hba.cq_ecount, cpu); in lpfc_sli4_queue_create()
8963 qdesc->chann = cpu; in lpfc_sli4_queue_create()
8964 qdesc->qe_valid = 1; in lpfc_sli4_queue_create()
8965 phba->sli4_hba.nvmels_cq = qdesc; in lpfc_sli4_queue_create()
8969 phba->sli4_hba.wq_esize, in lpfc_sli4_queue_create()
8970 phba->sli4_hba.wq_ecount, cpu); in lpfc_sli4_queue_create()
8976 qdesc->chann = cpu; in lpfc_sli4_queue_create()
8977 phba->sli4_hba.nvmels_wq = qdesc; in lpfc_sli4_queue_create()
8978 list_add_tail(&qdesc->wq_list, &phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_create()
8987 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
8988 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
8994 phba->sli4_hba.hdr_rq = qdesc; in lpfc_sli4_queue_create()
8998 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
8999 phba->sli4_hba.rq_ecount, cpu); in lpfc_sli4_queue_create()
9005 phba->sli4_hba.dat_rq = qdesc; in lpfc_sli4_queue_create()
9007 if ((phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) && in lpfc_sli4_queue_create()
9008 phba->nvmet_support) { in lpfc_sli4_queue_create()
9009 for (idx = 0; idx < phba->cfg_nvmet_mrq; idx++) { in lpfc_sli4_queue_create()
9010 cpu = lpfc_find_cpu_handle(phba, idx, in lpfc_sli4_queue_create()
9015 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
9017 cpu); in lpfc_sli4_queue_create()
9024 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
9025 phba->sli4_hba.nvmet_mrq_hdr[idx] = qdesc; in lpfc_sli4_queue_create()
9028 qdesc->rqbp = kzalloc_node(sizeof(*qdesc->rqbp), in lpfc_sli4_queue_create()
9030 cpu_to_node(cpu)); in lpfc_sli4_queue_create()
9031 if (qdesc->rqbp == NULL) { in lpfc_sli4_queue_create()
9039 INIT_LIST_HEAD(&qdesc->rqbp->rqb_buffer_list); in lpfc_sli4_queue_create()
9044 phba->sli4_hba.rq_esize, in lpfc_sli4_queue_create()
9046 cpu); in lpfc_sli4_queue_create()
9053 qdesc->hdwq = idx; in lpfc_sli4_queue_create()
9054 phba->sli4_hba.nvmet_mrq_data[idx] = qdesc; in lpfc_sli4_queue_create()
9059 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_create()
9060 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
9061 memset(&phba->sli4_hba.hdwq[idx].nvme_cstat, 0, in lpfc_sli4_queue_create()
9062 sizeof(phba->sli4_hba.hdwq[idx].nvme_cstat)); in lpfc_sli4_queue_create()
9067 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP) { in lpfc_sli4_queue_create()
9068 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_queue_create()
9069 memset(&phba->sli4_hba.hdwq[idx].scsi_cstat, 0, in lpfc_sli4_queue_create()
9070 sizeof(phba->sli4_hba.hdwq[idx].scsi_cstat)); in lpfc_sli4_queue_create()
9078 return -ENOMEM; in lpfc_sli4_queue_create()
9112 hdwq = phba->sli4_hba.hdwq; in lpfc_sli4_release_hdwq()
9115 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_release_hdwq()
9121 if (phba->cfg_xpsgl && !phba->nvmet_support) in lpfc_sli4_release_hdwq()
9126 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_release_hdwq()
9128 eq = phba->sli4_hba.hba_eq_hdl[idx].eq; in lpfc_sli4_release_hdwq()
9130 phba->sli4_hba.hba_eq_hdl[idx].eq = NULL; in lpfc_sli4_release_hdwq()
9135 * lpfc_sli4_queue_destroy - Destroy all the SLI4 queues
9142 * 0 - successful
9143 * -ENOMEM - No available memory
9144 * -EIO - The mailbox failed to complete successfully.
9154 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9155 phba->sli.sli_flag |= LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
9156 while (phba->sli.sli_flag & LPFC_QUEUE_FREE_WAIT) { in lpfc_sli4_queue_destroy()
9157 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9159 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9161 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9164 if (phba->sli4_hba.hdwq) in lpfc_sli4_queue_destroy()
9167 if (phba->nvmet_support) { in lpfc_sli4_queue_destroy()
9168 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_destroy()
9169 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
9171 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_destroy()
9172 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
9173 lpfc_sli4_release_queues(&phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_destroy()
9174 phba->cfg_nvmet_mrq); in lpfc_sli4_queue_destroy()
9178 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_destroy()
9181 __lpfc_sli4_release_queue(&phba->sli4_hba.els_wq); in lpfc_sli4_queue_destroy()
9184 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_destroy()
9187 __lpfc_sli4_release_queue(&phba->sli4_hba.hdr_rq); in lpfc_sli4_queue_destroy()
9188 __lpfc_sli4_release_queue(&phba->sli4_hba.dat_rq); in lpfc_sli4_queue_destroy()
9191 __lpfc_sli4_release_queue(&phba->sli4_hba.els_cq); in lpfc_sli4_queue_destroy()
9194 __lpfc_sli4_release_queue(&phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_destroy()
9197 __lpfc_sli4_release_queue(&phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_destroy()
9200 INIT_LIST_HEAD(&phba->sli4_hba.lpfc_wq_list); in lpfc_sli4_queue_destroy()
9203 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9204 phba->sli.sli_flag &= ~LPFC_QUEUE_FREE_INIT; in lpfc_sli4_queue_destroy()
9205 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_destroy()
9215 rqbp = rq->rqbp; in lpfc_free_rq_buffer()
9216 while (!list_empty(&rqbp->rqb_buffer_list)) { in lpfc_free_rq_buffer()
9217 list_remove_head(&rqbp->rqb_buffer_list, h_buf, in lpfc_free_rq_buffer()
9221 (rqbp->rqb_free_buffer)(phba, rqb_buffer); in lpfc_free_rq_buffer()
9222 rqbp->buffer_count--; in lpfc_free_rq_buffer()
9237 "6085 Fast-path %s (%d) not allocated\n", in lpfc_create_wq_cq()
9239 return -ENOMEM; in lpfc_create_wq_cq()
9255 *cq_map = cq->queue_id; in lpfc_create_wq_cq()
9258 "6087 CQ setup: cq[%d]-id=%d, parent eq[%d]-id=%d\n", in lpfc_create_wq_cq()
9259 qidx, cq->queue_id, qidx, eq->queue_id); in lpfc_create_wq_cq()
9267 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
9272 pring = wq->pring; in lpfc_create_wq_cq()
9273 pring->sli.sli4.wqp = (void *)wq; in lpfc_create_wq_cq()
9274 cq->pring = pring; in lpfc_create_wq_cq()
9277 "2593 WQ setup: wq[%d]-id=%d assoc=%d, cq[%d]-id=%d\n", in lpfc_create_wq_cq()
9278 qidx, wq->queue_id, wq->assoc_qid, qidx, cq->queue_id); in lpfc_create_wq_cq()
9283 "0539 Failed setup of slow-path MQ: " in lpfc_create_wq_cq()
9285 /* no need to tear down cq - caller will do so */ in lpfc_create_wq_cq()
9290 "2589 MBX MQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_create_wq_cq()
9291 phba->sli4_hba.mbx_wq->queue_id, in lpfc_create_wq_cq()
9292 phba->sli4_hba.mbx_cq->queue_id); in lpfc_create_wq_cq()
9299 * lpfc_setup_cq_lookup - Setup the CQ lookup table
9311 memset(phba->sli4_hba.cq_lookup, 0, in lpfc_setup_cq_lookup()
9312 (sizeof(struct lpfc_queue *) * (phba->sli4_hba.cq_max + 1))); in lpfc_setup_cq_lookup()
9314 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_setup_cq_lookup()
9316 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_setup_cq_lookup()
9320 list_for_each_entry(childq, &eq->child_list, list) { in lpfc_setup_cq_lookup()
9321 if (childq->queue_id > phba->sli4_hba.cq_max) in lpfc_setup_cq_lookup()
9323 if (childq->subtype == LPFC_IO) in lpfc_setup_cq_lookup()
9324 phba->sli4_hba.cq_lookup[childq->queue_id] = in lpfc_setup_cq_lookup()
9331 * lpfc_sli4_queue_setup - Set up all the SLI4 queues
9338 * 0 - successful
9339 * -ENOMEM - No available memory
9340 * -EIO - The mailbox failed to complete successfully.
9350 int qidx, cpu; in lpfc_sli4_queue_setup() local
9352 int rc = -ENOMEM; in lpfc_sli4_queue_setup()
9354 /* Check for dual-ULP support */ in lpfc_sli4_queue_setup()
9355 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_queue_setup()
9360 return -ENOMEM; in lpfc_sli4_queue_setup()
9362 length = (sizeof(struct lpfc_mbx_query_fw_config) - in lpfc_sli4_queue_setup()
9371 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli4_queue_setup()
9372 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_queue_setup()
9373 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_queue_setup()
9380 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
9381 rc = -ENXIO; in lpfc_sli4_queue_setup()
9385 phba->sli4_hba.fw_func_mode = in lpfc_sli4_queue_setup()
9386 mboxq->u.mqe.un.query_fw_cfg.rsp.function_mode; in lpfc_sli4_queue_setup()
9387 phba->sli4_hba.ulp0_mode = mboxq->u.mqe.un.query_fw_cfg.rsp.ulp0_mode; in lpfc_sli4_queue_setup()
9388 phba->sli4_hba.ulp1_mode = mboxq->u.mqe.un.query_fw_cfg.rsp.ulp1_mode; in lpfc_sli4_queue_setup()
9389 phba->sli4_hba.physical_port = in lpfc_sli4_queue_setup()
9390 mboxq->u.mqe.un.query_fw_cfg.rsp.physical_port; in lpfc_sli4_queue_setup()
9393 "ulp1_mode:x%x\n", phba->sli4_hba.fw_func_mode, in lpfc_sli4_queue_setup()
9394 phba->sli4_hba.ulp0_mode, phba->sli4_hba.ulp1_mode); in lpfc_sli4_queue_setup()
9397 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_queue_setup()
9402 qp = phba->sli4_hba.hdwq; in lpfc_sli4_queue_setup()
9407 "3147 Fast-path EQs not allocated\n"); in lpfc_sli4_queue_setup()
9408 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9413 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_setup()
9415 for_each_present_cpu(cpu) { in lpfc_sli4_queue_setup()
9416 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
9418 /* Look for the CPU thats using that vector with in lpfc_sli4_queue_setup()
9421 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_sli4_queue_setup()
9423 if (qidx != cpup->eq) in lpfc_sli4_queue_setup()
9427 rc = lpfc_eq_create(phba, qp[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
9428 phba->cfg_fcp_imax); in lpfc_sli4_queue_setup()
9431 "0523 Failed setup of fast-path" in lpfc_sli4_queue_setup()
9433 cpup->eq, (uint32_t)rc); in lpfc_sli4_queue_setup()
9438 phba->sli4_hba.hba_eq_hdl[cpup->eq].eq = in lpfc_sli4_queue_setup()
9439 qp[cpup->hdwq].hba_eq; in lpfc_sli4_queue_setup()
9442 "2584 HBA EQ setup: queue[%d]-id=%d\n", in lpfc_sli4_queue_setup()
9443 cpup->eq, in lpfc_sli4_queue_setup()
9444 qp[cpup->hdwq].hba_eq->queue_id); in lpfc_sli4_queue_setup()
9449 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_setup()
9450 cpu = lpfc_find_cpu_handle(phba, qidx, LPFC_FIND_BY_HDWQ); in lpfc_sli4_queue_setup()
9451 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_sli4_queue_setup()
9455 phba->sli4_hba.hdwq[cpup->hdwq].hba_eq, in lpfc_sli4_queue_setup()
9458 &phba->sli4_hba.hdwq[qidx].io_cq_map, in lpfc_sli4_queue_setup()
9474 /* Set up slow-path MBOX CQ/MQ */ in lpfc_sli4_queue_setup()
9476 if (!phba->sli4_hba.mbx_cq || !phba->sli4_hba.mbx_wq) { in lpfc_sli4_queue_setup()
9479 phba->sli4_hba.mbx_cq ? in lpfc_sli4_queue_setup()
9481 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9486 phba->sli4_hba.mbx_cq, in lpfc_sli4_queue_setup()
9487 phba->sli4_hba.mbx_wq, in lpfc_sli4_queue_setup()
9495 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
9496 if (!phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_setup()
9498 "3165 Fast-path NVME CQ Set " in lpfc_sli4_queue_setup()
9500 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9503 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
9505 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
9517 rc = lpfc_cq_create(phba, phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
9526 phba->sli4_hba.nvmet_cqset[0]->chann = 0; in lpfc_sli4_queue_setup()
9529 "6090 NVMET CQ setup: cq-id=%d, " in lpfc_sli4_queue_setup()
9530 "parent eq-id=%d\n", in lpfc_sli4_queue_setup()
9531 phba->sli4_hba.nvmet_cqset[0]->queue_id, in lpfc_sli4_queue_setup()
9532 qp[0].hba_eq->queue_id); in lpfc_sli4_queue_setup()
9536 /* Set up slow-path ELS WQ/CQ */ in lpfc_sli4_queue_setup()
9537 if (!phba->sli4_hba.els_cq || !phba->sli4_hba.els_wq) { in lpfc_sli4_queue_setup()
9540 phba->sli4_hba.els_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
9541 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9545 phba->sli4_hba.els_cq, in lpfc_sli4_queue_setup()
9546 phba->sli4_hba.els_wq, in lpfc_sli4_queue_setup()
9555 "2590 ELS WQ setup: wq-id=%d, parent cq-id=%d\n", in lpfc_sli4_queue_setup()
9556 phba->sli4_hba.els_wq->queue_id, in lpfc_sli4_queue_setup()
9557 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
9559 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_setup()
9561 if (!phba->sli4_hba.nvmels_cq || !phba->sli4_hba.nvmels_wq) { in lpfc_sli4_queue_setup()
9564 phba->sli4_hba.nvmels_cq ? "WQ" : "CQ"); in lpfc_sli4_queue_setup()
9565 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9569 phba->sli4_hba.nvmels_cq, in lpfc_sli4_queue_setup()
9570 phba->sli4_hba.nvmels_wq, in lpfc_sli4_queue_setup()
9580 "6096 ELS WQ setup: wq-id=%d, " in lpfc_sli4_queue_setup()
9581 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
9582 phba->sli4_hba.nvmels_wq->queue_id, in lpfc_sli4_queue_setup()
9583 phba->sli4_hba.nvmels_cq->queue_id); in lpfc_sli4_queue_setup()
9589 if (phba->nvmet_support) { in lpfc_sli4_queue_setup()
9590 if ((!phba->sli4_hba.nvmet_cqset) || in lpfc_sli4_queue_setup()
9591 (!phba->sli4_hba.nvmet_mrq_hdr) || in lpfc_sli4_queue_setup()
9592 (!phba->sli4_hba.nvmet_mrq_data)) { in lpfc_sli4_queue_setup()
9596 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9599 if (phba->cfg_nvmet_mrq > 1) { in lpfc_sli4_queue_setup()
9601 phba->sli4_hba.nvmet_mrq_hdr, in lpfc_sli4_queue_setup()
9602 phba->sli4_hba.nvmet_mrq_data, in lpfc_sli4_queue_setup()
9603 phba->sli4_hba.nvmet_cqset, in lpfc_sli4_queue_setup()
9615 phba->sli4_hba.nvmet_mrq_hdr[0], in lpfc_sli4_queue_setup()
9616 phba->sli4_hba.nvmet_mrq_data[0], in lpfc_sli4_queue_setup()
9617 phba->sli4_hba.nvmet_cqset[0], in lpfc_sli4_queue_setup()
9629 "6099 NVMET RQ setup: hdr-rq-id=%d, " in lpfc_sli4_queue_setup()
9630 "dat-rq-id=%d parent cq-id=%d\n", in lpfc_sli4_queue_setup()
9631 phba->sli4_hba.nvmet_mrq_hdr[0]->queue_id, in lpfc_sli4_queue_setup()
9632 phba->sli4_hba.nvmet_mrq_data[0]->queue_id, in lpfc_sli4_queue_setup()
9633 phba->sli4_hba.nvmet_cqset[0]->queue_id); in lpfc_sli4_queue_setup()
9638 if (!phba->sli4_hba.hdr_rq || !phba->sli4_hba.dat_rq) { in lpfc_sli4_queue_setup()
9641 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9645 rc = lpfc_rq_create(phba, phba->sli4_hba.hdr_rq, phba->sli4_hba.dat_rq, in lpfc_sli4_queue_setup()
9646 phba->sli4_hba.els_cq, LPFC_USOL); in lpfc_sli4_queue_setup()
9655 "2592 USL RQ setup: hdr-rq-id=%d, dat-rq-id=%d " in lpfc_sli4_queue_setup()
9656 "parent cq-id=%d\n", in lpfc_sli4_queue_setup()
9657 phba->sli4_hba.hdr_rq->queue_id, in lpfc_sli4_queue_setup()
9658 phba->sli4_hba.dat_rq->queue_id, in lpfc_sli4_queue_setup()
9659 phba->sli4_hba.els_cq->queue_id); in lpfc_sli4_queue_setup()
9661 if (phba->cfg_fcp_imax) in lpfc_sli4_queue_setup()
9662 usdelay = LPFC_SEC_TO_USEC / phba->cfg_fcp_imax; in lpfc_sli4_queue_setup()
9666 for (qidx = 0; qidx < phba->cfg_irq_chann; in lpfc_sli4_queue_setup()
9671 if (phba->sli4_hba.cq_max) { in lpfc_sli4_queue_setup()
9672 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_setup()
9673 phba->sli4_hba.cq_lookup = kcalloc((phba->sli4_hba.cq_max + 1), in lpfc_sli4_queue_setup()
9675 if (!phba->sli4_hba.cq_lookup) { in lpfc_sli4_queue_setup()
9678 "size 0x%x\n", phba->sli4_hba.cq_max); in lpfc_sli4_queue_setup()
9679 rc = -ENOMEM; in lpfc_sli4_queue_setup()
9693 * lpfc_sli4_queue_unset - Unset all the SLI4 queues
9700 * 0 - successful
9701 * -ENOMEM - No available memory
9702 * -EIO - The mailbox failed to complete successfully.
9712 if (phba->sli4_hba.mbx_wq) in lpfc_sli4_queue_unset()
9713 lpfc_mq_destroy(phba, phba->sli4_hba.mbx_wq); in lpfc_sli4_queue_unset()
9716 if (phba->sli4_hba.nvmels_wq) in lpfc_sli4_queue_unset()
9717 lpfc_wq_destroy(phba, phba->sli4_hba.nvmels_wq); in lpfc_sli4_queue_unset()
9720 if (phba->sli4_hba.els_wq) in lpfc_sli4_queue_unset()
9721 lpfc_wq_destroy(phba, phba->sli4_hba.els_wq); in lpfc_sli4_queue_unset()
9724 if (phba->sli4_hba.hdr_rq) in lpfc_sli4_queue_unset()
9725 lpfc_rq_destroy(phba, phba->sli4_hba.hdr_rq, in lpfc_sli4_queue_unset()
9726 phba->sli4_hba.dat_rq); in lpfc_sli4_queue_unset()
9729 if (phba->sli4_hba.mbx_cq) in lpfc_sli4_queue_unset()
9730 lpfc_cq_destroy(phba, phba->sli4_hba.mbx_cq); in lpfc_sli4_queue_unset()
9733 if (phba->sli4_hba.els_cq) in lpfc_sli4_queue_unset()
9734 lpfc_cq_destroy(phba, phba->sli4_hba.els_cq); in lpfc_sli4_queue_unset()
9737 if (phba->sli4_hba.nvmels_cq) in lpfc_sli4_queue_unset()
9738 lpfc_cq_destroy(phba, phba->sli4_hba.nvmels_cq); in lpfc_sli4_queue_unset()
9740 if (phba->nvmet_support) { in lpfc_sli4_queue_unset()
9742 if (phba->sli4_hba.nvmet_mrq_hdr) { in lpfc_sli4_queue_unset()
9743 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
9746 phba->sli4_hba.nvmet_mrq_hdr[qidx], in lpfc_sli4_queue_unset()
9747 phba->sli4_hba.nvmet_mrq_data[qidx]); in lpfc_sli4_queue_unset()
9751 if (phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_queue_unset()
9752 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) in lpfc_sli4_queue_unset()
9754 phba, phba->sli4_hba.nvmet_cqset[qidx]); in lpfc_sli4_queue_unset()
9758 /* Unset fast-path SLI4 queues */ in lpfc_sli4_queue_unset()
9759 if (phba->sli4_hba.hdwq) { in lpfc_sli4_queue_unset()
9761 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_queue_unset()
9763 qp = &phba->sli4_hba.hdwq[qidx]; in lpfc_sli4_queue_unset()
9764 lpfc_wq_destroy(phba, qp->io_wq); in lpfc_sli4_queue_unset()
9765 lpfc_cq_destroy(phba, qp->io_cq); in lpfc_sli4_queue_unset()
9768 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_queue_unset()
9770 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_sli4_queue_unset()
9775 kfree(phba->sli4_hba.cq_lookup); in lpfc_sli4_queue_unset()
9776 phba->sli4_hba.cq_lookup = NULL; in lpfc_sli4_queue_unset()
9777 phba->sli4_hba.cq_max = 0; in lpfc_sli4_queue_unset()
9781 * lpfc_sli4_cq_event_pool_create - Create completion-queue event free pool
9788 * - Mailbox asynchronous events
9789 * - Receive queue completion unsolicited events
9790 * Later, this can be used for all the slow-path events.
9793 * 0 - successful
9794 * -ENOMEM - No available memory
9802 for (i = 0; i < (4 * phba->sli4_hba.cq_ecount); i++) { in lpfc_sli4_cq_event_pool_create()
9806 list_add_tail(&cq_event->list, in lpfc_sli4_cq_event_pool_create()
9807 &phba->sli4_hba.sp_cqe_event_pool); in lpfc_sli4_cq_event_pool_create()
9813 return -ENOMEM; in lpfc_sli4_cq_event_pool_create()
9817 * lpfc_sli4_cq_event_pool_destroy - Free completion-queue event free pool
9822 * cleanup routine to free all the outstanding completion-queue events
9832 &phba->sli4_hba.sp_cqe_event_pool, list) { in lpfc_sli4_cq_event_pool_destroy()
9833 list_del(&cq_event->list); in lpfc_sli4_cq_event_pool_destroy()
9839 * __lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
9843 * completion-queue event from the free pool.
9845 * Return: Pointer to the newly allocated completion-queue event if successful
9853 list_remove_head(&phba->sli4_hba.sp_cqe_event_pool, cq_event, in __lpfc_sli4_cq_event_alloc()
9859 * lpfc_sli4_cq_event_alloc - Allocate a completion-queue event from free pool
9863 * completion-queue event from the free pool.
9865 * Return: Pointer to the newly allocated completion-queue event if successful
9874 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
9876 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_alloc()
9881 * __lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
9886 * completion-queue event back into the free pool.
9892 list_add_tail(&cq_event->list, &phba->sli4_hba.sp_cqe_event_pool); in __lpfc_sli4_cq_event_release()
9896 * lpfc_sli4_cq_event_release - Release a completion-queue event to free pool
9901 * completion-queue event back into the free pool.
9908 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
9910 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release()
9914 * lpfc_sli4_cq_event_release_all - Release all cq events to the free pool
9917 * This routine is to free all the pending completion-queue events to the
9928 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release_all()
9930 list_splice_init(&phba->sli4_hba.sp_fcp_xri_aborted_work_queue, in lpfc_sli4_cq_event_release_all()
9933 list_splice_init(&phba->sli4_hba.sp_els_xri_aborted_work_queue, in lpfc_sli4_cq_event_release_all()
9936 list_splice_init(&phba->sli4_hba.sp_asynce_work_queue, in lpfc_sli4_cq_event_release_all()
9938 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_cq_event_release_all()
9947 * lpfc_pci_function_reset - Reset pci function.
9954 * 0 - successful
9955 * -ENOMEM - No available memory
9956 * -EIO - The mailbox failed to complete successfully.
9970 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_pci_function_reset()
9973 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, in lpfc_pci_function_reset()
9980 return -ENOMEM; in lpfc_pci_function_reset()
9983 /* Setup PCI function reset mailbox-ioctl command */ in lpfc_pci_function_reset()
9989 &mboxq->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_pci_function_reset()
9990 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_pci_function_reset()
9992 &shdr->response); in lpfc_pci_function_reset()
9994 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_pci_function_reset()
10001 rc = -ENXIO; in lpfc_pci_function_reset()
10013 if (lpfc_readl(phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
10015 rc = -ENODEV; in lpfc_pci_function_reset()
10024 phba->work_status[0] = readl( in lpfc_pci_function_reset()
10025 phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_pci_function_reset()
10026 phba->work_status[1] = readl( in lpfc_pci_function_reset()
10027 phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_pci_function_reset()
10032 phba->work_status[0], in lpfc_pci_function_reset()
10033 phba->work_status[1]); in lpfc_pci_function_reset()
10034 rc = -ENODEV; in lpfc_pci_function_reset()
10047 writel(reg_data.word0, phba->sli4_hba.u.if_type2. in lpfc_pci_function_reset()
10050 pci_read_config_word(phba->pcidev, in lpfc_pci_function_reset()
10057 rc = -ENODEV; in lpfc_pci_function_reset()
10068 /* Catch the not-ready port failure after a port reset. */ in lpfc_pci_function_reset()
10073 rc = -ENODEV; in lpfc_pci_function_reset()
10080 * lpfc_sli4_pci_mem_setup - Setup SLI4 HBA PCI memory space.
10084 * with SLI-4 interface spec.
10087 * 0 - successful
10088 * other values - error
10093 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_pci_mem_setup()
10099 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10102 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in lpfc_sli4_pci_mem_setup()
10104 error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in lpfc_sli4_pci_mem_setup()
10113 &phba->sli4_hba.sli_intf.word0)) { in lpfc_sli4_pci_mem_setup()
10114 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10118 if (bf_get(lpfc_sli_intf_valid, &phba->sli4_hba.sli_intf) != in lpfc_sli4_pci_mem_setup()
10123 phba->sli4_hba.sli_intf.word0); in lpfc_sli4_pci_mem_setup()
10124 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10127 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_setup()
10135 phba->pci_bar0_map = pci_resource_start(pdev, PCI_64BIT_BAR0); in lpfc_sli4_pci_mem_setup()
10142 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10143 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
10144 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10145 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
10148 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10150 phba->pci_bar0_memmap_p = phba->sli4_hba.conf_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10154 phba->pci_bar0_map = pci_resource_start(pdev, 1); in lpfc_sli4_pci_mem_setup()
10157 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
10158 "FATAL - No BAR0 mapping for SLI4, if_type 2\n"); in lpfc_sli4_pci_mem_setup()
10159 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10161 phba->sli4_hba.conf_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10162 ioremap(phba->pci_bar0_map, bar0map_len); in lpfc_sli4_pci_mem_setup()
10163 if (!phba->sli4_hba.conf_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10164 dev_printk(KERN_ERR, &pdev->dev, in lpfc_sli4_pci_mem_setup()
10167 return -ENODEV; in lpfc_sli4_pci_mem_setup()
10178 phba->pci_bar1_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
10181 phba->sli4_hba.ctrl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10182 ioremap(phba->pci_bar1_map, in lpfc_sli4_pci_mem_setup()
10184 if (!phba->sli4_hba.ctrl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10185 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
10188 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10191 phba->pci_bar2_memmap_p = in lpfc_sli4_pci_mem_setup()
10192 phba->sli4_hba.ctrl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10195 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10206 phba->pci_bar1_map = pci_resource_start(pdev, PCI_64BIT_BAR2); in lpfc_sli4_pci_mem_setup()
10208 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10209 ioremap(phba->pci_bar1_map, bar1map_len); in lpfc_sli4_pci_mem_setup()
10210 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10211 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
10213 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10216 phba->pci_bar2_memmap_p = phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10226 phba->pci_bar2_map = pci_resource_start(pdev, in lpfc_sli4_pci_mem_setup()
10229 phba->sli4_hba.drbl_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10230 ioremap(phba->pci_bar2_map, in lpfc_sli4_pci_mem_setup()
10232 if (!phba->sli4_hba.drbl_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10233 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
10236 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10239 phba->pci_bar4_memmap_p = in lpfc_sli4_pci_mem_setup()
10240 phba->sli4_hba.drbl_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10245 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10256 phba->pci_bar2_map = pci_resource_start(pdev, PCI_64BIT_BAR4); in lpfc_sli4_pci_mem_setup()
10258 phba->sli4_hba.dpp_regs_memmap_p = in lpfc_sli4_pci_mem_setup()
10259 ioremap(phba->pci_bar2_map, bar2map_len); in lpfc_sli4_pci_mem_setup()
10260 if (!phba->sli4_hba.dpp_regs_memmap_p) { in lpfc_sli4_pci_mem_setup()
10261 dev_err(&pdev->dev, in lpfc_sli4_pci_mem_setup()
10263 error = -ENOMEM; in lpfc_sli4_pci_mem_setup()
10266 phba->pci_bar4_memmap_p = phba->sli4_hba.dpp_regs_memmap_p; in lpfc_sli4_pci_mem_setup()
10273 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
10274 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_write_eq_db; in lpfc_sli4_pci_mem_setup()
10275 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_write_cq_db; in lpfc_sli4_pci_mem_setup()
10278 phba->sli4_hba.sli4_eq_clr_intr = lpfc_sli4_if6_eq_clr_intr; in lpfc_sli4_pci_mem_setup()
10279 phba->sli4_hba.sli4_write_eq_db = lpfc_sli4_if6_write_eq_db; in lpfc_sli4_pci_mem_setup()
10280 phba->sli4_hba.sli4_write_cq_db = lpfc_sli4_if6_write_cq_db; in lpfc_sli4_pci_mem_setup()
10289 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
10291 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
10293 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_setup()
10299 * lpfc_sli4_pci_mem_unset - Unset SLI4 HBA PCI memory space.
10303 * with SLI-4 interface spec.
10309 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_pci_mem_unset()
10313 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10314 iounmap(phba->sli4_hba.ctrl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10315 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10318 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10321 iounmap(phba->sli4_hba.drbl_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10322 iounmap(phba->sli4_hba.conf_regs_memmap_p); in lpfc_sli4_pci_mem_unset()
10326 dev_printk(KERN_ERR, &phba->pcidev->dev, in lpfc_sli4_pci_mem_unset()
10327 "FATAL - unsupported SLI4 interface type - %d\n", in lpfc_sli4_pci_mem_unset()
10334 * lpfc_sli_enable_msix - Enable MSI-X interrupt mode on SLI-3 device
10337 * This routine is invoked to enable the MSI-X interrupt vectors to device
10338 * with SLI-3 interface specs.
10341 * 0 - successful
10342 * other values - error
10350 /* Set up MSI-X multi-message vectors */ in lpfc_sli_enable_msix()
10351 rc = pci_alloc_irq_vectors(phba->pcidev, in lpfc_sli_enable_msix()
10355 "0420 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli_enable_msix()
10360 * Assign MSI-X vectors to interrupt handlers in lpfc_sli_enable_msix()
10363 /* vector-0 is associated to slow-path handler */ in lpfc_sli_enable_msix()
10364 rc = request_irq(pci_irq_vector(phba->pcidev, 0), in lpfc_sli_enable_msix()
10369 "0421 MSI-X slow-path request_irq failed " in lpfc_sli_enable_msix()
10374 /* vector-1 is associated to fast-path handler */ in lpfc_sli_enable_msix()
10375 rc = request_irq(pci_irq_vector(phba->pcidev, 1), in lpfc_sli_enable_msix()
10381 "0429 MSI-X fast-path request_irq failed " in lpfc_sli_enable_msix()
10387 * Configure HBA MSI-X attention conditions to messages in lpfc_sli_enable_msix()
10389 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_enable_msix()
10392 rc = -ENOMEM; in lpfc_sli_enable_msix()
10406 pmb->u.mb.mbxCommand, pmb->u.mb.mbxStatus); in lpfc_sli_enable_msix()
10411 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
10416 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_enable_msix()
10420 free_irq(pci_irq_vector(phba->pcidev, 1), phba); in lpfc_sli_enable_msix()
10424 free_irq(pci_irq_vector(phba->pcidev, 0), phba); in lpfc_sli_enable_msix()
10427 /* Unconfigure MSI-X capability structure */ in lpfc_sli_enable_msix()
10428 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_enable_msix()
10435 * lpfc_sli_enable_msi - Enable MSI interrupt mode on SLI-3 device.
10439 * SLI-3 interface spec. The kernel function pci_enable_msi() is called to
10445 * 0 - successful
10446 * other values - error
10453 rc = pci_enable_msi(phba->pcidev); in lpfc_sli_enable_msi()
10463 rc = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_msi()
10466 pci_disable_msi(phba->pcidev); in lpfc_sli_enable_msi()
10474 * lpfc_sli_enable_intr - Enable device interrupt to SLI-3 device.
10478 * interrupt handler(s) to interrupt vector(s) to device with SLI-3 interface
10483 * MSI-X -> MSI -> IRQ.
10486 * 0 - successful
10487 * other values - error
10499 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli_enable_intr()
10502 /* Indicate initialization to MSI-X mode */ in lpfc_sli_enable_intr()
10503 phba->intr_type = MSIX; in lpfc_sli_enable_intr()
10509 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli_enable_intr()
10510 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli_enable_intr()
10514 phba->intr_type = MSI; in lpfc_sli_enable_intr()
10519 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli_enable_intr()
10520 if (phba->intr_type == NONE) { in lpfc_sli_enable_intr()
10521 retval = request_irq(phba->pcidev->irq, lpfc_sli_intr_handler, in lpfc_sli_enable_intr()
10525 phba->intr_type = INTx; in lpfc_sli_enable_intr()
10533 * lpfc_sli_disable_intr - Disable device interrupt to SLI-3 device.
10538 * SLI-3 interface spec. Depending on the interrupt mode, the driver will
10546 if (phba->intr_type == MSIX) in lpfc_sli_disable_intr()
10552 free_irq(pci_irq_vector(phba->pcidev, i), phba); in lpfc_sli_disable_intr()
10553 pci_free_irq_vectors(phba->pcidev); in lpfc_sli_disable_intr()
10556 phba->intr_type = NONE; in lpfc_sli_disable_intr()
10557 phba->sli.slistat.sli_intr = 0; in lpfc_sli_disable_intr()
10561 * lpfc_find_cpu_handle - Find the CPU that corresponds to the specified Queue
10566 * Return the CPU that matches the selection criteria
10572 int cpu; in lpfc_find_cpu_handle() local
10575 for_each_present_cpu(cpu) { in lpfc_find_cpu_handle()
10576 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_find_cpu_handle()
10583 (cpup->flag & LPFC_CPU_FIRST_IRQ) && in lpfc_find_cpu_handle()
10584 (cpup->irq != LPFC_VECTOR_MAP_EMPTY) && in lpfc_find_cpu_handle()
10585 (cpup->eq == id)) in lpfc_find_cpu_handle()
10586 return cpu; in lpfc_find_cpu_handle()
10588 /* If matching by HDWQ, select the first CPU that matches */ in lpfc_find_cpu_handle()
10589 if ((match == LPFC_FIND_BY_HDWQ) && (cpup->hdwq == id)) in lpfc_find_cpu_handle()
10590 return cpu; in lpfc_find_cpu_handle()
10597 * lpfc_find_hyper - Determine if the CPU map entry is hyper-threaded
10599 * @cpu: CPU map index
10600 * @phys_id: CPU package physical id
10601 * @core_id: CPU core id
10604 lpfc_find_hyper(struct lpfc_hba *phba, int cpu, in lpfc_find_hyper() argument
10611 cpup = &phba->sli4_hba.cpu_map[idx]; in lpfc_find_hyper()
10613 if ((cpup->phys_id == phys_id) && in lpfc_find_hyper()
10614 (cpup->core_id == core_id) && in lpfc_find_hyper()
10615 (cpu != idx)) in lpfc_find_hyper()
10623 * lpfc_cpu_affinity_check - Check vector CPU affinity mappings
10627 * The routine will figure out the CPU affinity assignment for every
10628 * MSI-X vector allocated for the HBA.
10629 * In addition, the CPU to IO channel mapping will be calculated
10630 * and the phba->sli4_hba.cpu_map array will reflect this.
10635 int i, cpu, idx, next_idx, new_cpu, start_cpu, first_cpu; in lpfc_cpu_affinity_check() local
10646 for_each_possible_cpu(cpu) { in lpfc_cpu_affinity_check()
10647 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
10648 cpup->phys_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_affinity_check()
10649 cpup->core_id = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_affinity_check()
10650 cpup->hdwq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_affinity_check()
10651 cpup->eq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_affinity_check()
10652 cpup->irq = LPFC_VECTOR_MAP_EMPTY; in lpfc_cpu_affinity_check()
10653 cpup->flag = 0; in lpfc_cpu_affinity_check()
10661 /* Update CPU map with physical id and core id of each CPU */ in lpfc_cpu_affinity_check()
10662 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
10663 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
10665 cpuinfo = &cpu_data(cpu); in lpfc_cpu_affinity_check()
10666 cpup->phys_id = cpuinfo->phys_proc_id; in lpfc_cpu_affinity_check()
10667 cpup->core_id = cpuinfo->cpu_core_id; in lpfc_cpu_affinity_check()
10668 if (lpfc_find_hyper(phba, cpu, cpup->phys_id, cpup->core_id)) in lpfc_cpu_affinity_check()
10669 cpup->flag |= LPFC_CPU_MAP_HYPER; in lpfc_cpu_affinity_check()
10672 cpup->phys_id = 0; in lpfc_cpu_affinity_check()
10673 cpup->core_id = cpu; in lpfc_cpu_affinity_check()
10677 "3328 CPU %d physid %d coreid %d flag x%x\n", in lpfc_cpu_affinity_check()
10678 cpu, cpup->phys_id, cpup->core_id, cpup->flag); in lpfc_cpu_affinity_check()
10680 if (cpup->phys_id > max_phys_id) in lpfc_cpu_affinity_check()
10681 max_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
10682 if (cpup->phys_id < min_phys_id) in lpfc_cpu_affinity_check()
10683 min_phys_id = cpup->phys_id; in lpfc_cpu_affinity_check()
10685 if (cpup->core_id > max_core_id) in lpfc_cpu_affinity_check()
10686 max_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
10687 if (cpup->core_id < min_core_id) in lpfc_cpu_affinity_check()
10688 min_core_id = cpup->core_id; in lpfc_cpu_affinity_check()
10693 per_cpu_ptr(phba->sli4_hba.eq_info, i); in lpfc_cpu_affinity_check()
10695 INIT_LIST_HEAD(&eqi->list); in lpfc_cpu_affinity_check()
10696 eqi->icnt = 0; in lpfc_cpu_affinity_check()
10706 * first present cpu, and assign the eq index to ensure at in lpfc_cpu_affinity_check()
10709 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_cpu_affinity_check()
10710 /* Get a CPU mask for all CPUs affinitized to this vector */ in lpfc_cpu_affinity_check()
10711 maskp = pci_irq_get_affinity(phba->pcidev, idx); in lpfc_cpu_affinity_check()
10713 if (phba->cfg_irq_chann > 1) in lpfc_cpu_affinity_check()
10717 idx, phba->cfg_irq_chann); in lpfc_cpu_affinity_check()
10719 cpu = cpumask_first(cpu_present_mask); in lpfc_cpu_affinity_check()
10720 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
10721 cpup->eq = idx; in lpfc_cpu_affinity_check()
10722 cpup->irq = pci_irq_vector(phba->pcidev, idx); in lpfc_cpu_affinity_check()
10723 cpup->flag |= LPFC_CPU_FIRST_IRQ; in lpfc_cpu_affinity_check()
10730 for_each_cpu_and(cpu, maskp, cpu_present_mask) { in lpfc_cpu_affinity_check()
10732 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
10733 cpup->eq = idx; in lpfc_cpu_affinity_check()
10734 cpup->irq = pci_irq_vector(phba->pcidev, idx); in lpfc_cpu_affinity_check()
10736 /* If this is the first CPU thats assigned to this in lpfc_cpu_affinity_check()
10740 cpup->flag |= LPFC_CPU_FIRST_IRQ; in lpfc_cpu_affinity_check()
10744 "3336 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
10746 cpu, cpup->irq, cpup->eq, cpup->flag); in lpfc_cpu_affinity_check()
10752 * Next we will set any unassigned (unaffinitized) cpu map in lpfc_cpu_affinity_check()
10758 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
10759 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
10761 /* Is this CPU entry unassigned */ in lpfc_cpu_affinity_check()
10762 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
10763 /* Mark CPU as IRQ not assigned by the kernel */ in lpfc_cpu_affinity_check()
10764 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
10772 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
10773 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
10774 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
10775 (new_cpup->irq != LPFC_VECTOR_MAP_EMPTY) && in lpfc_cpu_affinity_check()
10776 (new_cpup->phys_id == cpup->phys_id)) in lpfc_cpu_affinity_check()
10783 /* At this point, we leave the CPU as unassigned */ in lpfc_cpu_affinity_check()
10787 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
10788 cpup->irq = new_cpup->irq; in lpfc_cpu_affinity_check()
10791 * chance of having multiple unassigned CPU entries in lpfc_cpu_affinity_check()
10799 "3337 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
10802 cpu, cpup->irq, new_cpu, cpup->phys_id); in lpfc_cpu_affinity_check()
10806 /* Set any unassigned cpu map entries to a IRQ on any phys_id */ in lpfc_cpu_affinity_check()
10809 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
10810 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
10813 if (cpup->eq == LPFC_VECTOR_MAP_EMPTY) { in lpfc_cpu_affinity_check()
10815 cpup->flag |= LPFC_CPU_MAP_UNASSIGN; in lpfc_cpu_affinity_check()
10823 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
10824 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
10825 if (!(new_cpup->flag & LPFC_CPU_MAP_UNASSIGN) && in lpfc_cpu_affinity_check()
10826 (new_cpup->irq != LPFC_VECTOR_MAP_EMPTY)) in lpfc_cpu_affinity_check()
10835 "3339 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
10837 cpup->hdwq, cpup->irq); in lpfc_cpu_affinity_check()
10841 cpup->eq = new_cpup->eq; in lpfc_cpu_affinity_check()
10842 cpup->irq = new_cpup->irq; in lpfc_cpu_affinity_check()
10845 * chance of having multiple unassigned CPU entries in lpfc_cpu_affinity_check()
10853 "3338 Set Affinity: CPU %d " in lpfc_cpu_affinity_check()
10855 cpu, cpup->irq, new_cpu, in lpfc_cpu_affinity_check()
10856 new_cpup->phys_id, new_cpup->core_id); in lpfc_cpu_affinity_check()
10864 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
10865 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
10868 if (!(cpup->flag & LPFC_CPU_FIRST_IRQ)) in lpfc_cpu_affinity_check()
10872 cpup->hdwq = idx; in lpfc_cpu_affinity_check()
10875 "3333 Set Affinity: CPU %d (phys %d core %d): " in lpfc_cpu_affinity_check()
10877 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
10878 cpup->hdwq, cpup->eq, cpup->irq, cpup->flag); in lpfc_cpu_affinity_check()
10881 * This will be 1 to 1 - hdwq to cpu, unless there are less in lpfc_cpu_affinity_check()
10882 * hardware queues then CPUs. For that case we will just round-robin in lpfc_cpu_affinity_check()
10885 * for irq_chann < hdwq. The idx is used for round-robin assignments in lpfc_cpu_affinity_check()
10891 for_each_present_cpu(cpu) { in lpfc_cpu_affinity_check()
10892 cpup = &phba->sli4_hba.cpu_map[cpu]; in lpfc_cpu_affinity_check()
10895 if (cpup->flag & LPFC_CPU_FIRST_IRQ) in lpfc_cpu_affinity_check()
10902 if (next_idx < phba->cfg_hdw_queue) { in lpfc_cpu_affinity_check()
10903 cpup->hdwq = next_idx; in lpfc_cpu_affinity_check()
10908 /* Not a First CPU and all hdw_queues are used. Reuse a in lpfc_cpu_affinity_check()
10909 * Hardware Queue for another CPU, so be smart about it in lpfc_cpu_affinity_check()
10911 * (CPU package) and core_id. in lpfc_cpu_affinity_check()
10914 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
10915 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
10916 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
10917 new_cpup->phys_id == cpup->phys_id && in lpfc_cpu_affinity_check()
10918 new_cpup->core_id == cpup->core_id) { in lpfc_cpu_affinity_check()
10930 for (i = 0; i < phba->sli4_hba.num_present_cpu; i++) { in lpfc_cpu_affinity_check()
10931 new_cpup = &phba->sli4_hba.cpu_map[new_cpu]; in lpfc_cpu_affinity_check()
10932 if (new_cpup->hdwq != LPFC_VECTOR_MAP_EMPTY && in lpfc_cpu_affinity_check()
10933 new_cpup->phys_id == cpup->phys_id) in lpfc_cpu_affinity_check()
10942 cpup->hdwq = idx % phba->cfg_hdw_queue; in lpfc_cpu_affinity_check()
10950 cpup->hdwq = new_cpup->hdwq; in lpfc_cpu_affinity_check()
10953 "3335 Set Affinity: CPU %d (phys %d core %d): " in lpfc_cpu_affinity_check()
10955 cpu, cpup->phys_id, cpup->core_id, in lpfc_cpu_affinity_check()
10956 cpup->hdwq, cpup->eq, cpup->irq, cpup->flag); in lpfc_cpu_affinity_check()
10966 * lpfc_sli4_enable_msix - Enable MSI-X interrupt mode to SLI-4 device
10969 * This routine is invoked to enable the MSI-X interrupt vectors to device
10970 * with SLI-4 interface spec.
10973 * 0 - successful
10974 * other values - error
10982 /* Set up MSI-X multi-message vectors */ in lpfc_sli4_enable_msix()
10983 vectors = phba->cfg_irq_chann; in lpfc_sli4_enable_msix()
10985 rc = pci_alloc_irq_vectors(phba->pcidev, in lpfc_sli4_enable_msix()
10990 "0484 PCI enable MSI-X failed (%d)\n", rc); in lpfc_sli4_enable_msix()
10995 /* Assign MSI-X vectors to interrupt handlers */ in lpfc_sli4_enable_msix()
10997 name = phba->sli4_hba.hba_eq_hdl[index].handler_name; in lpfc_sli4_enable_msix()
11002 phba->sli4_hba.hba_eq_hdl[index].idx = index; in lpfc_sli4_enable_msix()
11003 phba->sli4_hba.hba_eq_hdl[index].phba = phba; in lpfc_sli4_enable_msix()
11004 rc = request_irq(pci_irq_vector(phba->pcidev, index), in lpfc_sli4_enable_msix()
11007 &phba->sli4_hba.hba_eq_hdl[index]); in lpfc_sli4_enable_msix()
11010 "0486 MSI-X fast-path (%d) " in lpfc_sli4_enable_msix()
11016 if (vectors != phba->cfg_irq_chann) { in lpfc_sli4_enable_msix()
11019 "MSI-X vectors, requested %d got %d\n", in lpfc_sli4_enable_msix()
11020 phba->cfg_irq_chann, vectors); in lpfc_sli4_enable_msix()
11021 if (phba->cfg_irq_chann > vectors) in lpfc_sli4_enable_msix()
11022 phba->cfg_irq_chann = vectors; in lpfc_sli4_enable_msix()
11023 if (phba->nvmet_support && (phba->cfg_nvmet_mrq > vectors)) in lpfc_sli4_enable_msix()
11024 phba->cfg_nvmet_mrq = vectors; in lpfc_sli4_enable_msix()
11031 for (--index; index >= 0; index--) in lpfc_sli4_enable_msix()
11032 free_irq(pci_irq_vector(phba->pcidev, index), in lpfc_sli4_enable_msix()
11033 &phba->sli4_hba.hba_eq_hdl[index]); in lpfc_sli4_enable_msix()
11035 /* Unconfigure MSI-X capability structure */ in lpfc_sli4_enable_msix()
11036 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msix()
11043 * lpfc_sli4_enable_msi - Enable MSI interrupt mode to SLI-4 device
11047 * SLI-4 interface spec. The kernel function pci_alloc_irq_vectors() is
11053 * 0 - successful
11054 * other values - error
11061 rc = pci_alloc_irq_vectors(phba->pcidev, 1, 1, in lpfc_sli4_enable_msi()
11069 return rc ? rc : -1; in lpfc_sli4_enable_msi()
11072 rc = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_msi()
11075 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_enable_msi()
11081 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_enable_msi()
11082 phba->sli4_hba.hba_eq_hdl[index].idx = index; in lpfc_sli4_enable_msi()
11083 phba->sli4_hba.hba_eq_hdl[index].phba = phba; in lpfc_sli4_enable_msi()
11090 * lpfc_sli4_enable_intr - Enable device interrupt to SLI-4 device
11094 * interrupt handler(s) to interrupt vector(s) to device with SLI-4
11099 * MSI-X -> MSI -> IRQ.
11102 * 0 - successful
11103 * other values - error
11115 /* Now, try to enable MSI-X interrupt mode */ in lpfc_sli4_enable_intr()
11118 /* Indicate initialization to MSI-X mode */ in lpfc_sli4_enable_intr()
11119 phba->intr_type = MSIX; in lpfc_sli4_enable_intr()
11125 /* Fallback to MSI if MSI-X initialization failed */ in lpfc_sli4_enable_intr()
11126 if (cfg_mode >= 1 && phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
11130 phba->intr_type = MSI; in lpfc_sli4_enable_intr()
11135 /* Fallback to INTx if both MSI-X/MSI initalization failed */ in lpfc_sli4_enable_intr()
11136 if (phba->intr_type == NONE) { in lpfc_sli4_enable_intr()
11137 retval = request_irq(phba->pcidev->irq, lpfc_sli4_intr_handler, in lpfc_sli4_enable_intr()
11143 phba->intr_type = INTx; in lpfc_sli4_enable_intr()
11146 for (idx = 0; idx < phba->cfg_irq_chann; idx++) { in lpfc_sli4_enable_intr()
11147 eqhdl = &phba->sli4_hba.hba_eq_hdl[idx]; in lpfc_sli4_enable_intr()
11148 eqhdl->idx = idx; in lpfc_sli4_enable_intr()
11149 eqhdl->phba = phba; in lpfc_sli4_enable_intr()
11157 * lpfc_sli4_disable_intr - Disable device interrupt to SLI-4 device
11162 * with SLI-4 interface spec. Depending on the interrupt mode, the driver
11169 if (phba->intr_type == MSIX) { in lpfc_sli4_disable_intr()
11172 /* Free up MSI-X multi-message vectors */ in lpfc_sli4_disable_intr()
11173 for (index = 0; index < phba->cfg_irq_chann; index++) { in lpfc_sli4_disable_intr()
11175 pci_irq_vector(phba->pcidev, index), in lpfc_sli4_disable_intr()
11177 free_irq(pci_irq_vector(phba->pcidev, index), in lpfc_sli4_disable_intr()
11178 &phba->sli4_hba.hba_eq_hdl[index]); in lpfc_sli4_disable_intr()
11181 free_irq(phba->pcidev->irq, phba); in lpfc_sli4_disable_intr()
11184 pci_free_irq_vectors(phba->pcidev); in lpfc_sli4_disable_intr()
11187 phba->intr_type = NONE; in lpfc_sli4_disable_intr()
11188 phba->sli.slistat.sli_intr = 0; in lpfc_sli4_disable_intr()
11192 * lpfc_unset_hba - Unset SLI3 hba device initialization
11196 * a device with SLI-3 interface spec.
11201 struct lpfc_vport *vport = phba->pport; in lpfc_unset_hba()
11204 spin_lock_irq(shost->host_lock); in lpfc_unset_hba()
11205 vport->load_flag |= FC_UNLOADING; in lpfc_unset_hba()
11206 spin_unlock_irq(shost->host_lock); in lpfc_unset_hba()
11208 kfree(phba->vpi_bmask); in lpfc_unset_hba()
11209 kfree(phba->vpi_ids); in lpfc_unset_hba()
11213 phba->pport->work_port_events = 0; in lpfc_unset_hba()
11225 * lpfc_sli4_xri_exchange_busy_wait - Wait for device XRI exchange busy
11245 int els_xri_cmpl = list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
11254 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) in lpfc_sli4_xri_exchange_busy_wait()
11258 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
11259 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
11260 io_xri_cmpl = list_empty(&qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
11267 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
11269 list_empty(&phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
11297 for (idx = 0; idx < phba->cfg_hdw_queue; idx++) { in lpfc_sli4_xri_exchange_busy_wait()
11298 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_sli4_xri_exchange_busy_wait()
11300 &qp->lpfc_abts_io_buf_list); in lpfc_sli4_xri_exchange_busy_wait()
11307 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_xri_exchange_busy_wait()
11309 &phba->sli4_hba.lpfc_abts_nvmet_ctx_list); in lpfc_sli4_xri_exchange_busy_wait()
11312 list_empty(&phba->sli4_hba.lpfc_abts_els_sgl_list); in lpfc_sli4_xri_exchange_busy_wait()
11318 * lpfc_sli4_hba_unset - Unset the fcoe hba
11332 struct pci_dev *pdev = phba->pcidev; in lpfc_sli4_hba_unset()
11335 if (phba->pport) in lpfc_sli4_hba_unset()
11336 phba->sli4_hba.intr_enable = 0; in lpfc_sli4_hba_unset()
11344 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
11345 phba->sli.sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_hba_unset()
11346 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
11348 while (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
11354 if (phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_hba_unset()
11355 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
11356 mboxq = phba->sli.mbox_active; in lpfc_sli4_hba_unset()
11357 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_hba_unset()
11359 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_hba_unset()
11360 phba->sli.mbox_active = NULL; in lpfc_sli4_hba_unset()
11361 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_unset()
11373 /* Disable SR-IOV if enabled */ in lpfc_sli4_hba_unset()
11374 if (phba->cfg_sriov_nr_virtfn) in lpfc_sli4_hba_unset()
11378 kthread_stop(phba->worker_thread); in lpfc_sli4_hba_unset()
11393 if (phba->ras_fwlog.ras_enabled) in lpfc_sli4_hba_unset()
11397 if (phba->pport) in lpfc_sli4_hba_unset()
11398 phba->pport->work_port_events = 0; in lpfc_sli4_hba_unset()
11402 * lpfc_pc_sli4_params_get - Get the SLI4_PARAMS port capabilities.
11409 * This function may be be called from any context that can block-wait
11422 mqe = &mboxq->u.mqe; in lpfc_pc_sli4_params_get()
11426 if (!phba->sli4_hba.intr_enable) in lpfc_pc_sli4_params_get()
11436 sli4_params = &phba->sli4_hba.pc_sli4_params; in lpfc_pc_sli4_params_get()
11437 sli4_params->if_type = bf_get(if_type, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11438 sli4_params->sli_rev = bf_get(sli_rev, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11439 sli4_params->sli_family = bf_get(sli_family, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11440 sli4_params->featurelevel_1 = bf_get(featurelevel_1, in lpfc_pc_sli4_params_get()
11441 &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11442 sli4_params->featurelevel_2 = bf_get(featurelevel_2, in lpfc_pc_sli4_params_get()
11443 &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11444 sli4_params->proto_types = mqe->un.sli4_params.word3; in lpfc_pc_sli4_params_get()
11445 sli4_params->sge_supp_len = mqe->un.sli4_params.sge_supp_len; in lpfc_pc_sli4_params_get()
11446 sli4_params->if_page_sz = bf_get(if_page_sz, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11447 sli4_params->rq_db_window = bf_get(rq_db_window, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11448 sli4_params->loopbk_scope = bf_get(loopbk_scope, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11449 sli4_params->eq_pages_max = bf_get(eq_pages, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11450 sli4_params->eqe_size = bf_get(eqe_size, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11451 sli4_params->cq_pages_max = bf_get(cq_pages, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11452 sli4_params->cqe_size = bf_get(cqe_size, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11453 sli4_params->mq_pages_max = bf_get(mq_pages, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11454 sli4_params->mqe_size = bf_get(mqe_size, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11455 sli4_params->mq_elem_cnt = bf_get(mq_elem_cnt, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11456 sli4_params->wq_pages_max = bf_get(wq_pages, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11457 sli4_params->wqe_size = bf_get(wqe_size, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11458 sli4_params->rq_pages_max = bf_get(rq_pages, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11459 sli4_params->rqe_size = bf_get(rqe_size, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11460 sli4_params->hdr_pages_max = bf_get(hdr_pages, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11461 sli4_params->hdr_size = bf_get(hdr_size, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11462 sli4_params->hdr_pp_align = bf_get(hdr_pp_align, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11463 sli4_params->sgl_pages_max = bf_get(sgl_pages, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11464 sli4_params->sgl_pp_align = bf_get(sgl_pp_align, &mqe->un.sli4_params); in lpfc_pc_sli4_params_get()
11467 if (sli4_params->sge_supp_len > LPFC_MAX_SGE_SIZE) in lpfc_pc_sli4_params_get()
11468 sli4_params->sge_supp_len = LPFC_MAX_SGE_SIZE; in lpfc_pc_sli4_params_get()
11474 * lpfc_get_sli4_parameters - Get the SLI4 Config PARAMETERS.
11481 * This function may be be called from any context that can block-wait
11489 struct lpfc_mqe *mqe = &mboxq->u.mqe; in lpfc_get_sli4_parameters()
11501 phba->sli4_hba.rpi_hdrs_in_use = 1; in lpfc_get_sli4_parameters()
11504 length = (sizeof(struct lpfc_mbx_get_sli4_parameters) - in lpfc_get_sli4_parameters()
11509 if (!phba->sli4_hba.intr_enable) in lpfc_get_sli4_parameters()
11517 sli4_params = &phba->sli4_hba.pc_sli4_params; in lpfc_get_sli4_parameters()
11518 mbx_sli4_parameters = &mqe->un.get_sli4_parameters.sli4_parameters; in lpfc_get_sli4_parameters()
11519 sli4_params->if_type = bf_get(cfg_if_type, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11520 sli4_params->sli_rev = bf_get(cfg_sli_rev, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11521 sli4_params->sli_family = bf_get(cfg_sli_family, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11522 sli4_params->featurelevel_1 = bf_get(cfg_sli_hint_1, in lpfc_get_sli4_parameters()
11524 sli4_params->featurelevel_2 = bf_get(cfg_sli_hint_2, in lpfc_get_sli4_parameters()
11527 phba->sli3_options |= LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
11529 phba->sli3_options &= ~LPFC_SLI4_PHWQ_ENABLED; in lpfc_get_sli4_parameters()
11530 sli4_params->sge_supp_len = mbx_sli4_parameters->sge_supp_len; in lpfc_get_sli4_parameters()
11531 sli4_params->loopbk_scope = bf_get(loopbk_scope, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11532 sli4_params->oas_supported = bf_get(cfg_oas, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11533 sli4_params->cqv = bf_get(cfg_cqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11534 sli4_params->mqv = bf_get(cfg_mqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11535 sli4_params->wqv = bf_get(cfg_wqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11536 sli4_params->rqv = bf_get(cfg_rqv, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11537 sli4_params->eqav = bf_get(cfg_eqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11538 sli4_params->cqav = bf_get(cfg_cqav, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11539 sli4_params->wqsize = bf_get(cfg_wqsize, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11540 sli4_params->bv1s = bf_get(cfg_bv1s, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11541 sli4_params->sgl_pages_max = bf_get(cfg_sgl_page_cnt, in lpfc_get_sli4_parameters()
11543 sli4_params->wqpcnt = bf_get(cfg_wqpcnt, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11544 sli4_params->sgl_pp_align = bf_get(cfg_sgl_pp_align, in lpfc_get_sli4_parameters()
11546 phba->sli4_hba.extents_in_use = bf_get(cfg_ext, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11547 phba->sli4_hba.rpi_hdrs_in_use = bf_get(cfg_hdrr, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11549 /* Check for Extended Pre-Registered SGL support */ in lpfc_get_sli4_parameters()
11550 phba->cfg_xpsgl = bf_get(cfg_xpsgl, mbx_sli4_parameters); in lpfc_get_sli4_parameters()
11558 sli4_params->nvme = 1; in lpfc_get_sli4_parameters()
11561 if (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP) { in lpfc_get_sli4_parameters()
11565 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
11570 sli4_params->nvme = 0; in lpfc_get_sli4_parameters()
11571 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_get_sli4_parameters()
11577 phba->cfg_enable_fc4_type); in lpfc_get_sli4_parameters()
11579 phba->nvme_support = 0; in lpfc_get_sli4_parameters()
11580 phba->nvmet_support = 0; in lpfc_get_sli4_parameters()
11581 phba->cfg_nvmet_mrq = 0; in lpfc_get_sli4_parameters()
11582 phba->cfg_nvme_seg_cnt = 0; in lpfc_get_sli4_parameters()
11585 if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_FCP)) in lpfc_get_sli4_parameters()
11586 return -ENODEV; in lpfc_get_sli4_parameters()
11587 phba->cfg_enable_fc4_type = LPFC_ENABLE_FCP; in lpfc_get_sli4_parameters()
11595 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_get_sli4_parameters()
11596 phba->cfg_sg_seg_cnt = LPFC_MAX_NVME_SEG_CNT; in lpfc_get_sli4_parameters()
11597 phba->cfg_iocb_cnt = 5; in lpfc_get_sli4_parameters()
11601 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) != in lpfc_get_sli4_parameters()
11603 phba->cfg_enable_pbde = 0; in lpfc_get_sli4_parameters()
11608 * In SLI4-Parameters Descriptor: in lpfc_get_sli4_parameters()
11613 if (phba->cfg_suppress_rsp && bf_get(cfg_xib, mbx_sli4_parameters) && in lpfc_get_sli4_parameters()
11615 phba->sli.sli_flag |= LPFC_SLI_SUPPRESS_RSP; in lpfc_get_sli4_parameters()
11617 phba->cfg_suppress_rsp = 0; in lpfc_get_sli4_parameters()
11620 phba->sli.sli_flag |= LPFC_SLI_USE_EQDR; in lpfc_get_sli4_parameters()
11623 if (sli4_params->sge_supp_len > LPFC_MAX_SGE_SIZE) in lpfc_get_sli4_parameters()
11624 sli4_params->sge_supp_len = LPFC_MAX_SGE_SIZE; in lpfc_get_sli4_parameters()
11629 * to use this option, 128-byte WQEs must be used. in lpfc_get_sli4_parameters()
11632 phba->fcp_embed_io = 1; in lpfc_get_sli4_parameters()
11634 phba->fcp_embed_io = 0; in lpfc_get_sli4_parameters()
11639 phba->cfg_enable_pbde, in lpfc_get_sli4_parameters()
11640 phba->fcp_embed_io, phba->nvme_support, in lpfc_get_sli4_parameters()
11641 phba->cfg_nvme_embed_cmd, phba->cfg_suppress_rsp); in lpfc_get_sli4_parameters()
11643 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
11645 (bf_get(lpfc_sli_intf_sli_family, &phba->sli4_hba.sli_intf) == in lpfc_get_sli4_parameters()
11652 (sli4_params->wqsize & LPFC_WQ_SZ128_SUPPORT)) in lpfc_get_sli4_parameters()
11653 phba->enab_exp_wqcq_pages = 1; in lpfc_get_sli4_parameters()
11655 phba->enab_exp_wqcq_pages = 0; in lpfc_get_sli4_parameters()
11660 phba->mds_diags_support = 1; in lpfc_get_sli4_parameters()
11662 phba->mds_diags_support = 0; in lpfc_get_sli4_parameters()
11668 phba->nsler = 1; in lpfc_get_sli4_parameters()
11670 phba->nsler = 0; in lpfc_get_sli4_parameters()
11676 * lpfc_pci_probe_one_s3 - PCI probe func to reg SLI-3 device to PCI subsystem.
11680 * This routine is to be called to attach a device with SLI-3 interface spec
11681 * to the PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
11682 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
11689 * 0 - driver can claim the device
11690 * negative value - driver can not claim the device
11704 return -ENOMEM; in lpfc_pci_probe_one_s3()
11711 /* Set up SLI API function jump table for PCI-device group-0 HBAs */ in lpfc_pci_probe_one_s3()
11716 /* Set up SLI-3 specific device PCI memory space */ in lpfc_pci_probe_one_s3()
11724 /* Set up SLI-3 specific device driver resources */ in lpfc_pci_probe_one_s3()
11750 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s3()
11761 vport = phba->pport; in lpfc_pci_probe_one_s3()
11771 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s3()
11780 error = -ENODEV; in lpfc_pci_probe_one_s3()
11783 /* SLI-3 HBA setup */ in lpfc_pci_probe_one_s3()
11787 error = -ENODEV; in lpfc_pci_probe_one_s3()
11795 phba->sli.slistat.sli_intr > LPFC_MSIX_VECTORS) { in lpfc_pci_probe_one_s3()
11797 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s3()
11808 cfg_mode = --intr_mode; in lpfc_pci_probe_one_s3()
11844 * lpfc_pci_remove_one_s3 - PCI func to unreg SLI-3 device from PCI subsystem.
11847 * This routine is to be called to disattach a device with SLI-3 interface
11848 * spec from PCI subsystem. When an Emulex HBA with SLI-3 interface spec is
11856 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s3()
11858 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s3()
11861 spin_lock_irq(&phba->hbalock); in lpfc_pci_remove_one_s3()
11862 vport->load_flag |= FC_UNLOADING; in lpfc_pci_remove_one_s3()
11863 spin_unlock_irq(&phba->hbalock); in lpfc_pci_remove_one_s3()
11870 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s3()
11871 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s3()
11873 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s3()
11892 kthread_stop(phba->worker_thread); in lpfc_pci_remove_one_s3()
11896 kfree(phba->vpi_bmask); in lpfc_pci_remove_one_s3()
11897 kfree(phba->vpi_ids); in lpfc_pci_remove_one_s3()
11900 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
11901 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s3()
11902 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s3()
11906 /* Disable SR-IOV if enabled */ in lpfc_pci_remove_one_s3()
11907 if (phba->cfg_sriov_nr_virtfn) in lpfc_pci_remove_one_s3()
11924 dma_free_coherent(&pdev->dev, lpfc_sli_hbq_size(), in lpfc_pci_remove_one_s3()
11925 phba->hbqslimp.virt, phba->hbqslimp.phys); in lpfc_pci_remove_one_s3()
11928 dma_free_coherent(&pdev->dev, SLI2_SLIM_SIZE, in lpfc_pci_remove_one_s3()
11929 phba->slim2p.virt, phba->slim2p.phys); in lpfc_pci_remove_one_s3()
11932 iounmap(phba->ctrl_regs_memmap_p); in lpfc_pci_remove_one_s3()
11933 iounmap(phba->slim_memmap_p); in lpfc_pci_remove_one_s3()
11942 * lpfc_pci_suspend_one_s3 - PCI func to suspend SLI-3 device for power mgmnt
11947 * system Power Management (PM) to device with SLI-3 interface spec. When
11951 * minimum PM requirements to a power-aware driver's PM support for the
11952 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
11959 * 0 - driver suspended the device
11966 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s3()
11974 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s3()
11987 * lpfc_pci_resume_one_s3 - PCI func to resume SLI-3 device for power mgmnt
11991 * system Power Management (PM) to device with SLI-3 interface spec. When PM
11994 * driver implements the minimum PM requirements to a power-aware driver's
11995 * PM for suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE,
12002 * 0 - driver suspended the device
12009 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s3()
12026 if (pdev->is_busmaster) in lpfc_pci_resume_one_s3()
12030 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s3()
12031 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s3()
12032 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s3()
12033 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s3()
12041 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
12045 return -EIO; in lpfc_pci_resume_one_s3()
12047 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s3()
12054 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s3()
12060 * lpfc_sli_prep_dev_for_recover - Prepare SLI3 device for pci slot recover
12074 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli_prep_dev_for_recover()
12080 * lpfc_sli_prep_dev_for_reset - Prepare SLI3 device for pci slot reset
12107 pci_disable_device(phba->pcidev); in lpfc_sli_prep_dev_for_reset()
12111 * lpfc_sli_prep_dev_for_perm_failure - Prepare SLI3 dev for pci slot disable
12134 * lpfc_io_error_detected_s3 - Method for handling SLI-3 device PCI I/O error
12139 * device with SLI-3 interface spec. This function is called by the PCI
12147 * PCI_ERS_RESULT_CAN_RECOVER - can be recovered with reset_link
12148 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
12149 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
12155 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s3()
12159 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s3()
12180 * lpfc_io_slot_reset_s3 - Method for restarting PCI SLI-3 device from scratch.
12184 * device with SLI-3 interface spec. This is called after PCI bus has been
12185 * reset to restart the PCI card from scratch, as if from a cold-boot.
12194 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
12195 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
12201 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s3()
12202 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s3()
12205 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s3()
12207 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s3()
12220 if (pdev->is_busmaster) in lpfc_io_slot_reset_s3()
12223 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
12224 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s3()
12225 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s3()
12228 intr_mode = lpfc_sli_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
12231 "0427 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s3()
12235 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s3()
12243 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s3()
12249 * lpfc_io_resume_s3 - Method for resuming PCI I/O operation on SLI-3 device.
12253 * with SLI-3 interface spec. It is called when kernel error recovery tells
12262 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s3()
12264 /* Bring device online, it will be no-op for non-fatal error resume */ in lpfc_io_resume_s3()
12269 * lpfc_sli4_get_els_iocb_cnt - Calculate the # of ELS IOCBs to reserve
12277 int max_xri = phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_get_els_iocb_cnt()
12279 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli4_get_els_iocb_cnt()
12299 * lpfc_sli4_get_iocb_cnt - Calculate the # of total IOCBs to reserve
12309 if (phba->nvmet_support) in lpfc_sli4_get_iocb_cnt()
12321 (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G6_FC && in lpfc_log_write_firmware_error()
12323 (phba->pcidev->device == PCI_DEVICE_ID_LANCER_G7_FC && in lpfc_log_write_firmware_error()
12329 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
12330 fsize, fw->size); in lpfc_log_write_firmware_error()
12335 phba->pcidev->device, magic_number, ftype, fid, in lpfc_log_write_firmware_error()
12336 fsize, fw->size); in lpfc_log_write_firmware_error()
12341 * lpfc_write_firmware - attempt to write a firmware image to the port
12358 /* It can be null in no-wait mode, sanity check */ in lpfc_write_firmware()
12360 rc = -ENXIO; in lpfc_write_firmware()
12363 image = (struct lpfc_grp_hdr *)fw->data; in lpfc_write_firmware()
12365 magic_number = be32_to_cpu(image->magic_number); in lpfc_write_firmware()
12368 fsize = be32_to_cpu(image->size); in lpfc_write_firmware()
12372 if (strncmp(fwrev, image->revision, strnlen(image->revision, 16))) { in lpfc_write_firmware()
12376 fwrev, image->revision); in lpfc_write_firmware()
12381 rc = -ENOMEM; in lpfc_write_firmware()
12384 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_write_firmware()
12386 &dmabuf->phys, in lpfc_write_firmware()
12388 if (!dmabuf->virt) { in lpfc_write_firmware()
12390 rc = -ENOMEM; in lpfc_write_firmware()
12393 list_add_tail(&dmabuf->list, &dma_buffer_list); in lpfc_write_firmware()
12395 while (offset < fw->size) { in lpfc_write_firmware()
12398 if (temp_offset + SLI4_PAGE_SIZE > fw->size) { in lpfc_write_firmware()
12399 memcpy(dmabuf->virt, in lpfc_write_firmware()
12400 fw->data + temp_offset, in lpfc_write_firmware()
12401 fw->size - temp_offset); in lpfc_write_firmware()
12402 temp_offset = fw->size; in lpfc_write_firmware()
12405 memcpy(dmabuf->virt, fw->data + temp_offset, in lpfc_write_firmware()
12410 (fw->size - offset), &offset); in lpfc_write_firmware()
12422 fwrev, image->revision); in lpfc_write_firmware()
12426 list_del(&dmabuf->list); in lpfc_write_firmware()
12427 dma_free_coherent(&phba->pcidev->dev, SLI4_PAGE_SIZE, in lpfc_write_firmware()
12428 dmabuf->virt, dmabuf->phys); in lpfc_write_firmware()
12439 * lpfc_sli4_request_firmware_update - Request linux generic firmware upgrade
12453 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) < in lpfc_sli4_request_firmware_update()
12455 return -EPERM; in lpfc_sli4_request_firmware_update()
12457 snprintf(file_name, ELX_MODEL_NAME_SIZE, "%s.grp", phba->ModelName); in lpfc_sli4_request_firmware_update()
12461 file_name, &phba->pcidev->dev, in lpfc_sli4_request_firmware_update()
12465 ret = request_firmware(&fw, file_name, &phba->pcidev->dev); in lpfc_sli4_request_firmware_update()
12469 ret = -EINVAL; in lpfc_sli4_request_firmware_update()
12476 * lpfc_pci_probe_one_s4 - PCI probe func to reg SLI-4 device to PCI subsys
12481 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
12482 * presented on PCI bus, the kernel PCI subsystem looks at PCI device-specific
12490 * 0 - driver can claim the device
12491 * negative value - driver can not claim the device
12505 return -ENOMEM; in lpfc_pci_probe_one_s4()
12512 /* Set up SLI API function jump table for PCI-device group-1 HBAs */ in lpfc_pci_probe_one_s4()
12517 /* Set up SLI-4 specific device PCI memory space */ in lpfc_pci_probe_one_s4()
12525 /* Set up SLI-4 Specific device driver resources */ in lpfc_pci_probe_one_s4()
12533 INIT_LIST_HEAD(&phba->active_rrq_list); in lpfc_pci_probe_one_s4()
12534 INIT_LIST_HEAD(&phba->fcf.fcf_pri_list); in lpfc_pci_probe_one_s4()
12545 lpfc_get_hba_model_desc(phba, phba->ModelName, phba->ModelDesc); in lpfc_pci_probe_one_s4()
12548 cfg_mode = phba->cfg_use_msi; in lpfc_pci_probe_one_s4()
12551 phba->pport = NULL; in lpfc_pci_probe_one_s4()
12559 error = -ENODEV; in lpfc_pci_probe_one_s4()
12562 /* Default to single EQ for non-MSI-X */ in lpfc_pci_probe_one_s4()
12563 if (phba->intr_type != MSIX) { in lpfc_pci_probe_one_s4()
12564 phba->cfg_irq_chann = 1; in lpfc_pci_probe_one_s4()
12565 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
12566 if (phba->nvmet_support) in lpfc_pci_probe_one_s4()
12567 phba->cfg_nvmet_mrq = 1; in lpfc_pci_probe_one_s4()
12570 lpfc_cpu_affinity_check(phba, phba->cfg_irq_chann); in lpfc_pci_probe_one_s4()
12579 vport = phba->pport; in lpfc_pci_probe_one_s4()
12590 /* Set up SLI-4 HBA */ in lpfc_pci_probe_one_s4()
12594 error = -ENODEV; in lpfc_pci_probe_one_s4()
12599 phba->intr_mode = intr_mode; in lpfc_pci_probe_one_s4()
12608 if (phba->nvmet_support == 0) { in lpfc_pci_probe_one_s4()
12609 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_pci_probe_one_s4()
12626 if (phba->cfg_request_firmware_upgrade) in lpfc_pci_probe_one_s4()
12659 * lpfc_pci_remove_one_s4 - PCI func to unreg SLI-4 device from PCI subsystem
12663 * SLI-4 interface spec. When an Emulex HBA with SLI-4 interface spec is
12671 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; in lpfc_pci_remove_one_s4()
12673 struct lpfc_hba *phba = vport->phba; in lpfc_pci_remove_one_s4()
12677 spin_lock_irq(&phba->hbalock); in lpfc_pci_remove_one_s4()
12678 vport->load_flag |= FC_UNLOADING; in lpfc_pci_remove_one_s4()
12679 spin_unlock_irq(&phba->hbalock); in lpfc_pci_remove_one_s4()
12687 for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { in lpfc_pci_remove_one_s4()
12688 if (vports[i]->port_type == LPFC_PHYSICAL_PORT) in lpfc_pci_remove_one_s4()
12690 fc_vport_terminate(vports[i]->fc_vport); in lpfc_pci_remove_one_s4()
12705 /* De-allocate multi-XRI pools */ in lpfc_pci_remove_one_s4()
12706 if (phba->cfg_xri_rebalancing) in lpfc_pci_remove_one_s4()
12717 spin_lock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
12718 list_del_init(&vport->listentry); in lpfc_pci_remove_one_s4()
12719 spin_unlock_irq(&phba->port_list_lock); in lpfc_pci_remove_one_s4()
12745 * lpfc_pci_suspend_one_s4 - PCI func to suspend SLI-4 device for power mgmnt
12750 * Power Management (PM) to device with SLI-4 interface spec. When PM invokes
12754 * requirements to a power-aware driver's PM support for suspend/resume -- all
12762 * 0 - driver suspended the device
12769 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one_s4()
12777 kthread_stop(phba->worker_thread); in lpfc_pci_suspend_one_s4()
12791 * lpfc_pci_resume_one_s4 - PCI func to resume SLI-4 device for power mgmnt
12795 * Power Management (PM) to device with SLI-4 interface spac. When PM invokes
12798 * implements the minimum PM requirements to a power-aware driver's PM for
12799 * suspend/resume -- all the possible PM messages (SUSPEND, HIBERNATE, FREEZE)
12806 * 0 - driver suspended the device
12813 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one_s4()
12830 if (pdev->is_busmaster) in lpfc_pci_resume_one_s4()
12834 phba->worker_thread = kthread_run(lpfc_do_work, phba, in lpfc_pci_resume_one_s4()
12835 "lpfc_worker_%d", phba->brd_no); in lpfc_pci_resume_one_s4()
12836 if (IS_ERR(phba->worker_thread)) { in lpfc_pci_resume_one_s4()
12837 error = PTR_ERR(phba->worker_thread); in lpfc_pci_resume_one_s4()
12845 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
12849 return -EIO; in lpfc_pci_resume_one_s4()
12851 phba->intr_mode = intr_mode; in lpfc_pci_resume_one_s4()
12858 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_pci_resume_one_s4()
12864 * lpfc_sli4_prep_dev_for_recover - Prepare SLI4 device for pci slot recover
12877 * and let the SCSI mid-layer to retry them to recover. in lpfc_sli4_prep_dev_for_recover()
12883 * lpfc_sli4_prep_dev_for_reset - Prepare SLI4 device for pci slot reset
12911 pci_disable_device(phba->pcidev); in lpfc_sli4_prep_dev_for_reset()
12915 * lpfc_sli4_prep_dev_for_perm_failure - Prepare SLI4 dev for pci slot disable
12939 * lpfc_io_error_detected_s4 - Method for handling PCI I/O error to SLI-4 device
12944 * with SLI-4 interface spec. This function is called by the PCI subsystem
12951 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
12952 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
12958 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected_s4()
12962 /* Non-fatal error, prepare for recovery */ in lpfc_io_error_detected_s4()
12983 * lpfc_io_slot_reset_s4 - Method for restart PCI SLI-4 device from scratch
12987 * with SLI-4 interface spec. It is called after PCI bus has been reset to
12988 * restart the PCI card from scratch, as if from a cold-boot. During the
12997 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
12998 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
13004 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset_s4()
13005 struct lpfc_sli *psli = &phba->sli; in lpfc_io_slot_reset_s4()
13008 dev_printk(KERN_INFO, &pdev->dev, "recovering from a slot reset.\n"); in lpfc_io_slot_reset_s4()
13010 printk(KERN_ERR "lpfc: Cannot re-enable " in lpfc_io_slot_reset_s4()
13023 if (pdev->is_busmaster) in lpfc_io_slot_reset_s4()
13026 spin_lock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
13027 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_io_slot_reset_s4()
13028 spin_unlock_irq(&phba->hbalock); in lpfc_io_slot_reset_s4()
13031 intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
13034 "2824 Cannot re-enable interrupt after " in lpfc_io_slot_reset_s4()
13038 phba->intr_mode = intr_mode; in lpfc_io_slot_reset_s4()
13041 lpfc_log_intr_mode(phba, phba->intr_mode); in lpfc_io_slot_reset_s4()
13047 * lpfc_io_resume_s4 - Method for resuming PCI I/O operation to SLI-4 device
13051 * with SLI-4 interface spec. It is called when kernel error recovery tells
13060 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume_s4()
13068 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) { in lpfc_io_resume_s4()
13079 * lpfc_pci_probe_one - lpfc PCI probe func to reg dev to PCI subsystem
13085 * at PCI device-specific information of the device and driver to see if the
13088 * the action to the proper SLI-3 or SLI-4 device probing routine, which will
13093 * 0 - driver can claim the device
13094 * negative value - driver can not claim the device
13103 return -ENODEV; in lpfc_pci_probe_one()
13115 * lpfc_pci_remove_one - lpfc PCI func to unreg dev from PCI subsystem
13120 * This routine dispatches the action to the proper SLI-3 or SLI-4 device
13128 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_remove_one()
13130 switch (phba->pci_dev_grp) { in lpfc_pci_remove_one()
13140 phba->pci_dev_grp); in lpfc_pci_remove_one()
13147 * lpfc_pci_suspend_one - lpfc PCI func to suspend dev for power management
13153 * the action to the proper SLI-3 or SLI-4 device suspend routine, which will
13157 * 0 - driver suspended the device
13164 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_suspend_one()
13165 int rc = -ENODEV; in lpfc_pci_suspend_one()
13167 switch (phba->pci_dev_grp) { in lpfc_pci_suspend_one()
13177 phba->pci_dev_grp); in lpfc_pci_suspend_one()
13184 * lpfc_pci_resume_one - lpfc PCI func to resume dev for power management
13189 * the action to the proper SLI-3 or SLI-4 device resume routine, which will
13193 * 0 - driver suspended the device
13200 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_pci_resume_one()
13201 int rc = -ENODEV; in lpfc_pci_resume_one()
13203 switch (phba->pci_dev_grp) { in lpfc_pci_resume_one()
13213 phba->pci_dev_grp); in lpfc_pci_resume_one()
13220 * lpfc_io_error_detected - lpfc method for handling PCI I/O error
13227 * the action to the proper SLI-3 or SLI-4 device error detected handling
13231 * PCI_ERS_RESULT_NEED_RESET - need to reset before recovery
13232 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
13238 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_error_detected()
13241 switch (phba->pci_dev_grp) { in lpfc_io_error_detected()
13251 phba->pci_dev_grp); in lpfc_io_error_detected()
13258 * lpfc_io_slot_reset - lpfc method for restart PCI dev from scratch
13263 * from scratch, as if from a cold-boot. When this routine is invoked, it
13264 * dispatches the action to the proper SLI-3 or SLI-4 device reset handling
13268 * PCI_ERS_RESULT_RECOVERED - the device has been recovered
13269 * PCI_ERS_RESULT_DISCONNECT - device could not be recovered
13275 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_slot_reset()
13278 switch (phba->pci_dev_grp) { in lpfc_io_slot_reset()
13288 phba->pci_dev_grp); in lpfc_io_slot_reset()
13295 * lpfc_io_resume - lpfc method for resuming PCI I/O operation
13301 * this routine is invoked, it dispatches the action to the proper SLI-3
13302 * or SLI-4 device io_resume routine, which will resume the device operation.
13308 struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; in lpfc_io_resume()
13310 switch (phba->pci_dev_grp) { in lpfc_io_resume()
13320 phba->pci_dev_grp); in lpfc_io_resume()
13327 * lpfc_sli4_oas_verify - Verify OAS is supported by this adapter
13340 if (!phba->cfg_EnableXLane) in lpfc_sli4_oas_verify()
13343 if (phba->sli4_hba.pc_sli4_params.oas_supported) { in lpfc_sli4_oas_verify()
13344 phba->cfg_fof = 1; in lpfc_sli4_oas_verify()
13346 phba->cfg_fof = 0; in lpfc_sli4_oas_verify()
13347 if (phba->device_data_mem_pool) in lpfc_sli4_oas_verify()
13348 mempool_destroy(phba->device_data_mem_pool); in lpfc_sli4_oas_verify()
13349 phba->device_data_mem_pool = NULL; in lpfc_sli4_oas_verify()
13356 * lpfc_sli4_ras_init - Verify RAS-FW log is supported by this adapter
13365 switch (phba->pcidev->device) { in lpfc_sli4_ras_init()
13368 phba->ras_fwlog.ras_hwsupport = true; in lpfc_sli4_ras_init()
13369 if (phba->cfg_ras_fwlog_func == PCI_FUNC(phba->pcidev->devfn) && in lpfc_sli4_ras_init()
13370 phba->cfg_ras_fwlog_buffsize) in lpfc_sli4_ras_init()
13371 phba->ras_fwlog.ras_enabled = true; in lpfc_sli4_ras_init()
13373 phba->ras_fwlog.ras_enabled = false; in lpfc_sli4_ras_init()
13376 phba->ras_fwlog.ras_hwsupport = false; in lpfc_sli4_ras_init()
13411 * lpfc_init - lpfc module initialization routine
13418 * 0 - successful
13419 * -ENOMEM - FC attach transport failed
13420 * all others - failed
13440 return -ENOMEM; in lpfc_init()
13445 return -ENOMEM; in lpfc_init()
13463 * lpfc_exit - lpfc module removal routine