Source-Changes-HG archive

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

[src/trunk]: src Make ubsec(4) loadable as kmod.



details:   https://anonhg.NetBSD.org/src/rev/8c990ad835cd
branches:  trunk
changeset: 791422:8c990ad835cd
user:      bad <bad%NetBSD.org@localhost>
date:      Sun Nov 17 17:16:24 2013 +0000

description:
Make ubsec(4) loadable as kmod.

diffstat:

 distrib/sets/lists/modules/md.evbppc |   6 ++-
 distrib/sets/lists/modules/mi        |   4 +-
 sys/dev/pci/ubsec.c                  |  88 ++++++++++++++++++++++++++++++++++-
 sys/dev/pci/ubsecvar.h               |   4 +-
 sys/modules/Makefile                 |   3 +-
 sys/modules/ubsec/Makefile           |  11 ++++
 sys/modules/ubsec/ubsec.ioconf       |  10 ++++
 7 files changed, 118 insertions(+), 8 deletions(-)

diffs (260 lines):

diff -r e33c3a355616 -r 8c990ad835cd distrib/sets/lists/modules/md.evbppc
--- a/distrib/sets/lists/modules/md.evbppc      Sun Nov 17 17:01:44 2013 +0000
+++ b/distrib/sets/lists/modules/md.evbppc      Sun Nov 17 17:16:24 2013 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: md.evbppc,v 1.34 2013/10/29 20:11:52 mbalmer Exp $
+# $NetBSD: md.evbppc,v 1.35 2013/11/17 17:16:24 bad Exp $
 ./stand/powerpc-4xx                                                    base-kernel-modules     kmod,compatmodules
 ./stand/powerpc-4xx/@OSRELEASE@                                                base-kernel-modules     kmod,compatmodules
 ./stand/powerpc-4xx/@OSRELEASE@/modules                                        base-kernel-modules     kmod,compatmodules
@@ -188,6 +188,8 @@
 ./stand/powerpc-4xx/@OSRELEASE@/modules/tprof/tprof.kmod                       base-kernel-modules     kmod,compatmodules
 ./stand/powerpc-4xx/@OSRELEASE@/modules/uatp                           base-kernel-modules     kmod,compatmodules
 ./stand/powerpc-4xx/@OSRELEASE@/modules/uatp/uatp.kmod                 base-kernel-modules     kmod,compatmodules
+./stand/powerpc-4xx/@OSRELEASE@/modules/ubsec                          base-kernel-modules     kmod,compatmodules
+./stand/powerpc-4xx/@OSRELEASE@/modules/ubsec/ubsec.kmod                       base-kernel-modules     kmod,compatmodules
 ./stand/powerpc-4xx/@OSRELEASE@/modules/udf                            base-kernel-modules     kmod,compatmodules
 ./stand/powerpc-4xx/@OSRELEASE@/modules/udf/udf.kmod                   base-kernel-modules     kmod,compatmodules
 ./stand/powerpc-4xx/@OSRELEASE@/modules/umap                           base-kernel-modules     kmod,compatmodules
@@ -393,6 +395,8 @@
 ./stand/powerpc-booke/@OSRELEASE@/modules/tprof/tprof.kmod             base-kernel-modules     kmod,compatmodules
 ./stand/powerpc-booke/@OSRELEASE@/modules/uatp                         base-kernel-modules     kmod,compatmodules
 ./stand/powerpc-booke/@OSRELEASE@/modules/uatp/uatp.kmod               base-kernel-modules     kmod,compatmodules
+./stand/powerpc-booke/@OSRELEASE@/modules/ubsec                                base-kernel-modules     kmod,compatmodules
+./stand/powerpc-booke/@OSRELEASE@/modules/ubsec/ubsec.kmod                     base-kernel-modules     kmod,compatmodules
 ./stand/powerpc-booke/@OSRELEASE@/modules/udf                          base-kernel-modules     kmod,compatmodules
 ./stand/powerpc-booke/@OSRELEASE@/modules/udf/udf.kmod                 base-kernel-modules     kmod,compatmodules
 ./stand/powerpc-booke/@OSRELEASE@/modules/umap                         base-kernel-modules     kmod,compatmodules
diff -r e33c3a355616 -r 8c990ad835cd distrib/sets/lists/modules/mi
--- a/distrib/sets/lists/modules/mi     Sun Nov 17 17:01:44 2013 +0000
+++ b/distrib/sets/lists/modules/mi     Sun Nov 17 17:16:24 2013 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.57 2013/11/16 16:59:03 skrll Exp $
+# $NetBSD: mi,v 1.58 2013/11/17 17:16:24 bad Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -194,6 +194,8 @@
 ./@MODULEDIR@/tprof/tprof.kmod                 base-kernel-modules     kmod
 ./@MODULEDIR@/uatp                             base-kernel-modules     kmod
 ./@MODULEDIR@/uatp/uatp.kmod                   base-kernel-modules     kmod
