drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c- Extension
.c- Size
- 27265 bytes
- Lines
- 1013
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/tcp.hlinux/if_vlan.hnet/geneve.hnet/dsfield.hen.hen/txrx.hipoib/ipoib.hen_accel/en_accel.hen_accel/ipsec_rxtx.hen_accel/psp_rxtx.hen_accel/macsec.hen/ptp.hnet/ipv6.h
Detected Declarations
struct mlx5e_tx_attrstruct mlx5e_tx_wqe_attrfunction Copyrightfunction mlx5e_skb_l2_header_offsetfunction mlx5e_skb_l3_header_offsetfunction mlx5e_calc_min_inlinefunction mlx5e_insert_vlanfunction mlx5e_txwqe_build_eseg_csumfunction mlx5e_tx_get_gso_ihsfunction mlx5e_txwqe_build_dsegsfunction mlx5e_tx_wqe_inline_modefunction mlx5e_sq_xmit_preparefunction mlx5e_sq_calc_wqe_attrfunction mlx5e_tx_skb_update_ts_flagsfunction mlx5e_tx_check_stopfunction mlx5e_tx_flushfunction mlx5e_txwqe_completefunction mlx5e_sq_xmit_wqefunction mlx5e_tx_skb_supports_mpwqefunction mlx5e_tx_mpwqe_same_esegfunction mlx5e_tx_mpwqe_session_startfunction mlx5e_tx_mpwqe_session_is_activefunction mlx5e_tx_mpwqe_add_dsegfunction mlx5e_sq_xmit_mpwqefunction mlx5e_tx_mpwqe_ensure_completefunction mlx5e_cqe_ts_id_esegfunction mlx5e_txwqe_build_esegfunction mlx5e_xmitfunction mlx5e_tx_wi_dma_unmapfunction mlx5e_consume_skbfunction mlx5e_tx_wi_consume_fifo_skbsfunction mlx5e_txqsq_wakefunction mlx5e_poll_tx_cqfunction mlx5e_tx_wi_kfree_fifo_skbsfunction mlx5e_free_txqsq_descsfunction mlx5i_txwqe_build_datagramfunction mlx5i_sq_calc_wqe_attrfunction mlx5i_sq_xmit
Annotated Snippet
struct mlx5e_tx_attr {
u32 num_bytes;
u16 headlen;
u16 ihs;
__be16 mss;
u16 insz;
u8 opcode;
};
struct mlx5e_tx_wqe_attr {
u16 ds_cnt;
u16 ds_cnt_inl;
u16 ds_cnt_ids;
u8 num_wqebbs;
};
static u8
mlx5e_tx_wqe_inline_mode(struct mlx5e_txqsq *sq, struct sk_buff *skb,
struct mlx5e_accel_tx_state *accel)
{
u8 mode;
#ifdef CONFIG_MLX5_EN_TLS
if (accel->tls.tls_tisn)
return MLX5_INLINE_MODE_TCP_UDP;
#endif
mode = sq->min_inline_mode;
if (skb_vlan_tag_present(skb))
mode = max_t(u8, MLX5_INLINE_MODE_L2, mode);
return mode;
}
static void mlx5e_sq_xmit_prepare(struct mlx5e_txqsq *sq, struct sk_buff *skb,
struct mlx5e_accel_tx_state *accel,
struct mlx5e_tx_attr *attr)
{
struct mlx5e_sq_stats *stats = sq->stats;
if (skb_is_gso(skb)) {
u16 ihs = mlx5e_tx_get_gso_ihs(sq, skb);
*attr = (struct mlx5e_tx_attr) {
.opcode = MLX5_OPCODE_LSO,
.mss = cpu_to_be16(skb_shinfo(skb)->gso_size),
.ihs = ihs,
.num_bytes = skb->len + (skb_shinfo(skb)->gso_segs - 1) * ihs,
.headlen = skb_headlen(skb) - ihs,
};
stats->packets += skb_shinfo(skb)->gso_segs;
} else {
u8 mode = mlx5e_tx_wqe_inline_mode(sq, skb, accel);
u16 ihs = mlx5e_calc_min_inline(mode, skb);
*attr = (struct mlx5e_tx_attr) {
.opcode = MLX5_OPCODE_SEND,
.mss = cpu_to_be16(0),
.ihs = ihs,
.num_bytes = max_t(unsigned int, skb->len, ETH_ZLEN),
.headlen = skb_headlen(skb) - ihs,
};
stats->packets++;
}
attr->insz = mlx5e_accel_tx_ids_len(sq, skb, accel);
stats->bytes += attr->num_bytes;
}
static void mlx5e_sq_calc_wqe_attr(struct sk_buff *skb, const struct mlx5e_tx_attr *attr,
struct mlx5e_tx_wqe_attr *wqe_attr)
{
u16 ds_cnt = MLX5E_TX_WQE_EMPTY_DS_COUNT;
u16 ds_cnt_inl = 0;
u16 ds_cnt_ids = 0;
/* Sync the calculation with MLX5E_MAX_TX_WQEBBS. */
if (attr->insz)
ds_cnt_ids = DIV_ROUND_UP(sizeof(struct mlx5_wqe_inline_seg) + attr->insz,
MLX5_SEND_WQE_DS);
ds_cnt += !!attr->headlen + skb_shinfo(skb)->nr_frags + ds_cnt_ids;
if (attr->ihs) {
u16 inl = attr->ihs - INL_HDR_START_SZ;
if (skb_vlan_tag_present(skb))
Annotation
- Immediate include surface: `linux/tcp.h`, `linux/if_vlan.h`, `net/geneve.h`, `net/dsfield.h`, `en.h`, `en/txrx.h`, `ipoib/ipoib.h`, `en_accel/en_accel.h`.
- Detected declarations: `struct mlx5e_tx_attr`, `struct mlx5e_tx_wqe_attr`, `function Copyright`, `function mlx5e_skb_l2_header_offset`, `function mlx5e_skb_l3_header_offset`, `function mlx5e_calc_min_inline`, `function mlx5e_insert_vlan`, `function mlx5e_txwqe_build_eseg_csum`, `function mlx5e_tx_get_gso_ihs`, `function mlx5e_txwqe_build_dsegs`.
- 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.