Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/ec4c5259d0ce
branches:  trunk
changeset: 980830:ec4c5259d0ce
user:      rin <rin%NetBSD.org@localhost>
date:      Sat Feb 20 09:36:30 2021 +0000

description:
sn(4): Add rnd(9) support.

diffstat:

 sys/arch/arc/jazz/if_sn_jazzio.c    |   6 ++++--
 sys/arch/mac68k/nubus/if_sn_nubus.c |   6 ++++--
 sys/arch/mac68k/obio/if_sn_obio.c   |   6 ++++--
 sys/dev/ic/dp83932.c                |  28 ++++++++++++++++++++++------
 sys/dev/ic/dp83932var.h             |   4 +++-
 5 files changed, 37 insertions(+), 13 deletions(-)

diffs (197 lines):

diff -r f348aed03957 -r ec4c5259d0ce sys/arch/arc/jazz/if_sn_jazzio.c
--- a/sys/arch/arc/jazz/if_sn_jazzio.c  Sat Feb 20 09:31:51 2021 +0000
+++ b/sys/arch/arc/jazz/if_sn_jazzio.c  Sat Feb 20 09:36:30 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_sn_jazzio.c,v 1.13 2011/07/01 19:25:41 dyoung Exp $ */
+/*     $NetBSD: if_sn_jazzio.c,v 1.14 2021/02/20 09:36:30 rin Exp $    */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sn_jazzio.c,v 1.13 2011/07/01 19:25:41 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sn_jazzio.c,v 1.14 2021/02/20 09:36:30 rin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -48,6 +48,8 @@
 #include <sys/device.h>
 #include <sys/kcore.h>
 
+#include <sys/rndsource.h>
+
 #include <net/if.h>
 #include <net/if_dl.h>
 #include <net/if_ether.h>
diff -r f348aed03957 -r ec4c5259d0ce sys/arch/mac68k/nubus/if_sn_nubus.c
--- a/sys/arch/mac68k/nubus/if_sn_nubus.c       Sat Feb 20 09:31:51 2021 +0000
+++ b/sys/arch/mac68k/nubus/if_sn_nubus.c       Sat Feb 20 09:36:30 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_sn_nubus.c,v 1.29 2008/04/23 13:29:45 tsutsui Exp $ */
+/*     $NetBSD: if_sn_nubus.c,v 1.30 2021/02/20 09:36:30 rin Exp $     */
 
 /*
  * Copyright (C) 1997 Allen Briggs
@@ -31,13 +31,15 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sn_nubus.c,v 1.29 2008/04/23 13:29:45 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sn_nubus.c,v 1.30 2021/02/20 09:36:30 rin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
 #include <sys/ioctl.h>
 
+#include <sys/rndsource.h>
+
 #include <net/if.h>
 #include <net/if_ether.h>
 
diff -r f348aed03957 -r ec4c5259d0ce sys/arch/mac68k/obio/if_sn_obio.c
--- a/sys/arch/mac68k/obio/if_sn_obio.c Sat Feb 20 09:31:51 2021 +0000
+++ b/sys/arch/mac68k/obio/if_sn_obio.c Sat Feb 20 09:36:30 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_sn_obio.c,v 1.28 2008/04/23 13:29:45 tsutsui Exp $  */
+/*     $NetBSD: if_sn_obio.c,v 1.29 2021/02/20 09:36:30 rin Exp $      */
 
 /*
  * Copyright (C) 1997 Allen Briggs
@@ -31,13 +31,15 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sn_obio.c,v 1.28 2008/04/23 13:29:45 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sn_obio.c,v 1.29 2021/02/20 09:36:30 rin Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
 #include <sys/systm.h>
 #include <sys/ioctl.h>
 
+#include <sys/rndsource.h>
+
 #include <net/if.h>
 #include <net/if_ether.h>
 
diff -r f348aed03957 -r ec4c5259d0ce sys/dev/ic/dp83932.c
--- a/sys/dev/ic/dp83932.c      Sat Feb 20 09:31:51 2021 +0000
+++ b/sys/dev/ic/dp83932.c      Sat Feb 20 09:36:30 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dp83932.c,v 1.46 2020/03/15 22:19:00 thorpej Exp $     */
+/*     $NetBSD: dp83932.c,v 1.47 2021/02/20 09:36:31 rin Exp $ */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dp83932.c,v 1.46 2020/03/15 22:19:00 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dp83932.c,v 1.47 2021/02/20 09:36:31 rin Exp $");
 
 
 #include <sys/param.h>
