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