4 * Copyright 2009-2011 Freescale Semiconductor, Inc.
14 #define SPRINTFCAT(str, format, param, max_alloc) \
18 tmp = kmalloc(sizeof(format) + max_alloc, GFP_ATOMIC); \
20 sprintf(tmp, format, param); \
24 strcat(str, "kmalloc failure in SPRINTFCAT"); \
28 static void report_jump_idx(u32 status, char *outstr)
30 u8 idx = (status & JRSTA_DECOERR_INDEX_MASK) >>
31 JRSTA_DECOERR_INDEX_SHIFT;
33 if (status & JRSTA_DECOERR_JUMP)
34 strcat(outstr, "jump tgt desc idx ");
36 strcat(outstr, "desc idx ");
38 SPRINTFCAT(outstr, "%d: ", idx, sizeof("255"));
41 static void report_ccb_status(u32 status, char *outstr)
43 static const char * const cha_id_list[] = {
58 static const char * const err_id_list[] = {
63 "PKHA A memory size error.",
64 "PKHA B memory size error.",
65 "Data arrived out of sequence error.",
66 "PKHA divide-by-zero error.",
67 "PKHA modulus even error.",
68 "DES key parity error.",
71 "Unsupported CCM AAD size.",
72 "Class 1 CHA is not reset",
73 "Invalid CHA combination was selected",
74 "Invalid CHA selected.",
76 static const char * const rng_err_id_list[] = {
83 "Prediction resistance",
84 "Prediction resistance and test request",
86 "Secure key generation",
88 u8 cha_id = (status & JRSTA_CCBERR_CHAID_MASK) >>
89 JRSTA_CCBERR_CHAID_SHIFT;
90 u8 err_id = status & JRSTA_CCBERR_ERRID_MASK;
92 report_jump_idx(status, outstr);
94 if (cha_id < ARRAY_SIZE(cha_id_list)) {
95 SPRINTFCAT(outstr, "%s: ", cha_id_list[cha_id],
96 strlen(cha_id_list[cha_id]));
98 SPRINTFCAT(outstr, "unidentified cha_id value 0x%02x: ",
99 cha_id, sizeof("ff"));
102 if ((cha_id << JRSTA_CCBERR_CHAID_SHIFT) == JRSTA_CCBERR_CHAID_RNG &&
103 err_id < ARRAY_SIZE(rng_err_id_list) &&
104 strlen(rng_err_id_list[err_id])) {
106 SPRINTFCAT(outstr, "%s", rng_err_id_list[err_id],
107 strlen(rng_err_id_list[err_id]));
108 } else if (err_id < ARRAY_SIZE(err_id_list)) {
109 SPRINTFCAT(outstr, "%s", err_id_list[err_id],
110 strlen(err_id_list[err_id]));
112 SPRINTFCAT(outstr, "unidentified err_id value 0x%02x",
113 err_id, sizeof("ff"));
117 static void report_jump_status(u32 status, char *outstr)
119 SPRINTFCAT(outstr, "%s() not implemented", __func__, sizeof(__func__));
122 static void report_deco_status(u32 status, char *outstr)
124 static const struct {
127 } desc_error_list[] = {
128 { 0x00, "No error." },
129 { 0x01, "SGT Length Error. The descriptor is trying to read "
130 "more data than is contained in the SGT table." },
131 { 0x02, "SGT Null Entry Error." },
132 { 0x03, "Job Ring Control Error. There is a bad value in the "
133 "Job Ring Control register." },
134 { 0x04, "Invalid Descriptor Command. The Descriptor Command "
135 "field is invalid." },
136 { 0x05, "Reserved." },
137 { 0x06, "Invalid KEY Command" },
138 { 0x07, "Invalid LOAD Command" },
139 { 0x08, "Invalid STORE Command" },
140 { 0x09, "Invalid OPERATION Command" },
141 { 0x0A, "Invalid FIFO LOAD Command" },
142 { 0x0B, "Invalid FIFO STORE Command" },
143 { 0x0C, "Invalid MOVE/MOVE_LEN Command" },
144 { 0x0D, "Invalid JUMP Command. A nonlocal JUMP Command is "
145 "invalid because the target is not a Job Header "
146 "Command, or the jump is from a Trusted Descriptor to "
147 "a Job Descriptor, or because the target Descriptor "
148 "contains a Shared Descriptor." },
149 { 0x0E, "Invalid MATH Command" },
150 { 0x0F, "Invalid SIGNATURE Command" },
151 { 0x10, "Invalid Sequence Command. A SEQ IN PTR OR SEQ OUT PTR "
152 "Command is invalid or a SEQ KEY, SEQ LOAD, SEQ FIFO "
153 "LOAD, or SEQ FIFO STORE decremented the input or "
154 "output sequence length below 0. This error may result "
155 "if a built-in PROTOCOL Command has encountered a "
157 { 0x11, "Skip data type invalid. The type must be 0xE or 0xF."},
158 { 0x12, "Shared Descriptor Header Error" },
159 { 0x13, "Header Error. Invalid length or parity, or certain "
161 { 0x14, "Burster Error. Burster has gotten to an illegal "
163 { 0x15, "Context Register Length Error. The descriptor is "
164 "trying to read or write past the end of the Context "
165 "Register. A SEQ LOAD or SEQ STORE with the VLF bit "
166 "set was executed with too large a length in the "
167 "variable length register (VSOL for SEQ STORE or VSIL "
169 { 0x16, "DMA Error" },
170 { 0x17, "Reserved." },
171 { 0x1A, "Job failed due to JR reset" },
172 { 0x1B, "Job failed due to Fail Mode" },
173 { 0x1C, "DECO Watchdog timer timeout error" },
174 { 0x1D, "DECO tried to copy a key from another DECO but the "
175 "other DECO's Key Registers were locked" },
176 { 0x1E, "DECO attempted to copy data from a DECO that had an "
177 "unmasked Descriptor error" },
178 { 0x1F, "LIODN error. DECO was trying to share from itself or "
179 "from another DECO but the two Non-SEQ LIODN values "
180 "didn't match or the 'shared from' DECO's Descriptor "
181 "required that the SEQ LIODNs be the same and they "
183 { 0x20, "DECO has completed a reset initiated via the DRR "
185 { 0x21, "Nonce error. When using EKT (CCM) key encryption "
186 "option in the FIFO STORE Command, the Nonce counter "
187 "reached its maximum value and this encryption mode "
188 "can no longer be used." },
189 { 0x22, "Meta data is too large (> 511 bytes) for TLS decap "
190 "(input frame; block ciphers) and IPsec decap (output "
191 "frame, when doing the next header byte update) and "
192 "DCRC (output frame)." },
193 { 0x23, "Read Input Frame error" },
194 { 0x24, "JDKEK, TDKEK or TDSK not loaded error" },
195 { 0x80, "DNR (do not run) error" },
196 { 0x81, "undefined protocol command" },
197 { 0x82, "invalid setting in PDB" },
198 { 0x83, "Anti-replay LATE error" },
199 { 0x84, "Anti-replay REPLAY error" },
200 { 0x85, "Sequence number overflow" },
201 { 0x86, "Sigver invalid signature" },
202 { 0x87, "DSA Sign Illegal test descriptor" },
203 { 0x88, "Protocol Format Error - A protocol has seen an error "
204 "in the format of data received. When running RSA, "
205 "this means that formatting with random padding was "
206 "used, and did not follow the form: 0x00, 0x02, 8-to-N "
207 "bytes of non-zero pad, 0x00, F data." },
208 { 0x89, "Protocol Size Error - A protocol has seen an error in "
209 "size. When running RSA, pdb size N < (size of F) when "
210 "no formatting is used; or pdb size N < (F + 11) when "
211 "formatting is used." },
212 { 0xC1, "Blob Command error: Undefined mode" },
213 { 0xC2, "Blob Command error: Secure Memory Blob mode error" },
214 { 0xC4, "Blob Command error: Black Blob key or input size "
216 { 0xC5, "Blob Command error: Invalid key destination" },
217 { 0xC8, "Blob Command error: Trusted/Secure mode error" },
218 { 0xF0, "IPsec TTL or hop limit field either came in as 0, "
219 "or was decremented to 0" },
220 { 0xF1, "3GPP HFN matches or exceeds the Threshold" },
222 u8 desc_error = status & JRSTA_DECOERR_ERROR_MASK;
225 report_jump_idx(status, outstr);
227 for (i = 0; i < ARRAY_SIZE(desc_error_list); i++)
228 if (desc_error_list[i].value == desc_error)
231 if (i != ARRAY_SIZE(desc_error_list) && desc_error_list[i].error_text) {
232 SPRINTFCAT(outstr, "%s", desc_error_list[i].error_text,
233 strlen(desc_error_list[i].error_text));
235 SPRINTFCAT(outstr, "unidentified error value 0x%02x",
236 desc_error, sizeof("ff"));
240 static void report_jr_status(u32 status, char *outstr)
242 SPRINTFCAT(outstr, "%s() not implemented", __func__, sizeof(__func__));
245 static void report_cond_code_status(u32 status, char *outstr)
247 SPRINTFCAT(outstr, "%s() not implemented", __func__, sizeof(__func__));
250 char *caam_jr_strstatus(char *outstr, u32 status)
252 static const struct stat_src {
253 void (*report_ssed)(u32 status, char *outstr);
256 { NULL, "No error" },
258 { report_ccb_status, "CCB" },
259 { report_jump_status, "Jump" },
260 { report_deco_status, "DECO" },
262 { report_jr_status, "Job Ring" },
263 { report_cond_code_status, "Condition Code" },
265 u32 ssrc = status >> JRSTA_SSRC_SHIFT;
267 sprintf(outstr, "%s: ", status_src[ssrc].error);
269 if (status_src[ssrc].report_ssed)
270 status_src[ssrc].report_ssed(status, outstr);
274 EXPORT_SYMBOL(caam_jr_strstatus);