Module Name: src Committed By: rin Date: Sun Jan 24 05:22:22 UTC 2021
Modified Files: src/sys/arch/powerpc/ibm4xx/dev: if_emac.c Log Message: Add rnd(9) support. To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/sys/arch/powerpc/ibm4xx/dev/if_emac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/powerpc/ibm4xx/dev/if_emac.c diff -u src/sys/arch/powerpc/ibm4xx/dev/if_emac.c:1.53 src/sys/arch/powerpc/ibm4xx/dev/if_emac.c:1.54 --- src/sys/arch/powerpc/ibm4xx/dev/if_emac.c:1.53 Mon Jul 6 09:34:17 2020 +++ src/sys/arch/powerpc/ibm4xx/dev/if_emac.c Sun Jan 24 05:22:21 2021 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: if_emac.c,v #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 @@ struct emac_softc { 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 @@ emac_attach(device_t parent, device_t se 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 @@ emac_txreap(struct emac_softc *sc) 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 @@ emac_txreap(struct emac_softc *sc) 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 @@ emac_txreap(struct emac_softc *sc) 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 @@ emac_rxeob_intr(void *arg) 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 @@ emac_rxeob_intr(void *arg) /* 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; }