dm writecache: add cond_resched to loop in persistent_memory_claim()
[linux/fpc-iii.git] / drivers / crypto / chelsio / chcr_ktls.h
blob5a7ae2ca446eae2e19961dd2470c1f52dc0f9981
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
8 #include <net/tls.h>
9 #include "cxgb4.h"
10 #include "t4_msg.h"
11 #include "t4_tcb.h"
12 #include "l2t.h"
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 {
28 KTLS_CONN_CLOSED,
29 KTLS_CONN_ACT_OPEN_REQ,
30 KTLS_CONN_ACT_OPEN_RPL,
31 KTLS_CONN_SET_TCB_REQ,
32 KTLS_CONN_SET_TCB_RPL,
33 KTLS_CONN_TX_READY,
36 struct chcr_ktls_info {
37 struct sock *sk;
38 spinlock_t lock; /* state machine lock */
39 struct ktls_key_ctx key_ctx;
40 struct adapter *adap;
41 struct l2t_entry *l2te;
42 struct net_device *netdev;
43 u64 iv;
44 u64 record_no;
45 int tid;
46 int atid;
47 int rx_qid;
48 u32 iv_size;
49 u32 prev_seq;
50 u32 prev_ack;
51 u32 salt_size;
52 u32 key_ctx_len;
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;
59 u16 prev_win;
60 u8 tx_chan;
61 u8 smt_idx;
62 u8 port_id;
63 u8 ip_family;
64 u8 first_qset;
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,
79 base);
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;
87 if (!u_ctx)
88 return -1;
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__ */