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)
This commit is contained in:
parent
2ca9461a05
commit
b7c4858f1e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=112124
@ -2152,10 +2152,16 @@ device fwe # Ethernet over Firewire (non-standard!)
|
||||
device crypto # core crypto support
|
||||
device cryptodev # /dev/crypto for access to h/w
|
||||
|
||||
device hifn # Hifn 7951, 7781, etc.
|
||||
device ubsec # Broadcom 5501, 5601, 58xx
|
||||
device rndtest # FIPS 140-2 entropy tester
|
||||
|
||||
device hifn # Hifn 7951, 7781, etc.
|
||||
options HIFN_DEBUG # enable debugging support: hw.hifn.debug
|
||||
options HIFN_RNDTEST # enable rndtest support
|
||||
|
||||
device ubsec # Broadcom 5501, 5601, 58xx
|
||||
options UBSEC_DEBUG # enable debugging support: hw.ubsec.debug
|
||||
options UBSEC_RNDTEST # enable rndtest support
|
||||
|
||||
#####################################################################
|
||||
|
||||
|
||||
|
@ -602,3 +602,10 @@ DEVICE_POLLING opt_global.h
|
||||
# Mutex profiling
|
||||
MUTEX_PROFILING opt_global.h
|
||||
|
||||
# options for ubsec driver
|
||||
UBSEC_DEBUG opt_ubsec.h
|
||||
UBSEC_RNDTEST opt_ubsec.h
|
||||
|
||||
# options for hifn driver
|
||||
HIFN_DEBUG opt_hifn.h
|
||||
HIFN_RNDTEST opt_hifn.h
|
||||
|
@ -41,11 +41,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#define HIFN_DEBUG
|
||||
|
||||
/*
|
||||
* Driver for the Hifn 7751 encryption processor.
|
||||
*/
|
||||
#include "opt_hifn.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -72,6 +71,10 @@
|
||||
|
||||
#include <pci/pcivar.h>
|
||||
#include <pci/pcireg.h>
|
||||
|
||||
#ifdef HIFN_RNDTEST
|
||||
#include <dev/rndtest/rndtest.h>
|
||||
#endif
|
||||
#include <dev/hifn/hifn7751reg.h>
|
||||
#include <dev/hifn/hifn7751var.h>
|
||||
|
||||
@ -109,6 +112,9 @@ static devclass_t hifn_devclass;
|
||||
|
||||
DRIVER_MODULE(hifn, pci, hifn_driver, hifn_devclass, 0, 0);
|
||||
MODULE_DEPEND(hifn, crypto, 1, 1, 1);
|
||||
#ifdef HIFN_RNDTEST
|
||||
MODULE_DEPEND(hifn, rndtest, 1, 1, 1);
|
||||
#endif
|
||||
|
||||
static void hifn_reset_board(struct hifn_softc *, int);
|
||||
static void hifn_reset_puc(struct hifn_softc *);
|
||||
@ -230,6 +236,12 @@ hifn_partname(struct hifn_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);
|
||||
}
|
||||
|
||||
/*
|
||||
* Attach an interface that successfully probed.
|
||||
*/
|
||||
@ -621,6 +633,15 @@ hifn_init_pubrng(struct hifn_softc *sc)
|
||||
u_int32_t r;
|
||||
int i;
|
||||
|
||||
#ifdef HIFN_RNDTEST
|
||||
sc->sc_rndtest = rndtest_attach(sc->sc_dev);
|
||||
if (sc->sc_rndtest)
|
||||
sc->sc_harvest = rndtest_harvest;
|
||||
else
|
||||
sc->sc_harvest = default_harvest;
|
||||
#else
|
||||
sc->sc_harvest = default_harvest;
|
||||
#endif
|
||||
if ((sc->sc_flags & HIFN_IS_7811) == 0) {
|
||||
/* Reset 7951 public key/rng engine */
|
||||
WRITE_REG_1(sc, HIFN_1_PUB_RESET,
|
||||
@ -705,7 +726,8 @@ hifn_rng(void *vsc)
|
||||
if (sc->sc_rngfirst)
|
||||
sc->sc_rngfirst = 0;
|
||||
else
|
||||
random_harvest(num, RANDOM_BITS(2), RANDOM_PURE);
|
||||
(*sc->sc_harvest)(sc->sc_rndtest,
|
||||
num, sizeof (num));
|
||||
}
|
||||
} else {
|
||||
num[0] = READ_REG_1(sc, HIFN_1_RNG_DATA);
|
||||
@ -714,7 +736,8 @@ hifn_rng(void *vsc)
|
||||
if (sc->sc_rngfirst)
|
||||
sc->sc_rngfirst = 0;
|
||||
else
|
||||
random_harvest(num, RANDOM_BITS(1), RANDOM_PURE);
|
||||
(*sc->sc_harvest)(sc->sc_rndtest,
|
||||
num, sizeof (num[0]));
|
||||
}
|
||||
|
||||
callout_reset(&sc->sc_rngto, sc->sc_rnghz, hifn_rng, sc);
|
||||
|
@ -133,6 +133,8 @@ struct hifn_session {
|
||||
#define HS_STATE_USED 1 /* allocated, but key not on card */
|
||||
#define HS_STATE_KEY 2 /* allocated and key is on card */
|
||||
|
||||
struct rndstate_test;
|
||||
|
||||
/*
|
||||
* Holds data specific to a single HIFN board.
|
||||
*/
|
||||
@ -171,6 +173,9 @@ struct hifn_softc {
|
||||
struct callout sc_tickto; /* for managing DMA */
|
||||
int sc_rngfirst;
|
||||
int sc_rnghz; /* RNG polling frequency */
|
||||
struct rndtest_state *sc_rndtest; /* RNG test state */
|
||||
void (*sc_harvest)(struct rndtest_state *,
|
||||
void *, u_int);
|
||||
int sc_c_busy; /* command ring busy */
|
||||
int sc_s_busy; /* source data ring busy */
|
||||
int sc_d_busy; /* destination data ring busy */
|
||||
|
@ -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;
|
||||
|
@ -174,6 +174,8 @@ struct ubsec_q {
|
||||
#define q_dst_segs q_dst.segs
|
||||
#define q_dst_mapsize q_dst.mapsize
|
||||
|
||||
struct rndstate_test;
|
||||
|
||||
struct ubsec_softc {
|
||||
device_t sc_dev; /* device backpointer */
|
||||
struct mtx sc_mtx; /* per-driver lock */
|
||||
@ -201,6 +203,9 @@ struct ubsec_softc {
|
||||
struct callout sc_rngto; /* rng timeout */
|
||||
int sc_rnghz; /* rng poll time */
|
||||
struct ubsec_q2_rng sc_rng;
|
||||
struct rndtest_state *sc_rndtest; /* RNG test state */
|
||||
void (*sc_harvest)(struct rndtest_state *,
|
||||
void *, u_int);
|
||||
struct ubsec_dma sc_dmaa[UBS_MAX_NQUEUE];
|
||||
struct ubsec_q *sc_queuea[UBS_MAX_NQUEUE];
|
||||
SIMPLEQ_HEAD(,ubsec_q2) sc_q2free; /* free list */
|
||||
|
Loading…
Reference in New Issue
Block a user