keystone-sa.h
4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
* Keystone crypto accelerator driver
*
* Copyright (C) 2013-2016 Texas Instruments Incorporated - http://www.ti.com
* Contact: Sandeep Nair <sandeep_n@ti.com>
*
* 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