summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormlelstv <mlelstv@NetBSD.org>2008-06-17 06:08:46 +0000
committermlelstv <mlelstv@NetBSD.org>2008-06-17 06:08:46 +0000
commit2f1d68867cd6c59a2a92c80e2f8a606629b73d8d (patch)
tree9b3d2beb1551dd1dccaada57db5143e5754f0024 /sys/dev
parentf1f0ceb1ae2451497c373db47f66f8ceea61fb4e (diff)
add rnd(4) hooks. Note that interrupts on bge hardware may occur
with certain patterns, especially when the interrupt mitigation logic kicks in. So this might be a very weak entropy source.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/if_bge.c23
-rw-r--r--sys/dev/pci/if_bgereg.h6
2 files changed, 26 insertions, 3 deletions
diff --git a/sys/dev/pci/if_bge.c b/sys/dev/pci/if_bge.c
index fb42167e738..abe82d0f1ea 100644
--- a/sys/dev/pci/if_bge.c
+++ b/sys/dev/pci/if_bge.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bge.c,v 1.147 2008/06/17 06:04:07 mlelstv Exp $ */
+/* $NetBSD: if_bge.c,v 1.148 2008/06/17 06:08:46 mlelstv Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
@@ -79,10 +79,11 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.147 2008/06/17 06:04:07 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.148 2008/06/17 06:08:46 mlelstv Exp $");
#include "bpfilter.h"
#include "vlan.h"
+#include "rnd.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -100,6 +101,10 @@ __KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.147 2008/06/17 06:04:07 mlelstv Exp $")
#include <net/if_media.h>
#include <net/if_ether.h>
+#if NRND > 0
+#include <sys/rnd.h>
+#endif
+
#ifdef INET
#include <netinet/in.h>
#include <netinet/in_systm.h>
@@ -2745,6 +2750,10 @@ bge_attach(device_t parent, device_t self, void *aux)
if_attach(ifp);
DPRINTFN(5, ("ether_ifattach\n"));
ether_ifattach(ifp, eaddr);
+#if NRND > 0
+ rnd_attach_source(&sc->rnd_source, device_xname(sc->bge_dev),
+ RND_TYPE_NET, 0);
+#endif
#ifdef BGE_EVENT_COUNTERS
/*
* Attach event counters.
@@ -2971,6 +2980,11 @@ bge_rxeof(struct bge_softc *sc)
tosync = sc->bge_rdata->bge_status_block.bge_idx[0].bge_rx_prod_idx -
sc->bge_rx_saved_considx;
+#if NRND > 0
+ if (tosync != 0 && RND_ENABLED(&sc->rnd_source))
+ rnd_add_uint32(&sc->rnd_source, tosync);
+#endif
+
toff = offset + (sc->bge_rx_saved_considx * sizeof (struct bge_rx_bd));
if (tosync < 0) {
@@ -3124,6 +3138,11 @@ bge_txeof(struct bge_softc *sc)
tosync = sc->bge_rdata->bge_status_block.bge_idx[0].bge_tx_cons_idx -
sc->bge_tx_saved_considx;
+#if NRND > 0
+ if (tosync != 0 && RND_ENABLED(&sc->rnd_source))
+ rnd_add_uint32(&sc->rnd_source, tosync);
+#endif
+
toff = offset + (sc->bge_tx_saved_considx * sizeof (struct bge_tx_bd));
if (tosync < 0) {
diff --git a/sys/dev/pci/if_bgereg.h b/sys/dev/pci/if_bgereg.h
index edc459bcbc1..b2c08500bf4 100644
--- a/sys/dev/pci/if_bgereg.h
+++ b/sys/dev/pci/if_bgereg.h
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bgereg.h,v 1.45 2007/12/09 20:28:08 jmcneill Exp $ */
+/* $NetBSD: if_bgereg.h,v 1.46 2008/06/17 06:12:10 mlelstv Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
* Copyright (c) 1997, 1998, 1999, 2001
@@ -2439,4 +2439,8 @@ struct bge_softc {
int bge_pending_rxintr_change;
SLIST_HEAD(, txdmamap_pool_entry) txdma_list;
struct txdmamap_pool_entry *txdma[BGE_TX_RING_CNT];
+
+#if NRND > 0
+ rndsource_element_t rnd_source; /* random source */
+#endif
};