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