freebsd-dev/sys
John Baldwin 1e9538d253 Support for TLS offload of TOE connections on T6 adapters.
The TOE engine in Chelsio T6 adapters supports offloading of TLS
encryption and TCP segmentation for offloaded connections.  Sockets
using TLS are required to use a set of custom socket options to upload
RX and TX keys to the NIC and to enable RX processing.  Currently
these socket options are implemented as TCP options in the vendor
specific range.  A patched OpenSSL library will be made available in a
port / package for use with the TLS TOE support.

TOE sockets can either offload both transmit and reception of TLS
records or just transmit.  TLS offload (both RX and TX) is enabled by
setting the dev.t6nex.<x>.tls sysctl to 1 and requires TOE to be
enabled on the relevant interface.  Transmit offload can be used on
any "normal" or TLS TOE socket by using the custom socket option to
program a transmit key.  This permits most TOE sockets to
transparently offload TLS when applications use a patched SSL library
(e.g. using LD_LIBRARY_PATH to request use of a patched OpenSSL
library).  Receive offload can only be used with TOE sockets using the
TLS mode.  The dev.t6nex.0.toe.tls_rx_ports sysctl can be set to a
list of TCP port numbers.  Any connection with either a local or
remote port number in that list will be created as a TLS socket rather
than a plain TOE socket.  Note that although this sysctl accepts an
arbitrary list of port numbers, the sysctl(8) tool is only able to set
sysctl nodes to a single value.  A TLS socket will hang without
receiving data if used by an application that is not using a patched
SSL library.  Thus, the tls_rx_ports node should be used with care.
For a server mostly concerned with offloading TLS transmit, this node
is not needed as plain TOE sockets will fall back to software crypto
when using an unpatched SSL library.

New per-interface statistics nodes are added giving counts of TLS
packets and payload bytes (payload bytes do not include TLS headers or
authentication tags/MACs) offloaded via the TOE engine, e.g.:

dev.cc.0.stats.rx_tls_octets: 149
dev.cc.0.stats.rx_tls_records: 13
dev.cc.0.stats.tx_tls_octets: 26501823
dev.cc.0.stats.tx_tls_records: 1620

TLS transmit work requests are constructed by a new variant of
t4_push_frames() called t4_push_tls_records() in tom/t4_tls.c.

TLS transmit work requests require a buffer containing IVs.  If the
IVs are too large to fit into the work request, a separate buffer is
allocated when constructing a work request.  This buffer is associated
with the transmit descriptor and freed when the descriptor is ACKed by
the adapter.

Received TLS frames use two new CPL messages.  The first message is a
CPL_TLS_DATA containing the decryped payload of a single TLS record.
The handler places the mbuf containing the received payload on an
mbufq in the TOE pcb.  The second message is a CPL_RX_TLS_CMP message
which includes a copy of the TLS header and indicates if there were
any errors.  The handler for this message places the TLS header into
the socket buffer followed by the saved mbuf with the payload data.
Both of these handlers are contained in tom/t4_tls.c.

A few routines were exposed from t4_cpl_io.c for use by t4_tls.c
including send_rx_credits(), a new send_rx_modulate(), and
t4_close_conn().

TLS keys for both transmit and receive are stored in onboard memory
in the NIC in the "TLS keys" memory region.

In some cases a TLS socket can hang with pending data available in the
NIC that is not delivered to the host.  As a workaround, TLS sockets
are more aggressive about sending CPL_RX_DATA_ACK messages anytime that
any data is read from a TLS socket.  In addition, a fallback timer will
periodically send CPL_RX_DATA_ACK messages to the NIC for connections
that are still in the handshake phase.  Once the connection has
finished the handshake and programmed RX keys via the socket option,
the timer is stopped.

A new function select_ulp_mode() is used to determine what sub-mode a
given TOE socket should use (plain TOE, DDP, or TLS).  The existing
set_tcpddp_ulp_mode() function has been renamed to set_ulp_mode() and
handles initialization of TLS-specific state when necessary in
addition to DDP-specific state.

Since TLS sockets do not receive individual TCP segments but always
receive full TLS records, they can receive more data than is available
in the current window (e.g. if a 16k TLS record is received but the
socket buffer is itself 16k).  To cope with this, just drop the window
to 0 when this happens, but track the overage and "eat" the overage as
it is read from the socket buffer not opening the window (or adding
rx_credits) for the overage bytes.

