drivers/crypto/caam/qi.h

Source file repositories/reference/linux-study-clean/drivers/crypto/caam/qi.h

File Facts

System
Linux kernel
Corpus path
drivers/crypto/caam/qi.h
Extension
.h
Size
5789 bytes
Lines
184
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 caam_drv_ctx {
	struct {
		u32 prehdr[2];
		u32 sh_desc[MAX_SDLEN];
	} __aligned(CRYPTO_DMA_ALIGN);
	dma_addr_t context_a;
	struct qman_fq *req_fq;
	struct qman_fq *rsp_fq;
	refcount_t refcnt;
	int cpu;
	enum optype op_type;
	struct device *qidev;
};

/**
 * caam_drv_req - The request structure the driver application should fill while
 *                submitting a job to driver.
 * @fd_sgt: QMan S/G pointing to output (fd_sgt[0]) and input (fd_sgt[1])
 *          buffers.
 * @cbk: callback function to invoke when job is completed
 * @app_ctx: arbitrary context attached with request by the application
 *
 * The fields mentioned below should not be used by application.
 * These are for private use by driver.
 *
 * @hdr__: linked list header to maintain list of outstanding requests to CAAM
 * @hwaddr: DMA address for the S/G table.
 */
struct caam_drv_req {
	struct qm_sg_entry fd_sgt[2];
	struct caam_drv_ctx *drv_ctx;
	caam_qi_cbk cbk;
	void *app_ctx;
} __aligned(CRYPTO_DMA_ALIGN);

/**
 * caam_drv_ctx_init - Initialise a CAAM/QI driver context
 *
 * A CAAM/QI driver context must be attached with each cryptographic context.
 * This function allocates memory for CAAM/QI context and returns a handle to
 * the application. This handle must be submitted along with each enqueue
 * request to the driver by the application.
 *
 * @cpu: CPU where the application prefers to the driver to receive CAAM
 *       responses. The request completion callback would be issued from this
 *       CPU.
 * @sh_desc: shared descriptor pointer to be attached with CAAM/QI driver
 *           context.
 *
 * Returns a driver context on success or negative error code on failure.
 */
struct caam_drv_ctx *caam_drv_ctx_init(struct device *qidev, int *cpu,
				       u32 *sh_desc);

/**
 * caam_qi_enqueue - Submit a request to QI backend driver.
 *
 * The request structure must be properly filled as described above.
 *
 * @qidev: device pointer for QI backend
 * @req: CAAM QI request structure
 *
 * Returns 0 on success or negative error code on failure.
 */
int caam_qi_enqueue(struct device *qidev, struct caam_drv_req *req);

/**
 * caam_drv_ctx_busy - Check if there are too many jobs pending with CAAM
 *		       or too many CAAM responses are pending to be processed.
 * @drv_ctx: driver context for which job is to be submitted
 *
 * Returns caam congestion status 'true/false'
 */
bool caam_drv_ctx_busy(struct caam_drv_ctx *drv_ctx);

/**
 * caam_drv_ctx_update - Update QI driver context
 *
 * Invoked when shared descriptor is required to be change in driver context.
 *
 * @drv_ctx: driver context to be updated
 * @sh_desc: new shared descriptor pointer to be updated in QI driver context
 *
 * Returns 0 on success or negative error code on failure.
 */
int caam_drv_ctx_update(struct caam_drv_ctx *drv_ctx, u32 *sh_desc);

/**
 * caam_drv_ctx_rel - Release a QI driver context
 * @drv_ctx: context to be released

Annotation

Implementation Notes