drivers/infiniband/hw/mlx4/sysfs.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/mlx4/sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/mlx4/sysfs.c- Extension
.c- Size
- 23600 bytes
- Lines
- 880
- 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.
- 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
mlx4_ib.hlinux/slab.hlinux/string.hlinux/stat.hrdma/ib_mad.h
Detected Declarations
struct mlx4_portstruct port_attributestruct port_table_attributefunction Copyrightfunction store_admin_alias_guidfunction show_port_gidfunction show_phys_port_pkeyfunction create_sysfs_entryfunction add_sysfs_port_mcg_attrfunction del_sysfs_port_mcg_attrfunction add_port_entriesfunction get_namefunction mlx4_port_releasefunction port_attr_showfunction port_attr_storefunction show_port_pkeyfunction store_port_pkeyfunction show_port_gid_idxfunction alloc_group_attrsfunction sysfs_show_smi_enabledfunction sysfs_show_enable_smi_adminfunction sysfs_store_enable_smi_adminfunction add_vf_smi_entriesfunction remove_vf_smi_entriesfunction add_portfunction register_one_pkey_treefunction register_pkey_treefunction unregister_pkey_treefunction list_for_each_entry_safefunction mlx4_ib_device_register_sysfsfunction rdma_for_each_portfunction unregister_alias_guid_treefunction mlx4_ib_device_unregister_sysfs
Annotated Snippet
struct mlx4_port {
struct kobject kobj;
struct mlx4_ib_dev *dev;
struct attribute_group pkey_group;
struct attribute_group gid_group;
struct device_attribute enable_smi_admin;
struct device_attribute smi_enabled;
int slave;
u8 port_num;
};
static void mlx4_port_release(struct kobject *kobj)
{
struct mlx4_port *p = container_of(kobj, struct mlx4_port, kobj);
struct attribute *a;
int i;
for (i = 0; (a = p->pkey_group.attrs[i]); ++i)
kfree(a);
kfree(p->pkey_group.attrs);
for (i = 0; (a = p->gid_group.attrs[i]); ++i)
kfree(a);
kfree(p->gid_group.attrs);
kfree(p);
}
struct port_attribute {
struct attribute attr;
ssize_t (*show)(struct mlx4_port *, struct port_attribute *, char *buf);
ssize_t (*store)(struct mlx4_port *, struct port_attribute *,
const char *buf, size_t count);
};
static ssize_t port_attr_show(struct kobject *kobj,
struct attribute *attr, char *buf)
{
struct port_attribute *port_attr =
container_of(attr, struct port_attribute, attr);
struct mlx4_port *p = container_of(kobj, struct mlx4_port, kobj);
if (!port_attr->show)
return -EIO;
return port_attr->show(p, port_attr, buf);
}
static ssize_t port_attr_store(struct kobject *kobj,
struct attribute *attr,
const char *buf, size_t size)
{
struct port_attribute *port_attr =
container_of(attr, struct port_attribute, attr);
struct mlx4_port *p = container_of(kobj, struct mlx4_port, kobj);
if (!port_attr->store)
return -EIO;
return port_attr->store(p, port_attr, buf, size);
}
static const struct sysfs_ops port_sysfs_ops = {
.show = port_attr_show,
.store = port_attr_store,
};
static struct kobj_type port_type = {
.release = mlx4_port_release,
.sysfs_ops = &port_sysfs_ops,
};
struct port_table_attribute {
struct port_attribute attr;
char name[8];
int index;
};
static ssize_t show_port_pkey(struct mlx4_port *p, struct port_attribute *attr,
char *buf)
{
struct port_table_attribute *tab_attr =
container_of(attr, struct port_table_attribute, attr);
struct pkey_mgt *m = &p->dev->pkeys;
u8 key = m->virt2phys_pkey[p->slave][p->port_num - 1][tab_attr->index];
if (key >= p->dev->dev->caps.pkey_table_len[p->port_num])
return sysfs_emit(buf, "none\n");
return sysfs_emit(buf, "%d\n", key);
}
static ssize_t store_port_pkey(struct mlx4_port *p, struct port_attribute *attr,
const char *buf, size_t count)
Annotation
- Immediate include surface: `mlx4_ib.h`, `linux/slab.h`, `linux/string.h`, `linux/stat.h`, `rdma/ib_mad.h`.
- Detected declarations: `struct mlx4_port`, `struct port_attribute`, `struct port_table_attribute`, `function Copyright`, `function store_admin_alias_guid`, `function show_port_gid`, `function show_phys_port_pkey`, `function create_sysfs_entry`, `function add_sysfs_port_mcg_attr`, `function del_sysfs_port_mcg_attr`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: source 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.