1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2019 Mellanox Technologies. */
4 #ifndef __MLX5E_KTLS_H__
5 #define __MLX5E_KTLS_H__
9 #ifdef CONFIG_MLX5_EN_TLS
11 #include "accel/tls.h"
13 #define MLX5E_KTLS_STATIC_UMR_WQE_SZ \
14 (offsetof(struct mlx5e_umr_wqe, tls_static_params_ctx) + \
15 MLX5_ST_SZ_BYTES(tls_static_params))
16 #define MLX5E_KTLS_STATIC_WQEBBS \
17 (DIV_ROUND_UP(MLX5E_KTLS_STATIC_UMR_WQE_SZ, MLX5_SEND_WQE_BB))
19 #define MLX5E_KTLS_PROGRESS_WQE_SZ \
20 (offsetof(struct mlx5e_tx_wqe, tls_progress_params_ctx) + \
21 MLX5_ST_SZ_BYTES(tls_progress_params))
22 #define MLX5E_KTLS_PROGRESS_WQEBBS \
23 (DIV_ROUND_UP(MLX5E_KTLS_PROGRESS_WQE_SZ, MLX5_SEND_WQE_BB))
24 #define MLX5E_KTLS_MAX_DUMP_WQEBBS 2
27 MLX5E_TLS_PROGRESS_PARAMS_AUTH_STATE_NO_OFFLOAD = 0,
28 MLX5E_TLS_PROGRESS_PARAMS_AUTH_STATE_OFFLOAD = 1,
29 MLX5E_TLS_PROGRESS_PARAMS_AUTH_STATE_AUTHENTICATION = 2,
33 MLX5E_TLS_PROGRESS_PARAMS_RECORD_TRACKER_STATE_START = 0,
34 MLX5E_TLS_PROGRESS_PARAMS_RECORD_TRACKER_STATE_SEARCHING = 1,
35 MLX5E_TLS_PROGRESS_PARAMS_RECORD_TRACKER_STATE_TRACKING = 2,
38 struct mlx5e_ktls_offload_context_tx {
39 struct tls_offload_context_tx *tx_ctx;
40 struct tls_crypto_info *crypto_info;
44 bool ctx_post_pending;
47 struct mlx5e_ktls_offload_context_tx_shadow {
48 struct tls_offload_context_tx tx_ctx;
49 struct mlx5e_ktls_offload_context_tx *priv_tx;
53 mlx5e_set_ktls_tx_priv_ctx(struct tls_context *tls_ctx,
54 struct mlx5e_ktls_offload_context_tx *priv_tx)
56 struct tls_offload_context_tx *tx_ctx = tls_offload_ctx_tx(tls_ctx);
57 struct mlx5e_ktls_offload_context_tx_shadow *shadow;
59 BUILD_BUG_ON(sizeof(*shadow) > TLS_OFFLOAD_CONTEXT_SIZE_TX);
61 shadow = (struct mlx5e_ktls_offload_context_tx_shadow *)tx_ctx;
63 shadow->priv_tx = priv_tx;
64 priv_tx->tx_ctx = tx_ctx;
67 static inline struct mlx5e_ktls_offload_context_tx *
68 mlx5e_get_ktls_tx_priv_ctx(struct tls_context *tls_ctx)
70 struct tls_offload_context_tx *tx_ctx = tls_offload_ctx_tx(tls_ctx);
71 struct mlx5e_ktls_offload_context_tx_shadow *shadow;
73 BUILD_BUG_ON(sizeof(*shadow) > TLS_OFFLOAD_CONTEXT_SIZE_TX);
75 shadow = (struct mlx5e_ktls_offload_context_tx_shadow *)tx_ctx;
77 return shadow->priv_tx;
80 void mlx5e_ktls_build_netdev(struct mlx5e_priv *priv);
81 void mlx5e_ktls_tx_offload_set_pending(struct mlx5e_ktls_offload_context_tx *priv_tx);
83 struct sk_buff *mlx5e_ktls_handle_tx_skb(struct net_device *netdev,
84 struct mlx5e_txqsq *sq,
86 struct mlx5e_tx_wqe **wqe, u16 *pi);
87 void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
88 struct mlx5e_tx_wqe_info *wi,
89 struct mlx5e_sq_dma *dma);
93 static inline void mlx5e_ktls_build_netdev(struct mlx5e_priv *priv)
99 #endif /* __MLX5E_TLS_H__ */