@@ -48,6 +48,8 @@
 #include <sys/errno.h>
 #include <sys/device.h>
 
+#include <sys/rndsource.h>
+
 #include <net/if.h>
 #include <net/if_dl.h>
 #include <net/if_ether.h>
@@ -215,6 +217,9 @@
        if_deferred_start_init(ifp, NULL);
        ether_ifattach(ifp, enaddr);
 
+       rnd_attach_source(&sc->sc_rndsource, ifp->if_xname, RND_TYPE_NET,
+           RND_FLAG_DEFAULT);
+
        /*
         * Make sure the interface is shutdown during reboot.
         */
@@ -627,8 +632,9 @@
        struct sonic_tda32 *tda32;
        struct sonic_tda16 *tda16;
        uint16_t status, totstat = 0;
-       int i;
+       int i, count;
 
+       count = 0;
        for (i = sc->sc_txdirty; sc->sc_txpending != 0;
             i = SONIC_NEXTTX(i), sc->sc_txpending--) {
                ds = &sc->sc_txsoft[i];
@@ -662,9 +668,10 @@
                 * Check for errors and collisions.
                 */
                net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
-               if (status & TCR_PTX)
+               if (status & TCR_PTX) {
                        if_statinc_ref(nsr, if_opackets);
-               else
+                       count++;
+               } else
                        if_statinc_ref(nsr, if_oerrors);
                if (TDA_STATUS_NCOL(status))
                        if_statadd_ref(nsr, if_collisions,
@@ -682,6 +689,9 @@
        if (sc->sc_txpending == 0)
                ifp->if_timer = 0;
 
+       if (count != 0)
+               rnd_add_uint32(&sc->sc_rndsource, count);
+
        return totstat;
 }
 
@@ -698,9 +708,10 @@
        struct sonic_rda32 *rda32;
        struct sonic_rda16 *rda16;
        struct mbuf *m;
-       int i, len;
+       int i, len, count;
        uint16_t status, bytecount /*, ptr0, ptr1, seqno */;
 
+       count = 0;
        for (i = sc->sc_rxptr;; i = SONIC_NEXTRX(i)) {
                ds = &sc->sc_rxsoft[i];
 
@@ -838,11 +849,16 @@
 
                /* Pass it on. */
                if_percpuq_enqueue(ifp->if_percpuq, m);
+
+               count++;
        }
 
        /* Update the receive pointer. */
        sc->sc_rxptr = i;
        CSR_WRITE(sc, SONIC_RWR, SONIC_CDRRADDR(sc, SONIC_PREVRX(i)));
+
+       if (count != 0)
+               rnd_add_uint32(&sc->sc_rndsource, count);
 }
 
 /*
diff -r f348aed03957 -r ec4c5259d0ce sys/dev/ic/dp83932var.h
--- a/sys/dev/ic/dp83932var.h   Sat Feb 20 09:31:51 2021 +0000
+++ b/sys/dev/ic/dp83932var.h   Sat Feb 20 09:36:30 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dp83932var.h,v 1.12 2009/09/01 15:20:53 tsutsui Exp $  */
+/*     $NetBSD: dp83932var.h,v 1.13 2021/02/20 09:36:31 rin Exp $      */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -200,6 +200,8 @@
        uint16_t sc_imr;                /* prototype IMR */
        uint16_t sc_dcr;                /* prototype DCR */
        uint16_t sc_dcr2;               /* prototype DCR2 */
+
+       krndsource_t sc_rndsource;      /* random source */
 };
 
 #define        CSR_READ(sc, reg)                                               \



Home | Main Index | Thread Index | Old Index