/* * Keystone crypto accelerator driver * * Copyright (C) 2013-2016 Texas Instruments Incorporated - http://www.ti.com * Contact: Sandeep Nair * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. */ #ifndef _KEYSTONE_SA_H_ #define _KEYSTONE_SA_H_ /* * 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 0 /* 3GPP Air Cipher */ #define SA_CTX_PE_PKT_TYPE_SRTP 1 /* SRTP */ #define SA_CTX_PE_PKT_TYPE_IPSEC_AH 2 /* IPSec Authentication Header */ /* IPSec Encapsulating Security Payload */ #define SA_CTX_PE_PKT_TYPE_IPSEC_ESP 3 /* Indicates that it is in data mode, It may not be used by PHP */ #define SA_CTX_PE_PKT_TYPE_NONE 4 #define SA_CTX_ENC_TYPE1_SZ 64 /* Encryption SC with Key only */ #define SA_CTX_ENC_TYPE2_SZ 96 /* Encryption SC with Key and Aux1 */ #define SA_CTX_AUTH_TYPE1_SZ 64 /* Auth SC with Key only */ #define SA_CTX_AUTH_TYPE2_SZ 96 /* Auth SC with Key and Aux1 */ /* Size of security context for PHP engine */ #define SA_CTX_PHP_PE_CTX_SZ 64 #define SA_CTX_MAX_SZ (64 + SA_CTX_ENC_TYPE2_SZ + SA_CTX_AUTH_TYPE2_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 0 #define SA_CTX_DMA_SIZE_64 1 #define SA_CTX_DMA_SIZE_96 2 #define SA_CTX_DMA_SIZE_128 3 #define SA_CTX_SCCTL_MK_DMA_INFO(php_f, eng0_f, eng1_f, php_e) \ ((php_f) | \ ((eng0_f) << 2) | \ ((eng1_f) << 4) | \ ((php_e) << 6)) /* * Byte offset of the owner word in SCCTL * in the security context */ #define SA_CTX_SCCTL_OWNER_OFFSET 0 /* * Assumption: CTX size is multiple of 32 */ #define SA_CTX_SIZE_TO_DMA_SIZE(ctx_sz) \ ((ctx_sz) ? ((ctx_sz) / 32 - 1) : 0) #define SA_CTX_ENC_KEY_OFFSET 32 #define SA_CTX_ENC_AUX1_OFFSET 64 #define SA_CTX_ENC_AUX2_OFFSET 96 #define SA_CTX_ENC_AUX3_OFFSET 112 #define SA_CTX_ENC_AUX4_OFFSET 128 /* Next Engine Select code in CP_ACE */ #define SA_ENG_ID_EM1 2 /* Enc/Dec engine with AES/DEC core */ #define SA_ENG_ID_EM2 3 /* Encryption/Decryption enginefor pass 2 */ #define SA_ENG_ID_AM1 4 /* Auth. engine with SHA1/MD5/SHA2 core */ #define SA_ENG_ID_AM2 5 /* Authentication engine for pass 2 */ #define SA_ENG_ID_OUTPORT2 20 /* Egress module 2 */ #define SA_ENG_ID_NONE 0xff /* * Command Label Definitions */ #define SA_CMDL_OFFSET_NESC 0 /* Next Engine Select Code */ #define SA_CMDL_OFFSET_LABEL_LEN 1 /* Engine Command Label Length */ /* 16-bit Length of Data to be processed */ #define SA_CMDL_OFFSET_DATA_LEN 2 #define SA_CMDL_OFFSET_DATA_OFFSET 4 /* Stat Data Offset */ #define SA_CMDL_OFFSET_OPTION_CTRL1 5 /* Option Control Byte 1 */ #define SA_CMDL_OFFSET_OPTION_CTRL2 6 /* Option Control Byte 2 */ #define SA_CMDL_OFFSET_OPTION_CTRL3 7 /* Option Control Byte 3 */ #define SA_CMDL_OFFSET_OPTION_BYTE 8 #define SA_CMDL_HEADER_SIZE_BYTES 8 #define SA_CMDL_OPTION_BYTES_MAX_SIZE 72 #define SA_CMDL_MAX_SIZE_BYTES (SA_CMDL_HEADER_SIZE_BYTES + \ SA_CMDL_OPTION_BYTES_MAX_SIZE) /* SWINFO word-0 flags */ #define SA_SW_INFO_FLAG_EVICT 0x0001 #define SA_SW_INFO_FLAG_TEAR 0x0002 #define SA_SW_INFO_FLAG_NOPD 0x0004 #define SA_CMD_ENCSS_EN 0x00000001 #define SA_CMD_AUTHSS_EN 0x00000002 #define SA_CMD_AIRSS_EN 0x00000004 #define SA_CMD_TRNG_EN 0x00000008 #define SA_CMD_PKA_EN 0x00000010 #define SA_CMD_PHP1SS_EN 0x00000020 #define SA_CMD_PHP2SS_EN 0x00000040 #define SA_CMD_CTXCACH_EN 0x00000080 #define SA_CMD_SA1_IN_EN 0x00000100 #define SA_CMD_SA0_IN_EN 0x00000200 #define SA_CMD_SA1_OUT_EN 0x00000400 #define SA_CMD_SA0_OUT_EN 0x00000800 #endif