linux/drivers/crypto/intel/ixp4xx/ixp4xx_crypto.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Intel IXP4xx NPE-C crypto driver
 *
 * Copyright (C) 2008 Christian Hohnstaedt <[email protected]>
 */

#include <linux/platform_device.h>
#include <linux/dma-mapping.h>
#include <linux/dmapool.h>
#include <linux/crypto.h>
#include <linux/kernel.h>
#include <linux/rtnetlink.h>
#include <linux/interrupt.h>
#include <linux/spinlock.h>
#include <linux/gfp.h>
#include <linux/module.h>
#include <linux/of.h>

#include <crypto/ctr.h>
#include <crypto/internal/des.h>
#include <crypto/aes.h>
#include <crypto/hmac.h>
#include <crypto/sha1.h>
#include <crypto/algapi.h>
#include <crypto/internal/aead.h>
#include <crypto/internal/skcipher.h>
#include <crypto/authenc.h>
#include <crypto/scatterwalk.h>

#include <linux/soc/ixp4xx/npe.h>
#include <linux/soc/ixp4xx/qmgr.h>

/* Intermittent includes, delete this after v5.14-rc1 */
#include <linux/soc/ixp4xx/cpu.h>

#define MAX_KEYLEN

/* hash: cfgword + 2 * digestlen; crypt: keylen + cfgword */
#define NPE_CTX_LEN
#define AES_BLOCK128

#define NPE_OP_HASH_VERIFY
#define NPE_OP_CCM_ENABLE
#define NPE_OP_CRYPT_ENABLE
#define NPE_OP_HASH_ENABLE
#define NPE_OP_NOT_IN_PLACE
#define NPE_OP_HMAC_DISABLE
#define NPE_OP_CRYPT_ENCRYPT

#define NPE_OP_CCM_GEN_MIC
#define NPE_OP_HASH_GEN_ICV
#define NPE_OP_ENC_GEN_KEY

#define MOD_ECB
#define MOD_CTR
#define MOD_CBC_ENC
#define MOD_CBC_DEC
#define MOD_CCM_ENC
#define MOD_CCM_DEC

#define KEYLEN_128
#define KEYLEN_192
#define KEYLEN_256

#define CIPH_DECR
#define CIPH_ENCR

#define MOD_DES
#define MOD_TDEA2
#define MOD_3DES
#define MOD_AES
#define MOD_AES128
#define MOD_AES192
#define MOD_AES256

#define MAX_IVLEN
#define NPE_QLEN
/* Space for registering when the first
 * NPE_QLEN crypt_ctl are busy */
#define NPE_QLEN_TOTAL

#define CTL_FLAG_UNUSED
#define CTL_FLAG_USED
#define CTL_FLAG_PERFORM_ABLK
#define CTL_FLAG_GEN_ICV
#define CTL_FLAG_GEN_REVAES
#define CTL_FLAG_PERFORM_AEAD
#define CTL_FLAG_MASK

#define HMAC_PAD_BLOCKLEN

#define MD5_DIGEST_SIZE

struct buffer_desc {};

struct crypt_ctl {};

struct ablk_ctx {};

struct aead_ctx {};

struct ix_hash_algo {};

struct ix_sa_dir {};

struct ixp_ctx {};

struct ixp_alg {};

struct ixp_aead_alg {};

static const struct ix_hash_algo hash_alg_md5 =;

static const struct ix_hash_algo hash_alg_sha1 =;

static struct npe *npe_c;

static unsigned int send_qid;
static unsigned int recv_qid;
static struct dma_pool *buffer_pool;
static struct dma_pool *ctx_pool;

static struct crypt_ctl *crypt_virt;
static dma_addr_t crypt_phys;

static int support_aes =;

static struct platform_device *pdev;

static inline dma_addr_t crypt_virt2phys(struct crypt_ctl *virt)
{}

static inline struct crypt_ctl *crypt_phys2virt(dma_addr_t phys)
{}

static inline u32 cipher_cfg_enc(struct crypto_tfm *tfm)
{}

static inline u32 cipher_cfg_dec(struct crypto_tfm *tfm)
{}

static inline const struct ix_hash_algo *ix_hash(struct crypto_tfm *tfm)
{}

