drivers/net/ethernet/chelsio/cxgb4vf/sge.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/chelsio/cxgb4vf/sge.c- Extension
.c- Size
- 82250 bytes
- Lines
- 2707
- 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/skbuff.hlinux/netdevice.hlinux/etherdevice.hlinux/if_vlan.hlinux/ip.hnet/ipv6.hnet/tcp.hlinux/dma-mapping.hlinux/prefetch.ht4vf_common.ht4vf_defs.h../cxgb4/t4_regs.h../cxgb4/t4_values.h../cxgb4/t4fw_api.h../cxgb4/t4_msg.h
Detected Declarations
struct tx_sw_descstruct rx_sw_descfunction descriptorfunction is_buf_mappedfunction need_skb_unmapfunction txq_availfunction fl_capfunction fl_starvingfunction map_skbfunction unmap_sglfunction free_tx_descfunction spacefunction reclaimablefunction reclaim_completed_txfunction get_buf_sizefunction free_rx_bufsfunction entityfunction ring_fl_dbfunction set_rx_sw_descfunction poison_buffunction refill_flfunction __refill_flfunction entryfunction flitsfunction flits_to_descfunction is_eth_immfunction calc_tx_flitsfunction write_sglfunction ring_tx_dbfunction failsfunction inline_tx_skbfunction hwcsumfunction txq_stopfunction txq_advancefunction t4vf_eth_xmitfunction copy_fragsfunction t4vf_pktgl_freefunction Offloadfunction t4vf_ethrx_handlerfunction is_new_responsefunction restore_rx_bufsfunction rspq_nextfunction process_responsesfunction interferefunction t4vf_sge_intr_msixfunction process_intrqfunction t4vf_intr_msifunction t4vf_intr_handler
Annotated Snippet
struct tx_sw_desc {
struct sk_buff *skb; /* socket buffer of TX data source */
struct ulptx_sgl *sgl; /* scatter/gather list in TX Queue */
};
/*
* Software state per RX Free List descriptor. We keep track of the allocated
* FL page, its size, and its PCI DMA address (if the page is mapped). The FL
* page size and its PCI DMA mapped state are stored in the low bits of the
* PCI DMA address as per below.
*/
struct rx_sw_desc {
struct page *page; /* Free List page buffer */
dma_addr_t dma_addr; /* PCI DMA address (if mapped) */
/* and flags (see below) */
};
/*
* The low bits of rx_sw_desc.dma_addr have special meaning. Note that the
* SGE also uses the low 4 bits to determine the size of the buffer. It uses
* those bits to index into the SGE_FL_BUFFER_SIZE[index] register array.
* Since we only use SGE_FL_BUFFER_SIZE0 and SGE_FL_BUFFER_SIZE1, these low 4
* bits can only contain a 0 or a 1 to indicate which size buffer we're giving
* to the SGE. Thus, our software state of "is the buffer mapped for DMA" is
* maintained in an inverse sense so the hardware never sees that bit high.
*/
enum {
RX_LARGE_BUF = 1 << 0, /* buffer is SGE_FL_BUFFER_SIZE[1] */
RX_UNMAPPED_BUF = 1 << 1, /* buffer is not mapped */
};
/**
* get_buf_addr - return DMA buffer address of software descriptor
* @sdesc: pointer to the software buffer descriptor
*
* Return the DMA buffer address of a software descriptor (stripping out
* our low-order flag bits).
*/
static inline dma_addr_t get_buf_addr(const struct rx_sw_desc *sdesc)
{
return sdesc->dma_addr & ~(dma_addr_t)(RX_LARGE_BUF | RX_UNMAPPED_BUF);
}
/**
* is_buf_mapped - is buffer mapped for DMA?
* @sdesc: pointer to the software buffer descriptor
*
* Determine whether the buffer associated with a software descriptor in
* mapped for DMA or not.
*/
static inline bool is_buf_mapped(const struct rx_sw_desc *sdesc)
{
return !(sdesc->dma_addr & RX_UNMAPPED_BUF);
}
/**
* need_skb_unmap - does the platform need unmapping of sk_buffs?
*
* Returns true if the platform needs sk_buff unmapping. The compiler
* optimizes away unnecessary code if this returns true.
*/
static inline int need_skb_unmap(void)
{
#ifdef CONFIG_NEED_DMA_MAP_STATE
return 1;
#else
return 0;
#endif
}
/**
* txq_avail - return the number of available slots in a TX queue
* @tq: the TX queue
*
* Returns the number of available descriptors in a TX queue.
*/
static inline unsigned int txq_avail(const struct sge_txq *tq)
{
return tq->size - 1 - tq->in_use;
}
/**
* fl_cap - return the capacity of a Free List
* @fl: the Free List
*
* Returns the capacity of a Free List. The capacity is less than the
* size because an Egress Queue Index Unit worth of descriptors needs to
* be left unpopulated, otherwise the Producer and Consumer indices PIDX
* and CIDX will match and the hardware will think the FL is empty.
*/
Annotation
- Immediate include surface: `linux/skbuff.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/if_vlan.h`, `linux/ip.h`, `net/ipv6.h`, `net/tcp.h`, `linux/dma-mapping.h`.
- Detected declarations: `struct tx_sw_desc`, `struct rx_sw_desc`, `function descriptor`, `function is_buf_mapped`, `function need_skb_unmap`, `function txq_avail`, `function fl_cap`, `function fl_starving`, `function map_skb`, `function unmap_sgl`.
- 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.