drivers/net/ethernet/mellanox/mlx5/core/en_dim.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en_dim.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en_dim.c- Extension
.c- Size
- 4109 bytes
- Lines
- 150
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
en.hen/dim.h
Detected Declarations
function Copyrightfunction mlx5e_rx_dim_workfunction mlx5e_tx_dim_workfunction voidfunction mlx5e_dim_disablefunction mlx5e_dim_rx_changefunction mlx5e_dim_tx_change
Annotated Snippet
#include "en.h"
#include "en/dim.h"
static void
mlx5e_complete_dim_work(struct dim *dim, struct dim_cq_moder moder,
struct mlx5_core_dev *mdev, struct mlx5_core_cq *mcq)
{
mlx5e_modify_cq_moderation(mdev, mcq, moder.usec, moder.pkts,
mlx5e_cq_period_mode(moder.cq_period_mode));
dim->state = DIM_START_MEASURE;
}
void mlx5e_rx_dim_work(struct work_struct *work)
{
struct dim *dim = container_of(work, struct dim, work);
struct mlx5e_rq *rq = dim->priv;
struct dim_cq_moder cur_moder =
net_dim_get_rx_moderation(dim->mode, dim->profile_ix);
mlx5e_complete_dim_work(dim, cur_moder, rq->mdev, &rq->cq.mcq);
}
void mlx5e_tx_dim_work(struct work_struct *work)
{
struct dim *dim = container_of(work, struct dim, work);
struct mlx5e_txqsq *sq = dim->priv;
struct dim_cq_moder cur_moder =
net_dim_get_tx_moderation(dim->mode, dim->profile_ix);
mlx5e_complete_dim_work(dim, cur_moder, sq->cq.mdev, &sq->cq.mcq);
}
static struct dim *mlx5e_dim_enable(struct mlx5_core_dev *mdev,
void (*work_fun)(struct work_struct *), int cpu,
u8 cq_period_mode, struct mlx5_core_cq *mcq,
void *queue)
{
struct dim *dim;
int err;
dim = kvzalloc_node(sizeof(*dim), GFP_KERNEL, cpu_to_node(cpu));
if (!dim)
return ERR_PTR(-ENOMEM);
INIT_WORK(&dim->work, work_fun);
dim->mode = cq_period_mode;
dim->priv = queue;
err = mlx5e_modify_cq_period_mode(mdev, mcq, dim->mode);
if (err) {
kvfree(dim);
return ERR_PTR(err);
}
return dim;
}
static void mlx5e_dim_disable(struct dim *dim)
{
cancel_work_sync(&dim->work);
kvfree(dim);
}
int mlx5e_dim_rx_change(struct mlx5e_rq *rq, bool enable)
{
if (enable == !!rq->dim)
return 0;
if (enable) {
struct mlx5e_channel *c = rq->channel;
struct dim *dim;
dim = mlx5e_dim_enable(rq->mdev, mlx5e_rx_dim_work, c->cpu,
c->rx_cq_moder.cq_period_mode, &rq->cq.mcq, rq);
if (IS_ERR(dim))
return PTR_ERR(dim);
rq->dim = dim;
__set_bit(MLX5E_RQ_STATE_DIM, &rq->state);
} else {
__clear_bit(MLX5E_RQ_STATE_DIM, &rq->state);
synchronize_net();
mlx5e_dim_disable(rq->dim);
rq->dim = NULL;
}
return 0;
}
Annotation
- Immediate include surface: `en.h`, `en/dim.h`.
- Detected declarations: `function Copyright`, `function mlx5e_rx_dim_work`, `function mlx5e_tx_dim_work`, `function void`, `function mlx5e_dim_disable`, `function mlx5e_dim_rx_change`, `function mlx5e_dim_tx_change`.
- 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.