drivers/net/ethernet/sfc/rx_common.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/sfc/rx_common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/sfc/rx_common.c- Extension
.c- Size
- 30217 bytes
- Lines
- 1044
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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
net_driver.hlinux/module.hlinux/iommu.hnet/rps.hefx.hnic.hrx_common.h
Detected Declarations
function efx_recycle_rx_pagefunction efx_recycle_rx_pagesfunction efx_discard_rx_packetfunction efx_init_rx_recycle_ringfunction efx_fini_rx_recycle_ringfunction efx_fini_rx_bufferfunction efx_probe_rx_queuefunction efx_init_rx_queuefunction efx_fini_rx_queuefunction efx_remove_rx_queuefunction efx_unmap_rx_bufferfunction efx_free_rx_buffersfunction efx_rx_slow_fillfunction efx_schedule_slow_fillfunction efx_init_rx_buffersfunction efx_rx_config_page_splitfunction serialisationfunction efx_rx_packet_grofunction efx_set_default_rx_indir_tablefunction efx_filter_is_mc_recipientfunction efx_filter_spec_equalfunction efx_filter_spec_hashfunction efx_rps_check_rulefunction efx_rps_hash_delfunction efx_probe_filtersfunction efx_for_each_channelfunction efx_remove_filtersfunction efx_for_each_channelfunction efx_filter_rfs_workfunction efx_filter_rfsfunction __efx_filter_rfs_expire
Annotated Snippet
if (rx_buf->page) {
put_page(rx_buf->page);
rx_buf->page = NULL;
}
rx_buf = efx_rx_buf_next(rx_queue, rx_buf);
} while (--num_bufs);
}
void efx_rx_slow_fill(struct timer_list *t)
{
struct efx_rx_queue *rx_queue = timer_container_of(rx_queue, t,
slow_fill);
/* Post an event to cause NAPI to run and refill the queue */
efx_nic_generate_fill_event(rx_queue);
++rx_queue->slow_fill_count;
}
void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue)
{
mod_timer(&rx_queue->slow_fill, jiffies + msecs_to_jiffies(10));
}
/* efx_init_rx_buffers - create EFX_RX_BATCH page-based RX buffers
*
* @rx_queue: Efx RX queue
*
* This allocates a batch of pages, maps them for DMA, and populates
* struct efx_rx_buffers for each one. Return a negative error code or
* 0 on success. If a single page can be used for multiple buffers,
* then the page will either be inserted fully, or not at all.
*/
static int efx_init_rx_buffers(struct efx_rx_queue *rx_queue, bool atomic)
{
unsigned int page_offset, index, count;
struct efx_nic *efx = rx_queue->efx;
struct efx_rx_page_state *state;
struct efx_rx_buffer *rx_buf;
dma_addr_t dma_addr;
struct page *page;
count = 0;
do {
page = efx_reuse_page(rx_queue);
if (page == NULL) {
page = alloc_pages(__GFP_COMP |
(atomic ? GFP_ATOMIC : GFP_KERNEL),
efx->rx_buffer_order);
if (unlikely(page == NULL))
return -ENOMEM;
dma_addr =
dma_map_page(&efx->pci_dev->dev, page, 0,
PAGE_SIZE << efx->rx_buffer_order,
DMA_FROM_DEVICE);
if (unlikely(dma_mapping_error(&efx->pci_dev->dev,
dma_addr))) {
__free_pages(page, efx->rx_buffer_order);
return -EIO;
}
state = page_address(page);
state->dma_addr = dma_addr;
} else {
state = page_address(page);
dma_addr = state->dma_addr;
}
dma_addr += sizeof(struct efx_rx_page_state);
page_offset = sizeof(struct efx_rx_page_state);
do {
index = rx_queue->added_count & rx_queue->ptr_mask;
rx_buf = efx_rx_buffer(rx_queue, index);
rx_buf->dma_addr = dma_addr + efx->rx_ip_align +
EFX_XDP_HEADROOM;
rx_buf->page = page;
rx_buf->page_offset = page_offset + efx->rx_ip_align +
EFX_XDP_HEADROOM;
rx_buf->len = efx->rx_dma_len;
rx_buf->flags = 0;
++rx_queue->added_count;
get_page(page);
dma_addr += efx->rx_page_buf_step;
page_offset += efx->rx_page_buf_step;
} while (page_offset + efx->rx_page_buf_step <= PAGE_SIZE);
rx_buf->flags = EFX_RX_BUF_LAST_IN_PAGE;
} while (++count < efx->rx_pages_per_batch);
return 0;
}
Annotation
- Immediate include surface: `net_driver.h`, `linux/module.h`, `linux/iommu.h`, `net/rps.h`, `efx.h`, `nic.h`, `rx_common.h`.
- Detected declarations: `function efx_recycle_rx_page`, `function efx_recycle_rx_pages`, `function efx_discard_rx_packet`, `function efx_init_rx_recycle_ring`, `function efx_fini_rx_recycle_ring`, `function efx_fini_rx_buffer`, `function efx_probe_rx_queue`, `function efx_init_rx_queue`, `function efx_fini_rx_queue`, `function efx_remove_rx_queue`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.