drivers/infiniband/hw/usnic/usnic_ib_sysfs.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/usnic/usnic_ib_sysfs.c- Extension
.c- Size
- 8125 bytes
- Lines
- 296
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/errno.hrdma/ib_user_verbs.hrdma/ib_addr.husnic_common_util.husnic_ib.husnic_ib_qp_grp.husnic_vnic.husnic_ib_verbs.husnic_ib_sysfs.husnic_log.h
Detected Declarations
struct qpn_attributefunction Copyrightfunction config_showfunction iface_showfunction max_vf_showfunction qp_per_vf_showfunction cq_per_vf_showfunction usnic_ib_qpn_attr_showfunction context_showfunction summary_showfunction usnic_ib_sysfs_register_usdevfunction usnic_ib_sysfs_unregister_usdevfunction usnic_ib_sysfs_qpn_addfunction usnic_ib_sysfs_qpn_remove
Annotated Snippet
struct qpn_attribute {
struct attribute attr;
ssize_t (*show)(struct usnic_ib_qp_grp *, char *buf);
};
/*
* Definitions for supporting QPN entries in sysfs
*/
static ssize_t
usnic_ib_qpn_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
{
struct usnic_ib_qp_grp *qp_grp;
struct qpn_attribute *qpn_attr;
qp_grp = container_of(kobj, struct usnic_ib_qp_grp, kobj);
qpn_attr = container_of(attr, struct qpn_attribute, attr);
return qpn_attr->show(qp_grp, buf);
}
static const struct sysfs_ops usnic_ib_qpn_sysfs_ops = {
.show = usnic_ib_qpn_attr_show
};
#define QPN_ATTR_RO(NAME) \
struct qpn_attribute qpn_attr_##NAME = __ATTR_RO(NAME)
static ssize_t context_show(struct usnic_ib_qp_grp *qp_grp, char *buf)
{
return sysfs_emit(buf, "0x%p\n", qp_grp->ctx);
}
static ssize_t summary_show(struct usnic_ib_qp_grp *qp_grp, char *buf)
{
int i, j;
struct usnic_vnic_res_chunk *res_chunk;
struct usnic_vnic_res *vnic_res;
int len;
len = sysfs_emit(buf, "QPN: %d State: (%s) PID: %u VF Idx: %hu",
qp_grp->ibqp.qp_num,
usnic_ib_qp_grp_state_to_string(qp_grp->state),
qp_grp->owner_pid,
usnic_vnic_get_index(qp_grp->vf->vnic));
for (i = 0; qp_grp->res_chunk_list[i]; i++) {
res_chunk = qp_grp->res_chunk_list[i];
for (j = 0; j < res_chunk->cnt; j++) {
vnic_res = res_chunk->res[j];
len += sysfs_emit_at(buf, len, " %s[%d]",
usnic_vnic_res_type_to_str(vnic_res->type),
vnic_res->vnic_idx);
}
}
len += sysfs_emit_at(buf, len, "\n");
return len;
}
static QPN_ATTR_RO(context);
static QPN_ATTR_RO(summary);
static struct attribute *usnic_ib_qpn_default_attrs[] = {
&qpn_attr_context.attr,
&qpn_attr_summary.attr,
NULL
};
ATTRIBUTE_GROUPS(usnic_ib_qpn_default);
static struct kobj_type usnic_ib_qpn_type = {
.sysfs_ops = &usnic_ib_qpn_sysfs_ops,
.default_groups = usnic_ib_qpn_default_groups,
};
int usnic_ib_sysfs_register_usdev(struct usnic_ib_dev *us_ibdev)
{
/* create kernel object for looking at individual QPs */
kobject_get(&us_ibdev->ib_dev.dev.kobj);
us_ibdev->qpn_kobj = kobject_create_and_add("qpn",
&us_ibdev->ib_dev.dev.kobj);
if (us_ibdev->qpn_kobj == NULL) {
kobject_put(&us_ibdev->ib_dev.dev.kobj);
return -ENOMEM;
}
return 0;
}
void usnic_ib_sysfs_unregister_usdev(struct usnic_ib_dev *us_ibdev)
Annotation
- Immediate include surface: `linux/init.h`, `linux/errno.h`, `rdma/ib_user_verbs.h`, `rdma/ib_addr.h`, `usnic_common_util.h`, `usnic_ib.h`, `usnic_ib_qp_grp.h`, `usnic_vnic.h`.
- Detected declarations: `struct qpn_attribute`, `function Copyright`, `function config_show`, `function iface_show`, `function max_vf_show`, `function qp_per_vf_show`, `function cq_per_vf_show`, `function usnic_ib_qpn_attr_show`, `function context_show`, `function summary_show`.
- 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.