Lines Matching +full:sub +full:- +full:mailbox

4  * Copyright (C) 2017-2021 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 *
47 * lpfc_dump_static_vport - Dump HBA's static vport information.
49 * @pmb: pointer to the driver internal queue element for mailbox command.
52 * The dump mailbox command provides a method for the device driver to obtain
55 * This routine prepares the mailbox command for dumping list of static
65 mb = &pmb->u.mb; in lpfc_dump_static_vport()
69 mb->mbxCommand = MBX_DUMP_MEMORY; in lpfc_dump_static_vport()
70 mb->un.varDmp.type = DMP_NV_PARAMS; in lpfc_dump_static_vport()
71 mb->un.varDmp.entry_index = offset; in lpfc_dump_static_vport()
72 mb->un.varDmp.region_id = DMP_REGION_VPORT; in lpfc_dump_static_vport()
73 mb->mbxOwner = OWN_HOST; in lpfc_dump_static_vport()
75 /* For SLI3 HBAs data is embedded in mailbox */ in lpfc_dump_static_vport()
76 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_dump_static_vport()
77 mb->un.varDmp.cv = 1; in lpfc_dump_static_vport()
78 mb->un.varDmp.word_cnt = DMP_RSP_SIZE/sizeof(uint32_t); in lpfc_dump_static_vport()
85 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); in lpfc_dump_static_vport()
87 if (!mp || !mp->virt) { in lpfc_dump_static_vport()
94 memset(mp->virt, 0, LPFC_BPL_SIZE); in lpfc_dump_static_vport()
95 INIT_LIST_HEAD(&mp->list); in lpfc_dump_static_vport()
97 pmb->ctx_buf = (uint8_t *)mp; in lpfc_dump_static_vport()
98 mb->un.varWords[3] = putPaddrLow(mp->phys); in lpfc_dump_static_vport()
99 mb->un.varWords[4] = putPaddrHigh(mp->phys); in lpfc_dump_static_vport()
100 mb->un.varDmp.sli4_length = sizeof(struct static_vport_info); in lpfc_dump_static_vport()
106 * lpfc_down_link - Bring down HBAs link.
108 * @pmb: pointer to the driver internal queue element for mailbox command.
110 * This routine prepares a mailbox command to bring down HBA link.
117 mb = &pmb->u.mb; in lpfc_down_link()
118 mb->mbxCommand = MBX_DOWN_LINK; in lpfc_down_link()
119 mb->mbxOwner = OWN_HOST; in lpfc_down_link()
123 * lpfc_dump_mem - Prepare a mailbox command for reading a region.
125 * @pmb: pointer to the driver internal queue element for mailbox command.
129 * The dump mailbox command provides a method for the device driver to obtain
132 * This routine prepares the mailbox command for dumping HBA's config region.
141 mb = &pmb->u.mb; in lpfc_dump_mem()
142 ctx = pmb->ctx_buf; in lpfc_dump_mem()
146 mb->mbxCommand = MBX_DUMP_MEMORY; in lpfc_dump_mem()
147 mb->un.varDmp.cv = 1; in lpfc_dump_mem()
148 mb->un.varDmp.type = DMP_NV_PARAMS; in lpfc_dump_mem()
149 mb->un.varDmp.entry_index = offset; in lpfc_dump_mem()
150 mb->un.varDmp.region_id = region_id; in lpfc_dump_mem()
151 mb->un.varDmp.word_cnt = (DMP_RSP_SIZE / sizeof (uint32_t)); in lpfc_dump_mem()
152 mb->un.varDmp.co = 0; in lpfc_dump_mem()
153 mb->un.varDmp.resp_offset = 0; in lpfc_dump_mem()
154 pmb->ctx_buf = ctx; in lpfc_dump_mem()
155 mb->mbxOwner = OWN_HOST; in lpfc_dump_mem()
160 * lpfc_dump_wakeup_param - Prepare mailbox command for retrieving wakeup params
162 * @pmb: pointer to the driver internal queue element for mailbox command.
164 * This function create a dump memory mailbox command to dump wake up
173 mb = &pmb->u.mb; in lpfc_dump_wakeup_param()
175 ctx = pmb->ctx_buf; in lpfc_dump_wakeup_param()
179 mb->mbxCommand = MBX_DUMP_MEMORY; in lpfc_dump_wakeup_param()
180 mb->mbxOwner = OWN_HOST; in lpfc_dump_wakeup_param()
181 mb->un.varDmp.cv = 1; in lpfc_dump_wakeup_param()
182 mb->un.varDmp.type = DMP_NV_PARAMS; in lpfc_dump_wakeup_param()
183 if (phba->sli_rev < LPFC_SLI_REV4) in lpfc_dump_wakeup_param()
184 mb->un.varDmp.entry_index = 0; in lpfc_dump_wakeup_param()
185 mb->un.varDmp.region_id = WAKE_UP_PARMS_REGION_ID; in lpfc_dump_wakeup_param()
186 mb->un.varDmp.word_cnt = WAKE_UP_PARMS_WORD_SIZE; in lpfc_dump_wakeup_param()
187 mb->un.varDmp.co = 0; in lpfc_dump_wakeup_param()
188 mb->un.varDmp.resp_offset = 0; in lpfc_dump_wakeup_param()
189 pmb->ctx_buf = ctx; in lpfc_dump_wakeup_param()
194 * lpfc_read_nv - Prepare a mailbox command for reading HBA's NVRAM param
196 * @pmb: pointer to the driver internal queue element for mailbox command.
198 * The read NVRAM mailbox command returns the HBA's non-volatile parameters
199 * that are used as defaults when the Fibre Channel link is brought on-line.
201 * This routine prepares the mailbox command for reading information stored
209 mb = &pmb->u.mb; in lpfc_read_nv()
211 mb->mbxCommand = MBX_READ_NV; in lpfc_read_nv()
212 mb->mbxOwner = OWN_HOST; in lpfc_read_nv()
217 * lpfc_config_async - Prepare a mailbox command for enabling HBA async event
219 * @pmb: pointer to the driver internal queue element for mailbox command.
222 * The asynchronous event enable mailbox command is used to enable the
226 * This routine prepares the mailbox command for enabling HBA asynchronous
235 mb = &pmb->u.mb; in lpfc_config_async()
237 mb->mbxCommand = MBX_ASYNCEVT_ENABLE; in lpfc_config_async()
238 mb->un.varCfgAsyncEvent.ring = ring; in lpfc_config_async()
239 mb->mbxOwner = OWN_HOST; in lpfc_config_async()
244 * lpfc_heart_beat - Prepare a mailbox command for heart beat
246 * @pmb: pointer to the driver internal queue element for mailbox command.
248 * The heart beat mailbox command is used to detect an unresponsive HBA, which
249 * is defined as any device where no error attention is sent and both mailbox
252 * This routine prepares the mailbox command for issuing a heart beat in the
253 * form of mailbox command to the HBA. The timely completion of the heart
254 * beat mailbox command indicates the health of the HBA.
261 mb = &pmb->u.mb; in lpfc_heart_beat()
263 mb->mbxCommand = MBX_HEARTBEAT; in lpfc_heart_beat()
264 mb->mbxOwner = OWN_HOST; in lpfc_heart_beat()
269 * lpfc_read_topology - Prepare a mailbox command for reading HBA topology
271 * @pmb: pointer to the driver internal queue element for mailbox command.
274 * The read topology mailbox command is issued to read the link topology
276 * Attention (HSTATT) register is set to 1 (For SLI-3) or when an FC Link
277 * Attention ACQE is received from the port (For SLI-4). A Link Event
281 * This routine prepares the mailbox command for reading HBA link topology
284 * memory as part of the execution of the mailbox command.
287 * 0 - Success (currently always return 0)
295 mb = &pmb->u.mb; in lpfc_read_topology()
298 INIT_LIST_HEAD(&mp->list); in lpfc_read_topology()
299 mb->mbxCommand = MBX_READ_TOPOLOGY; in lpfc_read_topology()
300 mb->un.varReadTop.lilpBde64.tus.f.bdeSize = LPFC_ALPA_MAP_SIZE; in lpfc_read_topology()
301 mb->un.varReadTop.lilpBde64.addrHigh = putPaddrHigh(mp->phys); in lpfc_read_topology()
302 mb->un.varReadTop.lilpBde64.addrLow = putPaddrLow(mp->phys); in lpfc_read_topology()
305 * the FW knows this mailbox is available for processing. in lpfc_read_topology()
307 pmb->ctx_buf = (uint8_t *)mp; in lpfc_read_topology()
308 mb->mbxOwner = OWN_HOST; in lpfc_read_topology()
313 * lpfc_clear_la - Prepare a mailbox command for clearing HBA link attention
315 * @pmb: pointer to the driver internal queue element for mailbox command.
317 * The clear link attention mailbox command is issued to clear the link event
321 * The current event tag is read using the read link attention event mailbox
324 * This routine prepares the mailbox command for clearing HBA link attention
332 mb = &pmb->u.mb; in lpfc_clear_la()
335 mb->un.varClearLA.eventTag = phba->fc_eventTag; in lpfc_clear_la()
336 mb->mbxCommand = MBX_CLEAR_LA; in lpfc_clear_la()
337 mb->mbxOwner = OWN_HOST; in lpfc_clear_la()
342 * lpfc_config_link - Prepare a mailbox command for configuring link on a HBA
344 * @pmb: pointer to the driver internal queue element for mailbox command.
346 * The configure link mailbox command is used before the initialize link
347 * mailbox command to override default value and to configure link-oriented
353 * This routine prepares the mailbox command for configuring link on a HBA.
358 struct lpfc_vport *vport = phba->pport; in lpfc_config_link()
359 MAILBOX_t *mb = &pmb->u.mb; in lpfc_config_link()
363 * SLI-2, Coalescing Response Feature. in lpfc_config_link()
365 if (phba->cfg_cr_delay && (phba->sli_rev < LPFC_SLI_REV4)) { in lpfc_config_link()
366 mb->un.varCfgLnk.cr = 1; in lpfc_config_link()
367 mb->un.varCfgLnk.ci = 1; in lpfc_config_link()
368 mb->un.varCfgLnk.cr_delay = phba->cfg_cr_delay; in lpfc_config_link()
369 mb->un.varCfgLnk.cr_count = phba->cfg_cr_count; in lpfc_config_link()
372 mb->un.varCfgLnk.myId = vport->fc_myDID; in lpfc_config_link()
373 mb->un.varCfgLnk.edtov = phba->fc_edtov; in lpfc_config_link()
374 mb->un.varCfgLnk.arbtov = phba->fc_arbtov; in lpfc_config_link()
375 mb->un.varCfgLnk.ratov = phba->fc_ratov; in lpfc_config_link()
376 mb->un.varCfgLnk.rttov = phba->fc_rttov; in lpfc_config_link()
377 mb->un.varCfgLnk.altov = phba->fc_altov; in lpfc_config_link()
378 mb->un.varCfgLnk.crtov = phba->fc_crtov; in lpfc_config_link()
379 mb->un.varCfgLnk.cscn = 0; in lpfc_config_link()
380 if (phba->bbcredit_support && phba->cfg_enable_bbcr) { in lpfc_config_link()
381 mb->un.varCfgLnk.cscn = 1; in lpfc_config_link()
382 mb->un.varCfgLnk.bbscn = bf_get(lpfc_bbscn_def, in lpfc_config_link()
383 &phba->sli4_hba.bbscn_params); in lpfc_config_link()
386 if (phba->cfg_ack0 && (phba->sli_rev < LPFC_SLI_REV4)) in lpfc_config_link()
387 mb->un.varCfgLnk.ack0_enable = 1; in lpfc_config_link()
389 mb->mbxCommand = MBX_CONFIG_LINK; in lpfc_config_link()
390 mb->mbxOwner = OWN_HOST; in lpfc_config_link()
395 * lpfc_config_msi - Prepare a mailbox command for configuring msi-x
397 * @pmb: pointer to the driver internal queue element for mailbox command.
399 * The configure MSI-X mailbox command is used to configure the HBA's SLI-3
400 * MSI-X multi-message interrupt vector association to interrupt attention
404 * 0 - Success
405 * -EINVAL - Failure
410 MAILBOX_t *mb = &pmb->u.mb; in lpfc_config_msi()
414 if (phba->cfg_use_msi != 2) { in lpfc_config_msi()
416 "0475 Not configured for supporting MSI-X " in lpfc_config_msi()
417 "cfg_use_msi: 0x%x\n", phba->cfg_use_msi); in lpfc_config_msi()
418 return -EINVAL; in lpfc_config_msi()
421 if (phba->sli_rev < 3) { in lpfc_config_msi()
423 "0476 HBA not supporting SLI-3 or later " in lpfc_config_msi()
424 "SLI Revision: 0x%x\n", phba->sli_rev); in lpfc_config_msi()
425 return -EINVAL; in lpfc_config_msi()
428 /* Clear mailbox command fields */ in lpfc_config_msi()
432 * SLI-3, Message Signaled Interrupt Fearure. in lpfc_config_msi()
435 /* Multi-message attention configuration */ in lpfc_config_msi()
440 mb->un.varCfgMSI.attentionConditions[0] = attentionConditions[0]; in lpfc_config_msi()
441 mb->un.varCfgMSI.attentionConditions[1] = attentionConditions[1]; in lpfc_config_msi()
448 mb->un.varCfgMSI.messageNumberByHA[HA_R0_POS] = 1; in lpfc_config_msi()
450 mb->un.varCfgMSI.messageNumberByHA[HA_R1_POS] = 1; in lpfc_config_msi()
453 mb->un.varCfgMSI.messageNumberByHA[HA_R0_POS^3] = 1; in lpfc_config_msi()
455 mb->un.varCfgMSI.messageNumberByHA[HA_R1_POS^3] = 1; in lpfc_config_msi()
457 /* Multi-message interrupt autoclear configuration*/ in lpfc_config_msi()
458 mb->un.varCfgMSI.autoClearHA[0] = attentionConditions[0]; in lpfc_config_msi()
459 mb->un.varCfgMSI.autoClearHA[1] = attentionConditions[1]; in lpfc_config_msi()
462 mb->un.varCfgMSI.autoClearHA[0] = 0; in lpfc_config_msi()
463 mb->un.varCfgMSI.autoClearHA[1] = 0; in lpfc_config_msi()
466 mb->mbxCommand = MBX_CONFIG_MSI; in lpfc_config_msi()
467 mb->mbxOwner = OWN_HOST; in lpfc_config_msi()
473 * lpfc_init_link - Prepare a mailbox command for initialize link on a HBA
475 * @pmb: pointer to the driver internal queue element for mailbox command.
479 * The initialize link mailbox command is used to initialize the Fibre
483 * This routine prepares the mailbox command for initializing link on a HBA
493 mb = &pmb->u.mb; in lpfc_init_link()
498 mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_LOOP; in lpfc_init_link()
499 mb->un.varInitLnk.link_flags |= FLAGS_TOPOLOGY_FAILOVER; in lpfc_init_link()
502 mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_PT_PT; in lpfc_init_link()
505 mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_LOOP; in lpfc_init_link()
508 mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_PT_PT; in lpfc_init_link()
509 mb->un.varInitLnk.link_flags |= FLAGS_TOPOLOGY_FAILOVER; in lpfc_init_link()
512 mb->un.varInitLnk.link_flags = FLAGS_LOCAL_LB; in lpfc_init_link()
517 if ((phba->sli4_hba.pc_sli4_params.sli_family == LPFC_SLI_INTF_FAMILY_G6 || in lpfc_init_link()
518 phba->sli4_hba.pc_sli4_params.if_type == LPFC_SLI_INTF_IF_TYPE_6) && in lpfc_init_link()
519 !(phba->sli4_hba.pc_sli4_params.pls) && in lpfc_init_link()
520 mb->un.varInitLnk.link_flags & FLAGS_TOPOLOGY_MODE_LOOP) { in lpfc_init_link()
521 mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_PT_PT; in lpfc_init_link()
522 phba->cfg_topology = FLAGS_TOPOLOGY_MODE_PT_PT; in lpfc_init_link()
526 if (phba->sli_rev == LPFC_SLI_REV3 && !phba->cfg_fcp_wait_abts_rsp) in lpfc_init_link()
527 mb->un.varInitLnk.link_flags |= FLAGS_IMED_ABORT; in lpfc_init_link()
532 vpd = &phba->vpd; in lpfc_init_link()
533 if (vpd->rev.feaLevelHigh >= 0x02){ in lpfc_init_link()
536 mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED; in lpfc_init_link()
537 mb->un.varInitLnk.link_speed = LINK_SPEED_1G; in lpfc_init_link()
540 mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED; in lpfc_init_link()
541 mb->un.varInitLnk.link_speed = LINK_SPEED_2G; in lpfc_init_link()
544 mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED; in lpfc_init_link()
545 mb->un.varInitLnk.link_speed = LINK_SPEED_4G; in lpfc_init_link()
548 mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED; in lpfc_init_link()
549 mb->un.varInitLnk.link_speed = LINK_SPEED_8G; in lpfc_init_link()
552 mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED; in lpfc_init_link()
553 mb->un.varInitLnk.link_speed = LINK_SPEED_10G; in lpfc_init_link()
556 mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED; in lpfc_init_link()
557 mb->un.varInitLnk.link_speed = LINK_SPEED_16G; in lpfc_init_link()
560 mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED; in lpfc_init_link()
561 mb->un.varInitLnk.link_speed = LINK_SPEED_32G; in lpfc_init_link()
564 mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED; in lpfc_init_link()
565 mb->un.varInitLnk.link_speed = LINK_SPEED_64G; in lpfc_init_link()
569 mb->un.varInitLnk.link_speed = LINK_SPEED_AUTO; in lpfc_init_link()
575 mb->un.varInitLnk.link_speed = LINK_SPEED_AUTO; in lpfc_init_link()
577 mb->mbxCommand = (volatile uint8_t)MBX_INIT_LINK; in lpfc_init_link()
578 mb->mbxOwner = OWN_HOST; in lpfc_init_link()
579 mb->un.varInitLnk.fabric_AL_PA = phba->fc_pref_ALPA; in lpfc_init_link()
584 * lpfc_read_sparam - Prepare a mailbox command for reading HBA parameters
586 * @pmb: pointer to the driver internal queue element for mailbox command.
589 * The read service parameter mailbox command is used to read the HBA port
591 * specified directly by a BDE in the mailbox command. These service
595 * This routine prepares the mailbox command for reading HBA port service
597 * are populated into the mailbox command for the HBA to DMA the service
601 * 0 - Success
602 * 1 - DMA memory allocation failed
610 mb = &pmb->u.mb; in lpfc_read_sparam()
613 mb->mbxOwner = OWN_HOST; in lpfc_read_sparam()
619 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); in lpfc_read_sparam()
620 if (!mp || !mp->virt) { in lpfc_read_sparam()
622 mb->mbxCommand = MBX_READ_SPARM64; in lpfc_read_sparam()
628 INIT_LIST_HEAD(&mp->list); in lpfc_read_sparam()
629 mb->mbxCommand = MBX_READ_SPARM64; in lpfc_read_sparam()
630 mb->un.varRdSparm.un.sp64.tus.f.bdeSize = sizeof (struct serv_parm); in lpfc_read_sparam()
631 mb->un.varRdSparm.un.sp64.addrHigh = putPaddrHigh(mp->phys); in lpfc_read_sparam()
632 mb->un.varRdSparm.un.sp64.addrLow = putPaddrLow(mp->phys); in lpfc_read_sparam()
633 if (phba->sli_rev >= LPFC_SLI_REV3) in lpfc_read_sparam()
634 mb->un.varRdSparm.vpi = phba->vpi_ids[vpi]; in lpfc_read_sparam()
637 pmb->ctx_buf = mp; in lpfc_read_sparam()
643 * lpfc_unreg_did - Prepare a mailbox command for unregistering DID
647 * @pmb: pointer to the driver internal queue element for mailbox command.
649 * The unregister DID mailbox command is used to unregister an N_Port/F_Port
654 * This routine prepares the mailbox command for unregistering a remote
663 mb = &pmb->u.mb; in lpfc_unreg_did()
666 mb->un.varUnregDID.did = did; in lpfc_unreg_did()
667 mb->un.varUnregDID.vpi = vpi; in lpfc_unreg_did()
669 (phba->sli_rev == LPFC_SLI_REV4)) in lpfc_unreg_did()
670 mb->un.varUnregDID.vpi = phba->vpi_ids[vpi]; in lpfc_unreg_did()
672 mb->mbxCommand = MBX_UNREG_D_ID; in lpfc_unreg_did()
673 mb->mbxOwner = OWN_HOST; in lpfc_unreg_did()
678 * lpfc_read_config - Prepare a mailbox command for reading HBA configuration
680 * @pmb: pointer to the driver internal queue element for mailbox command.
682 * The read configuration mailbox command is used to read the HBA port
683 * configuration parameters. This mailbox command provides a method for
685 * mailbox commands.
687 * This routine prepares the mailbox command for reading out HBA configuration
695 mb = &pmb->u.mb; in lpfc_read_config()
698 mb->mbxCommand = MBX_READ_CONFIG; in lpfc_read_config()
699 mb->mbxOwner = OWN_HOST; in lpfc_read_config()
704 * lpfc_read_lnk_stat - Prepare a mailbox command for reading HBA link stats
706 * @pmb: pointer to the driver internal queue element for mailbox command.
708 * The read link status mailbox command is used to read the link status from
709 * the HBA. Link status includes all link-related error counters. These
713 * This routine prepares the mailbox command for reading out HBA link status.
720 mb = &pmb->u.mb; in lpfc_read_lnk_stat()
723 mb->mbxCommand = MBX_READ_LNK_STAT; in lpfc_read_lnk_stat()
724 mb->mbxOwner = OWN_HOST; in lpfc_read_lnk_stat()
729 * lpfc_reg_rpi - Prepare a mailbox command for registering remote login
734 * @pmb: pointer to the driver internal queue element for mailbox command.
737 * The registration login mailbox command is used to register an N_Port or
739 * service parameters internally and thereby make the appropriate FC-2
744 * This routine prepares the mailbox command for registering remote port login.
746 * HBA with the mailbox command.
749 * 0 - Success
750 * 1 - DMA memory allocation failed
756 MAILBOX_t *mb = &pmb->u.mb; in lpfc_reg_rpi()
762 mb->un.varRegLogin.rpi = 0; in lpfc_reg_rpi()
763 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_reg_rpi()
764 mb->un.varRegLogin.rpi = phba->sli4_hba.rpi_ids[rpi]; in lpfc_reg_rpi()
765 if (phba->sli_rev >= LPFC_SLI_REV3) in lpfc_reg_rpi()
766 mb->un.varRegLogin.vpi = phba->vpi_ids[vpi]; in lpfc_reg_rpi()
767 mb->un.varRegLogin.did = did; in lpfc_reg_rpi()
768 mb->mbxOwner = OWN_HOST; in lpfc_reg_rpi()
772 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); in lpfc_reg_rpi()
773 if (!mp || !mp->virt) { in lpfc_reg_rpi()
775 mb->mbxCommand = MBX_REG_LOGIN64; in lpfc_reg_rpi()
782 INIT_LIST_HEAD(&mp->list); in lpfc_reg_rpi()
783 sparam = mp->virt; in lpfc_reg_rpi()
789 pmb->ctx_buf = (uint8_t *)mp; in lpfc_reg_rpi()
791 mb->mbxCommand = MBX_REG_LOGIN64; in lpfc_reg_rpi()
792 mb->un.varRegLogin.un.sp64.tus.f.bdeSize = sizeof (struct serv_parm); in lpfc_reg_rpi()
793 mb->un.varRegLogin.un.sp64.addrHigh = putPaddrHigh(mp->phys); in lpfc_reg_rpi()
794 mb->un.varRegLogin.un.sp64.addrLow = putPaddrLow(mp->phys); in lpfc_reg_rpi()
800 * lpfc_unreg_login - Prepare a mailbox command for unregistering remote login
804 * @pmb: pointer to the driver internal queue element for mailbox command.
806 * The unregistration login mailbox command is used to unregister an N_Port
810 * This routine prepares the mailbox command for unregistering remote port
822 mb = &pmb->u.mb; in lpfc_unreg_login()
825 mb->un.varUnregLogin.rpi = rpi; in lpfc_unreg_login()
826 mb->un.varUnregLogin.rsvd1 = 0; in lpfc_unreg_login()
827 if (phba->sli_rev >= LPFC_SLI_REV3) in lpfc_unreg_login()
828 mb->un.varUnregLogin.vpi = phba->vpi_ids[vpi]; in lpfc_unreg_login()
830 mb->mbxCommand = MBX_UNREG_LOGIN; in lpfc_unreg_login()
831 mb->mbxOwner = OWN_HOST; in lpfc_unreg_login()
837 * lpfc_sli4_unreg_all_rpis - unregister all RPIs for a vport on SLI4 HBA.
840 * This routine sends mailbox command to unregister all active RPIs for
846 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_unreg_all_rpis()
850 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_unreg_all_rpis()
859 lpfc_unreg_login(phba, vport->vpi, phba->vpi_ids[vport->vpi], in lpfc_sli4_unreg_all_rpis()
861 mbox->u.mb.un.varUnregLogin.rsvd1 = 0x4000; in lpfc_sli4_unreg_all_rpis()
862 mbox->vport = vport; in lpfc_sli4_unreg_all_rpis()
863 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_sli4_unreg_all_rpis()
864 mbox->ctx_ndlp = NULL; in lpfc_sli4_unreg_all_rpis()
867 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_unreg_all_rpis()
872 * lpfc_reg_vpi - Prepare a mailbox command for registering vport identifier
874 * @pmb: pointer to the driver internal queue element for mailbox command.
876 * The registration vport identifier mailbox command is used to activate a
882 * This routine prepares the mailbox command for registering a virtual N_Port.
887 MAILBOX_t *mb = &pmb->u.mb; in lpfc_reg_vpi()
888 struct lpfc_hba *phba = vport->phba; in lpfc_reg_vpi()
892 * Set the re-reg VPI bit for f/w to update the MAC address. in lpfc_reg_vpi()
894 if ((phba->sli_rev == LPFC_SLI_REV4) && in lpfc_reg_vpi()
895 !(vport->fc_flag & FC_VPORT_NEEDS_REG_VPI)) in lpfc_reg_vpi()
896 mb->un.varRegVpi.upd = 1; in lpfc_reg_vpi()
898 mb->un.varRegVpi.vpi = phba->vpi_ids[vport->vpi]; in lpfc_reg_vpi()
899 mb->un.varRegVpi.sid = vport->fc_myDID; in lpfc_reg_vpi()
900 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_reg_vpi()
901 mb->un.varRegVpi.vfi = phba->sli4_hba.vfi_ids[vport->vfi]; in lpfc_reg_vpi()
903 mb->un.varRegVpi.vfi = vport->vfi + vport->phba->vfi_base; in lpfc_reg_vpi()
904 memcpy(mb->un.varRegVpi.wwn, &vport->fc_portname, in lpfc_reg_vpi()
906 mb->un.varRegVpi.wwn[0] = cpu_to_le32(mb->un.varRegVpi.wwn[0]); in lpfc_reg_vpi()
907 mb->un.varRegVpi.wwn[1] = cpu_to_le32(mb->un.varRegVpi.wwn[1]); in lpfc_reg_vpi()
909 mb->mbxCommand = MBX_REG_VPI; in lpfc_reg_vpi()
910 mb->mbxOwner = OWN_HOST; in lpfc_reg_vpi()
916 * lpfc_unreg_vpi - Prepare a mailbox command for unregistering vport id
919 * @pmb: pointer to the driver internal queue element for mailbox command.
921 * The unregistration vport identifier mailbox command is used to inactivate
925 * any active exchanges. The HBA will post the mailbox response after making
928 * This routine prepares the mailbox command for unregistering a virtual
934 MAILBOX_t *mb = &pmb->u.mb; in lpfc_unreg_vpi()
937 if (phba->sli_rev == LPFC_SLI_REV3) in lpfc_unreg_vpi()
938 mb->un.varUnregVpi.vpi = phba->vpi_ids[vpi]; in lpfc_unreg_vpi()
939 else if (phba->sli_rev >= LPFC_SLI_REV4) in lpfc_unreg_vpi()
940 mb->un.varUnregVpi.sli4_vpi = phba->vpi_ids[vpi]; in lpfc_unreg_vpi()
942 mb->mbxCommand = MBX_UNREG_VPI; in lpfc_unreg_vpi()
943 mb->mbxOwner = OWN_HOST; in lpfc_unreg_vpi()
949 * lpfc_config_pcb_setup - Set up IOCB rings in the Port Control Block (PCB)
958 struct lpfc_sli *psli = &phba->sli; in lpfc_config_pcb_setup()
960 PCB_t *pcbp = phba->pcb; in lpfc_config_pcb_setup()
966 pcbp->maxRing = (psli->num_rings - 1); in lpfc_config_pcb_setup()
968 for (i = 0; i < psli->num_rings; i++) { in lpfc_config_pcb_setup()
969 pring = &psli->sli3_ring[i]; in lpfc_config_pcb_setup()
971 pring->sli.sli3.sizeCiocb = in lpfc_config_pcb_setup()
972 phba->sli_rev == 3 ? SLI3_IOCB_CMD_SIZE : in lpfc_config_pcb_setup()
974 pring->sli.sli3.sizeRiocb = in lpfc_config_pcb_setup()
975 phba->sli_rev == 3 ? SLI3_IOCB_RSP_SIZE : in lpfc_config_pcb_setup()
979 if ((pring->sli.sli3.numCiocb == 0) || in lpfc_config_pcb_setup()
980 (pring->sli.sli3.numRiocb == 0)) { in lpfc_config_pcb_setup()
981 pcbp->rdsc[i].cmdEntries = 0; in lpfc_config_pcb_setup()
982 pcbp->rdsc[i].rspEntries = 0; in lpfc_config_pcb_setup()
983 pcbp->rdsc[i].cmdAddrHigh = 0; in lpfc_config_pcb_setup()
984 pcbp->rdsc[i].rspAddrHigh = 0; in lpfc_config_pcb_setup()
985 pcbp->rdsc[i].cmdAddrLow = 0; in lpfc_config_pcb_setup()
986 pcbp->rdsc[i].rspAddrLow = 0; in lpfc_config_pcb_setup()
987 pring->sli.sli3.cmdringaddr = NULL; in lpfc_config_pcb_setup()
988 pring->sli.sli3.rspringaddr = NULL; in lpfc_config_pcb_setup()
992 pring->sli.sli3.cmdringaddr = (void *)&phba->IOCBs[iocbCnt]; in lpfc_config_pcb_setup()
993 pcbp->rdsc[i].cmdEntries = pring->sli.sli3.numCiocb; in lpfc_config_pcb_setup()
995 offset = (uint8_t *) &phba->IOCBs[iocbCnt] - in lpfc_config_pcb_setup()
996 (uint8_t *) phba->slim2p.virt; in lpfc_config_pcb_setup()
997 pdma_addr = phba->slim2p.phys + offset; in lpfc_config_pcb_setup()
998 pcbp->rdsc[i].cmdAddrHigh = putPaddrHigh(pdma_addr); in lpfc_config_pcb_setup()
999 pcbp->rdsc[i].cmdAddrLow = putPaddrLow(pdma_addr); in lpfc_config_pcb_setup()
1000 iocbCnt += pring->sli.sli3.numCiocb; in lpfc_config_pcb_setup()
1003 pring->sli.sli3.rspringaddr = (void *) &phba->IOCBs[iocbCnt]; in lpfc_config_pcb_setup()
1005 pcbp->rdsc[i].rspEntries = pring->sli.sli3.numRiocb; in lpfc_config_pcb_setup()
1006 offset = (uint8_t *)&phba->IOCBs[iocbCnt] - in lpfc_config_pcb_setup()
1007 (uint8_t *)phba->slim2p.virt; in lpfc_config_pcb_setup()
1008 pdma_addr = phba->slim2p.phys + offset; in lpfc_config_pcb_setup()
1009 pcbp->rdsc[i].rspAddrHigh = putPaddrHigh(pdma_addr); in lpfc_config_pcb_setup()
1010 pcbp->rdsc[i].rspAddrLow = putPaddrLow(pdma_addr); in lpfc_config_pcb_setup()
1011 iocbCnt += pring->sli.sli3.numRiocb; in lpfc_config_pcb_setup()
1016 * lpfc_read_rev - Prepare a mailbox command for reading HBA revision
1018 * @pmb: pointer to the driver internal queue element for mailbox command.
1020 * The read revision mailbox command is used to read the revision levels of
1022 * firmware, and available firmware. HBAs that supports SLI-3 mode of
1026 * This routine prepares the mailbox command for reading HBA revision
1032 MAILBOX_t *mb = &pmb->u.mb; in lpfc_read_rev()
1034 mb->un.varRdRev.cv = 1; in lpfc_read_rev()
1035 mb->un.varRdRev.v3req = 1; /* Request SLI3 info */ in lpfc_read_rev()
1036 mb->mbxCommand = MBX_READ_REV; in lpfc_read_rev()
1037 mb->mbxOwner = OWN_HOST; in lpfc_read_rev()
1044 MAILBOX_t *mb = &pmb->u.mb; in lpfc_sli4_swap_str()
1047 switch (mb->mbxCommand) { in lpfc_sli4_swap_str()
1049 mqe = &pmb->u.mqe; in lpfc_sli4_swap_str()
1050 lpfc_sli_pcimem_bcopy(mqe->un.read_rev.fw_name, in lpfc_sli4_swap_str()
1051 mqe->un.read_rev.fw_name, 16); in lpfc_sli4_swap_str()
1052 lpfc_sli_pcimem_bcopy(mqe->un.read_rev.ulp_fw_name, in lpfc_sli4_swap_str()
1053 mqe->un.read_rev.ulp_fw_name, 16); in lpfc_sli4_swap_str()
1062 * lpfc_build_hbq_profile2 - Set up the HBQ Selection Profile 2
1063 * @hbqmb: pointer to the HBQ configuration data structure in mailbox command.
1075 hbqmb->profiles.profile2.seqlenbcnt = hbq_desc->seqlenbcnt; in lpfc_build_hbq_profile2()
1076 hbqmb->profiles.profile2.maxlen = hbq_desc->maxlen; in lpfc_build_hbq_profile2()
1077 hbqmb->profiles.profile2.seqlenoff = hbq_desc->seqlenoff; in lpfc_build_hbq_profile2()
1081 * lpfc_build_hbq_profile3 - Set up the HBQ Selection Profile 3
1082 * @hbqmb: pointer to the HBQ configuration data structure in mailbox command.
1094 hbqmb->profiles.profile3.seqlenbcnt = hbq_desc->seqlenbcnt; in lpfc_build_hbq_profile3()
1095 hbqmb->profiles.profile3.maxlen = hbq_desc->maxlen; in lpfc_build_hbq_profile3()
1096 hbqmb->profiles.profile3.cmdcodeoff = hbq_desc->cmdcodeoff; in lpfc_build_hbq_profile3()
1097 hbqmb->profiles.profile3.seqlenoff = hbq_desc->seqlenoff; in lpfc_build_hbq_profile3()
1098 memcpy(&hbqmb->profiles.profile3.cmdmatch, hbq_desc->cmdmatch, in lpfc_build_hbq_profile3()
1099 sizeof(hbqmb->profiles.profile3.cmdmatch)); in lpfc_build_hbq_profile3()
1103 * lpfc_build_hbq_profile5 - Set up the HBQ Selection Profile 5
1104 * @hbqmb: pointer to the HBQ configuration data structure in mailbox command.
1117 hbqmb->profiles.profile5.seqlenbcnt = hbq_desc->seqlenbcnt; in lpfc_build_hbq_profile5()
1118 hbqmb->profiles.profile5.maxlen = hbq_desc->maxlen; in lpfc_build_hbq_profile5()
1119 hbqmb->profiles.profile5.cmdcodeoff = hbq_desc->cmdcodeoff; in lpfc_build_hbq_profile5()
1120 hbqmb->profiles.profile5.seqlenoff = hbq_desc->seqlenoff; in lpfc_build_hbq_profile5()
1121 memcpy(&hbqmb->profiles.profile5.cmdmatch, hbq_desc->cmdmatch, in lpfc_build_hbq_profile5()
1122 sizeof(hbqmb->profiles.profile5.cmdmatch)); in lpfc_build_hbq_profile5()
1126 * lpfc_config_hbq - Prepare a mailbox command for configuring an HBQ
1131 * @pmb: pointer to the driver internal queue element for mailbox command.
1133 * The configure HBQ (Host Buffer Queue) mailbox command is used to configure
1137 * This routine prepares the mailbox command for configuring an HBQ.
1145 MAILBOX_t *mb = &pmb->u.mb; in lpfc_config_hbq()
1146 struct config_hbq_var *hbqmb = &mb->un.varCfgHbq; in lpfc_config_hbq()
1149 hbqmb->hbqId = id; in lpfc_config_hbq()
1150 hbqmb->entry_count = hbq_desc->entry_count; /* # entries in HBQ */ in lpfc_config_hbq()
1151 hbqmb->recvNotify = hbq_desc->rn; /* Receive in lpfc_config_hbq()
1153 hbqmb->numMask = hbq_desc->mask_count; /* # R_CTL/TYPE masks in lpfc_config_hbq()
1154 * # in words 0-19 */ in lpfc_config_hbq()
1155 hbqmb->profile = hbq_desc->profile; /* Selection profile: in lpfc_config_hbq()
1158 hbqmb->ringMask = hbq_desc->ring_mask; /* Binds HBQ to a ring in lpfc_config_hbq()
1161 hbqmb->headerLen = hbq_desc->headerLen; /* 0 if not profile 4 in lpfc_config_hbq()
1163 hbqmb->logEntry = hbq_desc->logEntry; /* Set to 1 if this in lpfc_config_hbq()
1167 hbqmb->hbqaddrLow = putPaddrLow(phba->hbqslimp.phys) + in lpfc_config_hbq()
1169 hbqmb->hbqaddrHigh = putPaddrHigh(phba->hbqslimp.phys); in lpfc_config_hbq()
1171 mb->mbxCommand = MBX_CONFIG_HBQ; in lpfc_config_hbq()
1172 mb->mbxOwner = OWN_HOST; in lpfc_config_hbq()
1177 if (hbq_desc->profile == 2) in lpfc_config_hbq()
1179 else if (hbq_desc->profile == 3) in lpfc_config_hbq()
1181 else if (hbq_desc->profile == 5) in lpfc_config_hbq()
1185 if (!hbq_desc->mask_count) in lpfc_config_hbq()
1189 for (i = 0; i < hbq_desc->mask_count; i++) { in lpfc_config_hbq()
1190 hbqmb->hbqMasks[i].tmatch = hbq_desc->hbqMasks[i].tmatch; in lpfc_config_hbq()
1191 hbqmb->hbqMasks[i].tmask = hbq_desc->hbqMasks[i].tmask; in lpfc_config_hbq()
1192 hbqmb->hbqMasks[i].rctlmatch = hbq_desc->hbqMasks[i].rctlmatch; in lpfc_config_hbq()
1193 hbqmb->hbqMasks[i].rctlmask = hbq_desc->hbqMasks[i].rctlmask; in lpfc_config_hbq()
1200 * lpfc_config_ring - Prepare a mailbox command for configuring an IOCB ring
1203 * @pmb: pointer to the driver internal queue element for mailbox command.
1205 * The configure ring mailbox command is used to configure an IOCB ring. This
1214 * This routine prepares the mailbox command for configuring IOCB ring.
1220 MAILBOX_t *mb = &pmb->u.mb; in lpfc_config_ring()
1226 mb->un.varCfgRing.ring = ring; in lpfc_config_ring()
1227 mb->un.varCfgRing.maxOrigXchg = 0; in lpfc_config_ring()
1228 mb->un.varCfgRing.maxRespXchg = 0; in lpfc_config_ring()
1229 mb->un.varCfgRing.recvNotify = 1; in lpfc_config_ring()
1231 psli = &phba->sli; in lpfc_config_ring()
1232 pring = &psli->sli3_ring[ring]; in lpfc_config_ring()
1233 mb->un.varCfgRing.numMask = pring->num_mask; in lpfc_config_ring()
1234 mb->mbxCommand = MBX_CONFIG_RING; in lpfc_config_ring()
1235 mb->mbxOwner = OWN_HOST; in lpfc_config_ring()
1238 if (pring->prt[0].profile) { in lpfc_config_ring()
1239 mb->un.varCfgRing.profile = pring->prt[0].profile; in lpfc_config_ring()
1244 for (i = 0; i < pring->num_mask; i++) { in lpfc_config_ring()
1245 mb->un.varCfgRing.rrRegs[i].rval = pring->prt[i].rctl; in lpfc_config_ring()
1246 if (mb->un.varCfgRing.rrRegs[i].rval != FC_RCTL_ELS_REQ) in lpfc_config_ring()
1247 mb->un.varCfgRing.rrRegs[i].rmask = 0xff; in lpfc_config_ring()
1249 mb->un.varCfgRing.rrRegs[i].rmask = 0xfe; in lpfc_config_ring()
1250 mb->un.varCfgRing.rrRegs[i].tval = pring->prt[i].type; in lpfc_config_ring()
1251 mb->un.varCfgRing.rrRegs[i].tmask = 0xff; in lpfc_config_ring()
1258 * lpfc_config_port - Prepare a mailbox command for configuring port
1260 * @pmb: pointer to the driver internal queue element for mailbox command.
1262 * The configure port mailbox command is used to identify the Port Control
1264 * driver must not access the mailbox in the HBA without first resetting
1269 * This routine prepares the mailbox command for configuring port.
1274 MAILBOX_t __iomem *mb_slim = (MAILBOX_t __iomem *) phba->MBslimaddr; in lpfc_config_port()
1275 MAILBOX_t *mb = &pmb->u.mb; in lpfc_config_port()
1284 mb->mbxCommand = MBX_CONFIG_PORT; in lpfc_config_port()
1285 mb->mbxOwner = OWN_HOST; in lpfc_config_port()
1287 mb->un.varCfgPort.pcbLen = sizeof(PCB_t); in lpfc_config_port()
1289 offset = (uint8_t *)phba->pcb - (uint8_t *)phba->slim2p.virt; in lpfc_config_port()
1290 pdma_addr = phba->slim2p.phys + offset; in lpfc_config_port()
1291 mb->un.varCfgPort.pcbLow = putPaddrLow(pdma_addr); in lpfc_config_port()
1292 mb->un.varCfgPort.pcbHigh = putPaddrHigh(pdma_addr); in lpfc_config_port()
1295 mb->un.varCfgPort.hps = 1; in lpfc_config_port()
1299 if (phba->sli_rev == LPFC_SLI_REV3 && phba->vpd.sli3Feat.cerbm) { in lpfc_config_port()
1300 if (phba->cfg_enable_bg) in lpfc_config_port()
1301 mb->un.varCfgPort.cbg = 1; /* configure BlockGuard */ in lpfc_config_port()
1302 mb->un.varCfgPort.cerbm = 1; /* Request HBQs */ in lpfc_config_port()
1303 mb->un.varCfgPort.ccrp = 1; /* Command Ring Polling */ in lpfc_config_port()
1304 mb->un.varCfgPort.max_hbq = lpfc_sli_hbq_count(); in lpfc_config_port()
1305 if (phba->max_vpi && phba->cfg_enable_npiv && in lpfc_config_port()
1306 phba->vpd.sli3Feat.cmv) { in lpfc_config_port()
1307 mb->un.varCfgPort.max_vpi = LPFC_MAX_VPI; in lpfc_config_port()
1308 mb->un.varCfgPort.cmv = 1; in lpfc_config_port()
1310 mb->un.varCfgPort.max_vpi = phba->max_vpi = 0; in lpfc_config_port()
1312 phba->sli_rev = LPFC_SLI_REV2; in lpfc_config_port()
1313 mb->un.varCfgPort.sli_mode = phba->sli_rev; in lpfc_config_port()
1316 if (phba->sli_rev == LPFC_SLI_REV3) in lpfc_config_port()
1317 mb->un.varCfgPort.casabt = 1; in lpfc_config_port()
1320 phba->pcb->type = TYPE_NATIVE_SLI2; in lpfc_config_port()
1321 phba->pcb->feature = FEATURE_INITIAL_SLI2; in lpfc_config_port()
1323 /* Setup Mailbox pointers */ in lpfc_config_port()
1324 phba->pcb->mailBoxSize = sizeof(MAILBOX_t) + MAILBOX_EXT_SIZE; in lpfc_config_port()
1325 offset = (uint8_t *)phba->mbox - (uint8_t *)phba->slim2p.virt; in lpfc_config_port()
1326 pdma_addr = phba->slim2p.phys + offset; in lpfc_config_port()
1327 phba->pcb->mbAddrHigh = putPaddrHigh(pdma_addr); in lpfc_config_port()
1328 phba->pcb->mbAddrLow = putPaddrLow(pdma_addr); in lpfc_config_port()
1349 pci_read_config_dword(phba->pcidev, PCI_BASE_ADDRESS_0, &bar_low); in lpfc_config_port()
1350 pci_read_config_dword(phba->pcidev, PCI_BASE_ADDRESS_1, &bar_high); in lpfc_config_port()
1353 * Set up HGP - Port Memory in lpfc_config_port()
1356 * following the "non-diagnostic" mode mailbox (32 words, 0x80 bytes) in lpfc_config_port()
1357 * area of SLIM. In SLI-2 mode, there's an additional 16 reserved in lpfc_config_port()
1359 * configured in SLI-3. in lpfc_config_port()
1361 * CR0Put - SLI2(no HBQs) = 0xc0, With HBQs = 0x80 in lpfc_config_port()
1370 * Reserved 0xa0-0xbf in lpfc_config_port()
1376 * HBQ(M-1)Put Pointer 0xc0+(M-1)*4 in lpfc_config_port()
1380 if (phba->cfg_hostmem_hgp && phba->sli_rev != 3) { in lpfc_config_port()
1381 phba->host_gp = (struct lpfc_hgp __iomem *) in lpfc_config_port()
1382 &phba->mbox->us.s2.host[0]; in lpfc_config_port()
1383 phba->hbq_put = NULL; in lpfc_config_port()
1384 offset = (uint8_t *)&phba->mbox->us.s2.host - in lpfc_config_port()
1385 (uint8_t *)phba->slim2p.virt; in lpfc_config_port()
1386 pdma_addr = phba->slim2p.phys + offset; in lpfc_config_port()
1387 phba->pcb->hgpAddrHigh = putPaddrHigh(pdma_addr); in lpfc_config_port()
1388 phba->pcb->hgpAddrLow = putPaddrLow(pdma_addr); in lpfc_config_port()
1391 mb->un.varCfgPort.hps = 1; in lpfc_config_port()
1393 if (phba->sli_rev == 3) { in lpfc_config_port()
1394 phba->host_gp = &mb_slim->us.s3.host[0]; in lpfc_config_port()
1395 phba->hbq_put = &mb_slim->us.s3.hbq_put[0]; in lpfc_config_port()
1397 phba->host_gp = &mb_slim->us.s2.host[0]; in lpfc_config_port()
1398 phba->hbq_put = NULL; in lpfc_config_port()
1401 /* mask off BAR0's flag bits 0 - 3 */ in lpfc_config_port()
1402 phba->pcb->hgpAddrLow = (bar_low & PCI_BASE_ADDRESS_MEM_MASK) + in lpfc_config_port()
1403 (void __iomem *)phba->host_gp - in lpfc_config_port()
1404 (void __iomem *)phba->MBslimaddr; in lpfc_config_port()
1406 phba->pcb->hgpAddrHigh = bar_high; in lpfc_config_port()
1408 phba->pcb->hgpAddrHigh = 0; in lpfc_config_port()
1412 for (i = 0; i < phba->sli.num_rings; i++) { in lpfc_config_port()
1413 lpfc_memcpy_to_slim(phba->host_gp + i, &hgp, in lpfc_config_port()
1414 sizeof(*phba->host_gp)); in lpfc_config_port()
1419 if (phba->sli_rev == 3) in lpfc_config_port()
1424 pdma_addr = phba->slim2p.phys + pgp_offset; in lpfc_config_port()
1425 phba->pcb->pgpAddrHigh = putPaddrHigh(pdma_addr); in lpfc_config_port()
1426 phba->pcb->pgpAddrLow = putPaddrLow(pdma_addr); in lpfc_config_port()
1432 if (lpfc_is_LC_HBA(phba->pcidev->device)) { in lpfc_config_port()
1437 memcpy(&mb->un.varCfgPort.hbainit, hbainit, 20); in lpfc_config_port()
1441 lpfc_sli_pcimem_bcopy(phba->pcb, phba->pcb, sizeof(PCB_t)); in lpfc_config_port()
1445 * lpfc_kill_board - Prepare a mailbox command for killing board
1447 * @pmb: pointer to the driver internal queue element for mailbox command.
1449 * The kill board mailbox command is used to tell firmware to perform a
1451 * When the kill board mailbox command is received, the ER3 bit is set to 1
1456 * This routine prepares the mailbox command for killing the board in
1462 MAILBOX_t *mb = &pmb->u.mb; in lpfc_kill_board()
1465 mb->mbxCommand = MBX_KILL_BOARD; in lpfc_kill_board()
1466 mb->mbxOwner = OWN_HOST; in lpfc_kill_board()
1471 * lpfc_mbox_put - Put a mailbox cmd into the tail of driver's mailbox queue
1473 * @mbq: pointer to the driver internal queue element for mailbox command.
1475 * Driver maintains a internal mailbox command queue implemented as a linked
1476 * list. When a mailbox command is issued, it shall be put into the mailbox
1478 * one mailbox command at a time.
1485 psli = &phba->sli; in lpfc_mbox_put()
1487 list_add_tail(&mbq->list, &psli->mboxq); in lpfc_mbox_put()
1489 psli->mboxq_cnt++; in lpfc_mbox_put()
1495 * lpfc_mbox_get - Remove a mailbox cmd from the head of driver's mailbox queue
1498 * Driver maintains a internal mailbox command queue implemented as a linked
1499 * list. When a mailbox command is issued, it shall be put into the mailbox
1501 * one mailbox command at a time. After HBA finished processing a mailbox
1502 * command, the driver will remove a pending mailbox command from the head of
1503 * the mailbox command queue and send to the HBA for processing.
1506 * pointer to the driver internal queue element for mailbox command.
1512 struct lpfc_sli *psli = &phba->sli; in lpfc_mbox_get()
1514 list_remove_head((&psli->mboxq), mbq, LPFC_MBOXQ_t, list); in lpfc_mbox_get()
1516 psli->mboxq_cnt--; in lpfc_mbox_get()
1522 * __lpfc_mbox_cmpl_put - Put mailbox cmd into mailbox cmd complete list
1524 * @mbq: pointer to the driver internal queue element for mailbox command.
1526 * This routine put the completed mailbox command into the mailbox command
1527 * complete list. This is the unlocked version of the routine. The mailbox
1528 * complete list is used by the driver worker thread to process mailbox
1534 list_add_tail(&mbq->list, &phba->sli.mboxq_cmpl); in __lpfc_mbox_cmpl_put()
1538 * lpfc_mbox_cmpl_put - Put mailbox command into mailbox command complete list
1540 * @mbq: pointer to the driver internal queue element for mailbox command.
1542 * This routine put the completed mailbox command into the mailbox command
1543 * complete list. This is the locked version of the routine. The mailbox
1544 * complete list is used by the driver worker thread to process mailbox
1553 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_mbox_cmpl_put()
1555 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_mbox_cmpl_put()
1560 * lpfc_mbox_cmd_check - Check the validality of a mailbox command
1562 * @mboxq: pointer to the driver internal queue element for mailbox command.
1564 * This routine is to check whether a mailbox command is valid to be issued.
1565 * This check will be performed by both the mailbox issue API when a client
1566 * is to issue a mailbox command to the mailbox transport.
1568 * Return 0 - pass the check, -ENODEV - fail the check
1573 /* Mailbox command that have a completion handler must also have a in lpfc_mbox_cmd_check()
1576 if (mboxq->mbox_cmpl && mboxq->mbox_cmpl != lpfc_sli_def_mbox_cmpl && in lpfc_mbox_cmd_check()
1577 mboxq->mbox_cmpl != lpfc_sli_wake_mbox_wait) { in lpfc_mbox_cmd_check()
1578 if (!mboxq->vport) { in lpfc_mbox_cmd_check()
1581 mboxq->u.mb.mbxCommand); in lpfc_mbox_cmd_check()
1583 return -ENODEV; in lpfc_mbox_cmd_check()
1590 * lpfc_mbox_dev_check - Check the device state for issuing a mailbox command
1594 * mailbox command. It is used by the mailbox transport API at the time the
1595 * to post a mailbox command to the device.
1597 * Return 0 - pass the check, -ENODEV - fail the check
1603 if (unlikely(pci_channel_offline(phba->pcidev))) in lpfc_mbox_dev_check()
1604 return -ENODEV; in lpfc_mbox_dev_check()
1607 if (phba->link_state == LPFC_HBA_ERROR) in lpfc_mbox_dev_check()
1608 return -ENODEV; in lpfc_mbox_dev_check()
1614 * lpfc_mbox_tmo_val - Retrieve mailbox command timeout value
1616 * @mboxq: pointer to the driver internal queue element for mailbox command.
1618 * This routine retrieves the proper timeout value according to the mailbox
1622 * Timeout value to be used for the given mailbox command
1627 MAILBOX_t *mbox = &mboxq->u.mb; in lpfc_mbox_tmo_val()
1630 switch (mbox->mbxCommand) { in lpfc_mbox_tmo_val()
1677 * lpfc_sli4_mbx_sge_set - Set a sge entry in non-embedded mailbox command
1683 * This routine sets up an entry in the non-embedded mailbox command at the sge
1693 &mbox->u.mqe.un.nembed_cmd; in lpfc_sli4_mbx_sge_set()
1694 nembed_sge->sge[sgentry].pa_lo = putPaddrLow(phyaddr); in lpfc_sli4_mbx_sge_set()
1695 nembed_sge->sge[sgentry].pa_hi = putPaddrHigh(phyaddr); in lpfc_sli4_mbx_sge_set()
1696 nembed_sge->sge[sgentry].length = length; in lpfc_sli4_mbx_sge_set()
1700 * lpfc_sli4_mbx_sge_get - Get a sge entry from non-embedded mailbox command
1703 * @sge: pointer to lpfc mailbox sge to load into.
1705 * This routine gets an entry from the non-embedded mailbox command at the sge
1715 &mbox->u.mqe.un.nembed_cmd; in lpfc_sli4_mbx_sge_get()
1716 sge->pa_lo = nembed_sge->sge[sgentry].pa_lo; in lpfc_sli4_mbx_sge_get()
1717 sge->pa_hi = nembed_sge->sge[sgentry].pa_hi; in lpfc_sli4_mbx_sge_get()
1718 sge->length = nembed_sge->sge[sgentry].length; in lpfc_sli4_mbx_sge_get()
1722 * lpfc_sli4_mbox_cmd_free - Free a sli4 mailbox command
1726 * This routine frees SLI4 specific mailbox command for sending IOCTL command.
1736 sli4_cfg = &mbox->u.mqe.un.sli4_config; in lpfc_sli4_mbox_cmd_free()
1739 if (bf_get(lpfc_mbox_hdr_emb, &sli4_cfg->header.cfg_mhdr)) { in lpfc_sli4_mbox_cmd_free()
1740 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_mbox_cmd_free()
1744 /* For non-embedded mbox command, we need to free the pages first */ in lpfc_sli4_mbox_cmd_free()
1745 sgecount = bf_get(lpfc_mbox_hdr_sge_cnt, &sli4_cfg->header.cfg_mhdr); in lpfc_sli4_mbox_cmd_free()
1747 if (unlikely(!mbox->sge_array)) { in lpfc_sli4_mbox_cmd_free()
1748 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_mbox_cmd_free()
1751 /* Each non-embedded DMA memory was allocated in the length of a page */ in lpfc_sli4_mbox_cmd_free()
1755 dma_free_coherent(&phba->pcidev->dev, SLI4_PAGE_SIZE, in lpfc_sli4_mbox_cmd_free()
1756 mbox->sge_array->addr[sgentry], phyaddr); in lpfc_sli4_mbox_cmd_free()
1759 kfree(mbox->sge_array); in lpfc_sli4_mbox_cmd_free()
1760 /* Finally, free the mailbox command itself */ in lpfc_sli4_mbox_cmd_free()
1761 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_mbox_cmd_free()
1765 * lpfc_sli4_config - Initialize the SLI4 Config Mailbox command
1768 * @subsystem: The sli4 config sub mailbox subsystem.
1769 * @opcode: The sli4 config sub mailbox command opcode.
1770 * @length: Length of the sli4 config mailbox command (including sub-header).
1773 * This routine sets up the header fields of SLI4 specific mailbox command
1777 * for none embedded mailbox command).
1791 /* Set up SLI4 mailbox command header fields */ in lpfc_sli4_config()
1793 bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_SLI4_CONFIG); in lpfc_sli4_config()
1796 sli4_config = &mbox->u.mqe.un.sli4_config; in lpfc_sli4_config()
1801 bf_set(lpfc_mbox_hdr_emb, &sli4_config->header.cfg_mhdr, 1); in lpfc_sli4_config()
1802 sli4_config->header.cfg_mhdr.payload_length = length; in lpfc_sli4_config()
1803 /* Set up sub-header fields following main header */ in lpfc_sli4_config()
1805 &sli4_config->header.cfg_shdr.request, opcode); in lpfc_sli4_config()
1807 &sli4_config->header.cfg_shdr.request, subsystem); in lpfc_sli4_config()
1808 sli4_config->header.cfg_shdr.request.request_length = in lpfc_sli4_config()
1809 length - LPFC_MBX_CMD_HDR_LENGTH; in lpfc_sli4_config()
1813 /* Setup for the non-embedded mbox command */ in lpfc_sli4_config()
1818 mbox->sge_array = kzalloc(sizeof(struct lpfc_mbx_nembed_sge_virt), in lpfc_sli4_config()
1820 if (!mbox->sge_array) { in lpfc_sli4_config()
1822 "2527 Failed to allocate non-embedded SGE " in lpfc_sli4_config()
1832 viraddr = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_config()
1838 mbox->sge_array->addr[pagen] = viraddr; in lpfc_sli4_config()
1839 /* Keep the first page for later sub-header construction */ in lpfc_sli4_config()
1842 resid_len = length - alloc_len; in lpfc_sli4_config()
1854 /* Set up main header fields in mailbox command */ in lpfc_sli4_config()
1855 sli4_config->header.cfg_mhdr.payload_length = alloc_len; in lpfc_sli4_config()
1856 bf_set(lpfc_mbox_hdr_sge_cnt, &sli4_config->header.cfg_mhdr, pagen); in lpfc_sli4_config()
1858 /* Set up sub-header fields into the first page */ in lpfc_sli4_config()
1860 bf_set(lpfc_mbox_hdr_opcode, &cfg_shdr->request, opcode); in lpfc_sli4_config()
1861 bf_set(lpfc_mbox_hdr_subsystem, &cfg_shdr->request, subsystem); in lpfc_sli4_config()
1862 cfg_shdr->request.request_length = in lpfc_sli4_config()
1863 alloc_len - sizeof(union lpfc_sli4_cfg_shdr); in lpfc_sli4_config()
1865 /* The sub-header is in DMA memory, which needs endian converstion */ in lpfc_sli4_config()
1873 * lpfc_sli4_mbox_rsrc_extent - Initialize the opcode resource extent.
1881 * mailbox commands. It is called after lpfc_sli4_config. The caller must
1882 * pass an allocated mailbox and the attributes required to initialize the
1883 * mailbox correctly.
1897 /* Get the first SGE entry from the non-embedded DMA memory */ in lpfc_sli4_mbox_rsrc_extent()
1898 virtaddr = mbox->sge_array->addr[0]; in lpfc_sli4_mbox_rsrc_extent()
1910 &mbox->u.mqe.un.alloc_rsrc_extents.u.req, in lpfc_sli4_mbox_rsrc_extent()
1916 lpfc_sli_pcimem_bcopy(&n_rsrc_extnt->word4, in lpfc_sli4_mbox_rsrc_extent()
1917 &n_rsrc_extnt->word4, in lpfc_sli4_mbox_rsrc_extent()
1927 &mbox->u.mqe.un.alloc_rsrc_extents.u.req, in lpfc_sli4_mbox_rsrc_extent()
1949 * lpfc_sli_config_mbox_subsys_get - Get subsystem from a sli_config mbox cmd
1953 * This routine gets the subsystem from a SLI4 specific SLI_CONFIG mailbox
1954 * command. If the mailbox command is not MBX_SLI4_CONFIG (0x9B) or if the
1955 * sub-header is not present, subsystem LPFC_MBOX_SUBSYSTEM_NA (0x0) shall
1964 if (mbox->u.mb.mbxCommand != MBX_SLI4_CONFIG) in lpfc_sli_config_mbox_subsys_get()
1966 sli4_cfg = &mbox->u.mqe.un.sli4_config; in lpfc_sli_config_mbox_subsys_get()
1968 /* For embedded mbox command, get opcode from embedded sub-header*/ in lpfc_sli_config_mbox_subsys_get()
1969 if (bf_get(lpfc_mbox_hdr_emb, &sli4_cfg->header.cfg_mhdr)) { in lpfc_sli_config_mbox_subsys_get()
1970 cfg_shdr = &mbox->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli_config_mbox_subsys_get()
1971 return bf_get(lpfc_mbox_hdr_subsystem, &cfg_shdr->request); in lpfc_sli_config_mbox_subsys_get()
1974 /* For non-embedded mbox command, get opcode from first dma page */ in lpfc_sli_config_mbox_subsys_get()
1975 if (unlikely(!mbox->sge_array)) in lpfc_sli_config_mbox_subsys_get()
1977 cfg_shdr = (union lpfc_sli4_cfg_shdr *)mbox->sge_array->addr[0]; in lpfc_sli_config_mbox_subsys_get()
1978 return bf_get(lpfc_mbox_hdr_subsystem, &cfg_shdr->request); in lpfc_sli_config_mbox_subsys_get()
1982 * lpfc_sli_config_mbox_opcode_get - Get opcode from a sli_config mbox cmd
1986 * This routine gets the opcode from a SLI4 specific SLI_CONFIG mailbox
1987 * command. If the mailbox command is not MBX_SLI4_CONFIG (0x9B) or if
1988 * the sub-header is not present, opcode LPFC_MBOX_OPCODE_NA (0x0) be
1997 if (mbox->u.mb.mbxCommand != MBX_SLI4_CONFIG) in lpfc_sli_config_mbox_opcode_get()
1999 sli4_cfg = &mbox->u.mqe.un.sli4_config; in lpfc_sli_config_mbox_opcode_get()
2001 /* For embedded mbox command, get opcode from embedded sub-header*/ in lpfc_sli_config_mbox_opcode_get()
2002 if (bf_get(lpfc_mbox_hdr_emb, &sli4_cfg->header.cfg_mhdr)) { in lpfc_sli_config_mbox_opcode_get()
2003 cfg_shdr = &mbox->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_sli_config_mbox_opcode_get()
2004 return bf_get(lpfc_mbox_hdr_opcode, &cfg_shdr->request); in lpfc_sli_config_mbox_opcode_get()
2007 /* For non-embedded mbox command, get opcode from first dma page */ in lpfc_sli_config_mbox_opcode_get()
2008 if (unlikely(!mbox->sge_array)) in lpfc_sli_config_mbox_opcode_get()
2010 cfg_shdr = (union lpfc_sli4_cfg_shdr *)mbox->sge_array->addr[0]; in lpfc_sli_config_mbox_opcode_get()
2011 return bf_get(lpfc_mbox_hdr_opcode, &cfg_shdr->request); in lpfc_sli_config_mbox_opcode_get()
2015 * lpfc_sli4_mbx_read_fcf_rec - Allocate and construct read fcf mbox cmd
2020 * This routine routine allocates and constructs non-embedded mailbox command
2023 * Return: pointer to the mailbox command constructed if successful, otherwise
2038 return -ENOMEM; in lpfc_sli4_mbx_read_fcf_rec()
2043 /* Set up READ_FCF SLI4_CONFIG mailbox-ioctl command */ in lpfc_sli4_mbx_read_fcf_rec()
2053 return -ENOMEM; in lpfc_sli4_mbx_read_fcf_rec()
2056 /* Get the first SGE entry from the non-embedded DMA memory. This in lpfc_sli4_mbx_read_fcf_rec()
2060 virt_addr = mboxq->sge_array->addr[0]; in lpfc_sli4_mbx_read_fcf_rec()
2064 bf_set(lpfc_mbx_read_fcf_tbl_indx, &read_fcf->u.request, fcf_index); in lpfc_sli4_mbx_read_fcf_rec()
2073 * lpfc_request_features: Configure SLI4 REQUEST_FEATURES mailbox
2077 * This routine sets up the mailbox for an SLI4 REQUEST_FEATURES
2078 * mailbox command.
2083 /* Set up SLI4 mailbox command header fields */ in lpfc_request_features()
2085 bf_set(lpfc_mqe_command, &mboxq->u.mqe, MBX_SLI4_REQ_FTRS); in lpfc_request_features()
2088 bf_set(lpfc_mbx_rq_ftr_rq_fcpi, &mboxq->u.mqe.un.req_ftrs, 1); in lpfc_request_features()
2089 bf_set(lpfc_mbx_rq_ftr_rq_perfh, &mboxq->u.mqe.un.req_ftrs, 1); in lpfc_request_features()
2092 if (phba->cfg_enable_bg) in lpfc_request_features()
2093 bf_set(lpfc_mbx_rq_ftr_rq_dif, &mboxq->u.mqe.un.req_ftrs, 1); in lpfc_request_features()
2096 if (phba->max_vpi && phba->cfg_enable_npiv) in lpfc_request_features()
2097 bf_set(lpfc_mbx_rq_ftr_rq_npiv, &mboxq->u.mqe.un.req_ftrs, 1); in lpfc_request_features()
2099 if (phba->nvmet_support) { in lpfc_request_features()
2100 bf_set(lpfc_mbx_rq_ftr_rq_mrqp, &mboxq->u.mqe.un.req_ftrs, 1); in lpfc_request_features()
2102 bf_set(lpfc_mbx_rq_ftr_rq_iaab, &mboxq->u.mqe.un.req_ftrs, 0); in lpfc_request_features()
2103 bf_set(lpfc_mbx_rq_ftr_rq_iaar, &mboxq->u.mqe.un.req_ftrs, 0); in lpfc_request_features()
2107 if (phba->cfg_vmid_app_header) { in lpfc_request_features()
2108 bf_set(lpfc_mbx_rq_ftr_rq_ashdr, &mboxq->u.mqe.un.req_ftrs, 1); in lpfc_request_features()
2109 bf_set(lpfc_ftr_ashdr, &phba->sli4_hba.sli4_flags, 1); in lpfc_request_features()
2115 * lpfc_init_vfi - Initialize the INIT_VFI mailbox command
2119 * This routine initializes @mbox to all zeros and then fills in the mailbox
2131 mbox->vport = vport; in lpfc_init_vfi()
2132 init_vfi = &mbox->u.mqe.un.init_vfi; in lpfc_init_vfi()
2133 bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_INIT_VFI); in lpfc_init_vfi()
2138 vport->phba->sli4_hba.vfi_ids[vport->vfi]); in lpfc_init_vfi()
2140 vport->phba->vpi_ids[vport->vpi]); in lpfc_init_vfi()
2142 vport->phba->fcf.fcfi); in lpfc_init_vfi()
2146 * lpfc_reg_vfi - Initialize the REG_VFI mailbox command
2151 * This routine initializes @mbox to all zeros and then fills in the mailbox
2160 struct lpfc_hba *phba = vport->phba; in lpfc_reg_vfi()
2164 reg_vfi = &mbox->u.mqe.un.reg_vfi; in lpfc_reg_vfi()
2165 bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_REG_VFI); in lpfc_reg_vfi()
2168 phba->sli4_hba.vfi_ids[vport->vfi]); in lpfc_reg_vfi()
2169 bf_set(lpfc_reg_vfi_fcfi, reg_vfi, phba->fcf.fcfi); in lpfc_reg_vfi()
2170 bf_set(lpfc_reg_vfi_vpi, reg_vfi, phba->vpi_ids[vport->vpi]); in lpfc_reg_vfi()
2171 memcpy(reg_vfi->wwn, &vport->fc_portname, sizeof(struct lpfc_name)); in lpfc_reg_vfi()
2172 reg_vfi->wwn[0] = cpu_to_le32(reg_vfi->wwn[0]); in lpfc_reg_vfi()
2173 reg_vfi->wwn[1] = cpu_to_le32(reg_vfi->wwn[1]); in lpfc_reg_vfi()
2174 reg_vfi->e_d_tov = phba->fc_edtov; in lpfc_reg_vfi()
2175 reg_vfi->r_a_tov = phba->fc_ratov; in lpfc_reg_vfi()
2177 reg_vfi->bde.addrHigh = putPaddrHigh(phys); in lpfc_reg_vfi()
2178 reg_vfi->bde.addrLow = putPaddrLow(phys); in lpfc_reg_vfi()
2179 reg_vfi->bde.tus.f.bdeSize = sizeof(vport->fc_sparam); in lpfc_reg_vfi()
2180 reg_vfi->bde.tus.f.bdeFlags = BUFF_TYPE_BDE_64; in lpfc_reg_vfi()
2182 bf_set(lpfc_reg_vfi_nport_id, reg_vfi, vport->fc_myDID); in lpfc_reg_vfi()
2185 if ((phba->sli4_hba.lnk_info.lnk_tp == LPFC_LNK_TYPE_FC) && in lpfc_reg_vfi()
2186 (vport->fc_flag & FC_VFI_REGISTERED) && in lpfc_reg_vfi()
2187 (!phba->fc_topology_changed)) in lpfc_reg_vfi()
2192 bbscn_fabric = (phba->fc_fabparam.cmn.bbRcvSizeMsb >> 4) & 0xF; in lpfc_reg_vfi()
2194 if (phba->bbcredit_support && phba->cfg_enable_bbcr && in lpfc_reg_vfi()
2197 &phba->sli4_hba.bbscn_params); in lpfc_reg_vfi()
2200 &phba->sli4_hba.bbscn_params); in lpfc_reg_vfi()
2215 vport->fc_myDID, in lpfc_reg_vfi()
2216 phba->fcf.fcfi, in lpfc_reg_vfi()
2217 phba->sli4_hba.vfi_ids[vport->vfi], in lpfc_reg_vfi()
2218 phba->vpi_ids[vport->vpi], in lpfc_reg_vfi()
2219 reg_vfi->wwn[0], reg_vfi->wwn[1], vport->fc_flag, in lpfc_reg_vfi()
2220 vport->port_state, phba->fc_topology_changed, in lpfc_reg_vfi()
2225 * lpfc_init_vpi - Initialize the INIT_VPI mailbox command
2230 * The INIT_VPI mailbox command supports virtual N_Ports. The driver uses the
2240 bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_INIT_VPI); in lpfc_init_vpi()
2241 bf_set(lpfc_init_vpi_vpi, &mbox->u.mqe.un.init_vpi, in lpfc_init_vpi()
2242 phba->vpi_ids[vpi]); in lpfc_init_vpi()
2243 bf_set(lpfc_init_vpi_vfi, &mbox->u.mqe.un.init_vpi, in lpfc_init_vpi()
2244 phba->sli4_hba.vfi_ids[phba->pport->vfi]); in lpfc_init_vpi()
2248 * lpfc_unreg_vfi - Initialize the UNREG_VFI mailbox command
2252 * The UNREG_VFI mailbox command causes the SLI Host to put a virtual fabric
2255 * fabric. The SLI Port posts the mailbox response after marking the virtual
2262 bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_UNREG_VFI); in lpfc_unreg_vfi()
2263 bf_set(lpfc_unreg_vfi_vfi, &mbox->u.mqe.un.unreg_vfi, in lpfc_unreg_vfi()
2264 vport->phba->sli4_hba.vfi_ids[vport->vfi]); in lpfc_unreg_vfi()
2268 * lpfc_sli4_dump_cfg_rg23 - Dump sli4 port config region 23
2272 * This function create a SLI4 dump mailbox command to dump configure
2282 mb = &mbox->u.mb; in lpfc_sli4_dump_cfg_rg23()
2286 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); in lpfc_sli4_dump_cfg_rg23()
2288 if (!mp || !mp->virt) { in lpfc_sli4_dump_cfg_rg23()
2297 memset(mp->virt, 0, LPFC_BPL_SIZE); in lpfc_sli4_dump_cfg_rg23()
2298 INIT_LIST_HEAD(&mp->list); in lpfc_sli4_dump_cfg_rg23()
2301 mbox->ctx_buf = (uint8_t *)mp; in lpfc_sli4_dump_cfg_rg23()
2303 mb->mbxCommand = MBX_DUMP_MEMORY; in lpfc_sli4_dump_cfg_rg23()
2304 mb->un.varDmp.type = DMP_NV_PARAMS; in lpfc_sli4_dump_cfg_rg23()
2305 mb->un.varDmp.region_id = DMP_REGION_23; in lpfc_sli4_dump_cfg_rg23()
2306 mb->un.varDmp.sli4_length = DMP_RGN23_SIZE; in lpfc_sli4_dump_cfg_rg23()
2307 mb->un.varWords[3] = putPaddrLow(mp->phys); in lpfc_sli4_dump_cfg_rg23()
2308 mb->un.varWords[4] = putPaddrHigh(mp->phys); in lpfc_sli4_dump_cfg_rg23()
2318 (struct lpfc_rdp_context *)(mboxq->ctx_ndlp); in lpfc_mbx_cmpl_rdp_link_stat()
2320 mb = &mboxq->u.mb; in lpfc_mbx_cmpl_rdp_link_stat()
2321 if (mb->mbxStatus) in lpfc_mbx_cmpl_rdp_link_stat()
2324 memcpy(&rdp_context->link_stat, &mb->un.varRdLnk, sizeof(READ_LNK_VAR)); in lpfc_mbx_cmpl_rdp_link_stat()
2330 rdp_context->cmpl(phba, rdp_context, rc); in lpfc_mbx_cmpl_rdp_link_stat()
2336 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)mbox->ctx_buf; in lpfc_mbx_cmpl_rdp_page_a2()
2338 (struct lpfc_rdp_context *)(mbox->ctx_ndlp); in lpfc_mbx_cmpl_rdp_page_a2()
2340 if (bf_get(lpfc_mqe_status, &mbox->u.mqe)) in lpfc_mbx_cmpl_rdp_page_a2()
2343 lpfc_sli_bemem_bcopy(mp->virt, &rdp_context->page_a2, in lpfc_mbx_cmpl_rdp_page_a2()
2347 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_mbx_cmpl_rdp_page_a2()
2352 mbox->vport = rdp_context->ndlp->vport; in lpfc_mbx_cmpl_rdp_page_a2()
2353 mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_link_stat; in lpfc_mbx_cmpl_rdp_page_a2()
2354 mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context; in lpfc_mbx_cmpl_rdp_page_a2()
2361 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_mbx_cmpl_rdp_page_a2()
2365 rdp_context->cmpl(phba, rdp_context, FAILURE); in lpfc_mbx_cmpl_rdp_page_a2()
2372 struct lpfc_dmabuf *mp = (struct lpfc_dmabuf *)(mbox->ctx_buf); in lpfc_mbx_cmpl_rdp_page_a0()
2374 (struct lpfc_rdp_context *)(mbox->ctx_ndlp); in lpfc_mbx_cmpl_rdp_page_a0()
2376 if (bf_get(lpfc_mqe_status, &mbox->u.mqe)) in lpfc_mbx_cmpl_rdp_page_a0()
2379 lpfc_sli_bemem_bcopy(mp->virt, &rdp_context->page_a0, in lpfc_mbx_cmpl_rdp_page_a0()
2384 memset(mp->virt, 0, DMP_SFF_PAGE_A2_SIZE); in lpfc_mbx_cmpl_rdp_page_a0()
2385 INIT_LIST_HEAD(&mp->list); in lpfc_mbx_cmpl_rdp_page_a0()
2388 mbox->ctx_buf = mp; in lpfc_mbx_cmpl_rdp_page_a0()
2389 mbox->vport = rdp_context->ndlp->vport; in lpfc_mbx_cmpl_rdp_page_a0()
2391 bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_DUMP_MEMORY); in lpfc_mbx_cmpl_rdp_page_a0()
2393 &mbox->u.mqe.un.mem_dump_type3, DMP_LMSD); in lpfc_mbx_cmpl_rdp_page_a0()
2395 &mbox->u.mqe.un.mem_dump_type3, phba->sli4_hba.physical_port); in lpfc_mbx_cmpl_rdp_page_a0()
2397 &mbox->u.mqe.un.mem_dump_type3, DMP_PAGE_A2); in lpfc_mbx_cmpl_rdp_page_a0()
2399 &mbox->u.mqe.un.mem_dump_type3, DMP_SFF_PAGE_A2_SIZE); in lpfc_mbx_cmpl_rdp_page_a0()
2400 mbox->u.mqe.un.mem_dump_type3.addr_lo = putPaddrLow(mp->phys); in lpfc_mbx_cmpl_rdp_page_a0()
2401 mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys); in lpfc_mbx_cmpl_rdp_page_a0()
2403 mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_page_a2; in lpfc_mbx_cmpl_rdp_page_a0()
2404 mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context; in lpfc_mbx_cmpl_rdp_page_a0()
2412 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_mbx_cmpl_rdp_page_a0()
2415 rdp_context->cmpl(phba, rdp_context, FAILURE); in lpfc_mbx_cmpl_rdp_page_a0()
2420 * lpfc_sli4_dump_page_a0 - Dump sli4 read SFP Diagnostic.
2424 * This function create a SLI4 dump mailbox command to dump configure
2436 mp->virt = lpfc_mbuf_alloc(phba, 0, &mp->phys); in lpfc_sli4_dump_page_a0()
2437 if (!mp || !mp->virt) { in lpfc_sli4_dump_page_a0()
2444 memset(mp->virt, 0, LPFC_BPL_SIZE); in lpfc_sli4_dump_page_a0()
2445 INIT_LIST_HEAD(&mp->list); in lpfc_sli4_dump_page_a0()
2447 bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_DUMP_MEMORY); in lpfc_sli4_dump_page_a0()
2449 mbox->ctx_buf = mp; in lpfc_sli4_dump_page_a0()
2452 &mbox->u.mqe.un.mem_dump_type3, DMP_LMSD); in lpfc_sli4_dump_page_a0()
2454 &mbox->u.mqe.un.mem_dump_type3, phba->sli4_hba.physical_port); in lpfc_sli4_dump_page_a0()
2456 &mbox->u.mqe.un.mem_dump_type3, DMP_PAGE_A0); in lpfc_sli4_dump_page_a0()
2458 &mbox->u.mqe.un.mem_dump_type3, DMP_SFF_PAGE_A0_SIZE); in lpfc_sli4_dump_page_a0()
2459 mbox->u.mqe.un.mem_dump_type3.addr_lo = putPaddrLow(mp->phys); in lpfc_sli4_dump_page_a0()
2460 mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys); in lpfc_sli4_dump_page_a0()
2466 * lpfc_reg_fcfi - Initialize the REG_FCFI mailbox command
2470 * The REG_FCFI mailbox command supports Fibre Channel Forwarders (FCFs). The
2472 * information via a READ_FCF mailbox command. This mailbox command also is used
2484 reg_fcfi = &mbox->u.mqe.un.reg_fcfi; in lpfc_reg_fcfi()
2485 bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_REG_FCFI); in lpfc_reg_fcfi()
2486 if (phba->nvmet_support == 0) { in lpfc_reg_fcfi()
2488 phba->sli4_hba.hdr_rq->queue_id); in lpfc_reg_fcfi()
2489 /* Match everything - rq_id0 */ in lpfc_reg_fcfi()
2499 (~phba->fcf.addr_mode) & 0x3); in lpfc_reg_fcfi()
2502 if (phba->cfg_nvmet_mrq != 1) in lpfc_reg_fcfi()
2506 phba->sli4_hba.nvmet_mrq_hdr[0]->queue_id); in lpfc_reg_fcfi()
2507 /* Match type FCP - rq_id0 */ in lpfc_reg_fcfi()
2514 phba->sli4_hba.hdr_rq->queue_id); in lpfc_reg_fcfi()
2515 /* Match everything else - rq_id1 */ in lpfc_reg_fcfi()
2524 phba->fcf.current_rec.fcf_indx); in lpfc_reg_fcfi()
2525 if (phba->fcf.current_rec.vlan_id != LPFC_FCOE_NULL_VID) { in lpfc_reg_fcfi()
2528 phba->fcf.current_rec.vlan_id); in lpfc_reg_fcfi()
2533 * lpfc_reg_fcfi_mrq - Initialize the REG_FCFI_MRQ mailbox command
2538 * The REG_FCFI_MRQ mailbox command supports Fibre Channel Forwarders (FCFs).
2540 * information via a READ_FCF mailbox command. This mailbox command also is used
2552 if (phba->cfg_nvmet_mrq <= 1) in lpfc_reg_fcfi_mrq()
2556 reg_fcfi = &mbox->u.mqe.un.reg_fcfi_mrq; in lpfc_reg_fcfi_mrq()
2557 bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_REG_FCFI_MRQ); in lpfc_reg_fcfi_mrq()
2560 phba->fcf.current_rec.fcf_indx); in lpfc_reg_fcfi_mrq()
2561 if (phba->fcf.current_rec.vlan_id != LPFC_FCOE_NULL_VID) { in lpfc_reg_fcfi_mrq()
2564 phba->fcf.current_rec.vlan_id); in lpfc_reg_fcfi_mrq()
2570 phba->sli4_hba.nvmet_mrq_hdr[0]->queue_id); in lpfc_reg_fcfi_mrq()
2571 /* Match NVME frames of type FCP (protocol NVME) - rq_id0 */ in lpfc_reg_fcfi_mrq()
2582 bf_set(lpfc_reg_fcfi_mrq_npairs, reg_fcfi, phba->cfg_nvmet_mrq); in lpfc_reg_fcfi_mrq()
2585 phba->sli4_hba.hdr_rq->queue_id); in lpfc_reg_fcfi_mrq()
2586 /* Match everything - rq_id1 */ in lpfc_reg_fcfi_mrq()
2597 * lpfc_unreg_fcfi - Initialize the UNREG_FCFI mailbox command
2601 * The UNREG_FCFI mailbox command supports Fibre Channel Forwarders (FCFs).
2608 bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_UNREG_FCFI); in lpfc_unreg_fcfi()
2609 bf_set(lpfc_unreg_fcfi, &mbox->u.mqe.un.unreg_fcfi, fcfi); in lpfc_unreg_fcfi()
2613 * lpfc_resume_rpi - Initialize the RESUME_RPI mailbox command
2617 * The RESUME_RPI mailbox command is used to restart I/O to an RPI after a
2623 struct lpfc_hba *phba = ndlp->phba; in lpfc_resume_rpi()
2627 resume_rpi = &mbox->u.mqe.un.resume_rpi; in lpfc_resume_rpi()
2628 bf_set(lpfc_mqe_command, &mbox->u.mqe, MBX_RESUME_RPI); in lpfc_resume_rpi()
2630 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); in lpfc_resume_rpi()
2632 resume_rpi->event_tag = ndlp->phba->fc_eventTag; in lpfc_resume_rpi()