Commit Graph

20 Commits

Author SHA1 Message Date
Mateusz Guzik
4bae659941 safexcel: plug set-but-not-used vars
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-12-18 13:29:32 +00:00
John Baldwin
6e17a2e00d crypto: Validate AES-GCM IV length in check_csp().
This centralizes the check for valid nonce lengths for AES-GCM.

While here, remove some duplicate checks for valid AES-GCM tag lengths
from ccp(4) and ccr(4).

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33194
2021-12-09 11:52:41 -08:00
Mark Johnston
60c95f3163 safexcel: Fix -Wunused-but-set-variable warnings
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-11-24 13:31:16 -05:00
Mark Johnston
36e4dcf47d safexcel: Set the context record unconditionally
The condition added in commit 5bdb8b273a excludes plain SHA
transforms, so for such sessions crypto operations would return
incorrect results.

Fixes:	5bdb8b273a ("safexcel: Maintain per-session context records")
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-10-18 09:50:42 -04:00
John Baldwin
366ae4a000 safexcel: Support truncated tags for AES-CCM.
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32119
2021-10-06 14:08:48 -07:00
John Baldwin
2ec2e4df09 safexcel: Support multiple nonce lengths for AES-CCM.
Reviewed by:	markj
Sponsored by:	Chelsio Communications, The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32118
2021-10-06 14:08:48 -07:00
Mark Johnston
d8787d4f78 crypto: Constify all transform descriptors
No functional change intended.

Reviewed by:	ae, jhb
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31196
2021-07-26 16:41:05 -04:00
Mark Johnston
2fccd4f9b6 safexcel: Disallow unsupported buffer layouts
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-01-27 15:31:10 -05:00
Mark Johnston
5bdb8b273a safexcel: Maintain per-session context records
The context record contains key material precomputed by the driver at
session creation time.  Rather than storing various components of the
context record in each session, go a bit further and store the full
context record image so that safexcel_process() can simply copy the
image into each request submitted to the hardware.  This simplifies the
data path and eliminates a bunch of unnecessary conditional logic that
was getting executed for each request.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC (Netgate)
2021-01-18 17:07:56 -05:00
Mark Johnston
1a6ffed5d7 safexcel: Simplify request allocation
Rather than preallocating a set of requests and moving them between
queues during state transitions, maintain a shadow of the command
descriptor ring to track the driver context of each request.  This is
simpler and requires less synchronization between safexcel_process() and
the ring interrupt handler.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC (Netgate)
2021-01-18 17:07:56 -05:00
Mark Johnston
b7e27af36b safexcel: Handle command/result descriptor exhaustion gracefully
Rather than returning a hard error in this case, return ERESTART so that
upper layers get a chance to retry the request (or drop it, depending on
the desired policy).

This case is hard to hit due to the somewhat low bound on queued
requests, but that will no longer be true after an upcoming change.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC (Netgate)
2021-01-18 17:07:56 -05:00
Mark Johnston
0371c3faaa safexcel: Add counters for some resource exhaustion conditions
This is useful when analyzing performance problems.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC (Netgate)
2021-01-18 17:07:55 -05:00
Mark Johnston
e934d455ba safexcel: Dispatch requests to the current CPU's ring
This gives better performance in some tests than the previous policy of
statically binding each session to a ring.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC (Netgate)
2021-01-18 17:07:55 -05:00
Mark Johnston
092cf8d63f safexcel: Fix a race around unblocking of crypto ops
safexcel_ring_intr() could fail to observed that sc_blocked is set after
completing all outstanding ops for a ring, in which case blocked ops
would be deferred forever.

Request structures are managed by individual rings, so move the
"blocked" flag into the per-ring state block and use the ring lock to
synchronize with safexcel_process().  Remove sc_mtx since it is now
unused.

MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC (Netgate)
2021-01-08 13:32:04 -05:00
Mark Johnston
8ba6acbbe6 safexcel: Stop using a stack buffer for the ring lock name
mtx_init() does not make a copy of the name so the buffer must be valid
for the lifetime of the driver instance.  Store each ring's lock's name
in the ring structure.

MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC (Netgate)
2021-01-08 13:32:04 -05:00
Mateusz Guzik
f3d4f94fa7 safexcel: clean up empty lines in .c and .h files 2020-09-01 21:54:58 +00:00
Li-Wen Hsu
096761378c Appease gcc's -Wparentheses (and -Werror)
Sponsored by:	The FreeBSD Foundation
2020-08-05 05:58:25 +00:00
Mark Johnston
39523b486b safexcel(4): Silence an integer truncation warning.
In practice overflow is not possible, but we might as well use the right
type for DMA ring sizes.

CID:		1430468
MFC after:	1 week
2020-07-16 14:21:55 +00:00
Mark Johnston
3db2b0d5ff safexcel(4): Fix the INVARIANTS build after a last-second change.
Reported by:	Jenkins
MFC with:	r363180
2020-07-14 15:05:24 +00:00
Mark Johnston
b356ddf076 Add a driver for the SafeXcel EIP-97.
The EIP-97 is a packet processing module found on the ESPRESSObin.  This
commit adds a crypto(9) driver for the crypto and hash engine in this
device.  An initial skeleton driver that could attach and submit
requests was written by loos and others at Netgate, and the driver was
finished by me.

Support for separate AAD and output buffers will be added in a separate
commit, to simplify merging to stable/12 (where those features don't
exist).

Reviewed by:	gnn, jhb
Feedback from:	andrew, cem, manu
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC (Netgate)
Differential Revision:	https://reviews.freebsd.org/D25417
2020-07-14 14:09:29 +00:00