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