summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorrin <rin@NetBSD.org>2021-05-03 10:28:26 +0000
committerrin <rin@NetBSD.org>2021-05-03 10:28:26 +0000
commit96d706cdfc89ba3f683bd73fbebc274e5eaeb9a5 (patch)
treef65acd1f3c16d74212324e038f220dfe1a3bb181 /sys
parent8106509aa9343d0b490a148cef3eed8e0a3568e3 (diff)
genet(4): Add support for rnd(9).
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/acpi/genet_acpi.c6
-rw-r--r--sys/dev/fdt/genet_fdt.c6
-rw-r--r--sys/dev/ic/bcmgenet.c17
-rw-r--r--sys/dev/ic/bcmgenetvar.h4
4 files changed, 26 insertions, 7 deletions
diff --git a/sys/dev/acpi/genet_acpi.c b/sys/dev/acpi/genet_acpi.c
index 67439f64da8..131c5026dbd 100644
--- a/sys/dev/acpi/genet_acpi.c
+++ b/sys/dev/acpi/genet_acpi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: genet_acpi.c,v 1.4 2021/01/29 15:49:55 thorpej Exp $ */
+/* $NetBSD: genet_acpi.c,v 1.5 2021/05/03 10:28:26 rin Exp $ */
/*-
* Copyright (c) 2020 Jared McNeill <jmcneill@invisible.ca>
@@ -29,13 +29,15 @@
#include "opt_net_mpsafe.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genet_acpi.c,v 1.4 2021/01/29 15:49:55 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genet_acpi.c,v 1.5 2021/05/03 10:28:26 rin Exp $");
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/cpu.h>
#include <sys/device.h>
+#include <sys/rndsource.h>
+
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_ether.h>
diff --git a/sys/dev/fdt/genet_fdt.c b/sys/dev/fdt/genet_fdt.c
index eaf0f38bc4d..78e0adc4080 100644
--- a/sys/dev/fdt/genet_fdt.c
+++ b/sys/dev/fdt/genet_fdt.c
@@ -1,4 +1,4 @@
-/* $NetBSD: genet_fdt.c,v 1.5 2021/03/08 13:15:06 mlelstv Exp $ */
+/* $NetBSD: genet_fdt.c,v 1.6 2021/05/03 10:28:26 rin Exp $ */
/*-
* Copyright (c) 2020 Jared McNeill <jmcneill@invisible.ca>
@@ -29,7 +29,7 @@
#include "opt_net_mpsafe.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genet_fdt.c,v 1.5 2021/03/08 13:15:06 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genet_fdt.c,v 1.6 2021/05/03 10:28:26 rin Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -38,6 +38,8 @@ __KERNEL_RCSID(0, "$NetBSD: genet_fdt.c,v 1.5 2021/03/08 13:15:06 mlelstv Exp $"
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/rndsource.h>
+
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_ether.h>
diff --git a/sys/dev/ic/bcmgenet.c b/sys/dev/ic/bcmgenet.c
index 2fb1c4954c1..9f2cc098754 100644
--- a/sys/dev/ic/bcmgenet.c
+++ b/sys/dev/ic/bcmgenet.c
@@ -1,4 +1,4 @@
-/* $NetBSD: bcmgenet.c,v 1.8 2021/03/08 13:14:44 mlelstv Exp $ */
+/* $NetBSD: bcmgenet.c,v 1.9 2021/05/03 10:28:26 rin Exp $ */
/*-
* Copyright (c) 2020 Jared McNeill <jmcneill@invisible.ca>
@@ -34,7 +34,7 @@
#include "opt_ddb.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.8 2021/03/08 13:14:44 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.9 2021/05/03 10:28:26 rin Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -46,6 +46,8 @@ __KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.8 2021/03/08 13:14:44 mlelstv Exp $")
#include <sys/callout.h>
#include <sys/cprng.h>
+#include <sys/rndsource.h>
+
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_ether.h>
@@ -681,6 +683,7 @@ genet_rxintr(struct genet_softc *sc, int qid)
int error, index, len, n;
struct mbuf *m, *m0;
uint32_t status, pidx, total;
+ int pkts = 0;
pidx = RD4(sc, GENET_RX_DMA_PROD_INDEX(qid)) & 0xffff;
total = (pidx - sc->sc_rx.cidx) & 0xffff;
@@ -749,6 +752,7 @@ genet_rxintr(struct genet_softc *sc, int qid)
m_adj(m, ETHER_ALIGN);
if_percpuq_enqueue(ifp->if_percpuq, m);
+ ++pkts;
next:
index = RX_NEXT(index);
@@ -756,6 +760,9 @@ next:
sc->sc_rx.cidx = (sc->sc_rx.cidx + 1) & 0xffff;
WR4(sc, GENET_RX_DMA_CONS_INDEX(qid), sc->sc_rx.cidx);
}
+
+ if (pkts != 0)
+ rnd_add_uint32(&sc->sc_rndsource, pkts);
}
static void
@@ -785,6 +792,9 @@ genet_txintr(struct genet_softc *sc, int qid)
}
if_statadd(ifp, if_opackets, pkts);
+
+ if (pkts != 0)
+ rnd_add_uint32(&sc->sc_rndsource, pkts);
}
static void
@@ -1100,6 +1110,9 @@ genet_attach(struct genet_softc *sc)
/* Attach ethernet interface */
ether_ifattach(ifp, eaddr);
+ rnd_attach_source(&sc->sc_rndsource, ifp->if_xname, RND_TYPE_NET,
+ RND_FLAG_DEFAULT);
+
return 0;
}
diff --git a/sys/dev/ic/bcmgenetvar.h b/sys/dev/ic/bcmgenetvar.h
index bb677581e3a..f22ec16eaef 100644
--- a/sys/dev/ic/bcmgenetvar.h
+++ b/sys/dev/ic/bcmgenetvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: bcmgenetvar.h,v 1.3 2021/03/08 13:14:44 mlelstv Exp $ */
+/* $NetBSD: bcmgenetvar.h,v 1.4 2021/05/03 10:28:26 rin Exp $ */
/*-
* Copyright (c) 2020 Jared McNeill <jmcneill@invisible.ca>
@@ -70,6 +70,8 @@ struct genet_softc {
struct genet_ring sc_tx;
struct genet_ring sc_rx;
+
+ krndsource_t sc_rndsource;
};
int genet_attach(struct genet_softc *);