drivers/net/ethernet/intel/ixgbevf/ipsec.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/ixgbevf/ipsec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/ixgbevf/ipsec.c- Extension
.c- Size
- 17709 bytes
- Lines
- 685
- 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
ixgbevf.hnet/xfrm.hcrypto/aead.h
Detected Declarations
function ixgbevf_ipsec_set_pf_safunction ixgbevf_ipsec_del_pf_safunction ixgbevf_ipsec_restorefunction ixgbevf_ipsec_find_empty_idxfunction ixgbevf_ipsec_parse_proto_keysfunction ixgbevf_ipsec_add_safunction ixgbevf_ipsec_del_safunction ixgbevf_ipsec_txfunction ixgbevf_ipsec_rxfunction ixgbevf_init_ipsec_offloadfunction ixgbevf_stop_ipsec_offload
Annotated Snippet
if (r->used) {
ret = ixgbevf_ipsec_set_pf_sa(adapter, r->xs);
if (ret < 0)
netdev_err(netdev, "reload rx_tbl[%d] failed = %d\n",
i, ret);
}
if (t->used) {
ret = ixgbevf_ipsec_set_pf_sa(adapter, t->xs);
if (ret < 0)
netdev_err(netdev, "reload tx_tbl[%d] failed = %d\n",
i, ret);
}
}
}
/**
* ixgbevf_ipsec_find_empty_idx - find the first unused security parameter index
* @ipsec: pointer to IPsec struct
* @rxtable: true if we need to look in the Rx table
*
* Returns the first unused index in either the Rx or Tx SA table
**/
static
int ixgbevf_ipsec_find_empty_idx(struct ixgbevf_ipsec *ipsec, bool rxtable)
{
u32 i;
if (rxtable) {
if (ipsec->num_rx_sa == IXGBE_IPSEC_MAX_SA_COUNT)
return -ENOSPC;
/* search rx sa table */
for (i = 0; i < IXGBE_IPSEC_MAX_SA_COUNT; i++) {
if (!ipsec->rx_tbl[i].used)
return i;
}
} else {
if (ipsec->num_tx_sa == IXGBE_IPSEC_MAX_SA_COUNT)
return -ENOSPC;
/* search tx sa table */
for (i = 0; i < IXGBE_IPSEC_MAX_SA_COUNT; i++) {
if (!ipsec->tx_tbl[i].used)
return i;
}
}
return -ENOSPC;
}
/**
* ixgbevf_ipsec_find_rx_state - find the state that matches
* @ipsec: pointer to IPsec struct
* @daddr: inbound address to match
* @proto: protocol to match
* @spi: SPI to match
* @ip4: true if using an IPv4 address
*
* Returns a pointer to the matching SA state information
**/
static
struct xfrm_state *ixgbevf_ipsec_find_rx_state(struct ixgbevf_ipsec *ipsec,
__be32 *daddr, u8 proto,
__be32 spi, bool ip4)
{
struct xfrm_state *ret = NULL;
struct rx_sa *rsa;
rcu_read_lock();
hash_for_each_possible_rcu(ipsec->rx_sa_list, rsa, hlist,
(__force u32)spi) {
if (spi == rsa->xs->id.spi &&
((ip4 && *daddr == rsa->xs->id.daddr.a4) ||
(!ip4 && !memcmp(daddr, &rsa->xs->id.daddr.a6,
sizeof(rsa->xs->id.daddr.a6)))) &&
proto == rsa->xs->id.proto) {
ret = rsa->xs;
xfrm_state_hold(ret);
break;
}
}
rcu_read_unlock();
return ret;
}
/**
* ixgbevf_ipsec_parse_proto_keys - find the key and salt based on the protocol
* @dev: pointer to net device to program
* @xs: pointer to xfrm_state struct
Annotation
- Immediate include surface: `ixgbevf.h`, `net/xfrm.h`, `crypto/aead.h`.
- Detected declarations: `function ixgbevf_ipsec_set_pf_sa`, `function ixgbevf_ipsec_del_pf_sa`, `function ixgbevf_ipsec_restore`, `function ixgbevf_ipsec_find_empty_idx`, `function ixgbevf_ipsec_parse_proto_keys`, `function ixgbevf_ipsec_add_sa`, `function ixgbevf_ipsec_del_sa`, `function ixgbevf_ipsec_tx`, `function ixgbevf_ipsec_rx`, `function ixgbevf_init_ipsec_offload`.
- 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.