drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c- Extension
.c- Size
- 30940 bytes
- Lines
- 1075
- 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/mutex.hlinux/rhashtable.hnet/ipv6.hspectrum_mr.hspectrum_router.h
Detected Declarations
struct mlxsw_sp_mrstruct mlxsw_sp_mr_vifstruct mlxsw_sp_mr_vif_opsstruct mlxsw_sp_mr_vifstruct mlxsw_sp_mr_route_vif_entrystruct mlxsw_sp_mr_tablestruct mlxsw_sp_mr_table_opsstruct mlxsw_sp_mr_tablestruct mlxsw_sp_mr_routefunction mlxsw_sp_mr_vif_validfunction mlxsw_sp_mr_vif_existsfunction mlxsw_sp_mr_route_ivif_in_evifsfunction mlxsw_sp_mr_route_valid_evifs_numfunction mlxsw_sp_mr_route_actionfunction mlxsw_sp_mr_route_priofunction mlxsw_sp_mr_route_evif_linkfunction mlxsw_sp_mr_route_evif_unlinkfunction mlxsw_sp_mr_route_ivif_linkfunction mlxsw_sp_mr_route_ivif_unlinkfunction mlxsw_sp_mr_route_info_createfunction list_for_each_entryfunction mlxsw_sp_mr_route_info_destroyfunction mlxsw_sp_mr_route_writefunction mlxsw_sp_mr_route_erasefunction mlxsw_sp_mr_route_createfunction mlxsw_sp_mr_route_destroyfunction mlxsw_sp_mr_mfc_offload_setfunction mlxsw_sp_mr_mfc_offload_updatefunction __mlxsw_sp_mr_route_delfunction mlxsw_sp_mr_route_addfunction mlxsw_sp_mr_route_delfunction mlxsw_sp_mr_route_ivif_resolvefunction mlxsw_sp_mr_route_ivif_unresolvefunction mlxsw_sp_mr_route_evif_resolvefunction mlxsw_sp_mr_route_evif_unresolvefunction mlxsw_sp_mr_vif_resolvefunction mlxsw_sp_mr_vif_unresolvefunction mlxsw_sp_mr_vif_addfunction mlxsw_sp_mr_vif_delfunction mlxsw_sp_mr_dev_vif_lookupfunction mlxsw_sp_mr_rif_addfunction mlxsw_sp_mr_rif_delfunction mlxsw_sp_mr_rif_mtu_updatefunction mlxsw_sp_mr_route4_validatefunction mlxsw_sp_mr_route4_keyfunction mlxsw_sp_mr_route4_stargfunction mlxsw_sp_mr_vif4_is_regularfunction mlxsw_sp_mr_route6_validate
Annotated Snippet
struct mlxsw_sp_mr {
const struct mlxsw_sp_mr_ops *mr_ops;
void *catchall_route_priv;
struct delayed_work stats_update_dw;
struct list_head table_list;
struct mutex table_list_lock; /* Protects table_list */
#define MLXSW_SP_MR_ROUTES_COUNTER_UPDATE_INTERVAL 5000 /* ms */
unsigned long priv[];
/* priv has to be always the last item */
};
struct mlxsw_sp_mr_vif;
struct mlxsw_sp_mr_vif_ops {
bool (*is_regular)(const struct mlxsw_sp_mr_vif *vif);
};
struct mlxsw_sp_mr_vif {
struct net_device *dev;
const struct mlxsw_sp_rif *rif;
unsigned long vif_flags;
/* A list of route_vif_entry structs that point to routes that the VIF
* instance is used as one of the egress VIFs
*/
struct list_head route_evif_list;
/* A list of route_vif_entry structs that point to routes that the VIF
* instance is used as an ingress VIF
*/
struct list_head route_ivif_list;
/* Protocol specific operations for a VIF */
const struct mlxsw_sp_mr_vif_ops *ops;
};
struct mlxsw_sp_mr_route_vif_entry {
struct list_head vif_node;
struct list_head route_node;
struct mlxsw_sp_mr_vif *mr_vif;
struct mlxsw_sp_mr_route *mr_route;
};
struct mlxsw_sp_mr_table;
struct mlxsw_sp_mr_table_ops {
bool (*is_route_valid)(const struct mlxsw_sp_mr_table *mr_table,
const struct mr_mfc *mfc);
void (*key_create)(struct mlxsw_sp_mr_table *mr_table,
struct mlxsw_sp_mr_route_key *key,
struct mr_mfc *mfc);
bool (*is_route_starg)(const struct mlxsw_sp_mr_table *mr_table,
const struct mlxsw_sp_mr_route *mr_route);
};
struct mlxsw_sp_mr_table {
struct list_head node;
enum mlxsw_sp_l3proto proto;
struct mlxsw_sp *mlxsw_sp;
u32 vr_id;
struct mlxsw_sp_mr_vif vifs[MAXVIFS];
struct list_head route_list;
struct mutex route_list_lock; /* Protects route_list */
struct rhashtable route_ht;
const struct mlxsw_sp_mr_table_ops *ops;
char catchall_route_priv[];
/* catchall_route_priv has to be always the last item */
};
struct mlxsw_sp_mr_route {
struct list_head node;
struct rhash_head ht_node;
struct mlxsw_sp_mr_route_key key;
enum mlxsw_sp_mr_route_action route_action;
u16 min_mtu;
struct mr_mfc *mfc;
void *route_priv;
const struct mlxsw_sp_mr_table *mr_table;
/* A list of route_vif_entry structs that point to the egress VIFs */
struct list_head evif_list;
/* A route_vif_entry struct that point to the ingress VIF */
struct mlxsw_sp_mr_route_vif_entry ivif;
};
static const struct rhashtable_params mlxsw_sp_mr_route_ht_params = {
.key_len = sizeof(struct mlxsw_sp_mr_route_key),
.key_offset = offsetof(struct mlxsw_sp_mr_route, key),
.head_offset = offsetof(struct mlxsw_sp_mr_route, ht_node),
.automatic_shrinking = true,
};
static bool mlxsw_sp_mr_vif_valid(const struct mlxsw_sp_mr_vif *vif)
Annotation
- Immediate include surface: `linux/mutex.h`, `linux/rhashtable.h`, `net/ipv6.h`, `spectrum_mr.h`, `spectrum_router.h`.
- Detected declarations: `struct mlxsw_sp_mr`, `struct mlxsw_sp_mr_vif`, `struct mlxsw_sp_mr_vif_ops`, `struct mlxsw_sp_mr_vif`, `struct mlxsw_sp_mr_route_vif_entry`, `struct mlxsw_sp_mr_table`, `struct mlxsw_sp_mr_table_ops`, `struct mlxsw_sp_mr_table`, `struct mlxsw_sp_mr_route`, `function mlxsw_sp_mr_vif_valid`.
- 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.