+./@MODULEDIR@/ubsec                            base-kernel-modules     kmod
+./@MODULEDIR@/ubsec/ubsec.kmod                 base-kernel-modules     kmod
 ./@MODULEDIR@/udf                              base-kernel-modules     kmod
 ./@MODULEDIR@/udf/udf.kmod                     base-kernel-modules     kmod
 ./@MODULEDIR@/umap                             base-kernel-modules     kmod
diff -r e33c3a355616 -r 8c990ad835cd sys/dev/pci/ubsec.c
--- a/sys/dev/pci/ubsec.c       Sun Nov 17 17:01:44 2013 +0000
+++ b/sys/dev/pci/ubsec.c       Sun Nov 17 17:16:24 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ubsec.c,v 1.31 2013/11/17 17:01:44 bad Exp $   */
+/*     $NetBSD: ubsec.c,v 1.32 2013/11/17 17:16:25 bad Exp $   */
 /* $FreeBSD: src/sys/dev/ubsec/ubsec.c,v 1.6.2.6 2003/01/23 21:06:43 sam Exp $ */
 /*     $OpenBSD: ubsec.c,v 1.127 2003/06/04 14:04:58 jason Exp $       */
 
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.31 2013/11/17 17:01:44 bad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.32 2013/11/17 17:16:25 bad Exp $");
 
 #undef UBSEC_DEBUG
 
@@ -57,6 +57,7 @@
 #include <sys/kernel.h>
 #include <sys/mbuf.h>
 #include <sys/device.h>
+#include <sys/module.h>
 #include <sys/queue.h>
 
 #include <opencrypto/cryptodev.h>
@@ -82,6 +83,7 @@
  */
 static int ubsec_probe(device_t, cfdata_t, void *);
 static void ubsec_attach(device_t, device_t, void *);
+static int  ubsec_detach(device_t, int);
 static void ubsec_reset_board(struct ubsec_softc *);
 static void ubsec_init_board(struct ubsec_softc *);
 static void ubsec_init_pciregs(struct pci_attach_args *pa);
@@ -99,7 +101,7 @@
 };
 #else
 CFATTACH_DECL_NEW(ubsec, sizeof(struct ubsec_softc), ubsec_probe, ubsec_attach,
-             NULL, NULL);
+             ubsec_detach, NULL);
 extern struct cfdriver ubsec_cd;
 #endif
 
@@ -310,6 +312,8 @@
        u_int32_t cmd, i;
 
        sc->sc_dev = self;
+       sc->sc_pct = pc;
+
        up = ubsec_lookup(pa);
        if (up == NULL) {
                printf("\n");
@@ -332,7 +336,7 @@
        pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, cmd);
 
        if (pci_mapreg_map(pa, BS_BAR, PCI_MAPREG_TYPE_MEM, 0,
-           &sc->sc_st, &sc->sc_sh, NULL, NULL)) {
+           &sc->sc_st, &sc->sc_sh, NULL, &sc->sc_memsize)) {
                aprint_error_dev(self, "can't find mem space");
                return;
        }
@@ -472,6 +476,82 @@
        }
 }
 
+static int
+ubsec_detach(device_t self, int flags)
+{
+       struct ubsec_softc *sc = device_private(self);
+       struct ubsec_q *q, *qtmp;
+
+       /* disable interrupts */
+       /* XXX wait/abort current ops? where is DMAERR enabled? */
+       WRITE_REG(sc, BS_CTRL, READ_REG(sc, BS_CTRL) &~
+           (BS_CTRL_MCR2INT | BS_CTRL_MCR1INT | BS_CTRL_DMAERR));
+
+#ifndef UBSEC_NO_RNG
+       if (sc->sc_flags & UBS_FLAGS_RNG) {
+               callout_halt(&sc->sc_rngto, NULL);
+               ubsec_dma_free(sc, &sc->sc_rng.rng_buf);
+               ubsec_dma_free(sc, &sc->sc_rng.rng_q.q_ctx);
+               ubsec_dma_free(sc, &sc->sc_rng.rng_q.q_mcr);
+               rnd_detach_source(&sc->sc_rnd_source);
+       }
+#endif /* UBSEC_NO_RNG */
+
+       crypto_unregister_all(sc->sc_cid);
+
+       mutex_spin_enter(&sc->sc_mtx);
+
+       ubsec_totalreset(sc);  /* XXX leaves the chip running */
+
+       SIMPLEQ_FOREACH_SAFE(q, &sc->sc_freequeue, q_next, qtmp) {
+               ubsec_dma_free(sc, &q->q_dma->d_alloc);
+               free(q, M_DEVBUF);
+       }
+
+       mutex_spin_exit(&sc->sc_mtx);
+
+       if (sc->sc_ih != NULL) {
+               pci_intr_disestablish(sc->sc_pct, sc->sc_ih);
+               sc->sc_ih = NULL;
+       }
+
+       if (sc->sc_memsize != 0) {
+               bus_space_unmap(sc->sc_st, sc->sc_sh, sc->sc_memsize);
+               sc->sc_memsize = 0;
+       }
+
+       return 0;
+}
+
+MODULE(MODULE_CLASS_DRIVER, ubsec, "pci");
+
+#ifdef _MODULE
+#include "ioconf.c"
+#endif
+
+static int
+ubsec_modcmd(modcmd_t cmd, void *data)
+{
+       int error = 0;
+
+       switch (cmd) {
+       case MODULE_CMD_INIT:
+#ifdef _MODULE
+               error = config_init_component(cfdriver_ioconf_ubsec,
+                   cfattach_ioconf_ubsec, cfdata_ioconf_ubsec);
+#endif
+               return error;
+       case MODULE_CMD_FINI:
+#ifdef _MODULE
+               error = config_fini_component(cfdriver_ioconf_ubsec,
+                   cfattach_ioconf_ubsec, cfdata_ioconf_ubsec);
+#endif
+               return error;
+       default:
+               return ENOTTY;
+       }
+}
+
 /*
  * UBSEC Interrupt routine
  */
