drivers/net/ethernet/amazon/ena/ena_netdev.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/amazon/ena/ena_netdev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/amazon/ena/ena_netdev.c- Extension
.c- Size
- 120416 bytes
- Lines
- 4382
- 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/ethtool.hlinux/kernel.hlinux/module.hlinux/numa.hlinux/pci.hlinux/utsname.hlinux/version.hlinux/vmalloc.hnet/ip.hena_netdev.hena_pci_id_tbl.hena_xdp.hena_phc.hena_devlink.hena_debugfs.h
Detected Declarations
function ena_tx_timeoutfunction update_rx_ring_mtufunction ena_change_mtufunction ena_xmit_commonfunction ena_com_prepare_txfunction ena_init_io_rings_commonfunction ena_init_io_ringsfunction ena_setup_tx_resourcesfunction ena_free_tx_resourcesfunction ena_setup_tx_resources_in_rangefunction ena_free_all_io_tx_resources_in_rangefunction ena_free_all_io_tx_resourcesfunction ena_setup_rx_resourcesfunction ena_free_rx_resourcesfunction ena_setup_all_rx_resourcesfunction ena_free_all_io_rx_resourcesfunction ena_alloc_rx_bufferfunction ena_unmap_rx_buff_attrsfunction ena_free_rx_pagefunction ena_refill_rx_bufsfunction ena_free_rx_bufsfunction ena_refill_all_rx_bufsfunction ena_free_all_rx_bufsfunction ena_unmap_tx_bufffunction ena_free_tx_bufsfunction ena_free_all_tx_bufsfunction ena_destroy_all_tx_queuesfunction ena_destroy_all_rx_queuesfunction ena_destroy_all_io_queuesfunction handle_invalid_req_idfunction validate_tx_req_idfunction ena_clean_tx_irqfunction ena_try_rx_buf_page_reusefunction ena_rx_checksumfunction ena_set_rx_hashfunction ena_xdp_handle_bufffunction ena_clean_rx_irqfunction ena_dim_workfunction ena_adjust_adaptive_rx_intr_moderationfunction ena_unmask_interruptfunction ena_update_ring_numa_nodefunction ena_io_pollfunction test_bitfunction contextfunction ena_intr_msix_mgmntfunction ena_intr_msix_iofunction ena_enable_msixfunction ena_setup_mgmnt_intr
Annotated Snippet
static const struct net_device_ops ena_netdev_ops = {
.ndo_open = ena_open,
.ndo_stop = ena_close,
.ndo_start_xmit = ena_start_xmit,
.ndo_get_stats64 = ena_get_stats64,
.ndo_tx_timeout = ena_tx_timeout,
.ndo_change_mtu = ena_change_mtu,
.ndo_validate_addr = eth_validate_addr,
.ndo_bpf = ena_xdp,
.ndo_xdp_xmit = ena_xdp_xmit,
};
static int ena_calc_io_queue_size(struct ena_adapter *adapter,
struct ena_com_dev_get_features_ctx *get_feat_ctx)
{
struct ena_admin_feature_llq_desc *llq = &get_feat_ctx->llq;
struct ena_com_dev *ena_dev = adapter->ena_dev;
u32 tx_queue_size = ENA_DEFAULT_RING_SIZE;
u32 rx_queue_size = ENA_DEFAULT_RING_SIZE;
u32 max_tx_queue_size;
u32 max_rx_queue_size;
/* If this function is called after driver load, the ring sizes have already
* been configured. Take it into account when recalculating ring size.
*/
if (adapter->tx_ring->ring_size)
tx_queue_size = adapter->tx_ring->ring_size;
if (adapter->rx_ring->ring_size)
rx_queue_size = adapter->rx_ring->ring_size;
if (ena_dev->supported_features & BIT(ENA_ADMIN_MAX_QUEUES_EXT)) {
struct ena_admin_queue_ext_feature_fields *max_queue_ext =
&get_feat_ctx->max_queue_ext.max_queue_ext;
max_rx_queue_size = min_t(u32, max_queue_ext->max_rx_cq_depth,
max_queue_ext->max_rx_sq_depth);
max_tx_queue_size = max_queue_ext->max_tx_cq_depth;
if (ena_dev->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_DEV)
max_tx_queue_size = min_t(u32, max_tx_queue_size,
llq->max_llq_depth);
else
max_tx_queue_size = min_t(u32, max_tx_queue_size,
max_queue_ext->max_tx_sq_depth);
adapter->max_tx_sgl_size = min_t(u16, ENA_PKT_MAX_BUFS,
max_queue_ext->max_per_packet_tx_descs);
adapter->max_rx_sgl_size = min_t(u16, ENA_PKT_MAX_BUFS,
max_queue_ext->max_per_packet_rx_descs);
} else {
struct ena_admin_queue_feature_desc *max_queues =
&get_feat_ctx->max_queues;
max_rx_queue_size = min_t(u32, max_queues->max_cq_depth,
max_queues->max_sq_depth);
max_tx_queue_size = max_queues->max_cq_depth;
if (ena_dev->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_DEV)
max_tx_queue_size = min_t(u32, max_tx_queue_size,
llq->max_llq_depth);
else
max_tx_queue_size = min_t(u32, max_tx_queue_size,
max_queues->max_sq_depth);
adapter->max_tx_sgl_size = min_t(u16, ENA_PKT_MAX_BUFS,
max_queues->max_packet_tx_descs);
adapter->max_rx_sgl_size = min_t(u16, ENA_PKT_MAX_BUFS,
max_queues->max_packet_rx_descs);
}
max_tx_queue_size = rounddown_pow_of_two(max_tx_queue_size);
max_rx_queue_size = rounddown_pow_of_two(max_rx_queue_size);
if (max_tx_queue_size < ENA_MIN_RING_SIZE) {
netdev_err(adapter->netdev, "Device max TX queue size: %d < minimum: %d\n",
max_tx_queue_size, ENA_MIN_RING_SIZE);
return -EINVAL;
}
if (max_rx_queue_size < ENA_MIN_RING_SIZE) {
netdev_err(adapter->netdev, "Device max RX queue size: %d < minimum: %d\n",
max_rx_queue_size, ENA_MIN_RING_SIZE);
return -EINVAL;
}
/* When forcing large headers, we multiply the entry size by 2, and therefore divide
* the queue size by 2, leaving the amount of memory used by the queues unchanged.
*/
if (adapter->large_llq_header_enabled) {
if ((llq->entry_size_ctrl_supported & ENA_ADMIN_LIST_ENTRY_SIZE_256B) &&
ena_dev->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_DEV) {
Annotation
- Immediate include surface: `linux/ethtool.h`, `linux/kernel.h`, `linux/module.h`, `linux/numa.h`, `linux/pci.h`, `linux/utsname.h`, `linux/version.h`, `linux/vmalloc.h`.
- Detected declarations: `function ena_tx_timeout`, `function update_rx_ring_mtu`, `function ena_change_mtu`, `function ena_xmit_common`, `function ena_com_prepare_tx`, `function ena_init_io_rings_common`, `function ena_init_io_rings`, `function ena_setup_tx_resources`, `function ena_free_tx_resources`, `function ena_setup_tx_resources_in_range`.
- 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.