#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/device.h>
#include <linux/iommu.h>
#include <uapi/linux/idxd.h>
#include <linux/highmem.h>
#include <linux/sched/smt.h>
#include <crypto/internal/acompress.h>
#include "idxd.h"
#include "iaa_crypto.h"
#include "iaa_crypto_stats.h"
#ifdef pr_fmt
#undef pr_fmt
#endif
#define pr_fmt(fmt) …
#define IAA_ALG_PRIORITY …
static unsigned int nr_iaa;
static unsigned int nr_cpus;
static unsigned int nr_nodes;
static unsigned int nr_cpus_per_node;
static unsigned int cpus_per_iaa;
static struct crypto_comp *deflate_generic_tfm;
static struct wq_table_entry __percpu *wq_table;
static struct idxd_wq *wq_table_next_wq(int cpu)
{ … }
static void wq_table_add(int cpu, struct idxd_wq *wq)
{ … }
static void wq_table_free_entry(int cpu)
{ … }
static void wq_table_clear_entry(int cpu)
{ … }
LIST_HEAD(…);
DEFINE_MUTEX(…) …;
static bool iaa_crypto_enabled;
static bool iaa_crypto_registered;
static bool iaa_verify_compress = …;
static ssize_t verify_compress_show(struct device_driver *driver, char *buf)
{ … }
static ssize_t verify_compress_store(struct device_driver *driver,
const char *buf, size_t count)
{ … }
static DRIVER_ATTR_RW(verify_compress);
static bool async_mode;
static bool use_irq;
static int set_iaa_sync_mode(const char *name)
{ … }
static ssize_t sync_mode_show(struct device_driver *driver, char *buf)
{ … }
static ssize_t sync_mode_store(struct device_driver *driver,
const char *buf, size_t count)
{ … }
static DRIVER_ATTR_RW(sync_mode);
static struct iaa_compression_mode *iaa_compression_modes[IAA_COMP_MODES_MAX];
static int find_empty_iaa_compression_mode(void)
{ … }
static struct iaa_compression_mode *find_iaa_compression_mode(const char *name, int *idx)
{ … }
static void free_iaa_compression_mode(struct iaa_compression_mode *mode)
{ … }
void remove_iaa_compression_mode(const char *name)
{ … }
EXPORT_SYMBOL_GPL(…);
int add_iaa_compression_mode(const char *name,
const u32 *ll_table,
int ll_table_size,
const u32 *d_table,
int d_table_size,
iaa_dev_comp_init_fn_t init,
iaa_dev_comp_free_fn_t free)
{ … }
EXPORT_SYMBOL_GPL(…);
static struct iaa_device_compression_mode *
get_iaa_device_compression_mode(struct iaa_device *iaa_device, int idx)
{ … }
static void free_device_compression_mode(struct iaa_device *iaa_device,
struct iaa_device_compression_mode *device_mode)
{ … }
#define IDXD_OP_FLAG_AECS_RW_TGLS …
#define IAX_AECS_DEFAULT_FLAG …
#define IAX_AECS_COMPRESS_FLAG …
#define IAX_AECS_DECOMPRESS_FLAG …
#define IAX_AECS_GEN_FLAG …
static int check_completion(struct device *dev,
struct iax_completion_record *comp,
bool compress,
bool only_once);
static int init_device_compression_mode(struct iaa_device *iaa_device,
struct iaa_compression_mode *mode,
int idx, struct idxd_wq *wq)
{ … }
static int init_device_compression_modes(struct iaa_device *iaa_device,
struct idxd_wq *wq)
{ … }
static void remove_device_compression_modes(struct iaa_device *iaa_device)
{ … }
static struct iaa_device *iaa_device_alloc(void)
{ … }
static bool iaa_has_wq(struct iaa_device *iaa_device, struct idxd_wq *wq)
{ … }
static struct iaa_device *add_iaa_device(struct idxd_device *idxd)
{ … }
static int init_iaa_device(struct iaa_device *iaa_device, struct iaa_wq *iaa_wq)
{ … }
static void del_iaa_device(struct iaa_device *iaa_device)
{ … }
static int add_iaa_wq(struct iaa_device *iaa_device, struct idxd_wq *wq,
struct iaa_wq **new_wq)
{ … }
static void del_iaa_wq(struct iaa_device *iaa_device, struct idxd_wq *wq)
{ … }
static void clear_wq_table(void)
{ … }
static void free_iaa_device(struct iaa_device *iaa_device)
{ … }
static void __free_iaa_wq(struct iaa_wq *iaa_wq)
{ … }
static void free_iaa_wq(struct iaa_wq *iaa_wq)
{ … }
static int iaa_wq_get(struct idxd_wq *wq)
{ … }
static int iaa_wq_put(struct idxd_wq *wq)
{ … }
static void free_wq_table(void)
{ … }
static int alloc_wq_table(int max_wqs)
{ … }
static int save_iaa_wq(struct idxd_wq *wq)
{ … }
static void remove_iaa_wq(struct idxd_wq *wq)
{ … }
static int wq_table_add_wqs(int iaa, int cpu)
{ … }
static void rebalance_wq_table(void)
{ … }
static inline int check_completion(struct device *dev,
struct iax_completion_record *comp,
bool compress,
bool only_once)
{ … }
static int deflate_generic_decompress(struct acomp_req *req)
{ … }
static int iaa_remap_for_verify(struct device *dev, struct iaa_wq *iaa_wq,
struct acomp_req *req,
dma_addr_t *src_addr, dma_addr_t *dst_addr);
static int iaa_compress_verify(struct crypto_tfm *tfm, struct acomp_req *req,
struct idxd_wq *wq,
dma_addr_t src_addr, unsigned int slen,
dma_addr_t dst_addr, unsigned int *dlen,
u32 compression_crc);
static void iaa_desc_complete(struct idxd_desc *idxd_desc,
enum idxd_complete_type comp_type,
bool free_desc, void *__ctx,
u32 *status)
{ … }
static int iaa_compress(struct crypto_tfm *tfm, struct acomp_req *req,
struct idxd_wq *wq,
dma_addr_t src_addr, unsigned int slen,
dma_addr_t dst_addr, unsigned int *dlen,
u32 *compression_crc,
bool disable_async)
{ … }
static int iaa_remap_for_verify(struct device *dev, struct iaa_wq *iaa_wq,
struct acomp_req *req,
dma_addr_t *src_addr, dma_addr_t *dst_addr)
{ … }
static int iaa_compress_verify(struct crypto_tfm *tfm, struct acomp_req *req,
struct idxd_wq *wq,
dma_addr_t src_addr, unsigned int slen,
dma_addr_t dst_addr, unsigned int *dlen,
u32 compression_crc)
{ … }
static int iaa_decompress(struct crypto_tfm *tfm, struct acomp_req *req,
struct idxd_wq *wq,
dma_addr_t src_addr, unsigned int slen,
dma_addr_t dst_addr, unsigned int *dlen,
bool disable_async)
{ … }
static int iaa_comp_acompress(struct acomp_req *req)
{ … }
static int iaa_comp_adecompress_alloc_dest(struct acomp_req *req)
{ … }
static int iaa_comp_adecompress(struct acomp_req *req)
{ … }
static void compression_ctx_init(struct iaa_compression_ctx *ctx)
{ … }
static int iaa_comp_init_fixed(struct crypto_acomp *acomp_tfm)
{ … }
static void dst_free(struct scatterlist *sgl)
{ … }
static struct acomp_alg iaa_acomp_fixed_deflate = …;
static int iaa_register_compression_device(void)
{ … }
static int iaa_unregister_compression_device(void)
{ … }
static int iaa_crypto_probe(struct idxd_dev *idxd_dev)
{ … }
static void iaa_crypto_remove(struct idxd_dev *idxd_dev)
{ … }
static enum idxd_dev_type dev_types[] = …;
static struct idxd_device_driver iaa_crypto_driver = …;
static int __init iaa_crypto_init_module(void)
{ … }
static void __exit iaa_crypto_cleanup_module(void)
{ … }
MODULE_IMPORT_NS(…);
MODULE_LICENSE(…) …;
MODULE_ALIAS_IDXD_DEVICE(…);
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
module_init(…) …;
module_exit(iaa_crypto_cleanup_module);