1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (C) 2020 Chelsio Communications. All rights reserved. */
4 #ifndef __CHCR_KTLS_H__
5 #define __CHCR_KTLS_H__
7 #ifdef CONFIG_CHELSIO_TLS_DEVICE
13 #include "chcr_common.h"
14 #include "cxgb4_uld.h"
16 #define CHCR_TCB_STATE_CLOSED 0
17 #define CHCR_KTLS_KEY_CTX_LEN 16
18 #define CHCR_SET_TCB_FIELD_LEN sizeof(struct cpl_set_tcb_field)
19 #define CHCR_PLAIN_TX_DATA_LEN (sizeof(struct fw_ulptx_wr) +\
20 sizeof(struct ulp_txpkt) +\
21 sizeof(struct ulptx_idata) +\
22 sizeof(struct cpl_tx_data))
24 #define CHCR_KTLS_WR_SIZE (CHCR_PLAIN_TX_DATA_LEN +\
25 sizeof(struct cpl_tx_sec_pdu))
27 enum chcr_ktls_conn_state
{
29 KTLS_CONN_ACT_OPEN_REQ
,
30 KTLS_CONN_ACT_OPEN_RPL
,
31 KTLS_CONN_SET_TCB_REQ
,
32 KTLS_CONN_SET_TCB_RPL
,
36 struct chcr_ktls_info
{
38 spinlock_t lock
; /* state machine lock */
39 struct ktls_key_ctx key_ctx
;
41 struct l2t_entry
*l2te
;
42 struct net_device
*netdev
;
53 u32 scmd0_seqno_numivs
;
54 u32 scmd0_ivgen_hdrlen
;
55 u32 tcp_start_seq_number
;
56 u32 scmd0_short_seqno_numivs
;
57 u32 scmd0_short_ivgen_hdrlen
;
58 enum chcr_ktls_conn_state connection_state
;
67 struct chcr_ktls_ofld_ctx_tx
{
68 struct tls_offload_context_tx base
;
69 struct chcr_ktls_info
*chcr_info
;
72 static inline struct chcr_ktls_ofld_ctx_tx
*
73 chcr_get_ktls_tx_context(struct tls_context
*tls_ctx
)
75 BUILD_BUG_ON(sizeof(struct chcr_ktls_ofld_ctx_tx
) >
76 TLS_OFFLOAD_CONTEXT_SIZE_TX
);
77 return container_of(tls_offload_ctx_tx(tls_ctx
),
78 struct chcr_ktls_ofld_ctx_tx
,
82 static inline int chcr_get_first_rx_qid(struct adapter
*adap
)
84 /* u_ctx is saved in adap, fetch it */
85 struct uld_ctx
*u_ctx
= adap
->uld
[CXGB4_ULD_CRYPTO
].handle
;
89 return u_ctx
->lldi
.rxq_ids
[0];
92 void chcr_enable_ktls(struct adapter
*adap
);
93 void chcr_disable_ktls(struct adapter
*adap
);
94 int chcr_ktls_cpl_act_open_rpl(struct adapter
*adap
, unsigned char *input
);
95 int chcr_ktls_cpl_set_tcb_rpl(struct adapter
*adap
, unsigned char *input
);
96 int chcr_ktls_xmit(struct sk_buff
*skb
, struct net_device
*dev
);
97 #endif /* CONFIG_CHELSIO_TLS_DEVICE */
98 #endif /* __CHCR_KTLS_H__ */