drivers/net/ethernet/intel/fm10k/fm10k_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/fm10k/fm10k_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/fm10k/fm10k_main.c- Extension
.c- Size
- 54369 bytes
- Lines
- 2008
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/types.hlinux/module.hnet/ipv6.hnet/ip.hnet/tcp.hlinux/if_macvlan.hlinux/prefetch.hfm10k.h
Detected Declarations
struct fm10k_nvgre_hdrfunction fm10k_init_modulefunction fm10k_exit_modulefunction fm10k_alloc_mapped_pagefunction fm10k_alloc_rx_buffersfunction fm10k_reuse_rx_pagefunction fm10k_can_reuse_rx_pagefunction fm10k_add_rx_fragfunction fm10k_rx_checksumfunction BITfunction fm10k_type_transfunction fm10k_process_skb_fieldsfunction fm10k_is_non_eopfunction fm10k_cleanup_headersfunction fm10k_receive_skbfunction fm10k_clean_rx_irqfunction fm10k_tx_encap_offloadfunction fm10k_tsofunction fm10k_tx_csumfunction fm10k_tx_desc_flagsfunction fm10k_tx_desc_pushfunction __fm10k_maybe_stop_txfunction fm10k_maybe_stop_txfunction fm10k_tx_mapfunction fm10k_xmit_frame_ringfunction fm10k_get_tx_completedfunction fm10k_get_tx_pendingfunction fm10k_check_tx_hangfunction fm10k_tx_timeout_resetfunction fm10k_clean_tx_irqfunction fm10k_update_itrfunction fm10k_qv_enablefunction fm10k_pollfunction fm10k_for_each_ringfunction fm10k_for_each_ringfunction QoSfunction fm10k_set_rss_queuesfunction fm10k_set_num_queuesfunction fm10k_reset_num_queuesfunction fm10k_alloc_q_vectorfunction fm10k_free_q_vectorfunction fm10k_alloc_q_vectorsfunction fm10k_free_q_vectorsfunction fm10k_reset_msix_capabilityfunction fm10k_init_msix_capabilityfunction fm10k_cache_ring_qosfunction fm10k_cache_ring_rssfunction fm10k_assign_rings
Annotated Snippet
module_init(fm10k_init_module);
/**
* fm10k_exit_module - Driver Exit Cleanup Routine
*
* fm10k_exit_module is called just before the driver is removed
* from memory.
**/
static void __exit fm10k_exit_module(void)
{
fm10k_unregister_pci_driver();
fm10k_dbg_exit();
/* destroy driver workqueue */
destroy_workqueue(fm10k_workqueue);
}
module_exit(fm10k_exit_module);
static bool fm10k_alloc_mapped_page(struct fm10k_ring *rx_ring,
struct fm10k_rx_buffer *bi)
{
struct page *page = bi->page;
dma_addr_t dma;
/* Only page will be NULL if buffer was consumed */
if (likely(page))
return true;
/* alloc new page for storage */
page = dev_alloc_page();
if (unlikely(!page)) {
rx_ring->rx_stats.alloc_failed++;
return false;
}
/* map page for use */
dma = dma_map_page(rx_ring->dev, page, 0, PAGE_SIZE, DMA_FROM_DEVICE);
/* if mapping failed free memory back to system since
* there isn't much point in holding memory we can't use
*/
if (dma_mapping_error(rx_ring->dev, dma)) {
__free_page(page);
rx_ring->rx_stats.alloc_failed++;
return false;
}
bi->dma = dma;
bi->page = page;
bi->page_offset = 0;
return true;
}
/**
* fm10k_alloc_rx_buffers - Replace used receive buffers
* @rx_ring: ring to place buffers on
* @cleaned_count: number of buffers to replace
**/
void fm10k_alloc_rx_buffers(struct fm10k_ring *rx_ring, u16 cleaned_count)
{
union fm10k_rx_desc *rx_desc;
struct fm10k_rx_buffer *bi;
u16 i = rx_ring->next_to_use;
/* nothing to do */
if (!cleaned_count)
return;
rx_desc = FM10K_RX_DESC(rx_ring, i);
bi = &rx_ring->rx_buffer[i];
i -= rx_ring->count;
do {
if (!fm10k_alloc_mapped_page(rx_ring, bi))
break;
/* Refresh the desc even if buffer_addrs didn't change
* because each write-back erases this info.
*/
rx_desc->q.pkt_addr = cpu_to_le64(bi->dma + bi->page_offset);
rx_desc++;
bi++;
i++;
if (unlikely(!i)) {
rx_desc = FM10K_RX_DESC(rx_ring, 0);
bi = rx_ring->rx_buffer;
Annotation
- Immediate include surface: `linux/types.h`, `linux/module.h`, `net/ipv6.h`, `net/ip.h`, `net/tcp.h`, `linux/if_macvlan.h`, `linux/prefetch.h`, `fm10k.h`.
- Detected declarations: `struct fm10k_nvgre_hdr`, `function fm10k_init_module`, `function fm10k_exit_module`, `function fm10k_alloc_mapped_page`, `function fm10k_alloc_rx_buffers`, `function fm10k_reuse_rx_page`, `function fm10k_can_reuse_rx_page`, `function fm10k_add_rx_frag`, `function fm10k_rx_checksum`, `function BIT`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.