/* * The CAAM QI hardware constructs a job descriptor which points * to shared descriptor (as pointed by context_a of FQ to CAAM). * When the job descriptor is executed by deco, the whole job * descriptor together with shared descriptor gets loaded in * deco buffer which is 64 words long (each 32-bit). * * The job descriptor constructed by QI hardware has layout: * * HEADER (1 word) * Shdesc ptr (1 or 2 words) * SEQ_OUT_PTR (1 word) * Out ptr (1 or 2 words) * Out length (1 word) * SEQ_IN_PTR (1 word) * In ptr (1 or 2 words) * In length (1 word) * * The shdesc ptr is used to fetch shared descriptor contents * into deco buffer. * * Apart from shdesc contents, the total number of words that * get loaded in deco buffer are '8' or '11'. The remaining words * in deco buffer can be used for storing shared descriptor.
*/ #define MAX_SDLEN ((CAAM_DESC_BYTES_MAX - DESC_JOB_IO_LEN_MIN) / CAAM_CMD_SZ)
#ifdef DEBUG #define PRINT_POS do { printk(KERN_DEBUG "%02d: %s\n", desc_len(desc),\
&__func__[sizeof("append")]); } while (0) #else #define PRINT_POS #endif
/* * HW fetches 4 S/G table entries at a time, irrespective of how many entries * are in the table. It's SW's responsibility to make sure these accesses * do not have side effects.
*/ staticinlineint pad_sg_nents(int sg_nents)
{ return ALIGN(sg_nents, 4);
}
/* Write command without affecting header, and return pointer to next word */ staticinline u32 *write_cmd(u32 * const desc, u32 command)
{
*desc = cpu_to_caam32(command);
/* * Append math command. Only the last part of destination and source need to * be specified
*/ #define APPEND_MATH(op, desc, dest, src_0, src_1, len) \
append_cmd(desc, CMD_MATH | MATH_FUN_##op | MATH_DEST_##dest | \
MATH_SRC0_##src_0 | MATH_SRC1_##src_1 | (u32)len);
/* Exactly one source is IMM. Data is passed in as u32 value */ #define APPEND_MATH_IMM_u32(op, desc, dest, src_0, src_1, data) \ do { \
APPEND_MATH(op, desc, dest, src_0, src_1, CAAM_CMD_SZ); \
append_cmd(desc, data); \
} while (0)
/** * struct alginfo - Container for algorithm details * @algtype: algorithm selector; for valid values, see documentation of the * functions where it is used. * @keylen: length of the provided algorithm key, in bytes * @keylen_pad: padded length of the provided algorithm key, in bytes * @key_dma: dma (bus) address where algorithm key resides * @key_virt: virtual address where algorithm key resides * @key_inline: true - key can be inlined in the descriptor; false - key is * referenced by the descriptor
*/ struct alginfo {
u32 algtype; unsignedint keylen; unsignedint keylen_pad;
dma_addr_t key_dma; constvoid *key_virt; bool key_inline;
};
/** * desc_inline_query() - Provide indications on which data items can be inlined * and which shall be referenced in a shared descriptor. * @sd_base_len: Shared descriptor base length - bytes consumed by the commands, * excluding the data items to be inlined (or corresponding * pointer if an item is not inlined). Each cnstr_* function that * generates descriptors should have a define mentioning * corresponding length. * @jd_len: Maximum length of the job descriptor(s) that will be used * together with the shared descriptor. * @data_len: Array of lengths of the data items trying to be inlined * @inl_mask: 32bit mask with bit x = 1 if data item x can be inlined, 0 * otherwise. * @count: Number of data items (size of @data_len array); must be <= 32 * * Return: 0 if data can be inlined / referenced, negative value if not. If 0, * check @inl_mask for details.
*/ staticinlineint desc_inline_query(unsignedint sd_base_len, unsignedint jd_len, unsignedint *data_len,
u32 *inl_mask, unsignedint count)
{ int rem_bytes = (int)(CAAM_DESC_BYTES_MAX - sd_base_len - jd_len); unsignedint i;
*inl_mask = 0; for (i = 0; (i < count) && (rem_bytes > 0); i++) { if (rem_bytes - (int)(data_len[i] +
(count - i - 1) * CAAM_PTR_SZ) >= 0) {
rem_bytes -= data_len[i];
*inl_mask |= (1 << i);
} else {
rem_bytes -= CAAM_PTR_SZ;
}
}
return (rem_bytes >= 0) ? 0 : -1;
}
/** * append_proto_dkp - Derived Key Protocol (DKP): key -> split key * @desc: pointer to buffer used for descriptor construction * @adata: pointer to authentication transform definitions. * keylen should be the length of initial key, while keylen_pad * the length of the derived (split) key. * Valid algorithm values - one of OP_ALG_ALGSEL_{MD5, SHA1, SHA224, * SHA256, SHA384, SHA512}.
*/ staticinlinevoid append_proto_dkp(u32 * const desc, struct alginfo *adata)
{
u32 protid;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.