drivers/net/bonding/bond_sysfs_slave.c
Source file repositories/reference/linux-study-clean/drivers/net/bonding/bond_sysfs_slave.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/bonding/bond_sysfs_slave.c- Extension
.c- Size
- 3706 bytes
- Lines
- 146
- Domain
- Driver Families
- Bucket
- drivers/net
- 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/capability.hlinux/kernel.hlinux/netdevice.hnet/bonding.h
Detected Declarations
struct slave_attributefunction state_showfunction mii_status_showfunction link_failure_count_showfunction perm_hwaddr_showfunction queue_id_showfunction ad_aggregator_id_showfunction ad_actor_oper_port_state_showfunction ad_partner_oper_port_state_showfunction slave_showfunction bond_sysfs_slave_addfunction bond_sysfs_slave_del
Annotated Snippet
struct slave_attribute {
struct attribute attr;
ssize_t (*show)(struct slave *, char *);
};
#define SLAVE_ATTR_RO(_name) \
const struct slave_attribute slave_attr_##_name = __ATTR_RO(_name)
static ssize_t state_show(struct slave *slave, char *buf)
{
switch (bond_slave_state(slave)) {
case BOND_STATE_ACTIVE:
return sysfs_emit(buf, "active\n");
case BOND_STATE_BACKUP:
return sysfs_emit(buf, "backup\n");
default:
return sysfs_emit(buf, "UNKNOWN\n");
}
}
static SLAVE_ATTR_RO(state);
static ssize_t mii_status_show(struct slave *slave, char *buf)
{
return sysfs_emit(buf, "%s\n", bond_slave_link_status(slave->link));
}
static SLAVE_ATTR_RO(mii_status);
static ssize_t link_failure_count_show(struct slave *slave, char *buf)
{
return sysfs_emit(buf, "%d\n", slave->link_failure_count);
}
static SLAVE_ATTR_RO(link_failure_count);
static ssize_t perm_hwaddr_show(struct slave *slave, char *buf)
{
return sysfs_emit(buf, "%*phC\n",
slave->dev->addr_len,
slave->perm_hwaddr);
}
static SLAVE_ATTR_RO(perm_hwaddr);
static ssize_t queue_id_show(struct slave *slave, char *buf)
{
return sysfs_emit(buf, "%d\n", READ_ONCE(slave->queue_id));
}
static SLAVE_ATTR_RO(queue_id);
static ssize_t ad_aggregator_id_show(struct slave *slave, char *buf)
{
const struct aggregator *agg;
if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
rcu_read_lock();
agg = rcu_dereference(SLAVE_AD_INFO(slave)->port.aggregator);
if (agg) {
ssize_t res = sysfs_emit(buf, "%d\n",
agg->aggregator_identifier);
rcu_read_unlock();
return res;
}
rcu_read_unlock();
}
return sysfs_emit(buf, "N/A\n");
}
static SLAVE_ATTR_RO(ad_aggregator_id);
static ssize_t ad_actor_oper_port_state_show(struct slave *slave, char *buf)
{
const struct port *ad_port;
if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
ad_port = &SLAVE_AD_INFO(slave)->port;
if (rcu_access_pointer(ad_port->aggregator))
return sysfs_emit(buf, "%u\n",
ad_port->actor_oper_port_state);
}
return sysfs_emit(buf, "N/A\n");
}
static SLAVE_ATTR_RO(ad_actor_oper_port_state);
static ssize_t ad_partner_oper_port_state_show(struct slave *slave, char *buf)
{
const struct port *ad_port;
if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
ad_port = &SLAVE_AD_INFO(slave)->port;
if (rcu_access_pointer(ad_port->aggregator))
return sysfs_emit(buf, "%u\n",
Annotation
- Immediate include surface: `linux/capability.h`, `linux/kernel.h`, `linux/netdevice.h`, `net/bonding.h`.
- Detected declarations: `struct slave_attribute`, `function state_show`, `function mii_status_show`, `function link_failure_count_show`, `function perm_hwaddr_show`, `function queue_id_show`, `function ad_aggregator_id_show`, `function ad_actor_oper_port_state_show`, `function ad_partner_oper_port_state_show`, `function slave_show`.
- Atlas domain: Driver Families / drivers/net.
- 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.