drivers/net/ethernet/mellanox/mlx5/core/en_common.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en_common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en_common.c- Extension
.c- Size
- 8244 bytes
- Lines
- 290
- 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
devlink.hen.hlib/crypto.h
Detected Declarations
function Copyrightfunction mlx5e_create_mkeyfunction mlx5e_create_tisfunction mlx5e_destroy_tisfunction mlx5e_destroy_tisesfunction mlx5_lag_should_assign_affinityfunction mlx5e_create_tisesfunction mlx5e_get_devlink_param_num_doorbellsfunction mlx5e_create_mdev_resourcesfunction mlx5e_destroy_mdev_resourcesfunction mlx5e_modify_tirs_lbfunction mlx5e_refresh_tirs
Annotated Snippet
if (err) {
mlx5_core_warn(mdev,
"could only allocate %d/%d doorbells, err %d.\n",
i, num_doorbells, err);
break;
}
}
res->num_bfregs = i;
if (create_tises) {
err = mlx5e_create_tises(mdev, res->tisn);
if (err) {
mlx5_core_err(mdev, "alloc tises failed, %d\n", err);
goto err_destroy_bfregs;
}
res->tisn_valid = true;
}
INIT_LIST_HEAD(&res->td.tirs_list);
mutex_init(&res->td.list_lock);
mdev->mlx5e_res.dek_priv = mlx5_crypto_dek_init(mdev);
if (IS_ERR(mdev->mlx5e_res.dek_priv)) {
mlx5_core_err(mdev, "crypto dek init failed, %pe\n",
mdev->mlx5e_res.dek_priv);
mdev->mlx5e_res.dek_priv = NULL;
}
return 0;
err_destroy_bfregs:
for (i = 0; i < res->num_bfregs; i++)
mlx5_free_bfreg(mdev, res->bfregs + i);
kfree(res->bfregs);
err_destroy_mkey:
mlx5_core_destroy_mkey(mdev, res->mkey);
err_dealloc_transport_domain:
mlx5_core_dealloc_transport_domain(mdev, res->td.tdn);
err_dealloc_pd:
mlx5_core_dealloc_pd(mdev, res->pdn);
return err;
}
void mlx5e_destroy_mdev_resources(struct mlx5_core_dev *mdev)
{
struct mlx5e_hw_objs *res = &mdev->mlx5e_res.hw_objs;
mlx5_crypto_dek_cleanup(mdev->mlx5e_res.dek_priv);
mdev->mlx5e_res.dek_priv = NULL;
if (res->tisn_valid)
mlx5e_destroy_tises(mdev, res->tisn);
for (unsigned int i = 0; i < res->num_bfregs; i++)
mlx5_free_bfreg(mdev, res->bfregs + i);
kfree(res->bfregs);
mlx5_core_destroy_mkey(mdev, res->mkey);
mlx5_core_dealloc_transport_domain(mdev, res->td.tdn);
mlx5_core_dealloc_pd(mdev, res->pdn);
memset(res, 0, sizeof(*res));
}
int mlx5e_modify_tirs_lb(struct mlx5_core_dev *mdev, bool enable_uc_lb,
bool enable_mc_lb)
{
struct mlx5e_tir_builder *builder;
struct mlx5e_tir *tir;
int err = 0;
builder = mlx5e_tir_builder_alloc(true);
if (!builder)
return -ENOMEM;
mlx5e_tir_builder_build_self_lb_block(builder, enable_uc_lb,
enable_mc_lb);
mutex_lock(&mdev->mlx5e_res.hw_objs.td.list_lock);
list_for_each_entry(tir, &mdev->mlx5e_res.hw_objs.td.tirs_list, list) {
err = mlx5e_tir_modify(tir, builder);
if (err) {
mlx5_core_err(mdev,
"modify tir(0x%x) enable_lb uc(%d) mc(%d) failed, %d\n",
mlx5e_tir_get_tirn(tir),
enable_uc_lb, enable_mc_lb, err);
break;
}
}
mutex_unlock(&mdev->mlx5e_res.hw_objs.td.list_lock);
mlx5e_tir_builder_free(builder);
return err;
Annotation
- Immediate include surface: `devlink.h`, `en.h`, `lib/crypto.h`.
- Detected declarations: `function Copyright`, `function mlx5e_create_mkey`, `function mlx5e_create_tis`, `function mlx5e_destroy_tis`, `function mlx5e_destroy_tises`, `function mlx5_lag_should_assign_affinity`, `function mlx5e_create_tises`, `function mlx5e_get_devlink_param_num_doorbells`, `function mlx5e_create_mdev_resources`, `function mlx5e_destroy_mdev_resources`.
- 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.