summaryrefslogtreecommitdiffstats
path: root/sys/dev/ubsec/ubsec.c
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2003-03-11 22:47:06 +0000
committersam <sam@FreeBSD.org>2003-03-11 22:47:06 +0000
commit08b96bb1399a2789ebc9d72321d31751cec37e33 (patch)
treec4b232799e4ac8460f49b969f01ac7575565a38e /sys/dev/ubsec/ubsec.c
parent0c3ac305c83bd43547194c4582f11b1918260bba (diff)
downloadFreeBSD-src-08b96bb1399a2789ebc9d72321d31751cec37e33.zip
FreeBSD-src-08b96bb1399a2789ebc9d72321d31751cec37e33.tar.gz
o add crypto driver glue for using the new rndtest driver/module; this is
conditional in each driver on foo_RNDTEST being defined_ o bring HIFN_DEBUG and UBSEC_DEBUG out to be visible options; they control the debugging printfs that are set with hw.foo.debug (e.g. hw.hifn.debug)
Diffstat (limited to 'sys/dev/ubsec/ubsec.c')
-rw-r--r--sys/dev/ubsec/ubsec.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/sys/dev/ubsec/ubsec.c b/sys/dev/ubsec/ubsec.c
index 278f2bb..c091653 100644
--- a/sys/dev/ubsec/ubsec.c
+++ b/sys/dev/ubsec/ubsec.c
@@ -40,12 +40,12 @@
*
*/
-#define UBSEC_DEBUG
-
/*
* uBsec 5[56]01, 58xx hardware crypto accelerator
*/
+#include "opt_ubsec.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
@@ -90,6 +90,9 @@
#define letoh16(x) le16toh(x)
#define letoh32(x) le32toh(x)
+#ifdef UBSEC_RNDTEST
+#include <dev/rndtest/rndtest.h>
+#endif
#include <dev/ubsec/ubsecreg.h>
#include <dev/ubsec/ubsecvar.h>
@@ -127,6 +130,9 @@ static devclass_t ubsec_devclass;
DRIVER_MODULE(ubsec, pci, ubsec_driver, ubsec_devclass, 0, 0);
MODULE_DEPEND(ubsec, crypto, 1, 1, 1);
+#ifdef UBSEC_RNDTEST
+MODULE_DEPEND(ubsec, rndtest, 1, 1, 1);
+#endif
static void ubsec_intr(void *);
static int ubsec_newsession(void *, u_int32_t *, struct cryptoini *);
@@ -231,6 +237,12 @@ ubsec_partname(struct ubsec_softc *sc)
return "Unknown-vendor unknown-part";
}
+static void
+default_harvest(struct rndtest_state *rsp, void *buf, u_int count)
+{
+ random_harvest(buf, count, count*NBBY, 0, RANDOM_PURE);
+}
+
static int
ubsec_attach(device_t dev)
{
@@ -405,6 +417,15 @@ ubsec_attach(device_t dev)
#ifndef UBSEC_NO_RNG
if (sc->sc_flags & UBS_FLAGS_RNG) {
sc->sc_statmask |= BS_STAT_MCR2_DONE;
+#ifdef UBSEC_RNDTEST
+ sc->sc_rndtest = rndtest_attach(dev);
+ if (sc->sc_rndtest)
+ sc->sc_harvest = rndtest_harvest;
+ else
+ sc->sc_harvest = default_harvest;
+#else
+ sc->sc_harvest = default_harvest;
+#endif
if (ubsec_dma_malloc(sc, sizeof(struct ubsec_mcr),
&sc->sc_rng.rng_q.q_mcr, 0))
@@ -477,6 +498,11 @@ ubsec_detach(device_t dev)
crypto_unregister_all(sc->sc_cid);
+#ifdef UBSEC_RNDTEST
+ if (sc->sc_rndtest)
+ rndtest_detach(sc->sc_rndtest);
+#endif
+
while (!SIMPLEQ_EMPTY(&sc->sc_freequeue)) {
struct ubsec_q *q;
@@ -1652,10 +1678,9 @@ ubsec_callback2(struct ubsec_softc *sc, struct ubsec_q2 *q)
struct ubsec_q2_rng *rng = (struct ubsec_q2_rng *)q;
ubsec_dma_sync(&rng->rng_buf, BUS_DMASYNC_POSTREAD);
- random_harvest(rng->rng_buf.dma_vaddr,
- UBSEC_RNG_BUFSIZ*sizeof (u_int32_t),
- UBSEC_RNG_BUFSIZ*sizeof (u_int32_t)*NBBY, 0,
- RANDOM_PURE);
+ (*sc->sc_harvest)(sc->sc_rndtest,
+ rng->rng_buf.dma_vaddr,
+ UBSEC_RNG_BUFSIZ*sizeof (u_int32_t));
rng->rng_used = 0;
callout_reset(&sc->sc_rngto, sc->sc_rnghz, ubsec_rng, sc);
break;
OpenPOWER on IntegriCloud