drivers/target/target_core_spc.c
Source file repositories/reference/linux-study-clean/drivers/target/target_core_spc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/target/target_core_spc.c- Extension
.c- Size
- 71466 bytes
- Lines
- 2565
- Domain
- Driver Families
- Bucket
- drivers/target
- 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/hex.hlinux/kernel.hlinux/module.hlinux/unaligned.hscsi/scsi_proto.hscsi/scsi_common.hscsi/scsi_tcq.htarget/target_core_base.htarget/target_core_backend.htarget/target_core_fabric.htarget_core_internal.htarget_core_alua.htarget_core_pr.htarget_core_ua.htarget_core_xcopy.h
Detected Declarations
function Commandsfunction spc_find_scsi_transport_vdfunction spc_emulate_inquiry_stdfunction Protectionfunction spc_emulate_evpd_80function spc_gen_naa_6h_vendor_specificfunction spc_emulate_evpd_83function spc_emulate_evpd_86function spc_emulate_evpd_b0function spc_emulate_evpd_b1function spc_emulate_evpd_b2function spc_emulate_evpd_b3function spc_emulate_evpd_00function spc_emulate_inquiryfunction spc_modesense_rwrecoveryfunction spc_modesense_controlfunction controlfunction Ownerfunction spc_modesense_cachingfunction spc_modesense_informational_exceptionsfunction spc_modesense_write_protectfunction spc_modesense_dpofuafunction spc_modesense_blockdescfunction spc_modesense_long_blockdescfunction spc_emulate_modesensefunction spc_emulate_modeselectfunction spc_emulate_request_sensefunction spc_emulate_report_lunsfunction spc_emulate_testunitreadyfunction set_dpofua_usage_bitsfunction set_dpofua_usage_bits32function tcm_is_ws_enabledfunction tcm_is_atomic_enabledfunction tcm_is_caw_enabledfunction tcm_is_rep_ref_enabledfunction tcm_is_unmap_enabledfunction tcm_is_pr_enabledfunction tcm_is_3pc_enabledfunction spc_rsoc_enabledfunction tcm_is_set_tpg_enabledfunction spc_rsoc_encode_command_timeouts_descriptorfunction spc_rsoc_encode_command_descriptorfunction spc_rsoc_encode_one_command_descriptorfunction spc_rsoc_get_descrfunction spc_emulate_report_supp_op_codesfunction spc_fill_pd_text_id_infofunction spc_emulate_report_id_infofunction spc_parse_cdb
Annotated Snippet
if (next) {
next = false;
buf[off++] |= val;
} else {
next = true;
buf[off] = val << 4;
}
}
}
/*
* Device identification VPD, for a complete list of
* DESIGNATOR TYPEs see spc4r17 Table 459.
*/
sense_reason_t
spc_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf)
{
struct se_device *dev = cmd->se_dev;
struct se_lun *lun = cmd->se_lun;
struct se_portal_group *tpg = NULL;
struct t10_alua_lu_gp_member *lu_gp_mem;
struct t10_alua_tg_pt_gp *tg_pt_gp;
unsigned char *prod = &dev->t10_wwn.model[0];
u32 off = 0;
u16 len = 0, id_len;
off = 4;
/*
* NAA IEEE Registered Extended Assigned designator format, see
* spc4r17 section 7.7.3.6.5
*
* We depend upon a target_core_mod/ConfigFS provided
* /sys/kernel/config/target/core/$HBA/$DEV/wwn/vpd_unit_serial
* value in order to return the NAA id.
*/
if (!(dev->dev_flags & DF_EMULATED_VPD_UNIT_SERIAL))
goto check_t10_vend_desc;
/* CODE SET == Binary */
buf[off++] = 0x1;
/* Set ASSOCIATION == addressed logical unit: 0)b */
buf[off] = 0x00;
/* Identifier/Designator type == NAA identifier */
buf[off++] |= 0x3;
off++;
/* Identifier/Designator length */
buf[off++] = 0x10;
/* NAA IEEE Registered Extended designator */
spc_gen_naa_6h_vendor_specific(dev, &buf[off]);
len = 20;
off = (len + 4);
check_t10_vend_desc:
/*
* T10 Vendor Identifier Page, see spc4r17 section 7.7.3.4
*/
id_len = 8; /* For Vendor field */
if (dev->dev_flags & DF_EMULATED_VPD_UNIT_SERIAL)
id_len += sprintf(&buf[off+12], "%s:%s", prod,
&dev->t10_wwn.unit_serial[0]);
buf[off] = 0x2; /* ASCII */
buf[off+1] = 0x1; /* T10 Vendor ID */
buf[off+2] = 0x0;
/* left align Vendor ID and pad with spaces */
memset(&buf[off+4], 0x20, INQUIRY_VENDOR_LEN);
memcpy(&buf[off+4], dev->t10_wwn.vendor,
strnlen(dev->t10_wwn.vendor, INQUIRY_VENDOR_LEN));
/* Extra Byte for NULL Terminator */
id_len++;
/* Identifier Length */
buf[off+3] = id_len;
/* Header size for Designation descriptor */
len += (id_len + 4);
off += (id_len + 4);
if (1) {
struct t10_alua_lu_gp *lu_gp;
u32 padding, scsi_name_len, scsi_target_len;
u16 lu_gp_id = 0;
u16 tg_pt_gp_id = 0;
u16 tpgt;
tpg = lun->lun_tpg;
Annotation
- Immediate include surface: `linux/hex.h`, `linux/kernel.h`, `linux/module.h`, `linux/unaligned.h`, `scsi/scsi_proto.h`, `scsi/scsi_common.h`, `scsi/scsi_tcq.h`, `target/target_core_base.h`.
- Detected declarations: `function Commands`, `function spc_find_scsi_transport_vd`, `function spc_emulate_inquiry_std`, `function Protection`, `function spc_emulate_evpd_80`, `function spc_gen_naa_6h_vendor_specific`, `function spc_emulate_evpd_83`, `function spc_emulate_evpd_86`, `function spc_emulate_evpd_b0`, `function spc_emulate_evpd_b1`.
- Atlas domain: Driver Families / drivers/target.
- 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.