crypto/dpaa2_sec: add run-time assembler for descriptor
[dpdk.git] / drivers / crypto / dpaa2_sec / hw / rta / signature_cmd.h
1 /*
2  * Copyright 2008-2016 Freescale Semiconductor, Inc.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause or GPL-2.0+
5  */
6
7 #ifndef __RTA_SIGNATURE_CMD_H__
8 #define __RTA_SIGNATURE_CMD_H__
9
10 static inline int
11 rta_signature(struct program *program, uint32_t sign_type)
12 {
13         uint32_t opcode = CMD_SIGNATURE;
14         unsigned int start_pc = program->current_pc;
15
16         switch (sign_type) {
17         case (SIGN_TYPE_FINAL):
18         case (SIGN_TYPE_FINAL_RESTORE):
19         case (SIGN_TYPE_FINAL_NONZERO):
20         case (SIGN_TYPE_IMM_2):
21         case (SIGN_TYPE_IMM_3):
22         case (SIGN_TYPE_IMM_4):
23                 opcode |= sign_type;
24                 break;
25         default:
26                 pr_err("SIGNATURE Command: Invalid type selection\n");
27                 goto err;
28         }
29
30         __rta_out32(program, opcode);
31         program->current_instruction++;
32
33         return (int)start_pc;
34
35  err:
36         program->first_error_pc = start_pc;
37         program->current_instruction++;
38         return -EINVAL;
39 }
40
41 #endif /* __RTA_SIGNATURE_CMD_H__ */