| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: hifn7751.c,v 1.76 2022/05/22 11:31:33 riastradh Exp $ */ | | 1 | /* $NetBSD: hifn7751.c,v 1.77 2022/05/22 11:34:48 riastradh Exp $ */ |
2 | /* $OpenBSD: hifn7751.c,v 1.179 2020/01/11 21:34:03 cheloha Exp $ */ | | 2 | /* $OpenBSD: hifn7751.c,v 1.179 2020/01/11 21:34:03 cheloha Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Invertex AEON / Hifn 7751 driver | | 5 | * Invertex AEON / Hifn 7751 driver |
6 | * Copyright (c) 1999 Invertex Inc. All rights reserved. | | 6 | * Copyright (c) 1999 Invertex Inc. All rights reserved. |
7 | * Copyright (c) 1999 Theo de Raadt | | 7 | * Copyright (c) 1999 Theo de Raadt |
8 | * Copyright (c) 2000-2001 Network Security Technologies, Inc. | | 8 | * Copyright (c) 2000-2001 Network Security Technologies, Inc. |
9 | * http://www.netsec.net | | 9 | * http://www.netsec.net |
10 | * Copyright (c) 2003 Hifn Inc. | | 10 | * Copyright (c) 2003 Hifn Inc. |
11 | * | | 11 | * |
12 | * This driver is based on a previous driver by Invertex, for which they | | 12 | * This driver is based on a previous driver by Invertex, for which they |
13 | * requested: Please send any comments, feedback, bug-fixes, or feature | | 13 | * requested: Please send any comments, feedback, bug-fixes, or feature |
14 | * requests to software@invertex.com. | | 14 | * requests to software@invertex.com. |
| @@ -37,27 +37,27 @@ | | | @@ -37,27 +37,27 @@ |
37 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 37 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
38 | * | | 38 | * |
39 | * Effort sponsored in part by the Defense Advanced Research Projects | | 39 | * Effort sponsored in part by the Defense Advanced Research Projects |
40 | * Agency (DARPA) and Air Force Research Laboratory, Air Force | | 40 | * Agency (DARPA) and Air Force Research Laboratory, Air Force |
41 | * Materiel Command, USAF, under agreement number F30602-01-2-0537. | | 41 | * Materiel Command, USAF, under agreement number F30602-01-2-0537. |
42 | * | | 42 | * |
43 | */ | | 43 | */ |
44 | | | 44 | |
45 | /* | | 45 | /* |
46 | * Driver for various Hifn encryption processors. | | 46 | * Driver for various Hifn encryption processors. |
47 | */ | | 47 | */ |
48 | | | 48 | |
49 | #include <sys/cdefs.h> | | 49 | #include <sys/cdefs.h> |
50 | __KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.76 2022/05/22 11:31:33 riastradh Exp $"); | | 50 | __KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.77 2022/05/22 11:34:48 riastradh Exp $"); |
51 | | | 51 | |
52 | #include <sys/param.h> | | 52 | #include <sys/param.h> |
53 | #include <sys/cprng.h> | | 53 | #include <sys/cprng.h> |
54 | #include <sys/device.h> | | 54 | #include <sys/device.h> |
55 | #include <sys/endian.h> | | 55 | #include <sys/endian.h> |
56 | #include <sys/errno.h> | | 56 | #include <sys/errno.h> |
57 | #include <sys/kernel.h> | | 57 | #include <sys/kernel.h> |
58 | #include <sys/mbuf.h> | | 58 | #include <sys/mbuf.h> |
59 | #include <sys/module.h> | | 59 | #include <sys/module.h> |
60 | #include <sys/mutex.h> | | 60 | #include <sys/mutex.h> |
61 | #include <sys/pool.h> | | 61 | #include <sys/pool.h> |
62 | #include <sys/proc.h> | | 62 | #include <sys/proc.h> |
63 | #include <sys/rndsource.h> | | 63 | #include <sys/rndsource.h> |
| @@ -2167,31 +2167,26 @@ hifn_freesession(void *arg, uint64_t tid | | | @@ -2167,31 +2167,26 @@ hifn_freesession(void *arg, uint64_t tid |
2167 | clrbit(sc->sc_sessions, session); | | 2167 | clrbit(sc->sc_sessions, session); |
2168 | mutex_spin_exit(&sc->sc_mtx); | | 2168 | mutex_spin_exit(&sc->sc_mtx); |
2169 | return (0); | | 2169 | return (0); |
2170 | } | | 2170 | } |
2171 | | | 2171 | |
2172 | static int | | 2172 | static int |
2173 | hifn_process(void *arg, struct cryptop *crp, int hint) | | 2173 | hifn_process(void *arg, struct cryptop *crp, int hint) |
2174 | { | | 2174 | { |
2175 | struct hifn_softc *sc = arg; | | 2175 | struct hifn_softc *sc = arg; |
2176 | struct hifn_command *cmd = NULL; | | 2176 | struct hifn_command *cmd = NULL; |
2177 | int session, err = 0, ivlen; | | 2177 | int session, err = 0, ivlen; |
2178 | struct cryptodesc *crd1, *crd2, *maccrd, *enccrd; | | 2178 | struct cryptodesc *crd1, *crd2, *maccrd, *enccrd; |
2179 | | | 2179 | |
2180 | if (crp == NULL || crp->crp_callback == NULL) { | | | |
2181 | hifnstats.hst_invalid++; | | | |
2182 | return (EINVAL); | | | |
2183 | } | | | |
2184 | | | | |
2185 | if ((cmd = pool_cache_get(sc->sc_cmd_cache, PR_NOWAIT)) == NULL) { | | 2180 | if ((cmd = pool_cache_get(sc->sc_cmd_cache, PR_NOWAIT)) == NULL) { |
2186 | hifnstats.hst_nomem++; | | 2181 | hifnstats.hst_nomem++; |
2187 | err = ENOMEM; | | 2182 | err = ENOMEM; |
2188 | goto errout; | | 2183 | goto errout; |
2189 | } | | 2184 | } |
2190 | | | 2185 | |
2191 | mutex_spin_enter(&sc->sc_mtx); | | 2186 | mutex_spin_enter(&sc->sc_mtx); |
2192 | session = HIFN_SESSION(crp->crp_sid); | | 2187 | session = HIFN_SESSION(crp->crp_sid); |
2193 | if (session >= sc->sc_maxses) { | | 2188 | if (session >= sc->sc_maxses) { |
2194 | err = EINVAL; | | 2189 | err = EINVAL; |
2195 | goto errout; | | 2190 | goto errout; |
2196 | } | | 2191 | } |
2197 | | | 2192 | |