xref: /freebsd/sys/dev/cxgbe/tom/t4_tls.h (revision 7de77bea2a6136af55fdf9cc49fb5b6e7cb9615e)
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 	bool tls13;
78 	struct tls_scmd scmd0;
79 	u_int iv_len;
80 	unsigned int tx_key_info_size;
81 	size_t rx_resid;
82 };
83 
84 struct tls_hdr {
85 	__u8   type;
86 	__be16 version;
87 	__be16 length;
88 } __packed;
89 
90 struct tlsrx_hdr_pkt {
91 	__u8   type;
92 	__be16 version;
93 	__be16 length;
94 
95 	__be64 tls_seq;
96 	__be16 reserved1;
97 	__u8   res_to_mac_error;
98 } __packed;
99 
100 /* res_to_mac_error fields */
101 #define S_TLSRX_HDR_PKT_INTERNAL_ERROR   4
102 #define M_TLSRX_HDR_PKT_INTERNAL_ERROR   0x1
103 #define V_TLSRX_HDR_PKT_INTERNAL_ERROR(x) \
104 	((x) << S_TLSRX_HDR_PKT_INTERNAL_ERROR)
105 #define G_TLSRX_HDR_PKT_INTERNAL_ERROR(x) \
106 (((x) >> S_TLSRX_HDR_PKT_INTERNAL_ERROR) & M_TLSRX_HDR_PKT_INTERNAL_ERROR)
107 #define F_TLSRX_HDR_PKT_INTERNAL_ERROR   V_TLSRX_HDR_PKT_INTERNAL_ERROR(1U)
108 
109 #define S_TLSRX_HDR_PKT_SPP_ERROR        3
110 #define M_TLSRX_HDR_PKT_SPP_ERROR        0x1
111 #define V_TLSRX_HDR_PKT_SPP_ERROR(x)     ((x) << S_TLSRX_HDR_PKT_SPP_ERROR)
112 #define G_TLSRX_HDR_PKT_SPP_ERROR(x)     \
113 (((x) >> S_TLSRX_HDR_PKT_SPP_ERROR) & M_TLSRX_HDR_PKT_SPP_ERROR)
114 #define F_TLSRX_HDR_PKT_SPP_ERROR        V_TLSRX_HDR_PKT_SPP_ERROR(1U)
115 
116 #define S_TLSRX_HDR_PKT_CCDX_ERROR       2
117 #define M_TLSRX_HDR_PKT_CCDX_ERROR       0x1
118 #define V_TLSRX_HDR_PKT_CCDX_ERROR(x)    ((x) << S_TLSRX_HDR_PKT_CCDX_ERROR)
119 #define G_TLSRX_HDR_PKT_CCDX_ERROR(x)    \
120 (((x) >> S_TLSRX_HDR_PKT_CCDX_ERROR) & M_TLSRX_HDR_PKT_CCDX_ERROR)
121 #define F_TLSRX_HDR_PKT_CCDX_ERROR       V_TLSRX_HDR_PKT_CCDX_ERROR(1U)
122 
123 #define S_TLSRX_HDR_PKT_PAD_ERROR        1
124 #define M_TLSRX_HDR_PKT_PAD_ERROR        0x1
125 #define V_TLSRX_HDR_PKT_PAD_ERROR(x)     ((x) << S_TLSRX_HDR_PKT_PAD_ERROR)
126 #define G_TLSRX_HDR_PKT_PAD_ERROR(x)     \
127 (((x) >> S_TLSRX_HDR_PKT_PAD_ERROR) & M_TLSRX_HDR_PKT_PAD_ERROR)
128 #define F_TLSRX_HDR_PKT_PAD_ERROR        V_TLSRX_HDR_PKT_PAD_ERROR(1U)
129 
130 #define S_TLSRX_HDR_PKT_MAC_ERROR        0
131 #define M_TLSRX_HDR_PKT_MAC_ERROR        0x1
132 #define V_TLSRX_HDR_PKT_MAC_ERROR(x)     ((x) << S_TLSRX_HDR_PKT_MAC_ERROR)
133 #define G_TLSRX_HDR_PKT_MAC_ERROR(x)     \
134 (((x) >> S_TLSRX_HDR_PKT_MAC_ERROR) & M_TLSRX_HDR_PKT_MAC_ERROR)
135 #define F_TLSRX_HDR_PKT_MAC_ERROR        V_TLSRX_HDR_PKT_MAC_ERROR(1U)
136 
137 #define M_TLSRX_HDR_PKT_ERROR		0x1F
138 
139 #endif /* _KERNEL */
140 
141 #endif /* !__T4_TLS_H__ */
142