xref: /dpdk/drivers/common/dpaax/caamflib/rta.h (revision 83087a92e29c1ce8c197c321b469713dc43b9c77)
1c0ded849SHemant Agrawal /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2c0ded849SHemant Agrawal  *
3c0ded849SHemant Agrawal  * Copyright 2008-2016 Freescale Semiconductor Inc.
4*83087a92SHemant Agrawal  * Copyright 2016,2021 NXP
5c0ded849SHemant Agrawal  *
6c0ded849SHemant Agrawal  */
7c0ded849SHemant Agrawal 
8c0ded849SHemant Agrawal #ifndef __RTA_RTA_H__
9c0ded849SHemant Agrawal #define __RTA_RTA_H__
10c0ded849SHemant Agrawal 
11c0ded849SHemant Agrawal #include "rta/sec_run_time_asm.h"
12c0ded849SHemant Agrawal #include "rta/fifo_load_store_cmd.h"
13c0ded849SHemant Agrawal #include "rta/header_cmd.h"
14c0ded849SHemant Agrawal #include "rta/jump_cmd.h"
15c0ded849SHemant Agrawal #include "rta/key_cmd.h"
16c0ded849SHemant Agrawal #include "rta/load_cmd.h"
17c0ded849SHemant Agrawal #include "rta/math_cmd.h"
18c0ded849SHemant Agrawal #include "rta/move_cmd.h"
19c0ded849SHemant Agrawal #include "rta/nfifo_cmd.h"
20c0ded849SHemant Agrawal #include "rta/operation_cmd.h"
21c0ded849SHemant Agrawal #include "rta/protocol_cmd.h"
22c0ded849SHemant Agrawal #include "rta/seq_in_out_ptr_cmd.h"
23c0ded849SHemant Agrawal #include "rta/signature_cmd.h"
24c0ded849SHemant Agrawal #include "rta/store_cmd.h"
25c0ded849SHemant Agrawal 
26c0ded849SHemant Agrawal /**
27c0ded849SHemant Agrawal  * DOC: About
28c0ded849SHemant Agrawal  *
29c0ded849SHemant Agrawal  * RTA (Runtime Assembler) Library is an easy and flexible runtime method for
30c0ded849SHemant Agrawal  * writing SEC descriptors. It implements a thin abstraction layer above
31c0ded849SHemant Agrawal  * SEC commands set; the resulting code is compact and similar to a
32c0ded849SHemant Agrawal  * descriptor sequence.
33c0ded849SHemant Agrawal  *
34c0ded849SHemant Agrawal  * RTA library improves comprehension of the SEC code, adds flexibility for
35c0ded849SHemant Agrawal  * writing complex descriptors and keeps the code lightweight. Should be used
36c0ded849SHemant Agrawal  * by whom needs to encode descriptors at runtime, with comprehensible flow
37c0ded849SHemant Agrawal  * control in descriptor.
38c0ded849SHemant Agrawal  */
39c0ded849SHemant Agrawal 
40c0ded849SHemant Agrawal /**
41c0ded849SHemant Agrawal  * DOC: Usage
42c0ded849SHemant Agrawal  *
43c0ded849SHemant Agrawal  * RTA is used in kernel space by the SEC / CAAM (Cryptographic Acceleration and
44c0ded849SHemant Agrawal  * Assurance Module) kernel module (drivers/crypto/caam) and SEC / CAAM QI
45c0ded849SHemant Agrawal  * kernel module (Freescale QorIQ SDK).
46c0ded849SHemant Agrawal  *
47c0ded849SHemant Agrawal  * RTA is used in user space by USDPAA - User Space DataPath Acceleration
48c0ded849SHemant Agrawal  * Architecture (Freescale QorIQ SDK).
49c0ded849SHemant Agrawal  */
50c0ded849SHemant Agrawal 
51c0ded849SHemant Agrawal /**
52c0ded849SHemant Agrawal  * DOC: Descriptor Buffer Management Routines
53c0ded849SHemant Agrawal  *
54c0ded849SHemant Agrawal  * Contains details of RTA descriptor buffer management and SEC Era
55c0ded849SHemant Agrawal  * management routines.
56c0ded849SHemant Agrawal  */
57c0ded849SHemant Agrawal 
58c0ded849SHemant Agrawal /**
59c0ded849SHemant Agrawal  * PROGRAM_CNTXT_INIT - must be called before any descriptor run-time assembly
60c0ded849SHemant Agrawal  *                      call type field carry info i.e. whether descriptor is
61c0ded849SHemant Agrawal  *                      shared or job descriptor.
62c0ded849SHemant Agrawal  * @program: pointer to struct program
63c0ded849SHemant Agrawal  * @buffer: input buffer where the descriptor will be placed (uint32_t *)
64c0ded849SHemant Agrawal  * @offset: offset in input buffer from where the data will be written
65c0ded849SHemant Agrawal  *          (unsigned int)
66c0ded849SHemant Agrawal  */
67c0ded849SHemant Agrawal #define PROGRAM_CNTXT_INIT(program, buffer, offset) \
68c0ded849SHemant Agrawal 	rta_program_cntxt_init(program, buffer, offset)
69c0ded849SHemant Agrawal 
70c0ded849SHemant Agrawal /**
71c0ded849SHemant Agrawal  * PROGRAM_FINALIZE - must be called to mark completion of RTA call.
72c0ded849SHemant Agrawal  * @program: pointer to struct program
73c0ded849SHemant Agrawal  *
74c0ded849SHemant Agrawal  * Return: total size of the descriptor in words or negative number on error.
75c0ded849SHemant Agrawal  */
76c0ded849SHemant Agrawal #define PROGRAM_FINALIZE(program) rta_program_finalize(program)
77c0ded849SHemant Agrawal 
78c0ded849SHemant Agrawal /**
79c0ded849SHemant Agrawal  * PROGRAM_SET_36BIT_ADDR - must be called to set pointer size to 36 bits
80c0ded849SHemant Agrawal  * @program: pointer to struct program
81c0ded849SHemant Agrawal  *
82c0ded849SHemant Agrawal  * Return: current size of the descriptor in words (unsigned int).
83c0ded849SHemant Agrawal  */
84c0ded849SHemant Agrawal #define PROGRAM_SET_36BIT_ADDR(program) rta_program_set_36bit_addr(program)
85c0ded849SHemant Agrawal 
86c0ded849SHemant Agrawal /**
87c0ded849SHemant Agrawal  * PROGRAM_SET_BSWAP - must be called to enable byte swapping
88c0ded849SHemant Agrawal  * @program: pointer to struct program
89c0ded849SHemant Agrawal  *
90c0ded849SHemant Agrawal  * Byte swapping on a 4-byte boundary will be performed at the end - when
91c0ded849SHemant Agrawal  * calling PROGRAM_FINALIZE().
92c0ded849SHemant Agrawal  *
93c0ded849SHemant Agrawal  * Return: current size of the descriptor in words (unsigned int).
94c0ded849SHemant Agrawal  */
95c0ded849SHemant Agrawal #define PROGRAM_SET_BSWAP(program) rta_program_set_bswap(program)
96c0ded849SHemant Agrawal 
97c0ded849SHemant Agrawal /**
98c0ded849SHemant Agrawal  * WORD - must be called to insert in descriptor buffer a 32bit value
99c0ded849SHemant Agrawal  * @program: pointer to struct program
100c0ded849SHemant Agrawal  * @val: input value to be written in descriptor buffer (uint32_t)
101c0ded849SHemant Agrawal  *
102c0ded849SHemant Agrawal  * Return: the descriptor buffer offset where this command is inserted
103c0ded849SHemant Agrawal  * (unsigned int).
104c0ded849SHemant Agrawal  */
105c0ded849SHemant Agrawal #define WORD(program, val) rta_word(program, val)
106c0ded849SHemant Agrawal 
107c0ded849SHemant Agrawal /**
108c0ded849SHemant Agrawal  * DWORD - must be called to insert in descriptor buffer a 64bit value
109c0ded849SHemant Agrawal  * @program: pointer to struct program
110c0ded849SHemant Agrawal  * @val: input value to be written in descriptor buffer (uint64_t)
111c0ded849SHemant Agrawal  *
112c0ded849SHemant Agrawal  * Return: the descriptor buffer offset where this command is inserted
113c0ded849SHemant Agrawal  * (unsigned int).
114c0ded849SHemant Agrawal  */
115c0ded849SHemant Agrawal #define DWORD(program, val) rta_dword(program, val)
116c0ded849SHemant Agrawal 
117c0ded849SHemant Agrawal /**
118c0ded849SHemant Agrawal  * COPY_DATA - must be called to insert in descriptor buffer data larger than
119c0ded849SHemant Agrawal  *             64bits.
120c0ded849SHemant Agrawal  * @program: pointer to struct program
121c0ded849SHemant Agrawal  * @data: input data to be written in descriptor buffer (uint8_t *)
122c0ded849SHemant Agrawal  * @len: length of input data (unsigned int)
123c0ded849SHemant Agrawal  *
124c0ded849SHemant Agrawal  * Return: the descriptor buffer offset where this command is inserted
125c0ded849SHemant Agrawal  * (unsigned int).
126c0ded849SHemant Agrawal  */
127c0ded849SHemant Agrawal #define COPY_DATA(program, data, len) rta_copy_data(program, (data), (len))
128c0ded849SHemant Agrawal 
129c0ded849SHemant Agrawal /**
130c0ded849SHemant Agrawal  * DESC_LEN -  determines job / shared descriptor buffer length (in words)
131c0ded849SHemant Agrawal  * @buffer: descriptor buffer (uint32_t *)
132c0ded849SHemant Agrawal  *
133c0ded849SHemant Agrawal  * Return: descriptor buffer length in words (unsigned int).
134c0ded849SHemant Agrawal  */
135c0ded849SHemant Agrawal #define DESC_LEN(buffer) rta_desc_len(buffer)
136c0ded849SHemant Agrawal 
137c0ded849SHemant Agrawal /**
138c0ded849SHemant Agrawal  * DESC_BYTES - determines job / shared descriptor buffer length (in bytes)
139c0ded849SHemant Agrawal  * @buffer: descriptor buffer (uint32_t *)
140c0ded849SHemant Agrawal  *
141c0ded849SHemant Agrawal  * Return: descriptor buffer length in bytes (unsigned int).
142c0ded849SHemant Agrawal  */
143c0ded849SHemant Agrawal #define DESC_BYTES(buffer) rta_desc_bytes(buffer)
144c0ded849SHemant Agrawal 
145c0ded849SHemant Agrawal /*
146c0ded849SHemant Agrawal  * SEC HW block revision.
147c0ded849SHemant Agrawal  *
148c0ded849SHemant Agrawal  * This *must not be confused with SEC version*:
149c0ded849SHemant Agrawal  * - SEC HW block revision format is "v"
150c0ded849SHemant Agrawal  * - SEC revision format is "x.y"
151c0ded849SHemant Agrawal  */
152c0ded849SHemant Agrawal extern enum rta_sec_era rta_sec_era;
153c0ded849SHemant Agrawal 
154c0ded849SHemant Agrawal /**
155c0ded849SHemant Agrawal  * rta_set_sec_era - Set SEC Era HW block revision for which the RTA library
156c0ded849SHemant Agrawal  *                   will generate the descriptors.
157c0ded849SHemant Agrawal  * @era: SEC Era (enum rta_sec_era)
158c0ded849SHemant Agrawal  *
159c0ded849SHemant Agrawal  * Return: 0 if the ERA was set successfully, -1 otherwise (int)
160c0ded849SHemant Agrawal  *
161c0ded849SHemant Agrawal  * Warning 1: Must be called *only once*, *before* using any other RTA API
162c0ded849SHemant Agrawal  * routine.
163c0ded849SHemant Agrawal  *
164c0ded849SHemant Agrawal  * Warning 2: *Not thread safe*.
165c0ded849SHemant Agrawal  */
166c0ded849SHemant Agrawal static inline int
rta_set_sec_era(enum rta_sec_era era)167c0ded849SHemant Agrawal rta_set_sec_era(enum rta_sec_era era)
168c0ded849SHemant Agrawal {
169c0ded849SHemant Agrawal 	if (era > MAX_SEC_ERA) {
170c0ded849SHemant Agrawal 		rta_sec_era = DEFAULT_SEC_ERA;
171c0ded849SHemant Agrawal 		pr_err("Unsupported SEC ERA. Defaulting to ERA %d\n",
172c0ded849SHemant Agrawal 		       DEFAULT_SEC_ERA + 1);
173c0ded849SHemant Agrawal 		return -1;
174c0ded849SHemant Agrawal 	}
175c0ded849SHemant Agrawal 
176c0ded849SHemant Agrawal 	rta_sec_era = era;
177c0ded849SHemant Agrawal 	return 0;
178c0ded849SHemant Agrawal }
179c0ded849SHemant Agrawal 
180c0ded849SHemant Agrawal /**
181c0ded849SHemant Agrawal  * rta_get_sec_era - Get SEC Era HW block revision for which the RTA library
182c0ded849SHemant Agrawal  *                   will generate the descriptors.
183c0ded849SHemant Agrawal  *
184c0ded849SHemant Agrawal  * Return: SEC Era (unsigned int).
185c0ded849SHemant Agrawal  */
186c0ded849SHemant Agrawal static inline unsigned int
rta_get_sec_era(void)187c0ded849SHemant Agrawal rta_get_sec_era(void)
188c0ded849SHemant Agrawal {
189c0ded849SHemant Agrawal 	return rta_sec_era;
190c0ded849SHemant Agrawal }
191c0ded849SHemant Agrawal 
192c0ded849SHemant Agrawal /**
193c0ded849SHemant Agrawal  * DOC: SEC Commands Routines
194c0ded849SHemant Agrawal  *
195c0ded849SHemant Agrawal  * Contains details of RTA wrapper routines over SEC engine commands.
196c0ded849SHemant Agrawal  */
197c0ded849SHemant Agrawal 
198c0ded849SHemant Agrawal /**
199c0ded849SHemant Agrawal  * SHR_HDR - Configures Shared Descriptor HEADER command
200c0ded849SHemant Agrawal  * @program: pointer to struct program
201c0ded849SHemant Agrawal  * @share: descriptor share state (enum rta_share_type)
202c0ded849SHemant Agrawal  * @start_idx: index in descriptor buffer where the execution of the shared
203c0ded849SHemant Agrawal  *             descriptor should start (@c unsigned int).
204c0ded849SHemant Agrawal  * @flags: operational flags: RIF, DNR, CIF, SC, PD
205c0ded849SHemant Agrawal  *
206c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
207c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
208c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
209c0ded849SHemant Agrawal  *         have been written.
210c0ded849SHemant Agrawal  */
211c0ded849SHemant Agrawal #define SHR_HDR(program, share, start_idx, flags) \
212c0ded849SHemant Agrawal 	rta_shr_header(program, share, start_idx, flags)
213c0ded849SHemant Agrawal 
214c0ded849SHemant Agrawal /**
215c0ded849SHemant Agrawal  * JOB_HDR - Configures JOB Descriptor HEADER command
216c0ded849SHemant Agrawal  * @program: pointer to struct program
217c0ded849SHemant Agrawal  * @share: descriptor share state (enum rta_share_type)
218c0ded849SHemant Agrawal  * @start_idx: index in descriptor buffer where the execution of the job
219c0ded849SHemant Agrawal  *            descriptor should start (unsigned int). In case SHR bit is present
220c0ded849SHemant Agrawal  *            in flags, this will be the shared descriptor length.
221c0ded849SHemant Agrawal  * @share_desc: pointer to shared descriptor, in case SHR bit is set (uint64_t)
222c0ded849SHemant Agrawal  * @flags: operational flags: RSMS, DNR, TD, MTD, REO, SHR
223c0ded849SHemant Agrawal  *
224c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
225c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
226c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
227c0ded849SHemant Agrawal  *         have been written.
228c0ded849SHemant Agrawal  */
229c0ded849SHemant Agrawal #define JOB_HDR(program, share, start_idx, share_desc, flags) \
230c0ded849SHemant Agrawal 	rta_job_header(program, share, start_idx, share_desc, flags, 0)
231c0ded849SHemant Agrawal 
232c0ded849SHemant Agrawal /**
233c0ded849SHemant Agrawal  * JOB_HDR_EXT - Configures JOB Descriptor HEADER command
234c0ded849SHemant Agrawal  * @program: pointer to struct program
235c0ded849SHemant Agrawal  * @share: descriptor share state (enum rta_share_type)
236c0ded849SHemant Agrawal  * @start_idx: index in descriptor buffer where the execution of the job
237c0ded849SHemant Agrawal  *            descriptor should start (unsigned int). In case SHR bit is present
238c0ded849SHemant Agrawal  *            in flags, this will be the shared descriptor length.
239c0ded849SHemant Agrawal  * @share_desc: pointer to shared descriptor, in case SHR bit is set (uint64_t)
240c0ded849SHemant Agrawal  * @flags: operational flags: RSMS, DNR, TD, MTD, REO, SHR
241c0ded849SHemant Agrawal  * @ext_flags: extended header flags: DSV (DECO Select Valid), DECO Id (limited
242c0ded849SHemant Agrawal  *             by DSEL_MASK).
243c0ded849SHemant Agrawal  *
244c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
245c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
246c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
247c0ded849SHemant Agrawal  *         have been written.
248c0ded849SHemant Agrawal  */
249c0ded849SHemant Agrawal #define JOB_HDR_EXT(program, share, start_idx, share_desc, flags, ext_flags) \
250c0ded849SHemant Agrawal 	rta_job_header(program, share, start_idx, share_desc, flags | EXT, \
251c0ded849SHemant Agrawal 		       ext_flags)
252c0ded849SHemant Agrawal 
253c0ded849SHemant Agrawal /**
254c0ded849SHemant Agrawal  * MOVE - Configures MOVE and MOVE_LEN commands
255c0ded849SHemant Agrawal  * @program: pointer to struct program
256c0ded849SHemant Agrawal  * @src: internal source of data that will be moved: CONTEXT1, CONTEXT2, OFIFO,
257c0ded849SHemant Agrawal  *       DESCBUF, MATH0-MATH3, IFIFOABD, IFIFOAB1, IFIFOAB2, AB1, AB2, ABD.
258c0ded849SHemant Agrawal  * @src_offset: offset in source data (uint16_t)
259c0ded849SHemant Agrawal  * @dst: internal destination of data that will be moved: CONTEXT1, CONTEXT2,
260c0ded849SHemant Agrawal  *       OFIFO, DESCBUF, MATH0-MATH3, IFIFOAB1, IFIFOAB2, IFIFO, PKA, KEY1,
261c0ded849SHemant Agrawal  *       KEY2, ALTSOURCE.
262c0ded849SHemant Agrawal  * @dst_offset: offset in destination data (uint16_t)
263c0ded849SHemant Agrawal  * @length: size of data to be moved: for MOVE must be specified as immediate
264c0ded849SHemant Agrawal  *          value and IMMED flag must be set; for MOVE_LEN must be specified
265c0ded849SHemant Agrawal  *          using MATH0-MATH3.
266c0ded849SHemant Agrawal  * @opt: operational flags: WAITCOMP, FLUSH1, FLUSH2, LAST1, LAST2, SIZE_WORD,
267c0ded849SHemant Agrawal  *       SIZE_BYTE, SIZE_DWORD, IMMED (not valid for MOVE_LEN).
268c0ded849SHemant Agrawal  *
269c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
270c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
271c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
272c0ded849SHemant Agrawal  *         have been written.
273c0ded849SHemant Agrawal  */
274c0ded849SHemant Agrawal #define MOVE(program, src, src_offset, dst, dst_offset, length, opt) \
275c0ded849SHemant Agrawal 	rta_move(program, __MOVE, src, src_offset, dst, dst_offset, length, opt)
276c0ded849SHemant Agrawal 
277c0ded849SHemant Agrawal /**
278c0ded849SHemant Agrawal  * MOVEB - Configures MOVEB command
279c0ded849SHemant Agrawal  * @program: pointer to struct program
280c0ded849SHemant Agrawal  * @src: internal source of data that will be moved: CONTEXT1, CONTEXT2, OFIFO,
281c0ded849SHemant Agrawal  *       DESCBUF, MATH0-MATH3, IFIFOABD, IFIFOAB1, IFIFOAB2, AB1, AB2, ABD.
282c0ded849SHemant Agrawal  * @src_offset: offset in source data (uint16_t)
283c0ded849SHemant Agrawal  * @dst: internal destination of data that will be moved: CONTEXT1, CONTEXT2,
284c0ded849SHemant Agrawal  *       OFIFO, DESCBUF, MATH0-MATH3, IFIFOAB1, IFIFOAB2, IFIFO, PKA, KEY1,
285c0ded849SHemant Agrawal  *       KEY2, ALTSOURCE.
286c0ded849SHemant Agrawal  * @dst_offset: offset in destination data (uint16_t)
287c0ded849SHemant Agrawal  * @length: size of data to be moved: for MOVE must be specified as immediate
288c0ded849SHemant Agrawal  *          value and IMMED flag must be set; for MOVE_LEN must be specified
289c0ded849SHemant Agrawal  *          using MATH0-MATH3.
290c0ded849SHemant Agrawal  * @opt: operational flags: WAITCOMP, FLUSH1, FLUSH2, LAST1, LAST2, SIZE_WORD,
291c0ded849SHemant Agrawal  *       SIZE_BYTE, SIZE_DWORD, IMMED (not valid for MOVE_LEN).
292c0ded849SHemant Agrawal  *
293c0ded849SHemant Agrawal  * Identical with MOVE command if byte swapping not enabled; else - when src/dst
294c0ded849SHemant Agrawal  * is descriptor buffer or MATH registers, data type is byte array when MOVE
295c0ded849SHemant Agrawal  * data type is 4-byte array and vice versa.
296c0ded849SHemant Agrawal  *
297c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
298c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
299c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
300c0ded849SHemant Agrawal  *         have been written.
301c0ded849SHemant Agrawal  */
302c0ded849SHemant Agrawal #define MOVEB(program, src, src_offset, dst, dst_offset, length, opt) \
303c0ded849SHemant Agrawal 	rta_move(program, __MOVEB, src, src_offset, dst, dst_offset, length, \
304c0ded849SHemant Agrawal 		 opt)
305c0ded849SHemant Agrawal 
306c0ded849SHemant Agrawal /**
307c0ded849SHemant Agrawal  * MOVEDW - Configures MOVEDW command
308c0ded849SHemant Agrawal  * @program: pointer to struct program
309c0ded849SHemant Agrawal  * @src: internal source of data that will be moved: CONTEXT1, CONTEXT2, OFIFO,
310c0ded849SHemant Agrawal  *       DESCBUF, MATH0-MATH3, IFIFOABD, IFIFOAB1, IFIFOAB2, AB1, AB2, ABD.
311c0ded849SHemant Agrawal  * @src_offset: offset in source data (uint16_t)
312c0ded849SHemant Agrawal  * @dst: internal destination of data that will be moved: CONTEXT1, CONTEXT2,
313c0ded849SHemant Agrawal  *       OFIFO, DESCBUF, MATH0-MATH3, IFIFOAB1, IFIFOAB2, IFIFO, PKA, KEY1,
314c0ded849SHemant Agrawal  *       KEY2, ALTSOURCE.
315c0ded849SHemant Agrawal  * @dst_offset: offset in destination data (uint16_t)
316c0ded849SHemant Agrawal  * @length: size of data to be moved: for MOVE must be specified as immediate
317c0ded849SHemant Agrawal  *          value and IMMED flag must be set; for MOVE_LEN must be specified
318c0ded849SHemant Agrawal  *          using MATH0-MATH3.
319c0ded849SHemant Agrawal  * @opt: operational flags: WAITCOMP, FLUSH1, FLUSH2, LAST1, LAST2, SIZE_WORD,
320c0ded849SHemant Agrawal  *       SIZE_BYTE, SIZE_DWORD, IMMED (not valid for MOVE_LEN).
321c0ded849SHemant Agrawal  *
322c0ded849SHemant Agrawal  * Identical with MOVE command, with the following differences: data type is
323c0ded849SHemant Agrawal  * 8-byte array; word swapping is performed when SEC is programmed in little
324c0ded849SHemant Agrawal  * endian mode.
325c0ded849SHemant Agrawal  *
326c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
327c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
328c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
329c0ded849SHemant Agrawal  *         have been written.
330c0ded849SHemant Agrawal  */
331c0ded849SHemant Agrawal #define MOVEDW(program, src, src_offset, dst, dst_offset, length, opt) \
332c0ded849SHemant Agrawal 	rta_move(program, __MOVEDW, src, src_offset, dst, dst_offset, length, \
333c0ded849SHemant Agrawal 		 opt)
334c0ded849SHemant Agrawal 
335c0ded849SHemant Agrawal /**
336c0ded849SHemant Agrawal  * FIFOLOAD - Configures FIFOLOAD command to load message data, PKHA data, IV,
337c0ded849SHemant Agrawal  *            ICV, AAD and bit length message data into Input Data FIFO.
338c0ded849SHemant Agrawal  * @program: pointer to struct program
339c0ded849SHemant Agrawal  * @data: input data type to store: PKHA registers, IFIFO, MSG1, MSG2,
340c0ded849SHemant Agrawal  *        MSGOUTSNOOP, MSGINSNOOP, IV1, IV2, AAD1, ICV1, ICV2, BIT_DATA, SKIP.
341c0ded849SHemant Agrawal  * @src: pointer or actual data in case of immediate load; IMMED, COPY and DCOPY
342c0ded849SHemant Agrawal  *       flags indicate action taken (inline imm data, inline ptr, inline from
343c0ded849SHemant Agrawal  *       ptr).
344c0ded849SHemant Agrawal  * @length: number of bytes to load (uint32_t)
345c0ded849SHemant Agrawal  * @flags: operational flags: SGF, IMMED, EXT, CLASS1, CLASS2, BOTH, FLUSH1,
346c0ded849SHemant Agrawal  *         LAST1, LAST2, COPY, DCOPY.
347c0ded849SHemant Agrawal  *
348c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
349c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
350c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
351c0ded849SHemant Agrawal  *         have been written.
352c0ded849SHemant Agrawal  */
353c0ded849SHemant Agrawal #define FIFOLOAD(program, data, src, length, flags) \
354c0ded849SHemant Agrawal 	rta_fifo_load(program, data, src, length, flags)
355c0ded849SHemant Agrawal 
356c0ded849SHemant Agrawal /**
357c0ded849SHemant Agrawal  * SEQFIFOLOAD - Configures SEQ FIFOLOAD command to load message data, PKHA
358c0ded849SHemant Agrawal  *               data, IV, ICV, AAD and bit length message data into Input Data
359c0ded849SHemant Agrawal  *               FIFO.
360c0ded849SHemant Agrawal  * @program: pointer to struct program
361c0ded849SHemant Agrawal  * @data: input data type to store: PKHA registers, IFIFO, MSG1, MSG2,
362c0ded849SHemant Agrawal  *        MSGOUTSNOOP, MSGINSNOOP, IV1, IV2, AAD1, ICV1, ICV2, BIT_DATA, SKIP.
363c0ded849SHemant Agrawal  * @length: number of bytes to load; can be set to 0 for SEQ command w/ VLF set
364c0ded849SHemant Agrawal  *          (uint32_t).
365c0ded849SHemant Agrawal  * @flags: operational flags: VLF, CLASS1, CLASS2, BOTH, FLUSH1, LAST1, LAST2,
366c0ded849SHemant Agrawal  *         AIDF.
367c0ded849SHemant Agrawal  *
368c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
369c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
370c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
371c0ded849SHemant Agrawal  *         have been written.
372c0ded849SHemant Agrawal  */
373c0ded849SHemant Agrawal #define SEQFIFOLOAD(program, data, length, flags) \
374c0ded849SHemant Agrawal 	rta_fifo_load(program, data, NONE, length, flags|SEQ)
375c0ded849SHemant Agrawal 
376c0ded849SHemant Agrawal /**
377c0ded849SHemant Agrawal  * FIFOSTORE - Configures FIFOSTORE command, to move data from Output Data FIFO
378c0ded849SHemant Agrawal  *             to external memory via DMA.
379c0ded849SHemant Agrawal  * @program: pointer to struct program
380c0ded849SHemant Agrawal  * @data: output data type to store: PKHA registers, IFIFO, OFIFO, RNG,
381c0ded849SHemant Agrawal  *        RNGOFIFO, AFHA_SBOX, MDHA_SPLIT_KEY, MSG, KEY1, KEY2, SKIP.
382c0ded849SHemant Agrawal  * @encrypt_flags: store data encryption mode: EKT, TK
383c0ded849SHemant Agrawal  * @dst: pointer to store location (uint64_t)
384c0ded849SHemant Agrawal  * @length: number of bytes to load (uint32_t)
385c0ded849SHemant Agrawal  * @flags: operational flags: SGF, CONT, EXT, CLASS1, CLASS2, BOTH
386c0ded849SHemant Agrawal  *
387c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
388c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
389c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
390c0ded849SHemant Agrawal  *         have been written.
391c0ded849SHemant Agrawal  */
392c0ded849SHemant Agrawal #define FIFOSTORE(program, data, encrypt_flags, dst, length, flags) \
393c0ded849SHemant Agrawal 	rta_fifo_store(program, data, encrypt_flags, dst, length, flags)
394c0ded849SHemant Agrawal 
395c0ded849SHemant Agrawal /**
396c0ded849SHemant Agrawal  * SEQFIFOSTORE - Configures SEQ FIFOSTORE command, to move data from Output
397c0ded849SHemant Agrawal  *                Data FIFO to external memory via DMA.
398c0ded849SHemant Agrawal  * @program: pointer to struct program
399c0ded849SHemant Agrawal  * @data: output data type to store: PKHA registers, IFIFO, OFIFO, RNG,
400c0ded849SHemant Agrawal  *        RNGOFIFO, AFHA_SBOX, MDHA_SPLIT_KEY, MSG, KEY1, KEY2, METADATA, SKIP.
401c0ded849SHemant Agrawal  * @encrypt_flags: store data encryption mode: EKT, TK
402c0ded849SHemant Agrawal  * @length: number of bytes to load; can be set to 0 for SEQ command w/ VLF set
403c0ded849SHemant Agrawal  *          (uint32_t).
404c0ded849SHemant Agrawal  * @flags: operational flags: VLF, CONT, EXT, CLASS1, CLASS2, BOTH
405c0ded849SHemant Agrawal  *
406c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
407c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
408c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
409c0ded849SHemant Agrawal  *         have been written.
410c0ded849SHemant Agrawal  */
411c0ded849SHemant Agrawal #define SEQFIFOSTORE(program, data, encrypt_flags, length, flags) \
412c0ded849SHemant Agrawal 	rta_fifo_store(program, data, encrypt_flags, 0, length, flags|SEQ)
413c0ded849SHemant Agrawal 
414c0ded849SHemant Agrawal /**
415c0ded849SHemant Agrawal  * KEY - Configures KEY and SEQ KEY commands
416c0ded849SHemant Agrawal  * @program: pointer to struct program
417c0ded849SHemant Agrawal  * @key_dst: key store location: KEY1, KEY2, PKE, AFHA_SBOX, MDHA_SPLIT_KEY
418c0ded849SHemant Agrawal  * @encrypt_flags: key encryption mode: ENC, EKT, TK, NWB, PTS
419c0ded849SHemant Agrawal  * @src: pointer or actual data in case of immediate load (uint64_t); IMMED,
420c0ded849SHemant Agrawal  *       COPY and DCOPY flags indicate action taken (inline imm data,
421c0ded849SHemant Agrawal  *       inline ptr, inline from ptr).
422c0ded849SHemant Agrawal  * @length: number of bytes to load; can be set to 0 for SEQ command w/ VLF set
423c0ded849SHemant Agrawal  *          (uint32_t).
424c0ded849SHemant Agrawal  * @flags: operational flags: for KEY: SGF, IMMED, COPY, DCOPY; for SEQKEY: SEQ,
425c0ded849SHemant Agrawal  *         VLF, AIDF.
426c0ded849SHemant Agrawal  *
427c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
428c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
429c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
430c0ded849SHemant Agrawal  *         have been written.
431c0ded849SHemant Agrawal  */
432c0ded849SHemant Agrawal #define KEY(program, key_dst, encrypt_flags, src, length, flags) \
433c0ded849SHemant Agrawal 	rta_key(program, key_dst, encrypt_flags, src, length, flags)
434c0ded849SHemant Agrawal 
435c0ded849SHemant Agrawal /**
436c0ded849SHemant Agrawal  * SEQINPTR - Configures SEQ IN PTR command
437c0ded849SHemant Agrawal  * @program: pointer to struct program
438c0ded849SHemant Agrawal  * @src: starting address for Input Sequence (uint64_t)
439c0ded849SHemant Agrawal  * @length: number of bytes in (or to be added to) Input Sequence (uint32_t)
440c0ded849SHemant Agrawal  * @flags: operational flags: RBS, INL, SGF, PRE, EXT, RTO, RJD, SOP (when PRE,
441c0ded849SHemant Agrawal  *         RTO or SOP are set, @src parameter must be 0).
442c0ded849SHemant Agrawal  *
443c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
444c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
445c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
446c0ded849SHemant Agrawal  *         have been written.
447c0ded849SHemant Agrawal  */
448c0ded849SHemant Agrawal #define SEQINPTR(program, src, length, flags) \
449c0ded849SHemant Agrawal 	rta_seq_in_ptr(program, src, length, flags)
450c0ded849SHemant Agrawal 
451c0ded849SHemant Agrawal /**
452c0ded849SHemant Agrawal  * SEQOUTPTR - Configures SEQ OUT PTR command
453c0ded849SHemant Agrawal  * @program: pointer to struct program
454c0ded849SHemant Agrawal  * @dst: starting address for Output Sequence (uint64_t)
455c0ded849SHemant Agrawal  * @length: number of bytes in (or to be added to) Output Sequence (uint32_t)
456c0ded849SHemant Agrawal  * @flags: operational flags: SGF, PRE, EXT, RTO, RST, EWS (when PRE or RTO are
457c0ded849SHemant Agrawal  *         set, @dst parameter must be 0).
458c0ded849SHemant Agrawal  *
459c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
460c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
461c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
462c0ded849SHemant Agrawal  *         have been written.
463c0ded849SHemant Agrawal  */
464c0ded849SHemant Agrawal #define SEQOUTPTR(program, dst, length, flags) \
465c0ded849SHemant Agrawal 	rta_seq_out_ptr(program, dst, length, flags)
466c0ded849SHemant Agrawal 
467c0ded849SHemant Agrawal /**
468c0ded849SHemant Agrawal  * ALG_OPERATION - Configures ALGORITHM OPERATION command
469c0ded849SHemant Agrawal  * @program: pointer to struct program
470c0ded849SHemant Agrawal  * @cipher_alg: algorithm to be used
471c0ded849SHemant Agrawal  * @aai: Additional Algorithm Information; contains mode information that is
472c0ded849SHemant Agrawal  *       associated with the algorithm (check desc.h for specific values).
473c0ded849SHemant Agrawal  * @algo_state: algorithm state; defines the state of the algorithm that is
474c0ded849SHemant Agrawal  *              being executed (check desc.h file for specific values).
475c0ded849SHemant Agrawal  * @icv_check: ICV checking; selects whether the algorithm should check
476c0ded849SHemant Agrawal  *             calculated ICV with known ICV: ICV_CHECK_ENABLE,
477c0ded849SHemant Agrawal  *             ICV_CHECK_DISABLE.
478c0ded849SHemant Agrawal  * @enc: selects between encryption and decryption: DIR_ENC, DIR_DEC
479c0ded849SHemant Agrawal  *
480c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
481c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
482c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
483c0ded849SHemant Agrawal  *         have been written.
484c0ded849SHemant Agrawal  */
485c0ded849SHemant Agrawal #define ALG_OPERATION(program, cipher_alg, aai, algo_state, icv_check, enc) \
486c0ded849SHemant Agrawal 	rta_operation(program, cipher_alg, aai, algo_state, icv_check, enc)
487c0ded849SHemant Agrawal 
488*83087a92SHemant Agrawal #define ALG_OPERATION_NP(program, cipher_alg, aai, algo_state, icv_check, enc) \
489*83087a92SHemant Agrawal 	rta_operation2(program, cipher_alg, aai, algo_state, icv_check, enc)
490*83087a92SHemant Agrawal 
491c0ded849SHemant Agrawal /**
492c0ded849SHemant Agrawal  * PROTOCOL - Configures PROTOCOL OPERATION command
493c0ded849SHemant Agrawal  * @program: pointer to struct program
494c0ded849SHemant Agrawal  * @optype: operation type: OP_TYPE_UNI_PROTOCOL / OP_TYPE_DECAP_PROTOCOL /
495c0ded849SHemant Agrawal  *          OP_TYPE_ENCAP_PROTOCOL.
496c0ded849SHemant Agrawal  * @protid: protocol identifier value (check desc.h file for specific values)
497c0ded849SHemant Agrawal  * @protoinfo: protocol dependent value (check desc.h file for specific values)
498c0ded849SHemant Agrawal  *
499c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
500c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
501c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
502c0ded849SHemant Agrawal  *         have been written.
503c0ded849SHemant Agrawal  */
504c0ded849SHemant Agrawal #define PROTOCOL(program, optype, protid, protoinfo) \
505c0ded849SHemant Agrawal 	rta_proto_operation(program, optype, protid, protoinfo)
506c0ded849SHemant Agrawal 
507c0ded849SHemant Agrawal /**
508c0ded849SHemant Agrawal  * DKP_PROTOCOL - Configures DKP (Derived Key Protocol) PROTOCOL command
509c0ded849SHemant Agrawal  * @program: pointer to struct program
510c0ded849SHemant Agrawal  * @protid: protocol identifier value - one of the following:
511c0ded849SHemant Agrawal  *          OP_PCLID_DKP_{MD5 | SHA1 | SHA224 | SHA256 | SHA384 | SHA512}
512c0ded849SHemant Agrawal  * @key_src: How the initial ("negotiated") key is provided to the DKP protocol.
513c0ded849SHemant Agrawal  *           Valid values - one of OP_PCL_DKP_SRC_{IMM, SEQ, PTR, SGF}. Not all
514c0ded849SHemant Agrawal  *           (key_src,key_dst) combinations are allowed.
515c0ded849SHemant Agrawal  * @key_dst: How the derived ("split") key is returned by the DKP protocol.
516c0ded849SHemant Agrawal  *           Valid values - one of OP_PCL_DKP_DST_{IMM, SEQ, PTR, SGF}. Not all
517c0ded849SHemant Agrawal  *           (key_src,key_dst) combinations are allowed.
518c0ded849SHemant Agrawal  * @keylen: length of the initial key, in bytes (uint16_t)
519c0ded849SHemant Agrawal  * @key: address where algorithm key resides; virtual address if key_type is
520c0ded849SHemant Agrawal  *       RTA_DATA_IMM, physical (bus) address if key_type is RTA_DATA_PTR or
521c0ded849SHemant Agrawal  *       RTA_DATA_IMM_DMA.
522c0ded849SHemant Agrawal  * @key_type: enum rta_data_type
523c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
524c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
525c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
526c0ded849SHemant Agrawal  *         have been written.
527c0ded849SHemant Agrawal  */
528c0ded849SHemant Agrawal #define DKP_PROTOCOL(program, protid, key_src, key_dst, keylen, key, key_type) \
529c0ded849SHemant Agrawal 	rta_dkp_proto(program, protid, key_src, key_dst, keylen, key, key_type)
530c0ded849SHemant Agrawal 
531c0ded849SHemant Agrawal /**
532c0ded849SHemant Agrawal  * PKHA_OPERATION - Configures PKHA OPERATION command
533c0ded849SHemant Agrawal  * @program: pointer to struct program
534c0ded849SHemant Agrawal  * @op_pkha: PKHA operation; indicates the modular arithmetic function to
535c0ded849SHemant Agrawal  *           execute (check desc.h file for specific values).
536c0ded849SHemant Agrawal  *
537c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
538c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
539c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
540c0ded849SHemant Agrawal  *         have been written.
541c0ded849SHemant Agrawal  */
542c0ded849SHemant Agrawal #define PKHA_OPERATION(program, op_pkha)   rta_pkha_operation(program, op_pkha)
543c0ded849SHemant Agrawal 
544c0ded849SHemant Agrawal /**
545c0ded849SHemant Agrawal  * JUMP - Configures JUMP command
546c0ded849SHemant Agrawal  * @program: pointer to struct program
547c0ded849SHemant Agrawal  * @addr: local offset for local jumps or address pointer for non-local jumps;
548c0ded849SHemant Agrawal  *        IMM or PTR macros must be used to indicate type.
549c0ded849SHemant Agrawal  * @jump_type: type of action taken by jump (enum rta_jump_type)
550c0ded849SHemant Agrawal  * @test_type: defines how jump conditions are evaluated (enum rta_jump_cond)
551c0ded849SHemant Agrawal  * @cond: jump conditions: operational flags - DONE1, DONE2, BOTH; various
552c0ded849SHemant Agrawal  *        sharing and wait conditions (JSL = 1) - NIFP, NIP, NOP, NCP, CALM,
553c0ded849SHemant Agrawal  *        SELF, SHARED, JQP; Math and PKHA status conditions (JSL = 0) - Z, N,
554c0ded849SHemant Agrawal  *        NV, C, PK0, PK1, PKP.
555c0ded849SHemant Agrawal  *
556c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
557c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
558c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
559c0ded849SHemant Agrawal  *         have been written.
560c0ded849SHemant Agrawal  */
561c0ded849SHemant Agrawal #define JUMP(program, addr, jump_type, test_type, cond) \
562c0ded849SHemant Agrawal 	rta_jump(program, addr, jump_type, test_type, cond, NONE)
563c0ded849SHemant Agrawal 
564c0ded849SHemant Agrawal /**
565c0ded849SHemant Agrawal  * JUMP_INC - Configures JUMP_INC command
566c0ded849SHemant Agrawal  * @program: pointer to struct program
567c0ded849SHemant Agrawal  * @addr: local offset; IMM or PTR macros must be used to indicate type
568c0ded849SHemant Agrawal  * @test_type: defines how jump conditions are evaluated (enum rta_jump_cond)
569c0ded849SHemant Agrawal  * @cond: jump conditions: Math status conditions (JSL = 0): Z, N, NV, C
570c0ded849SHemant Agrawal  * @src_dst: register to increment / decrement: MATH0-MATH3, DPOVRD, SEQINSZ,
571c0ded849SHemant Agrawal  *           SEQOUTSZ, VSEQINSZ, VSEQOUTSZ.
572c0ded849SHemant Agrawal  *
573c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
574c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
575c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
576c0ded849SHemant Agrawal  *         have been written.
577c0ded849SHemant Agrawal  */
578c0ded849SHemant Agrawal #define JUMP_INC(program, addr, test_type, cond, src_dst) \
579c0ded849SHemant Agrawal 	rta_jump(program, addr, LOCAL_JUMP_INC, test_type, cond, src_dst)
580c0ded849SHemant Agrawal 
581c0ded849SHemant Agrawal /**
582c0ded849SHemant Agrawal  * JUMP_DEC - Configures JUMP_DEC command
583c0ded849SHemant Agrawal  * @program: pointer to struct program
584c0ded849SHemant Agrawal  * @addr: local offset; IMM or PTR macros must be used to indicate type
585c0ded849SHemant Agrawal  * @test_type: defines how jump conditions are evaluated (enum rta_jump_cond)
586c0ded849SHemant Agrawal  * @cond: jump conditions: Math status conditions (JSL = 0): Z, N, NV, C
587c0ded849SHemant Agrawal  * @src_dst: register to increment / decrement: MATH0-MATH3, DPOVRD, SEQINSZ,
588c0ded849SHemant Agrawal  *           SEQOUTSZ, VSEQINSZ, VSEQOUTSZ.
589c0ded849SHemant Agrawal  *
590c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
591c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
592c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
593c0ded849SHemant Agrawal  *         have been written.
594c0ded849SHemant Agrawal  */
595c0ded849SHemant Agrawal #define JUMP_DEC(program, addr, test_type, cond, src_dst) \
596c0ded849SHemant Agrawal 	rta_jump(program, addr, LOCAL_JUMP_DEC, test_type, cond, src_dst)
597c0ded849SHemant Agrawal 
598c0ded849SHemant Agrawal /**
599c0ded849SHemant Agrawal  * LOAD - Configures LOAD command to load data registers from descriptor or from
600c0ded849SHemant Agrawal  *        a memory location.
601c0ded849SHemant Agrawal  * @program: pointer to struct program
602c0ded849SHemant Agrawal  * @addr: immediate value or pointer to the data to be loaded; IMMED, COPY and
603c0ded849SHemant Agrawal  *        DCOPY flags indicate action taken (inline imm data, inline ptr, inline
604c0ded849SHemant Agrawal  *        from ptr).
605c0ded849SHemant Agrawal  * @dst: destination register (uint64_t)
606c0ded849SHemant Agrawal  * @offset: start point to write data in destination register (uint32_t)
607c0ded849SHemant Agrawal  * @length: number of bytes to load (uint32_t)
608c0ded849SHemant Agrawal  * @flags: operational flags: VLF, IMMED, COPY, DCOPY
609c0ded849SHemant Agrawal  *
610c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
611c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
612c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
613c0ded849SHemant Agrawal  *         have been written.
614c0ded849SHemant Agrawal  */
615c0ded849SHemant Agrawal #define LOAD(program, addr, dst, offset, length, flags) \
616c0ded849SHemant Agrawal 	rta_load(program, addr, dst, offset, length, flags)
617c0ded849SHemant Agrawal 
618c0ded849SHemant Agrawal /**
619c0ded849SHemant Agrawal  * SEQLOAD - Configures SEQ LOAD command to load data registers from descriptor
620c0ded849SHemant Agrawal  *           or from a memory location.
621c0ded849SHemant Agrawal  * @program: pointer to struct program
622c0ded849SHemant Agrawal  * @dst: destination register (uint64_t)
623c0ded849SHemant Agrawal  * @offset: start point to write data in destination register (uint32_t)
624c0ded849SHemant Agrawal  * @length: number of bytes to load (uint32_t)
625c0ded849SHemant Agrawal  * @flags: operational flags: SGF
626c0ded849SHemant Agrawal  *
627c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
628c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
629c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
630c0ded849SHemant Agrawal  *         have been written.
631c0ded849SHemant Agrawal  */
632c0ded849SHemant Agrawal #define SEQLOAD(program, dst, offset, length, flags) \
633c0ded849SHemant Agrawal 	rta_load(program, NONE, dst, offset, length, flags|SEQ)
634c0ded849SHemant Agrawal 
635c0ded849SHemant Agrawal /**
636c0ded849SHemant Agrawal  * STORE - Configures STORE command to read data from registers and write them
637c0ded849SHemant Agrawal  *         to a memory location.
638c0ded849SHemant Agrawal  * @program: pointer to struct program
639c0ded849SHemant Agrawal  * @src: immediate value or source register for data to be stored: KEY1SZ,
640c0ded849SHemant Agrawal  *       KEY2SZ, DJQDA, MODE1, MODE2, DJQCTRL, DATA1SZ, DATA2SZ, DSTAT, ICV1SZ,
641c0ded849SHemant Agrawal  *       ICV2SZ, DPID, CCTRL, ICTRL, CLRW, CSTAT, MATH0-MATH3, PKHA registers,
642c0ded849SHemant Agrawal  *       CONTEXT1, CONTEXT2, DESCBUF, JOBDESCBUF, SHAREDESCBUF. In case of
643c0ded849SHemant Agrawal  *       immediate value, IMMED, COPY and DCOPY flags indicate action taken
644c0ded849SHemant Agrawal  *       (inline imm data, inline ptr, inline from ptr).
645c0ded849SHemant Agrawal  * @offset: start point for reading from source register (uint16_t)
646c0ded849SHemant Agrawal  * @dst: pointer to store location (uint64_t)
647c0ded849SHemant Agrawal  * @length: number of bytes to store (uint32_t)
648c0ded849SHemant Agrawal  * @flags: operational flags: VLF, IMMED, COPY, DCOPY
649c0ded849SHemant Agrawal  *
650c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
651c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
652c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
653c0ded849SHemant Agrawal  *         have been written.
654c0ded849SHemant Agrawal  */
655c0ded849SHemant Agrawal #define STORE(program, src, offset, dst, length, flags) \
656c0ded849SHemant Agrawal 	rta_store(program, src, offset, dst, length, flags)
657c0ded849SHemant Agrawal 
658c0ded849SHemant Agrawal /**
659c0ded849SHemant Agrawal  * SEQSTORE - Configures SEQ STORE command to read data from registers and write
660c0ded849SHemant Agrawal  *            them to a memory location.
661c0ded849SHemant Agrawal  * @program: pointer to struct program
662c0ded849SHemant Agrawal  * @src: immediate value or source register for data to be stored: KEY1SZ,
663c0ded849SHemant Agrawal  *       KEY2SZ, DJQDA, MODE1, MODE2, DJQCTRL, DATA1SZ, DATA2SZ, DSTAT, ICV1SZ,
664c0ded849SHemant Agrawal  *       ICV2SZ, DPID, CCTRL, ICTRL, CLRW, CSTAT, MATH0-MATH3, PKHA registers,
665c0ded849SHemant Agrawal  *       CONTEXT1, CONTEXT2, DESCBUF, JOBDESCBUF, SHAREDESCBUF. In case of
666c0ded849SHemant Agrawal  *       immediate value, IMMED, COPY and DCOPY flags indicate action taken
667c0ded849SHemant Agrawal  *       (inline imm data, inline ptr, inline from ptr).
668c0ded849SHemant Agrawal  * @offset: start point for reading from source register (uint16_t)
669c0ded849SHemant Agrawal  * @length: number of bytes to store (uint32_t)
670c0ded849SHemant Agrawal  * @flags: operational flags: SGF, IMMED, COPY, DCOPY
671c0ded849SHemant Agrawal  *
672c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
673c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
674c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
675c0ded849SHemant Agrawal  *         have been written.
676c0ded849SHemant Agrawal  */
677c0ded849SHemant Agrawal #define SEQSTORE(program, src, offset, length, flags) \
678c0ded849SHemant Agrawal 	rta_store(program, src, offset, NONE, length, flags|SEQ)
679c0ded849SHemant Agrawal 
680c0ded849SHemant Agrawal /**
681c0ded849SHemant Agrawal  * MATHB - Configures MATHB command to perform binary operations
682c0ded849SHemant Agrawal  * @program: pointer to struct program
683c0ded849SHemant Agrawal  * @operand1: first operand: MATH0-MATH3, DPOVRD, SEQINSZ, SEQOUTSZ, VSEQINSZ,
684c0ded849SHemant Agrawal  *            VSEQOUTSZ, ZERO, ONE, NONE, Immediate value. IMMED must be used to
685c0ded849SHemant Agrawal  *            indicate immediate value.
686c0ded849SHemant Agrawal  * @operator: function to be performed: ADD, ADDC, SUB, SUBB, OR, AND, XOR,
687c0ded849SHemant Agrawal  *            LSHIFT, RSHIFT, SHLD.
688c0ded849SHemant Agrawal  * @operand2: second operand: MATH0-MATH3, DPOVRD, VSEQINSZ, VSEQOUTSZ, ABD,
689c0ded849SHemant Agrawal  *            OFIFO, JOBSRC, ZERO, ONE, Immediate value. IMMED2 must be used to
690c0ded849SHemant Agrawal  *            indicate immediate value.
691c0ded849SHemant Agrawal  * @result: destination for the result: MATH0-MATH3, DPOVRD, SEQINSZ, SEQOUTSZ,
692c0ded849SHemant Agrawal  *          NONE, VSEQINSZ, VSEQOUTSZ.
693c0ded849SHemant Agrawal  * @length: length in bytes of the operation and the immediate value, if there
694c0ded849SHemant Agrawal  *          is one (int).
695c0ded849SHemant Agrawal  * @opt: operational flags: IFB, NFU, STL, SWP, IMMED, IMMED2
696c0ded849SHemant Agrawal  *
697c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
698c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
699c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
700c0ded849SHemant Agrawal  *         have been written.
701c0ded849SHemant Agrawal  */
702c0ded849SHemant Agrawal #define MATHB(program, operand1, operator, operand2, result, length, opt) \
703c0ded849SHemant Agrawal 	rta_math(program, operand1, MATH_FUN_##operator, operand2, result, \
704c0ded849SHemant Agrawal 		 length, opt)
705c0ded849SHemant Agrawal 
706c0ded849SHemant Agrawal /**
707c0ded849SHemant Agrawal  * MATHI - Configures MATHI command to perform binary operations
708c0ded849SHemant Agrawal  * @program: pointer to struct program
709c0ded849SHemant Agrawal  * @operand: if !SSEL: MATH0-MATH3, DPOVRD, SEQINSZ, SEQOUTSZ, VSEQINSZ,
710c0ded849SHemant Agrawal  *           VSEQOUTSZ, ZERO, ONE.
711c0ded849SHemant Agrawal  *           if SSEL: MATH0-MATH3, DPOVRD, VSEQINSZ, VSEQOUTSZ, ABD, OFIFO,
712c0ded849SHemant Agrawal  *           JOBSRC, ZERO, ONE.
713c0ded849SHemant Agrawal  * @operator: function to be performed: ADD, ADDC, SUB, SUBB, OR, AND, XOR,
714c0ded849SHemant Agrawal  *            LSHIFT, RSHIFT, FBYT (for !SSEL only).
715c0ded849SHemant Agrawal  * @imm: Immediate value (uint8_t). IMMED must be used to indicate immediate
716c0ded849SHemant Agrawal  *       value.
717c0ded849SHemant Agrawal  * @result: destination for the result: MATH0-MATH3, DPOVRD, SEQINSZ, SEQOUTSZ,
718c0ded849SHemant Agrawal  *          NONE, VSEQINSZ, VSEQOUTSZ.
719c0ded849SHemant Agrawal  * @length: length in bytes of the operation and the immediate value, if there
720c0ded849SHemant Agrawal  *          is one (int). @imm is left-extended with zeros if needed.
721c0ded849SHemant Agrawal  * @opt: operational flags: NFU, SSEL, SWP, IMMED
722c0ded849SHemant Agrawal  *
723c0ded849SHemant Agrawal  * If !SSEL, @operand <@operator> @imm -> @result
724c0ded849SHemant Agrawal  * If SSEL, @imm <@operator> @operand -> @result
725c0ded849SHemant Agrawal  *
726c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
727c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
728c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
729c0ded849SHemant Agrawal  *         have been written.
730c0ded849SHemant Agrawal  */
731c0ded849SHemant Agrawal #define MATHI(program, operand, operator, imm, result, length, opt) \
732c0ded849SHemant Agrawal 	rta_mathi(program, operand, MATH_FUN_##operator, imm, result, length, \
733c0ded849SHemant Agrawal 		  opt)
734c0ded849SHemant Agrawal 
735c0ded849SHemant Agrawal /**
736c0ded849SHemant Agrawal  * MATHU - Configures MATHU command to perform unary operations
737c0ded849SHemant Agrawal  * @program: pointer to struct program
738c0ded849SHemant Agrawal  * @operand1: operand: MATH0-MATH3, DPOVRD, SEQINSZ, SEQOUTSZ, VSEQINSZ,
739c0ded849SHemant Agrawal  *            VSEQOUTSZ, ZERO, ONE, NONE, Immediate value. IMMED must be used to
740c0ded849SHemant Agrawal  *            indicate immediate value.
741c0ded849SHemant Agrawal  * @operator: function to be performed: ZBYT, BSWAP
742c0ded849SHemant Agrawal  * @result: destination for the result: MATH0-MATH3, DPOVRD, SEQINSZ, SEQOUTSZ,
743c0ded849SHemant Agrawal  *          NONE, VSEQINSZ, VSEQOUTSZ.
744c0ded849SHemant Agrawal  * @length: length in bytes of the operation and the immediate value, if there
745c0ded849SHemant Agrawal  *          is one (int).
746c0ded849SHemant Agrawal  * @opt: operational flags: NFU, STL, SWP, IMMED
747c0ded849SHemant Agrawal  *
748c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
749c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
750c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
751c0ded849SHemant Agrawal  *         have been written.
752c0ded849SHemant Agrawal  */
753c0ded849SHemant Agrawal #define MATHU(program, operand1, operator, result, length, opt) \
754c0ded849SHemant Agrawal 	rta_math(program, operand1, MATH_FUN_##operator, NONE, result, length, \
755c0ded849SHemant Agrawal 		 opt)
756c0ded849SHemant Agrawal 
757c0ded849SHemant Agrawal /**
758c0ded849SHemant Agrawal  * SIGNATURE - Configures SIGNATURE command
759c0ded849SHemant Agrawal  * @program: pointer to struct program
760c0ded849SHemant Agrawal  * @sign_type: signature type: SIGN_TYPE_FINAL, SIGN_TYPE_FINAL_RESTORE,
761c0ded849SHemant Agrawal  *             SIGN_TYPE_FINAL_NONZERO, SIGN_TYPE_IMM_2, SIGN_TYPE_IMM_3,
762c0ded849SHemant Agrawal  *             SIGN_TYPE_IMM_4.
763c0ded849SHemant Agrawal  *
764c0ded849SHemant Agrawal  * After SIGNATURE command, DWORD or WORD must be used to insert signature in
765c0ded849SHemant Agrawal  * descriptor buffer.
766c0ded849SHemant Agrawal  *
767c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
768c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
769c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
770c0ded849SHemant Agrawal  *         have been written.
771c0ded849SHemant Agrawal  */
772c0ded849SHemant Agrawal #define SIGNATURE(program, sign_type)   rta_signature(program, sign_type)
773c0ded849SHemant Agrawal 
774c0ded849SHemant Agrawal /**
775c0ded849SHemant Agrawal  * NFIFOADD - Configures NFIFO command, a shortcut of RTA Load command to write
776c0ded849SHemant Agrawal  *            to iNfo FIFO.
777c0ded849SHemant Agrawal  * @program: pointer to struct program
778c0ded849SHemant Agrawal  * @src: source for the input data in Alignment Block:IFIFO, OFIFO, PAD,
779c0ded849SHemant Agrawal  *       MSGOUTSNOOP, ALTSOURCE, OFIFO_SYNC, MSGOUTSNOOP_ALT.
780c0ded849SHemant Agrawal  * @data: type of data that is going through the Input Data FIFO: MSG, MSG1,
781c0ded849SHemant Agrawal  *        MSG2, IV1, IV2, ICV1, ICV2, SAD1, AAD1, AAD2, AFHA_SBOX, SKIP,
782c0ded849SHemant Agrawal  *        PKHA registers, AB1, AB2, ABD.
783c0ded849SHemant Agrawal  * @length: length of the data copied in FIFO registers (uint32_t)
784c0ded849SHemant Agrawal  * @flags: select options between:
785c0ded849SHemant Agrawal  *         -operational flags: LAST1, LAST2, FLUSH1, FLUSH2, OC, BP
786c0ded849SHemant Agrawal  *         -when PAD is selected as source: BM, PR, PS
787c0ded849SHemant Agrawal  *         -padding type: <em>PAD_ZERO, PAD_NONZERO, PAD_INCREMENT, PAD_RANDOM,
788c0ded849SHemant Agrawal  *          PAD_ZERO_N1, PAD_NONZERO_0, PAD_N1, PAD_NONZERO_N
789c0ded849SHemant Agrawal  *
790c0ded849SHemant Agrawal  * Return: On success, descriptor buffer offset where this command is inserted.
791c0ded849SHemant Agrawal  *         On error, a negative error code; first error program counter will
792c0ded849SHemant Agrawal  *         point to offset in descriptor buffer where the instruction should
793c0ded849SHemant Agrawal  *         have been written.
794c0ded849SHemant Agrawal  */
795c0ded849SHemant Agrawal #define NFIFOADD(program, src, data, length, flags) \
796c0ded849SHemant Agrawal 	rta_nfifo_load(program, src, data, length, flags)
797c0ded849SHemant Agrawal 
798c0ded849SHemant Agrawal /**
799c0ded849SHemant Agrawal  * DOC: Self Referential Code Management Routines
800c0ded849SHemant Agrawal  *
801c0ded849SHemant Agrawal  * Contains details of RTA self referential code routines.
802c0ded849SHemant Agrawal  */
803c0ded849SHemant Agrawal 
804c0ded849SHemant Agrawal /**
805c0ded849SHemant Agrawal  * REFERENCE - initialize a variable used for storing an index inside a
806c0ded849SHemant Agrawal  *             descriptor buffer.
807c0ded849SHemant Agrawal  * @ref: reference to a descriptor buffer's index where an update is required
808c0ded849SHemant Agrawal  *       with a value that will be known latter in the program flow.
809c0ded849SHemant Agrawal  */
810c0ded849SHemant Agrawal #define REFERENCE(ref)    int ref = -1
811c0ded849SHemant Agrawal 
812c0ded849SHemant Agrawal /**
813c0ded849SHemant Agrawal  * LABEL - initialize a variable used for storing an index inside a descriptor
814c0ded849SHemant Agrawal  *         buffer.
815c0ded849SHemant Agrawal  * @label: label stores the value with what should be updated the REFERENCE line
816c0ded849SHemant Agrawal  *         in the descriptor buffer.
817c0ded849SHemant Agrawal  */
818c0ded849SHemant Agrawal #define LABEL(label)      unsigned int label = 0
819c0ded849SHemant Agrawal 
820c0ded849SHemant Agrawal /**
821c0ded849SHemant Agrawal  * SET_LABEL - set a LABEL value
822c0ded849SHemant Agrawal  * @program: pointer to struct program
823c0ded849SHemant Agrawal  * @label: value that will be inserted in a line previously written in the
824c0ded849SHemant Agrawal  *         descriptor buffer.
825c0ded849SHemant Agrawal  */
826c0ded849SHemant Agrawal #define SET_LABEL(program, label)  (label = rta_set_label(program))
827c0ded849SHemant Agrawal 
828c0ded849SHemant Agrawal /**
829c0ded849SHemant Agrawal  * PATCH_JUMP - Auxiliary command to resolve self referential code
830c0ded849SHemant Agrawal  * @program: buffer to be updated (struct program *)
831c0ded849SHemant Agrawal  * @line: position in descriptor buffer where the update will be done; this
832c0ded849SHemant Agrawal  *        value is previously retained in program flow using a reference near
833c0ded849SHemant Agrawal  *        the sequence to be modified.
834c0ded849SHemant Agrawal  * @new_ref: updated value that will be inserted in descriptor buffer at the
835c0ded849SHemant Agrawal  *          specified line; this value is previously obtained using SET_LABEL
836c0ded849SHemant Agrawal  *          macro near the line that will be used as reference (unsigned int).
837c0ded849SHemant Agrawal  *          For JUMP command, the value represents the offset field (in words).
838c0ded849SHemant Agrawal  *
839c0ded849SHemant Agrawal  * Return: 0 in case of success, a negative error code if it fails
840c0ded849SHemant Agrawal  */
841c0ded849SHemant Agrawal #define PATCH_JUMP(program, line, new_ref) rta_patch_jmp(program, line, new_ref)
842c0ded849SHemant Agrawal 
843c0ded849SHemant Agrawal /**
844c0ded849SHemant Agrawal  * PATCH_MOVE - Auxiliary command to resolve self referential code
845c0ded849SHemant Agrawal  * @program: buffer to be updated (struct program *)
846c0ded849SHemant Agrawal  * @line: position in descriptor buffer where the update will be done; this
847c0ded849SHemant Agrawal  *        value is previously retained in program flow using a reference near
848c0ded849SHemant Agrawal  *        the sequence to be modified.
849c0ded849SHemant Agrawal  * @new_ref: updated value that will be inserted in descriptor buffer at the
850c0ded849SHemant Agrawal  *          specified line; this value is previously obtained using SET_LABEL
851c0ded849SHemant Agrawal  *          macro near the line that will be used as reference (unsigned int).
852c0ded849SHemant Agrawal  *          For MOVE command, the value represents the offset field (in words).
853c0ded849SHemant Agrawal  *
854c0ded849SHemant Agrawal  * Return: 0 in case of success, a negative error code if it fails
855c0ded849SHemant Agrawal  */
856c0ded849SHemant Agrawal #define PATCH_MOVE(program, line, new_ref) \
857c0ded849SHemant Agrawal 	rta_patch_move(program, line, new_ref)
858c0ded849SHemant Agrawal 
859c0ded849SHemant Agrawal /**
860c0ded849SHemant Agrawal  * PATCH_LOAD - Auxiliary command to resolve self referential code
861c0ded849SHemant Agrawal  * @program: buffer to be updated (struct program *)
862c0ded849SHemant Agrawal  * @line: position in descriptor buffer where the update will be done; this
863c0ded849SHemant Agrawal  *        value is previously retained in program flow using a reference near
864c0ded849SHemant Agrawal  *        the sequence to be modified.
865c0ded849SHemant Agrawal  * @new_ref: updated value that will be inserted in descriptor buffer at the
866c0ded849SHemant Agrawal  *          specified line; this value is previously obtained using SET_LABEL
867c0ded849SHemant Agrawal  *          macro near the line that will be used as reference (unsigned int).
868c0ded849SHemant Agrawal  *          For LOAD command, the value represents the offset field (in words).
869c0ded849SHemant Agrawal  *
870c0ded849SHemant Agrawal  * Return: 0 in case of success, a negative error code if it fails
871c0ded849SHemant Agrawal  */
872c0ded849SHemant Agrawal #define PATCH_LOAD(program, line, new_ref) \
873c0ded849SHemant Agrawal 	rta_patch_load(program, line, new_ref)
874c0ded849SHemant Agrawal 
875c0ded849SHemant Agrawal /**
876c0ded849SHemant Agrawal  * PATCH_STORE - Auxiliary command to resolve self referential code
877c0ded849SHemant Agrawal  * @program: buffer to be updated (struct program *)
878c0ded849SHemant Agrawal  * @line: position in descriptor buffer where the update will be done; this
879c0ded849SHemant Agrawal  *        value is previously retained in program flow using a reference near
880c0ded849SHemant Agrawal  *        the sequence to be modified.
881c0ded849SHemant Agrawal  * @new_ref: updated value that will be inserted in descriptor buffer at the
882c0ded849SHemant Agrawal  *          specified line; this value is previously obtained using SET_LABEL
883c0ded849SHemant Agrawal  *          macro near the line that will be used as reference (unsigned int).
884c0ded849SHemant Agrawal  *          For STORE command, the value represents the offset field (in words).
885c0ded849SHemant Agrawal  *
886c0ded849SHemant Agrawal  * Return: 0 in case of success, a negative error code if it fails
887c0ded849SHemant Agrawal  */
888c0ded849SHemant Agrawal #define PATCH_STORE(program, line, new_ref) \
889c0ded849SHemant Agrawal 	rta_patch_store(program, line, new_ref)
890c0ded849SHemant Agrawal 
891c0ded849SHemant Agrawal /**
892c0ded849SHemant Agrawal  * PATCH_HDR - Auxiliary command to resolve self referential code
893c0ded849SHemant Agrawal  * @program: buffer to be updated (struct program *)
894c0ded849SHemant Agrawal  * @line: position in descriptor buffer where the update will be done; this
895c0ded849SHemant Agrawal  *        value is previously retained in program flow using a reference near
896c0ded849SHemant Agrawal  *        the sequence to be modified.
897c0ded849SHemant Agrawal  * @new_ref: updated value that will be inserted in descriptor buffer at the
898c0ded849SHemant Agrawal  *          specified line; this value is previously obtained using SET_LABEL
899c0ded849SHemant Agrawal  *          macro near the line that will be used as reference (unsigned int).
900c0ded849SHemant Agrawal  *          For HEADER command, the value represents the start index field.
901c0ded849SHemant Agrawal  *
902c0ded849SHemant Agrawal  * Return: 0 in case of success, a negative error code if it fails
903c0ded849SHemant Agrawal  */
904c0ded849SHemant Agrawal #define PATCH_HDR(program, line, new_ref) \
905c0ded849SHemant Agrawal 	rta_patch_header(program, line, new_ref)
906c0ded849SHemant Agrawal 
907c0ded849SHemant Agrawal /**
908c0ded849SHemant Agrawal  * PATCH_RAW - Auxiliary command to resolve self referential code
909c0ded849SHemant Agrawal  * @program: buffer to be updated (struct program *)
910c0ded849SHemant Agrawal  * @line: position in descriptor buffer where the update will be done; this
911c0ded849SHemant Agrawal  *        value is previously retained in program flow using a reference near
912c0ded849SHemant Agrawal  *        the sequence to be modified.
913c0ded849SHemant Agrawal  * @mask: mask to be used for applying the new value (unsigned int). The mask
914c0ded849SHemant Agrawal  *        selects which bits from the provided @new_val are taken into
915c0ded849SHemant Agrawal  *        consideration when overwriting the existing value.
916c0ded849SHemant Agrawal  * @new_val: updated value that will be masked using the provided mask value
917c0ded849SHemant Agrawal  *           and inserted in descriptor buffer at the specified line.
918c0ded849SHemant Agrawal  *
919c0ded849SHemant Agrawal  * Return: 0 in case of success, a negative error code if it fails
920c0ded849SHemant Agrawal  */
921c0ded849SHemant Agrawal #define PATCH_RAW(program, line, mask, new_val) \
922c0ded849SHemant Agrawal 	rta_patch_raw(program, line, mask, new_val)
923c0ded849SHemant Agrawal 
924c0ded849SHemant Agrawal #endif /* __RTA_RTA_H__ */
925