Source-Changes-HG archive

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

[src/trunk]: src/sys/opencrypto refactor: remove glue macros for FreeBSD code.



details:   https://anonhg.NetBSD.org/src/rev/3b88e236ed2e
branches:  trunk
changeset: 825796:3b88e236ed2e
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Mon Jul 31 04:19:26 2017 +0000

description:
refactor: remove glue macros for FreeBSD code.

diffstat:

 sys/opencrypto/crypto.c |  47 +++++++++++++++++++----------------------------
 1 files changed, 19 insertions(+), 28 deletions(-)

diffs (117 lines):

diff -r b391fc7dcf71 -r 3b88e236ed2e sys/opencrypto/crypto.c
--- a/sys/opencrypto/crypto.c   Mon Jul 31 00:51:20 2017 +0000
+++ b/sys/opencrypto/crypto.c   Mon Jul 31 04:19:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: crypto.c,v 1.96 2017/07/26 06:44:01 knakahara Exp $ */
+/*     $NetBSD: crypto.c,v 1.97 2017/07/31 04:19:26 knakahara Exp $ */
 /*     $FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $   */
 /*     $OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $ */
 
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.96 2017/07/26 06:44:01 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.97 2017/07/31 04:19:26 knakahara Exp $");
 
 #include <sys/param.h>
 #include <sys/reboot.h>
@@ -80,20 +80,6 @@
 #include <opencrypto/cryptodev.h>
 #include <opencrypto/xform.h>                  /* XXX for M_XDATA */
 
-/* below are kludges for residual code wrtitten to FreeBSD interfaces */
-  #define SWI_CRYPTO 17
-  #define register_swi(lvl, fn)  \
-  softint_establish(SOFTINT_NET|SOFTINT_MPSAFE, (void (*)(void *))fn, NULL)
-  #define unregister_swi(lvl, fn)  softint_disestablish(softintr_cookie)
-  #define setsoftcrypto(x)                     \
-       do{                                     \
-               kpreempt_disable();             \
-               softint_schedule(x);            \
-               kpreempt_enable();              \
-       }while(0)
-
-int crypto_ret_q_check(struct cryptop *);
-
 /*
  * Crypto drivers register themselves by allocating a slot in the
  * crypto_drivers table with crypto_get_driverid() and then registering
@@ -103,8 +89,7 @@
 /* Don't directly access crypto_drivers[i], use crypto_checkdriver(i). */
 static struct cryptocap *crypto_drivers;
 static int crypto_drivers_num;
-static void *softintr_cookie;
-
+static void *crypto_q_si;
 static void *crypto_ret_si;
 
 /*
@@ -508,7 +493,7 @@
  *
  * This scheme is not intended for SMP machines.
  */
-static void cryptointr(void);          /* swi thread to dispatch ops */
+static void cryptointr(void *);        /* swi thread to dispatch ops */
 static void cryptoret_softint(void *); /* kernel thread for callbacks*/
 static int crypto_destroy(bool);
 static int crypto_invoke(struct cryptop *crp, int hint);
@@ -607,8 +592,8 @@
        }
        crypto_drivers_num = CRYPTO_DRIVERS_INITIAL;
 
-       softintr_cookie = register_swi(SWI_CRYPTO, cryptointr);
-       if (softintr_cookie == NULL) {
+       crypto_q_si = softint_establish(SOFTINT_NET|SOFTINT_MPSAFE, cryptointr, NULL);
+       if (crypto_q_si == NULL) {
                printf("crypto_init: cannot establish request queue handler\n");
                return crypto_destroy(false);
        }
@@ -703,8 +688,8 @@
        if (crypto_ret_si != NULL)
                softint_disestablish(crypto_ret_si);
 
-       if (softintr_cookie != NULL)
-               unregister_swi(SWI_CRYPTO, cryptointr);
+       if (crypto_q_si != NULL)
+               softint_disestablish(crypto_q_si);
 
        mutex_enter(&crypto_drv_mtx);
        if (crypto_drivers != NULL)
@@ -1278,8 +1263,11 @@
                cap->cc_kqblocked = 0;
        }
        crypto_driver_unlock(cap);
-       if (needwakeup)
-               setsoftcrypto(softintr_cookie);
+       if (needwakeup) {
+               kpreempt_disable();
+               softint_schedule(crypto_q_si);
+               kpreempt_enable();
+       }
 
        return 0;
 }
@@ -1323,8 +1311,11 @@
                TAILQ_INSERT_TAIL(crp_q, crp, crp_next);
                crypto_put_crp_qs(&s);
                crp_q = NULL;
-               if (wasempty)
-                       setsoftcrypto(softintr_cookie);
+               if (wasempty) {
+                       kpreempt_disable();
+                       softint_schedule(crypto_q_si);
+                       kpreempt_enable();
+               }
 
                return 0;
        }
@@ -1901,7 +1892,7 @@
  * Software interrupt thread to dispatch crypto requests.
  */
 static void
-cryptointr(void)
+cryptointr(void *arg __unused)
 {
        struct cryptop *crp, *submit, *cnext;
        struct cryptkop *krp, *knext;



Home | Main Index | Thread Index | Old Index