diff options
Diffstat (limited to 'drivers/crypto/amcc')
-rw-r--r-- | drivers/crypto/amcc/crypto4xx_alg.c | 50 | ||||
-rw-r--r-- | drivers/crypto/amcc/crypto4xx_core.c | 47 | ||||
-rw-r--r-- | drivers/crypto/amcc/crypto4xx_core.h | 44 |
3 files changed, 108 insertions, 33 deletions
diff --git a/drivers/crypto/amcc/crypto4xx_alg.c b/drivers/crypto/amcc/crypto4xx_alg.c index 9d81d8f7571..79fe7ec3306 100644 --- a/drivers/crypto/amcc/crypto4xx_alg.c +++ b/drivers/crypto/amcc/crypto4xx_alg.c @@ -366,7 +366,6 @@ int crypto4xx_compute_gcm_hash_key_sw(struct crypto4xx_ctx *ctx, goto out; crypto4xx_memcpy_le(ctx->sa_in + get_dynamic_sa_offset_inner_digest(ctx), src, 16); - out: crypto_free_blkcipher(aes_tfm); return rc; @@ -471,6 +470,7 @@ static int crypto4xx_setkey_3des(struct crypto_ablkcipher *cipher, sa = (struct dynamic_sa_ctl *) ctx->sa_out; sa->sa_command_0.bf.dir = DIR_OUTBOUND; + CRYPTO4XX_DEBUG("alg %s setkey", crypto_tfm_alg_name(tfm)); return 0; } @@ -516,6 +516,8 @@ int crypto4xx_encrypt(struct ablkcipher_request *req) ctx->is_hash = 0; ctx->pd_ctl = 0x1; + CRYPTO4XX_TXLOG("encrypt %s nbytes %d", + req->base.tfm->__crt_alg->cra_name, req->nbytes); return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, req->nbytes, NULL, 0, req->info, get_dynamic_sa_iv_size(ctx)); @@ -530,6 +532,8 @@ int crypto4xx_decrypt(struct ablkcipher_request *req) ctx->pd_ctl = 0x1; ctx->direction = DIR_INBOUND; + CRYPTO4XX_TXLOG("decrypt %s nbytes %d", + req->base.tfm->__crt_alg->cra_name, req->nbytes); return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, req->nbytes, NULL, 0, req->info, get_dynamic_sa_iv_size(ctx)); @@ -545,6 +549,8 @@ int crypto4xx_encrypt_ctr(struct ablkcipher_request *req) ctx->pd_ctl = 0x1; ctx->direction = DIR_OUTBOUND; + CRYPTO4XX_TXLOG("encrypt %s nbytes %d", + req->base.tfm->__crt_alg->cra_name, req->nbytes); return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, req->nbytes, NULL, 0, req->info, @@ -561,6 +567,8 @@ int crypto4xx_decrypt_ctr(struct ablkcipher_request *req) ctx->pd_ctl = 0x1; ctx->direction = DIR_INBOUND; + CRYPTO4XX_TXLOG("decrypt %s nbytes %d", + req->base.tfm->__crt_alg->cra_name, req->nbytes); return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, req->nbytes, NULL, 0, req->info, @@ -637,6 +645,7 @@ static int crypto4xx_setkey_aes(struct crypto_ablkcipher *cipher, sa = (struct dynamic_sa_ctl *) ctx->sa_out; sa->sa_command_0.bf.dir = DIR_OUTBOUND; + CRYPTO4XX_DEBUG("alg %s setkey", crypto_tfm_alg_name(tfm)); return 0; } @@ -728,6 +737,7 @@ int crypto4xx_setkey_aes_ctr(struct crypto_ablkcipher *cipher, sa = (struct dynamic_sa_ctl *) ctx->sa_out; sa->sa_command_0.bf.dir = DIR_OUTBOUND; + CRYPTO4XX_DEBUG("alg %s setkey", crypto_tfm_alg_name(tfm)); return 0; } @@ -856,7 +866,8 @@ int crypto4xx_setkey_aes_gcm(struct crypto_aead *cipher, sa = (struct dynamic_sa_ctl *) ctx->sa_out; sa->sa_command_0.bf.dir = DIR_OUTBOUND; sa->sa_command_0.bf.opcode = SA_OPCODE_ENCRYPT_HASH; - + + CRYPTO4XX_DEBUG("alg %s setkey", crypto_tfm_alg_name(tfm)); return 0; err: crypto4xx_free_sa(ctx); @@ -871,6 +882,8 @@ int crypto4xx_encrypt_aes_gcm(struct aead_request *req) ctx->direction = DIR_OUTBOUND; ctx->append_icv = 1; + CRYPTO4XX_TXLOG("encrypt %s nbytes %d", + req->base.tfm->__crt_alg->cra_name, req->cryptlen); return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, req->cryptlen, req->assoc, req->assoclen, req->iv, crypto_aead_ivsize(aead)); @@ -882,6 +895,8 @@ int crypto4xx_decrypt_aes_gcm(struct aead_request *req) struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm); int len = req->cryptlen - crypto_aead_authsize(aead); + CRYPTO4XX_TXLOG("decrypt %s nbytes %d", + req->base.tfm->__crt_alg->cra_name, req->cryptlen); ctx->direction = DIR_INBOUND; ctx->append_icv = 0; return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, @@ -993,7 +1008,7 @@ int crypto4xx_setkey_aes_ccm(struct crypto_aead *cipher, const u8 *key, SA_SEQ_MASK_OFF, SA_MC_ENABLE, SA_NOT_COPY_PAD, SA_COPY_PAYLOAD, SA_NOT_COPY_HDR); - + CRYPTO4XX_DEBUG("alg %s setkey", crypto_tfm_alg_name(tfm)); return 0; } @@ -1153,6 +1168,7 @@ int crypto4xx_setkey_kasumi(struct crypto_ablkcipher *cipher, sa = (struct dynamic_sa_ctl *) ctx->sa_out; sa->sa_command_0.bf.dir = DIR_OUTBOUND; + CRYPTO4XX_DEBUG("alg %s setkey", crypto_tfm_alg_name(tfm)); return 0; } @@ -1185,6 +1201,8 @@ int crypto4xx_encrypt_kasumi(struct ablkcipher_request *req) ctx->direction = DIR_OUTBOUND; ctx->pd_ctl = 0x1; + CRYPTO4XX_TXLOG("encrypt %s nbytes %d", + req->base.tfm->__crt_alg->cra_name, req->nbytes); return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst, req->nbytes, NULL, 0, NULL, 0); } @@ -1315,7 +1333,7 @@ int crypto4xx_setkey_arc4(struct crypto_ablkcipher *cipher, sa = (struct dynamic_sa_ctl *) ctx->sa_out; sa->sa_command_0.bf.dir = DIR_OUTBOUND; - + CRYPTO4XX_DEBUG("alg %s setkey", crypto_tfm_alg_name(tfm)); return 0; } @@ -1460,6 +1478,11 @@ int crypto4xx_hash_digest(struct ahash_request *req) ctx->pd_ctl = 0x11; ctx->direction = DIR_INBOUND; +#if 0 + ESP_PHD(KERN_CONT, "", DUMP_PREFIX_OFFSET, + 16, 1, + (void*)req, sizeof(struct ahash_request), false); +#endif return crypto4xx_build_pd(&req->base, ctx, req->src, (struct scatterlist *) req->result, req->nbytes, NULL, 0, NULL, 0); @@ -1550,7 +1573,8 @@ int crypto4xx_hash_hmac_setkey(struct crypto_ahash *hash, memcpy(ctx->sa_out, ctx->sa_in, ctx->sa_len * 4); sa = (struct dynamic_sa_ctl *) ctx->sa_out; sa->sa_command_0.bf.dir = DIR_OUTBOUND; - + + CRYPTO4XX_DEBUG("alg %s setkey", crypto_tfm_alg_name(tfm)); return 0; err: crypto4xx_free_sa(ctx); @@ -1799,7 +1823,7 @@ int crypto4xx_xcbc_setkey(struct crypto_ahash *hash, memcpy(ctx->sa_out, ctx->sa_in, ctx->sa_len * 4); sa = (struct dynamic_sa_ctl *) ctx->sa_out; sa->sa_command_0.bf.dir = DIR_OUTBOUND; - + CRYPTO4XX_DEBUG("alg %s setkey", crypto_tfm_alg_name(tfm)); return 0; err: crypto4xx_free_sa(ctx); @@ -1872,7 +1896,7 @@ int crypto4xx_kasumi_f9_setkey(struct crypto_ahash *hash, ctx->hash_final = 1; ctx->pd_ctl = 0x11; ctx->bypass = 4; - + CRYPTO4XX_DEBUG("alg %s setkey", crypto_tfm_alg_name(tfm)); return 0; } @@ -2093,7 +2117,7 @@ int crypto4xx_setkey_esp_tunnel(struct crypto_aead *cipher, ctx->is_hash = 0; ctx->pad_ctl = param->pad_block_size/4; ctx->append_icv = 0; - + CRYPTO4XX_DEBUG("alg %s setkey", crypto_tfm_alg_name(tfm)); return 0; err_nomem_sr: @@ -3021,7 +3045,7 @@ int crypto4xx_setkey_macsec_gcm(struct crypto_aead *cipher, ctx->hash_final = 1; ctx->is_hash = 0; ctx->bypass = 0; - + CRYPTO4XX_DEBUG("alg %s setkey", crypto_tfm_alg_name(tfm)); return 0; err_nomem_sr: @@ -3177,6 +3201,7 @@ static int crypto4xx_setkey_dtls(struct crypto_aead *cipher, CRYPTO_FEEDBACK_MODE_NO_FB, SA_EXTENDED_SN_ON, SA_SEQ_MASK_OFF, SA_MC_ENABLE, SA_COPY_PAD, SA_COPY_PAYLOAD, SA_COPY_HDR); + CRYPTO4XX_DEBUG("alg %s setkey", crypto_tfm_alg_name(tfm)); return 0; err_nomem_sr: @@ -3413,7 +3438,7 @@ static int crypto4xx_setkey_ssl_tls(struct crypto_aead *cipher, SA_COPY_PAD, SA_COPY_PAYLOAD, SA_COPY_HDR); - + CRYPTO4XX_DEBUG("alg %s setkey", crypto_tfm_alg_name(tfm)); return 0; err_nomem_sr: @@ -3617,7 +3642,8 @@ int crypto4xx_setkey_ssl_tls_arc4(struct crypto_aead *cipher, sa->sa_command_1.bf.arc4_stateful = 1; sa->sa_command_1.bf.save_arc4_state = 1; - + + CRYPTO4XX_DEBUG("alg %s setkey", crypto_tfm_alg_name(tfm)); return 0; err_nomem_arc4: @@ -4070,11 +4096,11 @@ int crypto4xx_setkey_transport_esp_rfc4106_gcm(struct crypto_aead *cipher, ctx->authenc = 0; ctx->hash_final = 1; ctx->is_hash = 0; - printk("param->pad_block_size = %d\n", param->pad_block_size); //ctx->pad_ctl = param->pad_block_size / 4; ctx->pad_ctl = 0x08; ctx->append_icv = 0; + CRYPTO4XX_DEBUG("alg %s setkey", crypto_tfm_alg_name(tfm)); return 0; err_nomem_sr: diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c index 8c00e30e9e6..f1721e85770 100644 --- a/drivers/crypto/amcc/crypto4xx_core.c +++ b/drivers/crypto/amcc/crypto4xx_core.c @@ -1279,9 +1279,10 @@ u32 crypto4xx_build_pd(struct crypto_async_request *req, */ crypto4xx_memcpy_le(pd_uinfo->sr_va + CTR_RFC3686_NONCE_SIZE, iv, iv_len); - } else + } else { crypto4xx_memcpy_le(pd_uinfo->sr_va, iv, iv_len); + } } if (ctx->is_gcm || ctx->ctr_aes) { u32 seq = 1; @@ -1444,14 +1445,15 @@ u32 crypto4xx_build_pd(struct crypto_async_request *req, pd_uinfo->state = PD_ENTRY_INUSE; wmb(); /* write any value to push engine to read a pd */ + if (dev->core_dev->revb_ver == 1) { #ifndef CONFIG_SEC_HW_POLL writel(1, dev->ce_base + CRYPTO4XX_INT_DESCR_RD); #endif - } else + } else { writel(1, dev->ce_base + CRYPTO4XX_INT_DESCR_RD); + } - dev->pkt_cnt++; return -EINPROGRESS; } @@ -1596,14 +1598,16 @@ static irqreturn_t crypto4xx_ce_interrupt_handler(int irq, void *data) { struct device *dev = (struct device *)data; struct crypto4xx_core_device *core_dev = dev_get_drvdata(dev); - //u32 int_status; + u32 int_status, dev_status; if (core_dev->dev->ce_base == 0) return 0; - //int_status = readl(core_dev->dev->ce_base + CRYPTO4XX_INT_UNMASK_STAT); - //printk("Interrupt status = 0x%08x\n", int_status); + int_status = readl(core_dev->dev->ce_base + CRYPTO4XX_INT_UNMASK_STAT); + printk("Interrupt status = 0x%08x\n", int_status); + dev_status = readl(core_dev->dev->ce_base + CRYPTO4XX_DEVICE_INFO); + printk("dev status = 0x%08x\n", dev_status); /* For RevB, 460EX and 460ExR Rev B */ if (core_dev->revb_ver == 1) { writel(PPC4XX_INTERRUPT_CLR_REVB, @@ -1625,7 +1629,7 @@ static irqreturn_t crypto4xx_ce_interrupt_handler(int irq, void *data) */ struct crypto4xx_alg_common crypto4xx_alg[] = { /* Crypto DES ECB, CBC, modes */ -#if 1 +#if 0 { .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .u.cipher = { .cra_name = "cbc(des)", .cra_driver_name = "ppc4xx-cbc-des", @@ -1885,6 +1889,7 @@ struct crypto4xx_alg_common crypto4xx_alg[] = { } } }}, +#endif /* Hash MD5 */ { .type = CRYPTO_ALG_TYPE_AHASH, .u.hash = { @@ -1907,8 +1912,8 @@ struct crypto4xx_alg_common crypto4xx_alg[] = { .cra_module = THIS_MODULE, } }}, -#endif -#if 1 + +#if 0 /* Hash MD5-HMAC */ { .type = CRYPTO_ALG_TYPE_AHASH, .u.hash = { .init = crypto4xx_hash_init, @@ -1972,7 +1977,7 @@ struct crypto4xx_alg_common crypto4xx_alg[] = { } }}, -#if 1 +#if 0 { .type = CRYPTO_ALG_TYPE_AHASH, .u.hash = { .init = crypto4xx_hash_init, .update = crypto4xx_hash_update, @@ -2117,7 +2122,7 @@ struct crypto4xx_alg_common crypto4xx_alg[] = { } }}, #endif -#if 1 +#if 0 { .type = CRYPTO_ALG_TYPE_AHASH, .u.hash = { .init = crypto4xx_hash_init, .update = crypto4xx_hash_update, @@ -2157,7 +2162,7 @@ struct crypto4xx_alg_common crypto4xx_alg[] = { .cra_module = THIS_MODULE, } }}, - +#endif /* Crypto Kasumi and Kasumi F8 */ { .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .u.cipher = { .cra_name = "kasumi", @@ -2224,8 +2229,8 @@ struct crypto4xx_alg_common crypto4xx_alg[] = { .cra_module = THIS_MODULE, } }}, -#endif -#if 1 + +#if 0 /* Crypto ARC4 - stateless */ { .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .u.cipher = { .cra_name = "ecb(arc4)", @@ -2273,7 +2278,7 @@ struct crypto4xx_alg_common crypto4xx_alg[] = { } }}, #endif -#if 1 +#if 0 /* IPSec combined hash and crypto Algorithms */ { .type = CRYPTO_ALG_TYPE_AEAD, .u.cipher = { .cra_name = "tunnel(esp(authenc(hmac(md5),cbc(aes))))", @@ -2323,7 +2328,7 @@ struct crypto4xx_alg_common crypto4xx_alg[] = { } }}, #endif -#if 1 +#if 0 /* IPSec combined hash and crypto Algorithms */ { .type = CRYPTO_ALG_TYPE_AEAD, .u.cipher = { .cra_name = "tunnel(esp(authenc(hmac(sha224),cbc(aes))))", @@ -2349,7 +2354,7 @@ struct crypto4xx_alg_common crypto4xx_alg[] = { } }}, #endif -#if 1 +#if 0 /* IPSec combined hash and crypto Algorithms */ { .type = CRYPTO_ALG_TYPE_AEAD, .u.cipher = { .cra_name = "tunnel(esp(authenc(hmac(sha256),cbc(aes))))", @@ -3108,7 +3113,7 @@ struct crypto4xx_alg_common crypto4xx_alg[] = { } }}, #endif -#if 1 +#if 0 /* IPSec combined hash and crypto Algorithms */ { .type = CRYPTO_ALG_TYPE_AEAD, .u.cipher = { .cra_name = "transport(esp(authenc(hmac(sha256),cbc(des3_ede))))", @@ -3251,7 +3256,7 @@ struct crypto4xx_alg_common crypto4xx_alg[] = { } }}, #endif -#if 1 +#if 0 { .type = CRYPTO_ALG_TYPE_AEAD, .u.cipher = { .cra_name = "dtls(aes-sha1)", .cra_driver_name = "dtls-ppc4xx", @@ -3278,7 +3283,7 @@ struct crypto4xx_alg_common crypto4xx_alg[] = { } }}, #endif -#if 1 +#if 0 { .type = CRYPTO_ALG_TYPE_AEAD, .u.cipher = { .cra_name = "dtls(des-sha1)", .cra_driver_name = "ppc4xx-dtls-des-sha1", @@ -3305,7 +3310,7 @@ struct crypto4xx_alg_common crypto4xx_alg[] = { } }}, #endif -#if 1 +#if 0 { .type = CRYPTO_ALG_TYPE_AEAD, .u.cipher = { .cra_name = "dtls(des3-sha1)", .cra_driver_name = "ppc4xx-dtls-des3-sha1", diff --git a/drivers/crypto/amcc/crypto4xx_core.h b/drivers/crypto/amcc/crypto4xx_core.h index 658a2416294..fea57ff139e 100644 --- a/drivers/crypto/amcc/crypto4xx_core.h +++ b/drivers/crypto/amcc/crypto4xx_core.h @@ -50,6 +50,50 @@ #define PD_ENTRY_FREE 0 #define ERING_WAS_FULL 0xffffffff +#if 0 +#define CRYPTO4XX_DEBUG_LOG +#define CRYPTO4XX_TXDEBUG +#endif + +/* Debugging Macro */ +#define CRYPTO4XX_HDR "CRYPTO4XX: " + +#define CRYPTO4XX_ERR(fmt, ...) \ + printk(KERN_ERR CRYPTO4XX_HDR fmt "\n", ##__VA_ARGS__); +#define CRYPTO4XX_LOG(fmt, ...) \ + printk(KERN_INFO CRYPTO4XX_HDR fmt "\n", ##__VA_ARGS__); + +#if !defined(CRYPTO4XX_TXDEBUG) +# define CRYPTO4XX_TXLOG(fmt, ...) +# define CRYPTO4XX_TXDUMP(hdr, d, l) +#else +# define CRYPTO4XX_TXLOG(fmt, ...) \ + do { \ + printk(KERN_INFO CRYPTO4XX_HDR fmt "\n", ##__VA_ARGS__); \ +} while(0); +# define CRYPTO4XX_TXDUMP(hdr, d, l) \ + do { \ + print_hex_dump(KERN_INFO, CRYPTO4XX_HDR hdr, \ + DUMP_PREFIX_ADDRESS, 16, 4, d, l, 1); \ +} while(0); +#endif + +#if !defined(CRYPTO4XX_DEBUG_LOG) +# define CRYPTO4XX_DEBUG(fmt, ...) +# define CRYPTO4XX_DEBUG_DUMP(hdr, fmt, ...) +#else +# define CRYPTO4XX_DEBUG(fmt, ...) \ + do { \ + printk(KERN_INFO CRYPTO4XX_HDR fmt "\n", ##__VA_ARGS__); \ +} while(0); +# define CRYPTO4XX_DEBUG_DUMP(hdr, d, l) \ + do { \ + print_hex_dump(KERN_INFO, CRYPTO4XX_HDR hdr, \ + DUMP_PREFIX_ADDRESS, 16, 4, d, l, 1); \ +} while(0); +#endif + + struct crypto4xx_device; struct pd_uinfo { |