drivers/net/ethernet/mellanox/mlx4/main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx4/main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx4/main.c- Extension
.c- Size
- 127623 bytes
- Lines
- 4572
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/module.hlinux/kernel.hlinux/init.hlinux/errno.hlinux/pci.hlinux/dma-mapping.hlinux/slab.hlinux/io-mapping.hlinux/delay.hlinux/etherdevice.hnet/devlink.huapi/rdma/mlx4-abi.hlinux/mlx4/device.hlinux/mlx4/doorbell.hrdma/ib_verbs.hmlx4.hfw.hicm.h
Detected Declarations
struct mlx4_bondenum mlx4_devlink_param_idfunction mlx4_devlink_ierr_reset_getfunction mlx4_devlink_ierr_reset_setfunction mlx4_devlink_crdump_snapshot_getfunction mlx4_devlink_crdump_snapshot_setfunction mlx4_devlink_max_macs_validatefunction mlx4_devlink_set_params_init_valuesfunction mlx4_set_num_reserved_uarsfunction mlx4_check_port_paramsfunction mlx4_set_port_maskfunction mlx4_query_funcfunction mlx4_enable_cqe_eqe_stridefunction _mlx4_dev_portfunction mlx4_dev_portfunction mlx4_enable_ignore_fcsfunction mlx4_dev_capfunction mlx4_how_many_lives_vffunction mlx4_get_parav_qkeyfunction mlx4_sync_pkey_tablefunction mlx4_put_slave_node_guidfunction mlx4_get_slave_node_guidfunction mlx4_is_slave_activefunction mlx4_handle_eth_header_mcast_priofunction slave_adjust_steering_modefunction mlx4_slave_destroy_special_qp_capfunction mlx4_slave_special_qp_capfunction mlx4_slave_capfunction mlx4_change_port_typesfunction show_port_typefunction __set_port_typefunction set_port_typefunction int_to_ibta_mtufunction ibta_mtu_to_intfunction show_port_ib_mtufunction set_port_ib_mtufunction mlx4_mf_bondfunction mlx4_mf_unbondfunction mlx4_bondfunction mlx4_unbondfunction mlx4_port_map_setfunction mlx4_bond_workfunction mlx4_queue_bond_workfunction mlx4_load_fwfunction mlx4_init_cmpt_tablefunction mlx4_init_icmfunction mlx4_free_icmsfunction mlx4_slave_exit
Annotated Snippet
static struct pci_driver mlx4_driver = {
.name = DRV_NAME,
.id_table = mlx4_pci_table,
.probe = mlx4_init_one,
.shutdown = mlx4_shutdown,
.remove = mlx4_remove_one,
.driver.pm = &mlx4_pm_ops,
.err_handler = &mlx4_err_handler,
};
static int __init mlx4_verify_params(void)
{
if (msi_x < 0) {
pr_warn("mlx4_core: bad msi_x: %d\n", msi_x);
return -1;
}
if ((log_num_mac < 0) || (log_num_mac > 7)) {
pr_warn("mlx4_core: bad num_mac: %d\n", log_num_mac);
return -1;
}
if (log_num_vlan != 0)
pr_warn("mlx4_core: log_num_vlan - obsolete module param, using %d\n",
MLX4_LOG_NUM_VLANS);
if (use_prio != 0)
pr_warn("mlx4_core: use_prio - obsolete module param, ignored\n");
if ((log_mtts_per_seg < 0) || (log_mtts_per_seg > 7)) {
pr_warn("mlx4_core: bad log_mtts_per_seg: %d\n",
log_mtts_per_seg);
return -1;
}
/* Check if module param for ports type has legal combination */
if (port_type_array[0] == false && port_type_array[1] == true) {
pr_warn("Module parameter configuration ETH/IB is not supported. Switching to default configuration IB/IB\n");
port_type_array[0] = true;
}
if (mlx4_log_num_mgm_entry_size < -7 ||
(mlx4_log_num_mgm_entry_size > 0 &&
(mlx4_log_num_mgm_entry_size < MLX4_MIN_MGM_LOG_ENTRY_SIZE ||
mlx4_log_num_mgm_entry_size > MLX4_MAX_MGM_LOG_ENTRY_SIZE))) {
pr_warn("mlx4_core: mlx4_log_num_mgm_entry_size (%d) not in legal range (-7..0 or %d..%d)\n",
mlx4_log_num_mgm_entry_size,
MLX4_MIN_MGM_LOG_ENTRY_SIZE,
MLX4_MAX_MGM_LOG_ENTRY_SIZE);
return -1;
}
return 0;
}
static int __init mlx4_init(void)
{
int ret;
WARN_ONCE(strcmp(MLX4_ADEV_NAME, KBUILD_MODNAME),
"mlx4_core name not in sync with kernel module name");
if (mlx4_verify_params())
return -EINVAL;
mlx4_wq = create_singlethread_workqueue("mlx4");
if (!mlx4_wq)
return -ENOMEM;
ret = pci_register_driver(&mlx4_driver);
if (ret < 0)
destroy_workqueue(mlx4_wq);
return ret < 0 ? ret : 0;
}
static void __exit mlx4_cleanup(void)
{
pci_unregister_driver(&mlx4_driver);
destroy_workqueue(mlx4_wq);
}
module_init(mlx4_init);
module_exit(mlx4_cleanup);
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/init.h`, `linux/errno.h`, `linux/pci.h`, `linux/dma-mapping.h`, `linux/slab.h`, `linux/io-mapping.h`.
- Detected declarations: `struct mlx4_bond`, `enum mlx4_devlink_param_id`, `function mlx4_devlink_ierr_reset_get`, `function mlx4_devlink_ierr_reset_set`, `function mlx4_devlink_crdump_snapshot_get`, `function mlx4_devlink_crdump_snapshot_set`, `function mlx4_devlink_max_macs_validate`, `function mlx4_devlink_set_params_init_values`, `function mlx4_set_num_reserved_uars`, `function mlx4_check_port_params`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.