static int setup_crypt_desc(void)
{}

static DEFINE_SPINLOCK(desc_lock);
static struct crypt_ctl *get_crypt_desc(void)
{}

static DEFINE_SPINLOCK(emerg_lock);
static struct crypt_ctl *get_crypt_desc_emerg(void)
{}

static void free_buf_chain(struct device *dev, struct buffer_desc *buf,
			   dma_addr_t phys)
{}

static struct tasklet_struct crypto_done_tasklet;

static void finish_scattered_hmac(struct crypt_ctl *crypt)
{}

static void one_packet(dma_addr_t phys)
{}

static void irqhandler(void *_unused)
{}

static void crypto_done_action(unsigned long arg)
{}

static int init_ixp_crypto(struct device *dev)
{}

static void release_ixp_crypto(struct device *dev)
{}

static void reset_sa_dir(struct ix_sa_dir *dir)
{}

static int init_sa_dir(struct ix_sa_dir *dir)
{}

static void free_sa_dir(struct ix_sa_dir *dir)
{}

static int init_tfm(struct crypto_tfm *tfm)
{}

static int init_tfm_ablk(struct crypto_skcipher *tfm)
{}

static int init_tfm_aead(struct crypto_aead *tfm)
{}

static void exit_tfm(struct crypto_tfm *tfm)
{}

static void exit_tfm_ablk(struct crypto_skcipher *tfm)
{}

static void exit_tfm_aead(struct crypto_aead *tfm)
{}

static int register_chain_var(struct crypto_tfm *tfm, u8 xpad, u32 target,
			      int init_len, u32 ctx_addr, const u8 *key,
			      int key_len)
{}

static int setup_auth(struct crypto_tfm *tfm, int encrypt, unsigned int authsize,
		      const u8 *key, int key_len, unsigned int digest_len)
{}

static int gen_rev_aes_key(struct crypto_tfm *tfm)
{}

static int setup_cipher(struct crypto_tfm *tfm, int encrypt, const u8 *key,
			int key_len)
{}

static struct buffer_desc *chainup_buffers(struct device *dev,
		struct scatterlist *sg,	unsigned int nbytes,
		struct buffer_desc *buf, gfp_t flags,
		enum dma_data_direction dir)
{}

static int ablk_setkey(struct crypto_skcipher *tfm, const u8 *key,
		       unsigned int key_len)
{}

static int ablk_des3_setkey(struct crypto_skcipher *tfm, const u8 *key,
			    unsigned int key_len)
{}

static int ablk_rfc3686_setkey(struct crypto_skcipher *tfm, const u8 *key,
			       unsigned int key_len)
{}

static int ixp4xx_cipher_fallback(struct skcipher_request *areq, int encrypt)
{}

static int ablk_perform(struct skcipher_request *req, int encrypt)
{}

static int ablk_encrypt(struct skcipher_request *req)
{}

static int ablk_decrypt(struct skcipher_request *req)
{}

static int ablk_rfc3686_crypt(struct skcipher_request *req)
{}

static int aead_perform(struct aead_request *req, int encrypt,
			int cryptoffset, int eff_cryptlen, u8 *iv)
{}

static int aead_setup(struct crypto_aead *tfm, unsigned int authsize)
{}

static int aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize)
{}

static int aead_setkey(struct crypto_aead *tfm, const u8 *key,
		       unsigned int keylen)
{}

static int des3_aead_setkey(struct crypto_aead *tfm, const u8 *key,
			    unsigned int keylen)
{}

static int aead_encrypt(struct aead_request *req)
{}

static int aead_decrypt(struct aead_request *req)
{}

static struct ixp_alg ixp4xx_algos[] =;

static struct ixp_aead_alg ixp4xx_aeads[] =;

#define IXP_POSTFIX

static int ixp_crypto_probe(struct platform_device *_pdev)
{}

static void ixp_crypto_remove(struct platform_device *pdev)
{}
static const struct of_device_id ixp4xx_crypto_of_match[] =;

static struct platform_driver ixp_crypto_driver =;
module_platform_driver();

MODULE_LICENSE();
MODULE_AUTHOR();
MODULE_DESCRIPTION();