drivers/infiniband/core/sysfs.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/core/sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/core/sysfs.c- Extension
.c- Size
- 39650 bytes
- Lines
- 1429
- 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.
- 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
core_priv.hlinux/slab.hlinux/stat.hlinux/string.hlinux/netdevice.hlinux/ethtool.hrdma/ib_mad.hrdma/ib_pma.hrdma/ib_cache.hrdma/rdma_counter.hrdma/ib_sysfs.h
Detected Declarations
struct port_table_attributestruct gid_attr_groupstruct ib_portstruct hw_stats_device_attributestruct hw_stats_port_attributestruct hw_stats_device_datastruct hw_stats_port_datafunction port_attr_showfunction port_attr_storefunction hw_stat_device_showfunction hw_stat_device_storefunction hw_stat_port_showfunction hw_stat_port_storefunction gid_attr_showfunction state_showfunction lid_showfunction lid_mask_count_showfunction sm_lid_showfunction sm_sl_showfunction cap_mask_showfunction rate_showfunction phys_state_showfunction link_layer_showfunction print_ndevfunction print_gid_typefunction _show_port_gid_attrfunction show_port_gidfunction show_port_gid_attr_ndevfunction show_port_gid_attr_gid_typefunction show_port_pkeyfunction get_perf_madfunction show_pma_counterfunction ib_port_releasefunction ib_port_gid_attr_releasefunction update_hw_statsfunction print_hw_statfunction show_hw_statsfunction show_stats_lifespanfunction set_stats_lifespanfunction alloc_hw_stats_devicefunction ib_device_release_hw_statsfunction ib_setup_device_attrsfunction alloc_hw_stats_portfunction setup_hw_port_statsfunction alloc_port_table_groupfunction setup_gid_attrsfunction destroy_gid_attrsfunction destroy_port
Annotated Snippet
struct port_table_attribute {
struct ib_port_attribute attr;
char name[8];
int index;
__be16 attr_id;
};
struct gid_attr_group {
struct ib_port *port;
struct kobject kobj;
struct attribute_group groups[2];
const struct attribute_group *groups_list[3];
struct port_table_attribute attrs_list[];
};
struct ib_port {
struct kobject kobj;
struct ib_device *ibdev;
struct gid_attr_group *gid_attr_group;
struct hw_stats_port_data *hw_stats_data;
struct attribute_group groups[3];
const struct attribute_group *groups_list[5];
u32 port_num;
struct port_table_attribute attrs_list[];
};
struct hw_stats_device_attribute {
struct device_attribute attr;
ssize_t (*show)(struct ib_device *ibdev, struct rdma_hw_stats *stats,
unsigned int index, unsigned int port_num, char *buf);
ssize_t (*store)(struct ib_device *ibdev, struct rdma_hw_stats *stats,
unsigned int index, unsigned int port_num,
const char *buf, size_t count);
};
struct hw_stats_port_attribute {
struct ib_port_attribute attr;
ssize_t (*show)(struct ib_device *ibdev, struct rdma_hw_stats *stats,
unsigned int index, unsigned int port_num, char *buf);
ssize_t (*store)(struct ib_device *ibdev, struct rdma_hw_stats *stats,
unsigned int index, unsigned int port_num,
const char *buf, size_t count);
};
struct hw_stats_device_data {
struct attribute_group group;
struct rdma_hw_stats *stats;
struct hw_stats_device_attribute attrs[];
};
struct hw_stats_port_data {
struct rdma_hw_stats *stats;
struct hw_stats_port_attribute attrs[];
};
static ssize_t port_attr_show(struct kobject *kobj,
struct attribute *attr, char *buf)
{
struct ib_port_attribute *port_attr =
container_of(attr, struct ib_port_attribute, attr);
struct ib_port *p = container_of(kobj, struct ib_port, kobj);
if (!port_attr->show)
return -EIO;
return port_attr->show(p->ibdev, p->port_num, port_attr, buf);
}
static ssize_t port_attr_store(struct kobject *kobj,
struct attribute *attr,
const char *buf, size_t count)
{
struct ib_port_attribute *port_attr =
container_of(attr, struct ib_port_attribute, attr);
struct ib_port *p = container_of(kobj, struct ib_port, kobj);
if (!port_attr->store)
return -EIO;
return port_attr->store(p->ibdev, p->port_num, port_attr, buf, count);
}
struct ib_device *ib_port_sysfs_get_ibdev_kobj(struct kobject *kobj,
u32 *port_num)
{
struct ib_port *port = container_of(kobj, struct ib_port, kobj);
*port_num = port->port_num;
return port->ibdev;
}
Annotation
- Immediate include surface: `core_priv.h`, `linux/slab.h`, `linux/stat.h`, `linux/string.h`, `linux/netdevice.h`, `linux/ethtool.h`, `rdma/ib_mad.h`, `rdma/ib_pma.h`.
- Detected declarations: `struct port_table_attribute`, `struct gid_attr_group`, `struct ib_port`, `struct hw_stats_device_attribute`, `struct hw_stats_port_attribute`, `struct hw_stats_device_data`, `struct hw_stats_port_data`, `function port_attr_show`, `function port_attr_store`, `function hw_stat_device_show`.
- 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.
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.