Commit Graph

13 Commits

Author SHA1 Message Date
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