drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c- Extension
.c- Size
- 38351 bytes
- Lines
- 1366
- 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.
- 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
crypto/internal/geniv.hcrypto/aead.hlinux/inetdevice.hlinux/netdevice.hnet/netevent.hen.heswitch.hipsec.hipsec_rxtx.hen_rep.h
Detected Declarations
function Copyrightfunction mlx5e_ipsec_handle_sw_limitsfunction mlx5e_ipsec_update_esn_statefunction mlx5e_ipsec_init_limitsfunction mlx5e_ipsec_init_macsfunction mlx5e_ipsec_state_maskfunction mlx5e_ipsec_build_accel_xfrm_attrsfunction mlx5e_xfrm_validate_statefunction mlx5e_ipsec_modify_statefunction mlx5e_ipsec_set_esn_opsfunction mlx5e_ipsec_handle_netdev_eventfunction mlx5_ipsec_create_workfunction mlx5e_ipsec_create_dworkfunction mlx5e_xfrm_add_statefunction mlx5e_xfrm_del_statefunction mlx5e_xfrm_free_statefunction mlx5e_ipsec_netevent_eventfunction mlx5e_ipsec_initfunction mlx5e_ipsec_cleanupfunction mlx5e_xfrm_advance_esn_statefunction mlx5e_xfrm_update_statsfunction word_to_maskfunction mlx5e_ipsec_policy_maskfunction mlx5e_xfrm_validate_policyfunction mlx5e_ipsec_build_accel_pol_attrsfunction mlx5e_xfrm_add_policyfunction mlx5e_xfrm_del_policyfunction mlx5e_xfrm_free_policyfunction mlx5e_ipsec_build_netdev
Annotated Snippet
switch (addrs->family) {
case AF_INET:
fl4.flowi4_proto = x->sel.proto;
fl4.daddr = addrs->saddr.a4;
fl4.saddr = addrs->daddr.a4;
pkey = &addrs->saddr.a4;
break;
case AF_INET6:
fl6.flowi6_proto = x->sel.proto;
memcpy(fl6.daddr.s6_addr32, addrs->saddr.a6, 16);
memcpy(fl6.saddr.s6_addr32, addrs->daddr.a6, 16);
pkey = &addrs->saddr.a6;
break;
default:
return;
}
break;
case XFRM_DEV_OFFLOAD_OUT:
src = attrs->smac;
dst = attrs->dmac;
switch (addrs->family) {
case AF_INET:
fl4.flowi4_proto = x->sel.proto;
fl4.daddr = addrs->daddr.a4;
fl4.saddr = addrs->saddr.a4;
pkey = &addrs->daddr.a4;
break;
case AF_INET6:
fl6.flowi6_proto = x->sel.proto;
memcpy(fl6.daddr.s6_addr32, addrs->daddr.a6, 16);
memcpy(fl6.saddr.s6_addr32, addrs->saddr.a6, 16);
pkey = &addrs->daddr.a6;
break;
default:
return;
}
break;
default:
return;
}
ether_addr_copy(src, addr);
/* Destination can refer to a routed network, so perform FIB lookup
* to resolve nexthop and get its MAC. Neighbour resolution is used as
* fallback.
*/
switch (addrs->family) {
case AF_INET:
rt = ip_route_output_key(dev_net(netdev), &fl4);
if (IS_ERR(rt))
goto neigh;
if (rt->rt_type != RTN_UNICAST) {
ip_rt_put(rt);
goto neigh;
}
rt_dst_entry = &rt->dst;
break;
case AF_INET6:
if (!IS_ENABLED(CONFIG_IPV6) ||
ip6_dst_lookup(dev_net(netdev), NULL, &rt_dst_entry, &fl6))
goto neigh;
break;
default:
return;
}
n = dst_neigh_lookup(rt_dst_entry, pkey);
if (!n) {
dst_release(rt_dst_entry);
goto neigh;
}
neigh_ha_snapshot(addr, n, netdev);
ether_addr_copy(dst, addr);
if (attrs->dir == XFRM_DEV_OFFLOAD_OUT &&
is_zero_ether_addr(addr))
neigh_event_send(n, NULL);
dst_release(rt_dst_entry);
neigh_release(n);
return;
neigh:
n = neigh_lookup(&arp_tbl, pkey, netdev);
if (!n) {
n = neigh_create(&arp_tbl, pkey, netdev);
if (IS_ERR(n))
return;
neigh_event_send(n, NULL);
Annotation
- Immediate include surface: `crypto/internal/geniv.h`, `crypto/aead.h`, `linux/inetdevice.h`, `linux/netdevice.h`, `net/netevent.h`, `en.h`, `eswitch.h`, `ipsec.h`.
- Detected declarations: `function Copyright`, `function mlx5e_ipsec_handle_sw_limits`, `function mlx5e_ipsec_update_esn_state`, `function mlx5e_ipsec_init_limits`, `function mlx5e_ipsec_init_macs`, `function mlx5e_ipsec_state_mask`, `function mlx5e_ipsec_build_accel_xfrm_attrs`, `function mlx5e_xfrm_validate_state`, `function mlx5e_ipsec_modify_state`, `function mlx5e_ipsec_set_esn_ops`.
- 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.