Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci De-#ifdef __OpenBSD__ify hifn7751.c.



details:   https://anonhg.NetBSD.org/src/rev/e5351b5d7e6a
branches:  trunk
changeset: 972136:e5351b5d7e6a
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun May 17 00:49:28 2020 +0000

description:
De-#ifdef __OpenBSD__ify hifn7751.c.

Not really helpful; we can just use diff3 to merge updates.

diffstat:

 sys/dev/pci/hifn7751.c    |  177 +++++++++------------------------------------
 sys/dev/pci/hifn7751var.h |    4 +-
 2 files changed, 36 insertions(+), 145 deletions(-)

diffs (truncated from 418 to 300 lines):

diff -r 47f4fdd0d512 -r e5351b5d7e6a sys/dev/pci/hifn7751.c
--- a/sys/dev/pci/hifn7751.c    Sat May 16 23:10:26 2020 +0000
+++ b/sys/dev/pci/hifn7751.c    Sun May 17 00:49:28 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hifn7751.c,v 1.67 2020/04/30 03:40:53 riastradh Exp $  */
+/*     $NetBSD: hifn7751.c,v 1.68 2020/05/17 00:49:28 riastradh Exp $  */
 /*     $FreeBSD: hifn7751.c,v 1.5.2.7 2003/10/08 23:52:00 sam Exp $ */
 /*     $OpenBSD: hifn7751.c,v 1.140 2003/08/01 17:55:54 deraadt Exp $  */
 
@@ -48,29 +48,24 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.67 2020/04/30 03:40:53 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.68 2020/05/17 00:49:28 riastradh Exp $");
 
 #include <sys/param.h>
-#include <sys/systm.h>
+#include <sys/cprng.h>
+#include <sys/device.h>
+#include <sys/endian.h>
+#include <sys/errno.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/module.h>
 #include <sys/mutex.h>
 #include <sys/proc.h>
-#include <sys/errno.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/mbuf.h>
-#include <sys/device.h>
-#include <sys/module.h>
-#include <sys/endian.h>
-
-#ifdef __OpenBSD__
-#include <crypto/crypto.h>
-#include <dev/rndvar.h>
-#else
-#include <opencrypto/cryptodev.h>
-#include <sys/cprng.h>
 #include <sys/rndsource.h>
 #include <sys/sha1.h>
-#endif
+#include <sys/systm.h>
+
+#include <opencrypto/cryptodev.h>
 
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
@@ -81,43 +76,20 @@
 
 #undef HIFN_DEBUG
 
-#ifdef __NetBSD__
-#define M_DUP_PKTHDR m_copy_pkthdr     /* XXX */
-#endif
-
 #ifdef HIFN_DEBUG
 extern int hifn_debug;         /* patchable */
 int hifn_debug = 1;
 #endif
 
-#ifdef __OpenBSD__
-#define HAVE_CRYPTO_LZS                /* OpenBSD OCF supports CRYPTO_COMP_LZS */
-#endif
-
 /*
  * Prototypes and count for the pci_device structure
  */
-#ifdef __OpenBSD__
-static int hifn_probe((struct device *, void *, void *);
-#else
-static int hifn_probe(device_t, cfdata_t, void *);
-#endif
+static int hifn_match(device_t, cfdata_t, void *);
 static void hifn_attach(device_t, device_t, void *);
-#ifdef __NetBSD__
 static int hifn_detach(device_t, int);
 
 CFATTACH_DECL_NEW(hifn, sizeof(struct hifn_softc),
-    hifn_probe, hifn_attach, hifn_detach, NULL);
-#else
-CFATTACH_DECL_NEW(hifn, sizeof(struct hifn_softc),
-    hifn_probe, hifn_attach, NULL, NULL);
-#endif
-
-#ifdef __OpenBSD__
-struct cfdriver hifn_cd = {
-       0, "hifn", DV_DULL
-};
-#endif
+    hifn_match, hifn_attach, hifn_detach, NULL);
 
 static void    hifn_reset_board(struct hifn_softc *, int);
 static void    hifn_reset_puc(struct hifn_softc *);
