Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Add rnd(9) support.



details:   https://anonhg.NetBSD.org/src/rev/6f74058446f6
branches:  trunk
changeset: 950278:6f74058446f6
user:      rin <rin%NetBSD.org@localhost>
date:      Sun Jan 24 05:16:56 2021 +0000

description:
Add rnd(9) support.

diffstat:

 sys/arch/mac68k/dev/if_mc.c           |  13 +++++++++++--
 sys/arch/mac68k/dev/if_mcvar.h        |   4 +++-
 sys/arch/mac68k/obio/if_mc_obio.c     |   6 ++++--
 sys/arch/powerpc/booke/dev/pq3etsec.c |  17 +++++++++++++++--
 sys/arch/powerpc/ibm4xx/dev/if_emac.c |  27 +++++++++++++++++++++++----
 5 files changed, 56 insertions(+), 11 deletions(-)

diffs (278 lines):

diff -r 9044616d6ff3 -r 6f74058446f6 sys/arch/mac68k/dev/if_mc.c
--- a/sys/arch/mac68k/dev/if_mc.c       Sun Jan 24 05:14:55 2021 +0000
+++ b/sys/arch/mac68k/dev/if_mc.c       Sun Jan 24 05:16:56 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_mc.c,v 1.56 2020/10/20 18:17:58 roy Exp $   */
+/*     $NetBSD: if_mc.c,v 1.57 2021/01/24 05:20:23 rin Exp $   */
 
 /*-
  * Copyright (c) 1997 David Huang <khym%azeotrope.org@localhost>
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.56 2020/10/20 18:17:58 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.57 2021/01/24 05:20:23 rin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -51,6 +51,8 @@
 #include <sys/errno.h>
 #include <sys/device.h>
 
+#include <sys/rndsource.h>
+
 #include <uvm/uvm_extern.h>
 
 #include <net/if.h>
@@ -158,6 +160,9 @@
        if_deferred_start_init(ifp, NULL);
        ether_ifattach(ifp, lladdr);
 
+       rnd_attach_source(&sc->rnd_source, ifp->if_xname, RND_TYPE_NET,
+           RND_FLAG_DEFAULT);
+
        return 0;
 }
 
@@ -516,6 +521,8 @@
        sc->sc_if.if_flags &= ~IFF_OACTIVE;
        sc->sc_if.if_timer = 0;
        if_schedule_deferred_start(&sc->sc_if);
+
+       rnd_add_uint32(&sc->rnd_source, xmtfs);
 }
 
 void
@@ -559,6 +566,8 @@
        }
 
        mace_read(sc, rxf.rx_frame, len);
+
+       rnd_add_uint32(&sc->rnd_source, rxf.rx_rcvsts);
 #undef rxf
 }
 
diff -r 9044616d6ff3 -r 6f74058446f6 sys/arch/mac68k/dev/if_mcvar.h
--- a/sys/arch/mac68k/dev/if_mcvar.h    Sun Jan 24 05:14:55 2021 +0000
+++ b/sys/arch/mac68k/dev/if_mcvar.h    Sun Jan 24 05:16:56 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_mcvar.h,v 1.16 2012/10/27 17:17:59 chs Exp $        */
+/*     $NetBSD: if_mcvar.h,v 1.17 2021/01/24 05:20:23 rin Exp $        */
 
 /*-
  * Copyright (c) 1997 David Huang <khym%azeotrope.org@localhost>
@@ -87,6 +87,8 @@
        int             sc_tail;
        int             sc_rxset;
        int             sc_txset, sc_txseti;
+
+       krndsource_t rnd_source;
 };
 
 int    mcsetup(struct mc_softc *, u_int8_t *);
diff -r 9044616d6ff3 -r 6f74058446f6 sys/arch/mac68k/obio/if_mc_obio.c
--- a/sys/arch/mac68k/obio/if_mc_obio.c Sun Jan 24 05:14:55 2021 +0000
+++ b/sys/arch/mac68k/obio/if_mc_obio.c Sun Jan 24 05:16:56 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_mc_obio.c,v 1.18 2012/10/27 17:18:00 chs Exp $      */
+/*     $NetBSD: if_mc_obio.c,v 1.19 2021/01/24 05:20:23 rin Exp $      */
 
 /*-
  * Copyright (c) 1997 David Huang <khym%azeotrope.org@localhost>
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mc_obio.c,v 1.18 2012/10/27 17:18:00 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mc_obio.c,v 1.19 2021/01/24 05:20:23 rin Exp $");
 
 #include "opt_ddb.h"
 
@@ -46,6 +46,8 @@
 #include <sys/socket.h>
 #include <sys/systm.h>
 
+#include <sys/rndsource.h>
+
 #include <net/if.h>
 #include <net/if_ether.h>
 
diff -r 9044616d6ff3 -r 6f74058446f6 sys/arch/powerpc/booke/dev/pq3etsec.c
--- a/sys/arch/powerpc/booke/dev/pq3etsec.c     Sun Jan 24 05:14:55 2021 +0000
+++ b/sys/arch/powerpc/booke/dev/pq3etsec.c     Sun Jan 24 05:16:56 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pq3etsec.c,v 1.51 2021/01/24 05:14:55 rin Exp $        */
+/*     $NetBSD: pq3etsec.c,v 1.52 2021/01/24 05:16:56 rin Exp $        */
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.51 2021/01/24 05:14:55 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.52 2021/01/24 05:16:56 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -58,6 +58,8 @@
 #include <sys/callout.h>
 #include <sys/sysctl.h>
 
