drivers/infiniband/ulp/rtrs/rtrs-clt.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/ulp/rtrs/rtrs-clt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/ulp/rtrs/rtrs-clt.c- Extension
.c- Size
- 87013 bytes
- Lines
- 3231
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/rculist.hlinux/random.hrtrs-clt.hrtrs-log.hrtrs-clt-trace.h
Detected Declarations
struct path_itfunction rtrs_clt_is_connectedfunction __rtrs_get_permitfunction __rtrs_put_permitfunction rtrs_clt_get_permitfunction rtrs_clt_put_permitfunction rtrs_permit_to_clt_confunction rtrs_clt_change_statefunction rtrs_clt_change_state_from_tofunction rtrs_rdma_error_recoveryfunction rtrs_clt_fast_reg_donefunction rtrs_clt_inv_rkey_donefunction rtrs_inv_rkeyfunction complete_rdma_reqfunction rtrs_post_send_rdmafunction process_io_rspfunction rtrs_clt_recv_donefunction rtrs_clt_rkey_rsp_donefunction rtrs_post_recv_empty_x2function rtrs_clt_rdma_donefunction post_recv_iofunction post_recv_pathfunction list_add_rcufunction get_next_path_rrfunction get_next_path_min_inflightfunction list_for_each_entry_rcufunction get_next_path_min_latencyfunction list_for_each_entry_rcufunction path_it_initfunction path_it_deinitfunction rtrs_clt_init_reqfunction rtrs_clt_get_reqfunction rtrs_clt_get_copy_reqfunction rtrs_post_rdma_write_sgfunction for_each_sgfunction rtrs_map_sg_frfunction rtrs_clt_write_reqfunction rtrs_clt_read_reqfunction rtrs_clt_failover_reqfunction fail_all_outstanding_reqsfunction free_path_reqsfunction alloc_path_reqsfunction alloc_permitsfunction free_permitsfunction query_fast_reg_modefunction rtrs_clt_change_state_get_oldfunction rtrs_clt_hb_err_handlerfunction rtrs_clt_init_hb
Annotated Snippet
err = device_add(&clt->dev);
if (err)
goto err_put;
clt->kobj_paths = kobject_create_and_add("paths", &clt->dev.kobj);
if (!clt->kobj_paths) {
err = -ENOMEM;
goto err_del;
}
err = rtrs_clt_create_sysfs_root_files(clt);
if (err) {
kobject_del(clt->kobj_paths);
kobject_put(clt->kobj_paths);
goto err_del;
}
dev_set_uevent_suppress(&clt->dev, false);
kobject_uevent(&clt->dev.kobj, KOBJ_ADD);
return clt;
err_del:
device_del(&clt->dev);
err_put:
free_percpu(clt->pcpu_path);
put_device(&clt->dev);
return ERR_PTR(err);
}
static void free_clt(struct rtrs_clt_sess *clt)
{
free_percpu(clt->pcpu_path);
/*
* release callback will free clt and destroy mutexes in last put
*/
device_unregister(&clt->dev);
}
/**
* rtrs_clt_open() - Open a path to an RTRS server
* @ops: holds the link event callback and the private pointer.
* @pathname: name of the path to an RTRS server
* @paths: Paths to be established defined by their src and dst addresses
* @paths_num: Number of elements in the @paths array
* @port: port to be used by the RTRS session
* @pdu_sz: Size of extra payload which can be accessed after permit allocation.
* @reconnect_delay_sec: time between reconnect tries
* @max_reconnect_attempts: Number of times to reconnect on error before giving
* up, 0 for * disabled, -1 for forever
* @nr_poll_queues: number of polling mode connection using IB_POLL_DIRECT flag
*
* Starts session establishment with the rtrs_server. The function can block
* up to ~2000ms before it returns.
*
* Return a valid pointer on success otherwise PTR_ERR.
*/
struct rtrs_clt_sess *rtrs_clt_open(struct rtrs_clt_ops *ops,
const char *pathname,
const struct rtrs_addr *paths,
size_t paths_num, u16 port,
size_t pdu_sz, u8 reconnect_delay_sec,
s16 max_reconnect_attempts, u32 nr_poll_queues)
{
struct rtrs_clt_path *clt_path, *tmp;
struct rtrs_clt_sess *clt;
int err, i;
if (strchr(pathname, '/') || strchr(pathname, '.')) {
pr_err("pathname cannot contain / and .\n");
err = -EINVAL;
goto out;
}
clt = alloc_clt(pathname, paths_num, port, pdu_sz, ops->priv,
ops->link_ev,
reconnect_delay_sec,
max_reconnect_attempts);
if (IS_ERR(clt)) {
err = PTR_ERR(clt);
goto out;
}
for (i = 0; i < paths_num; i++) {
struct rtrs_clt_path *clt_path;
clt_path = alloc_path(clt, &paths[i], nr_cpu_ids,
nr_poll_queues);
if (IS_ERR(clt_path)) {
err = PTR_ERR(clt_path);
goto close_all_path;
}
if (!i)
Annotation
- Immediate include surface: `linux/module.h`, `linux/rculist.h`, `linux/random.h`, `rtrs-clt.h`, `rtrs-log.h`, `rtrs-clt-trace.h`.
- Detected declarations: `struct path_it`, `function rtrs_clt_is_connected`, `function __rtrs_get_permit`, `function __rtrs_put_permit`, `function rtrs_clt_get_permit`, `function rtrs_clt_put_permit`, `function rtrs_permit_to_clt_con`, `function rtrs_clt_change_state`, `function rtrs_clt_change_state_from_to`, `function rtrs_rdma_error_recovery`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.