1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2020, Mellanox Technologies inc. All rights reserved. */
3 
4 #ifndef __MLX5E_KTLS_TXRX_H__
5 #define __MLX5E_KTLS_TXRX_H__
6 
7 #ifdef CONFIG_MLX5_EN_TLS
8 
9 #include <net/tls.h>
10 #include "en.h"
11 #include "en/txrx.h"
12 
13 struct mlx5e_accel_tx_tls_state {
14 	u32 tls_tisn;
15 };
16 
17 u16 mlx5e_ktls_get_stop_room(struct mlx5_core_dev *mdev, struct mlx5e_params *params);
18 
19 bool mlx5e_ktls_handle_tx_skb(struct net_device *netdev, struct mlx5e_txqsq *sq,
20 			      struct sk_buff *skb,
21 			      struct mlx5e_accel_tx_tls_state *state);
22 void mlx5e_ktls_handle_rx_skb(struct mlx5e_rq *rq, struct sk_buff *skb,
23 			      struct mlx5_cqe64 *cqe, u32 *cqe_bcnt);
24 
25 void mlx5e_ktls_handle_ctx_completion(struct mlx5e_icosq_wqe_info *wi);
26 void mlx5e_ktls_handle_get_psv_completion(struct mlx5e_icosq_wqe_info *wi,
27 					  struct mlx5e_icosq *sq);
28 
29 void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
30 					   struct mlx5e_tx_wqe_info *wi,
31 					   u32 *dma_fifo_cc);
32 static inline bool
mlx5e_ktls_tx_try_handle_resync_dump_comp(struct mlx5e_txqsq * sq,struct mlx5e_tx_wqe_info * wi,u32 * dma_fifo_cc)33 mlx5e_ktls_tx_try_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
34 					  struct mlx5e_tx_wqe_info *wi,
35 					  u32 *dma_fifo_cc)
36 {
37 	if (unlikely(wi->resync_dump_frag_page)) {
38 		mlx5e_ktls_tx_handle_resync_dump_comp(sq, wi, dma_fifo_cc);
39 		return true;
40 	}
41 	return false;
42 }
43 
44 bool mlx5e_ktls_rx_handle_resync_list(struct mlx5e_channel *c, int budget);
45 
46 static inline bool
mlx5e_ktls_rx_pending_resync_list(struct mlx5e_channel * c,int budget)47 mlx5e_ktls_rx_pending_resync_list(struct mlx5e_channel *c, int budget)
48 {
49 	return budget && test_bit(MLX5E_SQ_STATE_PENDING_TLS_RX_RESYNC, &c->async_icosq.state);
50 }
51 
52 static inline void
mlx5e_ktls_handle_tx_wqe(struct mlx5_wqe_ctrl_seg * cseg,struct mlx5e_accel_tx_tls_state * state)53 mlx5e_ktls_handle_tx_wqe(struct mlx5_wqe_ctrl_seg *cseg,
54 			 struct mlx5e_accel_tx_tls_state *state)
55 {
56 	cseg->tis_tir_num = cpu_to_be32(state->tls_tisn << 8);
57 }
58 #else
59 static inline bool
mlx5e_ktls_tx_try_handle_resync_dump_comp(struct mlx5e_txqsq * sq,struct mlx5e_tx_wqe_info * wi,u32 * dma_fifo_cc)60 mlx5e_ktls_tx_try_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
61 					  struct mlx5e_tx_wqe_info *wi,
62 					  u32 *dma_fifo_cc)
63 {
64 	return false;
65 }
66 
67 static inline bool
mlx5e_ktls_rx_handle_resync_list(struct mlx5e_channel * c,int budget)68 mlx5e_ktls_rx_handle_resync_list(struct mlx5e_channel *c, int budget)
69 {
70 	return false;
71 }
72 
73 static inline bool
mlx5e_ktls_rx_pending_resync_list(struct mlx5e_channel * c,int budget)74 mlx5e_ktls_rx_pending_resync_list(struct mlx5e_channel *c, int budget)
75 {
76 	return false;
77 }
78 
mlx5e_ktls_get_stop_room(struct mlx5_core_dev * mdev,struct mlx5e_params * params)79 static inline u16 mlx5e_ktls_get_stop_room(struct mlx5_core_dev *mdev,
80 					   struct mlx5e_params *params)
81 {
82 	return 0;
83 }
84 
mlx5e_ktls_handle_rx_skb(struct mlx5e_rq * rq,struct sk_buff * skb,struct mlx5_cqe64 * cqe,u32 * cqe_bcnt)85 static inline void mlx5e_ktls_handle_rx_skb(struct mlx5e_rq *rq,
86 					    struct sk_buff *skb,
87 					    struct mlx5_cqe64 *cqe,
88 					    u32 *cqe_bcnt)
89 {
90 }
91 #endif /* CONFIG_MLX5_EN_TLS */
92 
93 #endif /* __MLX5E_TLS_TXRX_H__ */
94