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
13struct mlx5e_accel_tx_tls_state {
14	u32 tls_tisn;
15};
16
17u16 mlx5e_ktls_get_stop_room(struct mlx5_core_dev *mdev, struct mlx5e_params *params);
18
19bool 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);
22void mlx5e_ktls_handle_rx_skb(struct mlx5e_rq *rq, struct sk_buff *skb,
23			      struct mlx5_cqe64 *cqe, u32 *cqe_bcnt);
24
25void mlx5e_ktls_handle_ctx_completion(struct mlx5e_icosq_wqe_info *wi);
26void mlx5e_ktls_handle_get_psv_completion(struct mlx5e_icosq_wqe_info *wi,
27					  struct mlx5e_icosq *sq);
28
29void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
30					   struct mlx5e_tx_wqe_info *wi,
31					   u32 *dma_fifo_cc);
32static inline bool
33mlx5e_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
44bool mlx5e_ktls_rx_handle_resync_list(struct mlx5e_channel *c, int budget);
45
46static inline bool
47mlx5e_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
52static inline void
53mlx5e_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
59static inline bool
60mlx5e_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
67static inline bool
68mlx5e_ktls_rx_handle_resync_list(struct mlx5e_channel *c, int budget)
69{
70	return false;
71}
72
73static inline bool
74mlx5e_ktls_rx_pending_resync_list(struct mlx5e_channel *c, int budget)
75{
76	return false;
77}
78
79static inline u16 mlx5e_ktls_get_stop_room(struct mlx5_core_dev *mdev,
80					   struct mlx5e_params *params)
81{
82	return 0;
83}
84
85static 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