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