drivers/scsi/libiscsi_tcp.c
Source file repositories/reference/linux-study-clean/drivers/scsi/libiscsi_tcp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/libiscsi_tcp.c- Extension
.c- Size
- 33421 bytes
- Lines
- 1240
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/crc32c.hlinux/types.hlinux/list.hlinux/inet.hlinux/slab.hlinux/file.hlinux/blkdev.hlinux/delay.hlinux/kfifo.hlinux/scatterlist.hlinux/module.hnet/tcp.hscsi/scsi_cmnd.hscsi/scsi_device.hscsi/scsi_host.hscsi/scsi.hscsi/scsi_transport_iscsi.htrace/events/iscsi.hiscsi_tcp.h
Detected Declarations
function iscsi_tcp_segment_init_sgfunction iscsi_tcp_segment_mapfunction iscsi_tcp_segment_unmapfunction iscsi_tcp_segment_splice_digestfunction iscsi_tcp_segment_donefunction iscsi_tcp_segment_recvfunction iscsi_tcp_dgst_headerfunction iscsi_tcp_dgst_verifyfunction __iscsi_segment_initfunction iscsi_segment_init_linearfunction iscsi_segment_seek_sgfunction iscsi_tcp_hdr_recv_prepfunction iscsi_tcp_data_recv_donefunction iscsi_tcp_data_recv_prepfunction iscsi_tcp_cleanup_taskfunction iscsi_tcp_data_infunction iscsi_tcp_r2t_rspfunction iscsi_tcp_process_data_infunction iscsi_tcp_hdr_dissectfunction iscsi_tcp_hdr_recv_donefunction iscsi_tcp_recv_segment_is_hdrfunction iscsi_tcp_recv_skbfunction iscsi_tcp_task_initfunction iscsi_tcp_task_xmitfunction iscsi_tcp_conn_setupfunction iscsi_tcp_conn_teardownfunction iscsi_tcp_r2tpool_allocfunction data_xmitfunction iscsi_tcp_r2tpool_freefunction iscsi_tcp_set_max_r2tfunction iscsi_tcp_conn_get_statsexport iscsi_tcp_segment_unmapexport iscsi_tcp_segment_doneexport iscsi_tcp_dgst_headerexport iscsi_segment_init_linearexport iscsi_segment_seek_sgexport iscsi_tcp_hdr_recv_prepexport iscsi_tcp_cleanup_taskexport iscsi_tcp_recv_segment_is_hdrexport iscsi_tcp_recv_skbexport iscsi_tcp_task_initexport iscsi_tcp_task_xmitexport iscsi_tcp_conn_setupexport iscsi_tcp_conn_teardownexport iscsi_tcp_r2tpool_allocexport iscsi_tcp_r2tpool_freeexport iscsi_tcp_set_max_r2texport iscsi_tcp_conn_get_stats
Annotated Snippet
if (segment->data) {
*segment->crcp = crc32c(*segment->crcp,
segment->data + segment->copied,
copied);
} else {
const void *data;
data = kmap_local_page(sg_page(segment->sg));
*segment->crcp = crc32c(*segment->crcp,
data + segment->copied +
segment->sg_offset +
segment->sg->offset,
copied);
kunmap_local(data);
}
}
segment->copied += copied;
if (segment->copied < segment->size) {
iscsi_tcp_segment_map(segment, recv);
return 0;
}
segment->total_copied += segment->copied;
segment->copied = 0;
segment->size = 0;
/* Unmap the current scatterlist page, if there is one. */
iscsi_tcp_segment_unmap(segment);
/* Do we have more scatterlist entries? */
ISCSI_DBG_TCP(tcp_conn->iscsi_conn, "total copied %u total size %u\n",
segment->total_copied, segment->total_size);
if (segment->total_copied < segment->total_size) {
/* Proceed to the next entry in the scatterlist. */
iscsi_tcp_segment_init_sg(segment, sg_next(segment->sg),
0);
iscsi_tcp_segment_map(segment, recv);
BUG_ON(segment->size == 0);
return 0;
}
/* Do we need to handle padding? */
if (!(tcp_conn->iscsi_conn->session->tt->caps & CAP_PADDING_OFFLOAD)) {
pad = iscsi_padding(segment->total_copied);
if (pad != 0) {
ISCSI_DBG_TCP(tcp_conn->iscsi_conn,
"consume %d pad bytes\n", pad);
segment->total_size += pad;
segment->size = pad;
segment->data = segment->padbuf;
return 0;
}
}
/*
* Set us up for transferring the data digest. hdr digest
* is completely handled in hdr done function.
*/
if (segment->crcp) {
put_unaligned_le32(~*segment->crcp, segment->digest);
iscsi_tcp_segment_splice_digest(segment,
recv ? segment->recv_digest : segment->digest);
return 0;
}
return 1;
}
EXPORT_SYMBOL_GPL(iscsi_tcp_segment_done);
/**
* iscsi_tcp_segment_recv - copy data to segment
* @tcp_conn: the iSCSI TCP connection
* @segment: the buffer to copy to
* @ptr: data pointer
* @len: amount of data available
*
* This function copies up to @len bytes to the
* given buffer, and returns the number of bytes
* consumed, which can actually be less than @len.
*
* If CRC is enabled, the function will update the CRC while copying.
* Combining these two operations doesn't buy us a lot (yet),
* but in the future we could implement combined copy+crc,
* just way we do for network layer checksums.
*/
static int
iscsi_tcp_segment_recv(struct iscsi_tcp_conn *tcp_conn,
struct iscsi_segment *segment, const void *ptr,
unsigned int len)
Annotation
- Immediate include surface: `linux/crc32c.h`, `linux/types.h`, `linux/list.h`, `linux/inet.h`, `linux/slab.h`, `linux/file.h`, `linux/blkdev.h`, `linux/delay.h`.
- Detected declarations: `function iscsi_tcp_segment_init_sg`, `function iscsi_tcp_segment_map`, `function iscsi_tcp_segment_unmap`, `function iscsi_tcp_segment_splice_digest`, `function iscsi_tcp_segment_done`, `function iscsi_tcp_segment_recv`, `function iscsi_tcp_dgst_header`, `function iscsi_tcp_dgst_verify`, `function __iscsi_segment_init`, `function iscsi_segment_init_linear`.
- 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.