linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] Bug fixes
@ 2017-01-27 10:39 Harsh Jain
  2017-01-27 10:39 ` [PATCH 1/8] crypto:chcr-Change flow IDs Harsh Jain
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Harsh Jain @ 2017-01-27 10:39 UTC (permalink / raw)
  To: herbert, linux-crypto, hariprasad, netdev, arjun, atul.gupta; +Cc: Harsh Jain

This patch series is based on Herbert's cryptodev-2.6 tree and depends on 
patch series "Bug Fixes for 4.10". It includes Bug Fixes.

Atul Gupta (2)
  crypto:chcr-Change flow IDs
  crypto:chcr- Fix wrong typecasting
Harsh Jain (8):
  crypto:chcr- Fix key length for RFC4106
  crypto:chcr-fix itnull.cocci warnings
  crypto:chcr- Use cipher instead of Block Cipher in gcm setkey
  crypto:chcr: Change cra_flags for cipher algos
  crypto:chcr- Change algo priority
  crypto:chcr-Fix Smatch Complaint

 drivers/crypto/chelsio/chcr_algo.c            | 53 ++++++++++++++-------------
 drivers/crypto/chelsio/chcr_algo.h            |  9 +++--
 drivers/crypto/chelsio/chcr_core.c            | 11 +++---
 drivers/crypto/chelsio/chcr_core.h            |  1 +
 drivers/crypto/chelsio/chcr_crypto.h          |  2 +-
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h |  8 ++++
 6 files changed, 47 insertions(+), 37 deletions(-)
 mode change 100644 => 100755 drivers/crypto/chelsio/chcr_algo.c

-- 
1.8.2.3

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/8] crypto:chcr-Change flow IDs
  2017-01-27 10:39 [PATCH 0/8] Bug fixes Harsh Jain
@ 2017-01-27 10:39 ` Harsh Jain
  2017-01-27 10:39 ` [PATCH 2/8] crypto:chcr- Fix key length for RFC4106 Harsh Jain
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Harsh Jain @ 2017-01-27 10:39 UTC (permalink / raw)
  To: herbert, linux-crypto, hariprasad, netdev, arjun, atul.gupta; +Cc: Harsh Jain

Change assign flowc id to each outgoing request.Firmware use flowc id
to schedule each request onto HW. FW reply may miss without this change.

Reviewed-by: Hariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: Atul Gupta <atul.gupta@chelsio.com>
---
 drivers/crypto/chelsio/chcr_algo.c            | 18 ++++++++++--------
 drivers/crypto/chelsio/chcr_algo.h            |  9 +++++----
 drivers/crypto/chelsio/chcr_core.h            |  1 +
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h |  8 ++++++++
 4 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
index d29c2b4..deec7c0 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -542,10 +542,11 @@ static inline void create_wreq(struct chcr_context *ctx,
 				    (calc_tx_flits_ofld(skb) * 8), 16)));
 	chcr_req->wreq.cookie = cpu_to_be64((uintptr_t)req);
 	chcr_req->wreq.rx_chid_to_rx_q_id =
-		FILL_WR_RX_Q_ID(ctx->dev->tx_channel_id, qid,
-				is_iv ? iv_loc : IV_NOP);
+		FILL_WR_RX_Q_ID(ctx->dev->rx_channel_id, qid,
+				is_iv ? iv_loc : IV_NOP, ctx->tx_channel_id);
 
-	chcr_req->ulptx.cmd_dest = FILL_ULPTX_CMD_DEST(ctx->dev->tx_channel_id);
+	chcr_req->ulptx.cmd_dest = FILL_ULPTX_CMD_DEST(ctx->dev->tx_channel_id,
+						       qid);
 	chcr_req->ulptx.len = htonl((DIV_ROUND_UP((calc_tx_flits_ofld(skb) * 8),
 					16) - ((sizeof(chcr_req->wreq)) >> 4)));
 
@@ -606,7 +607,7 @@ static inline void create_wreq(struct chcr_context *ctx,
 	chcr_req = (struct chcr_wr *)__skb_put(skb, transhdr_len);
 	memset(chcr_req, 0, transhdr_len);
 	chcr_req->sec_cpl.op_ivinsrtofst =
-		FILL_SEC_CPL_OP_IVINSR(ctx->dev->tx_channel_id, 2, 1);
+		FILL_SEC_CPL_OP_IVINSR(ctx->dev->rx_channel_id, 2, 1);
 
 	chcr_req->sec_cpl.pldlen = htonl(ivsize + req->nbytes);
 	chcr_req->sec_cpl.aadstart_cipherstop_hi =
@@ -782,6 +783,7 @@ static int chcr_device_init(struct chcr_context *ctx)
 		spin_lock(&ctx->dev->lock_chcr_dev);
 		ctx->tx_channel_id = rxq_idx;
 		ctx->dev->tx_channel_id = !ctx->dev->tx_channel_id;
+		ctx->dev->rx_channel_id = 0;
 		spin_unlock(&ctx->dev->lock_chcr_dev);
 	}
 out:
@@ -874,7 +876,7 @@ static struct sk_buff *create_hash_wr(struct ahash_request *req,
 	memset(chcr_req, 0, transhdr_len);
 
 	chcr_req->sec_cpl.op_ivinsrtofst =
-		FILL_SEC_CPL_OP_IVINSR(ctx->dev->tx_channel_id, 2, 0);
+		FILL_SEC_CPL_OP_IVINSR(ctx->dev->rx_channel_id, 2, 0);
 	chcr_req->sec_cpl.pldlen = htonl(param->bfr_len + param->sg_len);
 
 	chcr_req->sec_cpl.aadstart_cipherstop_hi =
@@ -1425,7 +1427,7 @@ static struct sk_buff *create_authenc_wr(struct aead_request *req,
 	 * to the hardware spec
 	 */
 	chcr_req->sec_cpl.op_ivinsrtofst =
-		FILL_SEC_CPL_OP_IVINSR(ctx->dev->tx_channel_id, 2,
+		FILL_SEC_CPL_OP_IVINSR(ctx->dev->rx_channel_id, 2,
 				       (ivsize ? (assoclen + 1) : 0));
 	chcr_req->sec_cpl.pldlen = htonl(assoclen + ivsize + req->cryptlen);
 	chcr_req->sec_cpl.aadstart_cipherstop_hi = FILL_SEC_CPL_CIPHERSTOP_HI(
@@ -1601,7 +1603,7 @@ static void fill_sec_cpl_for_aead(struct cpl_tx_sec_pdu *sec_cpl,
 	unsigned int ivsize = AES_BLOCK_SIZE;
 	unsigned int cipher_mode = CHCR_SCMD_CIPHER_MODE_AES_CCM;
 	unsigned int mac_mode = CHCR_SCMD_AUTH_MODE_CBCMAC;
-	unsigned int c_id = chcrctx->dev->tx_channel_id;
+	unsigned int c_id = chcrctx->dev->rx_channel_id;
 	unsigned int ccm_xtra;
 	unsigned char tag_offset = 0, auth_offset = 0;
 	unsigned char hmac_ctrl = get_hmac(crypto_aead_authsize(tfm));
@@ -1877,7 +1879,7 @@ static struct sk_buff *create_gcm_wr(struct aead_request *req,
 
 	tag_offset = (op_type == CHCR_ENCRYPT_OP) ? 0 : authsize;
 	chcr_req->sec_cpl.op_ivinsrtofst = FILL_SEC_CPL_OP_IVINSR(
-					ctx->dev->tx_channel_id, 2, (ivsize ?
+					ctx->dev->rx_channel_id, 2, (ivsize ?
 					(req->assoclen + 1) : 0));
 	chcr_req->sec_cpl.pldlen = htonl(req->assoclen + ivsize + crypt_len);
 	chcr_req->sec_cpl.aadstart_cipherstop_hi = FILL_SEC_CPL_CIPHERSTOP_HI(
diff --git a/drivers/crypto/chelsio/chcr_algo.h b/drivers/crypto/chelsio/chcr_algo.h
index 3c7c51f..ba38bae 100644
--- a/drivers/crypto/chelsio/chcr_algo.h
+++ b/drivers/crypto/chelsio/chcr_algo.h
@@ -185,20 +185,21 @@
 			FW_CRYPTO_LOOKASIDE_WR_CCTX_LOC_V(1) | \
 			FW_CRYPTO_LOOKASIDE_WR_CCTX_SIZE_V((ctx_len)))
 
-#define FILL_WR_RX_Q_ID(cid, qid, wr_iv) \
+#define FILL_WR_RX_Q_ID(cid, qid, wr_iv, fid) \
 		htonl( \
 			FW_CRYPTO_LOOKASIDE_WR_RX_CHID_V((cid)) | \
 			FW_CRYPTO_LOOKASIDE_WR_RX_Q_ID_V((qid)) | \
 			FW_CRYPTO_LOOKASIDE_WR_LCB_V(0) | \
-			FW_CRYPTO_LOOKASIDE_WR_IV_V((wr_iv)))
+			FW_CRYPTO_LOOKASIDE_WR_IV_V((wr_iv)) | \
+			FW_CRYPTO_LOOKASIDE_WR_FQIDX_V(fid))
 
-#define FILL_ULPTX_CMD_DEST(cid) \
+#define FILL_ULPTX_CMD_DEST(cid, qid) \
 	htonl(ULPTX_CMD_V(ULP_TX_PKT) | \
 	      ULP_TXPKT_DEST_V(0) | \
 	      ULP_TXPKT_DATAMODIFY_V(0) | \
 	      ULP_TXPKT_CHANNELID_V((cid)) | \
 	      ULP_TXPKT_RO_V(1) | \
-	      ULP_TXPKT_FID_V(0))
+	      ULP_TXPKT_FID_V(qid))
 
 #define KEYCTX_ALIGN_PAD(bs) ({unsigned int _bs = (bs);\
 			      _bs == SHA1_DIGEST_SIZE ? 12 : 0; })
diff --git a/drivers/crypto/chelsio/chcr_core.h b/drivers/crypto/chelsio/chcr_core.h
index c7088a4..79da22b 100644
--- a/drivers/crypto/chelsio/chcr_core.h
+++ b/drivers/crypto/chelsio/chcr_core.h
@@ -75,6 +75,7 @@ struct chcr_dev {
 	spinlock_t lock_chcr_dev;
 	struct uld_ctx *u_ctx;
 	unsigned char tx_channel_id;
+	unsigned char rx_channel_id;
 };
 
 struct uld_ctx {
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
index 8d9e4b7..ccc05f8 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
@@ -3385,6 +3385,14 @@ struct fw_crypto_lookaside_wr {
 #define FW_CRYPTO_LOOKASIDE_WR_IV_G(x) \
 	(((x) >> FW_CRYPTO_LOOKASIDE_WR_IV_S) & FW_CRYPTO_LOOKASIDE_WR_IV_M)
 
+#define FW_CRYPTO_LOOKASIDE_WR_FQIDX_S   15
+#define FW_CRYPTO_LOOKASIDE_WR_FQIDX_M   0xff
+#define FW_CRYPTO_LOOKASIDE_WR_FQIDX_V(x) \
+	((x) << FW_CRYPTO_LOOKASIDE_WR_FQIDX_S)
+#define FW_CRYPTO_LOOKASIDE_WR_FQIDX_G(x) \
+	(((x) >> FW_CRYPTO_LOOKASIDE_WR_FQIDX_S) & \
+	 FW_CRYPTO_LOOKASIDE_WR_FQIDX_M)
+
 #define FW_CRYPTO_LOOKASIDE_WR_TX_CH_S 10
 #define FW_CRYPTO_LOOKASIDE_WR_TX_CH_M 0x3
 #define FW_CRYPTO_LOOKASIDE_WR_TX_CH_V(x) \
-- 
1.8.2.3

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/8] crypto:chcr- Fix key length for RFC4106
  2017-01-27 10:39 [PATCH 0/8] Bug fixes Harsh Jain
  2017-01-27 10:39 ` [PATCH 1/8] crypto:chcr-Change flow IDs Harsh Jain
