drivers/net/ethernet/netronome/nfp/crypto/tls.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/crypto/tls.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/crypto/tls.c- Extension
.c- Size
- 15695 bytes
- Lines
- 606
- 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/bitfield.hlinux/ipv6.hlinux/skbuff.hlinux/string.hnet/inet6_hashtables.hnet/tls.h../ccm.h../nfp_net.hcrypto.hfw.h
Detected Declarations
function BITfunction __nfp_net_tls_conn_cnt_changedfunction nfp_net_tls_conn_cnt_changedfunction nfp_net_tls_conn_addfunction nfp_net_tls_conn_removefunction nfp_net_tls_alloc_simplefunction nfp_net_tls_communicate_simplefunction nfp_net_tls_del_fwfunction nfp_net_tls_set_ipver_vlanfunction nfp_net_tls_assign_conn_idfunction nfp_net_tls_set_ipv4function nfp_net_tls_set_ipv6function nfp_net_tls_set_l4function nfp_tls_1_2_dir_to_opcodefunction nfp_net_cipher_supportedfunction nfp_net_tls_addfunction nfp_net_tls_delfunction nfp_net_tls_resyncfunction nfp_net_tls_rx_resync_reqfunction nfp_net_tls_resetfunction nfp_net_tls_init
Annotated Snippet
ipv6_addr_type(&sk->sk_v6_daddr) != IPV6_ADDR_MAPPED) {
req_sz = sizeof(struct nfp_crypto_req_add_v6);
ipv6 = true;
break;
}
fallthrough;
#endif
case AF_INET:
req_sz = sizeof(struct nfp_crypto_req_add_v4);
ipv6 = false;
break;
default:
return -EOPNOTSUPP;
}
err = nfp_net_tls_conn_add(nn, direction);
if (err)
return err;
skb = nfp_ccm_mbox_msg_alloc(nn, req_sz, sizeof(*reply), GFP_KERNEL);
if (!skb) {
err = -ENOMEM;
goto err_conn_remove;
}
front = (void *)skb->data;
front->ep_id = 0;
front->key_len = NFP_NET_TLS_NON_ADDR_KEY_LEN;
front->opcode = nfp_tls_1_2_dir_to_opcode(direction);
memset(front->resv, 0, sizeof(front->resv));
nfp_net_tls_set_ipver_vlan(front, ipv6 ? 6 : 4);
req = (void *)skb->data;
if (ipv6)
back = nfp_net_tls_set_ipv6(nn, req, sk, direction);
else
back = nfp_net_tls_set_ipv4(nn, req, sk, direction);
nfp_net_tls_set_l4(front, back, sk, direction);
back->counter = 0;
back->tcp_seq = cpu_to_be32(start_offload_tcp_sn);
tls_ci = (struct tls12_crypto_info_aes_gcm_128 *)crypto_info;
memcpy(back->key, tls_ci->key, TLS_CIPHER_AES_GCM_128_KEY_SIZE);
memset(&back->key[TLS_CIPHER_AES_GCM_128_KEY_SIZE / 4], 0,
sizeof(back->key) - TLS_CIPHER_AES_GCM_128_KEY_SIZE);
memcpy(back->iv, tls_ci->iv, TLS_CIPHER_AES_GCM_128_IV_SIZE);
memcpy(&back->salt, tls_ci->salt, TLS_CIPHER_AES_GCM_128_SALT_SIZE);
memcpy(back->rec_no, tls_ci->rec_seq, sizeof(tls_ci->rec_seq));
/* Get an extra ref on the skb so we can wipe the key after */
skb_get(skb);
err = nfp_ccm_mbox_communicate(nn, skb, NFP_CCM_TYPE_CRYPTO_ADD,
sizeof(*reply), sizeof(*reply));
reply = (void *)skb->data;
/* We depend on CCM MBOX code not reallocating skb we sent
* so we can clear the key material out of the memory.
*/
if (!WARN_ON_ONCE((u8 *)back < skb->head ||
(u8 *)back > skb_end_pointer(skb)) &&
!WARN_ON_ONCE((u8 *)&reply[1] > (u8 *)back))
memzero_explicit(back, sizeof(*back));
dev_consume_skb_any(skb); /* the extra ref from skb_get() above */
if (err) {
nn_dp_warn(&nn->dp, "failed to add TLS: %d (%d)\n",
err, direction == TLS_OFFLOAD_CTX_DIR_TX);
/* communicate frees skb on error */
goto err_conn_remove;
}
err = -be32_to_cpu(reply->error);
if (err) {
if (err == -ENOSPC) {
if (!atomic_fetch_inc(&nn->ktls_no_space))
nn_info(nn, "HW TLS table full\n");
} else {
nn_dp_warn(&nn->dp,
"failed to add TLS, FW replied: %d\n", err);
}
goto err_free_skb;
}
if (!reply->handle[0] && !reply->handle[1]) {
nn_dp_warn(&nn->dp, "FW returned NULL handle\n");
err = -EINVAL;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/ipv6.h`, `linux/skbuff.h`, `linux/string.h`, `net/inet6_hashtables.h`, `net/tls.h`, `../ccm.h`, `../nfp_net.h`.
- Detected declarations: `function BIT`, `function __nfp_net_tls_conn_cnt_changed`, `function nfp_net_tls_conn_cnt_changed`, `function nfp_net_tls_conn_add`, `function nfp_net_tls_conn_remove`, `function nfp_net_tls_alloc_simple`, `function nfp_net_tls_communicate_simple`, `function nfp_net_tls_del_fw`, `function nfp_net_tls_set_ipver_vlan`, `function nfp_net_tls_assign_conn_id`.
- 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.