drivers/net/ethernet/chelsio/cxgb3/sge.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/chelsio/cxgb3/sge.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/chelsio/cxgb3/sge.c- Extension
.c- Size
- 95480 bytes
- Lines
- 3371
- 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.hlinux/tcp.hlinux/dma-mapping.hlinux/slab.hlinux/prefetch.hnet/arp.hcommon.hregs.hsge_defs.ht3_cpl.hfirmware_exports.hcxgb3_offload.h
Detected Declarations
struct tx_descstruct rx_descstruct tx_sw_descstruct rx_sw_descstruct rsp_descstruct deferred_unmap_infofunction refill_rspqfunction need_skb_unmapfunction itselffunction free_tx_descfunction reclaim_completed_txfunction should_restart_txfunction clear_rx_descfunction free_rx_bufsfunction add_one_rx_buffunction add_one_rx_chunkfunction alloc_pg_chunkfunction ring_fl_dbfunction refill_flfunction __refill_flfunction recycle_rx_buffunction entryfunction t3_reset_qsetfunction t3_free_qsetfunction init_qset_cntxtfunction sgl_lenfunction flits_to_descfunction calc_tx_descsfunction map_skbfunction write_sglfunction check_ring_tx_dbfunction wr_gen2function write_wr_hdr_sglfunction write_tx_pkt_wrfunction t3_stop_tx_queuefunction t3_eth_xmitfunction write_immfunction check_desc_availfunction reclaim_completed_txfunction immediatefunction ctrl_xmitfunction restart_ctrlqfunction t3_mgmt_txfunction deferred_unmap_destructorfunction setup_deferred_unmappingfunction write_ofld_wrfunction calc_tx_descs_ofldfunction ofld_xmit
Annotated Snippet
struct tx_desc {
__be64 flit[TX_DESC_FLITS];
};
struct rx_desc {
__be32 addr_lo;
__be32 len_gen;
__be32 gen2;
__be32 addr_hi;
};
struct tx_sw_desc { /* SW state per Tx descriptor */
struct sk_buff *skb;
u8 eop; /* set if last descriptor for packet */
u8 addr_idx; /* buffer index of first SGL entry in descriptor */
u8 fragidx; /* first page fragment associated with descriptor */
s8 sflit; /* start flit of first SGL entry in descriptor */
};
struct rx_sw_desc { /* SW state per Rx descriptor */
union {
struct sk_buff *skb;
struct fl_pg_chunk pg_chunk;
};
DEFINE_DMA_UNMAP_ADDR(dma_addr);
};
struct rsp_desc { /* response queue descriptor */
struct rss_header rss_hdr;
__be32 flags;
__be32 len_cq;
struct_group(immediate,
u8 imm_data[47];
u8 intr_gen;
);
};
/*
* Holds unmapping information for Tx packets that need deferred unmapping.
* This structure lives at skb->head and must be allocated by callers.
*/
struct deferred_unmap_info {
struct pci_dev *pdev;
dma_addr_t addr[MAX_SKB_FRAGS + 1];
};
/*
* Maps a number of flits to the number of Tx descriptors that can hold them.
* The formula is
*
* desc = 1 + (flits - 2) / (WR_FLITS - 1).
*
* HW allows up to 4 descriptors to be combined into a WR.
*/
static u8 flit_desc_map[] = {
0,
#if SGE_NUM_GENBITS == 1
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
#elif SGE_NUM_GENBITS == 2
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
#else
# error "SGE_NUM_GENBITS must be 1 or 2"
#endif
};
static inline struct sge_qset *rspq_to_qset(const struct sge_rspq *q)
{
return container_of(q, struct sge_qset, rspq);
}
static inline struct sge_qset *txq_to_qset(const struct sge_txq *q, int qidx)
{
return container_of(q, struct sge_qset, txq[qidx]);
}
/**
* refill_rspq - replenish an SGE response queue
* @adapter: the adapter
* @q: the response queue to replenish
* @credits: how many new responses to make available
*
* Replenishes a response queue by making the supplied number of responses
* available to HW.
*/
Annotation
- Immediate include surface: `linux/skbuff.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/if_vlan.h`, `linux/ip.h`, `linux/tcp.h`, `linux/dma-mapping.h`, `linux/slab.h`.
- Detected declarations: `struct tx_desc`, `struct rx_desc`, `struct tx_sw_desc`, `struct rx_sw_desc`, `struct rsp_desc`, `struct deferred_unmap_info`, `function refill_rspq`, `function need_skb_unmap`, `function itself`, `function free_tx_desc`.
- 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.