Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev genet(4): Add support for rnd(9).



details:   https://anonhg.NetBSD.org/src/rev/5628fb994dcb
branches:  trunk
changeset: 983107:5628fb994dcb
user:      rin <rin%NetBSD.org@localhost>
date:      Mon May 03 10:28:26 2021 +0000

description:
genet(4): Add support for rnd(9).

diffstat:

 sys/dev/acpi/genet_acpi.c |   6 ++++--
 sys/dev/fdt/genet_fdt.c   |   6 ++++--
 sys/dev/ic/bcmgenet.c     |  17 +++++++++++++++--
 sys/dev/ic/bcmgenetvar.h  |   4 +++-
 4 files changed, 26 insertions(+), 7 deletions(-)

diffs (144 lines):

diff -r 14b1a2cf7332 -r 5628fb994dcb sys/dev/acpi/genet_acpi.c
--- a/sys/dev/acpi/genet_acpi.c Mon May 03 10:25:14 2021 +0000
+++ b/sys/dev/acpi/genet_acpi.c Mon May 03 10:28:26 2021 +0000
@@ -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@localhost>
@@ -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 -r 14b1a2cf7332 -r 5628fb994dcb sys/dev/fdt/genet_fdt.c
--- a/sys/dev/fdt/genet_fdt.c   Mon May 03 10:25:14 2021 +0000
+++ b/sys/dev/fdt/genet_fdt.c   Mon May 03 10:28:26 2021 +0000
@@ -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@localhost>
@@ -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 @@
 #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 -r 14b1a2cf7332 -r 5628fb994dcb sys/dev/ic/bcmgenet.c
--- a/sys/dev/ic/bcmgenet.c     Mon May 03 10:25:14 2021 +0000
+++ b/sys/dev/ic/bcmgenet.c     Mon May 03 10:28:26 2021 +0000
@@ -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@localhost>
@@ -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 @@
 #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 @@
        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 @@
                m_adj(m, ETHER_ALIGN);
 
                if_percpuq_enqueue(ifp->if_percpuq, m);
+               ++pkts;
 
 next:
                index = RX_NEXT(index);
@@ -756,6 +760,9 @@
                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 @@
        }
 
        if_statadd(ifp, if_opackets, pkts);
+
+       if (pkts != 0)
+               rnd_add_uint32(&sc->sc_rndsource, pkts);
 }
 
 static void
@@ -1100,6 +1110,9 @@
        /* 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 -r 14b1a2cf7332 -r 5628fb994dcb sys/dev/ic/bcmgenetvar.h
--- a/sys/dev/ic/bcmgenetvar.h  Mon May 03 10:25:14 2021 +0000
+++ b/sys/dev/ic/bcmgenetvar.h  Mon May 03 10:28:26 2021 +0000
@@ -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@localhost>
@@ -70,6 +70,8 @@
 
        struct genet_ring       sc_tx;
        struct genet_ring       sc_rx;
+
+       krndsource_t            sc_rndsource;
 };
 
 int    genet_attach(struct genet_softc *);



Home | Main Index | Thread Index | Old Index