summaryrefslogtreecommitdiff
path: root/sys/arch/i386/pci
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2017-02-07 17:25:47 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2017-02-07 17:25:47 +0000
commit1222539b6394ce40c12127425e341be7447471ee (patch)
tree721477aee6fbd097fd777cf68fa80f12b72bca78 /sys/arch/i386/pci
parentb5f0b38252e2338e048adce12dde40f7a6cae620 (diff)
Reduce the per-packet allocation costs for crypto operations (cryptop)
by pre-allocating two cryptodesc objects and storing them in an array instead of a linked list. If more than two cryptodesc objects are required use mallocarray to fetch them. Adapt the drivers to the new API. This change results in one pool-get per ESP packet instead of three. It also simplifies softraid crypto where more cryptodesc objects are allocated than used. From, with and ok markus@, ok bluhm@ "looks sane" mpi@
Diffstat (limited to 'sys/arch/i386/pci')
-rw-r--r--sys/arch/i386/pci/glxsb.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/arch/i386/pci/glxsb.c b/sys/arch/i386/pci/glxsb.c
index c93a86452b4..21786ab4ece 100644
--- a/sys/arch/i386/pci/glxsb.c
+++ b/sys/arch/i386/pci/glxsb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: glxsb.c,v 1.30 2015/09/08 08:33:26 deraadt Exp $ */
+/* $OpenBSD: glxsb.c,v 1.31 2017/02/07 17:25:45 patrick Exp $ */
/*
* Copyright (c) 2006 Tom Cosgrove <tom@openbsd.org>
@@ -778,7 +778,7 @@ glxsb_crypto_process(struct cryptop *crp)
struct glxsb_session *ses;
struct cryptodesc *crd;
int sesn,err = 0;
- int s;
+ int s, i;
s = splnet();
@@ -786,8 +786,7 @@ glxsb_crypto_process(struct cryptop *crp)
err = EINVAL;
goto out;
}
- crd = crp->crp_desc;
- if (crd == NULL) {
+ if (crp->crp_ndesc < 1) {
err = EINVAL;
goto out;
}
@@ -803,7 +802,8 @@ glxsb_crypto_process(struct cryptop *crp)
goto out;
}
- for (crd = crp->crp_desc; crd; crd = crd->crd_next) {
+ for (i = 0; i < crp->crp_ndesc; i++) {
+ crd = &crp->crp_desc[i];
switch (crd->crd_alg) {
case CRYPTO_AES_CBC:
if (ses->ses_swd_enc) {