drivers/scsi/lpfc/lpfc_mbox.c
Source file repositories/reference/linux-study-clean/drivers/scsi/lpfc/lpfc_mbox.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/lpfc/lpfc_mbox.c- Extension
.c- Size
- 89050 bytes
- Lines
- 2668
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/blkdev.hlinux/pci.hlinux/slab.hlinux/interrupt.hscsi/scsi_device.hscsi/scsi_transport_fc.hscsi/scsi.hscsi/fc/fc_fs.hlpfc_hw4.hlpfc_hw.hlpfc_sli.hlpfc_sli4.hlpfc_nl.hlpfc_disc.hlpfc_scsi.hlpfc.hlpfc_logmsg.hlpfc_crtn.hlpfc_compat.h
Detected Declarations
function lpfc_mbox_rsrc_prepfunction lpfc_mbox_rsrc_cleanupfunction lpfc_dump_static_vportfunction lpfc_down_linkfunction lpfc_dump_memfunction lpfc_dump_wakeup_paramfunction lpfc_read_nvfunction lpfc_config_asyncfunction lpfc_heart_beatfunction Attentionfunction lpfc_clear_lafunction lpfc_config_linkfunction lpfc_config_msifunction lpfc_init_linkfunction replyfunction lpfc_unreg_didfunction lpfc_read_configfunction lpfc_read_lnk_statfunction lpfc_reg_rpifunction lpfc_unreg_loginfunction lpfc_sli4_unreg_all_rpisfunction lpfc_reg_vpifunction lpfc_unreg_vpifunction Blockfunction lpfc_read_revfunction lpfc_sli4_swap_strfunction Queuefunction Queuefunction Queuefunction HBQfunction Blockfunction lpfc_config_portfunction wordsfunction lpfc_kill_boardfunction lpfc_mbox_putfunction lpfc_mbox_getfunction __lpfc_mbox_cmpl_putfunction lpfc_mbox_cmpl_putfunction lpfc_mbox_cmd_checkfunction lpfc_mbox_dev_checkfunction lpfc_mbox_tmo_valfunction lpfc_sli4_mbx_sge_setfunction lpfc_sli4_mbx_sge_getfunction lpfc_sli4_mbox_cmd_freefunction lpfc_sli4_configfunction lpfc_sli4_mbox_rsrc_extentfunction lpfc_sli_config_mbox_subsys_getfunction lpfc_sli_config_mbox_opcode_get
Annotated Snippet
switch(linkspeed){
case LPFC_USER_LINK_SPEED_1G:
mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED;
mb->un.varInitLnk.link_speed = LINK_SPEED_1G;
break;
case LPFC_USER_LINK_SPEED_2G:
mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED;
mb->un.varInitLnk.link_speed = LINK_SPEED_2G;
break;
case LPFC_USER_LINK_SPEED_4G:
mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED;
mb->un.varInitLnk.link_speed = LINK_SPEED_4G;
break;
case LPFC_USER_LINK_SPEED_8G:
mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED;
mb->un.varInitLnk.link_speed = LINK_SPEED_8G;
break;
case LPFC_USER_LINK_SPEED_10G:
mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED;
mb->un.varInitLnk.link_speed = LINK_SPEED_10G;
break;
case LPFC_USER_LINK_SPEED_16G:
mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED;
mb->un.varInitLnk.link_speed = LINK_SPEED_16G;
break;
case LPFC_USER_LINK_SPEED_32G:
mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED;
mb->un.varInitLnk.link_speed = LINK_SPEED_32G;
break;
case LPFC_USER_LINK_SPEED_64G:
mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED;
mb->un.varInitLnk.link_speed = LINK_SPEED_64G;
break;
case LPFC_USER_LINK_SPEED_128G:
mb->un.varInitLnk.link_flags |= FLAGS_LINK_SPEED;
mb->un.varInitLnk.link_speed = LINK_SPEED_128G;
break;
case LPFC_USER_LINK_SPEED_AUTO:
default:
mb->un.varInitLnk.link_speed = LINK_SPEED_AUTO;
break;
}
}
else
mb->un.varInitLnk.link_speed = LINK_SPEED_AUTO;
mb->mbxCommand = (volatile uint8_t)MBX_INIT_LINK;
mb->mbxOwner = OWN_HOST;
mb->un.varInitLnk.fabric_AL_PA = phba->fc_pref_ALPA;
return;
}
/**
* lpfc_read_sparam - Prepare a mailbox command for reading HBA parameters
* @phba: pointer to lpfc hba data structure.
* @pmb: pointer to the driver internal queue element for mailbox command.
* @vpi: virtual N_Port identifier.
*
* The read service parameter mailbox command is used to read the HBA port
* service parameters. The service parameters are read into the buffer
* specified directly by a BDE in the mailbox command. These service
* parameters may then be used to build the payload of an N_Port/F_POrt
* login request and reply (LOGI/ACC).
*
* This routine prepares the mailbox command for reading HBA port service
* parameters. The DMA memory is allocated in this function and the addresses
* are populated into the mailbox command for the HBA to DMA the service
* parameters into.
*
* Return codes
* 0 - Success
* 1 - DMA memory allocation failed
**/
int
lpfc_read_sparam(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb, int vpi)
{
struct lpfc_dmabuf *mp;
MAILBOX_t *mb;
int rc;
memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
/* Get a buffer to hold the HBAs Service Parameters */
rc = lpfc_mbox_rsrc_prep(phba, pmb);
if (rc) {
lpfc_printf_log(phba, KERN_WARNING, LOG_MBOX,
"0301 READ_SPARAM: no buffers\n");
return 1;
}
Annotation
- Immediate include surface: `linux/blkdev.h`, `linux/pci.h`, `linux/slab.h`, `linux/interrupt.h`, `scsi/scsi_device.h`, `scsi/scsi_transport_fc.h`, `scsi/scsi.h`, `scsi/fc/fc_fs.h`.
- Detected declarations: `function lpfc_mbox_rsrc_prep`, `function lpfc_mbox_rsrc_cleanup`, `function lpfc_dump_static_vport`, `function lpfc_down_link`, `function lpfc_dump_mem`, `function lpfc_dump_wakeup_param`, `function lpfc_read_nv`, `function lpfc_config_async`, `function lpfc_heart_beat`, `function Attention`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.