drivers/crypto/axis/artpec6_crypto.c

Source file repositories/reference/linux-study-clean/drivers/crypto/axis/artpec6_crypto.c

File Facts

System
Linux kernel
Corpus path
drivers/crypto/axis/artpec6_crypto.c
Extension
.c
Size
79385 bytes
Lines
2981
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

struct pdma_descr_ctrl  {
	unsigned char short_descr : 1;
	unsigned char pad1        : 1;
	unsigned char eop         : 1;
	unsigned char intr        : 1;
	unsigned char short_len   : 3;
	unsigned char pad2        : 1;
} __packed;

struct pdma_data_descr {
	unsigned int len : 24;
	unsigned int buf : 32;
} __packed;

struct pdma_short_descr {
	unsigned char data[7];
} __packed;

struct pdma_descr {
	struct pdma_descr_ctrl ctrl;
	union {
		struct pdma_data_descr   data;
		struct pdma_short_descr  shrt;
	};
};

struct pdma_stat_descr {
	unsigned char pad1        : 1;
	unsigned char pad2        : 1;
	unsigned char eop         : 1;
	unsigned char pad3        : 5;
	unsigned int  len         : 24;
};

/* Each descriptor array can hold max 64 entries */
#define PDMA_DESCR_COUNT	64

#define MODULE_NAME   "Artpec-6 CA"

/* Hash modes (including HMAC variants) */
#define ARTPEC6_CRYPTO_HASH_SHA1	1
#define ARTPEC6_CRYPTO_HASH_SHA256	2

/* Crypto modes */
#define ARTPEC6_CRYPTO_CIPHER_AES_ECB	1
#define ARTPEC6_CRYPTO_CIPHER_AES_CBC	2
#define ARTPEC6_CRYPTO_CIPHER_AES_CTR	3
#define ARTPEC6_CRYPTO_CIPHER_AES_XTS	5

/* The PDMA is a DMA-engine tightly coupled with a ciphering engine.
 * It operates on a descriptor array with up to 64 descriptor entries.
 * The arrays must be 64 byte aligned in memory.
 *
 * The ciphering unit has no registers and is completely controlled by
 * a 4-byte metadata that is inserted at the beginning of each dma packet.
 *
 * A dma packet is a sequence of descriptors terminated by setting the .eop
 * field in the final descriptor of the packet.
 *
 * Multiple packets are used for providing context data, key data and
 * the plain/ciphertext.
 *
 *   PDMA Descriptors (Array)
 *  +------+------+------+~~+-------+------+----
 *  |  0   |  1   |  2   |~~| 11 EOP|  12  |  ....
 *  +--+---+--+---+----+-+~~+-------+----+-+----
 *     |      |        |       |         |
 *     |      |        |       |         |
 *   __|__  +-------++-------++-------+ +----+
 *  | MD  | |Payload||Payload||Payload| | MD |
 *  +-----+ +-------++-------++-------+ +----+
 */

struct artpec6_crypto_bounce_buffer {
	struct list_head list;
	size_t length;
	struct scatterlist *sg;
	size_t offset;
	/* buf is aligned to ARTPEC_CACHE_LINE_MAX and
	 * holds up to ARTPEC_CACHE_LINE_MAX bytes data.
	 */
	void *buf;
};

struct artpec6_crypto_dma_map {
	dma_addr_t dma_addr;
	size_t size;
	enum dma_data_direction dir;
};

Annotation

Implementation Notes