drivers/net/ethernet/sfc/falcon/rx.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/sfc/falcon/rx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/sfc/falcon/rx.c- Extension
.c- Size
- 28788 bytes
- Lines
- 979
- 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
linux/socket.hlinux/in.hlinux/slab.hlinux/ip.hlinux/ipv6.hlinux/tcp.hlinux/udp.hlinux/prefetch.hlinux/moduleparam.hlinux/iommu.hnet/ip.hnet/checksum.hnet_driver.hefx.hfilter.hnic.hselftest.hworkarounds.h
Detected Declarations
function ef4_rx_buf_hashfunction ef4_rx_buf_nextfunction ef4_sync_rx_bufferfunction ef4_rx_config_page_splitfunction ef4_init_rx_buffersfunction ef4_unmap_rx_bufferfunction ef4_free_rx_buffersfunction ef4_recycle_rx_pagefunction ef4_fini_rx_bufferfunction ef4_recycle_rx_pagesfunction ef4_discard_rx_packetfunction serialisationfunction ef4_rx_slow_fillfunction ef4_rx_packet__check_lenfunction ef4_rx_packet_grofunction ef4_rx_packetfunction unlikelyfunction ef4_rx_deliverfunction __ef4_rx_packetfunction ef4_probe_rx_queuefunction ef4_init_rx_recycle_ringfunction ef4_init_rx_queuefunction ef4_fini_rx_queuefunction ef4_remove_rx_queuefunction ef4_filter_rfsfunction __ef4_filter_rfs_expirefunction ef4_filter_is_mc_recipient
Annotated Snippet
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 ef4_rx_page_state);
page_offset = sizeof(struct ef4_rx_page_state);
do {
index = rx_queue->added_count & rx_queue->ptr_mask;
rx_buf = ef4_rx_buffer(rx_queue, index);
rx_buf->dma_addr = dma_addr + efx->rx_ip_align;
rx_buf->page = page;
rx_buf->page_offset = page_offset + efx->rx_ip_align;
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 = EF4_RX_BUF_LAST_IN_PAGE;
} while (++count < efx->rx_pages_per_batch);
return 0;
}
/* Unmap a DMA-mapped page. This function is only called for the final RX
* buffer in a page.
*/
static void ef4_unmap_rx_buffer(struct ef4_nic *efx,
struct ef4_rx_buffer *rx_buf)
{
struct page *page = rx_buf->page;
if (page) {
struct ef4_rx_page_state *state = page_address(page);
dma_unmap_page(&efx->pci_dev->dev,
state->dma_addr,
PAGE_SIZE << efx->rx_buffer_order,
DMA_FROM_DEVICE);
}
}
static void ef4_free_rx_buffers(struct ef4_rx_queue *rx_queue,
struct ef4_rx_buffer *rx_buf,
unsigned int num_bufs)
{
do {
if (rx_buf->page) {
put_page(rx_buf->page);
rx_buf->page = NULL;
}
rx_buf = ef4_rx_buf_next(rx_queue, rx_buf);
} while (--num_bufs);
}
/* Attempt to recycle the page if there is an RX recycle ring; the page can
* only be added if this is the final RX buffer, to prevent pages being used in
* the descriptor ring and appearing in the recycle ring simultaneously.
*/
static void ef4_recycle_rx_page(struct ef4_channel *channel,
struct ef4_rx_buffer *rx_buf)
{
struct page *page = rx_buf->page;
struct ef4_rx_queue *rx_queue = ef4_channel_get_rx_queue(channel);
struct ef4_nic *efx = rx_queue->efx;
unsigned index;
/* Only recycle the page after processing the final buffer. */
if (!(rx_buf->flags & EF4_RX_BUF_LAST_IN_PAGE))
return;
Annotation
- Immediate include surface: `linux/socket.h`, `linux/in.h`, `linux/slab.h`, `linux/ip.h`, `linux/ipv6.h`, `linux/tcp.h`, `linux/udp.h`, `linux/prefetch.h`.
- Detected declarations: `function ef4_rx_buf_hash`, `function ef4_rx_buf_next`, `function ef4_sync_rx_buffer`, `function ef4_rx_config_page_split`, `function ef4_init_rx_buffers`, `function ef4_unmap_rx_buffer`, `function ef4_free_rx_buffers`, `function ef4_recycle_rx_page`, `function ef4_fini_rx_buffer`, `function ef4_recycle_rx_pages`.
- 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.