Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Dec 2006 21:31:02 GMT
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 111160 for review
Message-ID:  <200612052131.kB5LV2SL084705@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=111160

Change 111160 by sam@sam_ebb on 2006/12/05 21:30:35

	Plan B: instead of splitting the cryptosoft driver out as
	a separate driver/module lump it back into the crypto module
	as done prior to kobj'ification of crypto drivers.  To deal
	with the ordering requirements of module unload and driver
	detach use explicit metadata linkage.  A tad awkward but
	seesm to work.  Thanks to jhb for guidance.

Affected files ...

.. //depot/projects/crypto/sys/conf/files#4 edit
.. //depot/projects/crypto/sys/modules/Makefile#3 edit
.. //depot/projects/crypto/sys/modules/crypto/Makefile#4 edit
.. //depot/projects/crypto/sys/modules/cryptosoft/Makefile#2 delete
.. //depot/projects/crypto/sys/opencrypto/crypto.c#7 edit
.. //depot/projects/crypto/sys/opencrypto/cryptosoft.c#4 edit

Differences ...

==== //depot/projects/crypto/sys/conf/files#4 (text+ko) ====

@@ -1902,7 +1902,7 @@
 opencrypto/crypto.c		optional crypto
 opencrypto/cryptodev.c		optional cryptodev
 opencrypto/cryptodev_if.m	optional crypto
-opencrypto/cryptosoft.c		optional cryptosoft
+opencrypto/cryptosoft.c		optional crypto
 opencrypto/deflate.c		optional crypto
 opencrypto/rmd160.c		optional crypto | ipsec
 opencrypto/skipjack.c		optional crypto

==== //depot/projects/crypto/sys/modules/Makefile#3 (text+ko) ====

@@ -58,7 +58,6 @@
 	${_cpufreq} \
 	${_crypto} \
 	${_cryptodev} \
-	${_cryptosoft} \
 	${_cs} \
 	${_ctau} \
 	cue \
@@ -313,7 +312,6 @@
 .if exists(${.CURDIR}/../opencrypto)
 _crypto=	crypto
 _cryptodev=	cryptodev
-_cryptosoft=	cryptosoft
 .endif
 .if exists(${.CURDIR}/../crypto)
 _random=	random

==== //depot/projects/crypto/sys/modules/crypto/Makefile#4 (text+ko) ====

@@ -9,7 +9,7 @@
 
 KMOD	= crypto
 SRCS	= crypto.c cryptodev_if.c
-SRCS	+= criov.c xform.c
+SRCS	+= criov.c cryptosoft.c xform.c
 SRCS	+= cast.c deflate.c rmd160.c rijndael-alg-fst.c rijndael-api.c
 SRCS	+= skipjack.c bf_enc.c bf_skey.c
 SRCS	+= des_ecb.c des_enc.c des_setkey.c

==== //depot/projects/crypto/sys/opencrypto/crypto.c#7 (text+ko) ====

@@ -286,38 +286,6 @@
 	mtx_destroy(&crypto_drivers_mtx);
 }
 
-/*
- * Initialization code, both for static and dynamic loading.
- */
-static int
-crypto_modevent(module_t mod, int type, void *unused)
-{
-	int error = EINVAL;
-
-	switch (type) {
-	case MOD_LOAD:
-		error = crypto_init();
-		if (error == 0 && bootverbose)
-			printf("crypto: <crypto core>\n");
-		break;
-	case MOD_UNLOAD:
-		/*XXX disallow if active sessions */
-		error = 0;
-		crypto_destroy();
-		return 0;
-	}
-	return error;
-}
-
-static moduledata_t crypto_mod = {
-	"crypto",
-	crypto_modevent,
-	0
-};
-MODULE_VERSION(crypto, 1);
-DECLARE_MODULE(crypto, crypto_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
-MODULE_DEPEND(crypto, zlib, 1, 1, 1);
-
 static struct cryptocap *
 crypto_checkdriver(u_int32_t hid)
 {
@@ -1462,3 +1430,34 @@
 
 	crypto_finis(&crp_ret_q);
 }
+
+int crypto_modevent(module_t mod, int type, void *unused);
+
+/*
+ * Initialization code, both for static and dynamic loading.
+ * Note this is not invoked with the usual MODULE_DECLARE
+ * mechanism but instead is listed as a dependency by the
+ * cryptosoft driver.  This guarantees proper ordering of
+ * calls on module load/unload.
+ */
+int
+crypto_modevent(module_t mod, int type, void *unused)
+{
+	int error = EINVAL;
+
+	switch (type) {
+	case MOD_LOAD:
+		error = crypto_init();
+		if (error == 0 && bootverbose)
+			printf("crypto: <crypto core>\n");
+		break;
+	case MOD_UNLOAD:
+		/*XXX disallow if active sessions */
+		error = 0;
+		crypto_destroy();
+		return 0;
+	}
+	return error;
+}
+MODULE_VERSION(crypto, 1);
+MODULE_DEPEND(crypto, zlib, 1, 1, 1);

==== //depot/projects/crypto/sys/opencrypto/cryptosoft.c#4 (text+ko) ====

@@ -1053,7 +1053,15 @@
 };
 static devclass_t swcr_devclass;
 
+/*
+ * NB: We explicitly reference the crypto module so we
+ * get the necessary ordering when built as a loadable
+ * module.  This is required because we bundle the crypto
+ * module code together with the cryptosoft driver (otherwise
+ * normal module dependencies would handle things).
+ */
+extern int crypto_modevent(struct module *, int, void *);
 /* XXX where to attach */
-DRIVER_MODULE(cryptosoft, nexus, swcr_driver, swcr_devclass, 0, 0);
+DRIVER_MODULE(cryptosoft, nexus, swcr_driver, swcr_devclass, crypto_modevent,0);
 MODULE_VERSION(cryptosoft, 1);
 MODULE_DEPEND(cryptosoft, crypto, 1, 1, 1);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200612052131.kB5LV2SL084705>