drivers/net/ethernet/mellanox/mlx5/core/en_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en_main.c- Extension
.c- Size
- 187296 bytes
- Lines
- 7064
- 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/dim.hnet/tc_act/tc_gact.hlinux/mlx5/fs.hnet/vxlan.hnet/geneve.hlinux/bpf.hlinux/debugfs.hlinux/if_bridge.hlinux/filter.hnet/netdev_lock.hnet/netdev_queues.hnet/netdev_rx_queue.hnet/page_pool/types.hnet/pkt_sched.hnet/xdp_sock_drv.heswitch.hen.hen/dim.hen/txrx.hen_tc.hen_rep.hen_accel/ipsec.hen_accel/psp.hen_accel/macsec.hen_accel/en_accel.hen_accel/ktls.hlib/vxlan.hlib/clock.hen/port.hen/xdp.hlib/eq.hen/monitor_stats.h
Detected Declarations
struct mlx5_qmgmt_datafunction Copyrightfunction mlx5e_check_fragmented_striding_rq_capfunction mlx5e_update_carrierfunction mlx5e_update_carrier_workfunction mlx5e_update_stats_workfunction mlx5e_queue_update_statsfunction async_eventfunction mlx5e_enable_async_eventsfunction mlx5e_disable_async_eventsfunction mlx5e_devcom_event_mpvfunction mlx5e_devcom_init_mpvfunction mlx5e_devcom_cleanup_mpvfunction blocking_eventfunction mlx5e_enable_blocking_eventsfunction mlx5e_disable_blocking_eventsfunction mlx5e_mpwrq_umr_octowordsfunction mlx5e_build_umr_wqefunction mlx5e_rq_alloc_mpwqe_infofunction mlx5e_rq_alloc_mpwqe_linear_infofunction mlx5e_mpwrq_access_modefunction mlx5e_create_umr_mkeyfunction pagefunction mlx5e_create_rq_umr_mkeyfunction mlx5e_init_frags_partitionfunction mlx5e_init_xsk_buffsfunction mlx5e_init_wqe_alloc_infofunction mlx5e_free_wqe_alloc_infofunction mlx5e_rq_err_cqe_workfunction mlx5e_rq_timeout_workfunction mlx5e_alloc_mpwqe_rq_drop_pagefunction mlx5e_free_mpwqe_rq_drop_pagefunction mlx5e_init_rxq_rqfunction mlx5e_release_rq_hd_pagesfunction mlx5e_alloc_rq_hd_pagesfunction mlx5e_create_rq_hd_mkeyfunction mlx5_rq_shampo_allocfunction mlx5e_rq_free_shampofunction mlx5e_alloc_rqfunction mlx5e_free_rqfunction mlx5e_create_rqfunction mlx5e_modify_rq_statefunction mlx5e_flush_rq_cqfunction mlx5e_flush_rqfunction mlx5e_modify_rq_vsdfunction mlx5e_destroy_rqfunction mlx5e_wait_for_min_rx_wqesfunction mlx5e_free_rx_missing_descs
Annotated Snippet
const struct net_device_ops *netdev_ops = c->netdev->netdev_ops;
struct dim_cq_moder icocq_moder = {0, 0};
struct mlx5e_create_cq_param ccp;
int err;
mlx5e_build_create_cq_param(&ccp, c);
err = mlx5e_open_cq(c->mdev, icocq_moder, &cparam->icosq.cqp, &ccp,
&c->icosq.cq);
if (err)
return err;
err = mlx5e_open_tx_cqs(c, params, &ccp, cparam);
if (err)
goto err_close_icosq_cq;
if (netdev_ops->ndo_xdp_xmit && c->xdp) {
c->xdpsq = mlx5e_open_xdpredirect_sq(c, params, cparam, &ccp);
if (IS_ERR(c->xdpsq)) {
err = PTR_ERR(c->xdpsq);
goto err_close_tx_cqs;
}
}
err = mlx5e_open_cq(c->mdev, params->rx_cq_moderation, &cparam->rq.cqp, &ccp,
&c->rq.cq);
if (err)
goto err_close_xdpredirect_sq;
err = c->xdp ? mlx5e_open_cq(c->mdev, params->tx_cq_moderation, &cparam->xdp_sq.cqp,
&ccp, &c->rq_xdpsq.cq) : 0;
if (err)
goto err_close_rx_cq;
if (async_icosq_needed) {
c->async_icosq = mlx5e_open_async_icosq(c, params, cparam,
&ccp);
if (IS_ERR(c->async_icosq)) {
err = PTR_ERR(c->async_icosq);
goto err_close_rq_xdpsq_cq;
}
}
mutex_init(&c->icosq_recovery_lock);
err = mlx5e_open_icosq(c, params, &cparam->icosq, &c->icosq,
mlx5e_icosq_err_cqe_work);
if (err)
goto err_close_async_icosq;
err = mlx5e_open_sqs(c, params, cparam);
if (err)
goto err_close_icosq;
err = mlx5e_open_rxq_rq(c, params, &cparam->rq, &cparam->rq_opt);
if (err)
goto err_close_sqs;
if (c->xdp) {
err = mlx5e_open_xdpsq(c, params, &cparam->xdp_sq, NULL,
&c->rq_xdpsq, false);
if (err)
goto err_close_rq;
}
return 0;
err_close_rq:
mlx5e_close_rq(&c->rq);
err_close_sqs:
mlx5e_close_sqs(c);
err_close_icosq:
mlx5e_close_icosq(&c->icosq);
err_close_async_icosq:
if (c->async_icosq)
mlx5e_close_async_icosq(c->async_icosq);
err_close_rq_xdpsq_cq:
if (c->xdp)
mlx5e_close_cq(&c->rq_xdpsq.cq);
err_close_rx_cq:
mlx5e_close_cq(&c->rq.cq);
err_close_xdpredirect_sq:
if (c->xdpsq)
mlx5e_close_xdpredirect_sq(c->xdpsq);
Annotation
- Immediate include surface: `linux/dim.h`, `net/tc_act/tc_gact.h`, `linux/mlx5/fs.h`, `net/vxlan.h`, `net/geneve.h`, `linux/bpf.h`, `linux/debugfs.h`, `linux/if_bridge.h`.
- Detected declarations: `struct mlx5_qmgmt_data`, `function Copyright`, `function mlx5e_check_fragmented_striding_rq_cap`, `function mlx5e_update_carrier`, `function mlx5e_update_carrier_work`, `function mlx5e_update_stats_work`, `function mlx5e_queue_update_stats`, `function async_event`, `function mlx5e_enable_async_events`, `function mlx5e_disable_async_events`.
- 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.