xref: /freebsd/sys/dev/cxgbe/tom/t4_tls.h (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2017-2018 Chelsio Communications, Inc.
5  * All rights reserved.
6  * Written by: John Baldwin <jhb@FreeBSD.org>, Atul Gupta
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  */
30 
31 #ifndef __T4_TLS_H__
32 #define __T4_TLS_H__
33 
34 #ifdef _KERNEL
35 
36 #define CONTENT_TYPE_CCS		20
37 #define CONTENT_TYPE_ALERT		21
38 #define CONTENT_TYPE_HANDSHAKE		22
39 #define CONTENT_TYPE_APP_DATA		23
40 #define CONTENT_TYPE_HEARTBEAT		24
41 #define CONTENT_TYPE_KEY_CONTEXT	32
42 #define CONTENT_TYPE_ERROR		127
43 
44 #define TLS_HEADER_LENGTH		5
45 #define TP_TX_PG_SZ			65536
46 #define FC_TP_PLEN_MAX			17408
47 
48 enum {
49 	TLS_SFO_WR_CONTEXTLOC_DSGL,
50 	TLS_SFO_WR_CONTEXTLOC_IMMEDIATE,
51 	TLS_SFO_WR_CONTEXTLOC_DDR,
52 };
53 
54 enum {
55 	CPL_TX_TLS_SFO_TYPE_CCS,
56 	CPL_TX_TLS_SFO_TYPE_ALERT,
57 	CPL_TX_TLS_SFO_TYPE_HANDSHAKE,
58 	CPL_TX_TLS_SFO_TYPE_DATA,
59 	CPL_TX_TLS_SFO_TYPE_CUSTOM,
60 };
61 
62 struct tls_scmd {
63 	__be32 seqno_numivs;
64 	__be32 ivgen_hdrlen;
65 };
66 
67 struct tls_ofld_info {
68 	unsigned int frag_size;
69 	int key_location;
70 	int rx_key_addr;
71 	int tx_key_addr;
72 	uint16_t rx_version;
73 	unsigned short fcplenmax;
74 	unsigned short adjusted_plen;
75 	unsigned short expn_per_ulp;
76 	unsigned short pdus_per_ulp;
77 	struct tls_scmd scmd0;
78 	u_int iv_len;
79 	unsigned int tx_key_info_size;
80 	size_t rx_resid;
81 };
82 
83 struct tls_hdr {
84 	__u8   type;
85 	__be16 version;
86 	__be16 length;
87 } __packed;
88 
89 struct tlsrx_hdr_pkt {
90 	__u8   type;
91 	__be16 version;
92 	__be16 length;
93 
94 	__be64 tls_seq;
95 	__be16 reserved1;
96 	__u8   res_to_mac_error;
97 } __packed;
98 
99 /* res_to_mac_error fields */
100 #define S_TLSRX_HDR_PKT_INTERNAL_ERROR   4
101 #define M_TLSRX_HDR_PKT_INTERNAL_ERROR   0x1
102 #define V_TLSRX_HDR_PKT_INTERNAL_ERROR(x) \
103 	((x) << S_TLSRX_HDR_PKT_INTERNAL_ERROR)
104 #define G_TLSRX_HDR_PKT_INTERNAL_ERROR(x) \
105 (((x) >> S_TLSRX_HDR_PKT_INTERNAL_ERROR) & M_TLSRX_HDR_PKT_INTERNAL_ERROR)
106 #define F_TLSRX_HDR_PKT_INTERNAL_ERROR   V_TLSRX_HDR_PKT_INTERNAL_ERROR(1U)
107 
108 #define S_TLSRX_HDR_PKT_SPP_ERROR        3
109 #define M_TLSRX_HDR_PKT_SPP_ERROR        0x1
110 #define V_TLSRX_HDR_PKT_SPP_ERROR(x)     ((x) << S_TLSRX_HDR_PKT_SPP_ERROR)
111 #define G_TLSRX_HDR_PKT_SPP_ERROR(x)     \
112 (((x) >> S_TLSRX_HDR_PKT_SPP_ERROR) & M_TLSRX_HDR_PKT_SPP_ERROR)
113 #define F_TLSRX_HDR_PKT_SPP_ERROR        V_TLSRX_HDR_PKT_SPP_ERROR(1U)
114 
115 #define S_TLSRX_HDR_PKT_CCDX_ERROR       2
116 #define M_TLSRX_HDR_PKT_CCDX_ERROR       0x1
117 #define V_TLSRX_HDR_PKT_CCDX_ERROR(x)    ((x) << S_TLSRX_HDR_PKT_CCDX_ERROR)
118 #define G_TLSRX_HDR_PKT_CCDX_ERROR(x)    \
119 (((x) >> S_TLSRX_HDR_PKT_CCDX_ERROR) & M_TLSRX_HDR_PKT_CCDX_ERROR)
120 #define F_TLSRX_HDR_PKT_CCDX_ERROR       V_TLSRX_HDR_PKT_CCDX_ERROR(1U)
121 
122 #define S_TLSRX_HDR_PKT_PAD_ERROR        1
123 #define M_TLSRX_HDR_PKT_PAD_ERROR        0x1
124 #define V_TLSRX_HDR_PKT_PAD_ERROR(x)     ((x) << S_TLSRX_HDR_PKT_PAD_ERROR)
125 #define G_TLSRX_HDR_PKT_PAD_ERROR(x)     \
126 (((x) >> S_TLSRX_HDR_PKT_PAD_ERROR) & M_TLSRX_HDR_PKT_PAD_ERROR)
127 #define F_TLSRX_HDR_PKT_PAD_ERROR        V_TLSRX_HDR_PKT_PAD_ERROR(1U)
128 
129 #define S_TLSRX_HDR_PKT_MAC_ERROR        0
130 #define M_TLSRX_HDR_PKT_MAC_ERROR        0x1
131 #define V_TLSRX_HDR_PKT_MAC_ERROR(x)     ((x) << S_TLSRX_HDR_PKT_MAC_ERROR)
132 #define G_TLSRX_HDR_PKT_MAC_ERROR(x)     \
133 (((x) >> S_TLSRX_HDR_PKT_MAC_ERROR) & M_TLSRX_HDR_PKT_MAC_ERROR)
134 #define F_TLSRX_HDR_PKT_MAC_ERROR        V_TLSRX_HDR_PKT_MAC_ERROR(1U)
135 
136 #define M_TLSRX_HDR_PKT_ERROR		0x1F
137 
138 #endif /* _KERNEL */
139 
140 #endif /* !__T4_TLS_H__ */
141