From 5386cf1679915ebe92c0b8b6d843f8e4b1699eeb Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sat, 3 Jul 2010 15:20:51 +0200 Subject: [PATCH] Zero-copy operations are now the default behavior. --- cryptodev_int.h | 2 ++ cryptodev_main.c | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cryptodev_int.h b/cryptodev_int.h index bc548c4..0b82017 100644 --- a/cryptodev_int.h +++ b/cryptodev_int.h @@ -11,6 +11,8 @@ #include #include +#undef DISABLE_ZCOPY + #define PFX "cryptodev: " #define dprintk(level,severity,format,a...) \ do { \ diff --git a/cryptodev_main.c b/cryptodev_main.c index 790dac3..0da4582 100644 --- a/cryptodev_main.c +++ b/cryptodev_main.c @@ -396,6 +396,7 @@ out_err: return ret; } +#ifdef DISABLE_ZCOPY /* This is the main crypto function - feed it with plaintext and get a ciphertext (or vice versa :-) */ @@ -448,6 +449,8 @@ __crypto_run_std(struct csession *ses_ptr, struct crypt_op *cop) return ret; } +#else /* Zero - copy */ + /* last page - first page + 1 */ #define PAGECOUNT(buf, buflen) \ ((((unsigned long)(buf + buflen - 1) & PAGE_MASK) >> PAGE_SHIFT) - \ @@ -559,17 +562,13 @@ __crypto_run_zc(struct csession *ses_ptr, struct crypt_op *cop) return ret; } -typedef int (*crypto_runner)(struct csession *ses_ptr, struct crypt_op *cop); +#endif /* DISABLE_ZCOPY */ static int crypto_run(struct fcrypt *fcr, struct crypt_op *cop) { struct csession *ses_ptr; uint8_t hash_output[AALG_MAX_RESULT_LEN]; int ret; - crypto_runner workers[] = { - [0] = __crypto_run_std, - [1] = __crypto_run_zc, - }; if (unlikely(cop->op != COP_ENCRYPT && cop->op != COP_DECRYPT)) { dprintk(1, KERN_DEBUG, "invalid operation op=%u\n", cop->op); @@ -608,8 +607,11 @@ static int crypto_run(struct fcrypt *fcr, struct crypt_op *cop) } } - - ret = (*workers[!!(cop->flags & COP_FLAG_ZCOPY)])(ses_ptr, cop); +#ifdef DISABLE_ZCOPY + ret = __crypto_run_std(ses_ptr, cop); +#else /* normal */ + ret = __crypto_run_zc(ses_ptr, cop); +#endif if (unlikely(ret)) goto out_unlock; -- 2.11.4.GIT