drivers/nvme/host/tcp.c
Source file repositories/reference/linux-study-clean/drivers/nvme/host/tcp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvme/host/tcp.c- Extension
.c- Size
- 80641 bytes
- Lines
- 3100
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/init.hlinux/slab.hlinux/err.hlinux/crc32.hlinux/nvme-tcp.hlinux/nvme-keyring.hnet/sock.hnet/tcp.hnet/tls.hnet/tls_prot.hnet/handshake.hlinux/blk-mq.hnet/busy_poll.htrace/events/sock.hnvme.hfabrics.h
Detected Declarations
struct nvme_tcp_queuestruct nvme_tcp_requeststruct nvme_tcp_ctrlstruct nvme_tcp_queuestruct nvme_tcp_ctrlenum nvme_tcp_send_stateenum nvme_tcp_queue_flagsenum nvme_tcp_recv_statefunction nvme_tcp_reclassify_socketfunction nvme_tcp_queue_idfunction nvme_tcp_recv_pdu_supportedfunction nvme_tcp_queue_tlsfunction nvme_tcp_tls_configuredfunction nvme_tcp_hdgst_lenfunction nvme_tcp_ddgst_lenfunction nvme_tcp_inline_data_sizefunction nvme_tcp_async_reqfunction nvme_tcp_has_inline_datafunction nvme_tcp_req_cur_offsetfunction nvme_tcp_req_cur_lengthfunction nvme_tcp_pdu_data_leftfunction nvme_tcp_pdu_last_sendfunction nvme_tcp_init_iterfunction nvme_tcp_advance_reqfunction nvme_tcp_send_allfunction nvme_tcp_queue_has_pendingfunction nvme_tcp_queue_morefunction nvme_tcp_queue_requestfunction nvme_tcp_process_req_listfunction nvme_tcp_fetch_requestfunction nvme_tcp_ddgst_updatefunction nvme_tcp_ddgst_finalfunction nvme_tcp_hdgstfunction nvme_tcp_set_hdgstfunction nvme_tcp_verify_hdgstfunction nvme_tcp_check_ddgstfunction nvme_tcp_exit_requestfunction nvme_tcp_init_requestfunction nvme_tcp_init_hctxfunction nvme_tcp_init_admin_hctxfunction nvme_tcp_recv_statefunction nvme_tcp_init_recv_ctxfunction nvme_tcp_error_recoveryfunction nvme_tcp_process_nvme_cqefunction nvme_tcp_handle_c2h_datafunction nvme_tcp_handle_compfunction nvme_tcp_setup_h2c_data_pdufunction nvme_tcp_handle_r2t
Annotated Snippet
static const struct blk_mq_ops nvme_tcp_mq_ops;
static const struct blk_mq_ops nvme_tcp_admin_mq_ops;
static int nvme_tcp_try_send(struct nvme_tcp_queue *queue);
#ifdef CONFIG_DEBUG_LOCK_ALLOC
/* lockdep can detect a circular dependency of the form
* sk_lock -> mmap_lock (page fault) -> fs locks -> sk_lock
* because dependencies are tracked for both nvme-tcp and user contexts. Using
* a separate class prevents lockdep from conflating nvme-tcp socket use with
* user-space socket API use.
*/
static void nvme_tcp_reclassify_socket(struct nvme_tcp_queue *queue)
{
struct sock *sk = queue->sock->sk;
if (WARN_ON_ONCE(!sock_allow_reclassification(sk)))
return;
switch (sk->sk_family) {
case AF_INET:
sock_lock_init_class_and_name(sk, "slock-AF_INET-NVME",
&queue->nvme_tcp_slock_key,
"sk_lock-AF_INET-NVME",
&queue->nvme_tcp_sk_key);
break;
case AF_INET6:
sock_lock_init_class_and_name(sk, "slock-AF_INET6-NVME",
&queue->nvme_tcp_slock_key,
"sk_lock-AF_INET6-NVME",
&queue->nvme_tcp_sk_key);
break;
default:
WARN_ON_ONCE(1);
}
}
#endif
static inline struct nvme_tcp_ctrl *to_tcp_ctrl(struct nvme_ctrl *ctrl)
{
return container_of(ctrl, struct nvme_tcp_ctrl, ctrl);
}
static inline int nvme_tcp_queue_id(struct nvme_tcp_queue *queue)
{
return queue - queue->ctrl->queues;
}
static inline bool nvme_tcp_recv_pdu_supported(enum nvme_tcp_pdu_type type)
{
switch (type) {
case nvme_tcp_c2h_term:
case nvme_tcp_c2h_data:
case nvme_tcp_r2t:
case nvme_tcp_rsp:
return true;
default:
return false;
}
}
/*
* Check if the queue is TLS encrypted
*/
static inline bool nvme_tcp_queue_tls(struct nvme_tcp_queue *queue)
{
if (!IS_ENABLED(CONFIG_NVME_TCP_TLS))
return 0;
return queue->tls_enabled;
}
/*
* Check if TLS is configured for the controller.
*/
static inline bool nvme_tcp_tls_configured(struct nvme_ctrl *ctrl)
{
if (!IS_ENABLED(CONFIG_NVME_TCP_TLS))
return 0;
return ctrl->opts->tls || ctrl->opts->concat;
}
static inline struct blk_mq_tags *nvme_tcp_tagset(struct nvme_tcp_queue *queue)
{
u32 queue_idx = nvme_tcp_queue_id(queue);
if (queue_idx == 0)
return queue->ctrl->admin_tag_set.tags[queue_idx];
return queue->ctrl->tag_set.tags[queue_idx - 1];
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/slab.h`, `linux/err.h`, `linux/crc32.h`, `linux/nvme-tcp.h`, `linux/nvme-keyring.h`, `net/sock.h`.
- Detected declarations: `struct nvme_tcp_queue`, `struct nvme_tcp_request`, `struct nvme_tcp_ctrl`, `struct nvme_tcp_queue`, `struct nvme_tcp_ctrl`, `enum nvme_tcp_send_state`, `enum nvme_tcp_queue_flags`, `enum nvme_tcp_recv_state`, `function nvme_tcp_reclassify_socket`, `function nvme_tcp_queue_id`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: pattern 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.