@@ -156,14 +128,14 @@
                                int *);
 static void    hifn_write_4(struct hifn_softc *, int, bus_size_t, uint32_t);
 static uint32_t hifn_read_4(struct hifn_softc *, int, bus_size_t);
-#ifdef HAVE_CRYPTO_LZS
+#ifdef CRYPTO_LZS_COMP
 static int     hifn_compression(struct hifn_softc *, struct cryptop *,
                                 struct hifn_command *);
 static struct mbuf *hifn_mkmbuf_chain(int, struct mbuf *);
 static int     hifn_compress_enter(struct hifn_softc *, struct hifn_command *);
 static void    hifn_callback_comp(struct hifn_softc *, struct hifn_command *,
                                   uint8_t *);
-#endif /* HAVE_CRYPTO_LZS */
+#endif /* CRYPTO_LZS_COMP */
 
 struct hifn_stats hifnstats;
 
@@ -228,7 +200,7 @@
 }
 
 static int
-hifn_probe(device_t parent, cfdata_t match, void *aux)
+hifn_match(device_t parent, cfdata_t match, void *aux)
 {
        struct pci_attach_args *pa = aux;
 
@@ -249,12 +221,6 @@
        const char *intrstr = NULL;
        const char *hifncap;
        char rbase;
-#ifdef __NetBSD__
-#define iosize0 sc->sc_iosz0
-#define iosize1 sc->sc_iosz1
-#else
-       bus_size_t iosize0, iosize1;
-#endif
        uint32_t cmd;
        uint16_t ena;
        bus_dma_segment_t seg;
@@ -282,13 +248,13 @@
        pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, cmd);
 
        if (pci_mapreg_map(pa, HIFN_BAR0, PCI_MAPREG_TYPE_MEM, 0,
-           &sc->sc_st0, &sc->sc_sh0, NULL, &iosize0)) {
+           &sc->sc_st0, &sc->sc_sh0, NULL, &sc->sc_iosz0)) {
                aprint_error_dev(sc->sc_dv, "can't map mem space %d\n", 0);
                return;
        }
 
        if (pci_mapreg_map(pa, HIFN_BAR1, PCI_MAPREG_TYPE_MEM, 0,
-           &sc->sc_st1, &sc->sc_sh1, NULL, &iosize1)) {
+           &sc->sc_st1, &sc->sc_sh1, NULL, &sc->sc_iosz1)) {
                aprint_error_dev(sc->sc_dv, "can't find mem space %d\n", 1);
                goto fail_io0;
        }
@@ -368,13 +334,8 @@
                goto fail_mem;
        }
        intrstr = pci_intr_string(pc, ih, intrbuf, sizeof(intrbuf));
-#ifdef __OpenBSD__
-       sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, hifn_intr, sc,
-           device_xname(self));
-#else
        sc->sc_ih = pci_intr_establish_xname(pc, ih, IPL_NET, hifn_intr, sc,
            device_xname(self));
-#endif
        if (sc->sc_ih == NULL) {
                aprint_error_dev(sc->sc_dv, "couldn't establish interrupt\n");
                if (intrstr != NULL)
@@ -440,13 +401,8 @@
                hifn_init_pubrng(sc);
        }
 
-#ifdef __OpenBSD__
-       timeout_set(&sc->sc_tickto, hifn_tick, sc);
-       timeout_add(&sc->sc_tickto, hz);
-#else
        callout_init(&sc->sc_tickto, CALLOUT_MPSAFE);
        callout_reset(&sc->sc_tickto, hz, hifn_tick, sc);
-#endif
        return;
 
 fail_intr:
@@ -462,12 +418,11 @@
            HIFN_DMACNFG_DMARESET | HIFN_DMACNFG_MODE);
 
 fail_io1:
-       bus_space_unmap(sc->sc_st1, sc->sc_sh1, iosize1);
+       bus_space_unmap(sc->sc_st1, sc->sc_sh1, sc->sc_iosz1);
 fail_io0:
-       bus_space_unmap(sc->sc_st0, sc->sc_sh0, iosize0);
+       bus_space_unmap(sc->sc_st0, sc->sc_sh0, sc->sc_iosz0);
 }
 
-#ifdef __NetBSD__
 static int
 hifn_detach(device_t self, int flags)
 {
@@ -529,8 +484,6 @@
        }
 }
 
-#endif /* ifdef __NetBSD__ */
-
 static void
 hifn_rng_get(size_t bytes, void *priv)
 {
@@ -597,18 +550,10 @@
                        sc->sc_rnghz = hz / 100;
                else
                        sc->sc_rnghz = 1;
-#ifdef __OpenBSD__
-               timeout_set(&sc->sc_rngto, hifn_rng, sc);
-#else  /* !__OpenBSD__ */
                callout_init(&sc->sc_rngto, CALLOUT_MPSAFE);
-#endif /* !__OpenBSD__ */
-
-#ifdef __NetBSD__
                rndsource_setcb(&sc->sc_rnd_source, hifn_rng_get, sc);
                rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dv),
-                                 RND_TYPE_RNG,
-                                 RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
-#endif
+                   RND_TYPE_RNG, RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
        }
 
        /* Enable public key engine, if available */
@@ -625,11 +570,7 @@
 hifn_rng_locked(void *vsc)
 {
        struct hifn_softc *sc = vsc;
-#ifdef __NetBSD__
        uint32_t num[64];
-#else
-       uint32_t num[2];
-#endif
        uint32_t sts;
        int i;
        size_t got, gotent;
@@ -658,27 +599,8 @@
                        num[1] = READ_REG_1(sc, HIFN_1_7811_RNGDAT);
                        got = 2 * sizeof(num[0]);
                        gotent = (got * NBBY) / HIFN_RNG_BITSPER;
-
-#ifdef __NetBSD__
                        rnd_add_data(&sc->sc_rnd_source, num, got, gotent);
                        sc->sc_rng_need -= gotent;
-#else
-                       /*
-                        * XXX This is a really bad idea.
-                        * XXX Hifn estimate as little as 0.06
-                        * XXX actual bits of entropy per output
-                        * XXX register bit.  How can we tell the
-                        * XXX kernel RNG subsystem we're handing
-                        * XXX it 64 "true" random bits, for any
-                        * XXX sane value of "true"?
-                        * XXX
-                        * XXX The right thing to do here, if we
-                        * XXX cannot supply an estimate ourselves,
-                        * XXX would be to hash the bits locally.
-                        */
-                       add_true_randomness(num[0]);
-                       add_true_randomness(num[1]);
-#endif
                }
        } else {
                int nwords = 0;
@@ -720,22 +642,13 @@
 
                got = nwords * sizeof(num[0]);
                gotent = (got * NBBY) / HIFN_RNG_BITSPER;
-#ifdef __NetBSD__
                rnd_add_data(&sc->sc_rnd_source, num, got, gotent);
                sc->sc_rng_need -= gotent;
-#else
-               /* XXX a bad idea; see 7811 block above */
-               add_true_randomness(num[0]);
-#endif
        }
 
-#ifdef __OpenBSD__
-       timeout_add(&sc->sc_rngto, sc->sc_rnghz);
-#else
        if (sc->sc_rng_need > 0) {
                callout_reset(&sc->sc_rngto, sc->sc_rnghz, hifn_rng, sc);
        }
-#endif
 }
 
 static void
@@ -1740,7 +1653,7 @@
                                goto err_srcmap;
                        }
                        if (len == MHLEN)
-                               M_DUP_PKTHDR(m0, cmd->srcu.src_m);
+                               m_copy_pkthdr(m0, cmd->srcu.src_m);
                        if (totlen >= MINCLSIZE) {
                                MCLGET(m0, M_DONTWAIT);
                                if (m0->m_flags & M_EXT)
@@ -1858,22 +1771,13 @@
        }
 
        /*



Home | Main Index | Thread Index | Old Index