drivers/infiniband/hw/mlx5/main.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/mlx5/main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/mlx5/main.c- Extension
.c- Size
- 147258 bytes
- Lines
- 5562
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- 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.
- 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/debugfs.hlinux/highmem.hlinux/module.hlinux/init.hlinux/errno.hlinux/pci.hlinux/dma-mapping.hlinux/slab.hlinux/bitmap.hlinux/log2.hlinux/sched.hlinux/sched/mm.hlinux/sched/task.hlinux/delay.hrdma/ib_user_verbs.hrdma/ib_addr.hrdma/ib_cache.hlinux/mlx5/port.hlinux/mlx5/vport.hlinux/mlx5/fs.hlinux/mlx5/eswitch.hlinux/mlx5/driver.hlinux/mlx5/lag.hlinux/list.hrdma/ib_smi.hrdma/ib_umem_odp.hrdma/lag.hlinux/in.hlinux/etherdevice.hmlx5_ib.hib_rep.hcmd.h
Detected Declarations
struct mlx5_ib_event_workstruct mlx5_reg_node_descenum ib_max_vl_numenum mlx5_vl_hw_capfunction mlx5_port_type_cap_to_rdma_llfunction mlx5_ib_port_link_layerfunction get_port_statefunction mlx5_netdev_send_eventfunction mlx5_netdev_eventfunction mlx5_ib_put_native_port_mdevfunction translate_eth_legacy_proto_operfunction translate_eth_ext_proto_operfunction translate_eth_proto_operfunction mlx5_query_port_rocefunction set_roce_addrfunction mlx5_ib_add_gidfunction mlx5_ib_del_gidfunction mlx5_get_roce_udp_sport_minfunction mlx5_use_mad_ifcfunction mlx5_get_vport_access_methodfunction get_atomic_capsfunction get_atomic_caps_qpfunction mlx5_query_system_image_guidfunction mlx5_query_max_pkeysfunction mlx5_query_vendor_idfunction mlx5_query_node_guidfunction mlx5_query_node_descfunction fill_esw_mgr_reg_c0function typesfunction mlx5_ib_calc_max_qp_wrfunction mlx5_ib_query_devicefunction translate_active_widthfunction mlx5_mtu_to_ib_mtufunction translate_max_vl_numfunction mlx5_query_hca_portfunction mlx5_ib_query_portfunction mlx5_ib_rep_query_portfunction mlx5_ib_rep_query_pkeyfunction mlx5_ib_query_port_speed_from_portfunction mlx5_ib_query_port_speed_from_vportfunction mlx5_ib_query_port_speed_from_bondfunction mlx5_ib_query_port_speed_non_repfunction mlx5_ib_query_port_speed_repfunction mlx5_ib_query_port_speedfunction mlx5_ib_query_gidfunction mlx5_query_hca_nic_pkeyfunction mlx5_ib_query_pkeyfunction mlx5_ib_modify_device
Annotated Snippet
static const struct file_operations fops_delay_drop_timeout = {
.owner = THIS_MODULE,
.open = simple_open,
.write = delay_drop_timeout_write,
.read = delay_drop_timeout_read,
};
static void mlx5_ib_unbind_slave_port(struct mlx5_ib_dev *ibdev,
struct mlx5_ib_multiport_info *mpi)
{
u32 port_num = mlx5_core_native_port_num(mpi->mdev) - 1;
struct mlx5_ib_port *port = &ibdev->port[port_num];
int comps;
int err;
int i;
lockdep_assert_held(&mlx5_ib_multiport_mutex);
mlx5_ib_disable_lb_mp(ibdev->mdev, mpi->mdev, &ibdev->lb);
mlx5_core_mp_event_replay(ibdev->mdev,
MLX5_DRIVER_EVENT_AFFILIATION_REMOVED,
NULL);
mlx5_core_mp_event_replay(mpi->mdev,
MLX5_DRIVER_EVENT_AFFILIATION_REMOVED,
NULL);
mlx5_ib_cleanup_cong_debugfs(ibdev, port_num);
spin_lock(&port->mp.mpi_lock);
if (!mpi->ibdev) {
spin_unlock(&port->mp.mpi_lock);
return;
}
mpi->ibdev = NULL;
spin_unlock(&port->mp.mpi_lock);
if (mpi->mdev_events.notifier_call)
mlx5_notifier_unregister(mpi->mdev, &mpi->mdev_events);
mpi->mdev_events.notifier_call = NULL;
mlx5_mdev_netdev_untrack(ibdev, port_num);
spin_lock(&port->mp.mpi_lock);
comps = mpi->mdev_refcnt;
if (comps) {
mpi->unaffiliate = true;
init_completion(&mpi->unref_comp);
spin_unlock(&port->mp.mpi_lock);
for (i = 0; i < comps; i++)
wait_for_completion(&mpi->unref_comp);
spin_lock(&port->mp.mpi_lock);
mpi->unaffiliate = false;
}
port->mp.mpi = NULL;
spin_unlock(&port->mp.mpi_lock);
err = mlx5_nic_vport_unaffiliate_multiport(mpi->mdev);
mlx5_ib_dbg(ibdev, "unaffiliated port %u\n", port_num + 1);
/* Log an error, still needed to cleanup the pointers and add
* it back to the list.
*/
if (err)
mlx5_ib_err(ibdev, "Failed to unaffiliate port %u\n",
port_num + 1);
ibdev->port[port_num].roce.last_port_state = IB_PORT_DOWN;
}
static bool mlx5_ib_bind_slave_port(struct mlx5_ib_dev *ibdev,
struct mlx5_ib_multiport_info *mpi)
{
u32 port_num = mlx5_core_native_port_num(mpi->mdev) - 1;
u64 key;
int err;
lockdep_assert_held(&mlx5_ib_multiport_mutex);
spin_lock(&ibdev->port[port_num].mp.mpi_lock);
if (ibdev->port[port_num].mp.mpi) {
mlx5_ib_dbg(ibdev, "port %u already affiliated.\n",
port_num + 1);
spin_unlock(&ibdev->port[port_num].mp.mpi_lock);
return false;
}
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/highmem.h`, `linux/module.h`, `linux/init.h`, `linux/errno.h`, `linux/pci.h`, `linux/dma-mapping.h`, `linux/slab.h`.
- Detected declarations: `struct mlx5_ib_event_work`, `struct mlx5_reg_node_desc`, `enum ib_max_vl_num`, `enum mlx5_vl_hw_cap`, `function mlx5_port_type_cap_to_rdma_ll`, `function mlx5_ib_port_link_layer`, `function get_port_state`, `function mlx5_netdev_send_event`, `function mlx5_netdev_event`, `function mlx5_ib_put_native_port_mdev`.
- Atlas domain: Driver Families / drivers/infiniband.
- Implementation status: pattern 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.