Subject: kern/28556: add rnd hooks to tl driver
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <dive@endersgame.net>
List: netbsd-bugs
Date: 12/05/2004 22:18:00
>Number: 28556
>Category: kern
>Synopsis: Add support for tl(4) to be used by the rnd subsystem
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sun Dec 05 22:18:00 +0000 2004
>Originator: dive@endersgame.net
>Release: NetBSD 2.99.10
>Organization:
Paper Voices, Inc.
>Environment:
System: NetBSD jane.endersgame.net 2.99.10 NetBSD 2.99.10 (JANE) #21: Thu Dec 2 22:54:08 EST 2004 dive@jane.endersgame.net:/sys/arch/i386/compile/JANE i386
Architecture: i386
Machine: i386
>Description:
No problem; simply a patch to let rtk(4) be used by rnd(4).
>How-To-Repeat:
N/A
>Fix:
Index: if_tl.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_tl.c,v
retrieving revision 1.66
diff -u -r1.66 if_tl.c
--- if_tl.c 30 Oct 2004 18:09:22 -0000 1.66
+++ if_tl.c 5 Dec 2004 22:11:07 -0000
@@ -74,6 +74,11 @@
#include <net/bpfdesc.h>
#endif
+#include "rnd.h"
+#if NRND > 0
+#include <sys/rnd.h>
+#endif
+
#ifdef INET
#include <netinet/in.h>
#include <netinet/in_systm.h>
@@ -482,6 +487,11 @@
IFQ_SET_READY(&ifp->if_snd);
if_attach(ifp);
ether_ifattach(&(sc)->tl_if, (sc)->tl_enaddr);
+
+#if NRND > 0
+ rnd_attach_source(&sc->rnd_source, sc->sc_dev.dv_xname,
+ RND_TYPE_NET, 0);
+#endif
}
static void
@@ -1226,6 +1236,12 @@
HOST_CMD_IntOn);
return 1;
}
+
+#if NRND > 0
+ if (RND_ENABLED(&sc->rnd_source))
+ rnd_add_uint32(&sc->rnd_source, int_reg);
+#endif
+
/* ack = 0 ; interrupt was perhaps not our. Just enable interrupts */
TL_HR_WRITE(sc, TL_HOST_CMD, HOST_CMD_IntOn);
return 0;
Index: if_tlvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_tlvar.h,v
retrieving revision 1.10
diff -u -r1.10 if_tlvar.h
--- if_tlvar.h 10 Nov 2003 08:51:52 -0000 1.10
+++ if_tlvar.h 5 Dec 2004 22:11:07 -0000
@@ -35,6 +35,12 @@
* available from www.ti.com
*/
+#include "rnd.h"
+
+#if NRND > 0
+#include <sys/rnd.h>
+#endif
+
#include <dev/i2c/i2cvar.h>
struct tl_product_desc {
@@ -83,6 +89,10 @@
int oerr_carrloss;
int oerr_mcopy;
#endif
+
+#if NRND > 0
+ rndsource_element_t rnd_source;
+#endif
};
#define tl_if tl_ec.ec_if
#define tl_bpf tl_if.if_bpf