drivers/net/ethernet/mellanox/mlx5/core/lag/mp.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/lag/mp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/lag/mp.c- Extension
.c- Size
- 10582 bytes
- Lines
- 412
- 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.hnet/nexthop.hlag/lag.hlag/mp.hmlx5_core.heswitch.hlib/events.h
Detected Declarations
struct mlx5_fib_event_workfunction __mlx5_lag_is_multipathfunction mlx5_lag_multipath_check_prereqfunction mlx5_lag_is_multipathfunction mlx5_lag_set_port_affinityfunction mlx5_lag_fib_event_flushfunction mlx5_lag_fib_setfunction mlx5_lag_get_next_fib_devfunction mlx5_lag_fib_route_eventfunction mlx5_lag_fib_nexthop_eventfunction mlx5_ldev_for_eachfunction fib_info_num_pathfunction mlx5_lag_fib_updatefunction mlx5_lag_init_fib_workfunction mlx5_lag_fib_eventfunction mlx5_lag_mp_resetfunction mlx5_lag_mp_initfunction mlx5_lag_mp_cleanup
Annotated Snippet
struct mlx5_fib_event_work {
struct work_struct work;
struct mlx5_lag *ldev;
unsigned long event;
union {
struct fib_entry_notifier_info fen_info;
struct fib_nh_notifier_info fnh_info;
};
};
static struct net_device*
mlx5_lag_get_next_fib_dev(struct mlx5_lag *ldev,
struct fib_info *fi,
struct net_device *current_dev)
{
struct net_device *fib_dev;
int i, ldev_idx, nhs;
nhs = fib_info_num_path(fi);
i = 0;
if (current_dev) {
for (; i < nhs; i++) {
fib_dev = fib_info_nh(fi, i)->fib_nh_dev;
if (fib_dev == current_dev) {
i++;
break;
}
}
}
for (; i < nhs; i++) {
fib_dev = fib_info_nh(fi, i)->fib_nh_dev;
ldev_idx = mlx5_lag_dev_get_netdev_idx(ldev, fib_dev);
if (ldev_idx >= 0)
return mlx5_lag_pf(ldev, ldev_idx)->netdev;
}
return NULL;
}
static void mlx5_lag_fib_route_event(struct mlx5_lag *ldev, unsigned long event,
struct fib_entry_notifier_info *fen_info)
{
int idx = mlx5_lag_get_dev_index_by_seq(ldev, MLX5_LAG_P1);
struct net_device *nh_dev0, *nh_dev1;
struct fib_info *fi = fen_info->fi;
struct lag_mp *mp = &ldev->lag_mp;
int i, dev_idx = 0;
if (idx < 0)
return;
/* Handle delete event */
if (event == FIB_EVENT_ENTRY_DEL) {
/* stop track */
if (mp->fib.mfi == fi)
mp->fib.mfi = NULL;
return;
}
/* Handle multipath entry with lower priority value */
if (mp->fib.mfi &&
(mp->fib.dst != fen_info->dst || mp->fib.dst_len != fen_info->dst_len) &&
mp->fib.dst_len <= fen_info->dst_len &&
!(mp->fib.dst_len == fen_info->dst_len &&
fi->fib_priority < mp->fib.priority)) {
mlx5_core_dbg(mlx5_lag_pf(ldev, idx)->dev,
"Multipath entry with lower priority was rejected\n");
return;
}
nh_dev0 = mlx5_lag_get_next_fib_dev(ldev, fi, NULL);
nh_dev1 = mlx5_lag_get_next_fib_dev(ldev, fi, nh_dev0);
/* Handle add/replace event */
if (!nh_dev0) {
if (mp->fib.dst == fen_info->dst && mp->fib.dst_len == fen_info->dst_len)
mp->fib.mfi = NULL;
return;
}
if (nh_dev0 == nh_dev1) {
mlx5_core_warn(mlx5_lag_pf(ldev, idx)->dev,
"Multipath offload doesn't support routes with multiple nexthops of the same device");
return;
}
if (!nh_dev1) {
if (__mlx5_lag_is_active(ldev)) {
mlx5_ldev_for_each(i, 0, ldev) {
dev_idx++;
Annotation
- Immediate include surface: `linux/netdevice.h`, `net/nexthop.h`, `lag/lag.h`, `lag/mp.h`, `mlx5_core.h`, `eswitch.h`, `lib/events.h`.
- Detected declarations: `struct mlx5_fib_event_work`, `function __mlx5_lag_is_multipath`, `function mlx5_lag_multipath_check_prereq`, `function mlx5_lag_is_multipath`, `function mlx5_lag_set_port_affinity`, `function mlx5_lag_fib_event_flush`, `function mlx5_lag_fib_set`, `function mlx5_lag_get_next_fib_dev`, `function mlx5_lag_fib_route_event`, `function mlx5_lag_fib_nexthop_event`.
- 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.