drivers/net/ethernet/mellanox/mlx5/core/dev.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/dev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/dev.c- Extension
.c- Size
- 14718 bytes
- Lines
- 592
- 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/mlx5/driver.hlinux/mlx5/eswitch.hlinux/mlx5/mlx5_ifc_vdpa.hlinux/mlx5/vport.hmlx5_core.hdevlink.hlag/lag.h
Detected Declarations
function is_eth_rep_supportedfunction mlx5_eth_supportedfunction mlx5_vnet_supportedfunction is_vnet_enabledfunction is_ib_rep_supportedfunction is_mp_supportedfunction mlx5_rdma_supportedfunction is_ib_enabledfunction is_dpll_supportedfunction is_fwctl_supportedfunction mlx5_adev_idx_allocfunction mlx5_adev_idx_freefunction mlx5_adev_initfunction mlx5_adev_cleanupfunction adev_releasefunction del_adevfunction mlx5_dev_set_lightweightfunction mlx5_dev_is_lightweightfunction mlx5_attach_devicefunction mlx5_detach_devicefunction mlx5_register_devicefunction mlx5_unregister_devicefunction add_driversfunction delete_driversfunction mlx5_rescan_drivers_lockedfunction mlx5_same_hw_devsfunction mlx5_core_reps_aux_devs_remove
Annotated Snippet
if (!priv->adev[i]) {
bool is_supported = false;
if (mlx5_adev_devices[i].is_enabled) {
bool enabled;
enabled = mlx5_adev_devices[i].is_enabled(dev);
if (!enabled)
continue;
}
if (mlx5_adev_devices[i].is_supported)
is_supported = mlx5_adev_devices[i].is_supported(dev);
if (!is_supported)
continue;
priv->adev[i] = add_adev(dev, i);
if (IS_ERR(priv->adev[i])) {
ret = PTR_ERR(priv->adev[i]);
priv->adev[i] = NULL;
}
} else {
adev = &priv->adev[i]->adev;
/* Pay attention that this is not PCI driver that
* mlx5_core_dev is connected, but auxiliary driver.
*/
if (!adev->dev.driver)
continue;
adrv = to_auxiliary_drv(adev->dev.driver);
if (adrv->resume)
ret = adrv->resume(adev);
}
if (ret) {
mlx5_core_warn(dev, "Device[%d] (%s) failed to load\n",
i, mlx5_adev_devices[i].suffix);
break;
}
}
mlx5_devcom_comp_unlock(dev->priv.hca_devcom_comp);
return ret;
}
void mlx5_detach_device(struct mlx5_core_dev *dev, bool suspend)
{
struct mlx5_priv *priv = &dev->priv;
struct auxiliary_device *adev;
const struct auxiliary_driver *adrv;
pm_message_t pm = {};
int i;
devl_assert_locked(priv_to_devlink(dev));
mlx5_devcom_comp_lock(dev->priv.hca_devcom_comp);
for (i = ARRAY_SIZE(mlx5_adev_devices) - 1; i >= 0; i--) {
if (!priv->adev[i])
continue;
if (mlx5_adev_devices[i].is_enabled) {
bool enabled;
enabled = mlx5_adev_devices[i].is_enabled(dev);
if (!enabled)
goto skip_suspend;
}
adev = &priv->adev[i]->adev;
/* Auxiliary driver was unbind manually through sysfs */
if (!adev->dev.driver)
goto skip_suspend;
adrv = to_auxiliary_drv(adev->dev.driver);
if (adrv->suspend && suspend) {
adrv->suspend(adev, pm);
continue;
}
skip_suspend:
del_adev(&priv->adev[i]->adev);
priv->adev[i] = NULL;
}
priv->flags |= MLX5_PRIV_FLAGS_DETACH;
mlx5_devcom_comp_unlock(dev->priv.hca_devcom_comp);
}
int mlx5_register_device(struct mlx5_core_dev *dev)
{
Annotation
- Immediate include surface: `linux/mlx5/driver.h`, `linux/mlx5/eswitch.h`, `linux/mlx5/mlx5_ifc_vdpa.h`, `linux/mlx5/vport.h`, `mlx5_core.h`, `devlink.h`, `lag/lag.h`.
- Detected declarations: `function is_eth_rep_supported`, `function mlx5_eth_supported`, `function mlx5_vnet_supported`, `function is_vnet_enabled`, `function is_ib_rep_supported`, `function is_mp_supported`, `function mlx5_rdma_supported`, `function is_ib_enabled`, `function is_dpll_supported`, `function is_fwctl_supported`.
- 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.