drivers/net/ethernet/mellanox/mlx5/core/en/rep/bond.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en/rep/bond.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en/rep/bond.c- Extension
.c- Size
- 9998 bytes
- Lines
- 352
- 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
linux/netdevice.hlinux/list.hnet/lag.hmlx5_core.heswitch.hesw/acl/ofld.hen_rep.h
Detected Declarations
struct mlx5e_rep_bondstruct mlx5e_rep_bond_slave_entrystruct mlx5e_rep_bond_metadatafunction mlx5e_lookup_rep_bond_metadatafunction list_for_each_entryfunction mlx5e_lookup_rep_bond_slave_entryfunction list_for_each_entryfunction mlx5e_rep_bond_metadata_releasefunction mlx5e_rep_bond_enslavefunction mlx5e_rep_bond_unslavefunction mlx5e_rep_is_lag_netdevfunction mlx5e_rep_changelowerstate_eventfunction mlx5e_rep_changeupper_eventfunction mlx5e_rep_esw_bond_neteventfunction mlx5e_rep_bond_initfunction mlx5e_rep_bond_cleanup
Annotated Snippet
struct mlx5e_rep_bond {
struct notifier_block nb;
struct netdev_net_notifier nn;
struct list_head metadata_list;
};
struct mlx5e_rep_bond_slave_entry {
struct list_head list;
struct net_device *netdev;
};
struct mlx5e_rep_bond_metadata {
struct list_head list; /* link to global list of rep_bond_metadata */
struct mlx5_eswitch *esw;
/* private of uplink holding rep bond metadata list */
struct net_device *lag_dev;
u32 metadata_reg_c_0;
struct list_head slaves_list; /* slaves list */
int slaves;
};
static struct mlx5e_rep_bond_metadata *
mlx5e_lookup_rep_bond_metadata(struct mlx5_rep_uplink_priv *uplink_priv,
const struct net_device *lag_dev)
{
struct mlx5e_rep_bond_metadata *found = NULL;
struct mlx5e_rep_bond_metadata *cur;
list_for_each_entry(cur, &uplink_priv->bond->metadata_list, list) {
if (cur->lag_dev == lag_dev) {
found = cur;
break;
}
}
return found;
}
static struct mlx5e_rep_bond_slave_entry *
mlx5e_lookup_rep_bond_slave_entry(struct mlx5e_rep_bond_metadata *mdata,
const struct net_device *netdev)
{
struct mlx5e_rep_bond_slave_entry *found = NULL;
struct mlx5e_rep_bond_slave_entry *cur;
list_for_each_entry(cur, &mdata->slaves_list, list) {
if (cur->netdev == netdev) {
found = cur;
break;
}
}
return found;
}
static void mlx5e_rep_bond_metadata_release(struct mlx5e_rep_bond_metadata *mdata)
{
netdev_dbg(mdata->lag_dev, "destroy rep_bond_metadata(%d)\n",
mdata->metadata_reg_c_0);
list_del(&mdata->list);
mlx5_esw_match_metadata_free(mdata->esw, mdata->metadata_reg_c_0);
WARN_ON(!list_empty(&mdata->slaves_list));
kfree(mdata);
}
/* This must be called under rtnl_lock */
int mlx5e_rep_bond_enslave(struct mlx5_eswitch *esw, struct net_device *netdev,
struct net_device *lag_dev)
{
struct mlx5e_rep_bond_slave_entry *s_entry;
struct mlx5e_rep_bond_metadata *mdata;
struct mlx5e_rep_priv *rpriv;
struct mlx5e_priv *priv;
int err;
ASSERT_RTNL();
rpriv = mlx5_eswitch_get_uplink_priv(esw, REP_ETH);
mdata = mlx5e_lookup_rep_bond_metadata(&rpriv->uplink_priv, lag_dev);
if (!mdata) {
/* First netdev becomes slave, no metadata presents the lag_dev. Create one */
mdata = kzalloc_obj(*mdata);
if (!mdata)
return -ENOMEM;
mdata->lag_dev = lag_dev;
mdata->esw = esw;
INIT_LIST_HEAD(&mdata->slaves_list);
mdata->metadata_reg_c_0 = mlx5_esw_match_metadata_alloc(esw);
Annotation
- Immediate include surface: `linux/netdevice.h`, `linux/list.h`, `net/lag.h`, `mlx5_core.h`, `eswitch.h`, `esw/acl/ofld.h`, `en_rep.h`.
- Detected declarations: `struct mlx5e_rep_bond`, `struct mlx5e_rep_bond_slave_entry`, `struct mlx5e_rep_bond_metadata`, `function mlx5e_lookup_rep_bond_metadata`, `function list_for_each_entry`, `function mlx5e_lookup_rep_bond_slave_entry`, `function list_for_each_entry`, `function mlx5e_rep_bond_metadata_release`, `function mlx5e_rep_bond_enslave`, `function mlx5e_rep_bond_unslave`.
- 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.