Commit df8d8667 authored by Tariq Toukan's avatar Tariq Toukan Committed by Saeed Mahameed

net/mlx5e: kTLS, Use kernel API to extract private offload context

Modify the implementation of the private kTLS TX HW offload context
getter and setter, so it uses the kernel API functions, instead of
a local shadow structure.
A single BUILD_BUG_ON check is sufficient, remove the duplicate.
Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
Reviewed-by: default avatarMaxim Mikityanskiy <maximmi@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 7d0d0d86
...@@ -56,37 +56,26 @@ struct mlx5e_ktls_offload_context_tx { ...@@ -56,37 +56,26 @@ struct mlx5e_ktls_offload_context_tx {
bool ctx_post_pending; bool ctx_post_pending;
}; };
struct mlx5e_ktls_offload_context_tx_shadow {
struct tls_offload_context_tx tx_ctx;
struct mlx5e_ktls_offload_context_tx *priv_tx;
};
static void static void
mlx5e_set_ktls_tx_priv_ctx(struct tls_context *tls_ctx, mlx5e_set_ktls_tx_priv_ctx(struct tls_context *tls_ctx,
struct mlx5e_ktls_offload_context_tx *priv_tx) struct mlx5e_ktls_offload_context_tx *priv_tx)
{ {
struct tls_offload_context_tx *tx_ctx = tls_offload_ctx_tx(tls_ctx); struct mlx5e_ktls_offload_context_tx **ctx =
struct mlx5e_ktls_offload_context_tx_shadow *shadow; __tls_driver_ctx(tls_ctx, TLS_OFFLOAD_CTX_DIR_TX);
BUILD_BUG_ON(sizeof(*shadow) > TLS_OFFLOAD_CONTEXT_SIZE_TX); BUILD_BUG_ON(sizeof(struct mlx5e_ktls_offload_context_tx *) >
TLS_OFFLOAD_CONTEXT_SIZE_TX);
shadow = (struct mlx5e_ktls_offload_context_tx_shadow *)tx_ctx; *ctx = priv_tx;
shadow->priv_tx = priv_tx;
priv_tx->tx_ctx = tx_ctx;
} }
static struct mlx5e_ktls_offload_context_tx * static struct mlx5e_ktls_offload_context_tx *
mlx5e_get_ktls_tx_priv_ctx(struct tls_context *tls_ctx) mlx5e_get_ktls_tx_priv_ctx(struct tls_context *tls_ctx)
{ {
struct tls_offload_context_tx *tx_ctx = tls_offload_ctx_tx(tls_ctx); struct mlx5e_ktls_offload_context_tx **ctx =
struct mlx5e_ktls_offload_context_tx_shadow *shadow; __tls_driver_ctx(tls_ctx, TLS_OFFLOAD_CTX_DIR_TX);
BUILD_BUG_ON(sizeof(*shadow) > TLS_OFFLOAD_CONTEXT_SIZE_TX);
shadow = (struct mlx5e_ktls_offload_context_tx_shadow *)tx_ctx;
return shadow->priv_tx; return *ctx;
} }
int mlx5e_ktls_add_tx(struct net_device *netdev, struct sock *sk, int mlx5e_ktls_add_tx(struct net_device *netdev, struct sock *sk,
...@@ -113,6 +102,7 @@ int mlx5e_ktls_add_tx(struct net_device *netdev, struct sock *sk, ...@@ -113,6 +102,7 @@ int mlx5e_ktls_add_tx(struct net_device *netdev, struct sock *sk,
priv_tx->expected_seq = start_offload_tcp_sn; priv_tx->expected_seq = start_offload_tcp_sn;
priv_tx->crypto_info = priv_tx->crypto_info =
*(struct tls12_crypto_info_aes_gcm_128 *)crypto_info; *(struct tls12_crypto_info_aes_gcm_128 *)crypto_info;
priv_tx->tx_ctx = tls_offload_ctx_tx(tls_ctx);
mlx5e_set_ktls_tx_priv_ctx(tls_ctx, priv_tx); mlx5e_set_ktls_tx_priv_ctx(tls_ctx, priv_tx);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment