Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci unifdef everything-but-NetBSD. Gets rid of a na...
details: https://anonhg.NetBSD.org/src/rev/15294d0a4c3b
branches: trunk
changeset: 933488:15294d0a4c3b
user: thorpej <thorpej%NetBSD.org@localhost>
date: Mon May 25 19:13:28 2020 +0000
description:
unifdef everything-but-NetBSD. Gets rid of a naked cfattach decl.
diffstat:
sys/dev/pci/ubsec.c | 82 +++++-----------------------------------------------
1 files changed, 9 insertions(+), 73 deletions(-)
diffs (189 lines):
diff -r 805fee4dfed8 -r 15294d0a4c3b sys/dev/pci/ubsec.c
--- a/sys/dev/pci/ubsec.c Mon May 25 19:05:30 2020 +0000
+++ b/sys/dev/pci/ubsec.c Mon May 25 19:13:28 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ubsec.c,v 1.50 2020/04/30 03:40:53 riastradh Exp $ */
+/* $NetBSD: ubsec.c,v 1.51 2020/05/25 19:13:28 thorpej Exp $ */
/* $FreeBSD: src/sys/dev/ubsec/ubsec.c,v 1.6.2.6 2003/01/23 21:06:43 sam Exp $ */
/* $OpenBSD: ubsec.c,v 1.143 2009/03/27 13:31:30 reyk Exp$ */
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.50 2020/04/30 03:40:53 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.51 2020/05/25 19:13:28 thorpej Exp $");
#undef UBSEC_DEBUG
@@ -47,11 +47,6 @@
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/endian.h>
-#ifdef __NetBSD__
- #define UBSEC_NO_RNG /* hangs on attach */
- #define letoh16 htole16
- #define letoh32 htole32
-#endif
#include <sys/errno.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
@@ -63,14 +58,9 @@
#include <opencrypto/cryptodev.h>
#include <opencrypto/xform.h>
-#ifdef __OpenBSD__
- #include <dev/rndvar.h>
- #include <sys/md5k.h>
-#else
- #include <sys/cprng.h>
- #include <sys/md5.h>
- #include <sys/rndsource.h>
-#endif
+#include <sys/cprng.h>
+#include <sys/md5.h>
+#include <sys/rndsource.h>
#include <sys/sha1.h>
#include <dev/pci/pcireg.h>
@@ -80,6 +70,10 @@
#include <dev/pci/ubsecreg.h>
#include <dev/pci/ubsecvar.h>
+#define UBSEC_NO_RNG /* hangs on attach */
+#define letoh16 htole16
+#define letoh32 htole32
+
/*
* Prototypes and count for the pci_device structure
*/
@@ -93,19 +87,9 @@
static void ubsec_totalreset(struct ubsec_softc *);
static int ubsec_free_q(struct ubsec_softc*, struct ubsec_q *);
-#ifdef __OpenBSD__
-struct cfattach ubsec_ca = {
- sizeof(struct ubsec_softc), ubsec_probe, ubsec_attach,
-};
-
-struct cfdriver ubsec_cd = {
- 0, "ubsec", DV_DULL
-};
-#else
CFATTACH_DECL_NEW(ubsec, sizeof(struct ubsec_softc), ubsec_probe, ubsec_attach,
ubsec_detach, NULL);
extern struct cfdriver ubsec_cd;
-#endif
/* patchable */
#ifdef UBSEC_DEBUG
@@ -503,13 +487,8 @@
sc->sc_rnghz = hz / 100;
else
sc->sc_rnghz = 1;
-#ifdef __OpenBSD__
- timeout_set(&sc->sc_rngto, ubsec_rng, sc);
- timeout_add(&sc->sc_rngto, sc->sc_rnghz);
-#else
callout_init(&sc->sc_rngto, 0);
callout_setfunc(&sc->sc_rngto, ubsec_rng, sc);
-#endif
rndsource_setcb(&sc->sc_rnd_source, ubsec_rng_get, sc);
rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dev),
RND_TYPE_RNG,
@@ -1053,11 +1032,7 @@
ses->ses_used = 1;
if (encini) {
/* get an IV, network byte order */
-#ifdef __NetBSD__
cprng_fast(ses->ses_iv, sizeof(ses->ses_iv));
-#else
- get_random_bytes(ses->ses_iv, sizeof(ses->ses_iv));
-#endif
/* Go ahead and compute key in ubsec's byte order */
if (encini->cri_alg == CRYPTO_AES_CBC) {
@@ -1175,9 +1150,6 @@
ubsec_process(void *arg, struct cryptop *crp, int hint)
{
struct ubsec_q *q = NULL;
-#ifdef __OpenBSD__
- int card;
-#endif
int err = 0, i, j, nicealign;
struct ubsec_softc *sc;
struct cryptodesc *crd1, *crd2, *maccrd, *enccrd;
@@ -2016,22 +1988,13 @@
bus_dmamap_sync(sc->sc_dmat, rng->rng_buf.dma_map, 0,
rng->rng_buf.dma_map->dm_mapsize, BUS_DMASYNC_POSTREAD);
p = (u_int32_t *)rng->rng_buf.dma_vaddr;
-#ifndef __NetBSD__
- for (i = 0; i < UBSEC_RNG_BUFSIZ; p++, i++)
- add_true_randomness(letoh32(*p));
-#else
i = UBSEC_RNG_BUFSIZ * sizeof(u_int32_t);
rnd_add_data(&sc->sc_rnd_source, (char *)p, i, i * NBBY);
sc->sc_rng_need -= i;
-#endif
rng->rng_used = 0;
-#ifdef __OpenBSD__
- timeout_add(&sc->sc_rngto, sc->sc_rnghz);
-#else
if (sc->sc_rng_need > 0) {
callout_schedule(&sc->sc_rngto, sc->sc_rnghz);
}
-#endif
break;
}
#endif
@@ -2204,11 +2167,7 @@
* Something weird happened, generate our own call back.
*/
(*nqueue)--;
-#ifdef __OpenBSD__
- timeout_add(&sc->sc_rngto, sc->sc_rnghz);
-#else
callout_schedule(&sc->sc_rngto, sc->sc_rnghz);
-#endif
}
#endif /* UBSEC_NO_RNG */
@@ -2434,24 +2393,6 @@
return (1);
}
-#ifdef __OpenBSD__
-struct ubsec_softc *
-ubsec_kfind(struct cryptkop *krp)
-{
- struct ubsec_softc *sc;
- int i;
-
- for (i = 0; i < ubsec_cd.cd_ndevs; i++) {
- sc = ubsec_cd.cd_devs[i];
- if (sc == NULL)
- continue;
- if (sc->sc_cid == krp->krp_hid)
- return (sc);
- }
- return (NULL);
-}
-#endif
-
static void
ubsec_kfree(struct ubsec_softc *sc, struct ubsec_q2 *q)
{
@@ -2493,13 +2434,8 @@
if (krp == NULL || krp->krp_callback == NULL)
return (EINVAL);
-#ifdef __OpenBSD__
- if ((sc = ubsec_kfind(krp)) == NULL)
- return (EINVAL);
-#else
sc = arg;
KASSERT(sc != NULL /*, ("ubsec_kprocess: null softc")*/);
-#endif
while (!SIMPLEQ_EMPTY(&sc->sc_q2free)) {
struct ubsec_q2 *q;
Home |
Main Index |
Thread Index |
Old Index