drivers/infiniband/core/uverbs_uapi.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/core/uverbs_uapi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/core/uverbs_uapi.c- Extension
.c- Size
- 18989 bytes
- Lines
- 750
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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
rdma/uverbs_ioctl.hrdma/rdma_user_ioctl.hlinux/bitops.hrdma_core.huverbs.h
Detected Declarations
function Copyrightfunction uapi_create_writefunction uapi_merge_methodfunction uapi_merge_obj_treefunction uapi_disable_elmfunction uapi_merge_deffunction uapi_finalize_ioctl_methodfunction uapi_key_attrs_startfunction uapi_finalizefunction radix_tree_for_each_slotfunction radix_tree_for_each_slotfunction uapi_remove_rangefunction radix_tree_for_each_slotfunction uapi_remove_objectfunction uapi_remove_methodfunction uapi_get_obj_idfunction uapi_key_okayfunction uapi_finalize_disablefunction uverbs_destroy_apifunction uverbs_disassociate_api_prefunction radix_tree_for_each_slotfunction uverbs_disassociate_apifunction radix_tree_for_each_slot
Annotated Snippet
* struct file_operations.owner to prevent the driver module
* code from unloading while the file is open. This provides
* enough safety that uverbs_uobject_fd_release() will
* continue to work. Drivers using FD are responsible to
* handle disassociation of the device on their own.
*/
if (WARN_ON(is_driver &&
obj->type_attrs->type_class != &uverbs_idr_class &&
obj->type_attrs->type_class != &uverbs_fd_class))
return -EINVAL;
}
if (!obj->methods)
return 0;
for (i = 0; i != obj->num_methods; i++) {
const struct uverbs_method_def *method = (*obj->methods)[i];
if (!method)
continue;
rc = uapi_merge_method(uapi, obj_elm, obj_key, method,
is_driver);
if (rc)
return rc;
}
return 0;
}
static int uapi_disable_elm(struct uverbs_api *uapi,
const struct uapi_definition *def,
u32 obj_key,
u32 method_key)
{
bool exists;
if (def->scope == UAPI_SCOPE_OBJECT) {
struct uverbs_api_object *obj_elm;
obj_elm = uapi_add_get_elm(
uapi, obj_key, sizeof(*obj_elm), &exists);
if (IS_ERR(obj_elm))
return PTR_ERR(obj_elm);
obj_elm->disabled = 1;
return 0;
}
if (def->scope == UAPI_SCOPE_METHOD &&
uapi_key_is_ioctl_method(method_key)) {
struct uverbs_api_ioctl_method *method_elm;
method_elm = uapi_add_get_elm(uapi, method_key,
sizeof(*method_elm), &exists);
if (IS_ERR(method_elm))
return PTR_ERR(method_elm);
method_elm->disabled = 1;
return 0;
}
if (def->scope == UAPI_SCOPE_METHOD &&
(uapi_key_is_write_method(method_key) ||
uapi_key_is_write_ex_method(method_key))) {
struct uverbs_api_write_method *write_elm;
write_elm = uapi_add_get_elm(uapi, method_key,
sizeof(*write_elm), &exists);
if (IS_ERR(write_elm))
return PTR_ERR(write_elm);
write_elm->disabled = 1;
return 0;
}
WARN_ON(true);
return -EINVAL;
}
static int uapi_merge_def(struct uverbs_api *uapi, struct ib_device *ibdev,
const struct uapi_definition *def_list,
bool is_driver)
{
const struct uapi_definition *def = def_list;
u32 cur_obj_key = UVERBS_API_KEY_ERR;
u32 cur_method_key = UVERBS_API_KEY_ERR;
bool exists;
int rc;
if (!def_list)
return 0;
Annotation
- Immediate include surface: `rdma/uverbs_ioctl.h`, `rdma/rdma_user_ioctl.h`, `linux/bitops.h`, `rdma_core.h`, `uverbs.h`.
- Detected declarations: `function Copyright`, `function uapi_create_write`, `function uapi_merge_method`, `function uapi_merge_obj_tree`, `function uapi_disable_elm`, `function uapi_merge_def`, `function uapi_finalize_ioctl_method`, `function uapi_key_attrs_start`, `function uapi_finalize`, `function radix_tree_for_each_slot`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: pattern implementation candidate.
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.