drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c- Extension
.c- Size
- 320912 bytes
- Lines
- 11786
- 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/types.hlinux/rhashtable.hlinux/bitops.hlinux/in6.hlinux/notifier.hlinux/inetdevice.hlinux/netdevice.hlinux/if_bridge.hlinux/socket.hlinux/route.hlinux/gcd.hlinux/if_macvlan.hlinux/refcount.hlinux/jhash.hlinux/net_namespace.hlinux/mutex.hlinux/genalloc.hlinux/xarray.hnet/netevent.hnet/neighbour.hnet/arp.hnet/inet_dscp.hnet/ip_fib.hnet/ip6_fib.hnet/nexthop.hnet/fib_rules.hnet/ip_tunnels.hnet/l3mdev.hnet/addrconf.hnet/ndisc.hnet/ipv6.h
Detected Declarations
struct mlxsw_sp_fibstruct mlxsw_sp_vrstruct mlxsw_sp_lpm_treestruct mlxsw_sp_rif_opsstruct mlxsw_sp_crif_keystruct mlxsw_sp_crifstruct mlxsw_sp_rifstruct mlxsw_sp_rif_paramsstruct mlxsw_sp_rif_subportstruct mlxsw_sp_rif_ipip_lbstruct mlxsw_sp_rif_params_ipip_lbstruct mlxsw_sp_rif_opsstruct mlxsw_sp_rif_mac_profilestruct mlxsw_sp_router_opsstruct mlxsw_sp_rif_counter_set_basicstruct mlxsw_sp_prefix_usagestruct mlxsw_sp_fib_keystruct mlxsw_sp_nexthop_group_infostruct mlxsw_sp_nexthop_groupstruct mlxsw_sp_fib_entrystruct mlxsw_sp_fib_nodestruct mlxsw_sp_fib_entry_decapstruct mlxsw_sp_fib_entrystruct mlxsw_sp_fib4_entrystruct mlxsw_sp_fib6_entrystruct mlxsw_sp_rt6struct mlxsw_sp_lpm_treestruct mlxsw_sp_fibstruct mlxsw_sp_vrstruct mlxsw_sp_neigh_keystruct mlxsw_sp_neigh_entrystruct mlxsw_sp_netevent_workstruct mlxsw_sp_neigh_rif_made_syncstruct mlxsw_sp_nexthop_keystruct mlxsw_sp_nexthop_counterstruct mlxsw_sp_nexthopstruct mlxsw_sp_nexthop_group_infostruct mlxsw_sp_nexthop_group_vr_keystruct mlxsw_sp_nexthop_group_vr_entrystruct mlxsw_sp_nexthop_groupstruct mlxsw_sp_nexthop_counterstruct mlxsw_sp_nexthop_group_cmp_argstruct mlxsw_sp_adj_grp_size_rangestruct mlxsw_sp_fib6_event_workstruct mlxsw_sp_fib_event_workstruct mlxsw_sp_router_hwstats_notify_workstruct mlxsw_sp_inet6addr_event_workstruct mlxsw_sp_router_replay_inetaddr_up
Annotated Snippet
struct mlxsw_sp_crif_key {
struct net_device *dev;
};
struct mlxsw_sp_crif {
struct mlxsw_sp_crif_key key;
struct rhash_head ht_node;
bool can_destroy;
struct list_head nexthop_list;
struct mlxsw_sp_rif *rif;
};
static const struct rhashtable_params mlxsw_sp_crif_ht_params = {
.key_offset = offsetof(struct mlxsw_sp_crif, key),
.key_len = sizeof_field(struct mlxsw_sp_crif, key),
.head_offset = offsetof(struct mlxsw_sp_crif, ht_node),
};
struct mlxsw_sp_rif {
struct mlxsw_sp_crif *crif; /* NULL for underlay RIF */
netdevice_tracker dev_tracker;
struct list_head neigh_list;
struct mlxsw_sp_fid *fid;
unsigned char addr[ETH_ALEN];
int mtu;
u16 rif_index;
u8 mac_profile_id;
u8 rif_entries;
u16 vr_id;
const struct mlxsw_sp_rif_ops *ops;
struct mlxsw_sp *mlxsw_sp;
unsigned int counter_ingress;
bool counter_ingress_valid;
unsigned int counter_egress;
bool counter_egress_valid;
};
static struct net_device *mlxsw_sp_rif_dev(const struct mlxsw_sp_rif *rif)
{
if (!rif->crif)
return NULL;
return rif->crif->key.dev;
}
struct mlxsw_sp_rif_params {
struct net_device *dev;
union {
u16 system_port;
u16 lag_id;
};
u16 vid;
bool lag;
bool double_entry;
};
struct mlxsw_sp_rif_subport {
struct mlxsw_sp_rif common;
refcount_t ref_count;
union {
u16 system_port;
u16 lag_id;
};
u16 vid;
bool lag;
};
struct mlxsw_sp_rif_ipip_lb {
struct mlxsw_sp_rif common;
struct mlxsw_sp_rif_ipip_lb_config lb_config;
u16 ul_vr_id; /* Spectrum-1. */
u16 ul_rif_id; /* Spectrum-2+. */
};
struct mlxsw_sp_rif_params_ipip_lb {
struct mlxsw_sp_rif_params common;
struct mlxsw_sp_rif_ipip_lb_config lb_config;
};
struct mlxsw_sp_rif_ops {
enum mlxsw_sp_rif_type type;
size_t rif_size;
void (*setup)(struct mlxsw_sp_rif *rif,
const struct mlxsw_sp_rif_params *params);
int (*configure)(struct mlxsw_sp_rif *rif,
struct netlink_ext_ack *extack);
void (*deconfigure)(struct mlxsw_sp_rif *rif);
struct mlxsw_sp_fid * (*fid_get)(struct mlxsw_sp_rif *rif,
const struct mlxsw_sp_rif_params *params,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/types.h`, `linux/rhashtable.h`, `linux/bitops.h`, `linux/in6.h`, `linux/notifier.h`, `linux/inetdevice.h`, `linux/netdevice.h`.
- Detected declarations: `struct mlxsw_sp_fib`, `struct mlxsw_sp_vr`, `struct mlxsw_sp_lpm_tree`, `struct mlxsw_sp_rif_ops`, `struct mlxsw_sp_crif_key`, `struct mlxsw_sp_crif`, `struct mlxsw_sp_rif`, `struct mlxsw_sp_rif_params`, `struct mlxsw_sp_rif_subport`, `struct mlxsw_sp_rif_ipip_lb`.
- 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.