xref: /dpdk/drivers/common/dpaax/caamflib/rta/protocol_cmd.h (revision c51ccb9618d12650982c8f29ff3335508f8ba1a6)
1c0ded849SHemant Agrawal /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2c0ded849SHemant Agrawal  *
3c0ded849SHemant Agrawal  * Copyright 2008-2016 Freescale Semiconductor Inc.
4*c51ccb96SHemant Agrawal  * Copyright 2016,2019,2023 NXP
5c0ded849SHemant Agrawal  *
6c0ded849SHemant Agrawal  */
7c0ded849SHemant Agrawal 
8c0ded849SHemant Agrawal #ifndef __RTA_PROTOCOL_CMD_H__
9c0ded849SHemant Agrawal #define __RTA_PROTOCOL_CMD_H__
10c0ded849SHemant Agrawal 
11c0ded849SHemant Agrawal extern enum rta_sec_era rta_sec_era;
12c0ded849SHemant Agrawal 
13c0ded849SHemant Agrawal static inline int
__rta_ssl_proto(uint16_t protoinfo)14c0ded849SHemant Agrawal __rta_ssl_proto(uint16_t protoinfo)
15c0ded849SHemant Agrawal {
16c0ded849SHemant Agrawal 	switch (protoinfo) {
17c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_EXPORT_WITH_RC4_40_MD5:
18c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_WITH_RC4_128_MD5:
19c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_WITH_RC4_128_SHA:
20c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_anon_EXPORT_WITH_RC4_40_MD5:
21c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_anon_WITH_RC4_128_MD5:
22c0ded849SHemant Agrawal 	case OP_PCL_TLS_KRB5_WITH_RC4_128_SHA:
23c0ded849SHemant Agrawal 	case OP_PCL_TLS_KRB5_WITH_RC4_128_MD5:
24c0ded849SHemant Agrawal 	case OP_PCL_TLS_KRB5_EXPORT_WITH_RC4_40_SHA:
25c0ded849SHemant Agrawal 	case OP_PCL_TLS_KRB5_EXPORT_WITH_RC4_40_MD5:
26c0ded849SHemant Agrawal 	case OP_PCL_TLS_PSK_WITH_RC4_128_SHA:
27c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_PSK_WITH_RC4_128_SHA:
28c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_PSK_WITH_RC4_128_SHA:
29c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_ECDSA_WITH_RC4_128_SHA:
30c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA:
31c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_RSA_WITH_RC4_128_SHA:
32c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_RSA_WITH_RC4_128_SHA:
33c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_anon_WITH_RC4_128_SHA:
34c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_PSK_WITH_RC4_128_SHA:
35c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_EXPORT_WITH_DES40_CBC_SHA:
36c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_WITH_DES_CBC_SHA:
37c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_WITH_3DES_EDE_CBC_SHA:
38c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA:
39c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_DSS_WITH_DES_CBC_SHA:
40c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA:
41c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA:
42c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_RSA_WITH_DES_CBC_SHA:
43c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA:
44c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA:
45c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_DSS_WITH_DES_CBC_SHA:
46c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA:
47c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA:
48c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_RSA_WITH_DES_CBC_SHA:
49c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA:
50c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA:
51c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_anon_WITH_DES_CBC_SHA:
52c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_anon_WITH_3DES_EDE_CBC_SHA:
53c0ded849SHemant Agrawal 	case OP_PCL_TLS_KRB5_WITH_DES_CBC_SHA:
54c0ded849SHemant Agrawal 	case OP_PCL_TLS_KRB5_WITH_3DES_EDE_CBC_SHA:
55c0ded849SHemant Agrawal 	case OP_PCL_TLS_KRB5_WITH_DES_CBC_MD5:
56c0ded849SHemant Agrawal 	case OP_PCL_TLS_KRB5_WITH_3DES_EDE_CBC_MD5:
57c0ded849SHemant Agrawal 	case OP_PCL_TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA:
58c0ded849SHemant Agrawal 	case OP_PCL_TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5:
59c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_WITH_AES_128_CBC_SHA:
60c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_DSS_WITH_AES_128_CBC_SHA:
61c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_RSA_WITH_AES_128_CBC_SHA:
62c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_DSS_WITH_AES_128_CBC_SHA:
63c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_RSA_WITH_AES_128_CBC_SHA:
64c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_anon_WITH_AES_128_CBC_SHA:
65c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_WITH_AES_256_CBC_SHA:
66c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_DSS_WITH_AES_256_CBC_SHA:
67c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_RSA_WITH_AES_256_CBC_SHA:
68c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_DSS_WITH_AES_256_CBC_SHA:
69c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_RSA_WITH_AES_256_CBC_SHA:
70c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_anon_WITH_AES_256_CBC_SHA:
71c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_DSS_WITH_AES_128_CBC_SHA256:
72c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_RSA_WITH_AES_128_CBC_SHA256:
73c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_DSS_WITH_AES_128_CBC_SHA256:
74c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256:
75c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_DSS_WITH_AES_256_CBC_SHA256:
76c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_RSA_WITH_AES_256_CBC_SHA256:
77c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_DSS_WITH_AES_256_CBC_SHA256:
78c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256:
79c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_anon_WITH_AES_128_CBC_SHA256:
80c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_anon_WITH_AES_256_CBC_SHA256:
81c0ded849SHemant Agrawal 	case OP_PCL_TLS_PSK_WITH_3DES_EDE_CBC_SHA:
82c0ded849SHemant Agrawal 	case OP_PCL_TLS_PSK_WITH_AES_128_CBC_SHA:
83c0ded849SHemant Agrawal 	case OP_PCL_TLS_PSK_WITH_AES_256_CBC_SHA:
84c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA:
85c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_PSK_WITH_AES_128_CBC_SHA:
86c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_PSK_WITH_AES_256_CBC_SHA:
87c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA:
88c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_PSK_WITH_AES_128_CBC_SHA:
89c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_PSK_WITH_AES_256_CBC_SHA:
90c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_WITH_AES_128_GCM_SHA256:
91c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_WITH_AES_256_GCM_SHA384:
92c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256:
93c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384:
94c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_RSA_WITH_AES_128_GCM_SHA256:
95c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_RSA_WITH_AES_256_GCM_SHA384:
96c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_DSS_WITH_AES_128_GCM_SHA256:
97c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_DSS_WITH_AES_256_GCM_SHA384:
98c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_DSS_WITH_AES_128_GCM_SHA256:
99c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_DSS_WITH_AES_256_GCM_SHA384:
100c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_anon_WITH_AES_128_GCM_SHA256:
101c0ded849SHemant Agrawal 	case OP_PCL_TLS_DH_anon_WITH_AES_256_GCM_SHA384:
102c0ded849SHemant Agrawal 	case OP_PCL_TLS_PSK_WITH_AES_128_GCM_SHA256:
103c0ded849SHemant Agrawal 	case OP_PCL_TLS_PSK_WITH_AES_256_GCM_SHA384:
104c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256:
105c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384:
106c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256:
107c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384:
108c0ded849SHemant Agrawal 	case OP_PCL_TLS_PSK_WITH_AES_128_CBC_SHA256:
109c0ded849SHemant Agrawal 	case OP_PCL_TLS_PSK_WITH_AES_256_CBC_SHA384:
110c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256:
111c0ded849SHemant Agrawal 	case OP_PCL_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384:
112c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256:
113c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384:
114c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA:
115c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA:
116c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA:
117c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA:
118c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA:
119c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA:
120c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA:
121c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA:
122c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA:
123c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA:
124c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:
125c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA:
126c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA:
127c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_anon_WITH_AES_128_CBC_SHA:
128c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_anon_WITH_AES_256_CBC_SHA:
129c0ded849SHemant Agrawal 	case OP_PCL_TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA:
130c0ded849SHemant Agrawal 	case OP_PCL_TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA:
131c0ded849SHemant Agrawal 	case OP_PCL_TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA:
132c0ded849SHemant Agrawal 	case OP_PCL_TLS_SRP_SHA_WITH_AES_128_CBC_SHA:
133c0ded849SHemant Agrawal 	case OP_PCL_TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA:
134c0ded849SHemant Agrawal 	case OP_PCL_TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA:
135c0ded849SHemant Agrawal 	case OP_PCL_TLS_SRP_SHA_WITH_AES_256_CBC_SHA:
136c0ded849SHemant Agrawal 	case OP_PCL_TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA:
137c0ded849SHemant Agrawal 	case OP_PCL_TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA:
138c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256:
139c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384:
140c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256:
141c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384:
142c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:
143c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384:
144c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256:
145c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384:
146c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:
147c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:
148c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256:
149c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384:
150c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:
151c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:
152c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256:
153c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384:
154c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA:
155c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA:
156c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA:
157c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256:
158c0ded849SHemant Agrawal 	case OP_PCL_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384:
159c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_WITH_AES_128_CBC_SHA256:
160c0ded849SHemant Agrawal 	case OP_PCL_TLS_RSA_WITH_AES_256_CBC_SHA256:
161c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_3DES_EDE_CBC_MD5:
162c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_3DES_EDE_CBC_SHA160:
163c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_3DES_EDE_CBC_SHA224:
164c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_3DES_EDE_CBC_SHA256:
165c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_3DES_EDE_CBC_SHA384:
166c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_3DES_EDE_CBC_SHA512:
167c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_AES_128_CBC_SHA160:
168c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_AES_128_CBC_SHA224:
169c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_AES_128_CBC_SHA256:
170c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_AES_128_CBC_SHA384:
171c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_AES_128_CBC_SHA512:
172c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_AES_192_CBC_SHA160:
173c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_AES_192_CBC_SHA224:
174c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_AES_192_CBC_SHA256:
175c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_AES_192_CBC_SHA512:
176c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_AES_256_CBC_SHA160:
177c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_AES_256_CBC_SHA224:
178c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_AES_256_CBC_SHA384:
179c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_AES_256_CBC_SHA512:
180c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_AES_256_CBC_SHA256:
181c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_AES_192_CBC_SHA384:
182c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_MASTER_SECRET_PRF_FE:
183c0ded849SHemant Agrawal 	case OP_PCL_PVT_TLS_MASTER_SECRET_PRF_FF:
184c0ded849SHemant Agrawal 		return 0;
185c0ded849SHemant Agrawal 	}
186c0ded849SHemant Agrawal 
187c0ded849SHemant Agrawal 	return -EINVAL;
188c0ded849SHemant Agrawal }
189c0ded849SHemant Agrawal 
190c0ded849SHemant Agrawal static inline int
__rta_ike_proto(uint16_t protoinfo)191c0ded849SHemant Agrawal __rta_ike_proto(uint16_t protoinfo)
192c0ded849SHemant Agrawal {
193c0ded849SHemant Agrawal 	switch (protoinfo) {
194c0ded849SHemant Agrawal 	case OP_PCL_IKE_HMAC_MD5:
195c0ded849SHemant Agrawal 	case OP_PCL_IKE_HMAC_SHA1:
196c0ded849SHemant Agrawal 	case OP_PCL_IKE_HMAC_AES128_CBC:
197c0ded849SHemant Agrawal 	case OP_PCL_IKE_HMAC_SHA256:
198c0ded849SHemant Agrawal 	case OP_PCL_IKE_HMAC_SHA384:
199c0ded849SHemant Agrawal 	case OP_PCL_IKE_HMAC_SHA512:
200c0ded849SHemant Agrawal 	case OP_PCL_IKE_HMAC_AES128_CMAC:
201c0ded849SHemant Agrawal 		return 0;
202c0ded849SHemant Agrawal 	}
203c0ded849SHemant Agrawal 
204c0ded849SHemant Agrawal 	return -EINVAL;
205c0ded849SHemant Agrawal }
206c0ded849SHemant Agrawal 
207c0ded849SHemant Agrawal static inline int
__rta_ipsec_proto(uint16_t protoinfo)208c0ded849SHemant Agrawal __rta_ipsec_proto(uint16_t protoinfo)
209c0ded849SHemant Agrawal {
210c0ded849SHemant Agrawal 	uint16_t proto_cls1 = protoinfo & OP_PCL_IPSEC_CIPHER_MASK;
211c0ded849SHemant Agrawal 	uint16_t proto_cls2 = protoinfo & OP_PCL_IPSEC_AUTH_MASK;
212c0ded849SHemant Agrawal 
213c0ded849SHemant Agrawal 	switch (proto_cls1) {
214c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_AES_NULL_WITH_GMAC:
215c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_AES_CCM8:
216c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_AES_CCM12:
217c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_AES_CCM16:
218c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_AES_GCM8:
219c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_AES_GCM12:
220c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_AES_GCM16:
221c0ded849SHemant Agrawal 		/* CCM, GCM, GMAC require PROTINFO[7:0] = 0 */
222c0ded849SHemant Agrawal 		if (proto_cls2 == OP_PCL_IPSEC_HMAC_NULL)
223c0ded849SHemant Agrawal 			return 0;
224c0ded849SHemant Agrawal 		return -EINVAL;
225c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_NULL:
226c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_DES_IV64:
227c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_DES:
228c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_3DES:
229c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_AES_CBC:
230c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_AES_CTR:
231c0ded849SHemant Agrawal 		break;
232c0ded849SHemant Agrawal 	default:
233c0ded849SHemant Agrawal 		return -EINVAL;
234c0ded849SHemant Agrawal 	}
235c0ded849SHemant Agrawal 
236c0ded849SHemant Agrawal 	switch (proto_cls2) {
237c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_HMAC_NULL:
238c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_HMAC_MD5_96:
239c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_HMAC_SHA1_96:
240c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_AES_XCBC_MAC_96:
241c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_HMAC_MD5_128:
242c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_HMAC_SHA1_160:
243c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_AES_CMAC_96:
244*c51ccb96SHemant Agrawal 	case OP_PCL_IPSEC_HMAC_SHA2_224_96:
245*c51ccb96SHemant Agrawal 	case OP_PCL_IPSEC_HMAC_SHA2_224_112:
246*c51ccb96SHemant Agrawal 	case OP_PCL_IPSEC_HMAC_SHA2_224_224:
247c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_HMAC_SHA2_256_128:
248c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_HMAC_SHA2_384_192:
249c0ded849SHemant Agrawal 	case OP_PCL_IPSEC_HMAC_SHA2_512_256:
250c0ded849SHemant Agrawal 		return 0;
251c0ded849SHemant Agrawal 	}
252c0ded849SHemant Agrawal 
253c0ded849SHemant Agrawal 	return -EINVAL;
254c0ded849SHemant Agrawal }
255c0ded849SHemant Agrawal 
256c0ded849SHemant Agrawal static inline int
__rta_srtp_proto(uint16_t protoinfo)257c0ded849SHemant Agrawal __rta_srtp_proto(uint16_t protoinfo)
258c0ded849SHemant Agrawal {
259c0ded849SHemant Agrawal 	uint16_t proto_cls1 = protoinfo & OP_PCL_SRTP_CIPHER_MASK;
260c0ded849SHemant Agrawal 	uint16_t proto_cls2 = protoinfo & OP_PCL_SRTP_AUTH_MASK;
261c0ded849SHemant Agrawal 
262c0ded849SHemant Agrawal 	switch (proto_cls1) {
263c0ded849SHemant Agrawal 	case OP_PCL_SRTP_AES_CTR:
264c0ded849SHemant Agrawal 		switch (proto_cls2) {
265c0ded849SHemant Agrawal 		case OP_PCL_SRTP_HMAC_SHA1_160:
266c0ded849SHemant Agrawal 			return 0;
267c0ded849SHemant Agrawal 		}
268c0ded849SHemant Agrawal 		/* no break */
269c0ded849SHemant Agrawal 	}
270c0ded849SHemant Agrawal 
271c0ded849SHemant Agrawal 	return -EINVAL;
272c0ded849SHemant Agrawal }
273c0ded849SHemant Agrawal 
274c0ded849SHemant Agrawal static inline int
__rta_macsec_proto(uint16_t protoinfo)275c0ded849SHemant Agrawal __rta_macsec_proto(uint16_t protoinfo)
276c0ded849SHemant Agrawal {
277c0ded849SHemant Agrawal 	switch (protoinfo) {
278c0ded849SHemant Agrawal 	case OP_PCL_MACSEC:
279c0ded849SHemant Agrawal 		return 0;
280c0ded849SHemant Agrawal 	}
281c0ded849SHemant Agrawal 
282c0ded849SHemant Agrawal 	return -EINVAL;
283c0ded849SHemant Agrawal }
284c0ded849SHemant Agrawal 
285c0ded849SHemant Agrawal static inline int
__rta_wifi_proto(uint16_t protoinfo)286c0ded849SHemant Agrawal __rta_wifi_proto(uint16_t protoinfo)
287c0ded849SHemant Agrawal {
288c0ded849SHemant Agrawal 	switch (protoinfo) {
289c0ded849SHemant Agrawal 	case OP_PCL_WIFI:
290c0ded849SHemant Agrawal 		return 0;
291c0ded849SHemant Agrawal 	}
292c0ded849SHemant Agrawal 
293c0ded849SHemant Agrawal 	return -EINVAL;
294c0ded849SHemant Agrawal }
295c0ded849SHemant Agrawal 
296c0ded849SHemant Agrawal static inline int
__rta_wimax_proto(uint16_t protoinfo)297c0ded849SHemant Agrawal __rta_wimax_proto(uint16_t protoinfo)
298c0ded849SHemant Agrawal {
299c0ded849SHemant Agrawal 	switch (protoinfo) {
300c0ded849SHemant Agrawal 	case OP_PCL_WIMAX_OFDM:
301c0ded849SHemant Agrawal 	case OP_PCL_WIMAX_OFDMA:
302c0ded849SHemant Agrawal 		return 0;
303c0ded849SHemant Agrawal 	}
304c0ded849SHemant Agrawal 
305c0ded849SHemant Agrawal 	return -EINVAL;
306c0ded849SHemant Agrawal }
307c0ded849SHemant Agrawal 
308c0ded849SHemant Agrawal /* Allowed blob proto flags for each SEC Era */
309c0ded849SHemant Agrawal static const uint32_t proto_blob_flags[] = {
310c0ded849SHemant Agrawal 	OP_PCL_BLOB_FORMAT_MASK | OP_PCL_BLOB_BLACK,
311c0ded849SHemant Agrawal 	OP_PCL_BLOB_FORMAT_MASK | OP_PCL_BLOB_BLACK | OP_PCL_BLOB_TKEK |
312c0ded849SHemant Agrawal 		OP_PCL_BLOB_EKT | OP_PCL_BLOB_REG_MASK,
313c0ded849SHemant Agrawal 	OP_PCL_BLOB_FORMAT_MASK | OP_PCL_BLOB_BLACK | OP_PCL_BLOB_TKEK |
314c0ded849SHemant Agrawal 		OP_PCL_BLOB_EKT | OP_PCL_BLOB_REG_MASK,
315c0ded849SHemant Agrawal 	OP_PCL_BLOB_FORMAT_MASK | OP_PCL_BLOB_BLACK | OP_PCL_BLOB_TKEK |
316c0ded849SHemant Agrawal 		OP_PCL_BLOB_EKT | OP_PCL_BLOB_REG_MASK | OP_PCL_BLOB_SEC_MEM,
317c0ded849SHemant Agrawal 	OP_PCL_BLOB_FORMAT_MASK | OP_PCL_BLOB_BLACK | OP_PCL_BLOB_TKEK |
318c0ded849SHemant Agrawal 		OP_PCL_BLOB_EKT | OP_PCL_BLOB_REG_MASK | OP_PCL_BLOB_SEC_MEM,
319c0ded849SHemant Agrawal 	OP_PCL_BLOB_FORMAT_MASK | OP_PCL_BLOB_BLACK | OP_PCL_BLOB_TKEK |
320c0ded849SHemant Agrawal 		OP_PCL_BLOB_EKT | OP_PCL_BLOB_REG_MASK | OP_PCL_BLOB_SEC_MEM,
321c0ded849SHemant Agrawal 	OP_PCL_BLOB_FORMAT_MASK | OP_PCL_BLOB_BLACK | OP_PCL_BLOB_TKEK |
322c0ded849SHemant Agrawal 		OP_PCL_BLOB_EKT | OP_PCL_BLOB_REG_MASK | OP_PCL_BLOB_SEC_MEM,
323c0ded849SHemant Agrawal 	OP_PCL_BLOB_FORMAT_MASK | OP_PCL_BLOB_BLACK | OP_PCL_BLOB_TKEK |
324c0ded849SHemant Agrawal 		OP_PCL_BLOB_EKT | OP_PCL_BLOB_REG_MASK | OP_PCL_BLOB_SEC_MEM,
325c0ded849SHemant Agrawal 	OP_PCL_BLOB_FORMAT_MASK | OP_PCL_BLOB_BLACK | OP_PCL_BLOB_TKEK |
326c0ded849SHemant Agrawal 		OP_PCL_BLOB_EKT | OP_PCL_BLOB_REG_MASK | OP_PCL_BLOB_SEC_MEM,
327c0ded849SHemant Agrawal 	OP_PCL_BLOB_FORMAT_MASK | OP_PCL_BLOB_BLACK | OP_PCL_BLOB_TKEK |
328c0ded849SHemant Agrawal 		OP_PCL_BLOB_EKT | OP_PCL_BLOB_REG_MASK | OP_PCL_BLOB_SEC_MEM
329c0ded849SHemant Agrawal };
330c0ded849SHemant Agrawal 
331c0ded849SHemant Agrawal static inline int
__rta_blob_proto(uint16_t protoinfo)332c0ded849SHemant Agrawal __rta_blob_proto(uint16_t protoinfo)
333c0ded849SHemant Agrawal {
334c0ded849SHemant Agrawal 	if (protoinfo & ~proto_blob_flags[rta_sec_era])
335c0ded849SHemant Agrawal 		return -EINVAL;
336c0ded849SHemant Agrawal 
337c0ded849SHemant Agrawal 	switch (protoinfo & OP_PCL_BLOB_FORMAT_MASK) {
338c0ded849SHemant Agrawal 	case OP_PCL_BLOB_FORMAT_NORMAL:
339c0ded849SHemant Agrawal 	case OP_PCL_BLOB_FORMAT_MASTER_VER:
340c0ded849SHemant Agrawal 	case OP_PCL_BLOB_FORMAT_TEST:
341c0ded849SHemant Agrawal 		break;
342c0ded849SHemant Agrawal 	default:
343c0ded849SHemant Agrawal 		return -EINVAL;
344c0ded849SHemant Agrawal 	}
345c0ded849SHemant Agrawal 
346c0ded849SHemant Agrawal 	switch (protoinfo & OP_PCL_BLOB_REG_MASK) {
347c0ded849SHemant Agrawal 	case OP_PCL_BLOB_AFHA_SBOX:
348c0ded849SHemant Agrawal 	case OP_PCL_BLOB_REG_MEMORY:
349c0ded849SHemant Agrawal 	case OP_PCL_BLOB_REG_KEY1:
350c0ded849SHemant Agrawal 	case OP_PCL_BLOB_REG_KEY2:
351c0ded849SHemant Agrawal 	case OP_PCL_BLOB_REG_SPLIT:
352c0ded849SHemant Agrawal 	case OP_PCL_BLOB_REG_PKE:
353c0ded849SHemant Agrawal 		return 0;
354c0ded849SHemant Agrawal 	}
355c0ded849SHemant Agrawal 
356c0ded849SHemant Agrawal 	return -EINVAL;
357c0ded849SHemant Agrawal }
358c0ded849SHemant Agrawal 
359c0ded849SHemant Agrawal static inline int
__rta_dlc_proto(uint16_t protoinfo)360c0ded849SHemant Agrawal __rta_dlc_proto(uint16_t protoinfo)
361c0ded849SHemant Agrawal {
362c0ded849SHemant Agrawal 	switch (protoinfo & OP_PCL_PKPROT_HASH_MASK) {
363c0ded849SHemant Agrawal 	case OP_PCL_PKPROT_HASH_MD5:
364c0ded849SHemant Agrawal 	case OP_PCL_PKPROT_HASH_SHA1:
365c0ded849SHemant Agrawal 	case OP_PCL_PKPROT_HASH_SHA224:
366c0ded849SHemant Agrawal 	case OP_PCL_PKPROT_HASH_SHA256:
367c0ded849SHemant Agrawal 	case OP_PCL_PKPROT_HASH_SHA384:
368c0ded849SHemant Agrawal 	case OP_PCL_PKPROT_HASH_SHA512:
369c0ded849SHemant Agrawal 		break;
370c0ded849SHemant Agrawal 	default:
371c0ded849SHemant Agrawal 		return -EINVAL;
372c0ded849SHemant Agrawal 	}
373c0ded849SHemant Agrawal 
374c0ded849SHemant Agrawal 	return 0;
375c0ded849SHemant Agrawal }
376c0ded849SHemant Agrawal 
377c0ded849SHemant Agrawal static inline int
__rta_rsa_enc_proto(uint16_t protoinfo)378c0ded849SHemant Agrawal __rta_rsa_enc_proto(uint16_t protoinfo)
379c0ded849SHemant Agrawal {
380c0ded849SHemant Agrawal 	switch (protoinfo & OP_PCL_RSAPROT_OP_MASK) {
381c0ded849SHemant Agrawal 	case OP_PCL_RSAPROT_OP_ENC_F_IN:
382c0ded849SHemant Agrawal 		if ((protoinfo & OP_PCL_RSAPROT_FFF_MASK) !=
383c0ded849SHemant Agrawal 		    OP_PCL_RSAPROT_FFF_RED)
384c0ded849SHemant Agrawal 			return -EINVAL;
385c0ded849SHemant Agrawal 		break;
386c0ded849SHemant Agrawal 	case OP_PCL_RSAPROT_OP_ENC_F_OUT:
387c0ded849SHemant Agrawal 		switch (protoinfo & OP_PCL_RSAPROT_FFF_MASK) {
388c0ded849SHemant Agrawal 		case OP_PCL_RSAPROT_FFF_RED:
389c0ded849SHemant Agrawal 		case OP_PCL_RSAPROT_FFF_ENC:
390c0ded849SHemant Agrawal 		case OP_PCL_RSAPROT_FFF_EKT:
391c0ded849SHemant Agrawal 		case OP_PCL_RSAPROT_FFF_TK_ENC:
392c0ded849SHemant Agrawal 		case OP_PCL_RSAPROT_FFF_TK_EKT:
393c0ded849SHemant Agrawal 			break;
394c0ded849SHemant Agrawal 		default:
395c0ded849SHemant Agrawal 			return -EINVAL;
396c0ded849SHemant Agrawal 		}
397c0ded849SHemant Agrawal 		break;
398c0ded849SHemant Agrawal 	default:
399c0ded849SHemant Agrawal 		return -EINVAL;
400c0ded849SHemant Agrawal 	}
401c0ded849SHemant Agrawal 
402c0ded849SHemant Agrawal 	return 0;
403c0ded849SHemant Agrawal }
404c0ded849SHemant Agrawal 
405c0ded849SHemant Agrawal static inline int
__rta_rsa_dec_proto(uint16_t protoinfo)406c0ded849SHemant Agrawal __rta_rsa_dec_proto(uint16_t protoinfo)
407c0ded849SHemant Agrawal {
408c0ded849SHemant Agrawal 	switch (protoinfo & OP_PCL_RSAPROT_OP_MASK) {
409c0ded849SHemant Agrawal 	case OP_PCL_RSAPROT_OP_DEC_ND:
410c0ded849SHemant Agrawal 	case OP_PCL_RSAPROT_OP_DEC_PQD:
411c0ded849SHemant Agrawal 	case OP_PCL_RSAPROT_OP_DEC_PQDPDQC:
412c0ded849SHemant Agrawal 		break;
413c0ded849SHemant Agrawal 	default:
414c0ded849SHemant Agrawal 		return -EINVAL;
415c0ded849SHemant Agrawal 	}
416c0ded849SHemant Agrawal 
417c0ded849SHemant Agrawal 	switch (protoinfo & OP_PCL_RSAPROT_PPP_MASK) {
418c0ded849SHemant Agrawal 	case OP_PCL_RSAPROT_PPP_RED:
419c0ded849SHemant Agrawal 	case OP_PCL_RSAPROT_PPP_ENC:
420c0ded849SHemant Agrawal 	case OP_PCL_RSAPROT_PPP_EKT:
421c0ded849SHemant Agrawal 	case OP_PCL_RSAPROT_PPP_TK_ENC:
422c0ded849SHemant Agrawal 	case OP_PCL_RSAPROT_PPP_TK_EKT:
423c0ded849SHemant Agrawal 		break;
424c0ded849SHemant Agrawal 	default:
425c0ded849SHemant Agrawal 		return -EINVAL;
426c0ded849SHemant Agrawal 	}
427c0ded849SHemant Agrawal 
428c0ded849SHemant Agrawal 	if (protoinfo & OP_PCL_RSAPROT_FMT_PKCSV15)
429c0ded849SHemant Agrawal 		switch (protoinfo & OP_PCL_RSAPROT_FFF_MASK) {
430c0ded849SHemant Agrawal 		case OP_PCL_RSAPROT_FFF_RED:
431c0ded849SHemant Agrawal 		case OP_PCL_RSAPROT_FFF_ENC:
432c0ded849SHemant Agrawal 		case OP_PCL_RSAPROT_FFF_EKT:
433c0ded849SHemant Agrawal 		case OP_PCL_RSAPROT_FFF_TK_ENC:
434c0ded849SHemant Agrawal 		case OP_PCL_RSAPROT_FFF_TK_EKT:
435c0ded849SHemant Agrawal 			break;
436c0ded849SHemant Agrawal 		default:
437c0ded849SHemant Agrawal 			return -EINVAL;
438c0ded849SHemant Agrawal 		}
439c0ded849SHemant Agrawal 
440c0ded849SHemant Agrawal 	return 0;
441c0ded849SHemant Agrawal }
442c0ded849SHemant Agrawal 
443c0ded849SHemant Agrawal /*
444c0ded849SHemant Agrawal  * DKP Protocol - Restrictions on key (SRC,DST) combinations
445c0ded849SHemant Agrawal  * For e.g. key_in_out[0][0] = 1 means (SRC=IMM,DST=IMM) combination is allowed
446c0ded849SHemant Agrawal  */
447c0ded849SHemant Agrawal static const uint8_t key_in_out[4][4] = { {1, 0, 0, 0},
448c0ded849SHemant Agrawal 					  {1, 1, 1, 1},
449c0ded849SHemant Agrawal 					  {1, 0, 1, 0},
450c0ded849SHemant Agrawal 					  {1, 0, 0, 1} };
451c0ded849SHemant Agrawal 
452c0ded849SHemant Agrawal static inline int
__rta_dkp_proto(uint16_t protoinfo)453c0ded849SHemant Agrawal __rta_dkp_proto(uint16_t protoinfo)
454c0ded849SHemant Agrawal {
455c0ded849SHemant Agrawal 	int key_src = (protoinfo & OP_PCL_DKP_SRC_MASK) >> OP_PCL_DKP_SRC_SHIFT;
456c0ded849SHemant Agrawal 	int key_dst = (protoinfo & OP_PCL_DKP_DST_MASK) >> OP_PCL_DKP_DST_SHIFT;
457c0ded849SHemant Agrawal 
458c0ded849SHemant Agrawal 	if (!key_in_out[key_src][key_dst]) {
459c0ded849SHemant Agrawal 		pr_err("PROTO_DESC: Invalid DKP key (SRC,DST)\n");
460c0ded849SHemant Agrawal 		return -EINVAL;
461c0ded849SHemant Agrawal 	}
462c0ded849SHemant Agrawal 
463c0ded849SHemant Agrawal 	return 0;
464c0ded849SHemant Agrawal }
465c0ded849SHemant Agrawal 
466c0ded849SHemant Agrawal 
467c0ded849SHemant Agrawal static inline int
__rta_3g_dcrc_proto(uint16_t protoinfo)468c0ded849SHemant Agrawal __rta_3g_dcrc_proto(uint16_t protoinfo)
469c0ded849SHemant Agrawal {
470c0ded849SHemant Agrawal 	switch (protoinfo) {
471c0ded849SHemant Agrawal 	case OP_PCL_3G_DCRC_CRC7:
472c0ded849SHemant Agrawal 	case OP_PCL_3G_DCRC_CRC11:
473c0ded849SHemant Agrawal 		return 0;
474c0ded849SHemant Agrawal 	}
475c0ded849SHemant Agrawal 
476c0ded849SHemant Agrawal 	return -EINVAL;
477c0ded849SHemant Agrawal }
478c0ded849SHemant Agrawal 
479c0ded849SHemant Agrawal static inline int
__rta_3g_rlc_proto(uint16_t protoinfo)480c0ded849SHemant Agrawal __rta_3g_rlc_proto(uint16_t protoinfo)
481c0ded849SHemant Agrawal {
482c0ded849SHemant Agrawal 	switch (protoinfo) {
483c0ded849SHemant Agrawal 	case OP_PCL_3G_RLC_NULL:
484c0ded849SHemant Agrawal 	case OP_PCL_3G_RLC_KASUMI:
485c0ded849SHemant Agrawal 	case OP_PCL_3G_RLC_SNOW:
486c0ded849SHemant Agrawal 		return 0;
487c0ded849SHemant Agrawal 	}
488c0ded849SHemant Agrawal 
489c0ded849SHemant Agrawal 	return -EINVAL;
490c0ded849SHemant Agrawal }
491c0ded849SHemant Agrawal 
492c0ded849SHemant Agrawal static inline int
__rta_lte_pdcp_proto(uint16_t protoinfo)493c0ded849SHemant Agrawal __rta_lte_pdcp_proto(uint16_t protoinfo)
494c0ded849SHemant Agrawal {
495c0ded849SHemant Agrawal 	switch (protoinfo) {
496c0ded849SHemant Agrawal 	case OP_PCL_LTE_ZUC:
497c0ded849SHemant Agrawal 	case OP_PCL_LTE_NULL:
498c0ded849SHemant Agrawal 	case OP_PCL_LTE_SNOW:
499c0ded849SHemant Agrawal 	case OP_PCL_LTE_AES:
500c0ded849SHemant Agrawal 		return 0;
501c0ded849SHemant Agrawal 	}
502c0ded849SHemant Agrawal 
503c0ded849SHemant Agrawal 	return -EINVAL;
504c0ded849SHemant Agrawal }
505c0ded849SHemant Agrawal 
506c0ded849SHemant Agrawal static inline int
__rta_lte_pdcp_mixed_proto(uint16_t protoinfo)507c0ded849SHemant Agrawal __rta_lte_pdcp_mixed_proto(uint16_t protoinfo)
508c0ded849SHemant Agrawal {
509c0ded849SHemant Agrawal 	switch (protoinfo & OP_PCL_LTE_MIXED_AUTH_MASK) {
510c0ded849SHemant Agrawal 	case OP_PCL_LTE_MIXED_AUTH_NULL:
511c0ded849SHemant Agrawal 	case OP_PCL_LTE_MIXED_AUTH_SNOW:
512c0ded849SHemant Agrawal 	case OP_PCL_LTE_MIXED_AUTH_AES:
513c0ded849SHemant Agrawal 	case OP_PCL_LTE_MIXED_AUTH_ZUC:
514c0ded849SHemant Agrawal 		break;
515c0ded849SHemant Agrawal 	default:
516c0ded849SHemant Agrawal 		return -EINVAL;
517c0ded849SHemant Agrawal 	}
518c0ded849SHemant Agrawal 
519c0ded849SHemant Agrawal 	switch (protoinfo & OP_PCL_LTE_MIXED_ENC_MASK) {
520c0ded849SHemant Agrawal 	case OP_PCL_LTE_MIXED_ENC_NULL:
521c0ded849SHemant Agrawal 	case OP_PCL_LTE_MIXED_ENC_SNOW:
522c0ded849SHemant Agrawal 	case OP_PCL_LTE_MIXED_ENC_AES:
523c0ded849SHemant Agrawal 	case OP_PCL_LTE_MIXED_ENC_ZUC:
524c0ded849SHemant Agrawal 		return 0;
525c0ded849SHemant Agrawal 	}
526c0ded849SHemant Agrawal 
527c0ded849SHemant Agrawal 	return -EINVAL;
528c0ded849SHemant Agrawal }
529c0ded849SHemant Agrawal 
530c0ded849SHemant Agrawal struct proto_map {
531c0ded849SHemant Agrawal 	uint32_t optype;
532c0ded849SHemant Agrawal 	uint32_t protid;
533c0ded849SHemant Agrawal 	int (*protoinfo_func)(uint16_t);
534c0ded849SHemant Agrawal };
535c0ded849SHemant Agrawal 
536c0ded849SHemant Agrawal static const struct proto_map proto_table[] = {
537c0ded849SHemant Agrawal /*1*/	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_SSL30_PRF,	 __rta_ssl_proto},
538c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_TLS10_PRF,	 __rta_ssl_proto},
539c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_TLS11_PRF,	 __rta_ssl_proto},
540c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_TLS12_PRF,	 __rta_ssl_proto},
541c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_DTLS_PRF,	 __rta_ssl_proto},
542c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_IKEV1_PRF,	 __rta_ike_proto},
543c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_IKEV2_PRF,	 __rta_ike_proto},
544c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_PUBLICKEYPAIR, __rta_dlc_proto},
545c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_DSASIGN,	 __rta_dlc_proto},
546c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_DSAVERIFY,	 __rta_dlc_proto},
547c0ded849SHemant Agrawal 	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_IPSEC,         __rta_ipsec_proto},
548c0ded849SHemant Agrawal 	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_SRTP,	         __rta_srtp_proto},
549c0ded849SHemant Agrawal 	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_SSL30,	 __rta_ssl_proto},
550c0ded849SHemant Agrawal 	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_TLS10,	 __rta_ssl_proto},
551c0ded849SHemant Agrawal 	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_TLS11,	 __rta_ssl_proto},
552c0ded849SHemant Agrawal 	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_TLS12,	 __rta_ssl_proto},
553c0ded849SHemant Agrawal 	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_DTLS,		 __rta_ssl_proto},
554c0ded849SHemant Agrawal 	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_MACSEC,        __rta_macsec_proto},
555c0ded849SHemant Agrawal 	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_WIFI,          __rta_wifi_proto},
556c0ded849SHemant Agrawal 	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_WIMAX,         __rta_wimax_proto},
557c0ded849SHemant Agrawal /*21*/	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_BLOB,          __rta_blob_proto},
558c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_DIFFIEHELLMAN, __rta_dlc_proto},
559c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_RSAENCRYPT,	 __rta_rsa_enc_proto},
560c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_RSADECRYPT,	 __rta_rsa_dec_proto},
561c0ded849SHemant Agrawal 	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_3G_DCRC,       __rta_3g_dcrc_proto},
562c0ded849SHemant Agrawal 	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_3G_RLC_PDU,    __rta_3g_rlc_proto},
563c0ded849SHemant Agrawal 	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_3G_RLC_SDU,    __rta_3g_rlc_proto},
564c0ded849SHemant Agrawal 	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_LTE_PDCP_USER, __rta_lte_pdcp_proto},
565c0ded849SHemant Agrawal /*29*/	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_LTE_PDCP_CTRL, __rta_lte_pdcp_proto},
566c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_DKP_MD5,       __rta_dkp_proto},
567c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_DKP_SHA1,      __rta_dkp_proto},
568c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_DKP_SHA224,    __rta_dkp_proto},
569c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_DKP_SHA256,    __rta_dkp_proto},
570c0ded849SHemant Agrawal 	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_DKP_SHA384,    __rta_dkp_proto},
571c0ded849SHemant Agrawal /*35*/	{OP_TYPE_UNI_PROTOCOL,   OP_PCLID_DKP_SHA512,    __rta_dkp_proto},
572c0ded849SHemant Agrawal 	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_PUBLICKEYPAIR, __rta_dlc_proto},
573c0ded849SHemant Agrawal /*37*/	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_DSASIGN,	 __rta_dlc_proto},
574c0ded849SHemant Agrawal /*38*/	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_LTE_PDCP_CTRL_MIXED,
575c0ded849SHemant Agrawal 	 __rta_lte_pdcp_mixed_proto},
576c0ded849SHemant Agrawal 	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_IPSEC_NEW,     __rta_ipsec_proto},
577c0ded849SHemant Agrawal /*40*/	{OP_TYPE_DECAP_PROTOCOL, OP_PCLID_LTE_PDCP_USER_RN,
578c0ded849SHemant Agrawal 	__rta_lte_pdcp_mixed_proto},
579c0ded849SHemant Agrawal };
580c0ded849SHemant Agrawal 
581c0ded849SHemant Agrawal /*
582c0ded849SHemant Agrawal  * Allowed OPERATION protocols for each SEC Era.
583c0ded849SHemant Agrawal  * Values represent the number of entries from proto_table[] that are supported.
584c0ded849SHemant Agrawal  */
585c0ded849SHemant Agrawal static const unsigned int proto_table_sz[] = {21, 29, 29, 29, 29, 35, 37,
586c0ded849SHemant Agrawal 						40, 40, 40};
587c0ded849SHemant Agrawal 
588c0ded849SHemant Agrawal static inline int
rta_proto_operation(struct program * program,uint32_t optype,uint32_t protid,uint16_t protoinfo)589c0ded849SHemant Agrawal rta_proto_operation(struct program *program, uint32_t optype,
590c0ded849SHemant Agrawal 				      uint32_t protid, uint16_t protoinfo)
591c0ded849SHemant Agrawal {
592c0ded849SHemant Agrawal 	uint32_t opcode = CMD_OPERATION;
593c0ded849SHemant Agrawal 	unsigned int i, found = 0;
594c0ded849SHemant Agrawal 	uint32_t optype_tmp = optype;
595c0ded849SHemant Agrawal 	unsigned int start_pc = program->current_pc;
596c0ded849SHemant Agrawal 	int ret = -EINVAL;
597c0ded849SHemant Agrawal 
598c0ded849SHemant Agrawal 	for (i = 0; i < proto_table_sz[rta_sec_era]; i++) {
599c0ded849SHemant Agrawal 		/* clear last bit in optype to match also decap proto */
600c0ded849SHemant Agrawal 		optype_tmp &= (uint32_t)~(1 << OP_TYPE_SHIFT);
601c0ded849SHemant Agrawal 		if (optype_tmp == proto_table[i].optype) {
602c0ded849SHemant Agrawal 			if (proto_table[i].protid == protid) {
603c0ded849SHemant Agrawal 				/* nothing else to verify */
604c0ded849SHemant Agrawal 				if (proto_table[i].protoinfo_func == NULL) {
605c0ded849SHemant Agrawal 					found = 1;
606c0ded849SHemant Agrawal 					break;
607c0ded849SHemant Agrawal 				}
608c0ded849SHemant Agrawal 				/* check protoinfo */
609c0ded849SHemant Agrawal 				ret = (*proto_table[i].protoinfo_func)
610c0ded849SHemant Agrawal 						(protoinfo);
611c0ded849SHemant Agrawal 				if (ret < 0) {
612c0ded849SHemant Agrawal 					pr_err("PROTO_DESC: Bad PROTO Type. SEC Program Line: %d\n",
613c0ded849SHemant Agrawal 					       program->current_pc);
614c0ded849SHemant Agrawal 					goto err;
615c0ded849SHemant Agrawal 				}
616c0ded849SHemant Agrawal 				found = 1;
617c0ded849SHemant Agrawal 				break;
618c0ded849SHemant Agrawal 			}
619c0ded849SHemant Agrawal 		}
620c0ded849SHemant Agrawal 	}
621c0ded849SHemant Agrawal 	if (!found) {
622c0ded849SHemant Agrawal 		pr_err("PROTO_DESC: Operation Type Mismatch. SEC Program Line: %d\n",
623c0ded849SHemant Agrawal 		       program->current_pc);
624c0ded849SHemant Agrawal 		goto err;
625c0ded849SHemant Agrawal 	}
626c0ded849SHemant Agrawal 
627c0ded849SHemant Agrawal 	__rta_out32(program, opcode | optype | protid | protoinfo);
628c0ded849SHemant Agrawal 	program->current_instruction++;
629c0ded849SHemant Agrawal 	return (int)start_pc;
630c0ded849SHemant Agrawal 
631c0ded849SHemant Agrawal  err:
632c0ded849SHemant Agrawal 	program->first_error_pc = start_pc;
633c0ded849SHemant Agrawal 	program->current_instruction++;
634c0ded849SHemant Agrawal 	return ret;
635c0ded849SHemant Agrawal }
636c0ded849SHemant Agrawal 
637c0ded849SHemant Agrawal static inline int
rta_dkp_proto(struct program * program,uint32_t protid,uint16_t key_src,uint16_t key_dst,uint16_t keylen,uint64_t key,enum rta_data_type key_type)638c0ded849SHemant Agrawal rta_dkp_proto(struct program *program, uint32_t protid,
639c0ded849SHemant Agrawal 				uint16_t key_src, uint16_t key_dst,
640c0ded849SHemant Agrawal 				uint16_t keylen, uint64_t key,
641c0ded849SHemant Agrawal 				enum rta_data_type key_type)
642c0ded849SHemant Agrawal {
643c0ded849SHemant Agrawal 	unsigned int start_pc = program->current_pc;
644c0ded849SHemant Agrawal 	unsigned int in_words = 0, out_words = 0;
645c0ded849SHemant Agrawal 	int ret;
646c0ded849SHemant Agrawal 
647c0ded849SHemant Agrawal 	key_src &= OP_PCL_DKP_SRC_MASK;
648c0ded849SHemant Agrawal 	key_dst &= OP_PCL_DKP_DST_MASK;
649c0ded849SHemant Agrawal 	keylen &= OP_PCL_DKP_KEY_MASK;
650c0ded849SHemant Agrawal 
651c0ded849SHemant Agrawal 	ret = rta_proto_operation(program, OP_TYPE_UNI_PROTOCOL, protid,
652c0ded849SHemant Agrawal 				  key_src | key_dst | keylen);
653c0ded849SHemant Agrawal 	if (ret < 0)
654c0ded849SHemant Agrawal 		return ret;
655c0ded849SHemant Agrawal 
656c0ded849SHemant Agrawal 	if ((key_src == OP_PCL_DKP_SRC_PTR) ||
657c0ded849SHemant Agrawal 	    (key_src == OP_PCL_DKP_SRC_SGF)) {
658c0ded849SHemant Agrawal 		__rta_out64(program, program->ps, key);
659c0ded849SHemant Agrawal 		in_words = program->ps ? 2 : 1;
660c0ded849SHemant Agrawal 	} else if (key_src == OP_PCL_DKP_SRC_IMM) {
661c0ded849SHemant Agrawal 		__rta_inline_data(program, key, inline_flags(key_type), keylen);
662c0ded849SHemant Agrawal 		in_words = (unsigned int)((keylen + 3) / 4);
663c0ded849SHemant Agrawal 	}
664c0ded849SHemant Agrawal 
665c0ded849SHemant Agrawal 	if ((key_dst == OP_PCL_DKP_DST_PTR) ||
666c0ded849SHemant Agrawal 	    (key_dst == OP_PCL_DKP_DST_SGF)) {
667c0ded849SHemant Agrawal 		out_words = in_words;
668c0ded849SHemant Agrawal 	} else  if (key_dst == OP_PCL_DKP_DST_IMM) {
669c0ded849SHemant Agrawal 		out_words = split_key_len(protid) / 4;
670c0ded849SHemant Agrawal 	}
671c0ded849SHemant Agrawal 
672c0ded849SHemant Agrawal 	if (out_words < in_words) {
673c0ded849SHemant Agrawal 		pr_err("PROTO_DESC: DKP doesn't currently support a smaller descriptor\n");
674c0ded849SHemant Agrawal 		program->first_error_pc = start_pc;
675c0ded849SHemant Agrawal 		return -EINVAL;
676c0ded849SHemant Agrawal 	}
677c0ded849SHemant Agrawal 
678c0ded849SHemant Agrawal 	/* If needed, reserve space in resulting descriptor for derived key */
679c0ded849SHemant Agrawal 	program->current_pc += (out_words - in_words);
680c0ded849SHemant Agrawal 
681c0ded849SHemant Agrawal 	return (int)start_pc;
682c0ded849SHemant Agrawal }
683c0ded849SHemant Agrawal 
684c0ded849SHemant Agrawal #endif /* __RTA_PROTOCOL_CMD_H__ */
685