drivers/net/ethernet/fungible/funeth/funeth_ktls.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/fungible/funeth/funeth_ktls.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/fungible/funeth/funeth_ktls.c- Extension
.c- Size
- 4181 bytes
- Lines
- 156
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
funeth.hfuneth_ktls.h
Detected Declarations
function fun_admin_ktls_createfunction fun_ktls_addfunction fun_ktls_delfunction fun_ktls_resyncfunction fun_ktls_initfunction fun_ktls_cleanup
Annotated Snippet
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
#include "funeth.h"
#include "funeth_ktls.h"
static int fun_admin_ktls_create(struct funeth_priv *fp, unsigned int id)
{
struct fun_admin_ktls_create_req req = {
.common = FUN_ADMIN_REQ_COMMON_INIT2(FUN_ADMIN_OP_KTLS,
sizeof(req)),
.subop = FUN_ADMIN_SUBOP_CREATE,
.id = cpu_to_be32(id),
};
return fun_submit_admin_sync_cmd(fp->fdev, &req.common, NULL, 0, 0);
}
static int fun_ktls_add(struct net_device *netdev, struct sock *sk,
enum tls_offload_ctx_dir direction,
struct tls_crypto_info *crypto_info,
u32 start_offload_tcp_sn)
{
struct funeth_priv *fp = netdev_priv(netdev);
struct fun_admin_ktls_modify_req req = {
.common = FUN_ADMIN_REQ_COMMON_INIT2(FUN_ADMIN_OP_KTLS,
sizeof(req)),
.subop = FUN_ADMIN_SUBOP_MODIFY,
.id = cpu_to_be32(fp->ktls_id),
.tcp_seq = cpu_to_be32(start_offload_tcp_sn),
};
struct fun_admin_ktls_modify_rsp rsp;
struct fun_ktls_tx_ctx *tx_ctx;
int rc;
if (direction != TLS_OFFLOAD_CTX_DIR_TX)
return -EOPNOTSUPP;
if (crypto_info->version == TLS_1_2_VERSION)
req.version = FUN_KTLS_TLSV2;
else
return -EOPNOTSUPP;
switch (crypto_info->cipher_type) {
case TLS_CIPHER_AES_GCM_128: {
struct tls12_crypto_info_aes_gcm_128 *c = (void *)crypto_info;
req.cipher = FUN_KTLS_CIPHER_AES_GCM_128;
memcpy(req.key, c->key, sizeof(c->key));
memcpy(req.iv, c->iv, sizeof(c->iv));
memcpy(req.salt, c->salt, sizeof(c->salt));
memcpy(req.record_seq, c->rec_seq, sizeof(c->rec_seq));
break;
}
default:
return -EOPNOTSUPP;
}
rc = fun_submit_admin_sync_cmd(fp->fdev, &req.common, &rsp,
sizeof(rsp), 0);
memzero_explicit(&req, sizeof(req));
if (rc)
return rc;
tx_ctx = tls_driver_ctx(sk, direction);
tx_ctx->tlsid = rsp.tlsid;
tx_ctx->next_seq = start_offload_tcp_sn;
atomic64_inc(&fp->tx_tls_add);
return 0;
}
static void fun_ktls_del(struct net_device *netdev,
struct tls_context *tls_ctx,
enum tls_offload_ctx_dir direction)
{
struct funeth_priv *fp = netdev_priv(netdev);
struct fun_admin_ktls_modify_req req;
struct fun_ktls_tx_ctx *tx_ctx;
if (direction != TLS_OFFLOAD_CTX_DIR_TX)
return;
tx_ctx = __tls_driver_ctx(tls_ctx, direction);
req.common = FUN_ADMIN_REQ_COMMON_INIT2(FUN_ADMIN_OP_KTLS,
offsetof(struct fun_admin_ktls_modify_req, tcp_seq));
req.subop = FUN_ADMIN_SUBOP_MODIFY;
req.flags = cpu_to_be16(FUN_KTLS_MODIFY_REMOVE);
req.id = cpu_to_be32(fp->ktls_id);
req.tlsid = tx_ctx->tlsid;
Annotation
- Immediate include surface: `funeth.h`, `funeth_ktls.h`.
- Detected declarations: `function fun_admin_ktls_create`, `function fun_ktls_add`, `function fun_ktls_del`, `function fun_ktls_resync`, `function fun_ktls_init`, `function fun_ktls_cleanup`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.