drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c- Extension
.c- Size
- 16494 bytes
- Lines
- 593
- 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
port_buffer.h
Detected Declarations
struct mlx5e_buffer_poolstruct mlx5_sbcm_paramsfunction Copyrightfunction mlx5e_port_query_poolfunction select_sbcm_paramsfunction port_update_pool_cfgfunction port_update_shared_bufferfunction port_set_bufferfunction calculate_xofffunction update_xoff_thresholdfunction update_buffer_lossyfunction fill_pfc_enfunction mlx5e_port_manual_buffer_config
Annotated Snippet
struct mlx5e_buffer_pool {
u32 infi_size;
u32 size;
u32 buff_occupancy;
};
static int mlx5e_port_query_pool(struct mlx5_core_dev *mdev,
struct mlx5e_buffer_pool *buffer_pool,
u32 desc, u8 dir, u8 pool_idx)
{
u32 out[MLX5_ST_SZ_DW(sbpr_reg)] = {};
int err;
err = mlx5e_port_query_sbpr(mdev, desc, dir, pool_idx, out,
sizeof(out));
if (err)
return err;
buffer_pool->size = MLX5_GET(sbpr_reg, out, size);
buffer_pool->infi_size = MLX5_GET(sbpr_reg, out, infi_size);
buffer_pool->buff_occupancy = MLX5_GET(sbpr_reg, out, buff_occupancy);
return err;
}
enum {
MLX5_INGRESS_DIR = 0,
MLX5_EGRESS_DIR = 1,
};
enum {
MLX5_LOSSY_POOL = 0,
MLX5_LOSSLESS_POOL = 1,
};
/* No limit on usage of shared buffer pool (max_buff=0) */
#define MLX5_SB_POOL_NO_THRESHOLD 0
/* Shared buffer pool usage threshold when calculated
* dynamically in alpha units. alpha=13 is equivalent to
* HW_alpha of [(1/128) * 2 ^ (alpha-1)] = 32, where HW_alpha
* equates to the following portion of the shared buffer pool:
* [32 / (1 + n * 32)] While *n* is the number of buffers
* that are using the shared buffer pool.
*/
#define MLX5_SB_POOL_THRESHOLD 13
/* Shared buffer class management parameters */
struct mlx5_sbcm_params {
u8 pool_idx;
u8 max_buff;
u8 infi_size;
};
static const struct mlx5_sbcm_params sbcm_default = {
.pool_idx = MLX5_LOSSY_POOL,
.max_buff = MLX5_SB_POOL_NO_THRESHOLD,
.infi_size = 0,
};
static const struct mlx5_sbcm_params sbcm_lossy = {
.pool_idx = MLX5_LOSSY_POOL,
.max_buff = MLX5_SB_POOL_NO_THRESHOLD,
.infi_size = 1,
};
static const struct mlx5_sbcm_params sbcm_lossless = {
.pool_idx = MLX5_LOSSLESS_POOL,
.max_buff = MLX5_SB_POOL_THRESHOLD,
.infi_size = 0,
};
static const struct mlx5_sbcm_params sbcm_lossless_no_threshold = {
.pool_idx = MLX5_LOSSLESS_POOL,
.max_buff = MLX5_SB_POOL_NO_THRESHOLD,
.infi_size = 1,
};
/**
* select_sbcm_params() - selects the shared buffer pool configuration
*
* @buffer: <input> port buffer to retrieve params of
* @lossless_buff_count: <input> number of lossless buffers in total
*
* The selection is based on the following rules:
* 1. If buffer size is 0, no shared buffer pool is used.
* 2. If buffer is lossy, use lossy shared buffer pool.
* 3. If there are more than 1 lossless buffers, use lossless shared buffer pool
* with threshold.
* 4. If there is only 1 lossless buffer, use lossless shared buffer pool
* without threshold.
Annotation
- Immediate include surface: `port_buffer.h`.
- Detected declarations: `struct mlx5e_buffer_pool`, `struct mlx5_sbcm_params`, `function Copyright`, `function mlx5e_port_query_pool`, `function select_sbcm_params`, `function port_update_pool_cfg`, `function port_update_shared_buffer`, `function port_set_buffer`, `function calculate_xoff`, `function update_xoff_threshold`.
- 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.