linux/drivers/crypto/sa2ul.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * K3 SA2UL crypto accelerator driver
 *
 * Copyright (C) 2018-2020 Texas Instruments Incorporated - http://www.ti.com
 *
 * Authors:	Keerthy
 *		Vitaly Andrianov
 *		Tero Kristo
 */

#ifndef _K3_SA2UL_
#define _K3_SA2UL_

#include <crypto/aes.h>
#include <crypto/sha1.h>
#include <crypto/sha2.h>

#define SA_ENGINE_STATUS
#define SA_ENGINE_ENABLE_CONTROL

struct sa_tfm_ctx;
/*
 * SA_ENGINE_ENABLE_CONTROL register bits
 */
#define SA_EEC_ENCSS_EN
#define SA_EEC_AUTHSS_EN
#define SA_EEC_TRNG_EN
#define SA_EEC_PKA_EN
#define SA_EEC_CTXCACH_EN
#define SA_EEC_CPPI_PORT_IN_EN
#define SA_EEC_CPPI_PORT_OUT_EN

/*
 * Encoding used to identify the typo of crypto operation
 * performed on the packet when the packet is returned
 * by SA
 */
#define SA_REQ_SUBTYPE_ENC
#define SA_REQ_SUBTYPE_DEC
#define SA_REQ_SUBTYPE_SHIFT
#define SA_REQ_SUBTYPE_MASK

/* Number of 32 bit words in EPIB  */
#define SA_DMA_NUM_EPIB_WORDS

/* Number of 32 bit words in PS data  */
#define SA_DMA_NUM_PS_WORDS
#define NKEY_SZ
#define MCI_SZ

/*
 * Maximum number of simultaeneous security contexts
 * supported by the driver
 */
#define SA_MAX_NUM_CTX

/*
 * Assumption: CTX size is multiple of 32
 */
#define SA_CTX_SIZE_TO_DMA_SIZE(ctx_sz)

#define SA_CTX_ENC_KEY_OFFSET
#define SA_CTX_ENC_AUX1_OFFSET
#define SA_CTX_ENC_AUX2_OFFSET
#define SA_CTX_ENC_AUX3_OFFSET
#define SA_CTX_ENC_AUX4_OFFSET

/* Next Engine Select code in CP_ACE */
#define SA_ENG_ID_EM1
#define SA_ENG_ID_EM2
#define SA_ENG_ID_AM1
#define SA_ENG_ID_AM2
#define SA_ENG_ID_OUTPORT2

/*
 * Command Label Definitions
 */
#define SA_CMDL_OFFSET_NESC
#define SA_CMDL_OFFSET_LABEL_LEN
/* 16-bit Length of Data to be processed */
#define SA_CMDL_OFFSET_DATA_LEN
#define SA_CMDL_OFFSET_DATA_OFFSET
#define SA_CMDL_OFFSET_OPTION_CTRL1
#define SA_CMDL_OFFSET_OPTION_CTRL2
#define SA_CMDL_OFFSET_OPTION_CTRL3
#define SA_CMDL_OFFSET_OPTION_BYTE

#define SA_CMDL_HEADER_SIZE_BYTES

#define SA_CMDL_OPTION_BYTES_MAX_SIZE
#define SA_CMDL_MAX_SIZE_BYTES

/* SWINFO word-0 flags */
#define SA_SW_INFO_FLAG_EVICT
#define SA_SW_INFO_FLAG_TEAR
#define SA_SW_INFO_FLAG_NOPD

/*
 * This type represents the various packet types to be processed
 * by the PHP engine in SA.
 * It is used to identify the corresponding PHP processing function.
 */
#define SA_CTX_PE_PKT_TYPE_3GPP_AIR
#define SA_CTX_PE_PKT_TYPE_SRTP
#define SA_CTX_PE_PKT_TYPE_IPSEC_AH
/* IPSec Encapsulating Security Payload */
#define SA_CTX_PE_PKT_TYPE_IPSEC_ESP
/* Indicates that it is in data mode, It may not be used by PHP */
#define SA_CTX_PE_PKT_TYPE_NONE
#define SA_CTX_ENC_TYPE1_SZ
#define SA_CTX_ENC_TYPE2_SZ

#define SA_CTX_AUTH_TYPE1_SZ
#define SA_CTX_AUTH_TYPE2_SZ
/* Size of security context for PHP engine */
#define SA_CTX_PHP_PE_CTX_SZ

#define SA_CTX_MAX_SZ

/*
 * Encoding of F/E control in SCCTL
 *  Bit 0-1: Fetch PHP Bytes
 *  Bit 2-3: Fetch Encryption/Air Ciphering Bytes
 *  Bit 4-5: Fetch Authentication Bytes or Encr pass 2
 *  Bit 6-7: Evict PHP Bytes
 *
 *  where   00 = 0 bytes
 *          01 = 64 bytes
 *          10 = 96 bytes
 *          11 = 128 bytes
 */
#define SA_CTX_DMA_SIZE_0
#define SA_CTX_DMA_SIZE_64
#define SA_CTX_DMA_SIZE_96
#define SA_CTX_DMA_SIZE_128

