drivers/net/dsa/mv88e6xxx/devlink.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/mv88e6xxx/devlink.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/mv88e6xxx/devlink.c- Extension
.c- Size
- 19778 bytes
- Lines
- 816
- 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.
- 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
net/dsa.hchip.hdevlink.hglobal1.hglobal2.hport.h
Detected Declarations
struct mv88e6xxx_devlink_atu_entrystruct mv88e6xxx_devlink_vtu_entrystruct mv88e6xxx_devlink_stu_entrystruct mv88e6xxx_regionenum mv88e6xxx_devlink_param_idenum mv88e6xxx_devlink_resource_idfunction mv88e6xxx_atu_get_hashfunction mv88e6xxx_atu_set_hashfunction mv88e6xxx_devlink_param_getfunction mv88e6xxx_devlink_param_setfunction mv88e6xxx_setup_devlink_paramsfunction mv88e6xxx_teardown_devlink_paramsfunction mv88e6xxx_devlink_atu_bin_getfunction mv88e6xxx_devlink_atu_bin_0_getfunction mv88e6xxx_devlink_atu_bin_1_getfunction mv88e6xxx_devlink_atu_bin_2_getfunction mv88e6xxx_devlink_atu_bin_3_getfunction mv88e6xxx_devlink_atu_getfunction mv88e6xxx_setup_devlink_resourcesfunction mv88e6xxx_region_global_snapshotfunction mv88e6xxx_region_atu_snapshot_fidfunction mv88e6xxx_region_atu_snapshotfunction mv88e6xxx_region_vtu_snapshotfunction mv88e6xxx_region_stu_snapshotfunction mv88e6xxx_region_pvt_snapshotfunction mv88e6xxx_region_port_snapshotfunction mv88e6xxx_teardown_devlink_regions_globalfunction mv88e6xxx_teardown_devlink_regions_portfunction mv88e6xxx_setup_devlink_regions_portfunction mv88e6xxx_setup_devlink_regions_globalfunction mv88e6xxx_devlink_info_get
Annotated Snippet
struct mv88e6xxx_devlink_atu_entry {
/* The FID is scattered over multiple registers. */
u16 fid;
u16 atu_op;
u16 atu_data;
u16 atu_01;
u16 atu_23;
u16 atu_45;
};
static int mv88e6xxx_region_atu_snapshot_fid(struct mv88e6xxx_chip *chip,
int fid,
struct mv88e6xxx_devlink_atu_entry *table,
int *count)
{
u16 atu_op, atu_data, atu_01, atu_23, atu_45;
struct mv88e6xxx_atu_entry addr;
int err;
addr.state = 0;
eth_broadcast_addr(addr.mac);
do {
err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
if (err)
return err;
if (!addr.state)
break;
err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_ATU_OP, &atu_op);
if (err)
return err;
err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_ATU_DATA, &atu_data);
if (err)
return err;
err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_ATU_MAC01, &atu_01);
if (err)
return err;
err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_ATU_MAC23, &atu_23);
if (err)
return err;
err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_ATU_MAC45, &atu_45);
if (err)
return err;
table[*count].fid = fid;
table[*count].atu_op = atu_op;
table[*count].atu_data = atu_data;
table[*count].atu_01 = atu_01;
table[*count].atu_23 = atu_23;
table[*count].atu_45 = atu_45;
(*count)++;
} while (!is_broadcast_ether_addr(addr.mac));
return 0;
}
static int mv88e6xxx_region_atu_snapshot(struct devlink *dl,
const struct devlink_region_ops *ops,
struct netlink_ext_ack *extack,
u8 **data)
{
struct dsa_switch *ds = dsa_devlink_to_ds(dl);
struct mv88e6xxx_devlink_atu_entry *table;
struct mv88e6xxx_chip *chip = ds->priv;
int fid = -1, err = 0, count = 0;
table = kzalloc_objs(struct mv88e6xxx_devlink_atu_entry,
mv88e6xxx_num_databases(chip));
if (!table)
return -ENOMEM;
mv88e6xxx_reg_lock(chip);
while (1) {
fid = find_next_bit(chip->fid_bitmap, MV88E6XXX_N_FID, fid + 1);
if (fid == MV88E6XXX_N_FID)
break;
err = mv88e6xxx_region_atu_snapshot_fid(chip, fid, table,
&count);
if (err) {
kfree(table);
goto out;
}
Annotation
- Immediate include surface: `net/dsa.h`, `chip.h`, `devlink.h`, `global1.h`, `global2.h`, `port.h`.
- Detected declarations: `struct mv88e6xxx_devlink_atu_entry`, `struct mv88e6xxx_devlink_vtu_entry`, `struct mv88e6xxx_devlink_stu_entry`, `struct mv88e6xxx_region`, `enum mv88e6xxx_devlink_param_id`, `enum mv88e6xxx_devlink_resource_id`, `function mv88e6xxx_atu_get_hash`, `function mv88e6xxx_atu_set_hash`, `function mv88e6xxx_devlink_param_get`, `function mv88e6xxx_devlink_param_set`.
- Atlas domain: Driver Families / drivers/net.
- 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.