diff -r e33c3a355616 -r 8c990ad835cd sys/dev/pci/ubsecvar.h
--- a/sys/dev/pci/ubsecvar.h    Sun Nov 17 17:01:44 2013 +0000
+++ b/sys/dev/pci/ubsecvar.h    Sun Nov 17 17:16:24 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ubsecvar.h,v 1.5 2013/06/13 00:55:01 tls Exp $ */
+/*     $NetBSD: ubsecvar.h,v 1.6 2013/11/17 17:16:25 bad Exp $ */
 /*     $OpenBSD: ubsecvar.h,v 1.36 2003/06/04 16:02:41 jason Exp $     */
 
 /*
@@ -150,6 +150,7 @@
        device_t                sc_dev;         /* generic device */
        void                    *sc_ih;         /* interrupt handler cookie */
        kmutex_t                sc_mtx;
+       pci_chipset_tag_t       sc_pct;         /* pci chipset tag */
        bus_space_handle_t      sc_sh;          /* memory handle */
        bus_space_tag_t         sc_st;          /* memory tag */
        bus_dma_tag_t           sc_dmat;        /* dma tag */
@@ -176,6 +177,7 @@
        struct ubsec_dma        sc_dmaa[UBS_MAX_NQUEUE];
        struct ubsec_q          *sc_queuea[UBS_MAX_NQUEUE];
        SIMPLEQ_HEAD(,ubsec_q2) sc_q2free;      /* free list */
+       bus_size_t              sc_memsize;     /* size mapped by sc_sh */
 };
 
 #define        UBSEC_QFLAGS_COPYOUTIV          0x1
diff -r e33c3a355616 -r 8c990ad835cd sys/modules/Makefile
--- a/sys/modules/Makefile      Sun Nov 17 17:01:44 2013 +0000
+++ b/sys/modules/Makefile      Sun Nov 17 17:16:24 2013 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.124 2013/11/16 16:59:04 skrll Exp $
+#      $NetBSD: Makefile,v 1.125 2013/11/17 17:16:24 bad Exp $
 
 .include <bsd.own.mk>
 
@@ -82,6 +82,7 @@
 SUBDIR+=       swsensor
 SUBDIR+=       tmpfs
 SUBDIR+=       uatp
+SUBDIR+=       ubsec
 SUBDIR+=       udf
 SUBDIR+=       umap
 SUBDIR+=       union
diff -r e33c3a355616 -r 8c990ad835cd sys/modules/ubsec/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/ubsec/Makefile        Sun Nov 17 17:16:24 2013 +0000
@@ -0,0 +1,11 @@
+#      $NetBSD: Makefile,v 1.1 2013/11/17 17:16:24 bad Exp $
+
+.include "../Makefile.inc"
+
+.PATH: ${S}/dev/pci
+
+KMOD=  ubsec
+IOCONF=        ubsec.ioconf
+SRCS=  ubsec.c
+
+.include <bsd.kmodule.mk>
diff -r e33c3a355616 -r 8c990ad835cd sys/modules/ubsec/ubsec.ioconf
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/modules/ubsec/ubsec.ioconf    Sun Nov 17 17:16:24 2013 +0000
@@ -0,0 +1,10 @@
+#      $NetBSD: ubsec.ioconf,v 1.1 2013/11/17 17:16:24 bad Exp $
+
+ioconf ubsec
+
+include "conf/files"
+include "dev/pci/files.pci"
+
+pseudo-root pci*
+
+ubsec* at pci? dev ? function ?



Home | Main Index | Thread Index | Old Index