drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c- Extension
.c- Size
- 52552 bytes
- Lines
- 1795
- 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/kernel.hlinux/types.hlinux/dcbnl.hlinux/if_ether.hlinux/list.hlinux/netlink.hspectrum.hcore.hport.hreg.h
Detected Declarations
struct mlxsw_sp_sb_prstruct mlxsw_cp_sb_occstruct mlxsw_sp_sb_cmstruct mlxsw_sp_sb_pmstruct mlxsw_sp_sb_mmstruct mlxsw_sp_sb_pool_desstruct mlxsw_sp_sb_portstruct mlxsw_sp_sbstruct mlxsw_sp_sb_valsstruct mlxsw_sp_sb_opsstruct mlxsw_sp_sb_sr_occ_query_cb_ctxfunction mlxsw_sp_cells_bytesfunction mlxsw_sp_bytes_cellsfunction mlxsw_sp_port_headroom_8x_adjustfunction mlxsw_sp_sb_cm_existsfunction mlxsw_sp_sb_pr_writefunction mlxsw_sp_sb_pr_desc_writefunction mlxsw_sp_sb_cm_writefunction mlxsw_sp_sb_pm_writefunction mlxsw_sp_sb_pm_occ_clearfunction mlxsw_sp_sb_pm_occ_query_cbfunction mlxsw_sp_sb_pm_occ_queryfunction mlxsw_sp_hdroom_prios_reset_buf_idxfunction mlxsw_sp_hdroom_bufs_reset_lossinessfunction mlxsw_sp_hdroom_buf_threshold_getfunction mlxsw_sp_hdroom_buf_packfunction mlxsw_sp_hdroom_buf_delay_getfunction mlxsw_sp_hdroom_int_buf_size_getfunction mlxsw_sp_hdroom_buf_is_usedfunction mlxsw_sp_hdroom_bufs_reset_sizesfunction mlxsw_sp_hdroom_configure_buffersfunction mlxsw_sp_hdroom_configure_priomapfunction mlxsw_sp_hdroom_configure_int_buffunction mlxsw_sp_hdroom_bufs_fitfunction __mlxsw_sp_hdroom_configurefunction mlxsw_sp_hdroom_configurefunction mlxsw_sp_port_headroom_initfunction mlxsw_sp_sb_port_initfunction mlxsw_sp_sb_port_finifunction mlxsw_sp_sb_ports_initfunction mlxsw_sp_sb_ports_finifunction mlxsw_sp_sb_prs_initfunction mlxsw_sp_sb_pool_is_staticfunction __mlxsw_sp_sb_cms_initfunction mlxsw_sp_port_sb_cms_initfunction mlxsw_sp_cpu_port_sb_cms_initfunction mlxsw_sp_sb_pms_initfunction mlxsw_sp_port_sb_pms_init
Annotated Snippet
struct mlxsw_sp_sb_pr {
enum mlxsw_reg_sbpr_mode mode;
u32 size;
u8 freeze_mode:1,
freeze_size:1;
};
struct mlxsw_cp_sb_occ {
u32 cur;
u32 max;
};
struct mlxsw_sp_sb_cm {
u32 min_buff;
u32 max_buff;
u16 pool_index;
struct mlxsw_cp_sb_occ occ;
u8 freeze_pool:1,
freeze_thresh:1;
};
#define MLXSW_SP_SB_INFI -1U
#define MLXSW_SP_SB_REST -2U
struct mlxsw_sp_sb_pm {
u32 min_buff;
u32 max_buff;
struct mlxsw_cp_sb_occ occ;
};
struct mlxsw_sp_sb_mm {
u32 min_buff;
u32 max_buff;
u16 pool_index;
};
struct mlxsw_sp_sb_pool_des {
enum mlxsw_reg_sbxx_dir dir;
u8 pool;
};
#define MLXSW_SP_SB_POOL_ING 0
#define MLXSW_SP_SB_POOL_EGR 4
#define MLXSW_SP_SB_POOL_EGR_MC 8
#define MLXSW_SP_SB_POOL_ING_CPU 9
#define MLXSW_SP_SB_POOL_EGR_CPU 10
static const struct mlxsw_sp_sb_pool_des mlxsw_sp1_sb_pool_dess[] = {
{MLXSW_REG_SBXX_DIR_INGRESS, 0},
{MLXSW_REG_SBXX_DIR_INGRESS, 1},
{MLXSW_REG_SBXX_DIR_INGRESS, 2},
{MLXSW_REG_SBXX_DIR_INGRESS, 3},
{MLXSW_REG_SBXX_DIR_EGRESS, 0},
{MLXSW_REG_SBXX_DIR_EGRESS, 1},
{MLXSW_REG_SBXX_DIR_EGRESS, 2},
{MLXSW_REG_SBXX_DIR_EGRESS, 3},
{MLXSW_REG_SBXX_DIR_EGRESS, 15},
{MLXSW_REG_SBXX_DIR_INGRESS, 4},
{MLXSW_REG_SBXX_DIR_EGRESS, 4},
};
static const struct mlxsw_sp_sb_pool_des mlxsw_sp2_sb_pool_dess[] = {
{MLXSW_REG_SBXX_DIR_INGRESS, 0},
{MLXSW_REG_SBXX_DIR_INGRESS, 1},
{MLXSW_REG_SBXX_DIR_INGRESS, 2},
{MLXSW_REG_SBXX_DIR_INGRESS, 3},
{MLXSW_REG_SBXX_DIR_EGRESS, 0},
{MLXSW_REG_SBXX_DIR_EGRESS, 1},
{MLXSW_REG_SBXX_DIR_EGRESS, 2},
{MLXSW_REG_SBXX_DIR_EGRESS, 3},
{MLXSW_REG_SBXX_DIR_EGRESS, 15},
{MLXSW_REG_SBXX_DIR_INGRESS, 4},
{MLXSW_REG_SBXX_DIR_EGRESS, 4},
};
#define MLXSW_SP_SB_ING_TC_COUNT 8
#define MLXSW_SP_SB_EG_TC_COUNT 16
struct mlxsw_sp_sb_port {
struct mlxsw_sp_sb_cm ing_cms[MLXSW_SP_SB_ING_TC_COUNT];
struct mlxsw_sp_sb_cm eg_cms[MLXSW_SP_SB_EG_TC_COUNT];
struct mlxsw_sp_sb_pm *pms;
};
struct mlxsw_sp_sb {
struct mlxsw_sp_sb_pr *prs;
struct mlxsw_sp_sb_port *ports;
u32 cell_size;
u32 max_headroom_cells;
u64 sb_size;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/types.h`, `linux/dcbnl.h`, `linux/if_ether.h`, `linux/list.h`, `linux/netlink.h`, `spectrum.h`, `core.h`.
- Detected declarations: `struct mlxsw_sp_sb_pr`, `struct mlxsw_cp_sb_occ`, `struct mlxsw_sp_sb_cm`, `struct mlxsw_sp_sb_pm`, `struct mlxsw_sp_sb_mm`, `struct mlxsw_sp_sb_pool_des`, `struct mlxsw_sp_sb_port`, `struct mlxsw_sp_sb`, `struct mlxsw_sp_sb_vals`, `struct mlxsw_sp_sb_ops`.
- 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.