/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */1/*2* Copyright 2015-2016 Freescale Semiconductor Inc.3* Copyright 2017-2018 NXP4*/56#ifndef _CAAMALG_QI2_H_7#define _CAAMALG_QI2_H_89#include <crypto/internal/skcipher.h>10#include <linux/compiler_attributes.h>11#include <soc/fsl/dpaa2-io.h>12#include <soc/fsl/dpaa2-fd.h>13#include <linux/threads.h>14#include <linux/netdevice.h>15#include "dpseci.h"16#include "desc_constr.h"1718#define DPAA2_CAAM_STORE_SIZE 1619/* NAPI weight *must* be a multiple of the store size. */20#define DPAA2_CAAM_NAPI_WEIGHT 5122122/* The congestion entrance threshold was chosen so that on LS208823* we support the maximum throughput for the available memory24*/25#define DPAA2_SEC_CONG_ENTRY_THRESH (128 * 1024 * 1024)26#define DPAA2_SEC_CONG_EXIT_THRESH (DPAA2_SEC_CONG_ENTRY_THRESH * 9 / 10)2728/**29* dpaa2_caam_priv - driver private data30* @dpseci_id: DPSECI object unique ID31* @major_ver: DPSECI major version32* @minor_ver: DPSECI minor version33* @dpseci_attr: DPSECI attributes34* @sec_attr: SEC engine attributes35* @rx_queue_attr: array of Rx queue attributes36* @tx_queue_attr: array of Tx queue attributes37* @cscn_mem: pointer to memory region containing the congestion SCN38* it's size is larger than to accommodate alignment39* @cscn_dma: dma address used by the QMAN to write CSCN messages40* @dev: device associated with the DPSECI object41* @mc_io: pointer to MC portal's I/O object42* @domain: IOMMU domain43* @ppriv: per CPU pointers to privata data44*/45struct dpaa2_caam_priv {46int dpsec_id;4748u16 major_ver;49u16 minor_ver;5051struct dpseci_attr dpseci_attr;52struct dpseci_sec_attr sec_attr;53struct dpseci_rx_queue_attr rx_queue_attr[DPSECI_MAX_QUEUE_NUM];54struct dpseci_tx_queue_attr tx_queue_attr[DPSECI_MAX_QUEUE_NUM];55int num_pairs;5657/* congestion */58void *cscn_mem;59dma_addr_t cscn_dma;6061struct device *dev;62struct fsl_mc_io *mc_io;63struct iommu_domain *domain;6465struct dpaa2_caam_priv_per_cpu __percpu *ppriv;66struct dentry *dfs_root;67};6869/**70* dpaa2_caam_priv_per_cpu - per CPU private data71* @napi: napi structure72* @net_dev: netdev used by napi73* @req_fqid: (virtual) request (Tx / enqueue) FQID74* @rsp_fqid: (virtual) response (Rx / dequeue) FQID75* @prio: internal queue number - index for dpaa2_caam_priv.*_queue_attr76* @nctx: notification context of response FQ77* @store: where dequeued frames are stored78* @priv: backpointer to dpaa2_caam_priv79* @dpio: portal used for data path operations80*/81struct dpaa2_caam_priv_per_cpu {82struct napi_struct napi;83struct net_device *net_dev;84int req_fqid;85int rsp_fqid;86int prio;87struct dpaa2_io_notification_ctx nctx;88struct dpaa2_io_store *store;89struct dpaa2_caam_priv *priv;90struct dpaa2_io *dpio;91};9293/* Length of a single buffer in the QI driver memory cache */94#define CAAM_QI_MEMCACHE_SIZE 5129596/*97* aead_edesc - s/w-extended aead descriptor98* @src_nents: number of segments in input scatterlist99* @dst_nents: number of segments in output scatterlist100* @iv_dma: dma address of iv for checking continuity and link table101* @qm_sg_bytes: length of dma mapped h/w link table102* @qm_sg_dma: bus physical mapped address of h/w link table103* @assoclen: associated data length, in CAAM endianness104* @assoclen_dma: bus physical mapped address of req->assoclen105* @sgt: the h/w link table, followed by IV106*/107struct aead_edesc {108int src_nents;109int dst_nents;110dma_addr_t iv_dma;111int qm_sg_bytes;112dma_addr_t qm_sg_dma;113unsigned int assoclen;114dma_addr_t assoclen_dma;115struct dpaa2_sg_entry sgt[];116};117118/*119* skcipher_edesc - s/w-extended skcipher descriptor120* @src_nents: number of segments in input scatterlist121* @dst_nents: number of segments in output scatterlist122* @iv_dma: dma address of iv for checking continuity and link table123* @qm_sg_bytes: length of dma mapped qm_sg space124* @qm_sg_dma: I/O virtual address of h/w link table125* @sgt: the h/w link table, followed by IV126*/127struct skcipher_edesc {128int src_nents;129int dst_nents;130dma_addr_t iv_dma;131int qm_sg_bytes;132dma_addr_t qm_sg_dma;133struct dpaa2_sg_entry sgt[];134};135136/*137* ahash_edesc - s/w-extended ahash descriptor138* @qm_sg_dma: I/O virtual address of h/w link table139* @src_nents: number of segments in input scatterlist140* @qm_sg_bytes: length of dma mapped qm_sg space141* @sgt: pointer to h/w link table142*/143struct ahash_edesc {144dma_addr_t qm_sg_dma;145int src_nents;146int qm_sg_bytes;147struct dpaa2_sg_entry sgt[];148};149150/**151* caam_flc - Flow Context (FLC)152* @flc: Flow Context options153* @sh_desc: Shared Descriptor154*/155struct caam_flc {156u32 flc[16];157u32 sh_desc[MAX_SDLEN];158} __aligned(CRYPTO_DMA_ALIGN);159160enum optype {161ENCRYPT = 0,162DECRYPT,163NUM_OP164};165166/**167* caam_request - the request structure the driver application should fill while168* submitting a job to driver.169* @fd_flt: Frame list table defining input and output170* fd_flt[0] - FLE pointing to output buffer171* fd_flt[1] - FLE pointing to input buffer172* @fd_flt_dma: DMA address for the frame list table173* @flc: Flow Context174* @flc_dma: I/O virtual address of Flow Context175* @cbk: Callback function to invoke when job is completed176* @ctx: arbit context attached with request by the application177* @edesc: extended descriptor; points to one of {skcipher,aead}_edesc178*/179struct caam_request {180struct dpaa2_fl_entry fd_flt[2] __aligned(CRYPTO_DMA_ALIGN);181dma_addr_t fd_flt_dma;182struct caam_flc *flc;183dma_addr_t flc_dma;184void (*cbk)(void *ctx, u32 err);185void *ctx;186void *edesc;187struct skcipher_request fallback_req;188};189190/**191* dpaa2_caam_enqueue() - enqueue a crypto request192* @dev: device associated with the DPSECI object193* @req: pointer to caam_request194*/195int dpaa2_caam_enqueue(struct device *dev, struct caam_request *req);196197#endif /* _CAAMALG_QI2_H_ */198199200