opnsense-src/sys/dev
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
..
aac
aacraid
acpi_support
acpica
adb
adlink
advansys
ae
age
agp
aha
ahci
aic
aic7xxx
al_eth
alc
ale
alpm
altera
amd_ecc_inject
amdpm
amdsbwd
amdsmb
amdsmn
amdtemp
amr
an
arcmsr
asmc
ata
ath
atkbdc
auxio
axgbe
bce
beri
bfe
bge
bhnd
bktr
bm
bnxt
buslogic
bvm
bwi
bwn net80211: wrap protection frame allocation into ieee80211_alloc_prot() 2018-03-09 11:33:56 +00:00
bxe
cadence
cardbus
cas
ce
cesa
cfe
cfi
chromebook_platform
ciss
cm
cmx
coretemp
cp
cpuctl
cpufreq
cs
ctau
cx
cxgb
cxgbe Support for TLS offload of TOE connections on T6 adapters. 2018-03-13 23:05:51 +00:00
cy
cyapa
dc
dcons
de
dme
dpaa
dpms
dpt
drm
drm2
dwc
e1000 e1000g: this statement may fall through 2018-03-12 17:05:53 +00:00
ed
efidev Correct minor typo in comment, efi_dmcap -> efi_tmcap 2018-03-13 15:02:46 +00:00
ena
ep
esp
et
etherswitch
evdev
ex
exca
extres extres/regulators: Add sysctls for regulators 2018-03-11 04:37:05 +00:00
fb
fdc
fdt
fe
ffec
filemon
firewire
flash
fxp
gem
glxiic
glxsb
gpio
gxemul
hdmi
hifn
hme
hpt27xx
hptiop
hptmv
hptnr
hptrr
hwpmc
hyperv
ic
ichiic
ichsmb
ichwd
ida
if_ndis
iicbus
iir
imcsmb
intel
intpm
io
ioat
ipmi
ips
ipw
isci
iscsi Check for duplicates when modifying an iSCSI session. Previously we did 2018-03-10 14:21:37 +00:00
iscsi_initiator
iser
isl
ismt
isp Fix ISP_FC_LIP and ISP_RESCAN on big-endian 64-bit systems. 2018-03-13 19:56:10 +00:00
ispfw
iwi Remove unused variable. 2018-03-08 22:04:54 +00:00
iwm
iwn
ixgb
ixgbe
ixl
jedec_dimm
jedec_ts
jme
joy
kbd
kbdmux
ksyms
le
led
lge
liquidio
lmc
malo
mbox
mc146818
md Don't overflow the kernel struct mdio in the MDIOCLIST ioctl. 2018-03-13 20:39:06 +00:00
mdio
mem
mfi
mge
mii
mk48txx
mlx
mlx4
mlx5 mlx5(4): Remove redundant declaration of mlx5_enter_error_state 2018-03-10 00:59:48 +00:00
mly
mmc
mmcnull
mn
mpr Implement a sysctl to dump in-flight I/O state for debugging. The tool to 2018-03-12 05:02:22 +00:00
mps Implement a sysctl to dump in-flight I/O state for debugging. The tool to 2018-03-12 05:02:22 +00:00
mpt
mrsas
mse
msk
mthca
mvs
mwl
mxge
my
nand
ncr
nctgpio
ncv
neta
netfpga10g/nf10bmac
netmap
nfe
nfsmb
nge
nmdm
nsp
ntb
null
nvd
nvme Print fuses and fna fields in identify data. 2018-03-12 16:31:25 +00:00
nvram
nvram2env
nxge
oce
ofw
otus otus(4): check mcast / mgt / ucast rates during Tx descriptor setup 2018-03-11 00:38:08 +00:00
ow
pbio
pccard
pccbb
pcf
pci
pcn
pdq
pms
powermac_nvram
ppbus
ppc
proto
psci
pst
pty
puc
qlnx/qlnxe
qlxgb
qlxgbe
qlxge
quicc
ral net80211: wrap protection frame allocation into ieee80211_alloc_prot() 2018-03-09 11:33:56 +00:00
random
rc
rccgpio
re
rl
rndtest
rp
rt
rtwn rtwn(4): reset Tx power values before calling get_txpower() 2018-03-10 23:47:03 +00:00
safe
sbni
scc
sdhci Fix build when option MMCCAM is defined. 2018-03-08 22:49:36 +00:00
sec
sf
sfxge
sge
siis
sio
sis
sk
smbus
smc
sn
snp
sound
speaker
spibus
ste
stg
stge
sym
syscons
tdfx
terasic
ti
tl
tpm
trm
tsec
twa
twe
tws
tx
txp
uart
ubsec
usb usb/wlan/*: properly include "opt_wlan.h" into all drivers 2018-03-10 23:16:24 +00:00
vge
viapm
viawd
videomode
virtio
vkbd
vmware/vmxnet3
vnic
vr
vt vt_vga: check if VGA is available from ACPI FADT table 2018-03-13 09:38:53 +00:00
vte
vx
vxge
watchdog
wb
wbwd
wi
wpi
wtap
xdma
xe
xen
xilinx
xl