Path: blob/master/drivers/crypto/intel/iaa/iaa_crypto.h
29281 views
/* SPDX-License-Identifier: GPL-2.0 */1/* Copyright(c) 2021 Intel Corporation. All rights rsvd. */23#ifndef __IAA_CRYPTO_H__4#define __IAA_CRYPTO_H__56#include <linux/crypto.h>7#include <linux/idxd.h>8#include <uapi/linux/idxd.h>910#define IDXD_SUBDRIVER_NAME "crypto"1112#define IAA_DECOMP_ENABLE BIT(0)13#define IAA_DECOMP_FLUSH_OUTPUT BIT(1)14#define IAA_DECOMP_CHECK_FOR_EOB BIT(2)15#define IAA_DECOMP_STOP_ON_EOB BIT(3)16#define IAA_DECOMP_SUPPRESS_OUTPUT BIT(9)1718#define IAA_COMP_FLUSH_OUTPUT BIT(1)19#define IAA_COMP_APPEND_EOB BIT(2)2021#define IAA_COMPLETION_TIMEOUT 10000002223#define IAA_ANALYTICS_ERROR 0x0a24#define IAA_ERROR_DECOMP_BUF_OVERFLOW 0x0b25#define IAA_ERROR_COMP_BUF_OVERFLOW 0x1926#define IAA_ERROR_WATCHDOG_EXPIRED 0x242728#define IAA_COMP_MODES_MAX 22930#define FIXED_HDR 0x231#define FIXED_HDR_SIZE 33233#define IAA_COMP_FLAGS (IAA_COMP_FLUSH_OUTPUT | \34IAA_COMP_APPEND_EOB)3536#define IAA_DECOMP_FLAGS (IAA_DECOMP_ENABLE | \37IAA_DECOMP_FLUSH_OUTPUT | \38IAA_DECOMP_CHECK_FOR_EOB | \39IAA_DECOMP_STOP_ON_EOB)4041/* Representation of IAA workqueue */42struct iaa_wq {43struct list_head list;4445struct idxd_wq *wq;46int ref;47bool remove;4849struct iaa_device *iaa_device;5051atomic64_t comp_calls;52atomic64_t comp_bytes;53atomic64_t decomp_calls;54atomic64_t decomp_bytes;55};5657struct iaa_device_compression_mode {58const char *name;5960struct aecs_comp_table_record *aecs_comp_table;6162dma_addr_t aecs_comp_table_dma_addr;63};6465/* Representation of IAA device with wqs, populated by probe */66struct iaa_device {67struct list_head list;68struct idxd_device *idxd;6970struct iaa_device_compression_mode *compression_modes[IAA_COMP_MODES_MAX];7172int n_wq;73struct list_head wqs;7475atomic64_t comp_calls;76atomic64_t comp_bytes;77atomic64_t decomp_calls;78atomic64_t decomp_bytes;79};8081struct wq_table_entry {82struct idxd_wq **wqs;83int max_wqs;84int n_wqs;85int cur_wq;86};8788#define IAA_AECS_ALIGN 328990/*91* Analytics Engine Configuration and State (AECS) contains parameters and92* internal state of the analytics engine.93*/94struct aecs_comp_table_record {95u32 crc;96u32 xor_checksum;97u32 reserved0[5];98u32 num_output_accum_bits;99u8 output_accum[256];100u32 ll_sym[286];101u32 reserved1;102u32 reserved2;103u32 d_sym[30];104u32 reserved_padding[2];105} __packed;106107int iaa_aecs_init_fixed(void);108void iaa_aecs_cleanup_fixed(void);109110typedef int (*iaa_dev_comp_init_fn_t) (struct iaa_device_compression_mode *mode);111typedef int (*iaa_dev_comp_free_fn_t) (struct iaa_device_compression_mode *mode);112113struct iaa_compression_mode {114const char *name;115u32 *ll_table;116int ll_table_size;117u32 *d_table;118int d_table_size;119iaa_dev_comp_init_fn_t init;120iaa_dev_comp_free_fn_t free;121};122123int add_iaa_compression_mode(const char *name,124const u32 *ll_table,125int ll_table_size,126const u32 *d_table,127int d_table_size,128iaa_dev_comp_init_fn_t init,129iaa_dev_comp_free_fn_t free);130131void remove_iaa_compression_mode(const char *name);132133enum iaa_mode {134IAA_MODE_FIXED,135};136137struct iaa_compression_ctx {138enum iaa_mode mode;139bool verify_compress;140bool async_mode;141bool use_irq;142};143144extern struct list_head iaa_devices;145extern struct mutex iaa_devices_lock;146147#endif148149150