Reviewed by:	np (earlier version)
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D14529
2018-03-13 23:05:51 +00:00
..
amd64 EFIRT: SetVirtualAddressMap with 1:1 mapping after exiting boot services 2018-03-13 17:10:52 +00:00
arm arm: Remove SoC Specific -MMCCAM kernelconfig 2018-03-11 23:14:50 +00:00
arm64 EFIRT: SetVirtualAddressMap with 1:1 mapping after exiting boot services 2018-03-13 17:10:52 +00:00
bsm
cam Reject ioctls to SCSI enclosures from 32-bit compat processes. 2018-03-12 23:02:01 +00:00
cddl MFV r330591: 8984 fix for 6764 breaks ACL inheritance 2018-03-07 13:49:26 +00:00
compat Linuxulator: apply style(9) to return 2018-03-12 15:35:24 +00:00
conf Implement NO_WCAST_QUAL for gcc4.2 architectures 2018-03-12 05:41:27 +00:00
contrib MFV: zstd: FIO_addFInfo: Fully initialize output 'total' struct 2018-03-05 20:03:45 +00:00
crypto Remove unused error return from API that cannot fail 2018-02-23 20:15:19 +00:00
ddb db_script_exec: use a saved script name when reporting commands executed 2018-03-04 13:27:21 +00:00
dev Support for TLS offload of TOE connections on T6 adapters. 2018-03-13 23:05:51 +00:00
dts [rpi] remove IRQ support for BCM233x RNG 2018-03-10 02:49:58 +00:00
fs Fix Bad file descriptor error. 2018-03-09 04:45:24 +00:00
gdb amd64: Protect the kernel text, data, and BSS by setting the RW/NX bits 2018-03-06 14:28:37 +00:00
geom g_part_gpt: Fix memory leak in error path 2018-03-07 01:55:50 +00:00
gnu bwn(4): txpid2g/txpid5g[lh] are not defined after sromrev 7; the default 2018-02-13 17:43:54 +00:00
i386 Use C99 boolean type for translate_osrel 2018-03-13 16:40:29 +00:00
isa Revert r330780, it was improperly tested and results in taking a spin 2018-03-11 20:13:15 +00:00
kern Use C99 boolean type for translate_osrel 2018-03-13 16:40:29 +00:00
kgssapi kgssapi: Remove trivial deadcode 2018-02-14 00:12:03 +00:00
libkern iconv uses strlen directly on user supplied memory 2018-02-26 18:23:36 +00:00
mips MIPS: Implement fue*word* and casueword* in assembly. 2018-03-12 22:10:06 +00:00
modules Support for TLS offload of TOE connections on T6 adapters. 2018-03-13 23:05:51 +00:00
net Define ethernet type 0x88A8 as ETHERTYPE_QINQ. 2018-03-06 12:01:31 +00:00
net80211 net80211: wrap protection frame allocation into ieee80211_alloc_prot() 2018-03-09 11:33:56 +00:00
netgraph Correct pseudo misspelling in sys/ comments 2018-02-23 18:15:50 +00:00
netinet Update tcp_lro with tested bugfixes from Netflix and LLNW: 2018-03-09 00:08:43 +00:00
netinet6 Update the MTU in affected routes when IPv6 RA changes the MTU 2018-02-12 19:49:20 +00:00
netipsec Rework key_sendup_mbuf() a bit: 2018-03-11 19:14:01 +00:00
netpfil Do not try to reassemble IPv6 fragments in "reass" rule. 2018-03-12 09:40:46 +00:00
netsmb Unsign some values related to allocation. 2018-01-22 02:08:10 +00:00
nfs Modernize nfssvc(2) registartion. 2018-02-08 20:09:42 +00:00
nfsclient style: Remove remaining deprecated MALLOC/FREE macros 2018-01-25 22:25:13 +00:00
nfsserver
nlm Use syscall_helper_register() to register syscalls and initialize though 2018-02-10 01:09:22 +00:00
ofed Make sure VNET is set when calling sa6_recoverscope() in ibcore. 2018-03-07 13:32:52 +00:00
opencrypto Move per-operation data out of the csession structure. 2018-01-26 23:21:50 +00:00
powerpc Restore missing temporary variable, deleted by accident in r330845. This 2018-03-13 18:24:21 +00:00
riscv Unify bulk free operations in several pmaps. 2018-03-04 20:53:20 +00:00
rpc
security mac_portacl(4): stop panicing INVARIANTS-enabled kernel by loading .ko 2018-02-25 23:10:13 +00:00
sparc64 amd64: Protect the kernel text, data, and BSS by setting the RW/NX bits 2018-03-06 14:28:37 +00:00
sys md_pad is used by MDIOCLIST and not available for future use. 2018-03-13 20:54:18 +00:00
teken
tests
tools Avoid using \$. It's an unknown escape sequence. Some awks warn about 2018-01-28 05:13:08 +00:00
ufs This change is some refactoring of Mark Johnston's changes in r329375 2018-03-02 04:34:53 +00:00
vm Revert the chunk from r330410 in vm_page_reclaim_run(). 2018-03-13 18:27:23 +00:00
x86 at_rtc: check in ACPI FADT boot flags if the RTC is present 2018-03-13 09:42:33 +00:00
xdr
xen
Makefile