cxgb4_write_sgl(9)
π
cxgb4_write_sgl β a Kernel API Manual moment β¨
okay so real talk, this is a page from the Kernel API Manual and honestly? it's giving "small function, big responsibility" π like it's just one line of C in the synopsis but bestie it is doing the most under the hood. no cap. let's get into it π
πΈ NAME πΈ
cxgb4_write_sgl β bestie's whole job is to populate a scatter/gather list for a packet β¨ that's it, that's the vibe, that's the mission π
π¦ SYNOPSIS π¦
void cxgb4_write_sgl (const struct sk_buff *skb , struct sge_txq *q ,
struct ulptx_sgl *sgl , u64 *end , unsigned int start , const dma_addr_t
*addr );
like look at that signature. six arguments. it's serving very much "trust me, I know what I'm doing" energy ππ«Ά
π ARGUMENTS π
one bullet per bestie, no skipping, we do not skip here π
skbβ the literal packet π the main character of this whole situation fr frqβ the Tx queue we are writing into π that's where the goods are goingsglβ the starting location for writing the SGL πΈ like, where the pen first touches the paper, iykykendβ points right after the end of the SGL π¦ so like, the finish line, but the finish line + 1startβ a start offset into theskbmain-body data to include in the SGL β¨ the "we're jumping in at this byte" eraaddrβ the list of bus addresses for the SGL elements π every element gets its address, we keep receipts
π₯ DESCRIPTION π₯
so basically β generates a gather list for the buffers that make up a packet π§ okay but here's the part where you actually have to pay attention, bestie, because there are β¨rulesβ¨:
the caller must provide adequate space for the SGL that will be written π not optional. not a suggestion. it's giving "you better have made room" π
the SGL includes all of the packet's page fragments and the data in its main body β except for the first start bytes πΈ like we're skipping the first start bytes of the main body, no takebacks.
and now the fussy bits, because this function is highkey picky:
sglmust be 16-byte aligned π― not "roughly", not "close enough" β 16-byte aligned. periodt.- it also must be within a Tx descriptor with available space π so vibe check your descriptor first, bestie π«Ά
endpoints right after the end of the SGL β but β οΈ it does not account for any potential wrap around, i.e.,end > sglπ
ngl that last one is important:endis a "right after the end" pointer, and it straight up does not account for any potential wrap around β the page literally spells outend > sglso likeβ¦ hold that thought πβ¨
π SEE ALSO π
okay so the source is this kernel file right here: ./drivers/net/ethernet/chelsio/cxgb4/sge.c π and the extended universe of cross-references is huge, like a whole friend group, so buckle up bestie π¦:
txq_avail(9), fl_cap(9), fl_starving(9), deferred_unmap_destructor(9), free_tx_desc(9), reclaim_completed_tx(9), cxgb4_reclaim_completed_tx(9), free_rx_bufs(9), unmap_rx_buf(9), refill_fl(9), alloc_ring(9), sgl_len(9), flits_to_desc(9), is_eth_imm(9), calc_tx_flits(9), cxgb4_ring_tx_db(9), cxgb4_inline_tx_skb(9), t4_sge_eth_txq_egress_update(9), cxgb4_eth_xmit(9), t4vf_is_eth_imm(9), t4vf_calc_tx_flits(9), cxgb4_vf_eth_xmit(9), reclaim_completed_tx_imm(9), cxgb4_ethofld_send_flowc(9), is_imm(9), ctrlq_check_stop(9), ctrl_xmit(9), restart_ctrlq(9), t4_mgmt_tx(9), is_ofld_imm(9), calc_tx_flits_ofld(9), txq_stop_maperr(9), ofldtxq_stop(9), service_ofldq(9), ofld_xmit(9), restart_ofldq(9), skb_txq(9), is_ctrl_pkt(9), t4_ofld_send(9), cxgb4_ofld_send(9), ofld_xmit_direct(9), t4_crypto_send(9), cxgb4_crypto_send(9), cxgb4_pktgl_to_skb(9), t4_pktgl_free(9), cxgb4_sgetim_to_hwtstamp(9), t4_systim_to_hwstamp(9), t4_rx_hststamp(9), t4_tx_hststamp(9), t4_tx_completion_handler(9), t4_ethrx_handler(9), restore_rx_bufs(9), is_new_response(9), rspq_next(9), process_responses(9), napi_rx_handler(9), t4_intr_handler(9), bar2_address(9), t4_sge_alloc_eth_txq(9), t4_free_sge_resources(9), t4_sge_stop(9), t4_sge_init_soft(9), t4_sge_init(9) πβ¨
and that's the whole page, bestie π«Ά go forth, align your SGL to 16 bytes, and slay π
β¨ cute little sign-off: this iconic page comes from the source./drivers/net/ethernet/chelsio...and it's dated October 2026, filed undercxgb4_write_sgl(9)π mwah π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms