int ret = 0;
struct crypto_tfm *base = crypto_diskcipher_tfm(tfm);
struct diskcipher_alg *cra = crypto_diskcipher_alg(base->__crt_alg);
- struct diskcipher_freectrl *fctrl = &cra->freectrl;
if (!cra) {
pr_err("%s: doesn't exist cra", __func__);
ret = cra->crypt(base, req);
- if (!list_empty(&fctrl->freelist)) {
- if (!atomic_read(&fctrl->freewq_active)) {
- atomic_set(&fctrl->freewq_active, 1);
- schedule_delayed_work(&fctrl->freewq, 0);
+#ifdef USE_FREE_REQ
+ if (!list_empty(&cra->freectrl.freelist)) {
+ if (!atomic_read(&cra->freectrl.freewq_active)) {
+ atomic_set(&cra->freectrl.freewq_active, 1);
+ schedule_delayed_work(&cra->freectrl.freewq, 0);
}
}
+#endif
out:
if (ret)
pr_err("%s fails ret:%d, cra:%p\n", __func__, ret, cra);
{
struct crypto_diskcipher *tfm = __crypto_diskcipher_cast(base);
- tfm->req_jiffies = 0;
atomic_set(&tfm->status, DISKC_ST_INIT);
return 0;
}
+#ifdef USE_FREE_REQ
static void free_workq_func(struct work_struct *work)
{
struct diskcipher_alg *cra =
else
atomic_set(&fctrl->freewq_active, 0);
}
+#endif
void crypto_free_req_diskcipher(struct crypto_diskcipher *tfm)
{
+#ifdef USE_FREE_REQ
struct crypto_tfm *base = crypto_diskcipher_tfm(tfm);
struct diskcipher_alg *cra = crypto_diskcipher_alg(base->__crt_alg);
struct diskcipher_freectrl *fctrl = &cra->freectrl;
list_move_tail(&tfm->node, &fctrl->freelist);
spin_unlock_irqrestore(&fctrl->freelist_lock, flags);
crypto_diskcipher_debug(DISKC_API_FREEREQ, 0);
+#else
+ crypto_free_diskcipher(tfm);
+#endif
}
unsigned int crypto_diskcipher_extsize(struct crypto_alg *alg)
int crypto_register_diskcipher(struct diskcipher_alg *alg)
{
struct crypto_alg *base = &alg->base;
+
+#ifdef USE_FREE_REQ
struct diskcipher_freectrl *fctrl = &alg->freectrl;
INIT_LIST_HEAD(&fctrl->freelist);
spin_lock_init(&fctrl->freelist_lock);
if (!fctrl->max_io_ms)
fctrl->max_io_ms = DISKCIPHER_MAX_IO_MS;
+#endif
base->cra_type = &crypto_diskcipher_type;
base->cra_flags = CRYPTO_ALG_TYPE_DISKCIPHER;
return crypto_register_alg(base);
struct crypto_diskcipher {
u32 algo;
unsigned int ivsize;
+#ifdef USE_FREE_REQ
/* for crypto_free_req_diskcipher */
unsigned long req_jiffies;
struct list_head node;
+#endif
atomic_t status;
struct crypto_tfm base;
};
* And pass the crypto information to disk host device via bio.
* Crypt operation executes on inline crypto on disk host device.
*/
-
+#ifdef USE_FREE_REQ
struct diskcipher_freectrl {
spinlock_t freelist_lock;
struct list_head freelist;
atomic_t freewq_active;
u32 max_io_ms;
};
+#endif
struct diskcipher_alg {
int (*setkey)(struct crypto_tfm *tfm, const char *key, u32 keylen,
int (*do_crypt)(struct crypto_tfm *tfm,
struct diskcipher_test_request *req);
#endif
- struct crypto_alg base;
+#ifdef USE_FREE_REQ
struct diskcipher_freectrl freectrl;
+#endif
+ struct crypto_alg base;
};
static inline unsigned int crypto_diskcipher_ivsize(struct crypto_diskcipher *tfm)