// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2016 Broadcom
*/
/*
* This file works with the SPU2 version of the SPU. SPU2 has different message
* formats than the previous version of the SPU. All SPU message format
* differences should be hidden in the spux.c,h files.
*/
#include <linux/kernel.h>
#include <linux/string.h>
#include "util.h"
#include "spu.h"
#include "spu2.h"
#define SPU2_TX_STATUS_LEN 0 /* SPU2 has no STATUS in input packet */
/*
* Controlled by pkt_stat_cnt field in CRYPTO_SS_SPU0_CORE_SPU2_CONTROL0
* register. Defaults to 2.
*/
#define SPU2_RX_STATUS_LEN 2
enum spu2_proto_sel {
SPU2_PROTO_RESV = 0,
SPU2_MACSEC_SECTAG8_ECB = 1,
SPU2_MACSEC_SECTAG8_SCB = 2,
SPU2_MACSEC_SECTAG16 = 3,
SPU2_MACSEC_SECTAG16_8_XPN = 4,
SPU2_IPSEC = 5,
SPU2_IPSEC_ESN = 6,
SPU2_TLS_CIPHER = 7,
SPU2_TLS_AEAD = 8,
SPU2_DTLS_CIPHER = 9,
SPU2_DTLS_AEAD = 10
};
static char *spu2_cipher_type_names[] = { "None", "AES128", "AES192", "AES256",
"DES", "3DES"
};
static char *spu2_cipher_mode_names[] = { "ECB", "CBC", "CTR", "CFB", "OFB",
"XTS", "CCM", "GCM"
};
static char *spu2_hash_type_names[] = { "None", "AES128", "AES192", "AES256",
"Reserved", "Reserved", "MD5", "SHA1", "SHA224", "SHA256", "SHA384",
"SHA512", "SHA512/224", "SHA512/256", "SHA3-224", "SHA3-256",
"SHA3-384", "SHA3-512"
};
static char *spu2_hash_mode_names[] = { "CMAC", "CBC-MAC", "XCBC-MAC", "HMAC",
"Rabin", "CCM", "GCM", "Reserved"
};
static char *spu2_ciph_type_name(enum spu2_cipher_type cipher_type)
{
if (cipher_type >= SPU2_CIPHER_TYPE_LAST)
return "Reserved";
return spu2_cipher_type_names[cipher_type];
}
static char *spu2_ciph_mode_name(enum spu2_cipher_mode cipher_mode)
{
if (cipher_mode >= SPU2_CIPHER_MODE_LAST)
return "Reserved";
return spu2_cipher_mode_names[cipher_mode];
}
static char *spu2_hash_type_name(enum spu2_hash_type hash_type)
{
if (hash_type >= SPU2_HASH_TYPE_LAST)
return "Reserved";
return spu2_hash_type_names[hash_type];
}
static char