drivers/net/ethernet/wangxun/libwx/wx_lib.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/wangxun/libwx/wx_lib.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/wangxun/libwx/wx_lib.c- Extension
.c- Size
- 91090 bytes
- Lines
- 3350
- 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/etherdevice.hnet/ip6_checksum.hnet/page_pool/helpers.hnet/inet_ecn.hlinux/workqueue.hlinux/iopoll.hlinux/sctp.hlinux/pci.hnet/tcp.hnet/ip.hwx_type.hwx_lib.hwx_ptp.hwx_hw.hwx_vf_lib.h
Detected Declarations
function wx_decode_ptypefunction wx_test_staterrfunction wx_dma_sync_fragfunction wx_put_rx_bufferfunction wx_alloc_mapped_pagefunction wx_alloc_rx_buffersfunction wx_desc_unusedfunction wx_is_non_eopfunction wx_pull_tailfunction wx_cleanup_headersfunction unlikelyfunction wx_rx_hashfunction wx_rx_checksumfunction wx_test_staterrfunction wx_rx_vlanfunction wx_set_rsc_gso_sizefunction wx_update_rsc_statsfunction wx_process_skb_fieldsfunction wx_clean_rx_irqfunction wx_clean_tx_irqfunction wx_update_rx_dim_samplefunction wx_update_tx_dim_samplefunction wx_update_dim_samplefunction wx_pollfunction wx_for_each_ringfunction wx_for_each_ringfunction wx_maybe_stop_txfunction wx_tx_cmd_typefunction wx_tx_olinfo_statusfunction wx_tx_mapfunction wx_tx_ctxtdescfunction wx_encode_tx_desc_ptypefunction wx_tsofunction wx_tx_csumfunction wx_xmit_frame_ringfunction wx_xmit_framefunction wx_set_itrfunction wx_rx_dim_workfunction wx_tx_dim_workfunction wx_napi_enable_allfunction wx_napi_disable_allfunction wx_set_vmdq_queuesfunction wx_set_rss_queuesfunction wx_set_num_queuesfunction wx_acquire_msix_vectorsfunction wx_set_interrupt_capabilityfunction wx_cache_ring_vmdqfunction wx_cache_ring_rss
Annotated Snippet
if (size <= WX_RXBUFFER_256) {
memcpy(__skb_put(skb, size), page_addr,
ALIGN(size, sizeof(long)));
page_pool_put_full_page(rx_ring->page_pool, rx_buffer->page, true);
return skb;
}
skb_mark_for_recycle(skb);
if (!wx_test_staterr(rx_desc, WX_RXD_STAT_EOP))
WX_CB(skb)->dma = rx_buffer->dma;
skb_add_rx_frag(skb, 0, rx_buffer->page,
rx_buffer->page_offset,
size, truesize);
goto out;
} else {
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_buffer->page,
rx_buffer->page_offset, size, truesize);
}
out:
#if (PAGE_SIZE < 8192)
/* flip page offset to other buffer */
rx_buffer->page_offset ^= truesize;
#else
/* move offset up to the next cache line */
rx_buffer->page_offset += truesize;
#endif
return skb;
}
static bool wx_alloc_mapped_page(struct wx_ring *rx_ring,
struct wx_rx_buffer *bi)
{
struct page *page = bi->page;
dma_addr_t dma;
/* since we are recycling buffers we should seldom need to alloc */
if (likely(page))
return true;
page = page_pool_dev_alloc_pages(rx_ring->page_pool);
if (unlikely(!page))
return false;
dma = page_pool_get_dma_addr(page);
bi->dma = dma;
bi->page = page;
bi->page_offset = 0;
return true;
}
/**
* wx_alloc_rx_buffers - Replace used receive buffers
* @rx_ring: ring to place buffers on
* @cleaned_count: number of buffers to replace
**/
void wx_alloc_rx_buffers(struct wx_ring *rx_ring, u16 cleaned_count)
{
u16 i = rx_ring->next_to_use;
union wx_rx_desc *rx_desc;
struct wx_rx_buffer *bi;
/* nothing to do */
if (!cleaned_count)
return;
rx_desc = WX_RX_DESC(rx_ring, i);
bi = &rx_ring->rx_buffer_info[i];
i -= rx_ring->count;
do {
if (!wx_alloc_mapped_page(rx_ring, bi))
break;
/* sync the buffer for use by the device */
dma_sync_single_range_for_device(rx_ring->dev, bi->dma,
bi->page_offset,
rx_ring->rx_buf_len,
DMA_FROM_DEVICE);
rx_desc->read.pkt_addr =
cpu_to_le64(bi->dma + bi->page_offset);
rx_desc++;
bi++;
Annotation
- Immediate include surface: `linux/etherdevice.h`, `net/ip6_checksum.h`, `net/page_pool/helpers.h`, `net/inet_ecn.h`, `linux/workqueue.h`, `linux/iopoll.h`, `linux/sctp.h`, `linux/pci.h`.
- Detected declarations: `function wx_decode_ptype`, `function wx_test_staterr`, `function wx_dma_sync_frag`, `function wx_put_rx_buffer`, `function wx_alloc_mapped_page`, `function wx_alloc_rx_buffers`, `function wx_desc_unused`, `function wx_is_non_eop`, `function wx_pull_tail`, `function wx_cleanup_headers`.
- 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.