drivers/net/ethernet/mellanox/mlx4/intf.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx4/intf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx4/intf.c- Extension
.c- Size
- 9498 bytes
- Lines
- 391
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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
linux/slab.hlinux/export.hlinux/errno.hnet/devlink.hmlx4.h
Detected Declarations
function is_eth_supportedfunction is_ib_supportedfunction mlx4_adev_initfunction mlx4_adev_cleanupfunction adev_releasefunction del_adevfunction mlx4_register_auxiliary_driverfunction mlx4_unregister_auxiliary_driverfunction mlx4_do_bondfunction mlx4_dispatch_eventfunction mlx4_register_event_notifierfunction mlx4_unregister_event_notifierfunction add_driversfunction delete_driversfunction rescan_drivers_lockedfunction mlx4_register_devicefunction mlx4_unregister_devicefunction mlx4_is_slaveexport mlx4_register_auxiliary_driverexport mlx4_unregister_auxiliary_driverexport mlx4_register_event_notifierexport mlx4_unregister_event_notifierexport mlx4_get_devlink_port
Annotated Snippet
if (ret) {
mlx4_err(dev, "Fail to reset port map\n");
return ret;
}
dev->flags &= ~MLX4_FLAG_BONDED;
}
mutex_lock(&intf_mutex);
for (i = 0; i < ARRAY_SIZE(mlx4_adev_devices); i++) {
struct mlx4_adev *madev = priv->adev[i];
struct mlx4_adrv *madrv;
enum mlx4_protocol protocol;
if (!madev)
continue;
device_lock(&madev->adev.dev);
if (!madev->adev.dev.driver) {
device_unlock(&madev->adev.dev);
continue;
}
madrv = container_of(madev->adev.dev.driver, struct mlx4_adrv,
adrv.driver);
if (!(madrv->flags & MLX4_INTFF_BONDING)) {
device_unlock(&madev->adev.dev);
continue;
}
if (mlx4_is_mfunc(dev)) {
mlx4_dbg(dev,
"SRIOV, disabled HA mode for intf proto %d\n",
madrv->protocol);
device_unlock(&madev->adev.dev);
continue;
}
protocol = madrv->protocol;
device_unlock(&madev->adev.dev);
del_adev(&madev->adev);
priv->adev[i] = add_adev(dev, i);
if (IS_ERR(priv->adev[i])) {
mlx4_warn(dev, "Device[%d] (%s) failed to load\n", i,
mlx4_adev_devices[i].suffix);
priv->adev[i] = NULL;
continue;
}
mlx4_dbg(dev,
"Interface for protocol %d restarted with bonded mode %s\n",
protocol, enable ? "enabled" : "disabled");
}
mutex_unlock(&intf_mutex);
return 0;
}
void mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_dev_event type,
void *param)
{
struct mlx4_priv *priv = mlx4_priv(dev);
atomic_notifier_call_chain(&priv->event_nh, type, param);
}
int mlx4_register_event_notifier(struct mlx4_dev *dev,
struct notifier_block *nb)
{
struct mlx4_priv *priv = mlx4_priv(dev);
return atomic_notifier_chain_register(&priv->event_nh, nb);
}
EXPORT_SYMBOL(mlx4_register_event_notifier);
int mlx4_unregister_event_notifier(struct mlx4_dev *dev,
struct notifier_block *nb)
{
struct mlx4_priv *priv = mlx4_priv(dev);
return atomic_notifier_chain_unregister(&priv->event_nh, nb);
}
EXPORT_SYMBOL(mlx4_unregister_event_notifier);
static int add_drivers(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
int i, ret = 0;
Annotation
- Immediate include surface: `linux/slab.h`, `linux/export.h`, `linux/errno.h`, `net/devlink.h`, `mlx4.h`.
- Detected declarations: `function is_eth_supported`, `function is_ib_supported`, `function mlx4_adev_init`, `function mlx4_adev_cleanup`, `function adev_release`, `function del_adev`, `function mlx4_register_auxiliary_driver`, `function mlx4_unregister_auxiliary_driver`, `function mlx4_do_bond`, `function mlx4_dispatch_event`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.