+#include <sys/rndsource.h>
+
 #include <net/if.h>
 #include <net/if_dl.h>
 #include <net/if_ether.h>
@@ -237,6 +239,8 @@
        int sc_ic_rx_count;
        int sc_ic_tx_time;
        int sc_ic_tx_count;
+
+       krndsource_t rnd_source;
 };
 
 #define        ETSEC_IC_RX_ENABLED(sc)                                         \
@@ -808,6 +812,9 @@
        if_deferred_start_init(ifp, NULL);
        ether_ifattach(ifp, enaddr);
 
+       rnd_attach_source(&sc->rnd_source, xname, RND_TYPE_NET,
+           RND_FLAG_DEFAULT);
+
        pq3etsec_ifstop(ifp, true);
 
        evcnt_attach_dynamic(&sc->sc_ev_rx_stall, EVCNT_TYPE_MISC,
@@ -1714,6 +1721,9 @@
                KASSERT(rxq->rxq_mbufs[consumer - rxq->rxq_first] == rxq->rxq_mconsumer);
 #endif
        }
+
+       if (rxconsumed != 0)
+               rnd_add_uint32(&sc->rnd_source, rxconsumed);
 }
 
 static void
@@ -2261,6 +2271,9 @@
                        KASSERT(consumer < txq->txq_last);
                }
        }
+
+       if (txfree != 0)
+               rnd_add_uint32(&sc->rnd_source, txfree);
 }
 
 static void
diff -r 9044616d6ff3 -r 6f74058446f6 sys/arch/powerpc/ibm4xx/dev/if_emac.c
--- a/sys/arch/powerpc/ibm4xx/dev/if_emac.c     Sun Jan 24 05:14:55 2021 +0000
+++ b/sys/arch/powerpc/ibm4xx/dev/if_emac.c     Sun Jan 24 05:16:56 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_emac.c,v 1.53 2020/07/06 09:34:17 rin Exp $ */
+/*     $NetBSD: if_emac.c,v 1.54 2021/01/24 05:22:21 rin Exp $ */
 
 /*
  * Copyright 2001, 2002 Wasabi Systems, Inc.
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_emac.c,v 1.53 2020/07/06 09:34:17 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_emac.c,v 1.54 2021/01/24 05:22:21 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_emac.h"
@@ -67,6 +67,8 @@
 #include <sys/cpu.h>
 #include <sys/device.h>
 
+#include <sys/rndsource.h>
+
 #include <uvm/uvm_extern.h>            /* for PAGE_SIZE */
 
 #include <net/if.h>
@@ -210,6 +212,8 @@
 
        int sc_rxptr;                   /* next ready RX descriptor/descsoft */
 
+       krndsource_t rnd_source;        /* random source */
+
        void (*sc_rmii_enable)(device_t, int);          /* reduced MII enable */
        void (*sc_rmii_disable)(device_t, int);         /* reduced MII disable*/
        void (*sc_rmii_speed)(device_t, int, int);      /* reduced MII speed */
@@ -555,6 +559,9 @@
        if_deferred_start_init(ifp, NULL);
        ether_ifattach(ifp, enaddr);
 
+       rnd_attach_source(&sc->rnd_source, xname, RND_TYPE_NET,
+           RND_FLAG_DEFAULT);
+
 #ifdef EMAC_EVENT_COUNTERS
        /*
         * Attach the event counters.
@@ -1254,13 +1261,14 @@
        struct ifnet *ifp = &sc->sc_ethercom.ec_if;
        struct emac_txsoft *txs;
        int handled, i;
-       uint32_t txstat;
+       uint32_t txstat, count;
 
        EMAC_EVCNT_INCR(&sc->sc_ev_txreap);
        handled = 0;
 
        ifp->if_flags &= ~IFF_OACTIVE;
 
+       count = 0;
        /*
         * Go through our Tx list and free mbufs for those
         * frames that have been transmitted.
@@ -1317,6 +1325,8 @@
                bus_dmamap_unload(sc->sc_dmat, txs->txs_dmamap);
                m_freem(txs->txs_mbuf);
                txs->txs_mbuf = NULL;
+
+               count++;
        }
 
        /* Update the dirty transmit buffer pointer. */
@@ -1329,6 +1339,9 @@
        if (sc->sc_txsfree == EMAC_TXQUEUELEN)
                ifp->if_timer = 0;
 
+       if (count != 0)
+               rnd_add_uint32(&sc->rnd_source, count);
+
        return handled;
 }
 
@@ -1582,11 +1595,12 @@
        struct ifnet *ifp = &sc->sc_ethercom.ec_if;
        struct emac_rxsoft *rxs;
        struct mbuf *m;
-       uint32_t rxstat;
+       uint32_t rxstat, count;
        int i, len;
 
        EMAC_EVCNT_INCR(&sc->sc_ev_rxintr);
 
+       count = 0;
        for (i = sc->sc_rxptr; ; i = EMAC_NEXTRX(i)) {
                rxs = &sc->sc_rxsoft[i];
 
@@ -1681,11 +1695,16 @@
 
                /* Pass it on. */
                if_percpuq_enqueue(ifp->if_percpuq, m);
+
+               count++;
        }
 
        /* Update the receive pointer. */
        sc->sc_rxptr = i;
 
+       if (count != 0)
+               rnd_add_uint32(&sc->rnd_source, count);
+
        return 1;
 }
 



Home | Main Index | Thread Index | Old Index