drivers/crypto/amcc/crypto4xx_core.c

Source file repositories/reference/linux-study-clean/drivers/crypto/amcc/crypto4xx_core.c

File Facts

System
Linux kernel
Corpus path
drivers/crypto/amcc/crypto4xx_core.c
Extension
.c
Size
37162 bytes
Lines
1364
Domain
Driver Families
Bucket
drivers/crypto
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (overflow) {
			first_sd = 0;
			last_sd = overflow;
			dst_start += to_copy;
			overflow = 0;
		}
	}
}

static void crypto4xx_ret_sg_desc(struct crypto4xx_device *dev,
				  struct pd_uinfo *pd_uinfo)
{
	int i;
	if (pd_uinfo->num_gd) {
		for (i = 0; i < pd_uinfo->num_gd; i++)
			crypto4xx_put_gd_to_gdr(dev);
		pd_uinfo->first_gd = 0xffffffff;
		pd_uinfo->num_gd = 0;
	}
	if (pd_uinfo->num_sd) {
		for (i = 0; i < pd_uinfo->num_sd; i++)
			crypto4xx_put_sd_to_sdr(dev);

		pd_uinfo->first_sd = 0xffffffff;
		pd_uinfo->num_sd = 0;
	}
}

static void crypto4xx_cipher_done(struct crypto4xx_device *dev,
				     struct pd_uinfo *pd_uinfo,
				     struct ce_pd *pd)
{
	struct skcipher_request *req;
	struct scatterlist *dst;

	req = skcipher_request_cast(pd_uinfo->async_req);

	if (pd_uinfo->sa_va->sa_command_0.bf.scatter) {
		crypto4xx_copy_pkt_to_dst(dev, pd, pd_uinfo,
					  req->cryptlen, req->dst);
	} else {
		dst = pd_uinfo->dest_va;
		dma_unmap_page(dev->core_dev->device, pd->dest, dst->length,
			       DMA_FROM_DEVICE);
	}

	if (pd_uinfo->sa_va->sa_command_0.bf.save_iv == SA_SAVE_IV) {
		struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req);

		crypto4xx_memcpy_from_le32((u32 *)req->iv,
			pd_uinfo->sr_va->save_iv,
			crypto_skcipher_ivsize(skcipher));
	}

	crypto4xx_ret_sg_desc(dev, pd_uinfo);

	if (pd_uinfo->state & PD_ENTRY_BUSY)
		skcipher_request_complete(req, -EINPROGRESS);
	skcipher_request_complete(req, 0);
}

static void crypto4xx_aead_done(struct crypto4xx_device *dev,
				struct pd_uinfo *pd_uinfo,
				struct ce_pd *pd)
{
	struct aead_request *aead_req = container_of(pd_uinfo->async_req,
		struct aead_request, base);
	struct scatterlist *dst = pd_uinfo->dest_va;
	size_t cp_len = crypto_aead_authsize(
		crypto_aead_reqtfm(aead_req));
	u32 icv[AES_BLOCK_SIZE];
	int err = 0;

	if (pd_uinfo->sa_va->sa_command_0.bf.scatter) {
		crypto4xx_copy_pkt_to_dst(dev, pd, pd_uinfo,
					  pd->pd_ctl_len.bf.pkt_len,
					  dst);
	} else {
		dma_unmap_page(dev->core_dev->device, pd->dest, dst->length,
				DMA_FROM_DEVICE);
	}

	if (pd_uinfo->sa_va->sa_command_0.bf.dir == DIR_OUTBOUND) {
		/* append icv at the end */
		crypto4xx_memcpy_from_le32(icv, pd_uinfo->sr_va->save_digest,
					   sizeof(icv));

		scatterwalk_map_and_copy(icv, dst, aead_req->cryptlen,
					 cp_len, 1);
	} else {

Annotation

Implementation Notes