drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c- Extension
.c- Size
- 36253 bytes
- Lines
- 1323
- 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.
- 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
linux/kernel.hlinux/mutex.hnet/devlink.hspectrum.hspectrum_dpipe.hspectrum_router.h
Detected Declarations
enum mlxsw_sp_field_metadata_idenum mlxsw_sp_dpipe_header_idenum mlxsw_sp_dpipe_table_host_matchenum mlxsw_sp_dpipe_table_adj_matchenum mlxsw_sp_dpipe_table_adj_actionfunction mlxsw_sp_dpipe_table_erif_actions_dumpfunction mlxsw_sp_dpipe_table_erif_matches_dumpfunction mlxsw_sp_erif_match_action_preparefunction mlxsw_sp_erif_entry_preparefunction mlxsw_sp_erif_entry_getfunction mlxsw_sp_dpipe_table_erif_entries_dumpfunction mlxsw_sp_dpipe_table_erif_counters_updatefunction mlxsw_sp_dpipe_table_erif_size_getfunction mlxsw_sp_dpipe_erif_table_initfunction mlxsw_sp_dpipe_erif_table_finifunction mlxsw_sp_dpipe_table_host_matches_dumpfunction mlxsw_sp_dpipe_table_host4_matches_dumpfunction mlxsw_sp_dpipe_table_host_actions_dumpfunction mlxsw_sp_dpipe_table_host_match_action_preparefunction mlxsw_sp_dpipe_table_host_entry_preparefunction __mlxsw_sp_dpipe_table_host_entry_fillfunction mlxsw_sp_dpipe_table_host4_entry_fillfunction mlxsw_sp_dpipe_table_host6_entry_fillfunction mlxsw_sp_dpipe_table_host_entry_fillfunction mlxsw_sp_dpipe_table_host_entries_getfunction mlxsw_sp_rif_neigh_for_eachfunction mlxsw_sp_dpipe_table_host_entries_dumpfunction mlxsw_sp_dpipe_table_host4_entries_dumpfunction mlxsw_sp_dpipe_table_host_counters_updatefunction mlxsw_sp_rif_neigh_for_eachfunction mlxsw_sp_dpipe_table_host4_counters_updatefunction mlxsw_sp_dpipe_table_host_size_getfunction mlxsw_sp_rif_neigh_for_eachfunction mlxsw_sp_dpipe_table_host4_size_getfunction mlxsw_sp_dpipe_host4_table_initfunction mlxsw_sp_dpipe_host4_table_finifunction mlxsw_sp_dpipe_table_host6_matches_dumpfunction mlxsw_sp_dpipe_table_host6_entries_dumpfunction mlxsw_sp_dpipe_table_host6_counters_updatefunction mlxsw_sp_dpipe_table_host6_size_getfunction mlxsw_sp_dpipe_host6_table_initfunction mlxsw_sp_dpipe_host6_table_finifunction mlxsw_sp_dpipe_table_adj_matches_dumpfunction mlxsw_sp_dpipe_table_adj_actions_dumpfunction mlxsw_sp_dpipe_table_adj_sizefunction mlxsw_sp_dpipe_table_adj_match_action_preparefunction mlxsw_sp_dpipe_table_adj_entry_preparefunction __mlxsw_sp_dpipe_table_adj_entry_fill
Annotated Snippet
if (err) {
if (err == -EMSGSIZE) {
if (!j)
goto err_entry_append;
break;
}
goto err_entry_append;
}
j++;
}
devlink_dpipe_entry_ctx_close(dump_ctx);
if (i != rif_count)
goto start_again;
mutex_unlock(&mlxsw_sp->router->lock);
devlink_dpipe_entry_clear(&entry);
return 0;
err_entry_append:
err_entry_get:
err_ctx_prepare:
mutex_unlock(&mlxsw_sp->router->lock);
devlink_dpipe_entry_clear(&entry);
return err;
}
static int mlxsw_sp_dpipe_table_erif_counters_update(void *priv, bool enable)
{
struct mlxsw_sp *mlxsw_sp = priv;
int i;
mutex_lock(&mlxsw_sp->router->lock);
for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++) {
struct mlxsw_sp_rif *rif = mlxsw_sp_rif_by_index(mlxsw_sp, i);
if (!rif)
continue;
if (enable)
mlxsw_sp_rif_counter_alloc(rif,
MLXSW_SP_RIF_COUNTER_EGRESS);
else
mlxsw_sp_rif_counter_free(rif,
MLXSW_SP_RIF_COUNTER_EGRESS);
}
mutex_unlock(&mlxsw_sp->router->lock);
return 0;
}
static u64 mlxsw_sp_dpipe_table_erif_size_get(void *priv)
{
struct mlxsw_sp *mlxsw_sp = priv;
return MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS);
}
static const struct devlink_dpipe_table_ops mlxsw_sp_erif_ops = {
.matches_dump = mlxsw_sp_dpipe_table_erif_matches_dump,
.actions_dump = mlxsw_sp_dpipe_table_erif_actions_dump,
.entries_dump = mlxsw_sp_dpipe_table_erif_entries_dump,
.counters_set_update = mlxsw_sp_dpipe_table_erif_counters_update,
.size_get = mlxsw_sp_dpipe_table_erif_size_get,
};
static int mlxsw_sp_dpipe_erif_table_init(struct mlxsw_sp *mlxsw_sp)
{
struct devlink *devlink = priv_to_devlink(mlxsw_sp->core);
return devl_dpipe_table_register(devlink,
MLXSW_SP_DPIPE_TABLE_NAME_ERIF,
&mlxsw_sp_erif_ops,
mlxsw_sp, false);
}
static void mlxsw_sp_dpipe_erif_table_fini(struct mlxsw_sp *mlxsw_sp)
{
struct devlink *devlink = priv_to_devlink(mlxsw_sp->core);
devl_dpipe_table_unregister(devlink, MLXSW_SP_DPIPE_TABLE_NAME_ERIF);
}
static int mlxsw_sp_dpipe_table_host_matches_dump(struct sk_buff *skb, int type)
{
struct devlink_dpipe_match match = {0};
int err;
match.type = DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT;
match.header = &mlxsw_sp_dpipe_header_metadata;
match.field_id = MLXSW_SP_DPIPE_FIELD_METADATA_ERIF_PORT;
err = devlink_dpipe_match_put(skb, &match);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/mutex.h`, `net/devlink.h`, `spectrum.h`, `spectrum_dpipe.h`, `spectrum_router.h`.
- Detected declarations: `enum mlxsw_sp_field_metadata_id`, `enum mlxsw_sp_dpipe_header_id`, `enum mlxsw_sp_dpipe_table_host_match`, `enum mlxsw_sp_dpipe_table_adj_match`, `enum mlxsw_sp_dpipe_table_adj_action`, `function mlxsw_sp_dpipe_table_erif_actions_dump`, `function mlxsw_sp_dpipe_table_erif_matches_dump`, `function mlxsw_sp_erif_match_action_prepare`, `function mlxsw_sp_erif_entry_prepare`, `function mlxsw_sp_erif_entry_get`.
- 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.