drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.c- Extension
.c- Size
- 5520 bytes
- Lines
- 207
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/skbuff.hlinux/ip.hlinux/udp.hnet/protocol.hnet/udp.hnet/ip6_checksum.hnet/psp/types.hen.hpsp.hen_accel/psp_rxtx.hen_accel/psp.h
Detected Declarations
function mlx5e_psp_set_swpfunction mlx5e_psp_set_statefunction mlx5e_psp_offload_handle_rx_skbfunction mlx5e_psp_tx_build_esegfunction mlx5e_psp_handle_tx_wqefunction mlx5e_psp_handle_tx_skb
Annotated Snippet
switch (inner_ipproto) {
case IPPROTO_UDP:
eseg->swp_flags |= MLX5_ETH_WQE_SWP_INNER_L4_UDP;
fallthrough;
case IPPROTO_TCP:
eseg->swp_inner_l4_offset = skb_inner_transport_offset(skb) / 2;
break;
default:
break;
}
} else {
/* IP in IP tunneling like vxlan*/
if (skb->inner_protocol_type != ENCAP_TYPE_ETHER)
return;
eth = (struct ethhdr *)skb_inner_mac_header(skb);
switch (ntohs(eth->h_proto)) {
case ETH_P_IP:
inner_ipproto = ((struct iphdr *)((char *)skb->data +
skb_inner_network_offset(skb)))->protocol;
break;
case ETH_P_IPV6:
inner_ipproto = ((struct ipv6hdr *)((char *)skb->data +
skb_inner_network_offset(skb)))->nexthdr;
break;
default:
break;
}
/* Tunnel(VXLAN TCP/UDP) over Transport Mode PSP i.e. PSP payload is vxlan tunnel */
switch (inner_ipproto) {
case IPPROTO_UDP:
eseg->swp_flags |= MLX5_ETH_WQE_SWP_INNER_L4_UDP;
fallthrough;
case IPPROTO_TCP:
eseg->swp_inner_l3_offset = skb_inner_network_offset(skb) / 2;
eseg->swp_inner_l4_offset =
(skb->csum_start + skb->head - skb->data) / 2;
if (skb->protocol == htons(ETH_P_IPV6))
eseg->swp_flags |= MLX5_ETH_WQE_SWP_INNER_L3_IPV6;
break;
default:
break;
}
psp_st->inner_ipproto = inner_ipproto;
}
}
static bool mlx5e_psp_set_state(struct mlx5e_priv *priv,
struct sk_buff *skb,
struct mlx5e_accel_tx_psp_state *psp_st)
{
struct psp_assoc *pas;
bool ret = false;
rcu_read_lock();
pas = psp_skb_get_assoc_rcu(skb);
if (!pas)
goto out;
ret = true;
psp_st->tailen = PSP_TRL_SIZE;
psp_st->spi = pas->tx.spi;
psp_st->ver = pas->version;
psp_st->keyid = *(u32 *)pas->drv_data;
out:
rcu_read_unlock();
return ret;
}
bool mlx5e_psp_offload_handle_rx_skb(struct net_device *netdev, struct sk_buff *skb,
struct mlx5_cqe64 *cqe)
{
u32 psp_meta_data = be32_to_cpu(cqe->ft_metadata);
struct mlx5e_priv *priv = netdev_priv(netdev);
u16 dev_id = priv->psp->psp->id;
bool strip_icv = true;
u8 generation = 0;
/* TBD: report errors as SW counters to ethtool, any further handling ? */
if (MLX5_PSP_METADATA_SYNDROME(psp_meta_data) != MLX5E_PSP_OFFLOAD_RX_SYNDROME_DECRYPTED)
goto drop;
if (psp_dev_rcv(skb, dev_id, generation, strip_icv))
goto drop;
skb->decrypted = 1;
return false;
Annotation
- Immediate include surface: `linux/skbuff.h`, `linux/ip.h`, `linux/udp.h`, `net/protocol.h`, `net/udp.h`, `net/ip6_checksum.h`, `net/psp/types.h`, `en.h`.
- Detected declarations: `function mlx5e_psp_set_swp`, `function mlx5e_psp_set_state`, `function mlx5e_psp_offload_handle_rx_skb`, `function mlx5e_psp_tx_build_eseg`, `function mlx5e_psp_handle_tx_wqe`, `function mlx5e_psp_handle_tx_skb`.
- 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.
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.