|
7 | 7 | #include "en.h" |
8 | 8 |
|
9 | 9 | #ifdef CONFIG_MLX5_EN_TLS |
10 | | -#include <net/tls.h> |
11 | | -#include "accel/tls.h" |
12 | | -#include "en_accel/tls_rxtx.h" |
13 | | - |
14 | | -#define MLX5E_KTLS_STATIC_UMR_WQE_SZ \ |
15 | | - (offsetof(struct mlx5e_umr_wqe, tls_static_params_ctx) + \ |
16 | | - MLX5_ST_SZ_BYTES(tls_static_params)) |
17 | | -#define MLX5E_KTLS_STATIC_WQEBBS \ |
18 | | - (DIV_ROUND_UP(MLX5E_KTLS_STATIC_UMR_WQE_SZ, MLX5_SEND_WQE_BB)) |
19 | | - |
20 | | -#define MLX5E_KTLS_PROGRESS_WQE_SZ \ |
21 | | - (offsetof(struct mlx5e_tx_wqe, tls_progress_params_ctx) + \ |
22 | | - sizeof(struct mlx5_wqe_tls_progress_params_seg)) |
23 | | -#define MLX5E_KTLS_PROGRESS_WQEBBS \ |
24 | | - (DIV_ROUND_UP(MLX5E_KTLS_PROGRESS_WQE_SZ, MLX5_SEND_WQE_BB)) |
25 | | - |
26 | | -struct mlx5e_dump_wqe { |
27 | | - struct mlx5_wqe_ctrl_seg ctrl; |
28 | | - struct mlx5_wqe_data_seg data; |
29 | | -}; |
30 | | - |
31 | | -#define MLX5E_TLS_FETCH_UMR_WQE(sq, pi) \ |
32 | | - ((struct mlx5e_umr_wqe *)mlx5e_fetch_wqe(&(sq)->wq, pi, MLX5E_KTLS_STATIC_UMR_WQE_SZ)) |
33 | | -#define MLX5E_TLS_FETCH_PROGRESS_WQE(sq, pi) \ |
34 | | - ((struct mlx5e_tx_wqe *)mlx5e_fetch_wqe(&(sq)->wq, pi, MLX5E_KTLS_PROGRESS_WQE_SZ)) |
35 | | -#define MLX5E_TLS_FETCH_DUMP_WQE(sq, pi) \ |
36 | | - ((struct mlx5e_dump_wqe *)mlx5e_fetch_wqe(&(sq)->wq, pi, \ |
37 | | - sizeof(struct mlx5e_dump_wqe))) |
38 | | - |
39 | | -#define MLX5E_KTLS_DUMP_WQEBBS \ |
40 | | - (DIV_ROUND_UP(sizeof(struct mlx5e_dump_wqe), MLX5_SEND_WQE_BB)) |
41 | | - |
42 | | -enum { |
43 | | - MLX5E_TLS_PROGRESS_PARAMS_AUTH_STATE_NO_OFFLOAD = 0, |
44 | | - MLX5E_TLS_PROGRESS_PARAMS_AUTH_STATE_OFFLOAD = 1, |
45 | | - MLX5E_TLS_PROGRESS_PARAMS_AUTH_STATE_AUTHENTICATION = 2, |
46 | | -}; |
47 | | - |
48 | | -enum { |
49 | | - MLX5E_TLS_PROGRESS_PARAMS_RECORD_TRACKER_STATE_START = 0, |
50 | | - MLX5E_TLS_PROGRESS_PARAMS_RECORD_TRACKER_STATE_TRACKING = 1, |
51 | | - MLX5E_TLS_PROGRESS_PARAMS_RECORD_TRACKER_STATE_SEARCHING = 2, |
52 | | -}; |
53 | | - |
54 | | -struct mlx5e_ktls_offload_context_tx { |
55 | | - struct tls_offload_context_tx *tx_ctx; |
56 | | - struct tls12_crypto_info_aes_gcm_128 crypto_info; |
57 | | - u32 expected_seq; |
58 | | - u32 tisn; |
59 | | - u32 key_id; |
60 | | - bool ctx_post_pending; |
61 | | -}; |
62 | | - |
63 | | -struct mlx5e_ktls_offload_context_tx_shadow { |
64 | | - struct tls_offload_context_tx tx_ctx; |
65 | | - struct mlx5e_ktls_offload_context_tx *priv_tx; |
66 | | -}; |
67 | | - |
68 | | -static inline void |
69 | | -mlx5e_set_ktls_tx_priv_ctx(struct tls_context *tls_ctx, |
70 | | - struct mlx5e_ktls_offload_context_tx *priv_tx) |
71 | | -{ |
72 | | - struct tls_offload_context_tx *tx_ctx = tls_offload_ctx_tx(tls_ctx); |
73 | | - struct mlx5e_ktls_offload_context_tx_shadow *shadow; |
74 | | - |
75 | | - BUILD_BUG_ON(sizeof(*shadow) > TLS_OFFLOAD_CONTEXT_SIZE_TX); |
76 | | - |
77 | | - shadow = (struct mlx5e_ktls_offload_context_tx_shadow *)tx_ctx; |
78 | | - |
79 | | - shadow->priv_tx = priv_tx; |
80 | | - priv_tx->tx_ctx = tx_ctx; |
81 | | -} |
82 | | - |
83 | | -static inline struct mlx5e_ktls_offload_context_tx * |
84 | | -mlx5e_get_ktls_tx_priv_ctx(struct tls_context *tls_ctx) |
85 | | -{ |
86 | | - struct tls_offload_context_tx *tx_ctx = tls_offload_ctx_tx(tls_ctx); |
87 | | - struct mlx5e_ktls_offload_context_tx_shadow *shadow; |
88 | | - |
89 | | - BUILD_BUG_ON(sizeof(*shadow) > TLS_OFFLOAD_CONTEXT_SIZE_TX); |
90 | | - |
91 | | - shadow = (struct mlx5e_ktls_offload_context_tx_shadow *)tx_ctx; |
92 | | - |
93 | | - return shadow->priv_tx; |
94 | | -} |
95 | 10 |
|
96 | 11 | void mlx5e_ktls_build_netdev(struct mlx5e_priv *priv); |
97 | | -void mlx5e_ktls_tx_offload_set_pending(struct mlx5e_ktls_offload_context_tx *priv_tx); |
98 | 12 |
|
99 | | -bool mlx5e_ktls_handle_tx_skb(struct tls_context *tls_ctx, struct mlx5e_txqsq *sq, |
100 | | - struct sk_buff *skb, int datalen, |
101 | | - struct mlx5e_accel_tx_tls_state *state); |
102 | | -void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq, |
103 | | - struct mlx5e_tx_wqe_info *wi, |
104 | | - u32 *dma_fifo_cc); |
105 | | -u16 mlx5e_ktls_get_stop_room(struct mlx5e_txqsq *sq); |
106 | | - |
107 | | -static inline u8 |
108 | | -mlx5e_ktls_dumps_num_wqes(struct mlx5e_txqsq *sq, unsigned int nfrags, |
109 | | - unsigned int sync_len) |
110 | | -{ |
111 | | - /* Given the MTU and sync_len, calculates an upper bound for the |
112 | | - * number of DUMP WQEs needed for the TX resync of a record. |
113 | | - */ |
114 | | - return nfrags + DIV_ROUND_UP(sync_len, sq->hw_mtu); |
115 | | -} |
116 | 13 | #else |
117 | 14 |
|
118 | 15 | static inline void mlx5e_ktls_build_netdev(struct mlx5e_priv *priv) |
119 | 16 | { |
120 | 17 | } |
121 | 18 |
|
122 | | -static inline void |
123 | | -mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq, |
124 | | - struct mlx5e_tx_wqe_info *wi, |
125 | | - u32 *dma_fifo_cc) {} |
126 | 19 | #endif |
127 | 20 |
|
128 | 21 | #endif /* __MLX5E_TLS_H__ */ |
0 commit comments