@ 2017-01-27 10:39 ` Harsh Jain
  2017-01-27 10:39 ` [PATCH 3/8] crypto:chcr-fix itnull.cocci warnings Harsh Jain
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Harsh Jain @ 2017-01-27 10:39 UTC (permalink / raw)
  To: herbert, linux-crypto, hariprasad, netdev, arjun, atul.gupta; +Cc: Harsh Jain

Check keylen before copying salt to avoid wrap around of Integer.

Signed-off-by: Harsh Jain <harsh@chelsio.com>
---
 drivers/crypto/chelsio/chcr_algo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
index deec7c0..6c2dea3 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -2194,8 +2194,8 @@ static int chcr_gcm_setkey(struct crypto_aead *aead, const u8 *key,
 	unsigned int ck_size;
 	int ret = 0, key_ctx_size = 0;
 
-	if (get_aead_subtype(aead) ==
-	    CRYPTO_ALG_SUB_TYPE_AEAD_RFC4106) {
+	if (get_aead_subtype(aead) == CRYPTO_ALG_SUB_TYPE_AEAD_RFC4106 &&
+	    keylen > 3) {
 		keylen -= 4;  /* nonce/salt is present in the last 4 bytes */
 		memcpy(aeadctx->salt, key + keylen, 4);
 	}
-- 
1.8.2.3

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 3/8] crypto:chcr-fix itnull.cocci warnings
  2017-01-27 10:39 [PATCH 0/8] Bug fixes Harsh Jain
  2017-01-27 10:39 ` [PATCH 1/8] crypto:chcr-Change flow IDs Harsh Jain
  2017-01-27 10:39 ` [PATCH 2/8] crypto:chcr- Fix key length for RFC4106 Harsh Jain
@ 2017-01-27 10:39 ` Harsh Jain
  2017-01-27 10:39 ` [PATCH 4/8] crypto:chcr- Use cipher instead of Block Cipher in gcm setkey Harsh Jain
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Harsh Jain @ 2017-01-27 10:39 UTC (permalink / raw)
  To: herbert, linux-crypto, hariprasad, netdev, arjun, atul.gupta
  Cc: Harsh Jain, Julia Lawall, Fengguang Wu

The first argument to list_for_each_entry cannot be NULL.

Generated by: scripts/coccinelle/iterators/itnull.cocci

Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Harsh Jain <harsh@chelsio.com>
---
 drivers/crypto/chelsio/chcr_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/chelsio/chcr_core.c b/drivers/crypto/chelsio/chcr_core.c
index 1c65f07..2bfd61a 100644
--- a/drivers/crypto/chelsio/chcr_core.c
+++ b/drivers/crypto/chelsio/chcr_core.c
@@ -61,7 +61,7 @@ int assign_chcr_device(struct chcr_dev **dev)
 	 */
 	mutex_lock(&dev_mutex); /* TODO ? */
 	list_for_each_entry(u_ctx, &uld_ctx_list, entry)
-		if (u_ctx && u_ctx->dev) {
+		if (u_ctx->dev) {
 			*dev = u_ctx->dev;
 			ret = 0;
 			break;
-- 
1.8.2.3

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 4/8] crypto:chcr- Use cipher instead of Block Cipher in gcm setkey
  2017-01-27 10:39 [PATCH 0/8] Bug fixes Harsh Jain
                   ` (2 preceding siblings ...)
  2017-01-27 10:39 ` [PATCH 3/8] crypto:chcr-fix itnull.cocci warnings Harsh Jain
@ 2017-01-27 10:39 ` Harsh Jain
  2017-01-27 10:39 ` [PATCH 5/8] crypto:chcr: Change cra_flags for cipher algos Harsh Jain
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Harsh Jain @ 2017-01-27 10:39 UTC (permalink / raw)
  To: herbert, linux-crypto, hariprasad, netdev, arjun, atul.gupta; +Cc: Harsh Jain

1 Block of encrption can be done with aes-generic. no need of
cbc(aes). This patch replaces cbc(aes-generic) with aes-generic.

Signed-off-by: Harsh Jain <harsh@chelsio.com>
---
 drivers/crypto/chelsio/chcr_algo.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
index 6c2dea3..d335943 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -2189,8 +2189,7 @@ static int chcr_gcm_setkey(struct crypto_aead *aead, const u8 *key,
 	struct chcr_context *ctx = crypto_aead_ctx(aead);
 	struct chcr_aead_ctx *aeadctx = AEAD_CTX(ctx);
 	struct chcr_gcm_ctx *gctx = GCM_CTX(aeadctx);
-	struct blkcipher_desc h_desc;
-	struct scatterlist src[1];
+	struct crypto_cipher *cipher;
 	unsigned int ck_size;
 	int ret = 0, key_ctx_size = 0;
 
@@ -2223,27 +2222,26 @@ static int chcr_gcm_setkey(struct crypto_aead *aead, const u8 *key,
 						CHCR_KEYCTX_MAC_KEY_SIZE_128,
 						0, 0,
 						key_ctx_size >> 4);
-	/* Calculate the H = CIPH(K, 0 repeated 16 times) using sync aes
-	 * blkcipher It will go on key context
+	/* Calculate the H = CIPH(K, 0 repeated 16 times).
+	 * It will go in key context
 	 */
-	h_desc.tfm = crypto_alloc_blkcipher("cbc(aes-generic)", 0, 0);
-	if (IS_ERR(h_desc.tfm)) {
+	cipher = crypto_alloc_cipher("aes-generic", 0, 0);
+	if (IS_ERR(cipher)) {
 		aeadctx->enckey_len = 0;
 		ret = -ENOMEM;
 		goto out;
 	}
-	h_desc.flags = 0;
-	ret = crypto_blkcipher_setkey(h_desc.tfm, key, keylen);
+
+	ret = crypto_cipher_setkey(cipher, key, keylen);
 	if (ret) {
 		aeadctx->enckey_len = 0;
 		goto out1;
 	}
 	memset(gctx->ghash_h, 0, AEAD_H_SIZE);
-	sg_init_one(&src[0], gctx->ghash_h, AEAD_H_SIZE);
-	ret = crypto_blkcipher_encrypt(&h_desc, &src[0], &src[0], AEAD_H_SIZE);
+	crypto_cipher_encrypt_one(cipher, gctx->ghash_h, gctx->ghash_h);
 
 out1:
-	crypto_free_blkcipher(h_desc.tfm);
+	crypto_free_cipher(cipher);
 out:
 	return ret;
 }
-- 
1.8.2.3

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 5/8] crypto:chcr: Change cra_flags for cipher algos
  2017-01-27 10:39 [PATCH 0/8] Bug fixes Harsh Jain
                   ` (3 preceding siblings ...)
  2017-01-27 10:39 ` [PATCH 4/8] crypto:chcr- Use cipher instead of Block Cipher in gcm setkey Harsh Jain
@ 2017-01-27 10:39 ` Harsh Jain
  2017-03-08  9:58   ` Harsh Jain
  2017-01-27 10:39 ` [PATCH 6/8] crypto:chcr- Change algo priority Harsh Jain
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 12+ messages in thread
From: Harsh Jain @ 2017-01-27 10:39 UTC (permalink / raw)
  To: herbert, linux-crypto, hariprasad, netdev, arjun, atul.gupta; +Cc: Harsh Jain

Change cipher algos flags to CRYPTO_ALG_TYPE_ABLKCIPHER.

Signed-off-by: Harsh Jain <harsh@chelsio.com>
---
 drivers/crypto/chelsio/chcr_algo.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
index d335943..21fc04c 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -171,7 +171,7 @@ int chcr_handle_resp(struct crypto_async_request *req, unsigned char *input,
 		}
 		break;
 
-	case CRYPTO_ALG_TYPE_BLKCIPHER:
+	case CRYPTO_ALG_TYPE_ABLKCIPHER:
 		ctx_req.req.ablk_req = (struct ablkcipher_request *)req;
 		ctx_req.ctx.ablk_ctx =
 			ablkcipher_request_ctx(ctx_req.req.ablk_req);
@@ -2492,7 +2492,7 @@ static int chcr_aead_op(struct aead_request *req,
 			.cra_name		= "cbc(aes)",
 			.cra_driver_name	= "cbc-aes-chcr",
 			.cra_priority		= CHCR_CRA_PRIORITY,
-			.cra_flags		= CRYPTO_ALG_TYPE_BLKCIPHER |
+			.cra_flags		= CRYPTO_ALG_TYPE_ABLKCIPHER |
 				CRYPTO_ALG_ASYNC,
 			.cra_blocksize		= AES_BLOCK_SIZE,
 			.cra_ctxsize		= sizeof(struct chcr_context)
@@ -2519,7 +2519,7 @@ static int chcr_aead_op(struct aead_request *req,
 			.cra_name		= "xts(aes)",
 			.cra_driver_name	= "xts-aes-chcr",
 			.cra_priority		= CHCR_CRA_PRIORITY,
-			.cra_flags		= CRYPTO_ALG_TYPE_BLKCIPHER |
+			.cra_flags		= CRYPTO_ALG_TYPE_ABLKCIPHER |
 				CRYPTO_ALG_ASYNC,
 			.cra_blocksize		= AES_BLOCK_SIZE,
 			.cra_ctxsize		= sizeof(struct chcr_context) +
-- 
1.8.2.3

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 6/8] crypto:chcr- Change algo priority
  2017-01-27 10:39 [PATCH 0/8] Bug fixes Harsh Jain
                   ` (4 preceding siblings ...)
  2017-01-27 10:39 ` [PATCH 5/8] crypto:chcr: Change cra_flags for cipher algos Harsh Jain
@ 2017-01-27 10:39 ` Harsh Jain
  2017-01-27 10:39 ` [PATCH 7/8] crypto:chcr- Fix wrong typecasting Harsh Jain
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Harsh Jain @ 2017-01-27 10:39 UTC (permalink / raw)
  To: herbert, linux-crypto, hariprasad, netdev, arjun, atul.gupta; +Cc: Harsh Jain

Update priorities to 3000

Signed-off-by: Harsh Jain <harsh@chelsio.com>
---
 drivers/crypto/chelsio/chcr_crypto.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/chelsio/chcr_crypto.h b/drivers/crypto/chelsio/chcr_crypto.h
index 7ec0a8f..81cfd0b 100644
--- a/drivers/crypto/chelsio/chcr_crypto.h
+++ b/drivers/crypto/chelsio/chcr_crypto.h
@@ -48,7 +48,7 @@
  * giving the processed data
  */
 
-#define CHCR_CRA_PRIORITY 300
+#define CHCR_CRA_PRIORITY 3000
 
 #define CHCR_AES_MAX_KEY_LEN  (2 * (AES_MAX_KEY_SIZE)) /* consider xts */
 #define CHCR_MAX_CRYPTO_IV_LEN 16 /* AES IV len */
-- 
1.8.2.3

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 7/8] crypto:chcr- Fix wrong typecasting
  2017-01-27 10:39 [PATCH 0/8] Bug fixes Harsh Jain
                   ` (5 preceding siblings ...)
  2017-01-27 10:39 ` [PATCH 6/8] crypto:chcr- Change algo priority Harsh Jain
@ 2017-01-27 10:39 ` Harsh Jain
  2017-01-27 10:39 ` [PATCH 8/8] crypto:chcr-Fix Smatch Complaint Harsh Jain
  2017-02-03 10:21 ` [PATCH 0/8] Bug fixes Herbert Xu
  8 siblings, 0 replies; 12+ messages in thread
From: Harsh Jain @ 2017-01-27 10:39 UTC (permalink / raw)
  To: herbert, linux-crypto, hariprasad, netdev, arjun, atul.gupta; +Cc: Harsh Jain

Typecast the pointer with correct structure.

Signed-off-by: Atul Gupta <atul.gupta@chelsio.com>
---
 drivers/crypto/chelsio/chcr_core.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/chelsio/chcr_core.c b/drivers/crypto/chelsio/chcr_core.c
index 2bfd61a..c28e018 100644
--- a/drivers/crypto/chelsio/chcr_core.c
+++ b/drivers/crypto/chelsio/chcr_core.c
@@ -151,18 +151,17 @@ int chcr_uld_rx_handler(void *handle, const __be64 *rsp,
 {
 	struct uld_ctx *u_ctx = (struct uld_ctx *)handle;
 	struct chcr_dev *dev = u_ctx->dev;
-	const struct cpl_act_establish *rpl = (struct cpl_act_establish
-					       *)rsp;
+	const struct cpl_fw6_pld *rpl = (struct cpl_fw6_pld *)rsp;
 
-	if (rpl->ot.opcode != CPL_FW6_PLD) {
+	if (rpl->opcode != CPL_FW6_PLD) {
 		pr_err("Unsupported opcode\n");
 		return 0;
 	}
 
 	if (!pgl)
-		work_handlers[rpl->ot.opcode](dev, (unsigned char *)&rsp[1]);
+		work_handlers[rpl->opcode](dev, (unsigned char *)&rsp[1]);
 	else
-		work_handlers[rpl->ot.opcode](dev, pgl->va);
+		work_handlers[rpl->opcode](dev, pgl->va);
 	return 0;
 }
 
-- 
1.8.2.3

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 8/8] crypto:chcr-Fix Smatch Complaint
  2017-01-27 10:39 [PATCH 0/8] Bug fixes Harsh Jain
                   ` (6 preceding siblings ...)
  2017-01-27 10:39 ` [PATCH 7/8] crypto:chcr- Fix wrong typecasting Harsh Jain
@ 2017-01-27 10:39 ` Harsh Jain
  2017-02-03 10:21 ` [PATCH 0/8] Bug fixes Herbert Xu
  8 siblings, 0 replies; 12+ messages in thread
From: Harsh Jain @ 2017-01-27 10:39 UTC (permalink / raw)
  To: herbert, linux-crypto, hariprasad, netdev, arjun, atul.gupta; +Cc: Harsh Jain

Initialise variable after null check.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Harsh Jain <harsh@chelsio.com>
---
 drivers/crypto/chelsio/chcr_algo.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
 mode change 100644 => 100755 drivers/crypto/chelsio/chcr_algo.c

diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
old mode 100644
new mode 100755
index 21fc04c..41bc7f4
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -2456,13 +2456,14 @@ static int chcr_aead_op(struct aead_request *req,
 {
 	struct crypto_aead *tfm = crypto_aead_reqtfm(req);
 	struct chcr_context *ctx = crypto_aead_ctx(tfm);
-	struct uld_ctx *u_ctx = ULD_CTX(ctx);
+	struct uld_ctx *u_ctx;
 	struct sk_buff *skb;
 
-	if (ctx && !ctx->dev) {
+	if (!ctx->dev) {
 		pr_err("chcr : %s : No crypto device.\n", __func__);
 		return -ENXIO;
 	}
+	u_ctx = ULD_CTX(ctx);
 	if (cxgb4_is_crypto_q_full(u_ctx->lldi.ports[0],
 				   ctx->tx_channel_id)) {
 		if (!(req->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG))
-- 
1.8.2.3

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/8] Bug fixes
  2017-01-27 10:39 [PATCH 0/8] Bug fixes Harsh Jain
                   ` (7 preceding siblings ...)
  2017-01-27 10:39 ` [PATCH 8/8] crypto:chcr-Fix Smatch Complaint Harsh Jain
@ 2017-02-03 10:21 ` Herbert Xu
  8 siblings, 0 replies; 12+ messages in thread
From: Herbert Xu @ 2017-02-03 10:21 UTC (permalink / raw)
  To: Harsh Jain; +Cc: linux-crypto, hariprasad, netdev, arjun, atul.gupta

On Fri, Jan 27, 2017 at 04:09:04PM +0530, Harsh Jain wrote:
> This patch series is based on Herbert's cryptodev-2.6 tree and depends on 
> patch series "Bug Fixes for 4.10". It includes Bug Fixes.
> 
> Atul Gupta (2)
>   crypto:chcr-Change flow IDs
>   crypto:chcr- Fix wrong typecasting
> Harsh Jain (8):
>   crypto:chcr- Fix key length for RFC4106
>   crypto:chcr-fix itnull.cocci warnings
>   crypto:chcr- Use cipher instead of Block Cipher in gcm setkey
>   crypto:chcr: Change cra_flags for cipher algos
>   crypto:chcr- Change algo priority
>   crypto:chcr-Fix Smatch Complaint

All applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 5/8] crypto:chcr: Change cra_flags for cipher algos
  2017-01-27 10:39 ` [PATCH 5/8] crypto:chcr: Change cra_flags for cipher algos Harsh Jain
@ 2017-03-08  9:58   ` Harsh Jain
  2017-03-08 10:21     ` Herbert Xu
  0 siblings, 1 reply; 12+ messages in thread
From: Harsh Jain @ 2017-03-08  9:58 UTC (permalink / raw)
  Cc: Herbert Xu, linux-crypto

Hi Herbert

On Fri, Jan 27, 2017 at 4:09 PM, Harsh Jain <harsh@chelsio.com> wrote:
> Change cipher algos flags to CRYPTO_ALG_TYPE_ABLKCIPHER.
>
> Signed-off-by: Harsh Jain <harsh@chelsio.com>
> ---
>  drivers/crypto/chelsio/chcr_algo.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
> index d335943..21fc04c 100644
> --- a/drivers/crypto/chelsio/chcr_algo.c
> +++ b/drivers/crypto/chelsio/chcr_algo.c
> @@ -171,7 +171,7 @@ int chcr_handle_resp(struct crypto_async_request *req, unsigned char *input,
>                 }
>                 break;
>
> -       case CRYPTO_ALG_TYPE_BLKCIPHER:
> +       case CRYPTO_ALG_TYPE_ABLKCIPHER:
>                 ctx_req.req.ablk_req = (struct ablkcipher_request *)req;
>                 ctx_req.ctx.ablk_ctx =
>                         ablkcipher_request_ctx(ctx_req.req.ablk_req);
> @@ -2492,7 +2492,7 @@ static int chcr_aead_op(struct aead_request *req,
>                         .cra_name               = "cbc(aes)",
>                         .cra_driver_name        = "cbc-aes-chcr",
>                         .cra_priority           = CHCR_CRA_PRIORITY,
> -                       .cra_flags              = CRYPTO_ALG_TYPE_BLKCIPHER |
> +                       .cra_flags              = CRYPTO_ALG_TYPE_ABLKCIPHER |
>                                 CRYPTO_ALG_ASYNC,
>                         .cra_blocksize          = AES_BLOCK_SIZE,
>                         .cra_ctxsize            = sizeof(struct chcr_context)
> @@ -2519,7 +2519,7 @@ static int chcr_aead_op(struct aead_request *req,
>                         .cra_name               = "xts(aes)",
>                         .cra_driver_name        = "xts-aes-chcr",
>                         .cra_priority           = CHCR_CRA_PRIORITY,
> -                       .cra_flags              = CRYPTO_ALG_TYPE_BLKCIPHER |
> +                       .cra_flags              = CRYPTO_ALG_TYPE_ABLKCIPHER |
>                                 CRYPTO_ALG_ASYNC,
>                         .cra_blocksize          = AES_BLOCK_SIZE,
>                         .cra_ctxsize            = sizeof(struct chcr_context) +

If I try above patch on 4.9.13 stable kernel. Kernel  stops executing
tests for cbc(aes), Same is working fine on cryptodev-2.6 latest tree.
It seems below patch set has changed the behavior.


crypto: testmgr - Do not test internal algorithms


diff --git a/crypto/algboss.c b/crypto/algboss.c
index 6e39d9c..ccb85e1 100644
--- a/crypto/algboss.c
+++ b/crypto/algboss.c
@@ -247,12 +247,8 @@ static int cryptomgr_schedule_test(struct crypto_alg *alg)
memcpy(param->alg, alg->cra_name, sizeof(param->alg));
type = alg->cra_flags;
- /* This piece of crap needs to disappear into per-type test hooks. */
- if (!((type ^ CRYPTO_ALG_TYPE_BLKCIPHER) &
- CRYPTO_ALG_TYPE_BLKCIPHER_MASK) && !(type & CRYPTO_ALG_GENIV) &&
- ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) ==
- CRYPTO_ALG_TYPE_BLKCIPHER ? alg->cra_blkcipher.ivsize :
- alg->cra_ablkcipher.ivsize))
+ /* Do not test internal algorithms. */
+ if (type & CRYPTO_ALG_INTERNAL)
type |= CRYPTO_ALG_TESTED;

Its bit confusing for me. Are we supposed to declared it as
"CRYPTO_ALG_TYPE_BLKCIPHER" for older kernels.

Regards
Harsh Jain

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 5/8] crypto:chcr: Change cra_flags for cipher algos
  2017-03-08  9:58   ` Harsh Jain
@ 2017-03-08 10:21     ` Herbert Xu
  0 siblings, 0 replies; 12+ messages in thread
From: Herbert Xu @ 2017-03-08 10:21 UTC (permalink / raw)
  To: Harsh Jain; +Cc: linux-crypto

On Wed, Mar 08, 2017 at 03:28:26PM +0530, Harsh Jain wrote:
>
> If I try above patch on 4.9.13 stable kernel. Kernel  stops executing
> tests for cbc(aes), Same is working fine on cryptodev-2.6 latest tree.
> It seems below patch set has changed the behavior.
> 
> 
> crypto: testmgr - Do not test internal algorithms

On older kernels each ablkcipher gets an geniv instantiated on top
of it.  Therefore the ablkcipher itself is never tested, only the
geniv is tested.

We have since got rid of the geniv and now test the ablkcipher
directly.

There was a period where we didn't generate a geniv but I forgot
to also remove the below chunk which skipped testing the ablkcipher.

> diff --git a/crypto/algboss.c b/crypto/algboss.c
> index 6e39d9c..ccb85e1 100644
> --- a/crypto/algboss.c
> +++ b/crypto/algboss.c
> @@ -247,12 +247,8 @@ static int cryptomgr_schedule_test(struct crypto_alg *alg)
> memcpy(param->alg, alg->cra_name, sizeof(param->alg));
> type = alg->cra_flags;
> - /* This piece of crap needs to disappear into per-type test hooks. */
> - if (!((type ^ CRYPTO_ALG_TYPE_BLKCIPHER) &
> - CRYPTO_ALG_TYPE_BLKCIPHER_MASK) && !(type & CRYPTO_ALG_GENIV) &&
> - ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) ==
> - CRYPTO_ALG_TYPE_BLKCIPHER ? alg->cra_blkcipher.ivsize :
> - alg->cra_ablkcipher.ivsize))
> + /* Do not test internal algorithms. */
> + if (type & CRYPTO_ALG_INTERNAL)
> type |= CRYPTO_ALG_TESTED;
>
> Its bit confusing for me. Are we supposed to declared it as
> "CRYPTO_ALG_TYPE_BLKCIPHER" for older kernels.

It should definitely be ABLKCIPHER in your case.

Even if the test is skipped your driver should still work.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-03-08 10:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-27 10:39 [PATCH 0/8] Bug fixes Harsh Jain
2017-01-27 10:39 ` [PATCH 1/8] crypto:chcr-Change flow IDs Harsh Jain
2017-01-27 10:39 ` [PATCH 2/8] crypto:chcr- Fix key length for RFC4106 Harsh Jain
2017-01-27 10:39 ` [PATCH 3/8] crypto:chcr-fix itnull.cocci warnings Harsh Jain
2017-01-27 10:39 ` [PATCH 4/8] crypto:chcr- Use cipher instead of Block Cipher in gcm setkey Harsh Jain
2017-01-27 10:39 ` [PATCH 5/8] crypto:chcr: Change cra_flags for cipher algos Harsh Jain
2017-03-08  9:58   ` Harsh Jain
2017-03-08 10:21     ` Herbert Xu
2017-01-27 10:39 ` [PATCH 6/8] crypto:chcr- Change algo priority Harsh Jain
2017-01-27 10:39 ` [PATCH 7/8] crypto:chcr- Fix wrong typecasting Harsh Jain
2017-01-27 10:39 ` [PATCH 8/8] crypto:chcr-Fix Smatch Complaint Harsh Jain
2017-02-03 10:21 ` [PATCH 0/8] Bug fixes Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).