/*
 * Byte offset of the owner word in SCCTL
 * in the security context
 */
#define SA_CTX_SCCTL_OWNER_OFFSET

#define SA_CTX_ENC_KEY_OFFSET
#define SA_CTX_ENC_AUX1_OFFSET
#define SA_CTX_ENC_AUX2_OFFSET
#define SA_CTX_ENC_AUX3_OFFSET
#define SA_CTX_ENC_AUX4_OFFSET

#define SA_SCCTL_FE_AUTH_ENC
#define SA_SCCTL_FE_ENC

#define SA_ALIGN_MASK
#define SA_ALIGNED

#define SA_AUTH_SW_CTRL_MD5
#define SA_AUTH_SW_CTRL_SHA1
#define SA_AUTH_SW_CTRL_SHA224
#define SA_AUTH_SW_CTRL_SHA256
#define SA_AUTH_SW_CTRL_SHA384
#define SA_AUTH_SW_CTRL_SHA512

/* SA2UL can only handle maximum data size of 64KB */
#define SA_MAX_DATA_SZ

/*
 * SA2UL can provide unpredictable results with packet sizes that fall
 * the following range, so avoid using it.
 */
#define SA_UNSAFE_DATA_SZ_MIN
#define SA_UNSAFE_DATA_SZ_MAX

struct sa_match_data;

/**
 * struct sa_crypto_data - Crypto driver instance data
 * @base: Base address of the register space
 * @soc_data: Pointer to SoC specific data
 * @pdev: Platform device pointer
 * @sc_pool: security context pool
 * @dev: Device pointer
 * @scid_lock: secure context ID lock
 * @sc_id_start: starting index for SC ID
 * @sc_id_end: Ending index for SC ID
 * @sc_id: Security Context ID
 * @ctx_bm: Bitmap to keep track of Security context ID's
 * @ctx: SA tfm context pointer
 * @dma_rx1: Pointer to DMA rx channel for sizes < 256 Bytes
 * @dma_rx2: Pointer to DMA rx channel for sizes > 256 Bytes
 * @dma_tx: Pointer to DMA TX channel
 */
struct sa_crypto_data {};

/**
 * struct sa_cmdl_param_info: Command label parameters info
 * @index: Index of the parameter in the command label format
 * @offset: the offset of the parameter
 * @size: Size of the parameter
 */
struct sa_cmdl_param_info {};

/* Maximum length of Auxiliary data in 32bit words */
#define SA_MAX_AUX_DATA_WORDS

/**
 * struct sa_cmdl_upd_info: Command label updation info
 * @flags: flags in command label
 * @submode: Encryption submodes
 * @enc_size: Size of first pass encryption size
 * @enc_size2: Size of second pass encryption size
 * @enc_offset: Encryption payload offset in the packet
 * @enc_iv: Encryption initialization vector for pass2
 * @enc_iv2: Encryption initialization vector for pass2
 * @aad: Associated data
 * @payload: Payload info
 * @auth_size: Authentication size for pass 1
 * @auth_size2: Authentication size for pass 2
 * @auth_offset: Authentication payload offset
 * @auth_iv: Authentication initialization vector
 * @aux_key_info: Authentication aux key information
 * @aux_key: Aux key for authentication
 */
struct sa_cmdl_upd_info {};

/*
 * Number of 32bit words appended after the command label
 * in PSDATA to identify the crypto request context.
 * word-0: Request type
 * word-1: pointer to request
 */
#define SA_PSDATA_CTX_WORDS

/* Maximum size of Command label in 32 words */
#define SA_MAX_CMDL_WORDS

/**
 * struct sa_ctx_info: SA context information
 * @sc: Pointer to security context
 * @sc_phys: Security context physical address that is passed on to SA2UL
 * @sc_id: Security context ID
 * @cmdl_size: Command label size
 * @cmdl: Command label for a particular iteration
 * @cmdl_upd_info: structure holding command label updation info
 * @epib: Extended protocol information block words
 */
struct sa_ctx_info {};

/**
 * struct sa_tfm_ctx: TFM context structure
 * @dev_data: struct sa_crypto_data pointer
 * @enc: struct sa_ctx_info for encryption
 * @dec: struct sa_ctx_info for decryption
 * @keylen: encrption/decryption keylength
 * @iv_idx: Initialization vector index
 * @key: encryption key
 * @fallback: SW fallback algorithm
 */
struct sa_tfm_ctx {};

/**
 * struct sa_sha_req_ctx: Structure used for sha request
 * @dev_data: struct sa_crypto_data pointer
 * @cmdl: Complete command label with psdata and epib included
 * @fallback_req: SW fallback request container
 */
struct sa_sha_req_ctx {};

enum sa_submode {};

/* Encryption algorithms */
enum sa_ealg_id {};

/* Authentication algorithms */
enum sa_aalg_id {};

/*
 * Mode control engine algorithms used to index the
 * mode control instruction tables
 */
enum sa_eng_algo_id {};

/**
 * struct sa_eng_info: Security accelerator engine info
 * @eng_id: Engine ID
 * @sc_size: security context size
 */
struct sa_eng_info {};

#endif /* _K3_SA2UL_ */