drivers/scsi/lpfc/lpfc_bsg.c
Source file repositories/reference/linux-study-clean/drivers/scsi/lpfc/lpfc_bsg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/lpfc/lpfc_bsg.c- Extension
.c- Size
- 166613 bytes
- Lines
- 5891
- 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/interrupt.hlinux/mempool.hlinux/pci.hlinux/slab.hlinux/delay.hlinux/list.hlinux/bsg-lib.hlinux/vmalloc.hscsi/scsi.hscsi/scsi_host.hscsi/scsi_transport_fc.hscsi/scsi_bsg_fc.hscsi/fc/fc_fs.hlpfc_hw4.hlpfc_hw.hlpfc_sli.hlpfc_sli4.hlpfc_nl.hlpfc_bsg.hlpfc_disc.hlpfc_scsi.hlpfc.hlpfc_logmsg.hlpfc_crtn.hlpfc_debugfs.hlpfc_vport.hlpfc_version.h
Detected Declarations
struct lpfc_bsg_eventstruct lpfc_bsg_iocbstruct lpfc_bsg_mboxstruct bsg_job_datastruct event_datastruct lpfc_dmabufextenum ELX_LOOPBACK_CMDfunction lpfc_free_bsg_buffersfunction lpfc_alloc_bsg_buffersfunction lpfc_bsg_copy_datafunction lpfc_bsg_send_mgmt_cmd_cmpfunction lpfc_bsg_send_mgmt_cmdfunction lpfc_bsg_rport_els_cmpfunction lpfc_bsg_rport_elsfunction lpfc_bsg_event_freefunction lpfc_bsg_event_reffunction lpfc_bsg_event_unreffunction lpfc_bsg_event_newfunction diag_cmd_data_freefunction list_for_each_safefunction lpfc_bsg_ct_unsol_eventfunction list_for_each_entryfunction list_for_each_entryfunction lpfc_bsg_ct_unsol_abortfunction lpfc_bsg_hba_set_eventfunction lpfc_bsg_hba_get_eventfunction lpfc_issue_ct_rsp_cmpfunction lpfc_issue_ct_rspfunction lpfc_bsg_send_mgmt_rspfunction lpfc_bsg_diag_mode_enterfunction lpfc_bsg_diag_mode_exitfunction lpfc_sli3_bsg_diag_loopback_modefunction lpfc_sli4_bsg_set_link_diag_statefunction lpfc_sli4_bsg_set_loopback_modefunction lpfc_sli4_diag_fcport_reg_setupfunction lpfc_sli4_bsg_diag_loopback_modefunction lpfc_bsg_diag_loopback_modefunction lpfc_sli4_bsg_diag_mode_endfunction lpfc_sli4_bsg_link_diag_testfunction lpfcdiag_loop_self_regfunction lpfcdiag_loop_self_unregfunction lpfcdiag_loop_get_xrifunction BSG_MBOX_SIZEfunction lpfc_bsg_dma_page_freefunction lpfc_bsg_dma_page_list_freefunction list_for_each_entry_safefunction diag_cmd_data_allocfunction lpfcdiag_sli3_loop_post_rxbufs
Annotated Snippet
struct lpfc_bsg_event {
struct list_head node;
struct kref kref;
wait_queue_head_t wq;
/* Event type and waiter identifiers */
uint32_t type_mask;
uint32_t req_id;
uint32_t reg_id;
/* next two flags are here for the auto-delete logic */
unsigned long wait_time_stamp;
int waiting;
/* seen and not seen events */
struct list_head events_to_get;
struct list_head events_to_see;
/* driver data associated with the job */
void *dd_data;
};
struct lpfc_bsg_iocb {
struct lpfc_iocbq *cmdiocbq;
struct lpfc_dmabuf *rmp;
struct lpfc_nodelist *ndlp;
};
struct lpfc_bsg_mbox {
LPFC_MBOXQ_t *pmboxq;
MAILBOX_t *mb;
struct lpfc_dmabuf *dmabuffers; /* for BIU diags */
uint8_t *ext; /* extended mailbox data */
uint32_t mbOffset; /* from app */
uint32_t inExtWLen; /* from app */
uint32_t outExtWLen; /* from app */
};
#define TYPE_EVT 1
#define TYPE_IOCB 2
#define TYPE_MBOX 3
struct bsg_job_data {
uint32_t type;
struct bsg_job *set_job; /* job waiting for this iocb to finish */
union {
struct lpfc_bsg_event *evt;
struct lpfc_bsg_iocb iocb;
struct lpfc_bsg_mbox mbox;
} context_un;
};
struct event_data {
struct list_head node;
uint32_t type;
uint32_t immed_dat;
void *data;
uint32_t len;
};
#define BUF_SZ_4K 4096
#define SLI_CT_ELX_LOOPBACK 0x10
enum ELX_LOOPBACK_CMD {
ELX_LOOPBACK_XRI_SETUP,
ELX_LOOPBACK_DATA,
};
#define ELX_LOOPBACK_HEADER_SZ \
(size_t)(&((struct lpfc_sli_ct_request *)NULL)->un)
/* For non-embedded read object command */
#define READ_OBJ_EMB0_SCHEME_0 {1, 10, 256, 128}
#define READ_OBJ_EMB0_SCHEME_1 {11, LPFC_EMB0_MAX_RD_OBJ_HBD_CNT, 512, 192}
static const struct lpfc_read_object_cmd_scheme {
u32 min_hbd_cnt;
u32 max_hbd_cnt;
u32 cmd_size;
u32 payload_word_offset;
} rd_obj_scheme[2] = {READ_OBJ_EMB0_SCHEME_0, READ_OBJ_EMB0_SCHEME_1};
struct lpfc_dmabufext {
struct lpfc_dmabuf dma;
uint32_t size;
uint32_t flag;
};
static void
lpfc_free_bsg_buffers(struct lpfc_hba *phba, struct lpfc_dmabuf *mlist)
{
struct lpfc_dmabuf *mlast, *next_mlast;
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/mempool.h`, `linux/pci.h`, `linux/slab.h`, `linux/delay.h`, `linux/list.h`, `linux/bsg-lib.h`, `linux/vmalloc.h`.
- Detected declarations: `struct lpfc_bsg_event`, `struct lpfc_bsg_iocb`, `struct lpfc_bsg_mbox`, `struct bsg_job_data`, `struct event_data`, `struct lpfc_dmabufext`, `enum ELX_LOOPBACK_CMD`, `function lpfc_free_bsg_buffers`, `function lpfc_alloc_bsg_buffers`, `function lpfc_bsg_copy_data`.
- 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.