drivers/target/target_core_fabric_lib.c
Source file repositories/reference/linux-study-clean/drivers/target/target_core_fabric_lib.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/target/target_core_fabric_lib.c- Extension
.c- Size
- 11764 bytes
- Lines
- 454
- Domain
- Driver Families
- Bucket
- drivers/target
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/hex.hlinux/kernel.hlinux/string.hlinux/ctype.hlinux/spinlock.hlinux/export.hlinux/unaligned.hscsi/scsi_proto.htarget/target_core_base.htarget/target_core_fabric.htarget_core_internal.htarget_core_pr.h
Detected Declarations
function sas_get_pr_transport_idfunction fc_get_pr_transport_idfunction sbp_get_pr_transport_idfunction srp_get_pr_transport_idfunction iscsi_get_pr_transport_idfunction iscsi_get_pr_transport_id_lenfunction sas_parse_pr_out_transport_idfunction srp_parse_pr_out_transport_idfunction fcp_parse_pr_out_transport_idfunction sbp_parse_pr_out_transport_idfunction iscsi_parse_pr_out_transport_idfunction portfunction target_get_pr_transport_id_lenfunction target_get_pr_transport_idfunction target_parse_pr_out_transport_id
Annotated Snippet
if (!strncmp(&ptr[i], ":", 1)) {
i++;
continue;
}
ret = hex2bin(&buf[off++], &ptr[i], 1);
if (ret < 0) {
pr_debug("%s: invalid hex string\n", __func__);
return ret;
}
i += 2;
}
/*
* The FC Transport ID is a hardcoded 24-byte length
*/
return 24;
}
static int sbp_get_pr_transport_id(
struct se_node_acl *nacl,
int *format_code,
unsigned char *buf)
{
int ret;
ret = hex2bin(&buf[8], nacl->initiatorname, 8);
if (ret) {
pr_debug("%s: invalid hex string\n", __func__);
return ret;
}
return 24;
}
static int srp_get_pr_transport_id(
struct se_node_acl *nacl,
int *format_code,
unsigned char *buf)
{
const char *p;
unsigned len, count, leading_zero_bytes;
int rc;
p = nacl->initiatorname;
if (strncasecmp(p, "0x", 2) == 0)
p += 2;
len = strlen(p);
if (len % 2)
return -EINVAL;
count = min(len / 2, 16U);
leading_zero_bytes = 16 - count;
memset(buf + 8, 0, leading_zero_bytes);
rc = hex2bin(buf + 8 + leading_zero_bytes, p, count);
if (rc < 0) {
pr_debug("hex2bin failed for %s: %d\n", p, rc);
return rc;
}
return 24;
}
static int iscsi_get_pr_transport_id(
struct se_node_acl *se_nacl,
struct t10_pr_registration *pr_reg,
int *format_code,
unsigned char *buf)
{
u32 off = 4, padding = 0;
int isid_len;
u16 len = 0;
spin_lock_irq(&se_nacl->nacl_sess_lock);
/*
* Only null terminate the last field.
*
* From spc4r37 section 7.6.4.6: TransportID for initiator ports using
* SCSI over iSCSI.
*
* Table 507 TPID=0 Initiator device TransportID
*
* The null-terminated, null-padded (see 4.3.2) ISCSI NAME field shall
* contain the iSCSI name of an iSCSI initiator node (see RFC 7143).
* The first ISCSI NAME field byte containing an ASCII null character
* terminates the ISCSI NAME field without regard for the specified
* length of the iSCSI TransportID or the contents of the ADDITIONAL
* LENGTH field.
*/
len = sprintf(&buf[off], "%s", se_nacl->initiatorname);
off += len;
if ((*format_code == 1) && (pr_reg->isid_present_at_reg)) {
Annotation
- Immediate include surface: `linux/hex.h`, `linux/kernel.h`, `linux/string.h`, `linux/ctype.h`, `linux/spinlock.h`, `linux/export.h`, `linux/unaligned.h`, `scsi/scsi_proto.h`.
- Detected declarations: `function sas_get_pr_transport_id`, `function fc_get_pr_transport_id`, `function sbp_get_pr_transport_id`, `function srp_get_pr_transport_id`, `function iscsi_get_pr_transport_id`, `function iscsi_get_pr_transport_id_len`, `function sas_parse_pr_out_transport_id`, `function srp_parse_pr_out_transport_id`, `function fcp_parse_pr_out_transport_id`, `function sbp_parse_pr_out_transport_id`.
- Atlas domain: Driver Families / drivers/target.
- Implementation status: source 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.