1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2008-2016 Freescale Semiconductor Inc.
8 #ifndef __DESC_COMMON_H__
9 #define __DESC_COMMON_H__
14 * DOC: Shared Descriptor Constructors - shared structures
16 * Data structures shared between algorithm, protocol implementations.
20 * struct alginfo - Container for algorithm details
21 * @algtype: algorithm selector; for valid values, see documentation of the
22 * functions where it is used.
23 * @keylen: length of the provided algorithm key, in bytes
24 * @key: address where algorithm key resides; virtual address if key_type is
25 * RTA_DATA_IMM, physical (bus) address if key_type is RTA_DATA_PTR or
27 * @key_enc_flags: key encryption flags; see encrypt_flags parameter of KEY
28 * command for valid values.
29 * @key_type: enum rta_data_type
30 * @algmode: algorithm mode selector; for valid values, see documentation of the
31 * functions where it is used.
37 uint32_t key_enc_flags;
38 enum rta_data_type key_type;
42 #define INLINE_KEY(alginfo) inline_flags(alginfo->key_type)
45 * rta_inline_query() - Provide indications on which data items can be inlined
46 * and which shall be referenced in a shared descriptor.
47 * @sd_base_len: Shared descriptor base length - bytes consumed by the commands,
48 * excluding the data items to be inlined (or corresponding
49 * pointer if an item is not inlined). Each cnstr_* function that
50 * generates descriptors should have a define mentioning
51 * corresponding length.
52 * @jd_len: Maximum length of the job descriptor(s) that will be used
53 * together with the shared descriptor.
54 * @data_len: Array of lengths of the data items trying to be inlined
55 * @inl_mask: 32bit mask with bit x = 1 if data item x can be inlined, 0
57 * @count: Number of data items (size of @data_len array); must be <= 32
59 * Return: 0 if data can be inlined / referenced, negative value if not. If 0,
60 * check @inl_mask for details.
63 rta_inline_query(unsigned int sd_base_len,
65 unsigned int *data_len,
69 int rem_bytes = (int)(CAAM_DESC_BYTES_MAX - sd_base_len - jd_len);
73 for (i = 0; (i < count) && (rem_bytes > 0); i++) {
74 if (rem_bytes - (int)(data_len[i] +
75 (count - i - 1) * CAAM_PTR_SZ) >= 0) {
76 rem_bytes -= data_len[i];
77 *inl_mask |= (1 << i);
79 rem_bytes -= CAAM_PTR_SZ;
83 return (rem_bytes >= 0) ? 0 : -1;
87 * struct protcmd - Container for Protocol Operation Command fields
88 * @optype: command type
89 * @protid: protocol Identifier
90 * @protinfo: protocol Information
98 #endif /* __DESC_COMMON_H__ */