drivers/scsi/libfc/fc_fcp.c
Source file repositories/reference/linux-study-clean/drivers/scsi/libfc/fc_fcp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/libfc/fc_fcp.c- Extension
.c- Size
- 61399 bytes
- Lines
- 2321
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/module.hlinux/delay.hlinux/kernel.hlinux/types.hlinux/spinlock.hlinux/scatterlist.hlinux/err.hlinux/crc32.hlinux/slab.hscsi/scsi_tcq.hscsi/scsi.hscsi/scsi_host.hscsi/scsi_device.hscsi/scsi_cmnd.hscsi/fc/fc_fc2.hscsi/libfc.hfc_encode.hfc_libfc.h
Detected Declarations
struct fc_fcp_internalfunction fc_fcp_pkt_allocfunction fc_fcp_pkt_releasefunction fc_fcp_pkt_holdfunction fc_fcp_pkt_destroyfunction fc_fcp_lock_pktfunction fc_fcp_unlock_pktfunction fc_fcp_timer_setfunction fc_fcp_abort_donefunction fc_fcp_send_abortfunction fc_seq_exch_abortfunction fc_fcp_retry_cmdfunction fc_fcp_ddp_setupfunction fc_fcp_ddp_donefunction fc_fcp_can_queue_ramp_upfunction fc_fcp_can_queue_ramp_downfunction fc_fcp_frame_allocfunction get_fsp_rec_tovfunction fc_fcp_recv_datafunction fc_fcp_send_datafunction fc_fcp_abts_respfunction fc_fcp_recvfunction fc_fcp_respfunction fc_fcp_complete_lockedfunction fc_fcp_cleanup_cmdfunction fc_fcp_cleanup_each_cmdfunction fc_fcp_abort_iofunction fc_fcp_pkt_sendfunction fc_fcp_cmd_sendfunction fc_fcp_errorfunction fc_fcp_pkt_abortfunction fc_lun_reset_sendfunction fc_lun_resetfunction fc_tm_donefunction fc_fcp_cleanupfunction fc_fcp_timeoutfunction fc_fcp_recfunction fc_fcp_rec_respfunction fc_fcp_rec_errorfunction fc_fcp_recoveryfunction fc_fcp_srrfunction fc_fcp_srr_respfunction fc_fcp_srr_errorfunction fc_fcp_lport_queue_readyfunction fc_queuecommandfunction fc_io_complfunction fc_eh_abortfunction fc_eh_device_reset
Annotated Snippet
struct fc_fcp_internal {
mempool_t *scsi_pkt_pool;
spinlock_t scsi_queue_lock;
struct list_head scsi_pkt_queue;
unsigned long last_can_queue_ramp_down_time;
unsigned long last_can_queue_ramp_up_time;
int max_can_queue;
};
#define fc_get_scsi_internal(x) ((struct fc_fcp_internal *)(x)->scsi_priv)
/*
* function prototypes
* FC scsi I/O related functions
*/
static void fc_fcp_recv_data(struct fc_fcp_pkt *, struct fc_frame *);
static void fc_fcp_recv(struct fc_seq *, struct fc_frame *, void *);
static void fc_fcp_resp(struct fc_fcp_pkt *, struct fc_frame *);
static void fc_fcp_complete_locked(struct fc_fcp_pkt *);
static void fc_tm_done(struct fc_seq *, struct fc_frame *, void *);
static void fc_fcp_error(struct fc_fcp_pkt *, struct fc_frame *);
static void fc_fcp_recovery(struct fc_fcp_pkt *, u8 code);
static void fc_fcp_timeout(struct timer_list *);
static void fc_fcp_rec(struct fc_fcp_pkt *);
static void fc_fcp_rec_error(struct fc_fcp_pkt *, struct fc_frame *);
static void fc_fcp_rec_resp(struct fc_seq *, struct fc_frame *, void *);
static void fc_io_compl(struct fc_fcp_pkt *);
static void fc_fcp_srr(struct fc_fcp_pkt *, enum fc_rctl, u32);
static void fc_fcp_srr_resp(struct fc_seq *, struct fc_frame *, void *);
static void fc_fcp_srr_error(struct fc_fcp_pkt *, struct fc_frame *);
/*
* command status codes
*/
#define FC_COMPLETE 0
#define FC_CMD_ABORTED 1
#define FC_CMD_RESET 2
#define FC_CMD_PLOGO 3
#define FC_SNS_RCV 4
#define FC_TRANS_ERR 5
#define FC_DATA_OVRRUN 6
#define FC_DATA_UNDRUN 7
#define FC_ERROR 8
#define FC_HRD_ERROR 9
#define FC_CRC_ERROR 10
#define FC_TIMED_OUT 11
#define FC_TRANS_RESET 12
/*
* Error recovery timeout values.
*/
#define FC_SCSI_TM_TOV (10 * HZ)
#define FC_HOST_RESET_TIMEOUT (30 * HZ)
#define FC_CAN_QUEUE_PERIOD (60 * HZ)
#define FC_MAX_ERROR_CNT 5
#define FC_MAX_RECOV_RETRY 3
#define FC_FCP_DFLT_QUEUE_DEPTH 32
/**
* fc_fcp_pkt_alloc() - Allocate a fcp_pkt
* @lport: The local port that the FCP packet is for
* @gfp: GFP flags for allocation
*
* Return value: fcp_pkt structure or null on allocation failure.
* Context: Can be called from process context, no lock is required.
*/
static struct fc_fcp_pkt *fc_fcp_pkt_alloc(struct fc_lport *lport, gfp_t gfp)
{
struct fc_fcp_internal *si = fc_get_scsi_internal(lport);
struct fc_fcp_pkt *fsp;
fsp = mempool_alloc(si->scsi_pkt_pool, gfp);
if (fsp) {
memset(fsp, 0, sizeof(*fsp));
fsp->lp = lport;
fsp->xfer_ddp = FC_XID_UNKNOWN;
refcount_set(&fsp->ref_cnt, 1);
timer_setup(&fsp->timer, NULL, 0);
INIT_LIST_HEAD(&fsp->list);
spin_lock_init(&fsp->scsi_pkt_lock);
} else {
this_cpu_inc(lport->stats->FcpPktAllocFails);
}
return fsp;
}
/**
Annotation
- Immediate include surface: `linux/module.h`, `linux/delay.h`, `linux/kernel.h`, `linux/types.h`, `linux/spinlock.h`, `linux/scatterlist.h`, `linux/err.h`, `linux/crc32.h`.
- Detected declarations: `struct fc_fcp_internal`, `function fc_fcp_pkt_alloc`, `function fc_fcp_pkt_release`, `function fc_fcp_pkt_hold`, `function fc_fcp_pkt_destroy`, `function fc_fcp_lock_pkt`, `function fc_fcp_unlock_pkt`, `function fc_fcp_timer_set`, `function fc_fcp_abort_done`, `function fc_fcp_send_abort`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.