^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright 2016 Broadcom
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #ifndef _CIPHER_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define _CIPHER_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/atomic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/mailbox/brcm-message.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/mailbox_client.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <crypto/aes.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <crypto/internal/hash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <crypto/internal/skcipher.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <crypto/aead.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <crypto/arc4.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <crypto/gcm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <crypto/sha.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <crypto/sha3.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include "spu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include "spum.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include "spu2.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /* Driver supports up to MAX_SPUS SPU blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define MAX_SPUS 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define ARC4_STATE_SIZE 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define CCM_AES_IV_SIZE 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define CCM_ESP_IV_SIZE 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define RFC4543_ICV_SIZE 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define MAX_KEY_SIZE ARC4_MAX_KEY_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define MAX_IV_SIZE AES_BLOCK_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define MAX_DIGEST_SIZE SHA3_512_DIGEST_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define MAX_ASSOC_SIZE 512
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /* size of salt value for AES-GCM-ESP and AES-CCM-ESP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define GCM_ESP_SALT_SIZE 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define CCM_ESP_SALT_SIZE 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define MAX_SALT_SIZE GCM_ESP_SALT_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define GCM_ESP_SALT_OFFSET 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define CCM_ESP_SALT_OFFSET 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define GCM_ESP_DIGESTSIZE 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define MAX_HASH_BLOCK_SIZE SHA512_BLOCK_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * Maximum number of bytes from a non-final hash request that can be deferred
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * until more data is available. With new crypto API framework, this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * can be no more than one block of data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define HASH_CARRY_MAX MAX_HASH_BLOCK_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) /* Force at least 4-byte alignment of all SPU message fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define SPU_MSG_ALIGN 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /* Number of times to resend mailbox message if mb queue is full */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define SPU_MB_RETRY_MAX 1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) /* op_counts[] indexes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) enum op_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) SPU_OP_CIPHER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) SPU_OP_HASH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) SPU_OP_HMAC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) SPU_OP_AEAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) SPU_OP_NUM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) enum spu_spu_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) SPU_TYPE_SPUM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) SPU_TYPE_SPU2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * SPUM_NS2 and SPUM_NSP are the SPU-M block on Northstar 2 and Northstar Plus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * respectively.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) enum spu_spu_subtype {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) SPU_SUBTYPE_SPUM_NS2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) SPU_SUBTYPE_SPUM_NSP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) SPU_SUBTYPE_SPU2_V1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) SPU_SUBTYPE_SPU2_V2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) struct spu_type_subtype {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) enum spu_spu_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) enum spu_spu_subtype subtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) struct cipher_op {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) enum spu_cipher_alg alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) enum spu_cipher_mode mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct auth_op {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) enum hash_alg alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) enum hash_mode mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct iproc_alg_s {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) u32 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) struct skcipher_alg skcipher;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) struct ahash_alg hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) struct aead_alg aead;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) } alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct cipher_op cipher_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct auth_op auth_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) bool auth_first;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) bool registered;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * Buffers for a SPU request/reply message pair. All part of one structure to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * allow a single alloc per request.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct spu_msg_buf {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /* Request message fragments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * SPU request message header. For SPU-M, holds MH, EMH, SCTX, BDESC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * and BD header. For SPU2, holds FMD, OMD.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) u8 bcm_spu_req_hdr[ALIGN(SPU2_HEADER_ALLOC_LEN, SPU_MSG_ALIGN)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /* IV or counter. Size to include salt. Also used for XTS tweek. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) u8 iv_ctr[ALIGN(2 * AES_BLOCK_SIZE, SPU_MSG_ALIGN)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) /* Hash digest. request and response. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) u8 digest[ALIGN(MAX_DIGEST_SIZE, SPU_MSG_ALIGN)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) /* SPU request message padding */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) u8 spu_req_pad[ALIGN(SPU_PAD_LEN_MAX, SPU_MSG_ALIGN)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /* SPU-M request message STATUS field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) u8 tx_stat[ALIGN(SPU_TX_STATUS_LEN, SPU_MSG_ALIGN)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) /* Response message fragments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /* SPU response message header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) u8 spu_resp_hdr[ALIGN(SPU2_HEADER_ALLOC_LEN, SPU_MSG_ALIGN)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /* SPU response message STATUS field padding */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) u8 rx_stat_pad[ALIGN(SPU_STAT_PAD_MAX, SPU_MSG_ALIGN)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /* SPU response message STATUS field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) u8 rx_stat[ALIGN(SPU_RX_STATUS_LEN, SPU_MSG_ALIGN)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) /* Buffers only used for skcipher */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * Field used for either SUPDT when RC4 is used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * -OR- tweak value when XTS/AES is used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) u8 supdt_tweak[ALIGN(SPU_SUPDT_LEN, SPU_MSG_ALIGN)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) } c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) /* Buffers only used for aead */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /* SPU response pad for GCM data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) u8 gcmpad[ALIGN(AES_BLOCK_SIZE, SPU_MSG_ALIGN)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) /* SPU request msg padding for GCM AAD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) u8 req_aad_pad[ALIGN(SPU_PAD_LEN_MAX, SPU_MSG_ALIGN)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) /* SPU response data to be discarded */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) u8 resp_aad[ALIGN(MAX_ASSOC_SIZE + MAX_IV_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) SPU_MSG_ALIGN)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) } a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) struct iproc_ctx_s {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) u8 enckey[MAX_KEY_SIZE + ARC4_STATE_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) unsigned int enckeylen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) u8 authkey[MAX_KEY_SIZE + ARC4_STATE_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) unsigned int authkeylen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) u8 salt[MAX_SALT_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) unsigned int salt_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) unsigned int salt_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) u8 iv[MAX_IV_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) unsigned int digestsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) struct iproc_alg_s *alg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) bool is_esp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) struct cipher_op cipher;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) enum spu_cipher_type cipher_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct auth_op auth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) bool auth_first;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) * The maximum length in bytes of the payload in a SPU message for this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * context. For SPU-M, the payload is the combination of AAD and data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) * For SPU2, the payload is just data. A value of SPU_MAX_PAYLOAD_INF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) * indicates that there is no limit to the length of the SPU message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) * payload.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) unsigned int max_payload;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct crypto_aead *fallback_cipher;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) /* auth_type is determined during processing of request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) u8 ipad[MAX_HASH_BLOCK_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) u8 opad[MAX_HASH_BLOCK_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) * Buffer to hold SPU message header template. Template is created at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) * setkey time for skcipher requests, since most of the fields in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) * header are known at that time. At request time, just fill in a few
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) * missing pieces related to length of data in the request and IVs, etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) u8 bcm_spu_req_hdr[ALIGN(SPU2_HEADER_ALLOC_LEN, SPU_MSG_ALIGN)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) /* Length of SPU request header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) u16 spu_req_hdr_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) /* Expected length of SPU response header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) u16 spu_resp_hdr_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * shash descriptor - needed to perform incremental hashing in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) * in software, when hw doesn't support it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) struct shash_desc *shash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) bool is_rfc4543; /* RFC 4543 style of GMAC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) /* state from iproc_reqctx_s necessary for hash state export/import */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) struct spu_hash_export_s {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) unsigned int total_todo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) unsigned int total_sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) u8 hash_carry[HASH_CARRY_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) unsigned int hash_carry_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) u8 incr_hash[MAX_DIGEST_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) bool is_sw_hmac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) struct iproc_reqctx_s {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) /* general context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) struct crypto_async_request *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) /* only valid after enqueue() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) struct iproc_ctx_s *ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) u8 chan_idx; /* Mailbox channel to be used to submit this request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) /* total todo, rx'd, and sent for this request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) unsigned int total_todo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) unsigned int total_received; /* only valid for skcipher */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) unsigned int total_sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) * num bytes sent to hw from the src sg in this request. This can differ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) * from total_sent for incremental hashing. total_sent includes previous
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) * init() and update() data. src_sent does not.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) unsigned int src_sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) * For AEAD requests, start of associated data. This will typically
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) * point to the beginning of the src scatterlist from the request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) * since assoc data is at the beginning of the src scatterlist rather
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) * than in its own sg.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) struct scatterlist *assoc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) * scatterlist entry and offset to start of data for next chunk. Crypto
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) * API src scatterlist for AEAD starts with AAD, if present. For first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) * chunk, src_sg is sg entry at beginning of input data (after AAD).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) * src_skip begins at the offset in that sg entry where data begins.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) struct scatterlist *src_sg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) int src_nents; /* Number of src entries with data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) u32 src_skip; /* bytes of current sg entry already used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) * Same for destination. For AEAD, if there is AAD, output data must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) * be written at offset following AAD.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) struct scatterlist *dst_sg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) int dst_nents; /* Number of dst entries with data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) u32 dst_skip; /* bytes of current sg entry already written */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) /* Mailbox message used to send this request to PDC driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) struct brcm_message mb_mssg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) bool bd_suppress; /* suppress BD field in SPU response? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) /* cipher context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) bool is_encrypt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) * CBC mode: IV. CTR mode: counter. Else empty. Used as a DMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) * buffer for AEAD requests. So allocate as DMAable memory. If IV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) * concatenated with salt, includes the salt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) u8 *iv_ctr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) /* Length of IV or counter, in bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) unsigned int iv_ctr_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) * Hash requests can be of any size, whether initial, update, or final.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) * A non-final request must be submitted to the SPU as an integral
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) * number of blocks. This may leave data at the end of the request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) * that is not a full block. Since the request is non-final, it cannot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) * be padded. So, we write the remainder to this hash_carry buffer and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) * hold it until the next request arrives. The carry data is then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) * submitted at the beginning of the data in the next SPU msg.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) * hash_carry_len is the number of bytes currently in hash_carry. These
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) * fields are only used for ahash requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) u8 hash_carry[HASH_CARRY_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) unsigned int hash_carry_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) unsigned int is_final; /* is this the final for the hash op? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) * Digest from incremental hash is saved here to include in next hash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) * operation. Cannot be stored in req->result for truncated hashes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) * since result may be sized for final digest. Cannot be saved in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) * msg_buf because that gets deleted between incremental hash ops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) * and is not saved as part of export().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) u8 incr_hash[MAX_DIGEST_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) /* hmac context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) bool is_sw_hmac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) /* aead context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) struct crypto_tfm *old_tfm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) crypto_completion_t old_complete;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) void *old_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) gfp_t gfp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) /* Buffers used to build SPU request and response messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) struct spu_msg_buf msg_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) * Structure encapsulates a set of function pointers specific to the type of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) * SPU hardware running. These functions handling creation and parsing of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) * SPU request messages and SPU response messages. Includes hardware-specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) * values read from device tree.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) struct spu_hw {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) void (*spu_dump_msg_hdr)(u8 *buf, unsigned int buf_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) u32 (*spu_ctx_max_payload)(enum spu_cipher_alg cipher_alg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) enum spu_cipher_mode cipher_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) unsigned int blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) u32 (*spu_payload_length)(u8 *spu_hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) u16 (*spu_response_hdr_len)(u16 auth_key_len, u16 enc_key_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) bool is_hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) u16 (*spu_hash_pad_len)(enum hash_alg hash_alg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) enum hash_mode hash_mode, u32 chunksize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) u16 hash_block_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) u32 (*spu_gcm_ccm_pad_len)(enum spu_cipher_mode cipher_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) unsigned int data_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) u32 (*spu_assoc_resp_len)(enum spu_cipher_mode cipher_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) unsigned int assoc_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) unsigned int iv_len, bool is_encrypt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) u8 (*spu_aead_ivlen)(enum spu_cipher_mode cipher_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) u16 iv_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) enum hash_type (*spu_hash_type)(u32 src_sent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) u32 (*spu_digest_size)(u32 digest_size, enum hash_alg alg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) enum hash_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) u32 (*spu_create_request)(u8 *spu_hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) struct spu_request_opts *req_opts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) struct spu_cipher_parms *cipher_parms,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) struct spu_hash_parms *hash_parms,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) struct spu_aead_parms *aead_parms,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) unsigned int data_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) u16 (*spu_cipher_req_init)(u8 *spu_hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) struct spu_cipher_parms *cipher_parms);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) void (*spu_cipher_req_finish)(u8 *spu_hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) u16 spu_req_hdr_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) unsigned int is_inbound,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) struct spu_cipher_parms *cipher_parms,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) unsigned int data_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) void (*spu_request_pad)(u8 *pad_start, u32 gcm_padding,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) u32 hash_pad_len, enum hash_alg auth_alg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) enum hash_mode auth_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) unsigned int total_sent, u32 status_padding);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) u8 (*spu_xts_tweak_in_payload)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) u8 (*spu_tx_status_len)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) u8 (*spu_rx_status_len)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) int (*spu_status_process)(u8 *statp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) void (*spu_ccm_update_iv)(unsigned int digestsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) struct spu_cipher_parms *cipher_parms,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) unsigned int assoclen, unsigned int chunksize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) bool is_encrypt, bool is_esp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) u32 (*spu_wordalign_padlen)(u32 data_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) /* The base virtual address of the SPU hw registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) void __iomem *reg_vbase[MAX_SPUS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) /* Version of the SPU hardware */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) enum spu_spu_type spu_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) /* Sub-version of the SPU hardware */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) enum spu_spu_subtype spu_subtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) /* The number of SPUs on this platform */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) u32 num_spu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) /* The number of SPU channels on this platform */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) u32 num_chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) struct bcm_device_private {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) struct platform_device *pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) struct spu_hw spu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) atomic_t session_count; /* number of streams active */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) atomic_t stream_count; /* monotonic counter for streamID's */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) /* Length of BCM header. Set to 0 when hw does not expect BCM HEADER. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) u8 bcm_hdr_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) /* The index of the channel to use for the next crypto request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) atomic_t next_chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) struct dentry *debugfs_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) struct dentry *debugfs_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) /* Number of request bytes processed and result bytes returned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) atomic64_t bytes_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) atomic64_t bytes_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) /* Number of operations of each type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) atomic_t op_counts[SPU_OP_NUM];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) atomic_t cipher_cnt[CIPHER_ALG_LAST][CIPHER_MODE_LAST];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) atomic_t hash_cnt[HASH_ALG_LAST];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) atomic_t hmac_cnt[HASH_ALG_LAST];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) atomic_t aead_cnt[AEAD_TYPE_LAST];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) /* Number of calls to setkey() for each operation type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) atomic_t setkey_cnt[SPU_OP_NUM];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) /* Number of times request was resubmitted because mb was full */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) atomic_t mb_no_spc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) /* Number of mailbox send failures */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) atomic_t mb_send_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) /* Number of ICV check failures for AEAD messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) atomic_t bad_icv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) struct mbox_client mcl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) /* Array of mailbox channel pointers, one for each channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) struct mbox_chan **mbox;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) extern struct bcm_device_private iproc_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) #endif