xref: /freebsd/sys/dev/cxgbe/tom/t4_tls.h (revision c1d255d3)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
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  * $FreeBSD$
30  *
31  */
32 
33 #ifndef __T4_TLS_H__
34 #define __T4_TLS_H__
35 
36 #ifdef _KERNEL
37 
38 /* Timeouts for handshake timer in seconds. */
39 #define TLS_SRV_HELLO_DONE		9
40 #define TLS_SRV_HELLO_RD_TM		5
41 #define TLS_SRV_HELLO_BKOFF_TM		15
42 
43 #define CONTENT_TYPE_CCS		20
44 #define CONTENT_TYPE_ALERT		21
45 #define CONTENT_TYPE_HANDSHAKE		22
46 #define CONTENT_TYPE_APP_DATA		23
47 #define CONTENT_TYPE_HEARTBEAT		24
48 #define CONTENT_TYPE_KEY_CONTEXT	32
49 #define CONTENT_TYPE_ERROR		127
50 
51 #define TLS_HEADER_LENGTH		5
52 #define TP_TX_PG_SZ			65536
53 #define FC_TP_PLEN_MAX			17408
54 
55 enum {
56 	TLS_SFO_WR_CONTEXTLOC_DSGL,
57 	TLS_SFO_WR_CONTEXTLOC_IMMEDIATE,
58 	TLS_SFO_WR_CONTEXTLOC_DDR,
59 };
60 
61 enum {
62 	CPL_TX_TLS_SFO_TYPE_CCS,
63 	CPL_TX_TLS_SFO_TYPE_ALERT,
64 	CPL_TX_TLS_SFO_TYPE_HANDSHAKE,
65 	CPL_TX_TLS_SFO_TYPE_DATA,
66 	CPL_TX_TLS_SFO_TYPE_HEARTBEAT,	/* XXX: Shouldn't this be "CUSTOM"? */
67 };
68 
69 struct tls_scmd {
70 	__be32 seqno_numivs;
71 	__be32 ivgen_hdrlen;
72 };
73 
74 struct tls_ofld_info {
75 	unsigned int frag_size;
76 	int key_location;
77 	int rx_key_addr;
78 	int tx_key_addr;
79 	uint64_t tx_seq_no;
80 	uint16_t rx_version;
81 	unsigned short fcplenmax;
82 	unsigned short adjusted_plen;
83 	unsigned short expn_per_ulp;
84 	unsigned short pdus_per_ulp;
85 	struct tls_scmd scmd0;
86 	u_int iv_len;
87 	unsigned int tx_key_info_size;
88 	struct callout handshake_timer;
89 };
90 
91 struct tls_hdr {
92 	__u8   type;
93 	__be16 version;
94 	__be16 length;
95 } __packed;
96 
97 struct tlsrx_hdr_pkt {
98 	__u8   type;
99 	__be16 version;
100 	__be16 length;
101 
102 	__be64 tls_seq;
103 	__be16 reserved1;
104 	__u8   res_to_mac_error;
105 } __packed;
106 
107 /* res_to_mac_error fields */
108 #define S_TLSRX_HDR_PKT_INTERNAL_ERROR   4
109 #define M_TLSRX_HDR_PKT_INTERNAL_ERROR   0x1
110 #define V_TLSRX_HDR_PKT_INTERNAL_ERROR(x) \
111 	((x) << S_TLSRX_HDR_PKT_INTERNAL_ERROR)
112 #define G_TLSRX_HDR_PKT_INTERNAL_ERROR(x) \
113 (((x) >> S_TLSRX_HDR_PKT_INTERNAL_ERROR) & M_TLSRX_HDR_PKT_INTERNAL_ERROR)
114 #define F_TLSRX_HDR_PKT_INTERNAL_ERROR   V_TLSRX_HDR_PKT_INTERNAL_ERROR(1U)
115 
116 #define S_TLSRX_HDR_PKT_SPP_ERROR        3
117 #define M_TLSRX_HDR_PKT_SPP_ERROR        0x1
118 #define V_TLSRX_HDR_PKT_SPP_ERROR(x)     ((x) << S_TLSRX_HDR_PKT_SPP_ERROR)
119 #define G_TLSRX_HDR_PKT_SPP_ERROR(x)     \
120 (((x) >> S_TLSRX_HDR_PKT_SPP_ERROR) & M_TLSRX_HDR_PKT_SPP_ERROR)
121 #define F_TLSRX_HDR_PKT_SPP_ERROR        V_TLSRX_HDR_PKT_SPP_ERROR(1U)
122 
123 #define S_TLSRX_HDR_PKT_CCDX_ERROR       2
124 #define M_TLSRX_HDR_PKT_CCDX_ERROR       0x1
125 #define V_TLSRX_HDR_PKT_CCDX_ERROR(x)    ((x) << S_TLSRX_HDR_PKT_CCDX_ERROR)
126 #define G_TLSRX_HDR_PKT_CCDX_ERROR(x)    \
127 (((x) >> S_TLSRX_HDR_PKT_CCDX_ERROR) & M_TLSRX_HDR_PKT_CCDX_ERROR)
128 #define F_TLSRX_HDR_PKT_CCDX_ERROR       V_TLSRX_HDR_PKT_CCDX_ERROR(1U)
129 
130 #define S_TLSRX_HDR_PKT_PAD_ERROR        1
131 #define M_TLSRX_HDR_PKT_PAD_ERROR        0x1
132 #define V_TLSRX_HDR_PKT_PAD_ERROR(x)     ((x) << S_TLSRX_HDR_PKT_PAD_ERROR)
133 #define G_TLSRX_HDR_PKT_PAD_ERROR(x)     \
134 (((x) >> S_TLSRX_HDR_PKT_PAD_ERROR) & M_TLSRX_HDR_PKT_PAD_ERROR)
135 #define F_TLSRX_HDR_PKT_PAD_ERROR        V_TLSRX_HDR_PKT_PAD_ERROR(1U)
136 
137 #define S_TLSRX_HDR_PKT_MAC_ERROR        0
138 #define M_TLSRX_HDR_PKT_MAC_ERROR        0x1
139 #define V_TLSRX_HDR_PKT_MAC_ERROR(x)     ((x) << S_TLSRX_HDR_PKT_MAC_ERROR)
140 #define G_TLSRX_HDR_PKT_MAC_ERROR(x)     \
141 (((x) >> S_TLSRX_HDR_PKT_MAC_ERROR) & M_TLSRX_HDR_PKT_MAC_ERROR)
142 #define F_TLSRX_HDR_PKT_MAC_ERROR        V_TLSRX_HDR_PKT_MAC_ERROR(1U)
143 
144 #define M_TLSRX_HDR_PKT_ERROR		0x1F
145 
146 #endif /* _KERNEL */
147 
148 #endif /* !__T4_TLS_H__ */
149