drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c- Extension
.c- Size
- 75406 bytes
- Lines
- 2956
- 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.
- 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/bitfield.hlinux/bpf.hlinux/bpf_trace.hlinux/iopoll.hlinux/pci.hnet/netdev_queues.hnet/page_pool/helpers.hnet/tcp.hnet/xdp.hfbnic.hfbnic_csr.hfbnic_netdev.hfbnic_txrx.h
Detected Declarations
struct fbnic_xmit_cbstruct fbnic_idle_regsfunction fbnic_ring_rd32function fbnic_ring_wr32function fbnic_ts40_to_nsfunction fbnic_desc_unusedfunction fbnic_desc_usedfunction fbnic_maybe_stop_txfunction fbnic_tx_sent_queuefunction fbnic_unmap_single_twdfunction fbnic_unmap_page_twdfunction fbnic_tx_tstampfunction fbnic_tx_lsofunction fbnic_tx_offloadsfunction fbnic_rx_csumfunction fbnic_tx_mapfunction fbnic_xmit_frame_ringfunction fbnic_xmit_framefunction fbnic_features_check_encap_gsofunction fbnic_features_checkfunction fbnic_clean_twq0function fbnic_clean_twq1function fbnic_clean_tsqfunction fbnic_page_pool_initfunction fbnic_page_pool_get_headfunction fbnic_page_pool_get_datafunction fbnic_page_pool_drainfunction fbnic_clean_twqfunction fbnic_clean_tcqfunction fbnic_clean_bdqfunction fbnic_bd_prepfunction fbnic_fill_bdqfunction fbnic_hdr_pg_startfunction fbnic_hdr_pg_endfunction fbnic_pkt_preparefunction fbnic_add_rx_fragfunction fbnic_put_pkt_bufffunction fbnic_pkt_txfunction fbnic_pkt_commit_tailfunction fbnic_skb_hash_typefunction fbnic_rx_tstampfunction fbnic_populate_skb_fieldsfunction fbnic_rcd_metadata_errfunction fbnic_clean_rcqfunction fbnic_nv_irq_disablefunction fbnic_nv_irq_rearmfunction fbnic_pollfunction fbnic_msix_clean_rings
Annotated Snippet
struct fbnic_xmit_cb {
u32 bytecount;
u16 gso_segs;
u8 desc_count;
u8 flags;
int hw_head;
};
#define FBNIC_XMIT_CB(__skb) ((struct fbnic_xmit_cb *)((__skb)->cb))
#define FBNIC_XMIT_NOUNMAP ((void *)1)
u32 __iomem *fbnic_ring_csr_base(const struct fbnic_ring *ring)
{
unsigned long csr_base = (unsigned long)ring->doorbell;
csr_base &= ~(FBNIC_QUEUE_STRIDE * sizeof(u32) - 1);
return (u32 __iomem *)csr_base;
}
static u32 fbnic_ring_rd32(struct fbnic_ring *ring, unsigned int csr)
{
u32 __iomem *csr_base = fbnic_ring_csr_base(ring);
return readl(csr_base + csr);
}
static void fbnic_ring_wr32(struct fbnic_ring *ring, unsigned int csr, u32 val)
{
u32 __iomem *csr_base = fbnic_ring_csr_base(ring);
writel(val, csr_base + csr);
}
/**
* fbnic_ts40_to_ns() - convert descriptor timestamp to PHC time
* @fbn: netdev priv of the FB NIC
* @ts40: timestamp read from a descriptor
*
* Return: u64 value of PHC time in nanoseconds
*
* Convert truncated 40 bit device timestamp as read from a descriptor
* to the full PHC time in nanoseconds.
*/
static __maybe_unused u64 fbnic_ts40_to_ns(struct fbnic_net *fbn, u64 ts40)
{
unsigned int s;
u64 time_ns;
s64 offset;
u8 ts_top;
u32 high;
do {
s = u64_stats_fetch_begin(&fbn->time_seq);
offset = READ_ONCE(fbn->time_offset);
} while (u64_stats_fetch_retry(&fbn->time_seq, s));
high = READ_ONCE(fbn->time_high);
/* Bits 63..40 from periodic clock reads, 39..0 from ts40 */
time_ns = (u64)(high >> 8) << 40 | ts40;
/* Compare bits 32-39 between periodic reads and ts40,
* see if HW clock may have wrapped since last read. We are sure
* that periodic reads are always at least ~1 minute behind, so
* this logic works perfectly fine.
*/
ts_top = ts40 >> 32;
if (ts_top < (u8)high && (u8)high - ts_top > U8_MAX / 2)
time_ns += 1ULL << 40;
return time_ns + offset;
}
static unsigned int fbnic_desc_unused(struct fbnic_ring *ring)
{
return (ring->head - ring->tail - 1) & ring->size_mask;
}
static unsigned int fbnic_desc_used(struct fbnic_ring *ring)
{
return (ring->tail - ring->head) & ring->size_mask;
}
static struct netdev_queue *txring_txq(const struct net_device *dev,
const struct fbnic_ring *ring)
{
return netdev_get_tx_queue(dev, ring->q_idx);
}
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bpf.h`, `linux/bpf_trace.h`, `linux/iopoll.h`, `linux/pci.h`, `net/netdev_queues.h`, `net/page_pool/helpers.h`, `net/tcp.h`.
- Detected declarations: `struct fbnic_xmit_cb`, `struct fbnic_idle_regs`, `function fbnic_ring_rd32`, `function fbnic_ring_wr32`, `function fbnic_ts40_to_ns`, `function fbnic_desc_unused`, `function fbnic_desc_used`, `function fbnic_maybe_stop_tx`, `function fbnic_tx_sent_queue`, `function fbnic_unmap_single_twd`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- 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.