Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36cda08f authored by Horia Geantă's avatar Horia Geantă Committed by Herbert Xu
Browse files

crypto: caam/qi - fix AD length endianness in S/G entry



Associated data (AD) length is read by CAAM from an S/G entry
that is initially filled by the GPP.
Accordingly, AD length has to be stored in CAAM endianness.

Fixes: b189817c ("crypto: caam/qi - add ablkcipher and authenc algorithms")
Signed-off-by: default avatarHoria Geantă <horia.geanta@nxp.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent eb9ba37d
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -399,6 +399,7 @@ static int xts_ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher,
 * @iv_dma: dma address of iv for checking continuity and link table
 * @iv_dma: dma address of iv for checking continuity and link table
 * @qm_sg_bytes: length of dma mapped h/w link table
 * @qm_sg_bytes: length of dma mapped h/w link table
 * @qm_sg_dma: bus physical mapped address of h/w link table
 * @qm_sg_dma: bus physical mapped address of h/w link table
 * @assoclen: associated data length, in CAAM endianness
 * @assoclen_dma: bus physical mapped address of req->assoclen
 * @assoclen_dma: bus physical mapped address of req->assoclen
 * @drv_req: driver-specific request structure
 * @drv_req: driver-specific request structure
 * @sgt: the h/w link table
 * @sgt: the h/w link table
@@ -409,6 +410,7 @@ struct aead_edesc {
	dma_addr_t iv_dma;
	dma_addr_t iv_dma;
	int qm_sg_bytes;
	int qm_sg_bytes;
	dma_addr_t qm_sg_dma;
	dma_addr_t qm_sg_dma;
	unsigned int assoclen;
	dma_addr_t assoclen_dma;
	dma_addr_t assoclen_dma;
	struct caam_drv_req drv_req;
	struct caam_drv_req drv_req;
#define CAAM_QI_MAX_AEAD_SG						\
#define CAAM_QI_MAX_AEAD_SG						\
@@ -684,7 +686,8 @@ static struct aead_edesc *aead_edesc_alloc(struct aead_request *req,
	edesc->drv_req.cbk = aead_done;
	edesc->drv_req.cbk = aead_done;
	edesc->drv_req.drv_ctx = drv_ctx;
	edesc->drv_req.drv_ctx = drv_ctx;


	edesc->assoclen_dma = dma_map_single(qidev, &req->assoclen, 4,
	edesc->assoclen = cpu_to_caam32(req->assoclen);
	edesc->assoclen_dma = dma_map_single(qidev, &edesc->assoclen, 4,
					     DMA_TO_DEVICE);
					     DMA_TO_DEVICE);
	if (dma_mapping_error(qidev, edesc->assoclen_dma)) {
	if (dma_mapping_error(qidev, edesc->assoclen_dma)) {
		dev_err(qidev, "unable to map assoclen\n");
		dev_err(qidev, "unable to map assoclen\n");