drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c- Extension
.c- Size
- 66712 bytes
- Lines
- 2337
- 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/errno.hlinux/netdevice.hnet/pkt_cls.hnet/red.hspectrum.hspectrum_span.hreg.h
Detected Declarations
struct mlxsw_sp_qdiscstruct mlxsw_sp_qdisc_opsstruct mlxsw_sp_qdisc_ets_bandstruct mlxsw_sp_qdisc_ets_datastruct mlxsw_sp_qdiscstruct mlxsw_sp_qdisc_statsstruct mlxsw_sp_qdisc_statestruct mlxsw_sp_qdisc_tree_validatestruct mlxsw_sp_qevent_blockstruct mlxsw_sp_qevent_bindingenum mlxsw_sp_qdisc_typefunction mlxsw_sp_qdisc_comparefunction mlxsw_sp_qdisc_walkfunction mlxsw_sp_qdisc_walk_cb_findfunction mlxsw_sp_qdisc_findfunction mlxsw_sp_qdisc_walk_cb_find_by_handlefunction mlxsw_sp_qdisc_find_by_handlefunction mlxsw_sp_qdisc_reduce_parent_backlogfunction mlxsw_sp_qdisc_get_prio_bitmapfunction mlxsw_sp_qdisc_get_tclass_numfunction mlxsw_sp_qdisc_destroyfunction mlxsw_sp_qdisc_tree_validate_childrenfunction __mlxsw_sp_qdisc_tree_validatefunction mlxsw_sp_qdisc_tree_validatefunction mlxsw_sp_qdisc_createfunction mlxsw_sp_qdisc_changefunction mlxsw_sp_qdisc_replacefunction mlxsw_sp_qdisc_get_statsfunction mlxsw_sp_qdisc_get_xstatsfunction mlxsw_sp_xstats_backlogfunction mlxsw_sp_xstats_tail_dropfunction mlxsw_sp_qdisc_bstats_per_priority_getfunction mlxsw_sp_qdisc_collect_tc_statsfunction mlxsw_sp_qdisc_update_statsfunction mlxsw_sp_qdisc_get_tc_statsfunction mlxsw_sp_tclass_congestion_enablefunction mlxsw_sp_tclass_congestion_disablefunction mlxsw_sp_setup_tc_qdisc_red_clean_statsfunction mlxsw_sp_qdisc_red_destroyfunction mlxsw_sp_qdisc_red_check_paramsfunction mlxsw_sp_qdisc_red_replacefunction mlxsw_sp_qdisc_leaf_unoffloadfunction mlxsw_sp_qdisc_red_unoffloadfunction mlxsw_sp_qdisc_get_red_xstatsfunction mlxsw_sp_qdisc_get_red_statsfunction mlxsw_sp_qdisc_leaf_find_classfunction __mlxsw_sp_setup_tc_redfunction mlxsw_sp_setup_tc_red
Annotated Snippet
struct mlxsw_sp_qdisc_ops {
enum mlxsw_sp_qdisc_type type;
int (*check_params)(struct mlxsw_sp_port *mlxsw_sp_port,
void *params);
int (*replace)(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle,
struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, void *params);
int (*destroy)(struct mlxsw_sp_port *mlxsw_sp_port,
struct mlxsw_sp_qdisc *mlxsw_sp_qdisc);
int (*get_stats)(struct mlxsw_sp_port *mlxsw_sp_port,
struct mlxsw_sp_qdisc *mlxsw_sp_qdisc,
struct tc_qopt_offload_stats *stats_ptr);
int (*get_xstats)(struct mlxsw_sp_port *mlxsw_sp_port,
struct mlxsw_sp_qdisc *mlxsw_sp_qdisc,
void *xstats_ptr);
void (*clean_stats)(struct mlxsw_sp_port *mlxsw_sp_port,
struct mlxsw_sp_qdisc *mlxsw_sp_qdisc);
/* unoffload - to be used for a qdisc that stops being offloaded without
* being destroyed.
*/
void (*unoffload)(struct mlxsw_sp_port *mlxsw_sp_port,
struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, void *params);
struct mlxsw_sp_qdisc *(*find_class)(struct mlxsw_sp_qdisc *mlxsw_sp_qdisc,
u32 parent);
unsigned int num_classes;
u8 (*get_prio_bitmap)(struct mlxsw_sp_qdisc *mlxsw_sp_qdisc,
struct mlxsw_sp_qdisc *child);
int (*get_tclass_num)(struct mlxsw_sp_qdisc *mlxsw_sp_qdisc,
struct mlxsw_sp_qdisc *child);
};
struct mlxsw_sp_qdisc_ets_band {
u8 prio_bitmap;
int tclass_num;
};
struct mlxsw_sp_qdisc_ets_data {
struct mlxsw_sp_qdisc_ets_band bands[IEEE_8021QAZ_MAX_TCS];
};
struct mlxsw_sp_qdisc {
u32 handle;
union {
struct red_stats red;
} xstats_base;
struct mlxsw_sp_qdisc_stats {
u64 tx_bytes;
u64 tx_packets;
u64 drops;
u64 overlimits;
u64 backlog;
} stats_base;
union {
struct mlxsw_sp_qdisc_ets_data *ets_data;
};
struct mlxsw_sp_qdisc_ops *ops;
struct mlxsw_sp_qdisc *parent;
struct mlxsw_sp_qdisc *qdiscs;
unsigned int num_classes;
};
struct mlxsw_sp_qdisc_state {
struct mlxsw_sp_qdisc root_qdisc;
/* When a PRIO or ETS are added, the invisible FIFOs in their bands are
* created first. When notifications for these FIFOs arrive, it is not
* known what qdisc their parent handle refers to. It could be a
* newly-created PRIO that will replace the currently-offloaded one, or
* it could be e.g. a RED that will be attached below it.
*
* As the notifications start to arrive, use them to note what the
* future parent handle is, and keep track of which child FIFOs were
* seen. Then when the parent is known, retroactively offload those
* FIFOs.
*/
u32 future_handle;
bool future_fifos[IEEE_8021QAZ_MAX_TCS];
struct mutex lock; /* Protects qdisc state. */
};
static bool
mlxsw_sp_qdisc_compare(struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, u32 handle)
{
return mlxsw_sp_qdisc->ops && mlxsw_sp_qdisc->handle == handle;
}
static struct mlxsw_sp_qdisc *
mlxsw_sp_qdisc_walk(struct mlxsw_sp_qdisc *qdisc,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/netdevice.h`, `net/pkt_cls.h`, `net/red.h`, `spectrum.h`, `spectrum_span.h`, `reg.h`.
- Detected declarations: `struct mlxsw_sp_qdisc`, `struct mlxsw_sp_qdisc_ops`, `struct mlxsw_sp_qdisc_ets_band`, `struct mlxsw_sp_qdisc_ets_data`, `struct mlxsw_sp_qdisc`, `struct mlxsw_sp_qdisc_stats`, `struct mlxsw_sp_qdisc_state`, `struct mlxsw_sp_qdisc_tree_validate`, `struct mlxsw_sp_qevent_block`, `struct mlxsw_sp_qevent_binding`.
- 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.