drivers/infiniband/core/cma_configfs.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/core/cma_configfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/core/cma_configfs.c- Extension
.c- Size
- 9067 bytes
- Lines
- 366
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- 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.
- 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/configfs.hrdma/ib_verbs.hrdma/rdma_cm.hcore_priv.hcma_priv.h
Detected Declarations
struct cma_devicestruct cma_dev_groupstruct cma_dev_port_groupstruct cma_dev_groupfunction filter_by_namefunction cma_configfs_params_getfunction cma_configfs_params_putfunction default_roce_mode_showfunction default_roce_mode_storefunction default_roce_tos_showfunction default_roce_tos_storefunction make_cma_portsfunction release_cma_devfunction release_cma_ports_groupfunction drop_cma_devfunction cma_configfs_initfunction cma_configfs_exit
Annotated Snippet
struct cma_dev_port_group {
u32 port_num;
struct cma_dev_group *cma_dev_group;
struct config_group group;
};
struct cma_dev_group {
char name[IB_DEVICE_NAME_MAX];
struct config_group device_group;
struct config_group ports_group;
struct cma_dev_port_group *ports;
};
static struct cma_dev_port_group *to_dev_port_group(struct config_item *item)
{
struct config_group *group;
if (!item)
return NULL;
group = container_of(item, struct config_group, cg_item);
return container_of(group, struct cma_dev_port_group, group);
}
static bool filter_by_name(struct ib_device *ib_dev, void *cookie)
{
return !strcmp(dev_name(&ib_dev->dev), cookie);
}
static int cma_configfs_params_get(struct config_item *item,
struct cma_device **pcma_dev,
struct cma_dev_port_group **pgroup)
{
struct cma_dev_port_group *group = to_dev_port_group(item);
struct cma_device *cma_dev;
if (!group)
return -ENODEV;
cma_dev = cma_enum_devices_by_ibdev(filter_by_name,
group->cma_dev_group->name);
if (!cma_dev)
return -ENODEV;
*pcma_dev = cma_dev;
*pgroup = group;
return 0;
}
static void cma_configfs_params_put(struct cma_device *cma_dev)
{
cma_dev_put(cma_dev);
}
static ssize_t default_roce_mode_show(struct config_item *item,
char *buf)
{
struct cma_device *cma_dev;
struct cma_dev_port_group *group;
int gid_type;
ssize_t ret;
ret = cma_configfs_params_get(item, &cma_dev, &group);
if (ret)
return ret;
gid_type = cma_get_default_gid_type(cma_dev, group->port_num);
cma_configfs_params_put(cma_dev);
if (gid_type < 0)
return gid_type;
return sysfs_emit(buf, "%s\n", ib_cache_gid_type_str(gid_type));
}
static ssize_t default_roce_mode_store(struct config_item *item,
const char *buf, size_t count)
{
struct cma_device *cma_dev;
struct cma_dev_port_group *group;
int gid_type;
ssize_t ret;
ret = cma_configfs_params_get(item, &cma_dev, &group);
if (ret)
return ret;
gid_type = ib_cache_gid_parse_type_str(buf);
if (gid_type < 0) {
Annotation
- Immediate include surface: `linux/configfs.h`, `rdma/ib_verbs.h`, `rdma/rdma_cm.h`, `core_priv.h`, `cma_priv.h`.
- Detected declarations: `struct cma_device`, `struct cma_dev_group`, `struct cma_dev_port_group`, `struct cma_dev_group`, `function filter_by_name`, `function cma_configfs_params_get`, `function cma_configfs_params_put`, `function default_roce_mode_show`, `function default_roce_mode_store`, `function default_roce_tos_show`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: source 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.